xref: /dpdk/app/test-pmd/cmdline.c (revision 25d11a86c56d50947af33d0b79ede622809bd8b9)
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 #include "bpf_cmd.h"
79 
80 static struct cmdline *testpmd_cl;
81 
82 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
83 
84 /* *** Help command with introduction. *** */
85 struct cmd_help_brief_result {
86 	cmdline_fixed_string_t help;
87 };
88 
89 static void cmd_help_brief_parsed(__attribute__((unused)) void *parsed_result,
90                                   struct cmdline *cl,
91                                   __attribute__((unused)) void *data)
92 {
93 	cmdline_printf(
94 		cl,
95 		"\n"
96 		"Help is available for the following sections:\n\n"
97 		"    help control    : Start and stop forwarding.\n"
98 		"    help display    : Displaying port, stats and config "
99 		"information.\n"
100 		"    help config     : Configuration information.\n"
101 		"    help ports      : Configuring ports.\n"
102 		"    help registers  : Reading and setting port registers.\n"
103 		"    help filters    : Filters configuration help.\n"
104 		"    help all        : All of the above sections.\n\n"
105 	);
106 
107 }
108 
109 cmdline_parse_token_string_t cmd_help_brief_help =
110 	TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
111 
112 cmdline_parse_inst_t cmd_help_brief = {
113 	.f = cmd_help_brief_parsed,
114 	.data = NULL,
115 	.help_str = "help: Show help",
116 	.tokens = {
117 		(void *)&cmd_help_brief_help,
118 		NULL,
119 	},
120 };
121 
122 /* *** Help command with help sections. *** */
123 struct cmd_help_long_result {
124 	cmdline_fixed_string_t help;
125 	cmdline_fixed_string_t section;
126 };
127 
128 static void cmd_help_long_parsed(void *parsed_result,
129                                  struct cmdline *cl,
130                                  __attribute__((unused)) void *data)
131 {
132 	int show_all = 0;
133 	struct cmd_help_long_result *res = parsed_result;
134 
135 	if (!strcmp(res->section, "all"))
136 		show_all = 1;
137 
138 	if (show_all || !strcmp(res->section, "control")) {
139 
140 		cmdline_printf(
141 			cl,
142 			"\n"
143 			"Control forwarding:\n"
144 			"-------------------\n\n"
145 
146 			"start\n"
147 			"    Start packet forwarding with current configuration.\n\n"
148 
149 			"start tx_first\n"
150 			"    Start packet forwarding with current config"
151 			" after sending one burst of packets.\n\n"
152 
153 			"stop\n"
154 			"    Stop packet forwarding, and display accumulated"
155 			" statistics.\n\n"
156 
157 			"quit\n"
158 			"    Quit to prompt.\n\n"
159 		);
160 	}
161 
162 	if (show_all || !strcmp(res->section, "display")) {
163 
164 		cmdline_printf(
165 			cl,
166 			"\n"
167 			"Display:\n"
168 			"--------\n\n"
169 
170 			"show port (info|stats|summary|xstats|fdir|stat_qmap|dcb_tc|cap) (port_id|all)\n"
171 			"    Display information for port_id, or all.\n\n"
172 
173 			"show port X rss reta (size) (mask0,mask1,...)\n"
174 			"    Display the rss redirection table entry indicated"
175 			" by masks on port X. size is used to indicate the"
176 			" hardware supported reta size\n\n"
177 
178 			"show port (port_id) rss-hash [key]\n"
179 			"    Display the RSS hash functions and RSS hash key of port\n\n"
180 
181 			"clear port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n"
182 			"    Clear information for port_id, or all.\n\n"
183 
184 			"show (rxq|txq) info (port_id) (queue_id)\n"
185 			"    Display information for configured RX/TX queue.\n\n"
186 
187 			"show config (rxtx|cores|fwd|txpkts)\n"
188 			"    Display the given configuration.\n\n"
189 
190 			"read rxd (port_id) (queue_id) (rxd_id)\n"
191 			"    Display an RX descriptor of a port RX queue.\n\n"
192 
193 			"read txd (port_id) (queue_id) (txd_id)\n"
194 			"    Display a TX descriptor of a port TX queue.\n\n"
195 
196 			"ddp get list (port_id)\n"
197 			"    Get ddp profile info list\n\n"
198 
199 			"ddp get info (profile_path)\n"
200 			"    Get ddp profile information.\n\n"
201 
202 			"show vf stats (port_id) (vf_id)\n"
203 			"    Display a VF's statistics.\n\n"
204 
205 			"clear vf stats (port_id) (vf_id)\n"
206 			"    Reset a VF's statistics.\n\n"
207 
208 			"show port (port_id) pctype mapping\n"
209 			"    Get flow ptype to pctype mapping on a port\n\n"
210 
211 			"show port meter stats (port_id) (meter_id) (clear)\n"
212 			"    Get meter stats on a port\n\n"
213                         "show port tm cap (port_id)\n"
214                         "       Display the port TM capability.\n\n"
215 
216                         "show port tm level cap (port_id) (level_id)\n"
217                         "       Display the port TM hierarchical level capability.\n\n"
218 
219                         "show port tm node cap (port_id) (node_id)\n"
220                         "       Display the port TM node capability.\n\n"
221 
222                         "show port tm node type (port_id) (node_id)\n"
223                         "       Display the port TM node type.\n\n"
224 
225                         "show port tm node stats (port_id) (node_id) (clear)\n"
226                         "       Display the port TM node stats.\n\n"
227 
228 		);
229 	}
230 
231 	if (show_all || !strcmp(res->section, "config")) {
232 		cmdline_printf(
233 			cl,
234 			"\n"
235 			"Configuration:\n"
236 			"--------------\n"
237 			"Configuration changes only become active when"
238 			" forwarding is started/restarted.\n\n"
239 
240 			"set default\n"
241 			"    Reset forwarding to the default configuration.\n\n"
242 
243 			"set verbose (level)\n"
244 			"    Set the debug verbosity level X.\n\n"
245 
246 			"set log global|(type) (level)\n"
247 			"    Set the log level.\n\n"
248 
249 			"set nbport (num)\n"
250 			"    Set number of ports.\n\n"
251 
252 			"set nbcore (num)\n"
253 			"    Set number of cores.\n\n"
254 
255 			"set coremask (mask)\n"
256 			"    Set the forwarding cores hexadecimal mask.\n\n"
257 
258 			"set portmask (mask)\n"
259 			"    Set the forwarding ports hexadecimal mask.\n\n"
260 
261 			"set burst (num)\n"
262 			"    Set number of packets per burst.\n\n"
263 
264 			"set burst tx delay (microseconds) retry (num)\n"
265 			"    Set the transmit delay time and number of retries,"
266 			" effective when retry is enabled.\n\n"
267 
268 			"set txpkts (x[,y]*)\n"
269 			"    Set the length of each segment of TXONLY"
270 			" and optionally CSUM packets.\n\n"
271 
272 			"set txsplit (off|on|rand)\n"
273 			"    Set the split policy for the TX packets."
274 			" Right now only applicable for CSUM and TXONLY"
275 			" modes\n\n"
276 
277 			"set corelist (x[,y]*)\n"
278 			"    Set the list of forwarding cores.\n\n"
279 
280 			"set portlist (x[,y]*)\n"
281 			"    Set the list of forwarding ports.\n\n"
282 
283 			"set port setup on (iterator|event)\n"
284 			"    Select how attached port is retrieved for setup.\n\n"
285 
286 			"set tx loopback (port_id) (on|off)\n"
287 			"    Enable or disable tx loopback.\n\n"
288 
289 			"set all queues drop (port_id) (on|off)\n"
290 			"    Set drop enable bit for all queues.\n\n"
291 
292 			"set vf split drop (port_id) (vf_id) (on|off)\n"
293 			"    Set split drop enable bit for a VF from the PF.\n\n"
294 
295 			"set vf mac antispoof (port_id) (vf_id) (on|off).\n"
296 			"    Set MAC antispoof for a VF from the PF.\n\n"
297 
298 			"set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n"
299 			"    Enable MACsec offload.\n\n"
300 
301 			"set macsec offload (port_id) off\n"
302 			"    Disable MACsec offload.\n\n"
303 
304 			"set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
305 			"    Configure MACsec secure connection (SC).\n\n"
306 
307 			"set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n"
308 			"    Configure MACsec secure association (SA).\n\n"
309 
310 			"set vf broadcast (port_id) (vf_id) (on|off)\n"
311 			"    Set VF broadcast for a VF from the PF.\n\n"
312 
313 			"vlan set strip (on|off) (port_id)\n"
314 			"    Set the VLAN strip on a port.\n\n"
315 
316 			"vlan set stripq (on|off) (port_id,queue_id)\n"
317 			"    Set the VLAN strip for a queue on a port.\n\n"
318 
319 			"set vf vlan stripq (port_id) (vf_id) (on|off)\n"
320 			"    Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
321 
322 			"set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
323 			"    Set VLAN insert for a VF from the PF.\n\n"
324 
325 			"set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
326 			"    Set VLAN antispoof for a VF from the PF.\n\n"
327 
328 			"set vf vlan tag (port_id) (vf_id) (on|off)\n"
329 			"    Set VLAN tag for a VF from the PF.\n\n"
330 
331 			"set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n"
332 			"    Set a VF's max bandwidth(Mbps).\n\n"
333 
334 			"set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n"
335 			"    Set all TCs' min bandwidth(%%) on a VF.\n\n"
336 
337 			"set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n"
338 			"    Set a TC's max bandwidth(Mbps) on a VF.\n\n"
339 
340 			"set tx strict-link-priority (port_id) (tc_bitmap)\n"
341 			"    Set some TCs' strict link priority mode on a physical port.\n\n"
342 
343 			"set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n"
344 			"    Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n"
345 
346 			"vlan set filter (on|off) (port_id)\n"
347 			"    Set the VLAN filter on a port.\n\n"
348 
349 			"vlan set qinq (on|off) (port_id)\n"
350 			"    Set the VLAN QinQ (extended queue in queue)"
351 			" on a port.\n\n"
352 
353 			"vlan set (inner|outer) tpid (value) (port_id)\n"
354 			"    Set the VLAN TPID for Packet Filtering on"
355 			" a port\n\n"
356 
357 			"rx_vlan add (vlan_id|all) (port_id)\n"
358 			"    Add a vlan_id, or all identifiers, to the set"
359 			" of VLAN identifiers filtered by port_id.\n\n"
360 
361 			"rx_vlan rm (vlan_id|all) (port_id)\n"
362 			"    Remove a vlan_id, or all identifiers, from the set"
363 			" of VLAN identifiers filtered by port_id.\n\n"
364 
365 			"rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
366 			"    Add a vlan_id, to the set of VLAN identifiers"
367 			"filtered for VF(s) from port_id.\n\n"
368 
369 			"rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
370 			"    Remove a vlan_id, to the set of VLAN identifiers"
371 			"filtered for VF(s) from port_id.\n\n"
372 
373 			"tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) "
374 			"(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
375 			"imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
376 			"   add a tunnel filter of a port.\n\n"
377 
378 			"tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) "
379 			"(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
380 			"imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
381 			"   remove a tunnel filter of a port.\n\n"
382 
383 			"rx_vxlan_port add (udp_port) (port_id)\n"
384 			"    Add an UDP port for VXLAN packet filter on a port\n\n"
385 
386 			"rx_vxlan_port rm (udp_port) (port_id)\n"
387 			"    Remove an UDP port for VXLAN packet filter on a port\n\n"
388 
389 			"tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
390 			"    Set hardware insertion of VLAN IDs (single or double VLAN "
391 			"depends on the number of VLAN IDs) in packets sent on a port.\n\n"
392 
393 			"tx_vlan set pvid port_id vlan_id (on|off)\n"
394 			"    Set port based TX VLAN insertion.\n\n"
395 
396 			"tx_vlan reset (port_id)\n"
397 			"    Disable hardware insertion of a VLAN header in"
398 			" packets sent on a port.\n\n"
399 
400 			"csum set (ip|udp|tcp|sctp|outer-ip|outer-udp) (hw|sw) (port_id)\n"
401 			"    Select hardware or software calculation of the"
402 			" checksum when transmitting a packet using the"
403 			" csum forward engine.\n"
404 			"    ip|udp|tcp|sctp always concern the inner layer.\n"
405 			"    outer-ip concerns the outer IP layer in"
406 			"    outer-udp concerns the outer UDP layer in"
407 			" case the packet is recognized as a tunnel packet by"
408 			" the forward engine (vxlan, gre and ipip are supported)\n"
409 			"    Please check the NIC datasheet for HW limits.\n\n"
410 
411 			"csum parse-tunnel (on|off) (tx_port_id)\n"
412 			"    If disabled, treat tunnel packets as non-tunneled"
413 			" packets (treat inner headers as payload). The port\n"
414 			"    argument is the port used for TX in csum forward"
415 			" engine.\n\n"
416 
417 			"csum show (port_id)\n"
418 			"    Display tx checksum offload configuration\n\n"
419 
420 			"tso set (segsize) (portid)\n"
421 			"    Enable TCP Segmentation Offload in csum forward"
422 			" engine.\n"
423 			"    Please check the NIC datasheet for HW limits.\n\n"
424 
425 			"tso show (portid)"
426 			"    Display the status of TCP Segmentation Offload.\n\n"
427 
428 			"set port (port_id) gro on|off\n"
429 			"    Enable or disable Generic Receive Offload in"
430 			" csum forwarding engine.\n\n"
431 
432 			"show port (port_id) gro\n"
433 			"    Display GRO configuration.\n\n"
434 
435 			"set gro flush (cycles)\n"
436 			"    Set the cycle to flush GROed packets from"
437 			" reassembly tables.\n\n"
438 
439 			"set port (port_id) gso (on|off)"
440 			"    Enable or disable Generic Segmentation Offload in"
441 			" csum forwarding engine.\n\n"
442 
443 			"set gso segsz (length)\n"
444 			"    Set max packet length for output GSO segments,"
445 			" including packet header and payload.\n\n"
446 
447 			"show port (port_id) gso\n"
448 			"    Show GSO configuration.\n\n"
449 
450 			"set fwd (%s)\n"
451 			"    Set packet forwarding mode.\n\n"
452 
453 			"mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
454 			"    Add a MAC address on port_id.\n\n"
455 
456 			"mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
457 			"    Remove a MAC address from port_id.\n\n"
458 
459 			"mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
460 			"    Set the default MAC address for port_id.\n\n"
461 
462 			"mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
463 			"    Add a MAC address for a VF on the port.\n\n"
464 
465 			"set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
466 			"    Set the MAC address for a VF from the PF.\n\n"
467 
468 			"set eth-peer (port_id) (peer_addr)\n"
469 			"    set the peer address for certain port.\n\n"
470 
471 			"set port (port_id) uta (mac_address|all) (on|off)\n"
472 			"    Add/Remove a or all unicast hash filter(s)"
473 			"from port X.\n\n"
474 
475 			"set promisc (port_id|all) (on|off)\n"
476 			"    Set the promiscuous mode on port_id, or all.\n\n"
477 
478 			"set allmulti (port_id|all) (on|off)\n"
479 			"    Set the allmulti mode on port_id, or all.\n\n"
480 
481 			"set vf promisc (port_id) (vf_id) (on|off)\n"
482 			"    Set unicast promiscuous mode for a VF from the PF.\n\n"
483 
484 			"set vf allmulti (port_id) (vf_id) (on|off)\n"
485 			"    Set multicast promiscuous mode for a VF from the PF.\n\n"
486 
487 			"set flow_ctrl rx (on|off) tx (on|off) (high_water)"
488 			" (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
489 			" (on|off) autoneg (on|off) (port_id)\n"
490 			"set flow_ctrl rx (on|off) (portid)\n"
491 			"set flow_ctrl tx (on|off) (portid)\n"
492 			"set flow_ctrl high_water (high_water) (portid)\n"
493 			"set flow_ctrl low_water (low_water) (portid)\n"
494 			"set flow_ctrl pause_time (pause_time) (portid)\n"
495 			"set flow_ctrl send_xon (send_xon) (portid)\n"
496 			"set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
497 			"set flow_ctrl autoneg (on|off) (port_id)\n"
498 			"    Set the link flow control parameter on a port.\n\n"
499 
500 			"set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
501 			" (low_water) (pause_time) (priority) (port_id)\n"
502 			"    Set the priority flow control parameter on a"
503 			" port.\n\n"
504 
505 			"set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
506 			"    Set statistics mapping (qmapping 0..15) for RX/TX"
507 			" queue on port.\n"
508 			"    e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
509 			" on port 0 to mapping 5.\n\n"
510 
511 			"set xstats-hide-zero on|off\n"
512 			"    Set the option to hide the zero values"
513 			" for xstats display.\n"
514 
515 			"set port (port_id) vf (vf_id) rx|tx on|off\n"
516 			"    Enable/Disable a VF receive/tranmit from a port\n\n"
517 
518 			"set port (port_id) vf (vf_id) (mac_addr)"
519 			" (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
520 			"   Add/Remove unicast or multicast MAC addr filter"
521 			" for a VF.\n\n"
522 
523 			"set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
524 			"|MPE) (on|off)\n"
525 			"    AUPE:accepts untagged VLAN;"
526 			"ROPE:accept unicast hash\n\n"
527 			"    BAM:accepts broadcast packets;"
528 			"MPE:accepts all multicast packets\n\n"
529 			"    Enable/Disable a VF receive mode of a port\n\n"
530 
531 			"set port (port_id) queue (queue_id) rate (rate_num)\n"
532 			"    Set rate limit for a queue of a port\n\n"
533 
534 			"set port (port_id) vf (vf_id) rate (rate_num) "
535 			"queue_mask (queue_mask_value)\n"
536 			"    Set rate limit for queues in VF of a port\n\n"
537 
538 			"set port (port_id) mirror-rule (rule_id)"
539 			" (pool-mirror-up|pool-mirror-down|vlan-mirror)"
540 			" (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
541 			"   Set pool or vlan type mirror rule on a port.\n"
542 			"   e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
543 			" dst-pool 0 on' enable mirror traffic with vlan 0,1"
544 			" to pool 0.\n\n"
545 
546 			"set port (port_id) mirror-rule (rule_id)"
547 			" (uplink-mirror|downlink-mirror) dst-pool"
548 			" (pool_id) (on|off)\n"
549 			"   Set uplink or downlink type mirror rule on a port.\n"
550 			"   e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
551 			" 0 on' enable mirror income traffic to pool 0.\n\n"
552 
553 			"reset port (port_id) mirror-rule (rule_id)\n"
554 			"   Reset a mirror rule.\n\n"
555 
556 			"set flush_rx (on|off)\n"
557 			"   Flush (default) or don't flush RX streams before"
558 			" forwarding. Mainly used with PCAP drivers.\n\n"
559 
560 			"set bypass mode (normal|bypass|isolate) (port_id)\n"
561 			"   Set the bypass mode for the lowest port on bypass enabled"
562 			" NIC.\n\n"
563 
564 			"set bypass event (timeout|os_on|os_off|power_on|power_off) "
565 			"mode (normal|bypass|isolate) (port_id)\n"
566 			"   Set the event required to initiate specified bypass mode for"
567 			" the lowest port on a bypass enabled NIC where:\n"
568 			"       timeout   = enable bypass after watchdog timeout.\n"
569 			"       os_on     = enable bypass when OS/board is powered on.\n"
570 			"       os_off    = enable bypass when OS/board is powered off.\n"
571 			"       power_on  = enable bypass when power supply is turned on.\n"
572 			"       power_off = enable bypass when power supply is turned off."
573 			"\n\n"
574 
575 			"set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
576 			"   Set the bypass watchdog timeout to 'n' seconds"
577 			" where 0 = instant.\n\n"
578 
579 			"show bypass config (port_id)\n"
580 			"   Show the bypass configuration for a bypass enabled NIC"
581 			" using the lowest port on the NIC.\n\n"
582 
583 #ifdef RTE_LIBRTE_PMD_BOND
584 			"create bonded device (mode) (socket)\n"
585 			"	Create a new bonded device with specific bonding mode and socket.\n\n"
586 
587 			"add bonding slave (slave_id) (port_id)\n"
588 			"	Add a slave device to a bonded device.\n\n"
589 
590 			"remove bonding slave (slave_id) (port_id)\n"
591 			"	Remove a slave device from a bonded device.\n\n"
592 
593 			"set bonding mode (value) (port_id)\n"
594 			"	Set the bonding mode on a bonded device.\n\n"
595 
596 			"set bonding primary (slave_id) (port_id)\n"
597 			"	Set the primary slave for a bonded device.\n\n"
598 
599 			"show bonding config (port_id)\n"
600 			"	Show the bonding config for port_id.\n\n"
601 
602 			"set bonding mac_addr (port_id) (address)\n"
603 			"	Set the MAC address of a bonded device.\n\n"
604 
605 			"set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)"
606 			"	Set Aggregation mode for IEEE802.3AD (mode 4)"
607 
608 			"set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
609 			"	Set the transmit balance policy for bonded device running in balance mode.\n\n"
610 
611 			"set bonding mon_period (port_id) (value)\n"
612 			"	Set the bonding link status monitoring polling period in ms.\n\n"
613 
614 			"set bonding lacp dedicated_queues <port_id> (enable|disable)\n"
615 			"	Enable/disable dedicated queues for LACP control traffic.\n\n"
616 
617 #endif
618 			"set link-up port (port_id)\n"
619 			"	Set link up for a port.\n\n"
620 
621 			"set link-down port (port_id)\n"
622 			"	Set link down for a port.\n\n"
623 
624 			"E-tag set insertion on port-tag-id (value)"
625 			" port (port_id) vf (vf_id)\n"
626 			"    Enable E-tag insertion for a VF on a port\n\n"
627 
628 			"E-tag set insertion off port (port_id) vf (vf_id)\n"
629 			"    Disable E-tag insertion for a VF on a port\n\n"
630 
631 			"E-tag set stripping (on|off) port (port_id)\n"
632 			"    Enable/disable E-tag stripping on a port\n\n"
633 
634 			"E-tag set forwarding (on|off) port (port_id)\n"
635 			"    Enable/disable E-tag based forwarding"
636 			" on a port\n\n"
637 
638 			"E-tag set filter add e-tag-id (value) dst-pool"
639 			" (pool_id) port (port_id)\n"
640 			"    Add an E-tag forwarding filter on a port\n\n"
641 
642 			"E-tag set filter del e-tag-id (value) port (port_id)\n"
643 			"    Delete an E-tag forwarding filter on a port\n\n"
644 
645 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
646 			"set port tm hierarchy default (port_id)\n"
647 			"	Set default traffic Management hierarchy on a port\n\n"
648 
649 #endif
650 			"ddp add (port_id) (profile_path[,backup_profile_path])\n"
651 			"    Load a profile package on a port\n\n"
652 
653 			"ddp del (port_id) (backup_profile_path)\n"
654 			"    Delete a profile package from a port\n\n"
655 
656 			"ptype mapping get (port_id) (valid_only)\n"
657 			"    Get ptype mapping on a port\n\n"
658 
659 			"ptype mapping replace (port_id) (target) (mask) (pky_type)\n"
660 			"    Replace target with the pkt_type in ptype mapping\n\n"
661 
662 			"ptype mapping reset (port_id)\n"
663 			"    Reset ptype mapping on a port\n\n"
664 
665 			"ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n"
666 			"    Update a ptype mapping item on a port\n\n"
667 
668 			"set port (port_id) queue-region region_id (value) "
669 			"queue_start_index (value) queue_num (value)\n"
670 			"    Set a queue region on a port\n\n"
671 
672 			"set port (port_id) queue-region region_id (value) "
673 			"flowtype (value)\n"
674 			"    Set a flowtype region index on a port\n\n"
675 
676 			"set port (port_id) queue-region UP (value) region_id (value)\n"
677 			"    Set the mapping of User Priority to "
678 			"queue region on a port\n\n"
679 
680 			"set port (port_id) queue-region flush (on|off)\n"
681 			"    flush all queue region related configuration\n\n"
682 
683 			"show port meter cap (port_id)\n"
684 			"    Show port meter capability information\n\n"
685 
686 			"add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs)\n"
687 			"    meter profile add - srtcm rfc 2697\n\n"
688 
689 			"add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs)\n"
690 			"    meter profile add - trtcm rfc 2698\n\n"
691 
692 			"add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs)\n"
693 			"    meter profile add - trtcm rfc 4115\n\n"
694 
695 			"del port meter profile (port_id) (profile_id)\n"
696 			"    meter profile delete\n\n"
697 
698 			"create port meter (port_id) (mtr_id) (profile_id) (meter_enable)\n"
699 			"(g_action) (y_action) (r_action) (stats_mask) (shared)\n"
700 			"(use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n"
701 			"(dscp_tbl_entry63)]\n"
702 			"    meter create\n\n"
703 
704 			"enable port meter (port_id) (mtr_id)\n"
705 			"    meter enable\n\n"
706 
707 			"disable port meter (port_id) (mtr_id)\n"
708 			"    meter disable\n\n"
709 
710 			"del port meter (port_id) (mtr_id)\n"
711 			"    meter delete\n\n"
712 
713 			"set port meter profile (port_id) (mtr_id) (profile_id)\n"
714 			"    meter update meter profile\n\n"
715 
716 			"set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n"
717 			"(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n"
718 			"    update meter dscp table entries\n\n"
719 
720 			"set port meter policer action (port_id) (mtr_id) (action_mask)\n"
721 			"(action0) [(action1) (action2)]\n"
722 			"    meter update policer action\n\n"
723 
724 			"set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
725 			"    meter update stats\n\n"
726 
727 			"show port (port_id) queue-region\n"
728 			"    show all queue region related configuration info\n\n"
729 
730 			"add port tm node shaper profile (port_id) (shaper_profile_id)"
731 			" (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)"
732 			" (packet_length_adjust)\n"
733 			"	Add port tm node private shaper profile.\n\n"
734 
735 			"del port tm node shaper profile (port_id) (shaper_profile_id)\n"
736 			"	Delete port tm node private shaper profile.\n\n"
737 
738 			"add port tm node shared shaper (port_id) (shared_shaper_id)"
739 			" (shaper_profile_id)\n"
740 			"	Add/update port tm node shared shaper.\n\n"
741 
742 			"del port tm node shared shaper (port_id) (shared_shaper_id)\n"
743 			"	Delete port tm node shared shaper.\n\n"
744 
745 			"set port tm node shaper profile (port_id) (node_id)"
746 			" (shaper_profile_id)\n"
747 			"	Set port tm node shaper profile.\n\n"
748 
749 			"add port tm node wred profile (port_id) (wred_profile_id)"
750 			" (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
751 			" (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
752 			" (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
753 			"	Add port tm node wred profile.\n\n"
754 
755 			"del port tm node wred profile (port_id) (wred_profile_id)\n"
756 			"	Delete port tm node wred profile.\n\n"
757 
758 			"add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
759 			" (priority) (weight) (level_id) (shaper_profile_id)"
760 			" (n_sp_priorities) (stats_mask) (n_shared_shapers)"
761 			" [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
762 			"	Add port tm nonleaf node.\n\n"
763 
764 			"add port tm leaf node (port_id) (node_id) (parent_node_id)"
765 			" (priority) (weight) (level_id) (shaper_profile_id)"
766 			" (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
767 			" [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
768 			"	Add port tm leaf node.\n\n"
769 
770 			"del port tm node (port_id) (node_id)\n"
771 			"	Delete port tm node.\n\n"
772 
773 			"set port tm node parent (port_id) (node_id) (parent_node_id)"
774 			" (priority) (weight)\n"
775 			"	Set port tm node parent.\n\n"
776 
777 			"suspend port tm node (port_id) (node_id)"
778 			"       Suspend tm node.\n\n"
779 
780 			"resume port tm node (port_id) (node_id)"
781 			"       Resume tm node.\n\n"
782 
783 			"port tm hierarchy commit (port_id) (clean_on_fail)\n"
784 			"	Commit tm hierarchy.\n\n"
785 
786 			"vxlan ip-version (ipv4|ipv6) vni (vni) udp-src"
787 			" (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst"
788 			" (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n"
789 			"       Configure the VXLAN encapsulation for flows.\n\n"
790 
791 			"vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)"
792 			" udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)"
793 			" ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)"
794 			" eth-dst (eth-dst)\n"
795 			"       Configure the VXLAN encapsulation for flows.\n\n"
796 
797 			"vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src"
798 			" (udp-src) udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl)"
799 			" ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src)"
800 			" eth-dst (eth-dst)\n"
801 			"       Configure the VXLAN encapsulation for flows.\n\n"
802 
803 			"nvgre ip-version (ipv4|ipv6) tni (tni) ip-src"
804 			" (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst"
805 			" (eth-dst)\n"
806 			"       Configure the NVGRE encapsulation for flows.\n\n"
807 
808 			"nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)"
809 			" ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)"
810 			" eth-src (eth-src) eth-dst (eth-dst)\n"
811 			"       Configure the NVGRE encapsulation for flows.\n\n"
812 
813 			, list_pkt_forwarding_modes()
814 		);
815 	}
816 
817 	if (show_all || !strcmp(res->section, "ports")) {
818 
819 		cmdline_printf(
820 			cl,
821 			"\n"
822 			"Port Operations:\n"
823 			"----------------\n\n"
824 
825 			"port start (port_id|all)\n"
826 			"    Start all ports or port_id.\n\n"
827 
828 			"port stop (port_id|all)\n"
829 			"    Stop all ports or port_id.\n\n"
830 
831 			"port close (port_id|all)\n"
832 			"    Close all ports or port_id.\n\n"
833 
834 			"port attach (ident)\n"
835 			"    Attach physical or virtual dev by pci address or virtual device name\n\n"
836 
837 			"port detach (port_id)\n"
838 			"    Detach physical or virtual dev by port_id\n\n"
839 
840 			"port config (port_id|all)"
841 			" speed (10|100|1000|10000|25000|40000|50000|100000|auto)"
842 			" duplex (half|full|auto)\n"
843 			"    Set speed and duplex for all ports or port_id\n\n"
844 
845 			"port config (port_id|all) loopback (mode)\n"
846 			"    Set loopback mode for all ports or port_id\n\n"
847 
848 			"port config all (rxq|txq|rxd|txd) (value)\n"
849 			"    Set number for rxq/txq/rxd/txd.\n\n"
850 
851 			"port config all max-pkt-len (value)\n"
852 			"    Set the max packet length.\n\n"
853 
854 			"port config all (crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|hw-vlan-filter|"
855 			"hw-vlan-strip|hw-vlan-extend|drop-en)"
856 			" (on|off)\n"
857 			"    Set crc-strip/scatter/rx-checksum/hardware-vlan/drop_en"
858 			" for ports.\n\n"
859 
860 			"port config all rss (all|default|ip|tcp|udp|sctp|"
861 			"ether|port|vxlan|geneve|nvgre|none|<flowtype_id>)\n"
862 			"    Set the RSS mode.\n\n"
863 
864 			"port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
865 			"    Set the RSS redirection table.\n\n"
866 
867 			"port config (port_id) dcb vt (on|off) (traffic_class)"
868 			" pfc (on|off)\n"
869 			"    Set the DCB mode.\n\n"
870 
871 			"port config all burst (value)\n"
872 			"    Set the number of packets per burst.\n\n"
873 
874 			"port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
875 			" (value)\n"
876 			"    Set the ring prefetch/host/writeback threshold"
877 			" for tx/rx queue.\n\n"
878 
879 			"port config all (txfreet|txrst|rxfreet) (value)\n"
880 			"    Set free threshold for rx/tx, or set"
881 			" tx rs bit threshold.\n\n"
882 			"port config mtu X value\n"
883 			"    Set the MTU of port X to a given value\n\n"
884 
885 			"port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n"
886 			"    Set a rx/tx queue's ring size configuration, the new"
887 			" value will take effect after command that (re-)start the port"
888 			" or command that setup the specific queue\n\n"
889 
890 			"port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
891 			"    Start/stop a rx/tx queue of port X. Only take effect"
892 			" when port X is started\n\n"
893 
894 			"port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n"
895 			"    Switch on/off a deferred start of port X rx/tx queue. Only"
896 			" take effect when port X is stopped.\n\n"
897 
898 			"port (port_id) (rxq|txq) (queue_id) setup\n"
899 			"    Setup a rx/tx queue of port X.\n\n"
900 
901 			"port config (port_id|all) l2-tunnel E-tag ether-type"
902 			" (value)\n"
903 			"    Set the value of E-tag ether-type.\n\n"
904 
905 			"port config (port_id|all) l2-tunnel E-tag"
906 			" (enable|disable)\n"
907 			"    Enable/disable the E-tag support.\n\n"
908 
909 			"port config (port_id) pctype mapping reset\n"
910 			"    Reset flow type to pctype mapping on a port\n\n"
911 
912 			"port config (port_id) pctype mapping update"
913 			" (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
914 			"    Update a flow type to pctype mapping item on a port\n\n"
915 
916 			"port config (port_id) pctype (pctype_id) hash_inset|"
917 			"fdir_inset|fdir_flx_inset get|set|clear field\n"
918 			" (field_idx)\n"
919 			"    Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n"
920 
921 			"port config (port_id) pctype (pctype_id) hash_inset|"
922 			"fdir_inset|fdir_flx_inset clear all"
923 			"    Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n"
924 
925 			"port config (port_id) udp_tunnel_port add|rm vxlan|geneve (udp_port)\n\n"
926 			"    Add/remove UDP tunnel port for tunneling offload\n\n"
927 		);
928 	}
929 
930 	if (show_all || !strcmp(res->section, "registers")) {
931 
932 		cmdline_printf(
933 			cl,
934 			"\n"
935 			"Registers:\n"
936 			"----------\n\n"
937 
938 			"read reg (port_id) (address)\n"
939 			"    Display value of a port register.\n\n"
940 
941 			"read regfield (port_id) (address) (bit_x) (bit_y)\n"
942 			"    Display a port register bit field.\n\n"
943 
944 			"read regbit (port_id) (address) (bit_x)\n"
945 			"    Display a single port register bit.\n\n"
946 
947 			"write reg (port_id) (address) (value)\n"
948 			"    Set value of a port register.\n\n"
949 
950 			"write regfield (port_id) (address) (bit_x) (bit_y)"
951 			" (value)\n"
952 			"    Set bit field of a port register.\n\n"
953 
954 			"write regbit (port_id) (address) (bit_x) (value)\n"
955 			"    Set single bit value of a port register.\n\n"
956 		);
957 	}
958 	if (show_all || !strcmp(res->section, "filters")) {
959 
960 		cmdline_printf(
961 			cl,
962 			"\n"
963 			"filters:\n"
964 			"--------\n\n"
965 
966 			"ethertype_filter (port_id) (add|del)"
967 			" (mac_addr|mac_ignr) (mac_address) ethertype"
968 			" (ether_type) (drop|fwd) queue (queue_id)\n"
969 			"    Add/Del an ethertype filter.\n\n"
970 
971 			"2tuple_filter (port_id) (add|del)"
972 			" dst_port (dst_port_value) protocol (protocol_value)"
973 			" mask (mask_value) tcp_flags (tcp_flags_value)"
974 			" priority (prio_value) queue (queue_id)\n"
975 			"    Add/Del a 2tuple filter.\n\n"
976 
977 			"5tuple_filter (port_id) (add|del)"
978 			" dst_ip (dst_address) src_ip (src_address)"
979 			" dst_port (dst_port_value) src_port (src_port_value)"
980 			" protocol (protocol_value)"
981 			" mask (mask_value) tcp_flags (tcp_flags_value)"
982 			" priority (prio_value) queue (queue_id)\n"
983 			"    Add/Del a 5tuple filter.\n\n"
984 
985 			"syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
986 			"    Add/Del syn filter.\n\n"
987 
988 			"flex_filter (port_id) (add|del) len (len_value)"
989 			" bytes (bytes_value) mask (mask_value)"
990 			" priority (prio_value) queue (queue_id)\n"
991 			"    Add/Del a flex filter.\n\n"
992 
993 			"flow_director_filter (port_id) mode IP (add|del|update)"
994 			" flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
995 			" src (src_ip_address) dst (dst_ip_address)"
996 			" tos (tos_value) proto (proto_value) ttl (ttl_value)"
997 			" vlan (vlan_value) flexbytes (flexbytes_value)"
998 			" (drop|fwd) pf|vf(vf_id) queue (queue_id)"
999 			" fd_id (fd_id_value)\n"
1000 			"    Add/Del an IP type flow director filter.\n\n"
1001 
1002 			"flow_director_filter (port_id) mode IP (add|del|update)"
1003 			" flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
1004 			" src (src_ip_address) (src_port)"
1005 			" dst (dst_ip_address) (dst_port)"
1006 			" tos (tos_value) ttl (ttl_value)"
1007 			" vlan (vlan_value) flexbytes (flexbytes_value)"
1008 			" (drop|fwd) pf|vf(vf_id) queue (queue_id)"
1009 			" fd_id (fd_id_value)\n"
1010 			"    Add/Del an UDP/TCP type flow director filter.\n\n"
1011 
1012 			"flow_director_filter (port_id) mode IP (add|del|update)"
1013 			" flow (ipv4-sctp|ipv6-sctp)"
1014 			" src (src_ip_address) (src_port)"
1015 			" dst (dst_ip_address) (dst_port)"
1016 			" tag (verification_tag) "
1017 			" tos (tos_value) ttl (ttl_value)"
1018 			" vlan (vlan_value)"
1019 			" flexbytes (flexbytes_value) (drop|fwd)"
1020 			" pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
1021 			"    Add/Del a SCTP type flow director filter.\n\n"
1022 
1023 			"flow_director_filter (port_id) mode IP (add|del|update)"
1024 			" flow l2_payload ether (ethertype)"
1025 			" flexbytes (flexbytes_value) (drop|fwd)"
1026 			" pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
1027 			"    Add/Del a l2 payload type flow director filter.\n\n"
1028 
1029 			"flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
1030 			" mac (mac_address) vlan (vlan_value)"
1031 			" flexbytes (flexbytes_value) (drop|fwd)"
1032 			" queue (queue_id) fd_id (fd_id_value)\n"
1033 			"    Add/Del a MAC-VLAN flow director filter.\n\n"
1034 
1035 			"flow_director_filter (port_id) mode Tunnel (add|del|update)"
1036 			" mac (mac_address) vlan (vlan_value)"
1037 			" tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
1038 			" flexbytes (flexbytes_value) (drop|fwd)"
1039 			" queue (queue_id) fd_id (fd_id_value)\n"
1040 			"    Add/Del a Tunnel flow director filter.\n\n"
1041 
1042 			"flow_director_filter (port_id) mode raw (add|del|update)"
1043 			" flow (flow_id) (drop|fwd) queue (queue_id)"
1044 			" fd_id (fd_id_value) packet (packet file name)\n"
1045 			"    Add/Del a raw type flow director filter.\n\n"
1046 
1047 			"flush_flow_director (port_id)\n"
1048 			"    Flush all flow director entries of a device.\n\n"
1049 
1050 			"flow_director_mask (port_id) mode IP vlan (vlan_value)"
1051 			" src_mask (ipv4_src) (ipv6_src) (src_port)"
1052 			" dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
1053 			"    Set flow director IP mask.\n\n"
1054 
1055 			"flow_director_mask (port_id) mode MAC-VLAN"
1056 			" vlan (vlan_value)\n"
1057 			"    Set flow director MAC-VLAN mask.\n\n"
1058 
1059 			"flow_director_mask (port_id) mode Tunnel"
1060 			" vlan (vlan_value) mac (mac_value)"
1061 			" tunnel-type (tunnel_type_value)"
1062 			" tunnel-id (tunnel_id_value)\n"
1063 			"    Set flow director Tunnel mask.\n\n"
1064 
1065 			"flow_director_flex_mask (port_id)"
1066 			" flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
1067 			"ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
1068 			" (mask)\n"
1069 			"    Configure mask of flex payload.\n\n"
1070 
1071 			"flow_director_flex_payload (port_id)"
1072 			" (raw|l2|l3|l4) (config)\n"
1073 			"    Configure flex payload selection.\n\n"
1074 
1075 			"get_sym_hash_ena_per_port (port_id)\n"
1076 			"    get symmetric hash enable configuration per port.\n\n"
1077 
1078 			"set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
1079 			"    set symmetric hash enable configuration per port"
1080 			" to enable or disable.\n\n"
1081 
1082 			"get_hash_global_config (port_id)\n"
1083 			"    Get the global configurations of hash filters.\n\n"
1084 
1085 			"set_hash_global_config (port_id) (toeplitz|simple_xor|default)"
1086 			" (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1087 			"ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
1088 			" (enable|disable)\n"
1089 			"    Set the global configurations of hash filters.\n\n"
1090 
1091 			"set_hash_input_set (port_id) (ipv4|ipv4-frag|"
1092 			"ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1093 			"ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1094 			"l2_payload|<flowtype_id>) (ovlan|ivlan|src-ipv4|dst-ipv4|"
1095 			"src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
1096 			"ipv6-next-header|udp-src-port|udp-dst-port|"
1097 			"tcp-src-port|tcp-dst-port|sctp-src-port|"
1098 			"sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
1099 			"fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
1100 			"fld-8th|none) (select|add)\n"
1101 			"    Set the input set for hash.\n\n"
1102 
1103 			"set_fdir_input_set (port_id) "
1104 			"(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1105 			"ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1106 			"l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
1107 			"dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
1108 			"ipv6-next-header|ipv6-hop-limits|udp-src-port|"
1109 			"udp-dst-port|tcp-src-port|tcp-dst-port|"
1110 			"sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
1111 			" (select|add)\n"
1112 			"    Set the input set for FDir.\n\n"
1113 
1114 			"flow validate {port_id}"
1115 			" [group {group_id}] [priority {level}]"
1116 			" [ingress] [egress]"
1117 			" pattern {item} [/ {item} [...]] / end"
1118 			" actions {action} [/ {action} [...]] / end\n"
1119 			"    Check whether a flow rule can be created.\n\n"
1120 
1121 			"flow create {port_id}"
1122 			" [group {group_id}] [priority {level}]"
1123 			" [ingress] [egress]"
1124 			" pattern {item} [/ {item} [...]] / end"
1125 			" actions {action} [/ {action} [...]] / end\n"
1126 			"    Create a flow rule.\n\n"
1127 
1128 			"flow destroy {port_id} rule {rule_id} [...]\n"
1129 			"    Destroy specific flow rules.\n\n"
1130 
1131 			"flow flush {port_id}\n"
1132 			"    Destroy all flow rules.\n\n"
1133 
1134 			"flow query {port_id} {rule_id} {action}\n"
1135 			"    Query an existing flow rule.\n\n"
1136 
1137 			"flow list {port_id} [group {group_id}] [...]\n"
1138 			"    List existing flow rules sorted by priority,"
1139 			" filtered by group identifiers.\n\n"
1140 
1141 			"flow isolate {port_id} {boolean}\n"
1142 			"    Restrict ingress traffic to the defined"
1143 			" flow rules\n\n"
1144 		);
1145 	}
1146 }
1147 
1148 cmdline_parse_token_string_t cmd_help_long_help =
1149 	TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1150 
1151 cmdline_parse_token_string_t cmd_help_long_section =
1152 	TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1153 			"all#control#display#config#"
1154 			"ports#registers#filters");
1155 
1156 cmdline_parse_inst_t cmd_help_long = {
1157 	.f = cmd_help_long_parsed,
1158 	.data = NULL,
1159 	.help_str = "help all|control|display|config|ports|register|filters: "
1160 		"Show help",
1161 	.tokens = {
1162 		(void *)&cmd_help_long_help,
1163 		(void *)&cmd_help_long_section,
1164 		NULL,
1165 	},
1166 };
1167 
1168 
1169 /* *** start/stop/close all ports *** */
1170 struct cmd_operate_port_result {
1171 	cmdline_fixed_string_t keyword;
1172 	cmdline_fixed_string_t name;
1173 	cmdline_fixed_string_t value;
1174 };
1175 
1176 static void cmd_operate_port_parsed(void *parsed_result,
1177 				__attribute__((unused)) struct cmdline *cl,
1178 				__attribute__((unused)) void *data)
1179 {
1180 	struct cmd_operate_port_result *res = parsed_result;
1181 
1182 	if (!strcmp(res->name, "start"))
1183 		start_port(RTE_PORT_ALL);
1184 	else if (!strcmp(res->name, "stop"))
1185 		stop_port(RTE_PORT_ALL);
1186 	else if (!strcmp(res->name, "close"))
1187 		close_port(RTE_PORT_ALL);
1188 	else if (!strcmp(res->name, "reset"))
1189 		reset_port(RTE_PORT_ALL);
1190 	else
1191 		printf("Unknown parameter\n");
1192 }
1193 
1194 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1195 	TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1196 								"port");
1197 cmdline_parse_token_string_t cmd_operate_port_all_port =
1198 	TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1199 						"start#stop#close#reset");
1200 cmdline_parse_token_string_t cmd_operate_port_all_all =
1201 	TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1202 
1203 cmdline_parse_inst_t cmd_operate_port = {
1204 	.f = cmd_operate_port_parsed,
1205 	.data = NULL,
1206 	.help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports",
1207 	.tokens = {
1208 		(void *)&cmd_operate_port_all_cmd,
1209 		(void *)&cmd_operate_port_all_port,
1210 		(void *)&cmd_operate_port_all_all,
1211 		NULL,
1212 	},
1213 };
1214 
1215 /* *** start/stop/close specific port *** */
1216 struct cmd_operate_specific_port_result {
1217 	cmdline_fixed_string_t keyword;
1218 	cmdline_fixed_string_t name;
1219 	uint8_t value;
1220 };
1221 
1222 static void cmd_operate_specific_port_parsed(void *parsed_result,
1223 			__attribute__((unused)) struct cmdline *cl,
1224 				__attribute__((unused)) void *data)
1225 {
1226 	struct cmd_operate_specific_port_result *res = parsed_result;
1227 
1228 	if (!strcmp(res->name, "start"))
1229 		start_port(res->value);
1230 	else if (!strcmp(res->name, "stop"))
1231 		stop_port(res->value);
1232 	else if (!strcmp(res->name, "close"))
1233 		close_port(res->value);
1234 	else if (!strcmp(res->name, "reset"))
1235 		reset_port(res->value);
1236 	else
1237 		printf("Unknown parameter\n");
1238 }
1239 
1240 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1241 	TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1242 							keyword, "port");
1243 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1244 	TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1245 						name, "start#stop#close#reset");
1246 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1247 	TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1248 							value, UINT8);
1249 
1250 cmdline_parse_inst_t cmd_operate_specific_port = {
1251 	.f = cmd_operate_specific_port_parsed,
1252 	.data = NULL,
1253 	.help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id",
1254 	.tokens = {
1255 		(void *)&cmd_operate_specific_port_cmd,
1256 		(void *)&cmd_operate_specific_port_port,
1257 		(void *)&cmd_operate_specific_port_id,
1258 		NULL,
1259 	},
1260 };
1261 
1262 /* *** enable port setup (after attach) via iterator or event *** */
1263 struct cmd_set_port_setup_on_result {
1264 	cmdline_fixed_string_t set;
1265 	cmdline_fixed_string_t port;
1266 	cmdline_fixed_string_t setup;
1267 	cmdline_fixed_string_t on;
1268 	cmdline_fixed_string_t mode;
1269 };
1270 
1271 static void cmd_set_port_setup_on_parsed(void *parsed_result,
1272 				__attribute__((unused)) struct cmdline *cl,
1273 				__attribute__((unused)) void *data)
1274 {
1275 	struct cmd_set_port_setup_on_result *res = parsed_result;
1276 
1277 	if (strcmp(res->mode, "event") == 0)
1278 		setup_on_probe_event = true;
1279 	else if (strcmp(res->mode, "iterator") == 0)
1280 		setup_on_probe_event = false;
1281 	else
1282 		printf("Unknown mode\n");
1283 }
1284 
1285 cmdline_parse_token_string_t cmd_set_port_setup_on_set =
1286 	TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1287 			set, "set");
1288 cmdline_parse_token_string_t cmd_set_port_setup_on_port =
1289 	TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1290 			port, "port");
1291 cmdline_parse_token_string_t cmd_set_port_setup_on_setup =
1292 	TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1293 			setup, "setup");
1294 cmdline_parse_token_string_t cmd_set_port_setup_on_on =
1295 	TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1296 			on, "on");
1297 cmdline_parse_token_string_t cmd_set_port_setup_on_mode =
1298 	TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1299 			mode, "iterator#event");
1300 
1301 cmdline_parse_inst_t cmd_set_port_setup_on = {
1302 	.f = cmd_set_port_setup_on_parsed,
1303 	.data = NULL,
1304 	.help_str = "set port setup on iterator|event",
1305 	.tokens = {
1306 		(void *)&cmd_set_port_setup_on_set,
1307 		(void *)&cmd_set_port_setup_on_port,
1308 		(void *)&cmd_set_port_setup_on_setup,
1309 		(void *)&cmd_set_port_setup_on_on,
1310 		(void *)&cmd_set_port_setup_on_mode,
1311 		NULL,
1312 	},
1313 };
1314 
1315 /* *** attach a specified port *** */
1316 struct cmd_operate_attach_port_result {
1317 	cmdline_fixed_string_t port;
1318 	cmdline_fixed_string_t keyword;
1319 	cmdline_fixed_string_t identifier;
1320 };
1321 
1322 static void cmd_operate_attach_port_parsed(void *parsed_result,
1323 				__attribute__((unused)) struct cmdline *cl,
1324 				__attribute__((unused)) void *data)
1325 {
1326 	struct cmd_operate_attach_port_result *res = parsed_result;
1327 
1328 	if (!strcmp(res->keyword, "attach"))
1329 		attach_port(res->identifier);
1330 	else
1331 		printf("Unknown parameter\n");
1332 }
1333 
1334 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1335 	TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1336 			port, "port");
1337 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1338 	TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1339 			keyword, "attach");
1340 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1341 	TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1342 			identifier, NULL);
1343 
1344 cmdline_parse_inst_t cmd_operate_attach_port = {
1345 	.f = cmd_operate_attach_port_parsed,
1346 	.data = NULL,
1347 	.help_str = "port attach <identifier>: "
1348 		"(identifier: pci address or virtual dev name)",
1349 	.tokens = {
1350 		(void *)&cmd_operate_attach_port_port,
1351 		(void *)&cmd_operate_attach_port_keyword,
1352 		(void *)&cmd_operate_attach_port_identifier,
1353 		NULL,
1354 	},
1355 };
1356 
1357 /* *** detach a specified port *** */
1358 struct cmd_operate_detach_port_result {
1359 	cmdline_fixed_string_t port;
1360 	cmdline_fixed_string_t keyword;
1361 	portid_t port_id;
1362 };
1363 
1364 static void cmd_operate_detach_port_parsed(void *parsed_result,
1365 				__attribute__((unused)) struct cmdline *cl,
1366 				__attribute__((unused)) void *data)
1367 {
1368 	struct cmd_operate_detach_port_result *res = parsed_result;
1369 
1370 	if (!strcmp(res->keyword, "detach"))
1371 		detach_port_device(res->port_id);
1372 	else
1373 		printf("Unknown parameter\n");
1374 }
1375 
1376 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1377 	TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1378 			port, "port");
1379 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1380 	TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1381 			keyword, "detach");
1382 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1383 	TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1384 			port_id, UINT16);
1385 
1386 cmdline_parse_inst_t cmd_operate_detach_port = {
1387 	.f = cmd_operate_detach_port_parsed,
1388 	.data = NULL,
1389 	.help_str = "port detach <port_id>",
1390 	.tokens = {
1391 		(void *)&cmd_operate_detach_port_port,
1392 		(void *)&cmd_operate_detach_port_keyword,
1393 		(void *)&cmd_operate_detach_port_port_id,
1394 		NULL,
1395 	},
1396 };
1397 
1398 /* *** configure speed for all ports *** */
1399 struct cmd_config_speed_all {
1400 	cmdline_fixed_string_t port;
1401 	cmdline_fixed_string_t keyword;
1402 	cmdline_fixed_string_t all;
1403 	cmdline_fixed_string_t item1;
1404 	cmdline_fixed_string_t item2;
1405 	cmdline_fixed_string_t value1;
1406 	cmdline_fixed_string_t value2;
1407 };
1408 
1409 static int
1410 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1411 {
1412 
1413 	int duplex;
1414 
1415 	if (!strcmp(duplexstr, "half")) {
1416 		duplex = ETH_LINK_HALF_DUPLEX;
1417 	} else if (!strcmp(duplexstr, "full")) {
1418 		duplex = ETH_LINK_FULL_DUPLEX;
1419 	} else if (!strcmp(duplexstr, "auto")) {
1420 		duplex = ETH_LINK_FULL_DUPLEX;
1421 	} else {
1422 		printf("Unknown duplex parameter\n");
1423 		return -1;
1424 	}
1425 
1426 	if (!strcmp(speedstr, "10")) {
1427 		*speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1428 				ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1429 	} else if (!strcmp(speedstr, "100")) {
1430 		*speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1431 				ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1432 	} else {
1433 		if (duplex != ETH_LINK_FULL_DUPLEX) {
1434 			printf("Invalid speed/duplex parameters\n");
1435 			return -1;
1436 		}
1437 		if (!strcmp(speedstr, "1000")) {
1438 			*speed = ETH_LINK_SPEED_1G;
1439 		} else if (!strcmp(speedstr, "10000")) {
1440 			*speed = ETH_LINK_SPEED_10G;
1441 		} else if (!strcmp(speedstr, "25000")) {
1442 			*speed = ETH_LINK_SPEED_25G;
1443 		} else if (!strcmp(speedstr, "40000")) {
1444 			*speed = ETH_LINK_SPEED_40G;
1445 		} else if (!strcmp(speedstr, "50000")) {
1446 			*speed = ETH_LINK_SPEED_50G;
1447 		} else if (!strcmp(speedstr, "100000")) {
1448 			*speed = ETH_LINK_SPEED_100G;
1449 		} else if (!strcmp(speedstr, "auto")) {
1450 			*speed = ETH_LINK_SPEED_AUTONEG;
1451 		} else {
1452 			printf("Unknown speed parameter\n");
1453 			return -1;
1454 		}
1455 	}
1456 
1457 	return 0;
1458 }
1459 
1460 static void
1461 cmd_config_speed_all_parsed(void *parsed_result,
1462 			__attribute__((unused)) struct cmdline *cl,
1463 			__attribute__((unused)) void *data)
1464 {
1465 	struct cmd_config_speed_all *res = parsed_result;
1466 	uint32_t link_speed;
1467 	portid_t pid;
1468 
1469 	if (!all_ports_stopped()) {
1470 		printf("Please stop all ports first\n");
1471 		return;
1472 	}
1473 
1474 	if (parse_and_check_speed_duplex(res->value1, res->value2,
1475 			&link_speed) < 0)
1476 		return;
1477 
1478 	RTE_ETH_FOREACH_DEV(pid) {
1479 		ports[pid].dev_conf.link_speeds = link_speed;
1480 	}
1481 
1482 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1483 }
1484 
1485 cmdline_parse_token_string_t cmd_config_speed_all_port =
1486 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1487 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1488 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1489 							"config");
1490 cmdline_parse_token_string_t cmd_config_speed_all_all =
1491 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1492 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1493 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1494 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1495 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1496 				"10#100#1000#10000#25000#40000#50000#100000#auto");
1497 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1498 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1499 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1500 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1501 						"half#full#auto");
1502 
1503 cmdline_parse_inst_t cmd_config_speed_all = {
1504 	.f = cmd_config_speed_all_parsed,
1505 	.data = NULL,
1506 	.help_str = "port config all speed "
1507 		"10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1508 							"half|full|auto",
1509 	.tokens = {
1510 		(void *)&cmd_config_speed_all_port,
1511 		(void *)&cmd_config_speed_all_keyword,
1512 		(void *)&cmd_config_speed_all_all,
1513 		(void *)&cmd_config_speed_all_item1,
1514 		(void *)&cmd_config_speed_all_value1,
1515 		(void *)&cmd_config_speed_all_item2,
1516 		(void *)&cmd_config_speed_all_value2,
1517 		NULL,
1518 	},
1519 };
1520 
1521 /* *** configure speed for specific port *** */
1522 struct cmd_config_speed_specific {
1523 	cmdline_fixed_string_t port;
1524 	cmdline_fixed_string_t keyword;
1525 	portid_t id;
1526 	cmdline_fixed_string_t item1;
1527 	cmdline_fixed_string_t item2;
1528 	cmdline_fixed_string_t value1;
1529 	cmdline_fixed_string_t value2;
1530 };
1531 
1532 static void
1533 cmd_config_speed_specific_parsed(void *parsed_result,
1534 				__attribute__((unused)) struct cmdline *cl,
1535 				__attribute__((unused)) void *data)
1536 {
1537 	struct cmd_config_speed_specific *res = parsed_result;
1538 	uint32_t link_speed;
1539 
1540 	if (!all_ports_stopped()) {
1541 		printf("Please stop all ports first\n");
1542 		return;
1543 	}
1544 
1545 	if (port_id_is_invalid(res->id, ENABLED_WARN))
1546 		return;
1547 
1548 	if (parse_and_check_speed_duplex(res->value1, res->value2,
1549 			&link_speed) < 0)
1550 		return;
1551 
1552 	ports[res->id].dev_conf.link_speeds = link_speed;
1553 
1554 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1555 }
1556 
1557 
1558 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1559 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1560 								"port");
1561 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1562 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1563 								"config");
1564 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1565 	TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT16);
1566 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1567 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1568 								"speed");
1569 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1570 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1571 				"10#100#1000#10000#25000#40000#50000#100000#auto");
1572 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1573 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1574 								"duplex");
1575 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1576 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1577 							"half#full#auto");
1578 
1579 cmdline_parse_inst_t cmd_config_speed_specific = {
1580 	.f = cmd_config_speed_specific_parsed,
1581 	.data = NULL,
1582 	.help_str = "port config <port_id> speed "
1583 		"10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1584 							"half|full|auto",
1585 	.tokens = {
1586 		(void *)&cmd_config_speed_specific_port,
1587 		(void *)&cmd_config_speed_specific_keyword,
1588 		(void *)&cmd_config_speed_specific_id,
1589 		(void *)&cmd_config_speed_specific_item1,
1590 		(void *)&cmd_config_speed_specific_value1,
1591 		(void *)&cmd_config_speed_specific_item2,
1592 		(void *)&cmd_config_speed_specific_value2,
1593 		NULL,
1594 	},
1595 };
1596 
1597 /* *** configure loopback for all ports *** */
1598 struct cmd_config_loopback_all {
1599 	cmdline_fixed_string_t port;
1600 	cmdline_fixed_string_t keyword;
1601 	cmdline_fixed_string_t all;
1602 	cmdline_fixed_string_t item;
1603 	uint32_t mode;
1604 };
1605 
1606 static void
1607 cmd_config_loopback_all_parsed(void *parsed_result,
1608 			__attribute__((unused)) struct cmdline *cl,
1609 			__attribute__((unused)) void *data)
1610 {
1611 	struct cmd_config_loopback_all *res = parsed_result;
1612 	portid_t pid;
1613 
1614 	if (!all_ports_stopped()) {
1615 		printf("Please stop all ports first\n");
1616 		return;
1617 	}
1618 
1619 	RTE_ETH_FOREACH_DEV(pid) {
1620 		ports[pid].dev_conf.lpbk_mode = res->mode;
1621 	}
1622 
1623 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1624 }
1625 
1626 cmdline_parse_token_string_t cmd_config_loopback_all_port =
1627 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1628 cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1629 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1630 							"config");
1631 cmdline_parse_token_string_t cmd_config_loopback_all_all =
1632 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1633 cmdline_parse_token_string_t cmd_config_loopback_all_item =
1634 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1635 							"loopback");
1636 cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1637 	TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, UINT32);
1638 
1639 cmdline_parse_inst_t cmd_config_loopback_all = {
1640 	.f = cmd_config_loopback_all_parsed,
1641 	.data = NULL,
1642 	.help_str = "port config all loopback <mode>",
1643 	.tokens = {
1644 		(void *)&cmd_config_loopback_all_port,
1645 		(void *)&cmd_config_loopback_all_keyword,
1646 		(void *)&cmd_config_loopback_all_all,
1647 		(void *)&cmd_config_loopback_all_item,
1648 		(void *)&cmd_config_loopback_all_mode,
1649 		NULL,
1650 	},
1651 };
1652 
1653 /* *** configure loopback for specific port *** */
1654 struct cmd_config_loopback_specific {
1655 	cmdline_fixed_string_t port;
1656 	cmdline_fixed_string_t keyword;
1657 	uint16_t port_id;
1658 	cmdline_fixed_string_t item;
1659 	uint32_t mode;
1660 };
1661 
1662 static void
1663 cmd_config_loopback_specific_parsed(void *parsed_result,
1664 				__attribute__((unused)) struct cmdline *cl,
1665 				__attribute__((unused)) void *data)
1666 {
1667 	struct cmd_config_loopback_specific *res = parsed_result;
1668 
1669 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1670 		return;
1671 
1672 	if (!port_is_stopped(res->port_id)) {
1673 		printf("Please stop port %u first\n", res->port_id);
1674 		return;
1675 	}
1676 
1677 	ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1678 
1679 	cmd_reconfig_device_queue(res->port_id, 1, 1);
1680 }
1681 
1682 
1683 cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1684 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1685 								"port");
1686 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1687 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1688 								"config");
1689 cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1690 	TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1691 								UINT16);
1692 cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1693 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1694 								"loopback");
1695 cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1696 	TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1697 			      UINT32);
1698 
1699 cmdline_parse_inst_t cmd_config_loopback_specific = {
1700 	.f = cmd_config_loopback_specific_parsed,
1701 	.data = NULL,
1702 	.help_str = "port config <port_id> loopback <mode>",
1703 	.tokens = {
1704 		(void *)&cmd_config_loopback_specific_port,
1705 		(void *)&cmd_config_loopback_specific_keyword,
1706 		(void *)&cmd_config_loopback_specific_id,
1707 		(void *)&cmd_config_loopback_specific_item,
1708 		(void *)&cmd_config_loopback_specific_mode,
1709 		NULL,
1710 	},
1711 };
1712 
1713 /* *** configure txq/rxq, txd/rxd *** */
1714 struct cmd_config_rx_tx {
1715 	cmdline_fixed_string_t port;
1716 	cmdline_fixed_string_t keyword;
1717 	cmdline_fixed_string_t all;
1718 	cmdline_fixed_string_t name;
1719 	uint16_t value;
1720 };
1721 
1722 static void
1723 cmd_config_rx_tx_parsed(void *parsed_result,
1724 			__attribute__((unused)) struct cmdline *cl,
1725 			__attribute__((unused)) void *data)
1726 {
1727 	struct cmd_config_rx_tx *res = parsed_result;
1728 
1729 	if (!all_ports_stopped()) {
1730 		printf("Please stop all ports first\n");
1731 		return;
1732 	}
1733 	if (!strcmp(res->name, "rxq")) {
1734 		if (!res->value && !nb_txq) {
1735 			printf("Warning: Either rx or tx queues should be non zero\n");
1736 			return;
1737 		}
1738 		if (check_nb_rxq(res->value) != 0)
1739 			return;
1740 		nb_rxq = res->value;
1741 	}
1742 	else if (!strcmp(res->name, "txq")) {
1743 		if (!res->value && !nb_rxq) {
1744 			printf("Warning: Either rx or tx queues should be non zero\n");
1745 			return;
1746 		}
1747 		if (check_nb_txq(res->value) != 0)
1748 			return;
1749 		nb_txq = res->value;
1750 	}
1751 	else if (!strcmp(res->name, "rxd")) {
1752 		if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1753 			printf("rxd %d invalid - must be > 0 && <= %d\n",
1754 					res->value, RTE_TEST_RX_DESC_MAX);
1755 			return;
1756 		}
1757 		nb_rxd = res->value;
1758 	} else if (!strcmp(res->name, "txd")) {
1759 		if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1760 			printf("txd %d invalid - must be > 0 && <= %d\n",
1761 					res->value, RTE_TEST_TX_DESC_MAX);
1762 			return;
1763 		}
1764 		nb_txd = res->value;
1765 	} else {
1766 		printf("Unknown parameter\n");
1767 		return;
1768 	}
1769 
1770 	fwd_config_setup();
1771 
1772 	init_port_config();
1773 
1774 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1775 }
1776 
1777 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1778 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1779 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1780 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1781 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1782 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1783 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1784 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1785 						"rxq#txq#rxd#txd");
1786 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1787 	TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1788 
1789 cmdline_parse_inst_t cmd_config_rx_tx = {
1790 	.f = cmd_config_rx_tx_parsed,
1791 	.data = NULL,
1792 	.help_str = "port config all rxq|txq|rxd|txd <value>",
1793 	.tokens = {
1794 		(void *)&cmd_config_rx_tx_port,
1795 		(void *)&cmd_config_rx_tx_keyword,
1796 		(void *)&cmd_config_rx_tx_all,
1797 		(void *)&cmd_config_rx_tx_name,
1798 		(void *)&cmd_config_rx_tx_value,
1799 		NULL,
1800 	},
1801 };
1802 
1803 /* *** config max packet length *** */
1804 struct cmd_config_max_pkt_len_result {
1805 	cmdline_fixed_string_t port;
1806 	cmdline_fixed_string_t keyword;
1807 	cmdline_fixed_string_t all;
1808 	cmdline_fixed_string_t name;
1809 	uint32_t value;
1810 };
1811 
1812 static void
1813 cmd_config_max_pkt_len_parsed(void *parsed_result,
1814 				__attribute__((unused)) struct cmdline *cl,
1815 				__attribute__((unused)) void *data)
1816 {
1817 	struct cmd_config_max_pkt_len_result *res = parsed_result;
1818 	portid_t pid;
1819 
1820 	if (!all_ports_stopped()) {
1821 		printf("Please stop all ports first\n");
1822 		return;
1823 	}
1824 
1825 	RTE_ETH_FOREACH_DEV(pid) {
1826 		struct rte_port *port = &ports[pid];
1827 		uint64_t rx_offloads = port->dev_conf.rxmode.offloads;
1828 
1829 		if (!strcmp(res->name, "max-pkt-len")) {
1830 			if (res->value < ETHER_MIN_LEN) {
1831 				printf("max-pkt-len can not be less than %d\n",
1832 						ETHER_MIN_LEN);
1833 				return;
1834 			}
1835 			if (res->value == port->dev_conf.rxmode.max_rx_pkt_len)
1836 				return;
1837 
1838 			port->dev_conf.rxmode.max_rx_pkt_len = res->value;
1839 			if (res->value > ETHER_MAX_LEN)
1840 				rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
1841 			else
1842 				rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
1843 			port->dev_conf.rxmode.offloads = rx_offloads;
1844 		} else {
1845 			printf("Unknown parameter\n");
1846 			return;
1847 		}
1848 	}
1849 
1850 	init_port_config();
1851 
1852 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1853 }
1854 
1855 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1856 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1857 								"port");
1858 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1859 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1860 								"config");
1861 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1862 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1863 								"all");
1864 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1865 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1866 								"max-pkt-len");
1867 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1868 	TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1869 								UINT32);
1870 
1871 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1872 	.f = cmd_config_max_pkt_len_parsed,
1873 	.data = NULL,
1874 	.help_str = "port config all max-pkt-len <value>",
1875 	.tokens = {
1876 		(void *)&cmd_config_max_pkt_len_port,
1877 		(void *)&cmd_config_max_pkt_len_keyword,
1878 		(void *)&cmd_config_max_pkt_len_all,
1879 		(void *)&cmd_config_max_pkt_len_name,
1880 		(void *)&cmd_config_max_pkt_len_value,
1881 		NULL,
1882 	},
1883 };
1884 
1885 /* *** configure port MTU *** */
1886 struct cmd_config_mtu_result {
1887 	cmdline_fixed_string_t port;
1888 	cmdline_fixed_string_t keyword;
1889 	cmdline_fixed_string_t mtu;
1890 	portid_t port_id;
1891 	uint16_t value;
1892 };
1893 
1894 static void
1895 cmd_config_mtu_parsed(void *parsed_result,
1896 		      __attribute__((unused)) struct cmdline *cl,
1897 		      __attribute__((unused)) void *data)
1898 {
1899 	struct cmd_config_mtu_result *res = parsed_result;
1900 
1901 	if (res->value < ETHER_MIN_LEN) {
1902 		printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1903 		return;
1904 	}
1905 	port_mtu_set(res->port_id, res->value);
1906 }
1907 
1908 cmdline_parse_token_string_t cmd_config_mtu_port =
1909 	TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1910 				 "port");
1911 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1912 	TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1913 				 "config");
1914 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1915 	TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1916 				 "mtu");
1917 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1918 	TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT16);
1919 cmdline_parse_token_num_t cmd_config_mtu_value =
1920 	TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1921 
1922 cmdline_parse_inst_t cmd_config_mtu = {
1923 	.f = cmd_config_mtu_parsed,
1924 	.data = NULL,
1925 	.help_str = "port config mtu <port_id> <value>",
1926 	.tokens = {
1927 		(void *)&cmd_config_mtu_port,
1928 		(void *)&cmd_config_mtu_keyword,
1929 		(void *)&cmd_config_mtu_mtu,
1930 		(void *)&cmd_config_mtu_port_id,
1931 		(void *)&cmd_config_mtu_value,
1932 		NULL,
1933 	},
1934 };
1935 
1936 /* *** configure rx mode *** */
1937 struct cmd_config_rx_mode_flag {
1938 	cmdline_fixed_string_t port;
1939 	cmdline_fixed_string_t keyword;
1940 	cmdline_fixed_string_t all;
1941 	cmdline_fixed_string_t name;
1942 	cmdline_fixed_string_t value;
1943 };
1944 
1945 static void
1946 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1947 				__attribute__((unused)) struct cmdline *cl,
1948 				__attribute__((unused)) void *data)
1949 {
1950 	struct cmd_config_rx_mode_flag *res = parsed_result;
1951 	portid_t pid;
1952 
1953 	if (!all_ports_stopped()) {
1954 		printf("Please stop all ports first\n");
1955 		return;
1956 	}
1957 
1958 	RTE_ETH_FOREACH_DEV(pid) {
1959 		struct rte_port *port;
1960 		uint64_t rx_offloads;
1961 
1962 		port = &ports[pid];
1963 		rx_offloads = port->dev_conf.rxmode.offloads;
1964 		if (!strcmp(res->name, "crc-strip")) {
1965 			if (!strcmp(res->value, "on")) {
1966 				rx_offloads &= ~DEV_RX_OFFLOAD_KEEP_CRC;
1967 			} else if (!strcmp(res->value, "off")) {
1968 				rx_offloads |= DEV_RX_OFFLOAD_KEEP_CRC;
1969 			} else {
1970 				printf("Unknown parameter\n");
1971 				return;
1972 			}
1973 		} else if (!strcmp(res->name, "scatter")) {
1974 			if (!strcmp(res->value, "on")) {
1975 				rx_offloads |= DEV_RX_OFFLOAD_SCATTER;
1976 			} else if (!strcmp(res->value, "off")) {
1977 				rx_offloads &= ~DEV_RX_OFFLOAD_SCATTER;
1978 			} else {
1979 				printf("Unknown parameter\n");
1980 				return;
1981 			}
1982 		} else if (!strcmp(res->name, "rx-cksum")) {
1983 			if (!strcmp(res->value, "on"))
1984 				rx_offloads |= DEV_RX_OFFLOAD_CHECKSUM;
1985 			else if (!strcmp(res->value, "off"))
1986 				rx_offloads &= ~DEV_RX_OFFLOAD_CHECKSUM;
1987 			else {
1988 				printf("Unknown parameter\n");
1989 				return;
1990 			}
1991 		} else if (!strcmp(res->name, "rx-timestamp")) {
1992 			if (!strcmp(res->value, "on"))
1993 				rx_offloads |= DEV_RX_OFFLOAD_TIMESTAMP;
1994 			else if (!strcmp(res->value, "off"))
1995 				rx_offloads &= ~DEV_RX_OFFLOAD_TIMESTAMP;
1996 			else {
1997 				printf("Unknown parameter\n");
1998 				return;
1999 			}
2000 		} else if (!strcmp(res->name, "hw-vlan")) {
2001 			if (!strcmp(res->value, "on")) {
2002 				rx_offloads |= (DEV_RX_OFFLOAD_VLAN_FILTER |
2003 						DEV_RX_OFFLOAD_VLAN_STRIP);
2004 			} else if (!strcmp(res->value, "off")) {
2005 				rx_offloads &= ~(DEV_RX_OFFLOAD_VLAN_FILTER |
2006 						DEV_RX_OFFLOAD_VLAN_STRIP);
2007 			} else {
2008 				printf("Unknown parameter\n");
2009 				return;
2010 			}
2011 		} else if (!strcmp(res->name, "hw-vlan-filter")) {
2012 			if (!strcmp(res->value, "on"))
2013 				rx_offloads |= DEV_RX_OFFLOAD_VLAN_FILTER;
2014 			else if (!strcmp(res->value, "off"))
2015 				rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_FILTER;
2016 			else {
2017 				printf("Unknown parameter\n");
2018 				return;
2019 			}
2020 		} else if (!strcmp(res->name, "hw-vlan-strip")) {
2021 			if (!strcmp(res->value, "on"))
2022 				rx_offloads |= DEV_RX_OFFLOAD_VLAN_STRIP;
2023 			else if (!strcmp(res->value, "off"))
2024 				rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_STRIP;
2025 			else {
2026 				printf("Unknown parameter\n");
2027 				return;
2028 			}
2029 		} else if (!strcmp(res->name, "hw-vlan-extend")) {
2030 			if (!strcmp(res->value, "on"))
2031 				rx_offloads |= DEV_RX_OFFLOAD_VLAN_EXTEND;
2032 			else if (!strcmp(res->value, "off"))
2033 				rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_EXTEND;
2034 			else {
2035 				printf("Unknown parameter\n");
2036 				return;
2037 			}
2038 		} else if (!strcmp(res->name, "drop-en")) {
2039 			if (!strcmp(res->value, "on"))
2040 				rx_drop_en = 1;
2041 			else if (!strcmp(res->value, "off"))
2042 				rx_drop_en = 0;
2043 			else {
2044 				printf("Unknown parameter\n");
2045 				return;
2046 			}
2047 		} else {
2048 			printf("Unknown parameter\n");
2049 			return;
2050 		}
2051 		port->dev_conf.rxmode.offloads = rx_offloads;
2052 	}
2053 
2054 	init_port_config();
2055 
2056 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2057 }
2058 
2059 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
2060 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
2061 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
2062 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
2063 								"config");
2064 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2065 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2066 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2067 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2068 					"crc-strip#scatter#rx-cksum#rx-timestamp#hw-vlan#"
2069 					"hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
2070 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2071 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2072 							"on#off");
2073 
2074 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2075 	.f = cmd_config_rx_mode_flag_parsed,
2076 	.data = NULL,
2077 	.help_str = "port config all crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|"
2078 		"hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
2079 	.tokens = {
2080 		(void *)&cmd_config_rx_mode_flag_port,
2081 		(void *)&cmd_config_rx_mode_flag_keyword,
2082 		(void *)&cmd_config_rx_mode_flag_all,
2083 		(void *)&cmd_config_rx_mode_flag_name,
2084 		(void *)&cmd_config_rx_mode_flag_value,
2085 		NULL,
2086 	},
2087 };
2088 
2089 /* *** configure rss *** */
2090 struct cmd_config_rss {
2091 	cmdline_fixed_string_t port;
2092 	cmdline_fixed_string_t keyword;
2093 	cmdline_fixed_string_t all;
2094 	cmdline_fixed_string_t name;
2095 	cmdline_fixed_string_t value;
2096 };
2097 
2098 static void
2099 cmd_config_rss_parsed(void *parsed_result,
2100 			__attribute__((unused)) struct cmdline *cl,
2101 			__attribute__((unused)) void *data)
2102 {
2103 	struct cmd_config_rss *res = parsed_result;
2104 	struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2105 	struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2106 	int use_default = 0;
2107 	int all_updated = 1;
2108 	int diag;
2109 	uint16_t i;
2110 
2111 	if (!strcmp(res->value, "all"))
2112 		rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
2113 				ETH_RSS_UDP | ETH_RSS_SCTP |
2114 					ETH_RSS_L2_PAYLOAD;
2115 	else if (!strcmp(res->value, "ip"))
2116 		rss_conf.rss_hf = ETH_RSS_IP;
2117 	else if (!strcmp(res->value, "udp"))
2118 		rss_conf.rss_hf = ETH_RSS_UDP;
2119 	else if (!strcmp(res->value, "tcp"))
2120 		rss_conf.rss_hf = ETH_RSS_TCP;
2121 	else if (!strcmp(res->value, "sctp"))
2122 		rss_conf.rss_hf = ETH_RSS_SCTP;
2123 	else if (!strcmp(res->value, "ether"))
2124 		rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
2125 	else if (!strcmp(res->value, "port"))
2126 		rss_conf.rss_hf = ETH_RSS_PORT;
2127 	else if (!strcmp(res->value, "vxlan"))
2128 		rss_conf.rss_hf = ETH_RSS_VXLAN;
2129 	else if (!strcmp(res->value, "geneve"))
2130 		rss_conf.rss_hf = ETH_RSS_GENEVE;
2131 	else if (!strcmp(res->value, "nvgre"))
2132 		rss_conf.rss_hf = ETH_RSS_NVGRE;
2133 	else if (!strcmp(res->value, "none"))
2134 		rss_conf.rss_hf = 0;
2135 	else if (!strcmp(res->value, "default"))
2136 		use_default = 1;
2137 	else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2138 						atoi(res->value) < 64)
2139 		rss_conf.rss_hf = 1ULL << atoi(res->value);
2140 	else {
2141 		printf("Unknown parameter\n");
2142 		return;
2143 	}
2144 	rss_conf.rss_key = NULL;
2145 	/* Update global configuration for RSS types. */
2146 	RTE_ETH_FOREACH_DEV(i) {
2147 		struct rte_eth_rss_conf local_rss_conf;
2148 
2149 		rte_eth_dev_info_get(i, &dev_info);
2150 		if (use_default)
2151 			rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2152 
2153 		local_rss_conf = rss_conf;
2154 		local_rss_conf.rss_hf = rss_conf.rss_hf &
2155 			dev_info.flow_type_rss_offloads;
2156 		if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2157 			printf("Port %u modified RSS hash function based on hardware support,"
2158 				"requested:%#"PRIx64" configured:%#"PRIx64"\n",
2159 				i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2160 		}
2161 		diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2162 		if (diag < 0) {
2163 			all_updated = 0;
2164 			printf("Configuration of RSS hash at ethernet port %d "
2165 				"failed with error (%d): %s.\n",
2166 				i, -diag, strerror(-diag));
2167 		}
2168 	}
2169 	if (all_updated && !use_default)
2170 		rss_hf = rss_conf.rss_hf;
2171 }
2172 
2173 cmdline_parse_token_string_t cmd_config_rss_port =
2174 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2175 cmdline_parse_token_string_t cmd_config_rss_keyword =
2176 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2177 cmdline_parse_token_string_t cmd_config_rss_all =
2178 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2179 cmdline_parse_token_string_t cmd_config_rss_name =
2180 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2181 cmdline_parse_token_string_t cmd_config_rss_value =
2182 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2183 
2184 cmdline_parse_inst_t cmd_config_rss = {
2185 	.f = cmd_config_rss_parsed,
2186 	.data = NULL,
2187 	.help_str = "port config all rss "
2188 		"all|default|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none|<flowtype_id>",
2189 	.tokens = {
2190 		(void *)&cmd_config_rss_port,
2191 		(void *)&cmd_config_rss_keyword,
2192 		(void *)&cmd_config_rss_all,
2193 		(void *)&cmd_config_rss_name,
2194 		(void *)&cmd_config_rss_value,
2195 		NULL,
2196 	},
2197 };
2198 
2199 /* *** configure rss hash key *** */
2200 struct cmd_config_rss_hash_key {
2201 	cmdline_fixed_string_t port;
2202 	cmdline_fixed_string_t config;
2203 	portid_t port_id;
2204 	cmdline_fixed_string_t rss_hash_key;
2205 	cmdline_fixed_string_t rss_type;
2206 	cmdline_fixed_string_t key;
2207 };
2208 
2209 static uint8_t
2210 hexa_digit_to_value(char hexa_digit)
2211 {
2212 	if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2213 		return (uint8_t) (hexa_digit - '0');
2214 	if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2215 		return (uint8_t) ((hexa_digit - 'a') + 10);
2216 	if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2217 		return (uint8_t) ((hexa_digit - 'A') + 10);
2218 	/* Invalid hexa digit */
2219 	return 0xFF;
2220 }
2221 
2222 static uint8_t
2223 parse_and_check_key_hexa_digit(char *key, int idx)
2224 {
2225 	uint8_t hexa_v;
2226 
2227 	hexa_v = hexa_digit_to_value(key[idx]);
2228 	if (hexa_v == 0xFF)
2229 		printf("invalid key: character %c at position %d is not a "
2230 		       "valid hexa digit\n", key[idx], idx);
2231 	return hexa_v;
2232 }
2233 
2234 static void
2235 cmd_config_rss_hash_key_parsed(void *parsed_result,
2236 			       __attribute__((unused)) struct cmdline *cl,
2237 			       __attribute__((unused)) void *data)
2238 {
2239 	struct cmd_config_rss_hash_key *res = parsed_result;
2240 	uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2241 	uint8_t xdgt0;
2242 	uint8_t xdgt1;
2243 	int i;
2244 	struct rte_eth_dev_info dev_info;
2245 	uint8_t hash_key_size;
2246 	uint32_t key_len;
2247 
2248 	memset(&dev_info, 0, sizeof(dev_info));
2249 	rte_eth_dev_info_get(res->port_id, &dev_info);
2250 	if (dev_info.hash_key_size > 0 &&
2251 			dev_info.hash_key_size <= sizeof(hash_key))
2252 		hash_key_size = dev_info.hash_key_size;
2253 	else {
2254 		printf("dev_info did not provide a valid hash key size\n");
2255 		return;
2256 	}
2257 	/* Check the length of the RSS hash key */
2258 	key_len = strlen(res->key);
2259 	if (key_len != (hash_key_size * 2)) {
2260 		printf("key length: %d invalid - key must be a string of %d"
2261 			   " hexa-decimal numbers\n",
2262 			   (int) key_len, hash_key_size * 2);
2263 		return;
2264 	}
2265 	/* Translate RSS hash key into binary representation */
2266 	for (i = 0; i < hash_key_size; i++) {
2267 		xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2268 		if (xdgt0 == 0xFF)
2269 			return;
2270 		xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2271 		if (xdgt1 == 0xFF)
2272 			return;
2273 		hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2274 	}
2275 	port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2276 			hash_key_size);
2277 }
2278 
2279 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2280 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2281 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2282 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2283 				 "config");
2284 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2285 	TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16);
2286 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2287 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2288 				 rss_hash_key, "rss-hash-key");
2289 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2290 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2291 				 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2292 				 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2293 				 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2294 				 "ipv6-tcp-ex#ipv6-udp-ex");
2295 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2296 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2297 
2298 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2299 	.f = cmd_config_rss_hash_key_parsed,
2300 	.data = NULL,
2301 	.help_str = "port config <port_id> rss-hash-key "
2302 		"ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2303 		"ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2304 		"l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex "
2305 		"<string of hex digits (variable length, NIC dependent)>",
2306 	.tokens = {
2307 		(void *)&cmd_config_rss_hash_key_port,
2308 		(void *)&cmd_config_rss_hash_key_config,
2309 		(void *)&cmd_config_rss_hash_key_port_id,
2310 		(void *)&cmd_config_rss_hash_key_rss_hash_key,
2311 		(void *)&cmd_config_rss_hash_key_rss_type,
2312 		(void *)&cmd_config_rss_hash_key_value,
2313 		NULL,
2314 	},
2315 };
2316 
2317 /* *** configure port rxq/txq ring size *** */
2318 struct cmd_config_rxtx_ring_size {
2319 	cmdline_fixed_string_t port;
2320 	cmdline_fixed_string_t config;
2321 	portid_t portid;
2322 	cmdline_fixed_string_t rxtxq;
2323 	uint16_t qid;
2324 	cmdline_fixed_string_t rsize;
2325 	uint16_t size;
2326 };
2327 
2328 static void
2329 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2330 				 __attribute__((unused)) struct cmdline *cl,
2331 				 __attribute__((unused)) void *data)
2332 {
2333 	struct cmd_config_rxtx_ring_size *res = parsed_result;
2334 	struct rte_port *port;
2335 	uint8_t isrx;
2336 
2337 	if (port_id_is_invalid(res->portid, ENABLED_WARN))
2338 		return;
2339 
2340 	if (res->portid == (portid_t)RTE_PORT_ALL) {
2341 		printf("Invalid port id\n");
2342 		return;
2343 	}
2344 
2345 	port = &ports[res->portid];
2346 
2347 	if (!strcmp(res->rxtxq, "rxq"))
2348 		isrx = 1;
2349 	else if (!strcmp(res->rxtxq, "txq"))
2350 		isrx = 0;
2351 	else {
2352 		printf("Unknown parameter\n");
2353 		return;
2354 	}
2355 
2356 	if (isrx && rx_queue_id_is_invalid(res->qid))
2357 		return;
2358 	else if (!isrx && tx_queue_id_is_invalid(res->qid))
2359 		return;
2360 
2361 	if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2362 		printf("Invalid rx ring_size, must > rx_free_thresh: %d\n",
2363 		       rx_free_thresh);
2364 		return;
2365 	}
2366 
2367 	if (isrx)
2368 		port->nb_rx_desc[res->qid] = res->size;
2369 	else
2370 		port->nb_tx_desc[res->qid] = res->size;
2371 
2372 	cmd_reconfig_device_queue(res->portid, 0, 1);
2373 }
2374 
2375 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2376 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2377 				 port, "port");
2378 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2379 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2380 				 config, "config");
2381 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2382 	TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2383 				 portid, UINT16);
2384 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2385 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2386 				 rxtxq, "rxq#txq");
2387 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2388 	TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2389 			      qid, UINT16);
2390 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2391 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2392 				 rsize, "ring_size");
2393 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2394 	TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2395 			      size, UINT16);
2396 
2397 cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2398 	.f = cmd_config_rxtx_ring_size_parsed,
2399 	.data = NULL,
2400 	.help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2401 	.tokens = {
2402 		(void *)&cmd_config_rxtx_ring_size_port,
2403 		(void *)&cmd_config_rxtx_ring_size_config,
2404 		(void *)&cmd_config_rxtx_ring_size_portid,
2405 		(void *)&cmd_config_rxtx_ring_size_rxtxq,
2406 		(void *)&cmd_config_rxtx_ring_size_qid,
2407 		(void *)&cmd_config_rxtx_ring_size_rsize,
2408 		(void *)&cmd_config_rxtx_ring_size_size,
2409 		NULL,
2410 	},
2411 };
2412 
2413 /* *** configure port rxq/txq start/stop *** */
2414 struct cmd_config_rxtx_queue {
2415 	cmdline_fixed_string_t port;
2416 	portid_t portid;
2417 	cmdline_fixed_string_t rxtxq;
2418 	uint16_t qid;
2419 	cmdline_fixed_string_t opname;
2420 };
2421 
2422 static void
2423 cmd_config_rxtx_queue_parsed(void *parsed_result,
2424 			__attribute__((unused)) struct cmdline *cl,
2425 			__attribute__((unused)) void *data)
2426 {
2427 	struct cmd_config_rxtx_queue *res = parsed_result;
2428 	uint8_t isrx;
2429 	uint8_t isstart;
2430 	int ret = 0;
2431 
2432 	if (test_done == 0) {
2433 		printf("Please stop forwarding first\n");
2434 		return;
2435 	}
2436 
2437 	if (port_id_is_invalid(res->portid, ENABLED_WARN))
2438 		return;
2439 
2440 	if (port_is_started(res->portid) != 1) {
2441 		printf("Please start port %u first\n", res->portid);
2442 		return;
2443 	}
2444 
2445 	if (!strcmp(res->rxtxq, "rxq"))
2446 		isrx = 1;
2447 	else if (!strcmp(res->rxtxq, "txq"))
2448 		isrx = 0;
2449 	else {
2450 		printf("Unknown parameter\n");
2451 		return;
2452 	}
2453 
2454 	if (isrx && rx_queue_id_is_invalid(res->qid))
2455 		return;
2456 	else if (!isrx && tx_queue_id_is_invalid(res->qid))
2457 		return;
2458 
2459 	if (!strcmp(res->opname, "start"))
2460 		isstart = 1;
2461 	else if (!strcmp(res->opname, "stop"))
2462 		isstart = 0;
2463 	else {
2464 		printf("Unknown parameter\n");
2465 		return;
2466 	}
2467 
2468 	if (isstart && isrx)
2469 		ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2470 	else if (!isstart && isrx)
2471 		ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2472 	else if (isstart && !isrx)
2473 		ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2474 	else
2475 		ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2476 
2477 	if (ret == -ENOTSUP)
2478 		printf("Function not supported in PMD driver\n");
2479 }
2480 
2481 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2482 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2483 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2484 	TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16);
2485 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2486 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2487 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2488 	TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
2489 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2490 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2491 						"start#stop");
2492 
2493 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2494 	.f = cmd_config_rxtx_queue_parsed,
2495 	.data = NULL,
2496 	.help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2497 	.tokens = {
2498 		(void *)&cmd_config_rxtx_queue_port,
2499 		(void *)&cmd_config_rxtx_queue_portid,
2500 		(void *)&cmd_config_rxtx_queue_rxtxq,
2501 		(void *)&cmd_config_rxtx_queue_qid,
2502 		(void *)&cmd_config_rxtx_queue_opname,
2503 		NULL,
2504 	},
2505 };
2506 
2507 /* *** configure port rxq/txq deferred start on/off *** */
2508 struct cmd_config_deferred_start_rxtx_queue {
2509 	cmdline_fixed_string_t port;
2510 	portid_t port_id;
2511 	cmdline_fixed_string_t rxtxq;
2512 	uint16_t qid;
2513 	cmdline_fixed_string_t opname;
2514 	cmdline_fixed_string_t state;
2515 };
2516 
2517 static void
2518 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2519 			__attribute__((unused)) struct cmdline *cl,
2520 			__attribute__((unused)) void *data)
2521 {
2522 	struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2523 	struct rte_port *port;
2524 	uint8_t isrx;
2525 	uint8_t ison;
2526 	uint8_t needreconfig = 0;
2527 
2528 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2529 		return;
2530 
2531 	if (port_is_started(res->port_id) != 0) {
2532 		printf("Please stop port %u first\n", res->port_id);
2533 		return;
2534 	}
2535 
2536 	port = &ports[res->port_id];
2537 
2538 	isrx = !strcmp(res->rxtxq, "rxq");
2539 
2540 	if (isrx && rx_queue_id_is_invalid(res->qid))
2541 		return;
2542 	else if (!isrx && tx_queue_id_is_invalid(res->qid))
2543 		return;
2544 
2545 	ison = !strcmp(res->state, "on");
2546 
2547 	if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) {
2548 		port->rx_conf[res->qid].rx_deferred_start = ison;
2549 		needreconfig = 1;
2550 	} else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) {
2551 		port->tx_conf[res->qid].tx_deferred_start = ison;
2552 		needreconfig = 1;
2553 	}
2554 
2555 	if (needreconfig)
2556 		cmd_reconfig_device_queue(res->port_id, 0, 1);
2557 }
2558 
2559 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2560 	TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2561 						port, "port");
2562 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2563 	TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2564 						port_id, UINT16);
2565 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2566 	TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2567 						rxtxq, "rxq#txq");
2568 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2569 	TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2570 						qid, UINT16);
2571 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2572 	TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2573 						opname, "deferred_start");
2574 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2575 	TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2576 						state, "on#off");
2577 
2578 cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
2579 	.f = cmd_config_deferred_start_rxtx_queue_parsed,
2580 	.data = NULL,
2581 	.help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
2582 	.tokens = {
2583 		(void *)&cmd_config_deferred_start_rxtx_queue_port,
2584 		(void *)&cmd_config_deferred_start_rxtx_queue_port_id,
2585 		(void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
2586 		(void *)&cmd_config_deferred_start_rxtx_queue_qid,
2587 		(void *)&cmd_config_deferred_start_rxtx_queue_opname,
2588 		(void *)&cmd_config_deferred_start_rxtx_queue_state,
2589 		NULL,
2590 	},
2591 };
2592 
2593 /* *** configure port rxq/txq setup *** */
2594 struct cmd_setup_rxtx_queue {
2595 	cmdline_fixed_string_t port;
2596 	portid_t portid;
2597 	cmdline_fixed_string_t rxtxq;
2598 	uint16_t qid;
2599 	cmdline_fixed_string_t setup;
2600 };
2601 
2602 /* Common CLI fields for queue setup */
2603 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2604 	TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2605 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2606 	TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, UINT16);
2607 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2608 	TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2609 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2610 	TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, UINT16);
2611 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2612 	TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2613 
2614 static void
2615 cmd_setup_rxtx_queue_parsed(
2616 	void *parsed_result,
2617 	__attribute__((unused)) struct cmdline *cl,
2618 	__attribute__((unused)) void *data)
2619 {
2620 	struct cmd_setup_rxtx_queue *res = parsed_result;
2621 	struct rte_port *port;
2622 	struct rte_mempool *mp;
2623 	unsigned int socket_id;
2624 	uint8_t isrx = 0;
2625 	int ret;
2626 
2627 	if (port_id_is_invalid(res->portid, ENABLED_WARN))
2628 		return;
2629 
2630 	if (res->portid == (portid_t)RTE_PORT_ALL) {
2631 		printf("Invalid port id\n");
2632 		return;
2633 	}
2634 
2635 	if (!strcmp(res->rxtxq, "rxq"))
2636 		isrx = 1;
2637 	else if (!strcmp(res->rxtxq, "txq"))
2638 		isrx = 0;
2639 	else {
2640 		printf("Unknown parameter\n");
2641 		return;
2642 	}
2643 
2644 	if (isrx && rx_queue_id_is_invalid(res->qid)) {
2645 		printf("Invalid rx queue\n");
2646 		return;
2647 	} else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2648 		printf("Invalid tx queue\n");
2649 		return;
2650 	}
2651 
2652 	port = &ports[res->portid];
2653 	if (isrx) {
2654 		socket_id = rxring_numa[res->portid];
2655 		if (!numa_support || socket_id == NUMA_NO_CONFIG)
2656 			socket_id = port->socket_id;
2657 
2658 		mp = mbuf_pool_find(socket_id);
2659 		if (mp == NULL) {
2660 			printf("Failed to setup RX queue: "
2661 				"No mempool allocation"
2662 				" on the socket %d\n",
2663 				rxring_numa[res->portid]);
2664 			return;
2665 		}
2666 		ret = rte_eth_rx_queue_setup(res->portid,
2667 					     res->qid,
2668 					     port->nb_rx_desc[res->qid],
2669 					     socket_id,
2670 					     &port->rx_conf[res->qid],
2671 					     mp);
2672 		if (ret)
2673 			printf("Failed to setup RX queue\n");
2674 	} else {
2675 		socket_id = txring_numa[res->portid];
2676 		if (!numa_support || socket_id == NUMA_NO_CONFIG)
2677 			socket_id = port->socket_id;
2678 
2679 		ret = rte_eth_tx_queue_setup(res->portid,
2680 					     res->qid,
2681 					     port->nb_tx_desc[res->qid],
2682 					     socket_id,
2683 					     &port->tx_conf[res->qid]);
2684 		if (ret)
2685 			printf("Failed to setup TX queue\n");
2686 	}
2687 }
2688 
2689 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2690 	.f = cmd_setup_rxtx_queue_parsed,
2691 	.data = NULL,
2692 	.help_str = "port <port_id> rxq|txq <queue_idx> setup",
2693 	.tokens = {
2694 		(void *)&cmd_setup_rxtx_queue_port,
2695 		(void *)&cmd_setup_rxtx_queue_portid,
2696 		(void *)&cmd_setup_rxtx_queue_rxtxq,
2697 		(void *)&cmd_setup_rxtx_queue_qid,
2698 		(void *)&cmd_setup_rxtx_queue_setup,
2699 		NULL,
2700 	},
2701 };
2702 
2703 
2704 /* *** Configure RSS RETA *** */
2705 struct cmd_config_rss_reta {
2706 	cmdline_fixed_string_t port;
2707 	cmdline_fixed_string_t keyword;
2708 	portid_t port_id;
2709 	cmdline_fixed_string_t name;
2710 	cmdline_fixed_string_t list_name;
2711 	cmdline_fixed_string_t list_of_items;
2712 };
2713 
2714 static int
2715 parse_reta_config(const char *str,
2716 		  struct rte_eth_rss_reta_entry64 *reta_conf,
2717 		  uint16_t nb_entries)
2718 {
2719 	int i;
2720 	unsigned size;
2721 	uint16_t hash_index, idx, shift;
2722 	uint16_t nb_queue;
2723 	char s[256];
2724 	const char *p, *p0 = str;
2725 	char *end;
2726 	enum fieldnames {
2727 		FLD_HASH_INDEX = 0,
2728 		FLD_QUEUE,
2729 		_NUM_FLD
2730 	};
2731 	unsigned long int_fld[_NUM_FLD];
2732 	char *str_fld[_NUM_FLD];
2733 
2734 	while ((p = strchr(p0,'(')) != NULL) {
2735 		++p;
2736 		if((p0 = strchr(p,')')) == NULL)
2737 			return -1;
2738 
2739 		size = p0 - p;
2740 		if(size >= sizeof(s))
2741 			return -1;
2742 
2743 		snprintf(s, sizeof(s), "%.*s", size, p);
2744 		if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2745 			return -1;
2746 		for (i = 0; i < _NUM_FLD; i++) {
2747 			errno = 0;
2748 			int_fld[i] = strtoul(str_fld[i], &end, 0);
2749 			if (errno != 0 || end == str_fld[i] ||
2750 					int_fld[i] > 65535)
2751 				return -1;
2752 		}
2753 
2754 		hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2755 		nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2756 
2757 		if (hash_index >= nb_entries) {
2758 			printf("Invalid RETA hash index=%d\n", hash_index);
2759 			return -1;
2760 		}
2761 
2762 		idx = hash_index / RTE_RETA_GROUP_SIZE;
2763 		shift = hash_index % RTE_RETA_GROUP_SIZE;
2764 		reta_conf[idx].mask |= (1ULL << shift);
2765 		reta_conf[idx].reta[shift] = nb_queue;
2766 	}
2767 
2768 	return 0;
2769 }
2770 
2771 static void
2772 cmd_set_rss_reta_parsed(void *parsed_result,
2773 			__attribute__((unused)) struct cmdline *cl,
2774 			__attribute__((unused)) void *data)
2775 {
2776 	int ret;
2777 	struct rte_eth_dev_info dev_info;
2778 	struct rte_eth_rss_reta_entry64 reta_conf[8];
2779 	struct cmd_config_rss_reta *res = parsed_result;
2780 
2781 	memset(&dev_info, 0, sizeof(dev_info));
2782 	rte_eth_dev_info_get(res->port_id, &dev_info);
2783 	if (dev_info.reta_size == 0) {
2784 		printf("Redirection table size is 0 which is "
2785 					"invalid for RSS\n");
2786 		return;
2787 	} else
2788 		printf("The reta size of port %d is %u\n",
2789 			res->port_id, dev_info.reta_size);
2790 	if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2791 		printf("Currently do not support more than %u entries of "
2792 			"redirection table\n", ETH_RSS_RETA_SIZE_512);
2793 		return;
2794 	}
2795 
2796 	memset(reta_conf, 0, sizeof(reta_conf));
2797 	if (!strcmp(res->list_name, "reta")) {
2798 		if (parse_reta_config(res->list_of_items, reta_conf,
2799 						dev_info.reta_size)) {
2800 			printf("Invalid RSS Redirection Table "
2801 					"config entered\n");
2802 			return;
2803 		}
2804 		ret = rte_eth_dev_rss_reta_update(res->port_id,
2805 				reta_conf, dev_info.reta_size);
2806 		if (ret != 0)
2807 			printf("Bad redirection table parameter, "
2808 					"return code = %d \n", ret);
2809 	}
2810 }
2811 
2812 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2813 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2814 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2815 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2816 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2817 	TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16);
2818 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2819 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2820 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2821 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2822 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2823         TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2824                                  NULL);
2825 cmdline_parse_inst_t cmd_config_rss_reta = {
2826 	.f = cmd_set_rss_reta_parsed,
2827 	.data = NULL,
2828 	.help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2829 	.tokens = {
2830 		(void *)&cmd_config_rss_reta_port,
2831 		(void *)&cmd_config_rss_reta_keyword,
2832 		(void *)&cmd_config_rss_reta_port_id,
2833 		(void *)&cmd_config_rss_reta_name,
2834 		(void *)&cmd_config_rss_reta_list_name,
2835 		(void *)&cmd_config_rss_reta_list_of_items,
2836 		NULL,
2837 	},
2838 };
2839 
2840 /* *** SHOW PORT RETA INFO *** */
2841 struct cmd_showport_reta {
2842 	cmdline_fixed_string_t show;
2843 	cmdline_fixed_string_t port;
2844 	portid_t port_id;
2845 	cmdline_fixed_string_t rss;
2846 	cmdline_fixed_string_t reta;
2847 	uint16_t size;
2848 	cmdline_fixed_string_t list_of_items;
2849 };
2850 
2851 static int
2852 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2853 			   uint16_t nb_entries,
2854 			   char *str)
2855 {
2856 	uint32_t size;
2857 	const char *p, *p0 = str;
2858 	char s[256];
2859 	char *end;
2860 	char *str_fld[8];
2861 	uint16_t i;
2862 	uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
2863 			RTE_RETA_GROUP_SIZE;
2864 	int ret;
2865 
2866 	p = strchr(p0, '(');
2867 	if (p == NULL)
2868 		return -1;
2869 	p++;
2870 	p0 = strchr(p, ')');
2871 	if (p0 == NULL)
2872 		return -1;
2873 	size = p0 - p;
2874 	if (size >= sizeof(s)) {
2875 		printf("The string size exceeds the internal buffer size\n");
2876 		return -1;
2877 	}
2878 	snprintf(s, sizeof(s), "%.*s", size, p);
2879 	ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
2880 	if (ret <= 0 || ret != num) {
2881 		printf("The bits of masks do not match the number of "
2882 					"reta entries: %u\n", num);
2883 		return -1;
2884 	}
2885 	for (i = 0; i < ret; i++)
2886 		conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
2887 
2888 	return 0;
2889 }
2890 
2891 static void
2892 cmd_showport_reta_parsed(void *parsed_result,
2893 			 __attribute__((unused)) struct cmdline *cl,
2894 			 __attribute__((unused)) void *data)
2895 {
2896 	struct cmd_showport_reta *res = parsed_result;
2897 	struct rte_eth_rss_reta_entry64 reta_conf[8];
2898 	struct rte_eth_dev_info dev_info;
2899 	uint16_t max_reta_size;
2900 
2901 	memset(&dev_info, 0, sizeof(dev_info));
2902 	rte_eth_dev_info_get(res->port_id, &dev_info);
2903 	max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
2904 	if (res->size == 0 || res->size > max_reta_size) {
2905 		printf("Invalid redirection table size: %u (1-%u)\n",
2906 			res->size, max_reta_size);
2907 		return;
2908 	}
2909 
2910 	memset(reta_conf, 0, sizeof(reta_conf));
2911 	if (showport_parse_reta_config(reta_conf, res->size,
2912 				res->list_of_items) < 0) {
2913 		printf("Invalid string: %s for reta masks\n",
2914 					res->list_of_items);
2915 		return;
2916 	}
2917 	port_rss_reta_info(res->port_id, reta_conf, res->size);
2918 }
2919 
2920 cmdline_parse_token_string_t cmd_showport_reta_show =
2921 	TOKEN_STRING_INITIALIZER(struct  cmd_showport_reta, show, "show");
2922 cmdline_parse_token_string_t cmd_showport_reta_port =
2923 	TOKEN_STRING_INITIALIZER(struct  cmd_showport_reta, port, "port");
2924 cmdline_parse_token_num_t cmd_showport_reta_port_id =
2925 	TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16);
2926 cmdline_parse_token_string_t cmd_showport_reta_rss =
2927 	TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
2928 cmdline_parse_token_string_t cmd_showport_reta_reta =
2929 	TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
2930 cmdline_parse_token_num_t cmd_showport_reta_size =
2931 	TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
2932 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
2933 	TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
2934 					list_of_items, NULL);
2935 
2936 cmdline_parse_inst_t cmd_showport_reta = {
2937 	.f = cmd_showport_reta_parsed,
2938 	.data = NULL,
2939 	.help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
2940 	.tokens = {
2941 		(void *)&cmd_showport_reta_show,
2942 		(void *)&cmd_showport_reta_port,
2943 		(void *)&cmd_showport_reta_port_id,
2944 		(void *)&cmd_showport_reta_rss,
2945 		(void *)&cmd_showport_reta_reta,
2946 		(void *)&cmd_showport_reta_size,
2947 		(void *)&cmd_showport_reta_list_of_items,
2948 		NULL,
2949 	},
2950 };
2951 
2952 /* *** Show RSS hash configuration *** */
2953 struct cmd_showport_rss_hash {
2954 	cmdline_fixed_string_t show;
2955 	cmdline_fixed_string_t port;
2956 	portid_t port_id;
2957 	cmdline_fixed_string_t rss_hash;
2958 	cmdline_fixed_string_t rss_type;
2959 	cmdline_fixed_string_t key; /* optional argument */
2960 };
2961 
2962 static void cmd_showport_rss_hash_parsed(void *parsed_result,
2963 				__attribute__((unused)) struct cmdline *cl,
2964 				void *show_rss_key)
2965 {
2966 	struct cmd_showport_rss_hash *res = parsed_result;
2967 
2968 	port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
2969 }
2970 
2971 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
2972 	TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
2973 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
2974 	TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
2975 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
2976 	TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16);
2977 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
2978 	TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
2979 				 "rss-hash");
2980 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
2981 	TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
2982 
2983 cmdline_parse_inst_t cmd_showport_rss_hash = {
2984 	.f = cmd_showport_rss_hash_parsed,
2985 	.data = NULL,
2986 	.help_str = "show port <port_id> rss-hash",
2987 	.tokens = {
2988 		(void *)&cmd_showport_rss_hash_show,
2989 		(void *)&cmd_showport_rss_hash_port,
2990 		(void *)&cmd_showport_rss_hash_port_id,
2991 		(void *)&cmd_showport_rss_hash_rss_hash,
2992 		NULL,
2993 	},
2994 };
2995 
2996 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
2997 	.f = cmd_showport_rss_hash_parsed,
2998 	.data = (void *)1,
2999 	.help_str = "show port <port_id> rss-hash key",
3000 	.tokens = {
3001 		(void *)&cmd_showport_rss_hash_show,
3002 		(void *)&cmd_showport_rss_hash_port,
3003 		(void *)&cmd_showport_rss_hash_port_id,
3004 		(void *)&cmd_showport_rss_hash_rss_hash,
3005 		(void *)&cmd_showport_rss_hash_rss_key,
3006 		NULL,
3007 	},
3008 };
3009 
3010 /* *** Configure DCB *** */
3011 struct cmd_config_dcb {
3012 	cmdline_fixed_string_t port;
3013 	cmdline_fixed_string_t config;
3014 	portid_t port_id;
3015 	cmdline_fixed_string_t dcb;
3016 	cmdline_fixed_string_t vt;
3017 	cmdline_fixed_string_t vt_en;
3018 	uint8_t num_tcs;
3019 	cmdline_fixed_string_t pfc;
3020 	cmdline_fixed_string_t pfc_en;
3021 };
3022 
3023 static void
3024 cmd_config_dcb_parsed(void *parsed_result,
3025                         __attribute__((unused)) struct cmdline *cl,
3026                         __attribute__((unused)) void *data)
3027 {
3028 	struct cmd_config_dcb *res = parsed_result;
3029 	portid_t port_id = res->port_id;
3030 	struct rte_port *port;
3031 	uint8_t pfc_en;
3032 	int ret;
3033 
3034 	port = &ports[port_id];
3035 	/** Check if the port is not started **/
3036 	if (port->port_status != RTE_PORT_STOPPED) {
3037 		printf("Please stop port %d first\n", port_id);
3038 		return;
3039 	}
3040 
3041 	if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
3042 		printf("The invalid number of traffic class,"
3043 			" only 4 or 8 allowed.\n");
3044 		return;
3045 	}
3046 
3047 	if (nb_fwd_lcores < res->num_tcs) {
3048 		printf("nb_cores shouldn't be less than number of TCs.\n");
3049 		return;
3050 	}
3051 	if (!strncmp(res->pfc_en, "on", 2))
3052 		pfc_en = 1;
3053 	else
3054 		pfc_en = 0;
3055 
3056 	/* DCB in VT mode */
3057 	if (!strncmp(res->vt_en, "on", 2))
3058 		ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3059 				(enum rte_eth_nb_tcs)res->num_tcs,
3060 				pfc_en);
3061 	else
3062 		ret = init_port_dcb_config(port_id, DCB_ENABLED,
3063 				(enum rte_eth_nb_tcs)res->num_tcs,
3064 				pfc_en);
3065 
3066 
3067 	if (ret != 0) {
3068 		printf("Cannot initialize network ports.\n");
3069 		return;
3070 	}
3071 
3072 	cmd_reconfig_device_queue(port_id, 1, 1);
3073 }
3074 
3075 cmdline_parse_token_string_t cmd_config_dcb_port =
3076         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3077 cmdline_parse_token_string_t cmd_config_dcb_config =
3078         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3079 cmdline_parse_token_num_t cmd_config_dcb_port_id =
3080 	TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16);
3081 cmdline_parse_token_string_t cmd_config_dcb_dcb =
3082         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3083 cmdline_parse_token_string_t cmd_config_dcb_vt =
3084         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3085 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3086         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3087 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3088         TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
3089 cmdline_parse_token_string_t cmd_config_dcb_pfc=
3090         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3091 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
3092         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
3093 
3094 cmdline_parse_inst_t cmd_config_dcb = {
3095 	.f = cmd_config_dcb_parsed,
3096 	.data = NULL,
3097 	.help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
3098 	.tokens = {
3099 		(void *)&cmd_config_dcb_port,
3100 		(void *)&cmd_config_dcb_config,
3101 		(void *)&cmd_config_dcb_port_id,
3102 		(void *)&cmd_config_dcb_dcb,
3103 		(void *)&cmd_config_dcb_vt,
3104 		(void *)&cmd_config_dcb_vt_en,
3105 		(void *)&cmd_config_dcb_num_tcs,
3106 		(void *)&cmd_config_dcb_pfc,
3107 		(void *)&cmd_config_dcb_pfc_en,
3108                 NULL,
3109         },
3110 };
3111 
3112 /* *** configure number of packets per burst *** */
3113 struct cmd_config_burst {
3114 	cmdline_fixed_string_t port;
3115 	cmdline_fixed_string_t keyword;
3116 	cmdline_fixed_string_t all;
3117 	cmdline_fixed_string_t name;
3118 	uint16_t value;
3119 };
3120 
3121 static void
3122 cmd_config_burst_parsed(void *parsed_result,
3123 			__attribute__((unused)) struct cmdline *cl,
3124 			__attribute__((unused)) void *data)
3125 {
3126 	struct cmd_config_burst *res = parsed_result;
3127 	struct rte_eth_dev_info dev_info;
3128 	uint16_t rec_nb_pkts;
3129 
3130 	if (!all_ports_stopped()) {
3131 		printf("Please stop all ports first\n");
3132 		return;
3133 	}
3134 
3135 	if (!strcmp(res->name, "burst")) {
3136 		if (res->value == 0) {
3137 			/* If user gives a value of zero, query the PMD for
3138 			 * its recommended Rx burst size. Testpmd uses a single
3139 			 * size for all ports, so assume all ports are the same
3140 			 * NIC model and use the values from Port 0.
3141 			 */
3142 			rte_eth_dev_info_get(0, &dev_info);
3143 			rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3144 
3145 			if (rec_nb_pkts == 0) {
3146 				printf("PMD does not recommend a burst size.\n"
3147 					"User provided value must be between"
3148 					" 1 and %d\n", MAX_PKT_BURST);
3149 				return;
3150 			} else if (rec_nb_pkts > MAX_PKT_BURST) {
3151 				printf("PMD recommended burst size of %d"
3152 					" exceeds maximum value of %d\n",
3153 					rec_nb_pkts, MAX_PKT_BURST);
3154 				return;
3155 			}
3156 			printf("Using PMD-provided burst value of %d\n",
3157 				rec_nb_pkts);
3158 			nb_pkt_per_burst = rec_nb_pkts;
3159 		} else if (res->value > MAX_PKT_BURST) {
3160 			printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
3161 			return;
3162 		} else
3163 			nb_pkt_per_burst = res->value;
3164 	} else {
3165 		printf("Unknown parameter\n");
3166 		return;
3167 	}
3168 
3169 	init_port_config();
3170 
3171 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3172 }
3173 
3174 cmdline_parse_token_string_t cmd_config_burst_port =
3175 	TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3176 cmdline_parse_token_string_t cmd_config_burst_keyword =
3177 	TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3178 cmdline_parse_token_string_t cmd_config_burst_all =
3179 	TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3180 cmdline_parse_token_string_t cmd_config_burst_name =
3181 	TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3182 cmdline_parse_token_num_t cmd_config_burst_value =
3183 	TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
3184 
3185 cmdline_parse_inst_t cmd_config_burst = {
3186 	.f = cmd_config_burst_parsed,
3187 	.data = NULL,
3188 	.help_str = "port config all burst <value>",
3189 	.tokens = {
3190 		(void *)&cmd_config_burst_port,
3191 		(void *)&cmd_config_burst_keyword,
3192 		(void *)&cmd_config_burst_all,
3193 		(void *)&cmd_config_burst_name,
3194 		(void *)&cmd_config_burst_value,
3195 		NULL,
3196 	},
3197 };
3198 
3199 /* *** configure rx/tx queues *** */
3200 struct cmd_config_thresh {
3201 	cmdline_fixed_string_t port;
3202 	cmdline_fixed_string_t keyword;
3203 	cmdline_fixed_string_t all;
3204 	cmdline_fixed_string_t name;
3205 	uint8_t value;
3206 };
3207 
3208 static void
3209 cmd_config_thresh_parsed(void *parsed_result,
3210 			__attribute__((unused)) struct cmdline *cl,
3211 			__attribute__((unused)) void *data)
3212 {
3213 	struct cmd_config_thresh *res = parsed_result;
3214 
3215 	if (!all_ports_stopped()) {
3216 		printf("Please stop all ports first\n");
3217 		return;
3218 	}
3219 
3220 	if (!strcmp(res->name, "txpt"))
3221 		tx_pthresh = res->value;
3222 	else if(!strcmp(res->name, "txht"))
3223 		tx_hthresh = res->value;
3224 	else if(!strcmp(res->name, "txwt"))
3225 		tx_wthresh = res->value;
3226 	else if(!strcmp(res->name, "rxpt"))
3227 		rx_pthresh = res->value;
3228 	else if(!strcmp(res->name, "rxht"))
3229 		rx_hthresh = res->value;
3230 	else if(!strcmp(res->name, "rxwt"))
3231 		rx_wthresh = res->value;
3232 	else {
3233 		printf("Unknown parameter\n");
3234 		return;
3235 	}
3236 
3237 	init_port_config();
3238 
3239 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3240 }
3241 
3242 cmdline_parse_token_string_t cmd_config_thresh_port =
3243 	TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3244 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3245 	TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3246 cmdline_parse_token_string_t cmd_config_thresh_all =
3247 	TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3248 cmdline_parse_token_string_t cmd_config_thresh_name =
3249 	TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3250 				"txpt#txht#txwt#rxpt#rxht#rxwt");
3251 cmdline_parse_token_num_t cmd_config_thresh_value =
3252 	TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
3253 
3254 cmdline_parse_inst_t cmd_config_thresh = {
3255 	.f = cmd_config_thresh_parsed,
3256 	.data = NULL,
3257 	.help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3258 	.tokens = {
3259 		(void *)&cmd_config_thresh_port,
3260 		(void *)&cmd_config_thresh_keyword,
3261 		(void *)&cmd_config_thresh_all,
3262 		(void *)&cmd_config_thresh_name,
3263 		(void *)&cmd_config_thresh_value,
3264 		NULL,
3265 	},
3266 };
3267 
3268 /* *** configure free/rs threshold *** */
3269 struct cmd_config_threshold {
3270 	cmdline_fixed_string_t port;
3271 	cmdline_fixed_string_t keyword;
3272 	cmdline_fixed_string_t all;
3273 	cmdline_fixed_string_t name;
3274 	uint16_t value;
3275 };
3276 
3277 static void
3278 cmd_config_threshold_parsed(void *parsed_result,
3279 			__attribute__((unused)) struct cmdline *cl,
3280 			__attribute__((unused)) void *data)
3281 {
3282 	struct cmd_config_threshold *res = parsed_result;
3283 
3284 	if (!all_ports_stopped()) {
3285 		printf("Please stop all ports first\n");
3286 		return;
3287 	}
3288 
3289 	if (!strcmp(res->name, "txfreet"))
3290 		tx_free_thresh = res->value;
3291 	else if (!strcmp(res->name, "txrst"))
3292 		tx_rs_thresh = res->value;
3293 	else if (!strcmp(res->name, "rxfreet"))
3294 		rx_free_thresh = res->value;
3295 	else {
3296 		printf("Unknown parameter\n");
3297 		return;
3298 	}
3299 
3300 	init_port_config();
3301 
3302 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3303 }
3304 
3305 cmdline_parse_token_string_t cmd_config_threshold_port =
3306 	TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3307 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3308 	TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3309 								"config");
3310 cmdline_parse_token_string_t cmd_config_threshold_all =
3311 	TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3312 cmdline_parse_token_string_t cmd_config_threshold_name =
3313 	TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3314 						"txfreet#txrst#rxfreet");
3315 cmdline_parse_token_num_t cmd_config_threshold_value =
3316 	TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
3317 
3318 cmdline_parse_inst_t cmd_config_threshold = {
3319 	.f = cmd_config_threshold_parsed,
3320 	.data = NULL,
3321 	.help_str = "port config all txfreet|txrst|rxfreet <value>",
3322 	.tokens = {
3323 		(void *)&cmd_config_threshold_port,
3324 		(void *)&cmd_config_threshold_keyword,
3325 		(void *)&cmd_config_threshold_all,
3326 		(void *)&cmd_config_threshold_name,
3327 		(void *)&cmd_config_threshold_value,
3328 		NULL,
3329 	},
3330 };
3331 
3332 /* *** stop *** */
3333 struct cmd_stop_result {
3334 	cmdline_fixed_string_t stop;
3335 };
3336 
3337 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
3338 			    __attribute__((unused)) struct cmdline *cl,
3339 			    __attribute__((unused)) void *data)
3340 {
3341 	stop_packet_forwarding();
3342 }
3343 
3344 cmdline_parse_token_string_t cmd_stop_stop =
3345 	TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3346 
3347 cmdline_parse_inst_t cmd_stop = {
3348 	.f = cmd_stop_parsed,
3349 	.data = NULL,
3350 	.help_str = "stop: Stop packet forwarding",
3351 	.tokens = {
3352 		(void *)&cmd_stop_stop,
3353 		NULL,
3354 	},
3355 };
3356 
3357 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3358 
3359 unsigned int
3360 parse_item_list(char* str, const char* item_name, unsigned int max_items,
3361 		unsigned int *parsed_items, int check_unique_values)
3362 {
3363 	unsigned int nb_item;
3364 	unsigned int value;
3365 	unsigned int i;
3366 	unsigned int j;
3367 	int value_ok;
3368 	char c;
3369 
3370 	/*
3371 	 * First parse all items in the list and store their value.
3372 	 */
3373 	value = 0;
3374 	nb_item = 0;
3375 	value_ok = 0;
3376 	for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3377 		c = str[i];
3378 		if ((c >= '0') && (c <= '9')) {
3379 			value = (unsigned int) (value * 10 + (c - '0'));
3380 			value_ok = 1;
3381 			continue;
3382 		}
3383 		if (c != ',') {
3384 			printf("character %c is not a decimal digit\n", c);
3385 			return 0;
3386 		}
3387 		if (! value_ok) {
3388 			printf("No valid value before comma\n");
3389 			return 0;
3390 		}
3391 		if (nb_item < max_items) {
3392 			parsed_items[nb_item] = value;
3393 			value_ok = 0;
3394 			value = 0;
3395 		}
3396 		nb_item++;
3397 	}
3398 	if (nb_item >= max_items) {
3399 		printf("Number of %s = %u > %u (maximum items)\n",
3400 		       item_name, nb_item + 1, max_items);
3401 		return 0;
3402 	}
3403 	parsed_items[nb_item++] = value;
3404 	if (! check_unique_values)
3405 		return nb_item;
3406 
3407 	/*
3408 	 * Then, check that all values in the list are differents.
3409 	 * No optimization here...
3410 	 */
3411 	for (i = 0; i < nb_item; i++) {
3412 		for (j = i + 1; j < nb_item; j++) {
3413 			if (parsed_items[j] == parsed_items[i]) {
3414 				printf("duplicated %s %u at index %u and %u\n",
3415 				       item_name, parsed_items[i], i, j);
3416 				return 0;
3417 			}
3418 		}
3419 	}
3420 	return nb_item;
3421 }
3422 
3423 struct cmd_set_list_result {
3424 	cmdline_fixed_string_t cmd_keyword;
3425 	cmdline_fixed_string_t list_name;
3426 	cmdline_fixed_string_t list_of_items;
3427 };
3428 
3429 static void cmd_set_list_parsed(void *parsed_result,
3430 				__attribute__((unused)) struct cmdline *cl,
3431 				__attribute__((unused)) void *data)
3432 {
3433 	struct cmd_set_list_result *res;
3434 	union {
3435 		unsigned int lcorelist[RTE_MAX_LCORE];
3436 		unsigned int portlist[RTE_MAX_ETHPORTS];
3437 	} parsed_items;
3438 	unsigned int nb_item;
3439 
3440 	if (test_done == 0) {
3441 		printf("Please stop forwarding first\n");
3442 		return;
3443 	}
3444 
3445 	res = parsed_result;
3446 	if (!strcmp(res->list_name, "corelist")) {
3447 		nb_item = parse_item_list(res->list_of_items, "core",
3448 					  RTE_MAX_LCORE,
3449 					  parsed_items.lcorelist, 1);
3450 		if (nb_item > 0) {
3451 			set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3452 			fwd_config_setup();
3453 		}
3454 		return;
3455 	}
3456 	if (!strcmp(res->list_name, "portlist")) {
3457 		nb_item = parse_item_list(res->list_of_items, "port",
3458 					  RTE_MAX_ETHPORTS,
3459 					  parsed_items.portlist, 1);
3460 		if (nb_item > 0) {
3461 			set_fwd_ports_list(parsed_items.portlist, nb_item);
3462 			fwd_config_setup();
3463 		}
3464 	}
3465 }
3466 
3467 cmdline_parse_token_string_t cmd_set_list_keyword =
3468 	TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3469 				 "set");
3470 cmdline_parse_token_string_t cmd_set_list_name =
3471 	TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3472 				 "corelist#portlist");
3473 cmdline_parse_token_string_t cmd_set_list_of_items =
3474 	TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3475 				 NULL);
3476 
3477 cmdline_parse_inst_t cmd_set_fwd_list = {
3478 	.f = cmd_set_list_parsed,
3479 	.data = NULL,
3480 	.help_str = "set corelist|portlist <list0[,list1]*>",
3481 	.tokens = {
3482 		(void *)&cmd_set_list_keyword,
3483 		(void *)&cmd_set_list_name,
3484 		(void *)&cmd_set_list_of_items,
3485 		NULL,
3486 	},
3487 };
3488 
3489 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3490 
3491 struct cmd_setmask_result {
3492 	cmdline_fixed_string_t set;
3493 	cmdline_fixed_string_t mask;
3494 	uint64_t hexavalue;
3495 };
3496 
3497 static void cmd_set_mask_parsed(void *parsed_result,
3498 				__attribute__((unused)) struct cmdline *cl,
3499 				__attribute__((unused)) void *data)
3500 {
3501 	struct cmd_setmask_result *res = parsed_result;
3502 
3503 	if (test_done == 0) {
3504 		printf("Please stop forwarding first\n");
3505 		return;
3506 	}
3507 	if (!strcmp(res->mask, "coremask")) {
3508 		set_fwd_lcores_mask(res->hexavalue);
3509 		fwd_config_setup();
3510 	} else if (!strcmp(res->mask, "portmask")) {
3511 		set_fwd_ports_mask(res->hexavalue);
3512 		fwd_config_setup();
3513 	}
3514 }
3515 
3516 cmdline_parse_token_string_t cmd_setmask_set =
3517 	TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3518 cmdline_parse_token_string_t cmd_setmask_mask =
3519 	TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3520 				 "coremask#portmask");
3521 cmdline_parse_token_num_t cmd_setmask_value =
3522 	TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
3523 
3524 cmdline_parse_inst_t cmd_set_fwd_mask = {
3525 	.f = cmd_set_mask_parsed,
3526 	.data = NULL,
3527 	.help_str = "set coremask|portmask <hexadecimal value>",
3528 	.tokens = {
3529 		(void *)&cmd_setmask_set,
3530 		(void *)&cmd_setmask_mask,
3531 		(void *)&cmd_setmask_value,
3532 		NULL,
3533 	},
3534 };
3535 
3536 /*
3537  * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3538  */
3539 struct cmd_set_result {
3540 	cmdline_fixed_string_t set;
3541 	cmdline_fixed_string_t what;
3542 	uint16_t value;
3543 };
3544 
3545 static void cmd_set_parsed(void *parsed_result,
3546 			   __attribute__((unused)) struct cmdline *cl,
3547 			   __attribute__((unused)) void *data)
3548 {
3549 	struct cmd_set_result *res = parsed_result;
3550 	if (!strcmp(res->what, "nbport")) {
3551 		set_fwd_ports_number(res->value);
3552 		fwd_config_setup();
3553 	} else if (!strcmp(res->what, "nbcore")) {
3554 		set_fwd_lcores_number(res->value);
3555 		fwd_config_setup();
3556 	} else if (!strcmp(res->what, "burst"))
3557 		set_nb_pkt_per_burst(res->value);
3558 	else if (!strcmp(res->what, "verbose"))
3559 		set_verbose_level(res->value);
3560 }
3561 
3562 cmdline_parse_token_string_t cmd_set_set =
3563 	TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3564 cmdline_parse_token_string_t cmd_set_what =
3565 	TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3566 				 "nbport#nbcore#burst#verbose");
3567 cmdline_parse_token_num_t cmd_set_value =
3568 	TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
3569 
3570 cmdline_parse_inst_t cmd_set_numbers = {
3571 	.f = cmd_set_parsed,
3572 	.data = NULL,
3573 	.help_str = "set nbport|nbcore|burst|verbose <value>",
3574 	.tokens = {
3575 		(void *)&cmd_set_set,
3576 		(void *)&cmd_set_what,
3577 		(void *)&cmd_set_value,
3578 		NULL,
3579 	},
3580 };
3581 
3582 /* *** SET LOG LEVEL CONFIGURATION *** */
3583 
3584 struct cmd_set_log_result {
3585 	cmdline_fixed_string_t set;
3586 	cmdline_fixed_string_t log;
3587 	cmdline_fixed_string_t type;
3588 	uint32_t level;
3589 };
3590 
3591 static void
3592 cmd_set_log_parsed(void *parsed_result,
3593 		   __attribute__((unused)) struct cmdline *cl,
3594 		   __attribute__((unused)) void *data)
3595 {
3596 	struct cmd_set_log_result *res;
3597 	int ret;
3598 
3599 	res = parsed_result;
3600 	if (!strcmp(res->type, "global"))
3601 		rte_log_set_global_level(res->level);
3602 	else {
3603 		ret = rte_log_set_level_regexp(res->type, res->level);
3604 		if (ret < 0)
3605 			printf("Unable to set log level\n");
3606 	}
3607 }
3608 
3609 cmdline_parse_token_string_t cmd_set_log_set =
3610 	TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3611 cmdline_parse_token_string_t cmd_set_log_log =
3612 	TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3613 cmdline_parse_token_string_t cmd_set_log_type =
3614 	TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3615 cmdline_parse_token_num_t cmd_set_log_level =
3616 	TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, UINT32);
3617 
3618 cmdline_parse_inst_t cmd_set_log = {
3619 	.f = cmd_set_log_parsed,
3620 	.data = NULL,
3621 	.help_str = "set log global|<type> <level>",
3622 	.tokens = {
3623 		(void *)&cmd_set_log_set,
3624 		(void *)&cmd_set_log_log,
3625 		(void *)&cmd_set_log_type,
3626 		(void *)&cmd_set_log_level,
3627 		NULL,
3628 	},
3629 };
3630 
3631 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3632 
3633 struct cmd_set_txpkts_result {
3634 	cmdline_fixed_string_t cmd_keyword;
3635 	cmdline_fixed_string_t txpkts;
3636 	cmdline_fixed_string_t seg_lengths;
3637 };
3638 
3639 static void
3640 cmd_set_txpkts_parsed(void *parsed_result,
3641 		      __attribute__((unused)) struct cmdline *cl,
3642 		      __attribute__((unused)) void *data)
3643 {
3644 	struct cmd_set_txpkts_result *res;
3645 	unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3646 	unsigned int nb_segs;
3647 
3648 	res = parsed_result;
3649 	nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3650 				  RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3651 	if (nb_segs > 0)
3652 		set_tx_pkt_segments(seg_lengths, nb_segs);
3653 }
3654 
3655 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3656 	TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3657 				 cmd_keyword, "set");
3658 cmdline_parse_token_string_t cmd_set_txpkts_name =
3659 	TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3660 				 txpkts, "txpkts");
3661 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3662 	TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3663 				 seg_lengths, NULL);
3664 
3665 cmdline_parse_inst_t cmd_set_txpkts = {
3666 	.f = cmd_set_txpkts_parsed,
3667 	.data = NULL,
3668 	.help_str = "set txpkts <len0[,len1]*>",
3669 	.tokens = {
3670 		(void *)&cmd_set_txpkts_keyword,
3671 		(void *)&cmd_set_txpkts_name,
3672 		(void *)&cmd_set_txpkts_lengths,
3673 		NULL,
3674 	},
3675 };
3676 
3677 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
3678 
3679 struct cmd_set_txsplit_result {
3680 	cmdline_fixed_string_t cmd_keyword;
3681 	cmdline_fixed_string_t txsplit;
3682 	cmdline_fixed_string_t mode;
3683 };
3684 
3685 static void
3686 cmd_set_txsplit_parsed(void *parsed_result,
3687 		      __attribute__((unused)) struct cmdline *cl,
3688 		      __attribute__((unused)) void *data)
3689 {
3690 	struct cmd_set_txsplit_result *res;
3691 
3692 	res = parsed_result;
3693 	set_tx_pkt_split(res->mode);
3694 }
3695 
3696 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
3697 	TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3698 				 cmd_keyword, "set");
3699 cmdline_parse_token_string_t cmd_set_txsplit_name =
3700 	TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3701 				 txsplit, "txsplit");
3702 cmdline_parse_token_string_t cmd_set_txsplit_mode =
3703 	TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3704 				 mode, NULL);
3705 
3706 cmdline_parse_inst_t cmd_set_txsplit = {
3707 	.f = cmd_set_txsplit_parsed,
3708 	.data = NULL,
3709 	.help_str = "set txsplit on|off|rand",
3710 	.tokens = {
3711 		(void *)&cmd_set_txsplit_keyword,
3712 		(void *)&cmd_set_txsplit_name,
3713 		(void *)&cmd_set_txsplit_mode,
3714 		NULL,
3715 	},
3716 };
3717 
3718 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
3719 struct cmd_rx_vlan_filter_all_result {
3720 	cmdline_fixed_string_t rx_vlan;
3721 	cmdline_fixed_string_t what;
3722 	cmdline_fixed_string_t all;
3723 	portid_t port_id;
3724 };
3725 
3726 static void
3727 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
3728 			      __attribute__((unused)) struct cmdline *cl,
3729 			      __attribute__((unused)) void *data)
3730 {
3731 	struct cmd_rx_vlan_filter_all_result *res = parsed_result;
3732 
3733 	if (!strcmp(res->what, "add"))
3734 		rx_vlan_all_filter_set(res->port_id, 1);
3735 	else
3736 		rx_vlan_all_filter_set(res->port_id, 0);
3737 }
3738 
3739 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
3740 	TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3741 				 rx_vlan, "rx_vlan");
3742 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
3743 	TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3744 				 what, "add#rm");
3745 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
3746 	TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3747 				 all, "all");
3748 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
3749 	TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3750 			      port_id, UINT16);
3751 
3752 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
3753 	.f = cmd_rx_vlan_filter_all_parsed,
3754 	.data = NULL,
3755 	.help_str = "rx_vlan add|rm all <port_id>: "
3756 		"Add/Remove all identifiers to/from the set of VLAN "
3757 		"identifiers filtered by a port",
3758 	.tokens = {
3759 		(void *)&cmd_rx_vlan_filter_all_rx_vlan,
3760 		(void *)&cmd_rx_vlan_filter_all_what,
3761 		(void *)&cmd_rx_vlan_filter_all_all,
3762 		(void *)&cmd_rx_vlan_filter_all_portid,
3763 		NULL,
3764 	},
3765 };
3766 
3767 /* *** VLAN OFFLOAD SET ON A PORT *** */
3768 struct cmd_vlan_offload_result {
3769 	cmdline_fixed_string_t vlan;
3770 	cmdline_fixed_string_t set;
3771 	cmdline_fixed_string_t vlan_type;
3772 	cmdline_fixed_string_t what;
3773 	cmdline_fixed_string_t on;
3774 	cmdline_fixed_string_t port_id;
3775 };
3776 
3777 static void
3778 cmd_vlan_offload_parsed(void *parsed_result,
3779 			  __attribute__((unused)) struct cmdline *cl,
3780 			  __attribute__((unused)) void *data)
3781 {
3782 	int on;
3783 	struct cmd_vlan_offload_result *res = parsed_result;
3784 	char *str;
3785 	int i, len = 0;
3786 	portid_t port_id = 0;
3787 	unsigned int tmp;
3788 
3789 	str = res->port_id;
3790 	len = strnlen(str, STR_TOKEN_SIZE);
3791 	i = 0;
3792 	/* Get port_id first */
3793 	while(i < len){
3794 		if(str[i] == ',')
3795 			break;
3796 
3797 		i++;
3798 	}
3799 	str[i]='\0';
3800 	tmp = strtoul(str, NULL, 0);
3801 	/* If port_id greater that what portid_t can represent, return */
3802 	if(tmp >= RTE_MAX_ETHPORTS)
3803 		return;
3804 	port_id = (portid_t)tmp;
3805 
3806 	if (!strcmp(res->on, "on"))
3807 		on = 1;
3808 	else
3809 		on = 0;
3810 
3811 	if (!strcmp(res->what, "strip"))
3812 		rx_vlan_strip_set(port_id,  on);
3813 	else if(!strcmp(res->what, "stripq")){
3814 		uint16_t queue_id = 0;
3815 
3816 		/* No queue_id, return */
3817 		if(i + 1 >= len) {
3818 			printf("must specify (port,queue_id)\n");
3819 			return;
3820 		}
3821 		tmp = strtoul(str + i + 1, NULL, 0);
3822 		/* If queue_id greater that what 16-bits can represent, return */
3823 		if(tmp > 0xffff)
3824 			return;
3825 
3826 		queue_id = (uint16_t)tmp;
3827 		rx_vlan_strip_set_on_queue(port_id, queue_id, on);
3828 	}
3829 	else if (!strcmp(res->what, "filter"))
3830 		rx_vlan_filter_set(port_id, on);
3831 	else
3832 		vlan_extend_set(port_id, on);
3833 
3834 	return;
3835 }
3836 
3837 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
3838 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3839 				 vlan, "vlan");
3840 cmdline_parse_token_string_t cmd_vlan_offload_set =
3841 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3842 				 set, "set");
3843 cmdline_parse_token_string_t cmd_vlan_offload_what =
3844 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3845 				 what, "strip#filter#qinq#stripq");
3846 cmdline_parse_token_string_t cmd_vlan_offload_on =
3847 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3848 			      on, "on#off");
3849 cmdline_parse_token_string_t cmd_vlan_offload_portid =
3850 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3851 			      port_id, NULL);
3852 
3853 cmdline_parse_inst_t cmd_vlan_offload = {
3854 	.f = cmd_vlan_offload_parsed,
3855 	.data = NULL,
3856 	.help_str = "vlan set strip|filter|qinq|stripq on|off "
3857 		"<port_id[,queue_id]>: "
3858 		"Filter/Strip for rx side qinq(extended) for both rx/tx sides",
3859 	.tokens = {
3860 		(void *)&cmd_vlan_offload_vlan,
3861 		(void *)&cmd_vlan_offload_set,
3862 		(void *)&cmd_vlan_offload_what,
3863 		(void *)&cmd_vlan_offload_on,
3864 		(void *)&cmd_vlan_offload_portid,
3865 		NULL,
3866 	},
3867 };
3868 
3869 /* *** VLAN TPID SET ON A PORT *** */
3870 struct cmd_vlan_tpid_result {
3871 	cmdline_fixed_string_t vlan;
3872 	cmdline_fixed_string_t set;
3873 	cmdline_fixed_string_t vlan_type;
3874 	cmdline_fixed_string_t what;
3875 	uint16_t tp_id;
3876 	portid_t port_id;
3877 };
3878 
3879 static void
3880 cmd_vlan_tpid_parsed(void *parsed_result,
3881 			  __attribute__((unused)) struct cmdline *cl,
3882 			  __attribute__((unused)) void *data)
3883 {
3884 	struct cmd_vlan_tpid_result *res = parsed_result;
3885 	enum rte_vlan_type vlan_type;
3886 
3887 	if (!strcmp(res->vlan_type, "inner"))
3888 		vlan_type = ETH_VLAN_TYPE_INNER;
3889 	else if (!strcmp(res->vlan_type, "outer"))
3890 		vlan_type = ETH_VLAN_TYPE_OUTER;
3891 	else {
3892 		printf("Unknown vlan type\n");
3893 		return;
3894 	}
3895 	vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
3896 }
3897 
3898 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
3899 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3900 				 vlan, "vlan");
3901 cmdline_parse_token_string_t cmd_vlan_tpid_set =
3902 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3903 				 set, "set");
3904 cmdline_parse_token_string_t cmd_vlan_type =
3905 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3906 				 vlan_type, "inner#outer");
3907 cmdline_parse_token_string_t cmd_vlan_tpid_what =
3908 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3909 				 what, "tpid");
3910 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
3911 	TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3912 			      tp_id, UINT16);
3913 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
3914 	TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3915 			      port_id, UINT16);
3916 
3917 cmdline_parse_inst_t cmd_vlan_tpid = {
3918 	.f = cmd_vlan_tpid_parsed,
3919 	.data = NULL,
3920 	.help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
3921 		"Set the VLAN Ether type",
3922 	.tokens = {
3923 		(void *)&cmd_vlan_tpid_vlan,
3924 		(void *)&cmd_vlan_tpid_set,
3925 		(void *)&cmd_vlan_type,
3926 		(void *)&cmd_vlan_tpid_what,
3927 		(void *)&cmd_vlan_tpid_tpid,
3928 		(void *)&cmd_vlan_tpid_portid,
3929 		NULL,
3930 	},
3931 };
3932 
3933 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
3934 struct cmd_rx_vlan_filter_result {
3935 	cmdline_fixed_string_t rx_vlan;
3936 	cmdline_fixed_string_t what;
3937 	uint16_t vlan_id;
3938 	portid_t port_id;
3939 };
3940 
3941 static void
3942 cmd_rx_vlan_filter_parsed(void *parsed_result,
3943 			  __attribute__((unused)) struct cmdline *cl,
3944 			  __attribute__((unused)) void *data)
3945 {
3946 	struct cmd_rx_vlan_filter_result *res = parsed_result;
3947 
3948 	if (!strcmp(res->what, "add"))
3949 		rx_vft_set(res->port_id, res->vlan_id, 1);
3950 	else
3951 		rx_vft_set(res->port_id, res->vlan_id, 0);
3952 }
3953 
3954 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
3955 	TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3956 				 rx_vlan, "rx_vlan");
3957 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
3958 	TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3959 				 what, "add#rm");
3960 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
3961 	TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3962 			      vlan_id, UINT16);
3963 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
3964 	TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3965 			      port_id, UINT16);
3966 
3967 cmdline_parse_inst_t cmd_rx_vlan_filter = {
3968 	.f = cmd_rx_vlan_filter_parsed,
3969 	.data = NULL,
3970 	.help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
3971 		"Add/Remove a VLAN identifier to/from the set of VLAN "
3972 		"identifiers filtered by a port",
3973 	.tokens = {
3974 		(void *)&cmd_rx_vlan_filter_rx_vlan,
3975 		(void *)&cmd_rx_vlan_filter_what,
3976 		(void *)&cmd_rx_vlan_filter_vlanid,
3977 		(void *)&cmd_rx_vlan_filter_portid,
3978 		NULL,
3979 	},
3980 };
3981 
3982 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3983 struct cmd_tx_vlan_set_result {
3984 	cmdline_fixed_string_t tx_vlan;
3985 	cmdline_fixed_string_t set;
3986 	portid_t port_id;
3987 	uint16_t vlan_id;
3988 };
3989 
3990 static void
3991 cmd_tx_vlan_set_parsed(void *parsed_result,
3992 		       __attribute__((unused)) struct cmdline *cl,
3993 		       __attribute__((unused)) void *data)
3994 {
3995 	struct cmd_tx_vlan_set_result *res = parsed_result;
3996 
3997 	if (!port_is_stopped(res->port_id)) {
3998 		printf("Please stop port %d first\n", res->port_id);
3999 		return;
4000 	}
4001 
4002 	tx_vlan_set(res->port_id, res->vlan_id);
4003 
4004 	cmd_reconfig_device_queue(res->port_id, 1, 1);
4005 }
4006 
4007 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4008 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4009 				 tx_vlan, "tx_vlan");
4010 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4011 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4012 				 set, "set");
4013 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4014 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4015 			      port_id, UINT16);
4016 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
4017 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4018 			      vlan_id, UINT16);
4019 
4020 cmdline_parse_inst_t cmd_tx_vlan_set = {
4021 	.f = cmd_tx_vlan_set_parsed,
4022 	.data = NULL,
4023 	.help_str = "tx_vlan set <port_id> <vlan_id>: "
4024 		"Enable hardware insertion of a single VLAN header "
4025 		"with a given TAG Identifier in packets sent on a port",
4026 	.tokens = {
4027 		(void *)&cmd_tx_vlan_set_tx_vlan,
4028 		(void *)&cmd_tx_vlan_set_set,
4029 		(void *)&cmd_tx_vlan_set_portid,
4030 		(void *)&cmd_tx_vlan_set_vlanid,
4031 		NULL,
4032 	},
4033 };
4034 
4035 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4036 struct cmd_tx_vlan_set_qinq_result {
4037 	cmdline_fixed_string_t tx_vlan;
4038 	cmdline_fixed_string_t set;
4039 	portid_t port_id;
4040 	uint16_t vlan_id;
4041 	uint16_t vlan_id_outer;
4042 };
4043 
4044 static void
4045 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4046 			    __attribute__((unused)) struct cmdline *cl,
4047 			    __attribute__((unused)) void *data)
4048 {
4049 	struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
4050 
4051 	if (!port_is_stopped(res->port_id)) {
4052 		printf("Please stop port %d first\n", res->port_id);
4053 		return;
4054 	}
4055 
4056 	tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
4057 
4058 	cmd_reconfig_device_queue(res->port_id, 1, 1);
4059 }
4060 
4061 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
4062 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4063 		tx_vlan, "tx_vlan");
4064 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
4065 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4066 		set, "set");
4067 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
4068 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4069 		port_id, UINT16);
4070 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
4071 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4072 		vlan_id, UINT16);
4073 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
4074 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4075 		vlan_id_outer, UINT16);
4076 
4077 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
4078 	.f = cmd_tx_vlan_set_qinq_parsed,
4079 	.data = NULL,
4080 	.help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
4081 		"Enable hardware insertion of double VLAN header "
4082 		"with given TAG Identifiers in packets sent on a port",
4083 	.tokens = {
4084 		(void *)&cmd_tx_vlan_set_qinq_tx_vlan,
4085 		(void *)&cmd_tx_vlan_set_qinq_set,
4086 		(void *)&cmd_tx_vlan_set_qinq_portid,
4087 		(void *)&cmd_tx_vlan_set_qinq_vlanid,
4088 		(void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
4089 		NULL,
4090 	},
4091 };
4092 
4093 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
4094 struct cmd_tx_vlan_set_pvid_result {
4095 	cmdline_fixed_string_t tx_vlan;
4096 	cmdline_fixed_string_t set;
4097 	cmdline_fixed_string_t pvid;
4098 	portid_t port_id;
4099 	uint16_t vlan_id;
4100 	cmdline_fixed_string_t mode;
4101 };
4102 
4103 static void
4104 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
4105 			    __attribute__((unused)) struct cmdline *cl,
4106 			    __attribute__((unused)) void *data)
4107 {
4108 	struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
4109 
4110 	if (strcmp(res->mode, "on") == 0)
4111 		tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
4112 	else
4113 		tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
4114 }
4115 
4116 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
4117 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4118 				 tx_vlan, "tx_vlan");
4119 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
4120 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4121 				 set, "set");
4122 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
4123 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4124 				 pvid, "pvid");
4125 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
4126 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4127 			     port_id, UINT16);
4128 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
4129 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4130 			      vlan_id, UINT16);
4131 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
4132 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4133 				 mode, "on#off");
4134 
4135 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
4136 	.f = cmd_tx_vlan_set_pvid_parsed,
4137 	.data = NULL,
4138 	.help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
4139 	.tokens = {
4140 		(void *)&cmd_tx_vlan_set_pvid_tx_vlan,
4141 		(void *)&cmd_tx_vlan_set_pvid_set,
4142 		(void *)&cmd_tx_vlan_set_pvid_pvid,
4143 		(void *)&cmd_tx_vlan_set_pvid_port_id,
4144 		(void *)&cmd_tx_vlan_set_pvid_vlan_id,
4145 		(void *)&cmd_tx_vlan_set_pvid_mode,
4146 		NULL,
4147 	},
4148 };
4149 
4150 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4151 struct cmd_tx_vlan_reset_result {
4152 	cmdline_fixed_string_t tx_vlan;
4153 	cmdline_fixed_string_t reset;
4154 	portid_t port_id;
4155 };
4156 
4157 static void
4158 cmd_tx_vlan_reset_parsed(void *parsed_result,
4159 			 __attribute__((unused)) struct cmdline *cl,
4160 			 __attribute__((unused)) void *data)
4161 {
4162 	struct cmd_tx_vlan_reset_result *res = parsed_result;
4163 
4164 	if (!port_is_stopped(res->port_id)) {
4165 		printf("Please stop port %d first\n", res->port_id);
4166 		return;
4167 	}
4168 
4169 	tx_vlan_reset(res->port_id);
4170 
4171 	cmd_reconfig_device_queue(res->port_id, 1, 1);
4172 }
4173 
4174 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4175 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4176 				 tx_vlan, "tx_vlan");
4177 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4178 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4179 				 reset, "reset");
4180 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4181 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4182 			      port_id, UINT16);
4183 
4184 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4185 	.f = cmd_tx_vlan_reset_parsed,
4186 	.data = NULL,
4187 	.help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4188 		"VLAN header in packets sent on a port",
4189 	.tokens = {
4190 		(void *)&cmd_tx_vlan_reset_tx_vlan,
4191 		(void *)&cmd_tx_vlan_reset_reset,
4192 		(void *)&cmd_tx_vlan_reset_portid,
4193 		NULL,
4194 	},
4195 };
4196 
4197 
4198 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4199 struct cmd_csum_result {
4200 	cmdline_fixed_string_t csum;
4201 	cmdline_fixed_string_t mode;
4202 	cmdline_fixed_string_t proto;
4203 	cmdline_fixed_string_t hwsw;
4204 	portid_t port_id;
4205 };
4206 
4207 static void
4208 csum_show(int port_id)
4209 {
4210 	struct rte_eth_dev_info dev_info;
4211 	uint64_t tx_offloads;
4212 
4213 	tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4214 	printf("Parse tunnel is %s\n",
4215 		(ports[port_id].parse_tunnel) ? "on" : "off");
4216 	printf("IP checksum offload is %s\n",
4217 		(tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4218 	printf("UDP checksum offload is %s\n",
4219 		(tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4220 	printf("TCP checksum offload is %s\n",
4221 		(tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4222 	printf("SCTP checksum offload is %s\n",
4223 		(tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4224 	printf("Outer-Ip checksum offload is %s\n",
4225 		(tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4226 	printf("Outer-Udp checksum offload is %s\n",
4227 		(tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
4228 
4229 	/* display warnings if configuration is not supported by the NIC */
4230 	rte_eth_dev_info_get(port_id, &dev_info);
4231 	if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
4232 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4233 		printf("Warning: hardware IP checksum enabled but not "
4234 			"supported by port %d\n", port_id);
4235 	}
4236 	if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
4237 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
4238 		printf("Warning: hardware UDP checksum enabled but not "
4239 			"supported by port %d\n", port_id);
4240 	}
4241 	if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
4242 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
4243 		printf("Warning: hardware TCP checksum enabled but not "
4244 			"supported by port %d\n", port_id);
4245 	}
4246 	if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
4247 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4248 		printf("Warning: hardware SCTP checksum enabled but not "
4249 			"supported by port %d\n", port_id);
4250 	}
4251 	if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4252 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4253 		printf("Warning: hardware outer IP checksum enabled but not "
4254 			"supported by port %d\n", port_id);
4255 	}
4256 	if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
4257 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)
4258 			== 0) {
4259 		printf("Warning: hardware outer UDP checksum enabled but not "
4260 			"supported by port %d\n", port_id);
4261 	}
4262 }
4263 
4264 static void
4265 cmd_csum_parsed(void *parsed_result,
4266 		       __attribute__((unused)) struct cmdline *cl,
4267 		       __attribute__((unused)) void *data)
4268 {
4269 	struct cmd_csum_result *res = parsed_result;
4270 	int hw = 0;
4271 	uint64_t csum_offloads = 0;
4272 	struct rte_eth_dev_info dev_info;
4273 
4274 	if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4275 		printf("invalid port %d\n", res->port_id);
4276 		return;
4277 	}
4278 	if (!port_is_stopped(res->port_id)) {
4279 		printf("Please stop port %d first\n", res->port_id);
4280 		return;
4281 	}
4282 
4283 	rte_eth_dev_info_get(res->port_id, &dev_info);
4284 	if (!strcmp(res->mode, "set")) {
4285 
4286 		if (!strcmp(res->hwsw, "hw"))
4287 			hw = 1;
4288 
4289 		if (!strcmp(res->proto, "ip")) {
4290 			if (hw == 0 || (dev_info.tx_offload_capa &
4291 						DEV_TX_OFFLOAD_IPV4_CKSUM)) {
4292 				csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
4293 			} else {
4294 				printf("IP checksum offload is not supported "
4295 				       "by port %u\n", res->port_id);
4296 			}
4297 		} else if (!strcmp(res->proto, "udp")) {
4298 			if (hw == 0 || (dev_info.tx_offload_capa &
4299 						DEV_TX_OFFLOAD_UDP_CKSUM)) {
4300 				csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
4301 			} else {
4302 				printf("UDP checksum offload is not supported "
4303 				       "by port %u\n", res->port_id);
4304 			}
4305 		} else if (!strcmp(res->proto, "tcp")) {
4306 			if (hw == 0 || (dev_info.tx_offload_capa &
4307 						DEV_TX_OFFLOAD_TCP_CKSUM)) {
4308 				csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
4309 			} else {
4310 				printf("TCP checksum offload is not supported "
4311 				       "by port %u\n", res->port_id);
4312 			}
4313 		} else if (!strcmp(res->proto, "sctp")) {
4314 			if (hw == 0 || (dev_info.tx_offload_capa &
4315 						DEV_TX_OFFLOAD_SCTP_CKSUM)) {
4316 				csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
4317 			} else {
4318 				printf("SCTP checksum offload is not supported "
4319 				       "by port %u\n", res->port_id);
4320 			}
4321 		} else if (!strcmp(res->proto, "outer-ip")) {
4322 			if (hw == 0 || (dev_info.tx_offload_capa &
4323 					DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4324 				csum_offloads |=
4325 						DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4326 			} else {
4327 				printf("Outer IP checksum offload is not "
4328 				       "supported by port %u\n", res->port_id);
4329 			}
4330 		} else if (!strcmp(res->proto, "outer-udp")) {
4331 			if (hw == 0 || (dev_info.tx_offload_capa &
4332 					DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
4333 				csum_offloads |=
4334 						DEV_TX_OFFLOAD_OUTER_UDP_CKSUM;
4335 			} else {
4336 				printf("Outer UDP checksum offload is not "
4337 				       "supported by port %u\n", res->port_id);
4338 			}
4339 		}
4340 
4341 		if (hw) {
4342 			ports[res->port_id].dev_conf.txmode.offloads |=
4343 							csum_offloads;
4344 		} else {
4345 			ports[res->port_id].dev_conf.txmode.offloads &=
4346 							(~csum_offloads);
4347 		}
4348 	}
4349 	csum_show(res->port_id);
4350 
4351 	cmd_reconfig_device_queue(res->port_id, 1, 1);
4352 }
4353 
4354 cmdline_parse_token_string_t cmd_csum_csum =
4355 	TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4356 				csum, "csum");
4357 cmdline_parse_token_string_t cmd_csum_mode =
4358 	TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4359 				mode, "set");
4360 cmdline_parse_token_string_t cmd_csum_proto =
4361 	TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4362 				proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
4363 cmdline_parse_token_string_t cmd_csum_hwsw =
4364 	TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4365 				hwsw, "hw#sw");
4366 cmdline_parse_token_num_t cmd_csum_portid =
4367 	TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4368 				port_id, UINT16);
4369 
4370 cmdline_parse_inst_t cmd_csum_set = {
4371 	.f = cmd_csum_parsed,
4372 	.data = NULL,
4373 	.help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
4374 		"Enable/Disable hardware calculation of L3/L4 checksum when "
4375 		"using csum forward engine",
4376 	.tokens = {
4377 		(void *)&cmd_csum_csum,
4378 		(void *)&cmd_csum_mode,
4379 		(void *)&cmd_csum_proto,
4380 		(void *)&cmd_csum_hwsw,
4381 		(void *)&cmd_csum_portid,
4382 		NULL,
4383 	},
4384 };
4385 
4386 cmdline_parse_token_string_t cmd_csum_mode_show =
4387 	TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4388 				mode, "show");
4389 
4390 cmdline_parse_inst_t cmd_csum_show = {
4391 	.f = cmd_csum_parsed,
4392 	.data = NULL,
4393 	.help_str = "csum show <port_id>: Show checksum offload configuration",
4394 	.tokens = {
4395 		(void *)&cmd_csum_csum,
4396 		(void *)&cmd_csum_mode_show,
4397 		(void *)&cmd_csum_portid,
4398 		NULL,
4399 	},
4400 };
4401 
4402 /* Enable/disable tunnel parsing */
4403 struct cmd_csum_tunnel_result {
4404 	cmdline_fixed_string_t csum;
4405 	cmdline_fixed_string_t parse;
4406 	cmdline_fixed_string_t onoff;
4407 	portid_t port_id;
4408 };
4409 
4410 static void
4411 cmd_csum_tunnel_parsed(void *parsed_result,
4412 		       __attribute__((unused)) struct cmdline *cl,
4413 		       __attribute__((unused)) void *data)
4414 {
4415 	struct cmd_csum_tunnel_result *res = parsed_result;
4416 
4417 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4418 		return;
4419 
4420 	if (!strcmp(res->onoff, "on"))
4421 		ports[res->port_id].parse_tunnel = 1;
4422 	else
4423 		ports[res->port_id].parse_tunnel = 0;
4424 
4425 	csum_show(res->port_id);
4426 }
4427 
4428 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4429 	TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4430 				csum, "csum");
4431 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4432 	TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4433 				parse, "parse-tunnel");
4434 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4435 	TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4436 				onoff, "on#off");
4437 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4438 	TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4439 				port_id, UINT16);
4440 
4441 cmdline_parse_inst_t cmd_csum_tunnel = {
4442 	.f = cmd_csum_tunnel_parsed,
4443 	.data = NULL,
4444 	.help_str = "csum parse-tunnel on|off <port_id>: "
4445 		"Enable/Disable parsing of tunnels for csum engine",
4446 	.tokens = {
4447 		(void *)&cmd_csum_tunnel_csum,
4448 		(void *)&cmd_csum_tunnel_parse,
4449 		(void *)&cmd_csum_tunnel_onoff,
4450 		(void *)&cmd_csum_tunnel_portid,
4451 		NULL,
4452 	},
4453 };
4454 
4455 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4456 struct cmd_tso_set_result {
4457 	cmdline_fixed_string_t tso;
4458 	cmdline_fixed_string_t mode;
4459 	uint16_t tso_segsz;
4460 	portid_t port_id;
4461 };
4462 
4463 static void
4464 cmd_tso_set_parsed(void *parsed_result,
4465 		       __attribute__((unused)) struct cmdline *cl,
4466 		       __attribute__((unused)) void *data)
4467 {
4468 	struct cmd_tso_set_result *res = parsed_result;
4469 	struct rte_eth_dev_info dev_info;
4470 
4471 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4472 		return;
4473 	if (!port_is_stopped(res->port_id)) {
4474 		printf("Please stop port %d first\n", res->port_id);
4475 		return;
4476 	}
4477 
4478 	if (!strcmp(res->mode, "set"))
4479 		ports[res->port_id].tso_segsz = res->tso_segsz;
4480 
4481 	rte_eth_dev_info_get(res->port_id, &dev_info);
4482 	if ((ports[res->port_id].tso_segsz != 0) &&
4483 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4484 		printf("Error: TSO is not supported by port %d\n",
4485 		       res->port_id);
4486 		return;
4487 	}
4488 
4489 	if (ports[res->port_id].tso_segsz == 0) {
4490 		ports[res->port_id].dev_conf.txmode.offloads &=
4491 						~DEV_TX_OFFLOAD_TCP_TSO;
4492 		printf("TSO for non-tunneled packets is disabled\n");
4493 	} else {
4494 		ports[res->port_id].dev_conf.txmode.offloads |=
4495 						DEV_TX_OFFLOAD_TCP_TSO;
4496 		printf("TSO segment size for non-tunneled packets is %d\n",
4497 			ports[res->port_id].tso_segsz);
4498 	}
4499 
4500 	/* display warnings if configuration is not supported by the NIC */
4501 	rte_eth_dev_info_get(res->port_id, &dev_info);
4502 	if ((ports[res->port_id].tso_segsz != 0) &&
4503 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4504 		printf("Warning: TSO enabled but not "
4505 			"supported by port %d\n", res->port_id);
4506 	}
4507 
4508 	cmd_reconfig_device_queue(res->port_id, 1, 1);
4509 }
4510 
4511 cmdline_parse_token_string_t cmd_tso_set_tso =
4512 	TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4513 				tso, "tso");
4514 cmdline_parse_token_string_t cmd_tso_set_mode =
4515 	TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4516 				mode, "set");
4517 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4518 	TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4519 				tso_segsz, UINT16);
4520 cmdline_parse_token_num_t cmd_tso_set_portid =
4521 	TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4522 				port_id, UINT16);
4523 
4524 cmdline_parse_inst_t cmd_tso_set = {
4525 	.f = cmd_tso_set_parsed,
4526 	.data = NULL,
4527 	.help_str = "tso set <tso_segsz> <port_id>: "
4528 		"Set TSO segment size of non-tunneled packets for csum engine "
4529 		"(0 to disable)",
4530 	.tokens = {
4531 		(void *)&cmd_tso_set_tso,
4532 		(void *)&cmd_tso_set_mode,
4533 		(void *)&cmd_tso_set_tso_segsz,
4534 		(void *)&cmd_tso_set_portid,
4535 		NULL,
4536 	},
4537 };
4538 
4539 cmdline_parse_token_string_t cmd_tso_show_mode =
4540 	TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4541 				mode, "show");
4542 
4543 
4544 cmdline_parse_inst_t cmd_tso_show = {
4545 	.f = cmd_tso_set_parsed,
4546 	.data = NULL,
4547 	.help_str = "tso show <port_id>: "
4548 		"Show TSO segment size of non-tunneled packets for csum engine",
4549 	.tokens = {
4550 		(void *)&cmd_tso_set_tso,
4551 		(void *)&cmd_tso_show_mode,
4552 		(void *)&cmd_tso_set_portid,
4553 		NULL,
4554 	},
4555 };
4556 
4557 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
4558 struct cmd_tunnel_tso_set_result {
4559 	cmdline_fixed_string_t tso;
4560 	cmdline_fixed_string_t mode;
4561 	uint16_t tso_segsz;
4562 	portid_t port_id;
4563 };
4564 
4565 static struct rte_eth_dev_info
4566 check_tunnel_tso_nic_support(portid_t port_id)
4567 {
4568 	struct rte_eth_dev_info dev_info;
4569 
4570 	rte_eth_dev_info_get(port_id, &dev_info);
4571 	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
4572 		printf("Warning: VXLAN TUNNEL TSO not supported therefore "
4573 		       "not enabled for port %d\n", port_id);
4574 	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
4575 		printf("Warning: GRE TUNNEL TSO	not supported therefore "
4576 		       "not enabled for port %d\n", port_id);
4577 	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
4578 		printf("Warning: IPIP TUNNEL TSO not supported therefore "
4579 		       "not enabled for port %d\n", port_id);
4580 	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
4581 		printf("Warning: GENEVE TUNNEL TSO not supported therefore "
4582 		       "not enabled for port %d\n", port_id);
4583 	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
4584 		printf("Warning: IP TUNNEL TSO not supported therefore "
4585 		       "not enabled for port %d\n", port_id);
4586 	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
4587 		printf("Warning: UDP TUNNEL TSO not supported therefore "
4588 		       "not enabled for port %d\n", port_id);
4589 	return dev_info;
4590 }
4591 
4592 static void
4593 cmd_tunnel_tso_set_parsed(void *parsed_result,
4594 			  __attribute__((unused)) struct cmdline *cl,
4595 			  __attribute__((unused)) void *data)
4596 {
4597 	struct cmd_tunnel_tso_set_result *res = parsed_result;
4598 	struct rte_eth_dev_info dev_info;
4599 
4600 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4601 		return;
4602 	if (!port_is_stopped(res->port_id)) {
4603 		printf("Please stop port %d first\n", res->port_id);
4604 		return;
4605 	}
4606 
4607 	if (!strcmp(res->mode, "set"))
4608 		ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
4609 
4610 	dev_info = check_tunnel_tso_nic_support(res->port_id);
4611 	if (ports[res->port_id].tunnel_tso_segsz == 0) {
4612 		ports[res->port_id].dev_conf.txmode.offloads &=
4613 			~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4614 			  DEV_TX_OFFLOAD_GRE_TNL_TSO |
4615 			  DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4616 			  DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4617 			  DEV_TX_OFFLOAD_IP_TNL_TSO |
4618 			  DEV_TX_OFFLOAD_UDP_TNL_TSO);
4619 		printf("TSO for tunneled packets is disabled\n");
4620 	} else {
4621 		uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4622 					 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4623 					 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4624 					 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4625 					 DEV_TX_OFFLOAD_IP_TNL_TSO |
4626 					 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4627 
4628 		ports[res->port_id].dev_conf.txmode.offloads |=
4629 			(tso_offloads & dev_info.tx_offload_capa);
4630 		printf("TSO segment size for tunneled packets is %d\n",
4631 			ports[res->port_id].tunnel_tso_segsz);
4632 
4633 		/* Below conditions are needed to make it work:
4634 		 * (1) tunnel TSO is supported by the NIC;
4635 		 * (2) "csum parse_tunnel" must be set so that tunneled pkts
4636 		 * are recognized;
4637 		 * (3) for tunneled pkts with outer L3 of IPv4,
4638 		 * "csum set outer-ip" must be set to hw, because after tso,
4639 		 * total_len of outer IP header is changed, and the checksum
4640 		 * of outer IP header calculated by sw should be wrong; that
4641 		 * is not necessary for IPv6 tunneled pkts because there's no
4642 		 * checksum in IP header anymore.
4643 		 */
4644 
4645 		if (!ports[res->port_id].parse_tunnel)
4646 			printf("Warning: csum parse_tunnel must be set "
4647 				"so that tunneled packets are recognized\n");
4648 		if (!(ports[res->port_id].dev_conf.txmode.offloads &
4649 		      DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
4650 			printf("Warning: csum set outer-ip must be set to hw "
4651 				"if outer L3 is IPv4; not necessary for IPv6\n");
4652 	}
4653 
4654 	cmd_reconfig_device_queue(res->port_id, 1, 1);
4655 }
4656 
4657 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
4658 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4659 				tso, "tunnel_tso");
4660 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
4661 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4662 				mode, "set");
4663 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
4664 	TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4665 				tso_segsz, UINT16);
4666 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
4667 	TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4668 				port_id, UINT16);
4669 
4670 cmdline_parse_inst_t cmd_tunnel_tso_set = {
4671 	.f = cmd_tunnel_tso_set_parsed,
4672 	.data = NULL,
4673 	.help_str = "tunnel_tso set <tso_segsz> <port_id>: "
4674 		"Set TSO segment size of tunneled packets for csum engine "
4675 		"(0 to disable)",
4676 	.tokens = {
4677 		(void *)&cmd_tunnel_tso_set_tso,
4678 		(void *)&cmd_tunnel_tso_set_mode,
4679 		(void *)&cmd_tunnel_tso_set_tso_segsz,
4680 		(void *)&cmd_tunnel_tso_set_portid,
4681 		NULL,
4682 	},
4683 };
4684 
4685 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
4686 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4687 				mode, "show");
4688 
4689 
4690 cmdline_parse_inst_t cmd_tunnel_tso_show = {
4691 	.f = cmd_tunnel_tso_set_parsed,
4692 	.data = NULL,
4693 	.help_str = "tunnel_tso show <port_id> "
4694 		"Show TSO segment size of tunneled packets for csum engine",
4695 	.tokens = {
4696 		(void *)&cmd_tunnel_tso_set_tso,
4697 		(void *)&cmd_tunnel_tso_show_mode,
4698 		(void *)&cmd_tunnel_tso_set_portid,
4699 		NULL,
4700 	},
4701 };
4702 
4703 /* *** SET GRO FOR A PORT *** */
4704 struct cmd_gro_enable_result {
4705 	cmdline_fixed_string_t cmd_set;
4706 	cmdline_fixed_string_t cmd_port;
4707 	cmdline_fixed_string_t cmd_keyword;
4708 	cmdline_fixed_string_t cmd_onoff;
4709 	portid_t cmd_pid;
4710 };
4711 
4712 static void
4713 cmd_gro_enable_parsed(void *parsed_result,
4714 		__attribute__((unused)) struct cmdline *cl,
4715 		__attribute__((unused)) void *data)
4716 {
4717 	struct cmd_gro_enable_result *res;
4718 
4719 	res = parsed_result;
4720 	if (!strcmp(res->cmd_keyword, "gro"))
4721 		setup_gro(res->cmd_onoff, res->cmd_pid);
4722 }
4723 
4724 cmdline_parse_token_string_t cmd_gro_enable_set =
4725 	TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4726 			cmd_set, "set");
4727 cmdline_parse_token_string_t cmd_gro_enable_port =
4728 	TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4729 			cmd_keyword, "port");
4730 cmdline_parse_token_num_t cmd_gro_enable_pid =
4731 	TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
4732 			cmd_pid, UINT16);
4733 cmdline_parse_token_string_t cmd_gro_enable_keyword =
4734 	TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4735 			cmd_keyword, "gro");
4736 cmdline_parse_token_string_t cmd_gro_enable_onoff =
4737 	TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4738 			cmd_onoff, "on#off");
4739 
4740 cmdline_parse_inst_t cmd_gro_enable = {
4741 	.f = cmd_gro_enable_parsed,
4742 	.data = NULL,
4743 	.help_str = "set port <port_id> gro on|off",
4744 	.tokens = {
4745 		(void *)&cmd_gro_enable_set,
4746 		(void *)&cmd_gro_enable_port,
4747 		(void *)&cmd_gro_enable_pid,
4748 		(void *)&cmd_gro_enable_keyword,
4749 		(void *)&cmd_gro_enable_onoff,
4750 		NULL,
4751 	},
4752 };
4753 
4754 /* *** DISPLAY GRO CONFIGURATION *** */
4755 struct cmd_gro_show_result {
4756 	cmdline_fixed_string_t cmd_show;
4757 	cmdline_fixed_string_t cmd_port;
4758 	cmdline_fixed_string_t cmd_keyword;
4759 	portid_t cmd_pid;
4760 };
4761 
4762 static void
4763 cmd_gro_show_parsed(void *parsed_result,
4764 		__attribute__((unused)) struct cmdline *cl,
4765 		__attribute__((unused)) void *data)
4766 {
4767 	struct cmd_gro_show_result *res;
4768 
4769 	res = parsed_result;
4770 	if (!strcmp(res->cmd_keyword, "gro"))
4771 		show_gro(res->cmd_pid);
4772 }
4773 
4774 cmdline_parse_token_string_t cmd_gro_show_show =
4775 	TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4776 			cmd_show, "show");
4777 cmdline_parse_token_string_t cmd_gro_show_port =
4778 	TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4779 			cmd_port, "port");
4780 cmdline_parse_token_num_t cmd_gro_show_pid =
4781 	TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
4782 			cmd_pid, UINT16);
4783 cmdline_parse_token_string_t cmd_gro_show_keyword =
4784 	TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4785 			cmd_keyword, "gro");
4786 
4787 cmdline_parse_inst_t cmd_gro_show = {
4788 	.f = cmd_gro_show_parsed,
4789 	.data = NULL,
4790 	.help_str = "show port <port_id> gro",
4791 	.tokens = {
4792 		(void *)&cmd_gro_show_show,
4793 		(void *)&cmd_gro_show_port,
4794 		(void *)&cmd_gro_show_pid,
4795 		(void *)&cmd_gro_show_keyword,
4796 		NULL,
4797 	},
4798 };
4799 
4800 /* *** SET FLUSH CYCLES FOR GRO *** */
4801 struct cmd_gro_flush_result {
4802 	cmdline_fixed_string_t cmd_set;
4803 	cmdline_fixed_string_t cmd_keyword;
4804 	cmdline_fixed_string_t cmd_flush;
4805 	uint8_t cmd_cycles;
4806 };
4807 
4808 static void
4809 cmd_gro_flush_parsed(void *parsed_result,
4810 		__attribute__((unused)) struct cmdline *cl,
4811 		__attribute__((unused)) void *data)
4812 {
4813 	struct cmd_gro_flush_result *res;
4814 
4815 	res = parsed_result;
4816 	if ((!strcmp(res->cmd_keyword, "gro")) &&
4817 			(!strcmp(res->cmd_flush, "flush")))
4818 		setup_gro_flush_cycles(res->cmd_cycles);
4819 }
4820 
4821 cmdline_parse_token_string_t cmd_gro_flush_set =
4822 	TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4823 			cmd_set, "set");
4824 cmdline_parse_token_string_t cmd_gro_flush_keyword =
4825 	TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4826 			cmd_keyword, "gro");
4827 cmdline_parse_token_string_t cmd_gro_flush_flush =
4828 	TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4829 			cmd_flush, "flush");
4830 cmdline_parse_token_num_t cmd_gro_flush_cycles =
4831 	TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
4832 			cmd_cycles, UINT8);
4833 
4834 cmdline_parse_inst_t cmd_gro_flush = {
4835 	.f = cmd_gro_flush_parsed,
4836 	.data = NULL,
4837 	.help_str = "set gro flush <cycles>",
4838 	.tokens = {
4839 		(void *)&cmd_gro_flush_set,
4840 		(void *)&cmd_gro_flush_keyword,
4841 		(void *)&cmd_gro_flush_flush,
4842 		(void *)&cmd_gro_flush_cycles,
4843 		NULL,
4844 	},
4845 };
4846 
4847 /* *** ENABLE/DISABLE GSO *** */
4848 struct cmd_gso_enable_result {
4849 	cmdline_fixed_string_t cmd_set;
4850 	cmdline_fixed_string_t cmd_port;
4851 	cmdline_fixed_string_t cmd_keyword;
4852 	cmdline_fixed_string_t cmd_mode;
4853 	portid_t cmd_pid;
4854 };
4855 
4856 static void
4857 cmd_gso_enable_parsed(void *parsed_result,
4858 		__attribute__((unused)) struct cmdline *cl,
4859 		__attribute__((unused)) void *data)
4860 {
4861 	struct cmd_gso_enable_result *res;
4862 
4863 	res = parsed_result;
4864 	if (!strcmp(res->cmd_keyword, "gso"))
4865 		setup_gso(res->cmd_mode, res->cmd_pid);
4866 }
4867 
4868 cmdline_parse_token_string_t cmd_gso_enable_set =
4869 	TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4870 			cmd_set, "set");
4871 cmdline_parse_token_string_t cmd_gso_enable_port =
4872 	TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4873 			cmd_port, "port");
4874 cmdline_parse_token_string_t cmd_gso_enable_keyword =
4875 	TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4876 			cmd_keyword, "gso");
4877 cmdline_parse_token_string_t cmd_gso_enable_mode =
4878 	TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4879 			cmd_mode, "on#off");
4880 cmdline_parse_token_num_t cmd_gso_enable_pid =
4881 	TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
4882 			cmd_pid, UINT16);
4883 
4884 cmdline_parse_inst_t cmd_gso_enable = {
4885 	.f = cmd_gso_enable_parsed,
4886 	.data = NULL,
4887 	.help_str = "set port <port_id> gso on|off",
4888 	.tokens = {
4889 		(void *)&cmd_gso_enable_set,
4890 		(void *)&cmd_gso_enable_port,
4891 		(void *)&cmd_gso_enable_pid,
4892 		(void *)&cmd_gso_enable_keyword,
4893 		(void *)&cmd_gso_enable_mode,
4894 		NULL,
4895 	},
4896 };
4897 
4898 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
4899 struct cmd_gso_size_result {
4900 	cmdline_fixed_string_t cmd_set;
4901 	cmdline_fixed_string_t cmd_keyword;
4902 	cmdline_fixed_string_t cmd_segsz;
4903 	uint16_t cmd_size;
4904 };
4905 
4906 static void
4907 cmd_gso_size_parsed(void *parsed_result,
4908 		       __attribute__((unused)) struct cmdline *cl,
4909 		       __attribute__((unused)) void *data)
4910 {
4911 	struct cmd_gso_size_result *res = parsed_result;
4912 
4913 	if (test_done == 0) {
4914 		printf("Before setting GSO segsz, please first"
4915 				" stop fowarding\n");
4916 		return;
4917 	}
4918 
4919 	if (!strcmp(res->cmd_keyword, "gso") &&
4920 			!strcmp(res->cmd_segsz, "segsz")) {
4921 		if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
4922 			printf("gso_size should be larger than %zu."
4923 					" Please input a legal value\n",
4924 					RTE_GSO_SEG_SIZE_MIN);
4925 		else
4926 			gso_max_segment_size = res->cmd_size;
4927 	}
4928 }
4929 
4930 cmdline_parse_token_string_t cmd_gso_size_set =
4931 	TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4932 				cmd_set, "set");
4933 cmdline_parse_token_string_t cmd_gso_size_keyword =
4934 	TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4935 				cmd_keyword, "gso");
4936 cmdline_parse_token_string_t cmd_gso_size_segsz =
4937 	TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4938 				cmd_segsz, "segsz");
4939 cmdline_parse_token_num_t cmd_gso_size_size =
4940 	TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
4941 				cmd_size, UINT16);
4942 
4943 cmdline_parse_inst_t cmd_gso_size = {
4944 	.f = cmd_gso_size_parsed,
4945 	.data = NULL,
4946 	.help_str = "set gso segsz <length>",
4947 	.tokens = {
4948 		(void *)&cmd_gso_size_set,
4949 		(void *)&cmd_gso_size_keyword,
4950 		(void *)&cmd_gso_size_segsz,
4951 		(void *)&cmd_gso_size_size,
4952 		NULL,
4953 	},
4954 };
4955 
4956 /* *** SHOW GSO CONFIGURATION *** */
4957 struct cmd_gso_show_result {
4958 	cmdline_fixed_string_t cmd_show;
4959 	cmdline_fixed_string_t cmd_port;
4960 	cmdline_fixed_string_t cmd_keyword;
4961 	portid_t cmd_pid;
4962 };
4963 
4964 static void
4965 cmd_gso_show_parsed(void *parsed_result,
4966 		       __attribute__((unused)) struct cmdline *cl,
4967 		       __attribute__((unused)) void *data)
4968 {
4969 	struct cmd_gso_show_result *res = parsed_result;
4970 
4971 	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
4972 		printf("invalid port id %u\n", res->cmd_pid);
4973 		return;
4974 	}
4975 	if (!strcmp(res->cmd_keyword, "gso")) {
4976 		if (gso_ports[res->cmd_pid].enable) {
4977 			printf("Max GSO'd packet size: %uB\n"
4978 					"Supported GSO types: TCP/IPv4, "
4979 					"UDP/IPv4, VxLAN with inner "
4980 					"TCP/IPv4 packet, GRE with inner "
4981 					"TCP/IPv4 packet\n",
4982 					gso_max_segment_size);
4983 		} else
4984 			printf("GSO is not enabled on Port %u\n", res->cmd_pid);
4985 	}
4986 }
4987 
4988 cmdline_parse_token_string_t cmd_gso_show_show =
4989 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4990 		cmd_show, "show");
4991 cmdline_parse_token_string_t cmd_gso_show_port =
4992 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4993 		cmd_port, "port");
4994 cmdline_parse_token_string_t cmd_gso_show_keyword =
4995 	TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4996 				cmd_keyword, "gso");
4997 cmdline_parse_token_num_t cmd_gso_show_pid =
4998 	TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
4999 				cmd_pid, UINT16);
5000 
5001 cmdline_parse_inst_t cmd_gso_show = {
5002 	.f = cmd_gso_show_parsed,
5003 	.data = NULL,
5004 	.help_str = "show port <port_id> gso",
5005 	.tokens = {
5006 		(void *)&cmd_gso_show_show,
5007 		(void *)&cmd_gso_show_port,
5008 		(void *)&cmd_gso_show_pid,
5009 		(void *)&cmd_gso_show_keyword,
5010 		NULL,
5011 	},
5012 };
5013 
5014 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
5015 struct cmd_set_flush_rx {
5016 	cmdline_fixed_string_t set;
5017 	cmdline_fixed_string_t flush_rx;
5018 	cmdline_fixed_string_t mode;
5019 };
5020 
5021 static void
5022 cmd_set_flush_rx_parsed(void *parsed_result,
5023 		__attribute__((unused)) struct cmdline *cl,
5024 		__attribute__((unused)) void *data)
5025 {
5026 	struct cmd_set_flush_rx *res = parsed_result;
5027 	no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5028 }
5029 
5030 cmdline_parse_token_string_t cmd_setflushrx_set =
5031 	TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5032 			set, "set");
5033 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
5034 	TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5035 			flush_rx, "flush_rx");
5036 cmdline_parse_token_string_t cmd_setflushrx_mode =
5037 	TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5038 			mode, "on#off");
5039 
5040 
5041 cmdline_parse_inst_t cmd_set_flush_rx = {
5042 	.f = cmd_set_flush_rx_parsed,
5043 	.help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
5044 	.data = NULL,
5045 	.tokens = {
5046 		(void *)&cmd_setflushrx_set,
5047 		(void *)&cmd_setflushrx_flush_rx,
5048 		(void *)&cmd_setflushrx_mode,
5049 		NULL,
5050 	},
5051 };
5052 
5053 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
5054 struct cmd_set_link_check {
5055 	cmdline_fixed_string_t set;
5056 	cmdline_fixed_string_t link_check;
5057 	cmdline_fixed_string_t mode;
5058 };
5059 
5060 static void
5061 cmd_set_link_check_parsed(void *parsed_result,
5062 		__attribute__((unused)) struct cmdline *cl,
5063 		__attribute__((unused)) void *data)
5064 {
5065 	struct cmd_set_link_check *res = parsed_result;
5066 	no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5067 }
5068 
5069 cmdline_parse_token_string_t cmd_setlinkcheck_set =
5070 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5071 			set, "set");
5072 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
5073 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5074 			link_check, "link_check");
5075 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
5076 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5077 			mode, "on#off");
5078 
5079 
5080 cmdline_parse_inst_t cmd_set_link_check = {
5081 	.f = cmd_set_link_check_parsed,
5082 	.help_str = "set link_check on|off: Enable/Disable link status check "
5083 	            "when starting/stopping a port",
5084 	.data = NULL,
5085 	.tokens = {
5086 		(void *)&cmd_setlinkcheck_set,
5087 		(void *)&cmd_setlinkcheck_link_check,
5088 		(void *)&cmd_setlinkcheck_mode,
5089 		NULL,
5090 	},
5091 };
5092 
5093 /* *** SET NIC BYPASS MODE *** */
5094 struct cmd_set_bypass_mode_result {
5095 	cmdline_fixed_string_t set;
5096 	cmdline_fixed_string_t bypass;
5097 	cmdline_fixed_string_t mode;
5098 	cmdline_fixed_string_t value;
5099 	portid_t port_id;
5100 };
5101 
5102 static void
5103 cmd_set_bypass_mode_parsed(void *parsed_result,
5104 		__attribute__((unused)) struct cmdline *cl,
5105 		__attribute__((unused)) void *data)
5106 {
5107 	struct cmd_set_bypass_mode_result *res = parsed_result;
5108 	portid_t port_id = res->port_id;
5109 	int32_t rc = -EINVAL;
5110 
5111 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5112 	uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5113 
5114 	if (!strcmp(res->value, "bypass"))
5115 		bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5116 	else if (!strcmp(res->value, "isolate"))
5117 		bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5118 	else
5119 		bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5120 
5121 	/* Set the bypass mode for the relevant port. */
5122 	rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
5123 #endif
5124 	if (rc != 0)
5125 		printf("\t Failed to set bypass mode for port = %d.\n", port_id);
5126 }
5127 
5128 cmdline_parse_token_string_t cmd_setbypass_mode_set =
5129 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5130 			set, "set");
5131 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
5132 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5133 			bypass, "bypass");
5134 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
5135 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5136 			mode, "mode");
5137 cmdline_parse_token_string_t cmd_setbypass_mode_value =
5138 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5139 			value, "normal#bypass#isolate");
5140 cmdline_parse_token_num_t cmd_setbypass_mode_port =
5141 	TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
5142 				port_id, UINT16);
5143 
5144 cmdline_parse_inst_t cmd_set_bypass_mode = {
5145 	.f = cmd_set_bypass_mode_parsed,
5146 	.help_str = "set bypass mode normal|bypass|isolate <port_id>: "
5147 	            "Set the NIC bypass mode for port_id",
5148 	.data = NULL,
5149 	.tokens = {
5150 		(void *)&cmd_setbypass_mode_set,
5151 		(void *)&cmd_setbypass_mode_bypass,
5152 		(void *)&cmd_setbypass_mode_mode,
5153 		(void *)&cmd_setbypass_mode_value,
5154 		(void *)&cmd_setbypass_mode_port,
5155 		NULL,
5156 	},
5157 };
5158 
5159 /* *** SET NIC BYPASS EVENT *** */
5160 struct cmd_set_bypass_event_result {
5161 	cmdline_fixed_string_t set;
5162 	cmdline_fixed_string_t bypass;
5163 	cmdline_fixed_string_t event;
5164 	cmdline_fixed_string_t event_value;
5165 	cmdline_fixed_string_t mode;
5166 	cmdline_fixed_string_t mode_value;
5167 	portid_t port_id;
5168 };
5169 
5170 static void
5171 cmd_set_bypass_event_parsed(void *parsed_result,
5172 		__attribute__((unused)) struct cmdline *cl,
5173 		__attribute__((unused)) void *data)
5174 {
5175 	int32_t rc = -EINVAL;
5176 	struct cmd_set_bypass_event_result *res = parsed_result;
5177 	portid_t port_id = res->port_id;
5178 
5179 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5180 	uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5181 	uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5182 
5183 	if (!strcmp(res->event_value, "timeout"))
5184 		bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
5185 	else if (!strcmp(res->event_value, "os_on"))
5186 		bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
5187 	else if (!strcmp(res->event_value, "os_off"))
5188 		bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5189 	else if (!strcmp(res->event_value, "power_on"))
5190 		bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5191 	else if (!strcmp(res->event_value, "power_off"))
5192 		bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5193 	else
5194 		bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5195 
5196 	if (!strcmp(res->mode_value, "bypass"))
5197 		bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5198 	else if (!strcmp(res->mode_value, "isolate"))
5199 		bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5200 	else
5201 		bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5202 
5203 	/* Set the watchdog timeout. */
5204 	if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5205 
5206 		rc = -EINVAL;
5207 		if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5208 			rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5209 							   bypass_timeout);
5210 		}
5211 		if (rc != 0) {
5212 			printf("Failed to set timeout value %u "
5213 			"for port %d, errto code: %d.\n",
5214 			bypass_timeout, port_id, rc);
5215 		}
5216 	}
5217 
5218 	/* Set the bypass event to transition to bypass mode. */
5219 	rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5220 					      bypass_mode);
5221 #endif
5222 
5223 	if (rc != 0)
5224 		printf("\t Failed to set bypass event for port = %d.\n",
5225 		       port_id);
5226 }
5227 
5228 cmdline_parse_token_string_t cmd_setbypass_event_set =
5229 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5230 			set, "set");
5231 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5232 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5233 			bypass, "bypass");
5234 cmdline_parse_token_string_t cmd_setbypass_event_event =
5235 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5236 			event, "event");
5237 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5238 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5239 			event_value, "none#timeout#os_off#os_on#power_on#power_off");
5240 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5241 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5242 			mode, "mode");
5243 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5244 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5245 			mode_value, "normal#bypass#isolate");
5246 cmdline_parse_token_num_t cmd_setbypass_event_port =
5247 	TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5248 				port_id, UINT16);
5249 
5250 cmdline_parse_inst_t cmd_set_bypass_event = {
5251 	.f = cmd_set_bypass_event_parsed,
5252 	.help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5253 		"power_off mode normal|bypass|isolate <port_id>: "
5254 		"Set the NIC bypass event mode for port_id",
5255 	.data = NULL,
5256 	.tokens = {
5257 		(void *)&cmd_setbypass_event_set,
5258 		(void *)&cmd_setbypass_event_bypass,
5259 		(void *)&cmd_setbypass_event_event,
5260 		(void *)&cmd_setbypass_event_event_value,
5261 		(void *)&cmd_setbypass_event_mode,
5262 		(void *)&cmd_setbypass_event_mode_value,
5263 		(void *)&cmd_setbypass_event_port,
5264 		NULL,
5265 	},
5266 };
5267 
5268 
5269 /* *** SET NIC BYPASS TIMEOUT *** */
5270 struct cmd_set_bypass_timeout_result {
5271 	cmdline_fixed_string_t set;
5272 	cmdline_fixed_string_t bypass;
5273 	cmdline_fixed_string_t timeout;
5274 	cmdline_fixed_string_t value;
5275 };
5276 
5277 static void
5278 cmd_set_bypass_timeout_parsed(void *parsed_result,
5279 		__attribute__((unused)) struct cmdline *cl,
5280 		__attribute__((unused)) void *data)
5281 {
5282 	__rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5283 
5284 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5285 	if (!strcmp(res->value, "1.5"))
5286 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5287 	else if (!strcmp(res->value, "2"))
5288 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5289 	else if (!strcmp(res->value, "3"))
5290 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5291 	else if (!strcmp(res->value, "4"))
5292 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5293 	else if (!strcmp(res->value, "8"))
5294 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5295 	else if (!strcmp(res->value, "16"))
5296 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5297 	else if (!strcmp(res->value, "32"))
5298 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5299 	else
5300 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5301 #endif
5302 }
5303 
5304 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5305 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5306 			set, "set");
5307 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5308 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5309 			bypass, "bypass");
5310 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5311 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5312 			timeout, "timeout");
5313 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5314 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5315 			value, "0#1.5#2#3#4#8#16#32");
5316 
5317 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5318 	.f = cmd_set_bypass_timeout_parsed,
5319 	.help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5320 		"Set the NIC bypass watchdog timeout in seconds",
5321 	.data = NULL,
5322 	.tokens = {
5323 		(void *)&cmd_setbypass_timeout_set,
5324 		(void *)&cmd_setbypass_timeout_bypass,
5325 		(void *)&cmd_setbypass_timeout_timeout,
5326 		(void *)&cmd_setbypass_timeout_value,
5327 		NULL,
5328 	},
5329 };
5330 
5331 /* *** SHOW NIC BYPASS MODE *** */
5332 struct cmd_show_bypass_config_result {
5333 	cmdline_fixed_string_t show;
5334 	cmdline_fixed_string_t bypass;
5335 	cmdline_fixed_string_t config;
5336 	portid_t port_id;
5337 };
5338 
5339 static void
5340 cmd_show_bypass_config_parsed(void *parsed_result,
5341 		__attribute__((unused)) struct cmdline *cl,
5342 		__attribute__((unused)) void *data)
5343 {
5344 	struct cmd_show_bypass_config_result *res = parsed_result;
5345 	portid_t port_id = res->port_id;
5346 	int rc = -EINVAL;
5347 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5348 	uint32_t event_mode;
5349 	uint32_t bypass_mode;
5350 	uint32_t timeout = bypass_timeout;
5351 	int i;
5352 
5353 	static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5354 		{"off", "1.5", "2", "3", "4", "8", "16", "32"};
5355 	static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5356 		{"UNKNOWN", "normal", "bypass", "isolate"};
5357 	static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5358 		"NONE",
5359 		"OS/board on",
5360 		"power supply on",
5361 		"OS/board off",
5362 		"power supply off",
5363 		"timeout"};
5364 	int num_events = (sizeof events) / (sizeof events[0]);
5365 
5366 	/* Display the bypass mode.*/
5367 	if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5368 		printf("\tFailed to get bypass mode for port = %d\n", port_id);
5369 		return;
5370 	}
5371 	else {
5372 		if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5373 			bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5374 
5375 		printf("\tbypass mode    = %s\n",  modes[bypass_mode]);
5376 	}
5377 
5378 	/* Display the bypass timeout.*/
5379 	if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5380 		timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5381 
5382 	printf("\tbypass timeout = %s\n", timeouts[timeout]);
5383 
5384 	/* Display the bypass events and associated modes. */
5385 	for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < num_events; i++) {
5386 
5387 		if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5388 			printf("\tFailed to get bypass mode for event = %s\n",
5389 				events[i]);
5390 		} else {
5391 			if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5392 				event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5393 
5394 			printf("\tbypass event: %-16s = %s\n", events[i],
5395 				modes[event_mode]);
5396 		}
5397 	}
5398 #endif
5399 	if (rc != 0)
5400 		printf("\tFailed to get bypass configuration for port = %d\n",
5401 		       port_id);
5402 }
5403 
5404 cmdline_parse_token_string_t cmd_showbypass_config_show =
5405 	TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5406 			show, "show");
5407 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5408 	TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5409 			bypass, "bypass");
5410 cmdline_parse_token_string_t cmd_showbypass_config_config =
5411 	TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5412 			config, "config");
5413 cmdline_parse_token_num_t cmd_showbypass_config_port =
5414 	TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5415 				port_id, UINT16);
5416 
5417 cmdline_parse_inst_t cmd_show_bypass_config = {
5418 	.f = cmd_show_bypass_config_parsed,
5419 	.help_str = "show bypass config <port_id>: "
5420 	            "Show the NIC bypass config for port_id",
5421 	.data = NULL,
5422 	.tokens = {
5423 		(void *)&cmd_showbypass_config_show,
5424 		(void *)&cmd_showbypass_config_bypass,
5425 		(void *)&cmd_showbypass_config_config,
5426 		(void *)&cmd_showbypass_config_port,
5427 		NULL,
5428 	},
5429 };
5430 
5431 #ifdef RTE_LIBRTE_PMD_BOND
5432 /* *** SET BONDING MODE *** */
5433 struct cmd_set_bonding_mode_result {
5434 	cmdline_fixed_string_t set;
5435 	cmdline_fixed_string_t bonding;
5436 	cmdline_fixed_string_t mode;
5437 	uint8_t value;
5438 	portid_t port_id;
5439 };
5440 
5441 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5442 		__attribute__((unused))  struct cmdline *cl,
5443 		__attribute__((unused)) void *data)
5444 {
5445 	struct cmd_set_bonding_mode_result *res = parsed_result;
5446 	portid_t port_id = res->port_id;
5447 
5448 	/* Set the bonding mode for the relevant port. */
5449 	if (0 != rte_eth_bond_mode_set(port_id, res->value))
5450 		printf("\t Failed to set bonding mode for port = %d.\n", port_id);
5451 }
5452 
5453 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5454 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5455 		set, "set");
5456 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5457 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5458 		bonding, "bonding");
5459 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5460 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5461 		mode, "mode");
5462 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5463 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5464 		value, UINT8);
5465 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5466 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5467 		port_id, UINT16);
5468 
5469 cmdline_parse_inst_t cmd_set_bonding_mode = {
5470 		.f = cmd_set_bonding_mode_parsed,
5471 		.help_str = "set bonding mode <mode_value> <port_id>: "
5472 			"Set the bonding mode for port_id",
5473 		.data = NULL,
5474 		.tokens = {
5475 				(void *) &cmd_setbonding_mode_set,
5476 				(void *) &cmd_setbonding_mode_bonding,
5477 				(void *) &cmd_setbonding_mode_mode,
5478 				(void *) &cmd_setbonding_mode_value,
5479 				(void *) &cmd_setbonding_mode_port,
5480 				NULL
5481 		}
5482 };
5483 
5484 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5485 struct cmd_set_bonding_lacp_dedicated_queues_result {
5486 	cmdline_fixed_string_t set;
5487 	cmdline_fixed_string_t bonding;
5488 	cmdline_fixed_string_t lacp;
5489 	cmdline_fixed_string_t dedicated_queues;
5490 	portid_t port_id;
5491 	cmdline_fixed_string_t mode;
5492 };
5493 
5494 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5495 		__attribute__((unused))  struct cmdline *cl,
5496 		__attribute__((unused)) void *data)
5497 {
5498 	struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5499 	portid_t port_id = res->port_id;
5500 	struct rte_port *port;
5501 
5502 	port = &ports[port_id];
5503 
5504 	/** Check if the port is not started **/
5505 	if (port->port_status != RTE_PORT_STOPPED) {
5506 		printf("Please stop port %d first\n", port_id);
5507 		return;
5508 	}
5509 
5510 	if (!strcmp(res->mode, "enable")) {
5511 		if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5512 			printf("Dedicate queues for LACP control packets"
5513 					" enabled\n");
5514 		else
5515 			printf("Enabling dedicate queues for LACP control "
5516 					"packets on port %d failed\n", port_id);
5517 	} else if (!strcmp(res->mode, "disable")) {
5518 		if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5519 			printf("Dedicated queues for LACP control packets "
5520 					"disabled\n");
5521 		else
5522 			printf("Disabling dedicated queues for LACP control "
5523 					"traffic on port %d failed\n", port_id);
5524 	}
5525 }
5526 
5527 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5528 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5529 		set, "set");
5530 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
5531 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5532 		bonding, "bonding");
5533 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
5534 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5535 		lacp, "lacp");
5536 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
5537 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5538 		dedicated_queues, "dedicated_queues");
5539 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
5540 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5541 		port_id, UINT16);
5542 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
5543 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5544 		mode, "enable#disable");
5545 
5546 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
5547 		.f = cmd_set_bonding_lacp_dedicated_queues_parsed,
5548 		.help_str = "set bonding lacp dedicated_queues <port_id> "
5549 			"enable|disable: "
5550 			"Enable/disable dedicated queues for LACP control traffic for port_id",
5551 		.data = NULL,
5552 		.tokens = {
5553 			(void *)&cmd_setbonding_lacp_dedicated_queues_set,
5554 			(void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
5555 			(void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
5556 			(void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
5557 			(void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
5558 			(void *)&cmd_setbonding_lacp_dedicated_queues_mode,
5559 			NULL
5560 		}
5561 };
5562 
5563 /* *** SET BALANCE XMIT POLICY *** */
5564 struct cmd_set_bonding_balance_xmit_policy_result {
5565 	cmdline_fixed_string_t set;
5566 	cmdline_fixed_string_t bonding;
5567 	cmdline_fixed_string_t balance_xmit_policy;
5568 	portid_t port_id;
5569 	cmdline_fixed_string_t policy;
5570 };
5571 
5572 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
5573 		__attribute__((unused))  struct cmdline *cl,
5574 		__attribute__((unused)) void *data)
5575 {
5576 	struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
5577 	portid_t port_id = res->port_id;
5578 	uint8_t policy;
5579 
5580 	if (!strcmp(res->policy, "l2")) {
5581 		policy = BALANCE_XMIT_POLICY_LAYER2;
5582 	} else if (!strcmp(res->policy, "l23")) {
5583 		policy = BALANCE_XMIT_POLICY_LAYER23;
5584 	} else if (!strcmp(res->policy, "l34")) {
5585 		policy = BALANCE_XMIT_POLICY_LAYER34;
5586 	} else {
5587 		printf("\t Invalid xmit policy selection");
5588 		return;
5589 	}
5590 
5591 	/* Set the bonding mode for the relevant port. */
5592 	if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
5593 		printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
5594 				port_id);
5595 	}
5596 }
5597 
5598 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
5599 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5600 		set, "set");
5601 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
5602 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5603 		bonding, "bonding");
5604 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
5605 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5606 		balance_xmit_policy, "balance_xmit_policy");
5607 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
5608 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5609 		port_id, UINT16);
5610 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
5611 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5612 		policy, "l2#l23#l34");
5613 
5614 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
5615 		.f = cmd_set_bonding_balance_xmit_policy_parsed,
5616 		.help_str = "set bonding balance_xmit_policy <port_id> "
5617 			"l2|l23|l34: "
5618 			"Set the bonding balance_xmit_policy for port_id",
5619 		.data = NULL,
5620 		.tokens = {
5621 				(void *)&cmd_setbonding_balance_xmit_policy_set,
5622 				(void *)&cmd_setbonding_balance_xmit_policy_bonding,
5623 				(void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
5624 				(void *)&cmd_setbonding_balance_xmit_policy_port,
5625 				(void *)&cmd_setbonding_balance_xmit_policy_policy,
5626 				NULL
5627 		}
5628 };
5629 
5630 /* *** SHOW NIC BONDING CONFIGURATION *** */
5631 struct cmd_show_bonding_config_result {
5632 	cmdline_fixed_string_t show;
5633 	cmdline_fixed_string_t bonding;
5634 	cmdline_fixed_string_t config;
5635 	portid_t port_id;
5636 };
5637 
5638 static void cmd_show_bonding_config_parsed(void *parsed_result,
5639 		__attribute__((unused))  struct cmdline *cl,
5640 		__attribute__((unused)) void *data)
5641 {
5642 	struct cmd_show_bonding_config_result *res = parsed_result;
5643 	int bonding_mode, agg_mode;
5644 	portid_t slaves[RTE_MAX_ETHPORTS];
5645 	int num_slaves, num_active_slaves;
5646 	int primary_id;
5647 	int i;
5648 	portid_t port_id = res->port_id;
5649 
5650 	/* Display the bonding mode.*/
5651 	bonding_mode = rte_eth_bond_mode_get(port_id);
5652 	if (bonding_mode < 0) {
5653 		printf("\tFailed to get bonding mode for port = %d\n", port_id);
5654 		return;
5655 	} else
5656 		printf("\tBonding mode: %d\n", bonding_mode);
5657 
5658 	if (bonding_mode == BONDING_MODE_BALANCE) {
5659 		int balance_xmit_policy;
5660 
5661 		balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
5662 		if (balance_xmit_policy < 0) {
5663 			printf("\tFailed to get balance xmit policy for port = %d\n",
5664 					port_id);
5665 			return;
5666 		} else {
5667 			printf("\tBalance Xmit Policy: ");
5668 
5669 			switch (balance_xmit_policy) {
5670 			case BALANCE_XMIT_POLICY_LAYER2:
5671 				printf("BALANCE_XMIT_POLICY_LAYER2");
5672 				break;
5673 			case BALANCE_XMIT_POLICY_LAYER23:
5674 				printf("BALANCE_XMIT_POLICY_LAYER23");
5675 				break;
5676 			case BALANCE_XMIT_POLICY_LAYER34:
5677 				printf("BALANCE_XMIT_POLICY_LAYER34");
5678 				break;
5679 			}
5680 			printf("\n");
5681 		}
5682 	}
5683 
5684 	if (bonding_mode == BONDING_MODE_8023AD) {
5685 		agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
5686 		printf("\tIEEE802.3AD Aggregator Mode: ");
5687 		switch (agg_mode) {
5688 		case AGG_BANDWIDTH:
5689 			printf("bandwidth");
5690 			break;
5691 		case AGG_STABLE:
5692 			printf("stable");
5693 			break;
5694 		case AGG_COUNT:
5695 			printf("count");
5696 			break;
5697 		}
5698 		printf("\n");
5699 	}
5700 
5701 	num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
5702 
5703 	if (num_slaves < 0) {
5704 		printf("\tFailed to get slave list for port = %d\n", port_id);
5705 		return;
5706 	}
5707 	if (num_slaves > 0) {
5708 		printf("\tSlaves (%d): [", num_slaves);
5709 		for (i = 0; i < num_slaves - 1; i++)
5710 			printf("%d ", slaves[i]);
5711 
5712 		printf("%d]\n", slaves[num_slaves - 1]);
5713 	} else {
5714 		printf("\tSlaves: []\n");
5715 
5716 	}
5717 
5718 	num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
5719 			RTE_MAX_ETHPORTS);
5720 
5721 	if (num_active_slaves < 0) {
5722 		printf("\tFailed to get active slave list for port = %d\n", port_id);
5723 		return;
5724 	}
5725 	if (num_active_slaves > 0) {
5726 		printf("\tActive Slaves (%d): [", num_active_slaves);
5727 		for (i = 0; i < num_active_slaves - 1; i++)
5728 			printf("%d ", slaves[i]);
5729 
5730 		printf("%d]\n", slaves[num_active_slaves - 1]);
5731 
5732 	} else {
5733 		printf("\tActive Slaves: []\n");
5734 
5735 	}
5736 
5737 	primary_id = rte_eth_bond_primary_get(port_id);
5738 	if (primary_id < 0) {
5739 		printf("\tFailed to get primary slave for port = %d\n", port_id);
5740 		return;
5741 	} else
5742 		printf("\tPrimary: [%d]\n", primary_id);
5743 
5744 }
5745 
5746 cmdline_parse_token_string_t cmd_showbonding_config_show =
5747 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5748 		show, "show");
5749 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
5750 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5751 		bonding, "bonding");
5752 cmdline_parse_token_string_t cmd_showbonding_config_config =
5753 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5754 		config, "config");
5755 cmdline_parse_token_num_t cmd_showbonding_config_port =
5756 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
5757 		port_id, UINT16);
5758 
5759 cmdline_parse_inst_t cmd_show_bonding_config = {
5760 		.f = cmd_show_bonding_config_parsed,
5761 		.help_str = "show bonding config <port_id>: "
5762 			"Show the bonding config for port_id",
5763 		.data = NULL,
5764 		.tokens = {
5765 				(void *)&cmd_showbonding_config_show,
5766 				(void *)&cmd_showbonding_config_bonding,
5767 				(void *)&cmd_showbonding_config_config,
5768 				(void *)&cmd_showbonding_config_port,
5769 				NULL
5770 		}
5771 };
5772 
5773 /* *** SET BONDING PRIMARY *** */
5774 struct cmd_set_bonding_primary_result {
5775 	cmdline_fixed_string_t set;
5776 	cmdline_fixed_string_t bonding;
5777 	cmdline_fixed_string_t primary;
5778 	portid_t slave_id;
5779 	portid_t port_id;
5780 };
5781 
5782 static void cmd_set_bonding_primary_parsed(void *parsed_result,
5783 		__attribute__((unused))  struct cmdline *cl,
5784 		__attribute__((unused)) void *data)
5785 {
5786 	struct cmd_set_bonding_primary_result *res = parsed_result;
5787 	portid_t master_port_id = res->port_id;
5788 	portid_t slave_port_id = res->slave_id;
5789 
5790 	/* Set the primary slave for a bonded device. */
5791 	if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
5792 		printf("\t Failed to set primary slave for port = %d.\n",
5793 				master_port_id);
5794 		return;
5795 	}
5796 	init_port_config();
5797 }
5798 
5799 cmdline_parse_token_string_t cmd_setbonding_primary_set =
5800 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5801 		set, "set");
5802 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
5803 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5804 		bonding, "bonding");
5805 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
5806 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5807 		primary, "primary");
5808 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
5809 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5810 		slave_id, UINT16);
5811 cmdline_parse_token_num_t cmd_setbonding_primary_port =
5812 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5813 		port_id, UINT16);
5814 
5815 cmdline_parse_inst_t cmd_set_bonding_primary = {
5816 		.f = cmd_set_bonding_primary_parsed,
5817 		.help_str = "set bonding primary <slave_id> <port_id>: "
5818 			"Set the primary slave for port_id",
5819 		.data = NULL,
5820 		.tokens = {
5821 				(void *)&cmd_setbonding_primary_set,
5822 				(void *)&cmd_setbonding_primary_bonding,
5823 				(void *)&cmd_setbonding_primary_primary,
5824 				(void *)&cmd_setbonding_primary_slave,
5825 				(void *)&cmd_setbonding_primary_port,
5826 				NULL
5827 		}
5828 };
5829 
5830 /* *** ADD SLAVE *** */
5831 struct cmd_add_bonding_slave_result {
5832 	cmdline_fixed_string_t add;
5833 	cmdline_fixed_string_t bonding;
5834 	cmdline_fixed_string_t slave;
5835 	portid_t slave_id;
5836 	portid_t port_id;
5837 };
5838 
5839 static void cmd_add_bonding_slave_parsed(void *parsed_result,
5840 		__attribute__((unused))  struct cmdline *cl,
5841 		__attribute__((unused)) void *data)
5842 {
5843 	struct cmd_add_bonding_slave_result *res = parsed_result;
5844 	portid_t master_port_id = res->port_id;
5845 	portid_t slave_port_id = res->slave_id;
5846 
5847 	/* add the slave for a bonded device. */
5848 	if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
5849 		printf("\t Failed to add slave %d to master port = %d.\n",
5850 				slave_port_id, master_port_id);
5851 		return;
5852 	}
5853 	init_port_config();
5854 	set_port_slave_flag(slave_port_id);
5855 }
5856 
5857 cmdline_parse_token_string_t cmd_addbonding_slave_add =
5858 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5859 		add, "add");
5860 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
5861 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5862 		bonding, "bonding");
5863 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
5864 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5865 		slave, "slave");
5866 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
5867 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5868 		slave_id, UINT16);
5869 cmdline_parse_token_num_t cmd_addbonding_slave_port =
5870 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5871 		port_id, UINT16);
5872 
5873 cmdline_parse_inst_t cmd_add_bonding_slave = {
5874 		.f = cmd_add_bonding_slave_parsed,
5875 		.help_str = "add bonding slave <slave_id> <port_id>: "
5876 			"Add a slave device to a bonded device",
5877 		.data = NULL,
5878 		.tokens = {
5879 				(void *)&cmd_addbonding_slave_add,
5880 				(void *)&cmd_addbonding_slave_bonding,
5881 				(void *)&cmd_addbonding_slave_slave,
5882 				(void *)&cmd_addbonding_slave_slaveid,
5883 				(void *)&cmd_addbonding_slave_port,
5884 				NULL
5885 		}
5886 };
5887 
5888 /* *** REMOVE SLAVE *** */
5889 struct cmd_remove_bonding_slave_result {
5890 	cmdline_fixed_string_t remove;
5891 	cmdline_fixed_string_t bonding;
5892 	cmdline_fixed_string_t slave;
5893 	portid_t slave_id;
5894 	portid_t port_id;
5895 };
5896 
5897 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
5898 		__attribute__((unused))  struct cmdline *cl,
5899 		__attribute__((unused)) void *data)
5900 {
5901 	struct cmd_remove_bonding_slave_result *res = parsed_result;
5902 	portid_t master_port_id = res->port_id;
5903 	portid_t slave_port_id = res->slave_id;
5904 
5905 	/* remove the slave from a bonded device. */
5906 	if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
5907 		printf("\t Failed to remove slave %d from master port = %d.\n",
5908 				slave_port_id, master_port_id);
5909 		return;
5910 	}
5911 	init_port_config();
5912 	clear_port_slave_flag(slave_port_id);
5913 }
5914 
5915 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
5916 		TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5917 				remove, "remove");
5918 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
5919 		TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5920 				bonding, "bonding");
5921 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
5922 		TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5923 				slave, "slave");
5924 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
5925 		TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5926 				slave_id, UINT16);
5927 cmdline_parse_token_num_t cmd_removebonding_slave_port =
5928 		TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5929 				port_id, UINT16);
5930 
5931 cmdline_parse_inst_t cmd_remove_bonding_slave = {
5932 		.f = cmd_remove_bonding_slave_parsed,
5933 		.help_str = "remove bonding slave <slave_id> <port_id>: "
5934 			"Remove a slave device from a bonded device",
5935 		.data = NULL,
5936 		.tokens = {
5937 				(void *)&cmd_removebonding_slave_remove,
5938 				(void *)&cmd_removebonding_slave_bonding,
5939 				(void *)&cmd_removebonding_slave_slave,
5940 				(void *)&cmd_removebonding_slave_slaveid,
5941 				(void *)&cmd_removebonding_slave_port,
5942 				NULL
5943 		}
5944 };
5945 
5946 /* *** CREATE BONDED DEVICE *** */
5947 struct cmd_create_bonded_device_result {
5948 	cmdline_fixed_string_t create;
5949 	cmdline_fixed_string_t bonded;
5950 	cmdline_fixed_string_t device;
5951 	uint8_t mode;
5952 	uint8_t socket;
5953 };
5954 
5955 static int bond_dev_num = 0;
5956 
5957 static void cmd_create_bonded_device_parsed(void *parsed_result,
5958 		__attribute__((unused))  struct cmdline *cl,
5959 		__attribute__((unused)) void *data)
5960 {
5961 	struct cmd_create_bonded_device_result *res = parsed_result;
5962 	char ethdev_name[RTE_ETH_NAME_MAX_LEN];
5963 	int port_id;
5964 
5965 	if (test_done == 0) {
5966 		printf("Please stop forwarding first\n");
5967 		return;
5968 	}
5969 
5970 	snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
5971 			bond_dev_num++);
5972 
5973 	/* Create a new bonded device. */
5974 	port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
5975 	if (port_id < 0) {
5976 		printf("\t Failed to create bonded device.\n");
5977 		return;
5978 	} else {
5979 		printf("Created new bonded device %s on (port %d).\n", ethdev_name,
5980 				port_id);
5981 
5982 		/* Update number of ports */
5983 		nb_ports = rte_eth_dev_count_avail();
5984 		reconfig(port_id, res->socket);
5985 		rte_eth_promiscuous_enable(port_id);
5986 		ports[port_id].need_setup = 0;
5987 		ports[port_id].port_status = RTE_PORT_STOPPED;
5988 	}
5989 
5990 }
5991 
5992 cmdline_parse_token_string_t cmd_createbonded_device_create =
5993 		TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5994 				create, "create");
5995 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
5996 		TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5997 				bonded, "bonded");
5998 cmdline_parse_token_string_t cmd_createbonded_device_device =
5999 		TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6000 				device, "device");
6001 cmdline_parse_token_num_t cmd_createbonded_device_mode =
6002 		TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6003 				mode, UINT8);
6004 cmdline_parse_token_num_t cmd_createbonded_device_socket =
6005 		TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6006 				socket, UINT8);
6007 
6008 cmdline_parse_inst_t cmd_create_bonded_device = {
6009 		.f = cmd_create_bonded_device_parsed,
6010 		.help_str = "create bonded device <mode> <socket>: "
6011 			"Create a new bonded device with specific bonding mode and socket",
6012 		.data = NULL,
6013 		.tokens = {
6014 				(void *)&cmd_createbonded_device_create,
6015 				(void *)&cmd_createbonded_device_bonded,
6016 				(void *)&cmd_createbonded_device_device,
6017 				(void *)&cmd_createbonded_device_mode,
6018 				(void *)&cmd_createbonded_device_socket,
6019 				NULL
6020 		}
6021 };
6022 
6023 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
6024 struct cmd_set_bond_mac_addr_result {
6025 	cmdline_fixed_string_t set;
6026 	cmdline_fixed_string_t bonding;
6027 	cmdline_fixed_string_t mac_addr;
6028 	uint16_t port_num;
6029 	struct ether_addr address;
6030 };
6031 
6032 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
6033 		__attribute__((unused))  struct cmdline *cl,
6034 		__attribute__((unused)) void *data)
6035 {
6036 	struct cmd_set_bond_mac_addr_result *res = parsed_result;
6037 	int ret;
6038 
6039 	if (port_id_is_invalid(res->port_num, ENABLED_WARN))
6040 		return;
6041 
6042 	ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
6043 
6044 	/* check the return value and print it if is < 0 */
6045 	if (ret < 0)
6046 		printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6047 }
6048 
6049 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
6050 		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
6051 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
6052 		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
6053 				"bonding");
6054 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
6055 		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
6056 				"mac_addr");
6057 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
6058 		TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
6059 				port_num, UINT16);
6060 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
6061 		TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
6062 
6063 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
6064 		.f = cmd_set_bond_mac_addr_parsed,
6065 		.data = (void *) 0,
6066 		.help_str = "set bonding mac_addr <port_id> <mac_addr>",
6067 		.tokens = {
6068 				(void *)&cmd_set_bond_mac_addr_set,
6069 				(void *)&cmd_set_bond_mac_addr_bonding,
6070 				(void *)&cmd_set_bond_mac_addr_mac,
6071 				(void *)&cmd_set_bond_mac_addr_portnum,
6072 				(void *)&cmd_set_bond_mac_addr_addr,
6073 				NULL
6074 		}
6075 };
6076 
6077 
6078 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
6079 struct cmd_set_bond_mon_period_result {
6080 	cmdline_fixed_string_t set;
6081 	cmdline_fixed_string_t bonding;
6082 	cmdline_fixed_string_t mon_period;
6083 	uint16_t port_num;
6084 	uint32_t period_ms;
6085 };
6086 
6087 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
6088 		__attribute__((unused))  struct cmdline *cl,
6089 		__attribute__((unused)) void *data)
6090 {
6091 	struct cmd_set_bond_mon_period_result *res = parsed_result;
6092 	int ret;
6093 
6094 	ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
6095 
6096 	/* check the return value and print it if is < 0 */
6097 	if (ret < 0)
6098 		printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6099 }
6100 
6101 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
6102 		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6103 				set, "set");
6104 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
6105 		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6106 				bonding, "bonding");
6107 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
6108 		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6109 				mon_period,	"mon_period");
6110 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
6111 		TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6112 				port_num, UINT16);
6113 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
6114 		TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6115 				period_ms, UINT32);
6116 
6117 cmdline_parse_inst_t cmd_set_bond_mon_period = {
6118 		.f = cmd_set_bond_mon_period_parsed,
6119 		.data = (void *) 0,
6120 		.help_str = "set bonding mon_period <port_id> <period_ms>",
6121 		.tokens = {
6122 				(void *)&cmd_set_bond_mon_period_set,
6123 				(void *)&cmd_set_bond_mon_period_bonding,
6124 				(void *)&cmd_set_bond_mon_period_mon_period,
6125 				(void *)&cmd_set_bond_mon_period_portnum,
6126 				(void *)&cmd_set_bond_mon_period_period_ms,
6127 				NULL
6128 		}
6129 };
6130 
6131 
6132 
6133 struct cmd_set_bonding_agg_mode_policy_result {
6134 	cmdline_fixed_string_t set;
6135 	cmdline_fixed_string_t bonding;
6136 	cmdline_fixed_string_t agg_mode;
6137 	uint16_t port_num;
6138 	cmdline_fixed_string_t policy;
6139 };
6140 
6141 
6142 static void
6143 cmd_set_bonding_agg_mode(void *parsed_result,
6144 		__attribute__((unused)) struct cmdline *cl,
6145 		__attribute__((unused)) void *data)
6146 {
6147 	struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
6148 	uint8_t policy = AGG_BANDWIDTH;
6149 
6150 	if (!strcmp(res->policy, "bandwidth"))
6151 		policy = AGG_BANDWIDTH;
6152 	else if (!strcmp(res->policy, "stable"))
6153 		policy = AGG_STABLE;
6154 	else if (!strcmp(res->policy, "count"))
6155 		policy = AGG_COUNT;
6156 
6157 	rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
6158 }
6159 
6160 
6161 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
6162 	TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6163 				set, "set");
6164 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
6165 	TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6166 				bonding, "bonding");
6167 
6168 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
6169 	TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6170 				agg_mode, "agg_mode");
6171 
6172 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
6173 	TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6174 				port_num, UINT16);
6175 
6176 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6177 	TOKEN_STRING_INITIALIZER(
6178 			struct cmd_set_bonding_balance_xmit_policy_result,
6179 		policy, "stable#bandwidth#count");
6180 
6181 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6182 	.f = cmd_set_bonding_agg_mode,
6183 	.data = (void *) 0,
6184 	.help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6185 	.tokens = {
6186 			(void *)&cmd_set_bonding_agg_mode_set,
6187 			(void *)&cmd_set_bonding_agg_mode_bonding,
6188 			(void *)&cmd_set_bonding_agg_mode_agg_mode,
6189 			(void *)&cmd_set_bonding_agg_mode_portnum,
6190 			(void *)&cmd_set_bonding_agg_mode_policy_string,
6191 			NULL
6192 		}
6193 };
6194 
6195 
6196 #endif /* RTE_LIBRTE_PMD_BOND */
6197 
6198 /* *** SET FORWARDING MODE *** */
6199 struct cmd_set_fwd_mode_result {
6200 	cmdline_fixed_string_t set;
6201 	cmdline_fixed_string_t fwd;
6202 	cmdline_fixed_string_t mode;
6203 };
6204 
6205 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6206 				    __attribute__((unused)) struct cmdline *cl,
6207 				    __attribute__((unused)) void *data)
6208 {
6209 	struct cmd_set_fwd_mode_result *res = parsed_result;
6210 
6211 	retry_enabled = 0;
6212 	set_pkt_forwarding_mode(res->mode);
6213 }
6214 
6215 cmdline_parse_token_string_t cmd_setfwd_set =
6216 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6217 cmdline_parse_token_string_t cmd_setfwd_fwd =
6218 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6219 cmdline_parse_token_string_t cmd_setfwd_mode =
6220 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6221 		"" /* defined at init */);
6222 
6223 cmdline_parse_inst_t cmd_set_fwd_mode = {
6224 	.f = cmd_set_fwd_mode_parsed,
6225 	.data = NULL,
6226 	.help_str = NULL, /* defined at init */
6227 	.tokens = {
6228 		(void *)&cmd_setfwd_set,
6229 		(void *)&cmd_setfwd_fwd,
6230 		(void *)&cmd_setfwd_mode,
6231 		NULL,
6232 	},
6233 };
6234 
6235 static void cmd_set_fwd_mode_init(void)
6236 {
6237 	char *modes, *c;
6238 	static char token[128];
6239 	static char help[256];
6240 	cmdline_parse_token_string_t *token_struct;
6241 
6242 	modes = list_pkt_forwarding_modes();
6243 	snprintf(help, sizeof(help), "set fwd %s: "
6244 		"Set packet forwarding mode", modes);
6245 	cmd_set_fwd_mode.help_str = help;
6246 
6247 	/* string token separator is # */
6248 	for (c = token; *modes != '\0'; modes++)
6249 		if (*modes == '|')
6250 			*c++ = '#';
6251 		else
6252 			*c++ = *modes;
6253 	token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6254 	token_struct->string_data.str = token;
6255 }
6256 
6257 /* *** SET RETRY FORWARDING MODE *** */
6258 struct cmd_set_fwd_retry_mode_result {
6259 	cmdline_fixed_string_t set;
6260 	cmdline_fixed_string_t fwd;
6261 	cmdline_fixed_string_t mode;
6262 	cmdline_fixed_string_t retry;
6263 };
6264 
6265 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6266 			    __attribute__((unused)) struct cmdline *cl,
6267 			    __attribute__((unused)) void *data)
6268 {
6269 	struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6270 
6271 	retry_enabled = 1;
6272 	set_pkt_forwarding_mode(res->mode);
6273 }
6274 
6275 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6276 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6277 			set, "set");
6278 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6279 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6280 			fwd, "fwd");
6281 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6282 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6283 			mode,
6284 		"" /* defined at init */);
6285 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6286 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6287 			retry, "retry");
6288 
6289 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6290 	.f = cmd_set_fwd_retry_mode_parsed,
6291 	.data = NULL,
6292 	.help_str = NULL, /* defined at init */
6293 	.tokens = {
6294 		(void *)&cmd_setfwd_retry_set,
6295 		(void *)&cmd_setfwd_retry_fwd,
6296 		(void *)&cmd_setfwd_retry_mode,
6297 		(void *)&cmd_setfwd_retry_retry,
6298 		NULL,
6299 	},
6300 };
6301 
6302 static void cmd_set_fwd_retry_mode_init(void)
6303 {
6304 	char *modes, *c;
6305 	static char token[128];
6306 	static char help[256];
6307 	cmdline_parse_token_string_t *token_struct;
6308 
6309 	modes = list_pkt_forwarding_retry_modes();
6310 	snprintf(help, sizeof(help), "set fwd %s retry: "
6311 		"Set packet forwarding mode with retry", modes);
6312 	cmd_set_fwd_retry_mode.help_str = help;
6313 
6314 	/* string token separator is # */
6315 	for (c = token; *modes != '\0'; modes++)
6316 		if (*modes == '|')
6317 			*c++ = '#';
6318 		else
6319 			*c++ = *modes;
6320 	token_struct = (cmdline_parse_token_string_t *)
6321 		cmd_set_fwd_retry_mode.tokens[2];
6322 	token_struct->string_data.str = token;
6323 }
6324 
6325 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6326 struct cmd_set_burst_tx_retry_result {
6327 	cmdline_fixed_string_t set;
6328 	cmdline_fixed_string_t burst;
6329 	cmdline_fixed_string_t tx;
6330 	cmdline_fixed_string_t delay;
6331 	uint32_t time;
6332 	cmdline_fixed_string_t retry;
6333 	uint32_t retry_num;
6334 };
6335 
6336 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6337 					__attribute__((unused)) struct cmdline *cl,
6338 					__attribute__((unused)) void *data)
6339 {
6340 	struct cmd_set_burst_tx_retry_result *res = parsed_result;
6341 
6342 	if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6343 		&& !strcmp(res->tx, "tx")) {
6344 		if (!strcmp(res->delay, "delay"))
6345 			burst_tx_delay_time = res->time;
6346 		if (!strcmp(res->retry, "retry"))
6347 			burst_tx_retry_num = res->retry_num;
6348 	}
6349 
6350 }
6351 
6352 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6353 	TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6354 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6355 	TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6356 				 "burst");
6357 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6358 	TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6359 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6360 	TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6361 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6362 	TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
6363 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6364 	TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6365 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6366 	TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
6367 
6368 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6369 	.f = cmd_set_burst_tx_retry_parsed,
6370 	.help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6371 	.tokens = {
6372 		(void *)&cmd_set_burst_tx_retry_set,
6373 		(void *)&cmd_set_burst_tx_retry_burst,
6374 		(void *)&cmd_set_burst_tx_retry_tx,
6375 		(void *)&cmd_set_burst_tx_retry_delay,
6376 		(void *)&cmd_set_burst_tx_retry_time,
6377 		(void *)&cmd_set_burst_tx_retry_retry,
6378 		(void *)&cmd_set_burst_tx_retry_retry_num,
6379 		NULL,
6380 	},
6381 };
6382 
6383 /* *** SET PROMISC MODE *** */
6384 struct cmd_set_promisc_mode_result {
6385 	cmdline_fixed_string_t set;
6386 	cmdline_fixed_string_t promisc;
6387 	cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6388 	uint16_t port_num;               /* valid if "allports" argument == 0 */
6389 	cmdline_fixed_string_t mode;
6390 };
6391 
6392 static void cmd_set_promisc_mode_parsed(void *parsed_result,
6393 					__attribute__((unused)) struct cmdline *cl,
6394 					void *allports)
6395 {
6396 	struct cmd_set_promisc_mode_result *res = parsed_result;
6397 	int enable;
6398 	portid_t i;
6399 
6400 	if (!strcmp(res->mode, "on"))
6401 		enable = 1;
6402 	else
6403 		enable = 0;
6404 
6405 	/* all ports */
6406 	if (allports) {
6407 		RTE_ETH_FOREACH_DEV(i) {
6408 			if (enable)
6409 				rte_eth_promiscuous_enable(i);
6410 			else
6411 				rte_eth_promiscuous_disable(i);
6412 		}
6413 	}
6414 	else {
6415 		if (enable)
6416 			rte_eth_promiscuous_enable(res->port_num);
6417 		else
6418 			rte_eth_promiscuous_disable(res->port_num);
6419 	}
6420 }
6421 
6422 cmdline_parse_token_string_t cmd_setpromisc_set =
6423 	TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6424 cmdline_parse_token_string_t cmd_setpromisc_promisc =
6425 	TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6426 				 "promisc");
6427 cmdline_parse_token_string_t cmd_setpromisc_portall =
6428 	TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6429 				 "all");
6430 cmdline_parse_token_num_t cmd_setpromisc_portnum =
6431 	TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6432 			      UINT16);
6433 cmdline_parse_token_string_t cmd_setpromisc_mode =
6434 	TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6435 				 "on#off");
6436 
6437 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6438 	.f = cmd_set_promisc_mode_parsed,
6439 	.data = (void *)1,
6440 	.help_str = "set promisc all on|off: Set promisc mode for all ports",
6441 	.tokens = {
6442 		(void *)&cmd_setpromisc_set,
6443 		(void *)&cmd_setpromisc_promisc,
6444 		(void *)&cmd_setpromisc_portall,
6445 		(void *)&cmd_setpromisc_mode,
6446 		NULL,
6447 	},
6448 };
6449 
6450 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6451 	.f = cmd_set_promisc_mode_parsed,
6452 	.data = (void *)0,
6453 	.help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6454 	.tokens = {
6455 		(void *)&cmd_setpromisc_set,
6456 		(void *)&cmd_setpromisc_promisc,
6457 		(void *)&cmd_setpromisc_portnum,
6458 		(void *)&cmd_setpromisc_mode,
6459 		NULL,
6460 	},
6461 };
6462 
6463 /* *** SET ALLMULTI MODE *** */
6464 struct cmd_set_allmulti_mode_result {
6465 	cmdline_fixed_string_t set;
6466 	cmdline_fixed_string_t allmulti;
6467 	cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6468 	uint16_t port_num;               /* valid if "allports" argument == 0 */
6469 	cmdline_fixed_string_t mode;
6470 };
6471 
6472 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6473 					__attribute__((unused)) struct cmdline *cl,
6474 					void *allports)
6475 {
6476 	struct cmd_set_allmulti_mode_result *res = parsed_result;
6477 	int enable;
6478 	portid_t i;
6479 
6480 	if (!strcmp(res->mode, "on"))
6481 		enable = 1;
6482 	else
6483 		enable = 0;
6484 
6485 	/* all ports */
6486 	if (allports) {
6487 		RTE_ETH_FOREACH_DEV(i) {
6488 			if (enable)
6489 				rte_eth_allmulticast_enable(i);
6490 			else
6491 				rte_eth_allmulticast_disable(i);
6492 		}
6493 	}
6494 	else {
6495 		if (enable)
6496 			rte_eth_allmulticast_enable(res->port_num);
6497 		else
6498 			rte_eth_allmulticast_disable(res->port_num);
6499 	}
6500 }
6501 
6502 cmdline_parse_token_string_t cmd_setallmulti_set =
6503 	TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6504 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6505 	TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6506 				 "allmulti");
6507 cmdline_parse_token_string_t cmd_setallmulti_portall =
6508 	TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6509 				 "all");
6510 cmdline_parse_token_num_t cmd_setallmulti_portnum =
6511 	TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6512 			      UINT16);
6513 cmdline_parse_token_string_t cmd_setallmulti_mode =
6514 	TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6515 				 "on#off");
6516 
6517 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6518 	.f = cmd_set_allmulti_mode_parsed,
6519 	.data = (void *)1,
6520 	.help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6521 	.tokens = {
6522 		(void *)&cmd_setallmulti_set,
6523 		(void *)&cmd_setallmulti_allmulti,
6524 		(void *)&cmd_setallmulti_portall,
6525 		(void *)&cmd_setallmulti_mode,
6526 		NULL,
6527 	},
6528 };
6529 
6530 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6531 	.f = cmd_set_allmulti_mode_parsed,
6532 	.data = (void *)0,
6533 	.help_str = "set allmulti <port_id> on|off: "
6534 		"Set allmulti mode on port_id",
6535 	.tokens = {
6536 		(void *)&cmd_setallmulti_set,
6537 		(void *)&cmd_setallmulti_allmulti,
6538 		(void *)&cmd_setallmulti_portnum,
6539 		(void *)&cmd_setallmulti_mode,
6540 		NULL,
6541 	},
6542 };
6543 
6544 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
6545 struct cmd_link_flow_ctrl_set_result {
6546 	cmdline_fixed_string_t set;
6547 	cmdline_fixed_string_t flow_ctrl;
6548 	cmdline_fixed_string_t rx;
6549 	cmdline_fixed_string_t rx_lfc_mode;
6550 	cmdline_fixed_string_t tx;
6551 	cmdline_fixed_string_t tx_lfc_mode;
6552 	cmdline_fixed_string_t mac_ctrl_frame_fwd;
6553 	cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
6554 	cmdline_fixed_string_t autoneg_str;
6555 	cmdline_fixed_string_t autoneg;
6556 	cmdline_fixed_string_t hw_str;
6557 	uint32_t high_water;
6558 	cmdline_fixed_string_t lw_str;
6559 	uint32_t low_water;
6560 	cmdline_fixed_string_t pt_str;
6561 	uint16_t pause_time;
6562 	cmdline_fixed_string_t xon_str;
6563 	uint16_t send_xon;
6564 	portid_t port_id;
6565 };
6566 
6567 cmdline_parse_token_string_t cmd_lfc_set_set =
6568 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6569 				set, "set");
6570 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
6571 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6572 				flow_ctrl, "flow_ctrl");
6573 cmdline_parse_token_string_t cmd_lfc_set_rx =
6574 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6575 				rx, "rx");
6576 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
6577 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6578 				rx_lfc_mode, "on#off");
6579 cmdline_parse_token_string_t cmd_lfc_set_tx =
6580 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6581 				tx, "tx");
6582 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
6583 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6584 				tx_lfc_mode, "on#off");
6585 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
6586 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6587 				hw_str, "high_water");
6588 cmdline_parse_token_num_t cmd_lfc_set_high_water =
6589 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6590 				high_water, UINT32);
6591 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
6592 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6593 				lw_str, "low_water");
6594 cmdline_parse_token_num_t cmd_lfc_set_low_water =
6595 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6596 				low_water, UINT32);
6597 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
6598 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6599 				pt_str, "pause_time");
6600 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
6601 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6602 				pause_time, UINT16);
6603 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
6604 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6605 				xon_str, "send_xon");
6606 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
6607 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6608 				send_xon, UINT16);
6609 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
6610 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6611 				mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
6612 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6613 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6614 				mac_ctrl_frame_fwd_mode, "on#off");
6615 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6616 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6617 				autoneg_str, "autoneg");
6618 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6619 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6620 				autoneg, "on#off");
6621 cmdline_parse_token_num_t cmd_lfc_set_portid =
6622 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6623 				port_id, UINT16);
6624 
6625 /* forward declaration */
6626 static void
6627 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6628 			      void *data);
6629 
6630 cmdline_parse_inst_t cmd_link_flow_control_set = {
6631 	.f = cmd_link_flow_ctrl_set_parsed,
6632 	.data = NULL,
6633 	.help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6634 		"<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6635 		"autoneg on|off <port_id>: Configure the Ethernet flow control",
6636 	.tokens = {
6637 		(void *)&cmd_lfc_set_set,
6638 		(void *)&cmd_lfc_set_flow_ctrl,
6639 		(void *)&cmd_lfc_set_rx,
6640 		(void *)&cmd_lfc_set_rx_mode,
6641 		(void *)&cmd_lfc_set_tx,
6642 		(void *)&cmd_lfc_set_tx_mode,
6643 		(void *)&cmd_lfc_set_high_water,
6644 		(void *)&cmd_lfc_set_low_water,
6645 		(void *)&cmd_lfc_set_pause_time,
6646 		(void *)&cmd_lfc_set_send_xon,
6647 		(void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6648 		(void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6649 		(void *)&cmd_lfc_set_autoneg_str,
6650 		(void *)&cmd_lfc_set_autoneg,
6651 		(void *)&cmd_lfc_set_portid,
6652 		NULL,
6653 	},
6654 };
6655 
6656 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6657 	.f = cmd_link_flow_ctrl_set_parsed,
6658 	.data = (void *)&cmd_link_flow_control_set_rx,
6659 	.help_str = "set flow_ctrl rx on|off <port_id>: "
6660 		"Change rx flow control parameter",
6661 	.tokens = {
6662 		(void *)&cmd_lfc_set_set,
6663 		(void *)&cmd_lfc_set_flow_ctrl,
6664 		(void *)&cmd_lfc_set_rx,
6665 		(void *)&cmd_lfc_set_rx_mode,
6666 		(void *)&cmd_lfc_set_portid,
6667 		NULL,
6668 	},
6669 };
6670 
6671 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6672 	.f = cmd_link_flow_ctrl_set_parsed,
6673 	.data = (void *)&cmd_link_flow_control_set_tx,
6674 	.help_str = "set flow_ctrl tx on|off <port_id>: "
6675 		"Change tx flow control parameter",
6676 	.tokens = {
6677 		(void *)&cmd_lfc_set_set,
6678 		(void *)&cmd_lfc_set_flow_ctrl,
6679 		(void *)&cmd_lfc_set_tx,
6680 		(void *)&cmd_lfc_set_tx_mode,
6681 		(void *)&cmd_lfc_set_portid,
6682 		NULL,
6683 	},
6684 };
6685 
6686 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
6687 	.f = cmd_link_flow_ctrl_set_parsed,
6688 	.data = (void *)&cmd_link_flow_control_set_hw,
6689 	.help_str = "set flow_ctrl high_water <value> <port_id>: "
6690 		"Change high water flow control parameter",
6691 	.tokens = {
6692 		(void *)&cmd_lfc_set_set,
6693 		(void *)&cmd_lfc_set_flow_ctrl,
6694 		(void *)&cmd_lfc_set_high_water_str,
6695 		(void *)&cmd_lfc_set_high_water,
6696 		(void *)&cmd_lfc_set_portid,
6697 		NULL,
6698 	},
6699 };
6700 
6701 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
6702 	.f = cmd_link_flow_ctrl_set_parsed,
6703 	.data = (void *)&cmd_link_flow_control_set_lw,
6704 	.help_str = "set flow_ctrl low_water <value> <port_id>: "
6705 		"Change low water flow control parameter",
6706 	.tokens = {
6707 		(void *)&cmd_lfc_set_set,
6708 		(void *)&cmd_lfc_set_flow_ctrl,
6709 		(void *)&cmd_lfc_set_low_water_str,
6710 		(void *)&cmd_lfc_set_low_water,
6711 		(void *)&cmd_lfc_set_portid,
6712 		NULL,
6713 	},
6714 };
6715 
6716 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
6717 	.f = cmd_link_flow_ctrl_set_parsed,
6718 	.data = (void *)&cmd_link_flow_control_set_pt,
6719 	.help_str = "set flow_ctrl pause_time <value> <port_id>: "
6720 		"Change pause time flow control parameter",
6721 	.tokens = {
6722 		(void *)&cmd_lfc_set_set,
6723 		(void *)&cmd_lfc_set_flow_ctrl,
6724 		(void *)&cmd_lfc_set_pause_time_str,
6725 		(void *)&cmd_lfc_set_pause_time,
6726 		(void *)&cmd_lfc_set_portid,
6727 		NULL,
6728 	},
6729 };
6730 
6731 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
6732 	.f = cmd_link_flow_ctrl_set_parsed,
6733 	.data = (void *)&cmd_link_flow_control_set_xon,
6734 	.help_str = "set flow_ctrl send_xon <value> <port_id>: "
6735 		"Change send_xon flow control parameter",
6736 	.tokens = {
6737 		(void *)&cmd_lfc_set_set,
6738 		(void *)&cmd_lfc_set_flow_ctrl,
6739 		(void *)&cmd_lfc_set_send_xon_str,
6740 		(void *)&cmd_lfc_set_send_xon,
6741 		(void *)&cmd_lfc_set_portid,
6742 		NULL,
6743 	},
6744 };
6745 
6746 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
6747 	.f = cmd_link_flow_ctrl_set_parsed,
6748 	.data = (void *)&cmd_link_flow_control_set_macfwd,
6749 	.help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
6750 		"Change mac ctrl fwd flow control parameter",
6751 	.tokens = {
6752 		(void *)&cmd_lfc_set_set,
6753 		(void *)&cmd_lfc_set_flow_ctrl,
6754 		(void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6755 		(void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6756 		(void *)&cmd_lfc_set_portid,
6757 		NULL,
6758 	},
6759 };
6760 
6761 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
6762 	.f = cmd_link_flow_ctrl_set_parsed,
6763 	.data = (void *)&cmd_link_flow_control_set_autoneg,
6764 	.help_str = "set flow_ctrl autoneg on|off <port_id>: "
6765 		"Change autoneg flow control parameter",
6766 	.tokens = {
6767 		(void *)&cmd_lfc_set_set,
6768 		(void *)&cmd_lfc_set_flow_ctrl,
6769 		(void *)&cmd_lfc_set_autoneg_str,
6770 		(void *)&cmd_lfc_set_autoneg,
6771 		(void *)&cmd_lfc_set_portid,
6772 		NULL,
6773 	},
6774 };
6775 
6776 static void
6777 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
6778 			      __attribute__((unused)) struct cmdline *cl,
6779 			      void *data)
6780 {
6781 	struct cmd_link_flow_ctrl_set_result *res = parsed_result;
6782 	cmdline_parse_inst_t *cmd = data;
6783 	struct rte_eth_fc_conf fc_conf;
6784 	int rx_fc_en = 0;
6785 	int tx_fc_en = 0;
6786 	int ret;
6787 
6788 	/*
6789 	 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6790 	 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6791 	 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6792 	 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6793 	 */
6794 	static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
6795 			{RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
6796 	};
6797 
6798 	/* Partial command line, retrieve current configuration */
6799 	if (cmd) {
6800 		ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
6801 		if (ret != 0) {
6802 			printf("cannot get current flow ctrl parameters, return"
6803 			       "code = %d\n", ret);
6804 			return;
6805 		}
6806 
6807 		if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
6808 		    (fc_conf.mode == RTE_FC_FULL))
6809 			rx_fc_en = 1;
6810 		if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
6811 		    (fc_conf.mode == RTE_FC_FULL))
6812 			tx_fc_en = 1;
6813 	}
6814 
6815 	if (!cmd || cmd == &cmd_link_flow_control_set_rx)
6816 		rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
6817 
6818 	if (!cmd || cmd == &cmd_link_flow_control_set_tx)
6819 		tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
6820 
6821 	fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
6822 
6823 	if (!cmd || cmd == &cmd_link_flow_control_set_hw)
6824 		fc_conf.high_water = res->high_water;
6825 
6826 	if (!cmd || cmd == &cmd_link_flow_control_set_lw)
6827 		fc_conf.low_water = res->low_water;
6828 
6829 	if (!cmd || cmd == &cmd_link_flow_control_set_pt)
6830 		fc_conf.pause_time = res->pause_time;
6831 
6832 	if (!cmd || cmd == &cmd_link_flow_control_set_xon)
6833 		fc_conf.send_xon = res->send_xon;
6834 
6835 	if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
6836 		if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
6837 			fc_conf.mac_ctrl_frame_fwd = 1;
6838 		else
6839 			fc_conf.mac_ctrl_frame_fwd = 0;
6840 	}
6841 
6842 	if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
6843 		fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
6844 
6845 	ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
6846 	if (ret != 0)
6847 		printf("bad flow contrl parameter, return code = %d \n", ret);
6848 }
6849 
6850 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
6851 struct cmd_priority_flow_ctrl_set_result {
6852 	cmdline_fixed_string_t set;
6853 	cmdline_fixed_string_t pfc_ctrl;
6854 	cmdline_fixed_string_t rx;
6855 	cmdline_fixed_string_t rx_pfc_mode;
6856 	cmdline_fixed_string_t tx;
6857 	cmdline_fixed_string_t tx_pfc_mode;
6858 	uint32_t high_water;
6859 	uint32_t low_water;
6860 	uint16_t pause_time;
6861 	uint8_t  priority;
6862 	portid_t port_id;
6863 };
6864 
6865 static void
6866 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
6867 		       __attribute__((unused)) struct cmdline *cl,
6868 		       __attribute__((unused)) void *data)
6869 {
6870 	struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
6871 	struct rte_eth_pfc_conf pfc_conf;
6872 	int rx_fc_enable, tx_fc_enable;
6873 	int ret;
6874 
6875 	/*
6876 	 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6877 	 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6878 	 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6879 	 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6880 	 */
6881 	static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
6882 			{RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
6883 	};
6884 
6885 	rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
6886 	tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
6887 	pfc_conf.fc.mode       = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
6888 	pfc_conf.fc.high_water = res->high_water;
6889 	pfc_conf.fc.low_water  = res->low_water;
6890 	pfc_conf.fc.pause_time = res->pause_time;
6891 	pfc_conf.priority      = res->priority;
6892 
6893 	ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
6894 	if (ret != 0)
6895 		printf("bad priority flow contrl parameter, return code = %d \n", ret);
6896 }
6897 
6898 cmdline_parse_token_string_t cmd_pfc_set_set =
6899 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6900 				set, "set");
6901 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
6902 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6903 				pfc_ctrl, "pfc_ctrl");
6904 cmdline_parse_token_string_t cmd_pfc_set_rx =
6905 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6906 				rx, "rx");
6907 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
6908 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6909 				rx_pfc_mode, "on#off");
6910 cmdline_parse_token_string_t cmd_pfc_set_tx =
6911 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6912 				tx, "tx");
6913 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
6914 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6915 				tx_pfc_mode, "on#off");
6916 cmdline_parse_token_num_t cmd_pfc_set_high_water =
6917 	TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6918 				high_water, UINT32);
6919 cmdline_parse_token_num_t cmd_pfc_set_low_water =
6920 	TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6921 				low_water, UINT32);
6922 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
6923 	TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6924 				pause_time, UINT16);
6925 cmdline_parse_token_num_t cmd_pfc_set_priority =
6926 	TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6927 				priority, UINT8);
6928 cmdline_parse_token_num_t cmd_pfc_set_portid =
6929 	TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6930 				port_id, UINT16);
6931 
6932 cmdline_parse_inst_t cmd_priority_flow_control_set = {
6933 	.f = cmd_priority_flow_ctrl_set_parsed,
6934 	.data = NULL,
6935 	.help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
6936 		"<pause_time> <priority> <port_id>: "
6937 		"Configure the Ethernet priority flow control",
6938 	.tokens = {
6939 		(void *)&cmd_pfc_set_set,
6940 		(void *)&cmd_pfc_set_flow_ctrl,
6941 		(void *)&cmd_pfc_set_rx,
6942 		(void *)&cmd_pfc_set_rx_mode,
6943 		(void *)&cmd_pfc_set_tx,
6944 		(void *)&cmd_pfc_set_tx_mode,
6945 		(void *)&cmd_pfc_set_high_water,
6946 		(void *)&cmd_pfc_set_low_water,
6947 		(void *)&cmd_pfc_set_pause_time,
6948 		(void *)&cmd_pfc_set_priority,
6949 		(void *)&cmd_pfc_set_portid,
6950 		NULL,
6951 	},
6952 };
6953 
6954 /* *** RESET CONFIGURATION *** */
6955 struct cmd_reset_result {
6956 	cmdline_fixed_string_t reset;
6957 	cmdline_fixed_string_t def;
6958 };
6959 
6960 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
6961 			     struct cmdline *cl,
6962 			     __attribute__((unused)) void *data)
6963 {
6964 	cmdline_printf(cl, "Reset to default forwarding configuration...\n");
6965 	set_def_fwd_config();
6966 }
6967 
6968 cmdline_parse_token_string_t cmd_reset_set =
6969 	TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
6970 cmdline_parse_token_string_t cmd_reset_def =
6971 	TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
6972 				 "default");
6973 
6974 cmdline_parse_inst_t cmd_reset = {
6975 	.f = cmd_reset_parsed,
6976 	.data = NULL,
6977 	.help_str = "set default: Reset default forwarding configuration",
6978 	.tokens = {
6979 		(void *)&cmd_reset_set,
6980 		(void *)&cmd_reset_def,
6981 		NULL,
6982 	},
6983 };
6984 
6985 /* *** START FORWARDING *** */
6986 struct cmd_start_result {
6987 	cmdline_fixed_string_t start;
6988 };
6989 
6990 cmdline_parse_token_string_t cmd_start_start =
6991 	TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
6992 
6993 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
6994 			     __attribute__((unused)) struct cmdline *cl,
6995 			     __attribute__((unused)) void *data)
6996 {
6997 	start_packet_forwarding(0);
6998 }
6999 
7000 cmdline_parse_inst_t cmd_start = {
7001 	.f = cmd_start_parsed,
7002 	.data = NULL,
7003 	.help_str = "start: Start packet forwarding",
7004 	.tokens = {
7005 		(void *)&cmd_start_start,
7006 		NULL,
7007 	},
7008 };
7009 
7010 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7011 struct cmd_start_tx_first_result {
7012 	cmdline_fixed_string_t start;
7013 	cmdline_fixed_string_t tx_first;
7014 };
7015 
7016 static void
7017 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
7018 			  __attribute__((unused)) struct cmdline *cl,
7019 			  __attribute__((unused)) void *data)
7020 {
7021 	start_packet_forwarding(1);
7022 }
7023 
7024 cmdline_parse_token_string_t cmd_start_tx_first_start =
7025 	TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7026 				 "start");
7027 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7028 	TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7029 				 tx_first, "tx_first");
7030 
7031 cmdline_parse_inst_t cmd_start_tx_first = {
7032 	.f = cmd_start_tx_first_parsed,
7033 	.data = NULL,
7034 	.help_str = "start tx_first: Start packet forwarding, "
7035 		"after sending 1 burst of packets",
7036 	.tokens = {
7037 		(void *)&cmd_start_tx_first_start,
7038 		(void *)&cmd_start_tx_first_tx_first,
7039 		NULL,
7040 	},
7041 };
7042 
7043 /* *** START FORWARDING WITH N TX BURST FIRST *** */
7044 struct cmd_start_tx_first_n_result {
7045 	cmdline_fixed_string_t start;
7046 	cmdline_fixed_string_t tx_first;
7047 	uint32_t tx_num;
7048 };
7049 
7050 static void
7051 cmd_start_tx_first_n_parsed(void *parsed_result,
7052 			  __attribute__((unused)) struct cmdline *cl,
7053 			  __attribute__((unused)) void *data)
7054 {
7055 	struct cmd_start_tx_first_n_result *res = parsed_result;
7056 
7057 	start_packet_forwarding(res->tx_num);
7058 }
7059 
7060 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7061 	TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7062 			start, "start");
7063 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7064 	TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7065 			tx_first, "tx_first");
7066 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7067 	TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7068 			tx_num, UINT32);
7069 
7070 cmdline_parse_inst_t cmd_start_tx_first_n = {
7071 	.f = cmd_start_tx_first_n_parsed,
7072 	.data = NULL,
7073 	.help_str = "start tx_first <num>: "
7074 		"packet forwarding, after sending <num> bursts of packets",
7075 	.tokens = {
7076 		(void *)&cmd_start_tx_first_n_start,
7077 		(void *)&cmd_start_tx_first_n_tx_first,
7078 		(void *)&cmd_start_tx_first_n_tx_num,
7079 		NULL,
7080 	},
7081 };
7082 
7083 /* *** SET LINK UP *** */
7084 struct cmd_set_link_up_result {
7085 	cmdline_fixed_string_t set;
7086 	cmdline_fixed_string_t link_up;
7087 	cmdline_fixed_string_t port;
7088 	portid_t port_id;
7089 };
7090 
7091 cmdline_parse_token_string_t cmd_set_link_up_set =
7092 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7093 cmdline_parse_token_string_t cmd_set_link_up_link_up =
7094 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7095 				"link-up");
7096 cmdline_parse_token_string_t cmd_set_link_up_port =
7097 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7098 cmdline_parse_token_num_t cmd_set_link_up_port_id =
7099 	TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16);
7100 
7101 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
7102 			     __attribute__((unused)) struct cmdline *cl,
7103 			     __attribute__((unused)) void *data)
7104 {
7105 	struct cmd_set_link_up_result *res = parsed_result;
7106 	dev_set_link_up(res->port_id);
7107 }
7108 
7109 cmdline_parse_inst_t cmd_set_link_up = {
7110 	.f = cmd_set_link_up_parsed,
7111 	.data = NULL,
7112 	.help_str = "set link-up port <port id>",
7113 	.tokens = {
7114 		(void *)&cmd_set_link_up_set,
7115 		(void *)&cmd_set_link_up_link_up,
7116 		(void *)&cmd_set_link_up_port,
7117 		(void *)&cmd_set_link_up_port_id,
7118 		NULL,
7119 	},
7120 };
7121 
7122 /* *** SET LINK DOWN *** */
7123 struct cmd_set_link_down_result {
7124 	cmdline_fixed_string_t set;
7125 	cmdline_fixed_string_t link_down;
7126 	cmdline_fixed_string_t port;
7127 	portid_t port_id;
7128 };
7129 
7130 cmdline_parse_token_string_t cmd_set_link_down_set =
7131 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
7132 cmdline_parse_token_string_t cmd_set_link_down_link_down =
7133 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
7134 				"link-down");
7135 cmdline_parse_token_string_t cmd_set_link_down_port =
7136 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
7137 cmdline_parse_token_num_t cmd_set_link_down_port_id =
7138 	TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16);
7139 
7140 static void cmd_set_link_down_parsed(
7141 				__attribute__((unused)) void *parsed_result,
7142 				__attribute__((unused)) struct cmdline *cl,
7143 				__attribute__((unused)) void *data)
7144 {
7145 	struct cmd_set_link_down_result *res = parsed_result;
7146 	dev_set_link_down(res->port_id);
7147 }
7148 
7149 cmdline_parse_inst_t cmd_set_link_down = {
7150 	.f = cmd_set_link_down_parsed,
7151 	.data = NULL,
7152 	.help_str = "set link-down port <port id>",
7153 	.tokens = {
7154 		(void *)&cmd_set_link_down_set,
7155 		(void *)&cmd_set_link_down_link_down,
7156 		(void *)&cmd_set_link_down_port,
7157 		(void *)&cmd_set_link_down_port_id,
7158 		NULL,
7159 	},
7160 };
7161 
7162 /* *** SHOW CFG *** */
7163 struct cmd_showcfg_result {
7164 	cmdline_fixed_string_t show;
7165 	cmdline_fixed_string_t cfg;
7166 	cmdline_fixed_string_t what;
7167 };
7168 
7169 static void cmd_showcfg_parsed(void *parsed_result,
7170 			       __attribute__((unused)) struct cmdline *cl,
7171 			       __attribute__((unused)) void *data)
7172 {
7173 	struct cmd_showcfg_result *res = parsed_result;
7174 	if (!strcmp(res->what, "rxtx"))
7175 		rxtx_config_display();
7176 	else if (!strcmp(res->what, "cores"))
7177 		fwd_lcores_config_display();
7178 	else if (!strcmp(res->what, "fwd"))
7179 		pkt_fwd_config_display(&cur_fwd_config);
7180 	else if (!strcmp(res->what, "txpkts"))
7181 		show_tx_pkt_segments();
7182 }
7183 
7184 cmdline_parse_token_string_t cmd_showcfg_show =
7185 	TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7186 cmdline_parse_token_string_t cmd_showcfg_port =
7187 	TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7188 cmdline_parse_token_string_t cmd_showcfg_what =
7189 	TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7190 				 "rxtx#cores#fwd#txpkts");
7191 
7192 cmdline_parse_inst_t cmd_showcfg = {
7193 	.f = cmd_showcfg_parsed,
7194 	.data = NULL,
7195 	.help_str = "show config rxtx|cores|fwd|txpkts",
7196 	.tokens = {
7197 		(void *)&cmd_showcfg_show,
7198 		(void *)&cmd_showcfg_port,
7199 		(void *)&cmd_showcfg_what,
7200 		NULL,
7201 	},
7202 };
7203 
7204 /* *** SHOW ALL PORT INFO *** */
7205 struct cmd_showportall_result {
7206 	cmdline_fixed_string_t show;
7207 	cmdline_fixed_string_t port;
7208 	cmdline_fixed_string_t what;
7209 	cmdline_fixed_string_t all;
7210 };
7211 
7212 static void cmd_showportall_parsed(void *parsed_result,
7213 				__attribute__((unused)) struct cmdline *cl,
7214 				__attribute__((unused)) void *data)
7215 {
7216 	portid_t i;
7217 
7218 	struct cmd_showportall_result *res = parsed_result;
7219 	if (!strcmp(res->show, "clear")) {
7220 		if (!strcmp(res->what, "stats"))
7221 			RTE_ETH_FOREACH_DEV(i)
7222 				nic_stats_clear(i);
7223 		else if (!strcmp(res->what, "xstats"))
7224 			RTE_ETH_FOREACH_DEV(i)
7225 				nic_xstats_clear(i);
7226 	} else if (!strcmp(res->what, "info"))
7227 		RTE_ETH_FOREACH_DEV(i)
7228 			port_infos_display(i);
7229 	else if (!strcmp(res->what, "summary")) {
7230 		port_summary_header_display();
7231 		RTE_ETH_FOREACH_DEV(i)
7232 			port_summary_display(i);
7233 	}
7234 	else if (!strcmp(res->what, "stats"))
7235 		RTE_ETH_FOREACH_DEV(i)
7236 			nic_stats_display(i);
7237 	else if (!strcmp(res->what, "xstats"))
7238 		RTE_ETH_FOREACH_DEV(i)
7239 			nic_xstats_display(i);
7240 	else if (!strcmp(res->what, "fdir"))
7241 		RTE_ETH_FOREACH_DEV(i)
7242 			fdir_get_infos(i);
7243 	else if (!strcmp(res->what, "stat_qmap"))
7244 		RTE_ETH_FOREACH_DEV(i)
7245 			nic_stats_mapping_display(i);
7246 	else if (!strcmp(res->what, "dcb_tc"))
7247 		RTE_ETH_FOREACH_DEV(i)
7248 			port_dcb_info_display(i);
7249 	else if (!strcmp(res->what, "cap"))
7250 		RTE_ETH_FOREACH_DEV(i)
7251 			port_offload_cap_display(i);
7252 }
7253 
7254 cmdline_parse_token_string_t cmd_showportall_show =
7255 	TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7256 				 "show#clear");
7257 cmdline_parse_token_string_t cmd_showportall_port =
7258 	TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7259 cmdline_parse_token_string_t cmd_showportall_what =
7260 	TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7261 				 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7262 cmdline_parse_token_string_t cmd_showportall_all =
7263 	TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7264 cmdline_parse_inst_t cmd_showportall = {
7265 	.f = cmd_showportall_parsed,
7266 	.data = NULL,
7267 	.help_str = "show|clear port "
7268 		"info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
7269 	.tokens = {
7270 		(void *)&cmd_showportall_show,
7271 		(void *)&cmd_showportall_port,
7272 		(void *)&cmd_showportall_what,
7273 		(void *)&cmd_showportall_all,
7274 		NULL,
7275 	},
7276 };
7277 
7278 /* *** SHOW PORT INFO *** */
7279 struct cmd_showport_result {
7280 	cmdline_fixed_string_t show;
7281 	cmdline_fixed_string_t port;
7282 	cmdline_fixed_string_t what;
7283 	uint16_t portnum;
7284 };
7285 
7286 static void cmd_showport_parsed(void *parsed_result,
7287 				__attribute__((unused)) struct cmdline *cl,
7288 				__attribute__((unused)) void *data)
7289 {
7290 	struct cmd_showport_result *res = parsed_result;
7291 	if (!strcmp(res->show, "clear")) {
7292 		if (!strcmp(res->what, "stats"))
7293 			nic_stats_clear(res->portnum);
7294 		else if (!strcmp(res->what, "xstats"))
7295 			nic_xstats_clear(res->portnum);
7296 	} else if (!strcmp(res->what, "info"))
7297 		port_infos_display(res->portnum);
7298 	else if (!strcmp(res->what, "summary")) {
7299 		port_summary_header_display();
7300 		port_summary_display(res->portnum);
7301 	}
7302 	else if (!strcmp(res->what, "stats"))
7303 		nic_stats_display(res->portnum);
7304 	else if (!strcmp(res->what, "xstats"))
7305 		nic_xstats_display(res->portnum);
7306 	else if (!strcmp(res->what, "fdir"))
7307 		 fdir_get_infos(res->portnum);
7308 	else if (!strcmp(res->what, "stat_qmap"))
7309 		nic_stats_mapping_display(res->portnum);
7310 	else if (!strcmp(res->what, "dcb_tc"))
7311 		port_dcb_info_display(res->portnum);
7312 	else if (!strcmp(res->what, "cap"))
7313 		port_offload_cap_display(res->portnum);
7314 }
7315 
7316 cmdline_parse_token_string_t cmd_showport_show =
7317 	TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7318 				 "show#clear");
7319 cmdline_parse_token_string_t cmd_showport_port =
7320 	TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7321 cmdline_parse_token_string_t cmd_showport_what =
7322 	TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7323 				 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7324 cmdline_parse_token_num_t cmd_showport_portnum =
7325 	TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
7326 
7327 cmdline_parse_inst_t cmd_showport = {
7328 	.f = cmd_showport_parsed,
7329 	.data = NULL,
7330 	.help_str = "show|clear port "
7331 		"info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
7332 		"<port_id>",
7333 	.tokens = {
7334 		(void *)&cmd_showport_show,
7335 		(void *)&cmd_showport_port,
7336 		(void *)&cmd_showport_what,
7337 		(void *)&cmd_showport_portnum,
7338 		NULL,
7339 	},
7340 };
7341 
7342 /* *** SHOW QUEUE INFO *** */
7343 struct cmd_showqueue_result {
7344 	cmdline_fixed_string_t show;
7345 	cmdline_fixed_string_t type;
7346 	cmdline_fixed_string_t what;
7347 	uint16_t portnum;
7348 	uint16_t queuenum;
7349 };
7350 
7351 static void
7352 cmd_showqueue_parsed(void *parsed_result,
7353 	__attribute__((unused)) struct cmdline *cl,
7354 	__attribute__((unused)) void *data)
7355 {
7356 	struct cmd_showqueue_result *res = parsed_result;
7357 
7358 	if (!strcmp(res->type, "rxq"))
7359 		rx_queue_infos_display(res->portnum, res->queuenum);
7360 	else if (!strcmp(res->type, "txq"))
7361 		tx_queue_infos_display(res->portnum, res->queuenum);
7362 }
7363 
7364 cmdline_parse_token_string_t cmd_showqueue_show =
7365 	TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
7366 cmdline_parse_token_string_t cmd_showqueue_type =
7367 	TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
7368 cmdline_parse_token_string_t cmd_showqueue_what =
7369 	TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
7370 cmdline_parse_token_num_t cmd_showqueue_portnum =
7371 	TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16);
7372 cmdline_parse_token_num_t cmd_showqueue_queuenum =
7373 	TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
7374 
7375 cmdline_parse_inst_t cmd_showqueue = {
7376 	.f = cmd_showqueue_parsed,
7377 	.data = NULL,
7378 	.help_str = "show rxq|txq info <port_id> <queue_id>",
7379 	.tokens = {
7380 		(void *)&cmd_showqueue_show,
7381 		(void *)&cmd_showqueue_type,
7382 		(void *)&cmd_showqueue_what,
7383 		(void *)&cmd_showqueue_portnum,
7384 		(void *)&cmd_showqueue_queuenum,
7385 		NULL,
7386 	},
7387 };
7388 
7389 /* *** READ PORT REGISTER *** */
7390 struct cmd_read_reg_result {
7391 	cmdline_fixed_string_t read;
7392 	cmdline_fixed_string_t reg;
7393 	portid_t port_id;
7394 	uint32_t reg_off;
7395 };
7396 
7397 static void
7398 cmd_read_reg_parsed(void *parsed_result,
7399 		    __attribute__((unused)) struct cmdline *cl,
7400 		    __attribute__((unused)) void *data)
7401 {
7402 	struct cmd_read_reg_result *res = parsed_result;
7403 	port_reg_display(res->port_id, res->reg_off);
7404 }
7405 
7406 cmdline_parse_token_string_t cmd_read_reg_read =
7407 	TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
7408 cmdline_parse_token_string_t cmd_read_reg_reg =
7409 	TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
7410 cmdline_parse_token_num_t cmd_read_reg_port_id =
7411 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16);
7412 cmdline_parse_token_num_t cmd_read_reg_reg_off =
7413 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
7414 
7415 cmdline_parse_inst_t cmd_read_reg = {
7416 	.f = cmd_read_reg_parsed,
7417 	.data = NULL,
7418 	.help_str = "read reg <port_id> <reg_off>",
7419 	.tokens = {
7420 		(void *)&cmd_read_reg_read,
7421 		(void *)&cmd_read_reg_reg,
7422 		(void *)&cmd_read_reg_port_id,
7423 		(void *)&cmd_read_reg_reg_off,
7424 		NULL,
7425 	},
7426 };
7427 
7428 /* *** READ PORT REGISTER BIT FIELD *** */
7429 struct cmd_read_reg_bit_field_result {
7430 	cmdline_fixed_string_t read;
7431 	cmdline_fixed_string_t regfield;
7432 	portid_t port_id;
7433 	uint32_t reg_off;
7434 	uint8_t bit1_pos;
7435 	uint8_t bit2_pos;
7436 };
7437 
7438 static void
7439 cmd_read_reg_bit_field_parsed(void *parsed_result,
7440 			      __attribute__((unused)) struct cmdline *cl,
7441 			      __attribute__((unused)) void *data)
7442 {
7443 	struct cmd_read_reg_bit_field_result *res = parsed_result;
7444 	port_reg_bit_field_display(res->port_id, res->reg_off,
7445 				   res->bit1_pos, res->bit2_pos);
7446 }
7447 
7448 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
7449 	TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
7450 				 "read");
7451 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
7452 	TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
7453 				 regfield, "regfield");
7454 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
7455 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
7456 			      UINT16);
7457 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
7458 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
7459 			      UINT32);
7460 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
7461 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
7462 			      UINT8);
7463 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
7464 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
7465 			      UINT8);
7466 
7467 cmdline_parse_inst_t cmd_read_reg_bit_field = {
7468 	.f = cmd_read_reg_bit_field_parsed,
7469 	.data = NULL,
7470 	.help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
7471 	"Read register bit field between bit_x and bit_y included",
7472 	.tokens = {
7473 		(void *)&cmd_read_reg_bit_field_read,
7474 		(void *)&cmd_read_reg_bit_field_regfield,
7475 		(void *)&cmd_read_reg_bit_field_port_id,
7476 		(void *)&cmd_read_reg_bit_field_reg_off,
7477 		(void *)&cmd_read_reg_bit_field_bit1_pos,
7478 		(void *)&cmd_read_reg_bit_field_bit2_pos,
7479 		NULL,
7480 	},
7481 };
7482 
7483 /* *** READ PORT REGISTER BIT *** */
7484 struct cmd_read_reg_bit_result {
7485 	cmdline_fixed_string_t read;
7486 	cmdline_fixed_string_t regbit;
7487 	portid_t port_id;
7488 	uint32_t reg_off;
7489 	uint8_t bit_pos;
7490 };
7491 
7492 static void
7493 cmd_read_reg_bit_parsed(void *parsed_result,
7494 			__attribute__((unused)) struct cmdline *cl,
7495 			__attribute__((unused)) void *data)
7496 {
7497 	struct cmd_read_reg_bit_result *res = parsed_result;
7498 	port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
7499 }
7500 
7501 cmdline_parse_token_string_t cmd_read_reg_bit_read =
7502 	TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
7503 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
7504 	TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
7505 				 regbit, "regbit");
7506 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
7507 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16);
7508 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
7509 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
7510 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
7511 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
7512 
7513 cmdline_parse_inst_t cmd_read_reg_bit = {
7514 	.f = cmd_read_reg_bit_parsed,
7515 	.data = NULL,
7516 	.help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
7517 	.tokens = {
7518 		(void *)&cmd_read_reg_bit_read,
7519 		(void *)&cmd_read_reg_bit_regbit,
7520 		(void *)&cmd_read_reg_bit_port_id,
7521 		(void *)&cmd_read_reg_bit_reg_off,
7522 		(void *)&cmd_read_reg_bit_bit_pos,
7523 		NULL,
7524 	},
7525 };
7526 
7527 /* *** WRITE PORT REGISTER *** */
7528 struct cmd_write_reg_result {
7529 	cmdline_fixed_string_t write;
7530 	cmdline_fixed_string_t reg;
7531 	portid_t port_id;
7532 	uint32_t reg_off;
7533 	uint32_t value;
7534 };
7535 
7536 static void
7537 cmd_write_reg_parsed(void *parsed_result,
7538 		     __attribute__((unused)) struct cmdline *cl,
7539 		     __attribute__((unused)) void *data)
7540 {
7541 	struct cmd_write_reg_result *res = parsed_result;
7542 	port_reg_set(res->port_id, res->reg_off, res->value);
7543 }
7544 
7545 cmdline_parse_token_string_t cmd_write_reg_write =
7546 	TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
7547 cmdline_parse_token_string_t cmd_write_reg_reg =
7548 	TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
7549 cmdline_parse_token_num_t cmd_write_reg_port_id =
7550 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16);
7551 cmdline_parse_token_num_t cmd_write_reg_reg_off =
7552 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
7553 cmdline_parse_token_num_t cmd_write_reg_value =
7554 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
7555 
7556 cmdline_parse_inst_t cmd_write_reg = {
7557 	.f = cmd_write_reg_parsed,
7558 	.data = NULL,
7559 	.help_str = "write reg <port_id> <reg_off> <reg_value>",
7560 	.tokens = {
7561 		(void *)&cmd_write_reg_write,
7562 		(void *)&cmd_write_reg_reg,
7563 		(void *)&cmd_write_reg_port_id,
7564 		(void *)&cmd_write_reg_reg_off,
7565 		(void *)&cmd_write_reg_value,
7566 		NULL,
7567 	},
7568 };
7569 
7570 /* *** WRITE PORT REGISTER BIT FIELD *** */
7571 struct cmd_write_reg_bit_field_result {
7572 	cmdline_fixed_string_t write;
7573 	cmdline_fixed_string_t regfield;
7574 	portid_t port_id;
7575 	uint32_t reg_off;
7576 	uint8_t bit1_pos;
7577 	uint8_t bit2_pos;
7578 	uint32_t value;
7579 };
7580 
7581 static void
7582 cmd_write_reg_bit_field_parsed(void *parsed_result,
7583 			       __attribute__((unused)) struct cmdline *cl,
7584 			       __attribute__((unused)) void *data)
7585 {
7586 	struct cmd_write_reg_bit_field_result *res = parsed_result;
7587 	port_reg_bit_field_set(res->port_id, res->reg_off,
7588 			  res->bit1_pos, res->bit2_pos, res->value);
7589 }
7590 
7591 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
7592 	TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
7593 				 "write");
7594 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
7595 	TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
7596 				 regfield, "regfield");
7597 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
7598 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
7599 			      UINT16);
7600 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
7601 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
7602 			      UINT32);
7603 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
7604 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
7605 			      UINT8);
7606 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
7607 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
7608 			      UINT8);
7609 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
7610 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
7611 			      UINT32);
7612 
7613 cmdline_parse_inst_t cmd_write_reg_bit_field = {
7614 	.f = cmd_write_reg_bit_field_parsed,
7615 	.data = NULL,
7616 	.help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
7617 		"<reg_value>: "
7618 		"Set register bit field between bit_x and bit_y included",
7619 	.tokens = {
7620 		(void *)&cmd_write_reg_bit_field_write,
7621 		(void *)&cmd_write_reg_bit_field_regfield,
7622 		(void *)&cmd_write_reg_bit_field_port_id,
7623 		(void *)&cmd_write_reg_bit_field_reg_off,
7624 		(void *)&cmd_write_reg_bit_field_bit1_pos,
7625 		(void *)&cmd_write_reg_bit_field_bit2_pos,
7626 		(void *)&cmd_write_reg_bit_field_value,
7627 		NULL,
7628 	},
7629 };
7630 
7631 /* *** WRITE PORT REGISTER BIT *** */
7632 struct cmd_write_reg_bit_result {
7633 	cmdline_fixed_string_t write;
7634 	cmdline_fixed_string_t regbit;
7635 	portid_t port_id;
7636 	uint32_t reg_off;
7637 	uint8_t bit_pos;
7638 	uint8_t value;
7639 };
7640 
7641 static void
7642 cmd_write_reg_bit_parsed(void *parsed_result,
7643 			 __attribute__((unused)) struct cmdline *cl,
7644 			 __attribute__((unused)) void *data)
7645 {
7646 	struct cmd_write_reg_bit_result *res = parsed_result;
7647 	port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
7648 }
7649 
7650 cmdline_parse_token_string_t cmd_write_reg_bit_write =
7651 	TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
7652 				 "write");
7653 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
7654 	TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
7655 				 regbit, "regbit");
7656 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
7657 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16);
7658 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
7659 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
7660 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
7661 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
7662 cmdline_parse_token_num_t cmd_write_reg_bit_value =
7663 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
7664 
7665 cmdline_parse_inst_t cmd_write_reg_bit = {
7666 	.f = cmd_write_reg_bit_parsed,
7667 	.data = NULL,
7668 	.help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
7669 		"0 <= bit_x <= 31",
7670 	.tokens = {
7671 		(void *)&cmd_write_reg_bit_write,
7672 		(void *)&cmd_write_reg_bit_regbit,
7673 		(void *)&cmd_write_reg_bit_port_id,
7674 		(void *)&cmd_write_reg_bit_reg_off,
7675 		(void *)&cmd_write_reg_bit_bit_pos,
7676 		(void *)&cmd_write_reg_bit_value,
7677 		NULL,
7678 	},
7679 };
7680 
7681 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
7682 struct cmd_read_rxd_txd_result {
7683 	cmdline_fixed_string_t read;
7684 	cmdline_fixed_string_t rxd_txd;
7685 	portid_t port_id;
7686 	uint16_t queue_id;
7687 	uint16_t desc_id;
7688 };
7689 
7690 static void
7691 cmd_read_rxd_txd_parsed(void *parsed_result,
7692 			__attribute__((unused)) struct cmdline *cl,
7693 			__attribute__((unused)) void *data)
7694 {
7695 	struct cmd_read_rxd_txd_result *res = parsed_result;
7696 
7697 	if (!strcmp(res->rxd_txd, "rxd"))
7698 		rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7699 	else if (!strcmp(res->rxd_txd, "txd"))
7700 		tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7701 }
7702 
7703 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
7704 	TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
7705 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
7706 	TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
7707 				 "rxd#txd");
7708 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
7709 	TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16);
7710 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
7711 	TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
7712 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
7713 	TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
7714 
7715 cmdline_parse_inst_t cmd_read_rxd_txd = {
7716 	.f = cmd_read_rxd_txd_parsed,
7717 	.data = NULL,
7718 	.help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
7719 	.tokens = {
7720 		(void *)&cmd_read_rxd_txd_read,
7721 		(void *)&cmd_read_rxd_txd_rxd_txd,
7722 		(void *)&cmd_read_rxd_txd_port_id,
7723 		(void *)&cmd_read_rxd_txd_queue_id,
7724 		(void *)&cmd_read_rxd_txd_desc_id,
7725 		NULL,
7726 	},
7727 };
7728 
7729 /* *** QUIT *** */
7730 struct cmd_quit_result {
7731 	cmdline_fixed_string_t quit;
7732 };
7733 
7734 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
7735 			    struct cmdline *cl,
7736 			    __attribute__((unused)) void *data)
7737 {
7738 	cmdline_quit(cl);
7739 }
7740 
7741 cmdline_parse_token_string_t cmd_quit_quit =
7742 	TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
7743 
7744 cmdline_parse_inst_t cmd_quit = {
7745 	.f = cmd_quit_parsed,
7746 	.data = NULL,
7747 	.help_str = "quit: Exit application",
7748 	.tokens = {
7749 		(void *)&cmd_quit_quit,
7750 		NULL,
7751 	},
7752 };
7753 
7754 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
7755 struct cmd_mac_addr_result {
7756 	cmdline_fixed_string_t mac_addr_cmd;
7757 	cmdline_fixed_string_t what;
7758 	uint16_t port_num;
7759 	struct ether_addr address;
7760 };
7761 
7762 static void cmd_mac_addr_parsed(void *parsed_result,
7763 		__attribute__((unused)) struct cmdline *cl,
7764 		__attribute__((unused)) void *data)
7765 {
7766 	struct cmd_mac_addr_result *res = parsed_result;
7767 	int ret;
7768 
7769 	if (strcmp(res->what, "add") == 0)
7770 		ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
7771 	else if (strcmp(res->what, "set") == 0)
7772 		ret = rte_eth_dev_default_mac_addr_set(res->port_num,
7773 						       &res->address);
7774 	else
7775 		ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
7776 
7777 	/* check the return value and print it if is < 0 */
7778 	if(ret < 0)
7779 		printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
7780 
7781 }
7782 
7783 cmdline_parse_token_string_t cmd_mac_addr_cmd =
7784 	TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
7785 				"mac_addr");
7786 cmdline_parse_token_string_t cmd_mac_addr_what =
7787 	TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
7788 				"add#remove#set");
7789 cmdline_parse_token_num_t cmd_mac_addr_portnum =
7790 		TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
7791 					UINT16);
7792 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
7793 		TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
7794 
7795 cmdline_parse_inst_t cmd_mac_addr = {
7796 	.f = cmd_mac_addr_parsed,
7797 	.data = (void *)0,
7798 	.help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
7799 			"Add/Remove/Set MAC address on port_id",
7800 	.tokens = {
7801 		(void *)&cmd_mac_addr_cmd,
7802 		(void *)&cmd_mac_addr_what,
7803 		(void *)&cmd_mac_addr_portnum,
7804 		(void *)&cmd_mac_addr_addr,
7805 		NULL,
7806 	},
7807 };
7808 
7809 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
7810 struct cmd_eth_peer_result {
7811 	cmdline_fixed_string_t set;
7812 	cmdline_fixed_string_t eth_peer;
7813 	portid_t port_id;
7814 	cmdline_fixed_string_t peer_addr;
7815 };
7816 
7817 static void cmd_set_eth_peer_parsed(void *parsed_result,
7818 			__attribute__((unused)) struct cmdline *cl,
7819 			__attribute__((unused)) void *data)
7820 {
7821 		struct cmd_eth_peer_result *res = parsed_result;
7822 
7823 		if (test_done == 0) {
7824 			printf("Please stop forwarding first\n");
7825 			return;
7826 		}
7827 		if (!strcmp(res->eth_peer, "eth-peer")) {
7828 			set_fwd_eth_peer(res->port_id, res->peer_addr);
7829 			fwd_config_setup();
7830 		}
7831 }
7832 cmdline_parse_token_string_t cmd_eth_peer_set =
7833 	TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
7834 cmdline_parse_token_string_t cmd_eth_peer =
7835 	TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
7836 cmdline_parse_token_num_t cmd_eth_peer_port_id =
7837 	TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, UINT16);
7838 cmdline_parse_token_string_t cmd_eth_peer_addr =
7839 	TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
7840 
7841 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
7842 	.f = cmd_set_eth_peer_parsed,
7843 	.data = NULL,
7844 	.help_str = "set eth-peer <port_id> <peer_mac>",
7845 	.tokens = {
7846 		(void *)&cmd_eth_peer_set,
7847 		(void *)&cmd_eth_peer,
7848 		(void *)&cmd_eth_peer_port_id,
7849 		(void *)&cmd_eth_peer_addr,
7850 		NULL,
7851 	},
7852 };
7853 
7854 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
7855 struct cmd_set_qmap_result {
7856 	cmdline_fixed_string_t set;
7857 	cmdline_fixed_string_t qmap;
7858 	cmdline_fixed_string_t what;
7859 	portid_t port_id;
7860 	uint16_t queue_id;
7861 	uint8_t map_value;
7862 };
7863 
7864 static void
7865 cmd_set_qmap_parsed(void *parsed_result,
7866 		       __attribute__((unused)) struct cmdline *cl,
7867 		       __attribute__((unused)) void *data)
7868 {
7869 	struct cmd_set_qmap_result *res = parsed_result;
7870 	int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
7871 
7872 	set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
7873 }
7874 
7875 cmdline_parse_token_string_t cmd_setqmap_set =
7876 	TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7877 				 set, "set");
7878 cmdline_parse_token_string_t cmd_setqmap_qmap =
7879 	TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7880 				 qmap, "stat_qmap");
7881 cmdline_parse_token_string_t cmd_setqmap_what =
7882 	TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7883 				 what, "tx#rx");
7884 cmdline_parse_token_num_t cmd_setqmap_portid =
7885 	TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7886 			      port_id, UINT16);
7887 cmdline_parse_token_num_t cmd_setqmap_queueid =
7888 	TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7889 			      queue_id, UINT16);
7890 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
7891 	TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7892 			      map_value, UINT8);
7893 
7894 cmdline_parse_inst_t cmd_set_qmap = {
7895 	.f = cmd_set_qmap_parsed,
7896 	.data = NULL,
7897 	.help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
7898 		"Set statistics mapping value on tx|rx queue_id of port_id",
7899 	.tokens = {
7900 		(void *)&cmd_setqmap_set,
7901 		(void *)&cmd_setqmap_qmap,
7902 		(void *)&cmd_setqmap_what,
7903 		(void *)&cmd_setqmap_portid,
7904 		(void *)&cmd_setqmap_queueid,
7905 		(void *)&cmd_setqmap_mapvalue,
7906 		NULL,
7907 	},
7908 };
7909 
7910 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS  DISPLAY *** */
7911 struct cmd_set_xstats_hide_zero_result {
7912 	cmdline_fixed_string_t keyword;
7913 	cmdline_fixed_string_t name;
7914 	cmdline_fixed_string_t on_off;
7915 };
7916 
7917 static void
7918 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
7919 			__attribute__((unused)) struct cmdline *cl,
7920 			__attribute__((unused)) void *data)
7921 {
7922 	struct cmd_set_xstats_hide_zero_result *res;
7923 	uint16_t on_off = 0;
7924 
7925 	res = parsed_result;
7926 	on_off = !strcmp(res->on_off, "on") ? 1 : 0;
7927 	set_xstats_hide_zero(on_off);
7928 }
7929 
7930 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
7931 	TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7932 				 keyword, "set");
7933 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
7934 	TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7935 				 name, "xstats-hide-zero");
7936 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
7937 	TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7938 				 on_off, "on#off");
7939 
7940 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
7941 	.f = cmd_set_xstats_hide_zero_parsed,
7942 	.data = NULL,
7943 	.help_str = "set xstats-hide-zero on|off",
7944 	.tokens = {
7945 		(void *)&cmd_set_xstats_hide_zero_keyword,
7946 		(void *)&cmd_set_xstats_hide_zero_name,
7947 		(void *)&cmd_set_xstats_hide_zero_on_off,
7948 		NULL,
7949 	},
7950 };
7951 
7952 /* *** CONFIGURE UNICAST HASH TABLE *** */
7953 struct cmd_set_uc_hash_table {
7954 	cmdline_fixed_string_t set;
7955 	cmdline_fixed_string_t port;
7956 	portid_t port_id;
7957 	cmdline_fixed_string_t what;
7958 	struct ether_addr address;
7959 	cmdline_fixed_string_t mode;
7960 };
7961 
7962 static void
7963 cmd_set_uc_hash_parsed(void *parsed_result,
7964 		       __attribute__((unused)) struct cmdline *cl,
7965 		       __attribute__((unused)) void *data)
7966 {
7967 	int ret=0;
7968 	struct cmd_set_uc_hash_table *res = parsed_result;
7969 
7970 	int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7971 
7972 	if (strcmp(res->what, "uta") == 0)
7973 		ret = rte_eth_dev_uc_hash_table_set(res->port_id,
7974 						&res->address,(uint8_t)is_on);
7975 	if (ret < 0)
7976 		printf("bad unicast hash table parameter, return code = %d \n", ret);
7977 
7978 }
7979 
7980 cmdline_parse_token_string_t cmd_set_uc_hash_set =
7981 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7982 				 set, "set");
7983 cmdline_parse_token_string_t cmd_set_uc_hash_port =
7984 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7985 				 port, "port");
7986 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
7987 	TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
7988 			      port_id, UINT16);
7989 cmdline_parse_token_string_t cmd_set_uc_hash_what =
7990 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7991 				 what, "uta");
7992 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
7993 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
7994 				address);
7995 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
7996 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7997 				 mode, "on#off");
7998 
7999 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
8000 	.f = cmd_set_uc_hash_parsed,
8001 	.data = NULL,
8002 	.help_str = "set port <port_id> uta <mac_addr> on|off)",
8003 	.tokens = {
8004 		(void *)&cmd_set_uc_hash_set,
8005 		(void *)&cmd_set_uc_hash_port,
8006 		(void *)&cmd_set_uc_hash_portid,
8007 		(void *)&cmd_set_uc_hash_what,
8008 		(void *)&cmd_set_uc_hash_mac,
8009 		(void *)&cmd_set_uc_hash_mode,
8010 		NULL,
8011 	},
8012 };
8013 
8014 struct cmd_set_uc_all_hash_table {
8015 	cmdline_fixed_string_t set;
8016 	cmdline_fixed_string_t port;
8017 	portid_t port_id;
8018 	cmdline_fixed_string_t what;
8019 	cmdline_fixed_string_t value;
8020 	cmdline_fixed_string_t mode;
8021 };
8022 
8023 static void
8024 cmd_set_uc_all_hash_parsed(void *parsed_result,
8025 		       __attribute__((unused)) struct cmdline *cl,
8026 		       __attribute__((unused)) void *data)
8027 {
8028 	int ret=0;
8029 	struct cmd_set_uc_all_hash_table *res = parsed_result;
8030 
8031 	int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8032 
8033 	if ((strcmp(res->what, "uta") == 0) &&
8034 		(strcmp(res->value, "all") == 0))
8035 		ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
8036 	if (ret < 0)
8037 		printf("bad unicast hash table parameter,"
8038 			"return code = %d \n", ret);
8039 }
8040 
8041 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
8042 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8043 				 set, "set");
8044 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
8045 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8046 				 port, "port");
8047 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
8048 	TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
8049 			      port_id, UINT16);
8050 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
8051 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8052 				 what, "uta");
8053 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
8054 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8055 				value,"all");
8056 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
8057 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8058 				 mode, "on#off");
8059 
8060 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
8061 	.f = cmd_set_uc_all_hash_parsed,
8062 	.data = NULL,
8063 	.help_str = "set port <port_id> uta all on|off",
8064 	.tokens = {
8065 		(void *)&cmd_set_uc_all_hash_set,
8066 		(void *)&cmd_set_uc_all_hash_port,
8067 		(void *)&cmd_set_uc_all_hash_portid,
8068 		(void *)&cmd_set_uc_all_hash_what,
8069 		(void *)&cmd_set_uc_all_hash_value,
8070 		(void *)&cmd_set_uc_all_hash_mode,
8071 		NULL,
8072 	},
8073 };
8074 
8075 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
8076 struct cmd_set_vf_macvlan_filter {
8077 	cmdline_fixed_string_t set;
8078 	cmdline_fixed_string_t port;
8079 	portid_t port_id;
8080 	cmdline_fixed_string_t vf;
8081 	uint8_t vf_id;
8082 	struct ether_addr address;
8083 	cmdline_fixed_string_t filter_type;
8084 	cmdline_fixed_string_t mode;
8085 };
8086 
8087 static void
8088 cmd_set_vf_macvlan_parsed(void *parsed_result,
8089 		       __attribute__((unused)) struct cmdline *cl,
8090 		       __attribute__((unused)) void *data)
8091 {
8092 	int is_on, ret = 0;
8093 	struct cmd_set_vf_macvlan_filter *res = parsed_result;
8094 	struct rte_eth_mac_filter filter;
8095 
8096 	memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
8097 
8098 	rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
8099 
8100 	/* set VF MAC filter */
8101 	filter.is_vf = 1;
8102 
8103 	/* set VF ID */
8104 	filter.dst_id = res->vf_id;
8105 
8106 	if (!strcmp(res->filter_type, "exact-mac"))
8107 		filter.filter_type = RTE_MAC_PERFECT_MATCH;
8108 	else if (!strcmp(res->filter_type, "exact-mac-vlan"))
8109 		filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
8110 	else if (!strcmp(res->filter_type, "hashmac"))
8111 		filter.filter_type = RTE_MAC_HASH_MATCH;
8112 	else if (!strcmp(res->filter_type, "hashmac-vlan"))
8113 		filter.filter_type = RTE_MACVLAN_HASH_MATCH;
8114 
8115 	is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8116 
8117 	if (is_on)
8118 		ret = rte_eth_dev_filter_ctrl(res->port_id,
8119 					RTE_ETH_FILTER_MACVLAN,
8120 					RTE_ETH_FILTER_ADD,
8121 					 &filter);
8122 	else
8123 		ret = rte_eth_dev_filter_ctrl(res->port_id,
8124 					RTE_ETH_FILTER_MACVLAN,
8125 					RTE_ETH_FILTER_DELETE,
8126 					&filter);
8127 
8128 	if (ret < 0)
8129 		printf("bad set MAC hash parameter, return code = %d\n", ret);
8130 
8131 }
8132 
8133 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
8134 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8135 				 set, "set");
8136 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
8137 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8138 				 port, "port");
8139 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
8140 	TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8141 			      port_id, UINT16);
8142 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
8143 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8144 				 vf, "vf");
8145 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
8146 	TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8147 				vf_id, UINT8);
8148 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
8149 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8150 				address);
8151 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
8152 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8153 				filter_type, "exact-mac#exact-mac-vlan"
8154 				"#hashmac#hashmac-vlan");
8155 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
8156 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8157 				 mode, "on#off");
8158 
8159 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
8160 	.f = cmd_set_vf_macvlan_parsed,
8161 	.data = NULL,
8162 	.help_str = "set port <port_id> vf <vf_id> <mac_addr> "
8163 		"exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
8164 		"Exact match rule: exact match of MAC or MAC and VLAN; "
8165 		"hash match rule: hash match of MAC and exact match of VLAN",
8166 	.tokens = {
8167 		(void *)&cmd_set_vf_macvlan_set,
8168 		(void *)&cmd_set_vf_macvlan_port,
8169 		(void *)&cmd_set_vf_macvlan_portid,
8170 		(void *)&cmd_set_vf_macvlan_vf,
8171 		(void *)&cmd_set_vf_macvlan_vf_id,
8172 		(void *)&cmd_set_vf_macvlan_mac,
8173 		(void *)&cmd_set_vf_macvlan_filter_type,
8174 		(void *)&cmd_set_vf_macvlan_mode,
8175 		NULL,
8176 	},
8177 };
8178 
8179 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
8180 struct cmd_set_vf_traffic {
8181 	cmdline_fixed_string_t set;
8182 	cmdline_fixed_string_t port;
8183 	portid_t port_id;
8184 	cmdline_fixed_string_t vf;
8185 	uint8_t vf_id;
8186 	cmdline_fixed_string_t what;
8187 	cmdline_fixed_string_t mode;
8188 };
8189 
8190 static void
8191 cmd_set_vf_traffic_parsed(void *parsed_result,
8192 		       __attribute__((unused)) struct cmdline *cl,
8193 		       __attribute__((unused)) void *data)
8194 {
8195 	struct cmd_set_vf_traffic *res = parsed_result;
8196 	int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
8197 	int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8198 
8199 	set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
8200 }
8201 
8202 cmdline_parse_token_string_t cmd_setvf_traffic_set =
8203 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8204 				 set, "set");
8205 cmdline_parse_token_string_t cmd_setvf_traffic_port =
8206 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8207 				 port, "port");
8208 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8209 	TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8210 			      port_id, UINT16);
8211 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8212 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8213 				 vf, "vf");
8214 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8215 	TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8216 			      vf_id, UINT8);
8217 cmdline_parse_token_string_t cmd_setvf_traffic_what =
8218 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8219 				 what, "tx#rx");
8220 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8221 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8222 				 mode, "on#off");
8223 
8224 cmdline_parse_inst_t cmd_set_vf_traffic = {
8225 	.f = cmd_set_vf_traffic_parsed,
8226 	.data = NULL,
8227 	.help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8228 	.tokens = {
8229 		(void *)&cmd_setvf_traffic_set,
8230 		(void *)&cmd_setvf_traffic_port,
8231 		(void *)&cmd_setvf_traffic_portid,
8232 		(void *)&cmd_setvf_traffic_vf,
8233 		(void *)&cmd_setvf_traffic_vfid,
8234 		(void *)&cmd_setvf_traffic_what,
8235 		(void *)&cmd_setvf_traffic_mode,
8236 		NULL,
8237 	},
8238 };
8239 
8240 /* *** CONFIGURE VF RECEIVE MODE *** */
8241 struct cmd_set_vf_rxmode {
8242 	cmdline_fixed_string_t set;
8243 	cmdline_fixed_string_t port;
8244 	portid_t port_id;
8245 	cmdline_fixed_string_t vf;
8246 	uint8_t vf_id;
8247 	cmdline_fixed_string_t what;
8248 	cmdline_fixed_string_t mode;
8249 	cmdline_fixed_string_t on;
8250 };
8251 
8252 static void
8253 cmd_set_vf_rxmode_parsed(void *parsed_result,
8254 		       __attribute__((unused)) struct cmdline *cl,
8255 		       __attribute__((unused)) void *data)
8256 {
8257 	int ret = -ENOTSUP;
8258 	uint16_t rx_mode = 0;
8259 	struct cmd_set_vf_rxmode *res = parsed_result;
8260 
8261 	int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8262 	if (!strcmp(res->what,"rxmode")) {
8263 		if (!strcmp(res->mode, "AUPE"))
8264 			rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
8265 		else if (!strcmp(res->mode, "ROPE"))
8266 			rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
8267 		else if (!strcmp(res->mode, "BAM"))
8268 			rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
8269 		else if (!strncmp(res->mode, "MPE",3))
8270 			rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
8271 	}
8272 
8273 	RTE_SET_USED(is_on);
8274 
8275 #ifdef RTE_LIBRTE_IXGBE_PMD
8276 	if (ret == -ENOTSUP)
8277 		ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8278 						  rx_mode, (uint8_t)is_on);
8279 #endif
8280 #ifdef RTE_LIBRTE_BNXT_PMD
8281 	if (ret == -ENOTSUP)
8282 		ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8283 						 rx_mode, (uint8_t)is_on);
8284 #endif
8285 	if (ret < 0)
8286 		printf("bad VF receive mode parameter, return code = %d \n",
8287 		ret);
8288 }
8289 
8290 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8291 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8292 				 set, "set");
8293 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8294 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8295 				 port, "port");
8296 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8297 	TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8298 			      port_id, UINT16);
8299 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8300 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8301 				 vf, "vf");
8302 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8303 	TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8304 			      vf_id, UINT8);
8305 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
8306 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8307 				 what, "rxmode");
8308 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
8309 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8310 				 mode, "AUPE#ROPE#BAM#MPE");
8311 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
8312 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8313 				 on, "on#off");
8314 
8315 cmdline_parse_inst_t cmd_set_vf_rxmode = {
8316 	.f = cmd_set_vf_rxmode_parsed,
8317 	.data = NULL,
8318 	.help_str = "set port <port_id> vf <vf_id> rxmode "
8319 		"AUPE|ROPE|BAM|MPE on|off",
8320 	.tokens = {
8321 		(void *)&cmd_set_vf_rxmode_set,
8322 		(void *)&cmd_set_vf_rxmode_port,
8323 		(void *)&cmd_set_vf_rxmode_portid,
8324 		(void *)&cmd_set_vf_rxmode_vf,
8325 		(void *)&cmd_set_vf_rxmode_vfid,
8326 		(void *)&cmd_set_vf_rxmode_what,
8327 		(void *)&cmd_set_vf_rxmode_mode,
8328 		(void *)&cmd_set_vf_rxmode_on,
8329 		NULL,
8330 	},
8331 };
8332 
8333 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
8334 struct cmd_vf_mac_addr_result {
8335 	cmdline_fixed_string_t mac_addr_cmd;
8336 	cmdline_fixed_string_t what;
8337 	cmdline_fixed_string_t port;
8338 	uint16_t port_num;
8339 	cmdline_fixed_string_t vf;
8340 	uint8_t vf_num;
8341 	struct ether_addr address;
8342 };
8343 
8344 static void cmd_vf_mac_addr_parsed(void *parsed_result,
8345 		__attribute__((unused)) struct cmdline *cl,
8346 		__attribute__((unused)) void *data)
8347 {
8348 	struct cmd_vf_mac_addr_result *res = parsed_result;
8349 	int ret = -ENOTSUP;
8350 
8351 	if (strcmp(res->what, "add") != 0)
8352 		return;
8353 
8354 #ifdef RTE_LIBRTE_I40E_PMD
8355 	if (ret == -ENOTSUP)
8356 		ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
8357 						   &res->address);
8358 #endif
8359 #ifdef RTE_LIBRTE_BNXT_PMD
8360 	if (ret == -ENOTSUP)
8361 		ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
8362 						res->vf_num);
8363 #endif
8364 
8365 	if(ret < 0)
8366 		printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
8367 
8368 }
8369 
8370 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
8371 	TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8372 				mac_addr_cmd,"mac_addr");
8373 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
8374 	TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8375 				what,"add");
8376 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
8377 	TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8378 				port,"port");
8379 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
8380 	TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8381 				port_num, UINT16);
8382 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
8383 	TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8384 				vf,"vf");
8385 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
8386 	TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8387 				vf_num, UINT8);
8388 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
8389 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
8390 				address);
8391 
8392 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
8393 	.f = cmd_vf_mac_addr_parsed,
8394 	.data = (void *)0,
8395 	.help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
8396 		"Add MAC address filtering for a VF on port_id",
8397 	.tokens = {
8398 		(void *)&cmd_vf_mac_addr_cmd,
8399 		(void *)&cmd_vf_mac_addr_what,
8400 		(void *)&cmd_vf_mac_addr_port,
8401 		(void *)&cmd_vf_mac_addr_portnum,
8402 		(void *)&cmd_vf_mac_addr_vf,
8403 		(void *)&cmd_vf_mac_addr_vfnum,
8404 		(void *)&cmd_vf_mac_addr_addr,
8405 		NULL,
8406 	},
8407 };
8408 
8409 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
8410 struct cmd_vf_rx_vlan_filter {
8411 	cmdline_fixed_string_t rx_vlan;
8412 	cmdline_fixed_string_t what;
8413 	uint16_t vlan_id;
8414 	cmdline_fixed_string_t port;
8415 	portid_t port_id;
8416 	cmdline_fixed_string_t vf;
8417 	uint64_t vf_mask;
8418 };
8419 
8420 static void
8421 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
8422 			  __attribute__((unused)) struct cmdline *cl,
8423 			  __attribute__((unused)) void *data)
8424 {
8425 	struct cmd_vf_rx_vlan_filter *res = parsed_result;
8426 	int ret = -ENOTSUP;
8427 
8428 	__rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
8429 
8430 #ifdef RTE_LIBRTE_IXGBE_PMD
8431 	if (ret == -ENOTSUP)
8432 		ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
8433 				res->vlan_id, res->vf_mask, is_add);
8434 #endif
8435 #ifdef RTE_LIBRTE_I40E_PMD
8436 	if (ret == -ENOTSUP)
8437 		ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
8438 				res->vlan_id, res->vf_mask, is_add);
8439 #endif
8440 #ifdef RTE_LIBRTE_BNXT_PMD
8441 	if (ret == -ENOTSUP)
8442 		ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
8443 				res->vlan_id, res->vf_mask, is_add);
8444 #endif
8445 
8446 	switch (ret) {
8447 	case 0:
8448 		break;
8449 	case -EINVAL:
8450 		printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
8451 				res->vlan_id, res->vf_mask);
8452 		break;
8453 	case -ENODEV:
8454 		printf("invalid port_id %d\n", res->port_id);
8455 		break;
8456 	case -ENOTSUP:
8457 		printf("function not implemented or supported\n");
8458 		break;
8459 	default:
8460 		printf("programming error: (%s)\n", strerror(-ret));
8461 	}
8462 }
8463 
8464 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
8465 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8466 				 rx_vlan, "rx_vlan");
8467 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
8468 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8469 				 what, "add#rm");
8470 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
8471 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8472 			      vlan_id, UINT16);
8473 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
8474 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8475 				 port, "port");
8476 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
8477 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8478 			      port_id, UINT16);
8479 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
8480 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8481 				 vf, "vf");
8482 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
8483 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8484 			      vf_mask, UINT64);
8485 
8486 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
8487 	.f = cmd_vf_rx_vlan_filter_parsed,
8488 	.data = NULL,
8489 	.help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
8490 		"(vf_mask = hexadecimal VF mask)",
8491 	.tokens = {
8492 		(void *)&cmd_vf_rx_vlan_filter_rx_vlan,
8493 		(void *)&cmd_vf_rx_vlan_filter_what,
8494 		(void *)&cmd_vf_rx_vlan_filter_vlanid,
8495 		(void *)&cmd_vf_rx_vlan_filter_port,
8496 		(void *)&cmd_vf_rx_vlan_filter_portid,
8497 		(void *)&cmd_vf_rx_vlan_filter_vf,
8498 		(void *)&cmd_vf_rx_vlan_filter_vf_mask,
8499 		NULL,
8500 	},
8501 };
8502 
8503 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
8504 struct cmd_queue_rate_limit_result {
8505 	cmdline_fixed_string_t set;
8506 	cmdline_fixed_string_t port;
8507 	uint16_t port_num;
8508 	cmdline_fixed_string_t queue;
8509 	uint8_t queue_num;
8510 	cmdline_fixed_string_t rate;
8511 	uint16_t rate_num;
8512 };
8513 
8514 static void cmd_queue_rate_limit_parsed(void *parsed_result,
8515 		__attribute__((unused)) struct cmdline *cl,
8516 		__attribute__((unused)) void *data)
8517 {
8518 	struct cmd_queue_rate_limit_result *res = parsed_result;
8519 	int ret = 0;
8520 
8521 	if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8522 		&& (strcmp(res->queue, "queue") == 0)
8523 		&& (strcmp(res->rate, "rate") == 0))
8524 		ret = set_queue_rate_limit(res->port_num, res->queue_num,
8525 					res->rate_num);
8526 	if (ret < 0)
8527 		printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
8528 
8529 }
8530 
8531 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
8532 	TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8533 				set, "set");
8534 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
8535 	TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8536 				port, "port");
8537 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
8538 	TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8539 				port_num, UINT16);
8540 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
8541 	TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8542 				queue, "queue");
8543 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
8544 	TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8545 				queue_num, UINT8);
8546 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
8547 	TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8548 				rate, "rate");
8549 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
8550 	TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8551 				rate_num, UINT16);
8552 
8553 cmdline_parse_inst_t cmd_queue_rate_limit = {
8554 	.f = cmd_queue_rate_limit_parsed,
8555 	.data = (void *)0,
8556 	.help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
8557 		"Set rate limit for a queue on port_id",
8558 	.tokens = {
8559 		(void *)&cmd_queue_rate_limit_set,
8560 		(void *)&cmd_queue_rate_limit_port,
8561 		(void *)&cmd_queue_rate_limit_portnum,
8562 		(void *)&cmd_queue_rate_limit_queue,
8563 		(void *)&cmd_queue_rate_limit_queuenum,
8564 		(void *)&cmd_queue_rate_limit_rate,
8565 		(void *)&cmd_queue_rate_limit_ratenum,
8566 		NULL,
8567 	},
8568 };
8569 
8570 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
8571 struct cmd_vf_rate_limit_result {
8572 	cmdline_fixed_string_t set;
8573 	cmdline_fixed_string_t port;
8574 	uint16_t port_num;
8575 	cmdline_fixed_string_t vf;
8576 	uint8_t vf_num;
8577 	cmdline_fixed_string_t rate;
8578 	uint16_t rate_num;
8579 	cmdline_fixed_string_t q_msk;
8580 	uint64_t q_msk_val;
8581 };
8582 
8583 static void cmd_vf_rate_limit_parsed(void *parsed_result,
8584 		__attribute__((unused)) struct cmdline *cl,
8585 		__attribute__((unused)) void *data)
8586 {
8587 	struct cmd_vf_rate_limit_result *res = parsed_result;
8588 	int ret = 0;
8589 
8590 	if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8591 		&& (strcmp(res->vf, "vf") == 0)
8592 		&& (strcmp(res->rate, "rate") == 0)
8593 		&& (strcmp(res->q_msk, "queue_mask") == 0))
8594 		ret = set_vf_rate_limit(res->port_num, res->vf_num,
8595 					res->rate_num, res->q_msk_val);
8596 	if (ret < 0)
8597 		printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
8598 
8599 }
8600 
8601 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
8602 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8603 				set, "set");
8604 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
8605 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8606 				port, "port");
8607 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
8608 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8609 				port_num, UINT16);
8610 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
8611 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8612 				vf, "vf");
8613 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
8614 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8615 				vf_num, UINT8);
8616 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
8617 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8618 				rate, "rate");
8619 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
8620 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8621 				rate_num, UINT16);
8622 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
8623 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8624 				q_msk, "queue_mask");
8625 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
8626 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8627 				q_msk_val, UINT64);
8628 
8629 cmdline_parse_inst_t cmd_vf_rate_limit = {
8630 	.f = cmd_vf_rate_limit_parsed,
8631 	.data = (void *)0,
8632 	.help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
8633 		"queue_mask <queue_mask_value>: "
8634 		"Set rate limit for queues of VF on port_id",
8635 	.tokens = {
8636 		(void *)&cmd_vf_rate_limit_set,
8637 		(void *)&cmd_vf_rate_limit_port,
8638 		(void *)&cmd_vf_rate_limit_portnum,
8639 		(void *)&cmd_vf_rate_limit_vf,
8640 		(void *)&cmd_vf_rate_limit_vfnum,
8641 		(void *)&cmd_vf_rate_limit_rate,
8642 		(void *)&cmd_vf_rate_limit_ratenum,
8643 		(void *)&cmd_vf_rate_limit_q_msk,
8644 		(void *)&cmd_vf_rate_limit_q_msk_val,
8645 		NULL,
8646 	},
8647 };
8648 
8649 /* *** ADD TUNNEL FILTER OF A PORT *** */
8650 struct cmd_tunnel_filter_result {
8651 	cmdline_fixed_string_t cmd;
8652 	cmdline_fixed_string_t what;
8653 	portid_t port_id;
8654 	struct ether_addr outer_mac;
8655 	struct ether_addr inner_mac;
8656 	cmdline_ipaddr_t ip_value;
8657 	uint16_t inner_vlan;
8658 	cmdline_fixed_string_t tunnel_type;
8659 	cmdline_fixed_string_t filter_type;
8660 	uint32_t tenant_id;
8661 	uint16_t queue_num;
8662 };
8663 
8664 static void
8665 cmd_tunnel_filter_parsed(void *parsed_result,
8666 			  __attribute__((unused)) struct cmdline *cl,
8667 			  __attribute__((unused)) void *data)
8668 {
8669 	struct cmd_tunnel_filter_result *res = parsed_result;
8670 	struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
8671 	int ret = 0;
8672 
8673 	memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
8674 
8675 	ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
8676 	ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
8677 	tunnel_filter_conf.inner_vlan = res->inner_vlan;
8678 
8679 	if (res->ip_value.family == AF_INET) {
8680 		tunnel_filter_conf.ip_addr.ipv4_addr =
8681 			res->ip_value.addr.ipv4.s_addr;
8682 		tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
8683 	} else {
8684 		memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
8685 			&(res->ip_value.addr.ipv6),
8686 			sizeof(struct in6_addr));
8687 		tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
8688 	}
8689 
8690 	if (!strcmp(res->filter_type, "imac-ivlan"))
8691 		tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
8692 	else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
8693 		tunnel_filter_conf.filter_type =
8694 			RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
8695 	else if (!strcmp(res->filter_type, "imac-tenid"))
8696 		tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
8697 	else if (!strcmp(res->filter_type, "imac"))
8698 		tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
8699 	else if (!strcmp(res->filter_type, "omac-imac-tenid"))
8700 		tunnel_filter_conf.filter_type =
8701 			RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
8702 	else if (!strcmp(res->filter_type, "oip"))
8703 		tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
8704 	else if (!strcmp(res->filter_type, "iip"))
8705 		tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
8706 	else {
8707 		printf("The filter type is not supported");
8708 		return;
8709 	}
8710 
8711 	if (!strcmp(res->tunnel_type, "vxlan"))
8712 		tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
8713 	else if (!strcmp(res->tunnel_type, "nvgre"))
8714 		tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
8715 	else if (!strcmp(res->tunnel_type, "ipingre"))
8716 		tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
8717 	else {
8718 		printf("The tunnel type %s not supported.\n", res->tunnel_type);
8719 		return;
8720 	}
8721 
8722 	tunnel_filter_conf.tenant_id = res->tenant_id;
8723 	tunnel_filter_conf.queue_id = res->queue_num;
8724 	if (!strcmp(res->what, "add"))
8725 		ret = rte_eth_dev_filter_ctrl(res->port_id,
8726 					RTE_ETH_FILTER_TUNNEL,
8727 					RTE_ETH_FILTER_ADD,
8728 					&tunnel_filter_conf);
8729 	else
8730 		ret = rte_eth_dev_filter_ctrl(res->port_id,
8731 					RTE_ETH_FILTER_TUNNEL,
8732 					RTE_ETH_FILTER_DELETE,
8733 					&tunnel_filter_conf);
8734 	if (ret < 0)
8735 		printf("cmd_tunnel_filter_parsed error: (%s)\n",
8736 				strerror(-ret));
8737 
8738 }
8739 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
8740 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8741 	cmd, "tunnel_filter");
8742 cmdline_parse_token_string_t cmd_tunnel_filter_what =
8743 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8744 	what, "add#rm");
8745 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
8746 	TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8747 	port_id, UINT16);
8748 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
8749 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8750 	outer_mac);
8751 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
8752 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8753 	inner_mac);
8754 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
8755 	TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8756 	inner_vlan, UINT16);
8757 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
8758 	TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8759 	ip_value);
8760 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
8761 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8762 	tunnel_type, "vxlan#nvgre#ipingre");
8763 
8764 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
8765 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8766 	filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
8767 		"imac#omac-imac-tenid");
8768 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
8769 	TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8770 	tenant_id, UINT32);
8771 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
8772 	TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8773 	queue_num, UINT16);
8774 
8775 cmdline_parse_inst_t cmd_tunnel_filter = {
8776 	.f = cmd_tunnel_filter_parsed,
8777 	.data = (void *)0,
8778 	.help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
8779 		"<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
8780 		"imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
8781 		"<queue_id>: Add/Rm tunnel filter of a port",
8782 	.tokens = {
8783 		(void *)&cmd_tunnel_filter_cmd,
8784 		(void *)&cmd_tunnel_filter_what,
8785 		(void *)&cmd_tunnel_filter_port_id,
8786 		(void *)&cmd_tunnel_filter_outer_mac,
8787 		(void *)&cmd_tunnel_filter_inner_mac,
8788 		(void *)&cmd_tunnel_filter_ip_value,
8789 		(void *)&cmd_tunnel_filter_innner_vlan,
8790 		(void *)&cmd_tunnel_filter_tunnel_type,
8791 		(void *)&cmd_tunnel_filter_filter_type,
8792 		(void *)&cmd_tunnel_filter_tenant_id,
8793 		(void *)&cmd_tunnel_filter_queue_num,
8794 		NULL,
8795 	},
8796 };
8797 
8798 /* *** CONFIGURE TUNNEL UDP PORT *** */
8799 struct cmd_tunnel_udp_config {
8800 	cmdline_fixed_string_t cmd;
8801 	cmdline_fixed_string_t what;
8802 	uint16_t udp_port;
8803 	portid_t port_id;
8804 };
8805 
8806 static void
8807 cmd_tunnel_udp_config_parsed(void *parsed_result,
8808 			  __attribute__((unused)) struct cmdline *cl,
8809 			  __attribute__((unused)) void *data)
8810 {
8811 	struct cmd_tunnel_udp_config *res = parsed_result;
8812 	struct rte_eth_udp_tunnel tunnel_udp;
8813 	int ret;
8814 
8815 	tunnel_udp.udp_port = res->udp_port;
8816 
8817 	if (!strcmp(res->cmd, "rx_vxlan_port"))
8818 		tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
8819 
8820 	if (!strcmp(res->what, "add"))
8821 		ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
8822 						      &tunnel_udp);
8823 	else
8824 		ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
8825 							 &tunnel_udp);
8826 
8827 	if (ret < 0)
8828 		printf("udp tunneling add error: (%s)\n", strerror(-ret));
8829 }
8830 
8831 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
8832 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8833 				cmd, "rx_vxlan_port");
8834 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
8835 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8836 				what, "add#rm");
8837 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
8838 	TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8839 				udp_port, UINT16);
8840 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
8841 	TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8842 				port_id, UINT16);
8843 
8844 cmdline_parse_inst_t cmd_tunnel_udp_config = {
8845 	.f = cmd_tunnel_udp_config_parsed,
8846 	.data = (void *)0,
8847 	.help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
8848 		"Add/Remove a tunneling UDP port filter",
8849 	.tokens = {
8850 		(void *)&cmd_tunnel_udp_config_cmd,
8851 		(void *)&cmd_tunnel_udp_config_what,
8852 		(void *)&cmd_tunnel_udp_config_udp_port,
8853 		(void *)&cmd_tunnel_udp_config_port_id,
8854 		NULL,
8855 	},
8856 };
8857 
8858 struct cmd_config_tunnel_udp_port {
8859 	cmdline_fixed_string_t port;
8860 	cmdline_fixed_string_t config;
8861 	portid_t port_id;
8862 	cmdline_fixed_string_t udp_tunnel_port;
8863 	cmdline_fixed_string_t action;
8864 	cmdline_fixed_string_t tunnel_type;
8865 	uint16_t udp_port;
8866 };
8867 
8868 static void
8869 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
8870 			       __attribute__((unused)) struct cmdline *cl,
8871 			       __attribute__((unused)) void *data)
8872 {
8873 	struct cmd_config_tunnel_udp_port *res = parsed_result;
8874 	struct rte_eth_udp_tunnel tunnel_udp;
8875 	int ret = 0;
8876 
8877 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8878 		return;
8879 
8880 	tunnel_udp.udp_port = res->udp_port;
8881 
8882 	if (!strcmp(res->tunnel_type, "vxlan")) {
8883 		tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
8884 	} else if (!strcmp(res->tunnel_type, "geneve")) {
8885 		tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE;
8886 	} else {
8887 		printf("Invalid tunnel type\n");
8888 		return;
8889 	}
8890 
8891 	if (!strcmp(res->action, "add"))
8892 		ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
8893 						      &tunnel_udp);
8894 	else
8895 		ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
8896 							 &tunnel_udp);
8897 
8898 	if (ret < 0)
8899 		printf("udp tunneling port add error: (%s)\n", strerror(-ret));
8900 }
8901 
8902 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
8903 	TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
8904 				 "port");
8905 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
8906 	TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
8907 				 "config");
8908 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
8909 	TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
8910 			      UINT16);
8911 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
8912 	TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
8913 				 udp_tunnel_port,
8914 				 "udp_tunnel_port");
8915 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
8916 	TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
8917 				 "add#rm");
8918 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
8919 	TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
8920 				 "vxlan#geneve");
8921 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
8922 	TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
8923 			      UINT16);
8924 
8925 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
8926 	.f = cmd_cfg_tunnel_udp_port_parsed,
8927 	.data = NULL,
8928 	.help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|geneve <udp_port>",
8929 	.tokens = {
8930 		(void *)&cmd_config_tunnel_udp_port_port,
8931 		(void *)&cmd_config_tunnel_udp_port_config,
8932 		(void *)&cmd_config_tunnel_udp_port_port_id,
8933 		(void *)&cmd_config_tunnel_udp_port_tunnel_port,
8934 		(void *)&cmd_config_tunnel_udp_port_action,
8935 		(void *)&cmd_config_tunnel_udp_port_tunnel_type,
8936 		(void *)&cmd_config_tunnel_udp_port_value,
8937 		NULL,
8938 	},
8939 };
8940 
8941 /* *** GLOBAL CONFIG *** */
8942 struct cmd_global_config_result {
8943 	cmdline_fixed_string_t cmd;
8944 	portid_t port_id;
8945 	cmdline_fixed_string_t cfg_type;
8946 	uint8_t len;
8947 };
8948 
8949 static void
8950 cmd_global_config_parsed(void *parsed_result,
8951 			 __attribute__((unused)) struct cmdline *cl,
8952 			 __attribute__((unused)) void *data)
8953 {
8954 	struct cmd_global_config_result *res = parsed_result;
8955 	struct rte_eth_global_cfg conf;
8956 	int ret;
8957 
8958 	memset(&conf, 0, sizeof(conf));
8959 	conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
8960 	conf.cfg.gre_key_len = res->len;
8961 	ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
8962 				      RTE_ETH_FILTER_SET, &conf);
8963 	if (ret != 0)
8964 		printf("Global config error\n");
8965 }
8966 
8967 cmdline_parse_token_string_t cmd_global_config_cmd =
8968 	TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
8969 		"global_config");
8970 cmdline_parse_token_num_t cmd_global_config_port_id =
8971 	TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id,
8972 			       UINT16);
8973 cmdline_parse_token_string_t cmd_global_config_type =
8974 	TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
8975 		cfg_type, "gre-key-len");
8976 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
8977 	TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
8978 		len, UINT8);
8979 
8980 cmdline_parse_inst_t cmd_global_config = {
8981 	.f = cmd_global_config_parsed,
8982 	.data = (void *)NULL,
8983 	.help_str = "global_config <port_id> gre-key-len <key_len>",
8984 	.tokens = {
8985 		(void *)&cmd_global_config_cmd,
8986 		(void *)&cmd_global_config_port_id,
8987 		(void *)&cmd_global_config_type,
8988 		(void *)&cmd_global_config_gre_key_len,
8989 		NULL,
8990 	},
8991 };
8992 
8993 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
8994 struct cmd_set_mirror_mask_result {
8995 	cmdline_fixed_string_t set;
8996 	cmdline_fixed_string_t port;
8997 	portid_t port_id;
8998 	cmdline_fixed_string_t mirror;
8999 	uint8_t rule_id;
9000 	cmdline_fixed_string_t what;
9001 	cmdline_fixed_string_t value;
9002 	cmdline_fixed_string_t dstpool;
9003 	uint8_t dstpool_id;
9004 	cmdline_fixed_string_t on;
9005 };
9006 
9007 cmdline_parse_token_string_t cmd_mirror_mask_set =
9008 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9009 				set, "set");
9010 cmdline_parse_token_string_t cmd_mirror_mask_port =
9011 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9012 				port, "port");
9013 cmdline_parse_token_num_t cmd_mirror_mask_portid =
9014 	TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9015 				port_id, UINT16);
9016 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
9017 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9018 				mirror, "mirror-rule");
9019 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
9020 	TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9021 				rule_id, UINT8);
9022 cmdline_parse_token_string_t cmd_mirror_mask_what =
9023 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9024 				what, "pool-mirror-up#pool-mirror-down"
9025 				      "#vlan-mirror");
9026 cmdline_parse_token_string_t cmd_mirror_mask_value =
9027 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9028 				value, NULL);
9029 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
9030 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9031 				dstpool, "dst-pool");
9032 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
9033 	TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9034 				dstpool_id, UINT8);
9035 cmdline_parse_token_string_t cmd_mirror_mask_on =
9036 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9037 				on, "on#off");
9038 
9039 static void
9040 cmd_set_mirror_mask_parsed(void *parsed_result,
9041 		       __attribute__((unused)) struct cmdline *cl,
9042 		       __attribute__((unused)) void *data)
9043 {
9044 	int ret,nb_item,i;
9045 	struct cmd_set_mirror_mask_result *res = parsed_result;
9046 	struct rte_eth_mirror_conf mr_conf;
9047 
9048 	memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9049 
9050 	unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
9051 
9052 	mr_conf.dst_pool = res->dstpool_id;
9053 
9054 	if (!strcmp(res->what, "pool-mirror-up")) {
9055 		mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9056 		mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
9057 	} else if (!strcmp(res->what, "pool-mirror-down")) {
9058 		mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9059 		mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
9060 	} else if (!strcmp(res->what, "vlan-mirror")) {
9061 		mr_conf.rule_type = ETH_MIRROR_VLAN;
9062 		nb_item = parse_item_list(res->value, "vlan",
9063 				ETH_MIRROR_MAX_VLANS, vlan_list, 1);
9064 		if (nb_item <= 0)
9065 			return;
9066 
9067 		for (i = 0; i < nb_item; i++) {
9068 			if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
9069 				printf("Invalid vlan_id: must be < 4096\n");
9070 				return;
9071 			}
9072 
9073 			mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
9074 			mr_conf.vlan.vlan_mask |= 1ULL << i;
9075 		}
9076 	}
9077 
9078 	if (!strcmp(res->on, "on"))
9079 		ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9080 						res->rule_id, 1);
9081 	else
9082 		ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9083 						res->rule_id, 0);
9084 	if (ret < 0)
9085 		printf("mirror rule add error: (%s)\n", strerror(-ret));
9086 }
9087 
9088 cmdline_parse_inst_t cmd_set_mirror_mask = {
9089 		.f = cmd_set_mirror_mask_parsed,
9090 		.data = NULL,
9091 		.help_str = "set port <port_id> mirror-rule <rule_id> "
9092 			"pool-mirror-up|pool-mirror-down|vlan-mirror "
9093 			"<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
9094 		.tokens = {
9095 			(void *)&cmd_mirror_mask_set,
9096 			(void *)&cmd_mirror_mask_port,
9097 			(void *)&cmd_mirror_mask_portid,
9098 			(void *)&cmd_mirror_mask_mirror,
9099 			(void *)&cmd_mirror_mask_ruleid,
9100 			(void *)&cmd_mirror_mask_what,
9101 			(void *)&cmd_mirror_mask_value,
9102 			(void *)&cmd_mirror_mask_dstpool,
9103 			(void *)&cmd_mirror_mask_poolid,
9104 			(void *)&cmd_mirror_mask_on,
9105 			NULL,
9106 		},
9107 };
9108 
9109 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
9110 struct cmd_set_mirror_link_result {
9111 	cmdline_fixed_string_t set;
9112 	cmdline_fixed_string_t port;
9113 	portid_t port_id;
9114 	cmdline_fixed_string_t mirror;
9115 	uint8_t rule_id;
9116 	cmdline_fixed_string_t what;
9117 	cmdline_fixed_string_t dstpool;
9118 	uint8_t dstpool_id;
9119 	cmdline_fixed_string_t on;
9120 };
9121 
9122 cmdline_parse_token_string_t cmd_mirror_link_set =
9123 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9124 				 set, "set");
9125 cmdline_parse_token_string_t cmd_mirror_link_port =
9126 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9127 				port, "port");
9128 cmdline_parse_token_num_t cmd_mirror_link_portid =
9129 	TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9130 				port_id, UINT16);
9131 cmdline_parse_token_string_t cmd_mirror_link_mirror =
9132 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9133 				mirror, "mirror-rule");
9134 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
9135 	TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9136 			    rule_id, UINT8);
9137 cmdline_parse_token_string_t cmd_mirror_link_what =
9138 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9139 				what, "uplink-mirror#downlink-mirror");
9140 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
9141 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9142 				dstpool, "dst-pool");
9143 cmdline_parse_token_num_t cmd_mirror_link_poolid =
9144 	TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9145 				dstpool_id, UINT8);
9146 cmdline_parse_token_string_t cmd_mirror_link_on =
9147 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9148 				on, "on#off");
9149 
9150 static void
9151 cmd_set_mirror_link_parsed(void *parsed_result,
9152 		       __attribute__((unused)) struct cmdline *cl,
9153 		       __attribute__((unused)) void *data)
9154 {
9155 	int ret;
9156 	struct cmd_set_mirror_link_result *res = parsed_result;
9157 	struct rte_eth_mirror_conf mr_conf;
9158 
9159 	memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9160 	if (!strcmp(res->what, "uplink-mirror"))
9161 		mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
9162 	else
9163 		mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
9164 
9165 	mr_conf.dst_pool = res->dstpool_id;
9166 
9167 	if (!strcmp(res->on, "on"))
9168 		ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9169 						res->rule_id, 1);
9170 	else
9171 		ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9172 						res->rule_id, 0);
9173 
9174 	/* check the return value and print it if is < 0 */
9175 	if (ret < 0)
9176 		printf("mirror rule add error: (%s)\n", strerror(-ret));
9177 
9178 }
9179 
9180 cmdline_parse_inst_t cmd_set_mirror_link = {
9181 		.f = cmd_set_mirror_link_parsed,
9182 		.data = NULL,
9183 		.help_str = "set port <port_id> mirror-rule <rule_id> "
9184 			"uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
9185 		.tokens = {
9186 			(void *)&cmd_mirror_link_set,
9187 			(void *)&cmd_mirror_link_port,
9188 			(void *)&cmd_mirror_link_portid,
9189 			(void *)&cmd_mirror_link_mirror,
9190 			(void *)&cmd_mirror_link_ruleid,
9191 			(void *)&cmd_mirror_link_what,
9192 			(void *)&cmd_mirror_link_dstpool,
9193 			(void *)&cmd_mirror_link_poolid,
9194 			(void *)&cmd_mirror_link_on,
9195 			NULL,
9196 		},
9197 };
9198 
9199 /* *** RESET VM MIRROR RULE *** */
9200 struct cmd_rm_mirror_rule_result {
9201 	cmdline_fixed_string_t reset;
9202 	cmdline_fixed_string_t port;
9203 	portid_t port_id;
9204 	cmdline_fixed_string_t mirror;
9205 	uint8_t rule_id;
9206 };
9207 
9208 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
9209 	TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9210 				 reset, "reset");
9211 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
9212 	TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9213 				port, "port");
9214 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
9215 	TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9216 				port_id, UINT16);
9217 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
9218 	TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9219 				mirror, "mirror-rule");
9220 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
9221 	TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9222 				rule_id, UINT8);
9223 
9224 static void
9225 cmd_reset_mirror_rule_parsed(void *parsed_result,
9226 		       __attribute__((unused)) struct cmdline *cl,
9227 		       __attribute__((unused)) void *data)
9228 {
9229 	int ret;
9230 	struct cmd_set_mirror_link_result *res = parsed_result;
9231         /* check rule_id */
9232 	ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
9233 	if(ret < 0)
9234 		printf("mirror rule remove error: (%s)\n", strerror(-ret));
9235 }
9236 
9237 cmdline_parse_inst_t cmd_reset_mirror_rule = {
9238 		.f = cmd_reset_mirror_rule_parsed,
9239 		.data = NULL,
9240 		.help_str = "reset port <port_id> mirror-rule <rule_id>",
9241 		.tokens = {
9242 			(void *)&cmd_rm_mirror_rule_reset,
9243 			(void *)&cmd_rm_mirror_rule_port,
9244 			(void *)&cmd_rm_mirror_rule_portid,
9245 			(void *)&cmd_rm_mirror_rule_mirror,
9246 			(void *)&cmd_rm_mirror_rule_ruleid,
9247 			NULL,
9248 		},
9249 };
9250 
9251 /* ******************************************************************************** */
9252 
9253 struct cmd_dump_result {
9254 	cmdline_fixed_string_t dump;
9255 };
9256 
9257 static void
9258 dump_struct_sizes(void)
9259 {
9260 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9261 	DUMP_SIZE(struct rte_mbuf);
9262 	DUMP_SIZE(struct rte_mempool);
9263 	DUMP_SIZE(struct rte_ring);
9264 #undef DUMP_SIZE
9265 }
9266 
9267 static void cmd_dump_parsed(void *parsed_result,
9268 			    __attribute__((unused)) struct cmdline *cl,
9269 			    __attribute__((unused)) void *data)
9270 {
9271 	struct cmd_dump_result *res = parsed_result;
9272 
9273 	if (!strcmp(res->dump, "dump_physmem"))
9274 		rte_dump_physmem_layout(stdout);
9275 	else if (!strcmp(res->dump, "dump_memzone"))
9276 		rte_memzone_dump(stdout);
9277 	else if (!strcmp(res->dump, "dump_struct_sizes"))
9278 		dump_struct_sizes();
9279 	else if (!strcmp(res->dump, "dump_ring"))
9280 		rte_ring_list_dump(stdout);
9281 	else if (!strcmp(res->dump, "dump_mempool"))
9282 		rte_mempool_list_dump(stdout);
9283 	else if (!strcmp(res->dump, "dump_devargs"))
9284 		rte_devargs_dump(stdout);
9285 	else if (!strcmp(res->dump, "dump_log_types"))
9286 		rte_log_dump(stdout);
9287 }
9288 
9289 cmdline_parse_token_string_t cmd_dump_dump =
9290 	TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9291 		"dump_physmem#"
9292 		"dump_memzone#"
9293 		"dump_struct_sizes#"
9294 		"dump_ring#"
9295 		"dump_mempool#"
9296 		"dump_devargs#"
9297 		"dump_log_types");
9298 
9299 cmdline_parse_inst_t cmd_dump = {
9300 	.f = cmd_dump_parsed,  /* function to call */
9301 	.data = NULL,      /* 2nd arg of func */
9302 	.help_str = "Dump status",
9303 	.tokens = {        /* token list, NULL terminated */
9304 		(void *)&cmd_dump_dump,
9305 		NULL,
9306 	},
9307 };
9308 
9309 /* ******************************************************************************** */
9310 
9311 struct cmd_dump_one_result {
9312 	cmdline_fixed_string_t dump;
9313 	cmdline_fixed_string_t name;
9314 };
9315 
9316 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9317 				__attribute__((unused)) void *data)
9318 {
9319 	struct cmd_dump_one_result *res = parsed_result;
9320 
9321 	if (!strcmp(res->dump, "dump_ring")) {
9322 		struct rte_ring *r;
9323 		r = rte_ring_lookup(res->name);
9324 		if (r == NULL) {
9325 			cmdline_printf(cl, "Cannot find ring\n");
9326 			return;
9327 		}
9328 		rte_ring_dump(stdout, r);
9329 	} else if (!strcmp(res->dump, "dump_mempool")) {
9330 		struct rte_mempool *mp;
9331 		mp = rte_mempool_lookup(res->name);
9332 		if (mp == NULL) {
9333 			cmdline_printf(cl, "Cannot find mempool\n");
9334 			return;
9335 		}
9336 		rte_mempool_dump(stdout, mp);
9337 	}
9338 }
9339 
9340 cmdline_parse_token_string_t cmd_dump_one_dump =
9341 	TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9342 				 "dump_ring#dump_mempool");
9343 
9344 cmdline_parse_token_string_t cmd_dump_one_name =
9345 	TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9346 
9347 cmdline_parse_inst_t cmd_dump_one = {
9348 	.f = cmd_dump_one_parsed,  /* function to call */
9349 	.data = NULL,      /* 2nd arg of func */
9350 	.help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9351 	.tokens = {        /* token list, NULL terminated */
9352 		(void *)&cmd_dump_one_dump,
9353 		(void *)&cmd_dump_one_name,
9354 		NULL,
9355 	},
9356 };
9357 
9358 /* *** Add/Del syn filter *** */
9359 struct cmd_syn_filter_result {
9360 	cmdline_fixed_string_t filter;
9361 	portid_t port_id;
9362 	cmdline_fixed_string_t ops;
9363 	cmdline_fixed_string_t priority;
9364 	cmdline_fixed_string_t high;
9365 	cmdline_fixed_string_t queue;
9366 	uint16_t queue_id;
9367 };
9368 
9369 static void
9370 cmd_syn_filter_parsed(void *parsed_result,
9371 			__attribute__((unused)) struct cmdline *cl,
9372 			__attribute__((unused)) void *data)
9373 {
9374 	struct cmd_syn_filter_result *res = parsed_result;
9375 	struct rte_eth_syn_filter syn_filter;
9376 	int ret = 0;
9377 
9378 	ret = rte_eth_dev_filter_supported(res->port_id,
9379 					RTE_ETH_FILTER_SYN);
9380 	if (ret < 0) {
9381 		printf("syn filter is not supported on port %u.\n",
9382 				res->port_id);
9383 		return;
9384 	}
9385 
9386 	memset(&syn_filter, 0, sizeof(syn_filter));
9387 
9388 	if (!strcmp(res->ops, "add")) {
9389 		if (!strcmp(res->high, "high"))
9390 			syn_filter.hig_pri = 1;
9391 		else
9392 			syn_filter.hig_pri = 0;
9393 
9394 		syn_filter.queue = res->queue_id;
9395 		ret = rte_eth_dev_filter_ctrl(res->port_id,
9396 						RTE_ETH_FILTER_SYN,
9397 						RTE_ETH_FILTER_ADD,
9398 						&syn_filter);
9399 	} else
9400 		ret = rte_eth_dev_filter_ctrl(res->port_id,
9401 						RTE_ETH_FILTER_SYN,
9402 						RTE_ETH_FILTER_DELETE,
9403 						&syn_filter);
9404 
9405 	if (ret < 0)
9406 		printf("syn filter programming error: (%s)\n",
9407 				strerror(-ret));
9408 }
9409 
9410 cmdline_parse_token_string_t cmd_syn_filter_filter =
9411 	TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9412 	filter, "syn_filter");
9413 cmdline_parse_token_num_t cmd_syn_filter_port_id =
9414 	TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9415 	port_id, UINT16);
9416 cmdline_parse_token_string_t cmd_syn_filter_ops =
9417 	TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9418 	ops, "add#del");
9419 cmdline_parse_token_string_t cmd_syn_filter_priority =
9420 	TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9421 				priority, "priority");
9422 cmdline_parse_token_string_t cmd_syn_filter_high =
9423 	TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9424 				high, "high#low");
9425 cmdline_parse_token_string_t cmd_syn_filter_queue =
9426 	TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9427 				queue, "queue");
9428 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
9429 	TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9430 				queue_id, UINT16);
9431 
9432 cmdline_parse_inst_t cmd_syn_filter = {
9433 	.f = cmd_syn_filter_parsed,
9434 	.data = NULL,
9435 	.help_str = "syn_filter <port_id> add|del priority high|low queue "
9436 		"<queue_id>: Add/Delete syn filter",
9437 	.tokens = {
9438 		(void *)&cmd_syn_filter_filter,
9439 		(void *)&cmd_syn_filter_port_id,
9440 		(void *)&cmd_syn_filter_ops,
9441 		(void *)&cmd_syn_filter_priority,
9442 		(void *)&cmd_syn_filter_high,
9443 		(void *)&cmd_syn_filter_queue,
9444 		(void *)&cmd_syn_filter_queue_id,
9445 		NULL,
9446 	},
9447 };
9448 
9449 /* *** queue region set *** */
9450 struct cmd_queue_region_result {
9451 	cmdline_fixed_string_t set;
9452 	cmdline_fixed_string_t port;
9453 	portid_t port_id;
9454 	cmdline_fixed_string_t cmd;
9455 	cmdline_fixed_string_t region;
9456 	uint8_t  region_id;
9457 	cmdline_fixed_string_t queue_start_index;
9458 	uint8_t  queue_id;
9459 	cmdline_fixed_string_t queue_num;
9460 	uint8_t  queue_num_value;
9461 };
9462 
9463 static void
9464 cmd_queue_region_parsed(void *parsed_result,
9465 			__attribute__((unused)) struct cmdline *cl,
9466 			__attribute__((unused)) void *data)
9467 {
9468 	struct cmd_queue_region_result *res = parsed_result;
9469 	int ret = -ENOTSUP;
9470 #ifdef RTE_LIBRTE_I40E_PMD
9471 	struct rte_pmd_i40e_queue_region_conf region_conf;
9472 	enum rte_pmd_i40e_queue_region_op op_type;
9473 #endif
9474 
9475 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9476 		return;
9477 
9478 #ifdef RTE_LIBRTE_I40E_PMD
9479 	memset(&region_conf, 0, sizeof(region_conf));
9480 	op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
9481 	region_conf.region_id = res->region_id;
9482 	region_conf.queue_num = res->queue_num_value;
9483 	region_conf.queue_start_index = res->queue_id;
9484 
9485 	ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9486 				op_type, &region_conf);
9487 #endif
9488 
9489 	switch (ret) {
9490 	case 0:
9491 		break;
9492 	case -ENOTSUP:
9493 		printf("function not implemented or supported\n");
9494 		break;
9495 	default:
9496 		printf("queue region config error: (%s)\n", strerror(-ret));
9497 	}
9498 }
9499 
9500 cmdline_parse_token_string_t cmd_queue_region_set =
9501 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9502 		set, "set");
9503 cmdline_parse_token_string_t cmd_queue_region_port =
9504 	TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
9505 cmdline_parse_token_num_t cmd_queue_region_port_id =
9506 	TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9507 				port_id, UINT16);
9508 cmdline_parse_token_string_t cmd_queue_region_cmd =
9509 	TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9510 				 cmd, "queue-region");
9511 cmdline_parse_token_string_t cmd_queue_region_id =
9512 	TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9513 				region, "region_id");
9514 cmdline_parse_token_num_t cmd_queue_region_index =
9515 	TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9516 				region_id, UINT8);
9517 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
9518 	TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9519 				queue_start_index, "queue_start_index");
9520 cmdline_parse_token_num_t cmd_queue_region_queue_id =
9521 	TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9522 				queue_id, UINT8);
9523 cmdline_parse_token_string_t cmd_queue_region_queue_num =
9524 	TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9525 				queue_num, "queue_num");
9526 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
9527 	TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9528 				queue_num_value, UINT8);
9529 
9530 cmdline_parse_inst_t cmd_queue_region = {
9531 	.f = cmd_queue_region_parsed,
9532 	.data = NULL,
9533 	.help_str = "set port <port_id> queue-region region_id <value> "
9534 		"queue_start_index <value> queue_num <value>: Set a queue region",
9535 	.tokens = {
9536 		(void *)&cmd_queue_region_set,
9537 		(void *)&cmd_queue_region_port,
9538 		(void *)&cmd_queue_region_port_id,
9539 		(void *)&cmd_queue_region_cmd,
9540 		(void *)&cmd_queue_region_id,
9541 		(void *)&cmd_queue_region_index,
9542 		(void *)&cmd_queue_region_queue_start_index,
9543 		(void *)&cmd_queue_region_queue_id,
9544 		(void *)&cmd_queue_region_queue_num,
9545 		(void *)&cmd_queue_region_queue_num_value,
9546 		NULL,
9547 	},
9548 };
9549 
9550 /* *** queue region and flowtype set *** */
9551 struct cmd_region_flowtype_result {
9552 	cmdline_fixed_string_t set;
9553 	cmdline_fixed_string_t port;
9554 	portid_t port_id;
9555 	cmdline_fixed_string_t cmd;
9556 	cmdline_fixed_string_t region;
9557 	uint8_t  region_id;
9558 	cmdline_fixed_string_t flowtype;
9559 	uint8_t  flowtype_id;
9560 };
9561 
9562 static void
9563 cmd_region_flowtype_parsed(void *parsed_result,
9564 			__attribute__((unused)) struct cmdline *cl,
9565 			__attribute__((unused)) void *data)
9566 {
9567 	struct cmd_region_flowtype_result *res = parsed_result;
9568 	int ret = -ENOTSUP;
9569 #ifdef RTE_LIBRTE_I40E_PMD
9570 	struct rte_pmd_i40e_queue_region_conf region_conf;
9571 	enum rte_pmd_i40e_queue_region_op op_type;
9572 #endif
9573 
9574 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9575 		return;
9576 
9577 #ifdef RTE_LIBRTE_I40E_PMD
9578 	memset(&region_conf, 0, sizeof(region_conf));
9579 
9580 	op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
9581 	region_conf.region_id = res->region_id;
9582 	region_conf.hw_flowtype = res->flowtype_id;
9583 
9584 	ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9585 			op_type, &region_conf);
9586 #endif
9587 
9588 	switch (ret) {
9589 	case 0:
9590 		break;
9591 	case -ENOTSUP:
9592 		printf("function not implemented or supported\n");
9593 		break;
9594 	default:
9595 		printf("region flowtype config error: (%s)\n", strerror(-ret));
9596 	}
9597 }
9598 
9599 cmdline_parse_token_string_t cmd_region_flowtype_set =
9600 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9601 				set, "set");
9602 cmdline_parse_token_string_t cmd_region_flowtype_port =
9603 	TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9604 				port, "port");
9605 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
9606 	TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9607 				port_id, UINT16);
9608 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
9609 	TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9610 				cmd, "queue-region");
9611 cmdline_parse_token_string_t cmd_region_flowtype_index =
9612 	TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9613 				region, "region_id");
9614 cmdline_parse_token_num_t cmd_region_flowtype_id =
9615 	TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9616 				region_id, UINT8);
9617 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
9618 	TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9619 				flowtype, "flowtype");
9620 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
9621 	TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9622 				flowtype_id, UINT8);
9623 cmdline_parse_inst_t cmd_region_flowtype = {
9624 	.f = cmd_region_flowtype_parsed,
9625 	.data = NULL,
9626 	.help_str = "set port <port_id> queue-region region_id <value> "
9627 		"flowtype <value>: Set a flowtype region index",
9628 	.tokens = {
9629 		(void *)&cmd_region_flowtype_set,
9630 		(void *)&cmd_region_flowtype_port,
9631 		(void *)&cmd_region_flowtype_port_index,
9632 		(void *)&cmd_region_flowtype_cmd,
9633 		(void *)&cmd_region_flowtype_index,
9634 		(void *)&cmd_region_flowtype_id,
9635 		(void *)&cmd_region_flowtype_flow_index,
9636 		(void *)&cmd_region_flowtype_flow_id,
9637 		NULL,
9638 	},
9639 };
9640 
9641 /* *** User Priority (UP) to queue region (region_id) set *** */
9642 struct cmd_user_priority_region_result {
9643 	cmdline_fixed_string_t set;
9644 	cmdline_fixed_string_t port;
9645 	portid_t port_id;
9646 	cmdline_fixed_string_t cmd;
9647 	cmdline_fixed_string_t user_priority;
9648 	uint8_t  user_priority_id;
9649 	cmdline_fixed_string_t region;
9650 	uint8_t  region_id;
9651 };
9652 
9653 static void
9654 cmd_user_priority_region_parsed(void *parsed_result,
9655 			__attribute__((unused)) struct cmdline *cl,
9656 			__attribute__((unused)) void *data)
9657 {
9658 	struct cmd_user_priority_region_result *res = parsed_result;
9659 	int ret = -ENOTSUP;
9660 #ifdef RTE_LIBRTE_I40E_PMD
9661 	struct rte_pmd_i40e_queue_region_conf region_conf;
9662 	enum rte_pmd_i40e_queue_region_op op_type;
9663 #endif
9664 
9665 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9666 		return;
9667 
9668 #ifdef RTE_LIBRTE_I40E_PMD
9669 	memset(&region_conf, 0, sizeof(region_conf));
9670 	op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
9671 	region_conf.user_priority = res->user_priority_id;
9672 	region_conf.region_id = res->region_id;
9673 
9674 	ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9675 				op_type, &region_conf);
9676 #endif
9677 
9678 	switch (ret) {
9679 	case 0:
9680 		break;
9681 	case -ENOTSUP:
9682 		printf("function not implemented or supported\n");
9683 		break;
9684 	default:
9685 		printf("user_priority region config error: (%s)\n",
9686 				strerror(-ret));
9687 	}
9688 }
9689 
9690 cmdline_parse_token_string_t cmd_user_priority_region_set =
9691 	TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9692 				set, "set");
9693 cmdline_parse_token_string_t cmd_user_priority_region_port =
9694 	TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9695 				port, "port");
9696 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
9697 	TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9698 				port_id, UINT16);
9699 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
9700 	TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9701 				cmd, "queue-region");
9702 cmdline_parse_token_string_t cmd_user_priority_region_UP =
9703 	TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9704 				user_priority, "UP");
9705 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
9706 	TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9707 				user_priority_id, UINT8);
9708 cmdline_parse_token_string_t cmd_user_priority_region_region =
9709 	TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9710 				region, "region_id");
9711 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
9712 	TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9713 				region_id, UINT8);
9714 
9715 cmdline_parse_inst_t cmd_user_priority_region = {
9716 	.f = cmd_user_priority_region_parsed,
9717 	.data = NULL,
9718 	.help_str = "set port <port_id> queue-region UP <value> "
9719 		"region_id <value>: Set the mapping of User Priority (UP) "
9720 		"to queue region (region_id) ",
9721 	.tokens = {
9722 		(void *)&cmd_user_priority_region_set,
9723 		(void *)&cmd_user_priority_region_port,
9724 		(void *)&cmd_user_priority_region_port_index,
9725 		(void *)&cmd_user_priority_region_cmd,
9726 		(void *)&cmd_user_priority_region_UP,
9727 		(void *)&cmd_user_priority_region_UP_id,
9728 		(void *)&cmd_user_priority_region_region,
9729 		(void *)&cmd_user_priority_region_region_id,
9730 		NULL,
9731 	},
9732 };
9733 
9734 /* *** flush all queue region related configuration *** */
9735 struct cmd_flush_queue_region_result {
9736 	cmdline_fixed_string_t set;
9737 	cmdline_fixed_string_t port;
9738 	portid_t port_id;
9739 	cmdline_fixed_string_t cmd;
9740 	cmdline_fixed_string_t flush;
9741 	cmdline_fixed_string_t what;
9742 };
9743 
9744 static void
9745 cmd_flush_queue_region_parsed(void *parsed_result,
9746 			__attribute__((unused)) struct cmdline *cl,
9747 			__attribute__((unused)) void *data)
9748 {
9749 	struct cmd_flush_queue_region_result *res = parsed_result;
9750 	int ret = -ENOTSUP;
9751 #ifdef RTE_LIBRTE_I40E_PMD
9752 	struct rte_pmd_i40e_queue_region_conf region_conf;
9753 	enum rte_pmd_i40e_queue_region_op op_type;
9754 #endif
9755 
9756 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9757 		return;
9758 
9759 #ifdef RTE_LIBRTE_I40E_PMD
9760 	memset(&region_conf, 0, sizeof(region_conf));
9761 
9762 	if (strcmp(res->what, "on") == 0)
9763 		op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
9764 	else
9765 		op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
9766 
9767 	ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9768 				op_type, &region_conf);
9769 #endif
9770 
9771 	switch (ret) {
9772 	case 0:
9773 		break;
9774 	case -ENOTSUP:
9775 		printf("function not implemented or supported\n");
9776 		break;
9777 	default:
9778 		printf("queue region config flush error: (%s)\n",
9779 				strerror(-ret));
9780 	}
9781 }
9782 
9783 cmdline_parse_token_string_t cmd_flush_queue_region_set =
9784 	TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9785 				set, "set");
9786 cmdline_parse_token_string_t cmd_flush_queue_region_port =
9787 	TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9788 				port, "port");
9789 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
9790 	TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
9791 				port_id, UINT16);
9792 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
9793 	TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9794 				cmd, "queue-region");
9795 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
9796 	TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9797 				flush, "flush");
9798 cmdline_parse_token_string_t cmd_flush_queue_region_what =
9799 	TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9800 				what, "on#off");
9801 
9802 cmdline_parse_inst_t cmd_flush_queue_region = {
9803 	.f = cmd_flush_queue_region_parsed,
9804 	.data = NULL,
9805 	.help_str = "set port <port_id> queue-region flush on|off"
9806 		": flush all queue region related configuration",
9807 	.tokens = {
9808 		(void *)&cmd_flush_queue_region_set,
9809 		(void *)&cmd_flush_queue_region_port,
9810 		(void *)&cmd_flush_queue_region_port_index,
9811 		(void *)&cmd_flush_queue_region_cmd,
9812 		(void *)&cmd_flush_queue_region_flush,
9813 		(void *)&cmd_flush_queue_region_what,
9814 		NULL,
9815 	},
9816 };
9817 
9818 /* *** get all queue region related configuration info *** */
9819 struct cmd_show_queue_region_info {
9820 	cmdline_fixed_string_t show;
9821 	cmdline_fixed_string_t port;
9822 	portid_t port_id;
9823 	cmdline_fixed_string_t cmd;
9824 };
9825 
9826 static void
9827 cmd_show_queue_region_info_parsed(void *parsed_result,
9828 			__attribute__((unused)) struct cmdline *cl,
9829 			__attribute__((unused)) void *data)
9830 {
9831 	struct cmd_show_queue_region_info *res = parsed_result;
9832 	int ret = -ENOTSUP;
9833 #ifdef RTE_LIBRTE_I40E_PMD
9834 	struct rte_pmd_i40e_queue_regions rte_pmd_regions;
9835 	enum rte_pmd_i40e_queue_region_op op_type;
9836 #endif
9837 
9838 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9839 		return;
9840 
9841 #ifdef RTE_LIBRTE_I40E_PMD
9842 	memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
9843 
9844 	op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
9845 
9846 	ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9847 					op_type, &rte_pmd_regions);
9848 
9849 	port_queue_region_info_display(res->port_id, &rte_pmd_regions);
9850 #endif
9851 
9852 	switch (ret) {
9853 	case 0:
9854 		break;
9855 	case -ENOTSUP:
9856 		printf("function not implemented or supported\n");
9857 		break;
9858 	default:
9859 		printf("queue region config info show error: (%s)\n",
9860 				strerror(-ret));
9861 	}
9862 }
9863 
9864 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
9865 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9866 				show, "show");
9867 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
9868 	TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9869 				port, "port");
9870 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
9871 	TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
9872 				port_id, UINT16);
9873 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
9874 	TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9875 				cmd, "queue-region");
9876 
9877 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
9878 	.f = cmd_show_queue_region_info_parsed,
9879 	.data = NULL,
9880 	.help_str = "show port <port_id> queue-region"
9881 		": show all queue region related configuration info",
9882 	.tokens = {
9883 		(void *)&cmd_show_queue_region_info_get,
9884 		(void *)&cmd_show_queue_region_info_port,
9885 		(void *)&cmd_show_queue_region_info_port_index,
9886 		(void *)&cmd_show_queue_region_info_cmd,
9887 		NULL,
9888 	},
9889 };
9890 
9891 /* *** ADD/REMOVE A 2tuple FILTER *** */
9892 struct cmd_2tuple_filter_result {
9893 	cmdline_fixed_string_t filter;
9894 	portid_t port_id;
9895 	cmdline_fixed_string_t ops;
9896 	cmdline_fixed_string_t dst_port;
9897 	uint16_t dst_port_value;
9898 	cmdline_fixed_string_t protocol;
9899 	uint8_t protocol_value;
9900 	cmdline_fixed_string_t mask;
9901 	uint8_t  mask_value;
9902 	cmdline_fixed_string_t tcp_flags;
9903 	uint8_t tcp_flags_value;
9904 	cmdline_fixed_string_t priority;
9905 	uint8_t  priority_value;
9906 	cmdline_fixed_string_t queue;
9907 	uint16_t  queue_id;
9908 };
9909 
9910 static void
9911 cmd_2tuple_filter_parsed(void *parsed_result,
9912 			__attribute__((unused)) struct cmdline *cl,
9913 			__attribute__((unused)) void *data)
9914 {
9915 	struct rte_eth_ntuple_filter filter;
9916 	struct cmd_2tuple_filter_result *res = parsed_result;
9917 	int ret = 0;
9918 
9919 	ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
9920 	if (ret < 0) {
9921 		printf("ntuple filter is not supported on port %u.\n",
9922 			res->port_id);
9923 		return;
9924 	}
9925 
9926 	memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
9927 
9928 	filter.flags = RTE_2TUPLE_FLAGS;
9929 	filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
9930 	filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
9931 	filter.proto = res->protocol_value;
9932 	filter.priority = res->priority_value;
9933 	if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
9934 		printf("nonzero tcp_flags is only meaningful"
9935 			" when protocol is TCP.\n");
9936 		return;
9937 	}
9938 	if (res->tcp_flags_value > TCP_FLAG_ALL) {
9939 		printf("invalid TCP flags.\n");
9940 		return;
9941 	}
9942 
9943 	if (res->tcp_flags_value != 0) {
9944 		filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
9945 		filter.tcp_flags = res->tcp_flags_value;
9946 	}
9947 
9948 	/* need convert to big endian. */
9949 	filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
9950 	filter.queue = res->queue_id;
9951 
9952 	if (!strcmp(res->ops, "add"))
9953 		ret = rte_eth_dev_filter_ctrl(res->port_id,
9954 				RTE_ETH_FILTER_NTUPLE,
9955 				RTE_ETH_FILTER_ADD,
9956 				&filter);
9957 	else
9958 		ret = rte_eth_dev_filter_ctrl(res->port_id,
9959 				RTE_ETH_FILTER_NTUPLE,
9960 				RTE_ETH_FILTER_DELETE,
9961 				&filter);
9962 	if (ret < 0)
9963 		printf("2tuple filter programming error: (%s)\n",
9964 			strerror(-ret));
9965 
9966 }
9967 
9968 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
9969 	TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9970 				 filter, "2tuple_filter");
9971 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
9972 	TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9973 				port_id, UINT16);
9974 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
9975 	TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9976 				 ops, "add#del");
9977 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
9978 	TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9979 				dst_port, "dst_port");
9980 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
9981 	TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9982 				dst_port_value, UINT16);
9983 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
9984 	TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9985 				protocol, "protocol");
9986 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
9987 	TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9988 				protocol_value, UINT8);
9989 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
9990 	TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9991 				mask, "mask");
9992 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
9993 	TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9994 				mask_value, INT8);
9995 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
9996 	TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9997 				tcp_flags, "tcp_flags");
9998 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
9999 	TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10000 				tcp_flags_value, UINT8);
10001 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
10002 	TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10003 				priority, "priority");
10004 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
10005 	TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10006 				priority_value, UINT8);
10007 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
10008 	TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10009 				queue, "queue");
10010 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
10011 	TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10012 				queue_id, UINT16);
10013 
10014 cmdline_parse_inst_t cmd_2tuple_filter = {
10015 	.f = cmd_2tuple_filter_parsed,
10016 	.data = NULL,
10017 	.help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
10018 		"<value> mask <value> tcp_flags <value> priority <value> queue "
10019 		"<queue_id>: Add a 2tuple filter",
10020 	.tokens = {
10021 		(void *)&cmd_2tuple_filter_filter,
10022 		(void *)&cmd_2tuple_filter_port_id,
10023 		(void *)&cmd_2tuple_filter_ops,
10024 		(void *)&cmd_2tuple_filter_dst_port,
10025 		(void *)&cmd_2tuple_filter_dst_port_value,
10026 		(void *)&cmd_2tuple_filter_protocol,
10027 		(void *)&cmd_2tuple_filter_protocol_value,
10028 		(void *)&cmd_2tuple_filter_mask,
10029 		(void *)&cmd_2tuple_filter_mask_value,
10030 		(void *)&cmd_2tuple_filter_tcp_flags,
10031 		(void *)&cmd_2tuple_filter_tcp_flags_value,
10032 		(void *)&cmd_2tuple_filter_priority,
10033 		(void *)&cmd_2tuple_filter_priority_value,
10034 		(void *)&cmd_2tuple_filter_queue,
10035 		(void *)&cmd_2tuple_filter_queue_id,
10036 		NULL,
10037 	},
10038 };
10039 
10040 /* *** ADD/REMOVE A 5tuple FILTER *** */
10041 struct cmd_5tuple_filter_result {
10042 	cmdline_fixed_string_t filter;
10043 	portid_t port_id;
10044 	cmdline_fixed_string_t ops;
10045 	cmdline_fixed_string_t dst_ip;
10046 	cmdline_ipaddr_t dst_ip_value;
10047 	cmdline_fixed_string_t src_ip;
10048 	cmdline_ipaddr_t src_ip_value;
10049 	cmdline_fixed_string_t dst_port;
10050 	uint16_t dst_port_value;
10051 	cmdline_fixed_string_t src_port;
10052 	uint16_t src_port_value;
10053 	cmdline_fixed_string_t protocol;
10054 	uint8_t protocol_value;
10055 	cmdline_fixed_string_t mask;
10056 	uint8_t  mask_value;
10057 	cmdline_fixed_string_t tcp_flags;
10058 	uint8_t tcp_flags_value;
10059 	cmdline_fixed_string_t priority;
10060 	uint8_t  priority_value;
10061 	cmdline_fixed_string_t queue;
10062 	uint16_t  queue_id;
10063 };
10064 
10065 static void
10066 cmd_5tuple_filter_parsed(void *parsed_result,
10067 			__attribute__((unused)) struct cmdline *cl,
10068 			__attribute__((unused)) void *data)
10069 {
10070 	struct rte_eth_ntuple_filter filter;
10071 	struct cmd_5tuple_filter_result *res = parsed_result;
10072 	int ret = 0;
10073 
10074 	ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
10075 	if (ret < 0) {
10076 		printf("ntuple filter is not supported on port %u.\n",
10077 			res->port_id);
10078 		return;
10079 	}
10080 
10081 	memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
10082 
10083 	filter.flags = RTE_5TUPLE_FLAGS;
10084 	filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
10085 	filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
10086 	filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
10087 	filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
10088 	filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
10089 	filter.proto = res->protocol_value;
10090 	filter.priority = res->priority_value;
10091 	if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
10092 		printf("nonzero tcp_flags is only meaningful"
10093 			" when protocol is TCP.\n");
10094 		return;
10095 	}
10096 	if (res->tcp_flags_value > TCP_FLAG_ALL) {
10097 		printf("invalid TCP flags.\n");
10098 		return;
10099 	}
10100 
10101 	if (res->tcp_flags_value != 0) {
10102 		filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
10103 		filter.tcp_flags = res->tcp_flags_value;
10104 	}
10105 
10106 	if (res->dst_ip_value.family == AF_INET)
10107 		/* no need to convert, already big endian. */
10108 		filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
10109 	else {
10110 		if (filter.dst_ip_mask == 0) {
10111 			printf("can not support ipv6 involved compare.\n");
10112 			return;
10113 		}
10114 		filter.dst_ip = 0;
10115 	}
10116 
10117 	if (res->src_ip_value.family == AF_INET)
10118 		/* no need to convert, already big endian. */
10119 		filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
10120 	else {
10121 		if (filter.src_ip_mask == 0) {
10122 			printf("can not support ipv6 involved compare.\n");
10123 			return;
10124 		}
10125 		filter.src_ip = 0;
10126 	}
10127 	/* need convert to big endian. */
10128 	filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
10129 	filter.src_port = rte_cpu_to_be_16(res->src_port_value);
10130 	filter.queue = res->queue_id;
10131 
10132 	if (!strcmp(res->ops, "add"))
10133 		ret = rte_eth_dev_filter_ctrl(res->port_id,
10134 				RTE_ETH_FILTER_NTUPLE,
10135 				RTE_ETH_FILTER_ADD,
10136 				&filter);
10137 	else
10138 		ret = rte_eth_dev_filter_ctrl(res->port_id,
10139 				RTE_ETH_FILTER_NTUPLE,
10140 				RTE_ETH_FILTER_DELETE,
10141 				&filter);
10142 	if (ret < 0)
10143 		printf("5tuple filter programming error: (%s)\n",
10144 			strerror(-ret));
10145 }
10146 
10147 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
10148 	TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10149 				 filter, "5tuple_filter");
10150 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
10151 	TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10152 				port_id, UINT16);
10153 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
10154 	TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10155 				 ops, "add#del");
10156 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
10157 	TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10158 				dst_ip, "dst_ip");
10159 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
10160 	TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10161 				dst_ip_value);
10162 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
10163 	TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10164 				src_ip, "src_ip");
10165 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
10166 	TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10167 				src_ip_value);
10168 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
10169 	TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10170 				dst_port, "dst_port");
10171 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
10172 	TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10173 				dst_port_value, UINT16);
10174 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
10175 	TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10176 				src_port, "src_port");
10177 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
10178 	TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10179 				src_port_value, UINT16);
10180 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
10181 	TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10182 				protocol, "protocol");
10183 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
10184 	TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10185 				protocol_value, UINT8);
10186 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
10187 	TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10188 				mask, "mask");
10189 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
10190 	TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10191 				mask_value, INT8);
10192 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
10193 	TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10194 				tcp_flags, "tcp_flags");
10195 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
10196 	TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10197 				tcp_flags_value, UINT8);
10198 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
10199 	TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10200 				priority, "priority");
10201 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
10202 	TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10203 				priority_value, UINT8);
10204 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
10205 	TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10206 				queue, "queue");
10207 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
10208 	TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10209 				queue_id, UINT16);
10210 
10211 cmdline_parse_inst_t cmd_5tuple_filter = {
10212 	.f = cmd_5tuple_filter_parsed,
10213 	.data = NULL,
10214 	.help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
10215 		"src_ip <value> dst_port <value> src_port <value> "
10216 		"protocol <value>  mask <value> tcp_flags <value> "
10217 		"priority <value> queue <queue_id>: Add/Del a 5tuple filter",
10218 	.tokens = {
10219 		(void *)&cmd_5tuple_filter_filter,
10220 		(void *)&cmd_5tuple_filter_port_id,
10221 		(void *)&cmd_5tuple_filter_ops,
10222 		(void *)&cmd_5tuple_filter_dst_ip,
10223 		(void *)&cmd_5tuple_filter_dst_ip_value,
10224 		(void *)&cmd_5tuple_filter_src_ip,
10225 		(void *)&cmd_5tuple_filter_src_ip_value,
10226 		(void *)&cmd_5tuple_filter_dst_port,
10227 		(void *)&cmd_5tuple_filter_dst_port_value,
10228 		(void *)&cmd_5tuple_filter_src_port,
10229 		(void *)&cmd_5tuple_filter_src_port_value,
10230 		(void *)&cmd_5tuple_filter_protocol,
10231 		(void *)&cmd_5tuple_filter_protocol_value,
10232 		(void *)&cmd_5tuple_filter_mask,
10233 		(void *)&cmd_5tuple_filter_mask_value,
10234 		(void *)&cmd_5tuple_filter_tcp_flags,
10235 		(void *)&cmd_5tuple_filter_tcp_flags_value,
10236 		(void *)&cmd_5tuple_filter_priority,
10237 		(void *)&cmd_5tuple_filter_priority_value,
10238 		(void *)&cmd_5tuple_filter_queue,
10239 		(void *)&cmd_5tuple_filter_queue_id,
10240 		NULL,
10241 	},
10242 };
10243 
10244 /* *** ADD/REMOVE A flex FILTER *** */
10245 struct cmd_flex_filter_result {
10246 	cmdline_fixed_string_t filter;
10247 	cmdline_fixed_string_t ops;
10248 	portid_t port_id;
10249 	cmdline_fixed_string_t len;
10250 	uint8_t len_value;
10251 	cmdline_fixed_string_t bytes;
10252 	cmdline_fixed_string_t bytes_value;
10253 	cmdline_fixed_string_t mask;
10254 	cmdline_fixed_string_t mask_value;
10255 	cmdline_fixed_string_t priority;
10256 	uint8_t priority_value;
10257 	cmdline_fixed_string_t queue;
10258 	uint16_t queue_id;
10259 };
10260 
10261 static int xdigit2val(unsigned char c)
10262 {
10263 	int val;
10264 	if (isdigit(c))
10265 		val = c - '0';
10266 	else if (isupper(c))
10267 		val = c - 'A' + 10;
10268 	else
10269 		val = c - 'a' + 10;
10270 	return val;
10271 }
10272 
10273 static void
10274 cmd_flex_filter_parsed(void *parsed_result,
10275 			  __attribute__((unused)) struct cmdline *cl,
10276 			  __attribute__((unused)) void *data)
10277 {
10278 	int ret = 0;
10279 	struct rte_eth_flex_filter filter;
10280 	struct cmd_flex_filter_result *res = parsed_result;
10281 	char *bytes_ptr, *mask_ptr;
10282 	uint16_t len, i, j = 0;
10283 	char c;
10284 	int val;
10285 	uint8_t byte = 0;
10286 
10287 	if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
10288 		printf("the len exceed the max length 128\n");
10289 		return;
10290 	}
10291 	memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
10292 	filter.len = res->len_value;
10293 	filter.priority = res->priority_value;
10294 	filter.queue = res->queue_id;
10295 	bytes_ptr = res->bytes_value;
10296 	mask_ptr = res->mask_value;
10297 
10298 	 /* translate bytes string to array. */
10299 	if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
10300 		(bytes_ptr[1] == 'X')))
10301 		bytes_ptr += 2;
10302 	len = strnlen(bytes_ptr, res->len_value * 2);
10303 	if (len == 0 || (len % 8 != 0)) {
10304 		printf("please check len and bytes input\n");
10305 		return;
10306 	}
10307 	for (i = 0; i < len; i++) {
10308 		c = bytes_ptr[i];
10309 		if (isxdigit(c) == 0) {
10310 			/* invalid characters. */
10311 			printf("invalid input\n");
10312 			return;
10313 		}
10314 		val = xdigit2val(c);
10315 		if (i % 2) {
10316 			byte |= val;
10317 			filter.bytes[j] = byte;
10318 			printf("bytes[%d]:%02x ", j, filter.bytes[j]);
10319 			j++;
10320 			byte = 0;
10321 		} else
10322 			byte |= val << 4;
10323 	}
10324 	printf("\n");
10325 	 /* translate mask string to uint8_t array. */
10326 	if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
10327 		(mask_ptr[1] == 'X')))
10328 		mask_ptr += 2;
10329 	len = strnlen(mask_ptr, (res->len_value + 3) / 4);
10330 	if (len == 0) {
10331 		printf("invalid input\n");
10332 		return;
10333 	}
10334 	j = 0;
10335 	byte = 0;
10336 	for (i = 0; i < len; i++) {
10337 		c = mask_ptr[i];
10338 		if (isxdigit(c) == 0) {
10339 			/* invalid characters. */
10340 			printf("invalid input\n");
10341 			return;
10342 		}
10343 		val = xdigit2val(c);
10344 		if (i % 2) {
10345 			byte |= val;
10346 			filter.mask[j] = byte;
10347 			printf("mask[%d]:%02x ", j, filter.mask[j]);
10348 			j++;
10349 			byte = 0;
10350 		} else
10351 			byte |= val << 4;
10352 	}
10353 	printf("\n");
10354 
10355 	if (!strcmp(res->ops, "add"))
10356 		ret = rte_eth_dev_filter_ctrl(res->port_id,
10357 				RTE_ETH_FILTER_FLEXIBLE,
10358 				RTE_ETH_FILTER_ADD,
10359 				&filter);
10360 	else
10361 		ret = rte_eth_dev_filter_ctrl(res->port_id,
10362 				RTE_ETH_FILTER_FLEXIBLE,
10363 				RTE_ETH_FILTER_DELETE,
10364 				&filter);
10365 
10366 	if (ret < 0)
10367 		printf("flex filter setting error: (%s)\n", strerror(-ret));
10368 }
10369 
10370 cmdline_parse_token_string_t cmd_flex_filter_filter =
10371 	TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10372 				filter, "flex_filter");
10373 cmdline_parse_token_num_t cmd_flex_filter_port_id =
10374 	TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10375 				port_id, UINT16);
10376 cmdline_parse_token_string_t cmd_flex_filter_ops =
10377 	TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10378 				ops, "add#del");
10379 cmdline_parse_token_string_t cmd_flex_filter_len =
10380 	TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10381 				len, "len");
10382 cmdline_parse_token_num_t cmd_flex_filter_len_value =
10383 	TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10384 				len_value, UINT8);
10385 cmdline_parse_token_string_t cmd_flex_filter_bytes =
10386 	TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10387 				bytes, "bytes");
10388 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
10389 	TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10390 				bytes_value, NULL);
10391 cmdline_parse_token_string_t cmd_flex_filter_mask =
10392 	TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10393 				mask, "mask");
10394 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
10395 	TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10396 				mask_value, NULL);
10397 cmdline_parse_token_string_t cmd_flex_filter_priority =
10398 	TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10399 				priority, "priority");
10400 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
10401 	TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10402 				priority_value, UINT8);
10403 cmdline_parse_token_string_t cmd_flex_filter_queue =
10404 	TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10405 				queue, "queue");
10406 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
10407 	TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10408 				queue_id, UINT16);
10409 cmdline_parse_inst_t cmd_flex_filter = {
10410 	.f = cmd_flex_filter_parsed,
10411 	.data = NULL,
10412 	.help_str = "flex_filter <port_id> add|del len <value> bytes "
10413 		"<value> mask <value> priority <value> queue <queue_id>: "
10414 		"Add/Del a flex filter",
10415 	.tokens = {
10416 		(void *)&cmd_flex_filter_filter,
10417 		(void *)&cmd_flex_filter_port_id,
10418 		(void *)&cmd_flex_filter_ops,
10419 		(void *)&cmd_flex_filter_len,
10420 		(void *)&cmd_flex_filter_len_value,
10421 		(void *)&cmd_flex_filter_bytes,
10422 		(void *)&cmd_flex_filter_bytes_value,
10423 		(void *)&cmd_flex_filter_mask,
10424 		(void *)&cmd_flex_filter_mask_value,
10425 		(void *)&cmd_flex_filter_priority,
10426 		(void *)&cmd_flex_filter_priority_value,
10427 		(void *)&cmd_flex_filter_queue,
10428 		(void *)&cmd_flex_filter_queue_id,
10429 		NULL,
10430 	},
10431 };
10432 
10433 /* *** Filters Control *** */
10434 
10435 /* *** deal with ethertype filter *** */
10436 struct cmd_ethertype_filter_result {
10437 	cmdline_fixed_string_t filter;
10438 	portid_t port_id;
10439 	cmdline_fixed_string_t ops;
10440 	cmdline_fixed_string_t mac;
10441 	struct ether_addr mac_addr;
10442 	cmdline_fixed_string_t ethertype;
10443 	uint16_t ethertype_value;
10444 	cmdline_fixed_string_t drop;
10445 	cmdline_fixed_string_t queue;
10446 	uint16_t  queue_id;
10447 };
10448 
10449 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
10450 	TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10451 				 filter, "ethertype_filter");
10452 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
10453 	TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10454 			      port_id, UINT16);
10455 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
10456 	TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10457 				 ops, "add#del");
10458 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
10459 	TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10460 				 mac, "mac_addr#mac_ignr");
10461 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
10462 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
10463 				     mac_addr);
10464 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
10465 	TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10466 				 ethertype, "ethertype");
10467 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
10468 	TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10469 			      ethertype_value, UINT16);
10470 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
10471 	TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10472 				 drop, "drop#fwd");
10473 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
10474 	TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10475 				 queue, "queue");
10476 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
10477 	TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10478 			      queue_id, UINT16);
10479 
10480 static void
10481 cmd_ethertype_filter_parsed(void *parsed_result,
10482 			  __attribute__((unused)) struct cmdline *cl,
10483 			  __attribute__((unused)) void *data)
10484 {
10485 	struct cmd_ethertype_filter_result *res = parsed_result;
10486 	struct rte_eth_ethertype_filter filter;
10487 	int ret = 0;
10488 
10489 	ret = rte_eth_dev_filter_supported(res->port_id,
10490 			RTE_ETH_FILTER_ETHERTYPE);
10491 	if (ret < 0) {
10492 		printf("ethertype filter is not supported on port %u.\n",
10493 			res->port_id);
10494 		return;
10495 	}
10496 
10497 	memset(&filter, 0, sizeof(filter));
10498 	if (!strcmp(res->mac, "mac_addr")) {
10499 		filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
10500 		rte_memcpy(&filter.mac_addr, &res->mac_addr,
10501 			sizeof(struct ether_addr));
10502 	}
10503 	if (!strcmp(res->drop, "drop"))
10504 		filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
10505 	filter.ether_type = res->ethertype_value;
10506 	filter.queue = res->queue_id;
10507 
10508 	if (!strcmp(res->ops, "add"))
10509 		ret = rte_eth_dev_filter_ctrl(res->port_id,
10510 				RTE_ETH_FILTER_ETHERTYPE,
10511 				RTE_ETH_FILTER_ADD,
10512 				&filter);
10513 	else
10514 		ret = rte_eth_dev_filter_ctrl(res->port_id,
10515 				RTE_ETH_FILTER_ETHERTYPE,
10516 				RTE_ETH_FILTER_DELETE,
10517 				&filter);
10518 	if (ret < 0)
10519 		printf("ethertype filter programming error: (%s)\n",
10520 			strerror(-ret));
10521 }
10522 
10523 cmdline_parse_inst_t cmd_ethertype_filter = {
10524 	.f = cmd_ethertype_filter_parsed,
10525 	.data = NULL,
10526 	.help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
10527 		"<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
10528 		"Add or delete an ethertype filter entry",
10529 	.tokens = {
10530 		(void *)&cmd_ethertype_filter_filter,
10531 		(void *)&cmd_ethertype_filter_port_id,
10532 		(void *)&cmd_ethertype_filter_ops,
10533 		(void *)&cmd_ethertype_filter_mac,
10534 		(void *)&cmd_ethertype_filter_mac_addr,
10535 		(void *)&cmd_ethertype_filter_ethertype,
10536 		(void *)&cmd_ethertype_filter_ethertype_value,
10537 		(void *)&cmd_ethertype_filter_drop,
10538 		(void *)&cmd_ethertype_filter_queue,
10539 		(void *)&cmd_ethertype_filter_queue_id,
10540 		NULL,
10541 	},
10542 };
10543 
10544 /* *** deal with flow director filter *** */
10545 struct cmd_flow_director_result {
10546 	cmdline_fixed_string_t flow_director_filter;
10547 	portid_t port_id;
10548 	cmdline_fixed_string_t mode;
10549 	cmdline_fixed_string_t mode_value;
10550 	cmdline_fixed_string_t ops;
10551 	cmdline_fixed_string_t flow;
10552 	cmdline_fixed_string_t flow_type;
10553 	cmdline_fixed_string_t ether;
10554 	uint16_t ether_type;
10555 	cmdline_fixed_string_t src;
10556 	cmdline_ipaddr_t ip_src;
10557 	uint16_t port_src;
10558 	cmdline_fixed_string_t dst;
10559 	cmdline_ipaddr_t ip_dst;
10560 	uint16_t port_dst;
10561 	cmdline_fixed_string_t verify_tag;
10562 	uint32_t verify_tag_value;
10563 	cmdline_fixed_string_t tos;
10564 	uint8_t tos_value;
10565 	cmdline_fixed_string_t proto;
10566 	uint8_t proto_value;
10567 	cmdline_fixed_string_t ttl;
10568 	uint8_t ttl_value;
10569 	cmdline_fixed_string_t vlan;
10570 	uint16_t vlan_value;
10571 	cmdline_fixed_string_t flexbytes;
10572 	cmdline_fixed_string_t flexbytes_value;
10573 	cmdline_fixed_string_t pf_vf;
10574 	cmdline_fixed_string_t drop;
10575 	cmdline_fixed_string_t queue;
10576 	uint16_t  queue_id;
10577 	cmdline_fixed_string_t fd_id;
10578 	uint32_t  fd_id_value;
10579 	cmdline_fixed_string_t mac;
10580 	struct ether_addr mac_addr;
10581 	cmdline_fixed_string_t tunnel;
10582 	cmdline_fixed_string_t tunnel_type;
10583 	cmdline_fixed_string_t tunnel_id;
10584 	uint32_t tunnel_id_value;
10585 	cmdline_fixed_string_t packet;
10586 	char filepath[];
10587 };
10588 
10589 static inline int
10590 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
10591 {
10592 	char s[256];
10593 	const char *p, *p0 = q_arg;
10594 	char *end;
10595 	unsigned long int_fld;
10596 	char *str_fld[max_num];
10597 	int i;
10598 	unsigned size;
10599 	int ret = -1;
10600 
10601 	p = strchr(p0, '(');
10602 	if (p == NULL)
10603 		return -1;
10604 	++p;
10605 	p0 = strchr(p, ')');
10606 	if (p0 == NULL)
10607 		return -1;
10608 
10609 	size = p0 - p;
10610 	if (size >= sizeof(s))
10611 		return -1;
10612 
10613 	snprintf(s, sizeof(s), "%.*s", size, p);
10614 	ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10615 	if (ret < 0 || ret > max_num)
10616 		return -1;
10617 	for (i = 0; i < ret; i++) {
10618 		errno = 0;
10619 		int_fld = strtoul(str_fld[i], &end, 0);
10620 		if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
10621 			return -1;
10622 		flexbytes[i] = (uint8_t)int_fld;
10623 	}
10624 	return ret;
10625 }
10626 
10627 static uint16_t
10628 str2flowtype(char *string)
10629 {
10630 	uint8_t i = 0;
10631 	static const struct {
10632 		char str[32];
10633 		uint16_t type;
10634 	} flowtype_str[] = {
10635 		{"raw", RTE_ETH_FLOW_RAW},
10636 		{"ipv4", RTE_ETH_FLOW_IPV4},
10637 		{"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10638 		{"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10639 		{"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10640 		{"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10641 		{"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10642 		{"ipv6", RTE_ETH_FLOW_IPV6},
10643 		{"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10644 		{"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10645 		{"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10646 		{"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10647 		{"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10648 		{"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10649 	};
10650 
10651 	for (i = 0; i < RTE_DIM(flowtype_str); i++) {
10652 		if (!strcmp(flowtype_str[i].str, string))
10653 			return flowtype_str[i].type;
10654 	}
10655 
10656 	if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
10657 		return (uint16_t)atoi(string);
10658 
10659 	return RTE_ETH_FLOW_UNKNOWN;
10660 }
10661 
10662 static enum rte_eth_fdir_tunnel_type
10663 str2fdir_tunneltype(char *string)
10664 {
10665 	uint8_t i = 0;
10666 
10667 	static const struct {
10668 		char str[32];
10669 		enum rte_eth_fdir_tunnel_type type;
10670 	} tunneltype_str[] = {
10671 		{"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
10672 		{"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
10673 	};
10674 
10675 	for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
10676 		if (!strcmp(tunneltype_str[i].str, string))
10677 			return tunneltype_str[i].type;
10678 	}
10679 	return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
10680 }
10681 
10682 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10683 do { \
10684 	if ((ip_addr).family == AF_INET) \
10685 		(ip) = (ip_addr).addr.ipv4.s_addr; \
10686 	else { \
10687 		printf("invalid parameter.\n"); \
10688 		return; \
10689 	} \
10690 } while (0)
10691 
10692 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10693 do { \
10694 	if ((ip_addr).family == AF_INET6) \
10695 		rte_memcpy(&(ip), \
10696 				 &((ip_addr).addr.ipv6), \
10697 				 sizeof(struct in6_addr)); \
10698 	else { \
10699 		printf("invalid parameter.\n"); \
10700 		return; \
10701 	} \
10702 } while (0)
10703 
10704 static void
10705 cmd_flow_director_filter_parsed(void *parsed_result,
10706 			  __attribute__((unused)) struct cmdline *cl,
10707 			  __attribute__((unused)) void *data)
10708 {
10709 	struct cmd_flow_director_result *res = parsed_result;
10710 	struct rte_eth_fdir_filter entry;
10711 	uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
10712 	char *end;
10713 	unsigned long vf_id;
10714 	int ret = 0;
10715 
10716 	ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
10717 	if (ret < 0) {
10718 		printf("flow director is not supported on port %u.\n",
10719 			res->port_id);
10720 		return;
10721 	}
10722 	memset(flexbytes, 0, sizeof(flexbytes));
10723 	memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
10724 
10725 	if (fdir_conf.mode ==  RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10726 		if (strcmp(res->mode_value, "MAC-VLAN")) {
10727 			printf("Please set mode to MAC-VLAN.\n");
10728 			return;
10729 		}
10730 	} else if (fdir_conf.mode ==  RTE_FDIR_MODE_PERFECT_TUNNEL) {
10731 		if (strcmp(res->mode_value, "Tunnel")) {
10732 			printf("Please set mode to Tunnel.\n");
10733 			return;
10734 		}
10735 	} else {
10736 		if (!strcmp(res->mode_value, "raw")) {
10737 #ifdef RTE_LIBRTE_I40E_PMD
10738 			struct rte_pmd_i40e_flow_type_mapping
10739 					mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
10740 			struct rte_pmd_i40e_pkt_template_conf conf;
10741 			uint16_t flow_type = str2flowtype(res->flow_type);
10742 			uint16_t i, port = res->port_id;
10743 			uint8_t add;
10744 
10745 			memset(&conf, 0, sizeof(conf));
10746 
10747 			if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
10748 				printf("Invalid flow type specified.\n");
10749 				return;
10750 			}
10751 			ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
10752 								 mapping);
10753 			if (ret)
10754 				return;
10755 			if (mapping[flow_type].pctype == 0ULL) {
10756 				printf("Invalid flow type specified.\n");
10757 				return;
10758 			}
10759 			for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
10760 				if (mapping[flow_type].pctype & (1ULL << i)) {
10761 					conf.input.pctype = i;
10762 					break;
10763 				}
10764 			}
10765 
10766 			conf.input.packet = open_file(res->filepath,
10767 						&conf.input.length);
10768 			if (!conf.input.packet)
10769 				return;
10770 			if (!strcmp(res->drop, "drop"))
10771 				conf.action.behavior =
10772 					RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
10773 			else
10774 				conf.action.behavior =
10775 					RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
10776 			conf.action.report_status =
10777 					RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
10778 			conf.action.rx_queue = res->queue_id;
10779 			conf.soft_id = res->fd_id_value;
10780 			add  = strcmp(res->ops, "del") ? 1 : 0;
10781 			ret = rte_pmd_i40e_flow_add_del_packet_template(port,
10782 									&conf,
10783 									add);
10784 			if (ret < 0)
10785 				printf("flow director config error: (%s)\n",
10786 				       strerror(-ret));
10787 			close_file(conf.input.packet);
10788 #endif
10789 			return;
10790 		} else if (strcmp(res->mode_value, "IP")) {
10791 			printf("Please set mode to IP or raw.\n");
10792 			return;
10793 		}
10794 		entry.input.flow_type = str2flowtype(res->flow_type);
10795 	}
10796 
10797 	ret = parse_flexbytes(res->flexbytes_value,
10798 					flexbytes,
10799 					RTE_ETH_FDIR_MAX_FLEXLEN);
10800 	if (ret < 0) {
10801 		printf("error: Cannot parse flexbytes input.\n");
10802 		return;
10803 	}
10804 
10805 	switch (entry.input.flow_type) {
10806 	case RTE_ETH_FLOW_FRAG_IPV4:
10807 	case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
10808 		entry.input.flow.ip4_flow.proto = res->proto_value;
10809 		/* fall-through */
10810 	case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
10811 	case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
10812 		IPV4_ADDR_TO_UINT(res->ip_dst,
10813 			entry.input.flow.ip4_flow.dst_ip);
10814 		IPV4_ADDR_TO_UINT(res->ip_src,
10815 			entry.input.flow.ip4_flow.src_ip);
10816 		entry.input.flow.ip4_flow.tos = res->tos_value;
10817 		entry.input.flow.ip4_flow.ttl = res->ttl_value;
10818 		/* need convert to big endian. */
10819 		entry.input.flow.udp4_flow.dst_port =
10820 				rte_cpu_to_be_16(res->port_dst);
10821 		entry.input.flow.udp4_flow.src_port =
10822 				rte_cpu_to_be_16(res->port_src);
10823 		break;
10824 	case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
10825 		IPV4_ADDR_TO_UINT(res->ip_dst,
10826 			entry.input.flow.sctp4_flow.ip.dst_ip);
10827 		IPV4_ADDR_TO_UINT(res->ip_src,
10828 			entry.input.flow.sctp4_flow.ip.src_ip);
10829 		entry.input.flow.ip4_flow.tos = res->tos_value;
10830 		entry.input.flow.ip4_flow.ttl = res->ttl_value;
10831 		/* need convert to big endian. */
10832 		entry.input.flow.sctp4_flow.dst_port =
10833 				rte_cpu_to_be_16(res->port_dst);
10834 		entry.input.flow.sctp4_flow.src_port =
10835 				rte_cpu_to_be_16(res->port_src);
10836 		entry.input.flow.sctp4_flow.verify_tag =
10837 				rte_cpu_to_be_32(res->verify_tag_value);
10838 		break;
10839 	case RTE_ETH_FLOW_FRAG_IPV6:
10840 	case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
10841 		entry.input.flow.ipv6_flow.proto = res->proto_value;
10842 		/* fall-through */
10843 	case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
10844 	case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
10845 		IPV6_ADDR_TO_ARRAY(res->ip_dst,
10846 			entry.input.flow.ipv6_flow.dst_ip);
10847 		IPV6_ADDR_TO_ARRAY(res->ip_src,
10848 			entry.input.flow.ipv6_flow.src_ip);
10849 		entry.input.flow.ipv6_flow.tc = res->tos_value;
10850 		entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
10851 		/* need convert to big endian. */
10852 		entry.input.flow.udp6_flow.dst_port =
10853 				rte_cpu_to_be_16(res->port_dst);
10854 		entry.input.flow.udp6_flow.src_port =
10855 				rte_cpu_to_be_16(res->port_src);
10856 		break;
10857 	case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
10858 		IPV6_ADDR_TO_ARRAY(res->ip_dst,
10859 			entry.input.flow.sctp6_flow.ip.dst_ip);
10860 		IPV6_ADDR_TO_ARRAY(res->ip_src,
10861 			entry.input.flow.sctp6_flow.ip.src_ip);
10862 		entry.input.flow.ipv6_flow.tc = res->tos_value;
10863 		entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
10864 		/* need convert to big endian. */
10865 		entry.input.flow.sctp6_flow.dst_port =
10866 				rte_cpu_to_be_16(res->port_dst);
10867 		entry.input.flow.sctp6_flow.src_port =
10868 				rte_cpu_to_be_16(res->port_src);
10869 		entry.input.flow.sctp6_flow.verify_tag =
10870 				rte_cpu_to_be_32(res->verify_tag_value);
10871 		break;
10872 	case RTE_ETH_FLOW_L2_PAYLOAD:
10873 		entry.input.flow.l2_flow.ether_type =
10874 			rte_cpu_to_be_16(res->ether_type);
10875 		break;
10876 	default:
10877 		break;
10878 	}
10879 
10880 	if (fdir_conf.mode ==  RTE_FDIR_MODE_PERFECT_MAC_VLAN)
10881 		rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
10882 				 &res->mac_addr,
10883 				 sizeof(struct ether_addr));
10884 
10885 	if (fdir_conf.mode ==  RTE_FDIR_MODE_PERFECT_TUNNEL) {
10886 		rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
10887 				 &res->mac_addr,
10888 				 sizeof(struct ether_addr));
10889 		entry.input.flow.tunnel_flow.tunnel_type =
10890 			str2fdir_tunneltype(res->tunnel_type);
10891 		entry.input.flow.tunnel_flow.tunnel_id =
10892 			rte_cpu_to_be_32(res->tunnel_id_value);
10893 	}
10894 
10895 	rte_memcpy(entry.input.flow_ext.flexbytes,
10896 		   flexbytes,
10897 		   RTE_ETH_FDIR_MAX_FLEXLEN);
10898 
10899 	entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
10900 
10901 	entry.action.flex_off = 0;  /*use 0 by default */
10902 	if (!strcmp(res->drop, "drop"))
10903 		entry.action.behavior = RTE_ETH_FDIR_REJECT;
10904 	else
10905 		entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
10906 
10907 	if (fdir_conf.mode !=  RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
10908 	    fdir_conf.mode !=  RTE_FDIR_MODE_PERFECT_TUNNEL) {
10909 		if (!strcmp(res->pf_vf, "pf"))
10910 			entry.input.flow_ext.is_vf = 0;
10911 		else if (!strncmp(res->pf_vf, "vf", 2)) {
10912 			struct rte_eth_dev_info dev_info;
10913 
10914 			memset(&dev_info, 0, sizeof(dev_info));
10915 			rte_eth_dev_info_get(res->port_id, &dev_info);
10916 			errno = 0;
10917 			vf_id = strtoul(res->pf_vf + 2, &end, 10);
10918 			if (errno != 0 || *end != '\0' ||
10919 			    vf_id >= dev_info.max_vfs) {
10920 				printf("invalid parameter %s.\n", res->pf_vf);
10921 				return;
10922 			}
10923 			entry.input.flow_ext.is_vf = 1;
10924 			entry.input.flow_ext.dst_id = (uint16_t)vf_id;
10925 		} else {
10926 			printf("invalid parameter %s.\n", res->pf_vf);
10927 			return;
10928 		}
10929 	}
10930 
10931 	/* set to report FD ID by default */
10932 	entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
10933 	entry.action.rx_queue = res->queue_id;
10934 	entry.soft_id = res->fd_id_value;
10935 	if (!strcmp(res->ops, "add"))
10936 		ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10937 					     RTE_ETH_FILTER_ADD, &entry);
10938 	else if (!strcmp(res->ops, "del"))
10939 		ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10940 					     RTE_ETH_FILTER_DELETE, &entry);
10941 	else
10942 		ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10943 					     RTE_ETH_FILTER_UPDATE, &entry);
10944 	if (ret < 0)
10945 		printf("flow director programming error: (%s)\n",
10946 			strerror(-ret));
10947 }
10948 
10949 cmdline_parse_token_string_t cmd_flow_director_filter =
10950 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10951 				 flow_director_filter, "flow_director_filter");
10952 cmdline_parse_token_num_t cmd_flow_director_port_id =
10953 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10954 			      port_id, UINT16);
10955 cmdline_parse_token_string_t cmd_flow_director_ops =
10956 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10957 				 ops, "add#del#update");
10958 cmdline_parse_token_string_t cmd_flow_director_flow =
10959 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10960 				 flow, "flow");
10961 cmdline_parse_token_string_t cmd_flow_director_flow_type =
10962 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10963 		flow_type, NULL);
10964 cmdline_parse_token_string_t cmd_flow_director_ether =
10965 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10966 				 ether, "ether");
10967 cmdline_parse_token_num_t cmd_flow_director_ether_type =
10968 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10969 			      ether_type, UINT16);
10970 cmdline_parse_token_string_t cmd_flow_director_src =
10971 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10972 				 src, "src");
10973 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
10974 	TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10975 				 ip_src);
10976 cmdline_parse_token_num_t cmd_flow_director_port_src =
10977 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10978 			      port_src, UINT16);
10979 cmdline_parse_token_string_t cmd_flow_director_dst =
10980 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10981 				 dst, "dst");
10982 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
10983 	TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10984 				 ip_dst);
10985 cmdline_parse_token_num_t cmd_flow_director_port_dst =
10986 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10987 			      port_dst, UINT16);
10988 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
10989 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10990 				  verify_tag, "verify_tag");
10991 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
10992 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10993 			      verify_tag_value, UINT32);
10994 cmdline_parse_token_string_t cmd_flow_director_tos =
10995 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10996 				 tos, "tos");
10997 cmdline_parse_token_num_t cmd_flow_director_tos_value =
10998 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10999 			      tos_value, UINT8);
11000 cmdline_parse_token_string_t cmd_flow_director_proto =
11001 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11002 				 proto, "proto");
11003 cmdline_parse_token_num_t cmd_flow_director_proto_value =
11004 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11005 			      proto_value, UINT8);
11006 cmdline_parse_token_string_t cmd_flow_director_ttl =
11007 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11008 				 ttl, "ttl");
11009 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
11010 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11011 			      ttl_value, UINT8);
11012 cmdline_parse_token_string_t cmd_flow_director_vlan =
11013 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11014 				 vlan, "vlan");
11015 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
11016 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11017 			      vlan_value, UINT16);
11018 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
11019 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11020 				 flexbytes, "flexbytes");
11021 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
11022 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11023 			      flexbytes_value, NULL);
11024 cmdline_parse_token_string_t cmd_flow_director_drop =
11025 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11026 				 drop, "drop#fwd");
11027 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
11028 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11029 			      pf_vf, NULL);
11030 cmdline_parse_token_string_t cmd_flow_director_queue =
11031 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11032 				 queue, "queue");
11033 cmdline_parse_token_num_t cmd_flow_director_queue_id =
11034 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11035 			      queue_id, UINT16);
11036 cmdline_parse_token_string_t cmd_flow_director_fd_id =
11037 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11038 				 fd_id, "fd_id");
11039 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
11040 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11041 			      fd_id_value, UINT32);
11042 
11043 cmdline_parse_token_string_t cmd_flow_director_mode =
11044 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11045 				 mode, "mode");
11046 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
11047 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11048 				 mode_value, "IP");
11049 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
11050 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11051 				 mode_value, "MAC-VLAN");
11052 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
11053 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11054 				 mode_value, "Tunnel");
11055 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
11056 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11057 				 mode_value, "raw");
11058 cmdline_parse_token_string_t cmd_flow_director_mac =
11059 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11060 				 mac, "mac");
11061 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
11062 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
11063 				    mac_addr);
11064 cmdline_parse_token_string_t cmd_flow_director_tunnel =
11065 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11066 				 tunnel, "tunnel");
11067 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
11068 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11069 				 tunnel_type, "NVGRE#VxLAN");
11070 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
11071 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11072 				 tunnel_id, "tunnel-id");
11073 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
11074 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11075 			      tunnel_id_value, UINT32);
11076 cmdline_parse_token_string_t cmd_flow_director_packet =
11077 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11078 				 packet, "packet");
11079 cmdline_parse_token_string_t cmd_flow_director_filepath =
11080 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11081 				 filepath, NULL);
11082 
11083 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
11084 	.f = cmd_flow_director_filter_parsed,
11085 	.data = NULL,
11086 	.help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
11087 		" ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
11088 		"ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
11089 		"l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
11090 		"proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
11091 		"flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> "
11092 		"fd_id <fd_id_value>: "
11093 		"Add or delete an ip flow director entry on NIC",
11094 	.tokens = {
11095 		(void *)&cmd_flow_director_filter,
11096 		(void *)&cmd_flow_director_port_id,
11097 		(void *)&cmd_flow_director_mode,
11098 		(void *)&cmd_flow_director_mode_ip,
11099 		(void *)&cmd_flow_director_ops,
11100 		(void *)&cmd_flow_director_flow,
11101 		(void *)&cmd_flow_director_flow_type,
11102 		(void *)&cmd_flow_director_src,
11103 		(void *)&cmd_flow_director_ip_src,
11104 		(void *)&cmd_flow_director_dst,
11105 		(void *)&cmd_flow_director_ip_dst,
11106 		(void *)&cmd_flow_director_tos,
11107 		(void *)&cmd_flow_director_tos_value,
11108 		(void *)&cmd_flow_director_proto,
11109 		(void *)&cmd_flow_director_proto_value,
11110 		(void *)&cmd_flow_director_ttl,
11111 		(void *)&cmd_flow_director_ttl_value,
11112 		(void *)&cmd_flow_director_vlan,
11113 		(void *)&cmd_flow_director_vlan_value,
11114 		(void *)&cmd_flow_director_flexbytes,
11115 		(void *)&cmd_flow_director_flexbytes_value,
11116 		(void *)&cmd_flow_director_drop,
11117 		(void *)&cmd_flow_director_pf_vf,
11118 		(void *)&cmd_flow_director_queue,
11119 		(void *)&cmd_flow_director_queue_id,
11120 		(void *)&cmd_flow_director_fd_id,
11121 		(void *)&cmd_flow_director_fd_id_value,
11122 		NULL,
11123 	},
11124 };
11125 
11126 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
11127 	.f = cmd_flow_director_filter_parsed,
11128 	.data = NULL,
11129 	.help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
11130 		"director entry on NIC",
11131 	.tokens = {
11132 		(void *)&cmd_flow_director_filter,
11133 		(void *)&cmd_flow_director_port_id,
11134 		(void *)&cmd_flow_director_mode,
11135 		(void *)&cmd_flow_director_mode_ip,
11136 		(void *)&cmd_flow_director_ops,
11137 		(void *)&cmd_flow_director_flow,
11138 		(void *)&cmd_flow_director_flow_type,
11139 		(void *)&cmd_flow_director_src,
11140 		(void *)&cmd_flow_director_ip_src,
11141 		(void *)&cmd_flow_director_port_src,
11142 		(void *)&cmd_flow_director_dst,
11143 		(void *)&cmd_flow_director_ip_dst,
11144 		(void *)&cmd_flow_director_port_dst,
11145 		(void *)&cmd_flow_director_tos,
11146 		(void *)&cmd_flow_director_tos_value,
11147 		(void *)&cmd_flow_director_ttl,
11148 		(void *)&cmd_flow_director_ttl_value,
11149 		(void *)&cmd_flow_director_vlan,
11150 		(void *)&cmd_flow_director_vlan_value,
11151 		(void *)&cmd_flow_director_flexbytes,
11152 		(void *)&cmd_flow_director_flexbytes_value,
11153 		(void *)&cmd_flow_director_drop,
11154 		(void *)&cmd_flow_director_pf_vf,
11155 		(void *)&cmd_flow_director_queue,
11156 		(void *)&cmd_flow_director_queue_id,
11157 		(void *)&cmd_flow_director_fd_id,
11158 		(void *)&cmd_flow_director_fd_id_value,
11159 		NULL,
11160 	},
11161 };
11162 
11163 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
11164 	.f = cmd_flow_director_filter_parsed,
11165 	.data = NULL,
11166 	.help_str = "flow_director_filter ... : Add or delete a sctp flow "
11167 		"director entry on NIC",
11168 	.tokens = {
11169 		(void *)&cmd_flow_director_filter,
11170 		(void *)&cmd_flow_director_port_id,
11171 		(void *)&cmd_flow_director_mode,
11172 		(void *)&cmd_flow_director_mode_ip,
11173 		(void *)&cmd_flow_director_ops,
11174 		(void *)&cmd_flow_director_flow,
11175 		(void *)&cmd_flow_director_flow_type,
11176 		(void *)&cmd_flow_director_src,
11177 		(void *)&cmd_flow_director_ip_src,
11178 		(void *)&cmd_flow_director_port_src,
11179 		(void *)&cmd_flow_director_dst,
11180 		(void *)&cmd_flow_director_ip_dst,
11181 		(void *)&cmd_flow_director_port_dst,
11182 		(void *)&cmd_flow_director_verify_tag,
11183 		(void *)&cmd_flow_director_verify_tag_value,
11184 		(void *)&cmd_flow_director_tos,
11185 		(void *)&cmd_flow_director_tos_value,
11186 		(void *)&cmd_flow_director_ttl,
11187 		(void *)&cmd_flow_director_ttl_value,
11188 		(void *)&cmd_flow_director_vlan,
11189 		(void *)&cmd_flow_director_vlan_value,
11190 		(void *)&cmd_flow_director_flexbytes,
11191 		(void *)&cmd_flow_director_flexbytes_value,
11192 		(void *)&cmd_flow_director_drop,
11193 		(void *)&cmd_flow_director_pf_vf,
11194 		(void *)&cmd_flow_director_queue,
11195 		(void *)&cmd_flow_director_queue_id,
11196 		(void *)&cmd_flow_director_fd_id,
11197 		(void *)&cmd_flow_director_fd_id_value,
11198 		NULL,
11199 	},
11200 };
11201 
11202 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
11203 	.f = cmd_flow_director_filter_parsed,
11204 	.data = NULL,
11205 	.help_str = "flow_director_filter ... : Add or delete a L2 flow "
11206 		"director entry on NIC",
11207 	.tokens = {
11208 		(void *)&cmd_flow_director_filter,
11209 		(void *)&cmd_flow_director_port_id,
11210 		(void *)&cmd_flow_director_mode,
11211 		(void *)&cmd_flow_director_mode_ip,
11212 		(void *)&cmd_flow_director_ops,
11213 		(void *)&cmd_flow_director_flow,
11214 		(void *)&cmd_flow_director_flow_type,
11215 		(void *)&cmd_flow_director_ether,
11216 		(void *)&cmd_flow_director_ether_type,
11217 		(void *)&cmd_flow_director_flexbytes,
11218 		(void *)&cmd_flow_director_flexbytes_value,
11219 		(void *)&cmd_flow_director_drop,
11220 		(void *)&cmd_flow_director_pf_vf,
11221 		(void *)&cmd_flow_director_queue,
11222 		(void *)&cmd_flow_director_queue_id,
11223 		(void *)&cmd_flow_director_fd_id,
11224 		(void *)&cmd_flow_director_fd_id_value,
11225 		NULL,
11226 	},
11227 };
11228 
11229 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
11230 	.f = cmd_flow_director_filter_parsed,
11231 	.data = NULL,
11232 	.help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
11233 		"director entry on NIC",
11234 	.tokens = {
11235 		(void *)&cmd_flow_director_filter,
11236 		(void *)&cmd_flow_director_port_id,
11237 		(void *)&cmd_flow_director_mode,
11238 		(void *)&cmd_flow_director_mode_mac_vlan,
11239 		(void *)&cmd_flow_director_ops,
11240 		(void *)&cmd_flow_director_mac,
11241 		(void *)&cmd_flow_director_mac_addr,
11242 		(void *)&cmd_flow_director_vlan,
11243 		(void *)&cmd_flow_director_vlan_value,
11244 		(void *)&cmd_flow_director_flexbytes,
11245 		(void *)&cmd_flow_director_flexbytes_value,
11246 		(void *)&cmd_flow_director_drop,
11247 		(void *)&cmd_flow_director_queue,
11248 		(void *)&cmd_flow_director_queue_id,
11249 		(void *)&cmd_flow_director_fd_id,
11250 		(void *)&cmd_flow_director_fd_id_value,
11251 		NULL,
11252 	},
11253 };
11254 
11255 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
11256 	.f = cmd_flow_director_filter_parsed,
11257 	.data = NULL,
11258 	.help_str = "flow_director_filter ... : Add or delete a tunnel flow "
11259 		"director entry on NIC",
11260 	.tokens = {
11261 		(void *)&cmd_flow_director_filter,
11262 		(void *)&cmd_flow_director_port_id,
11263 		(void *)&cmd_flow_director_mode,
11264 		(void *)&cmd_flow_director_mode_tunnel,
11265 		(void *)&cmd_flow_director_ops,
11266 		(void *)&cmd_flow_director_mac,
11267 		(void *)&cmd_flow_director_mac_addr,
11268 		(void *)&cmd_flow_director_vlan,
11269 		(void *)&cmd_flow_director_vlan_value,
11270 		(void *)&cmd_flow_director_tunnel,
11271 		(void *)&cmd_flow_director_tunnel_type,
11272 		(void *)&cmd_flow_director_tunnel_id,
11273 		(void *)&cmd_flow_director_tunnel_id_value,
11274 		(void *)&cmd_flow_director_flexbytes,
11275 		(void *)&cmd_flow_director_flexbytes_value,
11276 		(void *)&cmd_flow_director_drop,
11277 		(void *)&cmd_flow_director_queue,
11278 		(void *)&cmd_flow_director_queue_id,
11279 		(void *)&cmd_flow_director_fd_id,
11280 		(void *)&cmd_flow_director_fd_id_value,
11281 		NULL,
11282 	},
11283 };
11284 
11285 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
11286 	.f = cmd_flow_director_filter_parsed,
11287 	.data = NULL,
11288 	.help_str = "flow_director_filter ... : Add or delete a raw flow "
11289 		"director entry on NIC",
11290 	.tokens = {
11291 		(void *)&cmd_flow_director_filter,
11292 		(void *)&cmd_flow_director_port_id,
11293 		(void *)&cmd_flow_director_mode,
11294 		(void *)&cmd_flow_director_mode_raw,
11295 		(void *)&cmd_flow_director_ops,
11296 		(void *)&cmd_flow_director_flow,
11297 		(void *)&cmd_flow_director_flow_type,
11298 		(void *)&cmd_flow_director_drop,
11299 		(void *)&cmd_flow_director_queue,
11300 		(void *)&cmd_flow_director_queue_id,
11301 		(void *)&cmd_flow_director_fd_id,
11302 		(void *)&cmd_flow_director_fd_id_value,
11303 		(void *)&cmd_flow_director_packet,
11304 		(void *)&cmd_flow_director_filepath,
11305 		NULL,
11306 	},
11307 };
11308 
11309 struct cmd_flush_flow_director_result {
11310 	cmdline_fixed_string_t flush_flow_director;
11311 	portid_t port_id;
11312 };
11313 
11314 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
11315 	TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
11316 				 flush_flow_director, "flush_flow_director");
11317 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
11318 	TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
11319 			      port_id, UINT16);
11320 
11321 static void
11322 cmd_flush_flow_director_parsed(void *parsed_result,
11323 			  __attribute__((unused)) struct cmdline *cl,
11324 			  __attribute__((unused)) void *data)
11325 {
11326 	struct cmd_flow_director_result *res = parsed_result;
11327 	int ret = 0;
11328 
11329 	ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
11330 	if (ret < 0) {
11331 		printf("flow director is not supported on port %u.\n",
11332 			res->port_id);
11333 		return;
11334 	}
11335 
11336 	ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11337 			RTE_ETH_FILTER_FLUSH, NULL);
11338 	if (ret < 0)
11339 		printf("flow director table flushing error: (%s)\n",
11340 			strerror(-ret));
11341 }
11342 
11343 cmdline_parse_inst_t cmd_flush_flow_director = {
11344 	.f = cmd_flush_flow_director_parsed,
11345 	.data = NULL,
11346 	.help_str = "flush_flow_director <port_id>: "
11347 		"Flush all flow director entries of a device on NIC",
11348 	.tokens = {
11349 		(void *)&cmd_flush_flow_director_flush,
11350 		(void *)&cmd_flush_flow_director_port_id,
11351 		NULL,
11352 	},
11353 };
11354 
11355 /* *** deal with flow director mask *** */
11356 struct cmd_flow_director_mask_result {
11357 	cmdline_fixed_string_t flow_director_mask;
11358 	portid_t port_id;
11359 	cmdline_fixed_string_t mode;
11360 	cmdline_fixed_string_t mode_value;
11361 	cmdline_fixed_string_t vlan;
11362 	uint16_t vlan_mask;
11363 	cmdline_fixed_string_t src_mask;
11364 	cmdline_ipaddr_t ipv4_src;
11365 	cmdline_ipaddr_t ipv6_src;
11366 	uint16_t port_src;
11367 	cmdline_fixed_string_t dst_mask;
11368 	cmdline_ipaddr_t ipv4_dst;
11369 	cmdline_ipaddr_t ipv6_dst;
11370 	uint16_t port_dst;
11371 	cmdline_fixed_string_t mac;
11372 	uint8_t mac_addr_byte_mask;
11373 	cmdline_fixed_string_t tunnel_id;
11374 	uint32_t tunnel_id_mask;
11375 	cmdline_fixed_string_t tunnel_type;
11376 	uint8_t tunnel_type_mask;
11377 };
11378 
11379 static void
11380 cmd_flow_director_mask_parsed(void *parsed_result,
11381 			  __attribute__((unused)) struct cmdline *cl,
11382 			  __attribute__((unused)) void *data)
11383 {
11384 	struct cmd_flow_director_mask_result *res = parsed_result;
11385 	struct rte_eth_fdir_masks *mask;
11386 	struct rte_port *port;
11387 
11388 	port = &ports[res->port_id];
11389 	/** Check if the port is not started **/
11390 	if (port->port_status != RTE_PORT_STOPPED) {
11391 		printf("Please stop port %d first\n", res->port_id);
11392 		return;
11393 	}
11394 
11395 	mask = &port->dev_conf.fdir_conf.mask;
11396 
11397 	if (fdir_conf.mode ==  RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
11398 		if (strcmp(res->mode_value, "MAC-VLAN")) {
11399 			printf("Please set mode to MAC-VLAN.\n");
11400 			return;
11401 		}
11402 
11403 		mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11404 	} else if (fdir_conf.mode ==  RTE_FDIR_MODE_PERFECT_TUNNEL) {
11405 		if (strcmp(res->mode_value, "Tunnel")) {
11406 			printf("Please set mode to Tunnel.\n");
11407 			return;
11408 		}
11409 
11410 		mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11411 		mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
11412 		mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
11413 		mask->tunnel_type_mask = res->tunnel_type_mask;
11414 	} else {
11415 		if (strcmp(res->mode_value, "IP")) {
11416 			printf("Please set mode to IP.\n");
11417 			return;
11418 		}
11419 
11420 		mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11421 		IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
11422 		IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
11423 		IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
11424 		IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
11425 		mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
11426 		mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
11427 	}
11428 
11429 	cmd_reconfig_device_queue(res->port_id, 1, 1);
11430 }
11431 
11432 cmdline_parse_token_string_t cmd_flow_director_mask =
11433 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11434 				 flow_director_mask, "flow_director_mask");
11435 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
11436 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11437 			      port_id, UINT16);
11438 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
11439 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11440 				 vlan, "vlan");
11441 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
11442 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11443 			      vlan_mask, UINT16);
11444 cmdline_parse_token_string_t cmd_flow_director_mask_src =
11445 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11446 				 src_mask, "src_mask");
11447 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
11448 	TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11449 				 ipv4_src);
11450 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
11451 	TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11452 				 ipv6_src);
11453 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
11454 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11455 			      port_src, UINT16);
11456 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
11457 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11458 				 dst_mask, "dst_mask");
11459 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
11460 	TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11461 				 ipv4_dst);
11462 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
11463 	TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11464 				 ipv6_dst);
11465 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
11466 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11467 			      port_dst, UINT16);
11468 
11469 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
11470 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11471 				 mode, "mode");
11472 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
11473 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11474 				 mode_value, "IP");
11475 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
11476 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11477 				 mode_value, "MAC-VLAN");
11478 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
11479 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11480 				 mode_value, "Tunnel");
11481 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
11482 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11483 				 mac, "mac");
11484 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
11485 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11486 			      mac_addr_byte_mask, UINT8);
11487 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
11488 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11489 				 tunnel_type, "tunnel-type");
11490 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
11491 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11492 			      tunnel_type_mask, UINT8);
11493 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
11494 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11495 				 tunnel_id, "tunnel-id");
11496 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
11497 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11498 			      tunnel_id_mask, UINT32);
11499 
11500 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
11501 	.f = cmd_flow_director_mask_parsed,
11502 	.data = NULL,
11503 	.help_str = "flow_director_mask ... : "
11504 		"Set IP mode flow director's mask on NIC",
11505 	.tokens = {
11506 		(void *)&cmd_flow_director_mask,
11507 		(void *)&cmd_flow_director_mask_port_id,
11508 		(void *)&cmd_flow_director_mask_mode,
11509 		(void *)&cmd_flow_director_mask_mode_ip,
11510 		(void *)&cmd_flow_director_mask_vlan,
11511 		(void *)&cmd_flow_director_mask_vlan_value,
11512 		(void *)&cmd_flow_director_mask_src,
11513 		(void *)&cmd_flow_director_mask_ipv4_src,
11514 		(void *)&cmd_flow_director_mask_ipv6_src,
11515 		(void *)&cmd_flow_director_mask_port_src,
11516 		(void *)&cmd_flow_director_mask_dst,
11517 		(void *)&cmd_flow_director_mask_ipv4_dst,
11518 		(void *)&cmd_flow_director_mask_ipv6_dst,
11519 		(void *)&cmd_flow_director_mask_port_dst,
11520 		NULL,
11521 	},
11522 };
11523 
11524 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
11525 	.f = cmd_flow_director_mask_parsed,
11526 	.data = NULL,
11527 	.help_str = "flow_director_mask ... : Set MAC VLAN mode "
11528 		"flow director's mask on NIC",
11529 	.tokens = {
11530 		(void *)&cmd_flow_director_mask,
11531 		(void *)&cmd_flow_director_mask_port_id,
11532 		(void *)&cmd_flow_director_mask_mode,
11533 		(void *)&cmd_flow_director_mask_mode_mac_vlan,
11534 		(void *)&cmd_flow_director_mask_vlan,
11535 		(void *)&cmd_flow_director_mask_vlan_value,
11536 		NULL,
11537 	},
11538 };
11539 
11540 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
11541 	.f = cmd_flow_director_mask_parsed,
11542 	.data = NULL,
11543 	.help_str = "flow_director_mask ... : Set tunnel mode "
11544 		"flow director's mask on NIC",
11545 	.tokens = {
11546 		(void *)&cmd_flow_director_mask,
11547 		(void *)&cmd_flow_director_mask_port_id,
11548 		(void *)&cmd_flow_director_mask_mode,
11549 		(void *)&cmd_flow_director_mask_mode_tunnel,
11550 		(void *)&cmd_flow_director_mask_vlan,
11551 		(void *)&cmd_flow_director_mask_vlan_value,
11552 		(void *)&cmd_flow_director_mask_mac,
11553 		(void *)&cmd_flow_director_mask_mac_value,
11554 		(void *)&cmd_flow_director_mask_tunnel_type,
11555 		(void *)&cmd_flow_director_mask_tunnel_type_value,
11556 		(void *)&cmd_flow_director_mask_tunnel_id,
11557 		(void *)&cmd_flow_director_mask_tunnel_id_value,
11558 		NULL,
11559 	},
11560 };
11561 
11562 /* *** deal with flow director mask on flexible payload *** */
11563 struct cmd_flow_director_flex_mask_result {
11564 	cmdline_fixed_string_t flow_director_flexmask;
11565 	portid_t port_id;
11566 	cmdline_fixed_string_t flow;
11567 	cmdline_fixed_string_t flow_type;
11568 	cmdline_fixed_string_t mask;
11569 };
11570 
11571 static void
11572 cmd_flow_director_flex_mask_parsed(void *parsed_result,
11573 			  __attribute__((unused)) struct cmdline *cl,
11574 			  __attribute__((unused)) void *data)
11575 {
11576 	struct cmd_flow_director_flex_mask_result *res = parsed_result;
11577 	struct rte_eth_fdir_info fdir_info;
11578 	struct rte_eth_fdir_flex_mask flex_mask;
11579 	struct rte_port *port;
11580 	uint64_t flow_type_mask;
11581 	uint16_t i;
11582 	int ret;
11583 
11584 	port = &ports[res->port_id];
11585 	/** Check if the port is not started **/
11586 	if (port->port_status != RTE_PORT_STOPPED) {
11587 		printf("Please stop port %d first\n", res->port_id);
11588 		return;
11589 	}
11590 
11591 	memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
11592 	ret = parse_flexbytes(res->mask,
11593 			flex_mask.mask,
11594 			RTE_ETH_FDIR_MAX_FLEXLEN);
11595 	if (ret < 0) {
11596 		printf("error: Cannot parse mask input.\n");
11597 		return;
11598 	}
11599 
11600 	memset(&fdir_info, 0, sizeof(fdir_info));
11601 	ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11602 				RTE_ETH_FILTER_INFO, &fdir_info);
11603 	if (ret < 0) {
11604 		printf("Cannot get FDir filter info\n");
11605 		return;
11606 	}
11607 
11608 	if (!strcmp(res->flow_type, "none")) {
11609 		/* means don't specify the flow type */
11610 		flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
11611 		for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
11612 			memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
11613 			       0, sizeof(struct rte_eth_fdir_flex_mask));
11614 		port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
11615 		rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
11616 				 &flex_mask,
11617 				 sizeof(struct rte_eth_fdir_flex_mask));
11618 		cmd_reconfig_device_queue(res->port_id, 1, 1);
11619 		return;
11620 	}
11621 	flow_type_mask = fdir_info.flow_types_mask[0];
11622 	if (!strcmp(res->flow_type, "all")) {
11623 		if (!flow_type_mask) {
11624 			printf("No flow type supported\n");
11625 			return;
11626 		}
11627 		for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
11628 			if (flow_type_mask & (1ULL << i)) {
11629 				flex_mask.flow_type = i;
11630 				fdir_set_flex_mask(res->port_id, &flex_mask);
11631 			}
11632 		}
11633 		cmd_reconfig_device_queue(res->port_id, 1, 1);
11634 		return;
11635 	}
11636 	flex_mask.flow_type = str2flowtype(res->flow_type);
11637 	if (!(flow_type_mask & (1ULL << flex_mask.flow_type))) {
11638 		printf("Flow type %s not supported on port %d\n",
11639 				res->flow_type, res->port_id);
11640 		return;
11641 	}
11642 	fdir_set_flex_mask(res->port_id, &flex_mask);
11643 	cmd_reconfig_device_queue(res->port_id, 1, 1);
11644 }
11645 
11646 cmdline_parse_token_string_t cmd_flow_director_flexmask =
11647 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11648 				 flow_director_flexmask,
11649 				 "flow_director_flex_mask");
11650 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
11651 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11652 			      port_id, UINT16);
11653 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
11654 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11655 				 flow, "flow");
11656 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
11657 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11658 		flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
11659 		"ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
11660 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
11661 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11662 				 mask, NULL);
11663 
11664 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
11665 	.f = cmd_flow_director_flex_mask_parsed,
11666 	.data = NULL,
11667 	.help_str = "flow_director_flex_mask ... : "
11668 		"Set flow director's flex mask on NIC",
11669 	.tokens = {
11670 		(void *)&cmd_flow_director_flexmask,
11671 		(void *)&cmd_flow_director_flexmask_port_id,
11672 		(void *)&cmd_flow_director_flexmask_flow,
11673 		(void *)&cmd_flow_director_flexmask_flow_type,
11674 		(void *)&cmd_flow_director_flexmask_mask,
11675 		NULL,
11676 	},
11677 };
11678 
11679 /* *** deal with flow director flexible payload configuration *** */
11680 struct cmd_flow_director_flexpayload_result {
11681 	cmdline_fixed_string_t flow_director_flexpayload;
11682 	portid_t port_id;
11683 	cmdline_fixed_string_t payload_layer;
11684 	cmdline_fixed_string_t payload_cfg;
11685 };
11686 
11687 static inline int
11688 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
11689 {
11690 	char s[256];
11691 	const char *p, *p0 = q_arg;
11692 	char *end;
11693 	unsigned long int_fld;
11694 	char *str_fld[max_num];
11695 	int i;
11696 	unsigned size;
11697 	int ret = -1;
11698 
11699 	p = strchr(p0, '(');
11700 	if (p == NULL)
11701 		return -1;
11702 	++p;
11703 	p0 = strchr(p, ')');
11704 	if (p0 == NULL)
11705 		return -1;
11706 
11707 	size = p0 - p;
11708 	if (size >= sizeof(s))
11709 		return -1;
11710 
11711 	snprintf(s, sizeof(s), "%.*s", size, p);
11712 	ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
11713 	if (ret < 0 || ret > max_num)
11714 		return -1;
11715 	for (i = 0; i < ret; i++) {
11716 		errno = 0;
11717 		int_fld = strtoul(str_fld[i], &end, 0);
11718 		if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
11719 			return -1;
11720 		offsets[i] = (uint16_t)int_fld;
11721 	}
11722 	return ret;
11723 }
11724 
11725 static void
11726 cmd_flow_director_flxpld_parsed(void *parsed_result,
11727 			  __attribute__((unused)) struct cmdline *cl,
11728 			  __attribute__((unused)) void *data)
11729 {
11730 	struct cmd_flow_director_flexpayload_result *res = parsed_result;
11731 	struct rte_eth_flex_payload_cfg flex_cfg;
11732 	struct rte_port *port;
11733 	int ret = 0;
11734 
11735 	port = &ports[res->port_id];
11736 	/** Check if the port is not started **/
11737 	if (port->port_status != RTE_PORT_STOPPED) {
11738 		printf("Please stop port %d first\n", res->port_id);
11739 		return;
11740 	}
11741 
11742 	memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
11743 
11744 	if (!strcmp(res->payload_layer, "raw"))
11745 		flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
11746 	else if (!strcmp(res->payload_layer, "l2"))
11747 		flex_cfg.type = RTE_ETH_L2_PAYLOAD;
11748 	else if (!strcmp(res->payload_layer, "l3"))
11749 		flex_cfg.type = RTE_ETH_L3_PAYLOAD;
11750 	else if (!strcmp(res->payload_layer, "l4"))
11751 		flex_cfg.type = RTE_ETH_L4_PAYLOAD;
11752 
11753 	ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
11754 			    RTE_ETH_FDIR_MAX_FLEXLEN);
11755 	if (ret < 0) {
11756 		printf("error: Cannot parse flex payload input.\n");
11757 		return;
11758 	}
11759 
11760 	fdir_set_flex_payload(res->port_id, &flex_cfg);
11761 	cmd_reconfig_device_queue(res->port_id, 1, 1);
11762 }
11763 
11764 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
11765 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11766 				 flow_director_flexpayload,
11767 				 "flow_director_flex_payload");
11768 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
11769 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11770 			      port_id, UINT16);
11771 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
11772 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11773 				 payload_layer, "raw#l2#l3#l4");
11774 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
11775 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11776 				 payload_cfg, NULL);
11777 
11778 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
11779 	.f = cmd_flow_director_flxpld_parsed,
11780 	.data = NULL,
11781 	.help_str = "flow_director_flexpayload ... : "
11782 		"Set flow director's flex payload on NIC",
11783 	.tokens = {
11784 		(void *)&cmd_flow_director_flexpayload,
11785 		(void *)&cmd_flow_director_flexpayload_port_id,
11786 		(void *)&cmd_flow_director_flexpayload_payload_layer,
11787 		(void *)&cmd_flow_director_flexpayload_payload_cfg,
11788 		NULL,
11789 	},
11790 };
11791 
11792 /* Generic flow interface command. */
11793 extern cmdline_parse_inst_t cmd_flow;
11794 
11795 /* *** Classification Filters Control *** */
11796 /* *** Get symmetric hash enable per port *** */
11797 struct cmd_get_sym_hash_ena_per_port_result {
11798 	cmdline_fixed_string_t get_sym_hash_ena_per_port;
11799 	portid_t port_id;
11800 };
11801 
11802 static void
11803 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
11804 				 __rte_unused struct cmdline *cl,
11805 				 __rte_unused void *data)
11806 {
11807 	struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
11808 	struct rte_eth_hash_filter_info info;
11809 	int ret;
11810 
11811 	if (rte_eth_dev_filter_supported(res->port_id,
11812 				RTE_ETH_FILTER_HASH) < 0) {
11813 		printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
11814 							res->port_id);
11815 		return;
11816 	}
11817 
11818 	memset(&info, 0, sizeof(info));
11819 	info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
11820 	ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11821 						RTE_ETH_FILTER_GET, &info);
11822 
11823 	if (ret < 0) {
11824 		printf("Cannot get symmetric hash enable per port "
11825 					"on port %u\n", res->port_id);
11826 		return;
11827 	}
11828 
11829 	printf("Symmetric hash is %s on port %u\n", info.info.enable ?
11830 				"enabled" : "disabled", res->port_id);
11831 }
11832 
11833 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
11834 	TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
11835 		get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
11836 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
11837 	TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
11838 		port_id, UINT16);
11839 
11840 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
11841 	.f = cmd_get_sym_hash_per_port_parsed,
11842 	.data = NULL,
11843 	.help_str = "get_sym_hash_ena_per_port <port_id>",
11844 	.tokens = {
11845 		(void *)&cmd_get_sym_hash_ena_per_port_all,
11846 		(void *)&cmd_get_sym_hash_ena_per_port_port_id,
11847 		NULL,
11848 	},
11849 };
11850 
11851 /* *** Set symmetric hash enable per port *** */
11852 struct cmd_set_sym_hash_ena_per_port_result {
11853 	cmdline_fixed_string_t set_sym_hash_ena_per_port;
11854 	cmdline_fixed_string_t enable;
11855 	portid_t port_id;
11856 };
11857 
11858 static void
11859 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
11860 				 __rte_unused struct cmdline *cl,
11861 				 __rte_unused void *data)
11862 {
11863 	struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
11864 	struct rte_eth_hash_filter_info info;
11865 	int ret;
11866 
11867 	if (rte_eth_dev_filter_supported(res->port_id,
11868 				RTE_ETH_FILTER_HASH) < 0) {
11869 		printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
11870 							res->port_id);
11871 		return;
11872 	}
11873 
11874 	memset(&info, 0, sizeof(info));
11875 	info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
11876 	if (!strcmp(res->enable, "enable"))
11877 		info.info.enable = 1;
11878 	ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11879 					RTE_ETH_FILTER_SET, &info);
11880 	if (ret < 0) {
11881 		printf("Cannot set symmetric hash enable per port on "
11882 					"port %u\n", res->port_id);
11883 		return;
11884 	}
11885 	printf("Symmetric hash has been set to %s on port %u\n",
11886 					res->enable, res->port_id);
11887 }
11888 
11889 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
11890 	TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11891 		set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
11892 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
11893 	TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11894 		port_id, UINT16);
11895 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
11896 	TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11897 		enable, "enable#disable");
11898 
11899 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
11900 	.f = cmd_set_sym_hash_per_port_parsed,
11901 	.data = NULL,
11902 	.help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
11903 	.tokens = {
11904 		(void *)&cmd_set_sym_hash_ena_per_port_all,
11905 		(void *)&cmd_set_sym_hash_ena_per_port_port_id,
11906 		(void *)&cmd_set_sym_hash_ena_per_port_enable,
11907 		NULL,
11908 	},
11909 };
11910 
11911 /* Get global config of hash function */
11912 struct cmd_get_hash_global_config_result {
11913 	cmdline_fixed_string_t get_hash_global_config;
11914 	portid_t port_id;
11915 };
11916 
11917 static char *
11918 flowtype_to_str(uint16_t ftype)
11919 {
11920 	uint16_t i;
11921 	static struct {
11922 		char str[16];
11923 		uint16_t ftype;
11924 	} ftype_table[] = {
11925 		{"ipv4", RTE_ETH_FLOW_IPV4},
11926 		{"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
11927 		{"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
11928 		{"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
11929 		{"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
11930 		{"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
11931 		{"ipv6", RTE_ETH_FLOW_IPV6},
11932 		{"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
11933 		{"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
11934 		{"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
11935 		{"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
11936 		{"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
11937 		{"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
11938 		{"port", RTE_ETH_FLOW_PORT},
11939 		{"vxlan", RTE_ETH_FLOW_VXLAN},
11940 		{"geneve", RTE_ETH_FLOW_GENEVE},
11941 		{"nvgre", RTE_ETH_FLOW_NVGRE},
11942 	};
11943 
11944 	for (i = 0; i < RTE_DIM(ftype_table); i++) {
11945 		if (ftype_table[i].ftype == ftype)
11946 			return ftype_table[i].str;
11947 	}
11948 
11949 	return NULL;
11950 }
11951 
11952 static void
11953 cmd_get_hash_global_config_parsed(void *parsed_result,
11954 				  __rte_unused struct cmdline *cl,
11955 				  __rte_unused void *data)
11956 {
11957 	struct cmd_get_hash_global_config_result *res = parsed_result;
11958 	struct rte_eth_hash_filter_info info;
11959 	uint32_t idx, offset;
11960 	uint16_t i;
11961 	char *str;
11962 	int ret;
11963 
11964 	if (rte_eth_dev_filter_supported(res->port_id,
11965 			RTE_ETH_FILTER_HASH) < 0) {
11966 		printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
11967 							res->port_id);
11968 		return;
11969 	}
11970 
11971 	memset(&info, 0, sizeof(info));
11972 	info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
11973 	ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11974 					RTE_ETH_FILTER_GET, &info);
11975 	if (ret < 0) {
11976 		printf("Cannot get hash global configurations by port %d\n",
11977 							res->port_id);
11978 		return;
11979 	}
11980 
11981 	switch (info.info.global_conf.hash_func) {
11982 	case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
11983 		printf("Hash function is Toeplitz\n");
11984 		break;
11985 	case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
11986 		printf("Hash function is Simple XOR\n");
11987 		break;
11988 	default:
11989 		printf("Unknown hash function\n");
11990 		break;
11991 	}
11992 
11993 	for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
11994 		idx = i / UINT64_BIT;
11995 		offset = i % UINT64_BIT;
11996 		if (!(info.info.global_conf.valid_bit_mask[idx] &
11997 						(1ULL << offset)))
11998 			continue;
11999 		str = flowtype_to_str(i);
12000 		if (!str)
12001 			continue;
12002 		printf("Symmetric hash is %s globally for flow type %s "
12003 							"by port %d\n",
12004 			((info.info.global_conf.sym_hash_enable_mask[idx] &
12005 			(1ULL << offset)) ? "enabled" : "disabled"), str,
12006 							res->port_id);
12007 	}
12008 }
12009 
12010 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
12011 	TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
12012 		get_hash_global_config, "get_hash_global_config");
12013 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
12014 	TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
12015 		port_id, UINT16);
12016 
12017 cmdline_parse_inst_t cmd_get_hash_global_config = {
12018 	.f = cmd_get_hash_global_config_parsed,
12019 	.data = NULL,
12020 	.help_str = "get_hash_global_config <port_id>",
12021 	.tokens = {
12022 		(void *)&cmd_get_hash_global_config_all,
12023 		(void *)&cmd_get_hash_global_config_port_id,
12024 		NULL,
12025 	},
12026 };
12027 
12028 /* Set global config of hash function */
12029 struct cmd_set_hash_global_config_result {
12030 	cmdline_fixed_string_t set_hash_global_config;
12031 	portid_t port_id;
12032 	cmdline_fixed_string_t hash_func;
12033 	cmdline_fixed_string_t flow_type;
12034 	cmdline_fixed_string_t enable;
12035 };
12036 
12037 static void
12038 cmd_set_hash_global_config_parsed(void *parsed_result,
12039 				  __rte_unused struct cmdline *cl,
12040 				  __rte_unused void *data)
12041 {
12042 	struct cmd_set_hash_global_config_result *res = parsed_result;
12043 	struct rte_eth_hash_filter_info info;
12044 	uint32_t ftype, idx, offset;
12045 	int ret;
12046 
12047 	if (rte_eth_dev_filter_supported(res->port_id,
12048 				RTE_ETH_FILTER_HASH) < 0) {
12049 		printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
12050 							res->port_id);
12051 		return;
12052 	}
12053 	memset(&info, 0, sizeof(info));
12054 	info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
12055 	if (!strcmp(res->hash_func, "toeplitz"))
12056 		info.info.global_conf.hash_func =
12057 			RTE_ETH_HASH_FUNCTION_TOEPLITZ;
12058 	else if (!strcmp(res->hash_func, "simple_xor"))
12059 		info.info.global_conf.hash_func =
12060 			RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
12061 	else if (!strcmp(res->hash_func, "default"))
12062 		info.info.global_conf.hash_func =
12063 			RTE_ETH_HASH_FUNCTION_DEFAULT;
12064 
12065 	ftype = str2flowtype(res->flow_type);
12066 	idx = ftype / UINT64_BIT;
12067 	offset = ftype % UINT64_BIT;
12068 	info.info.global_conf.valid_bit_mask[idx] |= (1ULL << offset);
12069 	if (!strcmp(res->enable, "enable"))
12070 		info.info.global_conf.sym_hash_enable_mask[idx] |=
12071 						(1ULL << offset);
12072 	ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12073 					RTE_ETH_FILTER_SET, &info);
12074 	if (ret < 0)
12075 		printf("Cannot set global hash configurations by port %d\n",
12076 							res->port_id);
12077 	else
12078 		printf("Global hash configurations have been set "
12079 			"succcessfully by port %d\n", res->port_id);
12080 }
12081 
12082 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
12083 	TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12084 		set_hash_global_config, "set_hash_global_config");
12085 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
12086 	TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
12087 		port_id, UINT16);
12088 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
12089 	TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12090 		hash_func, "toeplitz#simple_xor#default");
12091 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
12092 	TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12093 		flow_type,
12094 		"ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
12095 		"ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12096 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
12097 	TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12098 		enable, "enable#disable");
12099 
12100 cmdline_parse_inst_t cmd_set_hash_global_config = {
12101 	.f = cmd_set_hash_global_config_parsed,
12102 	.data = NULL,
12103 	.help_str = "set_hash_global_config <port_id> "
12104 		"toeplitz|simple_xor|default "
12105 		"ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12106 		"ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
12107 		"l2_payload enable|disable",
12108 	.tokens = {
12109 		(void *)&cmd_set_hash_global_config_all,
12110 		(void *)&cmd_set_hash_global_config_port_id,
12111 		(void *)&cmd_set_hash_global_config_hash_func,
12112 		(void *)&cmd_set_hash_global_config_flow_type,
12113 		(void *)&cmd_set_hash_global_config_enable,
12114 		NULL,
12115 	},
12116 };
12117 
12118 /* Set hash input set */
12119 struct cmd_set_hash_input_set_result {
12120 	cmdline_fixed_string_t set_hash_input_set;
12121 	portid_t port_id;
12122 	cmdline_fixed_string_t flow_type;
12123 	cmdline_fixed_string_t inset_field;
12124 	cmdline_fixed_string_t select;
12125 };
12126 
12127 static enum rte_eth_input_set_field
12128 str2inset(char *string)
12129 {
12130 	uint16_t i;
12131 
12132 	static const struct {
12133 		char str[32];
12134 		enum rte_eth_input_set_field inset;
12135 	} inset_table[] = {
12136 		{"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
12137 		{"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
12138 		{"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
12139 		{"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
12140 		{"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
12141 		{"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
12142 		{"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
12143 		{"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
12144 		{"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
12145 		{"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
12146 		{"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
12147 		{"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
12148 		{"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
12149 		{"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
12150 		{"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
12151 		{"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
12152 		{"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
12153 		{"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
12154 		{"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
12155 		{"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
12156 		{"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
12157 		{"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
12158 		{"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
12159 		{"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
12160 		{"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
12161 		{"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
12162 		{"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
12163 		{"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
12164 		{"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
12165 		{"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
12166 		{"none", RTE_ETH_INPUT_SET_NONE},
12167 	};
12168 
12169 	for (i = 0; i < RTE_DIM(inset_table); i++) {
12170 		if (!strcmp(string, inset_table[i].str))
12171 			return inset_table[i].inset;
12172 	}
12173 
12174 	return RTE_ETH_INPUT_SET_UNKNOWN;
12175 }
12176 
12177 static void
12178 cmd_set_hash_input_set_parsed(void *parsed_result,
12179 			      __rte_unused struct cmdline *cl,
12180 			      __rte_unused void *data)
12181 {
12182 	struct cmd_set_hash_input_set_result *res = parsed_result;
12183 	struct rte_eth_hash_filter_info info;
12184 
12185 	memset(&info, 0, sizeof(info));
12186 	info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
12187 	info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12188 	info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12189 	info.info.input_set_conf.inset_size = 1;
12190 	if (!strcmp(res->select, "select"))
12191 		info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12192 	else if (!strcmp(res->select, "add"))
12193 		info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12194 	rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12195 				RTE_ETH_FILTER_SET, &info);
12196 }
12197 
12198 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
12199 	TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12200 		set_hash_input_set, "set_hash_input_set");
12201 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
12202 	TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
12203 		port_id, UINT16);
12204 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
12205 	TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12206 		flow_type, NULL);
12207 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
12208 	TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12209 		inset_field,
12210 		"ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12211 		"ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
12212 		"udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
12213 		"sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
12214 		"fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
12215 		"fld-8th#none");
12216 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
12217 	TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12218 		select, "select#add");
12219 
12220 cmdline_parse_inst_t cmd_set_hash_input_set = {
12221 	.f = cmd_set_hash_input_set_parsed,
12222 	.data = NULL,
12223 	.help_str = "set_hash_input_set <port_id> "
12224 	"ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12225 	"ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
12226 	"ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
12227 	"ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
12228 	"tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
12229 	"gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
12230 	"fld-7th|fld-8th|none select|add",
12231 	.tokens = {
12232 		(void *)&cmd_set_hash_input_set_cmd,
12233 		(void *)&cmd_set_hash_input_set_port_id,
12234 		(void *)&cmd_set_hash_input_set_flow_type,
12235 		(void *)&cmd_set_hash_input_set_field,
12236 		(void *)&cmd_set_hash_input_set_select,
12237 		NULL,
12238 	},
12239 };
12240 
12241 /* Set flow director input set */
12242 struct cmd_set_fdir_input_set_result {
12243 	cmdline_fixed_string_t set_fdir_input_set;
12244 	portid_t port_id;
12245 	cmdline_fixed_string_t flow_type;
12246 	cmdline_fixed_string_t inset_field;
12247 	cmdline_fixed_string_t select;
12248 };
12249 
12250 static void
12251 cmd_set_fdir_input_set_parsed(void *parsed_result,
12252 	__rte_unused struct cmdline *cl,
12253 	__rte_unused void *data)
12254 {
12255 	struct cmd_set_fdir_input_set_result *res = parsed_result;
12256 	struct rte_eth_fdir_filter_info info;
12257 
12258 	memset(&info, 0, sizeof(info));
12259 	info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
12260 	info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12261 	info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12262 	info.info.input_set_conf.inset_size = 1;
12263 	if (!strcmp(res->select, "select"))
12264 		info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12265 	else if (!strcmp(res->select, "add"))
12266 		info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12267 	rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
12268 		RTE_ETH_FILTER_SET, &info);
12269 }
12270 
12271 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
12272 	TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12273 	set_fdir_input_set, "set_fdir_input_set");
12274 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
12275 	TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
12276 	port_id, UINT16);
12277 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
12278 	TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12279 	flow_type,
12280 	"ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
12281 	"ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12282 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
12283 	TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12284 	inset_field,
12285 	"ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12286 	"ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
12287 	"ipv6-hop-limits#udp-src-port#udp-dst-port#"
12288 	"tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
12289 	"sctp-veri-tag#none");
12290 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
12291 	TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12292 	select, "select#add");
12293 
12294 cmdline_parse_inst_t cmd_set_fdir_input_set = {
12295 	.f = cmd_set_fdir_input_set_parsed,
12296 	.data = NULL,
12297 	.help_str = "set_fdir_input_set <port_id> "
12298 	"ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12299 	"ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
12300 	"ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
12301 	"ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
12302 	"ipv6-hop-limits|udp-src-port|udp-dst-port|"
12303 	"tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
12304 	"sctp-veri-tag|none select|add",
12305 	.tokens = {
12306 		(void *)&cmd_set_fdir_input_set_cmd,
12307 		(void *)&cmd_set_fdir_input_set_port_id,
12308 		(void *)&cmd_set_fdir_input_set_flow_type,
12309 		(void *)&cmd_set_fdir_input_set_field,
12310 		(void *)&cmd_set_fdir_input_set_select,
12311 		NULL,
12312 	},
12313 };
12314 
12315 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
12316 struct cmd_mcast_addr_result {
12317 	cmdline_fixed_string_t mcast_addr_cmd;
12318 	cmdline_fixed_string_t what;
12319 	uint16_t port_num;
12320 	struct ether_addr mc_addr;
12321 };
12322 
12323 static void cmd_mcast_addr_parsed(void *parsed_result,
12324 		__attribute__((unused)) struct cmdline *cl,
12325 		__attribute__((unused)) void *data)
12326 {
12327 	struct cmd_mcast_addr_result *res = parsed_result;
12328 
12329 	if (!is_multicast_ether_addr(&res->mc_addr)) {
12330 		printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
12331 		       res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
12332 		       res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
12333 		       res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
12334 		return;
12335 	}
12336 	if (strcmp(res->what, "add") == 0)
12337 		mcast_addr_add(res->port_num, &res->mc_addr);
12338 	else
12339 		mcast_addr_remove(res->port_num, &res->mc_addr);
12340 }
12341 
12342 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
12343 	TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
12344 				 mcast_addr_cmd, "mcast_addr");
12345 cmdline_parse_token_string_t cmd_mcast_addr_what =
12346 	TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
12347 				 "add#remove");
12348 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
12349 	TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
12350 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
12351 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
12352 
12353 cmdline_parse_inst_t cmd_mcast_addr = {
12354 	.f = cmd_mcast_addr_parsed,
12355 	.data = (void *)0,
12356 	.help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
12357 		"Add/Remove multicast MAC address on port_id",
12358 	.tokens = {
12359 		(void *)&cmd_mcast_addr_cmd,
12360 		(void *)&cmd_mcast_addr_what,
12361 		(void *)&cmd_mcast_addr_portnum,
12362 		(void *)&cmd_mcast_addr_addr,
12363 		NULL,
12364 	},
12365 };
12366 
12367 /* l2 tunnel config
12368  * only support E-tag now.
12369  */
12370 
12371 /* Ether type config */
12372 struct cmd_config_l2_tunnel_eth_type_result {
12373 	cmdline_fixed_string_t port;
12374 	cmdline_fixed_string_t config;
12375 	cmdline_fixed_string_t all;
12376 	portid_t id;
12377 	cmdline_fixed_string_t l2_tunnel;
12378 	cmdline_fixed_string_t l2_tunnel_type;
12379 	cmdline_fixed_string_t eth_type;
12380 	uint16_t eth_type_val;
12381 };
12382 
12383 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
12384 	TOKEN_STRING_INITIALIZER
12385 		(struct cmd_config_l2_tunnel_eth_type_result,
12386 		 port, "port");
12387 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
12388 	TOKEN_STRING_INITIALIZER
12389 		(struct cmd_config_l2_tunnel_eth_type_result,
12390 		 config, "config");
12391 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
12392 	TOKEN_STRING_INITIALIZER
12393 		(struct cmd_config_l2_tunnel_eth_type_result,
12394 		 all, "all");
12395 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
12396 	TOKEN_NUM_INITIALIZER
12397 		(struct cmd_config_l2_tunnel_eth_type_result,
12398 		 id, UINT16);
12399 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
12400 	TOKEN_STRING_INITIALIZER
12401 		(struct cmd_config_l2_tunnel_eth_type_result,
12402 		 l2_tunnel, "l2-tunnel");
12403 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
12404 	TOKEN_STRING_INITIALIZER
12405 		(struct cmd_config_l2_tunnel_eth_type_result,
12406 		 l2_tunnel_type, "E-tag");
12407 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
12408 	TOKEN_STRING_INITIALIZER
12409 		(struct cmd_config_l2_tunnel_eth_type_result,
12410 		 eth_type, "ether-type");
12411 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
12412 	TOKEN_NUM_INITIALIZER
12413 		(struct cmd_config_l2_tunnel_eth_type_result,
12414 		 eth_type_val, UINT16);
12415 
12416 static enum rte_eth_tunnel_type
12417 str2fdir_l2_tunnel_type(char *string)
12418 {
12419 	uint32_t i = 0;
12420 
12421 	static const struct {
12422 		char str[32];
12423 		enum rte_eth_tunnel_type type;
12424 	} l2_tunnel_type_str[] = {
12425 		{"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
12426 	};
12427 
12428 	for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
12429 		if (!strcmp(l2_tunnel_type_str[i].str, string))
12430 			return l2_tunnel_type_str[i].type;
12431 	}
12432 	return RTE_TUNNEL_TYPE_NONE;
12433 }
12434 
12435 /* ether type config for all ports */
12436 static void
12437 cmd_config_l2_tunnel_eth_type_all_parsed
12438 	(void *parsed_result,
12439 	 __attribute__((unused)) struct cmdline *cl,
12440 	 __attribute__((unused)) void *data)
12441 {
12442 	struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
12443 	struct rte_eth_l2_tunnel_conf entry;
12444 	portid_t pid;
12445 
12446 	entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12447 	entry.ether_type = res->eth_type_val;
12448 
12449 	RTE_ETH_FOREACH_DEV(pid) {
12450 		rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
12451 	}
12452 }
12453 
12454 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
12455 	.f = cmd_config_l2_tunnel_eth_type_all_parsed,
12456 	.data = NULL,
12457 	.help_str = "port config all l2-tunnel E-tag ether-type <value>",
12458 	.tokens = {
12459 		(void *)&cmd_config_l2_tunnel_eth_type_port,
12460 		(void *)&cmd_config_l2_tunnel_eth_type_config,
12461 		(void *)&cmd_config_l2_tunnel_eth_type_all_str,
12462 		(void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12463 		(void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12464 		(void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12465 		(void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12466 		NULL,
12467 	},
12468 };
12469 
12470 /* ether type config for a specific port */
12471 static void
12472 cmd_config_l2_tunnel_eth_type_specific_parsed(
12473 	void *parsed_result,
12474 	__attribute__((unused)) struct cmdline *cl,
12475 	__attribute__((unused)) void *data)
12476 {
12477 	struct cmd_config_l2_tunnel_eth_type_result *res =
12478 		 parsed_result;
12479 	struct rte_eth_l2_tunnel_conf entry;
12480 
12481 	if (port_id_is_invalid(res->id, ENABLED_WARN))
12482 		return;
12483 
12484 	entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12485 	entry.ether_type = res->eth_type_val;
12486 
12487 	rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
12488 }
12489 
12490 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
12491 	.f = cmd_config_l2_tunnel_eth_type_specific_parsed,
12492 	.data = NULL,
12493 	.help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
12494 	.tokens = {
12495 		(void *)&cmd_config_l2_tunnel_eth_type_port,
12496 		(void *)&cmd_config_l2_tunnel_eth_type_config,
12497 		(void *)&cmd_config_l2_tunnel_eth_type_id,
12498 		(void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12499 		(void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12500 		(void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12501 		(void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12502 		NULL,
12503 	},
12504 };
12505 
12506 /* Enable/disable l2 tunnel */
12507 struct cmd_config_l2_tunnel_en_dis_result {
12508 	cmdline_fixed_string_t port;
12509 	cmdline_fixed_string_t config;
12510 	cmdline_fixed_string_t all;
12511 	portid_t id;
12512 	cmdline_fixed_string_t l2_tunnel;
12513 	cmdline_fixed_string_t l2_tunnel_type;
12514 	cmdline_fixed_string_t en_dis;
12515 };
12516 
12517 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
12518 	TOKEN_STRING_INITIALIZER
12519 		(struct cmd_config_l2_tunnel_en_dis_result,
12520 		 port, "port");
12521 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
12522 	TOKEN_STRING_INITIALIZER
12523 		(struct cmd_config_l2_tunnel_en_dis_result,
12524 		 config, "config");
12525 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
12526 	TOKEN_STRING_INITIALIZER
12527 		(struct cmd_config_l2_tunnel_en_dis_result,
12528 		 all, "all");
12529 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
12530 	TOKEN_NUM_INITIALIZER
12531 		(struct cmd_config_l2_tunnel_en_dis_result,
12532 		 id, UINT16);
12533 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
12534 	TOKEN_STRING_INITIALIZER
12535 		(struct cmd_config_l2_tunnel_en_dis_result,
12536 		 l2_tunnel, "l2-tunnel");
12537 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
12538 	TOKEN_STRING_INITIALIZER
12539 		(struct cmd_config_l2_tunnel_en_dis_result,
12540 		 l2_tunnel_type, "E-tag");
12541 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
12542 	TOKEN_STRING_INITIALIZER
12543 		(struct cmd_config_l2_tunnel_en_dis_result,
12544 		 en_dis, "enable#disable");
12545 
12546 /* enable/disable l2 tunnel for all ports */
12547 static void
12548 cmd_config_l2_tunnel_en_dis_all_parsed(
12549 	void *parsed_result,
12550 	__attribute__((unused)) struct cmdline *cl,
12551 	__attribute__((unused)) void *data)
12552 {
12553 	struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
12554 	struct rte_eth_l2_tunnel_conf entry;
12555 	portid_t pid;
12556 	uint8_t en;
12557 
12558 	entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12559 
12560 	if (!strcmp("enable", res->en_dis))
12561 		en = 1;
12562 	else
12563 		en = 0;
12564 
12565 	RTE_ETH_FOREACH_DEV(pid) {
12566 		rte_eth_dev_l2_tunnel_offload_set(pid,
12567 						  &entry,
12568 						  ETH_L2_TUNNEL_ENABLE_MASK,
12569 						  en);
12570 	}
12571 }
12572 
12573 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
12574 	.f = cmd_config_l2_tunnel_en_dis_all_parsed,
12575 	.data = NULL,
12576 	.help_str = "port config all l2-tunnel E-tag enable|disable",
12577 	.tokens = {
12578 		(void *)&cmd_config_l2_tunnel_en_dis_port,
12579 		(void *)&cmd_config_l2_tunnel_en_dis_config,
12580 		(void *)&cmd_config_l2_tunnel_en_dis_all_str,
12581 		(void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12582 		(void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12583 		(void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12584 		NULL,
12585 	},
12586 };
12587 
12588 /* enable/disable l2 tunnel for a port */
12589 static void
12590 cmd_config_l2_tunnel_en_dis_specific_parsed(
12591 	void *parsed_result,
12592 	__attribute__((unused)) struct cmdline *cl,
12593 	__attribute__((unused)) void *data)
12594 {
12595 	struct cmd_config_l2_tunnel_en_dis_result *res =
12596 		parsed_result;
12597 	struct rte_eth_l2_tunnel_conf entry;
12598 
12599 	if (port_id_is_invalid(res->id, ENABLED_WARN))
12600 		return;
12601 
12602 	entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12603 
12604 	if (!strcmp("enable", res->en_dis))
12605 		rte_eth_dev_l2_tunnel_offload_set(res->id,
12606 						  &entry,
12607 						  ETH_L2_TUNNEL_ENABLE_MASK,
12608 						  1);
12609 	else
12610 		rte_eth_dev_l2_tunnel_offload_set(res->id,
12611 						  &entry,
12612 						  ETH_L2_TUNNEL_ENABLE_MASK,
12613 						  0);
12614 }
12615 
12616 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
12617 	.f = cmd_config_l2_tunnel_en_dis_specific_parsed,
12618 	.data = NULL,
12619 	.help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
12620 	.tokens = {
12621 		(void *)&cmd_config_l2_tunnel_en_dis_port,
12622 		(void *)&cmd_config_l2_tunnel_en_dis_config,
12623 		(void *)&cmd_config_l2_tunnel_en_dis_id,
12624 		(void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12625 		(void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12626 		(void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12627 		NULL,
12628 	},
12629 };
12630 
12631 /* E-tag configuration */
12632 
12633 /* Common result structure for all E-tag configuration */
12634 struct cmd_config_e_tag_result {
12635 	cmdline_fixed_string_t e_tag;
12636 	cmdline_fixed_string_t set;
12637 	cmdline_fixed_string_t insertion;
12638 	cmdline_fixed_string_t stripping;
12639 	cmdline_fixed_string_t forwarding;
12640 	cmdline_fixed_string_t filter;
12641 	cmdline_fixed_string_t add;
12642 	cmdline_fixed_string_t del;
12643 	cmdline_fixed_string_t on;
12644 	cmdline_fixed_string_t off;
12645 	cmdline_fixed_string_t on_off;
12646 	cmdline_fixed_string_t port_tag_id;
12647 	uint32_t port_tag_id_val;
12648 	cmdline_fixed_string_t e_tag_id;
12649 	uint16_t e_tag_id_val;
12650 	cmdline_fixed_string_t dst_pool;
12651 	uint8_t dst_pool_val;
12652 	cmdline_fixed_string_t port;
12653 	portid_t port_id;
12654 	cmdline_fixed_string_t vf;
12655 	uint8_t vf_id;
12656 };
12657 
12658 /* Common CLI fields for all E-tag configuration */
12659 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
12660 	TOKEN_STRING_INITIALIZER
12661 		(struct cmd_config_e_tag_result,
12662 		 e_tag, "E-tag");
12663 cmdline_parse_token_string_t cmd_config_e_tag_set =
12664 	TOKEN_STRING_INITIALIZER
12665 		(struct cmd_config_e_tag_result,
12666 		 set, "set");
12667 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
12668 	TOKEN_STRING_INITIALIZER
12669 		(struct cmd_config_e_tag_result,
12670 		 insertion, "insertion");
12671 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
12672 	TOKEN_STRING_INITIALIZER
12673 		(struct cmd_config_e_tag_result,
12674 		 stripping, "stripping");
12675 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
12676 	TOKEN_STRING_INITIALIZER
12677 		(struct cmd_config_e_tag_result,
12678 		 forwarding, "forwarding");
12679 cmdline_parse_token_string_t cmd_config_e_tag_filter =
12680 	TOKEN_STRING_INITIALIZER
12681 		(struct cmd_config_e_tag_result,
12682 		 filter, "filter");
12683 cmdline_parse_token_string_t cmd_config_e_tag_add =
12684 	TOKEN_STRING_INITIALIZER
12685 		(struct cmd_config_e_tag_result,
12686 		 add, "add");
12687 cmdline_parse_token_string_t cmd_config_e_tag_del =
12688 	TOKEN_STRING_INITIALIZER
12689 		(struct cmd_config_e_tag_result,
12690 		 del, "del");
12691 cmdline_parse_token_string_t cmd_config_e_tag_on =
12692 	TOKEN_STRING_INITIALIZER
12693 		(struct cmd_config_e_tag_result,
12694 		 on, "on");
12695 cmdline_parse_token_string_t cmd_config_e_tag_off =
12696 	TOKEN_STRING_INITIALIZER
12697 		(struct cmd_config_e_tag_result,
12698 		 off, "off");
12699 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
12700 	TOKEN_STRING_INITIALIZER
12701 		(struct cmd_config_e_tag_result,
12702 		 on_off, "on#off");
12703 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
12704 	TOKEN_STRING_INITIALIZER
12705 		(struct cmd_config_e_tag_result,
12706 		 port_tag_id, "port-tag-id");
12707 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
12708 	TOKEN_NUM_INITIALIZER
12709 		(struct cmd_config_e_tag_result,
12710 		 port_tag_id_val, UINT32);
12711 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
12712 	TOKEN_STRING_INITIALIZER
12713 		(struct cmd_config_e_tag_result,
12714 		 e_tag_id, "e-tag-id");
12715 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
12716 	TOKEN_NUM_INITIALIZER
12717 		(struct cmd_config_e_tag_result,
12718 		 e_tag_id_val, UINT16);
12719 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
12720 	TOKEN_STRING_INITIALIZER
12721 		(struct cmd_config_e_tag_result,
12722 		 dst_pool, "dst-pool");
12723 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
12724 	TOKEN_NUM_INITIALIZER
12725 		(struct cmd_config_e_tag_result,
12726 		 dst_pool_val, UINT8);
12727 cmdline_parse_token_string_t cmd_config_e_tag_port =
12728 	TOKEN_STRING_INITIALIZER
12729 		(struct cmd_config_e_tag_result,
12730 		 port, "port");
12731 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
12732 	TOKEN_NUM_INITIALIZER
12733 		(struct cmd_config_e_tag_result,
12734 		 port_id, UINT16);
12735 cmdline_parse_token_string_t cmd_config_e_tag_vf =
12736 	TOKEN_STRING_INITIALIZER
12737 		(struct cmd_config_e_tag_result,
12738 		 vf, "vf");
12739 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
12740 	TOKEN_NUM_INITIALIZER
12741 		(struct cmd_config_e_tag_result,
12742 		 vf_id, UINT8);
12743 
12744 /* E-tag insertion configuration */
12745 static void
12746 cmd_config_e_tag_insertion_en_parsed(
12747 	void *parsed_result,
12748 	__attribute__((unused)) struct cmdline *cl,
12749 	__attribute__((unused)) void *data)
12750 {
12751 	struct cmd_config_e_tag_result *res =
12752 		parsed_result;
12753 	struct rte_eth_l2_tunnel_conf entry;
12754 
12755 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12756 		return;
12757 
12758 	entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12759 	entry.tunnel_id = res->port_tag_id_val;
12760 	entry.vf_id = res->vf_id;
12761 	rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12762 					  &entry,
12763 					  ETH_L2_TUNNEL_INSERTION_MASK,
12764 					  1);
12765 }
12766 
12767 static void
12768 cmd_config_e_tag_insertion_dis_parsed(
12769 	void *parsed_result,
12770 	__attribute__((unused)) struct cmdline *cl,
12771 	__attribute__((unused)) void *data)
12772 {
12773 	struct cmd_config_e_tag_result *res =
12774 		parsed_result;
12775 	struct rte_eth_l2_tunnel_conf entry;
12776 
12777 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12778 		return;
12779 
12780 	entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12781 	entry.vf_id = res->vf_id;
12782 
12783 	rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12784 					  &entry,
12785 					  ETH_L2_TUNNEL_INSERTION_MASK,
12786 					  0);
12787 }
12788 
12789 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
12790 	.f = cmd_config_e_tag_insertion_en_parsed,
12791 	.data = NULL,
12792 	.help_str = "E-tag ... : E-tag insertion enable",
12793 	.tokens = {
12794 		(void *)&cmd_config_e_tag_e_tag,
12795 		(void *)&cmd_config_e_tag_set,
12796 		(void *)&cmd_config_e_tag_insertion,
12797 		(void *)&cmd_config_e_tag_on,
12798 		(void *)&cmd_config_e_tag_port_tag_id,
12799 		(void *)&cmd_config_e_tag_port_tag_id_val,
12800 		(void *)&cmd_config_e_tag_port,
12801 		(void *)&cmd_config_e_tag_port_id,
12802 		(void *)&cmd_config_e_tag_vf,
12803 		(void *)&cmd_config_e_tag_vf_id,
12804 		NULL,
12805 	},
12806 };
12807 
12808 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
12809 	.f = cmd_config_e_tag_insertion_dis_parsed,
12810 	.data = NULL,
12811 	.help_str = "E-tag ... : E-tag insertion disable",
12812 	.tokens = {
12813 		(void *)&cmd_config_e_tag_e_tag,
12814 		(void *)&cmd_config_e_tag_set,
12815 		(void *)&cmd_config_e_tag_insertion,
12816 		(void *)&cmd_config_e_tag_off,
12817 		(void *)&cmd_config_e_tag_port,
12818 		(void *)&cmd_config_e_tag_port_id,
12819 		(void *)&cmd_config_e_tag_vf,
12820 		(void *)&cmd_config_e_tag_vf_id,
12821 		NULL,
12822 	},
12823 };
12824 
12825 /* E-tag stripping configuration */
12826 static void
12827 cmd_config_e_tag_stripping_parsed(
12828 	void *parsed_result,
12829 	__attribute__((unused)) struct cmdline *cl,
12830 	__attribute__((unused)) void *data)
12831 {
12832 	struct cmd_config_e_tag_result *res =
12833 		parsed_result;
12834 	struct rte_eth_l2_tunnel_conf entry;
12835 
12836 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12837 		return;
12838 
12839 	entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12840 
12841 	if (!strcmp(res->on_off, "on"))
12842 		rte_eth_dev_l2_tunnel_offload_set
12843 			(res->port_id,
12844 			 &entry,
12845 			 ETH_L2_TUNNEL_STRIPPING_MASK,
12846 			 1);
12847 	else
12848 		rte_eth_dev_l2_tunnel_offload_set
12849 			(res->port_id,
12850 			 &entry,
12851 			 ETH_L2_TUNNEL_STRIPPING_MASK,
12852 			 0);
12853 }
12854 
12855 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
12856 	.f = cmd_config_e_tag_stripping_parsed,
12857 	.data = NULL,
12858 	.help_str = "E-tag ... : E-tag stripping enable/disable",
12859 	.tokens = {
12860 		(void *)&cmd_config_e_tag_e_tag,
12861 		(void *)&cmd_config_e_tag_set,
12862 		(void *)&cmd_config_e_tag_stripping,
12863 		(void *)&cmd_config_e_tag_on_off,
12864 		(void *)&cmd_config_e_tag_port,
12865 		(void *)&cmd_config_e_tag_port_id,
12866 		NULL,
12867 	},
12868 };
12869 
12870 /* E-tag forwarding configuration */
12871 static void
12872 cmd_config_e_tag_forwarding_parsed(
12873 	void *parsed_result,
12874 	__attribute__((unused)) struct cmdline *cl,
12875 	__attribute__((unused)) void *data)
12876 {
12877 	struct cmd_config_e_tag_result *res = parsed_result;
12878 	struct rte_eth_l2_tunnel_conf entry;
12879 
12880 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12881 		return;
12882 
12883 	entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12884 
12885 	if (!strcmp(res->on_off, "on"))
12886 		rte_eth_dev_l2_tunnel_offload_set
12887 			(res->port_id,
12888 			 &entry,
12889 			 ETH_L2_TUNNEL_FORWARDING_MASK,
12890 			 1);
12891 	else
12892 		rte_eth_dev_l2_tunnel_offload_set
12893 			(res->port_id,
12894 			 &entry,
12895 			 ETH_L2_TUNNEL_FORWARDING_MASK,
12896 			 0);
12897 }
12898 
12899 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
12900 	.f = cmd_config_e_tag_forwarding_parsed,
12901 	.data = NULL,
12902 	.help_str = "E-tag ... : E-tag forwarding enable/disable",
12903 	.tokens = {
12904 		(void *)&cmd_config_e_tag_e_tag,
12905 		(void *)&cmd_config_e_tag_set,
12906 		(void *)&cmd_config_e_tag_forwarding,
12907 		(void *)&cmd_config_e_tag_on_off,
12908 		(void *)&cmd_config_e_tag_port,
12909 		(void *)&cmd_config_e_tag_port_id,
12910 		NULL,
12911 	},
12912 };
12913 
12914 /* E-tag filter configuration */
12915 static void
12916 cmd_config_e_tag_filter_add_parsed(
12917 	void *parsed_result,
12918 	__attribute__((unused)) struct cmdline *cl,
12919 	__attribute__((unused)) void *data)
12920 {
12921 	struct cmd_config_e_tag_result *res = parsed_result;
12922 	struct rte_eth_l2_tunnel_conf entry;
12923 	int ret = 0;
12924 
12925 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12926 		return;
12927 
12928 	if (res->e_tag_id_val > 0x3fff) {
12929 		printf("e-tag-id must be equal or less than 0x3fff.\n");
12930 		return;
12931 	}
12932 
12933 	ret = rte_eth_dev_filter_supported(res->port_id,
12934 					   RTE_ETH_FILTER_L2_TUNNEL);
12935 	if (ret < 0) {
12936 		printf("E-tag filter is not supported on port %u.\n",
12937 		       res->port_id);
12938 		return;
12939 	}
12940 
12941 	entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12942 	entry.tunnel_id = res->e_tag_id_val;
12943 	entry.pool = res->dst_pool_val;
12944 
12945 	ret = rte_eth_dev_filter_ctrl(res->port_id,
12946 				      RTE_ETH_FILTER_L2_TUNNEL,
12947 				      RTE_ETH_FILTER_ADD,
12948 				      &entry);
12949 	if (ret < 0)
12950 		printf("E-tag filter programming error: (%s)\n",
12951 		       strerror(-ret));
12952 }
12953 
12954 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
12955 	.f = cmd_config_e_tag_filter_add_parsed,
12956 	.data = NULL,
12957 	.help_str = "E-tag ... : E-tag filter add",
12958 	.tokens = {
12959 		(void *)&cmd_config_e_tag_e_tag,
12960 		(void *)&cmd_config_e_tag_set,
12961 		(void *)&cmd_config_e_tag_filter,
12962 		(void *)&cmd_config_e_tag_add,
12963 		(void *)&cmd_config_e_tag_e_tag_id,
12964 		(void *)&cmd_config_e_tag_e_tag_id_val,
12965 		(void *)&cmd_config_e_tag_dst_pool,
12966 		(void *)&cmd_config_e_tag_dst_pool_val,
12967 		(void *)&cmd_config_e_tag_port,
12968 		(void *)&cmd_config_e_tag_port_id,
12969 		NULL,
12970 	},
12971 };
12972 
12973 static void
12974 cmd_config_e_tag_filter_del_parsed(
12975 	void *parsed_result,
12976 	__attribute__((unused)) struct cmdline *cl,
12977 	__attribute__((unused)) void *data)
12978 {
12979 	struct cmd_config_e_tag_result *res = parsed_result;
12980 	struct rte_eth_l2_tunnel_conf entry;
12981 	int ret = 0;
12982 
12983 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12984 		return;
12985 
12986 	if (res->e_tag_id_val > 0x3fff) {
12987 		printf("e-tag-id must be less than 0x3fff.\n");
12988 		return;
12989 	}
12990 
12991 	ret = rte_eth_dev_filter_supported(res->port_id,
12992 					   RTE_ETH_FILTER_L2_TUNNEL);
12993 	if (ret < 0) {
12994 		printf("E-tag filter is not supported on port %u.\n",
12995 		       res->port_id);
12996 		return;
12997 	}
12998 
12999 	entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13000 	entry.tunnel_id = res->e_tag_id_val;
13001 
13002 	ret = rte_eth_dev_filter_ctrl(res->port_id,
13003 				      RTE_ETH_FILTER_L2_TUNNEL,
13004 				      RTE_ETH_FILTER_DELETE,
13005 				      &entry);
13006 	if (ret < 0)
13007 		printf("E-tag filter programming error: (%s)\n",
13008 		       strerror(-ret));
13009 }
13010 
13011 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
13012 	.f = cmd_config_e_tag_filter_del_parsed,
13013 	.data = NULL,
13014 	.help_str = "E-tag ... : E-tag filter delete",
13015 	.tokens = {
13016 		(void *)&cmd_config_e_tag_e_tag,
13017 		(void *)&cmd_config_e_tag_set,
13018 		(void *)&cmd_config_e_tag_filter,
13019 		(void *)&cmd_config_e_tag_del,
13020 		(void *)&cmd_config_e_tag_e_tag_id,
13021 		(void *)&cmd_config_e_tag_e_tag_id_val,
13022 		(void *)&cmd_config_e_tag_port,
13023 		(void *)&cmd_config_e_tag_port_id,
13024 		NULL,
13025 	},
13026 };
13027 
13028 /* vf vlan anti spoof configuration */
13029 
13030 /* Common result structure for vf vlan anti spoof */
13031 struct cmd_vf_vlan_anti_spoof_result {
13032 	cmdline_fixed_string_t set;
13033 	cmdline_fixed_string_t vf;
13034 	cmdline_fixed_string_t vlan;
13035 	cmdline_fixed_string_t antispoof;
13036 	portid_t port_id;
13037 	uint32_t vf_id;
13038 	cmdline_fixed_string_t on_off;
13039 };
13040 
13041 /* Common CLI fields for vf vlan anti spoof enable disable */
13042 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
13043 	TOKEN_STRING_INITIALIZER
13044 		(struct cmd_vf_vlan_anti_spoof_result,
13045 		 set, "set");
13046 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
13047 	TOKEN_STRING_INITIALIZER
13048 		(struct cmd_vf_vlan_anti_spoof_result,
13049 		 vf, "vf");
13050 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
13051 	TOKEN_STRING_INITIALIZER
13052 		(struct cmd_vf_vlan_anti_spoof_result,
13053 		 vlan, "vlan");
13054 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
13055 	TOKEN_STRING_INITIALIZER
13056 		(struct cmd_vf_vlan_anti_spoof_result,
13057 		 antispoof, "antispoof");
13058 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
13059 	TOKEN_NUM_INITIALIZER
13060 		(struct cmd_vf_vlan_anti_spoof_result,
13061 		 port_id, UINT16);
13062 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
13063 	TOKEN_NUM_INITIALIZER
13064 		(struct cmd_vf_vlan_anti_spoof_result,
13065 		 vf_id, UINT32);
13066 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
13067 	TOKEN_STRING_INITIALIZER
13068 		(struct cmd_vf_vlan_anti_spoof_result,
13069 		 on_off, "on#off");
13070 
13071 static void
13072 cmd_set_vf_vlan_anti_spoof_parsed(
13073 	void *parsed_result,
13074 	__attribute__((unused)) struct cmdline *cl,
13075 	__attribute__((unused)) void *data)
13076 {
13077 	struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
13078 	int ret = -ENOTSUP;
13079 
13080 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13081 
13082 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13083 		return;
13084 
13085 #ifdef RTE_LIBRTE_IXGBE_PMD
13086 	if (ret == -ENOTSUP)
13087 		ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
13088 				res->vf_id, is_on);
13089 #endif
13090 #ifdef RTE_LIBRTE_I40E_PMD
13091 	if (ret == -ENOTSUP)
13092 		ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
13093 				res->vf_id, is_on);
13094 #endif
13095 #ifdef RTE_LIBRTE_BNXT_PMD
13096 	if (ret == -ENOTSUP)
13097 		ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
13098 				res->vf_id, is_on);
13099 #endif
13100 
13101 	switch (ret) {
13102 	case 0:
13103 		break;
13104 	case -EINVAL:
13105 		printf("invalid vf_id %d\n", res->vf_id);
13106 		break;
13107 	case -ENODEV:
13108 		printf("invalid port_id %d\n", res->port_id);
13109 		break;
13110 	case -ENOTSUP:
13111 		printf("function not implemented\n");
13112 		break;
13113 	default:
13114 		printf("programming error: (%s)\n", strerror(-ret));
13115 	}
13116 }
13117 
13118 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
13119 	.f = cmd_set_vf_vlan_anti_spoof_parsed,
13120 	.data = NULL,
13121 	.help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
13122 	.tokens = {
13123 		(void *)&cmd_vf_vlan_anti_spoof_set,
13124 		(void *)&cmd_vf_vlan_anti_spoof_vf,
13125 		(void *)&cmd_vf_vlan_anti_spoof_vlan,
13126 		(void *)&cmd_vf_vlan_anti_spoof_antispoof,
13127 		(void *)&cmd_vf_vlan_anti_spoof_port_id,
13128 		(void *)&cmd_vf_vlan_anti_spoof_vf_id,
13129 		(void *)&cmd_vf_vlan_anti_spoof_on_off,
13130 		NULL,
13131 	},
13132 };
13133 
13134 /* vf mac anti spoof configuration */
13135 
13136 /* Common result structure for vf mac anti spoof */
13137 struct cmd_vf_mac_anti_spoof_result {
13138 	cmdline_fixed_string_t set;
13139 	cmdline_fixed_string_t vf;
13140 	cmdline_fixed_string_t mac;
13141 	cmdline_fixed_string_t antispoof;
13142 	portid_t port_id;
13143 	uint32_t vf_id;
13144 	cmdline_fixed_string_t on_off;
13145 };
13146 
13147 /* Common CLI fields for vf mac anti spoof enable disable */
13148 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
13149 	TOKEN_STRING_INITIALIZER
13150 		(struct cmd_vf_mac_anti_spoof_result,
13151 		 set, "set");
13152 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
13153 	TOKEN_STRING_INITIALIZER
13154 		(struct cmd_vf_mac_anti_spoof_result,
13155 		 vf, "vf");
13156 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
13157 	TOKEN_STRING_INITIALIZER
13158 		(struct cmd_vf_mac_anti_spoof_result,
13159 		 mac, "mac");
13160 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
13161 	TOKEN_STRING_INITIALIZER
13162 		(struct cmd_vf_mac_anti_spoof_result,
13163 		 antispoof, "antispoof");
13164 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
13165 	TOKEN_NUM_INITIALIZER
13166 		(struct cmd_vf_mac_anti_spoof_result,
13167 		 port_id, UINT16);
13168 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
13169 	TOKEN_NUM_INITIALIZER
13170 		(struct cmd_vf_mac_anti_spoof_result,
13171 		 vf_id, UINT32);
13172 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
13173 	TOKEN_STRING_INITIALIZER
13174 		(struct cmd_vf_mac_anti_spoof_result,
13175 		 on_off, "on#off");
13176 
13177 static void
13178 cmd_set_vf_mac_anti_spoof_parsed(
13179 	void *parsed_result,
13180 	__attribute__((unused)) struct cmdline *cl,
13181 	__attribute__((unused)) void *data)
13182 {
13183 	struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
13184 	int ret = -ENOTSUP;
13185 
13186 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13187 
13188 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13189 		return;
13190 
13191 #ifdef RTE_LIBRTE_IXGBE_PMD
13192 	if (ret == -ENOTSUP)
13193 		ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
13194 			res->vf_id, is_on);
13195 #endif
13196 #ifdef RTE_LIBRTE_I40E_PMD
13197 	if (ret == -ENOTSUP)
13198 		ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
13199 			res->vf_id, is_on);
13200 #endif
13201 #ifdef RTE_LIBRTE_BNXT_PMD
13202 	if (ret == -ENOTSUP)
13203 		ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
13204 			res->vf_id, is_on);
13205 #endif
13206 
13207 	switch (ret) {
13208 	case 0:
13209 		break;
13210 	case -EINVAL:
13211 		printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13212 		break;
13213 	case -ENODEV:
13214 		printf("invalid port_id %d\n", res->port_id);
13215 		break;
13216 	case -ENOTSUP:
13217 		printf("function not implemented\n");
13218 		break;
13219 	default:
13220 		printf("programming error: (%s)\n", strerror(-ret));
13221 	}
13222 }
13223 
13224 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
13225 	.f = cmd_set_vf_mac_anti_spoof_parsed,
13226 	.data = NULL,
13227 	.help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
13228 	.tokens = {
13229 		(void *)&cmd_vf_mac_anti_spoof_set,
13230 		(void *)&cmd_vf_mac_anti_spoof_vf,
13231 		(void *)&cmd_vf_mac_anti_spoof_mac,
13232 		(void *)&cmd_vf_mac_anti_spoof_antispoof,
13233 		(void *)&cmd_vf_mac_anti_spoof_port_id,
13234 		(void *)&cmd_vf_mac_anti_spoof_vf_id,
13235 		(void *)&cmd_vf_mac_anti_spoof_on_off,
13236 		NULL,
13237 	},
13238 };
13239 
13240 /* vf vlan strip queue configuration */
13241 
13242 /* Common result structure for vf mac anti spoof */
13243 struct cmd_vf_vlan_stripq_result {
13244 	cmdline_fixed_string_t set;
13245 	cmdline_fixed_string_t vf;
13246 	cmdline_fixed_string_t vlan;
13247 	cmdline_fixed_string_t stripq;
13248 	portid_t port_id;
13249 	uint16_t vf_id;
13250 	cmdline_fixed_string_t on_off;
13251 };
13252 
13253 /* Common CLI fields for vf vlan strip enable disable */
13254 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
13255 	TOKEN_STRING_INITIALIZER
13256 		(struct cmd_vf_vlan_stripq_result,
13257 		 set, "set");
13258 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
13259 	TOKEN_STRING_INITIALIZER
13260 		(struct cmd_vf_vlan_stripq_result,
13261 		 vf, "vf");
13262 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
13263 	TOKEN_STRING_INITIALIZER
13264 		(struct cmd_vf_vlan_stripq_result,
13265 		 vlan, "vlan");
13266 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
13267 	TOKEN_STRING_INITIALIZER
13268 		(struct cmd_vf_vlan_stripq_result,
13269 		 stripq, "stripq");
13270 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
13271 	TOKEN_NUM_INITIALIZER
13272 		(struct cmd_vf_vlan_stripq_result,
13273 		 port_id, UINT16);
13274 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
13275 	TOKEN_NUM_INITIALIZER
13276 		(struct cmd_vf_vlan_stripq_result,
13277 		 vf_id, UINT16);
13278 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
13279 	TOKEN_STRING_INITIALIZER
13280 		(struct cmd_vf_vlan_stripq_result,
13281 		 on_off, "on#off");
13282 
13283 static void
13284 cmd_set_vf_vlan_stripq_parsed(
13285 	void *parsed_result,
13286 	__attribute__((unused)) struct cmdline *cl,
13287 	__attribute__((unused)) void *data)
13288 {
13289 	struct cmd_vf_vlan_stripq_result *res = parsed_result;
13290 	int ret = -ENOTSUP;
13291 
13292 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13293 
13294 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13295 		return;
13296 
13297 #ifdef RTE_LIBRTE_IXGBE_PMD
13298 	if (ret == -ENOTSUP)
13299 		ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
13300 			res->vf_id, is_on);
13301 #endif
13302 #ifdef RTE_LIBRTE_I40E_PMD
13303 	if (ret == -ENOTSUP)
13304 		ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
13305 			res->vf_id, is_on);
13306 #endif
13307 #ifdef RTE_LIBRTE_BNXT_PMD
13308 	if (ret == -ENOTSUP)
13309 		ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
13310 			res->vf_id, is_on);
13311 #endif
13312 
13313 	switch (ret) {
13314 	case 0:
13315 		break;
13316 	case -EINVAL:
13317 		printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13318 		break;
13319 	case -ENODEV:
13320 		printf("invalid port_id %d\n", res->port_id);
13321 		break;
13322 	case -ENOTSUP:
13323 		printf("function not implemented\n");
13324 		break;
13325 	default:
13326 		printf("programming error: (%s)\n", strerror(-ret));
13327 	}
13328 }
13329 
13330 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
13331 	.f = cmd_set_vf_vlan_stripq_parsed,
13332 	.data = NULL,
13333 	.help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
13334 	.tokens = {
13335 		(void *)&cmd_vf_vlan_stripq_set,
13336 		(void *)&cmd_vf_vlan_stripq_vf,
13337 		(void *)&cmd_vf_vlan_stripq_vlan,
13338 		(void *)&cmd_vf_vlan_stripq_stripq,
13339 		(void *)&cmd_vf_vlan_stripq_port_id,
13340 		(void *)&cmd_vf_vlan_stripq_vf_id,
13341 		(void *)&cmd_vf_vlan_stripq_on_off,
13342 		NULL,
13343 	},
13344 };
13345 
13346 /* vf vlan insert configuration */
13347 
13348 /* Common result structure for vf vlan insert */
13349 struct cmd_vf_vlan_insert_result {
13350 	cmdline_fixed_string_t set;
13351 	cmdline_fixed_string_t vf;
13352 	cmdline_fixed_string_t vlan;
13353 	cmdline_fixed_string_t insert;
13354 	portid_t port_id;
13355 	uint16_t vf_id;
13356 	uint16_t vlan_id;
13357 };
13358 
13359 /* Common CLI fields for vf vlan insert enable disable */
13360 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
13361 	TOKEN_STRING_INITIALIZER
13362 		(struct cmd_vf_vlan_insert_result,
13363 		 set, "set");
13364 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
13365 	TOKEN_STRING_INITIALIZER
13366 		(struct cmd_vf_vlan_insert_result,
13367 		 vf, "vf");
13368 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
13369 	TOKEN_STRING_INITIALIZER
13370 		(struct cmd_vf_vlan_insert_result,
13371 		 vlan, "vlan");
13372 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
13373 	TOKEN_STRING_INITIALIZER
13374 		(struct cmd_vf_vlan_insert_result,
13375 		 insert, "insert");
13376 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
13377 	TOKEN_NUM_INITIALIZER
13378 		(struct cmd_vf_vlan_insert_result,
13379 		 port_id, UINT16);
13380 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
13381 	TOKEN_NUM_INITIALIZER
13382 		(struct cmd_vf_vlan_insert_result,
13383 		 vf_id, UINT16);
13384 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
13385 	TOKEN_NUM_INITIALIZER
13386 		(struct cmd_vf_vlan_insert_result,
13387 		 vlan_id, UINT16);
13388 
13389 static void
13390 cmd_set_vf_vlan_insert_parsed(
13391 	void *parsed_result,
13392 	__attribute__((unused)) struct cmdline *cl,
13393 	__attribute__((unused)) void *data)
13394 {
13395 	struct cmd_vf_vlan_insert_result *res = parsed_result;
13396 	int ret = -ENOTSUP;
13397 
13398 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13399 		return;
13400 
13401 #ifdef RTE_LIBRTE_IXGBE_PMD
13402 	if (ret == -ENOTSUP)
13403 		ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
13404 			res->vlan_id);
13405 #endif
13406 #ifdef RTE_LIBRTE_I40E_PMD
13407 	if (ret == -ENOTSUP)
13408 		ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
13409 			res->vlan_id);
13410 #endif
13411 #ifdef RTE_LIBRTE_BNXT_PMD
13412 	if (ret == -ENOTSUP)
13413 		ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
13414 			res->vlan_id);
13415 #endif
13416 
13417 	switch (ret) {
13418 	case 0:
13419 		break;
13420 	case -EINVAL:
13421 		printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
13422 		break;
13423 	case -ENODEV:
13424 		printf("invalid port_id %d\n", res->port_id);
13425 		break;
13426 	case -ENOTSUP:
13427 		printf("function not implemented\n");
13428 		break;
13429 	default:
13430 		printf("programming error: (%s)\n", strerror(-ret));
13431 	}
13432 }
13433 
13434 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
13435 	.f = cmd_set_vf_vlan_insert_parsed,
13436 	.data = NULL,
13437 	.help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
13438 	.tokens = {
13439 		(void *)&cmd_vf_vlan_insert_set,
13440 		(void *)&cmd_vf_vlan_insert_vf,
13441 		(void *)&cmd_vf_vlan_insert_vlan,
13442 		(void *)&cmd_vf_vlan_insert_insert,
13443 		(void *)&cmd_vf_vlan_insert_port_id,
13444 		(void *)&cmd_vf_vlan_insert_vf_id,
13445 		(void *)&cmd_vf_vlan_insert_vlan_id,
13446 		NULL,
13447 	},
13448 };
13449 
13450 /* tx loopback configuration */
13451 
13452 /* Common result structure for tx loopback */
13453 struct cmd_tx_loopback_result {
13454 	cmdline_fixed_string_t set;
13455 	cmdline_fixed_string_t tx;
13456 	cmdline_fixed_string_t loopback;
13457 	portid_t port_id;
13458 	cmdline_fixed_string_t on_off;
13459 };
13460 
13461 /* Common CLI fields for tx loopback enable disable */
13462 cmdline_parse_token_string_t cmd_tx_loopback_set =
13463 	TOKEN_STRING_INITIALIZER
13464 		(struct cmd_tx_loopback_result,
13465 		 set, "set");
13466 cmdline_parse_token_string_t cmd_tx_loopback_tx =
13467 	TOKEN_STRING_INITIALIZER
13468 		(struct cmd_tx_loopback_result,
13469 		 tx, "tx");
13470 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
13471 	TOKEN_STRING_INITIALIZER
13472 		(struct cmd_tx_loopback_result,
13473 		 loopback, "loopback");
13474 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
13475 	TOKEN_NUM_INITIALIZER
13476 		(struct cmd_tx_loopback_result,
13477 		 port_id, UINT16);
13478 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
13479 	TOKEN_STRING_INITIALIZER
13480 		(struct cmd_tx_loopback_result,
13481 		 on_off, "on#off");
13482 
13483 static void
13484 cmd_set_tx_loopback_parsed(
13485 	void *parsed_result,
13486 	__attribute__((unused)) struct cmdline *cl,
13487 	__attribute__((unused)) void *data)
13488 {
13489 	struct cmd_tx_loopback_result *res = parsed_result;
13490 	int ret = -ENOTSUP;
13491 
13492 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13493 
13494 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13495 		return;
13496 
13497 #ifdef RTE_LIBRTE_IXGBE_PMD
13498 	if (ret == -ENOTSUP)
13499 		ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
13500 #endif
13501 #ifdef RTE_LIBRTE_I40E_PMD
13502 	if (ret == -ENOTSUP)
13503 		ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
13504 #endif
13505 #ifdef RTE_LIBRTE_BNXT_PMD
13506 	if (ret == -ENOTSUP)
13507 		ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
13508 #endif
13509 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD
13510 	if (ret == -ENOTSUP)
13511 		ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
13512 #endif
13513 
13514 	switch (ret) {
13515 	case 0:
13516 		break;
13517 	case -EINVAL:
13518 		printf("invalid is_on %d\n", is_on);
13519 		break;
13520 	case -ENODEV:
13521 		printf("invalid port_id %d\n", res->port_id);
13522 		break;
13523 	case -ENOTSUP:
13524 		printf("function not implemented\n");
13525 		break;
13526 	default:
13527 		printf("programming error: (%s)\n", strerror(-ret));
13528 	}
13529 }
13530 
13531 cmdline_parse_inst_t cmd_set_tx_loopback = {
13532 	.f = cmd_set_tx_loopback_parsed,
13533 	.data = NULL,
13534 	.help_str = "set tx loopback <port_id> on|off",
13535 	.tokens = {
13536 		(void *)&cmd_tx_loopback_set,
13537 		(void *)&cmd_tx_loopback_tx,
13538 		(void *)&cmd_tx_loopback_loopback,
13539 		(void *)&cmd_tx_loopback_port_id,
13540 		(void *)&cmd_tx_loopback_on_off,
13541 		NULL,
13542 	},
13543 };
13544 
13545 /* all queues drop enable configuration */
13546 
13547 /* Common result structure for all queues drop enable */
13548 struct cmd_all_queues_drop_en_result {
13549 	cmdline_fixed_string_t set;
13550 	cmdline_fixed_string_t all;
13551 	cmdline_fixed_string_t queues;
13552 	cmdline_fixed_string_t drop;
13553 	portid_t port_id;
13554 	cmdline_fixed_string_t on_off;
13555 };
13556 
13557 /* Common CLI fields for tx loopback enable disable */
13558 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
13559 	TOKEN_STRING_INITIALIZER
13560 		(struct cmd_all_queues_drop_en_result,
13561 		 set, "set");
13562 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
13563 	TOKEN_STRING_INITIALIZER
13564 		(struct cmd_all_queues_drop_en_result,
13565 		 all, "all");
13566 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
13567 	TOKEN_STRING_INITIALIZER
13568 		(struct cmd_all_queues_drop_en_result,
13569 		 queues, "queues");
13570 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
13571 	TOKEN_STRING_INITIALIZER
13572 		(struct cmd_all_queues_drop_en_result,
13573 		 drop, "drop");
13574 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
13575 	TOKEN_NUM_INITIALIZER
13576 		(struct cmd_all_queues_drop_en_result,
13577 		 port_id, UINT16);
13578 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
13579 	TOKEN_STRING_INITIALIZER
13580 		(struct cmd_all_queues_drop_en_result,
13581 		 on_off, "on#off");
13582 
13583 static void
13584 cmd_set_all_queues_drop_en_parsed(
13585 	void *parsed_result,
13586 	__attribute__((unused)) struct cmdline *cl,
13587 	__attribute__((unused)) void *data)
13588 {
13589 	struct cmd_all_queues_drop_en_result *res = parsed_result;
13590 	int ret = -ENOTSUP;
13591 	int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13592 
13593 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13594 		return;
13595 
13596 #ifdef RTE_LIBRTE_IXGBE_PMD
13597 	if (ret == -ENOTSUP)
13598 		ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
13599 #endif
13600 #ifdef RTE_LIBRTE_BNXT_PMD
13601 	if (ret == -ENOTSUP)
13602 		ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
13603 #endif
13604 	switch (ret) {
13605 	case 0:
13606 		break;
13607 	case -EINVAL:
13608 		printf("invalid is_on %d\n", is_on);
13609 		break;
13610 	case -ENODEV:
13611 		printf("invalid port_id %d\n", res->port_id);
13612 		break;
13613 	case -ENOTSUP:
13614 		printf("function not implemented\n");
13615 		break;
13616 	default:
13617 		printf("programming error: (%s)\n", strerror(-ret));
13618 	}
13619 }
13620 
13621 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
13622 	.f = cmd_set_all_queues_drop_en_parsed,
13623 	.data = NULL,
13624 	.help_str = "set all queues drop <port_id> on|off",
13625 	.tokens = {
13626 		(void *)&cmd_all_queues_drop_en_set,
13627 		(void *)&cmd_all_queues_drop_en_all,
13628 		(void *)&cmd_all_queues_drop_en_queues,
13629 		(void *)&cmd_all_queues_drop_en_drop,
13630 		(void *)&cmd_all_queues_drop_en_port_id,
13631 		(void *)&cmd_all_queues_drop_en_on_off,
13632 		NULL,
13633 	},
13634 };
13635 
13636 /* vf split drop enable configuration */
13637 
13638 /* Common result structure for vf split drop enable */
13639 struct cmd_vf_split_drop_en_result {
13640 	cmdline_fixed_string_t set;
13641 	cmdline_fixed_string_t vf;
13642 	cmdline_fixed_string_t split;
13643 	cmdline_fixed_string_t drop;
13644 	portid_t port_id;
13645 	uint16_t vf_id;
13646 	cmdline_fixed_string_t on_off;
13647 };
13648 
13649 /* Common CLI fields for vf split drop enable disable */
13650 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
13651 	TOKEN_STRING_INITIALIZER
13652 		(struct cmd_vf_split_drop_en_result,
13653 		 set, "set");
13654 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
13655 	TOKEN_STRING_INITIALIZER
13656 		(struct cmd_vf_split_drop_en_result,
13657 		 vf, "vf");
13658 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
13659 	TOKEN_STRING_INITIALIZER
13660 		(struct cmd_vf_split_drop_en_result,
13661 		 split, "split");
13662 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
13663 	TOKEN_STRING_INITIALIZER
13664 		(struct cmd_vf_split_drop_en_result,
13665 		 drop, "drop");
13666 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
13667 	TOKEN_NUM_INITIALIZER
13668 		(struct cmd_vf_split_drop_en_result,
13669 		 port_id, UINT16);
13670 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
13671 	TOKEN_NUM_INITIALIZER
13672 		(struct cmd_vf_split_drop_en_result,
13673 		 vf_id, UINT16);
13674 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
13675 	TOKEN_STRING_INITIALIZER
13676 		(struct cmd_vf_split_drop_en_result,
13677 		 on_off, "on#off");
13678 
13679 static void
13680 cmd_set_vf_split_drop_en_parsed(
13681 	void *parsed_result,
13682 	__attribute__((unused)) struct cmdline *cl,
13683 	__attribute__((unused)) void *data)
13684 {
13685 	struct cmd_vf_split_drop_en_result *res = parsed_result;
13686 	int ret = -ENOTSUP;
13687 	int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13688 
13689 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13690 		return;
13691 
13692 #ifdef RTE_LIBRTE_IXGBE_PMD
13693 	ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
13694 			is_on);
13695 #endif
13696 	switch (ret) {
13697 	case 0:
13698 		break;
13699 	case -EINVAL:
13700 		printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13701 		break;
13702 	case -ENODEV:
13703 		printf("invalid port_id %d\n", res->port_id);
13704 		break;
13705 	case -ENOTSUP:
13706 		printf("not supported on port %d\n", res->port_id);
13707 		break;
13708 	default:
13709 		printf("programming error: (%s)\n", strerror(-ret));
13710 	}
13711 }
13712 
13713 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
13714 	.f = cmd_set_vf_split_drop_en_parsed,
13715 	.data = NULL,
13716 	.help_str = "set vf split drop <port_id> <vf_id> on|off",
13717 	.tokens = {
13718 		(void *)&cmd_vf_split_drop_en_set,
13719 		(void *)&cmd_vf_split_drop_en_vf,
13720 		(void *)&cmd_vf_split_drop_en_split,
13721 		(void *)&cmd_vf_split_drop_en_drop,
13722 		(void *)&cmd_vf_split_drop_en_port_id,
13723 		(void *)&cmd_vf_split_drop_en_vf_id,
13724 		(void *)&cmd_vf_split_drop_en_on_off,
13725 		NULL,
13726 	},
13727 };
13728 
13729 /* vf mac address configuration */
13730 
13731 /* Common result structure for vf mac address */
13732 struct cmd_set_vf_mac_addr_result {
13733 	cmdline_fixed_string_t set;
13734 	cmdline_fixed_string_t vf;
13735 	cmdline_fixed_string_t mac;
13736 	cmdline_fixed_string_t addr;
13737 	portid_t port_id;
13738 	uint16_t vf_id;
13739 	struct ether_addr mac_addr;
13740 
13741 };
13742 
13743 /* Common CLI fields for vf split drop enable disable */
13744 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
13745 	TOKEN_STRING_INITIALIZER
13746 		(struct cmd_set_vf_mac_addr_result,
13747 		 set, "set");
13748 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
13749 	TOKEN_STRING_INITIALIZER
13750 		(struct cmd_set_vf_mac_addr_result,
13751 		 vf, "vf");
13752 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
13753 	TOKEN_STRING_INITIALIZER
13754 		(struct cmd_set_vf_mac_addr_result,
13755 		 mac, "mac");
13756 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
13757 	TOKEN_STRING_INITIALIZER
13758 		(struct cmd_set_vf_mac_addr_result,
13759 		 addr, "addr");
13760 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
13761 	TOKEN_NUM_INITIALIZER
13762 		(struct cmd_set_vf_mac_addr_result,
13763 		 port_id, UINT16);
13764 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
13765 	TOKEN_NUM_INITIALIZER
13766 		(struct cmd_set_vf_mac_addr_result,
13767 		 vf_id, UINT16);
13768 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
13769 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
13770 		 mac_addr);
13771 
13772 static void
13773 cmd_set_vf_mac_addr_parsed(
13774 	void *parsed_result,
13775 	__attribute__((unused)) struct cmdline *cl,
13776 	__attribute__((unused)) void *data)
13777 {
13778 	struct cmd_set_vf_mac_addr_result *res = parsed_result;
13779 	int ret = -ENOTSUP;
13780 
13781 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13782 		return;
13783 
13784 #ifdef RTE_LIBRTE_IXGBE_PMD
13785 	if (ret == -ENOTSUP)
13786 		ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
13787 				&res->mac_addr);
13788 #endif
13789 #ifdef RTE_LIBRTE_I40E_PMD
13790 	if (ret == -ENOTSUP)
13791 		ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
13792 				&res->mac_addr);
13793 #endif
13794 #ifdef RTE_LIBRTE_BNXT_PMD
13795 	if (ret == -ENOTSUP)
13796 		ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
13797 				&res->mac_addr);
13798 #endif
13799 
13800 	switch (ret) {
13801 	case 0:
13802 		break;
13803 	case -EINVAL:
13804 		printf("invalid vf_id %d or mac_addr\n", res->vf_id);
13805 		break;
13806 	case -ENODEV:
13807 		printf("invalid port_id %d\n", res->port_id);
13808 		break;
13809 	case -ENOTSUP:
13810 		printf("function not implemented\n");
13811 		break;
13812 	default:
13813 		printf("programming error: (%s)\n", strerror(-ret));
13814 	}
13815 }
13816 
13817 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
13818 	.f = cmd_set_vf_mac_addr_parsed,
13819 	.data = NULL,
13820 	.help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
13821 	.tokens = {
13822 		(void *)&cmd_set_vf_mac_addr_set,
13823 		(void *)&cmd_set_vf_mac_addr_vf,
13824 		(void *)&cmd_set_vf_mac_addr_mac,
13825 		(void *)&cmd_set_vf_mac_addr_addr,
13826 		(void *)&cmd_set_vf_mac_addr_port_id,
13827 		(void *)&cmd_set_vf_mac_addr_vf_id,
13828 		(void *)&cmd_set_vf_mac_addr_mac_addr,
13829 		NULL,
13830 	},
13831 };
13832 
13833 /* MACsec configuration */
13834 
13835 /* Common result structure for MACsec offload enable */
13836 struct cmd_macsec_offload_on_result {
13837 	cmdline_fixed_string_t set;
13838 	cmdline_fixed_string_t macsec;
13839 	cmdline_fixed_string_t offload;
13840 	portid_t port_id;
13841 	cmdline_fixed_string_t on;
13842 	cmdline_fixed_string_t encrypt;
13843 	cmdline_fixed_string_t en_on_off;
13844 	cmdline_fixed_string_t replay_protect;
13845 	cmdline_fixed_string_t rp_on_off;
13846 };
13847 
13848 /* Common CLI fields for MACsec offload disable */
13849 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
13850 	TOKEN_STRING_INITIALIZER
13851 		(struct cmd_macsec_offload_on_result,
13852 		 set, "set");
13853 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
13854 	TOKEN_STRING_INITIALIZER
13855 		(struct cmd_macsec_offload_on_result,
13856 		 macsec, "macsec");
13857 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
13858 	TOKEN_STRING_INITIALIZER
13859 		(struct cmd_macsec_offload_on_result,
13860 		 offload, "offload");
13861 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
13862 	TOKEN_NUM_INITIALIZER
13863 		(struct cmd_macsec_offload_on_result,
13864 		 port_id, UINT16);
13865 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
13866 	TOKEN_STRING_INITIALIZER
13867 		(struct cmd_macsec_offload_on_result,
13868 		 on, "on");
13869 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
13870 	TOKEN_STRING_INITIALIZER
13871 		(struct cmd_macsec_offload_on_result,
13872 		 encrypt, "encrypt");
13873 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
13874 	TOKEN_STRING_INITIALIZER
13875 		(struct cmd_macsec_offload_on_result,
13876 		 en_on_off, "on#off");
13877 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
13878 	TOKEN_STRING_INITIALIZER
13879 		(struct cmd_macsec_offload_on_result,
13880 		 replay_protect, "replay-protect");
13881 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
13882 	TOKEN_STRING_INITIALIZER
13883 		(struct cmd_macsec_offload_on_result,
13884 		 rp_on_off, "on#off");
13885 
13886 static void
13887 cmd_set_macsec_offload_on_parsed(
13888 	void *parsed_result,
13889 	__attribute__((unused)) struct cmdline *cl,
13890 	__attribute__((unused)) void *data)
13891 {
13892 	struct cmd_macsec_offload_on_result *res = parsed_result;
13893 	int ret = -ENOTSUP;
13894 	portid_t port_id = res->port_id;
13895 	int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
13896 	int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
13897 	struct rte_eth_dev_info dev_info;
13898 
13899 	if (port_id_is_invalid(port_id, ENABLED_WARN))
13900 		return;
13901 	if (!port_is_stopped(port_id)) {
13902 		printf("Please stop port %d first\n", port_id);
13903 		return;
13904 	}
13905 
13906 	rte_eth_dev_info_get(port_id, &dev_info);
13907 	if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
13908 #ifdef RTE_LIBRTE_IXGBE_PMD
13909 		ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
13910 #endif
13911 	}
13912 	RTE_SET_USED(en);
13913 	RTE_SET_USED(rp);
13914 
13915 	switch (ret) {
13916 	case 0:
13917 		ports[port_id].dev_conf.txmode.offloads |=
13918 						DEV_TX_OFFLOAD_MACSEC_INSERT;
13919 		cmd_reconfig_device_queue(port_id, 1, 1);
13920 		break;
13921 	case -ENODEV:
13922 		printf("invalid port_id %d\n", port_id);
13923 		break;
13924 	case -ENOTSUP:
13925 		printf("not supported on port %d\n", port_id);
13926 		break;
13927 	default:
13928 		printf("programming error: (%s)\n", strerror(-ret));
13929 	}
13930 }
13931 
13932 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
13933 	.f = cmd_set_macsec_offload_on_parsed,
13934 	.data = NULL,
13935 	.help_str = "set macsec offload <port_id> on "
13936 		"encrypt on|off replay-protect on|off",
13937 	.tokens = {
13938 		(void *)&cmd_macsec_offload_on_set,
13939 		(void *)&cmd_macsec_offload_on_macsec,
13940 		(void *)&cmd_macsec_offload_on_offload,
13941 		(void *)&cmd_macsec_offload_on_port_id,
13942 		(void *)&cmd_macsec_offload_on_on,
13943 		(void *)&cmd_macsec_offload_on_encrypt,
13944 		(void *)&cmd_macsec_offload_on_en_on_off,
13945 		(void *)&cmd_macsec_offload_on_replay_protect,
13946 		(void *)&cmd_macsec_offload_on_rp_on_off,
13947 		NULL,
13948 	},
13949 };
13950 
13951 /* Common result structure for MACsec offload disable */
13952 struct cmd_macsec_offload_off_result {
13953 	cmdline_fixed_string_t set;
13954 	cmdline_fixed_string_t macsec;
13955 	cmdline_fixed_string_t offload;
13956 	portid_t port_id;
13957 	cmdline_fixed_string_t off;
13958 };
13959 
13960 /* Common CLI fields for MACsec offload disable */
13961 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
13962 	TOKEN_STRING_INITIALIZER
13963 		(struct cmd_macsec_offload_off_result,
13964 		 set, "set");
13965 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
13966 	TOKEN_STRING_INITIALIZER
13967 		(struct cmd_macsec_offload_off_result,
13968 		 macsec, "macsec");
13969 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
13970 	TOKEN_STRING_INITIALIZER
13971 		(struct cmd_macsec_offload_off_result,
13972 		 offload, "offload");
13973 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
13974 	TOKEN_NUM_INITIALIZER
13975 		(struct cmd_macsec_offload_off_result,
13976 		 port_id, UINT16);
13977 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
13978 	TOKEN_STRING_INITIALIZER
13979 		(struct cmd_macsec_offload_off_result,
13980 		 off, "off");
13981 
13982 static void
13983 cmd_set_macsec_offload_off_parsed(
13984 	void *parsed_result,
13985 	__attribute__((unused)) struct cmdline *cl,
13986 	__attribute__((unused)) void *data)
13987 {
13988 	struct cmd_macsec_offload_off_result *res = parsed_result;
13989 	int ret = -ENOTSUP;
13990 	struct rte_eth_dev_info dev_info;
13991 	portid_t port_id = res->port_id;
13992 
13993 	if (port_id_is_invalid(port_id, ENABLED_WARN))
13994 		return;
13995 	if (!port_is_stopped(port_id)) {
13996 		printf("Please stop port %d first\n", port_id);
13997 		return;
13998 	}
13999 
14000 	rte_eth_dev_info_get(port_id, &dev_info);
14001 	if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
14002 #ifdef RTE_LIBRTE_IXGBE_PMD
14003 		ret = rte_pmd_ixgbe_macsec_disable(port_id);
14004 #endif
14005 	}
14006 	switch (ret) {
14007 	case 0:
14008 		ports[port_id].dev_conf.txmode.offloads &=
14009 						~DEV_TX_OFFLOAD_MACSEC_INSERT;
14010 		cmd_reconfig_device_queue(port_id, 1, 1);
14011 		break;
14012 	case -ENODEV:
14013 		printf("invalid port_id %d\n", port_id);
14014 		break;
14015 	case -ENOTSUP:
14016 		printf("not supported on port %d\n", port_id);
14017 		break;
14018 	default:
14019 		printf("programming error: (%s)\n", strerror(-ret));
14020 	}
14021 }
14022 
14023 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
14024 	.f = cmd_set_macsec_offload_off_parsed,
14025 	.data = NULL,
14026 	.help_str = "set macsec offload <port_id> off",
14027 	.tokens = {
14028 		(void *)&cmd_macsec_offload_off_set,
14029 		(void *)&cmd_macsec_offload_off_macsec,
14030 		(void *)&cmd_macsec_offload_off_offload,
14031 		(void *)&cmd_macsec_offload_off_port_id,
14032 		(void *)&cmd_macsec_offload_off_off,
14033 		NULL,
14034 	},
14035 };
14036 
14037 /* Common result structure for MACsec secure connection configure */
14038 struct cmd_macsec_sc_result {
14039 	cmdline_fixed_string_t set;
14040 	cmdline_fixed_string_t macsec;
14041 	cmdline_fixed_string_t sc;
14042 	cmdline_fixed_string_t tx_rx;
14043 	portid_t port_id;
14044 	struct ether_addr mac;
14045 	uint16_t pi;
14046 };
14047 
14048 /* Common CLI fields for MACsec secure connection configure */
14049 cmdline_parse_token_string_t cmd_macsec_sc_set =
14050 	TOKEN_STRING_INITIALIZER
14051 		(struct cmd_macsec_sc_result,
14052 		 set, "set");
14053 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
14054 	TOKEN_STRING_INITIALIZER
14055 		(struct cmd_macsec_sc_result,
14056 		 macsec, "macsec");
14057 cmdline_parse_token_string_t cmd_macsec_sc_sc =
14058 	TOKEN_STRING_INITIALIZER
14059 		(struct cmd_macsec_sc_result,
14060 		 sc, "sc");
14061 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
14062 	TOKEN_STRING_INITIALIZER
14063 		(struct cmd_macsec_sc_result,
14064 		 tx_rx, "tx#rx");
14065 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
14066 	TOKEN_NUM_INITIALIZER
14067 		(struct cmd_macsec_sc_result,
14068 		 port_id, UINT16);
14069 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
14070 	TOKEN_ETHERADDR_INITIALIZER
14071 		(struct cmd_macsec_sc_result,
14072 		 mac);
14073 cmdline_parse_token_num_t cmd_macsec_sc_pi =
14074 	TOKEN_NUM_INITIALIZER
14075 		(struct cmd_macsec_sc_result,
14076 		 pi, UINT16);
14077 
14078 static void
14079 cmd_set_macsec_sc_parsed(
14080 	void *parsed_result,
14081 	__attribute__((unused)) struct cmdline *cl,
14082 	__attribute__((unused)) void *data)
14083 {
14084 	struct cmd_macsec_sc_result *res = parsed_result;
14085 	int ret = -ENOTSUP;
14086 	int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14087 
14088 #ifdef RTE_LIBRTE_IXGBE_PMD
14089 	ret = is_tx ?
14090 		rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
14091 				res->mac.addr_bytes) :
14092 		rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
14093 				res->mac.addr_bytes, res->pi);
14094 #endif
14095 	RTE_SET_USED(is_tx);
14096 
14097 	switch (ret) {
14098 	case 0:
14099 		break;
14100 	case -ENODEV:
14101 		printf("invalid port_id %d\n", res->port_id);
14102 		break;
14103 	case -ENOTSUP:
14104 		printf("not supported on port %d\n", res->port_id);
14105 		break;
14106 	default:
14107 		printf("programming error: (%s)\n", strerror(-ret));
14108 	}
14109 }
14110 
14111 cmdline_parse_inst_t cmd_set_macsec_sc = {
14112 	.f = cmd_set_macsec_sc_parsed,
14113 	.data = NULL,
14114 	.help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
14115 	.tokens = {
14116 		(void *)&cmd_macsec_sc_set,
14117 		(void *)&cmd_macsec_sc_macsec,
14118 		(void *)&cmd_macsec_sc_sc,
14119 		(void *)&cmd_macsec_sc_tx_rx,
14120 		(void *)&cmd_macsec_sc_port_id,
14121 		(void *)&cmd_macsec_sc_mac,
14122 		(void *)&cmd_macsec_sc_pi,
14123 		NULL,
14124 	},
14125 };
14126 
14127 /* Common result structure for MACsec secure connection configure */
14128 struct cmd_macsec_sa_result {
14129 	cmdline_fixed_string_t set;
14130 	cmdline_fixed_string_t macsec;
14131 	cmdline_fixed_string_t sa;
14132 	cmdline_fixed_string_t tx_rx;
14133 	portid_t port_id;
14134 	uint8_t idx;
14135 	uint8_t an;
14136 	uint32_t pn;
14137 	cmdline_fixed_string_t key;
14138 };
14139 
14140 /* Common CLI fields for MACsec secure connection configure */
14141 cmdline_parse_token_string_t cmd_macsec_sa_set =
14142 	TOKEN_STRING_INITIALIZER
14143 		(struct cmd_macsec_sa_result,
14144 		 set, "set");
14145 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
14146 	TOKEN_STRING_INITIALIZER
14147 		(struct cmd_macsec_sa_result,
14148 		 macsec, "macsec");
14149 cmdline_parse_token_string_t cmd_macsec_sa_sa =
14150 	TOKEN_STRING_INITIALIZER
14151 		(struct cmd_macsec_sa_result,
14152 		 sa, "sa");
14153 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
14154 	TOKEN_STRING_INITIALIZER
14155 		(struct cmd_macsec_sa_result,
14156 		 tx_rx, "tx#rx");
14157 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
14158 	TOKEN_NUM_INITIALIZER
14159 		(struct cmd_macsec_sa_result,
14160 		 port_id, UINT16);
14161 cmdline_parse_token_num_t cmd_macsec_sa_idx =
14162 	TOKEN_NUM_INITIALIZER
14163 		(struct cmd_macsec_sa_result,
14164 		 idx, UINT8);
14165 cmdline_parse_token_num_t cmd_macsec_sa_an =
14166 	TOKEN_NUM_INITIALIZER
14167 		(struct cmd_macsec_sa_result,
14168 		 an, UINT8);
14169 cmdline_parse_token_num_t cmd_macsec_sa_pn =
14170 	TOKEN_NUM_INITIALIZER
14171 		(struct cmd_macsec_sa_result,
14172 		 pn, UINT32);
14173 cmdline_parse_token_string_t cmd_macsec_sa_key =
14174 	TOKEN_STRING_INITIALIZER
14175 		(struct cmd_macsec_sa_result,
14176 		 key, NULL);
14177 
14178 static void
14179 cmd_set_macsec_sa_parsed(
14180 	void *parsed_result,
14181 	__attribute__((unused)) struct cmdline *cl,
14182 	__attribute__((unused)) void *data)
14183 {
14184 	struct cmd_macsec_sa_result *res = parsed_result;
14185 	int ret = -ENOTSUP;
14186 	int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14187 	uint8_t key[16] = { 0 };
14188 	uint8_t xdgt0;
14189 	uint8_t xdgt1;
14190 	int key_len;
14191 	int i;
14192 
14193 	key_len = strlen(res->key) / 2;
14194 	if (key_len > 16)
14195 		key_len = 16;
14196 
14197 	for (i = 0; i < key_len; i++) {
14198 		xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
14199 		if (xdgt0 == 0xFF)
14200 			return;
14201 		xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
14202 		if (xdgt1 == 0xFF)
14203 			return;
14204 		key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
14205 	}
14206 
14207 #ifdef RTE_LIBRTE_IXGBE_PMD
14208 	ret = is_tx ?
14209 		rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
14210 			res->idx, res->an, res->pn, key) :
14211 		rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
14212 			res->idx, res->an, res->pn, key);
14213 #endif
14214 	RTE_SET_USED(is_tx);
14215 	RTE_SET_USED(key);
14216 
14217 	switch (ret) {
14218 	case 0:
14219 		break;
14220 	case -EINVAL:
14221 		printf("invalid idx %d or an %d\n", res->idx, res->an);
14222 		break;
14223 	case -ENODEV:
14224 		printf("invalid port_id %d\n", res->port_id);
14225 		break;
14226 	case -ENOTSUP:
14227 		printf("not supported on port %d\n", res->port_id);
14228 		break;
14229 	default:
14230 		printf("programming error: (%s)\n", strerror(-ret));
14231 	}
14232 }
14233 
14234 cmdline_parse_inst_t cmd_set_macsec_sa = {
14235 	.f = cmd_set_macsec_sa_parsed,
14236 	.data = NULL,
14237 	.help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
14238 	.tokens = {
14239 		(void *)&cmd_macsec_sa_set,
14240 		(void *)&cmd_macsec_sa_macsec,
14241 		(void *)&cmd_macsec_sa_sa,
14242 		(void *)&cmd_macsec_sa_tx_rx,
14243 		(void *)&cmd_macsec_sa_port_id,
14244 		(void *)&cmd_macsec_sa_idx,
14245 		(void *)&cmd_macsec_sa_an,
14246 		(void *)&cmd_macsec_sa_pn,
14247 		(void *)&cmd_macsec_sa_key,
14248 		NULL,
14249 	},
14250 };
14251 
14252 /* VF unicast promiscuous mode configuration */
14253 
14254 /* Common result structure for VF unicast promiscuous mode */
14255 struct cmd_vf_promisc_result {
14256 	cmdline_fixed_string_t set;
14257 	cmdline_fixed_string_t vf;
14258 	cmdline_fixed_string_t promisc;
14259 	portid_t port_id;
14260 	uint32_t vf_id;
14261 	cmdline_fixed_string_t on_off;
14262 };
14263 
14264 /* Common CLI fields for VF unicast promiscuous mode enable disable */
14265 cmdline_parse_token_string_t cmd_vf_promisc_set =
14266 	TOKEN_STRING_INITIALIZER
14267 		(struct cmd_vf_promisc_result,
14268 		 set, "set");
14269 cmdline_parse_token_string_t cmd_vf_promisc_vf =
14270 	TOKEN_STRING_INITIALIZER
14271 		(struct cmd_vf_promisc_result,
14272 		 vf, "vf");
14273 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
14274 	TOKEN_STRING_INITIALIZER
14275 		(struct cmd_vf_promisc_result,
14276 		 promisc, "promisc");
14277 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
14278 	TOKEN_NUM_INITIALIZER
14279 		(struct cmd_vf_promisc_result,
14280 		 port_id, UINT16);
14281 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
14282 	TOKEN_NUM_INITIALIZER
14283 		(struct cmd_vf_promisc_result,
14284 		 vf_id, UINT32);
14285 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
14286 	TOKEN_STRING_INITIALIZER
14287 		(struct cmd_vf_promisc_result,
14288 		 on_off, "on#off");
14289 
14290 static void
14291 cmd_set_vf_promisc_parsed(
14292 	void *parsed_result,
14293 	__attribute__((unused)) struct cmdline *cl,
14294 	__attribute__((unused)) void *data)
14295 {
14296 	struct cmd_vf_promisc_result *res = parsed_result;
14297 	int ret = -ENOTSUP;
14298 
14299 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14300 
14301 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14302 		return;
14303 
14304 #ifdef RTE_LIBRTE_I40E_PMD
14305 	ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
14306 						  res->vf_id, is_on);
14307 #endif
14308 
14309 	switch (ret) {
14310 	case 0:
14311 		break;
14312 	case -EINVAL:
14313 		printf("invalid vf_id %d\n", res->vf_id);
14314 		break;
14315 	case -ENODEV:
14316 		printf("invalid port_id %d\n", res->port_id);
14317 		break;
14318 	case -ENOTSUP:
14319 		printf("function not implemented\n");
14320 		break;
14321 	default:
14322 		printf("programming error: (%s)\n", strerror(-ret));
14323 	}
14324 }
14325 
14326 cmdline_parse_inst_t cmd_set_vf_promisc = {
14327 	.f = cmd_set_vf_promisc_parsed,
14328 	.data = NULL,
14329 	.help_str = "set vf promisc <port_id> <vf_id> on|off: "
14330 		"Set unicast promiscuous mode for a VF from the PF",
14331 	.tokens = {
14332 		(void *)&cmd_vf_promisc_set,
14333 		(void *)&cmd_vf_promisc_vf,
14334 		(void *)&cmd_vf_promisc_promisc,
14335 		(void *)&cmd_vf_promisc_port_id,
14336 		(void *)&cmd_vf_promisc_vf_id,
14337 		(void *)&cmd_vf_promisc_on_off,
14338 		NULL,
14339 	},
14340 };
14341 
14342 /* VF multicast promiscuous mode configuration */
14343 
14344 /* Common result structure for VF multicast promiscuous mode */
14345 struct cmd_vf_allmulti_result {
14346 	cmdline_fixed_string_t set;
14347 	cmdline_fixed_string_t vf;
14348 	cmdline_fixed_string_t allmulti;
14349 	portid_t port_id;
14350 	uint32_t vf_id;
14351 	cmdline_fixed_string_t on_off;
14352 };
14353 
14354 /* Common CLI fields for VF multicast promiscuous mode enable disable */
14355 cmdline_parse_token_string_t cmd_vf_allmulti_set =
14356 	TOKEN_STRING_INITIALIZER
14357 		(struct cmd_vf_allmulti_result,
14358 		 set, "set");
14359 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
14360 	TOKEN_STRING_INITIALIZER
14361 		(struct cmd_vf_allmulti_result,
14362 		 vf, "vf");
14363 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
14364 	TOKEN_STRING_INITIALIZER
14365 		(struct cmd_vf_allmulti_result,
14366 		 allmulti, "allmulti");
14367 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
14368 	TOKEN_NUM_INITIALIZER
14369 		(struct cmd_vf_allmulti_result,
14370 		 port_id, UINT16);
14371 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
14372 	TOKEN_NUM_INITIALIZER
14373 		(struct cmd_vf_allmulti_result,
14374 		 vf_id, UINT32);
14375 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
14376 	TOKEN_STRING_INITIALIZER
14377 		(struct cmd_vf_allmulti_result,
14378 		 on_off, "on#off");
14379 
14380 static void
14381 cmd_set_vf_allmulti_parsed(
14382 	void *parsed_result,
14383 	__attribute__((unused)) struct cmdline *cl,
14384 	__attribute__((unused)) void *data)
14385 {
14386 	struct cmd_vf_allmulti_result *res = parsed_result;
14387 	int ret = -ENOTSUP;
14388 
14389 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14390 
14391 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14392 		return;
14393 
14394 #ifdef RTE_LIBRTE_I40E_PMD
14395 	ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
14396 						    res->vf_id, is_on);
14397 #endif
14398 
14399 	switch (ret) {
14400 	case 0:
14401 		break;
14402 	case -EINVAL:
14403 		printf("invalid vf_id %d\n", res->vf_id);
14404 		break;
14405 	case -ENODEV:
14406 		printf("invalid port_id %d\n", res->port_id);
14407 		break;
14408 	case -ENOTSUP:
14409 		printf("function not implemented\n");
14410 		break;
14411 	default:
14412 		printf("programming error: (%s)\n", strerror(-ret));
14413 	}
14414 }
14415 
14416 cmdline_parse_inst_t cmd_set_vf_allmulti = {
14417 	.f = cmd_set_vf_allmulti_parsed,
14418 	.data = NULL,
14419 	.help_str = "set vf allmulti <port_id> <vf_id> on|off: "
14420 		"Set multicast promiscuous mode for a VF from the PF",
14421 	.tokens = {
14422 		(void *)&cmd_vf_allmulti_set,
14423 		(void *)&cmd_vf_allmulti_vf,
14424 		(void *)&cmd_vf_allmulti_allmulti,
14425 		(void *)&cmd_vf_allmulti_port_id,
14426 		(void *)&cmd_vf_allmulti_vf_id,
14427 		(void *)&cmd_vf_allmulti_on_off,
14428 		NULL,
14429 	},
14430 };
14431 
14432 /* vf broadcast mode configuration */
14433 
14434 /* Common result structure for vf broadcast */
14435 struct cmd_set_vf_broadcast_result {
14436 	cmdline_fixed_string_t set;
14437 	cmdline_fixed_string_t vf;
14438 	cmdline_fixed_string_t broadcast;
14439 	portid_t port_id;
14440 	uint16_t vf_id;
14441 	cmdline_fixed_string_t on_off;
14442 };
14443 
14444 /* Common CLI fields for vf broadcast enable disable */
14445 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
14446 	TOKEN_STRING_INITIALIZER
14447 		(struct cmd_set_vf_broadcast_result,
14448 		 set, "set");
14449 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
14450 	TOKEN_STRING_INITIALIZER
14451 		(struct cmd_set_vf_broadcast_result,
14452 		 vf, "vf");
14453 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
14454 	TOKEN_STRING_INITIALIZER
14455 		(struct cmd_set_vf_broadcast_result,
14456 		 broadcast, "broadcast");
14457 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
14458 	TOKEN_NUM_INITIALIZER
14459 		(struct cmd_set_vf_broadcast_result,
14460 		 port_id, UINT16);
14461 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
14462 	TOKEN_NUM_INITIALIZER
14463 		(struct cmd_set_vf_broadcast_result,
14464 		 vf_id, UINT16);
14465 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
14466 	TOKEN_STRING_INITIALIZER
14467 		(struct cmd_set_vf_broadcast_result,
14468 		 on_off, "on#off");
14469 
14470 static void
14471 cmd_set_vf_broadcast_parsed(
14472 	void *parsed_result,
14473 	__attribute__((unused)) struct cmdline *cl,
14474 	__attribute__((unused)) void *data)
14475 {
14476 	struct cmd_set_vf_broadcast_result *res = parsed_result;
14477 	int ret = -ENOTSUP;
14478 
14479 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14480 
14481 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14482 		return;
14483 
14484 #ifdef RTE_LIBRTE_I40E_PMD
14485 	ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
14486 					    res->vf_id, is_on);
14487 #endif
14488 
14489 	switch (ret) {
14490 	case 0:
14491 		break;
14492 	case -EINVAL:
14493 		printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14494 		break;
14495 	case -ENODEV:
14496 		printf("invalid port_id %d\n", res->port_id);
14497 		break;
14498 	case -ENOTSUP:
14499 		printf("function not implemented\n");
14500 		break;
14501 	default:
14502 		printf("programming error: (%s)\n", strerror(-ret));
14503 	}
14504 }
14505 
14506 cmdline_parse_inst_t cmd_set_vf_broadcast = {
14507 	.f = cmd_set_vf_broadcast_parsed,
14508 	.data = NULL,
14509 	.help_str = "set vf broadcast <port_id> <vf_id> on|off",
14510 	.tokens = {
14511 		(void *)&cmd_set_vf_broadcast_set,
14512 		(void *)&cmd_set_vf_broadcast_vf,
14513 		(void *)&cmd_set_vf_broadcast_broadcast,
14514 		(void *)&cmd_set_vf_broadcast_port_id,
14515 		(void *)&cmd_set_vf_broadcast_vf_id,
14516 		(void *)&cmd_set_vf_broadcast_on_off,
14517 		NULL,
14518 	},
14519 };
14520 
14521 /* vf vlan tag configuration */
14522 
14523 /* Common result structure for vf vlan tag */
14524 struct cmd_set_vf_vlan_tag_result {
14525 	cmdline_fixed_string_t set;
14526 	cmdline_fixed_string_t vf;
14527 	cmdline_fixed_string_t vlan;
14528 	cmdline_fixed_string_t tag;
14529 	portid_t port_id;
14530 	uint16_t vf_id;
14531 	cmdline_fixed_string_t on_off;
14532 };
14533 
14534 /* Common CLI fields for vf vlan tag enable disable */
14535 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
14536 	TOKEN_STRING_INITIALIZER
14537 		(struct cmd_set_vf_vlan_tag_result,
14538 		 set, "set");
14539 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
14540 	TOKEN_STRING_INITIALIZER
14541 		(struct cmd_set_vf_vlan_tag_result,
14542 		 vf, "vf");
14543 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
14544 	TOKEN_STRING_INITIALIZER
14545 		(struct cmd_set_vf_vlan_tag_result,
14546 		 vlan, "vlan");
14547 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
14548 	TOKEN_STRING_INITIALIZER
14549 		(struct cmd_set_vf_vlan_tag_result,
14550 		 tag, "tag");
14551 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
14552 	TOKEN_NUM_INITIALIZER
14553 		(struct cmd_set_vf_vlan_tag_result,
14554 		 port_id, UINT16);
14555 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
14556 	TOKEN_NUM_INITIALIZER
14557 		(struct cmd_set_vf_vlan_tag_result,
14558 		 vf_id, UINT16);
14559 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
14560 	TOKEN_STRING_INITIALIZER
14561 		(struct cmd_set_vf_vlan_tag_result,
14562 		 on_off, "on#off");
14563 
14564 static void
14565 cmd_set_vf_vlan_tag_parsed(
14566 	void *parsed_result,
14567 	__attribute__((unused)) struct cmdline *cl,
14568 	__attribute__((unused)) void *data)
14569 {
14570 	struct cmd_set_vf_vlan_tag_result *res = parsed_result;
14571 	int ret = -ENOTSUP;
14572 
14573 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14574 
14575 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14576 		return;
14577 
14578 #ifdef RTE_LIBRTE_I40E_PMD
14579 	ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
14580 					   res->vf_id, is_on);
14581 #endif
14582 
14583 	switch (ret) {
14584 	case 0:
14585 		break;
14586 	case -EINVAL:
14587 		printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14588 		break;
14589 	case -ENODEV:
14590 		printf("invalid port_id %d\n", res->port_id);
14591 		break;
14592 	case -ENOTSUP:
14593 		printf("function not implemented\n");
14594 		break;
14595 	default:
14596 		printf("programming error: (%s)\n", strerror(-ret));
14597 	}
14598 }
14599 
14600 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
14601 	.f = cmd_set_vf_vlan_tag_parsed,
14602 	.data = NULL,
14603 	.help_str = "set vf vlan tag <port_id> <vf_id> on|off",
14604 	.tokens = {
14605 		(void *)&cmd_set_vf_vlan_tag_set,
14606 		(void *)&cmd_set_vf_vlan_tag_vf,
14607 		(void *)&cmd_set_vf_vlan_tag_vlan,
14608 		(void *)&cmd_set_vf_vlan_tag_tag,
14609 		(void *)&cmd_set_vf_vlan_tag_port_id,
14610 		(void *)&cmd_set_vf_vlan_tag_vf_id,
14611 		(void *)&cmd_set_vf_vlan_tag_on_off,
14612 		NULL,
14613 	},
14614 };
14615 
14616 /* Common definition of VF and TC TX bandwidth configuration */
14617 struct cmd_vf_tc_bw_result {
14618 	cmdline_fixed_string_t set;
14619 	cmdline_fixed_string_t vf;
14620 	cmdline_fixed_string_t tc;
14621 	cmdline_fixed_string_t tx;
14622 	cmdline_fixed_string_t min_bw;
14623 	cmdline_fixed_string_t max_bw;
14624 	cmdline_fixed_string_t strict_link_prio;
14625 	portid_t port_id;
14626 	uint16_t vf_id;
14627 	uint8_t tc_no;
14628 	uint32_t bw;
14629 	cmdline_fixed_string_t bw_list;
14630 	uint8_t tc_map;
14631 };
14632 
14633 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
14634 	TOKEN_STRING_INITIALIZER
14635 		(struct cmd_vf_tc_bw_result,
14636 		 set, "set");
14637 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
14638 	TOKEN_STRING_INITIALIZER
14639 		(struct cmd_vf_tc_bw_result,
14640 		 vf, "vf");
14641 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
14642 	TOKEN_STRING_INITIALIZER
14643 		(struct cmd_vf_tc_bw_result,
14644 		 tc, "tc");
14645 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
14646 	TOKEN_STRING_INITIALIZER
14647 		(struct cmd_vf_tc_bw_result,
14648 		 tx, "tx");
14649 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
14650 	TOKEN_STRING_INITIALIZER
14651 		(struct cmd_vf_tc_bw_result,
14652 		 strict_link_prio, "strict-link-priority");
14653 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
14654 	TOKEN_STRING_INITIALIZER
14655 		(struct cmd_vf_tc_bw_result,
14656 		 min_bw, "min-bandwidth");
14657 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
14658 	TOKEN_STRING_INITIALIZER
14659 		(struct cmd_vf_tc_bw_result,
14660 		 max_bw, "max-bandwidth");
14661 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
14662 	TOKEN_NUM_INITIALIZER
14663 		(struct cmd_vf_tc_bw_result,
14664 		 port_id, UINT16);
14665 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
14666 	TOKEN_NUM_INITIALIZER
14667 		(struct cmd_vf_tc_bw_result,
14668 		 vf_id, UINT16);
14669 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
14670 	TOKEN_NUM_INITIALIZER
14671 		(struct cmd_vf_tc_bw_result,
14672 		 tc_no, UINT8);
14673 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
14674 	TOKEN_NUM_INITIALIZER
14675 		(struct cmd_vf_tc_bw_result,
14676 		 bw, UINT32);
14677 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
14678 	TOKEN_STRING_INITIALIZER
14679 		(struct cmd_vf_tc_bw_result,
14680 		 bw_list, NULL);
14681 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
14682 	TOKEN_NUM_INITIALIZER
14683 		(struct cmd_vf_tc_bw_result,
14684 		 tc_map, UINT8);
14685 
14686 /* VF max bandwidth setting */
14687 static void
14688 cmd_vf_max_bw_parsed(
14689 	void *parsed_result,
14690 	__attribute__((unused)) struct cmdline *cl,
14691 	__attribute__((unused)) void *data)
14692 {
14693 	struct cmd_vf_tc_bw_result *res = parsed_result;
14694 	int ret = -ENOTSUP;
14695 
14696 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14697 		return;
14698 
14699 #ifdef RTE_LIBRTE_I40E_PMD
14700 	ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
14701 					 res->vf_id, res->bw);
14702 #endif
14703 
14704 	switch (ret) {
14705 	case 0:
14706 		break;
14707 	case -EINVAL:
14708 		printf("invalid vf_id %d or bandwidth %d\n",
14709 		       res->vf_id, res->bw);
14710 		break;
14711 	case -ENODEV:
14712 		printf("invalid port_id %d\n", res->port_id);
14713 		break;
14714 	case -ENOTSUP:
14715 		printf("function not implemented\n");
14716 		break;
14717 	default:
14718 		printf("programming error: (%s)\n", strerror(-ret));
14719 	}
14720 }
14721 
14722 cmdline_parse_inst_t cmd_vf_max_bw = {
14723 	.f = cmd_vf_max_bw_parsed,
14724 	.data = NULL,
14725 	.help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
14726 	.tokens = {
14727 		(void *)&cmd_vf_tc_bw_set,
14728 		(void *)&cmd_vf_tc_bw_vf,
14729 		(void *)&cmd_vf_tc_bw_tx,
14730 		(void *)&cmd_vf_tc_bw_max_bw,
14731 		(void *)&cmd_vf_tc_bw_port_id,
14732 		(void *)&cmd_vf_tc_bw_vf_id,
14733 		(void *)&cmd_vf_tc_bw_bw,
14734 		NULL,
14735 	},
14736 };
14737 
14738 static int
14739 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
14740 			   uint8_t *tc_num,
14741 			   char *str)
14742 {
14743 	uint32_t size;
14744 	const char *p, *p0 = str;
14745 	char s[256];
14746 	char *end;
14747 	char *str_fld[16];
14748 	uint16_t i;
14749 	int ret;
14750 
14751 	p = strchr(p0, '(');
14752 	if (p == NULL) {
14753 		printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14754 		return -1;
14755 	}
14756 	p++;
14757 	p0 = strchr(p, ')');
14758 	if (p0 == NULL) {
14759 		printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14760 		return -1;
14761 	}
14762 	size = p0 - p;
14763 	if (size >= sizeof(s)) {
14764 		printf("The string size exceeds the internal buffer size\n");
14765 		return -1;
14766 	}
14767 	snprintf(s, sizeof(s), "%.*s", size, p);
14768 	ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
14769 	if (ret <= 0) {
14770 		printf("Failed to get the bandwidth list. ");
14771 		return -1;
14772 	}
14773 	*tc_num = ret;
14774 	for (i = 0; i < ret; i++)
14775 		bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
14776 
14777 	return 0;
14778 }
14779 
14780 /* TC min bandwidth setting */
14781 static void
14782 cmd_vf_tc_min_bw_parsed(
14783 	void *parsed_result,
14784 	__attribute__((unused)) struct cmdline *cl,
14785 	__attribute__((unused)) void *data)
14786 {
14787 	struct cmd_vf_tc_bw_result *res = parsed_result;
14788 	uint8_t tc_num;
14789 	uint8_t bw[16];
14790 	int ret = -ENOTSUP;
14791 
14792 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14793 		return;
14794 
14795 	ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
14796 	if (ret)
14797 		return;
14798 
14799 #ifdef RTE_LIBRTE_I40E_PMD
14800 	ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
14801 					      tc_num, bw);
14802 #endif
14803 
14804 	switch (ret) {
14805 	case 0:
14806 		break;
14807 	case -EINVAL:
14808 		printf("invalid vf_id %d or bandwidth\n", res->vf_id);
14809 		break;
14810 	case -ENODEV:
14811 		printf("invalid port_id %d\n", res->port_id);
14812 		break;
14813 	case -ENOTSUP:
14814 		printf("function not implemented\n");
14815 		break;
14816 	default:
14817 		printf("programming error: (%s)\n", strerror(-ret));
14818 	}
14819 }
14820 
14821 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
14822 	.f = cmd_vf_tc_min_bw_parsed,
14823 	.data = NULL,
14824 	.help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
14825 		    " <bw1, bw2, ...>",
14826 	.tokens = {
14827 		(void *)&cmd_vf_tc_bw_set,
14828 		(void *)&cmd_vf_tc_bw_vf,
14829 		(void *)&cmd_vf_tc_bw_tc,
14830 		(void *)&cmd_vf_tc_bw_tx,
14831 		(void *)&cmd_vf_tc_bw_min_bw,
14832 		(void *)&cmd_vf_tc_bw_port_id,
14833 		(void *)&cmd_vf_tc_bw_vf_id,
14834 		(void *)&cmd_vf_tc_bw_bw_list,
14835 		NULL,
14836 	},
14837 };
14838 
14839 static void
14840 cmd_tc_min_bw_parsed(
14841 	void *parsed_result,
14842 	__attribute__((unused)) struct cmdline *cl,
14843 	__attribute__((unused)) void *data)
14844 {
14845 	struct cmd_vf_tc_bw_result *res = parsed_result;
14846 	struct rte_port *port;
14847 	uint8_t tc_num;
14848 	uint8_t bw[16];
14849 	int ret = -ENOTSUP;
14850 
14851 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14852 		return;
14853 
14854 	port = &ports[res->port_id];
14855 	/** Check if the port is not started **/
14856 	if (port->port_status != RTE_PORT_STOPPED) {
14857 		printf("Please stop port %d first\n", res->port_id);
14858 		return;
14859 	}
14860 
14861 	ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
14862 	if (ret)
14863 		return;
14864 
14865 #ifdef RTE_LIBRTE_IXGBE_PMD
14866 	ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
14867 #endif
14868 
14869 	switch (ret) {
14870 	case 0:
14871 		break;
14872 	case -EINVAL:
14873 		printf("invalid bandwidth\n");
14874 		break;
14875 	case -ENODEV:
14876 		printf("invalid port_id %d\n", res->port_id);
14877 		break;
14878 	case -ENOTSUP:
14879 		printf("function not implemented\n");
14880 		break;
14881 	default:
14882 		printf("programming error: (%s)\n", strerror(-ret));
14883 	}
14884 }
14885 
14886 cmdline_parse_inst_t cmd_tc_min_bw = {
14887 	.f = cmd_tc_min_bw_parsed,
14888 	.data = NULL,
14889 	.help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
14890 	.tokens = {
14891 		(void *)&cmd_vf_tc_bw_set,
14892 		(void *)&cmd_vf_tc_bw_tc,
14893 		(void *)&cmd_vf_tc_bw_tx,
14894 		(void *)&cmd_vf_tc_bw_min_bw,
14895 		(void *)&cmd_vf_tc_bw_port_id,
14896 		(void *)&cmd_vf_tc_bw_bw_list,
14897 		NULL,
14898 	},
14899 };
14900 
14901 /* TC max bandwidth setting */
14902 static void
14903 cmd_vf_tc_max_bw_parsed(
14904 	void *parsed_result,
14905 	__attribute__((unused)) struct cmdline *cl,
14906 	__attribute__((unused)) void *data)
14907 {
14908 	struct cmd_vf_tc_bw_result *res = parsed_result;
14909 	int ret = -ENOTSUP;
14910 
14911 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14912 		return;
14913 
14914 #ifdef RTE_LIBRTE_I40E_PMD
14915 	ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
14916 					    res->tc_no, res->bw);
14917 #endif
14918 
14919 	switch (ret) {
14920 	case 0:
14921 		break;
14922 	case -EINVAL:
14923 		printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
14924 		       res->vf_id, res->tc_no, res->bw);
14925 		break;
14926 	case -ENODEV:
14927 		printf("invalid port_id %d\n", res->port_id);
14928 		break;
14929 	case -ENOTSUP:
14930 		printf("function not implemented\n");
14931 		break;
14932 	default:
14933 		printf("programming error: (%s)\n", strerror(-ret));
14934 	}
14935 }
14936 
14937 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
14938 	.f = cmd_vf_tc_max_bw_parsed,
14939 	.data = NULL,
14940 	.help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
14941 		    " <bandwidth>",
14942 	.tokens = {
14943 		(void *)&cmd_vf_tc_bw_set,
14944 		(void *)&cmd_vf_tc_bw_vf,
14945 		(void *)&cmd_vf_tc_bw_tc,
14946 		(void *)&cmd_vf_tc_bw_tx,
14947 		(void *)&cmd_vf_tc_bw_max_bw,
14948 		(void *)&cmd_vf_tc_bw_port_id,
14949 		(void *)&cmd_vf_tc_bw_vf_id,
14950 		(void *)&cmd_vf_tc_bw_tc_no,
14951 		(void *)&cmd_vf_tc_bw_bw,
14952 		NULL,
14953 	},
14954 };
14955 
14956 
14957 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
14958 
14959 /* *** Set Port default Traffic Management Hierarchy *** */
14960 struct cmd_set_port_tm_hierarchy_default_result {
14961 	cmdline_fixed_string_t set;
14962 	cmdline_fixed_string_t port;
14963 	cmdline_fixed_string_t tm;
14964 	cmdline_fixed_string_t hierarchy;
14965 	cmdline_fixed_string_t def;
14966 	portid_t port_id;
14967 };
14968 
14969 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_set =
14970 	TOKEN_STRING_INITIALIZER(
14971 		struct cmd_set_port_tm_hierarchy_default_result, set, "set");
14972 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_port =
14973 	TOKEN_STRING_INITIALIZER(
14974 		struct cmd_set_port_tm_hierarchy_default_result, port, "port");
14975 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_tm =
14976 	TOKEN_STRING_INITIALIZER(
14977 		struct cmd_set_port_tm_hierarchy_default_result, tm, "tm");
14978 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_hierarchy =
14979 	TOKEN_STRING_INITIALIZER(
14980 		struct cmd_set_port_tm_hierarchy_default_result,
14981 			hierarchy, "hierarchy");
14982 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_default =
14983 	TOKEN_STRING_INITIALIZER(
14984 		struct cmd_set_port_tm_hierarchy_default_result,
14985 			def, "default");
14986 cmdline_parse_token_num_t cmd_set_port_tm_hierarchy_default_port_id =
14987 	TOKEN_NUM_INITIALIZER(
14988 		struct cmd_set_port_tm_hierarchy_default_result,
14989 			port_id, UINT16);
14990 
14991 static void cmd_set_port_tm_hierarchy_default_parsed(void *parsed_result,
14992 	__attribute__((unused)) struct cmdline *cl,
14993 	__attribute__((unused)) void *data)
14994 {
14995 	struct cmd_set_port_tm_hierarchy_default_result *res = parsed_result;
14996 	struct rte_port *p;
14997 	portid_t port_id = res->port_id;
14998 
14999 	if (port_id_is_invalid(port_id, ENABLED_WARN))
15000 		return;
15001 
15002 	p = &ports[port_id];
15003 
15004 	/* Forward mode: tm */
15005 	if (strcmp(cur_fwd_config.fwd_eng->fwd_mode_name, "softnic")) {
15006 		printf("  softnicfwd mode not enabled(error)\n");
15007 		return;
15008 	}
15009 
15010 	/* Set the default tm hierarchy */
15011 	p->softport.default_tm_hierarchy_enable = 1;
15012 }
15013 
15014 cmdline_parse_inst_t cmd_set_port_tm_hierarchy_default = {
15015 	.f = cmd_set_port_tm_hierarchy_default_parsed,
15016 	.data = NULL,
15017 	.help_str = "set port tm hierarchy default <port_id>",
15018 	.tokens = {
15019 		(void *)&cmd_set_port_tm_hierarchy_default_set,
15020 		(void *)&cmd_set_port_tm_hierarchy_default_port,
15021 		(void *)&cmd_set_port_tm_hierarchy_default_tm,
15022 		(void *)&cmd_set_port_tm_hierarchy_default_hierarchy,
15023 		(void *)&cmd_set_port_tm_hierarchy_default_default,
15024 		(void *)&cmd_set_port_tm_hierarchy_default_port_id,
15025 		NULL,
15026 	},
15027 };
15028 #endif
15029 
15030 /** Set VXLAN encapsulation details */
15031 struct cmd_set_vxlan_result {
15032 	cmdline_fixed_string_t set;
15033 	cmdline_fixed_string_t vxlan;
15034 	cmdline_fixed_string_t pos_token;
15035 	cmdline_fixed_string_t ip_version;
15036 	uint32_t vlan_present:1;
15037 	uint32_t vni;
15038 	uint16_t udp_src;
15039 	uint16_t udp_dst;
15040 	cmdline_ipaddr_t ip_src;
15041 	cmdline_ipaddr_t ip_dst;
15042 	uint16_t tci;
15043 	uint8_t tos;
15044 	uint8_t ttl;
15045 	struct ether_addr eth_src;
15046 	struct ether_addr eth_dst;
15047 };
15048 
15049 cmdline_parse_token_string_t cmd_set_vxlan_set =
15050 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
15051 cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
15052 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
15053 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
15054 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15055 				 "vxlan-tos-ttl");
15056 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
15057 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15058 				 "vxlan-with-vlan");
15059 cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
15060 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15061 				 "ip-version");
15062 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
15063 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
15064 				 "ipv4#ipv6");
15065 cmdline_parse_token_string_t cmd_set_vxlan_vni =
15066 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15067 				 "vni");
15068 cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
15069 	TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, UINT32);
15070 cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
15071 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15072 				 "udp-src");
15073 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
15074 	TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, UINT16);
15075 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
15076 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15077 				 "udp-dst");
15078 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
15079 	TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, UINT16);
15080 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
15081 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15082 				 "ip-tos");
15083 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
15084 	TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, UINT8);
15085 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
15086 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15087 				 "ip-ttl");
15088 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
15089 	TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, UINT8);
15090 cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
15091 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15092 				 "ip-src");
15093 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
15094 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
15095 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
15096 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15097 				 "ip-dst");
15098 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
15099 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
15100 cmdline_parse_token_string_t cmd_set_vxlan_vlan =
15101 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15102 				 "vlan-tci");
15103 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
15104 	TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, UINT16);
15105 cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
15106 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15107 				 "eth-src");
15108 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
15109 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
15110 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
15111 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15112 				 "eth-dst");
15113 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
15114 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
15115 
15116 static void cmd_set_vxlan_parsed(void *parsed_result,
15117 	__attribute__((unused)) struct cmdline *cl,
15118 	__attribute__((unused)) void *data)
15119 {
15120 	struct cmd_set_vxlan_result *res = parsed_result;
15121 	union {
15122 		uint32_t vxlan_id;
15123 		uint8_t vni[4];
15124 	} id = {
15125 		.vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
15126 	};
15127 
15128 	vxlan_encap_conf.select_tos_ttl = 0;
15129 	if (strcmp(res->vxlan, "vxlan") == 0)
15130 		vxlan_encap_conf.select_vlan = 0;
15131 	else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
15132 		vxlan_encap_conf.select_vlan = 1;
15133 	else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
15134 		vxlan_encap_conf.select_vlan = 0;
15135 		vxlan_encap_conf.select_tos_ttl = 1;
15136 	}
15137 	if (strcmp(res->ip_version, "ipv4") == 0)
15138 		vxlan_encap_conf.select_ipv4 = 1;
15139 	else if (strcmp(res->ip_version, "ipv6") == 0)
15140 		vxlan_encap_conf.select_ipv4 = 0;
15141 	else
15142 		return;
15143 	rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
15144 	vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
15145 	vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
15146 	vxlan_encap_conf.ip_tos = res->tos;
15147 	vxlan_encap_conf.ip_ttl = res->ttl;
15148 	if (vxlan_encap_conf.select_ipv4) {
15149 		IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
15150 		IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
15151 	} else {
15152 		IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
15153 		IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
15154 	}
15155 	if (vxlan_encap_conf.select_vlan)
15156 		vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15157 	rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
15158 		   ETHER_ADDR_LEN);
15159 	rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15160 		   ETHER_ADDR_LEN);
15161 }
15162 
15163 cmdline_parse_inst_t cmd_set_vxlan = {
15164 	.f = cmd_set_vxlan_parsed,
15165 	.data = NULL,
15166 	.help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
15167 		" <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
15168 		" eth-src <eth-src> eth-dst <eth-dst>",
15169 	.tokens = {
15170 		(void *)&cmd_set_vxlan_set,
15171 		(void *)&cmd_set_vxlan_vxlan,
15172 		(void *)&cmd_set_vxlan_ip_version,
15173 		(void *)&cmd_set_vxlan_ip_version_value,
15174 		(void *)&cmd_set_vxlan_vni,
15175 		(void *)&cmd_set_vxlan_vni_value,
15176 		(void *)&cmd_set_vxlan_udp_src,
15177 		(void *)&cmd_set_vxlan_udp_src_value,
15178 		(void *)&cmd_set_vxlan_udp_dst,
15179 		(void *)&cmd_set_vxlan_udp_dst_value,
15180 		(void *)&cmd_set_vxlan_ip_src,
15181 		(void *)&cmd_set_vxlan_ip_src_value,
15182 		(void *)&cmd_set_vxlan_ip_dst,
15183 		(void *)&cmd_set_vxlan_ip_dst_value,
15184 		(void *)&cmd_set_vxlan_eth_src,
15185 		(void *)&cmd_set_vxlan_eth_src_value,
15186 		(void *)&cmd_set_vxlan_eth_dst,
15187 		(void *)&cmd_set_vxlan_eth_dst_value,
15188 		NULL,
15189 	},
15190 };
15191 
15192 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
15193 	.f = cmd_set_vxlan_parsed,
15194 	.data = NULL,
15195 	.help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
15196 		" <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
15197 		" ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15198 		" eth-dst <eth-dst>",
15199 	.tokens = {
15200 		(void *)&cmd_set_vxlan_set,
15201 		(void *)&cmd_set_vxlan_vxlan_tos_ttl,
15202 		(void *)&cmd_set_vxlan_ip_version,
15203 		(void *)&cmd_set_vxlan_ip_version_value,
15204 		(void *)&cmd_set_vxlan_vni,
15205 		(void *)&cmd_set_vxlan_vni_value,
15206 		(void *)&cmd_set_vxlan_udp_src,
15207 		(void *)&cmd_set_vxlan_udp_src_value,
15208 		(void *)&cmd_set_vxlan_udp_dst,
15209 		(void *)&cmd_set_vxlan_udp_dst_value,
15210 		(void *)&cmd_set_vxlan_ip_tos,
15211 		(void *)&cmd_set_vxlan_ip_tos_value,
15212 		(void *)&cmd_set_vxlan_ip_ttl,
15213 		(void *)&cmd_set_vxlan_ip_ttl_value,
15214 		(void *)&cmd_set_vxlan_ip_src,
15215 		(void *)&cmd_set_vxlan_ip_src_value,
15216 		(void *)&cmd_set_vxlan_ip_dst,
15217 		(void *)&cmd_set_vxlan_ip_dst_value,
15218 		(void *)&cmd_set_vxlan_eth_src,
15219 		(void *)&cmd_set_vxlan_eth_src_value,
15220 		(void *)&cmd_set_vxlan_eth_dst,
15221 		(void *)&cmd_set_vxlan_eth_dst_value,
15222 		NULL,
15223 	},
15224 };
15225 
15226 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
15227 	.f = cmd_set_vxlan_parsed,
15228 	.data = NULL,
15229 	.help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
15230 		" udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
15231 		" <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
15232 		" <eth-dst>",
15233 	.tokens = {
15234 		(void *)&cmd_set_vxlan_set,
15235 		(void *)&cmd_set_vxlan_vxlan_with_vlan,
15236 		(void *)&cmd_set_vxlan_ip_version,
15237 		(void *)&cmd_set_vxlan_ip_version_value,
15238 		(void *)&cmd_set_vxlan_vni,
15239 		(void *)&cmd_set_vxlan_vni_value,
15240 		(void *)&cmd_set_vxlan_udp_src,
15241 		(void *)&cmd_set_vxlan_udp_src_value,
15242 		(void *)&cmd_set_vxlan_udp_dst,
15243 		(void *)&cmd_set_vxlan_udp_dst_value,
15244 		(void *)&cmd_set_vxlan_ip_src,
15245 		(void *)&cmd_set_vxlan_ip_src_value,
15246 		(void *)&cmd_set_vxlan_ip_dst,
15247 		(void *)&cmd_set_vxlan_ip_dst_value,
15248 		(void *)&cmd_set_vxlan_vlan,
15249 		(void *)&cmd_set_vxlan_vlan_value,
15250 		(void *)&cmd_set_vxlan_eth_src,
15251 		(void *)&cmd_set_vxlan_eth_src_value,
15252 		(void *)&cmd_set_vxlan_eth_dst,
15253 		(void *)&cmd_set_vxlan_eth_dst_value,
15254 		NULL,
15255 	},
15256 };
15257 
15258 /** Set NVGRE encapsulation details */
15259 struct cmd_set_nvgre_result {
15260 	cmdline_fixed_string_t set;
15261 	cmdline_fixed_string_t nvgre;
15262 	cmdline_fixed_string_t pos_token;
15263 	cmdline_fixed_string_t ip_version;
15264 	uint32_t tni;
15265 	cmdline_ipaddr_t ip_src;
15266 	cmdline_ipaddr_t ip_dst;
15267 	uint16_t tci;
15268 	struct ether_addr eth_src;
15269 	struct ether_addr eth_dst;
15270 };
15271 
15272 cmdline_parse_token_string_t cmd_set_nvgre_set =
15273 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
15274 cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
15275 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
15276 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
15277 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
15278 				 "nvgre-with-vlan");
15279 cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
15280 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15281 				 "ip-version");
15282 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
15283 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
15284 				 "ipv4#ipv6");
15285 cmdline_parse_token_string_t cmd_set_nvgre_tni =
15286 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15287 				 "tni");
15288 cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
15289 	TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, UINT32);
15290 cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
15291 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15292 				 "ip-src");
15293 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
15294 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
15295 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
15296 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15297 				 "ip-dst");
15298 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
15299 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
15300 cmdline_parse_token_string_t cmd_set_nvgre_vlan =
15301 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15302 				 "vlan-tci");
15303 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
15304 	TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, UINT16);
15305 cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
15306 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15307 				 "eth-src");
15308 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
15309 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
15310 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
15311 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15312 				 "eth-dst");
15313 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
15314 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
15315 
15316 static void cmd_set_nvgre_parsed(void *parsed_result,
15317 	__attribute__((unused)) struct cmdline *cl,
15318 	__attribute__((unused)) void *data)
15319 {
15320 	struct cmd_set_nvgre_result *res = parsed_result;
15321 	union {
15322 		uint32_t nvgre_tni;
15323 		uint8_t tni[4];
15324 	} id = {
15325 		.nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
15326 	};
15327 
15328 	if (strcmp(res->nvgre, "nvgre") == 0)
15329 		nvgre_encap_conf.select_vlan = 0;
15330 	else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
15331 		nvgre_encap_conf.select_vlan = 1;
15332 	if (strcmp(res->ip_version, "ipv4") == 0)
15333 		nvgre_encap_conf.select_ipv4 = 1;
15334 	else if (strcmp(res->ip_version, "ipv6") == 0)
15335 		nvgre_encap_conf.select_ipv4 = 0;
15336 	else
15337 		return;
15338 	rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
15339 	if (nvgre_encap_conf.select_ipv4) {
15340 		IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
15341 		IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
15342 	} else {
15343 		IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
15344 		IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
15345 	}
15346 	if (nvgre_encap_conf.select_vlan)
15347 		nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15348 	rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
15349 		   ETHER_ADDR_LEN);
15350 	rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15351 		   ETHER_ADDR_LEN);
15352 }
15353 
15354 cmdline_parse_inst_t cmd_set_nvgre = {
15355 	.f = cmd_set_nvgre_parsed,
15356 	.data = NULL,
15357 	.help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
15358 		" <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15359 		" eth-dst <eth-dst>",
15360 	.tokens = {
15361 		(void *)&cmd_set_nvgre_set,
15362 		(void *)&cmd_set_nvgre_nvgre,
15363 		(void *)&cmd_set_nvgre_ip_version,
15364 		(void *)&cmd_set_nvgre_ip_version_value,
15365 		(void *)&cmd_set_nvgre_tni,
15366 		(void *)&cmd_set_nvgre_tni_value,
15367 		(void *)&cmd_set_nvgre_ip_src,
15368 		(void *)&cmd_set_nvgre_ip_src_value,
15369 		(void *)&cmd_set_nvgre_ip_dst,
15370 		(void *)&cmd_set_nvgre_ip_dst_value,
15371 		(void *)&cmd_set_nvgre_eth_src,
15372 		(void *)&cmd_set_nvgre_eth_src_value,
15373 		(void *)&cmd_set_nvgre_eth_dst,
15374 		(void *)&cmd_set_nvgre_eth_dst_value,
15375 		NULL,
15376 	},
15377 };
15378 
15379 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
15380 	.f = cmd_set_nvgre_parsed,
15381 	.data = NULL,
15382 	.help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
15383 		" ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
15384 		" eth-src <eth-src> eth-dst <eth-dst>",
15385 	.tokens = {
15386 		(void *)&cmd_set_nvgre_set,
15387 		(void *)&cmd_set_nvgre_nvgre_with_vlan,
15388 		(void *)&cmd_set_nvgre_ip_version,
15389 		(void *)&cmd_set_nvgre_ip_version_value,
15390 		(void *)&cmd_set_nvgre_tni,
15391 		(void *)&cmd_set_nvgre_tni_value,
15392 		(void *)&cmd_set_nvgre_ip_src,
15393 		(void *)&cmd_set_nvgre_ip_src_value,
15394 		(void *)&cmd_set_nvgre_ip_dst,
15395 		(void *)&cmd_set_nvgre_ip_dst_value,
15396 		(void *)&cmd_set_nvgre_vlan,
15397 		(void *)&cmd_set_nvgre_vlan_value,
15398 		(void *)&cmd_set_nvgre_eth_src,
15399 		(void *)&cmd_set_nvgre_eth_src_value,
15400 		(void *)&cmd_set_nvgre_eth_dst,
15401 		(void *)&cmd_set_nvgre_eth_dst_value,
15402 		NULL,
15403 	},
15404 };
15405 
15406 /** Set L2 encapsulation details */
15407 struct cmd_set_l2_encap_result {
15408 	cmdline_fixed_string_t set;
15409 	cmdline_fixed_string_t l2_encap;
15410 	cmdline_fixed_string_t pos_token;
15411 	cmdline_fixed_string_t ip_version;
15412 	uint32_t vlan_present:1;
15413 	uint16_t tci;
15414 	struct ether_addr eth_src;
15415 	struct ether_addr eth_dst;
15416 };
15417 
15418 cmdline_parse_token_string_t cmd_set_l2_encap_set =
15419 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
15420 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
15421 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
15422 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
15423 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
15424 				 "l2_encap-with-vlan");
15425 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
15426 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15427 				 "ip-version");
15428 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
15429 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
15430 				 "ipv4#ipv6");
15431 cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
15432 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15433 				 "vlan-tci");
15434 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
15435 	TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, UINT16);
15436 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
15437 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15438 				 "eth-src");
15439 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
15440 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
15441 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
15442 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15443 				 "eth-dst");
15444 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
15445 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
15446 
15447 static void cmd_set_l2_encap_parsed(void *parsed_result,
15448 	__attribute__((unused)) struct cmdline *cl,
15449 	__attribute__((unused)) void *data)
15450 {
15451 	struct cmd_set_l2_encap_result *res = parsed_result;
15452 
15453 	if (strcmp(res->l2_encap, "l2_encap") == 0)
15454 		l2_encap_conf.select_vlan = 0;
15455 	else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
15456 		l2_encap_conf.select_vlan = 1;
15457 	if (strcmp(res->ip_version, "ipv4") == 0)
15458 		l2_encap_conf.select_ipv4 = 1;
15459 	else if (strcmp(res->ip_version, "ipv6") == 0)
15460 		l2_encap_conf.select_ipv4 = 0;
15461 	else
15462 		return;
15463 	if (l2_encap_conf.select_vlan)
15464 		l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15465 	rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
15466 		   ETHER_ADDR_LEN);
15467 	rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15468 		   ETHER_ADDR_LEN);
15469 }
15470 
15471 cmdline_parse_inst_t cmd_set_l2_encap = {
15472 	.f = cmd_set_l2_encap_parsed,
15473 	.data = NULL,
15474 	.help_str = "set l2_encap ip-version ipv4|ipv6"
15475 		" eth-src <eth-src> eth-dst <eth-dst>",
15476 	.tokens = {
15477 		(void *)&cmd_set_l2_encap_set,
15478 		(void *)&cmd_set_l2_encap_l2_encap,
15479 		(void *)&cmd_set_l2_encap_ip_version,
15480 		(void *)&cmd_set_l2_encap_ip_version_value,
15481 		(void *)&cmd_set_l2_encap_eth_src,
15482 		(void *)&cmd_set_l2_encap_eth_src_value,
15483 		(void *)&cmd_set_l2_encap_eth_dst,
15484 		(void *)&cmd_set_l2_encap_eth_dst_value,
15485 		NULL,
15486 	},
15487 };
15488 
15489 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
15490 	.f = cmd_set_l2_encap_parsed,
15491 	.data = NULL,
15492 	.help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
15493 		" vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
15494 	.tokens = {
15495 		(void *)&cmd_set_l2_encap_set,
15496 		(void *)&cmd_set_l2_encap_l2_encap_with_vlan,
15497 		(void *)&cmd_set_l2_encap_ip_version,
15498 		(void *)&cmd_set_l2_encap_ip_version_value,
15499 		(void *)&cmd_set_l2_encap_vlan,
15500 		(void *)&cmd_set_l2_encap_vlan_value,
15501 		(void *)&cmd_set_l2_encap_eth_src,
15502 		(void *)&cmd_set_l2_encap_eth_src_value,
15503 		(void *)&cmd_set_l2_encap_eth_dst,
15504 		(void *)&cmd_set_l2_encap_eth_dst_value,
15505 		NULL,
15506 	},
15507 };
15508 
15509 /** Set L2 decapsulation details */
15510 struct cmd_set_l2_decap_result {
15511 	cmdline_fixed_string_t set;
15512 	cmdline_fixed_string_t l2_decap;
15513 	cmdline_fixed_string_t pos_token;
15514 	uint32_t vlan_present:1;
15515 };
15516 
15517 cmdline_parse_token_string_t cmd_set_l2_decap_set =
15518 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
15519 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
15520 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
15521 				 "l2_decap");
15522 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
15523 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
15524 				 "l2_decap-with-vlan");
15525 
15526 static void cmd_set_l2_decap_parsed(void *parsed_result,
15527 	__attribute__((unused)) struct cmdline *cl,
15528 	__attribute__((unused)) void *data)
15529 {
15530 	struct cmd_set_l2_decap_result *res = parsed_result;
15531 
15532 	if (strcmp(res->l2_decap, "l2_decap") == 0)
15533 		l2_decap_conf.select_vlan = 0;
15534 	else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
15535 		l2_decap_conf.select_vlan = 1;
15536 }
15537 
15538 cmdline_parse_inst_t cmd_set_l2_decap = {
15539 	.f = cmd_set_l2_decap_parsed,
15540 	.data = NULL,
15541 	.help_str = "set l2_decap",
15542 	.tokens = {
15543 		(void *)&cmd_set_l2_decap_set,
15544 		(void *)&cmd_set_l2_decap_l2_decap,
15545 		NULL,
15546 	},
15547 };
15548 
15549 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
15550 	.f = cmd_set_l2_decap_parsed,
15551 	.data = NULL,
15552 	.help_str = "set l2_decap-with-vlan",
15553 	.tokens = {
15554 		(void *)&cmd_set_l2_decap_set,
15555 		(void *)&cmd_set_l2_decap_l2_decap_with_vlan,
15556 		NULL,
15557 	},
15558 };
15559 
15560 /** Set MPLSoGRE encapsulation details */
15561 struct cmd_set_mplsogre_encap_result {
15562 	cmdline_fixed_string_t set;
15563 	cmdline_fixed_string_t mplsogre;
15564 	cmdline_fixed_string_t pos_token;
15565 	cmdline_fixed_string_t ip_version;
15566 	uint32_t vlan_present:1;
15567 	uint32_t label;
15568 	cmdline_ipaddr_t ip_src;
15569 	cmdline_ipaddr_t ip_dst;
15570 	uint16_t tci;
15571 	struct ether_addr eth_src;
15572 	struct ether_addr eth_dst;
15573 };
15574 
15575 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
15576 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
15577 				 "set");
15578 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
15579 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
15580 				 "mplsogre_encap");
15581 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
15582 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15583 				 mplsogre, "mplsogre_encap-with-vlan");
15584 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
15585 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15586 				 pos_token, "ip-version");
15587 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
15588 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15589 				 ip_version, "ipv4#ipv6");
15590 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
15591 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15592 				 pos_token, "label");
15593 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
15594 	TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
15595 			      UINT32);
15596 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
15597 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15598 				 pos_token, "ip-src");
15599 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
15600 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
15601 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
15602 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15603 				 pos_token, "ip-dst");
15604 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
15605 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
15606 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
15607 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15608 				 pos_token, "vlan-tci");
15609 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
15610 	TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
15611 			      UINT16);
15612 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
15613 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15614 				 pos_token, "eth-src");
15615 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
15616 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15617 				    eth_src);
15618 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
15619 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15620 				 pos_token, "eth-dst");
15621 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
15622 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15623 				    eth_dst);
15624 
15625 static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
15626 	__attribute__((unused)) struct cmdline *cl,
15627 	__attribute__((unused)) void *data)
15628 {
15629 	struct cmd_set_mplsogre_encap_result *res = parsed_result;
15630 	union {
15631 		uint32_t mplsogre_label;
15632 		uint8_t label[4];
15633 	} id = {
15634 		.mplsogre_label = rte_cpu_to_be_32(res->label<<12),
15635 	};
15636 
15637 	if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
15638 		mplsogre_encap_conf.select_vlan = 0;
15639 	else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
15640 		mplsogre_encap_conf.select_vlan = 1;
15641 	if (strcmp(res->ip_version, "ipv4") == 0)
15642 		mplsogre_encap_conf.select_ipv4 = 1;
15643 	else if (strcmp(res->ip_version, "ipv6") == 0)
15644 		mplsogre_encap_conf.select_ipv4 = 0;
15645 	else
15646 		return;
15647 	rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
15648 	if (mplsogre_encap_conf.select_ipv4) {
15649 		IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
15650 		IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
15651 	} else {
15652 		IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
15653 		IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
15654 	}
15655 	if (mplsogre_encap_conf.select_vlan)
15656 		mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15657 	rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
15658 		   ETHER_ADDR_LEN);
15659 	rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15660 		   ETHER_ADDR_LEN);
15661 }
15662 
15663 cmdline_parse_inst_t cmd_set_mplsogre_encap = {
15664 	.f = cmd_set_mplsogre_encap_parsed,
15665 	.data = NULL,
15666 	.help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
15667 		" ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15668 		" eth-dst <eth-dst>",
15669 	.tokens = {
15670 		(void *)&cmd_set_mplsogre_encap_set,
15671 		(void *)&cmd_set_mplsogre_encap_mplsogre_encap,
15672 		(void *)&cmd_set_mplsogre_encap_ip_version,
15673 		(void *)&cmd_set_mplsogre_encap_ip_version_value,
15674 		(void *)&cmd_set_mplsogre_encap_label,
15675 		(void *)&cmd_set_mplsogre_encap_label_value,
15676 		(void *)&cmd_set_mplsogre_encap_ip_src,
15677 		(void *)&cmd_set_mplsogre_encap_ip_src_value,
15678 		(void *)&cmd_set_mplsogre_encap_ip_dst,
15679 		(void *)&cmd_set_mplsogre_encap_ip_dst_value,
15680 		(void *)&cmd_set_mplsogre_encap_eth_src,
15681 		(void *)&cmd_set_mplsogre_encap_eth_src_value,
15682 		(void *)&cmd_set_mplsogre_encap_eth_dst,
15683 		(void *)&cmd_set_mplsogre_encap_eth_dst_value,
15684 		NULL,
15685 	},
15686 };
15687 
15688 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
15689 	.f = cmd_set_mplsogre_encap_parsed,
15690 	.data = NULL,
15691 	.help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
15692 		" label <label> ip-src <ip-src> ip-dst <ip-dst>"
15693 		" vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
15694 	.tokens = {
15695 		(void *)&cmd_set_mplsogre_encap_set,
15696 		(void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
15697 		(void *)&cmd_set_mplsogre_encap_ip_version,
15698 		(void *)&cmd_set_mplsogre_encap_ip_version_value,
15699 		(void *)&cmd_set_mplsogre_encap_label,
15700 		(void *)&cmd_set_mplsogre_encap_label_value,
15701 		(void *)&cmd_set_mplsogre_encap_ip_src,
15702 		(void *)&cmd_set_mplsogre_encap_ip_src_value,
15703 		(void *)&cmd_set_mplsogre_encap_ip_dst,
15704 		(void *)&cmd_set_mplsogre_encap_ip_dst_value,
15705 		(void *)&cmd_set_mplsogre_encap_vlan,
15706 		(void *)&cmd_set_mplsogre_encap_vlan_value,
15707 		(void *)&cmd_set_mplsogre_encap_eth_src,
15708 		(void *)&cmd_set_mplsogre_encap_eth_src_value,
15709 		(void *)&cmd_set_mplsogre_encap_eth_dst,
15710 		(void *)&cmd_set_mplsogre_encap_eth_dst_value,
15711 		NULL,
15712 	},
15713 };
15714 
15715 /** Set MPLSoGRE decapsulation details */
15716 struct cmd_set_mplsogre_decap_result {
15717 	cmdline_fixed_string_t set;
15718 	cmdline_fixed_string_t mplsogre;
15719 	cmdline_fixed_string_t pos_token;
15720 	cmdline_fixed_string_t ip_version;
15721 	uint32_t vlan_present:1;
15722 };
15723 
15724 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
15725 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
15726 				 "set");
15727 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
15728 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
15729 				 "mplsogre_decap");
15730 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
15731 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
15732 				 mplsogre, "mplsogre_decap-with-vlan");
15733 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
15734 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
15735 				 pos_token, "ip-version");
15736 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
15737 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
15738 				 ip_version, "ipv4#ipv6");
15739 
15740 static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
15741 	__attribute__((unused)) struct cmdline *cl,
15742 	__attribute__((unused)) void *data)
15743 {
15744 	struct cmd_set_mplsogre_decap_result *res = parsed_result;
15745 
15746 	if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
15747 		mplsogre_decap_conf.select_vlan = 0;
15748 	else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
15749 		mplsogre_decap_conf.select_vlan = 1;
15750 	if (strcmp(res->ip_version, "ipv4") == 0)
15751 		mplsogre_decap_conf.select_ipv4 = 1;
15752 	else if (strcmp(res->ip_version, "ipv6") == 0)
15753 		mplsogre_decap_conf.select_ipv4 = 0;
15754 }
15755 
15756 cmdline_parse_inst_t cmd_set_mplsogre_decap = {
15757 	.f = cmd_set_mplsogre_decap_parsed,
15758 	.data = NULL,
15759 	.help_str = "set mplsogre_decap ip-version ipv4|ipv6",
15760 	.tokens = {
15761 		(void *)&cmd_set_mplsogre_decap_set,
15762 		(void *)&cmd_set_mplsogre_decap_mplsogre_decap,
15763 		(void *)&cmd_set_mplsogre_decap_ip_version,
15764 		(void *)&cmd_set_mplsogre_decap_ip_version_value,
15765 		NULL,
15766 	},
15767 };
15768 
15769 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
15770 	.f = cmd_set_mplsogre_decap_parsed,
15771 	.data = NULL,
15772 	.help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
15773 	.tokens = {
15774 		(void *)&cmd_set_mplsogre_decap_set,
15775 		(void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
15776 		(void *)&cmd_set_mplsogre_decap_ip_version,
15777 		(void *)&cmd_set_mplsogre_decap_ip_version_value,
15778 		NULL,
15779 	},
15780 };
15781 
15782 /** Set MPLSoUDP encapsulation details */
15783 struct cmd_set_mplsoudp_encap_result {
15784 	cmdline_fixed_string_t set;
15785 	cmdline_fixed_string_t mplsoudp;
15786 	cmdline_fixed_string_t pos_token;
15787 	cmdline_fixed_string_t ip_version;
15788 	uint32_t vlan_present:1;
15789 	uint32_t label;
15790 	uint16_t udp_src;
15791 	uint16_t udp_dst;
15792 	cmdline_ipaddr_t ip_src;
15793 	cmdline_ipaddr_t ip_dst;
15794 	uint16_t tci;
15795 	struct ether_addr eth_src;
15796 	struct ether_addr eth_dst;
15797 };
15798 
15799 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
15800 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
15801 				 "set");
15802 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
15803 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
15804 				 "mplsoudp_encap");
15805 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
15806 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15807 				 mplsoudp, "mplsoudp_encap-with-vlan");
15808 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
15809 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15810 				 pos_token, "ip-version");
15811 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
15812 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15813 				 ip_version, "ipv4#ipv6");
15814 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
15815 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15816 				 pos_token, "label");
15817 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
15818 	TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
15819 			      UINT32);
15820 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
15821 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15822 				 pos_token, "udp-src");
15823 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
15824 	TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
15825 			      UINT16);
15826 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
15827 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15828 				 pos_token, "udp-dst");
15829 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
15830 	TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
15831 			      UINT16);
15832 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
15833 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15834 				 pos_token, "ip-src");
15835 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
15836 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
15837 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
15838 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15839 				 pos_token, "ip-dst");
15840 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
15841 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
15842 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
15843 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15844 				 pos_token, "vlan-tci");
15845 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
15846 	TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
15847 			      UINT16);
15848 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
15849 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15850 				 pos_token, "eth-src");
15851 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
15852 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15853 				    eth_src);
15854 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
15855 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15856 				 pos_token, "eth-dst");
15857 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
15858 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15859 				    eth_dst);
15860 
15861 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
15862 	__attribute__((unused)) struct cmdline *cl,
15863 	__attribute__((unused)) void *data)
15864 {
15865 	struct cmd_set_mplsoudp_encap_result *res = parsed_result;
15866 	union {
15867 		uint32_t mplsoudp_label;
15868 		uint8_t label[4];
15869 	} id = {
15870 		.mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
15871 	};
15872 
15873 	if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
15874 		mplsoudp_encap_conf.select_vlan = 0;
15875 	else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
15876 		mplsoudp_encap_conf.select_vlan = 1;
15877 	if (strcmp(res->ip_version, "ipv4") == 0)
15878 		mplsoudp_encap_conf.select_ipv4 = 1;
15879 	else if (strcmp(res->ip_version, "ipv6") == 0)
15880 		mplsoudp_encap_conf.select_ipv4 = 0;
15881 	else
15882 		return;
15883 	rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
15884 	mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
15885 	mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
15886 	if (mplsoudp_encap_conf.select_ipv4) {
15887 		IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
15888 		IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
15889 	} else {
15890 		IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
15891 		IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
15892 	}
15893 	if (mplsoudp_encap_conf.select_vlan)
15894 		mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15895 	rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
15896 		   ETHER_ADDR_LEN);
15897 	rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15898 		   ETHER_ADDR_LEN);
15899 }
15900 
15901 cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
15902 	.f = cmd_set_mplsoudp_encap_parsed,
15903 	.data = NULL,
15904 	.help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
15905 		" udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
15906 		" ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
15907 	.tokens = {
15908 		(void *)&cmd_set_mplsoudp_encap_set,
15909 		(void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
15910 		(void *)&cmd_set_mplsoudp_encap_ip_version,
15911 		(void *)&cmd_set_mplsoudp_encap_ip_version_value,
15912 		(void *)&cmd_set_mplsoudp_encap_label,
15913 		(void *)&cmd_set_mplsoudp_encap_label_value,
15914 		(void *)&cmd_set_mplsoudp_encap_udp_src,
15915 		(void *)&cmd_set_mplsoudp_encap_udp_src_value,
15916 		(void *)&cmd_set_mplsoudp_encap_udp_dst,
15917 		(void *)&cmd_set_mplsoudp_encap_udp_dst_value,
15918 		(void *)&cmd_set_mplsoudp_encap_ip_src,
15919 		(void *)&cmd_set_mplsoudp_encap_ip_src_value,
15920 		(void *)&cmd_set_mplsoudp_encap_ip_dst,
15921 		(void *)&cmd_set_mplsoudp_encap_ip_dst_value,
15922 		(void *)&cmd_set_mplsoudp_encap_eth_src,
15923 		(void *)&cmd_set_mplsoudp_encap_eth_src_value,
15924 		(void *)&cmd_set_mplsoudp_encap_eth_dst,
15925 		(void *)&cmd_set_mplsoudp_encap_eth_dst_value,
15926 		NULL,
15927 	},
15928 };
15929 
15930 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
15931 	.f = cmd_set_mplsoudp_encap_parsed,
15932 	.data = NULL,
15933 	.help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
15934 		" label <label> udp-src <udp-src> udp-dst <udp-dst>"
15935 		" ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
15936 		" eth-src <eth-src> eth-dst <eth-dst>",
15937 	.tokens = {
15938 		(void *)&cmd_set_mplsoudp_encap_set,
15939 		(void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
15940 		(void *)&cmd_set_mplsoudp_encap_ip_version,
15941 		(void *)&cmd_set_mplsoudp_encap_ip_version_value,
15942 		(void *)&cmd_set_mplsoudp_encap_label,
15943 		(void *)&cmd_set_mplsoudp_encap_label_value,
15944 		(void *)&cmd_set_mplsoudp_encap_udp_src,
15945 		(void *)&cmd_set_mplsoudp_encap_udp_src_value,
15946 		(void *)&cmd_set_mplsoudp_encap_udp_dst,
15947 		(void *)&cmd_set_mplsoudp_encap_udp_dst_value,
15948 		(void *)&cmd_set_mplsoudp_encap_ip_src,
15949 		(void *)&cmd_set_mplsoudp_encap_ip_src_value,
15950 		(void *)&cmd_set_mplsoudp_encap_ip_dst,
15951 		(void *)&cmd_set_mplsoudp_encap_ip_dst_value,
15952 		(void *)&cmd_set_mplsoudp_encap_vlan,
15953 		(void *)&cmd_set_mplsoudp_encap_vlan_value,
15954 		(void *)&cmd_set_mplsoudp_encap_eth_src,
15955 		(void *)&cmd_set_mplsoudp_encap_eth_src_value,
15956 		(void *)&cmd_set_mplsoudp_encap_eth_dst,
15957 		(void *)&cmd_set_mplsoudp_encap_eth_dst_value,
15958 		NULL,
15959 	},
15960 };
15961 
15962 /** Set MPLSoUDP decapsulation details */
15963 struct cmd_set_mplsoudp_decap_result {
15964 	cmdline_fixed_string_t set;
15965 	cmdline_fixed_string_t mplsoudp;
15966 	cmdline_fixed_string_t pos_token;
15967 	cmdline_fixed_string_t ip_version;
15968 	uint32_t vlan_present:1;
15969 };
15970 
15971 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
15972 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
15973 				 "set");
15974 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
15975 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
15976 				 "mplsoudp_decap");
15977 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
15978 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
15979 				 mplsoudp, "mplsoudp_decap-with-vlan");
15980 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
15981 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
15982 				 pos_token, "ip-version");
15983 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
15984 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
15985 				 ip_version, "ipv4#ipv6");
15986 
15987 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
15988 	__attribute__((unused)) struct cmdline *cl,
15989 	__attribute__((unused)) void *data)
15990 {
15991 	struct cmd_set_mplsoudp_decap_result *res = parsed_result;
15992 
15993 	if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
15994 		mplsoudp_decap_conf.select_vlan = 0;
15995 	else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
15996 		mplsoudp_decap_conf.select_vlan = 1;
15997 	if (strcmp(res->ip_version, "ipv4") == 0)
15998 		mplsoudp_decap_conf.select_ipv4 = 1;
15999 	else if (strcmp(res->ip_version, "ipv6") == 0)
16000 		mplsoudp_decap_conf.select_ipv4 = 0;
16001 }
16002 
16003 cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
16004 	.f = cmd_set_mplsoudp_decap_parsed,
16005 	.data = NULL,
16006 	.help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
16007 	.tokens = {
16008 		(void *)&cmd_set_mplsoudp_decap_set,
16009 		(void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
16010 		(void *)&cmd_set_mplsoudp_decap_ip_version,
16011 		(void *)&cmd_set_mplsoudp_decap_ip_version_value,
16012 		NULL,
16013 	},
16014 };
16015 
16016 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
16017 	.f = cmd_set_mplsoudp_decap_parsed,
16018 	.data = NULL,
16019 	.help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
16020 	.tokens = {
16021 		(void *)&cmd_set_mplsoudp_decap_set,
16022 		(void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
16023 		(void *)&cmd_set_mplsoudp_decap_ip_version,
16024 		(void *)&cmd_set_mplsoudp_decap_ip_version_value,
16025 		NULL,
16026 	},
16027 };
16028 
16029 /* Strict link priority scheduling mode setting */
16030 static void
16031 cmd_strict_link_prio_parsed(
16032 	void *parsed_result,
16033 	__attribute__((unused)) struct cmdline *cl,
16034 	__attribute__((unused)) void *data)
16035 {
16036 	struct cmd_vf_tc_bw_result *res = parsed_result;
16037 	int ret = -ENOTSUP;
16038 
16039 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16040 		return;
16041 
16042 #ifdef RTE_LIBRTE_I40E_PMD
16043 	ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
16044 #endif
16045 
16046 	switch (ret) {
16047 	case 0:
16048 		break;
16049 	case -EINVAL:
16050 		printf("invalid tc_bitmap 0x%x\n", res->tc_map);
16051 		break;
16052 	case -ENODEV:
16053 		printf("invalid port_id %d\n", res->port_id);
16054 		break;
16055 	case -ENOTSUP:
16056 		printf("function not implemented\n");
16057 		break;
16058 	default:
16059 		printf("programming error: (%s)\n", strerror(-ret));
16060 	}
16061 }
16062 
16063 cmdline_parse_inst_t cmd_strict_link_prio = {
16064 	.f = cmd_strict_link_prio_parsed,
16065 	.data = NULL,
16066 	.help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
16067 	.tokens = {
16068 		(void *)&cmd_vf_tc_bw_set,
16069 		(void *)&cmd_vf_tc_bw_tx,
16070 		(void *)&cmd_vf_tc_bw_strict_link_prio,
16071 		(void *)&cmd_vf_tc_bw_port_id,
16072 		(void *)&cmd_vf_tc_bw_tc_map,
16073 		NULL,
16074 	},
16075 };
16076 
16077 /* Load dynamic device personalization*/
16078 struct cmd_ddp_add_result {
16079 	cmdline_fixed_string_t ddp;
16080 	cmdline_fixed_string_t add;
16081 	portid_t port_id;
16082 	char filepath[];
16083 };
16084 
16085 cmdline_parse_token_string_t cmd_ddp_add_ddp =
16086 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
16087 cmdline_parse_token_string_t cmd_ddp_add_add =
16088 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
16089 cmdline_parse_token_num_t cmd_ddp_add_port_id =
16090 	TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
16091 cmdline_parse_token_string_t cmd_ddp_add_filepath =
16092 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
16093 
16094 static void
16095 cmd_ddp_add_parsed(
16096 	void *parsed_result,
16097 	__attribute__((unused)) struct cmdline *cl,
16098 	__attribute__((unused)) void *data)
16099 {
16100 	struct cmd_ddp_add_result *res = parsed_result;
16101 	uint8_t *buff;
16102 	uint32_t size;
16103 	char *filepath;
16104 	char *file_fld[2];
16105 	int file_num;
16106 	int ret = -ENOTSUP;
16107 
16108 	if (!all_ports_stopped()) {
16109 		printf("Please stop all ports first\n");
16110 		return;
16111 	}
16112 
16113 	filepath = strdup(res->filepath);
16114 	if (filepath == NULL) {
16115 		printf("Failed to allocate memory\n");
16116 		return;
16117 	}
16118 	file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
16119 
16120 	buff = open_file(file_fld[0], &size);
16121 	if (!buff) {
16122 		free((void *)filepath);
16123 		return;
16124 	}
16125 
16126 #ifdef RTE_LIBRTE_I40E_PMD
16127 	if (ret == -ENOTSUP)
16128 		ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16129 					       buff, size,
16130 					       RTE_PMD_I40E_PKG_OP_WR_ADD);
16131 #endif
16132 
16133 	if (ret == -EEXIST)
16134 		printf("Profile has already existed.\n");
16135 	else if (ret < 0)
16136 		printf("Failed to load profile.\n");
16137 	else if (file_num == 2)
16138 		save_file(file_fld[1], buff, size);
16139 
16140 	close_file(buff);
16141 	free((void *)filepath);
16142 }
16143 
16144 cmdline_parse_inst_t cmd_ddp_add = {
16145 	.f = cmd_ddp_add_parsed,
16146 	.data = NULL,
16147 	.help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
16148 	.tokens = {
16149 		(void *)&cmd_ddp_add_ddp,
16150 		(void *)&cmd_ddp_add_add,
16151 		(void *)&cmd_ddp_add_port_id,
16152 		(void *)&cmd_ddp_add_filepath,
16153 		NULL,
16154 	},
16155 };
16156 
16157 /* Delete dynamic device personalization*/
16158 struct cmd_ddp_del_result {
16159 	cmdline_fixed_string_t ddp;
16160 	cmdline_fixed_string_t del;
16161 	portid_t port_id;
16162 	char filepath[];
16163 };
16164 
16165 cmdline_parse_token_string_t cmd_ddp_del_ddp =
16166 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
16167 cmdline_parse_token_string_t cmd_ddp_del_del =
16168 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
16169 cmdline_parse_token_num_t cmd_ddp_del_port_id =
16170 	TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
16171 cmdline_parse_token_string_t cmd_ddp_del_filepath =
16172 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
16173 
16174 static void
16175 cmd_ddp_del_parsed(
16176 	void *parsed_result,
16177 	__attribute__((unused)) struct cmdline *cl,
16178 	__attribute__((unused)) void *data)
16179 {
16180 	struct cmd_ddp_del_result *res = parsed_result;
16181 	uint8_t *buff;
16182 	uint32_t size;
16183 	int ret = -ENOTSUP;
16184 
16185 	if (!all_ports_stopped()) {
16186 		printf("Please stop all ports first\n");
16187 		return;
16188 	}
16189 
16190 	buff = open_file(res->filepath, &size);
16191 	if (!buff)
16192 		return;
16193 
16194 #ifdef RTE_LIBRTE_I40E_PMD
16195 	if (ret == -ENOTSUP)
16196 		ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16197 					       buff, size,
16198 					       RTE_PMD_I40E_PKG_OP_WR_DEL);
16199 #endif
16200 
16201 	if (ret == -EACCES)
16202 		printf("Profile does not exist.\n");
16203 	else if (ret < 0)
16204 		printf("Failed to delete profile.\n");
16205 
16206 	close_file(buff);
16207 }
16208 
16209 cmdline_parse_inst_t cmd_ddp_del = {
16210 	.f = cmd_ddp_del_parsed,
16211 	.data = NULL,
16212 	.help_str = "ddp del <port_id> <backup_profile_path>",
16213 	.tokens = {
16214 		(void *)&cmd_ddp_del_ddp,
16215 		(void *)&cmd_ddp_del_del,
16216 		(void *)&cmd_ddp_del_port_id,
16217 		(void *)&cmd_ddp_del_filepath,
16218 		NULL,
16219 	},
16220 };
16221 
16222 /* Get dynamic device personalization profile info */
16223 struct cmd_ddp_info_result {
16224 	cmdline_fixed_string_t ddp;
16225 	cmdline_fixed_string_t get;
16226 	cmdline_fixed_string_t info;
16227 	char filepath[];
16228 };
16229 
16230 cmdline_parse_token_string_t cmd_ddp_info_ddp =
16231 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
16232 cmdline_parse_token_string_t cmd_ddp_info_get =
16233 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
16234 cmdline_parse_token_string_t cmd_ddp_info_info =
16235 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
16236 cmdline_parse_token_string_t cmd_ddp_info_filepath =
16237 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
16238 
16239 static void
16240 cmd_ddp_info_parsed(
16241 	void *parsed_result,
16242 	__attribute__((unused)) struct cmdline *cl,
16243 	__attribute__((unused)) void *data)
16244 {
16245 	struct cmd_ddp_info_result *res = parsed_result;
16246 	uint8_t *pkg;
16247 	uint32_t pkg_size;
16248 	int ret = -ENOTSUP;
16249 #ifdef RTE_LIBRTE_I40E_PMD
16250 	uint32_t i, j, n;
16251 	uint8_t *buff;
16252 	uint32_t buff_size = 0;
16253 	struct rte_pmd_i40e_profile_info info;
16254 	uint32_t dev_num = 0;
16255 	struct rte_pmd_i40e_ddp_device_id *devs;
16256 	uint32_t proto_num = 0;
16257 	struct rte_pmd_i40e_proto_info *proto = NULL;
16258 	uint32_t pctype_num = 0;
16259 	struct rte_pmd_i40e_ptype_info *pctype;
16260 	uint32_t ptype_num = 0;
16261 	struct rte_pmd_i40e_ptype_info *ptype;
16262 	uint8_t proto_id;
16263 
16264 #endif
16265 
16266 	pkg = open_file(res->filepath, &pkg_size);
16267 	if (!pkg)
16268 		return;
16269 
16270 #ifdef RTE_LIBRTE_I40E_PMD
16271 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16272 				(uint8_t *)&info, sizeof(info),
16273 				RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
16274 	if (!ret) {
16275 		printf("Global Track id:       0x%x\n", info.track_id);
16276 		printf("Global Version:        %d.%d.%d.%d\n",
16277 			info.version.major,
16278 			info.version.minor,
16279 			info.version.update,
16280 			info.version.draft);
16281 		printf("Global Package name:   %s\n\n", info.name);
16282 	}
16283 
16284 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16285 				(uint8_t *)&info, sizeof(info),
16286 				RTE_PMD_I40E_PKG_INFO_HEADER);
16287 	if (!ret) {
16288 		printf("i40e Profile Track id: 0x%x\n", info.track_id);
16289 		printf("i40e Profile Version:  %d.%d.%d.%d\n",
16290 			info.version.major,
16291 			info.version.minor,
16292 			info.version.update,
16293 			info.version.draft);
16294 		printf("i40e Profile name:     %s\n\n", info.name);
16295 	}
16296 
16297 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16298 				(uint8_t *)&buff_size, sizeof(buff_size),
16299 				RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
16300 	if (!ret && buff_size) {
16301 		buff = (uint8_t *)malloc(buff_size);
16302 		if (buff) {
16303 			ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16304 						buff, buff_size,
16305 						RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
16306 			if (!ret)
16307 				printf("Package Notes:\n%s\n\n", buff);
16308 			free(buff);
16309 		}
16310 	}
16311 
16312 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16313 				(uint8_t *)&dev_num, sizeof(dev_num),
16314 				RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
16315 	if (!ret && dev_num) {
16316 		buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
16317 		devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
16318 		if (devs) {
16319 			ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16320 						(uint8_t *)devs, buff_size,
16321 						RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
16322 			if (!ret) {
16323 				printf("List of supported devices:\n");
16324 				for (i = 0; i < dev_num; i++) {
16325 					printf("  %04X:%04X %04X:%04X\n",
16326 						devs[i].vendor_dev_id >> 16,
16327 						devs[i].vendor_dev_id & 0xFFFF,
16328 						devs[i].sub_vendor_dev_id >> 16,
16329 						devs[i].sub_vendor_dev_id & 0xFFFF);
16330 				}
16331 				printf("\n");
16332 			}
16333 			free(devs);
16334 		}
16335 	}
16336 
16337 	/* get information about protocols and packet types */
16338 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16339 		(uint8_t *)&proto_num, sizeof(proto_num),
16340 		RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
16341 	if (ret || !proto_num)
16342 		goto no_print_return;
16343 
16344 	buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
16345 	proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
16346 	if (!proto)
16347 		goto no_print_return;
16348 
16349 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
16350 					buff_size,
16351 					RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
16352 	if (!ret) {
16353 		printf("List of used protocols:\n");
16354 		for (i = 0; i < proto_num; i++)
16355 			printf("  %2u: %s\n", proto[i].proto_id,
16356 			       proto[i].name);
16357 		printf("\n");
16358 	}
16359 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16360 		(uint8_t *)&pctype_num, sizeof(pctype_num),
16361 		RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
16362 	if (ret || !pctype_num)
16363 		goto no_print_pctypes;
16364 
16365 	buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16366 	pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16367 	if (!pctype)
16368 		goto no_print_pctypes;
16369 
16370 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
16371 					buff_size,
16372 					RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
16373 	if (ret) {
16374 		free(pctype);
16375 		goto no_print_pctypes;
16376 	}
16377 
16378 	printf("List of defined packet classification types:\n");
16379 	for (i = 0; i < pctype_num; i++) {
16380 		printf("  %2u:", pctype[i].ptype_id);
16381 		for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
16382 			proto_id = pctype[i].protocols[j];
16383 			if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
16384 				for (n = 0; n < proto_num; n++) {
16385 					if (proto[n].proto_id == proto_id) {
16386 						printf(" %s", proto[n].name);
16387 						break;
16388 					}
16389 				}
16390 			}
16391 		}
16392 		printf("\n");
16393 	}
16394 	printf("\n");
16395 	free(pctype);
16396 
16397 no_print_pctypes:
16398 
16399 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
16400 					sizeof(ptype_num),
16401 					RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
16402 	if (ret || !ptype_num)
16403 		goto no_print_return;
16404 
16405 	buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16406 	ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16407 	if (!ptype)
16408 		goto no_print_return;
16409 
16410 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
16411 					buff_size,
16412 					RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
16413 	if (ret) {
16414 		free(ptype);
16415 		goto no_print_return;
16416 	}
16417 	printf("List of defined packet types:\n");
16418 	for (i = 0; i < ptype_num; i++) {
16419 		printf("  %2u:", ptype[i].ptype_id);
16420 		for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
16421 			proto_id = ptype[i].protocols[j];
16422 			if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
16423 				for (n = 0; n < proto_num; n++) {
16424 					if (proto[n].proto_id == proto_id) {
16425 						printf(" %s", proto[n].name);
16426 						break;
16427 					}
16428 				}
16429 			}
16430 		}
16431 		printf("\n");
16432 	}
16433 	free(ptype);
16434 	printf("\n");
16435 
16436 	ret = 0;
16437 no_print_return:
16438 	if (proto)
16439 		free(proto);
16440 #endif
16441 	if (ret == -ENOTSUP)
16442 		printf("Function not supported in PMD driver\n");
16443 	close_file(pkg);
16444 }
16445 
16446 cmdline_parse_inst_t cmd_ddp_get_info = {
16447 	.f = cmd_ddp_info_parsed,
16448 	.data = NULL,
16449 	.help_str = "ddp get info <profile_path>",
16450 	.tokens = {
16451 		(void *)&cmd_ddp_info_ddp,
16452 		(void *)&cmd_ddp_info_get,
16453 		(void *)&cmd_ddp_info_info,
16454 		(void *)&cmd_ddp_info_filepath,
16455 		NULL,
16456 	},
16457 };
16458 
16459 /* Get dynamic device personalization profile info list*/
16460 #define PROFILE_INFO_SIZE 48
16461 #define MAX_PROFILE_NUM 16
16462 
16463 struct cmd_ddp_get_list_result {
16464 	cmdline_fixed_string_t ddp;
16465 	cmdline_fixed_string_t get;
16466 	cmdline_fixed_string_t list;
16467 	portid_t port_id;
16468 };
16469 
16470 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
16471 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
16472 cmdline_parse_token_string_t cmd_ddp_get_list_get =
16473 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
16474 cmdline_parse_token_string_t cmd_ddp_get_list_list =
16475 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
16476 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
16477 	TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
16478 
16479 static void
16480 cmd_ddp_get_list_parsed(
16481 	__attribute__((unused)) void *parsed_result,
16482 	__attribute__((unused)) struct cmdline *cl,
16483 	__attribute__((unused)) void *data)
16484 {
16485 #ifdef RTE_LIBRTE_I40E_PMD
16486 	struct cmd_ddp_get_list_result *res = parsed_result;
16487 	struct rte_pmd_i40e_profile_list *p_list;
16488 	struct rte_pmd_i40e_profile_info *p_info;
16489 	uint32_t p_num;
16490 	uint32_t size;
16491 	uint32_t i;
16492 #endif
16493 	int ret = -ENOTSUP;
16494 
16495 #ifdef RTE_LIBRTE_I40E_PMD
16496 	size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
16497 	p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
16498 	if (!p_list)
16499 		printf("%s: Failed to malloc buffer\n", __func__);
16500 
16501 	if (ret == -ENOTSUP)
16502 		ret = rte_pmd_i40e_get_ddp_list(res->port_id,
16503 						(uint8_t *)p_list, size);
16504 
16505 	if (!ret) {
16506 		p_num = p_list->p_count;
16507 		printf("Profile number is: %d\n\n", p_num);
16508 
16509 		for (i = 0; i < p_num; i++) {
16510 			p_info = &p_list->p_info[i];
16511 			printf("Profile %d:\n", i);
16512 			printf("Track id:     0x%x\n", p_info->track_id);
16513 			printf("Version:      %d.%d.%d.%d\n",
16514 			       p_info->version.major,
16515 			       p_info->version.minor,
16516 			       p_info->version.update,
16517 			       p_info->version.draft);
16518 			printf("Profile name: %s\n\n", p_info->name);
16519 		}
16520 	}
16521 
16522 	free(p_list);
16523 #endif
16524 
16525 	if (ret < 0)
16526 		printf("Failed to get ddp list\n");
16527 }
16528 
16529 cmdline_parse_inst_t cmd_ddp_get_list = {
16530 	.f = cmd_ddp_get_list_parsed,
16531 	.data = NULL,
16532 	.help_str = "ddp get list <port_id>",
16533 	.tokens = {
16534 		(void *)&cmd_ddp_get_list_ddp,
16535 		(void *)&cmd_ddp_get_list_get,
16536 		(void *)&cmd_ddp_get_list_list,
16537 		(void *)&cmd_ddp_get_list_port_id,
16538 		NULL,
16539 	},
16540 };
16541 
16542 /* Configure input set */
16543 struct cmd_cfg_input_set_result {
16544 	cmdline_fixed_string_t port;
16545 	cmdline_fixed_string_t cfg;
16546 	portid_t port_id;
16547 	cmdline_fixed_string_t pctype;
16548 	uint8_t pctype_id;
16549 	cmdline_fixed_string_t inset_type;
16550 	cmdline_fixed_string_t opt;
16551 	cmdline_fixed_string_t field;
16552 	uint8_t field_idx;
16553 };
16554 
16555 static void
16556 cmd_cfg_input_set_parsed(
16557 	__attribute__((unused)) void *parsed_result,
16558 	__attribute__((unused)) struct cmdline *cl,
16559 	__attribute__((unused)) void *data)
16560 {
16561 #ifdef RTE_LIBRTE_I40E_PMD
16562 	struct cmd_cfg_input_set_result *res = parsed_result;
16563 	enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
16564 	struct rte_pmd_i40e_inset inset;
16565 #endif
16566 	int ret = -ENOTSUP;
16567 
16568 	if (!all_ports_stopped()) {
16569 		printf("Please stop all ports first\n");
16570 		return;
16571 	}
16572 
16573 #ifdef RTE_LIBRTE_I40E_PMD
16574 	if (!strcmp(res->inset_type, "hash_inset"))
16575 		inset_type = INSET_HASH;
16576 	else if (!strcmp(res->inset_type, "fdir_inset"))
16577 		inset_type = INSET_FDIR;
16578 	else if (!strcmp(res->inset_type, "fdir_flx_inset"))
16579 		inset_type = INSET_FDIR_FLX;
16580 	ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
16581 				     &inset, inset_type);
16582 	if (ret) {
16583 		printf("Failed to get input set.\n");
16584 		return;
16585 	}
16586 
16587 	if (!strcmp(res->opt, "get")) {
16588 		ret = rte_pmd_i40e_inset_field_get(inset.inset,
16589 						   res->field_idx);
16590 		if (ret)
16591 			printf("Field index %d is enabled.\n", res->field_idx);
16592 		else
16593 			printf("Field index %d is disabled.\n", res->field_idx);
16594 		return;
16595 	} else if (!strcmp(res->opt, "set"))
16596 		ret = rte_pmd_i40e_inset_field_set(&inset.inset,
16597 						   res->field_idx);
16598 	else if (!strcmp(res->opt, "clear"))
16599 		ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
16600 						     res->field_idx);
16601 	if (ret) {
16602 		printf("Failed to configure input set field.\n");
16603 		return;
16604 	}
16605 
16606 	ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
16607 				     &inset, inset_type);
16608 	if (ret) {
16609 		printf("Failed to set input set.\n");
16610 		return;
16611 	}
16612 #endif
16613 
16614 	if (ret == -ENOTSUP)
16615 		printf("Function not supported\n");
16616 }
16617 
16618 cmdline_parse_token_string_t cmd_cfg_input_set_port =
16619 	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16620 				 port, "port");
16621 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
16622 	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16623 				 cfg, "config");
16624 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
16625 	TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16626 			      port_id, UINT16);
16627 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
16628 	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16629 				 pctype, "pctype");
16630 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
16631 	TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16632 			      pctype_id, UINT8);
16633 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
16634 	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16635 				 inset_type,
16636 				 "hash_inset#fdir_inset#fdir_flx_inset");
16637 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
16638 	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16639 				 opt, "get#set#clear");
16640 cmdline_parse_token_string_t cmd_cfg_input_set_field =
16641 	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16642 				 field, "field");
16643 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
16644 	TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16645 			      field_idx, UINT8);
16646 
16647 cmdline_parse_inst_t cmd_cfg_input_set = {
16648 	.f = cmd_cfg_input_set_parsed,
16649 	.data = NULL,
16650 	.help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
16651 		    "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
16652 	.tokens = {
16653 		(void *)&cmd_cfg_input_set_port,
16654 		(void *)&cmd_cfg_input_set_cfg,
16655 		(void *)&cmd_cfg_input_set_port_id,
16656 		(void *)&cmd_cfg_input_set_pctype,
16657 		(void *)&cmd_cfg_input_set_pctype_id,
16658 		(void *)&cmd_cfg_input_set_inset_type,
16659 		(void *)&cmd_cfg_input_set_opt,
16660 		(void *)&cmd_cfg_input_set_field,
16661 		(void *)&cmd_cfg_input_set_field_idx,
16662 		NULL,
16663 	},
16664 };
16665 
16666 /* Clear input set */
16667 struct cmd_clear_input_set_result {
16668 	cmdline_fixed_string_t port;
16669 	cmdline_fixed_string_t cfg;
16670 	portid_t port_id;
16671 	cmdline_fixed_string_t pctype;
16672 	uint8_t pctype_id;
16673 	cmdline_fixed_string_t inset_type;
16674 	cmdline_fixed_string_t clear;
16675 	cmdline_fixed_string_t all;
16676 };
16677 
16678 static void
16679 cmd_clear_input_set_parsed(
16680 	__attribute__((unused)) void *parsed_result,
16681 	__attribute__((unused)) struct cmdline *cl,
16682 	__attribute__((unused)) void *data)
16683 {
16684 #ifdef RTE_LIBRTE_I40E_PMD
16685 	struct cmd_clear_input_set_result *res = parsed_result;
16686 	enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
16687 	struct rte_pmd_i40e_inset inset;
16688 #endif
16689 	int ret = -ENOTSUP;
16690 
16691 	if (!all_ports_stopped()) {
16692 		printf("Please stop all ports first\n");
16693 		return;
16694 	}
16695 
16696 #ifdef RTE_LIBRTE_I40E_PMD
16697 	if (!strcmp(res->inset_type, "hash_inset"))
16698 		inset_type = INSET_HASH;
16699 	else if (!strcmp(res->inset_type, "fdir_inset"))
16700 		inset_type = INSET_FDIR;
16701 	else if (!strcmp(res->inset_type, "fdir_flx_inset"))
16702 		inset_type = INSET_FDIR_FLX;
16703 
16704 	memset(&inset, 0, sizeof(inset));
16705 
16706 	ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
16707 				     &inset, inset_type);
16708 	if (ret) {
16709 		printf("Failed to clear input set.\n");
16710 		return;
16711 	}
16712 
16713 #endif
16714 
16715 	if (ret == -ENOTSUP)
16716 		printf("Function not supported\n");
16717 }
16718 
16719 cmdline_parse_token_string_t cmd_clear_input_set_port =
16720 	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16721 				 port, "port");
16722 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
16723 	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16724 				 cfg, "config");
16725 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
16726 	TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
16727 			      port_id, UINT16);
16728 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
16729 	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16730 				 pctype, "pctype");
16731 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
16732 	TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
16733 			      pctype_id, UINT8);
16734 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
16735 	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16736 				 inset_type,
16737 				 "hash_inset#fdir_inset#fdir_flx_inset");
16738 cmdline_parse_token_string_t cmd_clear_input_set_clear =
16739 	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16740 				 clear, "clear");
16741 cmdline_parse_token_string_t cmd_clear_input_set_all =
16742 	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16743 				 all, "all");
16744 
16745 cmdline_parse_inst_t cmd_clear_input_set = {
16746 	.f = cmd_clear_input_set_parsed,
16747 	.data = NULL,
16748 	.help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
16749 		    "fdir_inset|fdir_flx_inset clear all",
16750 	.tokens = {
16751 		(void *)&cmd_clear_input_set_port,
16752 		(void *)&cmd_clear_input_set_cfg,
16753 		(void *)&cmd_clear_input_set_port_id,
16754 		(void *)&cmd_clear_input_set_pctype,
16755 		(void *)&cmd_clear_input_set_pctype_id,
16756 		(void *)&cmd_clear_input_set_inset_type,
16757 		(void *)&cmd_clear_input_set_clear,
16758 		(void *)&cmd_clear_input_set_all,
16759 		NULL,
16760 	},
16761 };
16762 
16763 /* show vf stats */
16764 
16765 /* Common result structure for show vf stats */
16766 struct cmd_show_vf_stats_result {
16767 	cmdline_fixed_string_t show;
16768 	cmdline_fixed_string_t vf;
16769 	cmdline_fixed_string_t stats;
16770 	portid_t port_id;
16771 	uint16_t vf_id;
16772 };
16773 
16774 /* Common CLI fields show vf stats*/
16775 cmdline_parse_token_string_t cmd_show_vf_stats_show =
16776 	TOKEN_STRING_INITIALIZER
16777 		(struct cmd_show_vf_stats_result,
16778 		 show, "show");
16779 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
16780 	TOKEN_STRING_INITIALIZER
16781 		(struct cmd_show_vf_stats_result,
16782 		 vf, "vf");
16783 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
16784 	TOKEN_STRING_INITIALIZER
16785 		(struct cmd_show_vf_stats_result,
16786 		 stats, "stats");
16787 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
16788 	TOKEN_NUM_INITIALIZER
16789 		(struct cmd_show_vf_stats_result,
16790 		 port_id, UINT16);
16791 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
16792 	TOKEN_NUM_INITIALIZER
16793 		(struct cmd_show_vf_stats_result,
16794 		 vf_id, UINT16);
16795 
16796 static void
16797 cmd_show_vf_stats_parsed(
16798 	void *parsed_result,
16799 	__attribute__((unused)) struct cmdline *cl,
16800 	__attribute__((unused)) void *data)
16801 {
16802 	struct cmd_show_vf_stats_result *res = parsed_result;
16803 	struct rte_eth_stats stats;
16804 	int ret = -ENOTSUP;
16805 	static const char *nic_stats_border = "########################";
16806 
16807 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16808 		return;
16809 
16810 	memset(&stats, 0, sizeof(stats));
16811 
16812 #ifdef RTE_LIBRTE_I40E_PMD
16813 	if (ret == -ENOTSUP)
16814 		ret = rte_pmd_i40e_get_vf_stats(res->port_id,
16815 						res->vf_id,
16816 						&stats);
16817 #endif
16818 #ifdef RTE_LIBRTE_BNXT_PMD
16819 	if (ret == -ENOTSUP)
16820 		ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
16821 						res->vf_id,
16822 						&stats);
16823 #endif
16824 
16825 	switch (ret) {
16826 	case 0:
16827 		break;
16828 	case -EINVAL:
16829 		printf("invalid vf_id %d\n", res->vf_id);
16830 		break;
16831 	case -ENODEV:
16832 		printf("invalid port_id %d\n", res->port_id);
16833 		break;
16834 	case -ENOTSUP:
16835 		printf("function not implemented\n");
16836 		break;
16837 	default:
16838 		printf("programming error: (%s)\n", strerror(-ret));
16839 	}
16840 
16841 	printf("\n  %s NIC statistics for port %-2d vf %-2d %s\n",
16842 		nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
16843 
16844 	printf("  RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes:  "
16845 	       "%-"PRIu64"\n",
16846 	       stats.ipackets, stats.imissed, stats.ibytes);
16847 	printf("  RX-errors: %-"PRIu64"\n", stats.ierrors);
16848 	printf("  RX-nombuf:  %-10"PRIu64"\n",
16849 	       stats.rx_nombuf);
16850 	printf("  TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes:  "
16851 	       "%-"PRIu64"\n",
16852 	       stats.opackets, stats.oerrors, stats.obytes);
16853 
16854 	printf("  %s############################%s\n",
16855 			       nic_stats_border, nic_stats_border);
16856 }
16857 
16858 cmdline_parse_inst_t cmd_show_vf_stats = {
16859 	.f = cmd_show_vf_stats_parsed,
16860 	.data = NULL,
16861 	.help_str = "show vf stats <port_id> <vf_id>",
16862 	.tokens = {
16863 		(void *)&cmd_show_vf_stats_show,
16864 		(void *)&cmd_show_vf_stats_vf,
16865 		(void *)&cmd_show_vf_stats_stats,
16866 		(void *)&cmd_show_vf_stats_port_id,
16867 		(void *)&cmd_show_vf_stats_vf_id,
16868 		NULL,
16869 	},
16870 };
16871 
16872 /* clear vf stats */
16873 
16874 /* Common result structure for clear vf stats */
16875 struct cmd_clear_vf_stats_result {
16876 	cmdline_fixed_string_t clear;
16877 	cmdline_fixed_string_t vf;
16878 	cmdline_fixed_string_t stats;
16879 	portid_t port_id;
16880 	uint16_t vf_id;
16881 };
16882 
16883 /* Common CLI fields clear vf stats*/
16884 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
16885 	TOKEN_STRING_INITIALIZER
16886 		(struct cmd_clear_vf_stats_result,
16887 		 clear, "clear");
16888 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
16889 	TOKEN_STRING_INITIALIZER
16890 		(struct cmd_clear_vf_stats_result,
16891 		 vf, "vf");
16892 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
16893 	TOKEN_STRING_INITIALIZER
16894 		(struct cmd_clear_vf_stats_result,
16895 		 stats, "stats");
16896 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
16897 	TOKEN_NUM_INITIALIZER
16898 		(struct cmd_clear_vf_stats_result,
16899 		 port_id, UINT16);
16900 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
16901 	TOKEN_NUM_INITIALIZER
16902 		(struct cmd_clear_vf_stats_result,
16903 		 vf_id, UINT16);
16904 
16905 static void
16906 cmd_clear_vf_stats_parsed(
16907 	void *parsed_result,
16908 	__attribute__((unused)) struct cmdline *cl,
16909 	__attribute__((unused)) void *data)
16910 {
16911 	struct cmd_clear_vf_stats_result *res = parsed_result;
16912 	int ret = -ENOTSUP;
16913 
16914 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16915 		return;
16916 
16917 #ifdef RTE_LIBRTE_I40E_PMD
16918 	if (ret == -ENOTSUP)
16919 		ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
16920 						  res->vf_id);
16921 #endif
16922 #ifdef RTE_LIBRTE_BNXT_PMD
16923 	if (ret == -ENOTSUP)
16924 		ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
16925 						  res->vf_id);
16926 #endif
16927 
16928 	switch (ret) {
16929 	case 0:
16930 		break;
16931 	case -EINVAL:
16932 		printf("invalid vf_id %d\n", res->vf_id);
16933 		break;
16934 	case -ENODEV:
16935 		printf("invalid port_id %d\n", res->port_id);
16936 		break;
16937 	case -ENOTSUP:
16938 		printf("function not implemented\n");
16939 		break;
16940 	default:
16941 		printf("programming error: (%s)\n", strerror(-ret));
16942 	}
16943 }
16944 
16945 cmdline_parse_inst_t cmd_clear_vf_stats = {
16946 	.f = cmd_clear_vf_stats_parsed,
16947 	.data = NULL,
16948 	.help_str = "clear vf stats <port_id> <vf_id>",
16949 	.tokens = {
16950 		(void *)&cmd_clear_vf_stats_clear,
16951 		(void *)&cmd_clear_vf_stats_vf,
16952 		(void *)&cmd_clear_vf_stats_stats,
16953 		(void *)&cmd_clear_vf_stats_port_id,
16954 		(void *)&cmd_clear_vf_stats_vf_id,
16955 		NULL,
16956 	},
16957 };
16958 
16959 /* port config pctype mapping reset */
16960 
16961 /* Common result structure for port config pctype mapping reset */
16962 struct cmd_pctype_mapping_reset_result {
16963 	cmdline_fixed_string_t port;
16964 	cmdline_fixed_string_t config;
16965 	portid_t port_id;
16966 	cmdline_fixed_string_t pctype;
16967 	cmdline_fixed_string_t mapping;
16968 	cmdline_fixed_string_t reset;
16969 };
16970 
16971 /* Common CLI fields for port config pctype mapping reset*/
16972 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
16973 	TOKEN_STRING_INITIALIZER
16974 		(struct cmd_pctype_mapping_reset_result,
16975 		 port, "port");
16976 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
16977 	TOKEN_STRING_INITIALIZER
16978 		(struct cmd_pctype_mapping_reset_result,
16979 		 config, "config");
16980 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
16981 	TOKEN_NUM_INITIALIZER
16982 		(struct cmd_pctype_mapping_reset_result,
16983 		 port_id, UINT16);
16984 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
16985 	TOKEN_STRING_INITIALIZER
16986 		(struct cmd_pctype_mapping_reset_result,
16987 		 pctype, "pctype");
16988 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
16989 	TOKEN_STRING_INITIALIZER
16990 		(struct cmd_pctype_mapping_reset_result,
16991 		 mapping, "mapping");
16992 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
16993 	TOKEN_STRING_INITIALIZER
16994 		(struct cmd_pctype_mapping_reset_result,
16995 		 reset, "reset");
16996 
16997 static void
16998 cmd_pctype_mapping_reset_parsed(
16999 	void *parsed_result,
17000 	__attribute__((unused)) struct cmdline *cl,
17001 	__attribute__((unused)) void *data)
17002 {
17003 	struct cmd_pctype_mapping_reset_result *res = parsed_result;
17004 	int ret = -ENOTSUP;
17005 
17006 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17007 		return;
17008 
17009 #ifdef RTE_LIBRTE_I40E_PMD
17010 	ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
17011 #endif
17012 
17013 	switch (ret) {
17014 	case 0:
17015 		break;
17016 	case -ENODEV:
17017 		printf("invalid port_id %d\n", res->port_id);
17018 		break;
17019 	case -ENOTSUP:
17020 		printf("function not implemented\n");
17021 		break;
17022 	default:
17023 		printf("programming error: (%s)\n", strerror(-ret));
17024 	}
17025 }
17026 
17027 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
17028 	.f = cmd_pctype_mapping_reset_parsed,
17029 	.data = NULL,
17030 	.help_str = "port config <port_id> pctype mapping reset",
17031 	.tokens = {
17032 		(void *)&cmd_pctype_mapping_reset_port,
17033 		(void *)&cmd_pctype_mapping_reset_config,
17034 		(void *)&cmd_pctype_mapping_reset_port_id,
17035 		(void *)&cmd_pctype_mapping_reset_pctype,
17036 		(void *)&cmd_pctype_mapping_reset_mapping,
17037 		(void *)&cmd_pctype_mapping_reset_reset,
17038 		NULL,
17039 	},
17040 };
17041 
17042 /* show port pctype mapping */
17043 
17044 /* Common result structure for show port pctype mapping */
17045 struct cmd_pctype_mapping_get_result {
17046 	cmdline_fixed_string_t show;
17047 	cmdline_fixed_string_t port;
17048 	portid_t port_id;
17049 	cmdline_fixed_string_t pctype;
17050 	cmdline_fixed_string_t mapping;
17051 };
17052 
17053 /* Common CLI fields for pctype mapping get */
17054 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
17055 	TOKEN_STRING_INITIALIZER
17056 		(struct cmd_pctype_mapping_get_result,
17057 		 show, "show");
17058 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
17059 	TOKEN_STRING_INITIALIZER
17060 		(struct cmd_pctype_mapping_get_result,
17061 		 port, "port");
17062 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
17063 	TOKEN_NUM_INITIALIZER
17064 		(struct cmd_pctype_mapping_get_result,
17065 		 port_id, UINT16);
17066 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
17067 	TOKEN_STRING_INITIALIZER
17068 		(struct cmd_pctype_mapping_get_result,
17069 		 pctype, "pctype");
17070 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
17071 	TOKEN_STRING_INITIALIZER
17072 		(struct cmd_pctype_mapping_get_result,
17073 		 mapping, "mapping");
17074 
17075 static void
17076 cmd_pctype_mapping_get_parsed(
17077 	void *parsed_result,
17078 	__attribute__((unused)) struct cmdline *cl,
17079 	__attribute__((unused)) void *data)
17080 {
17081 	struct cmd_pctype_mapping_get_result *res = parsed_result;
17082 	int ret = -ENOTSUP;
17083 #ifdef RTE_LIBRTE_I40E_PMD
17084 	struct rte_pmd_i40e_flow_type_mapping
17085 				mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
17086 	int i, j, first_pctype;
17087 #endif
17088 
17089 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17090 		return;
17091 
17092 #ifdef RTE_LIBRTE_I40E_PMD
17093 	ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
17094 #endif
17095 
17096 	switch (ret) {
17097 	case 0:
17098 		break;
17099 	case -ENODEV:
17100 		printf("invalid port_id %d\n", res->port_id);
17101 		return;
17102 	case -ENOTSUP:
17103 		printf("function not implemented\n");
17104 		return;
17105 	default:
17106 		printf("programming error: (%s)\n", strerror(-ret));
17107 		return;
17108 	}
17109 
17110 #ifdef RTE_LIBRTE_I40E_PMD
17111 	for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
17112 		if (mapping[i].pctype != 0ULL) {
17113 			first_pctype = 1;
17114 
17115 			printf("pctype: ");
17116 			for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
17117 				if (mapping[i].pctype & (1ULL << j)) {
17118 					printf(first_pctype ?
17119 					       "%02d" : ",%02d", j);
17120 					first_pctype = 0;
17121 				}
17122 			}
17123 			printf("  ->  flowtype: %02d\n", mapping[i].flow_type);
17124 		}
17125 	}
17126 #endif
17127 }
17128 
17129 cmdline_parse_inst_t cmd_pctype_mapping_get = {
17130 	.f = cmd_pctype_mapping_get_parsed,
17131 	.data = NULL,
17132 	.help_str = "show port <port_id> pctype mapping",
17133 	.tokens = {
17134 		(void *)&cmd_pctype_mapping_get_show,
17135 		(void *)&cmd_pctype_mapping_get_port,
17136 		(void *)&cmd_pctype_mapping_get_port_id,
17137 		(void *)&cmd_pctype_mapping_get_pctype,
17138 		(void *)&cmd_pctype_mapping_get_mapping,
17139 		NULL,
17140 	},
17141 };
17142 
17143 /* port config pctype mapping update */
17144 
17145 /* Common result structure for port config pctype mapping update */
17146 struct cmd_pctype_mapping_update_result {
17147 	cmdline_fixed_string_t port;
17148 	cmdline_fixed_string_t config;
17149 	portid_t port_id;
17150 	cmdline_fixed_string_t pctype;
17151 	cmdline_fixed_string_t mapping;
17152 	cmdline_fixed_string_t update;
17153 	cmdline_fixed_string_t pctype_list;
17154 	uint16_t flow_type;
17155 };
17156 
17157 /* Common CLI fields for pctype mapping update*/
17158 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
17159 	TOKEN_STRING_INITIALIZER
17160 		(struct cmd_pctype_mapping_update_result,
17161 		 port, "port");
17162 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
17163 	TOKEN_STRING_INITIALIZER
17164 		(struct cmd_pctype_mapping_update_result,
17165 		 config, "config");
17166 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
17167 	TOKEN_NUM_INITIALIZER
17168 		(struct cmd_pctype_mapping_update_result,
17169 		 port_id, UINT16);
17170 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
17171 	TOKEN_STRING_INITIALIZER
17172 		(struct cmd_pctype_mapping_update_result,
17173 		 pctype, "pctype");
17174 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
17175 	TOKEN_STRING_INITIALIZER
17176 		(struct cmd_pctype_mapping_update_result,
17177 		 mapping, "mapping");
17178 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
17179 	TOKEN_STRING_INITIALIZER
17180 		(struct cmd_pctype_mapping_update_result,
17181 		 update, "update");
17182 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
17183 	TOKEN_STRING_INITIALIZER
17184 		(struct cmd_pctype_mapping_update_result,
17185 		 pctype_list, NULL);
17186 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
17187 	TOKEN_NUM_INITIALIZER
17188 		(struct cmd_pctype_mapping_update_result,
17189 		 flow_type, UINT16);
17190 
17191 static void
17192 cmd_pctype_mapping_update_parsed(
17193 	void *parsed_result,
17194 	__attribute__((unused)) struct cmdline *cl,
17195 	__attribute__((unused)) void *data)
17196 {
17197 	struct cmd_pctype_mapping_update_result *res = parsed_result;
17198 	int ret = -ENOTSUP;
17199 #ifdef RTE_LIBRTE_I40E_PMD
17200 	struct rte_pmd_i40e_flow_type_mapping mapping;
17201 	unsigned int i;
17202 	unsigned int nb_item;
17203 	unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
17204 #endif
17205 
17206 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17207 		return;
17208 
17209 #ifdef RTE_LIBRTE_I40E_PMD
17210 	nb_item = parse_item_list(res->pctype_list, "pctypes",
17211 				  RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
17212 	mapping.flow_type = res->flow_type;
17213 	for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
17214 		mapping.pctype |= (1ULL << pctype_list[i]);
17215 	ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
17216 						&mapping,
17217 						1,
17218 						0);
17219 #endif
17220 
17221 	switch (ret) {
17222 	case 0:
17223 		break;
17224 	case -EINVAL:
17225 		printf("invalid pctype or flow type\n");
17226 		break;
17227 	case -ENODEV:
17228 		printf("invalid port_id %d\n", res->port_id);
17229 		break;
17230 	case -ENOTSUP:
17231 		printf("function not implemented\n");
17232 		break;
17233 	default:
17234 		printf("programming error: (%s)\n", strerror(-ret));
17235 	}
17236 }
17237 
17238 cmdline_parse_inst_t cmd_pctype_mapping_update = {
17239 	.f = cmd_pctype_mapping_update_parsed,
17240 	.data = NULL,
17241 	.help_str = "port config <port_id> pctype mapping update"
17242 	" <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
17243 	.tokens = {
17244 		(void *)&cmd_pctype_mapping_update_port,
17245 		(void *)&cmd_pctype_mapping_update_config,
17246 		(void *)&cmd_pctype_mapping_update_port_id,
17247 		(void *)&cmd_pctype_mapping_update_pctype,
17248 		(void *)&cmd_pctype_mapping_update_mapping,
17249 		(void *)&cmd_pctype_mapping_update_update,
17250 		(void *)&cmd_pctype_mapping_update_pc_type,
17251 		(void *)&cmd_pctype_mapping_update_flow_type,
17252 		NULL,
17253 	},
17254 };
17255 
17256 /* ptype mapping get */
17257 
17258 /* Common result structure for ptype mapping get */
17259 struct cmd_ptype_mapping_get_result {
17260 	cmdline_fixed_string_t ptype;
17261 	cmdline_fixed_string_t mapping;
17262 	cmdline_fixed_string_t get;
17263 	portid_t port_id;
17264 	uint8_t valid_only;
17265 };
17266 
17267 /* Common CLI fields for ptype mapping get */
17268 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
17269 	TOKEN_STRING_INITIALIZER
17270 		(struct cmd_ptype_mapping_get_result,
17271 		 ptype, "ptype");
17272 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
17273 	TOKEN_STRING_INITIALIZER
17274 		(struct cmd_ptype_mapping_get_result,
17275 		 mapping, "mapping");
17276 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
17277 	TOKEN_STRING_INITIALIZER
17278 		(struct cmd_ptype_mapping_get_result,
17279 		 get, "get");
17280 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
17281 	TOKEN_NUM_INITIALIZER
17282 		(struct cmd_ptype_mapping_get_result,
17283 		 port_id, UINT16);
17284 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
17285 	TOKEN_NUM_INITIALIZER
17286 		(struct cmd_ptype_mapping_get_result,
17287 		 valid_only, UINT8);
17288 
17289 static void
17290 cmd_ptype_mapping_get_parsed(
17291 	void *parsed_result,
17292 	__attribute__((unused)) struct cmdline *cl,
17293 	__attribute__((unused)) void *data)
17294 {
17295 	struct cmd_ptype_mapping_get_result *res = parsed_result;
17296 	int ret = -ENOTSUP;
17297 #ifdef RTE_LIBRTE_I40E_PMD
17298 	int max_ptype_num = 256;
17299 	struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
17300 	uint16_t count;
17301 	int i;
17302 #endif
17303 
17304 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17305 		return;
17306 
17307 #ifdef RTE_LIBRTE_I40E_PMD
17308 	ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
17309 					mapping,
17310 					max_ptype_num,
17311 					&count,
17312 					res->valid_only);
17313 #endif
17314 
17315 	switch (ret) {
17316 	case 0:
17317 		break;
17318 	case -ENODEV:
17319 		printf("invalid port_id %d\n", res->port_id);
17320 		break;
17321 	case -ENOTSUP:
17322 		printf("function not implemented\n");
17323 		break;
17324 	default:
17325 		printf("programming error: (%s)\n", strerror(-ret));
17326 	}
17327 
17328 #ifdef RTE_LIBRTE_I40E_PMD
17329 	if (!ret) {
17330 		for (i = 0; i < count; i++)
17331 			printf("%3d\t0x%08x\n",
17332 				mapping[i].hw_ptype, mapping[i].sw_ptype);
17333 	}
17334 #endif
17335 }
17336 
17337 cmdline_parse_inst_t cmd_ptype_mapping_get = {
17338 	.f = cmd_ptype_mapping_get_parsed,
17339 	.data = NULL,
17340 	.help_str = "ptype mapping get <port_id> <valid_only>",
17341 	.tokens = {
17342 		(void *)&cmd_ptype_mapping_get_ptype,
17343 		(void *)&cmd_ptype_mapping_get_mapping,
17344 		(void *)&cmd_ptype_mapping_get_get,
17345 		(void *)&cmd_ptype_mapping_get_port_id,
17346 		(void *)&cmd_ptype_mapping_get_valid_only,
17347 		NULL,
17348 	},
17349 };
17350 
17351 /* ptype mapping replace */
17352 
17353 /* Common result structure for ptype mapping replace */
17354 struct cmd_ptype_mapping_replace_result {
17355 	cmdline_fixed_string_t ptype;
17356 	cmdline_fixed_string_t mapping;
17357 	cmdline_fixed_string_t replace;
17358 	portid_t port_id;
17359 	uint32_t target;
17360 	uint8_t mask;
17361 	uint32_t pkt_type;
17362 };
17363 
17364 /* Common CLI fields for ptype mapping replace */
17365 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
17366 	TOKEN_STRING_INITIALIZER
17367 		(struct cmd_ptype_mapping_replace_result,
17368 		 ptype, "ptype");
17369 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
17370 	TOKEN_STRING_INITIALIZER
17371 		(struct cmd_ptype_mapping_replace_result,
17372 		 mapping, "mapping");
17373 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
17374 	TOKEN_STRING_INITIALIZER
17375 		(struct cmd_ptype_mapping_replace_result,
17376 		 replace, "replace");
17377 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
17378 	TOKEN_NUM_INITIALIZER
17379 		(struct cmd_ptype_mapping_replace_result,
17380 		 port_id, UINT16);
17381 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
17382 	TOKEN_NUM_INITIALIZER
17383 		(struct cmd_ptype_mapping_replace_result,
17384 		 target, UINT32);
17385 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
17386 	TOKEN_NUM_INITIALIZER
17387 		(struct cmd_ptype_mapping_replace_result,
17388 		 mask, UINT8);
17389 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
17390 	TOKEN_NUM_INITIALIZER
17391 		(struct cmd_ptype_mapping_replace_result,
17392 		 pkt_type, UINT32);
17393 
17394 static void
17395 cmd_ptype_mapping_replace_parsed(
17396 	void *parsed_result,
17397 	__attribute__((unused)) struct cmdline *cl,
17398 	__attribute__((unused)) void *data)
17399 {
17400 	struct cmd_ptype_mapping_replace_result *res = parsed_result;
17401 	int ret = -ENOTSUP;
17402 
17403 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17404 		return;
17405 
17406 #ifdef RTE_LIBRTE_I40E_PMD
17407 	ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
17408 					res->target,
17409 					res->mask,
17410 					res->pkt_type);
17411 #endif
17412 
17413 	switch (ret) {
17414 	case 0:
17415 		break;
17416 	case -EINVAL:
17417 		printf("invalid ptype 0x%8x or 0x%8x\n",
17418 				res->target, res->pkt_type);
17419 		break;
17420 	case -ENODEV:
17421 		printf("invalid port_id %d\n", res->port_id);
17422 		break;
17423 	case -ENOTSUP:
17424 		printf("function not implemented\n");
17425 		break;
17426 	default:
17427 		printf("programming error: (%s)\n", strerror(-ret));
17428 	}
17429 }
17430 
17431 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
17432 	.f = cmd_ptype_mapping_replace_parsed,
17433 	.data = NULL,
17434 	.help_str =
17435 		"ptype mapping replace <port_id> <target> <mask> <pkt_type>",
17436 	.tokens = {
17437 		(void *)&cmd_ptype_mapping_replace_ptype,
17438 		(void *)&cmd_ptype_mapping_replace_mapping,
17439 		(void *)&cmd_ptype_mapping_replace_replace,
17440 		(void *)&cmd_ptype_mapping_replace_port_id,
17441 		(void *)&cmd_ptype_mapping_replace_target,
17442 		(void *)&cmd_ptype_mapping_replace_mask,
17443 		(void *)&cmd_ptype_mapping_replace_pkt_type,
17444 		NULL,
17445 	},
17446 };
17447 
17448 /* ptype mapping reset */
17449 
17450 /* Common result structure for ptype mapping reset */
17451 struct cmd_ptype_mapping_reset_result {
17452 	cmdline_fixed_string_t ptype;
17453 	cmdline_fixed_string_t mapping;
17454 	cmdline_fixed_string_t reset;
17455 	portid_t port_id;
17456 };
17457 
17458 /* Common CLI fields for ptype mapping reset*/
17459 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
17460 	TOKEN_STRING_INITIALIZER
17461 		(struct cmd_ptype_mapping_reset_result,
17462 		 ptype, "ptype");
17463 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
17464 	TOKEN_STRING_INITIALIZER
17465 		(struct cmd_ptype_mapping_reset_result,
17466 		 mapping, "mapping");
17467 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
17468 	TOKEN_STRING_INITIALIZER
17469 		(struct cmd_ptype_mapping_reset_result,
17470 		 reset, "reset");
17471 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
17472 	TOKEN_NUM_INITIALIZER
17473 		(struct cmd_ptype_mapping_reset_result,
17474 		 port_id, UINT16);
17475 
17476 static void
17477 cmd_ptype_mapping_reset_parsed(
17478 	void *parsed_result,
17479 	__attribute__((unused)) struct cmdline *cl,
17480 	__attribute__((unused)) void *data)
17481 {
17482 	struct cmd_ptype_mapping_reset_result *res = parsed_result;
17483 	int ret = -ENOTSUP;
17484 
17485 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17486 		return;
17487 
17488 #ifdef RTE_LIBRTE_I40E_PMD
17489 	ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
17490 #endif
17491 
17492 	switch (ret) {
17493 	case 0:
17494 		break;
17495 	case -ENODEV:
17496 		printf("invalid port_id %d\n", res->port_id);
17497 		break;
17498 	case -ENOTSUP:
17499 		printf("function not implemented\n");
17500 		break;
17501 	default:
17502 		printf("programming error: (%s)\n", strerror(-ret));
17503 	}
17504 }
17505 
17506 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
17507 	.f = cmd_ptype_mapping_reset_parsed,
17508 	.data = NULL,
17509 	.help_str = "ptype mapping reset <port_id>",
17510 	.tokens = {
17511 		(void *)&cmd_ptype_mapping_reset_ptype,
17512 		(void *)&cmd_ptype_mapping_reset_mapping,
17513 		(void *)&cmd_ptype_mapping_reset_reset,
17514 		(void *)&cmd_ptype_mapping_reset_port_id,
17515 		NULL,
17516 	},
17517 };
17518 
17519 /* ptype mapping update */
17520 
17521 /* Common result structure for ptype mapping update */
17522 struct cmd_ptype_mapping_update_result {
17523 	cmdline_fixed_string_t ptype;
17524 	cmdline_fixed_string_t mapping;
17525 	cmdline_fixed_string_t reset;
17526 	portid_t port_id;
17527 	uint8_t hw_ptype;
17528 	uint32_t sw_ptype;
17529 };
17530 
17531 /* Common CLI fields for ptype mapping update*/
17532 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
17533 	TOKEN_STRING_INITIALIZER
17534 		(struct cmd_ptype_mapping_update_result,
17535 		 ptype, "ptype");
17536 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
17537 	TOKEN_STRING_INITIALIZER
17538 		(struct cmd_ptype_mapping_update_result,
17539 		 mapping, "mapping");
17540 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
17541 	TOKEN_STRING_INITIALIZER
17542 		(struct cmd_ptype_mapping_update_result,
17543 		 reset, "update");
17544 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
17545 	TOKEN_NUM_INITIALIZER
17546 		(struct cmd_ptype_mapping_update_result,
17547 		 port_id, UINT16);
17548 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
17549 	TOKEN_NUM_INITIALIZER
17550 		(struct cmd_ptype_mapping_update_result,
17551 		 hw_ptype, UINT8);
17552 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
17553 	TOKEN_NUM_INITIALIZER
17554 		(struct cmd_ptype_mapping_update_result,
17555 		 sw_ptype, UINT32);
17556 
17557 static void
17558 cmd_ptype_mapping_update_parsed(
17559 	void *parsed_result,
17560 	__attribute__((unused)) struct cmdline *cl,
17561 	__attribute__((unused)) void *data)
17562 {
17563 	struct cmd_ptype_mapping_update_result *res = parsed_result;
17564 	int ret = -ENOTSUP;
17565 #ifdef RTE_LIBRTE_I40E_PMD
17566 	struct rte_pmd_i40e_ptype_mapping mapping;
17567 #endif
17568 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17569 		return;
17570 
17571 #ifdef RTE_LIBRTE_I40E_PMD
17572 	mapping.hw_ptype = res->hw_ptype;
17573 	mapping.sw_ptype = res->sw_ptype;
17574 	ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
17575 						&mapping,
17576 						1,
17577 						0);
17578 #endif
17579 
17580 	switch (ret) {
17581 	case 0:
17582 		break;
17583 	case -EINVAL:
17584 		printf("invalid ptype 0x%8x\n", res->sw_ptype);
17585 		break;
17586 	case -ENODEV:
17587 		printf("invalid port_id %d\n", res->port_id);
17588 		break;
17589 	case -ENOTSUP:
17590 		printf("function not implemented\n");
17591 		break;
17592 	default:
17593 		printf("programming error: (%s)\n", strerror(-ret));
17594 	}
17595 }
17596 
17597 cmdline_parse_inst_t cmd_ptype_mapping_update = {
17598 	.f = cmd_ptype_mapping_update_parsed,
17599 	.data = NULL,
17600 	.help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
17601 	.tokens = {
17602 		(void *)&cmd_ptype_mapping_update_ptype,
17603 		(void *)&cmd_ptype_mapping_update_mapping,
17604 		(void *)&cmd_ptype_mapping_update_update,
17605 		(void *)&cmd_ptype_mapping_update_port_id,
17606 		(void *)&cmd_ptype_mapping_update_hw_ptype,
17607 		(void *)&cmd_ptype_mapping_update_sw_ptype,
17608 		NULL,
17609 	},
17610 };
17611 
17612 /* Common result structure for file commands */
17613 struct cmd_cmdfile_result {
17614 	cmdline_fixed_string_t load;
17615 	cmdline_fixed_string_t filename;
17616 };
17617 
17618 /* Common CLI fields for file commands */
17619 cmdline_parse_token_string_t cmd_load_cmdfile =
17620 	TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
17621 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
17622 	TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
17623 
17624 static void
17625 cmd_load_from_file_parsed(
17626 	void *parsed_result,
17627 	__attribute__((unused)) struct cmdline *cl,
17628 	__attribute__((unused)) void *data)
17629 {
17630 	struct cmd_cmdfile_result *res = parsed_result;
17631 
17632 	cmdline_read_from_file(res->filename);
17633 }
17634 
17635 cmdline_parse_inst_t cmd_load_from_file = {
17636 	.f = cmd_load_from_file_parsed,
17637 	.data = NULL,
17638 	.help_str = "load <filename>",
17639 	.tokens = {
17640 		(void *)&cmd_load_cmdfile,
17641 		(void *)&cmd_load_cmdfile_filename,
17642 		NULL,
17643 	},
17644 };
17645 
17646 /* Get Rx offloads capabilities */
17647 struct cmd_rx_offload_get_capa_result {
17648 	cmdline_fixed_string_t show;
17649 	cmdline_fixed_string_t port;
17650 	portid_t port_id;
17651 	cmdline_fixed_string_t rx_offload;
17652 	cmdline_fixed_string_t capabilities;
17653 };
17654 
17655 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
17656 	TOKEN_STRING_INITIALIZER
17657 		(struct cmd_rx_offload_get_capa_result,
17658 		 show, "show");
17659 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
17660 	TOKEN_STRING_INITIALIZER
17661 		(struct cmd_rx_offload_get_capa_result,
17662 		 port, "port");
17663 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
17664 	TOKEN_NUM_INITIALIZER
17665 		(struct cmd_rx_offload_get_capa_result,
17666 		 port_id, UINT16);
17667 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
17668 	TOKEN_STRING_INITIALIZER
17669 		(struct cmd_rx_offload_get_capa_result,
17670 		 rx_offload, "rx_offload");
17671 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
17672 	TOKEN_STRING_INITIALIZER
17673 		(struct cmd_rx_offload_get_capa_result,
17674 		 capabilities, "capabilities");
17675 
17676 static void
17677 print_rx_offloads(uint64_t offloads)
17678 {
17679 	uint64_t single_offload;
17680 	int begin;
17681 	int end;
17682 	int bit;
17683 
17684 	if (offloads == 0)
17685 		return;
17686 
17687 	begin = __builtin_ctzll(offloads);
17688 	end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
17689 
17690 	single_offload = 1 << begin;
17691 	for (bit = begin; bit < end; bit++) {
17692 		if (offloads & single_offload)
17693 			printf(" %s",
17694 			       rte_eth_dev_rx_offload_name(single_offload));
17695 		single_offload <<= 1;
17696 	}
17697 }
17698 
17699 static void
17700 cmd_rx_offload_get_capa_parsed(
17701 	void *parsed_result,
17702 	__attribute__((unused)) struct cmdline *cl,
17703 	__attribute__((unused)) void *data)
17704 {
17705 	struct cmd_rx_offload_get_capa_result *res = parsed_result;
17706 	struct rte_eth_dev_info dev_info;
17707 	portid_t port_id = res->port_id;
17708 	uint64_t queue_offloads;
17709 	uint64_t port_offloads;
17710 
17711 	rte_eth_dev_info_get(port_id, &dev_info);
17712 	queue_offloads = dev_info.rx_queue_offload_capa;
17713 	port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
17714 
17715 	printf("Rx Offloading Capabilities of port %d :\n", port_id);
17716 	printf("  Per Queue :");
17717 	print_rx_offloads(queue_offloads);
17718 
17719 	printf("\n");
17720 	printf("  Per Port  :");
17721 	print_rx_offloads(port_offloads);
17722 	printf("\n\n");
17723 }
17724 
17725 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
17726 	.f = cmd_rx_offload_get_capa_parsed,
17727 	.data = NULL,
17728 	.help_str = "show port <port_id> rx_offload capabilities",
17729 	.tokens = {
17730 		(void *)&cmd_rx_offload_get_capa_show,
17731 		(void *)&cmd_rx_offload_get_capa_port,
17732 		(void *)&cmd_rx_offload_get_capa_port_id,
17733 		(void *)&cmd_rx_offload_get_capa_rx_offload,
17734 		(void *)&cmd_rx_offload_get_capa_capabilities,
17735 		NULL,
17736 	}
17737 };
17738 
17739 /* Get Rx offloads configuration */
17740 struct cmd_rx_offload_get_configuration_result {
17741 	cmdline_fixed_string_t show;
17742 	cmdline_fixed_string_t port;
17743 	portid_t port_id;
17744 	cmdline_fixed_string_t rx_offload;
17745 	cmdline_fixed_string_t configuration;
17746 };
17747 
17748 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
17749 	TOKEN_STRING_INITIALIZER
17750 		(struct cmd_rx_offload_get_configuration_result,
17751 		 show, "show");
17752 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
17753 	TOKEN_STRING_INITIALIZER
17754 		(struct cmd_rx_offload_get_configuration_result,
17755 		 port, "port");
17756 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
17757 	TOKEN_NUM_INITIALIZER
17758 		(struct cmd_rx_offload_get_configuration_result,
17759 		 port_id, UINT16);
17760 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
17761 	TOKEN_STRING_INITIALIZER
17762 		(struct cmd_rx_offload_get_configuration_result,
17763 		 rx_offload, "rx_offload");
17764 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
17765 	TOKEN_STRING_INITIALIZER
17766 		(struct cmd_rx_offload_get_configuration_result,
17767 		 configuration, "configuration");
17768 
17769 static void
17770 cmd_rx_offload_get_configuration_parsed(
17771 	void *parsed_result,
17772 	__attribute__((unused)) struct cmdline *cl,
17773 	__attribute__((unused)) void *data)
17774 {
17775 	struct cmd_rx_offload_get_configuration_result *res = parsed_result;
17776 	struct rte_eth_dev_info dev_info;
17777 	portid_t port_id = res->port_id;
17778 	struct rte_port *port = &ports[port_id];
17779 	uint64_t port_offloads;
17780 	uint64_t queue_offloads;
17781 	uint16_t nb_rx_queues;
17782 	int q;
17783 
17784 	printf("Rx Offloading Configuration of port %d :\n", port_id);
17785 
17786 	port_offloads = port->dev_conf.rxmode.offloads;
17787 	printf("  Port :");
17788 	print_rx_offloads(port_offloads);
17789 	printf("\n");
17790 
17791 	rte_eth_dev_info_get(port_id, &dev_info);
17792 	nb_rx_queues = dev_info.nb_rx_queues;
17793 	for (q = 0; q < nb_rx_queues; q++) {
17794 		queue_offloads = port->rx_conf[q].offloads;
17795 		printf("  Queue[%2d] :", q);
17796 		print_rx_offloads(queue_offloads);
17797 		printf("\n");
17798 	}
17799 	printf("\n");
17800 }
17801 
17802 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
17803 	.f = cmd_rx_offload_get_configuration_parsed,
17804 	.data = NULL,
17805 	.help_str = "show port <port_id> rx_offload configuration",
17806 	.tokens = {
17807 		(void *)&cmd_rx_offload_get_configuration_show,
17808 		(void *)&cmd_rx_offload_get_configuration_port,
17809 		(void *)&cmd_rx_offload_get_configuration_port_id,
17810 		(void *)&cmd_rx_offload_get_configuration_rx_offload,
17811 		(void *)&cmd_rx_offload_get_configuration_configuration,
17812 		NULL,
17813 	}
17814 };
17815 
17816 /* Enable/Disable a per port offloading */
17817 struct cmd_config_per_port_rx_offload_result {
17818 	cmdline_fixed_string_t port;
17819 	cmdline_fixed_string_t config;
17820 	portid_t port_id;
17821 	cmdline_fixed_string_t rx_offload;
17822 	cmdline_fixed_string_t offload;
17823 	cmdline_fixed_string_t on_off;
17824 };
17825 
17826 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
17827 	TOKEN_STRING_INITIALIZER
17828 		(struct cmd_config_per_port_rx_offload_result,
17829 		 port, "port");
17830 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
17831 	TOKEN_STRING_INITIALIZER
17832 		(struct cmd_config_per_port_rx_offload_result,
17833 		 config, "config");
17834 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
17835 	TOKEN_NUM_INITIALIZER
17836 		(struct cmd_config_per_port_rx_offload_result,
17837 		 port_id, UINT16);
17838 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
17839 	TOKEN_STRING_INITIALIZER
17840 		(struct cmd_config_per_port_rx_offload_result,
17841 		 rx_offload, "rx_offload");
17842 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
17843 	TOKEN_STRING_INITIALIZER
17844 		(struct cmd_config_per_port_rx_offload_result,
17845 		 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
17846 			   "qinq_strip#outer_ipv4_cksum#macsec_strip#"
17847 			   "header_split#vlan_filter#vlan_extend#jumbo_frame#"
17848 			   "crc_strip#scatter#timestamp#security#keep_crc");
17849 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
17850 	TOKEN_STRING_INITIALIZER
17851 		(struct cmd_config_per_port_rx_offload_result,
17852 		 on_off, "on#off");
17853 
17854 static uint64_t
17855 search_rx_offload(const char *name)
17856 {
17857 	uint64_t single_offload;
17858 	const char *single_name;
17859 	int found = 0;
17860 	unsigned int bit;
17861 
17862 	single_offload = 1;
17863 	for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
17864 		single_name = rte_eth_dev_rx_offload_name(single_offload);
17865 		if (!strcasecmp(single_name, name)) {
17866 			found = 1;
17867 			break;
17868 		}
17869 		single_offload <<= 1;
17870 	}
17871 
17872 	if (found)
17873 		return single_offload;
17874 
17875 	return 0;
17876 }
17877 
17878 static void
17879 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
17880 				__attribute__((unused)) struct cmdline *cl,
17881 				__attribute__((unused)) void *data)
17882 {
17883 	struct cmd_config_per_port_rx_offload_result *res = parsed_result;
17884 	portid_t port_id = res->port_id;
17885 	struct rte_eth_dev_info dev_info;
17886 	struct rte_port *port = &ports[port_id];
17887 	uint64_t single_offload;
17888 	uint16_t nb_rx_queues;
17889 	int q;
17890 
17891 	if (port->port_status != RTE_PORT_STOPPED) {
17892 		printf("Error: Can't config offload when Port %d "
17893 		       "is not stopped\n", port_id);
17894 		return;
17895 	}
17896 
17897 	single_offload = search_rx_offload(res->offload);
17898 	if (single_offload == 0) {
17899 		printf("Unknown offload name: %s\n", res->offload);
17900 		return;
17901 	}
17902 
17903 	rte_eth_dev_info_get(port_id, &dev_info);
17904 	nb_rx_queues = dev_info.nb_rx_queues;
17905 	if (!strcmp(res->on_off, "on")) {
17906 		port->dev_conf.rxmode.offloads |= single_offload;
17907 		for (q = 0; q < nb_rx_queues; q++)
17908 			port->rx_conf[q].offloads |= single_offload;
17909 	} else {
17910 		port->dev_conf.rxmode.offloads &= ~single_offload;
17911 		for (q = 0; q < nb_rx_queues; q++)
17912 			port->rx_conf[q].offloads &= ~single_offload;
17913 	}
17914 
17915 	cmd_reconfig_device_queue(port_id, 1, 1);
17916 }
17917 
17918 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
17919 	.f = cmd_config_per_port_rx_offload_parsed,
17920 	.data = NULL,
17921 	.help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
17922 		    "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
17923 		    "macsec_strip|header_split|vlan_filter|vlan_extend|"
17924 		    "jumbo_frame|crc_strip|scatter|timestamp|security|keep_crc "
17925 		    "on|off",
17926 	.tokens = {
17927 		(void *)&cmd_config_per_port_rx_offload_result_port,
17928 		(void *)&cmd_config_per_port_rx_offload_result_config,
17929 		(void *)&cmd_config_per_port_rx_offload_result_port_id,
17930 		(void *)&cmd_config_per_port_rx_offload_result_rx_offload,
17931 		(void *)&cmd_config_per_port_rx_offload_result_offload,
17932 		(void *)&cmd_config_per_port_rx_offload_result_on_off,
17933 		NULL,
17934 	}
17935 };
17936 
17937 /* Enable/Disable a per queue offloading */
17938 struct cmd_config_per_queue_rx_offload_result {
17939 	cmdline_fixed_string_t port;
17940 	portid_t port_id;
17941 	cmdline_fixed_string_t rxq;
17942 	uint16_t queue_id;
17943 	cmdline_fixed_string_t rx_offload;
17944 	cmdline_fixed_string_t offload;
17945 	cmdline_fixed_string_t on_off;
17946 };
17947 
17948 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
17949 	TOKEN_STRING_INITIALIZER
17950 		(struct cmd_config_per_queue_rx_offload_result,
17951 		 port, "port");
17952 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
17953 	TOKEN_NUM_INITIALIZER
17954 		(struct cmd_config_per_queue_rx_offload_result,
17955 		 port_id, UINT16);
17956 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
17957 	TOKEN_STRING_INITIALIZER
17958 		(struct cmd_config_per_queue_rx_offload_result,
17959 		 rxq, "rxq");
17960 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
17961 	TOKEN_NUM_INITIALIZER
17962 		(struct cmd_config_per_queue_rx_offload_result,
17963 		 queue_id, UINT16);
17964 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
17965 	TOKEN_STRING_INITIALIZER
17966 		(struct cmd_config_per_queue_rx_offload_result,
17967 		 rx_offload, "rx_offload");
17968 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
17969 	TOKEN_STRING_INITIALIZER
17970 		(struct cmd_config_per_queue_rx_offload_result,
17971 		 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
17972 			   "qinq_strip#outer_ipv4_cksum#macsec_strip#"
17973 			   "header_split#vlan_filter#vlan_extend#jumbo_frame#"
17974 			   "crc_strip#scatter#timestamp#security#keep_crc");
17975 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
17976 	TOKEN_STRING_INITIALIZER
17977 		(struct cmd_config_per_queue_rx_offload_result,
17978 		 on_off, "on#off");
17979 
17980 static void
17981 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
17982 				__attribute__((unused)) struct cmdline *cl,
17983 				__attribute__((unused)) void *data)
17984 {
17985 	struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
17986 	struct rte_eth_dev_info dev_info;
17987 	portid_t port_id = res->port_id;
17988 	uint16_t queue_id = res->queue_id;
17989 	struct rte_port *port = &ports[port_id];
17990 	uint64_t single_offload;
17991 
17992 	if (port->port_status != RTE_PORT_STOPPED) {
17993 		printf("Error: Can't config offload when Port %d "
17994 		       "is not stopped\n", port_id);
17995 		return;
17996 	}
17997 
17998 	rte_eth_dev_info_get(port_id, &dev_info);
17999 	if (queue_id >= dev_info.nb_rx_queues) {
18000 		printf("Error: input queue_id should be 0 ... "
18001 		       "%d\n", dev_info.nb_rx_queues - 1);
18002 		return;
18003 	}
18004 
18005 	single_offload = search_rx_offload(res->offload);
18006 	if (single_offload == 0) {
18007 		printf("Unknown offload name: %s\n", res->offload);
18008 		return;
18009 	}
18010 
18011 	if (!strcmp(res->on_off, "on"))
18012 		port->rx_conf[queue_id].offloads |= single_offload;
18013 	else
18014 		port->rx_conf[queue_id].offloads &= ~single_offload;
18015 
18016 	cmd_reconfig_device_queue(port_id, 1, 1);
18017 }
18018 
18019 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
18020 	.f = cmd_config_per_queue_rx_offload_parsed,
18021 	.data = NULL,
18022 	.help_str = "port <port_id> rxq <queue_id> rx_offload "
18023 		    "vlan_strip|ipv4_cksum|"
18024 		    "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
18025 		    "macsec_strip|header_split|vlan_filter|vlan_extend|"
18026 		    "jumbo_frame|crc_strip|scatter|timestamp|security|keep_crc "
18027 		    "on|off",
18028 	.tokens = {
18029 		(void *)&cmd_config_per_queue_rx_offload_result_port,
18030 		(void *)&cmd_config_per_queue_rx_offload_result_port_id,
18031 		(void *)&cmd_config_per_queue_rx_offload_result_rxq,
18032 		(void *)&cmd_config_per_queue_rx_offload_result_queue_id,
18033 		(void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
18034 		(void *)&cmd_config_per_queue_rx_offload_result_offload,
18035 		(void *)&cmd_config_per_queue_rx_offload_result_on_off,
18036 		NULL,
18037 	}
18038 };
18039 
18040 /* Get Tx offloads capabilities */
18041 struct cmd_tx_offload_get_capa_result {
18042 	cmdline_fixed_string_t show;
18043 	cmdline_fixed_string_t port;
18044 	portid_t port_id;
18045 	cmdline_fixed_string_t tx_offload;
18046 	cmdline_fixed_string_t capabilities;
18047 };
18048 
18049 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
18050 	TOKEN_STRING_INITIALIZER
18051 		(struct cmd_tx_offload_get_capa_result,
18052 		 show, "show");
18053 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
18054 	TOKEN_STRING_INITIALIZER
18055 		(struct cmd_tx_offload_get_capa_result,
18056 		 port, "port");
18057 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
18058 	TOKEN_NUM_INITIALIZER
18059 		(struct cmd_tx_offload_get_capa_result,
18060 		 port_id, UINT16);
18061 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
18062 	TOKEN_STRING_INITIALIZER
18063 		(struct cmd_tx_offload_get_capa_result,
18064 		 tx_offload, "tx_offload");
18065 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
18066 	TOKEN_STRING_INITIALIZER
18067 		(struct cmd_tx_offload_get_capa_result,
18068 		 capabilities, "capabilities");
18069 
18070 static void
18071 print_tx_offloads(uint64_t offloads)
18072 {
18073 	uint64_t single_offload;
18074 	int begin;
18075 	int end;
18076 	int bit;
18077 
18078 	if (offloads == 0)
18079 		return;
18080 
18081 	begin = __builtin_ctzll(offloads);
18082 	end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
18083 
18084 	single_offload = 1 << begin;
18085 	for (bit = begin; bit < end; bit++) {
18086 		if (offloads & single_offload)
18087 			printf(" %s",
18088 			       rte_eth_dev_tx_offload_name(single_offload));
18089 		single_offload <<= 1;
18090 	}
18091 }
18092 
18093 static void
18094 cmd_tx_offload_get_capa_parsed(
18095 	void *parsed_result,
18096 	__attribute__((unused)) struct cmdline *cl,
18097 	__attribute__((unused)) void *data)
18098 {
18099 	struct cmd_tx_offload_get_capa_result *res = parsed_result;
18100 	struct rte_eth_dev_info dev_info;
18101 	portid_t port_id = res->port_id;
18102 	uint64_t queue_offloads;
18103 	uint64_t port_offloads;
18104 
18105 	rte_eth_dev_info_get(port_id, &dev_info);
18106 	queue_offloads = dev_info.tx_queue_offload_capa;
18107 	port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
18108 
18109 	printf("Tx Offloading Capabilities of port %d :\n", port_id);
18110 	printf("  Per Queue :");
18111 	print_tx_offloads(queue_offloads);
18112 
18113 	printf("\n");
18114 	printf("  Per Port  :");
18115 	print_tx_offloads(port_offloads);
18116 	printf("\n\n");
18117 }
18118 
18119 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
18120 	.f = cmd_tx_offload_get_capa_parsed,
18121 	.data = NULL,
18122 	.help_str = "show port <port_id> tx_offload capabilities",
18123 	.tokens = {
18124 		(void *)&cmd_tx_offload_get_capa_show,
18125 		(void *)&cmd_tx_offload_get_capa_port,
18126 		(void *)&cmd_tx_offload_get_capa_port_id,
18127 		(void *)&cmd_tx_offload_get_capa_tx_offload,
18128 		(void *)&cmd_tx_offload_get_capa_capabilities,
18129 		NULL,
18130 	}
18131 };
18132 
18133 /* Get Tx offloads configuration */
18134 struct cmd_tx_offload_get_configuration_result {
18135 	cmdline_fixed_string_t show;
18136 	cmdline_fixed_string_t port;
18137 	portid_t port_id;
18138 	cmdline_fixed_string_t tx_offload;
18139 	cmdline_fixed_string_t configuration;
18140 };
18141 
18142 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
18143 	TOKEN_STRING_INITIALIZER
18144 		(struct cmd_tx_offload_get_configuration_result,
18145 		 show, "show");
18146 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
18147 	TOKEN_STRING_INITIALIZER
18148 		(struct cmd_tx_offload_get_configuration_result,
18149 		 port, "port");
18150 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
18151 	TOKEN_NUM_INITIALIZER
18152 		(struct cmd_tx_offload_get_configuration_result,
18153 		 port_id, UINT16);
18154 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
18155 	TOKEN_STRING_INITIALIZER
18156 		(struct cmd_tx_offload_get_configuration_result,
18157 		 tx_offload, "tx_offload");
18158 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
18159 	TOKEN_STRING_INITIALIZER
18160 		(struct cmd_tx_offload_get_configuration_result,
18161 		 configuration, "configuration");
18162 
18163 static void
18164 cmd_tx_offload_get_configuration_parsed(
18165 	void *parsed_result,
18166 	__attribute__((unused)) struct cmdline *cl,
18167 	__attribute__((unused)) void *data)
18168 {
18169 	struct cmd_tx_offload_get_configuration_result *res = parsed_result;
18170 	struct rte_eth_dev_info dev_info;
18171 	portid_t port_id = res->port_id;
18172 	struct rte_port *port = &ports[port_id];
18173 	uint64_t port_offloads;
18174 	uint64_t queue_offloads;
18175 	uint16_t nb_tx_queues;
18176 	int q;
18177 
18178 	printf("Tx Offloading Configuration of port %d :\n", port_id);
18179 
18180 	port_offloads = port->dev_conf.txmode.offloads;
18181 	printf("  Port :");
18182 	print_tx_offloads(port_offloads);
18183 	printf("\n");
18184 
18185 	rte_eth_dev_info_get(port_id, &dev_info);
18186 	nb_tx_queues = dev_info.nb_tx_queues;
18187 	for (q = 0; q < nb_tx_queues; q++) {
18188 		queue_offloads = port->tx_conf[q].offloads;
18189 		printf("  Queue[%2d] :", q);
18190 		print_tx_offloads(queue_offloads);
18191 		printf("\n");
18192 	}
18193 	printf("\n");
18194 }
18195 
18196 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
18197 	.f = cmd_tx_offload_get_configuration_parsed,
18198 	.data = NULL,
18199 	.help_str = "show port <port_id> tx_offload configuration",
18200 	.tokens = {
18201 		(void *)&cmd_tx_offload_get_configuration_show,
18202 		(void *)&cmd_tx_offload_get_configuration_port,
18203 		(void *)&cmd_tx_offload_get_configuration_port_id,
18204 		(void *)&cmd_tx_offload_get_configuration_tx_offload,
18205 		(void *)&cmd_tx_offload_get_configuration_configuration,
18206 		NULL,
18207 	}
18208 };
18209 
18210 /* Enable/Disable a per port offloading */
18211 struct cmd_config_per_port_tx_offload_result {
18212 	cmdline_fixed_string_t port;
18213 	cmdline_fixed_string_t config;
18214 	portid_t port_id;
18215 	cmdline_fixed_string_t tx_offload;
18216 	cmdline_fixed_string_t offload;
18217 	cmdline_fixed_string_t on_off;
18218 };
18219 
18220 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
18221 	TOKEN_STRING_INITIALIZER
18222 		(struct cmd_config_per_port_tx_offload_result,
18223 		 port, "port");
18224 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
18225 	TOKEN_STRING_INITIALIZER
18226 		(struct cmd_config_per_port_tx_offload_result,
18227 		 config, "config");
18228 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
18229 	TOKEN_NUM_INITIALIZER
18230 		(struct cmd_config_per_port_tx_offload_result,
18231 		 port_id, UINT16);
18232 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
18233 	TOKEN_STRING_INITIALIZER
18234 		(struct cmd_config_per_port_tx_offload_result,
18235 		 tx_offload, "tx_offload");
18236 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
18237 	TOKEN_STRING_INITIALIZER
18238 		(struct cmd_config_per_port_tx_offload_result,
18239 		 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18240 			  "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18241 			  "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18242 			  "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18243 			  "mt_lockfree#multi_segs#mbuf_fast_free#security#"
18244 			  "match_metadata");
18245 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
18246 	TOKEN_STRING_INITIALIZER
18247 		(struct cmd_config_per_port_tx_offload_result,
18248 		 on_off, "on#off");
18249 
18250 static uint64_t
18251 search_tx_offload(const char *name)
18252 {
18253 	uint64_t single_offload;
18254 	const char *single_name;
18255 	int found = 0;
18256 	unsigned int bit;
18257 
18258 	single_offload = 1;
18259 	for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
18260 		single_name = rte_eth_dev_tx_offload_name(single_offload);
18261 		if (!strcasecmp(single_name, name)) {
18262 			found = 1;
18263 			break;
18264 		} else if (!strcasecmp(single_name, "UNKNOWN"))
18265 			break;
18266 		else if (single_name == NULL)
18267 			break;
18268 		single_offload <<= 1;
18269 	}
18270 
18271 	if (found)
18272 		return single_offload;
18273 
18274 	return 0;
18275 }
18276 
18277 static void
18278 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
18279 				__attribute__((unused)) struct cmdline *cl,
18280 				__attribute__((unused)) void *data)
18281 {
18282 	struct cmd_config_per_port_tx_offload_result *res = parsed_result;
18283 	portid_t port_id = res->port_id;
18284 	struct rte_eth_dev_info dev_info;
18285 	struct rte_port *port = &ports[port_id];
18286 	uint64_t single_offload;
18287 	uint16_t nb_tx_queues;
18288 	int q;
18289 
18290 	if (port->port_status != RTE_PORT_STOPPED) {
18291 		printf("Error: Can't config offload when Port %d "
18292 		       "is not stopped\n", port_id);
18293 		return;
18294 	}
18295 
18296 	single_offload = search_tx_offload(res->offload);
18297 	if (single_offload == 0) {
18298 		printf("Unknown offload name: %s\n", res->offload);
18299 		return;
18300 	}
18301 
18302 	rte_eth_dev_info_get(port_id, &dev_info);
18303 	nb_tx_queues = dev_info.nb_tx_queues;
18304 	if (!strcmp(res->on_off, "on")) {
18305 		port->dev_conf.txmode.offloads |= single_offload;
18306 		for (q = 0; q < nb_tx_queues; q++)
18307 			port->tx_conf[q].offloads |= single_offload;
18308 	} else {
18309 		port->dev_conf.txmode.offloads &= ~single_offload;
18310 		for (q = 0; q < nb_tx_queues; q++)
18311 			port->tx_conf[q].offloads &= ~single_offload;
18312 	}
18313 
18314 	cmd_reconfig_device_queue(port_id, 1, 1);
18315 }
18316 
18317 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
18318 	.f = cmd_config_per_port_tx_offload_parsed,
18319 	.data = NULL,
18320 	.help_str = "port config <port_id> tx_offload "
18321 		    "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
18322 		    "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
18323 		    "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
18324 		    "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
18325 		    "mt_lockfree|multi_segs|mbuf_fast_free|security|"
18326 		    "match_metadata on|off",
18327 	.tokens = {
18328 		(void *)&cmd_config_per_port_tx_offload_result_port,
18329 		(void *)&cmd_config_per_port_tx_offload_result_config,
18330 		(void *)&cmd_config_per_port_tx_offload_result_port_id,
18331 		(void *)&cmd_config_per_port_tx_offload_result_tx_offload,
18332 		(void *)&cmd_config_per_port_tx_offload_result_offload,
18333 		(void *)&cmd_config_per_port_tx_offload_result_on_off,
18334 		NULL,
18335 	}
18336 };
18337 
18338 /* Enable/Disable a per queue offloading */
18339 struct cmd_config_per_queue_tx_offload_result {
18340 	cmdline_fixed_string_t port;
18341 	portid_t port_id;
18342 	cmdline_fixed_string_t txq;
18343 	uint16_t queue_id;
18344 	cmdline_fixed_string_t tx_offload;
18345 	cmdline_fixed_string_t offload;
18346 	cmdline_fixed_string_t on_off;
18347 };
18348 
18349 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
18350 	TOKEN_STRING_INITIALIZER
18351 		(struct cmd_config_per_queue_tx_offload_result,
18352 		 port, "port");
18353 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
18354 	TOKEN_NUM_INITIALIZER
18355 		(struct cmd_config_per_queue_tx_offload_result,
18356 		 port_id, UINT16);
18357 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
18358 	TOKEN_STRING_INITIALIZER
18359 		(struct cmd_config_per_queue_tx_offload_result,
18360 		 txq, "txq");
18361 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
18362 	TOKEN_NUM_INITIALIZER
18363 		(struct cmd_config_per_queue_tx_offload_result,
18364 		 queue_id, UINT16);
18365 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
18366 	TOKEN_STRING_INITIALIZER
18367 		(struct cmd_config_per_queue_tx_offload_result,
18368 		 tx_offload, "tx_offload");
18369 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
18370 	TOKEN_STRING_INITIALIZER
18371 		(struct cmd_config_per_queue_tx_offload_result,
18372 		 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18373 			  "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18374 			  "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18375 			  "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18376 			  "mt_lockfree#multi_segs#mbuf_fast_free#security");
18377 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
18378 	TOKEN_STRING_INITIALIZER
18379 		(struct cmd_config_per_queue_tx_offload_result,
18380 		 on_off, "on#off");
18381 
18382 static void
18383 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
18384 				__attribute__((unused)) struct cmdline *cl,
18385 				__attribute__((unused)) void *data)
18386 {
18387 	struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
18388 	struct rte_eth_dev_info dev_info;
18389 	portid_t port_id = res->port_id;
18390 	uint16_t queue_id = res->queue_id;
18391 	struct rte_port *port = &ports[port_id];
18392 	uint64_t single_offload;
18393 
18394 	if (port->port_status != RTE_PORT_STOPPED) {
18395 		printf("Error: Can't config offload when Port %d "
18396 		       "is not stopped\n", port_id);
18397 		return;
18398 	}
18399 
18400 	rte_eth_dev_info_get(port_id, &dev_info);
18401 	if (queue_id >= dev_info.nb_tx_queues) {
18402 		printf("Error: input queue_id should be 0 ... "
18403 		       "%d\n", dev_info.nb_tx_queues - 1);
18404 		return;
18405 	}
18406 
18407 	single_offload = search_tx_offload(res->offload);
18408 	if (single_offload == 0) {
18409 		printf("Unknown offload name: %s\n", res->offload);
18410 		return;
18411 	}
18412 
18413 	if (!strcmp(res->on_off, "on"))
18414 		port->tx_conf[queue_id].offloads |= single_offload;
18415 	else
18416 		port->tx_conf[queue_id].offloads &= ~single_offload;
18417 
18418 	cmd_reconfig_device_queue(port_id, 1, 1);
18419 }
18420 
18421 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
18422 	.f = cmd_config_per_queue_tx_offload_parsed,
18423 	.data = NULL,
18424 	.help_str = "port <port_id> txq <queue_id> tx_offload "
18425 		    "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
18426 		    "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
18427 		    "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
18428 		    "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
18429 		    "mt_lockfree|multi_segs|mbuf_fast_free|security "
18430 		    "on|off",
18431 	.tokens = {
18432 		(void *)&cmd_config_per_queue_tx_offload_result_port,
18433 		(void *)&cmd_config_per_queue_tx_offload_result_port_id,
18434 		(void *)&cmd_config_per_queue_tx_offload_result_txq,
18435 		(void *)&cmd_config_per_queue_tx_offload_result_queue_id,
18436 		(void *)&cmd_config_per_queue_tx_offload_result_txoffload,
18437 		(void *)&cmd_config_per_queue_tx_offload_result_offload,
18438 		(void *)&cmd_config_per_queue_tx_offload_result_on_off,
18439 		NULL,
18440 	}
18441 };
18442 
18443 /* *** configure tx_metadata for specific port *** */
18444 struct cmd_config_tx_metadata_specific_result {
18445 	cmdline_fixed_string_t port;
18446 	cmdline_fixed_string_t keyword;
18447 	uint16_t port_id;
18448 	cmdline_fixed_string_t item;
18449 	uint32_t value;
18450 };
18451 
18452 static void
18453 cmd_config_tx_metadata_specific_parsed(void *parsed_result,
18454 				__attribute__((unused)) struct cmdline *cl,
18455 				__attribute__((unused)) void *data)
18456 {
18457 	struct cmd_config_tx_metadata_specific_result *res = parsed_result;
18458 
18459 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
18460 		return;
18461 	ports[res->port_id].tx_metadata = rte_cpu_to_be_32(res->value);
18462 	/* Add/remove callback to insert valid metadata in every Tx packet. */
18463 	if (ports[res->port_id].tx_metadata)
18464 		add_tx_md_callback(res->port_id);
18465 	else
18466 		remove_tx_md_callback(res->port_id);
18467 }
18468 
18469 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
18470 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18471 			port, "port");
18472 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
18473 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18474 			keyword, "config");
18475 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
18476 	TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18477 			port_id, UINT16);
18478 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
18479 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18480 			item, "tx_metadata");
18481 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
18482 	TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18483 			value, UINT32);
18484 
18485 cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
18486 	.f = cmd_config_tx_metadata_specific_parsed,
18487 	.data = NULL,
18488 	.help_str = "port config <port_id> tx_metadata <value>",
18489 	.tokens = {
18490 		(void *)&cmd_config_tx_metadata_specific_port,
18491 		(void *)&cmd_config_tx_metadata_specific_keyword,
18492 		(void *)&cmd_config_tx_metadata_specific_id,
18493 		(void *)&cmd_config_tx_metadata_specific_item,
18494 		(void *)&cmd_config_tx_metadata_specific_value,
18495 		NULL,
18496 	},
18497 };
18498 
18499 /* *** display tx_metadata per port configuration *** */
18500 struct cmd_show_tx_metadata_result {
18501 	cmdline_fixed_string_t cmd_show;
18502 	cmdline_fixed_string_t cmd_port;
18503 	cmdline_fixed_string_t cmd_keyword;
18504 	portid_t cmd_pid;
18505 };
18506 
18507 static void
18508 cmd_show_tx_metadata_parsed(void *parsed_result,
18509 		__attribute__((unused)) struct cmdline *cl,
18510 		__attribute__((unused)) void *data)
18511 {
18512 	struct cmd_show_tx_metadata_result *res = parsed_result;
18513 
18514 	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
18515 		printf("invalid port id %u\n", res->cmd_pid);
18516 		return;
18517 	}
18518 	if (!strcmp(res->cmd_keyword, "tx_metadata")) {
18519 		printf("Port %u tx_metadata: %u\n", res->cmd_pid,
18520 			rte_be_to_cpu_32(ports[res->cmd_pid].tx_metadata));
18521 	}
18522 }
18523 
18524 cmdline_parse_token_string_t cmd_show_tx_metadata_show =
18525 	TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
18526 			cmd_show, "show");
18527 cmdline_parse_token_string_t cmd_show_tx_metadata_port =
18528 	TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
18529 			cmd_port, "port");
18530 cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
18531 	TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
18532 			cmd_pid, UINT16);
18533 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
18534 	TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
18535 			cmd_keyword, "tx_metadata");
18536 
18537 cmdline_parse_inst_t cmd_show_tx_metadata = {
18538 	.f = cmd_show_tx_metadata_parsed,
18539 	.data = NULL,
18540 	.help_str = "show port <port_id> tx_metadata",
18541 	.tokens = {
18542 		(void *)&cmd_show_tx_metadata_show,
18543 		(void *)&cmd_show_tx_metadata_port,
18544 		(void *)&cmd_show_tx_metadata_pid,
18545 		(void *)&cmd_show_tx_metadata_keyword,
18546 		NULL,
18547 	},
18548 };
18549 
18550 /* ******************************************************************************** */
18551 
18552 /* list of instructions */
18553 cmdline_parse_ctx_t main_ctx[] = {
18554 	(cmdline_parse_inst_t *)&cmd_help_brief,
18555 	(cmdline_parse_inst_t *)&cmd_help_long,
18556 	(cmdline_parse_inst_t *)&cmd_quit,
18557 	(cmdline_parse_inst_t *)&cmd_load_from_file,
18558 	(cmdline_parse_inst_t *)&cmd_showport,
18559 	(cmdline_parse_inst_t *)&cmd_showqueue,
18560 	(cmdline_parse_inst_t *)&cmd_showportall,
18561 	(cmdline_parse_inst_t *)&cmd_showcfg,
18562 	(cmdline_parse_inst_t *)&cmd_start,
18563 	(cmdline_parse_inst_t *)&cmd_start_tx_first,
18564 	(cmdline_parse_inst_t *)&cmd_start_tx_first_n,
18565 	(cmdline_parse_inst_t *)&cmd_set_link_up,
18566 	(cmdline_parse_inst_t *)&cmd_set_link_down,
18567 	(cmdline_parse_inst_t *)&cmd_reset,
18568 	(cmdline_parse_inst_t *)&cmd_set_numbers,
18569 	(cmdline_parse_inst_t *)&cmd_set_log,
18570 	(cmdline_parse_inst_t *)&cmd_set_txpkts,
18571 	(cmdline_parse_inst_t *)&cmd_set_txsplit,
18572 	(cmdline_parse_inst_t *)&cmd_set_fwd_list,
18573 	(cmdline_parse_inst_t *)&cmd_set_fwd_mask,
18574 	(cmdline_parse_inst_t *)&cmd_set_fwd_mode,
18575 	(cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
18576 	(cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
18577 	(cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
18578 	(cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
18579 	(cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
18580 	(cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
18581 	(cmdline_parse_inst_t *)&cmd_set_flush_rx,
18582 	(cmdline_parse_inst_t *)&cmd_set_link_check,
18583 	(cmdline_parse_inst_t *)&cmd_set_bypass_mode,
18584 	(cmdline_parse_inst_t *)&cmd_set_bypass_event,
18585 	(cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
18586 	(cmdline_parse_inst_t *)&cmd_show_bypass_config,
18587 #ifdef RTE_LIBRTE_PMD_BOND
18588 	(cmdline_parse_inst_t *) &cmd_set_bonding_mode,
18589 	(cmdline_parse_inst_t *) &cmd_show_bonding_config,
18590 	(cmdline_parse_inst_t *) &cmd_set_bonding_primary,
18591 	(cmdline_parse_inst_t *) &cmd_add_bonding_slave,
18592 	(cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
18593 	(cmdline_parse_inst_t *) &cmd_create_bonded_device,
18594 	(cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
18595 	(cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
18596 	(cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
18597 	(cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
18598 	(cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
18599 #endif
18600 	(cmdline_parse_inst_t *)&cmd_vlan_offload,
18601 	(cmdline_parse_inst_t *)&cmd_vlan_tpid,
18602 	(cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
18603 	(cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
18604 	(cmdline_parse_inst_t *)&cmd_tx_vlan_set,
18605 	(cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
18606 	(cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
18607 	(cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
18608 	(cmdline_parse_inst_t *)&cmd_csum_set,
18609 	(cmdline_parse_inst_t *)&cmd_csum_show,
18610 	(cmdline_parse_inst_t *)&cmd_csum_tunnel,
18611 	(cmdline_parse_inst_t *)&cmd_tso_set,
18612 	(cmdline_parse_inst_t *)&cmd_tso_show,
18613 	(cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
18614 	(cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
18615 	(cmdline_parse_inst_t *)&cmd_gro_enable,
18616 	(cmdline_parse_inst_t *)&cmd_gro_flush,
18617 	(cmdline_parse_inst_t *)&cmd_gro_show,
18618 	(cmdline_parse_inst_t *)&cmd_gso_enable,
18619 	(cmdline_parse_inst_t *)&cmd_gso_size,
18620 	(cmdline_parse_inst_t *)&cmd_gso_show,
18621 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set,
18622 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
18623 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
18624 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
18625 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
18626 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
18627 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
18628 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
18629 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
18630 	(cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
18631 	(cmdline_parse_inst_t *)&cmd_config_dcb,
18632 	(cmdline_parse_inst_t *)&cmd_read_reg,
18633 	(cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
18634 	(cmdline_parse_inst_t *)&cmd_read_reg_bit,
18635 	(cmdline_parse_inst_t *)&cmd_write_reg,
18636 	(cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
18637 	(cmdline_parse_inst_t *)&cmd_write_reg_bit,
18638 	(cmdline_parse_inst_t *)&cmd_read_rxd_txd,
18639 	(cmdline_parse_inst_t *)&cmd_stop,
18640 	(cmdline_parse_inst_t *)&cmd_mac_addr,
18641 	(cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
18642 	(cmdline_parse_inst_t *)&cmd_set_qmap,
18643 	(cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
18644 	(cmdline_parse_inst_t *)&cmd_operate_port,
18645 	(cmdline_parse_inst_t *)&cmd_operate_specific_port,
18646 	(cmdline_parse_inst_t *)&cmd_operate_attach_port,
18647 	(cmdline_parse_inst_t *)&cmd_operate_detach_port,
18648 	(cmdline_parse_inst_t *)&cmd_set_port_setup_on,
18649 	(cmdline_parse_inst_t *)&cmd_config_speed_all,
18650 	(cmdline_parse_inst_t *)&cmd_config_speed_specific,
18651 	(cmdline_parse_inst_t *)&cmd_config_loopback_all,
18652 	(cmdline_parse_inst_t *)&cmd_config_loopback_specific,
18653 	(cmdline_parse_inst_t *)&cmd_config_rx_tx,
18654 	(cmdline_parse_inst_t *)&cmd_config_mtu,
18655 	(cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
18656 	(cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
18657 	(cmdline_parse_inst_t *)&cmd_config_rss,
18658 	(cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
18659 	(cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
18660 	(cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
18661 	(cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
18662 	(cmdline_parse_inst_t *)&cmd_config_rss_reta,
18663 	(cmdline_parse_inst_t *)&cmd_showport_reta,
18664 	(cmdline_parse_inst_t *)&cmd_config_burst,
18665 	(cmdline_parse_inst_t *)&cmd_config_thresh,
18666 	(cmdline_parse_inst_t *)&cmd_config_threshold,
18667 	(cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
18668 	(cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
18669 	(cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
18670 	(cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
18671 	(cmdline_parse_inst_t *)&cmd_queue_rate_limit,
18672 	(cmdline_parse_inst_t *)&cmd_tunnel_filter,
18673 	(cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
18674 	(cmdline_parse_inst_t *)&cmd_global_config,
18675 	(cmdline_parse_inst_t *)&cmd_set_mirror_mask,
18676 	(cmdline_parse_inst_t *)&cmd_set_mirror_link,
18677 	(cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
18678 	(cmdline_parse_inst_t *)&cmd_showport_rss_hash,
18679 	(cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
18680 	(cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
18681 	(cmdline_parse_inst_t *)&cmd_dump,
18682 	(cmdline_parse_inst_t *)&cmd_dump_one,
18683 	(cmdline_parse_inst_t *)&cmd_ethertype_filter,
18684 	(cmdline_parse_inst_t *)&cmd_syn_filter,
18685 	(cmdline_parse_inst_t *)&cmd_2tuple_filter,
18686 	(cmdline_parse_inst_t *)&cmd_5tuple_filter,
18687 	(cmdline_parse_inst_t *)&cmd_flex_filter,
18688 	(cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
18689 	(cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
18690 	(cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
18691 	(cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
18692 	(cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
18693 	(cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
18694 	(cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
18695 	(cmdline_parse_inst_t *)&cmd_flush_flow_director,
18696 	(cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
18697 	(cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
18698 	(cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
18699 	(cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
18700 	(cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
18701 	(cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
18702 	(cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
18703 	(cmdline_parse_inst_t *)&cmd_get_hash_global_config,
18704 	(cmdline_parse_inst_t *)&cmd_set_hash_global_config,
18705 	(cmdline_parse_inst_t *)&cmd_set_hash_input_set,
18706 	(cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
18707 	(cmdline_parse_inst_t *)&cmd_flow,
18708 	(cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
18709 	(cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
18710 	(cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
18711 	(cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
18712 	(cmdline_parse_inst_t *)&cmd_create_port_meter,
18713 	(cmdline_parse_inst_t *)&cmd_enable_port_meter,
18714 	(cmdline_parse_inst_t *)&cmd_disable_port_meter,
18715 	(cmdline_parse_inst_t *)&cmd_del_port_meter,
18716 	(cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
18717 	(cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
18718 	(cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
18719 	(cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
18720 	(cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
18721 	(cmdline_parse_inst_t *)&cmd_mcast_addr,
18722 	(cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
18723 	(cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
18724 	(cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
18725 	(cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
18726 	(cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
18727 	(cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
18728 	(cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
18729 	(cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
18730 	(cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
18731 	(cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
18732 	(cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
18733 	(cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
18734 	(cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
18735 	(cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
18736 	(cmdline_parse_inst_t *)&cmd_set_tx_loopback,
18737 	(cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
18738 	(cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
18739 	(cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
18740 	(cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
18741 	(cmdline_parse_inst_t *)&cmd_set_macsec_sc,
18742 	(cmdline_parse_inst_t *)&cmd_set_macsec_sa,
18743 	(cmdline_parse_inst_t *)&cmd_set_vf_traffic,
18744 	(cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
18745 	(cmdline_parse_inst_t *)&cmd_vf_rate_limit,
18746 	(cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
18747 	(cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
18748 	(cmdline_parse_inst_t *)&cmd_set_vf_promisc,
18749 	(cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
18750 	(cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
18751 	(cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
18752 	(cmdline_parse_inst_t *)&cmd_vf_max_bw,
18753 	(cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
18754 	(cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
18755 	(cmdline_parse_inst_t *)&cmd_strict_link_prio,
18756 	(cmdline_parse_inst_t *)&cmd_tc_min_bw,
18757 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
18758 	(cmdline_parse_inst_t *)&cmd_set_port_tm_hierarchy_default,
18759 #endif
18760 	(cmdline_parse_inst_t *)&cmd_set_vxlan,
18761 	(cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl,
18762 	(cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
18763 	(cmdline_parse_inst_t *)&cmd_set_nvgre,
18764 	(cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
18765 	(cmdline_parse_inst_t *)&cmd_set_l2_encap,
18766 	(cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
18767 	(cmdline_parse_inst_t *)&cmd_set_l2_decap,
18768 	(cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
18769 	(cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
18770 	(cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
18771 	(cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
18772 	(cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
18773 	(cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
18774 	(cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
18775 	(cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
18776 	(cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
18777 	(cmdline_parse_inst_t *)&cmd_ddp_add,
18778 	(cmdline_parse_inst_t *)&cmd_ddp_del,
18779 	(cmdline_parse_inst_t *)&cmd_ddp_get_list,
18780 	(cmdline_parse_inst_t *)&cmd_ddp_get_info,
18781 	(cmdline_parse_inst_t *)&cmd_cfg_input_set,
18782 	(cmdline_parse_inst_t *)&cmd_clear_input_set,
18783 	(cmdline_parse_inst_t *)&cmd_show_vf_stats,
18784 	(cmdline_parse_inst_t *)&cmd_clear_vf_stats,
18785 	(cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
18786 	(cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
18787 	(cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
18788 	(cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
18789 
18790 	(cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
18791 	(cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
18792 	(cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
18793 	(cmdline_parse_inst_t *)&cmd_queue_region,
18794 	(cmdline_parse_inst_t *)&cmd_region_flowtype,
18795 	(cmdline_parse_inst_t *)&cmd_user_priority_region,
18796 	(cmdline_parse_inst_t *)&cmd_flush_queue_region,
18797 	(cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
18798 	(cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
18799 	(cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
18800 	(cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
18801 	(cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
18802 	(cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
18803 	(cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
18804 	(cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
18805 	(cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
18806 	(cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
18807 	(cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
18808 	(cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
18809 	(cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
18810 	(cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
18811 	(cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
18812 	(cmdline_parse_inst_t *)&cmd_del_port_tm_node,
18813 	(cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
18814 	(cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
18815 	(cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
18816 	(cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
18817 	(cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
18818 	(cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
18819 	(cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
18820 	(cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
18821 	(cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
18822 	(cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
18823 	(cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
18824 	(cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
18825 	(cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
18826 	(cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
18827 	(cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
18828 	(cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
18829 #ifdef RTE_LIBRTE_BPF
18830 	(cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
18831 	(cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
18832 #endif
18833 	(cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
18834 	(cmdline_parse_inst_t *)&cmd_show_tx_metadata,
18835 	NULL,
18836 };
18837 
18838 /* read cmdline commands from file */
18839 void
18840 cmdline_read_from_file(const char *filename)
18841 {
18842 	struct cmdline *cl;
18843 
18844 	cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
18845 	if (cl == NULL) {
18846 		printf("Failed to create file based cmdline context: %s\n",
18847 		       filename);
18848 		return;
18849 	}
18850 
18851 	cmdline_interact(cl);
18852 	cmdline_quit(cl);
18853 
18854 	cmdline_free(cl);
18855 
18856 	printf("Read CLI commands from %s\n", filename);
18857 }
18858 
18859 /* prompt function, called from main on MASTER lcore */
18860 void
18861 prompt(void)
18862 {
18863 	/* initialize non-constant commands */
18864 	cmd_set_fwd_mode_init();
18865 	cmd_set_fwd_retry_mode_init();
18866 
18867 	testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
18868 	if (testpmd_cl == NULL)
18869 		return;
18870 	cmdline_interact(testpmd_cl);
18871 	cmdline_stdin_exit(testpmd_cl);
18872 }
18873 
18874 void
18875 prompt_exit(void)
18876 {
18877 	if (testpmd_cl != NULL)
18878 		cmdline_quit(testpmd_cl);
18879 }
18880 
18881 static void
18882 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
18883 {
18884 	if (id == (portid_t)RTE_PORT_ALL) {
18885 		portid_t pid;
18886 
18887 		RTE_ETH_FOREACH_DEV(pid) {
18888 			/* check if need_reconfig has been set to 1 */
18889 			if (ports[pid].need_reconfig == 0)
18890 				ports[pid].need_reconfig = dev;
18891 			/* check if need_reconfig_queues has been set to 1 */
18892 			if (ports[pid].need_reconfig_queues == 0)
18893 				ports[pid].need_reconfig_queues = queue;
18894 		}
18895 	} else if (!port_id_is_invalid(id, DISABLED_WARN)) {
18896 		/* check if need_reconfig has been set to 1 */
18897 		if (ports[id].need_reconfig == 0)
18898 			ports[id].need_reconfig = dev;
18899 		/* check if need_reconfig_queues has been set to 1 */
18900 		if (ports[id].need_reconfig_queues == 0)
18901 			ports[id].need_reconfig_queues = queue;
18902 	}
18903 }
18904