xref: /dpdk/app/test-pmd/cmdline.c (revision d6f923ba)
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2010-2016 Intel Corporation.
3  * Copyright(c) 2014 6WIND S.A.
4  */
5 
6 #include <stdarg.h>
7 #include <errno.h>
8 #include <stdio.h>
9 #include <stdint.h>
10 #include <string.h>
11 #include <termios.h>
12 #include <unistd.h>
13 #include <inttypes.h>
14 #include <sys/socket.h>
15 #include <netinet/in.h>
16 
17 #include <sys/queue.h>
18 
19 #include <rte_common.h>
20 #include <rte_byteorder.h>
21 #include <rte_log.h>
22 #include <rte_debug.h>
23 #include <rte_cycles.h>
24 #include <rte_memory.h>
25 #include <rte_memzone.h>
26 #include <rte_malloc.h>
27 #include <rte_launch.h>
28 #include <rte_eal.h>
29 #include <rte_per_lcore.h>
30 #include <rte_lcore.h>
31 #include <rte_atomic.h>
32 #include <rte_branch_prediction.h>
33 #include <rte_ring.h>
34 #include <rte_mempool.h>
35 #include <rte_interrupts.h>
36 #include <rte_pci.h>
37 #include <rte_ether.h>
38 #include <rte_ethdev.h>
39 #include <rte_string_fns.h>
40 #include <rte_devargs.h>
41 #include <rte_flow.h>
42 #include <rte_gro.h>
43 #include <rte_mbuf_dyn.h>
44 
45 #include <cmdline_rdline.h>
46 #include <cmdline_parse.h>
47 #include <cmdline_parse_num.h>
48 #include <cmdline_parse_string.h>
49 #include <cmdline_parse_ipaddr.h>
50 #include <cmdline_parse_etheraddr.h>
51 #include <cmdline_socket.h>
52 #include <cmdline.h>
53 #ifdef RTE_LIBRTE_PMD_BOND
54 #include <rte_eth_bond.h>
55 #include <rte_eth_bond_8023ad.h>
56 #endif
57 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD
58 #include <rte_pmd_dpaa.h>
59 #endif
60 #ifdef RTE_LIBRTE_IXGBE_PMD
61 #include <rte_pmd_ixgbe.h>
62 #endif
63 #ifdef RTE_LIBRTE_I40E_PMD
64 #include <rte_pmd_i40e.h>
65 #endif
66 #ifdef RTE_LIBRTE_BNXT_PMD
67 #include <rte_pmd_bnxt.h>
68 #endif
69 #include "testpmd.h"
70 #include "cmdline_mtr.h"
71 #include "cmdline_tm.h"
72 #include "bpf_cmd.h"
73 
74 static struct cmdline *testpmd_cl;
75 
76 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
77 
78 /* *** Help command with introduction. *** */
79 struct cmd_help_brief_result {
80 	cmdline_fixed_string_t help;
81 };
82 
83 static void cmd_help_brief_parsed(__attribute__((unused)) void *parsed_result,
84                                   struct cmdline *cl,
85                                   __attribute__((unused)) void *data)
86 {
87 	cmdline_printf(
88 		cl,
89 		"\n"
90 		"Help is available for the following sections:\n\n"
91 		"    help control                    : Start and stop forwarding.\n"
92 		"    help display                    : Displaying port, stats and config "
93 		"information.\n"
94 		"    help config                     : Configuration information.\n"
95 		"    help ports                      : Configuring ports.\n"
96 		"    help registers                  : Reading and setting port registers.\n"
97 		"    help filters                    : Filters configuration help.\n"
98 		"    help traffic_management         : Traffic Management commmands.\n"
99 		"    help devices                    : Device related cmds.\n"
100 		"    help all                        : All of the above sections.\n\n"
101 	);
102 
103 }
104 
105 cmdline_parse_token_string_t cmd_help_brief_help =
106 	TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
107 
108 cmdline_parse_inst_t cmd_help_brief = {
109 	.f = cmd_help_brief_parsed,
110 	.data = NULL,
111 	.help_str = "help: Show help",
112 	.tokens = {
113 		(void *)&cmd_help_brief_help,
114 		NULL,
115 	},
116 };
117 
118 /* *** Help command with help sections. *** */
119 struct cmd_help_long_result {
120 	cmdline_fixed_string_t help;
121 	cmdline_fixed_string_t section;
122 };
123 
124 static void cmd_help_long_parsed(void *parsed_result,
125                                  struct cmdline *cl,
126                                  __attribute__((unused)) void *data)
127 {
128 	int show_all = 0;
129 	struct cmd_help_long_result *res = parsed_result;
130 
131 	if (!strcmp(res->section, "all"))
132 		show_all = 1;
133 
134 	if (show_all || !strcmp(res->section, "control")) {
135 
136 		cmdline_printf(
137 			cl,
138 			"\n"
139 			"Control forwarding:\n"
140 			"-------------------\n\n"
141 
142 			"start\n"
143 			"    Start packet forwarding with current configuration.\n\n"
144 
145 			"start tx_first\n"
146 			"    Start packet forwarding with current config"
147 			" after sending one burst of packets.\n\n"
148 
149 			"stop\n"
150 			"    Stop packet forwarding, and display accumulated"
151 			" statistics.\n\n"
152 
153 			"quit\n"
154 			"    Quit to prompt.\n\n"
155 		);
156 	}
157 
158 	if (show_all || !strcmp(res->section, "display")) {
159 
160 		cmdline_printf(
161 			cl,
162 			"\n"
163 			"Display:\n"
164 			"--------\n\n"
165 
166 			"show port (info|stats|summary|xstats|fdir|stat_qmap|dcb_tc|cap) (port_id|all)\n"
167 			"    Display information for port_id, or all.\n\n"
168 
169 			"show port X rss reta (size) (mask0,mask1,...)\n"
170 			"    Display the rss redirection table entry indicated"
171 			" by masks on port X. size is used to indicate the"
172 			" hardware supported reta size\n\n"
173 
174 			"show port (port_id) rss-hash [key]\n"
175 			"    Display the RSS hash functions and RSS hash key of port\n\n"
176 
177 			"clear port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n"
178 			"    Clear information for port_id, or all.\n\n"
179 
180 			"show (rxq|txq) info (port_id) (queue_id)\n"
181 			"    Display information for configured RX/TX queue.\n\n"
182 
183 			"show config (rxtx|cores|fwd|txpkts)\n"
184 			"    Display the given configuration.\n\n"
185 
186 			"read rxd (port_id) (queue_id) (rxd_id)\n"
187 			"    Display an RX descriptor of a port RX queue.\n\n"
188 
189 			"read txd (port_id) (queue_id) (txd_id)\n"
190 			"    Display a TX descriptor of a port TX queue.\n\n"
191 
192 			"ddp get list (port_id)\n"
193 			"    Get ddp profile info list\n\n"
194 
195 			"ddp get info (profile_path)\n"
196 			"    Get ddp profile information.\n\n"
197 
198 			"show vf stats (port_id) (vf_id)\n"
199 			"    Display a VF's statistics.\n\n"
200 
201 			"clear vf stats (port_id) (vf_id)\n"
202 			"    Reset a VF's statistics.\n\n"
203 
204 			"show port (port_id) pctype mapping\n"
205 			"    Get flow ptype to pctype mapping on a port\n\n"
206 
207 			"show port meter stats (port_id) (meter_id) (clear)\n"
208 			"    Get meter stats on a port\n\n"
209 
210 			"show fwd stats all\n"
211 			"    Display statistics for all fwd engines.\n\n"
212 
213 			"clear fwd stats all\n"
214 			"    Clear statistics for all fwd engines.\n\n"
215 
216 			"show port (port_id) rx_offload capabilities\n"
217 			"    List all per queue and per port Rx offloading"
218 			" capabilities of a port\n\n"
219 
220 			"show port (port_id) rx_offload configuration\n"
221 			"    List port level and all queue level"
222 			" Rx offloading configuration\n\n"
223 
224 			"show port (port_id) tx_offload capabilities\n"
225 			"    List all per queue and per port"
226 			" Tx offloading capabilities of a port\n\n"
227 
228 			"show port (port_id) tx_offload configuration\n"
229 			"    List port level and all queue level"
230 			" Tx offloading configuration\n\n"
231 
232 			"show port (port_id) tx_metadata\n"
233 			"    Show Tx metadata value set"
234 			" for a specific port\n\n"
235 
236 			"show port (port_id) ptypes\n"
237 			"    Show port supported ptypes"
238 			" for a specific port\n\n"
239 
240 			"show device info (<identifier>|all)"
241 			"       Show general information about devices probed.\n\n"
242 
243 			"show port (port_id) rxq|txq (queue_id) desc (desc_id) status"
244 			"       Show status of rx|tx descriptor.\n\n"
245 
246 			"show port (port_id) macs|mcast_macs"
247 			"       Display list of mac addresses added to port.\n\n"
248 		);
249 	}
250 
251 	if (show_all || !strcmp(res->section, "config")) {
252 		cmdline_printf(
253 			cl,
254 			"\n"
255 			"Configuration:\n"
256 			"--------------\n"
257 			"Configuration changes only become active when"
258 			" forwarding is started/restarted.\n\n"
259 
260 			"set default\n"
261 			"    Reset forwarding to the default configuration.\n\n"
262 
263 			"set verbose (level)\n"
264 			"    Set the debug verbosity level X.\n\n"
265 
266 			"set log global|(type) (level)\n"
267 			"    Set the log level.\n\n"
268 
269 			"set nbport (num)\n"
270 			"    Set number of ports.\n\n"
271 
272 			"set nbcore (num)\n"
273 			"    Set number of cores.\n\n"
274 
275 			"set coremask (mask)\n"
276 			"    Set the forwarding cores hexadecimal mask.\n\n"
277 
278 			"set portmask (mask)\n"
279 			"    Set the forwarding ports hexadecimal mask.\n\n"
280 
281 			"set burst (num)\n"
282 			"    Set number of packets per burst.\n\n"
283 
284 			"set burst tx delay (microseconds) retry (num)\n"
285 			"    Set the transmit delay time and number of retries,"
286 			" effective when retry is enabled.\n\n"
287 
288 			"set txpkts (x[,y]*)\n"
289 			"    Set the length of each segment of TXONLY"
290 			" and optionally CSUM packets.\n\n"
291 
292 			"set txsplit (off|on|rand)\n"
293 			"    Set the split policy for the TX packets."
294 			" Right now only applicable for CSUM and TXONLY"
295 			" modes\n\n"
296 
297 			"set corelist (x[,y]*)\n"
298 			"    Set the list of forwarding cores.\n\n"
299 
300 			"set portlist (x[,y]*)\n"
301 			"    Set the list of forwarding ports.\n\n"
302 
303 			"set port setup on (iterator|event)\n"
304 			"    Select how attached port is retrieved for setup.\n\n"
305 
306 			"set tx loopback (port_id) (on|off)\n"
307 			"    Enable or disable tx loopback.\n\n"
308 
309 			"set all queues drop (port_id) (on|off)\n"
310 			"    Set drop enable bit for all queues.\n\n"
311 
312 			"set vf split drop (port_id) (vf_id) (on|off)\n"
313 			"    Set split drop enable bit for a VF from the PF.\n\n"
314 
315 			"set vf mac antispoof (port_id) (vf_id) (on|off).\n"
316 			"    Set MAC antispoof for a VF from the PF.\n\n"
317 
318 			"set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n"
319 			"    Enable MACsec offload.\n\n"
320 
321 			"set macsec offload (port_id) off\n"
322 			"    Disable MACsec offload.\n\n"
323 
324 			"set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
325 			"    Configure MACsec secure connection (SC).\n\n"
326 
327 			"set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n"
328 			"    Configure MACsec secure association (SA).\n\n"
329 
330 			"set vf broadcast (port_id) (vf_id) (on|off)\n"
331 			"    Set VF broadcast for a VF from the PF.\n\n"
332 
333 			"vlan set stripq (on|off) (port_id,queue_id)\n"
334 			"    Set the VLAN strip for a queue on a port.\n\n"
335 
336 			"set vf vlan stripq (port_id) (vf_id) (on|off)\n"
337 			"    Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
338 
339 			"set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
340 			"    Set VLAN insert for a VF from the PF.\n\n"
341 
342 			"set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
343 			"    Set VLAN antispoof for a VF from the PF.\n\n"
344 
345 			"set vf vlan tag (port_id) (vf_id) (on|off)\n"
346 			"    Set VLAN tag for a VF from the PF.\n\n"
347 
348 			"set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n"
349 			"    Set a VF's max bandwidth(Mbps).\n\n"
350 
351 			"set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n"
352 			"    Set all TCs' min bandwidth(%%) on a VF.\n\n"
353 
354 			"set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n"
355 			"    Set a TC's max bandwidth(Mbps) on a VF.\n\n"
356 
357 			"set tx strict-link-priority (port_id) (tc_bitmap)\n"
358 			"    Set some TCs' strict link priority mode on a physical port.\n\n"
359 
360 			"set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n"
361 			"    Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n"
362 
363 			"vlan set (strip|filter|qinq_strip|extend) (on|off) (port_id)\n"
364 			"    Set the VLAN strip or filter or qinq strip or extend\n\n"
365 
366 			"vlan set (inner|outer) tpid (value) (port_id)\n"
367 			"    Set the VLAN TPID for Packet Filtering on"
368 			" a port\n\n"
369 
370 			"rx_vlan add (vlan_id|all) (port_id)\n"
371 			"    Add a vlan_id, or all identifiers, to the set"
372 			" of VLAN identifiers filtered by port_id.\n\n"
373 
374 			"rx_vlan rm (vlan_id|all) (port_id)\n"
375 			"    Remove a vlan_id, or all identifiers, from the set"
376 			" of VLAN identifiers filtered by port_id.\n\n"
377 
378 			"rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
379 			"    Add a vlan_id, to the set of VLAN identifiers"
380 			"filtered for VF(s) from port_id.\n\n"
381 
382 			"rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
383 			"    Remove a vlan_id, to the set of VLAN identifiers"
384 			"filtered for VF(s) from port_id.\n\n"
385 
386 			"tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) "
387 			"(inner_vlan) (vxlan|nvgre|ipingre|vxlan-gpe) (imac-ivlan|imac-ivlan-tenid|"
388 			"imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
389 			"   add a tunnel filter of a port.\n\n"
390 
391 			"tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) "
392 			"(inner_vlan) (vxlan|nvgre|ipingre|vxlan-gpe) (imac-ivlan|imac-ivlan-tenid|"
393 			"imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
394 			"   remove a tunnel filter of a port.\n\n"
395 
396 			"rx_vxlan_port add (udp_port) (port_id)\n"
397 			"    Add an UDP port for VXLAN packet filter on a port\n\n"
398 
399 			"rx_vxlan_port rm (udp_port) (port_id)\n"
400 			"    Remove an UDP port for VXLAN packet filter on a port\n\n"
401 
402 			"tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
403 			"    Set hardware insertion of VLAN IDs (single or double VLAN "
404 			"depends on the number of VLAN IDs) in packets sent on a port.\n\n"
405 
406 			"tx_vlan set pvid port_id vlan_id (on|off)\n"
407 			"    Set port based TX VLAN insertion.\n\n"
408 
409 			"tx_vlan reset (port_id)\n"
410 			"    Disable hardware insertion of a VLAN header in"
411 			" packets sent on a port.\n\n"
412 
413 			"csum set (ip|udp|tcp|sctp|outer-ip|outer-udp) (hw|sw) (port_id)\n"
414 			"    Select hardware or software calculation of the"
415 			" checksum when transmitting a packet using the"
416 			" csum forward engine.\n"
417 			"    ip|udp|tcp|sctp always concern the inner layer.\n"
418 			"    outer-ip concerns the outer IP layer in"
419 			"    outer-udp concerns the outer UDP layer in"
420 			" case the packet is recognized as a tunnel packet by"
421 			" the forward engine (vxlan, gre and ipip are supported)\n"
422 			"    Please check the NIC datasheet for HW limits.\n\n"
423 
424 			"csum parse-tunnel (on|off) (tx_port_id)\n"
425 			"    If disabled, treat tunnel packets as non-tunneled"
426 			" packets (treat inner headers as payload). The port\n"
427 			"    argument is the port used for TX in csum forward"
428 			" engine.\n\n"
429 
430 			"csum show (port_id)\n"
431 			"    Display tx checksum offload configuration\n\n"
432 
433 			"tso set (segsize) (portid)\n"
434 			"    Enable TCP Segmentation Offload in csum forward"
435 			" engine.\n"
436 			"    Please check the NIC datasheet for HW limits.\n\n"
437 
438 			"tso show (portid)"
439 			"    Display the status of TCP Segmentation Offload.\n\n"
440 
441 			"set port (port_id) gro on|off\n"
442 			"    Enable or disable Generic Receive Offload in"
443 			" csum forwarding engine.\n\n"
444 
445 			"show port (port_id) gro\n"
446 			"    Display GRO configuration.\n\n"
447 
448 			"set gro flush (cycles)\n"
449 			"    Set the cycle to flush GROed packets from"
450 			" reassembly tables.\n\n"
451 
452 			"set port (port_id) gso (on|off)"
453 			"    Enable or disable Generic Segmentation Offload in"
454 			" csum forwarding engine.\n\n"
455 
456 			"set gso segsz (length)\n"
457 			"    Set max packet length for output GSO segments,"
458 			" including packet header and payload.\n\n"
459 
460 			"show port (port_id) gso\n"
461 			"    Show GSO configuration.\n\n"
462 
463 			"set fwd (%s)\n"
464 			"    Set packet forwarding mode.\n\n"
465 
466 			"mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
467 			"    Add a MAC address on port_id.\n\n"
468 
469 			"mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
470 			"    Remove a MAC address from port_id.\n\n"
471 
472 			"mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
473 			"    Set the default MAC address for port_id.\n\n"
474 
475 			"mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
476 			"    Add a MAC address for a VF on the port.\n\n"
477 
478 			"set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
479 			"    Set the MAC address for a VF from the PF.\n\n"
480 
481 			"set eth-peer (port_id) (peer_addr)\n"
482 			"    set the peer address for certain port.\n\n"
483 
484 			"set port (port_id) uta (mac_address|all) (on|off)\n"
485 			"    Add/Remove a or all unicast hash filter(s)"
486 			"from port X.\n\n"
487 
488 			"set promisc (port_id|all) (on|off)\n"
489 			"    Set the promiscuous mode on port_id, or all.\n\n"
490 
491 			"set allmulti (port_id|all) (on|off)\n"
492 			"    Set the allmulti mode on port_id, or all.\n\n"
493 
494 			"set vf promisc (port_id) (vf_id) (on|off)\n"
495 			"    Set unicast promiscuous mode for a VF from the PF.\n\n"
496 
497 			"set vf allmulti (port_id) (vf_id) (on|off)\n"
498 			"    Set multicast promiscuous mode for a VF from the PF.\n\n"
499 
500 			"set flow_ctrl rx (on|off) tx (on|off) (high_water)"
501 			" (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
502 			" (on|off) autoneg (on|off) (port_id)\n"
503 			"set flow_ctrl rx (on|off) (portid)\n"
504 			"set flow_ctrl tx (on|off) (portid)\n"
505 			"set flow_ctrl high_water (high_water) (portid)\n"
506 			"set flow_ctrl low_water (low_water) (portid)\n"
507 			"set flow_ctrl pause_time (pause_time) (portid)\n"
508 			"set flow_ctrl send_xon (send_xon) (portid)\n"
509 			"set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
510 			"set flow_ctrl autoneg (on|off) (port_id)\n"
511 			"    Set the link flow control parameter on a port.\n\n"
512 
513 			"set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
514 			" (low_water) (pause_time) (priority) (port_id)\n"
515 			"    Set the priority flow control parameter on a"
516 			" port.\n\n"
517 
518 			"set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
519 			"    Set statistics mapping (qmapping 0..15) for RX/TX"
520 			" queue on port.\n"
521 			"    e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
522 			" on port 0 to mapping 5.\n\n"
523 
524 			"set xstats-hide-zero on|off\n"
525 			"    Set the option to hide the zero values"
526 			" for xstats display.\n"
527 
528 			"set port (port_id) vf (vf_id) rx|tx on|off\n"
529 			"    Enable/Disable a VF receive/tranmit from a port\n\n"
530 
531 			"set port (port_id) vf (vf_id) (mac_addr)"
532 			" (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
533 			"   Add/Remove unicast or multicast MAC addr filter"
534 			" for a VF.\n\n"
535 
536 			"set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
537 			"|MPE) (on|off)\n"
538 			"    AUPE:accepts untagged VLAN;"
539 			"ROPE:accept unicast hash\n\n"
540 			"    BAM:accepts broadcast packets;"
541 			"MPE:accepts all multicast packets\n\n"
542 			"    Enable/Disable a VF receive mode of a port\n\n"
543 
544 			"set port (port_id) queue (queue_id) rate (rate_num)\n"
545 			"    Set rate limit for a queue of a port\n\n"
546 
547 			"set port (port_id) vf (vf_id) rate (rate_num) "
548 			"queue_mask (queue_mask_value)\n"
549 			"    Set rate limit for queues in VF of a port\n\n"
550 
551 			"set port (port_id) mirror-rule (rule_id)"
552 			" (pool-mirror-up|pool-mirror-down|vlan-mirror)"
553 			" (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
554 			"   Set pool or vlan type mirror rule on a port.\n"
555 			"   e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
556 			" dst-pool 0 on' enable mirror traffic with vlan 0,1"
557 			" to pool 0.\n\n"
558 
559 			"set port (port_id) mirror-rule (rule_id)"
560 			" (uplink-mirror|downlink-mirror) dst-pool"
561 			" (pool_id) (on|off)\n"
562 			"   Set uplink or downlink type mirror rule on a port.\n"
563 			"   e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
564 			" 0 on' enable mirror income traffic to pool 0.\n\n"
565 
566 			"reset port (port_id) mirror-rule (rule_id)\n"
567 			"   Reset a mirror rule.\n\n"
568 
569 			"set flush_rx (on|off)\n"
570 			"   Flush (default) or don't flush RX streams before"
571 			" forwarding. Mainly used with PCAP drivers.\n\n"
572 
573 			"set bypass mode (normal|bypass|isolate) (port_id)\n"
574 			"   Set the bypass mode for the lowest port on bypass enabled"
575 			" NIC.\n\n"
576 
577 			"set bypass event (timeout|os_on|os_off|power_on|power_off) "
578 			"mode (normal|bypass|isolate) (port_id)\n"
579 			"   Set the event required to initiate specified bypass mode for"
580 			" the lowest port on a bypass enabled NIC where:\n"
581 			"       timeout   = enable bypass after watchdog timeout.\n"
582 			"       os_on     = enable bypass when OS/board is powered on.\n"
583 			"       os_off    = enable bypass when OS/board is powered off.\n"
584 			"       power_on  = enable bypass when power supply is turned on.\n"
585 			"       power_off = enable bypass when power supply is turned off."
586 			"\n\n"
587 
588 			"set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
589 			"   Set the bypass watchdog timeout to 'n' seconds"
590 			" where 0 = instant.\n\n"
591 
592 			"show bypass config (port_id)\n"
593 			"   Show the bypass configuration for a bypass enabled NIC"
594 			" using the lowest port on the NIC.\n\n"
595 
596 #ifdef RTE_LIBRTE_PMD_BOND
597 			"create bonded device (mode) (socket)\n"
598 			"	Create a new bonded device with specific bonding mode and socket.\n\n"
599 
600 			"add bonding slave (slave_id) (port_id)\n"
601 			"	Add a slave device to a bonded device.\n\n"
602 
603 			"remove bonding slave (slave_id) (port_id)\n"
604 			"	Remove a slave device from a bonded device.\n\n"
605 
606 			"set bonding mode (value) (port_id)\n"
607 			"	Set the bonding mode on a bonded device.\n\n"
608 
609 			"set bonding primary (slave_id) (port_id)\n"
610 			"	Set the primary slave for a bonded device.\n\n"
611 
612 			"show bonding config (port_id)\n"
613 			"	Show the bonding config for port_id.\n\n"
614 
615 			"set bonding mac_addr (port_id) (address)\n"
616 			"	Set the MAC address of a bonded device.\n\n"
617 
618 			"set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)"
619 			"	Set Aggregation mode for IEEE802.3AD (mode 4)"
620 
621 			"set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
622 			"	Set the transmit balance policy for bonded device running in balance mode.\n\n"
623 
624 			"set bonding mon_period (port_id) (value)\n"
625 			"	Set the bonding link status monitoring polling period in ms.\n\n"
626 
627 			"set bonding lacp dedicated_queues <port_id> (enable|disable)\n"
628 			"	Enable/disable dedicated queues for LACP control traffic.\n\n"
629 
630 #endif
631 			"set link-up port (port_id)\n"
632 			"	Set link up for a port.\n\n"
633 
634 			"set link-down port (port_id)\n"
635 			"	Set link down for a port.\n\n"
636 
637 			"E-tag set insertion on port-tag-id (value)"
638 			" port (port_id) vf (vf_id)\n"
639 			"    Enable E-tag insertion for a VF on a port\n\n"
640 
641 			"E-tag set insertion off port (port_id) vf (vf_id)\n"
642 			"    Disable E-tag insertion for a VF on a port\n\n"
643 
644 			"E-tag set stripping (on|off) port (port_id)\n"
645 			"    Enable/disable E-tag stripping on a port\n\n"
646 
647 			"E-tag set forwarding (on|off) port (port_id)\n"
648 			"    Enable/disable E-tag based forwarding"
649 			" on a port\n\n"
650 
651 			"E-tag set filter add e-tag-id (value) dst-pool"
652 			" (pool_id) port (port_id)\n"
653 			"    Add an E-tag forwarding filter on a port\n\n"
654 
655 			"E-tag set filter del e-tag-id (value) port (port_id)\n"
656 			"    Delete an E-tag forwarding filter on a port\n\n"
657 
658 			"ddp add (port_id) (profile_path[,backup_profile_path])\n"
659 			"    Load a profile package on a port\n\n"
660 
661 			"ddp del (port_id) (backup_profile_path)\n"
662 			"    Delete a profile package from a port\n\n"
663 
664 			"ptype mapping get (port_id) (valid_only)\n"
665 			"    Get ptype mapping on a port\n\n"
666 
667 			"ptype mapping replace (port_id) (target) (mask) (pky_type)\n"
668 			"    Replace target with the pkt_type in ptype mapping\n\n"
669 
670 			"ptype mapping reset (port_id)\n"
671 			"    Reset ptype mapping on a port\n\n"
672 
673 			"ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n"
674 			"    Update a ptype mapping item on a port\n\n"
675 
676 			"set port (port_id) ptype_mask (ptype_mask)\n"
677 			"    set packet types classification for a specific port\n\n"
678 
679 			"set port (port_id) queue-region region_id (value) "
680 			"queue_start_index (value) queue_num (value)\n"
681 			"    Set a queue region on a port\n\n"
682 
683 			"set port (port_id) queue-region region_id (value) "
684 			"flowtype (value)\n"
685 			"    Set a flowtype region index on a port\n\n"
686 
687 			"set port (port_id) queue-region UP (value) region_id (value)\n"
688 			"    Set the mapping of User Priority to "
689 			"queue region on a port\n\n"
690 
691 			"set port (port_id) queue-region flush (on|off)\n"
692 			"    flush all queue region related configuration\n\n"
693 
694 			"show port meter cap (port_id)\n"
695 			"    Show port meter capability information\n\n"
696 
697 			"add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs)\n"
698 			"    meter profile add - srtcm rfc 2697\n\n"
699 
700 			"add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs)\n"
701 			"    meter profile add - trtcm rfc 2698\n\n"
702 
703 			"add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs)\n"
704 			"    meter profile add - trtcm rfc 4115\n\n"
705 
706 			"del port meter profile (port_id) (profile_id)\n"
707 			"    meter profile delete\n\n"
708 
709 			"create port meter (port_id) (mtr_id) (profile_id) (meter_enable)\n"
710 			"(g_action) (y_action) (r_action) (stats_mask) (shared)\n"
711 			"(use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n"
712 			"(dscp_tbl_entry63)]\n"
713 			"    meter create\n\n"
714 
715 			"enable port meter (port_id) (mtr_id)\n"
716 			"    meter enable\n\n"
717 
718 			"disable port meter (port_id) (mtr_id)\n"
719 			"    meter disable\n\n"
720 
721 			"del port meter (port_id) (mtr_id)\n"
722 			"    meter delete\n\n"
723 
724 			"set port meter profile (port_id) (mtr_id) (profile_id)\n"
725 			"    meter update meter profile\n\n"
726 
727 			"set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n"
728 			"(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n"
729 			"    update meter dscp table entries\n\n"
730 
731 			"set port meter policer action (port_id) (mtr_id) (action_mask)\n"
732 			"(action0) [(action1) (action2)]\n"
733 			"    meter update policer action\n\n"
734 
735 			"set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
736 			"    meter update stats\n\n"
737 
738 			"show port (port_id) queue-region\n"
739 			"    show all queue region related configuration info\n\n"
740 
741 			, list_pkt_forwarding_modes()
742 		);
743 	}
744 
745 	if (show_all || !strcmp(res->section, "ports")) {
746 
747 		cmdline_printf(
748 			cl,
749 			"\n"
750 			"Port Operations:\n"
751 			"----------------\n\n"
752 
753 			"port start (port_id|all)\n"
754 			"    Start all ports or port_id.\n\n"
755 
756 			"port stop (port_id|all)\n"
757 			"    Stop all ports or port_id.\n\n"
758 
759 			"port close (port_id|all)\n"
760 			"    Close all ports or port_id.\n\n"
761 
762 			"port reset (port_id|all)\n"
763 			"    Reset all ports or port_id.\n\n"
764 
765 			"port attach (ident)\n"
766 			"    Attach physical or virtual dev by pci address or virtual device name\n\n"
767 
768 			"port detach (port_id)\n"
769 			"    Detach physical or virtual dev by port_id\n\n"
770 
771 			"port config (port_id|all)"
772 			" speed (10|100|1000|10000|25000|40000|50000|100000|auto)"
773 			" duplex (half|full|auto)\n"
774 			"    Set speed and duplex for all ports or port_id\n\n"
775 
776 			"port config (port_id|all) loopback (mode)\n"
777 			"    Set loopback mode for all ports or port_id\n\n"
778 
779 			"port config all (rxq|txq|rxd|txd) (value)\n"
780 			"    Set number for rxq/txq/rxd/txd.\n\n"
781 
782 			"port config all max-pkt-len (value)\n"
783 			"    Set the max packet length.\n\n"
784 
785 			"port config all max-lro-pkt-size (value)\n"
786 			"    Set the max LRO aggregated packet size.\n\n"
787 
788 			"port config all drop-en (on|off)\n"
789 			"    Enable or disable packet drop on all RX queues of all ports when no "
790 			"receive buffers available.\n\n"
791 
792 			"port config all rss (all|default|ip|tcp|udp|sctp|"
793 			"ether|port|vxlan|geneve|nvgre|vxlan-gpe|none|<flowtype_id>)\n"
794 			"    Set the RSS mode.\n\n"
795 
796 			"port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
797 			"    Set the RSS redirection table.\n\n"
798 
799 			"port config (port_id) dcb vt (on|off) (traffic_class)"
800 			" pfc (on|off)\n"
801 			"    Set the DCB mode.\n\n"
802 
803 			"port config all burst (value)\n"
804 			"    Set the number of packets per burst.\n\n"
805 
806 			"port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
807 			" (value)\n"
808 			"    Set the ring prefetch/host/writeback threshold"
809 			" for tx/rx queue.\n\n"
810 
811 			"port config all (txfreet|txrst|rxfreet) (value)\n"
812 			"    Set free threshold for rx/tx, or set"
813 			" tx rs bit threshold.\n\n"
814 			"port config mtu X value\n"
815 			"    Set the MTU of port X to a given value\n\n"
816 
817 			"port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n"
818 			"    Set a rx/tx queue's ring size configuration, the new"
819 			" value will take effect after command that (re-)start the port"
820 			" or command that setup the specific queue\n\n"
821 
822 			"port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
823 			"    Start/stop a rx/tx queue of port X. Only take effect"
824 			" when port X is started\n\n"
825 
826 			"port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n"
827 			"    Switch on/off a deferred start of port X rx/tx queue. Only"
828 			" take effect when port X is stopped.\n\n"
829 
830 			"port (port_id) (rxq|txq) (queue_id) setup\n"
831 			"    Setup a rx/tx queue of port X.\n\n"
832 
833 			"port config (port_id|all) l2-tunnel E-tag ether-type"
834 			" (value)\n"
835 			"    Set the value of E-tag ether-type.\n\n"
836 
837 			"port config (port_id|all) l2-tunnel E-tag"
838 			" (enable|disable)\n"
839 			"    Enable/disable the E-tag support.\n\n"
840 
841 			"port config (port_id) pctype mapping reset\n"
842 			"    Reset flow type to pctype mapping on a port\n\n"
843 
844 			"port config (port_id) pctype mapping update"
845 			" (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
846 			"    Update a flow type to pctype mapping item on a port\n\n"
847 
848 			"port config (port_id) pctype (pctype_id) hash_inset|"
849 			"fdir_inset|fdir_flx_inset get|set|clear field\n"
850 			" (field_idx)\n"
851 			"    Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n"
852 
853 			"port config (port_id) pctype (pctype_id) hash_inset|"
854 			"fdir_inset|fdir_flx_inset clear all"
855 			"    Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n"
856 
857 			"port config (port_id) udp_tunnel_port add|rm vxlan|geneve (udp_port)\n\n"
858 			"    Add/remove UDP tunnel port for tunneling offload\n\n"
859 
860 			"port config <port_id> rx_offload vlan_strip|"
861 			"ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
862 			"outer_ipv4_cksum|macsec_strip|header_split|"
863 			"vlan_filter|vlan_extend|jumbo_frame|"
864 			"scatter|timestamp|security|keep_crc on|off\n"
865 			"     Enable or disable a per port Rx offloading"
866 			" on all Rx queues of a port\n\n"
867 
868 			"port (port_id) rxq (queue_id) rx_offload vlan_strip|"
869 			"ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
870 			"outer_ipv4_cksum|macsec_strip|header_split|"
871 			"vlan_filter|vlan_extend|jumbo_frame|"
872 			"scatter|timestamp|security|keep_crc on|off\n"
873 			"    Enable or disable a per queue Rx offloading"
874 			" only on a specific Rx queue\n\n"
875 
876 			"port config (port_id) tx_offload vlan_insert|"
877 			"ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
878 			"udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
879 			"gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|"
880 			"macsec_insert|mt_lockfree|multi_segs|mbuf_fast_free|"
881 			"security on|off\n"
882 			"    Enable or disable a per port Tx offloading"
883 			" on all Tx queues of a port\n\n"
884 
885 			"port (port_id) txq (queue_id) tx_offload vlan_insert|"
886 			"ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
887 			"udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
888 			"gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|macsec_insert"
889 			"|mt_lockfree|multi_segs|mbuf_fast_free|security"
890 			" on|off\n"
891 			"    Enable or disable a per queue Tx offloading"
892 			" only on a specific Tx queue\n\n"
893 
894 			"bpf-load rx|tx (port) (queue) (J|M|B) (file_name)\n"
895 			"    Load an eBPF program as a callback"
896 			" for particular RX/TX queue\n\n"
897 
898 			"bpf-unload rx|tx (port) (queue)\n"
899 			"    Unload previously loaded eBPF program"
900 			" for particular RX/TX queue\n\n"
901 
902 			"port config (port_id) tx_metadata (value)\n"
903 			"    Set Tx metadata value per port. Testpmd will add this value"
904 			" to any Tx packet sent from this port\n\n"
905 
906 			"port config (port_id) dynf (name) set|clear\n"
907 			"    Register a dynf and Set/clear this flag on Tx. "
908 			"Testpmd will set this value to any Tx packet "
909 			"sent from this port\n\n"
910 		);
911 	}
912 
913 	if (show_all || !strcmp(res->section, "registers")) {
914 
915 		cmdline_printf(
916 			cl,
917 			"\n"
918 			"Registers:\n"
919 			"----------\n\n"
920 
921 			"read reg (port_id) (address)\n"
922 			"    Display value of a port register.\n\n"
923 
924 			"read regfield (port_id) (address) (bit_x) (bit_y)\n"
925 			"    Display a port register bit field.\n\n"
926 
927 			"read regbit (port_id) (address) (bit_x)\n"
928 			"    Display a single port register bit.\n\n"
929 
930 			"write reg (port_id) (address) (value)\n"
931 			"    Set value of a port register.\n\n"
932 
933 			"write regfield (port_id) (address) (bit_x) (bit_y)"
934 			" (value)\n"
935 			"    Set bit field of a port register.\n\n"
936 
937 			"write regbit (port_id) (address) (bit_x) (value)\n"
938 			"    Set single bit value of a port register.\n\n"
939 		);
940 	}
941 	if (show_all || !strcmp(res->section, "filters")) {
942 
943 		cmdline_printf(
944 			cl,
945 			"\n"
946 			"filters:\n"
947 			"--------\n\n"
948 
949 			"ethertype_filter (port_id) (add|del)"
950 			" (mac_addr|mac_ignr) (mac_address) ethertype"
951 			" (ether_type) (drop|fwd) queue (queue_id)\n"
952 			"    Add/Del an ethertype filter.\n\n"
953 
954 			"2tuple_filter (port_id) (add|del)"
955 			" dst_port (dst_port_value) protocol (protocol_value)"
956 			" mask (mask_value) tcp_flags (tcp_flags_value)"
957 			" priority (prio_value) queue (queue_id)\n"
958 			"    Add/Del a 2tuple filter.\n\n"
959 
960 			"5tuple_filter (port_id) (add|del)"
961 			" dst_ip (dst_address) src_ip (src_address)"
962 			" dst_port (dst_port_value) src_port (src_port_value)"
963 			" protocol (protocol_value)"
964 			" mask (mask_value) tcp_flags (tcp_flags_value)"
965 			" priority (prio_value) queue (queue_id)\n"
966 			"    Add/Del a 5tuple filter.\n\n"
967 
968 			"syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
969 			"    Add/Del syn filter.\n\n"
970 
971 			"flex_filter (port_id) (add|del) len (len_value)"
972 			" bytes (bytes_value) mask (mask_value)"
973 			" priority (prio_value) queue (queue_id)\n"
974 			"    Add/Del a flex filter.\n\n"
975 
976 			"flow_director_filter (port_id) mode IP (add|del|update)"
977 			" flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
978 			" src (src_ip_address) dst (dst_ip_address)"
979 			" tos (tos_value) proto (proto_value) ttl (ttl_value)"
980 			" vlan (vlan_value) flexbytes (flexbytes_value)"
981 			" (drop|fwd) pf|vf(vf_id) queue (queue_id)"
982 			" fd_id (fd_id_value)\n"
983 			"    Add/Del an IP type flow director filter.\n\n"
984 
985 			"flow_director_filter (port_id) mode IP (add|del|update)"
986 			" flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
987 			" src (src_ip_address) (src_port)"
988 			" dst (dst_ip_address) (dst_port)"
989 			" tos (tos_value) ttl (ttl_value)"
990 			" vlan (vlan_value) flexbytes (flexbytes_value)"
991 			" (drop|fwd) pf|vf(vf_id) queue (queue_id)"
992 			" fd_id (fd_id_value)\n"
993 			"    Add/Del an UDP/TCP type flow director filter.\n\n"
994 
995 			"flow_director_filter (port_id) mode IP (add|del|update)"
996 			" flow (ipv4-sctp|ipv6-sctp)"
997 			" src (src_ip_address) (src_port)"
998 			" dst (dst_ip_address) (dst_port)"
999 			" tag (verification_tag) "
1000 			" tos (tos_value) ttl (ttl_value)"
1001 			" vlan (vlan_value)"
1002 			" flexbytes (flexbytes_value) (drop|fwd)"
1003 			" pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
1004 			"    Add/Del a SCTP type flow director filter.\n\n"
1005 
1006 			"flow_director_filter (port_id) mode IP (add|del|update)"
1007 			" flow l2_payload ether (ethertype)"
1008 			" flexbytes (flexbytes_value) (drop|fwd)"
1009 			" pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
1010 			"    Add/Del a l2 payload type flow director filter.\n\n"
1011 
1012 			"flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
1013 			" mac (mac_address) vlan (vlan_value)"
1014 			" flexbytes (flexbytes_value) (drop|fwd)"
1015 			" queue (queue_id) fd_id (fd_id_value)\n"
1016 			"    Add/Del a MAC-VLAN flow director filter.\n\n"
1017 
1018 			"flow_director_filter (port_id) mode Tunnel (add|del|update)"
1019 			" mac (mac_address) vlan (vlan_value)"
1020 			" tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
1021 			" flexbytes (flexbytes_value) (drop|fwd)"
1022 			" queue (queue_id) fd_id (fd_id_value)\n"
1023 			"    Add/Del a Tunnel flow director filter.\n\n"
1024 
1025 			"flow_director_filter (port_id) mode raw (add|del|update)"
1026 			" flow (flow_id) (drop|fwd) queue (queue_id)"
1027 			" fd_id (fd_id_value) packet (packet file name)\n"
1028 			"    Add/Del a raw type flow director filter.\n\n"
1029 
1030 			"flush_flow_director (port_id)\n"
1031 			"    Flush all flow director entries of a device.\n\n"
1032 
1033 			"flow_director_mask (port_id) mode IP vlan (vlan_value)"
1034 			" src_mask (ipv4_src) (ipv6_src) (src_port)"
1035 			" dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
1036 			"    Set flow director IP mask.\n\n"
1037 
1038 			"flow_director_mask (port_id) mode MAC-VLAN"
1039 			" vlan (vlan_value)\n"
1040 			"    Set flow director MAC-VLAN mask.\n\n"
1041 
1042 			"flow_director_mask (port_id) mode Tunnel"
1043 			" vlan (vlan_value) mac (mac_value)"
1044 			" tunnel-type (tunnel_type_value)"
1045 			" tunnel-id (tunnel_id_value)\n"
1046 			"    Set flow director Tunnel mask.\n\n"
1047 
1048 			"flow_director_flex_mask (port_id)"
1049 			" flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
1050 			"ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
1051 			" (mask)\n"
1052 			"    Configure mask of flex payload.\n\n"
1053 
1054 			"flow_director_flex_payload (port_id)"
1055 			" (raw|l2|l3|l4) (config)\n"
1056 			"    Configure flex payload selection.\n\n"
1057 
1058 			"get_sym_hash_ena_per_port (port_id)\n"
1059 			"    get symmetric hash enable configuration per port.\n\n"
1060 
1061 			"set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
1062 			"    set symmetric hash enable configuration per port"
1063 			" to enable or disable.\n\n"
1064 
1065 			"get_hash_global_config (port_id)\n"
1066 			"    Get the global configurations of hash filters.\n\n"
1067 
1068 			"set_hash_global_config (port_id) (toeplitz|simple_xor|symmetric_toeplitz|default)"
1069 			" (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1070 			"ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
1071 			" (enable|disable)\n"
1072 			"    Set the global configurations of hash filters.\n\n"
1073 
1074 			"set_hash_input_set (port_id) (ipv4|ipv4-frag|"
1075 			"ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1076 			"ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1077 			"l2_payload|<flowtype_id>) (ovlan|ivlan|src-ipv4|dst-ipv4|"
1078 			"src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
1079 			"ipv6-next-header|udp-src-port|udp-dst-port|"
1080 			"tcp-src-port|tcp-dst-port|sctp-src-port|"
1081 			"sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
1082 			"fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
1083 			"fld-8th|none) (select|add)\n"
1084 			"    Set the input set for hash.\n\n"
1085 
1086 			"set_fdir_input_set (port_id) "
1087 			"(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1088 			"ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1089 			"l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
1090 			"dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
1091 			"ipv6-next-header|ipv6-hop-limits|udp-src-port|"
1092 			"udp-dst-port|tcp-src-port|tcp-dst-port|"
1093 			"sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
1094 			" (select|add)\n"
1095 			"    Set the input set for FDir.\n\n"
1096 
1097 			"flow validate {port_id}"
1098 			" [group {group_id}] [priority {level}]"
1099 			" [ingress] [egress]"
1100 			" pattern {item} [/ {item} [...]] / end"
1101 			" actions {action} [/ {action} [...]] / end\n"
1102 			"    Check whether a flow rule can be created.\n\n"
1103 
1104 			"flow create {port_id}"
1105 			" [group {group_id}] [priority {level}]"
1106 			" [ingress] [egress]"
1107 			" pattern {item} [/ {item} [...]] / end"
1108 			" actions {action} [/ {action} [...]] / end\n"
1109 			"    Create a flow rule.\n\n"
1110 
1111 			"flow destroy {port_id} rule {rule_id} [...]\n"
1112 			"    Destroy specific flow rules.\n\n"
1113 
1114 			"flow flush {port_id}\n"
1115 			"    Destroy all flow rules.\n\n"
1116 
1117 			"flow query {port_id} {rule_id} {action}\n"
1118 			"    Query an existing flow rule.\n\n"
1119 
1120 			"flow list {port_id} [group {group_id}] [...]\n"
1121 			"    List existing flow rules sorted by priority,"
1122 			" filtered by group identifiers.\n\n"
1123 
1124 			"flow isolate {port_id} {boolean}\n"
1125 			"    Restrict ingress traffic to the defined"
1126 			" flow rules\n\n"
1127 
1128 			"set vxlan ip-version (ipv4|ipv6) vni (vni) udp-src"
1129 			" (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst"
1130 			" (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n"
1131 			"       Configure the VXLAN encapsulation for flows.\n\n"
1132 
1133 			"set vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)"
1134 			" udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)"
1135 			" ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)"
1136 			" eth-dst (eth-dst)\n"
1137 			"       Configure the VXLAN encapsulation for flows.\n\n"
1138 
1139 			"set vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src"
1140 			" (udp-src) udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl)"
1141 			" ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src)"
1142 			" eth-dst (eth-dst)\n"
1143 			"       Configure the VXLAN encapsulation for flows.\n\n"
1144 
1145 			"set nvgre ip-version (ipv4|ipv6) tni (tni) ip-src"
1146 			" (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst"
1147 			" (eth-dst)\n"
1148 			"       Configure the NVGRE encapsulation for flows.\n\n"
1149 
1150 			"set nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)"
1151 			" ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)"
1152 			" eth-src (eth-src) eth-dst (eth-dst)\n"
1153 			"       Configure the NVGRE encapsulation for flows.\n\n"
1154 
1155 			"set raw_encap {flow items}\n"
1156 			"	Configure the encapsulation with raw data.\n\n"
1157 
1158 			"set raw_decap {flow items}\n"
1159 			"	Configure the decapsulation with raw data.\n\n"
1160 
1161 		);
1162 	}
1163 
1164 	if (show_all || !strcmp(res->section, "traffic_management")) {
1165 		cmdline_printf(
1166 			cl,
1167 			"\n"
1168 			"Traffic Management:\n"
1169 			"--------------\n"
1170 			"show port tm cap (port_id)\n"
1171 			"       Display the port TM capability.\n\n"
1172 
1173 			"show port tm level cap (port_id) (level_id)\n"
1174 			"       Display the port TM hierarchical level capability.\n\n"
1175 
1176 			"show port tm node cap (port_id) (node_id)\n"
1177 			"       Display the port TM node capability.\n\n"
1178 
1179 			"show port tm node type (port_id) (node_id)\n"
1180 			"       Display the port TM node type.\n\n"
1181 
1182 			"show port tm node stats (port_id) (node_id) (clear)\n"
1183 			"       Display the port TM node stats.\n\n"
1184 
1185 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
1186 			"set port tm hierarchy default (port_id)\n"
1187 			"       Set default traffic Management hierarchy on a port\n\n"
1188 #endif
1189 
1190 			"add port tm node shaper profile (port_id) (shaper_profile_id)"
1191 			" (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)"
1192 			" (packet_length_adjust)\n"
1193 			"       Add port tm node private shaper profile.\n\n"
1194 
1195 			"del port tm node shaper profile (port_id) (shaper_profile_id)\n"
1196 			"       Delete port tm node private shaper profile.\n\n"
1197 
1198 			"add port tm node shared shaper (port_id) (shared_shaper_id)"
1199 			" (shaper_profile_id)\n"
1200 			"       Add/update port tm node shared shaper.\n\n"
1201 
1202 			"del port tm node shared shaper (port_id) (shared_shaper_id)\n"
1203 			"       Delete port tm node shared shaper.\n\n"
1204 
1205 			"set port tm node shaper profile (port_id) (node_id)"
1206 			" (shaper_profile_id)\n"
1207 			"       Set port tm node shaper profile.\n\n"
1208 
1209 			"add port tm node wred profile (port_id) (wred_profile_id)"
1210 			" (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
1211 			" (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
1212 			" (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
1213 			"       Add port tm node wred profile.\n\n"
1214 
1215 			"del port tm node wred profile (port_id) (wred_profile_id)\n"
1216 			"       Delete port tm node wred profile.\n\n"
1217 
1218 			"add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
1219 			" (priority) (weight) (level_id) (shaper_profile_id)"
1220 			" (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1221 			" [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1222 			"       Add port tm nonleaf node.\n\n"
1223 
1224 			"add port tm leaf node (port_id) (node_id) (parent_node_id)"
1225 			" (priority) (weight) (level_id) (shaper_profile_id)"
1226 			" (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
1227 			" [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1228 			"       Add port tm leaf node.\n\n"
1229 
1230 			"del port tm node (port_id) (node_id)\n"
1231 			"       Delete port tm node.\n\n"
1232 
1233 			"set port tm node parent (port_id) (node_id) (parent_node_id)"
1234 			" (priority) (weight)\n"
1235 			"       Set port tm node parent.\n\n"
1236 
1237 			"suspend port tm node (port_id) (node_id)"
1238 			"       Suspend tm node.\n\n"
1239 
1240 			"resume port tm node (port_id) (node_id)"
1241 			"       Resume tm node.\n\n"
1242 
1243 			"port tm hierarchy commit (port_id) (clean_on_fail)\n"
1244 			"       Commit tm hierarchy.\n\n"
1245 
1246 			"set port tm mark ip_ecn (port) (green) (yellow)"
1247 			" (red)\n"
1248 			"    Enables/Disables the traffic management marking"
1249 			" for IP ECN (Explicit Congestion Notification)"
1250 			" packets on a given port\n\n"
1251 
1252 			"set port tm mark ip_dscp (port) (green) (yellow)"
1253 			" (red)\n"
1254 			"    Enables/Disables the traffic management marking"
1255 			" on the port for IP dscp packets\n\n"
1256 
1257 			"set port tm mark vlan_dei (port) (green) (yellow)"
1258 			" (red)\n"
1259 			"    Enables/Disables the traffic management marking"
1260 			" on the port for VLAN packets with DEI enabled\n\n"
1261 		);
1262 	}
1263 
1264 	if (show_all || !strcmp(res->section, "devices")) {
1265 		cmdline_printf(
1266 			cl,
1267 			"\n"
1268 			"Device Operations:\n"
1269 			"--------------\n"
1270 			"device detach (identifier)\n"
1271 			"       Detach device by identifier.\n\n"
1272 		);
1273 	}
1274 
1275 }
1276 
1277 cmdline_parse_token_string_t cmd_help_long_help =
1278 	TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1279 
1280 cmdline_parse_token_string_t cmd_help_long_section =
1281 	TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1282 			"all#control#display#config#"
1283 			"ports#registers#filters#traffic_management#devices");
1284 
1285 cmdline_parse_inst_t cmd_help_long = {
1286 	.f = cmd_help_long_parsed,
1287 	.data = NULL,
1288 	.help_str = "help all|control|display|config|ports|register|"
1289 		"filters|traffic_management|devices: "
1290 		"Show help",
1291 	.tokens = {
1292 		(void *)&cmd_help_long_help,
1293 		(void *)&cmd_help_long_section,
1294 		NULL,
1295 	},
1296 };
1297 
1298 
1299 /* *** start/stop/close all ports *** */
1300 struct cmd_operate_port_result {
1301 	cmdline_fixed_string_t keyword;
1302 	cmdline_fixed_string_t name;
1303 	cmdline_fixed_string_t value;
1304 };
1305 
1306 static void cmd_operate_port_parsed(void *parsed_result,
1307 				__attribute__((unused)) struct cmdline *cl,
1308 				__attribute__((unused)) void *data)
1309 {
1310 	struct cmd_operate_port_result *res = parsed_result;
1311 
1312 	if (!strcmp(res->name, "start"))
1313 		start_port(RTE_PORT_ALL);
1314 	else if (!strcmp(res->name, "stop"))
1315 		stop_port(RTE_PORT_ALL);
1316 	else if (!strcmp(res->name, "close"))
1317 		close_port(RTE_PORT_ALL);
1318 	else if (!strcmp(res->name, "reset"))
1319 		reset_port(RTE_PORT_ALL);
1320 	else
1321 		printf("Unknown parameter\n");
1322 }
1323 
1324 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1325 	TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1326 								"port");
1327 cmdline_parse_token_string_t cmd_operate_port_all_port =
1328 	TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1329 						"start#stop#close#reset");
1330 cmdline_parse_token_string_t cmd_operate_port_all_all =
1331 	TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1332 
1333 cmdline_parse_inst_t cmd_operate_port = {
1334 	.f = cmd_operate_port_parsed,
1335 	.data = NULL,
1336 	.help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports",
1337 	.tokens = {
1338 		(void *)&cmd_operate_port_all_cmd,
1339 		(void *)&cmd_operate_port_all_port,
1340 		(void *)&cmd_operate_port_all_all,
1341 		NULL,
1342 	},
1343 };
1344 
1345 /* *** start/stop/close specific port *** */
1346 struct cmd_operate_specific_port_result {
1347 	cmdline_fixed_string_t keyword;
1348 	cmdline_fixed_string_t name;
1349 	uint8_t value;
1350 };
1351 
1352 static void cmd_operate_specific_port_parsed(void *parsed_result,
1353 			__attribute__((unused)) struct cmdline *cl,
1354 				__attribute__((unused)) void *data)
1355 {
1356 	struct cmd_operate_specific_port_result *res = parsed_result;
1357 
1358 	if (!strcmp(res->name, "start"))
1359 		start_port(res->value);
1360 	else if (!strcmp(res->name, "stop"))
1361 		stop_port(res->value);
1362 	else if (!strcmp(res->name, "close"))
1363 		close_port(res->value);
1364 	else if (!strcmp(res->name, "reset"))
1365 		reset_port(res->value);
1366 	else
1367 		printf("Unknown parameter\n");
1368 }
1369 
1370 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1371 	TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1372 							keyword, "port");
1373 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1374 	TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1375 						name, "start#stop#close#reset");
1376 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1377 	TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1378 							value, UINT8);
1379 
1380 cmdline_parse_inst_t cmd_operate_specific_port = {
1381 	.f = cmd_operate_specific_port_parsed,
1382 	.data = NULL,
1383 	.help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id",
1384 	.tokens = {
1385 		(void *)&cmd_operate_specific_port_cmd,
1386 		(void *)&cmd_operate_specific_port_port,
1387 		(void *)&cmd_operate_specific_port_id,
1388 		NULL,
1389 	},
1390 };
1391 
1392 /* *** enable port setup (after attach) via iterator or event *** */
1393 struct cmd_set_port_setup_on_result {
1394 	cmdline_fixed_string_t set;
1395 	cmdline_fixed_string_t port;
1396 	cmdline_fixed_string_t setup;
1397 	cmdline_fixed_string_t on;
1398 	cmdline_fixed_string_t mode;
1399 };
1400 
1401 static void cmd_set_port_setup_on_parsed(void *parsed_result,
1402 				__attribute__((unused)) struct cmdline *cl,
1403 				__attribute__((unused)) void *data)
1404 {
1405 	struct cmd_set_port_setup_on_result *res = parsed_result;
1406 
1407 	if (strcmp(res->mode, "event") == 0)
1408 		setup_on_probe_event = true;
1409 	else if (strcmp(res->mode, "iterator") == 0)
1410 		setup_on_probe_event = false;
1411 	else
1412 		printf("Unknown mode\n");
1413 }
1414 
1415 cmdline_parse_token_string_t cmd_set_port_setup_on_set =
1416 	TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1417 			set, "set");
1418 cmdline_parse_token_string_t cmd_set_port_setup_on_port =
1419 	TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1420 			port, "port");
1421 cmdline_parse_token_string_t cmd_set_port_setup_on_setup =
1422 	TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1423 			setup, "setup");
1424 cmdline_parse_token_string_t cmd_set_port_setup_on_on =
1425 	TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1426 			on, "on");
1427 cmdline_parse_token_string_t cmd_set_port_setup_on_mode =
1428 	TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1429 			mode, "iterator#event");
1430 
1431 cmdline_parse_inst_t cmd_set_port_setup_on = {
1432 	.f = cmd_set_port_setup_on_parsed,
1433 	.data = NULL,
1434 	.help_str = "set port setup on iterator|event",
1435 	.tokens = {
1436 		(void *)&cmd_set_port_setup_on_set,
1437 		(void *)&cmd_set_port_setup_on_port,
1438 		(void *)&cmd_set_port_setup_on_setup,
1439 		(void *)&cmd_set_port_setup_on_on,
1440 		(void *)&cmd_set_port_setup_on_mode,
1441 		NULL,
1442 	},
1443 };
1444 
1445 /* *** attach a specified port *** */
1446 struct cmd_operate_attach_port_result {
1447 	cmdline_fixed_string_t port;
1448 	cmdline_fixed_string_t keyword;
1449 	cmdline_fixed_string_t identifier;
1450 };
1451 
1452 static void cmd_operate_attach_port_parsed(void *parsed_result,
1453 				__attribute__((unused)) struct cmdline *cl,
1454 				__attribute__((unused)) void *data)
1455 {
1456 	struct cmd_operate_attach_port_result *res = parsed_result;
1457 
1458 	if (!strcmp(res->keyword, "attach"))
1459 		attach_port(res->identifier);
1460 	else
1461 		printf("Unknown parameter\n");
1462 }
1463 
1464 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1465 	TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1466 			port, "port");
1467 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1468 	TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1469 			keyword, "attach");
1470 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1471 	TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1472 			identifier, NULL);
1473 
1474 cmdline_parse_inst_t cmd_operate_attach_port = {
1475 	.f = cmd_operate_attach_port_parsed,
1476 	.data = NULL,
1477 	.help_str = "port attach <identifier>: "
1478 		"(identifier: pci address or virtual dev name)",
1479 	.tokens = {
1480 		(void *)&cmd_operate_attach_port_port,
1481 		(void *)&cmd_operate_attach_port_keyword,
1482 		(void *)&cmd_operate_attach_port_identifier,
1483 		NULL,
1484 	},
1485 };
1486 
1487 /* *** detach a specified port *** */
1488 struct cmd_operate_detach_port_result {
1489 	cmdline_fixed_string_t port;
1490 	cmdline_fixed_string_t keyword;
1491 	portid_t port_id;
1492 };
1493 
1494 static void cmd_operate_detach_port_parsed(void *parsed_result,
1495 				__attribute__((unused)) struct cmdline *cl,
1496 				__attribute__((unused)) void *data)
1497 {
1498 	struct cmd_operate_detach_port_result *res = parsed_result;
1499 
1500 	if (!strcmp(res->keyword, "detach"))
1501 		detach_port_device(res->port_id);
1502 	else
1503 		printf("Unknown parameter\n");
1504 }
1505 
1506 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1507 	TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1508 			port, "port");
1509 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1510 	TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1511 			keyword, "detach");
1512 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1513 	TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1514 			port_id, UINT16);
1515 
1516 cmdline_parse_inst_t cmd_operate_detach_port = {
1517 	.f = cmd_operate_detach_port_parsed,
1518 	.data = NULL,
1519 	.help_str = "port detach <port_id>",
1520 	.tokens = {
1521 		(void *)&cmd_operate_detach_port_port,
1522 		(void *)&cmd_operate_detach_port_keyword,
1523 		(void *)&cmd_operate_detach_port_port_id,
1524 		NULL,
1525 	},
1526 };
1527 
1528 /* *** detach device by identifier *** */
1529 struct cmd_operate_detach_device_result {
1530 	cmdline_fixed_string_t device;
1531 	cmdline_fixed_string_t keyword;
1532 	cmdline_fixed_string_t identifier;
1533 };
1534 
1535 static void cmd_operate_detach_device_parsed(void *parsed_result,
1536 				__attribute__((unused)) struct cmdline *cl,
1537 				__attribute__((unused)) void *data)
1538 {
1539 	struct cmd_operate_detach_device_result *res = parsed_result;
1540 
1541 	if (!strcmp(res->keyword, "detach"))
1542 		detach_device(res->identifier);
1543 	else
1544 		printf("Unknown parameter\n");
1545 }
1546 
1547 cmdline_parse_token_string_t cmd_operate_detach_device_device =
1548 	TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1549 			device, "device");
1550 cmdline_parse_token_string_t cmd_operate_detach_device_keyword =
1551 	TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1552 			keyword, "detach");
1553 cmdline_parse_token_string_t cmd_operate_detach_device_identifier =
1554 	TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1555 			identifier, NULL);
1556 
1557 cmdline_parse_inst_t cmd_operate_detach_device = {
1558 	.f = cmd_operate_detach_device_parsed,
1559 	.data = NULL,
1560 	.help_str = "device detach <identifier>:"
1561 		"(identifier: pci address or virtual dev name)",
1562 	.tokens = {
1563 		(void *)&cmd_operate_detach_device_device,
1564 		(void *)&cmd_operate_detach_device_keyword,
1565 		(void *)&cmd_operate_detach_device_identifier,
1566 		NULL,
1567 	},
1568 };
1569 /* *** configure speed for all ports *** */
1570 struct cmd_config_speed_all {
1571 	cmdline_fixed_string_t port;
1572 	cmdline_fixed_string_t keyword;
1573 	cmdline_fixed_string_t all;
1574 	cmdline_fixed_string_t item1;
1575 	cmdline_fixed_string_t item2;
1576 	cmdline_fixed_string_t value1;
1577 	cmdline_fixed_string_t value2;
1578 };
1579 
1580 static int
1581 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1582 {
1583 
1584 	int duplex;
1585 
1586 	if (!strcmp(duplexstr, "half")) {
1587 		duplex = ETH_LINK_HALF_DUPLEX;
1588 	} else if (!strcmp(duplexstr, "full")) {
1589 		duplex = ETH_LINK_FULL_DUPLEX;
1590 	} else if (!strcmp(duplexstr, "auto")) {
1591 		duplex = ETH_LINK_FULL_DUPLEX;
1592 	} else {
1593 		printf("Unknown duplex parameter\n");
1594 		return -1;
1595 	}
1596 
1597 	if (!strcmp(speedstr, "10")) {
1598 		*speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1599 				ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1600 	} else if (!strcmp(speedstr, "100")) {
1601 		*speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1602 				ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1603 	} else {
1604 		if (duplex != ETH_LINK_FULL_DUPLEX) {
1605 			printf("Invalid speed/duplex parameters\n");
1606 			return -1;
1607 		}
1608 		if (!strcmp(speedstr, "1000")) {
1609 			*speed = ETH_LINK_SPEED_1G;
1610 		} else if (!strcmp(speedstr, "10000")) {
1611 			*speed = ETH_LINK_SPEED_10G;
1612 		} else if (!strcmp(speedstr, "25000")) {
1613 			*speed = ETH_LINK_SPEED_25G;
1614 		} else if (!strcmp(speedstr, "40000")) {
1615 			*speed = ETH_LINK_SPEED_40G;
1616 		} else if (!strcmp(speedstr, "50000")) {
1617 			*speed = ETH_LINK_SPEED_50G;
1618 		} else if (!strcmp(speedstr, "100000")) {
1619 			*speed = ETH_LINK_SPEED_100G;
1620 		} else if (!strcmp(speedstr, "auto")) {
1621 			*speed = ETH_LINK_SPEED_AUTONEG;
1622 		} else {
1623 			printf("Unknown speed parameter\n");
1624 			return -1;
1625 		}
1626 	}
1627 
1628 	return 0;
1629 }
1630 
1631 static void
1632 cmd_config_speed_all_parsed(void *parsed_result,
1633 			__attribute__((unused)) struct cmdline *cl,
1634 			__attribute__((unused)) void *data)
1635 {
1636 	struct cmd_config_speed_all *res = parsed_result;
1637 	uint32_t link_speed;
1638 	portid_t pid;
1639 
1640 	if (!all_ports_stopped()) {
1641 		printf("Please stop all ports first\n");
1642 		return;
1643 	}
1644 
1645 	if (parse_and_check_speed_duplex(res->value1, res->value2,
1646 			&link_speed) < 0)
1647 		return;
1648 
1649 	RTE_ETH_FOREACH_DEV(pid) {
1650 		ports[pid].dev_conf.link_speeds = link_speed;
1651 	}
1652 
1653 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1654 }
1655 
1656 cmdline_parse_token_string_t cmd_config_speed_all_port =
1657 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1658 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1659 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1660 							"config");
1661 cmdline_parse_token_string_t cmd_config_speed_all_all =
1662 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1663 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1664 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1665 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1666 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1667 				"10#100#1000#10000#25000#40000#50000#100000#auto");
1668 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1669 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1670 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1671 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1672 						"half#full#auto");
1673 
1674 cmdline_parse_inst_t cmd_config_speed_all = {
1675 	.f = cmd_config_speed_all_parsed,
1676 	.data = NULL,
1677 	.help_str = "port config all speed "
1678 		"10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1679 							"half|full|auto",
1680 	.tokens = {
1681 		(void *)&cmd_config_speed_all_port,
1682 		(void *)&cmd_config_speed_all_keyword,
1683 		(void *)&cmd_config_speed_all_all,
1684 		(void *)&cmd_config_speed_all_item1,
1685 		(void *)&cmd_config_speed_all_value1,
1686 		(void *)&cmd_config_speed_all_item2,
1687 		(void *)&cmd_config_speed_all_value2,
1688 		NULL,
1689 	},
1690 };
1691 
1692 /* *** configure speed for specific port *** */
1693 struct cmd_config_speed_specific {
1694 	cmdline_fixed_string_t port;
1695 	cmdline_fixed_string_t keyword;
1696 	portid_t id;
1697 	cmdline_fixed_string_t item1;
1698 	cmdline_fixed_string_t item2;
1699 	cmdline_fixed_string_t value1;
1700 	cmdline_fixed_string_t value2;
1701 };
1702 
1703 static void
1704 cmd_config_speed_specific_parsed(void *parsed_result,
1705 				__attribute__((unused)) struct cmdline *cl,
1706 				__attribute__((unused)) void *data)
1707 {
1708 	struct cmd_config_speed_specific *res = parsed_result;
1709 	uint32_t link_speed;
1710 
1711 	if (!all_ports_stopped()) {
1712 		printf("Please stop all ports first\n");
1713 		return;
1714 	}
1715 
1716 	if (port_id_is_invalid(res->id, ENABLED_WARN))
1717 		return;
1718 
1719 	if (parse_and_check_speed_duplex(res->value1, res->value2,
1720 			&link_speed) < 0)
1721 		return;
1722 
1723 	ports[res->id].dev_conf.link_speeds = link_speed;
1724 
1725 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1726 }
1727 
1728 
1729 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1730 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1731 								"port");
1732 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1733 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1734 								"config");
1735 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1736 	TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT16);
1737 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1738 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1739 								"speed");
1740 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1741 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1742 				"10#100#1000#10000#25000#40000#50000#100000#auto");
1743 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1744 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1745 								"duplex");
1746 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1747 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1748 							"half#full#auto");
1749 
1750 cmdline_parse_inst_t cmd_config_speed_specific = {
1751 	.f = cmd_config_speed_specific_parsed,
1752 	.data = NULL,
1753 	.help_str = "port config <port_id> speed "
1754 		"10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1755 							"half|full|auto",
1756 	.tokens = {
1757 		(void *)&cmd_config_speed_specific_port,
1758 		(void *)&cmd_config_speed_specific_keyword,
1759 		(void *)&cmd_config_speed_specific_id,
1760 		(void *)&cmd_config_speed_specific_item1,
1761 		(void *)&cmd_config_speed_specific_value1,
1762 		(void *)&cmd_config_speed_specific_item2,
1763 		(void *)&cmd_config_speed_specific_value2,
1764 		NULL,
1765 	},
1766 };
1767 
1768 /* *** configure loopback for all ports *** */
1769 struct cmd_config_loopback_all {
1770 	cmdline_fixed_string_t port;
1771 	cmdline_fixed_string_t keyword;
1772 	cmdline_fixed_string_t all;
1773 	cmdline_fixed_string_t item;
1774 	uint32_t mode;
1775 };
1776 
1777 static void
1778 cmd_config_loopback_all_parsed(void *parsed_result,
1779 			__attribute__((unused)) struct cmdline *cl,
1780 			__attribute__((unused)) void *data)
1781 {
1782 	struct cmd_config_loopback_all *res = parsed_result;
1783 	portid_t pid;
1784 
1785 	if (!all_ports_stopped()) {
1786 		printf("Please stop all ports first\n");
1787 		return;
1788 	}
1789 
1790 	RTE_ETH_FOREACH_DEV(pid) {
1791 		ports[pid].dev_conf.lpbk_mode = res->mode;
1792 	}
1793 
1794 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1795 }
1796 
1797 cmdline_parse_token_string_t cmd_config_loopback_all_port =
1798 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1799 cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1800 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1801 							"config");
1802 cmdline_parse_token_string_t cmd_config_loopback_all_all =
1803 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1804 cmdline_parse_token_string_t cmd_config_loopback_all_item =
1805 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1806 							"loopback");
1807 cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1808 	TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, UINT32);
1809 
1810 cmdline_parse_inst_t cmd_config_loopback_all = {
1811 	.f = cmd_config_loopback_all_parsed,
1812 	.data = NULL,
1813 	.help_str = "port config all loopback <mode>",
1814 	.tokens = {
1815 		(void *)&cmd_config_loopback_all_port,
1816 		(void *)&cmd_config_loopback_all_keyword,
1817 		(void *)&cmd_config_loopback_all_all,
1818 		(void *)&cmd_config_loopback_all_item,
1819 		(void *)&cmd_config_loopback_all_mode,
1820 		NULL,
1821 	},
1822 };
1823 
1824 /* *** configure loopback for specific port *** */
1825 struct cmd_config_loopback_specific {
1826 	cmdline_fixed_string_t port;
1827 	cmdline_fixed_string_t keyword;
1828 	uint16_t port_id;
1829 	cmdline_fixed_string_t item;
1830 	uint32_t mode;
1831 };
1832 
1833 static void
1834 cmd_config_loopback_specific_parsed(void *parsed_result,
1835 				__attribute__((unused)) struct cmdline *cl,
1836 				__attribute__((unused)) void *data)
1837 {
1838 	struct cmd_config_loopback_specific *res = parsed_result;
1839 
1840 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1841 		return;
1842 
1843 	if (!port_is_stopped(res->port_id)) {
1844 		printf("Please stop port %u first\n", res->port_id);
1845 		return;
1846 	}
1847 
1848 	ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1849 
1850 	cmd_reconfig_device_queue(res->port_id, 1, 1);
1851 }
1852 
1853 
1854 cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1855 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1856 								"port");
1857 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1858 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1859 								"config");
1860 cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1861 	TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1862 								UINT16);
1863 cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1864 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1865 								"loopback");
1866 cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1867 	TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1868 			      UINT32);
1869 
1870 cmdline_parse_inst_t cmd_config_loopback_specific = {
1871 	.f = cmd_config_loopback_specific_parsed,
1872 	.data = NULL,
1873 	.help_str = "port config <port_id> loopback <mode>",
1874 	.tokens = {
1875 		(void *)&cmd_config_loopback_specific_port,
1876 		(void *)&cmd_config_loopback_specific_keyword,
1877 		(void *)&cmd_config_loopback_specific_id,
1878 		(void *)&cmd_config_loopback_specific_item,
1879 		(void *)&cmd_config_loopback_specific_mode,
1880 		NULL,
1881 	},
1882 };
1883 
1884 /* *** configure txq/rxq, txd/rxd *** */
1885 struct cmd_config_rx_tx {
1886 	cmdline_fixed_string_t port;
1887 	cmdline_fixed_string_t keyword;
1888 	cmdline_fixed_string_t all;
1889 	cmdline_fixed_string_t name;
1890 	uint16_t value;
1891 };
1892 
1893 static void
1894 cmd_config_rx_tx_parsed(void *parsed_result,
1895 			__attribute__((unused)) struct cmdline *cl,
1896 			__attribute__((unused)) void *data)
1897 {
1898 	struct cmd_config_rx_tx *res = parsed_result;
1899 
1900 	if (!all_ports_stopped()) {
1901 		printf("Please stop all ports first\n");
1902 		return;
1903 	}
1904 	if (!strcmp(res->name, "rxq")) {
1905 		if (!res->value && !nb_txq) {
1906 			printf("Warning: Either rx or tx queues should be non zero\n");
1907 			return;
1908 		}
1909 		if (check_nb_rxq(res->value) != 0)
1910 			return;
1911 		nb_rxq = res->value;
1912 	}
1913 	else if (!strcmp(res->name, "txq")) {
1914 		if (!res->value && !nb_rxq) {
1915 			printf("Warning: Either rx or tx queues should be non zero\n");
1916 			return;
1917 		}
1918 		if (check_nb_txq(res->value) != 0)
1919 			return;
1920 		nb_txq = res->value;
1921 	}
1922 	else if (!strcmp(res->name, "rxd")) {
1923 		if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1924 			printf("rxd %d invalid - must be > 0 && <= %d\n",
1925 					res->value, RTE_TEST_RX_DESC_MAX);
1926 			return;
1927 		}
1928 		nb_rxd = res->value;
1929 	} else if (!strcmp(res->name, "txd")) {
1930 		if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1931 			printf("txd %d invalid - must be > 0 && <= %d\n",
1932 					res->value, RTE_TEST_TX_DESC_MAX);
1933 			return;
1934 		}
1935 		nb_txd = res->value;
1936 	} else {
1937 		printf("Unknown parameter\n");
1938 		return;
1939 	}
1940 
1941 	fwd_config_setup();
1942 
1943 	init_port_config();
1944 
1945 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1946 }
1947 
1948 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1949 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1950 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1951 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1952 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1953 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1954 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1955 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1956 						"rxq#txq#rxd#txd");
1957 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1958 	TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1959 
1960 cmdline_parse_inst_t cmd_config_rx_tx = {
1961 	.f = cmd_config_rx_tx_parsed,
1962 	.data = NULL,
1963 	.help_str = "port config all rxq|txq|rxd|txd <value>",
1964 	.tokens = {
1965 		(void *)&cmd_config_rx_tx_port,
1966 		(void *)&cmd_config_rx_tx_keyword,
1967 		(void *)&cmd_config_rx_tx_all,
1968 		(void *)&cmd_config_rx_tx_name,
1969 		(void *)&cmd_config_rx_tx_value,
1970 		NULL,
1971 	},
1972 };
1973 
1974 /* *** config max packet length *** */
1975 struct cmd_config_max_pkt_len_result {
1976 	cmdline_fixed_string_t port;
1977 	cmdline_fixed_string_t keyword;
1978 	cmdline_fixed_string_t all;
1979 	cmdline_fixed_string_t name;
1980 	uint32_t value;
1981 };
1982 
1983 static void
1984 cmd_config_max_pkt_len_parsed(void *parsed_result,
1985 				__attribute__((unused)) struct cmdline *cl,
1986 				__attribute__((unused)) void *data)
1987 {
1988 	struct cmd_config_max_pkt_len_result *res = parsed_result;
1989 	portid_t pid;
1990 
1991 	if (!all_ports_stopped()) {
1992 		printf("Please stop all ports first\n");
1993 		return;
1994 	}
1995 
1996 	RTE_ETH_FOREACH_DEV(pid) {
1997 		struct rte_port *port = &ports[pid];
1998 		uint64_t rx_offloads = port->dev_conf.rxmode.offloads;
1999 
2000 		if (!strcmp(res->name, "max-pkt-len")) {
2001 			if (res->value < RTE_ETHER_MIN_LEN) {
2002 				printf("max-pkt-len can not be less than %d\n",
2003 						RTE_ETHER_MIN_LEN);
2004 				return;
2005 			}
2006 			if (res->value == port->dev_conf.rxmode.max_rx_pkt_len)
2007 				return;
2008 
2009 			port->dev_conf.rxmode.max_rx_pkt_len = res->value;
2010 			if (res->value > RTE_ETHER_MAX_LEN)
2011 				rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
2012 			else
2013 				rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
2014 			port->dev_conf.rxmode.offloads = rx_offloads;
2015 		} else {
2016 			printf("Unknown parameter\n");
2017 			return;
2018 		}
2019 	}
2020 
2021 	init_port_config();
2022 
2023 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2024 }
2025 
2026 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
2027 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
2028 								"port");
2029 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
2030 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
2031 								"config");
2032 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
2033 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
2034 								"all");
2035 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
2036 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
2037 								"max-pkt-len");
2038 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
2039 	TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
2040 								UINT32);
2041 
2042 cmdline_parse_inst_t cmd_config_max_pkt_len = {
2043 	.f = cmd_config_max_pkt_len_parsed,
2044 	.data = NULL,
2045 	.help_str = "port config all max-pkt-len <value>",
2046 	.tokens = {
2047 		(void *)&cmd_config_max_pkt_len_port,
2048 		(void *)&cmd_config_max_pkt_len_keyword,
2049 		(void *)&cmd_config_max_pkt_len_all,
2050 		(void *)&cmd_config_max_pkt_len_name,
2051 		(void *)&cmd_config_max_pkt_len_value,
2052 		NULL,
2053 	},
2054 };
2055 
2056 /* *** config max LRO aggregated packet size *** */
2057 struct cmd_config_max_lro_pkt_size_result {
2058 	cmdline_fixed_string_t port;
2059 	cmdline_fixed_string_t keyword;
2060 	cmdline_fixed_string_t all;
2061 	cmdline_fixed_string_t name;
2062 	uint32_t value;
2063 };
2064 
2065 static void
2066 cmd_config_max_lro_pkt_size_parsed(void *parsed_result,
2067 				__attribute__((unused)) struct cmdline *cl,
2068 				__attribute__((unused)) void *data)
2069 {
2070 	struct cmd_config_max_lro_pkt_size_result *res = parsed_result;
2071 	portid_t pid;
2072 
2073 	if (!all_ports_stopped()) {
2074 		printf("Please stop all ports first\n");
2075 		return;
2076 	}
2077 
2078 	RTE_ETH_FOREACH_DEV(pid) {
2079 		struct rte_port *port = &ports[pid];
2080 
2081 		if (!strcmp(res->name, "max-lro-pkt-size")) {
2082 			if (res->value ==
2083 					port->dev_conf.rxmode.max_lro_pkt_size)
2084 				return;
2085 
2086 			port->dev_conf.rxmode.max_lro_pkt_size = res->value;
2087 		} else {
2088 			printf("Unknown parameter\n");
2089 			return;
2090 		}
2091 	}
2092 
2093 	init_port_config();
2094 
2095 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2096 }
2097 
2098 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_port =
2099 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2100 				 port, "port");
2101 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_keyword =
2102 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2103 				 keyword, "config");
2104 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_all =
2105 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2106 				 all, "all");
2107 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_name =
2108 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2109 				 name, "max-lro-pkt-size");
2110 cmdline_parse_token_num_t cmd_config_max_lro_pkt_size_value =
2111 	TOKEN_NUM_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2112 			      value, UINT32);
2113 
2114 cmdline_parse_inst_t cmd_config_max_lro_pkt_size = {
2115 	.f = cmd_config_max_lro_pkt_size_parsed,
2116 	.data = NULL,
2117 	.help_str = "port config all max-lro-pkt-size <value>",
2118 	.tokens = {
2119 		(void *)&cmd_config_max_lro_pkt_size_port,
2120 		(void *)&cmd_config_max_lro_pkt_size_keyword,
2121 		(void *)&cmd_config_max_lro_pkt_size_all,
2122 		(void *)&cmd_config_max_lro_pkt_size_name,
2123 		(void *)&cmd_config_max_lro_pkt_size_value,
2124 		NULL,
2125 	},
2126 };
2127 
2128 /* *** configure port MTU *** */
2129 struct cmd_config_mtu_result {
2130 	cmdline_fixed_string_t port;
2131 	cmdline_fixed_string_t keyword;
2132 	cmdline_fixed_string_t mtu;
2133 	portid_t port_id;
2134 	uint16_t value;
2135 };
2136 
2137 static void
2138 cmd_config_mtu_parsed(void *parsed_result,
2139 		      __attribute__((unused)) struct cmdline *cl,
2140 		      __attribute__((unused)) void *data)
2141 {
2142 	struct cmd_config_mtu_result *res = parsed_result;
2143 
2144 	if (res->value < RTE_ETHER_MIN_LEN) {
2145 		printf("mtu cannot be less than %d\n", RTE_ETHER_MIN_LEN);
2146 		return;
2147 	}
2148 	port_mtu_set(res->port_id, res->value);
2149 }
2150 
2151 cmdline_parse_token_string_t cmd_config_mtu_port =
2152 	TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
2153 				 "port");
2154 cmdline_parse_token_string_t cmd_config_mtu_keyword =
2155 	TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2156 				 "config");
2157 cmdline_parse_token_string_t cmd_config_mtu_mtu =
2158 	TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2159 				 "mtu");
2160 cmdline_parse_token_num_t cmd_config_mtu_port_id =
2161 	TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT16);
2162 cmdline_parse_token_num_t cmd_config_mtu_value =
2163 	TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
2164 
2165 cmdline_parse_inst_t cmd_config_mtu = {
2166 	.f = cmd_config_mtu_parsed,
2167 	.data = NULL,
2168 	.help_str = "port config mtu <port_id> <value>",
2169 	.tokens = {
2170 		(void *)&cmd_config_mtu_port,
2171 		(void *)&cmd_config_mtu_keyword,
2172 		(void *)&cmd_config_mtu_mtu,
2173 		(void *)&cmd_config_mtu_port_id,
2174 		(void *)&cmd_config_mtu_value,
2175 		NULL,
2176 	},
2177 };
2178 
2179 /* *** configure rx mode *** */
2180 struct cmd_config_rx_mode_flag {
2181 	cmdline_fixed_string_t port;
2182 	cmdline_fixed_string_t keyword;
2183 	cmdline_fixed_string_t all;
2184 	cmdline_fixed_string_t name;
2185 	cmdline_fixed_string_t value;
2186 };
2187 
2188 static void
2189 cmd_config_rx_mode_flag_parsed(void *parsed_result,
2190 				__attribute__((unused)) struct cmdline *cl,
2191 				__attribute__((unused)) void *data)
2192 {
2193 	struct cmd_config_rx_mode_flag *res = parsed_result;
2194 
2195 	if (!all_ports_stopped()) {
2196 		printf("Please stop all ports first\n");
2197 		return;
2198 	}
2199 
2200 	if (!strcmp(res->name, "drop-en")) {
2201 		if (!strcmp(res->value, "on"))
2202 			rx_drop_en = 1;
2203 		else if (!strcmp(res->value, "off"))
2204 			rx_drop_en = 0;
2205 		else {
2206 			printf("Unknown parameter\n");
2207 			return;
2208 		}
2209 	} else {
2210 		printf("Unknown parameter\n");
2211 		return;
2212 	}
2213 
2214 	init_port_config();
2215 
2216 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2217 }
2218 
2219 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
2220 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
2221 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
2222 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
2223 								"config");
2224 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2225 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2226 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2227 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2228 					"drop-en");
2229 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2230 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2231 							"on#off");
2232 
2233 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2234 	.f = cmd_config_rx_mode_flag_parsed,
2235 	.data = NULL,
2236 	.help_str = "port config all drop-en on|off",
2237 	.tokens = {
2238 		(void *)&cmd_config_rx_mode_flag_port,
2239 		(void *)&cmd_config_rx_mode_flag_keyword,
2240 		(void *)&cmd_config_rx_mode_flag_all,
2241 		(void *)&cmd_config_rx_mode_flag_name,
2242 		(void *)&cmd_config_rx_mode_flag_value,
2243 		NULL,
2244 	},
2245 };
2246 
2247 /* *** configure rss *** */
2248 struct cmd_config_rss {
2249 	cmdline_fixed_string_t port;
2250 	cmdline_fixed_string_t keyword;
2251 	cmdline_fixed_string_t all;
2252 	cmdline_fixed_string_t name;
2253 	cmdline_fixed_string_t value;
2254 };
2255 
2256 static void
2257 cmd_config_rss_parsed(void *parsed_result,
2258 			__attribute__((unused)) struct cmdline *cl,
2259 			__attribute__((unused)) void *data)
2260 {
2261 	struct cmd_config_rss *res = parsed_result;
2262 	struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2263 	struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2264 	int use_default = 0;
2265 	int all_updated = 1;
2266 	int diag;
2267 	uint16_t i;
2268 	int ret;
2269 
2270 	if (!strcmp(res->value, "all"))
2271 		rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
2272 				ETH_RSS_UDP | ETH_RSS_SCTP |
2273 					ETH_RSS_L2_PAYLOAD;
2274 	else if (!strcmp(res->value, "ip"))
2275 		rss_conf.rss_hf = ETH_RSS_IP;
2276 	else if (!strcmp(res->value, "udp"))
2277 		rss_conf.rss_hf = ETH_RSS_UDP;
2278 	else if (!strcmp(res->value, "tcp"))
2279 		rss_conf.rss_hf = ETH_RSS_TCP;
2280 	else if (!strcmp(res->value, "sctp"))
2281 		rss_conf.rss_hf = ETH_RSS_SCTP;
2282 	else if (!strcmp(res->value, "ether"))
2283 		rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
2284 	else if (!strcmp(res->value, "port"))
2285 		rss_conf.rss_hf = ETH_RSS_PORT;
2286 	else if (!strcmp(res->value, "vxlan"))
2287 		rss_conf.rss_hf = ETH_RSS_VXLAN;
2288 	else if (!strcmp(res->value, "geneve"))
2289 		rss_conf.rss_hf = ETH_RSS_GENEVE;
2290 	else if (!strcmp(res->value, "nvgre"))
2291 		rss_conf.rss_hf = ETH_RSS_NVGRE;
2292 	else if (!strcmp(res->value, "l3-src-only"))
2293 		rss_conf.rss_hf = ETH_RSS_L3_SRC_ONLY;
2294 	else if (!strcmp(res->value, "l3-dst-only"))
2295 		rss_conf.rss_hf = ETH_RSS_L3_DST_ONLY;
2296 	else if (!strcmp(res->value, "l4-src-only"))
2297 		rss_conf.rss_hf = ETH_RSS_L4_SRC_ONLY;
2298 	else if (!strcmp(res->value, "l4-dst-only"))
2299 		rss_conf.rss_hf = ETH_RSS_L4_DST_ONLY;
2300 	else if (!strcmp(res->value, "none"))
2301 		rss_conf.rss_hf = 0;
2302 	else if (!strcmp(res->value, "default"))
2303 		use_default = 1;
2304 	else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2305 						atoi(res->value) < 64)
2306 		rss_conf.rss_hf = 1ULL << atoi(res->value);
2307 	else {
2308 		printf("Unknown parameter\n");
2309 		return;
2310 	}
2311 	rss_conf.rss_key = NULL;
2312 	/* Update global configuration for RSS types. */
2313 	RTE_ETH_FOREACH_DEV(i) {
2314 		struct rte_eth_rss_conf local_rss_conf;
2315 
2316 		ret = eth_dev_info_get_print_err(i, &dev_info);
2317 		if (ret != 0)
2318 			return;
2319 
2320 		if (use_default)
2321 			rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2322 
2323 		local_rss_conf = rss_conf;
2324 		local_rss_conf.rss_hf = rss_conf.rss_hf &
2325 			dev_info.flow_type_rss_offloads;
2326 		if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2327 			printf("Port %u modified RSS hash function based on hardware support,"
2328 				"requested:%#"PRIx64" configured:%#"PRIx64"\n",
2329 				i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2330 		}
2331 		diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2332 		if (diag < 0) {
2333 			all_updated = 0;
2334 			printf("Configuration of RSS hash at ethernet port %d "
2335 				"failed with error (%d): %s.\n",
2336 				i, -diag, strerror(-diag));
2337 		}
2338 	}
2339 	if (all_updated && !use_default)
2340 		rss_hf = rss_conf.rss_hf;
2341 }
2342 
2343 cmdline_parse_token_string_t cmd_config_rss_port =
2344 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2345 cmdline_parse_token_string_t cmd_config_rss_keyword =
2346 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2347 cmdline_parse_token_string_t cmd_config_rss_all =
2348 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2349 cmdline_parse_token_string_t cmd_config_rss_name =
2350 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2351 cmdline_parse_token_string_t cmd_config_rss_value =
2352 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2353 
2354 cmdline_parse_inst_t cmd_config_rss = {
2355 	.f = cmd_config_rss_parsed,
2356 	.data = NULL,
2357 	.help_str = "port config all rss "
2358 		"all|default|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|vxlan-gpe|none|<flowtype_id>",
2359 	.tokens = {
2360 		(void *)&cmd_config_rss_port,
2361 		(void *)&cmd_config_rss_keyword,
2362 		(void *)&cmd_config_rss_all,
2363 		(void *)&cmd_config_rss_name,
2364 		(void *)&cmd_config_rss_value,
2365 		NULL,
2366 	},
2367 };
2368 
2369 /* *** configure rss hash key *** */
2370 struct cmd_config_rss_hash_key {
2371 	cmdline_fixed_string_t port;
2372 	cmdline_fixed_string_t config;
2373 	portid_t port_id;
2374 	cmdline_fixed_string_t rss_hash_key;
2375 	cmdline_fixed_string_t rss_type;
2376 	cmdline_fixed_string_t key;
2377 };
2378 
2379 static uint8_t
2380 hexa_digit_to_value(char hexa_digit)
2381 {
2382 	if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2383 		return (uint8_t) (hexa_digit - '0');
2384 	if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2385 		return (uint8_t) ((hexa_digit - 'a') + 10);
2386 	if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2387 		return (uint8_t) ((hexa_digit - 'A') + 10);
2388 	/* Invalid hexa digit */
2389 	return 0xFF;
2390 }
2391 
2392 static uint8_t
2393 parse_and_check_key_hexa_digit(char *key, int idx)
2394 {
2395 	uint8_t hexa_v;
2396 
2397 	hexa_v = hexa_digit_to_value(key[idx]);
2398 	if (hexa_v == 0xFF)
2399 		printf("invalid key: character %c at position %d is not a "
2400 		       "valid hexa digit\n", key[idx], idx);
2401 	return hexa_v;
2402 }
2403 
2404 static void
2405 cmd_config_rss_hash_key_parsed(void *parsed_result,
2406 			       __attribute__((unused)) struct cmdline *cl,
2407 			       __attribute__((unused)) void *data)
2408 {
2409 	struct cmd_config_rss_hash_key *res = parsed_result;
2410 	uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2411 	uint8_t xdgt0;
2412 	uint8_t xdgt1;
2413 	int i;
2414 	struct rte_eth_dev_info dev_info;
2415 	uint8_t hash_key_size;
2416 	uint32_t key_len;
2417 	int ret;
2418 
2419 	ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2420 	if (ret != 0)
2421 		return;
2422 
2423 	if (dev_info.hash_key_size > 0 &&
2424 			dev_info.hash_key_size <= sizeof(hash_key))
2425 		hash_key_size = dev_info.hash_key_size;
2426 	else {
2427 		printf("dev_info did not provide a valid hash key size\n");
2428 		return;
2429 	}
2430 	/* Check the length of the RSS hash key */
2431 	key_len = strlen(res->key);
2432 	if (key_len != (hash_key_size * 2)) {
2433 		printf("key length: %d invalid - key must be a string of %d"
2434 			   " hexa-decimal numbers\n",
2435 			   (int) key_len, hash_key_size * 2);
2436 		return;
2437 	}
2438 	/* Translate RSS hash key into binary representation */
2439 	for (i = 0; i < hash_key_size; i++) {
2440 		xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2441 		if (xdgt0 == 0xFF)
2442 			return;
2443 		xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2444 		if (xdgt1 == 0xFF)
2445 			return;
2446 		hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2447 	}
2448 	port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2449 			hash_key_size);
2450 }
2451 
2452 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2453 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2454 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2455 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2456 				 "config");
2457 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2458 	TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16);
2459 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2460 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2461 				 rss_hash_key, "rss-hash-key");
2462 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2463 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2464 				 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2465 				 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2466 				 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2467 				 "ipv6-tcp-ex#ipv6-udp-ex#"
2468 				 "l3-src-only#l3-dst-only#l4-src-only#l4-dst-only");
2469 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2470 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2471 
2472 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2473 	.f = cmd_config_rss_hash_key_parsed,
2474 	.data = NULL,
2475 	.help_str = "port config <port_id> rss-hash-key "
2476 		"ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2477 		"ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2478 		"l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|"
2479 		"l3-src-only|l3-dst-only|l4-src-only|l4-dst-only "
2480 		"<string of hex digits (variable length, NIC dependent)>",
2481 	.tokens = {
2482 		(void *)&cmd_config_rss_hash_key_port,
2483 		(void *)&cmd_config_rss_hash_key_config,
2484 		(void *)&cmd_config_rss_hash_key_port_id,
2485 		(void *)&cmd_config_rss_hash_key_rss_hash_key,
2486 		(void *)&cmd_config_rss_hash_key_rss_type,
2487 		(void *)&cmd_config_rss_hash_key_value,
2488 		NULL,
2489 	},
2490 };
2491 
2492 /* *** configure port rxq/txq ring size *** */
2493 struct cmd_config_rxtx_ring_size {
2494 	cmdline_fixed_string_t port;
2495 	cmdline_fixed_string_t config;
2496 	portid_t portid;
2497 	cmdline_fixed_string_t rxtxq;
2498 	uint16_t qid;
2499 	cmdline_fixed_string_t rsize;
2500 	uint16_t size;
2501 };
2502 
2503 static void
2504 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2505 				 __attribute__((unused)) struct cmdline *cl,
2506 				 __attribute__((unused)) void *data)
2507 {
2508 	struct cmd_config_rxtx_ring_size *res = parsed_result;
2509 	struct rte_port *port;
2510 	uint8_t isrx;
2511 
2512 	if (port_id_is_invalid(res->portid, ENABLED_WARN))
2513 		return;
2514 
2515 	if (res->portid == (portid_t)RTE_PORT_ALL) {
2516 		printf("Invalid port id\n");
2517 		return;
2518 	}
2519 
2520 	port = &ports[res->portid];
2521 
2522 	if (!strcmp(res->rxtxq, "rxq"))
2523 		isrx = 1;
2524 	else if (!strcmp(res->rxtxq, "txq"))
2525 		isrx = 0;
2526 	else {
2527 		printf("Unknown parameter\n");
2528 		return;
2529 	}
2530 
2531 	if (isrx && rx_queue_id_is_invalid(res->qid))
2532 		return;
2533 	else if (!isrx && tx_queue_id_is_invalid(res->qid))
2534 		return;
2535 
2536 	if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2537 		printf("Invalid rx ring_size, must > rx_free_thresh: %d\n",
2538 		       rx_free_thresh);
2539 		return;
2540 	}
2541 
2542 	if (isrx)
2543 		port->nb_rx_desc[res->qid] = res->size;
2544 	else
2545 		port->nb_tx_desc[res->qid] = res->size;
2546 
2547 	cmd_reconfig_device_queue(res->portid, 0, 1);
2548 }
2549 
2550 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2551 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2552 				 port, "port");
2553 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2554 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2555 				 config, "config");
2556 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2557 	TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2558 				 portid, UINT16);
2559 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2560 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2561 				 rxtxq, "rxq#txq");
2562 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2563 	TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2564 			      qid, UINT16);
2565 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2566 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2567 				 rsize, "ring_size");
2568 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2569 	TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2570 			      size, UINT16);
2571 
2572 cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2573 	.f = cmd_config_rxtx_ring_size_parsed,
2574 	.data = NULL,
2575 	.help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2576 	.tokens = {
2577 		(void *)&cmd_config_rxtx_ring_size_port,
2578 		(void *)&cmd_config_rxtx_ring_size_config,
2579 		(void *)&cmd_config_rxtx_ring_size_portid,
2580 		(void *)&cmd_config_rxtx_ring_size_rxtxq,
2581 		(void *)&cmd_config_rxtx_ring_size_qid,
2582 		(void *)&cmd_config_rxtx_ring_size_rsize,
2583 		(void *)&cmd_config_rxtx_ring_size_size,
2584 		NULL,
2585 	},
2586 };
2587 
2588 /* *** configure port rxq/txq start/stop *** */
2589 struct cmd_config_rxtx_queue {
2590 	cmdline_fixed_string_t port;
2591 	portid_t portid;
2592 	cmdline_fixed_string_t rxtxq;
2593 	uint16_t qid;
2594 	cmdline_fixed_string_t opname;
2595 };
2596 
2597 static void
2598 cmd_config_rxtx_queue_parsed(void *parsed_result,
2599 			__attribute__((unused)) struct cmdline *cl,
2600 			__attribute__((unused)) void *data)
2601 {
2602 	struct cmd_config_rxtx_queue *res = parsed_result;
2603 	uint8_t isrx;
2604 	uint8_t isstart;
2605 	int ret = 0;
2606 
2607 	if (test_done == 0) {
2608 		printf("Please stop forwarding first\n");
2609 		return;
2610 	}
2611 
2612 	if (port_id_is_invalid(res->portid, ENABLED_WARN))
2613 		return;
2614 
2615 	if (port_is_started(res->portid) != 1) {
2616 		printf("Please start port %u first\n", res->portid);
2617 		return;
2618 	}
2619 
2620 	if (!strcmp(res->rxtxq, "rxq"))
2621 		isrx = 1;
2622 	else if (!strcmp(res->rxtxq, "txq"))
2623 		isrx = 0;
2624 	else {
2625 		printf("Unknown parameter\n");
2626 		return;
2627 	}
2628 
2629 	if (isrx && rx_queue_id_is_invalid(res->qid))
2630 		return;
2631 	else if (!isrx && tx_queue_id_is_invalid(res->qid))
2632 		return;
2633 
2634 	if (!strcmp(res->opname, "start"))
2635 		isstart = 1;
2636 	else if (!strcmp(res->opname, "stop"))
2637 		isstart = 0;
2638 	else {
2639 		printf("Unknown parameter\n");
2640 		return;
2641 	}
2642 
2643 	if (isstart && isrx)
2644 		ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2645 	else if (!isstart && isrx)
2646 		ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2647 	else if (isstart && !isrx)
2648 		ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2649 	else
2650 		ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2651 
2652 	if (ret == -ENOTSUP)
2653 		printf("Function not supported in PMD driver\n");
2654 }
2655 
2656 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2657 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2658 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2659 	TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16);
2660 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2661 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2662 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2663 	TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
2664 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2665 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2666 						"start#stop");
2667 
2668 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2669 	.f = cmd_config_rxtx_queue_parsed,
2670 	.data = NULL,
2671 	.help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2672 	.tokens = {
2673 		(void *)&cmd_config_rxtx_queue_port,
2674 		(void *)&cmd_config_rxtx_queue_portid,
2675 		(void *)&cmd_config_rxtx_queue_rxtxq,
2676 		(void *)&cmd_config_rxtx_queue_qid,
2677 		(void *)&cmd_config_rxtx_queue_opname,
2678 		NULL,
2679 	},
2680 };
2681 
2682 /* *** configure port rxq/txq deferred start on/off *** */
2683 struct cmd_config_deferred_start_rxtx_queue {
2684 	cmdline_fixed_string_t port;
2685 	portid_t port_id;
2686 	cmdline_fixed_string_t rxtxq;
2687 	uint16_t qid;
2688 	cmdline_fixed_string_t opname;
2689 	cmdline_fixed_string_t state;
2690 };
2691 
2692 static void
2693 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2694 			__attribute__((unused)) struct cmdline *cl,
2695 			__attribute__((unused)) void *data)
2696 {
2697 	struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2698 	struct rte_port *port;
2699 	uint8_t isrx;
2700 	uint8_t ison;
2701 	uint8_t needreconfig = 0;
2702 
2703 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2704 		return;
2705 
2706 	if (port_is_started(res->port_id) != 0) {
2707 		printf("Please stop port %u first\n", res->port_id);
2708 		return;
2709 	}
2710 
2711 	port = &ports[res->port_id];
2712 
2713 	isrx = !strcmp(res->rxtxq, "rxq");
2714 
2715 	if (isrx && rx_queue_id_is_invalid(res->qid))
2716 		return;
2717 	else if (!isrx && tx_queue_id_is_invalid(res->qid))
2718 		return;
2719 
2720 	ison = !strcmp(res->state, "on");
2721 
2722 	if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) {
2723 		port->rx_conf[res->qid].rx_deferred_start = ison;
2724 		needreconfig = 1;
2725 	} else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) {
2726 		port->tx_conf[res->qid].tx_deferred_start = ison;
2727 		needreconfig = 1;
2728 	}
2729 
2730 	if (needreconfig)
2731 		cmd_reconfig_device_queue(res->port_id, 0, 1);
2732 }
2733 
2734 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2735 	TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2736 						port, "port");
2737 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2738 	TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2739 						port_id, UINT16);
2740 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2741 	TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2742 						rxtxq, "rxq#txq");
2743 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2744 	TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2745 						qid, UINT16);
2746 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2747 	TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2748 						opname, "deferred_start");
2749 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2750 	TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2751 						state, "on#off");
2752 
2753 cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
2754 	.f = cmd_config_deferred_start_rxtx_queue_parsed,
2755 	.data = NULL,
2756 	.help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
2757 	.tokens = {
2758 		(void *)&cmd_config_deferred_start_rxtx_queue_port,
2759 		(void *)&cmd_config_deferred_start_rxtx_queue_port_id,
2760 		(void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
2761 		(void *)&cmd_config_deferred_start_rxtx_queue_qid,
2762 		(void *)&cmd_config_deferred_start_rxtx_queue_opname,
2763 		(void *)&cmd_config_deferred_start_rxtx_queue_state,
2764 		NULL,
2765 	},
2766 };
2767 
2768 /* *** configure port rxq/txq setup *** */
2769 struct cmd_setup_rxtx_queue {
2770 	cmdline_fixed_string_t port;
2771 	portid_t portid;
2772 	cmdline_fixed_string_t rxtxq;
2773 	uint16_t qid;
2774 	cmdline_fixed_string_t setup;
2775 };
2776 
2777 /* Common CLI fields for queue setup */
2778 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2779 	TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2780 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2781 	TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, UINT16);
2782 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2783 	TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2784 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2785 	TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, UINT16);
2786 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2787 	TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2788 
2789 static void
2790 cmd_setup_rxtx_queue_parsed(
2791 	void *parsed_result,
2792 	__attribute__((unused)) struct cmdline *cl,
2793 	__attribute__((unused)) void *data)
2794 {
2795 	struct cmd_setup_rxtx_queue *res = parsed_result;
2796 	struct rte_port *port;
2797 	struct rte_mempool *mp;
2798 	unsigned int socket_id;
2799 	uint8_t isrx = 0;
2800 	int ret;
2801 
2802 	if (port_id_is_invalid(res->portid, ENABLED_WARN))
2803 		return;
2804 
2805 	if (res->portid == (portid_t)RTE_PORT_ALL) {
2806 		printf("Invalid port id\n");
2807 		return;
2808 	}
2809 
2810 	if (!strcmp(res->rxtxq, "rxq"))
2811 		isrx = 1;
2812 	else if (!strcmp(res->rxtxq, "txq"))
2813 		isrx = 0;
2814 	else {
2815 		printf("Unknown parameter\n");
2816 		return;
2817 	}
2818 
2819 	if (isrx && rx_queue_id_is_invalid(res->qid)) {
2820 		printf("Invalid rx queue\n");
2821 		return;
2822 	} else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2823 		printf("Invalid tx queue\n");
2824 		return;
2825 	}
2826 
2827 	port = &ports[res->portid];
2828 	if (isrx) {
2829 		socket_id = rxring_numa[res->portid];
2830 		if (!numa_support || socket_id == NUMA_NO_CONFIG)
2831 			socket_id = port->socket_id;
2832 
2833 		mp = mbuf_pool_find(socket_id);
2834 		if (mp == NULL) {
2835 			printf("Failed to setup RX queue: "
2836 				"No mempool allocation"
2837 				" on the socket %d\n",
2838 				rxring_numa[res->portid]);
2839 			return;
2840 		}
2841 		ret = rte_eth_rx_queue_setup(res->portid,
2842 					     res->qid,
2843 					     port->nb_rx_desc[res->qid],
2844 					     socket_id,
2845 					     &port->rx_conf[res->qid],
2846 					     mp);
2847 		if (ret)
2848 			printf("Failed to setup RX queue\n");
2849 	} else {
2850 		socket_id = txring_numa[res->portid];
2851 		if (!numa_support || socket_id == NUMA_NO_CONFIG)
2852 			socket_id = port->socket_id;
2853 
2854 		ret = rte_eth_tx_queue_setup(res->portid,
2855 					     res->qid,
2856 					     port->nb_tx_desc[res->qid],
2857 					     socket_id,
2858 					     &port->tx_conf[res->qid]);
2859 		if (ret)
2860 			printf("Failed to setup TX queue\n");
2861 	}
2862 }
2863 
2864 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2865 	.f = cmd_setup_rxtx_queue_parsed,
2866 	.data = NULL,
2867 	.help_str = "port <port_id> rxq|txq <queue_idx> setup",
2868 	.tokens = {
2869 		(void *)&cmd_setup_rxtx_queue_port,
2870 		(void *)&cmd_setup_rxtx_queue_portid,
2871 		(void *)&cmd_setup_rxtx_queue_rxtxq,
2872 		(void *)&cmd_setup_rxtx_queue_qid,
2873 		(void *)&cmd_setup_rxtx_queue_setup,
2874 		NULL,
2875 	},
2876 };
2877 
2878 
2879 /* *** Configure RSS RETA *** */
2880 struct cmd_config_rss_reta {
2881 	cmdline_fixed_string_t port;
2882 	cmdline_fixed_string_t keyword;
2883 	portid_t port_id;
2884 	cmdline_fixed_string_t name;
2885 	cmdline_fixed_string_t list_name;
2886 	cmdline_fixed_string_t list_of_items;
2887 };
2888 
2889 static int
2890 parse_reta_config(const char *str,
2891 		  struct rte_eth_rss_reta_entry64 *reta_conf,
2892 		  uint16_t nb_entries)
2893 {
2894 	int i;
2895 	unsigned size;
2896 	uint16_t hash_index, idx, shift;
2897 	uint16_t nb_queue;
2898 	char s[256];
2899 	const char *p, *p0 = str;
2900 	char *end;
2901 	enum fieldnames {
2902 		FLD_HASH_INDEX = 0,
2903 		FLD_QUEUE,
2904 		_NUM_FLD
2905 	};
2906 	unsigned long int_fld[_NUM_FLD];
2907 	char *str_fld[_NUM_FLD];
2908 
2909 	while ((p = strchr(p0,'(')) != NULL) {
2910 		++p;
2911 		if((p0 = strchr(p,')')) == NULL)
2912 			return -1;
2913 
2914 		size = p0 - p;
2915 		if(size >= sizeof(s))
2916 			return -1;
2917 
2918 		snprintf(s, sizeof(s), "%.*s", size, p);
2919 		if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2920 			return -1;
2921 		for (i = 0; i < _NUM_FLD; i++) {
2922 			errno = 0;
2923 			int_fld[i] = strtoul(str_fld[i], &end, 0);
2924 			if (errno != 0 || end == str_fld[i] ||
2925 					int_fld[i] > 65535)
2926 				return -1;
2927 		}
2928 
2929 		hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2930 		nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2931 
2932 		if (hash_index >= nb_entries) {
2933 			printf("Invalid RETA hash index=%d\n", hash_index);
2934 			return -1;
2935 		}
2936 
2937 		idx = hash_index / RTE_RETA_GROUP_SIZE;
2938 		shift = hash_index % RTE_RETA_GROUP_SIZE;
2939 		reta_conf[idx].mask |= (1ULL << shift);
2940 		reta_conf[idx].reta[shift] = nb_queue;
2941 	}
2942 
2943 	return 0;
2944 }
2945 
2946 static void
2947 cmd_set_rss_reta_parsed(void *parsed_result,
2948 			__attribute__((unused)) struct cmdline *cl,
2949 			__attribute__((unused)) void *data)
2950 {
2951 	int ret;
2952 	struct rte_eth_dev_info dev_info;
2953 	struct rte_eth_rss_reta_entry64 reta_conf[8];
2954 	struct cmd_config_rss_reta *res = parsed_result;
2955 
2956 	ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2957 	if (ret != 0)
2958 		return;
2959 
2960 	if (dev_info.reta_size == 0) {
2961 		printf("Redirection table size is 0 which is "
2962 					"invalid for RSS\n");
2963 		return;
2964 	} else
2965 		printf("The reta size of port %d is %u\n",
2966 			res->port_id, dev_info.reta_size);
2967 	if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2968 		printf("Currently do not support more than %u entries of "
2969 			"redirection table\n", ETH_RSS_RETA_SIZE_512);
2970 		return;
2971 	}
2972 
2973 	memset(reta_conf, 0, sizeof(reta_conf));
2974 	if (!strcmp(res->list_name, "reta")) {
2975 		if (parse_reta_config(res->list_of_items, reta_conf,
2976 						dev_info.reta_size)) {
2977 			printf("Invalid RSS Redirection Table "
2978 					"config entered\n");
2979 			return;
2980 		}
2981 		ret = rte_eth_dev_rss_reta_update(res->port_id,
2982 				reta_conf, dev_info.reta_size);
2983 		if (ret != 0)
2984 			printf("Bad redirection table parameter, "
2985 					"return code = %d \n", ret);
2986 	}
2987 }
2988 
2989 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2990 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2991 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2992 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2993 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2994 	TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16);
2995 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2996 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2997 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2998 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2999 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
3000         TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
3001                                  NULL);
3002 cmdline_parse_inst_t cmd_config_rss_reta = {
3003 	.f = cmd_set_rss_reta_parsed,
3004 	.data = NULL,
3005 	.help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
3006 	.tokens = {
3007 		(void *)&cmd_config_rss_reta_port,
3008 		(void *)&cmd_config_rss_reta_keyword,
3009 		(void *)&cmd_config_rss_reta_port_id,
3010 		(void *)&cmd_config_rss_reta_name,
3011 		(void *)&cmd_config_rss_reta_list_name,
3012 		(void *)&cmd_config_rss_reta_list_of_items,
3013 		NULL,
3014 	},
3015 };
3016 
3017 /* *** SHOW PORT RETA INFO *** */
3018 struct cmd_showport_reta {
3019 	cmdline_fixed_string_t show;
3020 	cmdline_fixed_string_t port;
3021 	portid_t port_id;
3022 	cmdline_fixed_string_t rss;
3023 	cmdline_fixed_string_t reta;
3024 	uint16_t size;
3025 	cmdline_fixed_string_t list_of_items;
3026 };
3027 
3028 static int
3029 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
3030 			   uint16_t nb_entries,
3031 			   char *str)
3032 {
3033 	uint32_t size;
3034 	const char *p, *p0 = str;
3035 	char s[256];
3036 	char *end;
3037 	char *str_fld[8];
3038 	uint16_t i;
3039 	uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
3040 			RTE_RETA_GROUP_SIZE;
3041 	int ret;
3042 
3043 	p = strchr(p0, '(');
3044 	if (p == NULL)
3045 		return -1;
3046 	p++;
3047 	p0 = strchr(p, ')');
3048 	if (p0 == NULL)
3049 		return -1;
3050 	size = p0 - p;
3051 	if (size >= sizeof(s)) {
3052 		printf("The string size exceeds the internal buffer size\n");
3053 		return -1;
3054 	}
3055 	snprintf(s, sizeof(s), "%.*s", size, p);
3056 	ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
3057 	if (ret <= 0 || ret != num) {
3058 		printf("The bits of masks do not match the number of "
3059 					"reta entries: %u\n", num);
3060 		return -1;
3061 	}
3062 	for (i = 0; i < ret; i++)
3063 		conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
3064 
3065 	return 0;
3066 }
3067 
3068 static void
3069 cmd_showport_reta_parsed(void *parsed_result,
3070 			 __attribute__((unused)) struct cmdline *cl,
3071 			 __attribute__((unused)) void *data)
3072 {
3073 	struct cmd_showport_reta *res = parsed_result;
3074 	struct rte_eth_rss_reta_entry64 reta_conf[8];
3075 	struct rte_eth_dev_info dev_info;
3076 	uint16_t max_reta_size;
3077 	int ret;
3078 
3079 	ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3080 	if (ret != 0)
3081 		return;
3082 
3083 	max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
3084 	if (res->size == 0 || res->size > max_reta_size) {
3085 		printf("Invalid redirection table size: %u (1-%u)\n",
3086 			res->size, max_reta_size);
3087 		return;
3088 	}
3089 
3090 	memset(reta_conf, 0, sizeof(reta_conf));
3091 	if (showport_parse_reta_config(reta_conf, res->size,
3092 				res->list_of_items) < 0) {
3093 		printf("Invalid string: %s for reta masks\n",
3094 					res->list_of_items);
3095 		return;
3096 	}
3097 	port_rss_reta_info(res->port_id, reta_conf, res->size);
3098 }
3099 
3100 cmdline_parse_token_string_t cmd_showport_reta_show =
3101 	TOKEN_STRING_INITIALIZER(struct  cmd_showport_reta, show, "show");
3102 cmdline_parse_token_string_t cmd_showport_reta_port =
3103 	TOKEN_STRING_INITIALIZER(struct  cmd_showport_reta, port, "port");
3104 cmdline_parse_token_num_t cmd_showport_reta_port_id =
3105 	TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16);
3106 cmdline_parse_token_string_t cmd_showport_reta_rss =
3107 	TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
3108 cmdline_parse_token_string_t cmd_showport_reta_reta =
3109 	TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
3110 cmdline_parse_token_num_t cmd_showport_reta_size =
3111 	TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
3112 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
3113 	TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
3114 					list_of_items, NULL);
3115 
3116 cmdline_parse_inst_t cmd_showport_reta = {
3117 	.f = cmd_showport_reta_parsed,
3118 	.data = NULL,
3119 	.help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
3120 	.tokens = {
3121 		(void *)&cmd_showport_reta_show,
3122 		(void *)&cmd_showport_reta_port,
3123 		(void *)&cmd_showport_reta_port_id,
3124 		(void *)&cmd_showport_reta_rss,
3125 		(void *)&cmd_showport_reta_reta,
3126 		(void *)&cmd_showport_reta_size,
3127 		(void *)&cmd_showport_reta_list_of_items,
3128 		NULL,
3129 	},
3130 };
3131 
3132 /* *** Show RSS hash configuration *** */
3133 struct cmd_showport_rss_hash {
3134 	cmdline_fixed_string_t show;
3135 	cmdline_fixed_string_t port;
3136 	portid_t port_id;
3137 	cmdline_fixed_string_t rss_hash;
3138 	cmdline_fixed_string_t rss_type;
3139 	cmdline_fixed_string_t key; /* optional argument */
3140 };
3141 
3142 static void cmd_showport_rss_hash_parsed(void *parsed_result,
3143 				__attribute__((unused)) struct cmdline *cl,
3144 				void *show_rss_key)
3145 {
3146 	struct cmd_showport_rss_hash *res = parsed_result;
3147 
3148 	port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
3149 }
3150 
3151 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
3152 	TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
3153 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
3154 	TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
3155 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
3156 	TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16);
3157 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
3158 	TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
3159 				 "rss-hash");
3160 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
3161 	TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
3162 
3163 cmdline_parse_inst_t cmd_showport_rss_hash = {
3164 	.f = cmd_showport_rss_hash_parsed,
3165 	.data = NULL,
3166 	.help_str = "show port <port_id> rss-hash",
3167 	.tokens = {
3168 		(void *)&cmd_showport_rss_hash_show,
3169 		(void *)&cmd_showport_rss_hash_port,
3170 		(void *)&cmd_showport_rss_hash_port_id,
3171 		(void *)&cmd_showport_rss_hash_rss_hash,
3172 		NULL,
3173 	},
3174 };
3175 
3176 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
3177 	.f = cmd_showport_rss_hash_parsed,
3178 	.data = (void *)1,
3179 	.help_str = "show port <port_id> rss-hash key",
3180 	.tokens = {
3181 		(void *)&cmd_showport_rss_hash_show,
3182 		(void *)&cmd_showport_rss_hash_port,
3183 		(void *)&cmd_showport_rss_hash_port_id,
3184 		(void *)&cmd_showport_rss_hash_rss_hash,
3185 		(void *)&cmd_showport_rss_hash_rss_key,
3186 		NULL,
3187 	},
3188 };
3189 
3190 /* *** Configure DCB *** */
3191 struct cmd_config_dcb {
3192 	cmdline_fixed_string_t port;
3193 	cmdline_fixed_string_t config;
3194 	portid_t port_id;
3195 	cmdline_fixed_string_t dcb;
3196 	cmdline_fixed_string_t vt;
3197 	cmdline_fixed_string_t vt_en;
3198 	uint8_t num_tcs;
3199 	cmdline_fixed_string_t pfc;
3200 	cmdline_fixed_string_t pfc_en;
3201 };
3202 
3203 static void
3204 cmd_config_dcb_parsed(void *parsed_result,
3205                         __attribute__((unused)) struct cmdline *cl,
3206                         __attribute__((unused)) void *data)
3207 {
3208 	struct cmd_config_dcb *res = parsed_result;
3209 	portid_t port_id = res->port_id;
3210 	struct rte_port *port;
3211 	uint8_t pfc_en;
3212 	int ret;
3213 
3214 	port = &ports[port_id];
3215 	/** Check if the port is not started **/
3216 	if (port->port_status != RTE_PORT_STOPPED) {
3217 		printf("Please stop port %d first\n", port_id);
3218 		return;
3219 	}
3220 
3221 	if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
3222 		printf("The invalid number of traffic class,"
3223 			" only 4 or 8 allowed.\n");
3224 		return;
3225 	}
3226 
3227 	if (nb_fwd_lcores < res->num_tcs) {
3228 		printf("nb_cores shouldn't be less than number of TCs.\n");
3229 		return;
3230 	}
3231 	if (!strncmp(res->pfc_en, "on", 2))
3232 		pfc_en = 1;
3233 	else
3234 		pfc_en = 0;
3235 
3236 	/* DCB in VT mode */
3237 	if (!strncmp(res->vt_en, "on", 2))
3238 		ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3239 				(enum rte_eth_nb_tcs)res->num_tcs,
3240 				pfc_en);
3241 	else
3242 		ret = init_port_dcb_config(port_id, DCB_ENABLED,
3243 				(enum rte_eth_nb_tcs)res->num_tcs,
3244 				pfc_en);
3245 
3246 
3247 	if (ret != 0) {
3248 		printf("Cannot initialize network ports.\n");
3249 		return;
3250 	}
3251 
3252 	cmd_reconfig_device_queue(port_id, 1, 1);
3253 }
3254 
3255 cmdline_parse_token_string_t cmd_config_dcb_port =
3256         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3257 cmdline_parse_token_string_t cmd_config_dcb_config =
3258         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3259 cmdline_parse_token_num_t cmd_config_dcb_port_id =
3260 	TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16);
3261 cmdline_parse_token_string_t cmd_config_dcb_dcb =
3262         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3263 cmdline_parse_token_string_t cmd_config_dcb_vt =
3264         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3265 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3266         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3267 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3268         TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
3269 cmdline_parse_token_string_t cmd_config_dcb_pfc=
3270         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3271 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
3272         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
3273 
3274 cmdline_parse_inst_t cmd_config_dcb = {
3275 	.f = cmd_config_dcb_parsed,
3276 	.data = NULL,
3277 	.help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
3278 	.tokens = {
3279 		(void *)&cmd_config_dcb_port,
3280 		(void *)&cmd_config_dcb_config,
3281 		(void *)&cmd_config_dcb_port_id,
3282 		(void *)&cmd_config_dcb_dcb,
3283 		(void *)&cmd_config_dcb_vt,
3284 		(void *)&cmd_config_dcb_vt_en,
3285 		(void *)&cmd_config_dcb_num_tcs,
3286 		(void *)&cmd_config_dcb_pfc,
3287 		(void *)&cmd_config_dcb_pfc_en,
3288                 NULL,
3289         },
3290 };
3291 
3292 /* *** configure number of packets per burst *** */
3293 struct cmd_config_burst {
3294 	cmdline_fixed_string_t port;
3295 	cmdline_fixed_string_t keyword;
3296 	cmdline_fixed_string_t all;
3297 	cmdline_fixed_string_t name;
3298 	uint16_t value;
3299 };
3300 
3301 static void
3302 cmd_config_burst_parsed(void *parsed_result,
3303 			__attribute__((unused)) struct cmdline *cl,
3304 			__attribute__((unused)) void *data)
3305 {
3306 	struct cmd_config_burst *res = parsed_result;
3307 	struct rte_eth_dev_info dev_info;
3308 	uint16_t rec_nb_pkts;
3309 	int ret;
3310 
3311 	if (!all_ports_stopped()) {
3312 		printf("Please stop all ports first\n");
3313 		return;
3314 	}
3315 
3316 	if (!strcmp(res->name, "burst")) {
3317 		if (res->value == 0) {
3318 			/* If user gives a value of zero, query the PMD for
3319 			 * its recommended Rx burst size. Testpmd uses a single
3320 			 * size for all ports, so assume all ports are the same
3321 			 * NIC model and use the values from Port 0.
3322 			 */
3323 			ret = eth_dev_info_get_print_err(0, &dev_info);
3324 			if (ret != 0)
3325 				return;
3326 
3327 			rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3328 
3329 			if (rec_nb_pkts == 0) {
3330 				printf("PMD does not recommend a burst size.\n"
3331 					"User provided value must be between"
3332 					" 1 and %d\n", MAX_PKT_BURST);
3333 				return;
3334 			} else if (rec_nb_pkts > MAX_PKT_BURST) {
3335 				printf("PMD recommended burst size of %d"
3336 					" exceeds maximum value of %d\n",
3337 					rec_nb_pkts, MAX_PKT_BURST);
3338 				return;
3339 			}
3340 			printf("Using PMD-provided burst value of %d\n",
3341 				rec_nb_pkts);
3342 			nb_pkt_per_burst = rec_nb_pkts;
3343 		} else if (res->value > MAX_PKT_BURST) {
3344 			printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
3345 			return;
3346 		} else
3347 			nb_pkt_per_burst = res->value;
3348 	} else {
3349 		printf("Unknown parameter\n");
3350 		return;
3351 	}
3352 
3353 	init_port_config();
3354 
3355 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3356 }
3357 
3358 cmdline_parse_token_string_t cmd_config_burst_port =
3359 	TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3360 cmdline_parse_token_string_t cmd_config_burst_keyword =
3361 	TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3362 cmdline_parse_token_string_t cmd_config_burst_all =
3363 	TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3364 cmdline_parse_token_string_t cmd_config_burst_name =
3365 	TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3366 cmdline_parse_token_num_t cmd_config_burst_value =
3367 	TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
3368 
3369 cmdline_parse_inst_t cmd_config_burst = {
3370 	.f = cmd_config_burst_parsed,
3371 	.data = NULL,
3372 	.help_str = "port config all burst <value>",
3373 	.tokens = {
3374 		(void *)&cmd_config_burst_port,
3375 		(void *)&cmd_config_burst_keyword,
3376 		(void *)&cmd_config_burst_all,
3377 		(void *)&cmd_config_burst_name,
3378 		(void *)&cmd_config_burst_value,
3379 		NULL,
3380 	},
3381 };
3382 
3383 /* *** configure rx/tx queues *** */
3384 struct cmd_config_thresh {
3385 	cmdline_fixed_string_t port;
3386 	cmdline_fixed_string_t keyword;
3387 	cmdline_fixed_string_t all;
3388 	cmdline_fixed_string_t name;
3389 	uint8_t value;
3390 };
3391 
3392 static void
3393 cmd_config_thresh_parsed(void *parsed_result,
3394 			__attribute__((unused)) struct cmdline *cl,
3395 			__attribute__((unused)) void *data)
3396 {
3397 	struct cmd_config_thresh *res = parsed_result;
3398 
3399 	if (!all_ports_stopped()) {
3400 		printf("Please stop all ports first\n");
3401 		return;
3402 	}
3403 
3404 	if (!strcmp(res->name, "txpt"))
3405 		tx_pthresh = res->value;
3406 	else if(!strcmp(res->name, "txht"))
3407 		tx_hthresh = res->value;
3408 	else if(!strcmp(res->name, "txwt"))
3409 		tx_wthresh = res->value;
3410 	else if(!strcmp(res->name, "rxpt"))
3411 		rx_pthresh = res->value;
3412 	else if(!strcmp(res->name, "rxht"))
3413 		rx_hthresh = res->value;
3414 	else if(!strcmp(res->name, "rxwt"))
3415 		rx_wthresh = res->value;
3416 	else {
3417 		printf("Unknown parameter\n");
3418 		return;
3419 	}
3420 
3421 	init_port_config();
3422 
3423 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3424 }
3425 
3426 cmdline_parse_token_string_t cmd_config_thresh_port =
3427 	TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3428 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3429 	TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3430 cmdline_parse_token_string_t cmd_config_thresh_all =
3431 	TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3432 cmdline_parse_token_string_t cmd_config_thresh_name =
3433 	TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3434 				"txpt#txht#txwt#rxpt#rxht#rxwt");
3435 cmdline_parse_token_num_t cmd_config_thresh_value =
3436 	TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
3437 
3438 cmdline_parse_inst_t cmd_config_thresh = {
3439 	.f = cmd_config_thresh_parsed,
3440 	.data = NULL,
3441 	.help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3442 	.tokens = {
3443 		(void *)&cmd_config_thresh_port,
3444 		(void *)&cmd_config_thresh_keyword,
3445 		(void *)&cmd_config_thresh_all,
3446 		(void *)&cmd_config_thresh_name,
3447 		(void *)&cmd_config_thresh_value,
3448 		NULL,
3449 	},
3450 };
3451 
3452 /* *** configure free/rs threshold *** */
3453 struct cmd_config_threshold {
3454 	cmdline_fixed_string_t port;
3455 	cmdline_fixed_string_t keyword;
3456 	cmdline_fixed_string_t all;
3457 	cmdline_fixed_string_t name;
3458 	uint16_t value;
3459 };
3460 
3461 static void
3462 cmd_config_threshold_parsed(void *parsed_result,
3463 			__attribute__((unused)) struct cmdline *cl,
3464 			__attribute__((unused)) void *data)
3465 {
3466 	struct cmd_config_threshold *res = parsed_result;
3467 
3468 	if (!all_ports_stopped()) {
3469 		printf("Please stop all ports first\n");
3470 		return;
3471 	}
3472 
3473 	if (!strcmp(res->name, "txfreet"))
3474 		tx_free_thresh = res->value;
3475 	else if (!strcmp(res->name, "txrst"))
3476 		tx_rs_thresh = res->value;
3477 	else if (!strcmp(res->name, "rxfreet"))
3478 		rx_free_thresh = res->value;
3479 	else {
3480 		printf("Unknown parameter\n");
3481 		return;
3482 	}
3483 
3484 	init_port_config();
3485 
3486 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3487 }
3488 
3489 cmdline_parse_token_string_t cmd_config_threshold_port =
3490 	TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3491 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3492 	TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3493 								"config");
3494 cmdline_parse_token_string_t cmd_config_threshold_all =
3495 	TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3496 cmdline_parse_token_string_t cmd_config_threshold_name =
3497 	TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3498 						"txfreet#txrst#rxfreet");
3499 cmdline_parse_token_num_t cmd_config_threshold_value =
3500 	TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
3501 
3502 cmdline_parse_inst_t cmd_config_threshold = {
3503 	.f = cmd_config_threshold_parsed,
3504 	.data = NULL,
3505 	.help_str = "port config all txfreet|txrst|rxfreet <value>",
3506 	.tokens = {
3507 		(void *)&cmd_config_threshold_port,
3508 		(void *)&cmd_config_threshold_keyword,
3509 		(void *)&cmd_config_threshold_all,
3510 		(void *)&cmd_config_threshold_name,
3511 		(void *)&cmd_config_threshold_value,
3512 		NULL,
3513 	},
3514 };
3515 
3516 /* *** stop *** */
3517 struct cmd_stop_result {
3518 	cmdline_fixed_string_t stop;
3519 };
3520 
3521 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
3522 			    __attribute__((unused)) struct cmdline *cl,
3523 			    __attribute__((unused)) void *data)
3524 {
3525 	stop_packet_forwarding();
3526 }
3527 
3528 cmdline_parse_token_string_t cmd_stop_stop =
3529 	TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3530 
3531 cmdline_parse_inst_t cmd_stop = {
3532 	.f = cmd_stop_parsed,
3533 	.data = NULL,
3534 	.help_str = "stop: Stop packet forwarding",
3535 	.tokens = {
3536 		(void *)&cmd_stop_stop,
3537 		NULL,
3538 	},
3539 };
3540 
3541 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3542 
3543 unsigned int
3544 parse_item_list(char* str, const char* item_name, unsigned int max_items,
3545 		unsigned int *parsed_items, int check_unique_values)
3546 {
3547 	unsigned int nb_item;
3548 	unsigned int value;
3549 	unsigned int i;
3550 	unsigned int j;
3551 	int value_ok;
3552 	char c;
3553 
3554 	/*
3555 	 * First parse all items in the list and store their value.
3556 	 */
3557 	value = 0;
3558 	nb_item = 0;
3559 	value_ok = 0;
3560 	for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3561 		c = str[i];
3562 		if ((c >= '0') && (c <= '9')) {
3563 			value = (unsigned int) (value * 10 + (c - '0'));
3564 			value_ok = 1;
3565 			continue;
3566 		}
3567 		if (c != ',') {
3568 			printf("character %c is not a decimal digit\n", c);
3569 			return 0;
3570 		}
3571 		if (! value_ok) {
3572 			printf("No valid value before comma\n");
3573 			return 0;
3574 		}
3575 		if (nb_item < max_items) {
3576 			parsed_items[nb_item] = value;
3577 			value_ok = 0;
3578 			value = 0;
3579 		}
3580 		nb_item++;
3581 	}
3582 	if (nb_item >= max_items) {
3583 		printf("Number of %s = %u > %u (maximum items)\n",
3584 		       item_name, nb_item + 1, max_items);
3585 		return 0;
3586 	}
3587 	parsed_items[nb_item++] = value;
3588 	if (! check_unique_values)
3589 		return nb_item;
3590 
3591 	/*
3592 	 * Then, check that all values in the list are differents.
3593 	 * No optimization here...
3594 	 */
3595 	for (i = 0; i < nb_item; i++) {
3596 		for (j = i + 1; j < nb_item; j++) {
3597 			if (parsed_items[j] == parsed_items[i]) {
3598 				printf("duplicated %s %u at index %u and %u\n",
3599 				       item_name, parsed_items[i], i, j);
3600 				return 0;
3601 			}
3602 		}
3603 	}
3604 	return nb_item;
3605 }
3606 
3607 struct cmd_set_list_result {
3608 	cmdline_fixed_string_t cmd_keyword;
3609 	cmdline_fixed_string_t list_name;
3610 	cmdline_fixed_string_t list_of_items;
3611 };
3612 
3613 static void cmd_set_list_parsed(void *parsed_result,
3614 				__attribute__((unused)) struct cmdline *cl,
3615 				__attribute__((unused)) void *data)
3616 {
3617 	struct cmd_set_list_result *res;
3618 	union {
3619 		unsigned int lcorelist[RTE_MAX_LCORE];
3620 		unsigned int portlist[RTE_MAX_ETHPORTS];
3621 	} parsed_items;
3622 	unsigned int nb_item;
3623 
3624 	if (test_done == 0) {
3625 		printf("Please stop forwarding first\n");
3626 		return;
3627 	}
3628 
3629 	res = parsed_result;
3630 	if (!strcmp(res->list_name, "corelist")) {
3631 		nb_item = parse_item_list(res->list_of_items, "core",
3632 					  RTE_MAX_LCORE,
3633 					  parsed_items.lcorelist, 1);
3634 		if (nb_item > 0) {
3635 			set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3636 			fwd_config_setup();
3637 		}
3638 		return;
3639 	}
3640 	if (!strcmp(res->list_name, "portlist")) {
3641 		nb_item = parse_item_list(res->list_of_items, "port",
3642 					  RTE_MAX_ETHPORTS,
3643 					  parsed_items.portlist, 1);
3644 		if (nb_item > 0) {
3645 			set_fwd_ports_list(parsed_items.portlist, nb_item);
3646 			fwd_config_setup();
3647 		}
3648 	}
3649 }
3650 
3651 cmdline_parse_token_string_t cmd_set_list_keyword =
3652 	TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3653 				 "set");
3654 cmdline_parse_token_string_t cmd_set_list_name =
3655 	TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3656 				 "corelist#portlist");
3657 cmdline_parse_token_string_t cmd_set_list_of_items =
3658 	TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3659 				 NULL);
3660 
3661 cmdline_parse_inst_t cmd_set_fwd_list = {
3662 	.f = cmd_set_list_parsed,
3663 	.data = NULL,
3664 	.help_str = "set corelist|portlist <list0[,list1]*>",
3665 	.tokens = {
3666 		(void *)&cmd_set_list_keyword,
3667 		(void *)&cmd_set_list_name,
3668 		(void *)&cmd_set_list_of_items,
3669 		NULL,
3670 	},
3671 };
3672 
3673 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3674 
3675 struct cmd_setmask_result {
3676 	cmdline_fixed_string_t set;
3677 	cmdline_fixed_string_t mask;
3678 	uint64_t hexavalue;
3679 };
3680 
3681 static void cmd_set_mask_parsed(void *parsed_result,
3682 				__attribute__((unused)) struct cmdline *cl,
3683 				__attribute__((unused)) void *data)
3684 {
3685 	struct cmd_setmask_result *res = parsed_result;
3686 
3687 	if (test_done == 0) {
3688 		printf("Please stop forwarding first\n");
3689 		return;
3690 	}
3691 	if (!strcmp(res->mask, "coremask")) {
3692 		set_fwd_lcores_mask(res->hexavalue);
3693 		fwd_config_setup();
3694 	} else if (!strcmp(res->mask, "portmask")) {
3695 		set_fwd_ports_mask(res->hexavalue);
3696 		fwd_config_setup();
3697 	}
3698 }
3699 
3700 cmdline_parse_token_string_t cmd_setmask_set =
3701 	TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3702 cmdline_parse_token_string_t cmd_setmask_mask =
3703 	TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3704 				 "coremask#portmask");
3705 cmdline_parse_token_num_t cmd_setmask_value =
3706 	TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
3707 
3708 cmdline_parse_inst_t cmd_set_fwd_mask = {
3709 	.f = cmd_set_mask_parsed,
3710 	.data = NULL,
3711 	.help_str = "set coremask|portmask <hexadecimal value>",
3712 	.tokens = {
3713 		(void *)&cmd_setmask_set,
3714 		(void *)&cmd_setmask_mask,
3715 		(void *)&cmd_setmask_value,
3716 		NULL,
3717 	},
3718 };
3719 
3720 /*
3721  * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3722  */
3723 struct cmd_set_result {
3724 	cmdline_fixed_string_t set;
3725 	cmdline_fixed_string_t what;
3726 	uint16_t value;
3727 };
3728 
3729 static void cmd_set_parsed(void *parsed_result,
3730 			   __attribute__((unused)) struct cmdline *cl,
3731 			   __attribute__((unused)) void *data)
3732 {
3733 	struct cmd_set_result *res = parsed_result;
3734 	if (!strcmp(res->what, "nbport")) {
3735 		set_fwd_ports_number(res->value);
3736 		fwd_config_setup();
3737 	} else if (!strcmp(res->what, "nbcore")) {
3738 		set_fwd_lcores_number(res->value);
3739 		fwd_config_setup();
3740 	} else if (!strcmp(res->what, "burst"))
3741 		set_nb_pkt_per_burst(res->value);
3742 	else if (!strcmp(res->what, "verbose"))
3743 		set_verbose_level(res->value);
3744 }
3745 
3746 cmdline_parse_token_string_t cmd_set_set =
3747 	TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3748 cmdline_parse_token_string_t cmd_set_what =
3749 	TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3750 				 "nbport#nbcore#burst#verbose");
3751 cmdline_parse_token_num_t cmd_set_value =
3752 	TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
3753 
3754 cmdline_parse_inst_t cmd_set_numbers = {
3755 	.f = cmd_set_parsed,
3756 	.data = NULL,
3757 	.help_str = "set nbport|nbcore|burst|verbose <value>",
3758 	.tokens = {
3759 		(void *)&cmd_set_set,
3760 		(void *)&cmd_set_what,
3761 		(void *)&cmd_set_value,
3762 		NULL,
3763 	},
3764 };
3765 
3766 /* *** SET LOG LEVEL CONFIGURATION *** */
3767 
3768 struct cmd_set_log_result {
3769 	cmdline_fixed_string_t set;
3770 	cmdline_fixed_string_t log;
3771 	cmdline_fixed_string_t type;
3772 	uint32_t level;
3773 };
3774 
3775 static void
3776 cmd_set_log_parsed(void *parsed_result,
3777 		   __attribute__((unused)) struct cmdline *cl,
3778 		   __attribute__((unused)) void *data)
3779 {
3780 	struct cmd_set_log_result *res;
3781 	int ret;
3782 
3783 	res = parsed_result;
3784 	if (!strcmp(res->type, "global"))
3785 		rte_log_set_global_level(res->level);
3786 	else {
3787 		ret = rte_log_set_level_regexp(res->type, res->level);
3788 		if (ret < 0)
3789 			printf("Unable to set log level\n");
3790 	}
3791 }
3792 
3793 cmdline_parse_token_string_t cmd_set_log_set =
3794 	TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3795 cmdline_parse_token_string_t cmd_set_log_log =
3796 	TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3797 cmdline_parse_token_string_t cmd_set_log_type =
3798 	TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3799 cmdline_parse_token_num_t cmd_set_log_level =
3800 	TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, UINT32);
3801 
3802 cmdline_parse_inst_t cmd_set_log = {
3803 	.f = cmd_set_log_parsed,
3804 	.data = NULL,
3805 	.help_str = "set log global|<type> <level>",
3806 	.tokens = {
3807 		(void *)&cmd_set_log_set,
3808 		(void *)&cmd_set_log_log,
3809 		(void *)&cmd_set_log_type,
3810 		(void *)&cmd_set_log_level,
3811 		NULL,
3812 	},
3813 };
3814 
3815 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3816 
3817 struct cmd_set_txpkts_result {
3818 	cmdline_fixed_string_t cmd_keyword;
3819 	cmdline_fixed_string_t txpkts;
3820 	cmdline_fixed_string_t seg_lengths;
3821 };
3822 
3823 static void
3824 cmd_set_txpkts_parsed(void *parsed_result,
3825 		      __attribute__((unused)) struct cmdline *cl,
3826 		      __attribute__((unused)) void *data)
3827 {
3828 	struct cmd_set_txpkts_result *res;
3829 	unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3830 	unsigned int nb_segs;
3831 
3832 	res = parsed_result;
3833 	nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3834 				  RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3835 	if (nb_segs > 0)
3836 		set_tx_pkt_segments(seg_lengths, nb_segs);
3837 }
3838 
3839 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3840 	TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3841 				 cmd_keyword, "set");
3842 cmdline_parse_token_string_t cmd_set_txpkts_name =
3843 	TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3844 				 txpkts, "txpkts");
3845 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3846 	TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3847 				 seg_lengths, NULL);
3848 
3849 cmdline_parse_inst_t cmd_set_txpkts = {
3850 	.f = cmd_set_txpkts_parsed,
3851 	.data = NULL,
3852 	.help_str = "set txpkts <len0[,len1]*>",
3853 	.tokens = {
3854 		(void *)&cmd_set_txpkts_keyword,
3855 		(void *)&cmd_set_txpkts_name,
3856 		(void *)&cmd_set_txpkts_lengths,
3857 		NULL,
3858 	},
3859 };
3860 
3861 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
3862 
3863 struct cmd_set_txsplit_result {
3864 	cmdline_fixed_string_t cmd_keyword;
3865 	cmdline_fixed_string_t txsplit;
3866 	cmdline_fixed_string_t mode;
3867 };
3868 
3869 static void
3870 cmd_set_txsplit_parsed(void *parsed_result,
3871 		      __attribute__((unused)) struct cmdline *cl,
3872 		      __attribute__((unused)) void *data)
3873 {
3874 	struct cmd_set_txsplit_result *res;
3875 
3876 	res = parsed_result;
3877 	set_tx_pkt_split(res->mode);
3878 }
3879 
3880 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
3881 	TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3882 				 cmd_keyword, "set");
3883 cmdline_parse_token_string_t cmd_set_txsplit_name =
3884 	TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3885 				 txsplit, "txsplit");
3886 cmdline_parse_token_string_t cmd_set_txsplit_mode =
3887 	TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3888 				 mode, NULL);
3889 
3890 cmdline_parse_inst_t cmd_set_txsplit = {
3891 	.f = cmd_set_txsplit_parsed,
3892 	.data = NULL,
3893 	.help_str = "set txsplit on|off|rand",
3894 	.tokens = {
3895 		(void *)&cmd_set_txsplit_keyword,
3896 		(void *)&cmd_set_txsplit_name,
3897 		(void *)&cmd_set_txsplit_mode,
3898 		NULL,
3899 	},
3900 };
3901 
3902 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
3903 struct cmd_rx_vlan_filter_all_result {
3904 	cmdline_fixed_string_t rx_vlan;
3905 	cmdline_fixed_string_t what;
3906 	cmdline_fixed_string_t all;
3907 	portid_t port_id;
3908 };
3909 
3910 static void
3911 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
3912 			      __attribute__((unused)) struct cmdline *cl,
3913 			      __attribute__((unused)) void *data)
3914 {
3915 	struct cmd_rx_vlan_filter_all_result *res = parsed_result;
3916 
3917 	if (!strcmp(res->what, "add"))
3918 		rx_vlan_all_filter_set(res->port_id, 1);
3919 	else
3920 		rx_vlan_all_filter_set(res->port_id, 0);
3921 }
3922 
3923 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
3924 	TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3925 				 rx_vlan, "rx_vlan");
3926 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
3927 	TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3928 				 what, "add#rm");
3929 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
3930 	TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3931 				 all, "all");
3932 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
3933 	TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3934 			      port_id, UINT16);
3935 
3936 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
3937 	.f = cmd_rx_vlan_filter_all_parsed,
3938 	.data = NULL,
3939 	.help_str = "rx_vlan add|rm all <port_id>: "
3940 		"Add/Remove all identifiers to/from the set of VLAN "
3941 		"identifiers filtered by a port",
3942 	.tokens = {
3943 		(void *)&cmd_rx_vlan_filter_all_rx_vlan,
3944 		(void *)&cmd_rx_vlan_filter_all_what,
3945 		(void *)&cmd_rx_vlan_filter_all_all,
3946 		(void *)&cmd_rx_vlan_filter_all_portid,
3947 		NULL,
3948 	},
3949 };
3950 
3951 /* *** VLAN OFFLOAD SET ON A PORT *** */
3952 struct cmd_vlan_offload_result {
3953 	cmdline_fixed_string_t vlan;
3954 	cmdline_fixed_string_t set;
3955 	cmdline_fixed_string_t vlan_type;
3956 	cmdline_fixed_string_t what;
3957 	cmdline_fixed_string_t on;
3958 	cmdline_fixed_string_t port_id;
3959 };
3960 
3961 static void
3962 cmd_vlan_offload_parsed(void *parsed_result,
3963 			  __attribute__((unused)) struct cmdline *cl,
3964 			  __attribute__((unused)) void *data)
3965 {
3966 	int on;
3967 	struct cmd_vlan_offload_result *res = parsed_result;
3968 	char *str;
3969 	int i, len = 0;
3970 	portid_t port_id = 0;
3971 	unsigned int tmp;
3972 
3973 	str = res->port_id;
3974 	len = strnlen(str, STR_TOKEN_SIZE);
3975 	i = 0;
3976 	/* Get port_id first */
3977 	while(i < len){
3978 		if(str[i] == ',')
3979 			break;
3980 
3981 		i++;
3982 	}
3983 	str[i]='\0';
3984 	tmp = strtoul(str, NULL, 0);
3985 	/* If port_id greater that what portid_t can represent, return */
3986 	if(tmp >= RTE_MAX_ETHPORTS)
3987 		return;
3988 	port_id = (portid_t)tmp;
3989 
3990 	if (!strcmp(res->on, "on"))
3991 		on = 1;
3992 	else
3993 		on = 0;
3994 
3995 	if (!strcmp(res->what, "strip"))
3996 		rx_vlan_strip_set(port_id,  on);
3997 	else if(!strcmp(res->what, "stripq")){
3998 		uint16_t queue_id = 0;
3999 
4000 		/* No queue_id, return */
4001 		if(i + 1 >= len) {
4002 			printf("must specify (port,queue_id)\n");
4003 			return;
4004 		}
4005 		tmp = strtoul(str + i + 1, NULL, 0);
4006 		/* If queue_id greater that what 16-bits can represent, return */
4007 		if(tmp > 0xffff)
4008 			return;
4009 
4010 		queue_id = (uint16_t)tmp;
4011 		rx_vlan_strip_set_on_queue(port_id, queue_id, on);
4012 	}
4013 	else if (!strcmp(res->what, "filter"))
4014 		rx_vlan_filter_set(port_id, on);
4015 	else if (!strcmp(res->what, "qinq_strip"))
4016 		rx_vlan_qinq_strip_set(port_id, on);
4017 	else
4018 		vlan_extend_set(port_id, on);
4019 
4020 	return;
4021 }
4022 
4023 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
4024 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4025 				 vlan, "vlan");
4026 cmdline_parse_token_string_t cmd_vlan_offload_set =
4027 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4028 				 set, "set");
4029 cmdline_parse_token_string_t cmd_vlan_offload_what =
4030 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4031 				what, "strip#filter#qinq_strip#extend#stripq");
4032 cmdline_parse_token_string_t cmd_vlan_offload_on =
4033 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4034 			      on, "on#off");
4035 cmdline_parse_token_string_t cmd_vlan_offload_portid =
4036 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4037 			      port_id, NULL);
4038 
4039 cmdline_parse_inst_t cmd_vlan_offload = {
4040 	.f = cmd_vlan_offload_parsed,
4041 	.data = NULL,
4042 	.help_str = "vlan set strip|filter|qinq_strip|extend|stripq on|off "
4043 		"<port_id[,queue_id]>: "
4044 		"Strip/Filter/QinQ for rx side Extend for both rx/tx sides",
4045 	.tokens = {
4046 		(void *)&cmd_vlan_offload_vlan,
4047 		(void *)&cmd_vlan_offload_set,
4048 		(void *)&cmd_vlan_offload_what,
4049 		(void *)&cmd_vlan_offload_on,
4050 		(void *)&cmd_vlan_offload_portid,
4051 		NULL,
4052 	},
4053 };
4054 
4055 /* *** VLAN TPID SET ON A PORT *** */
4056 struct cmd_vlan_tpid_result {
4057 	cmdline_fixed_string_t vlan;
4058 	cmdline_fixed_string_t set;
4059 	cmdline_fixed_string_t vlan_type;
4060 	cmdline_fixed_string_t what;
4061 	uint16_t tp_id;
4062 	portid_t port_id;
4063 };
4064 
4065 static void
4066 cmd_vlan_tpid_parsed(void *parsed_result,
4067 			  __attribute__((unused)) struct cmdline *cl,
4068 			  __attribute__((unused)) void *data)
4069 {
4070 	struct cmd_vlan_tpid_result *res = parsed_result;
4071 	enum rte_vlan_type vlan_type;
4072 
4073 	if (!strcmp(res->vlan_type, "inner"))
4074 		vlan_type = ETH_VLAN_TYPE_INNER;
4075 	else if (!strcmp(res->vlan_type, "outer"))
4076 		vlan_type = ETH_VLAN_TYPE_OUTER;
4077 	else {
4078 		printf("Unknown vlan type\n");
4079 		return;
4080 	}
4081 	vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
4082 }
4083 
4084 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
4085 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4086 				 vlan, "vlan");
4087 cmdline_parse_token_string_t cmd_vlan_tpid_set =
4088 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4089 				 set, "set");
4090 cmdline_parse_token_string_t cmd_vlan_type =
4091 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4092 				 vlan_type, "inner#outer");
4093 cmdline_parse_token_string_t cmd_vlan_tpid_what =
4094 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4095 				 what, "tpid");
4096 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
4097 	TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4098 			      tp_id, UINT16);
4099 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
4100 	TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4101 			      port_id, UINT16);
4102 
4103 cmdline_parse_inst_t cmd_vlan_tpid = {
4104 	.f = cmd_vlan_tpid_parsed,
4105 	.data = NULL,
4106 	.help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
4107 		"Set the VLAN Ether type",
4108 	.tokens = {
4109 		(void *)&cmd_vlan_tpid_vlan,
4110 		(void *)&cmd_vlan_tpid_set,
4111 		(void *)&cmd_vlan_type,
4112 		(void *)&cmd_vlan_tpid_what,
4113 		(void *)&cmd_vlan_tpid_tpid,
4114 		(void *)&cmd_vlan_tpid_portid,
4115 		NULL,
4116 	},
4117 };
4118 
4119 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4120 struct cmd_rx_vlan_filter_result {
4121 	cmdline_fixed_string_t rx_vlan;
4122 	cmdline_fixed_string_t what;
4123 	uint16_t vlan_id;
4124 	portid_t port_id;
4125 };
4126 
4127 static void
4128 cmd_rx_vlan_filter_parsed(void *parsed_result,
4129 			  __attribute__((unused)) struct cmdline *cl,
4130 			  __attribute__((unused)) void *data)
4131 {
4132 	struct cmd_rx_vlan_filter_result *res = parsed_result;
4133 
4134 	if (!strcmp(res->what, "add"))
4135 		rx_vft_set(res->port_id, res->vlan_id, 1);
4136 	else
4137 		rx_vft_set(res->port_id, res->vlan_id, 0);
4138 }
4139 
4140 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
4141 	TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4142 				 rx_vlan, "rx_vlan");
4143 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
4144 	TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4145 				 what, "add#rm");
4146 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
4147 	TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4148 			      vlan_id, UINT16);
4149 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
4150 	TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4151 			      port_id, UINT16);
4152 
4153 cmdline_parse_inst_t cmd_rx_vlan_filter = {
4154 	.f = cmd_rx_vlan_filter_parsed,
4155 	.data = NULL,
4156 	.help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
4157 		"Add/Remove a VLAN identifier to/from the set of VLAN "
4158 		"identifiers filtered by a port",
4159 	.tokens = {
4160 		(void *)&cmd_rx_vlan_filter_rx_vlan,
4161 		(void *)&cmd_rx_vlan_filter_what,
4162 		(void *)&cmd_rx_vlan_filter_vlanid,
4163 		(void *)&cmd_rx_vlan_filter_portid,
4164 		NULL,
4165 	},
4166 };
4167 
4168 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4169 struct cmd_tx_vlan_set_result {
4170 	cmdline_fixed_string_t tx_vlan;
4171 	cmdline_fixed_string_t set;
4172 	portid_t port_id;
4173 	uint16_t vlan_id;
4174 };
4175 
4176 static void
4177 cmd_tx_vlan_set_parsed(void *parsed_result,
4178 		       __attribute__((unused)) struct cmdline *cl,
4179 		       __attribute__((unused)) void *data)
4180 {
4181 	struct cmd_tx_vlan_set_result *res = parsed_result;
4182 
4183 	if (!port_is_stopped(res->port_id)) {
4184 		printf("Please stop port %d first\n", res->port_id);
4185 		return;
4186 	}
4187 
4188 	tx_vlan_set(res->port_id, res->vlan_id);
4189 
4190 	cmd_reconfig_device_queue(res->port_id, 1, 1);
4191 }
4192 
4193 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4194 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4195 				 tx_vlan, "tx_vlan");
4196 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4197 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4198 				 set, "set");
4199 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4200 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4201 			      port_id, UINT16);
4202 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
4203 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4204 			      vlan_id, UINT16);
4205 
4206 cmdline_parse_inst_t cmd_tx_vlan_set = {
4207 	.f = cmd_tx_vlan_set_parsed,
4208 	.data = NULL,
4209 	.help_str = "tx_vlan set <port_id> <vlan_id>: "
4210 		"Enable hardware insertion of a single VLAN header "
4211 		"with a given TAG Identifier in packets sent on a port",
4212 	.tokens = {
4213 		(void *)&cmd_tx_vlan_set_tx_vlan,
4214 		(void *)&cmd_tx_vlan_set_set,
4215 		(void *)&cmd_tx_vlan_set_portid,
4216 		(void *)&cmd_tx_vlan_set_vlanid,
4217 		NULL,
4218 	},
4219 };
4220 
4221 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4222 struct cmd_tx_vlan_set_qinq_result {
4223 	cmdline_fixed_string_t tx_vlan;
4224 	cmdline_fixed_string_t set;
4225 	portid_t port_id;
4226 	uint16_t vlan_id;
4227 	uint16_t vlan_id_outer;
4228 };
4229 
4230 static void
4231 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4232 			    __attribute__((unused)) struct cmdline *cl,
4233 			    __attribute__((unused)) void *data)
4234 {
4235 	struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
4236 
4237 	if (!port_is_stopped(res->port_id)) {
4238 		printf("Please stop port %d first\n", res->port_id);
4239 		return;
4240 	}
4241 
4242 	tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
4243 
4244 	cmd_reconfig_device_queue(res->port_id, 1, 1);
4245 }
4246 
4247 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
4248 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4249 		tx_vlan, "tx_vlan");
4250 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
4251 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4252 		set, "set");
4253 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
4254 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4255 		port_id, UINT16);
4256 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
4257 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4258 		vlan_id, UINT16);
4259 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
4260 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4261 		vlan_id_outer, UINT16);
4262 
4263 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
4264 	.f = cmd_tx_vlan_set_qinq_parsed,
4265 	.data = NULL,
4266 	.help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
4267 		"Enable hardware insertion of double VLAN header "
4268 		"with given TAG Identifiers in packets sent on a port",
4269 	.tokens = {
4270 		(void *)&cmd_tx_vlan_set_qinq_tx_vlan,
4271 		(void *)&cmd_tx_vlan_set_qinq_set,
4272 		(void *)&cmd_tx_vlan_set_qinq_portid,
4273 		(void *)&cmd_tx_vlan_set_qinq_vlanid,
4274 		(void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
4275 		NULL,
4276 	},
4277 };
4278 
4279 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
4280 struct cmd_tx_vlan_set_pvid_result {
4281 	cmdline_fixed_string_t tx_vlan;
4282 	cmdline_fixed_string_t set;
4283 	cmdline_fixed_string_t pvid;
4284 	portid_t port_id;
4285 	uint16_t vlan_id;
4286 	cmdline_fixed_string_t mode;
4287 };
4288 
4289 static void
4290 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
4291 			    __attribute__((unused)) struct cmdline *cl,
4292 			    __attribute__((unused)) void *data)
4293 {
4294 	struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
4295 
4296 	if (strcmp(res->mode, "on") == 0)
4297 		tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
4298 	else
4299 		tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
4300 }
4301 
4302 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
4303 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4304 				 tx_vlan, "tx_vlan");
4305 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
4306 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4307 				 set, "set");
4308 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
4309 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4310 				 pvid, "pvid");
4311 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
4312 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4313 			     port_id, UINT16);
4314 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
4315 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4316 			      vlan_id, UINT16);
4317 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
4318 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4319 				 mode, "on#off");
4320 
4321 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
4322 	.f = cmd_tx_vlan_set_pvid_parsed,
4323 	.data = NULL,
4324 	.help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
4325 	.tokens = {
4326 		(void *)&cmd_tx_vlan_set_pvid_tx_vlan,
4327 		(void *)&cmd_tx_vlan_set_pvid_set,
4328 		(void *)&cmd_tx_vlan_set_pvid_pvid,
4329 		(void *)&cmd_tx_vlan_set_pvid_port_id,
4330 		(void *)&cmd_tx_vlan_set_pvid_vlan_id,
4331 		(void *)&cmd_tx_vlan_set_pvid_mode,
4332 		NULL,
4333 	},
4334 };
4335 
4336 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4337 struct cmd_tx_vlan_reset_result {
4338 	cmdline_fixed_string_t tx_vlan;
4339 	cmdline_fixed_string_t reset;
4340 	portid_t port_id;
4341 };
4342 
4343 static void
4344 cmd_tx_vlan_reset_parsed(void *parsed_result,
4345 			 __attribute__((unused)) struct cmdline *cl,
4346 			 __attribute__((unused)) void *data)
4347 {
4348 	struct cmd_tx_vlan_reset_result *res = parsed_result;
4349 
4350 	if (!port_is_stopped(res->port_id)) {
4351 		printf("Please stop port %d first\n", res->port_id);
4352 		return;
4353 	}
4354 
4355 	tx_vlan_reset(res->port_id);
4356 
4357 	cmd_reconfig_device_queue(res->port_id, 1, 1);
4358 }
4359 
4360 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4361 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4362 				 tx_vlan, "tx_vlan");
4363 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4364 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4365 				 reset, "reset");
4366 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4367 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4368 			      port_id, UINT16);
4369 
4370 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4371 	.f = cmd_tx_vlan_reset_parsed,
4372 	.data = NULL,
4373 	.help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4374 		"VLAN header in packets sent on a port",
4375 	.tokens = {
4376 		(void *)&cmd_tx_vlan_reset_tx_vlan,
4377 		(void *)&cmd_tx_vlan_reset_reset,
4378 		(void *)&cmd_tx_vlan_reset_portid,
4379 		NULL,
4380 	},
4381 };
4382 
4383 
4384 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4385 struct cmd_csum_result {
4386 	cmdline_fixed_string_t csum;
4387 	cmdline_fixed_string_t mode;
4388 	cmdline_fixed_string_t proto;
4389 	cmdline_fixed_string_t hwsw;
4390 	portid_t port_id;
4391 };
4392 
4393 static void
4394 csum_show(int port_id)
4395 {
4396 	struct rte_eth_dev_info dev_info;
4397 	uint64_t tx_offloads;
4398 	int ret;
4399 
4400 	tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4401 	printf("Parse tunnel is %s\n",
4402 		(ports[port_id].parse_tunnel) ? "on" : "off");
4403 	printf("IP checksum offload is %s\n",
4404 		(tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4405 	printf("UDP checksum offload is %s\n",
4406 		(tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4407 	printf("TCP checksum offload is %s\n",
4408 		(tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4409 	printf("SCTP checksum offload is %s\n",
4410 		(tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4411 	printf("Outer-Ip checksum offload is %s\n",
4412 		(tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4413 	printf("Outer-Udp checksum offload is %s\n",
4414 		(tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
4415 
4416 	/* display warnings if configuration is not supported by the NIC */
4417 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
4418 	if (ret != 0)
4419 		return;
4420 
4421 	if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
4422 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4423 		printf("Warning: hardware IP checksum enabled but not "
4424 			"supported by port %d\n", port_id);
4425 	}
4426 	if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
4427 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
4428 		printf("Warning: hardware UDP checksum enabled but not "
4429 			"supported by port %d\n", port_id);
4430 	}
4431 	if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
4432 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
4433 		printf("Warning: hardware TCP checksum enabled but not "
4434 			"supported by port %d\n", port_id);
4435 	}
4436 	if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
4437 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4438 		printf("Warning: hardware SCTP checksum enabled but not "
4439 			"supported by port %d\n", port_id);
4440 	}
4441 	if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4442 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4443 		printf("Warning: hardware outer IP checksum enabled but not "
4444 			"supported by port %d\n", port_id);
4445 	}
4446 	if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
4447 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)
4448 			== 0) {
4449 		printf("Warning: hardware outer UDP checksum enabled but not "
4450 			"supported by port %d\n", port_id);
4451 	}
4452 }
4453 
4454 static void
4455 cmd_config_queue_tx_offloads(struct rte_port *port)
4456 {
4457 	int k;
4458 
4459 	/* Apply queue tx offloads configuration */
4460 	for (k = 0; k < port->dev_info.max_rx_queues; k++)
4461 		port->tx_conf[k].offloads =
4462 			port->dev_conf.txmode.offloads;
4463 }
4464 
4465 static void
4466 cmd_csum_parsed(void *parsed_result,
4467 		       __attribute__((unused)) struct cmdline *cl,
4468 		       __attribute__((unused)) void *data)
4469 {
4470 	struct cmd_csum_result *res = parsed_result;
4471 	int hw = 0;
4472 	uint64_t csum_offloads = 0;
4473 	struct rte_eth_dev_info dev_info;
4474 	int ret;
4475 
4476 	if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4477 		printf("invalid port %d\n", res->port_id);
4478 		return;
4479 	}
4480 	if (!port_is_stopped(res->port_id)) {
4481 		printf("Please stop port %d first\n", res->port_id);
4482 		return;
4483 	}
4484 
4485 	ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4486 	if (ret != 0)
4487 		return;
4488 
4489 	if (!strcmp(res->mode, "set")) {
4490 
4491 		if (!strcmp(res->hwsw, "hw"))
4492 			hw = 1;
4493 
4494 		if (!strcmp(res->proto, "ip")) {
4495 			if (hw == 0 || (dev_info.tx_offload_capa &
4496 						DEV_TX_OFFLOAD_IPV4_CKSUM)) {
4497 				csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
4498 			} else {
4499 				printf("IP checksum offload is not supported "
4500 				       "by port %u\n", res->port_id);
4501 			}
4502 		} else if (!strcmp(res->proto, "udp")) {
4503 			if (hw == 0 || (dev_info.tx_offload_capa &
4504 						DEV_TX_OFFLOAD_UDP_CKSUM)) {
4505 				csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
4506 			} else {
4507 				printf("UDP checksum offload is not supported "
4508 				       "by port %u\n", res->port_id);
4509 			}
4510 		} else if (!strcmp(res->proto, "tcp")) {
4511 			if (hw == 0 || (dev_info.tx_offload_capa &
4512 						DEV_TX_OFFLOAD_TCP_CKSUM)) {
4513 				csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
4514 			} else {
4515 				printf("TCP checksum offload is not supported "
4516 				       "by port %u\n", res->port_id);
4517 			}
4518 		} else if (!strcmp(res->proto, "sctp")) {
4519 			if (hw == 0 || (dev_info.tx_offload_capa &
4520 						DEV_TX_OFFLOAD_SCTP_CKSUM)) {
4521 				csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
4522 			} else {
4523 				printf("SCTP checksum offload is not supported "
4524 				       "by port %u\n", res->port_id);
4525 			}
4526 		} else if (!strcmp(res->proto, "outer-ip")) {
4527 			if (hw == 0 || (dev_info.tx_offload_capa &
4528 					DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4529 				csum_offloads |=
4530 						DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4531 			} else {
4532 				printf("Outer IP checksum offload is not "
4533 				       "supported by port %u\n", res->port_id);
4534 			}
4535 		} else if (!strcmp(res->proto, "outer-udp")) {
4536 			if (hw == 0 || (dev_info.tx_offload_capa &
4537 					DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
4538 				csum_offloads |=
4539 						DEV_TX_OFFLOAD_OUTER_UDP_CKSUM;
4540 			} else {
4541 				printf("Outer UDP checksum offload is not "
4542 				       "supported by port %u\n", res->port_id);
4543 			}
4544 		}
4545 
4546 		if (hw) {
4547 			ports[res->port_id].dev_conf.txmode.offloads |=
4548 							csum_offloads;
4549 		} else {
4550 			ports[res->port_id].dev_conf.txmode.offloads &=
4551 							(~csum_offloads);
4552 		}
4553 		cmd_config_queue_tx_offloads(&ports[res->port_id]);
4554 	}
4555 	csum_show(res->port_id);
4556 
4557 	cmd_reconfig_device_queue(res->port_id, 1, 1);
4558 }
4559 
4560 cmdline_parse_token_string_t cmd_csum_csum =
4561 	TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4562 				csum, "csum");
4563 cmdline_parse_token_string_t cmd_csum_mode =
4564 	TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4565 				mode, "set");
4566 cmdline_parse_token_string_t cmd_csum_proto =
4567 	TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4568 				proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
4569 cmdline_parse_token_string_t cmd_csum_hwsw =
4570 	TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4571 				hwsw, "hw#sw");
4572 cmdline_parse_token_num_t cmd_csum_portid =
4573 	TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4574 				port_id, UINT16);
4575 
4576 cmdline_parse_inst_t cmd_csum_set = {
4577 	.f = cmd_csum_parsed,
4578 	.data = NULL,
4579 	.help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
4580 		"Enable/Disable hardware calculation of L3/L4 checksum when "
4581 		"using csum forward engine",
4582 	.tokens = {
4583 		(void *)&cmd_csum_csum,
4584 		(void *)&cmd_csum_mode,
4585 		(void *)&cmd_csum_proto,
4586 		(void *)&cmd_csum_hwsw,
4587 		(void *)&cmd_csum_portid,
4588 		NULL,
4589 	},
4590 };
4591 
4592 cmdline_parse_token_string_t cmd_csum_mode_show =
4593 	TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4594 				mode, "show");
4595 
4596 cmdline_parse_inst_t cmd_csum_show = {
4597 	.f = cmd_csum_parsed,
4598 	.data = NULL,
4599 	.help_str = "csum show <port_id>: Show checksum offload configuration",
4600 	.tokens = {
4601 		(void *)&cmd_csum_csum,
4602 		(void *)&cmd_csum_mode_show,
4603 		(void *)&cmd_csum_portid,
4604 		NULL,
4605 	},
4606 };
4607 
4608 /* Enable/disable tunnel parsing */
4609 struct cmd_csum_tunnel_result {
4610 	cmdline_fixed_string_t csum;
4611 	cmdline_fixed_string_t parse;
4612 	cmdline_fixed_string_t onoff;
4613 	portid_t port_id;
4614 };
4615 
4616 static void
4617 cmd_csum_tunnel_parsed(void *parsed_result,
4618 		       __attribute__((unused)) struct cmdline *cl,
4619 		       __attribute__((unused)) void *data)
4620 {
4621 	struct cmd_csum_tunnel_result *res = parsed_result;
4622 
4623 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4624 		return;
4625 
4626 	if (!strcmp(res->onoff, "on"))
4627 		ports[res->port_id].parse_tunnel = 1;
4628 	else
4629 		ports[res->port_id].parse_tunnel = 0;
4630 
4631 	csum_show(res->port_id);
4632 }
4633 
4634 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4635 	TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4636 				csum, "csum");
4637 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4638 	TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4639 				parse, "parse-tunnel");
4640 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4641 	TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4642 				onoff, "on#off");
4643 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4644 	TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4645 				port_id, UINT16);
4646 
4647 cmdline_parse_inst_t cmd_csum_tunnel = {
4648 	.f = cmd_csum_tunnel_parsed,
4649 	.data = NULL,
4650 	.help_str = "csum parse-tunnel on|off <port_id>: "
4651 		"Enable/Disable parsing of tunnels for csum engine",
4652 	.tokens = {
4653 		(void *)&cmd_csum_tunnel_csum,
4654 		(void *)&cmd_csum_tunnel_parse,
4655 		(void *)&cmd_csum_tunnel_onoff,
4656 		(void *)&cmd_csum_tunnel_portid,
4657 		NULL,
4658 	},
4659 };
4660 
4661 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4662 struct cmd_tso_set_result {
4663 	cmdline_fixed_string_t tso;
4664 	cmdline_fixed_string_t mode;
4665 	uint16_t tso_segsz;
4666 	portid_t port_id;
4667 };
4668 
4669 static void
4670 cmd_tso_set_parsed(void *parsed_result,
4671 		       __attribute__((unused)) struct cmdline *cl,
4672 		       __attribute__((unused)) void *data)
4673 {
4674 	struct cmd_tso_set_result *res = parsed_result;
4675 	struct rte_eth_dev_info dev_info;
4676 	int ret;
4677 
4678 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4679 		return;
4680 	if (!port_is_stopped(res->port_id)) {
4681 		printf("Please stop port %d first\n", res->port_id);
4682 		return;
4683 	}
4684 
4685 	if (!strcmp(res->mode, "set"))
4686 		ports[res->port_id].tso_segsz = res->tso_segsz;
4687 
4688 	ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4689 	if (ret != 0)
4690 		return;
4691 
4692 	if ((ports[res->port_id].tso_segsz != 0) &&
4693 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4694 		printf("Error: TSO is not supported by port %d\n",
4695 		       res->port_id);
4696 		return;
4697 	}
4698 
4699 	if (ports[res->port_id].tso_segsz == 0) {
4700 		ports[res->port_id].dev_conf.txmode.offloads &=
4701 						~DEV_TX_OFFLOAD_TCP_TSO;
4702 		printf("TSO for non-tunneled packets is disabled\n");
4703 	} else {
4704 		ports[res->port_id].dev_conf.txmode.offloads |=
4705 						DEV_TX_OFFLOAD_TCP_TSO;
4706 		printf("TSO segment size for non-tunneled packets is %d\n",
4707 			ports[res->port_id].tso_segsz);
4708 	}
4709 	cmd_config_queue_tx_offloads(&ports[res->port_id]);
4710 
4711 	/* display warnings if configuration is not supported by the NIC */
4712 	ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4713 	if (ret != 0)
4714 		return;
4715 
4716 	if ((ports[res->port_id].tso_segsz != 0) &&
4717 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4718 		printf("Warning: TSO enabled but not "
4719 			"supported by port %d\n", res->port_id);
4720 	}
4721 
4722 	cmd_reconfig_device_queue(res->port_id, 1, 1);
4723 }
4724 
4725 cmdline_parse_token_string_t cmd_tso_set_tso =
4726 	TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4727 				tso, "tso");
4728 cmdline_parse_token_string_t cmd_tso_set_mode =
4729 	TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4730 				mode, "set");
4731 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4732 	TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4733 				tso_segsz, UINT16);
4734 cmdline_parse_token_num_t cmd_tso_set_portid =
4735 	TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4736 				port_id, UINT16);
4737 
4738 cmdline_parse_inst_t cmd_tso_set = {
4739 	.f = cmd_tso_set_parsed,
4740 	.data = NULL,
4741 	.help_str = "tso set <tso_segsz> <port_id>: "
4742 		"Set TSO segment size of non-tunneled packets for csum engine "
4743 		"(0 to disable)",
4744 	.tokens = {
4745 		(void *)&cmd_tso_set_tso,
4746 		(void *)&cmd_tso_set_mode,
4747 		(void *)&cmd_tso_set_tso_segsz,
4748 		(void *)&cmd_tso_set_portid,
4749 		NULL,
4750 	},
4751 };
4752 
4753 cmdline_parse_token_string_t cmd_tso_show_mode =
4754 	TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4755 				mode, "show");
4756 
4757 
4758 cmdline_parse_inst_t cmd_tso_show = {
4759 	.f = cmd_tso_set_parsed,
4760 	.data = NULL,
4761 	.help_str = "tso show <port_id>: "
4762 		"Show TSO segment size of non-tunneled packets for csum engine",
4763 	.tokens = {
4764 		(void *)&cmd_tso_set_tso,
4765 		(void *)&cmd_tso_show_mode,
4766 		(void *)&cmd_tso_set_portid,
4767 		NULL,
4768 	},
4769 };
4770 
4771 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
4772 struct cmd_tunnel_tso_set_result {
4773 	cmdline_fixed_string_t tso;
4774 	cmdline_fixed_string_t mode;
4775 	uint16_t tso_segsz;
4776 	portid_t port_id;
4777 };
4778 
4779 static struct rte_eth_dev_info
4780 check_tunnel_tso_nic_support(portid_t port_id)
4781 {
4782 	struct rte_eth_dev_info dev_info;
4783 
4784 	if (eth_dev_info_get_print_err(port_id, &dev_info) != 0)
4785 		return dev_info;
4786 
4787 	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
4788 		printf("Warning: VXLAN TUNNEL TSO not supported therefore "
4789 		       "not enabled for port %d\n", port_id);
4790 	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
4791 		printf("Warning: GRE TUNNEL TSO	not supported therefore "
4792 		       "not enabled for port %d\n", port_id);
4793 	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
4794 		printf("Warning: IPIP TUNNEL TSO not supported therefore "
4795 		       "not enabled for port %d\n", port_id);
4796 	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
4797 		printf("Warning: GENEVE TUNNEL TSO not supported therefore "
4798 		       "not enabled for port %d\n", port_id);
4799 	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
4800 		printf("Warning: IP TUNNEL TSO not supported therefore "
4801 		       "not enabled for port %d\n", port_id);
4802 	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
4803 		printf("Warning: UDP TUNNEL TSO not supported therefore "
4804 		       "not enabled for port %d\n", port_id);
4805 	return dev_info;
4806 }
4807 
4808 static void
4809 cmd_tunnel_tso_set_parsed(void *parsed_result,
4810 			  __attribute__((unused)) struct cmdline *cl,
4811 			  __attribute__((unused)) void *data)
4812 {
4813 	struct cmd_tunnel_tso_set_result *res = parsed_result;
4814 	struct rte_eth_dev_info dev_info;
4815 
4816 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4817 		return;
4818 	if (!port_is_stopped(res->port_id)) {
4819 		printf("Please stop port %d first\n", res->port_id);
4820 		return;
4821 	}
4822 
4823 	if (!strcmp(res->mode, "set"))
4824 		ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
4825 
4826 	dev_info = check_tunnel_tso_nic_support(res->port_id);
4827 	if (ports[res->port_id].tunnel_tso_segsz == 0) {
4828 		ports[res->port_id].dev_conf.txmode.offloads &=
4829 			~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4830 			  DEV_TX_OFFLOAD_GRE_TNL_TSO |
4831 			  DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4832 			  DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4833 			  DEV_TX_OFFLOAD_IP_TNL_TSO |
4834 			  DEV_TX_OFFLOAD_UDP_TNL_TSO);
4835 		printf("TSO for tunneled packets is disabled\n");
4836 	} else {
4837 		uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4838 					 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4839 					 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4840 					 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4841 					 DEV_TX_OFFLOAD_IP_TNL_TSO |
4842 					 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4843 
4844 		ports[res->port_id].dev_conf.txmode.offloads |=
4845 			(tso_offloads & dev_info.tx_offload_capa);
4846 		printf("TSO segment size for tunneled packets is %d\n",
4847 			ports[res->port_id].tunnel_tso_segsz);
4848 
4849 		/* Below conditions are needed to make it work:
4850 		 * (1) tunnel TSO is supported by the NIC;
4851 		 * (2) "csum parse_tunnel" must be set so that tunneled pkts
4852 		 * are recognized;
4853 		 * (3) for tunneled pkts with outer L3 of IPv4,
4854 		 * "csum set outer-ip" must be set to hw, because after tso,
4855 		 * total_len of outer IP header is changed, and the checksum
4856 		 * of outer IP header calculated by sw should be wrong; that
4857 		 * is not necessary for IPv6 tunneled pkts because there's no
4858 		 * checksum in IP header anymore.
4859 		 */
4860 
4861 		if (!ports[res->port_id].parse_tunnel)
4862 			printf("Warning: csum parse_tunnel must be set "
4863 				"so that tunneled packets are recognized\n");
4864 		if (!(ports[res->port_id].dev_conf.txmode.offloads &
4865 		      DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
4866 			printf("Warning: csum set outer-ip must be set to hw "
4867 				"if outer L3 is IPv4; not necessary for IPv6\n");
4868 	}
4869 
4870 	cmd_config_queue_tx_offloads(&ports[res->port_id]);
4871 	cmd_reconfig_device_queue(res->port_id, 1, 1);
4872 }
4873 
4874 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
4875 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4876 				tso, "tunnel_tso");
4877 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
4878 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4879 				mode, "set");
4880 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
4881 	TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4882 				tso_segsz, UINT16);
4883 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
4884 	TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4885 				port_id, UINT16);
4886 
4887 cmdline_parse_inst_t cmd_tunnel_tso_set = {
4888 	.f = cmd_tunnel_tso_set_parsed,
4889 	.data = NULL,
4890 	.help_str = "tunnel_tso set <tso_segsz> <port_id>: "
4891 		"Set TSO segment size of tunneled packets for csum engine "
4892 		"(0 to disable)",
4893 	.tokens = {
4894 		(void *)&cmd_tunnel_tso_set_tso,
4895 		(void *)&cmd_tunnel_tso_set_mode,
4896 		(void *)&cmd_tunnel_tso_set_tso_segsz,
4897 		(void *)&cmd_tunnel_tso_set_portid,
4898 		NULL,
4899 	},
4900 };
4901 
4902 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
4903 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4904 				mode, "show");
4905 
4906 
4907 cmdline_parse_inst_t cmd_tunnel_tso_show = {
4908 	.f = cmd_tunnel_tso_set_parsed,
4909 	.data = NULL,
4910 	.help_str = "tunnel_tso show <port_id> "
4911 		"Show TSO segment size of tunneled packets for csum engine",
4912 	.tokens = {
4913 		(void *)&cmd_tunnel_tso_set_tso,
4914 		(void *)&cmd_tunnel_tso_show_mode,
4915 		(void *)&cmd_tunnel_tso_set_portid,
4916 		NULL,
4917 	},
4918 };
4919 
4920 /* *** SET GRO FOR A PORT *** */
4921 struct cmd_gro_enable_result {
4922 	cmdline_fixed_string_t cmd_set;
4923 	cmdline_fixed_string_t cmd_port;
4924 	cmdline_fixed_string_t cmd_keyword;
4925 	cmdline_fixed_string_t cmd_onoff;
4926 	portid_t cmd_pid;
4927 };
4928 
4929 static void
4930 cmd_gro_enable_parsed(void *parsed_result,
4931 		__attribute__((unused)) struct cmdline *cl,
4932 		__attribute__((unused)) void *data)
4933 {
4934 	struct cmd_gro_enable_result *res;
4935 
4936 	res = parsed_result;
4937 	if (!strcmp(res->cmd_keyword, "gro"))
4938 		setup_gro(res->cmd_onoff, res->cmd_pid);
4939 }
4940 
4941 cmdline_parse_token_string_t cmd_gro_enable_set =
4942 	TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4943 			cmd_set, "set");
4944 cmdline_parse_token_string_t cmd_gro_enable_port =
4945 	TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4946 			cmd_keyword, "port");
4947 cmdline_parse_token_num_t cmd_gro_enable_pid =
4948 	TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
4949 			cmd_pid, UINT16);
4950 cmdline_parse_token_string_t cmd_gro_enable_keyword =
4951 	TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4952 			cmd_keyword, "gro");
4953 cmdline_parse_token_string_t cmd_gro_enable_onoff =
4954 	TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4955 			cmd_onoff, "on#off");
4956 
4957 cmdline_parse_inst_t cmd_gro_enable = {
4958 	.f = cmd_gro_enable_parsed,
4959 	.data = NULL,
4960 	.help_str = "set port <port_id> gro on|off",
4961 	.tokens = {
4962 		(void *)&cmd_gro_enable_set,
4963 		(void *)&cmd_gro_enable_port,
4964 		(void *)&cmd_gro_enable_pid,
4965 		(void *)&cmd_gro_enable_keyword,
4966 		(void *)&cmd_gro_enable_onoff,
4967 		NULL,
4968 	},
4969 };
4970 
4971 /* *** DISPLAY GRO CONFIGURATION *** */
4972 struct cmd_gro_show_result {
4973 	cmdline_fixed_string_t cmd_show;
4974 	cmdline_fixed_string_t cmd_port;
4975 	cmdline_fixed_string_t cmd_keyword;
4976 	portid_t cmd_pid;
4977 };
4978 
4979 static void
4980 cmd_gro_show_parsed(void *parsed_result,
4981 		__attribute__((unused)) struct cmdline *cl,
4982 		__attribute__((unused)) void *data)
4983 {
4984 	struct cmd_gro_show_result *res;
4985 
4986 	res = parsed_result;
4987 	if (!strcmp(res->cmd_keyword, "gro"))
4988 		show_gro(res->cmd_pid);
4989 }
4990 
4991 cmdline_parse_token_string_t cmd_gro_show_show =
4992 	TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4993 			cmd_show, "show");
4994 cmdline_parse_token_string_t cmd_gro_show_port =
4995 	TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4996 			cmd_port, "port");
4997 cmdline_parse_token_num_t cmd_gro_show_pid =
4998 	TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
4999 			cmd_pid, UINT16);
5000 cmdline_parse_token_string_t cmd_gro_show_keyword =
5001 	TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5002 			cmd_keyword, "gro");
5003 
5004 cmdline_parse_inst_t cmd_gro_show = {
5005 	.f = cmd_gro_show_parsed,
5006 	.data = NULL,
5007 	.help_str = "show port <port_id> gro",
5008 	.tokens = {
5009 		(void *)&cmd_gro_show_show,
5010 		(void *)&cmd_gro_show_port,
5011 		(void *)&cmd_gro_show_pid,
5012 		(void *)&cmd_gro_show_keyword,
5013 		NULL,
5014 	},
5015 };
5016 
5017 /* *** SET FLUSH CYCLES FOR GRO *** */
5018 struct cmd_gro_flush_result {
5019 	cmdline_fixed_string_t cmd_set;
5020 	cmdline_fixed_string_t cmd_keyword;
5021 	cmdline_fixed_string_t cmd_flush;
5022 	uint8_t cmd_cycles;
5023 };
5024 
5025 static void
5026 cmd_gro_flush_parsed(void *parsed_result,
5027 		__attribute__((unused)) struct cmdline *cl,
5028 		__attribute__((unused)) void *data)
5029 {
5030 	struct cmd_gro_flush_result *res;
5031 
5032 	res = parsed_result;
5033 	if ((!strcmp(res->cmd_keyword, "gro")) &&
5034 			(!strcmp(res->cmd_flush, "flush")))
5035 		setup_gro_flush_cycles(res->cmd_cycles);
5036 }
5037 
5038 cmdline_parse_token_string_t cmd_gro_flush_set =
5039 	TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5040 			cmd_set, "set");
5041 cmdline_parse_token_string_t cmd_gro_flush_keyword =
5042 	TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5043 			cmd_keyword, "gro");
5044 cmdline_parse_token_string_t cmd_gro_flush_flush =
5045 	TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5046 			cmd_flush, "flush");
5047 cmdline_parse_token_num_t cmd_gro_flush_cycles =
5048 	TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
5049 			cmd_cycles, UINT8);
5050 
5051 cmdline_parse_inst_t cmd_gro_flush = {
5052 	.f = cmd_gro_flush_parsed,
5053 	.data = NULL,
5054 	.help_str = "set gro flush <cycles>",
5055 	.tokens = {
5056 		(void *)&cmd_gro_flush_set,
5057 		(void *)&cmd_gro_flush_keyword,
5058 		(void *)&cmd_gro_flush_flush,
5059 		(void *)&cmd_gro_flush_cycles,
5060 		NULL,
5061 	},
5062 };
5063 
5064 /* *** ENABLE/DISABLE GSO *** */
5065 struct cmd_gso_enable_result {
5066 	cmdline_fixed_string_t cmd_set;
5067 	cmdline_fixed_string_t cmd_port;
5068 	cmdline_fixed_string_t cmd_keyword;
5069 	cmdline_fixed_string_t cmd_mode;
5070 	portid_t cmd_pid;
5071 };
5072 
5073 static void
5074 cmd_gso_enable_parsed(void *parsed_result,
5075 		__attribute__((unused)) struct cmdline *cl,
5076 		__attribute__((unused)) void *data)
5077 {
5078 	struct cmd_gso_enable_result *res;
5079 
5080 	res = parsed_result;
5081 	if (!strcmp(res->cmd_keyword, "gso"))
5082 		setup_gso(res->cmd_mode, res->cmd_pid);
5083 }
5084 
5085 cmdline_parse_token_string_t cmd_gso_enable_set =
5086 	TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5087 			cmd_set, "set");
5088 cmdline_parse_token_string_t cmd_gso_enable_port =
5089 	TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5090 			cmd_port, "port");
5091 cmdline_parse_token_string_t cmd_gso_enable_keyword =
5092 	TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5093 			cmd_keyword, "gso");
5094 cmdline_parse_token_string_t cmd_gso_enable_mode =
5095 	TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5096 			cmd_mode, "on#off");
5097 cmdline_parse_token_num_t cmd_gso_enable_pid =
5098 	TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
5099 			cmd_pid, UINT16);
5100 
5101 cmdline_parse_inst_t cmd_gso_enable = {
5102 	.f = cmd_gso_enable_parsed,
5103 	.data = NULL,
5104 	.help_str = "set port <port_id> gso on|off",
5105 	.tokens = {
5106 		(void *)&cmd_gso_enable_set,
5107 		(void *)&cmd_gso_enable_port,
5108 		(void *)&cmd_gso_enable_pid,
5109 		(void *)&cmd_gso_enable_keyword,
5110 		(void *)&cmd_gso_enable_mode,
5111 		NULL,
5112 	},
5113 };
5114 
5115 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
5116 struct cmd_gso_size_result {
5117 	cmdline_fixed_string_t cmd_set;
5118 	cmdline_fixed_string_t cmd_keyword;
5119 	cmdline_fixed_string_t cmd_segsz;
5120 	uint16_t cmd_size;
5121 };
5122 
5123 static void
5124 cmd_gso_size_parsed(void *parsed_result,
5125 		       __attribute__((unused)) struct cmdline *cl,
5126 		       __attribute__((unused)) void *data)
5127 {
5128 	struct cmd_gso_size_result *res = parsed_result;
5129 
5130 	if (test_done == 0) {
5131 		printf("Before setting GSO segsz, please first"
5132 				" stop fowarding\n");
5133 		return;
5134 	}
5135 
5136 	if (!strcmp(res->cmd_keyword, "gso") &&
5137 			!strcmp(res->cmd_segsz, "segsz")) {
5138 		if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
5139 			printf("gso_size should be larger than %zu."
5140 					" Please input a legal value\n",
5141 					RTE_GSO_SEG_SIZE_MIN);
5142 		else
5143 			gso_max_segment_size = res->cmd_size;
5144 	}
5145 }
5146 
5147 cmdline_parse_token_string_t cmd_gso_size_set =
5148 	TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5149 				cmd_set, "set");
5150 cmdline_parse_token_string_t cmd_gso_size_keyword =
5151 	TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5152 				cmd_keyword, "gso");
5153 cmdline_parse_token_string_t cmd_gso_size_segsz =
5154 	TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5155 				cmd_segsz, "segsz");
5156 cmdline_parse_token_num_t cmd_gso_size_size =
5157 	TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
5158 				cmd_size, UINT16);
5159 
5160 cmdline_parse_inst_t cmd_gso_size = {
5161 	.f = cmd_gso_size_parsed,
5162 	.data = NULL,
5163 	.help_str = "set gso segsz <length>",
5164 	.tokens = {
5165 		(void *)&cmd_gso_size_set,
5166 		(void *)&cmd_gso_size_keyword,
5167 		(void *)&cmd_gso_size_segsz,
5168 		(void *)&cmd_gso_size_size,
5169 		NULL,
5170 	},
5171 };
5172 
5173 /* *** SHOW GSO CONFIGURATION *** */
5174 struct cmd_gso_show_result {
5175 	cmdline_fixed_string_t cmd_show;
5176 	cmdline_fixed_string_t cmd_port;
5177 	cmdline_fixed_string_t cmd_keyword;
5178 	portid_t cmd_pid;
5179 };
5180 
5181 static void
5182 cmd_gso_show_parsed(void *parsed_result,
5183 		       __attribute__((unused)) struct cmdline *cl,
5184 		       __attribute__((unused)) void *data)
5185 {
5186 	struct cmd_gso_show_result *res = parsed_result;
5187 
5188 	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
5189 		printf("invalid port id %u\n", res->cmd_pid);
5190 		return;
5191 	}
5192 	if (!strcmp(res->cmd_keyword, "gso")) {
5193 		if (gso_ports[res->cmd_pid].enable) {
5194 			printf("Max GSO'd packet size: %uB\n"
5195 					"Supported GSO types: TCP/IPv4, "
5196 					"UDP/IPv4, VxLAN with inner "
5197 					"TCP/IPv4 packet, GRE with inner "
5198 					"TCP/IPv4 packet\n",
5199 					gso_max_segment_size);
5200 		} else
5201 			printf("GSO is not enabled on Port %u\n", res->cmd_pid);
5202 	}
5203 }
5204 
5205 cmdline_parse_token_string_t cmd_gso_show_show =
5206 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5207 		cmd_show, "show");
5208 cmdline_parse_token_string_t cmd_gso_show_port =
5209 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5210 		cmd_port, "port");
5211 cmdline_parse_token_string_t cmd_gso_show_keyword =
5212 	TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5213 				cmd_keyword, "gso");
5214 cmdline_parse_token_num_t cmd_gso_show_pid =
5215 	TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
5216 				cmd_pid, UINT16);
5217 
5218 cmdline_parse_inst_t cmd_gso_show = {
5219 	.f = cmd_gso_show_parsed,
5220 	.data = NULL,
5221 	.help_str = "show port <port_id> gso",
5222 	.tokens = {
5223 		(void *)&cmd_gso_show_show,
5224 		(void *)&cmd_gso_show_port,
5225 		(void *)&cmd_gso_show_pid,
5226 		(void *)&cmd_gso_show_keyword,
5227 		NULL,
5228 	},
5229 };
5230 
5231 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
5232 struct cmd_set_flush_rx {
5233 	cmdline_fixed_string_t set;
5234 	cmdline_fixed_string_t flush_rx;
5235 	cmdline_fixed_string_t mode;
5236 };
5237 
5238 static void
5239 cmd_set_flush_rx_parsed(void *parsed_result,
5240 		__attribute__((unused)) struct cmdline *cl,
5241 		__attribute__((unused)) void *data)
5242 {
5243 	struct cmd_set_flush_rx *res = parsed_result;
5244 	no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5245 }
5246 
5247 cmdline_parse_token_string_t cmd_setflushrx_set =
5248 	TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5249 			set, "set");
5250 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
5251 	TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5252 			flush_rx, "flush_rx");
5253 cmdline_parse_token_string_t cmd_setflushrx_mode =
5254 	TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5255 			mode, "on#off");
5256 
5257 
5258 cmdline_parse_inst_t cmd_set_flush_rx = {
5259 	.f = cmd_set_flush_rx_parsed,
5260 	.help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
5261 	.data = NULL,
5262 	.tokens = {
5263 		(void *)&cmd_setflushrx_set,
5264 		(void *)&cmd_setflushrx_flush_rx,
5265 		(void *)&cmd_setflushrx_mode,
5266 		NULL,
5267 	},
5268 };
5269 
5270 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
5271 struct cmd_set_link_check {
5272 	cmdline_fixed_string_t set;
5273 	cmdline_fixed_string_t link_check;
5274 	cmdline_fixed_string_t mode;
5275 };
5276 
5277 static void
5278 cmd_set_link_check_parsed(void *parsed_result,
5279 		__attribute__((unused)) struct cmdline *cl,
5280 		__attribute__((unused)) void *data)
5281 {
5282 	struct cmd_set_link_check *res = parsed_result;
5283 	no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5284 }
5285 
5286 cmdline_parse_token_string_t cmd_setlinkcheck_set =
5287 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5288 			set, "set");
5289 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
5290 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5291 			link_check, "link_check");
5292 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
5293 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5294 			mode, "on#off");
5295 
5296 
5297 cmdline_parse_inst_t cmd_set_link_check = {
5298 	.f = cmd_set_link_check_parsed,
5299 	.help_str = "set link_check on|off: Enable/Disable link status check "
5300 	            "when starting/stopping a port",
5301 	.data = NULL,
5302 	.tokens = {
5303 		(void *)&cmd_setlinkcheck_set,
5304 		(void *)&cmd_setlinkcheck_link_check,
5305 		(void *)&cmd_setlinkcheck_mode,
5306 		NULL,
5307 	},
5308 };
5309 
5310 /* *** SET NIC BYPASS MODE *** */
5311 struct cmd_set_bypass_mode_result {
5312 	cmdline_fixed_string_t set;
5313 	cmdline_fixed_string_t bypass;
5314 	cmdline_fixed_string_t mode;
5315 	cmdline_fixed_string_t value;
5316 	portid_t port_id;
5317 };
5318 
5319 static void
5320 cmd_set_bypass_mode_parsed(void *parsed_result,
5321 		__attribute__((unused)) struct cmdline *cl,
5322 		__attribute__((unused)) void *data)
5323 {
5324 	struct cmd_set_bypass_mode_result *res = parsed_result;
5325 	portid_t port_id = res->port_id;
5326 	int32_t rc = -EINVAL;
5327 
5328 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5329 	uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5330 
5331 	if (!strcmp(res->value, "bypass"))
5332 		bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5333 	else if (!strcmp(res->value, "isolate"))
5334 		bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5335 	else
5336 		bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5337 
5338 	/* Set the bypass mode for the relevant port. */
5339 	rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
5340 #endif
5341 	if (rc != 0)
5342 		printf("\t Failed to set bypass mode for port = %d.\n", port_id);
5343 }
5344 
5345 cmdline_parse_token_string_t cmd_setbypass_mode_set =
5346 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5347 			set, "set");
5348 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
5349 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5350 			bypass, "bypass");
5351 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
5352 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5353 			mode, "mode");
5354 cmdline_parse_token_string_t cmd_setbypass_mode_value =
5355 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5356 			value, "normal#bypass#isolate");
5357 cmdline_parse_token_num_t cmd_setbypass_mode_port =
5358 	TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
5359 				port_id, UINT16);
5360 
5361 cmdline_parse_inst_t cmd_set_bypass_mode = {
5362 	.f = cmd_set_bypass_mode_parsed,
5363 	.help_str = "set bypass mode normal|bypass|isolate <port_id>: "
5364 	            "Set the NIC bypass mode for port_id",
5365 	.data = NULL,
5366 	.tokens = {
5367 		(void *)&cmd_setbypass_mode_set,
5368 		(void *)&cmd_setbypass_mode_bypass,
5369 		(void *)&cmd_setbypass_mode_mode,
5370 		(void *)&cmd_setbypass_mode_value,
5371 		(void *)&cmd_setbypass_mode_port,
5372 		NULL,
5373 	},
5374 };
5375 
5376 /* *** SET NIC BYPASS EVENT *** */
5377 struct cmd_set_bypass_event_result {
5378 	cmdline_fixed_string_t set;
5379 	cmdline_fixed_string_t bypass;
5380 	cmdline_fixed_string_t event;
5381 	cmdline_fixed_string_t event_value;
5382 	cmdline_fixed_string_t mode;
5383 	cmdline_fixed_string_t mode_value;
5384 	portid_t port_id;
5385 };
5386 
5387 static void
5388 cmd_set_bypass_event_parsed(void *parsed_result,
5389 		__attribute__((unused)) struct cmdline *cl,
5390 		__attribute__((unused)) void *data)
5391 {
5392 	int32_t rc = -EINVAL;
5393 	struct cmd_set_bypass_event_result *res = parsed_result;
5394 	portid_t port_id = res->port_id;
5395 
5396 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5397 	uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5398 	uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5399 
5400 	if (!strcmp(res->event_value, "timeout"))
5401 		bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
5402 	else if (!strcmp(res->event_value, "os_on"))
5403 		bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
5404 	else if (!strcmp(res->event_value, "os_off"))
5405 		bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5406 	else if (!strcmp(res->event_value, "power_on"))
5407 		bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5408 	else if (!strcmp(res->event_value, "power_off"))
5409 		bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5410 	else
5411 		bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5412 
5413 	if (!strcmp(res->mode_value, "bypass"))
5414 		bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5415 	else if (!strcmp(res->mode_value, "isolate"))
5416 		bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5417 	else
5418 		bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5419 
5420 	/* Set the watchdog timeout. */
5421 	if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5422 
5423 		rc = -EINVAL;
5424 		if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5425 			rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5426 							   bypass_timeout);
5427 		}
5428 		if (rc != 0) {
5429 			printf("Failed to set timeout value %u "
5430 			"for port %d, errto code: %d.\n",
5431 			bypass_timeout, port_id, rc);
5432 		}
5433 	}
5434 
5435 	/* Set the bypass event to transition to bypass mode. */
5436 	rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5437 					      bypass_mode);
5438 #endif
5439 
5440 	if (rc != 0)
5441 		printf("\t Failed to set bypass event for port = %d.\n",
5442 		       port_id);
5443 }
5444 
5445 cmdline_parse_token_string_t cmd_setbypass_event_set =
5446 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5447 			set, "set");
5448 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5449 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5450 			bypass, "bypass");
5451 cmdline_parse_token_string_t cmd_setbypass_event_event =
5452 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5453 			event, "event");
5454 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5455 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5456 			event_value, "none#timeout#os_off#os_on#power_on#power_off");
5457 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5458 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5459 			mode, "mode");
5460 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5461 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5462 			mode_value, "normal#bypass#isolate");
5463 cmdline_parse_token_num_t cmd_setbypass_event_port =
5464 	TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5465 				port_id, UINT16);
5466 
5467 cmdline_parse_inst_t cmd_set_bypass_event = {
5468 	.f = cmd_set_bypass_event_parsed,
5469 	.help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5470 		"power_off mode normal|bypass|isolate <port_id>: "
5471 		"Set the NIC bypass event mode for port_id",
5472 	.data = NULL,
5473 	.tokens = {
5474 		(void *)&cmd_setbypass_event_set,
5475 		(void *)&cmd_setbypass_event_bypass,
5476 		(void *)&cmd_setbypass_event_event,
5477 		(void *)&cmd_setbypass_event_event_value,
5478 		(void *)&cmd_setbypass_event_mode,
5479 		(void *)&cmd_setbypass_event_mode_value,
5480 		(void *)&cmd_setbypass_event_port,
5481 		NULL,
5482 	},
5483 };
5484 
5485 
5486 /* *** SET NIC BYPASS TIMEOUT *** */
5487 struct cmd_set_bypass_timeout_result {
5488 	cmdline_fixed_string_t set;
5489 	cmdline_fixed_string_t bypass;
5490 	cmdline_fixed_string_t timeout;
5491 	cmdline_fixed_string_t value;
5492 };
5493 
5494 static void
5495 cmd_set_bypass_timeout_parsed(void *parsed_result,
5496 		__attribute__((unused)) struct cmdline *cl,
5497 		__attribute__((unused)) void *data)
5498 {
5499 	__rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5500 
5501 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5502 	if (!strcmp(res->value, "1.5"))
5503 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5504 	else if (!strcmp(res->value, "2"))
5505 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5506 	else if (!strcmp(res->value, "3"))
5507 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5508 	else if (!strcmp(res->value, "4"))
5509 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5510 	else if (!strcmp(res->value, "8"))
5511 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5512 	else if (!strcmp(res->value, "16"))
5513 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5514 	else if (!strcmp(res->value, "32"))
5515 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5516 	else
5517 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5518 #endif
5519 }
5520 
5521 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5522 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5523 			set, "set");
5524 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5525 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5526 			bypass, "bypass");
5527 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5528 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5529 			timeout, "timeout");
5530 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5531 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5532 			value, "0#1.5#2#3#4#8#16#32");
5533 
5534 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5535 	.f = cmd_set_bypass_timeout_parsed,
5536 	.help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5537 		"Set the NIC bypass watchdog timeout in seconds",
5538 	.data = NULL,
5539 	.tokens = {
5540 		(void *)&cmd_setbypass_timeout_set,
5541 		(void *)&cmd_setbypass_timeout_bypass,
5542 		(void *)&cmd_setbypass_timeout_timeout,
5543 		(void *)&cmd_setbypass_timeout_value,
5544 		NULL,
5545 	},
5546 };
5547 
5548 /* *** SHOW NIC BYPASS MODE *** */
5549 struct cmd_show_bypass_config_result {
5550 	cmdline_fixed_string_t show;
5551 	cmdline_fixed_string_t bypass;
5552 	cmdline_fixed_string_t config;
5553 	portid_t port_id;
5554 };
5555 
5556 static void
5557 cmd_show_bypass_config_parsed(void *parsed_result,
5558 		__attribute__((unused)) struct cmdline *cl,
5559 		__attribute__((unused)) void *data)
5560 {
5561 	struct cmd_show_bypass_config_result *res = parsed_result;
5562 	portid_t port_id = res->port_id;
5563 	int rc = -EINVAL;
5564 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5565 	uint32_t event_mode;
5566 	uint32_t bypass_mode;
5567 	uint32_t timeout = bypass_timeout;
5568 	unsigned int i;
5569 
5570 	static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5571 		{"off", "1.5", "2", "3", "4", "8", "16", "32"};
5572 	static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5573 		{"UNKNOWN", "normal", "bypass", "isolate"};
5574 	static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5575 		"NONE",
5576 		"OS/board on",
5577 		"power supply on",
5578 		"OS/board off",
5579 		"power supply off",
5580 		"timeout"};
5581 
5582 	/* Display the bypass mode.*/
5583 	if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5584 		printf("\tFailed to get bypass mode for port = %d\n", port_id);
5585 		return;
5586 	}
5587 	else {
5588 		if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5589 			bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5590 
5591 		printf("\tbypass mode    = %s\n",  modes[bypass_mode]);
5592 	}
5593 
5594 	/* Display the bypass timeout.*/
5595 	if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5596 		timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5597 
5598 	printf("\tbypass timeout = %s\n", timeouts[timeout]);
5599 
5600 	/* Display the bypass events and associated modes. */
5601 	for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < RTE_DIM(events); i++) {
5602 
5603 		if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5604 			printf("\tFailed to get bypass mode for event = %s\n",
5605 				events[i]);
5606 		} else {
5607 			if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5608 				event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5609 
5610 			printf("\tbypass event: %-16s = %s\n", events[i],
5611 				modes[event_mode]);
5612 		}
5613 	}
5614 #endif
5615 	if (rc != 0)
5616 		printf("\tFailed to get bypass configuration for port = %d\n",
5617 		       port_id);
5618 }
5619 
5620 cmdline_parse_token_string_t cmd_showbypass_config_show =
5621 	TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5622 			show, "show");
5623 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5624 	TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5625 			bypass, "bypass");
5626 cmdline_parse_token_string_t cmd_showbypass_config_config =
5627 	TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5628 			config, "config");
5629 cmdline_parse_token_num_t cmd_showbypass_config_port =
5630 	TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5631 				port_id, UINT16);
5632 
5633 cmdline_parse_inst_t cmd_show_bypass_config = {
5634 	.f = cmd_show_bypass_config_parsed,
5635 	.help_str = "show bypass config <port_id>: "
5636 	            "Show the NIC bypass config for port_id",
5637 	.data = NULL,
5638 	.tokens = {
5639 		(void *)&cmd_showbypass_config_show,
5640 		(void *)&cmd_showbypass_config_bypass,
5641 		(void *)&cmd_showbypass_config_config,
5642 		(void *)&cmd_showbypass_config_port,
5643 		NULL,
5644 	},
5645 };
5646 
5647 #ifdef RTE_LIBRTE_PMD_BOND
5648 /* *** SET BONDING MODE *** */
5649 struct cmd_set_bonding_mode_result {
5650 	cmdline_fixed_string_t set;
5651 	cmdline_fixed_string_t bonding;
5652 	cmdline_fixed_string_t mode;
5653 	uint8_t value;
5654 	portid_t port_id;
5655 };
5656 
5657 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5658 		__attribute__((unused))  struct cmdline *cl,
5659 		__attribute__((unused)) void *data)
5660 {
5661 	struct cmd_set_bonding_mode_result *res = parsed_result;
5662 	portid_t port_id = res->port_id;
5663 
5664 	/* Set the bonding mode for the relevant port. */
5665 	if (0 != rte_eth_bond_mode_set(port_id, res->value))
5666 		printf("\t Failed to set bonding mode for port = %d.\n", port_id);
5667 }
5668 
5669 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5670 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5671 		set, "set");
5672 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5673 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5674 		bonding, "bonding");
5675 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5676 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5677 		mode, "mode");
5678 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5679 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5680 		value, UINT8);
5681 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5682 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5683 		port_id, UINT16);
5684 
5685 cmdline_parse_inst_t cmd_set_bonding_mode = {
5686 		.f = cmd_set_bonding_mode_parsed,
5687 		.help_str = "set bonding mode <mode_value> <port_id>: "
5688 			"Set the bonding mode for port_id",
5689 		.data = NULL,
5690 		.tokens = {
5691 				(void *) &cmd_setbonding_mode_set,
5692 				(void *) &cmd_setbonding_mode_bonding,
5693 				(void *) &cmd_setbonding_mode_mode,
5694 				(void *) &cmd_setbonding_mode_value,
5695 				(void *) &cmd_setbonding_mode_port,
5696 				NULL
5697 		}
5698 };
5699 
5700 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5701 struct cmd_set_bonding_lacp_dedicated_queues_result {
5702 	cmdline_fixed_string_t set;
5703 	cmdline_fixed_string_t bonding;
5704 	cmdline_fixed_string_t lacp;
5705 	cmdline_fixed_string_t dedicated_queues;
5706 	portid_t port_id;
5707 	cmdline_fixed_string_t mode;
5708 };
5709 
5710 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5711 		__attribute__((unused))  struct cmdline *cl,
5712 		__attribute__((unused)) void *data)
5713 {
5714 	struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5715 	portid_t port_id = res->port_id;
5716 	struct rte_port *port;
5717 
5718 	port = &ports[port_id];
5719 
5720 	/** Check if the port is not started **/
5721 	if (port->port_status != RTE_PORT_STOPPED) {
5722 		printf("Please stop port %d first\n", port_id);
5723 		return;
5724 	}
5725 
5726 	if (!strcmp(res->mode, "enable")) {
5727 		if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5728 			printf("Dedicate queues for LACP control packets"
5729 					" enabled\n");
5730 		else
5731 			printf("Enabling dedicate queues for LACP control "
5732 					"packets on port %d failed\n", port_id);
5733 	} else if (!strcmp(res->mode, "disable")) {
5734 		if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5735 			printf("Dedicated queues for LACP control packets "
5736 					"disabled\n");
5737 		else
5738 			printf("Disabling dedicated queues for LACP control "
5739 					"traffic on port %d failed\n", port_id);
5740 	}
5741 }
5742 
5743 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5744 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5745 		set, "set");
5746 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
5747 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5748 		bonding, "bonding");
5749 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
5750 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5751 		lacp, "lacp");
5752 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
5753 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5754 		dedicated_queues, "dedicated_queues");
5755 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
5756 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5757 		port_id, UINT16);
5758 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
5759 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5760 		mode, "enable#disable");
5761 
5762 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
5763 		.f = cmd_set_bonding_lacp_dedicated_queues_parsed,
5764 		.help_str = "set bonding lacp dedicated_queues <port_id> "
5765 			"enable|disable: "
5766 			"Enable/disable dedicated queues for LACP control traffic for port_id",
5767 		.data = NULL,
5768 		.tokens = {
5769 			(void *)&cmd_setbonding_lacp_dedicated_queues_set,
5770 			(void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
5771 			(void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
5772 			(void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
5773 			(void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
5774 			(void *)&cmd_setbonding_lacp_dedicated_queues_mode,
5775 			NULL
5776 		}
5777 };
5778 
5779 /* *** SET BALANCE XMIT POLICY *** */
5780 struct cmd_set_bonding_balance_xmit_policy_result {
5781 	cmdline_fixed_string_t set;
5782 	cmdline_fixed_string_t bonding;
5783 	cmdline_fixed_string_t balance_xmit_policy;
5784 	portid_t port_id;
5785 	cmdline_fixed_string_t policy;
5786 };
5787 
5788 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
5789 		__attribute__((unused))  struct cmdline *cl,
5790 		__attribute__((unused)) void *data)
5791 {
5792 	struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
5793 	portid_t port_id = res->port_id;
5794 	uint8_t policy;
5795 
5796 	if (!strcmp(res->policy, "l2")) {
5797 		policy = BALANCE_XMIT_POLICY_LAYER2;
5798 	} else if (!strcmp(res->policy, "l23")) {
5799 		policy = BALANCE_XMIT_POLICY_LAYER23;
5800 	} else if (!strcmp(res->policy, "l34")) {
5801 		policy = BALANCE_XMIT_POLICY_LAYER34;
5802 	} else {
5803 		printf("\t Invalid xmit policy selection");
5804 		return;
5805 	}
5806 
5807 	/* Set the bonding mode for the relevant port. */
5808 	if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
5809 		printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
5810 				port_id);
5811 	}
5812 }
5813 
5814 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
5815 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5816 		set, "set");
5817 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
5818 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5819 		bonding, "bonding");
5820 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
5821 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5822 		balance_xmit_policy, "balance_xmit_policy");
5823 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
5824 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5825 		port_id, UINT16);
5826 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
5827 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5828 		policy, "l2#l23#l34");
5829 
5830 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
5831 		.f = cmd_set_bonding_balance_xmit_policy_parsed,
5832 		.help_str = "set bonding balance_xmit_policy <port_id> "
5833 			"l2|l23|l34: "
5834 			"Set the bonding balance_xmit_policy for port_id",
5835 		.data = NULL,
5836 		.tokens = {
5837 				(void *)&cmd_setbonding_balance_xmit_policy_set,
5838 				(void *)&cmd_setbonding_balance_xmit_policy_bonding,
5839 				(void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
5840 				(void *)&cmd_setbonding_balance_xmit_policy_port,
5841 				(void *)&cmd_setbonding_balance_xmit_policy_policy,
5842 				NULL
5843 		}
5844 };
5845 
5846 /* *** SHOW NIC BONDING CONFIGURATION *** */
5847 struct cmd_show_bonding_config_result {
5848 	cmdline_fixed_string_t show;
5849 	cmdline_fixed_string_t bonding;
5850 	cmdline_fixed_string_t config;
5851 	portid_t port_id;
5852 };
5853 
5854 static void cmd_show_bonding_config_parsed(void *parsed_result,
5855 		__attribute__((unused))  struct cmdline *cl,
5856 		__attribute__((unused)) void *data)
5857 {
5858 	struct cmd_show_bonding_config_result *res = parsed_result;
5859 	int bonding_mode, agg_mode;
5860 	portid_t slaves[RTE_MAX_ETHPORTS];
5861 	int num_slaves, num_active_slaves;
5862 	int primary_id;
5863 	int i;
5864 	portid_t port_id = res->port_id;
5865 
5866 	/* Display the bonding mode.*/
5867 	bonding_mode = rte_eth_bond_mode_get(port_id);
5868 	if (bonding_mode < 0) {
5869 		printf("\tFailed to get bonding mode for port = %d\n", port_id);
5870 		return;
5871 	} else
5872 		printf("\tBonding mode: %d\n", bonding_mode);
5873 
5874 	if (bonding_mode == BONDING_MODE_BALANCE) {
5875 		int balance_xmit_policy;
5876 
5877 		balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
5878 		if (balance_xmit_policy < 0) {
5879 			printf("\tFailed to get balance xmit policy for port = %d\n",
5880 					port_id);
5881 			return;
5882 		} else {
5883 			printf("\tBalance Xmit Policy: ");
5884 
5885 			switch (balance_xmit_policy) {
5886 			case BALANCE_XMIT_POLICY_LAYER2:
5887 				printf("BALANCE_XMIT_POLICY_LAYER2");
5888 				break;
5889 			case BALANCE_XMIT_POLICY_LAYER23:
5890 				printf("BALANCE_XMIT_POLICY_LAYER23");
5891 				break;
5892 			case BALANCE_XMIT_POLICY_LAYER34:
5893 				printf("BALANCE_XMIT_POLICY_LAYER34");
5894 				break;
5895 			}
5896 			printf("\n");
5897 		}
5898 	}
5899 
5900 	if (bonding_mode == BONDING_MODE_8023AD) {
5901 		agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
5902 		printf("\tIEEE802.3AD Aggregator Mode: ");
5903 		switch (agg_mode) {
5904 		case AGG_BANDWIDTH:
5905 			printf("bandwidth");
5906 			break;
5907 		case AGG_STABLE:
5908 			printf("stable");
5909 			break;
5910 		case AGG_COUNT:
5911 			printf("count");
5912 			break;
5913 		}
5914 		printf("\n");
5915 	}
5916 
5917 	num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
5918 
5919 	if (num_slaves < 0) {
5920 		printf("\tFailed to get slave list for port = %d\n", port_id);
5921 		return;
5922 	}
5923 	if (num_slaves > 0) {
5924 		printf("\tSlaves (%d): [", num_slaves);
5925 		for (i = 0; i < num_slaves - 1; i++)
5926 			printf("%d ", slaves[i]);
5927 
5928 		printf("%d]\n", slaves[num_slaves - 1]);
5929 	} else {
5930 		printf("\tSlaves: []\n");
5931 
5932 	}
5933 
5934 	num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
5935 			RTE_MAX_ETHPORTS);
5936 
5937 	if (num_active_slaves < 0) {
5938 		printf("\tFailed to get active slave list for port = %d\n", port_id);
5939 		return;
5940 	}
5941 	if (num_active_slaves > 0) {
5942 		printf("\tActive Slaves (%d): [", num_active_slaves);
5943 		for (i = 0; i < num_active_slaves - 1; i++)
5944 			printf("%d ", slaves[i]);
5945 
5946 		printf("%d]\n", slaves[num_active_slaves - 1]);
5947 
5948 	} else {
5949 		printf("\tActive Slaves: []\n");
5950 
5951 	}
5952 
5953 	primary_id = rte_eth_bond_primary_get(port_id);
5954 	if (primary_id < 0) {
5955 		printf("\tFailed to get primary slave for port = %d\n", port_id);
5956 		return;
5957 	} else
5958 		printf("\tPrimary: [%d]\n", primary_id);
5959 
5960 }
5961 
5962 cmdline_parse_token_string_t cmd_showbonding_config_show =
5963 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5964 		show, "show");
5965 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
5966 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5967 		bonding, "bonding");
5968 cmdline_parse_token_string_t cmd_showbonding_config_config =
5969 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5970 		config, "config");
5971 cmdline_parse_token_num_t cmd_showbonding_config_port =
5972 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
5973 		port_id, UINT16);
5974 
5975 cmdline_parse_inst_t cmd_show_bonding_config = {
5976 		.f = cmd_show_bonding_config_parsed,
5977 		.help_str = "show bonding config <port_id>: "
5978 			"Show the bonding config for port_id",
5979 		.data = NULL,
5980 		.tokens = {
5981 				(void *)&cmd_showbonding_config_show,
5982 				(void *)&cmd_showbonding_config_bonding,
5983 				(void *)&cmd_showbonding_config_config,
5984 				(void *)&cmd_showbonding_config_port,
5985 				NULL
5986 		}
5987 };
5988 
5989 /* *** SET BONDING PRIMARY *** */
5990 struct cmd_set_bonding_primary_result {
5991 	cmdline_fixed_string_t set;
5992 	cmdline_fixed_string_t bonding;
5993 	cmdline_fixed_string_t primary;
5994 	portid_t slave_id;
5995 	portid_t port_id;
5996 };
5997 
5998 static void cmd_set_bonding_primary_parsed(void *parsed_result,
5999 		__attribute__((unused))  struct cmdline *cl,
6000 		__attribute__((unused)) void *data)
6001 {
6002 	struct cmd_set_bonding_primary_result *res = parsed_result;
6003 	portid_t master_port_id = res->port_id;
6004 	portid_t slave_port_id = res->slave_id;
6005 
6006 	/* Set the primary slave for a bonded device. */
6007 	if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
6008 		printf("\t Failed to set primary slave for port = %d.\n",
6009 				master_port_id);
6010 		return;
6011 	}
6012 	init_port_config();
6013 }
6014 
6015 cmdline_parse_token_string_t cmd_setbonding_primary_set =
6016 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6017 		set, "set");
6018 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
6019 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6020 		bonding, "bonding");
6021 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
6022 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6023 		primary, "primary");
6024 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
6025 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6026 		slave_id, UINT16);
6027 cmdline_parse_token_num_t cmd_setbonding_primary_port =
6028 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6029 		port_id, UINT16);
6030 
6031 cmdline_parse_inst_t cmd_set_bonding_primary = {
6032 		.f = cmd_set_bonding_primary_parsed,
6033 		.help_str = "set bonding primary <slave_id> <port_id>: "
6034 			"Set the primary slave for port_id",
6035 		.data = NULL,
6036 		.tokens = {
6037 				(void *)&cmd_setbonding_primary_set,
6038 				(void *)&cmd_setbonding_primary_bonding,
6039 				(void *)&cmd_setbonding_primary_primary,
6040 				(void *)&cmd_setbonding_primary_slave,
6041 				(void *)&cmd_setbonding_primary_port,
6042 				NULL
6043 		}
6044 };
6045 
6046 /* *** ADD SLAVE *** */
6047 struct cmd_add_bonding_slave_result {
6048 	cmdline_fixed_string_t add;
6049 	cmdline_fixed_string_t bonding;
6050 	cmdline_fixed_string_t slave;
6051 	portid_t slave_id;
6052 	portid_t port_id;
6053 };
6054 
6055 static void cmd_add_bonding_slave_parsed(void *parsed_result,
6056 		__attribute__((unused))  struct cmdline *cl,
6057 		__attribute__((unused)) void *data)
6058 {
6059 	struct cmd_add_bonding_slave_result *res = parsed_result;
6060 	portid_t master_port_id = res->port_id;
6061 	portid_t slave_port_id = res->slave_id;
6062 
6063 	/* add the slave for a bonded device. */
6064 	if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
6065 		printf("\t Failed to add slave %d to master port = %d.\n",
6066 				slave_port_id, master_port_id);
6067 		return;
6068 	}
6069 	init_port_config();
6070 	set_port_slave_flag(slave_port_id);
6071 }
6072 
6073 cmdline_parse_token_string_t cmd_addbonding_slave_add =
6074 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6075 		add, "add");
6076 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
6077 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6078 		bonding, "bonding");
6079 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
6080 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6081 		slave, "slave");
6082 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
6083 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6084 		slave_id, UINT16);
6085 cmdline_parse_token_num_t cmd_addbonding_slave_port =
6086 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6087 		port_id, UINT16);
6088 
6089 cmdline_parse_inst_t cmd_add_bonding_slave = {
6090 		.f = cmd_add_bonding_slave_parsed,
6091 		.help_str = "add bonding slave <slave_id> <port_id>: "
6092 			"Add a slave device to a bonded device",
6093 		.data = NULL,
6094 		.tokens = {
6095 				(void *)&cmd_addbonding_slave_add,
6096 				(void *)&cmd_addbonding_slave_bonding,
6097 				(void *)&cmd_addbonding_slave_slave,
6098 				(void *)&cmd_addbonding_slave_slaveid,
6099 				(void *)&cmd_addbonding_slave_port,
6100 				NULL
6101 		}
6102 };
6103 
6104 /* *** REMOVE SLAVE *** */
6105 struct cmd_remove_bonding_slave_result {
6106 	cmdline_fixed_string_t remove;
6107 	cmdline_fixed_string_t bonding;
6108 	cmdline_fixed_string_t slave;
6109 	portid_t slave_id;
6110 	portid_t port_id;
6111 };
6112 
6113 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
6114 		__attribute__((unused))  struct cmdline *cl,
6115 		__attribute__((unused)) void *data)
6116 {
6117 	struct cmd_remove_bonding_slave_result *res = parsed_result;
6118 	portid_t master_port_id = res->port_id;
6119 	portid_t slave_port_id = res->slave_id;
6120 
6121 	/* remove the slave from a bonded device. */
6122 	if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
6123 		printf("\t Failed to remove slave %d from master port = %d.\n",
6124 				slave_port_id, master_port_id);
6125 		return;
6126 	}
6127 	init_port_config();
6128 	clear_port_slave_flag(slave_port_id);
6129 }
6130 
6131 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
6132 		TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6133 				remove, "remove");
6134 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
6135 		TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6136 				bonding, "bonding");
6137 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
6138 		TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6139 				slave, "slave");
6140 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
6141 		TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6142 				slave_id, UINT16);
6143 cmdline_parse_token_num_t cmd_removebonding_slave_port =
6144 		TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6145 				port_id, UINT16);
6146 
6147 cmdline_parse_inst_t cmd_remove_bonding_slave = {
6148 		.f = cmd_remove_bonding_slave_parsed,
6149 		.help_str = "remove bonding slave <slave_id> <port_id>: "
6150 			"Remove a slave device from a bonded device",
6151 		.data = NULL,
6152 		.tokens = {
6153 				(void *)&cmd_removebonding_slave_remove,
6154 				(void *)&cmd_removebonding_slave_bonding,
6155 				(void *)&cmd_removebonding_slave_slave,
6156 				(void *)&cmd_removebonding_slave_slaveid,
6157 				(void *)&cmd_removebonding_slave_port,
6158 				NULL
6159 		}
6160 };
6161 
6162 /* *** CREATE BONDED DEVICE *** */
6163 struct cmd_create_bonded_device_result {
6164 	cmdline_fixed_string_t create;
6165 	cmdline_fixed_string_t bonded;
6166 	cmdline_fixed_string_t device;
6167 	uint8_t mode;
6168 	uint8_t socket;
6169 };
6170 
6171 static int bond_dev_num = 0;
6172 
6173 static void cmd_create_bonded_device_parsed(void *parsed_result,
6174 		__attribute__((unused))  struct cmdline *cl,
6175 		__attribute__((unused)) void *data)
6176 {
6177 	struct cmd_create_bonded_device_result *res = parsed_result;
6178 	char ethdev_name[RTE_ETH_NAME_MAX_LEN];
6179 	int port_id;
6180 	int ret;
6181 
6182 	if (test_done == 0) {
6183 		printf("Please stop forwarding first\n");
6184 		return;
6185 	}
6186 
6187 	snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
6188 			bond_dev_num++);
6189 
6190 	/* Create a new bonded device. */
6191 	port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
6192 	if (port_id < 0) {
6193 		printf("\t Failed to create bonded device.\n");
6194 		return;
6195 	} else {
6196 		printf("Created new bonded device %s on (port %d).\n", ethdev_name,
6197 				port_id);
6198 
6199 		/* Update number of ports */
6200 		nb_ports = rte_eth_dev_count_avail();
6201 		reconfig(port_id, res->socket);
6202 		ret = rte_eth_promiscuous_enable(port_id);
6203 		if (ret != 0)
6204 			printf("Failed to enable promiscuous mode for port %u: %s - ignore\n",
6205 				port_id, rte_strerror(-ret));
6206 
6207 		ports[port_id].need_setup = 0;
6208 		ports[port_id].port_status = RTE_PORT_STOPPED;
6209 	}
6210 
6211 }
6212 
6213 cmdline_parse_token_string_t cmd_createbonded_device_create =
6214 		TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6215 				create, "create");
6216 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
6217 		TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6218 				bonded, "bonded");
6219 cmdline_parse_token_string_t cmd_createbonded_device_device =
6220 		TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6221 				device, "device");
6222 cmdline_parse_token_num_t cmd_createbonded_device_mode =
6223 		TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6224 				mode, UINT8);
6225 cmdline_parse_token_num_t cmd_createbonded_device_socket =
6226 		TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6227 				socket, UINT8);
6228 
6229 cmdline_parse_inst_t cmd_create_bonded_device = {
6230 		.f = cmd_create_bonded_device_parsed,
6231 		.help_str = "create bonded device <mode> <socket>: "
6232 			"Create a new bonded device with specific bonding mode and socket",
6233 		.data = NULL,
6234 		.tokens = {
6235 				(void *)&cmd_createbonded_device_create,
6236 				(void *)&cmd_createbonded_device_bonded,
6237 				(void *)&cmd_createbonded_device_device,
6238 				(void *)&cmd_createbonded_device_mode,
6239 				(void *)&cmd_createbonded_device_socket,
6240 				NULL
6241 		}
6242 };
6243 
6244 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
6245 struct cmd_set_bond_mac_addr_result {
6246 	cmdline_fixed_string_t set;
6247 	cmdline_fixed_string_t bonding;
6248 	cmdline_fixed_string_t mac_addr;
6249 	uint16_t port_num;
6250 	struct rte_ether_addr address;
6251 };
6252 
6253 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
6254 		__attribute__((unused))  struct cmdline *cl,
6255 		__attribute__((unused)) void *data)
6256 {
6257 	struct cmd_set_bond_mac_addr_result *res = parsed_result;
6258 	int ret;
6259 
6260 	if (port_id_is_invalid(res->port_num, ENABLED_WARN))
6261 		return;
6262 
6263 	ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
6264 
6265 	/* check the return value and print it if is < 0 */
6266 	if (ret < 0)
6267 		printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6268 }
6269 
6270 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
6271 		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
6272 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
6273 		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
6274 				"bonding");
6275 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
6276 		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
6277 				"mac_addr");
6278 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
6279 		TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
6280 				port_num, UINT16);
6281 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
6282 		TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
6283 
6284 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
6285 		.f = cmd_set_bond_mac_addr_parsed,
6286 		.data = (void *) 0,
6287 		.help_str = "set bonding mac_addr <port_id> <mac_addr>",
6288 		.tokens = {
6289 				(void *)&cmd_set_bond_mac_addr_set,
6290 				(void *)&cmd_set_bond_mac_addr_bonding,
6291 				(void *)&cmd_set_bond_mac_addr_mac,
6292 				(void *)&cmd_set_bond_mac_addr_portnum,
6293 				(void *)&cmd_set_bond_mac_addr_addr,
6294 				NULL
6295 		}
6296 };
6297 
6298 
6299 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
6300 struct cmd_set_bond_mon_period_result {
6301 	cmdline_fixed_string_t set;
6302 	cmdline_fixed_string_t bonding;
6303 	cmdline_fixed_string_t mon_period;
6304 	uint16_t port_num;
6305 	uint32_t period_ms;
6306 };
6307 
6308 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
6309 		__attribute__((unused))  struct cmdline *cl,
6310 		__attribute__((unused)) void *data)
6311 {
6312 	struct cmd_set_bond_mon_period_result *res = parsed_result;
6313 	int ret;
6314 
6315 	ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
6316 
6317 	/* check the return value and print it if is < 0 */
6318 	if (ret < 0)
6319 		printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6320 }
6321 
6322 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
6323 		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6324 				set, "set");
6325 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
6326 		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6327 				bonding, "bonding");
6328 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
6329 		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6330 				mon_period,	"mon_period");
6331 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
6332 		TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6333 				port_num, UINT16);
6334 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
6335 		TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6336 				period_ms, UINT32);
6337 
6338 cmdline_parse_inst_t cmd_set_bond_mon_period = {
6339 		.f = cmd_set_bond_mon_period_parsed,
6340 		.data = (void *) 0,
6341 		.help_str = "set bonding mon_period <port_id> <period_ms>",
6342 		.tokens = {
6343 				(void *)&cmd_set_bond_mon_period_set,
6344 				(void *)&cmd_set_bond_mon_period_bonding,
6345 				(void *)&cmd_set_bond_mon_period_mon_period,
6346 				(void *)&cmd_set_bond_mon_period_portnum,
6347 				(void *)&cmd_set_bond_mon_period_period_ms,
6348 				NULL
6349 		}
6350 };
6351 
6352 
6353 
6354 struct cmd_set_bonding_agg_mode_policy_result {
6355 	cmdline_fixed_string_t set;
6356 	cmdline_fixed_string_t bonding;
6357 	cmdline_fixed_string_t agg_mode;
6358 	uint16_t port_num;
6359 	cmdline_fixed_string_t policy;
6360 };
6361 
6362 
6363 static void
6364 cmd_set_bonding_agg_mode(void *parsed_result,
6365 		__attribute__((unused)) struct cmdline *cl,
6366 		__attribute__((unused)) void *data)
6367 {
6368 	struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
6369 	uint8_t policy = AGG_BANDWIDTH;
6370 
6371 	if (!strcmp(res->policy, "bandwidth"))
6372 		policy = AGG_BANDWIDTH;
6373 	else if (!strcmp(res->policy, "stable"))
6374 		policy = AGG_STABLE;
6375 	else if (!strcmp(res->policy, "count"))
6376 		policy = AGG_COUNT;
6377 
6378 	rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
6379 }
6380 
6381 
6382 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
6383 	TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6384 				set, "set");
6385 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
6386 	TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6387 				bonding, "bonding");
6388 
6389 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
6390 	TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6391 				agg_mode, "agg_mode");
6392 
6393 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
6394 	TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6395 				port_num, UINT16);
6396 
6397 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6398 	TOKEN_STRING_INITIALIZER(
6399 			struct cmd_set_bonding_balance_xmit_policy_result,
6400 		policy, "stable#bandwidth#count");
6401 
6402 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6403 	.f = cmd_set_bonding_agg_mode,
6404 	.data = (void *) 0,
6405 	.help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6406 	.tokens = {
6407 			(void *)&cmd_set_bonding_agg_mode_set,
6408 			(void *)&cmd_set_bonding_agg_mode_bonding,
6409 			(void *)&cmd_set_bonding_agg_mode_agg_mode,
6410 			(void *)&cmd_set_bonding_agg_mode_portnum,
6411 			(void *)&cmd_set_bonding_agg_mode_policy_string,
6412 			NULL
6413 		}
6414 };
6415 
6416 
6417 #endif /* RTE_LIBRTE_PMD_BOND */
6418 
6419 /* *** SET FORWARDING MODE *** */
6420 struct cmd_set_fwd_mode_result {
6421 	cmdline_fixed_string_t set;
6422 	cmdline_fixed_string_t fwd;
6423 	cmdline_fixed_string_t mode;
6424 };
6425 
6426 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6427 				    __attribute__((unused)) struct cmdline *cl,
6428 				    __attribute__((unused)) void *data)
6429 {
6430 	struct cmd_set_fwd_mode_result *res = parsed_result;
6431 
6432 	retry_enabled = 0;
6433 	set_pkt_forwarding_mode(res->mode);
6434 }
6435 
6436 cmdline_parse_token_string_t cmd_setfwd_set =
6437 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6438 cmdline_parse_token_string_t cmd_setfwd_fwd =
6439 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6440 cmdline_parse_token_string_t cmd_setfwd_mode =
6441 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6442 		"" /* defined at init */);
6443 
6444 cmdline_parse_inst_t cmd_set_fwd_mode = {
6445 	.f = cmd_set_fwd_mode_parsed,
6446 	.data = NULL,
6447 	.help_str = NULL, /* defined at init */
6448 	.tokens = {
6449 		(void *)&cmd_setfwd_set,
6450 		(void *)&cmd_setfwd_fwd,
6451 		(void *)&cmd_setfwd_mode,
6452 		NULL,
6453 	},
6454 };
6455 
6456 static void cmd_set_fwd_mode_init(void)
6457 {
6458 	char *modes, *c;
6459 	static char token[128];
6460 	static char help[256];
6461 	cmdline_parse_token_string_t *token_struct;
6462 
6463 	modes = list_pkt_forwarding_modes();
6464 	snprintf(help, sizeof(help), "set fwd %s: "
6465 		"Set packet forwarding mode", modes);
6466 	cmd_set_fwd_mode.help_str = help;
6467 
6468 	/* string token separator is # */
6469 	for (c = token; *modes != '\0'; modes++)
6470 		if (*modes == '|')
6471 			*c++ = '#';
6472 		else
6473 			*c++ = *modes;
6474 	token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6475 	token_struct->string_data.str = token;
6476 }
6477 
6478 /* *** SET RETRY FORWARDING MODE *** */
6479 struct cmd_set_fwd_retry_mode_result {
6480 	cmdline_fixed_string_t set;
6481 	cmdline_fixed_string_t fwd;
6482 	cmdline_fixed_string_t mode;
6483 	cmdline_fixed_string_t retry;
6484 };
6485 
6486 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6487 			    __attribute__((unused)) struct cmdline *cl,
6488 			    __attribute__((unused)) void *data)
6489 {
6490 	struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6491 
6492 	retry_enabled = 1;
6493 	set_pkt_forwarding_mode(res->mode);
6494 }
6495 
6496 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6497 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6498 			set, "set");
6499 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6500 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6501 			fwd, "fwd");
6502 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6503 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6504 			mode,
6505 		"" /* defined at init */);
6506 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6507 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6508 			retry, "retry");
6509 
6510 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6511 	.f = cmd_set_fwd_retry_mode_parsed,
6512 	.data = NULL,
6513 	.help_str = NULL, /* defined at init */
6514 	.tokens = {
6515 		(void *)&cmd_setfwd_retry_set,
6516 		(void *)&cmd_setfwd_retry_fwd,
6517 		(void *)&cmd_setfwd_retry_mode,
6518 		(void *)&cmd_setfwd_retry_retry,
6519 		NULL,
6520 	},
6521 };
6522 
6523 static void cmd_set_fwd_retry_mode_init(void)
6524 {
6525 	char *modes, *c;
6526 	static char token[128];
6527 	static char help[256];
6528 	cmdline_parse_token_string_t *token_struct;
6529 
6530 	modes = list_pkt_forwarding_retry_modes();
6531 	snprintf(help, sizeof(help), "set fwd %s retry: "
6532 		"Set packet forwarding mode with retry", modes);
6533 	cmd_set_fwd_retry_mode.help_str = help;
6534 
6535 	/* string token separator is # */
6536 	for (c = token; *modes != '\0'; modes++)
6537 		if (*modes == '|')
6538 			*c++ = '#';
6539 		else
6540 			*c++ = *modes;
6541 	token_struct = (cmdline_parse_token_string_t *)
6542 		cmd_set_fwd_retry_mode.tokens[2];
6543 	token_struct->string_data.str = token;
6544 }
6545 
6546 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6547 struct cmd_set_burst_tx_retry_result {
6548 	cmdline_fixed_string_t set;
6549 	cmdline_fixed_string_t burst;
6550 	cmdline_fixed_string_t tx;
6551 	cmdline_fixed_string_t delay;
6552 	uint32_t time;
6553 	cmdline_fixed_string_t retry;
6554 	uint32_t retry_num;
6555 };
6556 
6557 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6558 					__attribute__((unused)) struct cmdline *cl,
6559 					__attribute__((unused)) void *data)
6560 {
6561 	struct cmd_set_burst_tx_retry_result *res = parsed_result;
6562 
6563 	if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6564 		&& !strcmp(res->tx, "tx")) {
6565 		if (!strcmp(res->delay, "delay"))
6566 			burst_tx_delay_time = res->time;
6567 		if (!strcmp(res->retry, "retry"))
6568 			burst_tx_retry_num = res->retry_num;
6569 	}
6570 
6571 }
6572 
6573 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6574 	TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6575 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6576 	TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6577 				 "burst");
6578 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6579 	TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6580 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6581 	TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6582 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6583 	TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
6584 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6585 	TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6586 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6587 	TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
6588 
6589 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6590 	.f = cmd_set_burst_tx_retry_parsed,
6591 	.help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6592 	.tokens = {
6593 		(void *)&cmd_set_burst_tx_retry_set,
6594 		(void *)&cmd_set_burst_tx_retry_burst,
6595 		(void *)&cmd_set_burst_tx_retry_tx,
6596 		(void *)&cmd_set_burst_tx_retry_delay,
6597 		(void *)&cmd_set_burst_tx_retry_time,
6598 		(void *)&cmd_set_burst_tx_retry_retry,
6599 		(void *)&cmd_set_burst_tx_retry_retry_num,
6600 		NULL,
6601 	},
6602 };
6603 
6604 /* *** SET PROMISC MODE *** */
6605 struct cmd_set_promisc_mode_result {
6606 	cmdline_fixed_string_t set;
6607 	cmdline_fixed_string_t promisc;
6608 	cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6609 	uint16_t port_num;               /* valid if "allports" argument == 0 */
6610 	cmdline_fixed_string_t mode;
6611 };
6612 
6613 static void cmd_set_promisc_mode_parsed(void *parsed_result,
6614 					__attribute__((unused)) struct cmdline *cl,
6615 					void *allports)
6616 {
6617 	struct cmd_set_promisc_mode_result *res = parsed_result;
6618 	int enable;
6619 	portid_t i;
6620 
6621 	if (!strcmp(res->mode, "on"))
6622 		enable = 1;
6623 	else
6624 		enable = 0;
6625 
6626 	/* all ports */
6627 	if (allports) {
6628 		RTE_ETH_FOREACH_DEV(i)
6629 			eth_set_promisc_mode(i, enable);
6630 	} else {
6631 		eth_set_promisc_mode(res->port_num, enable);
6632 	}
6633 }
6634 
6635 cmdline_parse_token_string_t cmd_setpromisc_set =
6636 	TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6637 cmdline_parse_token_string_t cmd_setpromisc_promisc =
6638 	TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6639 				 "promisc");
6640 cmdline_parse_token_string_t cmd_setpromisc_portall =
6641 	TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6642 				 "all");
6643 cmdline_parse_token_num_t cmd_setpromisc_portnum =
6644 	TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6645 			      UINT16);
6646 cmdline_parse_token_string_t cmd_setpromisc_mode =
6647 	TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6648 				 "on#off");
6649 
6650 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6651 	.f = cmd_set_promisc_mode_parsed,
6652 	.data = (void *)1,
6653 	.help_str = "set promisc all on|off: Set promisc mode for all ports",
6654 	.tokens = {
6655 		(void *)&cmd_setpromisc_set,
6656 		(void *)&cmd_setpromisc_promisc,
6657 		(void *)&cmd_setpromisc_portall,
6658 		(void *)&cmd_setpromisc_mode,
6659 		NULL,
6660 	},
6661 };
6662 
6663 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6664 	.f = cmd_set_promisc_mode_parsed,
6665 	.data = (void *)0,
6666 	.help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6667 	.tokens = {
6668 		(void *)&cmd_setpromisc_set,
6669 		(void *)&cmd_setpromisc_promisc,
6670 		(void *)&cmd_setpromisc_portnum,
6671 		(void *)&cmd_setpromisc_mode,
6672 		NULL,
6673 	},
6674 };
6675 
6676 /* *** SET ALLMULTI MODE *** */
6677 struct cmd_set_allmulti_mode_result {
6678 	cmdline_fixed_string_t set;
6679 	cmdline_fixed_string_t allmulti;
6680 	cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6681 	uint16_t port_num;               /* valid if "allports" argument == 0 */
6682 	cmdline_fixed_string_t mode;
6683 };
6684 
6685 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6686 					__attribute__((unused)) struct cmdline *cl,
6687 					void *allports)
6688 {
6689 	struct cmd_set_allmulti_mode_result *res = parsed_result;
6690 	int enable;
6691 	portid_t i;
6692 
6693 	if (!strcmp(res->mode, "on"))
6694 		enable = 1;
6695 	else
6696 		enable = 0;
6697 
6698 	/* all ports */
6699 	if (allports) {
6700 		RTE_ETH_FOREACH_DEV(i) {
6701 			eth_set_allmulticast_mode(i, enable);
6702 		}
6703 	}
6704 	else {
6705 		eth_set_allmulticast_mode(res->port_num, enable);
6706 	}
6707 }
6708 
6709 cmdline_parse_token_string_t cmd_setallmulti_set =
6710 	TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6711 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6712 	TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6713 				 "allmulti");
6714 cmdline_parse_token_string_t cmd_setallmulti_portall =
6715 	TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6716 				 "all");
6717 cmdline_parse_token_num_t cmd_setallmulti_portnum =
6718 	TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6719 			      UINT16);
6720 cmdline_parse_token_string_t cmd_setallmulti_mode =
6721 	TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6722 				 "on#off");
6723 
6724 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6725 	.f = cmd_set_allmulti_mode_parsed,
6726 	.data = (void *)1,
6727 	.help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6728 	.tokens = {
6729 		(void *)&cmd_setallmulti_set,
6730 		(void *)&cmd_setallmulti_allmulti,
6731 		(void *)&cmd_setallmulti_portall,
6732 		(void *)&cmd_setallmulti_mode,
6733 		NULL,
6734 	},
6735 };
6736 
6737 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6738 	.f = cmd_set_allmulti_mode_parsed,
6739 	.data = (void *)0,
6740 	.help_str = "set allmulti <port_id> on|off: "
6741 		"Set allmulti mode on port_id",
6742 	.tokens = {
6743 		(void *)&cmd_setallmulti_set,
6744 		(void *)&cmd_setallmulti_allmulti,
6745 		(void *)&cmd_setallmulti_portnum,
6746 		(void *)&cmd_setallmulti_mode,
6747 		NULL,
6748 	},
6749 };
6750 
6751 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
6752 struct cmd_link_flow_ctrl_set_result {
6753 	cmdline_fixed_string_t set;
6754 	cmdline_fixed_string_t flow_ctrl;
6755 	cmdline_fixed_string_t rx;
6756 	cmdline_fixed_string_t rx_lfc_mode;
6757 	cmdline_fixed_string_t tx;
6758 	cmdline_fixed_string_t tx_lfc_mode;
6759 	cmdline_fixed_string_t mac_ctrl_frame_fwd;
6760 	cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
6761 	cmdline_fixed_string_t autoneg_str;
6762 	cmdline_fixed_string_t autoneg;
6763 	cmdline_fixed_string_t hw_str;
6764 	uint32_t high_water;
6765 	cmdline_fixed_string_t lw_str;
6766 	uint32_t low_water;
6767 	cmdline_fixed_string_t pt_str;
6768 	uint16_t pause_time;
6769 	cmdline_fixed_string_t xon_str;
6770 	uint16_t send_xon;
6771 	portid_t port_id;
6772 };
6773 
6774 cmdline_parse_token_string_t cmd_lfc_set_set =
6775 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6776 				set, "set");
6777 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
6778 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6779 				flow_ctrl, "flow_ctrl");
6780 cmdline_parse_token_string_t cmd_lfc_set_rx =
6781 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6782 				rx, "rx");
6783 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
6784 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6785 				rx_lfc_mode, "on#off");
6786 cmdline_parse_token_string_t cmd_lfc_set_tx =
6787 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6788 				tx, "tx");
6789 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
6790 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6791 				tx_lfc_mode, "on#off");
6792 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
6793 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6794 				hw_str, "high_water");
6795 cmdline_parse_token_num_t cmd_lfc_set_high_water =
6796 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6797 				high_water, UINT32);
6798 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
6799 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6800 				lw_str, "low_water");
6801 cmdline_parse_token_num_t cmd_lfc_set_low_water =
6802 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6803 				low_water, UINT32);
6804 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
6805 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6806 				pt_str, "pause_time");
6807 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
6808 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6809 				pause_time, UINT16);
6810 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
6811 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6812 				xon_str, "send_xon");
6813 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
6814 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6815 				send_xon, UINT16);
6816 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
6817 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6818 				mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
6819 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6820 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6821 				mac_ctrl_frame_fwd_mode, "on#off");
6822 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6823 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6824 				autoneg_str, "autoneg");
6825 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6826 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6827 				autoneg, "on#off");
6828 cmdline_parse_token_num_t cmd_lfc_set_portid =
6829 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6830 				port_id, UINT16);
6831 
6832 /* forward declaration */
6833 static void
6834 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6835 			      void *data);
6836 
6837 cmdline_parse_inst_t cmd_link_flow_control_set = {
6838 	.f = cmd_link_flow_ctrl_set_parsed,
6839 	.data = NULL,
6840 	.help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6841 		"<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6842 		"autoneg on|off <port_id>: Configure the Ethernet flow control",
6843 	.tokens = {
6844 		(void *)&cmd_lfc_set_set,
6845 		(void *)&cmd_lfc_set_flow_ctrl,
6846 		(void *)&cmd_lfc_set_rx,
6847 		(void *)&cmd_lfc_set_rx_mode,
6848 		(void *)&cmd_lfc_set_tx,
6849 		(void *)&cmd_lfc_set_tx_mode,
6850 		(void *)&cmd_lfc_set_high_water,
6851 		(void *)&cmd_lfc_set_low_water,
6852 		(void *)&cmd_lfc_set_pause_time,
6853 		(void *)&cmd_lfc_set_send_xon,
6854 		(void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6855 		(void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6856 		(void *)&cmd_lfc_set_autoneg_str,
6857 		(void *)&cmd_lfc_set_autoneg,
6858 		(void *)&cmd_lfc_set_portid,
6859 		NULL,
6860 	},
6861 };
6862 
6863 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6864 	.f = cmd_link_flow_ctrl_set_parsed,
6865 	.data = (void *)&cmd_link_flow_control_set_rx,
6866 	.help_str = "set flow_ctrl rx on|off <port_id>: "
6867 		"Change rx flow control parameter",
6868 	.tokens = {
6869 		(void *)&cmd_lfc_set_set,
6870 		(void *)&cmd_lfc_set_flow_ctrl,
6871 		(void *)&cmd_lfc_set_rx,
6872 		(void *)&cmd_lfc_set_rx_mode,
6873 		(void *)&cmd_lfc_set_portid,
6874 		NULL,
6875 	},
6876 };
6877 
6878 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6879 	.f = cmd_link_flow_ctrl_set_parsed,
6880 	.data = (void *)&cmd_link_flow_control_set_tx,
6881 	.help_str = "set flow_ctrl tx on|off <port_id>: "
6882 		"Change tx flow control parameter",
6883 	.tokens = {
6884 		(void *)&cmd_lfc_set_set,
6885 		(void *)&cmd_lfc_set_flow_ctrl,
6886 		(void *)&cmd_lfc_set_tx,
6887 		(void *)&cmd_lfc_set_tx_mode,
6888 		(void *)&cmd_lfc_set_portid,
6889 		NULL,
6890 	},
6891 };
6892 
6893 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
6894 	.f = cmd_link_flow_ctrl_set_parsed,
6895 	.data = (void *)&cmd_link_flow_control_set_hw,
6896 	.help_str = "set flow_ctrl high_water <value> <port_id>: "
6897 		"Change high water flow control parameter",
6898 	.tokens = {
6899 		(void *)&cmd_lfc_set_set,
6900 		(void *)&cmd_lfc_set_flow_ctrl,
6901 		(void *)&cmd_lfc_set_high_water_str,
6902 		(void *)&cmd_lfc_set_high_water,
6903 		(void *)&cmd_lfc_set_portid,
6904 		NULL,
6905 	},
6906 };
6907 
6908 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
6909 	.f = cmd_link_flow_ctrl_set_parsed,
6910 	.data = (void *)&cmd_link_flow_control_set_lw,
6911 	.help_str = "set flow_ctrl low_water <value> <port_id>: "
6912 		"Change low water flow control parameter",
6913 	.tokens = {
6914 		(void *)&cmd_lfc_set_set,
6915 		(void *)&cmd_lfc_set_flow_ctrl,
6916 		(void *)&cmd_lfc_set_low_water_str,
6917 		(void *)&cmd_lfc_set_low_water,
6918 		(void *)&cmd_lfc_set_portid,
6919 		NULL,
6920 	},
6921 };
6922 
6923 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
6924 	.f = cmd_link_flow_ctrl_set_parsed,
6925 	.data = (void *)&cmd_link_flow_control_set_pt,
6926 	.help_str = "set flow_ctrl pause_time <value> <port_id>: "
6927 		"Change pause time flow control parameter",
6928 	.tokens = {
6929 		(void *)&cmd_lfc_set_set,
6930 		(void *)&cmd_lfc_set_flow_ctrl,
6931 		(void *)&cmd_lfc_set_pause_time_str,
6932 		(void *)&cmd_lfc_set_pause_time,
6933 		(void *)&cmd_lfc_set_portid,
6934 		NULL,
6935 	},
6936 };
6937 
6938 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
6939 	.f = cmd_link_flow_ctrl_set_parsed,
6940 	.data = (void *)&cmd_link_flow_control_set_xon,
6941 	.help_str = "set flow_ctrl send_xon <value> <port_id>: "
6942 		"Change send_xon flow control parameter",
6943 	.tokens = {
6944 		(void *)&cmd_lfc_set_set,
6945 		(void *)&cmd_lfc_set_flow_ctrl,
6946 		(void *)&cmd_lfc_set_send_xon_str,
6947 		(void *)&cmd_lfc_set_send_xon,
6948 		(void *)&cmd_lfc_set_portid,
6949 		NULL,
6950 	},
6951 };
6952 
6953 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
6954 	.f = cmd_link_flow_ctrl_set_parsed,
6955 	.data = (void *)&cmd_link_flow_control_set_macfwd,
6956 	.help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
6957 		"Change mac ctrl fwd flow control parameter",
6958 	.tokens = {
6959 		(void *)&cmd_lfc_set_set,
6960 		(void *)&cmd_lfc_set_flow_ctrl,
6961 		(void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6962 		(void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6963 		(void *)&cmd_lfc_set_portid,
6964 		NULL,
6965 	},
6966 };
6967 
6968 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
6969 	.f = cmd_link_flow_ctrl_set_parsed,
6970 	.data = (void *)&cmd_link_flow_control_set_autoneg,
6971 	.help_str = "set flow_ctrl autoneg on|off <port_id>: "
6972 		"Change autoneg flow control parameter",
6973 	.tokens = {
6974 		(void *)&cmd_lfc_set_set,
6975 		(void *)&cmd_lfc_set_flow_ctrl,
6976 		(void *)&cmd_lfc_set_autoneg_str,
6977 		(void *)&cmd_lfc_set_autoneg,
6978 		(void *)&cmd_lfc_set_portid,
6979 		NULL,
6980 	},
6981 };
6982 
6983 static void
6984 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
6985 			      __attribute__((unused)) struct cmdline *cl,
6986 			      void *data)
6987 {
6988 	struct cmd_link_flow_ctrl_set_result *res = parsed_result;
6989 	cmdline_parse_inst_t *cmd = data;
6990 	struct rte_eth_fc_conf fc_conf;
6991 	int rx_fc_en = 0;
6992 	int tx_fc_en = 0;
6993 	int ret;
6994 
6995 	/*
6996 	 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6997 	 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6998 	 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6999 	 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7000 	 */
7001 	static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
7002 			{RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7003 	};
7004 
7005 	/* Partial command line, retrieve current configuration */
7006 	if (cmd) {
7007 		ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
7008 		if (ret != 0) {
7009 			printf("cannot get current flow ctrl parameters, return"
7010 			       "code = %d\n", ret);
7011 			return;
7012 		}
7013 
7014 		if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
7015 		    (fc_conf.mode == RTE_FC_FULL))
7016 			rx_fc_en = 1;
7017 		if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
7018 		    (fc_conf.mode == RTE_FC_FULL))
7019 			tx_fc_en = 1;
7020 	}
7021 
7022 	if (!cmd || cmd == &cmd_link_flow_control_set_rx)
7023 		rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
7024 
7025 	if (!cmd || cmd == &cmd_link_flow_control_set_tx)
7026 		tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
7027 
7028 	fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
7029 
7030 	if (!cmd || cmd == &cmd_link_flow_control_set_hw)
7031 		fc_conf.high_water = res->high_water;
7032 
7033 	if (!cmd || cmd == &cmd_link_flow_control_set_lw)
7034 		fc_conf.low_water = res->low_water;
7035 
7036 	if (!cmd || cmd == &cmd_link_flow_control_set_pt)
7037 		fc_conf.pause_time = res->pause_time;
7038 
7039 	if (!cmd || cmd == &cmd_link_flow_control_set_xon)
7040 		fc_conf.send_xon = res->send_xon;
7041 
7042 	if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
7043 		if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
7044 			fc_conf.mac_ctrl_frame_fwd = 1;
7045 		else
7046 			fc_conf.mac_ctrl_frame_fwd = 0;
7047 	}
7048 
7049 	if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
7050 		fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
7051 
7052 	ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
7053 	if (ret != 0)
7054 		printf("bad flow contrl parameter, return code = %d \n", ret);
7055 }
7056 
7057 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
7058 struct cmd_priority_flow_ctrl_set_result {
7059 	cmdline_fixed_string_t set;
7060 	cmdline_fixed_string_t pfc_ctrl;
7061 	cmdline_fixed_string_t rx;
7062 	cmdline_fixed_string_t rx_pfc_mode;
7063 	cmdline_fixed_string_t tx;
7064 	cmdline_fixed_string_t tx_pfc_mode;
7065 	uint32_t high_water;
7066 	uint32_t low_water;
7067 	uint16_t pause_time;
7068 	uint8_t  priority;
7069 	portid_t port_id;
7070 };
7071 
7072 static void
7073 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
7074 		       __attribute__((unused)) struct cmdline *cl,
7075 		       __attribute__((unused)) void *data)
7076 {
7077 	struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
7078 	struct rte_eth_pfc_conf pfc_conf;
7079 	int rx_fc_enable, tx_fc_enable;
7080 	int ret;
7081 
7082 	/*
7083 	 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7084 	 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7085 	 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7086 	 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7087 	 */
7088 	static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
7089 			{RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
7090 	};
7091 
7092 	rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
7093 	tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
7094 	pfc_conf.fc.mode       = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
7095 	pfc_conf.fc.high_water = res->high_water;
7096 	pfc_conf.fc.low_water  = res->low_water;
7097 	pfc_conf.fc.pause_time = res->pause_time;
7098 	pfc_conf.priority      = res->priority;
7099 
7100 	ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
7101 	if (ret != 0)
7102 		printf("bad priority flow contrl parameter, return code = %d \n", ret);
7103 }
7104 
7105 cmdline_parse_token_string_t cmd_pfc_set_set =
7106 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7107 				set, "set");
7108 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
7109 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7110 				pfc_ctrl, "pfc_ctrl");
7111 cmdline_parse_token_string_t cmd_pfc_set_rx =
7112 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7113 				rx, "rx");
7114 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
7115 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7116 				rx_pfc_mode, "on#off");
7117 cmdline_parse_token_string_t cmd_pfc_set_tx =
7118 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7119 				tx, "tx");
7120 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
7121 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7122 				tx_pfc_mode, "on#off");
7123 cmdline_parse_token_num_t cmd_pfc_set_high_water =
7124 	TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7125 				high_water, UINT32);
7126 cmdline_parse_token_num_t cmd_pfc_set_low_water =
7127 	TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7128 				low_water, UINT32);
7129 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
7130 	TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7131 				pause_time, UINT16);
7132 cmdline_parse_token_num_t cmd_pfc_set_priority =
7133 	TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7134 				priority, UINT8);
7135 cmdline_parse_token_num_t cmd_pfc_set_portid =
7136 	TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7137 				port_id, UINT16);
7138 
7139 cmdline_parse_inst_t cmd_priority_flow_control_set = {
7140 	.f = cmd_priority_flow_ctrl_set_parsed,
7141 	.data = NULL,
7142 	.help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
7143 		"<pause_time> <priority> <port_id>: "
7144 		"Configure the Ethernet priority flow control",
7145 	.tokens = {
7146 		(void *)&cmd_pfc_set_set,
7147 		(void *)&cmd_pfc_set_flow_ctrl,
7148 		(void *)&cmd_pfc_set_rx,
7149 		(void *)&cmd_pfc_set_rx_mode,
7150 		(void *)&cmd_pfc_set_tx,
7151 		(void *)&cmd_pfc_set_tx_mode,
7152 		(void *)&cmd_pfc_set_high_water,
7153 		(void *)&cmd_pfc_set_low_water,
7154 		(void *)&cmd_pfc_set_pause_time,
7155 		(void *)&cmd_pfc_set_priority,
7156 		(void *)&cmd_pfc_set_portid,
7157 		NULL,
7158 	},
7159 };
7160 
7161 /* *** RESET CONFIGURATION *** */
7162 struct cmd_reset_result {
7163 	cmdline_fixed_string_t reset;
7164 	cmdline_fixed_string_t def;
7165 };
7166 
7167 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
7168 			     struct cmdline *cl,
7169 			     __attribute__((unused)) void *data)
7170 {
7171 	cmdline_printf(cl, "Reset to default forwarding configuration...\n");
7172 	set_def_fwd_config();
7173 }
7174 
7175 cmdline_parse_token_string_t cmd_reset_set =
7176 	TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
7177 cmdline_parse_token_string_t cmd_reset_def =
7178 	TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
7179 				 "default");
7180 
7181 cmdline_parse_inst_t cmd_reset = {
7182 	.f = cmd_reset_parsed,
7183 	.data = NULL,
7184 	.help_str = "set default: Reset default forwarding configuration",
7185 	.tokens = {
7186 		(void *)&cmd_reset_set,
7187 		(void *)&cmd_reset_def,
7188 		NULL,
7189 	},
7190 };
7191 
7192 /* *** START FORWARDING *** */
7193 struct cmd_start_result {
7194 	cmdline_fixed_string_t start;
7195 };
7196 
7197 cmdline_parse_token_string_t cmd_start_start =
7198 	TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
7199 
7200 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
7201 			     __attribute__((unused)) struct cmdline *cl,
7202 			     __attribute__((unused)) void *data)
7203 {
7204 	start_packet_forwarding(0);
7205 }
7206 
7207 cmdline_parse_inst_t cmd_start = {
7208 	.f = cmd_start_parsed,
7209 	.data = NULL,
7210 	.help_str = "start: Start packet forwarding",
7211 	.tokens = {
7212 		(void *)&cmd_start_start,
7213 		NULL,
7214 	},
7215 };
7216 
7217 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7218 struct cmd_start_tx_first_result {
7219 	cmdline_fixed_string_t start;
7220 	cmdline_fixed_string_t tx_first;
7221 };
7222 
7223 static void
7224 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
7225 			  __attribute__((unused)) struct cmdline *cl,
7226 			  __attribute__((unused)) void *data)
7227 {
7228 	start_packet_forwarding(1);
7229 }
7230 
7231 cmdline_parse_token_string_t cmd_start_tx_first_start =
7232 	TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7233 				 "start");
7234 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7235 	TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7236 				 tx_first, "tx_first");
7237 
7238 cmdline_parse_inst_t cmd_start_tx_first = {
7239 	.f = cmd_start_tx_first_parsed,
7240 	.data = NULL,
7241 	.help_str = "start tx_first: Start packet forwarding, "
7242 		"after sending 1 burst of packets",
7243 	.tokens = {
7244 		(void *)&cmd_start_tx_first_start,
7245 		(void *)&cmd_start_tx_first_tx_first,
7246 		NULL,
7247 	},
7248 };
7249 
7250 /* *** START FORWARDING WITH N TX BURST FIRST *** */
7251 struct cmd_start_tx_first_n_result {
7252 	cmdline_fixed_string_t start;
7253 	cmdline_fixed_string_t tx_first;
7254 	uint32_t tx_num;
7255 };
7256 
7257 static void
7258 cmd_start_tx_first_n_parsed(void *parsed_result,
7259 			  __attribute__((unused)) struct cmdline *cl,
7260 			  __attribute__((unused)) void *data)
7261 {
7262 	struct cmd_start_tx_first_n_result *res = parsed_result;
7263 
7264 	start_packet_forwarding(res->tx_num);
7265 }
7266 
7267 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7268 	TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7269 			start, "start");
7270 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7271 	TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7272 			tx_first, "tx_first");
7273 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7274 	TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7275 			tx_num, UINT32);
7276 
7277 cmdline_parse_inst_t cmd_start_tx_first_n = {
7278 	.f = cmd_start_tx_first_n_parsed,
7279 	.data = NULL,
7280 	.help_str = "start tx_first <num>: "
7281 		"packet forwarding, after sending <num> bursts of packets",
7282 	.tokens = {
7283 		(void *)&cmd_start_tx_first_n_start,
7284 		(void *)&cmd_start_tx_first_n_tx_first,
7285 		(void *)&cmd_start_tx_first_n_tx_num,
7286 		NULL,
7287 	},
7288 };
7289 
7290 /* *** SET LINK UP *** */
7291 struct cmd_set_link_up_result {
7292 	cmdline_fixed_string_t set;
7293 	cmdline_fixed_string_t link_up;
7294 	cmdline_fixed_string_t port;
7295 	portid_t port_id;
7296 };
7297 
7298 cmdline_parse_token_string_t cmd_set_link_up_set =
7299 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7300 cmdline_parse_token_string_t cmd_set_link_up_link_up =
7301 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7302 				"link-up");
7303 cmdline_parse_token_string_t cmd_set_link_up_port =
7304 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7305 cmdline_parse_token_num_t cmd_set_link_up_port_id =
7306 	TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16);
7307 
7308 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
7309 			     __attribute__((unused)) struct cmdline *cl,
7310 			     __attribute__((unused)) void *data)
7311 {
7312 	struct cmd_set_link_up_result *res = parsed_result;
7313 	dev_set_link_up(res->port_id);
7314 }
7315 
7316 cmdline_parse_inst_t cmd_set_link_up = {
7317 	.f = cmd_set_link_up_parsed,
7318 	.data = NULL,
7319 	.help_str = "set link-up port <port id>",
7320 	.tokens = {
7321 		(void *)&cmd_set_link_up_set,
7322 		(void *)&cmd_set_link_up_link_up,
7323 		(void *)&cmd_set_link_up_port,
7324 		(void *)&cmd_set_link_up_port_id,
7325 		NULL,
7326 	},
7327 };
7328 
7329 /* *** SET LINK DOWN *** */
7330 struct cmd_set_link_down_result {
7331 	cmdline_fixed_string_t set;
7332 	cmdline_fixed_string_t link_down;
7333 	cmdline_fixed_string_t port;
7334 	portid_t port_id;
7335 };
7336 
7337 cmdline_parse_token_string_t cmd_set_link_down_set =
7338 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
7339 cmdline_parse_token_string_t cmd_set_link_down_link_down =
7340 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
7341 				"link-down");
7342 cmdline_parse_token_string_t cmd_set_link_down_port =
7343 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
7344 cmdline_parse_token_num_t cmd_set_link_down_port_id =
7345 	TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16);
7346 
7347 static void cmd_set_link_down_parsed(
7348 				__attribute__((unused)) void *parsed_result,
7349 				__attribute__((unused)) struct cmdline *cl,
7350 				__attribute__((unused)) void *data)
7351 {
7352 	struct cmd_set_link_down_result *res = parsed_result;
7353 	dev_set_link_down(res->port_id);
7354 }
7355 
7356 cmdline_parse_inst_t cmd_set_link_down = {
7357 	.f = cmd_set_link_down_parsed,
7358 	.data = NULL,
7359 	.help_str = "set link-down port <port id>",
7360 	.tokens = {
7361 		(void *)&cmd_set_link_down_set,
7362 		(void *)&cmd_set_link_down_link_down,
7363 		(void *)&cmd_set_link_down_port,
7364 		(void *)&cmd_set_link_down_port_id,
7365 		NULL,
7366 	},
7367 };
7368 
7369 /* *** SHOW CFG *** */
7370 struct cmd_showcfg_result {
7371 	cmdline_fixed_string_t show;
7372 	cmdline_fixed_string_t cfg;
7373 	cmdline_fixed_string_t what;
7374 };
7375 
7376 static void cmd_showcfg_parsed(void *parsed_result,
7377 			       __attribute__((unused)) struct cmdline *cl,
7378 			       __attribute__((unused)) void *data)
7379 {
7380 	struct cmd_showcfg_result *res = parsed_result;
7381 	if (!strcmp(res->what, "rxtx"))
7382 		rxtx_config_display();
7383 	else if (!strcmp(res->what, "cores"))
7384 		fwd_lcores_config_display();
7385 	else if (!strcmp(res->what, "fwd"))
7386 		pkt_fwd_config_display(&cur_fwd_config);
7387 	else if (!strcmp(res->what, "txpkts"))
7388 		show_tx_pkt_segments();
7389 }
7390 
7391 cmdline_parse_token_string_t cmd_showcfg_show =
7392 	TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7393 cmdline_parse_token_string_t cmd_showcfg_port =
7394 	TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7395 cmdline_parse_token_string_t cmd_showcfg_what =
7396 	TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7397 				 "rxtx#cores#fwd#txpkts");
7398 
7399 cmdline_parse_inst_t cmd_showcfg = {
7400 	.f = cmd_showcfg_parsed,
7401 	.data = NULL,
7402 	.help_str = "show config rxtx|cores|fwd|txpkts",
7403 	.tokens = {
7404 		(void *)&cmd_showcfg_show,
7405 		(void *)&cmd_showcfg_port,
7406 		(void *)&cmd_showcfg_what,
7407 		NULL,
7408 	},
7409 };
7410 
7411 /* *** SHOW ALL PORT INFO *** */
7412 struct cmd_showportall_result {
7413 	cmdline_fixed_string_t show;
7414 	cmdline_fixed_string_t port;
7415 	cmdline_fixed_string_t what;
7416 	cmdline_fixed_string_t all;
7417 };
7418 
7419 static void cmd_showportall_parsed(void *parsed_result,
7420 				__attribute__((unused)) struct cmdline *cl,
7421 				__attribute__((unused)) void *data)
7422 {
7423 	portid_t i;
7424 
7425 	struct cmd_showportall_result *res = parsed_result;
7426 	if (!strcmp(res->show, "clear")) {
7427 		if (!strcmp(res->what, "stats"))
7428 			RTE_ETH_FOREACH_DEV(i)
7429 				nic_stats_clear(i);
7430 		else if (!strcmp(res->what, "xstats"))
7431 			RTE_ETH_FOREACH_DEV(i)
7432 				nic_xstats_clear(i);
7433 	} else if (!strcmp(res->what, "info"))
7434 		RTE_ETH_FOREACH_DEV(i)
7435 			port_infos_display(i);
7436 	else if (!strcmp(res->what, "summary")) {
7437 		port_summary_header_display();
7438 		RTE_ETH_FOREACH_DEV(i)
7439 			port_summary_display(i);
7440 	}
7441 	else if (!strcmp(res->what, "stats"))
7442 		RTE_ETH_FOREACH_DEV(i)
7443 			nic_stats_display(i);
7444 	else if (!strcmp(res->what, "xstats"))
7445 		RTE_ETH_FOREACH_DEV(i)
7446 			nic_xstats_display(i);
7447 	else if (!strcmp(res->what, "fdir"))
7448 		RTE_ETH_FOREACH_DEV(i)
7449 			fdir_get_infos(i);
7450 	else if (!strcmp(res->what, "stat_qmap"))
7451 		RTE_ETH_FOREACH_DEV(i)
7452 			nic_stats_mapping_display(i);
7453 	else if (!strcmp(res->what, "dcb_tc"))
7454 		RTE_ETH_FOREACH_DEV(i)
7455 			port_dcb_info_display(i);
7456 	else if (!strcmp(res->what, "cap"))
7457 		RTE_ETH_FOREACH_DEV(i)
7458 			port_offload_cap_display(i);
7459 }
7460 
7461 cmdline_parse_token_string_t cmd_showportall_show =
7462 	TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7463 				 "show#clear");
7464 cmdline_parse_token_string_t cmd_showportall_port =
7465 	TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7466 cmdline_parse_token_string_t cmd_showportall_what =
7467 	TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7468 				 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7469 cmdline_parse_token_string_t cmd_showportall_all =
7470 	TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7471 cmdline_parse_inst_t cmd_showportall = {
7472 	.f = cmd_showportall_parsed,
7473 	.data = NULL,
7474 	.help_str = "show|clear port "
7475 		"info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
7476 	.tokens = {
7477 		(void *)&cmd_showportall_show,
7478 		(void *)&cmd_showportall_port,
7479 		(void *)&cmd_showportall_what,
7480 		(void *)&cmd_showportall_all,
7481 		NULL,
7482 	},
7483 };
7484 
7485 /* *** SHOW PORT INFO *** */
7486 struct cmd_showport_result {
7487 	cmdline_fixed_string_t show;
7488 	cmdline_fixed_string_t port;
7489 	cmdline_fixed_string_t what;
7490 	uint16_t portnum;
7491 };
7492 
7493 static void cmd_showport_parsed(void *parsed_result,
7494 				__attribute__((unused)) struct cmdline *cl,
7495 				__attribute__((unused)) void *data)
7496 {
7497 	struct cmd_showport_result *res = parsed_result;
7498 	if (!strcmp(res->show, "clear")) {
7499 		if (!strcmp(res->what, "stats"))
7500 			nic_stats_clear(res->portnum);
7501 		else if (!strcmp(res->what, "xstats"))
7502 			nic_xstats_clear(res->portnum);
7503 	} else if (!strcmp(res->what, "info"))
7504 		port_infos_display(res->portnum);
7505 	else if (!strcmp(res->what, "summary")) {
7506 		port_summary_header_display();
7507 		port_summary_display(res->portnum);
7508 	}
7509 	else if (!strcmp(res->what, "stats"))
7510 		nic_stats_display(res->portnum);
7511 	else if (!strcmp(res->what, "xstats"))
7512 		nic_xstats_display(res->portnum);
7513 	else if (!strcmp(res->what, "fdir"))
7514 		 fdir_get_infos(res->portnum);
7515 	else if (!strcmp(res->what, "stat_qmap"))
7516 		nic_stats_mapping_display(res->portnum);
7517 	else if (!strcmp(res->what, "dcb_tc"))
7518 		port_dcb_info_display(res->portnum);
7519 	else if (!strcmp(res->what, "cap"))
7520 		port_offload_cap_display(res->portnum);
7521 }
7522 
7523 cmdline_parse_token_string_t cmd_showport_show =
7524 	TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7525 				 "show#clear");
7526 cmdline_parse_token_string_t cmd_showport_port =
7527 	TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7528 cmdline_parse_token_string_t cmd_showport_what =
7529 	TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7530 				 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7531 cmdline_parse_token_num_t cmd_showport_portnum =
7532 	TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
7533 
7534 cmdline_parse_inst_t cmd_showport = {
7535 	.f = cmd_showport_parsed,
7536 	.data = NULL,
7537 	.help_str = "show|clear port "
7538 		"info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
7539 		"<port_id>",
7540 	.tokens = {
7541 		(void *)&cmd_showport_show,
7542 		(void *)&cmd_showport_port,
7543 		(void *)&cmd_showport_what,
7544 		(void *)&cmd_showport_portnum,
7545 		NULL,
7546 	},
7547 };
7548 
7549 /* *** SHOW DEVICE INFO *** */
7550 struct cmd_showdevice_result {
7551 	cmdline_fixed_string_t show;
7552 	cmdline_fixed_string_t device;
7553 	cmdline_fixed_string_t what;
7554 	cmdline_fixed_string_t identifier;
7555 };
7556 
7557 static void cmd_showdevice_parsed(void *parsed_result,
7558 				__attribute__((unused)) struct cmdline *cl,
7559 				__attribute__((unused)) void *data)
7560 {
7561 	struct cmd_showdevice_result *res = parsed_result;
7562 	if (!strcmp(res->what, "info")) {
7563 		if (!strcmp(res->identifier, "all"))
7564 			device_infos_display(NULL);
7565 		else
7566 			device_infos_display(res->identifier);
7567 	}
7568 }
7569 
7570 cmdline_parse_token_string_t cmd_showdevice_show =
7571 	TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show,
7572 				 "show");
7573 cmdline_parse_token_string_t cmd_showdevice_device =
7574 	TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device");
7575 cmdline_parse_token_string_t cmd_showdevice_what =
7576 	TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what,
7577 				 "info");
7578 cmdline_parse_token_string_t cmd_showdevice_identifier =
7579 	TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result,
7580 			identifier, NULL);
7581 
7582 cmdline_parse_inst_t cmd_showdevice = {
7583 	.f = cmd_showdevice_parsed,
7584 	.data = NULL,
7585 	.help_str = "show device info <identifier>|all",
7586 	.tokens = {
7587 		(void *)&cmd_showdevice_show,
7588 		(void *)&cmd_showdevice_device,
7589 		(void *)&cmd_showdevice_what,
7590 		(void *)&cmd_showdevice_identifier,
7591 		NULL,
7592 	},
7593 };
7594 /* *** SHOW QUEUE INFO *** */
7595 struct cmd_showqueue_result {
7596 	cmdline_fixed_string_t show;
7597 	cmdline_fixed_string_t type;
7598 	cmdline_fixed_string_t what;
7599 	uint16_t portnum;
7600 	uint16_t queuenum;
7601 };
7602 
7603 static void
7604 cmd_showqueue_parsed(void *parsed_result,
7605 	__attribute__((unused)) struct cmdline *cl,
7606 	__attribute__((unused)) void *data)
7607 {
7608 	struct cmd_showqueue_result *res = parsed_result;
7609 
7610 	if (!strcmp(res->type, "rxq"))
7611 		rx_queue_infos_display(res->portnum, res->queuenum);
7612 	else if (!strcmp(res->type, "txq"))
7613 		tx_queue_infos_display(res->portnum, res->queuenum);
7614 }
7615 
7616 cmdline_parse_token_string_t cmd_showqueue_show =
7617 	TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
7618 cmdline_parse_token_string_t cmd_showqueue_type =
7619 	TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
7620 cmdline_parse_token_string_t cmd_showqueue_what =
7621 	TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
7622 cmdline_parse_token_num_t cmd_showqueue_portnum =
7623 	TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16);
7624 cmdline_parse_token_num_t cmd_showqueue_queuenum =
7625 	TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
7626 
7627 cmdline_parse_inst_t cmd_showqueue = {
7628 	.f = cmd_showqueue_parsed,
7629 	.data = NULL,
7630 	.help_str = "show rxq|txq info <port_id> <queue_id>",
7631 	.tokens = {
7632 		(void *)&cmd_showqueue_show,
7633 		(void *)&cmd_showqueue_type,
7634 		(void *)&cmd_showqueue_what,
7635 		(void *)&cmd_showqueue_portnum,
7636 		(void *)&cmd_showqueue_queuenum,
7637 		NULL,
7638 	},
7639 };
7640 
7641 /* show/clear fwd engine statistics */
7642 struct fwd_result {
7643 	cmdline_fixed_string_t action;
7644 	cmdline_fixed_string_t fwd;
7645 	cmdline_fixed_string_t stats;
7646 	cmdline_fixed_string_t all;
7647 };
7648 
7649 cmdline_parse_token_string_t cmd_fwd_action =
7650 	TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
7651 cmdline_parse_token_string_t cmd_fwd_fwd =
7652 	TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
7653 cmdline_parse_token_string_t cmd_fwd_stats =
7654 	TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
7655 cmdline_parse_token_string_t cmd_fwd_all =
7656 	TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
7657 
7658 static void
7659 cmd_showfwdall_parsed(void *parsed_result,
7660 		      __rte_unused struct cmdline *cl,
7661 		      __rte_unused void *data)
7662 {
7663 	struct fwd_result *res = parsed_result;
7664 
7665 	if (!strcmp(res->action, "show"))
7666 		fwd_stats_display();
7667 	else
7668 		fwd_stats_reset();
7669 }
7670 
7671 static cmdline_parse_inst_t cmd_showfwdall = {
7672 	.f = cmd_showfwdall_parsed,
7673 	.data = NULL,
7674 	.help_str = "show|clear fwd stats all",
7675 	.tokens = {
7676 		(void *)&cmd_fwd_action,
7677 		(void *)&cmd_fwd_fwd,
7678 		(void *)&cmd_fwd_stats,
7679 		(void *)&cmd_fwd_all,
7680 		NULL,
7681 	},
7682 };
7683 
7684 /* *** READ PORT REGISTER *** */
7685 struct cmd_read_reg_result {
7686 	cmdline_fixed_string_t read;
7687 	cmdline_fixed_string_t reg;
7688 	portid_t port_id;
7689 	uint32_t reg_off;
7690 };
7691 
7692 static void
7693 cmd_read_reg_parsed(void *parsed_result,
7694 		    __attribute__((unused)) struct cmdline *cl,
7695 		    __attribute__((unused)) void *data)
7696 {
7697 	struct cmd_read_reg_result *res = parsed_result;
7698 	port_reg_display(res->port_id, res->reg_off);
7699 }
7700 
7701 cmdline_parse_token_string_t cmd_read_reg_read =
7702 	TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
7703 cmdline_parse_token_string_t cmd_read_reg_reg =
7704 	TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
7705 cmdline_parse_token_num_t cmd_read_reg_port_id =
7706 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16);
7707 cmdline_parse_token_num_t cmd_read_reg_reg_off =
7708 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
7709 
7710 cmdline_parse_inst_t cmd_read_reg = {
7711 	.f = cmd_read_reg_parsed,
7712 	.data = NULL,
7713 	.help_str = "read reg <port_id> <reg_off>",
7714 	.tokens = {
7715 		(void *)&cmd_read_reg_read,
7716 		(void *)&cmd_read_reg_reg,
7717 		(void *)&cmd_read_reg_port_id,
7718 		(void *)&cmd_read_reg_reg_off,
7719 		NULL,
7720 	},
7721 };
7722 
7723 /* *** READ PORT REGISTER BIT FIELD *** */
7724 struct cmd_read_reg_bit_field_result {
7725 	cmdline_fixed_string_t read;
7726 	cmdline_fixed_string_t regfield;
7727 	portid_t port_id;
7728 	uint32_t reg_off;
7729 	uint8_t bit1_pos;
7730 	uint8_t bit2_pos;
7731 };
7732 
7733 static void
7734 cmd_read_reg_bit_field_parsed(void *parsed_result,
7735 			      __attribute__((unused)) struct cmdline *cl,
7736 			      __attribute__((unused)) void *data)
7737 {
7738 	struct cmd_read_reg_bit_field_result *res = parsed_result;
7739 	port_reg_bit_field_display(res->port_id, res->reg_off,
7740 				   res->bit1_pos, res->bit2_pos);
7741 }
7742 
7743 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
7744 	TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
7745 				 "read");
7746 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
7747 	TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
7748 				 regfield, "regfield");
7749 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
7750 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
7751 			      UINT16);
7752 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
7753 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
7754 			      UINT32);
7755 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
7756 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
7757 			      UINT8);
7758 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
7759 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
7760 			      UINT8);
7761 
7762 cmdline_parse_inst_t cmd_read_reg_bit_field = {
7763 	.f = cmd_read_reg_bit_field_parsed,
7764 	.data = NULL,
7765 	.help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
7766 	"Read register bit field between bit_x and bit_y included",
7767 	.tokens = {
7768 		(void *)&cmd_read_reg_bit_field_read,
7769 		(void *)&cmd_read_reg_bit_field_regfield,
7770 		(void *)&cmd_read_reg_bit_field_port_id,
7771 		(void *)&cmd_read_reg_bit_field_reg_off,
7772 		(void *)&cmd_read_reg_bit_field_bit1_pos,
7773 		(void *)&cmd_read_reg_bit_field_bit2_pos,
7774 		NULL,
7775 	},
7776 };
7777 
7778 /* *** READ PORT REGISTER BIT *** */
7779 struct cmd_read_reg_bit_result {
7780 	cmdline_fixed_string_t read;
7781 	cmdline_fixed_string_t regbit;
7782 	portid_t port_id;
7783 	uint32_t reg_off;
7784 	uint8_t bit_pos;
7785 };
7786 
7787 static void
7788 cmd_read_reg_bit_parsed(void *parsed_result,
7789 			__attribute__((unused)) struct cmdline *cl,
7790 			__attribute__((unused)) void *data)
7791 {
7792 	struct cmd_read_reg_bit_result *res = parsed_result;
7793 	port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
7794 }
7795 
7796 cmdline_parse_token_string_t cmd_read_reg_bit_read =
7797 	TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
7798 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
7799 	TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
7800 				 regbit, "regbit");
7801 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
7802 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16);
7803 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
7804 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
7805 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
7806 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
7807 
7808 cmdline_parse_inst_t cmd_read_reg_bit = {
7809 	.f = cmd_read_reg_bit_parsed,
7810 	.data = NULL,
7811 	.help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
7812 	.tokens = {
7813 		(void *)&cmd_read_reg_bit_read,
7814 		(void *)&cmd_read_reg_bit_regbit,
7815 		(void *)&cmd_read_reg_bit_port_id,
7816 		(void *)&cmd_read_reg_bit_reg_off,
7817 		(void *)&cmd_read_reg_bit_bit_pos,
7818 		NULL,
7819 	},
7820 };
7821 
7822 /* *** WRITE PORT REGISTER *** */
7823 struct cmd_write_reg_result {
7824 	cmdline_fixed_string_t write;
7825 	cmdline_fixed_string_t reg;
7826 	portid_t port_id;
7827 	uint32_t reg_off;
7828 	uint32_t value;
7829 };
7830 
7831 static void
7832 cmd_write_reg_parsed(void *parsed_result,
7833 		     __attribute__((unused)) struct cmdline *cl,
7834 		     __attribute__((unused)) void *data)
7835 {
7836 	struct cmd_write_reg_result *res = parsed_result;
7837 	port_reg_set(res->port_id, res->reg_off, res->value);
7838 }
7839 
7840 cmdline_parse_token_string_t cmd_write_reg_write =
7841 	TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
7842 cmdline_parse_token_string_t cmd_write_reg_reg =
7843 	TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
7844 cmdline_parse_token_num_t cmd_write_reg_port_id =
7845 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16);
7846 cmdline_parse_token_num_t cmd_write_reg_reg_off =
7847 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
7848 cmdline_parse_token_num_t cmd_write_reg_value =
7849 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
7850 
7851 cmdline_parse_inst_t cmd_write_reg = {
7852 	.f = cmd_write_reg_parsed,
7853 	.data = NULL,
7854 	.help_str = "write reg <port_id> <reg_off> <reg_value>",
7855 	.tokens = {
7856 		(void *)&cmd_write_reg_write,
7857 		(void *)&cmd_write_reg_reg,
7858 		(void *)&cmd_write_reg_port_id,
7859 		(void *)&cmd_write_reg_reg_off,
7860 		(void *)&cmd_write_reg_value,
7861 		NULL,
7862 	},
7863 };
7864 
7865 /* *** WRITE PORT REGISTER BIT FIELD *** */
7866 struct cmd_write_reg_bit_field_result {
7867 	cmdline_fixed_string_t write;
7868 	cmdline_fixed_string_t regfield;
7869 	portid_t port_id;
7870 	uint32_t reg_off;
7871 	uint8_t bit1_pos;
7872 	uint8_t bit2_pos;
7873 	uint32_t value;
7874 };
7875 
7876 static void
7877 cmd_write_reg_bit_field_parsed(void *parsed_result,
7878 			       __attribute__((unused)) struct cmdline *cl,
7879 			       __attribute__((unused)) void *data)
7880 {
7881 	struct cmd_write_reg_bit_field_result *res = parsed_result;
7882 	port_reg_bit_field_set(res->port_id, res->reg_off,
7883 			  res->bit1_pos, res->bit2_pos, res->value);
7884 }
7885 
7886 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
7887 	TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
7888 				 "write");
7889 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
7890 	TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
7891 				 regfield, "regfield");
7892 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
7893 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
7894 			      UINT16);
7895 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
7896 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
7897 			      UINT32);
7898 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
7899 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
7900 			      UINT8);
7901 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
7902 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
7903 			      UINT8);
7904 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
7905 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
7906 			      UINT32);
7907 
7908 cmdline_parse_inst_t cmd_write_reg_bit_field = {
7909 	.f = cmd_write_reg_bit_field_parsed,
7910 	.data = NULL,
7911 	.help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
7912 		"<reg_value>: "
7913 		"Set register bit field between bit_x and bit_y included",
7914 	.tokens = {
7915 		(void *)&cmd_write_reg_bit_field_write,
7916 		(void *)&cmd_write_reg_bit_field_regfield,
7917 		(void *)&cmd_write_reg_bit_field_port_id,
7918 		(void *)&cmd_write_reg_bit_field_reg_off,
7919 		(void *)&cmd_write_reg_bit_field_bit1_pos,
7920 		(void *)&cmd_write_reg_bit_field_bit2_pos,
7921 		(void *)&cmd_write_reg_bit_field_value,
7922 		NULL,
7923 	},
7924 };
7925 
7926 /* *** WRITE PORT REGISTER BIT *** */
7927 struct cmd_write_reg_bit_result {
7928 	cmdline_fixed_string_t write;
7929 	cmdline_fixed_string_t regbit;
7930 	portid_t port_id;
7931 	uint32_t reg_off;
7932 	uint8_t bit_pos;
7933 	uint8_t value;
7934 };
7935 
7936 static void
7937 cmd_write_reg_bit_parsed(void *parsed_result,
7938 			 __attribute__((unused)) struct cmdline *cl,
7939 			 __attribute__((unused)) void *data)
7940 {
7941 	struct cmd_write_reg_bit_result *res = parsed_result;
7942 	port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
7943 }
7944 
7945 cmdline_parse_token_string_t cmd_write_reg_bit_write =
7946 	TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
7947 				 "write");
7948 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
7949 	TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
7950 				 regbit, "regbit");
7951 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
7952 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16);
7953 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
7954 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
7955 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
7956 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
7957 cmdline_parse_token_num_t cmd_write_reg_bit_value =
7958 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
7959 
7960 cmdline_parse_inst_t cmd_write_reg_bit = {
7961 	.f = cmd_write_reg_bit_parsed,
7962 	.data = NULL,
7963 	.help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
7964 		"0 <= bit_x <= 31",
7965 	.tokens = {
7966 		(void *)&cmd_write_reg_bit_write,
7967 		(void *)&cmd_write_reg_bit_regbit,
7968 		(void *)&cmd_write_reg_bit_port_id,
7969 		(void *)&cmd_write_reg_bit_reg_off,
7970 		(void *)&cmd_write_reg_bit_bit_pos,
7971 		(void *)&cmd_write_reg_bit_value,
7972 		NULL,
7973 	},
7974 };
7975 
7976 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
7977 struct cmd_read_rxd_txd_result {
7978 	cmdline_fixed_string_t read;
7979 	cmdline_fixed_string_t rxd_txd;
7980 	portid_t port_id;
7981 	uint16_t queue_id;
7982 	uint16_t desc_id;
7983 };
7984 
7985 static void
7986 cmd_read_rxd_txd_parsed(void *parsed_result,
7987 			__attribute__((unused)) struct cmdline *cl,
7988 			__attribute__((unused)) void *data)
7989 {
7990 	struct cmd_read_rxd_txd_result *res = parsed_result;
7991 
7992 	if (!strcmp(res->rxd_txd, "rxd"))
7993 		rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7994 	else if (!strcmp(res->rxd_txd, "txd"))
7995 		tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7996 }
7997 
7998 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
7999 	TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
8000 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
8001 	TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
8002 				 "rxd#txd");
8003 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
8004 	TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16);
8005 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
8006 	TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
8007 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
8008 	TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
8009 
8010 cmdline_parse_inst_t cmd_read_rxd_txd = {
8011 	.f = cmd_read_rxd_txd_parsed,
8012 	.data = NULL,
8013 	.help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
8014 	.tokens = {
8015 		(void *)&cmd_read_rxd_txd_read,
8016 		(void *)&cmd_read_rxd_txd_rxd_txd,
8017 		(void *)&cmd_read_rxd_txd_port_id,
8018 		(void *)&cmd_read_rxd_txd_queue_id,
8019 		(void *)&cmd_read_rxd_txd_desc_id,
8020 		NULL,
8021 	},
8022 };
8023 
8024 /* *** QUIT *** */
8025 struct cmd_quit_result {
8026 	cmdline_fixed_string_t quit;
8027 };
8028 
8029 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
8030 			    struct cmdline *cl,
8031 			    __attribute__((unused)) void *data)
8032 {
8033 	cmdline_quit(cl);
8034 }
8035 
8036 cmdline_parse_token_string_t cmd_quit_quit =
8037 	TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
8038 
8039 cmdline_parse_inst_t cmd_quit = {
8040 	.f = cmd_quit_parsed,
8041 	.data = NULL,
8042 	.help_str = "quit: Exit application",
8043 	.tokens = {
8044 		(void *)&cmd_quit_quit,
8045 		NULL,
8046 	},
8047 };
8048 
8049 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
8050 struct cmd_mac_addr_result {
8051 	cmdline_fixed_string_t mac_addr_cmd;
8052 	cmdline_fixed_string_t what;
8053 	uint16_t port_num;
8054 	struct rte_ether_addr address;
8055 };
8056 
8057 static void cmd_mac_addr_parsed(void *parsed_result,
8058 		__attribute__((unused)) struct cmdline *cl,
8059 		__attribute__((unused)) void *data)
8060 {
8061 	struct cmd_mac_addr_result *res = parsed_result;
8062 	int ret;
8063 
8064 	if (strcmp(res->what, "add") == 0)
8065 		ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
8066 	else if (strcmp(res->what, "set") == 0)
8067 		ret = rte_eth_dev_default_mac_addr_set(res->port_num,
8068 						       &res->address);
8069 	else
8070 		ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
8071 
8072 	/* check the return value and print it if is < 0 */
8073 	if(ret < 0)
8074 		printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
8075 
8076 }
8077 
8078 cmdline_parse_token_string_t cmd_mac_addr_cmd =
8079 	TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
8080 				"mac_addr");
8081 cmdline_parse_token_string_t cmd_mac_addr_what =
8082 	TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
8083 				"add#remove#set");
8084 cmdline_parse_token_num_t cmd_mac_addr_portnum =
8085 		TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
8086 					UINT16);
8087 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
8088 		TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
8089 
8090 cmdline_parse_inst_t cmd_mac_addr = {
8091 	.f = cmd_mac_addr_parsed,
8092 	.data = (void *)0,
8093 	.help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
8094 			"Add/Remove/Set MAC address on port_id",
8095 	.tokens = {
8096 		(void *)&cmd_mac_addr_cmd,
8097 		(void *)&cmd_mac_addr_what,
8098 		(void *)&cmd_mac_addr_portnum,
8099 		(void *)&cmd_mac_addr_addr,
8100 		NULL,
8101 	},
8102 };
8103 
8104 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
8105 struct cmd_eth_peer_result {
8106 	cmdline_fixed_string_t set;
8107 	cmdline_fixed_string_t eth_peer;
8108 	portid_t port_id;
8109 	cmdline_fixed_string_t peer_addr;
8110 };
8111 
8112 static void cmd_set_eth_peer_parsed(void *parsed_result,
8113 			__attribute__((unused)) struct cmdline *cl,
8114 			__attribute__((unused)) void *data)
8115 {
8116 		struct cmd_eth_peer_result *res = parsed_result;
8117 
8118 		if (test_done == 0) {
8119 			printf("Please stop forwarding first\n");
8120 			return;
8121 		}
8122 		if (!strcmp(res->eth_peer, "eth-peer")) {
8123 			set_fwd_eth_peer(res->port_id, res->peer_addr);
8124 			fwd_config_setup();
8125 		}
8126 }
8127 cmdline_parse_token_string_t cmd_eth_peer_set =
8128 	TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
8129 cmdline_parse_token_string_t cmd_eth_peer =
8130 	TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
8131 cmdline_parse_token_num_t cmd_eth_peer_port_id =
8132 	TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, UINT16);
8133 cmdline_parse_token_string_t cmd_eth_peer_addr =
8134 	TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
8135 
8136 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
8137 	.f = cmd_set_eth_peer_parsed,
8138 	.data = NULL,
8139 	.help_str = "set eth-peer <port_id> <peer_mac>",
8140 	.tokens = {
8141 		(void *)&cmd_eth_peer_set,
8142 		(void *)&cmd_eth_peer,
8143 		(void *)&cmd_eth_peer_port_id,
8144 		(void *)&cmd_eth_peer_addr,
8145 		NULL,
8146 	},
8147 };
8148 
8149 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
8150 struct cmd_set_qmap_result {
8151 	cmdline_fixed_string_t set;
8152 	cmdline_fixed_string_t qmap;
8153 	cmdline_fixed_string_t what;
8154 	portid_t port_id;
8155 	uint16_t queue_id;
8156 	uint8_t map_value;
8157 };
8158 
8159 static void
8160 cmd_set_qmap_parsed(void *parsed_result,
8161 		       __attribute__((unused)) struct cmdline *cl,
8162 		       __attribute__((unused)) void *data)
8163 {
8164 	struct cmd_set_qmap_result *res = parsed_result;
8165 	int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
8166 
8167 	set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
8168 }
8169 
8170 cmdline_parse_token_string_t cmd_setqmap_set =
8171 	TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8172 				 set, "set");
8173 cmdline_parse_token_string_t cmd_setqmap_qmap =
8174 	TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8175 				 qmap, "stat_qmap");
8176 cmdline_parse_token_string_t cmd_setqmap_what =
8177 	TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8178 				 what, "tx#rx");
8179 cmdline_parse_token_num_t cmd_setqmap_portid =
8180 	TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8181 			      port_id, UINT16);
8182 cmdline_parse_token_num_t cmd_setqmap_queueid =
8183 	TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8184 			      queue_id, UINT16);
8185 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
8186 	TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8187 			      map_value, UINT8);
8188 
8189 cmdline_parse_inst_t cmd_set_qmap = {
8190 	.f = cmd_set_qmap_parsed,
8191 	.data = NULL,
8192 	.help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
8193 		"Set statistics mapping value on tx|rx queue_id of port_id",
8194 	.tokens = {
8195 		(void *)&cmd_setqmap_set,
8196 		(void *)&cmd_setqmap_qmap,
8197 		(void *)&cmd_setqmap_what,
8198 		(void *)&cmd_setqmap_portid,
8199 		(void *)&cmd_setqmap_queueid,
8200 		(void *)&cmd_setqmap_mapvalue,
8201 		NULL,
8202 	},
8203 };
8204 
8205 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS  DISPLAY *** */
8206 struct cmd_set_xstats_hide_zero_result {
8207 	cmdline_fixed_string_t keyword;
8208 	cmdline_fixed_string_t name;
8209 	cmdline_fixed_string_t on_off;
8210 };
8211 
8212 static void
8213 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
8214 			__attribute__((unused)) struct cmdline *cl,
8215 			__attribute__((unused)) void *data)
8216 {
8217 	struct cmd_set_xstats_hide_zero_result *res;
8218 	uint16_t on_off = 0;
8219 
8220 	res = parsed_result;
8221 	on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8222 	set_xstats_hide_zero(on_off);
8223 }
8224 
8225 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
8226 	TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8227 				 keyword, "set");
8228 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
8229 	TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8230 				 name, "xstats-hide-zero");
8231 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
8232 	TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8233 				 on_off, "on#off");
8234 
8235 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
8236 	.f = cmd_set_xstats_hide_zero_parsed,
8237 	.data = NULL,
8238 	.help_str = "set xstats-hide-zero on|off",
8239 	.tokens = {
8240 		(void *)&cmd_set_xstats_hide_zero_keyword,
8241 		(void *)&cmd_set_xstats_hide_zero_name,
8242 		(void *)&cmd_set_xstats_hide_zero_on_off,
8243 		NULL,
8244 	},
8245 };
8246 
8247 /* *** CONFIGURE UNICAST HASH TABLE *** */
8248 struct cmd_set_uc_hash_table {
8249 	cmdline_fixed_string_t set;
8250 	cmdline_fixed_string_t port;
8251 	portid_t port_id;
8252 	cmdline_fixed_string_t what;
8253 	struct rte_ether_addr address;
8254 	cmdline_fixed_string_t mode;
8255 };
8256 
8257 static void
8258 cmd_set_uc_hash_parsed(void *parsed_result,
8259 		       __attribute__((unused)) struct cmdline *cl,
8260 		       __attribute__((unused)) void *data)
8261 {
8262 	int ret=0;
8263 	struct cmd_set_uc_hash_table *res = parsed_result;
8264 
8265 	int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8266 
8267 	if (strcmp(res->what, "uta") == 0)
8268 		ret = rte_eth_dev_uc_hash_table_set(res->port_id,
8269 						&res->address,(uint8_t)is_on);
8270 	if (ret < 0)
8271 		printf("bad unicast hash table parameter, return code = %d \n", ret);
8272 
8273 }
8274 
8275 cmdline_parse_token_string_t cmd_set_uc_hash_set =
8276 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8277 				 set, "set");
8278 cmdline_parse_token_string_t cmd_set_uc_hash_port =
8279 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8280 				 port, "port");
8281 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
8282 	TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
8283 			      port_id, UINT16);
8284 cmdline_parse_token_string_t cmd_set_uc_hash_what =
8285 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8286 				 what, "uta");
8287 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
8288 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
8289 				address);
8290 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
8291 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8292 				 mode, "on#off");
8293 
8294 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
8295 	.f = cmd_set_uc_hash_parsed,
8296 	.data = NULL,
8297 	.help_str = "set port <port_id> uta <mac_addr> on|off)",
8298 	.tokens = {
8299 		(void *)&cmd_set_uc_hash_set,
8300 		(void *)&cmd_set_uc_hash_port,
8301 		(void *)&cmd_set_uc_hash_portid,
8302 		(void *)&cmd_set_uc_hash_what,
8303 		(void *)&cmd_set_uc_hash_mac,
8304 		(void *)&cmd_set_uc_hash_mode,
8305 		NULL,
8306 	},
8307 };
8308 
8309 struct cmd_set_uc_all_hash_table {
8310 	cmdline_fixed_string_t set;
8311 	cmdline_fixed_string_t port;
8312 	portid_t port_id;
8313 	cmdline_fixed_string_t what;
8314 	cmdline_fixed_string_t value;
8315 	cmdline_fixed_string_t mode;
8316 };
8317 
8318 static void
8319 cmd_set_uc_all_hash_parsed(void *parsed_result,
8320 		       __attribute__((unused)) struct cmdline *cl,
8321 		       __attribute__((unused)) void *data)
8322 {
8323 	int ret=0;
8324 	struct cmd_set_uc_all_hash_table *res = parsed_result;
8325 
8326 	int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8327 
8328 	if ((strcmp(res->what, "uta") == 0) &&
8329 		(strcmp(res->value, "all") == 0))
8330 		ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
8331 	if (ret < 0)
8332 		printf("bad unicast hash table parameter,"
8333 			"return code = %d \n", ret);
8334 }
8335 
8336 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
8337 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8338 				 set, "set");
8339 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
8340 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8341 				 port, "port");
8342 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
8343 	TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
8344 			      port_id, UINT16);
8345 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
8346 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8347 				 what, "uta");
8348 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
8349 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8350 				value,"all");
8351 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
8352 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8353 				 mode, "on#off");
8354 
8355 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
8356 	.f = cmd_set_uc_all_hash_parsed,
8357 	.data = NULL,
8358 	.help_str = "set port <port_id> uta all on|off",
8359 	.tokens = {
8360 		(void *)&cmd_set_uc_all_hash_set,
8361 		(void *)&cmd_set_uc_all_hash_port,
8362 		(void *)&cmd_set_uc_all_hash_portid,
8363 		(void *)&cmd_set_uc_all_hash_what,
8364 		(void *)&cmd_set_uc_all_hash_value,
8365 		(void *)&cmd_set_uc_all_hash_mode,
8366 		NULL,
8367 	},
8368 };
8369 
8370 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
8371 struct cmd_set_vf_macvlan_filter {
8372 	cmdline_fixed_string_t set;
8373 	cmdline_fixed_string_t port;
8374 	portid_t port_id;
8375 	cmdline_fixed_string_t vf;
8376 	uint8_t vf_id;
8377 	struct rte_ether_addr address;
8378 	cmdline_fixed_string_t filter_type;
8379 	cmdline_fixed_string_t mode;
8380 };
8381 
8382 static void
8383 cmd_set_vf_macvlan_parsed(void *parsed_result,
8384 		       __attribute__((unused)) struct cmdline *cl,
8385 		       __attribute__((unused)) void *data)
8386 {
8387 	int is_on, ret = 0;
8388 	struct cmd_set_vf_macvlan_filter *res = parsed_result;
8389 	struct rte_eth_mac_filter filter;
8390 
8391 	memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
8392 
8393 	rte_memcpy(&filter.mac_addr, &res->address, RTE_ETHER_ADDR_LEN);
8394 
8395 	/* set VF MAC filter */
8396 	filter.is_vf = 1;
8397 
8398 	/* set VF ID */
8399 	filter.dst_id = res->vf_id;
8400 
8401 	if (!strcmp(res->filter_type, "exact-mac"))
8402 		filter.filter_type = RTE_MAC_PERFECT_MATCH;
8403 	else if (!strcmp(res->filter_type, "exact-mac-vlan"))
8404 		filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
8405 	else if (!strcmp(res->filter_type, "hashmac"))
8406 		filter.filter_type = RTE_MAC_HASH_MATCH;
8407 	else if (!strcmp(res->filter_type, "hashmac-vlan"))
8408 		filter.filter_type = RTE_MACVLAN_HASH_MATCH;
8409 
8410 	is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8411 
8412 	if (is_on)
8413 		ret = rte_eth_dev_filter_ctrl(res->port_id,
8414 					RTE_ETH_FILTER_MACVLAN,
8415 					RTE_ETH_FILTER_ADD,
8416 					 &filter);
8417 	else
8418 		ret = rte_eth_dev_filter_ctrl(res->port_id,
8419 					RTE_ETH_FILTER_MACVLAN,
8420 					RTE_ETH_FILTER_DELETE,
8421 					&filter);
8422 
8423 	if (ret < 0)
8424 		printf("bad set MAC hash parameter, return code = %d\n", ret);
8425 
8426 }
8427 
8428 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
8429 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8430 				 set, "set");
8431 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
8432 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8433 				 port, "port");
8434 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
8435 	TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8436 			      port_id, UINT16);
8437 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
8438 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8439 				 vf, "vf");
8440 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
8441 	TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8442 				vf_id, UINT8);
8443 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
8444 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8445 				address);
8446 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
8447 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8448 				filter_type, "exact-mac#exact-mac-vlan"
8449 				"#hashmac#hashmac-vlan");
8450 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
8451 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8452 				 mode, "on#off");
8453 
8454 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
8455 	.f = cmd_set_vf_macvlan_parsed,
8456 	.data = NULL,
8457 	.help_str = "set port <port_id> vf <vf_id> <mac_addr> "
8458 		"exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
8459 		"Exact match rule: exact match of MAC or MAC and VLAN; "
8460 		"hash match rule: hash match of MAC and exact match of VLAN",
8461 	.tokens = {
8462 		(void *)&cmd_set_vf_macvlan_set,
8463 		(void *)&cmd_set_vf_macvlan_port,
8464 		(void *)&cmd_set_vf_macvlan_portid,
8465 		(void *)&cmd_set_vf_macvlan_vf,
8466 		(void *)&cmd_set_vf_macvlan_vf_id,
8467 		(void *)&cmd_set_vf_macvlan_mac,
8468 		(void *)&cmd_set_vf_macvlan_filter_type,
8469 		(void *)&cmd_set_vf_macvlan_mode,
8470 		NULL,
8471 	},
8472 };
8473 
8474 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
8475 struct cmd_set_vf_traffic {
8476 	cmdline_fixed_string_t set;
8477 	cmdline_fixed_string_t port;
8478 	portid_t port_id;
8479 	cmdline_fixed_string_t vf;
8480 	uint8_t vf_id;
8481 	cmdline_fixed_string_t what;
8482 	cmdline_fixed_string_t mode;
8483 };
8484 
8485 static void
8486 cmd_set_vf_traffic_parsed(void *parsed_result,
8487 		       __attribute__((unused)) struct cmdline *cl,
8488 		       __attribute__((unused)) void *data)
8489 {
8490 	struct cmd_set_vf_traffic *res = parsed_result;
8491 	int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
8492 	int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8493 
8494 	set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
8495 }
8496 
8497 cmdline_parse_token_string_t cmd_setvf_traffic_set =
8498 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8499 				 set, "set");
8500 cmdline_parse_token_string_t cmd_setvf_traffic_port =
8501 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8502 				 port, "port");
8503 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8504 	TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8505 			      port_id, UINT16);
8506 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8507 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8508 				 vf, "vf");
8509 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8510 	TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8511 			      vf_id, UINT8);
8512 cmdline_parse_token_string_t cmd_setvf_traffic_what =
8513 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8514 				 what, "tx#rx");
8515 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8516 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8517 				 mode, "on#off");
8518 
8519 cmdline_parse_inst_t cmd_set_vf_traffic = {
8520 	.f = cmd_set_vf_traffic_parsed,
8521 	.data = NULL,
8522 	.help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8523 	.tokens = {
8524 		(void *)&cmd_setvf_traffic_set,
8525 		(void *)&cmd_setvf_traffic_port,
8526 		(void *)&cmd_setvf_traffic_portid,
8527 		(void *)&cmd_setvf_traffic_vf,
8528 		(void *)&cmd_setvf_traffic_vfid,
8529 		(void *)&cmd_setvf_traffic_what,
8530 		(void *)&cmd_setvf_traffic_mode,
8531 		NULL,
8532 	},
8533 };
8534 
8535 /* *** CONFIGURE VF RECEIVE MODE *** */
8536 struct cmd_set_vf_rxmode {
8537 	cmdline_fixed_string_t set;
8538 	cmdline_fixed_string_t port;
8539 	portid_t port_id;
8540 	cmdline_fixed_string_t vf;
8541 	uint8_t vf_id;
8542 	cmdline_fixed_string_t what;
8543 	cmdline_fixed_string_t mode;
8544 	cmdline_fixed_string_t on;
8545 };
8546 
8547 static void
8548 cmd_set_vf_rxmode_parsed(void *parsed_result,
8549 		       __attribute__((unused)) struct cmdline *cl,
8550 		       __attribute__((unused)) void *data)
8551 {
8552 	int ret = -ENOTSUP;
8553 	uint16_t vf_rxmode = 0;
8554 	struct cmd_set_vf_rxmode *res = parsed_result;
8555 
8556 	int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8557 	if (!strcmp(res->what,"rxmode")) {
8558 		if (!strcmp(res->mode, "AUPE"))
8559 			vf_rxmode |= ETH_VMDQ_ACCEPT_UNTAG;
8560 		else if (!strcmp(res->mode, "ROPE"))
8561 			vf_rxmode |= ETH_VMDQ_ACCEPT_HASH_UC;
8562 		else if (!strcmp(res->mode, "BAM"))
8563 			vf_rxmode |= ETH_VMDQ_ACCEPT_BROADCAST;
8564 		else if (!strncmp(res->mode, "MPE",3))
8565 			vf_rxmode |= ETH_VMDQ_ACCEPT_MULTICAST;
8566 	}
8567 
8568 	RTE_SET_USED(is_on);
8569 
8570 #ifdef RTE_LIBRTE_IXGBE_PMD
8571 	if (ret == -ENOTSUP)
8572 		ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8573 						  vf_rxmode, (uint8_t)is_on);
8574 #endif
8575 #ifdef RTE_LIBRTE_BNXT_PMD
8576 	if (ret == -ENOTSUP)
8577 		ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8578 						 vf_rxmode, (uint8_t)is_on);
8579 #endif
8580 	if (ret < 0)
8581 		printf("bad VF receive mode parameter, return code = %d \n",
8582 		ret);
8583 }
8584 
8585 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8586 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8587 				 set, "set");
8588 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8589 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8590 				 port, "port");
8591 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8592 	TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8593 			      port_id, UINT16);
8594 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8595 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8596 				 vf, "vf");
8597 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8598 	TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8599 			      vf_id, UINT8);
8600 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
8601 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8602 				 what, "rxmode");
8603 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
8604 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8605 				 mode, "AUPE#ROPE#BAM#MPE");
8606 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
8607 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8608 				 on, "on#off");
8609 
8610 cmdline_parse_inst_t cmd_set_vf_rxmode = {
8611 	.f = cmd_set_vf_rxmode_parsed,
8612 	.data = NULL,
8613 	.help_str = "set port <port_id> vf <vf_id> rxmode "
8614 		"AUPE|ROPE|BAM|MPE on|off",
8615 	.tokens = {
8616 		(void *)&cmd_set_vf_rxmode_set,
8617 		(void *)&cmd_set_vf_rxmode_port,
8618 		(void *)&cmd_set_vf_rxmode_portid,
8619 		(void *)&cmd_set_vf_rxmode_vf,
8620 		(void *)&cmd_set_vf_rxmode_vfid,
8621 		(void *)&cmd_set_vf_rxmode_what,
8622 		(void *)&cmd_set_vf_rxmode_mode,
8623 		(void *)&cmd_set_vf_rxmode_on,
8624 		NULL,
8625 	},
8626 };
8627 
8628 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
8629 struct cmd_vf_mac_addr_result {
8630 	cmdline_fixed_string_t mac_addr_cmd;
8631 	cmdline_fixed_string_t what;
8632 	cmdline_fixed_string_t port;
8633 	uint16_t port_num;
8634 	cmdline_fixed_string_t vf;
8635 	uint8_t vf_num;
8636 	struct rte_ether_addr address;
8637 };
8638 
8639 static void cmd_vf_mac_addr_parsed(void *parsed_result,
8640 		__attribute__((unused)) struct cmdline *cl,
8641 		__attribute__((unused)) void *data)
8642 {
8643 	struct cmd_vf_mac_addr_result *res = parsed_result;
8644 	int ret = -ENOTSUP;
8645 
8646 	if (strcmp(res->what, "add") != 0)
8647 		return;
8648 
8649 #ifdef RTE_LIBRTE_I40E_PMD
8650 	if (ret == -ENOTSUP)
8651 		ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
8652 						   &res->address);
8653 #endif
8654 #ifdef RTE_LIBRTE_BNXT_PMD
8655 	if (ret == -ENOTSUP)
8656 		ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
8657 						res->vf_num);
8658 #endif
8659 
8660 	if(ret < 0)
8661 		printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
8662 
8663 }
8664 
8665 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
8666 	TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8667 				mac_addr_cmd,"mac_addr");
8668 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
8669 	TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8670 				what,"add");
8671 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
8672 	TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8673 				port,"port");
8674 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
8675 	TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8676 				port_num, UINT16);
8677 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
8678 	TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8679 				vf,"vf");
8680 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
8681 	TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8682 				vf_num, UINT8);
8683 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
8684 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
8685 				address);
8686 
8687 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
8688 	.f = cmd_vf_mac_addr_parsed,
8689 	.data = (void *)0,
8690 	.help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
8691 		"Add MAC address filtering for a VF on port_id",
8692 	.tokens = {
8693 		(void *)&cmd_vf_mac_addr_cmd,
8694 		(void *)&cmd_vf_mac_addr_what,
8695 		(void *)&cmd_vf_mac_addr_port,
8696 		(void *)&cmd_vf_mac_addr_portnum,
8697 		(void *)&cmd_vf_mac_addr_vf,
8698 		(void *)&cmd_vf_mac_addr_vfnum,
8699 		(void *)&cmd_vf_mac_addr_addr,
8700 		NULL,
8701 	},
8702 };
8703 
8704 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
8705 struct cmd_vf_rx_vlan_filter {
8706 	cmdline_fixed_string_t rx_vlan;
8707 	cmdline_fixed_string_t what;
8708 	uint16_t vlan_id;
8709 	cmdline_fixed_string_t port;
8710 	portid_t port_id;
8711 	cmdline_fixed_string_t vf;
8712 	uint64_t vf_mask;
8713 };
8714 
8715 static void
8716 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
8717 			  __attribute__((unused)) struct cmdline *cl,
8718 			  __attribute__((unused)) void *data)
8719 {
8720 	struct cmd_vf_rx_vlan_filter *res = parsed_result;
8721 	int ret = -ENOTSUP;
8722 
8723 	__rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
8724 
8725 #ifdef RTE_LIBRTE_IXGBE_PMD
8726 	if (ret == -ENOTSUP)
8727 		ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
8728 				res->vlan_id, res->vf_mask, is_add);
8729 #endif
8730 #ifdef RTE_LIBRTE_I40E_PMD
8731 	if (ret == -ENOTSUP)
8732 		ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
8733 				res->vlan_id, res->vf_mask, is_add);
8734 #endif
8735 #ifdef RTE_LIBRTE_BNXT_PMD
8736 	if (ret == -ENOTSUP)
8737 		ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
8738 				res->vlan_id, res->vf_mask, is_add);
8739 #endif
8740 
8741 	switch (ret) {
8742 	case 0:
8743 		break;
8744 	case -EINVAL:
8745 		printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
8746 				res->vlan_id, res->vf_mask);
8747 		break;
8748 	case -ENODEV:
8749 		printf("invalid port_id %d\n", res->port_id);
8750 		break;
8751 	case -ENOTSUP:
8752 		printf("function not implemented or supported\n");
8753 		break;
8754 	default:
8755 		printf("programming error: (%s)\n", strerror(-ret));
8756 	}
8757 }
8758 
8759 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
8760 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8761 				 rx_vlan, "rx_vlan");
8762 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
8763 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8764 				 what, "add#rm");
8765 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
8766 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8767 			      vlan_id, UINT16);
8768 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
8769 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8770 				 port, "port");
8771 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
8772 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8773 			      port_id, UINT16);
8774 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
8775 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8776 				 vf, "vf");
8777 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
8778 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8779 			      vf_mask, UINT64);
8780 
8781 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
8782 	.f = cmd_vf_rx_vlan_filter_parsed,
8783 	.data = NULL,
8784 	.help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
8785 		"(vf_mask = hexadecimal VF mask)",
8786 	.tokens = {
8787 		(void *)&cmd_vf_rx_vlan_filter_rx_vlan,
8788 		(void *)&cmd_vf_rx_vlan_filter_what,
8789 		(void *)&cmd_vf_rx_vlan_filter_vlanid,
8790 		(void *)&cmd_vf_rx_vlan_filter_port,
8791 		(void *)&cmd_vf_rx_vlan_filter_portid,
8792 		(void *)&cmd_vf_rx_vlan_filter_vf,
8793 		(void *)&cmd_vf_rx_vlan_filter_vf_mask,
8794 		NULL,
8795 	},
8796 };
8797 
8798 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
8799 struct cmd_queue_rate_limit_result {
8800 	cmdline_fixed_string_t set;
8801 	cmdline_fixed_string_t port;
8802 	uint16_t port_num;
8803 	cmdline_fixed_string_t queue;
8804 	uint8_t queue_num;
8805 	cmdline_fixed_string_t rate;
8806 	uint16_t rate_num;
8807 };
8808 
8809 static void cmd_queue_rate_limit_parsed(void *parsed_result,
8810 		__attribute__((unused)) struct cmdline *cl,
8811 		__attribute__((unused)) void *data)
8812 {
8813 	struct cmd_queue_rate_limit_result *res = parsed_result;
8814 	int ret = 0;
8815 
8816 	if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8817 		&& (strcmp(res->queue, "queue") == 0)
8818 		&& (strcmp(res->rate, "rate") == 0))
8819 		ret = set_queue_rate_limit(res->port_num, res->queue_num,
8820 					res->rate_num);
8821 	if (ret < 0)
8822 		printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
8823 
8824 }
8825 
8826 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
8827 	TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8828 				set, "set");
8829 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
8830 	TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8831 				port, "port");
8832 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
8833 	TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8834 				port_num, UINT16);
8835 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
8836 	TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8837 				queue, "queue");
8838 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
8839 	TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8840 				queue_num, UINT8);
8841 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
8842 	TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8843 				rate, "rate");
8844 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
8845 	TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8846 				rate_num, UINT16);
8847 
8848 cmdline_parse_inst_t cmd_queue_rate_limit = {
8849 	.f = cmd_queue_rate_limit_parsed,
8850 	.data = (void *)0,
8851 	.help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
8852 		"Set rate limit for a queue on port_id",
8853 	.tokens = {
8854 		(void *)&cmd_queue_rate_limit_set,
8855 		(void *)&cmd_queue_rate_limit_port,
8856 		(void *)&cmd_queue_rate_limit_portnum,
8857 		(void *)&cmd_queue_rate_limit_queue,
8858 		(void *)&cmd_queue_rate_limit_queuenum,
8859 		(void *)&cmd_queue_rate_limit_rate,
8860 		(void *)&cmd_queue_rate_limit_ratenum,
8861 		NULL,
8862 	},
8863 };
8864 
8865 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
8866 struct cmd_vf_rate_limit_result {
8867 	cmdline_fixed_string_t set;
8868 	cmdline_fixed_string_t port;
8869 	uint16_t port_num;
8870 	cmdline_fixed_string_t vf;
8871 	uint8_t vf_num;
8872 	cmdline_fixed_string_t rate;
8873 	uint16_t rate_num;
8874 	cmdline_fixed_string_t q_msk;
8875 	uint64_t q_msk_val;
8876 };
8877 
8878 static void cmd_vf_rate_limit_parsed(void *parsed_result,
8879 		__attribute__((unused)) struct cmdline *cl,
8880 		__attribute__((unused)) void *data)
8881 {
8882 	struct cmd_vf_rate_limit_result *res = parsed_result;
8883 	int ret = 0;
8884 
8885 	if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8886 		&& (strcmp(res->vf, "vf") == 0)
8887 		&& (strcmp(res->rate, "rate") == 0)
8888 		&& (strcmp(res->q_msk, "queue_mask") == 0))
8889 		ret = set_vf_rate_limit(res->port_num, res->vf_num,
8890 					res->rate_num, res->q_msk_val);
8891 	if (ret < 0)
8892 		printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
8893 
8894 }
8895 
8896 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
8897 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8898 				set, "set");
8899 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
8900 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8901 				port, "port");
8902 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
8903 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8904 				port_num, UINT16);
8905 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
8906 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8907 				vf, "vf");
8908 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
8909 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8910 				vf_num, UINT8);
8911 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
8912 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8913 				rate, "rate");
8914 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
8915 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8916 				rate_num, UINT16);
8917 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
8918 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8919 				q_msk, "queue_mask");
8920 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
8921 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8922 				q_msk_val, UINT64);
8923 
8924 cmdline_parse_inst_t cmd_vf_rate_limit = {
8925 	.f = cmd_vf_rate_limit_parsed,
8926 	.data = (void *)0,
8927 	.help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
8928 		"queue_mask <queue_mask_value>: "
8929 		"Set rate limit for queues of VF on port_id",
8930 	.tokens = {
8931 		(void *)&cmd_vf_rate_limit_set,
8932 		(void *)&cmd_vf_rate_limit_port,
8933 		(void *)&cmd_vf_rate_limit_portnum,
8934 		(void *)&cmd_vf_rate_limit_vf,
8935 		(void *)&cmd_vf_rate_limit_vfnum,
8936 		(void *)&cmd_vf_rate_limit_rate,
8937 		(void *)&cmd_vf_rate_limit_ratenum,
8938 		(void *)&cmd_vf_rate_limit_q_msk,
8939 		(void *)&cmd_vf_rate_limit_q_msk_val,
8940 		NULL,
8941 	},
8942 };
8943 
8944 /* *** ADD TUNNEL FILTER OF A PORT *** */
8945 struct cmd_tunnel_filter_result {
8946 	cmdline_fixed_string_t cmd;
8947 	cmdline_fixed_string_t what;
8948 	portid_t port_id;
8949 	struct rte_ether_addr outer_mac;
8950 	struct rte_ether_addr inner_mac;
8951 	cmdline_ipaddr_t ip_value;
8952 	uint16_t inner_vlan;
8953 	cmdline_fixed_string_t tunnel_type;
8954 	cmdline_fixed_string_t filter_type;
8955 	uint32_t tenant_id;
8956 	uint16_t queue_num;
8957 };
8958 
8959 static void
8960 cmd_tunnel_filter_parsed(void *parsed_result,
8961 			  __attribute__((unused)) struct cmdline *cl,
8962 			  __attribute__((unused)) void *data)
8963 {
8964 	struct cmd_tunnel_filter_result *res = parsed_result;
8965 	struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
8966 	int ret = 0;
8967 
8968 	memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
8969 
8970 	rte_ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
8971 	rte_ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
8972 	tunnel_filter_conf.inner_vlan = res->inner_vlan;
8973 
8974 	if (res->ip_value.family == AF_INET) {
8975 		tunnel_filter_conf.ip_addr.ipv4_addr =
8976 			res->ip_value.addr.ipv4.s_addr;
8977 		tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
8978 	} else {
8979 		memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
8980 			&(res->ip_value.addr.ipv6),
8981 			sizeof(struct in6_addr));
8982 		tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
8983 	}
8984 
8985 	if (!strcmp(res->filter_type, "imac-ivlan"))
8986 		tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
8987 	else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
8988 		tunnel_filter_conf.filter_type =
8989 			RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
8990 	else if (!strcmp(res->filter_type, "imac-tenid"))
8991 		tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
8992 	else if (!strcmp(res->filter_type, "imac"))
8993 		tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
8994 	else if (!strcmp(res->filter_type, "omac-imac-tenid"))
8995 		tunnel_filter_conf.filter_type =
8996 			RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
8997 	else if (!strcmp(res->filter_type, "oip"))
8998 		tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
8999 	else if (!strcmp(res->filter_type, "iip"))
9000 		tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
9001 	else {
9002 		printf("The filter type is not supported");
9003 		return;
9004 	}
9005 
9006 	if (!strcmp(res->tunnel_type, "vxlan"))
9007 		tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
9008 	else if (!strcmp(res->tunnel_type, "vxlan-gpe"))
9009 		tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9010 	else if (!strcmp(res->tunnel_type, "nvgre"))
9011 		tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
9012 	else if (!strcmp(res->tunnel_type, "ipingre"))
9013 		tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
9014 	else {
9015 		printf("The tunnel type %s not supported.\n", res->tunnel_type);
9016 		return;
9017 	}
9018 
9019 	tunnel_filter_conf.tenant_id = res->tenant_id;
9020 	tunnel_filter_conf.queue_id = res->queue_num;
9021 	if (!strcmp(res->what, "add"))
9022 		ret = rte_eth_dev_filter_ctrl(res->port_id,
9023 					RTE_ETH_FILTER_TUNNEL,
9024 					RTE_ETH_FILTER_ADD,
9025 					&tunnel_filter_conf);
9026 	else
9027 		ret = rte_eth_dev_filter_ctrl(res->port_id,
9028 					RTE_ETH_FILTER_TUNNEL,
9029 					RTE_ETH_FILTER_DELETE,
9030 					&tunnel_filter_conf);
9031 	if (ret < 0)
9032 		printf("cmd_tunnel_filter_parsed error: (%s)\n",
9033 				strerror(-ret));
9034 
9035 }
9036 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
9037 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9038 	cmd, "tunnel_filter");
9039 cmdline_parse_token_string_t cmd_tunnel_filter_what =
9040 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9041 	what, "add#rm");
9042 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
9043 	TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9044 	port_id, UINT16);
9045 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
9046 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
9047 	outer_mac);
9048 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
9049 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
9050 	inner_mac);
9051 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
9052 	TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9053 	inner_vlan, UINT16);
9054 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
9055 	TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
9056 	ip_value);
9057 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
9058 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9059 	tunnel_type, "vxlan#nvgre#ipingre#vxlan-gpe");
9060 
9061 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
9062 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9063 	filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
9064 		"imac#omac-imac-tenid");
9065 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
9066 	TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9067 	tenant_id, UINT32);
9068 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
9069 	TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9070 	queue_num, UINT16);
9071 
9072 cmdline_parse_inst_t cmd_tunnel_filter = {
9073 	.f = cmd_tunnel_filter_parsed,
9074 	.data = (void *)0,
9075 	.help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
9076 		"<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
9077 		"imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
9078 		"<queue_id>: Add/Rm tunnel filter of a port",
9079 	.tokens = {
9080 		(void *)&cmd_tunnel_filter_cmd,
9081 		(void *)&cmd_tunnel_filter_what,
9082 		(void *)&cmd_tunnel_filter_port_id,
9083 		(void *)&cmd_tunnel_filter_outer_mac,
9084 		(void *)&cmd_tunnel_filter_inner_mac,
9085 		(void *)&cmd_tunnel_filter_ip_value,
9086 		(void *)&cmd_tunnel_filter_innner_vlan,
9087 		(void *)&cmd_tunnel_filter_tunnel_type,
9088 		(void *)&cmd_tunnel_filter_filter_type,
9089 		(void *)&cmd_tunnel_filter_tenant_id,
9090 		(void *)&cmd_tunnel_filter_queue_num,
9091 		NULL,
9092 	},
9093 };
9094 
9095 /* *** CONFIGURE TUNNEL UDP PORT *** */
9096 struct cmd_tunnel_udp_config {
9097 	cmdline_fixed_string_t cmd;
9098 	cmdline_fixed_string_t what;
9099 	uint16_t udp_port;
9100 	portid_t port_id;
9101 };
9102 
9103 static void
9104 cmd_tunnel_udp_config_parsed(void *parsed_result,
9105 			  __attribute__((unused)) struct cmdline *cl,
9106 			  __attribute__((unused)) void *data)
9107 {
9108 	struct cmd_tunnel_udp_config *res = parsed_result;
9109 	struct rte_eth_udp_tunnel tunnel_udp;
9110 	int ret;
9111 
9112 	tunnel_udp.udp_port = res->udp_port;
9113 
9114 	if (!strcmp(res->cmd, "rx_vxlan_port"))
9115 		tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9116 
9117 	if (!strcmp(res->what, "add"))
9118 		ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9119 						      &tunnel_udp);
9120 	else
9121 		ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9122 							 &tunnel_udp);
9123 
9124 	if (ret < 0)
9125 		printf("udp tunneling add error: (%s)\n", strerror(-ret));
9126 }
9127 
9128 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
9129 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9130 				cmd, "rx_vxlan_port");
9131 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
9132 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9133 				what, "add#rm");
9134 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
9135 	TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9136 				udp_port, UINT16);
9137 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
9138 	TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9139 				port_id, UINT16);
9140 
9141 cmdline_parse_inst_t cmd_tunnel_udp_config = {
9142 	.f = cmd_tunnel_udp_config_parsed,
9143 	.data = (void *)0,
9144 	.help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
9145 		"Add/Remove a tunneling UDP port filter",
9146 	.tokens = {
9147 		(void *)&cmd_tunnel_udp_config_cmd,
9148 		(void *)&cmd_tunnel_udp_config_what,
9149 		(void *)&cmd_tunnel_udp_config_udp_port,
9150 		(void *)&cmd_tunnel_udp_config_port_id,
9151 		NULL,
9152 	},
9153 };
9154 
9155 struct cmd_config_tunnel_udp_port {
9156 	cmdline_fixed_string_t port;
9157 	cmdline_fixed_string_t config;
9158 	portid_t port_id;
9159 	cmdline_fixed_string_t udp_tunnel_port;
9160 	cmdline_fixed_string_t action;
9161 	cmdline_fixed_string_t tunnel_type;
9162 	uint16_t udp_port;
9163 };
9164 
9165 static void
9166 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
9167 			       __attribute__((unused)) struct cmdline *cl,
9168 			       __attribute__((unused)) void *data)
9169 {
9170 	struct cmd_config_tunnel_udp_port *res = parsed_result;
9171 	struct rte_eth_udp_tunnel tunnel_udp;
9172 	int ret = 0;
9173 
9174 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9175 		return;
9176 
9177 	tunnel_udp.udp_port = res->udp_port;
9178 
9179 	if (!strcmp(res->tunnel_type, "vxlan")) {
9180 		tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9181 	} else if (!strcmp(res->tunnel_type, "geneve")) {
9182 		tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE;
9183 	} else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
9184 		tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9185 	} else {
9186 		printf("Invalid tunnel type\n");
9187 		return;
9188 	}
9189 
9190 	if (!strcmp(res->action, "add"))
9191 		ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9192 						      &tunnel_udp);
9193 	else
9194 		ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9195 							 &tunnel_udp);
9196 
9197 	if (ret < 0)
9198 		printf("udp tunneling port add error: (%s)\n", strerror(-ret));
9199 }
9200 
9201 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
9202 	TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
9203 				 "port");
9204 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
9205 	TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
9206 				 "config");
9207 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
9208 	TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
9209 			      UINT16);
9210 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
9211 	TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
9212 				 udp_tunnel_port,
9213 				 "udp_tunnel_port");
9214 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
9215 	TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
9216 				 "add#rm");
9217 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
9218 	TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
9219 				 "vxlan#geneve#vxlan-gpe");
9220 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
9221 	TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
9222 			      UINT16);
9223 
9224 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
9225 	.f = cmd_cfg_tunnel_udp_port_parsed,
9226 	.data = NULL,
9227 	.help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|geneve|vxlan-gpe <udp_port>",
9228 	.tokens = {
9229 		(void *)&cmd_config_tunnel_udp_port_port,
9230 		(void *)&cmd_config_tunnel_udp_port_config,
9231 		(void *)&cmd_config_tunnel_udp_port_port_id,
9232 		(void *)&cmd_config_tunnel_udp_port_tunnel_port,
9233 		(void *)&cmd_config_tunnel_udp_port_action,
9234 		(void *)&cmd_config_tunnel_udp_port_tunnel_type,
9235 		(void *)&cmd_config_tunnel_udp_port_value,
9236 		NULL,
9237 	},
9238 };
9239 
9240 /* *** GLOBAL CONFIG *** */
9241 struct cmd_global_config_result {
9242 	cmdline_fixed_string_t cmd;
9243 	portid_t port_id;
9244 	cmdline_fixed_string_t cfg_type;
9245 	uint8_t len;
9246 };
9247 
9248 static void
9249 cmd_global_config_parsed(void *parsed_result,
9250 			 __attribute__((unused)) struct cmdline *cl,
9251 			 __attribute__((unused)) void *data)
9252 {
9253 	struct cmd_global_config_result *res = parsed_result;
9254 	struct rte_eth_global_cfg conf;
9255 	int ret;
9256 
9257 	memset(&conf, 0, sizeof(conf));
9258 	conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
9259 	conf.cfg.gre_key_len = res->len;
9260 	ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
9261 				      RTE_ETH_FILTER_SET, &conf);
9262 	if (ret != 0)
9263 		printf("Global config error\n");
9264 }
9265 
9266 cmdline_parse_token_string_t cmd_global_config_cmd =
9267 	TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
9268 		"global_config");
9269 cmdline_parse_token_num_t cmd_global_config_port_id =
9270 	TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id,
9271 			       UINT16);
9272 cmdline_parse_token_string_t cmd_global_config_type =
9273 	TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
9274 		cfg_type, "gre-key-len");
9275 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
9276 	TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
9277 		len, UINT8);
9278 
9279 cmdline_parse_inst_t cmd_global_config = {
9280 	.f = cmd_global_config_parsed,
9281 	.data = (void *)NULL,
9282 	.help_str = "global_config <port_id> gre-key-len <key_len>",
9283 	.tokens = {
9284 		(void *)&cmd_global_config_cmd,
9285 		(void *)&cmd_global_config_port_id,
9286 		(void *)&cmd_global_config_type,
9287 		(void *)&cmd_global_config_gre_key_len,
9288 		NULL,
9289 	},
9290 };
9291 
9292 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
9293 struct cmd_set_mirror_mask_result {
9294 	cmdline_fixed_string_t set;
9295 	cmdline_fixed_string_t port;
9296 	portid_t port_id;
9297 	cmdline_fixed_string_t mirror;
9298 	uint8_t rule_id;
9299 	cmdline_fixed_string_t what;
9300 	cmdline_fixed_string_t value;
9301 	cmdline_fixed_string_t dstpool;
9302 	uint8_t dstpool_id;
9303 	cmdline_fixed_string_t on;
9304 };
9305 
9306 cmdline_parse_token_string_t cmd_mirror_mask_set =
9307 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9308 				set, "set");
9309 cmdline_parse_token_string_t cmd_mirror_mask_port =
9310 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9311 				port, "port");
9312 cmdline_parse_token_num_t cmd_mirror_mask_portid =
9313 	TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9314 				port_id, UINT16);
9315 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
9316 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9317 				mirror, "mirror-rule");
9318 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
9319 	TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9320 				rule_id, UINT8);
9321 cmdline_parse_token_string_t cmd_mirror_mask_what =
9322 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9323 				what, "pool-mirror-up#pool-mirror-down"
9324 				      "#vlan-mirror");
9325 cmdline_parse_token_string_t cmd_mirror_mask_value =
9326 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9327 				value, NULL);
9328 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
9329 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9330 				dstpool, "dst-pool");
9331 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
9332 	TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9333 				dstpool_id, UINT8);
9334 cmdline_parse_token_string_t cmd_mirror_mask_on =
9335 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9336 				on, "on#off");
9337 
9338 static void
9339 cmd_set_mirror_mask_parsed(void *parsed_result,
9340 		       __attribute__((unused)) struct cmdline *cl,
9341 		       __attribute__((unused)) void *data)
9342 {
9343 	int ret,nb_item,i;
9344 	struct cmd_set_mirror_mask_result *res = parsed_result;
9345 	struct rte_eth_mirror_conf mr_conf;
9346 
9347 	memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9348 
9349 	unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
9350 
9351 	mr_conf.dst_pool = res->dstpool_id;
9352 
9353 	if (!strcmp(res->what, "pool-mirror-up")) {
9354 		mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9355 		mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
9356 	} else if (!strcmp(res->what, "pool-mirror-down")) {
9357 		mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9358 		mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
9359 	} else if (!strcmp(res->what, "vlan-mirror")) {
9360 		mr_conf.rule_type = ETH_MIRROR_VLAN;
9361 		nb_item = parse_item_list(res->value, "vlan",
9362 				ETH_MIRROR_MAX_VLANS, vlan_list, 1);
9363 		if (nb_item <= 0)
9364 			return;
9365 
9366 		for (i = 0; i < nb_item; i++) {
9367 			if (vlan_list[i] > RTE_ETHER_MAX_VLAN_ID) {
9368 				printf("Invalid vlan_id: must be < 4096\n");
9369 				return;
9370 			}
9371 
9372 			mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
9373 			mr_conf.vlan.vlan_mask |= 1ULL << i;
9374 		}
9375 	}
9376 
9377 	if (!strcmp(res->on, "on"))
9378 		ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9379 						res->rule_id, 1);
9380 	else
9381 		ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9382 						res->rule_id, 0);
9383 	if (ret < 0)
9384 		printf("mirror rule add error: (%s)\n", strerror(-ret));
9385 }
9386 
9387 cmdline_parse_inst_t cmd_set_mirror_mask = {
9388 		.f = cmd_set_mirror_mask_parsed,
9389 		.data = NULL,
9390 		.help_str = "set port <port_id> mirror-rule <rule_id> "
9391 			"pool-mirror-up|pool-mirror-down|vlan-mirror "
9392 			"<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
9393 		.tokens = {
9394 			(void *)&cmd_mirror_mask_set,
9395 			(void *)&cmd_mirror_mask_port,
9396 			(void *)&cmd_mirror_mask_portid,
9397 			(void *)&cmd_mirror_mask_mirror,
9398 			(void *)&cmd_mirror_mask_ruleid,
9399 			(void *)&cmd_mirror_mask_what,
9400 			(void *)&cmd_mirror_mask_value,
9401 			(void *)&cmd_mirror_mask_dstpool,
9402 			(void *)&cmd_mirror_mask_poolid,
9403 			(void *)&cmd_mirror_mask_on,
9404 			NULL,
9405 		},
9406 };
9407 
9408 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
9409 struct cmd_set_mirror_link_result {
9410 	cmdline_fixed_string_t set;
9411 	cmdline_fixed_string_t port;
9412 	portid_t port_id;
9413 	cmdline_fixed_string_t mirror;
9414 	uint8_t rule_id;
9415 	cmdline_fixed_string_t what;
9416 	cmdline_fixed_string_t dstpool;
9417 	uint8_t dstpool_id;
9418 	cmdline_fixed_string_t on;
9419 };
9420 
9421 cmdline_parse_token_string_t cmd_mirror_link_set =
9422 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9423 				 set, "set");
9424 cmdline_parse_token_string_t cmd_mirror_link_port =
9425 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9426 				port, "port");
9427 cmdline_parse_token_num_t cmd_mirror_link_portid =
9428 	TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9429 				port_id, UINT16);
9430 cmdline_parse_token_string_t cmd_mirror_link_mirror =
9431 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9432 				mirror, "mirror-rule");
9433 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
9434 	TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9435 			    rule_id, UINT8);
9436 cmdline_parse_token_string_t cmd_mirror_link_what =
9437 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9438 				what, "uplink-mirror#downlink-mirror");
9439 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
9440 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9441 				dstpool, "dst-pool");
9442 cmdline_parse_token_num_t cmd_mirror_link_poolid =
9443 	TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9444 				dstpool_id, UINT8);
9445 cmdline_parse_token_string_t cmd_mirror_link_on =
9446 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9447 				on, "on#off");
9448 
9449 static void
9450 cmd_set_mirror_link_parsed(void *parsed_result,
9451 		       __attribute__((unused)) struct cmdline *cl,
9452 		       __attribute__((unused)) void *data)
9453 {
9454 	int ret;
9455 	struct cmd_set_mirror_link_result *res = parsed_result;
9456 	struct rte_eth_mirror_conf mr_conf;
9457 
9458 	memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9459 	if (!strcmp(res->what, "uplink-mirror"))
9460 		mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
9461 	else
9462 		mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
9463 
9464 	mr_conf.dst_pool = res->dstpool_id;
9465 
9466 	if (!strcmp(res->on, "on"))
9467 		ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9468 						res->rule_id, 1);
9469 	else
9470 		ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9471 						res->rule_id, 0);
9472 
9473 	/* check the return value and print it if is < 0 */
9474 	if (ret < 0)
9475 		printf("mirror rule add error: (%s)\n", strerror(-ret));
9476 
9477 }
9478 
9479 cmdline_parse_inst_t cmd_set_mirror_link = {
9480 		.f = cmd_set_mirror_link_parsed,
9481 		.data = NULL,
9482 		.help_str = "set port <port_id> mirror-rule <rule_id> "
9483 			"uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
9484 		.tokens = {
9485 			(void *)&cmd_mirror_link_set,
9486 			(void *)&cmd_mirror_link_port,
9487 			(void *)&cmd_mirror_link_portid,
9488 			(void *)&cmd_mirror_link_mirror,
9489 			(void *)&cmd_mirror_link_ruleid,
9490 			(void *)&cmd_mirror_link_what,
9491 			(void *)&cmd_mirror_link_dstpool,
9492 			(void *)&cmd_mirror_link_poolid,
9493 			(void *)&cmd_mirror_link_on,
9494 			NULL,
9495 		},
9496 };
9497 
9498 /* *** RESET VM MIRROR RULE *** */
9499 struct cmd_rm_mirror_rule_result {
9500 	cmdline_fixed_string_t reset;
9501 	cmdline_fixed_string_t port;
9502 	portid_t port_id;
9503 	cmdline_fixed_string_t mirror;
9504 	uint8_t rule_id;
9505 };
9506 
9507 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
9508 	TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9509 				 reset, "reset");
9510 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
9511 	TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9512 				port, "port");
9513 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
9514 	TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9515 				port_id, UINT16);
9516 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
9517 	TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9518 				mirror, "mirror-rule");
9519 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
9520 	TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9521 				rule_id, UINT8);
9522 
9523 static void
9524 cmd_reset_mirror_rule_parsed(void *parsed_result,
9525 		       __attribute__((unused)) struct cmdline *cl,
9526 		       __attribute__((unused)) void *data)
9527 {
9528 	int ret;
9529 	struct cmd_set_mirror_link_result *res = parsed_result;
9530         /* check rule_id */
9531 	ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
9532 	if(ret < 0)
9533 		printf("mirror rule remove error: (%s)\n", strerror(-ret));
9534 }
9535 
9536 cmdline_parse_inst_t cmd_reset_mirror_rule = {
9537 		.f = cmd_reset_mirror_rule_parsed,
9538 		.data = NULL,
9539 		.help_str = "reset port <port_id> mirror-rule <rule_id>",
9540 		.tokens = {
9541 			(void *)&cmd_rm_mirror_rule_reset,
9542 			(void *)&cmd_rm_mirror_rule_port,
9543 			(void *)&cmd_rm_mirror_rule_portid,
9544 			(void *)&cmd_rm_mirror_rule_mirror,
9545 			(void *)&cmd_rm_mirror_rule_ruleid,
9546 			NULL,
9547 		},
9548 };
9549 
9550 /* ******************************************************************************** */
9551 
9552 struct cmd_dump_result {
9553 	cmdline_fixed_string_t dump;
9554 };
9555 
9556 static void
9557 dump_struct_sizes(void)
9558 {
9559 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9560 	DUMP_SIZE(struct rte_mbuf);
9561 	DUMP_SIZE(struct rte_mempool);
9562 	DUMP_SIZE(struct rte_ring);
9563 #undef DUMP_SIZE
9564 }
9565 
9566 static void cmd_dump_parsed(void *parsed_result,
9567 			    __attribute__((unused)) struct cmdline *cl,
9568 			    __attribute__((unused)) void *data)
9569 {
9570 	struct cmd_dump_result *res = parsed_result;
9571 
9572 	if (!strcmp(res->dump, "dump_physmem"))
9573 		rte_dump_physmem_layout(stdout);
9574 	else if (!strcmp(res->dump, "dump_memzone"))
9575 		rte_memzone_dump(stdout);
9576 	else if (!strcmp(res->dump, "dump_struct_sizes"))
9577 		dump_struct_sizes();
9578 	else if (!strcmp(res->dump, "dump_ring"))
9579 		rte_ring_list_dump(stdout);
9580 	else if (!strcmp(res->dump, "dump_mempool"))
9581 		rte_mempool_list_dump(stdout);
9582 	else if (!strcmp(res->dump, "dump_devargs"))
9583 		rte_devargs_dump(stdout);
9584 	else if (!strcmp(res->dump, "dump_log_types"))
9585 		rte_log_dump(stdout);
9586 }
9587 
9588 cmdline_parse_token_string_t cmd_dump_dump =
9589 	TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9590 		"dump_physmem#"
9591 		"dump_memzone#"
9592 		"dump_struct_sizes#"
9593 		"dump_ring#"
9594 		"dump_mempool#"
9595 		"dump_devargs#"
9596 		"dump_log_types");
9597 
9598 cmdline_parse_inst_t cmd_dump = {
9599 	.f = cmd_dump_parsed,  /* function to call */
9600 	.data = NULL,      /* 2nd arg of func */
9601 	.help_str = "Dump status",
9602 	.tokens = {        /* token list, NULL terminated */
9603 		(void *)&cmd_dump_dump,
9604 		NULL,
9605 	},
9606 };
9607 
9608 /* ******************************************************************************** */
9609 
9610 struct cmd_dump_one_result {
9611 	cmdline_fixed_string_t dump;
9612 	cmdline_fixed_string_t name;
9613 };
9614 
9615 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9616 				__attribute__((unused)) void *data)
9617 {
9618 	struct cmd_dump_one_result *res = parsed_result;
9619 
9620 	if (!strcmp(res->dump, "dump_ring")) {
9621 		struct rte_ring *r;
9622 		r = rte_ring_lookup(res->name);
9623 		if (r == NULL) {
9624 			cmdline_printf(cl, "Cannot find ring\n");
9625 			return;
9626 		}
9627 		rte_ring_dump(stdout, r);
9628 	} else if (!strcmp(res->dump, "dump_mempool")) {
9629 		struct rte_mempool *mp;
9630 		mp = rte_mempool_lookup(res->name);
9631 		if (mp == NULL) {
9632 			cmdline_printf(cl, "Cannot find mempool\n");
9633 			return;
9634 		}
9635 		rte_mempool_dump(stdout, mp);
9636 	}
9637 }
9638 
9639 cmdline_parse_token_string_t cmd_dump_one_dump =
9640 	TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9641 				 "dump_ring#dump_mempool");
9642 
9643 cmdline_parse_token_string_t cmd_dump_one_name =
9644 	TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9645 
9646 cmdline_parse_inst_t cmd_dump_one = {
9647 	.f = cmd_dump_one_parsed,  /* function to call */
9648 	.data = NULL,      /* 2nd arg of func */
9649 	.help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9650 	.tokens = {        /* token list, NULL terminated */
9651 		(void *)&cmd_dump_one_dump,
9652 		(void *)&cmd_dump_one_name,
9653 		NULL,
9654 	},
9655 };
9656 
9657 /* *** Add/Del syn filter *** */
9658 struct cmd_syn_filter_result {
9659 	cmdline_fixed_string_t filter;
9660 	portid_t port_id;
9661 	cmdline_fixed_string_t ops;
9662 	cmdline_fixed_string_t priority;
9663 	cmdline_fixed_string_t high;
9664 	cmdline_fixed_string_t queue;
9665 	uint16_t queue_id;
9666 };
9667 
9668 static void
9669 cmd_syn_filter_parsed(void *parsed_result,
9670 			__attribute__((unused)) struct cmdline *cl,
9671 			__attribute__((unused)) void *data)
9672 {
9673 	struct cmd_syn_filter_result *res = parsed_result;
9674 	struct rte_eth_syn_filter syn_filter;
9675 	int ret = 0;
9676 
9677 	ret = rte_eth_dev_filter_supported(res->port_id,
9678 					RTE_ETH_FILTER_SYN);
9679 	if (ret < 0) {
9680 		printf("syn filter is not supported on port %u.\n",
9681 				res->port_id);
9682 		return;
9683 	}
9684 
9685 	memset(&syn_filter, 0, sizeof(syn_filter));
9686 
9687 	if (!strcmp(res->ops, "add")) {
9688 		if (!strcmp(res->high, "high"))
9689 			syn_filter.hig_pri = 1;
9690 		else
9691 			syn_filter.hig_pri = 0;
9692 
9693 		syn_filter.queue = res->queue_id;
9694 		ret = rte_eth_dev_filter_ctrl(res->port_id,
9695 						RTE_ETH_FILTER_SYN,
9696 						RTE_ETH_FILTER_ADD,
9697 						&syn_filter);
9698 	} else
9699 		ret = rte_eth_dev_filter_ctrl(res->port_id,
9700 						RTE_ETH_FILTER_SYN,
9701 						RTE_ETH_FILTER_DELETE,
9702 						&syn_filter);
9703 
9704 	if (ret < 0)
9705 		printf("syn filter programming error: (%s)\n",
9706 				strerror(-ret));
9707 }
9708 
9709 cmdline_parse_token_string_t cmd_syn_filter_filter =
9710 	TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9711 	filter, "syn_filter");
9712 cmdline_parse_token_num_t cmd_syn_filter_port_id =
9713 	TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9714 	port_id, UINT16);
9715 cmdline_parse_token_string_t cmd_syn_filter_ops =
9716 	TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9717 	ops, "add#del");
9718 cmdline_parse_token_string_t cmd_syn_filter_priority =
9719 	TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9720 				priority, "priority");
9721 cmdline_parse_token_string_t cmd_syn_filter_high =
9722 	TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9723 				high, "high#low");
9724 cmdline_parse_token_string_t cmd_syn_filter_queue =
9725 	TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9726 				queue, "queue");
9727 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
9728 	TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9729 				queue_id, UINT16);
9730 
9731 cmdline_parse_inst_t cmd_syn_filter = {
9732 	.f = cmd_syn_filter_parsed,
9733 	.data = NULL,
9734 	.help_str = "syn_filter <port_id> add|del priority high|low queue "
9735 		"<queue_id>: Add/Delete syn filter",
9736 	.tokens = {
9737 		(void *)&cmd_syn_filter_filter,
9738 		(void *)&cmd_syn_filter_port_id,
9739 		(void *)&cmd_syn_filter_ops,
9740 		(void *)&cmd_syn_filter_priority,
9741 		(void *)&cmd_syn_filter_high,
9742 		(void *)&cmd_syn_filter_queue,
9743 		(void *)&cmd_syn_filter_queue_id,
9744 		NULL,
9745 	},
9746 };
9747 
9748 /* *** queue region set *** */
9749 struct cmd_queue_region_result {
9750 	cmdline_fixed_string_t set;
9751 	cmdline_fixed_string_t port;
9752 	portid_t port_id;
9753 	cmdline_fixed_string_t cmd;
9754 	cmdline_fixed_string_t region;
9755 	uint8_t  region_id;
9756 	cmdline_fixed_string_t queue_start_index;
9757 	uint8_t  queue_id;
9758 	cmdline_fixed_string_t queue_num;
9759 	uint8_t  queue_num_value;
9760 };
9761 
9762 static void
9763 cmd_queue_region_parsed(void *parsed_result,
9764 			__attribute__((unused)) struct cmdline *cl,
9765 			__attribute__((unused)) void *data)
9766 {
9767 	struct cmd_queue_region_result *res = parsed_result;
9768 	int ret = -ENOTSUP;
9769 #ifdef RTE_LIBRTE_I40E_PMD
9770 	struct rte_pmd_i40e_queue_region_conf region_conf;
9771 	enum rte_pmd_i40e_queue_region_op op_type;
9772 #endif
9773 
9774 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9775 		return;
9776 
9777 #ifdef RTE_LIBRTE_I40E_PMD
9778 	memset(&region_conf, 0, sizeof(region_conf));
9779 	op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
9780 	region_conf.region_id = res->region_id;
9781 	region_conf.queue_num = res->queue_num_value;
9782 	region_conf.queue_start_index = res->queue_id;
9783 
9784 	ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9785 				op_type, &region_conf);
9786 #endif
9787 
9788 	switch (ret) {
9789 	case 0:
9790 		break;
9791 	case -ENOTSUP:
9792 		printf("function not implemented or supported\n");
9793 		break;
9794 	default:
9795 		printf("queue region config error: (%s)\n", strerror(-ret));
9796 	}
9797 }
9798 
9799 cmdline_parse_token_string_t cmd_queue_region_set =
9800 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9801 		set, "set");
9802 cmdline_parse_token_string_t cmd_queue_region_port =
9803 	TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
9804 cmdline_parse_token_num_t cmd_queue_region_port_id =
9805 	TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9806 				port_id, UINT16);
9807 cmdline_parse_token_string_t cmd_queue_region_cmd =
9808 	TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9809 				 cmd, "queue-region");
9810 cmdline_parse_token_string_t cmd_queue_region_id =
9811 	TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9812 				region, "region_id");
9813 cmdline_parse_token_num_t cmd_queue_region_index =
9814 	TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9815 				region_id, UINT8);
9816 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
9817 	TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9818 				queue_start_index, "queue_start_index");
9819 cmdline_parse_token_num_t cmd_queue_region_queue_id =
9820 	TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9821 				queue_id, UINT8);
9822 cmdline_parse_token_string_t cmd_queue_region_queue_num =
9823 	TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9824 				queue_num, "queue_num");
9825 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
9826 	TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9827 				queue_num_value, UINT8);
9828 
9829 cmdline_parse_inst_t cmd_queue_region = {
9830 	.f = cmd_queue_region_parsed,
9831 	.data = NULL,
9832 	.help_str = "set port <port_id> queue-region region_id <value> "
9833 		"queue_start_index <value> queue_num <value>: Set a queue region",
9834 	.tokens = {
9835 		(void *)&cmd_queue_region_set,
9836 		(void *)&cmd_queue_region_port,
9837 		(void *)&cmd_queue_region_port_id,
9838 		(void *)&cmd_queue_region_cmd,
9839 		(void *)&cmd_queue_region_id,
9840 		(void *)&cmd_queue_region_index,
9841 		(void *)&cmd_queue_region_queue_start_index,
9842 		(void *)&cmd_queue_region_queue_id,
9843 		(void *)&cmd_queue_region_queue_num,
9844 		(void *)&cmd_queue_region_queue_num_value,
9845 		NULL,
9846 	},
9847 };
9848 
9849 /* *** queue region and flowtype set *** */
9850 struct cmd_region_flowtype_result {
9851 	cmdline_fixed_string_t set;
9852 	cmdline_fixed_string_t port;
9853 	portid_t port_id;
9854 	cmdline_fixed_string_t cmd;
9855 	cmdline_fixed_string_t region;
9856 	uint8_t  region_id;
9857 	cmdline_fixed_string_t flowtype;
9858 	uint8_t  flowtype_id;
9859 };
9860 
9861 static void
9862 cmd_region_flowtype_parsed(void *parsed_result,
9863 			__attribute__((unused)) struct cmdline *cl,
9864 			__attribute__((unused)) void *data)
9865 {
9866 	struct cmd_region_flowtype_result *res = parsed_result;
9867 	int ret = -ENOTSUP;
9868 #ifdef RTE_LIBRTE_I40E_PMD
9869 	struct rte_pmd_i40e_queue_region_conf region_conf;
9870 	enum rte_pmd_i40e_queue_region_op op_type;
9871 #endif
9872 
9873 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9874 		return;
9875 
9876 #ifdef RTE_LIBRTE_I40E_PMD
9877 	memset(&region_conf, 0, sizeof(region_conf));
9878 
9879 	op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
9880 	region_conf.region_id = res->region_id;
9881 	region_conf.hw_flowtype = res->flowtype_id;
9882 
9883 	ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9884 			op_type, &region_conf);
9885 #endif
9886 
9887 	switch (ret) {
9888 	case 0:
9889 		break;
9890 	case -ENOTSUP:
9891 		printf("function not implemented or supported\n");
9892 		break;
9893 	default:
9894 		printf("region flowtype config error: (%s)\n", strerror(-ret));
9895 	}
9896 }
9897 
9898 cmdline_parse_token_string_t cmd_region_flowtype_set =
9899 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9900 				set, "set");
9901 cmdline_parse_token_string_t cmd_region_flowtype_port =
9902 	TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9903 				port, "port");
9904 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
9905 	TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9906 				port_id, UINT16);
9907 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
9908 	TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9909 				cmd, "queue-region");
9910 cmdline_parse_token_string_t cmd_region_flowtype_index =
9911 	TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9912 				region, "region_id");
9913 cmdline_parse_token_num_t cmd_region_flowtype_id =
9914 	TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9915 				region_id, UINT8);
9916 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
9917 	TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9918 				flowtype, "flowtype");
9919 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
9920 	TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9921 				flowtype_id, UINT8);
9922 cmdline_parse_inst_t cmd_region_flowtype = {
9923 	.f = cmd_region_flowtype_parsed,
9924 	.data = NULL,
9925 	.help_str = "set port <port_id> queue-region region_id <value> "
9926 		"flowtype <value>: Set a flowtype region index",
9927 	.tokens = {
9928 		(void *)&cmd_region_flowtype_set,
9929 		(void *)&cmd_region_flowtype_port,
9930 		(void *)&cmd_region_flowtype_port_index,
9931 		(void *)&cmd_region_flowtype_cmd,
9932 		(void *)&cmd_region_flowtype_index,
9933 		(void *)&cmd_region_flowtype_id,
9934 		(void *)&cmd_region_flowtype_flow_index,
9935 		(void *)&cmd_region_flowtype_flow_id,
9936 		NULL,
9937 	},
9938 };
9939 
9940 /* *** User Priority (UP) to queue region (region_id) set *** */
9941 struct cmd_user_priority_region_result {
9942 	cmdline_fixed_string_t set;
9943 	cmdline_fixed_string_t port;
9944 	portid_t port_id;
9945 	cmdline_fixed_string_t cmd;
9946 	cmdline_fixed_string_t user_priority;
9947 	uint8_t  user_priority_id;
9948 	cmdline_fixed_string_t region;
9949 	uint8_t  region_id;
9950 };
9951 
9952 static void
9953 cmd_user_priority_region_parsed(void *parsed_result,
9954 			__attribute__((unused)) struct cmdline *cl,
9955 			__attribute__((unused)) void *data)
9956 {
9957 	struct cmd_user_priority_region_result *res = parsed_result;
9958 	int ret = -ENOTSUP;
9959 #ifdef RTE_LIBRTE_I40E_PMD
9960 	struct rte_pmd_i40e_queue_region_conf region_conf;
9961 	enum rte_pmd_i40e_queue_region_op op_type;
9962 #endif
9963 
9964 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9965 		return;
9966 
9967 #ifdef RTE_LIBRTE_I40E_PMD
9968 	memset(&region_conf, 0, sizeof(region_conf));
9969 	op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
9970 	region_conf.user_priority = res->user_priority_id;
9971 	region_conf.region_id = res->region_id;
9972 
9973 	ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9974 				op_type, &region_conf);
9975 #endif
9976 
9977 	switch (ret) {
9978 	case 0:
9979 		break;
9980 	case -ENOTSUP:
9981 		printf("function not implemented or supported\n");
9982 		break;
9983 	default:
9984 		printf("user_priority region config error: (%s)\n",
9985 				strerror(-ret));
9986 	}
9987 }
9988 
9989 cmdline_parse_token_string_t cmd_user_priority_region_set =
9990 	TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9991 				set, "set");
9992 cmdline_parse_token_string_t cmd_user_priority_region_port =
9993 	TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9994 				port, "port");
9995 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
9996 	TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9997 				port_id, UINT16);
9998 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
9999 	TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10000 				cmd, "queue-region");
10001 cmdline_parse_token_string_t cmd_user_priority_region_UP =
10002 	TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10003 				user_priority, "UP");
10004 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
10005 	TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10006 				user_priority_id, UINT8);
10007 cmdline_parse_token_string_t cmd_user_priority_region_region =
10008 	TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10009 				region, "region_id");
10010 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
10011 	TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10012 				region_id, UINT8);
10013 
10014 cmdline_parse_inst_t cmd_user_priority_region = {
10015 	.f = cmd_user_priority_region_parsed,
10016 	.data = NULL,
10017 	.help_str = "set port <port_id> queue-region UP <value> "
10018 		"region_id <value>: Set the mapping of User Priority (UP) "
10019 		"to queue region (region_id) ",
10020 	.tokens = {
10021 		(void *)&cmd_user_priority_region_set,
10022 		(void *)&cmd_user_priority_region_port,
10023 		(void *)&cmd_user_priority_region_port_index,
10024 		(void *)&cmd_user_priority_region_cmd,
10025 		(void *)&cmd_user_priority_region_UP,
10026 		(void *)&cmd_user_priority_region_UP_id,
10027 		(void *)&cmd_user_priority_region_region,
10028 		(void *)&cmd_user_priority_region_region_id,
10029 		NULL,
10030 	},
10031 };
10032 
10033 /* *** flush all queue region related configuration *** */
10034 struct cmd_flush_queue_region_result {
10035 	cmdline_fixed_string_t set;
10036 	cmdline_fixed_string_t port;
10037 	portid_t port_id;
10038 	cmdline_fixed_string_t cmd;
10039 	cmdline_fixed_string_t flush;
10040 	cmdline_fixed_string_t what;
10041 };
10042 
10043 static void
10044 cmd_flush_queue_region_parsed(void *parsed_result,
10045 			__attribute__((unused)) struct cmdline *cl,
10046 			__attribute__((unused)) void *data)
10047 {
10048 	struct cmd_flush_queue_region_result *res = parsed_result;
10049 	int ret = -ENOTSUP;
10050 #ifdef RTE_LIBRTE_I40E_PMD
10051 	struct rte_pmd_i40e_queue_region_conf region_conf;
10052 	enum rte_pmd_i40e_queue_region_op op_type;
10053 #endif
10054 
10055 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10056 		return;
10057 
10058 #ifdef RTE_LIBRTE_I40E_PMD
10059 	memset(&region_conf, 0, sizeof(region_conf));
10060 
10061 	if (strcmp(res->what, "on") == 0)
10062 		op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
10063 	else
10064 		op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
10065 
10066 	ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10067 				op_type, &region_conf);
10068 #endif
10069 
10070 	switch (ret) {
10071 	case 0:
10072 		break;
10073 	case -ENOTSUP:
10074 		printf("function not implemented or supported\n");
10075 		break;
10076 	default:
10077 		printf("queue region config flush error: (%s)\n",
10078 				strerror(-ret));
10079 	}
10080 }
10081 
10082 cmdline_parse_token_string_t cmd_flush_queue_region_set =
10083 	TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10084 				set, "set");
10085 cmdline_parse_token_string_t cmd_flush_queue_region_port =
10086 	TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10087 				port, "port");
10088 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
10089 	TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
10090 				port_id, UINT16);
10091 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
10092 	TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10093 				cmd, "queue-region");
10094 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
10095 	TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10096 				flush, "flush");
10097 cmdline_parse_token_string_t cmd_flush_queue_region_what =
10098 	TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10099 				what, "on#off");
10100 
10101 cmdline_parse_inst_t cmd_flush_queue_region = {
10102 	.f = cmd_flush_queue_region_parsed,
10103 	.data = NULL,
10104 	.help_str = "set port <port_id> queue-region flush on|off"
10105 		": flush all queue region related configuration",
10106 	.tokens = {
10107 		(void *)&cmd_flush_queue_region_set,
10108 		(void *)&cmd_flush_queue_region_port,
10109 		(void *)&cmd_flush_queue_region_port_index,
10110 		(void *)&cmd_flush_queue_region_cmd,
10111 		(void *)&cmd_flush_queue_region_flush,
10112 		(void *)&cmd_flush_queue_region_what,
10113 		NULL,
10114 	},
10115 };
10116 
10117 /* *** get all queue region related configuration info *** */
10118 struct cmd_show_queue_region_info {
10119 	cmdline_fixed_string_t show;
10120 	cmdline_fixed_string_t port;
10121 	portid_t port_id;
10122 	cmdline_fixed_string_t cmd;
10123 };
10124 
10125 static void
10126 cmd_show_queue_region_info_parsed(void *parsed_result,
10127 			__attribute__((unused)) struct cmdline *cl,
10128 			__attribute__((unused)) void *data)
10129 {
10130 	struct cmd_show_queue_region_info *res = parsed_result;
10131 	int ret = -ENOTSUP;
10132 #ifdef RTE_LIBRTE_I40E_PMD
10133 	struct rte_pmd_i40e_queue_regions rte_pmd_regions;
10134 	enum rte_pmd_i40e_queue_region_op op_type;
10135 #endif
10136 
10137 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10138 		return;
10139 
10140 #ifdef RTE_LIBRTE_I40E_PMD
10141 	memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
10142 
10143 	op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
10144 
10145 	ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10146 					op_type, &rte_pmd_regions);
10147 
10148 	port_queue_region_info_display(res->port_id, &rte_pmd_regions);
10149 #endif
10150 
10151 	switch (ret) {
10152 	case 0:
10153 		break;
10154 	case -ENOTSUP:
10155 		printf("function not implemented or supported\n");
10156 		break;
10157 	default:
10158 		printf("queue region config info show error: (%s)\n",
10159 				strerror(-ret));
10160 	}
10161 }
10162 
10163 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
10164 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10165 				show, "show");
10166 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
10167 	TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10168 				port, "port");
10169 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
10170 	TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
10171 				port_id, UINT16);
10172 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
10173 	TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10174 				cmd, "queue-region");
10175 
10176 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
10177 	.f = cmd_show_queue_region_info_parsed,
10178 	.data = NULL,
10179 	.help_str = "show port <port_id> queue-region"
10180 		": show all queue region related configuration info",
10181 	.tokens = {
10182 		(void *)&cmd_show_queue_region_info_get,
10183 		(void *)&cmd_show_queue_region_info_port,
10184 		(void *)&cmd_show_queue_region_info_port_index,
10185 		(void *)&cmd_show_queue_region_info_cmd,
10186 		NULL,
10187 	},
10188 };
10189 
10190 /* *** ADD/REMOVE A 2tuple FILTER *** */
10191 struct cmd_2tuple_filter_result {
10192 	cmdline_fixed_string_t filter;
10193 	portid_t port_id;
10194 	cmdline_fixed_string_t ops;
10195 	cmdline_fixed_string_t dst_port;
10196 	uint16_t dst_port_value;
10197 	cmdline_fixed_string_t protocol;
10198 	uint8_t protocol_value;
10199 	cmdline_fixed_string_t mask;
10200 	uint8_t  mask_value;
10201 	cmdline_fixed_string_t tcp_flags;
10202 	uint8_t tcp_flags_value;
10203 	cmdline_fixed_string_t priority;
10204 	uint8_t  priority_value;
10205 	cmdline_fixed_string_t queue;
10206 	uint16_t  queue_id;
10207 };
10208 
10209 static void
10210 cmd_2tuple_filter_parsed(void *parsed_result,
10211 			__attribute__((unused)) struct cmdline *cl,
10212 			__attribute__((unused)) void *data)
10213 {
10214 	struct rte_eth_ntuple_filter filter;
10215 	struct cmd_2tuple_filter_result *res = parsed_result;
10216 	int ret = 0;
10217 
10218 	ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
10219 	if (ret < 0) {
10220 		printf("ntuple filter is not supported on port %u.\n",
10221 			res->port_id);
10222 		return;
10223 	}
10224 
10225 	memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
10226 
10227 	filter.flags = RTE_2TUPLE_FLAGS;
10228 	filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
10229 	filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
10230 	filter.proto = res->protocol_value;
10231 	filter.priority = res->priority_value;
10232 	if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
10233 		printf("nonzero tcp_flags is only meaningful"
10234 			" when protocol is TCP.\n");
10235 		return;
10236 	}
10237 	if (res->tcp_flags_value > RTE_NTUPLE_TCP_FLAGS_MASK) {
10238 		printf("invalid TCP flags.\n");
10239 		return;
10240 	}
10241 
10242 	if (res->tcp_flags_value != 0) {
10243 		filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
10244 		filter.tcp_flags = res->tcp_flags_value;
10245 	}
10246 
10247 	/* need convert to big endian. */
10248 	filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
10249 	filter.queue = res->queue_id;
10250 
10251 	if (!strcmp(res->ops, "add"))
10252 		ret = rte_eth_dev_filter_ctrl(res->port_id,
10253 				RTE_ETH_FILTER_NTUPLE,
10254 				RTE_ETH_FILTER_ADD,
10255 				&filter);
10256 	else
10257 		ret = rte_eth_dev_filter_ctrl(res->port_id,
10258 				RTE_ETH_FILTER_NTUPLE,
10259 				RTE_ETH_FILTER_DELETE,
10260 				&filter);
10261 	if (ret < 0)
10262 		printf("2tuple filter programming error: (%s)\n",
10263 			strerror(-ret));
10264 
10265 }
10266 
10267 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
10268 	TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10269 				 filter, "2tuple_filter");
10270 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
10271 	TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10272 				port_id, UINT16);
10273 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
10274 	TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10275 				 ops, "add#del");
10276 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
10277 	TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10278 				dst_port, "dst_port");
10279 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
10280 	TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10281 				dst_port_value, UINT16);
10282 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
10283 	TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10284 				protocol, "protocol");
10285 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
10286 	TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10287 				protocol_value, UINT8);
10288 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
10289 	TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10290 				mask, "mask");
10291 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
10292 	TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10293 				mask_value, INT8);
10294 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
10295 	TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10296 				tcp_flags, "tcp_flags");
10297 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
10298 	TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10299 				tcp_flags_value, UINT8);
10300 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
10301 	TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10302 				priority, "priority");
10303 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
10304 	TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10305 				priority_value, UINT8);
10306 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
10307 	TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10308 				queue, "queue");
10309 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
10310 	TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10311 				queue_id, UINT16);
10312 
10313 cmdline_parse_inst_t cmd_2tuple_filter = {
10314 	.f = cmd_2tuple_filter_parsed,
10315 	.data = NULL,
10316 	.help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
10317 		"<value> mask <value> tcp_flags <value> priority <value> queue "
10318 		"<queue_id>: Add a 2tuple filter",
10319 	.tokens = {
10320 		(void *)&cmd_2tuple_filter_filter,
10321 		(void *)&cmd_2tuple_filter_port_id,
10322 		(void *)&cmd_2tuple_filter_ops,
10323 		(void *)&cmd_2tuple_filter_dst_port,
10324 		(void *)&cmd_2tuple_filter_dst_port_value,
10325 		(void *)&cmd_2tuple_filter_protocol,
10326 		(void *)&cmd_2tuple_filter_protocol_value,
10327 		(void *)&cmd_2tuple_filter_mask,
10328 		(void *)&cmd_2tuple_filter_mask_value,
10329 		(void *)&cmd_2tuple_filter_tcp_flags,
10330 		(void *)&cmd_2tuple_filter_tcp_flags_value,
10331 		(void *)&cmd_2tuple_filter_priority,
10332 		(void *)&cmd_2tuple_filter_priority_value,
10333 		(void *)&cmd_2tuple_filter_queue,
10334 		(void *)&cmd_2tuple_filter_queue_id,
10335 		NULL,
10336 	},
10337 };
10338 
10339 /* *** ADD/REMOVE A 5tuple FILTER *** */
10340 struct cmd_5tuple_filter_result {
10341 	cmdline_fixed_string_t filter;
10342 	portid_t port_id;
10343 	cmdline_fixed_string_t ops;
10344 	cmdline_fixed_string_t dst_ip;
10345 	cmdline_ipaddr_t dst_ip_value;
10346 	cmdline_fixed_string_t src_ip;
10347 	cmdline_ipaddr_t src_ip_value;
10348 	cmdline_fixed_string_t dst_port;
10349 	uint16_t dst_port_value;
10350 	cmdline_fixed_string_t src_port;
10351 	uint16_t src_port_value;
10352 	cmdline_fixed_string_t protocol;
10353 	uint8_t protocol_value;
10354 	cmdline_fixed_string_t mask;
10355 	uint8_t  mask_value;
10356 	cmdline_fixed_string_t tcp_flags;
10357 	uint8_t tcp_flags_value;
10358 	cmdline_fixed_string_t priority;
10359 	uint8_t  priority_value;
10360 	cmdline_fixed_string_t queue;
10361 	uint16_t  queue_id;
10362 };
10363 
10364 static void
10365 cmd_5tuple_filter_parsed(void *parsed_result,
10366 			__attribute__((unused)) struct cmdline *cl,
10367 			__attribute__((unused)) void *data)
10368 {
10369 	struct rte_eth_ntuple_filter filter;
10370 	struct cmd_5tuple_filter_result *res = parsed_result;
10371 	int ret = 0;
10372 
10373 	ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
10374 	if (ret < 0) {
10375 		printf("ntuple filter is not supported on port %u.\n",
10376 			res->port_id);
10377 		return;
10378 	}
10379 
10380 	memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
10381 
10382 	filter.flags = RTE_5TUPLE_FLAGS;
10383 	filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
10384 	filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
10385 	filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
10386 	filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
10387 	filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
10388 	filter.proto = res->protocol_value;
10389 	filter.priority = res->priority_value;
10390 	if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
10391 		printf("nonzero tcp_flags is only meaningful"
10392 			" when protocol is TCP.\n");
10393 		return;
10394 	}
10395 	if (res->tcp_flags_value > RTE_NTUPLE_TCP_FLAGS_MASK) {
10396 		printf("invalid TCP flags.\n");
10397 		return;
10398 	}
10399 
10400 	if (res->tcp_flags_value != 0) {
10401 		filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
10402 		filter.tcp_flags = res->tcp_flags_value;
10403 	}
10404 
10405 	if (res->dst_ip_value.family == AF_INET)
10406 		/* no need to convert, already big endian. */
10407 		filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
10408 	else {
10409 		if (filter.dst_ip_mask == 0) {
10410 			printf("can not support ipv6 involved compare.\n");
10411 			return;
10412 		}
10413 		filter.dst_ip = 0;
10414 	}
10415 
10416 	if (res->src_ip_value.family == AF_INET)
10417 		/* no need to convert, already big endian. */
10418 		filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
10419 	else {
10420 		if (filter.src_ip_mask == 0) {
10421 			printf("can not support ipv6 involved compare.\n");
10422 			return;
10423 		}
10424 		filter.src_ip = 0;
10425 	}
10426 	/* need convert to big endian. */
10427 	filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
10428 	filter.src_port = rte_cpu_to_be_16(res->src_port_value);
10429 	filter.queue = res->queue_id;
10430 
10431 	if (!strcmp(res->ops, "add"))
10432 		ret = rte_eth_dev_filter_ctrl(res->port_id,
10433 				RTE_ETH_FILTER_NTUPLE,
10434 				RTE_ETH_FILTER_ADD,
10435 				&filter);
10436 	else
10437 		ret = rte_eth_dev_filter_ctrl(res->port_id,
10438 				RTE_ETH_FILTER_NTUPLE,
10439 				RTE_ETH_FILTER_DELETE,
10440 				&filter);
10441 	if (ret < 0)
10442 		printf("5tuple filter programming error: (%s)\n",
10443 			strerror(-ret));
10444 }
10445 
10446 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
10447 	TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10448 				 filter, "5tuple_filter");
10449 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
10450 	TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10451 				port_id, UINT16);
10452 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
10453 	TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10454 				 ops, "add#del");
10455 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
10456 	TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10457 				dst_ip, "dst_ip");
10458 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
10459 	TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10460 				dst_ip_value);
10461 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
10462 	TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10463 				src_ip, "src_ip");
10464 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
10465 	TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10466 				src_ip_value);
10467 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
10468 	TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10469 				dst_port, "dst_port");
10470 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
10471 	TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10472 				dst_port_value, UINT16);
10473 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
10474 	TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10475 				src_port, "src_port");
10476 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
10477 	TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10478 				src_port_value, UINT16);
10479 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
10480 	TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10481 				protocol, "protocol");
10482 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
10483 	TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10484 				protocol_value, UINT8);
10485 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
10486 	TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10487 				mask, "mask");
10488 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
10489 	TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10490 				mask_value, INT8);
10491 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
10492 	TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10493 				tcp_flags, "tcp_flags");
10494 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
10495 	TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10496 				tcp_flags_value, UINT8);
10497 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
10498 	TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10499 				priority, "priority");
10500 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
10501 	TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10502 				priority_value, UINT8);
10503 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
10504 	TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10505 				queue, "queue");
10506 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
10507 	TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10508 				queue_id, UINT16);
10509 
10510 cmdline_parse_inst_t cmd_5tuple_filter = {
10511 	.f = cmd_5tuple_filter_parsed,
10512 	.data = NULL,
10513 	.help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
10514 		"src_ip <value> dst_port <value> src_port <value> "
10515 		"protocol <value>  mask <value> tcp_flags <value> "
10516 		"priority <value> queue <queue_id>: Add/Del a 5tuple filter",
10517 	.tokens = {
10518 		(void *)&cmd_5tuple_filter_filter,
10519 		(void *)&cmd_5tuple_filter_port_id,
10520 		(void *)&cmd_5tuple_filter_ops,
10521 		(void *)&cmd_5tuple_filter_dst_ip,
10522 		(void *)&cmd_5tuple_filter_dst_ip_value,
10523 		(void *)&cmd_5tuple_filter_src_ip,
10524 		(void *)&cmd_5tuple_filter_src_ip_value,
10525 		(void *)&cmd_5tuple_filter_dst_port,
10526 		(void *)&cmd_5tuple_filter_dst_port_value,
10527 		(void *)&cmd_5tuple_filter_src_port,
10528 		(void *)&cmd_5tuple_filter_src_port_value,
10529 		(void *)&cmd_5tuple_filter_protocol,
10530 		(void *)&cmd_5tuple_filter_protocol_value,
10531 		(void *)&cmd_5tuple_filter_mask,
10532 		(void *)&cmd_5tuple_filter_mask_value,
10533 		(void *)&cmd_5tuple_filter_tcp_flags,
10534 		(void *)&cmd_5tuple_filter_tcp_flags_value,
10535 		(void *)&cmd_5tuple_filter_priority,
10536 		(void *)&cmd_5tuple_filter_priority_value,
10537 		(void *)&cmd_5tuple_filter_queue,
10538 		(void *)&cmd_5tuple_filter_queue_id,
10539 		NULL,
10540 	},
10541 };
10542 
10543 /* *** ADD/REMOVE A flex FILTER *** */
10544 struct cmd_flex_filter_result {
10545 	cmdline_fixed_string_t filter;
10546 	cmdline_fixed_string_t ops;
10547 	portid_t port_id;
10548 	cmdline_fixed_string_t len;
10549 	uint8_t len_value;
10550 	cmdline_fixed_string_t bytes;
10551 	cmdline_fixed_string_t bytes_value;
10552 	cmdline_fixed_string_t mask;
10553 	cmdline_fixed_string_t mask_value;
10554 	cmdline_fixed_string_t priority;
10555 	uint8_t priority_value;
10556 	cmdline_fixed_string_t queue;
10557 	uint16_t queue_id;
10558 };
10559 
10560 static int xdigit2val(unsigned char c)
10561 {
10562 	int val;
10563 	if (isdigit(c))
10564 		val = c - '0';
10565 	else if (isupper(c))
10566 		val = c - 'A' + 10;
10567 	else
10568 		val = c - 'a' + 10;
10569 	return val;
10570 }
10571 
10572 static void
10573 cmd_flex_filter_parsed(void *parsed_result,
10574 			  __attribute__((unused)) struct cmdline *cl,
10575 			  __attribute__((unused)) void *data)
10576 {
10577 	int ret = 0;
10578 	struct rte_eth_flex_filter filter;
10579 	struct cmd_flex_filter_result *res = parsed_result;
10580 	char *bytes_ptr, *mask_ptr;
10581 	uint16_t len, i, j = 0;
10582 	char c;
10583 	int val;
10584 	uint8_t byte = 0;
10585 
10586 	if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
10587 		printf("the len exceed the max length 128\n");
10588 		return;
10589 	}
10590 	memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
10591 	filter.len = res->len_value;
10592 	filter.priority = res->priority_value;
10593 	filter.queue = res->queue_id;
10594 	bytes_ptr = res->bytes_value;
10595 	mask_ptr = res->mask_value;
10596 
10597 	 /* translate bytes string to array. */
10598 	if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
10599 		(bytes_ptr[1] == 'X')))
10600 		bytes_ptr += 2;
10601 	len = strnlen(bytes_ptr, res->len_value * 2);
10602 	if (len == 0 || (len % 8 != 0)) {
10603 		printf("please check len and bytes input\n");
10604 		return;
10605 	}
10606 	for (i = 0; i < len; i++) {
10607 		c = bytes_ptr[i];
10608 		if (isxdigit(c) == 0) {
10609 			/* invalid characters. */
10610 			printf("invalid input\n");
10611 			return;
10612 		}
10613 		val = xdigit2val(c);
10614 		if (i % 2) {
10615 			byte |= val;
10616 			filter.bytes[j] = byte;
10617 			printf("bytes[%d]:%02x ", j, filter.bytes[j]);
10618 			j++;
10619 			byte = 0;
10620 		} else
10621 			byte |= val << 4;
10622 	}
10623 	printf("\n");
10624 	 /* translate mask string to uint8_t array. */
10625 	if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
10626 		(mask_ptr[1] == 'X')))
10627 		mask_ptr += 2;
10628 	len = strnlen(mask_ptr, (res->len_value + 3) / 4);
10629 	if (len == 0) {
10630 		printf("invalid input\n");
10631 		return;
10632 	}
10633 	j = 0;
10634 	byte = 0;
10635 	for (i = 0; i < len; i++) {
10636 		c = mask_ptr[i];
10637 		if (isxdigit(c) == 0) {
10638 			/* invalid characters. */
10639 			printf("invalid input\n");
10640 			return;
10641 		}
10642 		val = xdigit2val(c);
10643 		if (i % 2) {
10644 			byte |= val;
10645 			filter.mask[j] = byte;
10646 			printf("mask[%d]:%02x ", j, filter.mask[j]);
10647 			j++;
10648 			byte = 0;
10649 		} else
10650 			byte |= val << 4;
10651 	}
10652 	printf("\n");
10653 
10654 	if (!strcmp(res->ops, "add"))
10655 		ret = rte_eth_dev_filter_ctrl(res->port_id,
10656 				RTE_ETH_FILTER_FLEXIBLE,
10657 				RTE_ETH_FILTER_ADD,
10658 				&filter);
10659 	else
10660 		ret = rte_eth_dev_filter_ctrl(res->port_id,
10661 				RTE_ETH_FILTER_FLEXIBLE,
10662 				RTE_ETH_FILTER_DELETE,
10663 				&filter);
10664 
10665 	if (ret < 0)
10666 		printf("flex filter setting error: (%s)\n", strerror(-ret));
10667 }
10668 
10669 cmdline_parse_token_string_t cmd_flex_filter_filter =
10670 	TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10671 				filter, "flex_filter");
10672 cmdline_parse_token_num_t cmd_flex_filter_port_id =
10673 	TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10674 				port_id, UINT16);
10675 cmdline_parse_token_string_t cmd_flex_filter_ops =
10676 	TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10677 				ops, "add#del");
10678 cmdline_parse_token_string_t cmd_flex_filter_len =
10679 	TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10680 				len, "len");
10681 cmdline_parse_token_num_t cmd_flex_filter_len_value =
10682 	TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10683 				len_value, UINT8);
10684 cmdline_parse_token_string_t cmd_flex_filter_bytes =
10685 	TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10686 				bytes, "bytes");
10687 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
10688 	TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10689 				bytes_value, NULL);
10690 cmdline_parse_token_string_t cmd_flex_filter_mask =
10691 	TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10692 				mask, "mask");
10693 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
10694 	TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10695 				mask_value, NULL);
10696 cmdline_parse_token_string_t cmd_flex_filter_priority =
10697 	TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10698 				priority, "priority");
10699 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
10700 	TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10701 				priority_value, UINT8);
10702 cmdline_parse_token_string_t cmd_flex_filter_queue =
10703 	TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10704 				queue, "queue");
10705 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
10706 	TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10707 				queue_id, UINT16);
10708 cmdline_parse_inst_t cmd_flex_filter = {
10709 	.f = cmd_flex_filter_parsed,
10710 	.data = NULL,
10711 	.help_str = "flex_filter <port_id> add|del len <value> bytes "
10712 		"<value> mask <value> priority <value> queue <queue_id>: "
10713 		"Add/Del a flex filter",
10714 	.tokens = {
10715 		(void *)&cmd_flex_filter_filter,
10716 		(void *)&cmd_flex_filter_port_id,
10717 		(void *)&cmd_flex_filter_ops,
10718 		(void *)&cmd_flex_filter_len,
10719 		(void *)&cmd_flex_filter_len_value,
10720 		(void *)&cmd_flex_filter_bytes,
10721 		(void *)&cmd_flex_filter_bytes_value,
10722 		(void *)&cmd_flex_filter_mask,
10723 		(void *)&cmd_flex_filter_mask_value,
10724 		(void *)&cmd_flex_filter_priority,
10725 		(void *)&cmd_flex_filter_priority_value,
10726 		(void *)&cmd_flex_filter_queue,
10727 		(void *)&cmd_flex_filter_queue_id,
10728 		NULL,
10729 	},
10730 };
10731 
10732 /* *** Filters Control *** */
10733 
10734 /* *** deal with ethertype filter *** */
10735 struct cmd_ethertype_filter_result {
10736 	cmdline_fixed_string_t filter;
10737 	portid_t port_id;
10738 	cmdline_fixed_string_t ops;
10739 	cmdline_fixed_string_t mac;
10740 	struct rte_ether_addr mac_addr;
10741 	cmdline_fixed_string_t ethertype;
10742 	uint16_t ethertype_value;
10743 	cmdline_fixed_string_t drop;
10744 	cmdline_fixed_string_t queue;
10745 	uint16_t  queue_id;
10746 };
10747 
10748 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
10749 	TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10750 				 filter, "ethertype_filter");
10751 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
10752 	TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10753 			      port_id, UINT16);
10754 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
10755 	TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10756 				 ops, "add#del");
10757 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
10758 	TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10759 				 mac, "mac_addr#mac_ignr");
10760 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
10761 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
10762 				     mac_addr);
10763 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
10764 	TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10765 				 ethertype, "ethertype");
10766 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
10767 	TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10768 			      ethertype_value, UINT16);
10769 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
10770 	TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10771 				 drop, "drop#fwd");
10772 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
10773 	TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10774 				 queue, "queue");
10775 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
10776 	TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10777 			      queue_id, UINT16);
10778 
10779 static void
10780 cmd_ethertype_filter_parsed(void *parsed_result,
10781 			  __attribute__((unused)) struct cmdline *cl,
10782 			  __attribute__((unused)) void *data)
10783 {
10784 	struct cmd_ethertype_filter_result *res = parsed_result;
10785 	struct rte_eth_ethertype_filter filter;
10786 	int ret = 0;
10787 
10788 	ret = rte_eth_dev_filter_supported(res->port_id,
10789 			RTE_ETH_FILTER_ETHERTYPE);
10790 	if (ret < 0) {
10791 		printf("ethertype filter is not supported on port %u.\n",
10792 			res->port_id);
10793 		return;
10794 	}
10795 
10796 	memset(&filter, 0, sizeof(filter));
10797 	if (!strcmp(res->mac, "mac_addr")) {
10798 		filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
10799 		rte_memcpy(&filter.mac_addr, &res->mac_addr,
10800 			sizeof(struct rte_ether_addr));
10801 	}
10802 	if (!strcmp(res->drop, "drop"))
10803 		filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
10804 	filter.ether_type = res->ethertype_value;
10805 	filter.queue = res->queue_id;
10806 
10807 	if (!strcmp(res->ops, "add"))
10808 		ret = rte_eth_dev_filter_ctrl(res->port_id,
10809 				RTE_ETH_FILTER_ETHERTYPE,
10810 				RTE_ETH_FILTER_ADD,
10811 				&filter);
10812 	else
10813 		ret = rte_eth_dev_filter_ctrl(res->port_id,
10814 				RTE_ETH_FILTER_ETHERTYPE,
10815 				RTE_ETH_FILTER_DELETE,
10816 				&filter);
10817 	if (ret < 0)
10818 		printf("ethertype filter programming error: (%s)\n",
10819 			strerror(-ret));
10820 }
10821 
10822 cmdline_parse_inst_t cmd_ethertype_filter = {
10823 	.f = cmd_ethertype_filter_parsed,
10824 	.data = NULL,
10825 	.help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
10826 		"<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
10827 		"Add or delete an ethertype filter entry",
10828 	.tokens = {
10829 		(void *)&cmd_ethertype_filter_filter,
10830 		(void *)&cmd_ethertype_filter_port_id,
10831 		(void *)&cmd_ethertype_filter_ops,
10832 		(void *)&cmd_ethertype_filter_mac,
10833 		(void *)&cmd_ethertype_filter_mac_addr,
10834 		(void *)&cmd_ethertype_filter_ethertype,
10835 		(void *)&cmd_ethertype_filter_ethertype_value,
10836 		(void *)&cmd_ethertype_filter_drop,
10837 		(void *)&cmd_ethertype_filter_queue,
10838 		(void *)&cmd_ethertype_filter_queue_id,
10839 		NULL,
10840 	},
10841 };
10842 
10843 /* *** deal with flow director filter *** */
10844 struct cmd_flow_director_result {
10845 	cmdline_fixed_string_t flow_director_filter;
10846 	portid_t port_id;
10847 	cmdline_fixed_string_t mode;
10848 	cmdline_fixed_string_t mode_value;
10849 	cmdline_fixed_string_t ops;
10850 	cmdline_fixed_string_t flow;
10851 	cmdline_fixed_string_t flow_type;
10852 	cmdline_fixed_string_t ether;
10853 	uint16_t ether_type;
10854 	cmdline_fixed_string_t src;
10855 	cmdline_ipaddr_t ip_src;
10856 	uint16_t port_src;
10857 	cmdline_fixed_string_t dst;
10858 	cmdline_ipaddr_t ip_dst;
10859 	uint16_t port_dst;
10860 	cmdline_fixed_string_t verify_tag;
10861 	uint32_t verify_tag_value;
10862 	cmdline_fixed_string_t tos;
10863 	uint8_t tos_value;
10864 	cmdline_fixed_string_t proto;
10865 	uint8_t proto_value;
10866 	cmdline_fixed_string_t ttl;
10867 	uint8_t ttl_value;
10868 	cmdline_fixed_string_t vlan;
10869 	uint16_t vlan_value;
10870 	cmdline_fixed_string_t flexbytes;
10871 	cmdline_fixed_string_t flexbytes_value;
10872 	cmdline_fixed_string_t pf_vf;
10873 	cmdline_fixed_string_t drop;
10874 	cmdline_fixed_string_t queue;
10875 	uint16_t  queue_id;
10876 	cmdline_fixed_string_t fd_id;
10877 	uint32_t  fd_id_value;
10878 	cmdline_fixed_string_t mac;
10879 	struct rte_ether_addr mac_addr;
10880 	cmdline_fixed_string_t tunnel;
10881 	cmdline_fixed_string_t tunnel_type;
10882 	cmdline_fixed_string_t tunnel_id;
10883 	uint32_t tunnel_id_value;
10884 	cmdline_fixed_string_t packet;
10885 	char filepath[];
10886 };
10887 
10888 static inline int
10889 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
10890 {
10891 	char s[256];
10892 	const char *p, *p0 = q_arg;
10893 	char *end;
10894 	unsigned long int_fld;
10895 	char *str_fld[max_num];
10896 	int i;
10897 	unsigned size;
10898 	int ret = -1;
10899 
10900 	p = strchr(p0, '(');
10901 	if (p == NULL)
10902 		return -1;
10903 	++p;
10904 	p0 = strchr(p, ')');
10905 	if (p0 == NULL)
10906 		return -1;
10907 
10908 	size = p0 - p;
10909 	if (size >= sizeof(s))
10910 		return -1;
10911 
10912 	snprintf(s, sizeof(s), "%.*s", size, p);
10913 	ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10914 	if (ret < 0 || ret > max_num)
10915 		return -1;
10916 	for (i = 0; i < ret; i++) {
10917 		errno = 0;
10918 		int_fld = strtoul(str_fld[i], &end, 0);
10919 		if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
10920 			return -1;
10921 		flexbytes[i] = (uint8_t)int_fld;
10922 	}
10923 	return ret;
10924 }
10925 
10926 static uint16_t
10927 str2flowtype(char *string)
10928 {
10929 	uint8_t i = 0;
10930 	static const struct {
10931 		char str[32];
10932 		uint16_t type;
10933 	} flowtype_str[] = {
10934 		{"raw", RTE_ETH_FLOW_RAW},
10935 		{"ipv4", RTE_ETH_FLOW_IPV4},
10936 		{"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10937 		{"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10938 		{"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10939 		{"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10940 		{"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10941 		{"ipv6", RTE_ETH_FLOW_IPV6},
10942 		{"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10943 		{"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10944 		{"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10945 		{"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10946 		{"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10947 		{"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10948 	};
10949 
10950 	for (i = 0; i < RTE_DIM(flowtype_str); i++) {
10951 		if (!strcmp(flowtype_str[i].str, string))
10952 			return flowtype_str[i].type;
10953 	}
10954 
10955 	if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
10956 		return (uint16_t)atoi(string);
10957 
10958 	return RTE_ETH_FLOW_UNKNOWN;
10959 }
10960 
10961 static enum rte_eth_fdir_tunnel_type
10962 str2fdir_tunneltype(char *string)
10963 {
10964 	uint8_t i = 0;
10965 
10966 	static const struct {
10967 		char str[32];
10968 		enum rte_eth_fdir_tunnel_type type;
10969 	} tunneltype_str[] = {
10970 		{"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
10971 		{"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
10972 	};
10973 
10974 	for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
10975 		if (!strcmp(tunneltype_str[i].str, string))
10976 			return tunneltype_str[i].type;
10977 	}
10978 	return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
10979 }
10980 
10981 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10982 do { \
10983 	if ((ip_addr).family == AF_INET) \
10984 		(ip) = (ip_addr).addr.ipv4.s_addr; \
10985 	else { \
10986 		printf("invalid parameter.\n"); \
10987 		return; \
10988 	} \
10989 } while (0)
10990 
10991 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10992 do { \
10993 	if ((ip_addr).family == AF_INET6) \
10994 		rte_memcpy(&(ip), \
10995 				 &((ip_addr).addr.ipv6), \
10996 				 sizeof(struct in6_addr)); \
10997 	else { \
10998 		printf("invalid parameter.\n"); \
10999 		return; \
11000 	} \
11001 } while (0)
11002 
11003 static void
11004 cmd_flow_director_filter_parsed(void *parsed_result,
11005 			  __attribute__((unused)) struct cmdline *cl,
11006 			  __attribute__((unused)) void *data)
11007 {
11008 	struct cmd_flow_director_result *res = parsed_result;
11009 	struct rte_eth_fdir_filter entry;
11010 	uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
11011 	char *end;
11012 	unsigned long vf_id;
11013 	int ret = 0;
11014 
11015 	ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
11016 	if (ret < 0) {
11017 		printf("flow director is not supported on port %u.\n",
11018 			res->port_id);
11019 		return;
11020 	}
11021 	memset(flexbytes, 0, sizeof(flexbytes));
11022 	memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
11023 
11024 	if (fdir_conf.mode ==  RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
11025 		if (strcmp(res->mode_value, "MAC-VLAN")) {
11026 			printf("Please set mode to MAC-VLAN.\n");
11027 			return;
11028 		}
11029 	} else if (fdir_conf.mode ==  RTE_FDIR_MODE_PERFECT_TUNNEL) {
11030 		if (strcmp(res->mode_value, "Tunnel")) {
11031 			printf("Please set mode to Tunnel.\n");
11032 			return;
11033 		}
11034 	} else {
11035 		if (!strcmp(res->mode_value, "raw")) {
11036 #ifdef RTE_LIBRTE_I40E_PMD
11037 			struct rte_pmd_i40e_flow_type_mapping
11038 					mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
11039 			struct rte_pmd_i40e_pkt_template_conf conf;
11040 			uint16_t flow_type = str2flowtype(res->flow_type);
11041 			uint16_t i, port = res->port_id;
11042 			uint8_t add;
11043 
11044 			memset(&conf, 0, sizeof(conf));
11045 
11046 			if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
11047 				printf("Invalid flow type specified.\n");
11048 				return;
11049 			}
11050 			ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
11051 								 mapping);
11052 			if (ret)
11053 				return;
11054 			if (mapping[flow_type].pctype == 0ULL) {
11055 				printf("Invalid flow type specified.\n");
11056 				return;
11057 			}
11058 			for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
11059 				if (mapping[flow_type].pctype & (1ULL << i)) {
11060 					conf.input.pctype = i;
11061 					break;
11062 				}
11063 			}
11064 
11065 			conf.input.packet = open_file(res->filepath,
11066 						&conf.input.length);
11067 			if (!conf.input.packet)
11068 				return;
11069 			if (!strcmp(res->drop, "drop"))
11070 				conf.action.behavior =
11071 					RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
11072 			else
11073 				conf.action.behavior =
11074 					RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
11075 			conf.action.report_status =
11076 					RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
11077 			conf.action.rx_queue = res->queue_id;
11078 			conf.soft_id = res->fd_id_value;
11079 			add  = strcmp(res->ops, "del") ? 1 : 0;
11080 			ret = rte_pmd_i40e_flow_add_del_packet_template(port,
11081 									&conf,
11082 									add);
11083 			if (ret < 0)
11084 				printf("flow director config error: (%s)\n",
11085 				       strerror(-ret));
11086 			close_file(conf.input.packet);
11087 #endif
11088 			return;
11089 		} else if (strcmp(res->mode_value, "IP")) {
11090 			printf("Please set mode to IP or raw.\n");
11091 			return;
11092 		}
11093 		entry.input.flow_type = str2flowtype(res->flow_type);
11094 	}
11095 
11096 	ret = parse_flexbytes(res->flexbytes_value,
11097 					flexbytes,
11098 					RTE_ETH_FDIR_MAX_FLEXLEN);
11099 	if (ret < 0) {
11100 		printf("error: Cannot parse flexbytes input.\n");
11101 		return;
11102 	}
11103 
11104 	switch (entry.input.flow_type) {
11105 	case RTE_ETH_FLOW_FRAG_IPV4:
11106 	case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
11107 		entry.input.flow.ip4_flow.proto = res->proto_value;
11108 		/* fall-through */
11109 	case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
11110 	case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
11111 		IPV4_ADDR_TO_UINT(res->ip_dst,
11112 			entry.input.flow.ip4_flow.dst_ip);
11113 		IPV4_ADDR_TO_UINT(res->ip_src,
11114 			entry.input.flow.ip4_flow.src_ip);
11115 		entry.input.flow.ip4_flow.tos = res->tos_value;
11116 		entry.input.flow.ip4_flow.ttl = res->ttl_value;
11117 		/* need convert to big endian. */
11118 		entry.input.flow.udp4_flow.dst_port =
11119 				rte_cpu_to_be_16(res->port_dst);
11120 		entry.input.flow.udp4_flow.src_port =
11121 				rte_cpu_to_be_16(res->port_src);
11122 		break;
11123 	case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
11124 		IPV4_ADDR_TO_UINT(res->ip_dst,
11125 			entry.input.flow.sctp4_flow.ip.dst_ip);
11126 		IPV4_ADDR_TO_UINT(res->ip_src,
11127 			entry.input.flow.sctp4_flow.ip.src_ip);
11128 		entry.input.flow.ip4_flow.tos = res->tos_value;
11129 		entry.input.flow.ip4_flow.ttl = res->ttl_value;
11130 		/* need convert to big endian. */
11131 		entry.input.flow.sctp4_flow.dst_port =
11132 				rte_cpu_to_be_16(res->port_dst);
11133 		entry.input.flow.sctp4_flow.src_port =
11134 				rte_cpu_to_be_16(res->port_src);
11135 		entry.input.flow.sctp4_flow.verify_tag =
11136 				rte_cpu_to_be_32(res->verify_tag_value);
11137 		break;
11138 	case RTE_ETH_FLOW_FRAG_IPV6:
11139 	case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
11140 		entry.input.flow.ipv6_flow.proto = res->proto_value;
11141 		/* fall-through */
11142 	case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
11143 	case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
11144 		IPV6_ADDR_TO_ARRAY(res->ip_dst,
11145 			entry.input.flow.ipv6_flow.dst_ip);
11146 		IPV6_ADDR_TO_ARRAY(res->ip_src,
11147 			entry.input.flow.ipv6_flow.src_ip);
11148 		entry.input.flow.ipv6_flow.tc = res->tos_value;
11149 		entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
11150 		/* need convert to big endian. */
11151 		entry.input.flow.udp6_flow.dst_port =
11152 				rte_cpu_to_be_16(res->port_dst);
11153 		entry.input.flow.udp6_flow.src_port =
11154 				rte_cpu_to_be_16(res->port_src);
11155 		break;
11156 	case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
11157 		IPV6_ADDR_TO_ARRAY(res->ip_dst,
11158 			entry.input.flow.sctp6_flow.ip.dst_ip);
11159 		IPV6_ADDR_TO_ARRAY(res->ip_src,
11160 			entry.input.flow.sctp6_flow.ip.src_ip);
11161 		entry.input.flow.ipv6_flow.tc = res->tos_value;
11162 		entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
11163 		/* need convert to big endian. */
11164 		entry.input.flow.sctp6_flow.dst_port =
11165 				rte_cpu_to_be_16(res->port_dst);
11166 		entry.input.flow.sctp6_flow.src_port =
11167 				rte_cpu_to_be_16(res->port_src);
11168 		entry.input.flow.sctp6_flow.verify_tag =
11169 				rte_cpu_to_be_32(res->verify_tag_value);
11170 		break;
11171 	case RTE_ETH_FLOW_L2_PAYLOAD:
11172 		entry.input.flow.l2_flow.ether_type =
11173 			rte_cpu_to_be_16(res->ether_type);
11174 		break;
11175 	default:
11176 		break;
11177 	}
11178 
11179 	if (fdir_conf.mode ==  RTE_FDIR_MODE_PERFECT_MAC_VLAN)
11180 		rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
11181 				 &res->mac_addr,
11182 				 sizeof(struct rte_ether_addr));
11183 
11184 	if (fdir_conf.mode ==  RTE_FDIR_MODE_PERFECT_TUNNEL) {
11185 		rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
11186 				 &res->mac_addr,
11187 				 sizeof(struct rte_ether_addr));
11188 		entry.input.flow.tunnel_flow.tunnel_type =
11189 			str2fdir_tunneltype(res->tunnel_type);
11190 		entry.input.flow.tunnel_flow.tunnel_id =
11191 			rte_cpu_to_be_32(res->tunnel_id_value);
11192 	}
11193 
11194 	rte_memcpy(entry.input.flow_ext.flexbytes,
11195 		   flexbytes,
11196 		   RTE_ETH_FDIR_MAX_FLEXLEN);
11197 
11198 	entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
11199 
11200 	entry.action.flex_off = 0;  /*use 0 by default */
11201 	if (!strcmp(res->drop, "drop"))
11202 		entry.action.behavior = RTE_ETH_FDIR_REJECT;
11203 	else
11204 		entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
11205 
11206 	if (fdir_conf.mode !=  RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
11207 	    fdir_conf.mode !=  RTE_FDIR_MODE_PERFECT_TUNNEL) {
11208 		if (!strcmp(res->pf_vf, "pf"))
11209 			entry.input.flow_ext.is_vf = 0;
11210 		else if (!strncmp(res->pf_vf, "vf", 2)) {
11211 			struct rte_eth_dev_info dev_info;
11212 
11213 			ret = eth_dev_info_get_print_err(res->port_id,
11214 						&dev_info);
11215 			if (ret != 0)
11216 				return;
11217 
11218 			errno = 0;
11219 			vf_id = strtoul(res->pf_vf + 2, &end, 10);
11220 			if (errno != 0 || *end != '\0' ||
11221 			    vf_id >= dev_info.max_vfs) {
11222 				printf("invalid parameter %s.\n", res->pf_vf);
11223 				return;
11224 			}
11225 			entry.input.flow_ext.is_vf = 1;
11226 			entry.input.flow_ext.dst_id = (uint16_t)vf_id;
11227 		} else {
11228 			printf("invalid parameter %s.\n", res->pf_vf);
11229 			return;
11230 		}
11231 	}
11232 
11233 	/* set to report FD ID by default */
11234 	entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
11235 	entry.action.rx_queue = res->queue_id;
11236 	entry.soft_id = res->fd_id_value;
11237 	if (!strcmp(res->ops, "add"))
11238 		ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11239 					     RTE_ETH_FILTER_ADD, &entry);
11240 	else if (!strcmp(res->ops, "del"))
11241 		ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11242 					     RTE_ETH_FILTER_DELETE, &entry);
11243 	else
11244 		ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11245 					     RTE_ETH_FILTER_UPDATE, &entry);
11246 	if (ret < 0)
11247 		printf("flow director programming error: (%s)\n",
11248 			strerror(-ret));
11249 }
11250 
11251 cmdline_parse_token_string_t cmd_flow_director_filter =
11252 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11253 				 flow_director_filter, "flow_director_filter");
11254 cmdline_parse_token_num_t cmd_flow_director_port_id =
11255 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11256 			      port_id, UINT16);
11257 cmdline_parse_token_string_t cmd_flow_director_ops =
11258 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11259 				 ops, "add#del#update");
11260 cmdline_parse_token_string_t cmd_flow_director_flow =
11261 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11262 				 flow, "flow");
11263 cmdline_parse_token_string_t cmd_flow_director_flow_type =
11264 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11265 		flow_type, NULL);
11266 cmdline_parse_token_string_t cmd_flow_director_ether =
11267 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11268 				 ether, "ether");
11269 cmdline_parse_token_num_t cmd_flow_director_ether_type =
11270 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11271 			      ether_type, UINT16);
11272 cmdline_parse_token_string_t cmd_flow_director_src =
11273 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11274 				 src, "src");
11275 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
11276 	TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
11277 				 ip_src);
11278 cmdline_parse_token_num_t cmd_flow_director_port_src =
11279 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11280 			      port_src, UINT16);
11281 cmdline_parse_token_string_t cmd_flow_director_dst =
11282 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11283 				 dst, "dst");
11284 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
11285 	TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
11286 				 ip_dst);
11287 cmdline_parse_token_num_t cmd_flow_director_port_dst =
11288 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11289 			      port_dst, UINT16);
11290 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
11291 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11292 				  verify_tag, "verify_tag");
11293 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
11294 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11295 			      verify_tag_value, UINT32);
11296 cmdline_parse_token_string_t cmd_flow_director_tos =
11297 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11298 				 tos, "tos");
11299 cmdline_parse_token_num_t cmd_flow_director_tos_value =
11300 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11301 			      tos_value, UINT8);
11302 cmdline_parse_token_string_t cmd_flow_director_proto =
11303 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11304 				 proto, "proto");
11305 cmdline_parse_token_num_t cmd_flow_director_proto_value =
11306 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11307 			      proto_value, UINT8);
11308 cmdline_parse_token_string_t cmd_flow_director_ttl =
11309 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11310 				 ttl, "ttl");
11311 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
11312 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11313 			      ttl_value, UINT8);
11314 cmdline_parse_token_string_t cmd_flow_director_vlan =
11315 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11316 				 vlan, "vlan");
11317 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
11318 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11319 			      vlan_value, UINT16);
11320 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
11321 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11322 				 flexbytes, "flexbytes");
11323 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
11324 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11325 			      flexbytes_value, NULL);
11326 cmdline_parse_token_string_t cmd_flow_director_drop =
11327 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11328 				 drop, "drop#fwd");
11329 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
11330 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11331 			      pf_vf, NULL);
11332 cmdline_parse_token_string_t cmd_flow_director_queue =
11333 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11334 				 queue, "queue");
11335 cmdline_parse_token_num_t cmd_flow_director_queue_id =
11336 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11337 			      queue_id, UINT16);
11338 cmdline_parse_token_string_t cmd_flow_director_fd_id =
11339 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11340 				 fd_id, "fd_id");
11341 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
11342 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11343 			      fd_id_value, UINT32);
11344 
11345 cmdline_parse_token_string_t cmd_flow_director_mode =
11346 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11347 				 mode, "mode");
11348 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
11349 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11350 				 mode_value, "IP");
11351 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
11352 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11353 				 mode_value, "MAC-VLAN");
11354 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
11355 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11356 				 mode_value, "Tunnel");
11357 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
11358 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11359 				 mode_value, "raw");
11360 cmdline_parse_token_string_t cmd_flow_director_mac =
11361 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11362 				 mac, "mac");
11363 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
11364 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
11365 				    mac_addr);
11366 cmdline_parse_token_string_t cmd_flow_director_tunnel =
11367 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11368 				 tunnel, "tunnel");
11369 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
11370 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11371 				 tunnel_type, "NVGRE#VxLAN");
11372 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
11373 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11374 				 tunnel_id, "tunnel-id");
11375 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
11376 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11377 			      tunnel_id_value, UINT32);
11378 cmdline_parse_token_string_t cmd_flow_director_packet =
11379 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11380 				 packet, "packet");
11381 cmdline_parse_token_string_t cmd_flow_director_filepath =
11382 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11383 				 filepath, NULL);
11384 
11385 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
11386 	.f = cmd_flow_director_filter_parsed,
11387 	.data = NULL,
11388 	.help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
11389 		" ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
11390 		"ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
11391 		"l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
11392 		"proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
11393 		"flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> "
11394 		"fd_id <fd_id_value>: "
11395 		"Add or delete an ip flow director entry on NIC",
11396 	.tokens = {
11397 		(void *)&cmd_flow_director_filter,
11398 		(void *)&cmd_flow_director_port_id,
11399 		(void *)&cmd_flow_director_mode,
11400 		(void *)&cmd_flow_director_mode_ip,
11401 		(void *)&cmd_flow_director_ops,
11402 		(void *)&cmd_flow_director_flow,
11403 		(void *)&cmd_flow_director_flow_type,
11404 		(void *)&cmd_flow_director_src,
11405 		(void *)&cmd_flow_director_ip_src,
11406 		(void *)&cmd_flow_director_dst,
11407 		(void *)&cmd_flow_director_ip_dst,
11408 		(void *)&cmd_flow_director_tos,
11409 		(void *)&cmd_flow_director_tos_value,
11410 		(void *)&cmd_flow_director_proto,
11411 		(void *)&cmd_flow_director_proto_value,
11412 		(void *)&cmd_flow_director_ttl,
11413 		(void *)&cmd_flow_director_ttl_value,
11414 		(void *)&cmd_flow_director_vlan,
11415 		(void *)&cmd_flow_director_vlan_value,
11416 		(void *)&cmd_flow_director_flexbytes,
11417 		(void *)&cmd_flow_director_flexbytes_value,
11418 		(void *)&cmd_flow_director_drop,
11419 		(void *)&cmd_flow_director_pf_vf,
11420 		(void *)&cmd_flow_director_queue,
11421 		(void *)&cmd_flow_director_queue_id,
11422 		(void *)&cmd_flow_director_fd_id,
11423 		(void *)&cmd_flow_director_fd_id_value,
11424 		NULL,
11425 	},
11426 };
11427 
11428 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
11429 	.f = cmd_flow_director_filter_parsed,
11430 	.data = NULL,
11431 	.help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
11432 		"director entry on NIC",
11433 	.tokens = {
11434 		(void *)&cmd_flow_director_filter,
11435 		(void *)&cmd_flow_director_port_id,
11436 		(void *)&cmd_flow_director_mode,
11437 		(void *)&cmd_flow_director_mode_ip,
11438 		(void *)&cmd_flow_director_ops,
11439 		(void *)&cmd_flow_director_flow,
11440 		(void *)&cmd_flow_director_flow_type,
11441 		(void *)&cmd_flow_director_src,
11442 		(void *)&cmd_flow_director_ip_src,
11443 		(void *)&cmd_flow_director_port_src,
11444 		(void *)&cmd_flow_director_dst,
11445 		(void *)&cmd_flow_director_ip_dst,
11446 		(void *)&cmd_flow_director_port_dst,
11447 		(void *)&cmd_flow_director_tos,
11448 		(void *)&cmd_flow_director_tos_value,
11449 		(void *)&cmd_flow_director_ttl,
11450 		(void *)&cmd_flow_director_ttl_value,
11451 		(void *)&cmd_flow_director_vlan,
11452 		(void *)&cmd_flow_director_vlan_value,
11453 		(void *)&cmd_flow_director_flexbytes,
11454 		(void *)&cmd_flow_director_flexbytes_value,
11455 		(void *)&cmd_flow_director_drop,
11456 		(void *)&cmd_flow_director_pf_vf,
11457 		(void *)&cmd_flow_director_queue,
11458 		(void *)&cmd_flow_director_queue_id,
11459 		(void *)&cmd_flow_director_fd_id,
11460 		(void *)&cmd_flow_director_fd_id_value,
11461 		NULL,
11462 	},
11463 };
11464 
11465 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
11466 	.f = cmd_flow_director_filter_parsed,
11467 	.data = NULL,
11468 	.help_str = "flow_director_filter ... : Add or delete a sctp flow "
11469 		"director entry on NIC",
11470 	.tokens = {
11471 		(void *)&cmd_flow_director_filter,
11472 		(void *)&cmd_flow_director_port_id,
11473 		(void *)&cmd_flow_director_mode,
11474 		(void *)&cmd_flow_director_mode_ip,
11475 		(void *)&cmd_flow_director_ops,
11476 		(void *)&cmd_flow_director_flow,
11477 		(void *)&cmd_flow_director_flow_type,
11478 		(void *)&cmd_flow_director_src,
11479 		(void *)&cmd_flow_director_ip_src,
11480 		(void *)&cmd_flow_director_port_src,
11481 		(void *)&cmd_flow_director_dst,
11482 		(void *)&cmd_flow_director_ip_dst,
11483 		(void *)&cmd_flow_director_port_dst,
11484 		(void *)&cmd_flow_director_verify_tag,
11485 		(void *)&cmd_flow_director_verify_tag_value,
11486 		(void *)&cmd_flow_director_tos,
11487 		(void *)&cmd_flow_director_tos_value,
11488 		(void *)&cmd_flow_director_ttl,
11489 		(void *)&cmd_flow_director_ttl_value,
11490 		(void *)&cmd_flow_director_vlan,
11491 		(void *)&cmd_flow_director_vlan_value,
11492 		(void *)&cmd_flow_director_flexbytes,
11493 		(void *)&cmd_flow_director_flexbytes_value,
11494 		(void *)&cmd_flow_director_drop,
11495 		(void *)&cmd_flow_director_pf_vf,
11496 		(void *)&cmd_flow_director_queue,
11497 		(void *)&cmd_flow_director_queue_id,
11498 		(void *)&cmd_flow_director_fd_id,
11499 		(void *)&cmd_flow_director_fd_id_value,
11500 		NULL,
11501 	},
11502 };
11503 
11504 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
11505 	.f = cmd_flow_director_filter_parsed,
11506 	.data = NULL,
11507 	.help_str = "flow_director_filter ... : Add or delete a L2 flow "
11508 		"director entry on NIC",
11509 	.tokens = {
11510 		(void *)&cmd_flow_director_filter,
11511 		(void *)&cmd_flow_director_port_id,
11512 		(void *)&cmd_flow_director_mode,
11513 		(void *)&cmd_flow_director_mode_ip,
11514 		(void *)&cmd_flow_director_ops,
11515 		(void *)&cmd_flow_director_flow,
11516 		(void *)&cmd_flow_director_flow_type,
11517 		(void *)&cmd_flow_director_ether,
11518 		(void *)&cmd_flow_director_ether_type,
11519 		(void *)&cmd_flow_director_flexbytes,
11520 		(void *)&cmd_flow_director_flexbytes_value,
11521 		(void *)&cmd_flow_director_drop,
11522 		(void *)&cmd_flow_director_pf_vf,
11523 		(void *)&cmd_flow_director_queue,
11524 		(void *)&cmd_flow_director_queue_id,
11525 		(void *)&cmd_flow_director_fd_id,
11526 		(void *)&cmd_flow_director_fd_id_value,
11527 		NULL,
11528 	},
11529 };
11530 
11531 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
11532 	.f = cmd_flow_director_filter_parsed,
11533 	.data = NULL,
11534 	.help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
11535 		"director entry on NIC",
11536 	.tokens = {
11537 		(void *)&cmd_flow_director_filter,
11538 		(void *)&cmd_flow_director_port_id,
11539 		(void *)&cmd_flow_director_mode,
11540 		(void *)&cmd_flow_director_mode_mac_vlan,
11541 		(void *)&cmd_flow_director_ops,
11542 		(void *)&cmd_flow_director_mac,
11543 		(void *)&cmd_flow_director_mac_addr,
11544 		(void *)&cmd_flow_director_vlan,
11545 		(void *)&cmd_flow_director_vlan_value,
11546 		(void *)&cmd_flow_director_flexbytes,
11547 		(void *)&cmd_flow_director_flexbytes_value,
11548 		(void *)&cmd_flow_director_drop,
11549 		(void *)&cmd_flow_director_queue,
11550 		(void *)&cmd_flow_director_queue_id,
11551 		(void *)&cmd_flow_director_fd_id,
11552 		(void *)&cmd_flow_director_fd_id_value,
11553 		NULL,
11554 	},
11555 };
11556 
11557 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
11558 	.f = cmd_flow_director_filter_parsed,
11559 	.data = NULL,
11560 	.help_str = "flow_director_filter ... : Add or delete a tunnel flow "
11561 		"director entry on NIC",
11562 	.tokens = {
11563 		(void *)&cmd_flow_director_filter,
11564 		(void *)&cmd_flow_director_port_id,
11565 		(void *)&cmd_flow_director_mode,
11566 		(void *)&cmd_flow_director_mode_tunnel,
11567 		(void *)&cmd_flow_director_ops,
11568 		(void *)&cmd_flow_director_mac,
11569 		(void *)&cmd_flow_director_mac_addr,
11570 		(void *)&cmd_flow_director_vlan,
11571 		(void *)&cmd_flow_director_vlan_value,
11572 		(void *)&cmd_flow_director_tunnel,
11573 		(void *)&cmd_flow_director_tunnel_type,
11574 		(void *)&cmd_flow_director_tunnel_id,
11575 		(void *)&cmd_flow_director_tunnel_id_value,
11576 		(void *)&cmd_flow_director_flexbytes,
11577 		(void *)&cmd_flow_director_flexbytes_value,
11578 		(void *)&cmd_flow_director_drop,
11579 		(void *)&cmd_flow_director_queue,
11580 		(void *)&cmd_flow_director_queue_id,
11581 		(void *)&cmd_flow_director_fd_id,
11582 		(void *)&cmd_flow_director_fd_id_value,
11583 		NULL,
11584 	},
11585 };
11586 
11587 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
11588 	.f = cmd_flow_director_filter_parsed,
11589 	.data = NULL,
11590 	.help_str = "flow_director_filter ... : Add or delete a raw flow "
11591 		"director entry on NIC",
11592 	.tokens = {
11593 		(void *)&cmd_flow_director_filter,
11594 		(void *)&cmd_flow_director_port_id,
11595 		(void *)&cmd_flow_director_mode,
11596 		(void *)&cmd_flow_director_mode_raw,
11597 		(void *)&cmd_flow_director_ops,
11598 		(void *)&cmd_flow_director_flow,
11599 		(void *)&cmd_flow_director_flow_type,
11600 		(void *)&cmd_flow_director_drop,
11601 		(void *)&cmd_flow_director_queue,
11602 		(void *)&cmd_flow_director_queue_id,
11603 		(void *)&cmd_flow_director_fd_id,
11604 		(void *)&cmd_flow_director_fd_id_value,
11605 		(void *)&cmd_flow_director_packet,
11606 		(void *)&cmd_flow_director_filepath,
11607 		NULL,
11608 	},
11609 };
11610 
11611 struct cmd_flush_flow_director_result {
11612 	cmdline_fixed_string_t flush_flow_director;
11613 	portid_t port_id;
11614 };
11615 
11616 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
11617 	TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
11618 				 flush_flow_director, "flush_flow_director");
11619 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
11620 	TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
11621 			      port_id, UINT16);
11622 
11623 static void
11624 cmd_flush_flow_director_parsed(void *parsed_result,
11625 			  __attribute__((unused)) struct cmdline *cl,
11626 			  __attribute__((unused)) void *data)
11627 {
11628 	struct cmd_flow_director_result *res = parsed_result;
11629 	int ret = 0;
11630 
11631 	ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
11632 	if (ret < 0) {
11633 		printf("flow director is not supported on port %u.\n",
11634 			res->port_id);
11635 		return;
11636 	}
11637 
11638 	ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11639 			RTE_ETH_FILTER_FLUSH, NULL);
11640 	if (ret < 0)
11641 		printf("flow director table flushing error: (%s)\n",
11642 			strerror(-ret));
11643 }
11644 
11645 cmdline_parse_inst_t cmd_flush_flow_director = {
11646 	.f = cmd_flush_flow_director_parsed,
11647 	.data = NULL,
11648 	.help_str = "flush_flow_director <port_id>: "
11649 		"Flush all flow director entries of a device on NIC",
11650 	.tokens = {
11651 		(void *)&cmd_flush_flow_director_flush,
11652 		(void *)&cmd_flush_flow_director_port_id,
11653 		NULL,
11654 	},
11655 };
11656 
11657 /* *** deal with flow director mask *** */
11658 struct cmd_flow_director_mask_result {
11659 	cmdline_fixed_string_t flow_director_mask;
11660 	portid_t port_id;
11661 	cmdline_fixed_string_t mode;
11662 	cmdline_fixed_string_t mode_value;
11663 	cmdline_fixed_string_t vlan;
11664 	uint16_t vlan_mask;
11665 	cmdline_fixed_string_t src_mask;
11666 	cmdline_ipaddr_t ipv4_src;
11667 	cmdline_ipaddr_t ipv6_src;
11668 	uint16_t port_src;
11669 	cmdline_fixed_string_t dst_mask;
11670 	cmdline_ipaddr_t ipv4_dst;
11671 	cmdline_ipaddr_t ipv6_dst;
11672 	uint16_t port_dst;
11673 	cmdline_fixed_string_t mac;
11674 	uint8_t mac_addr_byte_mask;
11675 	cmdline_fixed_string_t tunnel_id;
11676 	uint32_t tunnel_id_mask;
11677 	cmdline_fixed_string_t tunnel_type;
11678 	uint8_t tunnel_type_mask;
11679 };
11680 
11681 static void
11682 cmd_flow_director_mask_parsed(void *parsed_result,
11683 			  __attribute__((unused)) struct cmdline *cl,
11684 			  __attribute__((unused)) void *data)
11685 {
11686 	struct cmd_flow_director_mask_result *res = parsed_result;
11687 	struct rte_eth_fdir_masks *mask;
11688 	struct rte_port *port;
11689 
11690 	port = &ports[res->port_id];
11691 	/** Check if the port is not started **/
11692 	if (port->port_status != RTE_PORT_STOPPED) {
11693 		printf("Please stop port %d first\n", res->port_id);
11694 		return;
11695 	}
11696 
11697 	mask = &port->dev_conf.fdir_conf.mask;
11698 
11699 	if (fdir_conf.mode ==  RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
11700 		if (strcmp(res->mode_value, "MAC-VLAN")) {
11701 			printf("Please set mode to MAC-VLAN.\n");
11702 			return;
11703 		}
11704 
11705 		mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11706 	} else if (fdir_conf.mode ==  RTE_FDIR_MODE_PERFECT_TUNNEL) {
11707 		if (strcmp(res->mode_value, "Tunnel")) {
11708 			printf("Please set mode to Tunnel.\n");
11709 			return;
11710 		}
11711 
11712 		mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11713 		mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
11714 		mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
11715 		mask->tunnel_type_mask = res->tunnel_type_mask;
11716 	} else {
11717 		if (strcmp(res->mode_value, "IP")) {
11718 			printf("Please set mode to IP.\n");
11719 			return;
11720 		}
11721 
11722 		mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11723 		IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
11724 		IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
11725 		IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
11726 		IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
11727 		mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
11728 		mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
11729 	}
11730 
11731 	cmd_reconfig_device_queue(res->port_id, 1, 1);
11732 }
11733 
11734 cmdline_parse_token_string_t cmd_flow_director_mask =
11735 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11736 				 flow_director_mask, "flow_director_mask");
11737 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
11738 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11739 			      port_id, UINT16);
11740 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
11741 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11742 				 vlan, "vlan");
11743 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
11744 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11745 			      vlan_mask, UINT16);
11746 cmdline_parse_token_string_t cmd_flow_director_mask_src =
11747 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11748 				 src_mask, "src_mask");
11749 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
11750 	TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11751 				 ipv4_src);
11752 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
11753 	TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11754 				 ipv6_src);
11755 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
11756 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11757 			      port_src, UINT16);
11758 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
11759 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11760 				 dst_mask, "dst_mask");
11761 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
11762 	TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11763 				 ipv4_dst);
11764 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
11765 	TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11766 				 ipv6_dst);
11767 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
11768 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11769 			      port_dst, UINT16);
11770 
11771 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
11772 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11773 				 mode, "mode");
11774 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
11775 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11776 				 mode_value, "IP");
11777 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
11778 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11779 				 mode_value, "MAC-VLAN");
11780 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
11781 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11782 				 mode_value, "Tunnel");
11783 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
11784 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11785 				 mac, "mac");
11786 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
11787 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11788 			      mac_addr_byte_mask, UINT8);
11789 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
11790 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11791 				 tunnel_type, "tunnel-type");
11792 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
11793 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11794 			      tunnel_type_mask, UINT8);
11795 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
11796 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11797 				 tunnel_id, "tunnel-id");
11798 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
11799 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11800 			      tunnel_id_mask, UINT32);
11801 
11802 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
11803 	.f = cmd_flow_director_mask_parsed,
11804 	.data = NULL,
11805 	.help_str = "flow_director_mask ... : "
11806 		"Set IP mode flow director's mask on NIC",
11807 	.tokens = {
11808 		(void *)&cmd_flow_director_mask,
11809 		(void *)&cmd_flow_director_mask_port_id,
11810 		(void *)&cmd_flow_director_mask_mode,
11811 		(void *)&cmd_flow_director_mask_mode_ip,
11812 		(void *)&cmd_flow_director_mask_vlan,
11813 		(void *)&cmd_flow_director_mask_vlan_value,
11814 		(void *)&cmd_flow_director_mask_src,
11815 		(void *)&cmd_flow_director_mask_ipv4_src,
11816 		(void *)&cmd_flow_director_mask_ipv6_src,
11817 		(void *)&cmd_flow_director_mask_port_src,
11818 		(void *)&cmd_flow_director_mask_dst,
11819 		(void *)&cmd_flow_director_mask_ipv4_dst,
11820 		(void *)&cmd_flow_director_mask_ipv6_dst,
11821 		(void *)&cmd_flow_director_mask_port_dst,
11822 		NULL,
11823 	},
11824 };
11825 
11826 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
11827 	.f = cmd_flow_director_mask_parsed,
11828 	.data = NULL,
11829 	.help_str = "flow_director_mask ... : Set MAC VLAN mode "
11830 		"flow director's mask on NIC",
11831 	.tokens = {
11832 		(void *)&cmd_flow_director_mask,
11833 		(void *)&cmd_flow_director_mask_port_id,
11834 		(void *)&cmd_flow_director_mask_mode,
11835 		(void *)&cmd_flow_director_mask_mode_mac_vlan,
11836 		(void *)&cmd_flow_director_mask_vlan,
11837 		(void *)&cmd_flow_director_mask_vlan_value,
11838 		NULL,
11839 	},
11840 };
11841 
11842 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
11843 	.f = cmd_flow_director_mask_parsed,
11844 	.data = NULL,
11845 	.help_str = "flow_director_mask ... : Set tunnel mode "
11846 		"flow director's mask on NIC",
11847 	.tokens = {
11848 		(void *)&cmd_flow_director_mask,
11849 		(void *)&cmd_flow_director_mask_port_id,
11850 		(void *)&cmd_flow_director_mask_mode,
11851 		(void *)&cmd_flow_director_mask_mode_tunnel,
11852 		(void *)&cmd_flow_director_mask_vlan,
11853 		(void *)&cmd_flow_director_mask_vlan_value,
11854 		(void *)&cmd_flow_director_mask_mac,
11855 		(void *)&cmd_flow_director_mask_mac_value,
11856 		(void *)&cmd_flow_director_mask_tunnel_type,
11857 		(void *)&cmd_flow_director_mask_tunnel_type_value,
11858 		(void *)&cmd_flow_director_mask_tunnel_id,
11859 		(void *)&cmd_flow_director_mask_tunnel_id_value,
11860 		NULL,
11861 	},
11862 };
11863 
11864 /* *** deal with flow director mask on flexible payload *** */
11865 struct cmd_flow_director_flex_mask_result {
11866 	cmdline_fixed_string_t flow_director_flexmask;
11867 	portid_t port_id;
11868 	cmdline_fixed_string_t flow;
11869 	cmdline_fixed_string_t flow_type;
11870 	cmdline_fixed_string_t mask;
11871 };
11872 
11873 static void
11874 cmd_flow_director_flex_mask_parsed(void *parsed_result,
11875 			  __attribute__((unused)) struct cmdline *cl,
11876 			  __attribute__((unused)) void *data)
11877 {
11878 	struct cmd_flow_director_flex_mask_result *res = parsed_result;
11879 	struct rte_eth_fdir_info fdir_info;
11880 	struct rte_eth_fdir_flex_mask flex_mask;
11881 	struct rte_port *port;
11882 	uint64_t flow_type_mask;
11883 	uint16_t i;
11884 	int ret;
11885 
11886 	port = &ports[res->port_id];
11887 	/** Check if the port is not started **/
11888 	if (port->port_status != RTE_PORT_STOPPED) {
11889 		printf("Please stop port %d first\n", res->port_id);
11890 		return;
11891 	}
11892 
11893 	memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
11894 	ret = parse_flexbytes(res->mask,
11895 			flex_mask.mask,
11896 			RTE_ETH_FDIR_MAX_FLEXLEN);
11897 	if (ret < 0) {
11898 		printf("error: Cannot parse mask input.\n");
11899 		return;
11900 	}
11901 
11902 	memset(&fdir_info, 0, sizeof(fdir_info));
11903 	ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11904 				RTE_ETH_FILTER_INFO, &fdir_info);
11905 	if (ret < 0) {
11906 		printf("Cannot get FDir filter info\n");
11907 		return;
11908 	}
11909 
11910 	if (!strcmp(res->flow_type, "none")) {
11911 		/* means don't specify the flow type */
11912 		flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
11913 		for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
11914 			memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
11915 			       0, sizeof(struct rte_eth_fdir_flex_mask));
11916 		port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
11917 		rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
11918 				 &flex_mask,
11919 				 sizeof(struct rte_eth_fdir_flex_mask));
11920 		cmd_reconfig_device_queue(res->port_id, 1, 1);
11921 		return;
11922 	}
11923 	flow_type_mask = fdir_info.flow_types_mask[0];
11924 	if (!strcmp(res->flow_type, "all")) {
11925 		if (!flow_type_mask) {
11926 			printf("No flow type supported\n");
11927 			return;
11928 		}
11929 		for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
11930 			if (flow_type_mask & (1ULL << i)) {
11931 				flex_mask.flow_type = i;
11932 				fdir_set_flex_mask(res->port_id, &flex_mask);
11933 			}
11934 		}
11935 		cmd_reconfig_device_queue(res->port_id, 1, 1);
11936 		return;
11937 	}
11938 	flex_mask.flow_type = str2flowtype(res->flow_type);
11939 	if (!(flow_type_mask & (1ULL << flex_mask.flow_type))) {
11940 		printf("Flow type %s not supported on port %d\n",
11941 				res->flow_type, res->port_id);
11942 		return;
11943 	}
11944 	fdir_set_flex_mask(res->port_id, &flex_mask);
11945 	cmd_reconfig_device_queue(res->port_id, 1, 1);
11946 }
11947 
11948 cmdline_parse_token_string_t cmd_flow_director_flexmask =
11949 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11950 				 flow_director_flexmask,
11951 				 "flow_director_flex_mask");
11952 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
11953 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11954 			      port_id, UINT16);
11955 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
11956 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11957 				 flow, "flow");
11958 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
11959 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11960 		flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
11961 		"ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
11962 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
11963 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11964 				 mask, NULL);
11965 
11966 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
11967 	.f = cmd_flow_director_flex_mask_parsed,
11968 	.data = NULL,
11969 	.help_str = "flow_director_flex_mask ... : "
11970 		"Set flow director's flex mask on NIC",
11971 	.tokens = {
11972 		(void *)&cmd_flow_director_flexmask,
11973 		(void *)&cmd_flow_director_flexmask_port_id,
11974 		(void *)&cmd_flow_director_flexmask_flow,
11975 		(void *)&cmd_flow_director_flexmask_flow_type,
11976 		(void *)&cmd_flow_director_flexmask_mask,
11977 		NULL,
11978 	},
11979 };
11980 
11981 /* *** deal with flow director flexible payload configuration *** */
11982 struct cmd_flow_director_flexpayload_result {
11983 	cmdline_fixed_string_t flow_director_flexpayload;
11984 	portid_t port_id;
11985 	cmdline_fixed_string_t payload_layer;
11986 	cmdline_fixed_string_t payload_cfg;
11987 };
11988 
11989 static inline int
11990 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
11991 {
11992 	char s[256];
11993 	const char *p, *p0 = q_arg;
11994 	char *end;
11995 	unsigned long int_fld;
11996 	char *str_fld[max_num];
11997 	int i;
11998 	unsigned size;
11999 	int ret = -1;
12000 
12001 	p = strchr(p0, '(');
12002 	if (p == NULL)
12003 		return -1;
12004 	++p;
12005 	p0 = strchr(p, ')');
12006 	if (p0 == NULL)
12007 		return -1;
12008 
12009 	size = p0 - p;
12010 	if (size >= sizeof(s))
12011 		return -1;
12012 
12013 	snprintf(s, sizeof(s), "%.*s", size, p);
12014 	ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
12015 	if (ret < 0 || ret > max_num)
12016 		return -1;
12017 	for (i = 0; i < ret; i++) {
12018 		errno = 0;
12019 		int_fld = strtoul(str_fld[i], &end, 0);
12020 		if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
12021 			return -1;
12022 		offsets[i] = (uint16_t)int_fld;
12023 	}
12024 	return ret;
12025 }
12026 
12027 static void
12028 cmd_flow_director_flxpld_parsed(void *parsed_result,
12029 			  __attribute__((unused)) struct cmdline *cl,
12030 			  __attribute__((unused)) void *data)
12031 {
12032 	struct cmd_flow_director_flexpayload_result *res = parsed_result;
12033 	struct rte_eth_flex_payload_cfg flex_cfg;
12034 	struct rte_port *port;
12035 	int ret = 0;
12036 
12037 	port = &ports[res->port_id];
12038 	/** Check if the port is not started **/
12039 	if (port->port_status != RTE_PORT_STOPPED) {
12040 		printf("Please stop port %d first\n", res->port_id);
12041 		return;
12042 	}
12043 
12044 	memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
12045 
12046 	if (!strcmp(res->payload_layer, "raw"))
12047 		flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
12048 	else if (!strcmp(res->payload_layer, "l2"))
12049 		flex_cfg.type = RTE_ETH_L2_PAYLOAD;
12050 	else if (!strcmp(res->payload_layer, "l3"))
12051 		flex_cfg.type = RTE_ETH_L3_PAYLOAD;
12052 	else if (!strcmp(res->payload_layer, "l4"))
12053 		flex_cfg.type = RTE_ETH_L4_PAYLOAD;
12054 
12055 	ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
12056 			    RTE_ETH_FDIR_MAX_FLEXLEN);
12057 	if (ret < 0) {
12058 		printf("error: Cannot parse flex payload input.\n");
12059 		return;
12060 	}
12061 
12062 	fdir_set_flex_payload(res->port_id, &flex_cfg);
12063 	cmd_reconfig_device_queue(res->port_id, 1, 1);
12064 }
12065 
12066 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
12067 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12068 				 flow_director_flexpayload,
12069 				 "flow_director_flex_payload");
12070 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
12071 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12072 			      port_id, UINT16);
12073 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
12074 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12075 				 payload_layer, "raw#l2#l3#l4");
12076 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
12077 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12078 				 payload_cfg, NULL);
12079 
12080 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
12081 	.f = cmd_flow_director_flxpld_parsed,
12082 	.data = NULL,
12083 	.help_str = "flow_director_flexpayload ... : "
12084 		"Set flow director's flex payload on NIC",
12085 	.tokens = {
12086 		(void *)&cmd_flow_director_flexpayload,
12087 		(void *)&cmd_flow_director_flexpayload_port_id,
12088 		(void *)&cmd_flow_director_flexpayload_payload_layer,
12089 		(void *)&cmd_flow_director_flexpayload_payload_cfg,
12090 		NULL,
12091 	},
12092 };
12093 
12094 /* Generic flow interface command. */
12095 extern cmdline_parse_inst_t cmd_flow;
12096 
12097 /* *** Classification Filters Control *** */
12098 /* *** Get symmetric hash enable per port *** */
12099 struct cmd_get_sym_hash_ena_per_port_result {
12100 	cmdline_fixed_string_t get_sym_hash_ena_per_port;
12101 	portid_t port_id;
12102 };
12103 
12104 static void
12105 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
12106 				 __rte_unused struct cmdline *cl,
12107 				 __rte_unused void *data)
12108 {
12109 	struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
12110 	struct rte_eth_hash_filter_info info;
12111 	int ret;
12112 
12113 	if (rte_eth_dev_filter_supported(res->port_id,
12114 				RTE_ETH_FILTER_HASH) < 0) {
12115 		printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
12116 							res->port_id);
12117 		return;
12118 	}
12119 
12120 	memset(&info, 0, sizeof(info));
12121 	info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
12122 	ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12123 						RTE_ETH_FILTER_GET, &info);
12124 
12125 	if (ret < 0) {
12126 		printf("Cannot get symmetric hash enable per port "
12127 					"on port %u\n", res->port_id);
12128 		return;
12129 	}
12130 
12131 	printf("Symmetric hash is %s on port %u\n", info.info.enable ?
12132 				"enabled" : "disabled", res->port_id);
12133 }
12134 
12135 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
12136 	TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
12137 		get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
12138 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
12139 	TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
12140 		port_id, UINT16);
12141 
12142 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
12143 	.f = cmd_get_sym_hash_per_port_parsed,
12144 	.data = NULL,
12145 	.help_str = "get_sym_hash_ena_per_port <port_id>",
12146 	.tokens = {
12147 		(void *)&cmd_get_sym_hash_ena_per_port_all,
12148 		(void *)&cmd_get_sym_hash_ena_per_port_port_id,
12149 		NULL,
12150 	},
12151 };
12152 
12153 /* *** Set symmetric hash enable per port *** */
12154 struct cmd_set_sym_hash_ena_per_port_result {
12155 	cmdline_fixed_string_t set_sym_hash_ena_per_port;
12156 	cmdline_fixed_string_t enable;
12157 	portid_t port_id;
12158 };
12159 
12160 static void
12161 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
12162 				 __rte_unused struct cmdline *cl,
12163 				 __rte_unused void *data)
12164 {
12165 	struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
12166 	struct rte_eth_hash_filter_info info;
12167 	int ret;
12168 
12169 	if (rte_eth_dev_filter_supported(res->port_id,
12170 				RTE_ETH_FILTER_HASH) < 0) {
12171 		printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
12172 							res->port_id);
12173 		return;
12174 	}
12175 
12176 	memset(&info, 0, sizeof(info));
12177 	info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
12178 	if (!strcmp(res->enable, "enable"))
12179 		info.info.enable = 1;
12180 	ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12181 					RTE_ETH_FILTER_SET, &info);
12182 	if (ret < 0) {
12183 		printf("Cannot set symmetric hash enable per port on "
12184 					"port %u\n", res->port_id);
12185 		return;
12186 	}
12187 	printf("Symmetric hash has been set to %s on port %u\n",
12188 					res->enable, res->port_id);
12189 }
12190 
12191 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
12192 	TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12193 		set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
12194 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
12195 	TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12196 		port_id, UINT16);
12197 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
12198 	TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12199 		enable, "enable#disable");
12200 
12201 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
12202 	.f = cmd_set_sym_hash_per_port_parsed,
12203 	.data = NULL,
12204 	.help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
12205 	.tokens = {
12206 		(void *)&cmd_set_sym_hash_ena_per_port_all,
12207 		(void *)&cmd_set_sym_hash_ena_per_port_port_id,
12208 		(void *)&cmd_set_sym_hash_ena_per_port_enable,
12209 		NULL,
12210 	},
12211 };
12212 
12213 /* Get global config of hash function */
12214 struct cmd_get_hash_global_config_result {
12215 	cmdline_fixed_string_t get_hash_global_config;
12216 	portid_t port_id;
12217 };
12218 
12219 static char *
12220 flowtype_to_str(uint16_t ftype)
12221 {
12222 	uint16_t i;
12223 	static struct {
12224 		char str[16];
12225 		uint16_t ftype;
12226 	} ftype_table[] = {
12227 		{"ipv4", RTE_ETH_FLOW_IPV4},
12228 		{"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
12229 		{"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
12230 		{"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
12231 		{"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
12232 		{"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
12233 		{"ipv6", RTE_ETH_FLOW_IPV6},
12234 		{"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
12235 		{"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
12236 		{"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
12237 		{"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
12238 		{"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
12239 		{"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
12240 		{"port", RTE_ETH_FLOW_PORT},
12241 		{"vxlan", RTE_ETH_FLOW_VXLAN},
12242 		{"geneve", RTE_ETH_FLOW_GENEVE},
12243 		{"nvgre", RTE_ETH_FLOW_NVGRE},
12244 		{"vxlan-gpe", RTE_ETH_FLOW_VXLAN_GPE},
12245 	};
12246 
12247 	for (i = 0; i < RTE_DIM(ftype_table); i++) {
12248 		if (ftype_table[i].ftype == ftype)
12249 			return ftype_table[i].str;
12250 	}
12251 
12252 	return NULL;
12253 }
12254 
12255 static void
12256 cmd_get_hash_global_config_parsed(void *parsed_result,
12257 				  __rte_unused struct cmdline *cl,
12258 				  __rte_unused void *data)
12259 {
12260 	struct cmd_get_hash_global_config_result *res = parsed_result;
12261 	struct rte_eth_hash_filter_info info;
12262 	uint32_t idx, offset;
12263 	uint16_t i;
12264 	char *str;
12265 	int ret;
12266 
12267 	if (rte_eth_dev_filter_supported(res->port_id,
12268 			RTE_ETH_FILTER_HASH) < 0) {
12269 		printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
12270 							res->port_id);
12271 		return;
12272 	}
12273 
12274 	memset(&info, 0, sizeof(info));
12275 	info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
12276 	ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12277 					RTE_ETH_FILTER_GET, &info);
12278 	if (ret < 0) {
12279 		printf("Cannot get hash global configurations by port %d\n",
12280 							res->port_id);
12281 		return;
12282 	}
12283 
12284 	switch (info.info.global_conf.hash_func) {
12285 	case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
12286 		printf("Hash function is Toeplitz\n");
12287 		break;
12288 	case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
12289 		printf("Hash function is Simple XOR\n");
12290 		break;
12291 	case RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ:
12292 		printf("Hash function is Symmetric Toeplitz\n");
12293 		break;
12294 	default:
12295 		printf("Unknown hash function\n");
12296 		break;
12297 	}
12298 
12299 	for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
12300 		idx = i / UINT64_BIT;
12301 		offset = i % UINT64_BIT;
12302 		if (!(info.info.global_conf.valid_bit_mask[idx] &
12303 						(1ULL << offset)))
12304 			continue;
12305 		str = flowtype_to_str(i);
12306 		if (!str)
12307 			continue;
12308 		printf("Symmetric hash is %s globally for flow type %s "
12309 							"by port %d\n",
12310 			((info.info.global_conf.sym_hash_enable_mask[idx] &
12311 			(1ULL << offset)) ? "enabled" : "disabled"), str,
12312 							res->port_id);
12313 	}
12314 }
12315 
12316 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
12317 	TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
12318 		get_hash_global_config, "get_hash_global_config");
12319 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
12320 	TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
12321 		port_id, UINT16);
12322 
12323 cmdline_parse_inst_t cmd_get_hash_global_config = {
12324 	.f = cmd_get_hash_global_config_parsed,
12325 	.data = NULL,
12326 	.help_str = "get_hash_global_config <port_id>",
12327 	.tokens = {
12328 		(void *)&cmd_get_hash_global_config_all,
12329 		(void *)&cmd_get_hash_global_config_port_id,
12330 		NULL,
12331 	},
12332 };
12333 
12334 /* Set global config of hash function */
12335 struct cmd_set_hash_global_config_result {
12336 	cmdline_fixed_string_t set_hash_global_config;
12337 	portid_t port_id;
12338 	cmdline_fixed_string_t hash_func;
12339 	cmdline_fixed_string_t flow_type;
12340 	cmdline_fixed_string_t enable;
12341 };
12342 
12343 static void
12344 cmd_set_hash_global_config_parsed(void *parsed_result,
12345 				  __rte_unused struct cmdline *cl,
12346 				  __rte_unused void *data)
12347 {
12348 	struct cmd_set_hash_global_config_result *res = parsed_result;
12349 	struct rte_eth_hash_filter_info info;
12350 	uint32_t ftype, idx, offset;
12351 	int ret;
12352 
12353 	if (rte_eth_dev_filter_supported(res->port_id,
12354 				RTE_ETH_FILTER_HASH) < 0) {
12355 		printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
12356 							res->port_id);
12357 		return;
12358 	}
12359 	memset(&info, 0, sizeof(info));
12360 	info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
12361 	if (!strcmp(res->hash_func, "toeplitz"))
12362 		info.info.global_conf.hash_func =
12363 			RTE_ETH_HASH_FUNCTION_TOEPLITZ;
12364 	else if (!strcmp(res->hash_func, "simple_xor"))
12365 		info.info.global_conf.hash_func =
12366 			RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
12367 	else if (!strcmp(res->hash_func, "symmetric_toeplitz"))
12368 		info.info.global_conf.hash_func =
12369 			RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ;
12370 	else if (!strcmp(res->hash_func, "default"))
12371 		info.info.global_conf.hash_func =
12372 			RTE_ETH_HASH_FUNCTION_DEFAULT;
12373 
12374 	ftype = str2flowtype(res->flow_type);
12375 	idx = ftype / UINT64_BIT;
12376 	offset = ftype % UINT64_BIT;
12377 	info.info.global_conf.valid_bit_mask[idx] |= (1ULL << offset);
12378 	if (!strcmp(res->enable, "enable"))
12379 		info.info.global_conf.sym_hash_enable_mask[idx] |=
12380 						(1ULL << offset);
12381 	ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12382 					RTE_ETH_FILTER_SET, &info);
12383 	if (ret < 0)
12384 		printf("Cannot set global hash configurations by port %d\n",
12385 							res->port_id);
12386 	else
12387 		printf("Global hash configurations have been set "
12388 			"successfully by port %d\n", res->port_id);
12389 }
12390 
12391 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
12392 	TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12393 		set_hash_global_config, "set_hash_global_config");
12394 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
12395 	TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
12396 		port_id, UINT16);
12397 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
12398 	TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12399 		hash_func, "toeplitz#simple_xor#symmetric_toeplitz#default");
12400 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
12401 	TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12402 		flow_type,
12403 		"ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
12404 		"ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12405 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
12406 	TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12407 		enable, "enable#disable");
12408 
12409 cmdline_parse_inst_t cmd_set_hash_global_config = {
12410 	.f = cmd_set_hash_global_config_parsed,
12411 	.data = NULL,
12412 	.help_str = "set_hash_global_config <port_id> "
12413 		"toeplitz|simple_xor|symmetric_toeplitz|default "
12414 		"ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12415 		"ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
12416 		"l2_payload enable|disable",
12417 	.tokens = {
12418 		(void *)&cmd_set_hash_global_config_all,
12419 		(void *)&cmd_set_hash_global_config_port_id,
12420 		(void *)&cmd_set_hash_global_config_hash_func,
12421 		(void *)&cmd_set_hash_global_config_flow_type,
12422 		(void *)&cmd_set_hash_global_config_enable,
12423 		NULL,
12424 	},
12425 };
12426 
12427 /* Set hash input set */
12428 struct cmd_set_hash_input_set_result {
12429 	cmdline_fixed_string_t set_hash_input_set;
12430 	portid_t port_id;
12431 	cmdline_fixed_string_t flow_type;
12432 	cmdline_fixed_string_t inset_field;
12433 	cmdline_fixed_string_t select;
12434 };
12435 
12436 static enum rte_eth_input_set_field
12437 str2inset(char *string)
12438 {
12439 	uint16_t i;
12440 
12441 	static const struct {
12442 		char str[32];
12443 		enum rte_eth_input_set_field inset;
12444 	} inset_table[] = {
12445 		{"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
12446 		{"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
12447 		{"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
12448 		{"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
12449 		{"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
12450 		{"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
12451 		{"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
12452 		{"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
12453 		{"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
12454 		{"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
12455 		{"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
12456 		{"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
12457 		{"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
12458 		{"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
12459 		{"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
12460 		{"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
12461 		{"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
12462 		{"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
12463 		{"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
12464 		{"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
12465 		{"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
12466 		{"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
12467 		{"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
12468 		{"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
12469 		{"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
12470 		{"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
12471 		{"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
12472 		{"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
12473 		{"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
12474 		{"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
12475 		{"none", RTE_ETH_INPUT_SET_NONE},
12476 	};
12477 
12478 	for (i = 0; i < RTE_DIM(inset_table); i++) {
12479 		if (!strcmp(string, inset_table[i].str))
12480 			return inset_table[i].inset;
12481 	}
12482 
12483 	return RTE_ETH_INPUT_SET_UNKNOWN;
12484 }
12485 
12486 static void
12487 cmd_set_hash_input_set_parsed(void *parsed_result,
12488 			      __rte_unused struct cmdline *cl,
12489 			      __rte_unused void *data)
12490 {
12491 	struct cmd_set_hash_input_set_result *res = parsed_result;
12492 	struct rte_eth_hash_filter_info info;
12493 
12494 	memset(&info, 0, sizeof(info));
12495 	info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
12496 	info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12497 	info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12498 	info.info.input_set_conf.inset_size = 1;
12499 	if (!strcmp(res->select, "select"))
12500 		info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12501 	else if (!strcmp(res->select, "add"))
12502 		info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12503 	rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12504 				RTE_ETH_FILTER_SET, &info);
12505 }
12506 
12507 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
12508 	TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12509 		set_hash_input_set, "set_hash_input_set");
12510 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
12511 	TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
12512 		port_id, UINT16);
12513 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
12514 	TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12515 		flow_type, NULL);
12516 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
12517 	TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12518 		inset_field,
12519 		"ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12520 		"ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
12521 		"udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
12522 		"sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
12523 		"fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
12524 		"fld-8th#none");
12525 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
12526 	TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12527 		select, "select#add");
12528 
12529 cmdline_parse_inst_t cmd_set_hash_input_set = {
12530 	.f = cmd_set_hash_input_set_parsed,
12531 	.data = NULL,
12532 	.help_str = "set_hash_input_set <port_id> "
12533 	"ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12534 	"ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
12535 	"ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
12536 	"ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
12537 	"tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
12538 	"gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
12539 	"fld-7th|fld-8th|none select|add",
12540 	.tokens = {
12541 		(void *)&cmd_set_hash_input_set_cmd,
12542 		(void *)&cmd_set_hash_input_set_port_id,
12543 		(void *)&cmd_set_hash_input_set_flow_type,
12544 		(void *)&cmd_set_hash_input_set_field,
12545 		(void *)&cmd_set_hash_input_set_select,
12546 		NULL,
12547 	},
12548 };
12549 
12550 /* Set flow director input set */
12551 struct cmd_set_fdir_input_set_result {
12552 	cmdline_fixed_string_t set_fdir_input_set;
12553 	portid_t port_id;
12554 	cmdline_fixed_string_t flow_type;
12555 	cmdline_fixed_string_t inset_field;
12556 	cmdline_fixed_string_t select;
12557 };
12558 
12559 static void
12560 cmd_set_fdir_input_set_parsed(void *parsed_result,
12561 	__rte_unused struct cmdline *cl,
12562 	__rte_unused void *data)
12563 {
12564 	struct cmd_set_fdir_input_set_result *res = parsed_result;
12565 	struct rte_eth_fdir_filter_info info;
12566 
12567 	memset(&info, 0, sizeof(info));
12568 	info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
12569 	info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12570 	info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12571 	info.info.input_set_conf.inset_size = 1;
12572 	if (!strcmp(res->select, "select"))
12573 		info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12574 	else if (!strcmp(res->select, "add"))
12575 		info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12576 	rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
12577 		RTE_ETH_FILTER_SET, &info);
12578 }
12579 
12580 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
12581 	TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12582 	set_fdir_input_set, "set_fdir_input_set");
12583 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
12584 	TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
12585 	port_id, UINT16);
12586 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
12587 	TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12588 	flow_type,
12589 	"ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
12590 	"ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12591 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
12592 	TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12593 	inset_field,
12594 	"ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12595 	"ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
12596 	"ipv6-hop-limits#udp-src-port#udp-dst-port#"
12597 	"tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
12598 	"sctp-veri-tag#none");
12599 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
12600 	TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12601 	select, "select#add");
12602 
12603 cmdline_parse_inst_t cmd_set_fdir_input_set = {
12604 	.f = cmd_set_fdir_input_set_parsed,
12605 	.data = NULL,
12606 	.help_str = "set_fdir_input_set <port_id> "
12607 	"ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12608 	"ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
12609 	"ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
12610 	"ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
12611 	"ipv6-hop-limits|udp-src-port|udp-dst-port|"
12612 	"tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
12613 	"sctp-veri-tag|none select|add",
12614 	.tokens = {
12615 		(void *)&cmd_set_fdir_input_set_cmd,
12616 		(void *)&cmd_set_fdir_input_set_port_id,
12617 		(void *)&cmd_set_fdir_input_set_flow_type,
12618 		(void *)&cmd_set_fdir_input_set_field,
12619 		(void *)&cmd_set_fdir_input_set_select,
12620 		NULL,
12621 	},
12622 };
12623 
12624 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
12625 struct cmd_mcast_addr_result {
12626 	cmdline_fixed_string_t mcast_addr_cmd;
12627 	cmdline_fixed_string_t what;
12628 	uint16_t port_num;
12629 	struct rte_ether_addr mc_addr;
12630 };
12631 
12632 static void cmd_mcast_addr_parsed(void *parsed_result,
12633 		__attribute__((unused)) struct cmdline *cl,
12634 		__attribute__((unused)) void *data)
12635 {
12636 	struct cmd_mcast_addr_result *res = parsed_result;
12637 
12638 	if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
12639 		printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
12640 		       res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
12641 		       res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
12642 		       res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
12643 		return;
12644 	}
12645 	if (strcmp(res->what, "add") == 0)
12646 		mcast_addr_add(res->port_num, &res->mc_addr);
12647 	else
12648 		mcast_addr_remove(res->port_num, &res->mc_addr);
12649 }
12650 
12651 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
12652 	TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
12653 				 mcast_addr_cmd, "mcast_addr");
12654 cmdline_parse_token_string_t cmd_mcast_addr_what =
12655 	TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
12656 				 "add#remove");
12657 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
12658 	TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
12659 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
12660 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
12661 
12662 cmdline_parse_inst_t cmd_mcast_addr = {
12663 	.f = cmd_mcast_addr_parsed,
12664 	.data = (void *)0,
12665 	.help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
12666 		"Add/Remove multicast MAC address on port_id",
12667 	.tokens = {
12668 		(void *)&cmd_mcast_addr_cmd,
12669 		(void *)&cmd_mcast_addr_what,
12670 		(void *)&cmd_mcast_addr_portnum,
12671 		(void *)&cmd_mcast_addr_addr,
12672 		NULL,
12673 	},
12674 };
12675 
12676 /* l2 tunnel config
12677  * only support E-tag now.
12678  */
12679 
12680 /* Ether type config */
12681 struct cmd_config_l2_tunnel_eth_type_result {
12682 	cmdline_fixed_string_t port;
12683 	cmdline_fixed_string_t config;
12684 	cmdline_fixed_string_t all;
12685 	portid_t id;
12686 	cmdline_fixed_string_t l2_tunnel;
12687 	cmdline_fixed_string_t l2_tunnel_type;
12688 	cmdline_fixed_string_t eth_type;
12689 	uint16_t eth_type_val;
12690 };
12691 
12692 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
12693 	TOKEN_STRING_INITIALIZER
12694 		(struct cmd_config_l2_tunnel_eth_type_result,
12695 		 port, "port");
12696 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
12697 	TOKEN_STRING_INITIALIZER
12698 		(struct cmd_config_l2_tunnel_eth_type_result,
12699 		 config, "config");
12700 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
12701 	TOKEN_STRING_INITIALIZER
12702 		(struct cmd_config_l2_tunnel_eth_type_result,
12703 		 all, "all");
12704 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
12705 	TOKEN_NUM_INITIALIZER
12706 		(struct cmd_config_l2_tunnel_eth_type_result,
12707 		 id, UINT16);
12708 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
12709 	TOKEN_STRING_INITIALIZER
12710 		(struct cmd_config_l2_tunnel_eth_type_result,
12711 		 l2_tunnel, "l2-tunnel");
12712 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
12713 	TOKEN_STRING_INITIALIZER
12714 		(struct cmd_config_l2_tunnel_eth_type_result,
12715 		 l2_tunnel_type, "E-tag");
12716 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
12717 	TOKEN_STRING_INITIALIZER
12718 		(struct cmd_config_l2_tunnel_eth_type_result,
12719 		 eth_type, "ether-type");
12720 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
12721 	TOKEN_NUM_INITIALIZER
12722 		(struct cmd_config_l2_tunnel_eth_type_result,
12723 		 eth_type_val, UINT16);
12724 
12725 static enum rte_eth_tunnel_type
12726 str2fdir_l2_tunnel_type(char *string)
12727 {
12728 	uint32_t i = 0;
12729 
12730 	static const struct {
12731 		char str[32];
12732 		enum rte_eth_tunnel_type type;
12733 	} l2_tunnel_type_str[] = {
12734 		{"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
12735 	};
12736 
12737 	for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
12738 		if (!strcmp(l2_tunnel_type_str[i].str, string))
12739 			return l2_tunnel_type_str[i].type;
12740 	}
12741 	return RTE_TUNNEL_TYPE_NONE;
12742 }
12743 
12744 /* ether type config for all ports */
12745 static void
12746 cmd_config_l2_tunnel_eth_type_all_parsed
12747 	(void *parsed_result,
12748 	 __attribute__((unused)) struct cmdline *cl,
12749 	 __attribute__((unused)) void *data)
12750 {
12751 	struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
12752 	struct rte_eth_l2_tunnel_conf entry;
12753 	portid_t pid;
12754 
12755 	entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12756 	entry.ether_type = res->eth_type_val;
12757 
12758 	RTE_ETH_FOREACH_DEV(pid) {
12759 		rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
12760 	}
12761 }
12762 
12763 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
12764 	.f = cmd_config_l2_tunnel_eth_type_all_parsed,
12765 	.data = NULL,
12766 	.help_str = "port config all l2-tunnel E-tag ether-type <value>",
12767 	.tokens = {
12768 		(void *)&cmd_config_l2_tunnel_eth_type_port,
12769 		(void *)&cmd_config_l2_tunnel_eth_type_config,
12770 		(void *)&cmd_config_l2_tunnel_eth_type_all_str,
12771 		(void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12772 		(void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12773 		(void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12774 		(void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12775 		NULL,
12776 	},
12777 };
12778 
12779 /* ether type config for a specific port */
12780 static void
12781 cmd_config_l2_tunnel_eth_type_specific_parsed(
12782 	void *parsed_result,
12783 	__attribute__((unused)) struct cmdline *cl,
12784 	__attribute__((unused)) void *data)
12785 {
12786 	struct cmd_config_l2_tunnel_eth_type_result *res =
12787 		 parsed_result;
12788 	struct rte_eth_l2_tunnel_conf entry;
12789 
12790 	if (port_id_is_invalid(res->id, ENABLED_WARN))
12791 		return;
12792 
12793 	entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12794 	entry.ether_type = res->eth_type_val;
12795 
12796 	rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
12797 }
12798 
12799 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
12800 	.f = cmd_config_l2_tunnel_eth_type_specific_parsed,
12801 	.data = NULL,
12802 	.help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
12803 	.tokens = {
12804 		(void *)&cmd_config_l2_tunnel_eth_type_port,
12805 		(void *)&cmd_config_l2_tunnel_eth_type_config,
12806 		(void *)&cmd_config_l2_tunnel_eth_type_id,
12807 		(void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12808 		(void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12809 		(void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12810 		(void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12811 		NULL,
12812 	},
12813 };
12814 
12815 /* Enable/disable l2 tunnel */
12816 struct cmd_config_l2_tunnel_en_dis_result {
12817 	cmdline_fixed_string_t port;
12818 	cmdline_fixed_string_t config;
12819 	cmdline_fixed_string_t all;
12820 	portid_t id;
12821 	cmdline_fixed_string_t l2_tunnel;
12822 	cmdline_fixed_string_t l2_tunnel_type;
12823 	cmdline_fixed_string_t en_dis;
12824 };
12825 
12826 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
12827 	TOKEN_STRING_INITIALIZER
12828 		(struct cmd_config_l2_tunnel_en_dis_result,
12829 		 port, "port");
12830 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
12831 	TOKEN_STRING_INITIALIZER
12832 		(struct cmd_config_l2_tunnel_en_dis_result,
12833 		 config, "config");
12834 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
12835 	TOKEN_STRING_INITIALIZER
12836 		(struct cmd_config_l2_tunnel_en_dis_result,
12837 		 all, "all");
12838 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
12839 	TOKEN_NUM_INITIALIZER
12840 		(struct cmd_config_l2_tunnel_en_dis_result,
12841 		 id, UINT16);
12842 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
12843 	TOKEN_STRING_INITIALIZER
12844 		(struct cmd_config_l2_tunnel_en_dis_result,
12845 		 l2_tunnel, "l2-tunnel");
12846 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
12847 	TOKEN_STRING_INITIALIZER
12848 		(struct cmd_config_l2_tunnel_en_dis_result,
12849 		 l2_tunnel_type, "E-tag");
12850 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
12851 	TOKEN_STRING_INITIALIZER
12852 		(struct cmd_config_l2_tunnel_en_dis_result,
12853 		 en_dis, "enable#disable");
12854 
12855 /* enable/disable l2 tunnel for all ports */
12856 static void
12857 cmd_config_l2_tunnel_en_dis_all_parsed(
12858 	void *parsed_result,
12859 	__attribute__((unused)) struct cmdline *cl,
12860 	__attribute__((unused)) void *data)
12861 {
12862 	struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
12863 	struct rte_eth_l2_tunnel_conf entry;
12864 	portid_t pid;
12865 	uint8_t en;
12866 
12867 	entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12868 
12869 	if (!strcmp("enable", res->en_dis))
12870 		en = 1;
12871 	else
12872 		en = 0;
12873 
12874 	RTE_ETH_FOREACH_DEV(pid) {
12875 		rte_eth_dev_l2_tunnel_offload_set(pid,
12876 						  &entry,
12877 						  ETH_L2_TUNNEL_ENABLE_MASK,
12878 						  en);
12879 	}
12880 }
12881 
12882 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
12883 	.f = cmd_config_l2_tunnel_en_dis_all_parsed,
12884 	.data = NULL,
12885 	.help_str = "port config all l2-tunnel E-tag enable|disable",
12886 	.tokens = {
12887 		(void *)&cmd_config_l2_tunnel_en_dis_port,
12888 		(void *)&cmd_config_l2_tunnel_en_dis_config,
12889 		(void *)&cmd_config_l2_tunnel_en_dis_all_str,
12890 		(void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12891 		(void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12892 		(void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12893 		NULL,
12894 	},
12895 };
12896 
12897 /* enable/disable l2 tunnel for a port */
12898 static void
12899 cmd_config_l2_tunnel_en_dis_specific_parsed(
12900 	void *parsed_result,
12901 	__attribute__((unused)) struct cmdline *cl,
12902 	__attribute__((unused)) void *data)
12903 {
12904 	struct cmd_config_l2_tunnel_en_dis_result *res =
12905 		parsed_result;
12906 	struct rte_eth_l2_tunnel_conf entry;
12907 
12908 	if (port_id_is_invalid(res->id, ENABLED_WARN))
12909 		return;
12910 
12911 	entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12912 
12913 	if (!strcmp("enable", res->en_dis))
12914 		rte_eth_dev_l2_tunnel_offload_set(res->id,
12915 						  &entry,
12916 						  ETH_L2_TUNNEL_ENABLE_MASK,
12917 						  1);
12918 	else
12919 		rte_eth_dev_l2_tunnel_offload_set(res->id,
12920 						  &entry,
12921 						  ETH_L2_TUNNEL_ENABLE_MASK,
12922 						  0);
12923 }
12924 
12925 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
12926 	.f = cmd_config_l2_tunnel_en_dis_specific_parsed,
12927 	.data = NULL,
12928 	.help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
12929 	.tokens = {
12930 		(void *)&cmd_config_l2_tunnel_en_dis_port,
12931 		(void *)&cmd_config_l2_tunnel_en_dis_config,
12932 		(void *)&cmd_config_l2_tunnel_en_dis_id,
12933 		(void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12934 		(void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12935 		(void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12936 		NULL,
12937 	},
12938 };
12939 
12940 /* E-tag configuration */
12941 
12942 /* Common result structure for all E-tag configuration */
12943 struct cmd_config_e_tag_result {
12944 	cmdline_fixed_string_t e_tag;
12945 	cmdline_fixed_string_t set;
12946 	cmdline_fixed_string_t insertion;
12947 	cmdline_fixed_string_t stripping;
12948 	cmdline_fixed_string_t forwarding;
12949 	cmdline_fixed_string_t filter;
12950 	cmdline_fixed_string_t add;
12951 	cmdline_fixed_string_t del;
12952 	cmdline_fixed_string_t on;
12953 	cmdline_fixed_string_t off;
12954 	cmdline_fixed_string_t on_off;
12955 	cmdline_fixed_string_t port_tag_id;
12956 	uint32_t port_tag_id_val;
12957 	cmdline_fixed_string_t e_tag_id;
12958 	uint16_t e_tag_id_val;
12959 	cmdline_fixed_string_t dst_pool;
12960 	uint8_t dst_pool_val;
12961 	cmdline_fixed_string_t port;
12962 	portid_t port_id;
12963 	cmdline_fixed_string_t vf;
12964 	uint8_t vf_id;
12965 };
12966 
12967 /* Common CLI fields for all E-tag configuration */
12968 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
12969 	TOKEN_STRING_INITIALIZER
12970 		(struct cmd_config_e_tag_result,
12971 		 e_tag, "E-tag");
12972 cmdline_parse_token_string_t cmd_config_e_tag_set =
12973 	TOKEN_STRING_INITIALIZER
12974 		(struct cmd_config_e_tag_result,
12975 		 set, "set");
12976 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
12977 	TOKEN_STRING_INITIALIZER
12978 		(struct cmd_config_e_tag_result,
12979 		 insertion, "insertion");
12980 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
12981 	TOKEN_STRING_INITIALIZER
12982 		(struct cmd_config_e_tag_result,
12983 		 stripping, "stripping");
12984 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
12985 	TOKEN_STRING_INITIALIZER
12986 		(struct cmd_config_e_tag_result,
12987 		 forwarding, "forwarding");
12988 cmdline_parse_token_string_t cmd_config_e_tag_filter =
12989 	TOKEN_STRING_INITIALIZER
12990 		(struct cmd_config_e_tag_result,
12991 		 filter, "filter");
12992 cmdline_parse_token_string_t cmd_config_e_tag_add =
12993 	TOKEN_STRING_INITIALIZER
12994 		(struct cmd_config_e_tag_result,
12995 		 add, "add");
12996 cmdline_parse_token_string_t cmd_config_e_tag_del =
12997 	TOKEN_STRING_INITIALIZER
12998 		(struct cmd_config_e_tag_result,
12999 		 del, "del");
13000 cmdline_parse_token_string_t cmd_config_e_tag_on =
13001 	TOKEN_STRING_INITIALIZER
13002 		(struct cmd_config_e_tag_result,
13003 		 on, "on");
13004 cmdline_parse_token_string_t cmd_config_e_tag_off =
13005 	TOKEN_STRING_INITIALIZER
13006 		(struct cmd_config_e_tag_result,
13007 		 off, "off");
13008 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
13009 	TOKEN_STRING_INITIALIZER
13010 		(struct cmd_config_e_tag_result,
13011 		 on_off, "on#off");
13012 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
13013 	TOKEN_STRING_INITIALIZER
13014 		(struct cmd_config_e_tag_result,
13015 		 port_tag_id, "port-tag-id");
13016 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
13017 	TOKEN_NUM_INITIALIZER
13018 		(struct cmd_config_e_tag_result,
13019 		 port_tag_id_val, UINT32);
13020 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
13021 	TOKEN_STRING_INITIALIZER
13022 		(struct cmd_config_e_tag_result,
13023 		 e_tag_id, "e-tag-id");
13024 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
13025 	TOKEN_NUM_INITIALIZER
13026 		(struct cmd_config_e_tag_result,
13027 		 e_tag_id_val, UINT16);
13028 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
13029 	TOKEN_STRING_INITIALIZER
13030 		(struct cmd_config_e_tag_result,
13031 		 dst_pool, "dst-pool");
13032 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
13033 	TOKEN_NUM_INITIALIZER
13034 		(struct cmd_config_e_tag_result,
13035 		 dst_pool_val, UINT8);
13036 cmdline_parse_token_string_t cmd_config_e_tag_port =
13037 	TOKEN_STRING_INITIALIZER
13038 		(struct cmd_config_e_tag_result,
13039 		 port, "port");
13040 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
13041 	TOKEN_NUM_INITIALIZER
13042 		(struct cmd_config_e_tag_result,
13043 		 port_id, UINT16);
13044 cmdline_parse_token_string_t cmd_config_e_tag_vf =
13045 	TOKEN_STRING_INITIALIZER
13046 		(struct cmd_config_e_tag_result,
13047 		 vf, "vf");
13048 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
13049 	TOKEN_NUM_INITIALIZER
13050 		(struct cmd_config_e_tag_result,
13051 		 vf_id, UINT8);
13052 
13053 /* E-tag insertion configuration */
13054 static void
13055 cmd_config_e_tag_insertion_en_parsed(
13056 	void *parsed_result,
13057 	__attribute__((unused)) struct cmdline *cl,
13058 	__attribute__((unused)) void *data)
13059 {
13060 	struct cmd_config_e_tag_result *res =
13061 		parsed_result;
13062 	struct rte_eth_l2_tunnel_conf entry;
13063 
13064 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13065 		return;
13066 
13067 	entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13068 	entry.tunnel_id = res->port_tag_id_val;
13069 	entry.vf_id = res->vf_id;
13070 	rte_eth_dev_l2_tunnel_offload_set(res->port_id,
13071 					  &entry,
13072 					  ETH_L2_TUNNEL_INSERTION_MASK,
13073 					  1);
13074 }
13075 
13076 static void
13077 cmd_config_e_tag_insertion_dis_parsed(
13078 	void *parsed_result,
13079 	__attribute__((unused)) struct cmdline *cl,
13080 	__attribute__((unused)) void *data)
13081 {
13082 	struct cmd_config_e_tag_result *res =
13083 		parsed_result;
13084 	struct rte_eth_l2_tunnel_conf entry;
13085 
13086 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13087 		return;
13088 
13089 	entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13090 	entry.vf_id = res->vf_id;
13091 
13092 	rte_eth_dev_l2_tunnel_offload_set(res->port_id,
13093 					  &entry,
13094 					  ETH_L2_TUNNEL_INSERTION_MASK,
13095 					  0);
13096 }
13097 
13098 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
13099 	.f = cmd_config_e_tag_insertion_en_parsed,
13100 	.data = NULL,
13101 	.help_str = "E-tag ... : E-tag insertion enable",
13102 	.tokens = {
13103 		(void *)&cmd_config_e_tag_e_tag,
13104 		(void *)&cmd_config_e_tag_set,
13105 		(void *)&cmd_config_e_tag_insertion,
13106 		(void *)&cmd_config_e_tag_on,
13107 		(void *)&cmd_config_e_tag_port_tag_id,
13108 		(void *)&cmd_config_e_tag_port_tag_id_val,
13109 		(void *)&cmd_config_e_tag_port,
13110 		(void *)&cmd_config_e_tag_port_id,
13111 		(void *)&cmd_config_e_tag_vf,
13112 		(void *)&cmd_config_e_tag_vf_id,
13113 		NULL,
13114 	},
13115 };
13116 
13117 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
13118 	.f = cmd_config_e_tag_insertion_dis_parsed,
13119 	.data = NULL,
13120 	.help_str = "E-tag ... : E-tag insertion disable",
13121 	.tokens = {
13122 		(void *)&cmd_config_e_tag_e_tag,
13123 		(void *)&cmd_config_e_tag_set,
13124 		(void *)&cmd_config_e_tag_insertion,
13125 		(void *)&cmd_config_e_tag_off,
13126 		(void *)&cmd_config_e_tag_port,
13127 		(void *)&cmd_config_e_tag_port_id,
13128 		(void *)&cmd_config_e_tag_vf,
13129 		(void *)&cmd_config_e_tag_vf_id,
13130 		NULL,
13131 	},
13132 };
13133 
13134 /* E-tag stripping configuration */
13135 static void
13136 cmd_config_e_tag_stripping_parsed(
13137 	void *parsed_result,
13138 	__attribute__((unused)) struct cmdline *cl,
13139 	__attribute__((unused)) void *data)
13140 {
13141 	struct cmd_config_e_tag_result *res =
13142 		parsed_result;
13143 	struct rte_eth_l2_tunnel_conf entry;
13144 
13145 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13146 		return;
13147 
13148 	entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13149 
13150 	if (!strcmp(res->on_off, "on"))
13151 		rte_eth_dev_l2_tunnel_offload_set
13152 			(res->port_id,
13153 			 &entry,
13154 			 ETH_L2_TUNNEL_STRIPPING_MASK,
13155 			 1);
13156 	else
13157 		rte_eth_dev_l2_tunnel_offload_set
13158 			(res->port_id,
13159 			 &entry,
13160 			 ETH_L2_TUNNEL_STRIPPING_MASK,
13161 			 0);
13162 }
13163 
13164 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
13165 	.f = cmd_config_e_tag_stripping_parsed,
13166 	.data = NULL,
13167 	.help_str = "E-tag ... : E-tag stripping enable/disable",
13168 	.tokens = {
13169 		(void *)&cmd_config_e_tag_e_tag,
13170 		(void *)&cmd_config_e_tag_set,
13171 		(void *)&cmd_config_e_tag_stripping,
13172 		(void *)&cmd_config_e_tag_on_off,
13173 		(void *)&cmd_config_e_tag_port,
13174 		(void *)&cmd_config_e_tag_port_id,
13175 		NULL,
13176 	},
13177 };
13178 
13179 /* E-tag forwarding configuration */
13180 static void
13181 cmd_config_e_tag_forwarding_parsed(
13182 	void *parsed_result,
13183 	__attribute__((unused)) struct cmdline *cl,
13184 	__attribute__((unused)) void *data)
13185 {
13186 	struct cmd_config_e_tag_result *res = parsed_result;
13187 	struct rte_eth_l2_tunnel_conf entry;
13188 
13189 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13190 		return;
13191 
13192 	entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13193 
13194 	if (!strcmp(res->on_off, "on"))
13195 		rte_eth_dev_l2_tunnel_offload_set
13196 			(res->port_id,
13197 			 &entry,
13198 			 ETH_L2_TUNNEL_FORWARDING_MASK,
13199 			 1);
13200 	else
13201 		rte_eth_dev_l2_tunnel_offload_set
13202 			(res->port_id,
13203 			 &entry,
13204 			 ETH_L2_TUNNEL_FORWARDING_MASK,
13205 			 0);
13206 }
13207 
13208 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
13209 	.f = cmd_config_e_tag_forwarding_parsed,
13210 	.data = NULL,
13211 	.help_str = "E-tag ... : E-tag forwarding enable/disable",
13212 	.tokens = {
13213 		(void *)&cmd_config_e_tag_e_tag,
13214 		(void *)&cmd_config_e_tag_set,
13215 		(void *)&cmd_config_e_tag_forwarding,
13216 		(void *)&cmd_config_e_tag_on_off,
13217 		(void *)&cmd_config_e_tag_port,
13218 		(void *)&cmd_config_e_tag_port_id,
13219 		NULL,
13220 	},
13221 };
13222 
13223 /* E-tag filter configuration */
13224 static void
13225 cmd_config_e_tag_filter_add_parsed(
13226 	void *parsed_result,
13227 	__attribute__((unused)) struct cmdline *cl,
13228 	__attribute__((unused)) void *data)
13229 {
13230 	struct cmd_config_e_tag_result *res = parsed_result;
13231 	struct rte_eth_l2_tunnel_conf entry;
13232 	int ret = 0;
13233 
13234 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13235 		return;
13236 
13237 	if (res->e_tag_id_val > 0x3fff) {
13238 		printf("e-tag-id must be equal or less than 0x3fff.\n");
13239 		return;
13240 	}
13241 
13242 	ret = rte_eth_dev_filter_supported(res->port_id,
13243 					   RTE_ETH_FILTER_L2_TUNNEL);
13244 	if (ret < 0) {
13245 		printf("E-tag filter is not supported on port %u.\n",
13246 		       res->port_id);
13247 		return;
13248 	}
13249 
13250 	entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13251 	entry.tunnel_id = res->e_tag_id_val;
13252 	entry.pool = res->dst_pool_val;
13253 
13254 	ret = rte_eth_dev_filter_ctrl(res->port_id,
13255 				      RTE_ETH_FILTER_L2_TUNNEL,
13256 				      RTE_ETH_FILTER_ADD,
13257 				      &entry);
13258 	if (ret < 0)
13259 		printf("E-tag filter programming error: (%s)\n",
13260 		       strerror(-ret));
13261 }
13262 
13263 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
13264 	.f = cmd_config_e_tag_filter_add_parsed,
13265 	.data = NULL,
13266 	.help_str = "E-tag ... : E-tag filter add",
13267 	.tokens = {
13268 		(void *)&cmd_config_e_tag_e_tag,
13269 		(void *)&cmd_config_e_tag_set,
13270 		(void *)&cmd_config_e_tag_filter,
13271 		(void *)&cmd_config_e_tag_add,
13272 		(void *)&cmd_config_e_tag_e_tag_id,
13273 		(void *)&cmd_config_e_tag_e_tag_id_val,
13274 		(void *)&cmd_config_e_tag_dst_pool,
13275 		(void *)&cmd_config_e_tag_dst_pool_val,
13276 		(void *)&cmd_config_e_tag_port,
13277 		(void *)&cmd_config_e_tag_port_id,
13278 		NULL,
13279 	},
13280 };
13281 
13282 static void
13283 cmd_config_e_tag_filter_del_parsed(
13284 	void *parsed_result,
13285 	__attribute__((unused)) struct cmdline *cl,
13286 	__attribute__((unused)) void *data)
13287 {
13288 	struct cmd_config_e_tag_result *res = parsed_result;
13289 	struct rte_eth_l2_tunnel_conf entry;
13290 	int ret = 0;
13291 
13292 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13293 		return;
13294 
13295 	if (res->e_tag_id_val > 0x3fff) {
13296 		printf("e-tag-id must be less than 0x3fff.\n");
13297 		return;
13298 	}
13299 
13300 	ret = rte_eth_dev_filter_supported(res->port_id,
13301 					   RTE_ETH_FILTER_L2_TUNNEL);
13302 	if (ret < 0) {
13303 		printf("E-tag filter is not supported on port %u.\n",
13304 		       res->port_id);
13305 		return;
13306 	}
13307 
13308 	entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13309 	entry.tunnel_id = res->e_tag_id_val;
13310 
13311 	ret = rte_eth_dev_filter_ctrl(res->port_id,
13312 				      RTE_ETH_FILTER_L2_TUNNEL,
13313 				      RTE_ETH_FILTER_DELETE,
13314 				      &entry);
13315 	if (ret < 0)
13316 		printf("E-tag filter programming error: (%s)\n",
13317 		       strerror(-ret));
13318 }
13319 
13320 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
13321 	.f = cmd_config_e_tag_filter_del_parsed,
13322 	.data = NULL,
13323 	.help_str = "E-tag ... : E-tag filter delete",
13324 	.tokens = {
13325 		(void *)&cmd_config_e_tag_e_tag,
13326 		(void *)&cmd_config_e_tag_set,
13327 		(void *)&cmd_config_e_tag_filter,
13328 		(void *)&cmd_config_e_tag_del,
13329 		(void *)&cmd_config_e_tag_e_tag_id,
13330 		(void *)&cmd_config_e_tag_e_tag_id_val,
13331 		(void *)&cmd_config_e_tag_port,
13332 		(void *)&cmd_config_e_tag_port_id,
13333 		NULL,
13334 	},
13335 };
13336 
13337 /* vf vlan anti spoof configuration */
13338 
13339 /* Common result structure for vf vlan anti spoof */
13340 struct cmd_vf_vlan_anti_spoof_result {
13341 	cmdline_fixed_string_t set;
13342 	cmdline_fixed_string_t vf;
13343 	cmdline_fixed_string_t vlan;
13344 	cmdline_fixed_string_t antispoof;
13345 	portid_t port_id;
13346 	uint32_t vf_id;
13347 	cmdline_fixed_string_t on_off;
13348 };
13349 
13350 /* Common CLI fields for vf vlan anti spoof enable disable */
13351 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
13352 	TOKEN_STRING_INITIALIZER
13353 		(struct cmd_vf_vlan_anti_spoof_result,
13354 		 set, "set");
13355 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
13356 	TOKEN_STRING_INITIALIZER
13357 		(struct cmd_vf_vlan_anti_spoof_result,
13358 		 vf, "vf");
13359 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
13360 	TOKEN_STRING_INITIALIZER
13361 		(struct cmd_vf_vlan_anti_spoof_result,
13362 		 vlan, "vlan");
13363 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
13364 	TOKEN_STRING_INITIALIZER
13365 		(struct cmd_vf_vlan_anti_spoof_result,
13366 		 antispoof, "antispoof");
13367 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
13368 	TOKEN_NUM_INITIALIZER
13369 		(struct cmd_vf_vlan_anti_spoof_result,
13370 		 port_id, UINT16);
13371 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
13372 	TOKEN_NUM_INITIALIZER
13373 		(struct cmd_vf_vlan_anti_spoof_result,
13374 		 vf_id, UINT32);
13375 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
13376 	TOKEN_STRING_INITIALIZER
13377 		(struct cmd_vf_vlan_anti_spoof_result,
13378 		 on_off, "on#off");
13379 
13380 static void
13381 cmd_set_vf_vlan_anti_spoof_parsed(
13382 	void *parsed_result,
13383 	__attribute__((unused)) struct cmdline *cl,
13384 	__attribute__((unused)) void *data)
13385 {
13386 	struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
13387 	int ret = -ENOTSUP;
13388 
13389 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13390 
13391 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13392 		return;
13393 
13394 #ifdef RTE_LIBRTE_IXGBE_PMD
13395 	if (ret == -ENOTSUP)
13396 		ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
13397 				res->vf_id, is_on);
13398 #endif
13399 #ifdef RTE_LIBRTE_I40E_PMD
13400 	if (ret == -ENOTSUP)
13401 		ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
13402 				res->vf_id, is_on);
13403 #endif
13404 #ifdef RTE_LIBRTE_BNXT_PMD
13405 	if (ret == -ENOTSUP)
13406 		ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
13407 				res->vf_id, is_on);
13408 #endif
13409 
13410 	switch (ret) {
13411 	case 0:
13412 		break;
13413 	case -EINVAL:
13414 		printf("invalid vf_id %d\n", res->vf_id);
13415 		break;
13416 	case -ENODEV:
13417 		printf("invalid port_id %d\n", res->port_id);
13418 		break;
13419 	case -ENOTSUP:
13420 		printf("function not implemented\n");
13421 		break;
13422 	default:
13423 		printf("programming error: (%s)\n", strerror(-ret));
13424 	}
13425 }
13426 
13427 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
13428 	.f = cmd_set_vf_vlan_anti_spoof_parsed,
13429 	.data = NULL,
13430 	.help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
13431 	.tokens = {
13432 		(void *)&cmd_vf_vlan_anti_spoof_set,
13433 		(void *)&cmd_vf_vlan_anti_spoof_vf,
13434 		(void *)&cmd_vf_vlan_anti_spoof_vlan,
13435 		(void *)&cmd_vf_vlan_anti_spoof_antispoof,
13436 		(void *)&cmd_vf_vlan_anti_spoof_port_id,
13437 		(void *)&cmd_vf_vlan_anti_spoof_vf_id,
13438 		(void *)&cmd_vf_vlan_anti_spoof_on_off,
13439 		NULL,
13440 	},
13441 };
13442 
13443 /* vf mac anti spoof configuration */
13444 
13445 /* Common result structure for vf mac anti spoof */
13446 struct cmd_vf_mac_anti_spoof_result {
13447 	cmdline_fixed_string_t set;
13448 	cmdline_fixed_string_t vf;
13449 	cmdline_fixed_string_t mac;
13450 	cmdline_fixed_string_t antispoof;
13451 	portid_t port_id;
13452 	uint32_t vf_id;
13453 	cmdline_fixed_string_t on_off;
13454 };
13455 
13456 /* Common CLI fields for vf mac anti spoof enable disable */
13457 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
13458 	TOKEN_STRING_INITIALIZER
13459 		(struct cmd_vf_mac_anti_spoof_result,
13460 		 set, "set");
13461 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
13462 	TOKEN_STRING_INITIALIZER
13463 		(struct cmd_vf_mac_anti_spoof_result,
13464 		 vf, "vf");
13465 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
13466 	TOKEN_STRING_INITIALIZER
13467 		(struct cmd_vf_mac_anti_spoof_result,
13468 		 mac, "mac");
13469 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
13470 	TOKEN_STRING_INITIALIZER
13471 		(struct cmd_vf_mac_anti_spoof_result,
13472 		 antispoof, "antispoof");
13473 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
13474 	TOKEN_NUM_INITIALIZER
13475 		(struct cmd_vf_mac_anti_spoof_result,
13476 		 port_id, UINT16);
13477 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
13478 	TOKEN_NUM_INITIALIZER
13479 		(struct cmd_vf_mac_anti_spoof_result,
13480 		 vf_id, UINT32);
13481 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
13482 	TOKEN_STRING_INITIALIZER
13483 		(struct cmd_vf_mac_anti_spoof_result,
13484 		 on_off, "on#off");
13485 
13486 static void
13487 cmd_set_vf_mac_anti_spoof_parsed(
13488 	void *parsed_result,
13489 	__attribute__((unused)) struct cmdline *cl,
13490 	__attribute__((unused)) void *data)
13491 {
13492 	struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
13493 	int ret = -ENOTSUP;
13494 
13495 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13496 
13497 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13498 		return;
13499 
13500 #ifdef RTE_LIBRTE_IXGBE_PMD
13501 	if (ret == -ENOTSUP)
13502 		ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
13503 			res->vf_id, is_on);
13504 #endif
13505 #ifdef RTE_LIBRTE_I40E_PMD
13506 	if (ret == -ENOTSUP)
13507 		ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
13508 			res->vf_id, is_on);
13509 #endif
13510 #ifdef RTE_LIBRTE_BNXT_PMD
13511 	if (ret == -ENOTSUP)
13512 		ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
13513 			res->vf_id, is_on);
13514 #endif
13515 
13516 	switch (ret) {
13517 	case 0:
13518 		break;
13519 	case -EINVAL:
13520 		printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13521 		break;
13522 	case -ENODEV:
13523 		printf("invalid port_id %d\n", res->port_id);
13524 		break;
13525 	case -ENOTSUP:
13526 		printf("function not implemented\n");
13527 		break;
13528 	default:
13529 		printf("programming error: (%s)\n", strerror(-ret));
13530 	}
13531 }
13532 
13533 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
13534 	.f = cmd_set_vf_mac_anti_spoof_parsed,
13535 	.data = NULL,
13536 	.help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
13537 	.tokens = {
13538 		(void *)&cmd_vf_mac_anti_spoof_set,
13539 		(void *)&cmd_vf_mac_anti_spoof_vf,
13540 		(void *)&cmd_vf_mac_anti_spoof_mac,
13541 		(void *)&cmd_vf_mac_anti_spoof_antispoof,
13542 		(void *)&cmd_vf_mac_anti_spoof_port_id,
13543 		(void *)&cmd_vf_mac_anti_spoof_vf_id,
13544 		(void *)&cmd_vf_mac_anti_spoof_on_off,
13545 		NULL,
13546 	},
13547 };
13548 
13549 /* vf vlan strip queue configuration */
13550 
13551 /* Common result structure for vf mac anti spoof */
13552 struct cmd_vf_vlan_stripq_result {
13553 	cmdline_fixed_string_t set;
13554 	cmdline_fixed_string_t vf;
13555 	cmdline_fixed_string_t vlan;
13556 	cmdline_fixed_string_t stripq;
13557 	portid_t port_id;
13558 	uint16_t vf_id;
13559 	cmdline_fixed_string_t on_off;
13560 };
13561 
13562 /* Common CLI fields for vf vlan strip enable disable */
13563 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
13564 	TOKEN_STRING_INITIALIZER
13565 		(struct cmd_vf_vlan_stripq_result,
13566 		 set, "set");
13567 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
13568 	TOKEN_STRING_INITIALIZER
13569 		(struct cmd_vf_vlan_stripq_result,
13570 		 vf, "vf");
13571 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
13572 	TOKEN_STRING_INITIALIZER
13573 		(struct cmd_vf_vlan_stripq_result,
13574 		 vlan, "vlan");
13575 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
13576 	TOKEN_STRING_INITIALIZER
13577 		(struct cmd_vf_vlan_stripq_result,
13578 		 stripq, "stripq");
13579 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
13580 	TOKEN_NUM_INITIALIZER
13581 		(struct cmd_vf_vlan_stripq_result,
13582 		 port_id, UINT16);
13583 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
13584 	TOKEN_NUM_INITIALIZER
13585 		(struct cmd_vf_vlan_stripq_result,
13586 		 vf_id, UINT16);
13587 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
13588 	TOKEN_STRING_INITIALIZER
13589 		(struct cmd_vf_vlan_stripq_result,
13590 		 on_off, "on#off");
13591 
13592 static void
13593 cmd_set_vf_vlan_stripq_parsed(
13594 	void *parsed_result,
13595 	__attribute__((unused)) struct cmdline *cl,
13596 	__attribute__((unused)) void *data)
13597 {
13598 	struct cmd_vf_vlan_stripq_result *res = parsed_result;
13599 	int ret = -ENOTSUP;
13600 
13601 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13602 
13603 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13604 		return;
13605 
13606 #ifdef RTE_LIBRTE_IXGBE_PMD
13607 	if (ret == -ENOTSUP)
13608 		ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
13609 			res->vf_id, is_on);
13610 #endif
13611 #ifdef RTE_LIBRTE_I40E_PMD
13612 	if (ret == -ENOTSUP)
13613 		ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
13614 			res->vf_id, is_on);
13615 #endif
13616 #ifdef RTE_LIBRTE_BNXT_PMD
13617 	if (ret == -ENOTSUP)
13618 		ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
13619 			res->vf_id, is_on);
13620 #endif
13621 
13622 	switch (ret) {
13623 	case 0:
13624 		break;
13625 	case -EINVAL:
13626 		printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13627 		break;
13628 	case -ENODEV:
13629 		printf("invalid port_id %d\n", res->port_id);
13630 		break;
13631 	case -ENOTSUP:
13632 		printf("function not implemented\n");
13633 		break;
13634 	default:
13635 		printf("programming error: (%s)\n", strerror(-ret));
13636 	}
13637 }
13638 
13639 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
13640 	.f = cmd_set_vf_vlan_stripq_parsed,
13641 	.data = NULL,
13642 	.help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
13643 	.tokens = {
13644 		(void *)&cmd_vf_vlan_stripq_set,
13645 		(void *)&cmd_vf_vlan_stripq_vf,
13646 		(void *)&cmd_vf_vlan_stripq_vlan,
13647 		(void *)&cmd_vf_vlan_stripq_stripq,
13648 		(void *)&cmd_vf_vlan_stripq_port_id,
13649 		(void *)&cmd_vf_vlan_stripq_vf_id,
13650 		(void *)&cmd_vf_vlan_stripq_on_off,
13651 		NULL,
13652 	},
13653 };
13654 
13655 /* vf vlan insert configuration */
13656 
13657 /* Common result structure for vf vlan insert */
13658 struct cmd_vf_vlan_insert_result {
13659 	cmdline_fixed_string_t set;
13660 	cmdline_fixed_string_t vf;
13661 	cmdline_fixed_string_t vlan;
13662 	cmdline_fixed_string_t insert;
13663 	portid_t port_id;
13664 	uint16_t vf_id;
13665 	uint16_t vlan_id;
13666 };
13667 
13668 /* Common CLI fields for vf vlan insert enable disable */
13669 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
13670 	TOKEN_STRING_INITIALIZER
13671 		(struct cmd_vf_vlan_insert_result,
13672 		 set, "set");
13673 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
13674 	TOKEN_STRING_INITIALIZER
13675 		(struct cmd_vf_vlan_insert_result,
13676 		 vf, "vf");
13677 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
13678 	TOKEN_STRING_INITIALIZER
13679 		(struct cmd_vf_vlan_insert_result,
13680 		 vlan, "vlan");
13681 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
13682 	TOKEN_STRING_INITIALIZER
13683 		(struct cmd_vf_vlan_insert_result,
13684 		 insert, "insert");
13685 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
13686 	TOKEN_NUM_INITIALIZER
13687 		(struct cmd_vf_vlan_insert_result,
13688 		 port_id, UINT16);
13689 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
13690 	TOKEN_NUM_INITIALIZER
13691 		(struct cmd_vf_vlan_insert_result,
13692 		 vf_id, UINT16);
13693 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
13694 	TOKEN_NUM_INITIALIZER
13695 		(struct cmd_vf_vlan_insert_result,
13696 		 vlan_id, UINT16);
13697 
13698 static void
13699 cmd_set_vf_vlan_insert_parsed(
13700 	void *parsed_result,
13701 	__attribute__((unused)) struct cmdline *cl,
13702 	__attribute__((unused)) void *data)
13703 {
13704 	struct cmd_vf_vlan_insert_result *res = parsed_result;
13705 	int ret = -ENOTSUP;
13706 
13707 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13708 		return;
13709 
13710 #ifdef RTE_LIBRTE_IXGBE_PMD
13711 	if (ret == -ENOTSUP)
13712 		ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
13713 			res->vlan_id);
13714 #endif
13715 #ifdef RTE_LIBRTE_I40E_PMD
13716 	if (ret == -ENOTSUP)
13717 		ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
13718 			res->vlan_id);
13719 #endif
13720 #ifdef RTE_LIBRTE_BNXT_PMD
13721 	if (ret == -ENOTSUP)
13722 		ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
13723 			res->vlan_id);
13724 #endif
13725 
13726 	switch (ret) {
13727 	case 0:
13728 		break;
13729 	case -EINVAL:
13730 		printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
13731 		break;
13732 	case -ENODEV:
13733 		printf("invalid port_id %d\n", res->port_id);
13734 		break;
13735 	case -ENOTSUP:
13736 		printf("function not implemented\n");
13737 		break;
13738 	default:
13739 		printf("programming error: (%s)\n", strerror(-ret));
13740 	}
13741 }
13742 
13743 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
13744 	.f = cmd_set_vf_vlan_insert_parsed,
13745 	.data = NULL,
13746 	.help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
13747 	.tokens = {
13748 		(void *)&cmd_vf_vlan_insert_set,
13749 		(void *)&cmd_vf_vlan_insert_vf,
13750 		(void *)&cmd_vf_vlan_insert_vlan,
13751 		(void *)&cmd_vf_vlan_insert_insert,
13752 		(void *)&cmd_vf_vlan_insert_port_id,
13753 		(void *)&cmd_vf_vlan_insert_vf_id,
13754 		(void *)&cmd_vf_vlan_insert_vlan_id,
13755 		NULL,
13756 	},
13757 };
13758 
13759 /* tx loopback configuration */
13760 
13761 /* Common result structure for tx loopback */
13762 struct cmd_tx_loopback_result {
13763 	cmdline_fixed_string_t set;
13764 	cmdline_fixed_string_t tx;
13765 	cmdline_fixed_string_t loopback;
13766 	portid_t port_id;
13767 	cmdline_fixed_string_t on_off;
13768 };
13769 
13770 /* Common CLI fields for tx loopback enable disable */
13771 cmdline_parse_token_string_t cmd_tx_loopback_set =
13772 	TOKEN_STRING_INITIALIZER
13773 		(struct cmd_tx_loopback_result,
13774 		 set, "set");
13775 cmdline_parse_token_string_t cmd_tx_loopback_tx =
13776 	TOKEN_STRING_INITIALIZER
13777 		(struct cmd_tx_loopback_result,
13778 		 tx, "tx");
13779 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
13780 	TOKEN_STRING_INITIALIZER
13781 		(struct cmd_tx_loopback_result,
13782 		 loopback, "loopback");
13783 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
13784 	TOKEN_NUM_INITIALIZER
13785 		(struct cmd_tx_loopback_result,
13786 		 port_id, UINT16);
13787 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
13788 	TOKEN_STRING_INITIALIZER
13789 		(struct cmd_tx_loopback_result,
13790 		 on_off, "on#off");
13791 
13792 static void
13793 cmd_set_tx_loopback_parsed(
13794 	void *parsed_result,
13795 	__attribute__((unused)) struct cmdline *cl,
13796 	__attribute__((unused)) void *data)
13797 {
13798 	struct cmd_tx_loopback_result *res = parsed_result;
13799 	int ret = -ENOTSUP;
13800 
13801 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13802 
13803 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13804 		return;
13805 
13806 #ifdef RTE_LIBRTE_IXGBE_PMD
13807 	if (ret == -ENOTSUP)
13808 		ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
13809 #endif
13810 #ifdef RTE_LIBRTE_I40E_PMD
13811 	if (ret == -ENOTSUP)
13812 		ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
13813 #endif
13814 #ifdef RTE_LIBRTE_BNXT_PMD
13815 	if (ret == -ENOTSUP)
13816 		ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
13817 #endif
13818 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD
13819 	if (ret == -ENOTSUP)
13820 		ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
13821 #endif
13822 
13823 	switch (ret) {
13824 	case 0:
13825 		break;
13826 	case -EINVAL:
13827 		printf("invalid is_on %d\n", is_on);
13828 		break;
13829 	case -ENODEV:
13830 		printf("invalid port_id %d\n", res->port_id);
13831 		break;
13832 	case -ENOTSUP:
13833 		printf("function not implemented\n");
13834 		break;
13835 	default:
13836 		printf("programming error: (%s)\n", strerror(-ret));
13837 	}
13838 }
13839 
13840 cmdline_parse_inst_t cmd_set_tx_loopback = {
13841 	.f = cmd_set_tx_loopback_parsed,
13842 	.data = NULL,
13843 	.help_str = "set tx loopback <port_id> on|off",
13844 	.tokens = {
13845 		(void *)&cmd_tx_loopback_set,
13846 		(void *)&cmd_tx_loopback_tx,
13847 		(void *)&cmd_tx_loopback_loopback,
13848 		(void *)&cmd_tx_loopback_port_id,
13849 		(void *)&cmd_tx_loopback_on_off,
13850 		NULL,
13851 	},
13852 };
13853 
13854 /* all queues drop enable configuration */
13855 
13856 /* Common result structure for all queues drop enable */
13857 struct cmd_all_queues_drop_en_result {
13858 	cmdline_fixed_string_t set;
13859 	cmdline_fixed_string_t all;
13860 	cmdline_fixed_string_t queues;
13861 	cmdline_fixed_string_t drop;
13862 	portid_t port_id;
13863 	cmdline_fixed_string_t on_off;
13864 };
13865 
13866 /* Common CLI fields for tx loopback enable disable */
13867 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
13868 	TOKEN_STRING_INITIALIZER
13869 		(struct cmd_all_queues_drop_en_result,
13870 		 set, "set");
13871 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
13872 	TOKEN_STRING_INITIALIZER
13873 		(struct cmd_all_queues_drop_en_result,
13874 		 all, "all");
13875 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
13876 	TOKEN_STRING_INITIALIZER
13877 		(struct cmd_all_queues_drop_en_result,
13878 		 queues, "queues");
13879 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
13880 	TOKEN_STRING_INITIALIZER
13881 		(struct cmd_all_queues_drop_en_result,
13882 		 drop, "drop");
13883 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
13884 	TOKEN_NUM_INITIALIZER
13885 		(struct cmd_all_queues_drop_en_result,
13886 		 port_id, UINT16);
13887 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
13888 	TOKEN_STRING_INITIALIZER
13889 		(struct cmd_all_queues_drop_en_result,
13890 		 on_off, "on#off");
13891 
13892 static void
13893 cmd_set_all_queues_drop_en_parsed(
13894 	void *parsed_result,
13895 	__attribute__((unused)) struct cmdline *cl,
13896 	__attribute__((unused)) void *data)
13897 {
13898 	struct cmd_all_queues_drop_en_result *res = parsed_result;
13899 	int ret = -ENOTSUP;
13900 	int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13901 
13902 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13903 		return;
13904 
13905 #ifdef RTE_LIBRTE_IXGBE_PMD
13906 	if (ret == -ENOTSUP)
13907 		ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
13908 #endif
13909 #ifdef RTE_LIBRTE_BNXT_PMD
13910 	if (ret == -ENOTSUP)
13911 		ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
13912 #endif
13913 	switch (ret) {
13914 	case 0:
13915 		break;
13916 	case -EINVAL:
13917 		printf("invalid is_on %d\n", is_on);
13918 		break;
13919 	case -ENODEV:
13920 		printf("invalid port_id %d\n", res->port_id);
13921 		break;
13922 	case -ENOTSUP:
13923 		printf("function not implemented\n");
13924 		break;
13925 	default:
13926 		printf("programming error: (%s)\n", strerror(-ret));
13927 	}
13928 }
13929 
13930 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
13931 	.f = cmd_set_all_queues_drop_en_parsed,
13932 	.data = NULL,
13933 	.help_str = "set all queues drop <port_id> on|off",
13934 	.tokens = {
13935 		(void *)&cmd_all_queues_drop_en_set,
13936 		(void *)&cmd_all_queues_drop_en_all,
13937 		(void *)&cmd_all_queues_drop_en_queues,
13938 		(void *)&cmd_all_queues_drop_en_drop,
13939 		(void *)&cmd_all_queues_drop_en_port_id,
13940 		(void *)&cmd_all_queues_drop_en_on_off,
13941 		NULL,
13942 	},
13943 };
13944 
13945 /* vf split drop enable configuration */
13946 
13947 /* Common result structure for vf split drop enable */
13948 struct cmd_vf_split_drop_en_result {
13949 	cmdline_fixed_string_t set;
13950 	cmdline_fixed_string_t vf;
13951 	cmdline_fixed_string_t split;
13952 	cmdline_fixed_string_t drop;
13953 	portid_t port_id;
13954 	uint16_t vf_id;
13955 	cmdline_fixed_string_t on_off;
13956 };
13957 
13958 /* Common CLI fields for vf split drop enable disable */
13959 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
13960 	TOKEN_STRING_INITIALIZER
13961 		(struct cmd_vf_split_drop_en_result,
13962 		 set, "set");
13963 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
13964 	TOKEN_STRING_INITIALIZER
13965 		(struct cmd_vf_split_drop_en_result,
13966 		 vf, "vf");
13967 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
13968 	TOKEN_STRING_INITIALIZER
13969 		(struct cmd_vf_split_drop_en_result,
13970 		 split, "split");
13971 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
13972 	TOKEN_STRING_INITIALIZER
13973 		(struct cmd_vf_split_drop_en_result,
13974 		 drop, "drop");
13975 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
13976 	TOKEN_NUM_INITIALIZER
13977 		(struct cmd_vf_split_drop_en_result,
13978 		 port_id, UINT16);
13979 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
13980 	TOKEN_NUM_INITIALIZER
13981 		(struct cmd_vf_split_drop_en_result,
13982 		 vf_id, UINT16);
13983 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
13984 	TOKEN_STRING_INITIALIZER
13985 		(struct cmd_vf_split_drop_en_result,
13986 		 on_off, "on#off");
13987 
13988 static void
13989 cmd_set_vf_split_drop_en_parsed(
13990 	void *parsed_result,
13991 	__attribute__((unused)) struct cmdline *cl,
13992 	__attribute__((unused)) void *data)
13993 {
13994 	struct cmd_vf_split_drop_en_result *res = parsed_result;
13995 	int ret = -ENOTSUP;
13996 	int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13997 
13998 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13999 		return;
14000 
14001 #ifdef RTE_LIBRTE_IXGBE_PMD
14002 	ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
14003 			is_on);
14004 #endif
14005 	switch (ret) {
14006 	case 0:
14007 		break;
14008 	case -EINVAL:
14009 		printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14010 		break;
14011 	case -ENODEV:
14012 		printf("invalid port_id %d\n", res->port_id);
14013 		break;
14014 	case -ENOTSUP:
14015 		printf("not supported on port %d\n", res->port_id);
14016 		break;
14017 	default:
14018 		printf("programming error: (%s)\n", strerror(-ret));
14019 	}
14020 }
14021 
14022 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
14023 	.f = cmd_set_vf_split_drop_en_parsed,
14024 	.data = NULL,
14025 	.help_str = "set vf split drop <port_id> <vf_id> on|off",
14026 	.tokens = {
14027 		(void *)&cmd_vf_split_drop_en_set,
14028 		(void *)&cmd_vf_split_drop_en_vf,
14029 		(void *)&cmd_vf_split_drop_en_split,
14030 		(void *)&cmd_vf_split_drop_en_drop,
14031 		(void *)&cmd_vf_split_drop_en_port_id,
14032 		(void *)&cmd_vf_split_drop_en_vf_id,
14033 		(void *)&cmd_vf_split_drop_en_on_off,
14034 		NULL,
14035 	},
14036 };
14037 
14038 /* vf mac address configuration */
14039 
14040 /* Common result structure for vf mac address */
14041 struct cmd_set_vf_mac_addr_result {
14042 	cmdline_fixed_string_t set;
14043 	cmdline_fixed_string_t vf;
14044 	cmdline_fixed_string_t mac;
14045 	cmdline_fixed_string_t addr;
14046 	portid_t port_id;
14047 	uint16_t vf_id;
14048 	struct rte_ether_addr mac_addr;
14049 
14050 };
14051 
14052 /* Common CLI fields for vf split drop enable disable */
14053 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
14054 	TOKEN_STRING_INITIALIZER
14055 		(struct cmd_set_vf_mac_addr_result,
14056 		 set, "set");
14057 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
14058 	TOKEN_STRING_INITIALIZER
14059 		(struct cmd_set_vf_mac_addr_result,
14060 		 vf, "vf");
14061 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
14062 	TOKEN_STRING_INITIALIZER
14063 		(struct cmd_set_vf_mac_addr_result,
14064 		 mac, "mac");
14065 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
14066 	TOKEN_STRING_INITIALIZER
14067 		(struct cmd_set_vf_mac_addr_result,
14068 		 addr, "addr");
14069 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
14070 	TOKEN_NUM_INITIALIZER
14071 		(struct cmd_set_vf_mac_addr_result,
14072 		 port_id, UINT16);
14073 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
14074 	TOKEN_NUM_INITIALIZER
14075 		(struct cmd_set_vf_mac_addr_result,
14076 		 vf_id, UINT16);
14077 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
14078 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
14079 		 mac_addr);
14080 
14081 static void
14082 cmd_set_vf_mac_addr_parsed(
14083 	void *parsed_result,
14084 	__attribute__((unused)) struct cmdline *cl,
14085 	__attribute__((unused)) void *data)
14086 {
14087 	struct cmd_set_vf_mac_addr_result *res = parsed_result;
14088 	int ret = -ENOTSUP;
14089 
14090 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14091 		return;
14092 
14093 #ifdef RTE_LIBRTE_IXGBE_PMD
14094 	if (ret == -ENOTSUP)
14095 		ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
14096 				&res->mac_addr);
14097 #endif
14098 #ifdef RTE_LIBRTE_I40E_PMD
14099 	if (ret == -ENOTSUP)
14100 		ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
14101 				&res->mac_addr);
14102 #endif
14103 #ifdef RTE_LIBRTE_BNXT_PMD
14104 	if (ret == -ENOTSUP)
14105 		ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
14106 				&res->mac_addr);
14107 #endif
14108 
14109 	switch (ret) {
14110 	case 0:
14111 		break;
14112 	case -EINVAL:
14113 		printf("invalid vf_id %d or mac_addr\n", res->vf_id);
14114 		break;
14115 	case -ENODEV:
14116 		printf("invalid port_id %d\n", res->port_id);
14117 		break;
14118 	case -ENOTSUP:
14119 		printf("function not implemented\n");
14120 		break;
14121 	default:
14122 		printf("programming error: (%s)\n", strerror(-ret));
14123 	}
14124 }
14125 
14126 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
14127 	.f = cmd_set_vf_mac_addr_parsed,
14128 	.data = NULL,
14129 	.help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
14130 	.tokens = {
14131 		(void *)&cmd_set_vf_mac_addr_set,
14132 		(void *)&cmd_set_vf_mac_addr_vf,
14133 		(void *)&cmd_set_vf_mac_addr_mac,
14134 		(void *)&cmd_set_vf_mac_addr_addr,
14135 		(void *)&cmd_set_vf_mac_addr_port_id,
14136 		(void *)&cmd_set_vf_mac_addr_vf_id,
14137 		(void *)&cmd_set_vf_mac_addr_mac_addr,
14138 		NULL,
14139 	},
14140 };
14141 
14142 /* MACsec configuration */
14143 
14144 /* Common result structure for MACsec offload enable */
14145 struct cmd_macsec_offload_on_result {
14146 	cmdline_fixed_string_t set;
14147 	cmdline_fixed_string_t macsec;
14148 	cmdline_fixed_string_t offload;
14149 	portid_t port_id;
14150 	cmdline_fixed_string_t on;
14151 	cmdline_fixed_string_t encrypt;
14152 	cmdline_fixed_string_t en_on_off;
14153 	cmdline_fixed_string_t replay_protect;
14154 	cmdline_fixed_string_t rp_on_off;
14155 };
14156 
14157 /* Common CLI fields for MACsec offload disable */
14158 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
14159 	TOKEN_STRING_INITIALIZER
14160 		(struct cmd_macsec_offload_on_result,
14161 		 set, "set");
14162 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
14163 	TOKEN_STRING_INITIALIZER
14164 		(struct cmd_macsec_offload_on_result,
14165 		 macsec, "macsec");
14166 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
14167 	TOKEN_STRING_INITIALIZER
14168 		(struct cmd_macsec_offload_on_result,
14169 		 offload, "offload");
14170 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
14171 	TOKEN_NUM_INITIALIZER
14172 		(struct cmd_macsec_offload_on_result,
14173 		 port_id, UINT16);
14174 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
14175 	TOKEN_STRING_INITIALIZER
14176 		(struct cmd_macsec_offload_on_result,
14177 		 on, "on");
14178 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
14179 	TOKEN_STRING_INITIALIZER
14180 		(struct cmd_macsec_offload_on_result,
14181 		 encrypt, "encrypt");
14182 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
14183 	TOKEN_STRING_INITIALIZER
14184 		(struct cmd_macsec_offload_on_result,
14185 		 en_on_off, "on#off");
14186 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
14187 	TOKEN_STRING_INITIALIZER
14188 		(struct cmd_macsec_offload_on_result,
14189 		 replay_protect, "replay-protect");
14190 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
14191 	TOKEN_STRING_INITIALIZER
14192 		(struct cmd_macsec_offload_on_result,
14193 		 rp_on_off, "on#off");
14194 
14195 static void
14196 cmd_set_macsec_offload_on_parsed(
14197 	void *parsed_result,
14198 	__attribute__((unused)) struct cmdline *cl,
14199 	__attribute__((unused)) void *data)
14200 {
14201 	struct cmd_macsec_offload_on_result *res = parsed_result;
14202 	int ret = -ENOTSUP;
14203 	portid_t port_id = res->port_id;
14204 	int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
14205 	int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
14206 	struct rte_eth_dev_info dev_info;
14207 
14208 	if (port_id_is_invalid(port_id, ENABLED_WARN))
14209 		return;
14210 	if (!port_is_stopped(port_id)) {
14211 		printf("Please stop port %d first\n", port_id);
14212 		return;
14213 	}
14214 
14215 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
14216 	if (ret != 0)
14217 		return;
14218 
14219 	if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
14220 #ifdef RTE_LIBRTE_IXGBE_PMD
14221 		ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
14222 #endif
14223 	}
14224 	RTE_SET_USED(en);
14225 	RTE_SET_USED(rp);
14226 
14227 	switch (ret) {
14228 	case 0:
14229 		ports[port_id].dev_conf.txmode.offloads |=
14230 						DEV_TX_OFFLOAD_MACSEC_INSERT;
14231 		cmd_reconfig_device_queue(port_id, 1, 1);
14232 		break;
14233 	case -ENODEV:
14234 		printf("invalid port_id %d\n", port_id);
14235 		break;
14236 	case -ENOTSUP:
14237 		printf("not supported on port %d\n", port_id);
14238 		break;
14239 	default:
14240 		printf("programming error: (%s)\n", strerror(-ret));
14241 	}
14242 }
14243 
14244 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
14245 	.f = cmd_set_macsec_offload_on_parsed,
14246 	.data = NULL,
14247 	.help_str = "set macsec offload <port_id> on "
14248 		"encrypt on|off replay-protect on|off",
14249 	.tokens = {
14250 		(void *)&cmd_macsec_offload_on_set,
14251 		(void *)&cmd_macsec_offload_on_macsec,
14252 		(void *)&cmd_macsec_offload_on_offload,
14253 		(void *)&cmd_macsec_offload_on_port_id,
14254 		(void *)&cmd_macsec_offload_on_on,
14255 		(void *)&cmd_macsec_offload_on_encrypt,
14256 		(void *)&cmd_macsec_offload_on_en_on_off,
14257 		(void *)&cmd_macsec_offload_on_replay_protect,
14258 		(void *)&cmd_macsec_offload_on_rp_on_off,
14259 		NULL,
14260 	},
14261 };
14262 
14263 /* Common result structure for MACsec offload disable */
14264 struct cmd_macsec_offload_off_result {
14265 	cmdline_fixed_string_t set;
14266 	cmdline_fixed_string_t macsec;
14267 	cmdline_fixed_string_t offload;
14268 	portid_t port_id;
14269 	cmdline_fixed_string_t off;
14270 };
14271 
14272 /* Common CLI fields for MACsec offload disable */
14273 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
14274 	TOKEN_STRING_INITIALIZER
14275 		(struct cmd_macsec_offload_off_result,
14276 		 set, "set");
14277 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
14278 	TOKEN_STRING_INITIALIZER
14279 		(struct cmd_macsec_offload_off_result,
14280 		 macsec, "macsec");
14281 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
14282 	TOKEN_STRING_INITIALIZER
14283 		(struct cmd_macsec_offload_off_result,
14284 		 offload, "offload");
14285 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
14286 	TOKEN_NUM_INITIALIZER
14287 		(struct cmd_macsec_offload_off_result,
14288 		 port_id, UINT16);
14289 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
14290 	TOKEN_STRING_INITIALIZER
14291 		(struct cmd_macsec_offload_off_result,
14292 		 off, "off");
14293 
14294 static void
14295 cmd_set_macsec_offload_off_parsed(
14296 	void *parsed_result,
14297 	__attribute__((unused)) struct cmdline *cl,
14298 	__attribute__((unused)) void *data)
14299 {
14300 	struct cmd_macsec_offload_off_result *res = parsed_result;
14301 	int ret = -ENOTSUP;
14302 	struct rte_eth_dev_info dev_info;
14303 	portid_t port_id = res->port_id;
14304 
14305 	if (port_id_is_invalid(port_id, ENABLED_WARN))
14306 		return;
14307 	if (!port_is_stopped(port_id)) {
14308 		printf("Please stop port %d first\n", port_id);
14309 		return;
14310 	}
14311 
14312 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
14313 	if (ret != 0)
14314 		return;
14315 
14316 	if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
14317 #ifdef RTE_LIBRTE_IXGBE_PMD
14318 		ret = rte_pmd_ixgbe_macsec_disable(port_id);
14319 #endif
14320 	}
14321 	switch (ret) {
14322 	case 0:
14323 		ports[port_id].dev_conf.txmode.offloads &=
14324 						~DEV_TX_OFFLOAD_MACSEC_INSERT;
14325 		cmd_reconfig_device_queue(port_id, 1, 1);
14326 		break;
14327 	case -ENODEV:
14328 		printf("invalid port_id %d\n", port_id);
14329 		break;
14330 	case -ENOTSUP:
14331 		printf("not supported on port %d\n", port_id);
14332 		break;
14333 	default:
14334 		printf("programming error: (%s)\n", strerror(-ret));
14335 	}
14336 }
14337 
14338 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
14339 	.f = cmd_set_macsec_offload_off_parsed,
14340 	.data = NULL,
14341 	.help_str = "set macsec offload <port_id> off",
14342 	.tokens = {
14343 		(void *)&cmd_macsec_offload_off_set,
14344 		(void *)&cmd_macsec_offload_off_macsec,
14345 		(void *)&cmd_macsec_offload_off_offload,
14346 		(void *)&cmd_macsec_offload_off_port_id,
14347 		(void *)&cmd_macsec_offload_off_off,
14348 		NULL,
14349 	},
14350 };
14351 
14352 /* Common result structure for MACsec secure connection configure */
14353 struct cmd_macsec_sc_result {
14354 	cmdline_fixed_string_t set;
14355 	cmdline_fixed_string_t macsec;
14356 	cmdline_fixed_string_t sc;
14357 	cmdline_fixed_string_t tx_rx;
14358 	portid_t port_id;
14359 	struct rte_ether_addr mac;
14360 	uint16_t pi;
14361 };
14362 
14363 /* Common CLI fields for MACsec secure connection configure */
14364 cmdline_parse_token_string_t cmd_macsec_sc_set =
14365 	TOKEN_STRING_INITIALIZER
14366 		(struct cmd_macsec_sc_result,
14367 		 set, "set");
14368 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
14369 	TOKEN_STRING_INITIALIZER
14370 		(struct cmd_macsec_sc_result,
14371 		 macsec, "macsec");
14372 cmdline_parse_token_string_t cmd_macsec_sc_sc =
14373 	TOKEN_STRING_INITIALIZER
14374 		(struct cmd_macsec_sc_result,
14375 		 sc, "sc");
14376 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
14377 	TOKEN_STRING_INITIALIZER
14378 		(struct cmd_macsec_sc_result,
14379 		 tx_rx, "tx#rx");
14380 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
14381 	TOKEN_NUM_INITIALIZER
14382 		(struct cmd_macsec_sc_result,
14383 		 port_id, UINT16);
14384 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
14385 	TOKEN_ETHERADDR_INITIALIZER
14386 		(struct cmd_macsec_sc_result,
14387 		 mac);
14388 cmdline_parse_token_num_t cmd_macsec_sc_pi =
14389 	TOKEN_NUM_INITIALIZER
14390 		(struct cmd_macsec_sc_result,
14391 		 pi, UINT16);
14392 
14393 static void
14394 cmd_set_macsec_sc_parsed(
14395 	void *parsed_result,
14396 	__attribute__((unused)) struct cmdline *cl,
14397 	__attribute__((unused)) void *data)
14398 {
14399 	struct cmd_macsec_sc_result *res = parsed_result;
14400 	int ret = -ENOTSUP;
14401 	int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14402 
14403 #ifdef RTE_LIBRTE_IXGBE_PMD
14404 	ret = is_tx ?
14405 		rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
14406 				res->mac.addr_bytes) :
14407 		rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
14408 				res->mac.addr_bytes, res->pi);
14409 #endif
14410 	RTE_SET_USED(is_tx);
14411 
14412 	switch (ret) {
14413 	case 0:
14414 		break;
14415 	case -ENODEV:
14416 		printf("invalid port_id %d\n", res->port_id);
14417 		break;
14418 	case -ENOTSUP:
14419 		printf("not supported on port %d\n", res->port_id);
14420 		break;
14421 	default:
14422 		printf("programming error: (%s)\n", strerror(-ret));
14423 	}
14424 }
14425 
14426 cmdline_parse_inst_t cmd_set_macsec_sc = {
14427 	.f = cmd_set_macsec_sc_parsed,
14428 	.data = NULL,
14429 	.help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
14430 	.tokens = {
14431 		(void *)&cmd_macsec_sc_set,
14432 		(void *)&cmd_macsec_sc_macsec,
14433 		(void *)&cmd_macsec_sc_sc,
14434 		(void *)&cmd_macsec_sc_tx_rx,
14435 		(void *)&cmd_macsec_sc_port_id,
14436 		(void *)&cmd_macsec_sc_mac,
14437 		(void *)&cmd_macsec_sc_pi,
14438 		NULL,
14439 	},
14440 };
14441 
14442 /* Common result structure for MACsec secure connection configure */
14443 struct cmd_macsec_sa_result {
14444 	cmdline_fixed_string_t set;
14445 	cmdline_fixed_string_t macsec;
14446 	cmdline_fixed_string_t sa;
14447 	cmdline_fixed_string_t tx_rx;
14448 	portid_t port_id;
14449 	uint8_t idx;
14450 	uint8_t an;
14451 	uint32_t pn;
14452 	cmdline_fixed_string_t key;
14453 };
14454 
14455 /* Common CLI fields for MACsec secure connection configure */
14456 cmdline_parse_token_string_t cmd_macsec_sa_set =
14457 	TOKEN_STRING_INITIALIZER
14458 		(struct cmd_macsec_sa_result,
14459 		 set, "set");
14460 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
14461 	TOKEN_STRING_INITIALIZER
14462 		(struct cmd_macsec_sa_result,
14463 		 macsec, "macsec");
14464 cmdline_parse_token_string_t cmd_macsec_sa_sa =
14465 	TOKEN_STRING_INITIALIZER
14466 		(struct cmd_macsec_sa_result,
14467 		 sa, "sa");
14468 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
14469 	TOKEN_STRING_INITIALIZER
14470 		(struct cmd_macsec_sa_result,
14471 		 tx_rx, "tx#rx");
14472 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
14473 	TOKEN_NUM_INITIALIZER
14474 		(struct cmd_macsec_sa_result,
14475 		 port_id, UINT16);
14476 cmdline_parse_token_num_t cmd_macsec_sa_idx =
14477 	TOKEN_NUM_INITIALIZER
14478 		(struct cmd_macsec_sa_result,
14479 		 idx, UINT8);
14480 cmdline_parse_token_num_t cmd_macsec_sa_an =
14481 	TOKEN_NUM_INITIALIZER
14482 		(struct cmd_macsec_sa_result,
14483 		 an, UINT8);
14484 cmdline_parse_token_num_t cmd_macsec_sa_pn =
14485 	TOKEN_NUM_INITIALIZER
14486 		(struct cmd_macsec_sa_result,
14487 		 pn, UINT32);
14488 cmdline_parse_token_string_t cmd_macsec_sa_key =
14489 	TOKEN_STRING_INITIALIZER
14490 		(struct cmd_macsec_sa_result,
14491 		 key, NULL);
14492 
14493 static void
14494 cmd_set_macsec_sa_parsed(
14495 	void *parsed_result,
14496 	__attribute__((unused)) struct cmdline *cl,
14497 	__attribute__((unused)) void *data)
14498 {
14499 	struct cmd_macsec_sa_result *res = parsed_result;
14500 	int ret = -ENOTSUP;
14501 	int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14502 	uint8_t key[16] = { 0 };
14503 	uint8_t xdgt0;
14504 	uint8_t xdgt1;
14505 	int key_len;
14506 	int i;
14507 
14508 	key_len = strlen(res->key) / 2;
14509 	if (key_len > 16)
14510 		key_len = 16;
14511 
14512 	for (i = 0; i < key_len; i++) {
14513 		xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
14514 		if (xdgt0 == 0xFF)
14515 			return;
14516 		xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
14517 		if (xdgt1 == 0xFF)
14518 			return;
14519 		key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
14520 	}
14521 
14522 #ifdef RTE_LIBRTE_IXGBE_PMD
14523 	ret = is_tx ?
14524 		rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
14525 			res->idx, res->an, res->pn, key) :
14526 		rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
14527 			res->idx, res->an, res->pn, key);
14528 #endif
14529 	RTE_SET_USED(is_tx);
14530 	RTE_SET_USED(key);
14531 
14532 	switch (ret) {
14533 	case 0:
14534 		break;
14535 	case -EINVAL:
14536 		printf("invalid idx %d or an %d\n", res->idx, res->an);
14537 		break;
14538 	case -ENODEV:
14539 		printf("invalid port_id %d\n", res->port_id);
14540 		break;
14541 	case -ENOTSUP:
14542 		printf("not supported on port %d\n", res->port_id);
14543 		break;
14544 	default:
14545 		printf("programming error: (%s)\n", strerror(-ret));
14546 	}
14547 }
14548 
14549 cmdline_parse_inst_t cmd_set_macsec_sa = {
14550 	.f = cmd_set_macsec_sa_parsed,
14551 	.data = NULL,
14552 	.help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
14553 	.tokens = {
14554 		(void *)&cmd_macsec_sa_set,
14555 		(void *)&cmd_macsec_sa_macsec,
14556 		(void *)&cmd_macsec_sa_sa,
14557 		(void *)&cmd_macsec_sa_tx_rx,
14558 		(void *)&cmd_macsec_sa_port_id,
14559 		(void *)&cmd_macsec_sa_idx,
14560 		(void *)&cmd_macsec_sa_an,
14561 		(void *)&cmd_macsec_sa_pn,
14562 		(void *)&cmd_macsec_sa_key,
14563 		NULL,
14564 	},
14565 };
14566 
14567 /* VF unicast promiscuous mode configuration */
14568 
14569 /* Common result structure for VF unicast promiscuous mode */
14570 struct cmd_vf_promisc_result {
14571 	cmdline_fixed_string_t set;
14572 	cmdline_fixed_string_t vf;
14573 	cmdline_fixed_string_t promisc;
14574 	portid_t port_id;
14575 	uint32_t vf_id;
14576 	cmdline_fixed_string_t on_off;
14577 };
14578 
14579 /* Common CLI fields for VF unicast promiscuous mode enable disable */
14580 cmdline_parse_token_string_t cmd_vf_promisc_set =
14581 	TOKEN_STRING_INITIALIZER
14582 		(struct cmd_vf_promisc_result,
14583 		 set, "set");
14584 cmdline_parse_token_string_t cmd_vf_promisc_vf =
14585 	TOKEN_STRING_INITIALIZER
14586 		(struct cmd_vf_promisc_result,
14587 		 vf, "vf");
14588 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
14589 	TOKEN_STRING_INITIALIZER
14590 		(struct cmd_vf_promisc_result,
14591 		 promisc, "promisc");
14592 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
14593 	TOKEN_NUM_INITIALIZER
14594 		(struct cmd_vf_promisc_result,
14595 		 port_id, UINT16);
14596 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
14597 	TOKEN_NUM_INITIALIZER
14598 		(struct cmd_vf_promisc_result,
14599 		 vf_id, UINT32);
14600 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
14601 	TOKEN_STRING_INITIALIZER
14602 		(struct cmd_vf_promisc_result,
14603 		 on_off, "on#off");
14604 
14605 static void
14606 cmd_set_vf_promisc_parsed(
14607 	void *parsed_result,
14608 	__attribute__((unused)) struct cmdline *cl,
14609 	__attribute__((unused)) void *data)
14610 {
14611 	struct cmd_vf_promisc_result *res = parsed_result;
14612 	int ret = -ENOTSUP;
14613 
14614 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14615 
14616 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14617 		return;
14618 
14619 #ifdef RTE_LIBRTE_I40E_PMD
14620 	ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
14621 						  res->vf_id, is_on);
14622 #endif
14623 
14624 	switch (ret) {
14625 	case 0:
14626 		break;
14627 	case -EINVAL:
14628 		printf("invalid vf_id %d\n", res->vf_id);
14629 		break;
14630 	case -ENODEV:
14631 		printf("invalid port_id %d\n", res->port_id);
14632 		break;
14633 	case -ENOTSUP:
14634 		printf("function not implemented\n");
14635 		break;
14636 	default:
14637 		printf("programming error: (%s)\n", strerror(-ret));
14638 	}
14639 }
14640 
14641 cmdline_parse_inst_t cmd_set_vf_promisc = {
14642 	.f = cmd_set_vf_promisc_parsed,
14643 	.data = NULL,
14644 	.help_str = "set vf promisc <port_id> <vf_id> on|off: "
14645 		"Set unicast promiscuous mode for a VF from the PF",
14646 	.tokens = {
14647 		(void *)&cmd_vf_promisc_set,
14648 		(void *)&cmd_vf_promisc_vf,
14649 		(void *)&cmd_vf_promisc_promisc,
14650 		(void *)&cmd_vf_promisc_port_id,
14651 		(void *)&cmd_vf_promisc_vf_id,
14652 		(void *)&cmd_vf_promisc_on_off,
14653 		NULL,
14654 	},
14655 };
14656 
14657 /* VF multicast promiscuous mode configuration */
14658 
14659 /* Common result structure for VF multicast promiscuous mode */
14660 struct cmd_vf_allmulti_result {
14661 	cmdline_fixed_string_t set;
14662 	cmdline_fixed_string_t vf;
14663 	cmdline_fixed_string_t allmulti;
14664 	portid_t port_id;
14665 	uint32_t vf_id;
14666 	cmdline_fixed_string_t on_off;
14667 };
14668 
14669 /* Common CLI fields for VF multicast promiscuous mode enable disable */
14670 cmdline_parse_token_string_t cmd_vf_allmulti_set =
14671 	TOKEN_STRING_INITIALIZER
14672 		(struct cmd_vf_allmulti_result,
14673 		 set, "set");
14674 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
14675 	TOKEN_STRING_INITIALIZER
14676 		(struct cmd_vf_allmulti_result,
14677 		 vf, "vf");
14678 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
14679 	TOKEN_STRING_INITIALIZER
14680 		(struct cmd_vf_allmulti_result,
14681 		 allmulti, "allmulti");
14682 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
14683 	TOKEN_NUM_INITIALIZER
14684 		(struct cmd_vf_allmulti_result,
14685 		 port_id, UINT16);
14686 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
14687 	TOKEN_NUM_INITIALIZER
14688 		(struct cmd_vf_allmulti_result,
14689 		 vf_id, UINT32);
14690 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
14691 	TOKEN_STRING_INITIALIZER
14692 		(struct cmd_vf_allmulti_result,
14693 		 on_off, "on#off");
14694 
14695 static void
14696 cmd_set_vf_allmulti_parsed(
14697 	void *parsed_result,
14698 	__attribute__((unused)) struct cmdline *cl,
14699 	__attribute__((unused)) void *data)
14700 {
14701 	struct cmd_vf_allmulti_result *res = parsed_result;
14702 	int ret = -ENOTSUP;
14703 
14704 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14705 
14706 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14707 		return;
14708 
14709 #ifdef RTE_LIBRTE_I40E_PMD
14710 	ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
14711 						    res->vf_id, is_on);
14712 #endif
14713 
14714 	switch (ret) {
14715 	case 0:
14716 		break;
14717 	case -EINVAL:
14718 		printf("invalid vf_id %d\n", res->vf_id);
14719 		break;
14720 	case -ENODEV:
14721 		printf("invalid port_id %d\n", res->port_id);
14722 		break;
14723 	case -ENOTSUP:
14724 		printf("function not implemented\n");
14725 		break;
14726 	default:
14727 		printf("programming error: (%s)\n", strerror(-ret));
14728 	}
14729 }
14730 
14731 cmdline_parse_inst_t cmd_set_vf_allmulti = {
14732 	.f = cmd_set_vf_allmulti_parsed,
14733 	.data = NULL,
14734 	.help_str = "set vf allmulti <port_id> <vf_id> on|off: "
14735 		"Set multicast promiscuous mode for a VF from the PF",
14736 	.tokens = {
14737 		(void *)&cmd_vf_allmulti_set,
14738 		(void *)&cmd_vf_allmulti_vf,
14739 		(void *)&cmd_vf_allmulti_allmulti,
14740 		(void *)&cmd_vf_allmulti_port_id,
14741 		(void *)&cmd_vf_allmulti_vf_id,
14742 		(void *)&cmd_vf_allmulti_on_off,
14743 		NULL,
14744 	},
14745 };
14746 
14747 /* vf broadcast mode configuration */
14748 
14749 /* Common result structure for vf broadcast */
14750 struct cmd_set_vf_broadcast_result {
14751 	cmdline_fixed_string_t set;
14752 	cmdline_fixed_string_t vf;
14753 	cmdline_fixed_string_t broadcast;
14754 	portid_t port_id;
14755 	uint16_t vf_id;
14756 	cmdline_fixed_string_t on_off;
14757 };
14758 
14759 /* Common CLI fields for vf broadcast enable disable */
14760 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
14761 	TOKEN_STRING_INITIALIZER
14762 		(struct cmd_set_vf_broadcast_result,
14763 		 set, "set");
14764 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
14765 	TOKEN_STRING_INITIALIZER
14766 		(struct cmd_set_vf_broadcast_result,
14767 		 vf, "vf");
14768 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
14769 	TOKEN_STRING_INITIALIZER
14770 		(struct cmd_set_vf_broadcast_result,
14771 		 broadcast, "broadcast");
14772 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
14773 	TOKEN_NUM_INITIALIZER
14774 		(struct cmd_set_vf_broadcast_result,
14775 		 port_id, UINT16);
14776 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
14777 	TOKEN_NUM_INITIALIZER
14778 		(struct cmd_set_vf_broadcast_result,
14779 		 vf_id, UINT16);
14780 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
14781 	TOKEN_STRING_INITIALIZER
14782 		(struct cmd_set_vf_broadcast_result,
14783 		 on_off, "on#off");
14784 
14785 static void
14786 cmd_set_vf_broadcast_parsed(
14787 	void *parsed_result,
14788 	__attribute__((unused)) struct cmdline *cl,
14789 	__attribute__((unused)) void *data)
14790 {
14791 	struct cmd_set_vf_broadcast_result *res = parsed_result;
14792 	int ret = -ENOTSUP;
14793 
14794 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14795 
14796 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14797 		return;
14798 
14799 #ifdef RTE_LIBRTE_I40E_PMD
14800 	ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
14801 					    res->vf_id, is_on);
14802 #endif
14803 
14804 	switch (ret) {
14805 	case 0:
14806 		break;
14807 	case -EINVAL:
14808 		printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14809 		break;
14810 	case -ENODEV:
14811 		printf("invalid port_id %d\n", res->port_id);
14812 		break;
14813 	case -ENOTSUP:
14814 		printf("function not implemented\n");
14815 		break;
14816 	default:
14817 		printf("programming error: (%s)\n", strerror(-ret));
14818 	}
14819 }
14820 
14821 cmdline_parse_inst_t cmd_set_vf_broadcast = {
14822 	.f = cmd_set_vf_broadcast_parsed,
14823 	.data = NULL,
14824 	.help_str = "set vf broadcast <port_id> <vf_id> on|off",
14825 	.tokens = {
14826 		(void *)&cmd_set_vf_broadcast_set,
14827 		(void *)&cmd_set_vf_broadcast_vf,
14828 		(void *)&cmd_set_vf_broadcast_broadcast,
14829 		(void *)&cmd_set_vf_broadcast_port_id,
14830 		(void *)&cmd_set_vf_broadcast_vf_id,
14831 		(void *)&cmd_set_vf_broadcast_on_off,
14832 		NULL,
14833 	},
14834 };
14835 
14836 /* vf vlan tag configuration */
14837 
14838 /* Common result structure for vf vlan tag */
14839 struct cmd_set_vf_vlan_tag_result {
14840 	cmdline_fixed_string_t set;
14841 	cmdline_fixed_string_t vf;
14842 	cmdline_fixed_string_t vlan;
14843 	cmdline_fixed_string_t tag;
14844 	portid_t port_id;
14845 	uint16_t vf_id;
14846 	cmdline_fixed_string_t on_off;
14847 };
14848 
14849 /* Common CLI fields for vf vlan tag enable disable */
14850 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
14851 	TOKEN_STRING_INITIALIZER
14852 		(struct cmd_set_vf_vlan_tag_result,
14853 		 set, "set");
14854 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
14855 	TOKEN_STRING_INITIALIZER
14856 		(struct cmd_set_vf_vlan_tag_result,
14857 		 vf, "vf");
14858 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
14859 	TOKEN_STRING_INITIALIZER
14860 		(struct cmd_set_vf_vlan_tag_result,
14861 		 vlan, "vlan");
14862 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
14863 	TOKEN_STRING_INITIALIZER
14864 		(struct cmd_set_vf_vlan_tag_result,
14865 		 tag, "tag");
14866 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
14867 	TOKEN_NUM_INITIALIZER
14868 		(struct cmd_set_vf_vlan_tag_result,
14869 		 port_id, UINT16);
14870 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
14871 	TOKEN_NUM_INITIALIZER
14872 		(struct cmd_set_vf_vlan_tag_result,
14873 		 vf_id, UINT16);
14874 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
14875 	TOKEN_STRING_INITIALIZER
14876 		(struct cmd_set_vf_vlan_tag_result,
14877 		 on_off, "on#off");
14878 
14879 static void
14880 cmd_set_vf_vlan_tag_parsed(
14881 	void *parsed_result,
14882 	__attribute__((unused)) struct cmdline *cl,
14883 	__attribute__((unused)) void *data)
14884 {
14885 	struct cmd_set_vf_vlan_tag_result *res = parsed_result;
14886 	int ret = -ENOTSUP;
14887 
14888 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14889 
14890 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14891 		return;
14892 
14893 #ifdef RTE_LIBRTE_I40E_PMD
14894 	ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
14895 					   res->vf_id, is_on);
14896 #endif
14897 
14898 	switch (ret) {
14899 	case 0:
14900 		break;
14901 	case -EINVAL:
14902 		printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14903 		break;
14904 	case -ENODEV:
14905 		printf("invalid port_id %d\n", res->port_id);
14906 		break;
14907 	case -ENOTSUP:
14908 		printf("function not implemented\n");
14909 		break;
14910 	default:
14911 		printf("programming error: (%s)\n", strerror(-ret));
14912 	}
14913 }
14914 
14915 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
14916 	.f = cmd_set_vf_vlan_tag_parsed,
14917 	.data = NULL,
14918 	.help_str = "set vf vlan tag <port_id> <vf_id> on|off",
14919 	.tokens = {
14920 		(void *)&cmd_set_vf_vlan_tag_set,
14921 		(void *)&cmd_set_vf_vlan_tag_vf,
14922 		(void *)&cmd_set_vf_vlan_tag_vlan,
14923 		(void *)&cmd_set_vf_vlan_tag_tag,
14924 		(void *)&cmd_set_vf_vlan_tag_port_id,
14925 		(void *)&cmd_set_vf_vlan_tag_vf_id,
14926 		(void *)&cmd_set_vf_vlan_tag_on_off,
14927 		NULL,
14928 	},
14929 };
14930 
14931 /* Common definition of VF and TC TX bandwidth configuration */
14932 struct cmd_vf_tc_bw_result {
14933 	cmdline_fixed_string_t set;
14934 	cmdline_fixed_string_t vf;
14935 	cmdline_fixed_string_t tc;
14936 	cmdline_fixed_string_t tx;
14937 	cmdline_fixed_string_t min_bw;
14938 	cmdline_fixed_string_t max_bw;
14939 	cmdline_fixed_string_t strict_link_prio;
14940 	portid_t port_id;
14941 	uint16_t vf_id;
14942 	uint8_t tc_no;
14943 	uint32_t bw;
14944 	cmdline_fixed_string_t bw_list;
14945 	uint8_t tc_map;
14946 };
14947 
14948 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
14949 	TOKEN_STRING_INITIALIZER
14950 		(struct cmd_vf_tc_bw_result,
14951 		 set, "set");
14952 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
14953 	TOKEN_STRING_INITIALIZER
14954 		(struct cmd_vf_tc_bw_result,
14955 		 vf, "vf");
14956 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
14957 	TOKEN_STRING_INITIALIZER
14958 		(struct cmd_vf_tc_bw_result,
14959 		 tc, "tc");
14960 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
14961 	TOKEN_STRING_INITIALIZER
14962 		(struct cmd_vf_tc_bw_result,
14963 		 tx, "tx");
14964 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
14965 	TOKEN_STRING_INITIALIZER
14966 		(struct cmd_vf_tc_bw_result,
14967 		 strict_link_prio, "strict-link-priority");
14968 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
14969 	TOKEN_STRING_INITIALIZER
14970 		(struct cmd_vf_tc_bw_result,
14971 		 min_bw, "min-bandwidth");
14972 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
14973 	TOKEN_STRING_INITIALIZER
14974 		(struct cmd_vf_tc_bw_result,
14975 		 max_bw, "max-bandwidth");
14976 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
14977 	TOKEN_NUM_INITIALIZER
14978 		(struct cmd_vf_tc_bw_result,
14979 		 port_id, UINT16);
14980 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
14981 	TOKEN_NUM_INITIALIZER
14982 		(struct cmd_vf_tc_bw_result,
14983 		 vf_id, UINT16);
14984 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
14985 	TOKEN_NUM_INITIALIZER
14986 		(struct cmd_vf_tc_bw_result,
14987 		 tc_no, UINT8);
14988 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
14989 	TOKEN_NUM_INITIALIZER
14990 		(struct cmd_vf_tc_bw_result,
14991 		 bw, UINT32);
14992 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
14993 	TOKEN_STRING_INITIALIZER
14994 		(struct cmd_vf_tc_bw_result,
14995 		 bw_list, NULL);
14996 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
14997 	TOKEN_NUM_INITIALIZER
14998 		(struct cmd_vf_tc_bw_result,
14999 		 tc_map, UINT8);
15000 
15001 /* VF max bandwidth setting */
15002 static void
15003 cmd_vf_max_bw_parsed(
15004 	void *parsed_result,
15005 	__attribute__((unused)) struct cmdline *cl,
15006 	__attribute__((unused)) void *data)
15007 {
15008 	struct cmd_vf_tc_bw_result *res = parsed_result;
15009 	int ret = -ENOTSUP;
15010 
15011 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15012 		return;
15013 
15014 #ifdef RTE_LIBRTE_I40E_PMD
15015 	ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
15016 					 res->vf_id, res->bw);
15017 #endif
15018 
15019 	switch (ret) {
15020 	case 0:
15021 		break;
15022 	case -EINVAL:
15023 		printf("invalid vf_id %d or bandwidth %d\n",
15024 		       res->vf_id, res->bw);
15025 		break;
15026 	case -ENODEV:
15027 		printf("invalid port_id %d\n", res->port_id);
15028 		break;
15029 	case -ENOTSUP:
15030 		printf("function not implemented\n");
15031 		break;
15032 	default:
15033 		printf("programming error: (%s)\n", strerror(-ret));
15034 	}
15035 }
15036 
15037 cmdline_parse_inst_t cmd_vf_max_bw = {
15038 	.f = cmd_vf_max_bw_parsed,
15039 	.data = NULL,
15040 	.help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
15041 	.tokens = {
15042 		(void *)&cmd_vf_tc_bw_set,
15043 		(void *)&cmd_vf_tc_bw_vf,
15044 		(void *)&cmd_vf_tc_bw_tx,
15045 		(void *)&cmd_vf_tc_bw_max_bw,
15046 		(void *)&cmd_vf_tc_bw_port_id,
15047 		(void *)&cmd_vf_tc_bw_vf_id,
15048 		(void *)&cmd_vf_tc_bw_bw,
15049 		NULL,
15050 	},
15051 };
15052 
15053 static int
15054 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
15055 			   uint8_t *tc_num,
15056 			   char *str)
15057 {
15058 	uint32_t size;
15059 	const char *p, *p0 = str;
15060 	char s[256];
15061 	char *end;
15062 	char *str_fld[16];
15063 	uint16_t i;
15064 	int ret;
15065 
15066 	p = strchr(p0, '(');
15067 	if (p == NULL) {
15068 		printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
15069 		return -1;
15070 	}
15071 	p++;
15072 	p0 = strchr(p, ')');
15073 	if (p0 == NULL) {
15074 		printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
15075 		return -1;
15076 	}
15077 	size = p0 - p;
15078 	if (size >= sizeof(s)) {
15079 		printf("The string size exceeds the internal buffer size\n");
15080 		return -1;
15081 	}
15082 	snprintf(s, sizeof(s), "%.*s", size, p);
15083 	ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
15084 	if (ret <= 0) {
15085 		printf("Failed to get the bandwidth list. ");
15086 		return -1;
15087 	}
15088 	*tc_num = ret;
15089 	for (i = 0; i < ret; i++)
15090 		bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
15091 
15092 	return 0;
15093 }
15094 
15095 /* TC min bandwidth setting */
15096 static void
15097 cmd_vf_tc_min_bw_parsed(
15098 	void *parsed_result,
15099 	__attribute__((unused)) struct cmdline *cl,
15100 	__attribute__((unused)) void *data)
15101 {
15102 	struct cmd_vf_tc_bw_result *res = parsed_result;
15103 	uint8_t tc_num;
15104 	uint8_t bw[16];
15105 	int ret = -ENOTSUP;
15106 
15107 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15108 		return;
15109 
15110 	ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
15111 	if (ret)
15112 		return;
15113 
15114 #ifdef RTE_LIBRTE_I40E_PMD
15115 	ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
15116 					      tc_num, bw);
15117 #endif
15118 
15119 	switch (ret) {
15120 	case 0:
15121 		break;
15122 	case -EINVAL:
15123 		printf("invalid vf_id %d or bandwidth\n", res->vf_id);
15124 		break;
15125 	case -ENODEV:
15126 		printf("invalid port_id %d\n", res->port_id);
15127 		break;
15128 	case -ENOTSUP:
15129 		printf("function not implemented\n");
15130 		break;
15131 	default:
15132 		printf("programming error: (%s)\n", strerror(-ret));
15133 	}
15134 }
15135 
15136 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
15137 	.f = cmd_vf_tc_min_bw_parsed,
15138 	.data = NULL,
15139 	.help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
15140 		    " <bw1, bw2, ...>",
15141 	.tokens = {
15142 		(void *)&cmd_vf_tc_bw_set,
15143 		(void *)&cmd_vf_tc_bw_vf,
15144 		(void *)&cmd_vf_tc_bw_tc,
15145 		(void *)&cmd_vf_tc_bw_tx,
15146 		(void *)&cmd_vf_tc_bw_min_bw,
15147 		(void *)&cmd_vf_tc_bw_port_id,
15148 		(void *)&cmd_vf_tc_bw_vf_id,
15149 		(void *)&cmd_vf_tc_bw_bw_list,
15150 		NULL,
15151 	},
15152 };
15153 
15154 static void
15155 cmd_tc_min_bw_parsed(
15156 	void *parsed_result,
15157 	__attribute__((unused)) struct cmdline *cl,
15158 	__attribute__((unused)) void *data)
15159 {
15160 	struct cmd_vf_tc_bw_result *res = parsed_result;
15161 	struct rte_port *port;
15162 	uint8_t tc_num;
15163 	uint8_t bw[16];
15164 	int ret = -ENOTSUP;
15165 
15166 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15167 		return;
15168 
15169 	port = &ports[res->port_id];
15170 	/** Check if the port is not started **/
15171 	if (port->port_status != RTE_PORT_STOPPED) {
15172 		printf("Please stop port %d first\n", res->port_id);
15173 		return;
15174 	}
15175 
15176 	ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
15177 	if (ret)
15178 		return;
15179 
15180 #ifdef RTE_LIBRTE_IXGBE_PMD
15181 	ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
15182 #endif
15183 
15184 	switch (ret) {
15185 	case 0:
15186 		break;
15187 	case -EINVAL:
15188 		printf("invalid bandwidth\n");
15189 		break;
15190 	case -ENODEV:
15191 		printf("invalid port_id %d\n", res->port_id);
15192 		break;
15193 	case -ENOTSUP:
15194 		printf("function not implemented\n");
15195 		break;
15196 	default:
15197 		printf("programming error: (%s)\n", strerror(-ret));
15198 	}
15199 }
15200 
15201 cmdline_parse_inst_t cmd_tc_min_bw = {
15202 	.f = cmd_tc_min_bw_parsed,
15203 	.data = NULL,
15204 	.help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
15205 	.tokens = {
15206 		(void *)&cmd_vf_tc_bw_set,
15207 		(void *)&cmd_vf_tc_bw_tc,
15208 		(void *)&cmd_vf_tc_bw_tx,
15209 		(void *)&cmd_vf_tc_bw_min_bw,
15210 		(void *)&cmd_vf_tc_bw_port_id,
15211 		(void *)&cmd_vf_tc_bw_bw_list,
15212 		NULL,
15213 	},
15214 };
15215 
15216 /* TC max bandwidth setting */
15217 static void
15218 cmd_vf_tc_max_bw_parsed(
15219 	void *parsed_result,
15220 	__attribute__((unused)) struct cmdline *cl,
15221 	__attribute__((unused)) void *data)
15222 {
15223 	struct cmd_vf_tc_bw_result *res = parsed_result;
15224 	int ret = -ENOTSUP;
15225 
15226 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15227 		return;
15228 
15229 #ifdef RTE_LIBRTE_I40E_PMD
15230 	ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
15231 					    res->tc_no, res->bw);
15232 #endif
15233 
15234 	switch (ret) {
15235 	case 0:
15236 		break;
15237 	case -EINVAL:
15238 		printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
15239 		       res->vf_id, res->tc_no, res->bw);
15240 		break;
15241 	case -ENODEV:
15242 		printf("invalid port_id %d\n", res->port_id);
15243 		break;
15244 	case -ENOTSUP:
15245 		printf("function not implemented\n");
15246 		break;
15247 	default:
15248 		printf("programming error: (%s)\n", strerror(-ret));
15249 	}
15250 }
15251 
15252 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
15253 	.f = cmd_vf_tc_max_bw_parsed,
15254 	.data = NULL,
15255 	.help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
15256 		    " <bandwidth>",
15257 	.tokens = {
15258 		(void *)&cmd_vf_tc_bw_set,
15259 		(void *)&cmd_vf_tc_bw_vf,
15260 		(void *)&cmd_vf_tc_bw_tc,
15261 		(void *)&cmd_vf_tc_bw_tx,
15262 		(void *)&cmd_vf_tc_bw_max_bw,
15263 		(void *)&cmd_vf_tc_bw_port_id,
15264 		(void *)&cmd_vf_tc_bw_vf_id,
15265 		(void *)&cmd_vf_tc_bw_tc_no,
15266 		(void *)&cmd_vf_tc_bw_bw,
15267 		NULL,
15268 	},
15269 };
15270 
15271 
15272 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
15273 
15274 /* *** Set Port default Traffic Management Hierarchy *** */
15275 struct cmd_set_port_tm_hierarchy_default_result {
15276 	cmdline_fixed_string_t set;
15277 	cmdline_fixed_string_t port;
15278 	cmdline_fixed_string_t tm;
15279 	cmdline_fixed_string_t hierarchy;
15280 	cmdline_fixed_string_t def;
15281 	portid_t port_id;
15282 };
15283 
15284 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_set =
15285 	TOKEN_STRING_INITIALIZER(
15286 		struct cmd_set_port_tm_hierarchy_default_result, set, "set");
15287 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_port =
15288 	TOKEN_STRING_INITIALIZER(
15289 		struct cmd_set_port_tm_hierarchy_default_result, port, "port");
15290 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_tm =
15291 	TOKEN_STRING_INITIALIZER(
15292 		struct cmd_set_port_tm_hierarchy_default_result, tm, "tm");
15293 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_hierarchy =
15294 	TOKEN_STRING_INITIALIZER(
15295 		struct cmd_set_port_tm_hierarchy_default_result,
15296 			hierarchy, "hierarchy");
15297 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_default =
15298 	TOKEN_STRING_INITIALIZER(
15299 		struct cmd_set_port_tm_hierarchy_default_result,
15300 			def, "default");
15301 cmdline_parse_token_num_t cmd_set_port_tm_hierarchy_default_port_id =
15302 	TOKEN_NUM_INITIALIZER(
15303 		struct cmd_set_port_tm_hierarchy_default_result,
15304 			port_id, UINT16);
15305 
15306 static void cmd_set_port_tm_hierarchy_default_parsed(void *parsed_result,
15307 	__attribute__((unused)) struct cmdline *cl,
15308 	__attribute__((unused)) void *data)
15309 {
15310 	struct cmd_set_port_tm_hierarchy_default_result *res = parsed_result;
15311 	struct rte_port *p;
15312 	portid_t port_id = res->port_id;
15313 
15314 	if (port_id_is_invalid(port_id, ENABLED_WARN))
15315 		return;
15316 
15317 	p = &ports[port_id];
15318 
15319 	/* Forward mode: tm */
15320 	if (strcmp(cur_fwd_config.fwd_eng->fwd_mode_name, "softnic")) {
15321 		printf("  softnicfwd mode not enabled(error)\n");
15322 		return;
15323 	}
15324 
15325 	/* Set the default tm hierarchy */
15326 	p->softport.default_tm_hierarchy_enable = 1;
15327 }
15328 
15329 cmdline_parse_inst_t cmd_set_port_tm_hierarchy_default = {
15330 	.f = cmd_set_port_tm_hierarchy_default_parsed,
15331 	.data = NULL,
15332 	.help_str = "set port tm hierarchy default <port_id>",
15333 	.tokens = {
15334 		(void *)&cmd_set_port_tm_hierarchy_default_set,
15335 		(void *)&cmd_set_port_tm_hierarchy_default_port,
15336 		(void *)&cmd_set_port_tm_hierarchy_default_tm,
15337 		(void *)&cmd_set_port_tm_hierarchy_default_hierarchy,
15338 		(void *)&cmd_set_port_tm_hierarchy_default_default,
15339 		(void *)&cmd_set_port_tm_hierarchy_default_port_id,
15340 		NULL,
15341 	},
15342 };
15343 #endif
15344 
15345 /** Set VXLAN encapsulation details */
15346 struct cmd_set_vxlan_result {
15347 	cmdline_fixed_string_t set;
15348 	cmdline_fixed_string_t vxlan;
15349 	cmdline_fixed_string_t pos_token;
15350 	cmdline_fixed_string_t ip_version;
15351 	uint32_t vlan_present:1;
15352 	uint32_t vni;
15353 	uint16_t udp_src;
15354 	uint16_t udp_dst;
15355 	cmdline_ipaddr_t ip_src;
15356 	cmdline_ipaddr_t ip_dst;
15357 	uint16_t tci;
15358 	uint8_t tos;
15359 	uint8_t ttl;
15360 	struct rte_ether_addr eth_src;
15361 	struct rte_ether_addr eth_dst;
15362 };
15363 
15364 cmdline_parse_token_string_t cmd_set_vxlan_set =
15365 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
15366 cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
15367 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
15368 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
15369 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15370 				 "vxlan-tos-ttl");
15371 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
15372 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15373 				 "vxlan-with-vlan");
15374 cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
15375 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15376 				 "ip-version");
15377 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
15378 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
15379 				 "ipv4#ipv6");
15380 cmdline_parse_token_string_t cmd_set_vxlan_vni =
15381 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15382 				 "vni");
15383 cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
15384 	TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, UINT32);
15385 cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
15386 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15387 				 "udp-src");
15388 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
15389 	TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, UINT16);
15390 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
15391 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15392 				 "udp-dst");
15393 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
15394 	TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, UINT16);
15395 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
15396 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15397 				 "ip-tos");
15398 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
15399 	TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, UINT8);
15400 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
15401 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15402 				 "ip-ttl");
15403 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
15404 	TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, UINT8);
15405 cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
15406 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15407 				 "ip-src");
15408 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
15409 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
15410 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
15411 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15412 				 "ip-dst");
15413 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
15414 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
15415 cmdline_parse_token_string_t cmd_set_vxlan_vlan =
15416 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15417 				 "vlan-tci");
15418 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
15419 	TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, UINT16);
15420 cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
15421 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15422 				 "eth-src");
15423 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
15424 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
15425 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
15426 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15427 				 "eth-dst");
15428 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
15429 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
15430 
15431 static void cmd_set_vxlan_parsed(void *parsed_result,
15432 	__attribute__((unused)) struct cmdline *cl,
15433 	__attribute__((unused)) void *data)
15434 {
15435 	struct cmd_set_vxlan_result *res = parsed_result;
15436 	union {
15437 		uint32_t vxlan_id;
15438 		uint8_t vni[4];
15439 	} id = {
15440 		.vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
15441 	};
15442 
15443 	vxlan_encap_conf.select_tos_ttl = 0;
15444 	if (strcmp(res->vxlan, "vxlan") == 0)
15445 		vxlan_encap_conf.select_vlan = 0;
15446 	else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
15447 		vxlan_encap_conf.select_vlan = 1;
15448 	else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
15449 		vxlan_encap_conf.select_vlan = 0;
15450 		vxlan_encap_conf.select_tos_ttl = 1;
15451 	}
15452 	if (strcmp(res->ip_version, "ipv4") == 0)
15453 		vxlan_encap_conf.select_ipv4 = 1;
15454 	else if (strcmp(res->ip_version, "ipv6") == 0)
15455 		vxlan_encap_conf.select_ipv4 = 0;
15456 	else
15457 		return;
15458 	rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
15459 	vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
15460 	vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
15461 	vxlan_encap_conf.ip_tos = res->tos;
15462 	vxlan_encap_conf.ip_ttl = res->ttl;
15463 	if (vxlan_encap_conf.select_ipv4) {
15464 		IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
15465 		IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
15466 	} else {
15467 		IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
15468 		IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
15469 	}
15470 	if (vxlan_encap_conf.select_vlan)
15471 		vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15472 	rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
15473 		   RTE_ETHER_ADDR_LEN);
15474 	rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15475 		   RTE_ETHER_ADDR_LEN);
15476 }
15477 
15478 cmdline_parse_inst_t cmd_set_vxlan = {
15479 	.f = cmd_set_vxlan_parsed,
15480 	.data = NULL,
15481 	.help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
15482 		" <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
15483 		" eth-src <eth-src> eth-dst <eth-dst>",
15484 	.tokens = {
15485 		(void *)&cmd_set_vxlan_set,
15486 		(void *)&cmd_set_vxlan_vxlan,
15487 		(void *)&cmd_set_vxlan_ip_version,
15488 		(void *)&cmd_set_vxlan_ip_version_value,
15489 		(void *)&cmd_set_vxlan_vni,
15490 		(void *)&cmd_set_vxlan_vni_value,
15491 		(void *)&cmd_set_vxlan_udp_src,
15492 		(void *)&cmd_set_vxlan_udp_src_value,
15493 		(void *)&cmd_set_vxlan_udp_dst,
15494 		(void *)&cmd_set_vxlan_udp_dst_value,
15495 		(void *)&cmd_set_vxlan_ip_src,
15496 		(void *)&cmd_set_vxlan_ip_src_value,
15497 		(void *)&cmd_set_vxlan_ip_dst,
15498 		(void *)&cmd_set_vxlan_ip_dst_value,
15499 		(void *)&cmd_set_vxlan_eth_src,
15500 		(void *)&cmd_set_vxlan_eth_src_value,
15501 		(void *)&cmd_set_vxlan_eth_dst,
15502 		(void *)&cmd_set_vxlan_eth_dst_value,
15503 		NULL,
15504 	},
15505 };
15506 
15507 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
15508 	.f = cmd_set_vxlan_parsed,
15509 	.data = NULL,
15510 	.help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
15511 		" <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
15512 		" ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15513 		" eth-dst <eth-dst>",
15514 	.tokens = {
15515 		(void *)&cmd_set_vxlan_set,
15516 		(void *)&cmd_set_vxlan_vxlan_tos_ttl,
15517 		(void *)&cmd_set_vxlan_ip_version,
15518 		(void *)&cmd_set_vxlan_ip_version_value,
15519 		(void *)&cmd_set_vxlan_vni,
15520 		(void *)&cmd_set_vxlan_vni_value,
15521 		(void *)&cmd_set_vxlan_udp_src,
15522 		(void *)&cmd_set_vxlan_udp_src_value,
15523 		(void *)&cmd_set_vxlan_udp_dst,
15524 		(void *)&cmd_set_vxlan_udp_dst_value,
15525 		(void *)&cmd_set_vxlan_ip_tos,
15526 		(void *)&cmd_set_vxlan_ip_tos_value,
15527 		(void *)&cmd_set_vxlan_ip_ttl,
15528 		(void *)&cmd_set_vxlan_ip_ttl_value,
15529 		(void *)&cmd_set_vxlan_ip_src,
15530 		(void *)&cmd_set_vxlan_ip_src_value,
15531 		(void *)&cmd_set_vxlan_ip_dst,
15532 		(void *)&cmd_set_vxlan_ip_dst_value,
15533 		(void *)&cmd_set_vxlan_eth_src,
15534 		(void *)&cmd_set_vxlan_eth_src_value,
15535 		(void *)&cmd_set_vxlan_eth_dst,
15536 		(void *)&cmd_set_vxlan_eth_dst_value,
15537 		NULL,
15538 	},
15539 };
15540 
15541 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
15542 	.f = cmd_set_vxlan_parsed,
15543 	.data = NULL,
15544 	.help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
15545 		" udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
15546 		" <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
15547 		" <eth-dst>",
15548 	.tokens = {
15549 		(void *)&cmd_set_vxlan_set,
15550 		(void *)&cmd_set_vxlan_vxlan_with_vlan,
15551 		(void *)&cmd_set_vxlan_ip_version,
15552 		(void *)&cmd_set_vxlan_ip_version_value,
15553 		(void *)&cmd_set_vxlan_vni,
15554 		(void *)&cmd_set_vxlan_vni_value,
15555 		(void *)&cmd_set_vxlan_udp_src,
15556 		(void *)&cmd_set_vxlan_udp_src_value,
15557 		(void *)&cmd_set_vxlan_udp_dst,
15558 		(void *)&cmd_set_vxlan_udp_dst_value,
15559 		(void *)&cmd_set_vxlan_ip_src,
15560 		(void *)&cmd_set_vxlan_ip_src_value,
15561 		(void *)&cmd_set_vxlan_ip_dst,
15562 		(void *)&cmd_set_vxlan_ip_dst_value,
15563 		(void *)&cmd_set_vxlan_vlan,
15564 		(void *)&cmd_set_vxlan_vlan_value,
15565 		(void *)&cmd_set_vxlan_eth_src,
15566 		(void *)&cmd_set_vxlan_eth_src_value,
15567 		(void *)&cmd_set_vxlan_eth_dst,
15568 		(void *)&cmd_set_vxlan_eth_dst_value,
15569 		NULL,
15570 	},
15571 };
15572 
15573 /** Set NVGRE encapsulation details */
15574 struct cmd_set_nvgre_result {
15575 	cmdline_fixed_string_t set;
15576 	cmdline_fixed_string_t nvgre;
15577 	cmdline_fixed_string_t pos_token;
15578 	cmdline_fixed_string_t ip_version;
15579 	uint32_t tni;
15580 	cmdline_ipaddr_t ip_src;
15581 	cmdline_ipaddr_t ip_dst;
15582 	uint16_t tci;
15583 	struct rte_ether_addr eth_src;
15584 	struct rte_ether_addr eth_dst;
15585 };
15586 
15587 cmdline_parse_token_string_t cmd_set_nvgre_set =
15588 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
15589 cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
15590 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
15591 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
15592 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
15593 				 "nvgre-with-vlan");
15594 cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
15595 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15596 				 "ip-version");
15597 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
15598 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
15599 				 "ipv4#ipv6");
15600 cmdline_parse_token_string_t cmd_set_nvgre_tni =
15601 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15602 				 "tni");
15603 cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
15604 	TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, UINT32);
15605 cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
15606 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15607 				 "ip-src");
15608 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
15609 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
15610 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
15611 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15612 				 "ip-dst");
15613 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
15614 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
15615 cmdline_parse_token_string_t cmd_set_nvgre_vlan =
15616 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15617 				 "vlan-tci");
15618 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
15619 	TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, UINT16);
15620 cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
15621 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15622 				 "eth-src");
15623 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
15624 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
15625 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
15626 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15627 				 "eth-dst");
15628 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
15629 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
15630 
15631 static void cmd_set_nvgre_parsed(void *parsed_result,
15632 	__attribute__((unused)) struct cmdline *cl,
15633 	__attribute__((unused)) void *data)
15634 {
15635 	struct cmd_set_nvgre_result *res = parsed_result;
15636 	union {
15637 		uint32_t nvgre_tni;
15638 		uint8_t tni[4];
15639 	} id = {
15640 		.nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
15641 	};
15642 
15643 	if (strcmp(res->nvgre, "nvgre") == 0)
15644 		nvgre_encap_conf.select_vlan = 0;
15645 	else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
15646 		nvgre_encap_conf.select_vlan = 1;
15647 	if (strcmp(res->ip_version, "ipv4") == 0)
15648 		nvgre_encap_conf.select_ipv4 = 1;
15649 	else if (strcmp(res->ip_version, "ipv6") == 0)
15650 		nvgre_encap_conf.select_ipv4 = 0;
15651 	else
15652 		return;
15653 	rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
15654 	if (nvgre_encap_conf.select_ipv4) {
15655 		IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
15656 		IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
15657 	} else {
15658 		IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
15659 		IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
15660 	}
15661 	if (nvgre_encap_conf.select_vlan)
15662 		nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15663 	rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
15664 		   RTE_ETHER_ADDR_LEN);
15665 	rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15666 		   RTE_ETHER_ADDR_LEN);
15667 }
15668 
15669 cmdline_parse_inst_t cmd_set_nvgre = {
15670 	.f = cmd_set_nvgre_parsed,
15671 	.data = NULL,
15672 	.help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
15673 		" <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15674 		" eth-dst <eth-dst>",
15675 	.tokens = {
15676 		(void *)&cmd_set_nvgre_set,
15677 		(void *)&cmd_set_nvgre_nvgre,
15678 		(void *)&cmd_set_nvgre_ip_version,
15679 		(void *)&cmd_set_nvgre_ip_version_value,
15680 		(void *)&cmd_set_nvgre_tni,
15681 		(void *)&cmd_set_nvgre_tni_value,
15682 		(void *)&cmd_set_nvgre_ip_src,
15683 		(void *)&cmd_set_nvgre_ip_src_value,
15684 		(void *)&cmd_set_nvgre_ip_dst,
15685 		(void *)&cmd_set_nvgre_ip_dst_value,
15686 		(void *)&cmd_set_nvgre_eth_src,
15687 		(void *)&cmd_set_nvgre_eth_src_value,
15688 		(void *)&cmd_set_nvgre_eth_dst,
15689 		(void *)&cmd_set_nvgre_eth_dst_value,
15690 		NULL,
15691 	},
15692 };
15693 
15694 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
15695 	.f = cmd_set_nvgre_parsed,
15696 	.data = NULL,
15697 	.help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
15698 		" ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
15699 		" eth-src <eth-src> eth-dst <eth-dst>",
15700 	.tokens = {
15701 		(void *)&cmd_set_nvgre_set,
15702 		(void *)&cmd_set_nvgre_nvgre_with_vlan,
15703 		(void *)&cmd_set_nvgre_ip_version,
15704 		(void *)&cmd_set_nvgre_ip_version_value,
15705 		(void *)&cmd_set_nvgre_tni,
15706 		(void *)&cmd_set_nvgre_tni_value,
15707 		(void *)&cmd_set_nvgre_ip_src,
15708 		(void *)&cmd_set_nvgre_ip_src_value,
15709 		(void *)&cmd_set_nvgre_ip_dst,
15710 		(void *)&cmd_set_nvgre_ip_dst_value,
15711 		(void *)&cmd_set_nvgre_vlan,
15712 		(void *)&cmd_set_nvgre_vlan_value,
15713 		(void *)&cmd_set_nvgre_eth_src,
15714 		(void *)&cmd_set_nvgre_eth_src_value,
15715 		(void *)&cmd_set_nvgre_eth_dst,
15716 		(void *)&cmd_set_nvgre_eth_dst_value,
15717 		NULL,
15718 	},
15719 };
15720 
15721 /** Set L2 encapsulation details */
15722 struct cmd_set_l2_encap_result {
15723 	cmdline_fixed_string_t set;
15724 	cmdline_fixed_string_t l2_encap;
15725 	cmdline_fixed_string_t pos_token;
15726 	cmdline_fixed_string_t ip_version;
15727 	uint32_t vlan_present:1;
15728 	uint16_t tci;
15729 	struct rte_ether_addr eth_src;
15730 	struct rte_ether_addr eth_dst;
15731 };
15732 
15733 cmdline_parse_token_string_t cmd_set_l2_encap_set =
15734 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
15735 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
15736 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
15737 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
15738 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
15739 				 "l2_encap-with-vlan");
15740 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
15741 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15742 				 "ip-version");
15743 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
15744 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
15745 				 "ipv4#ipv6");
15746 cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
15747 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15748 				 "vlan-tci");
15749 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
15750 	TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, UINT16);
15751 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
15752 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15753 				 "eth-src");
15754 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
15755 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
15756 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
15757 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15758 				 "eth-dst");
15759 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
15760 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
15761 
15762 static void cmd_set_l2_encap_parsed(void *parsed_result,
15763 	__attribute__((unused)) struct cmdline *cl,
15764 	__attribute__((unused)) void *data)
15765 {
15766 	struct cmd_set_l2_encap_result *res = parsed_result;
15767 
15768 	if (strcmp(res->l2_encap, "l2_encap") == 0)
15769 		l2_encap_conf.select_vlan = 0;
15770 	else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
15771 		l2_encap_conf.select_vlan = 1;
15772 	if (strcmp(res->ip_version, "ipv4") == 0)
15773 		l2_encap_conf.select_ipv4 = 1;
15774 	else if (strcmp(res->ip_version, "ipv6") == 0)
15775 		l2_encap_conf.select_ipv4 = 0;
15776 	else
15777 		return;
15778 	if (l2_encap_conf.select_vlan)
15779 		l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15780 	rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
15781 		   RTE_ETHER_ADDR_LEN);
15782 	rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15783 		   RTE_ETHER_ADDR_LEN);
15784 }
15785 
15786 cmdline_parse_inst_t cmd_set_l2_encap = {
15787 	.f = cmd_set_l2_encap_parsed,
15788 	.data = NULL,
15789 	.help_str = "set l2_encap ip-version ipv4|ipv6"
15790 		" eth-src <eth-src> eth-dst <eth-dst>",
15791 	.tokens = {
15792 		(void *)&cmd_set_l2_encap_set,
15793 		(void *)&cmd_set_l2_encap_l2_encap,
15794 		(void *)&cmd_set_l2_encap_ip_version,
15795 		(void *)&cmd_set_l2_encap_ip_version_value,
15796 		(void *)&cmd_set_l2_encap_eth_src,
15797 		(void *)&cmd_set_l2_encap_eth_src_value,
15798 		(void *)&cmd_set_l2_encap_eth_dst,
15799 		(void *)&cmd_set_l2_encap_eth_dst_value,
15800 		NULL,
15801 	},
15802 };
15803 
15804 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
15805 	.f = cmd_set_l2_encap_parsed,
15806 	.data = NULL,
15807 	.help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
15808 		" vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
15809 	.tokens = {
15810 		(void *)&cmd_set_l2_encap_set,
15811 		(void *)&cmd_set_l2_encap_l2_encap_with_vlan,
15812 		(void *)&cmd_set_l2_encap_ip_version,
15813 		(void *)&cmd_set_l2_encap_ip_version_value,
15814 		(void *)&cmd_set_l2_encap_vlan,
15815 		(void *)&cmd_set_l2_encap_vlan_value,
15816 		(void *)&cmd_set_l2_encap_eth_src,
15817 		(void *)&cmd_set_l2_encap_eth_src_value,
15818 		(void *)&cmd_set_l2_encap_eth_dst,
15819 		(void *)&cmd_set_l2_encap_eth_dst_value,
15820 		NULL,
15821 	},
15822 };
15823 
15824 /** Set L2 decapsulation details */
15825 struct cmd_set_l2_decap_result {
15826 	cmdline_fixed_string_t set;
15827 	cmdline_fixed_string_t l2_decap;
15828 	cmdline_fixed_string_t pos_token;
15829 	uint32_t vlan_present:1;
15830 };
15831 
15832 cmdline_parse_token_string_t cmd_set_l2_decap_set =
15833 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
15834 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
15835 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
15836 				 "l2_decap");
15837 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
15838 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
15839 				 "l2_decap-with-vlan");
15840 
15841 static void cmd_set_l2_decap_parsed(void *parsed_result,
15842 	__attribute__((unused)) struct cmdline *cl,
15843 	__attribute__((unused)) void *data)
15844 {
15845 	struct cmd_set_l2_decap_result *res = parsed_result;
15846 
15847 	if (strcmp(res->l2_decap, "l2_decap") == 0)
15848 		l2_decap_conf.select_vlan = 0;
15849 	else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
15850 		l2_decap_conf.select_vlan = 1;
15851 }
15852 
15853 cmdline_parse_inst_t cmd_set_l2_decap = {
15854 	.f = cmd_set_l2_decap_parsed,
15855 	.data = NULL,
15856 	.help_str = "set l2_decap",
15857 	.tokens = {
15858 		(void *)&cmd_set_l2_decap_set,
15859 		(void *)&cmd_set_l2_decap_l2_decap,
15860 		NULL,
15861 	},
15862 };
15863 
15864 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
15865 	.f = cmd_set_l2_decap_parsed,
15866 	.data = NULL,
15867 	.help_str = "set l2_decap-with-vlan",
15868 	.tokens = {
15869 		(void *)&cmd_set_l2_decap_set,
15870 		(void *)&cmd_set_l2_decap_l2_decap_with_vlan,
15871 		NULL,
15872 	},
15873 };
15874 
15875 /** Set MPLSoGRE encapsulation details */
15876 struct cmd_set_mplsogre_encap_result {
15877 	cmdline_fixed_string_t set;
15878 	cmdline_fixed_string_t mplsogre;
15879 	cmdline_fixed_string_t pos_token;
15880 	cmdline_fixed_string_t ip_version;
15881 	uint32_t vlan_present:1;
15882 	uint32_t label;
15883 	cmdline_ipaddr_t ip_src;
15884 	cmdline_ipaddr_t ip_dst;
15885 	uint16_t tci;
15886 	struct rte_ether_addr eth_src;
15887 	struct rte_ether_addr eth_dst;
15888 };
15889 
15890 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
15891 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
15892 				 "set");
15893 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
15894 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
15895 				 "mplsogre_encap");
15896 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
15897 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15898 				 mplsogre, "mplsogre_encap-with-vlan");
15899 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
15900 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15901 				 pos_token, "ip-version");
15902 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
15903 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15904 				 ip_version, "ipv4#ipv6");
15905 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
15906 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15907 				 pos_token, "label");
15908 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
15909 	TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
15910 			      UINT32);
15911 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
15912 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15913 				 pos_token, "ip-src");
15914 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
15915 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
15916 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
15917 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15918 				 pos_token, "ip-dst");
15919 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
15920 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
15921 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
15922 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15923 				 pos_token, "vlan-tci");
15924 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
15925 	TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
15926 			      UINT16);
15927 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
15928 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15929 				 pos_token, "eth-src");
15930 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
15931 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15932 				    eth_src);
15933 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
15934 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15935 				 pos_token, "eth-dst");
15936 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
15937 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15938 				    eth_dst);
15939 
15940 static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
15941 	__attribute__((unused)) struct cmdline *cl,
15942 	__attribute__((unused)) void *data)
15943 {
15944 	struct cmd_set_mplsogre_encap_result *res = parsed_result;
15945 	union {
15946 		uint32_t mplsogre_label;
15947 		uint8_t label[4];
15948 	} id = {
15949 		.mplsogre_label = rte_cpu_to_be_32(res->label<<12),
15950 	};
15951 
15952 	if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
15953 		mplsogre_encap_conf.select_vlan = 0;
15954 	else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
15955 		mplsogre_encap_conf.select_vlan = 1;
15956 	if (strcmp(res->ip_version, "ipv4") == 0)
15957 		mplsogre_encap_conf.select_ipv4 = 1;
15958 	else if (strcmp(res->ip_version, "ipv6") == 0)
15959 		mplsogre_encap_conf.select_ipv4 = 0;
15960 	else
15961 		return;
15962 	rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
15963 	if (mplsogre_encap_conf.select_ipv4) {
15964 		IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
15965 		IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
15966 	} else {
15967 		IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
15968 		IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
15969 	}
15970 	if (mplsogre_encap_conf.select_vlan)
15971 		mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15972 	rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
15973 		   RTE_ETHER_ADDR_LEN);
15974 	rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15975 		   RTE_ETHER_ADDR_LEN);
15976 }
15977 
15978 cmdline_parse_inst_t cmd_set_mplsogre_encap = {
15979 	.f = cmd_set_mplsogre_encap_parsed,
15980 	.data = NULL,
15981 	.help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
15982 		" ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15983 		" eth-dst <eth-dst>",
15984 	.tokens = {
15985 		(void *)&cmd_set_mplsogre_encap_set,
15986 		(void *)&cmd_set_mplsogre_encap_mplsogre_encap,
15987 		(void *)&cmd_set_mplsogre_encap_ip_version,
15988 		(void *)&cmd_set_mplsogre_encap_ip_version_value,
15989 		(void *)&cmd_set_mplsogre_encap_label,
15990 		(void *)&cmd_set_mplsogre_encap_label_value,
15991 		(void *)&cmd_set_mplsogre_encap_ip_src,
15992 		(void *)&cmd_set_mplsogre_encap_ip_src_value,
15993 		(void *)&cmd_set_mplsogre_encap_ip_dst,
15994 		(void *)&cmd_set_mplsogre_encap_ip_dst_value,
15995 		(void *)&cmd_set_mplsogre_encap_eth_src,
15996 		(void *)&cmd_set_mplsogre_encap_eth_src_value,
15997 		(void *)&cmd_set_mplsogre_encap_eth_dst,
15998 		(void *)&cmd_set_mplsogre_encap_eth_dst_value,
15999 		NULL,
16000 	},
16001 };
16002 
16003 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
16004 	.f = cmd_set_mplsogre_encap_parsed,
16005 	.data = NULL,
16006 	.help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
16007 		" label <label> ip-src <ip-src> ip-dst <ip-dst>"
16008 		" vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
16009 	.tokens = {
16010 		(void *)&cmd_set_mplsogre_encap_set,
16011 		(void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
16012 		(void *)&cmd_set_mplsogre_encap_ip_version,
16013 		(void *)&cmd_set_mplsogre_encap_ip_version_value,
16014 		(void *)&cmd_set_mplsogre_encap_label,
16015 		(void *)&cmd_set_mplsogre_encap_label_value,
16016 		(void *)&cmd_set_mplsogre_encap_ip_src,
16017 		(void *)&cmd_set_mplsogre_encap_ip_src_value,
16018 		(void *)&cmd_set_mplsogre_encap_ip_dst,
16019 		(void *)&cmd_set_mplsogre_encap_ip_dst_value,
16020 		(void *)&cmd_set_mplsogre_encap_vlan,
16021 		(void *)&cmd_set_mplsogre_encap_vlan_value,
16022 		(void *)&cmd_set_mplsogre_encap_eth_src,
16023 		(void *)&cmd_set_mplsogre_encap_eth_src_value,
16024 		(void *)&cmd_set_mplsogre_encap_eth_dst,
16025 		(void *)&cmd_set_mplsogre_encap_eth_dst_value,
16026 		NULL,
16027 	},
16028 };
16029 
16030 /** Set MPLSoGRE decapsulation details */
16031 struct cmd_set_mplsogre_decap_result {
16032 	cmdline_fixed_string_t set;
16033 	cmdline_fixed_string_t mplsogre;
16034 	cmdline_fixed_string_t pos_token;
16035 	cmdline_fixed_string_t ip_version;
16036 	uint32_t vlan_present:1;
16037 };
16038 
16039 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
16040 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
16041 				 "set");
16042 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
16043 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
16044 				 "mplsogre_decap");
16045 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
16046 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
16047 				 mplsogre, "mplsogre_decap-with-vlan");
16048 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
16049 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
16050 				 pos_token, "ip-version");
16051 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
16052 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
16053 				 ip_version, "ipv4#ipv6");
16054 
16055 static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
16056 	__attribute__((unused)) struct cmdline *cl,
16057 	__attribute__((unused)) void *data)
16058 {
16059 	struct cmd_set_mplsogre_decap_result *res = parsed_result;
16060 
16061 	if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
16062 		mplsogre_decap_conf.select_vlan = 0;
16063 	else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
16064 		mplsogre_decap_conf.select_vlan = 1;
16065 	if (strcmp(res->ip_version, "ipv4") == 0)
16066 		mplsogre_decap_conf.select_ipv4 = 1;
16067 	else if (strcmp(res->ip_version, "ipv6") == 0)
16068 		mplsogre_decap_conf.select_ipv4 = 0;
16069 }
16070 
16071 cmdline_parse_inst_t cmd_set_mplsogre_decap = {
16072 	.f = cmd_set_mplsogre_decap_parsed,
16073 	.data = NULL,
16074 	.help_str = "set mplsogre_decap ip-version ipv4|ipv6",
16075 	.tokens = {
16076 		(void *)&cmd_set_mplsogre_decap_set,
16077 		(void *)&cmd_set_mplsogre_decap_mplsogre_decap,
16078 		(void *)&cmd_set_mplsogre_decap_ip_version,
16079 		(void *)&cmd_set_mplsogre_decap_ip_version_value,
16080 		NULL,
16081 	},
16082 };
16083 
16084 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
16085 	.f = cmd_set_mplsogre_decap_parsed,
16086 	.data = NULL,
16087 	.help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
16088 	.tokens = {
16089 		(void *)&cmd_set_mplsogre_decap_set,
16090 		(void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
16091 		(void *)&cmd_set_mplsogre_decap_ip_version,
16092 		(void *)&cmd_set_mplsogre_decap_ip_version_value,
16093 		NULL,
16094 	},
16095 };
16096 
16097 /** Set MPLSoUDP encapsulation details */
16098 struct cmd_set_mplsoudp_encap_result {
16099 	cmdline_fixed_string_t set;
16100 	cmdline_fixed_string_t mplsoudp;
16101 	cmdline_fixed_string_t pos_token;
16102 	cmdline_fixed_string_t ip_version;
16103 	uint32_t vlan_present:1;
16104 	uint32_t label;
16105 	uint16_t udp_src;
16106 	uint16_t udp_dst;
16107 	cmdline_ipaddr_t ip_src;
16108 	cmdline_ipaddr_t ip_dst;
16109 	uint16_t tci;
16110 	struct rte_ether_addr eth_src;
16111 	struct rte_ether_addr eth_dst;
16112 };
16113 
16114 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
16115 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
16116 				 "set");
16117 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
16118 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
16119 				 "mplsoudp_encap");
16120 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
16121 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16122 				 mplsoudp, "mplsoudp_encap-with-vlan");
16123 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
16124 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16125 				 pos_token, "ip-version");
16126 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
16127 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16128 				 ip_version, "ipv4#ipv6");
16129 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
16130 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16131 				 pos_token, "label");
16132 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
16133 	TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
16134 			      UINT32);
16135 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
16136 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16137 				 pos_token, "udp-src");
16138 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
16139 	TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
16140 			      UINT16);
16141 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
16142 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16143 				 pos_token, "udp-dst");
16144 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
16145 	TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
16146 			      UINT16);
16147 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
16148 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16149 				 pos_token, "ip-src");
16150 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
16151 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
16152 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
16153 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16154 				 pos_token, "ip-dst");
16155 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
16156 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
16157 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
16158 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16159 				 pos_token, "vlan-tci");
16160 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
16161 	TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
16162 			      UINT16);
16163 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
16164 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16165 				 pos_token, "eth-src");
16166 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
16167 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16168 				    eth_src);
16169 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
16170 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16171 				 pos_token, "eth-dst");
16172 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
16173 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16174 				    eth_dst);
16175 
16176 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
16177 	__attribute__((unused)) struct cmdline *cl,
16178 	__attribute__((unused)) void *data)
16179 {
16180 	struct cmd_set_mplsoudp_encap_result *res = parsed_result;
16181 	union {
16182 		uint32_t mplsoudp_label;
16183 		uint8_t label[4];
16184 	} id = {
16185 		.mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
16186 	};
16187 
16188 	if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
16189 		mplsoudp_encap_conf.select_vlan = 0;
16190 	else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
16191 		mplsoudp_encap_conf.select_vlan = 1;
16192 	if (strcmp(res->ip_version, "ipv4") == 0)
16193 		mplsoudp_encap_conf.select_ipv4 = 1;
16194 	else if (strcmp(res->ip_version, "ipv6") == 0)
16195 		mplsoudp_encap_conf.select_ipv4 = 0;
16196 	else
16197 		return;
16198 	rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
16199 	mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
16200 	mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
16201 	if (mplsoudp_encap_conf.select_ipv4) {
16202 		IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
16203 		IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
16204 	} else {
16205 		IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
16206 		IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
16207 	}
16208 	if (mplsoudp_encap_conf.select_vlan)
16209 		mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
16210 	rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
16211 		   RTE_ETHER_ADDR_LEN);
16212 	rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
16213 		   RTE_ETHER_ADDR_LEN);
16214 }
16215 
16216 cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
16217 	.f = cmd_set_mplsoudp_encap_parsed,
16218 	.data = NULL,
16219 	.help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
16220 		" udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
16221 		" ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
16222 	.tokens = {
16223 		(void *)&cmd_set_mplsoudp_encap_set,
16224 		(void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
16225 		(void *)&cmd_set_mplsoudp_encap_ip_version,
16226 		(void *)&cmd_set_mplsoudp_encap_ip_version_value,
16227 		(void *)&cmd_set_mplsoudp_encap_label,
16228 		(void *)&cmd_set_mplsoudp_encap_label_value,
16229 		(void *)&cmd_set_mplsoudp_encap_udp_src,
16230 		(void *)&cmd_set_mplsoudp_encap_udp_src_value,
16231 		(void *)&cmd_set_mplsoudp_encap_udp_dst,
16232 		(void *)&cmd_set_mplsoudp_encap_udp_dst_value,
16233 		(void *)&cmd_set_mplsoudp_encap_ip_src,
16234 		(void *)&cmd_set_mplsoudp_encap_ip_src_value,
16235 		(void *)&cmd_set_mplsoudp_encap_ip_dst,
16236 		(void *)&cmd_set_mplsoudp_encap_ip_dst_value,
16237 		(void *)&cmd_set_mplsoudp_encap_eth_src,
16238 		(void *)&cmd_set_mplsoudp_encap_eth_src_value,
16239 		(void *)&cmd_set_mplsoudp_encap_eth_dst,
16240 		(void *)&cmd_set_mplsoudp_encap_eth_dst_value,
16241 		NULL,
16242 	},
16243 };
16244 
16245 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
16246 	.f = cmd_set_mplsoudp_encap_parsed,
16247 	.data = NULL,
16248 	.help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
16249 		" label <label> udp-src <udp-src> udp-dst <udp-dst>"
16250 		" ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
16251 		" eth-src <eth-src> eth-dst <eth-dst>",
16252 	.tokens = {
16253 		(void *)&cmd_set_mplsoudp_encap_set,
16254 		(void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
16255 		(void *)&cmd_set_mplsoudp_encap_ip_version,
16256 		(void *)&cmd_set_mplsoudp_encap_ip_version_value,
16257 		(void *)&cmd_set_mplsoudp_encap_label,
16258 		(void *)&cmd_set_mplsoudp_encap_label_value,
16259 		(void *)&cmd_set_mplsoudp_encap_udp_src,
16260 		(void *)&cmd_set_mplsoudp_encap_udp_src_value,
16261 		(void *)&cmd_set_mplsoudp_encap_udp_dst,
16262 		(void *)&cmd_set_mplsoudp_encap_udp_dst_value,
16263 		(void *)&cmd_set_mplsoudp_encap_ip_src,
16264 		(void *)&cmd_set_mplsoudp_encap_ip_src_value,
16265 		(void *)&cmd_set_mplsoudp_encap_ip_dst,
16266 		(void *)&cmd_set_mplsoudp_encap_ip_dst_value,
16267 		(void *)&cmd_set_mplsoudp_encap_vlan,
16268 		(void *)&cmd_set_mplsoudp_encap_vlan_value,
16269 		(void *)&cmd_set_mplsoudp_encap_eth_src,
16270 		(void *)&cmd_set_mplsoudp_encap_eth_src_value,
16271 		(void *)&cmd_set_mplsoudp_encap_eth_dst,
16272 		(void *)&cmd_set_mplsoudp_encap_eth_dst_value,
16273 		NULL,
16274 	},
16275 };
16276 
16277 /** Set MPLSoUDP decapsulation details */
16278 struct cmd_set_mplsoudp_decap_result {
16279 	cmdline_fixed_string_t set;
16280 	cmdline_fixed_string_t mplsoudp;
16281 	cmdline_fixed_string_t pos_token;
16282 	cmdline_fixed_string_t ip_version;
16283 	uint32_t vlan_present:1;
16284 };
16285 
16286 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
16287 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
16288 				 "set");
16289 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
16290 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
16291 				 "mplsoudp_decap");
16292 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
16293 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16294 				 mplsoudp, "mplsoudp_decap-with-vlan");
16295 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
16296 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16297 				 pos_token, "ip-version");
16298 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
16299 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16300 				 ip_version, "ipv4#ipv6");
16301 
16302 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
16303 	__attribute__((unused)) struct cmdline *cl,
16304 	__attribute__((unused)) void *data)
16305 {
16306 	struct cmd_set_mplsoudp_decap_result *res = parsed_result;
16307 
16308 	if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
16309 		mplsoudp_decap_conf.select_vlan = 0;
16310 	else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
16311 		mplsoudp_decap_conf.select_vlan = 1;
16312 	if (strcmp(res->ip_version, "ipv4") == 0)
16313 		mplsoudp_decap_conf.select_ipv4 = 1;
16314 	else if (strcmp(res->ip_version, "ipv6") == 0)
16315 		mplsoudp_decap_conf.select_ipv4 = 0;
16316 }
16317 
16318 cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
16319 	.f = cmd_set_mplsoudp_decap_parsed,
16320 	.data = NULL,
16321 	.help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
16322 	.tokens = {
16323 		(void *)&cmd_set_mplsoudp_decap_set,
16324 		(void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
16325 		(void *)&cmd_set_mplsoudp_decap_ip_version,
16326 		(void *)&cmd_set_mplsoudp_decap_ip_version_value,
16327 		NULL,
16328 	},
16329 };
16330 
16331 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
16332 	.f = cmd_set_mplsoudp_decap_parsed,
16333 	.data = NULL,
16334 	.help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
16335 	.tokens = {
16336 		(void *)&cmd_set_mplsoudp_decap_set,
16337 		(void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
16338 		(void *)&cmd_set_mplsoudp_decap_ip_version,
16339 		(void *)&cmd_set_mplsoudp_decap_ip_version_value,
16340 		NULL,
16341 	},
16342 };
16343 
16344 /* Strict link priority scheduling mode setting */
16345 static void
16346 cmd_strict_link_prio_parsed(
16347 	void *parsed_result,
16348 	__attribute__((unused)) struct cmdline *cl,
16349 	__attribute__((unused)) void *data)
16350 {
16351 	struct cmd_vf_tc_bw_result *res = parsed_result;
16352 	int ret = -ENOTSUP;
16353 
16354 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16355 		return;
16356 
16357 #ifdef RTE_LIBRTE_I40E_PMD
16358 	ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
16359 #endif
16360 
16361 	switch (ret) {
16362 	case 0:
16363 		break;
16364 	case -EINVAL:
16365 		printf("invalid tc_bitmap 0x%x\n", res->tc_map);
16366 		break;
16367 	case -ENODEV:
16368 		printf("invalid port_id %d\n", res->port_id);
16369 		break;
16370 	case -ENOTSUP:
16371 		printf("function not implemented\n");
16372 		break;
16373 	default:
16374 		printf("programming error: (%s)\n", strerror(-ret));
16375 	}
16376 }
16377 
16378 cmdline_parse_inst_t cmd_strict_link_prio = {
16379 	.f = cmd_strict_link_prio_parsed,
16380 	.data = NULL,
16381 	.help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
16382 	.tokens = {
16383 		(void *)&cmd_vf_tc_bw_set,
16384 		(void *)&cmd_vf_tc_bw_tx,
16385 		(void *)&cmd_vf_tc_bw_strict_link_prio,
16386 		(void *)&cmd_vf_tc_bw_port_id,
16387 		(void *)&cmd_vf_tc_bw_tc_map,
16388 		NULL,
16389 	},
16390 };
16391 
16392 /* Load dynamic device personalization*/
16393 struct cmd_ddp_add_result {
16394 	cmdline_fixed_string_t ddp;
16395 	cmdline_fixed_string_t add;
16396 	portid_t port_id;
16397 	char filepath[];
16398 };
16399 
16400 cmdline_parse_token_string_t cmd_ddp_add_ddp =
16401 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
16402 cmdline_parse_token_string_t cmd_ddp_add_add =
16403 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
16404 cmdline_parse_token_num_t cmd_ddp_add_port_id =
16405 	TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
16406 cmdline_parse_token_string_t cmd_ddp_add_filepath =
16407 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
16408 
16409 static void
16410 cmd_ddp_add_parsed(
16411 	void *parsed_result,
16412 	__attribute__((unused)) struct cmdline *cl,
16413 	__attribute__((unused)) void *data)
16414 {
16415 	struct cmd_ddp_add_result *res = parsed_result;
16416 	uint8_t *buff;
16417 	uint32_t size;
16418 	char *filepath;
16419 	char *file_fld[2];
16420 	int file_num;
16421 	int ret = -ENOTSUP;
16422 
16423 	if (!all_ports_stopped()) {
16424 		printf("Please stop all ports first\n");
16425 		return;
16426 	}
16427 
16428 	filepath = strdup(res->filepath);
16429 	if (filepath == NULL) {
16430 		printf("Failed to allocate memory\n");
16431 		return;
16432 	}
16433 	file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
16434 
16435 	buff = open_file(file_fld[0], &size);
16436 	if (!buff) {
16437 		free((void *)filepath);
16438 		return;
16439 	}
16440 
16441 #ifdef RTE_LIBRTE_I40E_PMD
16442 	if (ret == -ENOTSUP)
16443 		ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16444 					       buff, size,
16445 					       RTE_PMD_I40E_PKG_OP_WR_ADD);
16446 #endif
16447 
16448 	if (ret == -EEXIST)
16449 		printf("Profile has already existed.\n");
16450 	else if (ret < 0)
16451 		printf("Failed to load profile.\n");
16452 	else if (file_num == 2)
16453 		save_file(file_fld[1], buff, size);
16454 
16455 	close_file(buff);
16456 	free((void *)filepath);
16457 }
16458 
16459 cmdline_parse_inst_t cmd_ddp_add = {
16460 	.f = cmd_ddp_add_parsed,
16461 	.data = NULL,
16462 	.help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
16463 	.tokens = {
16464 		(void *)&cmd_ddp_add_ddp,
16465 		(void *)&cmd_ddp_add_add,
16466 		(void *)&cmd_ddp_add_port_id,
16467 		(void *)&cmd_ddp_add_filepath,
16468 		NULL,
16469 	},
16470 };
16471 
16472 /* Delete dynamic device personalization*/
16473 struct cmd_ddp_del_result {
16474 	cmdline_fixed_string_t ddp;
16475 	cmdline_fixed_string_t del;
16476 	portid_t port_id;
16477 	char filepath[];
16478 };
16479 
16480 cmdline_parse_token_string_t cmd_ddp_del_ddp =
16481 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
16482 cmdline_parse_token_string_t cmd_ddp_del_del =
16483 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
16484 cmdline_parse_token_num_t cmd_ddp_del_port_id =
16485 	TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
16486 cmdline_parse_token_string_t cmd_ddp_del_filepath =
16487 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
16488 
16489 static void
16490 cmd_ddp_del_parsed(
16491 	void *parsed_result,
16492 	__attribute__((unused)) struct cmdline *cl,
16493 	__attribute__((unused)) void *data)
16494 {
16495 	struct cmd_ddp_del_result *res = parsed_result;
16496 	uint8_t *buff;
16497 	uint32_t size;
16498 	int ret = -ENOTSUP;
16499 
16500 	if (!all_ports_stopped()) {
16501 		printf("Please stop all ports first\n");
16502 		return;
16503 	}
16504 
16505 	buff = open_file(res->filepath, &size);
16506 	if (!buff)
16507 		return;
16508 
16509 #ifdef RTE_LIBRTE_I40E_PMD
16510 	if (ret == -ENOTSUP)
16511 		ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16512 					       buff, size,
16513 					       RTE_PMD_I40E_PKG_OP_WR_DEL);
16514 #endif
16515 
16516 	if (ret == -EACCES)
16517 		printf("Profile does not exist.\n");
16518 	else if (ret < 0)
16519 		printf("Failed to delete profile.\n");
16520 
16521 	close_file(buff);
16522 }
16523 
16524 cmdline_parse_inst_t cmd_ddp_del = {
16525 	.f = cmd_ddp_del_parsed,
16526 	.data = NULL,
16527 	.help_str = "ddp del <port_id> <backup_profile_path>",
16528 	.tokens = {
16529 		(void *)&cmd_ddp_del_ddp,
16530 		(void *)&cmd_ddp_del_del,
16531 		(void *)&cmd_ddp_del_port_id,
16532 		(void *)&cmd_ddp_del_filepath,
16533 		NULL,
16534 	},
16535 };
16536 
16537 /* Get dynamic device personalization profile info */
16538 struct cmd_ddp_info_result {
16539 	cmdline_fixed_string_t ddp;
16540 	cmdline_fixed_string_t get;
16541 	cmdline_fixed_string_t info;
16542 	char filepath[];
16543 };
16544 
16545 cmdline_parse_token_string_t cmd_ddp_info_ddp =
16546 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
16547 cmdline_parse_token_string_t cmd_ddp_info_get =
16548 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
16549 cmdline_parse_token_string_t cmd_ddp_info_info =
16550 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
16551 cmdline_parse_token_string_t cmd_ddp_info_filepath =
16552 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
16553 
16554 static void
16555 cmd_ddp_info_parsed(
16556 	void *parsed_result,
16557 	__attribute__((unused)) struct cmdline *cl,
16558 	__attribute__((unused)) void *data)
16559 {
16560 	struct cmd_ddp_info_result *res = parsed_result;
16561 	uint8_t *pkg;
16562 	uint32_t pkg_size;
16563 	int ret = -ENOTSUP;
16564 #ifdef RTE_LIBRTE_I40E_PMD
16565 	uint32_t i, j, n;
16566 	uint8_t *buff;
16567 	uint32_t buff_size = 0;
16568 	struct rte_pmd_i40e_profile_info info;
16569 	uint32_t dev_num = 0;
16570 	struct rte_pmd_i40e_ddp_device_id *devs;
16571 	uint32_t proto_num = 0;
16572 	struct rte_pmd_i40e_proto_info *proto = NULL;
16573 	uint32_t pctype_num = 0;
16574 	struct rte_pmd_i40e_ptype_info *pctype;
16575 	uint32_t ptype_num = 0;
16576 	struct rte_pmd_i40e_ptype_info *ptype;
16577 	uint8_t proto_id;
16578 
16579 #endif
16580 
16581 	pkg = open_file(res->filepath, &pkg_size);
16582 	if (!pkg)
16583 		return;
16584 
16585 #ifdef RTE_LIBRTE_I40E_PMD
16586 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16587 				(uint8_t *)&info, sizeof(info),
16588 				RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
16589 	if (!ret) {
16590 		printf("Global Track id:       0x%x\n", info.track_id);
16591 		printf("Global Version:        %d.%d.%d.%d\n",
16592 			info.version.major,
16593 			info.version.minor,
16594 			info.version.update,
16595 			info.version.draft);
16596 		printf("Global Package name:   %s\n\n", info.name);
16597 	}
16598 
16599 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16600 				(uint8_t *)&info, sizeof(info),
16601 				RTE_PMD_I40E_PKG_INFO_HEADER);
16602 	if (!ret) {
16603 		printf("i40e Profile Track id: 0x%x\n", info.track_id);
16604 		printf("i40e Profile Version:  %d.%d.%d.%d\n",
16605 			info.version.major,
16606 			info.version.minor,
16607 			info.version.update,
16608 			info.version.draft);
16609 		printf("i40e Profile name:     %s\n\n", info.name);
16610 	}
16611 
16612 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16613 				(uint8_t *)&buff_size, sizeof(buff_size),
16614 				RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
16615 	if (!ret && buff_size) {
16616 		buff = (uint8_t *)malloc(buff_size);
16617 		if (buff) {
16618 			ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16619 						buff, buff_size,
16620 						RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
16621 			if (!ret)
16622 				printf("Package Notes:\n%s\n\n", buff);
16623 			free(buff);
16624 		}
16625 	}
16626 
16627 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16628 				(uint8_t *)&dev_num, sizeof(dev_num),
16629 				RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
16630 	if (!ret && dev_num) {
16631 		buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
16632 		devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
16633 		if (devs) {
16634 			ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16635 						(uint8_t *)devs, buff_size,
16636 						RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
16637 			if (!ret) {
16638 				printf("List of supported devices:\n");
16639 				for (i = 0; i < dev_num; i++) {
16640 					printf("  %04X:%04X %04X:%04X\n",
16641 						devs[i].vendor_dev_id >> 16,
16642 						devs[i].vendor_dev_id & 0xFFFF,
16643 						devs[i].sub_vendor_dev_id >> 16,
16644 						devs[i].sub_vendor_dev_id & 0xFFFF);
16645 				}
16646 				printf("\n");
16647 			}
16648 			free(devs);
16649 		}
16650 	}
16651 
16652 	/* get information about protocols and packet types */
16653 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16654 		(uint8_t *)&proto_num, sizeof(proto_num),
16655 		RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
16656 	if (ret || !proto_num)
16657 		goto no_print_return;
16658 
16659 	buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
16660 	proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
16661 	if (!proto)
16662 		goto no_print_return;
16663 
16664 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
16665 					buff_size,
16666 					RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
16667 	if (!ret) {
16668 		printf("List of used protocols:\n");
16669 		for (i = 0; i < proto_num; i++)
16670 			printf("  %2u: %s\n", proto[i].proto_id,
16671 			       proto[i].name);
16672 		printf("\n");
16673 	}
16674 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16675 		(uint8_t *)&pctype_num, sizeof(pctype_num),
16676 		RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
16677 	if (ret || !pctype_num)
16678 		goto no_print_pctypes;
16679 
16680 	buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16681 	pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16682 	if (!pctype)
16683 		goto no_print_pctypes;
16684 
16685 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
16686 					buff_size,
16687 					RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
16688 	if (ret) {
16689 		free(pctype);
16690 		goto no_print_pctypes;
16691 	}
16692 
16693 	printf("List of defined packet classification types:\n");
16694 	for (i = 0; i < pctype_num; i++) {
16695 		printf("  %2u:", pctype[i].ptype_id);
16696 		for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
16697 			proto_id = pctype[i].protocols[j];
16698 			if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
16699 				for (n = 0; n < proto_num; n++) {
16700 					if (proto[n].proto_id == proto_id) {
16701 						printf(" %s", proto[n].name);
16702 						break;
16703 					}
16704 				}
16705 			}
16706 		}
16707 		printf("\n");
16708 	}
16709 	printf("\n");
16710 	free(pctype);
16711 
16712 no_print_pctypes:
16713 
16714 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
16715 					sizeof(ptype_num),
16716 					RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
16717 	if (ret || !ptype_num)
16718 		goto no_print_return;
16719 
16720 	buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16721 	ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16722 	if (!ptype)
16723 		goto no_print_return;
16724 
16725 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
16726 					buff_size,
16727 					RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
16728 	if (ret) {
16729 		free(ptype);
16730 		goto no_print_return;
16731 	}
16732 	printf("List of defined packet types:\n");
16733 	for (i = 0; i < ptype_num; i++) {
16734 		printf("  %2u:", ptype[i].ptype_id);
16735 		for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
16736 			proto_id = ptype[i].protocols[j];
16737 			if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
16738 				for (n = 0; n < proto_num; n++) {
16739 					if (proto[n].proto_id == proto_id) {
16740 						printf(" %s", proto[n].name);
16741 						break;
16742 					}
16743 				}
16744 			}
16745 		}
16746 		printf("\n");
16747 	}
16748 	free(ptype);
16749 	printf("\n");
16750 
16751 	ret = 0;
16752 no_print_return:
16753 	if (proto)
16754 		free(proto);
16755 #endif
16756 	if (ret == -ENOTSUP)
16757 		printf("Function not supported in PMD driver\n");
16758 	close_file(pkg);
16759 }
16760 
16761 cmdline_parse_inst_t cmd_ddp_get_info = {
16762 	.f = cmd_ddp_info_parsed,
16763 	.data = NULL,
16764 	.help_str = "ddp get info <profile_path>",
16765 	.tokens = {
16766 		(void *)&cmd_ddp_info_ddp,
16767 		(void *)&cmd_ddp_info_get,
16768 		(void *)&cmd_ddp_info_info,
16769 		(void *)&cmd_ddp_info_filepath,
16770 		NULL,
16771 	},
16772 };
16773 
16774 /* Get dynamic device personalization profile info list*/
16775 #define PROFILE_INFO_SIZE 48
16776 #define MAX_PROFILE_NUM 16
16777 
16778 struct cmd_ddp_get_list_result {
16779 	cmdline_fixed_string_t ddp;
16780 	cmdline_fixed_string_t get;
16781 	cmdline_fixed_string_t list;
16782 	portid_t port_id;
16783 };
16784 
16785 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
16786 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
16787 cmdline_parse_token_string_t cmd_ddp_get_list_get =
16788 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
16789 cmdline_parse_token_string_t cmd_ddp_get_list_list =
16790 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
16791 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
16792 	TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
16793 
16794 static void
16795 cmd_ddp_get_list_parsed(
16796 	__attribute__((unused)) void *parsed_result,
16797 	__attribute__((unused)) struct cmdline *cl,
16798 	__attribute__((unused)) void *data)
16799 {
16800 #ifdef RTE_LIBRTE_I40E_PMD
16801 	struct cmd_ddp_get_list_result *res = parsed_result;
16802 	struct rte_pmd_i40e_profile_list *p_list;
16803 	struct rte_pmd_i40e_profile_info *p_info;
16804 	uint32_t p_num;
16805 	uint32_t size;
16806 	uint32_t i;
16807 #endif
16808 	int ret = -ENOTSUP;
16809 
16810 #ifdef RTE_LIBRTE_I40E_PMD
16811 	size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
16812 	p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
16813 	if (!p_list)
16814 		printf("%s: Failed to malloc buffer\n", __func__);
16815 
16816 	if (ret == -ENOTSUP)
16817 		ret = rte_pmd_i40e_get_ddp_list(res->port_id,
16818 						(uint8_t *)p_list, size);
16819 
16820 	if (!ret) {
16821 		p_num = p_list->p_count;
16822 		printf("Profile number is: %d\n\n", p_num);
16823 
16824 		for (i = 0; i < p_num; i++) {
16825 			p_info = &p_list->p_info[i];
16826 			printf("Profile %d:\n", i);
16827 			printf("Track id:     0x%x\n", p_info->track_id);
16828 			printf("Version:      %d.%d.%d.%d\n",
16829 			       p_info->version.major,
16830 			       p_info->version.minor,
16831 			       p_info->version.update,
16832 			       p_info->version.draft);
16833 			printf("Profile name: %s\n\n", p_info->name);
16834 		}
16835 	}
16836 
16837 	free(p_list);
16838 #endif
16839 
16840 	if (ret < 0)
16841 		printf("Failed to get ddp list\n");
16842 }
16843 
16844 cmdline_parse_inst_t cmd_ddp_get_list = {
16845 	.f = cmd_ddp_get_list_parsed,
16846 	.data = NULL,
16847 	.help_str = "ddp get list <port_id>",
16848 	.tokens = {
16849 		(void *)&cmd_ddp_get_list_ddp,
16850 		(void *)&cmd_ddp_get_list_get,
16851 		(void *)&cmd_ddp_get_list_list,
16852 		(void *)&cmd_ddp_get_list_port_id,
16853 		NULL,
16854 	},
16855 };
16856 
16857 /* Configure input set */
16858 struct cmd_cfg_input_set_result {
16859 	cmdline_fixed_string_t port;
16860 	cmdline_fixed_string_t cfg;
16861 	portid_t port_id;
16862 	cmdline_fixed_string_t pctype;
16863 	uint8_t pctype_id;
16864 	cmdline_fixed_string_t inset_type;
16865 	cmdline_fixed_string_t opt;
16866 	cmdline_fixed_string_t field;
16867 	uint8_t field_idx;
16868 };
16869 
16870 static void
16871 cmd_cfg_input_set_parsed(
16872 	__attribute__((unused)) void *parsed_result,
16873 	__attribute__((unused)) struct cmdline *cl,
16874 	__attribute__((unused)) void *data)
16875 {
16876 #ifdef RTE_LIBRTE_I40E_PMD
16877 	struct cmd_cfg_input_set_result *res = parsed_result;
16878 	enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
16879 	struct rte_pmd_i40e_inset inset;
16880 #endif
16881 	int ret = -ENOTSUP;
16882 
16883 	if (!all_ports_stopped()) {
16884 		printf("Please stop all ports first\n");
16885 		return;
16886 	}
16887 
16888 #ifdef RTE_LIBRTE_I40E_PMD
16889 	if (!strcmp(res->inset_type, "hash_inset"))
16890 		inset_type = INSET_HASH;
16891 	else if (!strcmp(res->inset_type, "fdir_inset"))
16892 		inset_type = INSET_FDIR;
16893 	else if (!strcmp(res->inset_type, "fdir_flx_inset"))
16894 		inset_type = INSET_FDIR_FLX;
16895 	ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
16896 				     &inset, inset_type);
16897 	if (ret) {
16898 		printf("Failed to get input set.\n");
16899 		return;
16900 	}
16901 
16902 	if (!strcmp(res->opt, "get")) {
16903 		ret = rte_pmd_i40e_inset_field_get(inset.inset,
16904 						   res->field_idx);
16905 		if (ret)
16906 			printf("Field index %d is enabled.\n", res->field_idx);
16907 		else
16908 			printf("Field index %d is disabled.\n", res->field_idx);
16909 		return;
16910 	} else if (!strcmp(res->opt, "set"))
16911 		ret = rte_pmd_i40e_inset_field_set(&inset.inset,
16912 						   res->field_idx);
16913 	else if (!strcmp(res->opt, "clear"))
16914 		ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
16915 						     res->field_idx);
16916 	if (ret) {
16917 		printf("Failed to configure input set field.\n");
16918 		return;
16919 	}
16920 
16921 	ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
16922 				     &inset, inset_type);
16923 	if (ret) {
16924 		printf("Failed to set input set.\n");
16925 		return;
16926 	}
16927 #endif
16928 
16929 	if (ret == -ENOTSUP)
16930 		printf("Function not supported\n");
16931 }
16932 
16933 cmdline_parse_token_string_t cmd_cfg_input_set_port =
16934 	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16935 				 port, "port");
16936 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
16937 	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16938 				 cfg, "config");
16939 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
16940 	TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16941 			      port_id, UINT16);
16942 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
16943 	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16944 				 pctype, "pctype");
16945 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
16946 	TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16947 			      pctype_id, UINT8);
16948 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
16949 	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16950 				 inset_type,
16951 				 "hash_inset#fdir_inset#fdir_flx_inset");
16952 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
16953 	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16954 				 opt, "get#set#clear");
16955 cmdline_parse_token_string_t cmd_cfg_input_set_field =
16956 	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16957 				 field, "field");
16958 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
16959 	TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16960 			      field_idx, UINT8);
16961 
16962 cmdline_parse_inst_t cmd_cfg_input_set = {
16963 	.f = cmd_cfg_input_set_parsed,
16964 	.data = NULL,
16965 	.help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
16966 		    "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
16967 	.tokens = {
16968 		(void *)&cmd_cfg_input_set_port,
16969 		(void *)&cmd_cfg_input_set_cfg,
16970 		(void *)&cmd_cfg_input_set_port_id,
16971 		(void *)&cmd_cfg_input_set_pctype,
16972 		(void *)&cmd_cfg_input_set_pctype_id,
16973 		(void *)&cmd_cfg_input_set_inset_type,
16974 		(void *)&cmd_cfg_input_set_opt,
16975 		(void *)&cmd_cfg_input_set_field,
16976 		(void *)&cmd_cfg_input_set_field_idx,
16977 		NULL,
16978 	},
16979 };
16980 
16981 /* Clear input set */
16982 struct cmd_clear_input_set_result {
16983 	cmdline_fixed_string_t port;
16984 	cmdline_fixed_string_t cfg;
16985 	portid_t port_id;
16986 	cmdline_fixed_string_t pctype;
16987 	uint8_t pctype_id;
16988 	cmdline_fixed_string_t inset_type;
16989 	cmdline_fixed_string_t clear;
16990 	cmdline_fixed_string_t all;
16991 };
16992 
16993 static void
16994 cmd_clear_input_set_parsed(
16995 	__attribute__((unused)) void *parsed_result,
16996 	__attribute__((unused)) struct cmdline *cl,
16997 	__attribute__((unused)) void *data)
16998 {
16999 #ifdef RTE_LIBRTE_I40E_PMD
17000 	struct cmd_clear_input_set_result *res = parsed_result;
17001 	enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
17002 	struct rte_pmd_i40e_inset inset;
17003 #endif
17004 	int ret = -ENOTSUP;
17005 
17006 	if (!all_ports_stopped()) {
17007 		printf("Please stop all ports first\n");
17008 		return;
17009 	}
17010 
17011 #ifdef RTE_LIBRTE_I40E_PMD
17012 	if (!strcmp(res->inset_type, "hash_inset"))
17013 		inset_type = INSET_HASH;
17014 	else if (!strcmp(res->inset_type, "fdir_inset"))
17015 		inset_type = INSET_FDIR;
17016 	else if (!strcmp(res->inset_type, "fdir_flx_inset"))
17017 		inset_type = INSET_FDIR_FLX;
17018 
17019 	memset(&inset, 0, sizeof(inset));
17020 
17021 	ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
17022 				     &inset, inset_type);
17023 	if (ret) {
17024 		printf("Failed to clear input set.\n");
17025 		return;
17026 	}
17027 
17028 #endif
17029 
17030 	if (ret == -ENOTSUP)
17031 		printf("Function not supported\n");
17032 }
17033 
17034 cmdline_parse_token_string_t cmd_clear_input_set_port =
17035 	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17036 				 port, "port");
17037 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
17038 	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17039 				 cfg, "config");
17040 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
17041 	TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
17042 			      port_id, UINT16);
17043 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
17044 	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17045 				 pctype, "pctype");
17046 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
17047 	TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
17048 			      pctype_id, UINT8);
17049 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
17050 	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17051 				 inset_type,
17052 				 "hash_inset#fdir_inset#fdir_flx_inset");
17053 cmdline_parse_token_string_t cmd_clear_input_set_clear =
17054 	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17055 				 clear, "clear");
17056 cmdline_parse_token_string_t cmd_clear_input_set_all =
17057 	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17058 				 all, "all");
17059 
17060 cmdline_parse_inst_t cmd_clear_input_set = {
17061 	.f = cmd_clear_input_set_parsed,
17062 	.data = NULL,
17063 	.help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
17064 		    "fdir_inset|fdir_flx_inset clear all",
17065 	.tokens = {
17066 		(void *)&cmd_clear_input_set_port,
17067 		(void *)&cmd_clear_input_set_cfg,
17068 		(void *)&cmd_clear_input_set_port_id,
17069 		(void *)&cmd_clear_input_set_pctype,
17070 		(void *)&cmd_clear_input_set_pctype_id,
17071 		(void *)&cmd_clear_input_set_inset_type,
17072 		(void *)&cmd_clear_input_set_clear,
17073 		(void *)&cmd_clear_input_set_all,
17074 		NULL,
17075 	},
17076 };
17077 
17078 /* show vf stats */
17079 
17080 /* Common result structure for show vf stats */
17081 struct cmd_show_vf_stats_result {
17082 	cmdline_fixed_string_t show;
17083 	cmdline_fixed_string_t vf;
17084 	cmdline_fixed_string_t stats;
17085 	portid_t port_id;
17086 	uint16_t vf_id;
17087 };
17088 
17089 /* Common CLI fields show vf stats*/
17090 cmdline_parse_token_string_t cmd_show_vf_stats_show =
17091 	TOKEN_STRING_INITIALIZER
17092 		(struct cmd_show_vf_stats_result,
17093 		 show, "show");
17094 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
17095 	TOKEN_STRING_INITIALIZER
17096 		(struct cmd_show_vf_stats_result,
17097 		 vf, "vf");
17098 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
17099 	TOKEN_STRING_INITIALIZER
17100 		(struct cmd_show_vf_stats_result,
17101 		 stats, "stats");
17102 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
17103 	TOKEN_NUM_INITIALIZER
17104 		(struct cmd_show_vf_stats_result,
17105 		 port_id, UINT16);
17106 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
17107 	TOKEN_NUM_INITIALIZER
17108 		(struct cmd_show_vf_stats_result,
17109 		 vf_id, UINT16);
17110 
17111 static void
17112 cmd_show_vf_stats_parsed(
17113 	void *parsed_result,
17114 	__attribute__((unused)) struct cmdline *cl,
17115 	__attribute__((unused)) void *data)
17116 {
17117 	struct cmd_show_vf_stats_result *res = parsed_result;
17118 	struct rte_eth_stats stats;
17119 	int ret = -ENOTSUP;
17120 	static const char *nic_stats_border = "########################";
17121 
17122 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17123 		return;
17124 
17125 	memset(&stats, 0, sizeof(stats));
17126 
17127 #ifdef RTE_LIBRTE_I40E_PMD
17128 	if (ret == -ENOTSUP)
17129 		ret = rte_pmd_i40e_get_vf_stats(res->port_id,
17130 						res->vf_id,
17131 						&stats);
17132 #endif
17133 #ifdef RTE_LIBRTE_BNXT_PMD
17134 	if (ret == -ENOTSUP)
17135 		ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
17136 						res->vf_id,
17137 						&stats);
17138 #endif
17139 
17140 	switch (ret) {
17141 	case 0:
17142 		break;
17143 	case -EINVAL:
17144 		printf("invalid vf_id %d\n", res->vf_id);
17145 		break;
17146 	case -ENODEV:
17147 		printf("invalid port_id %d\n", res->port_id);
17148 		break;
17149 	case -ENOTSUP:
17150 		printf("function not implemented\n");
17151 		break;
17152 	default:
17153 		printf("programming error: (%s)\n", strerror(-ret));
17154 	}
17155 
17156 	printf("\n  %s NIC statistics for port %-2d vf %-2d %s\n",
17157 		nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
17158 
17159 	printf("  RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes:  "
17160 	       "%-"PRIu64"\n",
17161 	       stats.ipackets, stats.imissed, stats.ibytes);
17162 	printf("  RX-errors: %-"PRIu64"\n", stats.ierrors);
17163 	printf("  RX-nombuf:  %-10"PRIu64"\n",
17164 	       stats.rx_nombuf);
17165 	printf("  TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes:  "
17166 	       "%-"PRIu64"\n",
17167 	       stats.opackets, stats.oerrors, stats.obytes);
17168 
17169 	printf("  %s############################%s\n",
17170 			       nic_stats_border, nic_stats_border);
17171 }
17172 
17173 cmdline_parse_inst_t cmd_show_vf_stats = {
17174 	.f = cmd_show_vf_stats_parsed,
17175 	.data = NULL,
17176 	.help_str = "show vf stats <port_id> <vf_id>",
17177 	.tokens = {
17178 		(void *)&cmd_show_vf_stats_show,
17179 		(void *)&cmd_show_vf_stats_vf,
17180 		(void *)&cmd_show_vf_stats_stats,
17181 		(void *)&cmd_show_vf_stats_port_id,
17182 		(void *)&cmd_show_vf_stats_vf_id,
17183 		NULL,
17184 	},
17185 };
17186 
17187 /* clear vf stats */
17188 
17189 /* Common result structure for clear vf stats */
17190 struct cmd_clear_vf_stats_result {
17191 	cmdline_fixed_string_t clear;
17192 	cmdline_fixed_string_t vf;
17193 	cmdline_fixed_string_t stats;
17194 	portid_t port_id;
17195 	uint16_t vf_id;
17196 };
17197 
17198 /* Common CLI fields clear vf stats*/
17199 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
17200 	TOKEN_STRING_INITIALIZER
17201 		(struct cmd_clear_vf_stats_result,
17202 		 clear, "clear");
17203 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
17204 	TOKEN_STRING_INITIALIZER
17205 		(struct cmd_clear_vf_stats_result,
17206 		 vf, "vf");
17207 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
17208 	TOKEN_STRING_INITIALIZER
17209 		(struct cmd_clear_vf_stats_result,
17210 		 stats, "stats");
17211 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
17212 	TOKEN_NUM_INITIALIZER
17213 		(struct cmd_clear_vf_stats_result,
17214 		 port_id, UINT16);
17215 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
17216 	TOKEN_NUM_INITIALIZER
17217 		(struct cmd_clear_vf_stats_result,
17218 		 vf_id, UINT16);
17219 
17220 static void
17221 cmd_clear_vf_stats_parsed(
17222 	void *parsed_result,
17223 	__attribute__((unused)) struct cmdline *cl,
17224 	__attribute__((unused)) void *data)
17225 {
17226 	struct cmd_clear_vf_stats_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 	if (ret == -ENOTSUP)
17234 		ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
17235 						  res->vf_id);
17236 #endif
17237 #ifdef RTE_LIBRTE_BNXT_PMD
17238 	if (ret == -ENOTSUP)
17239 		ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
17240 						  res->vf_id);
17241 #endif
17242 
17243 	switch (ret) {
17244 	case 0:
17245 		break;
17246 	case -EINVAL:
17247 		printf("invalid vf_id %d\n", res->vf_id);
17248 		break;
17249 	case -ENODEV:
17250 		printf("invalid port_id %d\n", res->port_id);
17251 		break;
17252 	case -ENOTSUP:
17253 		printf("function not implemented\n");
17254 		break;
17255 	default:
17256 		printf("programming error: (%s)\n", strerror(-ret));
17257 	}
17258 }
17259 
17260 cmdline_parse_inst_t cmd_clear_vf_stats = {
17261 	.f = cmd_clear_vf_stats_parsed,
17262 	.data = NULL,
17263 	.help_str = "clear vf stats <port_id> <vf_id>",
17264 	.tokens = {
17265 		(void *)&cmd_clear_vf_stats_clear,
17266 		(void *)&cmd_clear_vf_stats_vf,
17267 		(void *)&cmd_clear_vf_stats_stats,
17268 		(void *)&cmd_clear_vf_stats_port_id,
17269 		(void *)&cmd_clear_vf_stats_vf_id,
17270 		NULL,
17271 	},
17272 };
17273 
17274 /* port config pctype mapping reset */
17275 
17276 /* Common result structure for port config pctype mapping reset */
17277 struct cmd_pctype_mapping_reset_result {
17278 	cmdline_fixed_string_t port;
17279 	cmdline_fixed_string_t config;
17280 	portid_t port_id;
17281 	cmdline_fixed_string_t pctype;
17282 	cmdline_fixed_string_t mapping;
17283 	cmdline_fixed_string_t reset;
17284 };
17285 
17286 /* Common CLI fields for port config pctype mapping reset*/
17287 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
17288 	TOKEN_STRING_INITIALIZER
17289 		(struct cmd_pctype_mapping_reset_result,
17290 		 port, "port");
17291 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
17292 	TOKEN_STRING_INITIALIZER
17293 		(struct cmd_pctype_mapping_reset_result,
17294 		 config, "config");
17295 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
17296 	TOKEN_NUM_INITIALIZER
17297 		(struct cmd_pctype_mapping_reset_result,
17298 		 port_id, UINT16);
17299 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
17300 	TOKEN_STRING_INITIALIZER
17301 		(struct cmd_pctype_mapping_reset_result,
17302 		 pctype, "pctype");
17303 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
17304 	TOKEN_STRING_INITIALIZER
17305 		(struct cmd_pctype_mapping_reset_result,
17306 		 mapping, "mapping");
17307 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
17308 	TOKEN_STRING_INITIALIZER
17309 		(struct cmd_pctype_mapping_reset_result,
17310 		 reset, "reset");
17311 
17312 static void
17313 cmd_pctype_mapping_reset_parsed(
17314 	void *parsed_result,
17315 	__attribute__((unused)) struct cmdline *cl,
17316 	__attribute__((unused)) void *data)
17317 {
17318 	struct cmd_pctype_mapping_reset_result *res = parsed_result;
17319 	int ret = -ENOTSUP;
17320 
17321 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17322 		return;
17323 
17324 #ifdef RTE_LIBRTE_I40E_PMD
17325 	ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
17326 #endif
17327 
17328 	switch (ret) {
17329 	case 0:
17330 		break;
17331 	case -ENODEV:
17332 		printf("invalid port_id %d\n", res->port_id);
17333 		break;
17334 	case -ENOTSUP:
17335 		printf("function not implemented\n");
17336 		break;
17337 	default:
17338 		printf("programming error: (%s)\n", strerror(-ret));
17339 	}
17340 }
17341 
17342 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
17343 	.f = cmd_pctype_mapping_reset_parsed,
17344 	.data = NULL,
17345 	.help_str = "port config <port_id> pctype mapping reset",
17346 	.tokens = {
17347 		(void *)&cmd_pctype_mapping_reset_port,
17348 		(void *)&cmd_pctype_mapping_reset_config,
17349 		(void *)&cmd_pctype_mapping_reset_port_id,
17350 		(void *)&cmd_pctype_mapping_reset_pctype,
17351 		(void *)&cmd_pctype_mapping_reset_mapping,
17352 		(void *)&cmd_pctype_mapping_reset_reset,
17353 		NULL,
17354 	},
17355 };
17356 
17357 /* show port pctype mapping */
17358 
17359 /* Common result structure for show port pctype mapping */
17360 struct cmd_pctype_mapping_get_result {
17361 	cmdline_fixed_string_t show;
17362 	cmdline_fixed_string_t port;
17363 	portid_t port_id;
17364 	cmdline_fixed_string_t pctype;
17365 	cmdline_fixed_string_t mapping;
17366 };
17367 
17368 /* Common CLI fields for pctype mapping get */
17369 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
17370 	TOKEN_STRING_INITIALIZER
17371 		(struct cmd_pctype_mapping_get_result,
17372 		 show, "show");
17373 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
17374 	TOKEN_STRING_INITIALIZER
17375 		(struct cmd_pctype_mapping_get_result,
17376 		 port, "port");
17377 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
17378 	TOKEN_NUM_INITIALIZER
17379 		(struct cmd_pctype_mapping_get_result,
17380 		 port_id, UINT16);
17381 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
17382 	TOKEN_STRING_INITIALIZER
17383 		(struct cmd_pctype_mapping_get_result,
17384 		 pctype, "pctype");
17385 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
17386 	TOKEN_STRING_INITIALIZER
17387 		(struct cmd_pctype_mapping_get_result,
17388 		 mapping, "mapping");
17389 
17390 static void
17391 cmd_pctype_mapping_get_parsed(
17392 	void *parsed_result,
17393 	__attribute__((unused)) struct cmdline *cl,
17394 	__attribute__((unused)) void *data)
17395 {
17396 	struct cmd_pctype_mapping_get_result *res = parsed_result;
17397 	int ret = -ENOTSUP;
17398 #ifdef RTE_LIBRTE_I40E_PMD
17399 	struct rte_pmd_i40e_flow_type_mapping
17400 				mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
17401 	int i, j, first_pctype;
17402 #endif
17403 
17404 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17405 		return;
17406 
17407 #ifdef RTE_LIBRTE_I40E_PMD
17408 	ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
17409 #endif
17410 
17411 	switch (ret) {
17412 	case 0:
17413 		break;
17414 	case -ENODEV:
17415 		printf("invalid port_id %d\n", res->port_id);
17416 		return;
17417 	case -ENOTSUP:
17418 		printf("function not implemented\n");
17419 		return;
17420 	default:
17421 		printf("programming error: (%s)\n", strerror(-ret));
17422 		return;
17423 	}
17424 
17425 #ifdef RTE_LIBRTE_I40E_PMD
17426 	for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
17427 		if (mapping[i].pctype != 0ULL) {
17428 			first_pctype = 1;
17429 
17430 			printf("pctype: ");
17431 			for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
17432 				if (mapping[i].pctype & (1ULL << j)) {
17433 					printf(first_pctype ?
17434 					       "%02d" : ",%02d", j);
17435 					first_pctype = 0;
17436 				}
17437 			}
17438 			printf("  ->  flowtype: %02d\n", mapping[i].flow_type);
17439 		}
17440 	}
17441 #endif
17442 }
17443 
17444 cmdline_parse_inst_t cmd_pctype_mapping_get = {
17445 	.f = cmd_pctype_mapping_get_parsed,
17446 	.data = NULL,
17447 	.help_str = "show port <port_id> pctype mapping",
17448 	.tokens = {
17449 		(void *)&cmd_pctype_mapping_get_show,
17450 		(void *)&cmd_pctype_mapping_get_port,
17451 		(void *)&cmd_pctype_mapping_get_port_id,
17452 		(void *)&cmd_pctype_mapping_get_pctype,
17453 		(void *)&cmd_pctype_mapping_get_mapping,
17454 		NULL,
17455 	},
17456 };
17457 
17458 /* port config pctype mapping update */
17459 
17460 /* Common result structure for port config pctype mapping update */
17461 struct cmd_pctype_mapping_update_result {
17462 	cmdline_fixed_string_t port;
17463 	cmdline_fixed_string_t config;
17464 	portid_t port_id;
17465 	cmdline_fixed_string_t pctype;
17466 	cmdline_fixed_string_t mapping;
17467 	cmdline_fixed_string_t update;
17468 	cmdline_fixed_string_t pctype_list;
17469 	uint16_t flow_type;
17470 };
17471 
17472 /* Common CLI fields for pctype mapping update*/
17473 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
17474 	TOKEN_STRING_INITIALIZER
17475 		(struct cmd_pctype_mapping_update_result,
17476 		 port, "port");
17477 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
17478 	TOKEN_STRING_INITIALIZER
17479 		(struct cmd_pctype_mapping_update_result,
17480 		 config, "config");
17481 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
17482 	TOKEN_NUM_INITIALIZER
17483 		(struct cmd_pctype_mapping_update_result,
17484 		 port_id, UINT16);
17485 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
17486 	TOKEN_STRING_INITIALIZER
17487 		(struct cmd_pctype_mapping_update_result,
17488 		 pctype, "pctype");
17489 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
17490 	TOKEN_STRING_INITIALIZER
17491 		(struct cmd_pctype_mapping_update_result,
17492 		 mapping, "mapping");
17493 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
17494 	TOKEN_STRING_INITIALIZER
17495 		(struct cmd_pctype_mapping_update_result,
17496 		 update, "update");
17497 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
17498 	TOKEN_STRING_INITIALIZER
17499 		(struct cmd_pctype_mapping_update_result,
17500 		 pctype_list, NULL);
17501 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
17502 	TOKEN_NUM_INITIALIZER
17503 		(struct cmd_pctype_mapping_update_result,
17504 		 flow_type, UINT16);
17505 
17506 static void
17507 cmd_pctype_mapping_update_parsed(
17508 	void *parsed_result,
17509 	__attribute__((unused)) struct cmdline *cl,
17510 	__attribute__((unused)) void *data)
17511 {
17512 	struct cmd_pctype_mapping_update_result *res = parsed_result;
17513 	int ret = -ENOTSUP;
17514 #ifdef RTE_LIBRTE_I40E_PMD
17515 	struct rte_pmd_i40e_flow_type_mapping mapping;
17516 	unsigned int i;
17517 	unsigned int nb_item;
17518 	unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
17519 #endif
17520 
17521 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17522 		return;
17523 
17524 #ifdef RTE_LIBRTE_I40E_PMD
17525 	nb_item = parse_item_list(res->pctype_list, "pctypes",
17526 				  RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
17527 	mapping.flow_type = res->flow_type;
17528 	for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
17529 		mapping.pctype |= (1ULL << pctype_list[i]);
17530 	ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
17531 						&mapping,
17532 						1,
17533 						0);
17534 #endif
17535 
17536 	switch (ret) {
17537 	case 0:
17538 		break;
17539 	case -EINVAL:
17540 		printf("invalid pctype or flow type\n");
17541 		break;
17542 	case -ENODEV:
17543 		printf("invalid port_id %d\n", res->port_id);
17544 		break;
17545 	case -ENOTSUP:
17546 		printf("function not implemented\n");
17547 		break;
17548 	default:
17549 		printf("programming error: (%s)\n", strerror(-ret));
17550 	}
17551 }
17552 
17553 cmdline_parse_inst_t cmd_pctype_mapping_update = {
17554 	.f = cmd_pctype_mapping_update_parsed,
17555 	.data = NULL,
17556 	.help_str = "port config <port_id> pctype mapping update"
17557 	" <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
17558 	.tokens = {
17559 		(void *)&cmd_pctype_mapping_update_port,
17560 		(void *)&cmd_pctype_mapping_update_config,
17561 		(void *)&cmd_pctype_mapping_update_port_id,
17562 		(void *)&cmd_pctype_mapping_update_pctype,
17563 		(void *)&cmd_pctype_mapping_update_mapping,
17564 		(void *)&cmd_pctype_mapping_update_update,
17565 		(void *)&cmd_pctype_mapping_update_pc_type,
17566 		(void *)&cmd_pctype_mapping_update_flow_type,
17567 		NULL,
17568 	},
17569 };
17570 
17571 /* ptype mapping get */
17572 
17573 /* Common result structure for ptype mapping get */
17574 struct cmd_ptype_mapping_get_result {
17575 	cmdline_fixed_string_t ptype;
17576 	cmdline_fixed_string_t mapping;
17577 	cmdline_fixed_string_t get;
17578 	portid_t port_id;
17579 	uint8_t valid_only;
17580 };
17581 
17582 /* Common CLI fields for ptype mapping get */
17583 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
17584 	TOKEN_STRING_INITIALIZER
17585 		(struct cmd_ptype_mapping_get_result,
17586 		 ptype, "ptype");
17587 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
17588 	TOKEN_STRING_INITIALIZER
17589 		(struct cmd_ptype_mapping_get_result,
17590 		 mapping, "mapping");
17591 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
17592 	TOKEN_STRING_INITIALIZER
17593 		(struct cmd_ptype_mapping_get_result,
17594 		 get, "get");
17595 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
17596 	TOKEN_NUM_INITIALIZER
17597 		(struct cmd_ptype_mapping_get_result,
17598 		 port_id, UINT16);
17599 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
17600 	TOKEN_NUM_INITIALIZER
17601 		(struct cmd_ptype_mapping_get_result,
17602 		 valid_only, UINT8);
17603 
17604 static void
17605 cmd_ptype_mapping_get_parsed(
17606 	void *parsed_result,
17607 	__attribute__((unused)) struct cmdline *cl,
17608 	__attribute__((unused)) void *data)
17609 {
17610 	struct cmd_ptype_mapping_get_result *res = parsed_result;
17611 	int ret = -ENOTSUP;
17612 #ifdef RTE_LIBRTE_I40E_PMD
17613 	int max_ptype_num = 256;
17614 	struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
17615 	uint16_t count;
17616 	int i;
17617 #endif
17618 
17619 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17620 		return;
17621 
17622 #ifdef RTE_LIBRTE_I40E_PMD
17623 	ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
17624 					mapping,
17625 					max_ptype_num,
17626 					&count,
17627 					res->valid_only);
17628 #endif
17629 
17630 	switch (ret) {
17631 	case 0:
17632 		break;
17633 	case -ENODEV:
17634 		printf("invalid port_id %d\n", res->port_id);
17635 		break;
17636 	case -ENOTSUP:
17637 		printf("function not implemented\n");
17638 		break;
17639 	default:
17640 		printf("programming error: (%s)\n", strerror(-ret));
17641 	}
17642 
17643 #ifdef RTE_LIBRTE_I40E_PMD
17644 	if (!ret) {
17645 		for (i = 0; i < count; i++)
17646 			printf("%3d\t0x%08x\n",
17647 				mapping[i].hw_ptype, mapping[i].sw_ptype);
17648 	}
17649 #endif
17650 }
17651 
17652 cmdline_parse_inst_t cmd_ptype_mapping_get = {
17653 	.f = cmd_ptype_mapping_get_parsed,
17654 	.data = NULL,
17655 	.help_str = "ptype mapping get <port_id> <valid_only>",
17656 	.tokens = {
17657 		(void *)&cmd_ptype_mapping_get_ptype,
17658 		(void *)&cmd_ptype_mapping_get_mapping,
17659 		(void *)&cmd_ptype_mapping_get_get,
17660 		(void *)&cmd_ptype_mapping_get_port_id,
17661 		(void *)&cmd_ptype_mapping_get_valid_only,
17662 		NULL,
17663 	},
17664 };
17665 
17666 /* ptype mapping replace */
17667 
17668 /* Common result structure for ptype mapping replace */
17669 struct cmd_ptype_mapping_replace_result {
17670 	cmdline_fixed_string_t ptype;
17671 	cmdline_fixed_string_t mapping;
17672 	cmdline_fixed_string_t replace;
17673 	portid_t port_id;
17674 	uint32_t target;
17675 	uint8_t mask;
17676 	uint32_t pkt_type;
17677 };
17678 
17679 /* Common CLI fields for ptype mapping replace */
17680 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
17681 	TOKEN_STRING_INITIALIZER
17682 		(struct cmd_ptype_mapping_replace_result,
17683 		 ptype, "ptype");
17684 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
17685 	TOKEN_STRING_INITIALIZER
17686 		(struct cmd_ptype_mapping_replace_result,
17687 		 mapping, "mapping");
17688 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
17689 	TOKEN_STRING_INITIALIZER
17690 		(struct cmd_ptype_mapping_replace_result,
17691 		 replace, "replace");
17692 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
17693 	TOKEN_NUM_INITIALIZER
17694 		(struct cmd_ptype_mapping_replace_result,
17695 		 port_id, UINT16);
17696 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
17697 	TOKEN_NUM_INITIALIZER
17698 		(struct cmd_ptype_mapping_replace_result,
17699 		 target, UINT32);
17700 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
17701 	TOKEN_NUM_INITIALIZER
17702 		(struct cmd_ptype_mapping_replace_result,
17703 		 mask, UINT8);
17704 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
17705 	TOKEN_NUM_INITIALIZER
17706 		(struct cmd_ptype_mapping_replace_result,
17707 		 pkt_type, UINT32);
17708 
17709 static void
17710 cmd_ptype_mapping_replace_parsed(
17711 	void *parsed_result,
17712 	__attribute__((unused)) struct cmdline *cl,
17713 	__attribute__((unused)) void *data)
17714 {
17715 	struct cmd_ptype_mapping_replace_result *res = parsed_result;
17716 	int ret = -ENOTSUP;
17717 
17718 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17719 		return;
17720 
17721 #ifdef RTE_LIBRTE_I40E_PMD
17722 	ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
17723 					res->target,
17724 					res->mask,
17725 					res->pkt_type);
17726 #endif
17727 
17728 	switch (ret) {
17729 	case 0:
17730 		break;
17731 	case -EINVAL:
17732 		printf("invalid ptype 0x%8x or 0x%8x\n",
17733 				res->target, res->pkt_type);
17734 		break;
17735 	case -ENODEV:
17736 		printf("invalid port_id %d\n", res->port_id);
17737 		break;
17738 	case -ENOTSUP:
17739 		printf("function not implemented\n");
17740 		break;
17741 	default:
17742 		printf("programming error: (%s)\n", strerror(-ret));
17743 	}
17744 }
17745 
17746 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
17747 	.f = cmd_ptype_mapping_replace_parsed,
17748 	.data = NULL,
17749 	.help_str =
17750 		"ptype mapping replace <port_id> <target> <mask> <pkt_type>",
17751 	.tokens = {
17752 		(void *)&cmd_ptype_mapping_replace_ptype,
17753 		(void *)&cmd_ptype_mapping_replace_mapping,
17754 		(void *)&cmd_ptype_mapping_replace_replace,
17755 		(void *)&cmd_ptype_mapping_replace_port_id,
17756 		(void *)&cmd_ptype_mapping_replace_target,
17757 		(void *)&cmd_ptype_mapping_replace_mask,
17758 		(void *)&cmd_ptype_mapping_replace_pkt_type,
17759 		NULL,
17760 	},
17761 };
17762 
17763 /* ptype mapping reset */
17764 
17765 /* Common result structure for ptype mapping reset */
17766 struct cmd_ptype_mapping_reset_result {
17767 	cmdline_fixed_string_t ptype;
17768 	cmdline_fixed_string_t mapping;
17769 	cmdline_fixed_string_t reset;
17770 	portid_t port_id;
17771 };
17772 
17773 /* Common CLI fields for ptype mapping reset*/
17774 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
17775 	TOKEN_STRING_INITIALIZER
17776 		(struct cmd_ptype_mapping_reset_result,
17777 		 ptype, "ptype");
17778 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
17779 	TOKEN_STRING_INITIALIZER
17780 		(struct cmd_ptype_mapping_reset_result,
17781 		 mapping, "mapping");
17782 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
17783 	TOKEN_STRING_INITIALIZER
17784 		(struct cmd_ptype_mapping_reset_result,
17785 		 reset, "reset");
17786 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
17787 	TOKEN_NUM_INITIALIZER
17788 		(struct cmd_ptype_mapping_reset_result,
17789 		 port_id, UINT16);
17790 
17791 static void
17792 cmd_ptype_mapping_reset_parsed(
17793 	void *parsed_result,
17794 	__attribute__((unused)) struct cmdline *cl,
17795 	__attribute__((unused)) void *data)
17796 {
17797 	struct cmd_ptype_mapping_reset_result *res = parsed_result;
17798 	int ret = -ENOTSUP;
17799 
17800 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17801 		return;
17802 
17803 #ifdef RTE_LIBRTE_I40E_PMD
17804 	ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
17805 #endif
17806 
17807 	switch (ret) {
17808 	case 0:
17809 		break;
17810 	case -ENODEV:
17811 		printf("invalid port_id %d\n", res->port_id);
17812 		break;
17813 	case -ENOTSUP:
17814 		printf("function not implemented\n");
17815 		break;
17816 	default:
17817 		printf("programming error: (%s)\n", strerror(-ret));
17818 	}
17819 }
17820 
17821 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
17822 	.f = cmd_ptype_mapping_reset_parsed,
17823 	.data = NULL,
17824 	.help_str = "ptype mapping reset <port_id>",
17825 	.tokens = {
17826 		(void *)&cmd_ptype_mapping_reset_ptype,
17827 		(void *)&cmd_ptype_mapping_reset_mapping,
17828 		(void *)&cmd_ptype_mapping_reset_reset,
17829 		(void *)&cmd_ptype_mapping_reset_port_id,
17830 		NULL,
17831 	},
17832 };
17833 
17834 /* ptype mapping update */
17835 
17836 /* Common result structure for ptype mapping update */
17837 struct cmd_ptype_mapping_update_result {
17838 	cmdline_fixed_string_t ptype;
17839 	cmdline_fixed_string_t mapping;
17840 	cmdline_fixed_string_t reset;
17841 	portid_t port_id;
17842 	uint8_t hw_ptype;
17843 	uint32_t sw_ptype;
17844 };
17845 
17846 /* Common CLI fields for ptype mapping update*/
17847 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
17848 	TOKEN_STRING_INITIALIZER
17849 		(struct cmd_ptype_mapping_update_result,
17850 		 ptype, "ptype");
17851 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
17852 	TOKEN_STRING_INITIALIZER
17853 		(struct cmd_ptype_mapping_update_result,
17854 		 mapping, "mapping");
17855 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
17856 	TOKEN_STRING_INITIALIZER
17857 		(struct cmd_ptype_mapping_update_result,
17858 		 reset, "update");
17859 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
17860 	TOKEN_NUM_INITIALIZER
17861 		(struct cmd_ptype_mapping_update_result,
17862 		 port_id, UINT16);
17863 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
17864 	TOKEN_NUM_INITIALIZER
17865 		(struct cmd_ptype_mapping_update_result,
17866 		 hw_ptype, UINT8);
17867 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
17868 	TOKEN_NUM_INITIALIZER
17869 		(struct cmd_ptype_mapping_update_result,
17870 		 sw_ptype, UINT32);
17871 
17872 static void
17873 cmd_ptype_mapping_update_parsed(
17874 	void *parsed_result,
17875 	__attribute__((unused)) struct cmdline *cl,
17876 	__attribute__((unused)) void *data)
17877 {
17878 	struct cmd_ptype_mapping_update_result *res = parsed_result;
17879 	int ret = -ENOTSUP;
17880 #ifdef RTE_LIBRTE_I40E_PMD
17881 	struct rte_pmd_i40e_ptype_mapping mapping;
17882 #endif
17883 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17884 		return;
17885 
17886 #ifdef RTE_LIBRTE_I40E_PMD
17887 	mapping.hw_ptype = res->hw_ptype;
17888 	mapping.sw_ptype = res->sw_ptype;
17889 	ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
17890 						&mapping,
17891 						1,
17892 						0);
17893 #endif
17894 
17895 	switch (ret) {
17896 	case 0:
17897 		break;
17898 	case -EINVAL:
17899 		printf("invalid ptype 0x%8x\n", res->sw_ptype);
17900 		break;
17901 	case -ENODEV:
17902 		printf("invalid port_id %d\n", res->port_id);
17903 		break;
17904 	case -ENOTSUP:
17905 		printf("function not implemented\n");
17906 		break;
17907 	default:
17908 		printf("programming error: (%s)\n", strerror(-ret));
17909 	}
17910 }
17911 
17912 cmdline_parse_inst_t cmd_ptype_mapping_update = {
17913 	.f = cmd_ptype_mapping_update_parsed,
17914 	.data = NULL,
17915 	.help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
17916 	.tokens = {
17917 		(void *)&cmd_ptype_mapping_update_ptype,
17918 		(void *)&cmd_ptype_mapping_update_mapping,
17919 		(void *)&cmd_ptype_mapping_update_update,
17920 		(void *)&cmd_ptype_mapping_update_port_id,
17921 		(void *)&cmd_ptype_mapping_update_hw_ptype,
17922 		(void *)&cmd_ptype_mapping_update_sw_ptype,
17923 		NULL,
17924 	},
17925 };
17926 
17927 /* Common result structure for file commands */
17928 struct cmd_cmdfile_result {
17929 	cmdline_fixed_string_t load;
17930 	cmdline_fixed_string_t filename;
17931 };
17932 
17933 /* Common CLI fields for file commands */
17934 cmdline_parse_token_string_t cmd_load_cmdfile =
17935 	TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
17936 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
17937 	TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
17938 
17939 static void
17940 cmd_load_from_file_parsed(
17941 	void *parsed_result,
17942 	__attribute__((unused)) struct cmdline *cl,
17943 	__attribute__((unused)) void *data)
17944 {
17945 	struct cmd_cmdfile_result *res = parsed_result;
17946 
17947 	cmdline_read_from_file(res->filename);
17948 }
17949 
17950 cmdline_parse_inst_t cmd_load_from_file = {
17951 	.f = cmd_load_from_file_parsed,
17952 	.data = NULL,
17953 	.help_str = "load <filename>",
17954 	.tokens = {
17955 		(void *)&cmd_load_cmdfile,
17956 		(void *)&cmd_load_cmdfile_filename,
17957 		NULL,
17958 	},
17959 };
17960 
17961 /* Get Rx offloads capabilities */
17962 struct cmd_rx_offload_get_capa_result {
17963 	cmdline_fixed_string_t show;
17964 	cmdline_fixed_string_t port;
17965 	portid_t port_id;
17966 	cmdline_fixed_string_t rx_offload;
17967 	cmdline_fixed_string_t capabilities;
17968 };
17969 
17970 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
17971 	TOKEN_STRING_INITIALIZER
17972 		(struct cmd_rx_offload_get_capa_result,
17973 		 show, "show");
17974 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
17975 	TOKEN_STRING_INITIALIZER
17976 		(struct cmd_rx_offload_get_capa_result,
17977 		 port, "port");
17978 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
17979 	TOKEN_NUM_INITIALIZER
17980 		(struct cmd_rx_offload_get_capa_result,
17981 		 port_id, UINT16);
17982 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
17983 	TOKEN_STRING_INITIALIZER
17984 		(struct cmd_rx_offload_get_capa_result,
17985 		 rx_offload, "rx_offload");
17986 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
17987 	TOKEN_STRING_INITIALIZER
17988 		(struct cmd_rx_offload_get_capa_result,
17989 		 capabilities, "capabilities");
17990 
17991 static void
17992 print_rx_offloads(uint64_t offloads)
17993 {
17994 	uint64_t single_offload;
17995 	int begin;
17996 	int end;
17997 	int bit;
17998 
17999 	if (offloads == 0)
18000 		return;
18001 
18002 	begin = __builtin_ctzll(offloads);
18003 	end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
18004 
18005 	single_offload = 1ULL << begin;
18006 	for (bit = begin; bit < end; bit++) {
18007 		if (offloads & single_offload)
18008 			printf(" %s",
18009 			       rte_eth_dev_rx_offload_name(single_offload));
18010 		single_offload <<= 1;
18011 	}
18012 }
18013 
18014 static void
18015 cmd_rx_offload_get_capa_parsed(
18016 	void *parsed_result,
18017 	__attribute__((unused)) struct cmdline *cl,
18018 	__attribute__((unused)) void *data)
18019 {
18020 	struct cmd_rx_offload_get_capa_result *res = parsed_result;
18021 	struct rte_eth_dev_info dev_info;
18022 	portid_t port_id = res->port_id;
18023 	uint64_t queue_offloads;
18024 	uint64_t port_offloads;
18025 	int ret;
18026 
18027 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
18028 	if (ret != 0)
18029 		return;
18030 
18031 	queue_offloads = dev_info.rx_queue_offload_capa;
18032 	port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
18033 
18034 	printf("Rx Offloading Capabilities of port %d :\n", port_id);
18035 	printf("  Per Queue :");
18036 	print_rx_offloads(queue_offloads);
18037 
18038 	printf("\n");
18039 	printf("  Per Port  :");
18040 	print_rx_offloads(port_offloads);
18041 	printf("\n\n");
18042 }
18043 
18044 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
18045 	.f = cmd_rx_offload_get_capa_parsed,
18046 	.data = NULL,
18047 	.help_str = "show port <port_id> rx_offload capabilities",
18048 	.tokens = {
18049 		(void *)&cmd_rx_offload_get_capa_show,
18050 		(void *)&cmd_rx_offload_get_capa_port,
18051 		(void *)&cmd_rx_offload_get_capa_port_id,
18052 		(void *)&cmd_rx_offload_get_capa_rx_offload,
18053 		(void *)&cmd_rx_offload_get_capa_capabilities,
18054 		NULL,
18055 	}
18056 };
18057 
18058 /* Get Rx offloads configuration */
18059 struct cmd_rx_offload_get_configuration_result {
18060 	cmdline_fixed_string_t show;
18061 	cmdline_fixed_string_t port;
18062 	portid_t port_id;
18063 	cmdline_fixed_string_t rx_offload;
18064 	cmdline_fixed_string_t configuration;
18065 };
18066 
18067 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
18068 	TOKEN_STRING_INITIALIZER
18069 		(struct cmd_rx_offload_get_configuration_result,
18070 		 show, "show");
18071 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
18072 	TOKEN_STRING_INITIALIZER
18073 		(struct cmd_rx_offload_get_configuration_result,
18074 		 port, "port");
18075 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
18076 	TOKEN_NUM_INITIALIZER
18077 		(struct cmd_rx_offload_get_configuration_result,
18078 		 port_id, UINT16);
18079 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
18080 	TOKEN_STRING_INITIALIZER
18081 		(struct cmd_rx_offload_get_configuration_result,
18082 		 rx_offload, "rx_offload");
18083 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
18084 	TOKEN_STRING_INITIALIZER
18085 		(struct cmd_rx_offload_get_configuration_result,
18086 		 configuration, "configuration");
18087 
18088 static void
18089 cmd_rx_offload_get_configuration_parsed(
18090 	void *parsed_result,
18091 	__attribute__((unused)) struct cmdline *cl,
18092 	__attribute__((unused)) void *data)
18093 {
18094 	struct cmd_rx_offload_get_configuration_result *res = parsed_result;
18095 	struct rte_eth_dev_info dev_info;
18096 	portid_t port_id = res->port_id;
18097 	struct rte_port *port = &ports[port_id];
18098 	uint64_t port_offloads;
18099 	uint64_t queue_offloads;
18100 	uint16_t nb_rx_queues;
18101 	int q;
18102 	int ret;
18103 
18104 	printf("Rx Offloading Configuration of port %d :\n", port_id);
18105 
18106 	port_offloads = port->dev_conf.rxmode.offloads;
18107 	printf("  Port :");
18108 	print_rx_offloads(port_offloads);
18109 	printf("\n");
18110 
18111 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
18112 	if (ret != 0)
18113 		return;
18114 
18115 	nb_rx_queues = dev_info.nb_rx_queues;
18116 	for (q = 0; q < nb_rx_queues; q++) {
18117 		queue_offloads = port->rx_conf[q].offloads;
18118 		printf("  Queue[%2d] :", q);
18119 		print_rx_offloads(queue_offloads);
18120 		printf("\n");
18121 	}
18122 	printf("\n");
18123 }
18124 
18125 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
18126 	.f = cmd_rx_offload_get_configuration_parsed,
18127 	.data = NULL,
18128 	.help_str = "show port <port_id> rx_offload configuration",
18129 	.tokens = {
18130 		(void *)&cmd_rx_offload_get_configuration_show,
18131 		(void *)&cmd_rx_offload_get_configuration_port,
18132 		(void *)&cmd_rx_offload_get_configuration_port_id,
18133 		(void *)&cmd_rx_offload_get_configuration_rx_offload,
18134 		(void *)&cmd_rx_offload_get_configuration_configuration,
18135 		NULL,
18136 	}
18137 };
18138 
18139 /* Enable/Disable a per port offloading */
18140 struct cmd_config_per_port_rx_offload_result {
18141 	cmdline_fixed_string_t port;
18142 	cmdline_fixed_string_t config;
18143 	portid_t port_id;
18144 	cmdline_fixed_string_t rx_offload;
18145 	cmdline_fixed_string_t offload;
18146 	cmdline_fixed_string_t on_off;
18147 };
18148 
18149 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
18150 	TOKEN_STRING_INITIALIZER
18151 		(struct cmd_config_per_port_rx_offload_result,
18152 		 port, "port");
18153 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
18154 	TOKEN_STRING_INITIALIZER
18155 		(struct cmd_config_per_port_rx_offload_result,
18156 		 config, "config");
18157 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
18158 	TOKEN_NUM_INITIALIZER
18159 		(struct cmd_config_per_port_rx_offload_result,
18160 		 port_id, UINT16);
18161 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
18162 	TOKEN_STRING_INITIALIZER
18163 		(struct cmd_config_per_port_rx_offload_result,
18164 		 rx_offload, "rx_offload");
18165 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
18166 	TOKEN_STRING_INITIALIZER
18167 		(struct cmd_config_per_port_rx_offload_result,
18168 		 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
18169 			   "qinq_strip#outer_ipv4_cksum#macsec_strip#"
18170 			   "header_split#vlan_filter#vlan_extend#jumbo_frame#"
18171 			   "scatter#timestamp#security#keep_crc#rss_hash");
18172 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
18173 	TOKEN_STRING_INITIALIZER
18174 		(struct cmd_config_per_port_rx_offload_result,
18175 		 on_off, "on#off");
18176 
18177 static uint64_t
18178 search_rx_offload(const char *name)
18179 {
18180 	uint64_t single_offload;
18181 	const char *single_name;
18182 	int found = 0;
18183 	unsigned int bit;
18184 
18185 	single_offload = 1;
18186 	for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
18187 		single_name = rte_eth_dev_rx_offload_name(single_offload);
18188 		if (!strcasecmp(single_name, name)) {
18189 			found = 1;
18190 			break;
18191 		}
18192 		single_offload <<= 1;
18193 	}
18194 
18195 	if (found)
18196 		return single_offload;
18197 
18198 	return 0;
18199 }
18200 
18201 static void
18202 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
18203 				__attribute__((unused)) struct cmdline *cl,
18204 				__attribute__((unused)) void *data)
18205 {
18206 	struct cmd_config_per_port_rx_offload_result *res = parsed_result;
18207 	portid_t port_id = res->port_id;
18208 	struct rte_eth_dev_info dev_info;
18209 	struct rte_port *port = &ports[port_id];
18210 	uint64_t single_offload;
18211 	uint16_t nb_rx_queues;
18212 	int q;
18213 	int ret;
18214 
18215 	if (port->port_status != RTE_PORT_STOPPED) {
18216 		printf("Error: Can't config offload when Port %d "
18217 		       "is not stopped\n", port_id);
18218 		return;
18219 	}
18220 
18221 	single_offload = search_rx_offload(res->offload);
18222 	if (single_offload == 0) {
18223 		printf("Unknown offload name: %s\n", res->offload);
18224 		return;
18225 	}
18226 
18227 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
18228 	if (ret != 0)
18229 		return;
18230 
18231 	nb_rx_queues = dev_info.nb_rx_queues;
18232 	if (!strcmp(res->on_off, "on")) {
18233 		port->dev_conf.rxmode.offloads |= single_offload;
18234 		for (q = 0; q < nb_rx_queues; q++)
18235 			port->rx_conf[q].offloads |= single_offload;
18236 	} else {
18237 		port->dev_conf.rxmode.offloads &= ~single_offload;
18238 		for (q = 0; q < nb_rx_queues; q++)
18239 			port->rx_conf[q].offloads &= ~single_offload;
18240 	}
18241 
18242 	cmd_reconfig_device_queue(port_id, 1, 1);
18243 }
18244 
18245 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
18246 	.f = cmd_config_per_port_rx_offload_parsed,
18247 	.data = NULL,
18248 	.help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
18249 		    "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
18250 		    "macsec_strip|header_split|vlan_filter|vlan_extend|"
18251 		    "jumbo_frame|scatter|timestamp|security|keep_crc|rss_hash "
18252 		    "on|off",
18253 	.tokens = {
18254 		(void *)&cmd_config_per_port_rx_offload_result_port,
18255 		(void *)&cmd_config_per_port_rx_offload_result_config,
18256 		(void *)&cmd_config_per_port_rx_offload_result_port_id,
18257 		(void *)&cmd_config_per_port_rx_offload_result_rx_offload,
18258 		(void *)&cmd_config_per_port_rx_offload_result_offload,
18259 		(void *)&cmd_config_per_port_rx_offload_result_on_off,
18260 		NULL,
18261 	}
18262 };
18263 
18264 /* Enable/Disable a per queue offloading */
18265 struct cmd_config_per_queue_rx_offload_result {
18266 	cmdline_fixed_string_t port;
18267 	portid_t port_id;
18268 	cmdline_fixed_string_t rxq;
18269 	uint16_t queue_id;
18270 	cmdline_fixed_string_t rx_offload;
18271 	cmdline_fixed_string_t offload;
18272 	cmdline_fixed_string_t on_off;
18273 };
18274 
18275 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
18276 	TOKEN_STRING_INITIALIZER
18277 		(struct cmd_config_per_queue_rx_offload_result,
18278 		 port, "port");
18279 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
18280 	TOKEN_NUM_INITIALIZER
18281 		(struct cmd_config_per_queue_rx_offload_result,
18282 		 port_id, UINT16);
18283 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
18284 	TOKEN_STRING_INITIALIZER
18285 		(struct cmd_config_per_queue_rx_offload_result,
18286 		 rxq, "rxq");
18287 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
18288 	TOKEN_NUM_INITIALIZER
18289 		(struct cmd_config_per_queue_rx_offload_result,
18290 		 queue_id, UINT16);
18291 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
18292 	TOKEN_STRING_INITIALIZER
18293 		(struct cmd_config_per_queue_rx_offload_result,
18294 		 rx_offload, "rx_offload");
18295 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
18296 	TOKEN_STRING_INITIALIZER
18297 		(struct cmd_config_per_queue_rx_offload_result,
18298 		 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
18299 			   "qinq_strip#outer_ipv4_cksum#macsec_strip#"
18300 			   "header_split#vlan_filter#vlan_extend#jumbo_frame#"
18301 			   "scatter#timestamp#security#keep_crc");
18302 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
18303 	TOKEN_STRING_INITIALIZER
18304 		(struct cmd_config_per_queue_rx_offload_result,
18305 		 on_off, "on#off");
18306 
18307 static void
18308 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
18309 				__attribute__((unused)) struct cmdline *cl,
18310 				__attribute__((unused)) void *data)
18311 {
18312 	struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
18313 	struct rte_eth_dev_info dev_info;
18314 	portid_t port_id = res->port_id;
18315 	uint16_t queue_id = res->queue_id;
18316 	struct rte_port *port = &ports[port_id];
18317 	uint64_t single_offload;
18318 	int ret;
18319 
18320 	if (port->port_status != RTE_PORT_STOPPED) {
18321 		printf("Error: Can't config offload when Port %d "
18322 		       "is not stopped\n", port_id);
18323 		return;
18324 	}
18325 
18326 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
18327 	if (ret != 0)
18328 		return;
18329 
18330 	if (queue_id >= dev_info.nb_rx_queues) {
18331 		printf("Error: input queue_id should be 0 ... "
18332 		       "%d\n", dev_info.nb_rx_queues - 1);
18333 		return;
18334 	}
18335 
18336 	single_offload = search_rx_offload(res->offload);
18337 	if (single_offload == 0) {
18338 		printf("Unknown offload name: %s\n", res->offload);
18339 		return;
18340 	}
18341 
18342 	if (!strcmp(res->on_off, "on"))
18343 		port->rx_conf[queue_id].offloads |= single_offload;
18344 	else
18345 		port->rx_conf[queue_id].offloads &= ~single_offload;
18346 
18347 	cmd_reconfig_device_queue(port_id, 1, 1);
18348 }
18349 
18350 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
18351 	.f = cmd_config_per_queue_rx_offload_parsed,
18352 	.data = NULL,
18353 	.help_str = "port <port_id> rxq <queue_id> rx_offload "
18354 		    "vlan_strip|ipv4_cksum|"
18355 		    "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
18356 		    "macsec_strip|header_split|vlan_filter|vlan_extend|"
18357 		    "jumbo_frame|scatter|timestamp|security|keep_crc "
18358 		    "on|off",
18359 	.tokens = {
18360 		(void *)&cmd_config_per_queue_rx_offload_result_port,
18361 		(void *)&cmd_config_per_queue_rx_offload_result_port_id,
18362 		(void *)&cmd_config_per_queue_rx_offload_result_rxq,
18363 		(void *)&cmd_config_per_queue_rx_offload_result_queue_id,
18364 		(void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
18365 		(void *)&cmd_config_per_queue_rx_offload_result_offload,
18366 		(void *)&cmd_config_per_queue_rx_offload_result_on_off,
18367 		NULL,
18368 	}
18369 };
18370 
18371 /* Get Tx offloads capabilities */
18372 struct cmd_tx_offload_get_capa_result {
18373 	cmdline_fixed_string_t show;
18374 	cmdline_fixed_string_t port;
18375 	portid_t port_id;
18376 	cmdline_fixed_string_t tx_offload;
18377 	cmdline_fixed_string_t capabilities;
18378 };
18379 
18380 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
18381 	TOKEN_STRING_INITIALIZER
18382 		(struct cmd_tx_offload_get_capa_result,
18383 		 show, "show");
18384 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
18385 	TOKEN_STRING_INITIALIZER
18386 		(struct cmd_tx_offload_get_capa_result,
18387 		 port, "port");
18388 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
18389 	TOKEN_NUM_INITIALIZER
18390 		(struct cmd_tx_offload_get_capa_result,
18391 		 port_id, UINT16);
18392 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
18393 	TOKEN_STRING_INITIALIZER
18394 		(struct cmd_tx_offload_get_capa_result,
18395 		 tx_offload, "tx_offload");
18396 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
18397 	TOKEN_STRING_INITIALIZER
18398 		(struct cmd_tx_offload_get_capa_result,
18399 		 capabilities, "capabilities");
18400 
18401 static void
18402 print_tx_offloads(uint64_t offloads)
18403 {
18404 	uint64_t single_offload;
18405 	int begin;
18406 	int end;
18407 	int bit;
18408 
18409 	if (offloads == 0)
18410 		return;
18411 
18412 	begin = __builtin_ctzll(offloads);
18413 	end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
18414 
18415 	single_offload = 1ULL << begin;
18416 	for (bit = begin; bit < end; bit++) {
18417 		if (offloads & single_offload)
18418 			printf(" %s",
18419 			       rte_eth_dev_tx_offload_name(single_offload));
18420 		single_offload <<= 1;
18421 	}
18422 }
18423 
18424 static void
18425 cmd_tx_offload_get_capa_parsed(
18426 	void *parsed_result,
18427 	__attribute__((unused)) struct cmdline *cl,
18428 	__attribute__((unused)) void *data)
18429 {
18430 	struct cmd_tx_offload_get_capa_result *res = parsed_result;
18431 	struct rte_eth_dev_info dev_info;
18432 	portid_t port_id = res->port_id;
18433 	uint64_t queue_offloads;
18434 	uint64_t port_offloads;
18435 	int ret;
18436 
18437 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
18438 	if (ret != 0)
18439 		return;
18440 
18441 	queue_offloads = dev_info.tx_queue_offload_capa;
18442 	port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
18443 
18444 	printf("Tx Offloading Capabilities of port %d :\n", port_id);
18445 	printf("  Per Queue :");
18446 	print_tx_offloads(queue_offloads);
18447 
18448 	printf("\n");
18449 	printf("  Per Port  :");
18450 	print_tx_offloads(port_offloads);
18451 	printf("\n\n");
18452 }
18453 
18454 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
18455 	.f = cmd_tx_offload_get_capa_parsed,
18456 	.data = NULL,
18457 	.help_str = "show port <port_id> tx_offload capabilities",
18458 	.tokens = {
18459 		(void *)&cmd_tx_offload_get_capa_show,
18460 		(void *)&cmd_tx_offload_get_capa_port,
18461 		(void *)&cmd_tx_offload_get_capa_port_id,
18462 		(void *)&cmd_tx_offload_get_capa_tx_offload,
18463 		(void *)&cmd_tx_offload_get_capa_capabilities,
18464 		NULL,
18465 	}
18466 };
18467 
18468 /* Get Tx offloads configuration */
18469 struct cmd_tx_offload_get_configuration_result {
18470 	cmdline_fixed_string_t show;
18471 	cmdline_fixed_string_t port;
18472 	portid_t port_id;
18473 	cmdline_fixed_string_t tx_offload;
18474 	cmdline_fixed_string_t configuration;
18475 };
18476 
18477 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
18478 	TOKEN_STRING_INITIALIZER
18479 		(struct cmd_tx_offload_get_configuration_result,
18480 		 show, "show");
18481 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
18482 	TOKEN_STRING_INITIALIZER
18483 		(struct cmd_tx_offload_get_configuration_result,
18484 		 port, "port");
18485 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
18486 	TOKEN_NUM_INITIALIZER
18487 		(struct cmd_tx_offload_get_configuration_result,
18488 		 port_id, UINT16);
18489 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
18490 	TOKEN_STRING_INITIALIZER
18491 		(struct cmd_tx_offload_get_configuration_result,
18492 		 tx_offload, "tx_offload");
18493 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
18494 	TOKEN_STRING_INITIALIZER
18495 		(struct cmd_tx_offload_get_configuration_result,
18496 		 configuration, "configuration");
18497 
18498 static void
18499 cmd_tx_offload_get_configuration_parsed(
18500 	void *parsed_result,
18501 	__attribute__((unused)) struct cmdline *cl,
18502 	__attribute__((unused)) void *data)
18503 {
18504 	struct cmd_tx_offload_get_configuration_result *res = parsed_result;
18505 	struct rte_eth_dev_info dev_info;
18506 	portid_t port_id = res->port_id;
18507 	struct rte_port *port = &ports[port_id];
18508 	uint64_t port_offloads;
18509 	uint64_t queue_offloads;
18510 	uint16_t nb_tx_queues;
18511 	int q;
18512 	int ret;
18513 
18514 	printf("Tx Offloading Configuration of port %d :\n", port_id);
18515 
18516 	port_offloads = port->dev_conf.txmode.offloads;
18517 	printf("  Port :");
18518 	print_tx_offloads(port_offloads);
18519 	printf("\n");
18520 
18521 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
18522 	if (ret != 0)
18523 		return;
18524 
18525 	nb_tx_queues = dev_info.nb_tx_queues;
18526 	for (q = 0; q < nb_tx_queues; q++) {
18527 		queue_offloads = port->tx_conf[q].offloads;
18528 		printf("  Queue[%2d] :", q);
18529 		print_tx_offloads(queue_offloads);
18530 		printf("\n");
18531 	}
18532 	printf("\n");
18533 }
18534 
18535 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
18536 	.f = cmd_tx_offload_get_configuration_parsed,
18537 	.data = NULL,
18538 	.help_str = "show port <port_id> tx_offload configuration",
18539 	.tokens = {
18540 		(void *)&cmd_tx_offload_get_configuration_show,
18541 		(void *)&cmd_tx_offload_get_configuration_port,
18542 		(void *)&cmd_tx_offload_get_configuration_port_id,
18543 		(void *)&cmd_tx_offload_get_configuration_tx_offload,
18544 		(void *)&cmd_tx_offload_get_configuration_configuration,
18545 		NULL,
18546 	}
18547 };
18548 
18549 /* Enable/Disable a per port offloading */
18550 struct cmd_config_per_port_tx_offload_result {
18551 	cmdline_fixed_string_t port;
18552 	cmdline_fixed_string_t config;
18553 	portid_t port_id;
18554 	cmdline_fixed_string_t tx_offload;
18555 	cmdline_fixed_string_t offload;
18556 	cmdline_fixed_string_t on_off;
18557 };
18558 
18559 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
18560 	TOKEN_STRING_INITIALIZER
18561 		(struct cmd_config_per_port_tx_offload_result,
18562 		 port, "port");
18563 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
18564 	TOKEN_STRING_INITIALIZER
18565 		(struct cmd_config_per_port_tx_offload_result,
18566 		 config, "config");
18567 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
18568 	TOKEN_NUM_INITIALIZER
18569 		(struct cmd_config_per_port_tx_offload_result,
18570 		 port_id, UINT16);
18571 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
18572 	TOKEN_STRING_INITIALIZER
18573 		(struct cmd_config_per_port_tx_offload_result,
18574 		 tx_offload, "tx_offload");
18575 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
18576 	TOKEN_STRING_INITIALIZER
18577 		(struct cmd_config_per_port_tx_offload_result,
18578 		 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18579 			  "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18580 			  "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18581 			  "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18582 			  "mt_lockfree#multi_segs#mbuf_fast_free#security");
18583 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
18584 	TOKEN_STRING_INITIALIZER
18585 		(struct cmd_config_per_port_tx_offload_result,
18586 		 on_off, "on#off");
18587 
18588 static uint64_t
18589 search_tx_offload(const char *name)
18590 {
18591 	uint64_t single_offload;
18592 	const char *single_name;
18593 	int found = 0;
18594 	unsigned int bit;
18595 
18596 	single_offload = 1;
18597 	for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
18598 		single_name = rte_eth_dev_tx_offload_name(single_offload);
18599 		if (single_name == NULL)
18600 			break;
18601 		if (!strcasecmp(single_name, name)) {
18602 			found = 1;
18603 			break;
18604 		} else if (!strcasecmp(single_name, "UNKNOWN"))
18605 			break;
18606 		single_offload <<= 1;
18607 	}
18608 
18609 	if (found)
18610 		return single_offload;
18611 
18612 	return 0;
18613 }
18614 
18615 static void
18616 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
18617 				__attribute__((unused)) struct cmdline *cl,
18618 				__attribute__((unused)) void *data)
18619 {
18620 	struct cmd_config_per_port_tx_offload_result *res = parsed_result;
18621 	portid_t port_id = res->port_id;
18622 	struct rte_eth_dev_info dev_info;
18623 	struct rte_port *port = &ports[port_id];
18624 	uint64_t single_offload;
18625 	uint16_t nb_tx_queues;
18626 	int q;
18627 	int ret;
18628 
18629 	if (port->port_status != RTE_PORT_STOPPED) {
18630 		printf("Error: Can't config offload when Port %d "
18631 		       "is not stopped\n", port_id);
18632 		return;
18633 	}
18634 
18635 	single_offload = search_tx_offload(res->offload);
18636 	if (single_offload == 0) {
18637 		printf("Unknown offload name: %s\n", res->offload);
18638 		return;
18639 	}
18640 
18641 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
18642 	if (ret != 0)
18643 		return;
18644 
18645 	nb_tx_queues = dev_info.nb_tx_queues;
18646 	if (!strcmp(res->on_off, "on")) {
18647 		port->dev_conf.txmode.offloads |= single_offload;
18648 		for (q = 0; q < nb_tx_queues; q++)
18649 			port->tx_conf[q].offloads |= single_offload;
18650 	} else {
18651 		port->dev_conf.txmode.offloads &= ~single_offload;
18652 		for (q = 0; q < nb_tx_queues; q++)
18653 			port->tx_conf[q].offloads &= ~single_offload;
18654 	}
18655 
18656 	cmd_reconfig_device_queue(port_id, 1, 1);
18657 }
18658 
18659 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
18660 	.f = cmd_config_per_port_tx_offload_parsed,
18661 	.data = NULL,
18662 	.help_str = "port config <port_id> tx_offload "
18663 		    "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
18664 		    "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
18665 		    "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
18666 		    "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
18667 		    "mt_lockfree|multi_segs|mbuf_fast_free|security on|off",
18668 	.tokens = {
18669 		(void *)&cmd_config_per_port_tx_offload_result_port,
18670 		(void *)&cmd_config_per_port_tx_offload_result_config,
18671 		(void *)&cmd_config_per_port_tx_offload_result_port_id,
18672 		(void *)&cmd_config_per_port_tx_offload_result_tx_offload,
18673 		(void *)&cmd_config_per_port_tx_offload_result_offload,
18674 		(void *)&cmd_config_per_port_tx_offload_result_on_off,
18675 		NULL,
18676 	}
18677 };
18678 
18679 /* Enable/Disable a per queue offloading */
18680 struct cmd_config_per_queue_tx_offload_result {
18681 	cmdline_fixed_string_t port;
18682 	portid_t port_id;
18683 	cmdline_fixed_string_t txq;
18684 	uint16_t queue_id;
18685 	cmdline_fixed_string_t tx_offload;
18686 	cmdline_fixed_string_t offload;
18687 	cmdline_fixed_string_t on_off;
18688 };
18689 
18690 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
18691 	TOKEN_STRING_INITIALIZER
18692 		(struct cmd_config_per_queue_tx_offload_result,
18693 		 port, "port");
18694 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
18695 	TOKEN_NUM_INITIALIZER
18696 		(struct cmd_config_per_queue_tx_offload_result,
18697 		 port_id, UINT16);
18698 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
18699 	TOKEN_STRING_INITIALIZER
18700 		(struct cmd_config_per_queue_tx_offload_result,
18701 		 txq, "txq");
18702 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
18703 	TOKEN_NUM_INITIALIZER
18704 		(struct cmd_config_per_queue_tx_offload_result,
18705 		 queue_id, UINT16);
18706 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
18707 	TOKEN_STRING_INITIALIZER
18708 		(struct cmd_config_per_queue_tx_offload_result,
18709 		 tx_offload, "tx_offload");
18710 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
18711 	TOKEN_STRING_INITIALIZER
18712 		(struct cmd_config_per_queue_tx_offload_result,
18713 		 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18714 			  "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18715 			  "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18716 			  "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18717 			  "mt_lockfree#multi_segs#mbuf_fast_free#security");
18718 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
18719 	TOKEN_STRING_INITIALIZER
18720 		(struct cmd_config_per_queue_tx_offload_result,
18721 		 on_off, "on#off");
18722 
18723 static void
18724 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
18725 				__attribute__((unused)) struct cmdline *cl,
18726 				__attribute__((unused)) void *data)
18727 {
18728 	struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
18729 	struct rte_eth_dev_info dev_info;
18730 	portid_t port_id = res->port_id;
18731 	uint16_t queue_id = res->queue_id;
18732 	struct rte_port *port = &ports[port_id];
18733 	uint64_t single_offload;
18734 	int ret;
18735 
18736 	if (port->port_status != RTE_PORT_STOPPED) {
18737 		printf("Error: Can't config offload when Port %d "
18738 		       "is not stopped\n", port_id);
18739 		return;
18740 	}
18741 
18742 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
18743 	if (ret != 0)
18744 		return;
18745 
18746 	if (queue_id >= dev_info.nb_tx_queues) {
18747 		printf("Error: input queue_id should be 0 ... "
18748 		       "%d\n", dev_info.nb_tx_queues - 1);
18749 		return;
18750 	}
18751 
18752 	single_offload = search_tx_offload(res->offload);
18753 	if (single_offload == 0) {
18754 		printf("Unknown offload name: %s\n", res->offload);
18755 		return;
18756 	}
18757 
18758 	if (!strcmp(res->on_off, "on"))
18759 		port->tx_conf[queue_id].offloads |= single_offload;
18760 	else
18761 		port->tx_conf[queue_id].offloads &= ~single_offload;
18762 
18763 	cmd_reconfig_device_queue(port_id, 1, 1);
18764 }
18765 
18766 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
18767 	.f = cmd_config_per_queue_tx_offload_parsed,
18768 	.data = NULL,
18769 	.help_str = "port <port_id> txq <queue_id> tx_offload "
18770 		    "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
18771 		    "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
18772 		    "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
18773 		    "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
18774 		    "mt_lockfree|multi_segs|mbuf_fast_free|security "
18775 		    "on|off",
18776 	.tokens = {
18777 		(void *)&cmd_config_per_queue_tx_offload_result_port,
18778 		(void *)&cmd_config_per_queue_tx_offload_result_port_id,
18779 		(void *)&cmd_config_per_queue_tx_offload_result_txq,
18780 		(void *)&cmd_config_per_queue_tx_offload_result_queue_id,
18781 		(void *)&cmd_config_per_queue_tx_offload_result_txoffload,
18782 		(void *)&cmd_config_per_queue_tx_offload_result_offload,
18783 		(void *)&cmd_config_per_queue_tx_offload_result_on_off,
18784 		NULL,
18785 	}
18786 };
18787 
18788 /* *** configure tx_metadata for specific port *** */
18789 struct cmd_config_tx_metadata_specific_result {
18790 	cmdline_fixed_string_t port;
18791 	cmdline_fixed_string_t keyword;
18792 	uint16_t port_id;
18793 	cmdline_fixed_string_t item;
18794 	uint32_t value;
18795 };
18796 
18797 static void
18798 cmd_config_tx_metadata_specific_parsed(void *parsed_result,
18799 				__attribute__((unused)) struct cmdline *cl,
18800 				__attribute__((unused)) void *data)
18801 {
18802 	struct cmd_config_tx_metadata_specific_result *res = parsed_result;
18803 
18804 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
18805 		return;
18806 	ports[res->port_id].tx_metadata = res->value;
18807 	/* Add/remove callback to insert valid metadata in every Tx packet. */
18808 	if (ports[res->port_id].tx_metadata)
18809 		add_tx_md_callback(res->port_id);
18810 	else
18811 		remove_tx_md_callback(res->port_id);
18812 	rte_flow_dynf_metadata_register();
18813 }
18814 
18815 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
18816 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18817 			port, "port");
18818 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
18819 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18820 			keyword, "config");
18821 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
18822 	TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18823 			port_id, UINT16);
18824 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
18825 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18826 			item, "tx_metadata");
18827 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
18828 	TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18829 			value, UINT32);
18830 
18831 cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
18832 	.f = cmd_config_tx_metadata_specific_parsed,
18833 	.data = NULL,
18834 	.help_str = "port config <port_id> tx_metadata <value>",
18835 	.tokens = {
18836 		(void *)&cmd_config_tx_metadata_specific_port,
18837 		(void *)&cmd_config_tx_metadata_specific_keyword,
18838 		(void *)&cmd_config_tx_metadata_specific_id,
18839 		(void *)&cmd_config_tx_metadata_specific_item,
18840 		(void *)&cmd_config_tx_metadata_specific_value,
18841 		NULL,
18842 	},
18843 };
18844 
18845 /* *** set dynf *** */
18846 struct cmd_config_tx_dynf_specific_result {
18847 	cmdline_fixed_string_t port;
18848 	cmdline_fixed_string_t keyword;
18849 	uint16_t port_id;
18850 	cmdline_fixed_string_t item;
18851 	cmdline_fixed_string_t name;
18852 	cmdline_fixed_string_t value;
18853 };
18854 
18855 static void
18856 cmd_config_dynf_specific_parsed(void *parsed_result,
18857 				__attribute__((unused)) struct cmdline *cl,
18858 				__attribute__((unused)) void *data)
18859 {
18860 	struct cmd_config_tx_dynf_specific_result *res = parsed_result;
18861 	struct rte_mbuf_dynflag desc_flag;
18862 	int flag;
18863 	uint64_t old_port_flags;
18864 
18865 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
18866 		return;
18867 	flag = rte_mbuf_dynflag_lookup(res->name, NULL);
18868 	if (flag <= 0) {
18869 		strcpy(desc_flag.name, res->name);
18870 		desc_flag.flags = 0;
18871 		flag = rte_mbuf_dynflag_register(&desc_flag);
18872 		if (flag < 0) {
18873 			printf("Can't register flag\n");
18874 			return;
18875 		}
18876 		strcpy(dynf_names[flag], res->name);
18877 	}
18878 	old_port_flags = ports[res->port_id].mbuf_dynf;
18879 	if (!strcmp(res->value, "set")) {
18880 		ports[res->port_id].mbuf_dynf |= 1UL << flag;
18881 		if (old_port_flags == 0)
18882 			add_tx_dynf_callback(res->port_id);
18883 	} else {
18884 		ports[res->port_id].mbuf_dynf &= ~(1UL << flag);
18885 		if (ports[res->port_id].mbuf_dynf == 0)
18886 			remove_tx_dynf_callback(res->port_id);
18887 	}
18888 }
18889 
18890 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_port =
18891 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
18892 			keyword, "port");
18893 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_keyword =
18894 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
18895 			keyword, "config");
18896 cmdline_parse_token_num_t cmd_config_tx_dynf_specific_port_id =
18897 	TOKEN_NUM_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
18898 			port_id, UINT16);
18899 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_item =
18900 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
18901 			item, "dynf");
18902 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_name =
18903 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
18904 			name, NULL);
18905 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_value =
18906 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
18907 			value, "set#clear");
18908 
18909 cmdline_parse_inst_t cmd_config_tx_dynf_specific = {
18910 	.f = cmd_config_dynf_specific_parsed,
18911 	.data = NULL,
18912 	.help_str = "port config <port id> dynf <name> set|clear",
18913 	.tokens = {
18914 		(void *)&cmd_config_tx_dynf_specific_port,
18915 		(void *)&cmd_config_tx_dynf_specific_keyword,
18916 		(void *)&cmd_config_tx_dynf_specific_port_id,
18917 		(void *)&cmd_config_tx_dynf_specific_item,
18918 		(void *)&cmd_config_tx_dynf_specific_name,
18919 		(void *)&cmd_config_tx_dynf_specific_value,
18920 		NULL,
18921 	},
18922 };
18923 
18924 /* *** display tx_metadata per port configuration *** */
18925 struct cmd_show_tx_metadata_result {
18926 	cmdline_fixed_string_t cmd_show;
18927 	cmdline_fixed_string_t cmd_port;
18928 	cmdline_fixed_string_t cmd_keyword;
18929 	portid_t cmd_pid;
18930 };
18931 
18932 static void
18933 cmd_show_tx_metadata_parsed(void *parsed_result,
18934 		__attribute__((unused)) struct cmdline *cl,
18935 		__attribute__((unused)) void *data)
18936 {
18937 	struct cmd_show_tx_metadata_result *res = parsed_result;
18938 
18939 	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
18940 		printf("invalid port id %u\n", res->cmd_pid);
18941 		return;
18942 	}
18943 	if (!strcmp(res->cmd_keyword, "tx_metadata")) {
18944 		printf("Port %u tx_metadata: %u\n", res->cmd_pid,
18945 		       ports[res->cmd_pid].tx_metadata);
18946 	}
18947 }
18948 
18949 cmdline_parse_token_string_t cmd_show_tx_metadata_show =
18950 	TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
18951 			cmd_show, "show");
18952 cmdline_parse_token_string_t cmd_show_tx_metadata_port =
18953 	TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
18954 			cmd_port, "port");
18955 cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
18956 	TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
18957 			cmd_pid, UINT16);
18958 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
18959 	TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
18960 			cmd_keyword, "tx_metadata");
18961 
18962 cmdline_parse_inst_t cmd_show_tx_metadata = {
18963 	.f = cmd_show_tx_metadata_parsed,
18964 	.data = NULL,
18965 	.help_str = "show port <port_id> tx_metadata",
18966 	.tokens = {
18967 		(void *)&cmd_show_tx_metadata_show,
18968 		(void *)&cmd_show_tx_metadata_port,
18969 		(void *)&cmd_show_tx_metadata_pid,
18970 		(void *)&cmd_show_tx_metadata_keyword,
18971 		NULL,
18972 	},
18973 };
18974 
18975 /* show port supported ptypes */
18976 
18977 /* Common result structure for show port ptypes */
18978 struct cmd_show_port_supported_ptypes_result {
18979 	cmdline_fixed_string_t show;
18980 	cmdline_fixed_string_t port;
18981 	portid_t port_id;
18982 	cmdline_fixed_string_t ptypes;
18983 };
18984 
18985 /* Common CLI fields for show port ptypes */
18986 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =
18987 	TOKEN_STRING_INITIALIZER
18988 		(struct cmd_show_port_supported_ptypes_result,
18989 		 show, "show");
18990 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
18991 	TOKEN_STRING_INITIALIZER
18992 		(struct cmd_show_port_supported_ptypes_result,
18993 		 port, "port");
18994 cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =
18995 	TOKEN_NUM_INITIALIZER
18996 		(struct cmd_show_port_supported_ptypes_result,
18997 		 port_id, UINT16);
18998 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =
18999 	TOKEN_STRING_INITIALIZER
19000 		(struct cmd_show_port_supported_ptypes_result,
19001 		 ptypes, "ptypes");
19002 
19003 static void
19004 cmd_show_port_supported_ptypes_parsed(
19005 	void *parsed_result,
19006 	__attribute__((unused)) struct cmdline *cl,
19007 	__attribute__((unused)) void *data)
19008 {
19009 #define RSVD_PTYPE_MASK       0xf0000000
19010 #define MAX_PTYPES_PER_LAYER  16
19011 #define LTYPE_NAMESIZE        32
19012 #define PTYPE_NAMESIZE        256
19013 	struct cmd_show_port_supported_ptypes_result *res = parsed_result;
19014 	char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE];
19015 	uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
19016 	uint32_t ptypes[MAX_PTYPES_PER_LAYER];
19017 	uint16_t port_id = res->port_id;
19018 	int ret, i;
19019 
19020 	ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0);
19021 	if (ret < 0)
19022 		return;
19023 
19024 	while (ptype_mask != RSVD_PTYPE_MASK) {
19025 
19026 		switch (ptype_mask) {
19027 		case RTE_PTYPE_L2_MASK:
19028 			strlcpy(ltype, "L2", sizeof(ltype));
19029 			break;
19030 		case RTE_PTYPE_L3_MASK:
19031 			strlcpy(ltype, "L3", sizeof(ltype));
19032 			break;
19033 		case RTE_PTYPE_L4_MASK:
19034 			strlcpy(ltype, "L4", sizeof(ltype));
19035 			break;
19036 		case RTE_PTYPE_TUNNEL_MASK:
19037 			strlcpy(ltype, "Tunnel", sizeof(ltype));
19038 			break;
19039 		case RTE_PTYPE_INNER_L2_MASK:
19040 			strlcpy(ltype, "Inner L2", sizeof(ltype));
19041 			break;
19042 		case RTE_PTYPE_INNER_L3_MASK:
19043 			strlcpy(ltype, "Inner L3", sizeof(ltype));
19044 			break;
19045 		case RTE_PTYPE_INNER_L4_MASK:
19046 			strlcpy(ltype, "Inner L4", sizeof(ltype));
19047 			break;
19048 		default:
19049 			return;
19050 		}
19051 
19052 		ret = rte_eth_dev_get_supported_ptypes(res->port_id,
19053 						       ptype_mask, ptypes,
19054 						       MAX_PTYPES_PER_LAYER);
19055 
19056 		if (ret > 0)
19057 			printf("Supported %s ptypes:\n", ltype);
19058 		else
19059 			printf("%s ptypes unsupported\n", ltype);
19060 
19061 		for (i = 0; i < ret; ++i) {
19062 			rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
19063 			printf("%s\n", buf);
19064 		}
19065 
19066 		ptype_mask <<= 4;
19067 	}
19068 }
19069 
19070 cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
19071 	.f = cmd_show_port_supported_ptypes_parsed,
19072 	.data = NULL,
19073 	.help_str = "show port <port_id> ptypes",
19074 	.tokens = {
19075 		(void *)&cmd_show_port_supported_ptypes_show,
19076 		(void *)&cmd_show_port_supported_ptypes_port,
19077 		(void *)&cmd_show_port_supported_ptypes_port_id,
19078 		(void *)&cmd_show_port_supported_ptypes_ptypes,
19079 		NULL,
19080 	},
19081 };
19082 
19083 /* *** display rx/tx descriptor status *** */
19084 struct cmd_show_rx_tx_desc_status_result {
19085 	cmdline_fixed_string_t cmd_show;
19086 	cmdline_fixed_string_t cmd_port;
19087 	cmdline_fixed_string_t cmd_keyword;
19088 	cmdline_fixed_string_t cmd_desc;
19089 	cmdline_fixed_string_t cmd_status;
19090 	portid_t cmd_pid;
19091 	portid_t cmd_qid;
19092 	portid_t cmd_did;
19093 };
19094 
19095 static void
19096 cmd_show_rx_tx_desc_status_parsed(void *parsed_result,
19097 		__attribute__((unused)) struct cmdline *cl,
19098 		__attribute__((unused)) void *data)
19099 {
19100 	struct cmd_show_rx_tx_desc_status_result *res = parsed_result;
19101 	int rc;
19102 
19103 	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
19104 		printf("invalid port id %u\n", res->cmd_pid);
19105 		return;
19106 	}
19107 
19108 	if (!strcmp(res->cmd_keyword, "rxq")) {
19109 		rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid,
19110 					     res->cmd_did);
19111 		if (rc < 0) {
19112 			printf("Invalid queueid = %d\n", res->cmd_qid);
19113 			return;
19114 		}
19115 		if (rc == RTE_ETH_RX_DESC_AVAIL)
19116 			printf("Desc status = AVAILABLE\n");
19117 		else if (rc == RTE_ETH_RX_DESC_DONE)
19118 			printf("Desc status = DONE\n");
19119 		else
19120 			printf("Desc status = UNAVAILABLE\n");
19121 	} else if (!strcmp(res->cmd_keyword, "txq")) {
19122 		rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid,
19123 					     res->cmd_did);
19124 		if (rc < 0) {
19125 			printf("Invalid queueid = %d\n", res->cmd_qid);
19126 			return;
19127 		}
19128 		if (rc == RTE_ETH_TX_DESC_FULL)
19129 			printf("Desc status = FULL\n");
19130 		else if (rc == RTE_ETH_TX_DESC_DONE)
19131 			printf("Desc status = DONE\n");
19132 		else
19133 			printf("Desc status = UNAVAILABLE\n");
19134 	}
19135 }
19136 
19137 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show =
19138 	TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19139 			cmd_show, "show");
19140 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port =
19141 	TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19142 			cmd_port, "port");
19143 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid =
19144 	TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19145 			cmd_pid, UINT16);
19146 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword =
19147 	TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19148 			cmd_keyword, "rxq#txq");
19149 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid =
19150 	TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19151 			cmd_qid, UINT16);
19152 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc =
19153 	TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19154 			cmd_desc, "desc");
19155 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did =
19156 	TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19157 			cmd_did, UINT16);
19158 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status =
19159 	TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19160 			cmd_status, "status");
19161 cmdline_parse_inst_t cmd_show_rx_tx_desc_status = {
19162 	.f = cmd_show_rx_tx_desc_status_parsed,
19163 	.data = NULL,
19164 	.help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> "
19165 		"status",
19166 	.tokens = {
19167 		(void *)&cmd_show_rx_tx_desc_status_show,
19168 		(void *)&cmd_show_rx_tx_desc_status_port,
19169 		(void *)&cmd_show_rx_tx_desc_status_pid,
19170 		(void *)&cmd_show_rx_tx_desc_status_keyword,
19171 		(void *)&cmd_show_rx_tx_desc_status_qid,
19172 		(void *)&cmd_show_rx_tx_desc_status_desc,
19173 		(void *)&cmd_show_rx_tx_desc_status_did,
19174 		(void *)&cmd_show_rx_tx_desc_status_status,
19175 		NULL,
19176 	},
19177 };
19178 
19179 /* Common result structure for set port ptypes */
19180 struct cmd_set_port_ptypes_result {
19181 	cmdline_fixed_string_t set;
19182 	cmdline_fixed_string_t port;
19183 	portid_t port_id;
19184 	cmdline_fixed_string_t ptype_mask;
19185 	uint32_t mask;
19186 };
19187 
19188 /* Common CLI fields for set port ptypes */
19189 cmdline_parse_token_string_t cmd_set_port_ptypes_set =
19190 	TOKEN_STRING_INITIALIZER
19191 		(struct cmd_set_port_ptypes_result,
19192 		 set, "set");
19193 cmdline_parse_token_string_t cmd_set_port_ptypes_port =
19194 	TOKEN_STRING_INITIALIZER
19195 		(struct cmd_set_port_ptypes_result,
19196 		 port, "port");
19197 cmdline_parse_token_num_t cmd_set_port_ptypes_port_id =
19198 	TOKEN_NUM_INITIALIZER
19199 		(struct cmd_set_port_ptypes_result,
19200 		 port_id, UINT16);
19201 cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str =
19202 	TOKEN_STRING_INITIALIZER
19203 		(struct cmd_set_port_ptypes_result,
19204 		 ptype_mask, "ptype_mask");
19205 cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 =
19206 	TOKEN_NUM_INITIALIZER
19207 		(struct cmd_set_port_ptypes_result,
19208 		 mask, UINT32);
19209 
19210 static void
19211 cmd_set_port_ptypes_parsed(
19212 	void *parsed_result,
19213 	__attribute__((unused)) struct cmdline *cl,
19214 	__attribute__((unused)) void *data)
19215 {
19216 	struct cmd_set_port_ptypes_result *res = parsed_result;
19217 #define PTYPE_NAMESIZE        256
19218 	char ptype_name[PTYPE_NAMESIZE];
19219 	uint16_t port_id = res->port_id;
19220 	uint32_t ptype_mask = res->mask;
19221 	int ret, i;
19222 
19223 	ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK,
19224 					       NULL, 0);
19225 	if (ret <= 0) {
19226 		printf("Port %d doesn't support any ptypes.\n", port_id);
19227 		return;
19228 	}
19229 
19230 	uint32_t ptypes[ret];
19231 
19232 	ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret);
19233 	if (ret < 0) {
19234 		printf("Unable to set requested ptypes for Port %d\n", port_id);
19235 		return;
19236 	}
19237 
19238 	printf("Successfully set following ptypes for Port %d\n", port_id);
19239 	for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) {
19240 		rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name));
19241 		printf("%s\n", ptype_name);
19242 	}
19243 
19244 	clear_ptypes = false;
19245 }
19246 
19247 cmdline_parse_inst_t cmd_set_port_ptypes = {
19248 	.f = cmd_set_port_ptypes_parsed,
19249 	.data = NULL,
19250 	.help_str = "set port <port_id> ptype_mask <mask>",
19251 	.tokens = {
19252 		(void *)&cmd_set_port_ptypes_set,
19253 		(void *)&cmd_set_port_ptypes_port,
19254 		(void *)&cmd_set_port_ptypes_port_id,
19255 		(void *)&cmd_set_port_ptypes_mask_str,
19256 		(void *)&cmd_set_port_ptypes_mask_u32,
19257 		NULL,
19258 	},
19259 };
19260 
19261 /* *** display mac addresses added to a port *** */
19262 struct cmd_showport_macs_result {
19263 	cmdline_fixed_string_t cmd_show;
19264 	cmdline_fixed_string_t cmd_port;
19265 	cmdline_fixed_string_t cmd_keyword;
19266 	portid_t cmd_pid;
19267 };
19268 
19269 static void
19270 cmd_showport_macs_parsed(void *parsed_result,
19271 		__attribute__((unused)) struct cmdline *cl,
19272 		__attribute__((unused)) void *data)
19273 {
19274 	struct cmd_showport_macs_result *res = parsed_result;
19275 
19276 	if (port_id_is_invalid(res->cmd_pid, ENABLED_WARN))
19277 		return;
19278 
19279 	if (!strcmp(res->cmd_keyword, "macs"))
19280 		show_macs(res->cmd_pid);
19281 	else if (!strcmp(res->cmd_keyword, "mcast_macs"))
19282 		show_mcast_macs(res->cmd_pid);
19283 }
19284 
19285 cmdline_parse_token_string_t cmd_showport_macs_show =
19286 	TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
19287 			cmd_show, "show");
19288 cmdline_parse_token_string_t cmd_showport_macs_port =
19289 	TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
19290 			cmd_port, "port");
19291 cmdline_parse_token_num_t cmd_showport_macs_pid =
19292 	TOKEN_NUM_INITIALIZER(struct cmd_showport_macs_result,
19293 			cmd_pid, UINT16);
19294 cmdline_parse_token_string_t cmd_showport_macs_keyword =
19295 	TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
19296 			cmd_keyword, "macs#mcast_macs");
19297 
19298 cmdline_parse_inst_t cmd_showport_macs = {
19299 	.f = cmd_showport_macs_parsed,
19300 	.data = NULL,
19301 	.help_str = "show port <port_id> macs|mcast_macs",
19302 	.tokens = {
19303 		(void *)&cmd_showport_macs_show,
19304 		(void *)&cmd_showport_macs_port,
19305 		(void *)&cmd_showport_macs_pid,
19306 		(void *)&cmd_showport_macs_keyword,
19307 		NULL,
19308 	},
19309 };
19310 
19311 /* ******************************************************************************** */
19312 
19313 /* list of instructions */
19314 cmdline_parse_ctx_t main_ctx[] = {
19315 	(cmdline_parse_inst_t *)&cmd_help_brief,
19316 	(cmdline_parse_inst_t *)&cmd_help_long,
19317 	(cmdline_parse_inst_t *)&cmd_quit,
19318 	(cmdline_parse_inst_t *)&cmd_load_from_file,
19319 	(cmdline_parse_inst_t *)&cmd_showport,
19320 	(cmdline_parse_inst_t *)&cmd_showqueue,
19321 	(cmdline_parse_inst_t *)&cmd_showportall,
19322 	(cmdline_parse_inst_t *)&cmd_showdevice,
19323 	(cmdline_parse_inst_t *)&cmd_showcfg,
19324 	(cmdline_parse_inst_t *)&cmd_showfwdall,
19325 	(cmdline_parse_inst_t *)&cmd_start,
19326 	(cmdline_parse_inst_t *)&cmd_start_tx_first,
19327 	(cmdline_parse_inst_t *)&cmd_start_tx_first_n,
19328 	(cmdline_parse_inst_t *)&cmd_set_link_up,
19329 	(cmdline_parse_inst_t *)&cmd_set_link_down,
19330 	(cmdline_parse_inst_t *)&cmd_reset,
19331 	(cmdline_parse_inst_t *)&cmd_set_numbers,
19332 	(cmdline_parse_inst_t *)&cmd_set_log,
19333 	(cmdline_parse_inst_t *)&cmd_set_txpkts,
19334 	(cmdline_parse_inst_t *)&cmd_set_txsplit,
19335 	(cmdline_parse_inst_t *)&cmd_set_fwd_list,
19336 	(cmdline_parse_inst_t *)&cmd_set_fwd_mask,
19337 	(cmdline_parse_inst_t *)&cmd_set_fwd_mode,
19338 	(cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
19339 	(cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
19340 	(cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
19341 	(cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
19342 	(cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
19343 	(cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
19344 	(cmdline_parse_inst_t *)&cmd_set_flush_rx,
19345 	(cmdline_parse_inst_t *)&cmd_set_link_check,
19346 	(cmdline_parse_inst_t *)&cmd_set_bypass_mode,
19347 	(cmdline_parse_inst_t *)&cmd_set_bypass_event,
19348 	(cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
19349 	(cmdline_parse_inst_t *)&cmd_show_bypass_config,
19350 #ifdef RTE_LIBRTE_PMD_BOND
19351 	(cmdline_parse_inst_t *) &cmd_set_bonding_mode,
19352 	(cmdline_parse_inst_t *) &cmd_show_bonding_config,
19353 	(cmdline_parse_inst_t *) &cmd_set_bonding_primary,
19354 	(cmdline_parse_inst_t *) &cmd_add_bonding_slave,
19355 	(cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
19356 	(cmdline_parse_inst_t *) &cmd_create_bonded_device,
19357 	(cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
19358 	(cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
19359 	(cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
19360 	(cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
19361 	(cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
19362 #endif
19363 	(cmdline_parse_inst_t *)&cmd_vlan_offload,
19364 	(cmdline_parse_inst_t *)&cmd_vlan_tpid,
19365 	(cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
19366 	(cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
19367 	(cmdline_parse_inst_t *)&cmd_tx_vlan_set,
19368 	(cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
19369 	(cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
19370 	(cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
19371 	(cmdline_parse_inst_t *)&cmd_csum_set,
19372 	(cmdline_parse_inst_t *)&cmd_csum_show,
19373 	(cmdline_parse_inst_t *)&cmd_csum_tunnel,
19374 	(cmdline_parse_inst_t *)&cmd_tso_set,
19375 	(cmdline_parse_inst_t *)&cmd_tso_show,
19376 	(cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
19377 	(cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
19378 	(cmdline_parse_inst_t *)&cmd_gro_enable,
19379 	(cmdline_parse_inst_t *)&cmd_gro_flush,
19380 	(cmdline_parse_inst_t *)&cmd_gro_show,
19381 	(cmdline_parse_inst_t *)&cmd_gso_enable,
19382 	(cmdline_parse_inst_t *)&cmd_gso_size,
19383 	(cmdline_parse_inst_t *)&cmd_gso_show,
19384 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set,
19385 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
19386 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
19387 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
19388 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
19389 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
19390 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
19391 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
19392 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
19393 	(cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
19394 	(cmdline_parse_inst_t *)&cmd_config_dcb,
19395 	(cmdline_parse_inst_t *)&cmd_read_reg,
19396 	(cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
19397 	(cmdline_parse_inst_t *)&cmd_read_reg_bit,
19398 	(cmdline_parse_inst_t *)&cmd_write_reg,
19399 	(cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
19400 	(cmdline_parse_inst_t *)&cmd_write_reg_bit,
19401 	(cmdline_parse_inst_t *)&cmd_read_rxd_txd,
19402 	(cmdline_parse_inst_t *)&cmd_stop,
19403 	(cmdline_parse_inst_t *)&cmd_mac_addr,
19404 	(cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
19405 	(cmdline_parse_inst_t *)&cmd_set_qmap,
19406 	(cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
19407 	(cmdline_parse_inst_t *)&cmd_operate_port,
19408 	(cmdline_parse_inst_t *)&cmd_operate_specific_port,
19409 	(cmdline_parse_inst_t *)&cmd_operate_attach_port,
19410 	(cmdline_parse_inst_t *)&cmd_operate_detach_port,
19411 	(cmdline_parse_inst_t *)&cmd_operate_detach_device,
19412 	(cmdline_parse_inst_t *)&cmd_set_port_setup_on,
19413 	(cmdline_parse_inst_t *)&cmd_config_speed_all,
19414 	(cmdline_parse_inst_t *)&cmd_config_speed_specific,
19415 	(cmdline_parse_inst_t *)&cmd_config_loopback_all,
19416 	(cmdline_parse_inst_t *)&cmd_config_loopback_specific,
19417 	(cmdline_parse_inst_t *)&cmd_config_rx_tx,
19418 	(cmdline_parse_inst_t *)&cmd_config_mtu,
19419 	(cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
19420 	(cmdline_parse_inst_t *)&cmd_config_max_lro_pkt_size,
19421 	(cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
19422 	(cmdline_parse_inst_t *)&cmd_config_rss,
19423 	(cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
19424 	(cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
19425 	(cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
19426 	(cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
19427 	(cmdline_parse_inst_t *)&cmd_config_rss_reta,
19428 	(cmdline_parse_inst_t *)&cmd_showport_reta,
19429 	(cmdline_parse_inst_t *)&cmd_showport_macs,
19430 	(cmdline_parse_inst_t *)&cmd_config_burst,
19431 	(cmdline_parse_inst_t *)&cmd_config_thresh,
19432 	(cmdline_parse_inst_t *)&cmd_config_threshold,
19433 	(cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
19434 	(cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
19435 	(cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
19436 	(cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
19437 	(cmdline_parse_inst_t *)&cmd_queue_rate_limit,
19438 	(cmdline_parse_inst_t *)&cmd_tunnel_filter,
19439 	(cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
19440 	(cmdline_parse_inst_t *)&cmd_global_config,
19441 	(cmdline_parse_inst_t *)&cmd_set_mirror_mask,
19442 	(cmdline_parse_inst_t *)&cmd_set_mirror_link,
19443 	(cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
19444 	(cmdline_parse_inst_t *)&cmd_showport_rss_hash,
19445 	(cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
19446 	(cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
19447 	(cmdline_parse_inst_t *)&cmd_dump,
19448 	(cmdline_parse_inst_t *)&cmd_dump_one,
19449 	(cmdline_parse_inst_t *)&cmd_ethertype_filter,
19450 	(cmdline_parse_inst_t *)&cmd_syn_filter,
19451 	(cmdline_parse_inst_t *)&cmd_2tuple_filter,
19452 	(cmdline_parse_inst_t *)&cmd_5tuple_filter,
19453 	(cmdline_parse_inst_t *)&cmd_flex_filter,
19454 	(cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
19455 	(cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
19456 	(cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
19457 	(cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
19458 	(cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
19459 	(cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
19460 	(cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
19461 	(cmdline_parse_inst_t *)&cmd_flush_flow_director,
19462 	(cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
19463 	(cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
19464 	(cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
19465 	(cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
19466 	(cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
19467 	(cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
19468 	(cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
19469 	(cmdline_parse_inst_t *)&cmd_get_hash_global_config,
19470 	(cmdline_parse_inst_t *)&cmd_set_hash_global_config,
19471 	(cmdline_parse_inst_t *)&cmd_set_hash_input_set,
19472 	(cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
19473 	(cmdline_parse_inst_t *)&cmd_flow,
19474 	(cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
19475 	(cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
19476 	(cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
19477 	(cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
19478 	(cmdline_parse_inst_t *)&cmd_create_port_meter,
19479 	(cmdline_parse_inst_t *)&cmd_enable_port_meter,
19480 	(cmdline_parse_inst_t *)&cmd_disable_port_meter,
19481 	(cmdline_parse_inst_t *)&cmd_del_port_meter,
19482 	(cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
19483 	(cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
19484 	(cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
19485 	(cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
19486 	(cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
19487 	(cmdline_parse_inst_t *)&cmd_mcast_addr,
19488 	(cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
19489 	(cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
19490 	(cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
19491 	(cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
19492 	(cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
19493 	(cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
19494 	(cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
19495 	(cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
19496 	(cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
19497 	(cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
19498 	(cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
19499 	(cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
19500 	(cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
19501 	(cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
19502 	(cmdline_parse_inst_t *)&cmd_set_tx_loopback,
19503 	(cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
19504 	(cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
19505 	(cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
19506 	(cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
19507 	(cmdline_parse_inst_t *)&cmd_set_macsec_sc,
19508 	(cmdline_parse_inst_t *)&cmd_set_macsec_sa,
19509 	(cmdline_parse_inst_t *)&cmd_set_vf_traffic,
19510 	(cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
19511 	(cmdline_parse_inst_t *)&cmd_vf_rate_limit,
19512 	(cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
19513 	(cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
19514 	(cmdline_parse_inst_t *)&cmd_set_vf_promisc,
19515 	(cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
19516 	(cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
19517 	(cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
19518 	(cmdline_parse_inst_t *)&cmd_vf_max_bw,
19519 	(cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
19520 	(cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
19521 	(cmdline_parse_inst_t *)&cmd_strict_link_prio,
19522 	(cmdline_parse_inst_t *)&cmd_tc_min_bw,
19523 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
19524 	(cmdline_parse_inst_t *)&cmd_set_port_tm_hierarchy_default,
19525 #endif
19526 	(cmdline_parse_inst_t *)&cmd_set_vxlan,
19527 	(cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl,
19528 	(cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
19529 	(cmdline_parse_inst_t *)&cmd_set_nvgre,
19530 	(cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
19531 	(cmdline_parse_inst_t *)&cmd_set_l2_encap,
19532 	(cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
19533 	(cmdline_parse_inst_t *)&cmd_set_l2_decap,
19534 	(cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
19535 	(cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
19536 	(cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
19537 	(cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
19538 	(cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
19539 	(cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
19540 	(cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
19541 	(cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
19542 	(cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
19543 	(cmdline_parse_inst_t *)&cmd_ddp_add,
19544 	(cmdline_parse_inst_t *)&cmd_ddp_del,
19545 	(cmdline_parse_inst_t *)&cmd_ddp_get_list,
19546 	(cmdline_parse_inst_t *)&cmd_ddp_get_info,
19547 	(cmdline_parse_inst_t *)&cmd_cfg_input_set,
19548 	(cmdline_parse_inst_t *)&cmd_clear_input_set,
19549 	(cmdline_parse_inst_t *)&cmd_show_vf_stats,
19550 	(cmdline_parse_inst_t *)&cmd_clear_vf_stats,
19551 	(cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes,
19552 	(cmdline_parse_inst_t *)&cmd_set_port_ptypes,
19553 	(cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
19554 	(cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
19555 	(cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
19556 	(cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
19557 
19558 	(cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
19559 	(cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
19560 	(cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
19561 	(cmdline_parse_inst_t *)&cmd_queue_region,
19562 	(cmdline_parse_inst_t *)&cmd_region_flowtype,
19563 	(cmdline_parse_inst_t *)&cmd_user_priority_region,
19564 	(cmdline_parse_inst_t *)&cmd_flush_queue_region,
19565 	(cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
19566 	(cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
19567 	(cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
19568 	(cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
19569 	(cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
19570 	(cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
19571 	(cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
19572 	(cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
19573 	(cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
19574 	(cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
19575 	(cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
19576 	(cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
19577 	(cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
19578 	(cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
19579 	(cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
19580 	(cmdline_parse_inst_t *)&cmd_del_port_tm_node,
19581 	(cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
19582 	(cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
19583 	(cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
19584 	(cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
19585 	(cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
19586 	(cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
19587 	(cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
19588 	(cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
19589 	(cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
19590 	(cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
19591 	(cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
19592 	(cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
19593 	(cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
19594 	(cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
19595 	(cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
19596 	(cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
19597 #ifdef RTE_LIBRTE_BPF
19598 	(cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
19599 	(cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
19600 #endif
19601 	(cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
19602 	(cmdline_parse_inst_t *)&cmd_show_tx_metadata,
19603 	(cmdline_parse_inst_t *)&cmd_show_rx_tx_desc_status,
19604 	(cmdline_parse_inst_t *)&cmd_set_raw,
19605 	(cmdline_parse_inst_t *)&cmd_show_set_raw,
19606 	(cmdline_parse_inst_t *)&cmd_show_set_raw_all,
19607 	(cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific,
19608 	NULL,
19609 };
19610 
19611 /* read cmdline commands from file */
19612 void
19613 cmdline_read_from_file(const char *filename)
19614 {
19615 	struct cmdline *cl;
19616 
19617 	cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
19618 	if (cl == NULL) {
19619 		printf("Failed to create file based cmdline context: %s\n",
19620 		       filename);
19621 		return;
19622 	}
19623 
19624 	cmdline_interact(cl);
19625 	cmdline_quit(cl);
19626 
19627 	cmdline_free(cl);
19628 
19629 	printf("Read CLI commands from %s\n", filename);
19630 }
19631 
19632 /* prompt function, called from main on MASTER lcore */
19633 void
19634 prompt(void)
19635 {
19636 	/* initialize non-constant commands */
19637 	cmd_set_fwd_mode_init();
19638 	cmd_set_fwd_retry_mode_init();
19639 
19640 	testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
19641 	if (testpmd_cl == NULL)
19642 		return;
19643 	cmdline_interact(testpmd_cl);
19644 	cmdline_stdin_exit(testpmd_cl);
19645 }
19646 
19647 void
19648 prompt_exit(void)
19649 {
19650 	if (testpmd_cl != NULL)
19651 		cmdline_quit(testpmd_cl);
19652 }
19653 
19654 static void
19655 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
19656 {
19657 	if (id == (portid_t)RTE_PORT_ALL) {
19658 		portid_t pid;
19659 
19660 		RTE_ETH_FOREACH_DEV(pid) {
19661 			/* check if need_reconfig has been set to 1 */
19662 			if (ports[pid].need_reconfig == 0)
19663 				ports[pid].need_reconfig = dev;
19664 			/* check if need_reconfig_queues has been set to 1 */
19665 			if (ports[pid].need_reconfig_queues == 0)
19666 				ports[pid].need_reconfig_queues = queue;
19667 		}
19668 	} else if (!port_id_is_invalid(id, DISABLED_WARN)) {
19669 		/* check if need_reconfig has been set to 1 */
19670 		if (ports[id].need_reconfig == 0)
19671 			ports[id].need_reconfig = dev;
19672 		/* check if need_reconfig_queues has been set to 1 */
19673 		if (ports[id].need_reconfig_queues == 0)
19674 			ports[id].need_reconfig_queues = queue;
19675 	}
19676 }
19677