xref: /dpdk/app/test-pmd/cmdline.c (revision 92c9ba90)
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2010-2016 Intel Corporation.
3  * Copyright(c) 2014 6WIND S.A.
4  */
5 
6 #include <stdarg.h>
7 #include <errno.h>
8 #include <stdio.h>
9 #include <stdint.h>
10 #include <string.h>
11 #include <termios.h>
12 #include <unistd.h>
13 #include <inttypes.h>
14 #ifndef __linux__
15 #ifndef __FreeBSD__
16 #include <net/socket.h>
17 #else
18 #include <sys/socket.h>
19 #endif
20 #endif
21 #include <netinet/in.h>
22 
23 #include <sys/queue.h>
24 
25 #include <rte_common.h>
26 #include <rte_byteorder.h>
27 #include <rte_log.h>
28 #include <rte_debug.h>
29 #include <rte_cycles.h>
30 #include <rte_memory.h>
31 #include <rte_memzone.h>
32 #include <rte_malloc.h>
33 #include <rte_launch.h>
34 #include <rte_eal.h>
35 #include <rte_per_lcore.h>
36 #include <rte_lcore.h>
37 #include <rte_atomic.h>
38 #include <rte_branch_prediction.h>
39 #include <rte_ring.h>
40 #include <rte_mempool.h>
41 #include <rte_interrupts.h>
42 #include <rte_pci.h>
43 #include <rte_ether.h>
44 #include <rte_ethdev.h>
45 #include <rte_string_fns.h>
46 #include <rte_devargs.h>
47 #include <rte_flow.h>
48 #include <rte_gro.h>
49 
50 #include <cmdline_rdline.h>
51 #include <cmdline_parse.h>
52 #include <cmdline_parse_num.h>
53 #include <cmdline_parse_string.h>
54 #include <cmdline_parse_ipaddr.h>
55 #include <cmdline_parse_etheraddr.h>
56 #include <cmdline_socket.h>
57 #include <cmdline.h>
58 #ifdef RTE_LIBRTE_PMD_BOND
59 #include <rte_eth_bond.h>
60 #include <rte_eth_bond_8023ad.h>
61 #endif
62 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD
63 #include <rte_pmd_dpaa.h>
64 #endif
65 #ifdef RTE_LIBRTE_IXGBE_PMD
66 #include <rte_pmd_ixgbe.h>
67 #endif
68 #ifdef RTE_LIBRTE_I40E_PMD
69 #include <rte_pmd_i40e.h>
70 #endif
71 #ifdef RTE_LIBRTE_BNXT_PMD
72 #include <rte_pmd_bnxt.h>
73 #endif
74 #include "testpmd.h"
75 #include "cmdline_mtr.h"
76 #include "cmdline_tm.h"
77 #include "bpf_cmd.h"
78 
79 static struct cmdline *testpmd_cl;
80 
81 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
82 
83 /* *** Help command with introduction. *** */
84 struct cmd_help_brief_result {
85 	cmdline_fixed_string_t help;
86 };
87 
88 static void cmd_help_brief_parsed(__attribute__((unused)) void *parsed_result,
89                                   struct cmdline *cl,
90                                   __attribute__((unused)) void *data)
91 {
92 	cmdline_printf(
93 		cl,
94 		"\n"
95 		"Help is available for the following sections:\n\n"
96 		"    help control    : Start and stop forwarding.\n"
97 		"    help display    : Displaying port, stats and config "
98 		"information.\n"
99 		"    help config     : Configuration information.\n"
100 		"    help ports      : Configuring ports.\n"
101 		"    help registers  : Reading and setting port registers.\n"
102 		"    help filters    : Filters configuration help.\n"
103 		"    help all        : All of the above sections.\n\n"
104 	);
105 
106 }
107 
108 cmdline_parse_token_string_t cmd_help_brief_help =
109 	TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
110 
111 cmdline_parse_inst_t cmd_help_brief = {
112 	.f = cmd_help_brief_parsed,
113 	.data = NULL,
114 	.help_str = "help: Show help",
115 	.tokens = {
116 		(void *)&cmd_help_brief_help,
117 		NULL,
118 	},
119 };
120 
121 /* *** Help command with help sections. *** */
122 struct cmd_help_long_result {
123 	cmdline_fixed_string_t help;
124 	cmdline_fixed_string_t section;
125 };
126 
127 static void cmd_help_long_parsed(void *parsed_result,
128                                  struct cmdline *cl,
129                                  __attribute__((unused)) void *data)
130 {
131 	int show_all = 0;
132 	struct cmd_help_long_result *res = parsed_result;
133 
134 	if (!strcmp(res->section, "all"))
135 		show_all = 1;
136 
137 	if (show_all || !strcmp(res->section, "control")) {
138 
139 		cmdline_printf(
140 			cl,
141 			"\n"
142 			"Control forwarding:\n"
143 			"-------------------\n\n"
144 
145 			"start\n"
146 			"    Start packet forwarding with current configuration.\n\n"
147 
148 			"start tx_first\n"
149 			"    Start packet forwarding with current config"
150 			" after sending one burst of packets.\n\n"
151 
152 			"stop\n"
153 			"    Stop packet forwarding, and display accumulated"
154 			" statistics.\n\n"
155 
156 			"quit\n"
157 			"    Quit to prompt.\n\n"
158 		);
159 	}
160 
161 	if (show_all || !strcmp(res->section, "display")) {
162 
163 		cmdline_printf(
164 			cl,
165 			"\n"
166 			"Display:\n"
167 			"--------\n\n"
168 
169 			"show port (info|stats|summary|xstats|fdir|stat_qmap|dcb_tc|cap) (port_id|all)\n"
170 			"    Display information for port_id, or all.\n\n"
171 
172 			"show port X rss reta (size) (mask0,mask1,...)\n"
173 			"    Display the rss redirection table entry indicated"
174 			" by masks on port X. size is used to indicate the"
175 			" hardware supported reta size\n\n"
176 
177 			"show port (port_id) rss-hash [key]\n"
178 			"    Display the RSS hash functions and RSS hash key of port\n\n"
179 
180 			"clear port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n"
181 			"    Clear information for port_id, or all.\n\n"
182 
183 			"show (rxq|txq) info (port_id) (queue_id)\n"
184 			"    Display information for configured RX/TX queue.\n\n"
185 
186 			"show config (rxtx|cores|fwd|txpkts)\n"
187 			"    Display the given configuration.\n\n"
188 
189 			"read rxd (port_id) (queue_id) (rxd_id)\n"
190 			"    Display an RX descriptor of a port RX queue.\n\n"
191 
192 			"read txd (port_id) (queue_id) (txd_id)\n"
193 			"    Display a TX descriptor of a port TX queue.\n\n"
194 
195 			"ddp get list (port_id)\n"
196 			"    Get ddp profile info list\n\n"
197 
198 			"ddp get info (profile_path)\n"
199 			"    Get ddp profile information.\n\n"
200 
201 			"show vf stats (port_id) (vf_id)\n"
202 			"    Display a VF's statistics.\n\n"
203 
204 			"clear vf stats (port_id) (vf_id)\n"
205 			"    Reset a VF's statistics.\n\n"
206 
207 			"show port (port_id) pctype mapping\n"
208 			"    Get flow ptype to pctype mapping on a port\n\n"
209 
210 			"show port meter stats (port_id) (meter_id) (clear)\n"
211 			"    Get meter stats on a port\n\n"
212                         "show port tm cap (port_id)\n"
213                         "       Display the port TM capability.\n\n"
214 
215                         "show port tm level cap (port_id) (level_id)\n"
216                         "       Display the port TM hierarchical level capability.\n\n"
217 
218                         "show port tm node cap (port_id) (node_id)\n"
219                         "       Display the port TM node capability.\n\n"
220 
221                         "show port tm node type (port_id) (node_id)\n"
222                         "       Display the port TM node type.\n\n"
223 
224                         "show port tm node stats (port_id) (node_id) (clear)\n"
225                         "       Display the port TM node stats.\n\n"
226 
227 			"show fwd stats all\n"
228 			"    Display statistics for all fwd engines.\n\n"
229 
230 			"clear fwd stats all\n"
231 			"    Clear statistics for all fwd engines.\n\n"
232 		);
233 	}
234 
235 	if (show_all || !strcmp(res->section, "config")) {
236 		cmdline_printf(
237 			cl,
238 			"\n"
239 			"Configuration:\n"
240 			"--------------\n"
241 			"Configuration changes only become active when"
242 			" forwarding is started/restarted.\n\n"
243 
244 			"set default\n"
245 			"    Reset forwarding to the default configuration.\n\n"
246 
247 			"set verbose (level)\n"
248 			"    Set the debug verbosity level X.\n\n"
249 
250 			"set log global|(type) (level)\n"
251 			"    Set the log level.\n\n"
252 
253 			"set nbport (num)\n"
254 			"    Set number of ports.\n\n"
255 
256 			"set nbcore (num)\n"
257 			"    Set number of cores.\n\n"
258 
259 			"set coremask (mask)\n"
260 			"    Set the forwarding cores hexadecimal mask.\n\n"
261 
262 			"set portmask (mask)\n"
263 			"    Set the forwarding ports hexadecimal mask.\n\n"
264 
265 			"set burst (num)\n"
266 			"    Set number of packets per burst.\n\n"
267 
268 			"set burst tx delay (microseconds) retry (num)\n"
269 			"    Set the transmit delay time and number of retries,"
270 			" effective when retry is enabled.\n\n"
271 
272 			"set txpkts (x[,y]*)\n"
273 			"    Set the length of each segment of TXONLY"
274 			" and optionally CSUM packets.\n\n"
275 
276 			"set txsplit (off|on|rand)\n"
277 			"    Set the split policy for the TX packets."
278 			" Right now only applicable for CSUM and TXONLY"
279 			" modes\n\n"
280 
281 			"set corelist (x[,y]*)\n"
282 			"    Set the list of forwarding cores.\n\n"
283 
284 			"set portlist (x[,y]*)\n"
285 			"    Set the list of forwarding ports.\n\n"
286 
287 			"set port setup on (iterator|event)\n"
288 			"    Select how attached port is retrieved for setup.\n\n"
289 
290 			"set tx loopback (port_id) (on|off)\n"
291 			"    Enable or disable tx loopback.\n\n"
292 
293 			"set all queues drop (port_id) (on|off)\n"
294 			"    Set drop enable bit for all queues.\n\n"
295 
296 			"set vf split drop (port_id) (vf_id) (on|off)\n"
297 			"    Set split drop enable bit for a VF from the PF.\n\n"
298 
299 			"set vf mac antispoof (port_id) (vf_id) (on|off).\n"
300 			"    Set MAC antispoof for a VF from the PF.\n\n"
301 
302 			"set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n"
303 			"    Enable MACsec offload.\n\n"
304 
305 			"set macsec offload (port_id) off\n"
306 			"    Disable MACsec offload.\n\n"
307 
308 			"set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
309 			"    Configure MACsec secure connection (SC).\n\n"
310 
311 			"set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n"
312 			"    Configure MACsec secure association (SA).\n\n"
313 
314 			"set vf broadcast (port_id) (vf_id) (on|off)\n"
315 			"    Set VF broadcast for a VF from the PF.\n\n"
316 
317 			"vlan set strip (on|off) (port_id)\n"
318 			"    Set the VLAN strip on a port.\n\n"
319 
320 			"vlan set stripq (on|off) (port_id,queue_id)\n"
321 			"    Set the VLAN strip for a queue on a port.\n\n"
322 
323 			"set vf vlan stripq (port_id) (vf_id) (on|off)\n"
324 			"    Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
325 
326 			"set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
327 			"    Set VLAN insert for a VF from the PF.\n\n"
328 
329 			"set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
330 			"    Set VLAN antispoof for a VF from the PF.\n\n"
331 
332 			"set vf vlan tag (port_id) (vf_id) (on|off)\n"
333 			"    Set VLAN tag for a VF from the PF.\n\n"
334 
335 			"set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n"
336 			"    Set a VF's max bandwidth(Mbps).\n\n"
337 
338 			"set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n"
339 			"    Set all TCs' min bandwidth(%%) on a VF.\n\n"
340 
341 			"set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n"
342 			"    Set a TC's max bandwidth(Mbps) on a VF.\n\n"
343 
344 			"set tx strict-link-priority (port_id) (tc_bitmap)\n"
345 			"    Set some TCs' strict link priority mode on a physical port.\n\n"
346 
347 			"set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n"
348 			"    Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n"
349 
350 			"vlan set filter (on|off) (port_id)\n"
351 			"    Set the VLAN filter on a port.\n\n"
352 
353 			"vlan set qinq (on|off) (port_id)\n"
354 			"    Set the VLAN QinQ (extended queue in queue)"
355 			" on a port.\n\n"
356 
357 			"vlan set (inner|outer) tpid (value) (port_id)\n"
358 			"    Set the VLAN TPID for Packet Filtering on"
359 			" a port\n\n"
360 
361 			"rx_vlan add (vlan_id|all) (port_id)\n"
362 			"    Add a vlan_id, or all identifiers, to the set"
363 			" of VLAN identifiers filtered by port_id.\n\n"
364 
365 			"rx_vlan rm (vlan_id|all) (port_id)\n"
366 			"    Remove a vlan_id, or all identifiers, from the set"
367 			" of VLAN identifiers filtered by port_id.\n\n"
368 
369 			"rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
370 			"    Add a vlan_id, to the set of VLAN identifiers"
371 			"filtered for VF(s) from port_id.\n\n"
372 
373 			"rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
374 			"    Remove a vlan_id, to the set of VLAN identifiers"
375 			"filtered for VF(s) from port_id.\n\n"
376 
377 			"tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) "
378 			"(inner_vlan) (vxlan|nvgre|ipingre|vxlan-gpe) (imac-ivlan|imac-ivlan-tenid|"
379 			"imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
380 			"   add a tunnel filter of a port.\n\n"
381 
382 			"tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) "
383 			"(inner_vlan) (vxlan|nvgre|ipingre|vxlan-gpe) (imac-ivlan|imac-ivlan-tenid|"
384 			"imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
385 			"   remove a tunnel filter of a port.\n\n"
386 
387 			"rx_vxlan_port add (udp_port) (port_id)\n"
388 			"    Add an UDP port for VXLAN packet filter on a port\n\n"
389 
390 			"rx_vxlan_port rm (udp_port) (port_id)\n"
391 			"    Remove an UDP port for VXLAN packet filter on a port\n\n"
392 
393 			"tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
394 			"    Set hardware insertion of VLAN IDs (single or double VLAN "
395 			"depends on the number of VLAN IDs) in packets sent on a port.\n\n"
396 
397 			"tx_vlan set pvid port_id vlan_id (on|off)\n"
398 			"    Set port based TX VLAN insertion.\n\n"
399 
400 			"tx_vlan reset (port_id)\n"
401 			"    Disable hardware insertion of a VLAN header in"
402 			" packets sent on a port.\n\n"
403 
404 			"csum set (ip|udp|tcp|sctp|outer-ip|outer-udp) (hw|sw) (port_id)\n"
405 			"    Select hardware or software calculation of the"
406 			" checksum when transmitting a packet using the"
407 			" csum forward engine.\n"
408 			"    ip|udp|tcp|sctp always concern the inner layer.\n"
409 			"    outer-ip concerns the outer IP layer in"
410 			"    outer-udp concerns the outer UDP layer in"
411 			" case the packet is recognized as a tunnel packet by"
412 			" the forward engine (vxlan, gre and ipip are supported)\n"
413 			"    Please check the NIC datasheet for HW limits.\n\n"
414 
415 			"csum parse-tunnel (on|off) (tx_port_id)\n"
416 			"    If disabled, treat tunnel packets as non-tunneled"
417 			" packets (treat inner headers as payload). The port\n"
418 			"    argument is the port used for TX in csum forward"
419 			" engine.\n\n"
420 
421 			"csum show (port_id)\n"
422 			"    Display tx checksum offload configuration\n\n"
423 
424 			"tso set (segsize) (portid)\n"
425 			"    Enable TCP Segmentation Offload in csum forward"
426 			" engine.\n"
427 			"    Please check the NIC datasheet for HW limits.\n\n"
428 
429 			"tso show (portid)"
430 			"    Display the status of TCP Segmentation Offload.\n\n"
431 
432 			"set port (port_id) gro on|off\n"
433 			"    Enable or disable Generic Receive Offload in"
434 			" csum forwarding engine.\n\n"
435 
436 			"show port (port_id) gro\n"
437 			"    Display GRO configuration.\n\n"
438 
439 			"set gro flush (cycles)\n"
440 			"    Set the cycle to flush GROed packets from"
441 			" reassembly tables.\n\n"
442 
443 			"set port (port_id) gso (on|off)"
444 			"    Enable or disable Generic Segmentation Offload in"
445 			" csum forwarding engine.\n\n"
446 
447 			"set gso segsz (length)\n"
448 			"    Set max packet length for output GSO segments,"
449 			" including packet header and payload.\n\n"
450 
451 			"show port (port_id) gso\n"
452 			"    Show GSO configuration.\n\n"
453 
454 			"set fwd (%s)\n"
455 			"    Set packet forwarding mode.\n\n"
456 
457 			"mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
458 			"    Add a MAC address on port_id.\n\n"
459 
460 			"mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
461 			"    Remove a MAC address from port_id.\n\n"
462 
463 			"mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
464 			"    Set the default MAC address for port_id.\n\n"
465 
466 			"mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
467 			"    Add a MAC address for a VF on the port.\n\n"
468 
469 			"set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
470 			"    Set the MAC address for a VF from the PF.\n\n"
471 
472 			"set eth-peer (port_id) (peer_addr)\n"
473 			"    set the peer address for certain port.\n\n"
474 
475 			"set port (port_id) uta (mac_address|all) (on|off)\n"
476 			"    Add/Remove a or all unicast hash filter(s)"
477 			"from port X.\n\n"
478 
479 			"set promisc (port_id|all) (on|off)\n"
480 			"    Set the promiscuous mode on port_id, or all.\n\n"
481 
482 			"set allmulti (port_id|all) (on|off)\n"
483 			"    Set the allmulti mode on port_id, or all.\n\n"
484 
485 			"set vf promisc (port_id) (vf_id) (on|off)\n"
486 			"    Set unicast promiscuous mode for a VF from the PF.\n\n"
487 
488 			"set vf allmulti (port_id) (vf_id) (on|off)\n"
489 			"    Set multicast promiscuous mode for a VF from the PF.\n\n"
490 
491 			"set flow_ctrl rx (on|off) tx (on|off) (high_water)"
492 			" (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
493 			" (on|off) autoneg (on|off) (port_id)\n"
494 			"set flow_ctrl rx (on|off) (portid)\n"
495 			"set flow_ctrl tx (on|off) (portid)\n"
496 			"set flow_ctrl high_water (high_water) (portid)\n"
497 			"set flow_ctrl low_water (low_water) (portid)\n"
498 			"set flow_ctrl pause_time (pause_time) (portid)\n"
499 			"set flow_ctrl send_xon (send_xon) (portid)\n"
500 			"set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
501 			"set flow_ctrl autoneg (on|off) (port_id)\n"
502 			"    Set the link flow control parameter on a port.\n\n"
503 
504 			"set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
505 			" (low_water) (pause_time) (priority) (port_id)\n"
506 			"    Set the priority flow control parameter on a"
507 			" port.\n\n"
508 
509 			"set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
510 			"    Set statistics mapping (qmapping 0..15) for RX/TX"
511 			" queue on port.\n"
512 			"    e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
513 			" on port 0 to mapping 5.\n\n"
514 
515 			"set xstats-hide-zero on|off\n"
516 			"    Set the option to hide the zero values"
517 			" for xstats display.\n"
518 
519 			"set port (port_id) vf (vf_id) rx|tx on|off\n"
520 			"    Enable/Disable a VF receive/tranmit from a port\n\n"
521 
522 			"set port (port_id) vf (vf_id) (mac_addr)"
523 			" (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
524 			"   Add/Remove unicast or multicast MAC addr filter"
525 			" for a VF.\n\n"
526 
527 			"set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
528 			"|MPE) (on|off)\n"
529 			"    AUPE:accepts untagged VLAN;"
530 			"ROPE:accept unicast hash\n\n"
531 			"    BAM:accepts broadcast packets;"
532 			"MPE:accepts all multicast packets\n\n"
533 			"    Enable/Disable a VF receive mode of a port\n\n"
534 
535 			"set port (port_id) queue (queue_id) rate (rate_num)\n"
536 			"    Set rate limit for a queue of a port\n\n"
537 
538 			"set port (port_id) vf (vf_id) rate (rate_num) "
539 			"queue_mask (queue_mask_value)\n"
540 			"    Set rate limit for queues in VF of a port\n\n"
541 
542 			"set port (port_id) mirror-rule (rule_id)"
543 			" (pool-mirror-up|pool-mirror-down|vlan-mirror)"
544 			" (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
545 			"   Set pool or vlan type mirror rule on a port.\n"
546 			"   e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
547 			" dst-pool 0 on' enable mirror traffic with vlan 0,1"
548 			" to pool 0.\n\n"
549 
550 			"set port (port_id) mirror-rule (rule_id)"
551 			" (uplink-mirror|downlink-mirror) dst-pool"
552 			" (pool_id) (on|off)\n"
553 			"   Set uplink or downlink type mirror rule on a port.\n"
554 			"   e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
555 			" 0 on' enable mirror income traffic to pool 0.\n\n"
556 
557 			"reset port (port_id) mirror-rule (rule_id)\n"
558 			"   Reset a mirror rule.\n\n"
559 
560 			"set flush_rx (on|off)\n"
561 			"   Flush (default) or don't flush RX streams before"
562 			" forwarding. Mainly used with PCAP drivers.\n\n"
563 
564 			"set bypass mode (normal|bypass|isolate) (port_id)\n"
565 			"   Set the bypass mode for the lowest port on bypass enabled"
566 			" NIC.\n\n"
567 
568 			"set bypass event (timeout|os_on|os_off|power_on|power_off) "
569 			"mode (normal|bypass|isolate) (port_id)\n"
570 			"   Set the event required to initiate specified bypass mode for"
571 			" the lowest port on a bypass enabled NIC where:\n"
572 			"       timeout   = enable bypass after watchdog timeout.\n"
573 			"       os_on     = enable bypass when OS/board is powered on.\n"
574 			"       os_off    = enable bypass when OS/board is powered off.\n"
575 			"       power_on  = enable bypass when power supply is turned on.\n"
576 			"       power_off = enable bypass when power supply is turned off."
577 			"\n\n"
578 
579 			"set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
580 			"   Set the bypass watchdog timeout to 'n' seconds"
581 			" where 0 = instant.\n\n"
582 
583 			"show bypass config (port_id)\n"
584 			"   Show the bypass configuration for a bypass enabled NIC"
585 			" using the lowest port on the NIC.\n\n"
586 
587 #ifdef RTE_LIBRTE_PMD_BOND
588 			"create bonded device (mode) (socket)\n"
589 			"	Create a new bonded device with specific bonding mode and socket.\n\n"
590 
591 			"add bonding slave (slave_id) (port_id)\n"
592 			"	Add a slave device to a bonded device.\n\n"
593 
594 			"remove bonding slave (slave_id) (port_id)\n"
595 			"	Remove a slave device from a bonded device.\n\n"
596 
597 			"set bonding mode (value) (port_id)\n"
598 			"	Set the bonding mode on a bonded device.\n\n"
599 
600 			"set bonding primary (slave_id) (port_id)\n"
601 			"	Set the primary slave for a bonded device.\n\n"
602 
603 			"show bonding config (port_id)\n"
604 			"	Show the bonding config for port_id.\n\n"
605 
606 			"set bonding mac_addr (port_id) (address)\n"
607 			"	Set the MAC address of a bonded device.\n\n"
608 
609 			"set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)"
610 			"	Set Aggregation mode for IEEE802.3AD (mode 4)"
611 
612 			"set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
613 			"	Set the transmit balance policy for bonded device running in balance mode.\n\n"
614 
615 			"set bonding mon_period (port_id) (value)\n"
616 			"	Set the bonding link status monitoring polling period in ms.\n\n"
617 
618 			"set bonding lacp dedicated_queues <port_id> (enable|disable)\n"
619 			"	Enable/disable dedicated queues for LACP control traffic.\n\n"
620 
621 #endif
622 			"set link-up port (port_id)\n"
623 			"	Set link up for a port.\n\n"
624 
625 			"set link-down port (port_id)\n"
626 			"	Set link down for a port.\n\n"
627 
628 			"E-tag set insertion on port-tag-id (value)"
629 			" port (port_id) vf (vf_id)\n"
630 			"    Enable E-tag insertion for a VF on a port\n\n"
631 
632 			"E-tag set insertion off port (port_id) vf (vf_id)\n"
633 			"    Disable E-tag insertion for a VF on a port\n\n"
634 
635 			"E-tag set stripping (on|off) port (port_id)\n"
636 			"    Enable/disable E-tag stripping on a port\n\n"
637 
638 			"E-tag set forwarding (on|off) port (port_id)\n"
639 			"    Enable/disable E-tag based forwarding"
640 			" on a port\n\n"
641 
642 			"E-tag set filter add e-tag-id (value) dst-pool"
643 			" (pool_id) port (port_id)\n"
644 			"    Add an E-tag forwarding filter on a port\n\n"
645 
646 			"E-tag set filter del e-tag-id (value) port (port_id)\n"
647 			"    Delete an E-tag forwarding filter on a port\n\n"
648 
649 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
650 			"set port tm hierarchy default (port_id)\n"
651 			"	Set default traffic Management hierarchy on a port\n\n"
652 
653 #endif
654 			"ddp add (port_id) (profile_path[,backup_profile_path])\n"
655 			"    Load a profile package on a port\n\n"
656 
657 			"ddp del (port_id) (backup_profile_path)\n"
658 			"    Delete a profile package from a port\n\n"
659 
660 			"ptype mapping get (port_id) (valid_only)\n"
661 			"    Get ptype mapping on a port\n\n"
662 
663 			"ptype mapping replace (port_id) (target) (mask) (pky_type)\n"
664 			"    Replace target with the pkt_type in ptype mapping\n\n"
665 
666 			"ptype mapping reset (port_id)\n"
667 			"    Reset ptype mapping on a port\n\n"
668 
669 			"ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n"
670 			"    Update a ptype mapping item on a port\n\n"
671 
672 			"set port (port_id) queue-region region_id (value) "
673 			"queue_start_index (value) queue_num (value)\n"
674 			"    Set a queue region on a port\n\n"
675 
676 			"set port (port_id) queue-region region_id (value) "
677 			"flowtype (value)\n"
678 			"    Set a flowtype region index on a port\n\n"
679 
680 			"set port (port_id) queue-region UP (value) region_id (value)\n"
681 			"    Set the mapping of User Priority to "
682 			"queue region on a port\n\n"
683 
684 			"set port (port_id) queue-region flush (on|off)\n"
685 			"    flush all queue region related configuration\n\n"
686 
687 			"show port meter cap (port_id)\n"
688 			"    Show port meter capability information\n\n"
689 
690 			"add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs)\n"
691 			"    meter profile add - srtcm rfc 2697\n\n"
692 
693 			"add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs)\n"
694 			"    meter profile add - trtcm rfc 2698\n\n"
695 
696 			"add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs)\n"
697 			"    meter profile add - trtcm rfc 4115\n\n"
698 
699 			"del port meter profile (port_id) (profile_id)\n"
700 			"    meter profile delete\n\n"
701 
702 			"create port meter (port_id) (mtr_id) (profile_id) (meter_enable)\n"
703 			"(g_action) (y_action) (r_action) (stats_mask) (shared)\n"
704 			"(use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n"
705 			"(dscp_tbl_entry63)]\n"
706 			"    meter create\n\n"
707 
708 			"enable port meter (port_id) (mtr_id)\n"
709 			"    meter enable\n\n"
710 
711 			"disable port meter (port_id) (mtr_id)\n"
712 			"    meter disable\n\n"
713 
714 			"del port meter (port_id) (mtr_id)\n"
715 			"    meter delete\n\n"
716 
717 			"set port meter profile (port_id) (mtr_id) (profile_id)\n"
718 			"    meter update meter profile\n\n"
719 
720 			"set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n"
721 			"(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n"
722 			"    update meter dscp table entries\n\n"
723 
724 			"set port meter policer action (port_id) (mtr_id) (action_mask)\n"
725 			"(action0) [(action1) (action2)]\n"
726 			"    meter update policer action\n\n"
727 
728 			"set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
729 			"    meter update stats\n\n"
730 
731 			"show port (port_id) queue-region\n"
732 			"    show all queue region related configuration info\n\n"
733 
734 			"add port tm node shaper profile (port_id) (shaper_profile_id)"
735 			" (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)"
736 			" (packet_length_adjust)\n"
737 			"	Add port tm node private shaper profile.\n\n"
738 
739 			"del port tm node shaper profile (port_id) (shaper_profile_id)\n"
740 			"	Delete port tm node private shaper profile.\n\n"
741 
742 			"add port tm node shared shaper (port_id) (shared_shaper_id)"
743 			" (shaper_profile_id)\n"
744 			"	Add/update port tm node shared shaper.\n\n"
745 
746 			"del port tm node shared shaper (port_id) (shared_shaper_id)\n"
747 			"	Delete port tm node shared shaper.\n\n"
748 
749 			"set port tm node shaper profile (port_id) (node_id)"
750 			" (shaper_profile_id)\n"
751 			"	Set port tm node shaper profile.\n\n"
752 
753 			"add port tm node wred profile (port_id) (wred_profile_id)"
754 			" (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
755 			" (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
756 			" (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
757 			"	Add port tm node wred profile.\n\n"
758 
759 			"del port tm node wred profile (port_id) (wred_profile_id)\n"
760 			"	Delete port tm node wred profile.\n\n"
761 
762 			"add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
763 			" (priority) (weight) (level_id) (shaper_profile_id)"
764 			" (n_sp_priorities) (stats_mask) (n_shared_shapers)"
765 			" [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
766 			"	Add port tm nonleaf node.\n\n"
767 
768 			"add port tm leaf node (port_id) (node_id) (parent_node_id)"
769 			" (priority) (weight) (level_id) (shaper_profile_id)"
770 			" (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
771 			" [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
772 			"	Add port tm leaf node.\n\n"
773 
774 			"del port tm node (port_id) (node_id)\n"
775 			"	Delete port tm node.\n\n"
776 
777 			"set port tm node parent (port_id) (node_id) (parent_node_id)"
778 			" (priority) (weight)\n"
779 			"	Set port tm node parent.\n\n"
780 
781 			"suspend port tm node (port_id) (node_id)"
782 			"       Suspend tm node.\n\n"
783 
784 			"resume port tm node (port_id) (node_id)"
785 			"       Resume tm node.\n\n"
786 
787 			"port tm hierarchy commit (port_id) (clean_on_fail)\n"
788 			"	Commit tm hierarchy.\n\n"
789 
790 			"vxlan ip-version (ipv4|ipv6) vni (vni) udp-src"
791 			" (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst"
792 			" (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n"
793 			"       Configure the VXLAN encapsulation for flows.\n\n"
794 
795 			"vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)"
796 			" udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)"
797 			" ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)"
798 			" eth-dst (eth-dst)\n"
799 			"       Configure the VXLAN encapsulation for flows.\n\n"
800 
801 			"vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src"
802 			" (udp-src) udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl)"
803 			" ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src)"
804 			" eth-dst (eth-dst)\n"
805 			"       Configure the VXLAN encapsulation for flows.\n\n"
806 
807 			"nvgre ip-version (ipv4|ipv6) tni (tni) ip-src"
808 			" (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst"
809 			" (eth-dst)\n"
810 			"       Configure the NVGRE encapsulation for flows.\n\n"
811 
812 			"nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)"
813 			" ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)"
814 			" eth-src (eth-src) eth-dst (eth-dst)\n"
815 			"       Configure the NVGRE encapsulation for flows.\n\n"
816 
817 			, list_pkt_forwarding_modes()
818 		);
819 	}
820 
821 	if (show_all || !strcmp(res->section, "ports")) {
822 
823 		cmdline_printf(
824 			cl,
825 			"\n"
826 			"Port Operations:\n"
827 			"----------------\n\n"
828 
829 			"port start (port_id|all)\n"
830 			"    Start all ports or port_id.\n\n"
831 
832 			"port stop (port_id|all)\n"
833 			"    Stop all ports or port_id.\n\n"
834 
835 			"port close (port_id|all)\n"
836 			"    Close all ports or port_id.\n\n"
837 
838 			"port attach (ident)\n"
839 			"    Attach physical or virtual dev by pci address or virtual device name\n\n"
840 
841 			"port detach (port_id)\n"
842 			"    Detach physical or virtual dev by port_id\n\n"
843 
844 			"port config (port_id|all)"
845 			" speed (10|100|1000|10000|25000|40000|50000|100000|auto)"
846 			" duplex (half|full|auto)\n"
847 			"    Set speed and duplex for all ports or port_id\n\n"
848 
849 			"port config (port_id|all) loopback (mode)\n"
850 			"    Set loopback mode for all ports or port_id\n\n"
851 
852 			"port config all (rxq|txq|rxd|txd) (value)\n"
853 			"    Set number for rxq/txq/rxd/txd.\n\n"
854 
855 			"port config all max-pkt-len (value)\n"
856 			"    Set the max packet length.\n\n"
857 
858 			"port config all (crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|hw-vlan-filter|"
859 			"hw-vlan-strip|hw-vlan-extend|drop-en)"
860 			" (on|off)\n"
861 			"    Set crc-strip/scatter/rx-checksum/hardware-vlan/drop_en"
862 			" for ports.\n\n"
863 
864 			"port config all rss (all|default|ip|tcp|udp|sctp|"
865 			"ether|port|vxlan|geneve|nvgre|vxlan-gpe|none|<flowtype_id>)\n"
866 			"    Set the RSS mode.\n\n"
867 
868 			"port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
869 			"    Set the RSS redirection table.\n\n"
870 
871 			"port config (port_id) dcb vt (on|off) (traffic_class)"
872 			" pfc (on|off)\n"
873 			"    Set the DCB mode.\n\n"
874 
875 			"port config all burst (value)\n"
876 			"    Set the number of packets per burst.\n\n"
877 
878 			"port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
879 			" (value)\n"
880 			"    Set the ring prefetch/host/writeback threshold"
881 			" for tx/rx queue.\n\n"
882 
883 			"port config all (txfreet|txrst|rxfreet) (value)\n"
884 			"    Set free threshold for rx/tx, or set"
885 			" tx rs bit threshold.\n\n"
886 			"port config mtu X value\n"
887 			"    Set the MTU of port X to a given value\n\n"
888 
889 			"port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n"
890 			"    Set a rx/tx queue's ring size configuration, the new"
891 			" value will take effect after command that (re-)start the port"
892 			" or command that setup the specific queue\n\n"
893 
894 			"port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
895 			"    Start/stop a rx/tx queue of port X. Only take effect"
896 			" when port X is started\n\n"
897 
898 			"port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n"
899 			"    Switch on/off a deferred start of port X rx/tx queue. Only"
900 			" take effect when port X is stopped.\n\n"
901 
902 			"port (port_id) (rxq|txq) (queue_id) setup\n"
903 			"    Setup a rx/tx queue of port X.\n\n"
904 
905 			"port config (port_id|all) l2-tunnel E-tag ether-type"
906 			" (value)\n"
907 			"    Set the value of E-tag ether-type.\n\n"
908 
909 			"port config (port_id|all) l2-tunnel E-tag"
910 			" (enable|disable)\n"
911 			"    Enable/disable the E-tag support.\n\n"
912 
913 			"port config (port_id) pctype mapping reset\n"
914 			"    Reset flow type to pctype mapping on a port\n\n"
915 
916 			"port config (port_id) pctype mapping update"
917 			" (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
918 			"    Update a flow type to pctype mapping item on a port\n\n"
919 
920 			"port config (port_id) pctype (pctype_id) hash_inset|"
921 			"fdir_inset|fdir_flx_inset get|set|clear field\n"
922 			" (field_idx)\n"
923 			"    Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n"
924 
925 			"port config (port_id) pctype (pctype_id) hash_inset|"
926 			"fdir_inset|fdir_flx_inset clear all"
927 			"    Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n"
928 
929 			"port config (port_id) udp_tunnel_port add|rm vxlan|geneve (udp_port)\n\n"
930 			"    Add/remove UDP tunnel port for tunneling offload\n\n"
931 		);
932 	}
933 
934 	if (show_all || !strcmp(res->section, "registers")) {
935 
936 		cmdline_printf(
937 			cl,
938 			"\n"
939 			"Registers:\n"
940 			"----------\n\n"
941 
942 			"read reg (port_id) (address)\n"
943 			"    Display value of a port register.\n\n"
944 
945 			"read regfield (port_id) (address) (bit_x) (bit_y)\n"
946 			"    Display a port register bit field.\n\n"
947 
948 			"read regbit (port_id) (address) (bit_x)\n"
949 			"    Display a single port register bit.\n\n"
950 
951 			"write reg (port_id) (address) (value)\n"
952 			"    Set value of a port register.\n\n"
953 
954 			"write regfield (port_id) (address) (bit_x) (bit_y)"
955 			" (value)\n"
956 			"    Set bit field of a port register.\n\n"
957 
958 			"write regbit (port_id) (address) (bit_x) (value)\n"
959 			"    Set single bit value of a port register.\n\n"
960 		);
961 	}
962 	if (show_all || !strcmp(res->section, "filters")) {
963 
964 		cmdline_printf(
965 			cl,
966 			"\n"
967 			"filters:\n"
968 			"--------\n\n"
969 
970 			"ethertype_filter (port_id) (add|del)"
971 			" (mac_addr|mac_ignr) (mac_address) ethertype"
972 			" (ether_type) (drop|fwd) queue (queue_id)\n"
973 			"    Add/Del an ethertype filter.\n\n"
974 
975 			"2tuple_filter (port_id) (add|del)"
976 			" dst_port (dst_port_value) protocol (protocol_value)"
977 			" mask (mask_value) tcp_flags (tcp_flags_value)"
978 			" priority (prio_value) queue (queue_id)\n"
979 			"    Add/Del a 2tuple filter.\n\n"
980 
981 			"5tuple_filter (port_id) (add|del)"
982 			" dst_ip (dst_address) src_ip (src_address)"
983 			" dst_port (dst_port_value) src_port (src_port_value)"
984 			" protocol (protocol_value)"
985 			" mask (mask_value) tcp_flags (tcp_flags_value)"
986 			" priority (prio_value) queue (queue_id)\n"
987 			"    Add/Del a 5tuple filter.\n\n"
988 
989 			"syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
990 			"    Add/Del syn filter.\n\n"
991 
992 			"flex_filter (port_id) (add|del) len (len_value)"
993 			" bytes (bytes_value) mask (mask_value)"
994 			" priority (prio_value) queue (queue_id)\n"
995 			"    Add/Del a flex filter.\n\n"
996 
997 			"flow_director_filter (port_id) mode IP (add|del|update)"
998 			" flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
999 			" src (src_ip_address) dst (dst_ip_address)"
1000 			" tos (tos_value) proto (proto_value) ttl (ttl_value)"
1001 			" vlan (vlan_value) flexbytes (flexbytes_value)"
1002 			" (drop|fwd) pf|vf(vf_id) queue (queue_id)"
1003 			" fd_id (fd_id_value)\n"
1004 			"    Add/Del an IP type flow director filter.\n\n"
1005 
1006 			"flow_director_filter (port_id) mode IP (add|del|update)"
1007 			" flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
1008 			" src (src_ip_address) (src_port)"
1009 			" dst (dst_ip_address) (dst_port)"
1010 			" tos (tos_value) ttl (ttl_value)"
1011 			" vlan (vlan_value) flexbytes (flexbytes_value)"
1012 			" (drop|fwd) pf|vf(vf_id) queue (queue_id)"
1013 			" fd_id (fd_id_value)\n"
1014 			"    Add/Del an UDP/TCP type flow director filter.\n\n"
1015 
1016 			"flow_director_filter (port_id) mode IP (add|del|update)"
1017 			" flow (ipv4-sctp|ipv6-sctp)"
1018 			" src (src_ip_address) (src_port)"
1019 			" dst (dst_ip_address) (dst_port)"
1020 			" tag (verification_tag) "
1021 			" tos (tos_value) ttl (ttl_value)"
1022 			" vlan (vlan_value)"
1023 			" flexbytes (flexbytes_value) (drop|fwd)"
1024 			" pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
1025 			"    Add/Del a SCTP type flow director filter.\n\n"
1026 
1027 			"flow_director_filter (port_id) mode IP (add|del|update)"
1028 			" flow l2_payload ether (ethertype)"
1029 			" flexbytes (flexbytes_value) (drop|fwd)"
1030 			" pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
1031 			"    Add/Del a l2 payload type flow director filter.\n\n"
1032 
1033 			"flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
1034 			" mac (mac_address) vlan (vlan_value)"
1035 			" flexbytes (flexbytes_value) (drop|fwd)"
1036 			" queue (queue_id) fd_id (fd_id_value)\n"
1037 			"    Add/Del a MAC-VLAN flow director filter.\n\n"
1038 
1039 			"flow_director_filter (port_id) mode Tunnel (add|del|update)"
1040 			" mac (mac_address) vlan (vlan_value)"
1041 			" tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
1042 			" flexbytes (flexbytes_value) (drop|fwd)"
1043 			" queue (queue_id) fd_id (fd_id_value)\n"
1044 			"    Add/Del a Tunnel flow director filter.\n\n"
1045 
1046 			"flow_director_filter (port_id) mode raw (add|del|update)"
1047 			" flow (flow_id) (drop|fwd) queue (queue_id)"
1048 			" fd_id (fd_id_value) packet (packet file name)\n"
1049 			"    Add/Del a raw type flow director filter.\n\n"
1050 
1051 			"flush_flow_director (port_id)\n"
1052 			"    Flush all flow director entries of a device.\n\n"
1053 
1054 			"flow_director_mask (port_id) mode IP vlan (vlan_value)"
1055 			" src_mask (ipv4_src) (ipv6_src) (src_port)"
1056 			" dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
1057 			"    Set flow director IP mask.\n\n"
1058 
1059 			"flow_director_mask (port_id) mode MAC-VLAN"
1060 			" vlan (vlan_value)\n"
1061 			"    Set flow director MAC-VLAN mask.\n\n"
1062 
1063 			"flow_director_mask (port_id) mode Tunnel"
1064 			" vlan (vlan_value) mac (mac_value)"
1065 			" tunnel-type (tunnel_type_value)"
1066 			" tunnel-id (tunnel_id_value)\n"
1067 			"    Set flow director Tunnel mask.\n\n"
1068 
1069 			"flow_director_flex_mask (port_id)"
1070 			" flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
1071 			"ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
1072 			" (mask)\n"
1073 			"    Configure mask of flex payload.\n\n"
1074 
1075 			"flow_director_flex_payload (port_id)"
1076 			" (raw|l2|l3|l4) (config)\n"
1077 			"    Configure flex payload selection.\n\n"
1078 
1079 			"get_sym_hash_ena_per_port (port_id)\n"
1080 			"    get symmetric hash enable configuration per port.\n\n"
1081 
1082 			"set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
1083 			"    set symmetric hash enable configuration per port"
1084 			" to enable or disable.\n\n"
1085 
1086 			"get_hash_global_config (port_id)\n"
1087 			"    Get the global configurations of hash filters.\n\n"
1088 
1089 			"set_hash_global_config (port_id) (toeplitz|simple_xor|default)"
1090 			" (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1091 			"ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
1092 			" (enable|disable)\n"
1093 			"    Set the global configurations of hash filters.\n\n"
1094 
1095 			"set_hash_input_set (port_id) (ipv4|ipv4-frag|"
1096 			"ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1097 			"ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1098 			"l2_payload|<flowtype_id>) (ovlan|ivlan|src-ipv4|dst-ipv4|"
1099 			"src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
1100 			"ipv6-next-header|udp-src-port|udp-dst-port|"
1101 			"tcp-src-port|tcp-dst-port|sctp-src-port|"
1102 			"sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
1103 			"fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
1104 			"fld-8th|none) (select|add)\n"
1105 			"    Set the input set for hash.\n\n"
1106 
1107 			"set_fdir_input_set (port_id) "
1108 			"(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1109 			"ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1110 			"l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
1111 			"dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
1112 			"ipv6-next-header|ipv6-hop-limits|udp-src-port|"
1113 			"udp-dst-port|tcp-src-port|tcp-dst-port|"
1114 			"sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
1115 			" (select|add)\n"
1116 			"    Set the input set for FDir.\n\n"
1117 
1118 			"flow validate {port_id}"
1119 			" [group {group_id}] [priority {level}]"
1120 			" [ingress] [egress]"
1121 			" pattern {item} [/ {item} [...]] / end"
1122 			" actions {action} [/ {action} [...]] / end\n"
1123 			"    Check whether a flow rule can be created.\n\n"
1124 
1125 			"flow create {port_id}"
1126 			" [group {group_id}] [priority {level}]"
1127 			" [ingress] [egress]"
1128 			" pattern {item} [/ {item} [...]] / end"
1129 			" actions {action} [/ {action} [...]] / end\n"
1130 			"    Create a flow rule.\n\n"
1131 
1132 			"flow destroy {port_id} rule {rule_id} [...]\n"
1133 			"    Destroy specific flow rules.\n\n"
1134 
1135 			"flow flush {port_id}\n"
1136 			"    Destroy all flow rules.\n\n"
1137 
1138 			"flow query {port_id} {rule_id} {action}\n"
1139 			"    Query an existing flow rule.\n\n"
1140 
1141 			"flow list {port_id} [group {group_id}] [...]\n"
1142 			"    List existing flow rules sorted by priority,"
1143 			" filtered by group identifiers.\n\n"
1144 
1145 			"flow isolate {port_id} {boolean}\n"
1146 			"    Restrict ingress traffic to the defined"
1147 			" flow rules\n\n"
1148 		);
1149 	}
1150 }
1151 
1152 cmdline_parse_token_string_t cmd_help_long_help =
1153 	TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1154 
1155 cmdline_parse_token_string_t cmd_help_long_section =
1156 	TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1157 			"all#control#display#config#"
1158 			"ports#registers#filters");
1159 
1160 cmdline_parse_inst_t cmd_help_long = {
1161 	.f = cmd_help_long_parsed,
1162 	.data = NULL,
1163 	.help_str = "help all|control|display|config|ports|register|filters: "
1164 		"Show help",
1165 	.tokens = {
1166 		(void *)&cmd_help_long_help,
1167 		(void *)&cmd_help_long_section,
1168 		NULL,
1169 	},
1170 };
1171 
1172 
1173 /* *** start/stop/close all ports *** */
1174 struct cmd_operate_port_result {
1175 	cmdline_fixed_string_t keyword;
1176 	cmdline_fixed_string_t name;
1177 	cmdline_fixed_string_t value;
1178 };
1179 
1180 static void cmd_operate_port_parsed(void *parsed_result,
1181 				__attribute__((unused)) struct cmdline *cl,
1182 				__attribute__((unused)) void *data)
1183 {
1184 	struct cmd_operate_port_result *res = parsed_result;
1185 
1186 	if (!strcmp(res->name, "start"))
1187 		start_port(RTE_PORT_ALL);
1188 	else if (!strcmp(res->name, "stop"))
1189 		stop_port(RTE_PORT_ALL);
1190 	else if (!strcmp(res->name, "close"))
1191 		close_port(RTE_PORT_ALL);
1192 	else if (!strcmp(res->name, "reset"))
1193 		reset_port(RTE_PORT_ALL);
1194 	else
1195 		printf("Unknown parameter\n");
1196 }
1197 
1198 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1199 	TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1200 								"port");
1201 cmdline_parse_token_string_t cmd_operate_port_all_port =
1202 	TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1203 						"start#stop#close#reset");
1204 cmdline_parse_token_string_t cmd_operate_port_all_all =
1205 	TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1206 
1207 cmdline_parse_inst_t cmd_operate_port = {
1208 	.f = cmd_operate_port_parsed,
1209 	.data = NULL,
1210 	.help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports",
1211 	.tokens = {
1212 		(void *)&cmd_operate_port_all_cmd,
1213 		(void *)&cmd_operate_port_all_port,
1214 		(void *)&cmd_operate_port_all_all,
1215 		NULL,
1216 	},
1217 };
1218 
1219 /* *** start/stop/close specific port *** */
1220 struct cmd_operate_specific_port_result {
1221 	cmdline_fixed_string_t keyword;
1222 	cmdline_fixed_string_t name;
1223 	uint8_t value;
1224 };
1225 
1226 static void cmd_operate_specific_port_parsed(void *parsed_result,
1227 			__attribute__((unused)) struct cmdline *cl,
1228 				__attribute__((unused)) void *data)
1229 {
1230 	struct cmd_operate_specific_port_result *res = parsed_result;
1231 
1232 	if (!strcmp(res->name, "start"))
1233 		start_port(res->value);
1234 	else if (!strcmp(res->name, "stop"))
1235 		stop_port(res->value);
1236 	else if (!strcmp(res->name, "close"))
1237 		close_port(res->value);
1238 	else if (!strcmp(res->name, "reset"))
1239 		reset_port(res->value);
1240 	else
1241 		printf("Unknown parameter\n");
1242 }
1243 
1244 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1245 	TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1246 							keyword, "port");
1247 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1248 	TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1249 						name, "start#stop#close#reset");
1250 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1251 	TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1252 							value, UINT8);
1253 
1254 cmdline_parse_inst_t cmd_operate_specific_port = {
1255 	.f = cmd_operate_specific_port_parsed,
1256 	.data = NULL,
1257 	.help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id",
1258 	.tokens = {
1259 		(void *)&cmd_operate_specific_port_cmd,
1260 		(void *)&cmd_operate_specific_port_port,
1261 		(void *)&cmd_operate_specific_port_id,
1262 		NULL,
1263 	},
1264 };
1265 
1266 /* *** enable port setup (after attach) via iterator or event *** */
1267 struct cmd_set_port_setup_on_result {
1268 	cmdline_fixed_string_t set;
1269 	cmdline_fixed_string_t port;
1270 	cmdline_fixed_string_t setup;
1271 	cmdline_fixed_string_t on;
1272 	cmdline_fixed_string_t mode;
1273 };
1274 
1275 static void cmd_set_port_setup_on_parsed(void *parsed_result,
1276 				__attribute__((unused)) struct cmdline *cl,
1277 				__attribute__((unused)) void *data)
1278 {
1279 	struct cmd_set_port_setup_on_result *res = parsed_result;
1280 
1281 	if (strcmp(res->mode, "event") == 0)
1282 		setup_on_probe_event = true;
1283 	else if (strcmp(res->mode, "iterator") == 0)
1284 		setup_on_probe_event = false;
1285 	else
1286 		printf("Unknown mode\n");
1287 }
1288 
1289 cmdline_parse_token_string_t cmd_set_port_setup_on_set =
1290 	TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1291 			set, "set");
1292 cmdline_parse_token_string_t cmd_set_port_setup_on_port =
1293 	TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1294 			port, "port");
1295 cmdline_parse_token_string_t cmd_set_port_setup_on_setup =
1296 	TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1297 			setup, "setup");
1298 cmdline_parse_token_string_t cmd_set_port_setup_on_on =
1299 	TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1300 			on, "on");
1301 cmdline_parse_token_string_t cmd_set_port_setup_on_mode =
1302 	TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1303 			mode, "iterator#event");
1304 
1305 cmdline_parse_inst_t cmd_set_port_setup_on = {
1306 	.f = cmd_set_port_setup_on_parsed,
1307 	.data = NULL,
1308 	.help_str = "set port setup on iterator|event",
1309 	.tokens = {
1310 		(void *)&cmd_set_port_setup_on_set,
1311 		(void *)&cmd_set_port_setup_on_port,
1312 		(void *)&cmd_set_port_setup_on_setup,
1313 		(void *)&cmd_set_port_setup_on_on,
1314 		(void *)&cmd_set_port_setup_on_mode,
1315 		NULL,
1316 	},
1317 };
1318 
1319 /* *** attach a specified port *** */
1320 struct cmd_operate_attach_port_result {
1321 	cmdline_fixed_string_t port;
1322 	cmdline_fixed_string_t keyword;
1323 	cmdline_fixed_string_t identifier;
1324 };
1325 
1326 static void cmd_operate_attach_port_parsed(void *parsed_result,
1327 				__attribute__((unused)) struct cmdline *cl,
1328 				__attribute__((unused)) void *data)
1329 {
1330 	struct cmd_operate_attach_port_result *res = parsed_result;
1331 
1332 	if (!strcmp(res->keyword, "attach"))
1333 		attach_port(res->identifier);
1334 	else
1335 		printf("Unknown parameter\n");
1336 }
1337 
1338 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1339 	TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1340 			port, "port");
1341 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1342 	TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1343 			keyword, "attach");
1344 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1345 	TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1346 			identifier, NULL);
1347 
1348 cmdline_parse_inst_t cmd_operate_attach_port = {
1349 	.f = cmd_operate_attach_port_parsed,
1350 	.data = NULL,
1351 	.help_str = "port attach <identifier>: "
1352 		"(identifier: pci address or virtual dev name)",
1353 	.tokens = {
1354 		(void *)&cmd_operate_attach_port_port,
1355 		(void *)&cmd_operate_attach_port_keyword,
1356 		(void *)&cmd_operate_attach_port_identifier,
1357 		NULL,
1358 	},
1359 };
1360 
1361 /* *** detach a specified port *** */
1362 struct cmd_operate_detach_port_result {
1363 	cmdline_fixed_string_t port;
1364 	cmdline_fixed_string_t keyword;
1365 	portid_t port_id;
1366 };
1367 
1368 static void cmd_operate_detach_port_parsed(void *parsed_result,
1369 				__attribute__((unused)) struct cmdline *cl,
1370 				__attribute__((unused)) void *data)
1371 {
1372 	struct cmd_operate_detach_port_result *res = parsed_result;
1373 
1374 	if (!strcmp(res->keyword, "detach"))
1375 		detach_port_device(res->port_id);
1376 	else
1377 		printf("Unknown parameter\n");
1378 }
1379 
1380 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1381 	TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1382 			port, "port");
1383 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1384 	TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1385 			keyword, "detach");
1386 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1387 	TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1388 			port_id, UINT16);
1389 
1390 cmdline_parse_inst_t cmd_operate_detach_port = {
1391 	.f = cmd_operate_detach_port_parsed,
1392 	.data = NULL,
1393 	.help_str = "port detach <port_id>",
1394 	.tokens = {
1395 		(void *)&cmd_operate_detach_port_port,
1396 		(void *)&cmd_operate_detach_port_keyword,
1397 		(void *)&cmd_operate_detach_port_port_id,
1398 		NULL,
1399 	},
1400 };
1401 
1402 /* *** configure speed for all ports *** */
1403 struct cmd_config_speed_all {
1404 	cmdline_fixed_string_t port;
1405 	cmdline_fixed_string_t keyword;
1406 	cmdline_fixed_string_t all;
1407 	cmdline_fixed_string_t item1;
1408 	cmdline_fixed_string_t item2;
1409 	cmdline_fixed_string_t value1;
1410 	cmdline_fixed_string_t value2;
1411 };
1412 
1413 static int
1414 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1415 {
1416 
1417 	int duplex;
1418 
1419 	if (!strcmp(duplexstr, "half")) {
1420 		duplex = ETH_LINK_HALF_DUPLEX;
1421 	} else if (!strcmp(duplexstr, "full")) {
1422 		duplex = ETH_LINK_FULL_DUPLEX;
1423 	} else if (!strcmp(duplexstr, "auto")) {
1424 		duplex = ETH_LINK_FULL_DUPLEX;
1425 	} else {
1426 		printf("Unknown duplex parameter\n");
1427 		return -1;
1428 	}
1429 
1430 	if (!strcmp(speedstr, "10")) {
1431 		*speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1432 				ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1433 	} else if (!strcmp(speedstr, "100")) {
1434 		*speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1435 				ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1436 	} else {
1437 		if (duplex != ETH_LINK_FULL_DUPLEX) {
1438 			printf("Invalid speed/duplex parameters\n");
1439 			return -1;
1440 		}
1441 		if (!strcmp(speedstr, "1000")) {
1442 			*speed = ETH_LINK_SPEED_1G | ETH_LINK_SPEED_FIXED;
1443 		} else if (!strcmp(speedstr, "10000")) {
1444 			*speed = ETH_LINK_SPEED_10G | ETH_LINK_SPEED_FIXED;
1445 		} else if (!strcmp(speedstr, "25000")) {
1446 			*speed = ETH_LINK_SPEED_25G | ETH_LINK_SPEED_FIXED;
1447 		} else if (!strcmp(speedstr, "40000")) {
1448 			*speed = ETH_LINK_SPEED_40G | ETH_LINK_SPEED_FIXED;
1449 		} else if (!strcmp(speedstr, "50000")) {
1450 			*speed = ETH_LINK_SPEED_50G | ETH_LINK_SPEED_FIXED;
1451 		} else if (!strcmp(speedstr, "100000")) {
1452 			*speed = ETH_LINK_SPEED_100G | ETH_LINK_SPEED_FIXED;
1453 		} else if (!strcmp(speedstr, "auto")) {
1454 			*speed = ETH_LINK_SPEED_AUTONEG;
1455 		} else {
1456 			printf("Unknown speed parameter\n");
1457 			return -1;
1458 		}
1459 	}
1460 
1461 	return 0;
1462 }
1463 
1464 static void
1465 cmd_config_speed_all_parsed(void *parsed_result,
1466 			__attribute__((unused)) struct cmdline *cl,
1467 			__attribute__((unused)) void *data)
1468 {
1469 	struct cmd_config_speed_all *res = parsed_result;
1470 	uint32_t link_speed;
1471 	portid_t pid;
1472 
1473 	if (!all_ports_stopped()) {
1474 		printf("Please stop all ports first\n");
1475 		return;
1476 	}
1477 
1478 	if (parse_and_check_speed_duplex(res->value1, res->value2,
1479 			&link_speed) < 0)
1480 		return;
1481 
1482 	RTE_ETH_FOREACH_DEV(pid) {
1483 		ports[pid].dev_conf.link_speeds = link_speed;
1484 	}
1485 
1486 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1487 }
1488 
1489 cmdline_parse_token_string_t cmd_config_speed_all_port =
1490 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1491 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1492 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1493 							"config");
1494 cmdline_parse_token_string_t cmd_config_speed_all_all =
1495 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1496 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1497 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1498 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1499 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1500 				"10#100#1000#10000#25000#40000#50000#100000#auto");
1501 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1502 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1503 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1504 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1505 						"half#full#auto");
1506 
1507 cmdline_parse_inst_t cmd_config_speed_all = {
1508 	.f = cmd_config_speed_all_parsed,
1509 	.data = NULL,
1510 	.help_str = "port config all speed "
1511 		"10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1512 							"half|full|auto",
1513 	.tokens = {
1514 		(void *)&cmd_config_speed_all_port,
1515 		(void *)&cmd_config_speed_all_keyword,
1516 		(void *)&cmd_config_speed_all_all,
1517 		(void *)&cmd_config_speed_all_item1,
1518 		(void *)&cmd_config_speed_all_value1,
1519 		(void *)&cmd_config_speed_all_item2,
1520 		(void *)&cmd_config_speed_all_value2,
1521 		NULL,
1522 	},
1523 };
1524 
1525 /* *** configure speed for specific port *** */
1526 struct cmd_config_speed_specific {
1527 	cmdline_fixed_string_t port;
1528 	cmdline_fixed_string_t keyword;
1529 	portid_t id;
1530 	cmdline_fixed_string_t item1;
1531 	cmdline_fixed_string_t item2;
1532 	cmdline_fixed_string_t value1;
1533 	cmdline_fixed_string_t value2;
1534 };
1535 
1536 static void
1537 cmd_config_speed_specific_parsed(void *parsed_result,
1538 				__attribute__((unused)) struct cmdline *cl,
1539 				__attribute__((unused)) void *data)
1540 {
1541 	struct cmd_config_speed_specific *res = parsed_result;
1542 	uint32_t link_speed;
1543 
1544 	if (!all_ports_stopped()) {
1545 		printf("Please stop all ports first\n");
1546 		return;
1547 	}
1548 
1549 	if (port_id_is_invalid(res->id, ENABLED_WARN))
1550 		return;
1551 
1552 	if (parse_and_check_speed_duplex(res->value1, res->value2,
1553 			&link_speed) < 0)
1554 		return;
1555 
1556 	ports[res->id].dev_conf.link_speeds = link_speed;
1557 
1558 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1559 }
1560 
1561 
1562 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1563 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1564 								"port");
1565 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1566 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1567 								"config");
1568 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1569 	TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT16);
1570 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1571 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1572 								"speed");
1573 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1574 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1575 				"10#100#1000#10000#25000#40000#50000#100000#auto");
1576 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1577 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1578 								"duplex");
1579 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1580 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1581 							"half#full#auto");
1582 
1583 cmdline_parse_inst_t cmd_config_speed_specific = {
1584 	.f = cmd_config_speed_specific_parsed,
1585 	.data = NULL,
1586 	.help_str = "port config <port_id> speed "
1587 		"10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1588 							"half|full|auto",
1589 	.tokens = {
1590 		(void *)&cmd_config_speed_specific_port,
1591 		(void *)&cmd_config_speed_specific_keyword,
1592 		(void *)&cmd_config_speed_specific_id,
1593 		(void *)&cmd_config_speed_specific_item1,
1594 		(void *)&cmd_config_speed_specific_value1,
1595 		(void *)&cmd_config_speed_specific_item2,
1596 		(void *)&cmd_config_speed_specific_value2,
1597 		NULL,
1598 	},
1599 };
1600 
1601 /* *** configure loopback for all ports *** */
1602 struct cmd_config_loopback_all {
1603 	cmdline_fixed_string_t port;
1604 	cmdline_fixed_string_t keyword;
1605 	cmdline_fixed_string_t all;
1606 	cmdline_fixed_string_t item;
1607 	uint32_t mode;
1608 };
1609 
1610 static void
1611 cmd_config_loopback_all_parsed(void *parsed_result,
1612 			__attribute__((unused)) struct cmdline *cl,
1613 			__attribute__((unused)) void *data)
1614 {
1615 	struct cmd_config_loopback_all *res = parsed_result;
1616 	portid_t pid;
1617 
1618 	if (!all_ports_stopped()) {
1619 		printf("Please stop all ports first\n");
1620 		return;
1621 	}
1622 
1623 	RTE_ETH_FOREACH_DEV(pid) {
1624 		ports[pid].dev_conf.lpbk_mode = res->mode;
1625 	}
1626 
1627 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1628 }
1629 
1630 cmdline_parse_token_string_t cmd_config_loopback_all_port =
1631 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1632 cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1633 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1634 							"config");
1635 cmdline_parse_token_string_t cmd_config_loopback_all_all =
1636 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1637 cmdline_parse_token_string_t cmd_config_loopback_all_item =
1638 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1639 							"loopback");
1640 cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1641 	TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, UINT32);
1642 
1643 cmdline_parse_inst_t cmd_config_loopback_all = {
1644 	.f = cmd_config_loopback_all_parsed,
1645 	.data = NULL,
1646 	.help_str = "port config all loopback <mode>",
1647 	.tokens = {
1648 		(void *)&cmd_config_loopback_all_port,
1649 		(void *)&cmd_config_loopback_all_keyword,
1650 		(void *)&cmd_config_loopback_all_all,
1651 		(void *)&cmd_config_loopback_all_item,
1652 		(void *)&cmd_config_loopback_all_mode,
1653 		NULL,
1654 	},
1655 };
1656 
1657 /* *** configure loopback for specific port *** */
1658 struct cmd_config_loopback_specific {
1659 	cmdline_fixed_string_t port;
1660 	cmdline_fixed_string_t keyword;
1661 	uint16_t port_id;
1662 	cmdline_fixed_string_t item;
1663 	uint32_t mode;
1664 };
1665 
1666 static void
1667 cmd_config_loopback_specific_parsed(void *parsed_result,
1668 				__attribute__((unused)) struct cmdline *cl,
1669 				__attribute__((unused)) void *data)
1670 {
1671 	struct cmd_config_loopback_specific *res = parsed_result;
1672 
1673 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1674 		return;
1675 
1676 	if (!port_is_stopped(res->port_id)) {
1677 		printf("Please stop port %u first\n", res->port_id);
1678 		return;
1679 	}
1680 
1681 	ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1682 
1683 	cmd_reconfig_device_queue(res->port_id, 1, 1);
1684 }
1685 
1686 
1687 cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1688 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1689 								"port");
1690 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1691 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1692 								"config");
1693 cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1694 	TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1695 								UINT16);
1696 cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1697 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1698 								"loopback");
1699 cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1700 	TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1701 			      UINT32);
1702 
1703 cmdline_parse_inst_t cmd_config_loopback_specific = {
1704 	.f = cmd_config_loopback_specific_parsed,
1705 	.data = NULL,
1706 	.help_str = "port config <port_id> loopback <mode>",
1707 	.tokens = {
1708 		(void *)&cmd_config_loopback_specific_port,
1709 		(void *)&cmd_config_loopback_specific_keyword,
1710 		(void *)&cmd_config_loopback_specific_id,
1711 		(void *)&cmd_config_loopback_specific_item,
1712 		(void *)&cmd_config_loopback_specific_mode,
1713 		NULL,
1714 	},
1715 };
1716 
1717 /* *** configure txq/rxq, txd/rxd *** */
1718 struct cmd_config_rx_tx {
1719 	cmdline_fixed_string_t port;
1720 	cmdline_fixed_string_t keyword;
1721 	cmdline_fixed_string_t all;
1722 	cmdline_fixed_string_t name;
1723 	uint16_t value;
1724 };
1725 
1726 static void
1727 cmd_config_rx_tx_parsed(void *parsed_result,
1728 			__attribute__((unused)) struct cmdline *cl,
1729 			__attribute__((unused)) void *data)
1730 {
1731 	struct cmd_config_rx_tx *res = parsed_result;
1732 
1733 	if (!all_ports_stopped()) {
1734 		printf("Please stop all ports first\n");
1735 		return;
1736 	}
1737 	if (!strcmp(res->name, "rxq")) {
1738 		if (!res->value && !nb_txq) {
1739 			printf("Warning: Either rx or tx queues should be non zero\n");
1740 			return;
1741 		}
1742 		if (check_nb_rxq(res->value) != 0)
1743 			return;
1744 		nb_rxq = res->value;
1745 	}
1746 	else if (!strcmp(res->name, "txq")) {
1747 		if (!res->value && !nb_rxq) {
1748 			printf("Warning: Either rx or tx queues should be non zero\n");
1749 			return;
1750 		}
1751 		if (check_nb_txq(res->value) != 0)
1752 			return;
1753 		nb_txq = res->value;
1754 	}
1755 	else if (!strcmp(res->name, "rxd")) {
1756 		if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1757 			printf("rxd %d invalid - must be > 0 && <= %d\n",
1758 					res->value, RTE_TEST_RX_DESC_MAX);
1759 			return;
1760 		}
1761 		nb_rxd = res->value;
1762 	} else if (!strcmp(res->name, "txd")) {
1763 		if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1764 			printf("txd %d invalid - must be > 0 && <= %d\n",
1765 					res->value, RTE_TEST_TX_DESC_MAX);
1766 			return;
1767 		}
1768 		nb_txd = res->value;
1769 	} else {
1770 		printf("Unknown parameter\n");
1771 		return;
1772 	}
1773 
1774 	fwd_config_setup();
1775 
1776 	init_port_config();
1777 
1778 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1779 }
1780 
1781 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1782 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1783 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1784 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1785 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1786 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1787 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1788 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1789 						"rxq#txq#rxd#txd");
1790 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1791 	TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1792 
1793 cmdline_parse_inst_t cmd_config_rx_tx = {
1794 	.f = cmd_config_rx_tx_parsed,
1795 	.data = NULL,
1796 	.help_str = "port config all rxq|txq|rxd|txd <value>",
1797 	.tokens = {
1798 		(void *)&cmd_config_rx_tx_port,
1799 		(void *)&cmd_config_rx_tx_keyword,
1800 		(void *)&cmd_config_rx_tx_all,
1801 		(void *)&cmd_config_rx_tx_name,
1802 		(void *)&cmd_config_rx_tx_value,
1803 		NULL,
1804 	},
1805 };
1806 
1807 /* *** config max packet length *** */
1808 struct cmd_config_max_pkt_len_result {
1809 	cmdline_fixed_string_t port;
1810 	cmdline_fixed_string_t keyword;
1811 	cmdline_fixed_string_t all;
1812 	cmdline_fixed_string_t name;
1813 	uint32_t value;
1814 };
1815 
1816 static void
1817 cmd_config_max_pkt_len_parsed(void *parsed_result,
1818 				__attribute__((unused)) struct cmdline *cl,
1819 				__attribute__((unused)) void *data)
1820 {
1821 	struct cmd_config_max_pkt_len_result *res = parsed_result;
1822 	portid_t pid;
1823 
1824 	if (!all_ports_stopped()) {
1825 		printf("Please stop all ports first\n");
1826 		return;
1827 	}
1828 
1829 	RTE_ETH_FOREACH_DEV(pid) {
1830 		struct rte_port *port = &ports[pid];
1831 		uint64_t rx_offloads = port->dev_conf.rxmode.offloads;
1832 
1833 		if (!strcmp(res->name, "max-pkt-len")) {
1834 			if (res->value < ETHER_MIN_LEN) {
1835 				printf("max-pkt-len can not be less than %d\n",
1836 						ETHER_MIN_LEN);
1837 				return;
1838 			}
1839 			if (res->value == port->dev_conf.rxmode.max_rx_pkt_len)
1840 				return;
1841 
1842 			port->dev_conf.rxmode.max_rx_pkt_len = res->value;
1843 			if (res->value > ETHER_MAX_LEN)
1844 				rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
1845 			else
1846 				rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
1847 			port->dev_conf.rxmode.offloads = rx_offloads;
1848 		} else {
1849 			printf("Unknown parameter\n");
1850 			return;
1851 		}
1852 	}
1853 
1854 	init_port_config();
1855 
1856 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1857 }
1858 
1859 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1860 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1861 								"port");
1862 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1863 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1864 								"config");
1865 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1866 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1867 								"all");
1868 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1869 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1870 								"max-pkt-len");
1871 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1872 	TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1873 								UINT32);
1874 
1875 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1876 	.f = cmd_config_max_pkt_len_parsed,
1877 	.data = NULL,
1878 	.help_str = "port config all max-pkt-len <value>",
1879 	.tokens = {
1880 		(void *)&cmd_config_max_pkt_len_port,
1881 		(void *)&cmd_config_max_pkt_len_keyword,
1882 		(void *)&cmd_config_max_pkt_len_all,
1883 		(void *)&cmd_config_max_pkt_len_name,
1884 		(void *)&cmd_config_max_pkt_len_value,
1885 		NULL,
1886 	},
1887 };
1888 
1889 /* *** configure port MTU *** */
1890 struct cmd_config_mtu_result {
1891 	cmdline_fixed_string_t port;
1892 	cmdline_fixed_string_t keyword;
1893 	cmdline_fixed_string_t mtu;
1894 	portid_t port_id;
1895 	uint16_t value;
1896 };
1897 
1898 static void
1899 cmd_config_mtu_parsed(void *parsed_result,
1900 		      __attribute__((unused)) struct cmdline *cl,
1901 		      __attribute__((unused)) void *data)
1902 {
1903 	struct cmd_config_mtu_result *res = parsed_result;
1904 
1905 	if (res->value < ETHER_MIN_LEN) {
1906 		printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1907 		return;
1908 	}
1909 	port_mtu_set(res->port_id, res->value);
1910 }
1911 
1912 cmdline_parse_token_string_t cmd_config_mtu_port =
1913 	TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1914 				 "port");
1915 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1916 	TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1917 				 "config");
1918 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1919 	TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1920 				 "mtu");
1921 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1922 	TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT16);
1923 cmdline_parse_token_num_t cmd_config_mtu_value =
1924 	TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1925 
1926 cmdline_parse_inst_t cmd_config_mtu = {
1927 	.f = cmd_config_mtu_parsed,
1928 	.data = NULL,
1929 	.help_str = "port config mtu <port_id> <value>",
1930 	.tokens = {
1931 		(void *)&cmd_config_mtu_port,
1932 		(void *)&cmd_config_mtu_keyword,
1933 		(void *)&cmd_config_mtu_mtu,
1934 		(void *)&cmd_config_mtu_port_id,
1935 		(void *)&cmd_config_mtu_value,
1936 		NULL,
1937 	},
1938 };
1939 
1940 /* *** configure rx mode *** */
1941 struct cmd_config_rx_mode_flag {
1942 	cmdline_fixed_string_t port;
1943 	cmdline_fixed_string_t keyword;
1944 	cmdline_fixed_string_t all;
1945 	cmdline_fixed_string_t name;
1946 	cmdline_fixed_string_t value;
1947 };
1948 
1949 static void
1950 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1951 				__attribute__((unused)) struct cmdline *cl,
1952 				__attribute__((unused)) void *data)
1953 {
1954 	struct cmd_config_rx_mode_flag *res = parsed_result;
1955 	portid_t pid;
1956 
1957 	if (!all_ports_stopped()) {
1958 		printf("Please stop all ports first\n");
1959 		return;
1960 	}
1961 
1962 	RTE_ETH_FOREACH_DEV(pid) {
1963 		struct rte_port *port;
1964 		uint64_t rx_offloads;
1965 
1966 		port = &ports[pid];
1967 		rx_offloads = port->dev_conf.rxmode.offloads;
1968 		if (!strcmp(res->name, "crc-strip")) {
1969 			if (!strcmp(res->value, "on")) {
1970 				rx_offloads &= ~DEV_RX_OFFLOAD_KEEP_CRC;
1971 			} else if (!strcmp(res->value, "off")) {
1972 				rx_offloads |= DEV_RX_OFFLOAD_KEEP_CRC;
1973 			} else {
1974 				printf("Unknown parameter\n");
1975 				return;
1976 			}
1977 		} else if (!strcmp(res->name, "scatter")) {
1978 			if (!strcmp(res->value, "on")) {
1979 				rx_offloads |= DEV_RX_OFFLOAD_SCATTER;
1980 			} else if (!strcmp(res->value, "off")) {
1981 				rx_offloads &= ~DEV_RX_OFFLOAD_SCATTER;
1982 			} else {
1983 				printf("Unknown parameter\n");
1984 				return;
1985 			}
1986 		} else if (!strcmp(res->name, "rx-cksum")) {
1987 			if (!strcmp(res->value, "on"))
1988 				rx_offloads |= DEV_RX_OFFLOAD_CHECKSUM;
1989 			else if (!strcmp(res->value, "off"))
1990 				rx_offloads &= ~DEV_RX_OFFLOAD_CHECKSUM;
1991 			else {
1992 				printf("Unknown parameter\n");
1993 				return;
1994 			}
1995 		} else if (!strcmp(res->name, "rx-timestamp")) {
1996 			if (!strcmp(res->value, "on"))
1997 				rx_offloads |= DEV_RX_OFFLOAD_TIMESTAMP;
1998 			else if (!strcmp(res->value, "off"))
1999 				rx_offloads &= ~DEV_RX_OFFLOAD_TIMESTAMP;
2000 			else {
2001 				printf("Unknown parameter\n");
2002 				return;
2003 			}
2004 		} else if (!strcmp(res->name, "hw-vlan")) {
2005 			if (!strcmp(res->value, "on")) {
2006 				rx_offloads |= (DEV_RX_OFFLOAD_VLAN_FILTER |
2007 						DEV_RX_OFFLOAD_VLAN_STRIP);
2008 			} else if (!strcmp(res->value, "off")) {
2009 				rx_offloads &= ~(DEV_RX_OFFLOAD_VLAN_FILTER |
2010 						DEV_RX_OFFLOAD_VLAN_STRIP);
2011 			} else {
2012 				printf("Unknown parameter\n");
2013 				return;
2014 			}
2015 		} else if (!strcmp(res->name, "hw-vlan-filter")) {
2016 			if (!strcmp(res->value, "on"))
2017 				rx_offloads |= DEV_RX_OFFLOAD_VLAN_FILTER;
2018 			else if (!strcmp(res->value, "off"))
2019 				rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_FILTER;
2020 			else {
2021 				printf("Unknown parameter\n");
2022 				return;
2023 			}
2024 		} else if (!strcmp(res->name, "hw-vlan-strip")) {
2025 			if (!strcmp(res->value, "on"))
2026 				rx_offloads |= DEV_RX_OFFLOAD_VLAN_STRIP;
2027 			else if (!strcmp(res->value, "off"))
2028 				rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_STRIP;
2029 			else {
2030 				printf("Unknown parameter\n");
2031 				return;
2032 			}
2033 		} else if (!strcmp(res->name, "hw-vlan-extend")) {
2034 			if (!strcmp(res->value, "on"))
2035 				rx_offloads |= DEV_RX_OFFLOAD_VLAN_EXTEND;
2036 			else if (!strcmp(res->value, "off"))
2037 				rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_EXTEND;
2038 			else {
2039 				printf("Unknown parameter\n");
2040 				return;
2041 			}
2042 		} else if (!strcmp(res->name, "drop-en")) {
2043 			if (!strcmp(res->value, "on"))
2044 				rx_drop_en = 1;
2045 			else if (!strcmp(res->value, "off"))
2046 				rx_drop_en = 0;
2047 			else {
2048 				printf("Unknown parameter\n");
2049 				return;
2050 			}
2051 		} else {
2052 			printf("Unknown parameter\n");
2053 			return;
2054 		}
2055 		port->dev_conf.rxmode.offloads = rx_offloads;
2056 	}
2057 
2058 	init_port_config();
2059 
2060 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2061 }
2062 
2063 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
2064 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
2065 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
2066 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
2067 								"config");
2068 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2069 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2070 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2071 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2072 					"crc-strip#scatter#rx-cksum#rx-timestamp#hw-vlan#"
2073 					"hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
2074 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2075 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2076 							"on#off");
2077 
2078 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2079 	.f = cmd_config_rx_mode_flag_parsed,
2080 	.data = NULL,
2081 	.help_str = "port config all crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|"
2082 		"hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
2083 	.tokens = {
2084 		(void *)&cmd_config_rx_mode_flag_port,
2085 		(void *)&cmd_config_rx_mode_flag_keyword,
2086 		(void *)&cmd_config_rx_mode_flag_all,
2087 		(void *)&cmd_config_rx_mode_flag_name,
2088 		(void *)&cmd_config_rx_mode_flag_value,
2089 		NULL,
2090 	},
2091 };
2092 
2093 /* *** configure rss *** */
2094 struct cmd_config_rss {
2095 	cmdline_fixed_string_t port;
2096 	cmdline_fixed_string_t keyword;
2097 	cmdline_fixed_string_t all;
2098 	cmdline_fixed_string_t name;
2099 	cmdline_fixed_string_t value;
2100 };
2101 
2102 static void
2103 cmd_config_rss_parsed(void *parsed_result,
2104 			__attribute__((unused)) struct cmdline *cl,
2105 			__attribute__((unused)) void *data)
2106 {
2107 	struct cmd_config_rss *res = parsed_result;
2108 	struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2109 	struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2110 	int use_default = 0;
2111 	int all_updated = 1;
2112 	int diag;
2113 	uint16_t i;
2114 
2115 	if (!strcmp(res->value, "all"))
2116 		rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
2117 				ETH_RSS_UDP | ETH_RSS_SCTP |
2118 					ETH_RSS_L2_PAYLOAD;
2119 	else if (!strcmp(res->value, "ip"))
2120 		rss_conf.rss_hf = ETH_RSS_IP;
2121 	else if (!strcmp(res->value, "udp"))
2122 		rss_conf.rss_hf = ETH_RSS_UDP;
2123 	else if (!strcmp(res->value, "tcp"))
2124 		rss_conf.rss_hf = ETH_RSS_TCP;
2125 	else if (!strcmp(res->value, "sctp"))
2126 		rss_conf.rss_hf = ETH_RSS_SCTP;
2127 	else if (!strcmp(res->value, "ether"))
2128 		rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
2129 	else if (!strcmp(res->value, "port"))
2130 		rss_conf.rss_hf = ETH_RSS_PORT;
2131 	else if (!strcmp(res->value, "vxlan"))
2132 		rss_conf.rss_hf = ETH_RSS_VXLAN;
2133 	else if (!strcmp(res->value, "geneve"))
2134 		rss_conf.rss_hf = ETH_RSS_GENEVE;
2135 	else if (!strcmp(res->value, "nvgre"))
2136 		rss_conf.rss_hf = ETH_RSS_NVGRE;
2137 	else if (!strcmp(res->value, "none"))
2138 		rss_conf.rss_hf = 0;
2139 	else if (!strcmp(res->value, "default"))
2140 		use_default = 1;
2141 	else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2142 						atoi(res->value) < 64)
2143 		rss_conf.rss_hf = 1ULL << atoi(res->value);
2144 	else {
2145 		printf("Unknown parameter\n");
2146 		return;
2147 	}
2148 	rss_conf.rss_key = NULL;
2149 	/* Update global configuration for RSS types. */
2150 	RTE_ETH_FOREACH_DEV(i) {
2151 		struct rte_eth_rss_conf local_rss_conf;
2152 
2153 		rte_eth_dev_info_get(i, &dev_info);
2154 		if (use_default)
2155 			rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2156 
2157 		local_rss_conf = rss_conf;
2158 		local_rss_conf.rss_hf = rss_conf.rss_hf &
2159 			dev_info.flow_type_rss_offloads;
2160 		if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2161 			printf("Port %u modified RSS hash function based on hardware support,"
2162 				"requested:%#"PRIx64" configured:%#"PRIx64"\n",
2163 				i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2164 		}
2165 		diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2166 		if (diag < 0) {
2167 			all_updated = 0;
2168 			printf("Configuration of RSS hash at ethernet port %d "
2169 				"failed with error (%d): %s.\n",
2170 				i, -diag, strerror(-diag));
2171 		}
2172 	}
2173 	if (all_updated && !use_default)
2174 		rss_hf = rss_conf.rss_hf;
2175 }
2176 
2177 cmdline_parse_token_string_t cmd_config_rss_port =
2178 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2179 cmdline_parse_token_string_t cmd_config_rss_keyword =
2180 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2181 cmdline_parse_token_string_t cmd_config_rss_all =
2182 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2183 cmdline_parse_token_string_t cmd_config_rss_name =
2184 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2185 cmdline_parse_token_string_t cmd_config_rss_value =
2186 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2187 
2188 cmdline_parse_inst_t cmd_config_rss = {
2189 	.f = cmd_config_rss_parsed,
2190 	.data = NULL,
2191 	.help_str = "port config all rss "
2192 		"all|default|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|vxlan-gpe|none|<flowtype_id>",
2193 	.tokens = {
2194 		(void *)&cmd_config_rss_port,
2195 		(void *)&cmd_config_rss_keyword,
2196 		(void *)&cmd_config_rss_all,
2197 		(void *)&cmd_config_rss_name,
2198 		(void *)&cmd_config_rss_value,
2199 		NULL,
2200 	},
2201 };
2202 
2203 /* *** configure rss hash key *** */
2204 struct cmd_config_rss_hash_key {
2205 	cmdline_fixed_string_t port;
2206 	cmdline_fixed_string_t config;
2207 	portid_t port_id;
2208 	cmdline_fixed_string_t rss_hash_key;
2209 	cmdline_fixed_string_t rss_type;
2210 	cmdline_fixed_string_t key;
2211 };
2212 
2213 static uint8_t
2214 hexa_digit_to_value(char hexa_digit)
2215 {
2216 	if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2217 		return (uint8_t) (hexa_digit - '0');
2218 	if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2219 		return (uint8_t) ((hexa_digit - 'a') + 10);
2220 	if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2221 		return (uint8_t) ((hexa_digit - 'A') + 10);
2222 	/* Invalid hexa digit */
2223 	return 0xFF;
2224 }
2225 
2226 static uint8_t
2227 parse_and_check_key_hexa_digit(char *key, int idx)
2228 {
2229 	uint8_t hexa_v;
2230 
2231 	hexa_v = hexa_digit_to_value(key[idx]);
2232 	if (hexa_v == 0xFF)
2233 		printf("invalid key: character %c at position %d is not a "
2234 		       "valid hexa digit\n", key[idx], idx);
2235 	return hexa_v;
2236 }
2237 
2238 static void
2239 cmd_config_rss_hash_key_parsed(void *parsed_result,
2240 			       __attribute__((unused)) struct cmdline *cl,
2241 			       __attribute__((unused)) void *data)
2242 {
2243 	struct cmd_config_rss_hash_key *res = parsed_result;
2244 	uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2245 	uint8_t xdgt0;
2246 	uint8_t xdgt1;
2247 	int i;
2248 	struct rte_eth_dev_info dev_info;
2249 	uint8_t hash_key_size;
2250 	uint32_t key_len;
2251 
2252 	memset(&dev_info, 0, sizeof(dev_info));
2253 	rte_eth_dev_info_get(res->port_id, &dev_info);
2254 	if (dev_info.hash_key_size > 0 &&
2255 			dev_info.hash_key_size <= sizeof(hash_key))
2256 		hash_key_size = dev_info.hash_key_size;
2257 	else {
2258 		printf("dev_info did not provide a valid hash key size\n");
2259 		return;
2260 	}
2261 	/* Check the length of the RSS hash key */
2262 	key_len = strlen(res->key);
2263 	if (key_len != (hash_key_size * 2)) {
2264 		printf("key length: %d invalid - key must be a string of %d"
2265 			   " hexa-decimal numbers\n",
2266 			   (int) key_len, hash_key_size * 2);
2267 		return;
2268 	}
2269 	/* Translate RSS hash key into binary representation */
2270 	for (i = 0; i < hash_key_size; i++) {
2271 		xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2272 		if (xdgt0 == 0xFF)
2273 			return;
2274 		xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2275 		if (xdgt1 == 0xFF)
2276 			return;
2277 		hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2278 	}
2279 	port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2280 			hash_key_size);
2281 }
2282 
2283 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2284 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2285 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2286 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2287 				 "config");
2288 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2289 	TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16);
2290 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2291 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2292 				 rss_hash_key, "rss-hash-key");
2293 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2294 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2295 				 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2296 				 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2297 				 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2298 				 "ipv6-tcp-ex#ipv6-udp-ex");
2299 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2300 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2301 
2302 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2303 	.f = cmd_config_rss_hash_key_parsed,
2304 	.data = NULL,
2305 	.help_str = "port config <port_id> rss-hash-key "
2306 		"ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2307 		"ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2308 		"l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex "
2309 		"<string of hex digits (variable length, NIC dependent)>",
2310 	.tokens = {
2311 		(void *)&cmd_config_rss_hash_key_port,
2312 		(void *)&cmd_config_rss_hash_key_config,
2313 		(void *)&cmd_config_rss_hash_key_port_id,
2314 		(void *)&cmd_config_rss_hash_key_rss_hash_key,
2315 		(void *)&cmd_config_rss_hash_key_rss_type,
2316 		(void *)&cmd_config_rss_hash_key_value,
2317 		NULL,
2318 	},
2319 };
2320 
2321 /* *** configure port rxq/txq ring size *** */
2322 struct cmd_config_rxtx_ring_size {
2323 	cmdline_fixed_string_t port;
2324 	cmdline_fixed_string_t config;
2325 	portid_t portid;
2326 	cmdline_fixed_string_t rxtxq;
2327 	uint16_t qid;
2328 	cmdline_fixed_string_t rsize;
2329 	uint16_t size;
2330 };
2331 
2332 static void
2333 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2334 				 __attribute__((unused)) struct cmdline *cl,
2335 				 __attribute__((unused)) void *data)
2336 {
2337 	struct cmd_config_rxtx_ring_size *res = parsed_result;
2338 	struct rte_port *port;
2339 	uint8_t isrx;
2340 
2341 	if (port_id_is_invalid(res->portid, ENABLED_WARN))
2342 		return;
2343 
2344 	if (res->portid == (portid_t)RTE_PORT_ALL) {
2345 		printf("Invalid port id\n");
2346 		return;
2347 	}
2348 
2349 	port = &ports[res->portid];
2350 
2351 	if (!strcmp(res->rxtxq, "rxq"))
2352 		isrx = 1;
2353 	else if (!strcmp(res->rxtxq, "txq"))
2354 		isrx = 0;
2355 	else {
2356 		printf("Unknown parameter\n");
2357 		return;
2358 	}
2359 
2360 	if (isrx && rx_queue_id_is_invalid(res->qid))
2361 		return;
2362 	else if (!isrx && tx_queue_id_is_invalid(res->qid))
2363 		return;
2364 
2365 	if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2366 		printf("Invalid rx ring_size, must > rx_free_thresh: %d\n",
2367 		       rx_free_thresh);
2368 		return;
2369 	}
2370 
2371 	if (isrx)
2372 		port->nb_rx_desc[res->qid] = res->size;
2373 	else
2374 		port->nb_tx_desc[res->qid] = res->size;
2375 
2376 	cmd_reconfig_device_queue(res->portid, 0, 1);
2377 }
2378 
2379 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2380 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2381 				 port, "port");
2382 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2383 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2384 				 config, "config");
2385 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2386 	TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2387 				 portid, UINT16);
2388 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2389 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2390 				 rxtxq, "rxq#txq");
2391 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2392 	TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2393 			      qid, UINT16);
2394 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2395 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2396 				 rsize, "ring_size");
2397 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2398 	TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2399 			      size, UINT16);
2400 
2401 cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2402 	.f = cmd_config_rxtx_ring_size_parsed,
2403 	.data = NULL,
2404 	.help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2405 	.tokens = {
2406 		(void *)&cmd_config_rxtx_ring_size_port,
2407 		(void *)&cmd_config_rxtx_ring_size_config,
2408 		(void *)&cmd_config_rxtx_ring_size_portid,
2409 		(void *)&cmd_config_rxtx_ring_size_rxtxq,
2410 		(void *)&cmd_config_rxtx_ring_size_qid,
2411 		(void *)&cmd_config_rxtx_ring_size_rsize,
2412 		(void *)&cmd_config_rxtx_ring_size_size,
2413 		NULL,
2414 	},
2415 };
2416 
2417 /* *** configure port rxq/txq start/stop *** */
2418 struct cmd_config_rxtx_queue {
2419 	cmdline_fixed_string_t port;
2420 	portid_t portid;
2421 	cmdline_fixed_string_t rxtxq;
2422 	uint16_t qid;
2423 	cmdline_fixed_string_t opname;
2424 };
2425 
2426 static void
2427 cmd_config_rxtx_queue_parsed(void *parsed_result,
2428 			__attribute__((unused)) struct cmdline *cl,
2429 			__attribute__((unused)) void *data)
2430 {
2431 	struct cmd_config_rxtx_queue *res = parsed_result;
2432 	uint8_t isrx;
2433 	uint8_t isstart;
2434 	int ret = 0;
2435 
2436 	if (test_done == 0) {
2437 		printf("Please stop forwarding first\n");
2438 		return;
2439 	}
2440 
2441 	if (port_id_is_invalid(res->portid, ENABLED_WARN))
2442 		return;
2443 
2444 	if (port_is_started(res->portid) != 1) {
2445 		printf("Please start port %u first\n", res->portid);
2446 		return;
2447 	}
2448 
2449 	if (!strcmp(res->rxtxq, "rxq"))
2450 		isrx = 1;
2451 	else if (!strcmp(res->rxtxq, "txq"))
2452 		isrx = 0;
2453 	else {
2454 		printf("Unknown parameter\n");
2455 		return;
2456 	}
2457 
2458 	if (isrx && rx_queue_id_is_invalid(res->qid))
2459 		return;
2460 	else if (!isrx && tx_queue_id_is_invalid(res->qid))
2461 		return;
2462 
2463 	if (!strcmp(res->opname, "start"))
2464 		isstart = 1;
2465 	else if (!strcmp(res->opname, "stop"))
2466 		isstart = 0;
2467 	else {
2468 		printf("Unknown parameter\n");
2469 		return;
2470 	}
2471 
2472 	if (isstart && isrx)
2473 		ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2474 	else if (!isstart && isrx)
2475 		ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2476 	else if (isstart && !isrx)
2477 		ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2478 	else
2479 		ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2480 
2481 	if (ret == -ENOTSUP)
2482 		printf("Function not supported in PMD driver\n");
2483 }
2484 
2485 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2486 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2487 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2488 	TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16);
2489 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2490 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2491 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2492 	TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
2493 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2494 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2495 						"start#stop");
2496 
2497 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2498 	.f = cmd_config_rxtx_queue_parsed,
2499 	.data = NULL,
2500 	.help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2501 	.tokens = {
2502 		(void *)&cmd_config_rxtx_queue_port,
2503 		(void *)&cmd_config_rxtx_queue_portid,
2504 		(void *)&cmd_config_rxtx_queue_rxtxq,
2505 		(void *)&cmd_config_rxtx_queue_qid,
2506 		(void *)&cmd_config_rxtx_queue_opname,
2507 		NULL,
2508 	},
2509 };
2510 
2511 /* *** configure port rxq/txq deferred start on/off *** */
2512 struct cmd_config_deferred_start_rxtx_queue {
2513 	cmdline_fixed_string_t port;
2514 	portid_t port_id;
2515 	cmdline_fixed_string_t rxtxq;
2516 	uint16_t qid;
2517 	cmdline_fixed_string_t opname;
2518 	cmdline_fixed_string_t state;
2519 };
2520 
2521 static void
2522 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2523 			__attribute__((unused)) struct cmdline *cl,
2524 			__attribute__((unused)) void *data)
2525 {
2526 	struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2527 	struct rte_port *port;
2528 	uint8_t isrx;
2529 	uint8_t ison;
2530 	uint8_t needreconfig = 0;
2531 
2532 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2533 		return;
2534 
2535 	if (port_is_started(res->port_id) != 0) {
2536 		printf("Please stop port %u first\n", res->port_id);
2537 		return;
2538 	}
2539 
2540 	port = &ports[res->port_id];
2541 
2542 	isrx = !strcmp(res->rxtxq, "rxq");
2543 
2544 	if (isrx && rx_queue_id_is_invalid(res->qid))
2545 		return;
2546 	else if (!isrx && tx_queue_id_is_invalid(res->qid))
2547 		return;
2548 
2549 	ison = !strcmp(res->state, "on");
2550 
2551 	if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) {
2552 		port->rx_conf[res->qid].rx_deferred_start = ison;
2553 		needreconfig = 1;
2554 	} else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) {
2555 		port->tx_conf[res->qid].tx_deferred_start = ison;
2556 		needreconfig = 1;
2557 	}
2558 
2559 	if (needreconfig)
2560 		cmd_reconfig_device_queue(res->port_id, 0, 1);
2561 }
2562 
2563 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2564 	TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2565 						port, "port");
2566 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2567 	TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2568 						port_id, UINT16);
2569 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2570 	TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2571 						rxtxq, "rxq#txq");
2572 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2573 	TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2574 						qid, UINT16);
2575 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2576 	TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2577 						opname, "deferred_start");
2578 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2579 	TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2580 						state, "on#off");
2581 
2582 cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
2583 	.f = cmd_config_deferred_start_rxtx_queue_parsed,
2584 	.data = NULL,
2585 	.help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
2586 	.tokens = {
2587 		(void *)&cmd_config_deferred_start_rxtx_queue_port,
2588 		(void *)&cmd_config_deferred_start_rxtx_queue_port_id,
2589 		(void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
2590 		(void *)&cmd_config_deferred_start_rxtx_queue_qid,
2591 		(void *)&cmd_config_deferred_start_rxtx_queue_opname,
2592 		(void *)&cmd_config_deferred_start_rxtx_queue_state,
2593 		NULL,
2594 	},
2595 };
2596 
2597 /* *** configure port rxq/txq setup *** */
2598 struct cmd_setup_rxtx_queue {
2599 	cmdline_fixed_string_t port;
2600 	portid_t portid;
2601 	cmdline_fixed_string_t rxtxq;
2602 	uint16_t qid;
2603 	cmdline_fixed_string_t setup;
2604 };
2605 
2606 /* Common CLI fields for queue setup */
2607 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2608 	TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2609 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2610 	TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, UINT16);
2611 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2612 	TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2613 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2614 	TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, UINT16);
2615 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2616 	TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2617 
2618 static void
2619 cmd_setup_rxtx_queue_parsed(
2620 	void *parsed_result,
2621 	__attribute__((unused)) struct cmdline *cl,
2622 	__attribute__((unused)) void *data)
2623 {
2624 	struct cmd_setup_rxtx_queue *res = parsed_result;
2625 	struct rte_port *port;
2626 	struct rte_mempool *mp;
2627 	unsigned int socket_id;
2628 	uint8_t isrx = 0;
2629 	int ret;
2630 
2631 	if (port_id_is_invalid(res->portid, ENABLED_WARN))
2632 		return;
2633 
2634 	if (res->portid == (portid_t)RTE_PORT_ALL) {
2635 		printf("Invalid port id\n");
2636 		return;
2637 	}
2638 
2639 	if (!strcmp(res->rxtxq, "rxq"))
2640 		isrx = 1;
2641 	else if (!strcmp(res->rxtxq, "txq"))
2642 		isrx = 0;
2643 	else {
2644 		printf("Unknown parameter\n");
2645 		return;
2646 	}
2647 
2648 	if (isrx && rx_queue_id_is_invalid(res->qid)) {
2649 		printf("Invalid rx queue\n");
2650 		return;
2651 	} else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2652 		printf("Invalid tx queue\n");
2653 		return;
2654 	}
2655 
2656 	port = &ports[res->portid];
2657 	if (isrx) {
2658 		socket_id = rxring_numa[res->portid];
2659 		if (!numa_support || socket_id == NUMA_NO_CONFIG)
2660 			socket_id = port->socket_id;
2661 
2662 		mp = mbuf_pool_find(socket_id);
2663 		if (mp == NULL) {
2664 			printf("Failed to setup RX queue: "
2665 				"No mempool allocation"
2666 				" on the socket %d\n",
2667 				rxring_numa[res->portid]);
2668 			return;
2669 		}
2670 		ret = rte_eth_rx_queue_setup(res->portid,
2671 					     res->qid,
2672 					     port->nb_rx_desc[res->qid],
2673 					     socket_id,
2674 					     &port->rx_conf[res->qid],
2675 					     mp);
2676 		if (ret)
2677 			printf("Failed to setup RX queue\n");
2678 	} else {
2679 		socket_id = txring_numa[res->portid];
2680 		if (!numa_support || socket_id == NUMA_NO_CONFIG)
2681 			socket_id = port->socket_id;
2682 
2683 		ret = rte_eth_tx_queue_setup(res->portid,
2684 					     res->qid,
2685 					     port->nb_tx_desc[res->qid],
2686 					     socket_id,
2687 					     &port->tx_conf[res->qid]);
2688 		if (ret)
2689 			printf("Failed to setup TX queue\n");
2690 	}
2691 }
2692 
2693 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2694 	.f = cmd_setup_rxtx_queue_parsed,
2695 	.data = NULL,
2696 	.help_str = "port <port_id> rxq|txq <queue_idx> setup",
2697 	.tokens = {
2698 		(void *)&cmd_setup_rxtx_queue_port,
2699 		(void *)&cmd_setup_rxtx_queue_portid,
2700 		(void *)&cmd_setup_rxtx_queue_rxtxq,
2701 		(void *)&cmd_setup_rxtx_queue_qid,
2702 		(void *)&cmd_setup_rxtx_queue_setup,
2703 		NULL,
2704 	},
2705 };
2706 
2707 
2708 /* *** Configure RSS RETA *** */
2709 struct cmd_config_rss_reta {
2710 	cmdline_fixed_string_t port;
2711 	cmdline_fixed_string_t keyword;
2712 	portid_t port_id;
2713 	cmdline_fixed_string_t name;
2714 	cmdline_fixed_string_t list_name;
2715 	cmdline_fixed_string_t list_of_items;
2716 };
2717 
2718 static int
2719 parse_reta_config(const char *str,
2720 		  struct rte_eth_rss_reta_entry64 *reta_conf,
2721 		  uint16_t nb_entries)
2722 {
2723 	int i;
2724 	unsigned size;
2725 	uint16_t hash_index, idx, shift;
2726 	uint16_t nb_queue;
2727 	char s[256];
2728 	const char *p, *p0 = str;
2729 	char *end;
2730 	enum fieldnames {
2731 		FLD_HASH_INDEX = 0,
2732 		FLD_QUEUE,
2733 		_NUM_FLD
2734 	};
2735 	unsigned long int_fld[_NUM_FLD];
2736 	char *str_fld[_NUM_FLD];
2737 
2738 	while ((p = strchr(p0,'(')) != NULL) {
2739 		++p;
2740 		if((p0 = strchr(p,')')) == NULL)
2741 			return -1;
2742 
2743 		size = p0 - p;
2744 		if(size >= sizeof(s))
2745 			return -1;
2746 
2747 		snprintf(s, sizeof(s), "%.*s", size, p);
2748 		if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2749 			return -1;
2750 		for (i = 0; i < _NUM_FLD; i++) {
2751 			errno = 0;
2752 			int_fld[i] = strtoul(str_fld[i], &end, 0);
2753 			if (errno != 0 || end == str_fld[i] ||
2754 					int_fld[i] > 65535)
2755 				return -1;
2756 		}
2757 
2758 		hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2759 		nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2760 
2761 		if (hash_index >= nb_entries) {
2762 			printf("Invalid RETA hash index=%d\n", hash_index);
2763 			return -1;
2764 		}
2765 
2766 		idx = hash_index / RTE_RETA_GROUP_SIZE;
2767 		shift = hash_index % RTE_RETA_GROUP_SIZE;
2768 		reta_conf[idx].mask |= (1ULL << shift);
2769 		reta_conf[idx].reta[shift] = nb_queue;
2770 	}
2771 
2772 	return 0;
2773 }
2774 
2775 static void
2776 cmd_set_rss_reta_parsed(void *parsed_result,
2777 			__attribute__((unused)) struct cmdline *cl,
2778 			__attribute__((unused)) void *data)
2779 {
2780 	int ret;
2781 	struct rte_eth_dev_info dev_info;
2782 	struct rte_eth_rss_reta_entry64 reta_conf[8];
2783 	struct cmd_config_rss_reta *res = parsed_result;
2784 
2785 	memset(&dev_info, 0, sizeof(dev_info));
2786 	rte_eth_dev_info_get(res->port_id, &dev_info);
2787 	if (dev_info.reta_size == 0) {
2788 		printf("Redirection table size is 0 which is "
2789 					"invalid for RSS\n");
2790 		return;
2791 	} else
2792 		printf("The reta size of port %d is %u\n",
2793 			res->port_id, dev_info.reta_size);
2794 	if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2795 		printf("Currently do not support more than %u entries of "
2796 			"redirection table\n", ETH_RSS_RETA_SIZE_512);
2797 		return;
2798 	}
2799 
2800 	memset(reta_conf, 0, sizeof(reta_conf));
2801 	if (!strcmp(res->list_name, "reta")) {
2802 		if (parse_reta_config(res->list_of_items, reta_conf,
2803 						dev_info.reta_size)) {
2804 			printf("Invalid RSS Redirection Table "
2805 					"config entered\n");
2806 			return;
2807 		}
2808 		ret = rte_eth_dev_rss_reta_update(res->port_id,
2809 				reta_conf, dev_info.reta_size);
2810 		if (ret != 0)
2811 			printf("Bad redirection table parameter, "
2812 					"return code = %d \n", ret);
2813 	}
2814 }
2815 
2816 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2817 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2818 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2819 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2820 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2821 	TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16);
2822 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2823 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2824 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2825 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2826 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2827         TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2828                                  NULL);
2829 cmdline_parse_inst_t cmd_config_rss_reta = {
2830 	.f = cmd_set_rss_reta_parsed,
2831 	.data = NULL,
2832 	.help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2833 	.tokens = {
2834 		(void *)&cmd_config_rss_reta_port,
2835 		(void *)&cmd_config_rss_reta_keyword,
2836 		(void *)&cmd_config_rss_reta_port_id,
2837 		(void *)&cmd_config_rss_reta_name,
2838 		(void *)&cmd_config_rss_reta_list_name,
2839 		(void *)&cmd_config_rss_reta_list_of_items,
2840 		NULL,
2841 	},
2842 };
2843 
2844 /* *** SHOW PORT RETA INFO *** */
2845 struct cmd_showport_reta {
2846 	cmdline_fixed_string_t show;
2847 	cmdline_fixed_string_t port;
2848 	portid_t port_id;
2849 	cmdline_fixed_string_t rss;
2850 	cmdline_fixed_string_t reta;
2851 	uint16_t size;
2852 	cmdline_fixed_string_t list_of_items;
2853 };
2854 
2855 static int
2856 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2857 			   uint16_t nb_entries,
2858 			   char *str)
2859 {
2860 	uint32_t size;
2861 	const char *p, *p0 = str;
2862 	char s[256];
2863 	char *end;
2864 	char *str_fld[8];
2865 	uint16_t i;
2866 	uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
2867 			RTE_RETA_GROUP_SIZE;
2868 	int ret;
2869 
2870 	p = strchr(p0, '(');
2871 	if (p == NULL)
2872 		return -1;
2873 	p++;
2874 	p0 = strchr(p, ')');
2875 	if (p0 == NULL)
2876 		return -1;
2877 	size = p0 - p;
2878 	if (size >= sizeof(s)) {
2879 		printf("The string size exceeds the internal buffer size\n");
2880 		return -1;
2881 	}
2882 	snprintf(s, sizeof(s), "%.*s", size, p);
2883 	ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
2884 	if (ret <= 0 || ret != num) {
2885 		printf("The bits of masks do not match the number of "
2886 					"reta entries: %u\n", num);
2887 		return -1;
2888 	}
2889 	for (i = 0; i < ret; i++)
2890 		conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
2891 
2892 	return 0;
2893 }
2894 
2895 static void
2896 cmd_showport_reta_parsed(void *parsed_result,
2897 			 __attribute__((unused)) struct cmdline *cl,
2898 			 __attribute__((unused)) void *data)
2899 {
2900 	struct cmd_showport_reta *res = parsed_result;
2901 	struct rte_eth_rss_reta_entry64 reta_conf[8];
2902 	struct rte_eth_dev_info dev_info;
2903 	uint16_t max_reta_size;
2904 
2905 	memset(&dev_info, 0, sizeof(dev_info));
2906 	rte_eth_dev_info_get(res->port_id, &dev_info);
2907 	max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
2908 	if (res->size == 0 || res->size > max_reta_size) {
2909 		printf("Invalid redirection table size: %u (1-%u)\n",
2910 			res->size, max_reta_size);
2911 		return;
2912 	}
2913 
2914 	memset(reta_conf, 0, sizeof(reta_conf));
2915 	if (showport_parse_reta_config(reta_conf, res->size,
2916 				res->list_of_items) < 0) {
2917 		printf("Invalid string: %s for reta masks\n",
2918 					res->list_of_items);
2919 		return;
2920 	}
2921 	port_rss_reta_info(res->port_id, reta_conf, res->size);
2922 }
2923 
2924 cmdline_parse_token_string_t cmd_showport_reta_show =
2925 	TOKEN_STRING_INITIALIZER(struct  cmd_showport_reta, show, "show");
2926 cmdline_parse_token_string_t cmd_showport_reta_port =
2927 	TOKEN_STRING_INITIALIZER(struct  cmd_showport_reta, port, "port");
2928 cmdline_parse_token_num_t cmd_showport_reta_port_id =
2929 	TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16);
2930 cmdline_parse_token_string_t cmd_showport_reta_rss =
2931 	TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
2932 cmdline_parse_token_string_t cmd_showport_reta_reta =
2933 	TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
2934 cmdline_parse_token_num_t cmd_showport_reta_size =
2935 	TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
2936 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
2937 	TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
2938 					list_of_items, NULL);
2939 
2940 cmdline_parse_inst_t cmd_showport_reta = {
2941 	.f = cmd_showport_reta_parsed,
2942 	.data = NULL,
2943 	.help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
2944 	.tokens = {
2945 		(void *)&cmd_showport_reta_show,
2946 		(void *)&cmd_showport_reta_port,
2947 		(void *)&cmd_showport_reta_port_id,
2948 		(void *)&cmd_showport_reta_rss,
2949 		(void *)&cmd_showport_reta_reta,
2950 		(void *)&cmd_showport_reta_size,
2951 		(void *)&cmd_showport_reta_list_of_items,
2952 		NULL,
2953 	},
2954 };
2955 
2956 /* *** Show RSS hash configuration *** */
2957 struct cmd_showport_rss_hash {
2958 	cmdline_fixed_string_t show;
2959 	cmdline_fixed_string_t port;
2960 	portid_t port_id;
2961 	cmdline_fixed_string_t rss_hash;
2962 	cmdline_fixed_string_t rss_type;
2963 	cmdline_fixed_string_t key; /* optional argument */
2964 };
2965 
2966 static void cmd_showport_rss_hash_parsed(void *parsed_result,
2967 				__attribute__((unused)) struct cmdline *cl,
2968 				void *show_rss_key)
2969 {
2970 	struct cmd_showport_rss_hash *res = parsed_result;
2971 
2972 	port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
2973 }
2974 
2975 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
2976 	TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
2977 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
2978 	TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
2979 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
2980 	TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16);
2981 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
2982 	TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
2983 				 "rss-hash");
2984 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
2985 	TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
2986 
2987 cmdline_parse_inst_t cmd_showport_rss_hash = {
2988 	.f = cmd_showport_rss_hash_parsed,
2989 	.data = NULL,
2990 	.help_str = "show port <port_id> rss-hash",
2991 	.tokens = {
2992 		(void *)&cmd_showport_rss_hash_show,
2993 		(void *)&cmd_showport_rss_hash_port,
2994 		(void *)&cmd_showport_rss_hash_port_id,
2995 		(void *)&cmd_showport_rss_hash_rss_hash,
2996 		NULL,
2997 	},
2998 };
2999 
3000 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
3001 	.f = cmd_showport_rss_hash_parsed,
3002 	.data = (void *)1,
3003 	.help_str = "show port <port_id> rss-hash key",
3004 	.tokens = {
3005 		(void *)&cmd_showport_rss_hash_show,
3006 		(void *)&cmd_showport_rss_hash_port,
3007 		(void *)&cmd_showport_rss_hash_port_id,
3008 		(void *)&cmd_showport_rss_hash_rss_hash,
3009 		(void *)&cmd_showport_rss_hash_rss_key,
3010 		NULL,
3011 	},
3012 };
3013 
3014 /* *** Configure DCB *** */
3015 struct cmd_config_dcb {
3016 	cmdline_fixed_string_t port;
3017 	cmdline_fixed_string_t config;
3018 	portid_t port_id;
3019 	cmdline_fixed_string_t dcb;
3020 	cmdline_fixed_string_t vt;
3021 	cmdline_fixed_string_t vt_en;
3022 	uint8_t num_tcs;
3023 	cmdline_fixed_string_t pfc;
3024 	cmdline_fixed_string_t pfc_en;
3025 };
3026 
3027 static void
3028 cmd_config_dcb_parsed(void *parsed_result,
3029                         __attribute__((unused)) struct cmdline *cl,
3030                         __attribute__((unused)) void *data)
3031 {
3032 	struct cmd_config_dcb *res = parsed_result;
3033 	portid_t port_id = res->port_id;
3034 	struct rte_port *port;
3035 	uint8_t pfc_en;
3036 	int ret;
3037 
3038 	port = &ports[port_id];
3039 	/** Check if the port is not started **/
3040 	if (port->port_status != RTE_PORT_STOPPED) {
3041 		printf("Please stop port %d first\n", port_id);
3042 		return;
3043 	}
3044 
3045 	if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
3046 		printf("The invalid number of traffic class,"
3047 			" only 4 or 8 allowed.\n");
3048 		return;
3049 	}
3050 
3051 	if (nb_fwd_lcores < res->num_tcs) {
3052 		printf("nb_cores shouldn't be less than number of TCs.\n");
3053 		return;
3054 	}
3055 	if (!strncmp(res->pfc_en, "on", 2))
3056 		pfc_en = 1;
3057 	else
3058 		pfc_en = 0;
3059 
3060 	/* DCB in VT mode */
3061 	if (!strncmp(res->vt_en, "on", 2))
3062 		ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3063 				(enum rte_eth_nb_tcs)res->num_tcs,
3064 				pfc_en);
3065 	else
3066 		ret = init_port_dcb_config(port_id, DCB_ENABLED,
3067 				(enum rte_eth_nb_tcs)res->num_tcs,
3068 				pfc_en);
3069 
3070 
3071 	if (ret != 0) {
3072 		printf("Cannot initialize network ports.\n");
3073 		return;
3074 	}
3075 
3076 	cmd_reconfig_device_queue(port_id, 1, 1);
3077 }
3078 
3079 cmdline_parse_token_string_t cmd_config_dcb_port =
3080         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3081 cmdline_parse_token_string_t cmd_config_dcb_config =
3082         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3083 cmdline_parse_token_num_t cmd_config_dcb_port_id =
3084 	TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16);
3085 cmdline_parse_token_string_t cmd_config_dcb_dcb =
3086         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3087 cmdline_parse_token_string_t cmd_config_dcb_vt =
3088         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3089 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3090         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3091 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3092         TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
3093 cmdline_parse_token_string_t cmd_config_dcb_pfc=
3094         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3095 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
3096         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
3097 
3098 cmdline_parse_inst_t cmd_config_dcb = {
3099 	.f = cmd_config_dcb_parsed,
3100 	.data = NULL,
3101 	.help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
3102 	.tokens = {
3103 		(void *)&cmd_config_dcb_port,
3104 		(void *)&cmd_config_dcb_config,
3105 		(void *)&cmd_config_dcb_port_id,
3106 		(void *)&cmd_config_dcb_dcb,
3107 		(void *)&cmd_config_dcb_vt,
3108 		(void *)&cmd_config_dcb_vt_en,
3109 		(void *)&cmd_config_dcb_num_tcs,
3110 		(void *)&cmd_config_dcb_pfc,
3111 		(void *)&cmd_config_dcb_pfc_en,
3112                 NULL,
3113         },
3114 };
3115 
3116 /* *** configure number of packets per burst *** */
3117 struct cmd_config_burst {
3118 	cmdline_fixed_string_t port;
3119 	cmdline_fixed_string_t keyword;
3120 	cmdline_fixed_string_t all;
3121 	cmdline_fixed_string_t name;
3122 	uint16_t value;
3123 };
3124 
3125 static void
3126 cmd_config_burst_parsed(void *parsed_result,
3127 			__attribute__((unused)) struct cmdline *cl,
3128 			__attribute__((unused)) void *data)
3129 {
3130 	struct cmd_config_burst *res = parsed_result;
3131 	struct rte_eth_dev_info dev_info;
3132 	uint16_t rec_nb_pkts;
3133 
3134 	if (!all_ports_stopped()) {
3135 		printf("Please stop all ports first\n");
3136 		return;
3137 	}
3138 
3139 	if (!strcmp(res->name, "burst")) {
3140 		if (res->value == 0) {
3141 			/* If user gives a value of zero, query the PMD for
3142 			 * its recommended Rx burst size. Testpmd uses a single
3143 			 * size for all ports, so assume all ports are the same
3144 			 * NIC model and use the values from Port 0.
3145 			 */
3146 			rte_eth_dev_info_get(0, &dev_info);
3147 			rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3148 
3149 			if (rec_nb_pkts == 0) {
3150 				printf("PMD does not recommend a burst size.\n"
3151 					"User provided value must be between"
3152 					" 1 and %d\n", MAX_PKT_BURST);
3153 				return;
3154 			} else if (rec_nb_pkts > MAX_PKT_BURST) {
3155 				printf("PMD recommended burst size of %d"
3156 					" exceeds maximum value of %d\n",
3157 					rec_nb_pkts, MAX_PKT_BURST);
3158 				return;
3159 			}
3160 			printf("Using PMD-provided burst value of %d\n",
3161 				rec_nb_pkts);
3162 			nb_pkt_per_burst = rec_nb_pkts;
3163 		} else if (res->value > MAX_PKT_BURST) {
3164 			printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
3165 			return;
3166 		} else
3167 			nb_pkt_per_burst = res->value;
3168 	} else {
3169 		printf("Unknown parameter\n");
3170 		return;
3171 	}
3172 
3173 	init_port_config();
3174 
3175 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3176 }
3177 
3178 cmdline_parse_token_string_t cmd_config_burst_port =
3179 	TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3180 cmdline_parse_token_string_t cmd_config_burst_keyword =
3181 	TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3182 cmdline_parse_token_string_t cmd_config_burst_all =
3183 	TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3184 cmdline_parse_token_string_t cmd_config_burst_name =
3185 	TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3186 cmdline_parse_token_num_t cmd_config_burst_value =
3187 	TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
3188 
3189 cmdline_parse_inst_t cmd_config_burst = {
3190 	.f = cmd_config_burst_parsed,
3191 	.data = NULL,
3192 	.help_str = "port config all burst <value>",
3193 	.tokens = {
3194 		(void *)&cmd_config_burst_port,
3195 		(void *)&cmd_config_burst_keyword,
3196 		(void *)&cmd_config_burst_all,
3197 		(void *)&cmd_config_burst_name,
3198 		(void *)&cmd_config_burst_value,
3199 		NULL,
3200 	},
3201 };
3202 
3203 /* *** configure rx/tx queues *** */
3204 struct cmd_config_thresh {
3205 	cmdline_fixed_string_t port;
3206 	cmdline_fixed_string_t keyword;
3207 	cmdline_fixed_string_t all;
3208 	cmdline_fixed_string_t name;
3209 	uint8_t value;
3210 };
3211 
3212 static void
3213 cmd_config_thresh_parsed(void *parsed_result,
3214 			__attribute__((unused)) struct cmdline *cl,
3215 			__attribute__((unused)) void *data)
3216 {
3217 	struct cmd_config_thresh *res = parsed_result;
3218 
3219 	if (!all_ports_stopped()) {
3220 		printf("Please stop all ports first\n");
3221 		return;
3222 	}
3223 
3224 	if (!strcmp(res->name, "txpt"))
3225 		tx_pthresh = res->value;
3226 	else if(!strcmp(res->name, "txht"))
3227 		tx_hthresh = res->value;
3228 	else if(!strcmp(res->name, "txwt"))
3229 		tx_wthresh = res->value;
3230 	else if(!strcmp(res->name, "rxpt"))
3231 		rx_pthresh = res->value;
3232 	else if(!strcmp(res->name, "rxht"))
3233 		rx_hthresh = res->value;
3234 	else if(!strcmp(res->name, "rxwt"))
3235 		rx_wthresh = res->value;
3236 	else {
3237 		printf("Unknown parameter\n");
3238 		return;
3239 	}
3240 
3241 	init_port_config();
3242 
3243 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3244 }
3245 
3246 cmdline_parse_token_string_t cmd_config_thresh_port =
3247 	TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3248 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3249 	TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3250 cmdline_parse_token_string_t cmd_config_thresh_all =
3251 	TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3252 cmdline_parse_token_string_t cmd_config_thresh_name =
3253 	TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3254 				"txpt#txht#txwt#rxpt#rxht#rxwt");
3255 cmdline_parse_token_num_t cmd_config_thresh_value =
3256 	TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
3257 
3258 cmdline_parse_inst_t cmd_config_thresh = {
3259 	.f = cmd_config_thresh_parsed,
3260 	.data = NULL,
3261 	.help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3262 	.tokens = {
3263 		(void *)&cmd_config_thresh_port,
3264 		(void *)&cmd_config_thresh_keyword,
3265 		(void *)&cmd_config_thresh_all,
3266 		(void *)&cmd_config_thresh_name,
3267 		(void *)&cmd_config_thresh_value,
3268 		NULL,
3269 	},
3270 };
3271 
3272 /* *** configure free/rs threshold *** */
3273 struct cmd_config_threshold {
3274 	cmdline_fixed_string_t port;
3275 	cmdline_fixed_string_t keyword;
3276 	cmdline_fixed_string_t all;
3277 	cmdline_fixed_string_t name;
3278 	uint16_t value;
3279 };
3280 
3281 static void
3282 cmd_config_threshold_parsed(void *parsed_result,
3283 			__attribute__((unused)) struct cmdline *cl,
3284 			__attribute__((unused)) void *data)
3285 {
3286 	struct cmd_config_threshold *res = parsed_result;
3287 
3288 	if (!all_ports_stopped()) {
3289 		printf("Please stop all ports first\n");
3290 		return;
3291 	}
3292 
3293 	if (!strcmp(res->name, "txfreet"))
3294 		tx_free_thresh = res->value;
3295 	else if (!strcmp(res->name, "txrst"))
3296 		tx_rs_thresh = res->value;
3297 	else if (!strcmp(res->name, "rxfreet"))
3298 		rx_free_thresh = res->value;
3299 	else {
3300 		printf("Unknown parameter\n");
3301 		return;
3302 	}
3303 
3304 	init_port_config();
3305 
3306 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3307 }
3308 
3309 cmdline_parse_token_string_t cmd_config_threshold_port =
3310 	TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3311 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3312 	TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3313 								"config");
3314 cmdline_parse_token_string_t cmd_config_threshold_all =
3315 	TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3316 cmdline_parse_token_string_t cmd_config_threshold_name =
3317 	TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3318 						"txfreet#txrst#rxfreet");
3319 cmdline_parse_token_num_t cmd_config_threshold_value =
3320 	TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
3321 
3322 cmdline_parse_inst_t cmd_config_threshold = {
3323 	.f = cmd_config_threshold_parsed,
3324 	.data = NULL,
3325 	.help_str = "port config all txfreet|txrst|rxfreet <value>",
3326 	.tokens = {
3327 		(void *)&cmd_config_threshold_port,
3328 		(void *)&cmd_config_threshold_keyword,
3329 		(void *)&cmd_config_threshold_all,
3330 		(void *)&cmd_config_threshold_name,
3331 		(void *)&cmd_config_threshold_value,
3332 		NULL,
3333 	},
3334 };
3335 
3336 /* *** stop *** */
3337 struct cmd_stop_result {
3338 	cmdline_fixed_string_t stop;
3339 };
3340 
3341 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
3342 			    __attribute__((unused)) struct cmdline *cl,
3343 			    __attribute__((unused)) void *data)
3344 {
3345 	stop_packet_forwarding();
3346 }
3347 
3348 cmdline_parse_token_string_t cmd_stop_stop =
3349 	TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3350 
3351 cmdline_parse_inst_t cmd_stop = {
3352 	.f = cmd_stop_parsed,
3353 	.data = NULL,
3354 	.help_str = "stop: Stop packet forwarding",
3355 	.tokens = {
3356 		(void *)&cmd_stop_stop,
3357 		NULL,
3358 	},
3359 };
3360 
3361 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3362 
3363 unsigned int
3364 parse_item_list(char* str, const char* item_name, unsigned int max_items,
3365 		unsigned int *parsed_items, int check_unique_values)
3366 {
3367 	unsigned int nb_item;
3368 	unsigned int value;
3369 	unsigned int i;
3370 	unsigned int j;
3371 	int value_ok;
3372 	char c;
3373 
3374 	/*
3375 	 * First parse all items in the list and store their value.
3376 	 */
3377 	value = 0;
3378 	nb_item = 0;
3379 	value_ok = 0;
3380 	for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3381 		c = str[i];
3382 		if ((c >= '0') && (c <= '9')) {
3383 			value = (unsigned int) (value * 10 + (c - '0'));
3384 			value_ok = 1;
3385 			continue;
3386 		}
3387 		if (c != ',') {
3388 			printf("character %c is not a decimal digit\n", c);
3389 			return 0;
3390 		}
3391 		if (! value_ok) {
3392 			printf("No valid value before comma\n");
3393 			return 0;
3394 		}
3395 		if (nb_item < max_items) {
3396 			parsed_items[nb_item] = value;
3397 			value_ok = 0;
3398 			value = 0;
3399 		}
3400 		nb_item++;
3401 	}
3402 	if (nb_item >= max_items) {
3403 		printf("Number of %s = %u > %u (maximum items)\n",
3404 		       item_name, nb_item + 1, max_items);
3405 		return 0;
3406 	}
3407 	parsed_items[nb_item++] = value;
3408 	if (! check_unique_values)
3409 		return nb_item;
3410 
3411 	/*
3412 	 * Then, check that all values in the list are differents.
3413 	 * No optimization here...
3414 	 */
3415 	for (i = 0; i < nb_item; i++) {
3416 		for (j = i + 1; j < nb_item; j++) {
3417 			if (parsed_items[j] == parsed_items[i]) {
3418 				printf("duplicated %s %u at index %u and %u\n",
3419 				       item_name, parsed_items[i], i, j);
3420 				return 0;
3421 			}
3422 		}
3423 	}
3424 	return nb_item;
3425 }
3426 
3427 struct cmd_set_list_result {
3428 	cmdline_fixed_string_t cmd_keyword;
3429 	cmdline_fixed_string_t list_name;
3430 	cmdline_fixed_string_t list_of_items;
3431 };
3432 
3433 static void cmd_set_list_parsed(void *parsed_result,
3434 				__attribute__((unused)) struct cmdline *cl,
3435 				__attribute__((unused)) void *data)
3436 {
3437 	struct cmd_set_list_result *res;
3438 	union {
3439 		unsigned int lcorelist[RTE_MAX_LCORE];
3440 		unsigned int portlist[RTE_MAX_ETHPORTS];
3441 	} parsed_items;
3442 	unsigned int nb_item;
3443 
3444 	if (test_done == 0) {
3445 		printf("Please stop forwarding first\n");
3446 		return;
3447 	}
3448 
3449 	res = parsed_result;
3450 	if (!strcmp(res->list_name, "corelist")) {
3451 		nb_item = parse_item_list(res->list_of_items, "core",
3452 					  RTE_MAX_LCORE,
3453 					  parsed_items.lcorelist, 1);
3454 		if (nb_item > 0) {
3455 			set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3456 			fwd_config_setup();
3457 		}
3458 		return;
3459 	}
3460 	if (!strcmp(res->list_name, "portlist")) {
3461 		nb_item = parse_item_list(res->list_of_items, "port",
3462 					  RTE_MAX_ETHPORTS,
3463 					  parsed_items.portlist, 1);
3464 		if (nb_item > 0) {
3465 			set_fwd_ports_list(parsed_items.portlist, nb_item);
3466 			fwd_config_setup();
3467 		}
3468 	}
3469 }
3470 
3471 cmdline_parse_token_string_t cmd_set_list_keyword =
3472 	TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3473 				 "set");
3474 cmdline_parse_token_string_t cmd_set_list_name =
3475 	TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3476 				 "corelist#portlist");
3477 cmdline_parse_token_string_t cmd_set_list_of_items =
3478 	TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3479 				 NULL);
3480 
3481 cmdline_parse_inst_t cmd_set_fwd_list = {
3482 	.f = cmd_set_list_parsed,
3483 	.data = NULL,
3484 	.help_str = "set corelist|portlist <list0[,list1]*>",
3485 	.tokens = {
3486 		(void *)&cmd_set_list_keyword,
3487 		(void *)&cmd_set_list_name,
3488 		(void *)&cmd_set_list_of_items,
3489 		NULL,
3490 	},
3491 };
3492 
3493 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3494 
3495 struct cmd_setmask_result {
3496 	cmdline_fixed_string_t set;
3497 	cmdline_fixed_string_t mask;
3498 	uint64_t hexavalue;
3499 };
3500 
3501 static void cmd_set_mask_parsed(void *parsed_result,
3502 				__attribute__((unused)) struct cmdline *cl,
3503 				__attribute__((unused)) void *data)
3504 {
3505 	struct cmd_setmask_result *res = parsed_result;
3506 
3507 	if (test_done == 0) {
3508 		printf("Please stop forwarding first\n");
3509 		return;
3510 	}
3511 	if (!strcmp(res->mask, "coremask")) {
3512 		set_fwd_lcores_mask(res->hexavalue);
3513 		fwd_config_setup();
3514 	} else if (!strcmp(res->mask, "portmask")) {
3515 		set_fwd_ports_mask(res->hexavalue);
3516 		fwd_config_setup();
3517 	}
3518 }
3519 
3520 cmdline_parse_token_string_t cmd_setmask_set =
3521 	TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3522 cmdline_parse_token_string_t cmd_setmask_mask =
3523 	TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3524 				 "coremask#portmask");
3525 cmdline_parse_token_num_t cmd_setmask_value =
3526 	TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
3527 
3528 cmdline_parse_inst_t cmd_set_fwd_mask = {
3529 	.f = cmd_set_mask_parsed,
3530 	.data = NULL,
3531 	.help_str = "set coremask|portmask <hexadecimal value>",
3532 	.tokens = {
3533 		(void *)&cmd_setmask_set,
3534 		(void *)&cmd_setmask_mask,
3535 		(void *)&cmd_setmask_value,
3536 		NULL,
3537 	},
3538 };
3539 
3540 /*
3541  * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3542  */
3543 struct cmd_set_result {
3544 	cmdline_fixed_string_t set;
3545 	cmdline_fixed_string_t what;
3546 	uint16_t value;
3547 };
3548 
3549 static void cmd_set_parsed(void *parsed_result,
3550 			   __attribute__((unused)) struct cmdline *cl,
3551 			   __attribute__((unused)) void *data)
3552 {
3553 	struct cmd_set_result *res = parsed_result;
3554 	if (!strcmp(res->what, "nbport")) {
3555 		set_fwd_ports_number(res->value);
3556 		fwd_config_setup();
3557 	} else if (!strcmp(res->what, "nbcore")) {
3558 		set_fwd_lcores_number(res->value);
3559 		fwd_config_setup();
3560 	} else if (!strcmp(res->what, "burst"))
3561 		set_nb_pkt_per_burst(res->value);
3562 	else if (!strcmp(res->what, "verbose"))
3563 		set_verbose_level(res->value);
3564 }
3565 
3566 cmdline_parse_token_string_t cmd_set_set =
3567 	TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3568 cmdline_parse_token_string_t cmd_set_what =
3569 	TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3570 				 "nbport#nbcore#burst#verbose");
3571 cmdline_parse_token_num_t cmd_set_value =
3572 	TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
3573 
3574 cmdline_parse_inst_t cmd_set_numbers = {
3575 	.f = cmd_set_parsed,
3576 	.data = NULL,
3577 	.help_str = "set nbport|nbcore|burst|verbose <value>",
3578 	.tokens = {
3579 		(void *)&cmd_set_set,
3580 		(void *)&cmd_set_what,
3581 		(void *)&cmd_set_value,
3582 		NULL,
3583 	},
3584 };
3585 
3586 /* *** SET LOG LEVEL CONFIGURATION *** */
3587 
3588 struct cmd_set_log_result {
3589 	cmdline_fixed_string_t set;
3590 	cmdline_fixed_string_t log;
3591 	cmdline_fixed_string_t type;
3592 	uint32_t level;
3593 };
3594 
3595 static void
3596 cmd_set_log_parsed(void *parsed_result,
3597 		   __attribute__((unused)) struct cmdline *cl,
3598 		   __attribute__((unused)) void *data)
3599 {
3600 	struct cmd_set_log_result *res;
3601 	int ret;
3602 
3603 	res = parsed_result;
3604 	if (!strcmp(res->type, "global"))
3605 		rte_log_set_global_level(res->level);
3606 	else {
3607 		ret = rte_log_set_level_regexp(res->type, res->level);
3608 		if (ret < 0)
3609 			printf("Unable to set log level\n");
3610 	}
3611 }
3612 
3613 cmdline_parse_token_string_t cmd_set_log_set =
3614 	TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3615 cmdline_parse_token_string_t cmd_set_log_log =
3616 	TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3617 cmdline_parse_token_string_t cmd_set_log_type =
3618 	TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3619 cmdline_parse_token_num_t cmd_set_log_level =
3620 	TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, UINT32);
3621 
3622 cmdline_parse_inst_t cmd_set_log = {
3623 	.f = cmd_set_log_parsed,
3624 	.data = NULL,
3625 	.help_str = "set log global|<type> <level>",
3626 	.tokens = {
3627 		(void *)&cmd_set_log_set,
3628 		(void *)&cmd_set_log_log,
3629 		(void *)&cmd_set_log_type,
3630 		(void *)&cmd_set_log_level,
3631 		NULL,
3632 	},
3633 };
3634 
3635 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3636 
3637 struct cmd_set_txpkts_result {
3638 	cmdline_fixed_string_t cmd_keyword;
3639 	cmdline_fixed_string_t txpkts;
3640 	cmdline_fixed_string_t seg_lengths;
3641 };
3642 
3643 static void
3644 cmd_set_txpkts_parsed(void *parsed_result,
3645 		      __attribute__((unused)) struct cmdline *cl,
3646 		      __attribute__((unused)) void *data)
3647 {
3648 	struct cmd_set_txpkts_result *res;
3649 	unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3650 	unsigned int nb_segs;
3651 
3652 	res = parsed_result;
3653 	nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3654 				  RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3655 	if (nb_segs > 0)
3656 		set_tx_pkt_segments(seg_lengths, nb_segs);
3657 }
3658 
3659 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3660 	TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3661 				 cmd_keyword, "set");
3662 cmdline_parse_token_string_t cmd_set_txpkts_name =
3663 	TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3664 				 txpkts, "txpkts");
3665 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3666 	TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3667 				 seg_lengths, NULL);
3668 
3669 cmdline_parse_inst_t cmd_set_txpkts = {
3670 	.f = cmd_set_txpkts_parsed,
3671 	.data = NULL,
3672 	.help_str = "set txpkts <len0[,len1]*>",
3673 	.tokens = {
3674 		(void *)&cmd_set_txpkts_keyword,
3675 		(void *)&cmd_set_txpkts_name,
3676 		(void *)&cmd_set_txpkts_lengths,
3677 		NULL,
3678 	},
3679 };
3680 
3681 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
3682 
3683 struct cmd_set_txsplit_result {
3684 	cmdline_fixed_string_t cmd_keyword;
3685 	cmdline_fixed_string_t txsplit;
3686 	cmdline_fixed_string_t mode;
3687 };
3688 
3689 static void
3690 cmd_set_txsplit_parsed(void *parsed_result,
3691 		      __attribute__((unused)) struct cmdline *cl,
3692 		      __attribute__((unused)) void *data)
3693 {
3694 	struct cmd_set_txsplit_result *res;
3695 
3696 	res = parsed_result;
3697 	set_tx_pkt_split(res->mode);
3698 }
3699 
3700 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
3701 	TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3702 				 cmd_keyword, "set");
3703 cmdline_parse_token_string_t cmd_set_txsplit_name =
3704 	TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3705 				 txsplit, "txsplit");
3706 cmdline_parse_token_string_t cmd_set_txsplit_mode =
3707 	TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3708 				 mode, NULL);
3709 
3710 cmdline_parse_inst_t cmd_set_txsplit = {
3711 	.f = cmd_set_txsplit_parsed,
3712 	.data = NULL,
3713 	.help_str = "set txsplit on|off|rand",
3714 	.tokens = {
3715 		(void *)&cmd_set_txsplit_keyword,
3716 		(void *)&cmd_set_txsplit_name,
3717 		(void *)&cmd_set_txsplit_mode,
3718 		NULL,
3719 	},
3720 };
3721 
3722 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
3723 struct cmd_rx_vlan_filter_all_result {
3724 	cmdline_fixed_string_t rx_vlan;
3725 	cmdline_fixed_string_t what;
3726 	cmdline_fixed_string_t all;
3727 	portid_t port_id;
3728 };
3729 
3730 static void
3731 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
3732 			      __attribute__((unused)) struct cmdline *cl,
3733 			      __attribute__((unused)) void *data)
3734 {
3735 	struct cmd_rx_vlan_filter_all_result *res = parsed_result;
3736 
3737 	if (!strcmp(res->what, "add"))
3738 		rx_vlan_all_filter_set(res->port_id, 1);
3739 	else
3740 		rx_vlan_all_filter_set(res->port_id, 0);
3741 }
3742 
3743 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
3744 	TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3745 				 rx_vlan, "rx_vlan");
3746 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
3747 	TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3748 				 what, "add#rm");
3749 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
3750 	TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3751 				 all, "all");
3752 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
3753 	TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3754 			      port_id, UINT16);
3755 
3756 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
3757 	.f = cmd_rx_vlan_filter_all_parsed,
3758 	.data = NULL,
3759 	.help_str = "rx_vlan add|rm all <port_id>: "
3760 		"Add/Remove all identifiers to/from the set of VLAN "
3761 		"identifiers filtered by a port",
3762 	.tokens = {
3763 		(void *)&cmd_rx_vlan_filter_all_rx_vlan,
3764 		(void *)&cmd_rx_vlan_filter_all_what,
3765 		(void *)&cmd_rx_vlan_filter_all_all,
3766 		(void *)&cmd_rx_vlan_filter_all_portid,
3767 		NULL,
3768 	},
3769 };
3770 
3771 /* *** VLAN OFFLOAD SET ON A PORT *** */
3772 struct cmd_vlan_offload_result {
3773 	cmdline_fixed_string_t vlan;
3774 	cmdline_fixed_string_t set;
3775 	cmdline_fixed_string_t vlan_type;
3776 	cmdline_fixed_string_t what;
3777 	cmdline_fixed_string_t on;
3778 	cmdline_fixed_string_t port_id;
3779 };
3780 
3781 static void
3782 cmd_vlan_offload_parsed(void *parsed_result,
3783 			  __attribute__((unused)) struct cmdline *cl,
3784 			  __attribute__((unused)) void *data)
3785 {
3786 	int on;
3787 	struct cmd_vlan_offload_result *res = parsed_result;
3788 	char *str;
3789 	int i, len = 0;
3790 	portid_t port_id = 0;
3791 	unsigned int tmp;
3792 
3793 	str = res->port_id;
3794 	len = strnlen(str, STR_TOKEN_SIZE);
3795 	i = 0;
3796 	/* Get port_id first */
3797 	while(i < len){
3798 		if(str[i] == ',')
3799 			break;
3800 
3801 		i++;
3802 	}
3803 	str[i]='\0';
3804 	tmp = strtoul(str, NULL, 0);
3805 	/* If port_id greater that what portid_t can represent, return */
3806 	if(tmp >= RTE_MAX_ETHPORTS)
3807 		return;
3808 	port_id = (portid_t)tmp;
3809 
3810 	if (!strcmp(res->on, "on"))
3811 		on = 1;
3812 	else
3813 		on = 0;
3814 
3815 	if (!strcmp(res->what, "strip"))
3816 		rx_vlan_strip_set(port_id,  on);
3817 	else if(!strcmp(res->what, "stripq")){
3818 		uint16_t queue_id = 0;
3819 
3820 		/* No queue_id, return */
3821 		if(i + 1 >= len) {
3822 			printf("must specify (port,queue_id)\n");
3823 			return;
3824 		}
3825 		tmp = strtoul(str + i + 1, NULL, 0);
3826 		/* If queue_id greater that what 16-bits can represent, return */
3827 		if(tmp > 0xffff)
3828 			return;
3829 
3830 		queue_id = (uint16_t)tmp;
3831 		rx_vlan_strip_set_on_queue(port_id, queue_id, on);
3832 	}
3833 	else if (!strcmp(res->what, "filter"))
3834 		rx_vlan_filter_set(port_id, on);
3835 	else
3836 		vlan_extend_set(port_id, on);
3837 
3838 	return;
3839 }
3840 
3841 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
3842 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3843 				 vlan, "vlan");
3844 cmdline_parse_token_string_t cmd_vlan_offload_set =
3845 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3846 				 set, "set");
3847 cmdline_parse_token_string_t cmd_vlan_offload_what =
3848 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3849 				 what, "strip#filter#qinq#stripq");
3850 cmdline_parse_token_string_t cmd_vlan_offload_on =
3851 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3852 			      on, "on#off");
3853 cmdline_parse_token_string_t cmd_vlan_offload_portid =
3854 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3855 			      port_id, NULL);
3856 
3857 cmdline_parse_inst_t cmd_vlan_offload = {
3858 	.f = cmd_vlan_offload_parsed,
3859 	.data = NULL,
3860 	.help_str = "vlan set strip|filter|qinq|stripq on|off "
3861 		"<port_id[,queue_id]>: "
3862 		"Filter/Strip for rx side qinq(extended) for both rx/tx sides",
3863 	.tokens = {
3864 		(void *)&cmd_vlan_offload_vlan,
3865 		(void *)&cmd_vlan_offload_set,
3866 		(void *)&cmd_vlan_offload_what,
3867 		(void *)&cmd_vlan_offload_on,
3868 		(void *)&cmd_vlan_offload_portid,
3869 		NULL,
3870 	},
3871 };
3872 
3873 /* *** VLAN TPID SET ON A PORT *** */
3874 struct cmd_vlan_tpid_result {
3875 	cmdline_fixed_string_t vlan;
3876 	cmdline_fixed_string_t set;
3877 	cmdline_fixed_string_t vlan_type;
3878 	cmdline_fixed_string_t what;
3879 	uint16_t tp_id;
3880 	portid_t port_id;
3881 };
3882 
3883 static void
3884 cmd_vlan_tpid_parsed(void *parsed_result,
3885 			  __attribute__((unused)) struct cmdline *cl,
3886 			  __attribute__((unused)) void *data)
3887 {
3888 	struct cmd_vlan_tpid_result *res = parsed_result;
3889 	enum rte_vlan_type vlan_type;
3890 
3891 	if (!strcmp(res->vlan_type, "inner"))
3892 		vlan_type = ETH_VLAN_TYPE_INNER;
3893 	else if (!strcmp(res->vlan_type, "outer"))
3894 		vlan_type = ETH_VLAN_TYPE_OUTER;
3895 	else {
3896 		printf("Unknown vlan type\n");
3897 		return;
3898 	}
3899 	vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
3900 }
3901 
3902 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
3903 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3904 				 vlan, "vlan");
3905 cmdline_parse_token_string_t cmd_vlan_tpid_set =
3906 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3907 				 set, "set");
3908 cmdline_parse_token_string_t cmd_vlan_type =
3909 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3910 				 vlan_type, "inner#outer");
3911 cmdline_parse_token_string_t cmd_vlan_tpid_what =
3912 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3913 				 what, "tpid");
3914 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
3915 	TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3916 			      tp_id, UINT16);
3917 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
3918 	TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3919 			      port_id, UINT16);
3920 
3921 cmdline_parse_inst_t cmd_vlan_tpid = {
3922 	.f = cmd_vlan_tpid_parsed,
3923 	.data = NULL,
3924 	.help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
3925 		"Set the VLAN Ether type",
3926 	.tokens = {
3927 		(void *)&cmd_vlan_tpid_vlan,
3928 		(void *)&cmd_vlan_tpid_set,
3929 		(void *)&cmd_vlan_type,
3930 		(void *)&cmd_vlan_tpid_what,
3931 		(void *)&cmd_vlan_tpid_tpid,
3932 		(void *)&cmd_vlan_tpid_portid,
3933 		NULL,
3934 	},
3935 };
3936 
3937 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
3938 struct cmd_rx_vlan_filter_result {
3939 	cmdline_fixed_string_t rx_vlan;
3940 	cmdline_fixed_string_t what;
3941 	uint16_t vlan_id;
3942 	portid_t port_id;
3943 };
3944 
3945 static void
3946 cmd_rx_vlan_filter_parsed(void *parsed_result,
3947 			  __attribute__((unused)) struct cmdline *cl,
3948 			  __attribute__((unused)) void *data)
3949 {
3950 	struct cmd_rx_vlan_filter_result *res = parsed_result;
3951 
3952 	if (!strcmp(res->what, "add"))
3953 		rx_vft_set(res->port_id, res->vlan_id, 1);
3954 	else
3955 		rx_vft_set(res->port_id, res->vlan_id, 0);
3956 }
3957 
3958 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
3959 	TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3960 				 rx_vlan, "rx_vlan");
3961 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
3962 	TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3963 				 what, "add#rm");
3964 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
3965 	TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3966 			      vlan_id, UINT16);
3967 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
3968 	TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3969 			      port_id, UINT16);
3970 
3971 cmdline_parse_inst_t cmd_rx_vlan_filter = {
3972 	.f = cmd_rx_vlan_filter_parsed,
3973 	.data = NULL,
3974 	.help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
3975 		"Add/Remove a VLAN identifier to/from the set of VLAN "
3976 		"identifiers filtered by a port",
3977 	.tokens = {
3978 		(void *)&cmd_rx_vlan_filter_rx_vlan,
3979 		(void *)&cmd_rx_vlan_filter_what,
3980 		(void *)&cmd_rx_vlan_filter_vlanid,
3981 		(void *)&cmd_rx_vlan_filter_portid,
3982 		NULL,
3983 	},
3984 };
3985 
3986 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3987 struct cmd_tx_vlan_set_result {
3988 	cmdline_fixed_string_t tx_vlan;
3989 	cmdline_fixed_string_t set;
3990 	portid_t port_id;
3991 	uint16_t vlan_id;
3992 };
3993 
3994 static void
3995 cmd_tx_vlan_set_parsed(void *parsed_result,
3996 		       __attribute__((unused)) struct cmdline *cl,
3997 		       __attribute__((unused)) void *data)
3998 {
3999 	struct cmd_tx_vlan_set_result *res = parsed_result;
4000 
4001 	if (!port_is_stopped(res->port_id)) {
4002 		printf("Please stop port %d first\n", res->port_id);
4003 		return;
4004 	}
4005 
4006 	tx_vlan_set(res->port_id, res->vlan_id);
4007 
4008 	cmd_reconfig_device_queue(res->port_id, 1, 1);
4009 }
4010 
4011 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4012 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4013 				 tx_vlan, "tx_vlan");
4014 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4015 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4016 				 set, "set");
4017 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4018 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4019 			      port_id, UINT16);
4020 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
4021 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4022 			      vlan_id, UINT16);
4023 
4024 cmdline_parse_inst_t cmd_tx_vlan_set = {
4025 	.f = cmd_tx_vlan_set_parsed,
4026 	.data = NULL,
4027 	.help_str = "tx_vlan set <port_id> <vlan_id>: "
4028 		"Enable hardware insertion of a single VLAN header "
4029 		"with a given TAG Identifier in packets sent on a port",
4030 	.tokens = {
4031 		(void *)&cmd_tx_vlan_set_tx_vlan,
4032 		(void *)&cmd_tx_vlan_set_set,
4033 		(void *)&cmd_tx_vlan_set_portid,
4034 		(void *)&cmd_tx_vlan_set_vlanid,
4035 		NULL,
4036 	},
4037 };
4038 
4039 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4040 struct cmd_tx_vlan_set_qinq_result {
4041 	cmdline_fixed_string_t tx_vlan;
4042 	cmdline_fixed_string_t set;
4043 	portid_t port_id;
4044 	uint16_t vlan_id;
4045 	uint16_t vlan_id_outer;
4046 };
4047 
4048 static void
4049 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4050 			    __attribute__((unused)) struct cmdline *cl,
4051 			    __attribute__((unused)) void *data)
4052 {
4053 	struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
4054 
4055 	if (!port_is_stopped(res->port_id)) {
4056 		printf("Please stop port %d first\n", res->port_id);
4057 		return;
4058 	}
4059 
4060 	tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
4061 
4062 	cmd_reconfig_device_queue(res->port_id, 1, 1);
4063 }
4064 
4065 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
4066 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4067 		tx_vlan, "tx_vlan");
4068 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
4069 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4070 		set, "set");
4071 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
4072 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4073 		port_id, UINT16);
4074 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
4075 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4076 		vlan_id, UINT16);
4077 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
4078 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4079 		vlan_id_outer, UINT16);
4080 
4081 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
4082 	.f = cmd_tx_vlan_set_qinq_parsed,
4083 	.data = NULL,
4084 	.help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
4085 		"Enable hardware insertion of double VLAN header "
4086 		"with given TAG Identifiers in packets sent on a port",
4087 	.tokens = {
4088 		(void *)&cmd_tx_vlan_set_qinq_tx_vlan,
4089 		(void *)&cmd_tx_vlan_set_qinq_set,
4090 		(void *)&cmd_tx_vlan_set_qinq_portid,
4091 		(void *)&cmd_tx_vlan_set_qinq_vlanid,
4092 		(void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
4093 		NULL,
4094 	},
4095 };
4096 
4097 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
4098 struct cmd_tx_vlan_set_pvid_result {
4099 	cmdline_fixed_string_t tx_vlan;
4100 	cmdline_fixed_string_t set;
4101 	cmdline_fixed_string_t pvid;
4102 	portid_t port_id;
4103 	uint16_t vlan_id;
4104 	cmdline_fixed_string_t mode;
4105 };
4106 
4107 static void
4108 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
4109 			    __attribute__((unused)) struct cmdline *cl,
4110 			    __attribute__((unused)) void *data)
4111 {
4112 	struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
4113 
4114 	if (strcmp(res->mode, "on") == 0)
4115 		tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
4116 	else
4117 		tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
4118 }
4119 
4120 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
4121 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4122 				 tx_vlan, "tx_vlan");
4123 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
4124 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4125 				 set, "set");
4126 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
4127 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4128 				 pvid, "pvid");
4129 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
4130 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4131 			     port_id, UINT16);
4132 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
4133 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4134 			      vlan_id, UINT16);
4135 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
4136 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4137 				 mode, "on#off");
4138 
4139 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
4140 	.f = cmd_tx_vlan_set_pvid_parsed,
4141 	.data = NULL,
4142 	.help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
4143 	.tokens = {
4144 		(void *)&cmd_tx_vlan_set_pvid_tx_vlan,
4145 		(void *)&cmd_tx_vlan_set_pvid_set,
4146 		(void *)&cmd_tx_vlan_set_pvid_pvid,
4147 		(void *)&cmd_tx_vlan_set_pvid_port_id,
4148 		(void *)&cmd_tx_vlan_set_pvid_vlan_id,
4149 		(void *)&cmd_tx_vlan_set_pvid_mode,
4150 		NULL,
4151 	},
4152 };
4153 
4154 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4155 struct cmd_tx_vlan_reset_result {
4156 	cmdline_fixed_string_t tx_vlan;
4157 	cmdline_fixed_string_t reset;
4158 	portid_t port_id;
4159 };
4160 
4161 static void
4162 cmd_tx_vlan_reset_parsed(void *parsed_result,
4163 			 __attribute__((unused)) struct cmdline *cl,
4164 			 __attribute__((unused)) void *data)
4165 {
4166 	struct cmd_tx_vlan_reset_result *res = parsed_result;
4167 
4168 	if (!port_is_stopped(res->port_id)) {
4169 		printf("Please stop port %d first\n", res->port_id);
4170 		return;
4171 	}
4172 
4173 	tx_vlan_reset(res->port_id);
4174 
4175 	cmd_reconfig_device_queue(res->port_id, 1, 1);
4176 }
4177 
4178 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4179 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4180 				 tx_vlan, "tx_vlan");
4181 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4182 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4183 				 reset, "reset");
4184 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4185 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4186 			      port_id, UINT16);
4187 
4188 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4189 	.f = cmd_tx_vlan_reset_parsed,
4190 	.data = NULL,
4191 	.help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4192 		"VLAN header in packets sent on a port",
4193 	.tokens = {
4194 		(void *)&cmd_tx_vlan_reset_tx_vlan,
4195 		(void *)&cmd_tx_vlan_reset_reset,
4196 		(void *)&cmd_tx_vlan_reset_portid,
4197 		NULL,
4198 	},
4199 };
4200 
4201 
4202 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4203 struct cmd_csum_result {
4204 	cmdline_fixed_string_t csum;
4205 	cmdline_fixed_string_t mode;
4206 	cmdline_fixed_string_t proto;
4207 	cmdline_fixed_string_t hwsw;
4208 	portid_t port_id;
4209 };
4210 
4211 static void
4212 csum_show(int port_id)
4213 {
4214 	struct rte_eth_dev_info dev_info;
4215 	uint64_t tx_offloads;
4216 
4217 	tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4218 	printf("Parse tunnel is %s\n",
4219 		(ports[port_id].parse_tunnel) ? "on" : "off");
4220 	printf("IP checksum offload is %s\n",
4221 		(tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4222 	printf("UDP checksum offload is %s\n",
4223 		(tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4224 	printf("TCP checksum offload is %s\n",
4225 		(tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4226 	printf("SCTP checksum offload is %s\n",
4227 		(tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4228 	printf("Outer-Ip checksum offload is %s\n",
4229 		(tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4230 	printf("Outer-Udp checksum offload is %s\n",
4231 		(tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
4232 
4233 	/* display warnings if configuration is not supported by the NIC */
4234 	rte_eth_dev_info_get(port_id, &dev_info);
4235 	if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
4236 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4237 		printf("Warning: hardware IP checksum enabled but not "
4238 			"supported by port %d\n", port_id);
4239 	}
4240 	if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
4241 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
4242 		printf("Warning: hardware UDP checksum enabled but not "
4243 			"supported by port %d\n", port_id);
4244 	}
4245 	if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
4246 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
4247 		printf("Warning: hardware TCP checksum enabled but not "
4248 			"supported by port %d\n", port_id);
4249 	}
4250 	if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
4251 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4252 		printf("Warning: hardware SCTP checksum enabled but not "
4253 			"supported by port %d\n", port_id);
4254 	}
4255 	if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4256 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4257 		printf("Warning: hardware outer IP checksum enabled but not "
4258 			"supported by port %d\n", port_id);
4259 	}
4260 	if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
4261 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)
4262 			== 0) {
4263 		printf("Warning: hardware outer UDP checksum enabled but not "
4264 			"supported by port %d\n", port_id);
4265 	}
4266 }
4267 
4268 static void
4269 cmd_csum_parsed(void *parsed_result,
4270 		       __attribute__((unused)) struct cmdline *cl,
4271 		       __attribute__((unused)) void *data)
4272 {
4273 	struct cmd_csum_result *res = parsed_result;
4274 	int hw = 0;
4275 	uint64_t csum_offloads = 0;
4276 	struct rte_eth_dev_info dev_info;
4277 
4278 	if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4279 		printf("invalid port %d\n", res->port_id);
4280 		return;
4281 	}
4282 	if (!port_is_stopped(res->port_id)) {
4283 		printf("Please stop port %d first\n", res->port_id);
4284 		return;
4285 	}
4286 
4287 	rte_eth_dev_info_get(res->port_id, &dev_info);
4288 	if (!strcmp(res->mode, "set")) {
4289 
4290 		if (!strcmp(res->hwsw, "hw"))
4291 			hw = 1;
4292 
4293 		if (!strcmp(res->proto, "ip")) {
4294 			if (hw == 0 || (dev_info.tx_offload_capa &
4295 						DEV_TX_OFFLOAD_IPV4_CKSUM)) {
4296 				csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
4297 			} else {
4298 				printf("IP checksum offload is not supported "
4299 				       "by port %u\n", res->port_id);
4300 			}
4301 		} else if (!strcmp(res->proto, "udp")) {
4302 			if (hw == 0 || (dev_info.tx_offload_capa &
4303 						DEV_TX_OFFLOAD_UDP_CKSUM)) {
4304 				csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
4305 			} else {
4306 				printf("UDP checksum offload is not supported "
4307 				       "by port %u\n", res->port_id);
4308 			}
4309 		} else if (!strcmp(res->proto, "tcp")) {
4310 			if (hw == 0 || (dev_info.tx_offload_capa &
4311 						DEV_TX_OFFLOAD_TCP_CKSUM)) {
4312 				csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
4313 			} else {
4314 				printf("TCP checksum offload is not supported "
4315 				       "by port %u\n", res->port_id);
4316 			}
4317 		} else if (!strcmp(res->proto, "sctp")) {
4318 			if (hw == 0 || (dev_info.tx_offload_capa &
4319 						DEV_TX_OFFLOAD_SCTP_CKSUM)) {
4320 				csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
4321 			} else {
4322 				printf("SCTP checksum offload is not supported "
4323 				       "by port %u\n", res->port_id);
4324 			}
4325 		} else if (!strcmp(res->proto, "outer-ip")) {
4326 			if (hw == 0 || (dev_info.tx_offload_capa &
4327 					DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4328 				csum_offloads |=
4329 						DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4330 			} else {
4331 				printf("Outer IP checksum offload is not "
4332 				       "supported by port %u\n", res->port_id);
4333 			}
4334 		} else if (!strcmp(res->proto, "outer-udp")) {
4335 			if (hw == 0 || (dev_info.tx_offload_capa &
4336 					DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
4337 				csum_offloads |=
4338 						DEV_TX_OFFLOAD_OUTER_UDP_CKSUM;
4339 			} else {
4340 				printf("Outer UDP checksum offload is not "
4341 				       "supported by port %u\n", res->port_id);
4342 			}
4343 		}
4344 
4345 		if (hw) {
4346 			ports[res->port_id].dev_conf.txmode.offloads |=
4347 							csum_offloads;
4348 		} else {
4349 			ports[res->port_id].dev_conf.txmode.offloads &=
4350 							(~csum_offloads);
4351 		}
4352 	}
4353 	csum_show(res->port_id);
4354 
4355 	cmd_reconfig_device_queue(res->port_id, 1, 1);
4356 }
4357 
4358 cmdline_parse_token_string_t cmd_csum_csum =
4359 	TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4360 				csum, "csum");
4361 cmdline_parse_token_string_t cmd_csum_mode =
4362 	TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4363 				mode, "set");
4364 cmdline_parse_token_string_t cmd_csum_proto =
4365 	TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4366 				proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
4367 cmdline_parse_token_string_t cmd_csum_hwsw =
4368 	TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4369 				hwsw, "hw#sw");
4370 cmdline_parse_token_num_t cmd_csum_portid =
4371 	TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4372 				port_id, UINT16);
4373 
4374 cmdline_parse_inst_t cmd_csum_set = {
4375 	.f = cmd_csum_parsed,
4376 	.data = NULL,
4377 	.help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
4378 		"Enable/Disable hardware calculation of L3/L4 checksum when "
4379 		"using csum forward engine",
4380 	.tokens = {
4381 		(void *)&cmd_csum_csum,
4382 		(void *)&cmd_csum_mode,
4383 		(void *)&cmd_csum_proto,
4384 		(void *)&cmd_csum_hwsw,
4385 		(void *)&cmd_csum_portid,
4386 		NULL,
4387 	},
4388 };
4389 
4390 cmdline_parse_token_string_t cmd_csum_mode_show =
4391 	TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4392 				mode, "show");
4393 
4394 cmdline_parse_inst_t cmd_csum_show = {
4395 	.f = cmd_csum_parsed,
4396 	.data = NULL,
4397 	.help_str = "csum show <port_id>: Show checksum offload configuration",
4398 	.tokens = {
4399 		(void *)&cmd_csum_csum,
4400 		(void *)&cmd_csum_mode_show,
4401 		(void *)&cmd_csum_portid,
4402 		NULL,
4403 	},
4404 };
4405 
4406 /* Enable/disable tunnel parsing */
4407 struct cmd_csum_tunnel_result {
4408 	cmdline_fixed_string_t csum;
4409 	cmdline_fixed_string_t parse;
4410 	cmdline_fixed_string_t onoff;
4411 	portid_t port_id;
4412 };
4413 
4414 static void
4415 cmd_csum_tunnel_parsed(void *parsed_result,
4416 		       __attribute__((unused)) struct cmdline *cl,
4417 		       __attribute__((unused)) void *data)
4418 {
4419 	struct cmd_csum_tunnel_result *res = parsed_result;
4420 
4421 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4422 		return;
4423 
4424 	if (!strcmp(res->onoff, "on"))
4425 		ports[res->port_id].parse_tunnel = 1;
4426 	else
4427 		ports[res->port_id].parse_tunnel = 0;
4428 
4429 	csum_show(res->port_id);
4430 }
4431 
4432 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4433 	TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4434 				csum, "csum");
4435 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4436 	TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4437 				parse, "parse-tunnel");
4438 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4439 	TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4440 				onoff, "on#off");
4441 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4442 	TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4443 				port_id, UINT16);
4444 
4445 cmdline_parse_inst_t cmd_csum_tunnel = {
4446 	.f = cmd_csum_tunnel_parsed,
4447 	.data = NULL,
4448 	.help_str = "csum parse-tunnel on|off <port_id>: "
4449 		"Enable/Disable parsing of tunnels for csum engine",
4450 	.tokens = {
4451 		(void *)&cmd_csum_tunnel_csum,
4452 		(void *)&cmd_csum_tunnel_parse,
4453 		(void *)&cmd_csum_tunnel_onoff,
4454 		(void *)&cmd_csum_tunnel_portid,
4455 		NULL,
4456 	},
4457 };
4458 
4459 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4460 struct cmd_tso_set_result {
4461 	cmdline_fixed_string_t tso;
4462 	cmdline_fixed_string_t mode;
4463 	uint16_t tso_segsz;
4464 	portid_t port_id;
4465 };
4466 
4467 static void
4468 cmd_tso_set_parsed(void *parsed_result,
4469 		       __attribute__((unused)) struct cmdline *cl,
4470 		       __attribute__((unused)) void *data)
4471 {
4472 	struct cmd_tso_set_result *res = parsed_result;
4473 	struct rte_eth_dev_info dev_info;
4474 
4475 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4476 		return;
4477 	if (!port_is_stopped(res->port_id)) {
4478 		printf("Please stop port %d first\n", res->port_id);
4479 		return;
4480 	}
4481 
4482 	if (!strcmp(res->mode, "set"))
4483 		ports[res->port_id].tso_segsz = res->tso_segsz;
4484 
4485 	rte_eth_dev_info_get(res->port_id, &dev_info);
4486 	if ((ports[res->port_id].tso_segsz != 0) &&
4487 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4488 		printf("Error: TSO is not supported by port %d\n",
4489 		       res->port_id);
4490 		return;
4491 	}
4492 
4493 	if (ports[res->port_id].tso_segsz == 0) {
4494 		ports[res->port_id].dev_conf.txmode.offloads &=
4495 						~DEV_TX_OFFLOAD_TCP_TSO;
4496 		printf("TSO for non-tunneled packets is disabled\n");
4497 	} else {
4498 		ports[res->port_id].dev_conf.txmode.offloads |=
4499 						DEV_TX_OFFLOAD_TCP_TSO;
4500 		printf("TSO segment size for non-tunneled packets is %d\n",
4501 			ports[res->port_id].tso_segsz);
4502 	}
4503 
4504 	/* display warnings if configuration is not supported by the NIC */
4505 	rte_eth_dev_info_get(res->port_id, &dev_info);
4506 	if ((ports[res->port_id].tso_segsz != 0) &&
4507 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4508 		printf("Warning: TSO enabled but not "
4509 			"supported by port %d\n", res->port_id);
4510 	}
4511 
4512 	cmd_reconfig_device_queue(res->port_id, 1, 1);
4513 }
4514 
4515 cmdline_parse_token_string_t cmd_tso_set_tso =
4516 	TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4517 				tso, "tso");
4518 cmdline_parse_token_string_t cmd_tso_set_mode =
4519 	TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4520 				mode, "set");
4521 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4522 	TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4523 				tso_segsz, UINT16);
4524 cmdline_parse_token_num_t cmd_tso_set_portid =
4525 	TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4526 				port_id, UINT16);
4527 
4528 cmdline_parse_inst_t cmd_tso_set = {
4529 	.f = cmd_tso_set_parsed,
4530 	.data = NULL,
4531 	.help_str = "tso set <tso_segsz> <port_id>: "
4532 		"Set TSO segment size of non-tunneled packets for csum engine "
4533 		"(0 to disable)",
4534 	.tokens = {
4535 		(void *)&cmd_tso_set_tso,
4536 		(void *)&cmd_tso_set_mode,
4537 		(void *)&cmd_tso_set_tso_segsz,
4538 		(void *)&cmd_tso_set_portid,
4539 		NULL,
4540 	},
4541 };
4542 
4543 cmdline_parse_token_string_t cmd_tso_show_mode =
4544 	TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4545 				mode, "show");
4546 
4547 
4548 cmdline_parse_inst_t cmd_tso_show = {
4549 	.f = cmd_tso_set_parsed,
4550 	.data = NULL,
4551 	.help_str = "tso show <port_id>: "
4552 		"Show TSO segment size of non-tunneled packets for csum engine",
4553 	.tokens = {
4554 		(void *)&cmd_tso_set_tso,
4555 		(void *)&cmd_tso_show_mode,
4556 		(void *)&cmd_tso_set_portid,
4557 		NULL,
4558 	},
4559 };
4560 
4561 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
4562 struct cmd_tunnel_tso_set_result {
4563 	cmdline_fixed_string_t tso;
4564 	cmdline_fixed_string_t mode;
4565 	uint16_t tso_segsz;
4566 	portid_t port_id;
4567 };
4568 
4569 static struct rte_eth_dev_info
4570 check_tunnel_tso_nic_support(portid_t port_id)
4571 {
4572 	struct rte_eth_dev_info dev_info;
4573 
4574 	rte_eth_dev_info_get(port_id, &dev_info);
4575 	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
4576 		printf("Warning: VXLAN TUNNEL TSO not supported therefore "
4577 		       "not enabled for port %d\n", port_id);
4578 	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
4579 		printf("Warning: GRE TUNNEL TSO	not supported therefore "
4580 		       "not enabled for port %d\n", port_id);
4581 	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
4582 		printf("Warning: IPIP TUNNEL TSO not supported therefore "
4583 		       "not enabled for port %d\n", port_id);
4584 	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
4585 		printf("Warning: GENEVE TUNNEL TSO not supported therefore "
4586 		       "not enabled for port %d\n", port_id);
4587 	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
4588 		printf("Warning: IP TUNNEL TSO not supported therefore "
4589 		       "not enabled for port %d\n", port_id);
4590 	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
4591 		printf("Warning: UDP TUNNEL TSO not supported therefore "
4592 		       "not enabled for port %d\n", port_id);
4593 	return dev_info;
4594 }
4595 
4596 static void
4597 cmd_tunnel_tso_set_parsed(void *parsed_result,
4598 			  __attribute__((unused)) struct cmdline *cl,
4599 			  __attribute__((unused)) void *data)
4600 {
4601 	struct cmd_tunnel_tso_set_result *res = parsed_result;
4602 	struct rte_eth_dev_info dev_info;
4603 
4604 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4605 		return;
4606 	if (!port_is_stopped(res->port_id)) {
4607 		printf("Please stop port %d first\n", res->port_id);
4608 		return;
4609 	}
4610 
4611 	if (!strcmp(res->mode, "set"))
4612 		ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
4613 
4614 	dev_info = check_tunnel_tso_nic_support(res->port_id);
4615 	if (ports[res->port_id].tunnel_tso_segsz == 0) {
4616 		ports[res->port_id].dev_conf.txmode.offloads &=
4617 			~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4618 			  DEV_TX_OFFLOAD_GRE_TNL_TSO |
4619 			  DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4620 			  DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4621 			  DEV_TX_OFFLOAD_IP_TNL_TSO |
4622 			  DEV_TX_OFFLOAD_UDP_TNL_TSO);
4623 		printf("TSO for tunneled packets is disabled\n");
4624 	} else {
4625 		uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4626 					 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4627 					 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4628 					 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4629 					 DEV_TX_OFFLOAD_IP_TNL_TSO |
4630 					 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4631 
4632 		ports[res->port_id].dev_conf.txmode.offloads |=
4633 			(tso_offloads & dev_info.tx_offload_capa);
4634 		printf("TSO segment size for tunneled packets is %d\n",
4635 			ports[res->port_id].tunnel_tso_segsz);
4636 
4637 		/* Below conditions are needed to make it work:
4638 		 * (1) tunnel TSO is supported by the NIC;
4639 		 * (2) "csum parse_tunnel" must be set so that tunneled pkts
4640 		 * are recognized;
4641 		 * (3) for tunneled pkts with outer L3 of IPv4,
4642 		 * "csum set outer-ip" must be set to hw, because after tso,
4643 		 * total_len of outer IP header is changed, and the checksum
4644 		 * of outer IP header calculated by sw should be wrong; that
4645 		 * is not necessary for IPv6 tunneled pkts because there's no
4646 		 * checksum in IP header anymore.
4647 		 */
4648 
4649 		if (!ports[res->port_id].parse_tunnel)
4650 			printf("Warning: csum parse_tunnel must be set "
4651 				"so that tunneled packets are recognized\n");
4652 		if (!(ports[res->port_id].dev_conf.txmode.offloads &
4653 		      DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
4654 			printf("Warning: csum set outer-ip must be set to hw "
4655 				"if outer L3 is IPv4; not necessary for IPv6\n");
4656 	}
4657 
4658 	cmd_reconfig_device_queue(res->port_id, 1, 1);
4659 }
4660 
4661 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
4662 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4663 				tso, "tunnel_tso");
4664 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
4665 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4666 				mode, "set");
4667 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
4668 	TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4669 				tso_segsz, UINT16);
4670 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
4671 	TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4672 				port_id, UINT16);
4673 
4674 cmdline_parse_inst_t cmd_tunnel_tso_set = {
4675 	.f = cmd_tunnel_tso_set_parsed,
4676 	.data = NULL,
4677 	.help_str = "tunnel_tso set <tso_segsz> <port_id>: "
4678 		"Set TSO segment size of tunneled packets for csum engine "
4679 		"(0 to disable)",
4680 	.tokens = {
4681 		(void *)&cmd_tunnel_tso_set_tso,
4682 		(void *)&cmd_tunnel_tso_set_mode,
4683 		(void *)&cmd_tunnel_tso_set_tso_segsz,
4684 		(void *)&cmd_tunnel_tso_set_portid,
4685 		NULL,
4686 	},
4687 };
4688 
4689 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
4690 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4691 				mode, "show");
4692 
4693 
4694 cmdline_parse_inst_t cmd_tunnel_tso_show = {
4695 	.f = cmd_tunnel_tso_set_parsed,
4696 	.data = NULL,
4697 	.help_str = "tunnel_tso show <port_id> "
4698 		"Show TSO segment size of tunneled packets for csum engine",
4699 	.tokens = {
4700 		(void *)&cmd_tunnel_tso_set_tso,
4701 		(void *)&cmd_tunnel_tso_show_mode,
4702 		(void *)&cmd_tunnel_tso_set_portid,
4703 		NULL,
4704 	},
4705 };
4706 
4707 /* *** SET GRO FOR A PORT *** */
4708 struct cmd_gro_enable_result {
4709 	cmdline_fixed_string_t cmd_set;
4710 	cmdline_fixed_string_t cmd_port;
4711 	cmdline_fixed_string_t cmd_keyword;
4712 	cmdline_fixed_string_t cmd_onoff;
4713 	portid_t cmd_pid;
4714 };
4715 
4716 static void
4717 cmd_gro_enable_parsed(void *parsed_result,
4718 		__attribute__((unused)) struct cmdline *cl,
4719 		__attribute__((unused)) void *data)
4720 {
4721 	struct cmd_gro_enable_result *res;
4722 
4723 	res = parsed_result;
4724 	if (!strcmp(res->cmd_keyword, "gro"))
4725 		setup_gro(res->cmd_onoff, res->cmd_pid);
4726 }
4727 
4728 cmdline_parse_token_string_t cmd_gro_enable_set =
4729 	TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4730 			cmd_set, "set");
4731 cmdline_parse_token_string_t cmd_gro_enable_port =
4732 	TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4733 			cmd_keyword, "port");
4734 cmdline_parse_token_num_t cmd_gro_enable_pid =
4735 	TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
4736 			cmd_pid, UINT16);
4737 cmdline_parse_token_string_t cmd_gro_enable_keyword =
4738 	TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4739 			cmd_keyword, "gro");
4740 cmdline_parse_token_string_t cmd_gro_enable_onoff =
4741 	TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4742 			cmd_onoff, "on#off");
4743 
4744 cmdline_parse_inst_t cmd_gro_enable = {
4745 	.f = cmd_gro_enable_parsed,
4746 	.data = NULL,
4747 	.help_str = "set port <port_id> gro on|off",
4748 	.tokens = {
4749 		(void *)&cmd_gro_enable_set,
4750 		(void *)&cmd_gro_enable_port,
4751 		(void *)&cmd_gro_enable_pid,
4752 		(void *)&cmd_gro_enable_keyword,
4753 		(void *)&cmd_gro_enable_onoff,
4754 		NULL,
4755 	},
4756 };
4757 
4758 /* *** DISPLAY GRO CONFIGURATION *** */
4759 struct cmd_gro_show_result {
4760 	cmdline_fixed_string_t cmd_show;
4761 	cmdline_fixed_string_t cmd_port;
4762 	cmdline_fixed_string_t cmd_keyword;
4763 	portid_t cmd_pid;
4764 };
4765 
4766 static void
4767 cmd_gro_show_parsed(void *parsed_result,
4768 		__attribute__((unused)) struct cmdline *cl,
4769 		__attribute__((unused)) void *data)
4770 {
4771 	struct cmd_gro_show_result *res;
4772 
4773 	res = parsed_result;
4774 	if (!strcmp(res->cmd_keyword, "gro"))
4775 		show_gro(res->cmd_pid);
4776 }
4777 
4778 cmdline_parse_token_string_t cmd_gro_show_show =
4779 	TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4780 			cmd_show, "show");
4781 cmdline_parse_token_string_t cmd_gro_show_port =
4782 	TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4783 			cmd_port, "port");
4784 cmdline_parse_token_num_t cmd_gro_show_pid =
4785 	TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
4786 			cmd_pid, UINT16);
4787 cmdline_parse_token_string_t cmd_gro_show_keyword =
4788 	TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4789 			cmd_keyword, "gro");
4790 
4791 cmdline_parse_inst_t cmd_gro_show = {
4792 	.f = cmd_gro_show_parsed,
4793 	.data = NULL,
4794 	.help_str = "show port <port_id> gro",
4795 	.tokens = {
4796 		(void *)&cmd_gro_show_show,
4797 		(void *)&cmd_gro_show_port,
4798 		(void *)&cmd_gro_show_pid,
4799 		(void *)&cmd_gro_show_keyword,
4800 		NULL,
4801 	},
4802 };
4803 
4804 /* *** SET FLUSH CYCLES FOR GRO *** */
4805 struct cmd_gro_flush_result {
4806 	cmdline_fixed_string_t cmd_set;
4807 	cmdline_fixed_string_t cmd_keyword;
4808 	cmdline_fixed_string_t cmd_flush;
4809 	uint8_t cmd_cycles;
4810 };
4811 
4812 static void
4813 cmd_gro_flush_parsed(void *parsed_result,
4814 		__attribute__((unused)) struct cmdline *cl,
4815 		__attribute__((unused)) void *data)
4816 {
4817 	struct cmd_gro_flush_result *res;
4818 
4819 	res = parsed_result;
4820 	if ((!strcmp(res->cmd_keyword, "gro")) &&
4821 			(!strcmp(res->cmd_flush, "flush")))
4822 		setup_gro_flush_cycles(res->cmd_cycles);
4823 }
4824 
4825 cmdline_parse_token_string_t cmd_gro_flush_set =
4826 	TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4827 			cmd_set, "set");
4828 cmdline_parse_token_string_t cmd_gro_flush_keyword =
4829 	TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4830 			cmd_keyword, "gro");
4831 cmdline_parse_token_string_t cmd_gro_flush_flush =
4832 	TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4833 			cmd_flush, "flush");
4834 cmdline_parse_token_num_t cmd_gro_flush_cycles =
4835 	TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
4836 			cmd_cycles, UINT8);
4837 
4838 cmdline_parse_inst_t cmd_gro_flush = {
4839 	.f = cmd_gro_flush_parsed,
4840 	.data = NULL,
4841 	.help_str = "set gro flush <cycles>",
4842 	.tokens = {
4843 		(void *)&cmd_gro_flush_set,
4844 		(void *)&cmd_gro_flush_keyword,
4845 		(void *)&cmd_gro_flush_flush,
4846 		(void *)&cmd_gro_flush_cycles,
4847 		NULL,
4848 	},
4849 };
4850 
4851 /* *** ENABLE/DISABLE GSO *** */
4852 struct cmd_gso_enable_result {
4853 	cmdline_fixed_string_t cmd_set;
4854 	cmdline_fixed_string_t cmd_port;
4855 	cmdline_fixed_string_t cmd_keyword;
4856 	cmdline_fixed_string_t cmd_mode;
4857 	portid_t cmd_pid;
4858 };
4859 
4860 static void
4861 cmd_gso_enable_parsed(void *parsed_result,
4862 		__attribute__((unused)) struct cmdline *cl,
4863 		__attribute__((unused)) void *data)
4864 {
4865 	struct cmd_gso_enable_result *res;
4866 
4867 	res = parsed_result;
4868 	if (!strcmp(res->cmd_keyword, "gso"))
4869 		setup_gso(res->cmd_mode, res->cmd_pid);
4870 }
4871 
4872 cmdline_parse_token_string_t cmd_gso_enable_set =
4873 	TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4874 			cmd_set, "set");
4875 cmdline_parse_token_string_t cmd_gso_enable_port =
4876 	TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4877 			cmd_port, "port");
4878 cmdline_parse_token_string_t cmd_gso_enable_keyword =
4879 	TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4880 			cmd_keyword, "gso");
4881 cmdline_parse_token_string_t cmd_gso_enable_mode =
4882 	TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4883 			cmd_mode, "on#off");
4884 cmdline_parse_token_num_t cmd_gso_enable_pid =
4885 	TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
4886 			cmd_pid, UINT16);
4887 
4888 cmdline_parse_inst_t cmd_gso_enable = {
4889 	.f = cmd_gso_enable_parsed,
4890 	.data = NULL,
4891 	.help_str = "set port <port_id> gso on|off",
4892 	.tokens = {
4893 		(void *)&cmd_gso_enable_set,
4894 		(void *)&cmd_gso_enable_port,
4895 		(void *)&cmd_gso_enable_pid,
4896 		(void *)&cmd_gso_enable_keyword,
4897 		(void *)&cmd_gso_enable_mode,
4898 		NULL,
4899 	},
4900 };
4901 
4902 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
4903 struct cmd_gso_size_result {
4904 	cmdline_fixed_string_t cmd_set;
4905 	cmdline_fixed_string_t cmd_keyword;
4906 	cmdline_fixed_string_t cmd_segsz;
4907 	uint16_t cmd_size;
4908 };
4909 
4910 static void
4911 cmd_gso_size_parsed(void *parsed_result,
4912 		       __attribute__((unused)) struct cmdline *cl,
4913 		       __attribute__((unused)) void *data)
4914 {
4915 	struct cmd_gso_size_result *res = parsed_result;
4916 
4917 	if (test_done == 0) {
4918 		printf("Before setting GSO segsz, please first"
4919 				" stop fowarding\n");
4920 		return;
4921 	}
4922 
4923 	if (!strcmp(res->cmd_keyword, "gso") &&
4924 			!strcmp(res->cmd_segsz, "segsz")) {
4925 		if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
4926 			printf("gso_size should be larger than %zu."
4927 					" Please input a legal value\n",
4928 					RTE_GSO_SEG_SIZE_MIN);
4929 		else
4930 			gso_max_segment_size = res->cmd_size;
4931 	}
4932 }
4933 
4934 cmdline_parse_token_string_t cmd_gso_size_set =
4935 	TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4936 				cmd_set, "set");
4937 cmdline_parse_token_string_t cmd_gso_size_keyword =
4938 	TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4939 				cmd_keyword, "gso");
4940 cmdline_parse_token_string_t cmd_gso_size_segsz =
4941 	TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4942 				cmd_segsz, "segsz");
4943 cmdline_parse_token_num_t cmd_gso_size_size =
4944 	TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
4945 				cmd_size, UINT16);
4946 
4947 cmdline_parse_inst_t cmd_gso_size = {
4948 	.f = cmd_gso_size_parsed,
4949 	.data = NULL,
4950 	.help_str = "set gso segsz <length>",
4951 	.tokens = {
4952 		(void *)&cmd_gso_size_set,
4953 		(void *)&cmd_gso_size_keyword,
4954 		(void *)&cmd_gso_size_segsz,
4955 		(void *)&cmd_gso_size_size,
4956 		NULL,
4957 	},
4958 };
4959 
4960 /* *** SHOW GSO CONFIGURATION *** */
4961 struct cmd_gso_show_result {
4962 	cmdline_fixed_string_t cmd_show;
4963 	cmdline_fixed_string_t cmd_port;
4964 	cmdline_fixed_string_t cmd_keyword;
4965 	portid_t cmd_pid;
4966 };
4967 
4968 static void
4969 cmd_gso_show_parsed(void *parsed_result,
4970 		       __attribute__((unused)) struct cmdline *cl,
4971 		       __attribute__((unused)) void *data)
4972 {
4973 	struct cmd_gso_show_result *res = parsed_result;
4974 
4975 	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
4976 		printf("invalid port id %u\n", res->cmd_pid);
4977 		return;
4978 	}
4979 	if (!strcmp(res->cmd_keyword, "gso")) {
4980 		if (gso_ports[res->cmd_pid].enable) {
4981 			printf("Max GSO'd packet size: %uB\n"
4982 					"Supported GSO types: TCP/IPv4, "
4983 					"UDP/IPv4, VxLAN with inner "
4984 					"TCP/IPv4 packet, GRE with inner "
4985 					"TCP/IPv4 packet\n",
4986 					gso_max_segment_size);
4987 		} else
4988 			printf("GSO is not enabled on Port %u\n", res->cmd_pid);
4989 	}
4990 }
4991 
4992 cmdline_parse_token_string_t cmd_gso_show_show =
4993 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4994 		cmd_show, "show");
4995 cmdline_parse_token_string_t cmd_gso_show_port =
4996 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4997 		cmd_port, "port");
4998 cmdline_parse_token_string_t cmd_gso_show_keyword =
4999 	TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5000 				cmd_keyword, "gso");
5001 cmdline_parse_token_num_t cmd_gso_show_pid =
5002 	TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
5003 				cmd_pid, UINT16);
5004 
5005 cmdline_parse_inst_t cmd_gso_show = {
5006 	.f = cmd_gso_show_parsed,
5007 	.data = NULL,
5008 	.help_str = "show port <port_id> gso",
5009 	.tokens = {
5010 		(void *)&cmd_gso_show_show,
5011 		(void *)&cmd_gso_show_port,
5012 		(void *)&cmd_gso_show_pid,
5013 		(void *)&cmd_gso_show_keyword,
5014 		NULL,
5015 	},
5016 };
5017 
5018 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
5019 struct cmd_set_flush_rx {
5020 	cmdline_fixed_string_t set;
5021 	cmdline_fixed_string_t flush_rx;
5022 	cmdline_fixed_string_t mode;
5023 };
5024 
5025 static void
5026 cmd_set_flush_rx_parsed(void *parsed_result,
5027 		__attribute__((unused)) struct cmdline *cl,
5028 		__attribute__((unused)) void *data)
5029 {
5030 	struct cmd_set_flush_rx *res = parsed_result;
5031 	no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5032 }
5033 
5034 cmdline_parse_token_string_t cmd_setflushrx_set =
5035 	TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5036 			set, "set");
5037 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
5038 	TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5039 			flush_rx, "flush_rx");
5040 cmdline_parse_token_string_t cmd_setflushrx_mode =
5041 	TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5042 			mode, "on#off");
5043 
5044 
5045 cmdline_parse_inst_t cmd_set_flush_rx = {
5046 	.f = cmd_set_flush_rx_parsed,
5047 	.help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
5048 	.data = NULL,
5049 	.tokens = {
5050 		(void *)&cmd_setflushrx_set,
5051 		(void *)&cmd_setflushrx_flush_rx,
5052 		(void *)&cmd_setflushrx_mode,
5053 		NULL,
5054 	},
5055 };
5056 
5057 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
5058 struct cmd_set_link_check {
5059 	cmdline_fixed_string_t set;
5060 	cmdline_fixed_string_t link_check;
5061 	cmdline_fixed_string_t mode;
5062 };
5063 
5064 static void
5065 cmd_set_link_check_parsed(void *parsed_result,
5066 		__attribute__((unused)) struct cmdline *cl,
5067 		__attribute__((unused)) void *data)
5068 {
5069 	struct cmd_set_link_check *res = parsed_result;
5070 	no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5071 }
5072 
5073 cmdline_parse_token_string_t cmd_setlinkcheck_set =
5074 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5075 			set, "set");
5076 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
5077 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5078 			link_check, "link_check");
5079 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
5080 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5081 			mode, "on#off");
5082 
5083 
5084 cmdline_parse_inst_t cmd_set_link_check = {
5085 	.f = cmd_set_link_check_parsed,
5086 	.help_str = "set link_check on|off: Enable/Disable link status check "
5087 	            "when starting/stopping a port",
5088 	.data = NULL,
5089 	.tokens = {
5090 		(void *)&cmd_setlinkcheck_set,
5091 		(void *)&cmd_setlinkcheck_link_check,
5092 		(void *)&cmd_setlinkcheck_mode,
5093 		NULL,
5094 	},
5095 };
5096 
5097 /* *** SET NIC BYPASS MODE *** */
5098 struct cmd_set_bypass_mode_result {
5099 	cmdline_fixed_string_t set;
5100 	cmdline_fixed_string_t bypass;
5101 	cmdline_fixed_string_t mode;
5102 	cmdline_fixed_string_t value;
5103 	portid_t port_id;
5104 };
5105 
5106 static void
5107 cmd_set_bypass_mode_parsed(void *parsed_result,
5108 		__attribute__((unused)) struct cmdline *cl,
5109 		__attribute__((unused)) void *data)
5110 {
5111 	struct cmd_set_bypass_mode_result *res = parsed_result;
5112 	portid_t port_id = res->port_id;
5113 	int32_t rc = -EINVAL;
5114 
5115 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5116 	uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5117 
5118 	if (!strcmp(res->value, "bypass"))
5119 		bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5120 	else if (!strcmp(res->value, "isolate"))
5121 		bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5122 	else
5123 		bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5124 
5125 	/* Set the bypass mode for the relevant port. */
5126 	rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
5127 #endif
5128 	if (rc != 0)
5129 		printf("\t Failed to set bypass mode for port = %d.\n", port_id);
5130 }
5131 
5132 cmdline_parse_token_string_t cmd_setbypass_mode_set =
5133 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5134 			set, "set");
5135 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
5136 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5137 			bypass, "bypass");
5138 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
5139 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5140 			mode, "mode");
5141 cmdline_parse_token_string_t cmd_setbypass_mode_value =
5142 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5143 			value, "normal#bypass#isolate");
5144 cmdline_parse_token_num_t cmd_setbypass_mode_port =
5145 	TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
5146 				port_id, UINT16);
5147 
5148 cmdline_parse_inst_t cmd_set_bypass_mode = {
5149 	.f = cmd_set_bypass_mode_parsed,
5150 	.help_str = "set bypass mode normal|bypass|isolate <port_id>: "
5151 	            "Set the NIC bypass mode for port_id",
5152 	.data = NULL,
5153 	.tokens = {
5154 		(void *)&cmd_setbypass_mode_set,
5155 		(void *)&cmd_setbypass_mode_bypass,
5156 		(void *)&cmd_setbypass_mode_mode,
5157 		(void *)&cmd_setbypass_mode_value,
5158 		(void *)&cmd_setbypass_mode_port,
5159 		NULL,
5160 	},
5161 };
5162 
5163 /* *** SET NIC BYPASS EVENT *** */
5164 struct cmd_set_bypass_event_result {
5165 	cmdline_fixed_string_t set;
5166 	cmdline_fixed_string_t bypass;
5167 	cmdline_fixed_string_t event;
5168 	cmdline_fixed_string_t event_value;
5169 	cmdline_fixed_string_t mode;
5170 	cmdline_fixed_string_t mode_value;
5171 	portid_t port_id;
5172 };
5173 
5174 static void
5175 cmd_set_bypass_event_parsed(void *parsed_result,
5176 		__attribute__((unused)) struct cmdline *cl,
5177 		__attribute__((unused)) void *data)
5178 {
5179 	int32_t rc = -EINVAL;
5180 	struct cmd_set_bypass_event_result *res = parsed_result;
5181 	portid_t port_id = res->port_id;
5182 
5183 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5184 	uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5185 	uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5186 
5187 	if (!strcmp(res->event_value, "timeout"))
5188 		bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
5189 	else if (!strcmp(res->event_value, "os_on"))
5190 		bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
5191 	else if (!strcmp(res->event_value, "os_off"))
5192 		bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5193 	else if (!strcmp(res->event_value, "power_on"))
5194 		bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5195 	else if (!strcmp(res->event_value, "power_off"))
5196 		bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5197 	else
5198 		bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5199 
5200 	if (!strcmp(res->mode_value, "bypass"))
5201 		bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5202 	else if (!strcmp(res->mode_value, "isolate"))
5203 		bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5204 	else
5205 		bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5206 
5207 	/* Set the watchdog timeout. */
5208 	if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5209 
5210 		rc = -EINVAL;
5211 		if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5212 			rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5213 							   bypass_timeout);
5214 		}
5215 		if (rc != 0) {
5216 			printf("Failed to set timeout value %u "
5217 			"for port %d, errto code: %d.\n",
5218 			bypass_timeout, port_id, rc);
5219 		}
5220 	}
5221 
5222 	/* Set the bypass event to transition to bypass mode. */
5223 	rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5224 					      bypass_mode);
5225 #endif
5226 
5227 	if (rc != 0)
5228 		printf("\t Failed to set bypass event for port = %d.\n",
5229 		       port_id);
5230 }
5231 
5232 cmdline_parse_token_string_t cmd_setbypass_event_set =
5233 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5234 			set, "set");
5235 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5236 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5237 			bypass, "bypass");
5238 cmdline_parse_token_string_t cmd_setbypass_event_event =
5239 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5240 			event, "event");
5241 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5242 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5243 			event_value, "none#timeout#os_off#os_on#power_on#power_off");
5244 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5245 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5246 			mode, "mode");
5247 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5248 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5249 			mode_value, "normal#bypass#isolate");
5250 cmdline_parse_token_num_t cmd_setbypass_event_port =
5251 	TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5252 				port_id, UINT16);
5253 
5254 cmdline_parse_inst_t cmd_set_bypass_event = {
5255 	.f = cmd_set_bypass_event_parsed,
5256 	.help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5257 		"power_off mode normal|bypass|isolate <port_id>: "
5258 		"Set the NIC bypass event mode for port_id",
5259 	.data = NULL,
5260 	.tokens = {
5261 		(void *)&cmd_setbypass_event_set,
5262 		(void *)&cmd_setbypass_event_bypass,
5263 		(void *)&cmd_setbypass_event_event,
5264 		(void *)&cmd_setbypass_event_event_value,
5265 		(void *)&cmd_setbypass_event_mode,
5266 		(void *)&cmd_setbypass_event_mode_value,
5267 		(void *)&cmd_setbypass_event_port,
5268 		NULL,
5269 	},
5270 };
5271 
5272 
5273 /* *** SET NIC BYPASS TIMEOUT *** */
5274 struct cmd_set_bypass_timeout_result {
5275 	cmdline_fixed_string_t set;
5276 	cmdline_fixed_string_t bypass;
5277 	cmdline_fixed_string_t timeout;
5278 	cmdline_fixed_string_t value;
5279 };
5280 
5281 static void
5282 cmd_set_bypass_timeout_parsed(void *parsed_result,
5283 		__attribute__((unused)) struct cmdline *cl,
5284 		__attribute__((unused)) void *data)
5285 {
5286 	__rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5287 
5288 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5289 	if (!strcmp(res->value, "1.5"))
5290 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5291 	else if (!strcmp(res->value, "2"))
5292 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5293 	else if (!strcmp(res->value, "3"))
5294 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5295 	else if (!strcmp(res->value, "4"))
5296 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5297 	else if (!strcmp(res->value, "8"))
5298 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5299 	else if (!strcmp(res->value, "16"))
5300 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5301 	else if (!strcmp(res->value, "32"))
5302 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5303 	else
5304 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5305 #endif
5306 }
5307 
5308 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5309 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5310 			set, "set");
5311 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5312 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5313 			bypass, "bypass");
5314 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5315 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5316 			timeout, "timeout");
5317 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5318 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5319 			value, "0#1.5#2#3#4#8#16#32");
5320 
5321 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5322 	.f = cmd_set_bypass_timeout_parsed,
5323 	.help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5324 		"Set the NIC bypass watchdog timeout in seconds",
5325 	.data = NULL,
5326 	.tokens = {
5327 		(void *)&cmd_setbypass_timeout_set,
5328 		(void *)&cmd_setbypass_timeout_bypass,
5329 		(void *)&cmd_setbypass_timeout_timeout,
5330 		(void *)&cmd_setbypass_timeout_value,
5331 		NULL,
5332 	},
5333 };
5334 
5335 /* *** SHOW NIC BYPASS MODE *** */
5336 struct cmd_show_bypass_config_result {
5337 	cmdline_fixed_string_t show;
5338 	cmdline_fixed_string_t bypass;
5339 	cmdline_fixed_string_t config;
5340 	portid_t port_id;
5341 };
5342 
5343 static void
5344 cmd_show_bypass_config_parsed(void *parsed_result,
5345 		__attribute__((unused)) struct cmdline *cl,
5346 		__attribute__((unused)) void *data)
5347 {
5348 	struct cmd_show_bypass_config_result *res = parsed_result;
5349 	portid_t port_id = res->port_id;
5350 	int rc = -EINVAL;
5351 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5352 	uint32_t event_mode;
5353 	uint32_t bypass_mode;
5354 	uint32_t timeout = bypass_timeout;
5355 	int i;
5356 
5357 	static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5358 		{"off", "1.5", "2", "3", "4", "8", "16", "32"};
5359 	static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5360 		{"UNKNOWN", "normal", "bypass", "isolate"};
5361 	static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5362 		"NONE",
5363 		"OS/board on",
5364 		"power supply on",
5365 		"OS/board off",
5366 		"power supply off",
5367 		"timeout"};
5368 	int num_events = (sizeof events) / (sizeof events[0]);
5369 
5370 	/* Display the bypass mode.*/
5371 	if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5372 		printf("\tFailed to get bypass mode for port = %d\n", port_id);
5373 		return;
5374 	}
5375 	else {
5376 		if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5377 			bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5378 
5379 		printf("\tbypass mode    = %s\n",  modes[bypass_mode]);
5380 	}
5381 
5382 	/* Display the bypass timeout.*/
5383 	if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5384 		timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5385 
5386 	printf("\tbypass timeout = %s\n", timeouts[timeout]);
5387 
5388 	/* Display the bypass events and associated modes. */
5389 	for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < num_events; i++) {
5390 
5391 		if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5392 			printf("\tFailed to get bypass mode for event = %s\n",
5393 				events[i]);
5394 		} else {
5395 			if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5396 				event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5397 
5398 			printf("\tbypass event: %-16s = %s\n", events[i],
5399 				modes[event_mode]);
5400 		}
5401 	}
5402 #endif
5403 	if (rc != 0)
5404 		printf("\tFailed to get bypass configuration for port = %d\n",
5405 		       port_id);
5406 }
5407 
5408 cmdline_parse_token_string_t cmd_showbypass_config_show =
5409 	TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5410 			show, "show");
5411 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5412 	TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5413 			bypass, "bypass");
5414 cmdline_parse_token_string_t cmd_showbypass_config_config =
5415 	TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5416 			config, "config");
5417 cmdline_parse_token_num_t cmd_showbypass_config_port =
5418 	TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5419 				port_id, UINT16);
5420 
5421 cmdline_parse_inst_t cmd_show_bypass_config = {
5422 	.f = cmd_show_bypass_config_parsed,
5423 	.help_str = "show bypass config <port_id>: "
5424 	            "Show the NIC bypass config for port_id",
5425 	.data = NULL,
5426 	.tokens = {
5427 		(void *)&cmd_showbypass_config_show,
5428 		(void *)&cmd_showbypass_config_bypass,
5429 		(void *)&cmd_showbypass_config_config,
5430 		(void *)&cmd_showbypass_config_port,
5431 		NULL,
5432 	},
5433 };
5434 
5435 #ifdef RTE_LIBRTE_PMD_BOND
5436 /* *** SET BONDING MODE *** */
5437 struct cmd_set_bonding_mode_result {
5438 	cmdline_fixed_string_t set;
5439 	cmdline_fixed_string_t bonding;
5440 	cmdline_fixed_string_t mode;
5441 	uint8_t value;
5442 	portid_t port_id;
5443 };
5444 
5445 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5446 		__attribute__((unused))  struct cmdline *cl,
5447 		__attribute__((unused)) void *data)
5448 {
5449 	struct cmd_set_bonding_mode_result *res = parsed_result;
5450 	portid_t port_id = res->port_id;
5451 
5452 	/* Set the bonding mode for the relevant port. */
5453 	if (0 != rte_eth_bond_mode_set(port_id, res->value))
5454 		printf("\t Failed to set bonding mode for port = %d.\n", port_id);
5455 }
5456 
5457 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5458 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5459 		set, "set");
5460 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5461 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5462 		bonding, "bonding");
5463 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5464 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5465 		mode, "mode");
5466 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5467 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5468 		value, UINT8);
5469 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5470 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5471 		port_id, UINT16);
5472 
5473 cmdline_parse_inst_t cmd_set_bonding_mode = {
5474 		.f = cmd_set_bonding_mode_parsed,
5475 		.help_str = "set bonding mode <mode_value> <port_id>: "
5476 			"Set the bonding mode for port_id",
5477 		.data = NULL,
5478 		.tokens = {
5479 				(void *) &cmd_setbonding_mode_set,
5480 				(void *) &cmd_setbonding_mode_bonding,
5481 				(void *) &cmd_setbonding_mode_mode,
5482 				(void *) &cmd_setbonding_mode_value,
5483 				(void *) &cmd_setbonding_mode_port,
5484 				NULL
5485 		}
5486 };
5487 
5488 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5489 struct cmd_set_bonding_lacp_dedicated_queues_result {
5490 	cmdline_fixed_string_t set;
5491 	cmdline_fixed_string_t bonding;
5492 	cmdline_fixed_string_t lacp;
5493 	cmdline_fixed_string_t dedicated_queues;
5494 	portid_t port_id;
5495 	cmdline_fixed_string_t mode;
5496 };
5497 
5498 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5499 		__attribute__((unused))  struct cmdline *cl,
5500 		__attribute__((unused)) void *data)
5501 {
5502 	struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5503 	portid_t port_id = res->port_id;
5504 	struct rte_port *port;
5505 
5506 	port = &ports[port_id];
5507 
5508 	/** Check if the port is not started **/
5509 	if (port->port_status != RTE_PORT_STOPPED) {
5510 		printf("Please stop port %d first\n", port_id);
5511 		return;
5512 	}
5513 
5514 	if (!strcmp(res->mode, "enable")) {
5515 		if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5516 			printf("Dedicate queues for LACP control packets"
5517 					" enabled\n");
5518 		else
5519 			printf("Enabling dedicate queues for LACP control "
5520 					"packets on port %d failed\n", port_id);
5521 	} else if (!strcmp(res->mode, "disable")) {
5522 		if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5523 			printf("Dedicated queues for LACP control packets "
5524 					"disabled\n");
5525 		else
5526 			printf("Disabling dedicated queues for LACP control "
5527 					"traffic on port %d failed\n", port_id);
5528 	}
5529 }
5530 
5531 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5532 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5533 		set, "set");
5534 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
5535 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5536 		bonding, "bonding");
5537 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
5538 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5539 		lacp, "lacp");
5540 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
5541 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5542 		dedicated_queues, "dedicated_queues");
5543 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
5544 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5545 		port_id, UINT16);
5546 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
5547 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5548 		mode, "enable#disable");
5549 
5550 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
5551 		.f = cmd_set_bonding_lacp_dedicated_queues_parsed,
5552 		.help_str = "set bonding lacp dedicated_queues <port_id> "
5553 			"enable|disable: "
5554 			"Enable/disable dedicated queues for LACP control traffic for port_id",
5555 		.data = NULL,
5556 		.tokens = {
5557 			(void *)&cmd_setbonding_lacp_dedicated_queues_set,
5558 			(void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
5559 			(void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
5560 			(void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
5561 			(void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
5562 			(void *)&cmd_setbonding_lacp_dedicated_queues_mode,
5563 			NULL
5564 		}
5565 };
5566 
5567 /* *** SET BALANCE XMIT POLICY *** */
5568 struct cmd_set_bonding_balance_xmit_policy_result {
5569 	cmdline_fixed_string_t set;
5570 	cmdline_fixed_string_t bonding;
5571 	cmdline_fixed_string_t balance_xmit_policy;
5572 	portid_t port_id;
5573 	cmdline_fixed_string_t policy;
5574 };
5575 
5576 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
5577 		__attribute__((unused))  struct cmdline *cl,
5578 		__attribute__((unused)) void *data)
5579 {
5580 	struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
5581 	portid_t port_id = res->port_id;
5582 	uint8_t policy;
5583 
5584 	if (!strcmp(res->policy, "l2")) {
5585 		policy = BALANCE_XMIT_POLICY_LAYER2;
5586 	} else if (!strcmp(res->policy, "l23")) {
5587 		policy = BALANCE_XMIT_POLICY_LAYER23;
5588 	} else if (!strcmp(res->policy, "l34")) {
5589 		policy = BALANCE_XMIT_POLICY_LAYER34;
5590 	} else {
5591 		printf("\t Invalid xmit policy selection");
5592 		return;
5593 	}
5594 
5595 	/* Set the bonding mode for the relevant port. */
5596 	if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
5597 		printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
5598 				port_id);
5599 	}
5600 }
5601 
5602 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
5603 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5604 		set, "set");
5605 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
5606 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5607 		bonding, "bonding");
5608 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
5609 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5610 		balance_xmit_policy, "balance_xmit_policy");
5611 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
5612 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5613 		port_id, UINT16);
5614 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
5615 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5616 		policy, "l2#l23#l34");
5617 
5618 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
5619 		.f = cmd_set_bonding_balance_xmit_policy_parsed,
5620 		.help_str = "set bonding balance_xmit_policy <port_id> "
5621 			"l2|l23|l34: "
5622 			"Set the bonding balance_xmit_policy for port_id",
5623 		.data = NULL,
5624 		.tokens = {
5625 				(void *)&cmd_setbonding_balance_xmit_policy_set,
5626 				(void *)&cmd_setbonding_balance_xmit_policy_bonding,
5627 				(void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
5628 				(void *)&cmd_setbonding_balance_xmit_policy_port,
5629 				(void *)&cmd_setbonding_balance_xmit_policy_policy,
5630 				NULL
5631 		}
5632 };
5633 
5634 /* *** SHOW NIC BONDING CONFIGURATION *** */
5635 struct cmd_show_bonding_config_result {
5636 	cmdline_fixed_string_t show;
5637 	cmdline_fixed_string_t bonding;
5638 	cmdline_fixed_string_t config;
5639 	portid_t port_id;
5640 };
5641 
5642 static void cmd_show_bonding_config_parsed(void *parsed_result,
5643 		__attribute__((unused))  struct cmdline *cl,
5644 		__attribute__((unused)) void *data)
5645 {
5646 	struct cmd_show_bonding_config_result *res = parsed_result;
5647 	int bonding_mode, agg_mode;
5648 	portid_t slaves[RTE_MAX_ETHPORTS];
5649 	int num_slaves, num_active_slaves;
5650 	int primary_id;
5651 	int i;
5652 	portid_t port_id = res->port_id;
5653 
5654 	/* Display the bonding mode.*/
5655 	bonding_mode = rte_eth_bond_mode_get(port_id);
5656 	if (bonding_mode < 0) {
5657 		printf("\tFailed to get bonding mode for port = %d\n", port_id);
5658 		return;
5659 	} else
5660 		printf("\tBonding mode: %d\n", bonding_mode);
5661 
5662 	if (bonding_mode == BONDING_MODE_BALANCE) {
5663 		int balance_xmit_policy;
5664 
5665 		balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
5666 		if (balance_xmit_policy < 0) {
5667 			printf("\tFailed to get balance xmit policy for port = %d\n",
5668 					port_id);
5669 			return;
5670 		} else {
5671 			printf("\tBalance Xmit Policy: ");
5672 
5673 			switch (balance_xmit_policy) {
5674 			case BALANCE_XMIT_POLICY_LAYER2:
5675 				printf("BALANCE_XMIT_POLICY_LAYER2");
5676 				break;
5677 			case BALANCE_XMIT_POLICY_LAYER23:
5678 				printf("BALANCE_XMIT_POLICY_LAYER23");
5679 				break;
5680 			case BALANCE_XMIT_POLICY_LAYER34:
5681 				printf("BALANCE_XMIT_POLICY_LAYER34");
5682 				break;
5683 			}
5684 			printf("\n");
5685 		}
5686 	}
5687 
5688 	if (bonding_mode == BONDING_MODE_8023AD) {
5689 		agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
5690 		printf("\tIEEE802.3AD Aggregator Mode: ");
5691 		switch (agg_mode) {
5692 		case AGG_BANDWIDTH:
5693 			printf("bandwidth");
5694 			break;
5695 		case AGG_STABLE:
5696 			printf("stable");
5697 			break;
5698 		case AGG_COUNT:
5699 			printf("count");
5700 			break;
5701 		}
5702 		printf("\n");
5703 	}
5704 
5705 	num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
5706 
5707 	if (num_slaves < 0) {
5708 		printf("\tFailed to get slave list for port = %d\n", port_id);
5709 		return;
5710 	}
5711 	if (num_slaves > 0) {
5712 		printf("\tSlaves (%d): [", num_slaves);
5713 		for (i = 0; i < num_slaves - 1; i++)
5714 			printf("%d ", slaves[i]);
5715 
5716 		printf("%d]\n", slaves[num_slaves - 1]);
5717 	} else {
5718 		printf("\tSlaves: []\n");
5719 
5720 	}
5721 
5722 	num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
5723 			RTE_MAX_ETHPORTS);
5724 
5725 	if (num_active_slaves < 0) {
5726 		printf("\tFailed to get active slave list for port = %d\n", port_id);
5727 		return;
5728 	}
5729 	if (num_active_slaves > 0) {
5730 		printf("\tActive Slaves (%d): [", num_active_slaves);
5731 		for (i = 0; i < num_active_slaves - 1; i++)
5732 			printf("%d ", slaves[i]);
5733 
5734 		printf("%d]\n", slaves[num_active_slaves - 1]);
5735 
5736 	} else {
5737 		printf("\tActive Slaves: []\n");
5738 
5739 	}
5740 
5741 	primary_id = rte_eth_bond_primary_get(port_id);
5742 	if (primary_id < 0) {
5743 		printf("\tFailed to get primary slave for port = %d\n", port_id);
5744 		return;
5745 	} else
5746 		printf("\tPrimary: [%d]\n", primary_id);
5747 
5748 }
5749 
5750 cmdline_parse_token_string_t cmd_showbonding_config_show =
5751 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5752 		show, "show");
5753 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
5754 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5755 		bonding, "bonding");
5756 cmdline_parse_token_string_t cmd_showbonding_config_config =
5757 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5758 		config, "config");
5759 cmdline_parse_token_num_t cmd_showbonding_config_port =
5760 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
5761 		port_id, UINT16);
5762 
5763 cmdline_parse_inst_t cmd_show_bonding_config = {
5764 		.f = cmd_show_bonding_config_parsed,
5765 		.help_str = "show bonding config <port_id>: "
5766 			"Show the bonding config for port_id",
5767 		.data = NULL,
5768 		.tokens = {
5769 				(void *)&cmd_showbonding_config_show,
5770 				(void *)&cmd_showbonding_config_bonding,
5771 				(void *)&cmd_showbonding_config_config,
5772 				(void *)&cmd_showbonding_config_port,
5773 				NULL
5774 		}
5775 };
5776 
5777 /* *** SET BONDING PRIMARY *** */
5778 struct cmd_set_bonding_primary_result {
5779 	cmdline_fixed_string_t set;
5780 	cmdline_fixed_string_t bonding;
5781 	cmdline_fixed_string_t primary;
5782 	portid_t slave_id;
5783 	portid_t port_id;
5784 };
5785 
5786 static void cmd_set_bonding_primary_parsed(void *parsed_result,
5787 		__attribute__((unused))  struct cmdline *cl,
5788 		__attribute__((unused)) void *data)
5789 {
5790 	struct cmd_set_bonding_primary_result *res = parsed_result;
5791 	portid_t master_port_id = res->port_id;
5792 	portid_t slave_port_id = res->slave_id;
5793 
5794 	/* Set the primary slave for a bonded device. */
5795 	if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
5796 		printf("\t Failed to set primary slave for port = %d.\n",
5797 				master_port_id);
5798 		return;
5799 	}
5800 	init_port_config();
5801 }
5802 
5803 cmdline_parse_token_string_t cmd_setbonding_primary_set =
5804 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5805 		set, "set");
5806 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
5807 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5808 		bonding, "bonding");
5809 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
5810 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5811 		primary, "primary");
5812 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
5813 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5814 		slave_id, UINT16);
5815 cmdline_parse_token_num_t cmd_setbonding_primary_port =
5816 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5817 		port_id, UINT16);
5818 
5819 cmdline_parse_inst_t cmd_set_bonding_primary = {
5820 		.f = cmd_set_bonding_primary_parsed,
5821 		.help_str = "set bonding primary <slave_id> <port_id>: "
5822 			"Set the primary slave for port_id",
5823 		.data = NULL,
5824 		.tokens = {
5825 				(void *)&cmd_setbonding_primary_set,
5826 				(void *)&cmd_setbonding_primary_bonding,
5827 				(void *)&cmd_setbonding_primary_primary,
5828 				(void *)&cmd_setbonding_primary_slave,
5829 				(void *)&cmd_setbonding_primary_port,
5830 				NULL
5831 		}
5832 };
5833 
5834 /* *** ADD SLAVE *** */
5835 struct cmd_add_bonding_slave_result {
5836 	cmdline_fixed_string_t add;
5837 	cmdline_fixed_string_t bonding;
5838 	cmdline_fixed_string_t slave;
5839 	portid_t slave_id;
5840 	portid_t port_id;
5841 };
5842 
5843 static void cmd_add_bonding_slave_parsed(void *parsed_result,
5844 		__attribute__((unused))  struct cmdline *cl,
5845 		__attribute__((unused)) void *data)
5846 {
5847 	struct cmd_add_bonding_slave_result *res = parsed_result;
5848 	portid_t master_port_id = res->port_id;
5849 	portid_t slave_port_id = res->slave_id;
5850 
5851 	/* add the slave for a bonded device. */
5852 	if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
5853 		printf("\t Failed to add slave %d to master port = %d.\n",
5854 				slave_port_id, master_port_id);
5855 		return;
5856 	}
5857 	init_port_config();
5858 	set_port_slave_flag(slave_port_id);
5859 }
5860 
5861 cmdline_parse_token_string_t cmd_addbonding_slave_add =
5862 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5863 		add, "add");
5864 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
5865 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5866 		bonding, "bonding");
5867 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
5868 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5869 		slave, "slave");
5870 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
5871 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5872 		slave_id, UINT16);
5873 cmdline_parse_token_num_t cmd_addbonding_slave_port =
5874 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5875 		port_id, UINT16);
5876 
5877 cmdline_parse_inst_t cmd_add_bonding_slave = {
5878 		.f = cmd_add_bonding_slave_parsed,
5879 		.help_str = "add bonding slave <slave_id> <port_id>: "
5880 			"Add a slave device to a bonded device",
5881 		.data = NULL,
5882 		.tokens = {
5883 				(void *)&cmd_addbonding_slave_add,
5884 				(void *)&cmd_addbonding_slave_bonding,
5885 				(void *)&cmd_addbonding_slave_slave,
5886 				(void *)&cmd_addbonding_slave_slaveid,
5887 				(void *)&cmd_addbonding_slave_port,
5888 				NULL
5889 		}
5890 };
5891 
5892 /* *** REMOVE SLAVE *** */
5893 struct cmd_remove_bonding_slave_result {
5894 	cmdline_fixed_string_t remove;
5895 	cmdline_fixed_string_t bonding;
5896 	cmdline_fixed_string_t slave;
5897 	portid_t slave_id;
5898 	portid_t port_id;
5899 };
5900 
5901 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
5902 		__attribute__((unused))  struct cmdline *cl,
5903 		__attribute__((unused)) void *data)
5904 {
5905 	struct cmd_remove_bonding_slave_result *res = parsed_result;
5906 	portid_t master_port_id = res->port_id;
5907 	portid_t slave_port_id = res->slave_id;
5908 
5909 	/* remove the slave from a bonded device. */
5910 	if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
5911 		printf("\t Failed to remove slave %d from master port = %d.\n",
5912 				slave_port_id, master_port_id);
5913 		return;
5914 	}
5915 	init_port_config();
5916 	clear_port_slave_flag(slave_port_id);
5917 }
5918 
5919 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
5920 		TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5921 				remove, "remove");
5922 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
5923 		TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5924 				bonding, "bonding");
5925 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
5926 		TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5927 				slave, "slave");
5928 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
5929 		TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5930 				slave_id, UINT16);
5931 cmdline_parse_token_num_t cmd_removebonding_slave_port =
5932 		TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5933 				port_id, UINT16);
5934 
5935 cmdline_parse_inst_t cmd_remove_bonding_slave = {
5936 		.f = cmd_remove_bonding_slave_parsed,
5937 		.help_str = "remove bonding slave <slave_id> <port_id>: "
5938 			"Remove a slave device from a bonded device",
5939 		.data = NULL,
5940 		.tokens = {
5941 				(void *)&cmd_removebonding_slave_remove,
5942 				(void *)&cmd_removebonding_slave_bonding,
5943 				(void *)&cmd_removebonding_slave_slave,
5944 				(void *)&cmd_removebonding_slave_slaveid,
5945 				(void *)&cmd_removebonding_slave_port,
5946 				NULL
5947 		}
5948 };
5949 
5950 /* *** CREATE BONDED DEVICE *** */
5951 struct cmd_create_bonded_device_result {
5952 	cmdline_fixed_string_t create;
5953 	cmdline_fixed_string_t bonded;
5954 	cmdline_fixed_string_t device;
5955 	uint8_t mode;
5956 	uint8_t socket;
5957 };
5958 
5959 static int bond_dev_num = 0;
5960 
5961 static void cmd_create_bonded_device_parsed(void *parsed_result,
5962 		__attribute__((unused))  struct cmdline *cl,
5963 		__attribute__((unused)) void *data)
5964 {
5965 	struct cmd_create_bonded_device_result *res = parsed_result;
5966 	char ethdev_name[RTE_ETH_NAME_MAX_LEN];
5967 	int port_id;
5968 
5969 	if (test_done == 0) {
5970 		printf("Please stop forwarding first\n");
5971 		return;
5972 	}
5973 
5974 	snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
5975 			bond_dev_num++);
5976 
5977 	/* Create a new bonded device. */
5978 	port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
5979 	if (port_id < 0) {
5980 		printf("\t Failed to create bonded device.\n");
5981 		return;
5982 	} else {
5983 		printf("Created new bonded device %s on (port %d).\n", ethdev_name,
5984 				port_id);
5985 
5986 		/* Update number of ports */
5987 		nb_ports = rte_eth_dev_count_avail();
5988 		reconfig(port_id, res->socket);
5989 		rte_eth_promiscuous_enable(port_id);
5990 		ports[port_id].need_setup = 0;
5991 		ports[port_id].port_status = RTE_PORT_STOPPED;
5992 	}
5993 
5994 }
5995 
5996 cmdline_parse_token_string_t cmd_createbonded_device_create =
5997 		TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5998 				create, "create");
5999 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
6000 		TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6001 				bonded, "bonded");
6002 cmdline_parse_token_string_t cmd_createbonded_device_device =
6003 		TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6004 				device, "device");
6005 cmdline_parse_token_num_t cmd_createbonded_device_mode =
6006 		TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6007 				mode, UINT8);
6008 cmdline_parse_token_num_t cmd_createbonded_device_socket =
6009 		TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6010 				socket, UINT8);
6011 
6012 cmdline_parse_inst_t cmd_create_bonded_device = {
6013 		.f = cmd_create_bonded_device_parsed,
6014 		.help_str = "create bonded device <mode> <socket>: "
6015 			"Create a new bonded device with specific bonding mode and socket",
6016 		.data = NULL,
6017 		.tokens = {
6018 				(void *)&cmd_createbonded_device_create,
6019 				(void *)&cmd_createbonded_device_bonded,
6020 				(void *)&cmd_createbonded_device_device,
6021 				(void *)&cmd_createbonded_device_mode,
6022 				(void *)&cmd_createbonded_device_socket,
6023 				NULL
6024 		}
6025 };
6026 
6027 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
6028 struct cmd_set_bond_mac_addr_result {
6029 	cmdline_fixed_string_t set;
6030 	cmdline_fixed_string_t bonding;
6031 	cmdline_fixed_string_t mac_addr;
6032 	uint16_t port_num;
6033 	struct ether_addr address;
6034 };
6035 
6036 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
6037 		__attribute__((unused))  struct cmdline *cl,
6038 		__attribute__((unused)) void *data)
6039 {
6040 	struct cmd_set_bond_mac_addr_result *res = parsed_result;
6041 	int ret;
6042 
6043 	if (port_id_is_invalid(res->port_num, ENABLED_WARN))
6044 		return;
6045 
6046 	ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
6047 
6048 	/* check the return value and print it if is < 0 */
6049 	if (ret < 0)
6050 		printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6051 }
6052 
6053 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
6054 		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
6055 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
6056 		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
6057 				"bonding");
6058 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
6059 		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
6060 				"mac_addr");
6061 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
6062 		TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
6063 				port_num, UINT16);
6064 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
6065 		TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
6066 
6067 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
6068 		.f = cmd_set_bond_mac_addr_parsed,
6069 		.data = (void *) 0,
6070 		.help_str = "set bonding mac_addr <port_id> <mac_addr>",
6071 		.tokens = {
6072 				(void *)&cmd_set_bond_mac_addr_set,
6073 				(void *)&cmd_set_bond_mac_addr_bonding,
6074 				(void *)&cmd_set_bond_mac_addr_mac,
6075 				(void *)&cmd_set_bond_mac_addr_portnum,
6076 				(void *)&cmd_set_bond_mac_addr_addr,
6077 				NULL
6078 		}
6079 };
6080 
6081 
6082 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
6083 struct cmd_set_bond_mon_period_result {
6084 	cmdline_fixed_string_t set;
6085 	cmdline_fixed_string_t bonding;
6086 	cmdline_fixed_string_t mon_period;
6087 	uint16_t port_num;
6088 	uint32_t period_ms;
6089 };
6090 
6091 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
6092 		__attribute__((unused))  struct cmdline *cl,
6093 		__attribute__((unused)) void *data)
6094 {
6095 	struct cmd_set_bond_mon_period_result *res = parsed_result;
6096 	int ret;
6097 
6098 	ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
6099 
6100 	/* check the return value and print it if is < 0 */
6101 	if (ret < 0)
6102 		printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6103 }
6104 
6105 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
6106 		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6107 				set, "set");
6108 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
6109 		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6110 				bonding, "bonding");
6111 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
6112 		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6113 				mon_period,	"mon_period");
6114 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
6115 		TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6116 				port_num, UINT16);
6117 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
6118 		TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6119 				period_ms, UINT32);
6120 
6121 cmdline_parse_inst_t cmd_set_bond_mon_period = {
6122 		.f = cmd_set_bond_mon_period_parsed,
6123 		.data = (void *) 0,
6124 		.help_str = "set bonding mon_period <port_id> <period_ms>",
6125 		.tokens = {
6126 				(void *)&cmd_set_bond_mon_period_set,
6127 				(void *)&cmd_set_bond_mon_period_bonding,
6128 				(void *)&cmd_set_bond_mon_period_mon_period,
6129 				(void *)&cmd_set_bond_mon_period_portnum,
6130 				(void *)&cmd_set_bond_mon_period_period_ms,
6131 				NULL
6132 		}
6133 };
6134 
6135 
6136 
6137 struct cmd_set_bonding_agg_mode_policy_result {
6138 	cmdline_fixed_string_t set;
6139 	cmdline_fixed_string_t bonding;
6140 	cmdline_fixed_string_t agg_mode;
6141 	uint16_t port_num;
6142 	cmdline_fixed_string_t policy;
6143 };
6144 
6145 
6146 static void
6147 cmd_set_bonding_agg_mode(void *parsed_result,
6148 		__attribute__((unused)) struct cmdline *cl,
6149 		__attribute__((unused)) void *data)
6150 {
6151 	struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
6152 	uint8_t policy = AGG_BANDWIDTH;
6153 
6154 	if (!strcmp(res->policy, "bandwidth"))
6155 		policy = AGG_BANDWIDTH;
6156 	else if (!strcmp(res->policy, "stable"))
6157 		policy = AGG_STABLE;
6158 	else if (!strcmp(res->policy, "count"))
6159 		policy = AGG_COUNT;
6160 
6161 	rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
6162 }
6163 
6164 
6165 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
6166 	TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6167 				set, "set");
6168 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
6169 	TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6170 				bonding, "bonding");
6171 
6172 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
6173 	TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6174 				agg_mode, "agg_mode");
6175 
6176 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
6177 	TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6178 				port_num, UINT16);
6179 
6180 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6181 	TOKEN_STRING_INITIALIZER(
6182 			struct cmd_set_bonding_balance_xmit_policy_result,
6183 		policy, "stable#bandwidth#count");
6184 
6185 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6186 	.f = cmd_set_bonding_agg_mode,
6187 	.data = (void *) 0,
6188 	.help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6189 	.tokens = {
6190 			(void *)&cmd_set_bonding_agg_mode_set,
6191 			(void *)&cmd_set_bonding_agg_mode_bonding,
6192 			(void *)&cmd_set_bonding_agg_mode_agg_mode,
6193 			(void *)&cmd_set_bonding_agg_mode_portnum,
6194 			(void *)&cmd_set_bonding_agg_mode_policy_string,
6195 			NULL
6196 		}
6197 };
6198 
6199 
6200 #endif /* RTE_LIBRTE_PMD_BOND */
6201 
6202 /* *** SET FORWARDING MODE *** */
6203 struct cmd_set_fwd_mode_result {
6204 	cmdline_fixed_string_t set;
6205 	cmdline_fixed_string_t fwd;
6206 	cmdline_fixed_string_t mode;
6207 };
6208 
6209 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6210 				    __attribute__((unused)) struct cmdline *cl,
6211 				    __attribute__((unused)) void *data)
6212 {
6213 	struct cmd_set_fwd_mode_result *res = parsed_result;
6214 
6215 	retry_enabled = 0;
6216 	set_pkt_forwarding_mode(res->mode);
6217 }
6218 
6219 cmdline_parse_token_string_t cmd_setfwd_set =
6220 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6221 cmdline_parse_token_string_t cmd_setfwd_fwd =
6222 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6223 cmdline_parse_token_string_t cmd_setfwd_mode =
6224 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6225 		"" /* defined at init */);
6226 
6227 cmdline_parse_inst_t cmd_set_fwd_mode = {
6228 	.f = cmd_set_fwd_mode_parsed,
6229 	.data = NULL,
6230 	.help_str = NULL, /* defined at init */
6231 	.tokens = {
6232 		(void *)&cmd_setfwd_set,
6233 		(void *)&cmd_setfwd_fwd,
6234 		(void *)&cmd_setfwd_mode,
6235 		NULL,
6236 	},
6237 };
6238 
6239 static void cmd_set_fwd_mode_init(void)
6240 {
6241 	char *modes, *c;
6242 	static char token[128];
6243 	static char help[256];
6244 	cmdline_parse_token_string_t *token_struct;
6245 
6246 	modes = list_pkt_forwarding_modes();
6247 	snprintf(help, sizeof(help), "set fwd %s: "
6248 		"Set packet forwarding mode", modes);
6249 	cmd_set_fwd_mode.help_str = help;
6250 
6251 	/* string token separator is # */
6252 	for (c = token; *modes != '\0'; modes++)
6253 		if (*modes == '|')
6254 			*c++ = '#';
6255 		else
6256 			*c++ = *modes;
6257 	token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6258 	token_struct->string_data.str = token;
6259 }
6260 
6261 /* *** SET RETRY FORWARDING MODE *** */
6262 struct cmd_set_fwd_retry_mode_result {
6263 	cmdline_fixed_string_t set;
6264 	cmdline_fixed_string_t fwd;
6265 	cmdline_fixed_string_t mode;
6266 	cmdline_fixed_string_t retry;
6267 };
6268 
6269 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6270 			    __attribute__((unused)) struct cmdline *cl,
6271 			    __attribute__((unused)) void *data)
6272 {
6273 	struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6274 
6275 	retry_enabled = 1;
6276 	set_pkt_forwarding_mode(res->mode);
6277 }
6278 
6279 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6280 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6281 			set, "set");
6282 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6283 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6284 			fwd, "fwd");
6285 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6286 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6287 			mode,
6288 		"" /* defined at init */);
6289 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6290 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6291 			retry, "retry");
6292 
6293 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6294 	.f = cmd_set_fwd_retry_mode_parsed,
6295 	.data = NULL,
6296 	.help_str = NULL, /* defined at init */
6297 	.tokens = {
6298 		(void *)&cmd_setfwd_retry_set,
6299 		(void *)&cmd_setfwd_retry_fwd,
6300 		(void *)&cmd_setfwd_retry_mode,
6301 		(void *)&cmd_setfwd_retry_retry,
6302 		NULL,
6303 	},
6304 };
6305 
6306 static void cmd_set_fwd_retry_mode_init(void)
6307 {
6308 	char *modes, *c;
6309 	static char token[128];
6310 	static char help[256];
6311 	cmdline_parse_token_string_t *token_struct;
6312 
6313 	modes = list_pkt_forwarding_retry_modes();
6314 	snprintf(help, sizeof(help), "set fwd %s retry: "
6315 		"Set packet forwarding mode with retry", modes);
6316 	cmd_set_fwd_retry_mode.help_str = help;
6317 
6318 	/* string token separator is # */
6319 	for (c = token; *modes != '\0'; modes++)
6320 		if (*modes == '|')
6321 			*c++ = '#';
6322 		else
6323 			*c++ = *modes;
6324 	token_struct = (cmdline_parse_token_string_t *)
6325 		cmd_set_fwd_retry_mode.tokens[2];
6326 	token_struct->string_data.str = token;
6327 }
6328 
6329 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6330 struct cmd_set_burst_tx_retry_result {
6331 	cmdline_fixed_string_t set;
6332 	cmdline_fixed_string_t burst;
6333 	cmdline_fixed_string_t tx;
6334 	cmdline_fixed_string_t delay;
6335 	uint32_t time;
6336 	cmdline_fixed_string_t retry;
6337 	uint32_t retry_num;
6338 };
6339 
6340 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6341 					__attribute__((unused)) struct cmdline *cl,
6342 					__attribute__((unused)) void *data)
6343 {
6344 	struct cmd_set_burst_tx_retry_result *res = parsed_result;
6345 
6346 	if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6347 		&& !strcmp(res->tx, "tx")) {
6348 		if (!strcmp(res->delay, "delay"))
6349 			burst_tx_delay_time = res->time;
6350 		if (!strcmp(res->retry, "retry"))
6351 			burst_tx_retry_num = res->retry_num;
6352 	}
6353 
6354 }
6355 
6356 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6357 	TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6358 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6359 	TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6360 				 "burst");
6361 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6362 	TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6363 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6364 	TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6365 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6366 	TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
6367 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6368 	TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6369 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6370 	TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
6371 
6372 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6373 	.f = cmd_set_burst_tx_retry_parsed,
6374 	.help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6375 	.tokens = {
6376 		(void *)&cmd_set_burst_tx_retry_set,
6377 		(void *)&cmd_set_burst_tx_retry_burst,
6378 		(void *)&cmd_set_burst_tx_retry_tx,
6379 		(void *)&cmd_set_burst_tx_retry_delay,
6380 		(void *)&cmd_set_burst_tx_retry_time,
6381 		(void *)&cmd_set_burst_tx_retry_retry,
6382 		(void *)&cmd_set_burst_tx_retry_retry_num,
6383 		NULL,
6384 	},
6385 };
6386 
6387 /* *** SET PROMISC MODE *** */
6388 struct cmd_set_promisc_mode_result {
6389 	cmdline_fixed_string_t set;
6390 	cmdline_fixed_string_t promisc;
6391 	cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6392 	uint16_t port_num;               /* valid if "allports" argument == 0 */
6393 	cmdline_fixed_string_t mode;
6394 };
6395 
6396 static void cmd_set_promisc_mode_parsed(void *parsed_result,
6397 					__attribute__((unused)) struct cmdline *cl,
6398 					void *allports)
6399 {
6400 	struct cmd_set_promisc_mode_result *res = parsed_result;
6401 	int enable;
6402 	portid_t i;
6403 
6404 	if (!strcmp(res->mode, "on"))
6405 		enable = 1;
6406 	else
6407 		enable = 0;
6408 
6409 	/* all ports */
6410 	if (allports) {
6411 		RTE_ETH_FOREACH_DEV(i) {
6412 			if (enable)
6413 				rte_eth_promiscuous_enable(i);
6414 			else
6415 				rte_eth_promiscuous_disable(i);
6416 		}
6417 	}
6418 	else {
6419 		if (enable)
6420 			rte_eth_promiscuous_enable(res->port_num);
6421 		else
6422 			rte_eth_promiscuous_disable(res->port_num);
6423 	}
6424 }
6425 
6426 cmdline_parse_token_string_t cmd_setpromisc_set =
6427 	TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6428 cmdline_parse_token_string_t cmd_setpromisc_promisc =
6429 	TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6430 				 "promisc");
6431 cmdline_parse_token_string_t cmd_setpromisc_portall =
6432 	TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6433 				 "all");
6434 cmdline_parse_token_num_t cmd_setpromisc_portnum =
6435 	TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6436 			      UINT16);
6437 cmdline_parse_token_string_t cmd_setpromisc_mode =
6438 	TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6439 				 "on#off");
6440 
6441 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6442 	.f = cmd_set_promisc_mode_parsed,
6443 	.data = (void *)1,
6444 	.help_str = "set promisc all on|off: Set promisc mode for all ports",
6445 	.tokens = {
6446 		(void *)&cmd_setpromisc_set,
6447 		(void *)&cmd_setpromisc_promisc,
6448 		(void *)&cmd_setpromisc_portall,
6449 		(void *)&cmd_setpromisc_mode,
6450 		NULL,
6451 	},
6452 };
6453 
6454 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6455 	.f = cmd_set_promisc_mode_parsed,
6456 	.data = (void *)0,
6457 	.help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6458 	.tokens = {
6459 		(void *)&cmd_setpromisc_set,
6460 		(void *)&cmd_setpromisc_promisc,
6461 		(void *)&cmd_setpromisc_portnum,
6462 		(void *)&cmd_setpromisc_mode,
6463 		NULL,
6464 	},
6465 };
6466 
6467 /* *** SET ALLMULTI MODE *** */
6468 struct cmd_set_allmulti_mode_result {
6469 	cmdline_fixed_string_t set;
6470 	cmdline_fixed_string_t allmulti;
6471 	cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6472 	uint16_t port_num;               /* valid if "allports" argument == 0 */
6473 	cmdline_fixed_string_t mode;
6474 };
6475 
6476 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6477 					__attribute__((unused)) struct cmdline *cl,
6478 					void *allports)
6479 {
6480 	struct cmd_set_allmulti_mode_result *res = parsed_result;
6481 	int enable;
6482 	portid_t i;
6483 
6484 	if (!strcmp(res->mode, "on"))
6485 		enable = 1;
6486 	else
6487 		enable = 0;
6488 
6489 	/* all ports */
6490 	if (allports) {
6491 		RTE_ETH_FOREACH_DEV(i) {
6492 			if (enable)
6493 				rte_eth_allmulticast_enable(i);
6494 			else
6495 				rte_eth_allmulticast_disable(i);
6496 		}
6497 	}
6498 	else {
6499 		if (enable)
6500 			rte_eth_allmulticast_enable(res->port_num);
6501 		else
6502 			rte_eth_allmulticast_disable(res->port_num);
6503 	}
6504 }
6505 
6506 cmdline_parse_token_string_t cmd_setallmulti_set =
6507 	TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6508 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6509 	TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6510 				 "allmulti");
6511 cmdline_parse_token_string_t cmd_setallmulti_portall =
6512 	TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6513 				 "all");
6514 cmdline_parse_token_num_t cmd_setallmulti_portnum =
6515 	TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6516 			      UINT16);
6517 cmdline_parse_token_string_t cmd_setallmulti_mode =
6518 	TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6519 				 "on#off");
6520 
6521 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6522 	.f = cmd_set_allmulti_mode_parsed,
6523 	.data = (void *)1,
6524 	.help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6525 	.tokens = {
6526 		(void *)&cmd_setallmulti_set,
6527 		(void *)&cmd_setallmulti_allmulti,
6528 		(void *)&cmd_setallmulti_portall,
6529 		(void *)&cmd_setallmulti_mode,
6530 		NULL,
6531 	},
6532 };
6533 
6534 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6535 	.f = cmd_set_allmulti_mode_parsed,
6536 	.data = (void *)0,
6537 	.help_str = "set allmulti <port_id> on|off: "
6538 		"Set allmulti mode on port_id",
6539 	.tokens = {
6540 		(void *)&cmd_setallmulti_set,
6541 		(void *)&cmd_setallmulti_allmulti,
6542 		(void *)&cmd_setallmulti_portnum,
6543 		(void *)&cmd_setallmulti_mode,
6544 		NULL,
6545 	},
6546 };
6547 
6548 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
6549 struct cmd_link_flow_ctrl_set_result {
6550 	cmdline_fixed_string_t set;
6551 	cmdline_fixed_string_t flow_ctrl;
6552 	cmdline_fixed_string_t rx;
6553 	cmdline_fixed_string_t rx_lfc_mode;
6554 	cmdline_fixed_string_t tx;
6555 	cmdline_fixed_string_t tx_lfc_mode;
6556 	cmdline_fixed_string_t mac_ctrl_frame_fwd;
6557 	cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
6558 	cmdline_fixed_string_t autoneg_str;
6559 	cmdline_fixed_string_t autoneg;
6560 	cmdline_fixed_string_t hw_str;
6561 	uint32_t high_water;
6562 	cmdline_fixed_string_t lw_str;
6563 	uint32_t low_water;
6564 	cmdline_fixed_string_t pt_str;
6565 	uint16_t pause_time;
6566 	cmdline_fixed_string_t xon_str;
6567 	uint16_t send_xon;
6568 	portid_t port_id;
6569 };
6570 
6571 cmdline_parse_token_string_t cmd_lfc_set_set =
6572 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6573 				set, "set");
6574 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
6575 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6576 				flow_ctrl, "flow_ctrl");
6577 cmdline_parse_token_string_t cmd_lfc_set_rx =
6578 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6579 				rx, "rx");
6580 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
6581 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6582 				rx_lfc_mode, "on#off");
6583 cmdline_parse_token_string_t cmd_lfc_set_tx =
6584 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6585 				tx, "tx");
6586 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
6587 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6588 				tx_lfc_mode, "on#off");
6589 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
6590 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6591 				hw_str, "high_water");
6592 cmdline_parse_token_num_t cmd_lfc_set_high_water =
6593 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6594 				high_water, UINT32);
6595 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
6596 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6597 				lw_str, "low_water");
6598 cmdline_parse_token_num_t cmd_lfc_set_low_water =
6599 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6600 				low_water, UINT32);
6601 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
6602 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6603 				pt_str, "pause_time");
6604 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
6605 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6606 				pause_time, UINT16);
6607 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
6608 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6609 				xon_str, "send_xon");
6610 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
6611 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6612 				send_xon, UINT16);
6613 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
6614 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6615 				mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
6616 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6617 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6618 				mac_ctrl_frame_fwd_mode, "on#off");
6619 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6620 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6621 				autoneg_str, "autoneg");
6622 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6623 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6624 				autoneg, "on#off");
6625 cmdline_parse_token_num_t cmd_lfc_set_portid =
6626 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6627 				port_id, UINT16);
6628 
6629 /* forward declaration */
6630 static void
6631 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6632 			      void *data);
6633 
6634 cmdline_parse_inst_t cmd_link_flow_control_set = {
6635 	.f = cmd_link_flow_ctrl_set_parsed,
6636 	.data = NULL,
6637 	.help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6638 		"<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6639 		"autoneg on|off <port_id>: Configure the Ethernet flow control",
6640 	.tokens = {
6641 		(void *)&cmd_lfc_set_set,
6642 		(void *)&cmd_lfc_set_flow_ctrl,
6643 		(void *)&cmd_lfc_set_rx,
6644 		(void *)&cmd_lfc_set_rx_mode,
6645 		(void *)&cmd_lfc_set_tx,
6646 		(void *)&cmd_lfc_set_tx_mode,
6647 		(void *)&cmd_lfc_set_high_water,
6648 		(void *)&cmd_lfc_set_low_water,
6649 		(void *)&cmd_lfc_set_pause_time,
6650 		(void *)&cmd_lfc_set_send_xon,
6651 		(void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6652 		(void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6653 		(void *)&cmd_lfc_set_autoneg_str,
6654 		(void *)&cmd_lfc_set_autoneg,
6655 		(void *)&cmd_lfc_set_portid,
6656 		NULL,
6657 	},
6658 };
6659 
6660 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6661 	.f = cmd_link_flow_ctrl_set_parsed,
6662 	.data = (void *)&cmd_link_flow_control_set_rx,
6663 	.help_str = "set flow_ctrl rx on|off <port_id>: "
6664 		"Change rx flow control parameter",
6665 	.tokens = {
6666 		(void *)&cmd_lfc_set_set,
6667 		(void *)&cmd_lfc_set_flow_ctrl,
6668 		(void *)&cmd_lfc_set_rx,
6669 		(void *)&cmd_lfc_set_rx_mode,
6670 		(void *)&cmd_lfc_set_portid,
6671 		NULL,
6672 	},
6673 };
6674 
6675 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6676 	.f = cmd_link_flow_ctrl_set_parsed,
6677 	.data = (void *)&cmd_link_flow_control_set_tx,
6678 	.help_str = "set flow_ctrl tx on|off <port_id>: "
6679 		"Change tx flow control parameter",
6680 	.tokens = {
6681 		(void *)&cmd_lfc_set_set,
6682 		(void *)&cmd_lfc_set_flow_ctrl,
6683 		(void *)&cmd_lfc_set_tx,
6684 		(void *)&cmd_lfc_set_tx_mode,
6685 		(void *)&cmd_lfc_set_portid,
6686 		NULL,
6687 	},
6688 };
6689 
6690 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
6691 	.f = cmd_link_flow_ctrl_set_parsed,
6692 	.data = (void *)&cmd_link_flow_control_set_hw,
6693 	.help_str = "set flow_ctrl high_water <value> <port_id>: "
6694 		"Change high water flow control parameter",
6695 	.tokens = {
6696 		(void *)&cmd_lfc_set_set,
6697 		(void *)&cmd_lfc_set_flow_ctrl,
6698 		(void *)&cmd_lfc_set_high_water_str,
6699 		(void *)&cmd_lfc_set_high_water,
6700 		(void *)&cmd_lfc_set_portid,
6701 		NULL,
6702 	},
6703 };
6704 
6705 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
6706 	.f = cmd_link_flow_ctrl_set_parsed,
6707 	.data = (void *)&cmd_link_flow_control_set_lw,
6708 	.help_str = "set flow_ctrl low_water <value> <port_id>: "
6709 		"Change low water flow control parameter",
6710 	.tokens = {
6711 		(void *)&cmd_lfc_set_set,
6712 		(void *)&cmd_lfc_set_flow_ctrl,
6713 		(void *)&cmd_lfc_set_low_water_str,
6714 		(void *)&cmd_lfc_set_low_water,
6715 		(void *)&cmd_lfc_set_portid,
6716 		NULL,
6717 	},
6718 };
6719 
6720 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
6721 	.f = cmd_link_flow_ctrl_set_parsed,
6722 	.data = (void *)&cmd_link_flow_control_set_pt,
6723 	.help_str = "set flow_ctrl pause_time <value> <port_id>: "
6724 		"Change pause time flow control parameter",
6725 	.tokens = {
6726 		(void *)&cmd_lfc_set_set,
6727 		(void *)&cmd_lfc_set_flow_ctrl,
6728 		(void *)&cmd_lfc_set_pause_time_str,
6729 		(void *)&cmd_lfc_set_pause_time,
6730 		(void *)&cmd_lfc_set_portid,
6731 		NULL,
6732 	},
6733 };
6734 
6735 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
6736 	.f = cmd_link_flow_ctrl_set_parsed,
6737 	.data = (void *)&cmd_link_flow_control_set_xon,
6738 	.help_str = "set flow_ctrl send_xon <value> <port_id>: "
6739 		"Change send_xon flow control parameter",
6740 	.tokens = {
6741 		(void *)&cmd_lfc_set_set,
6742 		(void *)&cmd_lfc_set_flow_ctrl,
6743 		(void *)&cmd_lfc_set_send_xon_str,
6744 		(void *)&cmd_lfc_set_send_xon,
6745 		(void *)&cmd_lfc_set_portid,
6746 		NULL,
6747 	},
6748 };
6749 
6750 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
6751 	.f = cmd_link_flow_ctrl_set_parsed,
6752 	.data = (void *)&cmd_link_flow_control_set_macfwd,
6753 	.help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
6754 		"Change mac ctrl fwd flow control parameter",
6755 	.tokens = {
6756 		(void *)&cmd_lfc_set_set,
6757 		(void *)&cmd_lfc_set_flow_ctrl,
6758 		(void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6759 		(void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6760 		(void *)&cmd_lfc_set_portid,
6761 		NULL,
6762 	},
6763 };
6764 
6765 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
6766 	.f = cmd_link_flow_ctrl_set_parsed,
6767 	.data = (void *)&cmd_link_flow_control_set_autoneg,
6768 	.help_str = "set flow_ctrl autoneg on|off <port_id>: "
6769 		"Change autoneg flow control parameter",
6770 	.tokens = {
6771 		(void *)&cmd_lfc_set_set,
6772 		(void *)&cmd_lfc_set_flow_ctrl,
6773 		(void *)&cmd_lfc_set_autoneg_str,
6774 		(void *)&cmd_lfc_set_autoneg,
6775 		(void *)&cmd_lfc_set_portid,
6776 		NULL,
6777 	},
6778 };
6779 
6780 static void
6781 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
6782 			      __attribute__((unused)) struct cmdline *cl,
6783 			      void *data)
6784 {
6785 	struct cmd_link_flow_ctrl_set_result *res = parsed_result;
6786 	cmdline_parse_inst_t *cmd = data;
6787 	struct rte_eth_fc_conf fc_conf;
6788 	int rx_fc_en = 0;
6789 	int tx_fc_en = 0;
6790 	int ret;
6791 
6792 	/*
6793 	 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6794 	 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6795 	 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6796 	 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6797 	 */
6798 	static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
6799 			{RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
6800 	};
6801 
6802 	/* Partial command line, retrieve current configuration */
6803 	if (cmd) {
6804 		ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
6805 		if (ret != 0) {
6806 			printf("cannot get current flow ctrl parameters, return"
6807 			       "code = %d\n", ret);
6808 			return;
6809 		}
6810 
6811 		if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
6812 		    (fc_conf.mode == RTE_FC_FULL))
6813 			rx_fc_en = 1;
6814 		if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
6815 		    (fc_conf.mode == RTE_FC_FULL))
6816 			tx_fc_en = 1;
6817 	}
6818 
6819 	if (!cmd || cmd == &cmd_link_flow_control_set_rx)
6820 		rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
6821 
6822 	if (!cmd || cmd == &cmd_link_flow_control_set_tx)
6823 		tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
6824 
6825 	fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
6826 
6827 	if (!cmd || cmd == &cmd_link_flow_control_set_hw)
6828 		fc_conf.high_water = res->high_water;
6829 
6830 	if (!cmd || cmd == &cmd_link_flow_control_set_lw)
6831 		fc_conf.low_water = res->low_water;
6832 
6833 	if (!cmd || cmd == &cmd_link_flow_control_set_pt)
6834 		fc_conf.pause_time = res->pause_time;
6835 
6836 	if (!cmd || cmd == &cmd_link_flow_control_set_xon)
6837 		fc_conf.send_xon = res->send_xon;
6838 
6839 	if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
6840 		if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
6841 			fc_conf.mac_ctrl_frame_fwd = 1;
6842 		else
6843 			fc_conf.mac_ctrl_frame_fwd = 0;
6844 	}
6845 
6846 	if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
6847 		fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
6848 
6849 	ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
6850 	if (ret != 0)
6851 		printf("bad flow contrl parameter, return code = %d \n", ret);
6852 }
6853 
6854 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
6855 struct cmd_priority_flow_ctrl_set_result {
6856 	cmdline_fixed_string_t set;
6857 	cmdline_fixed_string_t pfc_ctrl;
6858 	cmdline_fixed_string_t rx;
6859 	cmdline_fixed_string_t rx_pfc_mode;
6860 	cmdline_fixed_string_t tx;
6861 	cmdline_fixed_string_t tx_pfc_mode;
6862 	uint32_t high_water;
6863 	uint32_t low_water;
6864 	uint16_t pause_time;
6865 	uint8_t  priority;
6866 	portid_t port_id;
6867 };
6868 
6869 static void
6870 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
6871 		       __attribute__((unused)) struct cmdline *cl,
6872 		       __attribute__((unused)) void *data)
6873 {
6874 	struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
6875 	struct rte_eth_pfc_conf pfc_conf;
6876 	int rx_fc_enable, tx_fc_enable;
6877 	int ret;
6878 
6879 	/*
6880 	 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6881 	 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6882 	 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6883 	 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6884 	 */
6885 	static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
6886 			{RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
6887 	};
6888 
6889 	rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
6890 	tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
6891 	pfc_conf.fc.mode       = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
6892 	pfc_conf.fc.high_water = res->high_water;
6893 	pfc_conf.fc.low_water  = res->low_water;
6894 	pfc_conf.fc.pause_time = res->pause_time;
6895 	pfc_conf.priority      = res->priority;
6896 
6897 	ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
6898 	if (ret != 0)
6899 		printf("bad priority flow contrl parameter, return code = %d \n", ret);
6900 }
6901 
6902 cmdline_parse_token_string_t cmd_pfc_set_set =
6903 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6904 				set, "set");
6905 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
6906 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6907 				pfc_ctrl, "pfc_ctrl");
6908 cmdline_parse_token_string_t cmd_pfc_set_rx =
6909 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6910 				rx, "rx");
6911 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
6912 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6913 				rx_pfc_mode, "on#off");
6914 cmdline_parse_token_string_t cmd_pfc_set_tx =
6915 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6916 				tx, "tx");
6917 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
6918 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6919 				tx_pfc_mode, "on#off");
6920 cmdline_parse_token_num_t cmd_pfc_set_high_water =
6921 	TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6922 				high_water, UINT32);
6923 cmdline_parse_token_num_t cmd_pfc_set_low_water =
6924 	TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6925 				low_water, UINT32);
6926 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
6927 	TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6928 				pause_time, UINT16);
6929 cmdline_parse_token_num_t cmd_pfc_set_priority =
6930 	TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6931 				priority, UINT8);
6932 cmdline_parse_token_num_t cmd_pfc_set_portid =
6933 	TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6934 				port_id, UINT16);
6935 
6936 cmdline_parse_inst_t cmd_priority_flow_control_set = {
6937 	.f = cmd_priority_flow_ctrl_set_parsed,
6938 	.data = NULL,
6939 	.help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
6940 		"<pause_time> <priority> <port_id>: "
6941 		"Configure the Ethernet priority flow control",
6942 	.tokens = {
6943 		(void *)&cmd_pfc_set_set,
6944 		(void *)&cmd_pfc_set_flow_ctrl,
6945 		(void *)&cmd_pfc_set_rx,
6946 		(void *)&cmd_pfc_set_rx_mode,
6947 		(void *)&cmd_pfc_set_tx,
6948 		(void *)&cmd_pfc_set_tx_mode,
6949 		(void *)&cmd_pfc_set_high_water,
6950 		(void *)&cmd_pfc_set_low_water,
6951 		(void *)&cmd_pfc_set_pause_time,
6952 		(void *)&cmd_pfc_set_priority,
6953 		(void *)&cmd_pfc_set_portid,
6954 		NULL,
6955 	},
6956 };
6957 
6958 /* *** RESET CONFIGURATION *** */
6959 struct cmd_reset_result {
6960 	cmdline_fixed_string_t reset;
6961 	cmdline_fixed_string_t def;
6962 };
6963 
6964 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
6965 			     struct cmdline *cl,
6966 			     __attribute__((unused)) void *data)
6967 {
6968 	cmdline_printf(cl, "Reset to default forwarding configuration...\n");
6969 	set_def_fwd_config();
6970 }
6971 
6972 cmdline_parse_token_string_t cmd_reset_set =
6973 	TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
6974 cmdline_parse_token_string_t cmd_reset_def =
6975 	TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
6976 				 "default");
6977 
6978 cmdline_parse_inst_t cmd_reset = {
6979 	.f = cmd_reset_parsed,
6980 	.data = NULL,
6981 	.help_str = "set default: Reset default forwarding configuration",
6982 	.tokens = {
6983 		(void *)&cmd_reset_set,
6984 		(void *)&cmd_reset_def,
6985 		NULL,
6986 	},
6987 };
6988 
6989 /* *** START FORWARDING *** */
6990 struct cmd_start_result {
6991 	cmdline_fixed_string_t start;
6992 };
6993 
6994 cmdline_parse_token_string_t cmd_start_start =
6995 	TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
6996 
6997 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
6998 			     __attribute__((unused)) struct cmdline *cl,
6999 			     __attribute__((unused)) void *data)
7000 {
7001 	start_packet_forwarding(0);
7002 }
7003 
7004 cmdline_parse_inst_t cmd_start = {
7005 	.f = cmd_start_parsed,
7006 	.data = NULL,
7007 	.help_str = "start: Start packet forwarding",
7008 	.tokens = {
7009 		(void *)&cmd_start_start,
7010 		NULL,
7011 	},
7012 };
7013 
7014 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7015 struct cmd_start_tx_first_result {
7016 	cmdline_fixed_string_t start;
7017 	cmdline_fixed_string_t tx_first;
7018 };
7019 
7020 static void
7021 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
7022 			  __attribute__((unused)) struct cmdline *cl,
7023 			  __attribute__((unused)) void *data)
7024 {
7025 	start_packet_forwarding(1);
7026 }
7027 
7028 cmdline_parse_token_string_t cmd_start_tx_first_start =
7029 	TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7030 				 "start");
7031 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7032 	TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7033 				 tx_first, "tx_first");
7034 
7035 cmdline_parse_inst_t cmd_start_tx_first = {
7036 	.f = cmd_start_tx_first_parsed,
7037 	.data = NULL,
7038 	.help_str = "start tx_first: Start packet forwarding, "
7039 		"after sending 1 burst of packets",
7040 	.tokens = {
7041 		(void *)&cmd_start_tx_first_start,
7042 		(void *)&cmd_start_tx_first_tx_first,
7043 		NULL,
7044 	},
7045 };
7046 
7047 /* *** START FORWARDING WITH N TX BURST FIRST *** */
7048 struct cmd_start_tx_first_n_result {
7049 	cmdline_fixed_string_t start;
7050 	cmdline_fixed_string_t tx_first;
7051 	uint32_t tx_num;
7052 };
7053 
7054 static void
7055 cmd_start_tx_first_n_parsed(void *parsed_result,
7056 			  __attribute__((unused)) struct cmdline *cl,
7057 			  __attribute__((unused)) void *data)
7058 {
7059 	struct cmd_start_tx_first_n_result *res = parsed_result;
7060 
7061 	start_packet_forwarding(res->tx_num);
7062 }
7063 
7064 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7065 	TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7066 			start, "start");
7067 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7068 	TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7069 			tx_first, "tx_first");
7070 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7071 	TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7072 			tx_num, UINT32);
7073 
7074 cmdline_parse_inst_t cmd_start_tx_first_n = {
7075 	.f = cmd_start_tx_first_n_parsed,
7076 	.data = NULL,
7077 	.help_str = "start tx_first <num>: "
7078 		"packet forwarding, after sending <num> bursts of packets",
7079 	.tokens = {
7080 		(void *)&cmd_start_tx_first_n_start,
7081 		(void *)&cmd_start_tx_first_n_tx_first,
7082 		(void *)&cmd_start_tx_first_n_tx_num,
7083 		NULL,
7084 	},
7085 };
7086 
7087 /* *** SET LINK UP *** */
7088 struct cmd_set_link_up_result {
7089 	cmdline_fixed_string_t set;
7090 	cmdline_fixed_string_t link_up;
7091 	cmdline_fixed_string_t port;
7092 	portid_t port_id;
7093 };
7094 
7095 cmdline_parse_token_string_t cmd_set_link_up_set =
7096 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7097 cmdline_parse_token_string_t cmd_set_link_up_link_up =
7098 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7099 				"link-up");
7100 cmdline_parse_token_string_t cmd_set_link_up_port =
7101 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7102 cmdline_parse_token_num_t cmd_set_link_up_port_id =
7103 	TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16);
7104 
7105 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
7106 			     __attribute__((unused)) struct cmdline *cl,
7107 			     __attribute__((unused)) void *data)
7108 {
7109 	struct cmd_set_link_up_result *res = parsed_result;
7110 	dev_set_link_up(res->port_id);
7111 }
7112 
7113 cmdline_parse_inst_t cmd_set_link_up = {
7114 	.f = cmd_set_link_up_parsed,
7115 	.data = NULL,
7116 	.help_str = "set link-up port <port id>",
7117 	.tokens = {
7118 		(void *)&cmd_set_link_up_set,
7119 		(void *)&cmd_set_link_up_link_up,
7120 		(void *)&cmd_set_link_up_port,
7121 		(void *)&cmd_set_link_up_port_id,
7122 		NULL,
7123 	},
7124 };
7125 
7126 /* *** SET LINK DOWN *** */
7127 struct cmd_set_link_down_result {
7128 	cmdline_fixed_string_t set;
7129 	cmdline_fixed_string_t link_down;
7130 	cmdline_fixed_string_t port;
7131 	portid_t port_id;
7132 };
7133 
7134 cmdline_parse_token_string_t cmd_set_link_down_set =
7135 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
7136 cmdline_parse_token_string_t cmd_set_link_down_link_down =
7137 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
7138 				"link-down");
7139 cmdline_parse_token_string_t cmd_set_link_down_port =
7140 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
7141 cmdline_parse_token_num_t cmd_set_link_down_port_id =
7142 	TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16);
7143 
7144 static void cmd_set_link_down_parsed(
7145 				__attribute__((unused)) void *parsed_result,
7146 				__attribute__((unused)) struct cmdline *cl,
7147 				__attribute__((unused)) void *data)
7148 {
7149 	struct cmd_set_link_down_result *res = parsed_result;
7150 	dev_set_link_down(res->port_id);
7151 }
7152 
7153 cmdline_parse_inst_t cmd_set_link_down = {
7154 	.f = cmd_set_link_down_parsed,
7155 	.data = NULL,
7156 	.help_str = "set link-down port <port id>",
7157 	.tokens = {
7158 		(void *)&cmd_set_link_down_set,
7159 		(void *)&cmd_set_link_down_link_down,
7160 		(void *)&cmd_set_link_down_port,
7161 		(void *)&cmd_set_link_down_port_id,
7162 		NULL,
7163 	},
7164 };
7165 
7166 /* *** SHOW CFG *** */
7167 struct cmd_showcfg_result {
7168 	cmdline_fixed_string_t show;
7169 	cmdline_fixed_string_t cfg;
7170 	cmdline_fixed_string_t what;
7171 };
7172 
7173 static void cmd_showcfg_parsed(void *parsed_result,
7174 			       __attribute__((unused)) struct cmdline *cl,
7175 			       __attribute__((unused)) void *data)
7176 {
7177 	struct cmd_showcfg_result *res = parsed_result;
7178 	if (!strcmp(res->what, "rxtx"))
7179 		rxtx_config_display();
7180 	else if (!strcmp(res->what, "cores"))
7181 		fwd_lcores_config_display();
7182 	else if (!strcmp(res->what, "fwd"))
7183 		pkt_fwd_config_display(&cur_fwd_config);
7184 	else if (!strcmp(res->what, "txpkts"))
7185 		show_tx_pkt_segments();
7186 }
7187 
7188 cmdline_parse_token_string_t cmd_showcfg_show =
7189 	TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7190 cmdline_parse_token_string_t cmd_showcfg_port =
7191 	TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7192 cmdline_parse_token_string_t cmd_showcfg_what =
7193 	TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7194 				 "rxtx#cores#fwd#txpkts");
7195 
7196 cmdline_parse_inst_t cmd_showcfg = {
7197 	.f = cmd_showcfg_parsed,
7198 	.data = NULL,
7199 	.help_str = "show config rxtx|cores|fwd|txpkts",
7200 	.tokens = {
7201 		(void *)&cmd_showcfg_show,
7202 		(void *)&cmd_showcfg_port,
7203 		(void *)&cmd_showcfg_what,
7204 		NULL,
7205 	},
7206 };
7207 
7208 /* *** SHOW ALL PORT INFO *** */
7209 struct cmd_showportall_result {
7210 	cmdline_fixed_string_t show;
7211 	cmdline_fixed_string_t port;
7212 	cmdline_fixed_string_t what;
7213 	cmdline_fixed_string_t all;
7214 };
7215 
7216 static void cmd_showportall_parsed(void *parsed_result,
7217 				__attribute__((unused)) struct cmdline *cl,
7218 				__attribute__((unused)) void *data)
7219 {
7220 	portid_t i;
7221 
7222 	struct cmd_showportall_result *res = parsed_result;
7223 	if (!strcmp(res->show, "clear")) {
7224 		if (!strcmp(res->what, "stats"))
7225 			RTE_ETH_FOREACH_DEV(i)
7226 				nic_stats_clear(i);
7227 		else if (!strcmp(res->what, "xstats"))
7228 			RTE_ETH_FOREACH_DEV(i)
7229 				nic_xstats_clear(i);
7230 	} else if (!strcmp(res->what, "info"))
7231 		RTE_ETH_FOREACH_DEV(i)
7232 			port_infos_display(i);
7233 	else if (!strcmp(res->what, "summary")) {
7234 		port_summary_header_display();
7235 		RTE_ETH_FOREACH_DEV(i)
7236 			port_summary_display(i);
7237 	}
7238 	else if (!strcmp(res->what, "stats"))
7239 		RTE_ETH_FOREACH_DEV(i)
7240 			nic_stats_display(i);
7241 	else if (!strcmp(res->what, "xstats"))
7242 		RTE_ETH_FOREACH_DEV(i)
7243 			nic_xstats_display(i);
7244 	else if (!strcmp(res->what, "fdir"))
7245 		RTE_ETH_FOREACH_DEV(i)
7246 			fdir_get_infos(i);
7247 	else if (!strcmp(res->what, "stat_qmap"))
7248 		RTE_ETH_FOREACH_DEV(i)
7249 			nic_stats_mapping_display(i);
7250 	else if (!strcmp(res->what, "dcb_tc"))
7251 		RTE_ETH_FOREACH_DEV(i)
7252 			port_dcb_info_display(i);
7253 	else if (!strcmp(res->what, "cap"))
7254 		RTE_ETH_FOREACH_DEV(i)
7255 			port_offload_cap_display(i);
7256 }
7257 
7258 cmdline_parse_token_string_t cmd_showportall_show =
7259 	TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7260 				 "show#clear");
7261 cmdline_parse_token_string_t cmd_showportall_port =
7262 	TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7263 cmdline_parse_token_string_t cmd_showportall_what =
7264 	TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7265 				 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7266 cmdline_parse_token_string_t cmd_showportall_all =
7267 	TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7268 cmdline_parse_inst_t cmd_showportall = {
7269 	.f = cmd_showportall_parsed,
7270 	.data = NULL,
7271 	.help_str = "show|clear port "
7272 		"info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
7273 	.tokens = {
7274 		(void *)&cmd_showportall_show,
7275 		(void *)&cmd_showportall_port,
7276 		(void *)&cmd_showportall_what,
7277 		(void *)&cmd_showportall_all,
7278 		NULL,
7279 	},
7280 };
7281 
7282 /* *** SHOW PORT INFO *** */
7283 struct cmd_showport_result {
7284 	cmdline_fixed_string_t show;
7285 	cmdline_fixed_string_t port;
7286 	cmdline_fixed_string_t what;
7287 	uint16_t portnum;
7288 };
7289 
7290 static void cmd_showport_parsed(void *parsed_result,
7291 				__attribute__((unused)) struct cmdline *cl,
7292 				__attribute__((unused)) void *data)
7293 {
7294 	struct cmd_showport_result *res = parsed_result;
7295 	if (!strcmp(res->show, "clear")) {
7296 		if (!strcmp(res->what, "stats"))
7297 			nic_stats_clear(res->portnum);
7298 		else if (!strcmp(res->what, "xstats"))
7299 			nic_xstats_clear(res->portnum);
7300 	} else if (!strcmp(res->what, "info"))
7301 		port_infos_display(res->portnum);
7302 	else if (!strcmp(res->what, "summary")) {
7303 		port_summary_header_display();
7304 		port_summary_display(res->portnum);
7305 	}
7306 	else if (!strcmp(res->what, "stats"))
7307 		nic_stats_display(res->portnum);
7308 	else if (!strcmp(res->what, "xstats"))
7309 		nic_xstats_display(res->portnum);
7310 	else if (!strcmp(res->what, "fdir"))
7311 		 fdir_get_infos(res->portnum);
7312 	else if (!strcmp(res->what, "stat_qmap"))
7313 		nic_stats_mapping_display(res->portnum);
7314 	else if (!strcmp(res->what, "dcb_tc"))
7315 		port_dcb_info_display(res->portnum);
7316 	else if (!strcmp(res->what, "cap"))
7317 		port_offload_cap_display(res->portnum);
7318 }
7319 
7320 cmdline_parse_token_string_t cmd_showport_show =
7321 	TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7322 				 "show#clear");
7323 cmdline_parse_token_string_t cmd_showport_port =
7324 	TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7325 cmdline_parse_token_string_t cmd_showport_what =
7326 	TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7327 				 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7328 cmdline_parse_token_num_t cmd_showport_portnum =
7329 	TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
7330 
7331 cmdline_parse_inst_t cmd_showport = {
7332 	.f = cmd_showport_parsed,
7333 	.data = NULL,
7334 	.help_str = "show|clear port "
7335 		"info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
7336 		"<port_id>",
7337 	.tokens = {
7338 		(void *)&cmd_showport_show,
7339 		(void *)&cmd_showport_port,
7340 		(void *)&cmd_showport_what,
7341 		(void *)&cmd_showport_portnum,
7342 		NULL,
7343 	},
7344 };
7345 
7346 /* *** SHOW QUEUE INFO *** */
7347 struct cmd_showqueue_result {
7348 	cmdline_fixed_string_t show;
7349 	cmdline_fixed_string_t type;
7350 	cmdline_fixed_string_t what;
7351 	uint16_t portnum;
7352 	uint16_t queuenum;
7353 };
7354 
7355 static void
7356 cmd_showqueue_parsed(void *parsed_result,
7357 	__attribute__((unused)) struct cmdline *cl,
7358 	__attribute__((unused)) void *data)
7359 {
7360 	struct cmd_showqueue_result *res = parsed_result;
7361 
7362 	if (!strcmp(res->type, "rxq"))
7363 		rx_queue_infos_display(res->portnum, res->queuenum);
7364 	else if (!strcmp(res->type, "txq"))
7365 		tx_queue_infos_display(res->portnum, res->queuenum);
7366 }
7367 
7368 cmdline_parse_token_string_t cmd_showqueue_show =
7369 	TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
7370 cmdline_parse_token_string_t cmd_showqueue_type =
7371 	TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
7372 cmdline_parse_token_string_t cmd_showqueue_what =
7373 	TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
7374 cmdline_parse_token_num_t cmd_showqueue_portnum =
7375 	TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16);
7376 cmdline_parse_token_num_t cmd_showqueue_queuenum =
7377 	TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
7378 
7379 cmdline_parse_inst_t cmd_showqueue = {
7380 	.f = cmd_showqueue_parsed,
7381 	.data = NULL,
7382 	.help_str = "show rxq|txq info <port_id> <queue_id>",
7383 	.tokens = {
7384 		(void *)&cmd_showqueue_show,
7385 		(void *)&cmd_showqueue_type,
7386 		(void *)&cmd_showqueue_what,
7387 		(void *)&cmd_showqueue_portnum,
7388 		(void *)&cmd_showqueue_queuenum,
7389 		NULL,
7390 	},
7391 };
7392 
7393 /* show/clear fwd engine statistics */
7394 struct fwd_result {
7395 	cmdline_fixed_string_t action;
7396 	cmdline_fixed_string_t fwd;
7397 	cmdline_fixed_string_t stats;
7398 	cmdline_fixed_string_t all;
7399 };
7400 
7401 cmdline_parse_token_string_t cmd_fwd_action =
7402 	TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
7403 cmdline_parse_token_string_t cmd_fwd_fwd =
7404 	TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
7405 cmdline_parse_token_string_t cmd_fwd_stats =
7406 	TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
7407 cmdline_parse_token_string_t cmd_fwd_all =
7408 	TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
7409 
7410 static void
7411 cmd_showfwdall_parsed(void *parsed_result,
7412 		      __rte_unused struct cmdline *cl,
7413 		      __rte_unused void *data)
7414 {
7415 	struct fwd_result *res = parsed_result;
7416 
7417 	if (!strcmp(res->action, "show"))
7418 		fwd_stats_display();
7419 	else
7420 		fwd_stats_reset();
7421 }
7422 
7423 static cmdline_parse_inst_t cmd_showfwdall = {
7424 	.f = cmd_showfwdall_parsed,
7425 	.data = NULL,
7426 	.help_str = "show|clear fwd stats all",
7427 	.tokens = {
7428 		(void *)&cmd_fwd_action,
7429 		(void *)&cmd_fwd_fwd,
7430 		(void *)&cmd_fwd_stats,
7431 		(void *)&cmd_fwd_all,
7432 		NULL,
7433 	},
7434 };
7435 
7436 /* *** READ PORT REGISTER *** */
7437 struct cmd_read_reg_result {
7438 	cmdline_fixed_string_t read;
7439 	cmdline_fixed_string_t reg;
7440 	portid_t port_id;
7441 	uint32_t reg_off;
7442 };
7443 
7444 static void
7445 cmd_read_reg_parsed(void *parsed_result,
7446 		    __attribute__((unused)) struct cmdline *cl,
7447 		    __attribute__((unused)) void *data)
7448 {
7449 	struct cmd_read_reg_result *res = parsed_result;
7450 	port_reg_display(res->port_id, res->reg_off);
7451 }
7452 
7453 cmdline_parse_token_string_t cmd_read_reg_read =
7454 	TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
7455 cmdline_parse_token_string_t cmd_read_reg_reg =
7456 	TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
7457 cmdline_parse_token_num_t cmd_read_reg_port_id =
7458 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16);
7459 cmdline_parse_token_num_t cmd_read_reg_reg_off =
7460 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
7461 
7462 cmdline_parse_inst_t cmd_read_reg = {
7463 	.f = cmd_read_reg_parsed,
7464 	.data = NULL,
7465 	.help_str = "read reg <port_id> <reg_off>",
7466 	.tokens = {
7467 		(void *)&cmd_read_reg_read,
7468 		(void *)&cmd_read_reg_reg,
7469 		(void *)&cmd_read_reg_port_id,
7470 		(void *)&cmd_read_reg_reg_off,
7471 		NULL,
7472 	},
7473 };
7474 
7475 /* *** READ PORT REGISTER BIT FIELD *** */
7476 struct cmd_read_reg_bit_field_result {
7477 	cmdline_fixed_string_t read;
7478 	cmdline_fixed_string_t regfield;
7479 	portid_t port_id;
7480 	uint32_t reg_off;
7481 	uint8_t bit1_pos;
7482 	uint8_t bit2_pos;
7483 };
7484 
7485 static void
7486 cmd_read_reg_bit_field_parsed(void *parsed_result,
7487 			      __attribute__((unused)) struct cmdline *cl,
7488 			      __attribute__((unused)) void *data)
7489 {
7490 	struct cmd_read_reg_bit_field_result *res = parsed_result;
7491 	port_reg_bit_field_display(res->port_id, res->reg_off,
7492 				   res->bit1_pos, res->bit2_pos);
7493 }
7494 
7495 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
7496 	TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
7497 				 "read");
7498 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
7499 	TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
7500 				 regfield, "regfield");
7501 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
7502 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
7503 			      UINT16);
7504 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
7505 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
7506 			      UINT32);
7507 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
7508 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
7509 			      UINT8);
7510 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
7511 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
7512 			      UINT8);
7513 
7514 cmdline_parse_inst_t cmd_read_reg_bit_field = {
7515 	.f = cmd_read_reg_bit_field_parsed,
7516 	.data = NULL,
7517 	.help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
7518 	"Read register bit field between bit_x and bit_y included",
7519 	.tokens = {
7520 		(void *)&cmd_read_reg_bit_field_read,
7521 		(void *)&cmd_read_reg_bit_field_regfield,
7522 		(void *)&cmd_read_reg_bit_field_port_id,
7523 		(void *)&cmd_read_reg_bit_field_reg_off,
7524 		(void *)&cmd_read_reg_bit_field_bit1_pos,
7525 		(void *)&cmd_read_reg_bit_field_bit2_pos,
7526 		NULL,
7527 	},
7528 };
7529 
7530 /* *** READ PORT REGISTER BIT *** */
7531 struct cmd_read_reg_bit_result {
7532 	cmdline_fixed_string_t read;
7533 	cmdline_fixed_string_t regbit;
7534 	portid_t port_id;
7535 	uint32_t reg_off;
7536 	uint8_t bit_pos;
7537 };
7538 
7539 static void
7540 cmd_read_reg_bit_parsed(void *parsed_result,
7541 			__attribute__((unused)) struct cmdline *cl,
7542 			__attribute__((unused)) void *data)
7543 {
7544 	struct cmd_read_reg_bit_result *res = parsed_result;
7545 	port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
7546 }
7547 
7548 cmdline_parse_token_string_t cmd_read_reg_bit_read =
7549 	TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
7550 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
7551 	TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
7552 				 regbit, "regbit");
7553 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
7554 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16);
7555 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
7556 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
7557 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
7558 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
7559 
7560 cmdline_parse_inst_t cmd_read_reg_bit = {
7561 	.f = cmd_read_reg_bit_parsed,
7562 	.data = NULL,
7563 	.help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
7564 	.tokens = {
7565 		(void *)&cmd_read_reg_bit_read,
7566 		(void *)&cmd_read_reg_bit_regbit,
7567 		(void *)&cmd_read_reg_bit_port_id,
7568 		(void *)&cmd_read_reg_bit_reg_off,
7569 		(void *)&cmd_read_reg_bit_bit_pos,
7570 		NULL,
7571 	},
7572 };
7573 
7574 /* *** WRITE PORT REGISTER *** */
7575 struct cmd_write_reg_result {
7576 	cmdline_fixed_string_t write;
7577 	cmdline_fixed_string_t reg;
7578 	portid_t port_id;
7579 	uint32_t reg_off;
7580 	uint32_t value;
7581 };
7582 
7583 static void
7584 cmd_write_reg_parsed(void *parsed_result,
7585 		     __attribute__((unused)) struct cmdline *cl,
7586 		     __attribute__((unused)) void *data)
7587 {
7588 	struct cmd_write_reg_result *res = parsed_result;
7589 	port_reg_set(res->port_id, res->reg_off, res->value);
7590 }
7591 
7592 cmdline_parse_token_string_t cmd_write_reg_write =
7593 	TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
7594 cmdline_parse_token_string_t cmd_write_reg_reg =
7595 	TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
7596 cmdline_parse_token_num_t cmd_write_reg_port_id =
7597 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16);
7598 cmdline_parse_token_num_t cmd_write_reg_reg_off =
7599 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
7600 cmdline_parse_token_num_t cmd_write_reg_value =
7601 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
7602 
7603 cmdline_parse_inst_t cmd_write_reg = {
7604 	.f = cmd_write_reg_parsed,
7605 	.data = NULL,
7606 	.help_str = "write reg <port_id> <reg_off> <reg_value>",
7607 	.tokens = {
7608 		(void *)&cmd_write_reg_write,
7609 		(void *)&cmd_write_reg_reg,
7610 		(void *)&cmd_write_reg_port_id,
7611 		(void *)&cmd_write_reg_reg_off,
7612 		(void *)&cmd_write_reg_value,
7613 		NULL,
7614 	},
7615 };
7616 
7617 /* *** WRITE PORT REGISTER BIT FIELD *** */
7618 struct cmd_write_reg_bit_field_result {
7619 	cmdline_fixed_string_t write;
7620 	cmdline_fixed_string_t regfield;
7621 	portid_t port_id;
7622 	uint32_t reg_off;
7623 	uint8_t bit1_pos;
7624 	uint8_t bit2_pos;
7625 	uint32_t value;
7626 };
7627 
7628 static void
7629 cmd_write_reg_bit_field_parsed(void *parsed_result,
7630 			       __attribute__((unused)) struct cmdline *cl,
7631 			       __attribute__((unused)) void *data)
7632 {
7633 	struct cmd_write_reg_bit_field_result *res = parsed_result;
7634 	port_reg_bit_field_set(res->port_id, res->reg_off,
7635 			  res->bit1_pos, res->bit2_pos, res->value);
7636 }
7637 
7638 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
7639 	TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
7640 				 "write");
7641 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
7642 	TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
7643 				 regfield, "regfield");
7644 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
7645 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
7646 			      UINT16);
7647 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
7648 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
7649 			      UINT32);
7650 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
7651 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
7652 			      UINT8);
7653 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
7654 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
7655 			      UINT8);
7656 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
7657 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
7658 			      UINT32);
7659 
7660 cmdline_parse_inst_t cmd_write_reg_bit_field = {
7661 	.f = cmd_write_reg_bit_field_parsed,
7662 	.data = NULL,
7663 	.help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
7664 		"<reg_value>: "
7665 		"Set register bit field between bit_x and bit_y included",
7666 	.tokens = {
7667 		(void *)&cmd_write_reg_bit_field_write,
7668 		(void *)&cmd_write_reg_bit_field_regfield,
7669 		(void *)&cmd_write_reg_bit_field_port_id,
7670 		(void *)&cmd_write_reg_bit_field_reg_off,
7671 		(void *)&cmd_write_reg_bit_field_bit1_pos,
7672 		(void *)&cmd_write_reg_bit_field_bit2_pos,
7673 		(void *)&cmd_write_reg_bit_field_value,
7674 		NULL,
7675 	},
7676 };
7677 
7678 /* *** WRITE PORT REGISTER BIT *** */
7679 struct cmd_write_reg_bit_result {
7680 	cmdline_fixed_string_t write;
7681 	cmdline_fixed_string_t regbit;
7682 	portid_t port_id;
7683 	uint32_t reg_off;
7684 	uint8_t bit_pos;
7685 	uint8_t value;
7686 };
7687 
7688 static void
7689 cmd_write_reg_bit_parsed(void *parsed_result,
7690 			 __attribute__((unused)) struct cmdline *cl,
7691 			 __attribute__((unused)) void *data)
7692 {
7693 	struct cmd_write_reg_bit_result *res = parsed_result;
7694 	port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
7695 }
7696 
7697 cmdline_parse_token_string_t cmd_write_reg_bit_write =
7698 	TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
7699 				 "write");
7700 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
7701 	TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
7702 				 regbit, "regbit");
7703 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
7704 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16);
7705 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
7706 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
7707 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
7708 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
7709 cmdline_parse_token_num_t cmd_write_reg_bit_value =
7710 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
7711 
7712 cmdline_parse_inst_t cmd_write_reg_bit = {
7713 	.f = cmd_write_reg_bit_parsed,
7714 	.data = NULL,
7715 	.help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
7716 		"0 <= bit_x <= 31",
7717 	.tokens = {
7718 		(void *)&cmd_write_reg_bit_write,
7719 		(void *)&cmd_write_reg_bit_regbit,
7720 		(void *)&cmd_write_reg_bit_port_id,
7721 		(void *)&cmd_write_reg_bit_reg_off,
7722 		(void *)&cmd_write_reg_bit_bit_pos,
7723 		(void *)&cmd_write_reg_bit_value,
7724 		NULL,
7725 	},
7726 };
7727 
7728 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
7729 struct cmd_read_rxd_txd_result {
7730 	cmdline_fixed_string_t read;
7731 	cmdline_fixed_string_t rxd_txd;
7732 	portid_t port_id;
7733 	uint16_t queue_id;
7734 	uint16_t desc_id;
7735 };
7736 
7737 static void
7738 cmd_read_rxd_txd_parsed(void *parsed_result,
7739 			__attribute__((unused)) struct cmdline *cl,
7740 			__attribute__((unused)) void *data)
7741 {
7742 	struct cmd_read_rxd_txd_result *res = parsed_result;
7743 
7744 	if (!strcmp(res->rxd_txd, "rxd"))
7745 		rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7746 	else if (!strcmp(res->rxd_txd, "txd"))
7747 		tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7748 }
7749 
7750 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
7751 	TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
7752 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
7753 	TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
7754 				 "rxd#txd");
7755 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
7756 	TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16);
7757 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
7758 	TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
7759 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
7760 	TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
7761 
7762 cmdline_parse_inst_t cmd_read_rxd_txd = {
7763 	.f = cmd_read_rxd_txd_parsed,
7764 	.data = NULL,
7765 	.help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
7766 	.tokens = {
7767 		(void *)&cmd_read_rxd_txd_read,
7768 		(void *)&cmd_read_rxd_txd_rxd_txd,
7769 		(void *)&cmd_read_rxd_txd_port_id,
7770 		(void *)&cmd_read_rxd_txd_queue_id,
7771 		(void *)&cmd_read_rxd_txd_desc_id,
7772 		NULL,
7773 	},
7774 };
7775 
7776 /* *** QUIT *** */
7777 struct cmd_quit_result {
7778 	cmdline_fixed_string_t quit;
7779 };
7780 
7781 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
7782 			    struct cmdline *cl,
7783 			    __attribute__((unused)) void *data)
7784 {
7785 	cmdline_quit(cl);
7786 }
7787 
7788 cmdline_parse_token_string_t cmd_quit_quit =
7789 	TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
7790 
7791 cmdline_parse_inst_t cmd_quit = {
7792 	.f = cmd_quit_parsed,
7793 	.data = NULL,
7794 	.help_str = "quit: Exit application",
7795 	.tokens = {
7796 		(void *)&cmd_quit_quit,
7797 		NULL,
7798 	},
7799 };
7800 
7801 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
7802 struct cmd_mac_addr_result {
7803 	cmdline_fixed_string_t mac_addr_cmd;
7804 	cmdline_fixed_string_t what;
7805 	uint16_t port_num;
7806 	struct ether_addr address;
7807 };
7808 
7809 static void cmd_mac_addr_parsed(void *parsed_result,
7810 		__attribute__((unused)) struct cmdline *cl,
7811 		__attribute__((unused)) void *data)
7812 {
7813 	struct cmd_mac_addr_result *res = parsed_result;
7814 	int ret;
7815 
7816 	if (strcmp(res->what, "add") == 0)
7817 		ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
7818 	else if (strcmp(res->what, "set") == 0)
7819 		ret = rte_eth_dev_default_mac_addr_set(res->port_num,
7820 						       &res->address);
7821 	else
7822 		ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
7823 
7824 	/* check the return value and print it if is < 0 */
7825 	if(ret < 0)
7826 		printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
7827 
7828 }
7829 
7830 cmdline_parse_token_string_t cmd_mac_addr_cmd =
7831 	TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
7832 				"mac_addr");
7833 cmdline_parse_token_string_t cmd_mac_addr_what =
7834 	TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
7835 				"add#remove#set");
7836 cmdline_parse_token_num_t cmd_mac_addr_portnum =
7837 		TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
7838 					UINT16);
7839 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
7840 		TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
7841 
7842 cmdline_parse_inst_t cmd_mac_addr = {
7843 	.f = cmd_mac_addr_parsed,
7844 	.data = (void *)0,
7845 	.help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
7846 			"Add/Remove/Set MAC address on port_id",
7847 	.tokens = {
7848 		(void *)&cmd_mac_addr_cmd,
7849 		(void *)&cmd_mac_addr_what,
7850 		(void *)&cmd_mac_addr_portnum,
7851 		(void *)&cmd_mac_addr_addr,
7852 		NULL,
7853 	},
7854 };
7855 
7856 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
7857 struct cmd_eth_peer_result {
7858 	cmdline_fixed_string_t set;
7859 	cmdline_fixed_string_t eth_peer;
7860 	portid_t port_id;
7861 	cmdline_fixed_string_t peer_addr;
7862 };
7863 
7864 static void cmd_set_eth_peer_parsed(void *parsed_result,
7865 			__attribute__((unused)) struct cmdline *cl,
7866 			__attribute__((unused)) void *data)
7867 {
7868 		struct cmd_eth_peer_result *res = parsed_result;
7869 
7870 		if (test_done == 0) {
7871 			printf("Please stop forwarding first\n");
7872 			return;
7873 		}
7874 		if (!strcmp(res->eth_peer, "eth-peer")) {
7875 			set_fwd_eth_peer(res->port_id, res->peer_addr);
7876 			fwd_config_setup();
7877 		}
7878 }
7879 cmdline_parse_token_string_t cmd_eth_peer_set =
7880 	TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
7881 cmdline_parse_token_string_t cmd_eth_peer =
7882 	TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
7883 cmdline_parse_token_num_t cmd_eth_peer_port_id =
7884 	TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, UINT16);
7885 cmdline_parse_token_string_t cmd_eth_peer_addr =
7886 	TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
7887 
7888 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
7889 	.f = cmd_set_eth_peer_parsed,
7890 	.data = NULL,
7891 	.help_str = "set eth-peer <port_id> <peer_mac>",
7892 	.tokens = {
7893 		(void *)&cmd_eth_peer_set,
7894 		(void *)&cmd_eth_peer,
7895 		(void *)&cmd_eth_peer_port_id,
7896 		(void *)&cmd_eth_peer_addr,
7897 		NULL,
7898 	},
7899 };
7900 
7901 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
7902 struct cmd_set_qmap_result {
7903 	cmdline_fixed_string_t set;
7904 	cmdline_fixed_string_t qmap;
7905 	cmdline_fixed_string_t what;
7906 	portid_t port_id;
7907 	uint16_t queue_id;
7908 	uint8_t map_value;
7909 };
7910 
7911 static void
7912 cmd_set_qmap_parsed(void *parsed_result,
7913 		       __attribute__((unused)) struct cmdline *cl,
7914 		       __attribute__((unused)) void *data)
7915 {
7916 	struct cmd_set_qmap_result *res = parsed_result;
7917 	int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
7918 
7919 	set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
7920 }
7921 
7922 cmdline_parse_token_string_t cmd_setqmap_set =
7923 	TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7924 				 set, "set");
7925 cmdline_parse_token_string_t cmd_setqmap_qmap =
7926 	TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7927 				 qmap, "stat_qmap");
7928 cmdline_parse_token_string_t cmd_setqmap_what =
7929 	TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7930 				 what, "tx#rx");
7931 cmdline_parse_token_num_t cmd_setqmap_portid =
7932 	TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7933 			      port_id, UINT16);
7934 cmdline_parse_token_num_t cmd_setqmap_queueid =
7935 	TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7936 			      queue_id, UINT16);
7937 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
7938 	TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7939 			      map_value, UINT8);
7940 
7941 cmdline_parse_inst_t cmd_set_qmap = {
7942 	.f = cmd_set_qmap_parsed,
7943 	.data = NULL,
7944 	.help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
7945 		"Set statistics mapping value on tx|rx queue_id of port_id",
7946 	.tokens = {
7947 		(void *)&cmd_setqmap_set,
7948 		(void *)&cmd_setqmap_qmap,
7949 		(void *)&cmd_setqmap_what,
7950 		(void *)&cmd_setqmap_portid,
7951 		(void *)&cmd_setqmap_queueid,
7952 		(void *)&cmd_setqmap_mapvalue,
7953 		NULL,
7954 	},
7955 };
7956 
7957 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS  DISPLAY *** */
7958 struct cmd_set_xstats_hide_zero_result {
7959 	cmdline_fixed_string_t keyword;
7960 	cmdline_fixed_string_t name;
7961 	cmdline_fixed_string_t on_off;
7962 };
7963 
7964 static void
7965 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
7966 			__attribute__((unused)) struct cmdline *cl,
7967 			__attribute__((unused)) void *data)
7968 {
7969 	struct cmd_set_xstats_hide_zero_result *res;
7970 	uint16_t on_off = 0;
7971 
7972 	res = parsed_result;
7973 	on_off = !strcmp(res->on_off, "on") ? 1 : 0;
7974 	set_xstats_hide_zero(on_off);
7975 }
7976 
7977 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
7978 	TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7979 				 keyword, "set");
7980 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
7981 	TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7982 				 name, "xstats-hide-zero");
7983 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
7984 	TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7985 				 on_off, "on#off");
7986 
7987 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
7988 	.f = cmd_set_xstats_hide_zero_parsed,
7989 	.data = NULL,
7990 	.help_str = "set xstats-hide-zero on|off",
7991 	.tokens = {
7992 		(void *)&cmd_set_xstats_hide_zero_keyword,
7993 		(void *)&cmd_set_xstats_hide_zero_name,
7994 		(void *)&cmd_set_xstats_hide_zero_on_off,
7995 		NULL,
7996 	},
7997 };
7998 
7999 /* *** CONFIGURE UNICAST HASH TABLE *** */
8000 struct cmd_set_uc_hash_table {
8001 	cmdline_fixed_string_t set;
8002 	cmdline_fixed_string_t port;
8003 	portid_t port_id;
8004 	cmdline_fixed_string_t what;
8005 	struct ether_addr address;
8006 	cmdline_fixed_string_t mode;
8007 };
8008 
8009 static void
8010 cmd_set_uc_hash_parsed(void *parsed_result,
8011 		       __attribute__((unused)) struct cmdline *cl,
8012 		       __attribute__((unused)) void *data)
8013 {
8014 	int ret=0;
8015 	struct cmd_set_uc_hash_table *res = parsed_result;
8016 
8017 	int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8018 
8019 	if (strcmp(res->what, "uta") == 0)
8020 		ret = rte_eth_dev_uc_hash_table_set(res->port_id,
8021 						&res->address,(uint8_t)is_on);
8022 	if (ret < 0)
8023 		printf("bad unicast hash table parameter, return code = %d \n", ret);
8024 
8025 }
8026 
8027 cmdline_parse_token_string_t cmd_set_uc_hash_set =
8028 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8029 				 set, "set");
8030 cmdline_parse_token_string_t cmd_set_uc_hash_port =
8031 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8032 				 port, "port");
8033 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
8034 	TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
8035 			      port_id, UINT16);
8036 cmdline_parse_token_string_t cmd_set_uc_hash_what =
8037 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8038 				 what, "uta");
8039 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
8040 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
8041 				address);
8042 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
8043 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8044 				 mode, "on#off");
8045 
8046 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
8047 	.f = cmd_set_uc_hash_parsed,
8048 	.data = NULL,
8049 	.help_str = "set port <port_id> uta <mac_addr> on|off)",
8050 	.tokens = {
8051 		(void *)&cmd_set_uc_hash_set,
8052 		(void *)&cmd_set_uc_hash_port,
8053 		(void *)&cmd_set_uc_hash_portid,
8054 		(void *)&cmd_set_uc_hash_what,
8055 		(void *)&cmd_set_uc_hash_mac,
8056 		(void *)&cmd_set_uc_hash_mode,
8057 		NULL,
8058 	},
8059 };
8060 
8061 struct cmd_set_uc_all_hash_table {
8062 	cmdline_fixed_string_t set;
8063 	cmdline_fixed_string_t port;
8064 	portid_t port_id;
8065 	cmdline_fixed_string_t what;
8066 	cmdline_fixed_string_t value;
8067 	cmdline_fixed_string_t mode;
8068 };
8069 
8070 static void
8071 cmd_set_uc_all_hash_parsed(void *parsed_result,
8072 		       __attribute__((unused)) struct cmdline *cl,
8073 		       __attribute__((unused)) void *data)
8074 {
8075 	int ret=0;
8076 	struct cmd_set_uc_all_hash_table *res = parsed_result;
8077 
8078 	int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8079 
8080 	if ((strcmp(res->what, "uta") == 0) &&
8081 		(strcmp(res->value, "all") == 0))
8082 		ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
8083 	if (ret < 0)
8084 		printf("bad unicast hash table parameter,"
8085 			"return code = %d \n", ret);
8086 }
8087 
8088 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
8089 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8090 				 set, "set");
8091 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
8092 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8093 				 port, "port");
8094 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
8095 	TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
8096 			      port_id, UINT16);
8097 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
8098 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8099 				 what, "uta");
8100 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
8101 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8102 				value,"all");
8103 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
8104 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8105 				 mode, "on#off");
8106 
8107 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
8108 	.f = cmd_set_uc_all_hash_parsed,
8109 	.data = NULL,
8110 	.help_str = "set port <port_id> uta all on|off",
8111 	.tokens = {
8112 		(void *)&cmd_set_uc_all_hash_set,
8113 		(void *)&cmd_set_uc_all_hash_port,
8114 		(void *)&cmd_set_uc_all_hash_portid,
8115 		(void *)&cmd_set_uc_all_hash_what,
8116 		(void *)&cmd_set_uc_all_hash_value,
8117 		(void *)&cmd_set_uc_all_hash_mode,
8118 		NULL,
8119 	},
8120 };
8121 
8122 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
8123 struct cmd_set_vf_macvlan_filter {
8124 	cmdline_fixed_string_t set;
8125 	cmdline_fixed_string_t port;
8126 	portid_t port_id;
8127 	cmdline_fixed_string_t vf;
8128 	uint8_t vf_id;
8129 	struct ether_addr address;
8130 	cmdline_fixed_string_t filter_type;
8131 	cmdline_fixed_string_t mode;
8132 };
8133 
8134 static void
8135 cmd_set_vf_macvlan_parsed(void *parsed_result,
8136 		       __attribute__((unused)) struct cmdline *cl,
8137 		       __attribute__((unused)) void *data)
8138 {
8139 	int is_on, ret = 0;
8140 	struct cmd_set_vf_macvlan_filter *res = parsed_result;
8141 	struct rte_eth_mac_filter filter;
8142 
8143 	memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
8144 
8145 	rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
8146 
8147 	/* set VF MAC filter */
8148 	filter.is_vf = 1;
8149 
8150 	/* set VF ID */
8151 	filter.dst_id = res->vf_id;
8152 
8153 	if (!strcmp(res->filter_type, "exact-mac"))
8154 		filter.filter_type = RTE_MAC_PERFECT_MATCH;
8155 	else if (!strcmp(res->filter_type, "exact-mac-vlan"))
8156 		filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
8157 	else if (!strcmp(res->filter_type, "hashmac"))
8158 		filter.filter_type = RTE_MAC_HASH_MATCH;
8159 	else if (!strcmp(res->filter_type, "hashmac-vlan"))
8160 		filter.filter_type = RTE_MACVLAN_HASH_MATCH;
8161 
8162 	is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8163 
8164 	if (is_on)
8165 		ret = rte_eth_dev_filter_ctrl(res->port_id,
8166 					RTE_ETH_FILTER_MACVLAN,
8167 					RTE_ETH_FILTER_ADD,
8168 					 &filter);
8169 	else
8170 		ret = rte_eth_dev_filter_ctrl(res->port_id,
8171 					RTE_ETH_FILTER_MACVLAN,
8172 					RTE_ETH_FILTER_DELETE,
8173 					&filter);
8174 
8175 	if (ret < 0)
8176 		printf("bad set MAC hash parameter, return code = %d\n", ret);
8177 
8178 }
8179 
8180 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
8181 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8182 				 set, "set");
8183 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
8184 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8185 				 port, "port");
8186 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
8187 	TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8188 			      port_id, UINT16);
8189 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
8190 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8191 				 vf, "vf");
8192 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
8193 	TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8194 				vf_id, UINT8);
8195 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
8196 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8197 				address);
8198 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
8199 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8200 				filter_type, "exact-mac#exact-mac-vlan"
8201 				"#hashmac#hashmac-vlan");
8202 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
8203 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8204 				 mode, "on#off");
8205 
8206 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
8207 	.f = cmd_set_vf_macvlan_parsed,
8208 	.data = NULL,
8209 	.help_str = "set port <port_id> vf <vf_id> <mac_addr> "
8210 		"exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
8211 		"Exact match rule: exact match of MAC or MAC and VLAN; "
8212 		"hash match rule: hash match of MAC and exact match of VLAN",
8213 	.tokens = {
8214 		(void *)&cmd_set_vf_macvlan_set,
8215 		(void *)&cmd_set_vf_macvlan_port,
8216 		(void *)&cmd_set_vf_macvlan_portid,
8217 		(void *)&cmd_set_vf_macvlan_vf,
8218 		(void *)&cmd_set_vf_macvlan_vf_id,
8219 		(void *)&cmd_set_vf_macvlan_mac,
8220 		(void *)&cmd_set_vf_macvlan_filter_type,
8221 		(void *)&cmd_set_vf_macvlan_mode,
8222 		NULL,
8223 	},
8224 };
8225 
8226 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
8227 struct cmd_set_vf_traffic {
8228 	cmdline_fixed_string_t set;
8229 	cmdline_fixed_string_t port;
8230 	portid_t port_id;
8231 	cmdline_fixed_string_t vf;
8232 	uint8_t vf_id;
8233 	cmdline_fixed_string_t what;
8234 	cmdline_fixed_string_t mode;
8235 };
8236 
8237 static void
8238 cmd_set_vf_traffic_parsed(void *parsed_result,
8239 		       __attribute__((unused)) struct cmdline *cl,
8240 		       __attribute__((unused)) void *data)
8241 {
8242 	struct cmd_set_vf_traffic *res = parsed_result;
8243 	int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
8244 	int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8245 
8246 	set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
8247 }
8248 
8249 cmdline_parse_token_string_t cmd_setvf_traffic_set =
8250 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8251 				 set, "set");
8252 cmdline_parse_token_string_t cmd_setvf_traffic_port =
8253 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8254 				 port, "port");
8255 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8256 	TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8257 			      port_id, UINT16);
8258 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8259 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8260 				 vf, "vf");
8261 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8262 	TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8263 			      vf_id, UINT8);
8264 cmdline_parse_token_string_t cmd_setvf_traffic_what =
8265 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8266 				 what, "tx#rx");
8267 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8268 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8269 				 mode, "on#off");
8270 
8271 cmdline_parse_inst_t cmd_set_vf_traffic = {
8272 	.f = cmd_set_vf_traffic_parsed,
8273 	.data = NULL,
8274 	.help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8275 	.tokens = {
8276 		(void *)&cmd_setvf_traffic_set,
8277 		(void *)&cmd_setvf_traffic_port,
8278 		(void *)&cmd_setvf_traffic_portid,
8279 		(void *)&cmd_setvf_traffic_vf,
8280 		(void *)&cmd_setvf_traffic_vfid,
8281 		(void *)&cmd_setvf_traffic_what,
8282 		(void *)&cmd_setvf_traffic_mode,
8283 		NULL,
8284 	},
8285 };
8286 
8287 /* *** CONFIGURE VF RECEIVE MODE *** */
8288 struct cmd_set_vf_rxmode {
8289 	cmdline_fixed_string_t set;
8290 	cmdline_fixed_string_t port;
8291 	portid_t port_id;
8292 	cmdline_fixed_string_t vf;
8293 	uint8_t vf_id;
8294 	cmdline_fixed_string_t what;
8295 	cmdline_fixed_string_t mode;
8296 	cmdline_fixed_string_t on;
8297 };
8298 
8299 static void
8300 cmd_set_vf_rxmode_parsed(void *parsed_result,
8301 		       __attribute__((unused)) struct cmdline *cl,
8302 		       __attribute__((unused)) void *data)
8303 {
8304 	int ret = -ENOTSUP;
8305 	uint16_t rx_mode = 0;
8306 	struct cmd_set_vf_rxmode *res = parsed_result;
8307 
8308 	int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8309 	if (!strcmp(res->what,"rxmode")) {
8310 		if (!strcmp(res->mode, "AUPE"))
8311 			rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
8312 		else if (!strcmp(res->mode, "ROPE"))
8313 			rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
8314 		else if (!strcmp(res->mode, "BAM"))
8315 			rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
8316 		else if (!strncmp(res->mode, "MPE",3))
8317 			rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
8318 	}
8319 
8320 	RTE_SET_USED(is_on);
8321 
8322 #ifdef RTE_LIBRTE_IXGBE_PMD
8323 	if (ret == -ENOTSUP)
8324 		ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8325 						  rx_mode, (uint8_t)is_on);
8326 #endif
8327 #ifdef RTE_LIBRTE_BNXT_PMD
8328 	if (ret == -ENOTSUP)
8329 		ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8330 						 rx_mode, (uint8_t)is_on);
8331 #endif
8332 	if (ret < 0)
8333 		printf("bad VF receive mode parameter, return code = %d \n",
8334 		ret);
8335 }
8336 
8337 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8338 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8339 				 set, "set");
8340 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8341 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8342 				 port, "port");
8343 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8344 	TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8345 			      port_id, UINT16);
8346 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8347 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8348 				 vf, "vf");
8349 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8350 	TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8351 			      vf_id, UINT8);
8352 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
8353 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8354 				 what, "rxmode");
8355 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
8356 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8357 				 mode, "AUPE#ROPE#BAM#MPE");
8358 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
8359 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8360 				 on, "on#off");
8361 
8362 cmdline_parse_inst_t cmd_set_vf_rxmode = {
8363 	.f = cmd_set_vf_rxmode_parsed,
8364 	.data = NULL,
8365 	.help_str = "set port <port_id> vf <vf_id> rxmode "
8366 		"AUPE|ROPE|BAM|MPE on|off",
8367 	.tokens = {
8368 		(void *)&cmd_set_vf_rxmode_set,
8369 		(void *)&cmd_set_vf_rxmode_port,
8370 		(void *)&cmd_set_vf_rxmode_portid,
8371 		(void *)&cmd_set_vf_rxmode_vf,
8372 		(void *)&cmd_set_vf_rxmode_vfid,
8373 		(void *)&cmd_set_vf_rxmode_what,
8374 		(void *)&cmd_set_vf_rxmode_mode,
8375 		(void *)&cmd_set_vf_rxmode_on,
8376 		NULL,
8377 	},
8378 };
8379 
8380 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
8381 struct cmd_vf_mac_addr_result {
8382 	cmdline_fixed_string_t mac_addr_cmd;
8383 	cmdline_fixed_string_t what;
8384 	cmdline_fixed_string_t port;
8385 	uint16_t port_num;
8386 	cmdline_fixed_string_t vf;
8387 	uint8_t vf_num;
8388 	struct ether_addr address;
8389 };
8390 
8391 static void cmd_vf_mac_addr_parsed(void *parsed_result,
8392 		__attribute__((unused)) struct cmdline *cl,
8393 		__attribute__((unused)) void *data)
8394 {
8395 	struct cmd_vf_mac_addr_result *res = parsed_result;
8396 	int ret = -ENOTSUP;
8397 
8398 	if (strcmp(res->what, "add") != 0)
8399 		return;
8400 
8401 #ifdef RTE_LIBRTE_I40E_PMD
8402 	if (ret == -ENOTSUP)
8403 		ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
8404 						   &res->address);
8405 #endif
8406 #ifdef RTE_LIBRTE_BNXT_PMD
8407 	if (ret == -ENOTSUP)
8408 		ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
8409 						res->vf_num);
8410 #endif
8411 
8412 	if(ret < 0)
8413 		printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
8414 
8415 }
8416 
8417 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
8418 	TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8419 				mac_addr_cmd,"mac_addr");
8420 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
8421 	TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8422 				what,"add");
8423 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
8424 	TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8425 				port,"port");
8426 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
8427 	TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8428 				port_num, UINT16);
8429 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
8430 	TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8431 				vf,"vf");
8432 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
8433 	TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8434 				vf_num, UINT8);
8435 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
8436 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
8437 				address);
8438 
8439 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
8440 	.f = cmd_vf_mac_addr_parsed,
8441 	.data = (void *)0,
8442 	.help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
8443 		"Add MAC address filtering for a VF on port_id",
8444 	.tokens = {
8445 		(void *)&cmd_vf_mac_addr_cmd,
8446 		(void *)&cmd_vf_mac_addr_what,
8447 		(void *)&cmd_vf_mac_addr_port,
8448 		(void *)&cmd_vf_mac_addr_portnum,
8449 		(void *)&cmd_vf_mac_addr_vf,
8450 		(void *)&cmd_vf_mac_addr_vfnum,
8451 		(void *)&cmd_vf_mac_addr_addr,
8452 		NULL,
8453 	},
8454 };
8455 
8456 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
8457 struct cmd_vf_rx_vlan_filter {
8458 	cmdline_fixed_string_t rx_vlan;
8459 	cmdline_fixed_string_t what;
8460 	uint16_t vlan_id;
8461 	cmdline_fixed_string_t port;
8462 	portid_t port_id;
8463 	cmdline_fixed_string_t vf;
8464 	uint64_t vf_mask;
8465 };
8466 
8467 static void
8468 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
8469 			  __attribute__((unused)) struct cmdline *cl,
8470 			  __attribute__((unused)) void *data)
8471 {
8472 	struct cmd_vf_rx_vlan_filter *res = parsed_result;
8473 	int ret = -ENOTSUP;
8474 
8475 	__rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
8476 
8477 #ifdef RTE_LIBRTE_IXGBE_PMD
8478 	if (ret == -ENOTSUP)
8479 		ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
8480 				res->vlan_id, res->vf_mask, is_add);
8481 #endif
8482 #ifdef RTE_LIBRTE_I40E_PMD
8483 	if (ret == -ENOTSUP)
8484 		ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
8485 				res->vlan_id, res->vf_mask, is_add);
8486 #endif
8487 #ifdef RTE_LIBRTE_BNXT_PMD
8488 	if (ret == -ENOTSUP)
8489 		ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
8490 				res->vlan_id, res->vf_mask, is_add);
8491 #endif
8492 
8493 	switch (ret) {
8494 	case 0:
8495 		break;
8496 	case -EINVAL:
8497 		printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
8498 				res->vlan_id, res->vf_mask);
8499 		break;
8500 	case -ENODEV:
8501 		printf("invalid port_id %d\n", res->port_id);
8502 		break;
8503 	case -ENOTSUP:
8504 		printf("function not implemented or supported\n");
8505 		break;
8506 	default:
8507 		printf("programming error: (%s)\n", strerror(-ret));
8508 	}
8509 }
8510 
8511 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
8512 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8513 				 rx_vlan, "rx_vlan");
8514 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
8515 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8516 				 what, "add#rm");
8517 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
8518 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8519 			      vlan_id, UINT16);
8520 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
8521 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8522 				 port, "port");
8523 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
8524 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8525 			      port_id, UINT16);
8526 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
8527 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8528 				 vf, "vf");
8529 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
8530 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8531 			      vf_mask, UINT64);
8532 
8533 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
8534 	.f = cmd_vf_rx_vlan_filter_parsed,
8535 	.data = NULL,
8536 	.help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
8537 		"(vf_mask = hexadecimal VF mask)",
8538 	.tokens = {
8539 		(void *)&cmd_vf_rx_vlan_filter_rx_vlan,
8540 		(void *)&cmd_vf_rx_vlan_filter_what,
8541 		(void *)&cmd_vf_rx_vlan_filter_vlanid,
8542 		(void *)&cmd_vf_rx_vlan_filter_port,
8543 		(void *)&cmd_vf_rx_vlan_filter_portid,
8544 		(void *)&cmd_vf_rx_vlan_filter_vf,
8545 		(void *)&cmd_vf_rx_vlan_filter_vf_mask,
8546 		NULL,
8547 	},
8548 };
8549 
8550 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
8551 struct cmd_queue_rate_limit_result {
8552 	cmdline_fixed_string_t set;
8553 	cmdline_fixed_string_t port;
8554 	uint16_t port_num;
8555 	cmdline_fixed_string_t queue;
8556 	uint8_t queue_num;
8557 	cmdline_fixed_string_t rate;
8558 	uint16_t rate_num;
8559 };
8560 
8561 static void cmd_queue_rate_limit_parsed(void *parsed_result,
8562 		__attribute__((unused)) struct cmdline *cl,
8563 		__attribute__((unused)) void *data)
8564 {
8565 	struct cmd_queue_rate_limit_result *res = parsed_result;
8566 	int ret = 0;
8567 
8568 	if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8569 		&& (strcmp(res->queue, "queue") == 0)
8570 		&& (strcmp(res->rate, "rate") == 0))
8571 		ret = set_queue_rate_limit(res->port_num, res->queue_num,
8572 					res->rate_num);
8573 	if (ret < 0)
8574 		printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
8575 
8576 }
8577 
8578 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
8579 	TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8580 				set, "set");
8581 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
8582 	TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8583 				port, "port");
8584 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
8585 	TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8586 				port_num, UINT16);
8587 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
8588 	TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8589 				queue, "queue");
8590 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
8591 	TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8592 				queue_num, UINT8);
8593 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
8594 	TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8595 				rate, "rate");
8596 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
8597 	TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8598 				rate_num, UINT16);
8599 
8600 cmdline_parse_inst_t cmd_queue_rate_limit = {
8601 	.f = cmd_queue_rate_limit_parsed,
8602 	.data = (void *)0,
8603 	.help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
8604 		"Set rate limit for a queue on port_id",
8605 	.tokens = {
8606 		(void *)&cmd_queue_rate_limit_set,
8607 		(void *)&cmd_queue_rate_limit_port,
8608 		(void *)&cmd_queue_rate_limit_portnum,
8609 		(void *)&cmd_queue_rate_limit_queue,
8610 		(void *)&cmd_queue_rate_limit_queuenum,
8611 		(void *)&cmd_queue_rate_limit_rate,
8612 		(void *)&cmd_queue_rate_limit_ratenum,
8613 		NULL,
8614 	},
8615 };
8616 
8617 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
8618 struct cmd_vf_rate_limit_result {
8619 	cmdline_fixed_string_t set;
8620 	cmdline_fixed_string_t port;
8621 	uint16_t port_num;
8622 	cmdline_fixed_string_t vf;
8623 	uint8_t vf_num;
8624 	cmdline_fixed_string_t rate;
8625 	uint16_t rate_num;
8626 	cmdline_fixed_string_t q_msk;
8627 	uint64_t q_msk_val;
8628 };
8629 
8630 static void cmd_vf_rate_limit_parsed(void *parsed_result,
8631 		__attribute__((unused)) struct cmdline *cl,
8632 		__attribute__((unused)) void *data)
8633 {
8634 	struct cmd_vf_rate_limit_result *res = parsed_result;
8635 	int ret = 0;
8636 
8637 	if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8638 		&& (strcmp(res->vf, "vf") == 0)
8639 		&& (strcmp(res->rate, "rate") == 0)
8640 		&& (strcmp(res->q_msk, "queue_mask") == 0))
8641 		ret = set_vf_rate_limit(res->port_num, res->vf_num,
8642 					res->rate_num, res->q_msk_val);
8643 	if (ret < 0)
8644 		printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
8645 
8646 }
8647 
8648 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
8649 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8650 				set, "set");
8651 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
8652 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8653 				port, "port");
8654 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
8655 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8656 				port_num, UINT16);
8657 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
8658 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8659 				vf, "vf");
8660 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
8661 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8662 				vf_num, UINT8);
8663 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
8664 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8665 				rate, "rate");
8666 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
8667 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8668 				rate_num, UINT16);
8669 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
8670 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8671 				q_msk, "queue_mask");
8672 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
8673 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8674 				q_msk_val, UINT64);
8675 
8676 cmdline_parse_inst_t cmd_vf_rate_limit = {
8677 	.f = cmd_vf_rate_limit_parsed,
8678 	.data = (void *)0,
8679 	.help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
8680 		"queue_mask <queue_mask_value>: "
8681 		"Set rate limit for queues of VF on port_id",
8682 	.tokens = {
8683 		(void *)&cmd_vf_rate_limit_set,
8684 		(void *)&cmd_vf_rate_limit_port,
8685 		(void *)&cmd_vf_rate_limit_portnum,
8686 		(void *)&cmd_vf_rate_limit_vf,
8687 		(void *)&cmd_vf_rate_limit_vfnum,
8688 		(void *)&cmd_vf_rate_limit_rate,
8689 		(void *)&cmd_vf_rate_limit_ratenum,
8690 		(void *)&cmd_vf_rate_limit_q_msk,
8691 		(void *)&cmd_vf_rate_limit_q_msk_val,
8692 		NULL,
8693 	},
8694 };
8695 
8696 /* *** ADD TUNNEL FILTER OF A PORT *** */
8697 struct cmd_tunnel_filter_result {
8698 	cmdline_fixed_string_t cmd;
8699 	cmdline_fixed_string_t what;
8700 	portid_t port_id;
8701 	struct ether_addr outer_mac;
8702 	struct ether_addr inner_mac;
8703 	cmdline_ipaddr_t ip_value;
8704 	uint16_t inner_vlan;
8705 	cmdline_fixed_string_t tunnel_type;
8706 	cmdline_fixed_string_t filter_type;
8707 	uint32_t tenant_id;
8708 	uint16_t queue_num;
8709 };
8710 
8711 static void
8712 cmd_tunnel_filter_parsed(void *parsed_result,
8713 			  __attribute__((unused)) struct cmdline *cl,
8714 			  __attribute__((unused)) void *data)
8715 {
8716 	struct cmd_tunnel_filter_result *res = parsed_result;
8717 	struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
8718 	int ret = 0;
8719 
8720 	memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
8721 
8722 	ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
8723 	ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
8724 	tunnel_filter_conf.inner_vlan = res->inner_vlan;
8725 
8726 	if (res->ip_value.family == AF_INET) {
8727 		tunnel_filter_conf.ip_addr.ipv4_addr =
8728 			res->ip_value.addr.ipv4.s_addr;
8729 		tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
8730 	} else {
8731 		memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
8732 			&(res->ip_value.addr.ipv6),
8733 			sizeof(struct in6_addr));
8734 		tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
8735 	}
8736 
8737 	if (!strcmp(res->filter_type, "imac-ivlan"))
8738 		tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
8739 	else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
8740 		tunnel_filter_conf.filter_type =
8741 			RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
8742 	else if (!strcmp(res->filter_type, "imac-tenid"))
8743 		tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
8744 	else if (!strcmp(res->filter_type, "imac"))
8745 		tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
8746 	else if (!strcmp(res->filter_type, "omac-imac-tenid"))
8747 		tunnel_filter_conf.filter_type =
8748 			RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
8749 	else if (!strcmp(res->filter_type, "oip"))
8750 		tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
8751 	else if (!strcmp(res->filter_type, "iip"))
8752 		tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
8753 	else {
8754 		printf("The filter type is not supported");
8755 		return;
8756 	}
8757 
8758 	if (!strcmp(res->tunnel_type, "vxlan"))
8759 		tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
8760 	else if (!strcmp(res->tunnel_type, "vxlan-gpe"))
8761 		tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
8762 	else if (!strcmp(res->tunnel_type, "nvgre"))
8763 		tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
8764 	else if (!strcmp(res->tunnel_type, "ipingre"))
8765 		tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
8766 	else {
8767 		printf("The tunnel type %s not supported.\n", res->tunnel_type);
8768 		return;
8769 	}
8770 
8771 	tunnel_filter_conf.tenant_id = res->tenant_id;
8772 	tunnel_filter_conf.queue_id = res->queue_num;
8773 	if (!strcmp(res->what, "add"))
8774 		ret = rte_eth_dev_filter_ctrl(res->port_id,
8775 					RTE_ETH_FILTER_TUNNEL,
8776 					RTE_ETH_FILTER_ADD,
8777 					&tunnel_filter_conf);
8778 	else
8779 		ret = rte_eth_dev_filter_ctrl(res->port_id,
8780 					RTE_ETH_FILTER_TUNNEL,
8781 					RTE_ETH_FILTER_DELETE,
8782 					&tunnel_filter_conf);
8783 	if (ret < 0)
8784 		printf("cmd_tunnel_filter_parsed error: (%s)\n",
8785 				strerror(-ret));
8786 
8787 }
8788 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
8789 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8790 	cmd, "tunnel_filter");
8791 cmdline_parse_token_string_t cmd_tunnel_filter_what =
8792 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8793 	what, "add#rm");
8794 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
8795 	TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8796 	port_id, UINT16);
8797 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
8798 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8799 	outer_mac);
8800 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
8801 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8802 	inner_mac);
8803 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
8804 	TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8805 	inner_vlan, UINT16);
8806 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
8807 	TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8808 	ip_value);
8809 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
8810 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8811 	tunnel_type, "vxlan#nvgre#ipingre#vxlan-gpe");
8812 
8813 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
8814 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8815 	filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
8816 		"imac#omac-imac-tenid");
8817 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
8818 	TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8819 	tenant_id, UINT32);
8820 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
8821 	TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8822 	queue_num, UINT16);
8823 
8824 cmdline_parse_inst_t cmd_tunnel_filter = {
8825 	.f = cmd_tunnel_filter_parsed,
8826 	.data = (void *)0,
8827 	.help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
8828 		"<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
8829 		"imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
8830 		"<queue_id>: Add/Rm tunnel filter of a port",
8831 	.tokens = {
8832 		(void *)&cmd_tunnel_filter_cmd,
8833 		(void *)&cmd_tunnel_filter_what,
8834 		(void *)&cmd_tunnel_filter_port_id,
8835 		(void *)&cmd_tunnel_filter_outer_mac,
8836 		(void *)&cmd_tunnel_filter_inner_mac,
8837 		(void *)&cmd_tunnel_filter_ip_value,
8838 		(void *)&cmd_tunnel_filter_innner_vlan,
8839 		(void *)&cmd_tunnel_filter_tunnel_type,
8840 		(void *)&cmd_tunnel_filter_filter_type,
8841 		(void *)&cmd_tunnel_filter_tenant_id,
8842 		(void *)&cmd_tunnel_filter_queue_num,
8843 		NULL,
8844 	},
8845 };
8846 
8847 /* *** CONFIGURE TUNNEL UDP PORT *** */
8848 struct cmd_tunnel_udp_config {
8849 	cmdline_fixed_string_t cmd;
8850 	cmdline_fixed_string_t what;
8851 	uint16_t udp_port;
8852 	portid_t port_id;
8853 };
8854 
8855 static void
8856 cmd_tunnel_udp_config_parsed(void *parsed_result,
8857 			  __attribute__((unused)) struct cmdline *cl,
8858 			  __attribute__((unused)) void *data)
8859 {
8860 	struct cmd_tunnel_udp_config *res = parsed_result;
8861 	struct rte_eth_udp_tunnel tunnel_udp;
8862 	int ret;
8863 
8864 	tunnel_udp.udp_port = res->udp_port;
8865 
8866 	if (!strcmp(res->cmd, "rx_vxlan_port"))
8867 		tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
8868 
8869 	if (!strcmp(res->what, "add"))
8870 		ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
8871 						      &tunnel_udp);
8872 	else
8873 		ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
8874 							 &tunnel_udp);
8875 
8876 	if (ret < 0)
8877 		printf("udp tunneling add error: (%s)\n", strerror(-ret));
8878 }
8879 
8880 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
8881 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8882 				cmd, "rx_vxlan_port");
8883 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
8884 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8885 				what, "add#rm");
8886 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
8887 	TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8888 				udp_port, UINT16);
8889 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
8890 	TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8891 				port_id, UINT16);
8892 
8893 cmdline_parse_inst_t cmd_tunnel_udp_config = {
8894 	.f = cmd_tunnel_udp_config_parsed,
8895 	.data = (void *)0,
8896 	.help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
8897 		"Add/Remove a tunneling UDP port filter",
8898 	.tokens = {
8899 		(void *)&cmd_tunnel_udp_config_cmd,
8900 		(void *)&cmd_tunnel_udp_config_what,
8901 		(void *)&cmd_tunnel_udp_config_udp_port,
8902 		(void *)&cmd_tunnel_udp_config_port_id,
8903 		NULL,
8904 	},
8905 };
8906 
8907 struct cmd_config_tunnel_udp_port {
8908 	cmdline_fixed_string_t port;
8909 	cmdline_fixed_string_t config;
8910 	portid_t port_id;
8911 	cmdline_fixed_string_t udp_tunnel_port;
8912 	cmdline_fixed_string_t action;
8913 	cmdline_fixed_string_t tunnel_type;
8914 	uint16_t udp_port;
8915 };
8916 
8917 static void
8918 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
8919 			       __attribute__((unused)) struct cmdline *cl,
8920 			       __attribute__((unused)) void *data)
8921 {
8922 	struct cmd_config_tunnel_udp_port *res = parsed_result;
8923 	struct rte_eth_udp_tunnel tunnel_udp;
8924 	int ret = 0;
8925 
8926 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8927 		return;
8928 
8929 	tunnel_udp.udp_port = res->udp_port;
8930 
8931 	if (!strcmp(res->tunnel_type, "vxlan")) {
8932 		tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
8933 	} else if (!strcmp(res->tunnel_type, "geneve")) {
8934 		tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE;
8935 	} else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
8936 		tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
8937 	} else {
8938 		printf("Invalid tunnel type\n");
8939 		return;
8940 	}
8941 
8942 	if (!strcmp(res->action, "add"))
8943 		ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
8944 						      &tunnel_udp);
8945 	else
8946 		ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
8947 							 &tunnel_udp);
8948 
8949 	if (ret < 0)
8950 		printf("udp tunneling port add error: (%s)\n", strerror(-ret));
8951 }
8952 
8953 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
8954 	TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
8955 				 "port");
8956 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
8957 	TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
8958 				 "config");
8959 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
8960 	TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
8961 			      UINT16);
8962 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
8963 	TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
8964 				 udp_tunnel_port,
8965 				 "udp_tunnel_port");
8966 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
8967 	TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
8968 				 "add#rm");
8969 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
8970 	TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
8971 				 "vxlan#geneve#vxlan-gpe");
8972 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
8973 	TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
8974 			      UINT16);
8975 
8976 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
8977 	.f = cmd_cfg_tunnel_udp_port_parsed,
8978 	.data = NULL,
8979 	.help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|geneve|vxlan-gpe <udp_port>",
8980 	.tokens = {
8981 		(void *)&cmd_config_tunnel_udp_port_port,
8982 		(void *)&cmd_config_tunnel_udp_port_config,
8983 		(void *)&cmd_config_tunnel_udp_port_port_id,
8984 		(void *)&cmd_config_tunnel_udp_port_tunnel_port,
8985 		(void *)&cmd_config_tunnel_udp_port_action,
8986 		(void *)&cmd_config_tunnel_udp_port_tunnel_type,
8987 		(void *)&cmd_config_tunnel_udp_port_value,
8988 		NULL,
8989 	},
8990 };
8991 
8992 /* *** GLOBAL CONFIG *** */
8993 struct cmd_global_config_result {
8994 	cmdline_fixed_string_t cmd;
8995 	portid_t port_id;
8996 	cmdline_fixed_string_t cfg_type;
8997 	uint8_t len;
8998 };
8999 
9000 static void
9001 cmd_global_config_parsed(void *parsed_result,
9002 			 __attribute__((unused)) struct cmdline *cl,
9003 			 __attribute__((unused)) void *data)
9004 {
9005 	struct cmd_global_config_result *res = parsed_result;
9006 	struct rte_eth_global_cfg conf;
9007 	int ret;
9008 
9009 	memset(&conf, 0, sizeof(conf));
9010 	conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
9011 	conf.cfg.gre_key_len = res->len;
9012 	ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
9013 				      RTE_ETH_FILTER_SET, &conf);
9014 	if (ret != 0)
9015 		printf("Global config error\n");
9016 }
9017 
9018 cmdline_parse_token_string_t cmd_global_config_cmd =
9019 	TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
9020 		"global_config");
9021 cmdline_parse_token_num_t cmd_global_config_port_id =
9022 	TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id,
9023 			       UINT16);
9024 cmdline_parse_token_string_t cmd_global_config_type =
9025 	TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
9026 		cfg_type, "gre-key-len");
9027 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
9028 	TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
9029 		len, UINT8);
9030 
9031 cmdline_parse_inst_t cmd_global_config = {
9032 	.f = cmd_global_config_parsed,
9033 	.data = (void *)NULL,
9034 	.help_str = "global_config <port_id> gre-key-len <key_len>",
9035 	.tokens = {
9036 		(void *)&cmd_global_config_cmd,
9037 		(void *)&cmd_global_config_port_id,
9038 		(void *)&cmd_global_config_type,
9039 		(void *)&cmd_global_config_gre_key_len,
9040 		NULL,
9041 	},
9042 };
9043 
9044 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
9045 struct cmd_set_mirror_mask_result {
9046 	cmdline_fixed_string_t set;
9047 	cmdline_fixed_string_t port;
9048 	portid_t port_id;
9049 	cmdline_fixed_string_t mirror;
9050 	uint8_t rule_id;
9051 	cmdline_fixed_string_t what;
9052 	cmdline_fixed_string_t value;
9053 	cmdline_fixed_string_t dstpool;
9054 	uint8_t dstpool_id;
9055 	cmdline_fixed_string_t on;
9056 };
9057 
9058 cmdline_parse_token_string_t cmd_mirror_mask_set =
9059 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9060 				set, "set");
9061 cmdline_parse_token_string_t cmd_mirror_mask_port =
9062 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9063 				port, "port");
9064 cmdline_parse_token_num_t cmd_mirror_mask_portid =
9065 	TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9066 				port_id, UINT16);
9067 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
9068 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9069 				mirror, "mirror-rule");
9070 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
9071 	TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9072 				rule_id, UINT8);
9073 cmdline_parse_token_string_t cmd_mirror_mask_what =
9074 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9075 				what, "pool-mirror-up#pool-mirror-down"
9076 				      "#vlan-mirror");
9077 cmdline_parse_token_string_t cmd_mirror_mask_value =
9078 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9079 				value, NULL);
9080 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
9081 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9082 				dstpool, "dst-pool");
9083 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
9084 	TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9085 				dstpool_id, UINT8);
9086 cmdline_parse_token_string_t cmd_mirror_mask_on =
9087 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9088 				on, "on#off");
9089 
9090 static void
9091 cmd_set_mirror_mask_parsed(void *parsed_result,
9092 		       __attribute__((unused)) struct cmdline *cl,
9093 		       __attribute__((unused)) void *data)
9094 {
9095 	int ret,nb_item,i;
9096 	struct cmd_set_mirror_mask_result *res = parsed_result;
9097 	struct rte_eth_mirror_conf mr_conf;
9098 
9099 	memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9100 
9101 	unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
9102 
9103 	mr_conf.dst_pool = res->dstpool_id;
9104 
9105 	if (!strcmp(res->what, "pool-mirror-up")) {
9106 		mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9107 		mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
9108 	} else if (!strcmp(res->what, "pool-mirror-down")) {
9109 		mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9110 		mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
9111 	} else if (!strcmp(res->what, "vlan-mirror")) {
9112 		mr_conf.rule_type = ETH_MIRROR_VLAN;
9113 		nb_item = parse_item_list(res->value, "vlan",
9114 				ETH_MIRROR_MAX_VLANS, vlan_list, 1);
9115 		if (nb_item <= 0)
9116 			return;
9117 
9118 		for (i = 0; i < nb_item; i++) {
9119 			if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
9120 				printf("Invalid vlan_id: must be < 4096\n");
9121 				return;
9122 			}
9123 
9124 			mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
9125 			mr_conf.vlan.vlan_mask |= 1ULL << i;
9126 		}
9127 	}
9128 
9129 	if (!strcmp(res->on, "on"))
9130 		ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9131 						res->rule_id, 1);
9132 	else
9133 		ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9134 						res->rule_id, 0);
9135 	if (ret < 0)
9136 		printf("mirror rule add error: (%s)\n", strerror(-ret));
9137 }
9138 
9139 cmdline_parse_inst_t cmd_set_mirror_mask = {
9140 		.f = cmd_set_mirror_mask_parsed,
9141 		.data = NULL,
9142 		.help_str = "set port <port_id> mirror-rule <rule_id> "
9143 			"pool-mirror-up|pool-mirror-down|vlan-mirror "
9144 			"<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
9145 		.tokens = {
9146 			(void *)&cmd_mirror_mask_set,
9147 			(void *)&cmd_mirror_mask_port,
9148 			(void *)&cmd_mirror_mask_portid,
9149 			(void *)&cmd_mirror_mask_mirror,
9150 			(void *)&cmd_mirror_mask_ruleid,
9151 			(void *)&cmd_mirror_mask_what,
9152 			(void *)&cmd_mirror_mask_value,
9153 			(void *)&cmd_mirror_mask_dstpool,
9154 			(void *)&cmd_mirror_mask_poolid,
9155 			(void *)&cmd_mirror_mask_on,
9156 			NULL,
9157 		},
9158 };
9159 
9160 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
9161 struct cmd_set_mirror_link_result {
9162 	cmdline_fixed_string_t set;
9163 	cmdline_fixed_string_t port;
9164 	portid_t port_id;
9165 	cmdline_fixed_string_t mirror;
9166 	uint8_t rule_id;
9167 	cmdline_fixed_string_t what;
9168 	cmdline_fixed_string_t dstpool;
9169 	uint8_t dstpool_id;
9170 	cmdline_fixed_string_t on;
9171 };
9172 
9173 cmdline_parse_token_string_t cmd_mirror_link_set =
9174 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9175 				 set, "set");
9176 cmdline_parse_token_string_t cmd_mirror_link_port =
9177 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9178 				port, "port");
9179 cmdline_parse_token_num_t cmd_mirror_link_portid =
9180 	TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9181 				port_id, UINT16);
9182 cmdline_parse_token_string_t cmd_mirror_link_mirror =
9183 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9184 				mirror, "mirror-rule");
9185 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
9186 	TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9187 			    rule_id, UINT8);
9188 cmdline_parse_token_string_t cmd_mirror_link_what =
9189 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9190 				what, "uplink-mirror#downlink-mirror");
9191 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
9192 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9193 				dstpool, "dst-pool");
9194 cmdline_parse_token_num_t cmd_mirror_link_poolid =
9195 	TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9196 				dstpool_id, UINT8);
9197 cmdline_parse_token_string_t cmd_mirror_link_on =
9198 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9199 				on, "on#off");
9200 
9201 static void
9202 cmd_set_mirror_link_parsed(void *parsed_result,
9203 		       __attribute__((unused)) struct cmdline *cl,
9204 		       __attribute__((unused)) void *data)
9205 {
9206 	int ret;
9207 	struct cmd_set_mirror_link_result *res = parsed_result;
9208 	struct rte_eth_mirror_conf mr_conf;
9209 
9210 	memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9211 	if (!strcmp(res->what, "uplink-mirror"))
9212 		mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
9213 	else
9214 		mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
9215 
9216 	mr_conf.dst_pool = res->dstpool_id;
9217 
9218 	if (!strcmp(res->on, "on"))
9219 		ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9220 						res->rule_id, 1);
9221 	else
9222 		ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9223 						res->rule_id, 0);
9224 
9225 	/* check the return value and print it if is < 0 */
9226 	if (ret < 0)
9227 		printf("mirror rule add error: (%s)\n", strerror(-ret));
9228 
9229 }
9230 
9231 cmdline_parse_inst_t cmd_set_mirror_link = {
9232 		.f = cmd_set_mirror_link_parsed,
9233 		.data = NULL,
9234 		.help_str = "set port <port_id> mirror-rule <rule_id> "
9235 			"uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
9236 		.tokens = {
9237 			(void *)&cmd_mirror_link_set,
9238 			(void *)&cmd_mirror_link_port,
9239 			(void *)&cmd_mirror_link_portid,
9240 			(void *)&cmd_mirror_link_mirror,
9241 			(void *)&cmd_mirror_link_ruleid,
9242 			(void *)&cmd_mirror_link_what,
9243 			(void *)&cmd_mirror_link_dstpool,
9244 			(void *)&cmd_mirror_link_poolid,
9245 			(void *)&cmd_mirror_link_on,
9246 			NULL,
9247 		},
9248 };
9249 
9250 /* *** RESET VM MIRROR RULE *** */
9251 struct cmd_rm_mirror_rule_result {
9252 	cmdline_fixed_string_t reset;
9253 	cmdline_fixed_string_t port;
9254 	portid_t port_id;
9255 	cmdline_fixed_string_t mirror;
9256 	uint8_t rule_id;
9257 };
9258 
9259 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
9260 	TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9261 				 reset, "reset");
9262 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
9263 	TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9264 				port, "port");
9265 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
9266 	TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9267 				port_id, UINT16);
9268 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
9269 	TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9270 				mirror, "mirror-rule");
9271 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
9272 	TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9273 				rule_id, UINT8);
9274 
9275 static void
9276 cmd_reset_mirror_rule_parsed(void *parsed_result,
9277 		       __attribute__((unused)) struct cmdline *cl,
9278 		       __attribute__((unused)) void *data)
9279 {
9280 	int ret;
9281 	struct cmd_set_mirror_link_result *res = parsed_result;
9282         /* check rule_id */
9283 	ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
9284 	if(ret < 0)
9285 		printf("mirror rule remove error: (%s)\n", strerror(-ret));
9286 }
9287 
9288 cmdline_parse_inst_t cmd_reset_mirror_rule = {
9289 		.f = cmd_reset_mirror_rule_parsed,
9290 		.data = NULL,
9291 		.help_str = "reset port <port_id> mirror-rule <rule_id>",
9292 		.tokens = {
9293 			(void *)&cmd_rm_mirror_rule_reset,
9294 			(void *)&cmd_rm_mirror_rule_port,
9295 			(void *)&cmd_rm_mirror_rule_portid,
9296 			(void *)&cmd_rm_mirror_rule_mirror,
9297 			(void *)&cmd_rm_mirror_rule_ruleid,
9298 			NULL,
9299 		},
9300 };
9301 
9302 /* ******************************************************************************** */
9303 
9304 struct cmd_dump_result {
9305 	cmdline_fixed_string_t dump;
9306 };
9307 
9308 static void
9309 dump_struct_sizes(void)
9310 {
9311 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9312 	DUMP_SIZE(struct rte_mbuf);
9313 	DUMP_SIZE(struct rte_mempool);
9314 	DUMP_SIZE(struct rte_ring);
9315 #undef DUMP_SIZE
9316 }
9317 
9318 static void cmd_dump_parsed(void *parsed_result,
9319 			    __attribute__((unused)) struct cmdline *cl,
9320 			    __attribute__((unused)) void *data)
9321 {
9322 	struct cmd_dump_result *res = parsed_result;
9323 
9324 	if (!strcmp(res->dump, "dump_physmem"))
9325 		rte_dump_physmem_layout(stdout);
9326 	else if (!strcmp(res->dump, "dump_memzone"))
9327 		rte_memzone_dump(stdout);
9328 	else if (!strcmp(res->dump, "dump_struct_sizes"))
9329 		dump_struct_sizes();
9330 	else if (!strcmp(res->dump, "dump_ring"))
9331 		rte_ring_list_dump(stdout);
9332 	else if (!strcmp(res->dump, "dump_mempool"))
9333 		rte_mempool_list_dump(stdout);
9334 	else if (!strcmp(res->dump, "dump_devargs"))
9335 		rte_devargs_dump(stdout);
9336 	else if (!strcmp(res->dump, "dump_log_types"))
9337 		rte_log_dump(stdout);
9338 }
9339 
9340 cmdline_parse_token_string_t cmd_dump_dump =
9341 	TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9342 		"dump_physmem#"
9343 		"dump_memzone#"
9344 		"dump_struct_sizes#"
9345 		"dump_ring#"
9346 		"dump_mempool#"
9347 		"dump_devargs#"
9348 		"dump_log_types");
9349 
9350 cmdline_parse_inst_t cmd_dump = {
9351 	.f = cmd_dump_parsed,  /* function to call */
9352 	.data = NULL,      /* 2nd arg of func */
9353 	.help_str = "Dump status",
9354 	.tokens = {        /* token list, NULL terminated */
9355 		(void *)&cmd_dump_dump,
9356 		NULL,
9357 	},
9358 };
9359 
9360 /* ******************************************************************************** */
9361 
9362 struct cmd_dump_one_result {
9363 	cmdline_fixed_string_t dump;
9364 	cmdline_fixed_string_t name;
9365 };
9366 
9367 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9368 				__attribute__((unused)) void *data)
9369 {
9370 	struct cmd_dump_one_result *res = parsed_result;
9371 
9372 	if (!strcmp(res->dump, "dump_ring")) {
9373 		struct rte_ring *r;
9374 		r = rte_ring_lookup(res->name);
9375 		if (r == NULL) {
9376 			cmdline_printf(cl, "Cannot find ring\n");
9377 			return;
9378 		}
9379 		rte_ring_dump(stdout, r);
9380 	} else if (!strcmp(res->dump, "dump_mempool")) {
9381 		struct rte_mempool *mp;
9382 		mp = rte_mempool_lookup(res->name);
9383 		if (mp == NULL) {
9384 			cmdline_printf(cl, "Cannot find mempool\n");
9385 			return;
9386 		}
9387 		rte_mempool_dump(stdout, mp);
9388 	}
9389 }
9390 
9391 cmdline_parse_token_string_t cmd_dump_one_dump =
9392 	TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9393 				 "dump_ring#dump_mempool");
9394 
9395 cmdline_parse_token_string_t cmd_dump_one_name =
9396 	TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9397 
9398 cmdline_parse_inst_t cmd_dump_one = {
9399 	.f = cmd_dump_one_parsed,  /* function to call */
9400 	.data = NULL,      /* 2nd arg of func */
9401 	.help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9402 	.tokens = {        /* token list, NULL terminated */
9403 		(void *)&cmd_dump_one_dump,
9404 		(void *)&cmd_dump_one_name,
9405 		NULL,
9406 	},
9407 };
9408 
9409 /* *** Add/Del syn filter *** */
9410 struct cmd_syn_filter_result {
9411 	cmdline_fixed_string_t filter;
9412 	portid_t port_id;
9413 	cmdline_fixed_string_t ops;
9414 	cmdline_fixed_string_t priority;
9415 	cmdline_fixed_string_t high;
9416 	cmdline_fixed_string_t queue;
9417 	uint16_t queue_id;
9418 };
9419 
9420 static void
9421 cmd_syn_filter_parsed(void *parsed_result,
9422 			__attribute__((unused)) struct cmdline *cl,
9423 			__attribute__((unused)) void *data)
9424 {
9425 	struct cmd_syn_filter_result *res = parsed_result;
9426 	struct rte_eth_syn_filter syn_filter;
9427 	int ret = 0;
9428 
9429 	ret = rte_eth_dev_filter_supported(res->port_id,
9430 					RTE_ETH_FILTER_SYN);
9431 	if (ret < 0) {
9432 		printf("syn filter is not supported on port %u.\n",
9433 				res->port_id);
9434 		return;
9435 	}
9436 
9437 	memset(&syn_filter, 0, sizeof(syn_filter));
9438 
9439 	if (!strcmp(res->ops, "add")) {
9440 		if (!strcmp(res->high, "high"))
9441 			syn_filter.hig_pri = 1;
9442 		else
9443 			syn_filter.hig_pri = 0;
9444 
9445 		syn_filter.queue = res->queue_id;
9446 		ret = rte_eth_dev_filter_ctrl(res->port_id,
9447 						RTE_ETH_FILTER_SYN,
9448 						RTE_ETH_FILTER_ADD,
9449 						&syn_filter);
9450 	} else
9451 		ret = rte_eth_dev_filter_ctrl(res->port_id,
9452 						RTE_ETH_FILTER_SYN,
9453 						RTE_ETH_FILTER_DELETE,
9454 						&syn_filter);
9455 
9456 	if (ret < 0)
9457 		printf("syn filter programming error: (%s)\n",
9458 				strerror(-ret));
9459 }
9460 
9461 cmdline_parse_token_string_t cmd_syn_filter_filter =
9462 	TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9463 	filter, "syn_filter");
9464 cmdline_parse_token_num_t cmd_syn_filter_port_id =
9465 	TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9466 	port_id, UINT16);
9467 cmdline_parse_token_string_t cmd_syn_filter_ops =
9468 	TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9469 	ops, "add#del");
9470 cmdline_parse_token_string_t cmd_syn_filter_priority =
9471 	TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9472 				priority, "priority");
9473 cmdline_parse_token_string_t cmd_syn_filter_high =
9474 	TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9475 				high, "high#low");
9476 cmdline_parse_token_string_t cmd_syn_filter_queue =
9477 	TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9478 				queue, "queue");
9479 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
9480 	TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9481 				queue_id, UINT16);
9482 
9483 cmdline_parse_inst_t cmd_syn_filter = {
9484 	.f = cmd_syn_filter_parsed,
9485 	.data = NULL,
9486 	.help_str = "syn_filter <port_id> add|del priority high|low queue "
9487 		"<queue_id>: Add/Delete syn filter",
9488 	.tokens = {
9489 		(void *)&cmd_syn_filter_filter,
9490 		(void *)&cmd_syn_filter_port_id,
9491 		(void *)&cmd_syn_filter_ops,
9492 		(void *)&cmd_syn_filter_priority,
9493 		(void *)&cmd_syn_filter_high,
9494 		(void *)&cmd_syn_filter_queue,
9495 		(void *)&cmd_syn_filter_queue_id,
9496 		NULL,
9497 	},
9498 };
9499 
9500 /* *** queue region set *** */
9501 struct cmd_queue_region_result {
9502 	cmdline_fixed_string_t set;
9503 	cmdline_fixed_string_t port;
9504 	portid_t port_id;
9505 	cmdline_fixed_string_t cmd;
9506 	cmdline_fixed_string_t region;
9507 	uint8_t  region_id;
9508 	cmdline_fixed_string_t queue_start_index;
9509 	uint8_t  queue_id;
9510 	cmdline_fixed_string_t queue_num;
9511 	uint8_t  queue_num_value;
9512 };
9513 
9514 static void
9515 cmd_queue_region_parsed(void *parsed_result,
9516 			__attribute__((unused)) struct cmdline *cl,
9517 			__attribute__((unused)) void *data)
9518 {
9519 	struct cmd_queue_region_result *res = parsed_result;
9520 	int ret = -ENOTSUP;
9521 #ifdef RTE_LIBRTE_I40E_PMD
9522 	struct rte_pmd_i40e_queue_region_conf region_conf;
9523 	enum rte_pmd_i40e_queue_region_op op_type;
9524 #endif
9525 
9526 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9527 		return;
9528 
9529 #ifdef RTE_LIBRTE_I40E_PMD
9530 	memset(&region_conf, 0, sizeof(region_conf));
9531 	op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
9532 	region_conf.region_id = res->region_id;
9533 	region_conf.queue_num = res->queue_num_value;
9534 	region_conf.queue_start_index = res->queue_id;
9535 
9536 	ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9537 				op_type, &region_conf);
9538 #endif
9539 
9540 	switch (ret) {
9541 	case 0:
9542 		break;
9543 	case -ENOTSUP:
9544 		printf("function not implemented or supported\n");
9545 		break;
9546 	default:
9547 		printf("queue region config error: (%s)\n", strerror(-ret));
9548 	}
9549 }
9550 
9551 cmdline_parse_token_string_t cmd_queue_region_set =
9552 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9553 		set, "set");
9554 cmdline_parse_token_string_t cmd_queue_region_port =
9555 	TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
9556 cmdline_parse_token_num_t cmd_queue_region_port_id =
9557 	TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9558 				port_id, UINT16);
9559 cmdline_parse_token_string_t cmd_queue_region_cmd =
9560 	TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9561 				 cmd, "queue-region");
9562 cmdline_parse_token_string_t cmd_queue_region_id =
9563 	TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9564 				region, "region_id");
9565 cmdline_parse_token_num_t cmd_queue_region_index =
9566 	TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9567 				region_id, UINT8);
9568 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
9569 	TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9570 				queue_start_index, "queue_start_index");
9571 cmdline_parse_token_num_t cmd_queue_region_queue_id =
9572 	TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9573 				queue_id, UINT8);
9574 cmdline_parse_token_string_t cmd_queue_region_queue_num =
9575 	TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9576 				queue_num, "queue_num");
9577 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
9578 	TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9579 				queue_num_value, UINT8);
9580 
9581 cmdline_parse_inst_t cmd_queue_region = {
9582 	.f = cmd_queue_region_parsed,
9583 	.data = NULL,
9584 	.help_str = "set port <port_id> queue-region region_id <value> "
9585 		"queue_start_index <value> queue_num <value>: Set a queue region",
9586 	.tokens = {
9587 		(void *)&cmd_queue_region_set,
9588 		(void *)&cmd_queue_region_port,
9589 		(void *)&cmd_queue_region_port_id,
9590 		(void *)&cmd_queue_region_cmd,
9591 		(void *)&cmd_queue_region_id,
9592 		(void *)&cmd_queue_region_index,
9593 		(void *)&cmd_queue_region_queue_start_index,
9594 		(void *)&cmd_queue_region_queue_id,
9595 		(void *)&cmd_queue_region_queue_num,
9596 		(void *)&cmd_queue_region_queue_num_value,
9597 		NULL,
9598 	},
9599 };
9600 
9601 /* *** queue region and flowtype set *** */
9602 struct cmd_region_flowtype_result {
9603 	cmdline_fixed_string_t set;
9604 	cmdline_fixed_string_t port;
9605 	portid_t port_id;
9606 	cmdline_fixed_string_t cmd;
9607 	cmdline_fixed_string_t region;
9608 	uint8_t  region_id;
9609 	cmdline_fixed_string_t flowtype;
9610 	uint8_t  flowtype_id;
9611 };
9612 
9613 static void
9614 cmd_region_flowtype_parsed(void *parsed_result,
9615 			__attribute__((unused)) struct cmdline *cl,
9616 			__attribute__((unused)) void *data)
9617 {
9618 	struct cmd_region_flowtype_result *res = parsed_result;
9619 	int ret = -ENOTSUP;
9620 #ifdef RTE_LIBRTE_I40E_PMD
9621 	struct rte_pmd_i40e_queue_region_conf region_conf;
9622 	enum rte_pmd_i40e_queue_region_op op_type;
9623 #endif
9624 
9625 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9626 		return;
9627 
9628 #ifdef RTE_LIBRTE_I40E_PMD
9629 	memset(&region_conf, 0, sizeof(region_conf));
9630 
9631 	op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
9632 	region_conf.region_id = res->region_id;
9633 	region_conf.hw_flowtype = res->flowtype_id;
9634 
9635 	ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9636 			op_type, &region_conf);
9637 #endif
9638 
9639 	switch (ret) {
9640 	case 0:
9641 		break;
9642 	case -ENOTSUP:
9643 		printf("function not implemented or supported\n");
9644 		break;
9645 	default:
9646 		printf("region flowtype config error: (%s)\n", strerror(-ret));
9647 	}
9648 }
9649 
9650 cmdline_parse_token_string_t cmd_region_flowtype_set =
9651 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9652 				set, "set");
9653 cmdline_parse_token_string_t cmd_region_flowtype_port =
9654 	TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9655 				port, "port");
9656 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
9657 	TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9658 				port_id, UINT16);
9659 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
9660 	TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9661 				cmd, "queue-region");
9662 cmdline_parse_token_string_t cmd_region_flowtype_index =
9663 	TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9664 				region, "region_id");
9665 cmdline_parse_token_num_t cmd_region_flowtype_id =
9666 	TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9667 				region_id, UINT8);
9668 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
9669 	TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9670 				flowtype, "flowtype");
9671 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
9672 	TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9673 				flowtype_id, UINT8);
9674 cmdline_parse_inst_t cmd_region_flowtype = {
9675 	.f = cmd_region_flowtype_parsed,
9676 	.data = NULL,
9677 	.help_str = "set port <port_id> queue-region region_id <value> "
9678 		"flowtype <value>: Set a flowtype region index",
9679 	.tokens = {
9680 		(void *)&cmd_region_flowtype_set,
9681 		(void *)&cmd_region_flowtype_port,
9682 		(void *)&cmd_region_flowtype_port_index,
9683 		(void *)&cmd_region_flowtype_cmd,
9684 		(void *)&cmd_region_flowtype_index,
9685 		(void *)&cmd_region_flowtype_id,
9686 		(void *)&cmd_region_flowtype_flow_index,
9687 		(void *)&cmd_region_flowtype_flow_id,
9688 		NULL,
9689 	},
9690 };
9691 
9692 /* *** User Priority (UP) to queue region (region_id) set *** */
9693 struct cmd_user_priority_region_result {
9694 	cmdline_fixed_string_t set;
9695 	cmdline_fixed_string_t port;
9696 	portid_t port_id;
9697 	cmdline_fixed_string_t cmd;
9698 	cmdline_fixed_string_t user_priority;
9699 	uint8_t  user_priority_id;
9700 	cmdline_fixed_string_t region;
9701 	uint8_t  region_id;
9702 };
9703 
9704 static void
9705 cmd_user_priority_region_parsed(void *parsed_result,
9706 			__attribute__((unused)) struct cmdline *cl,
9707 			__attribute__((unused)) void *data)
9708 {
9709 	struct cmd_user_priority_region_result *res = parsed_result;
9710 	int ret = -ENOTSUP;
9711 #ifdef RTE_LIBRTE_I40E_PMD
9712 	struct rte_pmd_i40e_queue_region_conf region_conf;
9713 	enum rte_pmd_i40e_queue_region_op op_type;
9714 #endif
9715 
9716 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9717 		return;
9718 
9719 #ifdef RTE_LIBRTE_I40E_PMD
9720 	memset(&region_conf, 0, sizeof(region_conf));
9721 	op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
9722 	region_conf.user_priority = res->user_priority_id;
9723 	region_conf.region_id = res->region_id;
9724 
9725 	ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9726 				op_type, &region_conf);
9727 #endif
9728 
9729 	switch (ret) {
9730 	case 0:
9731 		break;
9732 	case -ENOTSUP:
9733 		printf("function not implemented or supported\n");
9734 		break;
9735 	default:
9736 		printf("user_priority region config error: (%s)\n",
9737 				strerror(-ret));
9738 	}
9739 }
9740 
9741 cmdline_parse_token_string_t cmd_user_priority_region_set =
9742 	TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9743 				set, "set");
9744 cmdline_parse_token_string_t cmd_user_priority_region_port =
9745 	TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9746 				port, "port");
9747 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
9748 	TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9749 				port_id, UINT16);
9750 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
9751 	TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9752 				cmd, "queue-region");
9753 cmdline_parse_token_string_t cmd_user_priority_region_UP =
9754 	TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9755 				user_priority, "UP");
9756 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
9757 	TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9758 				user_priority_id, UINT8);
9759 cmdline_parse_token_string_t cmd_user_priority_region_region =
9760 	TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9761 				region, "region_id");
9762 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
9763 	TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9764 				region_id, UINT8);
9765 
9766 cmdline_parse_inst_t cmd_user_priority_region = {
9767 	.f = cmd_user_priority_region_parsed,
9768 	.data = NULL,
9769 	.help_str = "set port <port_id> queue-region UP <value> "
9770 		"region_id <value>: Set the mapping of User Priority (UP) "
9771 		"to queue region (region_id) ",
9772 	.tokens = {
9773 		(void *)&cmd_user_priority_region_set,
9774 		(void *)&cmd_user_priority_region_port,
9775 		(void *)&cmd_user_priority_region_port_index,
9776 		(void *)&cmd_user_priority_region_cmd,
9777 		(void *)&cmd_user_priority_region_UP,
9778 		(void *)&cmd_user_priority_region_UP_id,
9779 		(void *)&cmd_user_priority_region_region,
9780 		(void *)&cmd_user_priority_region_region_id,
9781 		NULL,
9782 	},
9783 };
9784 
9785 /* *** flush all queue region related configuration *** */
9786 struct cmd_flush_queue_region_result {
9787 	cmdline_fixed_string_t set;
9788 	cmdline_fixed_string_t port;
9789 	portid_t port_id;
9790 	cmdline_fixed_string_t cmd;
9791 	cmdline_fixed_string_t flush;
9792 	cmdline_fixed_string_t what;
9793 };
9794 
9795 static void
9796 cmd_flush_queue_region_parsed(void *parsed_result,
9797 			__attribute__((unused)) struct cmdline *cl,
9798 			__attribute__((unused)) void *data)
9799 {
9800 	struct cmd_flush_queue_region_result *res = parsed_result;
9801 	int ret = -ENOTSUP;
9802 #ifdef RTE_LIBRTE_I40E_PMD
9803 	struct rte_pmd_i40e_queue_region_conf region_conf;
9804 	enum rte_pmd_i40e_queue_region_op op_type;
9805 #endif
9806 
9807 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9808 		return;
9809 
9810 #ifdef RTE_LIBRTE_I40E_PMD
9811 	memset(&region_conf, 0, sizeof(region_conf));
9812 
9813 	if (strcmp(res->what, "on") == 0)
9814 		op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
9815 	else
9816 		op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
9817 
9818 	ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9819 				op_type, &region_conf);
9820 #endif
9821 
9822 	switch (ret) {
9823 	case 0:
9824 		break;
9825 	case -ENOTSUP:
9826 		printf("function not implemented or supported\n");
9827 		break;
9828 	default:
9829 		printf("queue region config flush error: (%s)\n",
9830 				strerror(-ret));
9831 	}
9832 }
9833 
9834 cmdline_parse_token_string_t cmd_flush_queue_region_set =
9835 	TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9836 				set, "set");
9837 cmdline_parse_token_string_t cmd_flush_queue_region_port =
9838 	TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9839 				port, "port");
9840 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
9841 	TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
9842 				port_id, UINT16);
9843 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
9844 	TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9845 				cmd, "queue-region");
9846 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
9847 	TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9848 				flush, "flush");
9849 cmdline_parse_token_string_t cmd_flush_queue_region_what =
9850 	TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9851 				what, "on#off");
9852 
9853 cmdline_parse_inst_t cmd_flush_queue_region = {
9854 	.f = cmd_flush_queue_region_parsed,
9855 	.data = NULL,
9856 	.help_str = "set port <port_id> queue-region flush on|off"
9857 		": flush all queue region related configuration",
9858 	.tokens = {
9859 		(void *)&cmd_flush_queue_region_set,
9860 		(void *)&cmd_flush_queue_region_port,
9861 		(void *)&cmd_flush_queue_region_port_index,
9862 		(void *)&cmd_flush_queue_region_cmd,
9863 		(void *)&cmd_flush_queue_region_flush,
9864 		(void *)&cmd_flush_queue_region_what,
9865 		NULL,
9866 	},
9867 };
9868 
9869 /* *** get all queue region related configuration info *** */
9870 struct cmd_show_queue_region_info {
9871 	cmdline_fixed_string_t show;
9872 	cmdline_fixed_string_t port;
9873 	portid_t port_id;
9874 	cmdline_fixed_string_t cmd;
9875 };
9876 
9877 static void
9878 cmd_show_queue_region_info_parsed(void *parsed_result,
9879 			__attribute__((unused)) struct cmdline *cl,
9880 			__attribute__((unused)) void *data)
9881 {
9882 	struct cmd_show_queue_region_info *res = parsed_result;
9883 	int ret = -ENOTSUP;
9884 #ifdef RTE_LIBRTE_I40E_PMD
9885 	struct rte_pmd_i40e_queue_regions rte_pmd_regions;
9886 	enum rte_pmd_i40e_queue_region_op op_type;
9887 #endif
9888 
9889 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9890 		return;
9891 
9892 #ifdef RTE_LIBRTE_I40E_PMD
9893 	memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
9894 
9895 	op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
9896 
9897 	ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9898 					op_type, &rte_pmd_regions);
9899 
9900 	port_queue_region_info_display(res->port_id, &rte_pmd_regions);
9901 #endif
9902 
9903 	switch (ret) {
9904 	case 0:
9905 		break;
9906 	case -ENOTSUP:
9907 		printf("function not implemented or supported\n");
9908 		break;
9909 	default:
9910 		printf("queue region config info show error: (%s)\n",
9911 				strerror(-ret));
9912 	}
9913 }
9914 
9915 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
9916 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9917 				show, "show");
9918 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
9919 	TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9920 				port, "port");
9921 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
9922 	TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
9923 				port_id, UINT16);
9924 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
9925 	TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9926 				cmd, "queue-region");
9927 
9928 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
9929 	.f = cmd_show_queue_region_info_parsed,
9930 	.data = NULL,
9931 	.help_str = "show port <port_id> queue-region"
9932 		": show all queue region related configuration info",
9933 	.tokens = {
9934 		(void *)&cmd_show_queue_region_info_get,
9935 		(void *)&cmd_show_queue_region_info_port,
9936 		(void *)&cmd_show_queue_region_info_port_index,
9937 		(void *)&cmd_show_queue_region_info_cmd,
9938 		NULL,
9939 	},
9940 };
9941 
9942 /* *** ADD/REMOVE A 2tuple FILTER *** */
9943 struct cmd_2tuple_filter_result {
9944 	cmdline_fixed_string_t filter;
9945 	portid_t port_id;
9946 	cmdline_fixed_string_t ops;
9947 	cmdline_fixed_string_t dst_port;
9948 	uint16_t dst_port_value;
9949 	cmdline_fixed_string_t protocol;
9950 	uint8_t protocol_value;
9951 	cmdline_fixed_string_t mask;
9952 	uint8_t  mask_value;
9953 	cmdline_fixed_string_t tcp_flags;
9954 	uint8_t tcp_flags_value;
9955 	cmdline_fixed_string_t priority;
9956 	uint8_t  priority_value;
9957 	cmdline_fixed_string_t queue;
9958 	uint16_t  queue_id;
9959 };
9960 
9961 static void
9962 cmd_2tuple_filter_parsed(void *parsed_result,
9963 			__attribute__((unused)) struct cmdline *cl,
9964 			__attribute__((unused)) void *data)
9965 {
9966 	struct rte_eth_ntuple_filter filter;
9967 	struct cmd_2tuple_filter_result *res = parsed_result;
9968 	int ret = 0;
9969 
9970 	ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
9971 	if (ret < 0) {
9972 		printf("ntuple filter is not supported on port %u.\n",
9973 			res->port_id);
9974 		return;
9975 	}
9976 
9977 	memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
9978 
9979 	filter.flags = RTE_2TUPLE_FLAGS;
9980 	filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
9981 	filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
9982 	filter.proto = res->protocol_value;
9983 	filter.priority = res->priority_value;
9984 	if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
9985 		printf("nonzero tcp_flags is only meaningful"
9986 			" when protocol is TCP.\n");
9987 		return;
9988 	}
9989 	if (res->tcp_flags_value > TCP_FLAG_ALL) {
9990 		printf("invalid TCP flags.\n");
9991 		return;
9992 	}
9993 
9994 	if (res->tcp_flags_value != 0) {
9995 		filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
9996 		filter.tcp_flags = res->tcp_flags_value;
9997 	}
9998 
9999 	/* need convert to big endian. */
10000 	filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
10001 	filter.queue = res->queue_id;
10002 
10003 	if (!strcmp(res->ops, "add"))
10004 		ret = rte_eth_dev_filter_ctrl(res->port_id,
10005 				RTE_ETH_FILTER_NTUPLE,
10006 				RTE_ETH_FILTER_ADD,
10007 				&filter);
10008 	else
10009 		ret = rte_eth_dev_filter_ctrl(res->port_id,
10010 				RTE_ETH_FILTER_NTUPLE,
10011 				RTE_ETH_FILTER_DELETE,
10012 				&filter);
10013 	if (ret < 0)
10014 		printf("2tuple filter programming error: (%s)\n",
10015 			strerror(-ret));
10016 
10017 }
10018 
10019 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
10020 	TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10021 				 filter, "2tuple_filter");
10022 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
10023 	TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10024 				port_id, UINT16);
10025 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
10026 	TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10027 				 ops, "add#del");
10028 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
10029 	TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10030 				dst_port, "dst_port");
10031 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
10032 	TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10033 				dst_port_value, UINT16);
10034 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
10035 	TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10036 				protocol, "protocol");
10037 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
10038 	TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10039 				protocol_value, UINT8);
10040 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
10041 	TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10042 				mask, "mask");
10043 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
10044 	TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10045 				mask_value, INT8);
10046 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
10047 	TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10048 				tcp_flags, "tcp_flags");
10049 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
10050 	TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10051 				tcp_flags_value, UINT8);
10052 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
10053 	TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10054 				priority, "priority");
10055 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
10056 	TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10057 				priority_value, UINT8);
10058 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
10059 	TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10060 				queue, "queue");
10061 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
10062 	TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10063 				queue_id, UINT16);
10064 
10065 cmdline_parse_inst_t cmd_2tuple_filter = {
10066 	.f = cmd_2tuple_filter_parsed,
10067 	.data = NULL,
10068 	.help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
10069 		"<value> mask <value> tcp_flags <value> priority <value> queue "
10070 		"<queue_id>: Add a 2tuple filter",
10071 	.tokens = {
10072 		(void *)&cmd_2tuple_filter_filter,
10073 		(void *)&cmd_2tuple_filter_port_id,
10074 		(void *)&cmd_2tuple_filter_ops,
10075 		(void *)&cmd_2tuple_filter_dst_port,
10076 		(void *)&cmd_2tuple_filter_dst_port_value,
10077 		(void *)&cmd_2tuple_filter_protocol,
10078 		(void *)&cmd_2tuple_filter_protocol_value,
10079 		(void *)&cmd_2tuple_filter_mask,
10080 		(void *)&cmd_2tuple_filter_mask_value,
10081 		(void *)&cmd_2tuple_filter_tcp_flags,
10082 		(void *)&cmd_2tuple_filter_tcp_flags_value,
10083 		(void *)&cmd_2tuple_filter_priority,
10084 		(void *)&cmd_2tuple_filter_priority_value,
10085 		(void *)&cmd_2tuple_filter_queue,
10086 		(void *)&cmd_2tuple_filter_queue_id,
10087 		NULL,
10088 	},
10089 };
10090 
10091 /* *** ADD/REMOVE A 5tuple FILTER *** */
10092 struct cmd_5tuple_filter_result {
10093 	cmdline_fixed_string_t filter;
10094 	portid_t port_id;
10095 	cmdline_fixed_string_t ops;
10096 	cmdline_fixed_string_t dst_ip;
10097 	cmdline_ipaddr_t dst_ip_value;
10098 	cmdline_fixed_string_t src_ip;
10099 	cmdline_ipaddr_t src_ip_value;
10100 	cmdline_fixed_string_t dst_port;
10101 	uint16_t dst_port_value;
10102 	cmdline_fixed_string_t src_port;
10103 	uint16_t src_port_value;
10104 	cmdline_fixed_string_t protocol;
10105 	uint8_t protocol_value;
10106 	cmdline_fixed_string_t mask;
10107 	uint8_t  mask_value;
10108 	cmdline_fixed_string_t tcp_flags;
10109 	uint8_t tcp_flags_value;
10110 	cmdline_fixed_string_t priority;
10111 	uint8_t  priority_value;
10112 	cmdline_fixed_string_t queue;
10113 	uint16_t  queue_id;
10114 };
10115 
10116 static void
10117 cmd_5tuple_filter_parsed(void *parsed_result,
10118 			__attribute__((unused)) struct cmdline *cl,
10119 			__attribute__((unused)) void *data)
10120 {
10121 	struct rte_eth_ntuple_filter filter;
10122 	struct cmd_5tuple_filter_result *res = parsed_result;
10123 	int ret = 0;
10124 
10125 	ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
10126 	if (ret < 0) {
10127 		printf("ntuple filter is not supported on port %u.\n",
10128 			res->port_id);
10129 		return;
10130 	}
10131 
10132 	memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
10133 
10134 	filter.flags = RTE_5TUPLE_FLAGS;
10135 	filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
10136 	filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
10137 	filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
10138 	filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
10139 	filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
10140 	filter.proto = res->protocol_value;
10141 	filter.priority = res->priority_value;
10142 	if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
10143 		printf("nonzero tcp_flags is only meaningful"
10144 			" when protocol is TCP.\n");
10145 		return;
10146 	}
10147 	if (res->tcp_flags_value > TCP_FLAG_ALL) {
10148 		printf("invalid TCP flags.\n");
10149 		return;
10150 	}
10151 
10152 	if (res->tcp_flags_value != 0) {
10153 		filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
10154 		filter.tcp_flags = res->tcp_flags_value;
10155 	}
10156 
10157 	if (res->dst_ip_value.family == AF_INET)
10158 		/* no need to convert, already big endian. */
10159 		filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
10160 	else {
10161 		if (filter.dst_ip_mask == 0) {
10162 			printf("can not support ipv6 involved compare.\n");
10163 			return;
10164 		}
10165 		filter.dst_ip = 0;
10166 	}
10167 
10168 	if (res->src_ip_value.family == AF_INET)
10169 		/* no need to convert, already big endian. */
10170 		filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
10171 	else {
10172 		if (filter.src_ip_mask == 0) {
10173 			printf("can not support ipv6 involved compare.\n");
10174 			return;
10175 		}
10176 		filter.src_ip = 0;
10177 	}
10178 	/* need convert to big endian. */
10179 	filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
10180 	filter.src_port = rte_cpu_to_be_16(res->src_port_value);
10181 	filter.queue = res->queue_id;
10182 
10183 	if (!strcmp(res->ops, "add"))
10184 		ret = rte_eth_dev_filter_ctrl(res->port_id,
10185 				RTE_ETH_FILTER_NTUPLE,
10186 				RTE_ETH_FILTER_ADD,
10187 				&filter);
10188 	else
10189 		ret = rte_eth_dev_filter_ctrl(res->port_id,
10190 				RTE_ETH_FILTER_NTUPLE,
10191 				RTE_ETH_FILTER_DELETE,
10192 				&filter);
10193 	if (ret < 0)
10194 		printf("5tuple filter programming error: (%s)\n",
10195 			strerror(-ret));
10196 }
10197 
10198 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
10199 	TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10200 				 filter, "5tuple_filter");
10201 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
10202 	TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10203 				port_id, UINT16);
10204 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
10205 	TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10206 				 ops, "add#del");
10207 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
10208 	TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10209 				dst_ip, "dst_ip");
10210 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
10211 	TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10212 				dst_ip_value);
10213 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
10214 	TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10215 				src_ip, "src_ip");
10216 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
10217 	TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10218 				src_ip_value);
10219 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
10220 	TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10221 				dst_port, "dst_port");
10222 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
10223 	TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10224 				dst_port_value, UINT16);
10225 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
10226 	TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10227 				src_port, "src_port");
10228 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
10229 	TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10230 				src_port_value, UINT16);
10231 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
10232 	TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10233 				protocol, "protocol");
10234 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
10235 	TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10236 				protocol_value, UINT8);
10237 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
10238 	TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10239 				mask, "mask");
10240 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
10241 	TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10242 				mask_value, INT8);
10243 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
10244 	TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10245 				tcp_flags, "tcp_flags");
10246 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
10247 	TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10248 				tcp_flags_value, UINT8);
10249 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
10250 	TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10251 				priority, "priority");
10252 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
10253 	TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10254 				priority_value, UINT8);
10255 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
10256 	TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10257 				queue, "queue");
10258 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
10259 	TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10260 				queue_id, UINT16);
10261 
10262 cmdline_parse_inst_t cmd_5tuple_filter = {
10263 	.f = cmd_5tuple_filter_parsed,
10264 	.data = NULL,
10265 	.help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
10266 		"src_ip <value> dst_port <value> src_port <value> "
10267 		"protocol <value>  mask <value> tcp_flags <value> "
10268 		"priority <value> queue <queue_id>: Add/Del a 5tuple filter",
10269 	.tokens = {
10270 		(void *)&cmd_5tuple_filter_filter,
10271 		(void *)&cmd_5tuple_filter_port_id,
10272 		(void *)&cmd_5tuple_filter_ops,
10273 		(void *)&cmd_5tuple_filter_dst_ip,
10274 		(void *)&cmd_5tuple_filter_dst_ip_value,
10275 		(void *)&cmd_5tuple_filter_src_ip,
10276 		(void *)&cmd_5tuple_filter_src_ip_value,
10277 		(void *)&cmd_5tuple_filter_dst_port,
10278 		(void *)&cmd_5tuple_filter_dst_port_value,
10279 		(void *)&cmd_5tuple_filter_src_port,
10280 		(void *)&cmd_5tuple_filter_src_port_value,
10281 		(void *)&cmd_5tuple_filter_protocol,
10282 		(void *)&cmd_5tuple_filter_protocol_value,
10283 		(void *)&cmd_5tuple_filter_mask,
10284 		(void *)&cmd_5tuple_filter_mask_value,
10285 		(void *)&cmd_5tuple_filter_tcp_flags,
10286 		(void *)&cmd_5tuple_filter_tcp_flags_value,
10287 		(void *)&cmd_5tuple_filter_priority,
10288 		(void *)&cmd_5tuple_filter_priority_value,
10289 		(void *)&cmd_5tuple_filter_queue,
10290 		(void *)&cmd_5tuple_filter_queue_id,
10291 		NULL,
10292 	},
10293 };
10294 
10295 /* *** ADD/REMOVE A flex FILTER *** */
10296 struct cmd_flex_filter_result {
10297 	cmdline_fixed_string_t filter;
10298 	cmdline_fixed_string_t ops;
10299 	portid_t port_id;
10300 	cmdline_fixed_string_t len;
10301 	uint8_t len_value;
10302 	cmdline_fixed_string_t bytes;
10303 	cmdline_fixed_string_t bytes_value;
10304 	cmdline_fixed_string_t mask;
10305 	cmdline_fixed_string_t mask_value;
10306 	cmdline_fixed_string_t priority;
10307 	uint8_t priority_value;
10308 	cmdline_fixed_string_t queue;
10309 	uint16_t queue_id;
10310 };
10311 
10312 static int xdigit2val(unsigned char c)
10313 {
10314 	int val;
10315 	if (isdigit(c))
10316 		val = c - '0';
10317 	else if (isupper(c))
10318 		val = c - 'A' + 10;
10319 	else
10320 		val = c - 'a' + 10;
10321 	return val;
10322 }
10323 
10324 static void
10325 cmd_flex_filter_parsed(void *parsed_result,
10326 			  __attribute__((unused)) struct cmdline *cl,
10327 			  __attribute__((unused)) void *data)
10328 {
10329 	int ret = 0;
10330 	struct rte_eth_flex_filter filter;
10331 	struct cmd_flex_filter_result *res = parsed_result;
10332 	char *bytes_ptr, *mask_ptr;
10333 	uint16_t len, i, j = 0;
10334 	char c;
10335 	int val;
10336 	uint8_t byte = 0;
10337 
10338 	if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
10339 		printf("the len exceed the max length 128\n");
10340 		return;
10341 	}
10342 	memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
10343 	filter.len = res->len_value;
10344 	filter.priority = res->priority_value;
10345 	filter.queue = res->queue_id;
10346 	bytes_ptr = res->bytes_value;
10347 	mask_ptr = res->mask_value;
10348 
10349 	 /* translate bytes string to array. */
10350 	if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
10351 		(bytes_ptr[1] == 'X')))
10352 		bytes_ptr += 2;
10353 	len = strnlen(bytes_ptr, res->len_value * 2);
10354 	if (len == 0 || (len % 8 != 0)) {
10355 		printf("please check len and bytes input\n");
10356 		return;
10357 	}
10358 	for (i = 0; i < len; i++) {
10359 		c = bytes_ptr[i];
10360 		if (isxdigit(c) == 0) {
10361 			/* invalid characters. */
10362 			printf("invalid input\n");
10363 			return;
10364 		}
10365 		val = xdigit2val(c);
10366 		if (i % 2) {
10367 			byte |= val;
10368 			filter.bytes[j] = byte;
10369 			printf("bytes[%d]:%02x ", j, filter.bytes[j]);
10370 			j++;
10371 			byte = 0;
10372 		} else
10373 			byte |= val << 4;
10374 	}
10375 	printf("\n");
10376 	 /* translate mask string to uint8_t array. */
10377 	if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
10378 		(mask_ptr[1] == 'X')))
10379 		mask_ptr += 2;
10380 	len = strnlen(mask_ptr, (res->len_value + 3) / 4);
10381 	if (len == 0) {
10382 		printf("invalid input\n");
10383 		return;
10384 	}
10385 	j = 0;
10386 	byte = 0;
10387 	for (i = 0; i < len; i++) {
10388 		c = mask_ptr[i];
10389 		if (isxdigit(c) == 0) {
10390 			/* invalid characters. */
10391 			printf("invalid input\n");
10392 			return;
10393 		}
10394 		val = xdigit2val(c);
10395 		if (i % 2) {
10396 			byte |= val;
10397 			filter.mask[j] = byte;
10398 			printf("mask[%d]:%02x ", j, filter.mask[j]);
10399 			j++;
10400 			byte = 0;
10401 		} else
10402 			byte |= val << 4;
10403 	}
10404 	printf("\n");
10405 
10406 	if (!strcmp(res->ops, "add"))
10407 		ret = rte_eth_dev_filter_ctrl(res->port_id,
10408 				RTE_ETH_FILTER_FLEXIBLE,
10409 				RTE_ETH_FILTER_ADD,
10410 				&filter);
10411 	else
10412 		ret = rte_eth_dev_filter_ctrl(res->port_id,
10413 				RTE_ETH_FILTER_FLEXIBLE,
10414 				RTE_ETH_FILTER_DELETE,
10415 				&filter);
10416 
10417 	if (ret < 0)
10418 		printf("flex filter setting error: (%s)\n", strerror(-ret));
10419 }
10420 
10421 cmdline_parse_token_string_t cmd_flex_filter_filter =
10422 	TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10423 				filter, "flex_filter");
10424 cmdline_parse_token_num_t cmd_flex_filter_port_id =
10425 	TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10426 				port_id, UINT16);
10427 cmdline_parse_token_string_t cmd_flex_filter_ops =
10428 	TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10429 				ops, "add#del");
10430 cmdline_parse_token_string_t cmd_flex_filter_len =
10431 	TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10432 				len, "len");
10433 cmdline_parse_token_num_t cmd_flex_filter_len_value =
10434 	TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10435 				len_value, UINT8);
10436 cmdline_parse_token_string_t cmd_flex_filter_bytes =
10437 	TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10438 				bytes, "bytes");
10439 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
10440 	TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10441 				bytes_value, NULL);
10442 cmdline_parse_token_string_t cmd_flex_filter_mask =
10443 	TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10444 				mask, "mask");
10445 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
10446 	TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10447 				mask_value, NULL);
10448 cmdline_parse_token_string_t cmd_flex_filter_priority =
10449 	TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10450 				priority, "priority");
10451 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
10452 	TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10453 				priority_value, UINT8);
10454 cmdline_parse_token_string_t cmd_flex_filter_queue =
10455 	TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10456 				queue, "queue");
10457 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
10458 	TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10459 				queue_id, UINT16);
10460 cmdline_parse_inst_t cmd_flex_filter = {
10461 	.f = cmd_flex_filter_parsed,
10462 	.data = NULL,
10463 	.help_str = "flex_filter <port_id> add|del len <value> bytes "
10464 		"<value> mask <value> priority <value> queue <queue_id>: "
10465 		"Add/Del a flex filter",
10466 	.tokens = {
10467 		(void *)&cmd_flex_filter_filter,
10468 		(void *)&cmd_flex_filter_port_id,
10469 		(void *)&cmd_flex_filter_ops,
10470 		(void *)&cmd_flex_filter_len,
10471 		(void *)&cmd_flex_filter_len_value,
10472 		(void *)&cmd_flex_filter_bytes,
10473 		(void *)&cmd_flex_filter_bytes_value,
10474 		(void *)&cmd_flex_filter_mask,
10475 		(void *)&cmd_flex_filter_mask_value,
10476 		(void *)&cmd_flex_filter_priority,
10477 		(void *)&cmd_flex_filter_priority_value,
10478 		(void *)&cmd_flex_filter_queue,
10479 		(void *)&cmd_flex_filter_queue_id,
10480 		NULL,
10481 	},
10482 };
10483 
10484 /* *** Filters Control *** */
10485 
10486 /* *** deal with ethertype filter *** */
10487 struct cmd_ethertype_filter_result {
10488 	cmdline_fixed_string_t filter;
10489 	portid_t port_id;
10490 	cmdline_fixed_string_t ops;
10491 	cmdline_fixed_string_t mac;
10492 	struct ether_addr mac_addr;
10493 	cmdline_fixed_string_t ethertype;
10494 	uint16_t ethertype_value;
10495 	cmdline_fixed_string_t drop;
10496 	cmdline_fixed_string_t queue;
10497 	uint16_t  queue_id;
10498 };
10499 
10500 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
10501 	TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10502 				 filter, "ethertype_filter");
10503 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
10504 	TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10505 			      port_id, UINT16);
10506 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
10507 	TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10508 				 ops, "add#del");
10509 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
10510 	TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10511 				 mac, "mac_addr#mac_ignr");
10512 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
10513 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
10514 				     mac_addr);
10515 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
10516 	TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10517 				 ethertype, "ethertype");
10518 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
10519 	TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10520 			      ethertype_value, UINT16);
10521 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
10522 	TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10523 				 drop, "drop#fwd");
10524 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
10525 	TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10526 				 queue, "queue");
10527 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
10528 	TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10529 			      queue_id, UINT16);
10530 
10531 static void
10532 cmd_ethertype_filter_parsed(void *parsed_result,
10533 			  __attribute__((unused)) struct cmdline *cl,
10534 			  __attribute__((unused)) void *data)
10535 {
10536 	struct cmd_ethertype_filter_result *res = parsed_result;
10537 	struct rte_eth_ethertype_filter filter;
10538 	int ret = 0;
10539 
10540 	ret = rte_eth_dev_filter_supported(res->port_id,
10541 			RTE_ETH_FILTER_ETHERTYPE);
10542 	if (ret < 0) {
10543 		printf("ethertype filter is not supported on port %u.\n",
10544 			res->port_id);
10545 		return;
10546 	}
10547 
10548 	memset(&filter, 0, sizeof(filter));
10549 	if (!strcmp(res->mac, "mac_addr")) {
10550 		filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
10551 		rte_memcpy(&filter.mac_addr, &res->mac_addr,
10552 			sizeof(struct ether_addr));
10553 	}
10554 	if (!strcmp(res->drop, "drop"))
10555 		filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
10556 	filter.ether_type = res->ethertype_value;
10557 	filter.queue = res->queue_id;
10558 
10559 	if (!strcmp(res->ops, "add"))
10560 		ret = rte_eth_dev_filter_ctrl(res->port_id,
10561 				RTE_ETH_FILTER_ETHERTYPE,
10562 				RTE_ETH_FILTER_ADD,
10563 				&filter);
10564 	else
10565 		ret = rte_eth_dev_filter_ctrl(res->port_id,
10566 				RTE_ETH_FILTER_ETHERTYPE,
10567 				RTE_ETH_FILTER_DELETE,
10568 				&filter);
10569 	if (ret < 0)
10570 		printf("ethertype filter programming error: (%s)\n",
10571 			strerror(-ret));
10572 }
10573 
10574 cmdline_parse_inst_t cmd_ethertype_filter = {
10575 	.f = cmd_ethertype_filter_parsed,
10576 	.data = NULL,
10577 	.help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
10578 		"<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
10579 		"Add or delete an ethertype filter entry",
10580 	.tokens = {
10581 		(void *)&cmd_ethertype_filter_filter,
10582 		(void *)&cmd_ethertype_filter_port_id,
10583 		(void *)&cmd_ethertype_filter_ops,
10584 		(void *)&cmd_ethertype_filter_mac,
10585 		(void *)&cmd_ethertype_filter_mac_addr,
10586 		(void *)&cmd_ethertype_filter_ethertype,
10587 		(void *)&cmd_ethertype_filter_ethertype_value,
10588 		(void *)&cmd_ethertype_filter_drop,
10589 		(void *)&cmd_ethertype_filter_queue,
10590 		(void *)&cmd_ethertype_filter_queue_id,
10591 		NULL,
10592 	},
10593 };
10594 
10595 /* *** deal with flow director filter *** */
10596 struct cmd_flow_director_result {
10597 	cmdline_fixed_string_t flow_director_filter;
10598 	portid_t port_id;
10599 	cmdline_fixed_string_t mode;
10600 	cmdline_fixed_string_t mode_value;
10601 	cmdline_fixed_string_t ops;
10602 	cmdline_fixed_string_t flow;
10603 	cmdline_fixed_string_t flow_type;
10604 	cmdline_fixed_string_t ether;
10605 	uint16_t ether_type;
10606 	cmdline_fixed_string_t src;
10607 	cmdline_ipaddr_t ip_src;
10608 	uint16_t port_src;
10609 	cmdline_fixed_string_t dst;
10610 	cmdline_ipaddr_t ip_dst;
10611 	uint16_t port_dst;
10612 	cmdline_fixed_string_t verify_tag;
10613 	uint32_t verify_tag_value;
10614 	cmdline_fixed_string_t tos;
10615 	uint8_t tos_value;
10616 	cmdline_fixed_string_t proto;
10617 	uint8_t proto_value;
10618 	cmdline_fixed_string_t ttl;
10619 	uint8_t ttl_value;
10620 	cmdline_fixed_string_t vlan;
10621 	uint16_t vlan_value;
10622 	cmdline_fixed_string_t flexbytes;
10623 	cmdline_fixed_string_t flexbytes_value;
10624 	cmdline_fixed_string_t pf_vf;
10625 	cmdline_fixed_string_t drop;
10626 	cmdline_fixed_string_t queue;
10627 	uint16_t  queue_id;
10628 	cmdline_fixed_string_t fd_id;
10629 	uint32_t  fd_id_value;
10630 	cmdline_fixed_string_t mac;
10631 	struct ether_addr mac_addr;
10632 	cmdline_fixed_string_t tunnel;
10633 	cmdline_fixed_string_t tunnel_type;
10634 	cmdline_fixed_string_t tunnel_id;
10635 	uint32_t tunnel_id_value;
10636 	cmdline_fixed_string_t packet;
10637 	char filepath[];
10638 };
10639 
10640 static inline int
10641 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
10642 {
10643 	char s[256];
10644 	const char *p, *p0 = q_arg;
10645 	char *end;
10646 	unsigned long int_fld;
10647 	char *str_fld[max_num];
10648 	int i;
10649 	unsigned size;
10650 	int ret = -1;
10651 
10652 	p = strchr(p0, '(');
10653 	if (p == NULL)
10654 		return -1;
10655 	++p;
10656 	p0 = strchr(p, ')');
10657 	if (p0 == NULL)
10658 		return -1;
10659 
10660 	size = p0 - p;
10661 	if (size >= sizeof(s))
10662 		return -1;
10663 
10664 	snprintf(s, sizeof(s), "%.*s", size, p);
10665 	ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10666 	if (ret < 0 || ret > max_num)
10667 		return -1;
10668 	for (i = 0; i < ret; i++) {
10669 		errno = 0;
10670 		int_fld = strtoul(str_fld[i], &end, 0);
10671 		if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
10672 			return -1;
10673 		flexbytes[i] = (uint8_t)int_fld;
10674 	}
10675 	return ret;
10676 }
10677 
10678 static uint16_t
10679 str2flowtype(char *string)
10680 {
10681 	uint8_t i = 0;
10682 	static const struct {
10683 		char str[32];
10684 		uint16_t type;
10685 	} flowtype_str[] = {
10686 		{"raw", RTE_ETH_FLOW_RAW},
10687 		{"ipv4", RTE_ETH_FLOW_IPV4},
10688 		{"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10689 		{"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10690 		{"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10691 		{"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10692 		{"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10693 		{"ipv6", RTE_ETH_FLOW_IPV6},
10694 		{"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10695 		{"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10696 		{"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10697 		{"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10698 		{"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10699 		{"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10700 	};
10701 
10702 	for (i = 0; i < RTE_DIM(flowtype_str); i++) {
10703 		if (!strcmp(flowtype_str[i].str, string))
10704 			return flowtype_str[i].type;
10705 	}
10706 
10707 	if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
10708 		return (uint16_t)atoi(string);
10709 
10710 	return RTE_ETH_FLOW_UNKNOWN;
10711 }
10712 
10713 static enum rte_eth_fdir_tunnel_type
10714 str2fdir_tunneltype(char *string)
10715 {
10716 	uint8_t i = 0;
10717 
10718 	static const struct {
10719 		char str[32];
10720 		enum rte_eth_fdir_tunnel_type type;
10721 	} tunneltype_str[] = {
10722 		{"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
10723 		{"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
10724 	};
10725 
10726 	for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
10727 		if (!strcmp(tunneltype_str[i].str, string))
10728 			return tunneltype_str[i].type;
10729 	}
10730 	return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
10731 }
10732 
10733 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10734 do { \
10735 	if ((ip_addr).family == AF_INET) \
10736 		(ip) = (ip_addr).addr.ipv4.s_addr; \
10737 	else { \
10738 		printf("invalid parameter.\n"); \
10739 		return; \
10740 	} \
10741 } while (0)
10742 
10743 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10744 do { \
10745 	if ((ip_addr).family == AF_INET6) \
10746 		rte_memcpy(&(ip), \
10747 				 &((ip_addr).addr.ipv6), \
10748 				 sizeof(struct in6_addr)); \
10749 	else { \
10750 		printf("invalid parameter.\n"); \
10751 		return; \
10752 	} \
10753 } while (0)
10754 
10755 static void
10756 cmd_flow_director_filter_parsed(void *parsed_result,
10757 			  __attribute__((unused)) struct cmdline *cl,
10758 			  __attribute__((unused)) void *data)
10759 {
10760 	struct cmd_flow_director_result *res = parsed_result;
10761 	struct rte_eth_fdir_filter entry;
10762 	uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
10763 	char *end;
10764 	unsigned long vf_id;
10765 	int ret = 0;
10766 
10767 	ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
10768 	if (ret < 0) {
10769 		printf("flow director is not supported on port %u.\n",
10770 			res->port_id);
10771 		return;
10772 	}
10773 	memset(flexbytes, 0, sizeof(flexbytes));
10774 	memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
10775 
10776 	if (fdir_conf.mode ==  RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10777 		if (strcmp(res->mode_value, "MAC-VLAN")) {
10778 			printf("Please set mode to MAC-VLAN.\n");
10779 			return;
10780 		}
10781 	} else if (fdir_conf.mode ==  RTE_FDIR_MODE_PERFECT_TUNNEL) {
10782 		if (strcmp(res->mode_value, "Tunnel")) {
10783 			printf("Please set mode to Tunnel.\n");
10784 			return;
10785 		}
10786 	} else {
10787 		if (!strcmp(res->mode_value, "raw")) {
10788 #ifdef RTE_LIBRTE_I40E_PMD
10789 			struct rte_pmd_i40e_flow_type_mapping
10790 					mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
10791 			struct rte_pmd_i40e_pkt_template_conf conf;
10792 			uint16_t flow_type = str2flowtype(res->flow_type);
10793 			uint16_t i, port = res->port_id;
10794 			uint8_t add;
10795 
10796 			memset(&conf, 0, sizeof(conf));
10797 
10798 			if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
10799 				printf("Invalid flow type specified.\n");
10800 				return;
10801 			}
10802 			ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
10803 								 mapping);
10804 			if (ret)
10805 				return;
10806 			if (mapping[flow_type].pctype == 0ULL) {
10807 				printf("Invalid flow type specified.\n");
10808 				return;
10809 			}
10810 			for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
10811 				if (mapping[flow_type].pctype & (1ULL << i)) {
10812 					conf.input.pctype = i;
10813 					break;
10814 				}
10815 			}
10816 
10817 			conf.input.packet = open_file(res->filepath,
10818 						&conf.input.length);
10819 			if (!conf.input.packet)
10820 				return;
10821 			if (!strcmp(res->drop, "drop"))
10822 				conf.action.behavior =
10823 					RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
10824 			else
10825 				conf.action.behavior =
10826 					RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
10827 			conf.action.report_status =
10828 					RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
10829 			conf.action.rx_queue = res->queue_id;
10830 			conf.soft_id = res->fd_id_value;
10831 			add  = strcmp(res->ops, "del") ? 1 : 0;
10832 			ret = rte_pmd_i40e_flow_add_del_packet_template(port,
10833 									&conf,
10834 									add);
10835 			if (ret < 0)
10836 				printf("flow director config error: (%s)\n",
10837 				       strerror(-ret));
10838 			close_file(conf.input.packet);
10839 #endif
10840 			return;
10841 		} else if (strcmp(res->mode_value, "IP")) {
10842 			printf("Please set mode to IP or raw.\n");
10843 			return;
10844 		}
10845 		entry.input.flow_type = str2flowtype(res->flow_type);
10846 	}
10847 
10848 	ret = parse_flexbytes(res->flexbytes_value,
10849 					flexbytes,
10850 					RTE_ETH_FDIR_MAX_FLEXLEN);
10851 	if (ret < 0) {
10852 		printf("error: Cannot parse flexbytes input.\n");
10853 		return;
10854 	}
10855 
10856 	switch (entry.input.flow_type) {
10857 	case RTE_ETH_FLOW_FRAG_IPV4:
10858 	case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
10859 		entry.input.flow.ip4_flow.proto = res->proto_value;
10860 		/* fall-through */
10861 	case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
10862 	case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
10863 		IPV4_ADDR_TO_UINT(res->ip_dst,
10864 			entry.input.flow.ip4_flow.dst_ip);
10865 		IPV4_ADDR_TO_UINT(res->ip_src,
10866 			entry.input.flow.ip4_flow.src_ip);
10867 		entry.input.flow.ip4_flow.tos = res->tos_value;
10868 		entry.input.flow.ip4_flow.ttl = res->ttl_value;
10869 		/* need convert to big endian. */
10870 		entry.input.flow.udp4_flow.dst_port =
10871 				rte_cpu_to_be_16(res->port_dst);
10872 		entry.input.flow.udp4_flow.src_port =
10873 				rte_cpu_to_be_16(res->port_src);
10874 		break;
10875 	case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
10876 		IPV4_ADDR_TO_UINT(res->ip_dst,
10877 			entry.input.flow.sctp4_flow.ip.dst_ip);
10878 		IPV4_ADDR_TO_UINT(res->ip_src,
10879 			entry.input.flow.sctp4_flow.ip.src_ip);
10880 		entry.input.flow.ip4_flow.tos = res->tos_value;
10881 		entry.input.flow.ip4_flow.ttl = res->ttl_value;
10882 		/* need convert to big endian. */
10883 		entry.input.flow.sctp4_flow.dst_port =
10884 				rte_cpu_to_be_16(res->port_dst);
10885 		entry.input.flow.sctp4_flow.src_port =
10886 				rte_cpu_to_be_16(res->port_src);
10887 		entry.input.flow.sctp4_flow.verify_tag =
10888 				rte_cpu_to_be_32(res->verify_tag_value);
10889 		break;
10890 	case RTE_ETH_FLOW_FRAG_IPV6:
10891 	case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
10892 		entry.input.flow.ipv6_flow.proto = res->proto_value;
10893 		/* fall-through */
10894 	case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
10895 	case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
10896 		IPV6_ADDR_TO_ARRAY(res->ip_dst,
10897 			entry.input.flow.ipv6_flow.dst_ip);
10898 		IPV6_ADDR_TO_ARRAY(res->ip_src,
10899 			entry.input.flow.ipv6_flow.src_ip);
10900 		entry.input.flow.ipv6_flow.tc = res->tos_value;
10901 		entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
10902 		/* need convert to big endian. */
10903 		entry.input.flow.udp6_flow.dst_port =
10904 				rte_cpu_to_be_16(res->port_dst);
10905 		entry.input.flow.udp6_flow.src_port =
10906 				rte_cpu_to_be_16(res->port_src);
10907 		break;
10908 	case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
10909 		IPV6_ADDR_TO_ARRAY(res->ip_dst,
10910 			entry.input.flow.sctp6_flow.ip.dst_ip);
10911 		IPV6_ADDR_TO_ARRAY(res->ip_src,
10912 			entry.input.flow.sctp6_flow.ip.src_ip);
10913 		entry.input.flow.ipv6_flow.tc = res->tos_value;
10914 		entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
10915 		/* need convert to big endian. */
10916 		entry.input.flow.sctp6_flow.dst_port =
10917 				rte_cpu_to_be_16(res->port_dst);
10918 		entry.input.flow.sctp6_flow.src_port =
10919 				rte_cpu_to_be_16(res->port_src);
10920 		entry.input.flow.sctp6_flow.verify_tag =
10921 				rte_cpu_to_be_32(res->verify_tag_value);
10922 		break;
10923 	case RTE_ETH_FLOW_L2_PAYLOAD:
10924 		entry.input.flow.l2_flow.ether_type =
10925 			rte_cpu_to_be_16(res->ether_type);
10926 		break;
10927 	default:
10928 		break;
10929 	}
10930 
10931 	if (fdir_conf.mode ==  RTE_FDIR_MODE_PERFECT_MAC_VLAN)
10932 		rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
10933 				 &res->mac_addr,
10934 				 sizeof(struct ether_addr));
10935 
10936 	if (fdir_conf.mode ==  RTE_FDIR_MODE_PERFECT_TUNNEL) {
10937 		rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
10938 				 &res->mac_addr,
10939 				 sizeof(struct ether_addr));
10940 		entry.input.flow.tunnel_flow.tunnel_type =
10941 			str2fdir_tunneltype(res->tunnel_type);
10942 		entry.input.flow.tunnel_flow.tunnel_id =
10943 			rte_cpu_to_be_32(res->tunnel_id_value);
10944 	}
10945 
10946 	rte_memcpy(entry.input.flow_ext.flexbytes,
10947 		   flexbytes,
10948 		   RTE_ETH_FDIR_MAX_FLEXLEN);
10949 
10950 	entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
10951 
10952 	entry.action.flex_off = 0;  /*use 0 by default */
10953 	if (!strcmp(res->drop, "drop"))
10954 		entry.action.behavior = RTE_ETH_FDIR_REJECT;
10955 	else
10956 		entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
10957 
10958 	if (fdir_conf.mode !=  RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
10959 	    fdir_conf.mode !=  RTE_FDIR_MODE_PERFECT_TUNNEL) {
10960 		if (!strcmp(res->pf_vf, "pf"))
10961 			entry.input.flow_ext.is_vf = 0;
10962 		else if (!strncmp(res->pf_vf, "vf", 2)) {
10963 			struct rte_eth_dev_info dev_info;
10964 
10965 			memset(&dev_info, 0, sizeof(dev_info));
10966 			rte_eth_dev_info_get(res->port_id, &dev_info);
10967 			errno = 0;
10968 			vf_id = strtoul(res->pf_vf + 2, &end, 10);
10969 			if (errno != 0 || *end != '\0' ||
10970 			    vf_id >= dev_info.max_vfs) {
10971 				printf("invalid parameter %s.\n", res->pf_vf);
10972 				return;
10973 			}
10974 			entry.input.flow_ext.is_vf = 1;
10975 			entry.input.flow_ext.dst_id = (uint16_t)vf_id;
10976 		} else {
10977 			printf("invalid parameter %s.\n", res->pf_vf);
10978 			return;
10979 		}
10980 	}
10981 
10982 	/* set to report FD ID by default */
10983 	entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
10984 	entry.action.rx_queue = res->queue_id;
10985 	entry.soft_id = res->fd_id_value;
10986 	if (!strcmp(res->ops, "add"))
10987 		ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10988 					     RTE_ETH_FILTER_ADD, &entry);
10989 	else if (!strcmp(res->ops, "del"))
10990 		ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10991 					     RTE_ETH_FILTER_DELETE, &entry);
10992 	else
10993 		ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10994 					     RTE_ETH_FILTER_UPDATE, &entry);
10995 	if (ret < 0)
10996 		printf("flow director programming error: (%s)\n",
10997 			strerror(-ret));
10998 }
10999 
11000 cmdline_parse_token_string_t cmd_flow_director_filter =
11001 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11002 				 flow_director_filter, "flow_director_filter");
11003 cmdline_parse_token_num_t cmd_flow_director_port_id =
11004 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11005 			      port_id, UINT16);
11006 cmdline_parse_token_string_t cmd_flow_director_ops =
11007 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11008 				 ops, "add#del#update");
11009 cmdline_parse_token_string_t cmd_flow_director_flow =
11010 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11011 				 flow, "flow");
11012 cmdline_parse_token_string_t cmd_flow_director_flow_type =
11013 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11014 		flow_type, NULL);
11015 cmdline_parse_token_string_t cmd_flow_director_ether =
11016 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11017 				 ether, "ether");
11018 cmdline_parse_token_num_t cmd_flow_director_ether_type =
11019 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11020 			      ether_type, UINT16);
11021 cmdline_parse_token_string_t cmd_flow_director_src =
11022 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11023 				 src, "src");
11024 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
11025 	TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
11026 				 ip_src);
11027 cmdline_parse_token_num_t cmd_flow_director_port_src =
11028 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11029 			      port_src, UINT16);
11030 cmdline_parse_token_string_t cmd_flow_director_dst =
11031 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11032 				 dst, "dst");
11033 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
11034 	TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
11035 				 ip_dst);
11036 cmdline_parse_token_num_t cmd_flow_director_port_dst =
11037 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11038 			      port_dst, UINT16);
11039 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
11040 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11041 				  verify_tag, "verify_tag");
11042 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
11043 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11044 			      verify_tag_value, UINT32);
11045 cmdline_parse_token_string_t cmd_flow_director_tos =
11046 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11047 				 tos, "tos");
11048 cmdline_parse_token_num_t cmd_flow_director_tos_value =
11049 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11050 			      tos_value, UINT8);
11051 cmdline_parse_token_string_t cmd_flow_director_proto =
11052 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11053 				 proto, "proto");
11054 cmdline_parse_token_num_t cmd_flow_director_proto_value =
11055 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11056 			      proto_value, UINT8);
11057 cmdline_parse_token_string_t cmd_flow_director_ttl =
11058 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11059 				 ttl, "ttl");
11060 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
11061 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11062 			      ttl_value, UINT8);
11063 cmdline_parse_token_string_t cmd_flow_director_vlan =
11064 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11065 				 vlan, "vlan");
11066 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
11067 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11068 			      vlan_value, UINT16);
11069 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
11070 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11071 				 flexbytes, "flexbytes");
11072 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
11073 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11074 			      flexbytes_value, NULL);
11075 cmdline_parse_token_string_t cmd_flow_director_drop =
11076 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11077 				 drop, "drop#fwd");
11078 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
11079 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11080 			      pf_vf, NULL);
11081 cmdline_parse_token_string_t cmd_flow_director_queue =
11082 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11083 				 queue, "queue");
11084 cmdline_parse_token_num_t cmd_flow_director_queue_id =
11085 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11086 			      queue_id, UINT16);
11087 cmdline_parse_token_string_t cmd_flow_director_fd_id =
11088 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11089 				 fd_id, "fd_id");
11090 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
11091 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11092 			      fd_id_value, UINT32);
11093 
11094 cmdline_parse_token_string_t cmd_flow_director_mode =
11095 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11096 				 mode, "mode");
11097 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
11098 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11099 				 mode_value, "IP");
11100 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
11101 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11102 				 mode_value, "MAC-VLAN");
11103 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
11104 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11105 				 mode_value, "Tunnel");
11106 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
11107 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11108 				 mode_value, "raw");
11109 cmdline_parse_token_string_t cmd_flow_director_mac =
11110 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11111 				 mac, "mac");
11112 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
11113 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
11114 				    mac_addr);
11115 cmdline_parse_token_string_t cmd_flow_director_tunnel =
11116 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11117 				 tunnel, "tunnel");
11118 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
11119 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11120 				 tunnel_type, "NVGRE#VxLAN");
11121 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
11122 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11123 				 tunnel_id, "tunnel-id");
11124 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
11125 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11126 			      tunnel_id_value, UINT32);
11127 cmdline_parse_token_string_t cmd_flow_director_packet =
11128 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11129 				 packet, "packet");
11130 cmdline_parse_token_string_t cmd_flow_director_filepath =
11131 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11132 				 filepath, NULL);
11133 
11134 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
11135 	.f = cmd_flow_director_filter_parsed,
11136 	.data = NULL,
11137 	.help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
11138 		" ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
11139 		"ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
11140 		"l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
11141 		"proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
11142 		"flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> "
11143 		"fd_id <fd_id_value>: "
11144 		"Add or delete an ip flow director entry on NIC",
11145 	.tokens = {
11146 		(void *)&cmd_flow_director_filter,
11147 		(void *)&cmd_flow_director_port_id,
11148 		(void *)&cmd_flow_director_mode,
11149 		(void *)&cmd_flow_director_mode_ip,
11150 		(void *)&cmd_flow_director_ops,
11151 		(void *)&cmd_flow_director_flow,
11152 		(void *)&cmd_flow_director_flow_type,
11153 		(void *)&cmd_flow_director_src,
11154 		(void *)&cmd_flow_director_ip_src,
11155 		(void *)&cmd_flow_director_dst,
11156 		(void *)&cmd_flow_director_ip_dst,
11157 		(void *)&cmd_flow_director_tos,
11158 		(void *)&cmd_flow_director_tos_value,
11159 		(void *)&cmd_flow_director_proto,
11160 		(void *)&cmd_flow_director_proto_value,
11161 		(void *)&cmd_flow_director_ttl,
11162 		(void *)&cmd_flow_director_ttl_value,
11163 		(void *)&cmd_flow_director_vlan,
11164 		(void *)&cmd_flow_director_vlan_value,
11165 		(void *)&cmd_flow_director_flexbytes,
11166 		(void *)&cmd_flow_director_flexbytes_value,
11167 		(void *)&cmd_flow_director_drop,
11168 		(void *)&cmd_flow_director_pf_vf,
11169 		(void *)&cmd_flow_director_queue,
11170 		(void *)&cmd_flow_director_queue_id,
11171 		(void *)&cmd_flow_director_fd_id,
11172 		(void *)&cmd_flow_director_fd_id_value,
11173 		NULL,
11174 	},
11175 };
11176 
11177 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
11178 	.f = cmd_flow_director_filter_parsed,
11179 	.data = NULL,
11180 	.help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
11181 		"director entry on NIC",
11182 	.tokens = {
11183 		(void *)&cmd_flow_director_filter,
11184 		(void *)&cmd_flow_director_port_id,
11185 		(void *)&cmd_flow_director_mode,
11186 		(void *)&cmd_flow_director_mode_ip,
11187 		(void *)&cmd_flow_director_ops,
11188 		(void *)&cmd_flow_director_flow,
11189 		(void *)&cmd_flow_director_flow_type,
11190 		(void *)&cmd_flow_director_src,
11191 		(void *)&cmd_flow_director_ip_src,
11192 		(void *)&cmd_flow_director_port_src,
11193 		(void *)&cmd_flow_director_dst,
11194 		(void *)&cmd_flow_director_ip_dst,
11195 		(void *)&cmd_flow_director_port_dst,
11196 		(void *)&cmd_flow_director_tos,
11197 		(void *)&cmd_flow_director_tos_value,
11198 		(void *)&cmd_flow_director_ttl,
11199 		(void *)&cmd_flow_director_ttl_value,
11200 		(void *)&cmd_flow_director_vlan,
11201 		(void *)&cmd_flow_director_vlan_value,
11202 		(void *)&cmd_flow_director_flexbytes,
11203 		(void *)&cmd_flow_director_flexbytes_value,
11204 		(void *)&cmd_flow_director_drop,
11205 		(void *)&cmd_flow_director_pf_vf,
11206 		(void *)&cmd_flow_director_queue,
11207 		(void *)&cmd_flow_director_queue_id,
11208 		(void *)&cmd_flow_director_fd_id,
11209 		(void *)&cmd_flow_director_fd_id_value,
11210 		NULL,
11211 	},
11212 };
11213 
11214 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
11215 	.f = cmd_flow_director_filter_parsed,
11216 	.data = NULL,
11217 	.help_str = "flow_director_filter ... : Add or delete a sctp flow "
11218 		"director entry on NIC",
11219 	.tokens = {
11220 		(void *)&cmd_flow_director_filter,
11221 		(void *)&cmd_flow_director_port_id,
11222 		(void *)&cmd_flow_director_mode,
11223 		(void *)&cmd_flow_director_mode_ip,
11224 		(void *)&cmd_flow_director_ops,
11225 		(void *)&cmd_flow_director_flow,
11226 		(void *)&cmd_flow_director_flow_type,
11227 		(void *)&cmd_flow_director_src,
11228 		(void *)&cmd_flow_director_ip_src,
11229 		(void *)&cmd_flow_director_port_src,
11230 		(void *)&cmd_flow_director_dst,
11231 		(void *)&cmd_flow_director_ip_dst,
11232 		(void *)&cmd_flow_director_port_dst,
11233 		(void *)&cmd_flow_director_verify_tag,
11234 		(void *)&cmd_flow_director_verify_tag_value,
11235 		(void *)&cmd_flow_director_tos,
11236 		(void *)&cmd_flow_director_tos_value,
11237 		(void *)&cmd_flow_director_ttl,
11238 		(void *)&cmd_flow_director_ttl_value,
11239 		(void *)&cmd_flow_director_vlan,
11240 		(void *)&cmd_flow_director_vlan_value,
11241 		(void *)&cmd_flow_director_flexbytes,
11242 		(void *)&cmd_flow_director_flexbytes_value,
11243 		(void *)&cmd_flow_director_drop,
11244 		(void *)&cmd_flow_director_pf_vf,
11245 		(void *)&cmd_flow_director_queue,
11246 		(void *)&cmd_flow_director_queue_id,
11247 		(void *)&cmd_flow_director_fd_id,
11248 		(void *)&cmd_flow_director_fd_id_value,
11249 		NULL,
11250 	},
11251 };
11252 
11253 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
11254 	.f = cmd_flow_director_filter_parsed,
11255 	.data = NULL,
11256 	.help_str = "flow_director_filter ... : Add or delete a L2 flow "
11257 		"director entry on NIC",
11258 	.tokens = {
11259 		(void *)&cmd_flow_director_filter,
11260 		(void *)&cmd_flow_director_port_id,
11261 		(void *)&cmd_flow_director_mode,
11262 		(void *)&cmd_flow_director_mode_ip,
11263 		(void *)&cmd_flow_director_ops,
11264 		(void *)&cmd_flow_director_flow,
11265 		(void *)&cmd_flow_director_flow_type,
11266 		(void *)&cmd_flow_director_ether,
11267 		(void *)&cmd_flow_director_ether_type,
11268 		(void *)&cmd_flow_director_flexbytes,
11269 		(void *)&cmd_flow_director_flexbytes_value,
11270 		(void *)&cmd_flow_director_drop,
11271 		(void *)&cmd_flow_director_pf_vf,
11272 		(void *)&cmd_flow_director_queue,
11273 		(void *)&cmd_flow_director_queue_id,
11274 		(void *)&cmd_flow_director_fd_id,
11275 		(void *)&cmd_flow_director_fd_id_value,
11276 		NULL,
11277 	},
11278 };
11279 
11280 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
11281 	.f = cmd_flow_director_filter_parsed,
11282 	.data = NULL,
11283 	.help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
11284 		"director entry on NIC",
11285 	.tokens = {
11286 		(void *)&cmd_flow_director_filter,
11287 		(void *)&cmd_flow_director_port_id,
11288 		(void *)&cmd_flow_director_mode,
11289 		(void *)&cmd_flow_director_mode_mac_vlan,
11290 		(void *)&cmd_flow_director_ops,
11291 		(void *)&cmd_flow_director_mac,
11292 		(void *)&cmd_flow_director_mac_addr,
11293 		(void *)&cmd_flow_director_vlan,
11294 		(void *)&cmd_flow_director_vlan_value,
11295 		(void *)&cmd_flow_director_flexbytes,
11296 		(void *)&cmd_flow_director_flexbytes_value,
11297 		(void *)&cmd_flow_director_drop,
11298 		(void *)&cmd_flow_director_queue,
11299 		(void *)&cmd_flow_director_queue_id,
11300 		(void *)&cmd_flow_director_fd_id,
11301 		(void *)&cmd_flow_director_fd_id_value,
11302 		NULL,
11303 	},
11304 };
11305 
11306 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
11307 	.f = cmd_flow_director_filter_parsed,
11308 	.data = NULL,
11309 	.help_str = "flow_director_filter ... : Add or delete a tunnel flow "
11310 		"director entry on NIC",
11311 	.tokens = {
11312 		(void *)&cmd_flow_director_filter,
11313 		(void *)&cmd_flow_director_port_id,
11314 		(void *)&cmd_flow_director_mode,
11315 		(void *)&cmd_flow_director_mode_tunnel,
11316 		(void *)&cmd_flow_director_ops,
11317 		(void *)&cmd_flow_director_mac,
11318 		(void *)&cmd_flow_director_mac_addr,
11319 		(void *)&cmd_flow_director_vlan,
11320 		(void *)&cmd_flow_director_vlan_value,
11321 		(void *)&cmd_flow_director_tunnel,
11322 		(void *)&cmd_flow_director_tunnel_type,
11323 		(void *)&cmd_flow_director_tunnel_id,
11324 		(void *)&cmd_flow_director_tunnel_id_value,
11325 		(void *)&cmd_flow_director_flexbytes,
11326 		(void *)&cmd_flow_director_flexbytes_value,
11327 		(void *)&cmd_flow_director_drop,
11328 		(void *)&cmd_flow_director_queue,
11329 		(void *)&cmd_flow_director_queue_id,
11330 		(void *)&cmd_flow_director_fd_id,
11331 		(void *)&cmd_flow_director_fd_id_value,
11332 		NULL,
11333 	},
11334 };
11335 
11336 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
11337 	.f = cmd_flow_director_filter_parsed,
11338 	.data = NULL,
11339 	.help_str = "flow_director_filter ... : Add or delete a raw flow "
11340 		"director entry on NIC",
11341 	.tokens = {
11342 		(void *)&cmd_flow_director_filter,
11343 		(void *)&cmd_flow_director_port_id,
11344 		(void *)&cmd_flow_director_mode,
11345 		(void *)&cmd_flow_director_mode_raw,
11346 		(void *)&cmd_flow_director_ops,
11347 		(void *)&cmd_flow_director_flow,
11348 		(void *)&cmd_flow_director_flow_type,
11349 		(void *)&cmd_flow_director_drop,
11350 		(void *)&cmd_flow_director_queue,
11351 		(void *)&cmd_flow_director_queue_id,
11352 		(void *)&cmd_flow_director_fd_id,
11353 		(void *)&cmd_flow_director_fd_id_value,
11354 		(void *)&cmd_flow_director_packet,
11355 		(void *)&cmd_flow_director_filepath,
11356 		NULL,
11357 	},
11358 };
11359 
11360 struct cmd_flush_flow_director_result {
11361 	cmdline_fixed_string_t flush_flow_director;
11362 	portid_t port_id;
11363 };
11364 
11365 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
11366 	TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
11367 				 flush_flow_director, "flush_flow_director");
11368 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
11369 	TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
11370 			      port_id, UINT16);
11371 
11372 static void
11373 cmd_flush_flow_director_parsed(void *parsed_result,
11374 			  __attribute__((unused)) struct cmdline *cl,
11375 			  __attribute__((unused)) void *data)
11376 {
11377 	struct cmd_flow_director_result *res = parsed_result;
11378 	int ret = 0;
11379 
11380 	ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
11381 	if (ret < 0) {
11382 		printf("flow director is not supported on port %u.\n",
11383 			res->port_id);
11384 		return;
11385 	}
11386 
11387 	ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11388 			RTE_ETH_FILTER_FLUSH, NULL);
11389 	if (ret < 0)
11390 		printf("flow director table flushing error: (%s)\n",
11391 			strerror(-ret));
11392 }
11393 
11394 cmdline_parse_inst_t cmd_flush_flow_director = {
11395 	.f = cmd_flush_flow_director_parsed,
11396 	.data = NULL,
11397 	.help_str = "flush_flow_director <port_id>: "
11398 		"Flush all flow director entries of a device on NIC",
11399 	.tokens = {
11400 		(void *)&cmd_flush_flow_director_flush,
11401 		(void *)&cmd_flush_flow_director_port_id,
11402 		NULL,
11403 	},
11404 };
11405 
11406 /* *** deal with flow director mask *** */
11407 struct cmd_flow_director_mask_result {
11408 	cmdline_fixed_string_t flow_director_mask;
11409 	portid_t port_id;
11410 	cmdline_fixed_string_t mode;
11411 	cmdline_fixed_string_t mode_value;
11412 	cmdline_fixed_string_t vlan;
11413 	uint16_t vlan_mask;
11414 	cmdline_fixed_string_t src_mask;
11415 	cmdline_ipaddr_t ipv4_src;
11416 	cmdline_ipaddr_t ipv6_src;
11417 	uint16_t port_src;
11418 	cmdline_fixed_string_t dst_mask;
11419 	cmdline_ipaddr_t ipv4_dst;
11420 	cmdline_ipaddr_t ipv6_dst;
11421 	uint16_t port_dst;
11422 	cmdline_fixed_string_t mac;
11423 	uint8_t mac_addr_byte_mask;
11424 	cmdline_fixed_string_t tunnel_id;
11425 	uint32_t tunnel_id_mask;
11426 	cmdline_fixed_string_t tunnel_type;
11427 	uint8_t tunnel_type_mask;
11428 };
11429 
11430 static void
11431 cmd_flow_director_mask_parsed(void *parsed_result,
11432 			  __attribute__((unused)) struct cmdline *cl,
11433 			  __attribute__((unused)) void *data)
11434 {
11435 	struct cmd_flow_director_mask_result *res = parsed_result;
11436 	struct rte_eth_fdir_masks *mask;
11437 	struct rte_port *port;
11438 
11439 	port = &ports[res->port_id];
11440 	/** Check if the port is not started **/
11441 	if (port->port_status != RTE_PORT_STOPPED) {
11442 		printf("Please stop port %d first\n", res->port_id);
11443 		return;
11444 	}
11445 
11446 	mask = &port->dev_conf.fdir_conf.mask;
11447 
11448 	if (fdir_conf.mode ==  RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
11449 		if (strcmp(res->mode_value, "MAC-VLAN")) {
11450 			printf("Please set mode to MAC-VLAN.\n");
11451 			return;
11452 		}
11453 
11454 		mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11455 	} else if (fdir_conf.mode ==  RTE_FDIR_MODE_PERFECT_TUNNEL) {
11456 		if (strcmp(res->mode_value, "Tunnel")) {
11457 			printf("Please set mode to Tunnel.\n");
11458 			return;
11459 		}
11460 
11461 		mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11462 		mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
11463 		mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
11464 		mask->tunnel_type_mask = res->tunnel_type_mask;
11465 	} else {
11466 		if (strcmp(res->mode_value, "IP")) {
11467 			printf("Please set mode to IP.\n");
11468 			return;
11469 		}
11470 
11471 		mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11472 		IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
11473 		IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
11474 		IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
11475 		IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
11476 		mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
11477 		mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
11478 	}
11479 
11480 	cmd_reconfig_device_queue(res->port_id, 1, 1);
11481 }
11482 
11483 cmdline_parse_token_string_t cmd_flow_director_mask =
11484 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11485 				 flow_director_mask, "flow_director_mask");
11486 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
11487 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11488 			      port_id, UINT16);
11489 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
11490 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11491 				 vlan, "vlan");
11492 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
11493 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11494 			      vlan_mask, UINT16);
11495 cmdline_parse_token_string_t cmd_flow_director_mask_src =
11496 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11497 				 src_mask, "src_mask");
11498 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
11499 	TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11500 				 ipv4_src);
11501 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
11502 	TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11503 				 ipv6_src);
11504 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
11505 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11506 			      port_src, UINT16);
11507 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
11508 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11509 				 dst_mask, "dst_mask");
11510 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
11511 	TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11512 				 ipv4_dst);
11513 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
11514 	TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11515 				 ipv6_dst);
11516 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
11517 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11518 			      port_dst, UINT16);
11519 
11520 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
11521 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11522 				 mode, "mode");
11523 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
11524 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11525 				 mode_value, "IP");
11526 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
11527 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11528 				 mode_value, "MAC-VLAN");
11529 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
11530 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11531 				 mode_value, "Tunnel");
11532 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
11533 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11534 				 mac, "mac");
11535 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
11536 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11537 			      mac_addr_byte_mask, UINT8);
11538 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
11539 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11540 				 tunnel_type, "tunnel-type");
11541 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
11542 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11543 			      tunnel_type_mask, UINT8);
11544 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
11545 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11546 				 tunnel_id, "tunnel-id");
11547 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
11548 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11549 			      tunnel_id_mask, UINT32);
11550 
11551 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
11552 	.f = cmd_flow_director_mask_parsed,
11553 	.data = NULL,
11554 	.help_str = "flow_director_mask ... : "
11555 		"Set IP mode flow director's mask on NIC",
11556 	.tokens = {
11557 		(void *)&cmd_flow_director_mask,
11558 		(void *)&cmd_flow_director_mask_port_id,
11559 		(void *)&cmd_flow_director_mask_mode,
11560 		(void *)&cmd_flow_director_mask_mode_ip,
11561 		(void *)&cmd_flow_director_mask_vlan,
11562 		(void *)&cmd_flow_director_mask_vlan_value,
11563 		(void *)&cmd_flow_director_mask_src,
11564 		(void *)&cmd_flow_director_mask_ipv4_src,
11565 		(void *)&cmd_flow_director_mask_ipv6_src,
11566 		(void *)&cmd_flow_director_mask_port_src,
11567 		(void *)&cmd_flow_director_mask_dst,
11568 		(void *)&cmd_flow_director_mask_ipv4_dst,
11569 		(void *)&cmd_flow_director_mask_ipv6_dst,
11570 		(void *)&cmd_flow_director_mask_port_dst,
11571 		NULL,
11572 	},
11573 };
11574 
11575 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
11576 	.f = cmd_flow_director_mask_parsed,
11577 	.data = NULL,
11578 	.help_str = "flow_director_mask ... : Set MAC VLAN mode "
11579 		"flow director's mask on NIC",
11580 	.tokens = {
11581 		(void *)&cmd_flow_director_mask,
11582 		(void *)&cmd_flow_director_mask_port_id,
11583 		(void *)&cmd_flow_director_mask_mode,
11584 		(void *)&cmd_flow_director_mask_mode_mac_vlan,
11585 		(void *)&cmd_flow_director_mask_vlan,
11586 		(void *)&cmd_flow_director_mask_vlan_value,
11587 		NULL,
11588 	},
11589 };
11590 
11591 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
11592 	.f = cmd_flow_director_mask_parsed,
11593 	.data = NULL,
11594 	.help_str = "flow_director_mask ... : Set tunnel mode "
11595 		"flow director's mask on NIC",
11596 	.tokens = {
11597 		(void *)&cmd_flow_director_mask,
11598 		(void *)&cmd_flow_director_mask_port_id,
11599 		(void *)&cmd_flow_director_mask_mode,
11600 		(void *)&cmd_flow_director_mask_mode_tunnel,
11601 		(void *)&cmd_flow_director_mask_vlan,
11602 		(void *)&cmd_flow_director_mask_vlan_value,
11603 		(void *)&cmd_flow_director_mask_mac,
11604 		(void *)&cmd_flow_director_mask_mac_value,
11605 		(void *)&cmd_flow_director_mask_tunnel_type,
11606 		(void *)&cmd_flow_director_mask_tunnel_type_value,
11607 		(void *)&cmd_flow_director_mask_tunnel_id,
11608 		(void *)&cmd_flow_director_mask_tunnel_id_value,
11609 		NULL,
11610 	},
11611 };
11612 
11613 /* *** deal with flow director mask on flexible payload *** */
11614 struct cmd_flow_director_flex_mask_result {
11615 	cmdline_fixed_string_t flow_director_flexmask;
11616 	portid_t port_id;
11617 	cmdline_fixed_string_t flow;
11618 	cmdline_fixed_string_t flow_type;
11619 	cmdline_fixed_string_t mask;
11620 };
11621 
11622 static void
11623 cmd_flow_director_flex_mask_parsed(void *parsed_result,
11624 			  __attribute__((unused)) struct cmdline *cl,
11625 			  __attribute__((unused)) void *data)
11626 {
11627 	struct cmd_flow_director_flex_mask_result *res = parsed_result;
11628 	struct rte_eth_fdir_info fdir_info;
11629 	struct rte_eth_fdir_flex_mask flex_mask;
11630 	struct rte_port *port;
11631 	uint64_t flow_type_mask;
11632 	uint16_t i;
11633 	int ret;
11634 
11635 	port = &ports[res->port_id];
11636 	/** Check if the port is not started **/
11637 	if (port->port_status != RTE_PORT_STOPPED) {
11638 		printf("Please stop port %d first\n", res->port_id);
11639 		return;
11640 	}
11641 
11642 	memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
11643 	ret = parse_flexbytes(res->mask,
11644 			flex_mask.mask,
11645 			RTE_ETH_FDIR_MAX_FLEXLEN);
11646 	if (ret < 0) {
11647 		printf("error: Cannot parse mask input.\n");
11648 		return;
11649 	}
11650 
11651 	memset(&fdir_info, 0, sizeof(fdir_info));
11652 	ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11653 				RTE_ETH_FILTER_INFO, &fdir_info);
11654 	if (ret < 0) {
11655 		printf("Cannot get FDir filter info\n");
11656 		return;
11657 	}
11658 
11659 	if (!strcmp(res->flow_type, "none")) {
11660 		/* means don't specify the flow type */
11661 		flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
11662 		for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
11663 			memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
11664 			       0, sizeof(struct rte_eth_fdir_flex_mask));
11665 		port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
11666 		rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
11667 				 &flex_mask,
11668 				 sizeof(struct rte_eth_fdir_flex_mask));
11669 		cmd_reconfig_device_queue(res->port_id, 1, 1);
11670 		return;
11671 	}
11672 	flow_type_mask = fdir_info.flow_types_mask[0];
11673 	if (!strcmp(res->flow_type, "all")) {
11674 		if (!flow_type_mask) {
11675 			printf("No flow type supported\n");
11676 			return;
11677 		}
11678 		for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
11679 			if (flow_type_mask & (1ULL << i)) {
11680 				flex_mask.flow_type = i;
11681 				fdir_set_flex_mask(res->port_id, &flex_mask);
11682 			}
11683 		}
11684 		cmd_reconfig_device_queue(res->port_id, 1, 1);
11685 		return;
11686 	}
11687 	flex_mask.flow_type = str2flowtype(res->flow_type);
11688 	if (!(flow_type_mask & (1ULL << flex_mask.flow_type))) {
11689 		printf("Flow type %s not supported on port %d\n",
11690 				res->flow_type, res->port_id);
11691 		return;
11692 	}
11693 	fdir_set_flex_mask(res->port_id, &flex_mask);
11694 	cmd_reconfig_device_queue(res->port_id, 1, 1);
11695 }
11696 
11697 cmdline_parse_token_string_t cmd_flow_director_flexmask =
11698 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11699 				 flow_director_flexmask,
11700 				 "flow_director_flex_mask");
11701 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
11702 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11703 			      port_id, UINT16);
11704 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
11705 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11706 				 flow, "flow");
11707 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
11708 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11709 		flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
11710 		"ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
11711 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
11712 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11713 				 mask, NULL);
11714 
11715 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
11716 	.f = cmd_flow_director_flex_mask_parsed,
11717 	.data = NULL,
11718 	.help_str = "flow_director_flex_mask ... : "
11719 		"Set flow director's flex mask on NIC",
11720 	.tokens = {
11721 		(void *)&cmd_flow_director_flexmask,
11722 		(void *)&cmd_flow_director_flexmask_port_id,
11723 		(void *)&cmd_flow_director_flexmask_flow,
11724 		(void *)&cmd_flow_director_flexmask_flow_type,
11725 		(void *)&cmd_flow_director_flexmask_mask,
11726 		NULL,
11727 	},
11728 };
11729 
11730 /* *** deal with flow director flexible payload configuration *** */
11731 struct cmd_flow_director_flexpayload_result {
11732 	cmdline_fixed_string_t flow_director_flexpayload;
11733 	portid_t port_id;
11734 	cmdline_fixed_string_t payload_layer;
11735 	cmdline_fixed_string_t payload_cfg;
11736 };
11737 
11738 static inline int
11739 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
11740 {
11741 	char s[256];
11742 	const char *p, *p0 = q_arg;
11743 	char *end;
11744 	unsigned long int_fld;
11745 	char *str_fld[max_num];
11746 	int i;
11747 	unsigned size;
11748 	int ret = -1;
11749 
11750 	p = strchr(p0, '(');
11751 	if (p == NULL)
11752 		return -1;
11753 	++p;
11754 	p0 = strchr(p, ')');
11755 	if (p0 == NULL)
11756 		return -1;
11757 
11758 	size = p0 - p;
11759 	if (size >= sizeof(s))
11760 		return -1;
11761 
11762 	snprintf(s, sizeof(s), "%.*s", size, p);
11763 	ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
11764 	if (ret < 0 || ret > max_num)
11765 		return -1;
11766 	for (i = 0; i < ret; i++) {
11767 		errno = 0;
11768 		int_fld = strtoul(str_fld[i], &end, 0);
11769 		if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
11770 			return -1;
11771 		offsets[i] = (uint16_t)int_fld;
11772 	}
11773 	return ret;
11774 }
11775 
11776 static void
11777 cmd_flow_director_flxpld_parsed(void *parsed_result,
11778 			  __attribute__((unused)) struct cmdline *cl,
11779 			  __attribute__((unused)) void *data)
11780 {
11781 	struct cmd_flow_director_flexpayload_result *res = parsed_result;
11782 	struct rte_eth_flex_payload_cfg flex_cfg;
11783 	struct rte_port *port;
11784 	int ret = 0;
11785 
11786 	port = &ports[res->port_id];
11787 	/** Check if the port is not started **/
11788 	if (port->port_status != RTE_PORT_STOPPED) {
11789 		printf("Please stop port %d first\n", res->port_id);
11790 		return;
11791 	}
11792 
11793 	memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
11794 
11795 	if (!strcmp(res->payload_layer, "raw"))
11796 		flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
11797 	else if (!strcmp(res->payload_layer, "l2"))
11798 		flex_cfg.type = RTE_ETH_L2_PAYLOAD;
11799 	else if (!strcmp(res->payload_layer, "l3"))
11800 		flex_cfg.type = RTE_ETH_L3_PAYLOAD;
11801 	else if (!strcmp(res->payload_layer, "l4"))
11802 		flex_cfg.type = RTE_ETH_L4_PAYLOAD;
11803 
11804 	ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
11805 			    RTE_ETH_FDIR_MAX_FLEXLEN);
11806 	if (ret < 0) {
11807 		printf("error: Cannot parse flex payload input.\n");
11808 		return;
11809 	}
11810 
11811 	fdir_set_flex_payload(res->port_id, &flex_cfg);
11812 	cmd_reconfig_device_queue(res->port_id, 1, 1);
11813 }
11814 
11815 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
11816 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11817 				 flow_director_flexpayload,
11818 				 "flow_director_flex_payload");
11819 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
11820 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11821 			      port_id, UINT16);
11822 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
11823 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11824 				 payload_layer, "raw#l2#l3#l4");
11825 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
11826 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11827 				 payload_cfg, NULL);
11828 
11829 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
11830 	.f = cmd_flow_director_flxpld_parsed,
11831 	.data = NULL,
11832 	.help_str = "flow_director_flexpayload ... : "
11833 		"Set flow director's flex payload on NIC",
11834 	.tokens = {
11835 		(void *)&cmd_flow_director_flexpayload,
11836 		(void *)&cmd_flow_director_flexpayload_port_id,
11837 		(void *)&cmd_flow_director_flexpayload_payload_layer,
11838 		(void *)&cmd_flow_director_flexpayload_payload_cfg,
11839 		NULL,
11840 	},
11841 };
11842 
11843 /* Generic flow interface command. */
11844 extern cmdline_parse_inst_t cmd_flow;
11845 
11846 /* *** Classification Filters Control *** */
11847 /* *** Get symmetric hash enable per port *** */
11848 struct cmd_get_sym_hash_ena_per_port_result {
11849 	cmdline_fixed_string_t get_sym_hash_ena_per_port;
11850 	portid_t port_id;
11851 };
11852 
11853 static void
11854 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
11855 				 __rte_unused struct cmdline *cl,
11856 				 __rte_unused void *data)
11857 {
11858 	struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
11859 	struct rte_eth_hash_filter_info info;
11860 	int ret;
11861 
11862 	if (rte_eth_dev_filter_supported(res->port_id,
11863 				RTE_ETH_FILTER_HASH) < 0) {
11864 		printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
11865 							res->port_id);
11866 		return;
11867 	}
11868 
11869 	memset(&info, 0, sizeof(info));
11870 	info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
11871 	ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11872 						RTE_ETH_FILTER_GET, &info);
11873 
11874 	if (ret < 0) {
11875 		printf("Cannot get symmetric hash enable per port "
11876 					"on port %u\n", res->port_id);
11877 		return;
11878 	}
11879 
11880 	printf("Symmetric hash is %s on port %u\n", info.info.enable ?
11881 				"enabled" : "disabled", res->port_id);
11882 }
11883 
11884 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
11885 	TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
11886 		get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
11887 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
11888 	TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
11889 		port_id, UINT16);
11890 
11891 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
11892 	.f = cmd_get_sym_hash_per_port_parsed,
11893 	.data = NULL,
11894 	.help_str = "get_sym_hash_ena_per_port <port_id>",
11895 	.tokens = {
11896 		(void *)&cmd_get_sym_hash_ena_per_port_all,
11897 		(void *)&cmd_get_sym_hash_ena_per_port_port_id,
11898 		NULL,
11899 	},
11900 };
11901 
11902 /* *** Set symmetric hash enable per port *** */
11903 struct cmd_set_sym_hash_ena_per_port_result {
11904 	cmdline_fixed_string_t set_sym_hash_ena_per_port;
11905 	cmdline_fixed_string_t enable;
11906 	portid_t port_id;
11907 };
11908 
11909 static void
11910 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
11911 				 __rte_unused struct cmdline *cl,
11912 				 __rte_unused void *data)
11913 {
11914 	struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
11915 	struct rte_eth_hash_filter_info info;
11916 	int ret;
11917 
11918 	if (rte_eth_dev_filter_supported(res->port_id,
11919 				RTE_ETH_FILTER_HASH) < 0) {
11920 		printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
11921 							res->port_id);
11922 		return;
11923 	}
11924 
11925 	memset(&info, 0, sizeof(info));
11926 	info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
11927 	if (!strcmp(res->enable, "enable"))
11928 		info.info.enable = 1;
11929 	ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11930 					RTE_ETH_FILTER_SET, &info);
11931 	if (ret < 0) {
11932 		printf("Cannot set symmetric hash enable per port on "
11933 					"port %u\n", res->port_id);
11934 		return;
11935 	}
11936 	printf("Symmetric hash has been set to %s on port %u\n",
11937 					res->enable, res->port_id);
11938 }
11939 
11940 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
11941 	TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11942 		set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
11943 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
11944 	TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11945 		port_id, UINT16);
11946 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
11947 	TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11948 		enable, "enable#disable");
11949 
11950 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
11951 	.f = cmd_set_sym_hash_per_port_parsed,
11952 	.data = NULL,
11953 	.help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
11954 	.tokens = {
11955 		(void *)&cmd_set_sym_hash_ena_per_port_all,
11956 		(void *)&cmd_set_sym_hash_ena_per_port_port_id,
11957 		(void *)&cmd_set_sym_hash_ena_per_port_enable,
11958 		NULL,
11959 	},
11960 };
11961 
11962 /* Get global config of hash function */
11963 struct cmd_get_hash_global_config_result {
11964 	cmdline_fixed_string_t get_hash_global_config;
11965 	portid_t port_id;
11966 };
11967 
11968 static char *
11969 flowtype_to_str(uint16_t ftype)
11970 {
11971 	uint16_t i;
11972 	static struct {
11973 		char str[16];
11974 		uint16_t ftype;
11975 	} ftype_table[] = {
11976 		{"ipv4", RTE_ETH_FLOW_IPV4},
11977 		{"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
11978 		{"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
11979 		{"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
11980 		{"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
11981 		{"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
11982 		{"ipv6", RTE_ETH_FLOW_IPV6},
11983 		{"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
11984 		{"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
11985 		{"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
11986 		{"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
11987 		{"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
11988 		{"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
11989 		{"port", RTE_ETH_FLOW_PORT},
11990 		{"vxlan", RTE_ETH_FLOW_VXLAN},
11991 		{"geneve", RTE_ETH_FLOW_GENEVE},
11992 		{"nvgre", RTE_ETH_FLOW_NVGRE},
11993 		{"vxlan-gpe", RTE_ETH_FLOW_VXLAN_GPE},
11994 	};
11995 
11996 	for (i = 0; i < RTE_DIM(ftype_table); i++) {
11997 		if (ftype_table[i].ftype == ftype)
11998 			return ftype_table[i].str;
11999 	}
12000 
12001 	return NULL;
12002 }
12003 
12004 static void
12005 cmd_get_hash_global_config_parsed(void *parsed_result,
12006 				  __rte_unused struct cmdline *cl,
12007 				  __rte_unused void *data)
12008 {
12009 	struct cmd_get_hash_global_config_result *res = parsed_result;
12010 	struct rte_eth_hash_filter_info info;
12011 	uint32_t idx, offset;
12012 	uint16_t i;
12013 	char *str;
12014 	int ret;
12015 
12016 	if (rte_eth_dev_filter_supported(res->port_id,
12017 			RTE_ETH_FILTER_HASH) < 0) {
12018 		printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
12019 							res->port_id);
12020 		return;
12021 	}
12022 
12023 	memset(&info, 0, sizeof(info));
12024 	info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
12025 	ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12026 					RTE_ETH_FILTER_GET, &info);
12027 	if (ret < 0) {
12028 		printf("Cannot get hash global configurations by port %d\n",
12029 							res->port_id);
12030 		return;
12031 	}
12032 
12033 	switch (info.info.global_conf.hash_func) {
12034 	case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
12035 		printf("Hash function is Toeplitz\n");
12036 		break;
12037 	case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
12038 		printf("Hash function is Simple XOR\n");
12039 		break;
12040 	default:
12041 		printf("Unknown hash function\n");
12042 		break;
12043 	}
12044 
12045 	for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
12046 		idx = i / UINT64_BIT;
12047 		offset = i % UINT64_BIT;
12048 		if (!(info.info.global_conf.valid_bit_mask[idx] &
12049 						(1ULL << offset)))
12050 			continue;
12051 		str = flowtype_to_str(i);
12052 		if (!str)
12053 			continue;
12054 		printf("Symmetric hash is %s globally for flow type %s "
12055 							"by port %d\n",
12056 			((info.info.global_conf.sym_hash_enable_mask[idx] &
12057 			(1ULL << offset)) ? "enabled" : "disabled"), str,
12058 							res->port_id);
12059 	}
12060 }
12061 
12062 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
12063 	TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
12064 		get_hash_global_config, "get_hash_global_config");
12065 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
12066 	TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
12067 		port_id, UINT16);
12068 
12069 cmdline_parse_inst_t cmd_get_hash_global_config = {
12070 	.f = cmd_get_hash_global_config_parsed,
12071 	.data = NULL,
12072 	.help_str = "get_hash_global_config <port_id>",
12073 	.tokens = {
12074 		(void *)&cmd_get_hash_global_config_all,
12075 		(void *)&cmd_get_hash_global_config_port_id,
12076 		NULL,
12077 	},
12078 };
12079 
12080 /* Set global config of hash function */
12081 struct cmd_set_hash_global_config_result {
12082 	cmdline_fixed_string_t set_hash_global_config;
12083 	portid_t port_id;
12084 	cmdline_fixed_string_t hash_func;
12085 	cmdline_fixed_string_t flow_type;
12086 	cmdline_fixed_string_t enable;
12087 };
12088 
12089 static void
12090 cmd_set_hash_global_config_parsed(void *parsed_result,
12091 				  __rte_unused struct cmdline *cl,
12092 				  __rte_unused void *data)
12093 {
12094 	struct cmd_set_hash_global_config_result *res = parsed_result;
12095 	struct rte_eth_hash_filter_info info;
12096 	uint32_t ftype, idx, offset;
12097 	int ret;
12098 
12099 	if (rte_eth_dev_filter_supported(res->port_id,
12100 				RTE_ETH_FILTER_HASH) < 0) {
12101 		printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
12102 							res->port_id);
12103 		return;
12104 	}
12105 	memset(&info, 0, sizeof(info));
12106 	info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
12107 	if (!strcmp(res->hash_func, "toeplitz"))
12108 		info.info.global_conf.hash_func =
12109 			RTE_ETH_HASH_FUNCTION_TOEPLITZ;
12110 	else if (!strcmp(res->hash_func, "simple_xor"))
12111 		info.info.global_conf.hash_func =
12112 			RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
12113 	else if (!strcmp(res->hash_func, "default"))
12114 		info.info.global_conf.hash_func =
12115 			RTE_ETH_HASH_FUNCTION_DEFAULT;
12116 
12117 	ftype = str2flowtype(res->flow_type);
12118 	idx = ftype / UINT64_BIT;
12119 	offset = ftype % UINT64_BIT;
12120 	info.info.global_conf.valid_bit_mask[idx] |= (1ULL << offset);
12121 	if (!strcmp(res->enable, "enable"))
12122 		info.info.global_conf.sym_hash_enable_mask[idx] |=
12123 						(1ULL << offset);
12124 	ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12125 					RTE_ETH_FILTER_SET, &info);
12126 	if (ret < 0)
12127 		printf("Cannot set global hash configurations by port %d\n",
12128 							res->port_id);
12129 	else
12130 		printf("Global hash configurations have been set "
12131 			"successfully by port %d\n", res->port_id);
12132 }
12133 
12134 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
12135 	TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12136 		set_hash_global_config, "set_hash_global_config");
12137 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
12138 	TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
12139 		port_id, UINT16);
12140 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
12141 	TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12142 		hash_func, "toeplitz#simple_xor#default");
12143 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
12144 	TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12145 		flow_type,
12146 		"ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
12147 		"ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12148 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
12149 	TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12150 		enable, "enable#disable");
12151 
12152 cmdline_parse_inst_t cmd_set_hash_global_config = {
12153 	.f = cmd_set_hash_global_config_parsed,
12154 	.data = NULL,
12155 	.help_str = "set_hash_global_config <port_id> "
12156 		"toeplitz|simple_xor|default "
12157 		"ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12158 		"ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
12159 		"l2_payload enable|disable",
12160 	.tokens = {
12161 		(void *)&cmd_set_hash_global_config_all,
12162 		(void *)&cmd_set_hash_global_config_port_id,
12163 		(void *)&cmd_set_hash_global_config_hash_func,
12164 		(void *)&cmd_set_hash_global_config_flow_type,
12165 		(void *)&cmd_set_hash_global_config_enable,
12166 		NULL,
12167 	},
12168 };
12169 
12170 /* Set hash input set */
12171 struct cmd_set_hash_input_set_result {
12172 	cmdline_fixed_string_t set_hash_input_set;
12173 	portid_t port_id;
12174 	cmdline_fixed_string_t flow_type;
12175 	cmdline_fixed_string_t inset_field;
12176 	cmdline_fixed_string_t select;
12177 };
12178 
12179 static enum rte_eth_input_set_field
12180 str2inset(char *string)
12181 {
12182 	uint16_t i;
12183 
12184 	static const struct {
12185 		char str[32];
12186 		enum rte_eth_input_set_field inset;
12187 	} inset_table[] = {
12188 		{"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
12189 		{"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
12190 		{"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
12191 		{"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
12192 		{"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
12193 		{"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
12194 		{"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
12195 		{"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
12196 		{"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
12197 		{"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
12198 		{"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
12199 		{"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
12200 		{"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
12201 		{"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
12202 		{"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
12203 		{"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
12204 		{"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
12205 		{"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
12206 		{"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
12207 		{"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
12208 		{"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
12209 		{"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
12210 		{"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
12211 		{"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
12212 		{"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
12213 		{"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
12214 		{"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
12215 		{"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
12216 		{"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
12217 		{"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
12218 		{"none", RTE_ETH_INPUT_SET_NONE},
12219 	};
12220 
12221 	for (i = 0; i < RTE_DIM(inset_table); i++) {
12222 		if (!strcmp(string, inset_table[i].str))
12223 			return inset_table[i].inset;
12224 	}
12225 
12226 	return RTE_ETH_INPUT_SET_UNKNOWN;
12227 }
12228 
12229 static void
12230 cmd_set_hash_input_set_parsed(void *parsed_result,
12231 			      __rte_unused struct cmdline *cl,
12232 			      __rte_unused void *data)
12233 {
12234 	struct cmd_set_hash_input_set_result *res = parsed_result;
12235 	struct rte_eth_hash_filter_info info;
12236 
12237 	memset(&info, 0, sizeof(info));
12238 	info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
12239 	info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12240 	info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12241 	info.info.input_set_conf.inset_size = 1;
12242 	if (!strcmp(res->select, "select"))
12243 		info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12244 	else if (!strcmp(res->select, "add"))
12245 		info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12246 	rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12247 				RTE_ETH_FILTER_SET, &info);
12248 }
12249 
12250 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
12251 	TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12252 		set_hash_input_set, "set_hash_input_set");
12253 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
12254 	TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
12255 		port_id, UINT16);
12256 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
12257 	TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12258 		flow_type, NULL);
12259 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
12260 	TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12261 		inset_field,
12262 		"ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12263 		"ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
12264 		"udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
12265 		"sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
12266 		"fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
12267 		"fld-8th#none");
12268 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
12269 	TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12270 		select, "select#add");
12271 
12272 cmdline_parse_inst_t cmd_set_hash_input_set = {
12273 	.f = cmd_set_hash_input_set_parsed,
12274 	.data = NULL,
12275 	.help_str = "set_hash_input_set <port_id> "
12276 	"ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12277 	"ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
12278 	"ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
12279 	"ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
12280 	"tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
12281 	"gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
12282 	"fld-7th|fld-8th|none select|add",
12283 	.tokens = {
12284 		(void *)&cmd_set_hash_input_set_cmd,
12285 		(void *)&cmd_set_hash_input_set_port_id,
12286 		(void *)&cmd_set_hash_input_set_flow_type,
12287 		(void *)&cmd_set_hash_input_set_field,
12288 		(void *)&cmd_set_hash_input_set_select,
12289 		NULL,
12290 	},
12291 };
12292 
12293 /* Set flow director input set */
12294 struct cmd_set_fdir_input_set_result {
12295 	cmdline_fixed_string_t set_fdir_input_set;
12296 	portid_t port_id;
12297 	cmdline_fixed_string_t flow_type;
12298 	cmdline_fixed_string_t inset_field;
12299 	cmdline_fixed_string_t select;
12300 };
12301 
12302 static void
12303 cmd_set_fdir_input_set_parsed(void *parsed_result,
12304 	__rte_unused struct cmdline *cl,
12305 	__rte_unused void *data)
12306 {
12307 	struct cmd_set_fdir_input_set_result *res = parsed_result;
12308 	struct rte_eth_fdir_filter_info info;
12309 
12310 	memset(&info, 0, sizeof(info));
12311 	info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
12312 	info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12313 	info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12314 	info.info.input_set_conf.inset_size = 1;
12315 	if (!strcmp(res->select, "select"))
12316 		info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12317 	else if (!strcmp(res->select, "add"))
12318 		info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12319 	rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
12320 		RTE_ETH_FILTER_SET, &info);
12321 }
12322 
12323 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
12324 	TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12325 	set_fdir_input_set, "set_fdir_input_set");
12326 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
12327 	TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
12328 	port_id, UINT16);
12329 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
12330 	TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12331 	flow_type,
12332 	"ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
12333 	"ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12334 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
12335 	TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12336 	inset_field,
12337 	"ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12338 	"ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
12339 	"ipv6-hop-limits#udp-src-port#udp-dst-port#"
12340 	"tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
12341 	"sctp-veri-tag#none");
12342 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
12343 	TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12344 	select, "select#add");
12345 
12346 cmdline_parse_inst_t cmd_set_fdir_input_set = {
12347 	.f = cmd_set_fdir_input_set_parsed,
12348 	.data = NULL,
12349 	.help_str = "set_fdir_input_set <port_id> "
12350 	"ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12351 	"ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
12352 	"ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
12353 	"ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
12354 	"ipv6-hop-limits|udp-src-port|udp-dst-port|"
12355 	"tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
12356 	"sctp-veri-tag|none select|add",
12357 	.tokens = {
12358 		(void *)&cmd_set_fdir_input_set_cmd,
12359 		(void *)&cmd_set_fdir_input_set_port_id,
12360 		(void *)&cmd_set_fdir_input_set_flow_type,
12361 		(void *)&cmd_set_fdir_input_set_field,
12362 		(void *)&cmd_set_fdir_input_set_select,
12363 		NULL,
12364 	},
12365 };
12366 
12367 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
12368 struct cmd_mcast_addr_result {
12369 	cmdline_fixed_string_t mcast_addr_cmd;
12370 	cmdline_fixed_string_t what;
12371 	uint16_t port_num;
12372 	struct ether_addr mc_addr;
12373 };
12374 
12375 static void cmd_mcast_addr_parsed(void *parsed_result,
12376 		__attribute__((unused)) struct cmdline *cl,
12377 		__attribute__((unused)) void *data)
12378 {
12379 	struct cmd_mcast_addr_result *res = parsed_result;
12380 
12381 	if (!is_multicast_ether_addr(&res->mc_addr)) {
12382 		printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
12383 		       res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
12384 		       res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
12385 		       res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
12386 		return;
12387 	}
12388 	if (strcmp(res->what, "add") == 0)
12389 		mcast_addr_add(res->port_num, &res->mc_addr);
12390 	else
12391 		mcast_addr_remove(res->port_num, &res->mc_addr);
12392 }
12393 
12394 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
12395 	TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
12396 				 mcast_addr_cmd, "mcast_addr");
12397 cmdline_parse_token_string_t cmd_mcast_addr_what =
12398 	TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
12399 				 "add#remove");
12400 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
12401 	TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
12402 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
12403 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
12404 
12405 cmdline_parse_inst_t cmd_mcast_addr = {
12406 	.f = cmd_mcast_addr_parsed,
12407 	.data = (void *)0,
12408 	.help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
12409 		"Add/Remove multicast MAC address on port_id",
12410 	.tokens = {
12411 		(void *)&cmd_mcast_addr_cmd,
12412 		(void *)&cmd_mcast_addr_what,
12413 		(void *)&cmd_mcast_addr_portnum,
12414 		(void *)&cmd_mcast_addr_addr,
12415 		NULL,
12416 	},
12417 };
12418 
12419 /* l2 tunnel config
12420  * only support E-tag now.
12421  */
12422 
12423 /* Ether type config */
12424 struct cmd_config_l2_tunnel_eth_type_result {
12425 	cmdline_fixed_string_t port;
12426 	cmdline_fixed_string_t config;
12427 	cmdline_fixed_string_t all;
12428 	portid_t id;
12429 	cmdline_fixed_string_t l2_tunnel;
12430 	cmdline_fixed_string_t l2_tunnel_type;
12431 	cmdline_fixed_string_t eth_type;
12432 	uint16_t eth_type_val;
12433 };
12434 
12435 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
12436 	TOKEN_STRING_INITIALIZER
12437 		(struct cmd_config_l2_tunnel_eth_type_result,
12438 		 port, "port");
12439 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
12440 	TOKEN_STRING_INITIALIZER
12441 		(struct cmd_config_l2_tunnel_eth_type_result,
12442 		 config, "config");
12443 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
12444 	TOKEN_STRING_INITIALIZER
12445 		(struct cmd_config_l2_tunnel_eth_type_result,
12446 		 all, "all");
12447 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
12448 	TOKEN_NUM_INITIALIZER
12449 		(struct cmd_config_l2_tunnel_eth_type_result,
12450 		 id, UINT16);
12451 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
12452 	TOKEN_STRING_INITIALIZER
12453 		(struct cmd_config_l2_tunnel_eth_type_result,
12454 		 l2_tunnel, "l2-tunnel");
12455 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
12456 	TOKEN_STRING_INITIALIZER
12457 		(struct cmd_config_l2_tunnel_eth_type_result,
12458 		 l2_tunnel_type, "E-tag");
12459 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
12460 	TOKEN_STRING_INITIALIZER
12461 		(struct cmd_config_l2_tunnel_eth_type_result,
12462 		 eth_type, "ether-type");
12463 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
12464 	TOKEN_NUM_INITIALIZER
12465 		(struct cmd_config_l2_tunnel_eth_type_result,
12466 		 eth_type_val, UINT16);
12467 
12468 static enum rte_eth_tunnel_type
12469 str2fdir_l2_tunnel_type(char *string)
12470 {
12471 	uint32_t i = 0;
12472 
12473 	static const struct {
12474 		char str[32];
12475 		enum rte_eth_tunnel_type type;
12476 	} l2_tunnel_type_str[] = {
12477 		{"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
12478 	};
12479 
12480 	for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
12481 		if (!strcmp(l2_tunnel_type_str[i].str, string))
12482 			return l2_tunnel_type_str[i].type;
12483 	}
12484 	return RTE_TUNNEL_TYPE_NONE;
12485 }
12486 
12487 /* ether type config for all ports */
12488 static void
12489 cmd_config_l2_tunnel_eth_type_all_parsed
12490 	(void *parsed_result,
12491 	 __attribute__((unused)) struct cmdline *cl,
12492 	 __attribute__((unused)) void *data)
12493 {
12494 	struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
12495 	struct rte_eth_l2_tunnel_conf entry;
12496 	portid_t pid;
12497 
12498 	entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12499 	entry.ether_type = res->eth_type_val;
12500 
12501 	RTE_ETH_FOREACH_DEV(pid) {
12502 		rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
12503 	}
12504 }
12505 
12506 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
12507 	.f = cmd_config_l2_tunnel_eth_type_all_parsed,
12508 	.data = NULL,
12509 	.help_str = "port config all l2-tunnel E-tag ether-type <value>",
12510 	.tokens = {
12511 		(void *)&cmd_config_l2_tunnel_eth_type_port,
12512 		(void *)&cmd_config_l2_tunnel_eth_type_config,
12513 		(void *)&cmd_config_l2_tunnel_eth_type_all_str,
12514 		(void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12515 		(void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12516 		(void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12517 		(void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12518 		NULL,
12519 	},
12520 };
12521 
12522 /* ether type config for a specific port */
12523 static void
12524 cmd_config_l2_tunnel_eth_type_specific_parsed(
12525 	void *parsed_result,
12526 	__attribute__((unused)) struct cmdline *cl,
12527 	__attribute__((unused)) void *data)
12528 {
12529 	struct cmd_config_l2_tunnel_eth_type_result *res =
12530 		 parsed_result;
12531 	struct rte_eth_l2_tunnel_conf entry;
12532 
12533 	if (port_id_is_invalid(res->id, ENABLED_WARN))
12534 		return;
12535 
12536 	entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12537 	entry.ether_type = res->eth_type_val;
12538 
12539 	rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
12540 }
12541 
12542 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
12543 	.f = cmd_config_l2_tunnel_eth_type_specific_parsed,
12544 	.data = NULL,
12545 	.help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
12546 	.tokens = {
12547 		(void *)&cmd_config_l2_tunnel_eth_type_port,
12548 		(void *)&cmd_config_l2_tunnel_eth_type_config,
12549 		(void *)&cmd_config_l2_tunnel_eth_type_id,
12550 		(void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12551 		(void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12552 		(void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12553 		(void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12554 		NULL,
12555 	},
12556 };
12557 
12558 /* Enable/disable l2 tunnel */
12559 struct cmd_config_l2_tunnel_en_dis_result {
12560 	cmdline_fixed_string_t port;
12561 	cmdline_fixed_string_t config;
12562 	cmdline_fixed_string_t all;
12563 	portid_t id;
12564 	cmdline_fixed_string_t l2_tunnel;
12565 	cmdline_fixed_string_t l2_tunnel_type;
12566 	cmdline_fixed_string_t en_dis;
12567 };
12568 
12569 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
12570 	TOKEN_STRING_INITIALIZER
12571 		(struct cmd_config_l2_tunnel_en_dis_result,
12572 		 port, "port");
12573 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
12574 	TOKEN_STRING_INITIALIZER
12575 		(struct cmd_config_l2_tunnel_en_dis_result,
12576 		 config, "config");
12577 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
12578 	TOKEN_STRING_INITIALIZER
12579 		(struct cmd_config_l2_tunnel_en_dis_result,
12580 		 all, "all");
12581 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
12582 	TOKEN_NUM_INITIALIZER
12583 		(struct cmd_config_l2_tunnel_en_dis_result,
12584 		 id, UINT16);
12585 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
12586 	TOKEN_STRING_INITIALIZER
12587 		(struct cmd_config_l2_tunnel_en_dis_result,
12588 		 l2_tunnel, "l2-tunnel");
12589 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
12590 	TOKEN_STRING_INITIALIZER
12591 		(struct cmd_config_l2_tunnel_en_dis_result,
12592 		 l2_tunnel_type, "E-tag");
12593 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
12594 	TOKEN_STRING_INITIALIZER
12595 		(struct cmd_config_l2_tunnel_en_dis_result,
12596 		 en_dis, "enable#disable");
12597 
12598 /* enable/disable l2 tunnel for all ports */
12599 static void
12600 cmd_config_l2_tunnel_en_dis_all_parsed(
12601 	void *parsed_result,
12602 	__attribute__((unused)) struct cmdline *cl,
12603 	__attribute__((unused)) void *data)
12604 {
12605 	struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
12606 	struct rte_eth_l2_tunnel_conf entry;
12607 	portid_t pid;
12608 	uint8_t en;
12609 
12610 	entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12611 
12612 	if (!strcmp("enable", res->en_dis))
12613 		en = 1;
12614 	else
12615 		en = 0;
12616 
12617 	RTE_ETH_FOREACH_DEV(pid) {
12618 		rte_eth_dev_l2_tunnel_offload_set(pid,
12619 						  &entry,
12620 						  ETH_L2_TUNNEL_ENABLE_MASK,
12621 						  en);
12622 	}
12623 }
12624 
12625 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
12626 	.f = cmd_config_l2_tunnel_en_dis_all_parsed,
12627 	.data = NULL,
12628 	.help_str = "port config all l2-tunnel E-tag enable|disable",
12629 	.tokens = {
12630 		(void *)&cmd_config_l2_tunnel_en_dis_port,
12631 		(void *)&cmd_config_l2_tunnel_en_dis_config,
12632 		(void *)&cmd_config_l2_tunnel_en_dis_all_str,
12633 		(void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12634 		(void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12635 		(void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12636 		NULL,
12637 	},
12638 };
12639 
12640 /* enable/disable l2 tunnel for a port */
12641 static void
12642 cmd_config_l2_tunnel_en_dis_specific_parsed(
12643 	void *parsed_result,
12644 	__attribute__((unused)) struct cmdline *cl,
12645 	__attribute__((unused)) void *data)
12646 {
12647 	struct cmd_config_l2_tunnel_en_dis_result *res =
12648 		parsed_result;
12649 	struct rte_eth_l2_tunnel_conf entry;
12650 
12651 	if (port_id_is_invalid(res->id, ENABLED_WARN))
12652 		return;
12653 
12654 	entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12655 
12656 	if (!strcmp("enable", res->en_dis))
12657 		rte_eth_dev_l2_tunnel_offload_set(res->id,
12658 						  &entry,
12659 						  ETH_L2_TUNNEL_ENABLE_MASK,
12660 						  1);
12661 	else
12662 		rte_eth_dev_l2_tunnel_offload_set(res->id,
12663 						  &entry,
12664 						  ETH_L2_TUNNEL_ENABLE_MASK,
12665 						  0);
12666 }
12667 
12668 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
12669 	.f = cmd_config_l2_tunnel_en_dis_specific_parsed,
12670 	.data = NULL,
12671 	.help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
12672 	.tokens = {
12673 		(void *)&cmd_config_l2_tunnel_en_dis_port,
12674 		(void *)&cmd_config_l2_tunnel_en_dis_config,
12675 		(void *)&cmd_config_l2_tunnel_en_dis_id,
12676 		(void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12677 		(void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12678 		(void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12679 		NULL,
12680 	},
12681 };
12682 
12683 /* E-tag configuration */
12684 
12685 /* Common result structure for all E-tag configuration */
12686 struct cmd_config_e_tag_result {
12687 	cmdline_fixed_string_t e_tag;
12688 	cmdline_fixed_string_t set;
12689 	cmdline_fixed_string_t insertion;
12690 	cmdline_fixed_string_t stripping;
12691 	cmdline_fixed_string_t forwarding;
12692 	cmdline_fixed_string_t filter;
12693 	cmdline_fixed_string_t add;
12694 	cmdline_fixed_string_t del;
12695 	cmdline_fixed_string_t on;
12696 	cmdline_fixed_string_t off;
12697 	cmdline_fixed_string_t on_off;
12698 	cmdline_fixed_string_t port_tag_id;
12699 	uint32_t port_tag_id_val;
12700 	cmdline_fixed_string_t e_tag_id;
12701 	uint16_t e_tag_id_val;
12702 	cmdline_fixed_string_t dst_pool;
12703 	uint8_t dst_pool_val;
12704 	cmdline_fixed_string_t port;
12705 	portid_t port_id;
12706 	cmdline_fixed_string_t vf;
12707 	uint8_t vf_id;
12708 };
12709 
12710 /* Common CLI fields for all E-tag configuration */
12711 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
12712 	TOKEN_STRING_INITIALIZER
12713 		(struct cmd_config_e_tag_result,
12714 		 e_tag, "E-tag");
12715 cmdline_parse_token_string_t cmd_config_e_tag_set =
12716 	TOKEN_STRING_INITIALIZER
12717 		(struct cmd_config_e_tag_result,
12718 		 set, "set");
12719 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
12720 	TOKEN_STRING_INITIALIZER
12721 		(struct cmd_config_e_tag_result,
12722 		 insertion, "insertion");
12723 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
12724 	TOKEN_STRING_INITIALIZER
12725 		(struct cmd_config_e_tag_result,
12726 		 stripping, "stripping");
12727 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
12728 	TOKEN_STRING_INITIALIZER
12729 		(struct cmd_config_e_tag_result,
12730 		 forwarding, "forwarding");
12731 cmdline_parse_token_string_t cmd_config_e_tag_filter =
12732 	TOKEN_STRING_INITIALIZER
12733 		(struct cmd_config_e_tag_result,
12734 		 filter, "filter");
12735 cmdline_parse_token_string_t cmd_config_e_tag_add =
12736 	TOKEN_STRING_INITIALIZER
12737 		(struct cmd_config_e_tag_result,
12738 		 add, "add");
12739 cmdline_parse_token_string_t cmd_config_e_tag_del =
12740 	TOKEN_STRING_INITIALIZER
12741 		(struct cmd_config_e_tag_result,
12742 		 del, "del");
12743 cmdline_parse_token_string_t cmd_config_e_tag_on =
12744 	TOKEN_STRING_INITIALIZER
12745 		(struct cmd_config_e_tag_result,
12746 		 on, "on");
12747 cmdline_parse_token_string_t cmd_config_e_tag_off =
12748 	TOKEN_STRING_INITIALIZER
12749 		(struct cmd_config_e_tag_result,
12750 		 off, "off");
12751 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
12752 	TOKEN_STRING_INITIALIZER
12753 		(struct cmd_config_e_tag_result,
12754 		 on_off, "on#off");
12755 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
12756 	TOKEN_STRING_INITIALIZER
12757 		(struct cmd_config_e_tag_result,
12758 		 port_tag_id, "port-tag-id");
12759 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
12760 	TOKEN_NUM_INITIALIZER
12761 		(struct cmd_config_e_tag_result,
12762 		 port_tag_id_val, UINT32);
12763 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
12764 	TOKEN_STRING_INITIALIZER
12765 		(struct cmd_config_e_tag_result,
12766 		 e_tag_id, "e-tag-id");
12767 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
12768 	TOKEN_NUM_INITIALIZER
12769 		(struct cmd_config_e_tag_result,
12770 		 e_tag_id_val, UINT16);
12771 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
12772 	TOKEN_STRING_INITIALIZER
12773 		(struct cmd_config_e_tag_result,
12774 		 dst_pool, "dst-pool");
12775 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
12776 	TOKEN_NUM_INITIALIZER
12777 		(struct cmd_config_e_tag_result,
12778 		 dst_pool_val, UINT8);
12779 cmdline_parse_token_string_t cmd_config_e_tag_port =
12780 	TOKEN_STRING_INITIALIZER
12781 		(struct cmd_config_e_tag_result,
12782 		 port, "port");
12783 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
12784 	TOKEN_NUM_INITIALIZER
12785 		(struct cmd_config_e_tag_result,
12786 		 port_id, UINT16);
12787 cmdline_parse_token_string_t cmd_config_e_tag_vf =
12788 	TOKEN_STRING_INITIALIZER
12789 		(struct cmd_config_e_tag_result,
12790 		 vf, "vf");
12791 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
12792 	TOKEN_NUM_INITIALIZER
12793 		(struct cmd_config_e_tag_result,
12794 		 vf_id, UINT8);
12795 
12796 /* E-tag insertion configuration */
12797 static void
12798 cmd_config_e_tag_insertion_en_parsed(
12799 	void *parsed_result,
12800 	__attribute__((unused)) struct cmdline *cl,
12801 	__attribute__((unused)) void *data)
12802 {
12803 	struct cmd_config_e_tag_result *res =
12804 		parsed_result;
12805 	struct rte_eth_l2_tunnel_conf entry;
12806 
12807 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12808 		return;
12809 
12810 	entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12811 	entry.tunnel_id = res->port_tag_id_val;
12812 	entry.vf_id = res->vf_id;
12813 	rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12814 					  &entry,
12815 					  ETH_L2_TUNNEL_INSERTION_MASK,
12816 					  1);
12817 }
12818 
12819 static void
12820 cmd_config_e_tag_insertion_dis_parsed(
12821 	void *parsed_result,
12822 	__attribute__((unused)) struct cmdline *cl,
12823 	__attribute__((unused)) void *data)
12824 {
12825 	struct cmd_config_e_tag_result *res =
12826 		parsed_result;
12827 	struct rte_eth_l2_tunnel_conf entry;
12828 
12829 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12830 		return;
12831 
12832 	entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12833 	entry.vf_id = res->vf_id;
12834 
12835 	rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12836 					  &entry,
12837 					  ETH_L2_TUNNEL_INSERTION_MASK,
12838 					  0);
12839 }
12840 
12841 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
12842 	.f = cmd_config_e_tag_insertion_en_parsed,
12843 	.data = NULL,
12844 	.help_str = "E-tag ... : E-tag insertion enable",
12845 	.tokens = {
12846 		(void *)&cmd_config_e_tag_e_tag,
12847 		(void *)&cmd_config_e_tag_set,
12848 		(void *)&cmd_config_e_tag_insertion,
12849 		(void *)&cmd_config_e_tag_on,
12850 		(void *)&cmd_config_e_tag_port_tag_id,
12851 		(void *)&cmd_config_e_tag_port_tag_id_val,
12852 		(void *)&cmd_config_e_tag_port,
12853 		(void *)&cmd_config_e_tag_port_id,
12854 		(void *)&cmd_config_e_tag_vf,
12855 		(void *)&cmd_config_e_tag_vf_id,
12856 		NULL,
12857 	},
12858 };
12859 
12860 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
12861 	.f = cmd_config_e_tag_insertion_dis_parsed,
12862 	.data = NULL,
12863 	.help_str = "E-tag ... : E-tag insertion disable",
12864 	.tokens = {
12865 		(void *)&cmd_config_e_tag_e_tag,
12866 		(void *)&cmd_config_e_tag_set,
12867 		(void *)&cmd_config_e_tag_insertion,
12868 		(void *)&cmd_config_e_tag_off,
12869 		(void *)&cmd_config_e_tag_port,
12870 		(void *)&cmd_config_e_tag_port_id,
12871 		(void *)&cmd_config_e_tag_vf,
12872 		(void *)&cmd_config_e_tag_vf_id,
12873 		NULL,
12874 	},
12875 };
12876 
12877 /* E-tag stripping configuration */
12878 static void
12879 cmd_config_e_tag_stripping_parsed(
12880 	void *parsed_result,
12881 	__attribute__((unused)) struct cmdline *cl,
12882 	__attribute__((unused)) void *data)
12883 {
12884 	struct cmd_config_e_tag_result *res =
12885 		parsed_result;
12886 	struct rte_eth_l2_tunnel_conf entry;
12887 
12888 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12889 		return;
12890 
12891 	entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12892 
12893 	if (!strcmp(res->on_off, "on"))
12894 		rte_eth_dev_l2_tunnel_offload_set
12895 			(res->port_id,
12896 			 &entry,
12897 			 ETH_L2_TUNNEL_STRIPPING_MASK,
12898 			 1);
12899 	else
12900 		rte_eth_dev_l2_tunnel_offload_set
12901 			(res->port_id,
12902 			 &entry,
12903 			 ETH_L2_TUNNEL_STRIPPING_MASK,
12904 			 0);
12905 }
12906 
12907 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
12908 	.f = cmd_config_e_tag_stripping_parsed,
12909 	.data = NULL,
12910 	.help_str = "E-tag ... : E-tag stripping enable/disable",
12911 	.tokens = {
12912 		(void *)&cmd_config_e_tag_e_tag,
12913 		(void *)&cmd_config_e_tag_set,
12914 		(void *)&cmd_config_e_tag_stripping,
12915 		(void *)&cmd_config_e_tag_on_off,
12916 		(void *)&cmd_config_e_tag_port,
12917 		(void *)&cmd_config_e_tag_port_id,
12918 		NULL,
12919 	},
12920 };
12921 
12922 /* E-tag forwarding configuration */
12923 static void
12924 cmd_config_e_tag_forwarding_parsed(
12925 	void *parsed_result,
12926 	__attribute__((unused)) struct cmdline *cl,
12927 	__attribute__((unused)) void *data)
12928 {
12929 	struct cmd_config_e_tag_result *res = parsed_result;
12930 	struct rte_eth_l2_tunnel_conf entry;
12931 
12932 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12933 		return;
12934 
12935 	entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12936 
12937 	if (!strcmp(res->on_off, "on"))
12938 		rte_eth_dev_l2_tunnel_offload_set
12939 			(res->port_id,
12940 			 &entry,
12941 			 ETH_L2_TUNNEL_FORWARDING_MASK,
12942 			 1);
12943 	else
12944 		rte_eth_dev_l2_tunnel_offload_set
12945 			(res->port_id,
12946 			 &entry,
12947 			 ETH_L2_TUNNEL_FORWARDING_MASK,
12948 			 0);
12949 }
12950 
12951 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
12952 	.f = cmd_config_e_tag_forwarding_parsed,
12953 	.data = NULL,
12954 	.help_str = "E-tag ... : E-tag forwarding enable/disable",
12955 	.tokens = {
12956 		(void *)&cmd_config_e_tag_e_tag,
12957 		(void *)&cmd_config_e_tag_set,
12958 		(void *)&cmd_config_e_tag_forwarding,
12959 		(void *)&cmd_config_e_tag_on_off,
12960 		(void *)&cmd_config_e_tag_port,
12961 		(void *)&cmd_config_e_tag_port_id,
12962 		NULL,
12963 	},
12964 };
12965 
12966 /* E-tag filter configuration */
12967 static void
12968 cmd_config_e_tag_filter_add_parsed(
12969 	void *parsed_result,
12970 	__attribute__((unused)) struct cmdline *cl,
12971 	__attribute__((unused)) void *data)
12972 {
12973 	struct cmd_config_e_tag_result *res = parsed_result;
12974 	struct rte_eth_l2_tunnel_conf entry;
12975 	int ret = 0;
12976 
12977 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12978 		return;
12979 
12980 	if (res->e_tag_id_val > 0x3fff) {
12981 		printf("e-tag-id must be equal or less than 0x3fff.\n");
12982 		return;
12983 	}
12984 
12985 	ret = rte_eth_dev_filter_supported(res->port_id,
12986 					   RTE_ETH_FILTER_L2_TUNNEL);
12987 	if (ret < 0) {
12988 		printf("E-tag filter is not supported on port %u.\n",
12989 		       res->port_id);
12990 		return;
12991 	}
12992 
12993 	entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12994 	entry.tunnel_id = res->e_tag_id_val;
12995 	entry.pool = res->dst_pool_val;
12996 
12997 	ret = rte_eth_dev_filter_ctrl(res->port_id,
12998 				      RTE_ETH_FILTER_L2_TUNNEL,
12999 				      RTE_ETH_FILTER_ADD,
13000 				      &entry);
13001 	if (ret < 0)
13002 		printf("E-tag filter programming error: (%s)\n",
13003 		       strerror(-ret));
13004 }
13005 
13006 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
13007 	.f = cmd_config_e_tag_filter_add_parsed,
13008 	.data = NULL,
13009 	.help_str = "E-tag ... : E-tag filter add",
13010 	.tokens = {
13011 		(void *)&cmd_config_e_tag_e_tag,
13012 		(void *)&cmd_config_e_tag_set,
13013 		(void *)&cmd_config_e_tag_filter,
13014 		(void *)&cmd_config_e_tag_add,
13015 		(void *)&cmd_config_e_tag_e_tag_id,
13016 		(void *)&cmd_config_e_tag_e_tag_id_val,
13017 		(void *)&cmd_config_e_tag_dst_pool,
13018 		(void *)&cmd_config_e_tag_dst_pool_val,
13019 		(void *)&cmd_config_e_tag_port,
13020 		(void *)&cmd_config_e_tag_port_id,
13021 		NULL,
13022 	},
13023 };
13024 
13025 static void
13026 cmd_config_e_tag_filter_del_parsed(
13027 	void *parsed_result,
13028 	__attribute__((unused)) struct cmdline *cl,
13029 	__attribute__((unused)) void *data)
13030 {
13031 	struct cmd_config_e_tag_result *res = parsed_result;
13032 	struct rte_eth_l2_tunnel_conf entry;
13033 	int ret = 0;
13034 
13035 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13036 		return;
13037 
13038 	if (res->e_tag_id_val > 0x3fff) {
13039 		printf("e-tag-id must be less than 0x3fff.\n");
13040 		return;
13041 	}
13042 
13043 	ret = rte_eth_dev_filter_supported(res->port_id,
13044 					   RTE_ETH_FILTER_L2_TUNNEL);
13045 	if (ret < 0) {
13046 		printf("E-tag filter is not supported on port %u.\n",
13047 		       res->port_id);
13048 		return;
13049 	}
13050 
13051 	entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13052 	entry.tunnel_id = res->e_tag_id_val;
13053 
13054 	ret = rte_eth_dev_filter_ctrl(res->port_id,
13055 				      RTE_ETH_FILTER_L2_TUNNEL,
13056 				      RTE_ETH_FILTER_DELETE,
13057 				      &entry);
13058 	if (ret < 0)
13059 		printf("E-tag filter programming error: (%s)\n",
13060 		       strerror(-ret));
13061 }
13062 
13063 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
13064 	.f = cmd_config_e_tag_filter_del_parsed,
13065 	.data = NULL,
13066 	.help_str = "E-tag ... : E-tag filter delete",
13067 	.tokens = {
13068 		(void *)&cmd_config_e_tag_e_tag,
13069 		(void *)&cmd_config_e_tag_set,
13070 		(void *)&cmd_config_e_tag_filter,
13071 		(void *)&cmd_config_e_tag_del,
13072 		(void *)&cmd_config_e_tag_e_tag_id,
13073 		(void *)&cmd_config_e_tag_e_tag_id_val,
13074 		(void *)&cmd_config_e_tag_port,
13075 		(void *)&cmd_config_e_tag_port_id,
13076 		NULL,
13077 	},
13078 };
13079 
13080 /* vf vlan anti spoof configuration */
13081 
13082 /* Common result structure for vf vlan anti spoof */
13083 struct cmd_vf_vlan_anti_spoof_result {
13084 	cmdline_fixed_string_t set;
13085 	cmdline_fixed_string_t vf;
13086 	cmdline_fixed_string_t vlan;
13087 	cmdline_fixed_string_t antispoof;
13088 	portid_t port_id;
13089 	uint32_t vf_id;
13090 	cmdline_fixed_string_t on_off;
13091 };
13092 
13093 /* Common CLI fields for vf vlan anti spoof enable disable */
13094 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
13095 	TOKEN_STRING_INITIALIZER
13096 		(struct cmd_vf_vlan_anti_spoof_result,
13097 		 set, "set");
13098 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
13099 	TOKEN_STRING_INITIALIZER
13100 		(struct cmd_vf_vlan_anti_spoof_result,
13101 		 vf, "vf");
13102 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
13103 	TOKEN_STRING_INITIALIZER
13104 		(struct cmd_vf_vlan_anti_spoof_result,
13105 		 vlan, "vlan");
13106 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
13107 	TOKEN_STRING_INITIALIZER
13108 		(struct cmd_vf_vlan_anti_spoof_result,
13109 		 antispoof, "antispoof");
13110 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
13111 	TOKEN_NUM_INITIALIZER
13112 		(struct cmd_vf_vlan_anti_spoof_result,
13113 		 port_id, UINT16);
13114 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
13115 	TOKEN_NUM_INITIALIZER
13116 		(struct cmd_vf_vlan_anti_spoof_result,
13117 		 vf_id, UINT32);
13118 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
13119 	TOKEN_STRING_INITIALIZER
13120 		(struct cmd_vf_vlan_anti_spoof_result,
13121 		 on_off, "on#off");
13122 
13123 static void
13124 cmd_set_vf_vlan_anti_spoof_parsed(
13125 	void *parsed_result,
13126 	__attribute__((unused)) struct cmdline *cl,
13127 	__attribute__((unused)) void *data)
13128 {
13129 	struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
13130 	int ret = -ENOTSUP;
13131 
13132 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13133 
13134 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13135 		return;
13136 
13137 #ifdef RTE_LIBRTE_IXGBE_PMD
13138 	if (ret == -ENOTSUP)
13139 		ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
13140 				res->vf_id, is_on);
13141 #endif
13142 #ifdef RTE_LIBRTE_I40E_PMD
13143 	if (ret == -ENOTSUP)
13144 		ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
13145 				res->vf_id, is_on);
13146 #endif
13147 #ifdef RTE_LIBRTE_BNXT_PMD
13148 	if (ret == -ENOTSUP)
13149 		ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
13150 				res->vf_id, is_on);
13151 #endif
13152 
13153 	switch (ret) {
13154 	case 0:
13155 		break;
13156 	case -EINVAL:
13157 		printf("invalid vf_id %d\n", res->vf_id);
13158 		break;
13159 	case -ENODEV:
13160 		printf("invalid port_id %d\n", res->port_id);
13161 		break;
13162 	case -ENOTSUP:
13163 		printf("function not implemented\n");
13164 		break;
13165 	default:
13166 		printf("programming error: (%s)\n", strerror(-ret));
13167 	}
13168 }
13169 
13170 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
13171 	.f = cmd_set_vf_vlan_anti_spoof_parsed,
13172 	.data = NULL,
13173 	.help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
13174 	.tokens = {
13175 		(void *)&cmd_vf_vlan_anti_spoof_set,
13176 		(void *)&cmd_vf_vlan_anti_spoof_vf,
13177 		(void *)&cmd_vf_vlan_anti_spoof_vlan,
13178 		(void *)&cmd_vf_vlan_anti_spoof_antispoof,
13179 		(void *)&cmd_vf_vlan_anti_spoof_port_id,
13180 		(void *)&cmd_vf_vlan_anti_spoof_vf_id,
13181 		(void *)&cmd_vf_vlan_anti_spoof_on_off,
13182 		NULL,
13183 	},
13184 };
13185 
13186 /* vf mac anti spoof configuration */
13187 
13188 /* Common result structure for vf mac anti spoof */
13189 struct cmd_vf_mac_anti_spoof_result {
13190 	cmdline_fixed_string_t set;
13191 	cmdline_fixed_string_t vf;
13192 	cmdline_fixed_string_t mac;
13193 	cmdline_fixed_string_t antispoof;
13194 	portid_t port_id;
13195 	uint32_t vf_id;
13196 	cmdline_fixed_string_t on_off;
13197 };
13198 
13199 /* Common CLI fields for vf mac anti spoof enable disable */
13200 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
13201 	TOKEN_STRING_INITIALIZER
13202 		(struct cmd_vf_mac_anti_spoof_result,
13203 		 set, "set");
13204 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
13205 	TOKEN_STRING_INITIALIZER
13206 		(struct cmd_vf_mac_anti_spoof_result,
13207 		 vf, "vf");
13208 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
13209 	TOKEN_STRING_INITIALIZER
13210 		(struct cmd_vf_mac_anti_spoof_result,
13211 		 mac, "mac");
13212 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
13213 	TOKEN_STRING_INITIALIZER
13214 		(struct cmd_vf_mac_anti_spoof_result,
13215 		 antispoof, "antispoof");
13216 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
13217 	TOKEN_NUM_INITIALIZER
13218 		(struct cmd_vf_mac_anti_spoof_result,
13219 		 port_id, UINT16);
13220 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
13221 	TOKEN_NUM_INITIALIZER
13222 		(struct cmd_vf_mac_anti_spoof_result,
13223 		 vf_id, UINT32);
13224 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
13225 	TOKEN_STRING_INITIALIZER
13226 		(struct cmd_vf_mac_anti_spoof_result,
13227 		 on_off, "on#off");
13228 
13229 static void
13230 cmd_set_vf_mac_anti_spoof_parsed(
13231 	void *parsed_result,
13232 	__attribute__((unused)) struct cmdline *cl,
13233 	__attribute__((unused)) void *data)
13234 {
13235 	struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
13236 	int ret = -ENOTSUP;
13237 
13238 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13239 
13240 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13241 		return;
13242 
13243 #ifdef RTE_LIBRTE_IXGBE_PMD
13244 	if (ret == -ENOTSUP)
13245 		ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
13246 			res->vf_id, is_on);
13247 #endif
13248 #ifdef RTE_LIBRTE_I40E_PMD
13249 	if (ret == -ENOTSUP)
13250 		ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
13251 			res->vf_id, is_on);
13252 #endif
13253 #ifdef RTE_LIBRTE_BNXT_PMD
13254 	if (ret == -ENOTSUP)
13255 		ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
13256 			res->vf_id, is_on);
13257 #endif
13258 
13259 	switch (ret) {
13260 	case 0:
13261 		break;
13262 	case -EINVAL:
13263 		printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13264 		break;
13265 	case -ENODEV:
13266 		printf("invalid port_id %d\n", res->port_id);
13267 		break;
13268 	case -ENOTSUP:
13269 		printf("function not implemented\n");
13270 		break;
13271 	default:
13272 		printf("programming error: (%s)\n", strerror(-ret));
13273 	}
13274 }
13275 
13276 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
13277 	.f = cmd_set_vf_mac_anti_spoof_parsed,
13278 	.data = NULL,
13279 	.help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
13280 	.tokens = {
13281 		(void *)&cmd_vf_mac_anti_spoof_set,
13282 		(void *)&cmd_vf_mac_anti_spoof_vf,
13283 		(void *)&cmd_vf_mac_anti_spoof_mac,
13284 		(void *)&cmd_vf_mac_anti_spoof_antispoof,
13285 		(void *)&cmd_vf_mac_anti_spoof_port_id,
13286 		(void *)&cmd_vf_mac_anti_spoof_vf_id,
13287 		(void *)&cmd_vf_mac_anti_spoof_on_off,
13288 		NULL,
13289 	},
13290 };
13291 
13292 /* vf vlan strip queue configuration */
13293 
13294 /* Common result structure for vf mac anti spoof */
13295 struct cmd_vf_vlan_stripq_result {
13296 	cmdline_fixed_string_t set;
13297 	cmdline_fixed_string_t vf;
13298 	cmdline_fixed_string_t vlan;
13299 	cmdline_fixed_string_t stripq;
13300 	portid_t port_id;
13301 	uint16_t vf_id;
13302 	cmdline_fixed_string_t on_off;
13303 };
13304 
13305 /* Common CLI fields for vf vlan strip enable disable */
13306 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
13307 	TOKEN_STRING_INITIALIZER
13308 		(struct cmd_vf_vlan_stripq_result,
13309 		 set, "set");
13310 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
13311 	TOKEN_STRING_INITIALIZER
13312 		(struct cmd_vf_vlan_stripq_result,
13313 		 vf, "vf");
13314 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
13315 	TOKEN_STRING_INITIALIZER
13316 		(struct cmd_vf_vlan_stripq_result,
13317 		 vlan, "vlan");
13318 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
13319 	TOKEN_STRING_INITIALIZER
13320 		(struct cmd_vf_vlan_stripq_result,
13321 		 stripq, "stripq");
13322 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
13323 	TOKEN_NUM_INITIALIZER
13324 		(struct cmd_vf_vlan_stripq_result,
13325 		 port_id, UINT16);
13326 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
13327 	TOKEN_NUM_INITIALIZER
13328 		(struct cmd_vf_vlan_stripq_result,
13329 		 vf_id, UINT16);
13330 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
13331 	TOKEN_STRING_INITIALIZER
13332 		(struct cmd_vf_vlan_stripq_result,
13333 		 on_off, "on#off");
13334 
13335 static void
13336 cmd_set_vf_vlan_stripq_parsed(
13337 	void *parsed_result,
13338 	__attribute__((unused)) struct cmdline *cl,
13339 	__attribute__((unused)) void *data)
13340 {
13341 	struct cmd_vf_vlan_stripq_result *res = parsed_result;
13342 	int ret = -ENOTSUP;
13343 
13344 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13345 
13346 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13347 		return;
13348 
13349 #ifdef RTE_LIBRTE_IXGBE_PMD
13350 	if (ret == -ENOTSUP)
13351 		ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
13352 			res->vf_id, is_on);
13353 #endif
13354 #ifdef RTE_LIBRTE_I40E_PMD
13355 	if (ret == -ENOTSUP)
13356 		ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
13357 			res->vf_id, is_on);
13358 #endif
13359 #ifdef RTE_LIBRTE_BNXT_PMD
13360 	if (ret == -ENOTSUP)
13361 		ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
13362 			res->vf_id, is_on);
13363 #endif
13364 
13365 	switch (ret) {
13366 	case 0:
13367 		break;
13368 	case -EINVAL:
13369 		printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13370 		break;
13371 	case -ENODEV:
13372 		printf("invalid port_id %d\n", res->port_id);
13373 		break;
13374 	case -ENOTSUP:
13375 		printf("function not implemented\n");
13376 		break;
13377 	default:
13378 		printf("programming error: (%s)\n", strerror(-ret));
13379 	}
13380 }
13381 
13382 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
13383 	.f = cmd_set_vf_vlan_stripq_parsed,
13384 	.data = NULL,
13385 	.help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
13386 	.tokens = {
13387 		(void *)&cmd_vf_vlan_stripq_set,
13388 		(void *)&cmd_vf_vlan_stripq_vf,
13389 		(void *)&cmd_vf_vlan_stripq_vlan,
13390 		(void *)&cmd_vf_vlan_stripq_stripq,
13391 		(void *)&cmd_vf_vlan_stripq_port_id,
13392 		(void *)&cmd_vf_vlan_stripq_vf_id,
13393 		(void *)&cmd_vf_vlan_stripq_on_off,
13394 		NULL,
13395 	},
13396 };
13397 
13398 /* vf vlan insert configuration */
13399 
13400 /* Common result structure for vf vlan insert */
13401 struct cmd_vf_vlan_insert_result {
13402 	cmdline_fixed_string_t set;
13403 	cmdline_fixed_string_t vf;
13404 	cmdline_fixed_string_t vlan;
13405 	cmdline_fixed_string_t insert;
13406 	portid_t port_id;
13407 	uint16_t vf_id;
13408 	uint16_t vlan_id;
13409 };
13410 
13411 /* Common CLI fields for vf vlan insert enable disable */
13412 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
13413 	TOKEN_STRING_INITIALIZER
13414 		(struct cmd_vf_vlan_insert_result,
13415 		 set, "set");
13416 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
13417 	TOKEN_STRING_INITIALIZER
13418 		(struct cmd_vf_vlan_insert_result,
13419 		 vf, "vf");
13420 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
13421 	TOKEN_STRING_INITIALIZER
13422 		(struct cmd_vf_vlan_insert_result,
13423 		 vlan, "vlan");
13424 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
13425 	TOKEN_STRING_INITIALIZER
13426 		(struct cmd_vf_vlan_insert_result,
13427 		 insert, "insert");
13428 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
13429 	TOKEN_NUM_INITIALIZER
13430 		(struct cmd_vf_vlan_insert_result,
13431 		 port_id, UINT16);
13432 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
13433 	TOKEN_NUM_INITIALIZER
13434 		(struct cmd_vf_vlan_insert_result,
13435 		 vf_id, UINT16);
13436 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
13437 	TOKEN_NUM_INITIALIZER
13438 		(struct cmd_vf_vlan_insert_result,
13439 		 vlan_id, UINT16);
13440 
13441 static void
13442 cmd_set_vf_vlan_insert_parsed(
13443 	void *parsed_result,
13444 	__attribute__((unused)) struct cmdline *cl,
13445 	__attribute__((unused)) void *data)
13446 {
13447 	struct cmd_vf_vlan_insert_result *res = parsed_result;
13448 	int ret = -ENOTSUP;
13449 
13450 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13451 		return;
13452 
13453 #ifdef RTE_LIBRTE_IXGBE_PMD
13454 	if (ret == -ENOTSUP)
13455 		ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
13456 			res->vlan_id);
13457 #endif
13458 #ifdef RTE_LIBRTE_I40E_PMD
13459 	if (ret == -ENOTSUP)
13460 		ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
13461 			res->vlan_id);
13462 #endif
13463 #ifdef RTE_LIBRTE_BNXT_PMD
13464 	if (ret == -ENOTSUP)
13465 		ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
13466 			res->vlan_id);
13467 #endif
13468 
13469 	switch (ret) {
13470 	case 0:
13471 		break;
13472 	case -EINVAL:
13473 		printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
13474 		break;
13475 	case -ENODEV:
13476 		printf("invalid port_id %d\n", res->port_id);
13477 		break;
13478 	case -ENOTSUP:
13479 		printf("function not implemented\n");
13480 		break;
13481 	default:
13482 		printf("programming error: (%s)\n", strerror(-ret));
13483 	}
13484 }
13485 
13486 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
13487 	.f = cmd_set_vf_vlan_insert_parsed,
13488 	.data = NULL,
13489 	.help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
13490 	.tokens = {
13491 		(void *)&cmd_vf_vlan_insert_set,
13492 		(void *)&cmd_vf_vlan_insert_vf,
13493 		(void *)&cmd_vf_vlan_insert_vlan,
13494 		(void *)&cmd_vf_vlan_insert_insert,
13495 		(void *)&cmd_vf_vlan_insert_port_id,
13496 		(void *)&cmd_vf_vlan_insert_vf_id,
13497 		(void *)&cmd_vf_vlan_insert_vlan_id,
13498 		NULL,
13499 	},
13500 };
13501 
13502 /* tx loopback configuration */
13503 
13504 /* Common result structure for tx loopback */
13505 struct cmd_tx_loopback_result {
13506 	cmdline_fixed_string_t set;
13507 	cmdline_fixed_string_t tx;
13508 	cmdline_fixed_string_t loopback;
13509 	portid_t port_id;
13510 	cmdline_fixed_string_t on_off;
13511 };
13512 
13513 /* Common CLI fields for tx loopback enable disable */
13514 cmdline_parse_token_string_t cmd_tx_loopback_set =
13515 	TOKEN_STRING_INITIALIZER
13516 		(struct cmd_tx_loopback_result,
13517 		 set, "set");
13518 cmdline_parse_token_string_t cmd_tx_loopback_tx =
13519 	TOKEN_STRING_INITIALIZER
13520 		(struct cmd_tx_loopback_result,
13521 		 tx, "tx");
13522 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
13523 	TOKEN_STRING_INITIALIZER
13524 		(struct cmd_tx_loopback_result,
13525 		 loopback, "loopback");
13526 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
13527 	TOKEN_NUM_INITIALIZER
13528 		(struct cmd_tx_loopback_result,
13529 		 port_id, UINT16);
13530 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
13531 	TOKEN_STRING_INITIALIZER
13532 		(struct cmd_tx_loopback_result,
13533 		 on_off, "on#off");
13534 
13535 static void
13536 cmd_set_tx_loopback_parsed(
13537 	void *parsed_result,
13538 	__attribute__((unused)) struct cmdline *cl,
13539 	__attribute__((unused)) void *data)
13540 {
13541 	struct cmd_tx_loopback_result *res = parsed_result;
13542 	int ret = -ENOTSUP;
13543 
13544 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13545 
13546 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13547 		return;
13548 
13549 #ifdef RTE_LIBRTE_IXGBE_PMD
13550 	if (ret == -ENOTSUP)
13551 		ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
13552 #endif
13553 #ifdef RTE_LIBRTE_I40E_PMD
13554 	if (ret == -ENOTSUP)
13555 		ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
13556 #endif
13557 #ifdef RTE_LIBRTE_BNXT_PMD
13558 	if (ret == -ENOTSUP)
13559 		ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
13560 #endif
13561 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD
13562 	if (ret == -ENOTSUP)
13563 		ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
13564 #endif
13565 
13566 	switch (ret) {
13567 	case 0:
13568 		break;
13569 	case -EINVAL:
13570 		printf("invalid is_on %d\n", is_on);
13571 		break;
13572 	case -ENODEV:
13573 		printf("invalid port_id %d\n", res->port_id);
13574 		break;
13575 	case -ENOTSUP:
13576 		printf("function not implemented\n");
13577 		break;
13578 	default:
13579 		printf("programming error: (%s)\n", strerror(-ret));
13580 	}
13581 }
13582 
13583 cmdline_parse_inst_t cmd_set_tx_loopback = {
13584 	.f = cmd_set_tx_loopback_parsed,
13585 	.data = NULL,
13586 	.help_str = "set tx loopback <port_id> on|off",
13587 	.tokens = {
13588 		(void *)&cmd_tx_loopback_set,
13589 		(void *)&cmd_tx_loopback_tx,
13590 		(void *)&cmd_tx_loopback_loopback,
13591 		(void *)&cmd_tx_loopback_port_id,
13592 		(void *)&cmd_tx_loopback_on_off,
13593 		NULL,
13594 	},
13595 };
13596 
13597 /* all queues drop enable configuration */
13598 
13599 /* Common result structure for all queues drop enable */
13600 struct cmd_all_queues_drop_en_result {
13601 	cmdline_fixed_string_t set;
13602 	cmdline_fixed_string_t all;
13603 	cmdline_fixed_string_t queues;
13604 	cmdline_fixed_string_t drop;
13605 	portid_t port_id;
13606 	cmdline_fixed_string_t on_off;
13607 };
13608 
13609 /* Common CLI fields for tx loopback enable disable */
13610 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
13611 	TOKEN_STRING_INITIALIZER
13612 		(struct cmd_all_queues_drop_en_result,
13613 		 set, "set");
13614 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
13615 	TOKEN_STRING_INITIALIZER
13616 		(struct cmd_all_queues_drop_en_result,
13617 		 all, "all");
13618 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
13619 	TOKEN_STRING_INITIALIZER
13620 		(struct cmd_all_queues_drop_en_result,
13621 		 queues, "queues");
13622 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
13623 	TOKEN_STRING_INITIALIZER
13624 		(struct cmd_all_queues_drop_en_result,
13625 		 drop, "drop");
13626 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
13627 	TOKEN_NUM_INITIALIZER
13628 		(struct cmd_all_queues_drop_en_result,
13629 		 port_id, UINT16);
13630 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
13631 	TOKEN_STRING_INITIALIZER
13632 		(struct cmd_all_queues_drop_en_result,
13633 		 on_off, "on#off");
13634 
13635 static void
13636 cmd_set_all_queues_drop_en_parsed(
13637 	void *parsed_result,
13638 	__attribute__((unused)) struct cmdline *cl,
13639 	__attribute__((unused)) void *data)
13640 {
13641 	struct cmd_all_queues_drop_en_result *res = parsed_result;
13642 	int ret = -ENOTSUP;
13643 	int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13644 
13645 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13646 		return;
13647 
13648 #ifdef RTE_LIBRTE_IXGBE_PMD
13649 	if (ret == -ENOTSUP)
13650 		ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
13651 #endif
13652 #ifdef RTE_LIBRTE_BNXT_PMD
13653 	if (ret == -ENOTSUP)
13654 		ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
13655 #endif
13656 	switch (ret) {
13657 	case 0:
13658 		break;
13659 	case -EINVAL:
13660 		printf("invalid is_on %d\n", is_on);
13661 		break;
13662 	case -ENODEV:
13663 		printf("invalid port_id %d\n", res->port_id);
13664 		break;
13665 	case -ENOTSUP:
13666 		printf("function not implemented\n");
13667 		break;
13668 	default:
13669 		printf("programming error: (%s)\n", strerror(-ret));
13670 	}
13671 }
13672 
13673 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
13674 	.f = cmd_set_all_queues_drop_en_parsed,
13675 	.data = NULL,
13676 	.help_str = "set all queues drop <port_id> on|off",
13677 	.tokens = {
13678 		(void *)&cmd_all_queues_drop_en_set,
13679 		(void *)&cmd_all_queues_drop_en_all,
13680 		(void *)&cmd_all_queues_drop_en_queues,
13681 		(void *)&cmd_all_queues_drop_en_drop,
13682 		(void *)&cmd_all_queues_drop_en_port_id,
13683 		(void *)&cmd_all_queues_drop_en_on_off,
13684 		NULL,
13685 	},
13686 };
13687 
13688 /* vf split drop enable configuration */
13689 
13690 /* Common result structure for vf split drop enable */
13691 struct cmd_vf_split_drop_en_result {
13692 	cmdline_fixed_string_t set;
13693 	cmdline_fixed_string_t vf;
13694 	cmdline_fixed_string_t split;
13695 	cmdline_fixed_string_t drop;
13696 	portid_t port_id;
13697 	uint16_t vf_id;
13698 	cmdline_fixed_string_t on_off;
13699 };
13700 
13701 /* Common CLI fields for vf split drop enable disable */
13702 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
13703 	TOKEN_STRING_INITIALIZER
13704 		(struct cmd_vf_split_drop_en_result,
13705 		 set, "set");
13706 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
13707 	TOKEN_STRING_INITIALIZER
13708 		(struct cmd_vf_split_drop_en_result,
13709 		 vf, "vf");
13710 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
13711 	TOKEN_STRING_INITIALIZER
13712 		(struct cmd_vf_split_drop_en_result,
13713 		 split, "split");
13714 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
13715 	TOKEN_STRING_INITIALIZER
13716 		(struct cmd_vf_split_drop_en_result,
13717 		 drop, "drop");
13718 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
13719 	TOKEN_NUM_INITIALIZER
13720 		(struct cmd_vf_split_drop_en_result,
13721 		 port_id, UINT16);
13722 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
13723 	TOKEN_NUM_INITIALIZER
13724 		(struct cmd_vf_split_drop_en_result,
13725 		 vf_id, UINT16);
13726 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
13727 	TOKEN_STRING_INITIALIZER
13728 		(struct cmd_vf_split_drop_en_result,
13729 		 on_off, "on#off");
13730 
13731 static void
13732 cmd_set_vf_split_drop_en_parsed(
13733 	void *parsed_result,
13734 	__attribute__((unused)) struct cmdline *cl,
13735 	__attribute__((unused)) void *data)
13736 {
13737 	struct cmd_vf_split_drop_en_result *res = parsed_result;
13738 	int ret = -ENOTSUP;
13739 	int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13740 
13741 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13742 		return;
13743 
13744 #ifdef RTE_LIBRTE_IXGBE_PMD
13745 	ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
13746 			is_on);
13747 #endif
13748 	switch (ret) {
13749 	case 0:
13750 		break;
13751 	case -EINVAL:
13752 		printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13753 		break;
13754 	case -ENODEV:
13755 		printf("invalid port_id %d\n", res->port_id);
13756 		break;
13757 	case -ENOTSUP:
13758 		printf("not supported on port %d\n", res->port_id);
13759 		break;
13760 	default:
13761 		printf("programming error: (%s)\n", strerror(-ret));
13762 	}
13763 }
13764 
13765 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
13766 	.f = cmd_set_vf_split_drop_en_parsed,
13767 	.data = NULL,
13768 	.help_str = "set vf split drop <port_id> <vf_id> on|off",
13769 	.tokens = {
13770 		(void *)&cmd_vf_split_drop_en_set,
13771 		(void *)&cmd_vf_split_drop_en_vf,
13772 		(void *)&cmd_vf_split_drop_en_split,
13773 		(void *)&cmd_vf_split_drop_en_drop,
13774 		(void *)&cmd_vf_split_drop_en_port_id,
13775 		(void *)&cmd_vf_split_drop_en_vf_id,
13776 		(void *)&cmd_vf_split_drop_en_on_off,
13777 		NULL,
13778 	},
13779 };
13780 
13781 /* vf mac address configuration */
13782 
13783 /* Common result structure for vf mac address */
13784 struct cmd_set_vf_mac_addr_result {
13785 	cmdline_fixed_string_t set;
13786 	cmdline_fixed_string_t vf;
13787 	cmdline_fixed_string_t mac;
13788 	cmdline_fixed_string_t addr;
13789 	portid_t port_id;
13790 	uint16_t vf_id;
13791 	struct ether_addr mac_addr;
13792 
13793 };
13794 
13795 /* Common CLI fields for vf split drop enable disable */
13796 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
13797 	TOKEN_STRING_INITIALIZER
13798 		(struct cmd_set_vf_mac_addr_result,
13799 		 set, "set");
13800 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
13801 	TOKEN_STRING_INITIALIZER
13802 		(struct cmd_set_vf_mac_addr_result,
13803 		 vf, "vf");
13804 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
13805 	TOKEN_STRING_INITIALIZER
13806 		(struct cmd_set_vf_mac_addr_result,
13807 		 mac, "mac");
13808 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
13809 	TOKEN_STRING_INITIALIZER
13810 		(struct cmd_set_vf_mac_addr_result,
13811 		 addr, "addr");
13812 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
13813 	TOKEN_NUM_INITIALIZER
13814 		(struct cmd_set_vf_mac_addr_result,
13815 		 port_id, UINT16);
13816 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
13817 	TOKEN_NUM_INITIALIZER
13818 		(struct cmd_set_vf_mac_addr_result,
13819 		 vf_id, UINT16);
13820 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
13821 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
13822 		 mac_addr);
13823 
13824 static void
13825 cmd_set_vf_mac_addr_parsed(
13826 	void *parsed_result,
13827 	__attribute__((unused)) struct cmdline *cl,
13828 	__attribute__((unused)) void *data)
13829 {
13830 	struct cmd_set_vf_mac_addr_result *res = parsed_result;
13831 	int ret = -ENOTSUP;
13832 
13833 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13834 		return;
13835 
13836 #ifdef RTE_LIBRTE_IXGBE_PMD
13837 	if (ret == -ENOTSUP)
13838 		ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
13839 				&res->mac_addr);
13840 #endif
13841 #ifdef RTE_LIBRTE_I40E_PMD
13842 	if (ret == -ENOTSUP)
13843 		ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
13844 				&res->mac_addr);
13845 #endif
13846 #ifdef RTE_LIBRTE_BNXT_PMD
13847 	if (ret == -ENOTSUP)
13848 		ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
13849 				&res->mac_addr);
13850 #endif
13851 
13852 	switch (ret) {
13853 	case 0:
13854 		break;
13855 	case -EINVAL:
13856 		printf("invalid vf_id %d or mac_addr\n", res->vf_id);
13857 		break;
13858 	case -ENODEV:
13859 		printf("invalid port_id %d\n", res->port_id);
13860 		break;
13861 	case -ENOTSUP:
13862 		printf("function not implemented\n");
13863 		break;
13864 	default:
13865 		printf("programming error: (%s)\n", strerror(-ret));
13866 	}
13867 }
13868 
13869 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
13870 	.f = cmd_set_vf_mac_addr_parsed,
13871 	.data = NULL,
13872 	.help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
13873 	.tokens = {
13874 		(void *)&cmd_set_vf_mac_addr_set,
13875 		(void *)&cmd_set_vf_mac_addr_vf,
13876 		(void *)&cmd_set_vf_mac_addr_mac,
13877 		(void *)&cmd_set_vf_mac_addr_addr,
13878 		(void *)&cmd_set_vf_mac_addr_port_id,
13879 		(void *)&cmd_set_vf_mac_addr_vf_id,
13880 		(void *)&cmd_set_vf_mac_addr_mac_addr,
13881 		NULL,
13882 	},
13883 };
13884 
13885 /* MACsec configuration */
13886 
13887 /* Common result structure for MACsec offload enable */
13888 struct cmd_macsec_offload_on_result {
13889 	cmdline_fixed_string_t set;
13890 	cmdline_fixed_string_t macsec;
13891 	cmdline_fixed_string_t offload;
13892 	portid_t port_id;
13893 	cmdline_fixed_string_t on;
13894 	cmdline_fixed_string_t encrypt;
13895 	cmdline_fixed_string_t en_on_off;
13896 	cmdline_fixed_string_t replay_protect;
13897 	cmdline_fixed_string_t rp_on_off;
13898 };
13899 
13900 /* Common CLI fields for MACsec offload disable */
13901 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
13902 	TOKEN_STRING_INITIALIZER
13903 		(struct cmd_macsec_offload_on_result,
13904 		 set, "set");
13905 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
13906 	TOKEN_STRING_INITIALIZER
13907 		(struct cmd_macsec_offload_on_result,
13908 		 macsec, "macsec");
13909 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
13910 	TOKEN_STRING_INITIALIZER
13911 		(struct cmd_macsec_offload_on_result,
13912 		 offload, "offload");
13913 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
13914 	TOKEN_NUM_INITIALIZER
13915 		(struct cmd_macsec_offload_on_result,
13916 		 port_id, UINT16);
13917 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
13918 	TOKEN_STRING_INITIALIZER
13919 		(struct cmd_macsec_offload_on_result,
13920 		 on, "on");
13921 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
13922 	TOKEN_STRING_INITIALIZER
13923 		(struct cmd_macsec_offload_on_result,
13924 		 encrypt, "encrypt");
13925 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
13926 	TOKEN_STRING_INITIALIZER
13927 		(struct cmd_macsec_offload_on_result,
13928 		 en_on_off, "on#off");
13929 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
13930 	TOKEN_STRING_INITIALIZER
13931 		(struct cmd_macsec_offload_on_result,
13932 		 replay_protect, "replay-protect");
13933 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
13934 	TOKEN_STRING_INITIALIZER
13935 		(struct cmd_macsec_offload_on_result,
13936 		 rp_on_off, "on#off");
13937 
13938 static void
13939 cmd_set_macsec_offload_on_parsed(
13940 	void *parsed_result,
13941 	__attribute__((unused)) struct cmdline *cl,
13942 	__attribute__((unused)) void *data)
13943 {
13944 	struct cmd_macsec_offload_on_result *res = parsed_result;
13945 	int ret = -ENOTSUP;
13946 	portid_t port_id = res->port_id;
13947 	int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
13948 	int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
13949 	struct rte_eth_dev_info dev_info;
13950 
13951 	if (port_id_is_invalid(port_id, ENABLED_WARN))
13952 		return;
13953 	if (!port_is_stopped(port_id)) {
13954 		printf("Please stop port %d first\n", port_id);
13955 		return;
13956 	}
13957 
13958 	rte_eth_dev_info_get(port_id, &dev_info);
13959 	if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
13960 #ifdef RTE_LIBRTE_IXGBE_PMD
13961 		ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
13962 #endif
13963 	}
13964 	RTE_SET_USED(en);
13965 	RTE_SET_USED(rp);
13966 
13967 	switch (ret) {
13968 	case 0:
13969 		ports[port_id].dev_conf.txmode.offloads |=
13970 						DEV_TX_OFFLOAD_MACSEC_INSERT;
13971 		cmd_reconfig_device_queue(port_id, 1, 1);
13972 		break;
13973 	case -ENODEV:
13974 		printf("invalid port_id %d\n", port_id);
13975 		break;
13976 	case -ENOTSUP:
13977 		printf("not supported on port %d\n", port_id);
13978 		break;
13979 	default:
13980 		printf("programming error: (%s)\n", strerror(-ret));
13981 	}
13982 }
13983 
13984 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
13985 	.f = cmd_set_macsec_offload_on_parsed,
13986 	.data = NULL,
13987 	.help_str = "set macsec offload <port_id> on "
13988 		"encrypt on|off replay-protect on|off",
13989 	.tokens = {
13990 		(void *)&cmd_macsec_offload_on_set,
13991 		(void *)&cmd_macsec_offload_on_macsec,
13992 		(void *)&cmd_macsec_offload_on_offload,
13993 		(void *)&cmd_macsec_offload_on_port_id,
13994 		(void *)&cmd_macsec_offload_on_on,
13995 		(void *)&cmd_macsec_offload_on_encrypt,
13996 		(void *)&cmd_macsec_offload_on_en_on_off,
13997 		(void *)&cmd_macsec_offload_on_replay_protect,
13998 		(void *)&cmd_macsec_offload_on_rp_on_off,
13999 		NULL,
14000 	},
14001 };
14002 
14003 /* Common result structure for MACsec offload disable */
14004 struct cmd_macsec_offload_off_result {
14005 	cmdline_fixed_string_t set;
14006 	cmdline_fixed_string_t macsec;
14007 	cmdline_fixed_string_t offload;
14008 	portid_t port_id;
14009 	cmdline_fixed_string_t off;
14010 };
14011 
14012 /* Common CLI fields for MACsec offload disable */
14013 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
14014 	TOKEN_STRING_INITIALIZER
14015 		(struct cmd_macsec_offload_off_result,
14016 		 set, "set");
14017 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
14018 	TOKEN_STRING_INITIALIZER
14019 		(struct cmd_macsec_offload_off_result,
14020 		 macsec, "macsec");
14021 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
14022 	TOKEN_STRING_INITIALIZER
14023 		(struct cmd_macsec_offload_off_result,
14024 		 offload, "offload");
14025 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
14026 	TOKEN_NUM_INITIALIZER
14027 		(struct cmd_macsec_offload_off_result,
14028 		 port_id, UINT16);
14029 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
14030 	TOKEN_STRING_INITIALIZER
14031 		(struct cmd_macsec_offload_off_result,
14032 		 off, "off");
14033 
14034 static void
14035 cmd_set_macsec_offload_off_parsed(
14036 	void *parsed_result,
14037 	__attribute__((unused)) struct cmdline *cl,
14038 	__attribute__((unused)) void *data)
14039 {
14040 	struct cmd_macsec_offload_off_result *res = parsed_result;
14041 	int ret = -ENOTSUP;
14042 	struct rte_eth_dev_info dev_info;
14043 	portid_t port_id = res->port_id;
14044 
14045 	if (port_id_is_invalid(port_id, ENABLED_WARN))
14046 		return;
14047 	if (!port_is_stopped(port_id)) {
14048 		printf("Please stop port %d first\n", port_id);
14049 		return;
14050 	}
14051 
14052 	rte_eth_dev_info_get(port_id, &dev_info);
14053 	if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
14054 #ifdef RTE_LIBRTE_IXGBE_PMD
14055 		ret = rte_pmd_ixgbe_macsec_disable(port_id);
14056 #endif
14057 	}
14058 	switch (ret) {
14059 	case 0:
14060 		ports[port_id].dev_conf.txmode.offloads &=
14061 						~DEV_TX_OFFLOAD_MACSEC_INSERT;
14062 		cmd_reconfig_device_queue(port_id, 1, 1);
14063 		break;
14064 	case -ENODEV:
14065 		printf("invalid port_id %d\n", port_id);
14066 		break;
14067 	case -ENOTSUP:
14068 		printf("not supported on port %d\n", port_id);
14069 		break;
14070 	default:
14071 		printf("programming error: (%s)\n", strerror(-ret));
14072 	}
14073 }
14074 
14075 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
14076 	.f = cmd_set_macsec_offload_off_parsed,
14077 	.data = NULL,
14078 	.help_str = "set macsec offload <port_id> off",
14079 	.tokens = {
14080 		(void *)&cmd_macsec_offload_off_set,
14081 		(void *)&cmd_macsec_offload_off_macsec,
14082 		(void *)&cmd_macsec_offload_off_offload,
14083 		(void *)&cmd_macsec_offload_off_port_id,
14084 		(void *)&cmd_macsec_offload_off_off,
14085 		NULL,
14086 	},
14087 };
14088 
14089 /* Common result structure for MACsec secure connection configure */
14090 struct cmd_macsec_sc_result {
14091 	cmdline_fixed_string_t set;
14092 	cmdline_fixed_string_t macsec;
14093 	cmdline_fixed_string_t sc;
14094 	cmdline_fixed_string_t tx_rx;
14095 	portid_t port_id;
14096 	struct ether_addr mac;
14097 	uint16_t pi;
14098 };
14099 
14100 /* Common CLI fields for MACsec secure connection configure */
14101 cmdline_parse_token_string_t cmd_macsec_sc_set =
14102 	TOKEN_STRING_INITIALIZER
14103 		(struct cmd_macsec_sc_result,
14104 		 set, "set");
14105 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
14106 	TOKEN_STRING_INITIALIZER
14107 		(struct cmd_macsec_sc_result,
14108 		 macsec, "macsec");
14109 cmdline_parse_token_string_t cmd_macsec_sc_sc =
14110 	TOKEN_STRING_INITIALIZER
14111 		(struct cmd_macsec_sc_result,
14112 		 sc, "sc");
14113 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
14114 	TOKEN_STRING_INITIALIZER
14115 		(struct cmd_macsec_sc_result,
14116 		 tx_rx, "tx#rx");
14117 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
14118 	TOKEN_NUM_INITIALIZER
14119 		(struct cmd_macsec_sc_result,
14120 		 port_id, UINT16);
14121 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
14122 	TOKEN_ETHERADDR_INITIALIZER
14123 		(struct cmd_macsec_sc_result,
14124 		 mac);
14125 cmdline_parse_token_num_t cmd_macsec_sc_pi =
14126 	TOKEN_NUM_INITIALIZER
14127 		(struct cmd_macsec_sc_result,
14128 		 pi, UINT16);
14129 
14130 static void
14131 cmd_set_macsec_sc_parsed(
14132 	void *parsed_result,
14133 	__attribute__((unused)) struct cmdline *cl,
14134 	__attribute__((unused)) void *data)
14135 {
14136 	struct cmd_macsec_sc_result *res = parsed_result;
14137 	int ret = -ENOTSUP;
14138 	int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14139 
14140 #ifdef RTE_LIBRTE_IXGBE_PMD
14141 	ret = is_tx ?
14142 		rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
14143 				res->mac.addr_bytes) :
14144 		rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
14145 				res->mac.addr_bytes, res->pi);
14146 #endif
14147 	RTE_SET_USED(is_tx);
14148 
14149 	switch (ret) {
14150 	case 0:
14151 		break;
14152 	case -ENODEV:
14153 		printf("invalid port_id %d\n", res->port_id);
14154 		break;
14155 	case -ENOTSUP:
14156 		printf("not supported on port %d\n", res->port_id);
14157 		break;
14158 	default:
14159 		printf("programming error: (%s)\n", strerror(-ret));
14160 	}
14161 }
14162 
14163 cmdline_parse_inst_t cmd_set_macsec_sc = {
14164 	.f = cmd_set_macsec_sc_parsed,
14165 	.data = NULL,
14166 	.help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
14167 	.tokens = {
14168 		(void *)&cmd_macsec_sc_set,
14169 		(void *)&cmd_macsec_sc_macsec,
14170 		(void *)&cmd_macsec_sc_sc,
14171 		(void *)&cmd_macsec_sc_tx_rx,
14172 		(void *)&cmd_macsec_sc_port_id,
14173 		(void *)&cmd_macsec_sc_mac,
14174 		(void *)&cmd_macsec_sc_pi,
14175 		NULL,
14176 	},
14177 };
14178 
14179 /* Common result structure for MACsec secure connection configure */
14180 struct cmd_macsec_sa_result {
14181 	cmdline_fixed_string_t set;
14182 	cmdline_fixed_string_t macsec;
14183 	cmdline_fixed_string_t sa;
14184 	cmdline_fixed_string_t tx_rx;
14185 	portid_t port_id;
14186 	uint8_t idx;
14187 	uint8_t an;
14188 	uint32_t pn;
14189 	cmdline_fixed_string_t key;
14190 };
14191 
14192 /* Common CLI fields for MACsec secure connection configure */
14193 cmdline_parse_token_string_t cmd_macsec_sa_set =
14194 	TOKEN_STRING_INITIALIZER
14195 		(struct cmd_macsec_sa_result,
14196 		 set, "set");
14197 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
14198 	TOKEN_STRING_INITIALIZER
14199 		(struct cmd_macsec_sa_result,
14200 		 macsec, "macsec");
14201 cmdline_parse_token_string_t cmd_macsec_sa_sa =
14202 	TOKEN_STRING_INITIALIZER
14203 		(struct cmd_macsec_sa_result,
14204 		 sa, "sa");
14205 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
14206 	TOKEN_STRING_INITIALIZER
14207 		(struct cmd_macsec_sa_result,
14208 		 tx_rx, "tx#rx");
14209 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
14210 	TOKEN_NUM_INITIALIZER
14211 		(struct cmd_macsec_sa_result,
14212 		 port_id, UINT16);
14213 cmdline_parse_token_num_t cmd_macsec_sa_idx =
14214 	TOKEN_NUM_INITIALIZER
14215 		(struct cmd_macsec_sa_result,
14216 		 idx, UINT8);
14217 cmdline_parse_token_num_t cmd_macsec_sa_an =
14218 	TOKEN_NUM_INITIALIZER
14219 		(struct cmd_macsec_sa_result,
14220 		 an, UINT8);
14221 cmdline_parse_token_num_t cmd_macsec_sa_pn =
14222 	TOKEN_NUM_INITIALIZER
14223 		(struct cmd_macsec_sa_result,
14224 		 pn, UINT32);
14225 cmdline_parse_token_string_t cmd_macsec_sa_key =
14226 	TOKEN_STRING_INITIALIZER
14227 		(struct cmd_macsec_sa_result,
14228 		 key, NULL);
14229 
14230 static void
14231 cmd_set_macsec_sa_parsed(
14232 	void *parsed_result,
14233 	__attribute__((unused)) struct cmdline *cl,
14234 	__attribute__((unused)) void *data)
14235 {
14236 	struct cmd_macsec_sa_result *res = parsed_result;
14237 	int ret = -ENOTSUP;
14238 	int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14239 	uint8_t key[16] = { 0 };
14240 	uint8_t xdgt0;
14241 	uint8_t xdgt1;
14242 	int key_len;
14243 	int i;
14244 
14245 	key_len = strlen(res->key) / 2;
14246 	if (key_len > 16)
14247 		key_len = 16;
14248 
14249 	for (i = 0; i < key_len; i++) {
14250 		xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
14251 		if (xdgt0 == 0xFF)
14252 			return;
14253 		xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
14254 		if (xdgt1 == 0xFF)
14255 			return;
14256 		key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
14257 	}
14258 
14259 #ifdef RTE_LIBRTE_IXGBE_PMD
14260 	ret = is_tx ?
14261 		rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
14262 			res->idx, res->an, res->pn, key) :
14263 		rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
14264 			res->idx, res->an, res->pn, key);
14265 #endif
14266 	RTE_SET_USED(is_tx);
14267 	RTE_SET_USED(key);
14268 
14269 	switch (ret) {
14270 	case 0:
14271 		break;
14272 	case -EINVAL:
14273 		printf("invalid idx %d or an %d\n", res->idx, res->an);
14274 		break;
14275 	case -ENODEV:
14276 		printf("invalid port_id %d\n", res->port_id);
14277 		break;
14278 	case -ENOTSUP:
14279 		printf("not supported on port %d\n", res->port_id);
14280 		break;
14281 	default:
14282 		printf("programming error: (%s)\n", strerror(-ret));
14283 	}
14284 }
14285 
14286 cmdline_parse_inst_t cmd_set_macsec_sa = {
14287 	.f = cmd_set_macsec_sa_parsed,
14288 	.data = NULL,
14289 	.help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
14290 	.tokens = {
14291 		(void *)&cmd_macsec_sa_set,
14292 		(void *)&cmd_macsec_sa_macsec,
14293 		(void *)&cmd_macsec_sa_sa,
14294 		(void *)&cmd_macsec_sa_tx_rx,
14295 		(void *)&cmd_macsec_sa_port_id,
14296 		(void *)&cmd_macsec_sa_idx,
14297 		(void *)&cmd_macsec_sa_an,
14298 		(void *)&cmd_macsec_sa_pn,
14299 		(void *)&cmd_macsec_sa_key,
14300 		NULL,
14301 	},
14302 };
14303 
14304 /* VF unicast promiscuous mode configuration */
14305 
14306 /* Common result structure for VF unicast promiscuous mode */
14307 struct cmd_vf_promisc_result {
14308 	cmdline_fixed_string_t set;
14309 	cmdline_fixed_string_t vf;
14310 	cmdline_fixed_string_t promisc;
14311 	portid_t port_id;
14312 	uint32_t vf_id;
14313 	cmdline_fixed_string_t on_off;
14314 };
14315 
14316 /* Common CLI fields for VF unicast promiscuous mode enable disable */
14317 cmdline_parse_token_string_t cmd_vf_promisc_set =
14318 	TOKEN_STRING_INITIALIZER
14319 		(struct cmd_vf_promisc_result,
14320 		 set, "set");
14321 cmdline_parse_token_string_t cmd_vf_promisc_vf =
14322 	TOKEN_STRING_INITIALIZER
14323 		(struct cmd_vf_promisc_result,
14324 		 vf, "vf");
14325 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
14326 	TOKEN_STRING_INITIALIZER
14327 		(struct cmd_vf_promisc_result,
14328 		 promisc, "promisc");
14329 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
14330 	TOKEN_NUM_INITIALIZER
14331 		(struct cmd_vf_promisc_result,
14332 		 port_id, UINT16);
14333 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
14334 	TOKEN_NUM_INITIALIZER
14335 		(struct cmd_vf_promisc_result,
14336 		 vf_id, UINT32);
14337 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
14338 	TOKEN_STRING_INITIALIZER
14339 		(struct cmd_vf_promisc_result,
14340 		 on_off, "on#off");
14341 
14342 static void
14343 cmd_set_vf_promisc_parsed(
14344 	void *parsed_result,
14345 	__attribute__((unused)) struct cmdline *cl,
14346 	__attribute__((unused)) void *data)
14347 {
14348 	struct cmd_vf_promisc_result *res = parsed_result;
14349 	int ret = -ENOTSUP;
14350 
14351 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14352 
14353 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14354 		return;
14355 
14356 #ifdef RTE_LIBRTE_I40E_PMD
14357 	ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
14358 						  res->vf_id, is_on);
14359 #endif
14360 
14361 	switch (ret) {
14362 	case 0:
14363 		break;
14364 	case -EINVAL:
14365 		printf("invalid vf_id %d\n", res->vf_id);
14366 		break;
14367 	case -ENODEV:
14368 		printf("invalid port_id %d\n", res->port_id);
14369 		break;
14370 	case -ENOTSUP:
14371 		printf("function not implemented\n");
14372 		break;
14373 	default:
14374 		printf("programming error: (%s)\n", strerror(-ret));
14375 	}
14376 }
14377 
14378 cmdline_parse_inst_t cmd_set_vf_promisc = {
14379 	.f = cmd_set_vf_promisc_parsed,
14380 	.data = NULL,
14381 	.help_str = "set vf promisc <port_id> <vf_id> on|off: "
14382 		"Set unicast promiscuous mode for a VF from the PF",
14383 	.tokens = {
14384 		(void *)&cmd_vf_promisc_set,
14385 		(void *)&cmd_vf_promisc_vf,
14386 		(void *)&cmd_vf_promisc_promisc,
14387 		(void *)&cmd_vf_promisc_port_id,
14388 		(void *)&cmd_vf_promisc_vf_id,
14389 		(void *)&cmd_vf_promisc_on_off,
14390 		NULL,
14391 	},
14392 };
14393 
14394 /* VF multicast promiscuous mode configuration */
14395 
14396 /* Common result structure for VF multicast promiscuous mode */
14397 struct cmd_vf_allmulti_result {
14398 	cmdline_fixed_string_t set;
14399 	cmdline_fixed_string_t vf;
14400 	cmdline_fixed_string_t allmulti;
14401 	portid_t port_id;
14402 	uint32_t vf_id;
14403 	cmdline_fixed_string_t on_off;
14404 };
14405 
14406 /* Common CLI fields for VF multicast promiscuous mode enable disable */
14407 cmdline_parse_token_string_t cmd_vf_allmulti_set =
14408 	TOKEN_STRING_INITIALIZER
14409 		(struct cmd_vf_allmulti_result,
14410 		 set, "set");
14411 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
14412 	TOKEN_STRING_INITIALIZER
14413 		(struct cmd_vf_allmulti_result,
14414 		 vf, "vf");
14415 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
14416 	TOKEN_STRING_INITIALIZER
14417 		(struct cmd_vf_allmulti_result,
14418 		 allmulti, "allmulti");
14419 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
14420 	TOKEN_NUM_INITIALIZER
14421 		(struct cmd_vf_allmulti_result,
14422 		 port_id, UINT16);
14423 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
14424 	TOKEN_NUM_INITIALIZER
14425 		(struct cmd_vf_allmulti_result,
14426 		 vf_id, UINT32);
14427 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
14428 	TOKEN_STRING_INITIALIZER
14429 		(struct cmd_vf_allmulti_result,
14430 		 on_off, "on#off");
14431 
14432 static void
14433 cmd_set_vf_allmulti_parsed(
14434 	void *parsed_result,
14435 	__attribute__((unused)) struct cmdline *cl,
14436 	__attribute__((unused)) void *data)
14437 {
14438 	struct cmd_vf_allmulti_result *res = parsed_result;
14439 	int ret = -ENOTSUP;
14440 
14441 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14442 
14443 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14444 		return;
14445 
14446 #ifdef RTE_LIBRTE_I40E_PMD
14447 	ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
14448 						    res->vf_id, is_on);
14449 #endif
14450 
14451 	switch (ret) {
14452 	case 0:
14453 		break;
14454 	case -EINVAL:
14455 		printf("invalid vf_id %d\n", res->vf_id);
14456 		break;
14457 	case -ENODEV:
14458 		printf("invalid port_id %d\n", res->port_id);
14459 		break;
14460 	case -ENOTSUP:
14461 		printf("function not implemented\n");
14462 		break;
14463 	default:
14464 		printf("programming error: (%s)\n", strerror(-ret));
14465 	}
14466 }
14467 
14468 cmdline_parse_inst_t cmd_set_vf_allmulti = {
14469 	.f = cmd_set_vf_allmulti_parsed,
14470 	.data = NULL,
14471 	.help_str = "set vf allmulti <port_id> <vf_id> on|off: "
14472 		"Set multicast promiscuous mode for a VF from the PF",
14473 	.tokens = {
14474 		(void *)&cmd_vf_allmulti_set,
14475 		(void *)&cmd_vf_allmulti_vf,
14476 		(void *)&cmd_vf_allmulti_allmulti,
14477 		(void *)&cmd_vf_allmulti_port_id,
14478 		(void *)&cmd_vf_allmulti_vf_id,
14479 		(void *)&cmd_vf_allmulti_on_off,
14480 		NULL,
14481 	},
14482 };
14483 
14484 /* vf broadcast mode configuration */
14485 
14486 /* Common result structure for vf broadcast */
14487 struct cmd_set_vf_broadcast_result {
14488 	cmdline_fixed_string_t set;
14489 	cmdline_fixed_string_t vf;
14490 	cmdline_fixed_string_t broadcast;
14491 	portid_t port_id;
14492 	uint16_t vf_id;
14493 	cmdline_fixed_string_t on_off;
14494 };
14495 
14496 /* Common CLI fields for vf broadcast enable disable */
14497 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
14498 	TOKEN_STRING_INITIALIZER
14499 		(struct cmd_set_vf_broadcast_result,
14500 		 set, "set");
14501 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
14502 	TOKEN_STRING_INITIALIZER
14503 		(struct cmd_set_vf_broadcast_result,
14504 		 vf, "vf");
14505 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
14506 	TOKEN_STRING_INITIALIZER
14507 		(struct cmd_set_vf_broadcast_result,
14508 		 broadcast, "broadcast");
14509 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
14510 	TOKEN_NUM_INITIALIZER
14511 		(struct cmd_set_vf_broadcast_result,
14512 		 port_id, UINT16);
14513 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
14514 	TOKEN_NUM_INITIALIZER
14515 		(struct cmd_set_vf_broadcast_result,
14516 		 vf_id, UINT16);
14517 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
14518 	TOKEN_STRING_INITIALIZER
14519 		(struct cmd_set_vf_broadcast_result,
14520 		 on_off, "on#off");
14521 
14522 static void
14523 cmd_set_vf_broadcast_parsed(
14524 	void *parsed_result,
14525 	__attribute__((unused)) struct cmdline *cl,
14526 	__attribute__((unused)) void *data)
14527 {
14528 	struct cmd_set_vf_broadcast_result *res = parsed_result;
14529 	int ret = -ENOTSUP;
14530 
14531 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14532 
14533 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14534 		return;
14535 
14536 #ifdef RTE_LIBRTE_I40E_PMD
14537 	ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
14538 					    res->vf_id, is_on);
14539 #endif
14540 
14541 	switch (ret) {
14542 	case 0:
14543 		break;
14544 	case -EINVAL:
14545 		printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14546 		break;
14547 	case -ENODEV:
14548 		printf("invalid port_id %d\n", res->port_id);
14549 		break;
14550 	case -ENOTSUP:
14551 		printf("function not implemented\n");
14552 		break;
14553 	default:
14554 		printf("programming error: (%s)\n", strerror(-ret));
14555 	}
14556 }
14557 
14558 cmdline_parse_inst_t cmd_set_vf_broadcast = {
14559 	.f = cmd_set_vf_broadcast_parsed,
14560 	.data = NULL,
14561 	.help_str = "set vf broadcast <port_id> <vf_id> on|off",
14562 	.tokens = {
14563 		(void *)&cmd_set_vf_broadcast_set,
14564 		(void *)&cmd_set_vf_broadcast_vf,
14565 		(void *)&cmd_set_vf_broadcast_broadcast,
14566 		(void *)&cmd_set_vf_broadcast_port_id,
14567 		(void *)&cmd_set_vf_broadcast_vf_id,
14568 		(void *)&cmd_set_vf_broadcast_on_off,
14569 		NULL,
14570 	},
14571 };
14572 
14573 /* vf vlan tag configuration */
14574 
14575 /* Common result structure for vf vlan tag */
14576 struct cmd_set_vf_vlan_tag_result {
14577 	cmdline_fixed_string_t set;
14578 	cmdline_fixed_string_t vf;
14579 	cmdline_fixed_string_t vlan;
14580 	cmdline_fixed_string_t tag;
14581 	portid_t port_id;
14582 	uint16_t vf_id;
14583 	cmdline_fixed_string_t on_off;
14584 };
14585 
14586 /* Common CLI fields for vf vlan tag enable disable */
14587 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
14588 	TOKEN_STRING_INITIALIZER
14589 		(struct cmd_set_vf_vlan_tag_result,
14590 		 set, "set");
14591 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
14592 	TOKEN_STRING_INITIALIZER
14593 		(struct cmd_set_vf_vlan_tag_result,
14594 		 vf, "vf");
14595 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
14596 	TOKEN_STRING_INITIALIZER
14597 		(struct cmd_set_vf_vlan_tag_result,
14598 		 vlan, "vlan");
14599 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
14600 	TOKEN_STRING_INITIALIZER
14601 		(struct cmd_set_vf_vlan_tag_result,
14602 		 tag, "tag");
14603 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
14604 	TOKEN_NUM_INITIALIZER
14605 		(struct cmd_set_vf_vlan_tag_result,
14606 		 port_id, UINT16);
14607 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
14608 	TOKEN_NUM_INITIALIZER
14609 		(struct cmd_set_vf_vlan_tag_result,
14610 		 vf_id, UINT16);
14611 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
14612 	TOKEN_STRING_INITIALIZER
14613 		(struct cmd_set_vf_vlan_tag_result,
14614 		 on_off, "on#off");
14615 
14616 static void
14617 cmd_set_vf_vlan_tag_parsed(
14618 	void *parsed_result,
14619 	__attribute__((unused)) struct cmdline *cl,
14620 	__attribute__((unused)) void *data)
14621 {
14622 	struct cmd_set_vf_vlan_tag_result *res = parsed_result;
14623 	int ret = -ENOTSUP;
14624 
14625 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14626 
14627 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14628 		return;
14629 
14630 #ifdef RTE_LIBRTE_I40E_PMD
14631 	ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
14632 					   res->vf_id, is_on);
14633 #endif
14634 
14635 	switch (ret) {
14636 	case 0:
14637 		break;
14638 	case -EINVAL:
14639 		printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14640 		break;
14641 	case -ENODEV:
14642 		printf("invalid port_id %d\n", res->port_id);
14643 		break;
14644 	case -ENOTSUP:
14645 		printf("function not implemented\n");
14646 		break;
14647 	default:
14648 		printf("programming error: (%s)\n", strerror(-ret));
14649 	}
14650 }
14651 
14652 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
14653 	.f = cmd_set_vf_vlan_tag_parsed,
14654 	.data = NULL,
14655 	.help_str = "set vf vlan tag <port_id> <vf_id> on|off",
14656 	.tokens = {
14657 		(void *)&cmd_set_vf_vlan_tag_set,
14658 		(void *)&cmd_set_vf_vlan_tag_vf,
14659 		(void *)&cmd_set_vf_vlan_tag_vlan,
14660 		(void *)&cmd_set_vf_vlan_tag_tag,
14661 		(void *)&cmd_set_vf_vlan_tag_port_id,
14662 		(void *)&cmd_set_vf_vlan_tag_vf_id,
14663 		(void *)&cmd_set_vf_vlan_tag_on_off,
14664 		NULL,
14665 	},
14666 };
14667 
14668 /* Common definition of VF and TC TX bandwidth configuration */
14669 struct cmd_vf_tc_bw_result {
14670 	cmdline_fixed_string_t set;
14671 	cmdline_fixed_string_t vf;
14672 	cmdline_fixed_string_t tc;
14673 	cmdline_fixed_string_t tx;
14674 	cmdline_fixed_string_t min_bw;
14675 	cmdline_fixed_string_t max_bw;
14676 	cmdline_fixed_string_t strict_link_prio;
14677 	portid_t port_id;
14678 	uint16_t vf_id;
14679 	uint8_t tc_no;
14680 	uint32_t bw;
14681 	cmdline_fixed_string_t bw_list;
14682 	uint8_t tc_map;
14683 };
14684 
14685 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
14686 	TOKEN_STRING_INITIALIZER
14687 		(struct cmd_vf_tc_bw_result,
14688 		 set, "set");
14689 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
14690 	TOKEN_STRING_INITIALIZER
14691 		(struct cmd_vf_tc_bw_result,
14692 		 vf, "vf");
14693 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
14694 	TOKEN_STRING_INITIALIZER
14695 		(struct cmd_vf_tc_bw_result,
14696 		 tc, "tc");
14697 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
14698 	TOKEN_STRING_INITIALIZER
14699 		(struct cmd_vf_tc_bw_result,
14700 		 tx, "tx");
14701 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
14702 	TOKEN_STRING_INITIALIZER
14703 		(struct cmd_vf_tc_bw_result,
14704 		 strict_link_prio, "strict-link-priority");
14705 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
14706 	TOKEN_STRING_INITIALIZER
14707 		(struct cmd_vf_tc_bw_result,
14708 		 min_bw, "min-bandwidth");
14709 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
14710 	TOKEN_STRING_INITIALIZER
14711 		(struct cmd_vf_tc_bw_result,
14712 		 max_bw, "max-bandwidth");
14713 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
14714 	TOKEN_NUM_INITIALIZER
14715 		(struct cmd_vf_tc_bw_result,
14716 		 port_id, UINT16);
14717 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
14718 	TOKEN_NUM_INITIALIZER
14719 		(struct cmd_vf_tc_bw_result,
14720 		 vf_id, UINT16);
14721 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
14722 	TOKEN_NUM_INITIALIZER
14723 		(struct cmd_vf_tc_bw_result,
14724 		 tc_no, UINT8);
14725 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
14726 	TOKEN_NUM_INITIALIZER
14727 		(struct cmd_vf_tc_bw_result,
14728 		 bw, UINT32);
14729 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
14730 	TOKEN_STRING_INITIALIZER
14731 		(struct cmd_vf_tc_bw_result,
14732 		 bw_list, NULL);
14733 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
14734 	TOKEN_NUM_INITIALIZER
14735 		(struct cmd_vf_tc_bw_result,
14736 		 tc_map, UINT8);
14737 
14738 /* VF max bandwidth setting */
14739 static void
14740 cmd_vf_max_bw_parsed(
14741 	void *parsed_result,
14742 	__attribute__((unused)) struct cmdline *cl,
14743 	__attribute__((unused)) void *data)
14744 {
14745 	struct cmd_vf_tc_bw_result *res = parsed_result;
14746 	int ret = -ENOTSUP;
14747 
14748 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14749 		return;
14750 
14751 #ifdef RTE_LIBRTE_I40E_PMD
14752 	ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
14753 					 res->vf_id, res->bw);
14754 #endif
14755 
14756 	switch (ret) {
14757 	case 0:
14758 		break;
14759 	case -EINVAL:
14760 		printf("invalid vf_id %d or bandwidth %d\n",
14761 		       res->vf_id, res->bw);
14762 		break;
14763 	case -ENODEV:
14764 		printf("invalid port_id %d\n", res->port_id);
14765 		break;
14766 	case -ENOTSUP:
14767 		printf("function not implemented\n");
14768 		break;
14769 	default:
14770 		printf("programming error: (%s)\n", strerror(-ret));
14771 	}
14772 }
14773 
14774 cmdline_parse_inst_t cmd_vf_max_bw = {
14775 	.f = cmd_vf_max_bw_parsed,
14776 	.data = NULL,
14777 	.help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
14778 	.tokens = {
14779 		(void *)&cmd_vf_tc_bw_set,
14780 		(void *)&cmd_vf_tc_bw_vf,
14781 		(void *)&cmd_vf_tc_bw_tx,
14782 		(void *)&cmd_vf_tc_bw_max_bw,
14783 		(void *)&cmd_vf_tc_bw_port_id,
14784 		(void *)&cmd_vf_tc_bw_vf_id,
14785 		(void *)&cmd_vf_tc_bw_bw,
14786 		NULL,
14787 	},
14788 };
14789 
14790 static int
14791 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
14792 			   uint8_t *tc_num,
14793 			   char *str)
14794 {
14795 	uint32_t size;
14796 	const char *p, *p0 = str;
14797 	char s[256];
14798 	char *end;
14799 	char *str_fld[16];
14800 	uint16_t i;
14801 	int ret;
14802 
14803 	p = strchr(p0, '(');
14804 	if (p == NULL) {
14805 		printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14806 		return -1;
14807 	}
14808 	p++;
14809 	p0 = strchr(p, ')');
14810 	if (p0 == NULL) {
14811 		printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14812 		return -1;
14813 	}
14814 	size = p0 - p;
14815 	if (size >= sizeof(s)) {
14816 		printf("The string size exceeds the internal buffer size\n");
14817 		return -1;
14818 	}
14819 	snprintf(s, sizeof(s), "%.*s", size, p);
14820 	ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
14821 	if (ret <= 0) {
14822 		printf("Failed to get the bandwidth list. ");
14823 		return -1;
14824 	}
14825 	*tc_num = ret;
14826 	for (i = 0; i < ret; i++)
14827 		bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
14828 
14829 	return 0;
14830 }
14831 
14832 /* TC min bandwidth setting */
14833 static void
14834 cmd_vf_tc_min_bw_parsed(
14835 	void *parsed_result,
14836 	__attribute__((unused)) struct cmdline *cl,
14837 	__attribute__((unused)) void *data)
14838 {
14839 	struct cmd_vf_tc_bw_result *res = parsed_result;
14840 	uint8_t tc_num;
14841 	uint8_t bw[16];
14842 	int ret = -ENOTSUP;
14843 
14844 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14845 		return;
14846 
14847 	ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
14848 	if (ret)
14849 		return;
14850 
14851 #ifdef RTE_LIBRTE_I40E_PMD
14852 	ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
14853 					      tc_num, bw);
14854 #endif
14855 
14856 	switch (ret) {
14857 	case 0:
14858 		break;
14859 	case -EINVAL:
14860 		printf("invalid vf_id %d or bandwidth\n", res->vf_id);
14861 		break;
14862 	case -ENODEV:
14863 		printf("invalid port_id %d\n", res->port_id);
14864 		break;
14865 	case -ENOTSUP:
14866 		printf("function not implemented\n");
14867 		break;
14868 	default:
14869 		printf("programming error: (%s)\n", strerror(-ret));
14870 	}
14871 }
14872 
14873 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
14874 	.f = cmd_vf_tc_min_bw_parsed,
14875 	.data = NULL,
14876 	.help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
14877 		    " <bw1, bw2, ...>",
14878 	.tokens = {
14879 		(void *)&cmd_vf_tc_bw_set,
14880 		(void *)&cmd_vf_tc_bw_vf,
14881 		(void *)&cmd_vf_tc_bw_tc,
14882 		(void *)&cmd_vf_tc_bw_tx,
14883 		(void *)&cmd_vf_tc_bw_min_bw,
14884 		(void *)&cmd_vf_tc_bw_port_id,
14885 		(void *)&cmd_vf_tc_bw_vf_id,
14886 		(void *)&cmd_vf_tc_bw_bw_list,
14887 		NULL,
14888 	},
14889 };
14890 
14891 static void
14892 cmd_tc_min_bw_parsed(
14893 	void *parsed_result,
14894 	__attribute__((unused)) struct cmdline *cl,
14895 	__attribute__((unused)) void *data)
14896 {
14897 	struct cmd_vf_tc_bw_result *res = parsed_result;
14898 	struct rte_port *port;
14899 	uint8_t tc_num;
14900 	uint8_t bw[16];
14901 	int ret = -ENOTSUP;
14902 
14903 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14904 		return;
14905 
14906 	port = &ports[res->port_id];
14907 	/** Check if the port is not started **/
14908 	if (port->port_status != RTE_PORT_STOPPED) {
14909 		printf("Please stop port %d first\n", res->port_id);
14910 		return;
14911 	}
14912 
14913 	ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
14914 	if (ret)
14915 		return;
14916 
14917 #ifdef RTE_LIBRTE_IXGBE_PMD
14918 	ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
14919 #endif
14920 
14921 	switch (ret) {
14922 	case 0:
14923 		break;
14924 	case -EINVAL:
14925 		printf("invalid bandwidth\n");
14926 		break;
14927 	case -ENODEV:
14928 		printf("invalid port_id %d\n", res->port_id);
14929 		break;
14930 	case -ENOTSUP:
14931 		printf("function not implemented\n");
14932 		break;
14933 	default:
14934 		printf("programming error: (%s)\n", strerror(-ret));
14935 	}
14936 }
14937 
14938 cmdline_parse_inst_t cmd_tc_min_bw = {
14939 	.f = cmd_tc_min_bw_parsed,
14940 	.data = NULL,
14941 	.help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
14942 	.tokens = {
14943 		(void *)&cmd_vf_tc_bw_set,
14944 		(void *)&cmd_vf_tc_bw_tc,
14945 		(void *)&cmd_vf_tc_bw_tx,
14946 		(void *)&cmd_vf_tc_bw_min_bw,
14947 		(void *)&cmd_vf_tc_bw_port_id,
14948 		(void *)&cmd_vf_tc_bw_bw_list,
14949 		NULL,
14950 	},
14951 };
14952 
14953 /* TC max bandwidth setting */
14954 static void
14955 cmd_vf_tc_max_bw_parsed(
14956 	void *parsed_result,
14957 	__attribute__((unused)) struct cmdline *cl,
14958 	__attribute__((unused)) void *data)
14959 {
14960 	struct cmd_vf_tc_bw_result *res = parsed_result;
14961 	int ret = -ENOTSUP;
14962 
14963 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14964 		return;
14965 
14966 #ifdef RTE_LIBRTE_I40E_PMD
14967 	ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
14968 					    res->tc_no, res->bw);
14969 #endif
14970 
14971 	switch (ret) {
14972 	case 0:
14973 		break;
14974 	case -EINVAL:
14975 		printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
14976 		       res->vf_id, res->tc_no, res->bw);
14977 		break;
14978 	case -ENODEV:
14979 		printf("invalid port_id %d\n", res->port_id);
14980 		break;
14981 	case -ENOTSUP:
14982 		printf("function not implemented\n");
14983 		break;
14984 	default:
14985 		printf("programming error: (%s)\n", strerror(-ret));
14986 	}
14987 }
14988 
14989 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
14990 	.f = cmd_vf_tc_max_bw_parsed,
14991 	.data = NULL,
14992 	.help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
14993 		    " <bandwidth>",
14994 	.tokens = {
14995 		(void *)&cmd_vf_tc_bw_set,
14996 		(void *)&cmd_vf_tc_bw_vf,
14997 		(void *)&cmd_vf_tc_bw_tc,
14998 		(void *)&cmd_vf_tc_bw_tx,
14999 		(void *)&cmd_vf_tc_bw_max_bw,
15000 		(void *)&cmd_vf_tc_bw_port_id,
15001 		(void *)&cmd_vf_tc_bw_vf_id,
15002 		(void *)&cmd_vf_tc_bw_tc_no,
15003 		(void *)&cmd_vf_tc_bw_bw,
15004 		NULL,
15005 	},
15006 };
15007 
15008 
15009 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
15010 
15011 /* *** Set Port default Traffic Management Hierarchy *** */
15012 struct cmd_set_port_tm_hierarchy_default_result {
15013 	cmdline_fixed_string_t set;
15014 	cmdline_fixed_string_t port;
15015 	cmdline_fixed_string_t tm;
15016 	cmdline_fixed_string_t hierarchy;
15017 	cmdline_fixed_string_t def;
15018 	portid_t port_id;
15019 };
15020 
15021 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_set =
15022 	TOKEN_STRING_INITIALIZER(
15023 		struct cmd_set_port_tm_hierarchy_default_result, set, "set");
15024 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_port =
15025 	TOKEN_STRING_INITIALIZER(
15026 		struct cmd_set_port_tm_hierarchy_default_result, port, "port");
15027 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_tm =
15028 	TOKEN_STRING_INITIALIZER(
15029 		struct cmd_set_port_tm_hierarchy_default_result, tm, "tm");
15030 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_hierarchy =
15031 	TOKEN_STRING_INITIALIZER(
15032 		struct cmd_set_port_tm_hierarchy_default_result,
15033 			hierarchy, "hierarchy");
15034 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_default =
15035 	TOKEN_STRING_INITIALIZER(
15036 		struct cmd_set_port_tm_hierarchy_default_result,
15037 			def, "default");
15038 cmdline_parse_token_num_t cmd_set_port_tm_hierarchy_default_port_id =
15039 	TOKEN_NUM_INITIALIZER(
15040 		struct cmd_set_port_tm_hierarchy_default_result,
15041 			port_id, UINT16);
15042 
15043 static void cmd_set_port_tm_hierarchy_default_parsed(void *parsed_result,
15044 	__attribute__((unused)) struct cmdline *cl,
15045 	__attribute__((unused)) void *data)
15046 {
15047 	struct cmd_set_port_tm_hierarchy_default_result *res = parsed_result;
15048 	struct rte_port *p;
15049 	portid_t port_id = res->port_id;
15050 
15051 	if (port_id_is_invalid(port_id, ENABLED_WARN))
15052 		return;
15053 
15054 	p = &ports[port_id];
15055 
15056 	/* Forward mode: tm */
15057 	if (strcmp(cur_fwd_config.fwd_eng->fwd_mode_name, "softnic")) {
15058 		printf("  softnicfwd mode not enabled(error)\n");
15059 		return;
15060 	}
15061 
15062 	/* Set the default tm hierarchy */
15063 	p->softport.default_tm_hierarchy_enable = 1;
15064 }
15065 
15066 cmdline_parse_inst_t cmd_set_port_tm_hierarchy_default = {
15067 	.f = cmd_set_port_tm_hierarchy_default_parsed,
15068 	.data = NULL,
15069 	.help_str = "set port tm hierarchy default <port_id>",
15070 	.tokens = {
15071 		(void *)&cmd_set_port_tm_hierarchy_default_set,
15072 		(void *)&cmd_set_port_tm_hierarchy_default_port,
15073 		(void *)&cmd_set_port_tm_hierarchy_default_tm,
15074 		(void *)&cmd_set_port_tm_hierarchy_default_hierarchy,
15075 		(void *)&cmd_set_port_tm_hierarchy_default_default,
15076 		(void *)&cmd_set_port_tm_hierarchy_default_port_id,
15077 		NULL,
15078 	},
15079 };
15080 #endif
15081 
15082 /** Set VXLAN encapsulation details */
15083 struct cmd_set_vxlan_result {
15084 	cmdline_fixed_string_t set;
15085 	cmdline_fixed_string_t vxlan;
15086 	cmdline_fixed_string_t pos_token;
15087 	cmdline_fixed_string_t ip_version;
15088 	uint32_t vlan_present:1;
15089 	uint32_t vni;
15090 	uint16_t udp_src;
15091 	uint16_t udp_dst;
15092 	cmdline_ipaddr_t ip_src;
15093 	cmdline_ipaddr_t ip_dst;
15094 	uint16_t tci;
15095 	uint8_t tos;
15096 	uint8_t ttl;
15097 	struct ether_addr eth_src;
15098 	struct ether_addr eth_dst;
15099 };
15100 
15101 cmdline_parse_token_string_t cmd_set_vxlan_set =
15102 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
15103 cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
15104 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
15105 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
15106 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15107 				 "vxlan-tos-ttl");
15108 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
15109 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15110 				 "vxlan-with-vlan");
15111 cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
15112 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15113 				 "ip-version");
15114 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
15115 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
15116 				 "ipv4#ipv6");
15117 cmdline_parse_token_string_t cmd_set_vxlan_vni =
15118 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15119 				 "vni");
15120 cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
15121 	TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, UINT32);
15122 cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
15123 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15124 				 "udp-src");
15125 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
15126 	TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, UINT16);
15127 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
15128 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15129 				 "udp-dst");
15130 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
15131 	TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, UINT16);
15132 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
15133 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15134 				 "ip-tos");
15135 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
15136 	TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, UINT8);
15137 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
15138 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15139 				 "ip-ttl");
15140 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
15141 	TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, UINT8);
15142 cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
15143 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15144 				 "ip-src");
15145 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
15146 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
15147 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
15148 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15149 				 "ip-dst");
15150 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
15151 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
15152 cmdline_parse_token_string_t cmd_set_vxlan_vlan =
15153 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15154 				 "vlan-tci");
15155 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
15156 	TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, UINT16);
15157 cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
15158 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15159 				 "eth-src");
15160 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
15161 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
15162 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
15163 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15164 				 "eth-dst");
15165 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
15166 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
15167 
15168 static void cmd_set_vxlan_parsed(void *parsed_result,
15169 	__attribute__((unused)) struct cmdline *cl,
15170 	__attribute__((unused)) void *data)
15171 {
15172 	struct cmd_set_vxlan_result *res = parsed_result;
15173 	union {
15174 		uint32_t vxlan_id;
15175 		uint8_t vni[4];
15176 	} id = {
15177 		.vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
15178 	};
15179 
15180 	vxlan_encap_conf.select_tos_ttl = 0;
15181 	if (strcmp(res->vxlan, "vxlan") == 0)
15182 		vxlan_encap_conf.select_vlan = 0;
15183 	else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
15184 		vxlan_encap_conf.select_vlan = 1;
15185 	else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
15186 		vxlan_encap_conf.select_vlan = 0;
15187 		vxlan_encap_conf.select_tos_ttl = 1;
15188 	}
15189 	if (strcmp(res->ip_version, "ipv4") == 0)
15190 		vxlan_encap_conf.select_ipv4 = 1;
15191 	else if (strcmp(res->ip_version, "ipv6") == 0)
15192 		vxlan_encap_conf.select_ipv4 = 0;
15193 	else
15194 		return;
15195 	rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
15196 	vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
15197 	vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
15198 	vxlan_encap_conf.ip_tos = res->tos;
15199 	vxlan_encap_conf.ip_ttl = res->ttl;
15200 	if (vxlan_encap_conf.select_ipv4) {
15201 		IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
15202 		IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
15203 	} else {
15204 		IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
15205 		IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
15206 	}
15207 	if (vxlan_encap_conf.select_vlan)
15208 		vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15209 	rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
15210 		   ETHER_ADDR_LEN);
15211 	rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15212 		   ETHER_ADDR_LEN);
15213 }
15214 
15215 cmdline_parse_inst_t cmd_set_vxlan = {
15216 	.f = cmd_set_vxlan_parsed,
15217 	.data = NULL,
15218 	.help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
15219 		" <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
15220 		" eth-src <eth-src> eth-dst <eth-dst>",
15221 	.tokens = {
15222 		(void *)&cmd_set_vxlan_set,
15223 		(void *)&cmd_set_vxlan_vxlan,
15224 		(void *)&cmd_set_vxlan_ip_version,
15225 		(void *)&cmd_set_vxlan_ip_version_value,
15226 		(void *)&cmd_set_vxlan_vni,
15227 		(void *)&cmd_set_vxlan_vni_value,
15228 		(void *)&cmd_set_vxlan_udp_src,
15229 		(void *)&cmd_set_vxlan_udp_src_value,
15230 		(void *)&cmd_set_vxlan_udp_dst,
15231 		(void *)&cmd_set_vxlan_udp_dst_value,
15232 		(void *)&cmd_set_vxlan_ip_src,
15233 		(void *)&cmd_set_vxlan_ip_src_value,
15234 		(void *)&cmd_set_vxlan_ip_dst,
15235 		(void *)&cmd_set_vxlan_ip_dst_value,
15236 		(void *)&cmd_set_vxlan_eth_src,
15237 		(void *)&cmd_set_vxlan_eth_src_value,
15238 		(void *)&cmd_set_vxlan_eth_dst,
15239 		(void *)&cmd_set_vxlan_eth_dst_value,
15240 		NULL,
15241 	},
15242 };
15243 
15244 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
15245 	.f = cmd_set_vxlan_parsed,
15246 	.data = NULL,
15247 	.help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
15248 		" <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
15249 		" ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15250 		" eth-dst <eth-dst>",
15251 	.tokens = {
15252 		(void *)&cmd_set_vxlan_set,
15253 		(void *)&cmd_set_vxlan_vxlan_tos_ttl,
15254 		(void *)&cmd_set_vxlan_ip_version,
15255 		(void *)&cmd_set_vxlan_ip_version_value,
15256 		(void *)&cmd_set_vxlan_vni,
15257 		(void *)&cmd_set_vxlan_vni_value,
15258 		(void *)&cmd_set_vxlan_udp_src,
15259 		(void *)&cmd_set_vxlan_udp_src_value,
15260 		(void *)&cmd_set_vxlan_udp_dst,
15261 		(void *)&cmd_set_vxlan_udp_dst_value,
15262 		(void *)&cmd_set_vxlan_ip_tos,
15263 		(void *)&cmd_set_vxlan_ip_tos_value,
15264 		(void *)&cmd_set_vxlan_ip_ttl,
15265 		(void *)&cmd_set_vxlan_ip_ttl_value,
15266 		(void *)&cmd_set_vxlan_ip_src,
15267 		(void *)&cmd_set_vxlan_ip_src_value,
15268 		(void *)&cmd_set_vxlan_ip_dst,
15269 		(void *)&cmd_set_vxlan_ip_dst_value,
15270 		(void *)&cmd_set_vxlan_eth_src,
15271 		(void *)&cmd_set_vxlan_eth_src_value,
15272 		(void *)&cmd_set_vxlan_eth_dst,
15273 		(void *)&cmd_set_vxlan_eth_dst_value,
15274 		NULL,
15275 	},
15276 };
15277 
15278 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
15279 	.f = cmd_set_vxlan_parsed,
15280 	.data = NULL,
15281 	.help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
15282 		" udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
15283 		" <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
15284 		" <eth-dst>",
15285 	.tokens = {
15286 		(void *)&cmd_set_vxlan_set,
15287 		(void *)&cmd_set_vxlan_vxlan_with_vlan,
15288 		(void *)&cmd_set_vxlan_ip_version,
15289 		(void *)&cmd_set_vxlan_ip_version_value,
15290 		(void *)&cmd_set_vxlan_vni,
15291 		(void *)&cmd_set_vxlan_vni_value,
15292 		(void *)&cmd_set_vxlan_udp_src,
15293 		(void *)&cmd_set_vxlan_udp_src_value,
15294 		(void *)&cmd_set_vxlan_udp_dst,
15295 		(void *)&cmd_set_vxlan_udp_dst_value,
15296 		(void *)&cmd_set_vxlan_ip_src,
15297 		(void *)&cmd_set_vxlan_ip_src_value,
15298 		(void *)&cmd_set_vxlan_ip_dst,
15299 		(void *)&cmd_set_vxlan_ip_dst_value,
15300 		(void *)&cmd_set_vxlan_vlan,
15301 		(void *)&cmd_set_vxlan_vlan_value,
15302 		(void *)&cmd_set_vxlan_eth_src,
15303 		(void *)&cmd_set_vxlan_eth_src_value,
15304 		(void *)&cmd_set_vxlan_eth_dst,
15305 		(void *)&cmd_set_vxlan_eth_dst_value,
15306 		NULL,
15307 	},
15308 };
15309 
15310 /** Set NVGRE encapsulation details */
15311 struct cmd_set_nvgre_result {
15312 	cmdline_fixed_string_t set;
15313 	cmdline_fixed_string_t nvgre;
15314 	cmdline_fixed_string_t pos_token;
15315 	cmdline_fixed_string_t ip_version;
15316 	uint32_t tni;
15317 	cmdline_ipaddr_t ip_src;
15318 	cmdline_ipaddr_t ip_dst;
15319 	uint16_t tci;
15320 	struct ether_addr eth_src;
15321 	struct ether_addr eth_dst;
15322 };
15323 
15324 cmdline_parse_token_string_t cmd_set_nvgre_set =
15325 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
15326 cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
15327 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
15328 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
15329 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
15330 				 "nvgre-with-vlan");
15331 cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
15332 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15333 				 "ip-version");
15334 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
15335 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
15336 				 "ipv4#ipv6");
15337 cmdline_parse_token_string_t cmd_set_nvgre_tni =
15338 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15339 				 "tni");
15340 cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
15341 	TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, UINT32);
15342 cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
15343 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15344 				 "ip-src");
15345 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
15346 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
15347 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
15348 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15349 				 "ip-dst");
15350 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
15351 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
15352 cmdline_parse_token_string_t cmd_set_nvgre_vlan =
15353 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15354 				 "vlan-tci");
15355 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
15356 	TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, UINT16);
15357 cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
15358 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15359 				 "eth-src");
15360 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
15361 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
15362 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
15363 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15364 				 "eth-dst");
15365 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
15366 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
15367 
15368 static void cmd_set_nvgre_parsed(void *parsed_result,
15369 	__attribute__((unused)) struct cmdline *cl,
15370 	__attribute__((unused)) void *data)
15371 {
15372 	struct cmd_set_nvgre_result *res = parsed_result;
15373 	union {
15374 		uint32_t nvgre_tni;
15375 		uint8_t tni[4];
15376 	} id = {
15377 		.nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
15378 	};
15379 
15380 	if (strcmp(res->nvgre, "nvgre") == 0)
15381 		nvgre_encap_conf.select_vlan = 0;
15382 	else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
15383 		nvgre_encap_conf.select_vlan = 1;
15384 	if (strcmp(res->ip_version, "ipv4") == 0)
15385 		nvgre_encap_conf.select_ipv4 = 1;
15386 	else if (strcmp(res->ip_version, "ipv6") == 0)
15387 		nvgre_encap_conf.select_ipv4 = 0;
15388 	else
15389 		return;
15390 	rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
15391 	if (nvgre_encap_conf.select_ipv4) {
15392 		IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
15393 		IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
15394 	} else {
15395 		IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
15396 		IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
15397 	}
15398 	if (nvgre_encap_conf.select_vlan)
15399 		nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15400 	rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
15401 		   ETHER_ADDR_LEN);
15402 	rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15403 		   ETHER_ADDR_LEN);
15404 }
15405 
15406 cmdline_parse_inst_t cmd_set_nvgre = {
15407 	.f = cmd_set_nvgre_parsed,
15408 	.data = NULL,
15409 	.help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
15410 		" <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15411 		" eth-dst <eth-dst>",
15412 	.tokens = {
15413 		(void *)&cmd_set_nvgre_set,
15414 		(void *)&cmd_set_nvgre_nvgre,
15415 		(void *)&cmd_set_nvgre_ip_version,
15416 		(void *)&cmd_set_nvgre_ip_version_value,
15417 		(void *)&cmd_set_nvgre_tni,
15418 		(void *)&cmd_set_nvgre_tni_value,
15419 		(void *)&cmd_set_nvgre_ip_src,
15420 		(void *)&cmd_set_nvgre_ip_src_value,
15421 		(void *)&cmd_set_nvgre_ip_dst,
15422 		(void *)&cmd_set_nvgre_ip_dst_value,
15423 		(void *)&cmd_set_nvgre_eth_src,
15424 		(void *)&cmd_set_nvgre_eth_src_value,
15425 		(void *)&cmd_set_nvgre_eth_dst,
15426 		(void *)&cmd_set_nvgre_eth_dst_value,
15427 		NULL,
15428 	},
15429 };
15430 
15431 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
15432 	.f = cmd_set_nvgre_parsed,
15433 	.data = NULL,
15434 	.help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
15435 		" ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
15436 		" eth-src <eth-src> eth-dst <eth-dst>",
15437 	.tokens = {
15438 		(void *)&cmd_set_nvgre_set,
15439 		(void *)&cmd_set_nvgre_nvgre_with_vlan,
15440 		(void *)&cmd_set_nvgre_ip_version,
15441 		(void *)&cmd_set_nvgre_ip_version_value,
15442 		(void *)&cmd_set_nvgre_tni,
15443 		(void *)&cmd_set_nvgre_tni_value,
15444 		(void *)&cmd_set_nvgre_ip_src,
15445 		(void *)&cmd_set_nvgre_ip_src_value,
15446 		(void *)&cmd_set_nvgre_ip_dst,
15447 		(void *)&cmd_set_nvgre_ip_dst_value,
15448 		(void *)&cmd_set_nvgre_vlan,
15449 		(void *)&cmd_set_nvgre_vlan_value,
15450 		(void *)&cmd_set_nvgre_eth_src,
15451 		(void *)&cmd_set_nvgre_eth_src_value,
15452 		(void *)&cmd_set_nvgre_eth_dst,
15453 		(void *)&cmd_set_nvgre_eth_dst_value,
15454 		NULL,
15455 	},
15456 };
15457 
15458 /** Set L2 encapsulation details */
15459 struct cmd_set_l2_encap_result {
15460 	cmdline_fixed_string_t set;
15461 	cmdline_fixed_string_t l2_encap;
15462 	cmdline_fixed_string_t pos_token;
15463 	cmdline_fixed_string_t ip_version;
15464 	uint32_t vlan_present:1;
15465 	uint16_t tci;
15466 	struct ether_addr eth_src;
15467 	struct ether_addr eth_dst;
15468 };
15469 
15470 cmdline_parse_token_string_t cmd_set_l2_encap_set =
15471 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
15472 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
15473 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
15474 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
15475 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
15476 				 "l2_encap-with-vlan");
15477 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
15478 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15479 				 "ip-version");
15480 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
15481 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
15482 				 "ipv4#ipv6");
15483 cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
15484 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15485 				 "vlan-tci");
15486 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
15487 	TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, UINT16);
15488 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
15489 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15490 				 "eth-src");
15491 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
15492 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
15493 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
15494 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15495 				 "eth-dst");
15496 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
15497 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
15498 
15499 static void cmd_set_l2_encap_parsed(void *parsed_result,
15500 	__attribute__((unused)) struct cmdline *cl,
15501 	__attribute__((unused)) void *data)
15502 {
15503 	struct cmd_set_l2_encap_result *res = parsed_result;
15504 
15505 	if (strcmp(res->l2_encap, "l2_encap") == 0)
15506 		l2_encap_conf.select_vlan = 0;
15507 	else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
15508 		l2_encap_conf.select_vlan = 1;
15509 	if (strcmp(res->ip_version, "ipv4") == 0)
15510 		l2_encap_conf.select_ipv4 = 1;
15511 	else if (strcmp(res->ip_version, "ipv6") == 0)
15512 		l2_encap_conf.select_ipv4 = 0;
15513 	else
15514 		return;
15515 	if (l2_encap_conf.select_vlan)
15516 		l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15517 	rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
15518 		   ETHER_ADDR_LEN);
15519 	rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15520 		   ETHER_ADDR_LEN);
15521 }
15522 
15523 cmdline_parse_inst_t cmd_set_l2_encap = {
15524 	.f = cmd_set_l2_encap_parsed,
15525 	.data = NULL,
15526 	.help_str = "set l2_encap ip-version ipv4|ipv6"
15527 		" eth-src <eth-src> eth-dst <eth-dst>",
15528 	.tokens = {
15529 		(void *)&cmd_set_l2_encap_set,
15530 		(void *)&cmd_set_l2_encap_l2_encap,
15531 		(void *)&cmd_set_l2_encap_ip_version,
15532 		(void *)&cmd_set_l2_encap_ip_version_value,
15533 		(void *)&cmd_set_l2_encap_eth_src,
15534 		(void *)&cmd_set_l2_encap_eth_src_value,
15535 		(void *)&cmd_set_l2_encap_eth_dst,
15536 		(void *)&cmd_set_l2_encap_eth_dst_value,
15537 		NULL,
15538 	},
15539 };
15540 
15541 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
15542 	.f = cmd_set_l2_encap_parsed,
15543 	.data = NULL,
15544 	.help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
15545 		" vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
15546 	.tokens = {
15547 		(void *)&cmd_set_l2_encap_set,
15548 		(void *)&cmd_set_l2_encap_l2_encap_with_vlan,
15549 		(void *)&cmd_set_l2_encap_ip_version,
15550 		(void *)&cmd_set_l2_encap_ip_version_value,
15551 		(void *)&cmd_set_l2_encap_vlan,
15552 		(void *)&cmd_set_l2_encap_vlan_value,
15553 		(void *)&cmd_set_l2_encap_eth_src,
15554 		(void *)&cmd_set_l2_encap_eth_src_value,
15555 		(void *)&cmd_set_l2_encap_eth_dst,
15556 		(void *)&cmd_set_l2_encap_eth_dst_value,
15557 		NULL,
15558 	},
15559 };
15560 
15561 /** Set L2 decapsulation details */
15562 struct cmd_set_l2_decap_result {
15563 	cmdline_fixed_string_t set;
15564 	cmdline_fixed_string_t l2_decap;
15565 	cmdline_fixed_string_t pos_token;
15566 	uint32_t vlan_present:1;
15567 };
15568 
15569 cmdline_parse_token_string_t cmd_set_l2_decap_set =
15570 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
15571 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
15572 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
15573 				 "l2_decap");
15574 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
15575 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
15576 				 "l2_decap-with-vlan");
15577 
15578 static void cmd_set_l2_decap_parsed(void *parsed_result,
15579 	__attribute__((unused)) struct cmdline *cl,
15580 	__attribute__((unused)) void *data)
15581 {
15582 	struct cmd_set_l2_decap_result *res = parsed_result;
15583 
15584 	if (strcmp(res->l2_decap, "l2_decap") == 0)
15585 		l2_decap_conf.select_vlan = 0;
15586 	else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
15587 		l2_decap_conf.select_vlan = 1;
15588 }
15589 
15590 cmdline_parse_inst_t cmd_set_l2_decap = {
15591 	.f = cmd_set_l2_decap_parsed,
15592 	.data = NULL,
15593 	.help_str = "set l2_decap",
15594 	.tokens = {
15595 		(void *)&cmd_set_l2_decap_set,
15596 		(void *)&cmd_set_l2_decap_l2_decap,
15597 		NULL,
15598 	},
15599 };
15600 
15601 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
15602 	.f = cmd_set_l2_decap_parsed,
15603 	.data = NULL,
15604 	.help_str = "set l2_decap-with-vlan",
15605 	.tokens = {
15606 		(void *)&cmd_set_l2_decap_set,
15607 		(void *)&cmd_set_l2_decap_l2_decap_with_vlan,
15608 		NULL,
15609 	},
15610 };
15611 
15612 /** Set MPLSoGRE encapsulation details */
15613 struct cmd_set_mplsogre_encap_result {
15614 	cmdline_fixed_string_t set;
15615 	cmdline_fixed_string_t mplsogre;
15616 	cmdline_fixed_string_t pos_token;
15617 	cmdline_fixed_string_t ip_version;
15618 	uint32_t vlan_present:1;
15619 	uint32_t label;
15620 	cmdline_ipaddr_t ip_src;
15621 	cmdline_ipaddr_t ip_dst;
15622 	uint16_t tci;
15623 	struct ether_addr eth_src;
15624 	struct ether_addr eth_dst;
15625 };
15626 
15627 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
15628 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
15629 				 "set");
15630 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
15631 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
15632 				 "mplsogre_encap");
15633 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
15634 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15635 				 mplsogre, "mplsogre_encap-with-vlan");
15636 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
15637 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15638 				 pos_token, "ip-version");
15639 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
15640 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15641 				 ip_version, "ipv4#ipv6");
15642 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
15643 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15644 				 pos_token, "label");
15645 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
15646 	TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
15647 			      UINT32);
15648 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
15649 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15650 				 pos_token, "ip-src");
15651 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
15652 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
15653 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
15654 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15655 				 pos_token, "ip-dst");
15656 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
15657 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
15658 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
15659 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15660 				 pos_token, "vlan-tci");
15661 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
15662 	TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
15663 			      UINT16);
15664 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
15665 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15666 				 pos_token, "eth-src");
15667 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
15668 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15669 				    eth_src);
15670 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
15671 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15672 				 pos_token, "eth-dst");
15673 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
15674 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15675 				    eth_dst);
15676 
15677 static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
15678 	__attribute__((unused)) struct cmdline *cl,
15679 	__attribute__((unused)) void *data)
15680 {
15681 	struct cmd_set_mplsogre_encap_result *res = parsed_result;
15682 	union {
15683 		uint32_t mplsogre_label;
15684 		uint8_t label[4];
15685 	} id = {
15686 		.mplsogre_label = rte_cpu_to_be_32(res->label<<12),
15687 	};
15688 
15689 	if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
15690 		mplsogre_encap_conf.select_vlan = 0;
15691 	else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
15692 		mplsogre_encap_conf.select_vlan = 1;
15693 	if (strcmp(res->ip_version, "ipv4") == 0)
15694 		mplsogre_encap_conf.select_ipv4 = 1;
15695 	else if (strcmp(res->ip_version, "ipv6") == 0)
15696 		mplsogre_encap_conf.select_ipv4 = 0;
15697 	else
15698 		return;
15699 	rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
15700 	if (mplsogre_encap_conf.select_ipv4) {
15701 		IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
15702 		IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
15703 	} else {
15704 		IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
15705 		IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
15706 	}
15707 	if (mplsogre_encap_conf.select_vlan)
15708 		mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15709 	rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
15710 		   ETHER_ADDR_LEN);
15711 	rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15712 		   ETHER_ADDR_LEN);
15713 }
15714 
15715 cmdline_parse_inst_t cmd_set_mplsogre_encap = {
15716 	.f = cmd_set_mplsogre_encap_parsed,
15717 	.data = NULL,
15718 	.help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
15719 		" ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15720 		" eth-dst <eth-dst>",
15721 	.tokens = {
15722 		(void *)&cmd_set_mplsogre_encap_set,
15723 		(void *)&cmd_set_mplsogre_encap_mplsogre_encap,
15724 		(void *)&cmd_set_mplsogre_encap_ip_version,
15725 		(void *)&cmd_set_mplsogre_encap_ip_version_value,
15726 		(void *)&cmd_set_mplsogre_encap_label,
15727 		(void *)&cmd_set_mplsogre_encap_label_value,
15728 		(void *)&cmd_set_mplsogre_encap_ip_src,
15729 		(void *)&cmd_set_mplsogre_encap_ip_src_value,
15730 		(void *)&cmd_set_mplsogre_encap_ip_dst,
15731 		(void *)&cmd_set_mplsogre_encap_ip_dst_value,
15732 		(void *)&cmd_set_mplsogre_encap_eth_src,
15733 		(void *)&cmd_set_mplsogre_encap_eth_src_value,
15734 		(void *)&cmd_set_mplsogre_encap_eth_dst,
15735 		(void *)&cmd_set_mplsogre_encap_eth_dst_value,
15736 		NULL,
15737 	},
15738 };
15739 
15740 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
15741 	.f = cmd_set_mplsogre_encap_parsed,
15742 	.data = NULL,
15743 	.help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
15744 		" label <label> ip-src <ip-src> ip-dst <ip-dst>"
15745 		" vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
15746 	.tokens = {
15747 		(void *)&cmd_set_mplsogre_encap_set,
15748 		(void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
15749 		(void *)&cmd_set_mplsogre_encap_ip_version,
15750 		(void *)&cmd_set_mplsogre_encap_ip_version_value,
15751 		(void *)&cmd_set_mplsogre_encap_label,
15752 		(void *)&cmd_set_mplsogre_encap_label_value,
15753 		(void *)&cmd_set_mplsogre_encap_ip_src,
15754 		(void *)&cmd_set_mplsogre_encap_ip_src_value,
15755 		(void *)&cmd_set_mplsogre_encap_ip_dst,
15756 		(void *)&cmd_set_mplsogre_encap_ip_dst_value,
15757 		(void *)&cmd_set_mplsogre_encap_vlan,
15758 		(void *)&cmd_set_mplsogre_encap_vlan_value,
15759 		(void *)&cmd_set_mplsogre_encap_eth_src,
15760 		(void *)&cmd_set_mplsogre_encap_eth_src_value,
15761 		(void *)&cmd_set_mplsogre_encap_eth_dst,
15762 		(void *)&cmd_set_mplsogre_encap_eth_dst_value,
15763 		NULL,
15764 	},
15765 };
15766 
15767 /** Set MPLSoGRE decapsulation details */
15768 struct cmd_set_mplsogre_decap_result {
15769 	cmdline_fixed_string_t set;
15770 	cmdline_fixed_string_t mplsogre;
15771 	cmdline_fixed_string_t pos_token;
15772 	cmdline_fixed_string_t ip_version;
15773 	uint32_t vlan_present:1;
15774 };
15775 
15776 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
15777 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
15778 				 "set");
15779 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
15780 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
15781 				 "mplsogre_decap");
15782 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
15783 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
15784 				 mplsogre, "mplsogre_decap-with-vlan");
15785 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
15786 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
15787 				 pos_token, "ip-version");
15788 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
15789 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
15790 				 ip_version, "ipv4#ipv6");
15791 
15792 static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
15793 	__attribute__((unused)) struct cmdline *cl,
15794 	__attribute__((unused)) void *data)
15795 {
15796 	struct cmd_set_mplsogre_decap_result *res = parsed_result;
15797 
15798 	if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
15799 		mplsogre_decap_conf.select_vlan = 0;
15800 	else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
15801 		mplsogre_decap_conf.select_vlan = 1;
15802 	if (strcmp(res->ip_version, "ipv4") == 0)
15803 		mplsogre_decap_conf.select_ipv4 = 1;
15804 	else if (strcmp(res->ip_version, "ipv6") == 0)
15805 		mplsogre_decap_conf.select_ipv4 = 0;
15806 }
15807 
15808 cmdline_parse_inst_t cmd_set_mplsogre_decap = {
15809 	.f = cmd_set_mplsogre_decap_parsed,
15810 	.data = NULL,
15811 	.help_str = "set mplsogre_decap ip-version ipv4|ipv6",
15812 	.tokens = {
15813 		(void *)&cmd_set_mplsogre_decap_set,
15814 		(void *)&cmd_set_mplsogre_decap_mplsogre_decap,
15815 		(void *)&cmd_set_mplsogre_decap_ip_version,
15816 		(void *)&cmd_set_mplsogre_decap_ip_version_value,
15817 		NULL,
15818 	},
15819 };
15820 
15821 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
15822 	.f = cmd_set_mplsogre_decap_parsed,
15823 	.data = NULL,
15824 	.help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
15825 	.tokens = {
15826 		(void *)&cmd_set_mplsogre_decap_set,
15827 		(void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
15828 		(void *)&cmd_set_mplsogre_decap_ip_version,
15829 		(void *)&cmd_set_mplsogre_decap_ip_version_value,
15830 		NULL,
15831 	},
15832 };
15833 
15834 /** Set MPLSoUDP encapsulation details */
15835 struct cmd_set_mplsoudp_encap_result {
15836 	cmdline_fixed_string_t set;
15837 	cmdline_fixed_string_t mplsoudp;
15838 	cmdline_fixed_string_t pos_token;
15839 	cmdline_fixed_string_t ip_version;
15840 	uint32_t vlan_present:1;
15841 	uint32_t label;
15842 	uint16_t udp_src;
15843 	uint16_t udp_dst;
15844 	cmdline_ipaddr_t ip_src;
15845 	cmdline_ipaddr_t ip_dst;
15846 	uint16_t tci;
15847 	struct ether_addr eth_src;
15848 	struct ether_addr eth_dst;
15849 };
15850 
15851 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
15852 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
15853 				 "set");
15854 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
15855 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
15856 				 "mplsoudp_encap");
15857 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
15858 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15859 				 mplsoudp, "mplsoudp_encap-with-vlan");
15860 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
15861 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15862 				 pos_token, "ip-version");
15863 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
15864 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15865 				 ip_version, "ipv4#ipv6");
15866 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
15867 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15868 				 pos_token, "label");
15869 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
15870 	TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
15871 			      UINT32);
15872 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
15873 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15874 				 pos_token, "udp-src");
15875 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
15876 	TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
15877 			      UINT16);
15878 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
15879 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15880 				 pos_token, "udp-dst");
15881 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
15882 	TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
15883 			      UINT16);
15884 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
15885 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15886 				 pos_token, "ip-src");
15887 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
15888 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
15889 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
15890 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15891 				 pos_token, "ip-dst");
15892 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
15893 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
15894 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
15895 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15896 				 pos_token, "vlan-tci");
15897 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
15898 	TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
15899 			      UINT16);
15900 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
15901 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15902 				 pos_token, "eth-src");
15903 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
15904 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15905 				    eth_src);
15906 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
15907 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15908 				 pos_token, "eth-dst");
15909 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
15910 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15911 				    eth_dst);
15912 
15913 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
15914 	__attribute__((unused)) struct cmdline *cl,
15915 	__attribute__((unused)) void *data)
15916 {
15917 	struct cmd_set_mplsoudp_encap_result *res = parsed_result;
15918 	union {
15919 		uint32_t mplsoudp_label;
15920 		uint8_t label[4];
15921 	} id = {
15922 		.mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
15923 	};
15924 
15925 	if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
15926 		mplsoudp_encap_conf.select_vlan = 0;
15927 	else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
15928 		mplsoudp_encap_conf.select_vlan = 1;
15929 	if (strcmp(res->ip_version, "ipv4") == 0)
15930 		mplsoudp_encap_conf.select_ipv4 = 1;
15931 	else if (strcmp(res->ip_version, "ipv6") == 0)
15932 		mplsoudp_encap_conf.select_ipv4 = 0;
15933 	else
15934 		return;
15935 	rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
15936 	mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
15937 	mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
15938 	if (mplsoudp_encap_conf.select_ipv4) {
15939 		IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
15940 		IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
15941 	} else {
15942 		IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
15943 		IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
15944 	}
15945 	if (mplsoudp_encap_conf.select_vlan)
15946 		mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15947 	rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
15948 		   ETHER_ADDR_LEN);
15949 	rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15950 		   ETHER_ADDR_LEN);
15951 }
15952 
15953 cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
15954 	.f = cmd_set_mplsoudp_encap_parsed,
15955 	.data = NULL,
15956 	.help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
15957 		" udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
15958 		" ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
15959 	.tokens = {
15960 		(void *)&cmd_set_mplsoudp_encap_set,
15961 		(void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
15962 		(void *)&cmd_set_mplsoudp_encap_ip_version,
15963 		(void *)&cmd_set_mplsoudp_encap_ip_version_value,
15964 		(void *)&cmd_set_mplsoudp_encap_label,
15965 		(void *)&cmd_set_mplsoudp_encap_label_value,
15966 		(void *)&cmd_set_mplsoudp_encap_udp_src,
15967 		(void *)&cmd_set_mplsoudp_encap_udp_src_value,
15968 		(void *)&cmd_set_mplsoudp_encap_udp_dst,
15969 		(void *)&cmd_set_mplsoudp_encap_udp_dst_value,
15970 		(void *)&cmd_set_mplsoudp_encap_ip_src,
15971 		(void *)&cmd_set_mplsoudp_encap_ip_src_value,
15972 		(void *)&cmd_set_mplsoudp_encap_ip_dst,
15973 		(void *)&cmd_set_mplsoudp_encap_ip_dst_value,
15974 		(void *)&cmd_set_mplsoudp_encap_eth_src,
15975 		(void *)&cmd_set_mplsoudp_encap_eth_src_value,
15976 		(void *)&cmd_set_mplsoudp_encap_eth_dst,
15977 		(void *)&cmd_set_mplsoudp_encap_eth_dst_value,
15978 		NULL,
15979 	},
15980 };
15981 
15982 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
15983 	.f = cmd_set_mplsoudp_encap_parsed,
15984 	.data = NULL,
15985 	.help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
15986 		" label <label> udp-src <udp-src> udp-dst <udp-dst>"
15987 		" ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
15988 		" eth-src <eth-src> eth-dst <eth-dst>",
15989 	.tokens = {
15990 		(void *)&cmd_set_mplsoudp_encap_set,
15991 		(void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
15992 		(void *)&cmd_set_mplsoudp_encap_ip_version,
15993 		(void *)&cmd_set_mplsoudp_encap_ip_version_value,
15994 		(void *)&cmd_set_mplsoudp_encap_label,
15995 		(void *)&cmd_set_mplsoudp_encap_label_value,
15996 		(void *)&cmd_set_mplsoudp_encap_udp_src,
15997 		(void *)&cmd_set_mplsoudp_encap_udp_src_value,
15998 		(void *)&cmd_set_mplsoudp_encap_udp_dst,
15999 		(void *)&cmd_set_mplsoudp_encap_udp_dst_value,
16000 		(void *)&cmd_set_mplsoudp_encap_ip_src,
16001 		(void *)&cmd_set_mplsoudp_encap_ip_src_value,
16002 		(void *)&cmd_set_mplsoudp_encap_ip_dst,
16003 		(void *)&cmd_set_mplsoudp_encap_ip_dst_value,
16004 		(void *)&cmd_set_mplsoudp_encap_vlan,
16005 		(void *)&cmd_set_mplsoudp_encap_vlan_value,
16006 		(void *)&cmd_set_mplsoudp_encap_eth_src,
16007 		(void *)&cmd_set_mplsoudp_encap_eth_src_value,
16008 		(void *)&cmd_set_mplsoudp_encap_eth_dst,
16009 		(void *)&cmd_set_mplsoudp_encap_eth_dst_value,
16010 		NULL,
16011 	},
16012 };
16013 
16014 /** Set MPLSoUDP decapsulation details */
16015 struct cmd_set_mplsoudp_decap_result {
16016 	cmdline_fixed_string_t set;
16017 	cmdline_fixed_string_t mplsoudp;
16018 	cmdline_fixed_string_t pos_token;
16019 	cmdline_fixed_string_t ip_version;
16020 	uint32_t vlan_present:1;
16021 };
16022 
16023 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
16024 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
16025 				 "set");
16026 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
16027 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
16028 				 "mplsoudp_decap");
16029 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
16030 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16031 				 mplsoudp, "mplsoudp_decap-with-vlan");
16032 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
16033 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16034 				 pos_token, "ip-version");
16035 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
16036 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16037 				 ip_version, "ipv4#ipv6");
16038 
16039 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
16040 	__attribute__((unused)) struct cmdline *cl,
16041 	__attribute__((unused)) void *data)
16042 {
16043 	struct cmd_set_mplsoudp_decap_result *res = parsed_result;
16044 
16045 	if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
16046 		mplsoudp_decap_conf.select_vlan = 0;
16047 	else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
16048 		mplsoudp_decap_conf.select_vlan = 1;
16049 	if (strcmp(res->ip_version, "ipv4") == 0)
16050 		mplsoudp_decap_conf.select_ipv4 = 1;
16051 	else if (strcmp(res->ip_version, "ipv6") == 0)
16052 		mplsoudp_decap_conf.select_ipv4 = 0;
16053 }
16054 
16055 cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
16056 	.f = cmd_set_mplsoudp_decap_parsed,
16057 	.data = NULL,
16058 	.help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
16059 	.tokens = {
16060 		(void *)&cmd_set_mplsoudp_decap_set,
16061 		(void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
16062 		(void *)&cmd_set_mplsoudp_decap_ip_version,
16063 		(void *)&cmd_set_mplsoudp_decap_ip_version_value,
16064 		NULL,
16065 	},
16066 };
16067 
16068 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
16069 	.f = cmd_set_mplsoudp_decap_parsed,
16070 	.data = NULL,
16071 	.help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
16072 	.tokens = {
16073 		(void *)&cmd_set_mplsoudp_decap_set,
16074 		(void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
16075 		(void *)&cmd_set_mplsoudp_decap_ip_version,
16076 		(void *)&cmd_set_mplsoudp_decap_ip_version_value,
16077 		NULL,
16078 	},
16079 };
16080 
16081 /* Strict link priority scheduling mode setting */
16082 static void
16083 cmd_strict_link_prio_parsed(
16084 	void *parsed_result,
16085 	__attribute__((unused)) struct cmdline *cl,
16086 	__attribute__((unused)) void *data)
16087 {
16088 	struct cmd_vf_tc_bw_result *res = parsed_result;
16089 	int ret = -ENOTSUP;
16090 
16091 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16092 		return;
16093 
16094 #ifdef RTE_LIBRTE_I40E_PMD
16095 	ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
16096 #endif
16097 
16098 	switch (ret) {
16099 	case 0:
16100 		break;
16101 	case -EINVAL:
16102 		printf("invalid tc_bitmap 0x%x\n", res->tc_map);
16103 		break;
16104 	case -ENODEV:
16105 		printf("invalid port_id %d\n", res->port_id);
16106 		break;
16107 	case -ENOTSUP:
16108 		printf("function not implemented\n");
16109 		break;
16110 	default:
16111 		printf("programming error: (%s)\n", strerror(-ret));
16112 	}
16113 }
16114 
16115 cmdline_parse_inst_t cmd_strict_link_prio = {
16116 	.f = cmd_strict_link_prio_parsed,
16117 	.data = NULL,
16118 	.help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
16119 	.tokens = {
16120 		(void *)&cmd_vf_tc_bw_set,
16121 		(void *)&cmd_vf_tc_bw_tx,
16122 		(void *)&cmd_vf_tc_bw_strict_link_prio,
16123 		(void *)&cmd_vf_tc_bw_port_id,
16124 		(void *)&cmd_vf_tc_bw_tc_map,
16125 		NULL,
16126 	},
16127 };
16128 
16129 /* Load dynamic device personalization*/
16130 struct cmd_ddp_add_result {
16131 	cmdline_fixed_string_t ddp;
16132 	cmdline_fixed_string_t add;
16133 	portid_t port_id;
16134 	char filepath[];
16135 };
16136 
16137 cmdline_parse_token_string_t cmd_ddp_add_ddp =
16138 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
16139 cmdline_parse_token_string_t cmd_ddp_add_add =
16140 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
16141 cmdline_parse_token_num_t cmd_ddp_add_port_id =
16142 	TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
16143 cmdline_parse_token_string_t cmd_ddp_add_filepath =
16144 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
16145 
16146 static void
16147 cmd_ddp_add_parsed(
16148 	void *parsed_result,
16149 	__attribute__((unused)) struct cmdline *cl,
16150 	__attribute__((unused)) void *data)
16151 {
16152 	struct cmd_ddp_add_result *res = parsed_result;
16153 	uint8_t *buff;
16154 	uint32_t size;
16155 	char *filepath;
16156 	char *file_fld[2];
16157 	int file_num;
16158 	int ret = -ENOTSUP;
16159 
16160 	if (!all_ports_stopped()) {
16161 		printf("Please stop all ports first\n");
16162 		return;
16163 	}
16164 
16165 	filepath = strdup(res->filepath);
16166 	if (filepath == NULL) {
16167 		printf("Failed to allocate memory\n");
16168 		return;
16169 	}
16170 	file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
16171 
16172 	buff = open_file(file_fld[0], &size);
16173 	if (!buff) {
16174 		free((void *)filepath);
16175 		return;
16176 	}
16177 
16178 #ifdef RTE_LIBRTE_I40E_PMD
16179 	if (ret == -ENOTSUP)
16180 		ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16181 					       buff, size,
16182 					       RTE_PMD_I40E_PKG_OP_WR_ADD);
16183 #endif
16184 
16185 	if (ret == -EEXIST)
16186 		printf("Profile has already existed.\n");
16187 	else if (ret < 0)
16188 		printf("Failed to load profile.\n");
16189 	else if (file_num == 2)
16190 		save_file(file_fld[1], buff, size);
16191 
16192 	close_file(buff);
16193 	free((void *)filepath);
16194 }
16195 
16196 cmdline_parse_inst_t cmd_ddp_add = {
16197 	.f = cmd_ddp_add_parsed,
16198 	.data = NULL,
16199 	.help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
16200 	.tokens = {
16201 		(void *)&cmd_ddp_add_ddp,
16202 		(void *)&cmd_ddp_add_add,
16203 		(void *)&cmd_ddp_add_port_id,
16204 		(void *)&cmd_ddp_add_filepath,
16205 		NULL,
16206 	},
16207 };
16208 
16209 /* Delete dynamic device personalization*/
16210 struct cmd_ddp_del_result {
16211 	cmdline_fixed_string_t ddp;
16212 	cmdline_fixed_string_t del;
16213 	portid_t port_id;
16214 	char filepath[];
16215 };
16216 
16217 cmdline_parse_token_string_t cmd_ddp_del_ddp =
16218 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
16219 cmdline_parse_token_string_t cmd_ddp_del_del =
16220 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
16221 cmdline_parse_token_num_t cmd_ddp_del_port_id =
16222 	TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
16223 cmdline_parse_token_string_t cmd_ddp_del_filepath =
16224 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
16225 
16226 static void
16227 cmd_ddp_del_parsed(
16228 	void *parsed_result,
16229 	__attribute__((unused)) struct cmdline *cl,
16230 	__attribute__((unused)) void *data)
16231 {
16232 	struct cmd_ddp_del_result *res = parsed_result;
16233 	uint8_t *buff;
16234 	uint32_t size;
16235 	int ret = -ENOTSUP;
16236 
16237 	if (!all_ports_stopped()) {
16238 		printf("Please stop all ports first\n");
16239 		return;
16240 	}
16241 
16242 	buff = open_file(res->filepath, &size);
16243 	if (!buff)
16244 		return;
16245 
16246 #ifdef RTE_LIBRTE_I40E_PMD
16247 	if (ret == -ENOTSUP)
16248 		ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16249 					       buff, size,
16250 					       RTE_PMD_I40E_PKG_OP_WR_DEL);
16251 #endif
16252 
16253 	if (ret == -EACCES)
16254 		printf("Profile does not exist.\n");
16255 	else if (ret < 0)
16256 		printf("Failed to delete profile.\n");
16257 
16258 	close_file(buff);
16259 }
16260 
16261 cmdline_parse_inst_t cmd_ddp_del = {
16262 	.f = cmd_ddp_del_parsed,
16263 	.data = NULL,
16264 	.help_str = "ddp del <port_id> <backup_profile_path>",
16265 	.tokens = {
16266 		(void *)&cmd_ddp_del_ddp,
16267 		(void *)&cmd_ddp_del_del,
16268 		(void *)&cmd_ddp_del_port_id,
16269 		(void *)&cmd_ddp_del_filepath,
16270 		NULL,
16271 	},
16272 };
16273 
16274 /* Get dynamic device personalization profile info */
16275 struct cmd_ddp_info_result {
16276 	cmdline_fixed_string_t ddp;
16277 	cmdline_fixed_string_t get;
16278 	cmdline_fixed_string_t info;
16279 	char filepath[];
16280 };
16281 
16282 cmdline_parse_token_string_t cmd_ddp_info_ddp =
16283 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
16284 cmdline_parse_token_string_t cmd_ddp_info_get =
16285 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
16286 cmdline_parse_token_string_t cmd_ddp_info_info =
16287 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
16288 cmdline_parse_token_string_t cmd_ddp_info_filepath =
16289 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
16290 
16291 static void
16292 cmd_ddp_info_parsed(
16293 	void *parsed_result,
16294 	__attribute__((unused)) struct cmdline *cl,
16295 	__attribute__((unused)) void *data)
16296 {
16297 	struct cmd_ddp_info_result *res = parsed_result;
16298 	uint8_t *pkg;
16299 	uint32_t pkg_size;
16300 	int ret = -ENOTSUP;
16301 #ifdef RTE_LIBRTE_I40E_PMD
16302 	uint32_t i, j, n;
16303 	uint8_t *buff;
16304 	uint32_t buff_size = 0;
16305 	struct rte_pmd_i40e_profile_info info;
16306 	uint32_t dev_num = 0;
16307 	struct rte_pmd_i40e_ddp_device_id *devs;
16308 	uint32_t proto_num = 0;
16309 	struct rte_pmd_i40e_proto_info *proto = NULL;
16310 	uint32_t pctype_num = 0;
16311 	struct rte_pmd_i40e_ptype_info *pctype;
16312 	uint32_t ptype_num = 0;
16313 	struct rte_pmd_i40e_ptype_info *ptype;
16314 	uint8_t proto_id;
16315 
16316 #endif
16317 
16318 	pkg = open_file(res->filepath, &pkg_size);
16319 	if (!pkg)
16320 		return;
16321 
16322 #ifdef RTE_LIBRTE_I40E_PMD
16323 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16324 				(uint8_t *)&info, sizeof(info),
16325 				RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
16326 	if (!ret) {
16327 		printf("Global Track id:       0x%x\n", info.track_id);
16328 		printf("Global Version:        %d.%d.%d.%d\n",
16329 			info.version.major,
16330 			info.version.minor,
16331 			info.version.update,
16332 			info.version.draft);
16333 		printf("Global Package name:   %s\n\n", info.name);
16334 	}
16335 
16336 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16337 				(uint8_t *)&info, sizeof(info),
16338 				RTE_PMD_I40E_PKG_INFO_HEADER);
16339 	if (!ret) {
16340 		printf("i40e Profile Track id: 0x%x\n", info.track_id);
16341 		printf("i40e Profile Version:  %d.%d.%d.%d\n",
16342 			info.version.major,
16343 			info.version.minor,
16344 			info.version.update,
16345 			info.version.draft);
16346 		printf("i40e Profile name:     %s\n\n", info.name);
16347 	}
16348 
16349 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16350 				(uint8_t *)&buff_size, sizeof(buff_size),
16351 				RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
16352 	if (!ret && buff_size) {
16353 		buff = (uint8_t *)malloc(buff_size);
16354 		if (buff) {
16355 			ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16356 						buff, buff_size,
16357 						RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
16358 			if (!ret)
16359 				printf("Package Notes:\n%s\n\n", buff);
16360 			free(buff);
16361 		}
16362 	}
16363 
16364 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16365 				(uint8_t *)&dev_num, sizeof(dev_num),
16366 				RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
16367 	if (!ret && dev_num) {
16368 		buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
16369 		devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
16370 		if (devs) {
16371 			ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16372 						(uint8_t *)devs, buff_size,
16373 						RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
16374 			if (!ret) {
16375 				printf("List of supported devices:\n");
16376 				for (i = 0; i < dev_num; i++) {
16377 					printf("  %04X:%04X %04X:%04X\n",
16378 						devs[i].vendor_dev_id >> 16,
16379 						devs[i].vendor_dev_id & 0xFFFF,
16380 						devs[i].sub_vendor_dev_id >> 16,
16381 						devs[i].sub_vendor_dev_id & 0xFFFF);
16382 				}
16383 				printf("\n");
16384 			}
16385 			free(devs);
16386 		}
16387 	}
16388 
16389 	/* get information about protocols and packet types */
16390 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16391 		(uint8_t *)&proto_num, sizeof(proto_num),
16392 		RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
16393 	if (ret || !proto_num)
16394 		goto no_print_return;
16395 
16396 	buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
16397 	proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
16398 	if (!proto)
16399 		goto no_print_return;
16400 
16401 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
16402 					buff_size,
16403 					RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
16404 	if (!ret) {
16405 		printf("List of used protocols:\n");
16406 		for (i = 0; i < proto_num; i++)
16407 			printf("  %2u: %s\n", proto[i].proto_id,
16408 			       proto[i].name);
16409 		printf("\n");
16410 	}
16411 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16412 		(uint8_t *)&pctype_num, sizeof(pctype_num),
16413 		RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
16414 	if (ret || !pctype_num)
16415 		goto no_print_pctypes;
16416 
16417 	buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16418 	pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16419 	if (!pctype)
16420 		goto no_print_pctypes;
16421 
16422 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
16423 					buff_size,
16424 					RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
16425 	if (ret) {
16426 		free(pctype);
16427 		goto no_print_pctypes;
16428 	}
16429 
16430 	printf("List of defined packet classification types:\n");
16431 	for (i = 0; i < pctype_num; i++) {
16432 		printf("  %2u:", pctype[i].ptype_id);
16433 		for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
16434 			proto_id = pctype[i].protocols[j];
16435 			if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
16436 				for (n = 0; n < proto_num; n++) {
16437 					if (proto[n].proto_id == proto_id) {
16438 						printf(" %s", proto[n].name);
16439 						break;
16440 					}
16441 				}
16442 			}
16443 		}
16444 		printf("\n");
16445 	}
16446 	printf("\n");
16447 	free(pctype);
16448 
16449 no_print_pctypes:
16450 
16451 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
16452 					sizeof(ptype_num),
16453 					RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
16454 	if (ret || !ptype_num)
16455 		goto no_print_return;
16456 
16457 	buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16458 	ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16459 	if (!ptype)
16460 		goto no_print_return;
16461 
16462 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
16463 					buff_size,
16464 					RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
16465 	if (ret) {
16466 		free(ptype);
16467 		goto no_print_return;
16468 	}
16469 	printf("List of defined packet types:\n");
16470 	for (i = 0; i < ptype_num; i++) {
16471 		printf("  %2u:", ptype[i].ptype_id);
16472 		for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
16473 			proto_id = ptype[i].protocols[j];
16474 			if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
16475 				for (n = 0; n < proto_num; n++) {
16476 					if (proto[n].proto_id == proto_id) {
16477 						printf(" %s", proto[n].name);
16478 						break;
16479 					}
16480 				}
16481 			}
16482 		}
16483 		printf("\n");
16484 	}
16485 	free(ptype);
16486 	printf("\n");
16487 
16488 	ret = 0;
16489 no_print_return:
16490 	if (proto)
16491 		free(proto);
16492 #endif
16493 	if (ret == -ENOTSUP)
16494 		printf("Function not supported in PMD driver\n");
16495 	close_file(pkg);
16496 }
16497 
16498 cmdline_parse_inst_t cmd_ddp_get_info = {
16499 	.f = cmd_ddp_info_parsed,
16500 	.data = NULL,
16501 	.help_str = "ddp get info <profile_path>",
16502 	.tokens = {
16503 		(void *)&cmd_ddp_info_ddp,
16504 		(void *)&cmd_ddp_info_get,
16505 		(void *)&cmd_ddp_info_info,
16506 		(void *)&cmd_ddp_info_filepath,
16507 		NULL,
16508 	},
16509 };
16510 
16511 /* Get dynamic device personalization profile info list*/
16512 #define PROFILE_INFO_SIZE 48
16513 #define MAX_PROFILE_NUM 16
16514 
16515 struct cmd_ddp_get_list_result {
16516 	cmdline_fixed_string_t ddp;
16517 	cmdline_fixed_string_t get;
16518 	cmdline_fixed_string_t list;
16519 	portid_t port_id;
16520 };
16521 
16522 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
16523 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
16524 cmdline_parse_token_string_t cmd_ddp_get_list_get =
16525 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
16526 cmdline_parse_token_string_t cmd_ddp_get_list_list =
16527 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
16528 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
16529 	TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
16530 
16531 static void
16532 cmd_ddp_get_list_parsed(
16533 	__attribute__((unused)) void *parsed_result,
16534 	__attribute__((unused)) struct cmdline *cl,
16535 	__attribute__((unused)) void *data)
16536 {
16537 #ifdef RTE_LIBRTE_I40E_PMD
16538 	struct cmd_ddp_get_list_result *res = parsed_result;
16539 	struct rte_pmd_i40e_profile_list *p_list;
16540 	struct rte_pmd_i40e_profile_info *p_info;
16541 	uint32_t p_num;
16542 	uint32_t size;
16543 	uint32_t i;
16544 #endif
16545 	int ret = -ENOTSUP;
16546 
16547 #ifdef RTE_LIBRTE_I40E_PMD
16548 	size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
16549 	p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
16550 	if (!p_list)
16551 		printf("%s: Failed to malloc buffer\n", __func__);
16552 
16553 	if (ret == -ENOTSUP)
16554 		ret = rte_pmd_i40e_get_ddp_list(res->port_id,
16555 						(uint8_t *)p_list, size);
16556 
16557 	if (!ret) {
16558 		p_num = p_list->p_count;
16559 		printf("Profile number is: %d\n\n", p_num);
16560 
16561 		for (i = 0; i < p_num; i++) {
16562 			p_info = &p_list->p_info[i];
16563 			printf("Profile %d:\n", i);
16564 			printf("Track id:     0x%x\n", p_info->track_id);
16565 			printf("Version:      %d.%d.%d.%d\n",
16566 			       p_info->version.major,
16567 			       p_info->version.minor,
16568 			       p_info->version.update,
16569 			       p_info->version.draft);
16570 			printf("Profile name: %s\n\n", p_info->name);
16571 		}
16572 	}
16573 
16574 	free(p_list);
16575 #endif
16576 
16577 	if (ret < 0)
16578 		printf("Failed to get ddp list\n");
16579 }
16580 
16581 cmdline_parse_inst_t cmd_ddp_get_list = {
16582 	.f = cmd_ddp_get_list_parsed,
16583 	.data = NULL,
16584 	.help_str = "ddp get list <port_id>",
16585 	.tokens = {
16586 		(void *)&cmd_ddp_get_list_ddp,
16587 		(void *)&cmd_ddp_get_list_get,
16588 		(void *)&cmd_ddp_get_list_list,
16589 		(void *)&cmd_ddp_get_list_port_id,
16590 		NULL,
16591 	},
16592 };
16593 
16594 /* Configure input set */
16595 struct cmd_cfg_input_set_result {
16596 	cmdline_fixed_string_t port;
16597 	cmdline_fixed_string_t cfg;
16598 	portid_t port_id;
16599 	cmdline_fixed_string_t pctype;
16600 	uint8_t pctype_id;
16601 	cmdline_fixed_string_t inset_type;
16602 	cmdline_fixed_string_t opt;
16603 	cmdline_fixed_string_t field;
16604 	uint8_t field_idx;
16605 };
16606 
16607 static void
16608 cmd_cfg_input_set_parsed(
16609 	__attribute__((unused)) void *parsed_result,
16610 	__attribute__((unused)) struct cmdline *cl,
16611 	__attribute__((unused)) void *data)
16612 {
16613 #ifdef RTE_LIBRTE_I40E_PMD
16614 	struct cmd_cfg_input_set_result *res = parsed_result;
16615 	enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
16616 	struct rte_pmd_i40e_inset inset;
16617 #endif
16618 	int ret = -ENOTSUP;
16619 
16620 	if (!all_ports_stopped()) {
16621 		printf("Please stop all ports first\n");
16622 		return;
16623 	}
16624 
16625 #ifdef RTE_LIBRTE_I40E_PMD
16626 	if (!strcmp(res->inset_type, "hash_inset"))
16627 		inset_type = INSET_HASH;
16628 	else if (!strcmp(res->inset_type, "fdir_inset"))
16629 		inset_type = INSET_FDIR;
16630 	else if (!strcmp(res->inset_type, "fdir_flx_inset"))
16631 		inset_type = INSET_FDIR_FLX;
16632 	ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
16633 				     &inset, inset_type);
16634 	if (ret) {
16635 		printf("Failed to get input set.\n");
16636 		return;
16637 	}
16638 
16639 	if (!strcmp(res->opt, "get")) {
16640 		ret = rte_pmd_i40e_inset_field_get(inset.inset,
16641 						   res->field_idx);
16642 		if (ret)
16643 			printf("Field index %d is enabled.\n", res->field_idx);
16644 		else
16645 			printf("Field index %d is disabled.\n", res->field_idx);
16646 		return;
16647 	} else if (!strcmp(res->opt, "set"))
16648 		ret = rte_pmd_i40e_inset_field_set(&inset.inset,
16649 						   res->field_idx);
16650 	else if (!strcmp(res->opt, "clear"))
16651 		ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
16652 						     res->field_idx);
16653 	if (ret) {
16654 		printf("Failed to configure input set field.\n");
16655 		return;
16656 	}
16657 
16658 	ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
16659 				     &inset, inset_type);
16660 	if (ret) {
16661 		printf("Failed to set input set.\n");
16662 		return;
16663 	}
16664 #endif
16665 
16666 	if (ret == -ENOTSUP)
16667 		printf("Function not supported\n");
16668 }
16669 
16670 cmdline_parse_token_string_t cmd_cfg_input_set_port =
16671 	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16672 				 port, "port");
16673 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
16674 	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16675 				 cfg, "config");
16676 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
16677 	TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16678 			      port_id, UINT16);
16679 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
16680 	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16681 				 pctype, "pctype");
16682 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
16683 	TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16684 			      pctype_id, UINT8);
16685 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
16686 	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16687 				 inset_type,
16688 				 "hash_inset#fdir_inset#fdir_flx_inset");
16689 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
16690 	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16691 				 opt, "get#set#clear");
16692 cmdline_parse_token_string_t cmd_cfg_input_set_field =
16693 	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16694 				 field, "field");
16695 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
16696 	TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16697 			      field_idx, UINT8);
16698 
16699 cmdline_parse_inst_t cmd_cfg_input_set = {
16700 	.f = cmd_cfg_input_set_parsed,
16701 	.data = NULL,
16702 	.help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
16703 		    "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
16704 	.tokens = {
16705 		(void *)&cmd_cfg_input_set_port,
16706 		(void *)&cmd_cfg_input_set_cfg,
16707 		(void *)&cmd_cfg_input_set_port_id,
16708 		(void *)&cmd_cfg_input_set_pctype,
16709 		(void *)&cmd_cfg_input_set_pctype_id,
16710 		(void *)&cmd_cfg_input_set_inset_type,
16711 		(void *)&cmd_cfg_input_set_opt,
16712 		(void *)&cmd_cfg_input_set_field,
16713 		(void *)&cmd_cfg_input_set_field_idx,
16714 		NULL,
16715 	},
16716 };
16717 
16718 /* Clear input set */
16719 struct cmd_clear_input_set_result {
16720 	cmdline_fixed_string_t port;
16721 	cmdline_fixed_string_t cfg;
16722 	portid_t port_id;
16723 	cmdline_fixed_string_t pctype;
16724 	uint8_t pctype_id;
16725 	cmdline_fixed_string_t inset_type;
16726 	cmdline_fixed_string_t clear;
16727 	cmdline_fixed_string_t all;
16728 };
16729 
16730 static void
16731 cmd_clear_input_set_parsed(
16732 	__attribute__((unused)) void *parsed_result,
16733 	__attribute__((unused)) struct cmdline *cl,
16734 	__attribute__((unused)) void *data)
16735 {
16736 #ifdef RTE_LIBRTE_I40E_PMD
16737 	struct cmd_clear_input_set_result *res = parsed_result;
16738 	enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
16739 	struct rte_pmd_i40e_inset inset;
16740 #endif
16741 	int ret = -ENOTSUP;
16742 
16743 	if (!all_ports_stopped()) {
16744 		printf("Please stop all ports first\n");
16745 		return;
16746 	}
16747 
16748 #ifdef RTE_LIBRTE_I40E_PMD
16749 	if (!strcmp(res->inset_type, "hash_inset"))
16750 		inset_type = INSET_HASH;
16751 	else if (!strcmp(res->inset_type, "fdir_inset"))
16752 		inset_type = INSET_FDIR;
16753 	else if (!strcmp(res->inset_type, "fdir_flx_inset"))
16754 		inset_type = INSET_FDIR_FLX;
16755 
16756 	memset(&inset, 0, sizeof(inset));
16757 
16758 	ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
16759 				     &inset, inset_type);
16760 	if (ret) {
16761 		printf("Failed to clear input set.\n");
16762 		return;
16763 	}
16764 
16765 #endif
16766 
16767 	if (ret == -ENOTSUP)
16768 		printf("Function not supported\n");
16769 }
16770 
16771 cmdline_parse_token_string_t cmd_clear_input_set_port =
16772 	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16773 				 port, "port");
16774 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
16775 	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16776 				 cfg, "config");
16777 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
16778 	TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
16779 			      port_id, UINT16);
16780 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
16781 	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16782 				 pctype, "pctype");
16783 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
16784 	TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
16785 			      pctype_id, UINT8);
16786 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
16787 	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16788 				 inset_type,
16789 				 "hash_inset#fdir_inset#fdir_flx_inset");
16790 cmdline_parse_token_string_t cmd_clear_input_set_clear =
16791 	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16792 				 clear, "clear");
16793 cmdline_parse_token_string_t cmd_clear_input_set_all =
16794 	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16795 				 all, "all");
16796 
16797 cmdline_parse_inst_t cmd_clear_input_set = {
16798 	.f = cmd_clear_input_set_parsed,
16799 	.data = NULL,
16800 	.help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
16801 		    "fdir_inset|fdir_flx_inset clear all",
16802 	.tokens = {
16803 		(void *)&cmd_clear_input_set_port,
16804 		(void *)&cmd_clear_input_set_cfg,
16805 		(void *)&cmd_clear_input_set_port_id,
16806 		(void *)&cmd_clear_input_set_pctype,
16807 		(void *)&cmd_clear_input_set_pctype_id,
16808 		(void *)&cmd_clear_input_set_inset_type,
16809 		(void *)&cmd_clear_input_set_clear,
16810 		(void *)&cmd_clear_input_set_all,
16811 		NULL,
16812 	},
16813 };
16814 
16815 /* show vf stats */
16816 
16817 /* Common result structure for show vf stats */
16818 struct cmd_show_vf_stats_result {
16819 	cmdline_fixed_string_t show;
16820 	cmdline_fixed_string_t vf;
16821 	cmdline_fixed_string_t stats;
16822 	portid_t port_id;
16823 	uint16_t vf_id;
16824 };
16825 
16826 /* Common CLI fields show vf stats*/
16827 cmdline_parse_token_string_t cmd_show_vf_stats_show =
16828 	TOKEN_STRING_INITIALIZER
16829 		(struct cmd_show_vf_stats_result,
16830 		 show, "show");
16831 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
16832 	TOKEN_STRING_INITIALIZER
16833 		(struct cmd_show_vf_stats_result,
16834 		 vf, "vf");
16835 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
16836 	TOKEN_STRING_INITIALIZER
16837 		(struct cmd_show_vf_stats_result,
16838 		 stats, "stats");
16839 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
16840 	TOKEN_NUM_INITIALIZER
16841 		(struct cmd_show_vf_stats_result,
16842 		 port_id, UINT16);
16843 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
16844 	TOKEN_NUM_INITIALIZER
16845 		(struct cmd_show_vf_stats_result,
16846 		 vf_id, UINT16);
16847 
16848 static void
16849 cmd_show_vf_stats_parsed(
16850 	void *parsed_result,
16851 	__attribute__((unused)) struct cmdline *cl,
16852 	__attribute__((unused)) void *data)
16853 {
16854 	struct cmd_show_vf_stats_result *res = parsed_result;
16855 	struct rte_eth_stats stats;
16856 	int ret = -ENOTSUP;
16857 	static const char *nic_stats_border = "########################";
16858 
16859 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16860 		return;
16861 
16862 	memset(&stats, 0, sizeof(stats));
16863 
16864 #ifdef RTE_LIBRTE_I40E_PMD
16865 	if (ret == -ENOTSUP)
16866 		ret = rte_pmd_i40e_get_vf_stats(res->port_id,
16867 						res->vf_id,
16868 						&stats);
16869 #endif
16870 #ifdef RTE_LIBRTE_BNXT_PMD
16871 	if (ret == -ENOTSUP)
16872 		ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
16873 						res->vf_id,
16874 						&stats);
16875 #endif
16876 
16877 	switch (ret) {
16878 	case 0:
16879 		break;
16880 	case -EINVAL:
16881 		printf("invalid vf_id %d\n", res->vf_id);
16882 		break;
16883 	case -ENODEV:
16884 		printf("invalid port_id %d\n", res->port_id);
16885 		break;
16886 	case -ENOTSUP:
16887 		printf("function not implemented\n");
16888 		break;
16889 	default:
16890 		printf("programming error: (%s)\n", strerror(-ret));
16891 	}
16892 
16893 	printf("\n  %s NIC statistics for port %-2d vf %-2d %s\n",
16894 		nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
16895 
16896 	printf("  RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes:  "
16897 	       "%-"PRIu64"\n",
16898 	       stats.ipackets, stats.imissed, stats.ibytes);
16899 	printf("  RX-errors: %-"PRIu64"\n", stats.ierrors);
16900 	printf("  RX-nombuf:  %-10"PRIu64"\n",
16901 	       stats.rx_nombuf);
16902 	printf("  TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes:  "
16903 	       "%-"PRIu64"\n",
16904 	       stats.opackets, stats.oerrors, stats.obytes);
16905 
16906 	printf("  %s############################%s\n",
16907 			       nic_stats_border, nic_stats_border);
16908 }
16909 
16910 cmdline_parse_inst_t cmd_show_vf_stats = {
16911 	.f = cmd_show_vf_stats_parsed,
16912 	.data = NULL,
16913 	.help_str = "show vf stats <port_id> <vf_id>",
16914 	.tokens = {
16915 		(void *)&cmd_show_vf_stats_show,
16916 		(void *)&cmd_show_vf_stats_vf,
16917 		(void *)&cmd_show_vf_stats_stats,
16918 		(void *)&cmd_show_vf_stats_port_id,
16919 		(void *)&cmd_show_vf_stats_vf_id,
16920 		NULL,
16921 	},
16922 };
16923 
16924 /* clear vf stats */
16925 
16926 /* Common result structure for clear vf stats */
16927 struct cmd_clear_vf_stats_result {
16928 	cmdline_fixed_string_t clear;
16929 	cmdline_fixed_string_t vf;
16930 	cmdline_fixed_string_t stats;
16931 	portid_t port_id;
16932 	uint16_t vf_id;
16933 };
16934 
16935 /* Common CLI fields clear vf stats*/
16936 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
16937 	TOKEN_STRING_INITIALIZER
16938 		(struct cmd_clear_vf_stats_result,
16939 		 clear, "clear");
16940 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
16941 	TOKEN_STRING_INITIALIZER
16942 		(struct cmd_clear_vf_stats_result,
16943 		 vf, "vf");
16944 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
16945 	TOKEN_STRING_INITIALIZER
16946 		(struct cmd_clear_vf_stats_result,
16947 		 stats, "stats");
16948 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
16949 	TOKEN_NUM_INITIALIZER
16950 		(struct cmd_clear_vf_stats_result,
16951 		 port_id, UINT16);
16952 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
16953 	TOKEN_NUM_INITIALIZER
16954 		(struct cmd_clear_vf_stats_result,
16955 		 vf_id, UINT16);
16956 
16957 static void
16958 cmd_clear_vf_stats_parsed(
16959 	void *parsed_result,
16960 	__attribute__((unused)) struct cmdline *cl,
16961 	__attribute__((unused)) void *data)
16962 {
16963 	struct cmd_clear_vf_stats_result *res = parsed_result;
16964 	int ret = -ENOTSUP;
16965 
16966 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16967 		return;
16968 
16969 #ifdef RTE_LIBRTE_I40E_PMD
16970 	if (ret == -ENOTSUP)
16971 		ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
16972 						  res->vf_id);
16973 #endif
16974 #ifdef RTE_LIBRTE_BNXT_PMD
16975 	if (ret == -ENOTSUP)
16976 		ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
16977 						  res->vf_id);
16978 #endif
16979 
16980 	switch (ret) {
16981 	case 0:
16982 		break;
16983 	case -EINVAL:
16984 		printf("invalid vf_id %d\n", res->vf_id);
16985 		break;
16986 	case -ENODEV:
16987 		printf("invalid port_id %d\n", res->port_id);
16988 		break;
16989 	case -ENOTSUP:
16990 		printf("function not implemented\n");
16991 		break;
16992 	default:
16993 		printf("programming error: (%s)\n", strerror(-ret));
16994 	}
16995 }
16996 
16997 cmdline_parse_inst_t cmd_clear_vf_stats = {
16998 	.f = cmd_clear_vf_stats_parsed,
16999 	.data = NULL,
17000 	.help_str = "clear vf stats <port_id> <vf_id>",
17001 	.tokens = {
17002 		(void *)&cmd_clear_vf_stats_clear,
17003 		(void *)&cmd_clear_vf_stats_vf,
17004 		(void *)&cmd_clear_vf_stats_stats,
17005 		(void *)&cmd_clear_vf_stats_port_id,
17006 		(void *)&cmd_clear_vf_stats_vf_id,
17007 		NULL,
17008 	},
17009 };
17010 
17011 /* port config pctype mapping reset */
17012 
17013 /* Common result structure for port config pctype mapping reset */
17014 struct cmd_pctype_mapping_reset_result {
17015 	cmdline_fixed_string_t port;
17016 	cmdline_fixed_string_t config;
17017 	portid_t port_id;
17018 	cmdline_fixed_string_t pctype;
17019 	cmdline_fixed_string_t mapping;
17020 	cmdline_fixed_string_t reset;
17021 };
17022 
17023 /* Common CLI fields for port config pctype mapping reset*/
17024 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
17025 	TOKEN_STRING_INITIALIZER
17026 		(struct cmd_pctype_mapping_reset_result,
17027 		 port, "port");
17028 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
17029 	TOKEN_STRING_INITIALIZER
17030 		(struct cmd_pctype_mapping_reset_result,
17031 		 config, "config");
17032 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
17033 	TOKEN_NUM_INITIALIZER
17034 		(struct cmd_pctype_mapping_reset_result,
17035 		 port_id, UINT16);
17036 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
17037 	TOKEN_STRING_INITIALIZER
17038 		(struct cmd_pctype_mapping_reset_result,
17039 		 pctype, "pctype");
17040 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
17041 	TOKEN_STRING_INITIALIZER
17042 		(struct cmd_pctype_mapping_reset_result,
17043 		 mapping, "mapping");
17044 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
17045 	TOKEN_STRING_INITIALIZER
17046 		(struct cmd_pctype_mapping_reset_result,
17047 		 reset, "reset");
17048 
17049 static void
17050 cmd_pctype_mapping_reset_parsed(
17051 	void *parsed_result,
17052 	__attribute__((unused)) struct cmdline *cl,
17053 	__attribute__((unused)) void *data)
17054 {
17055 	struct cmd_pctype_mapping_reset_result *res = parsed_result;
17056 	int ret = -ENOTSUP;
17057 
17058 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17059 		return;
17060 
17061 #ifdef RTE_LIBRTE_I40E_PMD
17062 	ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
17063 #endif
17064 
17065 	switch (ret) {
17066 	case 0:
17067 		break;
17068 	case -ENODEV:
17069 		printf("invalid port_id %d\n", res->port_id);
17070 		break;
17071 	case -ENOTSUP:
17072 		printf("function not implemented\n");
17073 		break;
17074 	default:
17075 		printf("programming error: (%s)\n", strerror(-ret));
17076 	}
17077 }
17078 
17079 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
17080 	.f = cmd_pctype_mapping_reset_parsed,
17081 	.data = NULL,
17082 	.help_str = "port config <port_id> pctype mapping reset",
17083 	.tokens = {
17084 		(void *)&cmd_pctype_mapping_reset_port,
17085 		(void *)&cmd_pctype_mapping_reset_config,
17086 		(void *)&cmd_pctype_mapping_reset_port_id,
17087 		(void *)&cmd_pctype_mapping_reset_pctype,
17088 		(void *)&cmd_pctype_mapping_reset_mapping,
17089 		(void *)&cmd_pctype_mapping_reset_reset,
17090 		NULL,
17091 	},
17092 };
17093 
17094 /* show port pctype mapping */
17095 
17096 /* Common result structure for show port pctype mapping */
17097 struct cmd_pctype_mapping_get_result {
17098 	cmdline_fixed_string_t show;
17099 	cmdline_fixed_string_t port;
17100 	portid_t port_id;
17101 	cmdline_fixed_string_t pctype;
17102 	cmdline_fixed_string_t mapping;
17103 };
17104 
17105 /* Common CLI fields for pctype mapping get */
17106 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
17107 	TOKEN_STRING_INITIALIZER
17108 		(struct cmd_pctype_mapping_get_result,
17109 		 show, "show");
17110 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
17111 	TOKEN_STRING_INITIALIZER
17112 		(struct cmd_pctype_mapping_get_result,
17113 		 port, "port");
17114 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
17115 	TOKEN_NUM_INITIALIZER
17116 		(struct cmd_pctype_mapping_get_result,
17117 		 port_id, UINT16);
17118 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
17119 	TOKEN_STRING_INITIALIZER
17120 		(struct cmd_pctype_mapping_get_result,
17121 		 pctype, "pctype");
17122 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
17123 	TOKEN_STRING_INITIALIZER
17124 		(struct cmd_pctype_mapping_get_result,
17125 		 mapping, "mapping");
17126 
17127 static void
17128 cmd_pctype_mapping_get_parsed(
17129 	void *parsed_result,
17130 	__attribute__((unused)) struct cmdline *cl,
17131 	__attribute__((unused)) void *data)
17132 {
17133 	struct cmd_pctype_mapping_get_result *res = parsed_result;
17134 	int ret = -ENOTSUP;
17135 #ifdef RTE_LIBRTE_I40E_PMD
17136 	struct rte_pmd_i40e_flow_type_mapping
17137 				mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
17138 	int i, j, first_pctype;
17139 #endif
17140 
17141 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17142 		return;
17143 
17144 #ifdef RTE_LIBRTE_I40E_PMD
17145 	ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
17146 #endif
17147 
17148 	switch (ret) {
17149 	case 0:
17150 		break;
17151 	case -ENODEV:
17152 		printf("invalid port_id %d\n", res->port_id);
17153 		return;
17154 	case -ENOTSUP:
17155 		printf("function not implemented\n");
17156 		return;
17157 	default:
17158 		printf("programming error: (%s)\n", strerror(-ret));
17159 		return;
17160 	}
17161 
17162 #ifdef RTE_LIBRTE_I40E_PMD
17163 	for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
17164 		if (mapping[i].pctype != 0ULL) {
17165 			first_pctype = 1;
17166 
17167 			printf("pctype: ");
17168 			for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
17169 				if (mapping[i].pctype & (1ULL << j)) {
17170 					printf(first_pctype ?
17171 					       "%02d" : ",%02d", j);
17172 					first_pctype = 0;
17173 				}
17174 			}
17175 			printf("  ->  flowtype: %02d\n", mapping[i].flow_type);
17176 		}
17177 	}
17178 #endif
17179 }
17180 
17181 cmdline_parse_inst_t cmd_pctype_mapping_get = {
17182 	.f = cmd_pctype_mapping_get_parsed,
17183 	.data = NULL,
17184 	.help_str = "show port <port_id> pctype mapping",
17185 	.tokens = {
17186 		(void *)&cmd_pctype_mapping_get_show,
17187 		(void *)&cmd_pctype_mapping_get_port,
17188 		(void *)&cmd_pctype_mapping_get_port_id,
17189 		(void *)&cmd_pctype_mapping_get_pctype,
17190 		(void *)&cmd_pctype_mapping_get_mapping,
17191 		NULL,
17192 	},
17193 };
17194 
17195 /* port config pctype mapping update */
17196 
17197 /* Common result structure for port config pctype mapping update */
17198 struct cmd_pctype_mapping_update_result {
17199 	cmdline_fixed_string_t port;
17200 	cmdline_fixed_string_t config;
17201 	portid_t port_id;
17202 	cmdline_fixed_string_t pctype;
17203 	cmdline_fixed_string_t mapping;
17204 	cmdline_fixed_string_t update;
17205 	cmdline_fixed_string_t pctype_list;
17206 	uint16_t flow_type;
17207 };
17208 
17209 /* Common CLI fields for pctype mapping update*/
17210 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
17211 	TOKEN_STRING_INITIALIZER
17212 		(struct cmd_pctype_mapping_update_result,
17213 		 port, "port");
17214 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
17215 	TOKEN_STRING_INITIALIZER
17216 		(struct cmd_pctype_mapping_update_result,
17217 		 config, "config");
17218 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
17219 	TOKEN_NUM_INITIALIZER
17220 		(struct cmd_pctype_mapping_update_result,
17221 		 port_id, UINT16);
17222 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
17223 	TOKEN_STRING_INITIALIZER
17224 		(struct cmd_pctype_mapping_update_result,
17225 		 pctype, "pctype");
17226 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
17227 	TOKEN_STRING_INITIALIZER
17228 		(struct cmd_pctype_mapping_update_result,
17229 		 mapping, "mapping");
17230 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
17231 	TOKEN_STRING_INITIALIZER
17232 		(struct cmd_pctype_mapping_update_result,
17233 		 update, "update");
17234 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
17235 	TOKEN_STRING_INITIALIZER
17236 		(struct cmd_pctype_mapping_update_result,
17237 		 pctype_list, NULL);
17238 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
17239 	TOKEN_NUM_INITIALIZER
17240 		(struct cmd_pctype_mapping_update_result,
17241 		 flow_type, UINT16);
17242 
17243 static void
17244 cmd_pctype_mapping_update_parsed(
17245 	void *parsed_result,
17246 	__attribute__((unused)) struct cmdline *cl,
17247 	__attribute__((unused)) void *data)
17248 {
17249 	struct cmd_pctype_mapping_update_result *res = parsed_result;
17250 	int ret = -ENOTSUP;
17251 #ifdef RTE_LIBRTE_I40E_PMD
17252 	struct rte_pmd_i40e_flow_type_mapping mapping;
17253 	unsigned int i;
17254 	unsigned int nb_item;
17255 	unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
17256 #endif
17257 
17258 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17259 		return;
17260 
17261 #ifdef RTE_LIBRTE_I40E_PMD
17262 	nb_item = parse_item_list(res->pctype_list, "pctypes",
17263 				  RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
17264 	mapping.flow_type = res->flow_type;
17265 	for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
17266 		mapping.pctype |= (1ULL << pctype_list[i]);
17267 	ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
17268 						&mapping,
17269 						1,
17270 						0);
17271 #endif
17272 
17273 	switch (ret) {
17274 	case 0:
17275 		break;
17276 	case -EINVAL:
17277 		printf("invalid pctype or flow type\n");
17278 		break;
17279 	case -ENODEV:
17280 		printf("invalid port_id %d\n", res->port_id);
17281 		break;
17282 	case -ENOTSUP:
17283 		printf("function not implemented\n");
17284 		break;
17285 	default:
17286 		printf("programming error: (%s)\n", strerror(-ret));
17287 	}
17288 }
17289 
17290 cmdline_parse_inst_t cmd_pctype_mapping_update = {
17291 	.f = cmd_pctype_mapping_update_parsed,
17292 	.data = NULL,
17293 	.help_str = "port config <port_id> pctype mapping update"
17294 	" <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
17295 	.tokens = {
17296 		(void *)&cmd_pctype_mapping_update_port,
17297 		(void *)&cmd_pctype_mapping_update_config,
17298 		(void *)&cmd_pctype_mapping_update_port_id,
17299 		(void *)&cmd_pctype_mapping_update_pctype,
17300 		(void *)&cmd_pctype_mapping_update_mapping,
17301 		(void *)&cmd_pctype_mapping_update_update,
17302 		(void *)&cmd_pctype_mapping_update_pc_type,
17303 		(void *)&cmd_pctype_mapping_update_flow_type,
17304 		NULL,
17305 	},
17306 };
17307 
17308 /* ptype mapping get */
17309 
17310 /* Common result structure for ptype mapping get */
17311 struct cmd_ptype_mapping_get_result {
17312 	cmdline_fixed_string_t ptype;
17313 	cmdline_fixed_string_t mapping;
17314 	cmdline_fixed_string_t get;
17315 	portid_t port_id;
17316 	uint8_t valid_only;
17317 };
17318 
17319 /* Common CLI fields for ptype mapping get */
17320 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
17321 	TOKEN_STRING_INITIALIZER
17322 		(struct cmd_ptype_mapping_get_result,
17323 		 ptype, "ptype");
17324 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
17325 	TOKEN_STRING_INITIALIZER
17326 		(struct cmd_ptype_mapping_get_result,
17327 		 mapping, "mapping");
17328 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
17329 	TOKEN_STRING_INITIALIZER
17330 		(struct cmd_ptype_mapping_get_result,
17331 		 get, "get");
17332 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
17333 	TOKEN_NUM_INITIALIZER
17334 		(struct cmd_ptype_mapping_get_result,
17335 		 port_id, UINT16);
17336 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
17337 	TOKEN_NUM_INITIALIZER
17338 		(struct cmd_ptype_mapping_get_result,
17339 		 valid_only, UINT8);
17340 
17341 static void
17342 cmd_ptype_mapping_get_parsed(
17343 	void *parsed_result,
17344 	__attribute__((unused)) struct cmdline *cl,
17345 	__attribute__((unused)) void *data)
17346 {
17347 	struct cmd_ptype_mapping_get_result *res = parsed_result;
17348 	int ret = -ENOTSUP;
17349 #ifdef RTE_LIBRTE_I40E_PMD
17350 	int max_ptype_num = 256;
17351 	struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
17352 	uint16_t count;
17353 	int i;
17354 #endif
17355 
17356 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17357 		return;
17358 
17359 #ifdef RTE_LIBRTE_I40E_PMD
17360 	ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
17361 					mapping,
17362 					max_ptype_num,
17363 					&count,
17364 					res->valid_only);
17365 #endif
17366 
17367 	switch (ret) {
17368 	case 0:
17369 		break;
17370 	case -ENODEV:
17371 		printf("invalid port_id %d\n", res->port_id);
17372 		break;
17373 	case -ENOTSUP:
17374 		printf("function not implemented\n");
17375 		break;
17376 	default:
17377 		printf("programming error: (%s)\n", strerror(-ret));
17378 	}
17379 
17380 #ifdef RTE_LIBRTE_I40E_PMD
17381 	if (!ret) {
17382 		for (i = 0; i < count; i++)
17383 			printf("%3d\t0x%08x\n",
17384 				mapping[i].hw_ptype, mapping[i].sw_ptype);
17385 	}
17386 #endif
17387 }
17388 
17389 cmdline_parse_inst_t cmd_ptype_mapping_get = {
17390 	.f = cmd_ptype_mapping_get_parsed,
17391 	.data = NULL,
17392 	.help_str = "ptype mapping get <port_id> <valid_only>",
17393 	.tokens = {
17394 		(void *)&cmd_ptype_mapping_get_ptype,
17395 		(void *)&cmd_ptype_mapping_get_mapping,
17396 		(void *)&cmd_ptype_mapping_get_get,
17397 		(void *)&cmd_ptype_mapping_get_port_id,
17398 		(void *)&cmd_ptype_mapping_get_valid_only,
17399 		NULL,
17400 	},
17401 };
17402 
17403 /* ptype mapping replace */
17404 
17405 /* Common result structure for ptype mapping replace */
17406 struct cmd_ptype_mapping_replace_result {
17407 	cmdline_fixed_string_t ptype;
17408 	cmdline_fixed_string_t mapping;
17409 	cmdline_fixed_string_t replace;
17410 	portid_t port_id;
17411 	uint32_t target;
17412 	uint8_t mask;
17413 	uint32_t pkt_type;
17414 };
17415 
17416 /* Common CLI fields for ptype mapping replace */
17417 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
17418 	TOKEN_STRING_INITIALIZER
17419 		(struct cmd_ptype_mapping_replace_result,
17420 		 ptype, "ptype");
17421 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
17422 	TOKEN_STRING_INITIALIZER
17423 		(struct cmd_ptype_mapping_replace_result,
17424 		 mapping, "mapping");
17425 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
17426 	TOKEN_STRING_INITIALIZER
17427 		(struct cmd_ptype_mapping_replace_result,
17428 		 replace, "replace");
17429 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
17430 	TOKEN_NUM_INITIALIZER
17431 		(struct cmd_ptype_mapping_replace_result,
17432 		 port_id, UINT16);
17433 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
17434 	TOKEN_NUM_INITIALIZER
17435 		(struct cmd_ptype_mapping_replace_result,
17436 		 target, UINT32);
17437 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
17438 	TOKEN_NUM_INITIALIZER
17439 		(struct cmd_ptype_mapping_replace_result,
17440 		 mask, UINT8);
17441 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
17442 	TOKEN_NUM_INITIALIZER
17443 		(struct cmd_ptype_mapping_replace_result,
17444 		 pkt_type, UINT32);
17445 
17446 static void
17447 cmd_ptype_mapping_replace_parsed(
17448 	void *parsed_result,
17449 	__attribute__((unused)) struct cmdline *cl,
17450 	__attribute__((unused)) void *data)
17451 {
17452 	struct cmd_ptype_mapping_replace_result *res = parsed_result;
17453 	int ret = -ENOTSUP;
17454 
17455 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17456 		return;
17457 
17458 #ifdef RTE_LIBRTE_I40E_PMD
17459 	ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
17460 					res->target,
17461 					res->mask,
17462 					res->pkt_type);
17463 #endif
17464 
17465 	switch (ret) {
17466 	case 0:
17467 		break;
17468 	case -EINVAL:
17469 		printf("invalid ptype 0x%8x or 0x%8x\n",
17470 				res->target, res->pkt_type);
17471 		break;
17472 	case -ENODEV:
17473 		printf("invalid port_id %d\n", res->port_id);
17474 		break;
17475 	case -ENOTSUP:
17476 		printf("function not implemented\n");
17477 		break;
17478 	default:
17479 		printf("programming error: (%s)\n", strerror(-ret));
17480 	}
17481 }
17482 
17483 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
17484 	.f = cmd_ptype_mapping_replace_parsed,
17485 	.data = NULL,
17486 	.help_str =
17487 		"ptype mapping replace <port_id> <target> <mask> <pkt_type>",
17488 	.tokens = {
17489 		(void *)&cmd_ptype_mapping_replace_ptype,
17490 		(void *)&cmd_ptype_mapping_replace_mapping,
17491 		(void *)&cmd_ptype_mapping_replace_replace,
17492 		(void *)&cmd_ptype_mapping_replace_port_id,
17493 		(void *)&cmd_ptype_mapping_replace_target,
17494 		(void *)&cmd_ptype_mapping_replace_mask,
17495 		(void *)&cmd_ptype_mapping_replace_pkt_type,
17496 		NULL,
17497 	},
17498 };
17499 
17500 /* ptype mapping reset */
17501 
17502 /* Common result structure for ptype mapping reset */
17503 struct cmd_ptype_mapping_reset_result {
17504 	cmdline_fixed_string_t ptype;
17505 	cmdline_fixed_string_t mapping;
17506 	cmdline_fixed_string_t reset;
17507 	portid_t port_id;
17508 };
17509 
17510 /* Common CLI fields for ptype mapping reset*/
17511 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
17512 	TOKEN_STRING_INITIALIZER
17513 		(struct cmd_ptype_mapping_reset_result,
17514 		 ptype, "ptype");
17515 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
17516 	TOKEN_STRING_INITIALIZER
17517 		(struct cmd_ptype_mapping_reset_result,
17518 		 mapping, "mapping");
17519 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
17520 	TOKEN_STRING_INITIALIZER
17521 		(struct cmd_ptype_mapping_reset_result,
17522 		 reset, "reset");
17523 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
17524 	TOKEN_NUM_INITIALIZER
17525 		(struct cmd_ptype_mapping_reset_result,
17526 		 port_id, UINT16);
17527 
17528 static void
17529 cmd_ptype_mapping_reset_parsed(
17530 	void *parsed_result,
17531 	__attribute__((unused)) struct cmdline *cl,
17532 	__attribute__((unused)) void *data)
17533 {
17534 	struct cmd_ptype_mapping_reset_result *res = parsed_result;
17535 	int ret = -ENOTSUP;
17536 
17537 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17538 		return;
17539 
17540 #ifdef RTE_LIBRTE_I40E_PMD
17541 	ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
17542 #endif
17543 
17544 	switch (ret) {
17545 	case 0:
17546 		break;
17547 	case -ENODEV:
17548 		printf("invalid port_id %d\n", res->port_id);
17549 		break;
17550 	case -ENOTSUP:
17551 		printf("function not implemented\n");
17552 		break;
17553 	default:
17554 		printf("programming error: (%s)\n", strerror(-ret));
17555 	}
17556 }
17557 
17558 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
17559 	.f = cmd_ptype_mapping_reset_parsed,
17560 	.data = NULL,
17561 	.help_str = "ptype mapping reset <port_id>",
17562 	.tokens = {
17563 		(void *)&cmd_ptype_mapping_reset_ptype,
17564 		(void *)&cmd_ptype_mapping_reset_mapping,
17565 		(void *)&cmd_ptype_mapping_reset_reset,
17566 		(void *)&cmd_ptype_mapping_reset_port_id,
17567 		NULL,
17568 	},
17569 };
17570 
17571 /* ptype mapping update */
17572 
17573 /* Common result structure for ptype mapping update */
17574 struct cmd_ptype_mapping_update_result {
17575 	cmdline_fixed_string_t ptype;
17576 	cmdline_fixed_string_t mapping;
17577 	cmdline_fixed_string_t reset;
17578 	portid_t port_id;
17579 	uint8_t hw_ptype;
17580 	uint32_t sw_ptype;
17581 };
17582 
17583 /* Common CLI fields for ptype mapping update*/
17584 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
17585 	TOKEN_STRING_INITIALIZER
17586 		(struct cmd_ptype_mapping_update_result,
17587 		 ptype, "ptype");
17588 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
17589 	TOKEN_STRING_INITIALIZER
17590 		(struct cmd_ptype_mapping_update_result,
17591 		 mapping, "mapping");
17592 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
17593 	TOKEN_STRING_INITIALIZER
17594 		(struct cmd_ptype_mapping_update_result,
17595 		 reset, "update");
17596 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
17597 	TOKEN_NUM_INITIALIZER
17598 		(struct cmd_ptype_mapping_update_result,
17599 		 port_id, UINT16);
17600 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
17601 	TOKEN_NUM_INITIALIZER
17602 		(struct cmd_ptype_mapping_update_result,
17603 		 hw_ptype, UINT8);
17604 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
17605 	TOKEN_NUM_INITIALIZER
17606 		(struct cmd_ptype_mapping_update_result,
17607 		 sw_ptype, UINT32);
17608 
17609 static void
17610 cmd_ptype_mapping_update_parsed(
17611 	void *parsed_result,
17612 	__attribute__((unused)) struct cmdline *cl,
17613 	__attribute__((unused)) void *data)
17614 {
17615 	struct cmd_ptype_mapping_update_result *res = parsed_result;
17616 	int ret = -ENOTSUP;
17617 #ifdef RTE_LIBRTE_I40E_PMD
17618 	struct rte_pmd_i40e_ptype_mapping mapping;
17619 #endif
17620 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17621 		return;
17622 
17623 #ifdef RTE_LIBRTE_I40E_PMD
17624 	mapping.hw_ptype = res->hw_ptype;
17625 	mapping.sw_ptype = res->sw_ptype;
17626 	ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
17627 						&mapping,
17628 						1,
17629 						0);
17630 #endif
17631 
17632 	switch (ret) {
17633 	case 0:
17634 		break;
17635 	case -EINVAL:
17636 		printf("invalid ptype 0x%8x\n", res->sw_ptype);
17637 		break;
17638 	case -ENODEV:
17639 		printf("invalid port_id %d\n", res->port_id);
17640 		break;
17641 	case -ENOTSUP:
17642 		printf("function not implemented\n");
17643 		break;
17644 	default:
17645 		printf("programming error: (%s)\n", strerror(-ret));
17646 	}
17647 }
17648 
17649 cmdline_parse_inst_t cmd_ptype_mapping_update = {
17650 	.f = cmd_ptype_mapping_update_parsed,
17651 	.data = NULL,
17652 	.help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
17653 	.tokens = {
17654 		(void *)&cmd_ptype_mapping_update_ptype,
17655 		(void *)&cmd_ptype_mapping_update_mapping,
17656 		(void *)&cmd_ptype_mapping_update_update,
17657 		(void *)&cmd_ptype_mapping_update_port_id,
17658 		(void *)&cmd_ptype_mapping_update_hw_ptype,
17659 		(void *)&cmd_ptype_mapping_update_sw_ptype,
17660 		NULL,
17661 	},
17662 };
17663 
17664 /* Common result structure for file commands */
17665 struct cmd_cmdfile_result {
17666 	cmdline_fixed_string_t load;
17667 	cmdline_fixed_string_t filename;
17668 };
17669 
17670 /* Common CLI fields for file commands */
17671 cmdline_parse_token_string_t cmd_load_cmdfile =
17672 	TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
17673 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
17674 	TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
17675 
17676 static void
17677 cmd_load_from_file_parsed(
17678 	void *parsed_result,
17679 	__attribute__((unused)) struct cmdline *cl,
17680 	__attribute__((unused)) void *data)
17681 {
17682 	struct cmd_cmdfile_result *res = parsed_result;
17683 
17684 	cmdline_read_from_file(res->filename);
17685 }
17686 
17687 cmdline_parse_inst_t cmd_load_from_file = {
17688 	.f = cmd_load_from_file_parsed,
17689 	.data = NULL,
17690 	.help_str = "load <filename>",
17691 	.tokens = {
17692 		(void *)&cmd_load_cmdfile,
17693 		(void *)&cmd_load_cmdfile_filename,
17694 		NULL,
17695 	},
17696 };
17697 
17698 /* Get Rx offloads capabilities */
17699 struct cmd_rx_offload_get_capa_result {
17700 	cmdline_fixed_string_t show;
17701 	cmdline_fixed_string_t port;
17702 	portid_t port_id;
17703 	cmdline_fixed_string_t rx_offload;
17704 	cmdline_fixed_string_t capabilities;
17705 };
17706 
17707 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
17708 	TOKEN_STRING_INITIALIZER
17709 		(struct cmd_rx_offload_get_capa_result,
17710 		 show, "show");
17711 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
17712 	TOKEN_STRING_INITIALIZER
17713 		(struct cmd_rx_offload_get_capa_result,
17714 		 port, "port");
17715 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
17716 	TOKEN_NUM_INITIALIZER
17717 		(struct cmd_rx_offload_get_capa_result,
17718 		 port_id, UINT16);
17719 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
17720 	TOKEN_STRING_INITIALIZER
17721 		(struct cmd_rx_offload_get_capa_result,
17722 		 rx_offload, "rx_offload");
17723 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
17724 	TOKEN_STRING_INITIALIZER
17725 		(struct cmd_rx_offload_get_capa_result,
17726 		 capabilities, "capabilities");
17727 
17728 static void
17729 print_rx_offloads(uint64_t offloads)
17730 {
17731 	uint64_t single_offload;
17732 	int begin;
17733 	int end;
17734 	int bit;
17735 
17736 	if (offloads == 0)
17737 		return;
17738 
17739 	begin = __builtin_ctzll(offloads);
17740 	end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
17741 
17742 	single_offload = 1 << begin;
17743 	for (bit = begin; bit < end; bit++) {
17744 		if (offloads & single_offload)
17745 			printf(" %s",
17746 			       rte_eth_dev_rx_offload_name(single_offload));
17747 		single_offload <<= 1;
17748 	}
17749 }
17750 
17751 static void
17752 cmd_rx_offload_get_capa_parsed(
17753 	void *parsed_result,
17754 	__attribute__((unused)) struct cmdline *cl,
17755 	__attribute__((unused)) void *data)
17756 {
17757 	struct cmd_rx_offload_get_capa_result *res = parsed_result;
17758 	struct rte_eth_dev_info dev_info;
17759 	portid_t port_id = res->port_id;
17760 	uint64_t queue_offloads;
17761 	uint64_t port_offloads;
17762 
17763 	rte_eth_dev_info_get(port_id, &dev_info);
17764 	queue_offloads = dev_info.rx_queue_offload_capa;
17765 	port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
17766 
17767 	printf("Rx Offloading Capabilities of port %d :\n", port_id);
17768 	printf("  Per Queue :");
17769 	print_rx_offloads(queue_offloads);
17770 
17771 	printf("\n");
17772 	printf("  Per Port  :");
17773 	print_rx_offloads(port_offloads);
17774 	printf("\n\n");
17775 }
17776 
17777 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
17778 	.f = cmd_rx_offload_get_capa_parsed,
17779 	.data = NULL,
17780 	.help_str = "show port <port_id> rx_offload capabilities",
17781 	.tokens = {
17782 		(void *)&cmd_rx_offload_get_capa_show,
17783 		(void *)&cmd_rx_offload_get_capa_port,
17784 		(void *)&cmd_rx_offload_get_capa_port_id,
17785 		(void *)&cmd_rx_offload_get_capa_rx_offload,
17786 		(void *)&cmd_rx_offload_get_capa_capabilities,
17787 		NULL,
17788 	}
17789 };
17790 
17791 /* Get Rx offloads configuration */
17792 struct cmd_rx_offload_get_configuration_result {
17793 	cmdline_fixed_string_t show;
17794 	cmdline_fixed_string_t port;
17795 	portid_t port_id;
17796 	cmdline_fixed_string_t rx_offload;
17797 	cmdline_fixed_string_t configuration;
17798 };
17799 
17800 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
17801 	TOKEN_STRING_INITIALIZER
17802 		(struct cmd_rx_offload_get_configuration_result,
17803 		 show, "show");
17804 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
17805 	TOKEN_STRING_INITIALIZER
17806 		(struct cmd_rx_offload_get_configuration_result,
17807 		 port, "port");
17808 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
17809 	TOKEN_NUM_INITIALIZER
17810 		(struct cmd_rx_offload_get_configuration_result,
17811 		 port_id, UINT16);
17812 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
17813 	TOKEN_STRING_INITIALIZER
17814 		(struct cmd_rx_offload_get_configuration_result,
17815 		 rx_offload, "rx_offload");
17816 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
17817 	TOKEN_STRING_INITIALIZER
17818 		(struct cmd_rx_offload_get_configuration_result,
17819 		 configuration, "configuration");
17820 
17821 static void
17822 cmd_rx_offload_get_configuration_parsed(
17823 	void *parsed_result,
17824 	__attribute__((unused)) struct cmdline *cl,
17825 	__attribute__((unused)) void *data)
17826 {
17827 	struct cmd_rx_offload_get_configuration_result *res = parsed_result;
17828 	struct rte_eth_dev_info dev_info;
17829 	portid_t port_id = res->port_id;
17830 	struct rte_port *port = &ports[port_id];
17831 	uint64_t port_offloads;
17832 	uint64_t queue_offloads;
17833 	uint16_t nb_rx_queues;
17834 	int q;
17835 
17836 	printf("Rx Offloading Configuration of port %d :\n", port_id);
17837 
17838 	port_offloads = port->dev_conf.rxmode.offloads;
17839 	printf("  Port :");
17840 	print_rx_offloads(port_offloads);
17841 	printf("\n");
17842 
17843 	rte_eth_dev_info_get(port_id, &dev_info);
17844 	nb_rx_queues = dev_info.nb_rx_queues;
17845 	for (q = 0; q < nb_rx_queues; q++) {
17846 		queue_offloads = port->rx_conf[q].offloads;
17847 		printf("  Queue[%2d] :", q);
17848 		print_rx_offloads(queue_offloads);
17849 		printf("\n");
17850 	}
17851 	printf("\n");
17852 }
17853 
17854 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
17855 	.f = cmd_rx_offload_get_configuration_parsed,
17856 	.data = NULL,
17857 	.help_str = "show port <port_id> rx_offload configuration",
17858 	.tokens = {
17859 		(void *)&cmd_rx_offload_get_configuration_show,
17860 		(void *)&cmd_rx_offload_get_configuration_port,
17861 		(void *)&cmd_rx_offload_get_configuration_port_id,
17862 		(void *)&cmd_rx_offload_get_configuration_rx_offload,
17863 		(void *)&cmd_rx_offload_get_configuration_configuration,
17864 		NULL,
17865 	}
17866 };
17867 
17868 /* Enable/Disable a per port offloading */
17869 struct cmd_config_per_port_rx_offload_result {
17870 	cmdline_fixed_string_t port;
17871 	cmdline_fixed_string_t config;
17872 	portid_t port_id;
17873 	cmdline_fixed_string_t rx_offload;
17874 	cmdline_fixed_string_t offload;
17875 	cmdline_fixed_string_t on_off;
17876 };
17877 
17878 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
17879 	TOKEN_STRING_INITIALIZER
17880 		(struct cmd_config_per_port_rx_offload_result,
17881 		 port, "port");
17882 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
17883 	TOKEN_STRING_INITIALIZER
17884 		(struct cmd_config_per_port_rx_offload_result,
17885 		 config, "config");
17886 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
17887 	TOKEN_NUM_INITIALIZER
17888 		(struct cmd_config_per_port_rx_offload_result,
17889 		 port_id, UINT16);
17890 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
17891 	TOKEN_STRING_INITIALIZER
17892 		(struct cmd_config_per_port_rx_offload_result,
17893 		 rx_offload, "rx_offload");
17894 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
17895 	TOKEN_STRING_INITIALIZER
17896 		(struct cmd_config_per_port_rx_offload_result,
17897 		 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
17898 			   "qinq_strip#outer_ipv4_cksum#macsec_strip#"
17899 			   "header_split#vlan_filter#vlan_extend#jumbo_frame#"
17900 			   "crc_strip#scatter#timestamp#security#keep_crc");
17901 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
17902 	TOKEN_STRING_INITIALIZER
17903 		(struct cmd_config_per_port_rx_offload_result,
17904 		 on_off, "on#off");
17905 
17906 static uint64_t
17907 search_rx_offload(const char *name)
17908 {
17909 	uint64_t single_offload;
17910 	const char *single_name;
17911 	int found = 0;
17912 	unsigned int bit;
17913 
17914 	single_offload = 1;
17915 	for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
17916 		single_name = rte_eth_dev_rx_offload_name(single_offload);
17917 		if (!strcasecmp(single_name, name)) {
17918 			found = 1;
17919 			break;
17920 		}
17921 		single_offload <<= 1;
17922 	}
17923 
17924 	if (found)
17925 		return single_offload;
17926 
17927 	return 0;
17928 }
17929 
17930 static void
17931 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
17932 				__attribute__((unused)) struct cmdline *cl,
17933 				__attribute__((unused)) void *data)
17934 {
17935 	struct cmd_config_per_port_rx_offload_result *res = parsed_result;
17936 	portid_t port_id = res->port_id;
17937 	struct rte_eth_dev_info dev_info;
17938 	struct rte_port *port = &ports[port_id];
17939 	uint64_t single_offload;
17940 	uint16_t nb_rx_queues;
17941 	int q;
17942 
17943 	if (port->port_status != RTE_PORT_STOPPED) {
17944 		printf("Error: Can't config offload when Port %d "
17945 		       "is not stopped\n", port_id);
17946 		return;
17947 	}
17948 
17949 	single_offload = search_rx_offload(res->offload);
17950 	if (single_offload == 0) {
17951 		printf("Unknown offload name: %s\n", res->offload);
17952 		return;
17953 	}
17954 
17955 	rte_eth_dev_info_get(port_id, &dev_info);
17956 	nb_rx_queues = dev_info.nb_rx_queues;
17957 	if (!strcmp(res->on_off, "on")) {
17958 		port->dev_conf.rxmode.offloads |= single_offload;
17959 		for (q = 0; q < nb_rx_queues; q++)
17960 			port->rx_conf[q].offloads |= single_offload;
17961 	} else {
17962 		port->dev_conf.rxmode.offloads &= ~single_offload;
17963 		for (q = 0; q < nb_rx_queues; q++)
17964 			port->rx_conf[q].offloads &= ~single_offload;
17965 	}
17966 
17967 	cmd_reconfig_device_queue(port_id, 1, 1);
17968 }
17969 
17970 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
17971 	.f = cmd_config_per_port_rx_offload_parsed,
17972 	.data = NULL,
17973 	.help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
17974 		    "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
17975 		    "macsec_strip|header_split|vlan_filter|vlan_extend|"
17976 		    "jumbo_frame|crc_strip|scatter|timestamp|security|keep_crc "
17977 		    "on|off",
17978 	.tokens = {
17979 		(void *)&cmd_config_per_port_rx_offload_result_port,
17980 		(void *)&cmd_config_per_port_rx_offload_result_config,
17981 		(void *)&cmd_config_per_port_rx_offload_result_port_id,
17982 		(void *)&cmd_config_per_port_rx_offload_result_rx_offload,
17983 		(void *)&cmd_config_per_port_rx_offload_result_offload,
17984 		(void *)&cmd_config_per_port_rx_offload_result_on_off,
17985 		NULL,
17986 	}
17987 };
17988 
17989 /* Enable/Disable a per queue offloading */
17990 struct cmd_config_per_queue_rx_offload_result {
17991 	cmdline_fixed_string_t port;
17992 	portid_t port_id;
17993 	cmdline_fixed_string_t rxq;
17994 	uint16_t queue_id;
17995 	cmdline_fixed_string_t rx_offload;
17996 	cmdline_fixed_string_t offload;
17997 	cmdline_fixed_string_t on_off;
17998 };
17999 
18000 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
18001 	TOKEN_STRING_INITIALIZER
18002 		(struct cmd_config_per_queue_rx_offload_result,
18003 		 port, "port");
18004 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
18005 	TOKEN_NUM_INITIALIZER
18006 		(struct cmd_config_per_queue_rx_offload_result,
18007 		 port_id, UINT16);
18008 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
18009 	TOKEN_STRING_INITIALIZER
18010 		(struct cmd_config_per_queue_rx_offload_result,
18011 		 rxq, "rxq");
18012 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
18013 	TOKEN_NUM_INITIALIZER
18014 		(struct cmd_config_per_queue_rx_offload_result,
18015 		 queue_id, UINT16);
18016 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
18017 	TOKEN_STRING_INITIALIZER
18018 		(struct cmd_config_per_queue_rx_offload_result,
18019 		 rx_offload, "rx_offload");
18020 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
18021 	TOKEN_STRING_INITIALIZER
18022 		(struct cmd_config_per_queue_rx_offload_result,
18023 		 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
18024 			   "qinq_strip#outer_ipv4_cksum#macsec_strip#"
18025 			   "header_split#vlan_filter#vlan_extend#jumbo_frame#"
18026 			   "crc_strip#scatter#timestamp#security#keep_crc");
18027 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
18028 	TOKEN_STRING_INITIALIZER
18029 		(struct cmd_config_per_queue_rx_offload_result,
18030 		 on_off, "on#off");
18031 
18032 static void
18033 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
18034 				__attribute__((unused)) struct cmdline *cl,
18035 				__attribute__((unused)) void *data)
18036 {
18037 	struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
18038 	struct rte_eth_dev_info dev_info;
18039 	portid_t port_id = res->port_id;
18040 	uint16_t queue_id = res->queue_id;
18041 	struct rte_port *port = &ports[port_id];
18042 	uint64_t single_offload;
18043 
18044 	if (port->port_status != RTE_PORT_STOPPED) {
18045 		printf("Error: Can't config offload when Port %d "
18046 		       "is not stopped\n", port_id);
18047 		return;
18048 	}
18049 
18050 	rte_eth_dev_info_get(port_id, &dev_info);
18051 	if (queue_id >= dev_info.nb_rx_queues) {
18052 		printf("Error: input queue_id should be 0 ... "
18053 		       "%d\n", dev_info.nb_rx_queues - 1);
18054 		return;
18055 	}
18056 
18057 	single_offload = search_rx_offload(res->offload);
18058 	if (single_offload == 0) {
18059 		printf("Unknown offload name: %s\n", res->offload);
18060 		return;
18061 	}
18062 
18063 	if (!strcmp(res->on_off, "on"))
18064 		port->rx_conf[queue_id].offloads |= single_offload;
18065 	else
18066 		port->rx_conf[queue_id].offloads &= ~single_offload;
18067 
18068 	cmd_reconfig_device_queue(port_id, 1, 1);
18069 }
18070 
18071 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
18072 	.f = cmd_config_per_queue_rx_offload_parsed,
18073 	.data = NULL,
18074 	.help_str = "port <port_id> rxq <queue_id> rx_offload "
18075 		    "vlan_strip|ipv4_cksum|"
18076 		    "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
18077 		    "macsec_strip|header_split|vlan_filter|vlan_extend|"
18078 		    "jumbo_frame|crc_strip|scatter|timestamp|security|keep_crc "
18079 		    "on|off",
18080 	.tokens = {
18081 		(void *)&cmd_config_per_queue_rx_offload_result_port,
18082 		(void *)&cmd_config_per_queue_rx_offload_result_port_id,
18083 		(void *)&cmd_config_per_queue_rx_offload_result_rxq,
18084 		(void *)&cmd_config_per_queue_rx_offload_result_queue_id,
18085 		(void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
18086 		(void *)&cmd_config_per_queue_rx_offload_result_offload,
18087 		(void *)&cmd_config_per_queue_rx_offload_result_on_off,
18088 		NULL,
18089 	}
18090 };
18091 
18092 /* Get Tx offloads capabilities */
18093 struct cmd_tx_offload_get_capa_result {
18094 	cmdline_fixed_string_t show;
18095 	cmdline_fixed_string_t port;
18096 	portid_t port_id;
18097 	cmdline_fixed_string_t tx_offload;
18098 	cmdline_fixed_string_t capabilities;
18099 };
18100 
18101 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
18102 	TOKEN_STRING_INITIALIZER
18103 		(struct cmd_tx_offload_get_capa_result,
18104 		 show, "show");
18105 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
18106 	TOKEN_STRING_INITIALIZER
18107 		(struct cmd_tx_offload_get_capa_result,
18108 		 port, "port");
18109 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
18110 	TOKEN_NUM_INITIALIZER
18111 		(struct cmd_tx_offload_get_capa_result,
18112 		 port_id, UINT16);
18113 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
18114 	TOKEN_STRING_INITIALIZER
18115 		(struct cmd_tx_offload_get_capa_result,
18116 		 tx_offload, "tx_offload");
18117 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
18118 	TOKEN_STRING_INITIALIZER
18119 		(struct cmd_tx_offload_get_capa_result,
18120 		 capabilities, "capabilities");
18121 
18122 static void
18123 print_tx_offloads(uint64_t offloads)
18124 {
18125 	uint64_t single_offload;
18126 	int begin;
18127 	int end;
18128 	int bit;
18129 
18130 	if (offloads == 0)
18131 		return;
18132 
18133 	begin = __builtin_ctzll(offloads);
18134 	end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
18135 
18136 	single_offload = 1 << begin;
18137 	for (bit = begin; bit < end; bit++) {
18138 		if (offloads & single_offload)
18139 			printf(" %s",
18140 			       rte_eth_dev_tx_offload_name(single_offload));
18141 		single_offload <<= 1;
18142 	}
18143 }
18144 
18145 static void
18146 cmd_tx_offload_get_capa_parsed(
18147 	void *parsed_result,
18148 	__attribute__((unused)) struct cmdline *cl,
18149 	__attribute__((unused)) void *data)
18150 {
18151 	struct cmd_tx_offload_get_capa_result *res = parsed_result;
18152 	struct rte_eth_dev_info dev_info;
18153 	portid_t port_id = res->port_id;
18154 	uint64_t queue_offloads;
18155 	uint64_t port_offloads;
18156 
18157 	rte_eth_dev_info_get(port_id, &dev_info);
18158 	queue_offloads = dev_info.tx_queue_offload_capa;
18159 	port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
18160 
18161 	printf("Tx Offloading Capabilities of port %d :\n", port_id);
18162 	printf("  Per Queue :");
18163 	print_tx_offloads(queue_offloads);
18164 
18165 	printf("\n");
18166 	printf("  Per Port  :");
18167 	print_tx_offloads(port_offloads);
18168 	printf("\n\n");
18169 }
18170 
18171 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
18172 	.f = cmd_tx_offload_get_capa_parsed,
18173 	.data = NULL,
18174 	.help_str = "show port <port_id> tx_offload capabilities",
18175 	.tokens = {
18176 		(void *)&cmd_tx_offload_get_capa_show,
18177 		(void *)&cmd_tx_offload_get_capa_port,
18178 		(void *)&cmd_tx_offload_get_capa_port_id,
18179 		(void *)&cmd_tx_offload_get_capa_tx_offload,
18180 		(void *)&cmd_tx_offload_get_capa_capabilities,
18181 		NULL,
18182 	}
18183 };
18184 
18185 /* Get Tx offloads configuration */
18186 struct cmd_tx_offload_get_configuration_result {
18187 	cmdline_fixed_string_t show;
18188 	cmdline_fixed_string_t port;
18189 	portid_t port_id;
18190 	cmdline_fixed_string_t tx_offload;
18191 	cmdline_fixed_string_t configuration;
18192 };
18193 
18194 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
18195 	TOKEN_STRING_INITIALIZER
18196 		(struct cmd_tx_offload_get_configuration_result,
18197 		 show, "show");
18198 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
18199 	TOKEN_STRING_INITIALIZER
18200 		(struct cmd_tx_offload_get_configuration_result,
18201 		 port, "port");
18202 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
18203 	TOKEN_NUM_INITIALIZER
18204 		(struct cmd_tx_offload_get_configuration_result,
18205 		 port_id, UINT16);
18206 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
18207 	TOKEN_STRING_INITIALIZER
18208 		(struct cmd_tx_offload_get_configuration_result,
18209 		 tx_offload, "tx_offload");
18210 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
18211 	TOKEN_STRING_INITIALIZER
18212 		(struct cmd_tx_offload_get_configuration_result,
18213 		 configuration, "configuration");
18214 
18215 static void
18216 cmd_tx_offload_get_configuration_parsed(
18217 	void *parsed_result,
18218 	__attribute__((unused)) struct cmdline *cl,
18219 	__attribute__((unused)) void *data)
18220 {
18221 	struct cmd_tx_offload_get_configuration_result *res = parsed_result;
18222 	struct rte_eth_dev_info dev_info;
18223 	portid_t port_id = res->port_id;
18224 	struct rte_port *port = &ports[port_id];
18225 	uint64_t port_offloads;
18226 	uint64_t queue_offloads;
18227 	uint16_t nb_tx_queues;
18228 	int q;
18229 
18230 	printf("Tx Offloading Configuration of port %d :\n", port_id);
18231 
18232 	port_offloads = port->dev_conf.txmode.offloads;
18233 	printf("  Port :");
18234 	print_tx_offloads(port_offloads);
18235 	printf("\n");
18236 
18237 	rte_eth_dev_info_get(port_id, &dev_info);
18238 	nb_tx_queues = dev_info.nb_tx_queues;
18239 	for (q = 0; q < nb_tx_queues; q++) {
18240 		queue_offloads = port->tx_conf[q].offloads;
18241 		printf("  Queue[%2d] :", q);
18242 		print_tx_offloads(queue_offloads);
18243 		printf("\n");
18244 	}
18245 	printf("\n");
18246 }
18247 
18248 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
18249 	.f = cmd_tx_offload_get_configuration_parsed,
18250 	.data = NULL,
18251 	.help_str = "show port <port_id> tx_offload configuration",
18252 	.tokens = {
18253 		(void *)&cmd_tx_offload_get_configuration_show,
18254 		(void *)&cmd_tx_offload_get_configuration_port,
18255 		(void *)&cmd_tx_offload_get_configuration_port_id,
18256 		(void *)&cmd_tx_offload_get_configuration_tx_offload,
18257 		(void *)&cmd_tx_offload_get_configuration_configuration,
18258 		NULL,
18259 	}
18260 };
18261 
18262 /* Enable/Disable a per port offloading */
18263 struct cmd_config_per_port_tx_offload_result {
18264 	cmdline_fixed_string_t port;
18265 	cmdline_fixed_string_t config;
18266 	portid_t port_id;
18267 	cmdline_fixed_string_t tx_offload;
18268 	cmdline_fixed_string_t offload;
18269 	cmdline_fixed_string_t on_off;
18270 };
18271 
18272 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
18273 	TOKEN_STRING_INITIALIZER
18274 		(struct cmd_config_per_port_tx_offload_result,
18275 		 port, "port");
18276 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
18277 	TOKEN_STRING_INITIALIZER
18278 		(struct cmd_config_per_port_tx_offload_result,
18279 		 config, "config");
18280 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
18281 	TOKEN_NUM_INITIALIZER
18282 		(struct cmd_config_per_port_tx_offload_result,
18283 		 port_id, UINT16);
18284 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
18285 	TOKEN_STRING_INITIALIZER
18286 		(struct cmd_config_per_port_tx_offload_result,
18287 		 tx_offload, "tx_offload");
18288 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
18289 	TOKEN_STRING_INITIALIZER
18290 		(struct cmd_config_per_port_tx_offload_result,
18291 		 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18292 			  "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18293 			  "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18294 			  "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18295 			  "mt_lockfree#multi_segs#mbuf_fast_free#security#"
18296 			  "match_metadata");
18297 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
18298 	TOKEN_STRING_INITIALIZER
18299 		(struct cmd_config_per_port_tx_offload_result,
18300 		 on_off, "on#off");
18301 
18302 static uint64_t
18303 search_tx_offload(const char *name)
18304 {
18305 	uint64_t single_offload;
18306 	const char *single_name;
18307 	int found = 0;
18308 	unsigned int bit;
18309 
18310 	single_offload = 1;
18311 	for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
18312 		single_name = rte_eth_dev_tx_offload_name(single_offload);
18313 		if (single_name == NULL)
18314 			break;
18315 		if (!strcasecmp(single_name, name)) {
18316 			found = 1;
18317 			break;
18318 		} else if (!strcasecmp(single_name, "UNKNOWN"))
18319 			break;
18320 		single_offload <<= 1;
18321 	}
18322 
18323 	if (found)
18324 		return single_offload;
18325 
18326 	return 0;
18327 }
18328 
18329 static void
18330 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
18331 				__attribute__((unused)) struct cmdline *cl,
18332 				__attribute__((unused)) void *data)
18333 {
18334 	struct cmd_config_per_port_tx_offload_result *res = parsed_result;
18335 	portid_t port_id = res->port_id;
18336 	struct rte_eth_dev_info dev_info;
18337 	struct rte_port *port = &ports[port_id];
18338 	uint64_t single_offload;
18339 	uint16_t nb_tx_queues;
18340 	int q;
18341 
18342 	if (port->port_status != RTE_PORT_STOPPED) {
18343 		printf("Error: Can't config offload when Port %d "
18344 		       "is not stopped\n", port_id);
18345 		return;
18346 	}
18347 
18348 	single_offload = search_tx_offload(res->offload);
18349 	if (single_offload == 0) {
18350 		printf("Unknown offload name: %s\n", res->offload);
18351 		return;
18352 	}
18353 
18354 	rte_eth_dev_info_get(port_id, &dev_info);
18355 	nb_tx_queues = dev_info.nb_tx_queues;
18356 	if (!strcmp(res->on_off, "on")) {
18357 		port->dev_conf.txmode.offloads |= single_offload;
18358 		for (q = 0; q < nb_tx_queues; q++)
18359 			port->tx_conf[q].offloads |= single_offload;
18360 	} else {
18361 		port->dev_conf.txmode.offloads &= ~single_offload;
18362 		for (q = 0; q < nb_tx_queues; q++)
18363 			port->tx_conf[q].offloads &= ~single_offload;
18364 	}
18365 
18366 	cmd_reconfig_device_queue(port_id, 1, 1);
18367 }
18368 
18369 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
18370 	.f = cmd_config_per_port_tx_offload_parsed,
18371 	.data = NULL,
18372 	.help_str = "port config <port_id> tx_offload "
18373 		    "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
18374 		    "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
18375 		    "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
18376 		    "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
18377 		    "mt_lockfree|multi_segs|mbuf_fast_free|security|"
18378 		    "match_metadata on|off",
18379 	.tokens = {
18380 		(void *)&cmd_config_per_port_tx_offload_result_port,
18381 		(void *)&cmd_config_per_port_tx_offload_result_config,
18382 		(void *)&cmd_config_per_port_tx_offload_result_port_id,
18383 		(void *)&cmd_config_per_port_tx_offload_result_tx_offload,
18384 		(void *)&cmd_config_per_port_tx_offload_result_offload,
18385 		(void *)&cmd_config_per_port_tx_offload_result_on_off,
18386 		NULL,
18387 	}
18388 };
18389 
18390 /* Enable/Disable a per queue offloading */
18391 struct cmd_config_per_queue_tx_offload_result {
18392 	cmdline_fixed_string_t port;
18393 	portid_t port_id;
18394 	cmdline_fixed_string_t txq;
18395 	uint16_t queue_id;
18396 	cmdline_fixed_string_t tx_offload;
18397 	cmdline_fixed_string_t offload;
18398 	cmdline_fixed_string_t on_off;
18399 };
18400 
18401 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
18402 	TOKEN_STRING_INITIALIZER
18403 		(struct cmd_config_per_queue_tx_offload_result,
18404 		 port, "port");
18405 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
18406 	TOKEN_NUM_INITIALIZER
18407 		(struct cmd_config_per_queue_tx_offload_result,
18408 		 port_id, UINT16);
18409 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
18410 	TOKEN_STRING_INITIALIZER
18411 		(struct cmd_config_per_queue_tx_offload_result,
18412 		 txq, "txq");
18413 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
18414 	TOKEN_NUM_INITIALIZER
18415 		(struct cmd_config_per_queue_tx_offload_result,
18416 		 queue_id, UINT16);
18417 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
18418 	TOKEN_STRING_INITIALIZER
18419 		(struct cmd_config_per_queue_tx_offload_result,
18420 		 tx_offload, "tx_offload");
18421 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
18422 	TOKEN_STRING_INITIALIZER
18423 		(struct cmd_config_per_queue_tx_offload_result,
18424 		 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18425 			  "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18426 			  "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18427 			  "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18428 			  "mt_lockfree#multi_segs#mbuf_fast_free#security");
18429 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
18430 	TOKEN_STRING_INITIALIZER
18431 		(struct cmd_config_per_queue_tx_offload_result,
18432 		 on_off, "on#off");
18433 
18434 static void
18435 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
18436 				__attribute__((unused)) struct cmdline *cl,
18437 				__attribute__((unused)) void *data)
18438 {
18439 	struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
18440 	struct rte_eth_dev_info dev_info;
18441 	portid_t port_id = res->port_id;
18442 	uint16_t queue_id = res->queue_id;
18443 	struct rte_port *port = &ports[port_id];
18444 	uint64_t single_offload;
18445 
18446 	if (port->port_status != RTE_PORT_STOPPED) {
18447 		printf("Error: Can't config offload when Port %d "
18448 		       "is not stopped\n", port_id);
18449 		return;
18450 	}
18451 
18452 	rte_eth_dev_info_get(port_id, &dev_info);
18453 	if (queue_id >= dev_info.nb_tx_queues) {
18454 		printf("Error: input queue_id should be 0 ... "
18455 		       "%d\n", dev_info.nb_tx_queues - 1);
18456 		return;
18457 	}
18458 
18459 	single_offload = search_tx_offload(res->offload);
18460 	if (single_offload == 0) {
18461 		printf("Unknown offload name: %s\n", res->offload);
18462 		return;
18463 	}
18464 
18465 	if (!strcmp(res->on_off, "on"))
18466 		port->tx_conf[queue_id].offloads |= single_offload;
18467 	else
18468 		port->tx_conf[queue_id].offloads &= ~single_offload;
18469 
18470 	cmd_reconfig_device_queue(port_id, 1, 1);
18471 }
18472 
18473 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
18474 	.f = cmd_config_per_queue_tx_offload_parsed,
18475 	.data = NULL,
18476 	.help_str = "port <port_id> txq <queue_id> tx_offload "
18477 		    "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
18478 		    "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
18479 		    "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
18480 		    "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
18481 		    "mt_lockfree|multi_segs|mbuf_fast_free|security "
18482 		    "on|off",
18483 	.tokens = {
18484 		(void *)&cmd_config_per_queue_tx_offload_result_port,
18485 		(void *)&cmd_config_per_queue_tx_offload_result_port_id,
18486 		(void *)&cmd_config_per_queue_tx_offload_result_txq,
18487 		(void *)&cmd_config_per_queue_tx_offload_result_queue_id,
18488 		(void *)&cmd_config_per_queue_tx_offload_result_txoffload,
18489 		(void *)&cmd_config_per_queue_tx_offload_result_offload,
18490 		(void *)&cmd_config_per_queue_tx_offload_result_on_off,
18491 		NULL,
18492 	}
18493 };
18494 
18495 /* *** configure tx_metadata for specific port *** */
18496 struct cmd_config_tx_metadata_specific_result {
18497 	cmdline_fixed_string_t port;
18498 	cmdline_fixed_string_t keyword;
18499 	uint16_t port_id;
18500 	cmdline_fixed_string_t item;
18501 	uint32_t value;
18502 };
18503 
18504 static void
18505 cmd_config_tx_metadata_specific_parsed(void *parsed_result,
18506 				__attribute__((unused)) struct cmdline *cl,
18507 				__attribute__((unused)) void *data)
18508 {
18509 	struct cmd_config_tx_metadata_specific_result *res = parsed_result;
18510 
18511 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
18512 		return;
18513 	ports[res->port_id].tx_metadata = rte_cpu_to_be_32(res->value);
18514 	/* Add/remove callback to insert valid metadata in every Tx packet. */
18515 	if (ports[res->port_id].tx_metadata)
18516 		add_tx_md_callback(res->port_id);
18517 	else
18518 		remove_tx_md_callback(res->port_id);
18519 }
18520 
18521 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
18522 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18523 			port, "port");
18524 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
18525 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18526 			keyword, "config");
18527 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
18528 	TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18529 			port_id, UINT16);
18530 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
18531 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18532 			item, "tx_metadata");
18533 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
18534 	TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18535 			value, UINT32);
18536 
18537 cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
18538 	.f = cmd_config_tx_metadata_specific_parsed,
18539 	.data = NULL,
18540 	.help_str = "port config <port_id> tx_metadata <value>",
18541 	.tokens = {
18542 		(void *)&cmd_config_tx_metadata_specific_port,
18543 		(void *)&cmd_config_tx_metadata_specific_keyword,
18544 		(void *)&cmd_config_tx_metadata_specific_id,
18545 		(void *)&cmd_config_tx_metadata_specific_item,
18546 		(void *)&cmd_config_tx_metadata_specific_value,
18547 		NULL,
18548 	},
18549 };
18550 
18551 /* *** display tx_metadata per port configuration *** */
18552 struct cmd_show_tx_metadata_result {
18553 	cmdline_fixed_string_t cmd_show;
18554 	cmdline_fixed_string_t cmd_port;
18555 	cmdline_fixed_string_t cmd_keyword;
18556 	portid_t cmd_pid;
18557 };
18558 
18559 static void
18560 cmd_show_tx_metadata_parsed(void *parsed_result,
18561 		__attribute__((unused)) struct cmdline *cl,
18562 		__attribute__((unused)) void *data)
18563 {
18564 	struct cmd_show_tx_metadata_result *res = parsed_result;
18565 
18566 	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
18567 		printf("invalid port id %u\n", res->cmd_pid);
18568 		return;
18569 	}
18570 	if (!strcmp(res->cmd_keyword, "tx_metadata")) {
18571 		printf("Port %u tx_metadata: %u\n", res->cmd_pid,
18572 			rte_be_to_cpu_32(ports[res->cmd_pid].tx_metadata));
18573 	}
18574 }
18575 
18576 cmdline_parse_token_string_t cmd_show_tx_metadata_show =
18577 	TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
18578 			cmd_show, "show");
18579 cmdline_parse_token_string_t cmd_show_tx_metadata_port =
18580 	TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
18581 			cmd_port, "port");
18582 cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
18583 	TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
18584 			cmd_pid, UINT16);
18585 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
18586 	TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
18587 			cmd_keyword, "tx_metadata");
18588 
18589 cmdline_parse_inst_t cmd_show_tx_metadata = {
18590 	.f = cmd_show_tx_metadata_parsed,
18591 	.data = NULL,
18592 	.help_str = "show port <port_id> tx_metadata",
18593 	.tokens = {
18594 		(void *)&cmd_show_tx_metadata_show,
18595 		(void *)&cmd_show_tx_metadata_port,
18596 		(void *)&cmd_show_tx_metadata_pid,
18597 		(void *)&cmd_show_tx_metadata_keyword,
18598 		NULL,
18599 	},
18600 };
18601 
18602 /* ******************************************************************************** */
18603 
18604 /* list of instructions */
18605 cmdline_parse_ctx_t main_ctx[] = {
18606 	(cmdline_parse_inst_t *)&cmd_help_brief,
18607 	(cmdline_parse_inst_t *)&cmd_help_long,
18608 	(cmdline_parse_inst_t *)&cmd_quit,
18609 	(cmdline_parse_inst_t *)&cmd_load_from_file,
18610 	(cmdline_parse_inst_t *)&cmd_showport,
18611 	(cmdline_parse_inst_t *)&cmd_showqueue,
18612 	(cmdline_parse_inst_t *)&cmd_showportall,
18613 	(cmdline_parse_inst_t *)&cmd_showcfg,
18614 	(cmdline_parse_inst_t *)&cmd_showfwdall,
18615 	(cmdline_parse_inst_t *)&cmd_start,
18616 	(cmdline_parse_inst_t *)&cmd_start_tx_first,
18617 	(cmdline_parse_inst_t *)&cmd_start_tx_first_n,
18618 	(cmdline_parse_inst_t *)&cmd_set_link_up,
18619 	(cmdline_parse_inst_t *)&cmd_set_link_down,
18620 	(cmdline_parse_inst_t *)&cmd_reset,
18621 	(cmdline_parse_inst_t *)&cmd_set_numbers,
18622 	(cmdline_parse_inst_t *)&cmd_set_log,
18623 	(cmdline_parse_inst_t *)&cmd_set_txpkts,
18624 	(cmdline_parse_inst_t *)&cmd_set_txsplit,
18625 	(cmdline_parse_inst_t *)&cmd_set_fwd_list,
18626 	(cmdline_parse_inst_t *)&cmd_set_fwd_mask,
18627 	(cmdline_parse_inst_t *)&cmd_set_fwd_mode,
18628 	(cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
18629 	(cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
18630 	(cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
18631 	(cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
18632 	(cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
18633 	(cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
18634 	(cmdline_parse_inst_t *)&cmd_set_flush_rx,
18635 	(cmdline_parse_inst_t *)&cmd_set_link_check,
18636 	(cmdline_parse_inst_t *)&cmd_set_bypass_mode,
18637 	(cmdline_parse_inst_t *)&cmd_set_bypass_event,
18638 	(cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
18639 	(cmdline_parse_inst_t *)&cmd_show_bypass_config,
18640 #ifdef RTE_LIBRTE_PMD_BOND
18641 	(cmdline_parse_inst_t *) &cmd_set_bonding_mode,
18642 	(cmdline_parse_inst_t *) &cmd_show_bonding_config,
18643 	(cmdline_parse_inst_t *) &cmd_set_bonding_primary,
18644 	(cmdline_parse_inst_t *) &cmd_add_bonding_slave,
18645 	(cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
18646 	(cmdline_parse_inst_t *) &cmd_create_bonded_device,
18647 	(cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
18648 	(cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
18649 	(cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
18650 	(cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
18651 	(cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
18652 #endif
18653 	(cmdline_parse_inst_t *)&cmd_vlan_offload,
18654 	(cmdline_parse_inst_t *)&cmd_vlan_tpid,
18655 	(cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
18656 	(cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
18657 	(cmdline_parse_inst_t *)&cmd_tx_vlan_set,
18658 	(cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
18659 	(cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
18660 	(cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
18661 	(cmdline_parse_inst_t *)&cmd_csum_set,
18662 	(cmdline_parse_inst_t *)&cmd_csum_show,
18663 	(cmdline_parse_inst_t *)&cmd_csum_tunnel,
18664 	(cmdline_parse_inst_t *)&cmd_tso_set,
18665 	(cmdline_parse_inst_t *)&cmd_tso_show,
18666 	(cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
18667 	(cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
18668 	(cmdline_parse_inst_t *)&cmd_gro_enable,
18669 	(cmdline_parse_inst_t *)&cmd_gro_flush,
18670 	(cmdline_parse_inst_t *)&cmd_gro_show,
18671 	(cmdline_parse_inst_t *)&cmd_gso_enable,
18672 	(cmdline_parse_inst_t *)&cmd_gso_size,
18673 	(cmdline_parse_inst_t *)&cmd_gso_show,
18674 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set,
18675 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
18676 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
18677 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
18678 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
18679 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
18680 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
18681 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
18682 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
18683 	(cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
18684 	(cmdline_parse_inst_t *)&cmd_config_dcb,
18685 	(cmdline_parse_inst_t *)&cmd_read_reg,
18686 	(cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
18687 	(cmdline_parse_inst_t *)&cmd_read_reg_bit,
18688 	(cmdline_parse_inst_t *)&cmd_write_reg,
18689 	(cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
18690 	(cmdline_parse_inst_t *)&cmd_write_reg_bit,
18691 	(cmdline_parse_inst_t *)&cmd_read_rxd_txd,
18692 	(cmdline_parse_inst_t *)&cmd_stop,
18693 	(cmdline_parse_inst_t *)&cmd_mac_addr,
18694 	(cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
18695 	(cmdline_parse_inst_t *)&cmd_set_qmap,
18696 	(cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
18697 	(cmdline_parse_inst_t *)&cmd_operate_port,
18698 	(cmdline_parse_inst_t *)&cmd_operate_specific_port,
18699 	(cmdline_parse_inst_t *)&cmd_operate_attach_port,
18700 	(cmdline_parse_inst_t *)&cmd_operate_detach_port,
18701 	(cmdline_parse_inst_t *)&cmd_set_port_setup_on,
18702 	(cmdline_parse_inst_t *)&cmd_config_speed_all,
18703 	(cmdline_parse_inst_t *)&cmd_config_speed_specific,
18704 	(cmdline_parse_inst_t *)&cmd_config_loopback_all,
18705 	(cmdline_parse_inst_t *)&cmd_config_loopback_specific,
18706 	(cmdline_parse_inst_t *)&cmd_config_rx_tx,
18707 	(cmdline_parse_inst_t *)&cmd_config_mtu,
18708 	(cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
18709 	(cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
18710 	(cmdline_parse_inst_t *)&cmd_config_rss,
18711 	(cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
18712 	(cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
18713 	(cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
18714 	(cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
18715 	(cmdline_parse_inst_t *)&cmd_config_rss_reta,
18716 	(cmdline_parse_inst_t *)&cmd_showport_reta,
18717 	(cmdline_parse_inst_t *)&cmd_config_burst,
18718 	(cmdline_parse_inst_t *)&cmd_config_thresh,
18719 	(cmdline_parse_inst_t *)&cmd_config_threshold,
18720 	(cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
18721 	(cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
18722 	(cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
18723 	(cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
18724 	(cmdline_parse_inst_t *)&cmd_queue_rate_limit,
18725 	(cmdline_parse_inst_t *)&cmd_tunnel_filter,
18726 	(cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
18727 	(cmdline_parse_inst_t *)&cmd_global_config,
18728 	(cmdline_parse_inst_t *)&cmd_set_mirror_mask,
18729 	(cmdline_parse_inst_t *)&cmd_set_mirror_link,
18730 	(cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
18731 	(cmdline_parse_inst_t *)&cmd_showport_rss_hash,
18732 	(cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
18733 	(cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
18734 	(cmdline_parse_inst_t *)&cmd_dump,
18735 	(cmdline_parse_inst_t *)&cmd_dump_one,
18736 	(cmdline_parse_inst_t *)&cmd_ethertype_filter,
18737 	(cmdline_parse_inst_t *)&cmd_syn_filter,
18738 	(cmdline_parse_inst_t *)&cmd_2tuple_filter,
18739 	(cmdline_parse_inst_t *)&cmd_5tuple_filter,
18740 	(cmdline_parse_inst_t *)&cmd_flex_filter,
18741 	(cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
18742 	(cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
18743 	(cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
18744 	(cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
18745 	(cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
18746 	(cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
18747 	(cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
18748 	(cmdline_parse_inst_t *)&cmd_flush_flow_director,
18749 	(cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
18750 	(cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
18751 	(cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
18752 	(cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
18753 	(cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
18754 	(cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
18755 	(cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
18756 	(cmdline_parse_inst_t *)&cmd_get_hash_global_config,
18757 	(cmdline_parse_inst_t *)&cmd_set_hash_global_config,
18758 	(cmdline_parse_inst_t *)&cmd_set_hash_input_set,
18759 	(cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
18760 	(cmdline_parse_inst_t *)&cmd_flow,
18761 	(cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
18762 	(cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
18763 	(cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
18764 	(cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
18765 	(cmdline_parse_inst_t *)&cmd_create_port_meter,
18766 	(cmdline_parse_inst_t *)&cmd_enable_port_meter,
18767 	(cmdline_parse_inst_t *)&cmd_disable_port_meter,
18768 	(cmdline_parse_inst_t *)&cmd_del_port_meter,
18769 	(cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
18770 	(cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
18771 	(cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
18772 	(cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
18773 	(cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
18774 	(cmdline_parse_inst_t *)&cmd_mcast_addr,
18775 	(cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
18776 	(cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
18777 	(cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
18778 	(cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
18779 	(cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
18780 	(cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
18781 	(cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
18782 	(cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
18783 	(cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
18784 	(cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
18785 	(cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
18786 	(cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
18787 	(cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
18788 	(cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
18789 	(cmdline_parse_inst_t *)&cmd_set_tx_loopback,
18790 	(cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
18791 	(cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
18792 	(cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
18793 	(cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
18794 	(cmdline_parse_inst_t *)&cmd_set_macsec_sc,
18795 	(cmdline_parse_inst_t *)&cmd_set_macsec_sa,
18796 	(cmdline_parse_inst_t *)&cmd_set_vf_traffic,
18797 	(cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
18798 	(cmdline_parse_inst_t *)&cmd_vf_rate_limit,
18799 	(cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
18800 	(cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
18801 	(cmdline_parse_inst_t *)&cmd_set_vf_promisc,
18802 	(cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
18803 	(cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
18804 	(cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
18805 	(cmdline_parse_inst_t *)&cmd_vf_max_bw,
18806 	(cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
18807 	(cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
18808 	(cmdline_parse_inst_t *)&cmd_strict_link_prio,
18809 	(cmdline_parse_inst_t *)&cmd_tc_min_bw,
18810 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
18811 	(cmdline_parse_inst_t *)&cmd_set_port_tm_hierarchy_default,
18812 #endif
18813 	(cmdline_parse_inst_t *)&cmd_set_vxlan,
18814 	(cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl,
18815 	(cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
18816 	(cmdline_parse_inst_t *)&cmd_set_nvgre,
18817 	(cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
18818 	(cmdline_parse_inst_t *)&cmd_set_l2_encap,
18819 	(cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
18820 	(cmdline_parse_inst_t *)&cmd_set_l2_decap,
18821 	(cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
18822 	(cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
18823 	(cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
18824 	(cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
18825 	(cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
18826 	(cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
18827 	(cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
18828 	(cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
18829 	(cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
18830 	(cmdline_parse_inst_t *)&cmd_ddp_add,
18831 	(cmdline_parse_inst_t *)&cmd_ddp_del,
18832 	(cmdline_parse_inst_t *)&cmd_ddp_get_list,
18833 	(cmdline_parse_inst_t *)&cmd_ddp_get_info,
18834 	(cmdline_parse_inst_t *)&cmd_cfg_input_set,
18835 	(cmdline_parse_inst_t *)&cmd_clear_input_set,
18836 	(cmdline_parse_inst_t *)&cmd_show_vf_stats,
18837 	(cmdline_parse_inst_t *)&cmd_clear_vf_stats,
18838 	(cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
18839 	(cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
18840 	(cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
18841 	(cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
18842 
18843 	(cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
18844 	(cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
18845 	(cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
18846 	(cmdline_parse_inst_t *)&cmd_queue_region,
18847 	(cmdline_parse_inst_t *)&cmd_region_flowtype,
18848 	(cmdline_parse_inst_t *)&cmd_user_priority_region,
18849 	(cmdline_parse_inst_t *)&cmd_flush_queue_region,
18850 	(cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
18851 	(cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
18852 	(cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
18853 	(cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
18854 	(cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
18855 	(cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
18856 	(cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
18857 	(cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
18858 	(cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
18859 	(cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
18860 	(cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
18861 	(cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
18862 	(cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
18863 	(cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
18864 	(cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
18865 	(cmdline_parse_inst_t *)&cmd_del_port_tm_node,
18866 	(cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
18867 	(cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
18868 	(cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
18869 	(cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
18870 	(cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
18871 	(cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
18872 	(cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
18873 	(cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
18874 	(cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
18875 	(cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
18876 	(cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
18877 	(cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
18878 	(cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
18879 	(cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
18880 	(cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
18881 	(cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
18882 #ifdef RTE_LIBRTE_BPF
18883 	(cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
18884 	(cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
18885 #endif
18886 	(cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
18887 	(cmdline_parse_inst_t *)&cmd_show_tx_metadata,
18888 	NULL,
18889 };
18890 
18891 /* read cmdline commands from file */
18892 void
18893 cmdline_read_from_file(const char *filename)
18894 {
18895 	struct cmdline *cl;
18896 
18897 	cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
18898 	if (cl == NULL) {
18899 		printf("Failed to create file based cmdline context: %s\n",
18900 		       filename);
18901 		return;
18902 	}
18903 
18904 	cmdline_interact(cl);
18905 	cmdline_quit(cl);
18906 
18907 	cmdline_free(cl);
18908 
18909 	printf("Read CLI commands from %s\n", filename);
18910 }
18911 
18912 /* prompt function, called from main on MASTER lcore */
18913 void
18914 prompt(void)
18915 {
18916 	/* initialize non-constant commands */
18917 	cmd_set_fwd_mode_init();
18918 	cmd_set_fwd_retry_mode_init();
18919 
18920 	testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
18921 	if (testpmd_cl == NULL)
18922 		return;
18923 	cmdline_interact(testpmd_cl);
18924 	cmdline_stdin_exit(testpmd_cl);
18925 }
18926 
18927 void
18928 prompt_exit(void)
18929 {
18930 	if (testpmd_cl != NULL)
18931 		cmdline_quit(testpmd_cl);
18932 }
18933 
18934 static void
18935 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
18936 {
18937 	if (id == (portid_t)RTE_PORT_ALL) {
18938 		portid_t pid;
18939 
18940 		RTE_ETH_FOREACH_DEV(pid) {
18941 			/* check if need_reconfig has been set to 1 */
18942 			if (ports[pid].need_reconfig == 0)
18943 				ports[pid].need_reconfig = dev;
18944 			/* check if need_reconfig_queues has been set to 1 */
18945 			if (ports[pid].need_reconfig_queues == 0)
18946 				ports[pid].need_reconfig_queues = queue;
18947 		}
18948 	} else if (!port_id_is_invalid(id, DISABLED_WARN)) {
18949 		/* check if need_reconfig has been set to 1 */
18950 		if (ports[id].need_reconfig == 0)
18951 			ports[id].need_reconfig = dev;
18952 		/* check if need_reconfig_queues has been set to 1 */
18953 		if (ports[id].need_reconfig_queues == 0)
18954 			ports[id].need_reconfig_queues = queue;
18955 	}
18956 }
18957