xref: /dpdk/app/test-pmd/cmdline.c (revision 5dba3b9c4c131b88a78bcecfef39db23ebc47873)
1 /*-
2  *   BSD LICENSE
3  *
4  *   Copyright(c) 2010-2016 Intel Corporation. All rights reserved.
5  *   Copyright(c) 2014 6WIND S.A.
6  *   All rights reserved.
7  *
8  *   Redistribution and use in source and binary forms, with or without
9  *   modification, are permitted provided that the following conditions
10  *   are met:
11  *
12  *     * Redistributions of source code must retain the above copyright
13  *       notice, this list of conditions and the following disclaimer.
14  *     * Redistributions in binary form must reproduce the above copyright
15  *       notice, this list of conditions and the following disclaimer in
16  *       the documentation and/or other materials provided with the
17  *       distribution.
18  *     * Neither the name of Intel Corporation nor the names of its
19  *       contributors may be used to endorse or promote products derived
20  *       from this software without specific prior written permission.
21  *
22  *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23  *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24  *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25  *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26  *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27  *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28  *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29  *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30  *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31  *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32  *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33  */
34 
35 #include <stdarg.h>
36 #include <errno.h>
37 #include <stdio.h>
38 #include <stdint.h>
39 #include <string.h>
40 #include <termios.h>
41 #include <unistd.h>
42 #include <inttypes.h>
43 #ifndef __linux__
44 #ifndef __FreeBSD__
45 #include <net/socket.h>
46 #else
47 #include <sys/socket.h>
48 #endif
49 #endif
50 #include <netinet/in.h>
51 
52 #include <sys/queue.h>
53 
54 #include <rte_common.h>
55 #include <rte_byteorder.h>
56 #include <rte_log.h>
57 #include <rte_debug.h>
58 #include <rte_cycles.h>
59 #include <rte_memory.h>
60 #include <rte_memzone.h>
61 #include <rte_malloc.h>
62 #include <rte_launch.h>
63 #include <rte_eal.h>
64 #include <rte_per_lcore.h>
65 #include <rte_lcore.h>
66 #include <rte_atomic.h>
67 #include <rte_branch_prediction.h>
68 #include <rte_ring.h>
69 #include <rte_mempool.h>
70 #include <rte_interrupts.h>
71 #include <rte_pci.h>
72 #include <rte_ether.h>
73 #include <rte_ethdev.h>
74 #include <rte_string_fns.h>
75 #include <rte_devargs.h>
76 #include <rte_eth_ctrl.h>
77 #include <rte_flow.h>
78 #include <rte_gro.h>
79 
80 #include <cmdline_rdline.h>
81 #include <cmdline_parse.h>
82 #include <cmdline_parse_num.h>
83 #include <cmdline_parse_string.h>
84 #include <cmdline_parse_ipaddr.h>
85 #include <cmdline_parse_etheraddr.h>
86 #include <cmdline_socket.h>
87 #include <cmdline.h>
88 #ifdef RTE_LIBRTE_PMD_BOND
89 #include <rte_eth_bond.h>
90 #include <rte_eth_bond_8023ad.h>
91 #endif
92 #ifdef RTE_LIBRTE_IXGBE_PMD
93 #include <rte_pmd_ixgbe.h>
94 #endif
95 #ifdef RTE_LIBRTE_I40E_PMD
96 #include <rte_pmd_i40e.h>
97 #endif
98 #ifdef RTE_LIBRTE_BNXT_PMD
99 #include <rte_pmd_bnxt.h>
100 #endif
101 #include "testpmd.h"
102 #include "cmdline_mtr.h"
103 #include "cmdline_tm.h"
104 
105 static struct cmdline *testpmd_cl;
106 
107 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
108 
109 /* *** Help command with introduction. *** */
110 struct cmd_help_brief_result {
111 	cmdline_fixed_string_t help;
112 };
113 
114 static void cmd_help_brief_parsed(__attribute__((unused)) void *parsed_result,
115                                   struct cmdline *cl,
116                                   __attribute__((unused)) void *data)
117 {
118 	cmdline_printf(
119 		cl,
120 		"\n"
121 		"Help is available for the following sections:\n\n"
122 		"    help control    : Start and stop forwarding.\n"
123 		"    help display    : Displaying port, stats and config "
124 		"information.\n"
125 		"    help config     : Configuration information.\n"
126 		"    help ports      : Configuring ports.\n"
127 		"    help registers  : Reading and setting port registers.\n"
128 		"    help filters    : Filters configuration help.\n"
129 		"    help all        : All of the above sections.\n\n"
130 	);
131 
132 }
133 
134 cmdline_parse_token_string_t cmd_help_brief_help =
135 	TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
136 
137 cmdline_parse_inst_t cmd_help_brief = {
138 	.f = cmd_help_brief_parsed,
139 	.data = NULL,
140 	.help_str = "help: Show help",
141 	.tokens = {
142 		(void *)&cmd_help_brief_help,
143 		NULL,
144 	},
145 };
146 
147 /* *** Help command with help sections. *** */
148 struct cmd_help_long_result {
149 	cmdline_fixed_string_t help;
150 	cmdline_fixed_string_t section;
151 };
152 
153 static void cmd_help_long_parsed(void *parsed_result,
154                                  struct cmdline *cl,
155                                  __attribute__((unused)) void *data)
156 {
157 	int show_all = 0;
158 	struct cmd_help_long_result *res = parsed_result;
159 
160 	if (!strcmp(res->section, "all"))
161 		show_all = 1;
162 
163 	if (show_all || !strcmp(res->section, "control")) {
164 
165 		cmdline_printf(
166 			cl,
167 			"\n"
168 			"Control forwarding:\n"
169 			"-------------------\n\n"
170 
171 			"start\n"
172 			"    Start packet forwarding with current configuration.\n\n"
173 
174 			"start tx_first\n"
175 			"    Start packet forwarding with current config"
176 			" after sending one burst of packets.\n\n"
177 
178 			"stop\n"
179 			"    Stop packet forwarding, and display accumulated"
180 			" statistics.\n\n"
181 
182 			"quit\n"
183 			"    Quit to prompt.\n\n"
184 		);
185 	}
186 
187 	if (show_all || !strcmp(res->section, "display")) {
188 
189 		cmdline_printf(
190 			cl,
191 			"\n"
192 			"Display:\n"
193 			"--------\n\n"
194 
195 			"show port (info|stats|xstats|fdir|stat_qmap|dcb_tc|cap) (port_id|all)\n"
196 			"    Display information for port_id, or all.\n\n"
197 
198 			"show port X rss reta (size) (mask0,mask1,...)\n"
199 			"    Display the rss redirection table entry indicated"
200 			" by masks on port X. size is used to indicate the"
201 			" hardware supported reta size\n\n"
202 
203 			"show port rss-hash ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|"
204 			"ipv4-sctp|ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
205 			"ipv6-other|l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex [key]\n"
206 			"    Display the RSS hash functions and RSS hash key"
207 			" of port X\n\n"
208 
209 			"clear port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n"
210 			"    Clear information for port_id, or all.\n\n"
211 
212 			"show (rxq|txq) info (port_id) (queue_id)\n"
213 			"    Display information for configured RX/TX queue.\n\n"
214 
215 			"show config (rxtx|cores|fwd|txpkts)\n"
216 			"    Display the given configuration.\n\n"
217 
218 			"read rxd (port_id) (queue_id) (rxd_id)\n"
219 			"    Display an RX descriptor of a port RX queue.\n\n"
220 
221 			"read txd (port_id) (queue_id) (txd_id)\n"
222 			"    Display a TX descriptor of a port TX queue.\n\n"
223 
224 			"ddp get list (port_id)\n"
225 			"    Get ddp profile info list\n\n"
226 
227 			"ddp get info (profile_path)\n"
228 			"    Get ddp profile information.\n\n"
229 
230 			"show vf stats (port_id) (vf_id)\n"
231 			"    Display a VF's statistics.\n\n"
232 
233 			"clear vf stats (port_id) (vf_id)\n"
234 			"    Reset a VF's statistics.\n\n"
235 
236 			"show port (port_id) pctype mapping\n"
237 			"    Get flow ptype to pctype mapping on a port\n\n"
238 
239 			"show port meter stats (port_id) (meter_id) (clear)\n"
240 			"    Get meter stats on a port\n\n"
241                         "show port tm cap (port_id)\n"
242                         "       Display the port TM capability.\n\n"
243 
244                         "show port tm level cap (port_id) (level_id)\n"
245                         "       Display the port TM hierarchical level capability.\n\n"
246 
247                         "show port tm node cap (port_id) (node_id)\n"
248                         "       Display the port TM node capability.\n\n"
249 
250                         "show port tm node type (port_id) (node_id)\n"
251                         "       Display the port TM node type.\n\n"
252 
253                         "show port tm node stats (port_id) (node_id) (clear)\n"
254                         "       Display the port TM node stats.\n\n"
255 
256 		);
257 	}
258 
259 	if (show_all || !strcmp(res->section, "config")) {
260 		cmdline_printf(
261 			cl,
262 			"\n"
263 			"Configuration:\n"
264 			"--------------\n"
265 			"Configuration changes only become active when"
266 			" forwarding is started/restarted.\n\n"
267 
268 			"set default\n"
269 			"    Reset forwarding to the default configuration.\n\n"
270 
271 			"set verbose (level)\n"
272 			"    Set the debug verbosity level X.\n\n"
273 
274 			"set nbport (num)\n"
275 			"    Set number of ports.\n\n"
276 
277 			"set nbcore (num)\n"
278 			"    Set number of cores.\n\n"
279 
280 			"set coremask (mask)\n"
281 			"    Set the forwarding cores hexadecimal mask.\n\n"
282 
283 			"set portmask (mask)\n"
284 			"    Set the forwarding ports hexadecimal mask.\n\n"
285 
286 			"set burst (num)\n"
287 			"    Set number of packets per burst.\n\n"
288 
289 			"set burst tx delay (microseconds) retry (num)\n"
290 			"    Set the transmit delay time and number of retries,"
291 			" effective when retry is enabled.\n\n"
292 
293 			"set txpkts (x[,y]*)\n"
294 			"    Set the length of each segment of TXONLY"
295 			" and optionally CSUM packets.\n\n"
296 
297 			"set txsplit (off|on|rand)\n"
298 			"    Set the split policy for the TX packets."
299 			" Right now only applicable for CSUM and TXONLY"
300 			" modes\n\n"
301 
302 			"set corelist (x[,y]*)\n"
303 			"    Set the list of forwarding cores.\n\n"
304 
305 			"set portlist (x[,y]*)\n"
306 			"    Set the list of forwarding ports.\n\n"
307 
308 			"set tx loopback (port_id) (on|off)\n"
309 			"    Enable or disable tx loopback.\n\n"
310 
311 			"set all queues drop (port_id) (on|off)\n"
312 			"    Set drop enable bit for all queues.\n\n"
313 
314 			"set vf split drop (port_id) (vf_id) (on|off)\n"
315 			"    Set split drop enable bit for a VF from the PF.\n\n"
316 
317 			"set vf mac antispoof (port_id) (vf_id) (on|off).\n"
318 			"    Set MAC antispoof for a VF from the PF.\n\n"
319 
320 			"set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n"
321 			"    Enable MACsec offload.\n\n"
322 
323 			"set macsec offload (port_id) off\n"
324 			"    Disable MACsec offload.\n\n"
325 
326 			"set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
327 			"    Configure MACsec secure connection (SC).\n\n"
328 
329 			"set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n"
330 			"    Configure MACsec secure association (SA).\n\n"
331 
332 			"set vf broadcast (port_id) (vf_id) (on|off)\n"
333 			"    Set VF broadcast for a VF from the PF.\n\n"
334 
335 			"vlan set strip (on|off) (port_id)\n"
336 			"    Set the VLAN strip on a port.\n\n"
337 
338 			"vlan set stripq (on|off) (port_id,queue_id)\n"
339 			"    Set the VLAN strip for a queue on a port.\n\n"
340 
341 			"set vf vlan stripq (port_id) (vf_id) (on|off)\n"
342 			"    Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
343 
344 			"set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
345 			"    Set VLAN insert for a VF from the PF.\n\n"
346 
347 			"set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
348 			"    Set VLAN antispoof for a VF from the PF.\n\n"
349 
350 			"set vf vlan tag (port_id) (vf_id) (on|off)\n"
351 			"    Set VLAN tag for a VF from the PF.\n\n"
352 
353 			"set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n"
354 			"    Set a VF's max bandwidth(Mbps).\n\n"
355 
356 			"set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n"
357 			"    Set all TCs' min bandwidth(%%) on a VF.\n\n"
358 
359 			"set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n"
360 			"    Set a TC's max bandwidth(Mbps) on a VF.\n\n"
361 
362 			"set tx strict-link-priority (port_id) (tc_bitmap)\n"
363 			"    Set some TCs' strict link priority mode on a physical port.\n\n"
364 
365 			"set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n"
366 			"    Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n"
367 
368 			"vlan set filter (on|off) (port_id)\n"
369 			"    Set the VLAN filter on a port.\n\n"
370 
371 			"vlan set qinq (on|off) (port_id)\n"
372 			"    Set the VLAN QinQ (extended queue in queue)"
373 			" on a port.\n\n"
374 
375 			"vlan set (inner|outer) tpid (value) (port_id)\n"
376 			"    Set the VLAN TPID for Packet Filtering on"
377 			" a port\n\n"
378 
379 			"rx_vlan add (vlan_id|all) (port_id)\n"
380 			"    Add a vlan_id, or all identifiers, to the set"
381 			" of VLAN identifiers filtered by port_id.\n\n"
382 
383 			"rx_vlan rm (vlan_id|all) (port_id)\n"
384 			"    Remove a vlan_id, or all identifiers, from the set"
385 			" of VLAN identifiers filtered by port_id.\n\n"
386 
387 			"rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
388 			"    Add a vlan_id, to the set of VLAN identifiers"
389 			"filtered for VF(s) from port_id.\n\n"
390 
391 			"rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
392 			"    Remove a vlan_id, to the set of VLAN identifiers"
393 			"filtered for VF(s) from port_id.\n\n"
394 
395 			"tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) "
396 			"(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
397 			"imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
398 			"   add a tunnel filter of a port.\n\n"
399 
400 			"tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) "
401 			"(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
402 			"imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
403 			"   remove a tunnel filter of a port.\n\n"
404 
405 			"rx_vxlan_port add (udp_port) (port_id)\n"
406 			"    Add an UDP port for VXLAN packet filter on a port\n\n"
407 
408 			"rx_vxlan_port rm (udp_port) (port_id)\n"
409 			"    Remove an UDP port for VXLAN packet filter on a port\n\n"
410 
411 			"tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
412 			"    Set hardware insertion of VLAN IDs (single or double VLAN "
413 			"depends on the number of VLAN IDs) in packets sent on a port.\n\n"
414 
415 			"tx_vlan set pvid port_id vlan_id (on|off)\n"
416 			"    Set port based TX VLAN insertion.\n\n"
417 
418 			"tx_vlan reset (port_id)\n"
419 			"    Disable hardware insertion of a VLAN header in"
420 			" packets sent on a port.\n\n"
421 
422 			"csum set (ip|udp|tcp|sctp|outer-ip) (hw|sw) (port_id)\n"
423 			"    Select hardware or software calculation of the"
424 			" checksum when transmitting a packet using the"
425 			" csum forward engine.\n"
426 			"    ip|udp|tcp|sctp always concern the inner layer.\n"
427 			"    outer-ip concerns the outer IP layer in"
428 			" case the packet is recognized as a tunnel packet by"
429 			" the forward engine (vxlan, gre and ipip are supported)\n"
430 			"    Please check the NIC datasheet for HW limits.\n\n"
431 
432 			"csum parse-tunnel (on|off) (tx_port_id)\n"
433 			"    If disabled, treat tunnel packets as non-tunneled"
434 			" packets (treat inner headers as payload). The port\n"
435 			"    argument is the port used for TX in csum forward"
436 			" engine.\n\n"
437 
438 			"csum show (port_id)\n"
439 			"    Display tx checksum offload configuration\n\n"
440 
441 			"tso set (segsize) (portid)\n"
442 			"    Enable TCP Segmentation Offload in csum forward"
443 			" engine.\n"
444 			"    Please check the NIC datasheet for HW limits.\n\n"
445 
446 			"tso show (portid)"
447 			"    Display the status of TCP Segmentation Offload.\n\n"
448 
449 			"set port (port_id) gro on|off\n"
450 			"    Enable or disable Generic Receive Offload in"
451 			" csum forwarding engine.\n\n"
452 
453 			"show port (port_id) gro\n"
454 			"    Display GRO configuration.\n\n"
455 
456 			"set gro flush (cycles)\n"
457 			"    Set the cycle to flush GROed packets from"
458 			" reassembly tables.\n\n"
459 
460 			"set port (port_id) gso (on|off)"
461 			"    Enable or disable Generic Segmentation Offload in"
462 			" csum forwarding engine.\n\n"
463 
464 			"set gso segsz (length)\n"
465 			"    Set max packet length for output GSO segments,"
466 			" including packet header and payload.\n\n"
467 
468 			"show port (port_id) gso\n"
469 			"    Show GSO configuration.\n\n"
470 
471 			"set fwd (%s)\n"
472 			"    Set packet forwarding mode.\n\n"
473 
474 			"mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
475 			"    Add a MAC address on port_id.\n\n"
476 
477 			"mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
478 			"    Remove a MAC address from port_id.\n\n"
479 
480 			"mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
481 			"    Set the default MAC address for port_id.\n\n"
482 
483 			"mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
484 			"    Add a MAC address for a VF on the port.\n\n"
485 
486 			"set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
487 			"    Set the MAC address for a VF from the PF.\n\n"
488 
489 			"set eth-peer (port_id) (peer_addr)\n"
490 			"    set the peer address for certain port.\n\n"
491 
492 			"set port (port_id) uta (mac_address|all) (on|off)\n"
493 			"    Add/Remove a or all unicast hash filter(s)"
494 			"from port X.\n\n"
495 
496 			"set promisc (port_id|all) (on|off)\n"
497 			"    Set the promiscuous mode on port_id, or all.\n\n"
498 
499 			"set allmulti (port_id|all) (on|off)\n"
500 			"    Set the allmulti mode on port_id, or all.\n\n"
501 
502 			"set vf promisc (port_id) (vf_id) (on|off)\n"
503 			"    Set unicast promiscuous mode for a VF from the PF.\n\n"
504 
505 			"set vf allmulti (port_id) (vf_id) (on|off)\n"
506 			"    Set multicast promiscuous mode for a VF from the PF.\n\n"
507 
508 			"set flow_ctrl rx (on|off) tx (on|off) (high_water)"
509 			" (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
510 			" (on|off) autoneg (on|off) (port_id)\n"
511 			"set flow_ctrl rx (on|off) (portid)\n"
512 			"set flow_ctrl tx (on|off) (portid)\n"
513 			"set flow_ctrl high_water (high_water) (portid)\n"
514 			"set flow_ctrl low_water (low_water) (portid)\n"
515 			"set flow_ctrl pause_time (pause_time) (portid)\n"
516 			"set flow_ctrl send_xon (send_xon) (portid)\n"
517 			"set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
518 			"set flow_ctrl autoneg (on|off) (port_id)\n"
519 			"    Set the link flow control parameter on a port.\n\n"
520 
521 			"set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
522 			" (low_water) (pause_time) (priority) (port_id)\n"
523 			"    Set the priority flow control parameter on a"
524 			" port.\n\n"
525 
526 			"set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
527 			"    Set statistics mapping (qmapping 0..15) for RX/TX"
528 			" queue on port.\n"
529 			"    e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
530 			" on port 0 to mapping 5.\n\n"
531 
532 			"set xstats-hide-zero on|off\n"
533 			"    Set the option to hide the zero values"
534 			" for xstats display.\n"
535 
536 			"set port (port_id) vf (vf_id) rx|tx on|off\n"
537 			"    Enable/Disable a VF receive/tranmit from a port\n\n"
538 
539 			"set port (port_id) vf (vf_id) (mac_addr)"
540 			" (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
541 			"   Add/Remove unicast or multicast MAC addr filter"
542 			" for a VF.\n\n"
543 
544 			"set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
545 			"|MPE) (on|off)\n"
546 			"    AUPE:accepts untagged VLAN;"
547 			"ROPE:accept unicast hash\n\n"
548 			"    BAM:accepts broadcast packets;"
549 			"MPE:accepts all multicast packets\n\n"
550 			"    Enable/Disable a VF receive mode of a port\n\n"
551 
552 			"set port (port_id) queue (queue_id) rate (rate_num)\n"
553 			"    Set rate limit for a queue of a port\n\n"
554 
555 			"set port (port_id) vf (vf_id) rate (rate_num) "
556 			"queue_mask (queue_mask_value)\n"
557 			"    Set rate limit for queues in VF of a port\n\n"
558 
559 			"set port (port_id) mirror-rule (rule_id)"
560 			" (pool-mirror-up|pool-mirror-down|vlan-mirror)"
561 			" (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
562 			"   Set pool or vlan type mirror rule on a port.\n"
563 			"   e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
564 			" dst-pool 0 on' enable mirror traffic with vlan 0,1"
565 			" to pool 0.\n\n"
566 
567 			"set port (port_id) mirror-rule (rule_id)"
568 			" (uplink-mirror|downlink-mirror) dst-pool"
569 			" (pool_id) (on|off)\n"
570 			"   Set uplink or downlink type mirror rule on a port.\n"
571 			"   e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
572 			" 0 on' enable mirror income traffic to pool 0.\n\n"
573 
574 			"reset port (port_id) mirror-rule (rule_id)\n"
575 			"   Reset a mirror rule.\n\n"
576 
577 			"set flush_rx (on|off)\n"
578 			"   Flush (default) or don't flush RX streams before"
579 			" forwarding. Mainly used with PCAP drivers.\n\n"
580 
581 			"set bypass mode (normal|bypass|isolate) (port_id)\n"
582 			"   Set the bypass mode for the lowest port on bypass enabled"
583 			" NIC.\n\n"
584 
585 			"set bypass event (timeout|os_on|os_off|power_on|power_off) "
586 			"mode (normal|bypass|isolate) (port_id)\n"
587 			"   Set the event required to initiate specified bypass mode for"
588 			" the lowest port on a bypass enabled NIC where:\n"
589 			"       timeout   = enable bypass after watchdog timeout.\n"
590 			"       os_on     = enable bypass when OS/board is powered on.\n"
591 			"       os_off    = enable bypass when OS/board is powered off.\n"
592 			"       power_on  = enable bypass when power supply is turned on.\n"
593 			"       power_off = enable bypass when power supply is turned off."
594 			"\n\n"
595 
596 			"set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
597 			"   Set the bypass watchdog timeout to 'n' seconds"
598 			" where 0 = instant.\n\n"
599 
600 			"show bypass config (port_id)\n"
601 			"   Show the bypass configuration for a bypass enabled NIC"
602 			" using the lowest port on the NIC.\n\n"
603 
604 #ifdef RTE_LIBRTE_PMD_BOND
605 			"create bonded device (mode) (socket)\n"
606 			"	Create a new bonded device with specific bonding mode and socket.\n\n"
607 
608 			"add bonding slave (slave_id) (port_id)\n"
609 			"	Add a slave device to a bonded device.\n\n"
610 
611 			"remove bonding slave (slave_id) (port_id)\n"
612 			"	Remove a slave device from a bonded device.\n\n"
613 
614 			"set bonding mode (value) (port_id)\n"
615 			"	Set the bonding mode on a bonded device.\n\n"
616 
617 			"set bonding primary (slave_id) (port_id)\n"
618 			"	Set the primary slave for a bonded device.\n\n"
619 
620 			"show bonding config (port_id)\n"
621 			"	Show the bonding config for port_id.\n\n"
622 
623 			"set bonding mac_addr (port_id) (address)\n"
624 			"	Set the MAC address of a bonded device.\n\n"
625 
626 			"set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)"
627 			"	Set Aggregation mode for IEEE802.3AD (mode 4)"
628 
629 			"set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
630 			"	Set the transmit balance policy for bonded device running in balance mode.\n\n"
631 
632 			"set bonding mon_period (port_id) (value)\n"
633 			"	Set the bonding link status monitoring polling period in ms.\n\n"
634 
635 			"set bonding lacp dedicated_queues <port_id> (enable|disable)\n"
636 			"	Enable/disable dedicated queues for LACP control traffic.\n\n"
637 
638 #endif
639 			"set link-up port (port_id)\n"
640 			"	Set link up for a port.\n\n"
641 
642 			"set link-down port (port_id)\n"
643 			"	Set link down for a port.\n\n"
644 
645 			"E-tag set insertion on port-tag-id (value)"
646 			" port (port_id) vf (vf_id)\n"
647 			"    Enable E-tag insertion for a VF on a port\n\n"
648 
649 			"E-tag set insertion off port (port_id) vf (vf_id)\n"
650 			"    Disable E-tag insertion for a VF on a port\n\n"
651 
652 			"E-tag set stripping (on|off) port (port_id)\n"
653 			"    Enable/disable E-tag stripping on a port\n\n"
654 
655 			"E-tag set forwarding (on|off) port (port_id)\n"
656 			"    Enable/disable E-tag based forwarding"
657 			" on a port\n\n"
658 
659 			"E-tag set filter add e-tag-id (value) dst-pool"
660 			" (pool_id) port (port_id)\n"
661 			"    Add an E-tag forwarding filter on a port\n\n"
662 
663 			"E-tag set filter del e-tag-id (value) port (port_id)\n"
664 			"    Delete an E-tag forwarding filter on a port\n\n"
665 
666 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
667 			"set port tm hierarchy default (port_id)\n"
668 			"	Set default traffic Management hierarchy on a port\n\n"
669 
670 #endif
671 			"ddp add (port_id) (profile_path[,output_path])\n"
672 			"    Load a profile package on a port\n\n"
673 
674 			"ddp del (port_id) (profile_path)\n"
675 			"    Delete a profile package from a port\n\n"
676 
677 			"ptype mapping get (port_id) (valid_only)\n"
678 			"    Get ptype mapping on a port\n\n"
679 
680 			"ptype mapping replace (port_id) (target) (mask) (pky_type)\n"
681 			"    Replace target with the pkt_type in ptype mapping\n\n"
682 
683 			"ptype mapping reset (port_id)\n"
684 			"    Reset ptype mapping on a port\n\n"
685 
686 			"ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n"
687 			"    Update a ptype mapping item on a port\n\n"
688 
689 			"set port (port_id) queue-region region_id (value) "
690 			"queue_start_index (value) queue_num (value)\n"
691 			"    Set a queue region on a port\n\n"
692 
693 			"set port (port_id) queue-region region_id (value) "
694 			"flowtype (value)\n"
695 			"    Set a flowtype region index on a port\n\n"
696 
697 			"set port (port_id) queue-region UP (value) region_id (value)\n"
698 			"    Set the mapping of User Priority to "
699 			"queue region on a port\n\n"
700 
701 			"set port (port_id) queue-region flush (on|off)\n"
702 			"    flush all queue region related configuration\n\n"
703 
704 			"show port meter cap (port_id)\n"
705 			"    Show port meter capability information\n\n"
706 
707 			"add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs)\n"
708 			"    meter profile add - srtcm rfc 2697\n\n"
709 
710 			"add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs)\n"
711 			"    meter profile add - trtcm rfc 2698\n\n"
712 
713 			"add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs)\n"
714 			"    meter profile add - trtcm rfc 4115\n\n"
715 
716 			"del port meter profile (port_id) (profile_id)\n"
717 			"    meter profile delete\n\n"
718 
719 			"create port meter (port_id) (mtr_id) (profile_id) (meter_enable)\n"
720 			"(g_action) (y_action) (r_action) (stats_mask) (shared)\n"
721 			"(use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n"
722 			"(dscp_tbl_entry63)]\n"
723 			"    meter create\n\n"
724 
725 			"enable port meter (port_id) (mtr_id)\n"
726 			"    meter enable\n\n"
727 
728 			"disable port meter (port_id) (mtr_id)\n"
729 			"    meter disable\n\n"
730 
731 			"del port meter (port_id) (mtr_id)\n"
732 			"    meter delete\n\n"
733 
734 			"set port meter profile (port_id) (mtr_id) (profile_id)\n"
735 			"    meter update meter profile\n\n"
736 
737 			"set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n"
738 			"(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n"
739 			"    update meter dscp table entries\n\n"
740 
741 			"set port meter policer action (port_id) (mtr_id) (action_mask)\n"
742 			"(action0) [(action1) (action2)]\n"
743 			"    meter update policer action\n\n"
744 
745 			"set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
746 			"    meter update stats\n\n"
747 
748 			"show port (port_id) queue-region\n"
749 			"    show all queue region related configuration info\n\n"
750 
751 			"add port tm node shaper profile (port_id) (shaper_profile_id)"
752 			" (tb_rate) (tb_size) (packet_length_adjust)\n"
753 			"	Add port tm node private shaper profile.\n\n"
754 
755 			"del port tm node shaper profile (port_id) (shaper_profile_id)\n"
756 			"	Delete port tm node private shaper profile.\n\n"
757 
758 			"add port tm node shared shaper (port_id) (shared_shaper_id)"
759 			" (shaper_profile_id)\n"
760 			"	Add/update port tm node shared shaper.\n\n"
761 
762 			"del port tm node shared shaper (port_id) (shared_shaper_id)\n"
763 			"	Delete port tm node shared shaper.\n\n"
764 
765 			"set port tm node shaper profile (port_id) (node_id)"
766 			" (shaper_profile_id)\n"
767 			"	Set port tm node shaper profile.\n\n"
768 
769 			"add port tm node wred profile (port_id) (wred_profile_id)"
770 			" (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
771 			" (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
772 			" (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
773 			"	Add port tm node wred profile.\n\n"
774 
775 			"del port tm node wred profile (port_id) (wred_profile_id)\n"
776 			"	Delete port tm node wred profile.\n\n"
777 
778 			"add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
779 			" (priority) (weight) (level_id) (shaper_profile_id)"
780 			" (n_sp_priorities) (stats_mask) (n_shared_shapers)"
781 			" [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
782 			"	Add port tm nonleaf node.\n\n"
783 
784 			"add port tm leaf node (port_id) (node_id) (parent_node_id)"
785 			" (priority) (weight) (level_id) (shaper_profile_id)"
786 			" (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
787 			" [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
788 			"	Add port tm leaf node.\n\n"
789 
790 			"del port tm node (port_id) (node_id)\n"
791 			"	Delete port tm node.\n\n"
792 
793 			"set port tm node parent (port_id) (node_id) (parent_node_id)"
794 			" (priority) (weight)\n"
795 			"	Set port tm node parent.\n\n"
796 
797 			"port tm hierarchy commit (port_id) (clean_on_fail)\n"
798 			"	Commit tm hierarchy.\n\n"
799 
800 			, list_pkt_forwarding_modes()
801 		);
802 	}
803 
804 	if (show_all || !strcmp(res->section, "ports")) {
805 
806 		cmdline_printf(
807 			cl,
808 			"\n"
809 			"Port Operations:\n"
810 			"----------------\n\n"
811 
812 			"port start (port_id|all)\n"
813 			"    Start all ports or port_id.\n\n"
814 
815 			"port stop (port_id|all)\n"
816 			"    Stop all ports or port_id.\n\n"
817 
818 			"port close (port_id|all)\n"
819 			"    Close all ports or port_id.\n\n"
820 
821 			"port attach (ident)\n"
822 			"    Attach physical or virtual dev by pci address or virtual device name\n\n"
823 
824 			"port detach (port_id)\n"
825 			"    Detach physical or virtual dev by port_id\n\n"
826 
827 			"port config (port_id|all)"
828 			" speed (10|100|1000|10000|25000|40000|50000|100000|auto)"
829 			" duplex (half|full|auto)\n"
830 			"    Set speed and duplex for all ports or port_id\n\n"
831 
832 			"port config all (rxq|txq|rxd|txd) (value)\n"
833 			"    Set number for rxq/txq/rxd/txd.\n\n"
834 
835 			"port config all max-pkt-len (value)\n"
836 			"    Set the max packet length.\n\n"
837 
838 			"port config all (crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|hw-vlan-filter|"
839 			"hw-vlan-strip|hw-vlan-extend|drop-en)"
840 			" (on|off)\n"
841 			"    Set crc-strip/scatter/rx-checksum/hardware-vlan/drop_en"
842 			" for ports.\n\n"
843 
844 			"port config all rss (all|ip|tcp|udp|sctp|ether|port|vxlan|"
845 			"geneve|nvgre|none|<flowtype_id>)\n"
846 			"    Set the RSS mode.\n\n"
847 
848 			"port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
849 			"    Set the RSS redirection table.\n\n"
850 
851 			"port config (port_id) dcb vt (on|off) (traffic_class)"
852 			" pfc (on|off)\n"
853 			"    Set the DCB mode.\n\n"
854 
855 			"port config all burst (value)\n"
856 			"    Set the number of packets per burst.\n\n"
857 
858 			"port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
859 			" (value)\n"
860 			"    Set the ring prefetch/host/writeback threshold"
861 			" for tx/rx queue.\n\n"
862 
863 			"port config all (txfreet|txrst|rxfreet) (value)\n"
864 			"    Set free threshold for rx/tx, or set"
865 			" tx rs bit threshold.\n\n"
866 			"port config mtu X value\n"
867 			"    Set the MTU of port X to a given value\n\n"
868 
869 			"port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
870 			"    Start/stop a rx/tx queue of port X. Only take effect"
871 			" when port X is started\n\n"
872 
873 			"port config (port_id|all) l2-tunnel E-tag ether-type"
874 			" (value)\n"
875 			"    Set the value of E-tag ether-type.\n\n"
876 
877 			"port config (port_id|all) l2-tunnel E-tag"
878 			" (enable|disable)\n"
879 			"    Enable/disable the E-tag support.\n\n"
880 
881 			"port config (port_id) pctype mapping reset\n"
882 			"    Reset flow type to pctype mapping on a port\n\n"
883 
884 			"port config (port_id) pctype mapping update"
885 			" (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
886 			"    Update a flow type to pctype mapping item on a port\n\n"
887 		);
888 	}
889 
890 	if (show_all || !strcmp(res->section, "registers")) {
891 
892 		cmdline_printf(
893 			cl,
894 			"\n"
895 			"Registers:\n"
896 			"----------\n\n"
897 
898 			"read reg (port_id) (address)\n"
899 			"    Display value of a port register.\n\n"
900 
901 			"read regfield (port_id) (address) (bit_x) (bit_y)\n"
902 			"    Display a port register bit field.\n\n"
903 
904 			"read regbit (port_id) (address) (bit_x)\n"
905 			"    Display a single port register bit.\n\n"
906 
907 			"write reg (port_id) (address) (value)\n"
908 			"    Set value of a port register.\n\n"
909 
910 			"write regfield (port_id) (address) (bit_x) (bit_y)"
911 			" (value)\n"
912 			"    Set bit field of a port register.\n\n"
913 
914 			"write regbit (port_id) (address) (bit_x) (value)\n"
915 			"    Set single bit value of a port register.\n\n"
916 		);
917 	}
918 	if (show_all || !strcmp(res->section, "filters")) {
919 
920 		cmdline_printf(
921 			cl,
922 			"\n"
923 			"filters:\n"
924 			"--------\n\n"
925 
926 			"ethertype_filter (port_id) (add|del)"
927 			" (mac_addr|mac_ignr) (mac_address) ethertype"
928 			" (ether_type) (drop|fwd) queue (queue_id)\n"
929 			"    Add/Del an ethertype filter.\n\n"
930 
931 			"2tuple_filter (port_id) (add|del)"
932 			" dst_port (dst_port_value) protocol (protocol_value)"
933 			" mask (mask_value) tcp_flags (tcp_flags_value)"
934 			" priority (prio_value) queue (queue_id)\n"
935 			"    Add/Del a 2tuple filter.\n\n"
936 
937 			"5tuple_filter (port_id) (add|del)"
938 			" dst_ip (dst_address) src_ip (src_address)"
939 			" dst_port (dst_port_value) src_port (src_port_value)"
940 			" protocol (protocol_value)"
941 			" mask (mask_value) tcp_flags (tcp_flags_value)"
942 			" priority (prio_value) queue (queue_id)\n"
943 			"    Add/Del a 5tuple filter.\n\n"
944 
945 			"syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
946 			"    Add/Del syn filter.\n\n"
947 
948 			"flex_filter (port_id) (add|del) len (len_value)"
949 			" bytes (bytes_value) mask (mask_value)"
950 			" priority (prio_value) queue (queue_id)\n"
951 			"    Add/Del a flex filter.\n\n"
952 
953 			"flow_director_filter (port_id) mode IP (add|del|update)"
954 			" flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
955 			" src (src_ip_address) dst (dst_ip_address)"
956 			" tos (tos_value) proto (proto_value) ttl (ttl_value)"
957 			" vlan (vlan_value) flexbytes (flexbytes_value)"
958 			" (drop|fwd) pf|vf(vf_id) queue (queue_id)"
959 			" fd_id (fd_id_value)\n"
960 			"    Add/Del an IP type flow director filter.\n\n"
961 
962 			"flow_director_filter (port_id) mode IP (add|del|update)"
963 			" flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
964 			" src (src_ip_address) (src_port)"
965 			" dst (dst_ip_address) (dst_port)"
966 			" tos (tos_value) ttl (ttl_value)"
967 			" vlan (vlan_value) flexbytes (flexbytes_value)"
968 			" (drop|fwd) pf|vf(vf_id) queue (queue_id)"
969 			" fd_id (fd_id_value)\n"
970 			"    Add/Del an UDP/TCP type flow director filter.\n\n"
971 
972 			"flow_director_filter (port_id) mode IP (add|del|update)"
973 			" flow (ipv4-sctp|ipv6-sctp)"
974 			" src (src_ip_address) (src_port)"
975 			" dst (dst_ip_address) (dst_port)"
976 			" tag (verification_tag) "
977 			" tos (tos_value) ttl (ttl_value)"
978 			" vlan (vlan_value)"
979 			" flexbytes (flexbytes_value) (drop|fwd)"
980 			" pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
981 			"    Add/Del a SCTP type flow director filter.\n\n"
982 
983 			"flow_director_filter (port_id) mode IP (add|del|update)"
984 			" flow l2_payload ether (ethertype)"
985 			" flexbytes (flexbytes_value) (drop|fwd)"
986 			" pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
987 			"    Add/Del a l2 payload type flow director filter.\n\n"
988 
989 			"flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
990 			" mac (mac_address) vlan (vlan_value)"
991 			" flexbytes (flexbytes_value) (drop|fwd)"
992 			" queue (queue_id) fd_id (fd_id_value)\n"
993 			"    Add/Del a MAC-VLAN flow director filter.\n\n"
994 
995 			"flow_director_filter (port_id) mode Tunnel (add|del|update)"
996 			" mac (mac_address) vlan (vlan_value)"
997 			" tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
998 			" flexbytes (flexbytes_value) (drop|fwd)"
999 			" queue (queue_id) fd_id (fd_id_value)\n"
1000 			"    Add/Del a Tunnel flow director filter.\n\n"
1001 
1002 			"flow_director_filter (port_id) mode raw (add|del|update)"
1003 			" flow (flow_id) (drop|fwd) queue (queue_id)"
1004 			" fd_id (fd_id_value) packet (packet file name)\n"
1005 			"    Add/Del a raw type flow director filter.\n\n"
1006 
1007 			"flush_flow_director (port_id)\n"
1008 			"    Flush all flow director entries of a device.\n\n"
1009 
1010 			"flow_director_mask (port_id) mode IP vlan (vlan_value)"
1011 			" src_mask (ipv4_src) (ipv6_src) (src_port)"
1012 			" dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
1013 			"    Set flow director IP mask.\n\n"
1014 
1015 			"flow_director_mask (port_id) mode MAC-VLAN"
1016 			" vlan (vlan_value)\n"
1017 			"    Set flow director MAC-VLAN mask.\n\n"
1018 
1019 			"flow_director_mask (port_id) mode Tunnel"
1020 			" vlan (vlan_value) mac (mac_value)"
1021 			" tunnel-type (tunnel_type_value)"
1022 			" tunnel-id (tunnel_id_value)\n"
1023 			"    Set flow director Tunnel mask.\n\n"
1024 
1025 			"flow_director_flex_mask (port_id)"
1026 			" flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
1027 			"ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
1028 			" (mask)\n"
1029 			"    Configure mask of flex payload.\n\n"
1030 
1031 			"flow_director_flex_payload (port_id)"
1032 			" (raw|l2|l3|l4) (config)\n"
1033 			"    Configure flex payload selection.\n\n"
1034 
1035 			"get_sym_hash_ena_per_port (port_id)\n"
1036 			"    get symmetric hash enable configuration per port.\n\n"
1037 
1038 			"set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
1039 			"    set symmetric hash enable configuration per port"
1040 			" to enable or disable.\n\n"
1041 
1042 			"get_hash_global_config (port_id)\n"
1043 			"    Get the global configurations of hash filters.\n\n"
1044 
1045 			"set_hash_global_config (port_id) (toeplitz|simple_xor|default)"
1046 			" (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1047 			"ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
1048 			" (enable|disable)\n"
1049 			"    Set the global configurations of hash filters.\n\n"
1050 
1051 			"set_hash_input_set (port_id) (ipv4|ipv4-frag|"
1052 			"ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1053 			"ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1054 			"l2_payload|<flowtype_id>) (ovlan|ivlan|src-ipv4|dst-ipv4|"
1055 			"src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
1056 			"ipv6-next-header|udp-src-port|udp-dst-port|"
1057 			"tcp-src-port|tcp-dst-port|sctp-src-port|"
1058 			"sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
1059 			"fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
1060 			"fld-8th|none) (select|add)\n"
1061 			"    Set the input set for hash.\n\n"
1062 
1063 			"set_fdir_input_set (port_id) "
1064 			"(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1065 			"ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1066 			"l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
1067 			"dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
1068 			"ipv6-next-header|ipv6-hop-limits|udp-src-port|"
1069 			"udp-dst-port|tcp-src-port|tcp-dst-port|"
1070 			"sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
1071 			" (select|add)\n"
1072 			"    Set the input set for FDir.\n\n"
1073 
1074 			"flow validate {port_id}"
1075 			" [group {group_id}] [priority {level}]"
1076 			" [ingress] [egress]"
1077 			" pattern {item} [/ {item} [...]] / end"
1078 			" actions {action} [/ {action} [...]] / end\n"
1079 			"    Check whether a flow rule can be created.\n\n"
1080 
1081 			"flow create {port_id}"
1082 			" [group {group_id}] [priority {level}]"
1083 			" [ingress] [egress]"
1084 			" pattern {item} [/ {item} [...]] / end"
1085 			" actions {action} [/ {action} [...]] / end\n"
1086 			"    Create a flow rule.\n\n"
1087 
1088 			"flow destroy {port_id} rule {rule_id} [...]\n"
1089 			"    Destroy specific flow rules.\n\n"
1090 
1091 			"flow flush {port_id}\n"
1092 			"    Destroy all flow rules.\n\n"
1093 
1094 			"flow query {port_id} {rule_id} {action}\n"
1095 			"    Query an existing flow rule.\n\n"
1096 
1097 			"flow list {port_id} [group {group_id}] [...]\n"
1098 			"    List existing flow rules sorted by priority,"
1099 			" filtered by group identifiers.\n\n"
1100 
1101 			"flow isolate {port_id} {boolean}\n"
1102 			"    Restrict ingress traffic to the defined"
1103 			" flow rules\n\n"
1104 		);
1105 	}
1106 }
1107 
1108 cmdline_parse_token_string_t cmd_help_long_help =
1109 	TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1110 
1111 cmdline_parse_token_string_t cmd_help_long_section =
1112 	TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1113 			"all#control#display#config#"
1114 			"ports#registers#filters");
1115 
1116 cmdline_parse_inst_t cmd_help_long = {
1117 	.f = cmd_help_long_parsed,
1118 	.data = NULL,
1119 	.help_str = "help all|control|display|config|ports|register|filters: "
1120 		"Show help",
1121 	.tokens = {
1122 		(void *)&cmd_help_long_help,
1123 		(void *)&cmd_help_long_section,
1124 		NULL,
1125 	},
1126 };
1127 
1128 
1129 /* *** start/stop/close all ports *** */
1130 struct cmd_operate_port_result {
1131 	cmdline_fixed_string_t keyword;
1132 	cmdline_fixed_string_t name;
1133 	cmdline_fixed_string_t value;
1134 };
1135 
1136 static void cmd_operate_port_parsed(void *parsed_result,
1137 				__attribute__((unused)) struct cmdline *cl,
1138 				__attribute__((unused)) void *data)
1139 {
1140 	struct cmd_operate_port_result *res = parsed_result;
1141 
1142 	if (!strcmp(res->name, "start"))
1143 		start_port(RTE_PORT_ALL);
1144 	else if (!strcmp(res->name, "stop"))
1145 		stop_port(RTE_PORT_ALL);
1146 	else if (!strcmp(res->name, "close"))
1147 		close_port(RTE_PORT_ALL);
1148 	else if (!strcmp(res->name, "reset"))
1149 		reset_port(RTE_PORT_ALL);
1150 	else
1151 		printf("Unknown parameter\n");
1152 }
1153 
1154 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1155 	TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1156 								"port");
1157 cmdline_parse_token_string_t cmd_operate_port_all_port =
1158 	TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1159 						"start#stop#close#reset");
1160 cmdline_parse_token_string_t cmd_operate_port_all_all =
1161 	TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1162 
1163 cmdline_parse_inst_t cmd_operate_port = {
1164 	.f = cmd_operate_port_parsed,
1165 	.data = NULL,
1166 	.help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports",
1167 	.tokens = {
1168 		(void *)&cmd_operate_port_all_cmd,
1169 		(void *)&cmd_operate_port_all_port,
1170 		(void *)&cmd_operate_port_all_all,
1171 		NULL,
1172 	},
1173 };
1174 
1175 /* *** start/stop/close specific port *** */
1176 struct cmd_operate_specific_port_result {
1177 	cmdline_fixed_string_t keyword;
1178 	cmdline_fixed_string_t name;
1179 	uint8_t value;
1180 };
1181 
1182 static void cmd_operate_specific_port_parsed(void *parsed_result,
1183 			__attribute__((unused)) struct cmdline *cl,
1184 				__attribute__((unused)) void *data)
1185 {
1186 	struct cmd_operate_specific_port_result *res = parsed_result;
1187 
1188 	if (!strcmp(res->name, "start"))
1189 		start_port(res->value);
1190 	else if (!strcmp(res->name, "stop"))
1191 		stop_port(res->value);
1192 	else if (!strcmp(res->name, "close"))
1193 		close_port(res->value);
1194 	else if (!strcmp(res->name, "reset"))
1195 		reset_port(res->value);
1196 	else
1197 		printf("Unknown parameter\n");
1198 }
1199 
1200 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1201 	TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1202 							keyword, "port");
1203 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1204 	TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1205 						name, "start#stop#close#reset");
1206 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1207 	TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1208 							value, UINT8);
1209 
1210 cmdline_parse_inst_t cmd_operate_specific_port = {
1211 	.f = cmd_operate_specific_port_parsed,
1212 	.data = NULL,
1213 	.help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id",
1214 	.tokens = {
1215 		(void *)&cmd_operate_specific_port_cmd,
1216 		(void *)&cmd_operate_specific_port_port,
1217 		(void *)&cmd_operate_specific_port_id,
1218 		NULL,
1219 	},
1220 };
1221 
1222 /* *** attach a specified port *** */
1223 struct cmd_operate_attach_port_result {
1224 	cmdline_fixed_string_t port;
1225 	cmdline_fixed_string_t keyword;
1226 	cmdline_fixed_string_t identifier;
1227 };
1228 
1229 static void cmd_operate_attach_port_parsed(void *parsed_result,
1230 				__attribute__((unused)) struct cmdline *cl,
1231 				__attribute__((unused)) void *data)
1232 {
1233 	struct cmd_operate_attach_port_result *res = parsed_result;
1234 
1235 	if (!strcmp(res->keyword, "attach"))
1236 		attach_port(res->identifier);
1237 	else
1238 		printf("Unknown parameter\n");
1239 }
1240 
1241 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1242 	TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1243 			port, "port");
1244 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1245 	TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1246 			keyword, "attach");
1247 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1248 	TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1249 			identifier, NULL);
1250 
1251 cmdline_parse_inst_t cmd_operate_attach_port = {
1252 	.f = cmd_operate_attach_port_parsed,
1253 	.data = NULL,
1254 	.help_str = "port attach <identifier>: "
1255 		"(identifier: pci address or virtual dev name)",
1256 	.tokens = {
1257 		(void *)&cmd_operate_attach_port_port,
1258 		(void *)&cmd_operate_attach_port_keyword,
1259 		(void *)&cmd_operate_attach_port_identifier,
1260 		NULL,
1261 	},
1262 };
1263 
1264 /* *** detach a specified port *** */
1265 struct cmd_operate_detach_port_result {
1266 	cmdline_fixed_string_t port;
1267 	cmdline_fixed_string_t keyword;
1268 	portid_t port_id;
1269 };
1270 
1271 static void cmd_operate_detach_port_parsed(void *parsed_result,
1272 				__attribute__((unused)) struct cmdline *cl,
1273 				__attribute__((unused)) void *data)
1274 {
1275 	struct cmd_operate_detach_port_result *res = parsed_result;
1276 
1277 	if (!strcmp(res->keyword, "detach"))
1278 		detach_port(res->port_id);
1279 	else
1280 		printf("Unknown parameter\n");
1281 }
1282 
1283 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1284 	TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1285 			port, "port");
1286 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1287 	TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1288 			keyword, "detach");
1289 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1290 	TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1291 			port_id, UINT16);
1292 
1293 cmdline_parse_inst_t cmd_operate_detach_port = {
1294 	.f = cmd_operate_detach_port_parsed,
1295 	.data = NULL,
1296 	.help_str = "port detach <port_id>",
1297 	.tokens = {
1298 		(void *)&cmd_operate_detach_port_port,
1299 		(void *)&cmd_operate_detach_port_keyword,
1300 		(void *)&cmd_operate_detach_port_port_id,
1301 		NULL,
1302 	},
1303 };
1304 
1305 /* *** configure speed for all ports *** */
1306 struct cmd_config_speed_all {
1307 	cmdline_fixed_string_t port;
1308 	cmdline_fixed_string_t keyword;
1309 	cmdline_fixed_string_t all;
1310 	cmdline_fixed_string_t item1;
1311 	cmdline_fixed_string_t item2;
1312 	cmdline_fixed_string_t value1;
1313 	cmdline_fixed_string_t value2;
1314 };
1315 
1316 static int
1317 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1318 {
1319 
1320 	int duplex;
1321 
1322 	if (!strcmp(duplexstr, "half")) {
1323 		duplex = ETH_LINK_HALF_DUPLEX;
1324 	} else if (!strcmp(duplexstr, "full")) {
1325 		duplex = ETH_LINK_FULL_DUPLEX;
1326 	} else if (!strcmp(duplexstr, "auto")) {
1327 		duplex = ETH_LINK_FULL_DUPLEX;
1328 	} else {
1329 		printf("Unknown duplex parameter\n");
1330 		return -1;
1331 	}
1332 
1333 	if (!strcmp(speedstr, "10")) {
1334 		*speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1335 				ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1336 	} else if (!strcmp(speedstr, "100")) {
1337 		*speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1338 				ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1339 	} else {
1340 		if (duplex != ETH_LINK_FULL_DUPLEX) {
1341 			printf("Invalid speed/duplex parameters\n");
1342 			return -1;
1343 		}
1344 		if (!strcmp(speedstr, "1000")) {
1345 			*speed = ETH_LINK_SPEED_1G;
1346 		} else if (!strcmp(speedstr, "10000")) {
1347 			*speed = ETH_LINK_SPEED_10G;
1348 		} else if (!strcmp(speedstr, "25000")) {
1349 			*speed = ETH_LINK_SPEED_25G;
1350 		} else if (!strcmp(speedstr, "40000")) {
1351 			*speed = ETH_LINK_SPEED_40G;
1352 		} else if (!strcmp(speedstr, "50000")) {
1353 			*speed = ETH_LINK_SPEED_50G;
1354 		} else if (!strcmp(speedstr, "100000")) {
1355 			*speed = ETH_LINK_SPEED_100G;
1356 		} else if (!strcmp(speedstr, "auto")) {
1357 			*speed = ETH_LINK_SPEED_AUTONEG;
1358 		} else {
1359 			printf("Unknown speed parameter\n");
1360 			return -1;
1361 		}
1362 	}
1363 
1364 	return 0;
1365 }
1366 
1367 static void
1368 cmd_config_speed_all_parsed(void *parsed_result,
1369 			__attribute__((unused)) struct cmdline *cl,
1370 			__attribute__((unused)) void *data)
1371 {
1372 	struct cmd_config_speed_all *res = parsed_result;
1373 	uint32_t link_speed;
1374 	portid_t pid;
1375 
1376 	if (!all_ports_stopped()) {
1377 		printf("Please stop all ports first\n");
1378 		return;
1379 	}
1380 
1381 	if (parse_and_check_speed_duplex(res->value1, res->value2,
1382 			&link_speed) < 0)
1383 		return;
1384 
1385 	RTE_ETH_FOREACH_DEV(pid) {
1386 		ports[pid].dev_conf.link_speeds = link_speed;
1387 	}
1388 
1389 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1390 }
1391 
1392 cmdline_parse_token_string_t cmd_config_speed_all_port =
1393 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1394 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1395 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1396 							"config");
1397 cmdline_parse_token_string_t cmd_config_speed_all_all =
1398 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1399 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1400 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1401 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1402 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1403 				"10#100#1000#10000#25000#40000#50000#100000#auto");
1404 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1405 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1406 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1407 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1408 						"half#full#auto");
1409 
1410 cmdline_parse_inst_t cmd_config_speed_all = {
1411 	.f = cmd_config_speed_all_parsed,
1412 	.data = NULL,
1413 	.help_str = "port config all speed "
1414 		"10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1415 							"half|full|auto",
1416 	.tokens = {
1417 		(void *)&cmd_config_speed_all_port,
1418 		(void *)&cmd_config_speed_all_keyword,
1419 		(void *)&cmd_config_speed_all_all,
1420 		(void *)&cmd_config_speed_all_item1,
1421 		(void *)&cmd_config_speed_all_value1,
1422 		(void *)&cmd_config_speed_all_item2,
1423 		(void *)&cmd_config_speed_all_value2,
1424 		NULL,
1425 	},
1426 };
1427 
1428 /* *** configure speed for specific port *** */
1429 struct cmd_config_speed_specific {
1430 	cmdline_fixed_string_t port;
1431 	cmdline_fixed_string_t keyword;
1432 	uint8_t id;
1433 	cmdline_fixed_string_t item1;
1434 	cmdline_fixed_string_t item2;
1435 	cmdline_fixed_string_t value1;
1436 	cmdline_fixed_string_t value2;
1437 };
1438 
1439 static void
1440 cmd_config_speed_specific_parsed(void *parsed_result,
1441 				__attribute__((unused)) struct cmdline *cl,
1442 				__attribute__((unused)) void *data)
1443 {
1444 	struct cmd_config_speed_specific *res = parsed_result;
1445 	uint32_t link_speed;
1446 
1447 	if (!all_ports_stopped()) {
1448 		printf("Please stop all ports first\n");
1449 		return;
1450 	}
1451 
1452 	if (port_id_is_invalid(res->id, ENABLED_WARN))
1453 		return;
1454 
1455 	if (parse_and_check_speed_duplex(res->value1, res->value2,
1456 			&link_speed) < 0)
1457 		return;
1458 
1459 	ports[res->id].dev_conf.link_speeds = link_speed;
1460 
1461 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1462 }
1463 
1464 
1465 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1466 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1467 								"port");
1468 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1469 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1470 								"config");
1471 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1472 	TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
1473 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1474 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1475 								"speed");
1476 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1477 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1478 				"10#100#1000#10000#25000#40000#50000#100000#auto");
1479 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1480 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1481 								"duplex");
1482 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1483 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1484 							"half#full#auto");
1485 
1486 cmdline_parse_inst_t cmd_config_speed_specific = {
1487 	.f = cmd_config_speed_specific_parsed,
1488 	.data = NULL,
1489 	.help_str = "port config <port_id> speed "
1490 		"10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1491 							"half|full|auto",
1492 	.tokens = {
1493 		(void *)&cmd_config_speed_specific_port,
1494 		(void *)&cmd_config_speed_specific_keyword,
1495 		(void *)&cmd_config_speed_specific_id,
1496 		(void *)&cmd_config_speed_specific_item1,
1497 		(void *)&cmd_config_speed_specific_value1,
1498 		(void *)&cmd_config_speed_specific_item2,
1499 		(void *)&cmd_config_speed_specific_value2,
1500 		NULL,
1501 	},
1502 };
1503 
1504 /* *** configure txq/rxq, txd/rxd *** */
1505 struct cmd_config_rx_tx {
1506 	cmdline_fixed_string_t port;
1507 	cmdline_fixed_string_t keyword;
1508 	cmdline_fixed_string_t all;
1509 	cmdline_fixed_string_t name;
1510 	uint16_t value;
1511 };
1512 
1513 static void
1514 cmd_config_rx_tx_parsed(void *parsed_result,
1515 			__attribute__((unused)) struct cmdline *cl,
1516 			__attribute__((unused)) void *data)
1517 {
1518 	struct cmd_config_rx_tx *res = parsed_result;
1519 
1520 	if (!all_ports_stopped()) {
1521 		printf("Please stop all ports first\n");
1522 		return;
1523 	}
1524 	if (!strcmp(res->name, "rxq")) {
1525 		if (!res->value && !nb_txq) {
1526 			printf("Warning: Either rx or tx queues should be non zero\n");
1527 			return;
1528 		}
1529 		nb_rxq = res->value;
1530 	}
1531 	else if (!strcmp(res->name, "txq")) {
1532 		if (!res->value && !nb_rxq) {
1533 			printf("Warning: Either rx or tx queues should be non zero\n");
1534 			return;
1535 		}
1536 		nb_txq = res->value;
1537 	}
1538 	else if (!strcmp(res->name, "rxd")) {
1539 		if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1540 			printf("rxd %d invalid - must be > 0 && <= %d\n",
1541 					res->value, RTE_TEST_RX_DESC_MAX);
1542 			return;
1543 		}
1544 		nb_rxd = res->value;
1545 	} else if (!strcmp(res->name, "txd")) {
1546 		if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1547 			printf("txd %d invalid - must be > 0 && <= %d\n",
1548 					res->value, RTE_TEST_TX_DESC_MAX);
1549 			return;
1550 		}
1551 		nb_txd = res->value;
1552 	} else {
1553 		printf("Unknown parameter\n");
1554 		return;
1555 	}
1556 
1557 	fwd_config_setup();
1558 
1559 	init_port_config();
1560 
1561 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1562 }
1563 
1564 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1565 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1566 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1567 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1568 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1569 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1570 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1571 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1572 						"rxq#txq#rxd#txd");
1573 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1574 	TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1575 
1576 cmdline_parse_inst_t cmd_config_rx_tx = {
1577 	.f = cmd_config_rx_tx_parsed,
1578 	.data = NULL,
1579 	.help_str = "port config all rxq|txq|rxd|txd <value>",
1580 	.tokens = {
1581 		(void *)&cmd_config_rx_tx_port,
1582 		(void *)&cmd_config_rx_tx_keyword,
1583 		(void *)&cmd_config_rx_tx_all,
1584 		(void *)&cmd_config_rx_tx_name,
1585 		(void *)&cmd_config_rx_tx_value,
1586 		NULL,
1587 	},
1588 };
1589 
1590 /* *** config max packet length *** */
1591 struct cmd_config_max_pkt_len_result {
1592 	cmdline_fixed_string_t port;
1593 	cmdline_fixed_string_t keyword;
1594 	cmdline_fixed_string_t all;
1595 	cmdline_fixed_string_t name;
1596 	uint32_t value;
1597 };
1598 
1599 static void
1600 cmd_config_max_pkt_len_parsed(void *parsed_result,
1601 				__attribute__((unused)) struct cmdline *cl,
1602 				__attribute__((unused)) void *data)
1603 {
1604 	struct cmd_config_max_pkt_len_result *res = parsed_result;
1605 	portid_t pid;
1606 
1607 	if (!all_ports_stopped()) {
1608 		printf("Please stop all ports first\n");
1609 		return;
1610 	}
1611 
1612 	RTE_ETH_FOREACH_DEV(pid) {
1613 		struct rte_port *port = &ports[pid];
1614 		uint64_t rx_offloads = port->dev_conf.rxmode.offloads;
1615 
1616 		if (!strcmp(res->name, "max-pkt-len")) {
1617 			if (res->value < ETHER_MIN_LEN) {
1618 				printf("max-pkt-len can not be less than %d\n",
1619 						ETHER_MIN_LEN);
1620 				return;
1621 			}
1622 			if (res->value == port->dev_conf.rxmode.max_rx_pkt_len)
1623 				return;
1624 
1625 			port->dev_conf.rxmode.max_rx_pkt_len = res->value;
1626 			if (res->value > ETHER_MAX_LEN)
1627 				rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
1628 			else
1629 				rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
1630 			port->dev_conf.rxmode.offloads = rx_offloads;
1631 		} else {
1632 			printf("Unknown parameter\n");
1633 			return;
1634 		}
1635 	}
1636 
1637 	init_port_config();
1638 
1639 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1640 }
1641 
1642 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1643 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1644 								"port");
1645 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1646 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1647 								"config");
1648 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1649 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1650 								"all");
1651 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1652 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1653 								"max-pkt-len");
1654 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1655 	TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1656 								UINT32);
1657 
1658 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1659 	.f = cmd_config_max_pkt_len_parsed,
1660 	.data = NULL,
1661 	.help_str = "port config all max-pkt-len <value>",
1662 	.tokens = {
1663 		(void *)&cmd_config_max_pkt_len_port,
1664 		(void *)&cmd_config_max_pkt_len_keyword,
1665 		(void *)&cmd_config_max_pkt_len_all,
1666 		(void *)&cmd_config_max_pkt_len_name,
1667 		(void *)&cmd_config_max_pkt_len_value,
1668 		NULL,
1669 	},
1670 };
1671 
1672 /* *** configure port MTU *** */
1673 struct cmd_config_mtu_result {
1674 	cmdline_fixed_string_t port;
1675 	cmdline_fixed_string_t keyword;
1676 	cmdline_fixed_string_t mtu;
1677 	portid_t port_id;
1678 	uint16_t value;
1679 };
1680 
1681 static void
1682 cmd_config_mtu_parsed(void *parsed_result,
1683 		      __attribute__((unused)) struct cmdline *cl,
1684 		      __attribute__((unused)) void *data)
1685 {
1686 	struct cmd_config_mtu_result *res = parsed_result;
1687 
1688 	if (res->value < ETHER_MIN_LEN) {
1689 		printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1690 		return;
1691 	}
1692 	port_mtu_set(res->port_id, res->value);
1693 }
1694 
1695 cmdline_parse_token_string_t cmd_config_mtu_port =
1696 	TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1697 				 "port");
1698 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1699 	TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1700 				 "config");
1701 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1702 	TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1703 				 "mtu");
1704 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1705 	TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT16);
1706 cmdline_parse_token_num_t cmd_config_mtu_value =
1707 	TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1708 
1709 cmdline_parse_inst_t cmd_config_mtu = {
1710 	.f = cmd_config_mtu_parsed,
1711 	.data = NULL,
1712 	.help_str = "port config mtu <port_id> <value>",
1713 	.tokens = {
1714 		(void *)&cmd_config_mtu_port,
1715 		(void *)&cmd_config_mtu_keyword,
1716 		(void *)&cmd_config_mtu_mtu,
1717 		(void *)&cmd_config_mtu_port_id,
1718 		(void *)&cmd_config_mtu_value,
1719 		NULL,
1720 	},
1721 };
1722 
1723 /* *** configure rx mode *** */
1724 struct cmd_config_rx_mode_flag {
1725 	cmdline_fixed_string_t port;
1726 	cmdline_fixed_string_t keyword;
1727 	cmdline_fixed_string_t all;
1728 	cmdline_fixed_string_t name;
1729 	cmdline_fixed_string_t value;
1730 };
1731 
1732 static void
1733 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1734 				__attribute__((unused)) struct cmdline *cl,
1735 				__attribute__((unused)) void *data)
1736 {
1737 	struct cmd_config_rx_mode_flag *res = parsed_result;
1738 	portid_t pid;
1739 
1740 	if (!all_ports_stopped()) {
1741 		printf("Please stop all ports first\n");
1742 		return;
1743 	}
1744 
1745 	RTE_ETH_FOREACH_DEV(pid) {
1746 		struct rte_port *port;
1747 		uint64_t rx_offloads;
1748 
1749 		port = &ports[pid];
1750 		rx_offloads = port->dev_conf.rxmode.offloads;
1751 		if (!strcmp(res->name, "crc-strip")) {
1752 			if (!strcmp(res->value, "on"))
1753 				rx_offloads |= DEV_RX_OFFLOAD_CRC_STRIP;
1754 			else if (!strcmp(res->value, "off"))
1755 				rx_offloads &= ~DEV_RX_OFFLOAD_CRC_STRIP;
1756 			else {
1757 				printf("Unknown parameter\n");
1758 				return;
1759 			}
1760 		} else if (!strcmp(res->name, "scatter")) {
1761 			if (!strcmp(res->value, "on")) {
1762 				rx_offloads |= DEV_RX_OFFLOAD_SCATTER;
1763 			} else if (!strcmp(res->value, "off")) {
1764 				rx_offloads &= ~DEV_RX_OFFLOAD_SCATTER;
1765 			} else {
1766 				printf("Unknown parameter\n");
1767 				return;
1768 			}
1769 		} else if (!strcmp(res->name, "rx-cksum")) {
1770 			if (!strcmp(res->value, "on"))
1771 				rx_offloads |= DEV_RX_OFFLOAD_CHECKSUM;
1772 			else if (!strcmp(res->value, "off"))
1773 				rx_offloads &= ~DEV_RX_OFFLOAD_CHECKSUM;
1774 			else {
1775 				printf("Unknown parameter\n");
1776 				return;
1777 			}
1778 		} else if (!strcmp(res->name, "rx-timestamp")) {
1779 			if (!strcmp(res->value, "on"))
1780 				rx_offloads |= DEV_RX_OFFLOAD_TIMESTAMP;
1781 			else if (!strcmp(res->value, "off"))
1782 				rx_offloads &= ~DEV_RX_OFFLOAD_TIMESTAMP;
1783 			else {
1784 				printf("Unknown parameter\n");
1785 				return;
1786 			}
1787 		} else if (!strcmp(res->name, "hw-vlan")) {
1788 			if (!strcmp(res->value, "on")) {
1789 				rx_offloads |= (DEV_RX_OFFLOAD_VLAN_FILTER |
1790 						DEV_RX_OFFLOAD_VLAN_STRIP);
1791 			} else if (!strcmp(res->value, "off")) {
1792 				rx_offloads &= ~(DEV_RX_OFFLOAD_VLAN_FILTER |
1793 						DEV_RX_OFFLOAD_VLAN_STRIP);
1794 			} else {
1795 				printf("Unknown parameter\n");
1796 				return;
1797 			}
1798 		} else if (!strcmp(res->name, "hw-vlan-filter")) {
1799 			if (!strcmp(res->value, "on"))
1800 				rx_offloads |= DEV_RX_OFFLOAD_VLAN_FILTER;
1801 			else if (!strcmp(res->value, "off"))
1802 				rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_FILTER;
1803 			else {
1804 				printf("Unknown parameter\n");
1805 				return;
1806 			}
1807 		} else if (!strcmp(res->name, "hw-vlan-strip")) {
1808 			if (!strcmp(res->value, "on"))
1809 				rx_offloads |= DEV_RX_OFFLOAD_VLAN_STRIP;
1810 			else if (!strcmp(res->value, "off"))
1811 				rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_STRIP;
1812 			else {
1813 				printf("Unknown parameter\n");
1814 				return;
1815 			}
1816 		} else if (!strcmp(res->name, "hw-vlan-extend")) {
1817 			if (!strcmp(res->value, "on"))
1818 				rx_offloads |= DEV_RX_OFFLOAD_VLAN_EXTEND;
1819 			else if (!strcmp(res->value, "off"))
1820 				rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_EXTEND;
1821 			else {
1822 				printf("Unknown parameter\n");
1823 				return;
1824 			}
1825 		} else if (!strcmp(res->name, "drop-en")) {
1826 			if (!strcmp(res->value, "on"))
1827 				rx_drop_en = 1;
1828 			else if (!strcmp(res->value, "off"))
1829 				rx_drop_en = 0;
1830 			else {
1831 				printf("Unknown parameter\n");
1832 				return;
1833 			}
1834 		} else {
1835 			printf("Unknown parameter\n");
1836 			return;
1837 		}
1838 		port->dev_conf.rxmode.offloads = rx_offloads;
1839 	}
1840 
1841 	init_port_config();
1842 
1843 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1844 }
1845 
1846 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1847 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1848 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1849 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1850 								"config");
1851 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1852 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1853 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1854 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1855 					"crc-strip#scatter#rx-cksum#rx-timestamp#hw-vlan#"
1856 					"hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
1857 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1858 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1859 							"on#off");
1860 
1861 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1862 	.f = cmd_config_rx_mode_flag_parsed,
1863 	.data = NULL,
1864 	.help_str = "port config all crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|"
1865 		"hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
1866 	.tokens = {
1867 		(void *)&cmd_config_rx_mode_flag_port,
1868 		(void *)&cmd_config_rx_mode_flag_keyword,
1869 		(void *)&cmd_config_rx_mode_flag_all,
1870 		(void *)&cmd_config_rx_mode_flag_name,
1871 		(void *)&cmd_config_rx_mode_flag_value,
1872 		NULL,
1873 	},
1874 };
1875 
1876 /* *** configure rss *** */
1877 struct cmd_config_rss {
1878 	cmdline_fixed_string_t port;
1879 	cmdline_fixed_string_t keyword;
1880 	cmdline_fixed_string_t all;
1881 	cmdline_fixed_string_t name;
1882 	cmdline_fixed_string_t value;
1883 };
1884 
1885 static void
1886 cmd_config_rss_parsed(void *parsed_result,
1887 			__attribute__((unused)) struct cmdline *cl,
1888 			__attribute__((unused)) void *data)
1889 {
1890 	struct cmd_config_rss *res = parsed_result;
1891 	struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
1892 	int diag;
1893 	uint8_t i;
1894 
1895 	if (!strcmp(res->value, "all"))
1896 		rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
1897 				ETH_RSS_UDP | ETH_RSS_SCTP |
1898 					ETH_RSS_L2_PAYLOAD;
1899 	else if (!strcmp(res->value, "ip"))
1900 		rss_conf.rss_hf = ETH_RSS_IP;
1901 	else if (!strcmp(res->value, "udp"))
1902 		rss_conf.rss_hf = ETH_RSS_UDP;
1903 	else if (!strcmp(res->value, "tcp"))
1904 		rss_conf.rss_hf = ETH_RSS_TCP;
1905 	else if (!strcmp(res->value, "sctp"))
1906 		rss_conf.rss_hf = ETH_RSS_SCTP;
1907 	else if (!strcmp(res->value, "ether"))
1908 		rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
1909 	else if (!strcmp(res->value, "port"))
1910 		rss_conf.rss_hf = ETH_RSS_PORT;
1911 	else if (!strcmp(res->value, "vxlan"))
1912 		rss_conf.rss_hf = ETH_RSS_VXLAN;
1913 	else if (!strcmp(res->value, "geneve"))
1914 		rss_conf.rss_hf = ETH_RSS_GENEVE;
1915 	else if (!strcmp(res->value, "nvgre"))
1916 		rss_conf.rss_hf = ETH_RSS_NVGRE;
1917 	else if (!strcmp(res->value, "none"))
1918 		rss_conf.rss_hf = 0;
1919 	else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
1920 						atoi(res->value) < 64)
1921 		rss_conf.rss_hf = 1ULL << atoi(res->value);
1922 	else {
1923 		printf("Unknown parameter\n");
1924 		return;
1925 	}
1926 	rss_conf.rss_key = NULL;
1927 	for (i = 0; i < rte_eth_dev_count(); i++) {
1928 		diag = rte_eth_dev_rss_hash_update(i, &rss_conf);
1929 		if (diag < 0)
1930 			printf("Configuration of RSS hash at ethernet port %d "
1931 				"failed with error (%d): %s.\n",
1932 				i, -diag, strerror(-diag));
1933 	}
1934 }
1935 
1936 cmdline_parse_token_string_t cmd_config_rss_port =
1937 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1938 cmdline_parse_token_string_t cmd_config_rss_keyword =
1939 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1940 cmdline_parse_token_string_t cmd_config_rss_all =
1941 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1942 cmdline_parse_token_string_t cmd_config_rss_name =
1943 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1944 cmdline_parse_token_string_t cmd_config_rss_value =
1945 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
1946 
1947 cmdline_parse_inst_t cmd_config_rss = {
1948 	.f = cmd_config_rss_parsed,
1949 	.data = NULL,
1950 	.help_str = "port config all rss "
1951 		"all|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none|<flowtype_id>",
1952 	.tokens = {
1953 		(void *)&cmd_config_rss_port,
1954 		(void *)&cmd_config_rss_keyword,
1955 		(void *)&cmd_config_rss_all,
1956 		(void *)&cmd_config_rss_name,
1957 		(void *)&cmd_config_rss_value,
1958 		NULL,
1959 	},
1960 };
1961 
1962 /* *** configure rss hash key *** */
1963 struct cmd_config_rss_hash_key {
1964 	cmdline_fixed_string_t port;
1965 	cmdline_fixed_string_t config;
1966 	portid_t port_id;
1967 	cmdline_fixed_string_t rss_hash_key;
1968 	cmdline_fixed_string_t rss_type;
1969 	cmdline_fixed_string_t key;
1970 };
1971 
1972 static uint8_t
1973 hexa_digit_to_value(char hexa_digit)
1974 {
1975 	if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1976 		return (uint8_t) (hexa_digit - '0');
1977 	if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1978 		return (uint8_t) ((hexa_digit - 'a') + 10);
1979 	if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1980 		return (uint8_t) ((hexa_digit - 'A') + 10);
1981 	/* Invalid hexa digit */
1982 	return 0xFF;
1983 }
1984 
1985 static uint8_t
1986 parse_and_check_key_hexa_digit(char *key, int idx)
1987 {
1988 	uint8_t hexa_v;
1989 
1990 	hexa_v = hexa_digit_to_value(key[idx]);
1991 	if (hexa_v == 0xFF)
1992 		printf("invalid key: character %c at position %d is not a "
1993 		       "valid hexa digit\n", key[idx], idx);
1994 	return hexa_v;
1995 }
1996 
1997 static void
1998 cmd_config_rss_hash_key_parsed(void *parsed_result,
1999 			       __attribute__((unused)) struct cmdline *cl,
2000 			       __attribute__((unused)) void *data)
2001 {
2002 	struct cmd_config_rss_hash_key *res = parsed_result;
2003 	uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2004 	uint8_t xdgt0;
2005 	uint8_t xdgt1;
2006 	int i;
2007 	struct rte_eth_dev_info dev_info;
2008 	uint8_t hash_key_size;
2009 	uint32_t key_len;
2010 
2011 	memset(&dev_info, 0, sizeof(dev_info));
2012 	rte_eth_dev_info_get(res->port_id, &dev_info);
2013 	if (dev_info.hash_key_size > 0 &&
2014 			dev_info.hash_key_size <= sizeof(hash_key))
2015 		hash_key_size = dev_info.hash_key_size;
2016 	else {
2017 		printf("dev_info did not provide a valid hash key size\n");
2018 		return;
2019 	}
2020 	/* Check the length of the RSS hash key */
2021 	key_len = strlen(res->key);
2022 	if (key_len != (hash_key_size * 2)) {
2023 		printf("key length: %d invalid - key must be a string of %d"
2024 			   " hexa-decimal numbers\n",
2025 			   (int) key_len, hash_key_size * 2);
2026 		return;
2027 	}
2028 	/* Translate RSS hash key into binary representation */
2029 	for (i = 0; i < hash_key_size; i++) {
2030 		xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2031 		if (xdgt0 == 0xFF)
2032 			return;
2033 		xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2034 		if (xdgt1 == 0xFF)
2035 			return;
2036 		hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2037 	}
2038 	port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2039 			hash_key_size);
2040 }
2041 
2042 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2043 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2044 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2045 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2046 				 "config");
2047 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2048 	TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16);
2049 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2050 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2051 				 rss_hash_key, "rss-hash-key");
2052 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2053 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2054 				 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2055 				 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2056 				 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2057 				 "ipv6-tcp-ex#ipv6-udp-ex");
2058 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2059 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2060 
2061 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2062 	.f = cmd_config_rss_hash_key_parsed,
2063 	.data = NULL,
2064 	.help_str = "port config <port_id> rss-hash-key "
2065 		"ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2066 		"ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2067 		"l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex "
2068 		"<string of hex digits (variable length, NIC dependent)>",
2069 	.tokens = {
2070 		(void *)&cmd_config_rss_hash_key_port,
2071 		(void *)&cmd_config_rss_hash_key_config,
2072 		(void *)&cmd_config_rss_hash_key_port_id,
2073 		(void *)&cmd_config_rss_hash_key_rss_hash_key,
2074 		(void *)&cmd_config_rss_hash_key_rss_type,
2075 		(void *)&cmd_config_rss_hash_key_value,
2076 		NULL,
2077 	},
2078 };
2079 
2080 /* *** configure port rxq/txq start/stop *** */
2081 struct cmd_config_rxtx_queue {
2082 	cmdline_fixed_string_t port;
2083 	portid_t portid;
2084 	cmdline_fixed_string_t rxtxq;
2085 	uint16_t qid;
2086 	cmdline_fixed_string_t opname;
2087 };
2088 
2089 static void
2090 cmd_config_rxtx_queue_parsed(void *parsed_result,
2091 			__attribute__((unused)) struct cmdline *cl,
2092 			__attribute__((unused)) void *data)
2093 {
2094 	struct cmd_config_rxtx_queue *res = parsed_result;
2095 	uint8_t isrx;
2096 	uint8_t isstart;
2097 	int ret = 0;
2098 
2099 	if (test_done == 0) {
2100 		printf("Please stop forwarding first\n");
2101 		return;
2102 	}
2103 
2104 	if (port_id_is_invalid(res->portid, ENABLED_WARN))
2105 		return;
2106 
2107 	if (port_is_started(res->portid) != 1) {
2108 		printf("Please start port %u first\n", res->portid);
2109 		return;
2110 	}
2111 
2112 	if (!strcmp(res->rxtxq, "rxq"))
2113 		isrx = 1;
2114 	else if (!strcmp(res->rxtxq, "txq"))
2115 		isrx = 0;
2116 	else {
2117 		printf("Unknown parameter\n");
2118 		return;
2119 	}
2120 
2121 	if (isrx && rx_queue_id_is_invalid(res->qid))
2122 		return;
2123 	else if (!isrx && tx_queue_id_is_invalid(res->qid))
2124 		return;
2125 
2126 	if (!strcmp(res->opname, "start"))
2127 		isstart = 1;
2128 	else if (!strcmp(res->opname, "stop"))
2129 		isstart = 0;
2130 	else {
2131 		printf("Unknown parameter\n");
2132 		return;
2133 	}
2134 
2135 	if (isstart && isrx)
2136 		ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2137 	else if (!isstart && isrx)
2138 		ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2139 	else if (isstart && !isrx)
2140 		ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2141 	else
2142 		ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2143 
2144 	if (ret == -ENOTSUP)
2145 		printf("Function not supported in PMD driver\n");
2146 }
2147 
2148 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2149 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2150 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2151 	TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16);
2152 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2153 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2154 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2155 	TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
2156 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2157 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2158 						"start#stop");
2159 
2160 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2161 	.f = cmd_config_rxtx_queue_parsed,
2162 	.data = NULL,
2163 	.help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2164 	.tokens = {
2165 		(void *)&cmd_config_speed_all_port,
2166 		(void *)&cmd_config_rxtx_queue_portid,
2167 		(void *)&cmd_config_rxtx_queue_rxtxq,
2168 		(void *)&cmd_config_rxtx_queue_qid,
2169 		(void *)&cmd_config_rxtx_queue_opname,
2170 		NULL,
2171 	},
2172 };
2173 
2174 /* *** Configure RSS RETA *** */
2175 struct cmd_config_rss_reta {
2176 	cmdline_fixed_string_t port;
2177 	cmdline_fixed_string_t keyword;
2178 	portid_t port_id;
2179 	cmdline_fixed_string_t name;
2180 	cmdline_fixed_string_t list_name;
2181 	cmdline_fixed_string_t list_of_items;
2182 };
2183 
2184 static int
2185 parse_reta_config(const char *str,
2186 		  struct rte_eth_rss_reta_entry64 *reta_conf,
2187 		  uint16_t nb_entries)
2188 {
2189 	int i;
2190 	unsigned size;
2191 	uint16_t hash_index, idx, shift;
2192 	uint16_t nb_queue;
2193 	char s[256];
2194 	const char *p, *p0 = str;
2195 	char *end;
2196 	enum fieldnames {
2197 		FLD_HASH_INDEX = 0,
2198 		FLD_QUEUE,
2199 		_NUM_FLD
2200 	};
2201 	unsigned long int_fld[_NUM_FLD];
2202 	char *str_fld[_NUM_FLD];
2203 
2204 	while ((p = strchr(p0,'(')) != NULL) {
2205 		++p;
2206 		if((p0 = strchr(p,')')) == NULL)
2207 			return -1;
2208 
2209 		size = p0 - p;
2210 		if(size >= sizeof(s))
2211 			return -1;
2212 
2213 		snprintf(s, sizeof(s), "%.*s", size, p);
2214 		if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2215 			return -1;
2216 		for (i = 0; i < _NUM_FLD; i++) {
2217 			errno = 0;
2218 			int_fld[i] = strtoul(str_fld[i], &end, 0);
2219 			if (errno != 0 || end == str_fld[i] ||
2220 					int_fld[i] > 65535)
2221 				return -1;
2222 		}
2223 
2224 		hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2225 		nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2226 
2227 		if (hash_index >= nb_entries) {
2228 			printf("Invalid RETA hash index=%d\n", hash_index);
2229 			return -1;
2230 		}
2231 
2232 		idx = hash_index / RTE_RETA_GROUP_SIZE;
2233 		shift = hash_index % RTE_RETA_GROUP_SIZE;
2234 		reta_conf[idx].mask |= (1ULL << shift);
2235 		reta_conf[idx].reta[shift] = nb_queue;
2236 	}
2237 
2238 	return 0;
2239 }
2240 
2241 static void
2242 cmd_set_rss_reta_parsed(void *parsed_result,
2243 			__attribute__((unused)) struct cmdline *cl,
2244 			__attribute__((unused)) void *data)
2245 {
2246 	int ret;
2247 	struct rte_eth_dev_info dev_info;
2248 	struct rte_eth_rss_reta_entry64 reta_conf[8];
2249 	struct cmd_config_rss_reta *res = parsed_result;
2250 
2251 	memset(&dev_info, 0, sizeof(dev_info));
2252 	rte_eth_dev_info_get(res->port_id, &dev_info);
2253 	if (dev_info.reta_size == 0) {
2254 		printf("Redirection table size is 0 which is "
2255 					"invalid for RSS\n");
2256 		return;
2257 	} else
2258 		printf("The reta size of port %d is %u\n",
2259 			res->port_id, dev_info.reta_size);
2260 	if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2261 		printf("Currently do not support more than %u entries of "
2262 			"redirection table\n", ETH_RSS_RETA_SIZE_512);
2263 		return;
2264 	}
2265 
2266 	memset(reta_conf, 0, sizeof(reta_conf));
2267 	if (!strcmp(res->list_name, "reta")) {
2268 		if (parse_reta_config(res->list_of_items, reta_conf,
2269 						dev_info.reta_size)) {
2270 			printf("Invalid RSS Redirection Table "
2271 					"config entered\n");
2272 			return;
2273 		}
2274 		ret = rte_eth_dev_rss_reta_update(res->port_id,
2275 				reta_conf, dev_info.reta_size);
2276 		if (ret != 0)
2277 			printf("Bad redirection table parameter, "
2278 					"return code = %d \n", ret);
2279 	}
2280 }
2281 
2282 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2283 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2284 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2285 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2286 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2287 	TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16);
2288 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2289 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2290 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2291 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2292 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2293         TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2294                                  NULL);
2295 cmdline_parse_inst_t cmd_config_rss_reta = {
2296 	.f = cmd_set_rss_reta_parsed,
2297 	.data = NULL,
2298 	.help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2299 	.tokens = {
2300 		(void *)&cmd_config_rss_reta_port,
2301 		(void *)&cmd_config_rss_reta_keyword,
2302 		(void *)&cmd_config_rss_reta_port_id,
2303 		(void *)&cmd_config_rss_reta_name,
2304 		(void *)&cmd_config_rss_reta_list_name,
2305 		(void *)&cmd_config_rss_reta_list_of_items,
2306 		NULL,
2307 	},
2308 };
2309 
2310 /* *** SHOW PORT RETA INFO *** */
2311 struct cmd_showport_reta {
2312 	cmdline_fixed_string_t show;
2313 	cmdline_fixed_string_t port;
2314 	portid_t port_id;
2315 	cmdline_fixed_string_t rss;
2316 	cmdline_fixed_string_t reta;
2317 	uint16_t size;
2318 	cmdline_fixed_string_t list_of_items;
2319 };
2320 
2321 static int
2322 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2323 			   uint16_t nb_entries,
2324 			   char *str)
2325 {
2326 	uint32_t size;
2327 	const char *p, *p0 = str;
2328 	char s[256];
2329 	char *end;
2330 	char *str_fld[8];
2331 	uint16_t i;
2332 	uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
2333 			RTE_RETA_GROUP_SIZE;
2334 	int ret;
2335 
2336 	p = strchr(p0, '(');
2337 	if (p == NULL)
2338 		return -1;
2339 	p++;
2340 	p0 = strchr(p, ')');
2341 	if (p0 == NULL)
2342 		return -1;
2343 	size = p0 - p;
2344 	if (size >= sizeof(s)) {
2345 		printf("The string size exceeds the internal buffer size\n");
2346 		return -1;
2347 	}
2348 	snprintf(s, sizeof(s), "%.*s", size, p);
2349 	ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
2350 	if (ret <= 0 || ret != num) {
2351 		printf("The bits of masks do not match the number of "
2352 					"reta entries: %u\n", num);
2353 		return -1;
2354 	}
2355 	for (i = 0; i < ret; i++)
2356 		conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
2357 
2358 	return 0;
2359 }
2360 
2361 static void
2362 cmd_showport_reta_parsed(void *parsed_result,
2363 			 __attribute__((unused)) struct cmdline *cl,
2364 			 __attribute__((unused)) void *data)
2365 {
2366 	struct cmd_showport_reta *res = parsed_result;
2367 	struct rte_eth_rss_reta_entry64 reta_conf[8];
2368 	struct rte_eth_dev_info dev_info;
2369 	uint16_t max_reta_size;
2370 
2371 	memset(&dev_info, 0, sizeof(dev_info));
2372 	rte_eth_dev_info_get(res->port_id, &dev_info);
2373 	max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
2374 	if (res->size == 0 || res->size > max_reta_size) {
2375 		printf("Invalid redirection table size: %u (1-%u)\n",
2376 			res->size, max_reta_size);
2377 		return;
2378 	}
2379 
2380 	memset(reta_conf, 0, sizeof(reta_conf));
2381 	if (showport_parse_reta_config(reta_conf, res->size,
2382 				res->list_of_items) < 0) {
2383 		printf("Invalid string: %s for reta masks\n",
2384 					res->list_of_items);
2385 		return;
2386 	}
2387 	port_rss_reta_info(res->port_id, reta_conf, res->size);
2388 }
2389 
2390 cmdline_parse_token_string_t cmd_showport_reta_show =
2391 	TOKEN_STRING_INITIALIZER(struct  cmd_showport_reta, show, "show");
2392 cmdline_parse_token_string_t cmd_showport_reta_port =
2393 	TOKEN_STRING_INITIALIZER(struct  cmd_showport_reta, port, "port");
2394 cmdline_parse_token_num_t cmd_showport_reta_port_id =
2395 	TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16);
2396 cmdline_parse_token_string_t cmd_showport_reta_rss =
2397 	TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
2398 cmdline_parse_token_string_t cmd_showport_reta_reta =
2399 	TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
2400 cmdline_parse_token_num_t cmd_showport_reta_size =
2401 	TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
2402 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
2403 	TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
2404 					list_of_items, NULL);
2405 
2406 cmdline_parse_inst_t cmd_showport_reta = {
2407 	.f = cmd_showport_reta_parsed,
2408 	.data = NULL,
2409 	.help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
2410 	.tokens = {
2411 		(void *)&cmd_showport_reta_show,
2412 		(void *)&cmd_showport_reta_port,
2413 		(void *)&cmd_showport_reta_port_id,
2414 		(void *)&cmd_showport_reta_rss,
2415 		(void *)&cmd_showport_reta_reta,
2416 		(void *)&cmd_showport_reta_size,
2417 		(void *)&cmd_showport_reta_list_of_items,
2418 		NULL,
2419 	},
2420 };
2421 
2422 /* *** Show RSS hash configuration *** */
2423 struct cmd_showport_rss_hash {
2424 	cmdline_fixed_string_t show;
2425 	cmdline_fixed_string_t port;
2426 	portid_t port_id;
2427 	cmdline_fixed_string_t rss_hash;
2428 	cmdline_fixed_string_t rss_type;
2429 	cmdline_fixed_string_t key; /* optional argument */
2430 };
2431 
2432 static void cmd_showport_rss_hash_parsed(void *parsed_result,
2433 				__attribute__((unused)) struct cmdline *cl,
2434 				void *show_rss_key)
2435 {
2436 	struct cmd_showport_rss_hash *res = parsed_result;
2437 
2438 	port_rss_hash_conf_show(res->port_id, res->rss_type,
2439 				show_rss_key != NULL);
2440 }
2441 
2442 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
2443 	TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
2444 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
2445 	TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
2446 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
2447 	TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16);
2448 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
2449 	TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
2450 				 "rss-hash");
2451 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash_info =
2452 	TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_type,
2453 				 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2454 				 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2455 				 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2456 				 "ipv6-tcp-ex#ipv6-udp-ex");
2457 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
2458 	TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
2459 
2460 cmdline_parse_inst_t cmd_showport_rss_hash = {
2461 	.f = cmd_showport_rss_hash_parsed,
2462 	.data = NULL,
2463 	.help_str = "show port <port_id> rss-hash "
2464 		"ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2465 		"ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2466 		"l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex",
2467 	.tokens = {
2468 		(void *)&cmd_showport_rss_hash_show,
2469 		(void *)&cmd_showport_rss_hash_port,
2470 		(void *)&cmd_showport_rss_hash_port_id,
2471 		(void *)&cmd_showport_rss_hash_rss_hash,
2472 		(void *)&cmd_showport_rss_hash_rss_hash_info,
2473 		NULL,
2474 	},
2475 };
2476 
2477 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
2478 	.f = cmd_showport_rss_hash_parsed,
2479 	.data = (void *)1,
2480 	.help_str = "show port <port_id> rss-hash "
2481 		"ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2482 		"ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2483 		"l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex key",
2484 	.tokens = {
2485 		(void *)&cmd_showport_rss_hash_show,
2486 		(void *)&cmd_showport_rss_hash_port,
2487 		(void *)&cmd_showport_rss_hash_port_id,
2488 		(void *)&cmd_showport_rss_hash_rss_hash,
2489 		(void *)&cmd_showport_rss_hash_rss_hash_info,
2490 		(void *)&cmd_showport_rss_hash_rss_key,
2491 		NULL,
2492 	},
2493 };
2494 
2495 /* *** Configure DCB *** */
2496 struct cmd_config_dcb {
2497 	cmdline_fixed_string_t port;
2498 	cmdline_fixed_string_t config;
2499 	portid_t port_id;
2500 	cmdline_fixed_string_t dcb;
2501 	cmdline_fixed_string_t vt;
2502 	cmdline_fixed_string_t vt_en;
2503 	uint8_t num_tcs;
2504 	cmdline_fixed_string_t pfc;
2505 	cmdline_fixed_string_t pfc_en;
2506 };
2507 
2508 static void
2509 cmd_config_dcb_parsed(void *parsed_result,
2510                         __attribute__((unused)) struct cmdline *cl,
2511                         __attribute__((unused)) void *data)
2512 {
2513 	struct cmd_config_dcb *res = parsed_result;
2514 	portid_t port_id = res->port_id;
2515 	struct rte_port *port;
2516 	uint8_t pfc_en;
2517 	int ret;
2518 
2519 	port = &ports[port_id];
2520 	/** Check if the port is not started **/
2521 	if (port->port_status != RTE_PORT_STOPPED) {
2522 		printf("Please stop port %d first\n", port_id);
2523 		return;
2524 	}
2525 
2526 	if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
2527 		printf("The invalid number of traffic class,"
2528 			" only 4 or 8 allowed.\n");
2529 		return;
2530 	}
2531 
2532 	if (nb_fwd_lcores < res->num_tcs) {
2533 		printf("nb_cores shouldn't be less than number of TCs.\n");
2534 		return;
2535 	}
2536 	if (!strncmp(res->pfc_en, "on", 2))
2537 		pfc_en = 1;
2538 	else
2539 		pfc_en = 0;
2540 
2541 	/* DCB in VT mode */
2542 	if (!strncmp(res->vt_en, "on", 2))
2543 		ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
2544 				(enum rte_eth_nb_tcs)res->num_tcs,
2545 				pfc_en);
2546 	else
2547 		ret = init_port_dcb_config(port_id, DCB_ENABLED,
2548 				(enum rte_eth_nb_tcs)res->num_tcs,
2549 				pfc_en);
2550 
2551 
2552 	if (ret != 0) {
2553 		printf("Cannot initialize network ports.\n");
2554 		return;
2555 	}
2556 
2557 	cmd_reconfig_device_queue(port_id, 1, 1);
2558 }
2559 
2560 cmdline_parse_token_string_t cmd_config_dcb_port =
2561         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
2562 cmdline_parse_token_string_t cmd_config_dcb_config =
2563         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
2564 cmdline_parse_token_num_t cmd_config_dcb_port_id =
2565 	TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16);
2566 cmdline_parse_token_string_t cmd_config_dcb_dcb =
2567         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
2568 cmdline_parse_token_string_t cmd_config_dcb_vt =
2569         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
2570 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
2571         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
2572 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
2573         TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
2574 cmdline_parse_token_string_t cmd_config_dcb_pfc=
2575         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
2576 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
2577         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
2578 
2579 cmdline_parse_inst_t cmd_config_dcb = {
2580 	.f = cmd_config_dcb_parsed,
2581 	.data = NULL,
2582 	.help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
2583 	.tokens = {
2584 		(void *)&cmd_config_dcb_port,
2585 		(void *)&cmd_config_dcb_config,
2586 		(void *)&cmd_config_dcb_port_id,
2587 		(void *)&cmd_config_dcb_dcb,
2588 		(void *)&cmd_config_dcb_vt,
2589 		(void *)&cmd_config_dcb_vt_en,
2590 		(void *)&cmd_config_dcb_num_tcs,
2591 		(void *)&cmd_config_dcb_pfc,
2592 		(void *)&cmd_config_dcb_pfc_en,
2593                 NULL,
2594         },
2595 };
2596 
2597 /* *** configure number of packets per burst *** */
2598 struct cmd_config_burst {
2599 	cmdline_fixed_string_t port;
2600 	cmdline_fixed_string_t keyword;
2601 	cmdline_fixed_string_t all;
2602 	cmdline_fixed_string_t name;
2603 	uint16_t value;
2604 };
2605 
2606 static void
2607 cmd_config_burst_parsed(void *parsed_result,
2608 			__attribute__((unused)) struct cmdline *cl,
2609 			__attribute__((unused)) void *data)
2610 {
2611 	struct cmd_config_burst *res = parsed_result;
2612 
2613 	if (!all_ports_stopped()) {
2614 		printf("Please stop all ports first\n");
2615 		return;
2616 	}
2617 
2618 	if (!strcmp(res->name, "burst")) {
2619 		if (res->value < 1 || res->value > MAX_PKT_BURST) {
2620 			printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
2621 			return;
2622 		}
2623 		nb_pkt_per_burst = res->value;
2624 	} else {
2625 		printf("Unknown parameter\n");
2626 		return;
2627 	}
2628 
2629 	init_port_config();
2630 
2631 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2632 }
2633 
2634 cmdline_parse_token_string_t cmd_config_burst_port =
2635 	TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
2636 cmdline_parse_token_string_t cmd_config_burst_keyword =
2637 	TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
2638 cmdline_parse_token_string_t cmd_config_burst_all =
2639 	TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
2640 cmdline_parse_token_string_t cmd_config_burst_name =
2641 	TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
2642 cmdline_parse_token_num_t cmd_config_burst_value =
2643 	TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
2644 
2645 cmdline_parse_inst_t cmd_config_burst = {
2646 	.f = cmd_config_burst_parsed,
2647 	.data = NULL,
2648 	.help_str = "port config all burst <value>",
2649 	.tokens = {
2650 		(void *)&cmd_config_burst_port,
2651 		(void *)&cmd_config_burst_keyword,
2652 		(void *)&cmd_config_burst_all,
2653 		(void *)&cmd_config_burst_name,
2654 		(void *)&cmd_config_burst_value,
2655 		NULL,
2656 	},
2657 };
2658 
2659 /* *** configure rx/tx queues *** */
2660 struct cmd_config_thresh {
2661 	cmdline_fixed_string_t port;
2662 	cmdline_fixed_string_t keyword;
2663 	cmdline_fixed_string_t all;
2664 	cmdline_fixed_string_t name;
2665 	uint8_t value;
2666 };
2667 
2668 static void
2669 cmd_config_thresh_parsed(void *parsed_result,
2670 			__attribute__((unused)) struct cmdline *cl,
2671 			__attribute__((unused)) void *data)
2672 {
2673 	struct cmd_config_thresh *res = parsed_result;
2674 
2675 	if (!all_ports_stopped()) {
2676 		printf("Please stop all ports first\n");
2677 		return;
2678 	}
2679 
2680 	if (!strcmp(res->name, "txpt"))
2681 		tx_pthresh = res->value;
2682 	else if(!strcmp(res->name, "txht"))
2683 		tx_hthresh = res->value;
2684 	else if(!strcmp(res->name, "txwt"))
2685 		tx_wthresh = res->value;
2686 	else if(!strcmp(res->name, "rxpt"))
2687 		rx_pthresh = res->value;
2688 	else if(!strcmp(res->name, "rxht"))
2689 		rx_hthresh = res->value;
2690 	else if(!strcmp(res->name, "rxwt"))
2691 		rx_wthresh = res->value;
2692 	else {
2693 		printf("Unknown parameter\n");
2694 		return;
2695 	}
2696 
2697 	init_port_config();
2698 
2699 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2700 }
2701 
2702 cmdline_parse_token_string_t cmd_config_thresh_port =
2703 	TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
2704 cmdline_parse_token_string_t cmd_config_thresh_keyword =
2705 	TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
2706 cmdline_parse_token_string_t cmd_config_thresh_all =
2707 	TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
2708 cmdline_parse_token_string_t cmd_config_thresh_name =
2709 	TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
2710 				"txpt#txht#txwt#rxpt#rxht#rxwt");
2711 cmdline_parse_token_num_t cmd_config_thresh_value =
2712 	TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2713 
2714 cmdline_parse_inst_t cmd_config_thresh = {
2715 	.f = cmd_config_thresh_parsed,
2716 	.data = NULL,
2717 	.help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
2718 	.tokens = {
2719 		(void *)&cmd_config_thresh_port,
2720 		(void *)&cmd_config_thresh_keyword,
2721 		(void *)&cmd_config_thresh_all,
2722 		(void *)&cmd_config_thresh_name,
2723 		(void *)&cmd_config_thresh_value,
2724 		NULL,
2725 	},
2726 };
2727 
2728 /* *** configure free/rs threshold *** */
2729 struct cmd_config_threshold {
2730 	cmdline_fixed_string_t port;
2731 	cmdline_fixed_string_t keyword;
2732 	cmdline_fixed_string_t all;
2733 	cmdline_fixed_string_t name;
2734 	uint16_t value;
2735 };
2736 
2737 static void
2738 cmd_config_threshold_parsed(void *parsed_result,
2739 			__attribute__((unused)) struct cmdline *cl,
2740 			__attribute__((unused)) void *data)
2741 {
2742 	struct cmd_config_threshold *res = parsed_result;
2743 
2744 	if (!all_ports_stopped()) {
2745 		printf("Please stop all ports first\n");
2746 		return;
2747 	}
2748 
2749 	if (!strcmp(res->name, "txfreet"))
2750 		tx_free_thresh = res->value;
2751 	else if (!strcmp(res->name, "txrst"))
2752 		tx_rs_thresh = res->value;
2753 	else if (!strcmp(res->name, "rxfreet"))
2754 		rx_free_thresh = res->value;
2755 	else {
2756 		printf("Unknown parameter\n");
2757 		return;
2758 	}
2759 
2760 	init_port_config();
2761 
2762 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2763 }
2764 
2765 cmdline_parse_token_string_t cmd_config_threshold_port =
2766 	TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2767 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2768 	TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2769 								"config");
2770 cmdline_parse_token_string_t cmd_config_threshold_all =
2771 	TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2772 cmdline_parse_token_string_t cmd_config_threshold_name =
2773 	TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2774 						"txfreet#txrst#rxfreet");
2775 cmdline_parse_token_num_t cmd_config_threshold_value =
2776 	TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2777 
2778 cmdline_parse_inst_t cmd_config_threshold = {
2779 	.f = cmd_config_threshold_parsed,
2780 	.data = NULL,
2781 	.help_str = "port config all txfreet|txrst|rxfreet <value>",
2782 	.tokens = {
2783 		(void *)&cmd_config_threshold_port,
2784 		(void *)&cmd_config_threshold_keyword,
2785 		(void *)&cmd_config_threshold_all,
2786 		(void *)&cmd_config_threshold_name,
2787 		(void *)&cmd_config_threshold_value,
2788 		NULL,
2789 	},
2790 };
2791 
2792 /* *** stop *** */
2793 struct cmd_stop_result {
2794 	cmdline_fixed_string_t stop;
2795 };
2796 
2797 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2798 			    __attribute__((unused)) struct cmdline *cl,
2799 			    __attribute__((unused)) void *data)
2800 {
2801 	stop_packet_forwarding();
2802 }
2803 
2804 cmdline_parse_token_string_t cmd_stop_stop =
2805 	TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2806 
2807 cmdline_parse_inst_t cmd_stop = {
2808 	.f = cmd_stop_parsed,
2809 	.data = NULL,
2810 	.help_str = "stop: Stop packet forwarding",
2811 	.tokens = {
2812 		(void *)&cmd_stop_stop,
2813 		NULL,
2814 	},
2815 };
2816 
2817 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2818 
2819 unsigned int
2820 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2821 		unsigned int *parsed_items, int check_unique_values)
2822 {
2823 	unsigned int nb_item;
2824 	unsigned int value;
2825 	unsigned int i;
2826 	unsigned int j;
2827 	int value_ok;
2828 	char c;
2829 
2830 	/*
2831 	 * First parse all items in the list and store their value.
2832 	 */
2833 	value = 0;
2834 	nb_item = 0;
2835 	value_ok = 0;
2836 	for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2837 		c = str[i];
2838 		if ((c >= '0') && (c <= '9')) {
2839 			value = (unsigned int) (value * 10 + (c - '0'));
2840 			value_ok = 1;
2841 			continue;
2842 		}
2843 		if (c != ',') {
2844 			printf("character %c is not a decimal digit\n", c);
2845 			return 0;
2846 		}
2847 		if (! value_ok) {
2848 			printf("No valid value before comma\n");
2849 			return 0;
2850 		}
2851 		if (nb_item < max_items) {
2852 			parsed_items[nb_item] = value;
2853 			value_ok = 0;
2854 			value = 0;
2855 		}
2856 		nb_item++;
2857 	}
2858 	if (nb_item >= max_items) {
2859 		printf("Number of %s = %u > %u (maximum items)\n",
2860 		       item_name, nb_item + 1, max_items);
2861 		return 0;
2862 	}
2863 	parsed_items[nb_item++] = value;
2864 	if (! check_unique_values)
2865 		return nb_item;
2866 
2867 	/*
2868 	 * Then, check that all values in the list are differents.
2869 	 * No optimization here...
2870 	 */
2871 	for (i = 0; i < nb_item; i++) {
2872 		for (j = i + 1; j < nb_item; j++) {
2873 			if (parsed_items[j] == parsed_items[i]) {
2874 				printf("duplicated %s %u at index %u and %u\n",
2875 				       item_name, parsed_items[i], i, j);
2876 				return 0;
2877 			}
2878 		}
2879 	}
2880 	return nb_item;
2881 }
2882 
2883 struct cmd_set_list_result {
2884 	cmdline_fixed_string_t cmd_keyword;
2885 	cmdline_fixed_string_t list_name;
2886 	cmdline_fixed_string_t list_of_items;
2887 };
2888 
2889 static void cmd_set_list_parsed(void *parsed_result,
2890 				__attribute__((unused)) struct cmdline *cl,
2891 				__attribute__((unused)) void *data)
2892 {
2893 	struct cmd_set_list_result *res;
2894 	union {
2895 		unsigned int lcorelist[RTE_MAX_LCORE];
2896 		unsigned int portlist[RTE_MAX_ETHPORTS];
2897 	} parsed_items;
2898 	unsigned int nb_item;
2899 
2900 	if (test_done == 0) {
2901 		printf("Please stop forwarding first\n");
2902 		return;
2903 	}
2904 
2905 	res = parsed_result;
2906 	if (!strcmp(res->list_name, "corelist")) {
2907 		nb_item = parse_item_list(res->list_of_items, "core",
2908 					  RTE_MAX_LCORE,
2909 					  parsed_items.lcorelist, 1);
2910 		if (nb_item > 0) {
2911 			set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2912 			fwd_config_setup();
2913 		}
2914 		return;
2915 	}
2916 	if (!strcmp(res->list_name, "portlist")) {
2917 		nb_item = parse_item_list(res->list_of_items, "port",
2918 					  RTE_MAX_ETHPORTS,
2919 					  parsed_items.portlist, 1);
2920 		if (nb_item > 0) {
2921 			set_fwd_ports_list(parsed_items.portlist, nb_item);
2922 			fwd_config_setup();
2923 		}
2924 	}
2925 }
2926 
2927 cmdline_parse_token_string_t cmd_set_list_keyword =
2928 	TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2929 				 "set");
2930 cmdline_parse_token_string_t cmd_set_list_name =
2931 	TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2932 				 "corelist#portlist");
2933 cmdline_parse_token_string_t cmd_set_list_of_items =
2934 	TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2935 				 NULL);
2936 
2937 cmdline_parse_inst_t cmd_set_fwd_list = {
2938 	.f = cmd_set_list_parsed,
2939 	.data = NULL,
2940 	.help_str = "set corelist|portlist <list0[,list1]*>",
2941 	.tokens = {
2942 		(void *)&cmd_set_list_keyword,
2943 		(void *)&cmd_set_list_name,
2944 		(void *)&cmd_set_list_of_items,
2945 		NULL,
2946 	},
2947 };
2948 
2949 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2950 
2951 struct cmd_setmask_result {
2952 	cmdline_fixed_string_t set;
2953 	cmdline_fixed_string_t mask;
2954 	uint64_t hexavalue;
2955 };
2956 
2957 static void cmd_set_mask_parsed(void *parsed_result,
2958 				__attribute__((unused)) struct cmdline *cl,
2959 				__attribute__((unused)) void *data)
2960 {
2961 	struct cmd_setmask_result *res = parsed_result;
2962 
2963 	if (test_done == 0) {
2964 		printf("Please stop forwarding first\n");
2965 		return;
2966 	}
2967 	if (!strcmp(res->mask, "coremask")) {
2968 		set_fwd_lcores_mask(res->hexavalue);
2969 		fwd_config_setup();
2970 	} else if (!strcmp(res->mask, "portmask")) {
2971 		set_fwd_ports_mask(res->hexavalue);
2972 		fwd_config_setup();
2973 	}
2974 }
2975 
2976 cmdline_parse_token_string_t cmd_setmask_set =
2977 	TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2978 cmdline_parse_token_string_t cmd_setmask_mask =
2979 	TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2980 				 "coremask#portmask");
2981 cmdline_parse_token_num_t cmd_setmask_value =
2982 	TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2983 
2984 cmdline_parse_inst_t cmd_set_fwd_mask = {
2985 	.f = cmd_set_mask_parsed,
2986 	.data = NULL,
2987 	.help_str = "set coremask|portmask <hexadecimal value>",
2988 	.tokens = {
2989 		(void *)&cmd_setmask_set,
2990 		(void *)&cmd_setmask_mask,
2991 		(void *)&cmd_setmask_value,
2992 		NULL,
2993 	},
2994 };
2995 
2996 /*
2997  * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2998  */
2999 struct cmd_set_result {
3000 	cmdline_fixed_string_t set;
3001 	cmdline_fixed_string_t what;
3002 	uint16_t value;
3003 };
3004 
3005 static void cmd_set_parsed(void *parsed_result,
3006 			   __attribute__((unused)) struct cmdline *cl,
3007 			   __attribute__((unused)) void *data)
3008 {
3009 	struct cmd_set_result *res = parsed_result;
3010 	if (!strcmp(res->what, "nbport")) {
3011 		set_fwd_ports_number(res->value);
3012 		fwd_config_setup();
3013 	} else if (!strcmp(res->what, "nbcore")) {
3014 		set_fwd_lcores_number(res->value);
3015 		fwd_config_setup();
3016 	} else if (!strcmp(res->what, "burst"))
3017 		set_nb_pkt_per_burst(res->value);
3018 	else if (!strcmp(res->what, "verbose"))
3019 		set_verbose_level(res->value);
3020 }
3021 
3022 cmdline_parse_token_string_t cmd_set_set =
3023 	TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3024 cmdline_parse_token_string_t cmd_set_what =
3025 	TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3026 				 "nbport#nbcore#burst#verbose");
3027 cmdline_parse_token_num_t cmd_set_value =
3028 	TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
3029 
3030 cmdline_parse_inst_t cmd_set_numbers = {
3031 	.f = cmd_set_parsed,
3032 	.data = NULL,
3033 	.help_str = "set nbport|nbcore|burst|verbose <value>",
3034 	.tokens = {
3035 		(void *)&cmd_set_set,
3036 		(void *)&cmd_set_what,
3037 		(void *)&cmd_set_value,
3038 		NULL,
3039 	},
3040 };
3041 
3042 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3043 
3044 struct cmd_set_txpkts_result {
3045 	cmdline_fixed_string_t cmd_keyword;
3046 	cmdline_fixed_string_t txpkts;
3047 	cmdline_fixed_string_t seg_lengths;
3048 };
3049 
3050 static void
3051 cmd_set_txpkts_parsed(void *parsed_result,
3052 		      __attribute__((unused)) struct cmdline *cl,
3053 		      __attribute__((unused)) void *data)
3054 {
3055 	struct cmd_set_txpkts_result *res;
3056 	unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3057 	unsigned int nb_segs;
3058 
3059 	res = parsed_result;
3060 	nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3061 				  RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3062 	if (nb_segs > 0)
3063 		set_tx_pkt_segments(seg_lengths, nb_segs);
3064 }
3065 
3066 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3067 	TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3068 				 cmd_keyword, "set");
3069 cmdline_parse_token_string_t cmd_set_txpkts_name =
3070 	TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3071 				 txpkts, "txpkts");
3072 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3073 	TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3074 				 seg_lengths, NULL);
3075 
3076 cmdline_parse_inst_t cmd_set_txpkts = {
3077 	.f = cmd_set_txpkts_parsed,
3078 	.data = NULL,
3079 	.help_str = "set txpkts <len0[,len1]*>",
3080 	.tokens = {
3081 		(void *)&cmd_set_txpkts_keyword,
3082 		(void *)&cmd_set_txpkts_name,
3083 		(void *)&cmd_set_txpkts_lengths,
3084 		NULL,
3085 	},
3086 };
3087 
3088 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
3089 
3090 struct cmd_set_txsplit_result {
3091 	cmdline_fixed_string_t cmd_keyword;
3092 	cmdline_fixed_string_t txsplit;
3093 	cmdline_fixed_string_t mode;
3094 };
3095 
3096 static void
3097 cmd_set_txsplit_parsed(void *parsed_result,
3098 		      __attribute__((unused)) struct cmdline *cl,
3099 		      __attribute__((unused)) void *data)
3100 {
3101 	struct cmd_set_txsplit_result *res;
3102 
3103 	res = parsed_result;
3104 	set_tx_pkt_split(res->mode);
3105 }
3106 
3107 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
3108 	TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3109 				 cmd_keyword, "set");
3110 cmdline_parse_token_string_t cmd_set_txsplit_name =
3111 	TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3112 				 txsplit, "txsplit");
3113 cmdline_parse_token_string_t cmd_set_txsplit_mode =
3114 	TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3115 				 mode, NULL);
3116 
3117 cmdline_parse_inst_t cmd_set_txsplit = {
3118 	.f = cmd_set_txsplit_parsed,
3119 	.data = NULL,
3120 	.help_str = "set txsplit on|off|rand",
3121 	.tokens = {
3122 		(void *)&cmd_set_txsplit_keyword,
3123 		(void *)&cmd_set_txsplit_name,
3124 		(void *)&cmd_set_txsplit_mode,
3125 		NULL,
3126 	},
3127 };
3128 
3129 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
3130 struct cmd_rx_vlan_filter_all_result {
3131 	cmdline_fixed_string_t rx_vlan;
3132 	cmdline_fixed_string_t what;
3133 	cmdline_fixed_string_t all;
3134 	portid_t port_id;
3135 };
3136 
3137 static void
3138 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
3139 			      __attribute__((unused)) struct cmdline *cl,
3140 			      __attribute__((unused)) void *data)
3141 {
3142 	struct cmd_rx_vlan_filter_all_result *res = parsed_result;
3143 
3144 	if (!strcmp(res->what, "add"))
3145 		rx_vlan_all_filter_set(res->port_id, 1);
3146 	else
3147 		rx_vlan_all_filter_set(res->port_id, 0);
3148 }
3149 
3150 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
3151 	TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3152 				 rx_vlan, "rx_vlan");
3153 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
3154 	TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3155 				 what, "add#rm");
3156 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
3157 	TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3158 				 all, "all");
3159 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
3160 	TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3161 			      port_id, UINT16);
3162 
3163 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
3164 	.f = cmd_rx_vlan_filter_all_parsed,
3165 	.data = NULL,
3166 	.help_str = "rx_vlan add|rm all <port_id>: "
3167 		"Add/Remove all identifiers to/from the set of VLAN "
3168 		"identifiers filtered by a port",
3169 	.tokens = {
3170 		(void *)&cmd_rx_vlan_filter_all_rx_vlan,
3171 		(void *)&cmd_rx_vlan_filter_all_what,
3172 		(void *)&cmd_rx_vlan_filter_all_all,
3173 		(void *)&cmd_rx_vlan_filter_all_portid,
3174 		NULL,
3175 	},
3176 };
3177 
3178 /* *** VLAN OFFLOAD SET ON A PORT *** */
3179 struct cmd_vlan_offload_result {
3180 	cmdline_fixed_string_t vlan;
3181 	cmdline_fixed_string_t set;
3182 	cmdline_fixed_string_t vlan_type;
3183 	cmdline_fixed_string_t what;
3184 	cmdline_fixed_string_t on;
3185 	cmdline_fixed_string_t port_id;
3186 };
3187 
3188 static void
3189 cmd_vlan_offload_parsed(void *parsed_result,
3190 			  __attribute__((unused)) struct cmdline *cl,
3191 			  __attribute__((unused)) void *data)
3192 {
3193 	int on;
3194 	struct cmd_vlan_offload_result *res = parsed_result;
3195 	char *str;
3196 	int i, len = 0;
3197 	portid_t port_id = 0;
3198 	unsigned int tmp;
3199 
3200 	str = res->port_id;
3201 	len = strnlen(str, STR_TOKEN_SIZE);
3202 	i = 0;
3203 	/* Get port_id first */
3204 	while(i < len){
3205 		if(str[i] == ',')
3206 			break;
3207 
3208 		i++;
3209 	}
3210 	str[i]='\0';
3211 	tmp = strtoul(str, NULL, 0);
3212 	/* If port_id greater that what portid_t can represent, return */
3213 	if(tmp >= RTE_MAX_ETHPORTS)
3214 		return;
3215 	port_id = (portid_t)tmp;
3216 
3217 	if (!strcmp(res->on, "on"))
3218 		on = 1;
3219 	else
3220 		on = 0;
3221 
3222 	if (!strcmp(res->what, "strip"))
3223 		rx_vlan_strip_set(port_id,  on);
3224 	else if(!strcmp(res->what, "stripq")){
3225 		uint16_t queue_id = 0;
3226 
3227 		/* No queue_id, return */
3228 		if(i + 1 >= len) {
3229 			printf("must specify (port,queue_id)\n");
3230 			return;
3231 		}
3232 		tmp = strtoul(str + i + 1, NULL, 0);
3233 		/* If queue_id greater that what 16-bits can represent, return */
3234 		if(tmp > 0xffff)
3235 			return;
3236 
3237 		queue_id = (uint16_t)tmp;
3238 		rx_vlan_strip_set_on_queue(port_id, queue_id, on);
3239 	}
3240 	else if (!strcmp(res->what, "filter"))
3241 		rx_vlan_filter_set(port_id, on);
3242 	else
3243 		vlan_extend_set(port_id, on);
3244 
3245 	return;
3246 }
3247 
3248 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
3249 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3250 				 vlan, "vlan");
3251 cmdline_parse_token_string_t cmd_vlan_offload_set =
3252 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3253 				 set, "set");
3254 cmdline_parse_token_string_t cmd_vlan_offload_what =
3255 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3256 				 what, "strip#filter#qinq#stripq");
3257 cmdline_parse_token_string_t cmd_vlan_offload_on =
3258 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3259 			      on, "on#off");
3260 cmdline_parse_token_string_t cmd_vlan_offload_portid =
3261 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3262 			      port_id, NULL);
3263 
3264 cmdline_parse_inst_t cmd_vlan_offload = {
3265 	.f = cmd_vlan_offload_parsed,
3266 	.data = NULL,
3267 	.help_str = "vlan set strip|filter|qinq|stripq on|off "
3268 		"<port_id[,queue_id]>: "
3269 		"Filter/Strip for rx side qinq(extended) for both rx/tx sides",
3270 	.tokens = {
3271 		(void *)&cmd_vlan_offload_vlan,
3272 		(void *)&cmd_vlan_offload_set,
3273 		(void *)&cmd_vlan_offload_what,
3274 		(void *)&cmd_vlan_offload_on,
3275 		(void *)&cmd_vlan_offload_portid,
3276 		NULL,
3277 	},
3278 };
3279 
3280 /* *** VLAN TPID SET ON A PORT *** */
3281 struct cmd_vlan_tpid_result {
3282 	cmdline_fixed_string_t vlan;
3283 	cmdline_fixed_string_t set;
3284 	cmdline_fixed_string_t vlan_type;
3285 	cmdline_fixed_string_t what;
3286 	uint16_t tp_id;
3287 	portid_t port_id;
3288 };
3289 
3290 static void
3291 cmd_vlan_tpid_parsed(void *parsed_result,
3292 			  __attribute__((unused)) struct cmdline *cl,
3293 			  __attribute__((unused)) void *data)
3294 {
3295 	struct cmd_vlan_tpid_result *res = parsed_result;
3296 	enum rte_vlan_type vlan_type;
3297 
3298 	if (!strcmp(res->vlan_type, "inner"))
3299 		vlan_type = ETH_VLAN_TYPE_INNER;
3300 	else if (!strcmp(res->vlan_type, "outer"))
3301 		vlan_type = ETH_VLAN_TYPE_OUTER;
3302 	else {
3303 		printf("Unknown vlan type\n");
3304 		return;
3305 	}
3306 	vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
3307 }
3308 
3309 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
3310 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3311 				 vlan, "vlan");
3312 cmdline_parse_token_string_t cmd_vlan_tpid_set =
3313 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3314 				 set, "set");
3315 cmdline_parse_token_string_t cmd_vlan_type =
3316 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3317 				 vlan_type, "inner#outer");
3318 cmdline_parse_token_string_t cmd_vlan_tpid_what =
3319 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3320 				 what, "tpid");
3321 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
3322 	TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3323 			      tp_id, UINT16);
3324 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
3325 	TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3326 			      port_id, UINT16);
3327 
3328 cmdline_parse_inst_t cmd_vlan_tpid = {
3329 	.f = cmd_vlan_tpid_parsed,
3330 	.data = NULL,
3331 	.help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
3332 		"Set the VLAN Ether type",
3333 	.tokens = {
3334 		(void *)&cmd_vlan_tpid_vlan,
3335 		(void *)&cmd_vlan_tpid_set,
3336 		(void *)&cmd_vlan_type,
3337 		(void *)&cmd_vlan_tpid_what,
3338 		(void *)&cmd_vlan_tpid_tpid,
3339 		(void *)&cmd_vlan_tpid_portid,
3340 		NULL,
3341 	},
3342 };
3343 
3344 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
3345 struct cmd_rx_vlan_filter_result {
3346 	cmdline_fixed_string_t rx_vlan;
3347 	cmdline_fixed_string_t what;
3348 	uint16_t vlan_id;
3349 	portid_t port_id;
3350 };
3351 
3352 static void
3353 cmd_rx_vlan_filter_parsed(void *parsed_result,
3354 			  __attribute__((unused)) struct cmdline *cl,
3355 			  __attribute__((unused)) void *data)
3356 {
3357 	struct cmd_rx_vlan_filter_result *res = parsed_result;
3358 
3359 	if (!strcmp(res->what, "add"))
3360 		rx_vft_set(res->port_id, res->vlan_id, 1);
3361 	else
3362 		rx_vft_set(res->port_id, res->vlan_id, 0);
3363 }
3364 
3365 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
3366 	TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3367 				 rx_vlan, "rx_vlan");
3368 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
3369 	TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3370 				 what, "add#rm");
3371 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
3372 	TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3373 			      vlan_id, UINT16);
3374 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
3375 	TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3376 			      port_id, UINT16);
3377 
3378 cmdline_parse_inst_t cmd_rx_vlan_filter = {
3379 	.f = cmd_rx_vlan_filter_parsed,
3380 	.data = NULL,
3381 	.help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
3382 		"Add/Remove a VLAN identifier to/from the set of VLAN "
3383 		"identifiers filtered by a port",
3384 	.tokens = {
3385 		(void *)&cmd_rx_vlan_filter_rx_vlan,
3386 		(void *)&cmd_rx_vlan_filter_what,
3387 		(void *)&cmd_rx_vlan_filter_vlanid,
3388 		(void *)&cmd_rx_vlan_filter_portid,
3389 		NULL,
3390 	},
3391 };
3392 
3393 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3394 struct cmd_tx_vlan_set_result {
3395 	cmdline_fixed_string_t tx_vlan;
3396 	cmdline_fixed_string_t set;
3397 	portid_t port_id;
3398 	uint16_t vlan_id;
3399 };
3400 
3401 static void
3402 cmd_tx_vlan_set_parsed(void *parsed_result,
3403 		       __attribute__((unused)) struct cmdline *cl,
3404 		       __attribute__((unused)) void *data)
3405 {
3406 	struct cmd_tx_vlan_set_result *res = parsed_result;
3407 
3408 	if (!port_is_stopped(res->port_id)) {
3409 		printf("Please stop port %d first\n", res->port_id);
3410 		return;
3411 	}
3412 
3413 	tx_vlan_set(res->port_id, res->vlan_id);
3414 
3415 	cmd_reconfig_device_queue(res->port_id, 1, 1);
3416 }
3417 
3418 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
3419 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3420 				 tx_vlan, "tx_vlan");
3421 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
3422 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3423 				 set, "set");
3424 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
3425 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3426 			      port_id, UINT16);
3427 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
3428 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3429 			      vlan_id, UINT16);
3430 
3431 cmdline_parse_inst_t cmd_tx_vlan_set = {
3432 	.f = cmd_tx_vlan_set_parsed,
3433 	.data = NULL,
3434 	.help_str = "tx_vlan set <port_id> <vlan_id>: "
3435 		"Enable hardware insertion of a single VLAN header "
3436 		"with a given TAG Identifier in packets sent on a port",
3437 	.tokens = {
3438 		(void *)&cmd_tx_vlan_set_tx_vlan,
3439 		(void *)&cmd_tx_vlan_set_set,
3440 		(void *)&cmd_tx_vlan_set_portid,
3441 		(void *)&cmd_tx_vlan_set_vlanid,
3442 		NULL,
3443 	},
3444 };
3445 
3446 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
3447 struct cmd_tx_vlan_set_qinq_result {
3448 	cmdline_fixed_string_t tx_vlan;
3449 	cmdline_fixed_string_t set;
3450 	portid_t port_id;
3451 	uint16_t vlan_id;
3452 	uint16_t vlan_id_outer;
3453 };
3454 
3455 static void
3456 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
3457 			    __attribute__((unused)) struct cmdline *cl,
3458 			    __attribute__((unused)) void *data)
3459 {
3460 	struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
3461 
3462 	if (!port_is_stopped(res->port_id)) {
3463 		printf("Please stop port %d first\n", res->port_id);
3464 		return;
3465 	}
3466 
3467 	tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
3468 
3469 	cmd_reconfig_device_queue(res->port_id, 1, 1);
3470 }
3471 
3472 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
3473 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3474 		tx_vlan, "tx_vlan");
3475 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
3476 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3477 		set, "set");
3478 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
3479 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3480 		port_id, UINT16);
3481 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
3482 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3483 		vlan_id, UINT16);
3484 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
3485 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3486 		vlan_id_outer, UINT16);
3487 
3488 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
3489 	.f = cmd_tx_vlan_set_qinq_parsed,
3490 	.data = NULL,
3491 	.help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
3492 		"Enable hardware insertion of double VLAN header "
3493 		"with given TAG Identifiers in packets sent on a port",
3494 	.tokens = {
3495 		(void *)&cmd_tx_vlan_set_qinq_tx_vlan,
3496 		(void *)&cmd_tx_vlan_set_qinq_set,
3497 		(void *)&cmd_tx_vlan_set_qinq_portid,
3498 		(void *)&cmd_tx_vlan_set_qinq_vlanid,
3499 		(void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
3500 		NULL,
3501 	},
3502 };
3503 
3504 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
3505 struct cmd_tx_vlan_set_pvid_result {
3506 	cmdline_fixed_string_t tx_vlan;
3507 	cmdline_fixed_string_t set;
3508 	cmdline_fixed_string_t pvid;
3509 	portid_t port_id;
3510 	uint16_t vlan_id;
3511 	cmdline_fixed_string_t mode;
3512 };
3513 
3514 static void
3515 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
3516 			    __attribute__((unused)) struct cmdline *cl,
3517 			    __attribute__((unused)) void *data)
3518 {
3519 	struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
3520 
3521 	if (strcmp(res->mode, "on") == 0)
3522 		tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
3523 	else
3524 		tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
3525 }
3526 
3527 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
3528 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3529 				 tx_vlan, "tx_vlan");
3530 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
3531 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3532 				 set, "set");
3533 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
3534 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3535 				 pvid, "pvid");
3536 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
3537 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3538 			     port_id, UINT16);
3539 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
3540 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3541 			      vlan_id, UINT16);
3542 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
3543 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3544 				 mode, "on#off");
3545 
3546 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
3547 	.f = cmd_tx_vlan_set_pvid_parsed,
3548 	.data = NULL,
3549 	.help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
3550 	.tokens = {
3551 		(void *)&cmd_tx_vlan_set_pvid_tx_vlan,
3552 		(void *)&cmd_tx_vlan_set_pvid_set,
3553 		(void *)&cmd_tx_vlan_set_pvid_pvid,
3554 		(void *)&cmd_tx_vlan_set_pvid_port_id,
3555 		(void *)&cmd_tx_vlan_set_pvid_vlan_id,
3556 		(void *)&cmd_tx_vlan_set_pvid_mode,
3557 		NULL,
3558 	},
3559 };
3560 
3561 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3562 struct cmd_tx_vlan_reset_result {
3563 	cmdline_fixed_string_t tx_vlan;
3564 	cmdline_fixed_string_t reset;
3565 	portid_t port_id;
3566 };
3567 
3568 static void
3569 cmd_tx_vlan_reset_parsed(void *parsed_result,
3570 			 __attribute__((unused)) struct cmdline *cl,
3571 			 __attribute__((unused)) void *data)
3572 {
3573 	struct cmd_tx_vlan_reset_result *res = parsed_result;
3574 
3575 	if (!port_is_stopped(res->port_id)) {
3576 		printf("Please stop port %d first\n", res->port_id);
3577 		return;
3578 	}
3579 
3580 	tx_vlan_reset(res->port_id);
3581 
3582 	cmd_reconfig_device_queue(res->port_id, 1, 1);
3583 }
3584 
3585 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
3586 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3587 				 tx_vlan, "tx_vlan");
3588 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
3589 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3590 				 reset, "reset");
3591 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
3592 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
3593 			      port_id, UINT16);
3594 
3595 cmdline_parse_inst_t cmd_tx_vlan_reset = {
3596 	.f = cmd_tx_vlan_reset_parsed,
3597 	.data = NULL,
3598 	.help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
3599 		"VLAN header in packets sent on a port",
3600 	.tokens = {
3601 		(void *)&cmd_tx_vlan_reset_tx_vlan,
3602 		(void *)&cmd_tx_vlan_reset_reset,
3603 		(void *)&cmd_tx_vlan_reset_portid,
3604 		NULL,
3605 	},
3606 };
3607 
3608 
3609 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
3610 struct cmd_csum_result {
3611 	cmdline_fixed_string_t csum;
3612 	cmdline_fixed_string_t mode;
3613 	cmdline_fixed_string_t proto;
3614 	cmdline_fixed_string_t hwsw;
3615 	portid_t port_id;
3616 };
3617 
3618 static void
3619 csum_show(int port_id)
3620 {
3621 	struct rte_eth_dev_info dev_info;
3622 	uint64_t tx_offloads;
3623 
3624 	tx_offloads = ports[port_id].dev_conf.txmode.offloads;
3625 	printf("Parse tunnel is %s\n",
3626 		(ports[port_id].parse_tunnel) ? "on" : "off");
3627 	printf("IP checksum offload is %s\n",
3628 		(tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
3629 	printf("UDP checksum offload is %s\n",
3630 		(tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
3631 	printf("TCP checksum offload is %s\n",
3632 		(tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
3633 	printf("SCTP checksum offload is %s\n",
3634 		(tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
3635 	printf("Outer-Ip checksum offload is %s\n",
3636 		(tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
3637 
3638 	/* display warnings if configuration is not supported by the NIC */
3639 	rte_eth_dev_info_get(port_id, &dev_info);
3640 	if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
3641 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
3642 		printf("Warning: hardware IP checksum enabled but not "
3643 			"supported by port %d\n", port_id);
3644 	}
3645 	if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
3646 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
3647 		printf("Warning: hardware UDP checksum enabled but not "
3648 			"supported by port %d\n", port_id);
3649 	}
3650 	if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
3651 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
3652 		printf("Warning: hardware TCP checksum enabled but not "
3653 			"supported by port %d\n", port_id);
3654 	}
3655 	if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
3656 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
3657 		printf("Warning: hardware SCTP checksum enabled but not "
3658 			"supported by port %d\n", port_id);
3659 	}
3660 	if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
3661 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
3662 		printf("Warning: hardware outer IP checksum enabled but not "
3663 			"supported by port %d\n", port_id);
3664 	}
3665 }
3666 
3667 static void
3668 cmd_csum_parsed(void *parsed_result,
3669 		       __attribute__((unused)) struct cmdline *cl,
3670 		       __attribute__((unused)) void *data)
3671 {
3672 	struct cmd_csum_result *res = parsed_result;
3673 	int hw = 0;
3674 	uint64_t csum_offloads = 0;
3675 	struct rte_eth_dev_info dev_info;
3676 
3677 	if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
3678 		printf("invalid port %d\n", res->port_id);
3679 		return;
3680 	}
3681 	if (!port_is_stopped(res->port_id)) {
3682 		printf("Please stop port %d first\n", res->port_id);
3683 		return;
3684 	}
3685 
3686 	rte_eth_dev_info_get(res->port_id, &dev_info);
3687 	if (!strcmp(res->mode, "set")) {
3688 
3689 		if (!strcmp(res->hwsw, "hw"))
3690 			hw = 1;
3691 
3692 		if (!strcmp(res->proto, "ip")) {
3693 			if (dev_info.tx_offload_capa &
3694 						DEV_TX_OFFLOAD_IPV4_CKSUM) {
3695 				csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
3696 			} else {
3697 				printf("IP checksum offload is not supported "
3698 				       "by port %u\n", res->port_id);
3699 			}
3700 		} else if (!strcmp(res->proto, "udp")) {
3701 			if (dev_info.tx_offload_capa &
3702 						DEV_TX_OFFLOAD_UDP_CKSUM) {
3703 				csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
3704 			} else {
3705 				printf("UDP checksum offload is not supported "
3706 				       "by port %u\n", res->port_id);
3707 			}
3708 		} else if (!strcmp(res->proto, "tcp")) {
3709 			if (dev_info.tx_offload_capa &
3710 						DEV_TX_OFFLOAD_TCP_CKSUM) {
3711 				csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
3712 			} else {
3713 				printf("TCP checksum offload is not supported "
3714 				       "by port %u\n", res->port_id);
3715 			}
3716 		} else if (!strcmp(res->proto, "sctp")) {
3717 			if (dev_info.tx_offload_capa &
3718 						DEV_TX_OFFLOAD_SCTP_CKSUM) {
3719 				csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
3720 			} else {
3721 				printf("SCTP checksum offload is not supported "
3722 				       "by port %u\n", res->port_id);
3723 			}
3724 		} else if (!strcmp(res->proto, "outer-ip")) {
3725 			if (dev_info.tx_offload_capa &
3726 					DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) {
3727 				csum_offloads |=
3728 						DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
3729 			} else {
3730 				printf("Outer IP checksum offload is not "
3731 				       "supported by port %u\n", res->port_id);
3732 			}
3733 		}
3734 
3735 		if (hw) {
3736 			ports[res->port_id].dev_conf.txmode.offloads |=
3737 							csum_offloads;
3738 		} else {
3739 			ports[res->port_id].dev_conf.txmode.offloads &=
3740 							(~csum_offloads);
3741 		}
3742 	}
3743 	csum_show(res->port_id);
3744 
3745 	cmd_reconfig_device_queue(res->port_id, 1, 1);
3746 }
3747 
3748 cmdline_parse_token_string_t cmd_csum_csum =
3749 	TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3750 				csum, "csum");
3751 cmdline_parse_token_string_t cmd_csum_mode =
3752 	TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3753 				mode, "set");
3754 cmdline_parse_token_string_t cmd_csum_proto =
3755 	TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3756 				proto, "ip#tcp#udp#sctp#outer-ip");
3757 cmdline_parse_token_string_t cmd_csum_hwsw =
3758 	TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3759 				hwsw, "hw#sw");
3760 cmdline_parse_token_num_t cmd_csum_portid =
3761 	TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
3762 				port_id, UINT16);
3763 
3764 cmdline_parse_inst_t cmd_csum_set = {
3765 	.f = cmd_csum_parsed,
3766 	.data = NULL,
3767 	.help_str = "csum set ip|tcp|udp|sctp|outer-ip hw|sw <port_id>: "
3768 		"Enable/Disable hardware calculation of L3/L4 checksum when "
3769 		"using csum forward engine",
3770 	.tokens = {
3771 		(void *)&cmd_csum_csum,
3772 		(void *)&cmd_csum_mode,
3773 		(void *)&cmd_csum_proto,
3774 		(void *)&cmd_csum_hwsw,
3775 		(void *)&cmd_csum_portid,
3776 		NULL,
3777 	},
3778 };
3779 
3780 cmdline_parse_token_string_t cmd_csum_mode_show =
3781 	TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3782 				mode, "show");
3783 
3784 cmdline_parse_inst_t cmd_csum_show = {
3785 	.f = cmd_csum_parsed,
3786 	.data = NULL,
3787 	.help_str = "csum show <port_id>: Show checksum offload configuration",
3788 	.tokens = {
3789 		(void *)&cmd_csum_csum,
3790 		(void *)&cmd_csum_mode_show,
3791 		(void *)&cmd_csum_portid,
3792 		NULL,
3793 	},
3794 };
3795 
3796 /* Enable/disable tunnel parsing */
3797 struct cmd_csum_tunnel_result {
3798 	cmdline_fixed_string_t csum;
3799 	cmdline_fixed_string_t parse;
3800 	cmdline_fixed_string_t onoff;
3801 	portid_t port_id;
3802 };
3803 
3804 static void
3805 cmd_csum_tunnel_parsed(void *parsed_result,
3806 		       __attribute__((unused)) struct cmdline *cl,
3807 		       __attribute__((unused)) void *data)
3808 {
3809 	struct cmd_csum_tunnel_result *res = parsed_result;
3810 
3811 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3812 		return;
3813 
3814 	if (!strcmp(res->onoff, "on"))
3815 		ports[res->port_id].parse_tunnel = 1;
3816 	else
3817 		ports[res->port_id].parse_tunnel = 0;
3818 
3819 	csum_show(res->port_id);
3820 }
3821 
3822 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
3823 	TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3824 				csum, "csum");
3825 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
3826 	TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3827 				parse, "parse_tunnel");
3828 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
3829 	TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3830 				onoff, "on#off");
3831 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
3832 	TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
3833 				port_id, UINT16);
3834 
3835 cmdline_parse_inst_t cmd_csum_tunnel = {
3836 	.f = cmd_csum_tunnel_parsed,
3837 	.data = NULL,
3838 	.help_str = "csum parse_tunnel on|off <port_id>: "
3839 		"Enable/Disable parsing of tunnels for csum engine",
3840 	.tokens = {
3841 		(void *)&cmd_csum_tunnel_csum,
3842 		(void *)&cmd_csum_tunnel_parse,
3843 		(void *)&cmd_csum_tunnel_onoff,
3844 		(void *)&cmd_csum_tunnel_portid,
3845 		NULL,
3846 	},
3847 };
3848 
3849 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
3850 struct cmd_tso_set_result {
3851 	cmdline_fixed_string_t tso;
3852 	cmdline_fixed_string_t mode;
3853 	uint16_t tso_segsz;
3854 	portid_t port_id;
3855 };
3856 
3857 static void
3858 cmd_tso_set_parsed(void *parsed_result,
3859 		       __attribute__((unused)) struct cmdline *cl,
3860 		       __attribute__((unused)) void *data)
3861 {
3862 	struct cmd_tso_set_result *res = parsed_result;
3863 	struct rte_eth_dev_info dev_info;
3864 
3865 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3866 		return;
3867 	if (!port_is_stopped(res->port_id)) {
3868 		printf("Please stop port %d first\n", res->port_id);
3869 		return;
3870 	}
3871 
3872 	if (!strcmp(res->mode, "set"))
3873 		ports[res->port_id].tso_segsz = res->tso_segsz;
3874 
3875 	rte_eth_dev_info_get(res->port_id, &dev_info);
3876 	if ((ports[res->port_id].tso_segsz != 0) &&
3877 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3878 		printf("Error: TSO is not supported by port %d\n",
3879 		       res->port_id);
3880 		return;
3881 	}
3882 
3883 	if (ports[res->port_id].tso_segsz == 0) {
3884 		ports[res->port_id].dev_conf.txmode.offloads &=
3885 						~DEV_TX_OFFLOAD_TCP_TSO;
3886 		printf("TSO for non-tunneled packets is disabled\n");
3887 	} else {
3888 		ports[res->port_id].dev_conf.txmode.offloads |=
3889 						DEV_TX_OFFLOAD_TCP_TSO;
3890 		printf("TSO segment size for non-tunneled packets is %d\n",
3891 			ports[res->port_id].tso_segsz);
3892 	}
3893 
3894 	/* display warnings if configuration is not supported by the NIC */
3895 	rte_eth_dev_info_get(res->port_id, &dev_info);
3896 	if ((ports[res->port_id].tso_segsz != 0) &&
3897 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3898 		printf("Warning: TSO enabled but not "
3899 			"supported by port %d\n", res->port_id);
3900 	}
3901 
3902 	cmd_reconfig_device_queue(res->port_id, 1, 1);
3903 }
3904 
3905 cmdline_parse_token_string_t cmd_tso_set_tso =
3906 	TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3907 				tso, "tso");
3908 cmdline_parse_token_string_t cmd_tso_set_mode =
3909 	TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3910 				mode, "set");
3911 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
3912 	TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3913 				tso_segsz, UINT16);
3914 cmdline_parse_token_num_t cmd_tso_set_portid =
3915 	TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3916 				port_id, UINT16);
3917 
3918 cmdline_parse_inst_t cmd_tso_set = {
3919 	.f = cmd_tso_set_parsed,
3920 	.data = NULL,
3921 	.help_str = "tso set <tso_segsz> <port_id>: "
3922 		"Set TSO segment size of non-tunneled packets for csum engine "
3923 		"(0 to disable)",
3924 	.tokens = {
3925 		(void *)&cmd_tso_set_tso,
3926 		(void *)&cmd_tso_set_mode,
3927 		(void *)&cmd_tso_set_tso_segsz,
3928 		(void *)&cmd_tso_set_portid,
3929 		NULL,
3930 	},
3931 };
3932 
3933 cmdline_parse_token_string_t cmd_tso_show_mode =
3934 	TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3935 				mode, "show");
3936 
3937 
3938 cmdline_parse_inst_t cmd_tso_show = {
3939 	.f = cmd_tso_set_parsed,
3940 	.data = NULL,
3941 	.help_str = "tso show <port_id>: "
3942 		"Show TSO segment size of non-tunneled packets for csum engine",
3943 	.tokens = {
3944 		(void *)&cmd_tso_set_tso,
3945 		(void *)&cmd_tso_show_mode,
3946 		(void *)&cmd_tso_set_portid,
3947 		NULL,
3948 	},
3949 };
3950 
3951 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
3952 struct cmd_tunnel_tso_set_result {
3953 	cmdline_fixed_string_t tso;
3954 	cmdline_fixed_string_t mode;
3955 	uint16_t tso_segsz;
3956 	portid_t port_id;
3957 };
3958 
3959 static struct rte_eth_dev_info
3960 check_tunnel_tso_nic_support(portid_t port_id)
3961 {
3962 	struct rte_eth_dev_info dev_info;
3963 
3964 	rte_eth_dev_info_get(port_id, &dev_info);
3965 	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
3966 		printf("Warning: VXLAN TUNNEL TSO not supported therefore "
3967 		       "not enabled for port %d\n", port_id);
3968 	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
3969 		printf("Warning: GRE TUNNEL TSO	not supported therefore "
3970 		       "not enabled for port %d\n", port_id);
3971 	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
3972 		printf("Warning: IPIP TUNNEL TSO not supported therefore "
3973 		       "not enabled for port %d\n", port_id);
3974 	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
3975 		printf("Warning: GENEVE TUNNEL TSO not supported therefore "
3976 		       "not enabled for port %d\n", port_id);
3977 	return dev_info;
3978 }
3979 
3980 static void
3981 cmd_tunnel_tso_set_parsed(void *parsed_result,
3982 			  __attribute__((unused)) struct cmdline *cl,
3983 			  __attribute__((unused)) void *data)
3984 {
3985 	struct cmd_tunnel_tso_set_result *res = parsed_result;
3986 	struct rte_eth_dev_info dev_info;
3987 
3988 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3989 		return;
3990 	if (!port_is_stopped(res->port_id)) {
3991 		printf("Please stop port %d first\n", res->port_id);
3992 		return;
3993 	}
3994 
3995 	if (!strcmp(res->mode, "set"))
3996 		ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
3997 
3998 	dev_info = check_tunnel_tso_nic_support(res->port_id);
3999 	if (ports[res->port_id].tunnel_tso_segsz == 0) {
4000 		ports[res->port_id].dev_conf.txmode.offloads &=
4001 			~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4002 			  DEV_TX_OFFLOAD_GRE_TNL_TSO |
4003 			  DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4004 			  DEV_TX_OFFLOAD_GENEVE_TNL_TSO);
4005 		printf("TSO for tunneled packets is disabled\n");
4006 	} else {
4007 		uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4008 					 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4009 					 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4010 					 DEV_TX_OFFLOAD_GENEVE_TNL_TSO);
4011 
4012 		ports[res->port_id].dev_conf.txmode.offloads |=
4013 			(tso_offloads & dev_info.tx_offload_capa);
4014 		printf("TSO segment size for tunneled packets is %d\n",
4015 			ports[res->port_id].tunnel_tso_segsz);
4016 
4017 		/* Below conditions are needed to make it work:
4018 		 * (1) tunnel TSO is supported by the NIC;
4019 		 * (2) "csum parse_tunnel" must be set so that tunneled pkts
4020 		 * are recognized;
4021 		 * (3) for tunneled pkts with outer L3 of IPv4,
4022 		 * "csum set outer-ip" must be set to hw, because after tso,
4023 		 * total_len of outer IP header is changed, and the checksum
4024 		 * of outer IP header calculated by sw should be wrong; that
4025 		 * is not necessary for IPv6 tunneled pkts because there's no
4026 		 * checksum in IP header anymore.
4027 		 */
4028 
4029 		if (!ports[res->port_id].parse_tunnel)
4030 			printf("Warning: csum parse_tunnel must be set "
4031 				"so that tunneled packets are recognized\n");
4032 		if (!(ports[res->port_id].dev_conf.txmode.offloads &
4033 		      DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
4034 			printf("Warning: csum set outer-ip must be set to hw "
4035 				"if outer L3 is IPv4; not necessary for IPv6\n");
4036 	}
4037 
4038 	cmd_reconfig_device_queue(res->port_id, 1, 1);
4039 }
4040 
4041 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
4042 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4043 				tso, "tunnel_tso");
4044 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
4045 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4046 				mode, "set");
4047 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
4048 	TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4049 				tso_segsz, UINT16);
4050 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
4051 	TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4052 				port_id, UINT16);
4053 
4054 cmdline_parse_inst_t cmd_tunnel_tso_set = {
4055 	.f = cmd_tunnel_tso_set_parsed,
4056 	.data = NULL,
4057 	.help_str = "tunnel_tso set <tso_segsz> <port_id>: "
4058 		"Set TSO segment size of tunneled packets for csum engine "
4059 		"(0 to disable)",
4060 	.tokens = {
4061 		(void *)&cmd_tunnel_tso_set_tso,
4062 		(void *)&cmd_tunnel_tso_set_mode,
4063 		(void *)&cmd_tunnel_tso_set_tso_segsz,
4064 		(void *)&cmd_tunnel_tso_set_portid,
4065 		NULL,
4066 	},
4067 };
4068 
4069 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
4070 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4071 				mode, "show");
4072 
4073 
4074 cmdline_parse_inst_t cmd_tunnel_tso_show = {
4075 	.f = cmd_tunnel_tso_set_parsed,
4076 	.data = NULL,
4077 	.help_str = "tunnel_tso show <port_id> "
4078 		"Show TSO segment size of tunneled packets for csum engine",
4079 	.tokens = {
4080 		(void *)&cmd_tunnel_tso_set_tso,
4081 		(void *)&cmd_tunnel_tso_show_mode,
4082 		(void *)&cmd_tunnel_tso_set_portid,
4083 		NULL,
4084 	},
4085 };
4086 
4087 /* *** SET GRO FOR A PORT *** */
4088 struct cmd_gro_enable_result {
4089 	cmdline_fixed_string_t cmd_set;
4090 	cmdline_fixed_string_t cmd_port;
4091 	cmdline_fixed_string_t cmd_keyword;
4092 	cmdline_fixed_string_t cmd_onoff;
4093 	portid_t cmd_pid;
4094 };
4095 
4096 static void
4097 cmd_gro_enable_parsed(void *parsed_result,
4098 		__attribute__((unused)) struct cmdline *cl,
4099 		__attribute__((unused)) void *data)
4100 {
4101 	struct cmd_gro_enable_result *res;
4102 
4103 	res = parsed_result;
4104 	if (!strcmp(res->cmd_keyword, "gro"))
4105 		setup_gro(res->cmd_onoff, res->cmd_pid);
4106 }
4107 
4108 cmdline_parse_token_string_t cmd_gro_enable_set =
4109 	TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4110 			cmd_set, "set");
4111 cmdline_parse_token_string_t cmd_gro_enable_port =
4112 	TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4113 			cmd_keyword, "port");
4114 cmdline_parse_token_num_t cmd_gro_enable_pid =
4115 	TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
4116 			cmd_pid, UINT16);
4117 cmdline_parse_token_string_t cmd_gro_enable_keyword =
4118 	TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4119 			cmd_keyword, "gro");
4120 cmdline_parse_token_string_t cmd_gro_enable_onoff =
4121 	TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4122 			cmd_onoff, "on#off");
4123 
4124 cmdline_parse_inst_t cmd_gro_enable = {
4125 	.f = cmd_gro_enable_parsed,
4126 	.data = NULL,
4127 	.help_str = "set port <port_id> gro on|off",
4128 	.tokens = {
4129 		(void *)&cmd_gro_enable_set,
4130 		(void *)&cmd_gro_enable_port,
4131 		(void *)&cmd_gro_enable_pid,
4132 		(void *)&cmd_gro_enable_keyword,
4133 		(void *)&cmd_gro_enable_onoff,
4134 		NULL,
4135 	},
4136 };
4137 
4138 /* *** DISPLAY GRO CONFIGURATION *** */
4139 struct cmd_gro_show_result {
4140 	cmdline_fixed_string_t cmd_show;
4141 	cmdline_fixed_string_t cmd_port;
4142 	cmdline_fixed_string_t cmd_keyword;
4143 	portid_t cmd_pid;
4144 };
4145 
4146 static void
4147 cmd_gro_show_parsed(void *parsed_result,
4148 		__attribute__((unused)) struct cmdline *cl,
4149 		__attribute__((unused)) void *data)
4150 {
4151 	struct cmd_gro_show_result *res;
4152 
4153 	res = parsed_result;
4154 	if (!strcmp(res->cmd_keyword, "gro"))
4155 		show_gro(res->cmd_pid);
4156 }
4157 
4158 cmdline_parse_token_string_t cmd_gro_show_show =
4159 	TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4160 			cmd_show, "show");
4161 cmdline_parse_token_string_t cmd_gro_show_port =
4162 	TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4163 			cmd_port, "port");
4164 cmdline_parse_token_num_t cmd_gro_show_pid =
4165 	TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
4166 			cmd_pid, UINT16);
4167 cmdline_parse_token_string_t cmd_gro_show_keyword =
4168 	TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4169 			cmd_keyword, "gro");
4170 
4171 cmdline_parse_inst_t cmd_gro_show = {
4172 	.f = cmd_gro_show_parsed,
4173 	.data = NULL,
4174 	.help_str = "show port <port_id> gro",
4175 	.tokens = {
4176 		(void *)&cmd_gro_show_show,
4177 		(void *)&cmd_gro_show_port,
4178 		(void *)&cmd_gro_show_pid,
4179 		(void *)&cmd_gro_show_keyword,
4180 		NULL,
4181 	},
4182 };
4183 
4184 /* *** SET FLUSH CYCLES FOR GRO *** */
4185 struct cmd_gro_flush_result {
4186 	cmdline_fixed_string_t cmd_set;
4187 	cmdline_fixed_string_t cmd_keyword;
4188 	cmdline_fixed_string_t cmd_flush;
4189 	uint8_t cmd_cycles;
4190 };
4191 
4192 static void
4193 cmd_gro_flush_parsed(void *parsed_result,
4194 		__attribute__((unused)) struct cmdline *cl,
4195 		__attribute__((unused)) void *data)
4196 {
4197 	struct cmd_gro_flush_result *res;
4198 
4199 	res = parsed_result;
4200 	if ((!strcmp(res->cmd_keyword, "gro")) &&
4201 			(!strcmp(res->cmd_flush, "flush")))
4202 		setup_gro_flush_cycles(res->cmd_cycles);
4203 }
4204 
4205 cmdline_parse_token_string_t cmd_gro_flush_set =
4206 	TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4207 			cmd_set, "set");
4208 cmdline_parse_token_string_t cmd_gro_flush_keyword =
4209 	TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4210 			cmd_keyword, "gro");
4211 cmdline_parse_token_string_t cmd_gro_flush_flush =
4212 	TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4213 			cmd_flush, "flush");
4214 cmdline_parse_token_num_t cmd_gro_flush_cycles =
4215 	TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
4216 			cmd_cycles, UINT8);
4217 
4218 cmdline_parse_inst_t cmd_gro_flush = {
4219 	.f = cmd_gro_flush_parsed,
4220 	.data = NULL,
4221 	.help_str = "set gro flush <cycles>",
4222 	.tokens = {
4223 		(void *)&cmd_gro_flush_set,
4224 		(void *)&cmd_gro_flush_keyword,
4225 		(void *)&cmd_gro_flush_flush,
4226 		(void *)&cmd_gro_flush_cycles,
4227 		NULL,
4228 	},
4229 };
4230 
4231 /* *** ENABLE/DISABLE GSO *** */
4232 struct cmd_gso_enable_result {
4233 	cmdline_fixed_string_t cmd_set;
4234 	cmdline_fixed_string_t cmd_port;
4235 	cmdline_fixed_string_t cmd_keyword;
4236 	cmdline_fixed_string_t cmd_mode;
4237 	portid_t cmd_pid;
4238 };
4239 
4240 static void
4241 cmd_gso_enable_parsed(void *parsed_result,
4242 		__attribute__((unused)) struct cmdline *cl,
4243 		__attribute__((unused)) void *data)
4244 {
4245 	struct cmd_gso_enable_result *res;
4246 
4247 	res = parsed_result;
4248 	if (!strcmp(res->cmd_keyword, "gso"))
4249 		setup_gso(res->cmd_mode, res->cmd_pid);
4250 }
4251 
4252 cmdline_parse_token_string_t cmd_gso_enable_set =
4253 	TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4254 			cmd_set, "set");
4255 cmdline_parse_token_string_t cmd_gso_enable_port =
4256 	TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4257 			cmd_port, "port");
4258 cmdline_parse_token_string_t cmd_gso_enable_keyword =
4259 	TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4260 			cmd_keyword, "gso");
4261 cmdline_parse_token_string_t cmd_gso_enable_mode =
4262 	TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4263 			cmd_mode, "on#off");
4264 cmdline_parse_token_num_t cmd_gso_enable_pid =
4265 	TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
4266 			cmd_pid, UINT16);
4267 
4268 cmdline_parse_inst_t cmd_gso_enable = {
4269 	.f = cmd_gso_enable_parsed,
4270 	.data = NULL,
4271 	.help_str = "set port <port_id> gso on|off",
4272 	.tokens = {
4273 		(void *)&cmd_gso_enable_set,
4274 		(void *)&cmd_gso_enable_port,
4275 		(void *)&cmd_gso_enable_pid,
4276 		(void *)&cmd_gso_enable_keyword,
4277 		(void *)&cmd_gso_enable_mode,
4278 		NULL,
4279 	},
4280 };
4281 
4282 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
4283 struct cmd_gso_size_result {
4284 	cmdline_fixed_string_t cmd_set;
4285 	cmdline_fixed_string_t cmd_keyword;
4286 	cmdline_fixed_string_t cmd_segsz;
4287 	uint16_t cmd_size;
4288 };
4289 
4290 static void
4291 cmd_gso_size_parsed(void *parsed_result,
4292 		       __attribute__((unused)) struct cmdline *cl,
4293 		       __attribute__((unused)) void *data)
4294 {
4295 	struct cmd_gso_size_result *res = parsed_result;
4296 
4297 	if (test_done == 0) {
4298 		printf("Before setting GSO segsz, please first"
4299 				" stop fowarding\n");
4300 		return;
4301 	}
4302 
4303 	if (!strcmp(res->cmd_keyword, "gso") &&
4304 			!strcmp(res->cmd_segsz, "segsz")) {
4305 		if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
4306 			printf("gso_size should be larger than %zu."
4307 					" Please input a legal value\n",
4308 					RTE_GSO_SEG_SIZE_MIN);
4309 		else
4310 			gso_max_segment_size = res->cmd_size;
4311 	}
4312 }
4313 
4314 cmdline_parse_token_string_t cmd_gso_size_set =
4315 	TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4316 				cmd_set, "set");
4317 cmdline_parse_token_string_t cmd_gso_size_keyword =
4318 	TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4319 				cmd_keyword, "gso");
4320 cmdline_parse_token_string_t cmd_gso_size_segsz =
4321 	TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4322 				cmd_segsz, "segsz");
4323 cmdline_parse_token_num_t cmd_gso_size_size =
4324 	TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
4325 				cmd_size, UINT16);
4326 
4327 cmdline_parse_inst_t cmd_gso_size = {
4328 	.f = cmd_gso_size_parsed,
4329 	.data = NULL,
4330 	.help_str = "set gso segsz <length>",
4331 	.tokens = {
4332 		(void *)&cmd_gso_size_set,
4333 		(void *)&cmd_gso_size_keyword,
4334 		(void *)&cmd_gso_size_segsz,
4335 		(void *)&cmd_gso_size_size,
4336 		NULL,
4337 	},
4338 };
4339 
4340 /* *** SHOW GSO CONFIGURATION *** */
4341 struct cmd_gso_show_result {
4342 	cmdline_fixed_string_t cmd_show;
4343 	cmdline_fixed_string_t cmd_port;
4344 	cmdline_fixed_string_t cmd_keyword;
4345 	portid_t cmd_pid;
4346 };
4347 
4348 static void
4349 cmd_gso_show_parsed(void *parsed_result,
4350 		       __attribute__((unused)) struct cmdline *cl,
4351 		       __attribute__((unused)) void *data)
4352 {
4353 	struct cmd_gso_show_result *res = parsed_result;
4354 
4355 	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
4356 		printf("invalid port id %u\n", res->cmd_pid);
4357 		return;
4358 	}
4359 	if (!strcmp(res->cmd_keyword, "gso")) {
4360 		if (gso_ports[res->cmd_pid].enable) {
4361 			printf("Max GSO'd packet size: %uB\n"
4362 					"Supported GSO types: TCP/IPv4, "
4363 					"VxLAN with inner TCP/IPv4 packet, "
4364 					"GRE with inner TCP/IPv4  packet\n",
4365 					gso_max_segment_size);
4366 		} else
4367 			printf("GSO is not enabled on Port %u\n", res->cmd_pid);
4368 	}
4369 }
4370 
4371 cmdline_parse_token_string_t cmd_gso_show_show =
4372 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4373 		cmd_show, "show");
4374 cmdline_parse_token_string_t cmd_gso_show_port =
4375 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4376 		cmd_port, "port");
4377 cmdline_parse_token_string_t cmd_gso_show_keyword =
4378 	TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4379 				cmd_keyword, "gso");
4380 cmdline_parse_token_num_t cmd_gso_show_pid =
4381 	TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
4382 				cmd_pid, UINT16);
4383 
4384 cmdline_parse_inst_t cmd_gso_show = {
4385 	.f = cmd_gso_show_parsed,
4386 	.data = NULL,
4387 	.help_str = "show port <port_id> gso",
4388 	.tokens = {
4389 		(void *)&cmd_gso_show_show,
4390 		(void *)&cmd_gso_show_port,
4391 		(void *)&cmd_gso_show_pid,
4392 		(void *)&cmd_gso_show_keyword,
4393 		NULL,
4394 	},
4395 };
4396 
4397 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
4398 struct cmd_set_flush_rx {
4399 	cmdline_fixed_string_t set;
4400 	cmdline_fixed_string_t flush_rx;
4401 	cmdline_fixed_string_t mode;
4402 };
4403 
4404 static void
4405 cmd_set_flush_rx_parsed(void *parsed_result,
4406 		__attribute__((unused)) struct cmdline *cl,
4407 		__attribute__((unused)) void *data)
4408 {
4409 	struct cmd_set_flush_rx *res = parsed_result;
4410 	no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4411 }
4412 
4413 cmdline_parse_token_string_t cmd_setflushrx_set =
4414 	TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4415 			set, "set");
4416 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
4417 	TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4418 			flush_rx, "flush_rx");
4419 cmdline_parse_token_string_t cmd_setflushrx_mode =
4420 	TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4421 			mode, "on#off");
4422 
4423 
4424 cmdline_parse_inst_t cmd_set_flush_rx = {
4425 	.f = cmd_set_flush_rx_parsed,
4426 	.help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
4427 	.data = NULL,
4428 	.tokens = {
4429 		(void *)&cmd_setflushrx_set,
4430 		(void *)&cmd_setflushrx_flush_rx,
4431 		(void *)&cmd_setflushrx_mode,
4432 		NULL,
4433 	},
4434 };
4435 
4436 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
4437 struct cmd_set_link_check {
4438 	cmdline_fixed_string_t set;
4439 	cmdline_fixed_string_t link_check;
4440 	cmdline_fixed_string_t mode;
4441 };
4442 
4443 static void
4444 cmd_set_link_check_parsed(void *parsed_result,
4445 		__attribute__((unused)) struct cmdline *cl,
4446 		__attribute__((unused)) void *data)
4447 {
4448 	struct cmd_set_link_check *res = parsed_result;
4449 	no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4450 }
4451 
4452 cmdline_parse_token_string_t cmd_setlinkcheck_set =
4453 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4454 			set, "set");
4455 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
4456 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4457 			link_check, "link_check");
4458 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
4459 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4460 			mode, "on#off");
4461 
4462 
4463 cmdline_parse_inst_t cmd_set_link_check = {
4464 	.f = cmd_set_link_check_parsed,
4465 	.help_str = "set link_check on|off: Enable/Disable link status check "
4466 	            "when starting/stopping a port",
4467 	.data = NULL,
4468 	.tokens = {
4469 		(void *)&cmd_setlinkcheck_set,
4470 		(void *)&cmd_setlinkcheck_link_check,
4471 		(void *)&cmd_setlinkcheck_mode,
4472 		NULL,
4473 	},
4474 };
4475 
4476 /* *** SET NIC BYPASS MODE *** */
4477 struct cmd_set_bypass_mode_result {
4478 	cmdline_fixed_string_t set;
4479 	cmdline_fixed_string_t bypass;
4480 	cmdline_fixed_string_t mode;
4481 	cmdline_fixed_string_t value;
4482 	portid_t port_id;
4483 };
4484 
4485 static void
4486 cmd_set_bypass_mode_parsed(void *parsed_result,
4487 		__attribute__((unused)) struct cmdline *cl,
4488 		__attribute__((unused)) void *data)
4489 {
4490 	struct cmd_set_bypass_mode_result *res = parsed_result;
4491 	portid_t port_id = res->port_id;
4492 	int32_t rc = -EINVAL;
4493 
4494 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4495 	uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4496 
4497 	if (!strcmp(res->value, "bypass"))
4498 		bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
4499 	else if (!strcmp(res->value, "isolate"))
4500 		bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
4501 	else
4502 		bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4503 
4504 	/* Set the bypass mode for the relevant port. */
4505 	rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
4506 #endif
4507 	if (rc != 0)
4508 		printf("\t Failed to set bypass mode for port = %d.\n", port_id);
4509 }
4510 
4511 cmdline_parse_token_string_t cmd_setbypass_mode_set =
4512 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4513 			set, "set");
4514 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
4515 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4516 			bypass, "bypass");
4517 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
4518 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4519 			mode, "mode");
4520 cmdline_parse_token_string_t cmd_setbypass_mode_value =
4521 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4522 			value, "normal#bypass#isolate");
4523 cmdline_parse_token_num_t cmd_setbypass_mode_port =
4524 	TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
4525 				port_id, UINT16);
4526 
4527 cmdline_parse_inst_t cmd_set_bypass_mode = {
4528 	.f = cmd_set_bypass_mode_parsed,
4529 	.help_str = "set bypass mode normal|bypass|isolate <port_id>: "
4530 	            "Set the NIC bypass mode for port_id",
4531 	.data = NULL,
4532 	.tokens = {
4533 		(void *)&cmd_setbypass_mode_set,
4534 		(void *)&cmd_setbypass_mode_bypass,
4535 		(void *)&cmd_setbypass_mode_mode,
4536 		(void *)&cmd_setbypass_mode_value,
4537 		(void *)&cmd_setbypass_mode_port,
4538 		NULL,
4539 	},
4540 };
4541 
4542 /* *** SET NIC BYPASS EVENT *** */
4543 struct cmd_set_bypass_event_result {
4544 	cmdline_fixed_string_t set;
4545 	cmdline_fixed_string_t bypass;
4546 	cmdline_fixed_string_t event;
4547 	cmdline_fixed_string_t event_value;
4548 	cmdline_fixed_string_t mode;
4549 	cmdline_fixed_string_t mode_value;
4550 	portid_t port_id;
4551 };
4552 
4553 static void
4554 cmd_set_bypass_event_parsed(void *parsed_result,
4555 		__attribute__((unused)) struct cmdline *cl,
4556 		__attribute__((unused)) void *data)
4557 {
4558 	int32_t rc = -EINVAL;
4559 	struct cmd_set_bypass_event_result *res = parsed_result;
4560 	portid_t port_id = res->port_id;
4561 
4562 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4563 	uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
4564 	uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4565 
4566 	if (!strcmp(res->event_value, "timeout"))
4567 		bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
4568 	else if (!strcmp(res->event_value, "os_on"))
4569 		bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
4570 	else if (!strcmp(res->event_value, "os_off"))
4571 		bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
4572 	else if (!strcmp(res->event_value, "power_on"))
4573 		bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
4574 	else if (!strcmp(res->event_value, "power_off"))
4575 		bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
4576 	else
4577 		bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
4578 
4579 	if (!strcmp(res->mode_value, "bypass"))
4580 		bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
4581 	else if (!strcmp(res->mode_value, "isolate"))
4582 		bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
4583 	else
4584 		bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4585 
4586 	/* Set the watchdog timeout. */
4587 	if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
4588 
4589 		rc = -EINVAL;
4590 		if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
4591 			rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
4592 							   bypass_timeout);
4593 		}
4594 		if (rc != 0) {
4595 			printf("Failed to set timeout value %u "
4596 			"for port %d, errto code: %d.\n",
4597 			bypass_timeout, port_id, rc);
4598 		}
4599 	}
4600 
4601 	/* Set the bypass event to transition to bypass mode. */
4602 	rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
4603 					      bypass_mode);
4604 #endif
4605 
4606 	if (rc != 0)
4607 		printf("\t Failed to set bypass event for port = %d.\n",
4608 		       port_id);
4609 }
4610 
4611 cmdline_parse_token_string_t cmd_setbypass_event_set =
4612 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4613 			set, "set");
4614 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
4615 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4616 			bypass, "bypass");
4617 cmdline_parse_token_string_t cmd_setbypass_event_event =
4618 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4619 			event, "event");
4620 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
4621 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4622 			event_value, "none#timeout#os_off#os_on#power_on#power_off");
4623 cmdline_parse_token_string_t cmd_setbypass_event_mode =
4624 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4625 			mode, "mode");
4626 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
4627 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4628 			mode_value, "normal#bypass#isolate");
4629 cmdline_parse_token_num_t cmd_setbypass_event_port =
4630 	TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
4631 				port_id, UINT16);
4632 
4633 cmdline_parse_inst_t cmd_set_bypass_event = {
4634 	.f = cmd_set_bypass_event_parsed,
4635 	.help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
4636 		"power_off mode normal|bypass|isolate <port_id>: "
4637 		"Set the NIC bypass event mode for port_id",
4638 	.data = NULL,
4639 	.tokens = {
4640 		(void *)&cmd_setbypass_event_set,
4641 		(void *)&cmd_setbypass_event_bypass,
4642 		(void *)&cmd_setbypass_event_event,
4643 		(void *)&cmd_setbypass_event_event_value,
4644 		(void *)&cmd_setbypass_event_mode,
4645 		(void *)&cmd_setbypass_event_mode_value,
4646 		(void *)&cmd_setbypass_event_port,
4647 		NULL,
4648 	},
4649 };
4650 
4651 
4652 /* *** SET NIC BYPASS TIMEOUT *** */
4653 struct cmd_set_bypass_timeout_result {
4654 	cmdline_fixed_string_t set;
4655 	cmdline_fixed_string_t bypass;
4656 	cmdline_fixed_string_t timeout;
4657 	cmdline_fixed_string_t value;
4658 };
4659 
4660 static void
4661 cmd_set_bypass_timeout_parsed(void *parsed_result,
4662 		__attribute__((unused)) struct cmdline *cl,
4663 		__attribute__((unused)) void *data)
4664 {
4665 	__rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
4666 
4667 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4668 	if (!strcmp(res->value, "1.5"))
4669 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
4670 	else if (!strcmp(res->value, "2"))
4671 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
4672 	else if (!strcmp(res->value, "3"))
4673 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
4674 	else if (!strcmp(res->value, "4"))
4675 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
4676 	else if (!strcmp(res->value, "8"))
4677 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
4678 	else if (!strcmp(res->value, "16"))
4679 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
4680 	else if (!strcmp(res->value, "32"))
4681 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
4682 	else
4683 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
4684 #endif
4685 }
4686 
4687 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
4688 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4689 			set, "set");
4690 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
4691 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4692 			bypass, "bypass");
4693 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
4694 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4695 			timeout, "timeout");
4696 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
4697 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4698 			value, "0#1.5#2#3#4#8#16#32");
4699 
4700 cmdline_parse_inst_t cmd_set_bypass_timeout = {
4701 	.f = cmd_set_bypass_timeout_parsed,
4702 	.help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
4703 		"Set the NIC bypass watchdog timeout in seconds",
4704 	.data = NULL,
4705 	.tokens = {
4706 		(void *)&cmd_setbypass_timeout_set,
4707 		(void *)&cmd_setbypass_timeout_bypass,
4708 		(void *)&cmd_setbypass_timeout_timeout,
4709 		(void *)&cmd_setbypass_timeout_value,
4710 		NULL,
4711 	},
4712 };
4713 
4714 /* *** SHOW NIC BYPASS MODE *** */
4715 struct cmd_show_bypass_config_result {
4716 	cmdline_fixed_string_t show;
4717 	cmdline_fixed_string_t bypass;
4718 	cmdline_fixed_string_t config;
4719 	portid_t port_id;
4720 };
4721 
4722 static void
4723 cmd_show_bypass_config_parsed(void *parsed_result,
4724 		__attribute__((unused)) struct cmdline *cl,
4725 		__attribute__((unused)) void *data)
4726 {
4727 	struct cmd_show_bypass_config_result *res = parsed_result;
4728 	portid_t port_id = res->port_id;
4729 	int rc = -EINVAL;
4730 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4731 	uint32_t event_mode;
4732 	uint32_t bypass_mode;
4733 	uint32_t timeout = bypass_timeout;
4734 	int i;
4735 
4736 	static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
4737 		{"off", "1.5", "2", "3", "4", "8", "16", "32"};
4738 	static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
4739 		{"UNKNOWN", "normal", "bypass", "isolate"};
4740 	static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
4741 		"NONE",
4742 		"OS/board on",
4743 		"power supply on",
4744 		"OS/board off",
4745 		"power supply off",
4746 		"timeout"};
4747 	int num_events = (sizeof events) / (sizeof events[0]);
4748 
4749 	/* Display the bypass mode.*/
4750 	if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
4751 		printf("\tFailed to get bypass mode for port = %d\n", port_id);
4752 		return;
4753 	}
4754 	else {
4755 		if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
4756 			bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
4757 
4758 		printf("\tbypass mode    = %s\n",  modes[bypass_mode]);
4759 	}
4760 
4761 	/* Display the bypass timeout.*/
4762 	if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
4763 		timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
4764 
4765 	printf("\tbypass timeout = %s\n", timeouts[timeout]);
4766 
4767 	/* Display the bypass events and associated modes. */
4768 	for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < num_events; i++) {
4769 
4770 		if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
4771 			printf("\tFailed to get bypass mode for event = %s\n",
4772 				events[i]);
4773 		} else {
4774 			if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
4775 				event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
4776 
4777 			printf("\tbypass event: %-16s = %s\n", events[i],
4778 				modes[event_mode]);
4779 		}
4780 	}
4781 #endif
4782 	if (rc != 0)
4783 		printf("\tFailed to get bypass configuration for port = %d\n",
4784 		       port_id);
4785 }
4786 
4787 cmdline_parse_token_string_t cmd_showbypass_config_show =
4788 	TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4789 			show, "show");
4790 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
4791 	TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4792 			bypass, "bypass");
4793 cmdline_parse_token_string_t cmd_showbypass_config_config =
4794 	TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4795 			config, "config");
4796 cmdline_parse_token_num_t cmd_showbypass_config_port =
4797 	TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
4798 				port_id, UINT16);
4799 
4800 cmdline_parse_inst_t cmd_show_bypass_config = {
4801 	.f = cmd_show_bypass_config_parsed,
4802 	.help_str = "show bypass config <port_id>: "
4803 	            "Show the NIC bypass config for port_id",
4804 	.data = NULL,
4805 	.tokens = {
4806 		(void *)&cmd_showbypass_config_show,
4807 		(void *)&cmd_showbypass_config_bypass,
4808 		(void *)&cmd_showbypass_config_config,
4809 		(void *)&cmd_showbypass_config_port,
4810 		NULL,
4811 	},
4812 };
4813 
4814 #ifdef RTE_LIBRTE_PMD_BOND
4815 /* *** SET BONDING MODE *** */
4816 struct cmd_set_bonding_mode_result {
4817 	cmdline_fixed_string_t set;
4818 	cmdline_fixed_string_t bonding;
4819 	cmdline_fixed_string_t mode;
4820 	uint8_t value;
4821 	portid_t port_id;
4822 };
4823 
4824 static void cmd_set_bonding_mode_parsed(void *parsed_result,
4825 		__attribute__((unused))  struct cmdline *cl,
4826 		__attribute__((unused)) void *data)
4827 {
4828 	struct cmd_set_bonding_mode_result *res = parsed_result;
4829 	portid_t port_id = res->port_id;
4830 
4831 	/* Set the bonding mode for the relevant port. */
4832 	if (0 != rte_eth_bond_mode_set(port_id, res->value))
4833 		printf("\t Failed to set bonding mode for port = %d.\n", port_id);
4834 }
4835 
4836 cmdline_parse_token_string_t cmd_setbonding_mode_set =
4837 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4838 		set, "set");
4839 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
4840 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4841 		bonding, "bonding");
4842 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
4843 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4844 		mode, "mode");
4845 cmdline_parse_token_num_t cmd_setbonding_mode_value =
4846 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4847 		value, UINT8);
4848 cmdline_parse_token_num_t cmd_setbonding_mode_port =
4849 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4850 		port_id, UINT16);
4851 
4852 cmdline_parse_inst_t cmd_set_bonding_mode = {
4853 		.f = cmd_set_bonding_mode_parsed,
4854 		.help_str = "set bonding mode <mode_value> <port_id>: "
4855 			"Set the bonding mode for port_id",
4856 		.data = NULL,
4857 		.tokens = {
4858 				(void *) &cmd_setbonding_mode_set,
4859 				(void *) &cmd_setbonding_mode_bonding,
4860 				(void *) &cmd_setbonding_mode_mode,
4861 				(void *) &cmd_setbonding_mode_value,
4862 				(void *) &cmd_setbonding_mode_port,
4863 				NULL
4864 		}
4865 };
4866 
4867 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
4868 struct cmd_set_bonding_lacp_dedicated_queues_result {
4869 	cmdline_fixed_string_t set;
4870 	cmdline_fixed_string_t bonding;
4871 	cmdline_fixed_string_t lacp;
4872 	cmdline_fixed_string_t dedicated_queues;
4873 	portid_t port_id;
4874 	cmdline_fixed_string_t mode;
4875 };
4876 
4877 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
4878 		__attribute__((unused))  struct cmdline *cl,
4879 		__attribute__((unused)) void *data)
4880 {
4881 	struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
4882 	portid_t port_id = res->port_id;
4883 	struct rte_port *port;
4884 
4885 	port = &ports[port_id];
4886 
4887 	/** Check if the port is not started **/
4888 	if (port->port_status != RTE_PORT_STOPPED) {
4889 		printf("Please stop port %d first\n", port_id);
4890 		return;
4891 	}
4892 
4893 	if (!strcmp(res->mode, "enable")) {
4894 		if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
4895 			printf("Dedicate queues for LACP control packets"
4896 					" enabled\n");
4897 		else
4898 			printf("Enabling dedicate queues for LACP control "
4899 					"packets on port %d failed\n", port_id);
4900 	} else if (!strcmp(res->mode, "disable")) {
4901 		if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
4902 			printf("Dedicated queues for LACP control packets "
4903 					"disabled\n");
4904 		else
4905 			printf("Disabling dedicated queues for LACP control "
4906 					"traffic on port %d failed\n", port_id);
4907 	}
4908 }
4909 
4910 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
4911 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4912 		set, "set");
4913 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
4914 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4915 		bonding, "bonding");
4916 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
4917 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4918 		lacp, "lacp");
4919 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
4920 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4921 		dedicated_queues, "dedicated_queues");
4922 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
4923 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4924 		port_id, UINT16);
4925 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
4926 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4927 		mode, "enable#disable");
4928 
4929 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
4930 		.f = cmd_set_bonding_lacp_dedicated_queues_parsed,
4931 		.help_str = "set bonding lacp dedicated_queues <port_id> "
4932 			"enable|disable: "
4933 			"Enable/disable dedicated queues for LACP control traffic for port_id",
4934 		.data = NULL,
4935 		.tokens = {
4936 			(void *)&cmd_setbonding_lacp_dedicated_queues_set,
4937 			(void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
4938 			(void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
4939 			(void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
4940 			(void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
4941 			(void *)&cmd_setbonding_lacp_dedicated_queues_mode,
4942 			NULL
4943 		}
4944 };
4945 
4946 /* *** SET BALANCE XMIT POLICY *** */
4947 struct cmd_set_bonding_balance_xmit_policy_result {
4948 	cmdline_fixed_string_t set;
4949 	cmdline_fixed_string_t bonding;
4950 	cmdline_fixed_string_t balance_xmit_policy;
4951 	portid_t port_id;
4952 	cmdline_fixed_string_t policy;
4953 };
4954 
4955 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
4956 		__attribute__((unused))  struct cmdline *cl,
4957 		__attribute__((unused)) void *data)
4958 {
4959 	struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
4960 	portid_t port_id = res->port_id;
4961 	uint8_t policy;
4962 
4963 	if (!strcmp(res->policy, "l2")) {
4964 		policy = BALANCE_XMIT_POLICY_LAYER2;
4965 	} else if (!strcmp(res->policy, "l23")) {
4966 		policy = BALANCE_XMIT_POLICY_LAYER23;
4967 	} else if (!strcmp(res->policy, "l34")) {
4968 		policy = BALANCE_XMIT_POLICY_LAYER34;
4969 	} else {
4970 		printf("\t Invalid xmit policy selection");
4971 		return;
4972 	}
4973 
4974 	/* Set the bonding mode for the relevant port. */
4975 	if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
4976 		printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
4977 				port_id);
4978 	}
4979 }
4980 
4981 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
4982 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4983 		set, "set");
4984 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
4985 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4986 		bonding, "bonding");
4987 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
4988 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4989 		balance_xmit_policy, "balance_xmit_policy");
4990 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
4991 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4992 		port_id, UINT16);
4993 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
4994 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4995 		policy, "l2#l23#l34");
4996 
4997 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
4998 		.f = cmd_set_bonding_balance_xmit_policy_parsed,
4999 		.help_str = "set bonding balance_xmit_policy <port_id> "
5000 			"l2|l23|l34: "
5001 			"Set the bonding balance_xmit_policy for port_id",
5002 		.data = NULL,
5003 		.tokens = {
5004 				(void *)&cmd_setbonding_balance_xmit_policy_set,
5005 				(void *)&cmd_setbonding_balance_xmit_policy_bonding,
5006 				(void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
5007 				(void *)&cmd_setbonding_balance_xmit_policy_port,
5008 				(void *)&cmd_setbonding_balance_xmit_policy_policy,
5009 				NULL
5010 		}
5011 };
5012 
5013 /* *** SHOW NIC BONDING CONFIGURATION *** */
5014 struct cmd_show_bonding_config_result {
5015 	cmdline_fixed_string_t show;
5016 	cmdline_fixed_string_t bonding;
5017 	cmdline_fixed_string_t config;
5018 	portid_t port_id;
5019 };
5020 
5021 static void cmd_show_bonding_config_parsed(void *parsed_result,
5022 		__attribute__((unused))  struct cmdline *cl,
5023 		__attribute__((unused)) void *data)
5024 {
5025 	struct cmd_show_bonding_config_result *res = parsed_result;
5026 	int bonding_mode, agg_mode;
5027 	portid_t slaves[RTE_MAX_ETHPORTS];
5028 	int num_slaves, num_active_slaves;
5029 	int primary_id;
5030 	int i;
5031 	portid_t port_id = res->port_id;
5032 
5033 	/* Display the bonding mode.*/
5034 	bonding_mode = rte_eth_bond_mode_get(port_id);
5035 	if (bonding_mode < 0) {
5036 		printf("\tFailed to get bonding mode for port = %d\n", port_id);
5037 		return;
5038 	} else
5039 		printf("\tBonding mode: %d\n", bonding_mode);
5040 
5041 	if (bonding_mode == BONDING_MODE_BALANCE) {
5042 		int balance_xmit_policy;
5043 
5044 		balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
5045 		if (balance_xmit_policy < 0) {
5046 			printf("\tFailed to get balance xmit policy for port = %d\n",
5047 					port_id);
5048 			return;
5049 		} else {
5050 			printf("\tBalance Xmit Policy: ");
5051 
5052 			switch (balance_xmit_policy) {
5053 			case BALANCE_XMIT_POLICY_LAYER2:
5054 				printf("BALANCE_XMIT_POLICY_LAYER2");
5055 				break;
5056 			case BALANCE_XMIT_POLICY_LAYER23:
5057 				printf("BALANCE_XMIT_POLICY_LAYER23");
5058 				break;
5059 			case BALANCE_XMIT_POLICY_LAYER34:
5060 				printf("BALANCE_XMIT_POLICY_LAYER34");
5061 				break;
5062 			}
5063 			printf("\n");
5064 		}
5065 	}
5066 
5067 	if (bonding_mode == BONDING_MODE_8023AD) {
5068 		agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
5069 		printf("\tIEEE802.3AD Aggregator Mode: ");
5070 		switch (agg_mode) {
5071 		case AGG_BANDWIDTH:
5072 			printf("bandwidth");
5073 			break;
5074 		case AGG_STABLE:
5075 			printf("stable");
5076 			break;
5077 		case AGG_COUNT:
5078 			printf("count");
5079 			break;
5080 		}
5081 		printf("\n");
5082 	}
5083 
5084 	num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
5085 
5086 	if (num_slaves < 0) {
5087 		printf("\tFailed to get slave list for port = %d\n", port_id);
5088 		return;
5089 	}
5090 	if (num_slaves > 0) {
5091 		printf("\tSlaves (%d): [", num_slaves);
5092 		for (i = 0; i < num_slaves - 1; i++)
5093 			printf("%d ", slaves[i]);
5094 
5095 		printf("%d]\n", slaves[num_slaves - 1]);
5096 	} else {
5097 		printf("\tSlaves: []\n");
5098 
5099 	}
5100 
5101 	num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
5102 			RTE_MAX_ETHPORTS);
5103 
5104 	if (num_active_slaves < 0) {
5105 		printf("\tFailed to get active slave list for port = %d\n", port_id);
5106 		return;
5107 	}
5108 	if (num_active_slaves > 0) {
5109 		printf("\tActive Slaves (%d): [", num_active_slaves);
5110 		for (i = 0; i < num_active_slaves - 1; i++)
5111 			printf("%d ", slaves[i]);
5112 
5113 		printf("%d]\n", slaves[num_active_slaves - 1]);
5114 
5115 	} else {
5116 		printf("\tActive Slaves: []\n");
5117 
5118 	}
5119 
5120 	primary_id = rte_eth_bond_primary_get(port_id);
5121 	if (primary_id < 0) {
5122 		printf("\tFailed to get primary slave for port = %d\n", port_id);
5123 		return;
5124 	} else
5125 		printf("\tPrimary: [%d]\n", primary_id);
5126 
5127 }
5128 
5129 cmdline_parse_token_string_t cmd_showbonding_config_show =
5130 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5131 		show, "show");
5132 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
5133 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5134 		bonding, "bonding");
5135 cmdline_parse_token_string_t cmd_showbonding_config_config =
5136 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5137 		config, "config");
5138 cmdline_parse_token_num_t cmd_showbonding_config_port =
5139 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
5140 		port_id, UINT16);
5141 
5142 cmdline_parse_inst_t cmd_show_bonding_config = {
5143 		.f = cmd_show_bonding_config_parsed,
5144 		.help_str = "show bonding config <port_id>: "
5145 			"Show the bonding config for port_id",
5146 		.data = NULL,
5147 		.tokens = {
5148 				(void *)&cmd_showbonding_config_show,
5149 				(void *)&cmd_showbonding_config_bonding,
5150 				(void *)&cmd_showbonding_config_config,
5151 				(void *)&cmd_showbonding_config_port,
5152 				NULL
5153 		}
5154 };
5155 
5156 /* *** SET BONDING PRIMARY *** */
5157 struct cmd_set_bonding_primary_result {
5158 	cmdline_fixed_string_t set;
5159 	cmdline_fixed_string_t bonding;
5160 	cmdline_fixed_string_t primary;
5161 	portid_t slave_id;
5162 	portid_t port_id;
5163 };
5164 
5165 static void cmd_set_bonding_primary_parsed(void *parsed_result,
5166 		__attribute__((unused))  struct cmdline *cl,
5167 		__attribute__((unused)) void *data)
5168 {
5169 	struct cmd_set_bonding_primary_result *res = parsed_result;
5170 	portid_t master_port_id = res->port_id;
5171 	portid_t slave_port_id = res->slave_id;
5172 
5173 	/* Set the primary slave for a bonded device. */
5174 	if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
5175 		printf("\t Failed to set primary slave for port = %d.\n",
5176 				master_port_id);
5177 		return;
5178 	}
5179 	init_port_config();
5180 }
5181 
5182 cmdline_parse_token_string_t cmd_setbonding_primary_set =
5183 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5184 		set, "set");
5185 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
5186 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5187 		bonding, "bonding");
5188 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
5189 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5190 		primary, "primary");
5191 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
5192 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5193 		slave_id, UINT16);
5194 cmdline_parse_token_num_t cmd_setbonding_primary_port =
5195 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5196 		port_id, UINT16);
5197 
5198 cmdline_parse_inst_t cmd_set_bonding_primary = {
5199 		.f = cmd_set_bonding_primary_parsed,
5200 		.help_str = "set bonding primary <slave_id> <port_id>: "
5201 			"Set the primary slave for port_id",
5202 		.data = NULL,
5203 		.tokens = {
5204 				(void *)&cmd_setbonding_primary_set,
5205 				(void *)&cmd_setbonding_primary_bonding,
5206 				(void *)&cmd_setbonding_primary_primary,
5207 				(void *)&cmd_setbonding_primary_slave,
5208 				(void *)&cmd_setbonding_primary_port,
5209 				NULL
5210 		}
5211 };
5212 
5213 /* *** ADD SLAVE *** */
5214 struct cmd_add_bonding_slave_result {
5215 	cmdline_fixed_string_t add;
5216 	cmdline_fixed_string_t bonding;
5217 	cmdline_fixed_string_t slave;
5218 	portid_t slave_id;
5219 	portid_t port_id;
5220 };
5221 
5222 static void cmd_add_bonding_slave_parsed(void *parsed_result,
5223 		__attribute__((unused))  struct cmdline *cl,
5224 		__attribute__((unused)) void *data)
5225 {
5226 	struct cmd_add_bonding_slave_result *res = parsed_result;
5227 	portid_t master_port_id = res->port_id;
5228 	portid_t slave_port_id = res->slave_id;
5229 
5230 	/* add the slave for a bonded device. */
5231 	if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
5232 		printf("\t Failed to add slave %d to master port = %d.\n",
5233 				slave_port_id, master_port_id);
5234 		return;
5235 	}
5236 	init_port_config();
5237 	set_port_slave_flag(slave_port_id);
5238 }
5239 
5240 cmdline_parse_token_string_t cmd_addbonding_slave_add =
5241 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5242 		add, "add");
5243 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
5244 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5245 		bonding, "bonding");
5246 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
5247 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5248 		slave, "slave");
5249 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
5250 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5251 		slave_id, UINT16);
5252 cmdline_parse_token_num_t cmd_addbonding_slave_port =
5253 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5254 		port_id, UINT16);
5255 
5256 cmdline_parse_inst_t cmd_add_bonding_slave = {
5257 		.f = cmd_add_bonding_slave_parsed,
5258 		.help_str = "add bonding slave <slave_id> <port_id>: "
5259 			"Add a slave device to a bonded device",
5260 		.data = NULL,
5261 		.tokens = {
5262 				(void *)&cmd_addbonding_slave_add,
5263 				(void *)&cmd_addbonding_slave_bonding,
5264 				(void *)&cmd_addbonding_slave_slave,
5265 				(void *)&cmd_addbonding_slave_slaveid,
5266 				(void *)&cmd_addbonding_slave_port,
5267 				NULL
5268 		}
5269 };
5270 
5271 /* *** REMOVE SLAVE *** */
5272 struct cmd_remove_bonding_slave_result {
5273 	cmdline_fixed_string_t remove;
5274 	cmdline_fixed_string_t bonding;
5275 	cmdline_fixed_string_t slave;
5276 	portid_t slave_id;
5277 	portid_t port_id;
5278 };
5279 
5280 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
5281 		__attribute__((unused))  struct cmdline *cl,
5282 		__attribute__((unused)) void *data)
5283 {
5284 	struct cmd_remove_bonding_slave_result *res = parsed_result;
5285 	portid_t master_port_id = res->port_id;
5286 	portid_t slave_port_id = res->slave_id;
5287 
5288 	/* remove the slave from a bonded device. */
5289 	if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
5290 		printf("\t Failed to remove slave %d from master port = %d.\n",
5291 				slave_port_id, master_port_id);
5292 		return;
5293 	}
5294 	init_port_config();
5295 	clear_port_slave_flag(slave_port_id);
5296 }
5297 
5298 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
5299 		TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5300 				remove, "remove");
5301 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
5302 		TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5303 				bonding, "bonding");
5304 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
5305 		TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5306 				slave, "slave");
5307 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
5308 		TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5309 				slave_id, UINT16);
5310 cmdline_parse_token_num_t cmd_removebonding_slave_port =
5311 		TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5312 				port_id, UINT16);
5313 
5314 cmdline_parse_inst_t cmd_remove_bonding_slave = {
5315 		.f = cmd_remove_bonding_slave_parsed,
5316 		.help_str = "remove bonding slave <slave_id> <port_id>: "
5317 			"Remove a slave device from a bonded device",
5318 		.data = NULL,
5319 		.tokens = {
5320 				(void *)&cmd_removebonding_slave_remove,
5321 				(void *)&cmd_removebonding_slave_bonding,
5322 				(void *)&cmd_removebonding_slave_slave,
5323 				(void *)&cmd_removebonding_slave_slaveid,
5324 				(void *)&cmd_removebonding_slave_port,
5325 				NULL
5326 		}
5327 };
5328 
5329 /* *** CREATE BONDED DEVICE *** */
5330 struct cmd_create_bonded_device_result {
5331 	cmdline_fixed_string_t create;
5332 	cmdline_fixed_string_t bonded;
5333 	cmdline_fixed_string_t device;
5334 	uint8_t mode;
5335 	uint8_t socket;
5336 };
5337 
5338 static int bond_dev_num = 0;
5339 
5340 static void cmd_create_bonded_device_parsed(void *parsed_result,
5341 		__attribute__((unused))  struct cmdline *cl,
5342 		__attribute__((unused)) void *data)
5343 {
5344 	struct cmd_create_bonded_device_result *res = parsed_result;
5345 	char ethdev_name[RTE_ETH_NAME_MAX_LEN];
5346 	int port_id;
5347 
5348 	if (test_done == 0) {
5349 		printf("Please stop forwarding first\n");
5350 		return;
5351 	}
5352 
5353 	snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
5354 			bond_dev_num++);
5355 
5356 	/* Create a new bonded device. */
5357 	port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
5358 	if (port_id < 0) {
5359 		printf("\t Failed to create bonded device.\n");
5360 		return;
5361 	} else {
5362 		printf("Created new bonded device %s on (port %d).\n", ethdev_name,
5363 				port_id);
5364 
5365 		/* Update number of ports */
5366 		nb_ports = rte_eth_dev_count();
5367 		reconfig(port_id, res->socket);
5368 		rte_eth_promiscuous_enable(port_id);
5369 	}
5370 
5371 }
5372 
5373 cmdline_parse_token_string_t cmd_createbonded_device_create =
5374 		TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5375 				create, "create");
5376 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
5377 		TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5378 				bonded, "bonded");
5379 cmdline_parse_token_string_t cmd_createbonded_device_device =
5380 		TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5381 				device, "device");
5382 cmdline_parse_token_num_t cmd_createbonded_device_mode =
5383 		TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5384 				mode, UINT8);
5385 cmdline_parse_token_num_t cmd_createbonded_device_socket =
5386 		TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5387 				socket, UINT8);
5388 
5389 cmdline_parse_inst_t cmd_create_bonded_device = {
5390 		.f = cmd_create_bonded_device_parsed,
5391 		.help_str = "create bonded device <mode> <socket>: "
5392 			"Create a new bonded device with specific bonding mode and socket",
5393 		.data = NULL,
5394 		.tokens = {
5395 				(void *)&cmd_createbonded_device_create,
5396 				(void *)&cmd_createbonded_device_bonded,
5397 				(void *)&cmd_createbonded_device_device,
5398 				(void *)&cmd_createbonded_device_mode,
5399 				(void *)&cmd_createbonded_device_socket,
5400 				NULL
5401 		}
5402 };
5403 
5404 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
5405 struct cmd_set_bond_mac_addr_result {
5406 	cmdline_fixed_string_t set;
5407 	cmdline_fixed_string_t bonding;
5408 	cmdline_fixed_string_t mac_addr;
5409 	uint16_t port_num;
5410 	struct ether_addr address;
5411 };
5412 
5413 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
5414 		__attribute__((unused))  struct cmdline *cl,
5415 		__attribute__((unused)) void *data)
5416 {
5417 	struct cmd_set_bond_mac_addr_result *res = parsed_result;
5418 	int ret;
5419 
5420 	if (port_id_is_invalid(res->port_num, ENABLED_WARN))
5421 		return;
5422 
5423 	ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
5424 
5425 	/* check the return value and print it if is < 0 */
5426 	if (ret < 0)
5427 		printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5428 }
5429 
5430 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
5431 		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
5432 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
5433 		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
5434 				"bonding");
5435 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
5436 		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
5437 				"mac_addr");
5438 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
5439 		TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
5440 				port_num, UINT16);
5441 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
5442 		TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
5443 
5444 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
5445 		.f = cmd_set_bond_mac_addr_parsed,
5446 		.data = (void *) 0,
5447 		.help_str = "set bonding mac_addr <port_id> <mac_addr>",
5448 		.tokens = {
5449 				(void *)&cmd_set_bond_mac_addr_set,
5450 				(void *)&cmd_set_bond_mac_addr_bonding,
5451 				(void *)&cmd_set_bond_mac_addr_mac,
5452 				(void *)&cmd_set_bond_mac_addr_portnum,
5453 				(void *)&cmd_set_bond_mac_addr_addr,
5454 				NULL
5455 		}
5456 };
5457 
5458 
5459 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
5460 struct cmd_set_bond_mon_period_result {
5461 	cmdline_fixed_string_t set;
5462 	cmdline_fixed_string_t bonding;
5463 	cmdline_fixed_string_t mon_period;
5464 	uint16_t port_num;
5465 	uint32_t period_ms;
5466 };
5467 
5468 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
5469 		__attribute__((unused))  struct cmdline *cl,
5470 		__attribute__((unused)) void *data)
5471 {
5472 	struct cmd_set_bond_mon_period_result *res = parsed_result;
5473 	int ret;
5474 
5475 	if (res->port_num >= nb_ports) {
5476 		printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
5477 		return;
5478 	}
5479 
5480 	ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
5481 
5482 	/* check the return value and print it if is < 0 */
5483 	if (ret < 0)
5484 		printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5485 }
5486 
5487 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
5488 		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5489 				set, "set");
5490 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
5491 		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5492 				bonding, "bonding");
5493 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
5494 		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5495 				mon_period,	"mon_period");
5496 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
5497 		TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5498 				port_num, UINT16);
5499 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
5500 		TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5501 				period_ms, UINT32);
5502 
5503 cmdline_parse_inst_t cmd_set_bond_mon_period = {
5504 		.f = cmd_set_bond_mon_period_parsed,
5505 		.data = (void *) 0,
5506 		.help_str = "set bonding mon_period <port_id> <period_ms>",
5507 		.tokens = {
5508 				(void *)&cmd_set_bond_mon_period_set,
5509 				(void *)&cmd_set_bond_mon_period_bonding,
5510 				(void *)&cmd_set_bond_mon_period_mon_period,
5511 				(void *)&cmd_set_bond_mon_period_portnum,
5512 				(void *)&cmd_set_bond_mon_period_period_ms,
5513 				NULL
5514 		}
5515 };
5516 
5517 
5518 
5519 struct cmd_set_bonding_agg_mode_policy_result {
5520 	cmdline_fixed_string_t set;
5521 	cmdline_fixed_string_t bonding;
5522 	cmdline_fixed_string_t agg_mode;
5523 	uint16_t port_num;
5524 	cmdline_fixed_string_t policy;
5525 };
5526 
5527 
5528 static void
5529 cmd_set_bonding_agg_mode(void *parsed_result,
5530 		__attribute__((unused)) struct cmdline *cl,
5531 		__attribute__((unused)) void *data)
5532 {
5533 	struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
5534 	uint8_t policy = AGG_BANDWIDTH;
5535 
5536 	if (res->port_num >= nb_ports) {
5537 		printf("Port id %d must be less than %d\n",
5538 				res->port_num, nb_ports);
5539 		return;
5540 	}
5541 
5542 	if (!strcmp(res->policy, "bandwidth"))
5543 		policy = AGG_BANDWIDTH;
5544 	else if (!strcmp(res->policy, "stable"))
5545 		policy = AGG_STABLE;
5546 	else if (!strcmp(res->policy, "count"))
5547 		policy = AGG_COUNT;
5548 
5549 	rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
5550 }
5551 
5552 
5553 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
5554 	TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5555 				set, "set");
5556 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
5557 	TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5558 				bonding, "bonding");
5559 
5560 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
5561 	TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5562 				agg_mode, "agg_mode");
5563 
5564 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
5565 	TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5566 				port_num, UINT16);
5567 
5568 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
5569 	TOKEN_STRING_INITIALIZER(
5570 			struct cmd_set_bonding_balance_xmit_policy_result,
5571 		policy, "stable#bandwidth#count");
5572 
5573 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
5574 	.f = cmd_set_bonding_agg_mode,
5575 	.data = (void *) 0,
5576 	.help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
5577 	.tokens = {
5578 			(void *)&cmd_set_bonding_agg_mode_set,
5579 			(void *)&cmd_set_bonding_agg_mode_bonding,
5580 			(void *)&cmd_set_bonding_agg_mode_agg_mode,
5581 			(void *)&cmd_set_bonding_agg_mode_portnum,
5582 			(void *)&cmd_set_bonding_agg_mode_policy_string,
5583 			NULL
5584 		}
5585 };
5586 
5587 
5588 #endif /* RTE_LIBRTE_PMD_BOND */
5589 
5590 /* *** SET FORWARDING MODE *** */
5591 struct cmd_set_fwd_mode_result {
5592 	cmdline_fixed_string_t set;
5593 	cmdline_fixed_string_t fwd;
5594 	cmdline_fixed_string_t mode;
5595 };
5596 
5597 static void cmd_set_fwd_mode_parsed(void *parsed_result,
5598 				    __attribute__((unused)) struct cmdline *cl,
5599 				    __attribute__((unused)) void *data)
5600 {
5601 	struct cmd_set_fwd_mode_result *res = parsed_result;
5602 
5603 	retry_enabled = 0;
5604 	set_pkt_forwarding_mode(res->mode);
5605 }
5606 
5607 cmdline_parse_token_string_t cmd_setfwd_set =
5608 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
5609 cmdline_parse_token_string_t cmd_setfwd_fwd =
5610 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
5611 cmdline_parse_token_string_t cmd_setfwd_mode =
5612 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
5613 		"" /* defined at init */);
5614 
5615 cmdline_parse_inst_t cmd_set_fwd_mode = {
5616 	.f = cmd_set_fwd_mode_parsed,
5617 	.data = NULL,
5618 	.help_str = NULL, /* defined at init */
5619 	.tokens = {
5620 		(void *)&cmd_setfwd_set,
5621 		(void *)&cmd_setfwd_fwd,
5622 		(void *)&cmd_setfwd_mode,
5623 		NULL,
5624 	},
5625 };
5626 
5627 static void cmd_set_fwd_mode_init(void)
5628 {
5629 	char *modes, *c;
5630 	static char token[128];
5631 	static char help[256];
5632 	cmdline_parse_token_string_t *token_struct;
5633 
5634 	modes = list_pkt_forwarding_modes();
5635 	snprintf(help, sizeof(help), "set fwd %s: "
5636 		"Set packet forwarding mode", modes);
5637 	cmd_set_fwd_mode.help_str = help;
5638 
5639 	/* string token separator is # */
5640 	for (c = token; *modes != '\0'; modes++)
5641 		if (*modes == '|')
5642 			*c++ = '#';
5643 		else
5644 			*c++ = *modes;
5645 	token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
5646 	token_struct->string_data.str = token;
5647 }
5648 
5649 /* *** SET RETRY FORWARDING MODE *** */
5650 struct cmd_set_fwd_retry_mode_result {
5651 	cmdline_fixed_string_t set;
5652 	cmdline_fixed_string_t fwd;
5653 	cmdline_fixed_string_t mode;
5654 	cmdline_fixed_string_t retry;
5655 };
5656 
5657 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
5658 			    __attribute__((unused)) struct cmdline *cl,
5659 			    __attribute__((unused)) void *data)
5660 {
5661 	struct cmd_set_fwd_retry_mode_result *res = parsed_result;
5662 
5663 	retry_enabled = 1;
5664 	set_pkt_forwarding_mode(res->mode);
5665 }
5666 
5667 cmdline_parse_token_string_t cmd_setfwd_retry_set =
5668 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5669 			set, "set");
5670 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
5671 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5672 			fwd, "fwd");
5673 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
5674 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5675 			mode,
5676 		"" /* defined at init */);
5677 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
5678 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5679 			retry, "retry");
5680 
5681 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
5682 	.f = cmd_set_fwd_retry_mode_parsed,
5683 	.data = NULL,
5684 	.help_str = NULL, /* defined at init */
5685 	.tokens = {
5686 		(void *)&cmd_setfwd_retry_set,
5687 		(void *)&cmd_setfwd_retry_fwd,
5688 		(void *)&cmd_setfwd_retry_mode,
5689 		(void *)&cmd_setfwd_retry_retry,
5690 		NULL,
5691 	},
5692 };
5693 
5694 static void cmd_set_fwd_retry_mode_init(void)
5695 {
5696 	char *modes, *c;
5697 	static char token[128];
5698 	static char help[256];
5699 	cmdline_parse_token_string_t *token_struct;
5700 
5701 	modes = list_pkt_forwarding_retry_modes();
5702 	snprintf(help, sizeof(help), "set fwd %s retry: "
5703 		"Set packet forwarding mode with retry", modes);
5704 	cmd_set_fwd_retry_mode.help_str = help;
5705 
5706 	/* string token separator is # */
5707 	for (c = token; *modes != '\0'; modes++)
5708 		if (*modes == '|')
5709 			*c++ = '#';
5710 		else
5711 			*c++ = *modes;
5712 	token_struct = (cmdline_parse_token_string_t *)
5713 		cmd_set_fwd_retry_mode.tokens[2];
5714 	token_struct->string_data.str = token;
5715 }
5716 
5717 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
5718 struct cmd_set_burst_tx_retry_result {
5719 	cmdline_fixed_string_t set;
5720 	cmdline_fixed_string_t burst;
5721 	cmdline_fixed_string_t tx;
5722 	cmdline_fixed_string_t delay;
5723 	uint32_t time;
5724 	cmdline_fixed_string_t retry;
5725 	uint32_t retry_num;
5726 };
5727 
5728 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
5729 					__attribute__((unused)) struct cmdline *cl,
5730 					__attribute__((unused)) void *data)
5731 {
5732 	struct cmd_set_burst_tx_retry_result *res = parsed_result;
5733 
5734 	if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
5735 		&& !strcmp(res->tx, "tx")) {
5736 		if (!strcmp(res->delay, "delay"))
5737 			burst_tx_delay_time = res->time;
5738 		if (!strcmp(res->retry, "retry"))
5739 			burst_tx_retry_num = res->retry_num;
5740 	}
5741 
5742 }
5743 
5744 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
5745 	TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
5746 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
5747 	TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
5748 				 "burst");
5749 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
5750 	TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
5751 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
5752 	TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
5753 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
5754 	TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
5755 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
5756 	TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
5757 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
5758 	TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
5759 
5760 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
5761 	.f = cmd_set_burst_tx_retry_parsed,
5762 	.help_str = "set burst tx delay <delay_usec> retry <num_retry>",
5763 	.tokens = {
5764 		(void *)&cmd_set_burst_tx_retry_set,
5765 		(void *)&cmd_set_burst_tx_retry_burst,
5766 		(void *)&cmd_set_burst_tx_retry_tx,
5767 		(void *)&cmd_set_burst_tx_retry_delay,
5768 		(void *)&cmd_set_burst_tx_retry_time,
5769 		(void *)&cmd_set_burst_tx_retry_retry,
5770 		(void *)&cmd_set_burst_tx_retry_retry_num,
5771 		NULL,
5772 	},
5773 };
5774 
5775 /* *** SET PROMISC MODE *** */
5776 struct cmd_set_promisc_mode_result {
5777 	cmdline_fixed_string_t set;
5778 	cmdline_fixed_string_t promisc;
5779 	cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5780 	uint16_t port_num;               /* valid if "allports" argument == 0 */
5781 	cmdline_fixed_string_t mode;
5782 };
5783 
5784 static void cmd_set_promisc_mode_parsed(void *parsed_result,
5785 					__attribute__((unused)) struct cmdline *cl,
5786 					void *allports)
5787 {
5788 	struct cmd_set_promisc_mode_result *res = parsed_result;
5789 	int enable;
5790 	portid_t i;
5791 
5792 	if (!strcmp(res->mode, "on"))
5793 		enable = 1;
5794 	else
5795 		enable = 0;
5796 
5797 	/* all ports */
5798 	if (allports) {
5799 		RTE_ETH_FOREACH_DEV(i) {
5800 			if (enable)
5801 				rte_eth_promiscuous_enable(i);
5802 			else
5803 				rte_eth_promiscuous_disable(i);
5804 		}
5805 	}
5806 	else {
5807 		if (enable)
5808 			rte_eth_promiscuous_enable(res->port_num);
5809 		else
5810 			rte_eth_promiscuous_disable(res->port_num);
5811 	}
5812 }
5813 
5814 cmdline_parse_token_string_t cmd_setpromisc_set =
5815 	TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
5816 cmdline_parse_token_string_t cmd_setpromisc_promisc =
5817 	TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
5818 				 "promisc");
5819 cmdline_parse_token_string_t cmd_setpromisc_portall =
5820 	TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
5821 				 "all");
5822 cmdline_parse_token_num_t cmd_setpromisc_portnum =
5823 	TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
5824 			      UINT8);
5825 cmdline_parse_token_string_t cmd_setpromisc_mode =
5826 	TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
5827 				 "on#off");
5828 
5829 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
5830 	.f = cmd_set_promisc_mode_parsed,
5831 	.data = (void *)1,
5832 	.help_str = "set promisc all on|off: Set promisc mode for all ports",
5833 	.tokens = {
5834 		(void *)&cmd_setpromisc_set,
5835 		(void *)&cmd_setpromisc_promisc,
5836 		(void *)&cmd_setpromisc_portall,
5837 		(void *)&cmd_setpromisc_mode,
5838 		NULL,
5839 	},
5840 };
5841 
5842 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
5843 	.f = cmd_set_promisc_mode_parsed,
5844 	.data = (void *)0,
5845 	.help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
5846 	.tokens = {
5847 		(void *)&cmd_setpromisc_set,
5848 		(void *)&cmd_setpromisc_promisc,
5849 		(void *)&cmd_setpromisc_portnum,
5850 		(void *)&cmd_setpromisc_mode,
5851 		NULL,
5852 	},
5853 };
5854 
5855 /* *** SET ALLMULTI MODE *** */
5856 struct cmd_set_allmulti_mode_result {
5857 	cmdline_fixed_string_t set;
5858 	cmdline_fixed_string_t allmulti;
5859 	cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5860 	uint16_t port_num;               /* valid if "allports" argument == 0 */
5861 	cmdline_fixed_string_t mode;
5862 };
5863 
5864 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
5865 					__attribute__((unused)) struct cmdline *cl,
5866 					void *allports)
5867 {
5868 	struct cmd_set_allmulti_mode_result *res = parsed_result;
5869 	int enable;
5870 	portid_t i;
5871 
5872 	if (!strcmp(res->mode, "on"))
5873 		enable = 1;
5874 	else
5875 		enable = 0;
5876 
5877 	/* all ports */
5878 	if (allports) {
5879 		RTE_ETH_FOREACH_DEV(i) {
5880 			if (enable)
5881 				rte_eth_allmulticast_enable(i);
5882 			else
5883 				rte_eth_allmulticast_disable(i);
5884 		}
5885 	}
5886 	else {
5887 		if (enable)
5888 			rte_eth_allmulticast_enable(res->port_num);
5889 		else
5890 			rte_eth_allmulticast_disable(res->port_num);
5891 	}
5892 }
5893 
5894 cmdline_parse_token_string_t cmd_setallmulti_set =
5895 	TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
5896 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
5897 	TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
5898 				 "allmulti");
5899 cmdline_parse_token_string_t cmd_setallmulti_portall =
5900 	TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
5901 				 "all");
5902 cmdline_parse_token_num_t cmd_setallmulti_portnum =
5903 	TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
5904 			      UINT16);
5905 cmdline_parse_token_string_t cmd_setallmulti_mode =
5906 	TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
5907 				 "on#off");
5908 
5909 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
5910 	.f = cmd_set_allmulti_mode_parsed,
5911 	.data = (void *)1,
5912 	.help_str = "set allmulti all on|off: Set allmulti mode for all ports",
5913 	.tokens = {
5914 		(void *)&cmd_setallmulti_set,
5915 		(void *)&cmd_setallmulti_allmulti,
5916 		(void *)&cmd_setallmulti_portall,
5917 		(void *)&cmd_setallmulti_mode,
5918 		NULL,
5919 	},
5920 };
5921 
5922 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
5923 	.f = cmd_set_allmulti_mode_parsed,
5924 	.data = (void *)0,
5925 	.help_str = "set allmulti <port_id> on|off: "
5926 		"Set allmulti mode on port_id",
5927 	.tokens = {
5928 		(void *)&cmd_setallmulti_set,
5929 		(void *)&cmd_setallmulti_allmulti,
5930 		(void *)&cmd_setallmulti_portnum,
5931 		(void *)&cmd_setallmulti_mode,
5932 		NULL,
5933 	},
5934 };
5935 
5936 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
5937 struct cmd_link_flow_ctrl_set_result {
5938 	cmdline_fixed_string_t set;
5939 	cmdline_fixed_string_t flow_ctrl;
5940 	cmdline_fixed_string_t rx;
5941 	cmdline_fixed_string_t rx_lfc_mode;
5942 	cmdline_fixed_string_t tx;
5943 	cmdline_fixed_string_t tx_lfc_mode;
5944 	cmdline_fixed_string_t mac_ctrl_frame_fwd;
5945 	cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
5946 	cmdline_fixed_string_t autoneg_str;
5947 	cmdline_fixed_string_t autoneg;
5948 	cmdline_fixed_string_t hw_str;
5949 	uint32_t high_water;
5950 	cmdline_fixed_string_t lw_str;
5951 	uint32_t low_water;
5952 	cmdline_fixed_string_t pt_str;
5953 	uint16_t pause_time;
5954 	cmdline_fixed_string_t xon_str;
5955 	uint16_t send_xon;
5956 	portid_t port_id;
5957 };
5958 
5959 cmdline_parse_token_string_t cmd_lfc_set_set =
5960 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5961 				set, "set");
5962 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
5963 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5964 				flow_ctrl, "flow_ctrl");
5965 cmdline_parse_token_string_t cmd_lfc_set_rx =
5966 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5967 				rx, "rx");
5968 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
5969 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5970 				rx_lfc_mode, "on#off");
5971 cmdline_parse_token_string_t cmd_lfc_set_tx =
5972 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5973 				tx, "tx");
5974 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
5975 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5976 				tx_lfc_mode, "on#off");
5977 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
5978 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5979 				hw_str, "high_water");
5980 cmdline_parse_token_num_t cmd_lfc_set_high_water =
5981 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5982 				high_water, UINT32);
5983 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
5984 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5985 				lw_str, "low_water");
5986 cmdline_parse_token_num_t cmd_lfc_set_low_water =
5987 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5988 				low_water, UINT32);
5989 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
5990 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5991 				pt_str, "pause_time");
5992 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
5993 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5994 				pause_time, UINT16);
5995 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
5996 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5997 				xon_str, "send_xon");
5998 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
5999 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6000 				send_xon, UINT16);
6001 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
6002 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6003 				mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
6004 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6005 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6006 				mac_ctrl_frame_fwd_mode, "on#off");
6007 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6008 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6009 				autoneg_str, "autoneg");
6010 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6011 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6012 				autoneg, "on#off");
6013 cmdline_parse_token_num_t cmd_lfc_set_portid =
6014 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6015 				port_id, UINT16);
6016 
6017 /* forward declaration */
6018 static void
6019 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6020 			      void *data);
6021 
6022 cmdline_parse_inst_t cmd_link_flow_control_set = {
6023 	.f = cmd_link_flow_ctrl_set_parsed,
6024 	.data = NULL,
6025 	.help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6026 		"<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6027 		"autoneg on|off <port_id>: Configure the Ethernet flow control",
6028 	.tokens = {
6029 		(void *)&cmd_lfc_set_set,
6030 		(void *)&cmd_lfc_set_flow_ctrl,
6031 		(void *)&cmd_lfc_set_rx,
6032 		(void *)&cmd_lfc_set_rx_mode,
6033 		(void *)&cmd_lfc_set_tx,
6034 		(void *)&cmd_lfc_set_tx_mode,
6035 		(void *)&cmd_lfc_set_high_water,
6036 		(void *)&cmd_lfc_set_low_water,
6037 		(void *)&cmd_lfc_set_pause_time,
6038 		(void *)&cmd_lfc_set_send_xon,
6039 		(void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6040 		(void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6041 		(void *)&cmd_lfc_set_autoneg_str,
6042 		(void *)&cmd_lfc_set_autoneg,
6043 		(void *)&cmd_lfc_set_portid,
6044 		NULL,
6045 	},
6046 };
6047 
6048 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6049 	.f = cmd_link_flow_ctrl_set_parsed,
6050 	.data = (void *)&cmd_link_flow_control_set_rx,
6051 	.help_str = "set flow_ctrl rx on|off <port_id>: "
6052 		"Change rx flow control parameter",
6053 	.tokens = {
6054 		(void *)&cmd_lfc_set_set,
6055 		(void *)&cmd_lfc_set_flow_ctrl,
6056 		(void *)&cmd_lfc_set_rx,
6057 		(void *)&cmd_lfc_set_rx_mode,
6058 		(void *)&cmd_lfc_set_portid,
6059 		NULL,
6060 	},
6061 };
6062 
6063 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6064 	.f = cmd_link_flow_ctrl_set_parsed,
6065 	.data = (void *)&cmd_link_flow_control_set_tx,
6066 	.help_str = "set flow_ctrl tx on|off <port_id>: "
6067 		"Change tx flow control parameter",
6068 	.tokens = {
6069 		(void *)&cmd_lfc_set_set,
6070 		(void *)&cmd_lfc_set_flow_ctrl,
6071 		(void *)&cmd_lfc_set_tx,
6072 		(void *)&cmd_lfc_set_tx_mode,
6073 		(void *)&cmd_lfc_set_portid,
6074 		NULL,
6075 	},
6076 };
6077 
6078 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
6079 	.f = cmd_link_flow_ctrl_set_parsed,
6080 	.data = (void *)&cmd_link_flow_control_set_hw,
6081 	.help_str = "set flow_ctrl high_water <value> <port_id>: "
6082 		"Change high water flow control parameter",
6083 	.tokens = {
6084 		(void *)&cmd_lfc_set_set,
6085 		(void *)&cmd_lfc_set_flow_ctrl,
6086 		(void *)&cmd_lfc_set_high_water_str,
6087 		(void *)&cmd_lfc_set_high_water,
6088 		(void *)&cmd_lfc_set_portid,
6089 		NULL,
6090 	},
6091 };
6092 
6093 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
6094 	.f = cmd_link_flow_ctrl_set_parsed,
6095 	.data = (void *)&cmd_link_flow_control_set_lw,
6096 	.help_str = "set flow_ctrl low_water <value> <port_id>: "
6097 		"Change low water flow control parameter",
6098 	.tokens = {
6099 		(void *)&cmd_lfc_set_set,
6100 		(void *)&cmd_lfc_set_flow_ctrl,
6101 		(void *)&cmd_lfc_set_low_water_str,
6102 		(void *)&cmd_lfc_set_low_water,
6103 		(void *)&cmd_lfc_set_portid,
6104 		NULL,
6105 	},
6106 };
6107 
6108 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
6109 	.f = cmd_link_flow_ctrl_set_parsed,
6110 	.data = (void *)&cmd_link_flow_control_set_pt,
6111 	.help_str = "set flow_ctrl pause_time <value> <port_id>: "
6112 		"Change pause time flow control parameter",
6113 	.tokens = {
6114 		(void *)&cmd_lfc_set_set,
6115 		(void *)&cmd_lfc_set_flow_ctrl,
6116 		(void *)&cmd_lfc_set_pause_time_str,
6117 		(void *)&cmd_lfc_set_pause_time,
6118 		(void *)&cmd_lfc_set_portid,
6119 		NULL,
6120 	},
6121 };
6122 
6123 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
6124 	.f = cmd_link_flow_ctrl_set_parsed,
6125 	.data = (void *)&cmd_link_flow_control_set_xon,
6126 	.help_str = "set flow_ctrl send_xon <value> <port_id>: "
6127 		"Change send_xon flow control parameter",
6128 	.tokens = {
6129 		(void *)&cmd_lfc_set_set,
6130 		(void *)&cmd_lfc_set_flow_ctrl,
6131 		(void *)&cmd_lfc_set_send_xon_str,
6132 		(void *)&cmd_lfc_set_send_xon,
6133 		(void *)&cmd_lfc_set_portid,
6134 		NULL,
6135 	},
6136 };
6137 
6138 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
6139 	.f = cmd_link_flow_ctrl_set_parsed,
6140 	.data = (void *)&cmd_link_flow_control_set_macfwd,
6141 	.help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
6142 		"Change mac ctrl fwd flow control parameter",
6143 	.tokens = {
6144 		(void *)&cmd_lfc_set_set,
6145 		(void *)&cmd_lfc_set_flow_ctrl,
6146 		(void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6147 		(void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6148 		(void *)&cmd_lfc_set_portid,
6149 		NULL,
6150 	},
6151 };
6152 
6153 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
6154 	.f = cmd_link_flow_ctrl_set_parsed,
6155 	.data = (void *)&cmd_link_flow_control_set_autoneg,
6156 	.help_str = "set flow_ctrl autoneg on|off <port_id>: "
6157 		"Change autoneg flow control parameter",
6158 	.tokens = {
6159 		(void *)&cmd_lfc_set_set,
6160 		(void *)&cmd_lfc_set_flow_ctrl,
6161 		(void *)&cmd_lfc_set_autoneg_str,
6162 		(void *)&cmd_lfc_set_autoneg,
6163 		(void *)&cmd_lfc_set_portid,
6164 		NULL,
6165 	},
6166 };
6167 
6168 static void
6169 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
6170 			      __attribute__((unused)) struct cmdline *cl,
6171 			      void *data)
6172 {
6173 	struct cmd_link_flow_ctrl_set_result *res = parsed_result;
6174 	cmdline_parse_inst_t *cmd = data;
6175 	struct rte_eth_fc_conf fc_conf;
6176 	int rx_fc_en = 0;
6177 	int tx_fc_en = 0;
6178 	int ret;
6179 
6180 	/*
6181 	 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6182 	 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6183 	 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6184 	 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6185 	 */
6186 	static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
6187 			{RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
6188 	};
6189 
6190 	/* Partial command line, retrieve current configuration */
6191 	if (cmd) {
6192 		ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
6193 		if (ret != 0) {
6194 			printf("cannot get current flow ctrl parameters, return"
6195 			       "code = %d\n", ret);
6196 			return;
6197 		}
6198 
6199 		if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
6200 		    (fc_conf.mode == RTE_FC_FULL))
6201 			rx_fc_en = 1;
6202 		if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
6203 		    (fc_conf.mode == RTE_FC_FULL))
6204 			tx_fc_en = 1;
6205 	}
6206 
6207 	if (!cmd || cmd == &cmd_link_flow_control_set_rx)
6208 		rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
6209 
6210 	if (!cmd || cmd == &cmd_link_flow_control_set_tx)
6211 		tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
6212 
6213 	fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
6214 
6215 	if (!cmd || cmd == &cmd_link_flow_control_set_hw)
6216 		fc_conf.high_water = res->high_water;
6217 
6218 	if (!cmd || cmd == &cmd_link_flow_control_set_lw)
6219 		fc_conf.low_water = res->low_water;
6220 
6221 	if (!cmd || cmd == &cmd_link_flow_control_set_pt)
6222 		fc_conf.pause_time = res->pause_time;
6223 
6224 	if (!cmd || cmd == &cmd_link_flow_control_set_xon)
6225 		fc_conf.send_xon = res->send_xon;
6226 
6227 	if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
6228 		if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
6229 			fc_conf.mac_ctrl_frame_fwd = 1;
6230 		else
6231 			fc_conf.mac_ctrl_frame_fwd = 0;
6232 	}
6233 
6234 	if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
6235 		fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
6236 
6237 	ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
6238 	if (ret != 0)
6239 		printf("bad flow contrl parameter, return code = %d \n", ret);
6240 }
6241 
6242 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
6243 struct cmd_priority_flow_ctrl_set_result {
6244 	cmdline_fixed_string_t set;
6245 	cmdline_fixed_string_t pfc_ctrl;
6246 	cmdline_fixed_string_t rx;
6247 	cmdline_fixed_string_t rx_pfc_mode;
6248 	cmdline_fixed_string_t tx;
6249 	cmdline_fixed_string_t tx_pfc_mode;
6250 	uint32_t high_water;
6251 	uint32_t low_water;
6252 	uint16_t pause_time;
6253 	uint8_t  priority;
6254 	portid_t port_id;
6255 };
6256 
6257 static void
6258 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
6259 		       __attribute__((unused)) struct cmdline *cl,
6260 		       __attribute__((unused)) void *data)
6261 {
6262 	struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
6263 	struct rte_eth_pfc_conf pfc_conf;
6264 	int rx_fc_enable, tx_fc_enable;
6265 	int ret;
6266 
6267 	/*
6268 	 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6269 	 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6270 	 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6271 	 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6272 	 */
6273 	static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
6274 			{RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
6275 	};
6276 
6277 	rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
6278 	tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
6279 	pfc_conf.fc.mode       = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
6280 	pfc_conf.fc.high_water = res->high_water;
6281 	pfc_conf.fc.low_water  = res->low_water;
6282 	pfc_conf.fc.pause_time = res->pause_time;
6283 	pfc_conf.priority      = res->priority;
6284 
6285 	ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
6286 	if (ret != 0)
6287 		printf("bad priority flow contrl parameter, return code = %d \n", ret);
6288 }
6289 
6290 cmdline_parse_token_string_t cmd_pfc_set_set =
6291 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6292 				set, "set");
6293 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
6294 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6295 				pfc_ctrl, "pfc_ctrl");
6296 cmdline_parse_token_string_t cmd_pfc_set_rx =
6297 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6298 				rx, "rx");
6299 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
6300 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6301 				rx_pfc_mode, "on#off");
6302 cmdline_parse_token_string_t cmd_pfc_set_tx =
6303 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6304 				tx, "tx");
6305 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
6306 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6307 				tx_pfc_mode, "on#off");
6308 cmdline_parse_token_num_t cmd_pfc_set_high_water =
6309 	TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6310 				high_water, UINT32);
6311 cmdline_parse_token_num_t cmd_pfc_set_low_water =
6312 	TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6313 				low_water, UINT32);
6314 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
6315 	TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6316 				pause_time, UINT16);
6317 cmdline_parse_token_num_t cmd_pfc_set_priority =
6318 	TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6319 				priority, UINT8);
6320 cmdline_parse_token_num_t cmd_pfc_set_portid =
6321 	TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6322 				port_id, UINT16);
6323 
6324 cmdline_parse_inst_t cmd_priority_flow_control_set = {
6325 	.f = cmd_priority_flow_ctrl_set_parsed,
6326 	.data = NULL,
6327 	.help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
6328 		"<pause_time> <priority> <port_id>: "
6329 		"Configure the Ethernet priority flow control",
6330 	.tokens = {
6331 		(void *)&cmd_pfc_set_set,
6332 		(void *)&cmd_pfc_set_flow_ctrl,
6333 		(void *)&cmd_pfc_set_rx,
6334 		(void *)&cmd_pfc_set_rx_mode,
6335 		(void *)&cmd_pfc_set_tx,
6336 		(void *)&cmd_pfc_set_tx_mode,
6337 		(void *)&cmd_pfc_set_high_water,
6338 		(void *)&cmd_pfc_set_low_water,
6339 		(void *)&cmd_pfc_set_pause_time,
6340 		(void *)&cmd_pfc_set_priority,
6341 		(void *)&cmd_pfc_set_portid,
6342 		NULL,
6343 	},
6344 };
6345 
6346 /* *** RESET CONFIGURATION *** */
6347 struct cmd_reset_result {
6348 	cmdline_fixed_string_t reset;
6349 	cmdline_fixed_string_t def;
6350 };
6351 
6352 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
6353 			     struct cmdline *cl,
6354 			     __attribute__((unused)) void *data)
6355 {
6356 	cmdline_printf(cl, "Reset to default forwarding configuration...\n");
6357 	set_def_fwd_config();
6358 }
6359 
6360 cmdline_parse_token_string_t cmd_reset_set =
6361 	TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
6362 cmdline_parse_token_string_t cmd_reset_def =
6363 	TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
6364 				 "default");
6365 
6366 cmdline_parse_inst_t cmd_reset = {
6367 	.f = cmd_reset_parsed,
6368 	.data = NULL,
6369 	.help_str = "set default: Reset default forwarding configuration",
6370 	.tokens = {
6371 		(void *)&cmd_reset_set,
6372 		(void *)&cmd_reset_def,
6373 		NULL,
6374 	},
6375 };
6376 
6377 /* *** START FORWARDING *** */
6378 struct cmd_start_result {
6379 	cmdline_fixed_string_t start;
6380 };
6381 
6382 cmdline_parse_token_string_t cmd_start_start =
6383 	TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
6384 
6385 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
6386 			     __attribute__((unused)) struct cmdline *cl,
6387 			     __attribute__((unused)) void *data)
6388 {
6389 	start_packet_forwarding(0);
6390 }
6391 
6392 cmdline_parse_inst_t cmd_start = {
6393 	.f = cmd_start_parsed,
6394 	.data = NULL,
6395 	.help_str = "start: Start packet forwarding",
6396 	.tokens = {
6397 		(void *)&cmd_start_start,
6398 		NULL,
6399 	},
6400 };
6401 
6402 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
6403 struct cmd_start_tx_first_result {
6404 	cmdline_fixed_string_t start;
6405 	cmdline_fixed_string_t tx_first;
6406 };
6407 
6408 static void
6409 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
6410 			  __attribute__((unused)) struct cmdline *cl,
6411 			  __attribute__((unused)) void *data)
6412 {
6413 	start_packet_forwarding(1);
6414 }
6415 
6416 cmdline_parse_token_string_t cmd_start_tx_first_start =
6417 	TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
6418 				 "start");
6419 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
6420 	TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
6421 				 tx_first, "tx_first");
6422 
6423 cmdline_parse_inst_t cmd_start_tx_first = {
6424 	.f = cmd_start_tx_first_parsed,
6425 	.data = NULL,
6426 	.help_str = "start tx_first: Start packet forwarding, "
6427 		"after sending 1 burst of packets",
6428 	.tokens = {
6429 		(void *)&cmd_start_tx_first_start,
6430 		(void *)&cmd_start_tx_first_tx_first,
6431 		NULL,
6432 	},
6433 };
6434 
6435 /* *** START FORWARDING WITH N TX BURST FIRST *** */
6436 struct cmd_start_tx_first_n_result {
6437 	cmdline_fixed_string_t start;
6438 	cmdline_fixed_string_t tx_first;
6439 	uint32_t tx_num;
6440 };
6441 
6442 static void
6443 cmd_start_tx_first_n_parsed(void *parsed_result,
6444 			  __attribute__((unused)) struct cmdline *cl,
6445 			  __attribute__((unused)) void *data)
6446 {
6447 	struct cmd_start_tx_first_n_result *res = parsed_result;
6448 
6449 	start_packet_forwarding(res->tx_num);
6450 }
6451 
6452 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
6453 	TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6454 			start, "start");
6455 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
6456 	TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6457 			tx_first, "tx_first");
6458 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
6459 	TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
6460 			tx_num, UINT32);
6461 
6462 cmdline_parse_inst_t cmd_start_tx_first_n = {
6463 	.f = cmd_start_tx_first_n_parsed,
6464 	.data = NULL,
6465 	.help_str = "start tx_first <num>: "
6466 		"packet forwarding, after sending <num> bursts of packets",
6467 	.tokens = {
6468 		(void *)&cmd_start_tx_first_n_start,
6469 		(void *)&cmd_start_tx_first_n_tx_first,
6470 		(void *)&cmd_start_tx_first_n_tx_num,
6471 		NULL,
6472 	},
6473 };
6474 
6475 /* *** SET LINK UP *** */
6476 struct cmd_set_link_up_result {
6477 	cmdline_fixed_string_t set;
6478 	cmdline_fixed_string_t link_up;
6479 	cmdline_fixed_string_t port;
6480 	portid_t port_id;
6481 };
6482 
6483 cmdline_parse_token_string_t cmd_set_link_up_set =
6484 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
6485 cmdline_parse_token_string_t cmd_set_link_up_link_up =
6486 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
6487 				"link-up");
6488 cmdline_parse_token_string_t cmd_set_link_up_port =
6489 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
6490 cmdline_parse_token_num_t cmd_set_link_up_port_id =
6491 	TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16);
6492 
6493 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
6494 			     __attribute__((unused)) struct cmdline *cl,
6495 			     __attribute__((unused)) void *data)
6496 {
6497 	struct cmd_set_link_up_result *res = parsed_result;
6498 	dev_set_link_up(res->port_id);
6499 }
6500 
6501 cmdline_parse_inst_t cmd_set_link_up = {
6502 	.f = cmd_set_link_up_parsed,
6503 	.data = NULL,
6504 	.help_str = "set link-up port <port id>",
6505 	.tokens = {
6506 		(void *)&cmd_set_link_up_set,
6507 		(void *)&cmd_set_link_up_link_up,
6508 		(void *)&cmd_set_link_up_port,
6509 		(void *)&cmd_set_link_up_port_id,
6510 		NULL,
6511 	},
6512 };
6513 
6514 /* *** SET LINK DOWN *** */
6515 struct cmd_set_link_down_result {
6516 	cmdline_fixed_string_t set;
6517 	cmdline_fixed_string_t link_down;
6518 	cmdline_fixed_string_t port;
6519 	portid_t port_id;
6520 };
6521 
6522 cmdline_parse_token_string_t cmd_set_link_down_set =
6523 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
6524 cmdline_parse_token_string_t cmd_set_link_down_link_down =
6525 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
6526 				"link-down");
6527 cmdline_parse_token_string_t cmd_set_link_down_port =
6528 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
6529 cmdline_parse_token_num_t cmd_set_link_down_port_id =
6530 	TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16);
6531 
6532 static void cmd_set_link_down_parsed(
6533 				__attribute__((unused)) void *parsed_result,
6534 				__attribute__((unused)) struct cmdline *cl,
6535 				__attribute__((unused)) void *data)
6536 {
6537 	struct cmd_set_link_down_result *res = parsed_result;
6538 	dev_set_link_down(res->port_id);
6539 }
6540 
6541 cmdline_parse_inst_t cmd_set_link_down = {
6542 	.f = cmd_set_link_down_parsed,
6543 	.data = NULL,
6544 	.help_str = "set link-down port <port id>",
6545 	.tokens = {
6546 		(void *)&cmd_set_link_down_set,
6547 		(void *)&cmd_set_link_down_link_down,
6548 		(void *)&cmd_set_link_down_port,
6549 		(void *)&cmd_set_link_down_port_id,
6550 		NULL,
6551 	},
6552 };
6553 
6554 /* *** SHOW CFG *** */
6555 struct cmd_showcfg_result {
6556 	cmdline_fixed_string_t show;
6557 	cmdline_fixed_string_t cfg;
6558 	cmdline_fixed_string_t what;
6559 };
6560 
6561 static void cmd_showcfg_parsed(void *parsed_result,
6562 			       __attribute__((unused)) struct cmdline *cl,
6563 			       __attribute__((unused)) void *data)
6564 {
6565 	struct cmd_showcfg_result *res = parsed_result;
6566 	if (!strcmp(res->what, "rxtx"))
6567 		rxtx_config_display();
6568 	else if (!strcmp(res->what, "cores"))
6569 		fwd_lcores_config_display();
6570 	else if (!strcmp(res->what, "fwd"))
6571 		pkt_fwd_config_display(&cur_fwd_config);
6572 	else if (!strcmp(res->what, "txpkts"))
6573 		show_tx_pkt_segments();
6574 }
6575 
6576 cmdline_parse_token_string_t cmd_showcfg_show =
6577 	TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
6578 cmdline_parse_token_string_t cmd_showcfg_port =
6579 	TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
6580 cmdline_parse_token_string_t cmd_showcfg_what =
6581 	TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
6582 				 "rxtx#cores#fwd#txpkts");
6583 
6584 cmdline_parse_inst_t cmd_showcfg = {
6585 	.f = cmd_showcfg_parsed,
6586 	.data = NULL,
6587 	.help_str = "show config rxtx|cores|fwd|txpkts",
6588 	.tokens = {
6589 		(void *)&cmd_showcfg_show,
6590 		(void *)&cmd_showcfg_port,
6591 		(void *)&cmd_showcfg_what,
6592 		NULL,
6593 	},
6594 };
6595 
6596 /* *** SHOW ALL PORT INFO *** */
6597 struct cmd_showportall_result {
6598 	cmdline_fixed_string_t show;
6599 	cmdline_fixed_string_t port;
6600 	cmdline_fixed_string_t what;
6601 	cmdline_fixed_string_t all;
6602 };
6603 
6604 static void cmd_showportall_parsed(void *parsed_result,
6605 				__attribute__((unused)) struct cmdline *cl,
6606 				__attribute__((unused)) void *data)
6607 {
6608 	portid_t i;
6609 
6610 	struct cmd_showportall_result *res = parsed_result;
6611 	if (!strcmp(res->show, "clear")) {
6612 		if (!strcmp(res->what, "stats"))
6613 			RTE_ETH_FOREACH_DEV(i)
6614 				nic_stats_clear(i);
6615 		else if (!strcmp(res->what, "xstats"))
6616 			RTE_ETH_FOREACH_DEV(i)
6617 				nic_xstats_clear(i);
6618 	} else if (!strcmp(res->what, "info"))
6619 		RTE_ETH_FOREACH_DEV(i)
6620 			port_infos_display(i);
6621 	else if (!strcmp(res->what, "stats"))
6622 		RTE_ETH_FOREACH_DEV(i)
6623 			nic_stats_display(i);
6624 	else if (!strcmp(res->what, "xstats"))
6625 		RTE_ETH_FOREACH_DEV(i)
6626 			nic_xstats_display(i);
6627 	else if (!strcmp(res->what, "fdir"))
6628 		RTE_ETH_FOREACH_DEV(i)
6629 			fdir_get_infos(i);
6630 	else if (!strcmp(res->what, "stat_qmap"))
6631 		RTE_ETH_FOREACH_DEV(i)
6632 			nic_stats_mapping_display(i);
6633 	else if (!strcmp(res->what, "dcb_tc"))
6634 		RTE_ETH_FOREACH_DEV(i)
6635 			port_dcb_info_display(i);
6636 	else if (!strcmp(res->what, "cap"))
6637 		RTE_ETH_FOREACH_DEV(i)
6638 			port_offload_cap_display(i);
6639 }
6640 
6641 cmdline_parse_token_string_t cmd_showportall_show =
6642 	TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
6643 				 "show#clear");
6644 cmdline_parse_token_string_t cmd_showportall_port =
6645 	TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
6646 cmdline_parse_token_string_t cmd_showportall_what =
6647 	TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
6648 				 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
6649 cmdline_parse_token_string_t cmd_showportall_all =
6650 	TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
6651 cmdline_parse_inst_t cmd_showportall = {
6652 	.f = cmd_showportall_parsed,
6653 	.data = NULL,
6654 	.help_str = "show|clear port "
6655 		"info|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
6656 	.tokens = {
6657 		(void *)&cmd_showportall_show,
6658 		(void *)&cmd_showportall_port,
6659 		(void *)&cmd_showportall_what,
6660 		(void *)&cmd_showportall_all,
6661 		NULL,
6662 	},
6663 };
6664 
6665 /* *** SHOW PORT INFO *** */
6666 struct cmd_showport_result {
6667 	cmdline_fixed_string_t show;
6668 	cmdline_fixed_string_t port;
6669 	cmdline_fixed_string_t what;
6670 	uint16_t portnum;
6671 };
6672 
6673 static void cmd_showport_parsed(void *parsed_result,
6674 				__attribute__((unused)) struct cmdline *cl,
6675 				__attribute__((unused)) void *data)
6676 {
6677 	struct cmd_showport_result *res = parsed_result;
6678 	if (!strcmp(res->show, "clear")) {
6679 		if (!strcmp(res->what, "stats"))
6680 			nic_stats_clear(res->portnum);
6681 		else if (!strcmp(res->what, "xstats"))
6682 			nic_xstats_clear(res->portnum);
6683 	} else if (!strcmp(res->what, "info"))
6684 		port_infos_display(res->portnum);
6685 	else if (!strcmp(res->what, "stats"))
6686 		nic_stats_display(res->portnum);
6687 	else if (!strcmp(res->what, "xstats"))
6688 		nic_xstats_display(res->portnum);
6689 	else if (!strcmp(res->what, "fdir"))
6690 		 fdir_get_infos(res->portnum);
6691 	else if (!strcmp(res->what, "stat_qmap"))
6692 		nic_stats_mapping_display(res->portnum);
6693 	else if (!strcmp(res->what, "dcb_tc"))
6694 		port_dcb_info_display(res->portnum);
6695 	else if (!strcmp(res->what, "cap"))
6696 		port_offload_cap_display(res->portnum);
6697 }
6698 
6699 cmdline_parse_token_string_t cmd_showport_show =
6700 	TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
6701 				 "show#clear");
6702 cmdline_parse_token_string_t cmd_showport_port =
6703 	TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
6704 cmdline_parse_token_string_t cmd_showport_what =
6705 	TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
6706 				 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
6707 cmdline_parse_token_num_t cmd_showport_portnum =
6708 	TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
6709 
6710 cmdline_parse_inst_t cmd_showport = {
6711 	.f = cmd_showport_parsed,
6712 	.data = NULL,
6713 	.help_str = "show|clear port "
6714 		"info|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
6715 		"<port_id>",
6716 	.tokens = {
6717 		(void *)&cmd_showport_show,
6718 		(void *)&cmd_showport_port,
6719 		(void *)&cmd_showport_what,
6720 		(void *)&cmd_showport_portnum,
6721 		NULL,
6722 	},
6723 };
6724 
6725 /* *** SHOW QUEUE INFO *** */
6726 struct cmd_showqueue_result {
6727 	cmdline_fixed_string_t show;
6728 	cmdline_fixed_string_t type;
6729 	cmdline_fixed_string_t what;
6730 	uint16_t portnum;
6731 	uint16_t queuenum;
6732 };
6733 
6734 static void
6735 cmd_showqueue_parsed(void *parsed_result,
6736 	__attribute__((unused)) struct cmdline *cl,
6737 	__attribute__((unused)) void *data)
6738 {
6739 	struct cmd_showqueue_result *res = parsed_result;
6740 
6741 	if (!strcmp(res->type, "rxq"))
6742 		rx_queue_infos_display(res->portnum, res->queuenum);
6743 	else if (!strcmp(res->type, "txq"))
6744 		tx_queue_infos_display(res->portnum, res->queuenum);
6745 }
6746 
6747 cmdline_parse_token_string_t cmd_showqueue_show =
6748 	TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
6749 cmdline_parse_token_string_t cmd_showqueue_type =
6750 	TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
6751 cmdline_parse_token_string_t cmd_showqueue_what =
6752 	TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
6753 cmdline_parse_token_num_t cmd_showqueue_portnum =
6754 	TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16);
6755 cmdline_parse_token_num_t cmd_showqueue_queuenum =
6756 	TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
6757 
6758 cmdline_parse_inst_t cmd_showqueue = {
6759 	.f = cmd_showqueue_parsed,
6760 	.data = NULL,
6761 	.help_str = "show rxq|txq info <port_id> <queue_id>",
6762 	.tokens = {
6763 		(void *)&cmd_showqueue_show,
6764 		(void *)&cmd_showqueue_type,
6765 		(void *)&cmd_showqueue_what,
6766 		(void *)&cmd_showqueue_portnum,
6767 		(void *)&cmd_showqueue_queuenum,
6768 		NULL,
6769 	},
6770 };
6771 
6772 /* *** READ PORT REGISTER *** */
6773 struct cmd_read_reg_result {
6774 	cmdline_fixed_string_t read;
6775 	cmdline_fixed_string_t reg;
6776 	portid_t port_id;
6777 	uint32_t reg_off;
6778 };
6779 
6780 static void
6781 cmd_read_reg_parsed(void *parsed_result,
6782 		    __attribute__((unused)) struct cmdline *cl,
6783 		    __attribute__((unused)) void *data)
6784 {
6785 	struct cmd_read_reg_result *res = parsed_result;
6786 	port_reg_display(res->port_id, res->reg_off);
6787 }
6788 
6789 cmdline_parse_token_string_t cmd_read_reg_read =
6790 	TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
6791 cmdline_parse_token_string_t cmd_read_reg_reg =
6792 	TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
6793 cmdline_parse_token_num_t cmd_read_reg_port_id =
6794 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16);
6795 cmdline_parse_token_num_t cmd_read_reg_reg_off =
6796 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
6797 
6798 cmdline_parse_inst_t cmd_read_reg = {
6799 	.f = cmd_read_reg_parsed,
6800 	.data = NULL,
6801 	.help_str = "read reg <port_id> <reg_off>",
6802 	.tokens = {
6803 		(void *)&cmd_read_reg_read,
6804 		(void *)&cmd_read_reg_reg,
6805 		(void *)&cmd_read_reg_port_id,
6806 		(void *)&cmd_read_reg_reg_off,
6807 		NULL,
6808 	},
6809 };
6810 
6811 /* *** READ PORT REGISTER BIT FIELD *** */
6812 struct cmd_read_reg_bit_field_result {
6813 	cmdline_fixed_string_t read;
6814 	cmdline_fixed_string_t regfield;
6815 	portid_t port_id;
6816 	uint32_t reg_off;
6817 	uint8_t bit1_pos;
6818 	uint8_t bit2_pos;
6819 };
6820 
6821 static void
6822 cmd_read_reg_bit_field_parsed(void *parsed_result,
6823 			      __attribute__((unused)) struct cmdline *cl,
6824 			      __attribute__((unused)) void *data)
6825 {
6826 	struct cmd_read_reg_bit_field_result *res = parsed_result;
6827 	port_reg_bit_field_display(res->port_id, res->reg_off,
6828 				   res->bit1_pos, res->bit2_pos);
6829 }
6830 
6831 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
6832 	TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
6833 				 "read");
6834 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
6835 	TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
6836 				 regfield, "regfield");
6837 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
6838 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
6839 			      UINT16);
6840 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
6841 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
6842 			      UINT32);
6843 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
6844 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
6845 			      UINT8);
6846 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
6847 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
6848 			      UINT8);
6849 
6850 cmdline_parse_inst_t cmd_read_reg_bit_field = {
6851 	.f = cmd_read_reg_bit_field_parsed,
6852 	.data = NULL,
6853 	.help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
6854 	"Read register bit field between bit_x and bit_y included",
6855 	.tokens = {
6856 		(void *)&cmd_read_reg_bit_field_read,
6857 		(void *)&cmd_read_reg_bit_field_regfield,
6858 		(void *)&cmd_read_reg_bit_field_port_id,
6859 		(void *)&cmd_read_reg_bit_field_reg_off,
6860 		(void *)&cmd_read_reg_bit_field_bit1_pos,
6861 		(void *)&cmd_read_reg_bit_field_bit2_pos,
6862 		NULL,
6863 	},
6864 };
6865 
6866 /* *** READ PORT REGISTER BIT *** */
6867 struct cmd_read_reg_bit_result {
6868 	cmdline_fixed_string_t read;
6869 	cmdline_fixed_string_t regbit;
6870 	portid_t port_id;
6871 	uint32_t reg_off;
6872 	uint8_t bit_pos;
6873 };
6874 
6875 static void
6876 cmd_read_reg_bit_parsed(void *parsed_result,
6877 			__attribute__((unused)) struct cmdline *cl,
6878 			__attribute__((unused)) void *data)
6879 {
6880 	struct cmd_read_reg_bit_result *res = parsed_result;
6881 	port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
6882 }
6883 
6884 cmdline_parse_token_string_t cmd_read_reg_bit_read =
6885 	TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
6886 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
6887 	TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
6888 				 regbit, "regbit");
6889 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
6890 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16);
6891 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
6892 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
6893 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
6894 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
6895 
6896 cmdline_parse_inst_t cmd_read_reg_bit = {
6897 	.f = cmd_read_reg_bit_parsed,
6898 	.data = NULL,
6899 	.help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
6900 	.tokens = {
6901 		(void *)&cmd_read_reg_bit_read,
6902 		(void *)&cmd_read_reg_bit_regbit,
6903 		(void *)&cmd_read_reg_bit_port_id,
6904 		(void *)&cmd_read_reg_bit_reg_off,
6905 		(void *)&cmd_read_reg_bit_bit_pos,
6906 		NULL,
6907 	},
6908 };
6909 
6910 /* *** WRITE PORT REGISTER *** */
6911 struct cmd_write_reg_result {
6912 	cmdline_fixed_string_t write;
6913 	cmdline_fixed_string_t reg;
6914 	portid_t port_id;
6915 	uint32_t reg_off;
6916 	uint32_t value;
6917 };
6918 
6919 static void
6920 cmd_write_reg_parsed(void *parsed_result,
6921 		     __attribute__((unused)) struct cmdline *cl,
6922 		     __attribute__((unused)) void *data)
6923 {
6924 	struct cmd_write_reg_result *res = parsed_result;
6925 	port_reg_set(res->port_id, res->reg_off, res->value);
6926 }
6927 
6928 cmdline_parse_token_string_t cmd_write_reg_write =
6929 	TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
6930 cmdline_parse_token_string_t cmd_write_reg_reg =
6931 	TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
6932 cmdline_parse_token_num_t cmd_write_reg_port_id =
6933 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16);
6934 cmdline_parse_token_num_t cmd_write_reg_reg_off =
6935 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
6936 cmdline_parse_token_num_t cmd_write_reg_value =
6937 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
6938 
6939 cmdline_parse_inst_t cmd_write_reg = {
6940 	.f = cmd_write_reg_parsed,
6941 	.data = NULL,
6942 	.help_str = "write reg <port_id> <reg_off> <reg_value>",
6943 	.tokens = {
6944 		(void *)&cmd_write_reg_write,
6945 		(void *)&cmd_write_reg_reg,
6946 		(void *)&cmd_write_reg_port_id,
6947 		(void *)&cmd_write_reg_reg_off,
6948 		(void *)&cmd_write_reg_value,
6949 		NULL,
6950 	},
6951 };
6952 
6953 /* *** WRITE PORT REGISTER BIT FIELD *** */
6954 struct cmd_write_reg_bit_field_result {
6955 	cmdline_fixed_string_t write;
6956 	cmdline_fixed_string_t regfield;
6957 	portid_t port_id;
6958 	uint32_t reg_off;
6959 	uint8_t bit1_pos;
6960 	uint8_t bit2_pos;
6961 	uint32_t value;
6962 };
6963 
6964 static void
6965 cmd_write_reg_bit_field_parsed(void *parsed_result,
6966 			       __attribute__((unused)) struct cmdline *cl,
6967 			       __attribute__((unused)) void *data)
6968 {
6969 	struct cmd_write_reg_bit_field_result *res = parsed_result;
6970 	port_reg_bit_field_set(res->port_id, res->reg_off,
6971 			  res->bit1_pos, res->bit2_pos, res->value);
6972 }
6973 
6974 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
6975 	TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
6976 				 "write");
6977 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
6978 	TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
6979 				 regfield, "regfield");
6980 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
6981 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
6982 			      UINT16);
6983 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
6984 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
6985 			      UINT32);
6986 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
6987 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
6988 			      UINT8);
6989 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
6990 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
6991 			      UINT8);
6992 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
6993 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
6994 			      UINT32);
6995 
6996 cmdline_parse_inst_t cmd_write_reg_bit_field = {
6997 	.f = cmd_write_reg_bit_field_parsed,
6998 	.data = NULL,
6999 	.help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
7000 		"<reg_value>: "
7001 		"Set register bit field between bit_x and bit_y included",
7002 	.tokens = {
7003 		(void *)&cmd_write_reg_bit_field_write,
7004 		(void *)&cmd_write_reg_bit_field_regfield,
7005 		(void *)&cmd_write_reg_bit_field_port_id,
7006 		(void *)&cmd_write_reg_bit_field_reg_off,
7007 		(void *)&cmd_write_reg_bit_field_bit1_pos,
7008 		(void *)&cmd_write_reg_bit_field_bit2_pos,
7009 		(void *)&cmd_write_reg_bit_field_value,
7010 		NULL,
7011 	},
7012 };
7013 
7014 /* *** WRITE PORT REGISTER BIT *** */
7015 struct cmd_write_reg_bit_result {
7016 	cmdline_fixed_string_t write;
7017 	cmdline_fixed_string_t regbit;
7018 	portid_t port_id;
7019 	uint32_t reg_off;
7020 	uint8_t bit_pos;
7021 	uint8_t value;
7022 };
7023 
7024 static void
7025 cmd_write_reg_bit_parsed(void *parsed_result,
7026 			 __attribute__((unused)) struct cmdline *cl,
7027 			 __attribute__((unused)) void *data)
7028 {
7029 	struct cmd_write_reg_bit_result *res = parsed_result;
7030 	port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
7031 }
7032 
7033 cmdline_parse_token_string_t cmd_write_reg_bit_write =
7034 	TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
7035 				 "write");
7036 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
7037 	TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
7038 				 regbit, "regbit");
7039 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
7040 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16);
7041 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
7042 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
7043 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
7044 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
7045 cmdline_parse_token_num_t cmd_write_reg_bit_value =
7046 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
7047 
7048 cmdline_parse_inst_t cmd_write_reg_bit = {
7049 	.f = cmd_write_reg_bit_parsed,
7050 	.data = NULL,
7051 	.help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
7052 		"0 <= bit_x <= 31",
7053 	.tokens = {
7054 		(void *)&cmd_write_reg_bit_write,
7055 		(void *)&cmd_write_reg_bit_regbit,
7056 		(void *)&cmd_write_reg_bit_port_id,
7057 		(void *)&cmd_write_reg_bit_reg_off,
7058 		(void *)&cmd_write_reg_bit_bit_pos,
7059 		(void *)&cmd_write_reg_bit_value,
7060 		NULL,
7061 	},
7062 };
7063 
7064 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
7065 struct cmd_read_rxd_txd_result {
7066 	cmdline_fixed_string_t read;
7067 	cmdline_fixed_string_t rxd_txd;
7068 	portid_t port_id;
7069 	uint16_t queue_id;
7070 	uint16_t desc_id;
7071 };
7072 
7073 static void
7074 cmd_read_rxd_txd_parsed(void *parsed_result,
7075 			__attribute__((unused)) struct cmdline *cl,
7076 			__attribute__((unused)) void *data)
7077 {
7078 	struct cmd_read_rxd_txd_result *res = parsed_result;
7079 
7080 	if (!strcmp(res->rxd_txd, "rxd"))
7081 		rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7082 	else if (!strcmp(res->rxd_txd, "txd"))
7083 		tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7084 }
7085 
7086 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
7087 	TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
7088 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
7089 	TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
7090 				 "rxd#txd");
7091 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
7092 	TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16);
7093 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
7094 	TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
7095 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
7096 	TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
7097 
7098 cmdline_parse_inst_t cmd_read_rxd_txd = {
7099 	.f = cmd_read_rxd_txd_parsed,
7100 	.data = NULL,
7101 	.help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
7102 	.tokens = {
7103 		(void *)&cmd_read_rxd_txd_read,
7104 		(void *)&cmd_read_rxd_txd_rxd_txd,
7105 		(void *)&cmd_read_rxd_txd_port_id,
7106 		(void *)&cmd_read_rxd_txd_queue_id,
7107 		(void *)&cmd_read_rxd_txd_desc_id,
7108 		NULL,
7109 	},
7110 };
7111 
7112 /* *** QUIT *** */
7113 struct cmd_quit_result {
7114 	cmdline_fixed_string_t quit;
7115 };
7116 
7117 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
7118 			    struct cmdline *cl,
7119 			    __attribute__((unused)) void *data)
7120 {
7121 	pmd_test_exit();
7122 	cmdline_quit(cl);
7123 }
7124 
7125 cmdline_parse_token_string_t cmd_quit_quit =
7126 	TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
7127 
7128 cmdline_parse_inst_t cmd_quit = {
7129 	.f = cmd_quit_parsed,
7130 	.data = NULL,
7131 	.help_str = "quit: Exit application",
7132 	.tokens = {
7133 		(void *)&cmd_quit_quit,
7134 		NULL,
7135 	},
7136 };
7137 
7138 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
7139 struct cmd_mac_addr_result {
7140 	cmdline_fixed_string_t mac_addr_cmd;
7141 	cmdline_fixed_string_t what;
7142 	uint16_t port_num;
7143 	struct ether_addr address;
7144 };
7145 
7146 static void cmd_mac_addr_parsed(void *parsed_result,
7147 		__attribute__((unused)) struct cmdline *cl,
7148 		__attribute__((unused)) void *data)
7149 {
7150 	struct cmd_mac_addr_result *res = parsed_result;
7151 	int ret;
7152 
7153 	if (strcmp(res->what, "add") == 0)
7154 		ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
7155 	else if (strcmp(res->what, "set") == 0)
7156 		ret = rte_eth_dev_default_mac_addr_set(res->port_num,
7157 						       &res->address);
7158 	else
7159 		ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
7160 
7161 	/* check the return value and print it if is < 0 */
7162 	if(ret < 0)
7163 		printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
7164 
7165 }
7166 
7167 cmdline_parse_token_string_t cmd_mac_addr_cmd =
7168 	TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
7169 				"mac_addr");
7170 cmdline_parse_token_string_t cmd_mac_addr_what =
7171 	TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
7172 				"add#remove#set");
7173 cmdline_parse_token_num_t cmd_mac_addr_portnum =
7174 		TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
7175 					UINT16);
7176 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
7177 		TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
7178 
7179 cmdline_parse_inst_t cmd_mac_addr = {
7180 	.f = cmd_mac_addr_parsed,
7181 	.data = (void *)0,
7182 	.help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
7183 			"Add/Remove/Set MAC address on port_id",
7184 	.tokens = {
7185 		(void *)&cmd_mac_addr_cmd,
7186 		(void *)&cmd_mac_addr_what,
7187 		(void *)&cmd_mac_addr_portnum,
7188 		(void *)&cmd_mac_addr_addr,
7189 		NULL,
7190 	},
7191 };
7192 
7193 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
7194 struct cmd_eth_peer_result {
7195 	cmdline_fixed_string_t set;
7196 	cmdline_fixed_string_t eth_peer;
7197 	portid_t port_id;
7198 	cmdline_fixed_string_t peer_addr;
7199 };
7200 
7201 static void cmd_set_eth_peer_parsed(void *parsed_result,
7202 			__attribute__((unused)) struct cmdline *cl,
7203 			__attribute__((unused)) void *data)
7204 {
7205 		struct cmd_eth_peer_result *res = parsed_result;
7206 
7207 		if (test_done == 0) {
7208 			printf("Please stop forwarding first\n");
7209 			return;
7210 		}
7211 		if (!strcmp(res->eth_peer, "eth-peer")) {
7212 			set_fwd_eth_peer(res->port_id, res->peer_addr);
7213 			fwd_config_setup();
7214 		}
7215 }
7216 cmdline_parse_token_string_t cmd_eth_peer_set =
7217 	TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
7218 cmdline_parse_token_string_t cmd_eth_peer =
7219 	TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
7220 cmdline_parse_token_num_t cmd_eth_peer_port_id =
7221 	TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, UINT16);
7222 cmdline_parse_token_string_t cmd_eth_peer_addr =
7223 	TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
7224 
7225 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
7226 	.f = cmd_set_eth_peer_parsed,
7227 	.data = NULL,
7228 	.help_str = "set eth-peer <port_id> <peer_mac>",
7229 	.tokens = {
7230 		(void *)&cmd_eth_peer_set,
7231 		(void *)&cmd_eth_peer,
7232 		(void *)&cmd_eth_peer_port_id,
7233 		(void *)&cmd_eth_peer_addr,
7234 		NULL,
7235 	},
7236 };
7237 
7238 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
7239 struct cmd_set_qmap_result {
7240 	cmdline_fixed_string_t set;
7241 	cmdline_fixed_string_t qmap;
7242 	cmdline_fixed_string_t what;
7243 	portid_t port_id;
7244 	uint16_t queue_id;
7245 	uint8_t map_value;
7246 };
7247 
7248 static void
7249 cmd_set_qmap_parsed(void *parsed_result,
7250 		       __attribute__((unused)) struct cmdline *cl,
7251 		       __attribute__((unused)) void *data)
7252 {
7253 	struct cmd_set_qmap_result *res = parsed_result;
7254 	int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
7255 
7256 	set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
7257 }
7258 
7259 cmdline_parse_token_string_t cmd_setqmap_set =
7260 	TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7261 				 set, "set");
7262 cmdline_parse_token_string_t cmd_setqmap_qmap =
7263 	TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7264 				 qmap, "stat_qmap");
7265 cmdline_parse_token_string_t cmd_setqmap_what =
7266 	TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7267 				 what, "tx#rx");
7268 cmdline_parse_token_num_t cmd_setqmap_portid =
7269 	TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7270 			      port_id, UINT16);
7271 cmdline_parse_token_num_t cmd_setqmap_queueid =
7272 	TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7273 			      queue_id, UINT16);
7274 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
7275 	TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7276 			      map_value, UINT8);
7277 
7278 cmdline_parse_inst_t cmd_set_qmap = {
7279 	.f = cmd_set_qmap_parsed,
7280 	.data = NULL,
7281 	.help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
7282 		"Set statistics mapping value on tx|rx queue_id of port_id",
7283 	.tokens = {
7284 		(void *)&cmd_setqmap_set,
7285 		(void *)&cmd_setqmap_qmap,
7286 		(void *)&cmd_setqmap_what,
7287 		(void *)&cmd_setqmap_portid,
7288 		(void *)&cmd_setqmap_queueid,
7289 		(void *)&cmd_setqmap_mapvalue,
7290 		NULL,
7291 	},
7292 };
7293 
7294 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS  DISPLAY *** */
7295 struct cmd_set_xstats_hide_zero_result {
7296 	cmdline_fixed_string_t keyword;
7297 	cmdline_fixed_string_t name;
7298 	cmdline_fixed_string_t on_off;
7299 };
7300 
7301 static void
7302 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
7303 			__attribute__((unused)) struct cmdline *cl,
7304 			__attribute__((unused)) void *data)
7305 {
7306 	struct cmd_set_xstats_hide_zero_result *res;
7307 	uint16_t on_off = 0;
7308 
7309 	res = parsed_result;
7310 	on_off = !strcmp(res->on_off, "on") ? 1 : 0;
7311 	set_xstats_hide_zero(on_off);
7312 }
7313 
7314 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
7315 	TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7316 				 keyword, "set");
7317 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
7318 	TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7319 				 name, "xstats-hide-zero");
7320 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
7321 	TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7322 				 on_off, "on#off");
7323 
7324 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
7325 	.f = cmd_set_xstats_hide_zero_parsed,
7326 	.data = NULL,
7327 	.help_str = "set xstats-hide-zero on|off",
7328 	.tokens = {
7329 		(void *)&cmd_set_xstats_hide_zero_keyword,
7330 		(void *)&cmd_set_xstats_hide_zero_name,
7331 		(void *)&cmd_set_xstats_hide_zero_on_off,
7332 		NULL,
7333 	},
7334 };
7335 
7336 /* *** CONFIGURE UNICAST HASH TABLE *** */
7337 struct cmd_set_uc_hash_table {
7338 	cmdline_fixed_string_t set;
7339 	cmdline_fixed_string_t port;
7340 	portid_t port_id;
7341 	cmdline_fixed_string_t what;
7342 	struct ether_addr address;
7343 	cmdline_fixed_string_t mode;
7344 };
7345 
7346 static void
7347 cmd_set_uc_hash_parsed(void *parsed_result,
7348 		       __attribute__((unused)) struct cmdline *cl,
7349 		       __attribute__((unused)) void *data)
7350 {
7351 	int ret=0;
7352 	struct cmd_set_uc_hash_table *res = parsed_result;
7353 
7354 	int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7355 
7356 	if (strcmp(res->what, "uta") == 0)
7357 		ret = rte_eth_dev_uc_hash_table_set(res->port_id,
7358 						&res->address,(uint8_t)is_on);
7359 	if (ret < 0)
7360 		printf("bad unicast hash table parameter, return code = %d \n", ret);
7361 
7362 }
7363 
7364 cmdline_parse_token_string_t cmd_set_uc_hash_set =
7365 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7366 				 set, "set");
7367 cmdline_parse_token_string_t cmd_set_uc_hash_port =
7368 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7369 				 port, "port");
7370 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
7371 	TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
7372 			      port_id, UINT16);
7373 cmdline_parse_token_string_t cmd_set_uc_hash_what =
7374 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7375 				 what, "uta");
7376 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
7377 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
7378 				address);
7379 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
7380 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7381 				 mode, "on#off");
7382 
7383 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
7384 	.f = cmd_set_uc_hash_parsed,
7385 	.data = NULL,
7386 	.help_str = "set port <port_id> uta <mac_addr> on|off)",
7387 	.tokens = {
7388 		(void *)&cmd_set_uc_hash_set,
7389 		(void *)&cmd_set_uc_hash_port,
7390 		(void *)&cmd_set_uc_hash_portid,
7391 		(void *)&cmd_set_uc_hash_what,
7392 		(void *)&cmd_set_uc_hash_mac,
7393 		(void *)&cmd_set_uc_hash_mode,
7394 		NULL,
7395 	},
7396 };
7397 
7398 struct cmd_set_uc_all_hash_table {
7399 	cmdline_fixed_string_t set;
7400 	cmdline_fixed_string_t port;
7401 	portid_t port_id;
7402 	cmdline_fixed_string_t what;
7403 	cmdline_fixed_string_t value;
7404 	cmdline_fixed_string_t mode;
7405 };
7406 
7407 static void
7408 cmd_set_uc_all_hash_parsed(void *parsed_result,
7409 		       __attribute__((unused)) struct cmdline *cl,
7410 		       __attribute__((unused)) void *data)
7411 {
7412 	int ret=0;
7413 	struct cmd_set_uc_all_hash_table *res = parsed_result;
7414 
7415 	int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7416 
7417 	if ((strcmp(res->what, "uta") == 0) &&
7418 		(strcmp(res->value, "all") == 0))
7419 		ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
7420 	if (ret < 0)
7421 		printf("bad unicast hash table parameter,"
7422 			"return code = %d \n", ret);
7423 }
7424 
7425 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
7426 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7427 				 set, "set");
7428 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
7429 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7430 				 port, "port");
7431 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
7432 	TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
7433 			      port_id, UINT16);
7434 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
7435 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7436 				 what, "uta");
7437 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
7438 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7439 				value,"all");
7440 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
7441 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7442 				 mode, "on#off");
7443 
7444 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
7445 	.f = cmd_set_uc_all_hash_parsed,
7446 	.data = NULL,
7447 	.help_str = "set port <port_id> uta all on|off",
7448 	.tokens = {
7449 		(void *)&cmd_set_uc_all_hash_set,
7450 		(void *)&cmd_set_uc_all_hash_port,
7451 		(void *)&cmd_set_uc_all_hash_portid,
7452 		(void *)&cmd_set_uc_all_hash_what,
7453 		(void *)&cmd_set_uc_all_hash_value,
7454 		(void *)&cmd_set_uc_all_hash_mode,
7455 		NULL,
7456 	},
7457 };
7458 
7459 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
7460 struct cmd_set_vf_macvlan_filter {
7461 	cmdline_fixed_string_t set;
7462 	cmdline_fixed_string_t port;
7463 	portid_t port_id;
7464 	cmdline_fixed_string_t vf;
7465 	uint8_t vf_id;
7466 	struct ether_addr address;
7467 	cmdline_fixed_string_t filter_type;
7468 	cmdline_fixed_string_t mode;
7469 };
7470 
7471 static void
7472 cmd_set_vf_macvlan_parsed(void *parsed_result,
7473 		       __attribute__((unused)) struct cmdline *cl,
7474 		       __attribute__((unused)) void *data)
7475 {
7476 	int is_on, ret = 0;
7477 	struct cmd_set_vf_macvlan_filter *res = parsed_result;
7478 	struct rte_eth_mac_filter filter;
7479 
7480 	memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
7481 
7482 	rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
7483 
7484 	/* set VF MAC filter */
7485 	filter.is_vf = 1;
7486 
7487 	/* set VF ID */
7488 	filter.dst_id = res->vf_id;
7489 
7490 	if (!strcmp(res->filter_type, "exact-mac"))
7491 		filter.filter_type = RTE_MAC_PERFECT_MATCH;
7492 	else if (!strcmp(res->filter_type, "exact-mac-vlan"))
7493 		filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
7494 	else if (!strcmp(res->filter_type, "hashmac"))
7495 		filter.filter_type = RTE_MAC_HASH_MATCH;
7496 	else if (!strcmp(res->filter_type, "hashmac-vlan"))
7497 		filter.filter_type = RTE_MACVLAN_HASH_MATCH;
7498 
7499 	is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7500 
7501 	if (is_on)
7502 		ret = rte_eth_dev_filter_ctrl(res->port_id,
7503 					RTE_ETH_FILTER_MACVLAN,
7504 					RTE_ETH_FILTER_ADD,
7505 					 &filter);
7506 	else
7507 		ret = rte_eth_dev_filter_ctrl(res->port_id,
7508 					RTE_ETH_FILTER_MACVLAN,
7509 					RTE_ETH_FILTER_DELETE,
7510 					&filter);
7511 
7512 	if (ret < 0)
7513 		printf("bad set MAC hash parameter, return code = %d\n", ret);
7514 
7515 }
7516 
7517 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
7518 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7519 				 set, "set");
7520 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
7521 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7522 				 port, "port");
7523 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
7524 	TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7525 			      port_id, UINT16);
7526 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
7527 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7528 				 vf, "vf");
7529 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
7530 	TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7531 				vf_id, UINT8);
7532 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
7533 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7534 				address);
7535 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
7536 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7537 				filter_type, "exact-mac#exact-mac-vlan"
7538 				"#hashmac#hashmac-vlan");
7539 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
7540 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7541 				 mode, "on#off");
7542 
7543 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
7544 	.f = cmd_set_vf_macvlan_parsed,
7545 	.data = NULL,
7546 	.help_str = "set port <port_id> vf <vf_id> <mac_addr> "
7547 		"exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
7548 		"Exact match rule: exact match of MAC or MAC and VLAN; "
7549 		"hash match rule: hash match of MAC and exact match of VLAN",
7550 	.tokens = {
7551 		(void *)&cmd_set_vf_macvlan_set,
7552 		(void *)&cmd_set_vf_macvlan_port,
7553 		(void *)&cmd_set_vf_macvlan_portid,
7554 		(void *)&cmd_set_vf_macvlan_vf,
7555 		(void *)&cmd_set_vf_macvlan_vf_id,
7556 		(void *)&cmd_set_vf_macvlan_mac,
7557 		(void *)&cmd_set_vf_macvlan_filter_type,
7558 		(void *)&cmd_set_vf_macvlan_mode,
7559 		NULL,
7560 	},
7561 };
7562 
7563 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
7564 struct cmd_set_vf_traffic {
7565 	cmdline_fixed_string_t set;
7566 	cmdline_fixed_string_t port;
7567 	portid_t port_id;
7568 	cmdline_fixed_string_t vf;
7569 	uint8_t vf_id;
7570 	cmdline_fixed_string_t what;
7571 	cmdline_fixed_string_t mode;
7572 };
7573 
7574 static void
7575 cmd_set_vf_traffic_parsed(void *parsed_result,
7576 		       __attribute__((unused)) struct cmdline *cl,
7577 		       __attribute__((unused)) void *data)
7578 {
7579 	struct cmd_set_vf_traffic *res = parsed_result;
7580 	int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
7581 	int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7582 
7583 	set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
7584 }
7585 
7586 cmdline_parse_token_string_t cmd_setvf_traffic_set =
7587 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7588 				 set, "set");
7589 cmdline_parse_token_string_t cmd_setvf_traffic_port =
7590 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7591 				 port, "port");
7592 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
7593 	TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
7594 			      port_id, UINT16);
7595 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
7596 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7597 				 vf, "vf");
7598 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
7599 	TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
7600 			      vf_id, UINT8);
7601 cmdline_parse_token_string_t cmd_setvf_traffic_what =
7602 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7603 				 what, "tx#rx");
7604 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
7605 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7606 				 mode, "on#off");
7607 
7608 cmdline_parse_inst_t cmd_set_vf_traffic = {
7609 	.f = cmd_set_vf_traffic_parsed,
7610 	.data = NULL,
7611 	.help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
7612 	.tokens = {
7613 		(void *)&cmd_setvf_traffic_set,
7614 		(void *)&cmd_setvf_traffic_port,
7615 		(void *)&cmd_setvf_traffic_portid,
7616 		(void *)&cmd_setvf_traffic_vf,
7617 		(void *)&cmd_setvf_traffic_vfid,
7618 		(void *)&cmd_setvf_traffic_what,
7619 		(void *)&cmd_setvf_traffic_mode,
7620 		NULL,
7621 	},
7622 };
7623 
7624 /* *** CONFIGURE VF RECEIVE MODE *** */
7625 struct cmd_set_vf_rxmode {
7626 	cmdline_fixed_string_t set;
7627 	cmdline_fixed_string_t port;
7628 	portid_t port_id;
7629 	cmdline_fixed_string_t vf;
7630 	uint8_t vf_id;
7631 	cmdline_fixed_string_t what;
7632 	cmdline_fixed_string_t mode;
7633 	cmdline_fixed_string_t on;
7634 };
7635 
7636 static void
7637 cmd_set_vf_rxmode_parsed(void *parsed_result,
7638 		       __attribute__((unused)) struct cmdline *cl,
7639 		       __attribute__((unused)) void *data)
7640 {
7641 	int ret = -ENOTSUP;
7642 	uint16_t rx_mode = 0;
7643 	struct cmd_set_vf_rxmode *res = parsed_result;
7644 
7645 	int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
7646 	if (!strcmp(res->what,"rxmode")) {
7647 		if (!strcmp(res->mode, "AUPE"))
7648 			rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
7649 		else if (!strcmp(res->mode, "ROPE"))
7650 			rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
7651 		else if (!strcmp(res->mode, "BAM"))
7652 			rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
7653 		else if (!strncmp(res->mode, "MPE",3))
7654 			rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
7655 	}
7656 
7657 	RTE_SET_USED(is_on);
7658 
7659 #ifdef RTE_LIBRTE_IXGBE_PMD
7660 	if (ret == -ENOTSUP)
7661 		ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
7662 						  rx_mode, (uint8_t)is_on);
7663 #endif
7664 #ifdef RTE_LIBRTE_BNXT_PMD
7665 	if (ret == -ENOTSUP)
7666 		ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
7667 						 rx_mode, (uint8_t)is_on);
7668 #endif
7669 	if (ret < 0)
7670 		printf("bad VF receive mode parameter, return code = %d \n",
7671 		ret);
7672 }
7673 
7674 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
7675 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7676 				 set, "set");
7677 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
7678 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7679 				 port, "port");
7680 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
7681 	TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
7682 			      port_id, UINT16);
7683 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
7684 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7685 				 vf, "vf");
7686 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
7687 	TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
7688 			      vf_id, UINT8);
7689 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
7690 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7691 				 what, "rxmode");
7692 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
7693 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7694 				 mode, "AUPE#ROPE#BAM#MPE");
7695 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
7696 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7697 				 on, "on#off");
7698 
7699 cmdline_parse_inst_t cmd_set_vf_rxmode = {
7700 	.f = cmd_set_vf_rxmode_parsed,
7701 	.data = NULL,
7702 	.help_str = "set port <port_id> vf <vf_id> rxmode "
7703 		"AUPE|ROPE|BAM|MPE on|off",
7704 	.tokens = {
7705 		(void *)&cmd_set_vf_rxmode_set,
7706 		(void *)&cmd_set_vf_rxmode_port,
7707 		(void *)&cmd_set_vf_rxmode_portid,
7708 		(void *)&cmd_set_vf_rxmode_vf,
7709 		(void *)&cmd_set_vf_rxmode_vfid,
7710 		(void *)&cmd_set_vf_rxmode_what,
7711 		(void *)&cmd_set_vf_rxmode_mode,
7712 		(void *)&cmd_set_vf_rxmode_on,
7713 		NULL,
7714 	},
7715 };
7716 
7717 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
7718 struct cmd_vf_mac_addr_result {
7719 	cmdline_fixed_string_t mac_addr_cmd;
7720 	cmdline_fixed_string_t what;
7721 	cmdline_fixed_string_t port;
7722 	uint16_t port_num;
7723 	cmdline_fixed_string_t vf;
7724 	uint8_t vf_num;
7725 	struct ether_addr address;
7726 };
7727 
7728 static void cmd_vf_mac_addr_parsed(void *parsed_result,
7729 		__attribute__((unused)) struct cmdline *cl,
7730 		__attribute__((unused)) void *data)
7731 {
7732 	struct cmd_vf_mac_addr_result *res = parsed_result;
7733 	int ret = -ENOTSUP;
7734 
7735 	if (strcmp(res->what, "add") != 0)
7736 		return;
7737 
7738 #ifdef RTE_LIBRTE_I40E_PMD
7739 	if (ret == -ENOTSUP)
7740 		ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
7741 						   &res->address);
7742 #endif
7743 #ifdef RTE_LIBRTE_BNXT_PMD
7744 	if (ret == -ENOTSUP)
7745 		ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
7746 						res->vf_num);
7747 #endif
7748 
7749 	if(ret < 0)
7750 		printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
7751 
7752 }
7753 
7754 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
7755 	TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7756 				mac_addr_cmd,"mac_addr");
7757 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
7758 	TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7759 				what,"add");
7760 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
7761 	TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7762 				port,"port");
7763 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
7764 	TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
7765 				port_num, UINT16);
7766 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
7767 	TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7768 				vf,"vf");
7769 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
7770 	TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
7771 				vf_num, UINT8);
7772 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
7773 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
7774 				address);
7775 
7776 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
7777 	.f = cmd_vf_mac_addr_parsed,
7778 	.data = (void *)0,
7779 	.help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
7780 		"Add MAC address filtering for a VF on port_id",
7781 	.tokens = {
7782 		(void *)&cmd_vf_mac_addr_cmd,
7783 		(void *)&cmd_vf_mac_addr_what,
7784 		(void *)&cmd_vf_mac_addr_port,
7785 		(void *)&cmd_vf_mac_addr_portnum,
7786 		(void *)&cmd_vf_mac_addr_vf,
7787 		(void *)&cmd_vf_mac_addr_vfnum,
7788 		(void *)&cmd_vf_mac_addr_addr,
7789 		NULL,
7790 	},
7791 };
7792 
7793 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
7794 struct cmd_vf_rx_vlan_filter {
7795 	cmdline_fixed_string_t rx_vlan;
7796 	cmdline_fixed_string_t what;
7797 	uint16_t vlan_id;
7798 	cmdline_fixed_string_t port;
7799 	portid_t port_id;
7800 	cmdline_fixed_string_t vf;
7801 	uint64_t vf_mask;
7802 };
7803 
7804 static void
7805 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
7806 			  __attribute__((unused)) struct cmdline *cl,
7807 			  __attribute__((unused)) void *data)
7808 {
7809 	struct cmd_vf_rx_vlan_filter *res = parsed_result;
7810 	int ret = -ENOTSUP;
7811 
7812 	__rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
7813 
7814 #ifdef RTE_LIBRTE_IXGBE_PMD
7815 	if (ret == -ENOTSUP)
7816 		ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
7817 				res->vlan_id, res->vf_mask, is_add);
7818 #endif
7819 #ifdef RTE_LIBRTE_I40E_PMD
7820 	if (ret == -ENOTSUP)
7821 		ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
7822 				res->vlan_id, res->vf_mask, is_add);
7823 #endif
7824 #ifdef RTE_LIBRTE_BNXT_PMD
7825 	if (ret == -ENOTSUP)
7826 		ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
7827 				res->vlan_id, res->vf_mask, is_add);
7828 #endif
7829 
7830 	switch (ret) {
7831 	case 0:
7832 		break;
7833 	case -EINVAL:
7834 		printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
7835 				res->vlan_id, res->vf_mask);
7836 		break;
7837 	case -ENODEV:
7838 		printf("invalid port_id %d\n", res->port_id);
7839 		break;
7840 	case -ENOTSUP:
7841 		printf("function not implemented or supported\n");
7842 		break;
7843 	default:
7844 		printf("programming error: (%s)\n", strerror(-ret));
7845 	}
7846 }
7847 
7848 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
7849 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7850 				 rx_vlan, "rx_vlan");
7851 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
7852 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7853 				 what, "add#rm");
7854 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
7855 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7856 			      vlan_id, UINT16);
7857 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
7858 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7859 				 port, "port");
7860 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
7861 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7862 			      port_id, UINT16);
7863 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
7864 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7865 				 vf, "vf");
7866 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
7867 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7868 			      vf_mask, UINT64);
7869 
7870 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
7871 	.f = cmd_vf_rx_vlan_filter_parsed,
7872 	.data = NULL,
7873 	.help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
7874 		"(vf_mask = hexadecimal VF mask)",
7875 	.tokens = {
7876 		(void *)&cmd_vf_rx_vlan_filter_rx_vlan,
7877 		(void *)&cmd_vf_rx_vlan_filter_what,
7878 		(void *)&cmd_vf_rx_vlan_filter_vlanid,
7879 		(void *)&cmd_vf_rx_vlan_filter_port,
7880 		(void *)&cmd_vf_rx_vlan_filter_portid,
7881 		(void *)&cmd_vf_rx_vlan_filter_vf,
7882 		(void *)&cmd_vf_rx_vlan_filter_vf_mask,
7883 		NULL,
7884 	},
7885 };
7886 
7887 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
7888 struct cmd_queue_rate_limit_result {
7889 	cmdline_fixed_string_t set;
7890 	cmdline_fixed_string_t port;
7891 	uint16_t port_num;
7892 	cmdline_fixed_string_t queue;
7893 	uint8_t queue_num;
7894 	cmdline_fixed_string_t rate;
7895 	uint16_t rate_num;
7896 };
7897 
7898 static void cmd_queue_rate_limit_parsed(void *parsed_result,
7899 		__attribute__((unused)) struct cmdline *cl,
7900 		__attribute__((unused)) void *data)
7901 {
7902 	struct cmd_queue_rate_limit_result *res = parsed_result;
7903 	int ret = 0;
7904 
7905 	if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7906 		&& (strcmp(res->queue, "queue") == 0)
7907 		&& (strcmp(res->rate, "rate") == 0))
7908 		ret = set_queue_rate_limit(res->port_num, res->queue_num,
7909 					res->rate_num);
7910 	if (ret < 0)
7911 		printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
7912 
7913 }
7914 
7915 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
7916 	TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7917 				set, "set");
7918 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
7919 	TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7920 				port, "port");
7921 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
7922 	TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7923 				port_num, UINT16);
7924 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
7925 	TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7926 				queue, "queue");
7927 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
7928 	TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7929 				queue_num, UINT8);
7930 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
7931 	TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7932 				rate, "rate");
7933 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
7934 	TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7935 				rate_num, UINT16);
7936 
7937 cmdline_parse_inst_t cmd_queue_rate_limit = {
7938 	.f = cmd_queue_rate_limit_parsed,
7939 	.data = (void *)0,
7940 	.help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
7941 		"Set rate limit for a queue on port_id",
7942 	.tokens = {
7943 		(void *)&cmd_queue_rate_limit_set,
7944 		(void *)&cmd_queue_rate_limit_port,
7945 		(void *)&cmd_queue_rate_limit_portnum,
7946 		(void *)&cmd_queue_rate_limit_queue,
7947 		(void *)&cmd_queue_rate_limit_queuenum,
7948 		(void *)&cmd_queue_rate_limit_rate,
7949 		(void *)&cmd_queue_rate_limit_ratenum,
7950 		NULL,
7951 	},
7952 };
7953 
7954 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
7955 struct cmd_vf_rate_limit_result {
7956 	cmdline_fixed_string_t set;
7957 	cmdline_fixed_string_t port;
7958 	uint16_t port_num;
7959 	cmdline_fixed_string_t vf;
7960 	uint8_t vf_num;
7961 	cmdline_fixed_string_t rate;
7962 	uint16_t rate_num;
7963 	cmdline_fixed_string_t q_msk;
7964 	uint64_t q_msk_val;
7965 };
7966 
7967 static void cmd_vf_rate_limit_parsed(void *parsed_result,
7968 		__attribute__((unused)) struct cmdline *cl,
7969 		__attribute__((unused)) void *data)
7970 {
7971 	struct cmd_vf_rate_limit_result *res = parsed_result;
7972 	int ret = 0;
7973 
7974 	if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7975 		&& (strcmp(res->vf, "vf") == 0)
7976 		&& (strcmp(res->rate, "rate") == 0)
7977 		&& (strcmp(res->q_msk, "queue_mask") == 0))
7978 		ret = set_vf_rate_limit(res->port_num, res->vf_num,
7979 					res->rate_num, res->q_msk_val);
7980 	if (ret < 0)
7981 		printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
7982 
7983 }
7984 
7985 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
7986 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7987 				set, "set");
7988 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
7989 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7990 				port, "port");
7991 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
7992 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7993 				port_num, UINT16);
7994 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
7995 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7996 				vf, "vf");
7997 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
7998 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7999 				vf_num, UINT8);
8000 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
8001 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8002 				rate, "rate");
8003 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
8004 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8005 				rate_num, UINT16);
8006 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
8007 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8008 				q_msk, "queue_mask");
8009 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
8010 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8011 				q_msk_val, UINT64);
8012 
8013 cmdline_parse_inst_t cmd_vf_rate_limit = {
8014 	.f = cmd_vf_rate_limit_parsed,
8015 	.data = (void *)0,
8016 	.help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
8017 		"queue_mask <queue_mask_value>: "
8018 		"Set rate limit for queues of VF on port_id",
8019 	.tokens = {
8020 		(void *)&cmd_vf_rate_limit_set,
8021 		(void *)&cmd_vf_rate_limit_port,
8022 		(void *)&cmd_vf_rate_limit_portnum,
8023 		(void *)&cmd_vf_rate_limit_vf,
8024 		(void *)&cmd_vf_rate_limit_vfnum,
8025 		(void *)&cmd_vf_rate_limit_rate,
8026 		(void *)&cmd_vf_rate_limit_ratenum,
8027 		(void *)&cmd_vf_rate_limit_q_msk,
8028 		(void *)&cmd_vf_rate_limit_q_msk_val,
8029 		NULL,
8030 	},
8031 };
8032 
8033 /* *** ADD TUNNEL FILTER OF A PORT *** */
8034 struct cmd_tunnel_filter_result {
8035 	cmdline_fixed_string_t cmd;
8036 	cmdline_fixed_string_t what;
8037 	portid_t port_id;
8038 	struct ether_addr outer_mac;
8039 	struct ether_addr inner_mac;
8040 	cmdline_ipaddr_t ip_value;
8041 	uint16_t inner_vlan;
8042 	cmdline_fixed_string_t tunnel_type;
8043 	cmdline_fixed_string_t filter_type;
8044 	uint32_t tenant_id;
8045 	uint16_t queue_num;
8046 };
8047 
8048 static void
8049 cmd_tunnel_filter_parsed(void *parsed_result,
8050 			  __attribute__((unused)) struct cmdline *cl,
8051 			  __attribute__((unused)) void *data)
8052 {
8053 	struct cmd_tunnel_filter_result *res = parsed_result;
8054 	struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
8055 	int ret = 0;
8056 
8057 	memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
8058 
8059 	ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
8060 	ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
8061 	tunnel_filter_conf.inner_vlan = res->inner_vlan;
8062 
8063 	if (res->ip_value.family == AF_INET) {
8064 		tunnel_filter_conf.ip_addr.ipv4_addr =
8065 			res->ip_value.addr.ipv4.s_addr;
8066 		tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
8067 	} else {
8068 		memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
8069 			&(res->ip_value.addr.ipv6),
8070 			sizeof(struct in6_addr));
8071 		tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
8072 	}
8073 
8074 	if (!strcmp(res->filter_type, "imac-ivlan"))
8075 		tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
8076 	else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
8077 		tunnel_filter_conf.filter_type =
8078 			RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
8079 	else if (!strcmp(res->filter_type, "imac-tenid"))
8080 		tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
8081 	else if (!strcmp(res->filter_type, "imac"))
8082 		tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
8083 	else if (!strcmp(res->filter_type, "omac-imac-tenid"))
8084 		tunnel_filter_conf.filter_type =
8085 			RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
8086 	else if (!strcmp(res->filter_type, "oip"))
8087 		tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
8088 	else if (!strcmp(res->filter_type, "iip"))
8089 		tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
8090 	else {
8091 		printf("The filter type is not supported");
8092 		return;
8093 	}
8094 
8095 	if (!strcmp(res->tunnel_type, "vxlan"))
8096 		tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
8097 	else if (!strcmp(res->tunnel_type, "nvgre"))
8098 		tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
8099 	else if (!strcmp(res->tunnel_type, "ipingre"))
8100 		tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
8101 	else {
8102 		printf("The tunnel type %s not supported.\n", res->tunnel_type);
8103 		return;
8104 	}
8105 
8106 	tunnel_filter_conf.tenant_id = res->tenant_id;
8107 	tunnel_filter_conf.queue_id = res->queue_num;
8108 	if (!strcmp(res->what, "add"))
8109 		ret = rte_eth_dev_filter_ctrl(res->port_id,
8110 					RTE_ETH_FILTER_TUNNEL,
8111 					RTE_ETH_FILTER_ADD,
8112 					&tunnel_filter_conf);
8113 	else
8114 		ret = rte_eth_dev_filter_ctrl(res->port_id,
8115 					RTE_ETH_FILTER_TUNNEL,
8116 					RTE_ETH_FILTER_DELETE,
8117 					&tunnel_filter_conf);
8118 	if (ret < 0)
8119 		printf("cmd_tunnel_filter_parsed error: (%s)\n",
8120 				strerror(-ret));
8121 
8122 }
8123 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
8124 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8125 	cmd, "tunnel_filter");
8126 cmdline_parse_token_string_t cmd_tunnel_filter_what =
8127 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8128 	what, "add#rm");
8129 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
8130 	TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8131 	port_id, UINT16);
8132 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
8133 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8134 	outer_mac);
8135 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
8136 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8137 	inner_mac);
8138 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
8139 	TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8140 	inner_vlan, UINT16);
8141 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
8142 	TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8143 	ip_value);
8144 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
8145 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8146 	tunnel_type, "vxlan#nvgre#ipingre");
8147 
8148 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
8149 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8150 	filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
8151 		"imac#omac-imac-tenid");
8152 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
8153 	TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8154 	tenant_id, UINT32);
8155 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
8156 	TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8157 	queue_num, UINT16);
8158 
8159 cmdline_parse_inst_t cmd_tunnel_filter = {
8160 	.f = cmd_tunnel_filter_parsed,
8161 	.data = (void *)0,
8162 	.help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
8163 		"<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
8164 		"imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
8165 		"<queue_id>: Add/Rm tunnel filter of a port",
8166 	.tokens = {
8167 		(void *)&cmd_tunnel_filter_cmd,
8168 		(void *)&cmd_tunnel_filter_what,
8169 		(void *)&cmd_tunnel_filter_port_id,
8170 		(void *)&cmd_tunnel_filter_outer_mac,
8171 		(void *)&cmd_tunnel_filter_inner_mac,
8172 		(void *)&cmd_tunnel_filter_ip_value,
8173 		(void *)&cmd_tunnel_filter_innner_vlan,
8174 		(void *)&cmd_tunnel_filter_tunnel_type,
8175 		(void *)&cmd_tunnel_filter_filter_type,
8176 		(void *)&cmd_tunnel_filter_tenant_id,
8177 		(void *)&cmd_tunnel_filter_queue_num,
8178 		NULL,
8179 	},
8180 };
8181 
8182 /* *** CONFIGURE TUNNEL UDP PORT *** */
8183 struct cmd_tunnel_udp_config {
8184 	cmdline_fixed_string_t cmd;
8185 	cmdline_fixed_string_t what;
8186 	uint16_t udp_port;
8187 	portid_t port_id;
8188 };
8189 
8190 static void
8191 cmd_tunnel_udp_config_parsed(void *parsed_result,
8192 			  __attribute__((unused)) struct cmdline *cl,
8193 			  __attribute__((unused)) void *data)
8194 {
8195 	struct cmd_tunnel_udp_config *res = parsed_result;
8196 	struct rte_eth_udp_tunnel tunnel_udp;
8197 	int ret;
8198 
8199 	tunnel_udp.udp_port = res->udp_port;
8200 
8201 	if (!strcmp(res->cmd, "rx_vxlan_port"))
8202 		tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
8203 
8204 	if (!strcmp(res->what, "add"))
8205 		ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
8206 						      &tunnel_udp);
8207 	else
8208 		ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
8209 							 &tunnel_udp);
8210 
8211 	if (ret < 0)
8212 		printf("udp tunneling add error: (%s)\n", strerror(-ret));
8213 }
8214 
8215 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
8216 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8217 				cmd, "rx_vxlan_port");
8218 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
8219 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8220 				what, "add#rm");
8221 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
8222 	TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8223 				udp_port, UINT16);
8224 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
8225 	TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8226 				port_id, UINT16);
8227 
8228 cmdline_parse_inst_t cmd_tunnel_udp_config = {
8229 	.f = cmd_tunnel_udp_config_parsed,
8230 	.data = (void *)0,
8231 	.help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
8232 		"Add/Remove a tunneling UDP port filter",
8233 	.tokens = {
8234 		(void *)&cmd_tunnel_udp_config_cmd,
8235 		(void *)&cmd_tunnel_udp_config_what,
8236 		(void *)&cmd_tunnel_udp_config_udp_port,
8237 		(void *)&cmd_tunnel_udp_config_port_id,
8238 		NULL,
8239 	},
8240 };
8241 
8242 /* *** GLOBAL CONFIG *** */
8243 struct cmd_global_config_result {
8244 	cmdline_fixed_string_t cmd;
8245 	portid_t port_id;
8246 	cmdline_fixed_string_t cfg_type;
8247 	uint8_t len;
8248 };
8249 
8250 static void
8251 cmd_global_config_parsed(void *parsed_result,
8252 			 __attribute__((unused)) struct cmdline *cl,
8253 			 __attribute__((unused)) void *data)
8254 {
8255 	struct cmd_global_config_result *res = parsed_result;
8256 	struct rte_eth_global_cfg conf;
8257 	int ret;
8258 
8259 	memset(&conf, 0, sizeof(conf));
8260 	conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
8261 	conf.cfg.gre_key_len = res->len;
8262 	ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
8263 				      RTE_ETH_FILTER_SET, &conf);
8264 	if (ret != 0)
8265 		printf("Global config error\n");
8266 }
8267 
8268 cmdline_parse_token_string_t cmd_global_config_cmd =
8269 	TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
8270 		"global_config");
8271 cmdline_parse_token_num_t cmd_global_config_port_id =
8272 	TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id,
8273 			       UINT16);
8274 cmdline_parse_token_string_t cmd_global_config_type =
8275 	TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
8276 		cfg_type, "gre-key-len");
8277 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
8278 	TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
8279 		len, UINT8);
8280 
8281 cmdline_parse_inst_t cmd_global_config = {
8282 	.f = cmd_global_config_parsed,
8283 	.data = (void *)NULL,
8284 	.help_str = "global_config <port_id> gre-key-len <key_len>",
8285 	.tokens = {
8286 		(void *)&cmd_global_config_cmd,
8287 		(void *)&cmd_global_config_port_id,
8288 		(void *)&cmd_global_config_type,
8289 		(void *)&cmd_global_config_gre_key_len,
8290 		NULL,
8291 	},
8292 };
8293 
8294 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
8295 struct cmd_set_mirror_mask_result {
8296 	cmdline_fixed_string_t set;
8297 	cmdline_fixed_string_t port;
8298 	portid_t port_id;
8299 	cmdline_fixed_string_t mirror;
8300 	uint8_t rule_id;
8301 	cmdline_fixed_string_t what;
8302 	cmdline_fixed_string_t value;
8303 	cmdline_fixed_string_t dstpool;
8304 	uint8_t dstpool_id;
8305 	cmdline_fixed_string_t on;
8306 };
8307 
8308 cmdline_parse_token_string_t cmd_mirror_mask_set =
8309 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8310 				set, "set");
8311 cmdline_parse_token_string_t cmd_mirror_mask_port =
8312 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8313 				port, "port");
8314 cmdline_parse_token_num_t cmd_mirror_mask_portid =
8315 	TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8316 				port_id, UINT16);
8317 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
8318 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8319 				mirror, "mirror-rule");
8320 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
8321 	TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8322 				rule_id, UINT8);
8323 cmdline_parse_token_string_t cmd_mirror_mask_what =
8324 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8325 				what, "pool-mirror-up#pool-mirror-down"
8326 				      "#vlan-mirror");
8327 cmdline_parse_token_string_t cmd_mirror_mask_value =
8328 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8329 				value, NULL);
8330 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
8331 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8332 				dstpool, "dst-pool");
8333 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
8334 	TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8335 				dstpool_id, UINT8);
8336 cmdline_parse_token_string_t cmd_mirror_mask_on =
8337 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8338 				on, "on#off");
8339 
8340 static void
8341 cmd_set_mirror_mask_parsed(void *parsed_result,
8342 		       __attribute__((unused)) struct cmdline *cl,
8343 		       __attribute__((unused)) void *data)
8344 {
8345 	int ret,nb_item,i;
8346 	struct cmd_set_mirror_mask_result *res = parsed_result;
8347 	struct rte_eth_mirror_conf mr_conf;
8348 
8349 	memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
8350 
8351 	unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
8352 
8353 	mr_conf.dst_pool = res->dstpool_id;
8354 
8355 	if (!strcmp(res->what, "pool-mirror-up")) {
8356 		mr_conf.pool_mask = strtoull(res->value, NULL, 16);
8357 		mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
8358 	} else if (!strcmp(res->what, "pool-mirror-down")) {
8359 		mr_conf.pool_mask = strtoull(res->value, NULL, 16);
8360 		mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
8361 	} else if (!strcmp(res->what, "vlan-mirror")) {
8362 		mr_conf.rule_type = ETH_MIRROR_VLAN;
8363 		nb_item = parse_item_list(res->value, "vlan",
8364 				ETH_MIRROR_MAX_VLANS, vlan_list, 1);
8365 		if (nb_item <= 0)
8366 			return;
8367 
8368 		for (i = 0; i < nb_item; i++) {
8369 			if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
8370 				printf("Invalid vlan_id: must be < 4096\n");
8371 				return;
8372 			}
8373 
8374 			mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
8375 			mr_conf.vlan.vlan_mask |= 1ULL << i;
8376 		}
8377 	}
8378 
8379 	if (!strcmp(res->on, "on"))
8380 		ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8381 						res->rule_id, 1);
8382 	else
8383 		ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8384 						res->rule_id, 0);
8385 	if (ret < 0)
8386 		printf("mirror rule add error: (%s)\n", strerror(-ret));
8387 }
8388 
8389 cmdline_parse_inst_t cmd_set_mirror_mask = {
8390 		.f = cmd_set_mirror_mask_parsed,
8391 		.data = NULL,
8392 		.help_str = "set port <port_id> mirror-rule <rule_id> "
8393 			"pool-mirror-up|pool-mirror-down|vlan-mirror "
8394 			"<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
8395 		.tokens = {
8396 			(void *)&cmd_mirror_mask_set,
8397 			(void *)&cmd_mirror_mask_port,
8398 			(void *)&cmd_mirror_mask_portid,
8399 			(void *)&cmd_mirror_mask_mirror,
8400 			(void *)&cmd_mirror_mask_ruleid,
8401 			(void *)&cmd_mirror_mask_what,
8402 			(void *)&cmd_mirror_mask_value,
8403 			(void *)&cmd_mirror_mask_dstpool,
8404 			(void *)&cmd_mirror_mask_poolid,
8405 			(void *)&cmd_mirror_mask_on,
8406 			NULL,
8407 		},
8408 };
8409 
8410 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
8411 struct cmd_set_mirror_link_result {
8412 	cmdline_fixed_string_t set;
8413 	cmdline_fixed_string_t port;
8414 	portid_t port_id;
8415 	cmdline_fixed_string_t mirror;
8416 	uint8_t rule_id;
8417 	cmdline_fixed_string_t what;
8418 	cmdline_fixed_string_t dstpool;
8419 	uint8_t dstpool_id;
8420 	cmdline_fixed_string_t on;
8421 };
8422 
8423 cmdline_parse_token_string_t cmd_mirror_link_set =
8424 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8425 				 set, "set");
8426 cmdline_parse_token_string_t cmd_mirror_link_port =
8427 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8428 				port, "port");
8429 cmdline_parse_token_num_t cmd_mirror_link_portid =
8430 	TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8431 				port_id, UINT16);
8432 cmdline_parse_token_string_t cmd_mirror_link_mirror =
8433 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8434 				mirror, "mirror-rule");
8435 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
8436 	TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8437 			    rule_id, UINT8);
8438 cmdline_parse_token_string_t cmd_mirror_link_what =
8439 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8440 				what, "uplink-mirror#downlink-mirror");
8441 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
8442 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8443 				dstpool, "dst-pool");
8444 cmdline_parse_token_num_t cmd_mirror_link_poolid =
8445 	TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8446 				dstpool_id, UINT8);
8447 cmdline_parse_token_string_t cmd_mirror_link_on =
8448 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8449 				on, "on#off");
8450 
8451 static void
8452 cmd_set_mirror_link_parsed(void *parsed_result,
8453 		       __attribute__((unused)) struct cmdline *cl,
8454 		       __attribute__((unused)) void *data)
8455 {
8456 	int ret;
8457 	struct cmd_set_mirror_link_result *res = parsed_result;
8458 	struct rte_eth_mirror_conf mr_conf;
8459 
8460 	memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
8461 	if (!strcmp(res->what, "uplink-mirror"))
8462 		mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
8463 	else
8464 		mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
8465 
8466 	mr_conf.dst_pool = res->dstpool_id;
8467 
8468 	if (!strcmp(res->on, "on"))
8469 		ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8470 						res->rule_id, 1);
8471 	else
8472 		ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8473 						res->rule_id, 0);
8474 
8475 	/* check the return value and print it if is < 0 */
8476 	if (ret < 0)
8477 		printf("mirror rule add error: (%s)\n", strerror(-ret));
8478 
8479 }
8480 
8481 cmdline_parse_inst_t cmd_set_mirror_link = {
8482 		.f = cmd_set_mirror_link_parsed,
8483 		.data = NULL,
8484 		.help_str = "set port <port_id> mirror-rule <rule_id> "
8485 			"uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
8486 		.tokens = {
8487 			(void *)&cmd_mirror_link_set,
8488 			(void *)&cmd_mirror_link_port,
8489 			(void *)&cmd_mirror_link_portid,
8490 			(void *)&cmd_mirror_link_mirror,
8491 			(void *)&cmd_mirror_link_ruleid,
8492 			(void *)&cmd_mirror_link_what,
8493 			(void *)&cmd_mirror_link_dstpool,
8494 			(void *)&cmd_mirror_link_poolid,
8495 			(void *)&cmd_mirror_link_on,
8496 			NULL,
8497 		},
8498 };
8499 
8500 /* *** RESET VM MIRROR RULE *** */
8501 struct cmd_rm_mirror_rule_result {
8502 	cmdline_fixed_string_t reset;
8503 	cmdline_fixed_string_t port;
8504 	portid_t port_id;
8505 	cmdline_fixed_string_t mirror;
8506 	uint8_t rule_id;
8507 };
8508 
8509 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
8510 	TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8511 				 reset, "reset");
8512 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
8513 	TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8514 				port, "port");
8515 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
8516 	TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
8517 				port_id, UINT16);
8518 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
8519 	TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8520 				mirror, "mirror-rule");
8521 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
8522 	TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
8523 				rule_id, UINT8);
8524 
8525 static void
8526 cmd_reset_mirror_rule_parsed(void *parsed_result,
8527 		       __attribute__((unused)) struct cmdline *cl,
8528 		       __attribute__((unused)) void *data)
8529 {
8530 	int ret;
8531 	struct cmd_set_mirror_link_result *res = parsed_result;
8532         /* check rule_id */
8533 	ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
8534 	if(ret < 0)
8535 		printf("mirror rule remove error: (%s)\n", strerror(-ret));
8536 }
8537 
8538 cmdline_parse_inst_t cmd_reset_mirror_rule = {
8539 		.f = cmd_reset_mirror_rule_parsed,
8540 		.data = NULL,
8541 		.help_str = "reset port <port_id> mirror-rule <rule_id>",
8542 		.tokens = {
8543 			(void *)&cmd_rm_mirror_rule_reset,
8544 			(void *)&cmd_rm_mirror_rule_port,
8545 			(void *)&cmd_rm_mirror_rule_portid,
8546 			(void *)&cmd_rm_mirror_rule_mirror,
8547 			(void *)&cmd_rm_mirror_rule_ruleid,
8548 			NULL,
8549 		},
8550 };
8551 
8552 /* ******************************************************************************** */
8553 
8554 struct cmd_dump_result {
8555 	cmdline_fixed_string_t dump;
8556 };
8557 
8558 static void
8559 dump_struct_sizes(void)
8560 {
8561 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
8562 	DUMP_SIZE(struct rte_mbuf);
8563 	DUMP_SIZE(struct rte_mempool);
8564 	DUMP_SIZE(struct rte_ring);
8565 #undef DUMP_SIZE
8566 }
8567 
8568 static void cmd_dump_parsed(void *parsed_result,
8569 			    __attribute__((unused)) struct cmdline *cl,
8570 			    __attribute__((unused)) void *data)
8571 {
8572 	struct cmd_dump_result *res = parsed_result;
8573 
8574 	if (!strcmp(res->dump, "dump_physmem"))
8575 		rte_dump_physmem_layout(stdout);
8576 	else if (!strcmp(res->dump, "dump_memzone"))
8577 		rte_memzone_dump(stdout);
8578 	else if (!strcmp(res->dump, "dump_struct_sizes"))
8579 		dump_struct_sizes();
8580 	else if (!strcmp(res->dump, "dump_ring"))
8581 		rte_ring_list_dump(stdout);
8582 	else if (!strcmp(res->dump, "dump_mempool"))
8583 		rte_mempool_list_dump(stdout);
8584 	else if (!strcmp(res->dump, "dump_devargs"))
8585 		rte_eal_devargs_dump(stdout);
8586 	else if (!strcmp(res->dump, "dump_log_types"))
8587 		rte_log_dump(stdout);
8588 }
8589 
8590 cmdline_parse_token_string_t cmd_dump_dump =
8591 	TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
8592 		"dump_physmem#"
8593 		"dump_memzone#"
8594 		"dump_struct_sizes#"
8595 		"dump_ring#"
8596 		"dump_mempool#"
8597 		"dump_devargs#"
8598 		"dump_log_types");
8599 
8600 cmdline_parse_inst_t cmd_dump = {
8601 	.f = cmd_dump_parsed,  /* function to call */
8602 	.data = NULL,      /* 2nd arg of func */
8603 	.help_str = "Dump status",
8604 	.tokens = {        /* token list, NULL terminated */
8605 		(void *)&cmd_dump_dump,
8606 		NULL,
8607 	},
8608 };
8609 
8610 /* ******************************************************************************** */
8611 
8612 struct cmd_dump_one_result {
8613 	cmdline_fixed_string_t dump;
8614 	cmdline_fixed_string_t name;
8615 };
8616 
8617 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
8618 				__attribute__((unused)) void *data)
8619 {
8620 	struct cmd_dump_one_result *res = parsed_result;
8621 
8622 	if (!strcmp(res->dump, "dump_ring")) {
8623 		struct rte_ring *r;
8624 		r = rte_ring_lookup(res->name);
8625 		if (r == NULL) {
8626 			cmdline_printf(cl, "Cannot find ring\n");
8627 			return;
8628 		}
8629 		rte_ring_dump(stdout, r);
8630 	} else if (!strcmp(res->dump, "dump_mempool")) {
8631 		struct rte_mempool *mp;
8632 		mp = rte_mempool_lookup(res->name);
8633 		if (mp == NULL) {
8634 			cmdline_printf(cl, "Cannot find mempool\n");
8635 			return;
8636 		}
8637 		rte_mempool_dump(stdout, mp);
8638 	}
8639 }
8640 
8641 cmdline_parse_token_string_t cmd_dump_one_dump =
8642 	TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
8643 				 "dump_ring#dump_mempool");
8644 
8645 cmdline_parse_token_string_t cmd_dump_one_name =
8646 	TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
8647 
8648 cmdline_parse_inst_t cmd_dump_one = {
8649 	.f = cmd_dump_one_parsed,  /* function to call */
8650 	.data = NULL,      /* 2nd arg of func */
8651 	.help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
8652 	.tokens = {        /* token list, NULL terminated */
8653 		(void *)&cmd_dump_one_dump,
8654 		(void *)&cmd_dump_one_name,
8655 		NULL,
8656 	},
8657 };
8658 
8659 /* *** Add/Del syn filter *** */
8660 struct cmd_syn_filter_result {
8661 	cmdline_fixed_string_t filter;
8662 	portid_t port_id;
8663 	cmdline_fixed_string_t ops;
8664 	cmdline_fixed_string_t priority;
8665 	cmdline_fixed_string_t high;
8666 	cmdline_fixed_string_t queue;
8667 	uint16_t queue_id;
8668 };
8669 
8670 static void
8671 cmd_syn_filter_parsed(void *parsed_result,
8672 			__attribute__((unused)) struct cmdline *cl,
8673 			__attribute__((unused)) void *data)
8674 {
8675 	struct cmd_syn_filter_result *res = parsed_result;
8676 	struct rte_eth_syn_filter syn_filter;
8677 	int ret = 0;
8678 
8679 	ret = rte_eth_dev_filter_supported(res->port_id,
8680 					RTE_ETH_FILTER_SYN);
8681 	if (ret < 0) {
8682 		printf("syn filter is not supported on port %u.\n",
8683 				res->port_id);
8684 		return;
8685 	}
8686 
8687 	memset(&syn_filter, 0, sizeof(syn_filter));
8688 
8689 	if (!strcmp(res->ops, "add")) {
8690 		if (!strcmp(res->high, "high"))
8691 			syn_filter.hig_pri = 1;
8692 		else
8693 			syn_filter.hig_pri = 0;
8694 
8695 		syn_filter.queue = res->queue_id;
8696 		ret = rte_eth_dev_filter_ctrl(res->port_id,
8697 						RTE_ETH_FILTER_SYN,
8698 						RTE_ETH_FILTER_ADD,
8699 						&syn_filter);
8700 	} else
8701 		ret = rte_eth_dev_filter_ctrl(res->port_id,
8702 						RTE_ETH_FILTER_SYN,
8703 						RTE_ETH_FILTER_DELETE,
8704 						&syn_filter);
8705 
8706 	if (ret < 0)
8707 		printf("syn filter programming error: (%s)\n",
8708 				strerror(-ret));
8709 }
8710 
8711 cmdline_parse_token_string_t cmd_syn_filter_filter =
8712 	TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8713 	filter, "syn_filter");
8714 cmdline_parse_token_num_t cmd_syn_filter_port_id =
8715 	TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
8716 	port_id, UINT16);
8717 cmdline_parse_token_string_t cmd_syn_filter_ops =
8718 	TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8719 	ops, "add#del");
8720 cmdline_parse_token_string_t cmd_syn_filter_priority =
8721 	TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8722 				priority, "priority");
8723 cmdline_parse_token_string_t cmd_syn_filter_high =
8724 	TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8725 				high, "high#low");
8726 cmdline_parse_token_string_t cmd_syn_filter_queue =
8727 	TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8728 				queue, "queue");
8729 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
8730 	TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
8731 				queue_id, UINT16);
8732 
8733 cmdline_parse_inst_t cmd_syn_filter = {
8734 	.f = cmd_syn_filter_parsed,
8735 	.data = NULL,
8736 	.help_str = "syn_filter <port_id> add|del priority high|low queue "
8737 		"<queue_id>: Add/Delete syn filter",
8738 	.tokens = {
8739 		(void *)&cmd_syn_filter_filter,
8740 		(void *)&cmd_syn_filter_port_id,
8741 		(void *)&cmd_syn_filter_ops,
8742 		(void *)&cmd_syn_filter_priority,
8743 		(void *)&cmd_syn_filter_high,
8744 		(void *)&cmd_syn_filter_queue,
8745 		(void *)&cmd_syn_filter_queue_id,
8746 		NULL,
8747 	},
8748 };
8749 
8750 /* *** queue region set *** */
8751 struct cmd_queue_region_result {
8752 	cmdline_fixed_string_t set;
8753 	cmdline_fixed_string_t port;
8754 	portid_t port_id;
8755 	cmdline_fixed_string_t cmd;
8756 	cmdline_fixed_string_t region;
8757 	uint8_t  region_id;
8758 	cmdline_fixed_string_t queue_start_index;
8759 	uint8_t  queue_id;
8760 	cmdline_fixed_string_t queue_num;
8761 	uint8_t  queue_num_value;
8762 };
8763 
8764 static void
8765 cmd_queue_region_parsed(void *parsed_result,
8766 			__attribute__((unused)) struct cmdline *cl,
8767 			__attribute__((unused)) void *data)
8768 {
8769 	struct cmd_queue_region_result *res = parsed_result;
8770 	int ret = -ENOTSUP;
8771 #ifdef RTE_LIBRTE_I40E_PMD
8772 	struct rte_pmd_i40e_queue_region_conf region_conf;
8773 	enum rte_pmd_i40e_queue_region_op op_type;
8774 #endif
8775 
8776 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8777 		return;
8778 
8779 #ifdef RTE_LIBRTE_I40E_PMD
8780 	memset(&region_conf, 0, sizeof(region_conf));
8781 	op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
8782 	region_conf.region_id = res->region_id;
8783 	region_conf.queue_num = res->queue_num_value;
8784 	region_conf.queue_start_index = res->queue_id;
8785 
8786 	ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
8787 				op_type, &region_conf);
8788 #endif
8789 
8790 	switch (ret) {
8791 	case 0:
8792 		break;
8793 	case -ENOTSUP:
8794 		printf("function not implemented or supported\n");
8795 		break;
8796 	default:
8797 		printf("queue region config error: (%s)\n", strerror(-ret));
8798 	}
8799 }
8800 
8801 cmdline_parse_token_string_t cmd_queue_region_set =
8802 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8803 		set, "set");
8804 cmdline_parse_token_string_t cmd_queue_region_port =
8805 	TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
8806 cmdline_parse_token_num_t cmd_queue_region_port_id =
8807 	TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8808 				port_id, UINT16);
8809 cmdline_parse_token_string_t cmd_queue_region_cmd =
8810 	TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8811 				 cmd, "queue-region");
8812 cmdline_parse_token_string_t cmd_queue_region_id =
8813 	TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8814 				region, "region_id");
8815 cmdline_parse_token_num_t cmd_queue_region_index =
8816 	TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8817 				region_id, UINT8);
8818 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
8819 	TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8820 				queue_start_index, "queue_start_index");
8821 cmdline_parse_token_num_t cmd_queue_region_queue_id =
8822 	TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8823 				queue_id, UINT8);
8824 cmdline_parse_token_string_t cmd_queue_region_queue_num =
8825 	TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8826 				queue_num, "queue_num");
8827 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
8828 	TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8829 				queue_num_value, UINT8);
8830 
8831 cmdline_parse_inst_t cmd_queue_region = {
8832 	.f = cmd_queue_region_parsed,
8833 	.data = NULL,
8834 	.help_str = "set port <port_id> queue-region region_id <value> "
8835 		"queue_start_index <value> queue_num <value>: Set a queue region",
8836 	.tokens = {
8837 		(void *)&cmd_queue_region_set,
8838 		(void *)&cmd_queue_region_port,
8839 		(void *)&cmd_queue_region_port_id,
8840 		(void *)&cmd_queue_region_cmd,
8841 		(void *)&cmd_queue_region_id,
8842 		(void *)&cmd_queue_region_index,
8843 		(void *)&cmd_queue_region_queue_start_index,
8844 		(void *)&cmd_queue_region_queue_id,
8845 		(void *)&cmd_queue_region_queue_num,
8846 		(void *)&cmd_queue_region_queue_num_value,
8847 		NULL,
8848 	},
8849 };
8850 
8851 /* *** queue region and flowtype set *** */
8852 struct cmd_region_flowtype_result {
8853 	cmdline_fixed_string_t set;
8854 	cmdline_fixed_string_t port;
8855 	portid_t port_id;
8856 	cmdline_fixed_string_t cmd;
8857 	cmdline_fixed_string_t region;
8858 	uint8_t  region_id;
8859 	cmdline_fixed_string_t flowtype;
8860 	uint8_t  flowtype_id;
8861 };
8862 
8863 static void
8864 cmd_region_flowtype_parsed(void *parsed_result,
8865 			__attribute__((unused)) struct cmdline *cl,
8866 			__attribute__((unused)) void *data)
8867 {
8868 	struct cmd_region_flowtype_result *res = parsed_result;
8869 	int ret = -ENOTSUP;
8870 #ifdef RTE_LIBRTE_I40E_PMD
8871 	struct rte_pmd_i40e_queue_region_conf region_conf;
8872 	enum rte_pmd_i40e_queue_region_op op_type;
8873 #endif
8874 
8875 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8876 		return;
8877 
8878 #ifdef RTE_LIBRTE_I40E_PMD
8879 	memset(&region_conf, 0, sizeof(region_conf));
8880 
8881 	op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
8882 	region_conf.region_id = res->region_id;
8883 	region_conf.hw_flowtype = res->flowtype_id;
8884 
8885 	ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
8886 			op_type, &region_conf);
8887 #endif
8888 
8889 	switch (ret) {
8890 	case 0:
8891 		break;
8892 	case -ENOTSUP:
8893 		printf("function not implemented or supported\n");
8894 		break;
8895 	default:
8896 		printf("region flowtype config error: (%s)\n", strerror(-ret));
8897 	}
8898 }
8899 
8900 cmdline_parse_token_string_t cmd_region_flowtype_set =
8901 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8902 				set, "set");
8903 cmdline_parse_token_string_t cmd_region_flowtype_port =
8904 	TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8905 				port, "port");
8906 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
8907 	TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
8908 				port_id, UINT16);
8909 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
8910 	TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8911 				cmd, "queue-region");
8912 cmdline_parse_token_string_t cmd_region_flowtype_index =
8913 	TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8914 				region, "region_id");
8915 cmdline_parse_token_num_t cmd_region_flowtype_id =
8916 	TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
8917 				region_id, UINT8);
8918 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
8919 	TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8920 				flowtype, "flowtype");
8921 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
8922 	TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
8923 				flowtype_id, UINT8);
8924 cmdline_parse_inst_t cmd_region_flowtype = {
8925 	.f = cmd_region_flowtype_parsed,
8926 	.data = NULL,
8927 	.help_str = "set port <port_id> queue-region region_id <value> "
8928 		"flowtype <value>: Set a flowtype region index",
8929 	.tokens = {
8930 		(void *)&cmd_region_flowtype_set,
8931 		(void *)&cmd_region_flowtype_port,
8932 		(void *)&cmd_region_flowtype_port_index,
8933 		(void *)&cmd_region_flowtype_cmd,
8934 		(void *)&cmd_region_flowtype_index,
8935 		(void *)&cmd_region_flowtype_id,
8936 		(void *)&cmd_region_flowtype_flow_index,
8937 		(void *)&cmd_region_flowtype_flow_id,
8938 		NULL,
8939 	},
8940 };
8941 
8942 /* *** User Priority (UP) to queue region (region_id) set *** */
8943 struct cmd_user_priority_region_result {
8944 	cmdline_fixed_string_t set;
8945 	cmdline_fixed_string_t port;
8946 	portid_t port_id;
8947 	cmdline_fixed_string_t cmd;
8948 	cmdline_fixed_string_t user_priority;
8949 	uint8_t  user_priority_id;
8950 	cmdline_fixed_string_t region;
8951 	uint8_t  region_id;
8952 };
8953 
8954 static void
8955 cmd_user_priority_region_parsed(void *parsed_result,
8956 			__attribute__((unused)) struct cmdline *cl,
8957 			__attribute__((unused)) void *data)
8958 {
8959 	struct cmd_user_priority_region_result *res = parsed_result;
8960 	int ret = -ENOTSUP;
8961 #ifdef RTE_LIBRTE_I40E_PMD
8962 	struct rte_pmd_i40e_queue_region_conf region_conf;
8963 	enum rte_pmd_i40e_queue_region_op op_type;
8964 #endif
8965 
8966 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8967 		return;
8968 
8969 #ifdef RTE_LIBRTE_I40E_PMD
8970 	memset(&region_conf, 0, sizeof(region_conf));
8971 	op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
8972 	region_conf.user_priority = res->user_priority_id;
8973 	region_conf.region_id = res->region_id;
8974 
8975 	ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
8976 				op_type, &region_conf);
8977 #endif
8978 
8979 	switch (ret) {
8980 	case 0:
8981 		break;
8982 	case -ENOTSUP:
8983 		printf("function not implemented or supported\n");
8984 		break;
8985 	default:
8986 		printf("user_priority region config error: (%s)\n",
8987 				strerror(-ret));
8988 	}
8989 }
8990 
8991 cmdline_parse_token_string_t cmd_user_priority_region_set =
8992 	TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
8993 				set, "set");
8994 cmdline_parse_token_string_t cmd_user_priority_region_port =
8995 	TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
8996 				port, "port");
8997 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
8998 	TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
8999 				port_id, UINT16);
9000 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
9001 	TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9002 				cmd, "queue-region");
9003 cmdline_parse_token_string_t cmd_user_priority_region_UP =
9004 	TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9005 				user_priority, "UP");
9006 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
9007 	TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9008 				user_priority_id, UINT8);
9009 cmdline_parse_token_string_t cmd_user_priority_region_region =
9010 	TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9011 				region, "region_id");
9012 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
9013 	TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9014 				region_id, UINT8);
9015 
9016 cmdline_parse_inst_t cmd_user_priority_region = {
9017 	.f = cmd_user_priority_region_parsed,
9018 	.data = NULL,
9019 	.help_str = "set port <port_id> queue-region UP <value> "
9020 		"region_id <value>: Set the mapping of User Priority (UP) "
9021 		"to queue region (region_id) ",
9022 	.tokens = {
9023 		(void *)&cmd_user_priority_region_set,
9024 		(void *)&cmd_user_priority_region_port,
9025 		(void *)&cmd_user_priority_region_port_index,
9026 		(void *)&cmd_user_priority_region_cmd,
9027 		(void *)&cmd_user_priority_region_UP,
9028 		(void *)&cmd_user_priority_region_UP_id,
9029 		(void *)&cmd_user_priority_region_region,
9030 		(void *)&cmd_user_priority_region_region_id,
9031 		NULL,
9032 	},
9033 };
9034 
9035 /* *** flush all queue region related configuration *** */
9036 struct cmd_flush_queue_region_result {
9037 	cmdline_fixed_string_t set;
9038 	cmdline_fixed_string_t port;
9039 	portid_t port_id;
9040 	cmdline_fixed_string_t cmd;
9041 	cmdline_fixed_string_t flush;
9042 	cmdline_fixed_string_t what;
9043 };
9044 
9045 static void
9046 cmd_flush_queue_region_parsed(void *parsed_result,
9047 			__attribute__((unused)) struct cmdline *cl,
9048 			__attribute__((unused)) void *data)
9049 {
9050 	struct cmd_flush_queue_region_result *res = parsed_result;
9051 	int ret = -ENOTSUP;
9052 #ifdef RTE_LIBRTE_I40E_PMD
9053 	struct rte_pmd_i40e_queue_region_conf region_conf;
9054 	enum rte_pmd_i40e_queue_region_op op_type;
9055 #endif
9056 
9057 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9058 		return;
9059 
9060 #ifdef RTE_LIBRTE_I40E_PMD
9061 	memset(&region_conf, 0, sizeof(region_conf));
9062 
9063 	if (strcmp(res->what, "on") == 0)
9064 		op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
9065 	else
9066 		op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
9067 
9068 	ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9069 				op_type, &region_conf);
9070 #endif
9071 
9072 	switch (ret) {
9073 	case 0:
9074 		break;
9075 	case -ENOTSUP:
9076 		printf("function not implemented or supported\n");
9077 		break;
9078 	default:
9079 		printf("queue region config flush error: (%s)\n",
9080 				strerror(-ret));
9081 	}
9082 }
9083 
9084 cmdline_parse_token_string_t cmd_flush_queue_region_set =
9085 	TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9086 				set, "set");
9087 cmdline_parse_token_string_t cmd_flush_queue_region_port =
9088 	TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9089 				port, "port");
9090 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
9091 	TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
9092 				port_id, UINT16);
9093 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
9094 	TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9095 				cmd, "queue-region");
9096 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
9097 	TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9098 				flush, "flush");
9099 cmdline_parse_token_string_t cmd_flush_queue_region_what =
9100 	TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9101 				what, "on#off");
9102 
9103 cmdline_parse_inst_t cmd_flush_queue_region = {
9104 	.f = cmd_flush_queue_region_parsed,
9105 	.data = NULL,
9106 	.help_str = "set port <port_id> queue-region flush on|off"
9107 		": flush all queue region related configuration",
9108 	.tokens = {
9109 		(void *)&cmd_flush_queue_region_set,
9110 		(void *)&cmd_flush_queue_region_port,
9111 		(void *)&cmd_flush_queue_region_port_index,
9112 		(void *)&cmd_flush_queue_region_cmd,
9113 		(void *)&cmd_flush_queue_region_flush,
9114 		(void *)&cmd_flush_queue_region_what,
9115 		NULL,
9116 	},
9117 };
9118 
9119 /* *** get all queue region related configuration info *** */
9120 struct cmd_show_queue_region_info {
9121 	cmdline_fixed_string_t show;
9122 	cmdline_fixed_string_t port;
9123 	portid_t port_id;
9124 	cmdline_fixed_string_t cmd;
9125 };
9126 
9127 static void
9128 cmd_show_queue_region_info_parsed(void *parsed_result,
9129 			__attribute__((unused)) struct cmdline *cl,
9130 			__attribute__((unused)) void *data)
9131 {
9132 	struct cmd_show_queue_region_info *res = parsed_result;
9133 	int ret = -ENOTSUP;
9134 #ifdef RTE_LIBRTE_I40E_PMD
9135 	struct rte_pmd_i40e_queue_regions rte_pmd_regions;
9136 	enum rte_pmd_i40e_queue_region_op op_type;
9137 #endif
9138 
9139 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9140 		return;
9141 
9142 #ifdef RTE_LIBRTE_I40E_PMD
9143 	memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
9144 
9145 	op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
9146 
9147 	ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9148 					op_type, &rte_pmd_regions);
9149 
9150 	port_queue_region_info_display(res->port_id, &rte_pmd_regions);
9151 #endif
9152 
9153 	switch (ret) {
9154 	case 0:
9155 		break;
9156 	case -ENOTSUP:
9157 		printf("function not implemented or supported\n");
9158 		break;
9159 	default:
9160 		printf("queue region config info show error: (%s)\n",
9161 				strerror(-ret));
9162 	}
9163 }
9164 
9165 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
9166 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9167 				show, "show");
9168 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
9169 	TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9170 				port, "port");
9171 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
9172 	TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
9173 				port_id, UINT16);
9174 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
9175 	TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9176 				cmd, "queue-region");
9177 
9178 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
9179 	.f = cmd_show_queue_region_info_parsed,
9180 	.data = NULL,
9181 	.help_str = "show port <port_id> queue-region"
9182 		": show all queue region related configuration info",
9183 	.tokens = {
9184 		(void *)&cmd_show_queue_region_info_get,
9185 		(void *)&cmd_show_queue_region_info_port,
9186 		(void *)&cmd_show_queue_region_info_port_index,
9187 		(void *)&cmd_show_queue_region_info_cmd,
9188 		NULL,
9189 	},
9190 };
9191 
9192 /* *** ADD/REMOVE A 2tuple FILTER *** */
9193 struct cmd_2tuple_filter_result {
9194 	cmdline_fixed_string_t filter;
9195 	portid_t port_id;
9196 	cmdline_fixed_string_t ops;
9197 	cmdline_fixed_string_t dst_port;
9198 	uint16_t dst_port_value;
9199 	cmdline_fixed_string_t protocol;
9200 	uint8_t protocol_value;
9201 	cmdline_fixed_string_t mask;
9202 	uint8_t  mask_value;
9203 	cmdline_fixed_string_t tcp_flags;
9204 	uint8_t tcp_flags_value;
9205 	cmdline_fixed_string_t priority;
9206 	uint8_t  priority_value;
9207 	cmdline_fixed_string_t queue;
9208 	uint16_t  queue_id;
9209 };
9210 
9211 static void
9212 cmd_2tuple_filter_parsed(void *parsed_result,
9213 			__attribute__((unused)) struct cmdline *cl,
9214 			__attribute__((unused)) void *data)
9215 {
9216 	struct rte_eth_ntuple_filter filter;
9217 	struct cmd_2tuple_filter_result *res = parsed_result;
9218 	int ret = 0;
9219 
9220 	ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
9221 	if (ret < 0) {
9222 		printf("ntuple filter is not supported on port %u.\n",
9223 			res->port_id);
9224 		return;
9225 	}
9226 
9227 	memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
9228 
9229 	filter.flags = RTE_2TUPLE_FLAGS;
9230 	filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
9231 	filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
9232 	filter.proto = res->protocol_value;
9233 	filter.priority = res->priority_value;
9234 	if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
9235 		printf("nonzero tcp_flags is only meaningful"
9236 			" when protocol is TCP.\n");
9237 		return;
9238 	}
9239 	if (res->tcp_flags_value > TCP_FLAG_ALL) {
9240 		printf("invalid TCP flags.\n");
9241 		return;
9242 	}
9243 
9244 	if (res->tcp_flags_value != 0) {
9245 		filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
9246 		filter.tcp_flags = res->tcp_flags_value;
9247 	}
9248 
9249 	/* need convert to big endian. */
9250 	filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
9251 	filter.queue = res->queue_id;
9252 
9253 	if (!strcmp(res->ops, "add"))
9254 		ret = rte_eth_dev_filter_ctrl(res->port_id,
9255 				RTE_ETH_FILTER_NTUPLE,
9256 				RTE_ETH_FILTER_ADD,
9257 				&filter);
9258 	else
9259 		ret = rte_eth_dev_filter_ctrl(res->port_id,
9260 				RTE_ETH_FILTER_NTUPLE,
9261 				RTE_ETH_FILTER_DELETE,
9262 				&filter);
9263 	if (ret < 0)
9264 		printf("2tuple filter programming error: (%s)\n",
9265 			strerror(-ret));
9266 
9267 }
9268 
9269 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
9270 	TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9271 				 filter, "2tuple_filter");
9272 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
9273 	TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9274 				port_id, UINT16);
9275 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
9276 	TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9277 				 ops, "add#del");
9278 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
9279 	TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9280 				dst_port, "dst_port");
9281 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
9282 	TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9283 				dst_port_value, UINT16);
9284 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
9285 	TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9286 				protocol, "protocol");
9287 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
9288 	TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9289 				protocol_value, UINT8);
9290 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
9291 	TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9292 				mask, "mask");
9293 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
9294 	TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9295 				mask_value, INT8);
9296 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
9297 	TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9298 				tcp_flags, "tcp_flags");
9299 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
9300 	TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9301 				tcp_flags_value, UINT8);
9302 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
9303 	TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9304 				priority, "priority");
9305 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
9306 	TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9307 				priority_value, UINT8);
9308 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
9309 	TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9310 				queue, "queue");
9311 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
9312 	TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9313 				queue_id, UINT16);
9314 
9315 cmdline_parse_inst_t cmd_2tuple_filter = {
9316 	.f = cmd_2tuple_filter_parsed,
9317 	.data = NULL,
9318 	.help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
9319 		"<value> mask <value> tcp_flags <value> priority <value> queue "
9320 		"<queue_id>: Add a 2tuple filter",
9321 	.tokens = {
9322 		(void *)&cmd_2tuple_filter_filter,
9323 		(void *)&cmd_2tuple_filter_port_id,
9324 		(void *)&cmd_2tuple_filter_ops,
9325 		(void *)&cmd_2tuple_filter_dst_port,
9326 		(void *)&cmd_2tuple_filter_dst_port_value,
9327 		(void *)&cmd_2tuple_filter_protocol,
9328 		(void *)&cmd_2tuple_filter_protocol_value,
9329 		(void *)&cmd_2tuple_filter_mask,
9330 		(void *)&cmd_2tuple_filter_mask_value,
9331 		(void *)&cmd_2tuple_filter_tcp_flags,
9332 		(void *)&cmd_2tuple_filter_tcp_flags_value,
9333 		(void *)&cmd_2tuple_filter_priority,
9334 		(void *)&cmd_2tuple_filter_priority_value,
9335 		(void *)&cmd_2tuple_filter_queue,
9336 		(void *)&cmd_2tuple_filter_queue_id,
9337 		NULL,
9338 	},
9339 };
9340 
9341 /* *** ADD/REMOVE A 5tuple FILTER *** */
9342 struct cmd_5tuple_filter_result {
9343 	cmdline_fixed_string_t filter;
9344 	portid_t port_id;
9345 	cmdline_fixed_string_t ops;
9346 	cmdline_fixed_string_t dst_ip;
9347 	cmdline_ipaddr_t dst_ip_value;
9348 	cmdline_fixed_string_t src_ip;
9349 	cmdline_ipaddr_t src_ip_value;
9350 	cmdline_fixed_string_t dst_port;
9351 	uint16_t dst_port_value;
9352 	cmdline_fixed_string_t src_port;
9353 	uint16_t src_port_value;
9354 	cmdline_fixed_string_t protocol;
9355 	uint8_t protocol_value;
9356 	cmdline_fixed_string_t mask;
9357 	uint8_t  mask_value;
9358 	cmdline_fixed_string_t tcp_flags;
9359 	uint8_t tcp_flags_value;
9360 	cmdline_fixed_string_t priority;
9361 	uint8_t  priority_value;
9362 	cmdline_fixed_string_t queue;
9363 	uint16_t  queue_id;
9364 };
9365 
9366 static void
9367 cmd_5tuple_filter_parsed(void *parsed_result,
9368 			__attribute__((unused)) struct cmdline *cl,
9369 			__attribute__((unused)) void *data)
9370 {
9371 	struct rte_eth_ntuple_filter filter;
9372 	struct cmd_5tuple_filter_result *res = parsed_result;
9373 	int ret = 0;
9374 
9375 	ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
9376 	if (ret < 0) {
9377 		printf("ntuple filter is not supported on port %u.\n",
9378 			res->port_id);
9379 		return;
9380 	}
9381 
9382 	memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
9383 
9384 	filter.flags = RTE_5TUPLE_FLAGS;
9385 	filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
9386 	filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
9387 	filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
9388 	filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
9389 	filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
9390 	filter.proto = res->protocol_value;
9391 	filter.priority = res->priority_value;
9392 	if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
9393 		printf("nonzero tcp_flags is only meaningful"
9394 			" when protocol is TCP.\n");
9395 		return;
9396 	}
9397 	if (res->tcp_flags_value > TCP_FLAG_ALL) {
9398 		printf("invalid TCP flags.\n");
9399 		return;
9400 	}
9401 
9402 	if (res->tcp_flags_value != 0) {
9403 		filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
9404 		filter.tcp_flags = res->tcp_flags_value;
9405 	}
9406 
9407 	if (res->dst_ip_value.family == AF_INET)
9408 		/* no need to convert, already big endian. */
9409 		filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
9410 	else {
9411 		if (filter.dst_ip_mask == 0) {
9412 			printf("can not support ipv6 involved compare.\n");
9413 			return;
9414 		}
9415 		filter.dst_ip = 0;
9416 	}
9417 
9418 	if (res->src_ip_value.family == AF_INET)
9419 		/* no need to convert, already big endian. */
9420 		filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
9421 	else {
9422 		if (filter.src_ip_mask == 0) {
9423 			printf("can not support ipv6 involved compare.\n");
9424 			return;
9425 		}
9426 		filter.src_ip = 0;
9427 	}
9428 	/* need convert to big endian. */
9429 	filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
9430 	filter.src_port = rte_cpu_to_be_16(res->src_port_value);
9431 	filter.queue = res->queue_id;
9432 
9433 	if (!strcmp(res->ops, "add"))
9434 		ret = rte_eth_dev_filter_ctrl(res->port_id,
9435 				RTE_ETH_FILTER_NTUPLE,
9436 				RTE_ETH_FILTER_ADD,
9437 				&filter);
9438 	else
9439 		ret = rte_eth_dev_filter_ctrl(res->port_id,
9440 				RTE_ETH_FILTER_NTUPLE,
9441 				RTE_ETH_FILTER_DELETE,
9442 				&filter);
9443 	if (ret < 0)
9444 		printf("5tuple filter programming error: (%s)\n",
9445 			strerror(-ret));
9446 }
9447 
9448 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
9449 	TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9450 				 filter, "5tuple_filter");
9451 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
9452 	TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9453 				port_id, UINT16);
9454 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
9455 	TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9456 				 ops, "add#del");
9457 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
9458 	TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9459 				dst_ip, "dst_ip");
9460 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
9461 	TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
9462 				dst_ip_value);
9463 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
9464 	TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9465 				src_ip, "src_ip");
9466 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
9467 	TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
9468 				src_ip_value);
9469 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
9470 	TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9471 				dst_port, "dst_port");
9472 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
9473 	TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9474 				dst_port_value, UINT16);
9475 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
9476 	TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9477 				src_port, "src_port");
9478 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
9479 	TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9480 				src_port_value, UINT16);
9481 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
9482 	TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9483 				protocol, "protocol");
9484 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
9485 	TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9486 				protocol_value, UINT8);
9487 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
9488 	TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9489 				mask, "mask");
9490 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
9491 	TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9492 				mask_value, INT8);
9493 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
9494 	TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9495 				tcp_flags, "tcp_flags");
9496 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
9497 	TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9498 				tcp_flags_value, UINT8);
9499 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
9500 	TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9501 				priority, "priority");
9502 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
9503 	TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9504 				priority_value, UINT8);
9505 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
9506 	TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9507 				queue, "queue");
9508 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
9509 	TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9510 				queue_id, UINT16);
9511 
9512 cmdline_parse_inst_t cmd_5tuple_filter = {
9513 	.f = cmd_5tuple_filter_parsed,
9514 	.data = NULL,
9515 	.help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
9516 		"src_ip <value> dst_port <value> src_port <value> "
9517 		"protocol <value>  mask <value> tcp_flags <value> "
9518 		"priority <value> queue <queue_id>: Add/Del a 5tuple filter",
9519 	.tokens = {
9520 		(void *)&cmd_5tuple_filter_filter,
9521 		(void *)&cmd_5tuple_filter_port_id,
9522 		(void *)&cmd_5tuple_filter_ops,
9523 		(void *)&cmd_5tuple_filter_dst_ip,
9524 		(void *)&cmd_5tuple_filter_dst_ip_value,
9525 		(void *)&cmd_5tuple_filter_src_ip,
9526 		(void *)&cmd_5tuple_filter_src_ip_value,
9527 		(void *)&cmd_5tuple_filter_dst_port,
9528 		(void *)&cmd_5tuple_filter_dst_port_value,
9529 		(void *)&cmd_5tuple_filter_src_port,
9530 		(void *)&cmd_5tuple_filter_src_port_value,
9531 		(void *)&cmd_5tuple_filter_protocol,
9532 		(void *)&cmd_5tuple_filter_protocol_value,
9533 		(void *)&cmd_5tuple_filter_mask,
9534 		(void *)&cmd_5tuple_filter_mask_value,
9535 		(void *)&cmd_5tuple_filter_tcp_flags,
9536 		(void *)&cmd_5tuple_filter_tcp_flags_value,
9537 		(void *)&cmd_5tuple_filter_priority,
9538 		(void *)&cmd_5tuple_filter_priority_value,
9539 		(void *)&cmd_5tuple_filter_queue,
9540 		(void *)&cmd_5tuple_filter_queue_id,
9541 		NULL,
9542 	},
9543 };
9544 
9545 /* *** ADD/REMOVE A flex FILTER *** */
9546 struct cmd_flex_filter_result {
9547 	cmdline_fixed_string_t filter;
9548 	cmdline_fixed_string_t ops;
9549 	portid_t port_id;
9550 	cmdline_fixed_string_t len;
9551 	uint8_t len_value;
9552 	cmdline_fixed_string_t bytes;
9553 	cmdline_fixed_string_t bytes_value;
9554 	cmdline_fixed_string_t mask;
9555 	cmdline_fixed_string_t mask_value;
9556 	cmdline_fixed_string_t priority;
9557 	uint8_t priority_value;
9558 	cmdline_fixed_string_t queue;
9559 	uint16_t queue_id;
9560 };
9561 
9562 static int xdigit2val(unsigned char c)
9563 {
9564 	int val;
9565 	if (isdigit(c))
9566 		val = c - '0';
9567 	else if (isupper(c))
9568 		val = c - 'A' + 10;
9569 	else
9570 		val = c - 'a' + 10;
9571 	return val;
9572 }
9573 
9574 static void
9575 cmd_flex_filter_parsed(void *parsed_result,
9576 			  __attribute__((unused)) struct cmdline *cl,
9577 			  __attribute__((unused)) void *data)
9578 {
9579 	int ret = 0;
9580 	struct rte_eth_flex_filter filter;
9581 	struct cmd_flex_filter_result *res = parsed_result;
9582 	char *bytes_ptr, *mask_ptr;
9583 	uint16_t len, i, j = 0;
9584 	char c;
9585 	int val;
9586 	uint8_t byte = 0;
9587 
9588 	if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
9589 		printf("the len exceed the max length 128\n");
9590 		return;
9591 	}
9592 	memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
9593 	filter.len = res->len_value;
9594 	filter.priority = res->priority_value;
9595 	filter.queue = res->queue_id;
9596 	bytes_ptr = res->bytes_value;
9597 	mask_ptr = res->mask_value;
9598 
9599 	 /* translate bytes string to array. */
9600 	if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
9601 		(bytes_ptr[1] == 'X')))
9602 		bytes_ptr += 2;
9603 	len = strnlen(bytes_ptr, res->len_value * 2);
9604 	if (len == 0 || (len % 8 != 0)) {
9605 		printf("please check len and bytes input\n");
9606 		return;
9607 	}
9608 	for (i = 0; i < len; i++) {
9609 		c = bytes_ptr[i];
9610 		if (isxdigit(c) == 0) {
9611 			/* invalid characters. */
9612 			printf("invalid input\n");
9613 			return;
9614 		}
9615 		val = xdigit2val(c);
9616 		if (i % 2) {
9617 			byte |= val;
9618 			filter.bytes[j] = byte;
9619 			printf("bytes[%d]:%02x ", j, filter.bytes[j]);
9620 			j++;
9621 			byte = 0;
9622 		} else
9623 			byte |= val << 4;
9624 	}
9625 	printf("\n");
9626 	 /* translate mask string to uint8_t array. */
9627 	if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
9628 		(mask_ptr[1] == 'X')))
9629 		mask_ptr += 2;
9630 	len = strnlen(mask_ptr, (res->len_value + 3) / 4);
9631 	if (len == 0) {
9632 		printf("invalid input\n");
9633 		return;
9634 	}
9635 	j = 0;
9636 	byte = 0;
9637 	for (i = 0; i < len; i++) {
9638 		c = mask_ptr[i];
9639 		if (isxdigit(c) == 0) {
9640 			/* invalid characters. */
9641 			printf("invalid input\n");
9642 			return;
9643 		}
9644 		val = xdigit2val(c);
9645 		if (i % 2) {
9646 			byte |= val;
9647 			filter.mask[j] = byte;
9648 			printf("mask[%d]:%02x ", j, filter.mask[j]);
9649 			j++;
9650 			byte = 0;
9651 		} else
9652 			byte |= val << 4;
9653 	}
9654 	printf("\n");
9655 
9656 	if (!strcmp(res->ops, "add"))
9657 		ret = rte_eth_dev_filter_ctrl(res->port_id,
9658 				RTE_ETH_FILTER_FLEXIBLE,
9659 				RTE_ETH_FILTER_ADD,
9660 				&filter);
9661 	else
9662 		ret = rte_eth_dev_filter_ctrl(res->port_id,
9663 				RTE_ETH_FILTER_FLEXIBLE,
9664 				RTE_ETH_FILTER_DELETE,
9665 				&filter);
9666 
9667 	if (ret < 0)
9668 		printf("flex filter setting error: (%s)\n", strerror(-ret));
9669 }
9670 
9671 cmdline_parse_token_string_t cmd_flex_filter_filter =
9672 	TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9673 				filter, "flex_filter");
9674 cmdline_parse_token_num_t cmd_flex_filter_port_id =
9675 	TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9676 				port_id, UINT16);
9677 cmdline_parse_token_string_t cmd_flex_filter_ops =
9678 	TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9679 				ops, "add#del");
9680 cmdline_parse_token_string_t cmd_flex_filter_len =
9681 	TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9682 				len, "len");
9683 cmdline_parse_token_num_t cmd_flex_filter_len_value =
9684 	TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9685 				len_value, UINT8);
9686 cmdline_parse_token_string_t cmd_flex_filter_bytes =
9687 	TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9688 				bytes, "bytes");
9689 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
9690 	TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9691 				bytes_value, NULL);
9692 cmdline_parse_token_string_t cmd_flex_filter_mask =
9693 	TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9694 				mask, "mask");
9695 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
9696 	TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9697 				mask_value, NULL);
9698 cmdline_parse_token_string_t cmd_flex_filter_priority =
9699 	TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9700 				priority, "priority");
9701 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
9702 	TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9703 				priority_value, UINT8);
9704 cmdline_parse_token_string_t cmd_flex_filter_queue =
9705 	TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9706 				queue, "queue");
9707 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
9708 	TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9709 				queue_id, UINT16);
9710 cmdline_parse_inst_t cmd_flex_filter = {
9711 	.f = cmd_flex_filter_parsed,
9712 	.data = NULL,
9713 	.help_str = "flex_filter <port_id> add|del len <value> bytes "
9714 		"<value> mask <value> priority <value> queue <queue_id>: "
9715 		"Add/Del a flex filter",
9716 	.tokens = {
9717 		(void *)&cmd_flex_filter_filter,
9718 		(void *)&cmd_flex_filter_port_id,
9719 		(void *)&cmd_flex_filter_ops,
9720 		(void *)&cmd_flex_filter_len,
9721 		(void *)&cmd_flex_filter_len_value,
9722 		(void *)&cmd_flex_filter_bytes,
9723 		(void *)&cmd_flex_filter_bytes_value,
9724 		(void *)&cmd_flex_filter_mask,
9725 		(void *)&cmd_flex_filter_mask_value,
9726 		(void *)&cmd_flex_filter_priority,
9727 		(void *)&cmd_flex_filter_priority_value,
9728 		(void *)&cmd_flex_filter_queue,
9729 		(void *)&cmd_flex_filter_queue_id,
9730 		NULL,
9731 	},
9732 };
9733 
9734 /* *** Filters Control *** */
9735 
9736 /* *** deal with ethertype filter *** */
9737 struct cmd_ethertype_filter_result {
9738 	cmdline_fixed_string_t filter;
9739 	portid_t port_id;
9740 	cmdline_fixed_string_t ops;
9741 	cmdline_fixed_string_t mac;
9742 	struct ether_addr mac_addr;
9743 	cmdline_fixed_string_t ethertype;
9744 	uint16_t ethertype_value;
9745 	cmdline_fixed_string_t drop;
9746 	cmdline_fixed_string_t queue;
9747 	uint16_t  queue_id;
9748 };
9749 
9750 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
9751 	TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9752 				 filter, "ethertype_filter");
9753 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
9754 	TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
9755 			      port_id, UINT16);
9756 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
9757 	TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9758 				 ops, "add#del");
9759 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
9760 	TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9761 				 mac, "mac_addr#mac_ignr");
9762 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
9763 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
9764 				     mac_addr);
9765 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
9766 	TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9767 				 ethertype, "ethertype");
9768 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
9769 	TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
9770 			      ethertype_value, UINT16);
9771 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
9772 	TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9773 				 drop, "drop#fwd");
9774 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
9775 	TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9776 				 queue, "queue");
9777 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
9778 	TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
9779 			      queue_id, UINT16);
9780 
9781 static void
9782 cmd_ethertype_filter_parsed(void *parsed_result,
9783 			  __attribute__((unused)) struct cmdline *cl,
9784 			  __attribute__((unused)) void *data)
9785 {
9786 	struct cmd_ethertype_filter_result *res = parsed_result;
9787 	struct rte_eth_ethertype_filter filter;
9788 	int ret = 0;
9789 
9790 	ret = rte_eth_dev_filter_supported(res->port_id,
9791 			RTE_ETH_FILTER_ETHERTYPE);
9792 	if (ret < 0) {
9793 		printf("ethertype filter is not supported on port %u.\n",
9794 			res->port_id);
9795 		return;
9796 	}
9797 
9798 	memset(&filter, 0, sizeof(filter));
9799 	if (!strcmp(res->mac, "mac_addr")) {
9800 		filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
9801 		rte_memcpy(&filter.mac_addr, &res->mac_addr,
9802 			sizeof(struct ether_addr));
9803 	}
9804 	if (!strcmp(res->drop, "drop"))
9805 		filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
9806 	filter.ether_type = res->ethertype_value;
9807 	filter.queue = res->queue_id;
9808 
9809 	if (!strcmp(res->ops, "add"))
9810 		ret = rte_eth_dev_filter_ctrl(res->port_id,
9811 				RTE_ETH_FILTER_ETHERTYPE,
9812 				RTE_ETH_FILTER_ADD,
9813 				&filter);
9814 	else
9815 		ret = rte_eth_dev_filter_ctrl(res->port_id,
9816 				RTE_ETH_FILTER_ETHERTYPE,
9817 				RTE_ETH_FILTER_DELETE,
9818 				&filter);
9819 	if (ret < 0)
9820 		printf("ethertype filter programming error: (%s)\n",
9821 			strerror(-ret));
9822 }
9823 
9824 cmdline_parse_inst_t cmd_ethertype_filter = {
9825 	.f = cmd_ethertype_filter_parsed,
9826 	.data = NULL,
9827 	.help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
9828 		"<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
9829 		"Add or delete an ethertype filter entry",
9830 	.tokens = {
9831 		(void *)&cmd_ethertype_filter_filter,
9832 		(void *)&cmd_ethertype_filter_port_id,
9833 		(void *)&cmd_ethertype_filter_ops,
9834 		(void *)&cmd_ethertype_filter_mac,
9835 		(void *)&cmd_ethertype_filter_mac_addr,
9836 		(void *)&cmd_ethertype_filter_ethertype,
9837 		(void *)&cmd_ethertype_filter_ethertype_value,
9838 		(void *)&cmd_ethertype_filter_drop,
9839 		(void *)&cmd_ethertype_filter_queue,
9840 		(void *)&cmd_ethertype_filter_queue_id,
9841 		NULL,
9842 	},
9843 };
9844 
9845 /* *** deal with flow director filter *** */
9846 struct cmd_flow_director_result {
9847 	cmdline_fixed_string_t flow_director_filter;
9848 	portid_t port_id;
9849 	cmdline_fixed_string_t mode;
9850 	cmdline_fixed_string_t mode_value;
9851 	cmdline_fixed_string_t ops;
9852 	cmdline_fixed_string_t flow;
9853 	cmdline_fixed_string_t flow_type;
9854 	cmdline_fixed_string_t ether;
9855 	uint16_t ether_type;
9856 	cmdline_fixed_string_t src;
9857 	cmdline_ipaddr_t ip_src;
9858 	uint16_t port_src;
9859 	cmdline_fixed_string_t dst;
9860 	cmdline_ipaddr_t ip_dst;
9861 	uint16_t port_dst;
9862 	cmdline_fixed_string_t verify_tag;
9863 	uint32_t verify_tag_value;
9864 	cmdline_ipaddr_t tos;
9865 	uint8_t tos_value;
9866 	cmdline_ipaddr_t proto;
9867 	uint8_t proto_value;
9868 	cmdline_ipaddr_t ttl;
9869 	uint8_t ttl_value;
9870 	cmdline_fixed_string_t vlan;
9871 	uint16_t vlan_value;
9872 	cmdline_fixed_string_t flexbytes;
9873 	cmdline_fixed_string_t flexbytes_value;
9874 	cmdline_fixed_string_t pf_vf;
9875 	cmdline_fixed_string_t drop;
9876 	cmdline_fixed_string_t queue;
9877 	uint16_t  queue_id;
9878 	cmdline_fixed_string_t fd_id;
9879 	uint32_t  fd_id_value;
9880 	cmdline_fixed_string_t mac;
9881 	struct ether_addr mac_addr;
9882 	cmdline_fixed_string_t tunnel;
9883 	cmdline_fixed_string_t tunnel_type;
9884 	cmdline_fixed_string_t tunnel_id;
9885 	uint32_t tunnel_id_value;
9886 	cmdline_fixed_string_t packet;
9887 	char filepath[];
9888 };
9889 
9890 static inline int
9891 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
9892 {
9893 	char s[256];
9894 	const char *p, *p0 = q_arg;
9895 	char *end;
9896 	unsigned long int_fld;
9897 	char *str_fld[max_num];
9898 	int i;
9899 	unsigned size;
9900 	int ret = -1;
9901 
9902 	p = strchr(p0, '(');
9903 	if (p == NULL)
9904 		return -1;
9905 	++p;
9906 	p0 = strchr(p, ')');
9907 	if (p0 == NULL)
9908 		return -1;
9909 
9910 	size = p0 - p;
9911 	if (size >= sizeof(s))
9912 		return -1;
9913 
9914 	snprintf(s, sizeof(s), "%.*s", size, p);
9915 	ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
9916 	if (ret < 0 || ret > max_num)
9917 		return -1;
9918 	for (i = 0; i < ret; i++) {
9919 		errno = 0;
9920 		int_fld = strtoul(str_fld[i], &end, 0);
9921 		if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
9922 			return -1;
9923 		flexbytes[i] = (uint8_t)int_fld;
9924 	}
9925 	return ret;
9926 }
9927 
9928 static uint16_t
9929 str2flowtype(char *string)
9930 {
9931 	uint8_t i = 0;
9932 	static const struct {
9933 		char str[32];
9934 		uint16_t type;
9935 	} flowtype_str[] = {
9936 		{"raw", RTE_ETH_FLOW_RAW},
9937 		{"ipv4", RTE_ETH_FLOW_IPV4},
9938 		{"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
9939 		{"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
9940 		{"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
9941 		{"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
9942 		{"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
9943 		{"ipv6", RTE_ETH_FLOW_IPV6},
9944 		{"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
9945 		{"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
9946 		{"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
9947 		{"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
9948 		{"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
9949 		{"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
9950 	};
9951 
9952 	for (i = 0; i < RTE_DIM(flowtype_str); i++) {
9953 		if (!strcmp(flowtype_str[i].str, string))
9954 			return flowtype_str[i].type;
9955 	}
9956 
9957 	if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
9958 		return (uint16_t)atoi(string);
9959 
9960 	return RTE_ETH_FLOW_UNKNOWN;
9961 }
9962 
9963 static enum rte_eth_fdir_tunnel_type
9964 str2fdir_tunneltype(char *string)
9965 {
9966 	uint8_t i = 0;
9967 
9968 	static const struct {
9969 		char str[32];
9970 		enum rte_eth_fdir_tunnel_type type;
9971 	} tunneltype_str[] = {
9972 		{"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
9973 		{"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
9974 	};
9975 
9976 	for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
9977 		if (!strcmp(tunneltype_str[i].str, string))
9978 			return tunneltype_str[i].type;
9979 	}
9980 	return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
9981 }
9982 
9983 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
9984 do { \
9985 	if ((ip_addr).family == AF_INET) \
9986 		(ip) = (ip_addr).addr.ipv4.s_addr; \
9987 	else { \
9988 		printf("invalid parameter.\n"); \
9989 		return; \
9990 	} \
9991 } while (0)
9992 
9993 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
9994 do { \
9995 	if ((ip_addr).family == AF_INET6) \
9996 		rte_memcpy(&(ip), \
9997 				 &((ip_addr).addr.ipv6), \
9998 				 sizeof(struct in6_addr)); \
9999 	else { \
10000 		printf("invalid parameter.\n"); \
10001 		return; \
10002 	} \
10003 } while (0)
10004 
10005 static void
10006 cmd_flow_director_filter_parsed(void *parsed_result,
10007 			  __attribute__((unused)) struct cmdline *cl,
10008 			  __attribute__((unused)) void *data)
10009 {
10010 	struct cmd_flow_director_result *res = parsed_result;
10011 	struct rte_eth_fdir_filter entry;
10012 	uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
10013 	char *end;
10014 	unsigned long vf_id;
10015 	int ret = 0;
10016 
10017 	ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
10018 	if (ret < 0) {
10019 		printf("flow director is not supported on port %u.\n",
10020 			res->port_id);
10021 		return;
10022 	}
10023 	memset(flexbytes, 0, sizeof(flexbytes));
10024 	memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
10025 
10026 	if (fdir_conf.mode ==  RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10027 		if (strcmp(res->mode_value, "MAC-VLAN")) {
10028 			printf("Please set mode to MAC-VLAN.\n");
10029 			return;
10030 		}
10031 	} else if (fdir_conf.mode ==  RTE_FDIR_MODE_PERFECT_TUNNEL) {
10032 		if (strcmp(res->mode_value, "Tunnel")) {
10033 			printf("Please set mode to Tunnel.\n");
10034 			return;
10035 		}
10036 	} else {
10037 		if (!strcmp(res->mode_value, "raw")) {
10038 #ifdef RTE_LIBRTE_I40E_PMD
10039 			struct rte_pmd_i40e_flow_type_mapping
10040 					mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
10041 			struct rte_pmd_i40e_pkt_template_conf conf;
10042 			uint16_t flow_type = str2flowtype(res->flow_type);
10043 			uint16_t i, port = res->port_id;
10044 			uint8_t add;
10045 
10046 			memset(&conf, 0, sizeof(conf));
10047 
10048 			if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
10049 				printf("Invalid flow type specified.\n");
10050 				return;
10051 			}
10052 			ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
10053 								 mapping);
10054 			if (ret)
10055 				return;
10056 			if (mapping[flow_type].pctype == 0ULL) {
10057 				printf("Invalid flow type specified.\n");
10058 				return;
10059 			}
10060 			for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
10061 				if (mapping[flow_type].pctype & (1ULL << i)) {
10062 					conf.input.pctype = i;
10063 					break;
10064 				}
10065 			}
10066 
10067 			conf.input.packet = open_file(res->filepath,
10068 						&conf.input.length);
10069 			if (!conf.input.packet)
10070 				return;
10071 			if (!strcmp(res->drop, "drop"))
10072 				conf.action.behavior =
10073 					RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
10074 			else
10075 				conf.action.behavior =
10076 					RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
10077 			conf.action.report_status =
10078 					RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
10079 			conf.action.rx_queue = res->queue_id;
10080 			conf.soft_id = res->fd_id_value;
10081 			add  = strcmp(res->ops, "del") ? 1 : 0;
10082 			ret = rte_pmd_i40e_flow_add_del_packet_template(port,
10083 									&conf,
10084 									add);
10085 			if (ret < 0)
10086 				printf("flow director config error: (%s)\n",
10087 				       strerror(-ret));
10088 			close_file(conf.input.packet);
10089 #endif
10090 			return;
10091 		} else if (strcmp(res->mode_value, "IP")) {
10092 			printf("Please set mode to IP or raw.\n");
10093 			return;
10094 		}
10095 		entry.input.flow_type = str2flowtype(res->flow_type);
10096 	}
10097 
10098 	ret = parse_flexbytes(res->flexbytes_value,
10099 					flexbytes,
10100 					RTE_ETH_FDIR_MAX_FLEXLEN);
10101 	if (ret < 0) {
10102 		printf("error: Cannot parse flexbytes input.\n");
10103 		return;
10104 	}
10105 
10106 	switch (entry.input.flow_type) {
10107 	case RTE_ETH_FLOW_FRAG_IPV4:
10108 	case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
10109 		entry.input.flow.ip4_flow.proto = res->proto_value;
10110 		/* fall-through */
10111 	case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
10112 	case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
10113 		IPV4_ADDR_TO_UINT(res->ip_dst,
10114 			entry.input.flow.ip4_flow.dst_ip);
10115 		IPV4_ADDR_TO_UINT(res->ip_src,
10116 			entry.input.flow.ip4_flow.src_ip);
10117 		entry.input.flow.ip4_flow.tos = res->tos_value;
10118 		entry.input.flow.ip4_flow.ttl = res->ttl_value;
10119 		/* need convert to big endian. */
10120 		entry.input.flow.udp4_flow.dst_port =
10121 				rte_cpu_to_be_16(res->port_dst);
10122 		entry.input.flow.udp4_flow.src_port =
10123 				rte_cpu_to_be_16(res->port_src);
10124 		break;
10125 	case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
10126 		IPV4_ADDR_TO_UINT(res->ip_dst,
10127 			entry.input.flow.sctp4_flow.ip.dst_ip);
10128 		IPV4_ADDR_TO_UINT(res->ip_src,
10129 			entry.input.flow.sctp4_flow.ip.src_ip);
10130 		entry.input.flow.ip4_flow.tos = res->tos_value;
10131 		entry.input.flow.ip4_flow.ttl = res->ttl_value;
10132 		/* need convert to big endian. */
10133 		entry.input.flow.sctp4_flow.dst_port =
10134 				rte_cpu_to_be_16(res->port_dst);
10135 		entry.input.flow.sctp4_flow.src_port =
10136 				rte_cpu_to_be_16(res->port_src);
10137 		entry.input.flow.sctp4_flow.verify_tag =
10138 				rte_cpu_to_be_32(res->verify_tag_value);
10139 		break;
10140 	case RTE_ETH_FLOW_FRAG_IPV6:
10141 	case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
10142 		entry.input.flow.ipv6_flow.proto = res->proto_value;
10143 		/* fall-through */
10144 	case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
10145 	case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
10146 		IPV6_ADDR_TO_ARRAY(res->ip_dst,
10147 			entry.input.flow.ipv6_flow.dst_ip);
10148 		IPV6_ADDR_TO_ARRAY(res->ip_src,
10149 			entry.input.flow.ipv6_flow.src_ip);
10150 		entry.input.flow.ipv6_flow.tc = res->tos_value;
10151 		entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
10152 		/* need convert to big endian. */
10153 		entry.input.flow.udp6_flow.dst_port =
10154 				rte_cpu_to_be_16(res->port_dst);
10155 		entry.input.flow.udp6_flow.src_port =
10156 				rte_cpu_to_be_16(res->port_src);
10157 		break;
10158 	case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
10159 		IPV6_ADDR_TO_ARRAY(res->ip_dst,
10160 			entry.input.flow.sctp6_flow.ip.dst_ip);
10161 		IPV6_ADDR_TO_ARRAY(res->ip_src,
10162 			entry.input.flow.sctp6_flow.ip.src_ip);
10163 		entry.input.flow.ipv6_flow.tc = res->tos_value;
10164 		entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
10165 		/* need convert to big endian. */
10166 		entry.input.flow.sctp6_flow.dst_port =
10167 				rte_cpu_to_be_16(res->port_dst);
10168 		entry.input.flow.sctp6_flow.src_port =
10169 				rte_cpu_to_be_16(res->port_src);
10170 		entry.input.flow.sctp6_flow.verify_tag =
10171 				rte_cpu_to_be_32(res->verify_tag_value);
10172 		break;
10173 	case RTE_ETH_FLOW_L2_PAYLOAD:
10174 		entry.input.flow.l2_flow.ether_type =
10175 			rte_cpu_to_be_16(res->ether_type);
10176 		break;
10177 	default:
10178 		break;
10179 	}
10180 
10181 	if (fdir_conf.mode ==  RTE_FDIR_MODE_PERFECT_MAC_VLAN)
10182 		rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
10183 				 &res->mac_addr,
10184 				 sizeof(struct ether_addr));
10185 
10186 	if (fdir_conf.mode ==  RTE_FDIR_MODE_PERFECT_TUNNEL) {
10187 		rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
10188 				 &res->mac_addr,
10189 				 sizeof(struct ether_addr));
10190 		entry.input.flow.tunnel_flow.tunnel_type =
10191 			str2fdir_tunneltype(res->tunnel_type);
10192 		entry.input.flow.tunnel_flow.tunnel_id =
10193 			rte_cpu_to_be_32(res->tunnel_id_value);
10194 	}
10195 
10196 	rte_memcpy(entry.input.flow_ext.flexbytes,
10197 		   flexbytes,
10198 		   RTE_ETH_FDIR_MAX_FLEXLEN);
10199 
10200 	entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
10201 
10202 	entry.action.flex_off = 0;  /*use 0 by default */
10203 	if (!strcmp(res->drop, "drop"))
10204 		entry.action.behavior = RTE_ETH_FDIR_REJECT;
10205 	else
10206 		entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
10207 
10208 	if (fdir_conf.mode !=  RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
10209 	    fdir_conf.mode !=  RTE_FDIR_MODE_PERFECT_TUNNEL) {
10210 		if (!strcmp(res->pf_vf, "pf"))
10211 			entry.input.flow_ext.is_vf = 0;
10212 		else if (!strncmp(res->pf_vf, "vf", 2)) {
10213 			struct rte_eth_dev_info dev_info;
10214 
10215 			memset(&dev_info, 0, sizeof(dev_info));
10216 			rte_eth_dev_info_get(res->port_id, &dev_info);
10217 			errno = 0;
10218 			vf_id = strtoul(res->pf_vf + 2, &end, 10);
10219 			if (errno != 0 || *end != '\0' ||
10220 			    vf_id >= dev_info.max_vfs) {
10221 				printf("invalid parameter %s.\n", res->pf_vf);
10222 				return;
10223 			}
10224 			entry.input.flow_ext.is_vf = 1;
10225 			entry.input.flow_ext.dst_id = (uint16_t)vf_id;
10226 		} else {
10227 			printf("invalid parameter %s.\n", res->pf_vf);
10228 			return;
10229 		}
10230 	}
10231 
10232 	/* set to report FD ID by default */
10233 	entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
10234 	entry.action.rx_queue = res->queue_id;
10235 	entry.soft_id = res->fd_id_value;
10236 	if (!strcmp(res->ops, "add"))
10237 		ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10238 					     RTE_ETH_FILTER_ADD, &entry);
10239 	else if (!strcmp(res->ops, "del"))
10240 		ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10241 					     RTE_ETH_FILTER_DELETE, &entry);
10242 	else
10243 		ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10244 					     RTE_ETH_FILTER_UPDATE, &entry);
10245 	if (ret < 0)
10246 		printf("flow director programming error: (%s)\n",
10247 			strerror(-ret));
10248 }
10249 
10250 cmdline_parse_token_string_t cmd_flow_director_filter =
10251 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10252 				 flow_director_filter, "flow_director_filter");
10253 cmdline_parse_token_num_t cmd_flow_director_port_id =
10254 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10255 			      port_id, UINT16);
10256 cmdline_parse_token_string_t cmd_flow_director_ops =
10257 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10258 				 ops, "add#del#update");
10259 cmdline_parse_token_string_t cmd_flow_director_flow =
10260 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10261 				 flow, "flow");
10262 cmdline_parse_token_string_t cmd_flow_director_flow_type =
10263 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10264 		flow_type, NULL);
10265 cmdline_parse_token_string_t cmd_flow_director_ether =
10266 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10267 				 ether, "ether");
10268 cmdline_parse_token_num_t cmd_flow_director_ether_type =
10269 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10270 			      ether_type, UINT16);
10271 cmdline_parse_token_string_t cmd_flow_director_src =
10272 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10273 				 src, "src");
10274 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
10275 	TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10276 				 ip_src);
10277 cmdline_parse_token_num_t cmd_flow_director_port_src =
10278 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10279 			      port_src, UINT16);
10280 cmdline_parse_token_string_t cmd_flow_director_dst =
10281 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10282 				 dst, "dst");
10283 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
10284 	TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10285 				 ip_dst);
10286 cmdline_parse_token_num_t cmd_flow_director_port_dst =
10287 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10288 			      port_dst, UINT16);
10289 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
10290 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10291 				  verify_tag, "verify_tag");
10292 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
10293 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10294 			      verify_tag_value, UINT32);
10295 cmdline_parse_token_string_t cmd_flow_director_tos =
10296 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10297 				 tos, "tos");
10298 cmdline_parse_token_num_t cmd_flow_director_tos_value =
10299 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10300 			      tos_value, UINT8);
10301 cmdline_parse_token_string_t cmd_flow_director_proto =
10302 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10303 				 proto, "proto");
10304 cmdline_parse_token_num_t cmd_flow_director_proto_value =
10305 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10306 			      proto_value, UINT8);
10307 cmdline_parse_token_string_t cmd_flow_director_ttl =
10308 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10309 				 ttl, "ttl");
10310 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
10311 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10312 			      ttl_value, UINT8);
10313 cmdline_parse_token_string_t cmd_flow_director_vlan =
10314 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10315 				 vlan, "vlan");
10316 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
10317 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10318 			      vlan_value, UINT16);
10319 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
10320 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10321 				 flexbytes, "flexbytes");
10322 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
10323 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10324 			      flexbytes_value, NULL);
10325 cmdline_parse_token_string_t cmd_flow_director_drop =
10326 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10327 				 drop, "drop#fwd");
10328 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
10329 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10330 			      pf_vf, NULL);
10331 cmdline_parse_token_string_t cmd_flow_director_queue =
10332 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10333 				 queue, "queue");
10334 cmdline_parse_token_num_t cmd_flow_director_queue_id =
10335 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10336 			      queue_id, UINT16);
10337 cmdline_parse_token_string_t cmd_flow_director_fd_id =
10338 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10339 				 fd_id, "fd_id");
10340 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
10341 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10342 			      fd_id_value, UINT32);
10343 
10344 cmdline_parse_token_string_t cmd_flow_director_mode =
10345 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10346 				 mode, "mode");
10347 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
10348 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10349 				 mode_value, "IP");
10350 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
10351 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10352 				 mode_value, "MAC-VLAN");
10353 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
10354 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10355 				 mode_value, "Tunnel");
10356 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
10357 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10358 				 mode_value, "raw");
10359 cmdline_parse_token_string_t cmd_flow_director_mac =
10360 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10361 				 mac, "mac");
10362 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
10363 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
10364 				    mac_addr);
10365 cmdline_parse_token_string_t cmd_flow_director_tunnel =
10366 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10367 				 tunnel, "tunnel");
10368 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
10369 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10370 				 tunnel_type, "NVGRE#VxLAN");
10371 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
10372 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10373 				 tunnel_id, "tunnel-id");
10374 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
10375 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10376 			      tunnel_id_value, UINT32);
10377 cmdline_parse_token_string_t cmd_flow_director_packet =
10378 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10379 				 packet, "packet");
10380 cmdline_parse_token_string_t cmd_flow_director_filepath =
10381 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10382 				 filepath, NULL);
10383 
10384 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
10385 	.f = cmd_flow_director_filter_parsed,
10386 	.data = NULL,
10387 	.help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
10388 		" ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
10389 		"ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
10390 		"l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
10391 		"proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
10392 		"flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> "
10393 		"fd_id <fd_id_value>: "
10394 		"Add or delete an ip flow director entry on NIC",
10395 	.tokens = {
10396 		(void *)&cmd_flow_director_filter,
10397 		(void *)&cmd_flow_director_port_id,
10398 		(void *)&cmd_flow_director_mode,
10399 		(void *)&cmd_flow_director_mode_ip,
10400 		(void *)&cmd_flow_director_ops,
10401 		(void *)&cmd_flow_director_flow,
10402 		(void *)&cmd_flow_director_flow_type,
10403 		(void *)&cmd_flow_director_src,
10404 		(void *)&cmd_flow_director_ip_src,
10405 		(void *)&cmd_flow_director_dst,
10406 		(void *)&cmd_flow_director_ip_dst,
10407 		(void *)&cmd_flow_director_tos,
10408 		(void *)&cmd_flow_director_tos_value,
10409 		(void *)&cmd_flow_director_proto,
10410 		(void *)&cmd_flow_director_proto_value,
10411 		(void *)&cmd_flow_director_ttl,
10412 		(void *)&cmd_flow_director_ttl_value,
10413 		(void *)&cmd_flow_director_vlan,
10414 		(void *)&cmd_flow_director_vlan_value,
10415 		(void *)&cmd_flow_director_flexbytes,
10416 		(void *)&cmd_flow_director_flexbytes_value,
10417 		(void *)&cmd_flow_director_drop,
10418 		(void *)&cmd_flow_director_pf_vf,
10419 		(void *)&cmd_flow_director_queue,
10420 		(void *)&cmd_flow_director_queue_id,
10421 		(void *)&cmd_flow_director_fd_id,
10422 		(void *)&cmd_flow_director_fd_id_value,
10423 		NULL,
10424 	},
10425 };
10426 
10427 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
10428 	.f = cmd_flow_director_filter_parsed,
10429 	.data = NULL,
10430 	.help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
10431 		"director entry on NIC",
10432 	.tokens = {
10433 		(void *)&cmd_flow_director_filter,
10434 		(void *)&cmd_flow_director_port_id,
10435 		(void *)&cmd_flow_director_mode,
10436 		(void *)&cmd_flow_director_mode_ip,
10437 		(void *)&cmd_flow_director_ops,
10438 		(void *)&cmd_flow_director_flow,
10439 		(void *)&cmd_flow_director_flow_type,
10440 		(void *)&cmd_flow_director_src,
10441 		(void *)&cmd_flow_director_ip_src,
10442 		(void *)&cmd_flow_director_port_src,
10443 		(void *)&cmd_flow_director_dst,
10444 		(void *)&cmd_flow_director_ip_dst,
10445 		(void *)&cmd_flow_director_port_dst,
10446 		(void *)&cmd_flow_director_tos,
10447 		(void *)&cmd_flow_director_tos_value,
10448 		(void *)&cmd_flow_director_ttl,
10449 		(void *)&cmd_flow_director_ttl_value,
10450 		(void *)&cmd_flow_director_vlan,
10451 		(void *)&cmd_flow_director_vlan_value,
10452 		(void *)&cmd_flow_director_flexbytes,
10453 		(void *)&cmd_flow_director_flexbytes_value,
10454 		(void *)&cmd_flow_director_drop,
10455 		(void *)&cmd_flow_director_pf_vf,
10456 		(void *)&cmd_flow_director_queue,
10457 		(void *)&cmd_flow_director_queue_id,
10458 		(void *)&cmd_flow_director_fd_id,
10459 		(void *)&cmd_flow_director_fd_id_value,
10460 		NULL,
10461 	},
10462 };
10463 
10464 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
10465 	.f = cmd_flow_director_filter_parsed,
10466 	.data = NULL,
10467 	.help_str = "flow_director_filter ... : Add or delete a sctp flow "
10468 		"director entry on NIC",
10469 	.tokens = {
10470 		(void *)&cmd_flow_director_filter,
10471 		(void *)&cmd_flow_director_port_id,
10472 		(void *)&cmd_flow_director_mode,
10473 		(void *)&cmd_flow_director_mode_ip,
10474 		(void *)&cmd_flow_director_ops,
10475 		(void *)&cmd_flow_director_flow,
10476 		(void *)&cmd_flow_director_flow_type,
10477 		(void *)&cmd_flow_director_src,
10478 		(void *)&cmd_flow_director_ip_src,
10479 		(void *)&cmd_flow_director_port_dst,
10480 		(void *)&cmd_flow_director_dst,
10481 		(void *)&cmd_flow_director_ip_dst,
10482 		(void *)&cmd_flow_director_port_dst,
10483 		(void *)&cmd_flow_director_verify_tag,
10484 		(void *)&cmd_flow_director_verify_tag_value,
10485 		(void *)&cmd_flow_director_tos,
10486 		(void *)&cmd_flow_director_tos_value,
10487 		(void *)&cmd_flow_director_ttl,
10488 		(void *)&cmd_flow_director_ttl_value,
10489 		(void *)&cmd_flow_director_vlan,
10490 		(void *)&cmd_flow_director_vlan_value,
10491 		(void *)&cmd_flow_director_flexbytes,
10492 		(void *)&cmd_flow_director_flexbytes_value,
10493 		(void *)&cmd_flow_director_drop,
10494 		(void *)&cmd_flow_director_pf_vf,
10495 		(void *)&cmd_flow_director_queue,
10496 		(void *)&cmd_flow_director_queue_id,
10497 		(void *)&cmd_flow_director_fd_id,
10498 		(void *)&cmd_flow_director_fd_id_value,
10499 		NULL,
10500 	},
10501 };
10502 
10503 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
10504 	.f = cmd_flow_director_filter_parsed,
10505 	.data = NULL,
10506 	.help_str = "flow_director_filter ... : Add or delete a L2 flow "
10507 		"director entry on NIC",
10508 	.tokens = {
10509 		(void *)&cmd_flow_director_filter,
10510 		(void *)&cmd_flow_director_port_id,
10511 		(void *)&cmd_flow_director_mode,
10512 		(void *)&cmd_flow_director_mode_ip,
10513 		(void *)&cmd_flow_director_ops,
10514 		(void *)&cmd_flow_director_flow,
10515 		(void *)&cmd_flow_director_flow_type,
10516 		(void *)&cmd_flow_director_ether,
10517 		(void *)&cmd_flow_director_ether_type,
10518 		(void *)&cmd_flow_director_flexbytes,
10519 		(void *)&cmd_flow_director_flexbytes_value,
10520 		(void *)&cmd_flow_director_drop,
10521 		(void *)&cmd_flow_director_pf_vf,
10522 		(void *)&cmd_flow_director_queue,
10523 		(void *)&cmd_flow_director_queue_id,
10524 		(void *)&cmd_flow_director_fd_id,
10525 		(void *)&cmd_flow_director_fd_id_value,
10526 		NULL,
10527 	},
10528 };
10529 
10530 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
10531 	.f = cmd_flow_director_filter_parsed,
10532 	.data = NULL,
10533 	.help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
10534 		"director entry on NIC",
10535 	.tokens = {
10536 		(void *)&cmd_flow_director_filter,
10537 		(void *)&cmd_flow_director_port_id,
10538 		(void *)&cmd_flow_director_mode,
10539 		(void *)&cmd_flow_director_mode_mac_vlan,
10540 		(void *)&cmd_flow_director_ops,
10541 		(void *)&cmd_flow_director_mac,
10542 		(void *)&cmd_flow_director_mac_addr,
10543 		(void *)&cmd_flow_director_vlan,
10544 		(void *)&cmd_flow_director_vlan_value,
10545 		(void *)&cmd_flow_director_flexbytes,
10546 		(void *)&cmd_flow_director_flexbytes_value,
10547 		(void *)&cmd_flow_director_drop,
10548 		(void *)&cmd_flow_director_queue,
10549 		(void *)&cmd_flow_director_queue_id,
10550 		(void *)&cmd_flow_director_fd_id,
10551 		(void *)&cmd_flow_director_fd_id_value,
10552 		NULL,
10553 	},
10554 };
10555 
10556 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
10557 	.f = cmd_flow_director_filter_parsed,
10558 	.data = NULL,
10559 	.help_str = "flow_director_filter ... : Add or delete a tunnel flow "
10560 		"director entry on NIC",
10561 	.tokens = {
10562 		(void *)&cmd_flow_director_filter,
10563 		(void *)&cmd_flow_director_port_id,
10564 		(void *)&cmd_flow_director_mode,
10565 		(void *)&cmd_flow_director_mode_tunnel,
10566 		(void *)&cmd_flow_director_ops,
10567 		(void *)&cmd_flow_director_mac,
10568 		(void *)&cmd_flow_director_mac_addr,
10569 		(void *)&cmd_flow_director_vlan,
10570 		(void *)&cmd_flow_director_vlan_value,
10571 		(void *)&cmd_flow_director_tunnel,
10572 		(void *)&cmd_flow_director_tunnel_type,
10573 		(void *)&cmd_flow_director_tunnel_id,
10574 		(void *)&cmd_flow_director_tunnel_id_value,
10575 		(void *)&cmd_flow_director_flexbytes,
10576 		(void *)&cmd_flow_director_flexbytes_value,
10577 		(void *)&cmd_flow_director_drop,
10578 		(void *)&cmd_flow_director_queue,
10579 		(void *)&cmd_flow_director_queue_id,
10580 		(void *)&cmd_flow_director_fd_id,
10581 		(void *)&cmd_flow_director_fd_id_value,
10582 		NULL,
10583 	},
10584 };
10585 
10586 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
10587 	.f = cmd_flow_director_filter_parsed,
10588 	.data = NULL,
10589 	.help_str = "flow_director_filter ... : Add or delete a raw flow "
10590 		"director entry on NIC",
10591 	.tokens = {
10592 		(void *)&cmd_flow_director_filter,
10593 		(void *)&cmd_flow_director_port_id,
10594 		(void *)&cmd_flow_director_mode,
10595 		(void *)&cmd_flow_director_mode_raw,
10596 		(void *)&cmd_flow_director_ops,
10597 		(void *)&cmd_flow_director_flow,
10598 		(void *)&cmd_flow_director_flow_type,
10599 		(void *)&cmd_flow_director_drop,
10600 		(void *)&cmd_flow_director_queue,
10601 		(void *)&cmd_flow_director_queue_id,
10602 		(void *)&cmd_flow_director_fd_id,
10603 		(void *)&cmd_flow_director_fd_id_value,
10604 		(void *)&cmd_flow_director_packet,
10605 		(void *)&cmd_flow_director_filepath,
10606 		NULL,
10607 	},
10608 };
10609 
10610 struct cmd_flush_flow_director_result {
10611 	cmdline_fixed_string_t flush_flow_director;
10612 	portid_t port_id;
10613 };
10614 
10615 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
10616 	TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
10617 				 flush_flow_director, "flush_flow_director");
10618 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
10619 	TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
10620 			      port_id, UINT16);
10621 
10622 static void
10623 cmd_flush_flow_director_parsed(void *parsed_result,
10624 			  __attribute__((unused)) struct cmdline *cl,
10625 			  __attribute__((unused)) void *data)
10626 {
10627 	struct cmd_flow_director_result *res = parsed_result;
10628 	int ret = 0;
10629 
10630 	ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
10631 	if (ret < 0) {
10632 		printf("flow director is not supported on port %u.\n",
10633 			res->port_id);
10634 		return;
10635 	}
10636 
10637 	ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10638 			RTE_ETH_FILTER_FLUSH, NULL);
10639 	if (ret < 0)
10640 		printf("flow director table flushing error: (%s)\n",
10641 			strerror(-ret));
10642 }
10643 
10644 cmdline_parse_inst_t cmd_flush_flow_director = {
10645 	.f = cmd_flush_flow_director_parsed,
10646 	.data = NULL,
10647 	.help_str = "flush_flow_director <port_id>: "
10648 		"Flush all flow director entries of a device on NIC",
10649 	.tokens = {
10650 		(void *)&cmd_flush_flow_director_flush,
10651 		(void *)&cmd_flush_flow_director_port_id,
10652 		NULL,
10653 	},
10654 };
10655 
10656 /* *** deal with flow director mask *** */
10657 struct cmd_flow_director_mask_result {
10658 	cmdline_fixed_string_t flow_director_mask;
10659 	portid_t port_id;
10660 	cmdline_fixed_string_t mode;
10661 	cmdline_fixed_string_t mode_value;
10662 	cmdline_fixed_string_t vlan;
10663 	uint16_t vlan_mask;
10664 	cmdline_fixed_string_t src_mask;
10665 	cmdline_ipaddr_t ipv4_src;
10666 	cmdline_ipaddr_t ipv6_src;
10667 	uint16_t port_src;
10668 	cmdline_fixed_string_t dst_mask;
10669 	cmdline_ipaddr_t ipv4_dst;
10670 	cmdline_ipaddr_t ipv6_dst;
10671 	uint16_t port_dst;
10672 	cmdline_fixed_string_t mac;
10673 	uint8_t mac_addr_byte_mask;
10674 	cmdline_fixed_string_t tunnel_id;
10675 	uint32_t tunnel_id_mask;
10676 	cmdline_fixed_string_t tunnel_type;
10677 	uint8_t tunnel_type_mask;
10678 };
10679 
10680 static void
10681 cmd_flow_director_mask_parsed(void *parsed_result,
10682 			  __attribute__((unused)) struct cmdline *cl,
10683 			  __attribute__((unused)) void *data)
10684 {
10685 	struct cmd_flow_director_mask_result *res = parsed_result;
10686 	struct rte_eth_fdir_masks *mask;
10687 	struct rte_port *port;
10688 
10689 	if (res->port_id > nb_ports) {
10690 		printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
10691 		return;
10692 	}
10693 
10694 	port = &ports[res->port_id];
10695 	/** Check if the port is not started **/
10696 	if (port->port_status != RTE_PORT_STOPPED) {
10697 		printf("Please stop port %d first\n", res->port_id);
10698 		return;
10699 	}
10700 
10701 	mask = &port->dev_conf.fdir_conf.mask;
10702 
10703 	if (fdir_conf.mode ==  RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10704 		if (strcmp(res->mode_value, "MAC-VLAN")) {
10705 			printf("Please set mode to MAC-VLAN.\n");
10706 			return;
10707 		}
10708 
10709 		mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10710 	} else if (fdir_conf.mode ==  RTE_FDIR_MODE_PERFECT_TUNNEL) {
10711 		if (strcmp(res->mode_value, "Tunnel")) {
10712 			printf("Please set mode to Tunnel.\n");
10713 			return;
10714 		}
10715 
10716 		mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10717 		mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
10718 		mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
10719 		mask->tunnel_type_mask = res->tunnel_type_mask;
10720 	} else {
10721 		if (strcmp(res->mode_value, "IP")) {
10722 			printf("Please set mode to IP.\n");
10723 			return;
10724 		}
10725 
10726 		mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10727 		IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
10728 		IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
10729 		IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
10730 		IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
10731 		mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
10732 		mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
10733 	}
10734 
10735 	cmd_reconfig_device_queue(res->port_id, 1, 1);
10736 }
10737 
10738 cmdline_parse_token_string_t cmd_flow_director_mask =
10739 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10740 				 flow_director_mask, "flow_director_mask");
10741 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
10742 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10743 			      port_id, UINT16);
10744 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
10745 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10746 				 vlan, "vlan");
10747 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
10748 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10749 			      vlan_mask, UINT16);
10750 cmdline_parse_token_string_t cmd_flow_director_mask_src =
10751 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10752 				 src_mask, "src_mask");
10753 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
10754 	TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10755 				 ipv4_src);
10756 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
10757 	TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10758 				 ipv6_src);
10759 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
10760 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10761 			      port_src, UINT16);
10762 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
10763 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10764 				 dst_mask, "dst_mask");
10765 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
10766 	TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10767 				 ipv4_dst);
10768 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
10769 	TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10770 				 ipv6_dst);
10771 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
10772 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10773 			      port_dst, UINT16);
10774 
10775 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
10776 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10777 				 mode, "mode");
10778 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
10779 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10780 				 mode_value, "IP");
10781 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
10782 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10783 				 mode_value, "MAC-VLAN");
10784 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
10785 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10786 				 mode_value, "Tunnel");
10787 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
10788 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10789 				 mac, "mac");
10790 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
10791 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10792 			      mac_addr_byte_mask, UINT8);
10793 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
10794 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10795 				 tunnel_type, "tunnel-type");
10796 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
10797 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10798 			      tunnel_type_mask, UINT8);
10799 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
10800 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10801 				 tunnel_id, "tunnel-id");
10802 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
10803 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10804 			      tunnel_id_mask, UINT32);
10805 
10806 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
10807 	.f = cmd_flow_director_mask_parsed,
10808 	.data = NULL,
10809 	.help_str = "flow_director_mask ... : "
10810 		"Set IP mode flow director's mask on NIC",
10811 	.tokens = {
10812 		(void *)&cmd_flow_director_mask,
10813 		(void *)&cmd_flow_director_mask_port_id,
10814 		(void *)&cmd_flow_director_mask_mode,
10815 		(void *)&cmd_flow_director_mask_mode_ip,
10816 		(void *)&cmd_flow_director_mask_vlan,
10817 		(void *)&cmd_flow_director_mask_vlan_value,
10818 		(void *)&cmd_flow_director_mask_src,
10819 		(void *)&cmd_flow_director_mask_ipv4_src,
10820 		(void *)&cmd_flow_director_mask_ipv6_src,
10821 		(void *)&cmd_flow_director_mask_port_src,
10822 		(void *)&cmd_flow_director_mask_dst,
10823 		(void *)&cmd_flow_director_mask_ipv4_dst,
10824 		(void *)&cmd_flow_director_mask_ipv6_dst,
10825 		(void *)&cmd_flow_director_mask_port_dst,
10826 		NULL,
10827 	},
10828 };
10829 
10830 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
10831 	.f = cmd_flow_director_mask_parsed,
10832 	.data = NULL,
10833 	.help_str = "flow_director_mask ... : Set MAC VLAN mode "
10834 		"flow director's mask on NIC",
10835 	.tokens = {
10836 		(void *)&cmd_flow_director_mask,
10837 		(void *)&cmd_flow_director_mask_port_id,
10838 		(void *)&cmd_flow_director_mask_mode,
10839 		(void *)&cmd_flow_director_mask_mode_mac_vlan,
10840 		(void *)&cmd_flow_director_mask_vlan,
10841 		(void *)&cmd_flow_director_mask_vlan_value,
10842 		NULL,
10843 	},
10844 };
10845 
10846 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
10847 	.f = cmd_flow_director_mask_parsed,
10848 	.data = NULL,
10849 	.help_str = "flow_director_mask ... : Set tunnel mode "
10850 		"flow director's mask on NIC",
10851 	.tokens = {
10852 		(void *)&cmd_flow_director_mask,
10853 		(void *)&cmd_flow_director_mask_port_id,
10854 		(void *)&cmd_flow_director_mask_mode,
10855 		(void *)&cmd_flow_director_mask_mode_tunnel,
10856 		(void *)&cmd_flow_director_mask_vlan,
10857 		(void *)&cmd_flow_director_mask_vlan_value,
10858 		(void *)&cmd_flow_director_mask_mac,
10859 		(void *)&cmd_flow_director_mask_mac_value,
10860 		(void *)&cmd_flow_director_mask_tunnel_type,
10861 		(void *)&cmd_flow_director_mask_tunnel_type_value,
10862 		(void *)&cmd_flow_director_mask_tunnel_id,
10863 		(void *)&cmd_flow_director_mask_tunnel_id_value,
10864 		NULL,
10865 	},
10866 };
10867 
10868 /* *** deal with flow director mask on flexible payload *** */
10869 struct cmd_flow_director_flex_mask_result {
10870 	cmdline_fixed_string_t flow_director_flexmask;
10871 	portid_t port_id;
10872 	cmdline_fixed_string_t flow;
10873 	cmdline_fixed_string_t flow_type;
10874 	cmdline_fixed_string_t mask;
10875 };
10876 
10877 static void
10878 cmd_flow_director_flex_mask_parsed(void *parsed_result,
10879 			  __attribute__((unused)) struct cmdline *cl,
10880 			  __attribute__((unused)) void *data)
10881 {
10882 	struct cmd_flow_director_flex_mask_result *res = parsed_result;
10883 	struct rte_eth_fdir_info fdir_info;
10884 	struct rte_eth_fdir_flex_mask flex_mask;
10885 	struct rte_port *port;
10886 	uint32_t flow_type_mask;
10887 	uint16_t i;
10888 	int ret;
10889 
10890 	if (res->port_id > nb_ports) {
10891 		printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
10892 		return;
10893 	}
10894 
10895 	port = &ports[res->port_id];
10896 	/** Check if the port is not started **/
10897 	if (port->port_status != RTE_PORT_STOPPED) {
10898 		printf("Please stop port %d first\n", res->port_id);
10899 		return;
10900 	}
10901 
10902 	memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
10903 	ret = parse_flexbytes(res->mask,
10904 			flex_mask.mask,
10905 			RTE_ETH_FDIR_MAX_FLEXLEN);
10906 	if (ret < 0) {
10907 		printf("error: Cannot parse mask input.\n");
10908 		return;
10909 	}
10910 
10911 	memset(&fdir_info, 0, sizeof(fdir_info));
10912 	ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10913 				RTE_ETH_FILTER_INFO, &fdir_info);
10914 	if (ret < 0) {
10915 		printf("Cannot get FDir filter info\n");
10916 		return;
10917 	}
10918 
10919 	if (!strcmp(res->flow_type, "none")) {
10920 		/* means don't specify the flow type */
10921 		flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
10922 		for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
10923 			memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
10924 			       0, sizeof(struct rte_eth_fdir_flex_mask));
10925 		port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
10926 		rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
10927 				 &flex_mask,
10928 				 sizeof(struct rte_eth_fdir_flex_mask));
10929 		cmd_reconfig_device_queue(res->port_id, 1, 1);
10930 		return;
10931 	}
10932 	flow_type_mask = fdir_info.flow_types_mask[0];
10933 	if (!strcmp(res->flow_type, "all")) {
10934 		if (!flow_type_mask) {
10935 			printf("No flow type supported\n");
10936 			return;
10937 		}
10938 		for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
10939 			if (flow_type_mask & (1 << i)) {
10940 				flex_mask.flow_type = i;
10941 				fdir_set_flex_mask(res->port_id, &flex_mask);
10942 			}
10943 		}
10944 		cmd_reconfig_device_queue(res->port_id, 1, 1);
10945 		return;
10946 	}
10947 	flex_mask.flow_type = str2flowtype(res->flow_type);
10948 	if (!(flow_type_mask & (1 << flex_mask.flow_type))) {
10949 		printf("Flow type %s not supported on port %d\n",
10950 				res->flow_type, res->port_id);
10951 		return;
10952 	}
10953 	fdir_set_flex_mask(res->port_id, &flex_mask);
10954 	cmd_reconfig_device_queue(res->port_id, 1, 1);
10955 }
10956 
10957 cmdline_parse_token_string_t cmd_flow_director_flexmask =
10958 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10959 				 flow_director_flexmask,
10960 				 "flow_director_flex_mask");
10961 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
10962 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10963 			      port_id, UINT16);
10964 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
10965 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10966 				 flow, "flow");
10967 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
10968 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10969 		flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
10970 		"ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
10971 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
10972 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10973 				 mask, NULL);
10974 
10975 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
10976 	.f = cmd_flow_director_flex_mask_parsed,
10977 	.data = NULL,
10978 	.help_str = "flow_director_flex_mask ... : "
10979 		"Set flow director's flex mask on NIC",
10980 	.tokens = {
10981 		(void *)&cmd_flow_director_flexmask,
10982 		(void *)&cmd_flow_director_flexmask_port_id,
10983 		(void *)&cmd_flow_director_flexmask_flow,
10984 		(void *)&cmd_flow_director_flexmask_flow_type,
10985 		(void *)&cmd_flow_director_flexmask_mask,
10986 		NULL,
10987 	},
10988 };
10989 
10990 /* *** deal with flow director flexible payload configuration *** */
10991 struct cmd_flow_director_flexpayload_result {
10992 	cmdline_fixed_string_t flow_director_flexpayload;
10993 	portid_t port_id;
10994 	cmdline_fixed_string_t payload_layer;
10995 	cmdline_fixed_string_t payload_cfg;
10996 };
10997 
10998 static inline int
10999 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
11000 {
11001 	char s[256];
11002 	const char *p, *p0 = q_arg;
11003 	char *end;
11004 	unsigned long int_fld;
11005 	char *str_fld[max_num];
11006 	int i;
11007 	unsigned size;
11008 	int ret = -1;
11009 
11010 	p = strchr(p0, '(');
11011 	if (p == NULL)
11012 		return -1;
11013 	++p;
11014 	p0 = strchr(p, ')');
11015 	if (p0 == NULL)
11016 		return -1;
11017 
11018 	size = p0 - p;
11019 	if (size >= sizeof(s))
11020 		return -1;
11021 
11022 	snprintf(s, sizeof(s), "%.*s", size, p);
11023 	ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
11024 	if (ret < 0 || ret > max_num)
11025 		return -1;
11026 	for (i = 0; i < ret; i++) {
11027 		errno = 0;
11028 		int_fld = strtoul(str_fld[i], &end, 0);
11029 		if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
11030 			return -1;
11031 		offsets[i] = (uint16_t)int_fld;
11032 	}
11033 	return ret;
11034 }
11035 
11036 static void
11037 cmd_flow_director_flxpld_parsed(void *parsed_result,
11038 			  __attribute__((unused)) struct cmdline *cl,
11039 			  __attribute__((unused)) void *data)
11040 {
11041 	struct cmd_flow_director_flexpayload_result *res = parsed_result;
11042 	struct rte_eth_flex_payload_cfg flex_cfg;
11043 	struct rte_port *port;
11044 	int ret = 0;
11045 
11046 	if (res->port_id > nb_ports) {
11047 		printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
11048 		return;
11049 	}
11050 
11051 	port = &ports[res->port_id];
11052 	/** Check if the port is not started **/
11053 	if (port->port_status != RTE_PORT_STOPPED) {
11054 		printf("Please stop port %d first\n", res->port_id);
11055 		return;
11056 	}
11057 
11058 	memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
11059 
11060 	if (!strcmp(res->payload_layer, "raw"))
11061 		flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
11062 	else if (!strcmp(res->payload_layer, "l2"))
11063 		flex_cfg.type = RTE_ETH_L2_PAYLOAD;
11064 	else if (!strcmp(res->payload_layer, "l3"))
11065 		flex_cfg.type = RTE_ETH_L3_PAYLOAD;
11066 	else if (!strcmp(res->payload_layer, "l4"))
11067 		flex_cfg.type = RTE_ETH_L4_PAYLOAD;
11068 
11069 	ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
11070 			    RTE_ETH_FDIR_MAX_FLEXLEN);
11071 	if (ret < 0) {
11072 		printf("error: Cannot parse flex payload input.\n");
11073 		return;
11074 	}
11075 
11076 	fdir_set_flex_payload(res->port_id, &flex_cfg);
11077 	cmd_reconfig_device_queue(res->port_id, 1, 1);
11078 }
11079 
11080 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
11081 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11082 				 flow_director_flexpayload,
11083 				 "flow_director_flex_payload");
11084 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
11085 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11086 			      port_id, UINT16);
11087 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
11088 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11089 				 payload_layer, "raw#l2#l3#l4");
11090 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
11091 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11092 				 payload_cfg, NULL);
11093 
11094 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
11095 	.f = cmd_flow_director_flxpld_parsed,
11096 	.data = NULL,
11097 	.help_str = "flow_director_flexpayload ... : "
11098 		"Set flow director's flex payload on NIC",
11099 	.tokens = {
11100 		(void *)&cmd_flow_director_flexpayload,
11101 		(void *)&cmd_flow_director_flexpayload_port_id,
11102 		(void *)&cmd_flow_director_flexpayload_payload_layer,
11103 		(void *)&cmd_flow_director_flexpayload_payload_cfg,
11104 		NULL,
11105 	},
11106 };
11107 
11108 /* Generic flow interface command. */
11109 extern cmdline_parse_inst_t cmd_flow;
11110 
11111 /* *** Classification Filters Control *** */
11112 /* *** Get symmetric hash enable per port *** */
11113 struct cmd_get_sym_hash_ena_per_port_result {
11114 	cmdline_fixed_string_t get_sym_hash_ena_per_port;
11115 	portid_t port_id;
11116 };
11117 
11118 static void
11119 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
11120 				 __rte_unused struct cmdline *cl,
11121 				 __rte_unused void *data)
11122 {
11123 	struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
11124 	struct rte_eth_hash_filter_info info;
11125 	int ret;
11126 
11127 	if (rte_eth_dev_filter_supported(res->port_id,
11128 				RTE_ETH_FILTER_HASH) < 0) {
11129 		printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
11130 							res->port_id);
11131 		return;
11132 	}
11133 
11134 	memset(&info, 0, sizeof(info));
11135 	info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
11136 	ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11137 						RTE_ETH_FILTER_GET, &info);
11138 
11139 	if (ret < 0) {
11140 		printf("Cannot get symmetric hash enable per port "
11141 					"on port %u\n", res->port_id);
11142 		return;
11143 	}
11144 
11145 	printf("Symmetric hash is %s on port %u\n", info.info.enable ?
11146 				"enabled" : "disabled", res->port_id);
11147 }
11148 
11149 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
11150 	TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
11151 		get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
11152 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
11153 	TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
11154 		port_id, UINT16);
11155 
11156 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
11157 	.f = cmd_get_sym_hash_per_port_parsed,
11158 	.data = NULL,
11159 	.help_str = "get_sym_hash_ena_per_port <port_id>",
11160 	.tokens = {
11161 		(void *)&cmd_get_sym_hash_ena_per_port_all,
11162 		(void *)&cmd_get_sym_hash_ena_per_port_port_id,
11163 		NULL,
11164 	},
11165 };
11166 
11167 /* *** Set symmetric hash enable per port *** */
11168 struct cmd_set_sym_hash_ena_per_port_result {
11169 	cmdline_fixed_string_t set_sym_hash_ena_per_port;
11170 	cmdline_fixed_string_t enable;
11171 	portid_t port_id;
11172 };
11173 
11174 static void
11175 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
11176 				 __rte_unused struct cmdline *cl,
11177 				 __rte_unused void *data)
11178 {
11179 	struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
11180 	struct rte_eth_hash_filter_info info;
11181 	int ret;
11182 
11183 	if (rte_eth_dev_filter_supported(res->port_id,
11184 				RTE_ETH_FILTER_HASH) < 0) {
11185 		printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
11186 							res->port_id);
11187 		return;
11188 	}
11189 
11190 	memset(&info, 0, sizeof(info));
11191 	info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
11192 	if (!strcmp(res->enable, "enable"))
11193 		info.info.enable = 1;
11194 	ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11195 					RTE_ETH_FILTER_SET, &info);
11196 	if (ret < 0) {
11197 		printf("Cannot set symmetric hash enable per port on "
11198 					"port %u\n", res->port_id);
11199 		return;
11200 	}
11201 	printf("Symmetric hash has been set to %s on port %u\n",
11202 					res->enable, res->port_id);
11203 }
11204 
11205 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
11206 	TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11207 		set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
11208 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
11209 	TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11210 		port_id, UINT16);
11211 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
11212 	TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11213 		enable, "enable#disable");
11214 
11215 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
11216 	.f = cmd_set_sym_hash_per_port_parsed,
11217 	.data = NULL,
11218 	.help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
11219 	.tokens = {
11220 		(void *)&cmd_set_sym_hash_ena_per_port_all,
11221 		(void *)&cmd_set_sym_hash_ena_per_port_port_id,
11222 		(void *)&cmd_set_sym_hash_ena_per_port_enable,
11223 		NULL,
11224 	},
11225 };
11226 
11227 /* Get global config of hash function */
11228 struct cmd_get_hash_global_config_result {
11229 	cmdline_fixed_string_t get_hash_global_config;
11230 	portid_t port_id;
11231 };
11232 
11233 static char *
11234 flowtype_to_str(uint16_t ftype)
11235 {
11236 	uint16_t i;
11237 	static struct {
11238 		char str[16];
11239 		uint16_t ftype;
11240 	} ftype_table[] = {
11241 		{"ipv4", RTE_ETH_FLOW_IPV4},
11242 		{"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
11243 		{"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
11244 		{"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
11245 		{"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
11246 		{"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
11247 		{"ipv6", RTE_ETH_FLOW_IPV6},
11248 		{"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
11249 		{"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
11250 		{"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
11251 		{"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
11252 		{"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
11253 		{"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
11254 		{"port", RTE_ETH_FLOW_PORT},
11255 		{"vxlan", RTE_ETH_FLOW_VXLAN},
11256 		{"geneve", RTE_ETH_FLOW_GENEVE},
11257 		{"nvgre", RTE_ETH_FLOW_NVGRE},
11258 	};
11259 
11260 	for (i = 0; i < RTE_DIM(ftype_table); i++) {
11261 		if (ftype_table[i].ftype == ftype)
11262 			return ftype_table[i].str;
11263 	}
11264 
11265 	return NULL;
11266 }
11267 
11268 static void
11269 cmd_get_hash_global_config_parsed(void *parsed_result,
11270 				  __rte_unused struct cmdline *cl,
11271 				  __rte_unused void *data)
11272 {
11273 	struct cmd_get_hash_global_config_result *res = parsed_result;
11274 	struct rte_eth_hash_filter_info info;
11275 	uint32_t idx, offset;
11276 	uint16_t i;
11277 	char *str;
11278 	int ret;
11279 
11280 	if (rte_eth_dev_filter_supported(res->port_id,
11281 			RTE_ETH_FILTER_HASH) < 0) {
11282 		printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
11283 							res->port_id);
11284 		return;
11285 	}
11286 
11287 	memset(&info, 0, sizeof(info));
11288 	info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
11289 	ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11290 					RTE_ETH_FILTER_GET, &info);
11291 	if (ret < 0) {
11292 		printf("Cannot get hash global configurations by port %d\n",
11293 							res->port_id);
11294 		return;
11295 	}
11296 
11297 	switch (info.info.global_conf.hash_func) {
11298 	case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
11299 		printf("Hash function is Toeplitz\n");
11300 		break;
11301 	case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
11302 		printf("Hash function is Simple XOR\n");
11303 		break;
11304 	default:
11305 		printf("Unknown hash function\n");
11306 		break;
11307 	}
11308 
11309 	for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
11310 		idx = i / UINT32_BIT;
11311 		offset = i % UINT32_BIT;
11312 		if (!(info.info.global_conf.valid_bit_mask[idx] &
11313 						(1UL << offset)))
11314 			continue;
11315 		str = flowtype_to_str(i);
11316 		if (!str)
11317 			continue;
11318 		printf("Symmetric hash is %s globally for flow type %s "
11319 							"by port %d\n",
11320 			((info.info.global_conf.sym_hash_enable_mask[idx] &
11321 			(1UL << offset)) ? "enabled" : "disabled"), str,
11322 							res->port_id);
11323 	}
11324 }
11325 
11326 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
11327 	TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
11328 		get_hash_global_config, "get_hash_global_config");
11329 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
11330 	TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
11331 		port_id, UINT16);
11332 
11333 cmdline_parse_inst_t cmd_get_hash_global_config = {
11334 	.f = cmd_get_hash_global_config_parsed,
11335 	.data = NULL,
11336 	.help_str = "get_hash_global_config <port_id>",
11337 	.tokens = {
11338 		(void *)&cmd_get_hash_global_config_all,
11339 		(void *)&cmd_get_hash_global_config_port_id,
11340 		NULL,
11341 	},
11342 };
11343 
11344 /* Set global config of hash function */
11345 struct cmd_set_hash_global_config_result {
11346 	cmdline_fixed_string_t set_hash_global_config;
11347 	portid_t port_id;
11348 	cmdline_fixed_string_t hash_func;
11349 	cmdline_fixed_string_t flow_type;
11350 	cmdline_fixed_string_t enable;
11351 };
11352 
11353 static void
11354 cmd_set_hash_global_config_parsed(void *parsed_result,
11355 				  __rte_unused struct cmdline *cl,
11356 				  __rte_unused void *data)
11357 {
11358 	struct cmd_set_hash_global_config_result *res = parsed_result;
11359 	struct rte_eth_hash_filter_info info;
11360 	uint32_t ftype, idx, offset;
11361 	int ret;
11362 
11363 	if (rte_eth_dev_filter_supported(res->port_id,
11364 				RTE_ETH_FILTER_HASH) < 0) {
11365 		printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
11366 							res->port_id);
11367 		return;
11368 	}
11369 	memset(&info, 0, sizeof(info));
11370 	info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
11371 	if (!strcmp(res->hash_func, "toeplitz"))
11372 		info.info.global_conf.hash_func =
11373 			RTE_ETH_HASH_FUNCTION_TOEPLITZ;
11374 	else if (!strcmp(res->hash_func, "simple_xor"))
11375 		info.info.global_conf.hash_func =
11376 			RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
11377 	else if (!strcmp(res->hash_func, "default"))
11378 		info.info.global_conf.hash_func =
11379 			RTE_ETH_HASH_FUNCTION_DEFAULT;
11380 
11381 	ftype = str2flowtype(res->flow_type);
11382 	idx = ftype / (CHAR_BIT * sizeof(uint32_t));
11383 	offset = ftype % (CHAR_BIT * sizeof(uint32_t));
11384 	info.info.global_conf.valid_bit_mask[idx] |= (1UL << offset);
11385 	if (!strcmp(res->enable, "enable"))
11386 		info.info.global_conf.sym_hash_enable_mask[idx] |=
11387 						(1UL << offset);
11388 	ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11389 					RTE_ETH_FILTER_SET, &info);
11390 	if (ret < 0)
11391 		printf("Cannot set global hash configurations by port %d\n",
11392 							res->port_id);
11393 	else
11394 		printf("Global hash configurations have been set "
11395 			"succcessfully by port %d\n", res->port_id);
11396 }
11397 
11398 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
11399 	TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11400 		set_hash_global_config, "set_hash_global_config");
11401 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
11402 	TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
11403 		port_id, UINT16);
11404 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
11405 	TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11406 		hash_func, "toeplitz#simple_xor#default");
11407 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
11408 	TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11409 		flow_type,
11410 		"ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
11411 		"ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
11412 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
11413 	TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11414 		enable, "enable#disable");
11415 
11416 cmdline_parse_inst_t cmd_set_hash_global_config = {
11417 	.f = cmd_set_hash_global_config_parsed,
11418 	.data = NULL,
11419 	.help_str = "set_hash_global_config <port_id> "
11420 		"toeplitz|simple_xor|default "
11421 		"ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11422 		"ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
11423 		"l2_payload enable|disable",
11424 	.tokens = {
11425 		(void *)&cmd_set_hash_global_config_all,
11426 		(void *)&cmd_set_hash_global_config_port_id,
11427 		(void *)&cmd_set_hash_global_config_hash_func,
11428 		(void *)&cmd_set_hash_global_config_flow_type,
11429 		(void *)&cmd_set_hash_global_config_enable,
11430 		NULL,
11431 	},
11432 };
11433 
11434 /* Set hash input set */
11435 struct cmd_set_hash_input_set_result {
11436 	cmdline_fixed_string_t set_hash_input_set;
11437 	portid_t port_id;
11438 	cmdline_fixed_string_t flow_type;
11439 	cmdline_fixed_string_t inset_field;
11440 	cmdline_fixed_string_t select;
11441 };
11442 
11443 static enum rte_eth_input_set_field
11444 str2inset(char *string)
11445 {
11446 	uint16_t i;
11447 
11448 	static const struct {
11449 		char str[32];
11450 		enum rte_eth_input_set_field inset;
11451 	} inset_table[] = {
11452 		{"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
11453 		{"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
11454 		{"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
11455 		{"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
11456 		{"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
11457 		{"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
11458 		{"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
11459 		{"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
11460 		{"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
11461 		{"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
11462 		{"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
11463 		{"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
11464 		{"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
11465 		{"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
11466 		{"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
11467 		{"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
11468 		{"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
11469 		{"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
11470 		{"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
11471 		{"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
11472 		{"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
11473 		{"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
11474 		{"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
11475 		{"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
11476 		{"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
11477 		{"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
11478 		{"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
11479 		{"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
11480 		{"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
11481 		{"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
11482 		{"none", RTE_ETH_INPUT_SET_NONE},
11483 	};
11484 
11485 	for (i = 0; i < RTE_DIM(inset_table); i++) {
11486 		if (!strcmp(string, inset_table[i].str))
11487 			return inset_table[i].inset;
11488 	}
11489 
11490 	return RTE_ETH_INPUT_SET_UNKNOWN;
11491 }
11492 
11493 static void
11494 cmd_set_hash_input_set_parsed(void *parsed_result,
11495 			      __rte_unused struct cmdline *cl,
11496 			      __rte_unused void *data)
11497 {
11498 	struct cmd_set_hash_input_set_result *res = parsed_result;
11499 	struct rte_eth_hash_filter_info info;
11500 
11501 	memset(&info, 0, sizeof(info));
11502 	info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
11503 	info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
11504 	info.info.input_set_conf.field[0] = str2inset(res->inset_field);
11505 	info.info.input_set_conf.inset_size = 1;
11506 	if (!strcmp(res->select, "select"))
11507 		info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
11508 	else if (!strcmp(res->select, "add"))
11509 		info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
11510 	rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11511 				RTE_ETH_FILTER_SET, &info);
11512 }
11513 
11514 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
11515 	TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11516 		set_hash_input_set, "set_hash_input_set");
11517 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
11518 	TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
11519 		port_id, UINT16);
11520 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
11521 	TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11522 		flow_type, NULL);
11523 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
11524 	TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11525 		inset_field,
11526 		"ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
11527 		"ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
11528 		"udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
11529 		"sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
11530 		"fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
11531 		"fld-8th#none");
11532 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
11533 	TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11534 		select, "select#add");
11535 
11536 cmdline_parse_inst_t cmd_set_hash_input_set = {
11537 	.f = cmd_set_hash_input_set_parsed,
11538 	.data = NULL,
11539 	.help_str = "set_hash_input_set <port_id> "
11540 	"ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11541 	"ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
11542 	"ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
11543 	"ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
11544 	"tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
11545 	"gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
11546 	"fld-7th|fld-8th|none select|add",
11547 	.tokens = {
11548 		(void *)&cmd_set_hash_input_set_cmd,
11549 		(void *)&cmd_set_hash_input_set_port_id,
11550 		(void *)&cmd_set_hash_input_set_flow_type,
11551 		(void *)&cmd_set_hash_input_set_field,
11552 		(void *)&cmd_set_hash_input_set_select,
11553 		NULL,
11554 	},
11555 };
11556 
11557 /* Set flow director input set */
11558 struct cmd_set_fdir_input_set_result {
11559 	cmdline_fixed_string_t set_fdir_input_set;
11560 	portid_t port_id;
11561 	cmdline_fixed_string_t flow_type;
11562 	cmdline_fixed_string_t inset_field;
11563 	cmdline_fixed_string_t select;
11564 };
11565 
11566 static void
11567 cmd_set_fdir_input_set_parsed(void *parsed_result,
11568 	__rte_unused struct cmdline *cl,
11569 	__rte_unused void *data)
11570 {
11571 	struct cmd_set_fdir_input_set_result *res = parsed_result;
11572 	struct rte_eth_fdir_filter_info info;
11573 
11574 	memset(&info, 0, sizeof(info));
11575 	info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
11576 	info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
11577 	info.info.input_set_conf.field[0] = str2inset(res->inset_field);
11578 	info.info.input_set_conf.inset_size = 1;
11579 	if (!strcmp(res->select, "select"))
11580 		info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
11581 	else if (!strcmp(res->select, "add"))
11582 		info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
11583 	rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11584 		RTE_ETH_FILTER_SET, &info);
11585 }
11586 
11587 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
11588 	TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11589 	set_fdir_input_set, "set_fdir_input_set");
11590 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
11591 	TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
11592 	port_id, UINT16);
11593 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
11594 	TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11595 	flow_type,
11596 	"ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
11597 	"ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
11598 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
11599 	TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11600 	inset_field,
11601 	"ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
11602 	"ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
11603 	"ipv6-hop-limits#udp-src-port#udp-dst-port#"
11604 	"tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
11605 	"sctp-veri-tag#none");
11606 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
11607 	TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11608 	select, "select#add");
11609 
11610 cmdline_parse_inst_t cmd_set_fdir_input_set = {
11611 	.f = cmd_set_fdir_input_set_parsed,
11612 	.data = NULL,
11613 	.help_str = "set_fdir_input_set <port_id> "
11614 	"ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11615 	"ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
11616 	"ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
11617 	"ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
11618 	"ipv6-hop-limits|udp-src-port|udp-dst-port|"
11619 	"tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
11620 	"sctp-veri-tag|none select|add",
11621 	.tokens = {
11622 		(void *)&cmd_set_fdir_input_set_cmd,
11623 		(void *)&cmd_set_fdir_input_set_port_id,
11624 		(void *)&cmd_set_fdir_input_set_flow_type,
11625 		(void *)&cmd_set_fdir_input_set_field,
11626 		(void *)&cmd_set_fdir_input_set_select,
11627 		NULL,
11628 	},
11629 };
11630 
11631 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
11632 struct cmd_mcast_addr_result {
11633 	cmdline_fixed_string_t mcast_addr_cmd;
11634 	cmdline_fixed_string_t what;
11635 	uint16_t port_num;
11636 	struct ether_addr mc_addr;
11637 };
11638 
11639 static void cmd_mcast_addr_parsed(void *parsed_result,
11640 		__attribute__((unused)) struct cmdline *cl,
11641 		__attribute__((unused)) void *data)
11642 {
11643 	struct cmd_mcast_addr_result *res = parsed_result;
11644 
11645 	if (!is_multicast_ether_addr(&res->mc_addr)) {
11646 		printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
11647 		       res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
11648 		       res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
11649 		       res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
11650 		return;
11651 	}
11652 	if (strcmp(res->what, "add") == 0)
11653 		mcast_addr_add(res->port_num, &res->mc_addr);
11654 	else
11655 		mcast_addr_remove(res->port_num, &res->mc_addr);
11656 }
11657 
11658 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
11659 	TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
11660 				 mcast_addr_cmd, "mcast_addr");
11661 cmdline_parse_token_string_t cmd_mcast_addr_what =
11662 	TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
11663 				 "add#remove");
11664 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
11665 	TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
11666 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
11667 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
11668 
11669 cmdline_parse_inst_t cmd_mcast_addr = {
11670 	.f = cmd_mcast_addr_parsed,
11671 	.data = (void *)0,
11672 	.help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
11673 		"Add/Remove multicast MAC address on port_id",
11674 	.tokens = {
11675 		(void *)&cmd_mcast_addr_cmd,
11676 		(void *)&cmd_mcast_addr_what,
11677 		(void *)&cmd_mcast_addr_portnum,
11678 		(void *)&cmd_mcast_addr_addr,
11679 		NULL,
11680 	},
11681 };
11682 
11683 /* l2 tunnel config
11684  * only support E-tag now.
11685  */
11686 
11687 /* Ether type config */
11688 struct cmd_config_l2_tunnel_eth_type_result {
11689 	cmdline_fixed_string_t port;
11690 	cmdline_fixed_string_t config;
11691 	cmdline_fixed_string_t all;
11692 	uint8_t id;
11693 	cmdline_fixed_string_t l2_tunnel;
11694 	cmdline_fixed_string_t l2_tunnel_type;
11695 	cmdline_fixed_string_t eth_type;
11696 	uint16_t eth_type_val;
11697 };
11698 
11699 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
11700 	TOKEN_STRING_INITIALIZER
11701 		(struct cmd_config_l2_tunnel_eth_type_result,
11702 		 port, "port");
11703 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
11704 	TOKEN_STRING_INITIALIZER
11705 		(struct cmd_config_l2_tunnel_eth_type_result,
11706 		 config, "config");
11707 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
11708 	TOKEN_STRING_INITIALIZER
11709 		(struct cmd_config_l2_tunnel_eth_type_result,
11710 		 all, "all");
11711 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
11712 	TOKEN_NUM_INITIALIZER
11713 		(struct cmd_config_l2_tunnel_eth_type_result,
11714 		 id, UINT8);
11715 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
11716 	TOKEN_STRING_INITIALIZER
11717 		(struct cmd_config_l2_tunnel_eth_type_result,
11718 		 l2_tunnel, "l2-tunnel");
11719 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
11720 	TOKEN_STRING_INITIALIZER
11721 		(struct cmd_config_l2_tunnel_eth_type_result,
11722 		 l2_tunnel_type, "E-tag");
11723 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
11724 	TOKEN_STRING_INITIALIZER
11725 		(struct cmd_config_l2_tunnel_eth_type_result,
11726 		 eth_type, "ether-type");
11727 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
11728 	TOKEN_NUM_INITIALIZER
11729 		(struct cmd_config_l2_tunnel_eth_type_result,
11730 		 eth_type_val, UINT16);
11731 
11732 static enum rte_eth_tunnel_type
11733 str2fdir_l2_tunnel_type(char *string)
11734 {
11735 	uint32_t i = 0;
11736 
11737 	static const struct {
11738 		char str[32];
11739 		enum rte_eth_tunnel_type type;
11740 	} l2_tunnel_type_str[] = {
11741 		{"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
11742 	};
11743 
11744 	for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
11745 		if (!strcmp(l2_tunnel_type_str[i].str, string))
11746 			return l2_tunnel_type_str[i].type;
11747 	}
11748 	return RTE_TUNNEL_TYPE_NONE;
11749 }
11750 
11751 /* ether type config for all ports */
11752 static void
11753 cmd_config_l2_tunnel_eth_type_all_parsed
11754 	(void *parsed_result,
11755 	 __attribute__((unused)) struct cmdline *cl,
11756 	 __attribute__((unused)) void *data)
11757 {
11758 	struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
11759 	struct rte_eth_l2_tunnel_conf entry;
11760 	portid_t pid;
11761 
11762 	entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11763 	entry.ether_type = res->eth_type_val;
11764 
11765 	RTE_ETH_FOREACH_DEV(pid) {
11766 		rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
11767 	}
11768 }
11769 
11770 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
11771 	.f = cmd_config_l2_tunnel_eth_type_all_parsed,
11772 	.data = NULL,
11773 	.help_str = "port config all l2-tunnel E-tag ether-type <value>",
11774 	.tokens = {
11775 		(void *)&cmd_config_l2_tunnel_eth_type_port,
11776 		(void *)&cmd_config_l2_tunnel_eth_type_config,
11777 		(void *)&cmd_config_l2_tunnel_eth_type_all_str,
11778 		(void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
11779 		(void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
11780 		(void *)&cmd_config_l2_tunnel_eth_type_eth_type,
11781 		(void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
11782 		NULL,
11783 	},
11784 };
11785 
11786 /* ether type config for a specific port */
11787 static void
11788 cmd_config_l2_tunnel_eth_type_specific_parsed(
11789 	void *parsed_result,
11790 	__attribute__((unused)) struct cmdline *cl,
11791 	__attribute__((unused)) void *data)
11792 {
11793 	struct cmd_config_l2_tunnel_eth_type_result *res =
11794 		 parsed_result;
11795 	struct rte_eth_l2_tunnel_conf entry;
11796 
11797 	if (port_id_is_invalid(res->id, ENABLED_WARN))
11798 		return;
11799 
11800 	entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11801 	entry.ether_type = res->eth_type_val;
11802 
11803 	rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
11804 }
11805 
11806 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
11807 	.f = cmd_config_l2_tunnel_eth_type_specific_parsed,
11808 	.data = NULL,
11809 	.help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
11810 	.tokens = {
11811 		(void *)&cmd_config_l2_tunnel_eth_type_port,
11812 		(void *)&cmd_config_l2_tunnel_eth_type_config,
11813 		(void *)&cmd_config_l2_tunnel_eth_type_id,
11814 		(void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
11815 		(void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
11816 		(void *)&cmd_config_l2_tunnel_eth_type_eth_type,
11817 		(void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
11818 		NULL,
11819 	},
11820 };
11821 
11822 /* Enable/disable l2 tunnel */
11823 struct cmd_config_l2_tunnel_en_dis_result {
11824 	cmdline_fixed_string_t port;
11825 	cmdline_fixed_string_t config;
11826 	cmdline_fixed_string_t all;
11827 	uint8_t id;
11828 	cmdline_fixed_string_t l2_tunnel;
11829 	cmdline_fixed_string_t l2_tunnel_type;
11830 	cmdline_fixed_string_t en_dis;
11831 };
11832 
11833 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
11834 	TOKEN_STRING_INITIALIZER
11835 		(struct cmd_config_l2_tunnel_en_dis_result,
11836 		 port, "port");
11837 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
11838 	TOKEN_STRING_INITIALIZER
11839 		(struct cmd_config_l2_tunnel_en_dis_result,
11840 		 config, "config");
11841 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
11842 	TOKEN_STRING_INITIALIZER
11843 		(struct cmd_config_l2_tunnel_en_dis_result,
11844 		 all, "all");
11845 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
11846 	TOKEN_NUM_INITIALIZER
11847 		(struct cmd_config_l2_tunnel_en_dis_result,
11848 		 id, UINT8);
11849 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
11850 	TOKEN_STRING_INITIALIZER
11851 		(struct cmd_config_l2_tunnel_en_dis_result,
11852 		 l2_tunnel, "l2-tunnel");
11853 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
11854 	TOKEN_STRING_INITIALIZER
11855 		(struct cmd_config_l2_tunnel_en_dis_result,
11856 		 l2_tunnel_type, "E-tag");
11857 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
11858 	TOKEN_STRING_INITIALIZER
11859 		(struct cmd_config_l2_tunnel_en_dis_result,
11860 		 en_dis, "enable#disable");
11861 
11862 /* enable/disable l2 tunnel for all ports */
11863 static void
11864 cmd_config_l2_tunnel_en_dis_all_parsed(
11865 	void *parsed_result,
11866 	__attribute__((unused)) struct cmdline *cl,
11867 	__attribute__((unused)) void *data)
11868 {
11869 	struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
11870 	struct rte_eth_l2_tunnel_conf entry;
11871 	portid_t pid;
11872 	uint8_t en;
11873 
11874 	entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11875 
11876 	if (!strcmp("enable", res->en_dis))
11877 		en = 1;
11878 	else
11879 		en = 0;
11880 
11881 	RTE_ETH_FOREACH_DEV(pid) {
11882 		rte_eth_dev_l2_tunnel_offload_set(pid,
11883 						  &entry,
11884 						  ETH_L2_TUNNEL_ENABLE_MASK,
11885 						  en);
11886 	}
11887 }
11888 
11889 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
11890 	.f = cmd_config_l2_tunnel_en_dis_all_parsed,
11891 	.data = NULL,
11892 	.help_str = "port config all l2-tunnel E-tag enable|disable",
11893 	.tokens = {
11894 		(void *)&cmd_config_l2_tunnel_en_dis_port,
11895 		(void *)&cmd_config_l2_tunnel_en_dis_config,
11896 		(void *)&cmd_config_l2_tunnel_en_dis_all_str,
11897 		(void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
11898 		(void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
11899 		(void *)&cmd_config_l2_tunnel_en_dis_en_dis,
11900 		NULL,
11901 	},
11902 };
11903 
11904 /* enable/disable l2 tunnel for a port */
11905 static void
11906 cmd_config_l2_tunnel_en_dis_specific_parsed(
11907 	void *parsed_result,
11908 	__attribute__((unused)) struct cmdline *cl,
11909 	__attribute__((unused)) void *data)
11910 {
11911 	struct cmd_config_l2_tunnel_en_dis_result *res =
11912 		parsed_result;
11913 	struct rte_eth_l2_tunnel_conf entry;
11914 
11915 	if (port_id_is_invalid(res->id, ENABLED_WARN))
11916 		return;
11917 
11918 	entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11919 
11920 	if (!strcmp("enable", res->en_dis))
11921 		rte_eth_dev_l2_tunnel_offload_set(res->id,
11922 						  &entry,
11923 						  ETH_L2_TUNNEL_ENABLE_MASK,
11924 						  1);
11925 	else
11926 		rte_eth_dev_l2_tunnel_offload_set(res->id,
11927 						  &entry,
11928 						  ETH_L2_TUNNEL_ENABLE_MASK,
11929 						  0);
11930 }
11931 
11932 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
11933 	.f = cmd_config_l2_tunnel_en_dis_specific_parsed,
11934 	.data = NULL,
11935 	.help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
11936 	.tokens = {
11937 		(void *)&cmd_config_l2_tunnel_en_dis_port,
11938 		(void *)&cmd_config_l2_tunnel_en_dis_config,
11939 		(void *)&cmd_config_l2_tunnel_en_dis_id,
11940 		(void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
11941 		(void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
11942 		(void *)&cmd_config_l2_tunnel_en_dis_en_dis,
11943 		NULL,
11944 	},
11945 };
11946 
11947 /* E-tag configuration */
11948 
11949 /* Common result structure for all E-tag configuration */
11950 struct cmd_config_e_tag_result {
11951 	cmdline_fixed_string_t e_tag;
11952 	cmdline_fixed_string_t set;
11953 	cmdline_fixed_string_t insertion;
11954 	cmdline_fixed_string_t stripping;
11955 	cmdline_fixed_string_t forwarding;
11956 	cmdline_fixed_string_t filter;
11957 	cmdline_fixed_string_t add;
11958 	cmdline_fixed_string_t del;
11959 	cmdline_fixed_string_t on;
11960 	cmdline_fixed_string_t off;
11961 	cmdline_fixed_string_t on_off;
11962 	cmdline_fixed_string_t port_tag_id;
11963 	uint32_t port_tag_id_val;
11964 	cmdline_fixed_string_t e_tag_id;
11965 	uint16_t e_tag_id_val;
11966 	cmdline_fixed_string_t dst_pool;
11967 	uint8_t dst_pool_val;
11968 	cmdline_fixed_string_t port;
11969 	portid_t port_id;
11970 	cmdline_fixed_string_t vf;
11971 	uint8_t vf_id;
11972 };
11973 
11974 /* Common CLI fields for all E-tag configuration */
11975 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
11976 	TOKEN_STRING_INITIALIZER
11977 		(struct cmd_config_e_tag_result,
11978 		 e_tag, "E-tag");
11979 cmdline_parse_token_string_t cmd_config_e_tag_set =
11980 	TOKEN_STRING_INITIALIZER
11981 		(struct cmd_config_e_tag_result,
11982 		 set, "set");
11983 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
11984 	TOKEN_STRING_INITIALIZER
11985 		(struct cmd_config_e_tag_result,
11986 		 insertion, "insertion");
11987 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
11988 	TOKEN_STRING_INITIALIZER
11989 		(struct cmd_config_e_tag_result,
11990 		 stripping, "stripping");
11991 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
11992 	TOKEN_STRING_INITIALIZER
11993 		(struct cmd_config_e_tag_result,
11994 		 forwarding, "forwarding");
11995 cmdline_parse_token_string_t cmd_config_e_tag_filter =
11996 	TOKEN_STRING_INITIALIZER
11997 		(struct cmd_config_e_tag_result,
11998 		 filter, "filter");
11999 cmdline_parse_token_string_t cmd_config_e_tag_add =
12000 	TOKEN_STRING_INITIALIZER
12001 		(struct cmd_config_e_tag_result,
12002 		 add, "add");
12003 cmdline_parse_token_string_t cmd_config_e_tag_del =
12004 	TOKEN_STRING_INITIALIZER
12005 		(struct cmd_config_e_tag_result,
12006 		 del, "del");
12007 cmdline_parse_token_string_t cmd_config_e_tag_on =
12008 	TOKEN_STRING_INITIALIZER
12009 		(struct cmd_config_e_tag_result,
12010 		 on, "on");
12011 cmdline_parse_token_string_t cmd_config_e_tag_off =
12012 	TOKEN_STRING_INITIALIZER
12013 		(struct cmd_config_e_tag_result,
12014 		 off, "off");
12015 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
12016 	TOKEN_STRING_INITIALIZER
12017 		(struct cmd_config_e_tag_result,
12018 		 on_off, "on#off");
12019 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
12020 	TOKEN_STRING_INITIALIZER
12021 		(struct cmd_config_e_tag_result,
12022 		 port_tag_id, "port-tag-id");
12023 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
12024 	TOKEN_NUM_INITIALIZER
12025 		(struct cmd_config_e_tag_result,
12026 		 port_tag_id_val, UINT32);
12027 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
12028 	TOKEN_STRING_INITIALIZER
12029 		(struct cmd_config_e_tag_result,
12030 		 e_tag_id, "e-tag-id");
12031 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
12032 	TOKEN_NUM_INITIALIZER
12033 		(struct cmd_config_e_tag_result,
12034 		 e_tag_id_val, UINT16);
12035 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
12036 	TOKEN_STRING_INITIALIZER
12037 		(struct cmd_config_e_tag_result,
12038 		 dst_pool, "dst-pool");
12039 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
12040 	TOKEN_NUM_INITIALIZER
12041 		(struct cmd_config_e_tag_result,
12042 		 dst_pool_val, UINT8);
12043 cmdline_parse_token_string_t cmd_config_e_tag_port =
12044 	TOKEN_STRING_INITIALIZER
12045 		(struct cmd_config_e_tag_result,
12046 		 port, "port");
12047 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
12048 	TOKEN_NUM_INITIALIZER
12049 		(struct cmd_config_e_tag_result,
12050 		 port_id, UINT16);
12051 cmdline_parse_token_string_t cmd_config_e_tag_vf =
12052 	TOKEN_STRING_INITIALIZER
12053 		(struct cmd_config_e_tag_result,
12054 		 vf, "vf");
12055 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
12056 	TOKEN_NUM_INITIALIZER
12057 		(struct cmd_config_e_tag_result,
12058 		 vf_id, UINT8);
12059 
12060 /* E-tag insertion configuration */
12061 static void
12062 cmd_config_e_tag_insertion_en_parsed(
12063 	void *parsed_result,
12064 	__attribute__((unused)) struct cmdline *cl,
12065 	__attribute__((unused)) void *data)
12066 {
12067 	struct cmd_config_e_tag_result *res =
12068 		parsed_result;
12069 	struct rte_eth_l2_tunnel_conf entry;
12070 
12071 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12072 		return;
12073 
12074 	entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12075 	entry.tunnel_id = res->port_tag_id_val;
12076 	entry.vf_id = res->vf_id;
12077 	rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12078 					  &entry,
12079 					  ETH_L2_TUNNEL_INSERTION_MASK,
12080 					  1);
12081 }
12082 
12083 static void
12084 cmd_config_e_tag_insertion_dis_parsed(
12085 	void *parsed_result,
12086 	__attribute__((unused)) struct cmdline *cl,
12087 	__attribute__((unused)) void *data)
12088 {
12089 	struct cmd_config_e_tag_result *res =
12090 		parsed_result;
12091 	struct rte_eth_l2_tunnel_conf entry;
12092 
12093 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12094 		return;
12095 
12096 	entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12097 	entry.vf_id = res->vf_id;
12098 
12099 	rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12100 					  &entry,
12101 					  ETH_L2_TUNNEL_INSERTION_MASK,
12102 					  0);
12103 }
12104 
12105 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
12106 	.f = cmd_config_e_tag_insertion_en_parsed,
12107 	.data = NULL,
12108 	.help_str = "E-tag ... : E-tag insertion enable",
12109 	.tokens = {
12110 		(void *)&cmd_config_e_tag_e_tag,
12111 		(void *)&cmd_config_e_tag_set,
12112 		(void *)&cmd_config_e_tag_insertion,
12113 		(void *)&cmd_config_e_tag_on,
12114 		(void *)&cmd_config_e_tag_port_tag_id,
12115 		(void *)&cmd_config_e_tag_port_tag_id_val,
12116 		(void *)&cmd_config_e_tag_port,
12117 		(void *)&cmd_config_e_tag_port_id,
12118 		(void *)&cmd_config_e_tag_vf,
12119 		(void *)&cmd_config_e_tag_vf_id,
12120 		NULL,
12121 	},
12122 };
12123 
12124 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
12125 	.f = cmd_config_e_tag_insertion_dis_parsed,
12126 	.data = NULL,
12127 	.help_str = "E-tag ... : E-tag insertion disable",
12128 	.tokens = {
12129 		(void *)&cmd_config_e_tag_e_tag,
12130 		(void *)&cmd_config_e_tag_set,
12131 		(void *)&cmd_config_e_tag_insertion,
12132 		(void *)&cmd_config_e_tag_off,
12133 		(void *)&cmd_config_e_tag_port,
12134 		(void *)&cmd_config_e_tag_port_id,
12135 		(void *)&cmd_config_e_tag_vf,
12136 		(void *)&cmd_config_e_tag_vf_id,
12137 		NULL,
12138 	},
12139 };
12140 
12141 /* E-tag stripping configuration */
12142 static void
12143 cmd_config_e_tag_stripping_parsed(
12144 	void *parsed_result,
12145 	__attribute__((unused)) struct cmdline *cl,
12146 	__attribute__((unused)) void *data)
12147 {
12148 	struct cmd_config_e_tag_result *res =
12149 		parsed_result;
12150 	struct rte_eth_l2_tunnel_conf entry;
12151 
12152 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12153 		return;
12154 
12155 	entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12156 
12157 	if (!strcmp(res->on_off, "on"))
12158 		rte_eth_dev_l2_tunnel_offload_set
12159 			(res->port_id,
12160 			 &entry,
12161 			 ETH_L2_TUNNEL_STRIPPING_MASK,
12162 			 1);
12163 	else
12164 		rte_eth_dev_l2_tunnel_offload_set
12165 			(res->port_id,
12166 			 &entry,
12167 			 ETH_L2_TUNNEL_STRIPPING_MASK,
12168 			 0);
12169 }
12170 
12171 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
12172 	.f = cmd_config_e_tag_stripping_parsed,
12173 	.data = NULL,
12174 	.help_str = "E-tag ... : E-tag stripping enable/disable",
12175 	.tokens = {
12176 		(void *)&cmd_config_e_tag_e_tag,
12177 		(void *)&cmd_config_e_tag_set,
12178 		(void *)&cmd_config_e_tag_stripping,
12179 		(void *)&cmd_config_e_tag_on_off,
12180 		(void *)&cmd_config_e_tag_port,
12181 		(void *)&cmd_config_e_tag_port_id,
12182 		NULL,
12183 	},
12184 };
12185 
12186 /* E-tag forwarding configuration */
12187 static void
12188 cmd_config_e_tag_forwarding_parsed(
12189 	void *parsed_result,
12190 	__attribute__((unused)) struct cmdline *cl,
12191 	__attribute__((unused)) void *data)
12192 {
12193 	struct cmd_config_e_tag_result *res = parsed_result;
12194 	struct rte_eth_l2_tunnel_conf entry;
12195 
12196 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12197 		return;
12198 
12199 	entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12200 
12201 	if (!strcmp(res->on_off, "on"))
12202 		rte_eth_dev_l2_tunnel_offload_set
12203 			(res->port_id,
12204 			 &entry,
12205 			 ETH_L2_TUNNEL_FORWARDING_MASK,
12206 			 1);
12207 	else
12208 		rte_eth_dev_l2_tunnel_offload_set
12209 			(res->port_id,
12210 			 &entry,
12211 			 ETH_L2_TUNNEL_FORWARDING_MASK,
12212 			 0);
12213 }
12214 
12215 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
12216 	.f = cmd_config_e_tag_forwarding_parsed,
12217 	.data = NULL,
12218 	.help_str = "E-tag ... : E-tag forwarding enable/disable",
12219 	.tokens = {
12220 		(void *)&cmd_config_e_tag_e_tag,
12221 		(void *)&cmd_config_e_tag_set,
12222 		(void *)&cmd_config_e_tag_forwarding,
12223 		(void *)&cmd_config_e_tag_on_off,
12224 		(void *)&cmd_config_e_tag_port,
12225 		(void *)&cmd_config_e_tag_port_id,
12226 		NULL,
12227 	},
12228 };
12229 
12230 /* E-tag filter configuration */
12231 static void
12232 cmd_config_e_tag_filter_add_parsed(
12233 	void *parsed_result,
12234 	__attribute__((unused)) struct cmdline *cl,
12235 	__attribute__((unused)) void *data)
12236 {
12237 	struct cmd_config_e_tag_result *res = parsed_result;
12238 	struct rte_eth_l2_tunnel_conf entry;
12239 	int ret = 0;
12240 
12241 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12242 		return;
12243 
12244 	if (res->e_tag_id_val > 0x3fff) {
12245 		printf("e-tag-id must be equal or less than 0x3fff.\n");
12246 		return;
12247 	}
12248 
12249 	ret = rte_eth_dev_filter_supported(res->port_id,
12250 					   RTE_ETH_FILTER_L2_TUNNEL);
12251 	if (ret < 0) {
12252 		printf("E-tag filter is not supported on port %u.\n",
12253 		       res->port_id);
12254 		return;
12255 	}
12256 
12257 	entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12258 	entry.tunnel_id = res->e_tag_id_val;
12259 	entry.pool = res->dst_pool_val;
12260 
12261 	ret = rte_eth_dev_filter_ctrl(res->port_id,
12262 				      RTE_ETH_FILTER_L2_TUNNEL,
12263 				      RTE_ETH_FILTER_ADD,
12264 				      &entry);
12265 	if (ret < 0)
12266 		printf("E-tag filter programming error: (%s)\n",
12267 		       strerror(-ret));
12268 }
12269 
12270 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
12271 	.f = cmd_config_e_tag_filter_add_parsed,
12272 	.data = NULL,
12273 	.help_str = "E-tag ... : E-tag filter add",
12274 	.tokens = {
12275 		(void *)&cmd_config_e_tag_e_tag,
12276 		(void *)&cmd_config_e_tag_set,
12277 		(void *)&cmd_config_e_tag_filter,
12278 		(void *)&cmd_config_e_tag_add,
12279 		(void *)&cmd_config_e_tag_e_tag_id,
12280 		(void *)&cmd_config_e_tag_e_tag_id_val,
12281 		(void *)&cmd_config_e_tag_dst_pool,
12282 		(void *)&cmd_config_e_tag_dst_pool_val,
12283 		(void *)&cmd_config_e_tag_port,
12284 		(void *)&cmd_config_e_tag_port_id,
12285 		NULL,
12286 	},
12287 };
12288 
12289 static void
12290 cmd_config_e_tag_filter_del_parsed(
12291 	void *parsed_result,
12292 	__attribute__((unused)) struct cmdline *cl,
12293 	__attribute__((unused)) void *data)
12294 {
12295 	struct cmd_config_e_tag_result *res = parsed_result;
12296 	struct rte_eth_l2_tunnel_conf entry;
12297 	int ret = 0;
12298 
12299 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12300 		return;
12301 
12302 	if (res->e_tag_id_val > 0x3fff) {
12303 		printf("e-tag-id must be less than 0x3fff.\n");
12304 		return;
12305 	}
12306 
12307 	ret = rte_eth_dev_filter_supported(res->port_id,
12308 					   RTE_ETH_FILTER_L2_TUNNEL);
12309 	if (ret < 0) {
12310 		printf("E-tag filter is not supported on port %u.\n",
12311 		       res->port_id);
12312 		return;
12313 	}
12314 
12315 	entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12316 	entry.tunnel_id = res->e_tag_id_val;
12317 
12318 	ret = rte_eth_dev_filter_ctrl(res->port_id,
12319 				      RTE_ETH_FILTER_L2_TUNNEL,
12320 				      RTE_ETH_FILTER_DELETE,
12321 				      &entry);
12322 	if (ret < 0)
12323 		printf("E-tag filter programming error: (%s)\n",
12324 		       strerror(-ret));
12325 }
12326 
12327 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
12328 	.f = cmd_config_e_tag_filter_del_parsed,
12329 	.data = NULL,
12330 	.help_str = "E-tag ... : E-tag filter delete",
12331 	.tokens = {
12332 		(void *)&cmd_config_e_tag_e_tag,
12333 		(void *)&cmd_config_e_tag_set,
12334 		(void *)&cmd_config_e_tag_filter,
12335 		(void *)&cmd_config_e_tag_del,
12336 		(void *)&cmd_config_e_tag_e_tag_id,
12337 		(void *)&cmd_config_e_tag_e_tag_id_val,
12338 		(void *)&cmd_config_e_tag_port,
12339 		(void *)&cmd_config_e_tag_port_id,
12340 		NULL,
12341 	},
12342 };
12343 
12344 /* vf vlan anti spoof configuration */
12345 
12346 /* Common result structure for vf vlan anti spoof */
12347 struct cmd_vf_vlan_anti_spoof_result {
12348 	cmdline_fixed_string_t set;
12349 	cmdline_fixed_string_t vf;
12350 	cmdline_fixed_string_t vlan;
12351 	cmdline_fixed_string_t antispoof;
12352 	portid_t port_id;
12353 	uint32_t vf_id;
12354 	cmdline_fixed_string_t on_off;
12355 };
12356 
12357 /* Common CLI fields for vf vlan anti spoof enable disable */
12358 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
12359 	TOKEN_STRING_INITIALIZER
12360 		(struct cmd_vf_vlan_anti_spoof_result,
12361 		 set, "set");
12362 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
12363 	TOKEN_STRING_INITIALIZER
12364 		(struct cmd_vf_vlan_anti_spoof_result,
12365 		 vf, "vf");
12366 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
12367 	TOKEN_STRING_INITIALIZER
12368 		(struct cmd_vf_vlan_anti_spoof_result,
12369 		 vlan, "vlan");
12370 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
12371 	TOKEN_STRING_INITIALIZER
12372 		(struct cmd_vf_vlan_anti_spoof_result,
12373 		 antispoof, "antispoof");
12374 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
12375 	TOKEN_NUM_INITIALIZER
12376 		(struct cmd_vf_vlan_anti_spoof_result,
12377 		 port_id, UINT16);
12378 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
12379 	TOKEN_NUM_INITIALIZER
12380 		(struct cmd_vf_vlan_anti_spoof_result,
12381 		 vf_id, UINT32);
12382 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
12383 	TOKEN_STRING_INITIALIZER
12384 		(struct cmd_vf_vlan_anti_spoof_result,
12385 		 on_off, "on#off");
12386 
12387 static void
12388 cmd_set_vf_vlan_anti_spoof_parsed(
12389 	void *parsed_result,
12390 	__attribute__((unused)) struct cmdline *cl,
12391 	__attribute__((unused)) void *data)
12392 {
12393 	struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
12394 	int ret = -ENOTSUP;
12395 
12396 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12397 
12398 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12399 		return;
12400 
12401 #ifdef RTE_LIBRTE_IXGBE_PMD
12402 	if (ret == -ENOTSUP)
12403 		ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
12404 				res->vf_id, is_on);
12405 #endif
12406 #ifdef RTE_LIBRTE_I40E_PMD
12407 	if (ret == -ENOTSUP)
12408 		ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
12409 				res->vf_id, is_on);
12410 #endif
12411 #ifdef RTE_LIBRTE_BNXT_PMD
12412 	if (ret == -ENOTSUP)
12413 		ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
12414 				res->vf_id, is_on);
12415 #endif
12416 
12417 	switch (ret) {
12418 	case 0:
12419 		break;
12420 	case -EINVAL:
12421 		printf("invalid vf_id %d\n", res->vf_id);
12422 		break;
12423 	case -ENODEV:
12424 		printf("invalid port_id %d\n", res->port_id);
12425 		break;
12426 	case -ENOTSUP:
12427 		printf("function not implemented\n");
12428 		break;
12429 	default:
12430 		printf("programming error: (%s)\n", strerror(-ret));
12431 	}
12432 }
12433 
12434 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
12435 	.f = cmd_set_vf_vlan_anti_spoof_parsed,
12436 	.data = NULL,
12437 	.help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
12438 	.tokens = {
12439 		(void *)&cmd_vf_vlan_anti_spoof_set,
12440 		(void *)&cmd_vf_vlan_anti_spoof_vf,
12441 		(void *)&cmd_vf_vlan_anti_spoof_vlan,
12442 		(void *)&cmd_vf_vlan_anti_spoof_antispoof,
12443 		(void *)&cmd_vf_vlan_anti_spoof_port_id,
12444 		(void *)&cmd_vf_vlan_anti_spoof_vf_id,
12445 		(void *)&cmd_vf_vlan_anti_spoof_on_off,
12446 		NULL,
12447 	},
12448 };
12449 
12450 /* vf mac anti spoof configuration */
12451 
12452 /* Common result structure for vf mac anti spoof */
12453 struct cmd_vf_mac_anti_spoof_result {
12454 	cmdline_fixed_string_t set;
12455 	cmdline_fixed_string_t vf;
12456 	cmdline_fixed_string_t mac;
12457 	cmdline_fixed_string_t antispoof;
12458 	portid_t port_id;
12459 	uint32_t vf_id;
12460 	cmdline_fixed_string_t on_off;
12461 };
12462 
12463 /* Common CLI fields for vf mac anti spoof enable disable */
12464 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
12465 	TOKEN_STRING_INITIALIZER
12466 		(struct cmd_vf_mac_anti_spoof_result,
12467 		 set, "set");
12468 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
12469 	TOKEN_STRING_INITIALIZER
12470 		(struct cmd_vf_mac_anti_spoof_result,
12471 		 vf, "vf");
12472 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
12473 	TOKEN_STRING_INITIALIZER
12474 		(struct cmd_vf_mac_anti_spoof_result,
12475 		 mac, "mac");
12476 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
12477 	TOKEN_STRING_INITIALIZER
12478 		(struct cmd_vf_mac_anti_spoof_result,
12479 		 antispoof, "antispoof");
12480 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
12481 	TOKEN_NUM_INITIALIZER
12482 		(struct cmd_vf_mac_anti_spoof_result,
12483 		 port_id, UINT16);
12484 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
12485 	TOKEN_NUM_INITIALIZER
12486 		(struct cmd_vf_mac_anti_spoof_result,
12487 		 vf_id, UINT32);
12488 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
12489 	TOKEN_STRING_INITIALIZER
12490 		(struct cmd_vf_mac_anti_spoof_result,
12491 		 on_off, "on#off");
12492 
12493 static void
12494 cmd_set_vf_mac_anti_spoof_parsed(
12495 	void *parsed_result,
12496 	__attribute__((unused)) struct cmdline *cl,
12497 	__attribute__((unused)) void *data)
12498 {
12499 	struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
12500 	int ret = -ENOTSUP;
12501 
12502 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12503 
12504 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12505 		return;
12506 
12507 #ifdef RTE_LIBRTE_IXGBE_PMD
12508 	if (ret == -ENOTSUP)
12509 		ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
12510 			res->vf_id, is_on);
12511 #endif
12512 #ifdef RTE_LIBRTE_I40E_PMD
12513 	if (ret == -ENOTSUP)
12514 		ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
12515 			res->vf_id, is_on);
12516 #endif
12517 #ifdef RTE_LIBRTE_BNXT_PMD
12518 	if (ret == -ENOTSUP)
12519 		ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
12520 			res->vf_id, is_on);
12521 #endif
12522 
12523 	switch (ret) {
12524 	case 0:
12525 		break;
12526 	case -EINVAL:
12527 		printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12528 		break;
12529 	case -ENODEV:
12530 		printf("invalid port_id %d\n", res->port_id);
12531 		break;
12532 	case -ENOTSUP:
12533 		printf("function not implemented\n");
12534 		break;
12535 	default:
12536 		printf("programming error: (%s)\n", strerror(-ret));
12537 	}
12538 }
12539 
12540 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
12541 	.f = cmd_set_vf_mac_anti_spoof_parsed,
12542 	.data = NULL,
12543 	.help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
12544 	.tokens = {
12545 		(void *)&cmd_vf_mac_anti_spoof_set,
12546 		(void *)&cmd_vf_mac_anti_spoof_vf,
12547 		(void *)&cmd_vf_mac_anti_spoof_mac,
12548 		(void *)&cmd_vf_mac_anti_spoof_antispoof,
12549 		(void *)&cmd_vf_mac_anti_spoof_port_id,
12550 		(void *)&cmd_vf_mac_anti_spoof_vf_id,
12551 		(void *)&cmd_vf_mac_anti_spoof_on_off,
12552 		NULL,
12553 	},
12554 };
12555 
12556 /* vf vlan strip queue configuration */
12557 
12558 /* Common result structure for vf mac anti spoof */
12559 struct cmd_vf_vlan_stripq_result {
12560 	cmdline_fixed_string_t set;
12561 	cmdline_fixed_string_t vf;
12562 	cmdline_fixed_string_t vlan;
12563 	cmdline_fixed_string_t stripq;
12564 	portid_t port_id;
12565 	uint16_t vf_id;
12566 	cmdline_fixed_string_t on_off;
12567 };
12568 
12569 /* Common CLI fields for vf vlan strip enable disable */
12570 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
12571 	TOKEN_STRING_INITIALIZER
12572 		(struct cmd_vf_vlan_stripq_result,
12573 		 set, "set");
12574 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
12575 	TOKEN_STRING_INITIALIZER
12576 		(struct cmd_vf_vlan_stripq_result,
12577 		 vf, "vf");
12578 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
12579 	TOKEN_STRING_INITIALIZER
12580 		(struct cmd_vf_vlan_stripq_result,
12581 		 vlan, "vlan");
12582 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
12583 	TOKEN_STRING_INITIALIZER
12584 		(struct cmd_vf_vlan_stripq_result,
12585 		 stripq, "stripq");
12586 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
12587 	TOKEN_NUM_INITIALIZER
12588 		(struct cmd_vf_vlan_stripq_result,
12589 		 port_id, UINT16);
12590 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
12591 	TOKEN_NUM_INITIALIZER
12592 		(struct cmd_vf_vlan_stripq_result,
12593 		 vf_id, UINT16);
12594 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
12595 	TOKEN_STRING_INITIALIZER
12596 		(struct cmd_vf_vlan_stripq_result,
12597 		 on_off, "on#off");
12598 
12599 static void
12600 cmd_set_vf_vlan_stripq_parsed(
12601 	void *parsed_result,
12602 	__attribute__((unused)) struct cmdline *cl,
12603 	__attribute__((unused)) void *data)
12604 {
12605 	struct cmd_vf_vlan_stripq_result *res = parsed_result;
12606 	int ret = -ENOTSUP;
12607 
12608 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12609 
12610 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12611 		return;
12612 
12613 #ifdef RTE_LIBRTE_IXGBE_PMD
12614 	if (ret == -ENOTSUP)
12615 		ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
12616 			res->vf_id, is_on);
12617 #endif
12618 #ifdef RTE_LIBRTE_I40E_PMD
12619 	if (ret == -ENOTSUP)
12620 		ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
12621 			res->vf_id, is_on);
12622 #endif
12623 #ifdef RTE_LIBRTE_BNXT_PMD
12624 	if (ret == -ENOTSUP)
12625 		ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
12626 			res->vf_id, is_on);
12627 #endif
12628 
12629 	switch (ret) {
12630 	case 0:
12631 		break;
12632 	case -EINVAL:
12633 		printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12634 		break;
12635 	case -ENODEV:
12636 		printf("invalid port_id %d\n", res->port_id);
12637 		break;
12638 	case -ENOTSUP:
12639 		printf("function not implemented\n");
12640 		break;
12641 	default:
12642 		printf("programming error: (%s)\n", strerror(-ret));
12643 	}
12644 }
12645 
12646 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
12647 	.f = cmd_set_vf_vlan_stripq_parsed,
12648 	.data = NULL,
12649 	.help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
12650 	.tokens = {
12651 		(void *)&cmd_vf_vlan_stripq_set,
12652 		(void *)&cmd_vf_vlan_stripq_vf,
12653 		(void *)&cmd_vf_vlan_stripq_vlan,
12654 		(void *)&cmd_vf_vlan_stripq_stripq,
12655 		(void *)&cmd_vf_vlan_stripq_port_id,
12656 		(void *)&cmd_vf_vlan_stripq_vf_id,
12657 		(void *)&cmd_vf_vlan_stripq_on_off,
12658 		NULL,
12659 	},
12660 };
12661 
12662 /* vf vlan insert configuration */
12663 
12664 /* Common result structure for vf vlan insert */
12665 struct cmd_vf_vlan_insert_result {
12666 	cmdline_fixed_string_t set;
12667 	cmdline_fixed_string_t vf;
12668 	cmdline_fixed_string_t vlan;
12669 	cmdline_fixed_string_t insert;
12670 	portid_t port_id;
12671 	uint16_t vf_id;
12672 	uint16_t vlan_id;
12673 };
12674 
12675 /* Common CLI fields for vf vlan insert enable disable */
12676 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
12677 	TOKEN_STRING_INITIALIZER
12678 		(struct cmd_vf_vlan_insert_result,
12679 		 set, "set");
12680 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
12681 	TOKEN_STRING_INITIALIZER
12682 		(struct cmd_vf_vlan_insert_result,
12683 		 vf, "vf");
12684 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
12685 	TOKEN_STRING_INITIALIZER
12686 		(struct cmd_vf_vlan_insert_result,
12687 		 vlan, "vlan");
12688 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
12689 	TOKEN_STRING_INITIALIZER
12690 		(struct cmd_vf_vlan_insert_result,
12691 		 insert, "insert");
12692 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
12693 	TOKEN_NUM_INITIALIZER
12694 		(struct cmd_vf_vlan_insert_result,
12695 		 port_id, UINT16);
12696 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
12697 	TOKEN_NUM_INITIALIZER
12698 		(struct cmd_vf_vlan_insert_result,
12699 		 vf_id, UINT16);
12700 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
12701 	TOKEN_NUM_INITIALIZER
12702 		(struct cmd_vf_vlan_insert_result,
12703 		 vlan_id, UINT16);
12704 
12705 static void
12706 cmd_set_vf_vlan_insert_parsed(
12707 	void *parsed_result,
12708 	__attribute__((unused)) struct cmdline *cl,
12709 	__attribute__((unused)) void *data)
12710 {
12711 	struct cmd_vf_vlan_insert_result *res = parsed_result;
12712 	int ret = -ENOTSUP;
12713 
12714 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12715 		return;
12716 
12717 #ifdef RTE_LIBRTE_IXGBE_PMD
12718 	if (ret == -ENOTSUP)
12719 		ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
12720 			res->vlan_id);
12721 #endif
12722 #ifdef RTE_LIBRTE_I40E_PMD
12723 	if (ret == -ENOTSUP)
12724 		ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
12725 			res->vlan_id);
12726 #endif
12727 #ifdef RTE_LIBRTE_BNXT_PMD
12728 	if (ret == -ENOTSUP)
12729 		ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
12730 			res->vlan_id);
12731 #endif
12732 
12733 	switch (ret) {
12734 	case 0:
12735 		break;
12736 	case -EINVAL:
12737 		printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
12738 		break;
12739 	case -ENODEV:
12740 		printf("invalid port_id %d\n", res->port_id);
12741 		break;
12742 	case -ENOTSUP:
12743 		printf("function not implemented\n");
12744 		break;
12745 	default:
12746 		printf("programming error: (%s)\n", strerror(-ret));
12747 	}
12748 }
12749 
12750 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
12751 	.f = cmd_set_vf_vlan_insert_parsed,
12752 	.data = NULL,
12753 	.help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
12754 	.tokens = {
12755 		(void *)&cmd_vf_vlan_insert_set,
12756 		(void *)&cmd_vf_vlan_insert_vf,
12757 		(void *)&cmd_vf_vlan_insert_vlan,
12758 		(void *)&cmd_vf_vlan_insert_insert,
12759 		(void *)&cmd_vf_vlan_insert_port_id,
12760 		(void *)&cmd_vf_vlan_insert_vf_id,
12761 		(void *)&cmd_vf_vlan_insert_vlan_id,
12762 		NULL,
12763 	},
12764 };
12765 
12766 /* tx loopback configuration */
12767 
12768 /* Common result structure for tx loopback */
12769 struct cmd_tx_loopback_result {
12770 	cmdline_fixed_string_t set;
12771 	cmdline_fixed_string_t tx;
12772 	cmdline_fixed_string_t loopback;
12773 	portid_t port_id;
12774 	cmdline_fixed_string_t on_off;
12775 };
12776 
12777 /* Common CLI fields for tx loopback enable disable */
12778 cmdline_parse_token_string_t cmd_tx_loopback_set =
12779 	TOKEN_STRING_INITIALIZER
12780 		(struct cmd_tx_loopback_result,
12781 		 set, "set");
12782 cmdline_parse_token_string_t cmd_tx_loopback_tx =
12783 	TOKEN_STRING_INITIALIZER
12784 		(struct cmd_tx_loopback_result,
12785 		 tx, "tx");
12786 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
12787 	TOKEN_STRING_INITIALIZER
12788 		(struct cmd_tx_loopback_result,
12789 		 loopback, "loopback");
12790 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
12791 	TOKEN_NUM_INITIALIZER
12792 		(struct cmd_tx_loopback_result,
12793 		 port_id, UINT16);
12794 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
12795 	TOKEN_STRING_INITIALIZER
12796 		(struct cmd_tx_loopback_result,
12797 		 on_off, "on#off");
12798 
12799 static void
12800 cmd_set_tx_loopback_parsed(
12801 	void *parsed_result,
12802 	__attribute__((unused)) struct cmdline *cl,
12803 	__attribute__((unused)) void *data)
12804 {
12805 	struct cmd_tx_loopback_result *res = parsed_result;
12806 	int ret = -ENOTSUP;
12807 
12808 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12809 
12810 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12811 		return;
12812 
12813 #ifdef RTE_LIBRTE_IXGBE_PMD
12814 	if (ret == -ENOTSUP)
12815 		ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
12816 #endif
12817 #ifdef RTE_LIBRTE_I40E_PMD
12818 	if (ret == -ENOTSUP)
12819 		ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
12820 #endif
12821 #ifdef RTE_LIBRTE_BNXT_PMD
12822 	if (ret == -ENOTSUP)
12823 		ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
12824 #endif
12825 
12826 	switch (ret) {
12827 	case 0:
12828 		break;
12829 	case -EINVAL:
12830 		printf("invalid is_on %d\n", is_on);
12831 		break;
12832 	case -ENODEV:
12833 		printf("invalid port_id %d\n", res->port_id);
12834 		break;
12835 	case -ENOTSUP:
12836 		printf("function not implemented\n");
12837 		break;
12838 	default:
12839 		printf("programming error: (%s)\n", strerror(-ret));
12840 	}
12841 }
12842 
12843 cmdline_parse_inst_t cmd_set_tx_loopback = {
12844 	.f = cmd_set_tx_loopback_parsed,
12845 	.data = NULL,
12846 	.help_str = "set tx loopback <port_id> on|off",
12847 	.tokens = {
12848 		(void *)&cmd_tx_loopback_set,
12849 		(void *)&cmd_tx_loopback_tx,
12850 		(void *)&cmd_tx_loopback_loopback,
12851 		(void *)&cmd_tx_loopback_port_id,
12852 		(void *)&cmd_tx_loopback_on_off,
12853 		NULL,
12854 	},
12855 };
12856 
12857 /* all queues drop enable configuration */
12858 
12859 /* Common result structure for all queues drop enable */
12860 struct cmd_all_queues_drop_en_result {
12861 	cmdline_fixed_string_t set;
12862 	cmdline_fixed_string_t all;
12863 	cmdline_fixed_string_t queues;
12864 	cmdline_fixed_string_t drop;
12865 	portid_t port_id;
12866 	cmdline_fixed_string_t on_off;
12867 };
12868 
12869 /* Common CLI fields for tx loopback enable disable */
12870 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
12871 	TOKEN_STRING_INITIALIZER
12872 		(struct cmd_all_queues_drop_en_result,
12873 		 set, "set");
12874 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
12875 	TOKEN_STRING_INITIALIZER
12876 		(struct cmd_all_queues_drop_en_result,
12877 		 all, "all");
12878 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
12879 	TOKEN_STRING_INITIALIZER
12880 		(struct cmd_all_queues_drop_en_result,
12881 		 queues, "queues");
12882 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
12883 	TOKEN_STRING_INITIALIZER
12884 		(struct cmd_all_queues_drop_en_result,
12885 		 drop, "drop");
12886 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
12887 	TOKEN_NUM_INITIALIZER
12888 		(struct cmd_all_queues_drop_en_result,
12889 		 port_id, UINT16);
12890 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
12891 	TOKEN_STRING_INITIALIZER
12892 		(struct cmd_all_queues_drop_en_result,
12893 		 on_off, "on#off");
12894 
12895 static void
12896 cmd_set_all_queues_drop_en_parsed(
12897 	void *parsed_result,
12898 	__attribute__((unused)) struct cmdline *cl,
12899 	__attribute__((unused)) void *data)
12900 {
12901 	struct cmd_all_queues_drop_en_result *res = parsed_result;
12902 	int ret = -ENOTSUP;
12903 	int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12904 
12905 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12906 		return;
12907 
12908 #ifdef RTE_LIBRTE_IXGBE_PMD
12909 	if (ret == -ENOTSUP)
12910 		ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
12911 #endif
12912 #ifdef RTE_LIBRTE_BNXT_PMD
12913 	if (ret == -ENOTSUP)
12914 		ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
12915 #endif
12916 	switch (ret) {
12917 	case 0:
12918 		break;
12919 	case -EINVAL:
12920 		printf("invalid is_on %d\n", is_on);
12921 		break;
12922 	case -ENODEV:
12923 		printf("invalid port_id %d\n", res->port_id);
12924 		break;
12925 	case -ENOTSUP:
12926 		printf("function not implemented\n");
12927 		break;
12928 	default:
12929 		printf("programming error: (%s)\n", strerror(-ret));
12930 	}
12931 }
12932 
12933 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
12934 	.f = cmd_set_all_queues_drop_en_parsed,
12935 	.data = NULL,
12936 	.help_str = "set all queues drop <port_id> on|off",
12937 	.tokens = {
12938 		(void *)&cmd_all_queues_drop_en_set,
12939 		(void *)&cmd_all_queues_drop_en_all,
12940 		(void *)&cmd_all_queues_drop_en_queues,
12941 		(void *)&cmd_all_queues_drop_en_drop,
12942 		(void *)&cmd_all_queues_drop_en_port_id,
12943 		(void *)&cmd_all_queues_drop_en_on_off,
12944 		NULL,
12945 	},
12946 };
12947 
12948 /* vf split drop enable configuration */
12949 
12950 /* Common result structure for vf split drop enable */
12951 struct cmd_vf_split_drop_en_result {
12952 	cmdline_fixed_string_t set;
12953 	cmdline_fixed_string_t vf;
12954 	cmdline_fixed_string_t split;
12955 	cmdline_fixed_string_t drop;
12956 	portid_t port_id;
12957 	uint16_t vf_id;
12958 	cmdline_fixed_string_t on_off;
12959 };
12960 
12961 /* Common CLI fields for vf split drop enable disable */
12962 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
12963 	TOKEN_STRING_INITIALIZER
12964 		(struct cmd_vf_split_drop_en_result,
12965 		 set, "set");
12966 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
12967 	TOKEN_STRING_INITIALIZER
12968 		(struct cmd_vf_split_drop_en_result,
12969 		 vf, "vf");
12970 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
12971 	TOKEN_STRING_INITIALIZER
12972 		(struct cmd_vf_split_drop_en_result,
12973 		 split, "split");
12974 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
12975 	TOKEN_STRING_INITIALIZER
12976 		(struct cmd_vf_split_drop_en_result,
12977 		 drop, "drop");
12978 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
12979 	TOKEN_NUM_INITIALIZER
12980 		(struct cmd_vf_split_drop_en_result,
12981 		 port_id, UINT16);
12982 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
12983 	TOKEN_NUM_INITIALIZER
12984 		(struct cmd_vf_split_drop_en_result,
12985 		 vf_id, UINT16);
12986 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
12987 	TOKEN_STRING_INITIALIZER
12988 		(struct cmd_vf_split_drop_en_result,
12989 		 on_off, "on#off");
12990 
12991 static void
12992 cmd_set_vf_split_drop_en_parsed(
12993 	void *parsed_result,
12994 	__attribute__((unused)) struct cmdline *cl,
12995 	__attribute__((unused)) void *data)
12996 {
12997 	struct cmd_vf_split_drop_en_result *res = parsed_result;
12998 	int ret = -ENOTSUP;
12999 	int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13000 
13001 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13002 		return;
13003 
13004 #ifdef RTE_LIBRTE_IXGBE_PMD
13005 	ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
13006 			is_on);
13007 #endif
13008 	switch (ret) {
13009 	case 0:
13010 		break;
13011 	case -EINVAL:
13012 		printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13013 		break;
13014 	case -ENODEV:
13015 		printf("invalid port_id %d\n", res->port_id);
13016 		break;
13017 	case -ENOTSUP:
13018 		printf("not supported on port %d\n", res->port_id);
13019 		break;
13020 	default:
13021 		printf("programming error: (%s)\n", strerror(-ret));
13022 	}
13023 }
13024 
13025 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
13026 	.f = cmd_set_vf_split_drop_en_parsed,
13027 	.data = NULL,
13028 	.help_str = "set vf split drop <port_id> <vf_id> on|off",
13029 	.tokens = {
13030 		(void *)&cmd_vf_split_drop_en_set,
13031 		(void *)&cmd_vf_split_drop_en_vf,
13032 		(void *)&cmd_vf_split_drop_en_split,
13033 		(void *)&cmd_vf_split_drop_en_drop,
13034 		(void *)&cmd_vf_split_drop_en_port_id,
13035 		(void *)&cmd_vf_split_drop_en_vf_id,
13036 		(void *)&cmd_vf_split_drop_en_on_off,
13037 		NULL,
13038 	},
13039 };
13040 
13041 /* vf mac address configuration */
13042 
13043 /* Common result structure for vf mac address */
13044 struct cmd_set_vf_mac_addr_result {
13045 	cmdline_fixed_string_t set;
13046 	cmdline_fixed_string_t vf;
13047 	cmdline_fixed_string_t mac;
13048 	cmdline_fixed_string_t addr;
13049 	portid_t port_id;
13050 	uint16_t vf_id;
13051 	struct ether_addr mac_addr;
13052 
13053 };
13054 
13055 /* Common CLI fields for vf split drop enable disable */
13056 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
13057 	TOKEN_STRING_INITIALIZER
13058 		(struct cmd_set_vf_mac_addr_result,
13059 		 set, "set");
13060 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
13061 	TOKEN_STRING_INITIALIZER
13062 		(struct cmd_set_vf_mac_addr_result,
13063 		 vf, "vf");
13064 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
13065 	TOKEN_STRING_INITIALIZER
13066 		(struct cmd_set_vf_mac_addr_result,
13067 		 mac, "mac");
13068 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
13069 	TOKEN_STRING_INITIALIZER
13070 		(struct cmd_set_vf_mac_addr_result,
13071 		 addr, "addr");
13072 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
13073 	TOKEN_NUM_INITIALIZER
13074 		(struct cmd_set_vf_mac_addr_result,
13075 		 port_id, UINT16);
13076 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
13077 	TOKEN_NUM_INITIALIZER
13078 		(struct cmd_set_vf_mac_addr_result,
13079 		 vf_id, UINT16);
13080 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
13081 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
13082 		 mac_addr);
13083 
13084 static void
13085 cmd_set_vf_mac_addr_parsed(
13086 	void *parsed_result,
13087 	__attribute__((unused)) struct cmdline *cl,
13088 	__attribute__((unused)) void *data)
13089 {
13090 	struct cmd_set_vf_mac_addr_result *res = parsed_result;
13091 	int ret = -ENOTSUP;
13092 
13093 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13094 		return;
13095 
13096 #ifdef RTE_LIBRTE_IXGBE_PMD
13097 	if (ret == -ENOTSUP)
13098 		ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
13099 				&res->mac_addr);
13100 #endif
13101 #ifdef RTE_LIBRTE_I40E_PMD
13102 	if (ret == -ENOTSUP)
13103 		ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
13104 				&res->mac_addr);
13105 #endif
13106 #ifdef RTE_LIBRTE_BNXT_PMD
13107 	if (ret == -ENOTSUP)
13108 		ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
13109 				&res->mac_addr);
13110 #endif
13111 
13112 	switch (ret) {
13113 	case 0:
13114 		break;
13115 	case -EINVAL:
13116 		printf("invalid vf_id %d or mac_addr\n", res->vf_id);
13117 		break;
13118 	case -ENODEV:
13119 		printf("invalid port_id %d\n", res->port_id);
13120 		break;
13121 	case -ENOTSUP:
13122 		printf("function not implemented\n");
13123 		break;
13124 	default:
13125 		printf("programming error: (%s)\n", strerror(-ret));
13126 	}
13127 }
13128 
13129 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
13130 	.f = cmd_set_vf_mac_addr_parsed,
13131 	.data = NULL,
13132 	.help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
13133 	.tokens = {
13134 		(void *)&cmd_set_vf_mac_addr_set,
13135 		(void *)&cmd_set_vf_mac_addr_vf,
13136 		(void *)&cmd_set_vf_mac_addr_mac,
13137 		(void *)&cmd_set_vf_mac_addr_addr,
13138 		(void *)&cmd_set_vf_mac_addr_port_id,
13139 		(void *)&cmd_set_vf_mac_addr_vf_id,
13140 		(void *)&cmd_set_vf_mac_addr_mac_addr,
13141 		NULL,
13142 	},
13143 };
13144 
13145 /* MACsec configuration */
13146 
13147 /* Common result structure for MACsec offload enable */
13148 struct cmd_macsec_offload_on_result {
13149 	cmdline_fixed_string_t set;
13150 	cmdline_fixed_string_t macsec;
13151 	cmdline_fixed_string_t offload;
13152 	portid_t port_id;
13153 	cmdline_fixed_string_t on;
13154 	cmdline_fixed_string_t encrypt;
13155 	cmdline_fixed_string_t en_on_off;
13156 	cmdline_fixed_string_t replay_protect;
13157 	cmdline_fixed_string_t rp_on_off;
13158 };
13159 
13160 /* Common CLI fields for MACsec offload disable */
13161 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
13162 	TOKEN_STRING_INITIALIZER
13163 		(struct cmd_macsec_offload_on_result,
13164 		 set, "set");
13165 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
13166 	TOKEN_STRING_INITIALIZER
13167 		(struct cmd_macsec_offload_on_result,
13168 		 macsec, "macsec");
13169 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
13170 	TOKEN_STRING_INITIALIZER
13171 		(struct cmd_macsec_offload_on_result,
13172 		 offload, "offload");
13173 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
13174 	TOKEN_NUM_INITIALIZER
13175 		(struct cmd_macsec_offload_on_result,
13176 		 port_id, UINT16);
13177 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
13178 	TOKEN_STRING_INITIALIZER
13179 		(struct cmd_macsec_offload_on_result,
13180 		 on, "on");
13181 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
13182 	TOKEN_STRING_INITIALIZER
13183 		(struct cmd_macsec_offload_on_result,
13184 		 encrypt, "encrypt");
13185 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
13186 	TOKEN_STRING_INITIALIZER
13187 		(struct cmd_macsec_offload_on_result,
13188 		 en_on_off, "on#off");
13189 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
13190 	TOKEN_STRING_INITIALIZER
13191 		(struct cmd_macsec_offload_on_result,
13192 		 replay_protect, "replay-protect");
13193 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
13194 	TOKEN_STRING_INITIALIZER
13195 		(struct cmd_macsec_offload_on_result,
13196 		 rp_on_off, "on#off");
13197 
13198 static void
13199 cmd_set_macsec_offload_on_parsed(
13200 	void *parsed_result,
13201 	__attribute__((unused)) struct cmdline *cl,
13202 	__attribute__((unused)) void *data)
13203 {
13204 	struct cmd_macsec_offload_on_result *res = parsed_result;
13205 	int ret = -ENOTSUP;
13206 	portid_t port_id = res->port_id;
13207 	int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
13208 	int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
13209 	struct rte_eth_dev_info dev_info;
13210 
13211 	if (port_id_is_invalid(port_id, ENABLED_WARN))
13212 		return;
13213 	if (!port_is_stopped(port_id)) {
13214 		printf("Please stop port %d first\n", port_id);
13215 		return;
13216 	}
13217 
13218 	rte_eth_dev_info_get(port_id, &dev_info);
13219 	if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
13220 #ifdef RTE_LIBRTE_IXGBE_PMD
13221 		ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
13222 #endif
13223 	}
13224 	RTE_SET_USED(en);
13225 	RTE_SET_USED(rp);
13226 
13227 	switch (ret) {
13228 	case 0:
13229 		ports[port_id].dev_conf.txmode.offloads |=
13230 						DEV_TX_OFFLOAD_MACSEC_INSERT;
13231 		cmd_reconfig_device_queue(port_id, 1, 1);
13232 		break;
13233 	case -ENODEV:
13234 		printf("invalid port_id %d\n", port_id);
13235 		break;
13236 	case -ENOTSUP:
13237 		printf("not supported on port %d\n", port_id);
13238 		break;
13239 	default:
13240 		printf("programming error: (%s)\n", strerror(-ret));
13241 	}
13242 }
13243 
13244 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
13245 	.f = cmd_set_macsec_offload_on_parsed,
13246 	.data = NULL,
13247 	.help_str = "set macsec offload <port_id> on "
13248 		"encrypt on|off replay-protect on|off",
13249 	.tokens = {
13250 		(void *)&cmd_macsec_offload_on_set,
13251 		(void *)&cmd_macsec_offload_on_macsec,
13252 		(void *)&cmd_macsec_offload_on_offload,
13253 		(void *)&cmd_macsec_offload_on_port_id,
13254 		(void *)&cmd_macsec_offload_on_on,
13255 		(void *)&cmd_macsec_offload_on_encrypt,
13256 		(void *)&cmd_macsec_offload_on_en_on_off,
13257 		(void *)&cmd_macsec_offload_on_replay_protect,
13258 		(void *)&cmd_macsec_offload_on_rp_on_off,
13259 		NULL,
13260 	},
13261 };
13262 
13263 /* Common result structure for MACsec offload disable */
13264 struct cmd_macsec_offload_off_result {
13265 	cmdline_fixed_string_t set;
13266 	cmdline_fixed_string_t macsec;
13267 	cmdline_fixed_string_t offload;
13268 	portid_t port_id;
13269 	cmdline_fixed_string_t off;
13270 };
13271 
13272 /* Common CLI fields for MACsec offload disable */
13273 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
13274 	TOKEN_STRING_INITIALIZER
13275 		(struct cmd_macsec_offload_off_result,
13276 		 set, "set");
13277 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
13278 	TOKEN_STRING_INITIALIZER
13279 		(struct cmd_macsec_offload_off_result,
13280 		 macsec, "macsec");
13281 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
13282 	TOKEN_STRING_INITIALIZER
13283 		(struct cmd_macsec_offload_off_result,
13284 		 offload, "offload");
13285 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
13286 	TOKEN_NUM_INITIALIZER
13287 		(struct cmd_macsec_offload_off_result,
13288 		 port_id, UINT16);
13289 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
13290 	TOKEN_STRING_INITIALIZER
13291 		(struct cmd_macsec_offload_off_result,
13292 		 off, "off");
13293 
13294 static void
13295 cmd_set_macsec_offload_off_parsed(
13296 	void *parsed_result,
13297 	__attribute__((unused)) struct cmdline *cl,
13298 	__attribute__((unused)) void *data)
13299 {
13300 	struct cmd_macsec_offload_off_result *res = parsed_result;
13301 	int ret = -ENOTSUP;
13302 	struct rte_eth_dev_info dev_info;
13303 	portid_t port_id = res->port_id;
13304 
13305 	if (port_id_is_invalid(port_id, ENABLED_WARN))
13306 		return;
13307 	if (!port_is_stopped(port_id)) {
13308 		printf("Please stop port %d first\n", port_id);
13309 		return;
13310 	}
13311 
13312 	rte_eth_dev_info_get(port_id, &dev_info);
13313 	if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
13314 #ifdef RTE_LIBRTE_IXGBE_PMD
13315 		ret = rte_pmd_ixgbe_macsec_disable(port_id);
13316 #endif
13317 	}
13318 	switch (ret) {
13319 	case 0:
13320 		ports[port_id].dev_conf.txmode.offloads &=
13321 						~DEV_TX_OFFLOAD_MACSEC_INSERT;
13322 		cmd_reconfig_device_queue(port_id, 1, 1);
13323 		break;
13324 	case -ENODEV:
13325 		printf("invalid port_id %d\n", port_id);
13326 		break;
13327 	case -ENOTSUP:
13328 		printf("not supported on port %d\n", port_id);
13329 		break;
13330 	default:
13331 		printf("programming error: (%s)\n", strerror(-ret));
13332 	}
13333 }
13334 
13335 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
13336 	.f = cmd_set_macsec_offload_off_parsed,
13337 	.data = NULL,
13338 	.help_str = "set macsec offload <port_id> off",
13339 	.tokens = {
13340 		(void *)&cmd_macsec_offload_off_set,
13341 		(void *)&cmd_macsec_offload_off_macsec,
13342 		(void *)&cmd_macsec_offload_off_offload,
13343 		(void *)&cmd_macsec_offload_off_port_id,
13344 		(void *)&cmd_macsec_offload_off_off,
13345 		NULL,
13346 	},
13347 };
13348 
13349 /* Common result structure for MACsec secure connection configure */
13350 struct cmd_macsec_sc_result {
13351 	cmdline_fixed_string_t set;
13352 	cmdline_fixed_string_t macsec;
13353 	cmdline_fixed_string_t sc;
13354 	cmdline_fixed_string_t tx_rx;
13355 	portid_t port_id;
13356 	struct ether_addr mac;
13357 	uint16_t pi;
13358 };
13359 
13360 /* Common CLI fields for MACsec secure connection configure */
13361 cmdline_parse_token_string_t cmd_macsec_sc_set =
13362 	TOKEN_STRING_INITIALIZER
13363 		(struct cmd_macsec_sc_result,
13364 		 set, "set");
13365 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
13366 	TOKEN_STRING_INITIALIZER
13367 		(struct cmd_macsec_sc_result,
13368 		 macsec, "macsec");
13369 cmdline_parse_token_string_t cmd_macsec_sc_sc =
13370 	TOKEN_STRING_INITIALIZER
13371 		(struct cmd_macsec_sc_result,
13372 		 sc, "sc");
13373 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
13374 	TOKEN_STRING_INITIALIZER
13375 		(struct cmd_macsec_sc_result,
13376 		 tx_rx, "tx#rx");
13377 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
13378 	TOKEN_NUM_INITIALIZER
13379 		(struct cmd_macsec_sc_result,
13380 		 port_id, UINT16);
13381 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
13382 	TOKEN_ETHERADDR_INITIALIZER
13383 		(struct cmd_macsec_sc_result,
13384 		 mac);
13385 cmdline_parse_token_num_t cmd_macsec_sc_pi =
13386 	TOKEN_NUM_INITIALIZER
13387 		(struct cmd_macsec_sc_result,
13388 		 pi, UINT16);
13389 
13390 static void
13391 cmd_set_macsec_sc_parsed(
13392 	void *parsed_result,
13393 	__attribute__((unused)) struct cmdline *cl,
13394 	__attribute__((unused)) void *data)
13395 {
13396 	struct cmd_macsec_sc_result *res = parsed_result;
13397 	int ret = -ENOTSUP;
13398 	int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
13399 
13400 #ifdef RTE_LIBRTE_IXGBE_PMD
13401 	ret = is_tx ?
13402 		rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
13403 				res->mac.addr_bytes) :
13404 		rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
13405 				res->mac.addr_bytes, res->pi);
13406 #endif
13407 	RTE_SET_USED(is_tx);
13408 
13409 	switch (ret) {
13410 	case 0:
13411 		break;
13412 	case -ENODEV:
13413 		printf("invalid port_id %d\n", res->port_id);
13414 		break;
13415 	case -ENOTSUP:
13416 		printf("not supported on port %d\n", res->port_id);
13417 		break;
13418 	default:
13419 		printf("programming error: (%s)\n", strerror(-ret));
13420 	}
13421 }
13422 
13423 cmdline_parse_inst_t cmd_set_macsec_sc = {
13424 	.f = cmd_set_macsec_sc_parsed,
13425 	.data = NULL,
13426 	.help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
13427 	.tokens = {
13428 		(void *)&cmd_macsec_sc_set,
13429 		(void *)&cmd_macsec_sc_macsec,
13430 		(void *)&cmd_macsec_sc_sc,
13431 		(void *)&cmd_macsec_sc_tx_rx,
13432 		(void *)&cmd_macsec_sc_port_id,
13433 		(void *)&cmd_macsec_sc_mac,
13434 		(void *)&cmd_macsec_sc_pi,
13435 		NULL,
13436 	},
13437 };
13438 
13439 /* Common result structure for MACsec secure connection configure */
13440 struct cmd_macsec_sa_result {
13441 	cmdline_fixed_string_t set;
13442 	cmdline_fixed_string_t macsec;
13443 	cmdline_fixed_string_t sa;
13444 	cmdline_fixed_string_t tx_rx;
13445 	portid_t port_id;
13446 	uint8_t idx;
13447 	uint8_t an;
13448 	uint32_t pn;
13449 	cmdline_fixed_string_t key;
13450 };
13451 
13452 /* Common CLI fields for MACsec secure connection configure */
13453 cmdline_parse_token_string_t cmd_macsec_sa_set =
13454 	TOKEN_STRING_INITIALIZER
13455 		(struct cmd_macsec_sa_result,
13456 		 set, "set");
13457 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
13458 	TOKEN_STRING_INITIALIZER
13459 		(struct cmd_macsec_sa_result,
13460 		 macsec, "macsec");
13461 cmdline_parse_token_string_t cmd_macsec_sa_sa =
13462 	TOKEN_STRING_INITIALIZER
13463 		(struct cmd_macsec_sa_result,
13464 		 sa, "sa");
13465 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
13466 	TOKEN_STRING_INITIALIZER
13467 		(struct cmd_macsec_sa_result,
13468 		 tx_rx, "tx#rx");
13469 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
13470 	TOKEN_NUM_INITIALIZER
13471 		(struct cmd_macsec_sa_result,
13472 		 port_id, UINT16);
13473 cmdline_parse_token_num_t cmd_macsec_sa_idx =
13474 	TOKEN_NUM_INITIALIZER
13475 		(struct cmd_macsec_sa_result,
13476 		 idx, UINT8);
13477 cmdline_parse_token_num_t cmd_macsec_sa_an =
13478 	TOKEN_NUM_INITIALIZER
13479 		(struct cmd_macsec_sa_result,
13480 		 an, UINT8);
13481 cmdline_parse_token_num_t cmd_macsec_sa_pn =
13482 	TOKEN_NUM_INITIALIZER
13483 		(struct cmd_macsec_sa_result,
13484 		 pn, UINT32);
13485 cmdline_parse_token_string_t cmd_macsec_sa_key =
13486 	TOKEN_STRING_INITIALIZER
13487 		(struct cmd_macsec_sa_result,
13488 		 key, NULL);
13489 
13490 static void
13491 cmd_set_macsec_sa_parsed(
13492 	void *parsed_result,
13493 	__attribute__((unused)) struct cmdline *cl,
13494 	__attribute__((unused)) void *data)
13495 {
13496 	struct cmd_macsec_sa_result *res = parsed_result;
13497 	int ret = -ENOTSUP;
13498 	int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
13499 	uint8_t key[16] = { 0 };
13500 	uint8_t xdgt0;
13501 	uint8_t xdgt1;
13502 	int key_len;
13503 	int i;
13504 
13505 	key_len = strlen(res->key) / 2;
13506 	if (key_len > 16)
13507 		key_len = 16;
13508 
13509 	for (i = 0; i < key_len; i++) {
13510 		xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
13511 		if (xdgt0 == 0xFF)
13512 			return;
13513 		xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
13514 		if (xdgt1 == 0xFF)
13515 			return;
13516 		key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
13517 	}
13518 
13519 #ifdef RTE_LIBRTE_IXGBE_PMD
13520 	ret = is_tx ?
13521 		rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
13522 			res->idx, res->an, res->pn, key) :
13523 		rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
13524 			res->idx, res->an, res->pn, key);
13525 #endif
13526 	RTE_SET_USED(is_tx);
13527 	RTE_SET_USED(key);
13528 
13529 	switch (ret) {
13530 	case 0:
13531 		break;
13532 	case -EINVAL:
13533 		printf("invalid idx %d or an %d\n", res->idx, res->an);
13534 		break;
13535 	case -ENODEV:
13536 		printf("invalid port_id %d\n", res->port_id);
13537 		break;
13538 	case -ENOTSUP:
13539 		printf("not supported on port %d\n", res->port_id);
13540 		break;
13541 	default:
13542 		printf("programming error: (%s)\n", strerror(-ret));
13543 	}
13544 }
13545 
13546 cmdline_parse_inst_t cmd_set_macsec_sa = {
13547 	.f = cmd_set_macsec_sa_parsed,
13548 	.data = NULL,
13549 	.help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
13550 	.tokens = {
13551 		(void *)&cmd_macsec_sa_set,
13552 		(void *)&cmd_macsec_sa_macsec,
13553 		(void *)&cmd_macsec_sa_sa,
13554 		(void *)&cmd_macsec_sa_tx_rx,
13555 		(void *)&cmd_macsec_sa_port_id,
13556 		(void *)&cmd_macsec_sa_idx,
13557 		(void *)&cmd_macsec_sa_an,
13558 		(void *)&cmd_macsec_sa_pn,
13559 		(void *)&cmd_macsec_sa_key,
13560 		NULL,
13561 	},
13562 };
13563 
13564 /* VF unicast promiscuous mode configuration */
13565 
13566 /* Common result structure for VF unicast promiscuous mode */
13567 struct cmd_vf_promisc_result {
13568 	cmdline_fixed_string_t set;
13569 	cmdline_fixed_string_t vf;
13570 	cmdline_fixed_string_t promisc;
13571 	portid_t port_id;
13572 	uint32_t vf_id;
13573 	cmdline_fixed_string_t on_off;
13574 };
13575 
13576 /* Common CLI fields for VF unicast promiscuous mode enable disable */
13577 cmdline_parse_token_string_t cmd_vf_promisc_set =
13578 	TOKEN_STRING_INITIALIZER
13579 		(struct cmd_vf_promisc_result,
13580 		 set, "set");
13581 cmdline_parse_token_string_t cmd_vf_promisc_vf =
13582 	TOKEN_STRING_INITIALIZER
13583 		(struct cmd_vf_promisc_result,
13584 		 vf, "vf");
13585 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
13586 	TOKEN_STRING_INITIALIZER
13587 		(struct cmd_vf_promisc_result,
13588 		 promisc, "promisc");
13589 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
13590 	TOKEN_NUM_INITIALIZER
13591 		(struct cmd_vf_promisc_result,
13592 		 port_id, UINT16);
13593 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
13594 	TOKEN_NUM_INITIALIZER
13595 		(struct cmd_vf_promisc_result,
13596 		 vf_id, UINT32);
13597 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
13598 	TOKEN_STRING_INITIALIZER
13599 		(struct cmd_vf_promisc_result,
13600 		 on_off, "on#off");
13601 
13602 static void
13603 cmd_set_vf_promisc_parsed(
13604 	void *parsed_result,
13605 	__attribute__((unused)) struct cmdline *cl,
13606 	__attribute__((unused)) void *data)
13607 {
13608 	struct cmd_vf_promisc_result *res = parsed_result;
13609 	int ret = -ENOTSUP;
13610 
13611 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13612 
13613 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13614 		return;
13615 
13616 #ifdef RTE_LIBRTE_I40E_PMD
13617 	ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
13618 						  res->vf_id, is_on);
13619 #endif
13620 
13621 	switch (ret) {
13622 	case 0:
13623 		break;
13624 	case -EINVAL:
13625 		printf("invalid vf_id %d\n", res->vf_id);
13626 		break;
13627 	case -ENODEV:
13628 		printf("invalid port_id %d\n", res->port_id);
13629 		break;
13630 	case -ENOTSUP:
13631 		printf("function not implemented\n");
13632 		break;
13633 	default:
13634 		printf("programming error: (%s)\n", strerror(-ret));
13635 	}
13636 }
13637 
13638 cmdline_parse_inst_t cmd_set_vf_promisc = {
13639 	.f = cmd_set_vf_promisc_parsed,
13640 	.data = NULL,
13641 	.help_str = "set vf promisc <port_id> <vf_id> on|off: "
13642 		"Set unicast promiscuous mode for a VF from the PF",
13643 	.tokens = {
13644 		(void *)&cmd_vf_promisc_set,
13645 		(void *)&cmd_vf_promisc_vf,
13646 		(void *)&cmd_vf_promisc_promisc,
13647 		(void *)&cmd_vf_promisc_port_id,
13648 		(void *)&cmd_vf_promisc_vf_id,
13649 		(void *)&cmd_vf_promisc_on_off,
13650 		NULL,
13651 	},
13652 };
13653 
13654 /* VF multicast promiscuous mode configuration */
13655 
13656 /* Common result structure for VF multicast promiscuous mode */
13657 struct cmd_vf_allmulti_result {
13658 	cmdline_fixed_string_t set;
13659 	cmdline_fixed_string_t vf;
13660 	cmdline_fixed_string_t allmulti;
13661 	portid_t port_id;
13662 	uint32_t vf_id;
13663 	cmdline_fixed_string_t on_off;
13664 };
13665 
13666 /* Common CLI fields for VF multicast promiscuous mode enable disable */
13667 cmdline_parse_token_string_t cmd_vf_allmulti_set =
13668 	TOKEN_STRING_INITIALIZER
13669 		(struct cmd_vf_allmulti_result,
13670 		 set, "set");
13671 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
13672 	TOKEN_STRING_INITIALIZER
13673 		(struct cmd_vf_allmulti_result,
13674 		 vf, "vf");
13675 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
13676 	TOKEN_STRING_INITIALIZER
13677 		(struct cmd_vf_allmulti_result,
13678 		 allmulti, "allmulti");
13679 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
13680 	TOKEN_NUM_INITIALIZER
13681 		(struct cmd_vf_allmulti_result,
13682 		 port_id, UINT16);
13683 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
13684 	TOKEN_NUM_INITIALIZER
13685 		(struct cmd_vf_allmulti_result,
13686 		 vf_id, UINT32);
13687 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
13688 	TOKEN_STRING_INITIALIZER
13689 		(struct cmd_vf_allmulti_result,
13690 		 on_off, "on#off");
13691 
13692 static void
13693 cmd_set_vf_allmulti_parsed(
13694 	void *parsed_result,
13695 	__attribute__((unused)) struct cmdline *cl,
13696 	__attribute__((unused)) void *data)
13697 {
13698 	struct cmd_vf_allmulti_result *res = parsed_result;
13699 	int ret = -ENOTSUP;
13700 
13701 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13702 
13703 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13704 		return;
13705 
13706 #ifdef RTE_LIBRTE_I40E_PMD
13707 	ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
13708 						    res->vf_id, is_on);
13709 #endif
13710 
13711 	switch (ret) {
13712 	case 0:
13713 		break;
13714 	case -EINVAL:
13715 		printf("invalid vf_id %d\n", res->vf_id);
13716 		break;
13717 	case -ENODEV:
13718 		printf("invalid port_id %d\n", res->port_id);
13719 		break;
13720 	case -ENOTSUP:
13721 		printf("function not implemented\n");
13722 		break;
13723 	default:
13724 		printf("programming error: (%s)\n", strerror(-ret));
13725 	}
13726 }
13727 
13728 cmdline_parse_inst_t cmd_set_vf_allmulti = {
13729 	.f = cmd_set_vf_allmulti_parsed,
13730 	.data = NULL,
13731 	.help_str = "set vf allmulti <port_id> <vf_id> on|off: "
13732 		"Set multicast promiscuous mode for a VF from the PF",
13733 	.tokens = {
13734 		(void *)&cmd_vf_allmulti_set,
13735 		(void *)&cmd_vf_allmulti_vf,
13736 		(void *)&cmd_vf_allmulti_allmulti,
13737 		(void *)&cmd_vf_allmulti_port_id,
13738 		(void *)&cmd_vf_allmulti_vf_id,
13739 		(void *)&cmd_vf_allmulti_on_off,
13740 		NULL,
13741 	},
13742 };
13743 
13744 /* vf broadcast mode configuration */
13745 
13746 /* Common result structure for vf broadcast */
13747 struct cmd_set_vf_broadcast_result {
13748 	cmdline_fixed_string_t set;
13749 	cmdline_fixed_string_t vf;
13750 	cmdline_fixed_string_t broadcast;
13751 	portid_t port_id;
13752 	uint16_t vf_id;
13753 	cmdline_fixed_string_t on_off;
13754 };
13755 
13756 /* Common CLI fields for vf broadcast enable disable */
13757 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
13758 	TOKEN_STRING_INITIALIZER
13759 		(struct cmd_set_vf_broadcast_result,
13760 		 set, "set");
13761 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
13762 	TOKEN_STRING_INITIALIZER
13763 		(struct cmd_set_vf_broadcast_result,
13764 		 vf, "vf");
13765 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
13766 	TOKEN_STRING_INITIALIZER
13767 		(struct cmd_set_vf_broadcast_result,
13768 		 broadcast, "broadcast");
13769 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
13770 	TOKEN_NUM_INITIALIZER
13771 		(struct cmd_set_vf_broadcast_result,
13772 		 port_id, UINT16);
13773 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
13774 	TOKEN_NUM_INITIALIZER
13775 		(struct cmd_set_vf_broadcast_result,
13776 		 vf_id, UINT16);
13777 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
13778 	TOKEN_STRING_INITIALIZER
13779 		(struct cmd_set_vf_broadcast_result,
13780 		 on_off, "on#off");
13781 
13782 static void
13783 cmd_set_vf_broadcast_parsed(
13784 	void *parsed_result,
13785 	__attribute__((unused)) struct cmdline *cl,
13786 	__attribute__((unused)) void *data)
13787 {
13788 	struct cmd_set_vf_broadcast_result *res = parsed_result;
13789 	int ret = -ENOTSUP;
13790 
13791 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13792 
13793 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13794 		return;
13795 
13796 #ifdef RTE_LIBRTE_I40E_PMD
13797 	ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
13798 					    res->vf_id, is_on);
13799 #endif
13800 
13801 	switch (ret) {
13802 	case 0:
13803 		break;
13804 	case -EINVAL:
13805 		printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13806 		break;
13807 	case -ENODEV:
13808 		printf("invalid port_id %d\n", res->port_id);
13809 		break;
13810 	case -ENOTSUP:
13811 		printf("function not implemented\n");
13812 		break;
13813 	default:
13814 		printf("programming error: (%s)\n", strerror(-ret));
13815 	}
13816 }
13817 
13818 cmdline_parse_inst_t cmd_set_vf_broadcast = {
13819 	.f = cmd_set_vf_broadcast_parsed,
13820 	.data = NULL,
13821 	.help_str = "set vf broadcast <port_id> <vf_id> on|off",
13822 	.tokens = {
13823 		(void *)&cmd_set_vf_broadcast_set,
13824 		(void *)&cmd_set_vf_broadcast_vf,
13825 		(void *)&cmd_set_vf_broadcast_broadcast,
13826 		(void *)&cmd_set_vf_broadcast_port_id,
13827 		(void *)&cmd_set_vf_broadcast_vf_id,
13828 		(void *)&cmd_set_vf_broadcast_on_off,
13829 		NULL,
13830 	},
13831 };
13832 
13833 /* vf vlan tag configuration */
13834 
13835 /* Common result structure for vf vlan tag */
13836 struct cmd_set_vf_vlan_tag_result {
13837 	cmdline_fixed_string_t set;
13838 	cmdline_fixed_string_t vf;
13839 	cmdline_fixed_string_t vlan;
13840 	cmdline_fixed_string_t tag;
13841 	portid_t port_id;
13842 	uint16_t vf_id;
13843 	cmdline_fixed_string_t on_off;
13844 };
13845 
13846 /* Common CLI fields for vf vlan tag enable disable */
13847 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
13848 	TOKEN_STRING_INITIALIZER
13849 		(struct cmd_set_vf_vlan_tag_result,
13850 		 set, "set");
13851 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
13852 	TOKEN_STRING_INITIALIZER
13853 		(struct cmd_set_vf_vlan_tag_result,
13854 		 vf, "vf");
13855 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
13856 	TOKEN_STRING_INITIALIZER
13857 		(struct cmd_set_vf_vlan_tag_result,
13858 		 vlan, "vlan");
13859 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
13860 	TOKEN_STRING_INITIALIZER
13861 		(struct cmd_set_vf_vlan_tag_result,
13862 		 tag, "tag");
13863 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
13864 	TOKEN_NUM_INITIALIZER
13865 		(struct cmd_set_vf_vlan_tag_result,
13866 		 port_id, UINT16);
13867 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
13868 	TOKEN_NUM_INITIALIZER
13869 		(struct cmd_set_vf_vlan_tag_result,
13870 		 vf_id, UINT16);
13871 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
13872 	TOKEN_STRING_INITIALIZER
13873 		(struct cmd_set_vf_vlan_tag_result,
13874 		 on_off, "on#off");
13875 
13876 static void
13877 cmd_set_vf_vlan_tag_parsed(
13878 	void *parsed_result,
13879 	__attribute__((unused)) struct cmdline *cl,
13880 	__attribute__((unused)) void *data)
13881 {
13882 	struct cmd_set_vf_vlan_tag_result *res = parsed_result;
13883 	int ret = -ENOTSUP;
13884 
13885 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13886 
13887 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13888 		return;
13889 
13890 #ifdef RTE_LIBRTE_I40E_PMD
13891 	ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
13892 					   res->vf_id, is_on);
13893 #endif
13894 
13895 	switch (ret) {
13896 	case 0:
13897 		break;
13898 	case -EINVAL:
13899 		printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13900 		break;
13901 	case -ENODEV:
13902 		printf("invalid port_id %d\n", res->port_id);
13903 		break;
13904 	case -ENOTSUP:
13905 		printf("function not implemented\n");
13906 		break;
13907 	default:
13908 		printf("programming error: (%s)\n", strerror(-ret));
13909 	}
13910 }
13911 
13912 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
13913 	.f = cmd_set_vf_vlan_tag_parsed,
13914 	.data = NULL,
13915 	.help_str = "set vf vlan tag <port_id> <vf_id> on|off",
13916 	.tokens = {
13917 		(void *)&cmd_set_vf_vlan_tag_set,
13918 		(void *)&cmd_set_vf_vlan_tag_vf,
13919 		(void *)&cmd_set_vf_vlan_tag_vlan,
13920 		(void *)&cmd_set_vf_vlan_tag_tag,
13921 		(void *)&cmd_set_vf_vlan_tag_port_id,
13922 		(void *)&cmd_set_vf_vlan_tag_vf_id,
13923 		(void *)&cmd_set_vf_vlan_tag_on_off,
13924 		NULL,
13925 	},
13926 };
13927 
13928 /* Common definition of VF and TC TX bandwidth configuration */
13929 struct cmd_vf_tc_bw_result {
13930 	cmdline_fixed_string_t set;
13931 	cmdline_fixed_string_t vf;
13932 	cmdline_fixed_string_t tc;
13933 	cmdline_fixed_string_t tx;
13934 	cmdline_fixed_string_t min_bw;
13935 	cmdline_fixed_string_t max_bw;
13936 	cmdline_fixed_string_t strict_link_prio;
13937 	portid_t port_id;
13938 	uint16_t vf_id;
13939 	uint8_t tc_no;
13940 	uint32_t bw;
13941 	cmdline_fixed_string_t bw_list;
13942 	uint8_t tc_map;
13943 };
13944 
13945 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
13946 	TOKEN_STRING_INITIALIZER
13947 		(struct cmd_vf_tc_bw_result,
13948 		 set, "set");
13949 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
13950 	TOKEN_STRING_INITIALIZER
13951 		(struct cmd_vf_tc_bw_result,
13952 		 vf, "vf");
13953 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
13954 	TOKEN_STRING_INITIALIZER
13955 		(struct cmd_vf_tc_bw_result,
13956 		 tc, "tc");
13957 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
13958 	TOKEN_STRING_INITIALIZER
13959 		(struct cmd_vf_tc_bw_result,
13960 		 tx, "tx");
13961 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
13962 	TOKEN_STRING_INITIALIZER
13963 		(struct cmd_vf_tc_bw_result,
13964 		 strict_link_prio, "strict-link-priority");
13965 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
13966 	TOKEN_STRING_INITIALIZER
13967 		(struct cmd_vf_tc_bw_result,
13968 		 min_bw, "min-bandwidth");
13969 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
13970 	TOKEN_STRING_INITIALIZER
13971 		(struct cmd_vf_tc_bw_result,
13972 		 max_bw, "max-bandwidth");
13973 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
13974 	TOKEN_NUM_INITIALIZER
13975 		(struct cmd_vf_tc_bw_result,
13976 		 port_id, UINT16);
13977 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
13978 	TOKEN_NUM_INITIALIZER
13979 		(struct cmd_vf_tc_bw_result,
13980 		 vf_id, UINT16);
13981 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
13982 	TOKEN_NUM_INITIALIZER
13983 		(struct cmd_vf_tc_bw_result,
13984 		 tc_no, UINT8);
13985 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
13986 	TOKEN_NUM_INITIALIZER
13987 		(struct cmd_vf_tc_bw_result,
13988 		 bw, UINT32);
13989 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
13990 	TOKEN_STRING_INITIALIZER
13991 		(struct cmd_vf_tc_bw_result,
13992 		 bw_list, NULL);
13993 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
13994 	TOKEN_NUM_INITIALIZER
13995 		(struct cmd_vf_tc_bw_result,
13996 		 tc_map, UINT8);
13997 
13998 /* VF max bandwidth setting */
13999 static void
14000 cmd_vf_max_bw_parsed(
14001 	void *parsed_result,
14002 	__attribute__((unused)) struct cmdline *cl,
14003 	__attribute__((unused)) void *data)
14004 {
14005 	struct cmd_vf_tc_bw_result *res = parsed_result;
14006 	int ret = -ENOTSUP;
14007 
14008 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14009 		return;
14010 
14011 #ifdef RTE_LIBRTE_I40E_PMD
14012 	ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
14013 					 res->vf_id, res->bw);
14014 #endif
14015 
14016 	switch (ret) {
14017 	case 0:
14018 		break;
14019 	case -EINVAL:
14020 		printf("invalid vf_id %d or bandwidth %d\n",
14021 		       res->vf_id, res->bw);
14022 		break;
14023 	case -ENODEV:
14024 		printf("invalid port_id %d\n", res->port_id);
14025 		break;
14026 	case -ENOTSUP:
14027 		printf("function not implemented\n");
14028 		break;
14029 	default:
14030 		printf("programming error: (%s)\n", strerror(-ret));
14031 	}
14032 }
14033 
14034 cmdline_parse_inst_t cmd_vf_max_bw = {
14035 	.f = cmd_vf_max_bw_parsed,
14036 	.data = NULL,
14037 	.help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
14038 	.tokens = {
14039 		(void *)&cmd_vf_tc_bw_set,
14040 		(void *)&cmd_vf_tc_bw_vf,
14041 		(void *)&cmd_vf_tc_bw_tx,
14042 		(void *)&cmd_vf_tc_bw_max_bw,
14043 		(void *)&cmd_vf_tc_bw_port_id,
14044 		(void *)&cmd_vf_tc_bw_vf_id,
14045 		(void *)&cmd_vf_tc_bw_bw,
14046 		NULL,
14047 	},
14048 };
14049 
14050 static int
14051 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
14052 			   uint8_t *tc_num,
14053 			   char *str)
14054 {
14055 	uint32_t size;
14056 	const char *p, *p0 = str;
14057 	char s[256];
14058 	char *end;
14059 	char *str_fld[16];
14060 	uint16_t i;
14061 	int ret;
14062 
14063 	p = strchr(p0, '(');
14064 	if (p == NULL) {
14065 		printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14066 		return -1;
14067 	}
14068 	p++;
14069 	p0 = strchr(p, ')');
14070 	if (p0 == NULL) {
14071 		printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14072 		return -1;
14073 	}
14074 	size = p0 - p;
14075 	if (size >= sizeof(s)) {
14076 		printf("The string size exceeds the internal buffer size\n");
14077 		return -1;
14078 	}
14079 	snprintf(s, sizeof(s), "%.*s", size, p);
14080 	ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
14081 	if (ret <= 0) {
14082 		printf("Failed to get the bandwidth list. ");
14083 		return -1;
14084 	}
14085 	*tc_num = ret;
14086 	for (i = 0; i < ret; i++)
14087 		bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
14088 
14089 	return 0;
14090 }
14091 
14092 /* TC min bandwidth setting */
14093 static void
14094 cmd_vf_tc_min_bw_parsed(
14095 	void *parsed_result,
14096 	__attribute__((unused)) struct cmdline *cl,
14097 	__attribute__((unused)) void *data)
14098 {
14099 	struct cmd_vf_tc_bw_result *res = parsed_result;
14100 	uint8_t tc_num;
14101 	uint8_t bw[16];
14102 	int ret = -ENOTSUP;
14103 
14104 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14105 		return;
14106 
14107 	ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
14108 	if (ret)
14109 		return;
14110 
14111 #ifdef RTE_LIBRTE_I40E_PMD
14112 	ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
14113 					      tc_num, bw);
14114 #endif
14115 
14116 	switch (ret) {
14117 	case 0:
14118 		break;
14119 	case -EINVAL:
14120 		printf("invalid vf_id %d or bandwidth\n", res->vf_id);
14121 		break;
14122 	case -ENODEV:
14123 		printf("invalid port_id %d\n", res->port_id);
14124 		break;
14125 	case -ENOTSUP:
14126 		printf("function not implemented\n");
14127 		break;
14128 	default:
14129 		printf("programming error: (%s)\n", strerror(-ret));
14130 	}
14131 }
14132 
14133 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
14134 	.f = cmd_vf_tc_min_bw_parsed,
14135 	.data = NULL,
14136 	.help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
14137 		    " <bw1, bw2, ...>",
14138 	.tokens = {
14139 		(void *)&cmd_vf_tc_bw_set,
14140 		(void *)&cmd_vf_tc_bw_vf,
14141 		(void *)&cmd_vf_tc_bw_tc,
14142 		(void *)&cmd_vf_tc_bw_tx,
14143 		(void *)&cmd_vf_tc_bw_min_bw,
14144 		(void *)&cmd_vf_tc_bw_port_id,
14145 		(void *)&cmd_vf_tc_bw_vf_id,
14146 		(void *)&cmd_vf_tc_bw_bw_list,
14147 		NULL,
14148 	},
14149 };
14150 
14151 static void
14152 cmd_tc_min_bw_parsed(
14153 	void *parsed_result,
14154 	__attribute__((unused)) struct cmdline *cl,
14155 	__attribute__((unused)) void *data)
14156 {
14157 	struct cmd_vf_tc_bw_result *res = parsed_result;
14158 	struct rte_port *port;
14159 	uint8_t tc_num;
14160 	uint8_t bw[16];
14161 	int ret = -ENOTSUP;
14162 
14163 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14164 		return;
14165 
14166 	port = &ports[res->port_id];
14167 	/** Check if the port is not started **/
14168 	if (port->port_status != RTE_PORT_STOPPED) {
14169 		printf("Please stop port %d first\n", res->port_id);
14170 		return;
14171 	}
14172 
14173 	ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
14174 	if (ret)
14175 		return;
14176 
14177 #ifdef RTE_LIBRTE_IXGBE_PMD
14178 	ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
14179 #endif
14180 
14181 	switch (ret) {
14182 	case 0:
14183 		break;
14184 	case -EINVAL:
14185 		printf("invalid bandwidth\n");
14186 		break;
14187 	case -ENODEV:
14188 		printf("invalid port_id %d\n", res->port_id);
14189 		break;
14190 	case -ENOTSUP:
14191 		printf("function not implemented\n");
14192 		break;
14193 	default:
14194 		printf("programming error: (%s)\n", strerror(-ret));
14195 	}
14196 }
14197 
14198 cmdline_parse_inst_t cmd_tc_min_bw = {
14199 	.f = cmd_tc_min_bw_parsed,
14200 	.data = NULL,
14201 	.help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
14202 	.tokens = {
14203 		(void *)&cmd_vf_tc_bw_set,
14204 		(void *)&cmd_vf_tc_bw_tc,
14205 		(void *)&cmd_vf_tc_bw_tx,
14206 		(void *)&cmd_vf_tc_bw_min_bw,
14207 		(void *)&cmd_vf_tc_bw_port_id,
14208 		(void *)&cmd_vf_tc_bw_bw_list,
14209 		NULL,
14210 	},
14211 };
14212 
14213 /* TC max bandwidth setting */
14214 static void
14215 cmd_vf_tc_max_bw_parsed(
14216 	void *parsed_result,
14217 	__attribute__((unused)) struct cmdline *cl,
14218 	__attribute__((unused)) void *data)
14219 {
14220 	struct cmd_vf_tc_bw_result *res = parsed_result;
14221 	int ret = -ENOTSUP;
14222 
14223 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14224 		return;
14225 
14226 #ifdef RTE_LIBRTE_I40E_PMD
14227 	ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
14228 					    res->tc_no, res->bw);
14229 #endif
14230 
14231 	switch (ret) {
14232 	case 0:
14233 		break;
14234 	case -EINVAL:
14235 		printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
14236 		       res->vf_id, res->tc_no, res->bw);
14237 		break;
14238 	case -ENODEV:
14239 		printf("invalid port_id %d\n", res->port_id);
14240 		break;
14241 	case -ENOTSUP:
14242 		printf("function not implemented\n");
14243 		break;
14244 	default:
14245 		printf("programming error: (%s)\n", strerror(-ret));
14246 	}
14247 }
14248 
14249 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
14250 	.f = cmd_vf_tc_max_bw_parsed,
14251 	.data = NULL,
14252 	.help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
14253 		    " <bandwidth>",
14254 	.tokens = {
14255 		(void *)&cmd_vf_tc_bw_set,
14256 		(void *)&cmd_vf_tc_bw_vf,
14257 		(void *)&cmd_vf_tc_bw_tc,
14258 		(void *)&cmd_vf_tc_bw_tx,
14259 		(void *)&cmd_vf_tc_bw_max_bw,
14260 		(void *)&cmd_vf_tc_bw_port_id,
14261 		(void *)&cmd_vf_tc_bw_vf_id,
14262 		(void *)&cmd_vf_tc_bw_tc_no,
14263 		(void *)&cmd_vf_tc_bw_bw,
14264 		NULL,
14265 	},
14266 };
14267 
14268 
14269 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
14270 
14271 /* *** Set Port default Traffic Management Hierarchy *** */
14272 struct cmd_set_port_tm_hierarchy_default_result {
14273 	cmdline_fixed_string_t set;
14274 	cmdline_fixed_string_t port;
14275 	cmdline_fixed_string_t tm;
14276 	cmdline_fixed_string_t hierarchy;
14277 	cmdline_fixed_string_t def;
14278 	portid_t port_id;
14279 };
14280 
14281 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_set =
14282 	TOKEN_STRING_INITIALIZER(
14283 		struct cmd_set_port_tm_hierarchy_default_result, set, "set");
14284 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_port =
14285 	TOKEN_STRING_INITIALIZER(
14286 		struct cmd_set_port_tm_hierarchy_default_result, port, "port");
14287 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_tm =
14288 	TOKEN_STRING_INITIALIZER(
14289 		struct cmd_set_port_tm_hierarchy_default_result, tm, "tm");
14290 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_hierarchy =
14291 	TOKEN_STRING_INITIALIZER(
14292 		struct cmd_set_port_tm_hierarchy_default_result,
14293 			hierarchy, "hierarchy");
14294 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_default =
14295 	TOKEN_STRING_INITIALIZER(
14296 		struct cmd_set_port_tm_hierarchy_default_result,
14297 			def, "default");
14298 cmdline_parse_token_num_t cmd_set_port_tm_hierarchy_default_port_id =
14299 	TOKEN_NUM_INITIALIZER(
14300 		struct cmd_set_port_tm_hierarchy_default_result,
14301 			port_id, UINT16);
14302 
14303 static void cmd_set_port_tm_hierarchy_default_parsed(void *parsed_result,
14304 	__attribute__((unused)) struct cmdline *cl,
14305 	__attribute__((unused)) void *data)
14306 {
14307 	struct cmd_set_port_tm_hierarchy_default_result *res = parsed_result;
14308 	struct rte_port *p;
14309 	portid_t port_id = res->port_id;
14310 
14311 	if (port_id_is_invalid(port_id, ENABLED_WARN))
14312 		return;
14313 
14314 	p = &ports[port_id];
14315 
14316 	/* Port tm flag */
14317 	if (p->softport.tm_flag == 0) {
14318 		printf("  tm not enabled on port %u (error)\n", port_id);
14319 		return;
14320 	}
14321 
14322 	/* Forward mode: tm */
14323 	if (strcmp(cur_fwd_config.fwd_eng->fwd_mode_name, "tm")) {
14324 		printf("  tm mode not enabled(error)\n");
14325 		return;
14326 	}
14327 
14328 	/* Set the default tm hierarchy */
14329 	p->softport.tm.default_hierarchy_enable = 1;
14330 }
14331 
14332 cmdline_parse_inst_t cmd_set_port_tm_hierarchy_default = {
14333 	.f = cmd_set_port_tm_hierarchy_default_parsed,
14334 	.data = NULL,
14335 	.help_str = "set port tm hierarchy default <port_id>",
14336 	.tokens = {
14337 		(void *)&cmd_set_port_tm_hierarchy_default_set,
14338 		(void *)&cmd_set_port_tm_hierarchy_default_port,
14339 		(void *)&cmd_set_port_tm_hierarchy_default_tm,
14340 		(void *)&cmd_set_port_tm_hierarchy_default_hierarchy,
14341 		(void *)&cmd_set_port_tm_hierarchy_default_default,
14342 		(void *)&cmd_set_port_tm_hierarchy_default_port_id,
14343 		NULL,
14344 	},
14345 };
14346 #endif
14347 
14348 /* Strict link priority scheduling mode setting */
14349 static void
14350 cmd_strict_link_prio_parsed(
14351 	void *parsed_result,
14352 	__attribute__((unused)) struct cmdline *cl,
14353 	__attribute__((unused)) void *data)
14354 {
14355 	struct cmd_vf_tc_bw_result *res = parsed_result;
14356 	int ret = -ENOTSUP;
14357 
14358 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14359 		return;
14360 
14361 #ifdef RTE_LIBRTE_I40E_PMD
14362 	ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
14363 #endif
14364 
14365 	switch (ret) {
14366 	case 0:
14367 		break;
14368 	case -EINVAL:
14369 		printf("invalid tc_bitmap 0x%x\n", res->tc_map);
14370 		break;
14371 	case -ENODEV:
14372 		printf("invalid port_id %d\n", res->port_id);
14373 		break;
14374 	case -ENOTSUP:
14375 		printf("function not implemented\n");
14376 		break;
14377 	default:
14378 		printf("programming error: (%s)\n", strerror(-ret));
14379 	}
14380 }
14381 
14382 cmdline_parse_inst_t cmd_strict_link_prio = {
14383 	.f = cmd_strict_link_prio_parsed,
14384 	.data = NULL,
14385 	.help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
14386 	.tokens = {
14387 		(void *)&cmd_vf_tc_bw_set,
14388 		(void *)&cmd_vf_tc_bw_tx,
14389 		(void *)&cmd_vf_tc_bw_strict_link_prio,
14390 		(void *)&cmd_vf_tc_bw_port_id,
14391 		(void *)&cmd_vf_tc_bw_tc_map,
14392 		NULL,
14393 	},
14394 };
14395 
14396 /* Load dynamic device personalization*/
14397 struct cmd_ddp_add_result {
14398 	cmdline_fixed_string_t ddp;
14399 	cmdline_fixed_string_t add;
14400 	portid_t port_id;
14401 	char filepath[];
14402 };
14403 
14404 cmdline_parse_token_string_t cmd_ddp_add_ddp =
14405 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
14406 cmdline_parse_token_string_t cmd_ddp_add_add =
14407 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
14408 cmdline_parse_token_num_t cmd_ddp_add_port_id =
14409 	TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
14410 cmdline_parse_token_string_t cmd_ddp_add_filepath =
14411 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
14412 
14413 static void
14414 cmd_ddp_add_parsed(
14415 	void *parsed_result,
14416 	__attribute__((unused)) struct cmdline *cl,
14417 	__attribute__((unused)) void *data)
14418 {
14419 	struct cmd_ddp_add_result *res = parsed_result;
14420 	uint8_t *buff;
14421 	uint32_t size;
14422 	char *filepath;
14423 	char *file_fld[2];
14424 	int file_num;
14425 	int ret = -ENOTSUP;
14426 
14427 	if (res->port_id > nb_ports) {
14428 		printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
14429 		return;
14430 	}
14431 
14432 	if (!all_ports_stopped()) {
14433 		printf("Please stop all ports first\n");
14434 		return;
14435 	}
14436 
14437 	filepath = strdup(res->filepath);
14438 	if (filepath == NULL) {
14439 		printf("Failed to allocate memory\n");
14440 		return;
14441 	}
14442 	file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
14443 
14444 	buff = open_file(file_fld[0], &size);
14445 	if (!buff) {
14446 		free((void *)filepath);
14447 		return;
14448 	}
14449 
14450 #ifdef RTE_LIBRTE_I40E_PMD
14451 	if (ret == -ENOTSUP)
14452 		ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14453 					       buff, size,
14454 					       RTE_PMD_I40E_PKG_OP_WR_ADD);
14455 #endif
14456 
14457 	if (ret == -EEXIST)
14458 		printf("Profile has already existed.\n");
14459 	else if (ret < 0)
14460 		printf("Failed to load profile.\n");
14461 	else if (file_num == 2)
14462 		save_file(file_fld[1], buff, size);
14463 
14464 	close_file(buff);
14465 	free((void *)filepath);
14466 }
14467 
14468 cmdline_parse_inst_t cmd_ddp_add = {
14469 	.f = cmd_ddp_add_parsed,
14470 	.data = NULL,
14471 	.help_str = "ddp add <port_id> <profile_path[,output_path]>",
14472 	.tokens = {
14473 		(void *)&cmd_ddp_add_ddp,
14474 		(void *)&cmd_ddp_add_add,
14475 		(void *)&cmd_ddp_add_port_id,
14476 		(void *)&cmd_ddp_add_filepath,
14477 		NULL,
14478 	},
14479 };
14480 
14481 /* Delete dynamic device personalization*/
14482 struct cmd_ddp_del_result {
14483 	cmdline_fixed_string_t ddp;
14484 	cmdline_fixed_string_t del;
14485 	portid_t port_id;
14486 	char filepath[];
14487 };
14488 
14489 cmdline_parse_token_string_t cmd_ddp_del_ddp =
14490 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
14491 cmdline_parse_token_string_t cmd_ddp_del_del =
14492 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
14493 cmdline_parse_token_num_t cmd_ddp_del_port_id =
14494 	TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
14495 cmdline_parse_token_string_t cmd_ddp_del_filepath =
14496 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
14497 
14498 static void
14499 cmd_ddp_del_parsed(
14500 	void *parsed_result,
14501 	__attribute__((unused)) struct cmdline *cl,
14502 	__attribute__((unused)) void *data)
14503 {
14504 	struct cmd_ddp_del_result *res = parsed_result;
14505 	uint8_t *buff;
14506 	uint32_t size;
14507 	int ret = -ENOTSUP;
14508 
14509 	if (res->port_id > nb_ports) {
14510 		printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
14511 		return;
14512 	}
14513 
14514 	if (!all_ports_stopped()) {
14515 		printf("Please stop all ports first\n");
14516 		return;
14517 	}
14518 
14519 	buff = open_file(res->filepath, &size);
14520 	if (!buff)
14521 		return;
14522 
14523 #ifdef RTE_LIBRTE_I40E_PMD
14524 	if (ret == -ENOTSUP)
14525 		ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14526 					       buff, size,
14527 					       RTE_PMD_I40E_PKG_OP_WR_DEL);
14528 #endif
14529 
14530 	if (ret == -EACCES)
14531 		printf("Profile does not exist.\n");
14532 	else if (ret < 0)
14533 		printf("Failed to delete profile.\n");
14534 
14535 	close_file(buff);
14536 }
14537 
14538 cmdline_parse_inst_t cmd_ddp_del = {
14539 	.f = cmd_ddp_del_parsed,
14540 	.data = NULL,
14541 	.help_str = "ddp del <port_id> <profile_path>",
14542 	.tokens = {
14543 		(void *)&cmd_ddp_del_ddp,
14544 		(void *)&cmd_ddp_del_del,
14545 		(void *)&cmd_ddp_del_port_id,
14546 		(void *)&cmd_ddp_del_filepath,
14547 		NULL,
14548 	},
14549 };
14550 
14551 /* Get dynamic device personalization profile info */
14552 struct cmd_ddp_info_result {
14553 	cmdline_fixed_string_t ddp;
14554 	cmdline_fixed_string_t get;
14555 	cmdline_fixed_string_t info;
14556 	char filepath[];
14557 };
14558 
14559 cmdline_parse_token_string_t cmd_ddp_info_ddp =
14560 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
14561 cmdline_parse_token_string_t cmd_ddp_info_get =
14562 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
14563 cmdline_parse_token_string_t cmd_ddp_info_info =
14564 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
14565 cmdline_parse_token_string_t cmd_ddp_info_filepath =
14566 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
14567 
14568 static void
14569 cmd_ddp_info_parsed(
14570 	void *parsed_result,
14571 	__attribute__((unused)) struct cmdline *cl,
14572 	__attribute__((unused)) void *data)
14573 {
14574 	struct cmd_ddp_info_result *res = parsed_result;
14575 	uint8_t *pkg;
14576 	uint32_t pkg_size;
14577 	int ret = -ENOTSUP;
14578 #ifdef RTE_LIBRTE_I40E_PMD
14579 	uint32_t i, j, n;
14580 	uint8_t *buff;
14581 	uint32_t buff_size = 0;
14582 	struct rte_pmd_i40e_profile_info info;
14583 	uint32_t dev_num = 0;
14584 	struct rte_pmd_i40e_ddp_device_id *devs;
14585 	uint32_t proto_num = 0;
14586 	struct rte_pmd_i40e_proto_info *proto = NULL;
14587 	uint32_t pctype_num = 0;
14588 	struct rte_pmd_i40e_ptype_info *pctype;
14589 	uint32_t ptype_num = 0;
14590 	struct rte_pmd_i40e_ptype_info *ptype;
14591 	uint8_t proto_id;
14592 
14593 #endif
14594 
14595 	pkg = open_file(res->filepath, &pkg_size);
14596 	if (!pkg)
14597 		return;
14598 
14599 #ifdef RTE_LIBRTE_I40E_PMD
14600 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14601 				(uint8_t *)&info, sizeof(info),
14602 				RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
14603 	if (!ret) {
14604 		printf("Global Track id:       0x%x\n", info.track_id);
14605 		printf("Global Version:        %d.%d.%d.%d\n",
14606 			info.version.major,
14607 			info.version.minor,
14608 			info.version.update,
14609 			info.version.draft);
14610 		printf("Global Package name:   %s\n\n", info.name);
14611 	}
14612 
14613 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14614 				(uint8_t *)&info, sizeof(info),
14615 				RTE_PMD_I40E_PKG_INFO_HEADER);
14616 	if (!ret) {
14617 		printf("i40e Profile Track id: 0x%x\n", info.track_id);
14618 		printf("i40e Profile Version:  %d.%d.%d.%d\n",
14619 			info.version.major,
14620 			info.version.minor,
14621 			info.version.update,
14622 			info.version.draft);
14623 		printf("i40e Profile name:     %s\n\n", info.name);
14624 	}
14625 
14626 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14627 				(uint8_t *)&buff_size, sizeof(buff_size),
14628 				RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
14629 	if (!ret && buff_size) {
14630 		buff = (uint8_t *)malloc(buff_size);
14631 		if (buff) {
14632 			ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14633 						buff, buff_size,
14634 						RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
14635 			if (!ret)
14636 				printf("Package Notes:\n%s\n\n", buff);
14637 			free(buff);
14638 		}
14639 	}
14640 
14641 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14642 				(uint8_t *)&dev_num, sizeof(dev_num),
14643 				RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
14644 	if (!ret && dev_num) {
14645 		buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
14646 		devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
14647 		if (devs) {
14648 			ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14649 						(uint8_t *)devs, buff_size,
14650 						RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
14651 			if (!ret) {
14652 				printf("List of supported devices:\n");
14653 				for (i = 0; i < dev_num; i++) {
14654 					printf("  %04X:%04X %04X:%04X\n",
14655 						devs[i].vendor_dev_id >> 16,
14656 						devs[i].vendor_dev_id & 0xFFFF,
14657 						devs[i].sub_vendor_dev_id >> 16,
14658 						devs[i].sub_vendor_dev_id & 0xFFFF);
14659 				}
14660 				printf("\n");
14661 			}
14662 			free(devs);
14663 		}
14664 	}
14665 
14666 	/* get information about protocols and packet types */
14667 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14668 		(uint8_t *)&proto_num, sizeof(proto_num),
14669 		RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
14670 	if (ret || !proto_num)
14671 		goto no_print_return;
14672 
14673 	buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
14674 	proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
14675 	if (!proto)
14676 		goto no_print_return;
14677 
14678 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
14679 					buff_size,
14680 					RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
14681 	if (!ret) {
14682 		printf("List of used protocols:\n");
14683 		for (i = 0; i < proto_num; i++)
14684 			printf("  %2u: %s\n", proto[i].proto_id,
14685 			       proto[i].name);
14686 		printf("\n");
14687 	}
14688 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14689 		(uint8_t *)&pctype_num, sizeof(pctype_num),
14690 		RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
14691 	if (ret || !pctype_num)
14692 		goto no_print_pctypes;
14693 
14694 	buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14695 	pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14696 	if (!pctype)
14697 		goto no_print_pctypes;
14698 
14699 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
14700 					buff_size,
14701 					RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
14702 	if (ret) {
14703 		free(pctype);
14704 		goto no_print_pctypes;
14705 	}
14706 
14707 	printf("List of defined packet classification types:\n");
14708 	for (i = 0; i < pctype_num; i++) {
14709 		printf("  %2u:", pctype[i].ptype_id);
14710 		for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14711 			proto_id = pctype[i].protocols[j];
14712 			if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14713 				for (n = 0; n < proto_num; n++) {
14714 					if (proto[n].proto_id == proto_id) {
14715 						printf(" %s", proto[n].name);
14716 						break;
14717 					}
14718 				}
14719 			}
14720 		}
14721 		printf("\n");
14722 	}
14723 	printf("\n");
14724 	free(pctype);
14725 
14726 no_print_pctypes:
14727 
14728 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
14729 					sizeof(ptype_num),
14730 					RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
14731 	if (ret || !ptype_num)
14732 		goto no_print_return;
14733 
14734 	buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14735 	ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14736 	if (!ptype)
14737 		goto no_print_return;
14738 
14739 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
14740 					buff_size,
14741 					RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
14742 	if (ret) {
14743 		free(ptype);
14744 		goto no_print_return;
14745 	}
14746 	printf("List of defined packet types:\n");
14747 	for (i = 0; i < ptype_num; i++) {
14748 		printf("  %2u:", ptype[i].ptype_id);
14749 		for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14750 			proto_id = ptype[i].protocols[j];
14751 			if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14752 				for (n = 0; n < proto_num; n++) {
14753 					if (proto[n].proto_id == proto_id) {
14754 						printf(" %s", proto[n].name);
14755 						break;
14756 					}
14757 				}
14758 			}
14759 		}
14760 		printf("\n");
14761 	}
14762 	free(ptype);
14763 	printf("\n");
14764 
14765 	ret = 0;
14766 no_print_return:
14767 	if (proto)
14768 		free(proto);
14769 #endif
14770 	if (ret == -ENOTSUP)
14771 		printf("Function not supported in PMD driver\n");
14772 	close_file(pkg);
14773 }
14774 
14775 cmdline_parse_inst_t cmd_ddp_get_info = {
14776 	.f = cmd_ddp_info_parsed,
14777 	.data = NULL,
14778 	.help_str = "ddp get info <profile_path>",
14779 	.tokens = {
14780 		(void *)&cmd_ddp_info_ddp,
14781 		(void *)&cmd_ddp_info_get,
14782 		(void *)&cmd_ddp_info_info,
14783 		(void *)&cmd_ddp_info_filepath,
14784 		NULL,
14785 	},
14786 };
14787 
14788 /* Get dynamic device personalization profile info list*/
14789 #define PROFILE_INFO_SIZE 48
14790 #define MAX_PROFILE_NUM 16
14791 
14792 struct cmd_ddp_get_list_result {
14793 	cmdline_fixed_string_t ddp;
14794 	cmdline_fixed_string_t get;
14795 	cmdline_fixed_string_t list;
14796 	portid_t port_id;
14797 };
14798 
14799 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
14800 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
14801 cmdline_parse_token_string_t cmd_ddp_get_list_get =
14802 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
14803 cmdline_parse_token_string_t cmd_ddp_get_list_list =
14804 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
14805 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
14806 	TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
14807 
14808 static void
14809 cmd_ddp_get_list_parsed(
14810 	void *parsed_result,
14811 	__attribute__((unused)) struct cmdline *cl,
14812 	__attribute__((unused)) void *data)
14813 {
14814 	struct cmd_ddp_get_list_result *res = parsed_result;
14815 #ifdef RTE_LIBRTE_I40E_PMD
14816 	struct rte_pmd_i40e_profile_list *p_list;
14817 	struct rte_pmd_i40e_profile_info *p_info;
14818 	uint32_t p_num;
14819 	uint32_t size;
14820 	uint32_t i;
14821 #endif
14822 	int ret = -ENOTSUP;
14823 
14824 	if (res->port_id > nb_ports) {
14825 		printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
14826 		return;
14827 	}
14828 
14829 #ifdef RTE_LIBRTE_I40E_PMD
14830 	size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
14831 	p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
14832 	if (!p_list)
14833 		printf("%s: Failed to malloc buffer\n", __func__);
14834 
14835 	if (ret == -ENOTSUP)
14836 		ret = rte_pmd_i40e_get_ddp_list(res->port_id,
14837 						(uint8_t *)p_list, size);
14838 
14839 	if (!ret) {
14840 		p_num = p_list->p_count;
14841 		printf("Profile number is: %d\n\n", p_num);
14842 
14843 		for (i = 0; i < p_num; i++) {
14844 			p_info = &p_list->p_info[i];
14845 			printf("Profile %d:\n", i);
14846 			printf("Track id:     0x%x\n", p_info->track_id);
14847 			printf("Version:      %d.%d.%d.%d\n",
14848 			       p_info->version.major,
14849 			       p_info->version.minor,
14850 			       p_info->version.update,
14851 			       p_info->version.draft);
14852 			printf("Profile name: %s\n\n", p_info->name);
14853 		}
14854 	}
14855 
14856 	free(p_list);
14857 #endif
14858 
14859 	if (ret < 0)
14860 		printf("Failed to get ddp list\n");
14861 }
14862 
14863 cmdline_parse_inst_t cmd_ddp_get_list = {
14864 	.f = cmd_ddp_get_list_parsed,
14865 	.data = NULL,
14866 	.help_str = "ddp get list <port_id>",
14867 	.tokens = {
14868 		(void *)&cmd_ddp_get_list_ddp,
14869 		(void *)&cmd_ddp_get_list_get,
14870 		(void *)&cmd_ddp_get_list_list,
14871 		(void *)&cmd_ddp_get_list_port_id,
14872 		NULL,
14873 	},
14874 };
14875 
14876 /* show vf stats */
14877 
14878 /* Common result structure for show vf stats */
14879 struct cmd_show_vf_stats_result {
14880 	cmdline_fixed_string_t show;
14881 	cmdline_fixed_string_t vf;
14882 	cmdline_fixed_string_t stats;
14883 	portid_t port_id;
14884 	uint16_t vf_id;
14885 };
14886 
14887 /* Common CLI fields show vf stats*/
14888 cmdline_parse_token_string_t cmd_show_vf_stats_show =
14889 	TOKEN_STRING_INITIALIZER
14890 		(struct cmd_show_vf_stats_result,
14891 		 show, "show");
14892 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
14893 	TOKEN_STRING_INITIALIZER
14894 		(struct cmd_show_vf_stats_result,
14895 		 vf, "vf");
14896 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
14897 	TOKEN_STRING_INITIALIZER
14898 		(struct cmd_show_vf_stats_result,
14899 		 stats, "stats");
14900 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
14901 	TOKEN_NUM_INITIALIZER
14902 		(struct cmd_show_vf_stats_result,
14903 		 port_id, UINT16);
14904 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
14905 	TOKEN_NUM_INITIALIZER
14906 		(struct cmd_show_vf_stats_result,
14907 		 vf_id, UINT16);
14908 
14909 static void
14910 cmd_show_vf_stats_parsed(
14911 	void *parsed_result,
14912 	__attribute__((unused)) struct cmdline *cl,
14913 	__attribute__((unused)) void *data)
14914 {
14915 	struct cmd_show_vf_stats_result *res = parsed_result;
14916 	struct rte_eth_stats stats;
14917 	int ret = -ENOTSUP;
14918 	static const char *nic_stats_border = "########################";
14919 
14920 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14921 		return;
14922 
14923 	memset(&stats, 0, sizeof(stats));
14924 
14925 #ifdef RTE_LIBRTE_I40E_PMD
14926 	if (ret == -ENOTSUP)
14927 		ret = rte_pmd_i40e_get_vf_stats(res->port_id,
14928 						res->vf_id,
14929 						&stats);
14930 #endif
14931 #ifdef RTE_LIBRTE_BNXT_PMD
14932 	if (ret == -ENOTSUP)
14933 		ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
14934 						res->vf_id,
14935 						&stats);
14936 #endif
14937 
14938 	switch (ret) {
14939 	case 0:
14940 		break;
14941 	case -EINVAL:
14942 		printf("invalid vf_id %d\n", res->vf_id);
14943 		break;
14944 	case -ENODEV:
14945 		printf("invalid port_id %d\n", res->port_id);
14946 		break;
14947 	case -ENOTSUP:
14948 		printf("function not implemented\n");
14949 		break;
14950 	default:
14951 		printf("programming error: (%s)\n", strerror(-ret));
14952 	}
14953 
14954 	printf("\n  %s NIC statistics for port %-2d vf %-2d %s\n",
14955 		nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
14956 
14957 	printf("  RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes:  "
14958 	       "%-"PRIu64"\n",
14959 	       stats.ipackets, stats.imissed, stats.ibytes);
14960 	printf("  RX-errors: %-"PRIu64"\n", stats.ierrors);
14961 	printf("  RX-nombuf:  %-10"PRIu64"\n",
14962 	       stats.rx_nombuf);
14963 	printf("  TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes:  "
14964 	       "%-"PRIu64"\n",
14965 	       stats.opackets, stats.oerrors, stats.obytes);
14966 
14967 	printf("  %s############################%s\n",
14968 			       nic_stats_border, nic_stats_border);
14969 }
14970 
14971 cmdline_parse_inst_t cmd_show_vf_stats = {
14972 	.f = cmd_show_vf_stats_parsed,
14973 	.data = NULL,
14974 	.help_str = "show vf stats <port_id> <vf_id>",
14975 	.tokens = {
14976 		(void *)&cmd_show_vf_stats_show,
14977 		(void *)&cmd_show_vf_stats_vf,
14978 		(void *)&cmd_show_vf_stats_stats,
14979 		(void *)&cmd_show_vf_stats_port_id,
14980 		(void *)&cmd_show_vf_stats_vf_id,
14981 		NULL,
14982 	},
14983 };
14984 
14985 /* clear vf stats */
14986 
14987 /* Common result structure for clear vf stats */
14988 struct cmd_clear_vf_stats_result {
14989 	cmdline_fixed_string_t clear;
14990 	cmdline_fixed_string_t vf;
14991 	cmdline_fixed_string_t stats;
14992 	portid_t port_id;
14993 	uint16_t vf_id;
14994 };
14995 
14996 /* Common CLI fields clear vf stats*/
14997 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
14998 	TOKEN_STRING_INITIALIZER
14999 		(struct cmd_clear_vf_stats_result,
15000 		 clear, "clear");
15001 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
15002 	TOKEN_STRING_INITIALIZER
15003 		(struct cmd_clear_vf_stats_result,
15004 		 vf, "vf");
15005 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
15006 	TOKEN_STRING_INITIALIZER
15007 		(struct cmd_clear_vf_stats_result,
15008 		 stats, "stats");
15009 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
15010 	TOKEN_NUM_INITIALIZER
15011 		(struct cmd_clear_vf_stats_result,
15012 		 port_id, UINT16);
15013 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
15014 	TOKEN_NUM_INITIALIZER
15015 		(struct cmd_clear_vf_stats_result,
15016 		 vf_id, UINT16);
15017 
15018 static void
15019 cmd_clear_vf_stats_parsed(
15020 	void *parsed_result,
15021 	__attribute__((unused)) struct cmdline *cl,
15022 	__attribute__((unused)) void *data)
15023 {
15024 	struct cmd_clear_vf_stats_result *res = parsed_result;
15025 	int ret = -ENOTSUP;
15026 
15027 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15028 		return;
15029 
15030 #ifdef RTE_LIBRTE_I40E_PMD
15031 	if (ret == -ENOTSUP)
15032 		ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
15033 						  res->vf_id);
15034 #endif
15035 #ifdef RTE_LIBRTE_BNXT_PMD
15036 	if (ret == -ENOTSUP)
15037 		ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
15038 						  res->vf_id);
15039 #endif
15040 
15041 	switch (ret) {
15042 	case 0:
15043 		break;
15044 	case -EINVAL:
15045 		printf("invalid vf_id %d\n", res->vf_id);
15046 		break;
15047 	case -ENODEV:
15048 		printf("invalid port_id %d\n", res->port_id);
15049 		break;
15050 	case -ENOTSUP:
15051 		printf("function not implemented\n");
15052 		break;
15053 	default:
15054 		printf("programming error: (%s)\n", strerror(-ret));
15055 	}
15056 }
15057 
15058 cmdline_parse_inst_t cmd_clear_vf_stats = {
15059 	.f = cmd_clear_vf_stats_parsed,
15060 	.data = NULL,
15061 	.help_str = "clear vf stats <port_id> <vf_id>",
15062 	.tokens = {
15063 		(void *)&cmd_clear_vf_stats_clear,
15064 		(void *)&cmd_clear_vf_stats_vf,
15065 		(void *)&cmd_clear_vf_stats_stats,
15066 		(void *)&cmd_clear_vf_stats_port_id,
15067 		(void *)&cmd_clear_vf_stats_vf_id,
15068 		NULL,
15069 	},
15070 };
15071 
15072 /* port config pctype mapping reset */
15073 
15074 /* Common result structure for port config pctype mapping reset */
15075 struct cmd_pctype_mapping_reset_result {
15076 	cmdline_fixed_string_t port;
15077 	cmdline_fixed_string_t config;
15078 	portid_t port_id;
15079 	cmdline_fixed_string_t pctype;
15080 	cmdline_fixed_string_t mapping;
15081 	cmdline_fixed_string_t reset;
15082 };
15083 
15084 /* Common CLI fields for port config pctype mapping reset*/
15085 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
15086 	TOKEN_STRING_INITIALIZER
15087 		(struct cmd_pctype_mapping_reset_result,
15088 		 port, "port");
15089 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
15090 	TOKEN_STRING_INITIALIZER
15091 		(struct cmd_pctype_mapping_reset_result,
15092 		 config, "config");
15093 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
15094 	TOKEN_NUM_INITIALIZER
15095 		(struct cmd_pctype_mapping_reset_result,
15096 		 port_id, UINT16);
15097 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
15098 	TOKEN_STRING_INITIALIZER
15099 		(struct cmd_pctype_mapping_reset_result,
15100 		 pctype, "pctype");
15101 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
15102 	TOKEN_STRING_INITIALIZER
15103 		(struct cmd_pctype_mapping_reset_result,
15104 		 mapping, "mapping");
15105 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
15106 	TOKEN_STRING_INITIALIZER
15107 		(struct cmd_pctype_mapping_reset_result,
15108 		 reset, "reset");
15109 
15110 static void
15111 cmd_pctype_mapping_reset_parsed(
15112 	void *parsed_result,
15113 	__attribute__((unused)) struct cmdline *cl,
15114 	__attribute__((unused)) void *data)
15115 {
15116 	struct cmd_pctype_mapping_reset_result *res = parsed_result;
15117 	int ret = -ENOTSUP;
15118 
15119 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15120 		return;
15121 
15122 #ifdef RTE_LIBRTE_I40E_PMD
15123 	ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
15124 #endif
15125 
15126 	switch (ret) {
15127 	case 0:
15128 		break;
15129 	case -ENODEV:
15130 		printf("invalid port_id %d\n", res->port_id);
15131 		break;
15132 	case -ENOTSUP:
15133 		printf("function not implemented\n");
15134 		break;
15135 	default:
15136 		printf("programming error: (%s)\n", strerror(-ret));
15137 	}
15138 }
15139 
15140 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
15141 	.f = cmd_pctype_mapping_reset_parsed,
15142 	.data = NULL,
15143 	.help_str = "port config <port_id> pctype mapping reset",
15144 	.tokens = {
15145 		(void *)&cmd_pctype_mapping_reset_port,
15146 		(void *)&cmd_pctype_mapping_reset_config,
15147 		(void *)&cmd_pctype_mapping_reset_port_id,
15148 		(void *)&cmd_pctype_mapping_reset_pctype,
15149 		(void *)&cmd_pctype_mapping_reset_mapping,
15150 		(void *)&cmd_pctype_mapping_reset_reset,
15151 		NULL,
15152 	},
15153 };
15154 
15155 /* show port pctype mapping */
15156 
15157 /* Common result structure for show port pctype mapping */
15158 struct cmd_pctype_mapping_get_result {
15159 	cmdline_fixed_string_t show;
15160 	cmdline_fixed_string_t port;
15161 	portid_t port_id;
15162 	cmdline_fixed_string_t pctype;
15163 	cmdline_fixed_string_t mapping;
15164 };
15165 
15166 /* Common CLI fields for pctype mapping get */
15167 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
15168 	TOKEN_STRING_INITIALIZER
15169 		(struct cmd_pctype_mapping_get_result,
15170 		 show, "show");
15171 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
15172 	TOKEN_STRING_INITIALIZER
15173 		(struct cmd_pctype_mapping_get_result,
15174 		 port, "port");
15175 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
15176 	TOKEN_NUM_INITIALIZER
15177 		(struct cmd_pctype_mapping_get_result,
15178 		 port_id, UINT16);
15179 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
15180 	TOKEN_STRING_INITIALIZER
15181 		(struct cmd_pctype_mapping_get_result,
15182 		 pctype, "pctype");
15183 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
15184 	TOKEN_STRING_INITIALIZER
15185 		(struct cmd_pctype_mapping_get_result,
15186 		 mapping, "mapping");
15187 
15188 static void
15189 cmd_pctype_mapping_get_parsed(
15190 	void *parsed_result,
15191 	__attribute__((unused)) struct cmdline *cl,
15192 	__attribute__((unused)) void *data)
15193 {
15194 	struct cmd_pctype_mapping_get_result *res = parsed_result;
15195 	int ret = -ENOTSUP;
15196 #ifdef RTE_LIBRTE_I40E_PMD
15197 	struct rte_pmd_i40e_flow_type_mapping
15198 				mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
15199 	int i, j, first_pctype;
15200 #endif
15201 
15202 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15203 		return;
15204 
15205 #ifdef RTE_LIBRTE_I40E_PMD
15206 	ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
15207 #endif
15208 
15209 	switch (ret) {
15210 	case 0:
15211 		break;
15212 	case -ENODEV:
15213 		printf("invalid port_id %d\n", res->port_id);
15214 		return;
15215 	case -ENOTSUP:
15216 		printf("function not implemented\n");
15217 		return;
15218 	default:
15219 		printf("programming error: (%s)\n", strerror(-ret));
15220 		return;
15221 	}
15222 
15223 #ifdef RTE_LIBRTE_I40E_PMD
15224 	for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
15225 		if (mapping[i].pctype != 0ULL) {
15226 			first_pctype = 1;
15227 
15228 			printf("pctype: ");
15229 			for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
15230 				if (mapping[i].pctype & (1ULL << j)) {
15231 					printf(first_pctype ?
15232 					       "%02d" : ",%02d", j);
15233 					first_pctype = 0;
15234 				}
15235 			}
15236 			printf("  ->  flowtype: %02d\n", mapping[i].flow_type);
15237 		}
15238 	}
15239 #endif
15240 }
15241 
15242 cmdline_parse_inst_t cmd_pctype_mapping_get = {
15243 	.f = cmd_pctype_mapping_get_parsed,
15244 	.data = NULL,
15245 	.help_str = "show port <port_id> pctype mapping",
15246 	.tokens = {
15247 		(void *)&cmd_pctype_mapping_get_show,
15248 		(void *)&cmd_pctype_mapping_get_port,
15249 		(void *)&cmd_pctype_mapping_get_port_id,
15250 		(void *)&cmd_pctype_mapping_get_pctype,
15251 		(void *)&cmd_pctype_mapping_get_mapping,
15252 		NULL,
15253 	},
15254 };
15255 
15256 /* port config pctype mapping update */
15257 
15258 /* Common result structure for port config pctype mapping update */
15259 struct cmd_pctype_mapping_update_result {
15260 	cmdline_fixed_string_t port;
15261 	cmdline_fixed_string_t config;
15262 	portid_t port_id;
15263 	cmdline_fixed_string_t pctype;
15264 	cmdline_fixed_string_t mapping;
15265 	cmdline_fixed_string_t update;
15266 	cmdline_fixed_string_t pctype_list;
15267 	uint16_t flow_type;
15268 };
15269 
15270 /* Common CLI fields for pctype mapping update*/
15271 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
15272 	TOKEN_STRING_INITIALIZER
15273 		(struct cmd_pctype_mapping_update_result,
15274 		 port, "port");
15275 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
15276 	TOKEN_STRING_INITIALIZER
15277 		(struct cmd_pctype_mapping_update_result,
15278 		 config, "config");
15279 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
15280 	TOKEN_NUM_INITIALIZER
15281 		(struct cmd_pctype_mapping_update_result,
15282 		 port_id, UINT16);
15283 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
15284 	TOKEN_STRING_INITIALIZER
15285 		(struct cmd_pctype_mapping_update_result,
15286 		 pctype, "pctype");
15287 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
15288 	TOKEN_STRING_INITIALIZER
15289 		(struct cmd_pctype_mapping_update_result,
15290 		 mapping, "mapping");
15291 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
15292 	TOKEN_STRING_INITIALIZER
15293 		(struct cmd_pctype_mapping_update_result,
15294 		 update, "update");
15295 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
15296 	TOKEN_STRING_INITIALIZER
15297 		(struct cmd_pctype_mapping_update_result,
15298 		 pctype_list, NULL);
15299 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
15300 	TOKEN_NUM_INITIALIZER
15301 		(struct cmd_pctype_mapping_update_result,
15302 		 flow_type, UINT16);
15303 
15304 static void
15305 cmd_pctype_mapping_update_parsed(
15306 	void *parsed_result,
15307 	__attribute__((unused)) struct cmdline *cl,
15308 	__attribute__((unused)) void *data)
15309 {
15310 	struct cmd_pctype_mapping_update_result *res = parsed_result;
15311 	int ret = -ENOTSUP;
15312 #ifdef RTE_LIBRTE_I40E_PMD
15313 	struct rte_pmd_i40e_flow_type_mapping mapping;
15314 	unsigned int i;
15315 	unsigned int nb_item;
15316 	unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
15317 #endif
15318 
15319 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15320 		return;
15321 
15322 #ifdef RTE_LIBRTE_I40E_PMD
15323 	nb_item = parse_item_list(res->pctype_list, "pctypes",
15324 				  RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
15325 	mapping.flow_type = res->flow_type;
15326 	for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
15327 		mapping.pctype |= (1ULL << pctype_list[i]);
15328 	ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
15329 						&mapping,
15330 						1,
15331 						0);
15332 #endif
15333 
15334 	switch (ret) {
15335 	case 0:
15336 		break;
15337 	case -EINVAL:
15338 		printf("invalid pctype or flow type\n");
15339 		break;
15340 	case -ENODEV:
15341 		printf("invalid port_id %d\n", res->port_id);
15342 		break;
15343 	case -ENOTSUP:
15344 		printf("function not implemented\n");
15345 		break;
15346 	default:
15347 		printf("programming error: (%s)\n", strerror(-ret));
15348 	}
15349 }
15350 
15351 cmdline_parse_inst_t cmd_pctype_mapping_update = {
15352 	.f = cmd_pctype_mapping_update_parsed,
15353 	.data = NULL,
15354 	.help_str = "port config <port_id> pctype mapping update"
15355 	" <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
15356 	.tokens = {
15357 		(void *)&cmd_pctype_mapping_update_port,
15358 		(void *)&cmd_pctype_mapping_update_config,
15359 		(void *)&cmd_pctype_mapping_update_port_id,
15360 		(void *)&cmd_pctype_mapping_update_pctype,
15361 		(void *)&cmd_pctype_mapping_update_mapping,
15362 		(void *)&cmd_pctype_mapping_update_update,
15363 		(void *)&cmd_pctype_mapping_update_pc_type,
15364 		(void *)&cmd_pctype_mapping_update_flow_type,
15365 		NULL,
15366 	},
15367 };
15368 
15369 /* ptype mapping get */
15370 
15371 /* Common result structure for ptype mapping get */
15372 struct cmd_ptype_mapping_get_result {
15373 	cmdline_fixed_string_t ptype;
15374 	cmdline_fixed_string_t mapping;
15375 	cmdline_fixed_string_t get;
15376 	portid_t port_id;
15377 	uint8_t valid_only;
15378 };
15379 
15380 /* Common CLI fields for ptype mapping get */
15381 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
15382 	TOKEN_STRING_INITIALIZER
15383 		(struct cmd_ptype_mapping_get_result,
15384 		 ptype, "ptype");
15385 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
15386 	TOKEN_STRING_INITIALIZER
15387 		(struct cmd_ptype_mapping_get_result,
15388 		 mapping, "mapping");
15389 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
15390 	TOKEN_STRING_INITIALIZER
15391 		(struct cmd_ptype_mapping_get_result,
15392 		 get, "get");
15393 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
15394 	TOKEN_NUM_INITIALIZER
15395 		(struct cmd_ptype_mapping_get_result,
15396 		 port_id, UINT16);
15397 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
15398 	TOKEN_NUM_INITIALIZER
15399 		(struct cmd_ptype_mapping_get_result,
15400 		 valid_only, UINT8);
15401 
15402 static void
15403 cmd_ptype_mapping_get_parsed(
15404 	void *parsed_result,
15405 	__attribute__((unused)) struct cmdline *cl,
15406 	__attribute__((unused)) void *data)
15407 {
15408 	struct cmd_ptype_mapping_get_result *res = parsed_result;
15409 	int ret = -ENOTSUP;
15410 #ifdef RTE_LIBRTE_I40E_PMD
15411 	int max_ptype_num = 256;
15412 	struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
15413 	uint16_t count;
15414 	int i;
15415 #endif
15416 
15417 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15418 		return;
15419 
15420 #ifdef RTE_LIBRTE_I40E_PMD
15421 	ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
15422 					mapping,
15423 					max_ptype_num,
15424 					&count,
15425 					res->valid_only);
15426 #endif
15427 
15428 	switch (ret) {
15429 	case 0:
15430 		break;
15431 	case -ENODEV:
15432 		printf("invalid port_id %d\n", res->port_id);
15433 		break;
15434 	case -ENOTSUP:
15435 		printf("function not implemented\n");
15436 		break;
15437 	default:
15438 		printf("programming error: (%s)\n", strerror(-ret));
15439 	}
15440 
15441 #ifdef RTE_LIBRTE_I40E_PMD
15442 	if (!ret) {
15443 		for (i = 0; i < count; i++)
15444 			printf("%3d\t0x%08x\n",
15445 				mapping[i].hw_ptype, mapping[i].sw_ptype);
15446 	}
15447 #endif
15448 }
15449 
15450 cmdline_parse_inst_t cmd_ptype_mapping_get = {
15451 	.f = cmd_ptype_mapping_get_parsed,
15452 	.data = NULL,
15453 	.help_str = "ptype mapping get <port_id> <valid_only>",
15454 	.tokens = {
15455 		(void *)&cmd_ptype_mapping_get_ptype,
15456 		(void *)&cmd_ptype_mapping_get_mapping,
15457 		(void *)&cmd_ptype_mapping_get_get,
15458 		(void *)&cmd_ptype_mapping_get_port_id,
15459 		(void *)&cmd_ptype_mapping_get_valid_only,
15460 		NULL,
15461 	},
15462 };
15463 
15464 /* ptype mapping replace */
15465 
15466 /* Common result structure for ptype mapping replace */
15467 struct cmd_ptype_mapping_replace_result {
15468 	cmdline_fixed_string_t ptype;
15469 	cmdline_fixed_string_t mapping;
15470 	cmdline_fixed_string_t replace;
15471 	portid_t port_id;
15472 	uint32_t target;
15473 	uint8_t mask;
15474 	uint32_t pkt_type;
15475 };
15476 
15477 /* Common CLI fields for ptype mapping replace */
15478 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
15479 	TOKEN_STRING_INITIALIZER
15480 		(struct cmd_ptype_mapping_replace_result,
15481 		 ptype, "ptype");
15482 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
15483 	TOKEN_STRING_INITIALIZER
15484 		(struct cmd_ptype_mapping_replace_result,
15485 		 mapping, "mapping");
15486 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
15487 	TOKEN_STRING_INITIALIZER
15488 		(struct cmd_ptype_mapping_replace_result,
15489 		 replace, "replace");
15490 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
15491 	TOKEN_NUM_INITIALIZER
15492 		(struct cmd_ptype_mapping_replace_result,
15493 		 port_id, UINT16);
15494 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
15495 	TOKEN_NUM_INITIALIZER
15496 		(struct cmd_ptype_mapping_replace_result,
15497 		 target, UINT32);
15498 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
15499 	TOKEN_NUM_INITIALIZER
15500 		(struct cmd_ptype_mapping_replace_result,
15501 		 mask, UINT8);
15502 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
15503 	TOKEN_NUM_INITIALIZER
15504 		(struct cmd_ptype_mapping_replace_result,
15505 		 pkt_type, UINT32);
15506 
15507 static void
15508 cmd_ptype_mapping_replace_parsed(
15509 	void *parsed_result,
15510 	__attribute__((unused)) struct cmdline *cl,
15511 	__attribute__((unused)) void *data)
15512 {
15513 	struct cmd_ptype_mapping_replace_result *res = parsed_result;
15514 	int ret = -ENOTSUP;
15515 
15516 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15517 		return;
15518 
15519 #ifdef RTE_LIBRTE_I40E_PMD
15520 	ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
15521 					res->target,
15522 					res->mask,
15523 					res->pkt_type);
15524 #endif
15525 
15526 	switch (ret) {
15527 	case 0:
15528 		break;
15529 	case -EINVAL:
15530 		printf("invalid ptype 0x%8x or 0x%8x\n",
15531 				res->target, res->pkt_type);
15532 		break;
15533 	case -ENODEV:
15534 		printf("invalid port_id %d\n", res->port_id);
15535 		break;
15536 	case -ENOTSUP:
15537 		printf("function not implemented\n");
15538 		break;
15539 	default:
15540 		printf("programming error: (%s)\n", strerror(-ret));
15541 	}
15542 }
15543 
15544 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
15545 	.f = cmd_ptype_mapping_replace_parsed,
15546 	.data = NULL,
15547 	.help_str =
15548 		"ptype mapping replace <port_id> <target> <mask> <pkt_type>",
15549 	.tokens = {
15550 		(void *)&cmd_ptype_mapping_replace_ptype,
15551 		(void *)&cmd_ptype_mapping_replace_mapping,
15552 		(void *)&cmd_ptype_mapping_replace_replace,
15553 		(void *)&cmd_ptype_mapping_replace_port_id,
15554 		(void *)&cmd_ptype_mapping_replace_target,
15555 		(void *)&cmd_ptype_mapping_replace_mask,
15556 		(void *)&cmd_ptype_mapping_replace_pkt_type,
15557 		NULL,
15558 	},
15559 };
15560 
15561 /* ptype mapping reset */
15562 
15563 /* Common result structure for ptype mapping reset */
15564 struct cmd_ptype_mapping_reset_result {
15565 	cmdline_fixed_string_t ptype;
15566 	cmdline_fixed_string_t mapping;
15567 	cmdline_fixed_string_t reset;
15568 	portid_t port_id;
15569 };
15570 
15571 /* Common CLI fields for ptype mapping reset*/
15572 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
15573 	TOKEN_STRING_INITIALIZER
15574 		(struct cmd_ptype_mapping_reset_result,
15575 		 ptype, "ptype");
15576 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
15577 	TOKEN_STRING_INITIALIZER
15578 		(struct cmd_ptype_mapping_reset_result,
15579 		 mapping, "mapping");
15580 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
15581 	TOKEN_STRING_INITIALIZER
15582 		(struct cmd_ptype_mapping_reset_result,
15583 		 reset, "reset");
15584 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
15585 	TOKEN_NUM_INITIALIZER
15586 		(struct cmd_ptype_mapping_reset_result,
15587 		 port_id, UINT16);
15588 
15589 static void
15590 cmd_ptype_mapping_reset_parsed(
15591 	void *parsed_result,
15592 	__attribute__((unused)) struct cmdline *cl,
15593 	__attribute__((unused)) void *data)
15594 {
15595 	struct cmd_ptype_mapping_reset_result *res = parsed_result;
15596 	int ret = -ENOTSUP;
15597 
15598 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15599 		return;
15600 
15601 #ifdef RTE_LIBRTE_I40E_PMD
15602 	ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
15603 #endif
15604 
15605 	switch (ret) {
15606 	case 0:
15607 		break;
15608 	case -ENODEV:
15609 		printf("invalid port_id %d\n", res->port_id);
15610 		break;
15611 	case -ENOTSUP:
15612 		printf("function not implemented\n");
15613 		break;
15614 	default:
15615 		printf("programming error: (%s)\n", strerror(-ret));
15616 	}
15617 }
15618 
15619 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
15620 	.f = cmd_ptype_mapping_reset_parsed,
15621 	.data = NULL,
15622 	.help_str = "ptype mapping reset <port_id>",
15623 	.tokens = {
15624 		(void *)&cmd_ptype_mapping_reset_ptype,
15625 		(void *)&cmd_ptype_mapping_reset_mapping,
15626 		(void *)&cmd_ptype_mapping_reset_reset,
15627 		(void *)&cmd_ptype_mapping_reset_port_id,
15628 		NULL,
15629 	},
15630 };
15631 
15632 /* ptype mapping update */
15633 
15634 /* Common result structure for ptype mapping update */
15635 struct cmd_ptype_mapping_update_result {
15636 	cmdline_fixed_string_t ptype;
15637 	cmdline_fixed_string_t mapping;
15638 	cmdline_fixed_string_t reset;
15639 	portid_t port_id;
15640 	uint8_t hw_ptype;
15641 	uint32_t sw_ptype;
15642 };
15643 
15644 /* Common CLI fields for ptype mapping update*/
15645 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
15646 	TOKEN_STRING_INITIALIZER
15647 		(struct cmd_ptype_mapping_update_result,
15648 		 ptype, "ptype");
15649 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
15650 	TOKEN_STRING_INITIALIZER
15651 		(struct cmd_ptype_mapping_update_result,
15652 		 mapping, "mapping");
15653 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
15654 	TOKEN_STRING_INITIALIZER
15655 		(struct cmd_ptype_mapping_update_result,
15656 		 reset, "update");
15657 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
15658 	TOKEN_NUM_INITIALIZER
15659 		(struct cmd_ptype_mapping_update_result,
15660 		 port_id, UINT16);
15661 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
15662 	TOKEN_NUM_INITIALIZER
15663 		(struct cmd_ptype_mapping_update_result,
15664 		 hw_ptype, UINT8);
15665 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
15666 	TOKEN_NUM_INITIALIZER
15667 		(struct cmd_ptype_mapping_update_result,
15668 		 sw_ptype, UINT32);
15669 
15670 static void
15671 cmd_ptype_mapping_update_parsed(
15672 	void *parsed_result,
15673 	__attribute__((unused)) struct cmdline *cl,
15674 	__attribute__((unused)) void *data)
15675 {
15676 	struct cmd_ptype_mapping_update_result *res = parsed_result;
15677 	int ret = -ENOTSUP;
15678 #ifdef RTE_LIBRTE_I40E_PMD
15679 	struct rte_pmd_i40e_ptype_mapping mapping;
15680 #endif
15681 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15682 		return;
15683 
15684 #ifdef RTE_LIBRTE_I40E_PMD
15685 	mapping.hw_ptype = res->hw_ptype;
15686 	mapping.sw_ptype = res->sw_ptype;
15687 	ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
15688 						&mapping,
15689 						1,
15690 						0);
15691 #endif
15692 
15693 	switch (ret) {
15694 	case 0:
15695 		break;
15696 	case -EINVAL:
15697 		printf("invalid ptype 0x%8x\n", res->sw_ptype);
15698 		break;
15699 	case -ENODEV:
15700 		printf("invalid port_id %d\n", res->port_id);
15701 		break;
15702 	case -ENOTSUP:
15703 		printf("function not implemented\n");
15704 		break;
15705 	default:
15706 		printf("programming error: (%s)\n", strerror(-ret));
15707 	}
15708 }
15709 
15710 cmdline_parse_inst_t cmd_ptype_mapping_update = {
15711 	.f = cmd_ptype_mapping_update_parsed,
15712 	.data = NULL,
15713 	.help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
15714 	.tokens = {
15715 		(void *)&cmd_ptype_mapping_update_ptype,
15716 		(void *)&cmd_ptype_mapping_update_mapping,
15717 		(void *)&cmd_ptype_mapping_update_update,
15718 		(void *)&cmd_ptype_mapping_update_port_id,
15719 		(void *)&cmd_ptype_mapping_update_hw_ptype,
15720 		(void *)&cmd_ptype_mapping_update_sw_ptype,
15721 		NULL,
15722 	},
15723 };
15724 
15725 /* Common result structure for file commands */
15726 struct cmd_cmdfile_result {
15727 	cmdline_fixed_string_t load;
15728 	cmdline_fixed_string_t filename;
15729 };
15730 
15731 /* Common CLI fields for file commands */
15732 cmdline_parse_token_string_t cmd_load_cmdfile =
15733 	TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
15734 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
15735 	TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
15736 
15737 static void
15738 cmd_load_from_file_parsed(
15739 	void *parsed_result,
15740 	__attribute__((unused)) struct cmdline *cl,
15741 	__attribute__((unused)) void *data)
15742 {
15743 	struct cmd_cmdfile_result *res = parsed_result;
15744 
15745 	cmdline_read_from_file(res->filename);
15746 }
15747 
15748 cmdline_parse_inst_t cmd_load_from_file = {
15749 	.f = cmd_load_from_file_parsed,
15750 	.data = NULL,
15751 	.help_str = "load <filename>",
15752 	.tokens = {
15753 		(void *)&cmd_load_cmdfile,
15754 		(void *)&cmd_load_cmdfile_filename,
15755 		NULL,
15756 	},
15757 };
15758 
15759 /* ******************************************************************************** */
15760 
15761 /* list of instructions */
15762 cmdline_parse_ctx_t main_ctx[] = {
15763 	(cmdline_parse_inst_t *)&cmd_help_brief,
15764 	(cmdline_parse_inst_t *)&cmd_help_long,
15765 	(cmdline_parse_inst_t *)&cmd_quit,
15766 	(cmdline_parse_inst_t *)&cmd_load_from_file,
15767 	(cmdline_parse_inst_t *)&cmd_showport,
15768 	(cmdline_parse_inst_t *)&cmd_showqueue,
15769 	(cmdline_parse_inst_t *)&cmd_showportall,
15770 	(cmdline_parse_inst_t *)&cmd_showcfg,
15771 	(cmdline_parse_inst_t *)&cmd_start,
15772 	(cmdline_parse_inst_t *)&cmd_start_tx_first,
15773 	(cmdline_parse_inst_t *)&cmd_start_tx_first_n,
15774 	(cmdline_parse_inst_t *)&cmd_set_link_up,
15775 	(cmdline_parse_inst_t *)&cmd_set_link_down,
15776 	(cmdline_parse_inst_t *)&cmd_reset,
15777 	(cmdline_parse_inst_t *)&cmd_set_numbers,
15778 	(cmdline_parse_inst_t *)&cmd_set_txpkts,
15779 	(cmdline_parse_inst_t *)&cmd_set_txsplit,
15780 	(cmdline_parse_inst_t *)&cmd_set_fwd_list,
15781 	(cmdline_parse_inst_t *)&cmd_set_fwd_mask,
15782 	(cmdline_parse_inst_t *)&cmd_set_fwd_mode,
15783 	(cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
15784 	(cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
15785 	(cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
15786 	(cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
15787 	(cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
15788 	(cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
15789 	(cmdline_parse_inst_t *)&cmd_set_flush_rx,
15790 	(cmdline_parse_inst_t *)&cmd_set_link_check,
15791 	(cmdline_parse_inst_t *)&cmd_set_bypass_mode,
15792 	(cmdline_parse_inst_t *)&cmd_set_bypass_event,
15793 	(cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
15794 	(cmdline_parse_inst_t *)&cmd_show_bypass_config,
15795 #ifdef RTE_LIBRTE_PMD_BOND
15796 	(cmdline_parse_inst_t *) &cmd_set_bonding_mode,
15797 	(cmdline_parse_inst_t *) &cmd_show_bonding_config,
15798 	(cmdline_parse_inst_t *) &cmd_set_bonding_primary,
15799 	(cmdline_parse_inst_t *) &cmd_add_bonding_slave,
15800 	(cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
15801 	(cmdline_parse_inst_t *) &cmd_create_bonded_device,
15802 	(cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
15803 	(cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
15804 	(cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
15805 	(cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
15806 	(cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
15807 #endif
15808 	(cmdline_parse_inst_t *)&cmd_vlan_offload,
15809 	(cmdline_parse_inst_t *)&cmd_vlan_tpid,
15810 	(cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
15811 	(cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
15812 	(cmdline_parse_inst_t *)&cmd_tx_vlan_set,
15813 	(cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
15814 	(cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
15815 	(cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
15816 	(cmdline_parse_inst_t *)&cmd_csum_set,
15817 	(cmdline_parse_inst_t *)&cmd_csum_show,
15818 	(cmdline_parse_inst_t *)&cmd_csum_tunnel,
15819 	(cmdline_parse_inst_t *)&cmd_tso_set,
15820 	(cmdline_parse_inst_t *)&cmd_tso_show,
15821 	(cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
15822 	(cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
15823 	(cmdline_parse_inst_t *)&cmd_gro_enable,
15824 	(cmdline_parse_inst_t *)&cmd_gro_flush,
15825 	(cmdline_parse_inst_t *)&cmd_gro_show,
15826 	(cmdline_parse_inst_t *)&cmd_gso_enable,
15827 	(cmdline_parse_inst_t *)&cmd_gso_size,
15828 	(cmdline_parse_inst_t *)&cmd_gso_show,
15829 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set,
15830 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
15831 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
15832 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
15833 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
15834 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
15835 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
15836 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
15837 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
15838 	(cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
15839 	(cmdline_parse_inst_t *)&cmd_config_dcb,
15840 	(cmdline_parse_inst_t *)&cmd_read_reg,
15841 	(cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
15842 	(cmdline_parse_inst_t *)&cmd_read_reg_bit,
15843 	(cmdline_parse_inst_t *)&cmd_write_reg,
15844 	(cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
15845 	(cmdline_parse_inst_t *)&cmd_write_reg_bit,
15846 	(cmdline_parse_inst_t *)&cmd_read_rxd_txd,
15847 	(cmdline_parse_inst_t *)&cmd_stop,
15848 	(cmdline_parse_inst_t *)&cmd_mac_addr,
15849 	(cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
15850 	(cmdline_parse_inst_t *)&cmd_set_qmap,
15851 	(cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
15852 	(cmdline_parse_inst_t *)&cmd_operate_port,
15853 	(cmdline_parse_inst_t *)&cmd_operate_specific_port,
15854 	(cmdline_parse_inst_t *)&cmd_operate_attach_port,
15855 	(cmdline_parse_inst_t *)&cmd_operate_detach_port,
15856 	(cmdline_parse_inst_t *)&cmd_config_speed_all,
15857 	(cmdline_parse_inst_t *)&cmd_config_speed_specific,
15858 	(cmdline_parse_inst_t *)&cmd_config_rx_tx,
15859 	(cmdline_parse_inst_t *)&cmd_config_mtu,
15860 	(cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
15861 	(cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
15862 	(cmdline_parse_inst_t *)&cmd_config_rss,
15863 	(cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
15864 	(cmdline_parse_inst_t *)&cmd_config_rss_reta,
15865 	(cmdline_parse_inst_t *)&cmd_showport_reta,
15866 	(cmdline_parse_inst_t *)&cmd_config_burst,
15867 	(cmdline_parse_inst_t *)&cmd_config_thresh,
15868 	(cmdline_parse_inst_t *)&cmd_config_threshold,
15869 	(cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
15870 	(cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
15871 	(cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
15872 	(cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
15873 	(cmdline_parse_inst_t *)&cmd_queue_rate_limit,
15874 	(cmdline_parse_inst_t *)&cmd_tunnel_filter,
15875 	(cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
15876 	(cmdline_parse_inst_t *)&cmd_global_config,
15877 	(cmdline_parse_inst_t *)&cmd_set_mirror_mask,
15878 	(cmdline_parse_inst_t *)&cmd_set_mirror_link,
15879 	(cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
15880 	(cmdline_parse_inst_t *)&cmd_showport_rss_hash,
15881 	(cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
15882 	(cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
15883 	(cmdline_parse_inst_t *)&cmd_dump,
15884 	(cmdline_parse_inst_t *)&cmd_dump_one,
15885 	(cmdline_parse_inst_t *)&cmd_ethertype_filter,
15886 	(cmdline_parse_inst_t *)&cmd_syn_filter,
15887 	(cmdline_parse_inst_t *)&cmd_2tuple_filter,
15888 	(cmdline_parse_inst_t *)&cmd_5tuple_filter,
15889 	(cmdline_parse_inst_t *)&cmd_flex_filter,
15890 	(cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
15891 	(cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
15892 	(cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
15893 	(cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
15894 	(cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
15895 	(cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
15896 	(cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
15897 	(cmdline_parse_inst_t *)&cmd_flush_flow_director,
15898 	(cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
15899 	(cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
15900 	(cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
15901 	(cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
15902 	(cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
15903 	(cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
15904 	(cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
15905 	(cmdline_parse_inst_t *)&cmd_get_hash_global_config,
15906 	(cmdline_parse_inst_t *)&cmd_set_hash_global_config,
15907 	(cmdline_parse_inst_t *)&cmd_set_hash_input_set,
15908 	(cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
15909 	(cmdline_parse_inst_t *)&cmd_flow,
15910 	(cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
15911 	(cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
15912 	(cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
15913 	(cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
15914 	(cmdline_parse_inst_t *)&cmd_create_port_meter,
15915 	(cmdline_parse_inst_t *)&cmd_enable_port_meter,
15916 	(cmdline_parse_inst_t *)&cmd_disable_port_meter,
15917 	(cmdline_parse_inst_t *)&cmd_del_port_meter,
15918 	(cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
15919 	(cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
15920 	(cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
15921 	(cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
15922 	(cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
15923 	(cmdline_parse_inst_t *)&cmd_mcast_addr,
15924 	(cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
15925 	(cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
15926 	(cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
15927 	(cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
15928 	(cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
15929 	(cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
15930 	(cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
15931 	(cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
15932 	(cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
15933 	(cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
15934 	(cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
15935 	(cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
15936 	(cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
15937 	(cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
15938 	(cmdline_parse_inst_t *)&cmd_set_tx_loopback,
15939 	(cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
15940 	(cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
15941 	(cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
15942 	(cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
15943 	(cmdline_parse_inst_t *)&cmd_set_macsec_sc,
15944 	(cmdline_parse_inst_t *)&cmd_set_macsec_sa,
15945 	(cmdline_parse_inst_t *)&cmd_set_vf_traffic,
15946 	(cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
15947 	(cmdline_parse_inst_t *)&cmd_vf_rate_limit,
15948 	(cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
15949 	(cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
15950 	(cmdline_parse_inst_t *)&cmd_set_vf_promisc,
15951 	(cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
15952 	(cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
15953 	(cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
15954 	(cmdline_parse_inst_t *)&cmd_vf_max_bw,
15955 	(cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
15956 	(cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
15957 	(cmdline_parse_inst_t *)&cmd_strict_link_prio,
15958 	(cmdline_parse_inst_t *)&cmd_tc_min_bw,
15959 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
15960 	(cmdline_parse_inst_t *)&cmd_set_port_tm_hierarchy_default,
15961 #endif
15962 	(cmdline_parse_inst_t *)&cmd_ddp_add,
15963 	(cmdline_parse_inst_t *)&cmd_ddp_del,
15964 	(cmdline_parse_inst_t *)&cmd_ddp_get_list,
15965 	(cmdline_parse_inst_t *)&cmd_ddp_get_info,
15966 	(cmdline_parse_inst_t *)&cmd_show_vf_stats,
15967 	(cmdline_parse_inst_t *)&cmd_clear_vf_stats,
15968 	(cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
15969 	(cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
15970 	(cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
15971 	(cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
15972 
15973 	(cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
15974 	(cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
15975 	(cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
15976 	(cmdline_parse_inst_t *)&cmd_queue_region,
15977 	(cmdline_parse_inst_t *)&cmd_region_flowtype,
15978 	(cmdline_parse_inst_t *)&cmd_user_priority_region,
15979 	(cmdline_parse_inst_t *)&cmd_flush_queue_region,
15980 	(cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
15981 	(cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
15982 	(cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
15983 	(cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
15984 	(cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
15985 	(cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
15986 	(cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
15987 	(cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
15988 	(cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
15989 	(cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
15990 	(cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
15991 	(cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
15992 	(cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
15993 	(cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
15994 	(cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
15995 	(cmdline_parse_inst_t *)&cmd_del_port_tm_node,
15996 	(cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
15997 	(cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
15998 	NULL,
15999 };
16000 
16001 /* read cmdline commands from file */
16002 void
16003 cmdline_read_from_file(const char *filename)
16004 {
16005 	struct cmdline *cl;
16006 
16007 	cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
16008 	if (cl == NULL) {
16009 		printf("Failed to create file based cmdline context: %s\n",
16010 		       filename);
16011 		return;
16012 	}
16013 
16014 	cmdline_interact(cl);
16015 	cmdline_quit(cl);
16016 
16017 	cmdline_free(cl);
16018 
16019 	printf("Read CLI commands from %s\n", filename);
16020 }
16021 
16022 /* prompt function, called from main on MASTER lcore */
16023 void
16024 prompt(void)
16025 {
16026 	/* initialize non-constant commands */
16027 	cmd_set_fwd_mode_init();
16028 	cmd_set_fwd_retry_mode_init();
16029 
16030 	testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
16031 	if (testpmd_cl == NULL)
16032 		return;
16033 	cmdline_interact(testpmd_cl);
16034 	cmdline_stdin_exit(testpmd_cl);
16035 }
16036 
16037 void
16038 prompt_exit(void)
16039 {
16040 	if (testpmd_cl != NULL)
16041 		cmdline_quit(testpmd_cl);
16042 }
16043 
16044 static void
16045 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
16046 {
16047 	if (id == (portid_t)RTE_PORT_ALL) {
16048 		portid_t pid;
16049 
16050 		RTE_ETH_FOREACH_DEV(pid) {
16051 			/* check if need_reconfig has been set to 1 */
16052 			if (ports[pid].need_reconfig == 0)
16053 				ports[pid].need_reconfig = dev;
16054 			/* check if need_reconfig_queues has been set to 1 */
16055 			if (ports[pid].need_reconfig_queues == 0)
16056 				ports[pid].need_reconfig_queues = queue;
16057 		}
16058 	} else if (!port_id_is_invalid(id, DISABLED_WARN)) {
16059 		/* check if need_reconfig has been set to 1 */
16060 		if (ports[id].need_reconfig == 0)
16061 			ports[id].need_reconfig = dev;
16062 		/* check if need_reconfig_queues has been set to 1 */
16063 		if (ports[id].need_reconfig_queues == 0)
16064 			ports[id].need_reconfig_queues = queue;
16065 	}
16066 }
16067