xref: /dpdk/app/test-pmd/cmdline.c (revision 2f82d143fb318042f47a50694baa4507b51b7381)
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2010-2016 Intel Corporation.
3  * Copyright(c) 2014 6WIND S.A.
4  */
5 
6 #include <stdarg.h>
7 #include <errno.h>
8 #include <stdio.h>
9 #include <stdint.h>
10 #include <string.h>
11 #include <termios.h>
12 #include <unistd.h>
13 #include <inttypes.h>
14 #ifndef __linux__
15 #ifndef __FreeBSD__
16 #include <net/socket.h>
17 #else
18 #include <sys/socket.h>
19 #endif
20 #endif
21 #include <netinet/in.h>
22 
23 #include <sys/queue.h>
24 
25 #include <rte_common.h>
26 #include <rte_byteorder.h>
27 #include <rte_log.h>
28 #include <rte_debug.h>
29 #include <rte_cycles.h>
30 #include <rte_memory.h>
31 #include <rte_memzone.h>
32 #include <rte_malloc.h>
33 #include <rte_launch.h>
34 #include <rte_eal.h>
35 #include <rte_per_lcore.h>
36 #include <rte_lcore.h>
37 #include <rte_atomic.h>
38 #include <rte_branch_prediction.h>
39 #include <rte_ring.h>
40 #include <rte_mempool.h>
41 #include <rte_interrupts.h>
42 #include <rte_pci.h>
43 #include <rte_ether.h>
44 #include <rte_ethdev.h>
45 #include <rte_string_fns.h>
46 #include <rte_devargs.h>
47 #include <rte_eth_ctrl.h>
48 #include <rte_flow.h>
49 #include <rte_gro.h>
50 
51 #include <cmdline_rdline.h>
52 #include <cmdline_parse.h>
53 #include <cmdline_parse_num.h>
54 #include <cmdline_parse_string.h>
55 #include <cmdline_parse_ipaddr.h>
56 #include <cmdline_parse_etheraddr.h>
57 #include <cmdline_socket.h>
58 #include <cmdline.h>
59 #ifdef RTE_LIBRTE_PMD_BOND
60 #include <rte_eth_bond.h>
61 #include <rte_eth_bond_8023ad.h>
62 #endif
63 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD
64 #include <rte_pmd_dpaa.h>
65 #endif
66 #ifdef RTE_LIBRTE_IXGBE_PMD
67 #include <rte_pmd_ixgbe.h>
68 #endif
69 #ifdef RTE_LIBRTE_I40E_PMD
70 #include <rte_pmd_i40e.h>
71 #endif
72 #ifdef RTE_LIBRTE_BNXT_PMD
73 #include <rte_pmd_bnxt.h>
74 #endif
75 #include "testpmd.h"
76 #include "cmdline_mtr.h"
77 #include "cmdline_tm.h"
78 
79 static struct cmdline *testpmd_cl;
80 
81 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
82 
83 /* *** Help command with introduction. *** */
84 struct cmd_help_brief_result {
85 	cmdline_fixed_string_t help;
86 };
87 
88 static void cmd_help_brief_parsed(__attribute__((unused)) void *parsed_result,
89                                   struct cmdline *cl,
90                                   __attribute__((unused)) void *data)
91 {
92 	cmdline_printf(
93 		cl,
94 		"\n"
95 		"Help is available for the following sections:\n\n"
96 		"    help control    : Start and stop forwarding.\n"
97 		"    help display    : Displaying port, stats and config "
98 		"information.\n"
99 		"    help config     : Configuration information.\n"
100 		"    help ports      : Configuring ports.\n"
101 		"    help registers  : Reading and setting port registers.\n"
102 		"    help filters    : Filters configuration help.\n"
103 		"    help all        : All of the above sections.\n\n"
104 	);
105 
106 }
107 
108 cmdline_parse_token_string_t cmd_help_brief_help =
109 	TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
110 
111 cmdline_parse_inst_t cmd_help_brief = {
112 	.f = cmd_help_brief_parsed,
113 	.data = NULL,
114 	.help_str = "help: Show help",
115 	.tokens = {
116 		(void *)&cmd_help_brief_help,
117 		NULL,
118 	},
119 };
120 
121 /* *** Help command with help sections. *** */
122 struct cmd_help_long_result {
123 	cmdline_fixed_string_t help;
124 	cmdline_fixed_string_t section;
125 };
126 
127 static void cmd_help_long_parsed(void *parsed_result,
128                                  struct cmdline *cl,
129                                  __attribute__((unused)) void *data)
130 {
131 	int show_all = 0;
132 	struct cmd_help_long_result *res = parsed_result;
133 
134 	if (!strcmp(res->section, "all"))
135 		show_all = 1;
136 
137 	if (show_all || !strcmp(res->section, "control")) {
138 
139 		cmdline_printf(
140 			cl,
141 			"\n"
142 			"Control forwarding:\n"
143 			"-------------------\n\n"
144 
145 			"start\n"
146 			"    Start packet forwarding with current configuration.\n\n"
147 
148 			"start tx_first\n"
149 			"    Start packet forwarding with current config"
150 			" after sending one burst of packets.\n\n"
151 
152 			"stop\n"
153 			"    Stop packet forwarding, and display accumulated"
154 			" statistics.\n\n"
155 
156 			"quit\n"
157 			"    Quit to prompt.\n\n"
158 		);
159 	}
160 
161 	if (show_all || !strcmp(res->section, "display")) {
162 
163 		cmdline_printf(
164 			cl,
165 			"\n"
166 			"Display:\n"
167 			"--------\n\n"
168 
169 			"show port (info|stats|xstats|fdir|stat_qmap|dcb_tc|cap) (port_id|all)\n"
170 			"    Display information for port_id, or all.\n\n"
171 
172 			"show port X rss reta (size) (mask0,mask1,...)\n"
173 			"    Display the rss redirection table entry indicated"
174 			" by masks on port X. size is used to indicate the"
175 			" hardware supported reta size\n\n"
176 
177 			"show port rss-hash ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|"
178 			"ipv4-sctp|ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
179 			"ipv6-other|l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex [key]\n"
180 			"    Display the RSS hash functions and RSS hash key"
181 			" of port X\n\n"
182 
183 			"clear port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n"
184 			"    Clear information for port_id, or all.\n\n"
185 
186 			"show (rxq|txq) info (port_id) (queue_id)\n"
187 			"    Display information for configured RX/TX queue.\n\n"
188 
189 			"show config (rxtx|cores|fwd|txpkts)\n"
190 			"    Display the given configuration.\n\n"
191 
192 			"read rxd (port_id) (queue_id) (rxd_id)\n"
193 			"    Display an RX descriptor of a port RX queue.\n\n"
194 
195 			"read txd (port_id) (queue_id) (txd_id)\n"
196 			"    Display a TX descriptor of a port TX queue.\n\n"
197 
198 			"ddp get list (port_id)\n"
199 			"    Get ddp profile info list\n\n"
200 
201 			"ddp get info (profile_path)\n"
202 			"    Get ddp profile information.\n\n"
203 
204 			"show vf stats (port_id) (vf_id)\n"
205 			"    Display a VF's statistics.\n\n"
206 
207 			"clear vf stats (port_id) (vf_id)\n"
208 			"    Reset a VF's statistics.\n\n"
209 
210 			"show port (port_id) pctype mapping\n"
211 			"    Get flow ptype to pctype mapping on a port\n\n"
212 
213 			"show port meter stats (port_id) (meter_id) (clear)\n"
214 			"    Get meter stats on a port\n\n"
215                         "show port tm cap (port_id)\n"
216                         "       Display the port TM capability.\n\n"
217 
218                         "show port tm level cap (port_id) (level_id)\n"
219                         "       Display the port TM hierarchical level capability.\n\n"
220 
221                         "show port tm node cap (port_id) (node_id)\n"
222                         "       Display the port TM node capability.\n\n"
223 
224                         "show port tm node type (port_id) (node_id)\n"
225                         "       Display the port TM node type.\n\n"
226 
227                         "show port tm node stats (port_id) (node_id) (clear)\n"
228                         "       Display the port TM node stats.\n\n"
229 
230 		);
231 	}
232 
233 	if (show_all || !strcmp(res->section, "config")) {
234 		cmdline_printf(
235 			cl,
236 			"\n"
237 			"Configuration:\n"
238 			"--------------\n"
239 			"Configuration changes only become active when"
240 			" forwarding is started/restarted.\n\n"
241 
242 			"set default\n"
243 			"    Reset forwarding to the default configuration.\n\n"
244 
245 			"set verbose (level)\n"
246 			"    Set the debug verbosity level X.\n\n"
247 
248 			"set log global|(type) (level)\n"
249 			"    Set the log level.\n\n"
250 
251 			"set nbport (num)\n"
252 			"    Set number of ports.\n\n"
253 
254 			"set nbcore (num)\n"
255 			"    Set number of cores.\n\n"
256 
257 			"set coremask (mask)\n"
258 			"    Set the forwarding cores hexadecimal mask.\n\n"
259 
260 			"set portmask (mask)\n"
261 			"    Set the forwarding ports hexadecimal mask.\n\n"
262 
263 			"set burst (num)\n"
264 			"    Set number of packets per burst.\n\n"
265 
266 			"set burst tx delay (microseconds) retry (num)\n"
267 			"    Set the transmit delay time and number of retries,"
268 			" effective when retry is enabled.\n\n"
269 
270 			"set txpkts (x[,y]*)\n"
271 			"    Set the length of each segment of TXONLY"
272 			" and optionally CSUM packets.\n\n"
273 
274 			"set txsplit (off|on|rand)\n"
275 			"    Set the split policy for the TX packets."
276 			" Right now only applicable for CSUM and TXONLY"
277 			" modes\n\n"
278 
279 			"set corelist (x[,y]*)\n"
280 			"    Set the list of forwarding cores.\n\n"
281 
282 			"set portlist (x[,y]*)\n"
283 			"    Set the list of forwarding ports.\n\n"
284 
285 			"set tx loopback (port_id) (on|off)\n"
286 			"    Enable or disable tx loopback.\n\n"
287 
288 			"set all queues drop (port_id) (on|off)\n"
289 			"    Set drop enable bit for all queues.\n\n"
290 
291 			"set vf split drop (port_id) (vf_id) (on|off)\n"
292 			"    Set split drop enable bit for a VF from the PF.\n\n"
293 
294 			"set vf mac antispoof (port_id) (vf_id) (on|off).\n"
295 			"    Set MAC antispoof for a VF from the PF.\n\n"
296 
297 			"set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n"
298 			"    Enable MACsec offload.\n\n"
299 
300 			"set macsec offload (port_id) off\n"
301 			"    Disable MACsec offload.\n\n"
302 
303 			"set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
304 			"    Configure MACsec secure connection (SC).\n\n"
305 
306 			"set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n"
307 			"    Configure MACsec secure association (SA).\n\n"
308 
309 			"set vf broadcast (port_id) (vf_id) (on|off)\n"
310 			"    Set VF broadcast for a VF from the PF.\n\n"
311 
312 			"vlan set strip (on|off) (port_id)\n"
313 			"    Set the VLAN strip on a port.\n\n"
314 
315 			"vlan set stripq (on|off) (port_id,queue_id)\n"
316 			"    Set the VLAN strip for a queue on a port.\n\n"
317 
318 			"set vf vlan stripq (port_id) (vf_id) (on|off)\n"
319 			"    Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
320 
321 			"set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
322 			"    Set VLAN insert for a VF from the PF.\n\n"
323 
324 			"set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
325 			"    Set VLAN antispoof for a VF from the PF.\n\n"
326 
327 			"set vf vlan tag (port_id) (vf_id) (on|off)\n"
328 			"    Set VLAN tag for a VF from the PF.\n\n"
329 
330 			"set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n"
331 			"    Set a VF's max bandwidth(Mbps).\n\n"
332 
333 			"set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n"
334 			"    Set all TCs' min bandwidth(%%) on a VF.\n\n"
335 
336 			"set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n"
337 			"    Set a TC's max bandwidth(Mbps) on a VF.\n\n"
338 
339 			"set tx strict-link-priority (port_id) (tc_bitmap)\n"
340 			"    Set some TCs' strict link priority mode on a physical port.\n\n"
341 
342 			"set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n"
343 			"    Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n"
344 
345 			"vlan set filter (on|off) (port_id)\n"
346 			"    Set the VLAN filter on a port.\n\n"
347 
348 			"vlan set qinq (on|off) (port_id)\n"
349 			"    Set the VLAN QinQ (extended queue in queue)"
350 			" on a port.\n\n"
351 
352 			"vlan set (inner|outer) tpid (value) (port_id)\n"
353 			"    Set the VLAN TPID for Packet Filtering on"
354 			" a port\n\n"
355 
356 			"rx_vlan add (vlan_id|all) (port_id)\n"
357 			"    Add a vlan_id, or all identifiers, to the set"
358 			" of VLAN identifiers filtered by port_id.\n\n"
359 
360 			"rx_vlan rm (vlan_id|all) (port_id)\n"
361 			"    Remove a vlan_id, or all identifiers, from the set"
362 			" of VLAN identifiers filtered by port_id.\n\n"
363 
364 			"rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
365 			"    Add a vlan_id, to the set of VLAN identifiers"
366 			"filtered for VF(s) from port_id.\n\n"
367 
368 			"rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
369 			"    Remove a vlan_id, to the set of VLAN identifiers"
370 			"filtered for VF(s) from port_id.\n\n"
371 
372 			"tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) "
373 			"(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
374 			"imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
375 			"   add a tunnel filter of a port.\n\n"
376 
377 			"tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) "
378 			"(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
379 			"imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
380 			"   remove a tunnel filter of a port.\n\n"
381 
382 			"rx_vxlan_port add (udp_port) (port_id)\n"
383 			"    Add an UDP port for VXLAN packet filter on a port\n\n"
384 
385 			"rx_vxlan_port rm (udp_port) (port_id)\n"
386 			"    Remove an UDP port for VXLAN packet filter on a port\n\n"
387 
388 			"tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
389 			"    Set hardware insertion of VLAN IDs (single or double VLAN "
390 			"depends on the number of VLAN IDs) in packets sent on a port.\n\n"
391 
392 			"tx_vlan set pvid port_id vlan_id (on|off)\n"
393 			"    Set port based TX VLAN insertion.\n\n"
394 
395 			"tx_vlan reset (port_id)\n"
396 			"    Disable hardware insertion of a VLAN header in"
397 			" packets sent on a port.\n\n"
398 
399 			"csum set (ip|udp|tcp|sctp|outer-ip) (hw|sw) (port_id)\n"
400 			"    Select hardware or software calculation of the"
401 			" checksum when transmitting a packet using the"
402 			" csum forward engine.\n"
403 			"    ip|udp|tcp|sctp always concern the inner layer.\n"
404 			"    outer-ip concerns the outer IP layer in"
405 			" case the packet is recognized as a tunnel packet by"
406 			" the forward engine (vxlan, gre and ipip are supported)\n"
407 			"    Please check the NIC datasheet for HW limits.\n\n"
408 
409 			"csum parse-tunnel (on|off) (tx_port_id)\n"
410 			"    If disabled, treat tunnel packets as non-tunneled"
411 			" packets (treat inner headers as payload). The port\n"
412 			"    argument is the port used for TX in csum forward"
413 			" engine.\n\n"
414 
415 			"csum show (port_id)\n"
416 			"    Display tx checksum offload configuration\n\n"
417 
418 			"tso set (segsize) (portid)\n"
419 			"    Enable TCP Segmentation Offload in csum forward"
420 			" engine.\n"
421 			"    Please check the NIC datasheet for HW limits.\n\n"
422 
423 			"tso show (portid)"
424 			"    Display the status of TCP Segmentation Offload.\n\n"
425 
426 			"set port (port_id) gro on|off\n"
427 			"    Enable or disable Generic Receive Offload in"
428 			" csum forwarding engine.\n\n"
429 
430 			"show port (port_id) gro\n"
431 			"    Display GRO configuration.\n\n"
432 
433 			"set gro flush (cycles)\n"
434 			"    Set the cycle to flush GROed packets from"
435 			" reassembly tables.\n\n"
436 
437 			"set port (port_id) gso (on|off)"
438 			"    Enable or disable Generic Segmentation Offload in"
439 			" csum forwarding engine.\n\n"
440 
441 			"set gso segsz (length)\n"
442 			"    Set max packet length for output GSO segments,"
443 			" including packet header and payload.\n\n"
444 
445 			"show port (port_id) gso\n"
446 			"    Show GSO configuration.\n\n"
447 
448 			"set fwd (%s)\n"
449 			"    Set packet forwarding mode.\n\n"
450 
451 			"mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
452 			"    Add a MAC address on port_id.\n\n"
453 
454 			"mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
455 			"    Remove a MAC address from port_id.\n\n"
456 
457 			"mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
458 			"    Set the default MAC address for port_id.\n\n"
459 
460 			"mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
461 			"    Add a MAC address for a VF on the port.\n\n"
462 
463 			"set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
464 			"    Set the MAC address for a VF from the PF.\n\n"
465 
466 			"set eth-peer (port_id) (peer_addr)\n"
467 			"    set the peer address for certain port.\n\n"
468 
469 			"set port (port_id) uta (mac_address|all) (on|off)\n"
470 			"    Add/Remove a or all unicast hash filter(s)"
471 			"from port X.\n\n"
472 
473 			"set promisc (port_id|all) (on|off)\n"
474 			"    Set the promiscuous mode on port_id, or all.\n\n"
475 
476 			"set allmulti (port_id|all) (on|off)\n"
477 			"    Set the allmulti mode on port_id, or all.\n\n"
478 
479 			"set vf promisc (port_id) (vf_id) (on|off)\n"
480 			"    Set unicast promiscuous mode for a VF from the PF.\n\n"
481 
482 			"set vf allmulti (port_id) (vf_id) (on|off)\n"
483 			"    Set multicast promiscuous mode for a VF from the PF.\n\n"
484 
485 			"set flow_ctrl rx (on|off) tx (on|off) (high_water)"
486 			" (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
487 			" (on|off) autoneg (on|off) (port_id)\n"
488 			"set flow_ctrl rx (on|off) (portid)\n"
489 			"set flow_ctrl tx (on|off) (portid)\n"
490 			"set flow_ctrl high_water (high_water) (portid)\n"
491 			"set flow_ctrl low_water (low_water) (portid)\n"
492 			"set flow_ctrl pause_time (pause_time) (portid)\n"
493 			"set flow_ctrl send_xon (send_xon) (portid)\n"
494 			"set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
495 			"set flow_ctrl autoneg (on|off) (port_id)\n"
496 			"    Set the link flow control parameter on a port.\n\n"
497 
498 			"set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
499 			" (low_water) (pause_time) (priority) (port_id)\n"
500 			"    Set the priority flow control parameter on a"
501 			" port.\n\n"
502 
503 			"set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
504 			"    Set statistics mapping (qmapping 0..15) for RX/TX"
505 			" queue on port.\n"
506 			"    e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
507 			" on port 0 to mapping 5.\n\n"
508 
509 			"set xstats-hide-zero on|off\n"
510 			"    Set the option to hide the zero values"
511 			" for xstats display.\n"
512 
513 			"set port (port_id) vf (vf_id) rx|tx on|off\n"
514 			"    Enable/Disable a VF receive/tranmit from a port\n\n"
515 
516 			"set port (port_id) vf (vf_id) (mac_addr)"
517 			" (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
518 			"   Add/Remove unicast or multicast MAC addr filter"
519 			" for a VF.\n\n"
520 
521 			"set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
522 			"|MPE) (on|off)\n"
523 			"    AUPE:accepts untagged VLAN;"
524 			"ROPE:accept unicast hash\n\n"
525 			"    BAM:accepts broadcast packets;"
526 			"MPE:accepts all multicast packets\n\n"
527 			"    Enable/Disable a VF receive mode of a port\n\n"
528 
529 			"set port (port_id) queue (queue_id) rate (rate_num)\n"
530 			"    Set rate limit for a queue of a port\n\n"
531 
532 			"set port (port_id) vf (vf_id) rate (rate_num) "
533 			"queue_mask (queue_mask_value)\n"
534 			"    Set rate limit for queues in VF of a port\n\n"
535 
536 			"set port (port_id) mirror-rule (rule_id)"
537 			" (pool-mirror-up|pool-mirror-down|vlan-mirror)"
538 			" (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
539 			"   Set pool or vlan type mirror rule on a port.\n"
540 			"   e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
541 			" dst-pool 0 on' enable mirror traffic with vlan 0,1"
542 			" to pool 0.\n\n"
543 
544 			"set port (port_id) mirror-rule (rule_id)"
545 			" (uplink-mirror|downlink-mirror) dst-pool"
546 			" (pool_id) (on|off)\n"
547 			"   Set uplink or downlink type mirror rule on a port.\n"
548 			"   e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
549 			" 0 on' enable mirror income traffic to pool 0.\n\n"
550 
551 			"reset port (port_id) mirror-rule (rule_id)\n"
552 			"   Reset a mirror rule.\n\n"
553 
554 			"set flush_rx (on|off)\n"
555 			"   Flush (default) or don't flush RX streams before"
556 			" forwarding. Mainly used with PCAP drivers.\n\n"
557 
558 			"set bypass mode (normal|bypass|isolate) (port_id)\n"
559 			"   Set the bypass mode for the lowest port on bypass enabled"
560 			" NIC.\n\n"
561 
562 			"set bypass event (timeout|os_on|os_off|power_on|power_off) "
563 			"mode (normal|bypass|isolate) (port_id)\n"
564 			"   Set the event required to initiate specified bypass mode for"
565 			" the lowest port on a bypass enabled NIC where:\n"
566 			"       timeout   = enable bypass after watchdog timeout.\n"
567 			"       os_on     = enable bypass when OS/board is powered on.\n"
568 			"       os_off    = enable bypass when OS/board is powered off.\n"
569 			"       power_on  = enable bypass when power supply is turned on.\n"
570 			"       power_off = enable bypass when power supply is turned off."
571 			"\n\n"
572 
573 			"set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
574 			"   Set the bypass watchdog timeout to 'n' seconds"
575 			" where 0 = instant.\n\n"
576 
577 			"show bypass config (port_id)\n"
578 			"   Show the bypass configuration for a bypass enabled NIC"
579 			" using the lowest port on the NIC.\n\n"
580 
581 #ifdef RTE_LIBRTE_PMD_BOND
582 			"create bonded device (mode) (socket)\n"
583 			"	Create a new bonded device with specific bonding mode and socket.\n\n"
584 
585 			"add bonding slave (slave_id) (port_id)\n"
586 			"	Add a slave device to a bonded device.\n\n"
587 
588 			"remove bonding slave (slave_id) (port_id)\n"
589 			"	Remove a slave device from a bonded device.\n\n"
590 
591 			"set bonding mode (value) (port_id)\n"
592 			"	Set the bonding mode on a bonded device.\n\n"
593 
594 			"set bonding primary (slave_id) (port_id)\n"
595 			"	Set the primary slave for a bonded device.\n\n"
596 
597 			"show bonding config (port_id)\n"
598 			"	Show the bonding config for port_id.\n\n"
599 
600 			"set bonding mac_addr (port_id) (address)\n"
601 			"	Set the MAC address of a bonded device.\n\n"
602 
603 			"set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)"
604 			"	Set Aggregation mode for IEEE802.3AD (mode 4)"
605 
606 			"set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
607 			"	Set the transmit balance policy for bonded device running in balance mode.\n\n"
608 
609 			"set bonding mon_period (port_id) (value)\n"
610 			"	Set the bonding link status monitoring polling period in ms.\n\n"
611 
612 			"set bonding lacp dedicated_queues <port_id> (enable|disable)\n"
613 			"	Enable/disable dedicated queues for LACP control traffic.\n\n"
614 
615 #endif
616 			"set link-up port (port_id)\n"
617 			"	Set link up for a port.\n\n"
618 
619 			"set link-down port (port_id)\n"
620 			"	Set link down for a port.\n\n"
621 
622 			"E-tag set insertion on port-tag-id (value)"
623 			" port (port_id) vf (vf_id)\n"
624 			"    Enable E-tag insertion for a VF on a port\n\n"
625 
626 			"E-tag set insertion off port (port_id) vf (vf_id)\n"
627 			"    Disable E-tag insertion for a VF on a port\n\n"
628 
629 			"E-tag set stripping (on|off) port (port_id)\n"
630 			"    Enable/disable E-tag stripping on a port\n\n"
631 
632 			"E-tag set forwarding (on|off) port (port_id)\n"
633 			"    Enable/disable E-tag based forwarding"
634 			" on a port\n\n"
635 
636 			"E-tag set filter add e-tag-id (value) dst-pool"
637 			" (pool_id) port (port_id)\n"
638 			"    Add an E-tag forwarding filter on a port\n\n"
639 
640 			"E-tag set filter del e-tag-id (value) port (port_id)\n"
641 			"    Delete an E-tag forwarding filter on a port\n\n"
642 
643 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
644 			"set port tm hierarchy default (port_id)\n"
645 			"	Set default traffic Management hierarchy on a port\n\n"
646 
647 #endif
648 			"ddp add (port_id) (profile_path[,backup_profile_path])\n"
649 			"    Load a profile package on a port\n\n"
650 
651 			"ddp del (port_id) (backup_profile_path)\n"
652 			"    Delete a profile package from a port\n\n"
653 
654 			"ptype mapping get (port_id) (valid_only)\n"
655 			"    Get ptype mapping on a port\n\n"
656 
657 			"ptype mapping replace (port_id) (target) (mask) (pky_type)\n"
658 			"    Replace target with the pkt_type in ptype mapping\n\n"
659 
660 			"ptype mapping reset (port_id)\n"
661 			"    Reset ptype mapping on a port\n\n"
662 
663 			"ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n"
664 			"    Update a ptype mapping item on a port\n\n"
665 
666 			"set port (port_id) queue-region region_id (value) "
667 			"queue_start_index (value) queue_num (value)\n"
668 			"    Set a queue region on a port\n\n"
669 
670 			"set port (port_id) queue-region region_id (value) "
671 			"flowtype (value)\n"
672 			"    Set a flowtype region index on a port\n\n"
673 
674 			"set port (port_id) queue-region UP (value) region_id (value)\n"
675 			"    Set the mapping of User Priority to "
676 			"queue region on a port\n\n"
677 
678 			"set port (port_id) queue-region flush (on|off)\n"
679 			"    flush all queue region related configuration\n\n"
680 
681 			"show port meter cap (port_id)\n"
682 			"    Show port meter capability information\n\n"
683 
684 			"add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs)\n"
685 			"    meter profile add - srtcm rfc 2697\n\n"
686 
687 			"add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs)\n"
688 			"    meter profile add - trtcm rfc 2698\n\n"
689 
690 			"add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs)\n"
691 			"    meter profile add - trtcm rfc 4115\n\n"
692 
693 			"del port meter profile (port_id) (profile_id)\n"
694 			"    meter profile delete\n\n"
695 
696 			"create port meter (port_id) (mtr_id) (profile_id) (meter_enable)\n"
697 			"(g_action) (y_action) (r_action) (stats_mask) (shared)\n"
698 			"(use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n"
699 			"(dscp_tbl_entry63)]\n"
700 			"    meter create\n\n"
701 
702 			"enable port meter (port_id) (mtr_id)\n"
703 			"    meter enable\n\n"
704 
705 			"disable port meter (port_id) (mtr_id)\n"
706 			"    meter disable\n\n"
707 
708 			"del port meter (port_id) (mtr_id)\n"
709 			"    meter delete\n\n"
710 
711 			"set port meter profile (port_id) (mtr_id) (profile_id)\n"
712 			"    meter update meter profile\n\n"
713 
714 			"set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n"
715 			"(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n"
716 			"    update meter dscp table entries\n\n"
717 
718 			"set port meter policer action (port_id) (mtr_id) (action_mask)\n"
719 			"(action0) [(action1) (action2)]\n"
720 			"    meter update policer action\n\n"
721 
722 			"set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
723 			"    meter update stats\n\n"
724 
725 			"show port (port_id) queue-region\n"
726 			"    show all queue region related configuration info\n\n"
727 
728 			"add port tm node shaper profile (port_id) (shaper_profile_id)"
729 			" (tb_rate) (tb_size) (packet_length_adjust)\n"
730 			"	Add port tm node private shaper profile.\n\n"
731 
732 			"del port tm node shaper profile (port_id) (shaper_profile_id)\n"
733 			"	Delete port tm node private shaper profile.\n\n"
734 
735 			"add port tm node shared shaper (port_id) (shared_shaper_id)"
736 			" (shaper_profile_id)\n"
737 			"	Add/update port tm node shared shaper.\n\n"
738 
739 			"del port tm node shared shaper (port_id) (shared_shaper_id)\n"
740 			"	Delete port tm node shared shaper.\n\n"
741 
742 			"set port tm node shaper profile (port_id) (node_id)"
743 			" (shaper_profile_id)\n"
744 			"	Set port tm node shaper profile.\n\n"
745 
746 			"add port tm node wred profile (port_id) (wred_profile_id)"
747 			" (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
748 			" (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
749 			" (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
750 			"	Add port tm node wred profile.\n\n"
751 
752 			"del port tm node wred profile (port_id) (wred_profile_id)\n"
753 			"	Delete port tm node wred profile.\n\n"
754 
755 			"add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
756 			" (priority) (weight) (level_id) (shaper_profile_id)"
757 			" (n_sp_priorities) (stats_mask) (n_shared_shapers)"
758 			" [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
759 			"	Add port tm nonleaf node.\n\n"
760 
761 			"add port tm leaf node (port_id) (node_id) (parent_node_id)"
762 			" (priority) (weight) (level_id) (shaper_profile_id)"
763 			" (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
764 			" [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
765 			"	Add port tm leaf node.\n\n"
766 
767 			"del port tm node (port_id) (node_id)\n"
768 			"	Delete port tm node.\n\n"
769 
770 			"set port tm node parent (port_id) (node_id) (parent_node_id)"
771 			" (priority) (weight)\n"
772 			"	Set port tm node parent.\n\n"
773 
774 			"port tm hierarchy commit (port_id) (clean_on_fail)\n"
775 			"	Commit tm hierarchy.\n\n"
776 
777 			, list_pkt_forwarding_modes()
778 		);
779 	}
780 
781 	if (show_all || !strcmp(res->section, "ports")) {
782 
783 		cmdline_printf(
784 			cl,
785 			"\n"
786 			"Port Operations:\n"
787 			"----------------\n\n"
788 
789 			"port start (port_id|all)\n"
790 			"    Start all ports or port_id.\n\n"
791 
792 			"port stop (port_id|all)\n"
793 			"    Stop all ports or port_id.\n\n"
794 
795 			"port close (port_id|all)\n"
796 			"    Close all ports or port_id.\n\n"
797 
798 			"port attach (ident)\n"
799 			"    Attach physical or virtual dev by pci address or virtual device name\n\n"
800 
801 			"port detach (port_id)\n"
802 			"    Detach physical or virtual dev by port_id\n\n"
803 
804 			"port config (port_id|all)"
805 			" speed (10|100|1000|10000|25000|40000|50000|100000|auto)"
806 			" duplex (half|full|auto)\n"
807 			"    Set speed and duplex for all ports or port_id\n\n"
808 
809 			"port config (port_id|all) loopback (mode)\n"
810 			"    Set loopback mode for all ports or port_id\n\n"
811 
812 			"port config all (rxq|txq|rxd|txd) (value)\n"
813 			"    Set number for rxq/txq/rxd/txd.\n\n"
814 
815 			"port config all max-pkt-len (value)\n"
816 			"    Set the max packet length.\n\n"
817 
818 			"port config all (crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|hw-vlan-filter|"
819 			"hw-vlan-strip|hw-vlan-extend|drop-en)"
820 			" (on|off)\n"
821 			"    Set crc-strip/scatter/rx-checksum/hardware-vlan/drop_en"
822 			" for ports.\n\n"
823 
824 			"port config all rss (all|default|ip|tcp|udp|sctp|"
825 			"ether|port|vxlan|geneve|nvgre|none|<flowtype_id>)\n"
826 			"    Set the RSS mode.\n\n"
827 
828 			"port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
829 			"    Set the RSS redirection table.\n\n"
830 
831 			"port config (port_id) dcb vt (on|off) (traffic_class)"
832 			" pfc (on|off)\n"
833 			"    Set the DCB mode.\n\n"
834 
835 			"port config all burst (value)\n"
836 			"    Set the number of packets per burst.\n\n"
837 
838 			"port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
839 			" (value)\n"
840 			"    Set the ring prefetch/host/writeback threshold"
841 			" for tx/rx queue.\n\n"
842 
843 			"port config all (txfreet|txrst|rxfreet) (value)\n"
844 			"    Set free threshold for rx/tx, or set"
845 			" tx rs bit threshold.\n\n"
846 			"port config mtu X value\n"
847 			"    Set the MTU of port X to a given value\n\n"
848 
849 			"port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n"
850 			"    Set a rx/tx queue's ring size configuration, the new"
851 			" value will take effect after command that (re-)start the port"
852 			" or command that setup the specific queue\n\n"
853 
854 			"port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
855 			"    Start/stop a rx/tx queue of port X. Only take effect"
856 			" when port X is started\n\n"
857 
858 			"port (port_id) (rxq|txq) (queue_id) setup\n"
859 			"    Setup a rx/tx queue of port X.\n\n"
860 
861 			"port config (port_id|all) l2-tunnel E-tag ether-type"
862 			" (value)\n"
863 			"    Set the value of E-tag ether-type.\n\n"
864 
865 			"port config (port_id|all) l2-tunnel E-tag"
866 			" (enable|disable)\n"
867 			"    Enable/disable the E-tag support.\n\n"
868 
869 			"port config (port_id) pctype mapping reset\n"
870 			"    Reset flow type to pctype mapping on a port\n\n"
871 
872 			"port config (port_id) pctype mapping update"
873 			" (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
874 			"    Update a flow type to pctype mapping item on a port\n\n"
875 
876 			"port config (port_id) pctype (pctype_id) hash_inset|"
877 			"fdir_inset|fdir_flx_inset get|set|clear field\n"
878 			" (field_idx)\n"
879 			"    Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n"
880 
881 			"port config (port_id) pctype (pctype_id) hash_inset|"
882 			"fdir_inset|fdir_flx_inset clear all"
883 			"    Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n"
884 
885 			"port config (port_id) udp_tunnel_port add|rm vxlan|geneve (udp_port)\n\n"
886 			"    Add/remove UDP tunnel port for tunneling offload\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 	portid_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, UINT16);
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 loopback for all ports *** */
1505 struct cmd_config_loopback_all {
1506 	cmdline_fixed_string_t port;
1507 	cmdline_fixed_string_t keyword;
1508 	cmdline_fixed_string_t all;
1509 	cmdline_fixed_string_t item;
1510 	uint32_t mode;
1511 };
1512 
1513 static void
1514 cmd_config_loopback_all_parsed(void *parsed_result,
1515 			__attribute__((unused)) struct cmdline *cl,
1516 			__attribute__((unused)) void *data)
1517 {
1518 	struct cmd_config_loopback_all *res = parsed_result;
1519 	portid_t pid;
1520 
1521 	if (!all_ports_stopped()) {
1522 		printf("Please stop all ports first\n");
1523 		return;
1524 	}
1525 
1526 	RTE_ETH_FOREACH_DEV(pid) {
1527 		ports[pid].dev_conf.lpbk_mode = res->mode;
1528 	}
1529 
1530 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1531 }
1532 
1533 cmdline_parse_token_string_t cmd_config_loopback_all_port =
1534 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1535 cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1536 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1537 							"config");
1538 cmdline_parse_token_string_t cmd_config_loopback_all_all =
1539 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1540 cmdline_parse_token_string_t cmd_config_loopback_all_item =
1541 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1542 							"loopback");
1543 cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1544 	TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, UINT32);
1545 
1546 cmdline_parse_inst_t cmd_config_loopback_all = {
1547 	.f = cmd_config_loopback_all_parsed,
1548 	.data = NULL,
1549 	.help_str = "port config all loopback <mode>",
1550 	.tokens = {
1551 		(void *)&cmd_config_loopback_all_port,
1552 		(void *)&cmd_config_loopback_all_keyword,
1553 		(void *)&cmd_config_loopback_all_all,
1554 		(void *)&cmd_config_loopback_all_item,
1555 		(void *)&cmd_config_loopback_all_mode,
1556 		NULL,
1557 	},
1558 };
1559 
1560 /* *** configure loopback for specific port *** */
1561 struct cmd_config_loopback_specific {
1562 	cmdline_fixed_string_t port;
1563 	cmdline_fixed_string_t keyword;
1564 	uint16_t port_id;
1565 	cmdline_fixed_string_t item;
1566 	uint32_t mode;
1567 };
1568 
1569 static void
1570 cmd_config_loopback_specific_parsed(void *parsed_result,
1571 				__attribute__((unused)) struct cmdline *cl,
1572 				__attribute__((unused)) void *data)
1573 {
1574 	struct cmd_config_loopback_specific *res = parsed_result;
1575 
1576 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1577 		return;
1578 
1579 	if (!port_is_stopped(res->port_id)) {
1580 		printf("Please stop port %u first\n", res->port_id);
1581 		return;
1582 	}
1583 
1584 	ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1585 
1586 	cmd_reconfig_device_queue(res->port_id, 1, 1);
1587 }
1588 
1589 
1590 cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1591 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1592 								"port");
1593 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1594 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1595 								"config");
1596 cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1597 	TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1598 								UINT16);
1599 cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1600 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1601 								"loopback");
1602 cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1603 	TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1604 			      UINT32);
1605 
1606 cmdline_parse_inst_t cmd_config_loopback_specific = {
1607 	.f = cmd_config_loopback_specific_parsed,
1608 	.data = NULL,
1609 	.help_str = "port config <port_id> loopback <mode>",
1610 	.tokens = {
1611 		(void *)&cmd_config_loopback_specific_port,
1612 		(void *)&cmd_config_loopback_specific_keyword,
1613 		(void *)&cmd_config_loopback_specific_id,
1614 		(void *)&cmd_config_loopback_specific_item,
1615 		(void *)&cmd_config_loopback_specific_mode,
1616 		NULL,
1617 	},
1618 };
1619 
1620 /* *** configure txq/rxq, txd/rxd *** */
1621 struct cmd_config_rx_tx {
1622 	cmdline_fixed_string_t port;
1623 	cmdline_fixed_string_t keyword;
1624 	cmdline_fixed_string_t all;
1625 	cmdline_fixed_string_t name;
1626 	uint16_t value;
1627 };
1628 
1629 static void
1630 cmd_config_rx_tx_parsed(void *parsed_result,
1631 			__attribute__((unused)) struct cmdline *cl,
1632 			__attribute__((unused)) void *data)
1633 {
1634 	struct cmd_config_rx_tx *res = parsed_result;
1635 
1636 	if (!all_ports_stopped()) {
1637 		printf("Please stop all ports first\n");
1638 		return;
1639 	}
1640 	if (!strcmp(res->name, "rxq")) {
1641 		if (!res->value && !nb_txq) {
1642 			printf("Warning: Either rx or tx queues should be non zero\n");
1643 			return;
1644 		}
1645 		if (check_nb_rxq(res->value) != 0)
1646 			return;
1647 		nb_rxq = res->value;
1648 	}
1649 	else if (!strcmp(res->name, "txq")) {
1650 		if (!res->value && !nb_rxq) {
1651 			printf("Warning: Either rx or tx queues should be non zero\n");
1652 			return;
1653 		}
1654 		if (check_nb_txq(res->value) != 0)
1655 			return;
1656 		nb_txq = res->value;
1657 	}
1658 	else if (!strcmp(res->name, "rxd")) {
1659 		if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1660 			printf("rxd %d invalid - must be > 0 && <= %d\n",
1661 					res->value, RTE_TEST_RX_DESC_MAX);
1662 			return;
1663 		}
1664 		nb_rxd = res->value;
1665 	} else if (!strcmp(res->name, "txd")) {
1666 		if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1667 			printf("txd %d invalid - must be > 0 && <= %d\n",
1668 					res->value, RTE_TEST_TX_DESC_MAX);
1669 			return;
1670 		}
1671 		nb_txd = res->value;
1672 	} else {
1673 		printf("Unknown parameter\n");
1674 		return;
1675 	}
1676 
1677 	fwd_config_setup();
1678 
1679 	init_port_config();
1680 
1681 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1682 }
1683 
1684 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1685 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1686 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1687 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1688 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1689 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1690 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1691 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1692 						"rxq#txq#rxd#txd");
1693 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1694 	TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1695 
1696 cmdline_parse_inst_t cmd_config_rx_tx = {
1697 	.f = cmd_config_rx_tx_parsed,
1698 	.data = NULL,
1699 	.help_str = "port config all rxq|txq|rxd|txd <value>",
1700 	.tokens = {
1701 		(void *)&cmd_config_rx_tx_port,
1702 		(void *)&cmd_config_rx_tx_keyword,
1703 		(void *)&cmd_config_rx_tx_all,
1704 		(void *)&cmd_config_rx_tx_name,
1705 		(void *)&cmd_config_rx_tx_value,
1706 		NULL,
1707 	},
1708 };
1709 
1710 /* *** config max packet length *** */
1711 struct cmd_config_max_pkt_len_result {
1712 	cmdline_fixed_string_t port;
1713 	cmdline_fixed_string_t keyword;
1714 	cmdline_fixed_string_t all;
1715 	cmdline_fixed_string_t name;
1716 	uint32_t value;
1717 };
1718 
1719 static void
1720 cmd_config_max_pkt_len_parsed(void *parsed_result,
1721 				__attribute__((unused)) struct cmdline *cl,
1722 				__attribute__((unused)) void *data)
1723 {
1724 	struct cmd_config_max_pkt_len_result *res = parsed_result;
1725 	portid_t pid;
1726 
1727 	if (!all_ports_stopped()) {
1728 		printf("Please stop all ports first\n");
1729 		return;
1730 	}
1731 
1732 	RTE_ETH_FOREACH_DEV(pid) {
1733 		struct rte_port *port = &ports[pid];
1734 		uint64_t rx_offloads = port->dev_conf.rxmode.offloads;
1735 
1736 		if (!strcmp(res->name, "max-pkt-len")) {
1737 			if (res->value < ETHER_MIN_LEN) {
1738 				printf("max-pkt-len can not be less than %d\n",
1739 						ETHER_MIN_LEN);
1740 				return;
1741 			}
1742 			if (res->value == port->dev_conf.rxmode.max_rx_pkt_len)
1743 				return;
1744 
1745 			port->dev_conf.rxmode.max_rx_pkt_len = res->value;
1746 			if (res->value > ETHER_MAX_LEN)
1747 				rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
1748 			else
1749 				rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
1750 			port->dev_conf.rxmode.offloads = rx_offloads;
1751 		} else {
1752 			printf("Unknown parameter\n");
1753 			return;
1754 		}
1755 	}
1756 
1757 	init_port_config();
1758 
1759 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1760 }
1761 
1762 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1763 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1764 								"port");
1765 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1766 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1767 								"config");
1768 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1769 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1770 								"all");
1771 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1772 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1773 								"max-pkt-len");
1774 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1775 	TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1776 								UINT32);
1777 
1778 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1779 	.f = cmd_config_max_pkt_len_parsed,
1780 	.data = NULL,
1781 	.help_str = "port config all max-pkt-len <value>",
1782 	.tokens = {
1783 		(void *)&cmd_config_max_pkt_len_port,
1784 		(void *)&cmd_config_max_pkt_len_keyword,
1785 		(void *)&cmd_config_max_pkt_len_all,
1786 		(void *)&cmd_config_max_pkt_len_name,
1787 		(void *)&cmd_config_max_pkt_len_value,
1788 		NULL,
1789 	},
1790 };
1791 
1792 /* *** configure port MTU *** */
1793 struct cmd_config_mtu_result {
1794 	cmdline_fixed_string_t port;
1795 	cmdline_fixed_string_t keyword;
1796 	cmdline_fixed_string_t mtu;
1797 	portid_t port_id;
1798 	uint16_t value;
1799 };
1800 
1801 static void
1802 cmd_config_mtu_parsed(void *parsed_result,
1803 		      __attribute__((unused)) struct cmdline *cl,
1804 		      __attribute__((unused)) void *data)
1805 {
1806 	struct cmd_config_mtu_result *res = parsed_result;
1807 
1808 	if (res->value < ETHER_MIN_LEN) {
1809 		printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1810 		return;
1811 	}
1812 	port_mtu_set(res->port_id, res->value);
1813 }
1814 
1815 cmdline_parse_token_string_t cmd_config_mtu_port =
1816 	TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1817 				 "port");
1818 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1819 	TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1820 				 "config");
1821 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1822 	TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1823 				 "mtu");
1824 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1825 	TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT16);
1826 cmdline_parse_token_num_t cmd_config_mtu_value =
1827 	TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1828 
1829 cmdline_parse_inst_t cmd_config_mtu = {
1830 	.f = cmd_config_mtu_parsed,
1831 	.data = NULL,
1832 	.help_str = "port config mtu <port_id> <value>",
1833 	.tokens = {
1834 		(void *)&cmd_config_mtu_port,
1835 		(void *)&cmd_config_mtu_keyword,
1836 		(void *)&cmd_config_mtu_mtu,
1837 		(void *)&cmd_config_mtu_port_id,
1838 		(void *)&cmd_config_mtu_value,
1839 		NULL,
1840 	},
1841 };
1842 
1843 /* *** configure rx mode *** */
1844 struct cmd_config_rx_mode_flag {
1845 	cmdline_fixed_string_t port;
1846 	cmdline_fixed_string_t keyword;
1847 	cmdline_fixed_string_t all;
1848 	cmdline_fixed_string_t name;
1849 	cmdline_fixed_string_t value;
1850 };
1851 
1852 static void
1853 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1854 				__attribute__((unused)) struct cmdline *cl,
1855 				__attribute__((unused)) void *data)
1856 {
1857 	struct cmd_config_rx_mode_flag *res = parsed_result;
1858 	portid_t pid;
1859 
1860 	if (!all_ports_stopped()) {
1861 		printf("Please stop all ports first\n");
1862 		return;
1863 	}
1864 
1865 	RTE_ETH_FOREACH_DEV(pid) {
1866 		struct rte_port *port;
1867 		uint64_t rx_offloads;
1868 
1869 		port = &ports[pid];
1870 		rx_offloads = port->dev_conf.rxmode.offloads;
1871 		if (!strcmp(res->name, "crc-strip")) {
1872 			if (!strcmp(res->value, "on"))
1873 				rx_offloads |= DEV_RX_OFFLOAD_CRC_STRIP;
1874 			else if (!strcmp(res->value, "off"))
1875 				rx_offloads &= ~DEV_RX_OFFLOAD_CRC_STRIP;
1876 			else {
1877 				printf("Unknown parameter\n");
1878 				return;
1879 			}
1880 		} else if (!strcmp(res->name, "scatter")) {
1881 			if (!strcmp(res->value, "on")) {
1882 				rx_offloads |= DEV_RX_OFFLOAD_SCATTER;
1883 			} else if (!strcmp(res->value, "off")) {
1884 				rx_offloads &= ~DEV_RX_OFFLOAD_SCATTER;
1885 			} else {
1886 				printf("Unknown parameter\n");
1887 				return;
1888 			}
1889 		} else if (!strcmp(res->name, "rx-cksum")) {
1890 			if (!strcmp(res->value, "on"))
1891 				rx_offloads |= DEV_RX_OFFLOAD_CHECKSUM;
1892 			else if (!strcmp(res->value, "off"))
1893 				rx_offloads &= ~DEV_RX_OFFLOAD_CHECKSUM;
1894 			else {
1895 				printf("Unknown parameter\n");
1896 				return;
1897 			}
1898 		} else if (!strcmp(res->name, "rx-timestamp")) {
1899 			if (!strcmp(res->value, "on"))
1900 				rx_offloads |= DEV_RX_OFFLOAD_TIMESTAMP;
1901 			else if (!strcmp(res->value, "off"))
1902 				rx_offloads &= ~DEV_RX_OFFLOAD_TIMESTAMP;
1903 			else {
1904 				printf("Unknown parameter\n");
1905 				return;
1906 			}
1907 		} else if (!strcmp(res->name, "hw-vlan")) {
1908 			if (!strcmp(res->value, "on")) {
1909 				rx_offloads |= (DEV_RX_OFFLOAD_VLAN_FILTER |
1910 						DEV_RX_OFFLOAD_VLAN_STRIP);
1911 			} else if (!strcmp(res->value, "off")) {
1912 				rx_offloads &= ~(DEV_RX_OFFLOAD_VLAN_FILTER |
1913 						DEV_RX_OFFLOAD_VLAN_STRIP);
1914 			} else {
1915 				printf("Unknown parameter\n");
1916 				return;
1917 			}
1918 		} else if (!strcmp(res->name, "hw-vlan-filter")) {
1919 			if (!strcmp(res->value, "on"))
1920 				rx_offloads |= DEV_RX_OFFLOAD_VLAN_FILTER;
1921 			else if (!strcmp(res->value, "off"))
1922 				rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_FILTER;
1923 			else {
1924 				printf("Unknown parameter\n");
1925 				return;
1926 			}
1927 		} else if (!strcmp(res->name, "hw-vlan-strip")) {
1928 			if (!strcmp(res->value, "on"))
1929 				rx_offloads |= DEV_RX_OFFLOAD_VLAN_STRIP;
1930 			else if (!strcmp(res->value, "off"))
1931 				rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_STRIP;
1932 			else {
1933 				printf("Unknown parameter\n");
1934 				return;
1935 			}
1936 		} else if (!strcmp(res->name, "hw-vlan-extend")) {
1937 			if (!strcmp(res->value, "on"))
1938 				rx_offloads |= DEV_RX_OFFLOAD_VLAN_EXTEND;
1939 			else if (!strcmp(res->value, "off"))
1940 				rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_EXTEND;
1941 			else {
1942 				printf("Unknown parameter\n");
1943 				return;
1944 			}
1945 		} else if (!strcmp(res->name, "drop-en")) {
1946 			if (!strcmp(res->value, "on"))
1947 				rx_drop_en = 1;
1948 			else if (!strcmp(res->value, "off"))
1949 				rx_drop_en = 0;
1950 			else {
1951 				printf("Unknown parameter\n");
1952 				return;
1953 			}
1954 		} else {
1955 			printf("Unknown parameter\n");
1956 			return;
1957 		}
1958 		port->dev_conf.rxmode.offloads = rx_offloads;
1959 	}
1960 
1961 	init_port_config();
1962 
1963 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1964 }
1965 
1966 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1967 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1968 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1969 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1970 								"config");
1971 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1972 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1973 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1974 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1975 					"crc-strip#scatter#rx-cksum#rx-timestamp#hw-vlan#"
1976 					"hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
1977 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1978 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1979 							"on#off");
1980 
1981 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1982 	.f = cmd_config_rx_mode_flag_parsed,
1983 	.data = NULL,
1984 	.help_str = "port config all crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|"
1985 		"hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
1986 	.tokens = {
1987 		(void *)&cmd_config_rx_mode_flag_port,
1988 		(void *)&cmd_config_rx_mode_flag_keyword,
1989 		(void *)&cmd_config_rx_mode_flag_all,
1990 		(void *)&cmd_config_rx_mode_flag_name,
1991 		(void *)&cmd_config_rx_mode_flag_value,
1992 		NULL,
1993 	},
1994 };
1995 
1996 /* *** configure rss *** */
1997 struct cmd_config_rss {
1998 	cmdline_fixed_string_t port;
1999 	cmdline_fixed_string_t keyword;
2000 	cmdline_fixed_string_t all;
2001 	cmdline_fixed_string_t name;
2002 	cmdline_fixed_string_t value;
2003 };
2004 
2005 static void
2006 cmd_config_rss_parsed(void *parsed_result,
2007 			__attribute__((unused)) struct cmdline *cl,
2008 			__attribute__((unused)) void *data)
2009 {
2010 	struct cmd_config_rss *res = parsed_result;
2011 	struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2012 	struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2013 	int use_default = 0;
2014 	int all_updated = 1;
2015 	int diag;
2016 	uint16_t i;
2017 
2018 	if (!strcmp(res->value, "all"))
2019 		rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
2020 				ETH_RSS_UDP | ETH_RSS_SCTP |
2021 					ETH_RSS_L2_PAYLOAD;
2022 	else if (!strcmp(res->value, "ip"))
2023 		rss_conf.rss_hf = ETH_RSS_IP;
2024 	else if (!strcmp(res->value, "udp"))
2025 		rss_conf.rss_hf = ETH_RSS_UDP;
2026 	else if (!strcmp(res->value, "tcp"))
2027 		rss_conf.rss_hf = ETH_RSS_TCP;
2028 	else if (!strcmp(res->value, "sctp"))
2029 		rss_conf.rss_hf = ETH_RSS_SCTP;
2030 	else if (!strcmp(res->value, "ether"))
2031 		rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
2032 	else if (!strcmp(res->value, "port"))
2033 		rss_conf.rss_hf = ETH_RSS_PORT;
2034 	else if (!strcmp(res->value, "vxlan"))
2035 		rss_conf.rss_hf = ETH_RSS_VXLAN;
2036 	else if (!strcmp(res->value, "geneve"))
2037 		rss_conf.rss_hf = ETH_RSS_GENEVE;
2038 	else if (!strcmp(res->value, "nvgre"))
2039 		rss_conf.rss_hf = ETH_RSS_NVGRE;
2040 	else if (!strcmp(res->value, "none"))
2041 		rss_conf.rss_hf = 0;
2042 	else if (!strcmp(res->value, "default"))
2043 		use_default = 1;
2044 	else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2045 						atoi(res->value) < 64)
2046 		rss_conf.rss_hf = 1ULL << atoi(res->value);
2047 	else {
2048 		printf("Unknown parameter\n");
2049 		return;
2050 	}
2051 	rss_conf.rss_key = NULL;
2052 	/* Update global configuration for RSS types. */
2053 	RTE_ETH_FOREACH_DEV(i) {
2054 		if (use_default) {
2055 			rte_eth_dev_info_get(i, &dev_info);
2056 			rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2057 		}
2058 		diag = rte_eth_dev_rss_hash_update(i, &rss_conf);
2059 		if (diag < 0) {
2060 			all_updated = 0;
2061 			printf("Configuration of RSS hash at ethernet port %d "
2062 				"failed with error (%d): %s.\n",
2063 				i, -diag, strerror(-diag));
2064 		}
2065 	}
2066 	if (all_updated && !use_default)
2067 		rss_hf = rss_conf.rss_hf;
2068 }
2069 
2070 cmdline_parse_token_string_t cmd_config_rss_port =
2071 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2072 cmdline_parse_token_string_t cmd_config_rss_keyword =
2073 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2074 cmdline_parse_token_string_t cmd_config_rss_all =
2075 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2076 cmdline_parse_token_string_t cmd_config_rss_name =
2077 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2078 cmdline_parse_token_string_t cmd_config_rss_value =
2079 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2080 
2081 cmdline_parse_inst_t cmd_config_rss = {
2082 	.f = cmd_config_rss_parsed,
2083 	.data = NULL,
2084 	.help_str = "port config all rss "
2085 		"all|default|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none|<flowtype_id>",
2086 	.tokens = {
2087 		(void *)&cmd_config_rss_port,
2088 		(void *)&cmd_config_rss_keyword,
2089 		(void *)&cmd_config_rss_all,
2090 		(void *)&cmd_config_rss_name,
2091 		(void *)&cmd_config_rss_value,
2092 		NULL,
2093 	},
2094 };
2095 
2096 /* *** configure rss hash key *** */
2097 struct cmd_config_rss_hash_key {
2098 	cmdline_fixed_string_t port;
2099 	cmdline_fixed_string_t config;
2100 	portid_t port_id;
2101 	cmdline_fixed_string_t rss_hash_key;
2102 	cmdline_fixed_string_t rss_type;
2103 	cmdline_fixed_string_t key;
2104 };
2105 
2106 static uint8_t
2107 hexa_digit_to_value(char hexa_digit)
2108 {
2109 	if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2110 		return (uint8_t) (hexa_digit - '0');
2111 	if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2112 		return (uint8_t) ((hexa_digit - 'a') + 10);
2113 	if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2114 		return (uint8_t) ((hexa_digit - 'A') + 10);
2115 	/* Invalid hexa digit */
2116 	return 0xFF;
2117 }
2118 
2119 static uint8_t
2120 parse_and_check_key_hexa_digit(char *key, int idx)
2121 {
2122 	uint8_t hexa_v;
2123 
2124 	hexa_v = hexa_digit_to_value(key[idx]);
2125 	if (hexa_v == 0xFF)
2126 		printf("invalid key: character %c at position %d is not a "
2127 		       "valid hexa digit\n", key[idx], idx);
2128 	return hexa_v;
2129 }
2130 
2131 static void
2132 cmd_config_rss_hash_key_parsed(void *parsed_result,
2133 			       __attribute__((unused)) struct cmdline *cl,
2134 			       __attribute__((unused)) void *data)
2135 {
2136 	struct cmd_config_rss_hash_key *res = parsed_result;
2137 	uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2138 	uint8_t xdgt0;
2139 	uint8_t xdgt1;
2140 	int i;
2141 	struct rte_eth_dev_info dev_info;
2142 	uint8_t hash_key_size;
2143 	uint32_t key_len;
2144 
2145 	memset(&dev_info, 0, sizeof(dev_info));
2146 	rte_eth_dev_info_get(res->port_id, &dev_info);
2147 	if (dev_info.hash_key_size > 0 &&
2148 			dev_info.hash_key_size <= sizeof(hash_key))
2149 		hash_key_size = dev_info.hash_key_size;
2150 	else {
2151 		printf("dev_info did not provide a valid hash key size\n");
2152 		return;
2153 	}
2154 	/* Check the length of the RSS hash key */
2155 	key_len = strlen(res->key);
2156 	if (key_len != (hash_key_size * 2)) {
2157 		printf("key length: %d invalid - key must be a string of %d"
2158 			   " hexa-decimal numbers\n",
2159 			   (int) key_len, hash_key_size * 2);
2160 		return;
2161 	}
2162 	/* Translate RSS hash key into binary representation */
2163 	for (i = 0; i < hash_key_size; i++) {
2164 		xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2165 		if (xdgt0 == 0xFF)
2166 			return;
2167 		xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2168 		if (xdgt1 == 0xFF)
2169 			return;
2170 		hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2171 	}
2172 	port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2173 			hash_key_size);
2174 }
2175 
2176 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2177 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2178 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2179 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2180 				 "config");
2181 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2182 	TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16);
2183 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2184 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2185 				 rss_hash_key, "rss-hash-key");
2186 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2187 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2188 				 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2189 				 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2190 				 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2191 				 "ipv6-tcp-ex#ipv6-udp-ex");
2192 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2193 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2194 
2195 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2196 	.f = cmd_config_rss_hash_key_parsed,
2197 	.data = NULL,
2198 	.help_str = "port config <port_id> rss-hash-key "
2199 		"ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2200 		"ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2201 		"l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex "
2202 		"<string of hex digits (variable length, NIC dependent)>",
2203 	.tokens = {
2204 		(void *)&cmd_config_rss_hash_key_port,
2205 		(void *)&cmd_config_rss_hash_key_config,
2206 		(void *)&cmd_config_rss_hash_key_port_id,
2207 		(void *)&cmd_config_rss_hash_key_rss_hash_key,
2208 		(void *)&cmd_config_rss_hash_key_rss_type,
2209 		(void *)&cmd_config_rss_hash_key_value,
2210 		NULL,
2211 	},
2212 };
2213 
2214 /* *** configure port rxq/txq ring size *** */
2215 struct cmd_config_rxtx_ring_size {
2216 	cmdline_fixed_string_t port;
2217 	cmdline_fixed_string_t config;
2218 	portid_t portid;
2219 	cmdline_fixed_string_t rxtxq;
2220 	uint16_t qid;
2221 	cmdline_fixed_string_t rsize;
2222 	uint16_t size;
2223 };
2224 
2225 static void
2226 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2227 				 __attribute__((unused)) struct cmdline *cl,
2228 				 __attribute__((unused)) void *data)
2229 {
2230 	struct cmd_config_rxtx_ring_size *res = parsed_result;
2231 	struct rte_port *port;
2232 	uint8_t isrx;
2233 
2234 	if (port_id_is_invalid(res->portid, ENABLED_WARN))
2235 		return;
2236 
2237 	if (res->portid == (portid_t)RTE_PORT_ALL) {
2238 		printf("Invalid port id\n");
2239 		return;
2240 	}
2241 
2242 	port = &ports[res->portid];
2243 
2244 	if (!strcmp(res->rxtxq, "rxq"))
2245 		isrx = 1;
2246 	else if (!strcmp(res->rxtxq, "txq"))
2247 		isrx = 0;
2248 	else {
2249 		printf("Unknown parameter\n");
2250 		return;
2251 	}
2252 
2253 	if (isrx && rx_queue_id_is_invalid(res->qid))
2254 		return;
2255 	else if (!isrx && tx_queue_id_is_invalid(res->qid))
2256 		return;
2257 
2258 	if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2259 		printf("Invalid rx ring_size, must > rx_free_thresh: %d\n",
2260 		       rx_free_thresh);
2261 		return;
2262 	}
2263 
2264 	if (isrx)
2265 		port->nb_rx_desc[res->qid] = res->size;
2266 	else
2267 		port->nb_tx_desc[res->qid] = res->size;
2268 
2269 	cmd_reconfig_device_queue(res->portid, 0, 1);
2270 }
2271 
2272 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2273 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2274 				 port, "port");
2275 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2276 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2277 				 config, "config");
2278 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2279 	TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2280 				 portid, UINT16);
2281 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2282 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2283 				 rxtxq, "rxq#txq");
2284 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2285 	TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2286 			      qid, UINT16);
2287 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2288 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2289 				 rsize, "ring_size");
2290 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2291 	TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2292 			      size, UINT16);
2293 
2294 cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2295 	.f = cmd_config_rxtx_ring_size_parsed,
2296 	.data = NULL,
2297 	.help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2298 	.tokens = {
2299 		(void *)&cmd_config_rxtx_ring_size_port,
2300 		(void *)&cmd_config_rxtx_ring_size_config,
2301 		(void *)&cmd_config_rxtx_ring_size_portid,
2302 		(void *)&cmd_config_rxtx_ring_size_rxtxq,
2303 		(void *)&cmd_config_rxtx_ring_size_qid,
2304 		(void *)&cmd_config_rxtx_ring_size_rsize,
2305 		(void *)&cmd_config_rxtx_ring_size_size,
2306 		NULL,
2307 	},
2308 };
2309 
2310 /* *** configure port rxq/txq start/stop *** */
2311 struct cmd_config_rxtx_queue {
2312 	cmdline_fixed_string_t port;
2313 	portid_t portid;
2314 	cmdline_fixed_string_t rxtxq;
2315 	uint16_t qid;
2316 	cmdline_fixed_string_t opname;
2317 };
2318 
2319 static void
2320 cmd_config_rxtx_queue_parsed(void *parsed_result,
2321 			__attribute__((unused)) struct cmdline *cl,
2322 			__attribute__((unused)) void *data)
2323 {
2324 	struct cmd_config_rxtx_queue *res = parsed_result;
2325 	uint8_t isrx;
2326 	uint8_t isstart;
2327 	int ret = 0;
2328 
2329 	if (test_done == 0) {
2330 		printf("Please stop forwarding first\n");
2331 		return;
2332 	}
2333 
2334 	if (port_id_is_invalid(res->portid, ENABLED_WARN))
2335 		return;
2336 
2337 	if (port_is_started(res->portid) != 1) {
2338 		printf("Please start port %u first\n", res->portid);
2339 		return;
2340 	}
2341 
2342 	if (!strcmp(res->rxtxq, "rxq"))
2343 		isrx = 1;
2344 	else if (!strcmp(res->rxtxq, "txq"))
2345 		isrx = 0;
2346 	else {
2347 		printf("Unknown parameter\n");
2348 		return;
2349 	}
2350 
2351 	if (isrx && rx_queue_id_is_invalid(res->qid))
2352 		return;
2353 	else if (!isrx && tx_queue_id_is_invalid(res->qid))
2354 		return;
2355 
2356 	if (!strcmp(res->opname, "start"))
2357 		isstart = 1;
2358 	else if (!strcmp(res->opname, "stop"))
2359 		isstart = 0;
2360 	else {
2361 		printf("Unknown parameter\n");
2362 		return;
2363 	}
2364 
2365 	if (isstart && isrx)
2366 		ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2367 	else if (!isstart && isrx)
2368 		ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2369 	else if (isstart && !isrx)
2370 		ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2371 	else
2372 		ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2373 
2374 	if (ret == -ENOTSUP)
2375 		printf("Function not supported in PMD driver\n");
2376 }
2377 
2378 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2379 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2380 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2381 	TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16);
2382 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2383 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2384 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2385 	TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
2386 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2387 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2388 						"start#stop");
2389 
2390 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2391 	.f = cmd_config_rxtx_queue_parsed,
2392 	.data = NULL,
2393 	.help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2394 	.tokens = {
2395 		(void *)&cmd_config_rxtx_queue_port,
2396 		(void *)&cmd_config_rxtx_queue_portid,
2397 		(void *)&cmd_config_rxtx_queue_rxtxq,
2398 		(void *)&cmd_config_rxtx_queue_qid,
2399 		(void *)&cmd_config_rxtx_queue_opname,
2400 		NULL,
2401 	},
2402 };
2403 
2404 /* *** configure port rxq/txq setup *** */
2405 struct cmd_setup_rxtx_queue {
2406 	cmdline_fixed_string_t port;
2407 	portid_t portid;
2408 	cmdline_fixed_string_t rxtxq;
2409 	uint16_t qid;
2410 	cmdline_fixed_string_t setup;
2411 };
2412 
2413 /* Common CLI fields for queue setup */
2414 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2415 	TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2416 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2417 	TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, UINT16);
2418 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2419 	TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2420 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2421 	TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, UINT16);
2422 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2423 	TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2424 
2425 static void
2426 cmd_setup_rxtx_queue_parsed(
2427 	void *parsed_result,
2428 	__attribute__((unused)) struct cmdline *cl,
2429 	__attribute__((unused)) void *data)
2430 {
2431 	struct cmd_setup_rxtx_queue *res = parsed_result;
2432 	struct rte_port *port;
2433 	struct rte_mempool *mp;
2434 	unsigned int socket_id;
2435 	uint8_t isrx = 0;
2436 	int ret;
2437 
2438 	if (port_id_is_invalid(res->portid, ENABLED_WARN))
2439 		return;
2440 
2441 	if (res->portid == (portid_t)RTE_PORT_ALL) {
2442 		printf("Invalid port id\n");
2443 		return;
2444 	}
2445 
2446 	if (!strcmp(res->rxtxq, "rxq"))
2447 		isrx = 1;
2448 	else if (!strcmp(res->rxtxq, "txq"))
2449 		isrx = 0;
2450 	else {
2451 		printf("Unknown parameter\n");
2452 		return;
2453 	}
2454 
2455 	if (isrx && rx_queue_id_is_invalid(res->qid)) {
2456 		printf("Invalid rx queue\n");
2457 		return;
2458 	} else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2459 		printf("Invalid tx queue\n");
2460 		return;
2461 	}
2462 
2463 	port = &ports[res->portid];
2464 	if (isrx) {
2465 		socket_id = rxring_numa[res->portid];
2466 		if (!numa_support || socket_id == NUMA_NO_CONFIG)
2467 			socket_id = port->socket_id;
2468 
2469 		mp = mbuf_pool_find(socket_id);
2470 		if (mp == NULL) {
2471 			printf("Failed to setup RX queue: "
2472 				"No mempool allocation"
2473 				" on the socket %d\n",
2474 				rxring_numa[res->portid]);
2475 			return;
2476 		}
2477 		ret = rte_eth_rx_queue_setup(res->portid,
2478 					     res->qid,
2479 					     port->nb_rx_desc[res->qid],
2480 					     socket_id,
2481 					     &port->rx_conf[res->qid],
2482 					     mp);
2483 		if (ret)
2484 			printf("Failed to setup RX queue\n");
2485 	} else {
2486 		socket_id = txring_numa[res->portid];
2487 		if (!numa_support || socket_id == NUMA_NO_CONFIG)
2488 			socket_id = port->socket_id;
2489 
2490 		ret = rte_eth_tx_queue_setup(res->portid,
2491 					     res->qid,
2492 					     port->nb_tx_desc[res->qid],
2493 					     socket_id,
2494 					     &port->tx_conf[res->qid]);
2495 		if (ret)
2496 			printf("Failed to setup TX queue\n");
2497 	}
2498 }
2499 
2500 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2501 	.f = cmd_setup_rxtx_queue_parsed,
2502 	.data = NULL,
2503 	.help_str = "port <port_id> rxq|txq <queue_idx> setup",
2504 	.tokens = {
2505 		(void *)&cmd_setup_rxtx_queue_port,
2506 		(void *)&cmd_setup_rxtx_queue_portid,
2507 		(void *)&cmd_setup_rxtx_queue_rxtxq,
2508 		(void *)&cmd_setup_rxtx_queue_qid,
2509 		(void *)&cmd_setup_rxtx_queue_setup,
2510 		NULL,
2511 	},
2512 };
2513 
2514 
2515 /* *** Configure RSS RETA *** */
2516 struct cmd_config_rss_reta {
2517 	cmdline_fixed_string_t port;
2518 	cmdline_fixed_string_t keyword;
2519 	portid_t port_id;
2520 	cmdline_fixed_string_t name;
2521 	cmdline_fixed_string_t list_name;
2522 	cmdline_fixed_string_t list_of_items;
2523 };
2524 
2525 static int
2526 parse_reta_config(const char *str,
2527 		  struct rte_eth_rss_reta_entry64 *reta_conf,
2528 		  uint16_t nb_entries)
2529 {
2530 	int i;
2531 	unsigned size;
2532 	uint16_t hash_index, idx, shift;
2533 	uint16_t nb_queue;
2534 	char s[256];
2535 	const char *p, *p0 = str;
2536 	char *end;
2537 	enum fieldnames {
2538 		FLD_HASH_INDEX = 0,
2539 		FLD_QUEUE,
2540 		_NUM_FLD
2541 	};
2542 	unsigned long int_fld[_NUM_FLD];
2543 	char *str_fld[_NUM_FLD];
2544 
2545 	while ((p = strchr(p0,'(')) != NULL) {
2546 		++p;
2547 		if((p0 = strchr(p,')')) == NULL)
2548 			return -1;
2549 
2550 		size = p0 - p;
2551 		if(size >= sizeof(s))
2552 			return -1;
2553 
2554 		snprintf(s, sizeof(s), "%.*s", size, p);
2555 		if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2556 			return -1;
2557 		for (i = 0; i < _NUM_FLD; i++) {
2558 			errno = 0;
2559 			int_fld[i] = strtoul(str_fld[i], &end, 0);
2560 			if (errno != 0 || end == str_fld[i] ||
2561 					int_fld[i] > 65535)
2562 				return -1;
2563 		}
2564 
2565 		hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2566 		nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2567 
2568 		if (hash_index >= nb_entries) {
2569 			printf("Invalid RETA hash index=%d\n", hash_index);
2570 			return -1;
2571 		}
2572 
2573 		idx = hash_index / RTE_RETA_GROUP_SIZE;
2574 		shift = hash_index % RTE_RETA_GROUP_SIZE;
2575 		reta_conf[idx].mask |= (1ULL << shift);
2576 		reta_conf[idx].reta[shift] = nb_queue;
2577 	}
2578 
2579 	return 0;
2580 }
2581 
2582 static void
2583 cmd_set_rss_reta_parsed(void *parsed_result,
2584 			__attribute__((unused)) struct cmdline *cl,
2585 			__attribute__((unused)) void *data)
2586 {
2587 	int ret;
2588 	struct rte_eth_dev_info dev_info;
2589 	struct rte_eth_rss_reta_entry64 reta_conf[8];
2590 	struct cmd_config_rss_reta *res = parsed_result;
2591 
2592 	memset(&dev_info, 0, sizeof(dev_info));
2593 	rte_eth_dev_info_get(res->port_id, &dev_info);
2594 	if (dev_info.reta_size == 0) {
2595 		printf("Redirection table size is 0 which is "
2596 					"invalid for RSS\n");
2597 		return;
2598 	} else
2599 		printf("The reta size of port %d is %u\n",
2600 			res->port_id, dev_info.reta_size);
2601 	if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2602 		printf("Currently do not support more than %u entries of "
2603 			"redirection table\n", ETH_RSS_RETA_SIZE_512);
2604 		return;
2605 	}
2606 
2607 	memset(reta_conf, 0, sizeof(reta_conf));
2608 	if (!strcmp(res->list_name, "reta")) {
2609 		if (parse_reta_config(res->list_of_items, reta_conf,
2610 						dev_info.reta_size)) {
2611 			printf("Invalid RSS Redirection Table "
2612 					"config entered\n");
2613 			return;
2614 		}
2615 		ret = rte_eth_dev_rss_reta_update(res->port_id,
2616 				reta_conf, dev_info.reta_size);
2617 		if (ret != 0)
2618 			printf("Bad redirection table parameter, "
2619 					"return code = %d \n", ret);
2620 	}
2621 }
2622 
2623 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2624 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2625 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2626 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2627 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2628 	TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16);
2629 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2630 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2631 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2632 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2633 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2634         TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2635                                  NULL);
2636 cmdline_parse_inst_t cmd_config_rss_reta = {
2637 	.f = cmd_set_rss_reta_parsed,
2638 	.data = NULL,
2639 	.help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2640 	.tokens = {
2641 		(void *)&cmd_config_rss_reta_port,
2642 		(void *)&cmd_config_rss_reta_keyword,
2643 		(void *)&cmd_config_rss_reta_port_id,
2644 		(void *)&cmd_config_rss_reta_name,
2645 		(void *)&cmd_config_rss_reta_list_name,
2646 		(void *)&cmd_config_rss_reta_list_of_items,
2647 		NULL,
2648 	},
2649 };
2650 
2651 /* *** SHOW PORT RETA INFO *** */
2652 struct cmd_showport_reta {
2653 	cmdline_fixed_string_t show;
2654 	cmdline_fixed_string_t port;
2655 	portid_t port_id;
2656 	cmdline_fixed_string_t rss;
2657 	cmdline_fixed_string_t reta;
2658 	uint16_t size;
2659 	cmdline_fixed_string_t list_of_items;
2660 };
2661 
2662 static int
2663 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2664 			   uint16_t nb_entries,
2665 			   char *str)
2666 {
2667 	uint32_t size;
2668 	const char *p, *p0 = str;
2669 	char s[256];
2670 	char *end;
2671 	char *str_fld[8];
2672 	uint16_t i;
2673 	uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
2674 			RTE_RETA_GROUP_SIZE;
2675 	int ret;
2676 
2677 	p = strchr(p0, '(');
2678 	if (p == NULL)
2679 		return -1;
2680 	p++;
2681 	p0 = strchr(p, ')');
2682 	if (p0 == NULL)
2683 		return -1;
2684 	size = p0 - p;
2685 	if (size >= sizeof(s)) {
2686 		printf("The string size exceeds the internal buffer size\n");
2687 		return -1;
2688 	}
2689 	snprintf(s, sizeof(s), "%.*s", size, p);
2690 	ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
2691 	if (ret <= 0 || ret != num) {
2692 		printf("The bits of masks do not match the number of "
2693 					"reta entries: %u\n", num);
2694 		return -1;
2695 	}
2696 	for (i = 0; i < ret; i++)
2697 		conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
2698 
2699 	return 0;
2700 }
2701 
2702 static void
2703 cmd_showport_reta_parsed(void *parsed_result,
2704 			 __attribute__((unused)) struct cmdline *cl,
2705 			 __attribute__((unused)) void *data)
2706 {
2707 	struct cmd_showport_reta *res = parsed_result;
2708 	struct rte_eth_rss_reta_entry64 reta_conf[8];
2709 	struct rte_eth_dev_info dev_info;
2710 	uint16_t max_reta_size;
2711 
2712 	memset(&dev_info, 0, sizeof(dev_info));
2713 	rte_eth_dev_info_get(res->port_id, &dev_info);
2714 	max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
2715 	if (res->size == 0 || res->size > max_reta_size) {
2716 		printf("Invalid redirection table size: %u (1-%u)\n",
2717 			res->size, max_reta_size);
2718 		return;
2719 	}
2720 
2721 	memset(reta_conf, 0, sizeof(reta_conf));
2722 	if (showport_parse_reta_config(reta_conf, res->size,
2723 				res->list_of_items) < 0) {
2724 		printf("Invalid string: %s for reta masks\n",
2725 					res->list_of_items);
2726 		return;
2727 	}
2728 	port_rss_reta_info(res->port_id, reta_conf, res->size);
2729 }
2730 
2731 cmdline_parse_token_string_t cmd_showport_reta_show =
2732 	TOKEN_STRING_INITIALIZER(struct  cmd_showport_reta, show, "show");
2733 cmdline_parse_token_string_t cmd_showport_reta_port =
2734 	TOKEN_STRING_INITIALIZER(struct  cmd_showport_reta, port, "port");
2735 cmdline_parse_token_num_t cmd_showport_reta_port_id =
2736 	TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16);
2737 cmdline_parse_token_string_t cmd_showport_reta_rss =
2738 	TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
2739 cmdline_parse_token_string_t cmd_showport_reta_reta =
2740 	TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
2741 cmdline_parse_token_num_t cmd_showport_reta_size =
2742 	TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
2743 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
2744 	TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
2745 					list_of_items, NULL);
2746 
2747 cmdline_parse_inst_t cmd_showport_reta = {
2748 	.f = cmd_showport_reta_parsed,
2749 	.data = NULL,
2750 	.help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
2751 	.tokens = {
2752 		(void *)&cmd_showport_reta_show,
2753 		(void *)&cmd_showport_reta_port,
2754 		(void *)&cmd_showport_reta_port_id,
2755 		(void *)&cmd_showport_reta_rss,
2756 		(void *)&cmd_showport_reta_reta,
2757 		(void *)&cmd_showport_reta_size,
2758 		(void *)&cmd_showport_reta_list_of_items,
2759 		NULL,
2760 	},
2761 };
2762 
2763 /* *** Show RSS hash configuration *** */
2764 struct cmd_showport_rss_hash {
2765 	cmdline_fixed_string_t show;
2766 	cmdline_fixed_string_t port;
2767 	portid_t port_id;
2768 	cmdline_fixed_string_t rss_hash;
2769 	cmdline_fixed_string_t rss_type;
2770 	cmdline_fixed_string_t key; /* optional argument */
2771 };
2772 
2773 static void cmd_showport_rss_hash_parsed(void *parsed_result,
2774 				__attribute__((unused)) struct cmdline *cl,
2775 				void *show_rss_key)
2776 {
2777 	struct cmd_showport_rss_hash *res = parsed_result;
2778 
2779 	port_rss_hash_conf_show(res->port_id, res->rss_type,
2780 				show_rss_key != NULL);
2781 }
2782 
2783 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
2784 	TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
2785 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
2786 	TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
2787 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
2788 	TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16);
2789 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
2790 	TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
2791 				 "rss-hash");
2792 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash_info =
2793 	TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_type,
2794 				 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2795 				 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2796 				 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2797 				 "ipv6-tcp-ex#ipv6-udp-ex");
2798 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
2799 	TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
2800 
2801 cmdline_parse_inst_t cmd_showport_rss_hash = {
2802 	.f = cmd_showport_rss_hash_parsed,
2803 	.data = NULL,
2804 	.help_str = "show port <port_id> rss-hash "
2805 		"ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2806 		"ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2807 		"l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex",
2808 	.tokens = {
2809 		(void *)&cmd_showport_rss_hash_show,
2810 		(void *)&cmd_showport_rss_hash_port,
2811 		(void *)&cmd_showport_rss_hash_port_id,
2812 		(void *)&cmd_showport_rss_hash_rss_hash,
2813 		(void *)&cmd_showport_rss_hash_rss_hash_info,
2814 		NULL,
2815 	},
2816 };
2817 
2818 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
2819 	.f = cmd_showport_rss_hash_parsed,
2820 	.data = (void *)1,
2821 	.help_str = "show port <port_id> rss-hash "
2822 		"ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2823 		"ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2824 		"l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex key",
2825 	.tokens = {
2826 		(void *)&cmd_showport_rss_hash_show,
2827 		(void *)&cmd_showport_rss_hash_port,
2828 		(void *)&cmd_showport_rss_hash_port_id,
2829 		(void *)&cmd_showport_rss_hash_rss_hash,
2830 		(void *)&cmd_showport_rss_hash_rss_hash_info,
2831 		(void *)&cmd_showport_rss_hash_rss_key,
2832 		NULL,
2833 	},
2834 };
2835 
2836 /* *** Configure DCB *** */
2837 struct cmd_config_dcb {
2838 	cmdline_fixed_string_t port;
2839 	cmdline_fixed_string_t config;
2840 	portid_t port_id;
2841 	cmdline_fixed_string_t dcb;
2842 	cmdline_fixed_string_t vt;
2843 	cmdline_fixed_string_t vt_en;
2844 	uint8_t num_tcs;
2845 	cmdline_fixed_string_t pfc;
2846 	cmdline_fixed_string_t pfc_en;
2847 };
2848 
2849 static void
2850 cmd_config_dcb_parsed(void *parsed_result,
2851                         __attribute__((unused)) struct cmdline *cl,
2852                         __attribute__((unused)) void *data)
2853 {
2854 	struct cmd_config_dcb *res = parsed_result;
2855 	portid_t port_id = res->port_id;
2856 	struct rte_port *port;
2857 	uint8_t pfc_en;
2858 	int ret;
2859 
2860 	port = &ports[port_id];
2861 	/** Check if the port is not started **/
2862 	if (port->port_status != RTE_PORT_STOPPED) {
2863 		printf("Please stop port %d first\n", port_id);
2864 		return;
2865 	}
2866 
2867 	if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
2868 		printf("The invalid number of traffic class,"
2869 			" only 4 or 8 allowed.\n");
2870 		return;
2871 	}
2872 
2873 	if (nb_fwd_lcores < res->num_tcs) {
2874 		printf("nb_cores shouldn't be less than number of TCs.\n");
2875 		return;
2876 	}
2877 	if (!strncmp(res->pfc_en, "on", 2))
2878 		pfc_en = 1;
2879 	else
2880 		pfc_en = 0;
2881 
2882 	/* DCB in VT mode */
2883 	if (!strncmp(res->vt_en, "on", 2))
2884 		ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
2885 				(enum rte_eth_nb_tcs)res->num_tcs,
2886 				pfc_en);
2887 	else
2888 		ret = init_port_dcb_config(port_id, DCB_ENABLED,
2889 				(enum rte_eth_nb_tcs)res->num_tcs,
2890 				pfc_en);
2891 
2892 
2893 	if (ret != 0) {
2894 		printf("Cannot initialize network ports.\n");
2895 		return;
2896 	}
2897 
2898 	cmd_reconfig_device_queue(port_id, 1, 1);
2899 }
2900 
2901 cmdline_parse_token_string_t cmd_config_dcb_port =
2902         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
2903 cmdline_parse_token_string_t cmd_config_dcb_config =
2904         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
2905 cmdline_parse_token_num_t cmd_config_dcb_port_id =
2906 	TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16);
2907 cmdline_parse_token_string_t cmd_config_dcb_dcb =
2908         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
2909 cmdline_parse_token_string_t cmd_config_dcb_vt =
2910         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
2911 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
2912         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
2913 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
2914         TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
2915 cmdline_parse_token_string_t cmd_config_dcb_pfc=
2916         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
2917 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
2918         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
2919 
2920 cmdline_parse_inst_t cmd_config_dcb = {
2921 	.f = cmd_config_dcb_parsed,
2922 	.data = NULL,
2923 	.help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
2924 	.tokens = {
2925 		(void *)&cmd_config_dcb_port,
2926 		(void *)&cmd_config_dcb_config,
2927 		(void *)&cmd_config_dcb_port_id,
2928 		(void *)&cmd_config_dcb_dcb,
2929 		(void *)&cmd_config_dcb_vt,
2930 		(void *)&cmd_config_dcb_vt_en,
2931 		(void *)&cmd_config_dcb_num_tcs,
2932 		(void *)&cmd_config_dcb_pfc,
2933 		(void *)&cmd_config_dcb_pfc_en,
2934                 NULL,
2935         },
2936 };
2937 
2938 /* *** configure number of packets per burst *** */
2939 struct cmd_config_burst {
2940 	cmdline_fixed_string_t port;
2941 	cmdline_fixed_string_t keyword;
2942 	cmdline_fixed_string_t all;
2943 	cmdline_fixed_string_t name;
2944 	uint16_t value;
2945 };
2946 
2947 static void
2948 cmd_config_burst_parsed(void *parsed_result,
2949 			__attribute__((unused)) struct cmdline *cl,
2950 			__attribute__((unused)) void *data)
2951 {
2952 	struct cmd_config_burst *res = parsed_result;
2953 	struct rte_eth_dev_info dev_info;
2954 	uint16_t rec_nb_pkts;
2955 
2956 	if (!all_ports_stopped()) {
2957 		printf("Please stop all ports first\n");
2958 		return;
2959 	}
2960 
2961 	if (!strcmp(res->name, "burst")) {
2962 		if (res->value == 0) {
2963 			/* If user gives a value of zero, query the PMD for
2964 			 * its recommended Rx burst size. Testpmd uses a single
2965 			 * size for all ports, so assume all ports are the same
2966 			 * NIC model and use the values from Port 0.
2967 			 */
2968 			rte_eth_dev_info_get(0, &dev_info);
2969 			rec_nb_pkts = dev_info.default_rxportconf.burst_size;
2970 
2971 			if (rec_nb_pkts == 0) {
2972 				printf("PMD does not recommend a burst size.\n"
2973 					"User provided value must be between"
2974 					" 1 and %d\n", MAX_PKT_BURST);
2975 				return;
2976 			} else if (rec_nb_pkts > MAX_PKT_BURST) {
2977 				printf("PMD recommended burst size of %d"
2978 					" exceeds maximum value of %d\n",
2979 					rec_nb_pkts, MAX_PKT_BURST);
2980 				return;
2981 			}
2982 			printf("Using PMD-provided burst value of %d\n",
2983 				rec_nb_pkts);
2984 			nb_pkt_per_burst = rec_nb_pkts;
2985 		} else if (res->value > MAX_PKT_BURST) {
2986 			printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
2987 			return;
2988 		} else
2989 			nb_pkt_per_burst = res->value;
2990 	} else {
2991 		printf("Unknown parameter\n");
2992 		return;
2993 	}
2994 
2995 	init_port_config();
2996 
2997 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2998 }
2999 
3000 cmdline_parse_token_string_t cmd_config_burst_port =
3001 	TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3002 cmdline_parse_token_string_t cmd_config_burst_keyword =
3003 	TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3004 cmdline_parse_token_string_t cmd_config_burst_all =
3005 	TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3006 cmdline_parse_token_string_t cmd_config_burst_name =
3007 	TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3008 cmdline_parse_token_num_t cmd_config_burst_value =
3009 	TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
3010 
3011 cmdline_parse_inst_t cmd_config_burst = {
3012 	.f = cmd_config_burst_parsed,
3013 	.data = NULL,
3014 	.help_str = "port config all burst <value>",
3015 	.tokens = {
3016 		(void *)&cmd_config_burst_port,
3017 		(void *)&cmd_config_burst_keyword,
3018 		(void *)&cmd_config_burst_all,
3019 		(void *)&cmd_config_burst_name,
3020 		(void *)&cmd_config_burst_value,
3021 		NULL,
3022 	},
3023 };
3024 
3025 /* *** configure rx/tx queues *** */
3026 struct cmd_config_thresh {
3027 	cmdline_fixed_string_t port;
3028 	cmdline_fixed_string_t keyword;
3029 	cmdline_fixed_string_t all;
3030 	cmdline_fixed_string_t name;
3031 	uint8_t value;
3032 };
3033 
3034 static void
3035 cmd_config_thresh_parsed(void *parsed_result,
3036 			__attribute__((unused)) struct cmdline *cl,
3037 			__attribute__((unused)) void *data)
3038 {
3039 	struct cmd_config_thresh *res = parsed_result;
3040 
3041 	if (!all_ports_stopped()) {
3042 		printf("Please stop all ports first\n");
3043 		return;
3044 	}
3045 
3046 	if (!strcmp(res->name, "txpt"))
3047 		tx_pthresh = res->value;
3048 	else if(!strcmp(res->name, "txht"))
3049 		tx_hthresh = res->value;
3050 	else if(!strcmp(res->name, "txwt"))
3051 		tx_wthresh = res->value;
3052 	else if(!strcmp(res->name, "rxpt"))
3053 		rx_pthresh = res->value;
3054 	else if(!strcmp(res->name, "rxht"))
3055 		rx_hthresh = res->value;
3056 	else if(!strcmp(res->name, "rxwt"))
3057 		rx_wthresh = res->value;
3058 	else {
3059 		printf("Unknown parameter\n");
3060 		return;
3061 	}
3062 
3063 	init_port_config();
3064 
3065 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3066 }
3067 
3068 cmdline_parse_token_string_t cmd_config_thresh_port =
3069 	TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3070 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3071 	TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3072 cmdline_parse_token_string_t cmd_config_thresh_all =
3073 	TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3074 cmdline_parse_token_string_t cmd_config_thresh_name =
3075 	TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3076 				"txpt#txht#txwt#rxpt#rxht#rxwt");
3077 cmdline_parse_token_num_t cmd_config_thresh_value =
3078 	TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
3079 
3080 cmdline_parse_inst_t cmd_config_thresh = {
3081 	.f = cmd_config_thresh_parsed,
3082 	.data = NULL,
3083 	.help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3084 	.tokens = {
3085 		(void *)&cmd_config_thresh_port,
3086 		(void *)&cmd_config_thresh_keyword,
3087 		(void *)&cmd_config_thresh_all,
3088 		(void *)&cmd_config_thresh_name,
3089 		(void *)&cmd_config_thresh_value,
3090 		NULL,
3091 	},
3092 };
3093 
3094 /* *** configure free/rs threshold *** */
3095 struct cmd_config_threshold {
3096 	cmdline_fixed_string_t port;
3097 	cmdline_fixed_string_t keyword;
3098 	cmdline_fixed_string_t all;
3099 	cmdline_fixed_string_t name;
3100 	uint16_t value;
3101 };
3102 
3103 static void
3104 cmd_config_threshold_parsed(void *parsed_result,
3105 			__attribute__((unused)) struct cmdline *cl,
3106 			__attribute__((unused)) void *data)
3107 {
3108 	struct cmd_config_threshold *res = parsed_result;
3109 
3110 	if (!all_ports_stopped()) {
3111 		printf("Please stop all ports first\n");
3112 		return;
3113 	}
3114 
3115 	if (!strcmp(res->name, "txfreet"))
3116 		tx_free_thresh = res->value;
3117 	else if (!strcmp(res->name, "txrst"))
3118 		tx_rs_thresh = res->value;
3119 	else if (!strcmp(res->name, "rxfreet"))
3120 		rx_free_thresh = res->value;
3121 	else {
3122 		printf("Unknown parameter\n");
3123 		return;
3124 	}
3125 
3126 	init_port_config();
3127 
3128 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3129 }
3130 
3131 cmdline_parse_token_string_t cmd_config_threshold_port =
3132 	TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3133 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3134 	TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3135 								"config");
3136 cmdline_parse_token_string_t cmd_config_threshold_all =
3137 	TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3138 cmdline_parse_token_string_t cmd_config_threshold_name =
3139 	TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3140 						"txfreet#txrst#rxfreet");
3141 cmdline_parse_token_num_t cmd_config_threshold_value =
3142 	TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
3143 
3144 cmdline_parse_inst_t cmd_config_threshold = {
3145 	.f = cmd_config_threshold_parsed,
3146 	.data = NULL,
3147 	.help_str = "port config all txfreet|txrst|rxfreet <value>",
3148 	.tokens = {
3149 		(void *)&cmd_config_threshold_port,
3150 		(void *)&cmd_config_threshold_keyword,
3151 		(void *)&cmd_config_threshold_all,
3152 		(void *)&cmd_config_threshold_name,
3153 		(void *)&cmd_config_threshold_value,
3154 		NULL,
3155 	},
3156 };
3157 
3158 /* *** stop *** */
3159 struct cmd_stop_result {
3160 	cmdline_fixed_string_t stop;
3161 };
3162 
3163 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
3164 			    __attribute__((unused)) struct cmdline *cl,
3165 			    __attribute__((unused)) void *data)
3166 {
3167 	stop_packet_forwarding();
3168 }
3169 
3170 cmdline_parse_token_string_t cmd_stop_stop =
3171 	TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3172 
3173 cmdline_parse_inst_t cmd_stop = {
3174 	.f = cmd_stop_parsed,
3175 	.data = NULL,
3176 	.help_str = "stop: Stop packet forwarding",
3177 	.tokens = {
3178 		(void *)&cmd_stop_stop,
3179 		NULL,
3180 	},
3181 };
3182 
3183 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3184 
3185 unsigned int
3186 parse_item_list(char* str, const char* item_name, unsigned int max_items,
3187 		unsigned int *parsed_items, int check_unique_values)
3188 {
3189 	unsigned int nb_item;
3190 	unsigned int value;
3191 	unsigned int i;
3192 	unsigned int j;
3193 	int value_ok;
3194 	char c;
3195 
3196 	/*
3197 	 * First parse all items in the list and store their value.
3198 	 */
3199 	value = 0;
3200 	nb_item = 0;
3201 	value_ok = 0;
3202 	for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3203 		c = str[i];
3204 		if ((c >= '0') && (c <= '9')) {
3205 			value = (unsigned int) (value * 10 + (c - '0'));
3206 			value_ok = 1;
3207 			continue;
3208 		}
3209 		if (c != ',') {
3210 			printf("character %c is not a decimal digit\n", c);
3211 			return 0;
3212 		}
3213 		if (! value_ok) {
3214 			printf("No valid value before comma\n");
3215 			return 0;
3216 		}
3217 		if (nb_item < max_items) {
3218 			parsed_items[nb_item] = value;
3219 			value_ok = 0;
3220 			value = 0;
3221 		}
3222 		nb_item++;
3223 	}
3224 	if (nb_item >= max_items) {
3225 		printf("Number of %s = %u > %u (maximum items)\n",
3226 		       item_name, nb_item + 1, max_items);
3227 		return 0;
3228 	}
3229 	parsed_items[nb_item++] = value;
3230 	if (! check_unique_values)
3231 		return nb_item;
3232 
3233 	/*
3234 	 * Then, check that all values in the list are differents.
3235 	 * No optimization here...
3236 	 */
3237 	for (i = 0; i < nb_item; i++) {
3238 		for (j = i + 1; j < nb_item; j++) {
3239 			if (parsed_items[j] == parsed_items[i]) {
3240 				printf("duplicated %s %u at index %u and %u\n",
3241 				       item_name, parsed_items[i], i, j);
3242 				return 0;
3243 			}
3244 		}
3245 	}
3246 	return nb_item;
3247 }
3248 
3249 struct cmd_set_list_result {
3250 	cmdline_fixed_string_t cmd_keyword;
3251 	cmdline_fixed_string_t list_name;
3252 	cmdline_fixed_string_t list_of_items;
3253 };
3254 
3255 static void cmd_set_list_parsed(void *parsed_result,
3256 				__attribute__((unused)) struct cmdline *cl,
3257 				__attribute__((unused)) void *data)
3258 {
3259 	struct cmd_set_list_result *res;
3260 	union {
3261 		unsigned int lcorelist[RTE_MAX_LCORE];
3262 		unsigned int portlist[RTE_MAX_ETHPORTS];
3263 	} parsed_items;
3264 	unsigned int nb_item;
3265 
3266 	if (test_done == 0) {
3267 		printf("Please stop forwarding first\n");
3268 		return;
3269 	}
3270 
3271 	res = parsed_result;
3272 	if (!strcmp(res->list_name, "corelist")) {
3273 		nb_item = parse_item_list(res->list_of_items, "core",
3274 					  RTE_MAX_LCORE,
3275 					  parsed_items.lcorelist, 1);
3276 		if (nb_item > 0) {
3277 			set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3278 			fwd_config_setup();
3279 		}
3280 		return;
3281 	}
3282 	if (!strcmp(res->list_name, "portlist")) {
3283 		nb_item = parse_item_list(res->list_of_items, "port",
3284 					  RTE_MAX_ETHPORTS,
3285 					  parsed_items.portlist, 1);
3286 		if (nb_item > 0) {
3287 			set_fwd_ports_list(parsed_items.portlist, nb_item);
3288 			fwd_config_setup();
3289 		}
3290 	}
3291 }
3292 
3293 cmdline_parse_token_string_t cmd_set_list_keyword =
3294 	TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3295 				 "set");
3296 cmdline_parse_token_string_t cmd_set_list_name =
3297 	TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3298 				 "corelist#portlist");
3299 cmdline_parse_token_string_t cmd_set_list_of_items =
3300 	TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3301 				 NULL);
3302 
3303 cmdline_parse_inst_t cmd_set_fwd_list = {
3304 	.f = cmd_set_list_parsed,
3305 	.data = NULL,
3306 	.help_str = "set corelist|portlist <list0[,list1]*>",
3307 	.tokens = {
3308 		(void *)&cmd_set_list_keyword,
3309 		(void *)&cmd_set_list_name,
3310 		(void *)&cmd_set_list_of_items,
3311 		NULL,
3312 	},
3313 };
3314 
3315 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3316 
3317 struct cmd_setmask_result {
3318 	cmdline_fixed_string_t set;
3319 	cmdline_fixed_string_t mask;
3320 	uint64_t hexavalue;
3321 };
3322 
3323 static void cmd_set_mask_parsed(void *parsed_result,
3324 				__attribute__((unused)) struct cmdline *cl,
3325 				__attribute__((unused)) void *data)
3326 {
3327 	struct cmd_setmask_result *res = parsed_result;
3328 
3329 	if (test_done == 0) {
3330 		printf("Please stop forwarding first\n");
3331 		return;
3332 	}
3333 	if (!strcmp(res->mask, "coremask")) {
3334 		set_fwd_lcores_mask(res->hexavalue);
3335 		fwd_config_setup();
3336 	} else if (!strcmp(res->mask, "portmask")) {
3337 		set_fwd_ports_mask(res->hexavalue);
3338 		fwd_config_setup();
3339 	}
3340 }
3341 
3342 cmdline_parse_token_string_t cmd_setmask_set =
3343 	TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3344 cmdline_parse_token_string_t cmd_setmask_mask =
3345 	TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3346 				 "coremask#portmask");
3347 cmdline_parse_token_num_t cmd_setmask_value =
3348 	TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
3349 
3350 cmdline_parse_inst_t cmd_set_fwd_mask = {
3351 	.f = cmd_set_mask_parsed,
3352 	.data = NULL,
3353 	.help_str = "set coremask|portmask <hexadecimal value>",
3354 	.tokens = {
3355 		(void *)&cmd_setmask_set,
3356 		(void *)&cmd_setmask_mask,
3357 		(void *)&cmd_setmask_value,
3358 		NULL,
3359 	},
3360 };
3361 
3362 /*
3363  * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3364  */
3365 struct cmd_set_result {
3366 	cmdline_fixed_string_t set;
3367 	cmdline_fixed_string_t what;
3368 	uint16_t value;
3369 };
3370 
3371 static void cmd_set_parsed(void *parsed_result,
3372 			   __attribute__((unused)) struct cmdline *cl,
3373 			   __attribute__((unused)) void *data)
3374 {
3375 	struct cmd_set_result *res = parsed_result;
3376 	if (!strcmp(res->what, "nbport")) {
3377 		set_fwd_ports_number(res->value);
3378 		fwd_config_setup();
3379 	} else if (!strcmp(res->what, "nbcore")) {
3380 		set_fwd_lcores_number(res->value);
3381 		fwd_config_setup();
3382 	} else if (!strcmp(res->what, "burst"))
3383 		set_nb_pkt_per_burst(res->value);
3384 	else if (!strcmp(res->what, "verbose"))
3385 		set_verbose_level(res->value);
3386 }
3387 
3388 cmdline_parse_token_string_t cmd_set_set =
3389 	TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3390 cmdline_parse_token_string_t cmd_set_what =
3391 	TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3392 				 "nbport#nbcore#burst#verbose");
3393 cmdline_parse_token_num_t cmd_set_value =
3394 	TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
3395 
3396 cmdline_parse_inst_t cmd_set_numbers = {
3397 	.f = cmd_set_parsed,
3398 	.data = NULL,
3399 	.help_str = "set nbport|nbcore|burst|verbose <value>",
3400 	.tokens = {
3401 		(void *)&cmd_set_set,
3402 		(void *)&cmd_set_what,
3403 		(void *)&cmd_set_value,
3404 		NULL,
3405 	},
3406 };
3407 
3408 /* *** SET LOG LEVEL CONFIGURATION *** */
3409 
3410 struct cmd_set_log_result {
3411 	cmdline_fixed_string_t set;
3412 	cmdline_fixed_string_t log;
3413 	cmdline_fixed_string_t type;
3414 	uint32_t level;
3415 };
3416 
3417 static void
3418 cmd_set_log_parsed(void *parsed_result,
3419 		   __attribute__((unused)) struct cmdline *cl,
3420 		   __attribute__((unused)) void *data)
3421 {
3422 	struct cmd_set_log_result *res;
3423 	int ret;
3424 
3425 	res = parsed_result;
3426 	if (!strcmp(res->type, "global"))
3427 		rte_log_set_global_level(res->level);
3428 	else {
3429 		ret = rte_log_set_level_regexp(res->type, res->level);
3430 		if (ret < 0)
3431 			printf("Unable to set log level\n");
3432 	}
3433 }
3434 
3435 cmdline_parse_token_string_t cmd_set_log_set =
3436 	TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3437 cmdline_parse_token_string_t cmd_set_log_log =
3438 	TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3439 cmdline_parse_token_string_t cmd_set_log_type =
3440 	TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3441 cmdline_parse_token_num_t cmd_set_log_level =
3442 	TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, UINT32);
3443 
3444 cmdline_parse_inst_t cmd_set_log = {
3445 	.f = cmd_set_log_parsed,
3446 	.data = NULL,
3447 	.help_str = "set log global|<type> <level>",
3448 	.tokens = {
3449 		(void *)&cmd_set_log_set,
3450 		(void *)&cmd_set_log_log,
3451 		(void *)&cmd_set_log_type,
3452 		(void *)&cmd_set_log_level,
3453 		NULL,
3454 	},
3455 };
3456 
3457 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3458 
3459 struct cmd_set_txpkts_result {
3460 	cmdline_fixed_string_t cmd_keyword;
3461 	cmdline_fixed_string_t txpkts;
3462 	cmdline_fixed_string_t seg_lengths;
3463 };
3464 
3465 static void
3466 cmd_set_txpkts_parsed(void *parsed_result,
3467 		      __attribute__((unused)) struct cmdline *cl,
3468 		      __attribute__((unused)) void *data)
3469 {
3470 	struct cmd_set_txpkts_result *res;
3471 	unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3472 	unsigned int nb_segs;
3473 
3474 	res = parsed_result;
3475 	nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3476 				  RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3477 	if (nb_segs > 0)
3478 		set_tx_pkt_segments(seg_lengths, nb_segs);
3479 }
3480 
3481 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3482 	TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3483 				 cmd_keyword, "set");
3484 cmdline_parse_token_string_t cmd_set_txpkts_name =
3485 	TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3486 				 txpkts, "txpkts");
3487 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3488 	TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3489 				 seg_lengths, NULL);
3490 
3491 cmdline_parse_inst_t cmd_set_txpkts = {
3492 	.f = cmd_set_txpkts_parsed,
3493 	.data = NULL,
3494 	.help_str = "set txpkts <len0[,len1]*>",
3495 	.tokens = {
3496 		(void *)&cmd_set_txpkts_keyword,
3497 		(void *)&cmd_set_txpkts_name,
3498 		(void *)&cmd_set_txpkts_lengths,
3499 		NULL,
3500 	},
3501 };
3502 
3503 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
3504 
3505 struct cmd_set_txsplit_result {
3506 	cmdline_fixed_string_t cmd_keyword;
3507 	cmdline_fixed_string_t txsplit;
3508 	cmdline_fixed_string_t mode;
3509 };
3510 
3511 static void
3512 cmd_set_txsplit_parsed(void *parsed_result,
3513 		      __attribute__((unused)) struct cmdline *cl,
3514 		      __attribute__((unused)) void *data)
3515 {
3516 	struct cmd_set_txsplit_result *res;
3517 
3518 	res = parsed_result;
3519 	set_tx_pkt_split(res->mode);
3520 }
3521 
3522 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
3523 	TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3524 				 cmd_keyword, "set");
3525 cmdline_parse_token_string_t cmd_set_txsplit_name =
3526 	TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3527 				 txsplit, "txsplit");
3528 cmdline_parse_token_string_t cmd_set_txsplit_mode =
3529 	TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3530 				 mode, NULL);
3531 
3532 cmdline_parse_inst_t cmd_set_txsplit = {
3533 	.f = cmd_set_txsplit_parsed,
3534 	.data = NULL,
3535 	.help_str = "set txsplit on|off|rand",
3536 	.tokens = {
3537 		(void *)&cmd_set_txsplit_keyword,
3538 		(void *)&cmd_set_txsplit_name,
3539 		(void *)&cmd_set_txsplit_mode,
3540 		NULL,
3541 	},
3542 };
3543 
3544 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
3545 struct cmd_rx_vlan_filter_all_result {
3546 	cmdline_fixed_string_t rx_vlan;
3547 	cmdline_fixed_string_t what;
3548 	cmdline_fixed_string_t all;
3549 	portid_t port_id;
3550 };
3551 
3552 static void
3553 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
3554 			      __attribute__((unused)) struct cmdline *cl,
3555 			      __attribute__((unused)) void *data)
3556 {
3557 	struct cmd_rx_vlan_filter_all_result *res = parsed_result;
3558 
3559 	if (!strcmp(res->what, "add"))
3560 		rx_vlan_all_filter_set(res->port_id, 1);
3561 	else
3562 		rx_vlan_all_filter_set(res->port_id, 0);
3563 }
3564 
3565 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
3566 	TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3567 				 rx_vlan, "rx_vlan");
3568 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
3569 	TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3570 				 what, "add#rm");
3571 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
3572 	TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3573 				 all, "all");
3574 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
3575 	TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3576 			      port_id, UINT16);
3577 
3578 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
3579 	.f = cmd_rx_vlan_filter_all_parsed,
3580 	.data = NULL,
3581 	.help_str = "rx_vlan add|rm all <port_id>: "
3582 		"Add/Remove all identifiers to/from the set of VLAN "
3583 		"identifiers filtered by a port",
3584 	.tokens = {
3585 		(void *)&cmd_rx_vlan_filter_all_rx_vlan,
3586 		(void *)&cmd_rx_vlan_filter_all_what,
3587 		(void *)&cmd_rx_vlan_filter_all_all,
3588 		(void *)&cmd_rx_vlan_filter_all_portid,
3589 		NULL,
3590 	},
3591 };
3592 
3593 /* *** VLAN OFFLOAD SET ON A PORT *** */
3594 struct cmd_vlan_offload_result {
3595 	cmdline_fixed_string_t vlan;
3596 	cmdline_fixed_string_t set;
3597 	cmdline_fixed_string_t vlan_type;
3598 	cmdline_fixed_string_t what;
3599 	cmdline_fixed_string_t on;
3600 	cmdline_fixed_string_t port_id;
3601 };
3602 
3603 static void
3604 cmd_vlan_offload_parsed(void *parsed_result,
3605 			  __attribute__((unused)) struct cmdline *cl,
3606 			  __attribute__((unused)) void *data)
3607 {
3608 	int on;
3609 	struct cmd_vlan_offload_result *res = parsed_result;
3610 	char *str;
3611 	int i, len = 0;
3612 	portid_t port_id = 0;
3613 	unsigned int tmp;
3614 
3615 	str = res->port_id;
3616 	len = strnlen(str, STR_TOKEN_SIZE);
3617 	i = 0;
3618 	/* Get port_id first */
3619 	while(i < len){
3620 		if(str[i] == ',')
3621 			break;
3622 
3623 		i++;
3624 	}
3625 	str[i]='\0';
3626 	tmp = strtoul(str, NULL, 0);
3627 	/* If port_id greater that what portid_t can represent, return */
3628 	if(tmp >= RTE_MAX_ETHPORTS)
3629 		return;
3630 	port_id = (portid_t)tmp;
3631 
3632 	if (!strcmp(res->on, "on"))
3633 		on = 1;
3634 	else
3635 		on = 0;
3636 
3637 	if (!strcmp(res->what, "strip"))
3638 		rx_vlan_strip_set(port_id,  on);
3639 	else if(!strcmp(res->what, "stripq")){
3640 		uint16_t queue_id = 0;
3641 
3642 		/* No queue_id, return */
3643 		if(i + 1 >= len) {
3644 			printf("must specify (port,queue_id)\n");
3645 			return;
3646 		}
3647 		tmp = strtoul(str + i + 1, NULL, 0);
3648 		/* If queue_id greater that what 16-bits can represent, return */
3649 		if(tmp > 0xffff)
3650 			return;
3651 
3652 		queue_id = (uint16_t)tmp;
3653 		rx_vlan_strip_set_on_queue(port_id, queue_id, on);
3654 	}
3655 	else if (!strcmp(res->what, "filter"))
3656 		rx_vlan_filter_set(port_id, on);
3657 	else
3658 		vlan_extend_set(port_id, on);
3659 
3660 	return;
3661 }
3662 
3663 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
3664 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3665 				 vlan, "vlan");
3666 cmdline_parse_token_string_t cmd_vlan_offload_set =
3667 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3668 				 set, "set");
3669 cmdline_parse_token_string_t cmd_vlan_offload_what =
3670 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3671 				 what, "strip#filter#qinq#stripq");
3672 cmdline_parse_token_string_t cmd_vlan_offload_on =
3673 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3674 			      on, "on#off");
3675 cmdline_parse_token_string_t cmd_vlan_offload_portid =
3676 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3677 			      port_id, NULL);
3678 
3679 cmdline_parse_inst_t cmd_vlan_offload = {
3680 	.f = cmd_vlan_offload_parsed,
3681 	.data = NULL,
3682 	.help_str = "vlan set strip|filter|qinq|stripq on|off "
3683 		"<port_id[,queue_id]>: "
3684 		"Filter/Strip for rx side qinq(extended) for both rx/tx sides",
3685 	.tokens = {
3686 		(void *)&cmd_vlan_offload_vlan,
3687 		(void *)&cmd_vlan_offload_set,
3688 		(void *)&cmd_vlan_offload_what,
3689 		(void *)&cmd_vlan_offload_on,
3690 		(void *)&cmd_vlan_offload_portid,
3691 		NULL,
3692 	},
3693 };
3694 
3695 /* *** VLAN TPID SET ON A PORT *** */
3696 struct cmd_vlan_tpid_result {
3697 	cmdline_fixed_string_t vlan;
3698 	cmdline_fixed_string_t set;
3699 	cmdline_fixed_string_t vlan_type;
3700 	cmdline_fixed_string_t what;
3701 	uint16_t tp_id;
3702 	portid_t port_id;
3703 };
3704 
3705 static void
3706 cmd_vlan_tpid_parsed(void *parsed_result,
3707 			  __attribute__((unused)) struct cmdline *cl,
3708 			  __attribute__((unused)) void *data)
3709 {
3710 	struct cmd_vlan_tpid_result *res = parsed_result;
3711 	enum rte_vlan_type vlan_type;
3712 
3713 	if (!strcmp(res->vlan_type, "inner"))
3714 		vlan_type = ETH_VLAN_TYPE_INNER;
3715 	else if (!strcmp(res->vlan_type, "outer"))
3716 		vlan_type = ETH_VLAN_TYPE_OUTER;
3717 	else {
3718 		printf("Unknown vlan type\n");
3719 		return;
3720 	}
3721 	vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
3722 }
3723 
3724 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
3725 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3726 				 vlan, "vlan");
3727 cmdline_parse_token_string_t cmd_vlan_tpid_set =
3728 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3729 				 set, "set");
3730 cmdline_parse_token_string_t cmd_vlan_type =
3731 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3732 				 vlan_type, "inner#outer");
3733 cmdline_parse_token_string_t cmd_vlan_tpid_what =
3734 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3735 				 what, "tpid");
3736 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
3737 	TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3738 			      tp_id, UINT16);
3739 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
3740 	TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3741 			      port_id, UINT16);
3742 
3743 cmdline_parse_inst_t cmd_vlan_tpid = {
3744 	.f = cmd_vlan_tpid_parsed,
3745 	.data = NULL,
3746 	.help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
3747 		"Set the VLAN Ether type",
3748 	.tokens = {
3749 		(void *)&cmd_vlan_tpid_vlan,
3750 		(void *)&cmd_vlan_tpid_set,
3751 		(void *)&cmd_vlan_type,
3752 		(void *)&cmd_vlan_tpid_what,
3753 		(void *)&cmd_vlan_tpid_tpid,
3754 		(void *)&cmd_vlan_tpid_portid,
3755 		NULL,
3756 	},
3757 };
3758 
3759 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
3760 struct cmd_rx_vlan_filter_result {
3761 	cmdline_fixed_string_t rx_vlan;
3762 	cmdline_fixed_string_t what;
3763 	uint16_t vlan_id;
3764 	portid_t port_id;
3765 };
3766 
3767 static void
3768 cmd_rx_vlan_filter_parsed(void *parsed_result,
3769 			  __attribute__((unused)) struct cmdline *cl,
3770 			  __attribute__((unused)) void *data)
3771 {
3772 	struct cmd_rx_vlan_filter_result *res = parsed_result;
3773 
3774 	if (!strcmp(res->what, "add"))
3775 		rx_vft_set(res->port_id, res->vlan_id, 1);
3776 	else
3777 		rx_vft_set(res->port_id, res->vlan_id, 0);
3778 }
3779 
3780 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
3781 	TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3782 				 rx_vlan, "rx_vlan");
3783 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
3784 	TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3785 				 what, "add#rm");
3786 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
3787 	TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3788 			      vlan_id, UINT16);
3789 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
3790 	TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3791 			      port_id, UINT16);
3792 
3793 cmdline_parse_inst_t cmd_rx_vlan_filter = {
3794 	.f = cmd_rx_vlan_filter_parsed,
3795 	.data = NULL,
3796 	.help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
3797 		"Add/Remove a VLAN identifier to/from the set of VLAN "
3798 		"identifiers filtered by a port",
3799 	.tokens = {
3800 		(void *)&cmd_rx_vlan_filter_rx_vlan,
3801 		(void *)&cmd_rx_vlan_filter_what,
3802 		(void *)&cmd_rx_vlan_filter_vlanid,
3803 		(void *)&cmd_rx_vlan_filter_portid,
3804 		NULL,
3805 	},
3806 };
3807 
3808 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3809 struct cmd_tx_vlan_set_result {
3810 	cmdline_fixed_string_t tx_vlan;
3811 	cmdline_fixed_string_t set;
3812 	portid_t port_id;
3813 	uint16_t vlan_id;
3814 };
3815 
3816 static void
3817 cmd_tx_vlan_set_parsed(void *parsed_result,
3818 		       __attribute__((unused)) struct cmdline *cl,
3819 		       __attribute__((unused)) void *data)
3820 {
3821 	struct cmd_tx_vlan_set_result *res = parsed_result;
3822 
3823 	if (!port_is_stopped(res->port_id)) {
3824 		printf("Please stop port %d first\n", res->port_id);
3825 		return;
3826 	}
3827 
3828 	tx_vlan_set(res->port_id, res->vlan_id);
3829 
3830 	cmd_reconfig_device_queue(res->port_id, 1, 1);
3831 }
3832 
3833 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
3834 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3835 				 tx_vlan, "tx_vlan");
3836 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
3837 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3838 				 set, "set");
3839 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
3840 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3841 			      port_id, UINT16);
3842 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
3843 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3844 			      vlan_id, UINT16);
3845 
3846 cmdline_parse_inst_t cmd_tx_vlan_set = {
3847 	.f = cmd_tx_vlan_set_parsed,
3848 	.data = NULL,
3849 	.help_str = "tx_vlan set <port_id> <vlan_id>: "
3850 		"Enable hardware insertion of a single VLAN header "
3851 		"with a given TAG Identifier in packets sent on a port",
3852 	.tokens = {
3853 		(void *)&cmd_tx_vlan_set_tx_vlan,
3854 		(void *)&cmd_tx_vlan_set_set,
3855 		(void *)&cmd_tx_vlan_set_portid,
3856 		(void *)&cmd_tx_vlan_set_vlanid,
3857 		NULL,
3858 	},
3859 };
3860 
3861 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
3862 struct cmd_tx_vlan_set_qinq_result {
3863 	cmdline_fixed_string_t tx_vlan;
3864 	cmdline_fixed_string_t set;
3865 	portid_t port_id;
3866 	uint16_t vlan_id;
3867 	uint16_t vlan_id_outer;
3868 };
3869 
3870 static void
3871 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
3872 			    __attribute__((unused)) struct cmdline *cl,
3873 			    __attribute__((unused)) void *data)
3874 {
3875 	struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
3876 
3877 	if (!port_is_stopped(res->port_id)) {
3878 		printf("Please stop port %d first\n", res->port_id);
3879 		return;
3880 	}
3881 
3882 	tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
3883 
3884 	cmd_reconfig_device_queue(res->port_id, 1, 1);
3885 }
3886 
3887 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
3888 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3889 		tx_vlan, "tx_vlan");
3890 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
3891 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3892 		set, "set");
3893 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
3894 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3895 		port_id, UINT16);
3896 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
3897 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3898 		vlan_id, UINT16);
3899 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
3900 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3901 		vlan_id_outer, UINT16);
3902 
3903 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
3904 	.f = cmd_tx_vlan_set_qinq_parsed,
3905 	.data = NULL,
3906 	.help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
3907 		"Enable hardware insertion of double VLAN header "
3908 		"with given TAG Identifiers in packets sent on a port",
3909 	.tokens = {
3910 		(void *)&cmd_tx_vlan_set_qinq_tx_vlan,
3911 		(void *)&cmd_tx_vlan_set_qinq_set,
3912 		(void *)&cmd_tx_vlan_set_qinq_portid,
3913 		(void *)&cmd_tx_vlan_set_qinq_vlanid,
3914 		(void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
3915 		NULL,
3916 	},
3917 };
3918 
3919 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
3920 struct cmd_tx_vlan_set_pvid_result {
3921 	cmdline_fixed_string_t tx_vlan;
3922 	cmdline_fixed_string_t set;
3923 	cmdline_fixed_string_t pvid;
3924 	portid_t port_id;
3925 	uint16_t vlan_id;
3926 	cmdline_fixed_string_t mode;
3927 };
3928 
3929 static void
3930 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
3931 			    __attribute__((unused)) struct cmdline *cl,
3932 			    __attribute__((unused)) void *data)
3933 {
3934 	struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
3935 
3936 	if (strcmp(res->mode, "on") == 0)
3937 		tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
3938 	else
3939 		tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
3940 }
3941 
3942 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
3943 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3944 				 tx_vlan, "tx_vlan");
3945 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
3946 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3947 				 set, "set");
3948 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
3949 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3950 				 pvid, "pvid");
3951 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
3952 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3953 			     port_id, UINT16);
3954 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
3955 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3956 			      vlan_id, UINT16);
3957 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
3958 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3959 				 mode, "on#off");
3960 
3961 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
3962 	.f = cmd_tx_vlan_set_pvid_parsed,
3963 	.data = NULL,
3964 	.help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
3965 	.tokens = {
3966 		(void *)&cmd_tx_vlan_set_pvid_tx_vlan,
3967 		(void *)&cmd_tx_vlan_set_pvid_set,
3968 		(void *)&cmd_tx_vlan_set_pvid_pvid,
3969 		(void *)&cmd_tx_vlan_set_pvid_port_id,
3970 		(void *)&cmd_tx_vlan_set_pvid_vlan_id,
3971 		(void *)&cmd_tx_vlan_set_pvid_mode,
3972 		NULL,
3973 	},
3974 };
3975 
3976 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3977 struct cmd_tx_vlan_reset_result {
3978 	cmdline_fixed_string_t tx_vlan;
3979 	cmdline_fixed_string_t reset;
3980 	portid_t port_id;
3981 };
3982 
3983 static void
3984 cmd_tx_vlan_reset_parsed(void *parsed_result,
3985 			 __attribute__((unused)) struct cmdline *cl,
3986 			 __attribute__((unused)) void *data)
3987 {
3988 	struct cmd_tx_vlan_reset_result *res = parsed_result;
3989 
3990 	if (!port_is_stopped(res->port_id)) {
3991 		printf("Please stop port %d first\n", res->port_id);
3992 		return;
3993 	}
3994 
3995 	tx_vlan_reset(res->port_id);
3996 
3997 	cmd_reconfig_device_queue(res->port_id, 1, 1);
3998 }
3999 
4000 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4001 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4002 				 tx_vlan, "tx_vlan");
4003 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4004 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4005 				 reset, "reset");
4006 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4007 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4008 			      port_id, UINT16);
4009 
4010 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4011 	.f = cmd_tx_vlan_reset_parsed,
4012 	.data = NULL,
4013 	.help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4014 		"VLAN header in packets sent on a port",
4015 	.tokens = {
4016 		(void *)&cmd_tx_vlan_reset_tx_vlan,
4017 		(void *)&cmd_tx_vlan_reset_reset,
4018 		(void *)&cmd_tx_vlan_reset_portid,
4019 		NULL,
4020 	},
4021 };
4022 
4023 
4024 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4025 struct cmd_csum_result {
4026 	cmdline_fixed_string_t csum;
4027 	cmdline_fixed_string_t mode;
4028 	cmdline_fixed_string_t proto;
4029 	cmdline_fixed_string_t hwsw;
4030 	portid_t port_id;
4031 };
4032 
4033 static void
4034 csum_show(int port_id)
4035 {
4036 	struct rte_eth_dev_info dev_info;
4037 	uint64_t tx_offloads;
4038 
4039 	tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4040 	printf("Parse tunnel is %s\n",
4041 		(ports[port_id].parse_tunnel) ? "on" : "off");
4042 	printf("IP checksum offload is %s\n",
4043 		(tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4044 	printf("UDP checksum offload is %s\n",
4045 		(tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4046 	printf("TCP checksum offload is %s\n",
4047 		(tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4048 	printf("SCTP checksum offload is %s\n",
4049 		(tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4050 	printf("Outer-Ip checksum offload is %s\n",
4051 		(tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4052 
4053 	/* display warnings if configuration is not supported by the NIC */
4054 	rte_eth_dev_info_get(port_id, &dev_info);
4055 	if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
4056 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4057 		printf("Warning: hardware IP checksum enabled but not "
4058 			"supported by port %d\n", port_id);
4059 	}
4060 	if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
4061 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
4062 		printf("Warning: hardware UDP checksum enabled but not "
4063 			"supported by port %d\n", port_id);
4064 	}
4065 	if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
4066 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
4067 		printf("Warning: hardware TCP checksum enabled but not "
4068 			"supported by port %d\n", port_id);
4069 	}
4070 	if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
4071 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4072 		printf("Warning: hardware SCTP checksum enabled but not "
4073 			"supported by port %d\n", port_id);
4074 	}
4075 	if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4076 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4077 		printf("Warning: hardware outer IP checksum enabled but not "
4078 			"supported by port %d\n", port_id);
4079 	}
4080 }
4081 
4082 static void
4083 cmd_csum_parsed(void *parsed_result,
4084 		       __attribute__((unused)) struct cmdline *cl,
4085 		       __attribute__((unused)) void *data)
4086 {
4087 	struct cmd_csum_result *res = parsed_result;
4088 	int hw = 0;
4089 	uint64_t csum_offloads = 0;
4090 	struct rte_eth_dev_info dev_info;
4091 
4092 	if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4093 		printf("invalid port %d\n", res->port_id);
4094 		return;
4095 	}
4096 	if (!port_is_stopped(res->port_id)) {
4097 		printf("Please stop port %d first\n", res->port_id);
4098 		return;
4099 	}
4100 
4101 	rte_eth_dev_info_get(res->port_id, &dev_info);
4102 	if (!strcmp(res->mode, "set")) {
4103 
4104 		if (!strcmp(res->hwsw, "hw"))
4105 			hw = 1;
4106 
4107 		if (!strcmp(res->proto, "ip")) {
4108 			if (hw == 0 || (dev_info.tx_offload_capa &
4109 						DEV_TX_OFFLOAD_IPV4_CKSUM)) {
4110 				csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
4111 			} else {
4112 				printf("IP checksum offload is not supported "
4113 				       "by port %u\n", res->port_id);
4114 			}
4115 		} else if (!strcmp(res->proto, "udp")) {
4116 			if (hw == 0 || (dev_info.tx_offload_capa &
4117 						DEV_TX_OFFLOAD_UDP_CKSUM)) {
4118 				csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
4119 			} else {
4120 				printf("UDP checksum offload is not supported "
4121 				       "by port %u\n", res->port_id);
4122 			}
4123 		} else if (!strcmp(res->proto, "tcp")) {
4124 			if (hw == 0 || (dev_info.tx_offload_capa &
4125 						DEV_TX_OFFLOAD_TCP_CKSUM)) {
4126 				csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
4127 			} else {
4128 				printf("TCP checksum offload is not supported "
4129 				       "by port %u\n", res->port_id);
4130 			}
4131 		} else if (!strcmp(res->proto, "sctp")) {
4132 			if (hw == 0 || (dev_info.tx_offload_capa &
4133 						DEV_TX_OFFLOAD_SCTP_CKSUM)) {
4134 				csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
4135 			} else {
4136 				printf("SCTP checksum offload is not supported "
4137 				       "by port %u\n", res->port_id);
4138 			}
4139 		} else if (!strcmp(res->proto, "outer-ip")) {
4140 			if (hw == 0 || (dev_info.tx_offload_capa &
4141 					DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4142 				csum_offloads |=
4143 						DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4144 			} else {
4145 				printf("Outer IP checksum offload is not "
4146 				       "supported by port %u\n", res->port_id);
4147 			}
4148 		}
4149 
4150 		if (hw) {
4151 			ports[res->port_id].dev_conf.txmode.offloads |=
4152 							csum_offloads;
4153 		} else {
4154 			ports[res->port_id].dev_conf.txmode.offloads &=
4155 							(~csum_offloads);
4156 		}
4157 	}
4158 	csum_show(res->port_id);
4159 
4160 	cmd_reconfig_device_queue(res->port_id, 1, 1);
4161 }
4162 
4163 cmdline_parse_token_string_t cmd_csum_csum =
4164 	TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4165 				csum, "csum");
4166 cmdline_parse_token_string_t cmd_csum_mode =
4167 	TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4168 				mode, "set");
4169 cmdline_parse_token_string_t cmd_csum_proto =
4170 	TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4171 				proto, "ip#tcp#udp#sctp#outer-ip");
4172 cmdline_parse_token_string_t cmd_csum_hwsw =
4173 	TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4174 				hwsw, "hw#sw");
4175 cmdline_parse_token_num_t cmd_csum_portid =
4176 	TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4177 				port_id, UINT16);
4178 
4179 cmdline_parse_inst_t cmd_csum_set = {
4180 	.f = cmd_csum_parsed,
4181 	.data = NULL,
4182 	.help_str = "csum set ip|tcp|udp|sctp|outer-ip hw|sw <port_id>: "
4183 		"Enable/Disable hardware calculation of L3/L4 checksum when "
4184 		"using csum forward engine",
4185 	.tokens = {
4186 		(void *)&cmd_csum_csum,
4187 		(void *)&cmd_csum_mode,
4188 		(void *)&cmd_csum_proto,
4189 		(void *)&cmd_csum_hwsw,
4190 		(void *)&cmd_csum_portid,
4191 		NULL,
4192 	},
4193 };
4194 
4195 cmdline_parse_token_string_t cmd_csum_mode_show =
4196 	TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4197 				mode, "show");
4198 
4199 cmdline_parse_inst_t cmd_csum_show = {
4200 	.f = cmd_csum_parsed,
4201 	.data = NULL,
4202 	.help_str = "csum show <port_id>: Show checksum offload configuration",
4203 	.tokens = {
4204 		(void *)&cmd_csum_csum,
4205 		(void *)&cmd_csum_mode_show,
4206 		(void *)&cmd_csum_portid,
4207 		NULL,
4208 	},
4209 };
4210 
4211 /* Enable/disable tunnel parsing */
4212 struct cmd_csum_tunnel_result {
4213 	cmdline_fixed_string_t csum;
4214 	cmdline_fixed_string_t parse;
4215 	cmdline_fixed_string_t onoff;
4216 	portid_t port_id;
4217 };
4218 
4219 static void
4220 cmd_csum_tunnel_parsed(void *parsed_result,
4221 		       __attribute__((unused)) struct cmdline *cl,
4222 		       __attribute__((unused)) void *data)
4223 {
4224 	struct cmd_csum_tunnel_result *res = parsed_result;
4225 
4226 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4227 		return;
4228 
4229 	if (!strcmp(res->onoff, "on"))
4230 		ports[res->port_id].parse_tunnel = 1;
4231 	else
4232 		ports[res->port_id].parse_tunnel = 0;
4233 
4234 	csum_show(res->port_id);
4235 }
4236 
4237 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4238 	TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4239 				csum, "csum");
4240 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4241 	TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4242 				parse, "parse_tunnel");
4243 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4244 	TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4245 				onoff, "on#off");
4246 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4247 	TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4248 				port_id, UINT16);
4249 
4250 cmdline_parse_inst_t cmd_csum_tunnel = {
4251 	.f = cmd_csum_tunnel_parsed,
4252 	.data = NULL,
4253 	.help_str = "csum parse_tunnel on|off <port_id>: "
4254 		"Enable/Disable parsing of tunnels for csum engine",
4255 	.tokens = {
4256 		(void *)&cmd_csum_tunnel_csum,
4257 		(void *)&cmd_csum_tunnel_parse,
4258 		(void *)&cmd_csum_tunnel_onoff,
4259 		(void *)&cmd_csum_tunnel_portid,
4260 		NULL,
4261 	},
4262 };
4263 
4264 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4265 struct cmd_tso_set_result {
4266 	cmdline_fixed_string_t tso;
4267 	cmdline_fixed_string_t mode;
4268 	uint16_t tso_segsz;
4269 	portid_t port_id;
4270 };
4271 
4272 static void
4273 cmd_tso_set_parsed(void *parsed_result,
4274 		       __attribute__((unused)) struct cmdline *cl,
4275 		       __attribute__((unused)) void *data)
4276 {
4277 	struct cmd_tso_set_result *res = parsed_result;
4278 	struct rte_eth_dev_info dev_info;
4279 
4280 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4281 		return;
4282 	if (!port_is_stopped(res->port_id)) {
4283 		printf("Please stop port %d first\n", res->port_id);
4284 		return;
4285 	}
4286 
4287 	if (!strcmp(res->mode, "set"))
4288 		ports[res->port_id].tso_segsz = res->tso_segsz;
4289 
4290 	rte_eth_dev_info_get(res->port_id, &dev_info);
4291 	if ((ports[res->port_id].tso_segsz != 0) &&
4292 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4293 		printf("Error: TSO is not supported by port %d\n",
4294 		       res->port_id);
4295 		return;
4296 	}
4297 
4298 	if (ports[res->port_id].tso_segsz == 0) {
4299 		ports[res->port_id].dev_conf.txmode.offloads &=
4300 						~DEV_TX_OFFLOAD_TCP_TSO;
4301 		printf("TSO for non-tunneled packets is disabled\n");
4302 	} else {
4303 		ports[res->port_id].dev_conf.txmode.offloads |=
4304 						DEV_TX_OFFLOAD_TCP_TSO;
4305 		printf("TSO segment size for non-tunneled packets is %d\n",
4306 			ports[res->port_id].tso_segsz);
4307 	}
4308 
4309 	/* display warnings if configuration is not supported by the NIC */
4310 	rte_eth_dev_info_get(res->port_id, &dev_info);
4311 	if ((ports[res->port_id].tso_segsz != 0) &&
4312 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4313 		printf("Warning: TSO enabled but not "
4314 			"supported by port %d\n", res->port_id);
4315 	}
4316 
4317 	cmd_reconfig_device_queue(res->port_id, 1, 1);
4318 }
4319 
4320 cmdline_parse_token_string_t cmd_tso_set_tso =
4321 	TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4322 				tso, "tso");
4323 cmdline_parse_token_string_t cmd_tso_set_mode =
4324 	TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4325 				mode, "set");
4326 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4327 	TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4328 				tso_segsz, UINT16);
4329 cmdline_parse_token_num_t cmd_tso_set_portid =
4330 	TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4331 				port_id, UINT16);
4332 
4333 cmdline_parse_inst_t cmd_tso_set = {
4334 	.f = cmd_tso_set_parsed,
4335 	.data = NULL,
4336 	.help_str = "tso set <tso_segsz> <port_id>: "
4337 		"Set TSO segment size of non-tunneled packets for csum engine "
4338 		"(0 to disable)",
4339 	.tokens = {
4340 		(void *)&cmd_tso_set_tso,
4341 		(void *)&cmd_tso_set_mode,
4342 		(void *)&cmd_tso_set_tso_segsz,
4343 		(void *)&cmd_tso_set_portid,
4344 		NULL,
4345 	},
4346 };
4347 
4348 cmdline_parse_token_string_t cmd_tso_show_mode =
4349 	TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4350 				mode, "show");
4351 
4352 
4353 cmdline_parse_inst_t cmd_tso_show = {
4354 	.f = cmd_tso_set_parsed,
4355 	.data = NULL,
4356 	.help_str = "tso show <port_id>: "
4357 		"Show TSO segment size of non-tunneled packets for csum engine",
4358 	.tokens = {
4359 		(void *)&cmd_tso_set_tso,
4360 		(void *)&cmd_tso_show_mode,
4361 		(void *)&cmd_tso_set_portid,
4362 		NULL,
4363 	},
4364 };
4365 
4366 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
4367 struct cmd_tunnel_tso_set_result {
4368 	cmdline_fixed_string_t tso;
4369 	cmdline_fixed_string_t mode;
4370 	uint16_t tso_segsz;
4371 	portid_t port_id;
4372 };
4373 
4374 static struct rte_eth_dev_info
4375 check_tunnel_tso_nic_support(portid_t port_id)
4376 {
4377 	struct rte_eth_dev_info dev_info;
4378 
4379 	rte_eth_dev_info_get(port_id, &dev_info);
4380 	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
4381 		printf("Warning: VXLAN TUNNEL TSO not supported therefore "
4382 		       "not enabled for port %d\n", port_id);
4383 	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
4384 		printf("Warning: GRE TUNNEL TSO	not supported therefore "
4385 		       "not enabled for port %d\n", port_id);
4386 	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
4387 		printf("Warning: IPIP TUNNEL TSO not supported therefore "
4388 		       "not enabled for port %d\n", port_id);
4389 	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
4390 		printf("Warning: GENEVE TUNNEL TSO not supported therefore "
4391 		       "not enabled for port %d\n", port_id);
4392 	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
4393 		printf("Warning: IP TUNNEL TSO not supported therefore "
4394 		       "not enabled for port %d\n", port_id);
4395 	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
4396 		printf("Warning: UDP TUNNEL TSO not supported therefore "
4397 		       "not enabled for port %d\n", port_id);
4398 	return dev_info;
4399 }
4400 
4401 static void
4402 cmd_tunnel_tso_set_parsed(void *parsed_result,
4403 			  __attribute__((unused)) struct cmdline *cl,
4404 			  __attribute__((unused)) void *data)
4405 {
4406 	struct cmd_tunnel_tso_set_result *res = parsed_result;
4407 	struct rte_eth_dev_info dev_info;
4408 
4409 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4410 		return;
4411 	if (!port_is_stopped(res->port_id)) {
4412 		printf("Please stop port %d first\n", res->port_id);
4413 		return;
4414 	}
4415 
4416 	if (!strcmp(res->mode, "set"))
4417 		ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
4418 
4419 	dev_info = check_tunnel_tso_nic_support(res->port_id);
4420 	if (ports[res->port_id].tunnel_tso_segsz == 0) {
4421 		ports[res->port_id].dev_conf.txmode.offloads &=
4422 			~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4423 			  DEV_TX_OFFLOAD_GRE_TNL_TSO |
4424 			  DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4425 			  DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4426 			  DEV_TX_OFFLOAD_IP_TNL_TSO |
4427 			  DEV_TX_OFFLOAD_UDP_TNL_TSO);
4428 		printf("TSO for tunneled packets is disabled\n");
4429 	} else {
4430 		uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4431 					 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4432 					 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4433 					 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4434 					 DEV_TX_OFFLOAD_IP_TNL_TSO |
4435 					 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4436 
4437 		ports[res->port_id].dev_conf.txmode.offloads |=
4438 			(tso_offloads & dev_info.tx_offload_capa);
4439 		printf("TSO segment size for tunneled packets is %d\n",
4440 			ports[res->port_id].tunnel_tso_segsz);
4441 
4442 		/* Below conditions are needed to make it work:
4443 		 * (1) tunnel TSO is supported by the NIC;
4444 		 * (2) "csum parse_tunnel" must be set so that tunneled pkts
4445 		 * are recognized;
4446 		 * (3) for tunneled pkts with outer L3 of IPv4,
4447 		 * "csum set outer-ip" must be set to hw, because after tso,
4448 		 * total_len of outer IP header is changed, and the checksum
4449 		 * of outer IP header calculated by sw should be wrong; that
4450 		 * is not necessary for IPv6 tunneled pkts because there's no
4451 		 * checksum in IP header anymore.
4452 		 */
4453 
4454 		if (!ports[res->port_id].parse_tunnel)
4455 			printf("Warning: csum parse_tunnel must be set "
4456 				"so that tunneled packets are recognized\n");
4457 		if (!(ports[res->port_id].dev_conf.txmode.offloads &
4458 		      DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
4459 			printf("Warning: csum set outer-ip must be set to hw "
4460 				"if outer L3 is IPv4; not necessary for IPv6\n");
4461 	}
4462 
4463 	cmd_reconfig_device_queue(res->port_id, 1, 1);
4464 }
4465 
4466 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
4467 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4468 				tso, "tunnel_tso");
4469 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
4470 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4471 				mode, "set");
4472 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
4473 	TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4474 				tso_segsz, UINT16);
4475 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
4476 	TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4477 				port_id, UINT16);
4478 
4479 cmdline_parse_inst_t cmd_tunnel_tso_set = {
4480 	.f = cmd_tunnel_tso_set_parsed,
4481 	.data = NULL,
4482 	.help_str = "tunnel_tso set <tso_segsz> <port_id>: "
4483 		"Set TSO segment size of tunneled packets for csum engine "
4484 		"(0 to disable)",
4485 	.tokens = {
4486 		(void *)&cmd_tunnel_tso_set_tso,
4487 		(void *)&cmd_tunnel_tso_set_mode,
4488 		(void *)&cmd_tunnel_tso_set_tso_segsz,
4489 		(void *)&cmd_tunnel_tso_set_portid,
4490 		NULL,
4491 	},
4492 };
4493 
4494 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
4495 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4496 				mode, "show");
4497 
4498 
4499 cmdline_parse_inst_t cmd_tunnel_tso_show = {
4500 	.f = cmd_tunnel_tso_set_parsed,
4501 	.data = NULL,
4502 	.help_str = "tunnel_tso show <port_id> "
4503 		"Show TSO segment size of tunneled packets for csum engine",
4504 	.tokens = {
4505 		(void *)&cmd_tunnel_tso_set_tso,
4506 		(void *)&cmd_tunnel_tso_show_mode,
4507 		(void *)&cmd_tunnel_tso_set_portid,
4508 		NULL,
4509 	},
4510 };
4511 
4512 /* *** SET GRO FOR A PORT *** */
4513 struct cmd_gro_enable_result {
4514 	cmdline_fixed_string_t cmd_set;
4515 	cmdline_fixed_string_t cmd_port;
4516 	cmdline_fixed_string_t cmd_keyword;
4517 	cmdline_fixed_string_t cmd_onoff;
4518 	portid_t cmd_pid;
4519 };
4520 
4521 static void
4522 cmd_gro_enable_parsed(void *parsed_result,
4523 		__attribute__((unused)) struct cmdline *cl,
4524 		__attribute__((unused)) void *data)
4525 {
4526 	struct cmd_gro_enable_result *res;
4527 
4528 	res = parsed_result;
4529 	if (!strcmp(res->cmd_keyword, "gro"))
4530 		setup_gro(res->cmd_onoff, res->cmd_pid);
4531 }
4532 
4533 cmdline_parse_token_string_t cmd_gro_enable_set =
4534 	TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4535 			cmd_set, "set");
4536 cmdline_parse_token_string_t cmd_gro_enable_port =
4537 	TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4538 			cmd_keyword, "port");
4539 cmdline_parse_token_num_t cmd_gro_enable_pid =
4540 	TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
4541 			cmd_pid, UINT16);
4542 cmdline_parse_token_string_t cmd_gro_enable_keyword =
4543 	TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4544 			cmd_keyword, "gro");
4545 cmdline_parse_token_string_t cmd_gro_enable_onoff =
4546 	TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4547 			cmd_onoff, "on#off");
4548 
4549 cmdline_parse_inst_t cmd_gro_enable = {
4550 	.f = cmd_gro_enable_parsed,
4551 	.data = NULL,
4552 	.help_str = "set port <port_id> gro on|off",
4553 	.tokens = {
4554 		(void *)&cmd_gro_enable_set,
4555 		(void *)&cmd_gro_enable_port,
4556 		(void *)&cmd_gro_enable_pid,
4557 		(void *)&cmd_gro_enable_keyword,
4558 		(void *)&cmd_gro_enable_onoff,
4559 		NULL,
4560 	},
4561 };
4562 
4563 /* *** DISPLAY GRO CONFIGURATION *** */
4564 struct cmd_gro_show_result {
4565 	cmdline_fixed_string_t cmd_show;
4566 	cmdline_fixed_string_t cmd_port;
4567 	cmdline_fixed_string_t cmd_keyword;
4568 	portid_t cmd_pid;
4569 };
4570 
4571 static void
4572 cmd_gro_show_parsed(void *parsed_result,
4573 		__attribute__((unused)) struct cmdline *cl,
4574 		__attribute__((unused)) void *data)
4575 {
4576 	struct cmd_gro_show_result *res;
4577 
4578 	res = parsed_result;
4579 	if (!strcmp(res->cmd_keyword, "gro"))
4580 		show_gro(res->cmd_pid);
4581 }
4582 
4583 cmdline_parse_token_string_t cmd_gro_show_show =
4584 	TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4585 			cmd_show, "show");
4586 cmdline_parse_token_string_t cmd_gro_show_port =
4587 	TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4588 			cmd_port, "port");
4589 cmdline_parse_token_num_t cmd_gro_show_pid =
4590 	TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
4591 			cmd_pid, UINT16);
4592 cmdline_parse_token_string_t cmd_gro_show_keyword =
4593 	TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4594 			cmd_keyword, "gro");
4595 
4596 cmdline_parse_inst_t cmd_gro_show = {
4597 	.f = cmd_gro_show_parsed,
4598 	.data = NULL,
4599 	.help_str = "show port <port_id> gro",
4600 	.tokens = {
4601 		(void *)&cmd_gro_show_show,
4602 		(void *)&cmd_gro_show_port,
4603 		(void *)&cmd_gro_show_pid,
4604 		(void *)&cmd_gro_show_keyword,
4605 		NULL,
4606 	},
4607 };
4608 
4609 /* *** SET FLUSH CYCLES FOR GRO *** */
4610 struct cmd_gro_flush_result {
4611 	cmdline_fixed_string_t cmd_set;
4612 	cmdline_fixed_string_t cmd_keyword;
4613 	cmdline_fixed_string_t cmd_flush;
4614 	uint8_t cmd_cycles;
4615 };
4616 
4617 static void
4618 cmd_gro_flush_parsed(void *parsed_result,
4619 		__attribute__((unused)) struct cmdline *cl,
4620 		__attribute__((unused)) void *data)
4621 {
4622 	struct cmd_gro_flush_result *res;
4623 
4624 	res = parsed_result;
4625 	if ((!strcmp(res->cmd_keyword, "gro")) &&
4626 			(!strcmp(res->cmd_flush, "flush")))
4627 		setup_gro_flush_cycles(res->cmd_cycles);
4628 }
4629 
4630 cmdline_parse_token_string_t cmd_gro_flush_set =
4631 	TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4632 			cmd_set, "set");
4633 cmdline_parse_token_string_t cmd_gro_flush_keyword =
4634 	TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4635 			cmd_keyword, "gro");
4636 cmdline_parse_token_string_t cmd_gro_flush_flush =
4637 	TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4638 			cmd_flush, "flush");
4639 cmdline_parse_token_num_t cmd_gro_flush_cycles =
4640 	TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
4641 			cmd_cycles, UINT8);
4642 
4643 cmdline_parse_inst_t cmd_gro_flush = {
4644 	.f = cmd_gro_flush_parsed,
4645 	.data = NULL,
4646 	.help_str = "set gro flush <cycles>",
4647 	.tokens = {
4648 		(void *)&cmd_gro_flush_set,
4649 		(void *)&cmd_gro_flush_keyword,
4650 		(void *)&cmd_gro_flush_flush,
4651 		(void *)&cmd_gro_flush_cycles,
4652 		NULL,
4653 	},
4654 };
4655 
4656 /* *** ENABLE/DISABLE GSO *** */
4657 struct cmd_gso_enable_result {
4658 	cmdline_fixed_string_t cmd_set;
4659 	cmdline_fixed_string_t cmd_port;
4660 	cmdline_fixed_string_t cmd_keyword;
4661 	cmdline_fixed_string_t cmd_mode;
4662 	portid_t cmd_pid;
4663 };
4664 
4665 static void
4666 cmd_gso_enable_parsed(void *parsed_result,
4667 		__attribute__((unused)) struct cmdline *cl,
4668 		__attribute__((unused)) void *data)
4669 {
4670 	struct cmd_gso_enable_result *res;
4671 
4672 	res = parsed_result;
4673 	if (!strcmp(res->cmd_keyword, "gso"))
4674 		setup_gso(res->cmd_mode, res->cmd_pid);
4675 }
4676 
4677 cmdline_parse_token_string_t cmd_gso_enable_set =
4678 	TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4679 			cmd_set, "set");
4680 cmdline_parse_token_string_t cmd_gso_enable_port =
4681 	TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4682 			cmd_port, "port");
4683 cmdline_parse_token_string_t cmd_gso_enable_keyword =
4684 	TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4685 			cmd_keyword, "gso");
4686 cmdline_parse_token_string_t cmd_gso_enable_mode =
4687 	TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4688 			cmd_mode, "on#off");
4689 cmdline_parse_token_num_t cmd_gso_enable_pid =
4690 	TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
4691 			cmd_pid, UINT16);
4692 
4693 cmdline_parse_inst_t cmd_gso_enable = {
4694 	.f = cmd_gso_enable_parsed,
4695 	.data = NULL,
4696 	.help_str = "set port <port_id> gso on|off",
4697 	.tokens = {
4698 		(void *)&cmd_gso_enable_set,
4699 		(void *)&cmd_gso_enable_port,
4700 		(void *)&cmd_gso_enable_pid,
4701 		(void *)&cmd_gso_enable_keyword,
4702 		(void *)&cmd_gso_enable_mode,
4703 		NULL,
4704 	},
4705 };
4706 
4707 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
4708 struct cmd_gso_size_result {
4709 	cmdline_fixed_string_t cmd_set;
4710 	cmdline_fixed_string_t cmd_keyword;
4711 	cmdline_fixed_string_t cmd_segsz;
4712 	uint16_t cmd_size;
4713 };
4714 
4715 static void
4716 cmd_gso_size_parsed(void *parsed_result,
4717 		       __attribute__((unused)) struct cmdline *cl,
4718 		       __attribute__((unused)) void *data)
4719 {
4720 	struct cmd_gso_size_result *res = parsed_result;
4721 
4722 	if (test_done == 0) {
4723 		printf("Before setting GSO segsz, please first"
4724 				" stop fowarding\n");
4725 		return;
4726 	}
4727 
4728 	if (!strcmp(res->cmd_keyword, "gso") &&
4729 			!strcmp(res->cmd_segsz, "segsz")) {
4730 		if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
4731 			printf("gso_size should be larger than %zu."
4732 					" Please input a legal value\n",
4733 					RTE_GSO_SEG_SIZE_MIN);
4734 		else
4735 			gso_max_segment_size = res->cmd_size;
4736 	}
4737 }
4738 
4739 cmdline_parse_token_string_t cmd_gso_size_set =
4740 	TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4741 				cmd_set, "set");
4742 cmdline_parse_token_string_t cmd_gso_size_keyword =
4743 	TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4744 				cmd_keyword, "gso");
4745 cmdline_parse_token_string_t cmd_gso_size_segsz =
4746 	TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4747 				cmd_segsz, "segsz");
4748 cmdline_parse_token_num_t cmd_gso_size_size =
4749 	TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
4750 				cmd_size, UINT16);
4751 
4752 cmdline_parse_inst_t cmd_gso_size = {
4753 	.f = cmd_gso_size_parsed,
4754 	.data = NULL,
4755 	.help_str = "set gso segsz <length>",
4756 	.tokens = {
4757 		(void *)&cmd_gso_size_set,
4758 		(void *)&cmd_gso_size_keyword,
4759 		(void *)&cmd_gso_size_segsz,
4760 		(void *)&cmd_gso_size_size,
4761 		NULL,
4762 	},
4763 };
4764 
4765 /* *** SHOW GSO CONFIGURATION *** */
4766 struct cmd_gso_show_result {
4767 	cmdline_fixed_string_t cmd_show;
4768 	cmdline_fixed_string_t cmd_port;
4769 	cmdline_fixed_string_t cmd_keyword;
4770 	portid_t cmd_pid;
4771 };
4772 
4773 static void
4774 cmd_gso_show_parsed(void *parsed_result,
4775 		       __attribute__((unused)) struct cmdline *cl,
4776 		       __attribute__((unused)) void *data)
4777 {
4778 	struct cmd_gso_show_result *res = parsed_result;
4779 
4780 	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
4781 		printf("invalid port id %u\n", res->cmd_pid);
4782 		return;
4783 	}
4784 	if (!strcmp(res->cmd_keyword, "gso")) {
4785 		if (gso_ports[res->cmd_pid].enable) {
4786 			printf("Max GSO'd packet size: %uB\n"
4787 					"Supported GSO types: TCP/IPv4, "
4788 					"VxLAN with inner TCP/IPv4 packet, "
4789 					"GRE with inner TCP/IPv4  packet\n",
4790 					gso_max_segment_size);
4791 		} else
4792 			printf("GSO is not enabled on Port %u\n", res->cmd_pid);
4793 	}
4794 }
4795 
4796 cmdline_parse_token_string_t cmd_gso_show_show =
4797 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4798 		cmd_show, "show");
4799 cmdline_parse_token_string_t cmd_gso_show_port =
4800 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4801 		cmd_port, "port");
4802 cmdline_parse_token_string_t cmd_gso_show_keyword =
4803 	TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4804 				cmd_keyword, "gso");
4805 cmdline_parse_token_num_t cmd_gso_show_pid =
4806 	TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
4807 				cmd_pid, UINT16);
4808 
4809 cmdline_parse_inst_t cmd_gso_show = {
4810 	.f = cmd_gso_show_parsed,
4811 	.data = NULL,
4812 	.help_str = "show port <port_id> gso",
4813 	.tokens = {
4814 		(void *)&cmd_gso_show_show,
4815 		(void *)&cmd_gso_show_port,
4816 		(void *)&cmd_gso_show_pid,
4817 		(void *)&cmd_gso_show_keyword,
4818 		NULL,
4819 	},
4820 };
4821 
4822 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
4823 struct cmd_set_flush_rx {
4824 	cmdline_fixed_string_t set;
4825 	cmdline_fixed_string_t flush_rx;
4826 	cmdline_fixed_string_t mode;
4827 };
4828 
4829 static void
4830 cmd_set_flush_rx_parsed(void *parsed_result,
4831 		__attribute__((unused)) struct cmdline *cl,
4832 		__attribute__((unused)) void *data)
4833 {
4834 	struct cmd_set_flush_rx *res = parsed_result;
4835 	no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4836 }
4837 
4838 cmdline_parse_token_string_t cmd_setflushrx_set =
4839 	TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4840 			set, "set");
4841 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
4842 	TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4843 			flush_rx, "flush_rx");
4844 cmdline_parse_token_string_t cmd_setflushrx_mode =
4845 	TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4846 			mode, "on#off");
4847 
4848 
4849 cmdline_parse_inst_t cmd_set_flush_rx = {
4850 	.f = cmd_set_flush_rx_parsed,
4851 	.help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
4852 	.data = NULL,
4853 	.tokens = {
4854 		(void *)&cmd_setflushrx_set,
4855 		(void *)&cmd_setflushrx_flush_rx,
4856 		(void *)&cmd_setflushrx_mode,
4857 		NULL,
4858 	},
4859 };
4860 
4861 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
4862 struct cmd_set_link_check {
4863 	cmdline_fixed_string_t set;
4864 	cmdline_fixed_string_t link_check;
4865 	cmdline_fixed_string_t mode;
4866 };
4867 
4868 static void
4869 cmd_set_link_check_parsed(void *parsed_result,
4870 		__attribute__((unused)) struct cmdline *cl,
4871 		__attribute__((unused)) void *data)
4872 {
4873 	struct cmd_set_link_check *res = parsed_result;
4874 	no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4875 }
4876 
4877 cmdline_parse_token_string_t cmd_setlinkcheck_set =
4878 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4879 			set, "set");
4880 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
4881 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4882 			link_check, "link_check");
4883 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
4884 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4885 			mode, "on#off");
4886 
4887 
4888 cmdline_parse_inst_t cmd_set_link_check = {
4889 	.f = cmd_set_link_check_parsed,
4890 	.help_str = "set link_check on|off: Enable/Disable link status check "
4891 	            "when starting/stopping a port",
4892 	.data = NULL,
4893 	.tokens = {
4894 		(void *)&cmd_setlinkcheck_set,
4895 		(void *)&cmd_setlinkcheck_link_check,
4896 		(void *)&cmd_setlinkcheck_mode,
4897 		NULL,
4898 	},
4899 };
4900 
4901 /* *** SET NIC BYPASS MODE *** */
4902 struct cmd_set_bypass_mode_result {
4903 	cmdline_fixed_string_t set;
4904 	cmdline_fixed_string_t bypass;
4905 	cmdline_fixed_string_t mode;
4906 	cmdline_fixed_string_t value;
4907 	portid_t port_id;
4908 };
4909 
4910 static void
4911 cmd_set_bypass_mode_parsed(void *parsed_result,
4912 		__attribute__((unused)) struct cmdline *cl,
4913 		__attribute__((unused)) void *data)
4914 {
4915 	struct cmd_set_bypass_mode_result *res = parsed_result;
4916 	portid_t port_id = res->port_id;
4917 	int32_t rc = -EINVAL;
4918 
4919 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4920 	uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4921 
4922 	if (!strcmp(res->value, "bypass"))
4923 		bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
4924 	else if (!strcmp(res->value, "isolate"))
4925 		bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
4926 	else
4927 		bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4928 
4929 	/* Set the bypass mode for the relevant port. */
4930 	rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
4931 #endif
4932 	if (rc != 0)
4933 		printf("\t Failed to set bypass mode for port = %d.\n", port_id);
4934 }
4935 
4936 cmdline_parse_token_string_t cmd_setbypass_mode_set =
4937 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4938 			set, "set");
4939 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
4940 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4941 			bypass, "bypass");
4942 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
4943 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4944 			mode, "mode");
4945 cmdline_parse_token_string_t cmd_setbypass_mode_value =
4946 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4947 			value, "normal#bypass#isolate");
4948 cmdline_parse_token_num_t cmd_setbypass_mode_port =
4949 	TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
4950 				port_id, UINT16);
4951 
4952 cmdline_parse_inst_t cmd_set_bypass_mode = {
4953 	.f = cmd_set_bypass_mode_parsed,
4954 	.help_str = "set bypass mode normal|bypass|isolate <port_id>: "
4955 	            "Set the NIC bypass mode for port_id",
4956 	.data = NULL,
4957 	.tokens = {
4958 		(void *)&cmd_setbypass_mode_set,
4959 		(void *)&cmd_setbypass_mode_bypass,
4960 		(void *)&cmd_setbypass_mode_mode,
4961 		(void *)&cmd_setbypass_mode_value,
4962 		(void *)&cmd_setbypass_mode_port,
4963 		NULL,
4964 	},
4965 };
4966 
4967 /* *** SET NIC BYPASS EVENT *** */
4968 struct cmd_set_bypass_event_result {
4969 	cmdline_fixed_string_t set;
4970 	cmdline_fixed_string_t bypass;
4971 	cmdline_fixed_string_t event;
4972 	cmdline_fixed_string_t event_value;
4973 	cmdline_fixed_string_t mode;
4974 	cmdline_fixed_string_t mode_value;
4975 	portid_t port_id;
4976 };
4977 
4978 static void
4979 cmd_set_bypass_event_parsed(void *parsed_result,
4980 		__attribute__((unused)) struct cmdline *cl,
4981 		__attribute__((unused)) void *data)
4982 {
4983 	int32_t rc = -EINVAL;
4984 	struct cmd_set_bypass_event_result *res = parsed_result;
4985 	portid_t port_id = res->port_id;
4986 
4987 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4988 	uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
4989 	uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4990 
4991 	if (!strcmp(res->event_value, "timeout"))
4992 		bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
4993 	else if (!strcmp(res->event_value, "os_on"))
4994 		bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
4995 	else if (!strcmp(res->event_value, "os_off"))
4996 		bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
4997 	else if (!strcmp(res->event_value, "power_on"))
4998 		bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
4999 	else if (!strcmp(res->event_value, "power_off"))
5000 		bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5001 	else
5002 		bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5003 
5004 	if (!strcmp(res->mode_value, "bypass"))
5005 		bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5006 	else if (!strcmp(res->mode_value, "isolate"))
5007 		bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5008 	else
5009 		bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5010 
5011 	/* Set the watchdog timeout. */
5012 	if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5013 
5014 		rc = -EINVAL;
5015 		if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5016 			rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5017 							   bypass_timeout);
5018 		}
5019 		if (rc != 0) {
5020 			printf("Failed to set timeout value %u "
5021 			"for port %d, errto code: %d.\n",
5022 			bypass_timeout, port_id, rc);
5023 		}
5024 	}
5025 
5026 	/* Set the bypass event to transition to bypass mode. */
5027 	rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5028 					      bypass_mode);
5029 #endif
5030 
5031 	if (rc != 0)
5032 		printf("\t Failed to set bypass event for port = %d.\n",
5033 		       port_id);
5034 }
5035 
5036 cmdline_parse_token_string_t cmd_setbypass_event_set =
5037 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5038 			set, "set");
5039 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5040 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5041 			bypass, "bypass");
5042 cmdline_parse_token_string_t cmd_setbypass_event_event =
5043 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5044 			event, "event");
5045 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5046 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5047 			event_value, "none#timeout#os_off#os_on#power_on#power_off");
5048 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5049 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5050 			mode, "mode");
5051 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5052 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5053 			mode_value, "normal#bypass#isolate");
5054 cmdline_parse_token_num_t cmd_setbypass_event_port =
5055 	TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5056 				port_id, UINT16);
5057 
5058 cmdline_parse_inst_t cmd_set_bypass_event = {
5059 	.f = cmd_set_bypass_event_parsed,
5060 	.help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5061 		"power_off mode normal|bypass|isolate <port_id>: "
5062 		"Set the NIC bypass event mode for port_id",
5063 	.data = NULL,
5064 	.tokens = {
5065 		(void *)&cmd_setbypass_event_set,
5066 		(void *)&cmd_setbypass_event_bypass,
5067 		(void *)&cmd_setbypass_event_event,
5068 		(void *)&cmd_setbypass_event_event_value,
5069 		(void *)&cmd_setbypass_event_mode,
5070 		(void *)&cmd_setbypass_event_mode_value,
5071 		(void *)&cmd_setbypass_event_port,
5072 		NULL,
5073 	},
5074 };
5075 
5076 
5077 /* *** SET NIC BYPASS TIMEOUT *** */
5078 struct cmd_set_bypass_timeout_result {
5079 	cmdline_fixed_string_t set;
5080 	cmdline_fixed_string_t bypass;
5081 	cmdline_fixed_string_t timeout;
5082 	cmdline_fixed_string_t value;
5083 };
5084 
5085 static void
5086 cmd_set_bypass_timeout_parsed(void *parsed_result,
5087 		__attribute__((unused)) struct cmdline *cl,
5088 		__attribute__((unused)) void *data)
5089 {
5090 	__rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5091 
5092 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5093 	if (!strcmp(res->value, "1.5"))
5094 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5095 	else if (!strcmp(res->value, "2"))
5096 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5097 	else if (!strcmp(res->value, "3"))
5098 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5099 	else if (!strcmp(res->value, "4"))
5100 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5101 	else if (!strcmp(res->value, "8"))
5102 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5103 	else if (!strcmp(res->value, "16"))
5104 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5105 	else if (!strcmp(res->value, "32"))
5106 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5107 	else
5108 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5109 #endif
5110 }
5111 
5112 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5113 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5114 			set, "set");
5115 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5116 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5117 			bypass, "bypass");
5118 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5119 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5120 			timeout, "timeout");
5121 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5122 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5123 			value, "0#1.5#2#3#4#8#16#32");
5124 
5125 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5126 	.f = cmd_set_bypass_timeout_parsed,
5127 	.help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5128 		"Set the NIC bypass watchdog timeout in seconds",
5129 	.data = NULL,
5130 	.tokens = {
5131 		(void *)&cmd_setbypass_timeout_set,
5132 		(void *)&cmd_setbypass_timeout_bypass,
5133 		(void *)&cmd_setbypass_timeout_timeout,
5134 		(void *)&cmd_setbypass_timeout_value,
5135 		NULL,
5136 	},
5137 };
5138 
5139 /* *** SHOW NIC BYPASS MODE *** */
5140 struct cmd_show_bypass_config_result {
5141 	cmdline_fixed_string_t show;
5142 	cmdline_fixed_string_t bypass;
5143 	cmdline_fixed_string_t config;
5144 	portid_t port_id;
5145 };
5146 
5147 static void
5148 cmd_show_bypass_config_parsed(void *parsed_result,
5149 		__attribute__((unused)) struct cmdline *cl,
5150 		__attribute__((unused)) void *data)
5151 {
5152 	struct cmd_show_bypass_config_result *res = parsed_result;
5153 	portid_t port_id = res->port_id;
5154 	int rc = -EINVAL;
5155 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5156 	uint32_t event_mode;
5157 	uint32_t bypass_mode;
5158 	uint32_t timeout = bypass_timeout;
5159 	int i;
5160 
5161 	static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5162 		{"off", "1.5", "2", "3", "4", "8", "16", "32"};
5163 	static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5164 		{"UNKNOWN", "normal", "bypass", "isolate"};
5165 	static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5166 		"NONE",
5167 		"OS/board on",
5168 		"power supply on",
5169 		"OS/board off",
5170 		"power supply off",
5171 		"timeout"};
5172 	int num_events = (sizeof events) / (sizeof events[0]);
5173 
5174 	/* Display the bypass mode.*/
5175 	if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5176 		printf("\tFailed to get bypass mode for port = %d\n", port_id);
5177 		return;
5178 	}
5179 	else {
5180 		if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5181 			bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5182 
5183 		printf("\tbypass mode    = %s\n",  modes[bypass_mode]);
5184 	}
5185 
5186 	/* Display the bypass timeout.*/
5187 	if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5188 		timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5189 
5190 	printf("\tbypass timeout = %s\n", timeouts[timeout]);
5191 
5192 	/* Display the bypass events and associated modes. */
5193 	for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < num_events; i++) {
5194 
5195 		if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5196 			printf("\tFailed to get bypass mode for event = %s\n",
5197 				events[i]);
5198 		} else {
5199 			if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5200 				event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5201 
5202 			printf("\tbypass event: %-16s = %s\n", events[i],
5203 				modes[event_mode]);
5204 		}
5205 	}
5206 #endif
5207 	if (rc != 0)
5208 		printf("\tFailed to get bypass configuration for port = %d\n",
5209 		       port_id);
5210 }
5211 
5212 cmdline_parse_token_string_t cmd_showbypass_config_show =
5213 	TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5214 			show, "show");
5215 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5216 	TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5217 			bypass, "bypass");
5218 cmdline_parse_token_string_t cmd_showbypass_config_config =
5219 	TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5220 			config, "config");
5221 cmdline_parse_token_num_t cmd_showbypass_config_port =
5222 	TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5223 				port_id, UINT16);
5224 
5225 cmdline_parse_inst_t cmd_show_bypass_config = {
5226 	.f = cmd_show_bypass_config_parsed,
5227 	.help_str = "show bypass config <port_id>: "
5228 	            "Show the NIC bypass config for port_id",
5229 	.data = NULL,
5230 	.tokens = {
5231 		(void *)&cmd_showbypass_config_show,
5232 		(void *)&cmd_showbypass_config_bypass,
5233 		(void *)&cmd_showbypass_config_config,
5234 		(void *)&cmd_showbypass_config_port,
5235 		NULL,
5236 	},
5237 };
5238 
5239 #ifdef RTE_LIBRTE_PMD_BOND
5240 /* *** SET BONDING MODE *** */
5241 struct cmd_set_bonding_mode_result {
5242 	cmdline_fixed_string_t set;
5243 	cmdline_fixed_string_t bonding;
5244 	cmdline_fixed_string_t mode;
5245 	uint8_t value;
5246 	portid_t port_id;
5247 };
5248 
5249 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5250 		__attribute__((unused))  struct cmdline *cl,
5251 		__attribute__((unused)) void *data)
5252 {
5253 	struct cmd_set_bonding_mode_result *res = parsed_result;
5254 	portid_t port_id = res->port_id;
5255 
5256 	/* Set the bonding mode for the relevant port. */
5257 	if (0 != rte_eth_bond_mode_set(port_id, res->value))
5258 		printf("\t Failed to set bonding mode for port = %d.\n", port_id);
5259 }
5260 
5261 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5262 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5263 		set, "set");
5264 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5265 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5266 		bonding, "bonding");
5267 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5268 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5269 		mode, "mode");
5270 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5271 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5272 		value, UINT8);
5273 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5274 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5275 		port_id, UINT16);
5276 
5277 cmdline_parse_inst_t cmd_set_bonding_mode = {
5278 		.f = cmd_set_bonding_mode_parsed,
5279 		.help_str = "set bonding mode <mode_value> <port_id>: "
5280 			"Set the bonding mode for port_id",
5281 		.data = NULL,
5282 		.tokens = {
5283 				(void *) &cmd_setbonding_mode_set,
5284 				(void *) &cmd_setbonding_mode_bonding,
5285 				(void *) &cmd_setbonding_mode_mode,
5286 				(void *) &cmd_setbonding_mode_value,
5287 				(void *) &cmd_setbonding_mode_port,
5288 				NULL
5289 		}
5290 };
5291 
5292 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5293 struct cmd_set_bonding_lacp_dedicated_queues_result {
5294 	cmdline_fixed_string_t set;
5295 	cmdline_fixed_string_t bonding;
5296 	cmdline_fixed_string_t lacp;
5297 	cmdline_fixed_string_t dedicated_queues;
5298 	portid_t port_id;
5299 	cmdline_fixed_string_t mode;
5300 };
5301 
5302 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5303 		__attribute__((unused))  struct cmdline *cl,
5304 		__attribute__((unused)) void *data)
5305 {
5306 	struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5307 	portid_t port_id = res->port_id;
5308 	struct rte_port *port;
5309 
5310 	port = &ports[port_id];
5311 
5312 	/** Check if the port is not started **/
5313 	if (port->port_status != RTE_PORT_STOPPED) {
5314 		printf("Please stop port %d first\n", port_id);
5315 		return;
5316 	}
5317 
5318 	if (!strcmp(res->mode, "enable")) {
5319 		if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5320 			printf("Dedicate queues for LACP control packets"
5321 					" enabled\n");
5322 		else
5323 			printf("Enabling dedicate queues for LACP control "
5324 					"packets on port %d failed\n", port_id);
5325 	} else if (!strcmp(res->mode, "disable")) {
5326 		if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5327 			printf("Dedicated queues for LACP control packets "
5328 					"disabled\n");
5329 		else
5330 			printf("Disabling dedicated queues for LACP control "
5331 					"traffic on port %d failed\n", port_id);
5332 	}
5333 }
5334 
5335 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5336 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5337 		set, "set");
5338 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
5339 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5340 		bonding, "bonding");
5341 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
5342 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5343 		lacp, "lacp");
5344 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
5345 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5346 		dedicated_queues, "dedicated_queues");
5347 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
5348 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5349 		port_id, UINT16);
5350 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
5351 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5352 		mode, "enable#disable");
5353 
5354 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
5355 		.f = cmd_set_bonding_lacp_dedicated_queues_parsed,
5356 		.help_str = "set bonding lacp dedicated_queues <port_id> "
5357 			"enable|disable: "
5358 			"Enable/disable dedicated queues for LACP control traffic for port_id",
5359 		.data = NULL,
5360 		.tokens = {
5361 			(void *)&cmd_setbonding_lacp_dedicated_queues_set,
5362 			(void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
5363 			(void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
5364 			(void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
5365 			(void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
5366 			(void *)&cmd_setbonding_lacp_dedicated_queues_mode,
5367 			NULL
5368 		}
5369 };
5370 
5371 /* *** SET BALANCE XMIT POLICY *** */
5372 struct cmd_set_bonding_balance_xmit_policy_result {
5373 	cmdline_fixed_string_t set;
5374 	cmdline_fixed_string_t bonding;
5375 	cmdline_fixed_string_t balance_xmit_policy;
5376 	portid_t port_id;
5377 	cmdline_fixed_string_t policy;
5378 };
5379 
5380 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
5381 		__attribute__((unused))  struct cmdline *cl,
5382 		__attribute__((unused)) void *data)
5383 {
5384 	struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
5385 	portid_t port_id = res->port_id;
5386 	uint8_t policy;
5387 
5388 	if (!strcmp(res->policy, "l2")) {
5389 		policy = BALANCE_XMIT_POLICY_LAYER2;
5390 	} else if (!strcmp(res->policy, "l23")) {
5391 		policy = BALANCE_XMIT_POLICY_LAYER23;
5392 	} else if (!strcmp(res->policy, "l34")) {
5393 		policy = BALANCE_XMIT_POLICY_LAYER34;
5394 	} else {
5395 		printf("\t Invalid xmit policy selection");
5396 		return;
5397 	}
5398 
5399 	/* Set the bonding mode for the relevant port. */
5400 	if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
5401 		printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
5402 				port_id);
5403 	}
5404 }
5405 
5406 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
5407 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5408 		set, "set");
5409 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
5410 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5411 		bonding, "bonding");
5412 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
5413 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5414 		balance_xmit_policy, "balance_xmit_policy");
5415 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
5416 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5417 		port_id, UINT16);
5418 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
5419 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5420 		policy, "l2#l23#l34");
5421 
5422 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
5423 		.f = cmd_set_bonding_balance_xmit_policy_parsed,
5424 		.help_str = "set bonding balance_xmit_policy <port_id> "
5425 			"l2|l23|l34: "
5426 			"Set the bonding balance_xmit_policy for port_id",
5427 		.data = NULL,
5428 		.tokens = {
5429 				(void *)&cmd_setbonding_balance_xmit_policy_set,
5430 				(void *)&cmd_setbonding_balance_xmit_policy_bonding,
5431 				(void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
5432 				(void *)&cmd_setbonding_balance_xmit_policy_port,
5433 				(void *)&cmd_setbonding_balance_xmit_policy_policy,
5434 				NULL
5435 		}
5436 };
5437 
5438 /* *** SHOW NIC BONDING CONFIGURATION *** */
5439 struct cmd_show_bonding_config_result {
5440 	cmdline_fixed_string_t show;
5441 	cmdline_fixed_string_t bonding;
5442 	cmdline_fixed_string_t config;
5443 	portid_t port_id;
5444 };
5445 
5446 static void cmd_show_bonding_config_parsed(void *parsed_result,
5447 		__attribute__((unused))  struct cmdline *cl,
5448 		__attribute__((unused)) void *data)
5449 {
5450 	struct cmd_show_bonding_config_result *res = parsed_result;
5451 	int bonding_mode, agg_mode;
5452 	portid_t slaves[RTE_MAX_ETHPORTS];
5453 	int num_slaves, num_active_slaves;
5454 	int primary_id;
5455 	int i;
5456 	portid_t port_id = res->port_id;
5457 
5458 	/* Display the bonding mode.*/
5459 	bonding_mode = rte_eth_bond_mode_get(port_id);
5460 	if (bonding_mode < 0) {
5461 		printf("\tFailed to get bonding mode for port = %d\n", port_id);
5462 		return;
5463 	} else
5464 		printf("\tBonding mode: %d\n", bonding_mode);
5465 
5466 	if (bonding_mode == BONDING_MODE_BALANCE) {
5467 		int balance_xmit_policy;
5468 
5469 		balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
5470 		if (balance_xmit_policy < 0) {
5471 			printf("\tFailed to get balance xmit policy for port = %d\n",
5472 					port_id);
5473 			return;
5474 		} else {
5475 			printf("\tBalance Xmit Policy: ");
5476 
5477 			switch (balance_xmit_policy) {
5478 			case BALANCE_XMIT_POLICY_LAYER2:
5479 				printf("BALANCE_XMIT_POLICY_LAYER2");
5480 				break;
5481 			case BALANCE_XMIT_POLICY_LAYER23:
5482 				printf("BALANCE_XMIT_POLICY_LAYER23");
5483 				break;
5484 			case BALANCE_XMIT_POLICY_LAYER34:
5485 				printf("BALANCE_XMIT_POLICY_LAYER34");
5486 				break;
5487 			}
5488 			printf("\n");
5489 		}
5490 	}
5491 
5492 	if (bonding_mode == BONDING_MODE_8023AD) {
5493 		agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
5494 		printf("\tIEEE802.3AD Aggregator Mode: ");
5495 		switch (agg_mode) {
5496 		case AGG_BANDWIDTH:
5497 			printf("bandwidth");
5498 			break;
5499 		case AGG_STABLE:
5500 			printf("stable");
5501 			break;
5502 		case AGG_COUNT:
5503 			printf("count");
5504 			break;
5505 		}
5506 		printf("\n");
5507 	}
5508 
5509 	num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
5510 
5511 	if (num_slaves < 0) {
5512 		printf("\tFailed to get slave list for port = %d\n", port_id);
5513 		return;
5514 	}
5515 	if (num_slaves > 0) {
5516 		printf("\tSlaves (%d): [", num_slaves);
5517 		for (i = 0; i < num_slaves - 1; i++)
5518 			printf("%d ", slaves[i]);
5519 
5520 		printf("%d]\n", slaves[num_slaves - 1]);
5521 	} else {
5522 		printf("\tSlaves: []\n");
5523 
5524 	}
5525 
5526 	num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
5527 			RTE_MAX_ETHPORTS);
5528 
5529 	if (num_active_slaves < 0) {
5530 		printf("\tFailed to get active slave list for port = %d\n", port_id);
5531 		return;
5532 	}
5533 	if (num_active_slaves > 0) {
5534 		printf("\tActive Slaves (%d): [", num_active_slaves);
5535 		for (i = 0; i < num_active_slaves - 1; i++)
5536 			printf("%d ", slaves[i]);
5537 
5538 		printf("%d]\n", slaves[num_active_slaves - 1]);
5539 
5540 	} else {
5541 		printf("\tActive Slaves: []\n");
5542 
5543 	}
5544 
5545 	primary_id = rte_eth_bond_primary_get(port_id);
5546 	if (primary_id < 0) {
5547 		printf("\tFailed to get primary slave for port = %d\n", port_id);
5548 		return;
5549 	} else
5550 		printf("\tPrimary: [%d]\n", primary_id);
5551 
5552 }
5553 
5554 cmdline_parse_token_string_t cmd_showbonding_config_show =
5555 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5556 		show, "show");
5557 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
5558 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5559 		bonding, "bonding");
5560 cmdline_parse_token_string_t cmd_showbonding_config_config =
5561 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5562 		config, "config");
5563 cmdline_parse_token_num_t cmd_showbonding_config_port =
5564 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
5565 		port_id, UINT16);
5566 
5567 cmdline_parse_inst_t cmd_show_bonding_config = {
5568 		.f = cmd_show_bonding_config_parsed,
5569 		.help_str = "show bonding config <port_id>: "
5570 			"Show the bonding config for port_id",
5571 		.data = NULL,
5572 		.tokens = {
5573 				(void *)&cmd_showbonding_config_show,
5574 				(void *)&cmd_showbonding_config_bonding,
5575 				(void *)&cmd_showbonding_config_config,
5576 				(void *)&cmd_showbonding_config_port,
5577 				NULL
5578 		}
5579 };
5580 
5581 /* *** SET BONDING PRIMARY *** */
5582 struct cmd_set_bonding_primary_result {
5583 	cmdline_fixed_string_t set;
5584 	cmdline_fixed_string_t bonding;
5585 	cmdline_fixed_string_t primary;
5586 	portid_t slave_id;
5587 	portid_t port_id;
5588 };
5589 
5590 static void cmd_set_bonding_primary_parsed(void *parsed_result,
5591 		__attribute__((unused))  struct cmdline *cl,
5592 		__attribute__((unused)) void *data)
5593 {
5594 	struct cmd_set_bonding_primary_result *res = parsed_result;
5595 	portid_t master_port_id = res->port_id;
5596 	portid_t slave_port_id = res->slave_id;
5597 
5598 	/* Set the primary slave for a bonded device. */
5599 	if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
5600 		printf("\t Failed to set primary slave for port = %d.\n",
5601 				master_port_id);
5602 		return;
5603 	}
5604 	init_port_config();
5605 }
5606 
5607 cmdline_parse_token_string_t cmd_setbonding_primary_set =
5608 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5609 		set, "set");
5610 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
5611 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5612 		bonding, "bonding");
5613 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
5614 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5615 		primary, "primary");
5616 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
5617 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5618 		slave_id, UINT16);
5619 cmdline_parse_token_num_t cmd_setbonding_primary_port =
5620 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5621 		port_id, UINT16);
5622 
5623 cmdline_parse_inst_t cmd_set_bonding_primary = {
5624 		.f = cmd_set_bonding_primary_parsed,
5625 		.help_str = "set bonding primary <slave_id> <port_id>: "
5626 			"Set the primary slave for port_id",
5627 		.data = NULL,
5628 		.tokens = {
5629 				(void *)&cmd_setbonding_primary_set,
5630 				(void *)&cmd_setbonding_primary_bonding,
5631 				(void *)&cmd_setbonding_primary_primary,
5632 				(void *)&cmd_setbonding_primary_slave,
5633 				(void *)&cmd_setbonding_primary_port,
5634 				NULL
5635 		}
5636 };
5637 
5638 /* *** ADD SLAVE *** */
5639 struct cmd_add_bonding_slave_result {
5640 	cmdline_fixed_string_t add;
5641 	cmdline_fixed_string_t bonding;
5642 	cmdline_fixed_string_t slave;
5643 	portid_t slave_id;
5644 	portid_t port_id;
5645 };
5646 
5647 static void cmd_add_bonding_slave_parsed(void *parsed_result,
5648 		__attribute__((unused))  struct cmdline *cl,
5649 		__attribute__((unused)) void *data)
5650 {
5651 	struct cmd_add_bonding_slave_result *res = parsed_result;
5652 	portid_t master_port_id = res->port_id;
5653 	portid_t slave_port_id = res->slave_id;
5654 
5655 	/* add the slave for a bonded device. */
5656 	if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
5657 		printf("\t Failed to add slave %d to master port = %d.\n",
5658 				slave_port_id, master_port_id);
5659 		return;
5660 	}
5661 	init_port_config();
5662 	set_port_slave_flag(slave_port_id);
5663 }
5664 
5665 cmdline_parse_token_string_t cmd_addbonding_slave_add =
5666 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5667 		add, "add");
5668 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
5669 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5670 		bonding, "bonding");
5671 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
5672 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5673 		slave, "slave");
5674 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
5675 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5676 		slave_id, UINT16);
5677 cmdline_parse_token_num_t cmd_addbonding_slave_port =
5678 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5679 		port_id, UINT16);
5680 
5681 cmdline_parse_inst_t cmd_add_bonding_slave = {
5682 		.f = cmd_add_bonding_slave_parsed,
5683 		.help_str = "add bonding slave <slave_id> <port_id>: "
5684 			"Add a slave device to a bonded device",
5685 		.data = NULL,
5686 		.tokens = {
5687 				(void *)&cmd_addbonding_slave_add,
5688 				(void *)&cmd_addbonding_slave_bonding,
5689 				(void *)&cmd_addbonding_slave_slave,
5690 				(void *)&cmd_addbonding_slave_slaveid,
5691 				(void *)&cmd_addbonding_slave_port,
5692 				NULL
5693 		}
5694 };
5695 
5696 /* *** REMOVE SLAVE *** */
5697 struct cmd_remove_bonding_slave_result {
5698 	cmdline_fixed_string_t remove;
5699 	cmdline_fixed_string_t bonding;
5700 	cmdline_fixed_string_t slave;
5701 	portid_t slave_id;
5702 	portid_t port_id;
5703 };
5704 
5705 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
5706 		__attribute__((unused))  struct cmdline *cl,
5707 		__attribute__((unused)) void *data)
5708 {
5709 	struct cmd_remove_bonding_slave_result *res = parsed_result;
5710 	portid_t master_port_id = res->port_id;
5711 	portid_t slave_port_id = res->slave_id;
5712 
5713 	/* remove the slave from a bonded device. */
5714 	if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
5715 		printf("\t Failed to remove slave %d from master port = %d.\n",
5716 				slave_port_id, master_port_id);
5717 		return;
5718 	}
5719 	init_port_config();
5720 	clear_port_slave_flag(slave_port_id);
5721 }
5722 
5723 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
5724 		TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5725 				remove, "remove");
5726 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
5727 		TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5728 				bonding, "bonding");
5729 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
5730 		TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5731 				slave, "slave");
5732 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
5733 		TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5734 				slave_id, UINT16);
5735 cmdline_parse_token_num_t cmd_removebonding_slave_port =
5736 		TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5737 				port_id, UINT16);
5738 
5739 cmdline_parse_inst_t cmd_remove_bonding_slave = {
5740 		.f = cmd_remove_bonding_slave_parsed,
5741 		.help_str = "remove bonding slave <slave_id> <port_id>: "
5742 			"Remove a slave device from a bonded device",
5743 		.data = NULL,
5744 		.tokens = {
5745 				(void *)&cmd_removebonding_slave_remove,
5746 				(void *)&cmd_removebonding_slave_bonding,
5747 				(void *)&cmd_removebonding_slave_slave,
5748 				(void *)&cmd_removebonding_slave_slaveid,
5749 				(void *)&cmd_removebonding_slave_port,
5750 				NULL
5751 		}
5752 };
5753 
5754 /* *** CREATE BONDED DEVICE *** */
5755 struct cmd_create_bonded_device_result {
5756 	cmdline_fixed_string_t create;
5757 	cmdline_fixed_string_t bonded;
5758 	cmdline_fixed_string_t device;
5759 	uint8_t mode;
5760 	uint8_t socket;
5761 };
5762 
5763 static int bond_dev_num = 0;
5764 
5765 static void cmd_create_bonded_device_parsed(void *parsed_result,
5766 		__attribute__((unused))  struct cmdline *cl,
5767 		__attribute__((unused)) void *data)
5768 {
5769 	struct cmd_create_bonded_device_result *res = parsed_result;
5770 	char ethdev_name[RTE_ETH_NAME_MAX_LEN];
5771 	int port_id;
5772 
5773 	if (test_done == 0) {
5774 		printf("Please stop forwarding first\n");
5775 		return;
5776 	}
5777 
5778 	snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
5779 			bond_dev_num++);
5780 
5781 	/* Create a new bonded device. */
5782 	port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
5783 	if (port_id < 0) {
5784 		printf("\t Failed to create bonded device.\n");
5785 		return;
5786 	} else {
5787 		printf("Created new bonded device %s on (port %d).\n", ethdev_name,
5788 				port_id);
5789 
5790 		/* Update number of ports */
5791 		nb_ports = rte_eth_dev_count_avail();
5792 		reconfig(port_id, res->socket);
5793 		rte_eth_promiscuous_enable(port_id);
5794 	}
5795 
5796 }
5797 
5798 cmdline_parse_token_string_t cmd_createbonded_device_create =
5799 		TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5800 				create, "create");
5801 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
5802 		TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5803 				bonded, "bonded");
5804 cmdline_parse_token_string_t cmd_createbonded_device_device =
5805 		TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5806 				device, "device");
5807 cmdline_parse_token_num_t cmd_createbonded_device_mode =
5808 		TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5809 				mode, UINT8);
5810 cmdline_parse_token_num_t cmd_createbonded_device_socket =
5811 		TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5812 				socket, UINT8);
5813 
5814 cmdline_parse_inst_t cmd_create_bonded_device = {
5815 		.f = cmd_create_bonded_device_parsed,
5816 		.help_str = "create bonded device <mode> <socket>: "
5817 			"Create a new bonded device with specific bonding mode and socket",
5818 		.data = NULL,
5819 		.tokens = {
5820 				(void *)&cmd_createbonded_device_create,
5821 				(void *)&cmd_createbonded_device_bonded,
5822 				(void *)&cmd_createbonded_device_device,
5823 				(void *)&cmd_createbonded_device_mode,
5824 				(void *)&cmd_createbonded_device_socket,
5825 				NULL
5826 		}
5827 };
5828 
5829 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
5830 struct cmd_set_bond_mac_addr_result {
5831 	cmdline_fixed_string_t set;
5832 	cmdline_fixed_string_t bonding;
5833 	cmdline_fixed_string_t mac_addr;
5834 	uint16_t port_num;
5835 	struct ether_addr address;
5836 };
5837 
5838 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
5839 		__attribute__((unused))  struct cmdline *cl,
5840 		__attribute__((unused)) void *data)
5841 {
5842 	struct cmd_set_bond_mac_addr_result *res = parsed_result;
5843 	int ret;
5844 
5845 	if (port_id_is_invalid(res->port_num, ENABLED_WARN))
5846 		return;
5847 
5848 	ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
5849 
5850 	/* check the return value and print it if is < 0 */
5851 	if (ret < 0)
5852 		printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5853 }
5854 
5855 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
5856 		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
5857 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
5858 		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
5859 				"bonding");
5860 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
5861 		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
5862 				"mac_addr");
5863 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
5864 		TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
5865 				port_num, UINT16);
5866 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
5867 		TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
5868 
5869 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
5870 		.f = cmd_set_bond_mac_addr_parsed,
5871 		.data = (void *) 0,
5872 		.help_str = "set bonding mac_addr <port_id> <mac_addr>",
5873 		.tokens = {
5874 				(void *)&cmd_set_bond_mac_addr_set,
5875 				(void *)&cmd_set_bond_mac_addr_bonding,
5876 				(void *)&cmd_set_bond_mac_addr_mac,
5877 				(void *)&cmd_set_bond_mac_addr_portnum,
5878 				(void *)&cmd_set_bond_mac_addr_addr,
5879 				NULL
5880 		}
5881 };
5882 
5883 
5884 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
5885 struct cmd_set_bond_mon_period_result {
5886 	cmdline_fixed_string_t set;
5887 	cmdline_fixed_string_t bonding;
5888 	cmdline_fixed_string_t mon_period;
5889 	uint16_t port_num;
5890 	uint32_t period_ms;
5891 };
5892 
5893 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
5894 		__attribute__((unused))  struct cmdline *cl,
5895 		__attribute__((unused)) void *data)
5896 {
5897 	struct cmd_set_bond_mon_period_result *res = parsed_result;
5898 	int ret;
5899 
5900 	ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
5901 
5902 	/* check the return value and print it if is < 0 */
5903 	if (ret < 0)
5904 		printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5905 }
5906 
5907 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
5908 		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5909 				set, "set");
5910 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
5911 		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5912 				bonding, "bonding");
5913 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
5914 		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5915 				mon_period,	"mon_period");
5916 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
5917 		TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5918 				port_num, UINT16);
5919 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
5920 		TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5921 				period_ms, UINT32);
5922 
5923 cmdline_parse_inst_t cmd_set_bond_mon_period = {
5924 		.f = cmd_set_bond_mon_period_parsed,
5925 		.data = (void *) 0,
5926 		.help_str = "set bonding mon_period <port_id> <period_ms>",
5927 		.tokens = {
5928 				(void *)&cmd_set_bond_mon_period_set,
5929 				(void *)&cmd_set_bond_mon_period_bonding,
5930 				(void *)&cmd_set_bond_mon_period_mon_period,
5931 				(void *)&cmd_set_bond_mon_period_portnum,
5932 				(void *)&cmd_set_bond_mon_period_period_ms,
5933 				NULL
5934 		}
5935 };
5936 
5937 
5938 
5939 struct cmd_set_bonding_agg_mode_policy_result {
5940 	cmdline_fixed_string_t set;
5941 	cmdline_fixed_string_t bonding;
5942 	cmdline_fixed_string_t agg_mode;
5943 	uint16_t port_num;
5944 	cmdline_fixed_string_t policy;
5945 };
5946 
5947 
5948 static void
5949 cmd_set_bonding_agg_mode(void *parsed_result,
5950 		__attribute__((unused)) struct cmdline *cl,
5951 		__attribute__((unused)) void *data)
5952 {
5953 	struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
5954 	uint8_t policy = AGG_BANDWIDTH;
5955 
5956 	if (!strcmp(res->policy, "bandwidth"))
5957 		policy = AGG_BANDWIDTH;
5958 	else if (!strcmp(res->policy, "stable"))
5959 		policy = AGG_STABLE;
5960 	else if (!strcmp(res->policy, "count"))
5961 		policy = AGG_COUNT;
5962 
5963 	rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
5964 }
5965 
5966 
5967 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
5968 	TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5969 				set, "set");
5970 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
5971 	TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5972 				bonding, "bonding");
5973 
5974 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
5975 	TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5976 				agg_mode, "agg_mode");
5977 
5978 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
5979 	TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5980 				port_num, UINT16);
5981 
5982 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
5983 	TOKEN_STRING_INITIALIZER(
5984 			struct cmd_set_bonding_balance_xmit_policy_result,
5985 		policy, "stable#bandwidth#count");
5986 
5987 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
5988 	.f = cmd_set_bonding_agg_mode,
5989 	.data = (void *) 0,
5990 	.help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
5991 	.tokens = {
5992 			(void *)&cmd_set_bonding_agg_mode_set,
5993 			(void *)&cmd_set_bonding_agg_mode_bonding,
5994 			(void *)&cmd_set_bonding_agg_mode_agg_mode,
5995 			(void *)&cmd_set_bonding_agg_mode_portnum,
5996 			(void *)&cmd_set_bonding_agg_mode_policy_string,
5997 			NULL
5998 		}
5999 };
6000 
6001 
6002 #endif /* RTE_LIBRTE_PMD_BOND */
6003 
6004 /* *** SET FORWARDING MODE *** */
6005 struct cmd_set_fwd_mode_result {
6006 	cmdline_fixed_string_t set;
6007 	cmdline_fixed_string_t fwd;
6008 	cmdline_fixed_string_t mode;
6009 };
6010 
6011 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6012 				    __attribute__((unused)) struct cmdline *cl,
6013 				    __attribute__((unused)) void *data)
6014 {
6015 	struct cmd_set_fwd_mode_result *res = parsed_result;
6016 
6017 	retry_enabled = 0;
6018 	set_pkt_forwarding_mode(res->mode);
6019 }
6020 
6021 cmdline_parse_token_string_t cmd_setfwd_set =
6022 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6023 cmdline_parse_token_string_t cmd_setfwd_fwd =
6024 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6025 cmdline_parse_token_string_t cmd_setfwd_mode =
6026 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6027 		"" /* defined at init */);
6028 
6029 cmdline_parse_inst_t cmd_set_fwd_mode = {
6030 	.f = cmd_set_fwd_mode_parsed,
6031 	.data = NULL,
6032 	.help_str = NULL, /* defined at init */
6033 	.tokens = {
6034 		(void *)&cmd_setfwd_set,
6035 		(void *)&cmd_setfwd_fwd,
6036 		(void *)&cmd_setfwd_mode,
6037 		NULL,
6038 	},
6039 };
6040 
6041 static void cmd_set_fwd_mode_init(void)
6042 {
6043 	char *modes, *c;
6044 	static char token[128];
6045 	static char help[256];
6046 	cmdline_parse_token_string_t *token_struct;
6047 
6048 	modes = list_pkt_forwarding_modes();
6049 	snprintf(help, sizeof(help), "set fwd %s: "
6050 		"Set packet forwarding mode", modes);
6051 	cmd_set_fwd_mode.help_str = help;
6052 
6053 	/* string token separator is # */
6054 	for (c = token; *modes != '\0'; modes++)
6055 		if (*modes == '|')
6056 			*c++ = '#';
6057 		else
6058 			*c++ = *modes;
6059 	token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6060 	token_struct->string_data.str = token;
6061 }
6062 
6063 /* *** SET RETRY FORWARDING MODE *** */
6064 struct cmd_set_fwd_retry_mode_result {
6065 	cmdline_fixed_string_t set;
6066 	cmdline_fixed_string_t fwd;
6067 	cmdline_fixed_string_t mode;
6068 	cmdline_fixed_string_t retry;
6069 };
6070 
6071 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6072 			    __attribute__((unused)) struct cmdline *cl,
6073 			    __attribute__((unused)) void *data)
6074 {
6075 	struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6076 
6077 	retry_enabled = 1;
6078 	set_pkt_forwarding_mode(res->mode);
6079 }
6080 
6081 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6082 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6083 			set, "set");
6084 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6085 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6086 			fwd, "fwd");
6087 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6088 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6089 			mode,
6090 		"" /* defined at init */);
6091 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6092 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6093 			retry, "retry");
6094 
6095 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6096 	.f = cmd_set_fwd_retry_mode_parsed,
6097 	.data = NULL,
6098 	.help_str = NULL, /* defined at init */
6099 	.tokens = {
6100 		(void *)&cmd_setfwd_retry_set,
6101 		(void *)&cmd_setfwd_retry_fwd,
6102 		(void *)&cmd_setfwd_retry_mode,
6103 		(void *)&cmd_setfwd_retry_retry,
6104 		NULL,
6105 	},
6106 };
6107 
6108 static void cmd_set_fwd_retry_mode_init(void)
6109 {
6110 	char *modes, *c;
6111 	static char token[128];
6112 	static char help[256];
6113 	cmdline_parse_token_string_t *token_struct;
6114 
6115 	modes = list_pkt_forwarding_retry_modes();
6116 	snprintf(help, sizeof(help), "set fwd %s retry: "
6117 		"Set packet forwarding mode with retry", modes);
6118 	cmd_set_fwd_retry_mode.help_str = help;
6119 
6120 	/* string token separator is # */
6121 	for (c = token; *modes != '\0'; modes++)
6122 		if (*modes == '|')
6123 			*c++ = '#';
6124 		else
6125 			*c++ = *modes;
6126 	token_struct = (cmdline_parse_token_string_t *)
6127 		cmd_set_fwd_retry_mode.tokens[2];
6128 	token_struct->string_data.str = token;
6129 }
6130 
6131 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6132 struct cmd_set_burst_tx_retry_result {
6133 	cmdline_fixed_string_t set;
6134 	cmdline_fixed_string_t burst;
6135 	cmdline_fixed_string_t tx;
6136 	cmdline_fixed_string_t delay;
6137 	uint32_t time;
6138 	cmdline_fixed_string_t retry;
6139 	uint32_t retry_num;
6140 };
6141 
6142 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6143 					__attribute__((unused)) struct cmdline *cl,
6144 					__attribute__((unused)) void *data)
6145 {
6146 	struct cmd_set_burst_tx_retry_result *res = parsed_result;
6147 
6148 	if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6149 		&& !strcmp(res->tx, "tx")) {
6150 		if (!strcmp(res->delay, "delay"))
6151 			burst_tx_delay_time = res->time;
6152 		if (!strcmp(res->retry, "retry"))
6153 			burst_tx_retry_num = res->retry_num;
6154 	}
6155 
6156 }
6157 
6158 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6159 	TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6160 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6161 	TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6162 				 "burst");
6163 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6164 	TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6165 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6166 	TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6167 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6168 	TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
6169 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6170 	TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6171 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6172 	TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
6173 
6174 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6175 	.f = cmd_set_burst_tx_retry_parsed,
6176 	.help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6177 	.tokens = {
6178 		(void *)&cmd_set_burst_tx_retry_set,
6179 		(void *)&cmd_set_burst_tx_retry_burst,
6180 		(void *)&cmd_set_burst_tx_retry_tx,
6181 		(void *)&cmd_set_burst_tx_retry_delay,
6182 		(void *)&cmd_set_burst_tx_retry_time,
6183 		(void *)&cmd_set_burst_tx_retry_retry,
6184 		(void *)&cmd_set_burst_tx_retry_retry_num,
6185 		NULL,
6186 	},
6187 };
6188 
6189 /* *** SET PROMISC MODE *** */
6190 struct cmd_set_promisc_mode_result {
6191 	cmdline_fixed_string_t set;
6192 	cmdline_fixed_string_t promisc;
6193 	cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6194 	uint16_t port_num;               /* valid if "allports" argument == 0 */
6195 	cmdline_fixed_string_t mode;
6196 };
6197 
6198 static void cmd_set_promisc_mode_parsed(void *parsed_result,
6199 					__attribute__((unused)) struct cmdline *cl,
6200 					void *allports)
6201 {
6202 	struct cmd_set_promisc_mode_result *res = parsed_result;
6203 	int enable;
6204 	portid_t i;
6205 
6206 	if (!strcmp(res->mode, "on"))
6207 		enable = 1;
6208 	else
6209 		enable = 0;
6210 
6211 	/* all ports */
6212 	if (allports) {
6213 		RTE_ETH_FOREACH_DEV(i) {
6214 			if (enable)
6215 				rte_eth_promiscuous_enable(i);
6216 			else
6217 				rte_eth_promiscuous_disable(i);
6218 		}
6219 	}
6220 	else {
6221 		if (enable)
6222 			rte_eth_promiscuous_enable(res->port_num);
6223 		else
6224 			rte_eth_promiscuous_disable(res->port_num);
6225 	}
6226 }
6227 
6228 cmdline_parse_token_string_t cmd_setpromisc_set =
6229 	TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6230 cmdline_parse_token_string_t cmd_setpromisc_promisc =
6231 	TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6232 				 "promisc");
6233 cmdline_parse_token_string_t cmd_setpromisc_portall =
6234 	TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6235 				 "all");
6236 cmdline_parse_token_num_t cmd_setpromisc_portnum =
6237 	TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6238 			      UINT16);
6239 cmdline_parse_token_string_t cmd_setpromisc_mode =
6240 	TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6241 				 "on#off");
6242 
6243 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6244 	.f = cmd_set_promisc_mode_parsed,
6245 	.data = (void *)1,
6246 	.help_str = "set promisc all on|off: Set promisc mode for all ports",
6247 	.tokens = {
6248 		(void *)&cmd_setpromisc_set,
6249 		(void *)&cmd_setpromisc_promisc,
6250 		(void *)&cmd_setpromisc_portall,
6251 		(void *)&cmd_setpromisc_mode,
6252 		NULL,
6253 	},
6254 };
6255 
6256 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6257 	.f = cmd_set_promisc_mode_parsed,
6258 	.data = (void *)0,
6259 	.help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6260 	.tokens = {
6261 		(void *)&cmd_setpromisc_set,
6262 		(void *)&cmd_setpromisc_promisc,
6263 		(void *)&cmd_setpromisc_portnum,
6264 		(void *)&cmd_setpromisc_mode,
6265 		NULL,
6266 	},
6267 };
6268 
6269 /* *** SET ALLMULTI MODE *** */
6270 struct cmd_set_allmulti_mode_result {
6271 	cmdline_fixed_string_t set;
6272 	cmdline_fixed_string_t allmulti;
6273 	cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6274 	uint16_t port_num;               /* valid if "allports" argument == 0 */
6275 	cmdline_fixed_string_t mode;
6276 };
6277 
6278 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6279 					__attribute__((unused)) struct cmdline *cl,
6280 					void *allports)
6281 {
6282 	struct cmd_set_allmulti_mode_result *res = parsed_result;
6283 	int enable;
6284 	portid_t i;
6285 
6286 	if (!strcmp(res->mode, "on"))
6287 		enable = 1;
6288 	else
6289 		enable = 0;
6290 
6291 	/* all ports */
6292 	if (allports) {
6293 		RTE_ETH_FOREACH_DEV(i) {
6294 			if (enable)
6295 				rte_eth_allmulticast_enable(i);
6296 			else
6297 				rte_eth_allmulticast_disable(i);
6298 		}
6299 	}
6300 	else {
6301 		if (enable)
6302 			rte_eth_allmulticast_enable(res->port_num);
6303 		else
6304 			rte_eth_allmulticast_disable(res->port_num);
6305 	}
6306 }
6307 
6308 cmdline_parse_token_string_t cmd_setallmulti_set =
6309 	TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6310 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6311 	TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6312 				 "allmulti");
6313 cmdline_parse_token_string_t cmd_setallmulti_portall =
6314 	TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6315 				 "all");
6316 cmdline_parse_token_num_t cmd_setallmulti_portnum =
6317 	TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6318 			      UINT16);
6319 cmdline_parse_token_string_t cmd_setallmulti_mode =
6320 	TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6321 				 "on#off");
6322 
6323 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6324 	.f = cmd_set_allmulti_mode_parsed,
6325 	.data = (void *)1,
6326 	.help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6327 	.tokens = {
6328 		(void *)&cmd_setallmulti_set,
6329 		(void *)&cmd_setallmulti_allmulti,
6330 		(void *)&cmd_setallmulti_portall,
6331 		(void *)&cmd_setallmulti_mode,
6332 		NULL,
6333 	},
6334 };
6335 
6336 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6337 	.f = cmd_set_allmulti_mode_parsed,
6338 	.data = (void *)0,
6339 	.help_str = "set allmulti <port_id> on|off: "
6340 		"Set allmulti mode on port_id",
6341 	.tokens = {
6342 		(void *)&cmd_setallmulti_set,
6343 		(void *)&cmd_setallmulti_allmulti,
6344 		(void *)&cmd_setallmulti_portnum,
6345 		(void *)&cmd_setallmulti_mode,
6346 		NULL,
6347 	},
6348 };
6349 
6350 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
6351 struct cmd_link_flow_ctrl_set_result {
6352 	cmdline_fixed_string_t set;
6353 	cmdline_fixed_string_t flow_ctrl;
6354 	cmdline_fixed_string_t rx;
6355 	cmdline_fixed_string_t rx_lfc_mode;
6356 	cmdline_fixed_string_t tx;
6357 	cmdline_fixed_string_t tx_lfc_mode;
6358 	cmdline_fixed_string_t mac_ctrl_frame_fwd;
6359 	cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
6360 	cmdline_fixed_string_t autoneg_str;
6361 	cmdline_fixed_string_t autoneg;
6362 	cmdline_fixed_string_t hw_str;
6363 	uint32_t high_water;
6364 	cmdline_fixed_string_t lw_str;
6365 	uint32_t low_water;
6366 	cmdline_fixed_string_t pt_str;
6367 	uint16_t pause_time;
6368 	cmdline_fixed_string_t xon_str;
6369 	uint16_t send_xon;
6370 	portid_t port_id;
6371 };
6372 
6373 cmdline_parse_token_string_t cmd_lfc_set_set =
6374 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6375 				set, "set");
6376 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
6377 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6378 				flow_ctrl, "flow_ctrl");
6379 cmdline_parse_token_string_t cmd_lfc_set_rx =
6380 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6381 				rx, "rx");
6382 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
6383 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6384 				rx_lfc_mode, "on#off");
6385 cmdline_parse_token_string_t cmd_lfc_set_tx =
6386 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6387 				tx, "tx");
6388 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
6389 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6390 				tx_lfc_mode, "on#off");
6391 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
6392 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6393 				hw_str, "high_water");
6394 cmdline_parse_token_num_t cmd_lfc_set_high_water =
6395 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6396 				high_water, UINT32);
6397 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
6398 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6399 				lw_str, "low_water");
6400 cmdline_parse_token_num_t cmd_lfc_set_low_water =
6401 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6402 				low_water, UINT32);
6403 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
6404 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6405 				pt_str, "pause_time");
6406 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
6407 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6408 				pause_time, UINT16);
6409 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
6410 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6411 				xon_str, "send_xon");
6412 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
6413 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6414 				send_xon, UINT16);
6415 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
6416 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6417 				mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
6418 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6419 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6420 				mac_ctrl_frame_fwd_mode, "on#off");
6421 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6422 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6423 				autoneg_str, "autoneg");
6424 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6425 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6426 				autoneg, "on#off");
6427 cmdline_parse_token_num_t cmd_lfc_set_portid =
6428 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6429 				port_id, UINT16);
6430 
6431 /* forward declaration */
6432 static void
6433 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6434 			      void *data);
6435 
6436 cmdline_parse_inst_t cmd_link_flow_control_set = {
6437 	.f = cmd_link_flow_ctrl_set_parsed,
6438 	.data = NULL,
6439 	.help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6440 		"<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6441 		"autoneg on|off <port_id>: Configure the Ethernet flow control",
6442 	.tokens = {
6443 		(void *)&cmd_lfc_set_set,
6444 		(void *)&cmd_lfc_set_flow_ctrl,
6445 		(void *)&cmd_lfc_set_rx,
6446 		(void *)&cmd_lfc_set_rx_mode,
6447 		(void *)&cmd_lfc_set_tx,
6448 		(void *)&cmd_lfc_set_tx_mode,
6449 		(void *)&cmd_lfc_set_high_water,
6450 		(void *)&cmd_lfc_set_low_water,
6451 		(void *)&cmd_lfc_set_pause_time,
6452 		(void *)&cmd_lfc_set_send_xon,
6453 		(void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6454 		(void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6455 		(void *)&cmd_lfc_set_autoneg_str,
6456 		(void *)&cmd_lfc_set_autoneg,
6457 		(void *)&cmd_lfc_set_portid,
6458 		NULL,
6459 	},
6460 };
6461 
6462 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6463 	.f = cmd_link_flow_ctrl_set_parsed,
6464 	.data = (void *)&cmd_link_flow_control_set_rx,
6465 	.help_str = "set flow_ctrl rx on|off <port_id>: "
6466 		"Change rx flow control parameter",
6467 	.tokens = {
6468 		(void *)&cmd_lfc_set_set,
6469 		(void *)&cmd_lfc_set_flow_ctrl,
6470 		(void *)&cmd_lfc_set_rx,
6471 		(void *)&cmd_lfc_set_rx_mode,
6472 		(void *)&cmd_lfc_set_portid,
6473 		NULL,
6474 	},
6475 };
6476 
6477 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6478 	.f = cmd_link_flow_ctrl_set_parsed,
6479 	.data = (void *)&cmd_link_flow_control_set_tx,
6480 	.help_str = "set flow_ctrl tx on|off <port_id>: "
6481 		"Change tx flow control parameter",
6482 	.tokens = {
6483 		(void *)&cmd_lfc_set_set,
6484 		(void *)&cmd_lfc_set_flow_ctrl,
6485 		(void *)&cmd_lfc_set_tx,
6486 		(void *)&cmd_lfc_set_tx_mode,
6487 		(void *)&cmd_lfc_set_portid,
6488 		NULL,
6489 	},
6490 };
6491 
6492 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
6493 	.f = cmd_link_flow_ctrl_set_parsed,
6494 	.data = (void *)&cmd_link_flow_control_set_hw,
6495 	.help_str = "set flow_ctrl high_water <value> <port_id>: "
6496 		"Change high water flow control parameter",
6497 	.tokens = {
6498 		(void *)&cmd_lfc_set_set,
6499 		(void *)&cmd_lfc_set_flow_ctrl,
6500 		(void *)&cmd_lfc_set_high_water_str,
6501 		(void *)&cmd_lfc_set_high_water,
6502 		(void *)&cmd_lfc_set_portid,
6503 		NULL,
6504 	},
6505 };
6506 
6507 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
6508 	.f = cmd_link_flow_ctrl_set_parsed,
6509 	.data = (void *)&cmd_link_flow_control_set_lw,
6510 	.help_str = "set flow_ctrl low_water <value> <port_id>: "
6511 		"Change low water flow control parameter",
6512 	.tokens = {
6513 		(void *)&cmd_lfc_set_set,
6514 		(void *)&cmd_lfc_set_flow_ctrl,
6515 		(void *)&cmd_lfc_set_low_water_str,
6516 		(void *)&cmd_lfc_set_low_water,
6517 		(void *)&cmd_lfc_set_portid,
6518 		NULL,
6519 	},
6520 };
6521 
6522 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
6523 	.f = cmd_link_flow_ctrl_set_parsed,
6524 	.data = (void *)&cmd_link_flow_control_set_pt,
6525 	.help_str = "set flow_ctrl pause_time <value> <port_id>: "
6526 		"Change pause time flow control parameter",
6527 	.tokens = {
6528 		(void *)&cmd_lfc_set_set,
6529 		(void *)&cmd_lfc_set_flow_ctrl,
6530 		(void *)&cmd_lfc_set_pause_time_str,
6531 		(void *)&cmd_lfc_set_pause_time,
6532 		(void *)&cmd_lfc_set_portid,
6533 		NULL,
6534 	},
6535 };
6536 
6537 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
6538 	.f = cmd_link_flow_ctrl_set_parsed,
6539 	.data = (void *)&cmd_link_flow_control_set_xon,
6540 	.help_str = "set flow_ctrl send_xon <value> <port_id>: "
6541 		"Change send_xon flow control parameter",
6542 	.tokens = {
6543 		(void *)&cmd_lfc_set_set,
6544 		(void *)&cmd_lfc_set_flow_ctrl,
6545 		(void *)&cmd_lfc_set_send_xon_str,
6546 		(void *)&cmd_lfc_set_send_xon,
6547 		(void *)&cmd_lfc_set_portid,
6548 		NULL,
6549 	},
6550 };
6551 
6552 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
6553 	.f = cmd_link_flow_ctrl_set_parsed,
6554 	.data = (void *)&cmd_link_flow_control_set_macfwd,
6555 	.help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
6556 		"Change mac ctrl fwd flow control parameter",
6557 	.tokens = {
6558 		(void *)&cmd_lfc_set_set,
6559 		(void *)&cmd_lfc_set_flow_ctrl,
6560 		(void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6561 		(void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6562 		(void *)&cmd_lfc_set_portid,
6563 		NULL,
6564 	},
6565 };
6566 
6567 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
6568 	.f = cmd_link_flow_ctrl_set_parsed,
6569 	.data = (void *)&cmd_link_flow_control_set_autoneg,
6570 	.help_str = "set flow_ctrl autoneg on|off <port_id>: "
6571 		"Change autoneg flow control parameter",
6572 	.tokens = {
6573 		(void *)&cmd_lfc_set_set,
6574 		(void *)&cmd_lfc_set_flow_ctrl,
6575 		(void *)&cmd_lfc_set_autoneg_str,
6576 		(void *)&cmd_lfc_set_autoneg,
6577 		(void *)&cmd_lfc_set_portid,
6578 		NULL,
6579 	},
6580 };
6581 
6582 static void
6583 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
6584 			      __attribute__((unused)) struct cmdline *cl,
6585 			      void *data)
6586 {
6587 	struct cmd_link_flow_ctrl_set_result *res = parsed_result;
6588 	cmdline_parse_inst_t *cmd = data;
6589 	struct rte_eth_fc_conf fc_conf;
6590 	int rx_fc_en = 0;
6591 	int tx_fc_en = 0;
6592 	int ret;
6593 
6594 	/*
6595 	 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6596 	 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6597 	 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6598 	 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6599 	 */
6600 	static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
6601 			{RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
6602 	};
6603 
6604 	/* Partial command line, retrieve current configuration */
6605 	if (cmd) {
6606 		ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
6607 		if (ret != 0) {
6608 			printf("cannot get current flow ctrl parameters, return"
6609 			       "code = %d\n", ret);
6610 			return;
6611 		}
6612 
6613 		if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
6614 		    (fc_conf.mode == RTE_FC_FULL))
6615 			rx_fc_en = 1;
6616 		if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
6617 		    (fc_conf.mode == RTE_FC_FULL))
6618 			tx_fc_en = 1;
6619 	}
6620 
6621 	if (!cmd || cmd == &cmd_link_flow_control_set_rx)
6622 		rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
6623 
6624 	if (!cmd || cmd == &cmd_link_flow_control_set_tx)
6625 		tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
6626 
6627 	fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
6628 
6629 	if (!cmd || cmd == &cmd_link_flow_control_set_hw)
6630 		fc_conf.high_water = res->high_water;
6631 
6632 	if (!cmd || cmd == &cmd_link_flow_control_set_lw)
6633 		fc_conf.low_water = res->low_water;
6634 
6635 	if (!cmd || cmd == &cmd_link_flow_control_set_pt)
6636 		fc_conf.pause_time = res->pause_time;
6637 
6638 	if (!cmd || cmd == &cmd_link_flow_control_set_xon)
6639 		fc_conf.send_xon = res->send_xon;
6640 
6641 	if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
6642 		if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
6643 			fc_conf.mac_ctrl_frame_fwd = 1;
6644 		else
6645 			fc_conf.mac_ctrl_frame_fwd = 0;
6646 	}
6647 
6648 	if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
6649 		fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
6650 
6651 	ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
6652 	if (ret != 0)
6653 		printf("bad flow contrl parameter, return code = %d \n", ret);
6654 }
6655 
6656 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
6657 struct cmd_priority_flow_ctrl_set_result {
6658 	cmdline_fixed_string_t set;
6659 	cmdline_fixed_string_t pfc_ctrl;
6660 	cmdline_fixed_string_t rx;
6661 	cmdline_fixed_string_t rx_pfc_mode;
6662 	cmdline_fixed_string_t tx;
6663 	cmdline_fixed_string_t tx_pfc_mode;
6664 	uint32_t high_water;
6665 	uint32_t low_water;
6666 	uint16_t pause_time;
6667 	uint8_t  priority;
6668 	portid_t port_id;
6669 };
6670 
6671 static void
6672 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
6673 		       __attribute__((unused)) struct cmdline *cl,
6674 		       __attribute__((unused)) void *data)
6675 {
6676 	struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
6677 	struct rte_eth_pfc_conf pfc_conf;
6678 	int rx_fc_enable, tx_fc_enable;
6679 	int ret;
6680 
6681 	/*
6682 	 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6683 	 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6684 	 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6685 	 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6686 	 */
6687 	static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
6688 			{RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
6689 	};
6690 
6691 	rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
6692 	tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
6693 	pfc_conf.fc.mode       = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
6694 	pfc_conf.fc.high_water = res->high_water;
6695 	pfc_conf.fc.low_water  = res->low_water;
6696 	pfc_conf.fc.pause_time = res->pause_time;
6697 	pfc_conf.priority      = res->priority;
6698 
6699 	ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
6700 	if (ret != 0)
6701 		printf("bad priority flow contrl parameter, return code = %d \n", ret);
6702 }
6703 
6704 cmdline_parse_token_string_t cmd_pfc_set_set =
6705 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6706 				set, "set");
6707 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
6708 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6709 				pfc_ctrl, "pfc_ctrl");
6710 cmdline_parse_token_string_t cmd_pfc_set_rx =
6711 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6712 				rx, "rx");
6713 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
6714 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6715 				rx_pfc_mode, "on#off");
6716 cmdline_parse_token_string_t cmd_pfc_set_tx =
6717 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6718 				tx, "tx");
6719 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
6720 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6721 				tx_pfc_mode, "on#off");
6722 cmdline_parse_token_num_t cmd_pfc_set_high_water =
6723 	TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6724 				high_water, UINT32);
6725 cmdline_parse_token_num_t cmd_pfc_set_low_water =
6726 	TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6727 				low_water, UINT32);
6728 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
6729 	TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6730 				pause_time, UINT16);
6731 cmdline_parse_token_num_t cmd_pfc_set_priority =
6732 	TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6733 				priority, UINT8);
6734 cmdline_parse_token_num_t cmd_pfc_set_portid =
6735 	TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6736 				port_id, UINT16);
6737 
6738 cmdline_parse_inst_t cmd_priority_flow_control_set = {
6739 	.f = cmd_priority_flow_ctrl_set_parsed,
6740 	.data = NULL,
6741 	.help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
6742 		"<pause_time> <priority> <port_id>: "
6743 		"Configure the Ethernet priority flow control",
6744 	.tokens = {
6745 		(void *)&cmd_pfc_set_set,
6746 		(void *)&cmd_pfc_set_flow_ctrl,
6747 		(void *)&cmd_pfc_set_rx,
6748 		(void *)&cmd_pfc_set_rx_mode,
6749 		(void *)&cmd_pfc_set_tx,
6750 		(void *)&cmd_pfc_set_tx_mode,
6751 		(void *)&cmd_pfc_set_high_water,
6752 		(void *)&cmd_pfc_set_low_water,
6753 		(void *)&cmd_pfc_set_pause_time,
6754 		(void *)&cmd_pfc_set_priority,
6755 		(void *)&cmd_pfc_set_portid,
6756 		NULL,
6757 	},
6758 };
6759 
6760 /* *** RESET CONFIGURATION *** */
6761 struct cmd_reset_result {
6762 	cmdline_fixed_string_t reset;
6763 	cmdline_fixed_string_t def;
6764 };
6765 
6766 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
6767 			     struct cmdline *cl,
6768 			     __attribute__((unused)) void *data)
6769 {
6770 	cmdline_printf(cl, "Reset to default forwarding configuration...\n");
6771 	set_def_fwd_config();
6772 }
6773 
6774 cmdline_parse_token_string_t cmd_reset_set =
6775 	TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
6776 cmdline_parse_token_string_t cmd_reset_def =
6777 	TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
6778 				 "default");
6779 
6780 cmdline_parse_inst_t cmd_reset = {
6781 	.f = cmd_reset_parsed,
6782 	.data = NULL,
6783 	.help_str = "set default: Reset default forwarding configuration",
6784 	.tokens = {
6785 		(void *)&cmd_reset_set,
6786 		(void *)&cmd_reset_def,
6787 		NULL,
6788 	},
6789 };
6790 
6791 /* *** START FORWARDING *** */
6792 struct cmd_start_result {
6793 	cmdline_fixed_string_t start;
6794 };
6795 
6796 cmdline_parse_token_string_t cmd_start_start =
6797 	TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
6798 
6799 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
6800 			     __attribute__((unused)) struct cmdline *cl,
6801 			     __attribute__((unused)) void *data)
6802 {
6803 	start_packet_forwarding(0);
6804 }
6805 
6806 cmdline_parse_inst_t cmd_start = {
6807 	.f = cmd_start_parsed,
6808 	.data = NULL,
6809 	.help_str = "start: Start packet forwarding",
6810 	.tokens = {
6811 		(void *)&cmd_start_start,
6812 		NULL,
6813 	},
6814 };
6815 
6816 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
6817 struct cmd_start_tx_first_result {
6818 	cmdline_fixed_string_t start;
6819 	cmdline_fixed_string_t tx_first;
6820 };
6821 
6822 static void
6823 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
6824 			  __attribute__((unused)) struct cmdline *cl,
6825 			  __attribute__((unused)) void *data)
6826 {
6827 	start_packet_forwarding(1);
6828 }
6829 
6830 cmdline_parse_token_string_t cmd_start_tx_first_start =
6831 	TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
6832 				 "start");
6833 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
6834 	TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
6835 				 tx_first, "tx_first");
6836 
6837 cmdline_parse_inst_t cmd_start_tx_first = {
6838 	.f = cmd_start_tx_first_parsed,
6839 	.data = NULL,
6840 	.help_str = "start tx_first: Start packet forwarding, "
6841 		"after sending 1 burst of packets",
6842 	.tokens = {
6843 		(void *)&cmd_start_tx_first_start,
6844 		(void *)&cmd_start_tx_first_tx_first,
6845 		NULL,
6846 	},
6847 };
6848 
6849 /* *** START FORWARDING WITH N TX BURST FIRST *** */
6850 struct cmd_start_tx_first_n_result {
6851 	cmdline_fixed_string_t start;
6852 	cmdline_fixed_string_t tx_first;
6853 	uint32_t tx_num;
6854 };
6855 
6856 static void
6857 cmd_start_tx_first_n_parsed(void *parsed_result,
6858 			  __attribute__((unused)) struct cmdline *cl,
6859 			  __attribute__((unused)) void *data)
6860 {
6861 	struct cmd_start_tx_first_n_result *res = parsed_result;
6862 
6863 	start_packet_forwarding(res->tx_num);
6864 }
6865 
6866 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
6867 	TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6868 			start, "start");
6869 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
6870 	TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6871 			tx_first, "tx_first");
6872 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
6873 	TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
6874 			tx_num, UINT32);
6875 
6876 cmdline_parse_inst_t cmd_start_tx_first_n = {
6877 	.f = cmd_start_tx_first_n_parsed,
6878 	.data = NULL,
6879 	.help_str = "start tx_first <num>: "
6880 		"packet forwarding, after sending <num> bursts of packets",
6881 	.tokens = {
6882 		(void *)&cmd_start_tx_first_n_start,
6883 		(void *)&cmd_start_tx_first_n_tx_first,
6884 		(void *)&cmd_start_tx_first_n_tx_num,
6885 		NULL,
6886 	},
6887 };
6888 
6889 /* *** SET LINK UP *** */
6890 struct cmd_set_link_up_result {
6891 	cmdline_fixed_string_t set;
6892 	cmdline_fixed_string_t link_up;
6893 	cmdline_fixed_string_t port;
6894 	portid_t port_id;
6895 };
6896 
6897 cmdline_parse_token_string_t cmd_set_link_up_set =
6898 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
6899 cmdline_parse_token_string_t cmd_set_link_up_link_up =
6900 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
6901 				"link-up");
6902 cmdline_parse_token_string_t cmd_set_link_up_port =
6903 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
6904 cmdline_parse_token_num_t cmd_set_link_up_port_id =
6905 	TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16);
6906 
6907 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
6908 			     __attribute__((unused)) struct cmdline *cl,
6909 			     __attribute__((unused)) void *data)
6910 {
6911 	struct cmd_set_link_up_result *res = parsed_result;
6912 	dev_set_link_up(res->port_id);
6913 }
6914 
6915 cmdline_parse_inst_t cmd_set_link_up = {
6916 	.f = cmd_set_link_up_parsed,
6917 	.data = NULL,
6918 	.help_str = "set link-up port <port id>",
6919 	.tokens = {
6920 		(void *)&cmd_set_link_up_set,
6921 		(void *)&cmd_set_link_up_link_up,
6922 		(void *)&cmd_set_link_up_port,
6923 		(void *)&cmd_set_link_up_port_id,
6924 		NULL,
6925 	},
6926 };
6927 
6928 /* *** SET LINK DOWN *** */
6929 struct cmd_set_link_down_result {
6930 	cmdline_fixed_string_t set;
6931 	cmdline_fixed_string_t link_down;
6932 	cmdline_fixed_string_t port;
6933 	portid_t port_id;
6934 };
6935 
6936 cmdline_parse_token_string_t cmd_set_link_down_set =
6937 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
6938 cmdline_parse_token_string_t cmd_set_link_down_link_down =
6939 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
6940 				"link-down");
6941 cmdline_parse_token_string_t cmd_set_link_down_port =
6942 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
6943 cmdline_parse_token_num_t cmd_set_link_down_port_id =
6944 	TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16);
6945 
6946 static void cmd_set_link_down_parsed(
6947 				__attribute__((unused)) void *parsed_result,
6948 				__attribute__((unused)) struct cmdline *cl,
6949 				__attribute__((unused)) void *data)
6950 {
6951 	struct cmd_set_link_down_result *res = parsed_result;
6952 	dev_set_link_down(res->port_id);
6953 }
6954 
6955 cmdline_parse_inst_t cmd_set_link_down = {
6956 	.f = cmd_set_link_down_parsed,
6957 	.data = NULL,
6958 	.help_str = "set link-down port <port id>",
6959 	.tokens = {
6960 		(void *)&cmd_set_link_down_set,
6961 		(void *)&cmd_set_link_down_link_down,
6962 		(void *)&cmd_set_link_down_port,
6963 		(void *)&cmd_set_link_down_port_id,
6964 		NULL,
6965 	},
6966 };
6967 
6968 /* *** SHOW CFG *** */
6969 struct cmd_showcfg_result {
6970 	cmdline_fixed_string_t show;
6971 	cmdline_fixed_string_t cfg;
6972 	cmdline_fixed_string_t what;
6973 };
6974 
6975 static void cmd_showcfg_parsed(void *parsed_result,
6976 			       __attribute__((unused)) struct cmdline *cl,
6977 			       __attribute__((unused)) void *data)
6978 {
6979 	struct cmd_showcfg_result *res = parsed_result;
6980 	if (!strcmp(res->what, "rxtx"))
6981 		rxtx_config_display();
6982 	else if (!strcmp(res->what, "cores"))
6983 		fwd_lcores_config_display();
6984 	else if (!strcmp(res->what, "fwd"))
6985 		pkt_fwd_config_display(&cur_fwd_config);
6986 	else if (!strcmp(res->what, "txpkts"))
6987 		show_tx_pkt_segments();
6988 }
6989 
6990 cmdline_parse_token_string_t cmd_showcfg_show =
6991 	TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
6992 cmdline_parse_token_string_t cmd_showcfg_port =
6993 	TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
6994 cmdline_parse_token_string_t cmd_showcfg_what =
6995 	TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
6996 				 "rxtx#cores#fwd#txpkts");
6997 
6998 cmdline_parse_inst_t cmd_showcfg = {
6999 	.f = cmd_showcfg_parsed,
7000 	.data = NULL,
7001 	.help_str = "show config rxtx|cores|fwd|txpkts",
7002 	.tokens = {
7003 		(void *)&cmd_showcfg_show,
7004 		(void *)&cmd_showcfg_port,
7005 		(void *)&cmd_showcfg_what,
7006 		NULL,
7007 	},
7008 };
7009 
7010 /* *** SHOW ALL PORT INFO *** */
7011 struct cmd_showportall_result {
7012 	cmdline_fixed_string_t show;
7013 	cmdline_fixed_string_t port;
7014 	cmdline_fixed_string_t what;
7015 	cmdline_fixed_string_t all;
7016 };
7017 
7018 static void cmd_showportall_parsed(void *parsed_result,
7019 				__attribute__((unused)) struct cmdline *cl,
7020 				__attribute__((unused)) void *data)
7021 {
7022 	portid_t i;
7023 
7024 	struct cmd_showportall_result *res = parsed_result;
7025 	if (!strcmp(res->show, "clear")) {
7026 		if (!strcmp(res->what, "stats"))
7027 			RTE_ETH_FOREACH_DEV(i)
7028 				nic_stats_clear(i);
7029 		else if (!strcmp(res->what, "xstats"))
7030 			RTE_ETH_FOREACH_DEV(i)
7031 				nic_xstats_clear(i);
7032 	} else if (!strcmp(res->what, "info"))
7033 		RTE_ETH_FOREACH_DEV(i)
7034 			port_infos_display(i);
7035 	else if (!strcmp(res->what, "stats"))
7036 		RTE_ETH_FOREACH_DEV(i)
7037 			nic_stats_display(i);
7038 	else if (!strcmp(res->what, "xstats"))
7039 		RTE_ETH_FOREACH_DEV(i)
7040 			nic_xstats_display(i);
7041 	else if (!strcmp(res->what, "fdir"))
7042 		RTE_ETH_FOREACH_DEV(i)
7043 			fdir_get_infos(i);
7044 	else if (!strcmp(res->what, "stat_qmap"))
7045 		RTE_ETH_FOREACH_DEV(i)
7046 			nic_stats_mapping_display(i);
7047 	else if (!strcmp(res->what, "dcb_tc"))
7048 		RTE_ETH_FOREACH_DEV(i)
7049 			port_dcb_info_display(i);
7050 	else if (!strcmp(res->what, "cap"))
7051 		RTE_ETH_FOREACH_DEV(i)
7052 			port_offload_cap_display(i);
7053 }
7054 
7055 cmdline_parse_token_string_t cmd_showportall_show =
7056 	TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7057 				 "show#clear");
7058 cmdline_parse_token_string_t cmd_showportall_port =
7059 	TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7060 cmdline_parse_token_string_t cmd_showportall_what =
7061 	TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7062 				 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7063 cmdline_parse_token_string_t cmd_showportall_all =
7064 	TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7065 cmdline_parse_inst_t cmd_showportall = {
7066 	.f = cmd_showportall_parsed,
7067 	.data = NULL,
7068 	.help_str = "show|clear port "
7069 		"info|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
7070 	.tokens = {
7071 		(void *)&cmd_showportall_show,
7072 		(void *)&cmd_showportall_port,
7073 		(void *)&cmd_showportall_what,
7074 		(void *)&cmd_showportall_all,
7075 		NULL,
7076 	},
7077 };
7078 
7079 /* *** SHOW PORT INFO *** */
7080 struct cmd_showport_result {
7081 	cmdline_fixed_string_t show;
7082 	cmdline_fixed_string_t port;
7083 	cmdline_fixed_string_t what;
7084 	uint16_t portnum;
7085 };
7086 
7087 static void cmd_showport_parsed(void *parsed_result,
7088 				__attribute__((unused)) struct cmdline *cl,
7089 				__attribute__((unused)) void *data)
7090 {
7091 	struct cmd_showport_result *res = parsed_result;
7092 	if (!strcmp(res->show, "clear")) {
7093 		if (!strcmp(res->what, "stats"))
7094 			nic_stats_clear(res->portnum);
7095 		else if (!strcmp(res->what, "xstats"))
7096 			nic_xstats_clear(res->portnum);
7097 	} else if (!strcmp(res->what, "info"))
7098 		port_infos_display(res->portnum);
7099 	else if (!strcmp(res->what, "stats"))
7100 		nic_stats_display(res->portnum);
7101 	else if (!strcmp(res->what, "xstats"))
7102 		nic_xstats_display(res->portnum);
7103 	else if (!strcmp(res->what, "fdir"))
7104 		 fdir_get_infos(res->portnum);
7105 	else if (!strcmp(res->what, "stat_qmap"))
7106 		nic_stats_mapping_display(res->portnum);
7107 	else if (!strcmp(res->what, "dcb_tc"))
7108 		port_dcb_info_display(res->portnum);
7109 	else if (!strcmp(res->what, "cap"))
7110 		port_offload_cap_display(res->portnum);
7111 }
7112 
7113 cmdline_parse_token_string_t cmd_showport_show =
7114 	TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7115 				 "show#clear");
7116 cmdline_parse_token_string_t cmd_showport_port =
7117 	TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7118 cmdline_parse_token_string_t cmd_showport_what =
7119 	TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7120 				 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7121 cmdline_parse_token_num_t cmd_showport_portnum =
7122 	TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
7123 
7124 cmdline_parse_inst_t cmd_showport = {
7125 	.f = cmd_showport_parsed,
7126 	.data = NULL,
7127 	.help_str = "show|clear port "
7128 		"info|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
7129 		"<port_id>",
7130 	.tokens = {
7131 		(void *)&cmd_showport_show,
7132 		(void *)&cmd_showport_port,
7133 		(void *)&cmd_showport_what,
7134 		(void *)&cmd_showport_portnum,
7135 		NULL,
7136 	},
7137 };
7138 
7139 /* *** SHOW QUEUE INFO *** */
7140 struct cmd_showqueue_result {
7141 	cmdline_fixed_string_t show;
7142 	cmdline_fixed_string_t type;
7143 	cmdline_fixed_string_t what;
7144 	uint16_t portnum;
7145 	uint16_t queuenum;
7146 };
7147 
7148 static void
7149 cmd_showqueue_parsed(void *parsed_result,
7150 	__attribute__((unused)) struct cmdline *cl,
7151 	__attribute__((unused)) void *data)
7152 {
7153 	struct cmd_showqueue_result *res = parsed_result;
7154 
7155 	if (!strcmp(res->type, "rxq"))
7156 		rx_queue_infos_display(res->portnum, res->queuenum);
7157 	else if (!strcmp(res->type, "txq"))
7158 		tx_queue_infos_display(res->portnum, res->queuenum);
7159 }
7160 
7161 cmdline_parse_token_string_t cmd_showqueue_show =
7162 	TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
7163 cmdline_parse_token_string_t cmd_showqueue_type =
7164 	TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
7165 cmdline_parse_token_string_t cmd_showqueue_what =
7166 	TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
7167 cmdline_parse_token_num_t cmd_showqueue_portnum =
7168 	TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16);
7169 cmdline_parse_token_num_t cmd_showqueue_queuenum =
7170 	TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
7171 
7172 cmdline_parse_inst_t cmd_showqueue = {
7173 	.f = cmd_showqueue_parsed,
7174 	.data = NULL,
7175 	.help_str = "show rxq|txq info <port_id> <queue_id>",
7176 	.tokens = {
7177 		(void *)&cmd_showqueue_show,
7178 		(void *)&cmd_showqueue_type,
7179 		(void *)&cmd_showqueue_what,
7180 		(void *)&cmd_showqueue_portnum,
7181 		(void *)&cmd_showqueue_queuenum,
7182 		NULL,
7183 	},
7184 };
7185 
7186 /* *** READ PORT REGISTER *** */
7187 struct cmd_read_reg_result {
7188 	cmdline_fixed_string_t read;
7189 	cmdline_fixed_string_t reg;
7190 	portid_t port_id;
7191 	uint32_t reg_off;
7192 };
7193 
7194 static void
7195 cmd_read_reg_parsed(void *parsed_result,
7196 		    __attribute__((unused)) struct cmdline *cl,
7197 		    __attribute__((unused)) void *data)
7198 {
7199 	struct cmd_read_reg_result *res = parsed_result;
7200 	port_reg_display(res->port_id, res->reg_off);
7201 }
7202 
7203 cmdline_parse_token_string_t cmd_read_reg_read =
7204 	TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
7205 cmdline_parse_token_string_t cmd_read_reg_reg =
7206 	TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
7207 cmdline_parse_token_num_t cmd_read_reg_port_id =
7208 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16);
7209 cmdline_parse_token_num_t cmd_read_reg_reg_off =
7210 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
7211 
7212 cmdline_parse_inst_t cmd_read_reg = {
7213 	.f = cmd_read_reg_parsed,
7214 	.data = NULL,
7215 	.help_str = "read reg <port_id> <reg_off>",
7216 	.tokens = {
7217 		(void *)&cmd_read_reg_read,
7218 		(void *)&cmd_read_reg_reg,
7219 		(void *)&cmd_read_reg_port_id,
7220 		(void *)&cmd_read_reg_reg_off,
7221 		NULL,
7222 	},
7223 };
7224 
7225 /* *** READ PORT REGISTER BIT FIELD *** */
7226 struct cmd_read_reg_bit_field_result {
7227 	cmdline_fixed_string_t read;
7228 	cmdline_fixed_string_t regfield;
7229 	portid_t port_id;
7230 	uint32_t reg_off;
7231 	uint8_t bit1_pos;
7232 	uint8_t bit2_pos;
7233 };
7234 
7235 static void
7236 cmd_read_reg_bit_field_parsed(void *parsed_result,
7237 			      __attribute__((unused)) struct cmdline *cl,
7238 			      __attribute__((unused)) void *data)
7239 {
7240 	struct cmd_read_reg_bit_field_result *res = parsed_result;
7241 	port_reg_bit_field_display(res->port_id, res->reg_off,
7242 				   res->bit1_pos, res->bit2_pos);
7243 }
7244 
7245 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
7246 	TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
7247 				 "read");
7248 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
7249 	TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
7250 				 regfield, "regfield");
7251 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
7252 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
7253 			      UINT16);
7254 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
7255 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
7256 			      UINT32);
7257 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
7258 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
7259 			      UINT8);
7260 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
7261 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
7262 			      UINT8);
7263 
7264 cmdline_parse_inst_t cmd_read_reg_bit_field = {
7265 	.f = cmd_read_reg_bit_field_parsed,
7266 	.data = NULL,
7267 	.help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
7268 	"Read register bit field between bit_x and bit_y included",
7269 	.tokens = {
7270 		(void *)&cmd_read_reg_bit_field_read,
7271 		(void *)&cmd_read_reg_bit_field_regfield,
7272 		(void *)&cmd_read_reg_bit_field_port_id,
7273 		(void *)&cmd_read_reg_bit_field_reg_off,
7274 		(void *)&cmd_read_reg_bit_field_bit1_pos,
7275 		(void *)&cmd_read_reg_bit_field_bit2_pos,
7276 		NULL,
7277 	},
7278 };
7279 
7280 /* *** READ PORT REGISTER BIT *** */
7281 struct cmd_read_reg_bit_result {
7282 	cmdline_fixed_string_t read;
7283 	cmdline_fixed_string_t regbit;
7284 	portid_t port_id;
7285 	uint32_t reg_off;
7286 	uint8_t bit_pos;
7287 };
7288 
7289 static void
7290 cmd_read_reg_bit_parsed(void *parsed_result,
7291 			__attribute__((unused)) struct cmdline *cl,
7292 			__attribute__((unused)) void *data)
7293 {
7294 	struct cmd_read_reg_bit_result *res = parsed_result;
7295 	port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
7296 }
7297 
7298 cmdline_parse_token_string_t cmd_read_reg_bit_read =
7299 	TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
7300 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
7301 	TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
7302 				 regbit, "regbit");
7303 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
7304 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16);
7305 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
7306 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
7307 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
7308 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
7309 
7310 cmdline_parse_inst_t cmd_read_reg_bit = {
7311 	.f = cmd_read_reg_bit_parsed,
7312 	.data = NULL,
7313 	.help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
7314 	.tokens = {
7315 		(void *)&cmd_read_reg_bit_read,
7316 		(void *)&cmd_read_reg_bit_regbit,
7317 		(void *)&cmd_read_reg_bit_port_id,
7318 		(void *)&cmd_read_reg_bit_reg_off,
7319 		(void *)&cmd_read_reg_bit_bit_pos,
7320 		NULL,
7321 	},
7322 };
7323 
7324 /* *** WRITE PORT REGISTER *** */
7325 struct cmd_write_reg_result {
7326 	cmdline_fixed_string_t write;
7327 	cmdline_fixed_string_t reg;
7328 	portid_t port_id;
7329 	uint32_t reg_off;
7330 	uint32_t value;
7331 };
7332 
7333 static void
7334 cmd_write_reg_parsed(void *parsed_result,
7335 		     __attribute__((unused)) struct cmdline *cl,
7336 		     __attribute__((unused)) void *data)
7337 {
7338 	struct cmd_write_reg_result *res = parsed_result;
7339 	port_reg_set(res->port_id, res->reg_off, res->value);
7340 }
7341 
7342 cmdline_parse_token_string_t cmd_write_reg_write =
7343 	TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
7344 cmdline_parse_token_string_t cmd_write_reg_reg =
7345 	TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
7346 cmdline_parse_token_num_t cmd_write_reg_port_id =
7347 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16);
7348 cmdline_parse_token_num_t cmd_write_reg_reg_off =
7349 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
7350 cmdline_parse_token_num_t cmd_write_reg_value =
7351 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
7352 
7353 cmdline_parse_inst_t cmd_write_reg = {
7354 	.f = cmd_write_reg_parsed,
7355 	.data = NULL,
7356 	.help_str = "write reg <port_id> <reg_off> <reg_value>",
7357 	.tokens = {
7358 		(void *)&cmd_write_reg_write,
7359 		(void *)&cmd_write_reg_reg,
7360 		(void *)&cmd_write_reg_port_id,
7361 		(void *)&cmd_write_reg_reg_off,
7362 		(void *)&cmd_write_reg_value,
7363 		NULL,
7364 	},
7365 };
7366 
7367 /* *** WRITE PORT REGISTER BIT FIELD *** */
7368 struct cmd_write_reg_bit_field_result {
7369 	cmdline_fixed_string_t write;
7370 	cmdline_fixed_string_t regfield;
7371 	portid_t port_id;
7372 	uint32_t reg_off;
7373 	uint8_t bit1_pos;
7374 	uint8_t bit2_pos;
7375 	uint32_t value;
7376 };
7377 
7378 static void
7379 cmd_write_reg_bit_field_parsed(void *parsed_result,
7380 			       __attribute__((unused)) struct cmdline *cl,
7381 			       __attribute__((unused)) void *data)
7382 {
7383 	struct cmd_write_reg_bit_field_result *res = parsed_result;
7384 	port_reg_bit_field_set(res->port_id, res->reg_off,
7385 			  res->bit1_pos, res->bit2_pos, res->value);
7386 }
7387 
7388 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
7389 	TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
7390 				 "write");
7391 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
7392 	TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
7393 				 regfield, "regfield");
7394 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
7395 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
7396 			      UINT16);
7397 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
7398 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
7399 			      UINT32);
7400 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
7401 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
7402 			      UINT8);
7403 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
7404 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
7405 			      UINT8);
7406 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
7407 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
7408 			      UINT32);
7409 
7410 cmdline_parse_inst_t cmd_write_reg_bit_field = {
7411 	.f = cmd_write_reg_bit_field_parsed,
7412 	.data = NULL,
7413 	.help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
7414 		"<reg_value>: "
7415 		"Set register bit field between bit_x and bit_y included",
7416 	.tokens = {
7417 		(void *)&cmd_write_reg_bit_field_write,
7418 		(void *)&cmd_write_reg_bit_field_regfield,
7419 		(void *)&cmd_write_reg_bit_field_port_id,
7420 		(void *)&cmd_write_reg_bit_field_reg_off,
7421 		(void *)&cmd_write_reg_bit_field_bit1_pos,
7422 		(void *)&cmd_write_reg_bit_field_bit2_pos,
7423 		(void *)&cmd_write_reg_bit_field_value,
7424 		NULL,
7425 	},
7426 };
7427 
7428 /* *** WRITE PORT REGISTER BIT *** */
7429 struct cmd_write_reg_bit_result {
7430 	cmdline_fixed_string_t write;
7431 	cmdline_fixed_string_t regbit;
7432 	portid_t port_id;
7433 	uint32_t reg_off;
7434 	uint8_t bit_pos;
7435 	uint8_t value;
7436 };
7437 
7438 static void
7439 cmd_write_reg_bit_parsed(void *parsed_result,
7440 			 __attribute__((unused)) struct cmdline *cl,
7441 			 __attribute__((unused)) void *data)
7442 {
7443 	struct cmd_write_reg_bit_result *res = parsed_result;
7444 	port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
7445 }
7446 
7447 cmdline_parse_token_string_t cmd_write_reg_bit_write =
7448 	TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
7449 				 "write");
7450 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
7451 	TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
7452 				 regbit, "regbit");
7453 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
7454 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16);
7455 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
7456 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
7457 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
7458 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
7459 cmdline_parse_token_num_t cmd_write_reg_bit_value =
7460 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
7461 
7462 cmdline_parse_inst_t cmd_write_reg_bit = {
7463 	.f = cmd_write_reg_bit_parsed,
7464 	.data = NULL,
7465 	.help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
7466 		"0 <= bit_x <= 31",
7467 	.tokens = {
7468 		(void *)&cmd_write_reg_bit_write,
7469 		(void *)&cmd_write_reg_bit_regbit,
7470 		(void *)&cmd_write_reg_bit_port_id,
7471 		(void *)&cmd_write_reg_bit_reg_off,
7472 		(void *)&cmd_write_reg_bit_bit_pos,
7473 		(void *)&cmd_write_reg_bit_value,
7474 		NULL,
7475 	},
7476 };
7477 
7478 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
7479 struct cmd_read_rxd_txd_result {
7480 	cmdline_fixed_string_t read;
7481 	cmdline_fixed_string_t rxd_txd;
7482 	portid_t port_id;
7483 	uint16_t queue_id;
7484 	uint16_t desc_id;
7485 };
7486 
7487 static void
7488 cmd_read_rxd_txd_parsed(void *parsed_result,
7489 			__attribute__((unused)) struct cmdline *cl,
7490 			__attribute__((unused)) void *data)
7491 {
7492 	struct cmd_read_rxd_txd_result *res = parsed_result;
7493 
7494 	if (!strcmp(res->rxd_txd, "rxd"))
7495 		rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7496 	else if (!strcmp(res->rxd_txd, "txd"))
7497 		tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7498 }
7499 
7500 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
7501 	TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
7502 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
7503 	TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
7504 				 "rxd#txd");
7505 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
7506 	TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16);
7507 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
7508 	TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
7509 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
7510 	TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
7511 
7512 cmdline_parse_inst_t cmd_read_rxd_txd = {
7513 	.f = cmd_read_rxd_txd_parsed,
7514 	.data = NULL,
7515 	.help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
7516 	.tokens = {
7517 		(void *)&cmd_read_rxd_txd_read,
7518 		(void *)&cmd_read_rxd_txd_rxd_txd,
7519 		(void *)&cmd_read_rxd_txd_port_id,
7520 		(void *)&cmd_read_rxd_txd_queue_id,
7521 		(void *)&cmd_read_rxd_txd_desc_id,
7522 		NULL,
7523 	},
7524 };
7525 
7526 /* *** QUIT *** */
7527 struct cmd_quit_result {
7528 	cmdline_fixed_string_t quit;
7529 };
7530 
7531 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
7532 			    struct cmdline *cl,
7533 			    __attribute__((unused)) void *data)
7534 {
7535 	pmd_test_exit();
7536 	cmdline_quit(cl);
7537 }
7538 
7539 cmdline_parse_token_string_t cmd_quit_quit =
7540 	TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
7541 
7542 cmdline_parse_inst_t cmd_quit = {
7543 	.f = cmd_quit_parsed,
7544 	.data = NULL,
7545 	.help_str = "quit: Exit application",
7546 	.tokens = {
7547 		(void *)&cmd_quit_quit,
7548 		NULL,
7549 	},
7550 };
7551 
7552 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
7553 struct cmd_mac_addr_result {
7554 	cmdline_fixed_string_t mac_addr_cmd;
7555 	cmdline_fixed_string_t what;
7556 	uint16_t port_num;
7557 	struct ether_addr address;
7558 };
7559 
7560 static void cmd_mac_addr_parsed(void *parsed_result,
7561 		__attribute__((unused)) struct cmdline *cl,
7562 		__attribute__((unused)) void *data)
7563 {
7564 	struct cmd_mac_addr_result *res = parsed_result;
7565 	int ret;
7566 
7567 	if (strcmp(res->what, "add") == 0)
7568 		ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
7569 	else if (strcmp(res->what, "set") == 0)
7570 		ret = rte_eth_dev_default_mac_addr_set(res->port_num,
7571 						       &res->address);
7572 	else
7573 		ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
7574 
7575 	/* check the return value and print it if is < 0 */
7576 	if(ret < 0)
7577 		printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
7578 
7579 }
7580 
7581 cmdline_parse_token_string_t cmd_mac_addr_cmd =
7582 	TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
7583 				"mac_addr");
7584 cmdline_parse_token_string_t cmd_mac_addr_what =
7585 	TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
7586 				"add#remove#set");
7587 cmdline_parse_token_num_t cmd_mac_addr_portnum =
7588 		TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
7589 					UINT16);
7590 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
7591 		TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
7592 
7593 cmdline_parse_inst_t cmd_mac_addr = {
7594 	.f = cmd_mac_addr_parsed,
7595 	.data = (void *)0,
7596 	.help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
7597 			"Add/Remove/Set MAC address on port_id",
7598 	.tokens = {
7599 		(void *)&cmd_mac_addr_cmd,
7600 		(void *)&cmd_mac_addr_what,
7601 		(void *)&cmd_mac_addr_portnum,
7602 		(void *)&cmd_mac_addr_addr,
7603 		NULL,
7604 	},
7605 };
7606 
7607 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
7608 struct cmd_eth_peer_result {
7609 	cmdline_fixed_string_t set;
7610 	cmdline_fixed_string_t eth_peer;
7611 	portid_t port_id;
7612 	cmdline_fixed_string_t peer_addr;
7613 };
7614 
7615 static void cmd_set_eth_peer_parsed(void *parsed_result,
7616 			__attribute__((unused)) struct cmdline *cl,
7617 			__attribute__((unused)) void *data)
7618 {
7619 		struct cmd_eth_peer_result *res = parsed_result;
7620 
7621 		if (test_done == 0) {
7622 			printf("Please stop forwarding first\n");
7623 			return;
7624 		}
7625 		if (!strcmp(res->eth_peer, "eth-peer")) {
7626 			set_fwd_eth_peer(res->port_id, res->peer_addr);
7627 			fwd_config_setup();
7628 		}
7629 }
7630 cmdline_parse_token_string_t cmd_eth_peer_set =
7631 	TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
7632 cmdline_parse_token_string_t cmd_eth_peer =
7633 	TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
7634 cmdline_parse_token_num_t cmd_eth_peer_port_id =
7635 	TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, UINT16);
7636 cmdline_parse_token_string_t cmd_eth_peer_addr =
7637 	TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
7638 
7639 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
7640 	.f = cmd_set_eth_peer_parsed,
7641 	.data = NULL,
7642 	.help_str = "set eth-peer <port_id> <peer_mac>",
7643 	.tokens = {
7644 		(void *)&cmd_eth_peer_set,
7645 		(void *)&cmd_eth_peer,
7646 		(void *)&cmd_eth_peer_port_id,
7647 		(void *)&cmd_eth_peer_addr,
7648 		NULL,
7649 	},
7650 };
7651 
7652 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
7653 struct cmd_set_qmap_result {
7654 	cmdline_fixed_string_t set;
7655 	cmdline_fixed_string_t qmap;
7656 	cmdline_fixed_string_t what;
7657 	portid_t port_id;
7658 	uint16_t queue_id;
7659 	uint8_t map_value;
7660 };
7661 
7662 static void
7663 cmd_set_qmap_parsed(void *parsed_result,
7664 		       __attribute__((unused)) struct cmdline *cl,
7665 		       __attribute__((unused)) void *data)
7666 {
7667 	struct cmd_set_qmap_result *res = parsed_result;
7668 	int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
7669 
7670 	set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
7671 }
7672 
7673 cmdline_parse_token_string_t cmd_setqmap_set =
7674 	TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7675 				 set, "set");
7676 cmdline_parse_token_string_t cmd_setqmap_qmap =
7677 	TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7678 				 qmap, "stat_qmap");
7679 cmdline_parse_token_string_t cmd_setqmap_what =
7680 	TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7681 				 what, "tx#rx");
7682 cmdline_parse_token_num_t cmd_setqmap_portid =
7683 	TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7684 			      port_id, UINT16);
7685 cmdline_parse_token_num_t cmd_setqmap_queueid =
7686 	TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7687 			      queue_id, UINT16);
7688 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
7689 	TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7690 			      map_value, UINT8);
7691 
7692 cmdline_parse_inst_t cmd_set_qmap = {
7693 	.f = cmd_set_qmap_parsed,
7694 	.data = NULL,
7695 	.help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
7696 		"Set statistics mapping value on tx|rx queue_id of port_id",
7697 	.tokens = {
7698 		(void *)&cmd_setqmap_set,
7699 		(void *)&cmd_setqmap_qmap,
7700 		(void *)&cmd_setqmap_what,
7701 		(void *)&cmd_setqmap_portid,
7702 		(void *)&cmd_setqmap_queueid,
7703 		(void *)&cmd_setqmap_mapvalue,
7704 		NULL,
7705 	},
7706 };
7707 
7708 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS  DISPLAY *** */
7709 struct cmd_set_xstats_hide_zero_result {
7710 	cmdline_fixed_string_t keyword;
7711 	cmdline_fixed_string_t name;
7712 	cmdline_fixed_string_t on_off;
7713 };
7714 
7715 static void
7716 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
7717 			__attribute__((unused)) struct cmdline *cl,
7718 			__attribute__((unused)) void *data)
7719 {
7720 	struct cmd_set_xstats_hide_zero_result *res;
7721 	uint16_t on_off = 0;
7722 
7723 	res = parsed_result;
7724 	on_off = !strcmp(res->on_off, "on") ? 1 : 0;
7725 	set_xstats_hide_zero(on_off);
7726 }
7727 
7728 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
7729 	TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7730 				 keyword, "set");
7731 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
7732 	TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7733 				 name, "xstats-hide-zero");
7734 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
7735 	TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7736 				 on_off, "on#off");
7737 
7738 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
7739 	.f = cmd_set_xstats_hide_zero_parsed,
7740 	.data = NULL,
7741 	.help_str = "set xstats-hide-zero on|off",
7742 	.tokens = {
7743 		(void *)&cmd_set_xstats_hide_zero_keyword,
7744 		(void *)&cmd_set_xstats_hide_zero_name,
7745 		(void *)&cmd_set_xstats_hide_zero_on_off,
7746 		NULL,
7747 	},
7748 };
7749 
7750 /* *** CONFIGURE UNICAST HASH TABLE *** */
7751 struct cmd_set_uc_hash_table {
7752 	cmdline_fixed_string_t set;
7753 	cmdline_fixed_string_t port;
7754 	portid_t port_id;
7755 	cmdline_fixed_string_t what;
7756 	struct ether_addr address;
7757 	cmdline_fixed_string_t mode;
7758 };
7759 
7760 static void
7761 cmd_set_uc_hash_parsed(void *parsed_result,
7762 		       __attribute__((unused)) struct cmdline *cl,
7763 		       __attribute__((unused)) void *data)
7764 {
7765 	int ret=0;
7766 	struct cmd_set_uc_hash_table *res = parsed_result;
7767 
7768 	int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7769 
7770 	if (strcmp(res->what, "uta") == 0)
7771 		ret = rte_eth_dev_uc_hash_table_set(res->port_id,
7772 						&res->address,(uint8_t)is_on);
7773 	if (ret < 0)
7774 		printf("bad unicast hash table parameter, return code = %d \n", ret);
7775 
7776 }
7777 
7778 cmdline_parse_token_string_t cmd_set_uc_hash_set =
7779 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7780 				 set, "set");
7781 cmdline_parse_token_string_t cmd_set_uc_hash_port =
7782 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7783 				 port, "port");
7784 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
7785 	TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
7786 			      port_id, UINT16);
7787 cmdline_parse_token_string_t cmd_set_uc_hash_what =
7788 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7789 				 what, "uta");
7790 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
7791 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
7792 				address);
7793 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
7794 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7795 				 mode, "on#off");
7796 
7797 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
7798 	.f = cmd_set_uc_hash_parsed,
7799 	.data = NULL,
7800 	.help_str = "set port <port_id> uta <mac_addr> on|off)",
7801 	.tokens = {
7802 		(void *)&cmd_set_uc_hash_set,
7803 		(void *)&cmd_set_uc_hash_port,
7804 		(void *)&cmd_set_uc_hash_portid,
7805 		(void *)&cmd_set_uc_hash_what,
7806 		(void *)&cmd_set_uc_hash_mac,
7807 		(void *)&cmd_set_uc_hash_mode,
7808 		NULL,
7809 	},
7810 };
7811 
7812 struct cmd_set_uc_all_hash_table {
7813 	cmdline_fixed_string_t set;
7814 	cmdline_fixed_string_t port;
7815 	portid_t port_id;
7816 	cmdline_fixed_string_t what;
7817 	cmdline_fixed_string_t value;
7818 	cmdline_fixed_string_t mode;
7819 };
7820 
7821 static void
7822 cmd_set_uc_all_hash_parsed(void *parsed_result,
7823 		       __attribute__((unused)) struct cmdline *cl,
7824 		       __attribute__((unused)) void *data)
7825 {
7826 	int ret=0;
7827 	struct cmd_set_uc_all_hash_table *res = parsed_result;
7828 
7829 	int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7830 
7831 	if ((strcmp(res->what, "uta") == 0) &&
7832 		(strcmp(res->value, "all") == 0))
7833 		ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
7834 	if (ret < 0)
7835 		printf("bad unicast hash table parameter,"
7836 			"return code = %d \n", ret);
7837 }
7838 
7839 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
7840 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7841 				 set, "set");
7842 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
7843 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7844 				 port, "port");
7845 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
7846 	TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
7847 			      port_id, UINT16);
7848 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
7849 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7850 				 what, "uta");
7851 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
7852 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7853 				value,"all");
7854 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
7855 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7856 				 mode, "on#off");
7857 
7858 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
7859 	.f = cmd_set_uc_all_hash_parsed,
7860 	.data = NULL,
7861 	.help_str = "set port <port_id> uta all on|off",
7862 	.tokens = {
7863 		(void *)&cmd_set_uc_all_hash_set,
7864 		(void *)&cmd_set_uc_all_hash_port,
7865 		(void *)&cmd_set_uc_all_hash_portid,
7866 		(void *)&cmd_set_uc_all_hash_what,
7867 		(void *)&cmd_set_uc_all_hash_value,
7868 		(void *)&cmd_set_uc_all_hash_mode,
7869 		NULL,
7870 	},
7871 };
7872 
7873 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
7874 struct cmd_set_vf_macvlan_filter {
7875 	cmdline_fixed_string_t set;
7876 	cmdline_fixed_string_t port;
7877 	portid_t port_id;
7878 	cmdline_fixed_string_t vf;
7879 	uint8_t vf_id;
7880 	struct ether_addr address;
7881 	cmdline_fixed_string_t filter_type;
7882 	cmdline_fixed_string_t mode;
7883 };
7884 
7885 static void
7886 cmd_set_vf_macvlan_parsed(void *parsed_result,
7887 		       __attribute__((unused)) struct cmdline *cl,
7888 		       __attribute__((unused)) void *data)
7889 {
7890 	int is_on, ret = 0;
7891 	struct cmd_set_vf_macvlan_filter *res = parsed_result;
7892 	struct rte_eth_mac_filter filter;
7893 
7894 	memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
7895 
7896 	rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
7897 
7898 	/* set VF MAC filter */
7899 	filter.is_vf = 1;
7900 
7901 	/* set VF ID */
7902 	filter.dst_id = res->vf_id;
7903 
7904 	if (!strcmp(res->filter_type, "exact-mac"))
7905 		filter.filter_type = RTE_MAC_PERFECT_MATCH;
7906 	else if (!strcmp(res->filter_type, "exact-mac-vlan"))
7907 		filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
7908 	else if (!strcmp(res->filter_type, "hashmac"))
7909 		filter.filter_type = RTE_MAC_HASH_MATCH;
7910 	else if (!strcmp(res->filter_type, "hashmac-vlan"))
7911 		filter.filter_type = RTE_MACVLAN_HASH_MATCH;
7912 
7913 	is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7914 
7915 	if (is_on)
7916 		ret = rte_eth_dev_filter_ctrl(res->port_id,
7917 					RTE_ETH_FILTER_MACVLAN,
7918 					RTE_ETH_FILTER_ADD,
7919 					 &filter);
7920 	else
7921 		ret = rte_eth_dev_filter_ctrl(res->port_id,
7922 					RTE_ETH_FILTER_MACVLAN,
7923 					RTE_ETH_FILTER_DELETE,
7924 					&filter);
7925 
7926 	if (ret < 0)
7927 		printf("bad set MAC hash parameter, return code = %d\n", ret);
7928 
7929 }
7930 
7931 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
7932 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7933 				 set, "set");
7934 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
7935 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7936 				 port, "port");
7937 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
7938 	TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7939 			      port_id, UINT16);
7940 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
7941 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7942 				 vf, "vf");
7943 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
7944 	TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7945 				vf_id, UINT8);
7946 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
7947 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7948 				address);
7949 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
7950 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7951 				filter_type, "exact-mac#exact-mac-vlan"
7952 				"#hashmac#hashmac-vlan");
7953 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
7954 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7955 				 mode, "on#off");
7956 
7957 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
7958 	.f = cmd_set_vf_macvlan_parsed,
7959 	.data = NULL,
7960 	.help_str = "set port <port_id> vf <vf_id> <mac_addr> "
7961 		"exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
7962 		"Exact match rule: exact match of MAC or MAC and VLAN; "
7963 		"hash match rule: hash match of MAC and exact match of VLAN",
7964 	.tokens = {
7965 		(void *)&cmd_set_vf_macvlan_set,
7966 		(void *)&cmd_set_vf_macvlan_port,
7967 		(void *)&cmd_set_vf_macvlan_portid,
7968 		(void *)&cmd_set_vf_macvlan_vf,
7969 		(void *)&cmd_set_vf_macvlan_vf_id,
7970 		(void *)&cmd_set_vf_macvlan_mac,
7971 		(void *)&cmd_set_vf_macvlan_filter_type,
7972 		(void *)&cmd_set_vf_macvlan_mode,
7973 		NULL,
7974 	},
7975 };
7976 
7977 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
7978 struct cmd_set_vf_traffic {
7979 	cmdline_fixed_string_t set;
7980 	cmdline_fixed_string_t port;
7981 	portid_t port_id;
7982 	cmdline_fixed_string_t vf;
7983 	uint8_t vf_id;
7984 	cmdline_fixed_string_t what;
7985 	cmdline_fixed_string_t mode;
7986 };
7987 
7988 static void
7989 cmd_set_vf_traffic_parsed(void *parsed_result,
7990 		       __attribute__((unused)) struct cmdline *cl,
7991 		       __attribute__((unused)) void *data)
7992 {
7993 	struct cmd_set_vf_traffic *res = parsed_result;
7994 	int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
7995 	int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7996 
7997 	set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
7998 }
7999 
8000 cmdline_parse_token_string_t cmd_setvf_traffic_set =
8001 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8002 				 set, "set");
8003 cmdline_parse_token_string_t cmd_setvf_traffic_port =
8004 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8005 				 port, "port");
8006 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8007 	TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8008 			      port_id, UINT16);
8009 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8010 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8011 				 vf, "vf");
8012 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8013 	TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8014 			      vf_id, UINT8);
8015 cmdline_parse_token_string_t cmd_setvf_traffic_what =
8016 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8017 				 what, "tx#rx");
8018 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8019 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8020 				 mode, "on#off");
8021 
8022 cmdline_parse_inst_t cmd_set_vf_traffic = {
8023 	.f = cmd_set_vf_traffic_parsed,
8024 	.data = NULL,
8025 	.help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8026 	.tokens = {
8027 		(void *)&cmd_setvf_traffic_set,
8028 		(void *)&cmd_setvf_traffic_port,
8029 		(void *)&cmd_setvf_traffic_portid,
8030 		(void *)&cmd_setvf_traffic_vf,
8031 		(void *)&cmd_setvf_traffic_vfid,
8032 		(void *)&cmd_setvf_traffic_what,
8033 		(void *)&cmd_setvf_traffic_mode,
8034 		NULL,
8035 	},
8036 };
8037 
8038 /* *** CONFIGURE VF RECEIVE MODE *** */
8039 struct cmd_set_vf_rxmode {
8040 	cmdline_fixed_string_t set;
8041 	cmdline_fixed_string_t port;
8042 	portid_t port_id;
8043 	cmdline_fixed_string_t vf;
8044 	uint8_t vf_id;
8045 	cmdline_fixed_string_t what;
8046 	cmdline_fixed_string_t mode;
8047 	cmdline_fixed_string_t on;
8048 };
8049 
8050 static void
8051 cmd_set_vf_rxmode_parsed(void *parsed_result,
8052 		       __attribute__((unused)) struct cmdline *cl,
8053 		       __attribute__((unused)) void *data)
8054 {
8055 	int ret = -ENOTSUP;
8056 	uint16_t rx_mode = 0;
8057 	struct cmd_set_vf_rxmode *res = parsed_result;
8058 
8059 	int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8060 	if (!strcmp(res->what,"rxmode")) {
8061 		if (!strcmp(res->mode, "AUPE"))
8062 			rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
8063 		else if (!strcmp(res->mode, "ROPE"))
8064 			rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
8065 		else if (!strcmp(res->mode, "BAM"))
8066 			rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
8067 		else if (!strncmp(res->mode, "MPE",3))
8068 			rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
8069 	}
8070 
8071 	RTE_SET_USED(is_on);
8072 
8073 #ifdef RTE_LIBRTE_IXGBE_PMD
8074 	if (ret == -ENOTSUP)
8075 		ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8076 						  rx_mode, (uint8_t)is_on);
8077 #endif
8078 #ifdef RTE_LIBRTE_BNXT_PMD
8079 	if (ret == -ENOTSUP)
8080 		ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8081 						 rx_mode, (uint8_t)is_on);
8082 #endif
8083 	if (ret < 0)
8084 		printf("bad VF receive mode parameter, return code = %d \n",
8085 		ret);
8086 }
8087 
8088 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8089 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8090 				 set, "set");
8091 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8092 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8093 				 port, "port");
8094 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8095 	TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8096 			      port_id, UINT16);
8097 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8098 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8099 				 vf, "vf");
8100 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8101 	TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8102 			      vf_id, UINT8);
8103 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
8104 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8105 				 what, "rxmode");
8106 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
8107 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8108 				 mode, "AUPE#ROPE#BAM#MPE");
8109 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
8110 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8111 				 on, "on#off");
8112 
8113 cmdline_parse_inst_t cmd_set_vf_rxmode = {
8114 	.f = cmd_set_vf_rxmode_parsed,
8115 	.data = NULL,
8116 	.help_str = "set port <port_id> vf <vf_id> rxmode "
8117 		"AUPE|ROPE|BAM|MPE on|off",
8118 	.tokens = {
8119 		(void *)&cmd_set_vf_rxmode_set,
8120 		(void *)&cmd_set_vf_rxmode_port,
8121 		(void *)&cmd_set_vf_rxmode_portid,
8122 		(void *)&cmd_set_vf_rxmode_vf,
8123 		(void *)&cmd_set_vf_rxmode_vfid,
8124 		(void *)&cmd_set_vf_rxmode_what,
8125 		(void *)&cmd_set_vf_rxmode_mode,
8126 		(void *)&cmd_set_vf_rxmode_on,
8127 		NULL,
8128 	},
8129 };
8130 
8131 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
8132 struct cmd_vf_mac_addr_result {
8133 	cmdline_fixed_string_t mac_addr_cmd;
8134 	cmdline_fixed_string_t what;
8135 	cmdline_fixed_string_t port;
8136 	uint16_t port_num;
8137 	cmdline_fixed_string_t vf;
8138 	uint8_t vf_num;
8139 	struct ether_addr address;
8140 };
8141 
8142 static void cmd_vf_mac_addr_parsed(void *parsed_result,
8143 		__attribute__((unused)) struct cmdline *cl,
8144 		__attribute__((unused)) void *data)
8145 {
8146 	struct cmd_vf_mac_addr_result *res = parsed_result;
8147 	int ret = -ENOTSUP;
8148 
8149 	if (strcmp(res->what, "add") != 0)
8150 		return;
8151 
8152 #ifdef RTE_LIBRTE_I40E_PMD
8153 	if (ret == -ENOTSUP)
8154 		ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
8155 						   &res->address);
8156 #endif
8157 #ifdef RTE_LIBRTE_BNXT_PMD
8158 	if (ret == -ENOTSUP)
8159 		ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
8160 						res->vf_num);
8161 #endif
8162 
8163 	if(ret < 0)
8164 		printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
8165 
8166 }
8167 
8168 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
8169 	TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8170 				mac_addr_cmd,"mac_addr");
8171 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
8172 	TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8173 				what,"add");
8174 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
8175 	TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8176 				port,"port");
8177 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
8178 	TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8179 				port_num, UINT16);
8180 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
8181 	TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8182 				vf,"vf");
8183 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
8184 	TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8185 				vf_num, UINT8);
8186 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
8187 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
8188 				address);
8189 
8190 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
8191 	.f = cmd_vf_mac_addr_parsed,
8192 	.data = (void *)0,
8193 	.help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
8194 		"Add MAC address filtering for a VF on port_id",
8195 	.tokens = {
8196 		(void *)&cmd_vf_mac_addr_cmd,
8197 		(void *)&cmd_vf_mac_addr_what,
8198 		(void *)&cmd_vf_mac_addr_port,
8199 		(void *)&cmd_vf_mac_addr_portnum,
8200 		(void *)&cmd_vf_mac_addr_vf,
8201 		(void *)&cmd_vf_mac_addr_vfnum,
8202 		(void *)&cmd_vf_mac_addr_addr,
8203 		NULL,
8204 	},
8205 };
8206 
8207 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
8208 struct cmd_vf_rx_vlan_filter {
8209 	cmdline_fixed_string_t rx_vlan;
8210 	cmdline_fixed_string_t what;
8211 	uint16_t vlan_id;
8212 	cmdline_fixed_string_t port;
8213 	portid_t port_id;
8214 	cmdline_fixed_string_t vf;
8215 	uint64_t vf_mask;
8216 };
8217 
8218 static void
8219 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
8220 			  __attribute__((unused)) struct cmdline *cl,
8221 			  __attribute__((unused)) void *data)
8222 {
8223 	struct cmd_vf_rx_vlan_filter *res = parsed_result;
8224 	int ret = -ENOTSUP;
8225 
8226 	__rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
8227 
8228 #ifdef RTE_LIBRTE_IXGBE_PMD
8229 	if (ret == -ENOTSUP)
8230 		ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
8231 				res->vlan_id, res->vf_mask, is_add);
8232 #endif
8233 #ifdef RTE_LIBRTE_I40E_PMD
8234 	if (ret == -ENOTSUP)
8235 		ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
8236 				res->vlan_id, res->vf_mask, is_add);
8237 #endif
8238 #ifdef RTE_LIBRTE_BNXT_PMD
8239 	if (ret == -ENOTSUP)
8240 		ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
8241 				res->vlan_id, res->vf_mask, is_add);
8242 #endif
8243 
8244 	switch (ret) {
8245 	case 0:
8246 		break;
8247 	case -EINVAL:
8248 		printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
8249 				res->vlan_id, res->vf_mask);
8250 		break;
8251 	case -ENODEV:
8252 		printf("invalid port_id %d\n", res->port_id);
8253 		break;
8254 	case -ENOTSUP:
8255 		printf("function not implemented or supported\n");
8256 		break;
8257 	default:
8258 		printf("programming error: (%s)\n", strerror(-ret));
8259 	}
8260 }
8261 
8262 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
8263 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8264 				 rx_vlan, "rx_vlan");
8265 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
8266 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8267 				 what, "add#rm");
8268 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
8269 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8270 			      vlan_id, UINT16);
8271 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
8272 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8273 				 port, "port");
8274 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
8275 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8276 			      port_id, UINT16);
8277 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
8278 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8279 				 vf, "vf");
8280 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
8281 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8282 			      vf_mask, UINT64);
8283 
8284 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
8285 	.f = cmd_vf_rx_vlan_filter_parsed,
8286 	.data = NULL,
8287 	.help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
8288 		"(vf_mask = hexadecimal VF mask)",
8289 	.tokens = {
8290 		(void *)&cmd_vf_rx_vlan_filter_rx_vlan,
8291 		(void *)&cmd_vf_rx_vlan_filter_what,
8292 		(void *)&cmd_vf_rx_vlan_filter_vlanid,
8293 		(void *)&cmd_vf_rx_vlan_filter_port,
8294 		(void *)&cmd_vf_rx_vlan_filter_portid,
8295 		(void *)&cmd_vf_rx_vlan_filter_vf,
8296 		(void *)&cmd_vf_rx_vlan_filter_vf_mask,
8297 		NULL,
8298 	},
8299 };
8300 
8301 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
8302 struct cmd_queue_rate_limit_result {
8303 	cmdline_fixed_string_t set;
8304 	cmdline_fixed_string_t port;
8305 	uint16_t port_num;
8306 	cmdline_fixed_string_t queue;
8307 	uint8_t queue_num;
8308 	cmdline_fixed_string_t rate;
8309 	uint16_t rate_num;
8310 };
8311 
8312 static void cmd_queue_rate_limit_parsed(void *parsed_result,
8313 		__attribute__((unused)) struct cmdline *cl,
8314 		__attribute__((unused)) void *data)
8315 {
8316 	struct cmd_queue_rate_limit_result *res = parsed_result;
8317 	int ret = 0;
8318 
8319 	if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8320 		&& (strcmp(res->queue, "queue") == 0)
8321 		&& (strcmp(res->rate, "rate") == 0))
8322 		ret = set_queue_rate_limit(res->port_num, res->queue_num,
8323 					res->rate_num);
8324 	if (ret < 0)
8325 		printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
8326 
8327 }
8328 
8329 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
8330 	TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8331 				set, "set");
8332 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
8333 	TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8334 				port, "port");
8335 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
8336 	TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8337 				port_num, UINT16);
8338 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
8339 	TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8340 				queue, "queue");
8341 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
8342 	TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8343 				queue_num, UINT8);
8344 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
8345 	TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8346 				rate, "rate");
8347 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
8348 	TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8349 				rate_num, UINT16);
8350 
8351 cmdline_parse_inst_t cmd_queue_rate_limit = {
8352 	.f = cmd_queue_rate_limit_parsed,
8353 	.data = (void *)0,
8354 	.help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
8355 		"Set rate limit for a queue on port_id",
8356 	.tokens = {
8357 		(void *)&cmd_queue_rate_limit_set,
8358 		(void *)&cmd_queue_rate_limit_port,
8359 		(void *)&cmd_queue_rate_limit_portnum,
8360 		(void *)&cmd_queue_rate_limit_queue,
8361 		(void *)&cmd_queue_rate_limit_queuenum,
8362 		(void *)&cmd_queue_rate_limit_rate,
8363 		(void *)&cmd_queue_rate_limit_ratenum,
8364 		NULL,
8365 	},
8366 };
8367 
8368 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
8369 struct cmd_vf_rate_limit_result {
8370 	cmdline_fixed_string_t set;
8371 	cmdline_fixed_string_t port;
8372 	uint16_t port_num;
8373 	cmdline_fixed_string_t vf;
8374 	uint8_t vf_num;
8375 	cmdline_fixed_string_t rate;
8376 	uint16_t rate_num;
8377 	cmdline_fixed_string_t q_msk;
8378 	uint64_t q_msk_val;
8379 };
8380 
8381 static void cmd_vf_rate_limit_parsed(void *parsed_result,
8382 		__attribute__((unused)) struct cmdline *cl,
8383 		__attribute__((unused)) void *data)
8384 {
8385 	struct cmd_vf_rate_limit_result *res = parsed_result;
8386 	int ret = 0;
8387 
8388 	if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8389 		&& (strcmp(res->vf, "vf") == 0)
8390 		&& (strcmp(res->rate, "rate") == 0)
8391 		&& (strcmp(res->q_msk, "queue_mask") == 0))
8392 		ret = set_vf_rate_limit(res->port_num, res->vf_num,
8393 					res->rate_num, res->q_msk_val);
8394 	if (ret < 0)
8395 		printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
8396 
8397 }
8398 
8399 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
8400 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8401 				set, "set");
8402 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
8403 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8404 				port, "port");
8405 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
8406 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8407 				port_num, UINT16);
8408 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
8409 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8410 				vf, "vf");
8411 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
8412 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8413 				vf_num, UINT8);
8414 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
8415 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8416 				rate, "rate");
8417 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
8418 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8419 				rate_num, UINT16);
8420 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
8421 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8422 				q_msk, "queue_mask");
8423 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
8424 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8425 				q_msk_val, UINT64);
8426 
8427 cmdline_parse_inst_t cmd_vf_rate_limit = {
8428 	.f = cmd_vf_rate_limit_parsed,
8429 	.data = (void *)0,
8430 	.help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
8431 		"queue_mask <queue_mask_value>: "
8432 		"Set rate limit for queues of VF on port_id",
8433 	.tokens = {
8434 		(void *)&cmd_vf_rate_limit_set,
8435 		(void *)&cmd_vf_rate_limit_port,
8436 		(void *)&cmd_vf_rate_limit_portnum,
8437 		(void *)&cmd_vf_rate_limit_vf,
8438 		(void *)&cmd_vf_rate_limit_vfnum,
8439 		(void *)&cmd_vf_rate_limit_rate,
8440 		(void *)&cmd_vf_rate_limit_ratenum,
8441 		(void *)&cmd_vf_rate_limit_q_msk,
8442 		(void *)&cmd_vf_rate_limit_q_msk_val,
8443 		NULL,
8444 	},
8445 };
8446 
8447 /* *** ADD TUNNEL FILTER OF A PORT *** */
8448 struct cmd_tunnel_filter_result {
8449 	cmdline_fixed_string_t cmd;
8450 	cmdline_fixed_string_t what;
8451 	portid_t port_id;
8452 	struct ether_addr outer_mac;
8453 	struct ether_addr inner_mac;
8454 	cmdline_ipaddr_t ip_value;
8455 	uint16_t inner_vlan;
8456 	cmdline_fixed_string_t tunnel_type;
8457 	cmdline_fixed_string_t filter_type;
8458 	uint32_t tenant_id;
8459 	uint16_t queue_num;
8460 };
8461 
8462 static void
8463 cmd_tunnel_filter_parsed(void *parsed_result,
8464 			  __attribute__((unused)) struct cmdline *cl,
8465 			  __attribute__((unused)) void *data)
8466 {
8467 	struct cmd_tunnel_filter_result *res = parsed_result;
8468 	struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
8469 	int ret = 0;
8470 
8471 	memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
8472 
8473 	ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
8474 	ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
8475 	tunnel_filter_conf.inner_vlan = res->inner_vlan;
8476 
8477 	if (res->ip_value.family == AF_INET) {
8478 		tunnel_filter_conf.ip_addr.ipv4_addr =
8479 			res->ip_value.addr.ipv4.s_addr;
8480 		tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
8481 	} else {
8482 		memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
8483 			&(res->ip_value.addr.ipv6),
8484 			sizeof(struct in6_addr));
8485 		tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
8486 	}
8487 
8488 	if (!strcmp(res->filter_type, "imac-ivlan"))
8489 		tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
8490 	else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
8491 		tunnel_filter_conf.filter_type =
8492 			RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
8493 	else if (!strcmp(res->filter_type, "imac-tenid"))
8494 		tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
8495 	else if (!strcmp(res->filter_type, "imac"))
8496 		tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
8497 	else if (!strcmp(res->filter_type, "omac-imac-tenid"))
8498 		tunnel_filter_conf.filter_type =
8499 			RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
8500 	else if (!strcmp(res->filter_type, "oip"))
8501 		tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
8502 	else if (!strcmp(res->filter_type, "iip"))
8503 		tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
8504 	else {
8505 		printf("The filter type is not supported");
8506 		return;
8507 	}
8508 
8509 	if (!strcmp(res->tunnel_type, "vxlan"))
8510 		tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
8511 	else if (!strcmp(res->tunnel_type, "nvgre"))
8512 		tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
8513 	else if (!strcmp(res->tunnel_type, "ipingre"))
8514 		tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
8515 	else {
8516 		printf("The tunnel type %s not supported.\n", res->tunnel_type);
8517 		return;
8518 	}
8519 
8520 	tunnel_filter_conf.tenant_id = res->tenant_id;
8521 	tunnel_filter_conf.queue_id = res->queue_num;
8522 	if (!strcmp(res->what, "add"))
8523 		ret = rte_eth_dev_filter_ctrl(res->port_id,
8524 					RTE_ETH_FILTER_TUNNEL,
8525 					RTE_ETH_FILTER_ADD,
8526 					&tunnel_filter_conf);
8527 	else
8528 		ret = rte_eth_dev_filter_ctrl(res->port_id,
8529 					RTE_ETH_FILTER_TUNNEL,
8530 					RTE_ETH_FILTER_DELETE,
8531 					&tunnel_filter_conf);
8532 	if (ret < 0)
8533 		printf("cmd_tunnel_filter_parsed error: (%s)\n",
8534 				strerror(-ret));
8535 
8536 }
8537 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
8538 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8539 	cmd, "tunnel_filter");
8540 cmdline_parse_token_string_t cmd_tunnel_filter_what =
8541 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8542 	what, "add#rm");
8543 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
8544 	TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8545 	port_id, UINT16);
8546 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
8547 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8548 	outer_mac);
8549 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
8550 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8551 	inner_mac);
8552 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
8553 	TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8554 	inner_vlan, UINT16);
8555 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
8556 	TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8557 	ip_value);
8558 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
8559 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8560 	tunnel_type, "vxlan#nvgre#ipingre");
8561 
8562 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
8563 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8564 	filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
8565 		"imac#omac-imac-tenid");
8566 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
8567 	TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8568 	tenant_id, UINT32);
8569 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
8570 	TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8571 	queue_num, UINT16);
8572 
8573 cmdline_parse_inst_t cmd_tunnel_filter = {
8574 	.f = cmd_tunnel_filter_parsed,
8575 	.data = (void *)0,
8576 	.help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
8577 		"<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
8578 		"imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
8579 		"<queue_id>: Add/Rm tunnel filter of a port",
8580 	.tokens = {
8581 		(void *)&cmd_tunnel_filter_cmd,
8582 		(void *)&cmd_tunnel_filter_what,
8583 		(void *)&cmd_tunnel_filter_port_id,
8584 		(void *)&cmd_tunnel_filter_outer_mac,
8585 		(void *)&cmd_tunnel_filter_inner_mac,
8586 		(void *)&cmd_tunnel_filter_ip_value,
8587 		(void *)&cmd_tunnel_filter_innner_vlan,
8588 		(void *)&cmd_tunnel_filter_tunnel_type,
8589 		(void *)&cmd_tunnel_filter_filter_type,
8590 		(void *)&cmd_tunnel_filter_tenant_id,
8591 		(void *)&cmd_tunnel_filter_queue_num,
8592 		NULL,
8593 	},
8594 };
8595 
8596 /* *** CONFIGURE TUNNEL UDP PORT *** */
8597 struct cmd_tunnel_udp_config {
8598 	cmdline_fixed_string_t cmd;
8599 	cmdline_fixed_string_t what;
8600 	uint16_t udp_port;
8601 	portid_t port_id;
8602 };
8603 
8604 static void
8605 cmd_tunnel_udp_config_parsed(void *parsed_result,
8606 			  __attribute__((unused)) struct cmdline *cl,
8607 			  __attribute__((unused)) void *data)
8608 {
8609 	struct cmd_tunnel_udp_config *res = parsed_result;
8610 	struct rte_eth_udp_tunnel tunnel_udp;
8611 	int ret;
8612 
8613 	tunnel_udp.udp_port = res->udp_port;
8614 
8615 	if (!strcmp(res->cmd, "rx_vxlan_port"))
8616 		tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
8617 
8618 	if (!strcmp(res->what, "add"))
8619 		ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
8620 						      &tunnel_udp);
8621 	else
8622 		ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
8623 							 &tunnel_udp);
8624 
8625 	if (ret < 0)
8626 		printf("udp tunneling add error: (%s)\n", strerror(-ret));
8627 }
8628 
8629 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
8630 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8631 				cmd, "rx_vxlan_port");
8632 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
8633 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8634 				what, "add#rm");
8635 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
8636 	TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8637 				udp_port, UINT16);
8638 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
8639 	TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8640 				port_id, UINT16);
8641 
8642 cmdline_parse_inst_t cmd_tunnel_udp_config = {
8643 	.f = cmd_tunnel_udp_config_parsed,
8644 	.data = (void *)0,
8645 	.help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
8646 		"Add/Remove a tunneling UDP port filter",
8647 	.tokens = {
8648 		(void *)&cmd_tunnel_udp_config_cmd,
8649 		(void *)&cmd_tunnel_udp_config_what,
8650 		(void *)&cmd_tunnel_udp_config_udp_port,
8651 		(void *)&cmd_tunnel_udp_config_port_id,
8652 		NULL,
8653 	},
8654 };
8655 
8656 struct cmd_config_tunnel_udp_port {
8657 	cmdline_fixed_string_t port;
8658 	cmdline_fixed_string_t config;
8659 	portid_t port_id;
8660 	cmdline_fixed_string_t udp_tunnel_port;
8661 	cmdline_fixed_string_t action;
8662 	cmdline_fixed_string_t tunnel_type;
8663 	uint16_t udp_port;
8664 };
8665 
8666 static void
8667 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
8668 			       __attribute__((unused)) struct cmdline *cl,
8669 			       __attribute__((unused)) void *data)
8670 {
8671 	struct cmd_config_tunnel_udp_port *res = parsed_result;
8672 	struct rte_eth_udp_tunnel tunnel_udp;
8673 	int ret = 0;
8674 
8675 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8676 		return;
8677 
8678 	tunnel_udp.udp_port = res->udp_port;
8679 
8680 	if (!strcmp(res->tunnel_type, "vxlan")) {
8681 		tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
8682 	} else if (!strcmp(res->tunnel_type, "geneve")) {
8683 		tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE;
8684 	} else {
8685 		printf("Invalid tunnel type\n");
8686 		return;
8687 	}
8688 
8689 	if (!strcmp(res->action, "add"))
8690 		ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
8691 						      &tunnel_udp);
8692 	else
8693 		ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
8694 							 &tunnel_udp);
8695 
8696 	if (ret < 0)
8697 		printf("udp tunneling port add error: (%s)\n", strerror(-ret));
8698 }
8699 
8700 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
8701 	TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
8702 				 "port");
8703 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
8704 	TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
8705 				 "config");
8706 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
8707 	TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
8708 			      UINT16);
8709 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
8710 	TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
8711 				 udp_tunnel_port,
8712 				 "udp_tunnel_port");
8713 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
8714 	TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
8715 				 "add#rm");
8716 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
8717 	TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
8718 				 "vxlan#geneve");
8719 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
8720 	TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
8721 			      UINT16);
8722 
8723 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
8724 	.f = cmd_cfg_tunnel_udp_port_parsed,
8725 	.data = NULL,
8726 	.help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|geneve <udp_port>",
8727 	.tokens = {
8728 		(void *)&cmd_config_tunnel_udp_port_port,
8729 		(void *)&cmd_config_tunnel_udp_port_config,
8730 		(void *)&cmd_config_tunnel_udp_port_port_id,
8731 		(void *)&cmd_config_tunnel_udp_port_tunnel_port,
8732 		(void *)&cmd_config_tunnel_udp_port_action,
8733 		(void *)&cmd_config_tunnel_udp_port_tunnel_type,
8734 		(void *)&cmd_config_tunnel_udp_port_value,
8735 		NULL,
8736 	},
8737 };
8738 
8739 /* *** GLOBAL CONFIG *** */
8740 struct cmd_global_config_result {
8741 	cmdline_fixed_string_t cmd;
8742 	portid_t port_id;
8743 	cmdline_fixed_string_t cfg_type;
8744 	uint8_t len;
8745 };
8746 
8747 static void
8748 cmd_global_config_parsed(void *parsed_result,
8749 			 __attribute__((unused)) struct cmdline *cl,
8750 			 __attribute__((unused)) void *data)
8751 {
8752 	struct cmd_global_config_result *res = parsed_result;
8753 	struct rte_eth_global_cfg conf;
8754 	int ret;
8755 
8756 	memset(&conf, 0, sizeof(conf));
8757 	conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
8758 	conf.cfg.gre_key_len = res->len;
8759 	ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
8760 				      RTE_ETH_FILTER_SET, &conf);
8761 	if (ret != 0)
8762 		printf("Global config error\n");
8763 }
8764 
8765 cmdline_parse_token_string_t cmd_global_config_cmd =
8766 	TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
8767 		"global_config");
8768 cmdline_parse_token_num_t cmd_global_config_port_id =
8769 	TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id,
8770 			       UINT16);
8771 cmdline_parse_token_string_t cmd_global_config_type =
8772 	TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
8773 		cfg_type, "gre-key-len");
8774 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
8775 	TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
8776 		len, UINT8);
8777 
8778 cmdline_parse_inst_t cmd_global_config = {
8779 	.f = cmd_global_config_parsed,
8780 	.data = (void *)NULL,
8781 	.help_str = "global_config <port_id> gre-key-len <key_len>",
8782 	.tokens = {
8783 		(void *)&cmd_global_config_cmd,
8784 		(void *)&cmd_global_config_port_id,
8785 		(void *)&cmd_global_config_type,
8786 		(void *)&cmd_global_config_gre_key_len,
8787 		NULL,
8788 	},
8789 };
8790 
8791 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
8792 struct cmd_set_mirror_mask_result {
8793 	cmdline_fixed_string_t set;
8794 	cmdline_fixed_string_t port;
8795 	portid_t port_id;
8796 	cmdline_fixed_string_t mirror;
8797 	uint8_t rule_id;
8798 	cmdline_fixed_string_t what;
8799 	cmdline_fixed_string_t value;
8800 	cmdline_fixed_string_t dstpool;
8801 	uint8_t dstpool_id;
8802 	cmdline_fixed_string_t on;
8803 };
8804 
8805 cmdline_parse_token_string_t cmd_mirror_mask_set =
8806 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8807 				set, "set");
8808 cmdline_parse_token_string_t cmd_mirror_mask_port =
8809 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8810 				port, "port");
8811 cmdline_parse_token_num_t cmd_mirror_mask_portid =
8812 	TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8813 				port_id, UINT16);
8814 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
8815 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8816 				mirror, "mirror-rule");
8817 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
8818 	TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8819 				rule_id, UINT8);
8820 cmdline_parse_token_string_t cmd_mirror_mask_what =
8821 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8822 				what, "pool-mirror-up#pool-mirror-down"
8823 				      "#vlan-mirror");
8824 cmdline_parse_token_string_t cmd_mirror_mask_value =
8825 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8826 				value, NULL);
8827 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
8828 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8829 				dstpool, "dst-pool");
8830 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
8831 	TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8832 				dstpool_id, UINT8);
8833 cmdline_parse_token_string_t cmd_mirror_mask_on =
8834 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8835 				on, "on#off");
8836 
8837 static void
8838 cmd_set_mirror_mask_parsed(void *parsed_result,
8839 		       __attribute__((unused)) struct cmdline *cl,
8840 		       __attribute__((unused)) void *data)
8841 {
8842 	int ret,nb_item,i;
8843 	struct cmd_set_mirror_mask_result *res = parsed_result;
8844 	struct rte_eth_mirror_conf mr_conf;
8845 
8846 	memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
8847 
8848 	unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
8849 
8850 	mr_conf.dst_pool = res->dstpool_id;
8851 
8852 	if (!strcmp(res->what, "pool-mirror-up")) {
8853 		mr_conf.pool_mask = strtoull(res->value, NULL, 16);
8854 		mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
8855 	} else if (!strcmp(res->what, "pool-mirror-down")) {
8856 		mr_conf.pool_mask = strtoull(res->value, NULL, 16);
8857 		mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
8858 	} else if (!strcmp(res->what, "vlan-mirror")) {
8859 		mr_conf.rule_type = ETH_MIRROR_VLAN;
8860 		nb_item = parse_item_list(res->value, "vlan",
8861 				ETH_MIRROR_MAX_VLANS, vlan_list, 1);
8862 		if (nb_item <= 0)
8863 			return;
8864 
8865 		for (i = 0; i < nb_item; i++) {
8866 			if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
8867 				printf("Invalid vlan_id: must be < 4096\n");
8868 				return;
8869 			}
8870 
8871 			mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
8872 			mr_conf.vlan.vlan_mask |= 1ULL << i;
8873 		}
8874 	}
8875 
8876 	if (!strcmp(res->on, "on"))
8877 		ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8878 						res->rule_id, 1);
8879 	else
8880 		ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8881 						res->rule_id, 0);
8882 	if (ret < 0)
8883 		printf("mirror rule add error: (%s)\n", strerror(-ret));
8884 }
8885 
8886 cmdline_parse_inst_t cmd_set_mirror_mask = {
8887 		.f = cmd_set_mirror_mask_parsed,
8888 		.data = NULL,
8889 		.help_str = "set port <port_id> mirror-rule <rule_id> "
8890 			"pool-mirror-up|pool-mirror-down|vlan-mirror "
8891 			"<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
8892 		.tokens = {
8893 			(void *)&cmd_mirror_mask_set,
8894 			(void *)&cmd_mirror_mask_port,
8895 			(void *)&cmd_mirror_mask_portid,
8896 			(void *)&cmd_mirror_mask_mirror,
8897 			(void *)&cmd_mirror_mask_ruleid,
8898 			(void *)&cmd_mirror_mask_what,
8899 			(void *)&cmd_mirror_mask_value,
8900 			(void *)&cmd_mirror_mask_dstpool,
8901 			(void *)&cmd_mirror_mask_poolid,
8902 			(void *)&cmd_mirror_mask_on,
8903 			NULL,
8904 		},
8905 };
8906 
8907 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
8908 struct cmd_set_mirror_link_result {
8909 	cmdline_fixed_string_t set;
8910 	cmdline_fixed_string_t port;
8911 	portid_t port_id;
8912 	cmdline_fixed_string_t mirror;
8913 	uint8_t rule_id;
8914 	cmdline_fixed_string_t what;
8915 	cmdline_fixed_string_t dstpool;
8916 	uint8_t dstpool_id;
8917 	cmdline_fixed_string_t on;
8918 };
8919 
8920 cmdline_parse_token_string_t cmd_mirror_link_set =
8921 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8922 				 set, "set");
8923 cmdline_parse_token_string_t cmd_mirror_link_port =
8924 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8925 				port, "port");
8926 cmdline_parse_token_num_t cmd_mirror_link_portid =
8927 	TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8928 				port_id, UINT16);
8929 cmdline_parse_token_string_t cmd_mirror_link_mirror =
8930 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8931 				mirror, "mirror-rule");
8932 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
8933 	TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8934 			    rule_id, UINT8);
8935 cmdline_parse_token_string_t cmd_mirror_link_what =
8936 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8937 				what, "uplink-mirror#downlink-mirror");
8938 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
8939 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8940 				dstpool, "dst-pool");
8941 cmdline_parse_token_num_t cmd_mirror_link_poolid =
8942 	TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8943 				dstpool_id, UINT8);
8944 cmdline_parse_token_string_t cmd_mirror_link_on =
8945 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8946 				on, "on#off");
8947 
8948 static void
8949 cmd_set_mirror_link_parsed(void *parsed_result,
8950 		       __attribute__((unused)) struct cmdline *cl,
8951 		       __attribute__((unused)) void *data)
8952 {
8953 	int ret;
8954 	struct cmd_set_mirror_link_result *res = parsed_result;
8955 	struct rte_eth_mirror_conf mr_conf;
8956 
8957 	memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
8958 	if (!strcmp(res->what, "uplink-mirror"))
8959 		mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
8960 	else
8961 		mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
8962 
8963 	mr_conf.dst_pool = res->dstpool_id;
8964 
8965 	if (!strcmp(res->on, "on"))
8966 		ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8967 						res->rule_id, 1);
8968 	else
8969 		ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8970 						res->rule_id, 0);
8971 
8972 	/* check the return value and print it if is < 0 */
8973 	if (ret < 0)
8974 		printf("mirror rule add error: (%s)\n", strerror(-ret));
8975 
8976 }
8977 
8978 cmdline_parse_inst_t cmd_set_mirror_link = {
8979 		.f = cmd_set_mirror_link_parsed,
8980 		.data = NULL,
8981 		.help_str = "set port <port_id> mirror-rule <rule_id> "
8982 			"uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
8983 		.tokens = {
8984 			(void *)&cmd_mirror_link_set,
8985 			(void *)&cmd_mirror_link_port,
8986 			(void *)&cmd_mirror_link_portid,
8987 			(void *)&cmd_mirror_link_mirror,
8988 			(void *)&cmd_mirror_link_ruleid,
8989 			(void *)&cmd_mirror_link_what,
8990 			(void *)&cmd_mirror_link_dstpool,
8991 			(void *)&cmd_mirror_link_poolid,
8992 			(void *)&cmd_mirror_link_on,
8993 			NULL,
8994 		},
8995 };
8996 
8997 /* *** RESET VM MIRROR RULE *** */
8998 struct cmd_rm_mirror_rule_result {
8999 	cmdline_fixed_string_t reset;
9000 	cmdline_fixed_string_t port;
9001 	portid_t port_id;
9002 	cmdline_fixed_string_t mirror;
9003 	uint8_t rule_id;
9004 };
9005 
9006 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
9007 	TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9008 				 reset, "reset");
9009 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
9010 	TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9011 				port, "port");
9012 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
9013 	TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9014 				port_id, UINT16);
9015 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
9016 	TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9017 				mirror, "mirror-rule");
9018 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
9019 	TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9020 				rule_id, UINT8);
9021 
9022 static void
9023 cmd_reset_mirror_rule_parsed(void *parsed_result,
9024 		       __attribute__((unused)) struct cmdline *cl,
9025 		       __attribute__((unused)) void *data)
9026 {
9027 	int ret;
9028 	struct cmd_set_mirror_link_result *res = parsed_result;
9029         /* check rule_id */
9030 	ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
9031 	if(ret < 0)
9032 		printf("mirror rule remove error: (%s)\n", strerror(-ret));
9033 }
9034 
9035 cmdline_parse_inst_t cmd_reset_mirror_rule = {
9036 		.f = cmd_reset_mirror_rule_parsed,
9037 		.data = NULL,
9038 		.help_str = "reset port <port_id> mirror-rule <rule_id>",
9039 		.tokens = {
9040 			(void *)&cmd_rm_mirror_rule_reset,
9041 			(void *)&cmd_rm_mirror_rule_port,
9042 			(void *)&cmd_rm_mirror_rule_portid,
9043 			(void *)&cmd_rm_mirror_rule_mirror,
9044 			(void *)&cmd_rm_mirror_rule_ruleid,
9045 			NULL,
9046 		},
9047 };
9048 
9049 /* ******************************************************************************** */
9050 
9051 struct cmd_dump_result {
9052 	cmdline_fixed_string_t dump;
9053 };
9054 
9055 static void
9056 dump_struct_sizes(void)
9057 {
9058 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9059 	DUMP_SIZE(struct rte_mbuf);
9060 	DUMP_SIZE(struct rte_mempool);
9061 	DUMP_SIZE(struct rte_ring);
9062 #undef DUMP_SIZE
9063 }
9064 
9065 static void cmd_dump_parsed(void *parsed_result,
9066 			    __attribute__((unused)) struct cmdline *cl,
9067 			    __attribute__((unused)) void *data)
9068 {
9069 	struct cmd_dump_result *res = parsed_result;
9070 
9071 	if (!strcmp(res->dump, "dump_physmem"))
9072 		rte_dump_physmem_layout(stdout);
9073 	else if (!strcmp(res->dump, "dump_memzone"))
9074 		rte_memzone_dump(stdout);
9075 	else if (!strcmp(res->dump, "dump_struct_sizes"))
9076 		dump_struct_sizes();
9077 	else if (!strcmp(res->dump, "dump_ring"))
9078 		rte_ring_list_dump(stdout);
9079 	else if (!strcmp(res->dump, "dump_mempool"))
9080 		rte_mempool_list_dump(stdout);
9081 	else if (!strcmp(res->dump, "dump_devargs"))
9082 		rte_devargs_dump(stdout);
9083 	else if (!strcmp(res->dump, "dump_log_types"))
9084 		rte_log_dump(stdout);
9085 }
9086 
9087 cmdline_parse_token_string_t cmd_dump_dump =
9088 	TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9089 		"dump_physmem#"
9090 		"dump_memzone#"
9091 		"dump_struct_sizes#"
9092 		"dump_ring#"
9093 		"dump_mempool#"
9094 		"dump_devargs#"
9095 		"dump_log_types");
9096 
9097 cmdline_parse_inst_t cmd_dump = {
9098 	.f = cmd_dump_parsed,  /* function to call */
9099 	.data = NULL,      /* 2nd arg of func */
9100 	.help_str = "Dump status",
9101 	.tokens = {        /* token list, NULL terminated */
9102 		(void *)&cmd_dump_dump,
9103 		NULL,
9104 	},
9105 };
9106 
9107 /* ******************************************************************************** */
9108 
9109 struct cmd_dump_one_result {
9110 	cmdline_fixed_string_t dump;
9111 	cmdline_fixed_string_t name;
9112 };
9113 
9114 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9115 				__attribute__((unused)) void *data)
9116 {
9117 	struct cmd_dump_one_result *res = parsed_result;
9118 
9119 	if (!strcmp(res->dump, "dump_ring")) {
9120 		struct rte_ring *r;
9121 		r = rte_ring_lookup(res->name);
9122 		if (r == NULL) {
9123 			cmdline_printf(cl, "Cannot find ring\n");
9124 			return;
9125 		}
9126 		rte_ring_dump(stdout, r);
9127 	} else if (!strcmp(res->dump, "dump_mempool")) {
9128 		struct rte_mempool *mp;
9129 		mp = rte_mempool_lookup(res->name);
9130 		if (mp == NULL) {
9131 			cmdline_printf(cl, "Cannot find mempool\n");
9132 			return;
9133 		}
9134 		rte_mempool_dump(stdout, mp);
9135 	}
9136 }
9137 
9138 cmdline_parse_token_string_t cmd_dump_one_dump =
9139 	TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9140 				 "dump_ring#dump_mempool");
9141 
9142 cmdline_parse_token_string_t cmd_dump_one_name =
9143 	TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9144 
9145 cmdline_parse_inst_t cmd_dump_one = {
9146 	.f = cmd_dump_one_parsed,  /* function to call */
9147 	.data = NULL,      /* 2nd arg of func */
9148 	.help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9149 	.tokens = {        /* token list, NULL terminated */
9150 		(void *)&cmd_dump_one_dump,
9151 		(void *)&cmd_dump_one_name,
9152 		NULL,
9153 	},
9154 };
9155 
9156 /* *** Add/Del syn filter *** */
9157 struct cmd_syn_filter_result {
9158 	cmdline_fixed_string_t filter;
9159 	portid_t port_id;
9160 	cmdline_fixed_string_t ops;
9161 	cmdline_fixed_string_t priority;
9162 	cmdline_fixed_string_t high;
9163 	cmdline_fixed_string_t queue;
9164 	uint16_t queue_id;
9165 };
9166 
9167 static void
9168 cmd_syn_filter_parsed(void *parsed_result,
9169 			__attribute__((unused)) struct cmdline *cl,
9170 			__attribute__((unused)) void *data)
9171 {
9172 	struct cmd_syn_filter_result *res = parsed_result;
9173 	struct rte_eth_syn_filter syn_filter;
9174 	int ret = 0;
9175 
9176 	ret = rte_eth_dev_filter_supported(res->port_id,
9177 					RTE_ETH_FILTER_SYN);
9178 	if (ret < 0) {
9179 		printf("syn filter is not supported on port %u.\n",
9180 				res->port_id);
9181 		return;
9182 	}
9183 
9184 	memset(&syn_filter, 0, sizeof(syn_filter));
9185 
9186 	if (!strcmp(res->ops, "add")) {
9187 		if (!strcmp(res->high, "high"))
9188 			syn_filter.hig_pri = 1;
9189 		else
9190 			syn_filter.hig_pri = 0;
9191 
9192 		syn_filter.queue = res->queue_id;
9193 		ret = rte_eth_dev_filter_ctrl(res->port_id,
9194 						RTE_ETH_FILTER_SYN,
9195 						RTE_ETH_FILTER_ADD,
9196 						&syn_filter);
9197 	} else
9198 		ret = rte_eth_dev_filter_ctrl(res->port_id,
9199 						RTE_ETH_FILTER_SYN,
9200 						RTE_ETH_FILTER_DELETE,
9201 						&syn_filter);
9202 
9203 	if (ret < 0)
9204 		printf("syn filter programming error: (%s)\n",
9205 				strerror(-ret));
9206 }
9207 
9208 cmdline_parse_token_string_t cmd_syn_filter_filter =
9209 	TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9210 	filter, "syn_filter");
9211 cmdline_parse_token_num_t cmd_syn_filter_port_id =
9212 	TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9213 	port_id, UINT16);
9214 cmdline_parse_token_string_t cmd_syn_filter_ops =
9215 	TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9216 	ops, "add#del");
9217 cmdline_parse_token_string_t cmd_syn_filter_priority =
9218 	TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9219 				priority, "priority");
9220 cmdline_parse_token_string_t cmd_syn_filter_high =
9221 	TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9222 				high, "high#low");
9223 cmdline_parse_token_string_t cmd_syn_filter_queue =
9224 	TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9225 				queue, "queue");
9226 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
9227 	TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9228 				queue_id, UINT16);
9229 
9230 cmdline_parse_inst_t cmd_syn_filter = {
9231 	.f = cmd_syn_filter_parsed,
9232 	.data = NULL,
9233 	.help_str = "syn_filter <port_id> add|del priority high|low queue "
9234 		"<queue_id>: Add/Delete syn filter",
9235 	.tokens = {
9236 		(void *)&cmd_syn_filter_filter,
9237 		(void *)&cmd_syn_filter_port_id,
9238 		(void *)&cmd_syn_filter_ops,
9239 		(void *)&cmd_syn_filter_priority,
9240 		(void *)&cmd_syn_filter_high,
9241 		(void *)&cmd_syn_filter_queue,
9242 		(void *)&cmd_syn_filter_queue_id,
9243 		NULL,
9244 	},
9245 };
9246 
9247 /* *** queue region set *** */
9248 struct cmd_queue_region_result {
9249 	cmdline_fixed_string_t set;
9250 	cmdline_fixed_string_t port;
9251 	portid_t port_id;
9252 	cmdline_fixed_string_t cmd;
9253 	cmdline_fixed_string_t region;
9254 	uint8_t  region_id;
9255 	cmdline_fixed_string_t queue_start_index;
9256 	uint8_t  queue_id;
9257 	cmdline_fixed_string_t queue_num;
9258 	uint8_t  queue_num_value;
9259 };
9260 
9261 static void
9262 cmd_queue_region_parsed(void *parsed_result,
9263 			__attribute__((unused)) struct cmdline *cl,
9264 			__attribute__((unused)) void *data)
9265 {
9266 	struct cmd_queue_region_result *res = parsed_result;
9267 	int ret = -ENOTSUP;
9268 #ifdef RTE_LIBRTE_I40E_PMD
9269 	struct rte_pmd_i40e_queue_region_conf region_conf;
9270 	enum rte_pmd_i40e_queue_region_op op_type;
9271 #endif
9272 
9273 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9274 		return;
9275 
9276 #ifdef RTE_LIBRTE_I40E_PMD
9277 	memset(&region_conf, 0, sizeof(region_conf));
9278 	op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
9279 	region_conf.region_id = res->region_id;
9280 	region_conf.queue_num = res->queue_num_value;
9281 	region_conf.queue_start_index = res->queue_id;
9282 
9283 	ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9284 				op_type, &region_conf);
9285 #endif
9286 
9287 	switch (ret) {
9288 	case 0:
9289 		break;
9290 	case -ENOTSUP:
9291 		printf("function not implemented or supported\n");
9292 		break;
9293 	default:
9294 		printf("queue region config error: (%s)\n", strerror(-ret));
9295 	}
9296 }
9297 
9298 cmdline_parse_token_string_t cmd_queue_region_set =
9299 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9300 		set, "set");
9301 cmdline_parse_token_string_t cmd_queue_region_port =
9302 	TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
9303 cmdline_parse_token_num_t cmd_queue_region_port_id =
9304 	TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9305 				port_id, UINT16);
9306 cmdline_parse_token_string_t cmd_queue_region_cmd =
9307 	TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9308 				 cmd, "queue-region");
9309 cmdline_parse_token_string_t cmd_queue_region_id =
9310 	TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9311 				region, "region_id");
9312 cmdline_parse_token_num_t cmd_queue_region_index =
9313 	TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9314 				region_id, UINT8);
9315 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
9316 	TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9317 				queue_start_index, "queue_start_index");
9318 cmdline_parse_token_num_t cmd_queue_region_queue_id =
9319 	TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9320 				queue_id, UINT8);
9321 cmdline_parse_token_string_t cmd_queue_region_queue_num =
9322 	TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9323 				queue_num, "queue_num");
9324 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
9325 	TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9326 				queue_num_value, UINT8);
9327 
9328 cmdline_parse_inst_t cmd_queue_region = {
9329 	.f = cmd_queue_region_parsed,
9330 	.data = NULL,
9331 	.help_str = "set port <port_id> queue-region region_id <value> "
9332 		"queue_start_index <value> queue_num <value>: Set a queue region",
9333 	.tokens = {
9334 		(void *)&cmd_queue_region_set,
9335 		(void *)&cmd_queue_region_port,
9336 		(void *)&cmd_queue_region_port_id,
9337 		(void *)&cmd_queue_region_cmd,
9338 		(void *)&cmd_queue_region_id,
9339 		(void *)&cmd_queue_region_index,
9340 		(void *)&cmd_queue_region_queue_start_index,
9341 		(void *)&cmd_queue_region_queue_id,
9342 		(void *)&cmd_queue_region_queue_num,
9343 		(void *)&cmd_queue_region_queue_num_value,
9344 		NULL,
9345 	},
9346 };
9347 
9348 /* *** queue region and flowtype set *** */
9349 struct cmd_region_flowtype_result {
9350 	cmdline_fixed_string_t set;
9351 	cmdline_fixed_string_t port;
9352 	portid_t port_id;
9353 	cmdline_fixed_string_t cmd;
9354 	cmdline_fixed_string_t region;
9355 	uint8_t  region_id;
9356 	cmdline_fixed_string_t flowtype;
9357 	uint8_t  flowtype_id;
9358 };
9359 
9360 static void
9361 cmd_region_flowtype_parsed(void *parsed_result,
9362 			__attribute__((unused)) struct cmdline *cl,
9363 			__attribute__((unused)) void *data)
9364 {
9365 	struct cmd_region_flowtype_result *res = parsed_result;
9366 	int ret = -ENOTSUP;
9367 #ifdef RTE_LIBRTE_I40E_PMD
9368 	struct rte_pmd_i40e_queue_region_conf region_conf;
9369 	enum rte_pmd_i40e_queue_region_op op_type;
9370 #endif
9371 
9372 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9373 		return;
9374 
9375 #ifdef RTE_LIBRTE_I40E_PMD
9376 	memset(&region_conf, 0, sizeof(region_conf));
9377 
9378 	op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
9379 	region_conf.region_id = res->region_id;
9380 	region_conf.hw_flowtype = res->flowtype_id;
9381 
9382 	ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9383 			op_type, &region_conf);
9384 #endif
9385 
9386 	switch (ret) {
9387 	case 0:
9388 		break;
9389 	case -ENOTSUP:
9390 		printf("function not implemented or supported\n");
9391 		break;
9392 	default:
9393 		printf("region flowtype config error: (%s)\n", strerror(-ret));
9394 	}
9395 }
9396 
9397 cmdline_parse_token_string_t cmd_region_flowtype_set =
9398 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9399 				set, "set");
9400 cmdline_parse_token_string_t cmd_region_flowtype_port =
9401 	TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9402 				port, "port");
9403 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
9404 	TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9405 				port_id, UINT16);
9406 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
9407 	TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9408 				cmd, "queue-region");
9409 cmdline_parse_token_string_t cmd_region_flowtype_index =
9410 	TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9411 				region, "region_id");
9412 cmdline_parse_token_num_t cmd_region_flowtype_id =
9413 	TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9414 				region_id, UINT8);
9415 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
9416 	TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9417 				flowtype, "flowtype");
9418 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
9419 	TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9420 				flowtype_id, UINT8);
9421 cmdline_parse_inst_t cmd_region_flowtype = {
9422 	.f = cmd_region_flowtype_parsed,
9423 	.data = NULL,
9424 	.help_str = "set port <port_id> queue-region region_id <value> "
9425 		"flowtype <value>: Set a flowtype region index",
9426 	.tokens = {
9427 		(void *)&cmd_region_flowtype_set,
9428 		(void *)&cmd_region_flowtype_port,
9429 		(void *)&cmd_region_flowtype_port_index,
9430 		(void *)&cmd_region_flowtype_cmd,
9431 		(void *)&cmd_region_flowtype_index,
9432 		(void *)&cmd_region_flowtype_id,
9433 		(void *)&cmd_region_flowtype_flow_index,
9434 		(void *)&cmd_region_flowtype_flow_id,
9435 		NULL,
9436 	},
9437 };
9438 
9439 /* *** User Priority (UP) to queue region (region_id) set *** */
9440 struct cmd_user_priority_region_result {
9441 	cmdline_fixed_string_t set;
9442 	cmdline_fixed_string_t port;
9443 	portid_t port_id;
9444 	cmdline_fixed_string_t cmd;
9445 	cmdline_fixed_string_t user_priority;
9446 	uint8_t  user_priority_id;
9447 	cmdline_fixed_string_t region;
9448 	uint8_t  region_id;
9449 };
9450 
9451 static void
9452 cmd_user_priority_region_parsed(void *parsed_result,
9453 			__attribute__((unused)) struct cmdline *cl,
9454 			__attribute__((unused)) void *data)
9455 {
9456 	struct cmd_user_priority_region_result *res = parsed_result;
9457 	int ret = -ENOTSUP;
9458 #ifdef RTE_LIBRTE_I40E_PMD
9459 	struct rte_pmd_i40e_queue_region_conf region_conf;
9460 	enum rte_pmd_i40e_queue_region_op op_type;
9461 #endif
9462 
9463 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9464 		return;
9465 
9466 #ifdef RTE_LIBRTE_I40E_PMD
9467 	memset(&region_conf, 0, sizeof(region_conf));
9468 	op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
9469 	region_conf.user_priority = res->user_priority_id;
9470 	region_conf.region_id = res->region_id;
9471 
9472 	ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9473 				op_type, &region_conf);
9474 #endif
9475 
9476 	switch (ret) {
9477 	case 0:
9478 		break;
9479 	case -ENOTSUP:
9480 		printf("function not implemented or supported\n");
9481 		break;
9482 	default:
9483 		printf("user_priority region config error: (%s)\n",
9484 				strerror(-ret));
9485 	}
9486 }
9487 
9488 cmdline_parse_token_string_t cmd_user_priority_region_set =
9489 	TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9490 				set, "set");
9491 cmdline_parse_token_string_t cmd_user_priority_region_port =
9492 	TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9493 				port, "port");
9494 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
9495 	TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9496 				port_id, UINT16);
9497 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
9498 	TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9499 				cmd, "queue-region");
9500 cmdline_parse_token_string_t cmd_user_priority_region_UP =
9501 	TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9502 				user_priority, "UP");
9503 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
9504 	TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9505 				user_priority_id, UINT8);
9506 cmdline_parse_token_string_t cmd_user_priority_region_region =
9507 	TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9508 				region, "region_id");
9509 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
9510 	TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9511 				region_id, UINT8);
9512 
9513 cmdline_parse_inst_t cmd_user_priority_region = {
9514 	.f = cmd_user_priority_region_parsed,
9515 	.data = NULL,
9516 	.help_str = "set port <port_id> queue-region UP <value> "
9517 		"region_id <value>: Set the mapping of User Priority (UP) "
9518 		"to queue region (region_id) ",
9519 	.tokens = {
9520 		(void *)&cmd_user_priority_region_set,
9521 		(void *)&cmd_user_priority_region_port,
9522 		(void *)&cmd_user_priority_region_port_index,
9523 		(void *)&cmd_user_priority_region_cmd,
9524 		(void *)&cmd_user_priority_region_UP,
9525 		(void *)&cmd_user_priority_region_UP_id,
9526 		(void *)&cmd_user_priority_region_region,
9527 		(void *)&cmd_user_priority_region_region_id,
9528 		NULL,
9529 	},
9530 };
9531 
9532 /* *** flush all queue region related configuration *** */
9533 struct cmd_flush_queue_region_result {
9534 	cmdline_fixed_string_t set;
9535 	cmdline_fixed_string_t port;
9536 	portid_t port_id;
9537 	cmdline_fixed_string_t cmd;
9538 	cmdline_fixed_string_t flush;
9539 	cmdline_fixed_string_t what;
9540 };
9541 
9542 static void
9543 cmd_flush_queue_region_parsed(void *parsed_result,
9544 			__attribute__((unused)) struct cmdline *cl,
9545 			__attribute__((unused)) void *data)
9546 {
9547 	struct cmd_flush_queue_region_result *res = parsed_result;
9548 	int ret = -ENOTSUP;
9549 #ifdef RTE_LIBRTE_I40E_PMD
9550 	struct rte_pmd_i40e_queue_region_conf region_conf;
9551 	enum rte_pmd_i40e_queue_region_op op_type;
9552 #endif
9553 
9554 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9555 		return;
9556 
9557 #ifdef RTE_LIBRTE_I40E_PMD
9558 	memset(&region_conf, 0, sizeof(region_conf));
9559 
9560 	if (strcmp(res->what, "on") == 0)
9561 		op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
9562 	else
9563 		op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
9564 
9565 	ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9566 				op_type, &region_conf);
9567 #endif
9568 
9569 	switch (ret) {
9570 	case 0:
9571 		break;
9572 	case -ENOTSUP:
9573 		printf("function not implemented or supported\n");
9574 		break;
9575 	default:
9576 		printf("queue region config flush error: (%s)\n",
9577 				strerror(-ret));
9578 	}
9579 }
9580 
9581 cmdline_parse_token_string_t cmd_flush_queue_region_set =
9582 	TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9583 				set, "set");
9584 cmdline_parse_token_string_t cmd_flush_queue_region_port =
9585 	TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9586 				port, "port");
9587 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
9588 	TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
9589 				port_id, UINT16);
9590 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
9591 	TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9592 				cmd, "queue-region");
9593 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
9594 	TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9595 				flush, "flush");
9596 cmdline_parse_token_string_t cmd_flush_queue_region_what =
9597 	TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9598 				what, "on#off");
9599 
9600 cmdline_parse_inst_t cmd_flush_queue_region = {
9601 	.f = cmd_flush_queue_region_parsed,
9602 	.data = NULL,
9603 	.help_str = "set port <port_id> queue-region flush on|off"
9604 		": flush all queue region related configuration",
9605 	.tokens = {
9606 		(void *)&cmd_flush_queue_region_set,
9607 		(void *)&cmd_flush_queue_region_port,
9608 		(void *)&cmd_flush_queue_region_port_index,
9609 		(void *)&cmd_flush_queue_region_cmd,
9610 		(void *)&cmd_flush_queue_region_flush,
9611 		(void *)&cmd_flush_queue_region_what,
9612 		NULL,
9613 	},
9614 };
9615 
9616 /* *** get all queue region related configuration info *** */
9617 struct cmd_show_queue_region_info {
9618 	cmdline_fixed_string_t show;
9619 	cmdline_fixed_string_t port;
9620 	portid_t port_id;
9621 	cmdline_fixed_string_t cmd;
9622 };
9623 
9624 static void
9625 cmd_show_queue_region_info_parsed(void *parsed_result,
9626 			__attribute__((unused)) struct cmdline *cl,
9627 			__attribute__((unused)) void *data)
9628 {
9629 	struct cmd_show_queue_region_info *res = parsed_result;
9630 	int ret = -ENOTSUP;
9631 #ifdef RTE_LIBRTE_I40E_PMD
9632 	struct rte_pmd_i40e_queue_regions rte_pmd_regions;
9633 	enum rte_pmd_i40e_queue_region_op op_type;
9634 #endif
9635 
9636 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9637 		return;
9638 
9639 #ifdef RTE_LIBRTE_I40E_PMD
9640 	memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
9641 
9642 	op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
9643 
9644 	ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9645 					op_type, &rte_pmd_regions);
9646 
9647 	port_queue_region_info_display(res->port_id, &rte_pmd_regions);
9648 #endif
9649 
9650 	switch (ret) {
9651 	case 0:
9652 		break;
9653 	case -ENOTSUP:
9654 		printf("function not implemented or supported\n");
9655 		break;
9656 	default:
9657 		printf("queue region config info show error: (%s)\n",
9658 				strerror(-ret));
9659 	}
9660 }
9661 
9662 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
9663 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9664 				show, "show");
9665 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
9666 	TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9667 				port, "port");
9668 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
9669 	TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
9670 				port_id, UINT16);
9671 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
9672 	TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9673 				cmd, "queue-region");
9674 
9675 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
9676 	.f = cmd_show_queue_region_info_parsed,
9677 	.data = NULL,
9678 	.help_str = "show port <port_id> queue-region"
9679 		": show all queue region related configuration info",
9680 	.tokens = {
9681 		(void *)&cmd_show_queue_region_info_get,
9682 		(void *)&cmd_show_queue_region_info_port,
9683 		(void *)&cmd_show_queue_region_info_port_index,
9684 		(void *)&cmd_show_queue_region_info_cmd,
9685 		NULL,
9686 	},
9687 };
9688 
9689 /* *** ADD/REMOVE A 2tuple FILTER *** */
9690 struct cmd_2tuple_filter_result {
9691 	cmdline_fixed_string_t filter;
9692 	portid_t port_id;
9693 	cmdline_fixed_string_t ops;
9694 	cmdline_fixed_string_t dst_port;
9695 	uint16_t dst_port_value;
9696 	cmdline_fixed_string_t protocol;
9697 	uint8_t protocol_value;
9698 	cmdline_fixed_string_t mask;
9699 	uint8_t  mask_value;
9700 	cmdline_fixed_string_t tcp_flags;
9701 	uint8_t tcp_flags_value;
9702 	cmdline_fixed_string_t priority;
9703 	uint8_t  priority_value;
9704 	cmdline_fixed_string_t queue;
9705 	uint16_t  queue_id;
9706 };
9707 
9708 static void
9709 cmd_2tuple_filter_parsed(void *parsed_result,
9710 			__attribute__((unused)) struct cmdline *cl,
9711 			__attribute__((unused)) void *data)
9712 {
9713 	struct rte_eth_ntuple_filter filter;
9714 	struct cmd_2tuple_filter_result *res = parsed_result;
9715 	int ret = 0;
9716 
9717 	ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
9718 	if (ret < 0) {
9719 		printf("ntuple filter is not supported on port %u.\n",
9720 			res->port_id);
9721 		return;
9722 	}
9723 
9724 	memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
9725 
9726 	filter.flags = RTE_2TUPLE_FLAGS;
9727 	filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
9728 	filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
9729 	filter.proto = res->protocol_value;
9730 	filter.priority = res->priority_value;
9731 	if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
9732 		printf("nonzero tcp_flags is only meaningful"
9733 			" when protocol is TCP.\n");
9734 		return;
9735 	}
9736 	if (res->tcp_flags_value > TCP_FLAG_ALL) {
9737 		printf("invalid TCP flags.\n");
9738 		return;
9739 	}
9740 
9741 	if (res->tcp_flags_value != 0) {
9742 		filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
9743 		filter.tcp_flags = res->tcp_flags_value;
9744 	}
9745 
9746 	/* need convert to big endian. */
9747 	filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
9748 	filter.queue = res->queue_id;
9749 
9750 	if (!strcmp(res->ops, "add"))
9751 		ret = rte_eth_dev_filter_ctrl(res->port_id,
9752 				RTE_ETH_FILTER_NTUPLE,
9753 				RTE_ETH_FILTER_ADD,
9754 				&filter);
9755 	else
9756 		ret = rte_eth_dev_filter_ctrl(res->port_id,
9757 				RTE_ETH_FILTER_NTUPLE,
9758 				RTE_ETH_FILTER_DELETE,
9759 				&filter);
9760 	if (ret < 0)
9761 		printf("2tuple filter programming error: (%s)\n",
9762 			strerror(-ret));
9763 
9764 }
9765 
9766 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
9767 	TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9768 				 filter, "2tuple_filter");
9769 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
9770 	TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9771 				port_id, UINT16);
9772 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
9773 	TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9774 				 ops, "add#del");
9775 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
9776 	TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9777 				dst_port, "dst_port");
9778 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
9779 	TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9780 				dst_port_value, UINT16);
9781 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
9782 	TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9783 				protocol, "protocol");
9784 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
9785 	TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9786 				protocol_value, UINT8);
9787 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
9788 	TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9789 				mask, "mask");
9790 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
9791 	TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9792 				mask_value, INT8);
9793 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
9794 	TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9795 				tcp_flags, "tcp_flags");
9796 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
9797 	TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9798 				tcp_flags_value, UINT8);
9799 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
9800 	TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9801 				priority, "priority");
9802 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
9803 	TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9804 				priority_value, UINT8);
9805 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
9806 	TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9807 				queue, "queue");
9808 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
9809 	TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9810 				queue_id, UINT16);
9811 
9812 cmdline_parse_inst_t cmd_2tuple_filter = {
9813 	.f = cmd_2tuple_filter_parsed,
9814 	.data = NULL,
9815 	.help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
9816 		"<value> mask <value> tcp_flags <value> priority <value> queue "
9817 		"<queue_id>: Add a 2tuple filter",
9818 	.tokens = {
9819 		(void *)&cmd_2tuple_filter_filter,
9820 		(void *)&cmd_2tuple_filter_port_id,
9821 		(void *)&cmd_2tuple_filter_ops,
9822 		(void *)&cmd_2tuple_filter_dst_port,
9823 		(void *)&cmd_2tuple_filter_dst_port_value,
9824 		(void *)&cmd_2tuple_filter_protocol,
9825 		(void *)&cmd_2tuple_filter_protocol_value,
9826 		(void *)&cmd_2tuple_filter_mask,
9827 		(void *)&cmd_2tuple_filter_mask_value,
9828 		(void *)&cmd_2tuple_filter_tcp_flags,
9829 		(void *)&cmd_2tuple_filter_tcp_flags_value,
9830 		(void *)&cmd_2tuple_filter_priority,
9831 		(void *)&cmd_2tuple_filter_priority_value,
9832 		(void *)&cmd_2tuple_filter_queue,
9833 		(void *)&cmd_2tuple_filter_queue_id,
9834 		NULL,
9835 	},
9836 };
9837 
9838 /* *** ADD/REMOVE A 5tuple FILTER *** */
9839 struct cmd_5tuple_filter_result {
9840 	cmdline_fixed_string_t filter;
9841 	portid_t port_id;
9842 	cmdline_fixed_string_t ops;
9843 	cmdline_fixed_string_t dst_ip;
9844 	cmdline_ipaddr_t dst_ip_value;
9845 	cmdline_fixed_string_t src_ip;
9846 	cmdline_ipaddr_t src_ip_value;
9847 	cmdline_fixed_string_t dst_port;
9848 	uint16_t dst_port_value;
9849 	cmdline_fixed_string_t src_port;
9850 	uint16_t src_port_value;
9851 	cmdline_fixed_string_t protocol;
9852 	uint8_t protocol_value;
9853 	cmdline_fixed_string_t mask;
9854 	uint8_t  mask_value;
9855 	cmdline_fixed_string_t tcp_flags;
9856 	uint8_t tcp_flags_value;
9857 	cmdline_fixed_string_t priority;
9858 	uint8_t  priority_value;
9859 	cmdline_fixed_string_t queue;
9860 	uint16_t  queue_id;
9861 };
9862 
9863 static void
9864 cmd_5tuple_filter_parsed(void *parsed_result,
9865 			__attribute__((unused)) struct cmdline *cl,
9866 			__attribute__((unused)) void *data)
9867 {
9868 	struct rte_eth_ntuple_filter filter;
9869 	struct cmd_5tuple_filter_result *res = parsed_result;
9870 	int ret = 0;
9871 
9872 	ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
9873 	if (ret < 0) {
9874 		printf("ntuple filter is not supported on port %u.\n",
9875 			res->port_id);
9876 		return;
9877 	}
9878 
9879 	memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
9880 
9881 	filter.flags = RTE_5TUPLE_FLAGS;
9882 	filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
9883 	filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
9884 	filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
9885 	filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
9886 	filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
9887 	filter.proto = res->protocol_value;
9888 	filter.priority = res->priority_value;
9889 	if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
9890 		printf("nonzero tcp_flags is only meaningful"
9891 			" when protocol is TCP.\n");
9892 		return;
9893 	}
9894 	if (res->tcp_flags_value > TCP_FLAG_ALL) {
9895 		printf("invalid TCP flags.\n");
9896 		return;
9897 	}
9898 
9899 	if (res->tcp_flags_value != 0) {
9900 		filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
9901 		filter.tcp_flags = res->tcp_flags_value;
9902 	}
9903 
9904 	if (res->dst_ip_value.family == AF_INET)
9905 		/* no need to convert, already big endian. */
9906 		filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
9907 	else {
9908 		if (filter.dst_ip_mask == 0) {
9909 			printf("can not support ipv6 involved compare.\n");
9910 			return;
9911 		}
9912 		filter.dst_ip = 0;
9913 	}
9914 
9915 	if (res->src_ip_value.family == AF_INET)
9916 		/* no need to convert, already big endian. */
9917 		filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
9918 	else {
9919 		if (filter.src_ip_mask == 0) {
9920 			printf("can not support ipv6 involved compare.\n");
9921 			return;
9922 		}
9923 		filter.src_ip = 0;
9924 	}
9925 	/* need convert to big endian. */
9926 	filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
9927 	filter.src_port = rte_cpu_to_be_16(res->src_port_value);
9928 	filter.queue = res->queue_id;
9929 
9930 	if (!strcmp(res->ops, "add"))
9931 		ret = rte_eth_dev_filter_ctrl(res->port_id,
9932 				RTE_ETH_FILTER_NTUPLE,
9933 				RTE_ETH_FILTER_ADD,
9934 				&filter);
9935 	else
9936 		ret = rte_eth_dev_filter_ctrl(res->port_id,
9937 				RTE_ETH_FILTER_NTUPLE,
9938 				RTE_ETH_FILTER_DELETE,
9939 				&filter);
9940 	if (ret < 0)
9941 		printf("5tuple filter programming error: (%s)\n",
9942 			strerror(-ret));
9943 }
9944 
9945 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
9946 	TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9947 				 filter, "5tuple_filter");
9948 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
9949 	TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9950 				port_id, UINT16);
9951 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
9952 	TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9953 				 ops, "add#del");
9954 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
9955 	TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9956 				dst_ip, "dst_ip");
9957 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
9958 	TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
9959 				dst_ip_value);
9960 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
9961 	TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9962 				src_ip, "src_ip");
9963 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
9964 	TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
9965 				src_ip_value);
9966 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
9967 	TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9968 				dst_port, "dst_port");
9969 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
9970 	TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9971 				dst_port_value, UINT16);
9972 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
9973 	TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9974 				src_port, "src_port");
9975 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
9976 	TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9977 				src_port_value, UINT16);
9978 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
9979 	TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9980 				protocol, "protocol");
9981 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
9982 	TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9983 				protocol_value, UINT8);
9984 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
9985 	TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9986 				mask, "mask");
9987 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
9988 	TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9989 				mask_value, INT8);
9990 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
9991 	TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9992 				tcp_flags, "tcp_flags");
9993 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
9994 	TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9995 				tcp_flags_value, UINT8);
9996 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
9997 	TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9998 				priority, "priority");
9999 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
10000 	TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10001 				priority_value, UINT8);
10002 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
10003 	TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10004 				queue, "queue");
10005 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
10006 	TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10007 				queue_id, UINT16);
10008 
10009 cmdline_parse_inst_t cmd_5tuple_filter = {
10010 	.f = cmd_5tuple_filter_parsed,
10011 	.data = NULL,
10012 	.help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
10013 		"src_ip <value> dst_port <value> src_port <value> "
10014 		"protocol <value>  mask <value> tcp_flags <value> "
10015 		"priority <value> queue <queue_id>: Add/Del a 5tuple filter",
10016 	.tokens = {
10017 		(void *)&cmd_5tuple_filter_filter,
10018 		(void *)&cmd_5tuple_filter_port_id,
10019 		(void *)&cmd_5tuple_filter_ops,
10020 		(void *)&cmd_5tuple_filter_dst_ip,
10021 		(void *)&cmd_5tuple_filter_dst_ip_value,
10022 		(void *)&cmd_5tuple_filter_src_ip,
10023 		(void *)&cmd_5tuple_filter_src_ip_value,
10024 		(void *)&cmd_5tuple_filter_dst_port,
10025 		(void *)&cmd_5tuple_filter_dst_port_value,
10026 		(void *)&cmd_5tuple_filter_src_port,
10027 		(void *)&cmd_5tuple_filter_src_port_value,
10028 		(void *)&cmd_5tuple_filter_protocol,
10029 		(void *)&cmd_5tuple_filter_protocol_value,
10030 		(void *)&cmd_5tuple_filter_mask,
10031 		(void *)&cmd_5tuple_filter_mask_value,
10032 		(void *)&cmd_5tuple_filter_tcp_flags,
10033 		(void *)&cmd_5tuple_filter_tcp_flags_value,
10034 		(void *)&cmd_5tuple_filter_priority,
10035 		(void *)&cmd_5tuple_filter_priority_value,
10036 		(void *)&cmd_5tuple_filter_queue,
10037 		(void *)&cmd_5tuple_filter_queue_id,
10038 		NULL,
10039 	},
10040 };
10041 
10042 /* *** ADD/REMOVE A flex FILTER *** */
10043 struct cmd_flex_filter_result {
10044 	cmdline_fixed_string_t filter;
10045 	cmdline_fixed_string_t ops;
10046 	portid_t port_id;
10047 	cmdline_fixed_string_t len;
10048 	uint8_t len_value;
10049 	cmdline_fixed_string_t bytes;
10050 	cmdline_fixed_string_t bytes_value;
10051 	cmdline_fixed_string_t mask;
10052 	cmdline_fixed_string_t mask_value;
10053 	cmdline_fixed_string_t priority;
10054 	uint8_t priority_value;
10055 	cmdline_fixed_string_t queue;
10056 	uint16_t queue_id;
10057 };
10058 
10059 static int xdigit2val(unsigned char c)
10060 {
10061 	int val;
10062 	if (isdigit(c))
10063 		val = c - '0';
10064 	else if (isupper(c))
10065 		val = c - 'A' + 10;
10066 	else
10067 		val = c - 'a' + 10;
10068 	return val;
10069 }
10070 
10071 static void
10072 cmd_flex_filter_parsed(void *parsed_result,
10073 			  __attribute__((unused)) struct cmdline *cl,
10074 			  __attribute__((unused)) void *data)
10075 {
10076 	int ret = 0;
10077 	struct rte_eth_flex_filter filter;
10078 	struct cmd_flex_filter_result *res = parsed_result;
10079 	char *bytes_ptr, *mask_ptr;
10080 	uint16_t len, i, j = 0;
10081 	char c;
10082 	int val;
10083 	uint8_t byte = 0;
10084 
10085 	if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
10086 		printf("the len exceed the max length 128\n");
10087 		return;
10088 	}
10089 	memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
10090 	filter.len = res->len_value;
10091 	filter.priority = res->priority_value;
10092 	filter.queue = res->queue_id;
10093 	bytes_ptr = res->bytes_value;
10094 	mask_ptr = res->mask_value;
10095 
10096 	 /* translate bytes string to array. */
10097 	if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
10098 		(bytes_ptr[1] == 'X')))
10099 		bytes_ptr += 2;
10100 	len = strnlen(bytes_ptr, res->len_value * 2);
10101 	if (len == 0 || (len % 8 != 0)) {
10102 		printf("please check len and bytes input\n");
10103 		return;
10104 	}
10105 	for (i = 0; i < len; i++) {
10106 		c = bytes_ptr[i];
10107 		if (isxdigit(c) == 0) {
10108 			/* invalid characters. */
10109 			printf("invalid input\n");
10110 			return;
10111 		}
10112 		val = xdigit2val(c);
10113 		if (i % 2) {
10114 			byte |= val;
10115 			filter.bytes[j] = byte;
10116 			printf("bytes[%d]:%02x ", j, filter.bytes[j]);
10117 			j++;
10118 			byte = 0;
10119 		} else
10120 			byte |= val << 4;
10121 	}
10122 	printf("\n");
10123 	 /* translate mask string to uint8_t array. */
10124 	if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
10125 		(mask_ptr[1] == 'X')))
10126 		mask_ptr += 2;
10127 	len = strnlen(mask_ptr, (res->len_value + 3) / 4);
10128 	if (len == 0) {
10129 		printf("invalid input\n");
10130 		return;
10131 	}
10132 	j = 0;
10133 	byte = 0;
10134 	for (i = 0; i < len; i++) {
10135 		c = mask_ptr[i];
10136 		if (isxdigit(c) == 0) {
10137 			/* invalid characters. */
10138 			printf("invalid input\n");
10139 			return;
10140 		}
10141 		val = xdigit2val(c);
10142 		if (i % 2) {
10143 			byte |= val;
10144 			filter.mask[j] = byte;
10145 			printf("mask[%d]:%02x ", j, filter.mask[j]);
10146 			j++;
10147 			byte = 0;
10148 		} else
10149 			byte |= val << 4;
10150 	}
10151 	printf("\n");
10152 
10153 	if (!strcmp(res->ops, "add"))
10154 		ret = rte_eth_dev_filter_ctrl(res->port_id,
10155 				RTE_ETH_FILTER_FLEXIBLE,
10156 				RTE_ETH_FILTER_ADD,
10157 				&filter);
10158 	else
10159 		ret = rte_eth_dev_filter_ctrl(res->port_id,
10160 				RTE_ETH_FILTER_FLEXIBLE,
10161 				RTE_ETH_FILTER_DELETE,
10162 				&filter);
10163 
10164 	if (ret < 0)
10165 		printf("flex filter setting error: (%s)\n", strerror(-ret));
10166 }
10167 
10168 cmdline_parse_token_string_t cmd_flex_filter_filter =
10169 	TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10170 				filter, "flex_filter");
10171 cmdline_parse_token_num_t cmd_flex_filter_port_id =
10172 	TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10173 				port_id, UINT16);
10174 cmdline_parse_token_string_t cmd_flex_filter_ops =
10175 	TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10176 				ops, "add#del");
10177 cmdline_parse_token_string_t cmd_flex_filter_len =
10178 	TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10179 				len, "len");
10180 cmdline_parse_token_num_t cmd_flex_filter_len_value =
10181 	TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10182 				len_value, UINT8);
10183 cmdline_parse_token_string_t cmd_flex_filter_bytes =
10184 	TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10185 				bytes, "bytes");
10186 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
10187 	TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10188 				bytes_value, NULL);
10189 cmdline_parse_token_string_t cmd_flex_filter_mask =
10190 	TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10191 				mask, "mask");
10192 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
10193 	TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10194 				mask_value, NULL);
10195 cmdline_parse_token_string_t cmd_flex_filter_priority =
10196 	TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10197 				priority, "priority");
10198 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
10199 	TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10200 				priority_value, UINT8);
10201 cmdline_parse_token_string_t cmd_flex_filter_queue =
10202 	TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10203 				queue, "queue");
10204 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
10205 	TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10206 				queue_id, UINT16);
10207 cmdline_parse_inst_t cmd_flex_filter = {
10208 	.f = cmd_flex_filter_parsed,
10209 	.data = NULL,
10210 	.help_str = "flex_filter <port_id> add|del len <value> bytes "
10211 		"<value> mask <value> priority <value> queue <queue_id>: "
10212 		"Add/Del a flex filter",
10213 	.tokens = {
10214 		(void *)&cmd_flex_filter_filter,
10215 		(void *)&cmd_flex_filter_port_id,
10216 		(void *)&cmd_flex_filter_ops,
10217 		(void *)&cmd_flex_filter_len,
10218 		(void *)&cmd_flex_filter_len_value,
10219 		(void *)&cmd_flex_filter_bytes,
10220 		(void *)&cmd_flex_filter_bytes_value,
10221 		(void *)&cmd_flex_filter_mask,
10222 		(void *)&cmd_flex_filter_mask_value,
10223 		(void *)&cmd_flex_filter_priority,
10224 		(void *)&cmd_flex_filter_priority_value,
10225 		(void *)&cmd_flex_filter_queue,
10226 		(void *)&cmd_flex_filter_queue_id,
10227 		NULL,
10228 	},
10229 };
10230 
10231 /* *** Filters Control *** */
10232 
10233 /* *** deal with ethertype filter *** */
10234 struct cmd_ethertype_filter_result {
10235 	cmdline_fixed_string_t filter;
10236 	portid_t port_id;
10237 	cmdline_fixed_string_t ops;
10238 	cmdline_fixed_string_t mac;
10239 	struct ether_addr mac_addr;
10240 	cmdline_fixed_string_t ethertype;
10241 	uint16_t ethertype_value;
10242 	cmdline_fixed_string_t drop;
10243 	cmdline_fixed_string_t queue;
10244 	uint16_t  queue_id;
10245 };
10246 
10247 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
10248 	TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10249 				 filter, "ethertype_filter");
10250 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
10251 	TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10252 			      port_id, UINT16);
10253 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
10254 	TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10255 				 ops, "add#del");
10256 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
10257 	TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10258 				 mac, "mac_addr#mac_ignr");
10259 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
10260 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
10261 				     mac_addr);
10262 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
10263 	TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10264 				 ethertype, "ethertype");
10265 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
10266 	TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10267 			      ethertype_value, UINT16);
10268 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
10269 	TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10270 				 drop, "drop#fwd");
10271 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
10272 	TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10273 				 queue, "queue");
10274 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
10275 	TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10276 			      queue_id, UINT16);
10277 
10278 static void
10279 cmd_ethertype_filter_parsed(void *parsed_result,
10280 			  __attribute__((unused)) struct cmdline *cl,
10281 			  __attribute__((unused)) void *data)
10282 {
10283 	struct cmd_ethertype_filter_result *res = parsed_result;
10284 	struct rte_eth_ethertype_filter filter;
10285 	int ret = 0;
10286 
10287 	ret = rte_eth_dev_filter_supported(res->port_id,
10288 			RTE_ETH_FILTER_ETHERTYPE);
10289 	if (ret < 0) {
10290 		printf("ethertype filter is not supported on port %u.\n",
10291 			res->port_id);
10292 		return;
10293 	}
10294 
10295 	memset(&filter, 0, sizeof(filter));
10296 	if (!strcmp(res->mac, "mac_addr")) {
10297 		filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
10298 		rte_memcpy(&filter.mac_addr, &res->mac_addr,
10299 			sizeof(struct ether_addr));
10300 	}
10301 	if (!strcmp(res->drop, "drop"))
10302 		filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
10303 	filter.ether_type = res->ethertype_value;
10304 	filter.queue = res->queue_id;
10305 
10306 	if (!strcmp(res->ops, "add"))
10307 		ret = rte_eth_dev_filter_ctrl(res->port_id,
10308 				RTE_ETH_FILTER_ETHERTYPE,
10309 				RTE_ETH_FILTER_ADD,
10310 				&filter);
10311 	else
10312 		ret = rte_eth_dev_filter_ctrl(res->port_id,
10313 				RTE_ETH_FILTER_ETHERTYPE,
10314 				RTE_ETH_FILTER_DELETE,
10315 				&filter);
10316 	if (ret < 0)
10317 		printf("ethertype filter programming error: (%s)\n",
10318 			strerror(-ret));
10319 }
10320 
10321 cmdline_parse_inst_t cmd_ethertype_filter = {
10322 	.f = cmd_ethertype_filter_parsed,
10323 	.data = NULL,
10324 	.help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
10325 		"<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
10326 		"Add or delete an ethertype filter entry",
10327 	.tokens = {
10328 		(void *)&cmd_ethertype_filter_filter,
10329 		(void *)&cmd_ethertype_filter_port_id,
10330 		(void *)&cmd_ethertype_filter_ops,
10331 		(void *)&cmd_ethertype_filter_mac,
10332 		(void *)&cmd_ethertype_filter_mac_addr,
10333 		(void *)&cmd_ethertype_filter_ethertype,
10334 		(void *)&cmd_ethertype_filter_ethertype_value,
10335 		(void *)&cmd_ethertype_filter_drop,
10336 		(void *)&cmd_ethertype_filter_queue,
10337 		(void *)&cmd_ethertype_filter_queue_id,
10338 		NULL,
10339 	},
10340 };
10341 
10342 /* *** deal with flow director filter *** */
10343 struct cmd_flow_director_result {
10344 	cmdline_fixed_string_t flow_director_filter;
10345 	portid_t port_id;
10346 	cmdline_fixed_string_t mode;
10347 	cmdline_fixed_string_t mode_value;
10348 	cmdline_fixed_string_t ops;
10349 	cmdline_fixed_string_t flow;
10350 	cmdline_fixed_string_t flow_type;
10351 	cmdline_fixed_string_t ether;
10352 	uint16_t ether_type;
10353 	cmdline_fixed_string_t src;
10354 	cmdline_ipaddr_t ip_src;
10355 	uint16_t port_src;
10356 	cmdline_fixed_string_t dst;
10357 	cmdline_ipaddr_t ip_dst;
10358 	uint16_t port_dst;
10359 	cmdline_fixed_string_t verify_tag;
10360 	uint32_t verify_tag_value;
10361 	cmdline_fixed_string_t tos;
10362 	uint8_t tos_value;
10363 	cmdline_fixed_string_t proto;
10364 	uint8_t proto_value;
10365 	cmdline_fixed_string_t ttl;
10366 	uint8_t ttl_value;
10367 	cmdline_fixed_string_t vlan;
10368 	uint16_t vlan_value;
10369 	cmdline_fixed_string_t flexbytes;
10370 	cmdline_fixed_string_t flexbytes_value;
10371 	cmdline_fixed_string_t pf_vf;
10372 	cmdline_fixed_string_t drop;
10373 	cmdline_fixed_string_t queue;
10374 	uint16_t  queue_id;
10375 	cmdline_fixed_string_t fd_id;
10376 	uint32_t  fd_id_value;
10377 	cmdline_fixed_string_t mac;
10378 	struct ether_addr mac_addr;
10379 	cmdline_fixed_string_t tunnel;
10380 	cmdline_fixed_string_t tunnel_type;
10381 	cmdline_fixed_string_t tunnel_id;
10382 	uint32_t tunnel_id_value;
10383 	cmdline_fixed_string_t packet;
10384 	char filepath[];
10385 };
10386 
10387 static inline int
10388 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
10389 {
10390 	char s[256];
10391 	const char *p, *p0 = q_arg;
10392 	char *end;
10393 	unsigned long int_fld;
10394 	char *str_fld[max_num];
10395 	int i;
10396 	unsigned size;
10397 	int ret = -1;
10398 
10399 	p = strchr(p0, '(');
10400 	if (p == NULL)
10401 		return -1;
10402 	++p;
10403 	p0 = strchr(p, ')');
10404 	if (p0 == NULL)
10405 		return -1;
10406 
10407 	size = p0 - p;
10408 	if (size >= sizeof(s))
10409 		return -1;
10410 
10411 	snprintf(s, sizeof(s), "%.*s", size, p);
10412 	ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10413 	if (ret < 0 || ret > max_num)
10414 		return -1;
10415 	for (i = 0; i < ret; i++) {
10416 		errno = 0;
10417 		int_fld = strtoul(str_fld[i], &end, 0);
10418 		if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
10419 			return -1;
10420 		flexbytes[i] = (uint8_t)int_fld;
10421 	}
10422 	return ret;
10423 }
10424 
10425 static uint16_t
10426 str2flowtype(char *string)
10427 {
10428 	uint8_t i = 0;
10429 	static const struct {
10430 		char str[32];
10431 		uint16_t type;
10432 	} flowtype_str[] = {
10433 		{"raw", RTE_ETH_FLOW_RAW},
10434 		{"ipv4", RTE_ETH_FLOW_IPV4},
10435 		{"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10436 		{"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10437 		{"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10438 		{"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10439 		{"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10440 		{"ipv6", RTE_ETH_FLOW_IPV6},
10441 		{"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10442 		{"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10443 		{"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10444 		{"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10445 		{"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10446 		{"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10447 	};
10448 
10449 	for (i = 0; i < RTE_DIM(flowtype_str); i++) {
10450 		if (!strcmp(flowtype_str[i].str, string))
10451 			return flowtype_str[i].type;
10452 	}
10453 
10454 	if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
10455 		return (uint16_t)atoi(string);
10456 
10457 	return RTE_ETH_FLOW_UNKNOWN;
10458 }
10459 
10460 static enum rte_eth_fdir_tunnel_type
10461 str2fdir_tunneltype(char *string)
10462 {
10463 	uint8_t i = 0;
10464 
10465 	static const struct {
10466 		char str[32];
10467 		enum rte_eth_fdir_tunnel_type type;
10468 	} tunneltype_str[] = {
10469 		{"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
10470 		{"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
10471 	};
10472 
10473 	for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
10474 		if (!strcmp(tunneltype_str[i].str, string))
10475 			return tunneltype_str[i].type;
10476 	}
10477 	return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
10478 }
10479 
10480 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10481 do { \
10482 	if ((ip_addr).family == AF_INET) \
10483 		(ip) = (ip_addr).addr.ipv4.s_addr; \
10484 	else { \
10485 		printf("invalid parameter.\n"); \
10486 		return; \
10487 	} \
10488 } while (0)
10489 
10490 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10491 do { \
10492 	if ((ip_addr).family == AF_INET6) \
10493 		rte_memcpy(&(ip), \
10494 				 &((ip_addr).addr.ipv6), \
10495 				 sizeof(struct in6_addr)); \
10496 	else { \
10497 		printf("invalid parameter.\n"); \
10498 		return; \
10499 	} \
10500 } while (0)
10501 
10502 static void
10503 cmd_flow_director_filter_parsed(void *parsed_result,
10504 			  __attribute__((unused)) struct cmdline *cl,
10505 			  __attribute__((unused)) void *data)
10506 {
10507 	struct cmd_flow_director_result *res = parsed_result;
10508 	struct rte_eth_fdir_filter entry;
10509 	uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
10510 	char *end;
10511 	unsigned long vf_id;
10512 	int ret = 0;
10513 
10514 	ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
10515 	if (ret < 0) {
10516 		printf("flow director is not supported on port %u.\n",
10517 			res->port_id);
10518 		return;
10519 	}
10520 	memset(flexbytes, 0, sizeof(flexbytes));
10521 	memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
10522 
10523 	if (fdir_conf.mode ==  RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10524 		if (strcmp(res->mode_value, "MAC-VLAN")) {
10525 			printf("Please set mode to MAC-VLAN.\n");
10526 			return;
10527 		}
10528 	} else if (fdir_conf.mode ==  RTE_FDIR_MODE_PERFECT_TUNNEL) {
10529 		if (strcmp(res->mode_value, "Tunnel")) {
10530 			printf("Please set mode to Tunnel.\n");
10531 			return;
10532 		}
10533 	} else {
10534 		if (!strcmp(res->mode_value, "raw")) {
10535 #ifdef RTE_LIBRTE_I40E_PMD
10536 			struct rte_pmd_i40e_flow_type_mapping
10537 					mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
10538 			struct rte_pmd_i40e_pkt_template_conf conf;
10539 			uint16_t flow_type = str2flowtype(res->flow_type);
10540 			uint16_t i, port = res->port_id;
10541 			uint8_t add;
10542 
10543 			memset(&conf, 0, sizeof(conf));
10544 
10545 			if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
10546 				printf("Invalid flow type specified.\n");
10547 				return;
10548 			}
10549 			ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
10550 								 mapping);
10551 			if (ret)
10552 				return;
10553 			if (mapping[flow_type].pctype == 0ULL) {
10554 				printf("Invalid flow type specified.\n");
10555 				return;
10556 			}
10557 			for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
10558 				if (mapping[flow_type].pctype & (1ULL << i)) {
10559 					conf.input.pctype = i;
10560 					break;
10561 				}
10562 			}
10563 
10564 			conf.input.packet = open_file(res->filepath,
10565 						&conf.input.length);
10566 			if (!conf.input.packet)
10567 				return;
10568 			if (!strcmp(res->drop, "drop"))
10569 				conf.action.behavior =
10570 					RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
10571 			else
10572 				conf.action.behavior =
10573 					RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
10574 			conf.action.report_status =
10575 					RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
10576 			conf.action.rx_queue = res->queue_id;
10577 			conf.soft_id = res->fd_id_value;
10578 			add  = strcmp(res->ops, "del") ? 1 : 0;
10579 			ret = rte_pmd_i40e_flow_add_del_packet_template(port,
10580 									&conf,
10581 									add);
10582 			if (ret < 0)
10583 				printf("flow director config error: (%s)\n",
10584 				       strerror(-ret));
10585 			close_file(conf.input.packet);
10586 #endif
10587 			return;
10588 		} else if (strcmp(res->mode_value, "IP")) {
10589 			printf("Please set mode to IP or raw.\n");
10590 			return;
10591 		}
10592 		entry.input.flow_type = str2flowtype(res->flow_type);
10593 	}
10594 
10595 	ret = parse_flexbytes(res->flexbytes_value,
10596 					flexbytes,
10597 					RTE_ETH_FDIR_MAX_FLEXLEN);
10598 	if (ret < 0) {
10599 		printf("error: Cannot parse flexbytes input.\n");
10600 		return;
10601 	}
10602 
10603 	switch (entry.input.flow_type) {
10604 	case RTE_ETH_FLOW_FRAG_IPV4:
10605 	case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
10606 		entry.input.flow.ip4_flow.proto = res->proto_value;
10607 		/* fall-through */
10608 	case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
10609 	case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
10610 		IPV4_ADDR_TO_UINT(res->ip_dst,
10611 			entry.input.flow.ip4_flow.dst_ip);
10612 		IPV4_ADDR_TO_UINT(res->ip_src,
10613 			entry.input.flow.ip4_flow.src_ip);
10614 		entry.input.flow.ip4_flow.tos = res->tos_value;
10615 		entry.input.flow.ip4_flow.ttl = res->ttl_value;
10616 		/* need convert to big endian. */
10617 		entry.input.flow.udp4_flow.dst_port =
10618 				rte_cpu_to_be_16(res->port_dst);
10619 		entry.input.flow.udp4_flow.src_port =
10620 				rte_cpu_to_be_16(res->port_src);
10621 		break;
10622 	case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
10623 		IPV4_ADDR_TO_UINT(res->ip_dst,
10624 			entry.input.flow.sctp4_flow.ip.dst_ip);
10625 		IPV4_ADDR_TO_UINT(res->ip_src,
10626 			entry.input.flow.sctp4_flow.ip.src_ip);
10627 		entry.input.flow.ip4_flow.tos = res->tos_value;
10628 		entry.input.flow.ip4_flow.ttl = res->ttl_value;
10629 		/* need convert to big endian. */
10630 		entry.input.flow.sctp4_flow.dst_port =
10631 				rte_cpu_to_be_16(res->port_dst);
10632 		entry.input.flow.sctp4_flow.src_port =
10633 				rte_cpu_to_be_16(res->port_src);
10634 		entry.input.flow.sctp4_flow.verify_tag =
10635 				rte_cpu_to_be_32(res->verify_tag_value);
10636 		break;
10637 	case RTE_ETH_FLOW_FRAG_IPV6:
10638 	case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
10639 		entry.input.flow.ipv6_flow.proto = res->proto_value;
10640 		/* fall-through */
10641 	case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
10642 	case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
10643 		IPV6_ADDR_TO_ARRAY(res->ip_dst,
10644 			entry.input.flow.ipv6_flow.dst_ip);
10645 		IPV6_ADDR_TO_ARRAY(res->ip_src,
10646 			entry.input.flow.ipv6_flow.src_ip);
10647 		entry.input.flow.ipv6_flow.tc = res->tos_value;
10648 		entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
10649 		/* need convert to big endian. */
10650 		entry.input.flow.udp6_flow.dst_port =
10651 				rte_cpu_to_be_16(res->port_dst);
10652 		entry.input.flow.udp6_flow.src_port =
10653 				rte_cpu_to_be_16(res->port_src);
10654 		break;
10655 	case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
10656 		IPV6_ADDR_TO_ARRAY(res->ip_dst,
10657 			entry.input.flow.sctp6_flow.ip.dst_ip);
10658 		IPV6_ADDR_TO_ARRAY(res->ip_src,
10659 			entry.input.flow.sctp6_flow.ip.src_ip);
10660 		entry.input.flow.ipv6_flow.tc = res->tos_value;
10661 		entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
10662 		/* need convert to big endian. */
10663 		entry.input.flow.sctp6_flow.dst_port =
10664 				rte_cpu_to_be_16(res->port_dst);
10665 		entry.input.flow.sctp6_flow.src_port =
10666 				rte_cpu_to_be_16(res->port_src);
10667 		entry.input.flow.sctp6_flow.verify_tag =
10668 				rte_cpu_to_be_32(res->verify_tag_value);
10669 		break;
10670 	case RTE_ETH_FLOW_L2_PAYLOAD:
10671 		entry.input.flow.l2_flow.ether_type =
10672 			rte_cpu_to_be_16(res->ether_type);
10673 		break;
10674 	default:
10675 		break;
10676 	}
10677 
10678 	if (fdir_conf.mode ==  RTE_FDIR_MODE_PERFECT_MAC_VLAN)
10679 		rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
10680 				 &res->mac_addr,
10681 				 sizeof(struct ether_addr));
10682 
10683 	if (fdir_conf.mode ==  RTE_FDIR_MODE_PERFECT_TUNNEL) {
10684 		rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
10685 				 &res->mac_addr,
10686 				 sizeof(struct ether_addr));
10687 		entry.input.flow.tunnel_flow.tunnel_type =
10688 			str2fdir_tunneltype(res->tunnel_type);
10689 		entry.input.flow.tunnel_flow.tunnel_id =
10690 			rte_cpu_to_be_32(res->tunnel_id_value);
10691 	}
10692 
10693 	rte_memcpy(entry.input.flow_ext.flexbytes,
10694 		   flexbytes,
10695 		   RTE_ETH_FDIR_MAX_FLEXLEN);
10696 
10697 	entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
10698 
10699 	entry.action.flex_off = 0;  /*use 0 by default */
10700 	if (!strcmp(res->drop, "drop"))
10701 		entry.action.behavior = RTE_ETH_FDIR_REJECT;
10702 	else
10703 		entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
10704 
10705 	if (fdir_conf.mode !=  RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
10706 	    fdir_conf.mode !=  RTE_FDIR_MODE_PERFECT_TUNNEL) {
10707 		if (!strcmp(res->pf_vf, "pf"))
10708 			entry.input.flow_ext.is_vf = 0;
10709 		else if (!strncmp(res->pf_vf, "vf", 2)) {
10710 			struct rte_eth_dev_info dev_info;
10711 
10712 			memset(&dev_info, 0, sizeof(dev_info));
10713 			rte_eth_dev_info_get(res->port_id, &dev_info);
10714 			errno = 0;
10715 			vf_id = strtoul(res->pf_vf + 2, &end, 10);
10716 			if (errno != 0 || *end != '\0' ||
10717 			    vf_id >= dev_info.max_vfs) {
10718 				printf("invalid parameter %s.\n", res->pf_vf);
10719 				return;
10720 			}
10721 			entry.input.flow_ext.is_vf = 1;
10722 			entry.input.flow_ext.dst_id = (uint16_t)vf_id;
10723 		} else {
10724 			printf("invalid parameter %s.\n", res->pf_vf);
10725 			return;
10726 		}
10727 	}
10728 
10729 	/* set to report FD ID by default */
10730 	entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
10731 	entry.action.rx_queue = res->queue_id;
10732 	entry.soft_id = res->fd_id_value;
10733 	if (!strcmp(res->ops, "add"))
10734 		ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10735 					     RTE_ETH_FILTER_ADD, &entry);
10736 	else if (!strcmp(res->ops, "del"))
10737 		ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10738 					     RTE_ETH_FILTER_DELETE, &entry);
10739 	else
10740 		ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10741 					     RTE_ETH_FILTER_UPDATE, &entry);
10742 	if (ret < 0)
10743 		printf("flow director programming error: (%s)\n",
10744 			strerror(-ret));
10745 }
10746 
10747 cmdline_parse_token_string_t cmd_flow_director_filter =
10748 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10749 				 flow_director_filter, "flow_director_filter");
10750 cmdline_parse_token_num_t cmd_flow_director_port_id =
10751 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10752 			      port_id, UINT16);
10753 cmdline_parse_token_string_t cmd_flow_director_ops =
10754 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10755 				 ops, "add#del#update");
10756 cmdline_parse_token_string_t cmd_flow_director_flow =
10757 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10758 				 flow, "flow");
10759 cmdline_parse_token_string_t cmd_flow_director_flow_type =
10760 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10761 		flow_type, NULL);
10762 cmdline_parse_token_string_t cmd_flow_director_ether =
10763 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10764 				 ether, "ether");
10765 cmdline_parse_token_num_t cmd_flow_director_ether_type =
10766 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10767 			      ether_type, UINT16);
10768 cmdline_parse_token_string_t cmd_flow_director_src =
10769 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10770 				 src, "src");
10771 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
10772 	TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10773 				 ip_src);
10774 cmdline_parse_token_num_t cmd_flow_director_port_src =
10775 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10776 			      port_src, UINT16);
10777 cmdline_parse_token_string_t cmd_flow_director_dst =
10778 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10779 				 dst, "dst");
10780 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
10781 	TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10782 				 ip_dst);
10783 cmdline_parse_token_num_t cmd_flow_director_port_dst =
10784 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10785 			      port_dst, UINT16);
10786 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
10787 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10788 				  verify_tag, "verify_tag");
10789 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
10790 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10791 			      verify_tag_value, UINT32);
10792 cmdline_parse_token_string_t cmd_flow_director_tos =
10793 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10794 				 tos, "tos");
10795 cmdline_parse_token_num_t cmd_flow_director_tos_value =
10796 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10797 			      tos_value, UINT8);
10798 cmdline_parse_token_string_t cmd_flow_director_proto =
10799 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10800 				 proto, "proto");
10801 cmdline_parse_token_num_t cmd_flow_director_proto_value =
10802 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10803 			      proto_value, UINT8);
10804 cmdline_parse_token_string_t cmd_flow_director_ttl =
10805 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10806 				 ttl, "ttl");
10807 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
10808 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10809 			      ttl_value, UINT8);
10810 cmdline_parse_token_string_t cmd_flow_director_vlan =
10811 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10812 				 vlan, "vlan");
10813 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
10814 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10815 			      vlan_value, UINT16);
10816 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
10817 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10818 				 flexbytes, "flexbytes");
10819 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
10820 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10821 			      flexbytes_value, NULL);
10822 cmdline_parse_token_string_t cmd_flow_director_drop =
10823 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10824 				 drop, "drop#fwd");
10825 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
10826 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10827 			      pf_vf, NULL);
10828 cmdline_parse_token_string_t cmd_flow_director_queue =
10829 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10830 				 queue, "queue");
10831 cmdline_parse_token_num_t cmd_flow_director_queue_id =
10832 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10833 			      queue_id, UINT16);
10834 cmdline_parse_token_string_t cmd_flow_director_fd_id =
10835 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10836 				 fd_id, "fd_id");
10837 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
10838 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10839 			      fd_id_value, UINT32);
10840 
10841 cmdline_parse_token_string_t cmd_flow_director_mode =
10842 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10843 				 mode, "mode");
10844 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
10845 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10846 				 mode_value, "IP");
10847 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
10848 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10849 				 mode_value, "MAC-VLAN");
10850 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
10851 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10852 				 mode_value, "Tunnel");
10853 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
10854 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10855 				 mode_value, "raw");
10856 cmdline_parse_token_string_t cmd_flow_director_mac =
10857 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10858 				 mac, "mac");
10859 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
10860 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
10861 				    mac_addr);
10862 cmdline_parse_token_string_t cmd_flow_director_tunnel =
10863 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10864 				 tunnel, "tunnel");
10865 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
10866 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10867 				 tunnel_type, "NVGRE#VxLAN");
10868 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
10869 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10870 				 tunnel_id, "tunnel-id");
10871 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
10872 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10873 			      tunnel_id_value, UINT32);
10874 cmdline_parse_token_string_t cmd_flow_director_packet =
10875 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10876 				 packet, "packet");
10877 cmdline_parse_token_string_t cmd_flow_director_filepath =
10878 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10879 				 filepath, NULL);
10880 
10881 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
10882 	.f = cmd_flow_director_filter_parsed,
10883 	.data = NULL,
10884 	.help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
10885 		" ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
10886 		"ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
10887 		"l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
10888 		"proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
10889 		"flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> "
10890 		"fd_id <fd_id_value>: "
10891 		"Add or delete an ip flow director entry on NIC",
10892 	.tokens = {
10893 		(void *)&cmd_flow_director_filter,
10894 		(void *)&cmd_flow_director_port_id,
10895 		(void *)&cmd_flow_director_mode,
10896 		(void *)&cmd_flow_director_mode_ip,
10897 		(void *)&cmd_flow_director_ops,
10898 		(void *)&cmd_flow_director_flow,
10899 		(void *)&cmd_flow_director_flow_type,
10900 		(void *)&cmd_flow_director_src,
10901 		(void *)&cmd_flow_director_ip_src,
10902 		(void *)&cmd_flow_director_dst,
10903 		(void *)&cmd_flow_director_ip_dst,
10904 		(void *)&cmd_flow_director_tos,
10905 		(void *)&cmd_flow_director_tos_value,
10906 		(void *)&cmd_flow_director_proto,
10907 		(void *)&cmd_flow_director_proto_value,
10908 		(void *)&cmd_flow_director_ttl,
10909 		(void *)&cmd_flow_director_ttl_value,
10910 		(void *)&cmd_flow_director_vlan,
10911 		(void *)&cmd_flow_director_vlan_value,
10912 		(void *)&cmd_flow_director_flexbytes,
10913 		(void *)&cmd_flow_director_flexbytes_value,
10914 		(void *)&cmd_flow_director_drop,
10915 		(void *)&cmd_flow_director_pf_vf,
10916 		(void *)&cmd_flow_director_queue,
10917 		(void *)&cmd_flow_director_queue_id,
10918 		(void *)&cmd_flow_director_fd_id,
10919 		(void *)&cmd_flow_director_fd_id_value,
10920 		NULL,
10921 	},
10922 };
10923 
10924 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
10925 	.f = cmd_flow_director_filter_parsed,
10926 	.data = NULL,
10927 	.help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
10928 		"director entry on NIC",
10929 	.tokens = {
10930 		(void *)&cmd_flow_director_filter,
10931 		(void *)&cmd_flow_director_port_id,
10932 		(void *)&cmd_flow_director_mode,
10933 		(void *)&cmd_flow_director_mode_ip,
10934 		(void *)&cmd_flow_director_ops,
10935 		(void *)&cmd_flow_director_flow,
10936 		(void *)&cmd_flow_director_flow_type,
10937 		(void *)&cmd_flow_director_src,
10938 		(void *)&cmd_flow_director_ip_src,
10939 		(void *)&cmd_flow_director_port_src,
10940 		(void *)&cmd_flow_director_dst,
10941 		(void *)&cmd_flow_director_ip_dst,
10942 		(void *)&cmd_flow_director_port_dst,
10943 		(void *)&cmd_flow_director_tos,
10944 		(void *)&cmd_flow_director_tos_value,
10945 		(void *)&cmd_flow_director_ttl,
10946 		(void *)&cmd_flow_director_ttl_value,
10947 		(void *)&cmd_flow_director_vlan,
10948 		(void *)&cmd_flow_director_vlan_value,
10949 		(void *)&cmd_flow_director_flexbytes,
10950 		(void *)&cmd_flow_director_flexbytes_value,
10951 		(void *)&cmd_flow_director_drop,
10952 		(void *)&cmd_flow_director_pf_vf,
10953 		(void *)&cmd_flow_director_queue,
10954 		(void *)&cmd_flow_director_queue_id,
10955 		(void *)&cmd_flow_director_fd_id,
10956 		(void *)&cmd_flow_director_fd_id_value,
10957 		NULL,
10958 	},
10959 };
10960 
10961 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
10962 	.f = cmd_flow_director_filter_parsed,
10963 	.data = NULL,
10964 	.help_str = "flow_director_filter ... : Add or delete a sctp flow "
10965 		"director entry on NIC",
10966 	.tokens = {
10967 		(void *)&cmd_flow_director_filter,
10968 		(void *)&cmd_flow_director_port_id,
10969 		(void *)&cmd_flow_director_mode,
10970 		(void *)&cmd_flow_director_mode_ip,
10971 		(void *)&cmd_flow_director_ops,
10972 		(void *)&cmd_flow_director_flow,
10973 		(void *)&cmd_flow_director_flow_type,
10974 		(void *)&cmd_flow_director_src,
10975 		(void *)&cmd_flow_director_ip_src,
10976 		(void *)&cmd_flow_director_port_src,
10977 		(void *)&cmd_flow_director_dst,
10978 		(void *)&cmd_flow_director_ip_dst,
10979 		(void *)&cmd_flow_director_port_dst,
10980 		(void *)&cmd_flow_director_verify_tag,
10981 		(void *)&cmd_flow_director_verify_tag_value,
10982 		(void *)&cmd_flow_director_tos,
10983 		(void *)&cmd_flow_director_tos_value,
10984 		(void *)&cmd_flow_director_ttl,
10985 		(void *)&cmd_flow_director_ttl_value,
10986 		(void *)&cmd_flow_director_vlan,
10987 		(void *)&cmd_flow_director_vlan_value,
10988 		(void *)&cmd_flow_director_flexbytes,
10989 		(void *)&cmd_flow_director_flexbytes_value,
10990 		(void *)&cmd_flow_director_drop,
10991 		(void *)&cmd_flow_director_pf_vf,
10992 		(void *)&cmd_flow_director_queue,
10993 		(void *)&cmd_flow_director_queue_id,
10994 		(void *)&cmd_flow_director_fd_id,
10995 		(void *)&cmd_flow_director_fd_id_value,
10996 		NULL,
10997 	},
10998 };
10999 
11000 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
11001 	.f = cmd_flow_director_filter_parsed,
11002 	.data = NULL,
11003 	.help_str = "flow_director_filter ... : Add or delete a L2 flow "
11004 		"director entry on NIC",
11005 	.tokens = {
11006 		(void *)&cmd_flow_director_filter,
11007 		(void *)&cmd_flow_director_port_id,
11008 		(void *)&cmd_flow_director_mode,
11009 		(void *)&cmd_flow_director_mode_ip,
11010 		(void *)&cmd_flow_director_ops,
11011 		(void *)&cmd_flow_director_flow,
11012 		(void *)&cmd_flow_director_flow_type,
11013 		(void *)&cmd_flow_director_ether,
11014 		(void *)&cmd_flow_director_ether_type,
11015 		(void *)&cmd_flow_director_flexbytes,
11016 		(void *)&cmd_flow_director_flexbytes_value,
11017 		(void *)&cmd_flow_director_drop,
11018 		(void *)&cmd_flow_director_pf_vf,
11019 		(void *)&cmd_flow_director_queue,
11020 		(void *)&cmd_flow_director_queue_id,
11021 		(void *)&cmd_flow_director_fd_id,
11022 		(void *)&cmd_flow_director_fd_id_value,
11023 		NULL,
11024 	},
11025 };
11026 
11027 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
11028 	.f = cmd_flow_director_filter_parsed,
11029 	.data = NULL,
11030 	.help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
11031 		"director entry on NIC",
11032 	.tokens = {
11033 		(void *)&cmd_flow_director_filter,
11034 		(void *)&cmd_flow_director_port_id,
11035 		(void *)&cmd_flow_director_mode,
11036 		(void *)&cmd_flow_director_mode_mac_vlan,
11037 		(void *)&cmd_flow_director_ops,
11038 		(void *)&cmd_flow_director_mac,
11039 		(void *)&cmd_flow_director_mac_addr,
11040 		(void *)&cmd_flow_director_vlan,
11041 		(void *)&cmd_flow_director_vlan_value,
11042 		(void *)&cmd_flow_director_flexbytes,
11043 		(void *)&cmd_flow_director_flexbytes_value,
11044 		(void *)&cmd_flow_director_drop,
11045 		(void *)&cmd_flow_director_queue,
11046 		(void *)&cmd_flow_director_queue_id,
11047 		(void *)&cmd_flow_director_fd_id,
11048 		(void *)&cmd_flow_director_fd_id_value,
11049 		NULL,
11050 	},
11051 };
11052 
11053 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
11054 	.f = cmd_flow_director_filter_parsed,
11055 	.data = NULL,
11056 	.help_str = "flow_director_filter ... : Add or delete a tunnel flow "
11057 		"director entry on NIC",
11058 	.tokens = {
11059 		(void *)&cmd_flow_director_filter,
11060 		(void *)&cmd_flow_director_port_id,
11061 		(void *)&cmd_flow_director_mode,
11062 		(void *)&cmd_flow_director_mode_tunnel,
11063 		(void *)&cmd_flow_director_ops,
11064 		(void *)&cmd_flow_director_mac,
11065 		(void *)&cmd_flow_director_mac_addr,
11066 		(void *)&cmd_flow_director_vlan,
11067 		(void *)&cmd_flow_director_vlan_value,
11068 		(void *)&cmd_flow_director_tunnel,
11069 		(void *)&cmd_flow_director_tunnel_type,
11070 		(void *)&cmd_flow_director_tunnel_id,
11071 		(void *)&cmd_flow_director_tunnel_id_value,
11072 		(void *)&cmd_flow_director_flexbytes,
11073 		(void *)&cmd_flow_director_flexbytes_value,
11074 		(void *)&cmd_flow_director_drop,
11075 		(void *)&cmd_flow_director_queue,
11076 		(void *)&cmd_flow_director_queue_id,
11077 		(void *)&cmd_flow_director_fd_id,
11078 		(void *)&cmd_flow_director_fd_id_value,
11079 		NULL,
11080 	},
11081 };
11082 
11083 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
11084 	.f = cmd_flow_director_filter_parsed,
11085 	.data = NULL,
11086 	.help_str = "flow_director_filter ... : Add or delete a raw flow "
11087 		"director entry on NIC",
11088 	.tokens = {
11089 		(void *)&cmd_flow_director_filter,
11090 		(void *)&cmd_flow_director_port_id,
11091 		(void *)&cmd_flow_director_mode,
11092 		(void *)&cmd_flow_director_mode_raw,
11093 		(void *)&cmd_flow_director_ops,
11094 		(void *)&cmd_flow_director_flow,
11095 		(void *)&cmd_flow_director_flow_type,
11096 		(void *)&cmd_flow_director_drop,
11097 		(void *)&cmd_flow_director_queue,
11098 		(void *)&cmd_flow_director_queue_id,
11099 		(void *)&cmd_flow_director_fd_id,
11100 		(void *)&cmd_flow_director_fd_id_value,
11101 		(void *)&cmd_flow_director_packet,
11102 		(void *)&cmd_flow_director_filepath,
11103 		NULL,
11104 	},
11105 };
11106 
11107 struct cmd_flush_flow_director_result {
11108 	cmdline_fixed_string_t flush_flow_director;
11109 	portid_t port_id;
11110 };
11111 
11112 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
11113 	TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
11114 				 flush_flow_director, "flush_flow_director");
11115 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
11116 	TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
11117 			      port_id, UINT16);
11118 
11119 static void
11120 cmd_flush_flow_director_parsed(void *parsed_result,
11121 			  __attribute__((unused)) struct cmdline *cl,
11122 			  __attribute__((unused)) void *data)
11123 {
11124 	struct cmd_flow_director_result *res = parsed_result;
11125 	int ret = 0;
11126 
11127 	ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
11128 	if (ret < 0) {
11129 		printf("flow director is not supported on port %u.\n",
11130 			res->port_id);
11131 		return;
11132 	}
11133 
11134 	ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11135 			RTE_ETH_FILTER_FLUSH, NULL);
11136 	if (ret < 0)
11137 		printf("flow director table flushing error: (%s)\n",
11138 			strerror(-ret));
11139 }
11140 
11141 cmdline_parse_inst_t cmd_flush_flow_director = {
11142 	.f = cmd_flush_flow_director_parsed,
11143 	.data = NULL,
11144 	.help_str = "flush_flow_director <port_id>: "
11145 		"Flush all flow director entries of a device on NIC",
11146 	.tokens = {
11147 		(void *)&cmd_flush_flow_director_flush,
11148 		(void *)&cmd_flush_flow_director_port_id,
11149 		NULL,
11150 	},
11151 };
11152 
11153 /* *** deal with flow director mask *** */
11154 struct cmd_flow_director_mask_result {
11155 	cmdline_fixed_string_t flow_director_mask;
11156 	portid_t port_id;
11157 	cmdline_fixed_string_t mode;
11158 	cmdline_fixed_string_t mode_value;
11159 	cmdline_fixed_string_t vlan;
11160 	uint16_t vlan_mask;
11161 	cmdline_fixed_string_t src_mask;
11162 	cmdline_ipaddr_t ipv4_src;
11163 	cmdline_ipaddr_t ipv6_src;
11164 	uint16_t port_src;
11165 	cmdline_fixed_string_t dst_mask;
11166 	cmdline_ipaddr_t ipv4_dst;
11167 	cmdline_ipaddr_t ipv6_dst;
11168 	uint16_t port_dst;
11169 	cmdline_fixed_string_t mac;
11170 	uint8_t mac_addr_byte_mask;
11171 	cmdline_fixed_string_t tunnel_id;
11172 	uint32_t tunnel_id_mask;
11173 	cmdline_fixed_string_t tunnel_type;
11174 	uint8_t tunnel_type_mask;
11175 };
11176 
11177 static void
11178 cmd_flow_director_mask_parsed(void *parsed_result,
11179 			  __attribute__((unused)) struct cmdline *cl,
11180 			  __attribute__((unused)) void *data)
11181 {
11182 	struct cmd_flow_director_mask_result *res = parsed_result;
11183 	struct rte_eth_fdir_masks *mask;
11184 	struct rte_port *port;
11185 
11186 	port = &ports[res->port_id];
11187 	/** Check if the port is not started **/
11188 	if (port->port_status != RTE_PORT_STOPPED) {
11189 		printf("Please stop port %d first\n", res->port_id);
11190 		return;
11191 	}
11192 
11193 	mask = &port->dev_conf.fdir_conf.mask;
11194 
11195 	if (fdir_conf.mode ==  RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
11196 		if (strcmp(res->mode_value, "MAC-VLAN")) {
11197 			printf("Please set mode to MAC-VLAN.\n");
11198 			return;
11199 		}
11200 
11201 		mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11202 	} else if (fdir_conf.mode ==  RTE_FDIR_MODE_PERFECT_TUNNEL) {
11203 		if (strcmp(res->mode_value, "Tunnel")) {
11204 			printf("Please set mode to Tunnel.\n");
11205 			return;
11206 		}
11207 
11208 		mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11209 		mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
11210 		mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
11211 		mask->tunnel_type_mask = res->tunnel_type_mask;
11212 	} else {
11213 		if (strcmp(res->mode_value, "IP")) {
11214 			printf("Please set mode to IP.\n");
11215 			return;
11216 		}
11217 
11218 		mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11219 		IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
11220 		IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
11221 		IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
11222 		IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
11223 		mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
11224 		mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
11225 	}
11226 
11227 	cmd_reconfig_device_queue(res->port_id, 1, 1);
11228 }
11229 
11230 cmdline_parse_token_string_t cmd_flow_director_mask =
11231 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11232 				 flow_director_mask, "flow_director_mask");
11233 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
11234 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11235 			      port_id, UINT16);
11236 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
11237 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11238 				 vlan, "vlan");
11239 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
11240 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11241 			      vlan_mask, UINT16);
11242 cmdline_parse_token_string_t cmd_flow_director_mask_src =
11243 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11244 				 src_mask, "src_mask");
11245 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
11246 	TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11247 				 ipv4_src);
11248 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
11249 	TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11250 				 ipv6_src);
11251 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
11252 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11253 			      port_src, UINT16);
11254 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
11255 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11256 				 dst_mask, "dst_mask");
11257 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
11258 	TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11259 				 ipv4_dst);
11260 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
11261 	TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11262 				 ipv6_dst);
11263 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
11264 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11265 			      port_dst, UINT16);
11266 
11267 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
11268 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11269 				 mode, "mode");
11270 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
11271 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11272 				 mode_value, "IP");
11273 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
11274 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11275 				 mode_value, "MAC-VLAN");
11276 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
11277 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11278 				 mode_value, "Tunnel");
11279 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
11280 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11281 				 mac, "mac");
11282 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
11283 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11284 			      mac_addr_byte_mask, UINT8);
11285 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
11286 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11287 				 tunnel_type, "tunnel-type");
11288 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
11289 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11290 			      tunnel_type_mask, UINT8);
11291 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
11292 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11293 				 tunnel_id, "tunnel-id");
11294 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
11295 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11296 			      tunnel_id_mask, UINT32);
11297 
11298 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
11299 	.f = cmd_flow_director_mask_parsed,
11300 	.data = NULL,
11301 	.help_str = "flow_director_mask ... : "
11302 		"Set IP mode flow director's mask on NIC",
11303 	.tokens = {
11304 		(void *)&cmd_flow_director_mask,
11305 		(void *)&cmd_flow_director_mask_port_id,
11306 		(void *)&cmd_flow_director_mask_mode,
11307 		(void *)&cmd_flow_director_mask_mode_ip,
11308 		(void *)&cmd_flow_director_mask_vlan,
11309 		(void *)&cmd_flow_director_mask_vlan_value,
11310 		(void *)&cmd_flow_director_mask_src,
11311 		(void *)&cmd_flow_director_mask_ipv4_src,
11312 		(void *)&cmd_flow_director_mask_ipv6_src,
11313 		(void *)&cmd_flow_director_mask_port_src,
11314 		(void *)&cmd_flow_director_mask_dst,
11315 		(void *)&cmd_flow_director_mask_ipv4_dst,
11316 		(void *)&cmd_flow_director_mask_ipv6_dst,
11317 		(void *)&cmd_flow_director_mask_port_dst,
11318 		NULL,
11319 	},
11320 };
11321 
11322 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
11323 	.f = cmd_flow_director_mask_parsed,
11324 	.data = NULL,
11325 	.help_str = "flow_director_mask ... : Set MAC VLAN mode "
11326 		"flow director's mask on NIC",
11327 	.tokens = {
11328 		(void *)&cmd_flow_director_mask,
11329 		(void *)&cmd_flow_director_mask_port_id,
11330 		(void *)&cmd_flow_director_mask_mode,
11331 		(void *)&cmd_flow_director_mask_mode_mac_vlan,
11332 		(void *)&cmd_flow_director_mask_vlan,
11333 		(void *)&cmd_flow_director_mask_vlan_value,
11334 		NULL,
11335 	},
11336 };
11337 
11338 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
11339 	.f = cmd_flow_director_mask_parsed,
11340 	.data = NULL,
11341 	.help_str = "flow_director_mask ... : Set tunnel mode "
11342 		"flow director's mask on NIC",
11343 	.tokens = {
11344 		(void *)&cmd_flow_director_mask,
11345 		(void *)&cmd_flow_director_mask_port_id,
11346 		(void *)&cmd_flow_director_mask_mode,
11347 		(void *)&cmd_flow_director_mask_mode_tunnel,
11348 		(void *)&cmd_flow_director_mask_vlan,
11349 		(void *)&cmd_flow_director_mask_vlan_value,
11350 		(void *)&cmd_flow_director_mask_mac,
11351 		(void *)&cmd_flow_director_mask_mac_value,
11352 		(void *)&cmd_flow_director_mask_tunnel_type,
11353 		(void *)&cmd_flow_director_mask_tunnel_type_value,
11354 		(void *)&cmd_flow_director_mask_tunnel_id,
11355 		(void *)&cmd_flow_director_mask_tunnel_id_value,
11356 		NULL,
11357 	},
11358 };
11359 
11360 /* *** deal with flow director mask on flexible payload *** */
11361 struct cmd_flow_director_flex_mask_result {
11362 	cmdline_fixed_string_t flow_director_flexmask;
11363 	portid_t port_id;
11364 	cmdline_fixed_string_t flow;
11365 	cmdline_fixed_string_t flow_type;
11366 	cmdline_fixed_string_t mask;
11367 };
11368 
11369 static void
11370 cmd_flow_director_flex_mask_parsed(void *parsed_result,
11371 			  __attribute__((unused)) struct cmdline *cl,
11372 			  __attribute__((unused)) void *data)
11373 {
11374 	struct cmd_flow_director_flex_mask_result *res = parsed_result;
11375 	struct rte_eth_fdir_info fdir_info;
11376 	struct rte_eth_fdir_flex_mask flex_mask;
11377 	struct rte_port *port;
11378 	uint64_t flow_type_mask;
11379 	uint16_t i;
11380 	int ret;
11381 
11382 	port = &ports[res->port_id];
11383 	/** Check if the port is not started **/
11384 	if (port->port_status != RTE_PORT_STOPPED) {
11385 		printf("Please stop port %d first\n", res->port_id);
11386 		return;
11387 	}
11388 
11389 	memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
11390 	ret = parse_flexbytes(res->mask,
11391 			flex_mask.mask,
11392 			RTE_ETH_FDIR_MAX_FLEXLEN);
11393 	if (ret < 0) {
11394 		printf("error: Cannot parse mask input.\n");
11395 		return;
11396 	}
11397 
11398 	memset(&fdir_info, 0, sizeof(fdir_info));
11399 	ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11400 				RTE_ETH_FILTER_INFO, &fdir_info);
11401 	if (ret < 0) {
11402 		printf("Cannot get FDir filter info\n");
11403 		return;
11404 	}
11405 
11406 	if (!strcmp(res->flow_type, "none")) {
11407 		/* means don't specify the flow type */
11408 		flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
11409 		for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
11410 			memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
11411 			       0, sizeof(struct rte_eth_fdir_flex_mask));
11412 		port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
11413 		rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
11414 				 &flex_mask,
11415 				 sizeof(struct rte_eth_fdir_flex_mask));
11416 		cmd_reconfig_device_queue(res->port_id, 1, 1);
11417 		return;
11418 	}
11419 	flow_type_mask = fdir_info.flow_types_mask[0];
11420 	if (!strcmp(res->flow_type, "all")) {
11421 		if (!flow_type_mask) {
11422 			printf("No flow type supported\n");
11423 			return;
11424 		}
11425 		for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
11426 			if (flow_type_mask & (1ULL << i)) {
11427 				flex_mask.flow_type = i;
11428 				fdir_set_flex_mask(res->port_id, &flex_mask);
11429 			}
11430 		}
11431 		cmd_reconfig_device_queue(res->port_id, 1, 1);
11432 		return;
11433 	}
11434 	flex_mask.flow_type = str2flowtype(res->flow_type);
11435 	if (!(flow_type_mask & (1ULL << flex_mask.flow_type))) {
11436 		printf("Flow type %s not supported on port %d\n",
11437 				res->flow_type, res->port_id);
11438 		return;
11439 	}
11440 	fdir_set_flex_mask(res->port_id, &flex_mask);
11441 	cmd_reconfig_device_queue(res->port_id, 1, 1);
11442 }
11443 
11444 cmdline_parse_token_string_t cmd_flow_director_flexmask =
11445 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11446 				 flow_director_flexmask,
11447 				 "flow_director_flex_mask");
11448 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
11449 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11450 			      port_id, UINT16);
11451 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
11452 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11453 				 flow, "flow");
11454 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
11455 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11456 		flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
11457 		"ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
11458 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
11459 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11460 				 mask, NULL);
11461 
11462 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
11463 	.f = cmd_flow_director_flex_mask_parsed,
11464 	.data = NULL,
11465 	.help_str = "flow_director_flex_mask ... : "
11466 		"Set flow director's flex mask on NIC",
11467 	.tokens = {
11468 		(void *)&cmd_flow_director_flexmask,
11469 		(void *)&cmd_flow_director_flexmask_port_id,
11470 		(void *)&cmd_flow_director_flexmask_flow,
11471 		(void *)&cmd_flow_director_flexmask_flow_type,
11472 		(void *)&cmd_flow_director_flexmask_mask,
11473 		NULL,
11474 	},
11475 };
11476 
11477 /* *** deal with flow director flexible payload configuration *** */
11478 struct cmd_flow_director_flexpayload_result {
11479 	cmdline_fixed_string_t flow_director_flexpayload;
11480 	portid_t port_id;
11481 	cmdline_fixed_string_t payload_layer;
11482 	cmdline_fixed_string_t payload_cfg;
11483 };
11484 
11485 static inline int
11486 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
11487 {
11488 	char s[256];
11489 	const char *p, *p0 = q_arg;
11490 	char *end;
11491 	unsigned long int_fld;
11492 	char *str_fld[max_num];
11493 	int i;
11494 	unsigned size;
11495 	int ret = -1;
11496 
11497 	p = strchr(p0, '(');
11498 	if (p == NULL)
11499 		return -1;
11500 	++p;
11501 	p0 = strchr(p, ')');
11502 	if (p0 == NULL)
11503 		return -1;
11504 
11505 	size = p0 - p;
11506 	if (size >= sizeof(s))
11507 		return -1;
11508 
11509 	snprintf(s, sizeof(s), "%.*s", size, p);
11510 	ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
11511 	if (ret < 0 || ret > max_num)
11512 		return -1;
11513 	for (i = 0; i < ret; i++) {
11514 		errno = 0;
11515 		int_fld = strtoul(str_fld[i], &end, 0);
11516 		if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
11517 			return -1;
11518 		offsets[i] = (uint16_t)int_fld;
11519 	}
11520 	return ret;
11521 }
11522 
11523 static void
11524 cmd_flow_director_flxpld_parsed(void *parsed_result,
11525 			  __attribute__((unused)) struct cmdline *cl,
11526 			  __attribute__((unused)) void *data)
11527 {
11528 	struct cmd_flow_director_flexpayload_result *res = parsed_result;
11529 	struct rte_eth_flex_payload_cfg flex_cfg;
11530 	struct rte_port *port;
11531 	int ret = 0;
11532 
11533 	port = &ports[res->port_id];
11534 	/** Check if the port is not started **/
11535 	if (port->port_status != RTE_PORT_STOPPED) {
11536 		printf("Please stop port %d first\n", res->port_id);
11537 		return;
11538 	}
11539 
11540 	memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
11541 
11542 	if (!strcmp(res->payload_layer, "raw"))
11543 		flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
11544 	else if (!strcmp(res->payload_layer, "l2"))
11545 		flex_cfg.type = RTE_ETH_L2_PAYLOAD;
11546 	else if (!strcmp(res->payload_layer, "l3"))
11547 		flex_cfg.type = RTE_ETH_L3_PAYLOAD;
11548 	else if (!strcmp(res->payload_layer, "l4"))
11549 		flex_cfg.type = RTE_ETH_L4_PAYLOAD;
11550 
11551 	ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
11552 			    RTE_ETH_FDIR_MAX_FLEXLEN);
11553 	if (ret < 0) {
11554 		printf("error: Cannot parse flex payload input.\n");
11555 		return;
11556 	}
11557 
11558 	fdir_set_flex_payload(res->port_id, &flex_cfg);
11559 	cmd_reconfig_device_queue(res->port_id, 1, 1);
11560 }
11561 
11562 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
11563 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11564 				 flow_director_flexpayload,
11565 				 "flow_director_flex_payload");
11566 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
11567 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11568 			      port_id, UINT16);
11569 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
11570 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11571 				 payload_layer, "raw#l2#l3#l4");
11572 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
11573 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11574 				 payload_cfg, NULL);
11575 
11576 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
11577 	.f = cmd_flow_director_flxpld_parsed,
11578 	.data = NULL,
11579 	.help_str = "flow_director_flexpayload ... : "
11580 		"Set flow director's flex payload on NIC",
11581 	.tokens = {
11582 		(void *)&cmd_flow_director_flexpayload,
11583 		(void *)&cmd_flow_director_flexpayload_port_id,
11584 		(void *)&cmd_flow_director_flexpayload_payload_layer,
11585 		(void *)&cmd_flow_director_flexpayload_payload_cfg,
11586 		NULL,
11587 	},
11588 };
11589 
11590 /* Generic flow interface command. */
11591 extern cmdline_parse_inst_t cmd_flow;
11592 
11593 /* *** Classification Filters Control *** */
11594 /* *** Get symmetric hash enable per port *** */
11595 struct cmd_get_sym_hash_ena_per_port_result {
11596 	cmdline_fixed_string_t get_sym_hash_ena_per_port;
11597 	portid_t port_id;
11598 };
11599 
11600 static void
11601 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
11602 				 __rte_unused struct cmdline *cl,
11603 				 __rte_unused void *data)
11604 {
11605 	struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
11606 	struct rte_eth_hash_filter_info info;
11607 	int ret;
11608 
11609 	if (rte_eth_dev_filter_supported(res->port_id,
11610 				RTE_ETH_FILTER_HASH) < 0) {
11611 		printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
11612 							res->port_id);
11613 		return;
11614 	}
11615 
11616 	memset(&info, 0, sizeof(info));
11617 	info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
11618 	ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11619 						RTE_ETH_FILTER_GET, &info);
11620 
11621 	if (ret < 0) {
11622 		printf("Cannot get symmetric hash enable per port "
11623 					"on port %u\n", res->port_id);
11624 		return;
11625 	}
11626 
11627 	printf("Symmetric hash is %s on port %u\n", info.info.enable ?
11628 				"enabled" : "disabled", res->port_id);
11629 }
11630 
11631 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
11632 	TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
11633 		get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
11634 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
11635 	TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
11636 		port_id, UINT16);
11637 
11638 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
11639 	.f = cmd_get_sym_hash_per_port_parsed,
11640 	.data = NULL,
11641 	.help_str = "get_sym_hash_ena_per_port <port_id>",
11642 	.tokens = {
11643 		(void *)&cmd_get_sym_hash_ena_per_port_all,
11644 		(void *)&cmd_get_sym_hash_ena_per_port_port_id,
11645 		NULL,
11646 	},
11647 };
11648 
11649 /* *** Set symmetric hash enable per port *** */
11650 struct cmd_set_sym_hash_ena_per_port_result {
11651 	cmdline_fixed_string_t set_sym_hash_ena_per_port;
11652 	cmdline_fixed_string_t enable;
11653 	portid_t port_id;
11654 };
11655 
11656 static void
11657 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
11658 				 __rte_unused struct cmdline *cl,
11659 				 __rte_unused void *data)
11660 {
11661 	struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
11662 	struct rte_eth_hash_filter_info info;
11663 	int ret;
11664 
11665 	if (rte_eth_dev_filter_supported(res->port_id,
11666 				RTE_ETH_FILTER_HASH) < 0) {
11667 		printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
11668 							res->port_id);
11669 		return;
11670 	}
11671 
11672 	memset(&info, 0, sizeof(info));
11673 	info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
11674 	if (!strcmp(res->enable, "enable"))
11675 		info.info.enable = 1;
11676 	ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11677 					RTE_ETH_FILTER_SET, &info);
11678 	if (ret < 0) {
11679 		printf("Cannot set symmetric hash enable per port on "
11680 					"port %u\n", res->port_id);
11681 		return;
11682 	}
11683 	printf("Symmetric hash has been set to %s on port %u\n",
11684 					res->enable, res->port_id);
11685 }
11686 
11687 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
11688 	TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11689 		set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
11690 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
11691 	TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11692 		port_id, UINT16);
11693 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
11694 	TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11695 		enable, "enable#disable");
11696 
11697 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
11698 	.f = cmd_set_sym_hash_per_port_parsed,
11699 	.data = NULL,
11700 	.help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
11701 	.tokens = {
11702 		(void *)&cmd_set_sym_hash_ena_per_port_all,
11703 		(void *)&cmd_set_sym_hash_ena_per_port_port_id,
11704 		(void *)&cmd_set_sym_hash_ena_per_port_enable,
11705 		NULL,
11706 	},
11707 };
11708 
11709 /* Get global config of hash function */
11710 struct cmd_get_hash_global_config_result {
11711 	cmdline_fixed_string_t get_hash_global_config;
11712 	portid_t port_id;
11713 };
11714 
11715 static char *
11716 flowtype_to_str(uint16_t ftype)
11717 {
11718 	uint16_t i;
11719 	static struct {
11720 		char str[16];
11721 		uint16_t ftype;
11722 	} ftype_table[] = {
11723 		{"ipv4", RTE_ETH_FLOW_IPV4},
11724 		{"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
11725 		{"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
11726 		{"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
11727 		{"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
11728 		{"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
11729 		{"ipv6", RTE_ETH_FLOW_IPV6},
11730 		{"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
11731 		{"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
11732 		{"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
11733 		{"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
11734 		{"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
11735 		{"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
11736 		{"port", RTE_ETH_FLOW_PORT},
11737 		{"vxlan", RTE_ETH_FLOW_VXLAN},
11738 		{"geneve", RTE_ETH_FLOW_GENEVE},
11739 		{"nvgre", RTE_ETH_FLOW_NVGRE},
11740 	};
11741 
11742 	for (i = 0; i < RTE_DIM(ftype_table); i++) {
11743 		if (ftype_table[i].ftype == ftype)
11744 			return ftype_table[i].str;
11745 	}
11746 
11747 	return NULL;
11748 }
11749 
11750 static void
11751 cmd_get_hash_global_config_parsed(void *parsed_result,
11752 				  __rte_unused struct cmdline *cl,
11753 				  __rte_unused void *data)
11754 {
11755 	struct cmd_get_hash_global_config_result *res = parsed_result;
11756 	struct rte_eth_hash_filter_info info;
11757 	uint32_t idx, offset;
11758 	uint16_t i;
11759 	char *str;
11760 	int ret;
11761 
11762 	if (rte_eth_dev_filter_supported(res->port_id,
11763 			RTE_ETH_FILTER_HASH) < 0) {
11764 		printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
11765 							res->port_id);
11766 		return;
11767 	}
11768 
11769 	memset(&info, 0, sizeof(info));
11770 	info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
11771 	ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11772 					RTE_ETH_FILTER_GET, &info);
11773 	if (ret < 0) {
11774 		printf("Cannot get hash global configurations by port %d\n",
11775 							res->port_id);
11776 		return;
11777 	}
11778 
11779 	switch (info.info.global_conf.hash_func) {
11780 	case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
11781 		printf("Hash function is Toeplitz\n");
11782 		break;
11783 	case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
11784 		printf("Hash function is Simple XOR\n");
11785 		break;
11786 	default:
11787 		printf("Unknown hash function\n");
11788 		break;
11789 	}
11790 
11791 	for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
11792 		idx = i / UINT64_BIT;
11793 		offset = i % UINT64_BIT;
11794 		if (!(info.info.global_conf.valid_bit_mask[idx] &
11795 						(1ULL << offset)))
11796 			continue;
11797 		str = flowtype_to_str(i);
11798 		if (!str)
11799 			continue;
11800 		printf("Symmetric hash is %s globally for flow type %s "
11801 							"by port %d\n",
11802 			((info.info.global_conf.sym_hash_enable_mask[idx] &
11803 			(1ULL << offset)) ? "enabled" : "disabled"), str,
11804 							res->port_id);
11805 	}
11806 }
11807 
11808 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
11809 	TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
11810 		get_hash_global_config, "get_hash_global_config");
11811 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
11812 	TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
11813 		port_id, UINT16);
11814 
11815 cmdline_parse_inst_t cmd_get_hash_global_config = {
11816 	.f = cmd_get_hash_global_config_parsed,
11817 	.data = NULL,
11818 	.help_str = "get_hash_global_config <port_id>",
11819 	.tokens = {
11820 		(void *)&cmd_get_hash_global_config_all,
11821 		(void *)&cmd_get_hash_global_config_port_id,
11822 		NULL,
11823 	},
11824 };
11825 
11826 /* Set global config of hash function */
11827 struct cmd_set_hash_global_config_result {
11828 	cmdline_fixed_string_t set_hash_global_config;
11829 	portid_t port_id;
11830 	cmdline_fixed_string_t hash_func;
11831 	cmdline_fixed_string_t flow_type;
11832 	cmdline_fixed_string_t enable;
11833 };
11834 
11835 static void
11836 cmd_set_hash_global_config_parsed(void *parsed_result,
11837 				  __rte_unused struct cmdline *cl,
11838 				  __rte_unused void *data)
11839 {
11840 	struct cmd_set_hash_global_config_result *res = parsed_result;
11841 	struct rte_eth_hash_filter_info info;
11842 	uint32_t ftype, idx, offset;
11843 	int ret;
11844 
11845 	if (rte_eth_dev_filter_supported(res->port_id,
11846 				RTE_ETH_FILTER_HASH) < 0) {
11847 		printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
11848 							res->port_id);
11849 		return;
11850 	}
11851 	memset(&info, 0, sizeof(info));
11852 	info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
11853 	if (!strcmp(res->hash_func, "toeplitz"))
11854 		info.info.global_conf.hash_func =
11855 			RTE_ETH_HASH_FUNCTION_TOEPLITZ;
11856 	else if (!strcmp(res->hash_func, "simple_xor"))
11857 		info.info.global_conf.hash_func =
11858 			RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
11859 	else if (!strcmp(res->hash_func, "default"))
11860 		info.info.global_conf.hash_func =
11861 			RTE_ETH_HASH_FUNCTION_DEFAULT;
11862 
11863 	ftype = str2flowtype(res->flow_type);
11864 	idx = ftype / UINT64_BIT;
11865 	offset = ftype % UINT64_BIT;
11866 	info.info.global_conf.valid_bit_mask[idx] |= (1ULL << offset);
11867 	if (!strcmp(res->enable, "enable"))
11868 		info.info.global_conf.sym_hash_enable_mask[idx] |=
11869 						(1ULL << offset);
11870 	ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11871 					RTE_ETH_FILTER_SET, &info);
11872 	if (ret < 0)
11873 		printf("Cannot set global hash configurations by port %d\n",
11874 							res->port_id);
11875 	else
11876 		printf("Global hash configurations have been set "
11877 			"succcessfully by port %d\n", res->port_id);
11878 }
11879 
11880 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
11881 	TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11882 		set_hash_global_config, "set_hash_global_config");
11883 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
11884 	TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
11885 		port_id, UINT16);
11886 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
11887 	TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11888 		hash_func, "toeplitz#simple_xor#default");
11889 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
11890 	TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11891 		flow_type,
11892 		"ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
11893 		"ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
11894 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
11895 	TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11896 		enable, "enable#disable");
11897 
11898 cmdline_parse_inst_t cmd_set_hash_global_config = {
11899 	.f = cmd_set_hash_global_config_parsed,
11900 	.data = NULL,
11901 	.help_str = "set_hash_global_config <port_id> "
11902 		"toeplitz|simple_xor|default "
11903 		"ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11904 		"ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
11905 		"l2_payload enable|disable",
11906 	.tokens = {
11907 		(void *)&cmd_set_hash_global_config_all,
11908 		(void *)&cmd_set_hash_global_config_port_id,
11909 		(void *)&cmd_set_hash_global_config_hash_func,
11910 		(void *)&cmd_set_hash_global_config_flow_type,
11911 		(void *)&cmd_set_hash_global_config_enable,
11912 		NULL,
11913 	},
11914 };
11915 
11916 /* Set hash input set */
11917 struct cmd_set_hash_input_set_result {
11918 	cmdline_fixed_string_t set_hash_input_set;
11919 	portid_t port_id;
11920 	cmdline_fixed_string_t flow_type;
11921 	cmdline_fixed_string_t inset_field;
11922 	cmdline_fixed_string_t select;
11923 };
11924 
11925 static enum rte_eth_input_set_field
11926 str2inset(char *string)
11927 {
11928 	uint16_t i;
11929 
11930 	static const struct {
11931 		char str[32];
11932 		enum rte_eth_input_set_field inset;
11933 	} inset_table[] = {
11934 		{"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
11935 		{"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
11936 		{"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
11937 		{"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
11938 		{"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
11939 		{"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
11940 		{"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
11941 		{"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
11942 		{"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
11943 		{"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
11944 		{"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
11945 		{"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
11946 		{"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
11947 		{"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
11948 		{"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
11949 		{"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
11950 		{"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
11951 		{"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
11952 		{"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
11953 		{"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
11954 		{"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
11955 		{"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
11956 		{"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
11957 		{"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
11958 		{"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
11959 		{"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
11960 		{"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
11961 		{"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
11962 		{"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
11963 		{"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
11964 		{"none", RTE_ETH_INPUT_SET_NONE},
11965 	};
11966 
11967 	for (i = 0; i < RTE_DIM(inset_table); i++) {
11968 		if (!strcmp(string, inset_table[i].str))
11969 			return inset_table[i].inset;
11970 	}
11971 
11972 	return RTE_ETH_INPUT_SET_UNKNOWN;
11973 }
11974 
11975 static void
11976 cmd_set_hash_input_set_parsed(void *parsed_result,
11977 			      __rte_unused struct cmdline *cl,
11978 			      __rte_unused void *data)
11979 {
11980 	struct cmd_set_hash_input_set_result *res = parsed_result;
11981 	struct rte_eth_hash_filter_info info;
11982 
11983 	memset(&info, 0, sizeof(info));
11984 	info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
11985 	info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
11986 	info.info.input_set_conf.field[0] = str2inset(res->inset_field);
11987 	info.info.input_set_conf.inset_size = 1;
11988 	if (!strcmp(res->select, "select"))
11989 		info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
11990 	else if (!strcmp(res->select, "add"))
11991 		info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
11992 	rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11993 				RTE_ETH_FILTER_SET, &info);
11994 }
11995 
11996 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
11997 	TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11998 		set_hash_input_set, "set_hash_input_set");
11999 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
12000 	TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
12001 		port_id, UINT16);
12002 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
12003 	TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12004 		flow_type, NULL);
12005 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
12006 	TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12007 		inset_field,
12008 		"ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12009 		"ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
12010 		"udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
12011 		"sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
12012 		"fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
12013 		"fld-8th#none");
12014 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
12015 	TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12016 		select, "select#add");
12017 
12018 cmdline_parse_inst_t cmd_set_hash_input_set = {
12019 	.f = cmd_set_hash_input_set_parsed,
12020 	.data = NULL,
12021 	.help_str = "set_hash_input_set <port_id> "
12022 	"ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12023 	"ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
12024 	"ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
12025 	"ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
12026 	"tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
12027 	"gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
12028 	"fld-7th|fld-8th|none select|add",
12029 	.tokens = {
12030 		(void *)&cmd_set_hash_input_set_cmd,
12031 		(void *)&cmd_set_hash_input_set_port_id,
12032 		(void *)&cmd_set_hash_input_set_flow_type,
12033 		(void *)&cmd_set_hash_input_set_field,
12034 		(void *)&cmd_set_hash_input_set_select,
12035 		NULL,
12036 	},
12037 };
12038 
12039 /* Set flow director input set */
12040 struct cmd_set_fdir_input_set_result {
12041 	cmdline_fixed_string_t set_fdir_input_set;
12042 	portid_t port_id;
12043 	cmdline_fixed_string_t flow_type;
12044 	cmdline_fixed_string_t inset_field;
12045 	cmdline_fixed_string_t select;
12046 };
12047 
12048 static void
12049 cmd_set_fdir_input_set_parsed(void *parsed_result,
12050 	__rte_unused struct cmdline *cl,
12051 	__rte_unused void *data)
12052 {
12053 	struct cmd_set_fdir_input_set_result *res = parsed_result;
12054 	struct rte_eth_fdir_filter_info info;
12055 
12056 	memset(&info, 0, sizeof(info));
12057 	info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
12058 	info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12059 	info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12060 	info.info.input_set_conf.inset_size = 1;
12061 	if (!strcmp(res->select, "select"))
12062 		info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12063 	else if (!strcmp(res->select, "add"))
12064 		info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12065 	rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
12066 		RTE_ETH_FILTER_SET, &info);
12067 }
12068 
12069 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
12070 	TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12071 	set_fdir_input_set, "set_fdir_input_set");
12072 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
12073 	TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
12074 	port_id, UINT16);
12075 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
12076 	TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12077 	flow_type,
12078 	"ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
12079 	"ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12080 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
12081 	TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12082 	inset_field,
12083 	"ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12084 	"ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
12085 	"ipv6-hop-limits#udp-src-port#udp-dst-port#"
12086 	"tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
12087 	"sctp-veri-tag#none");
12088 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
12089 	TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12090 	select, "select#add");
12091 
12092 cmdline_parse_inst_t cmd_set_fdir_input_set = {
12093 	.f = cmd_set_fdir_input_set_parsed,
12094 	.data = NULL,
12095 	.help_str = "set_fdir_input_set <port_id> "
12096 	"ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12097 	"ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
12098 	"ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
12099 	"ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
12100 	"ipv6-hop-limits|udp-src-port|udp-dst-port|"
12101 	"tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
12102 	"sctp-veri-tag|none select|add",
12103 	.tokens = {
12104 		(void *)&cmd_set_fdir_input_set_cmd,
12105 		(void *)&cmd_set_fdir_input_set_port_id,
12106 		(void *)&cmd_set_fdir_input_set_flow_type,
12107 		(void *)&cmd_set_fdir_input_set_field,
12108 		(void *)&cmd_set_fdir_input_set_select,
12109 		NULL,
12110 	},
12111 };
12112 
12113 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
12114 struct cmd_mcast_addr_result {
12115 	cmdline_fixed_string_t mcast_addr_cmd;
12116 	cmdline_fixed_string_t what;
12117 	uint16_t port_num;
12118 	struct ether_addr mc_addr;
12119 };
12120 
12121 static void cmd_mcast_addr_parsed(void *parsed_result,
12122 		__attribute__((unused)) struct cmdline *cl,
12123 		__attribute__((unused)) void *data)
12124 {
12125 	struct cmd_mcast_addr_result *res = parsed_result;
12126 
12127 	if (!is_multicast_ether_addr(&res->mc_addr)) {
12128 		printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
12129 		       res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
12130 		       res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
12131 		       res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
12132 		return;
12133 	}
12134 	if (strcmp(res->what, "add") == 0)
12135 		mcast_addr_add(res->port_num, &res->mc_addr);
12136 	else
12137 		mcast_addr_remove(res->port_num, &res->mc_addr);
12138 }
12139 
12140 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
12141 	TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
12142 				 mcast_addr_cmd, "mcast_addr");
12143 cmdline_parse_token_string_t cmd_mcast_addr_what =
12144 	TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
12145 				 "add#remove");
12146 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
12147 	TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
12148 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
12149 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
12150 
12151 cmdline_parse_inst_t cmd_mcast_addr = {
12152 	.f = cmd_mcast_addr_parsed,
12153 	.data = (void *)0,
12154 	.help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
12155 		"Add/Remove multicast MAC address on port_id",
12156 	.tokens = {
12157 		(void *)&cmd_mcast_addr_cmd,
12158 		(void *)&cmd_mcast_addr_what,
12159 		(void *)&cmd_mcast_addr_portnum,
12160 		(void *)&cmd_mcast_addr_addr,
12161 		NULL,
12162 	},
12163 };
12164 
12165 /* l2 tunnel config
12166  * only support E-tag now.
12167  */
12168 
12169 /* Ether type config */
12170 struct cmd_config_l2_tunnel_eth_type_result {
12171 	cmdline_fixed_string_t port;
12172 	cmdline_fixed_string_t config;
12173 	cmdline_fixed_string_t all;
12174 	portid_t id;
12175 	cmdline_fixed_string_t l2_tunnel;
12176 	cmdline_fixed_string_t l2_tunnel_type;
12177 	cmdline_fixed_string_t eth_type;
12178 	uint16_t eth_type_val;
12179 };
12180 
12181 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
12182 	TOKEN_STRING_INITIALIZER
12183 		(struct cmd_config_l2_tunnel_eth_type_result,
12184 		 port, "port");
12185 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
12186 	TOKEN_STRING_INITIALIZER
12187 		(struct cmd_config_l2_tunnel_eth_type_result,
12188 		 config, "config");
12189 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
12190 	TOKEN_STRING_INITIALIZER
12191 		(struct cmd_config_l2_tunnel_eth_type_result,
12192 		 all, "all");
12193 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
12194 	TOKEN_NUM_INITIALIZER
12195 		(struct cmd_config_l2_tunnel_eth_type_result,
12196 		 id, UINT16);
12197 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
12198 	TOKEN_STRING_INITIALIZER
12199 		(struct cmd_config_l2_tunnel_eth_type_result,
12200 		 l2_tunnel, "l2-tunnel");
12201 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
12202 	TOKEN_STRING_INITIALIZER
12203 		(struct cmd_config_l2_tunnel_eth_type_result,
12204 		 l2_tunnel_type, "E-tag");
12205 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
12206 	TOKEN_STRING_INITIALIZER
12207 		(struct cmd_config_l2_tunnel_eth_type_result,
12208 		 eth_type, "ether-type");
12209 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
12210 	TOKEN_NUM_INITIALIZER
12211 		(struct cmd_config_l2_tunnel_eth_type_result,
12212 		 eth_type_val, UINT16);
12213 
12214 static enum rte_eth_tunnel_type
12215 str2fdir_l2_tunnel_type(char *string)
12216 {
12217 	uint32_t i = 0;
12218 
12219 	static const struct {
12220 		char str[32];
12221 		enum rte_eth_tunnel_type type;
12222 	} l2_tunnel_type_str[] = {
12223 		{"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
12224 	};
12225 
12226 	for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
12227 		if (!strcmp(l2_tunnel_type_str[i].str, string))
12228 			return l2_tunnel_type_str[i].type;
12229 	}
12230 	return RTE_TUNNEL_TYPE_NONE;
12231 }
12232 
12233 /* ether type config for all ports */
12234 static void
12235 cmd_config_l2_tunnel_eth_type_all_parsed
12236 	(void *parsed_result,
12237 	 __attribute__((unused)) struct cmdline *cl,
12238 	 __attribute__((unused)) void *data)
12239 {
12240 	struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
12241 	struct rte_eth_l2_tunnel_conf entry;
12242 	portid_t pid;
12243 
12244 	entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12245 	entry.ether_type = res->eth_type_val;
12246 
12247 	RTE_ETH_FOREACH_DEV(pid) {
12248 		rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
12249 	}
12250 }
12251 
12252 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
12253 	.f = cmd_config_l2_tunnel_eth_type_all_parsed,
12254 	.data = NULL,
12255 	.help_str = "port config all l2-tunnel E-tag ether-type <value>",
12256 	.tokens = {
12257 		(void *)&cmd_config_l2_tunnel_eth_type_port,
12258 		(void *)&cmd_config_l2_tunnel_eth_type_config,
12259 		(void *)&cmd_config_l2_tunnel_eth_type_all_str,
12260 		(void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12261 		(void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12262 		(void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12263 		(void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12264 		NULL,
12265 	},
12266 };
12267 
12268 /* ether type config for a specific port */
12269 static void
12270 cmd_config_l2_tunnel_eth_type_specific_parsed(
12271 	void *parsed_result,
12272 	__attribute__((unused)) struct cmdline *cl,
12273 	__attribute__((unused)) void *data)
12274 {
12275 	struct cmd_config_l2_tunnel_eth_type_result *res =
12276 		 parsed_result;
12277 	struct rte_eth_l2_tunnel_conf entry;
12278 
12279 	if (port_id_is_invalid(res->id, ENABLED_WARN))
12280 		return;
12281 
12282 	entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12283 	entry.ether_type = res->eth_type_val;
12284 
12285 	rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
12286 }
12287 
12288 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
12289 	.f = cmd_config_l2_tunnel_eth_type_specific_parsed,
12290 	.data = NULL,
12291 	.help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
12292 	.tokens = {
12293 		(void *)&cmd_config_l2_tunnel_eth_type_port,
12294 		(void *)&cmd_config_l2_tunnel_eth_type_config,
12295 		(void *)&cmd_config_l2_tunnel_eth_type_id,
12296 		(void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12297 		(void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12298 		(void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12299 		(void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12300 		NULL,
12301 	},
12302 };
12303 
12304 /* Enable/disable l2 tunnel */
12305 struct cmd_config_l2_tunnel_en_dis_result {
12306 	cmdline_fixed_string_t port;
12307 	cmdline_fixed_string_t config;
12308 	cmdline_fixed_string_t all;
12309 	portid_t id;
12310 	cmdline_fixed_string_t l2_tunnel;
12311 	cmdline_fixed_string_t l2_tunnel_type;
12312 	cmdline_fixed_string_t en_dis;
12313 };
12314 
12315 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
12316 	TOKEN_STRING_INITIALIZER
12317 		(struct cmd_config_l2_tunnel_en_dis_result,
12318 		 port, "port");
12319 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
12320 	TOKEN_STRING_INITIALIZER
12321 		(struct cmd_config_l2_tunnel_en_dis_result,
12322 		 config, "config");
12323 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
12324 	TOKEN_STRING_INITIALIZER
12325 		(struct cmd_config_l2_tunnel_en_dis_result,
12326 		 all, "all");
12327 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
12328 	TOKEN_NUM_INITIALIZER
12329 		(struct cmd_config_l2_tunnel_en_dis_result,
12330 		 id, UINT16);
12331 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
12332 	TOKEN_STRING_INITIALIZER
12333 		(struct cmd_config_l2_tunnel_en_dis_result,
12334 		 l2_tunnel, "l2-tunnel");
12335 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
12336 	TOKEN_STRING_INITIALIZER
12337 		(struct cmd_config_l2_tunnel_en_dis_result,
12338 		 l2_tunnel_type, "E-tag");
12339 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
12340 	TOKEN_STRING_INITIALIZER
12341 		(struct cmd_config_l2_tunnel_en_dis_result,
12342 		 en_dis, "enable#disable");
12343 
12344 /* enable/disable l2 tunnel for all ports */
12345 static void
12346 cmd_config_l2_tunnel_en_dis_all_parsed(
12347 	void *parsed_result,
12348 	__attribute__((unused)) struct cmdline *cl,
12349 	__attribute__((unused)) void *data)
12350 {
12351 	struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
12352 	struct rte_eth_l2_tunnel_conf entry;
12353 	portid_t pid;
12354 	uint8_t en;
12355 
12356 	entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12357 
12358 	if (!strcmp("enable", res->en_dis))
12359 		en = 1;
12360 	else
12361 		en = 0;
12362 
12363 	RTE_ETH_FOREACH_DEV(pid) {
12364 		rte_eth_dev_l2_tunnel_offload_set(pid,
12365 						  &entry,
12366 						  ETH_L2_TUNNEL_ENABLE_MASK,
12367 						  en);
12368 	}
12369 }
12370 
12371 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
12372 	.f = cmd_config_l2_tunnel_en_dis_all_parsed,
12373 	.data = NULL,
12374 	.help_str = "port config all l2-tunnel E-tag enable|disable",
12375 	.tokens = {
12376 		(void *)&cmd_config_l2_tunnel_en_dis_port,
12377 		(void *)&cmd_config_l2_tunnel_en_dis_config,
12378 		(void *)&cmd_config_l2_tunnel_en_dis_all_str,
12379 		(void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12380 		(void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12381 		(void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12382 		NULL,
12383 	},
12384 };
12385 
12386 /* enable/disable l2 tunnel for a port */
12387 static void
12388 cmd_config_l2_tunnel_en_dis_specific_parsed(
12389 	void *parsed_result,
12390 	__attribute__((unused)) struct cmdline *cl,
12391 	__attribute__((unused)) void *data)
12392 {
12393 	struct cmd_config_l2_tunnel_en_dis_result *res =
12394 		parsed_result;
12395 	struct rte_eth_l2_tunnel_conf entry;
12396 
12397 	if (port_id_is_invalid(res->id, ENABLED_WARN))
12398 		return;
12399 
12400 	entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12401 
12402 	if (!strcmp("enable", res->en_dis))
12403 		rte_eth_dev_l2_tunnel_offload_set(res->id,
12404 						  &entry,
12405 						  ETH_L2_TUNNEL_ENABLE_MASK,
12406 						  1);
12407 	else
12408 		rte_eth_dev_l2_tunnel_offload_set(res->id,
12409 						  &entry,
12410 						  ETH_L2_TUNNEL_ENABLE_MASK,
12411 						  0);
12412 }
12413 
12414 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
12415 	.f = cmd_config_l2_tunnel_en_dis_specific_parsed,
12416 	.data = NULL,
12417 	.help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
12418 	.tokens = {
12419 		(void *)&cmd_config_l2_tunnel_en_dis_port,
12420 		(void *)&cmd_config_l2_tunnel_en_dis_config,
12421 		(void *)&cmd_config_l2_tunnel_en_dis_id,
12422 		(void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12423 		(void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12424 		(void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12425 		NULL,
12426 	},
12427 };
12428 
12429 /* E-tag configuration */
12430 
12431 /* Common result structure for all E-tag configuration */
12432 struct cmd_config_e_tag_result {
12433 	cmdline_fixed_string_t e_tag;
12434 	cmdline_fixed_string_t set;
12435 	cmdline_fixed_string_t insertion;
12436 	cmdline_fixed_string_t stripping;
12437 	cmdline_fixed_string_t forwarding;
12438 	cmdline_fixed_string_t filter;
12439 	cmdline_fixed_string_t add;
12440 	cmdline_fixed_string_t del;
12441 	cmdline_fixed_string_t on;
12442 	cmdline_fixed_string_t off;
12443 	cmdline_fixed_string_t on_off;
12444 	cmdline_fixed_string_t port_tag_id;
12445 	uint32_t port_tag_id_val;
12446 	cmdline_fixed_string_t e_tag_id;
12447 	uint16_t e_tag_id_val;
12448 	cmdline_fixed_string_t dst_pool;
12449 	uint8_t dst_pool_val;
12450 	cmdline_fixed_string_t port;
12451 	portid_t port_id;
12452 	cmdline_fixed_string_t vf;
12453 	uint8_t vf_id;
12454 };
12455 
12456 /* Common CLI fields for all E-tag configuration */
12457 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
12458 	TOKEN_STRING_INITIALIZER
12459 		(struct cmd_config_e_tag_result,
12460 		 e_tag, "E-tag");
12461 cmdline_parse_token_string_t cmd_config_e_tag_set =
12462 	TOKEN_STRING_INITIALIZER
12463 		(struct cmd_config_e_tag_result,
12464 		 set, "set");
12465 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
12466 	TOKEN_STRING_INITIALIZER
12467 		(struct cmd_config_e_tag_result,
12468 		 insertion, "insertion");
12469 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
12470 	TOKEN_STRING_INITIALIZER
12471 		(struct cmd_config_e_tag_result,
12472 		 stripping, "stripping");
12473 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
12474 	TOKEN_STRING_INITIALIZER
12475 		(struct cmd_config_e_tag_result,
12476 		 forwarding, "forwarding");
12477 cmdline_parse_token_string_t cmd_config_e_tag_filter =
12478 	TOKEN_STRING_INITIALIZER
12479 		(struct cmd_config_e_tag_result,
12480 		 filter, "filter");
12481 cmdline_parse_token_string_t cmd_config_e_tag_add =
12482 	TOKEN_STRING_INITIALIZER
12483 		(struct cmd_config_e_tag_result,
12484 		 add, "add");
12485 cmdline_parse_token_string_t cmd_config_e_tag_del =
12486 	TOKEN_STRING_INITIALIZER
12487 		(struct cmd_config_e_tag_result,
12488 		 del, "del");
12489 cmdline_parse_token_string_t cmd_config_e_tag_on =
12490 	TOKEN_STRING_INITIALIZER
12491 		(struct cmd_config_e_tag_result,
12492 		 on, "on");
12493 cmdline_parse_token_string_t cmd_config_e_tag_off =
12494 	TOKEN_STRING_INITIALIZER
12495 		(struct cmd_config_e_tag_result,
12496 		 off, "off");
12497 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
12498 	TOKEN_STRING_INITIALIZER
12499 		(struct cmd_config_e_tag_result,
12500 		 on_off, "on#off");
12501 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
12502 	TOKEN_STRING_INITIALIZER
12503 		(struct cmd_config_e_tag_result,
12504 		 port_tag_id, "port-tag-id");
12505 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
12506 	TOKEN_NUM_INITIALIZER
12507 		(struct cmd_config_e_tag_result,
12508 		 port_tag_id_val, UINT32);
12509 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
12510 	TOKEN_STRING_INITIALIZER
12511 		(struct cmd_config_e_tag_result,
12512 		 e_tag_id, "e-tag-id");
12513 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
12514 	TOKEN_NUM_INITIALIZER
12515 		(struct cmd_config_e_tag_result,
12516 		 e_tag_id_val, UINT16);
12517 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
12518 	TOKEN_STRING_INITIALIZER
12519 		(struct cmd_config_e_tag_result,
12520 		 dst_pool, "dst-pool");
12521 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
12522 	TOKEN_NUM_INITIALIZER
12523 		(struct cmd_config_e_tag_result,
12524 		 dst_pool_val, UINT8);
12525 cmdline_parse_token_string_t cmd_config_e_tag_port =
12526 	TOKEN_STRING_INITIALIZER
12527 		(struct cmd_config_e_tag_result,
12528 		 port, "port");
12529 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
12530 	TOKEN_NUM_INITIALIZER
12531 		(struct cmd_config_e_tag_result,
12532 		 port_id, UINT16);
12533 cmdline_parse_token_string_t cmd_config_e_tag_vf =
12534 	TOKEN_STRING_INITIALIZER
12535 		(struct cmd_config_e_tag_result,
12536 		 vf, "vf");
12537 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
12538 	TOKEN_NUM_INITIALIZER
12539 		(struct cmd_config_e_tag_result,
12540 		 vf_id, UINT8);
12541 
12542 /* E-tag insertion configuration */
12543 static void
12544 cmd_config_e_tag_insertion_en_parsed(
12545 	void *parsed_result,
12546 	__attribute__((unused)) struct cmdline *cl,
12547 	__attribute__((unused)) void *data)
12548 {
12549 	struct cmd_config_e_tag_result *res =
12550 		parsed_result;
12551 	struct rte_eth_l2_tunnel_conf entry;
12552 
12553 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12554 		return;
12555 
12556 	entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12557 	entry.tunnel_id = res->port_tag_id_val;
12558 	entry.vf_id = res->vf_id;
12559 	rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12560 					  &entry,
12561 					  ETH_L2_TUNNEL_INSERTION_MASK,
12562 					  1);
12563 }
12564 
12565 static void
12566 cmd_config_e_tag_insertion_dis_parsed(
12567 	void *parsed_result,
12568 	__attribute__((unused)) struct cmdline *cl,
12569 	__attribute__((unused)) void *data)
12570 {
12571 	struct cmd_config_e_tag_result *res =
12572 		parsed_result;
12573 	struct rte_eth_l2_tunnel_conf entry;
12574 
12575 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12576 		return;
12577 
12578 	entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12579 	entry.vf_id = res->vf_id;
12580 
12581 	rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12582 					  &entry,
12583 					  ETH_L2_TUNNEL_INSERTION_MASK,
12584 					  0);
12585 }
12586 
12587 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
12588 	.f = cmd_config_e_tag_insertion_en_parsed,
12589 	.data = NULL,
12590 	.help_str = "E-tag ... : E-tag insertion enable",
12591 	.tokens = {
12592 		(void *)&cmd_config_e_tag_e_tag,
12593 		(void *)&cmd_config_e_tag_set,
12594 		(void *)&cmd_config_e_tag_insertion,
12595 		(void *)&cmd_config_e_tag_on,
12596 		(void *)&cmd_config_e_tag_port_tag_id,
12597 		(void *)&cmd_config_e_tag_port_tag_id_val,
12598 		(void *)&cmd_config_e_tag_port,
12599 		(void *)&cmd_config_e_tag_port_id,
12600 		(void *)&cmd_config_e_tag_vf,
12601 		(void *)&cmd_config_e_tag_vf_id,
12602 		NULL,
12603 	},
12604 };
12605 
12606 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
12607 	.f = cmd_config_e_tag_insertion_dis_parsed,
12608 	.data = NULL,
12609 	.help_str = "E-tag ... : E-tag insertion disable",
12610 	.tokens = {
12611 		(void *)&cmd_config_e_tag_e_tag,
12612 		(void *)&cmd_config_e_tag_set,
12613 		(void *)&cmd_config_e_tag_insertion,
12614 		(void *)&cmd_config_e_tag_off,
12615 		(void *)&cmd_config_e_tag_port,
12616 		(void *)&cmd_config_e_tag_port_id,
12617 		(void *)&cmd_config_e_tag_vf,
12618 		(void *)&cmd_config_e_tag_vf_id,
12619 		NULL,
12620 	},
12621 };
12622 
12623 /* E-tag stripping configuration */
12624 static void
12625 cmd_config_e_tag_stripping_parsed(
12626 	void *parsed_result,
12627 	__attribute__((unused)) struct cmdline *cl,
12628 	__attribute__((unused)) void *data)
12629 {
12630 	struct cmd_config_e_tag_result *res =
12631 		parsed_result;
12632 	struct rte_eth_l2_tunnel_conf entry;
12633 
12634 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12635 		return;
12636 
12637 	entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12638 
12639 	if (!strcmp(res->on_off, "on"))
12640 		rte_eth_dev_l2_tunnel_offload_set
12641 			(res->port_id,
12642 			 &entry,
12643 			 ETH_L2_TUNNEL_STRIPPING_MASK,
12644 			 1);
12645 	else
12646 		rte_eth_dev_l2_tunnel_offload_set
12647 			(res->port_id,
12648 			 &entry,
12649 			 ETH_L2_TUNNEL_STRIPPING_MASK,
12650 			 0);
12651 }
12652 
12653 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
12654 	.f = cmd_config_e_tag_stripping_parsed,
12655 	.data = NULL,
12656 	.help_str = "E-tag ... : E-tag stripping enable/disable",
12657 	.tokens = {
12658 		(void *)&cmd_config_e_tag_e_tag,
12659 		(void *)&cmd_config_e_tag_set,
12660 		(void *)&cmd_config_e_tag_stripping,
12661 		(void *)&cmd_config_e_tag_on_off,
12662 		(void *)&cmd_config_e_tag_port,
12663 		(void *)&cmd_config_e_tag_port_id,
12664 		NULL,
12665 	},
12666 };
12667 
12668 /* E-tag forwarding configuration */
12669 static void
12670 cmd_config_e_tag_forwarding_parsed(
12671 	void *parsed_result,
12672 	__attribute__((unused)) struct cmdline *cl,
12673 	__attribute__((unused)) void *data)
12674 {
12675 	struct cmd_config_e_tag_result *res = parsed_result;
12676 	struct rte_eth_l2_tunnel_conf entry;
12677 
12678 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12679 		return;
12680 
12681 	entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12682 
12683 	if (!strcmp(res->on_off, "on"))
12684 		rte_eth_dev_l2_tunnel_offload_set
12685 			(res->port_id,
12686 			 &entry,
12687 			 ETH_L2_TUNNEL_FORWARDING_MASK,
12688 			 1);
12689 	else
12690 		rte_eth_dev_l2_tunnel_offload_set
12691 			(res->port_id,
12692 			 &entry,
12693 			 ETH_L2_TUNNEL_FORWARDING_MASK,
12694 			 0);
12695 }
12696 
12697 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
12698 	.f = cmd_config_e_tag_forwarding_parsed,
12699 	.data = NULL,
12700 	.help_str = "E-tag ... : E-tag forwarding enable/disable",
12701 	.tokens = {
12702 		(void *)&cmd_config_e_tag_e_tag,
12703 		(void *)&cmd_config_e_tag_set,
12704 		(void *)&cmd_config_e_tag_forwarding,
12705 		(void *)&cmd_config_e_tag_on_off,
12706 		(void *)&cmd_config_e_tag_port,
12707 		(void *)&cmd_config_e_tag_port_id,
12708 		NULL,
12709 	},
12710 };
12711 
12712 /* E-tag filter configuration */
12713 static void
12714 cmd_config_e_tag_filter_add_parsed(
12715 	void *parsed_result,
12716 	__attribute__((unused)) struct cmdline *cl,
12717 	__attribute__((unused)) void *data)
12718 {
12719 	struct cmd_config_e_tag_result *res = parsed_result;
12720 	struct rte_eth_l2_tunnel_conf entry;
12721 	int ret = 0;
12722 
12723 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12724 		return;
12725 
12726 	if (res->e_tag_id_val > 0x3fff) {
12727 		printf("e-tag-id must be equal or less than 0x3fff.\n");
12728 		return;
12729 	}
12730 
12731 	ret = rte_eth_dev_filter_supported(res->port_id,
12732 					   RTE_ETH_FILTER_L2_TUNNEL);
12733 	if (ret < 0) {
12734 		printf("E-tag filter is not supported on port %u.\n",
12735 		       res->port_id);
12736 		return;
12737 	}
12738 
12739 	entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12740 	entry.tunnel_id = res->e_tag_id_val;
12741 	entry.pool = res->dst_pool_val;
12742 
12743 	ret = rte_eth_dev_filter_ctrl(res->port_id,
12744 				      RTE_ETH_FILTER_L2_TUNNEL,
12745 				      RTE_ETH_FILTER_ADD,
12746 				      &entry);
12747 	if (ret < 0)
12748 		printf("E-tag filter programming error: (%s)\n",
12749 		       strerror(-ret));
12750 }
12751 
12752 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
12753 	.f = cmd_config_e_tag_filter_add_parsed,
12754 	.data = NULL,
12755 	.help_str = "E-tag ... : E-tag filter add",
12756 	.tokens = {
12757 		(void *)&cmd_config_e_tag_e_tag,
12758 		(void *)&cmd_config_e_tag_set,
12759 		(void *)&cmd_config_e_tag_filter,
12760 		(void *)&cmd_config_e_tag_add,
12761 		(void *)&cmd_config_e_tag_e_tag_id,
12762 		(void *)&cmd_config_e_tag_e_tag_id_val,
12763 		(void *)&cmd_config_e_tag_dst_pool,
12764 		(void *)&cmd_config_e_tag_dst_pool_val,
12765 		(void *)&cmd_config_e_tag_port,
12766 		(void *)&cmd_config_e_tag_port_id,
12767 		NULL,
12768 	},
12769 };
12770 
12771 static void
12772 cmd_config_e_tag_filter_del_parsed(
12773 	void *parsed_result,
12774 	__attribute__((unused)) struct cmdline *cl,
12775 	__attribute__((unused)) void *data)
12776 {
12777 	struct cmd_config_e_tag_result *res = parsed_result;
12778 	struct rte_eth_l2_tunnel_conf entry;
12779 	int ret = 0;
12780 
12781 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12782 		return;
12783 
12784 	if (res->e_tag_id_val > 0x3fff) {
12785 		printf("e-tag-id must be less than 0x3fff.\n");
12786 		return;
12787 	}
12788 
12789 	ret = rte_eth_dev_filter_supported(res->port_id,
12790 					   RTE_ETH_FILTER_L2_TUNNEL);
12791 	if (ret < 0) {
12792 		printf("E-tag filter is not supported on port %u.\n",
12793 		       res->port_id);
12794 		return;
12795 	}
12796 
12797 	entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12798 	entry.tunnel_id = res->e_tag_id_val;
12799 
12800 	ret = rte_eth_dev_filter_ctrl(res->port_id,
12801 				      RTE_ETH_FILTER_L2_TUNNEL,
12802 				      RTE_ETH_FILTER_DELETE,
12803 				      &entry);
12804 	if (ret < 0)
12805 		printf("E-tag filter programming error: (%s)\n",
12806 		       strerror(-ret));
12807 }
12808 
12809 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
12810 	.f = cmd_config_e_tag_filter_del_parsed,
12811 	.data = NULL,
12812 	.help_str = "E-tag ... : E-tag filter delete",
12813 	.tokens = {
12814 		(void *)&cmd_config_e_tag_e_tag,
12815 		(void *)&cmd_config_e_tag_set,
12816 		(void *)&cmd_config_e_tag_filter,
12817 		(void *)&cmd_config_e_tag_del,
12818 		(void *)&cmd_config_e_tag_e_tag_id,
12819 		(void *)&cmd_config_e_tag_e_tag_id_val,
12820 		(void *)&cmd_config_e_tag_port,
12821 		(void *)&cmd_config_e_tag_port_id,
12822 		NULL,
12823 	},
12824 };
12825 
12826 /* vf vlan anti spoof configuration */
12827 
12828 /* Common result structure for vf vlan anti spoof */
12829 struct cmd_vf_vlan_anti_spoof_result {
12830 	cmdline_fixed_string_t set;
12831 	cmdline_fixed_string_t vf;
12832 	cmdline_fixed_string_t vlan;
12833 	cmdline_fixed_string_t antispoof;
12834 	portid_t port_id;
12835 	uint32_t vf_id;
12836 	cmdline_fixed_string_t on_off;
12837 };
12838 
12839 /* Common CLI fields for vf vlan anti spoof enable disable */
12840 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
12841 	TOKEN_STRING_INITIALIZER
12842 		(struct cmd_vf_vlan_anti_spoof_result,
12843 		 set, "set");
12844 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
12845 	TOKEN_STRING_INITIALIZER
12846 		(struct cmd_vf_vlan_anti_spoof_result,
12847 		 vf, "vf");
12848 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
12849 	TOKEN_STRING_INITIALIZER
12850 		(struct cmd_vf_vlan_anti_spoof_result,
12851 		 vlan, "vlan");
12852 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
12853 	TOKEN_STRING_INITIALIZER
12854 		(struct cmd_vf_vlan_anti_spoof_result,
12855 		 antispoof, "antispoof");
12856 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
12857 	TOKEN_NUM_INITIALIZER
12858 		(struct cmd_vf_vlan_anti_spoof_result,
12859 		 port_id, UINT16);
12860 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
12861 	TOKEN_NUM_INITIALIZER
12862 		(struct cmd_vf_vlan_anti_spoof_result,
12863 		 vf_id, UINT32);
12864 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
12865 	TOKEN_STRING_INITIALIZER
12866 		(struct cmd_vf_vlan_anti_spoof_result,
12867 		 on_off, "on#off");
12868 
12869 static void
12870 cmd_set_vf_vlan_anti_spoof_parsed(
12871 	void *parsed_result,
12872 	__attribute__((unused)) struct cmdline *cl,
12873 	__attribute__((unused)) void *data)
12874 {
12875 	struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
12876 	int ret = -ENOTSUP;
12877 
12878 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12879 
12880 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12881 		return;
12882 
12883 #ifdef RTE_LIBRTE_IXGBE_PMD
12884 	if (ret == -ENOTSUP)
12885 		ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
12886 				res->vf_id, is_on);
12887 #endif
12888 #ifdef RTE_LIBRTE_I40E_PMD
12889 	if (ret == -ENOTSUP)
12890 		ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
12891 				res->vf_id, is_on);
12892 #endif
12893 #ifdef RTE_LIBRTE_BNXT_PMD
12894 	if (ret == -ENOTSUP)
12895 		ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
12896 				res->vf_id, is_on);
12897 #endif
12898 
12899 	switch (ret) {
12900 	case 0:
12901 		break;
12902 	case -EINVAL:
12903 		printf("invalid vf_id %d\n", res->vf_id);
12904 		break;
12905 	case -ENODEV:
12906 		printf("invalid port_id %d\n", res->port_id);
12907 		break;
12908 	case -ENOTSUP:
12909 		printf("function not implemented\n");
12910 		break;
12911 	default:
12912 		printf("programming error: (%s)\n", strerror(-ret));
12913 	}
12914 }
12915 
12916 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
12917 	.f = cmd_set_vf_vlan_anti_spoof_parsed,
12918 	.data = NULL,
12919 	.help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
12920 	.tokens = {
12921 		(void *)&cmd_vf_vlan_anti_spoof_set,
12922 		(void *)&cmd_vf_vlan_anti_spoof_vf,
12923 		(void *)&cmd_vf_vlan_anti_spoof_vlan,
12924 		(void *)&cmd_vf_vlan_anti_spoof_antispoof,
12925 		(void *)&cmd_vf_vlan_anti_spoof_port_id,
12926 		(void *)&cmd_vf_vlan_anti_spoof_vf_id,
12927 		(void *)&cmd_vf_vlan_anti_spoof_on_off,
12928 		NULL,
12929 	},
12930 };
12931 
12932 /* vf mac anti spoof configuration */
12933 
12934 /* Common result structure for vf mac anti spoof */
12935 struct cmd_vf_mac_anti_spoof_result {
12936 	cmdline_fixed_string_t set;
12937 	cmdline_fixed_string_t vf;
12938 	cmdline_fixed_string_t mac;
12939 	cmdline_fixed_string_t antispoof;
12940 	portid_t port_id;
12941 	uint32_t vf_id;
12942 	cmdline_fixed_string_t on_off;
12943 };
12944 
12945 /* Common CLI fields for vf mac anti spoof enable disable */
12946 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
12947 	TOKEN_STRING_INITIALIZER
12948 		(struct cmd_vf_mac_anti_spoof_result,
12949 		 set, "set");
12950 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
12951 	TOKEN_STRING_INITIALIZER
12952 		(struct cmd_vf_mac_anti_spoof_result,
12953 		 vf, "vf");
12954 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
12955 	TOKEN_STRING_INITIALIZER
12956 		(struct cmd_vf_mac_anti_spoof_result,
12957 		 mac, "mac");
12958 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
12959 	TOKEN_STRING_INITIALIZER
12960 		(struct cmd_vf_mac_anti_spoof_result,
12961 		 antispoof, "antispoof");
12962 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
12963 	TOKEN_NUM_INITIALIZER
12964 		(struct cmd_vf_mac_anti_spoof_result,
12965 		 port_id, UINT16);
12966 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
12967 	TOKEN_NUM_INITIALIZER
12968 		(struct cmd_vf_mac_anti_spoof_result,
12969 		 vf_id, UINT32);
12970 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
12971 	TOKEN_STRING_INITIALIZER
12972 		(struct cmd_vf_mac_anti_spoof_result,
12973 		 on_off, "on#off");
12974 
12975 static void
12976 cmd_set_vf_mac_anti_spoof_parsed(
12977 	void *parsed_result,
12978 	__attribute__((unused)) struct cmdline *cl,
12979 	__attribute__((unused)) void *data)
12980 {
12981 	struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
12982 	int ret = -ENOTSUP;
12983 
12984 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12985 
12986 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12987 		return;
12988 
12989 #ifdef RTE_LIBRTE_IXGBE_PMD
12990 	if (ret == -ENOTSUP)
12991 		ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
12992 			res->vf_id, is_on);
12993 #endif
12994 #ifdef RTE_LIBRTE_I40E_PMD
12995 	if (ret == -ENOTSUP)
12996 		ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
12997 			res->vf_id, is_on);
12998 #endif
12999 #ifdef RTE_LIBRTE_BNXT_PMD
13000 	if (ret == -ENOTSUP)
13001 		ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
13002 			res->vf_id, is_on);
13003 #endif
13004 
13005 	switch (ret) {
13006 	case 0:
13007 		break;
13008 	case -EINVAL:
13009 		printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13010 		break;
13011 	case -ENODEV:
13012 		printf("invalid port_id %d\n", res->port_id);
13013 		break;
13014 	case -ENOTSUP:
13015 		printf("function not implemented\n");
13016 		break;
13017 	default:
13018 		printf("programming error: (%s)\n", strerror(-ret));
13019 	}
13020 }
13021 
13022 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
13023 	.f = cmd_set_vf_mac_anti_spoof_parsed,
13024 	.data = NULL,
13025 	.help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
13026 	.tokens = {
13027 		(void *)&cmd_vf_mac_anti_spoof_set,
13028 		(void *)&cmd_vf_mac_anti_spoof_vf,
13029 		(void *)&cmd_vf_mac_anti_spoof_mac,
13030 		(void *)&cmd_vf_mac_anti_spoof_antispoof,
13031 		(void *)&cmd_vf_mac_anti_spoof_port_id,
13032 		(void *)&cmd_vf_mac_anti_spoof_vf_id,
13033 		(void *)&cmd_vf_mac_anti_spoof_on_off,
13034 		NULL,
13035 	},
13036 };
13037 
13038 /* vf vlan strip queue configuration */
13039 
13040 /* Common result structure for vf mac anti spoof */
13041 struct cmd_vf_vlan_stripq_result {
13042 	cmdline_fixed_string_t set;
13043 	cmdline_fixed_string_t vf;
13044 	cmdline_fixed_string_t vlan;
13045 	cmdline_fixed_string_t stripq;
13046 	portid_t port_id;
13047 	uint16_t vf_id;
13048 	cmdline_fixed_string_t on_off;
13049 };
13050 
13051 /* Common CLI fields for vf vlan strip enable disable */
13052 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
13053 	TOKEN_STRING_INITIALIZER
13054 		(struct cmd_vf_vlan_stripq_result,
13055 		 set, "set");
13056 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
13057 	TOKEN_STRING_INITIALIZER
13058 		(struct cmd_vf_vlan_stripq_result,
13059 		 vf, "vf");
13060 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
13061 	TOKEN_STRING_INITIALIZER
13062 		(struct cmd_vf_vlan_stripq_result,
13063 		 vlan, "vlan");
13064 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
13065 	TOKEN_STRING_INITIALIZER
13066 		(struct cmd_vf_vlan_stripq_result,
13067 		 stripq, "stripq");
13068 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
13069 	TOKEN_NUM_INITIALIZER
13070 		(struct cmd_vf_vlan_stripq_result,
13071 		 port_id, UINT16);
13072 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
13073 	TOKEN_NUM_INITIALIZER
13074 		(struct cmd_vf_vlan_stripq_result,
13075 		 vf_id, UINT16);
13076 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
13077 	TOKEN_STRING_INITIALIZER
13078 		(struct cmd_vf_vlan_stripq_result,
13079 		 on_off, "on#off");
13080 
13081 static void
13082 cmd_set_vf_vlan_stripq_parsed(
13083 	void *parsed_result,
13084 	__attribute__((unused)) struct cmdline *cl,
13085 	__attribute__((unused)) void *data)
13086 {
13087 	struct cmd_vf_vlan_stripq_result *res = parsed_result;
13088 	int ret = -ENOTSUP;
13089 
13090 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13091 
13092 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13093 		return;
13094 
13095 #ifdef RTE_LIBRTE_IXGBE_PMD
13096 	if (ret == -ENOTSUP)
13097 		ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
13098 			res->vf_id, is_on);
13099 #endif
13100 #ifdef RTE_LIBRTE_I40E_PMD
13101 	if (ret == -ENOTSUP)
13102 		ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
13103 			res->vf_id, is_on);
13104 #endif
13105 #ifdef RTE_LIBRTE_BNXT_PMD
13106 	if (ret == -ENOTSUP)
13107 		ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
13108 			res->vf_id, is_on);
13109 #endif
13110 
13111 	switch (ret) {
13112 	case 0:
13113 		break;
13114 	case -EINVAL:
13115 		printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13116 		break;
13117 	case -ENODEV:
13118 		printf("invalid port_id %d\n", res->port_id);
13119 		break;
13120 	case -ENOTSUP:
13121 		printf("function not implemented\n");
13122 		break;
13123 	default:
13124 		printf("programming error: (%s)\n", strerror(-ret));
13125 	}
13126 }
13127 
13128 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
13129 	.f = cmd_set_vf_vlan_stripq_parsed,
13130 	.data = NULL,
13131 	.help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
13132 	.tokens = {
13133 		(void *)&cmd_vf_vlan_stripq_set,
13134 		(void *)&cmd_vf_vlan_stripq_vf,
13135 		(void *)&cmd_vf_vlan_stripq_vlan,
13136 		(void *)&cmd_vf_vlan_stripq_stripq,
13137 		(void *)&cmd_vf_vlan_stripq_port_id,
13138 		(void *)&cmd_vf_vlan_stripq_vf_id,
13139 		(void *)&cmd_vf_vlan_stripq_on_off,
13140 		NULL,
13141 	},
13142 };
13143 
13144 /* vf vlan insert configuration */
13145 
13146 /* Common result structure for vf vlan insert */
13147 struct cmd_vf_vlan_insert_result {
13148 	cmdline_fixed_string_t set;
13149 	cmdline_fixed_string_t vf;
13150 	cmdline_fixed_string_t vlan;
13151 	cmdline_fixed_string_t insert;
13152 	portid_t port_id;
13153 	uint16_t vf_id;
13154 	uint16_t vlan_id;
13155 };
13156 
13157 /* Common CLI fields for vf vlan insert enable disable */
13158 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
13159 	TOKEN_STRING_INITIALIZER
13160 		(struct cmd_vf_vlan_insert_result,
13161 		 set, "set");
13162 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
13163 	TOKEN_STRING_INITIALIZER
13164 		(struct cmd_vf_vlan_insert_result,
13165 		 vf, "vf");
13166 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
13167 	TOKEN_STRING_INITIALIZER
13168 		(struct cmd_vf_vlan_insert_result,
13169 		 vlan, "vlan");
13170 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
13171 	TOKEN_STRING_INITIALIZER
13172 		(struct cmd_vf_vlan_insert_result,
13173 		 insert, "insert");
13174 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
13175 	TOKEN_NUM_INITIALIZER
13176 		(struct cmd_vf_vlan_insert_result,
13177 		 port_id, UINT16);
13178 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
13179 	TOKEN_NUM_INITIALIZER
13180 		(struct cmd_vf_vlan_insert_result,
13181 		 vf_id, UINT16);
13182 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
13183 	TOKEN_NUM_INITIALIZER
13184 		(struct cmd_vf_vlan_insert_result,
13185 		 vlan_id, UINT16);
13186 
13187 static void
13188 cmd_set_vf_vlan_insert_parsed(
13189 	void *parsed_result,
13190 	__attribute__((unused)) struct cmdline *cl,
13191 	__attribute__((unused)) void *data)
13192 {
13193 	struct cmd_vf_vlan_insert_result *res = parsed_result;
13194 	int ret = -ENOTSUP;
13195 
13196 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13197 		return;
13198 
13199 #ifdef RTE_LIBRTE_IXGBE_PMD
13200 	if (ret == -ENOTSUP)
13201 		ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
13202 			res->vlan_id);
13203 #endif
13204 #ifdef RTE_LIBRTE_I40E_PMD
13205 	if (ret == -ENOTSUP)
13206 		ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
13207 			res->vlan_id);
13208 #endif
13209 #ifdef RTE_LIBRTE_BNXT_PMD
13210 	if (ret == -ENOTSUP)
13211 		ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
13212 			res->vlan_id);
13213 #endif
13214 
13215 	switch (ret) {
13216 	case 0:
13217 		break;
13218 	case -EINVAL:
13219 		printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
13220 		break;
13221 	case -ENODEV:
13222 		printf("invalid port_id %d\n", res->port_id);
13223 		break;
13224 	case -ENOTSUP:
13225 		printf("function not implemented\n");
13226 		break;
13227 	default:
13228 		printf("programming error: (%s)\n", strerror(-ret));
13229 	}
13230 }
13231 
13232 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
13233 	.f = cmd_set_vf_vlan_insert_parsed,
13234 	.data = NULL,
13235 	.help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
13236 	.tokens = {
13237 		(void *)&cmd_vf_vlan_insert_set,
13238 		(void *)&cmd_vf_vlan_insert_vf,
13239 		(void *)&cmd_vf_vlan_insert_vlan,
13240 		(void *)&cmd_vf_vlan_insert_insert,
13241 		(void *)&cmd_vf_vlan_insert_port_id,
13242 		(void *)&cmd_vf_vlan_insert_vf_id,
13243 		(void *)&cmd_vf_vlan_insert_vlan_id,
13244 		NULL,
13245 	},
13246 };
13247 
13248 /* tx loopback configuration */
13249 
13250 /* Common result structure for tx loopback */
13251 struct cmd_tx_loopback_result {
13252 	cmdline_fixed_string_t set;
13253 	cmdline_fixed_string_t tx;
13254 	cmdline_fixed_string_t loopback;
13255 	portid_t port_id;
13256 	cmdline_fixed_string_t on_off;
13257 };
13258 
13259 /* Common CLI fields for tx loopback enable disable */
13260 cmdline_parse_token_string_t cmd_tx_loopback_set =
13261 	TOKEN_STRING_INITIALIZER
13262 		(struct cmd_tx_loopback_result,
13263 		 set, "set");
13264 cmdline_parse_token_string_t cmd_tx_loopback_tx =
13265 	TOKEN_STRING_INITIALIZER
13266 		(struct cmd_tx_loopback_result,
13267 		 tx, "tx");
13268 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
13269 	TOKEN_STRING_INITIALIZER
13270 		(struct cmd_tx_loopback_result,
13271 		 loopback, "loopback");
13272 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
13273 	TOKEN_NUM_INITIALIZER
13274 		(struct cmd_tx_loopback_result,
13275 		 port_id, UINT16);
13276 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
13277 	TOKEN_STRING_INITIALIZER
13278 		(struct cmd_tx_loopback_result,
13279 		 on_off, "on#off");
13280 
13281 static void
13282 cmd_set_tx_loopback_parsed(
13283 	void *parsed_result,
13284 	__attribute__((unused)) struct cmdline *cl,
13285 	__attribute__((unused)) void *data)
13286 {
13287 	struct cmd_tx_loopback_result *res = parsed_result;
13288 	int ret = -ENOTSUP;
13289 
13290 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13291 
13292 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13293 		return;
13294 
13295 #ifdef RTE_LIBRTE_IXGBE_PMD
13296 	if (ret == -ENOTSUP)
13297 		ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
13298 #endif
13299 #ifdef RTE_LIBRTE_I40E_PMD
13300 	if (ret == -ENOTSUP)
13301 		ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
13302 #endif
13303 #ifdef RTE_LIBRTE_BNXT_PMD
13304 	if (ret == -ENOTSUP)
13305 		ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
13306 #endif
13307 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD
13308 	if (ret == -ENOTSUP)
13309 		ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
13310 #endif
13311 
13312 	switch (ret) {
13313 	case 0:
13314 		break;
13315 	case -EINVAL:
13316 		printf("invalid is_on %d\n", is_on);
13317 		break;
13318 	case -ENODEV:
13319 		printf("invalid port_id %d\n", res->port_id);
13320 		break;
13321 	case -ENOTSUP:
13322 		printf("function not implemented\n");
13323 		break;
13324 	default:
13325 		printf("programming error: (%s)\n", strerror(-ret));
13326 	}
13327 }
13328 
13329 cmdline_parse_inst_t cmd_set_tx_loopback = {
13330 	.f = cmd_set_tx_loopback_parsed,
13331 	.data = NULL,
13332 	.help_str = "set tx loopback <port_id> on|off",
13333 	.tokens = {
13334 		(void *)&cmd_tx_loopback_set,
13335 		(void *)&cmd_tx_loopback_tx,
13336 		(void *)&cmd_tx_loopback_loopback,
13337 		(void *)&cmd_tx_loopback_port_id,
13338 		(void *)&cmd_tx_loopback_on_off,
13339 		NULL,
13340 	},
13341 };
13342 
13343 /* all queues drop enable configuration */
13344 
13345 /* Common result structure for all queues drop enable */
13346 struct cmd_all_queues_drop_en_result {
13347 	cmdline_fixed_string_t set;
13348 	cmdline_fixed_string_t all;
13349 	cmdline_fixed_string_t queues;
13350 	cmdline_fixed_string_t drop;
13351 	portid_t port_id;
13352 	cmdline_fixed_string_t on_off;
13353 };
13354 
13355 /* Common CLI fields for tx loopback enable disable */
13356 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
13357 	TOKEN_STRING_INITIALIZER
13358 		(struct cmd_all_queues_drop_en_result,
13359 		 set, "set");
13360 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
13361 	TOKEN_STRING_INITIALIZER
13362 		(struct cmd_all_queues_drop_en_result,
13363 		 all, "all");
13364 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
13365 	TOKEN_STRING_INITIALIZER
13366 		(struct cmd_all_queues_drop_en_result,
13367 		 queues, "queues");
13368 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
13369 	TOKEN_STRING_INITIALIZER
13370 		(struct cmd_all_queues_drop_en_result,
13371 		 drop, "drop");
13372 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
13373 	TOKEN_NUM_INITIALIZER
13374 		(struct cmd_all_queues_drop_en_result,
13375 		 port_id, UINT16);
13376 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
13377 	TOKEN_STRING_INITIALIZER
13378 		(struct cmd_all_queues_drop_en_result,
13379 		 on_off, "on#off");
13380 
13381 static void
13382 cmd_set_all_queues_drop_en_parsed(
13383 	void *parsed_result,
13384 	__attribute__((unused)) struct cmdline *cl,
13385 	__attribute__((unused)) void *data)
13386 {
13387 	struct cmd_all_queues_drop_en_result *res = parsed_result;
13388 	int ret = -ENOTSUP;
13389 	int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13390 
13391 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13392 		return;
13393 
13394 #ifdef RTE_LIBRTE_IXGBE_PMD
13395 	if (ret == -ENOTSUP)
13396 		ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
13397 #endif
13398 #ifdef RTE_LIBRTE_BNXT_PMD
13399 	if (ret == -ENOTSUP)
13400 		ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
13401 #endif
13402 	switch (ret) {
13403 	case 0:
13404 		break;
13405 	case -EINVAL:
13406 		printf("invalid is_on %d\n", is_on);
13407 		break;
13408 	case -ENODEV:
13409 		printf("invalid port_id %d\n", res->port_id);
13410 		break;
13411 	case -ENOTSUP:
13412 		printf("function not implemented\n");
13413 		break;
13414 	default:
13415 		printf("programming error: (%s)\n", strerror(-ret));
13416 	}
13417 }
13418 
13419 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
13420 	.f = cmd_set_all_queues_drop_en_parsed,
13421 	.data = NULL,
13422 	.help_str = "set all queues drop <port_id> on|off",
13423 	.tokens = {
13424 		(void *)&cmd_all_queues_drop_en_set,
13425 		(void *)&cmd_all_queues_drop_en_all,
13426 		(void *)&cmd_all_queues_drop_en_queues,
13427 		(void *)&cmd_all_queues_drop_en_drop,
13428 		(void *)&cmd_all_queues_drop_en_port_id,
13429 		(void *)&cmd_all_queues_drop_en_on_off,
13430 		NULL,
13431 	},
13432 };
13433 
13434 /* vf split drop enable configuration */
13435 
13436 /* Common result structure for vf split drop enable */
13437 struct cmd_vf_split_drop_en_result {
13438 	cmdline_fixed_string_t set;
13439 	cmdline_fixed_string_t vf;
13440 	cmdline_fixed_string_t split;
13441 	cmdline_fixed_string_t drop;
13442 	portid_t port_id;
13443 	uint16_t vf_id;
13444 	cmdline_fixed_string_t on_off;
13445 };
13446 
13447 /* Common CLI fields for vf split drop enable disable */
13448 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
13449 	TOKEN_STRING_INITIALIZER
13450 		(struct cmd_vf_split_drop_en_result,
13451 		 set, "set");
13452 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
13453 	TOKEN_STRING_INITIALIZER
13454 		(struct cmd_vf_split_drop_en_result,
13455 		 vf, "vf");
13456 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
13457 	TOKEN_STRING_INITIALIZER
13458 		(struct cmd_vf_split_drop_en_result,
13459 		 split, "split");
13460 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
13461 	TOKEN_STRING_INITIALIZER
13462 		(struct cmd_vf_split_drop_en_result,
13463 		 drop, "drop");
13464 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
13465 	TOKEN_NUM_INITIALIZER
13466 		(struct cmd_vf_split_drop_en_result,
13467 		 port_id, UINT16);
13468 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
13469 	TOKEN_NUM_INITIALIZER
13470 		(struct cmd_vf_split_drop_en_result,
13471 		 vf_id, UINT16);
13472 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
13473 	TOKEN_STRING_INITIALIZER
13474 		(struct cmd_vf_split_drop_en_result,
13475 		 on_off, "on#off");
13476 
13477 static void
13478 cmd_set_vf_split_drop_en_parsed(
13479 	void *parsed_result,
13480 	__attribute__((unused)) struct cmdline *cl,
13481 	__attribute__((unused)) void *data)
13482 {
13483 	struct cmd_vf_split_drop_en_result *res = parsed_result;
13484 	int ret = -ENOTSUP;
13485 	int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13486 
13487 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13488 		return;
13489 
13490 #ifdef RTE_LIBRTE_IXGBE_PMD
13491 	ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
13492 			is_on);
13493 #endif
13494 	switch (ret) {
13495 	case 0:
13496 		break;
13497 	case -EINVAL:
13498 		printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13499 		break;
13500 	case -ENODEV:
13501 		printf("invalid port_id %d\n", res->port_id);
13502 		break;
13503 	case -ENOTSUP:
13504 		printf("not supported on port %d\n", res->port_id);
13505 		break;
13506 	default:
13507 		printf("programming error: (%s)\n", strerror(-ret));
13508 	}
13509 }
13510 
13511 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
13512 	.f = cmd_set_vf_split_drop_en_parsed,
13513 	.data = NULL,
13514 	.help_str = "set vf split drop <port_id> <vf_id> on|off",
13515 	.tokens = {
13516 		(void *)&cmd_vf_split_drop_en_set,
13517 		(void *)&cmd_vf_split_drop_en_vf,
13518 		(void *)&cmd_vf_split_drop_en_split,
13519 		(void *)&cmd_vf_split_drop_en_drop,
13520 		(void *)&cmd_vf_split_drop_en_port_id,
13521 		(void *)&cmd_vf_split_drop_en_vf_id,
13522 		(void *)&cmd_vf_split_drop_en_on_off,
13523 		NULL,
13524 	},
13525 };
13526 
13527 /* vf mac address configuration */
13528 
13529 /* Common result structure for vf mac address */
13530 struct cmd_set_vf_mac_addr_result {
13531 	cmdline_fixed_string_t set;
13532 	cmdline_fixed_string_t vf;
13533 	cmdline_fixed_string_t mac;
13534 	cmdline_fixed_string_t addr;
13535 	portid_t port_id;
13536 	uint16_t vf_id;
13537 	struct ether_addr mac_addr;
13538 
13539 };
13540 
13541 /* Common CLI fields for vf split drop enable disable */
13542 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
13543 	TOKEN_STRING_INITIALIZER
13544 		(struct cmd_set_vf_mac_addr_result,
13545 		 set, "set");
13546 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
13547 	TOKEN_STRING_INITIALIZER
13548 		(struct cmd_set_vf_mac_addr_result,
13549 		 vf, "vf");
13550 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
13551 	TOKEN_STRING_INITIALIZER
13552 		(struct cmd_set_vf_mac_addr_result,
13553 		 mac, "mac");
13554 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
13555 	TOKEN_STRING_INITIALIZER
13556 		(struct cmd_set_vf_mac_addr_result,
13557 		 addr, "addr");
13558 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
13559 	TOKEN_NUM_INITIALIZER
13560 		(struct cmd_set_vf_mac_addr_result,
13561 		 port_id, UINT16);
13562 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
13563 	TOKEN_NUM_INITIALIZER
13564 		(struct cmd_set_vf_mac_addr_result,
13565 		 vf_id, UINT16);
13566 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
13567 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
13568 		 mac_addr);
13569 
13570 static void
13571 cmd_set_vf_mac_addr_parsed(
13572 	void *parsed_result,
13573 	__attribute__((unused)) struct cmdline *cl,
13574 	__attribute__((unused)) void *data)
13575 {
13576 	struct cmd_set_vf_mac_addr_result *res = parsed_result;
13577 	int ret = -ENOTSUP;
13578 
13579 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13580 		return;
13581 
13582 #ifdef RTE_LIBRTE_IXGBE_PMD
13583 	if (ret == -ENOTSUP)
13584 		ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
13585 				&res->mac_addr);
13586 #endif
13587 #ifdef RTE_LIBRTE_I40E_PMD
13588 	if (ret == -ENOTSUP)
13589 		ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
13590 				&res->mac_addr);
13591 #endif
13592 #ifdef RTE_LIBRTE_BNXT_PMD
13593 	if (ret == -ENOTSUP)
13594 		ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
13595 				&res->mac_addr);
13596 #endif
13597 
13598 	switch (ret) {
13599 	case 0:
13600 		break;
13601 	case -EINVAL:
13602 		printf("invalid vf_id %d or mac_addr\n", res->vf_id);
13603 		break;
13604 	case -ENODEV:
13605 		printf("invalid port_id %d\n", res->port_id);
13606 		break;
13607 	case -ENOTSUP:
13608 		printf("function not implemented\n");
13609 		break;
13610 	default:
13611 		printf("programming error: (%s)\n", strerror(-ret));
13612 	}
13613 }
13614 
13615 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
13616 	.f = cmd_set_vf_mac_addr_parsed,
13617 	.data = NULL,
13618 	.help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
13619 	.tokens = {
13620 		(void *)&cmd_set_vf_mac_addr_set,
13621 		(void *)&cmd_set_vf_mac_addr_vf,
13622 		(void *)&cmd_set_vf_mac_addr_mac,
13623 		(void *)&cmd_set_vf_mac_addr_addr,
13624 		(void *)&cmd_set_vf_mac_addr_port_id,
13625 		(void *)&cmd_set_vf_mac_addr_vf_id,
13626 		(void *)&cmd_set_vf_mac_addr_mac_addr,
13627 		NULL,
13628 	},
13629 };
13630 
13631 /* MACsec configuration */
13632 
13633 /* Common result structure for MACsec offload enable */
13634 struct cmd_macsec_offload_on_result {
13635 	cmdline_fixed_string_t set;
13636 	cmdline_fixed_string_t macsec;
13637 	cmdline_fixed_string_t offload;
13638 	portid_t port_id;
13639 	cmdline_fixed_string_t on;
13640 	cmdline_fixed_string_t encrypt;
13641 	cmdline_fixed_string_t en_on_off;
13642 	cmdline_fixed_string_t replay_protect;
13643 	cmdline_fixed_string_t rp_on_off;
13644 };
13645 
13646 /* Common CLI fields for MACsec offload disable */
13647 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
13648 	TOKEN_STRING_INITIALIZER
13649 		(struct cmd_macsec_offload_on_result,
13650 		 set, "set");
13651 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
13652 	TOKEN_STRING_INITIALIZER
13653 		(struct cmd_macsec_offload_on_result,
13654 		 macsec, "macsec");
13655 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
13656 	TOKEN_STRING_INITIALIZER
13657 		(struct cmd_macsec_offload_on_result,
13658 		 offload, "offload");
13659 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
13660 	TOKEN_NUM_INITIALIZER
13661 		(struct cmd_macsec_offload_on_result,
13662 		 port_id, UINT16);
13663 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
13664 	TOKEN_STRING_INITIALIZER
13665 		(struct cmd_macsec_offload_on_result,
13666 		 on, "on");
13667 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
13668 	TOKEN_STRING_INITIALIZER
13669 		(struct cmd_macsec_offload_on_result,
13670 		 encrypt, "encrypt");
13671 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
13672 	TOKEN_STRING_INITIALIZER
13673 		(struct cmd_macsec_offload_on_result,
13674 		 en_on_off, "on#off");
13675 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
13676 	TOKEN_STRING_INITIALIZER
13677 		(struct cmd_macsec_offload_on_result,
13678 		 replay_protect, "replay-protect");
13679 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
13680 	TOKEN_STRING_INITIALIZER
13681 		(struct cmd_macsec_offload_on_result,
13682 		 rp_on_off, "on#off");
13683 
13684 static void
13685 cmd_set_macsec_offload_on_parsed(
13686 	void *parsed_result,
13687 	__attribute__((unused)) struct cmdline *cl,
13688 	__attribute__((unused)) void *data)
13689 {
13690 	struct cmd_macsec_offload_on_result *res = parsed_result;
13691 	int ret = -ENOTSUP;
13692 	portid_t port_id = res->port_id;
13693 	int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
13694 	int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
13695 	struct rte_eth_dev_info dev_info;
13696 
13697 	if (port_id_is_invalid(port_id, ENABLED_WARN))
13698 		return;
13699 	if (!port_is_stopped(port_id)) {
13700 		printf("Please stop port %d first\n", port_id);
13701 		return;
13702 	}
13703 
13704 	rte_eth_dev_info_get(port_id, &dev_info);
13705 	if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
13706 #ifdef RTE_LIBRTE_IXGBE_PMD
13707 		ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
13708 #endif
13709 	}
13710 	RTE_SET_USED(en);
13711 	RTE_SET_USED(rp);
13712 
13713 	switch (ret) {
13714 	case 0:
13715 		ports[port_id].dev_conf.txmode.offloads |=
13716 						DEV_TX_OFFLOAD_MACSEC_INSERT;
13717 		cmd_reconfig_device_queue(port_id, 1, 1);
13718 		break;
13719 	case -ENODEV:
13720 		printf("invalid port_id %d\n", port_id);
13721 		break;
13722 	case -ENOTSUP:
13723 		printf("not supported on port %d\n", port_id);
13724 		break;
13725 	default:
13726 		printf("programming error: (%s)\n", strerror(-ret));
13727 	}
13728 }
13729 
13730 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
13731 	.f = cmd_set_macsec_offload_on_parsed,
13732 	.data = NULL,
13733 	.help_str = "set macsec offload <port_id> on "
13734 		"encrypt on|off replay-protect on|off",
13735 	.tokens = {
13736 		(void *)&cmd_macsec_offload_on_set,
13737 		(void *)&cmd_macsec_offload_on_macsec,
13738 		(void *)&cmd_macsec_offload_on_offload,
13739 		(void *)&cmd_macsec_offload_on_port_id,
13740 		(void *)&cmd_macsec_offload_on_on,
13741 		(void *)&cmd_macsec_offload_on_encrypt,
13742 		(void *)&cmd_macsec_offload_on_en_on_off,
13743 		(void *)&cmd_macsec_offload_on_replay_protect,
13744 		(void *)&cmd_macsec_offload_on_rp_on_off,
13745 		NULL,
13746 	},
13747 };
13748 
13749 /* Common result structure for MACsec offload disable */
13750 struct cmd_macsec_offload_off_result {
13751 	cmdline_fixed_string_t set;
13752 	cmdline_fixed_string_t macsec;
13753 	cmdline_fixed_string_t offload;
13754 	portid_t port_id;
13755 	cmdline_fixed_string_t off;
13756 };
13757 
13758 /* Common CLI fields for MACsec offload disable */
13759 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
13760 	TOKEN_STRING_INITIALIZER
13761 		(struct cmd_macsec_offload_off_result,
13762 		 set, "set");
13763 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
13764 	TOKEN_STRING_INITIALIZER
13765 		(struct cmd_macsec_offload_off_result,
13766 		 macsec, "macsec");
13767 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
13768 	TOKEN_STRING_INITIALIZER
13769 		(struct cmd_macsec_offload_off_result,
13770 		 offload, "offload");
13771 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
13772 	TOKEN_NUM_INITIALIZER
13773 		(struct cmd_macsec_offload_off_result,
13774 		 port_id, UINT16);
13775 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
13776 	TOKEN_STRING_INITIALIZER
13777 		(struct cmd_macsec_offload_off_result,
13778 		 off, "off");
13779 
13780 static void
13781 cmd_set_macsec_offload_off_parsed(
13782 	void *parsed_result,
13783 	__attribute__((unused)) struct cmdline *cl,
13784 	__attribute__((unused)) void *data)
13785 {
13786 	struct cmd_macsec_offload_off_result *res = parsed_result;
13787 	int ret = -ENOTSUP;
13788 	struct rte_eth_dev_info dev_info;
13789 	portid_t port_id = res->port_id;
13790 
13791 	if (port_id_is_invalid(port_id, ENABLED_WARN))
13792 		return;
13793 	if (!port_is_stopped(port_id)) {
13794 		printf("Please stop port %d first\n", port_id);
13795 		return;
13796 	}
13797 
13798 	rte_eth_dev_info_get(port_id, &dev_info);
13799 	if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
13800 #ifdef RTE_LIBRTE_IXGBE_PMD
13801 		ret = rte_pmd_ixgbe_macsec_disable(port_id);
13802 #endif
13803 	}
13804 	switch (ret) {
13805 	case 0:
13806 		ports[port_id].dev_conf.txmode.offloads &=
13807 						~DEV_TX_OFFLOAD_MACSEC_INSERT;
13808 		cmd_reconfig_device_queue(port_id, 1, 1);
13809 		break;
13810 	case -ENODEV:
13811 		printf("invalid port_id %d\n", port_id);
13812 		break;
13813 	case -ENOTSUP:
13814 		printf("not supported on port %d\n", port_id);
13815 		break;
13816 	default:
13817 		printf("programming error: (%s)\n", strerror(-ret));
13818 	}
13819 }
13820 
13821 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
13822 	.f = cmd_set_macsec_offload_off_parsed,
13823 	.data = NULL,
13824 	.help_str = "set macsec offload <port_id> off",
13825 	.tokens = {
13826 		(void *)&cmd_macsec_offload_off_set,
13827 		(void *)&cmd_macsec_offload_off_macsec,
13828 		(void *)&cmd_macsec_offload_off_offload,
13829 		(void *)&cmd_macsec_offload_off_port_id,
13830 		(void *)&cmd_macsec_offload_off_off,
13831 		NULL,
13832 	},
13833 };
13834 
13835 /* Common result structure for MACsec secure connection configure */
13836 struct cmd_macsec_sc_result {
13837 	cmdline_fixed_string_t set;
13838 	cmdline_fixed_string_t macsec;
13839 	cmdline_fixed_string_t sc;
13840 	cmdline_fixed_string_t tx_rx;
13841 	portid_t port_id;
13842 	struct ether_addr mac;
13843 	uint16_t pi;
13844 };
13845 
13846 /* Common CLI fields for MACsec secure connection configure */
13847 cmdline_parse_token_string_t cmd_macsec_sc_set =
13848 	TOKEN_STRING_INITIALIZER
13849 		(struct cmd_macsec_sc_result,
13850 		 set, "set");
13851 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
13852 	TOKEN_STRING_INITIALIZER
13853 		(struct cmd_macsec_sc_result,
13854 		 macsec, "macsec");
13855 cmdline_parse_token_string_t cmd_macsec_sc_sc =
13856 	TOKEN_STRING_INITIALIZER
13857 		(struct cmd_macsec_sc_result,
13858 		 sc, "sc");
13859 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
13860 	TOKEN_STRING_INITIALIZER
13861 		(struct cmd_macsec_sc_result,
13862 		 tx_rx, "tx#rx");
13863 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
13864 	TOKEN_NUM_INITIALIZER
13865 		(struct cmd_macsec_sc_result,
13866 		 port_id, UINT16);
13867 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
13868 	TOKEN_ETHERADDR_INITIALIZER
13869 		(struct cmd_macsec_sc_result,
13870 		 mac);
13871 cmdline_parse_token_num_t cmd_macsec_sc_pi =
13872 	TOKEN_NUM_INITIALIZER
13873 		(struct cmd_macsec_sc_result,
13874 		 pi, UINT16);
13875 
13876 static void
13877 cmd_set_macsec_sc_parsed(
13878 	void *parsed_result,
13879 	__attribute__((unused)) struct cmdline *cl,
13880 	__attribute__((unused)) void *data)
13881 {
13882 	struct cmd_macsec_sc_result *res = parsed_result;
13883 	int ret = -ENOTSUP;
13884 	int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
13885 
13886 #ifdef RTE_LIBRTE_IXGBE_PMD
13887 	ret = is_tx ?
13888 		rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
13889 				res->mac.addr_bytes) :
13890 		rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
13891 				res->mac.addr_bytes, res->pi);
13892 #endif
13893 	RTE_SET_USED(is_tx);
13894 
13895 	switch (ret) {
13896 	case 0:
13897 		break;
13898 	case -ENODEV:
13899 		printf("invalid port_id %d\n", res->port_id);
13900 		break;
13901 	case -ENOTSUP:
13902 		printf("not supported on port %d\n", res->port_id);
13903 		break;
13904 	default:
13905 		printf("programming error: (%s)\n", strerror(-ret));
13906 	}
13907 }
13908 
13909 cmdline_parse_inst_t cmd_set_macsec_sc = {
13910 	.f = cmd_set_macsec_sc_parsed,
13911 	.data = NULL,
13912 	.help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
13913 	.tokens = {
13914 		(void *)&cmd_macsec_sc_set,
13915 		(void *)&cmd_macsec_sc_macsec,
13916 		(void *)&cmd_macsec_sc_sc,
13917 		(void *)&cmd_macsec_sc_tx_rx,
13918 		(void *)&cmd_macsec_sc_port_id,
13919 		(void *)&cmd_macsec_sc_mac,
13920 		(void *)&cmd_macsec_sc_pi,
13921 		NULL,
13922 	},
13923 };
13924 
13925 /* Common result structure for MACsec secure connection configure */
13926 struct cmd_macsec_sa_result {
13927 	cmdline_fixed_string_t set;
13928 	cmdline_fixed_string_t macsec;
13929 	cmdline_fixed_string_t sa;
13930 	cmdline_fixed_string_t tx_rx;
13931 	portid_t port_id;
13932 	uint8_t idx;
13933 	uint8_t an;
13934 	uint32_t pn;
13935 	cmdline_fixed_string_t key;
13936 };
13937 
13938 /* Common CLI fields for MACsec secure connection configure */
13939 cmdline_parse_token_string_t cmd_macsec_sa_set =
13940 	TOKEN_STRING_INITIALIZER
13941 		(struct cmd_macsec_sa_result,
13942 		 set, "set");
13943 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
13944 	TOKEN_STRING_INITIALIZER
13945 		(struct cmd_macsec_sa_result,
13946 		 macsec, "macsec");
13947 cmdline_parse_token_string_t cmd_macsec_sa_sa =
13948 	TOKEN_STRING_INITIALIZER
13949 		(struct cmd_macsec_sa_result,
13950 		 sa, "sa");
13951 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
13952 	TOKEN_STRING_INITIALIZER
13953 		(struct cmd_macsec_sa_result,
13954 		 tx_rx, "tx#rx");
13955 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
13956 	TOKEN_NUM_INITIALIZER
13957 		(struct cmd_macsec_sa_result,
13958 		 port_id, UINT16);
13959 cmdline_parse_token_num_t cmd_macsec_sa_idx =
13960 	TOKEN_NUM_INITIALIZER
13961 		(struct cmd_macsec_sa_result,
13962 		 idx, UINT8);
13963 cmdline_parse_token_num_t cmd_macsec_sa_an =
13964 	TOKEN_NUM_INITIALIZER
13965 		(struct cmd_macsec_sa_result,
13966 		 an, UINT8);
13967 cmdline_parse_token_num_t cmd_macsec_sa_pn =
13968 	TOKEN_NUM_INITIALIZER
13969 		(struct cmd_macsec_sa_result,
13970 		 pn, UINT32);
13971 cmdline_parse_token_string_t cmd_macsec_sa_key =
13972 	TOKEN_STRING_INITIALIZER
13973 		(struct cmd_macsec_sa_result,
13974 		 key, NULL);
13975 
13976 static void
13977 cmd_set_macsec_sa_parsed(
13978 	void *parsed_result,
13979 	__attribute__((unused)) struct cmdline *cl,
13980 	__attribute__((unused)) void *data)
13981 {
13982 	struct cmd_macsec_sa_result *res = parsed_result;
13983 	int ret = -ENOTSUP;
13984 	int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
13985 	uint8_t key[16] = { 0 };
13986 	uint8_t xdgt0;
13987 	uint8_t xdgt1;
13988 	int key_len;
13989 	int i;
13990 
13991 	key_len = strlen(res->key) / 2;
13992 	if (key_len > 16)
13993 		key_len = 16;
13994 
13995 	for (i = 0; i < key_len; i++) {
13996 		xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
13997 		if (xdgt0 == 0xFF)
13998 			return;
13999 		xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
14000 		if (xdgt1 == 0xFF)
14001 			return;
14002 		key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
14003 	}
14004 
14005 #ifdef RTE_LIBRTE_IXGBE_PMD
14006 	ret = is_tx ?
14007 		rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
14008 			res->idx, res->an, res->pn, key) :
14009 		rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
14010 			res->idx, res->an, res->pn, key);
14011 #endif
14012 	RTE_SET_USED(is_tx);
14013 	RTE_SET_USED(key);
14014 
14015 	switch (ret) {
14016 	case 0:
14017 		break;
14018 	case -EINVAL:
14019 		printf("invalid idx %d or an %d\n", res->idx, res->an);
14020 		break;
14021 	case -ENODEV:
14022 		printf("invalid port_id %d\n", res->port_id);
14023 		break;
14024 	case -ENOTSUP:
14025 		printf("not supported on port %d\n", res->port_id);
14026 		break;
14027 	default:
14028 		printf("programming error: (%s)\n", strerror(-ret));
14029 	}
14030 }
14031 
14032 cmdline_parse_inst_t cmd_set_macsec_sa = {
14033 	.f = cmd_set_macsec_sa_parsed,
14034 	.data = NULL,
14035 	.help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
14036 	.tokens = {
14037 		(void *)&cmd_macsec_sa_set,
14038 		(void *)&cmd_macsec_sa_macsec,
14039 		(void *)&cmd_macsec_sa_sa,
14040 		(void *)&cmd_macsec_sa_tx_rx,
14041 		(void *)&cmd_macsec_sa_port_id,
14042 		(void *)&cmd_macsec_sa_idx,
14043 		(void *)&cmd_macsec_sa_an,
14044 		(void *)&cmd_macsec_sa_pn,
14045 		(void *)&cmd_macsec_sa_key,
14046 		NULL,
14047 	},
14048 };
14049 
14050 /* VF unicast promiscuous mode configuration */
14051 
14052 /* Common result structure for VF unicast promiscuous mode */
14053 struct cmd_vf_promisc_result {
14054 	cmdline_fixed_string_t set;
14055 	cmdline_fixed_string_t vf;
14056 	cmdline_fixed_string_t promisc;
14057 	portid_t port_id;
14058 	uint32_t vf_id;
14059 	cmdline_fixed_string_t on_off;
14060 };
14061 
14062 /* Common CLI fields for VF unicast promiscuous mode enable disable */
14063 cmdline_parse_token_string_t cmd_vf_promisc_set =
14064 	TOKEN_STRING_INITIALIZER
14065 		(struct cmd_vf_promisc_result,
14066 		 set, "set");
14067 cmdline_parse_token_string_t cmd_vf_promisc_vf =
14068 	TOKEN_STRING_INITIALIZER
14069 		(struct cmd_vf_promisc_result,
14070 		 vf, "vf");
14071 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
14072 	TOKEN_STRING_INITIALIZER
14073 		(struct cmd_vf_promisc_result,
14074 		 promisc, "promisc");
14075 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
14076 	TOKEN_NUM_INITIALIZER
14077 		(struct cmd_vf_promisc_result,
14078 		 port_id, UINT16);
14079 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
14080 	TOKEN_NUM_INITIALIZER
14081 		(struct cmd_vf_promisc_result,
14082 		 vf_id, UINT32);
14083 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
14084 	TOKEN_STRING_INITIALIZER
14085 		(struct cmd_vf_promisc_result,
14086 		 on_off, "on#off");
14087 
14088 static void
14089 cmd_set_vf_promisc_parsed(
14090 	void *parsed_result,
14091 	__attribute__((unused)) struct cmdline *cl,
14092 	__attribute__((unused)) void *data)
14093 {
14094 	struct cmd_vf_promisc_result *res = parsed_result;
14095 	int ret = -ENOTSUP;
14096 
14097 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14098 
14099 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14100 		return;
14101 
14102 #ifdef RTE_LIBRTE_I40E_PMD
14103 	ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
14104 						  res->vf_id, is_on);
14105 #endif
14106 
14107 	switch (ret) {
14108 	case 0:
14109 		break;
14110 	case -EINVAL:
14111 		printf("invalid vf_id %d\n", res->vf_id);
14112 		break;
14113 	case -ENODEV:
14114 		printf("invalid port_id %d\n", res->port_id);
14115 		break;
14116 	case -ENOTSUP:
14117 		printf("function not implemented\n");
14118 		break;
14119 	default:
14120 		printf("programming error: (%s)\n", strerror(-ret));
14121 	}
14122 }
14123 
14124 cmdline_parse_inst_t cmd_set_vf_promisc = {
14125 	.f = cmd_set_vf_promisc_parsed,
14126 	.data = NULL,
14127 	.help_str = "set vf promisc <port_id> <vf_id> on|off: "
14128 		"Set unicast promiscuous mode for a VF from the PF",
14129 	.tokens = {
14130 		(void *)&cmd_vf_promisc_set,
14131 		(void *)&cmd_vf_promisc_vf,
14132 		(void *)&cmd_vf_promisc_promisc,
14133 		(void *)&cmd_vf_promisc_port_id,
14134 		(void *)&cmd_vf_promisc_vf_id,
14135 		(void *)&cmd_vf_promisc_on_off,
14136 		NULL,
14137 	},
14138 };
14139 
14140 /* VF multicast promiscuous mode configuration */
14141 
14142 /* Common result structure for VF multicast promiscuous mode */
14143 struct cmd_vf_allmulti_result {
14144 	cmdline_fixed_string_t set;
14145 	cmdline_fixed_string_t vf;
14146 	cmdline_fixed_string_t allmulti;
14147 	portid_t port_id;
14148 	uint32_t vf_id;
14149 	cmdline_fixed_string_t on_off;
14150 };
14151 
14152 /* Common CLI fields for VF multicast promiscuous mode enable disable */
14153 cmdline_parse_token_string_t cmd_vf_allmulti_set =
14154 	TOKEN_STRING_INITIALIZER
14155 		(struct cmd_vf_allmulti_result,
14156 		 set, "set");
14157 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
14158 	TOKEN_STRING_INITIALIZER
14159 		(struct cmd_vf_allmulti_result,
14160 		 vf, "vf");
14161 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
14162 	TOKEN_STRING_INITIALIZER
14163 		(struct cmd_vf_allmulti_result,
14164 		 allmulti, "allmulti");
14165 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
14166 	TOKEN_NUM_INITIALIZER
14167 		(struct cmd_vf_allmulti_result,
14168 		 port_id, UINT16);
14169 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
14170 	TOKEN_NUM_INITIALIZER
14171 		(struct cmd_vf_allmulti_result,
14172 		 vf_id, UINT32);
14173 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
14174 	TOKEN_STRING_INITIALIZER
14175 		(struct cmd_vf_allmulti_result,
14176 		 on_off, "on#off");
14177 
14178 static void
14179 cmd_set_vf_allmulti_parsed(
14180 	void *parsed_result,
14181 	__attribute__((unused)) struct cmdline *cl,
14182 	__attribute__((unused)) void *data)
14183 {
14184 	struct cmd_vf_allmulti_result *res = parsed_result;
14185 	int ret = -ENOTSUP;
14186 
14187 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14188 
14189 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14190 		return;
14191 
14192 #ifdef RTE_LIBRTE_I40E_PMD
14193 	ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
14194 						    res->vf_id, is_on);
14195 #endif
14196 
14197 	switch (ret) {
14198 	case 0:
14199 		break;
14200 	case -EINVAL:
14201 		printf("invalid vf_id %d\n", res->vf_id);
14202 		break;
14203 	case -ENODEV:
14204 		printf("invalid port_id %d\n", res->port_id);
14205 		break;
14206 	case -ENOTSUP:
14207 		printf("function not implemented\n");
14208 		break;
14209 	default:
14210 		printf("programming error: (%s)\n", strerror(-ret));
14211 	}
14212 }
14213 
14214 cmdline_parse_inst_t cmd_set_vf_allmulti = {
14215 	.f = cmd_set_vf_allmulti_parsed,
14216 	.data = NULL,
14217 	.help_str = "set vf allmulti <port_id> <vf_id> on|off: "
14218 		"Set multicast promiscuous mode for a VF from the PF",
14219 	.tokens = {
14220 		(void *)&cmd_vf_allmulti_set,
14221 		(void *)&cmd_vf_allmulti_vf,
14222 		(void *)&cmd_vf_allmulti_allmulti,
14223 		(void *)&cmd_vf_allmulti_port_id,
14224 		(void *)&cmd_vf_allmulti_vf_id,
14225 		(void *)&cmd_vf_allmulti_on_off,
14226 		NULL,
14227 	},
14228 };
14229 
14230 /* vf broadcast mode configuration */
14231 
14232 /* Common result structure for vf broadcast */
14233 struct cmd_set_vf_broadcast_result {
14234 	cmdline_fixed_string_t set;
14235 	cmdline_fixed_string_t vf;
14236 	cmdline_fixed_string_t broadcast;
14237 	portid_t port_id;
14238 	uint16_t vf_id;
14239 	cmdline_fixed_string_t on_off;
14240 };
14241 
14242 /* Common CLI fields for vf broadcast enable disable */
14243 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
14244 	TOKEN_STRING_INITIALIZER
14245 		(struct cmd_set_vf_broadcast_result,
14246 		 set, "set");
14247 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
14248 	TOKEN_STRING_INITIALIZER
14249 		(struct cmd_set_vf_broadcast_result,
14250 		 vf, "vf");
14251 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
14252 	TOKEN_STRING_INITIALIZER
14253 		(struct cmd_set_vf_broadcast_result,
14254 		 broadcast, "broadcast");
14255 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
14256 	TOKEN_NUM_INITIALIZER
14257 		(struct cmd_set_vf_broadcast_result,
14258 		 port_id, UINT16);
14259 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
14260 	TOKEN_NUM_INITIALIZER
14261 		(struct cmd_set_vf_broadcast_result,
14262 		 vf_id, UINT16);
14263 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
14264 	TOKEN_STRING_INITIALIZER
14265 		(struct cmd_set_vf_broadcast_result,
14266 		 on_off, "on#off");
14267 
14268 static void
14269 cmd_set_vf_broadcast_parsed(
14270 	void *parsed_result,
14271 	__attribute__((unused)) struct cmdline *cl,
14272 	__attribute__((unused)) void *data)
14273 {
14274 	struct cmd_set_vf_broadcast_result *res = parsed_result;
14275 	int ret = -ENOTSUP;
14276 
14277 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14278 
14279 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14280 		return;
14281 
14282 #ifdef RTE_LIBRTE_I40E_PMD
14283 	ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
14284 					    res->vf_id, is_on);
14285 #endif
14286 
14287 	switch (ret) {
14288 	case 0:
14289 		break;
14290 	case -EINVAL:
14291 		printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14292 		break;
14293 	case -ENODEV:
14294 		printf("invalid port_id %d\n", res->port_id);
14295 		break;
14296 	case -ENOTSUP:
14297 		printf("function not implemented\n");
14298 		break;
14299 	default:
14300 		printf("programming error: (%s)\n", strerror(-ret));
14301 	}
14302 }
14303 
14304 cmdline_parse_inst_t cmd_set_vf_broadcast = {
14305 	.f = cmd_set_vf_broadcast_parsed,
14306 	.data = NULL,
14307 	.help_str = "set vf broadcast <port_id> <vf_id> on|off",
14308 	.tokens = {
14309 		(void *)&cmd_set_vf_broadcast_set,
14310 		(void *)&cmd_set_vf_broadcast_vf,
14311 		(void *)&cmd_set_vf_broadcast_broadcast,
14312 		(void *)&cmd_set_vf_broadcast_port_id,
14313 		(void *)&cmd_set_vf_broadcast_vf_id,
14314 		(void *)&cmd_set_vf_broadcast_on_off,
14315 		NULL,
14316 	},
14317 };
14318 
14319 /* vf vlan tag configuration */
14320 
14321 /* Common result structure for vf vlan tag */
14322 struct cmd_set_vf_vlan_tag_result {
14323 	cmdline_fixed_string_t set;
14324 	cmdline_fixed_string_t vf;
14325 	cmdline_fixed_string_t vlan;
14326 	cmdline_fixed_string_t tag;
14327 	portid_t port_id;
14328 	uint16_t vf_id;
14329 	cmdline_fixed_string_t on_off;
14330 };
14331 
14332 /* Common CLI fields for vf vlan tag enable disable */
14333 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
14334 	TOKEN_STRING_INITIALIZER
14335 		(struct cmd_set_vf_vlan_tag_result,
14336 		 set, "set");
14337 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
14338 	TOKEN_STRING_INITIALIZER
14339 		(struct cmd_set_vf_vlan_tag_result,
14340 		 vf, "vf");
14341 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
14342 	TOKEN_STRING_INITIALIZER
14343 		(struct cmd_set_vf_vlan_tag_result,
14344 		 vlan, "vlan");
14345 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
14346 	TOKEN_STRING_INITIALIZER
14347 		(struct cmd_set_vf_vlan_tag_result,
14348 		 tag, "tag");
14349 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
14350 	TOKEN_NUM_INITIALIZER
14351 		(struct cmd_set_vf_vlan_tag_result,
14352 		 port_id, UINT16);
14353 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
14354 	TOKEN_NUM_INITIALIZER
14355 		(struct cmd_set_vf_vlan_tag_result,
14356 		 vf_id, UINT16);
14357 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
14358 	TOKEN_STRING_INITIALIZER
14359 		(struct cmd_set_vf_vlan_tag_result,
14360 		 on_off, "on#off");
14361 
14362 static void
14363 cmd_set_vf_vlan_tag_parsed(
14364 	void *parsed_result,
14365 	__attribute__((unused)) struct cmdline *cl,
14366 	__attribute__((unused)) void *data)
14367 {
14368 	struct cmd_set_vf_vlan_tag_result *res = parsed_result;
14369 	int ret = -ENOTSUP;
14370 
14371 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14372 
14373 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14374 		return;
14375 
14376 #ifdef RTE_LIBRTE_I40E_PMD
14377 	ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
14378 					   res->vf_id, is_on);
14379 #endif
14380 
14381 	switch (ret) {
14382 	case 0:
14383 		break;
14384 	case -EINVAL:
14385 		printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14386 		break;
14387 	case -ENODEV:
14388 		printf("invalid port_id %d\n", res->port_id);
14389 		break;
14390 	case -ENOTSUP:
14391 		printf("function not implemented\n");
14392 		break;
14393 	default:
14394 		printf("programming error: (%s)\n", strerror(-ret));
14395 	}
14396 }
14397 
14398 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
14399 	.f = cmd_set_vf_vlan_tag_parsed,
14400 	.data = NULL,
14401 	.help_str = "set vf vlan tag <port_id> <vf_id> on|off",
14402 	.tokens = {
14403 		(void *)&cmd_set_vf_vlan_tag_set,
14404 		(void *)&cmd_set_vf_vlan_tag_vf,
14405 		(void *)&cmd_set_vf_vlan_tag_vlan,
14406 		(void *)&cmd_set_vf_vlan_tag_tag,
14407 		(void *)&cmd_set_vf_vlan_tag_port_id,
14408 		(void *)&cmd_set_vf_vlan_tag_vf_id,
14409 		(void *)&cmd_set_vf_vlan_tag_on_off,
14410 		NULL,
14411 	},
14412 };
14413 
14414 /* Common definition of VF and TC TX bandwidth configuration */
14415 struct cmd_vf_tc_bw_result {
14416 	cmdline_fixed_string_t set;
14417 	cmdline_fixed_string_t vf;
14418 	cmdline_fixed_string_t tc;
14419 	cmdline_fixed_string_t tx;
14420 	cmdline_fixed_string_t min_bw;
14421 	cmdline_fixed_string_t max_bw;
14422 	cmdline_fixed_string_t strict_link_prio;
14423 	portid_t port_id;
14424 	uint16_t vf_id;
14425 	uint8_t tc_no;
14426 	uint32_t bw;
14427 	cmdline_fixed_string_t bw_list;
14428 	uint8_t tc_map;
14429 };
14430 
14431 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
14432 	TOKEN_STRING_INITIALIZER
14433 		(struct cmd_vf_tc_bw_result,
14434 		 set, "set");
14435 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
14436 	TOKEN_STRING_INITIALIZER
14437 		(struct cmd_vf_tc_bw_result,
14438 		 vf, "vf");
14439 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
14440 	TOKEN_STRING_INITIALIZER
14441 		(struct cmd_vf_tc_bw_result,
14442 		 tc, "tc");
14443 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
14444 	TOKEN_STRING_INITIALIZER
14445 		(struct cmd_vf_tc_bw_result,
14446 		 tx, "tx");
14447 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
14448 	TOKEN_STRING_INITIALIZER
14449 		(struct cmd_vf_tc_bw_result,
14450 		 strict_link_prio, "strict-link-priority");
14451 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
14452 	TOKEN_STRING_INITIALIZER
14453 		(struct cmd_vf_tc_bw_result,
14454 		 min_bw, "min-bandwidth");
14455 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
14456 	TOKEN_STRING_INITIALIZER
14457 		(struct cmd_vf_tc_bw_result,
14458 		 max_bw, "max-bandwidth");
14459 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
14460 	TOKEN_NUM_INITIALIZER
14461 		(struct cmd_vf_tc_bw_result,
14462 		 port_id, UINT16);
14463 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
14464 	TOKEN_NUM_INITIALIZER
14465 		(struct cmd_vf_tc_bw_result,
14466 		 vf_id, UINT16);
14467 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
14468 	TOKEN_NUM_INITIALIZER
14469 		(struct cmd_vf_tc_bw_result,
14470 		 tc_no, UINT8);
14471 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
14472 	TOKEN_NUM_INITIALIZER
14473 		(struct cmd_vf_tc_bw_result,
14474 		 bw, UINT32);
14475 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
14476 	TOKEN_STRING_INITIALIZER
14477 		(struct cmd_vf_tc_bw_result,
14478 		 bw_list, NULL);
14479 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
14480 	TOKEN_NUM_INITIALIZER
14481 		(struct cmd_vf_tc_bw_result,
14482 		 tc_map, UINT8);
14483 
14484 /* VF max bandwidth setting */
14485 static void
14486 cmd_vf_max_bw_parsed(
14487 	void *parsed_result,
14488 	__attribute__((unused)) struct cmdline *cl,
14489 	__attribute__((unused)) void *data)
14490 {
14491 	struct cmd_vf_tc_bw_result *res = parsed_result;
14492 	int ret = -ENOTSUP;
14493 
14494 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14495 		return;
14496 
14497 #ifdef RTE_LIBRTE_I40E_PMD
14498 	ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
14499 					 res->vf_id, res->bw);
14500 #endif
14501 
14502 	switch (ret) {
14503 	case 0:
14504 		break;
14505 	case -EINVAL:
14506 		printf("invalid vf_id %d or bandwidth %d\n",
14507 		       res->vf_id, res->bw);
14508 		break;
14509 	case -ENODEV:
14510 		printf("invalid port_id %d\n", res->port_id);
14511 		break;
14512 	case -ENOTSUP:
14513 		printf("function not implemented\n");
14514 		break;
14515 	default:
14516 		printf("programming error: (%s)\n", strerror(-ret));
14517 	}
14518 }
14519 
14520 cmdline_parse_inst_t cmd_vf_max_bw = {
14521 	.f = cmd_vf_max_bw_parsed,
14522 	.data = NULL,
14523 	.help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
14524 	.tokens = {
14525 		(void *)&cmd_vf_tc_bw_set,
14526 		(void *)&cmd_vf_tc_bw_vf,
14527 		(void *)&cmd_vf_tc_bw_tx,
14528 		(void *)&cmd_vf_tc_bw_max_bw,
14529 		(void *)&cmd_vf_tc_bw_port_id,
14530 		(void *)&cmd_vf_tc_bw_vf_id,
14531 		(void *)&cmd_vf_tc_bw_bw,
14532 		NULL,
14533 	},
14534 };
14535 
14536 static int
14537 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
14538 			   uint8_t *tc_num,
14539 			   char *str)
14540 {
14541 	uint32_t size;
14542 	const char *p, *p0 = str;
14543 	char s[256];
14544 	char *end;
14545 	char *str_fld[16];
14546 	uint16_t i;
14547 	int ret;
14548 
14549 	p = strchr(p0, '(');
14550 	if (p == NULL) {
14551 		printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14552 		return -1;
14553 	}
14554 	p++;
14555 	p0 = strchr(p, ')');
14556 	if (p0 == NULL) {
14557 		printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14558 		return -1;
14559 	}
14560 	size = p0 - p;
14561 	if (size >= sizeof(s)) {
14562 		printf("The string size exceeds the internal buffer size\n");
14563 		return -1;
14564 	}
14565 	snprintf(s, sizeof(s), "%.*s", size, p);
14566 	ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
14567 	if (ret <= 0) {
14568 		printf("Failed to get the bandwidth list. ");
14569 		return -1;
14570 	}
14571 	*tc_num = ret;
14572 	for (i = 0; i < ret; i++)
14573 		bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
14574 
14575 	return 0;
14576 }
14577 
14578 /* TC min bandwidth setting */
14579 static void
14580 cmd_vf_tc_min_bw_parsed(
14581 	void *parsed_result,
14582 	__attribute__((unused)) struct cmdline *cl,
14583 	__attribute__((unused)) void *data)
14584 {
14585 	struct cmd_vf_tc_bw_result *res = parsed_result;
14586 	uint8_t tc_num;
14587 	uint8_t bw[16];
14588 	int ret = -ENOTSUP;
14589 
14590 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14591 		return;
14592 
14593 	ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
14594 	if (ret)
14595 		return;
14596 
14597 #ifdef RTE_LIBRTE_I40E_PMD
14598 	ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
14599 					      tc_num, bw);
14600 #endif
14601 
14602 	switch (ret) {
14603 	case 0:
14604 		break;
14605 	case -EINVAL:
14606 		printf("invalid vf_id %d or bandwidth\n", res->vf_id);
14607 		break;
14608 	case -ENODEV:
14609 		printf("invalid port_id %d\n", res->port_id);
14610 		break;
14611 	case -ENOTSUP:
14612 		printf("function not implemented\n");
14613 		break;
14614 	default:
14615 		printf("programming error: (%s)\n", strerror(-ret));
14616 	}
14617 }
14618 
14619 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
14620 	.f = cmd_vf_tc_min_bw_parsed,
14621 	.data = NULL,
14622 	.help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
14623 		    " <bw1, bw2, ...>",
14624 	.tokens = {
14625 		(void *)&cmd_vf_tc_bw_set,
14626 		(void *)&cmd_vf_tc_bw_vf,
14627 		(void *)&cmd_vf_tc_bw_tc,
14628 		(void *)&cmd_vf_tc_bw_tx,
14629 		(void *)&cmd_vf_tc_bw_min_bw,
14630 		(void *)&cmd_vf_tc_bw_port_id,
14631 		(void *)&cmd_vf_tc_bw_vf_id,
14632 		(void *)&cmd_vf_tc_bw_bw_list,
14633 		NULL,
14634 	},
14635 };
14636 
14637 static void
14638 cmd_tc_min_bw_parsed(
14639 	void *parsed_result,
14640 	__attribute__((unused)) struct cmdline *cl,
14641 	__attribute__((unused)) void *data)
14642 {
14643 	struct cmd_vf_tc_bw_result *res = parsed_result;
14644 	struct rte_port *port;
14645 	uint8_t tc_num;
14646 	uint8_t bw[16];
14647 	int ret = -ENOTSUP;
14648 
14649 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14650 		return;
14651 
14652 	port = &ports[res->port_id];
14653 	/** Check if the port is not started **/
14654 	if (port->port_status != RTE_PORT_STOPPED) {
14655 		printf("Please stop port %d first\n", res->port_id);
14656 		return;
14657 	}
14658 
14659 	ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
14660 	if (ret)
14661 		return;
14662 
14663 #ifdef RTE_LIBRTE_IXGBE_PMD
14664 	ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
14665 #endif
14666 
14667 	switch (ret) {
14668 	case 0:
14669 		break;
14670 	case -EINVAL:
14671 		printf("invalid bandwidth\n");
14672 		break;
14673 	case -ENODEV:
14674 		printf("invalid port_id %d\n", res->port_id);
14675 		break;
14676 	case -ENOTSUP:
14677 		printf("function not implemented\n");
14678 		break;
14679 	default:
14680 		printf("programming error: (%s)\n", strerror(-ret));
14681 	}
14682 }
14683 
14684 cmdline_parse_inst_t cmd_tc_min_bw = {
14685 	.f = cmd_tc_min_bw_parsed,
14686 	.data = NULL,
14687 	.help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
14688 	.tokens = {
14689 		(void *)&cmd_vf_tc_bw_set,
14690 		(void *)&cmd_vf_tc_bw_tc,
14691 		(void *)&cmd_vf_tc_bw_tx,
14692 		(void *)&cmd_vf_tc_bw_min_bw,
14693 		(void *)&cmd_vf_tc_bw_port_id,
14694 		(void *)&cmd_vf_tc_bw_bw_list,
14695 		NULL,
14696 	},
14697 };
14698 
14699 /* TC max bandwidth setting */
14700 static void
14701 cmd_vf_tc_max_bw_parsed(
14702 	void *parsed_result,
14703 	__attribute__((unused)) struct cmdline *cl,
14704 	__attribute__((unused)) void *data)
14705 {
14706 	struct cmd_vf_tc_bw_result *res = parsed_result;
14707 	int ret = -ENOTSUP;
14708 
14709 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14710 		return;
14711 
14712 #ifdef RTE_LIBRTE_I40E_PMD
14713 	ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
14714 					    res->tc_no, res->bw);
14715 #endif
14716 
14717 	switch (ret) {
14718 	case 0:
14719 		break;
14720 	case -EINVAL:
14721 		printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
14722 		       res->vf_id, res->tc_no, res->bw);
14723 		break;
14724 	case -ENODEV:
14725 		printf("invalid port_id %d\n", res->port_id);
14726 		break;
14727 	case -ENOTSUP:
14728 		printf("function not implemented\n");
14729 		break;
14730 	default:
14731 		printf("programming error: (%s)\n", strerror(-ret));
14732 	}
14733 }
14734 
14735 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
14736 	.f = cmd_vf_tc_max_bw_parsed,
14737 	.data = NULL,
14738 	.help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
14739 		    " <bandwidth>",
14740 	.tokens = {
14741 		(void *)&cmd_vf_tc_bw_set,
14742 		(void *)&cmd_vf_tc_bw_vf,
14743 		(void *)&cmd_vf_tc_bw_tc,
14744 		(void *)&cmd_vf_tc_bw_tx,
14745 		(void *)&cmd_vf_tc_bw_max_bw,
14746 		(void *)&cmd_vf_tc_bw_port_id,
14747 		(void *)&cmd_vf_tc_bw_vf_id,
14748 		(void *)&cmd_vf_tc_bw_tc_no,
14749 		(void *)&cmd_vf_tc_bw_bw,
14750 		NULL,
14751 	},
14752 };
14753 
14754 
14755 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
14756 
14757 /* *** Set Port default Traffic Management Hierarchy *** */
14758 struct cmd_set_port_tm_hierarchy_default_result {
14759 	cmdline_fixed_string_t set;
14760 	cmdline_fixed_string_t port;
14761 	cmdline_fixed_string_t tm;
14762 	cmdline_fixed_string_t hierarchy;
14763 	cmdline_fixed_string_t def;
14764 	portid_t port_id;
14765 };
14766 
14767 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_set =
14768 	TOKEN_STRING_INITIALIZER(
14769 		struct cmd_set_port_tm_hierarchy_default_result, set, "set");
14770 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_port =
14771 	TOKEN_STRING_INITIALIZER(
14772 		struct cmd_set_port_tm_hierarchy_default_result, port, "port");
14773 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_tm =
14774 	TOKEN_STRING_INITIALIZER(
14775 		struct cmd_set_port_tm_hierarchy_default_result, tm, "tm");
14776 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_hierarchy =
14777 	TOKEN_STRING_INITIALIZER(
14778 		struct cmd_set_port_tm_hierarchy_default_result,
14779 			hierarchy, "hierarchy");
14780 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_default =
14781 	TOKEN_STRING_INITIALIZER(
14782 		struct cmd_set_port_tm_hierarchy_default_result,
14783 			def, "default");
14784 cmdline_parse_token_num_t cmd_set_port_tm_hierarchy_default_port_id =
14785 	TOKEN_NUM_INITIALIZER(
14786 		struct cmd_set_port_tm_hierarchy_default_result,
14787 			port_id, UINT16);
14788 
14789 static void cmd_set_port_tm_hierarchy_default_parsed(void *parsed_result,
14790 	__attribute__((unused)) struct cmdline *cl,
14791 	__attribute__((unused)) void *data)
14792 {
14793 	struct cmd_set_port_tm_hierarchy_default_result *res = parsed_result;
14794 	struct rte_port *p;
14795 	portid_t port_id = res->port_id;
14796 
14797 	if (port_id_is_invalid(port_id, ENABLED_WARN))
14798 		return;
14799 
14800 	p = &ports[port_id];
14801 
14802 	/* Port tm flag */
14803 	if (p->softport.tm_flag == 0) {
14804 		printf("  tm not enabled on port %u (error)\n", port_id);
14805 		return;
14806 	}
14807 
14808 	/* Forward mode: tm */
14809 	if (strcmp(cur_fwd_config.fwd_eng->fwd_mode_name, "tm")) {
14810 		printf("  tm mode not enabled(error)\n");
14811 		return;
14812 	}
14813 
14814 	/* Set the default tm hierarchy */
14815 	p->softport.tm.default_hierarchy_enable = 1;
14816 }
14817 
14818 cmdline_parse_inst_t cmd_set_port_tm_hierarchy_default = {
14819 	.f = cmd_set_port_tm_hierarchy_default_parsed,
14820 	.data = NULL,
14821 	.help_str = "set port tm hierarchy default <port_id>",
14822 	.tokens = {
14823 		(void *)&cmd_set_port_tm_hierarchy_default_set,
14824 		(void *)&cmd_set_port_tm_hierarchy_default_port,
14825 		(void *)&cmd_set_port_tm_hierarchy_default_tm,
14826 		(void *)&cmd_set_port_tm_hierarchy_default_hierarchy,
14827 		(void *)&cmd_set_port_tm_hierarchy_default_default,
14828 		(void *)&cmd_set_port_tm_hierarchy_default_port_id,
14829 		NULL,
14830 	},
14831 };
14832 #endif
14833 
14834 /* Strict link priority scheduling mode setting */
14835 static void
14836 cmd_strict_link_prio_parsed(
14837 	void *parsed_result,
14838 	__attribute__((unused)) struct cmdline *cl,
14839 	__attribute__((unused)) void *data)
14840 {
14841 	struct cmd_vf_tc_bw_result *res = parsed_result;
14842 	int ret = -ENOTSUP;
14843 
14844 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14845 		return;
14846 
14847 #ifdef RTE_LIBRTE_I40E_PMD
14848 	ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
14849 #endif
14850 
14851 	switch (ret) {
14852 	case 0:
14853 		break;
14854 	case -EINVAL:
14855 		printf("invalid tc_bitmap 0x%x\n", res->tc_map);
14856 		break;
14857 	case -ENODEV:
14858 		printf("invalid port_id %d\n", res->port_id);
14859 		break;
14860 	case -ENOTSUP:
14861 		printf("function not implemented\n");
14862 		break;
14863 	default:
14864 		printf("programming error: (%s)\n", strerror(-ret));
14865 	}
14866 }
14867 
14868 cmdline_parse_inst_t cmd_strict_link_prio = {
14869 	.f = cmd_strict_link_prio_parsed,
14870 	.data = NULL,
14871 	.help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
14872 	.tokens = {
14873 		(void *)&cmd_vf_tc_bw_set,
14874 		(void *)&cmd_vf_tc_bw_tx,
14875 		(void *)&cmd_vf_tc_bw_strict_link_prio,
14876 		(void *)&cmd_vf_tc_bw_port_id,
14877 		(void *)&cmd_vf_tc_bw_tc_map,
14878 		NULL,
14879 	},
14880 };
14881 
14882 /* Load dynamic device personalization*/
14883 struct cmd_ddp_add_result {
14884 	cmdline_fixed_string_t ddp;
14885 	cmdline_fixed_string_t add;
14886 	portid_t port_id;
14887 	char filepath[];
14888 };
14889 
14890 cmdline_parse_token_string_t cmd_ddp_add_ddp =
14891 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
14892 cmdline_parse_token_string_t cmd_ddp_add_add =
14893 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
14894 cmdline_parse_token_num_t cmd_ddp_add_port_id =
14895 	TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
14896 cmdline_parse_token_string_t cmd_ddp_add_filepath =
14897 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
14898 
14899 static void
14900 cmd_ddp_add_parsed(
14901 	void *parsed_result,
14902 	__attribute__((unused)) struct cmdline *cl,
14903 	__attribute__((unused)) void *data)
14904 {
14905 	struct cmd_ddp_add_result *res = parsed_result;
14906 	uint8_t *buff;
14907 	uint32_t size;
14908 	char *filepath;
14909 	char *file_fld[2];
14910 	int file_num;
14911 	int ret = -ENOTSUP;
14912 
14913 	if (!all_ports_stopped()) {
14914 		printf("Please stop all ports first\n");
14915 		return;
14916 	}
14917 
14918 	filepath = strdup(res->filepath);
14919 	if (filepath == NULL) {
14920 		printf("Failed to allocate memory\n");
14921 		return;
14922 	}
14923 	file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
14924 
14925 	buff = open_file(file_fld[0], &size);
14926 	if (!buff) {
14927 		free((void *)filepath);
14928 		return;
14929 	}
14930 
14931 #ifdef RTE_LIBRTE_I40E_PMD
14932 	if (ret == -ENOTSUP)
14933 		ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14934 					       buff, size,
14935 					       RTE_PMD_I40E_PKG_OP_WR_ADD);
14936 #endif
14937 
14938 	if (ret == -EEXIST)
14939 		printf("Profile has already existed.\n");
14940 	else if (ret < 0)
14941 		printf("Failed to load profile.\n");
14942 	else if (file_num == 2)
14943 		save_file(file_fld[1], buff, size);
14944 
14945 	close_file(buff);
14946 	free((void *)filepath);
14947 }
14948 
14949 cmdline_parse_inst_t cmd_ddp_add = {
14950 	.f = cmd_ddp_add_parsed,
14951 	.data = NULL,
14952 	.help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
14953 	.tokens = {
14954 		(void *)&cmd_ddp_add_ddp,
14955 		(void *)&cmd_ddp_add_add,
14956 		(void *)&cmd_ddp_add_port_id,
14957 		(void *)&cmd_ddp_add_filepath,
14958 		NULL,
14959 	},
14960 };
14961 
14962 /* Delete dynamic device personalization*/
14963 struct cmd_ddp_del_result {
14964 	cmdline_fixed_string_t ddp;
14965 	cmdline_fixed_string_t del;
14966 	portid_t port_id;
14967 	char filepath[];
14968 };
14969 
14970 cmdline_parse_token_string_t cmd_ddp_del_ddp =
14971 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
14972 cmdline_parse_token_string_t cmd_ddp_del_del =
14973 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
14974 cmdline_parse_token_num_t cmd_ddp_del_port_id =
14975 	TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
14976 cmdline_parse_token_string_t cmd_ddp_del_filepath =
14977 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
14978 
14979 static void
14980 cmd_ddp_del_parsed(
14981 	void *parsed_result,
14982 	__attribute__((unused)) struct cmdline *cl,
14983 	__attribute__((unused)) void *data)
14984 {
14985 	struct cmd_ddp_del_result *res = parsed_result;
14986 	uint8_t *buff;
14987 	uint32_t size;
14988 	int ret = -ENOTSUP;
14989 
14990 	if (!all_ports_stopped()) {
14991 		printf("Please stop all ports first\n");
14992 		return;
14993 	}
14994 
14995 	buff = open_file(res->filepath, &size);
14996 	if (!buff)
14997 		return;
14998 
14999 #ifdef RTE_LIBRTE_I40E_PMD
15000 	if (ret == -ENOTSUP)
15001 		ret = rte_pmd_i40e_process_ddp_package(res->port_id,
15002 					       buff, size,
15003 					       RTE_PMD_I40E_PKG_OP_WR_DEL);
15004 #endif
15005 
15006 	if (ret == -EACCES)
15007 		printf("Profile does not exist.\n");
15008 	else if (ret < 0)
15009 		printf("Failed to delete profile.\n");
15010 
15011 	close_file(buff);
15012 }
15013 
15014 cmdline_parse_inst_t cmd_ddp_del = {
15015 	.f = cmd_ddp_del_parsed,
15016 	.data = NULL,
15017 	.help_str = "ddp del <port_id> <backup_profile_path>",
15018 	.tokens = {
15019 		(void *)&cmd_ddp_del_ddp,
15020 		(void *)&cmd_ddp_del_del,
15021 		(void *)&cmd_ddp_del_port_id,
15022 		(void *)&cmd_ddp_del_filepath,
15023 		NULL,
15024 	},
15025 };
15026 
15027 /* Get dynamic device personalization profile info */
15028 struct cmd_ddp_info_result {
15029 	cmdline_fixed_string_t ddp;
15030 	cmdline_fixed_string_t get;
15031 	cmdline_fixed_string_t info;
15032 	char filepath[];
15033 };
15034 
15035 cmdline_parse_token_string_t cmd_ddp_info_ddp =
15036 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
15037 cmdline_parse_token_string_t cmd_ddp_info_get =
15038 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
15039 cmdline_parse_token_string_t cmd_ddp_info_info =
15040 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
15041 cmdline_parse_token_string_t cmd_ddp_info_filepath =
15042 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
15043 
15044 static void
15045 cmd_ddp_info_parsed(
15046 	void *parsed_result,
15047 	__attribute__((unused)) struct cmdline *cl,
15048 	__attribute__((unused)) void *data)
15049 {
15050 	struct cmd_ddp_info_result *res = parsed_result;
15051 	uint8_t *pkg;
15052 	uint32_t pkg_size;
15053 	int ret = -ENOTSUP;
15054 #ifdef RTE_LIBRTE_I40E_PMD
15055 	uint32_t i, j, n;
15056 	uint8_t *buff;
15057 	uint32_t buff_size = 0;
15058 	struct rte_pmd_i40e_profile_info info;
15059 	uint32_t dev_num = 0;
15060 	struct rte_pmd_i40e_ddp_device_id *devs;
15061 	uint32_t proto_num = 0;
15062 	struct rte_pmd_i40e_proto_info *proto = NULL;
15063 	uint32_t pctype_num = 0;
15064 	struct rte_pmd_i40e_ptype_info *pctype;
15065 	uint32_t ptype_num = 0;
15066 	struct rte_pmd_i40e_ptype_info *ptype;
15067 	uint8_t proto_id;
15068 
15069 #endif
15070 
15071 	pkg = open_file(res->filepath, &pkg_size);
15072 	if (!pkg)
15073 		return;
15074 
15075 #ifdef RTE_LIBRTE_I40E_PMD
15076 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15077 				(uint8_t *)&info, sizeof(info),
15078 				RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
15079 	if (!ret) {
15080 		printf("Global Track id:       0x%x\n", info.track_id);
15081 		printf("Global Version:        %d.%d.%d.%d\n",
15082 			info.version.major,
15083 			info.version.minor,
15084 			info.version.update,
15085 			info.version.draft);
15086 		printf("Global Package name:   %s\n\n", info.name);
15087 	}
15088 
15089 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15090 				(uint8_t *)&info, sizeof(info),
15091 				RTE_PMD_I40E_PKG_INFO_HEADER);
15092 	if (!ret) {
15093 		printf("i40e Profile Track id: 0x%x\n", info.track_id);
15094 		printf("i40e Profile Version:  %d.%d.%d.%d\n",
15095 			info.version.major,
15096 			info.version.minor,
15097 			info.version.update,
15098 			info.version.draft);
15099 		printf("i40e Profile name:     %s\n\n", info.name);
15100 	}
15101 
15102 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15103 				(uint8_t *)&buff_size, sizeof(buff_size),
15104 				RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
15105 	if (!ret && buff_size) {
15106 		buff = (uint8_t *)malloc(buff_size);
15107 		if (buff) {
15108 			ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15109 						buff, buff_size,
15110 						RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
15111 			if (!ret)
15112 				printf("Package Notes:\n%s\n\n", buff);
15113 			free(buff);
15114 		}
15115 	}
15116 
15117 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15118 				(uint8_t *)&dev_num, sizeof(dev_num),
15119 				RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
15120 	if (!ret && dev_num) {
15121 		buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
15122 		devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
15123 		if (devs) {
15124 			ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15125 						(uint8_t *)devs, buff_size,
15126 						RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
15127 			if (!ret) {
15128 				printf("List of supported devices:\n");
15129 				for (i = 0; i < dev_num; i++) {
15130 					printf("  %04X:%04X %04X:%04X\n",
15131 						devs[i].vendor_dev_id >> 16,
15132 						devs[i].vendor_dev_id & 0xFFFF,
15133 						devs[i].sub_vendor_dev_id >> 16,
15134 						devs[i].sub_vendor_dev_id & 0xFFFF);
15135 				}
15136 				printf("\n");
15137 			}
15138 			free(devs);
15139 		}
15140 	}
15141 
15142 	/* get information about protocols and packet types */
15143 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15144 		(uint8_t *)&proto_num, sizeof(proto_num),
15145 		RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
15146 	if (ret || !proto_num)
15147 		goto no_print_return;
15148 
15149 	buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
15150 	proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
15151 	if (!proto)
15152 		goto no_print_return;
15153 
15154 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
15155 					buff_size,
15156 					RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
15157 	if (!ret) {
15158 		printf("List of used protocols:\n");
15159 		for (i = 0; i < proto_num; i++)
15160 			printf("  %2u: %s\n", proto[i].proto_id,
15161 			       proto[i].name);
15162 		printf("\n");
15163 	}
15164 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15165 		(uint8_t *)&pctype_num, sizeof(pctype_num),
15166 		RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
15167 	if (ret || !pctype_num)
15168 		goto no_print_pctypes;
15169 
15170 	buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
15171 	pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
15172 	if (!pctype)
15173 		goto no_print_pctypes;
15174 
15175 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
15176 					buff_size,
15177 					RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
15178 	if (ret) {
15179 		free(pctype);
15180 		goto no_print_pctypes;
15181 	}
15182 
15183 	printf("List of defined packet classification types:\n");
15184 	for (i = 0; i < pctype_num; i++) {
15185 		printf("  %2u:", pctype[i].ptype_id);
15186 		for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
15187 			proto_id = pctype[i].protocols[j];
15188 			if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
15189 				for (n = 0; n < proto_num; n++) {
15190 					if (proto[n].proto_id == proto_id) {
15191 						printf(" %s", proto[n].name);
15192 						break;
15193 					}
15194 				}
15195 			}
15196 		}
15197 		printf("\n");
15198 	}
15199 	printf("\n");
15200 	free(pctype);
15201 
15202 no_print_pctypes:
15203 
15204 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
15205 					sizeof(ptype_num),
15206 					RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
15207 	if (ret || !ptype_num)
15208 		goto no_print_return;
15209 
15210 	buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
15211 	ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
15212 	if (!ptype)
15213 		goto no_print_return;
15214 
15215 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
15216 					buff_size,
15217 					RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
15218 	if (ret) {
15219 		free(ptype);
15220 		goto no_print_return;
15221 	}
15222 	printf("List of defined packet types:\n");
15223 	for (i = 0; i < ptype_num; i++) {
15224 		printf("  %2u:", ptype[i].ptype_id);
15225 		for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
15226 			proto_id = ptype[i].protocols[j];
15227 			if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
15228 				for (n = 0; n < proto_num; n++) {
15229 					if (proto[n].proto_id == proto_id) {
15230 						printf(" %s", proto[n].name);
15231 						break;
15232 					}
15233 				}
15234 			}
15235 		}
15236 		printf("\n");
15237 	}
15238 	free(ptype);
15239 	printf("\n");
15240 
15241 	ret = 0;
15242 no_print_return:
15243 	if (proto)
15244 		free(proto);
15245 #endif
15246 	if (ret == -ENOTSUP)
15247 		printf("Function not supported in PMD driver\n");
15248 	close_file(pkg);
15249 }
15250 
15251 cmdline_parse_inst_t cmd_ddp_get_info = {
15252 	.f = cmd_ddp_info_parsed,
15253 	.data = NULL,
15254 	.help_str = "ddp get info <profile_path>",
15255 	.tokens = {
15256 		(void *)&cmd_ddp_info_ddp,
15257 		(void *)&cmd_ddp_info_get,
15258 		(void *)&cmd_ddp_info_info,
15259 		(void *)&cmd_ddp_info_filepath,
15260 		NULL,
15261 	},
15262 };
15263 
15264 /* Get dynamic device personalization profile info list*/
15265 #define PROFILE_INFO_SIZE 48
15266 #define MAX_PROFILE_NUM 16
15267 
15268 struct cmd_ddp_get_list_result {
15269 	cmdline_fixed_string_t ddp;
15270 	cmdline_fixed_string_t get;
15271 	cmdline_fixed_string_t list;
15272 	portid_t port_id;
15273 };
15274 
15275 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
15276 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
15277 cmdline_parse_token_string_t cmd_ddp_get_list_get =
15278 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
15279 cmdline_parse_token_string_t cmd_ddp_get_list_list =
15280 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
15281 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
15282 	TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
15283 
15284 static void
15285 cmd_ddp_get_list_parsed(
15286 	__attribute__((unused)) void *parsed_result,
15287 	__attribute__((unused)) struct cmdline *cl,
15288 	__attribute__((unused)) void *data)
15289 {
15290 #ifdef RTE_LIBRTE_I40E_PMD
15291 	struct cmd_ddp_get_list_result *res = parsed_result;
15292 	struct rte_pmd_i40e_profile_list *p_list;
15293 	struct rte_pmd_i40e_profile_info *p_info;
15294 	uint32_t p_num;
15295 	uint32_t size;
15296 	uint32_t i;
15297 #endif
15298 	int ret = -ENOTSUP;
15299 
15300 #ifdef RTE_LIBRTE_I40E_PMD
15301 	size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
15302 	p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
15303 	if (!p_list)
15304 		printf("%s: Failed to malloc buffer\n", __func__);
15305 
15306 	if (ret == -ENOTSUP)
15307 		ret = rte_pmd_i40e_get_ddp_list(res->port_id,
15308 						(uint8_t *)p_list, size);
15309 
15310 	if (!ret) {
15311 		p_num = p_list->p_count;
15312 		printf("Profile number is: %d\n\n", p_num);
15313 
15314 		for (i = 0; i < p_num; i++) {
15315 			p_info = &p_list->p_info[i];
15316 			printf("Profile %d:\n", i);
15317 			printf("Track id:     0x%x\n", p_info->track_id);
15318 			printf("Version:      %d.%d.%d.%d\n",
15319 			       p_info->version.major,
15320 			       p_info->version.minor,
15321 			       p_info->version.update,
15322 			       p_info->version.draft);
15323 			printf("Profile name: %s\n\n", p_info->name);
15324 		}
15325 	}
15326 
15327 	free(p_list);
15328 #endif
15329 
15330 	if (ret < 0)
15331 		printf("Failed to get ddp list\n");
15332 }
15333 
15334 cmdline_parse_inst_t cmd_ddp_get_list = {
15335 	.f = cmd_ddp_get_list_parsed,
15336 	.data = NULL,
15337 	.help_str = "ddp get list <port_id>",
15338 	.tokens = {
15339 		(void *)&cmd_ddp_get_list_ddp,
15340 		(void *)&cmd_ddp_get_list_get,
15341 		(void *)&cmd_ddp_get_list_list,
15342 		(void *)&cmd_ddp_get_list_port_id,
15343 		NULL,
15344 	},
15345 };
15346 
15347 /* Configure input set */
15348 struct cmd_cfg_input_set_result {
15349 	cmdline_fixed_string_t port;
15350 	cmdline_fixed_string_t cfg;
15351 	portid_t port_id;
15352 	cmdline_fixed_string_t pctype;
15353 	uint8_t pctype_id;
15354 	cmdline_fixed_string_t inset_type;
15355 	cmdline_fixed_string_t opt;
15356 	cmdline_fixed_string_t field;
15357 	uint8_t field_idx;
15358 };
15359 
15360 static void
15361 cmd_cfg_input_set_parsed(
15362 	__attribute__((unused)) void *parsed_result,
15363 	__attribute__((unused)) struct cmdline *cl,
15364 	__attribute__((unused)) void *data)
15365 {
15366 #ifdef RTE_LIBRTE_I40E_PMD
15367 	struct cmd_cfg_input_set_result *res = parsed_result;
15368 	enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
15369 	struct rte_pmd_i40e_inset inset;
15370 #endif
15371 	int ret = -ENOTSUP;
15372 
15373 	if (!all_ports_stopped()) {
15374 		printf("Please stop all ports first\n");
15375 		return;
15376 	}
15377 
15378 #ifdef RTE_LIBRTE_I40E_PMD
15379 	if (!strcmp(res->inset_type, "hash_inset"))
15380 		inset_type = INSET_HASH;
15381 	else if (!strcmp(res->inset_type, "fdir_inset"))
15382 		inset_type = INSET_FDIR;
15383 	else if (!strcmp(res->inset_type, "fdir_flx_inset"))
15384 		inset_type = INSET_FDIR_FLX;
15385 	ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
15386 				     &inset, inset_type);
15387 	if (ret) {
15388 		printf("Failed to get input set.\n");
15389 		return;
15390 	}
15391 
15392 	if (!strcmp(res->opt, "get")) {
15393 		ret = rte_pmd_i40e_inset_field_get(inset.inset,
15394 						   res->field_idx);
15395 		if (ret)
15396 			printf("Field index %d is enabled.\n", res->field_idx);
15397 		else
15398 			printf("Field index %d is disabled.\n", res->field_idx);
15399 		return;
15400 	} else if (!strcmp(res->opt, "set"))
15401 		ret = rte_pmd_i40e_inset_field_set(&inset.inset,
15402 						   res->field_idx);
15403 	else if (!strcmp(res->opt, "clear"))
15404 		ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
15405 						     res->field_idx);
15406 	if (ret) {
15407 		printf("Failed to configure input set field.\n");
15408 		return;
15409 	}
15410 
15411 	ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
15412 				     &inset, inset_type);
15413 	if (ret) {
15414 		printf("Failed to set input set.\n");
15415 		return;
15416 	}
15417 #endif
15418 
15419 	if (ret == -ENOTSUP)
15420 		printf("Function not supported\n");
15421 }
15422 
15423 cmdline_parse_token_string_t cmd_cfg_input_set_port =
15424 	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15425 				 port, "port");
15426 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
15427 	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15428 				 cfg, "config");
15429 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
15430 	TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15431 			      port_id, UINT16);
15432 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
15433 	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15434 				 pctype, "pctype");
15435 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
15436 	TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15437 			      pctype_id, UINT8);
15438 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
15439 	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15440 				 inset_type,
15441 				 "hash_inset#fdir_inset#fdir_flx_inset");
15442 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
15443 	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15444 				 opt, "get#set#clear");
15445 cmdline_parse_token_string_t cmd_cfg_input_set_field =
15446 	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15447 				 field, "field");
15448 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
15449 	TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15450 			      field_idx, UINT8);
15451 
15452 cmdline_parse_inst_t cmd_cfg_input_set = {
15453 	.f = cmd_cfg_input_set_parsed,
15454 	.data = NULL,
15455 	.help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
15456 		    "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
15457 	.tokens = {
15458 		(void *)&cmd_cfg_input_set_port,
15459 		(void *)&cmd_cfg_input_set_cfg,
15460 		(void *)&cmd_cfg_input_set_port_id,
15461 		(void *)&cmd_cfg_input_set_pctype,
15462 		(void *)&cmd_cfg_input_set_pctype_id,
15463 		(void *)&cmd_cfg_input_set_inset_type,
15464 		(void *)&cmd_cfg_input_set_opt,
15465 		(void *)&cmd_cfg_input_set_field,
15466 		(void *)&cmd_cfg_input_set_field_idx,
15467 		NULL,
15468 	},
15469 };
15470 
15471 /* Clear input set */
15472 struct cmd_clear_input_set_result {
15473 	cmdline_fixed_string_t port;
15474 	cmdline_fixed_string_t cfg;
15475 	portid_t port_id;
15476 	cmdline_fixed_string_t pctype;
15477 	uint8_t pctype_id;
15478 	cmdline_fixed_string_t inset_type;
15479 	cmdline_fixed_string_t clear;
15480 	cmdline_fixed_string_t all;
15481 };
15482 
15483 static void
15484 cmd_clear_input_set_parsed(
15485 	__attribute__((unused)) void *parsed_result,
15486 	__attribute__((unused)) struct cmdline *cl,
15487 	__attribute__((unused)) void *data)
15488 {
15489 #ifdef RTE_LIBRTE_I40E_PMD
15490 	struct cmd_clear_input_set_result *res = parsed_result;
15491 	enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
15492 	struct rte_pmd_i40e_inset inset;
15493 #endif
15494 	int ret = -ENOTSUP;
15495 
15496 	if (!all_ports_stopped()) {
15497 		printf("Please stop all ports first\n");
15498 		return;
15499 	}
15500 
15501 #ifdef RTE_LIBRTE_I40E_PMD
15502 	if (!strcmp(res->inset_type, "hash_inset"))
15503 		inset_type = INSET_HASH;
15504 	else if (!strcmp(res->inset_type, "fdir_inset"))
15505 		inset_type = INSET_FDIR;
15506 	else if (!strcmp(res->inset_type, "fdir_flx_inset"))
15507 		inset_type = INSET_FDIR_FLX;
15508 
15509 	memset(&inset, 0, sizeof(inset));
15510 
15511 	ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
15512 				     &inset, inset_type);
15513 	if (ret) {
15514 		printf("Failed to clear input set.\n");
15515 		return;
15516 	}
15517 
15518 #endif
15519 
15520 	if (ret == -ENOTSUP)
15521 		printf("Function not supported\n");
15522 }
15523 
15524 cmdline_parse_token_string_t cmd_clear_input_set_port =
15525 	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15526 				 port, "port");
15527 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
15528 	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15529 				 cfg, "config");
15530 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
15531 	TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
15532 			      port_id, UINT16);
15533 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
15534 	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15535 				 pctype, "pctype");
15536 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
15537 	TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
15538 			      pctype_id, UINT8);
15539 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
15540 	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15541 				 inset_type,
15542 				 "hash_inset#fdir_inset#fdir_flx_inset");
15543 cmdline_parse_token_string_t cmd_clear_input_set_clear =
15544 	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15545 				 clear, "clear");
15546 cmdline_parse_token_string_t cmd_clear_input_set_all =
15547 	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15548 				 all, "all");
15549 
15550 cmdline_parse_inst_t cmd_clear_input_set = {
15551 	.f = cmd_clear_input_set_parsed,
15552 	.data = NULL,
15553 	.help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
15554 		    "fdir_inset|fdir_flx_inset clear all",
15555 	.tokens = {
15556 		(void *)&cmd_clear_input_set_port,
15557 		(void *)&cmd_clear_input_set_cfg,
15558 		(void *)&cmd_clear_input_set_port_id,
15559 		(void *)&cmd_clear_input_set_pctype,
15560 		(void *)&cmd_clear_input_set_pctype_id,
15561 		(void *)&cmd_clear_input_set_inset_type,
15562 		(void *)&cmd_clear_input_set_clear,
15563 		(void *)&cmd_clear_input_set_all,
15564 		NULL,
15565 	},
15566 };
15567 
15568 /* show vf stats */
15569 
15570 /* Common result structure for show vf stats */
15571 struct cmd_show_vf_stats_result {
15572 	cmdline_fixed_string_t show;
15573 	cmdline_fixed_string_t vf;
15574 	cmdline_fixed_string_t stats;
15575 	portid_t port_id;
15576 	uint16_t vf_id;
15577 };
15578 
15579 /* Common CLI fields show vf stats*/
15580 cmdline_parse_token_string_t cmd_show_vf_stats_show =
15581 	TOKEN_STRING_INITIALIZER
15582 		(struct cmd_show_vf_stats_result,
15583 		 show, "show");
15584 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
15585 	TOKEN_STRING_INITIALIZER
15586 		(struct cmd_show_vf_stats_result,
15587 		 vf, "vf");
15588 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
15589 	TOKEN_STRING_INITIALIZER
15590 		(struct cmd_show_vf_stats_result,
15591 		 stats, "stats");
15592 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
15593 	TOKEN_NUM_INITIALIZER
15594 		(struct cmd_show_vf_stats_result,
15595 		 port_id, UINT16);
15596 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
15597 	TOKEN_NUM_INITIALIZER
15598 		(struct cmd_show_vf_stats_result,
15599 		 vf_id, UINT16);
15600 
15601 static void
15602 cmd_show_vf_stats_parsed(
15603 	void *parsed_result,
15604 	__attribute__((unused)) struct cmdline *cl,
15605 	__attribute__((unused)) void *data)
15606 {
15607 	struct cmd_show_vf_stats_result *res = parsed_result;
15608 	struct rte_eth_stats stats;
15609 	int ret = -ENOTSUP;
15610 	static const char *nic_stats_border = "########################";
15611 
15612 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15613 		return;
15614 
15615 	memset(&stats, 0, sizeof(stats));
15616 
15617 #ifdef RTE_LIBRTE_I40E_PMD
15618 	if (ret == -ENOTSUP)
15619 		ret = rte_pmd_i40e_get_vf_stats(res->port_id,
15620 						res->vf_id,
15621 						&stats);
15622 #endif
15623 #ifdef RTE_LIBRTE_BNXT_PMD
15624 	if (ret == -ENOTSUP)
15625 		ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
15626 						res->vf_id,
15627 						&stats);
15628 #endif
15629 
15630 	switch (ret) {
15631 	case 0:
15632 		break;
15633 	case -EINVAL:
15634 		printf("invalid vf_id %d\n", res->vf_id);
15635 		break;
15636 	case -ENODEV:
15637 		printf("invalid port_id %d\n", res->port_id);
15638 		break;
15639 	case -ENOTSUP:
15640 		printf("function not implemented\n");
15641 		break;
15642 	default:
15643 		printf("programming error: (%s)\n", strerror(-ret));
15644 	}
15645 
15646 	printf("\n  %s NIC statistics for port %-2d vf %-2d %s\n",
15647 		nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
15648 
15649 	printf("  RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes:  "
15650 	       "%-"PRIu64"\n",
15651 	       stats.ipackets, stats.imissed, stats.ibytes);
15652 	printf("  RX-errors: %-"PRIu64"\n", stats.ierrors);
15653 	printf("  RX-nombuf:  %-10"PRIu64"\n",
15654 	       stats.rx_nombuf);
15655 	printf("  TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes:  "
15656 	       "%-"PRIu64"\n",
15657 	       stats.opackets, stats.oerrors, stats.obytes);
15658 
15659 	printf("  %s############################%s\n",
15660 			       nic_stats_border, nic_stats_border);
15661 }
15662 
15663 cmdline_parse_inst_t cmd_show_vf_stats = {
15664 	.f = cmd_show_vf_stats_parsed,
15665 	.data = NULL,
15666 	.help_str = "show vf stats <port_id> <vf_id>",
15667 	.tokens = {
15668 		(void *)&cmd_show_vf_stats_show,
15669 		(void *)&cmd_show_vf_stats_vf,
15670 		(void *)&cmd_show_vf_stats_stats,
15671 		(void *)&cmd_show_vf_stats_port_id,
15672 		(void *)&cmd_show_vf_stats_vf_id,
15673 		NULL,
15674 	},
15675 };
15676 
15677 /* clear vf stats */
15678 
15679 /* Common result structure for clear vf stats */
15680 struct cmd_clear_vf_stats_result {
15681 	cmdline_fixed_string_t clear;
15682 	cmdline_fixed_string_t vf;
15683 	cmdline_fixed_string_t stats;
15684 	portid_t port_id;
15685 	uint16_t vf_id;
15686 };
15687 
15688 /* Common CLI fields clear vf stats*/
15689 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
15690 	TOKEN_STRING_INITIALIZER
15691 		(struct cmd_clear_vf_stats_result,
15692 		 clear, "clear");
15693 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
15694 	TOKEN_STRING_INITIALIZER
15695 		(struct cmd_clear_vf_stats_result,
15696 		 vf, "vf");
15697 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
15698 	TOKEN_STRING_INITIALIZER
15699 		(struct cmd_clear_vf_stats_result,
15700 		 stats, "stats");
15701 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
15702 	TOKEN_NUM_INITIALIZER
15703 		(struct cmd_clear_vf_stats_result,
15704 		 port_id, UINT16);
15705 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
15706 	TOKEN_NUM_INITIALIZER
15707 		(struct cmd_clear_vf_stats_result,
15708 		 vf_id, UINT16);
15709 
15710 static void
15711 cmd_clear_vf_stats_parsed(
15712 	void *parsed_result,
15713 	__attribute__((unused)) struct cmdline *cl,
15714 	__attribute__((unused)) void *data)
15715 {
15716 	struct cmd_clear_vf_stats_result *res = parsed_result;
15717 	int ret = -ENOTSUP;
15718 
15719 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15720 		return;
15721 
15722 #ifdef RTE_LIBRTE_I40E_PMD
15723 	if (ret == -ENOTSUP)
15724 		ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
15725 						  res->vf_id);
15726 #endif
15727 #ifdef RTE_LIBRTE_BNXT_PMD
15728 	if (ret == -ENOTSUP)
15729 		ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
15730 						  res->vf_id);
15731 #endif
15732 
15733 	switch (ret) {
15734 	case 0:
15735 		break;
15736 	case -EINVAL:
15737 		printf("invalid vf_id %d\n", res->vf_id);
15738 		break;
15739 	case -ENODEV:
15740 		printf("invalid port_id %d\n", res->port_id);
15741 		break;
15742 	case -ENOTSUP:
15743 		printf("function not implemented\n");
15744 		break;
15745 	default:
15746 		printf("programming error: (%s)\n", strerror(-ret));
15747 	}
15748 }
15749 
15750 cmdline_parse_inst_t cmd_clear_vf_stats = {
15751 	.f = cmd_clear_vf_stats_parsed,
15752 	.data = NULL,
15753 	.help_str = "clear vf stats <port_id> <vf_id>",
15754 	.tokens = {
15755 		(void *)&cmd_clear_vf_stats_clear,
15756 		(void *)&cmd_clear_vf_stats_vf,
15757 		(void *)&cmd_clear_vf_stats_stats,
15758 		(void *)&cmd_clear_vf_stats_port_id,
15759 		(void *)&cmd_clear_vf_stats_vf_id,
15760 		NULL,
15761 	},
15762 };
15763 
15764 /* port config pctype mapping reset */
15765 
15766 /* Common result structure for port config pctype mapping reset */
15767 struct cmd_pctype_mapping_reset_result {
15768 	cmdline_fixed_string_t port;
15769 	cmdline_fixed_string_t config;
15770 	portid_t port_id;
15771 	cmdline_fixed_string_t pctype;
15772 	cmdline_fixed_string_t mapping;
15773 	cmdline_fixed_string_t reset;
15774 };
15775 
15776 /* Common CLI fields for port config pctype mapping reset*/
15777 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
15778 	TOKEN_STRING_INITIALIZER
15779 		(struct cmd_pctype_mapping_reset_result,
15780 		 port, "port");
15781 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
15782 	TOKEN_STRING_INITIALIZER
15783 		(struct cmd_pctype_mapping_reset_result,
15784 		 config, "config");
15785 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
15786 	TOKEN_NUM_INITIALIZER
15787 		(struct cmd_pctype_mapping_reset_result,
15788 		 port_id, UINT16);
15789 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
15790 	TOKEN_STRING_INITIALIZER
15791 		(struct cmd_pctype_mapping_reset_result,
15792 		 pctype, "pctype");
15793 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
15794 	TOKEN_STRING_INITIALIZER
15795 		(struct cmd_pctype_mapping_reset_result,
15796 		 mapping, "mapping");
15797 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
15798 	TOKEN_STRING_INITIALIZER
15799 		(struct cmd_pctype_mapping_reset_result,
15800 		 reset, "reset");
15801 
15802 static void
15803 cmd_pctype_mapping_reset_parsed(
15804 	void *parsed_result,
15805 	__attribute__((unused)) struct cmdline *cl,
15806 	__attribute__((unused)) void *data)
15807 {
15808 	struct cmd_pctype_mapping_reset_result *res = parsed_result;
15809 	int ret = -ENOTSUP;
15810 
15811 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15812 		return;
15813 
15814 #ifdef RTE_LIBRTE_I40E_PMD
15815 	ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
15816 #endif
15817 
15818 	switch (ret) {
15819 	case 0:
15820 		break;
15821 	case -ENODEV:
15822 		printf("invalid port_id %d\n", res->port_id);
15823 		break;
15824 	case -ENOTSUP:
15825 		printf("function not implemented\n");
15826 		break;
15827 	default:
15828 		printf("programming error: (%s)\n", strerror(-ret));
15829 	}
15830 }
15831 
15832 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
15833 	.f = cmd_pctype_mapping_reset_parsed,
15834 	.data = NULL,
15835 	.help_str = "port config <port_id> pctype mapping reset",
15836 	.tokens = {
15837 		(void *)&cmd_pctype_mapping_reset_port,
15838 		(void *)&cmd_pctype_mapping_reset_config,
15839 		(void *)&cmd_pctype_mapping_reset_port_id,
15840 		(void *)&cmd_pctype_mapping_reset_pctype,
15841 		(void *)&cmd_pctype_mapping_reset_mapping,
15842 		(void *)&cmd_pctype_mapping_reset_reset,
15843 		NULL,
15844 	},
15845 };
15846 
15847 /* show port pctype mapping */
15848 
15849 /* Common result structure for show port pctype mapping */
15850 struct cmd_pctype_mapping_get_result {
15851 	cmdline_fixed_string_t show;
15852 	cmdline_fixed_string_t port;
15853 	portid_t port_id;
15854 	cmdline_fixed_string_t pctype;
15855 	cmdline_fixed_string_t mapping;
15856 };
15857 
15858 /* Common CLI fields for pctype mapping get */
15859 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
15860 	TOKEN_STRING_INITIALIZER
15861 		(struct cmd_pctype_mapping_get_result,
15862 		 show, "show");
15863 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
15864 	TOKEN_STRING_INITIALIZER
15865 		(struct cmd_pctype_mapping_get_result,
15866 		 port, "port");
15867 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
15868 	TOKEN_NUM_INITIALIZER
15869 		(struct cmd_pctype_mapping_get_result,
15870 		 port_id, UINT16);
15871 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
15872 	TOKEN_STRING_INITIALIZER
15873 		(struct cmd_pctype_mapping_get_result,
15874 		 pctype, "pctype");
15875 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
15876 	TOKEN_STRING_INITIALIZER
15877 		(struct cmd_pctype_mapping_get_result,
15878 		 mapping, "mapping");
15879 
15880 static void
15881 cmd_pctype_mapping_get_parsed(
15882 	void *parsed_result,
15883 	__attribute__((unused)) struct cmdline *cl,
15884 	__attribute__((unused)) void *data)
15885 {
15886 	struct cmd_pctype_mapping_get_result *res = parsed_result;
15887 	int ret = -ENOTSUP;
15888 #ifdef RTE_LIBRTE_I40E_PMD
15889 	struct rte_pmd_i40e_flow_type_mapping
15890 				mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
15891 	int i, j, first_pctype;
15892 #endif
15893 
15894 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15895 		return;
15896 
15897 #ifdef RTE_LIBRTE_I40E_PMD
15898 	ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
15899 #endif
15900 
15901 	switch (ret) {
15902 	case 0:
15903 		break;
15904 	case -ENODEV:
15905 		printf("invalid port_id %d\n", res->port_id);
15906 		return;
15907 	case -ENOTSUP:
15908 		printf("function not implemented\n");
15909 		return;
15910 	default:
15911 		printf("programming error: (%s)\n", strerror(-ret));
15912 		return;
15913 	}
15914 
15915 #ifdef RTE_LIBRTE_I40E_PMD
15916 	for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
15917 		if (mapping[i].pctype != 0ULL) {
15918 			first_pctype = 1;
15919 
15920 			printf("pctype: ");
15921 			for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
15922 				if (mapping[i].pctype & (1ULL << j)) {
15923 					printf(first_pctype ?
15924 					       "%02d" : ",%02d", j);
15925 					first_pctype = 0;
15926 				}
15927 			}
15928 			printf("  ->  flowtype: %02d\n", mapping[i].flow_type);
15929 		}
15930 	}
15931 #endif
15932 }
15933 
15934 cmdline_parse_inst_t cmd_pctype_mapping_get = {
15935 	.f = cmd_pctype_mapping_get_parsed,
15936 	.data = NULL,
15937 	.help_str = "show port <port_id> pctype mapping",
15938 	.tokens = {
15939 		(void *)&cmd_pctype_mapping_get_show,
15940 		(void *)&cmd_pctype_mapping_get_port,
15941 		(void *)&cmd_pctype_mapping_get_port_id,
15942 		(void *)&cmd_pctype_mapping_get_pctype,
15943 		(void *)&cmd_pctype_mapping_get_mapping,
15944 		NULL,
15945 	},
15946 };
15947 
15948 /* port config pctype mapping update */
15949 
15950 /* Common result structure for port config pctype mapping update */
15951 struct cmd_pctype_mapping_update_result {
15952 	cmdline_fixed_string_t port;
15953 	cmdline_fixed_string_t config;
15954 	portid_t port_id;
15955 	cmdline_fixed_string_t pctype;
15956 	cmdline_fixed_string_t mapping;
15957 	cmdline_fixed_string_t update;
15958 	cmdline_fixed_string_t pctype_list;
15959 	uint16_t flow_type;
15960 };
15961 
15962 /* Common CLI fields for pctype mapping update*/
15963 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
15964 	TOKEN_STRING_INITIALIZER
15965 		(struct cmd_pctype_mapping_update_result,
15966 		 port, "port");
15967 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
15968 	TOKEN_STRING_INITIALIZER
15969 		(struct cmd_pctype_mapping_update_result,
15970 		 config, "config");
15971 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
15972 	TOKEN_NUM_INITIALIZER
15973 		(struct cmd_pctype_mapping_update_result,
15974 		 port_id, UINT16);
15975 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
15976 	TOKEN_STRING_INITIALIZER
15977 		(struct cmd_pctype_mapping_update_result,
15978 		 pctype, "pctype");
15979 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
15980 	TOKEN_STRING_INITIALIZER
15981 		(struct cmd_pctype_mapping_update_result,
15982 		 mapping, "mapping");
15983 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
15984 	TOKEN_STRING_INITIALIZER
15985 		(struct cmd_pctype_mapping_update_result,
15986 		 update, "update");
15987 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
15988 	TOKEN_STRING_INITIALIZER
15989 		(struct cmd_pctype_mapping_update_result,
15990 		 pctype_list, NULL);
15991 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
15992 	TOKEN_NUM_INITIALIZER
15993 		(struct cmd_pctype_mapping_update_result,
15994 		 flow_type, UINT16);
15995 
15996 static void
15997 cmd_pctype_mapping_update_parsed(
15998 	void *parsed_result,
15999 	__attribute__((unused)) struct cmdline *cl,
16000 	__attribute__((unused)) void *data)
16001 {
16002 	struct cmd_pctype_mapping_update_result *res = parsed_result;
16003 	int ret = -ENOTSUP;
16004 #ifdef RTE_LIBRTE_I40E_PMD
16005 	struct rte_pmd_i40e_flow_type_mapping mapping;
16006 	unsigned int i;
16007 	unsigned int nb_item;
16008 	unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
16009 #endif
16010 
16011 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16012 		return;
16013 
16014 #ifdef RTE_LIBRTE_I40E_PMD
16015 	nb_item = parse_item_list(res->pctype_list, "pctypes",
16016 				  RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
16017 	mapping.flow_type = res->flow_type;
16018 	for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
16019 		mapping.pctype |= (1ULL << pctype_list[i]);
16020 	ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
16021 						&mapping,
16022 						1,
16023 						0);
16024 #endif
16025 
16026 	switch (ret) {
16027 	case 0:
16028 		break;
16029 	case -EINVAL:
16030 		printf("invalid pctype or flow type\n");
16031 		break;
16032 	case -ENODEV:
16033 		printf("invalid port_id %d\n", res->port_id);
16034 		break;
16035 	case -ENOTSUP:
16036 		printf("function not implemented\n");
16037 		break;
16038 	default:
16039 		printf("programming error: (%s)\n", strerror(-ret));
16040 	}
16041 }
16042 
16043 cmdline_parse_inst_t cmd_pctype_mapping_update = {
16044 	.f = cmd_pctype_mapping_update_parsed,
16045 	.data = NULL,
16046 	.help_str = "port config <port_id> pctype mapping update"
16047 	" <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
16048 	.tokens = {
16049 		(void *)&cmd_pctype_mapping_update_port,
16050 		(void *)&cmd_pctype_mapping_update_config,
16051 		(void *)&cmd_pctype_mapping_update_port_id,
16052 		(void *)&cmd_pctype_mapping_update_pctype,
16053 		(void *)&cmd_pctype_mapping_update_mapping,
16054 		(void *)&cmd_pctype_mapping_update_update,
16055 		(void *)&cmd_pctype_mapping_update_pc_type,
16056 		(void *)&cmd_pctype_mapping_update_flow_type,
16057 		NULL,
16058 	},
16059 };
16060 
16061 /* ptype mapping get */
16062 
16063 /* Common result structure for ptype mapping get */
16064 struct cmd_ptype_mapping_get_result {
16065 	cmdline_fixed_string_t ptype;
16066 	cmdline_fixed_string_t mapping;
16067 	cmdline_fixed_string_t get;
16068 	portid_t port_id;
16069 	uint8_t valid_only;
16070 };
16071 
16072 /* Common CLI fields for ptype mapping get */
16073 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
16074 	TOKEN_STRING_INITIALIZER
16075 		(struct cmd_ptype_mapping_get_result,
16076 		 ptype, "ptype");
16077 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
16078 	TOKEN_STRING_INITIALIZER
16079 		(struct cmd_ptype_mapping_get_result,
16080 		 mapping, "mapping");
16081 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
16082 	TOKEN_STRING_INITIALIZER
16083 		(struct cmd_ptype_mapping_get_result,
16084 		 get, "get");
16085 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
16086 	TOKEN_NUM_INITIALIZER
16087 		(struct cmd_ptype_mapping_get_result,
16088 		 port_id, UINT16);
16089 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
16090 	TOKEN_NUM_INITIALIZER
16091 		(struct cmd_ptype_mapping_get_result,
16092 		 valid_only, UINT8);
16093 
16094 static void
16095 cmd_ptype_mapping_get_parsed(
16096 	void *parsed_result,
16097 	__attribute__((unused)) struct cmdline *cl,
16098 	__attribute__((unused)) void *data)
16099 {
16100 	struct cmd_ptype_mapping_get_result *res = parsed_result;
16101 	int ret = -ENOTSUP;
16102 #ifdef RTE_LIBRTE_I40E_PMD
16103 	int max_ptype_num = 256;
16104 	struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
16105 	uint16_t count;
16106 	int i;
16107 #endif
16108 
16109 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16110 		return;
16111 
16112 #ifdef RTE_LIBRTE_I40E_PMD
16113 	ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
16114 					mapping,
16115 					max_ptype_num,
16116 					&count,
16117 					res->valid_only);
16118 #endif
16119 
16120 	switch (ret) {
16121 	case 0:
16122 		break;
16123 	case -ENODEV:
16124 		printf("invalid port_id %d\n", res->port_id);
16125 		break;
16126 	case -ENOTSUP:
16127 		printf("function not implemented\n");
16128 		break;
16129 	default:
16130 		printf("programming error: (%s)\n", strerror(-ret));
16131 	}
16132 
16133 #ifdef RTE_LIBRTE_I40E_PMD
16134 	if (!ret) {
16135 		for (i = 0; i < count; i++)
16136 			printf("%3d\t0x%08x\n",
16137 				mapping[i].hw_ptype, mapping[i].sw_ptype);
16138 	}
16139 #endif
16140 }
16141 
16142 cmdline_parse_inst_t cmd_ptype_mapping_get = {
16143 	.f = cmd_ptype_mapping_get_parsed,
16144 	.data = NULL,
16145 	.help_str = "ptype mapping get <port_id> <valid_only>",
16146 	.tokens = {
16147 		(void *)&cmd_ptype_mapping_get_ptype,
16148 		(void *)&cmd_ptype_mapping_get_mapping,
16149 		(void *)&cmd_ptype_mapping_get_get,
16150 		(void *)&cmd_ptype_mapping_get_port_id,
16151 		(void *)&cmd_ptype_mapping_get_valid_only,
16152 		NULL,
16153 	},
16154 };
16155 
16156 /* ptype mapping replace */
16157 
16158 /* Common result structure for ptype mapping replace */
16159 struct cmd_ptype_mapping_replace_result {
16160 	cmdline_fixed_string_t ptype;
16161 	cmdline_fixed_string_t mapping;
16162 	cmdline_fixed_string_t replace;
16163 	portid_t port_id;
16164 	uint32_t target;
16165 	uint8_t mask;
16166 	uint32_t pkt_type;
16167 };
16168 
16169 /* Common CLI fields for ptype mapping replace */
16170 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
16171 	TOKEN_STRING_INITIALIZER
16172 		(struct cmd_ptype_mapping_replace_result,
16173 		 ptype, "ptype");
16174 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
16175 	TOKEN_STRING_INITIALIZER
16176 		(struct cmd_ptype_mapping_replace_result,
16177 		 mapping, "mapping");
16178 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
16179 	TOKEN_STRING_INITIALIZER
16180 		(struct cmd_ptype_mapping_replace_result,
16181 		 replace, "replace");
16182 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
16183 	TOKEN_NUM_INITIALIZER
16184 		(struct cmd_ptype_mapping_replace_result,
16185 		 port_id, UINT16);
16186 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
16187 	TOKEN_NUM_INITIALIZER
16188 		(struct cmd_ptype_mapping_replace_result,
16189 		 target, UINT32);
16190 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
16191 	TOKEN_NUM_INITIALIZER
16192 		(struct cmd_ptype_mapping_replace_result,
16193 		 mask, UINT8);
16194 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
16195 	TOKEN_NUM_INITIALIZER
16196 		(struct cmd_ptype_mapping_replace_result,
16197 		 pkt_type, UINT32);
16198 
16199 static void
16200 cmd_ptype_mapping_replace_parsed(
16201 	void *parsed_result,
16202 	__attribute__((unused)) struct cmdline *cl,
16203 	__attribute__((unused)) void *data)
16204 {
16205 	struct cmd_ptype_mapping_replace_result *res = parsed_result;
16206 	int ret = -ENOTSUP;
16207 
16208 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16209 		return;
16210 
16211 #ifdef RTE_LIBRTE_I40E_PMD
16212 	ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
16213 					res->target,
16214 					res->mask,
16215 					res->pkt_type);
16216 #endif
16217 
16218 	switch (ret) {
16219 	case 0:
16220 		break;
16221 	case -EINVAL:
16222 		printf("invalid ptype 0x%8x or 0x%8x\n",
16223 				res->target, res->pkt_type);
16224 		break;
16225 	case -ENODEV:
16226 		printf("invalid port_id %d\n", res->port_id);
16227 		break;
16228 	case -ENOTSUP:
16229 		printf("function not implemented\n");
16230 		break;
16231 	default:
16232 		printf("programming error: (%s)\n", strerror(-ret));
16233 	}
16234 }
16235 
16236 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
16237 	.f = cmd_ptype_mapping_replace_parsed,
16238 	.data = NULL,
16239 	.help_str =
16240 		"ptype mapping replace <port_id> <target> <mask> <pkt_type>",
16241 	.tokens = {
16242 		(void *)&cmd_ptype_mapping_replace_ptype,
16243 		(void *)&cmd_ptype_mapping_replace_mapping,
16244 		(void *)&cmd_ptype_mapping_replace_replace,
16245 		(void *)&cmd_ptype_mapping_replace_port_id,
16246 		(void *)&cmd_ptype_mapping_replace_target,
16247 		(void *)&cmd_ptype_mapping_replace_mask,
16248 		(void *)&cmd_ptype_mapping_replace_pkt_type,
16249 		NULL,
16250 	},
16251 };
16252 
16253 /* ptype mapping reset */
16254 
16255 /* Common result structure for ptype mapping reset */
16256 struct cmd_ptype_mapping_reset_result {
16257 	cmdline_fixed_string_t ptype;
16258 	cmdline_fixed_string_t mapping;
16259 	cmdline_fixed_string_t reset;
16260 	portid_t port_id;
16261 };
16262 
16263 /* Common CLI fields for ptype mapping reset*/
16264 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
16265 	TOKEN_STRING_INITIALIZER
16266 		(struct cmd_ptype_mapping_reset_result,
16267 		 ptype, "ptype");
16268 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
16269 	TOKEN_STRING_INITIALIZER
16270 		(struct cmd_ptype_mapping_reset_result,
16271 		 mapping, "mapping");
16272 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
16273 	TOKEN_STRING_INITIALIZER
16274 		(struct cmd_ptype_mapping_reset_result,
16275 		 reset, "reset");
16276 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
16277 	TOKEN_NUM_INITIALIZER
16278 		(struct cmd_ptype_mapping_reset_result,
16279 		 port_id, UINT16);
16280 
16281 static void
16282 cmd_ptype_mapping_reset_parsed(
16283 	void *parsed_result,
16284 	__attribute__((unused)) struct cmdline *cl,
16285 	__attribute__((unused)) void *data)
16286 {
16287 	struct cmd_ptype_mapping_reset_result *res = parsed_result;
16288 	int ret = -ENOTSUP;
16289 
16290 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16291 		return;
16292 
16293 #ifdef RTE_LIBRTE_I40E_PMD
16294 	ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
16295 #endif
16296 
16297 	switch (ret) {
16298 	case 0:
16299 		break;
16300 	case -ENODEV:
16301 		printf("invalid port_id %d\n", res->port_id);
16302 		break;
16303 	case -ENOTSUP:
16304 		printf("function not implemented\n");
16305 		break;
16306 	default:
16307 		printf("programming error: (%s)\n", strerror(-ret));
16308 	}
16309 }
16310 
16311 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
16312 	.f = cmd_ptype_mapping_reset_parsed,
16313 	.data = NULL,
16314 	.help_str = "ptype mapping reset <port_id>",
16315 	.tokens = {
16316 		(void *)&cmd_ptype_mapping_reset_ptype,
16317 		(void *)&cmd_ptype_mapping_reset_mapping,
16318 		(void *)&cmd_ptype_mapping_reset_reset,
16319 		(void *)&cmd_ptype_mapping_reset_port_id,
16320 		NULL,
16321 	},
16322 };
16323 
16324 /* ptype mapping update */
16325 
16326 /* Common result structure for ptype mapping update */
16327 struct cmd_ptype_mapping_update_result {
16328 	cmdline_fixed_string_t ptype;
16329 	cmdline_fixed_string_t mapping;
16330 	cmdline_fixed_string_t reset;
16331 	portid_t port_id;
16332 	uint8_t hw_ptype;
16333 	uint32_t sw_ptype;
16334 };
16335 
16336 /* Common CLI fields for ptype mapping update*/
16337 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
16338 	TOKEN_STRING_INITIALIZER
16339 		(struct cmd_ptype_mapping_update_result,
16340 		 ptype, "ptype");
16341 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
16342 	TOKEN_STRING_INITIALIZER
16343 		(struct cmd_ptype_mapping_update_result,
16344 		 mapping, "mapping");
16345 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
16346 	TOKEN_STRING_INITIALIZER
16347 		(struct cmd_ptype_mapping_update_result,
16348 		 reset, "update");
16349 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
16350 	TOKEN_NUM_INITIALIZER
16351 		(struct cmd_ptype_mapping_update_result,
16352 		 port_id, UINT16);
16353 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
16354 	TOKEN_NUM_INITIALIZER
16355 		(struct cmd_ptype_mapping_update_result,
16356 		 hw_ptype, UINT8);
16357 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
16358 	TOKEN_NUM_INITIALIZER
16359 		(struct cmd_ptype_mapping_update_result,
16360 		 sw_ptype, UINT32);
16361 
16362 static void
16363 cmd_ptype_mapping_update_parsed(
16364 	void *parsed_result,
16365 	__attribute__((unused)) struct cmdline *cl,
16366 	__attribute__((unused)) void *data)
16367 {
16368 	struct cmd_ptype_mapping_update_result *res = parsed_result;
16369 	int ret = -ENOTSUP;
16370 #ifdef RTE_LIBRTE_I40E_PMD
16371 	struct rte_pmd_i40e_ptype_mapping mapping;
16372 #endif
16373 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16374 		return;
16375 
16376 #ifdef RTE_LIBRTE_I40E_PMD
16377 	mapping.hw_ptype = res->hw_ptype;
16378 	mapping.sw_ptype = res->sw_ptype;
16379 	ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
16380 						&mapping,
16381 						1,
16382 						0);
16383 #endif
16384 
16385 	switch (ret) {
16386 	case 0:
16387 		break;
16388 	case -EINVAL:
16389 		printf("invalid ptype 0x%8x\n", res->sw_ptype);
16390 		break;
16391 	case -ENODEV:
16392 		printf("invalid port_id %d\n", res->port_id);
16393 		break;
16394 	case -ENOTSUP:
16395 		printf("function not implemented\n");
16396 		break;
16397 	default:
16398 		printf("programming error: (%s)\n", strerror(-ret));
16399 	}
16400 }
16401 
16402 cmdline_parse_inst_t cmd_ptype_mapping_update = {
16403 	.f = cmd_ptype_mapping_update_parsed,
16404 	.data = NULL,
16405 	.help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
16406 	.tokens = {
16407 		(void *)&cmd_ptype_mapping_update_ptype,
16408 		(void *)&cmd_ptype_mapping_update_mapping,
16409 		(void *)&cmd_ptype_mapping_update_update,
16410 		(void *)&cmd_ptype_mapping_update_port_id,
16411 		(void *)&cmd_ptype_mapping_update_hw_ptype,
16412 		(void *)&cmd_ptype_mapping_update_sw_ptype,
16413 		NULL,
16414 	},
16415 };
16416 
16417 /* Common result structure for file commands */
16418 struct cmd_cmdfile_result {
16419 	cmdline_fixed_string_t load;
16420 	cmdline_fixed_string_t filename;
16421 };
16422 
16423 /* Common CLI fields for file commands */
16424 cmdline_parse_token_string_t cmd_load_cmdfile =
16425 	TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
16426 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
16427 	TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
16428 
16429 static void
16430 cmd_load_from_file_parsed(
16431 	void *parsed_result,
16432 	__attribute__((unused)) struct cmdline *cl,
16433 	__attribute__((unused)) void *data)
16434 {
16435 	struct cmd_cmdfile_result *res = parsed_result;
16436 
16437 	cmdline_read_from_file(res->filename);
16438 }
16439 
16440 cmdline_parse_inst_t cmd_load_from_file = {
16441 	.f = cmd_load_from_file_parsed,
16442 	.data = NULL,
16443 	.help_str = "load <filename>",
16444 	.tokens = {
16445 		(void *)&cmd_load_cmdfile,
16446 		(void *)&cmd_load_cmdfile_filename,
16447 		NULL,
16448 	},
16449 };
16450 
16451 /* ******************************************************************************** */
16452 
16453 /* list of instructions */
16454 cmdline_parse_ctx_t main_ctx[] = {
16455 	(cmdline_parse_inst_t *)&cmd_help_brief,
16456 	(cmdline_parse_inst_t *)&cmd_help_long,
16457 	(cmdline_parse_inst_t *)&cmd_quit,
16458 	(cmdline_parse_inst_t *)&cmd_load_from_file,
16459 	(cmdline_parse_inst_t *)&cmd_showport,
16460 	(cmdline_parse_inst_t *)&cmd_showqueue,
16461 	(cmdline_parse_inst_t *)&cmd_showportall,
16462 	(cmdline_parse_inst_t *)&cmd_showcfg,
16463 	(cmdline_parse_inst_t *)&cmd_start,
16464 	(cmdline_parse_inst_t *)&cmd_start_tx_first,
16465 	(cmdline_parse_inst_t *)&cmd_start_tx_first_n,
16466 	(cmdline_parse_inst_t *)&cmd_set_link_up,
16467 	(cmdline_parse_inst_t *)&cmd_set_link_down,
16468 	(cmdline_parse_inst_t *)&cmd_reset,
16469 	(cmdline_parse_inst_t *)&cmd_set_numbers,
16470 	(cmdline_parse_inst_t *)&cmd_set_log,
16471 	(cmdline_parse_inst_t *)&cmd_set_txpkts,
16472 	(cmdline_parse_inst_t *)&cmd_set_txsplit,
16473 	(cmdline_parse_inst_t *)&cmd_set_fwd_list,
16474 	(cmdline_parse_inst_t *)&cmd_set_fwd_mask,
16475 	(cmdline_parse_inst_t *)&cmd_set_fwd_mode,
16476 	(cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
16477 	(cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
16478 	(cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
16479 	(cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
16480 	(cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
16481 	(cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
16482 	(cmdline_parse_inst_t *)&cmd_set_flush_rx,
16483 	(cmdline_parse_inst_t *)&cmd_set_link_check,
16484 	(cmdline_parse_inst_t *)&cmd_set_bypass_mode,
16485 	(cmdline_parse_inst_t *)&cmd_set_bypass_event,
16486 	(cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
16487 	(cmdline_parse_inst_t *)&cmd_show_bypass_config,
16488 #ifdef RTE_LIBRTE_PMD_BOND
16489 	(cmdline_parse_inst_t *) &cmd_set_bonding_mode,
16490 	(cmdline_parse_inst_t *) &cmd_show_bonding_config,
16491 	(cmdline_parse_inst_t *) &cmd_set_bonding_primary,
16492 	(cmdline_parse_inst_t *) &cmd_add_bonding_slave,
16493 	(cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
16494 	(cmdline_parse_inst_t *) &cmd_create_bonded_device,
16495 	(cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
16496 	(cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
16497 	(cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
16498 	(cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
16499 	(cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
16500 #endif
16501 	(cmdline_parse_inst_t *)&cmd_vlan_offload,
16502 	(cmdline_parse_inst_t *)&cmd_vlan_tpid,
16503 	(cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
16504 	(cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
16505 	(cmdline_parse_inst_t *)&cmd_tx_vlan_set,
16506 	(cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
16507 	(cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
16508 	(cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
16509 	(cmdline_parse_inst_t *)&cmd_csum_set,
16510 	(cmdline_parse_inst_t *)&cmd_csum_show,
16511 	(cmdline_parse_inst_t *)&cmd_csum_tunnel,
16512 	(cmdline_parse_inst_t *)&cmd_tso_set,
16513 	(cmdline_parse_inst_t *)&cmd_tso_show,
16514 	(cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
16515 	(cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
16516 	(cmdline_parse_inst_t *)&cmd_gro_enable,
16517 	(cmdline_parse_inst_t *)&cmd_gro_flush,
16518 	(cmdline_parse_inst_t *)&cmd_gro_show,
16519 	(cmdline_parse_inst_t *)&cmd_gso_enable,
16520 	(cmdline_parse_inst_t *)&cmd_gso_size,
16521 	(cmdline_parse_inst_t *)&cmd_gso_show,
16522 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set,
16523 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
16524 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
16525 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
16526 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
16527 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
16528 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
16529 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
16530 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
16531 	(cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
16532 	(cmdline_parse_inst_t *)&cmd_config_dcb,
16533 	(cmdline_parse_inst_t *)&cmd_read_reg,
16534 	(cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
16535 	(cmdline_parse_inst_t *)&cmd_read_reg_bit,
16536 	(cmdline_parse_inst_t *)&cmd_write_reg,
16537 	(cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
16538 	(cmdline_parse_inst_t *)&cmd_write_reg_bit,
16539 	(cmdline_parse_inst_t *)&cmd_read_rxd_txd,
16540 	(cmdline_parse_inst_t *)&cmd_stop,
16541 	(cmdline_parse_inst_t *)&cmd_mac_addr,
16542 	(cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
16543 	(cmdline_parse_inst_t *)&cmd_set_qmap,
16544 	(cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
16545 	(cmdline_parse_inst_t *)&cmd_operate_port,
16546 	(cmdline_parse_inst_t *)&cmd_operate_specific_port,
16547 	(cmdline_parse_inst_t *)&cmd_operate_attach_port,
16548 	(cmdline_parse_inst_t *)&cmd_operate_detach_port,
16549 	(cmdline_parse_inst_t *)&cmd_config_speed_all,
16550 	(cmdline_parse_inst_t *)&cmd_config_speed_specific,
16551 	(cmdline_parse_inst_t *)&cmd_config_loopback_all,
16552 	(cmdline_parse_inst_t *)&cmd_config_loopback_specific,
16553 	(cmdline_parse_inst_t *)&cmd_config_rx_tx,
16554 	(cmdline_parse_inst_t *)&cmd_config_mtu,
16555 	(cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
16556 	(cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
16557 	(cmdline_parse_inst_t *)&cmd_config_rss,
16558 	(cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
16559 	(cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
16560 	(cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
16561 	(cmdline_parse_inst_t *)&cmd_config_rss_reta,
16562 	(cmdline_parse_inst_t *)&cmd_showport_reta,
16563 	(cmdline_parse_inst_t *)&cmd_config_burst,
16564 	(cmdline_parse_inst_t *)&cmd_config_thresh,
16565 	(cmdline_parse_inst_t *)&cmd_config_threshold,
16566 	(cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
16567 	(cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
16568 	(cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
16569 	(cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
16570 	(cmdline_parse_inst_t *)&cmd_queue_rate_limit,
16571 	(cmdline_parse_inst_t *)&cmd_tunnel_filter,
16572 	(cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
16573 	(cmdline_parse_inst_t *)&cmd_global_config,
16574 	(cmdline_parse_inst_t *)&cmd_set_mirror_mask,
16575 	(cmdline_parse_inst_t *)&cmd_set_mirror_link,
16576 	(cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
16577 	(cmdline_parse_inst_t *)&cmd_showport_rss_hash,
16578 	(cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
16579 	(cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
16580 	(cmdline_parse_inst_t *)&cmd_dump,
16581 	(cmdline_parse_inst_t *)&cmd_dump_one,
16582 	(cmdline_parse_inst_t *)&cmd_ethertype_filter,
16583 	(cmdline_parse_inst_t *)&cmd_syn_filter,
16584 	(cmdline_parse_inst_t *)&cmd_2tuple_filter,
16585 	(cmdline_parse_inst_t *)&cmd_5tuple_filter,
16586 	(cmdline_parse_inst_t *)&cmd_flex_filter,
16587 	(cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
16588 	(cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
16589 	(cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
16590 	(cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
16591 	(cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
16592 	(cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
16593 	(cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
16594 	(cmdline_parse_inst_t *)&cmd_flush_flow_director,
16595 	(cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
16596 	(cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
16597 	(cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
16598 	(cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
16599 	(cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
16600 	(cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
16601 	(cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
16602 	(cmdline_parse_inst_t *)&cmd_get_hash_global_config,
16603 	(cmdline_parse_inst_t *)&cmd_set_hash_global_config,
16604 	(cmdline_parse_inst_t *)&cmd_set_hash_input_set,
16605 	(cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
16606 	(cmdline_parse_inst_t *)&cmd_flow,
16607 	(cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
16608 	(cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
16609 	(cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
16610 	(cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
16611 	(cmdline_parse_inst_t *)&cmd_create_port_meter,
16612 	(cmdline_parse_inst_t *)&cmd_enable_port_meter,
16613 	(cmdline_parse_inst_t *)&cmd_disable_port_meter,
16614 	(cmdline_parse_inst_t *)&cmd_del_port_meter,
16615 	(cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
16616 	(cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
16617 	(cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
16618 	(cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
16619 	(cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
16620 	(cmdline_parse_inst_t *)&cmd_mcast_addr,
16621 	(cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
16622 	(cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
16623 	(cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
16624 	(cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
16625 	(cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
16626 	(cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
16627 	(cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
16628 	(cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
16629 	(cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
16630 	(cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
16631 	(cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
16632 	(cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
16633 	(cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
16634 	(cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
16635 	(cmdline_parse_inst_t *)&cmd_set_tx_loopback,
16636 	(cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
16637 	(cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
16638 	(cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
16639 	(cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
16640 	(cmdline_parse_inst_t *)&cmd_set_macsec_sc,
16641 	(cmdline_parse_inst_t *)&cmd_set_macsec_sa,
16642 	(cmdline_parse_inst_t *)&cmd_set_vf_traffic,
16643 	(cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
16644 	(cmdline_parse_inst_t *)&cmd_vf_rate_limit,
16645 	(cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
16646 	(cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
16647 	(cmdline_parse_inst_t *)&cmd_set_vf_promisc,
16648 	(cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
16649 	(cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
16650 	(cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
16651 	(cmdline_parse_inst_t *)&cmd_vf_max_bw,
16652 	(cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
16653 	(cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
16654 	(cmdline_parse_inst_t *)&cmd_strict_link_prio,
16655 	(cmdline_parse_inst_t *)&cmd_tc_min_bw,
16656 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
16657 	(cmdline_parse_inst_t *)&cmd_set_port_tm_hierarchy_default,
16658 #endif
16659 	(cmdline_parse_inst_t *)&cmd_ddp_add,
16660 	(cmdline_parse_inst_t *)&cmd_ddp_del,
16661 	(cmdline_parse_inst_t *)&cmd_ddp_get_list,
16662 	(cmdline_parse_inst_t *)&cmd_ddp_get_info,
16663 	(cmdline_parse_inst_t *)&cmd_cfg_input_set,
16664 	(cmdline_parse_inst_t *)&cmd_clear_input_set,
16665 	(cmdline_parse_inst_t *)&cmd_show_vf_stats,
16666 	(cmdline_parse_inst_t *)&cmd_clear_vf_stats,
16667 	(cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
16668 	(cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
16669 	(cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
16670 	(cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
16671 
16672 	(cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
16673 	(cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
16674 	(cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
16675 	(cmdline_parse_inst_t *)&cmd_queue_region,
16676 	(cmdline_parse_inst_t *)&cmd_region_flowtype,
16677 	(cmdline_parse_inst_t *)&cmd_user_priority_region,
16678 	(cmdline_parse_inst_t *)&cmd_flush_queue_region,
16679 	(cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
16680 	(cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
16681 	(cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
16682 	(cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
16683 	(cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
16684 	(cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
16685 	(cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
16686 	(cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
16687 	(cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
16688 	(cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
16689 	(cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
16690 	(cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
16691 	(cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
16692 	(cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
16693 	(cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
16694 	(cmdline_parse_inst_t *)&cmd_del_port_tm_node,
16695 	(cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
16696 	(cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
16697 	(cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
16698 	NULL,
16699 };
16700 
16701 /* read cmdline commands from file */
16702 void
16703 cmdline_read_from_file(const char *filename)
16704 {
16705 	struct cmdline *cl;
16706 
16707 	cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
16708 	if (cl == NULL) {
16709 		printf("Failed to create file based cmdline context: %s\n",
16710 		       filename);
16711 		return;
16712 	}
16713 
16714 	cmdline_interact(cl);
16715 	cmdline_quit(cl);
16716 
16717 	cmdline_free(cl);
16718 
16719 	printf("Read CLI commands from %s\n", filename);
16720 }
16721 
16722 /* prompt function, called from main on MASTER lcore */
16723 void
16724 prompt(void)
16725 {
16726 	/* initialize non-constant commands */
16727 	cmd_set_fwd_mode_init();
16728 	cmd_set_fwd_retry_mode_init();
16729 
16730 	testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
16731 	if (testpmd_cl == NULL)
16732 		return;
16733 	cmdline_interact(testpmd_cl);
16734 	cmdline_stdin_exit(testpmd_cl);
16735 }
16736 
16737 void
16738 prompt_exit(void)
16739 {
16740 	if (testpmd_cl != NULL)
16741 		cmdline_quit(testpmd_cl);
16742 }
16743 
16744 static void
16745 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
16746 {
16747 	if (id == (portid_t)RTE_PORT_ALL) {
16748 		portid_t pid;
16749 
16750 		RTE_ETH_FOREACH_DEV(pid) {
16751 			/* check if need_reconfig has been set to 1 */
16752 			if (ports[pid].need_reconfig == 0)
16753 				ports[pid].need_reconfig = dev;
16754 			/* check if need_reconfig_queues has been set to 1 */
16755 			if (ports[pid].need_reconfig_queues == 0)
16756 				ports[pid].need_reconfig_queues = queue;
16757 		}
16758 	} else if (!port_id_is_invalid(id, DISABLED_WARN)) {
16759 		/* check if need_reconfig has been set to 1 */
16760 		if (ports[id].need_reconfig == 0)
16761 			ports[id].need_reconfig = dev;
16762 		/* check if need_reconfig_queues has been set to 1 */
16763 		if (ports[id].need_reconfig_queues == 0)
16764 			ports[id].need_reconfig_queues = queue;
16765 	}
16766 }
16767