xref: /dpdk/app/test-pmd/cmdline.c (revision f43d3dbbd90c9e195d26d18ac7da9ca2854c3f1e)
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2010-2016 Intel Corporation.
3  * Copyright(c) 2014 6WIND S.A.
4  */
5 
6 #include <stdarg.h>
7 #include <errno.h>
8 #include <stdio.h>
9 #include <stdint.h>
10 #include <string.h>
11 #include <termios.h>
12 #include <unistd.h>
13 #include <inttypes.h>
14 #include <sys/socket.h>
15 #include <netinet/in.h>
16 
17 #include <sys/queue.h>
18 
19 #include <rte_common.h>
20 #include <rte_byteorder.h>
21 #include <rte_log.h>
22 #include <rte_debug.h>
23 #include <rte_cycles.h>
24 #include <rte_memory.h>
25 #include <rte_memzone.h>
26 #include <rte_malloc.h>
27 #include <rte_launch.h>
28 #include <rte_eal.h>
29 #include <rte_per_lcore.h>
30 #include <rte_lcore.h>
31 #include <rte_atomic.h>
32 #include <rte_branch_prediction.h>
33 #include <rte_ring.h>
34 #include <rte_mempool.h>
35 #include <rte_interrupts.h>
36 #include <rte_pci.h>
37 #include <rte_ether.h>
38 #include <rte_ethdev.h>
39 #include <rte_string_fns.h>
40 #include <rte_devargs.h>
41 #include <rte_flow.h>
42 #include <rte_gro.h>
43 
44 #include <cmdline_rdline.h>
45 #include <cmdline_parse.h>
46 #include <cmdline_parse_num.h>
47 #include <cmdline_parse_string.h>
48 #include <cmdline_parse_ipaddr.h>
49 #include <cmdline_parse_etheraddr.h>
50 #include <cmdline_socket.h>
51 #include <cmdline.h>
52 #ifdef RTE_LIBRTE_PMD_BOND
53 #include <rte_eth_bond.h>
54 #include <rte_eth_bond_8023ad.h>
55 #endif
56 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD
57 #include <rte_pmd_dpaa.h>
58 #endif
59 #ifdef RTE_LIBRTE_IXGBE_PMD
60 #include <rte_pmd_ixgbe.h>
61 #endif
62 #ifdef RTE_LIBRTE_I40E_PMD
63 #include <rte_pmd_i40e.h>
64 #endif
65 #ifdef RTE_LIBRTE_BNXT_PMD
66 #include <rte_pmd_bnxt.h>
67 #endif
68 #include "testpmd.h"
69 #include "cmdline_mtr.h"
70 #include "cmdline_tm.h"
71 #include "bpf_cmd.h"
72 
73 static struct cmdline *testpmd_cl;
74 
75 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
76 
77 /* *** Help command with introduction. *** */
78 struct cmd_help_brief_result {
79 	cmdline_fixed_string_t help;
80 };
81 
82 static void cmd_help_brief_parsed(__attribute__((unused)) void *parsed_result,
83                                   struct cmdline *cl,
84                                   __attribute__((unused)) void *data)
85 {
86 	cmdline_printf(
87 		cl,
88 		"\n"
89 		"Help is available for the following sections:\n\n"
90 		"    help control                    : Start and stop forwarding.\n"
91 		"    help display                    : Displaying port, stats and config "
92 		"information.\n"
93 		"    help config                     : Configuration information.\n"
94 		"    help ports                      : Configuring ports.\n"
95 		"    help registers                  : Reading and setting port registers.\n"
96 		"    help filters                    : Filters configuration help.\n"
97 		"    help traffic_management         : Traffic Management commmands.\n"
98 		"    help devices                    : Device related cmds.\n"
99 		"    help all                        : All of the above sections.\n\n"
100 	);
101 
102 }
103 
104 cmdline_parse_token_string_t cmd_help_brief_help =
105 	TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
106 
107 cmdline_parse_inst_t cmd_help_brief = {
108 	.f = cmd_help_brief_parsed,
109 	.data = NULL,
110 	.help_str = "help: Show help",
111 	.tokens = {
112 		(void *)&cmd_help_brief_help,
113 		NULL,
114 	},
115 };
116 
117 /* *** Help command with help sections. *** */
118 struct cmd_help_long_result {
119 	cmdline_fixed_string_t help;
120 	cmdline_fixed_string_t section;
121 };
122 
123 static void cmd_help_long_parsed(void *parsed_result,
124                                  struct cmdline *cl,
125                                  __attribute__((unused)) void *data)
126 {
127 	int show_all = 0;
128 	struct cmd_help_long_result *res = parsed_result;
129 
130 	if (!strcmp(res->section, "all"))
131 		show_all = 1;
132 
133 	if (show_all || !strcmp(res->section, "control")) {
134 
135 		cmdline_printf(
136 			cl,
137 			"\n"
138 			"Control forwarding:\n"
139 			"-------------------\n\n"
140 
141 			"start\n"
142 			"    Start packet forwarding with current configuration.\n\n"
143 
144 			"start tx_first\n"
145 			"    Start packet forwarding with current config"
146 			" after sending one burst of packets.\n\n"
147 
148 			"stop\n"
149 			"    Stop packet forwarding, and display accumulated"
150 			" statistics.\n\n"
151 
152 			"quit\n"
153 			"    Quit to prompt.\n\n"
154 		);
155 	}
156 
157 	if (show_all || !strcmp(res->section, "display")) {
158 
159 		cmdline_printf(
160 			cl,
161 			"\n"
162 			"Display:\n"
163 			"--------\n\n"
164 
165 			"show port (info|stats|summary|xstats|fdir|stat_qmap|dcb_tc|cap) (port_id|all)\n"
166 			"    Display information for port_id, or all.\n\n"
167 
168 			"show port X rss reta (size) (mask0,mask1,...)\n"
169 			"    Display the rss redirection table entry indicated"
170 			" by masks on port X. size is used to indicate the"
171 			" hardware supported reta size\n\n"
172 
173 			"show port (port_id) rss-hash [key]\n"
174 			"    Display the RSS hash functions and RSS hash key of port\n\n"
175 
176 			"clear port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n"
177 			"    Clear information for port_id, or all.\n\n"
178 
179 			"show (rxq|txq) info (port_id) (queue_id)\n"
180 			"    Display information for configured RX/TX queue.\n\n"
181 
182 			"show config (rxtx|cores|fwd|txpkts)\n"
183 			"    Display the given configuration.\n\n"
184 
185 			"read rxd (port_id) (queue_id) (rxd_id)\n"
186 			"    Display an RX descriptor of a port RX queue.\n\n"
187 
188 			"read txd (port_id) (queue_id) (txd_id)\n"
189 			"    Display a TX descriptor of a port TX queue.\n\n"
190 
191 			"ddp get list (port_id)\n"
192 			"    Get ddp profile info list\n\n"
193 
194 			"ddp get info (profile_path)\n"
195 			"    Get ddp profile information.\n\n"
196 
197 			"show vf stats (port_id) (vf_id)\n"
198 			"    Display a VF's statistics.\n\n"
199 
200 			"clear vf stats (port_id) (vf_id)\n"
201 			"    Reset a VF's statistics.\n\n"
202 
203 			"show port (port_id) pctype mapping\n"
204 			"    Get flow ptype to pctype mapping on a port\n\n"
205 
206 			"show port meter stats (port_id) (meter_id) (clear)\n"
207 			"    Get meter stats on a port\n\n"
208 
209 			"show fwd stats all\n"
210 			"    Display statistics for all fwd engines.\n\n"
211 
212 			"clear fwd stats all\n"
213 			"    Clear statistics for all fwd engines.\n\n"
214 
215 			"show port (port_id) rx_offload capabilities\n"
216 			"    List all per queue and per port Rx offloading"
217 			" capabilities of a port\n\n"
218 
219 			"show port (port_id) rx_offload configuration\n"
220 			"    List port level and all queue level"
221 			" Rx offloading configuration\n\n"
222 
223 			"show port (port_id) tx_offload capabilities\n"
224 			"    List all per queue and per port"
225 			" Tx offloading capabilities of a port\n\n"
226 
227 			"show port (port_id) tx_offload configuration\n"
228 			"    List port level and all queue level"
229 			" Tx offloading configuration\n\n"
230 
231 			"show port (port_id) tx_metadata\n"
232 			"    Show Tx metadata value set"
233 			" for a specific port\n\n"
234 
235 			"show port (port_id) ptypes\n"
236 			"    Show port supported ptypes"
237 			" for a specific port\n\n"
238 
239 			"show device info (<identifier>|all)"
240 			"       Show general information about devices probed.\n\n"
241 
242 			"show port (port_id) rxq|txq (queue_id) desc (desc_id) status"
243 			"       Show status of rx|tx descriptor.\n\n"
244 		);
245 	}
246 
247 	if (show_all || !strcmp(res->section, "config")) {
248 		cmdline_printf(
249 			cl,
250 			"\n"
251 			"Configuration:\n"
252 			"--------------\n"
253 			"Configuration changes only become active when"
254 			" forwarding is started/restarted.\n\n"
255 
256 			"set default\n"
257 			"    Reset forwarding to the default configuration.\n\n"
258 
259 			"set verbose (level)\n"
260 			"    Set the debug verbosity level X.\n\n"
261 
262 			"set log global|(type) (level)\n"
263 			"    Set the log level.\n\n"
264 
265 			"set nbport (num)\n"
266 			"    Set number of ports.\n\n"
267 
268 			"set nbcore (num)\n"
269 			"    Set number of cores.\n\n"
270 
271 			"set coremask (mask)\n"
272 			"    Set the forwarding cores hexadecimal mask.\n\n"
273 
274 			"set portmask (mask)\n"
275 			"    Set the forwarding ports hexadecimal mask.\n\n"
276 
277 			"set burst (num)\n"
278 			"    Set number of packets per burst.\n\n"
279 
280 			"set burst tx delay (microseconds) retry (num)\n"
281 			"    Set the transmit delay time and number of retries,"
282 			" effective when retry is enabled.\n\n"
283 
284 			"set txpkts (x[,y]*)\n"
285 			"    Set the length of each segment of TXONLY"
286 			" and optionally CSUM packets.\n\n"
287 
288 			"set txsplit (off|on|rand)\n"
289 			"    Set the split policy for the TX packets."
290 			" Right now only applicable for CSUM and TXONLY"
291 			" modes\n\n"
292 
293 			"set corelist (x[,y]*)\n"
294 			"    Set the list of forwarding cores.\n\n"
295 
296 			"set portlist (x[,y]*)\n"
297 			"    Set the list of forwarding ports.\n\n"
298 
299 			"set port setup on (iterator|event)\n"
300 			"    Select how attached port is retrieved for setup.\n\n"
301 
302 			"set tx loopback (port_id) (on|off)\n"
303 			"    Enable or disable tx loopback.\n\n"
304 
305 			"set all queues drop (port_id) (on|off)\n"
306 			"    Set drop enable bit for all queues.\n\n"
307 
308 			"set vf split drop (port_id) (vf_id) (on|off)\n"
309 			"    Set split drop enable bit for a VF from the PF.\n\n"
310 
311 			"set vf mac antispoof (port_id) (vf_id) (on|off).\n"
312 			"    Set MAC antispoof for a VF from the PF.\n\n"
313 
314 			"set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n"
315 			"    Enable MACsec offload.\n\n"
316 
317 			"set macsec offload (port_id) off\n"
318 			"    Disable MACsec offload.\n\n"
319 
320 			"set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
321 			"    Configure MACsec secure connection (SC).\n\n"
322 
323 			"set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n"
324 			"    Configure MACsec secure association (SA).\n\n"
325 
326 			"set vf broadcast (port_id) (vf_id) (on|off)\n"
327 			"    Set VF broadcast for a VF from the PF.\n\n"
328 
329 			"vlan set stripq (on|off) (port_id,queue_id)\n"
330 			"    Set the VLAN strip for a queue on a port.\n\n"
331 
332 			"set vf vlan stripq (port_id) (vf_id) (on|off)\n"
333 			"    Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
334 
335 			"set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
336 			"    Set VLAN insert for a VF from the PF.\n\n"
337 
338 			"set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
339 			"    Set VLAN antispoof for a VF from the PF.\n\n"
340 
341 			"set vf vlan tag (port_id) (vf_id) (on|off)\n"
342 			"    Set VLAN tag for a VF from the PF.\n\n"
343 
344 			"set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n"
345 			"    Set a VF's max bandwidth(Mbps).\n\n"
346 
347 			"set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n"
348 			"    Set all TCs' min bandwidth(%%) on a VF.\n\n"
349 
350 			"set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n"
351 			"    Set a TC's max bandwidth(Mbps) on a VF.\n\n"
352 
353 			"set tx strict-link-priority (port_id) (tc_bitmap)\n"
354 			"    Set some TCs' strict link priority mode on a physical port.\n\n"
355 
356 			"set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n"
357 			"    Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n"
358 
359 			"vlan set (strip|filter|qinq_strip|extend) (on|off) (port_id)\n"
360 			"    Set the VLAN strip or filter or qinq strip or extend\n\n"
361 
362 			"vlan set (inner|outer) tpid (value) (port_id)\n"
363 			"    Set the VLAN TPID for Packet Filtering on"
364 			" a port\n\n"
365 
366 			"rx_vlan add (vlan_id|all) (port_id)\n"
367 			"    Add a vlan_id, or all identifiers, to the set"
368 			" of VLAN identifiers filtered by port_id.\n\n"
369 
370 			"rx_vlan rm (vlan_id|all) (port_id)\n"
371 			"    Remove a vlan_id, or all identifiers, from the set"
372 			" of VLAN identifiers filtered by port_id.\n\n"
373 
374 			"rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
375 			"    Add a vlan_id, to the set of VLAN identifiers"
376 			"filtered for VF(s) from port_id.\n\n"
377 
378 			"rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
379 			"    Remove a vlan_id, to the set of VLAN identifiers"
380 			"filtered for VF(s) from port_id.\n\n"
381 
382 			"tunnel_filter add (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 			"   add a tunnel filter of a port.\n\n"
386 
387 			"tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) "
388 			"(inner_vlan) (vxlan|nvgre|ipingre|vxlan-gpe) (imac-ivlan|imac-ivlan-tenid|"
389 			"imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
390 			"   remove a tunnel filter of a port.\n\n"
391 
392 			"rx_vxlan_port add (udp_port) (port_id)\n"
393 			"    Add an UDP port for VXLAN packet filter on a port\n\n"
394 
395 			"rx_vxlan_port rm (udp_port) (port_id)\n"
396 			"    Remove an UDP port for VXLAN packet filter on a port\n\n"
397 
398 			"tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
399 			"    Set hardware insertion of VLAN IDs (single or double VLAN "
400 			"depends on the number of VLAN IDs) in packets sent on a port.\n\n"
401 
402 			"tx_vlan set pvid port_id vlan_id (on|off)\n"
403 			"    Set port based TX VLAN insertion.\n\n"
404 
405 			"tx_vlan reset (port_id)\n"
406 			"    Disable hardware insertion of a VLAN header in"
407 			" packets sent on a port.\n\n"
408 
409 			"csum set (ip|udp|tcp|sctp|outer-ip|outer-udp) (hw|sw) (port_id)\n"
410 			"    Select hardware or software calculation of the"
411 			" checksum when transmitting a packet using the"
412 			" csum forward engine.\n"
413 			"    ip|udp|tcp|sctp always concern the inner layer.\n"
414 			"    outer-ip concerns the outer IP layer in"
415 			"    outer-udp concerns the outer UDP layer in"
416 			" case the packet is recognized as a tunnel packet by"
417 			" the forward engine (vxlan, gre and ipip are supported)\n"
418 			"    Please check the NIC datasheet for HW limits.\n\n"
419 
420 			"csum parse-tunnel (on|off) (tx_port_id)\n"
421 			"    If disabled, treat tunnel packets as non-tunneled"
422 			" packets (treat inner headers as payload). The port\n"
423 			"    argument is the port used for TX in csum forward"
424 			" engine.\n\n"
425 
426 			"csum show (port_id)\n"
427 			"    Display tx checksum offload configuration\n\n"
428 
429 			"tso set (segsize) (portid)\n"
430 			"    Enable TCP Segmentation Offload in csum forward"
431 			" engine.\n"
432 			"    Please check the NIC datasheet for HW limits.\n\n"
433 
434 			"tso show (portid)"
435 			"    Display the status of TCP Segmentation Offload.\n\n"
436 
437 			"set port (port_id) gro on|off\n"
438 			"    Enable or disable Generic Receive Offload in"
439 			" csum forwarding engine.\n\n"
440 
441 			"show port (port_id) gro\n"
442 			"    Display GRO configuration.\n\n"
443 
444 			"set gro flush (cycles)\n"
445 			"    Set the cycle to flush GROed packets from"
446 			" reassembly tables.\n\n"
447 
448 			"set port (port_id) gso (on|off)"
449 			"    Enable or disable Generic Segmentation Offload in"
450 			" csum forwarding engine.\n\n"
451 
452 			"set gso segsz (length)\n"
453 			"    Set max packet length for output GSO segments,"
454 			" including packet header and payload.\n\n"
455 
456 			"show port (port_id) gso\n"
457 			"    Show GSO configuration.\n\n"
458 
459 			"set fwd (%s)\n"
460 			"    Set packet forwarding mode.\n\n"
461 
462 			"mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
463 			"    Add a MAC address on port_id.\n\n"
464 
465 			"mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
466 			"    Remove a MAC address from port_id.\n\n"
467 
468 			"mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
469 			"    Set the default MAC address for port_id.\n\n"
470 
471 			"mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
472 			"    Add a MAC address for a VF on the port.\n\n"
473 
474 			"set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
475 			"    Set the MAC address for a VF from the PF.\n\n"
476 
477 			"set eth-peer (port_id) (peer_addr)\n"
478 			"    set the peer address for certain port.\n\n"
479 
480 			"set port (port_id) uta (mac_address|all) (on|off)\n"
481 			"    Add/Remove a or all unicast hash filter(s)"
482 			"from port X.\n\n"
483 
484 			"set promisc (port_id|all) (on|off)\n"
485 			"    Set the promiscuous mode on port_id, or all.\n\n"
486 
487 			"set allmulti (port_id|all) (on|off)\n"
488 			"    Set the allmulti mode on port_id, or all.\n\n"
489 
490 			"set vf promisc (port_id) (vf_id) (on|off)\n"
491 			"    Set unicast promiscuous mode for a VF from the PF.\n\n"
492 
493 			"set vf allmulti (port_id) (vf_id) (on|off)\n"
494 			"    Set multicast promiscuous mode for a VF from the PF.\n\n"
495 
496 			"set flow_ctrl rx (on|off) tx (on|off) (high_water)"
497 			" (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
498 			" (on|off) autoneg (on|off) (port_id)\n"
499 			"set flow_ctrl rx (on|off) (portid)\n"
500 			"set flow_ctrl tx (on|off) (portid)\n"
501 			"set flow_ctrl high_water (high_water) (portid)\n"
502 			"set flow_ctrl low_water (low_water) (portid)\n"
503 			"set flow_ctrl pause_time (pause_time) (portid)\n"
504 			"set flow_ctrl send_xon (send_xon) (portid)\n"
505 			"set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
506 			"set flow_ctrl autoneg (on|off) (port_id)\n"
507 			"    Set the link flow control parameter on a port.\n\n"
508 
509 			"set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
510 			" (low_water) (pause_time) (priority) (port_id)\n"
511 			"    Set the priority flow control parameter on a"
512 			" port.\n\n"
513 
514 			"set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
515 			"    Set statistics mapping (qmapping 0..15) for RX/TX"
516 			" queue on port.\n"
517 			"    e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
518 			" on port 0 to mapping 5.\n\n"
519 
520 			"set xstats-hide-zero on|off\n"
521 			"    Set the option to hide the zero values"
522 			" for xstats display.\n"
523 
524 			"set port (port_id) vf (vf_id) rx|tx on|off\n"
525 			"    Enable/Disable a VF receive/tranmit from a port\n\n"
526 
527 			"set port (port_id) vf (vf_id) (mac_addr)"
528 			" (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
529 			"   Add/Remove unicast or multicast MAC addr filter"
530 			" for a VF.\n\n"
531 
532 			"set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
533 			"|MPE) (on|off)\n"
534 			"    AUPE:accepts untagged VLAN;"
535 			"ROPE:accept unicast hash\n\n"
536 			"    BAM:accepts broadcast packets;"
537 			"MPE:accepts all multicast packets\n\n"
538 			"    Enable/Disable a VF receive mode of a port\n\n"
539 
540 			"set port (port_id) queue (queue_id) rate (rate_num)\n"
541 			"    Set rate limit for a queue of a port\n\n"
542 
543 			"set port (port_id) vf (vf_id) rate (rate_num) "
544 			"queue_mask (queue_mask_value)\n"
545 			"    Set rate limit for queues in VF of a port\n\n"
546 
547 			"set port (port_id) mirror-rule (rule_id)"
548 			" (pool-mirror-up|pool-mirror-down|vlan-mirror)"
549 			" (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
550 			"   Set pool or vlan type mirror rule on a port.\n"
551 			"   e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
552 			" dst-pool 0 on' enable mirror traffic with vlan 0,1"
553 			" to pool 0.\n\n"
554 
555 			"set port (port_id) mirror-rule (rule_id)"
556 			" (uplink-mirror|downlink-mirror) dst-pool"
557 			" (pool_id) (on|off)\n"
558 			"   Set uplink or downlink type mirror rule on a port.\n"
559 			"   e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
560 			" 0 on' enable mirror income traffic to pool 0.\n\n"
561 
562 			"reset port (port_id) mirror-rule (rule_id)\n"
563 			"   Reset a mirror rule.\n\n"
564 
565 			"set flush_rx (on|off)\n"
566 			"   Flush (default) or don't flush RX streams before"
567 			" forwarding. Mainly used with PCAP drivers.\n\n"
568 
569 			"set bypass mode (normal|bypass|isolate) (port_id)\n"
570 			"   Set the bypass mode for the lowest port on bypass enabled"
571 			" NIC.\n\n"
572 
573 			"set bypass event (timeout|os_on|os_off|power_on|power_off) "
574 			"mode (normal|bypass|isolate) (port_id)\n"
575 			"   Set the event required to initiate specified bypass mode for"
576 			" the lowest port on a bypass enabled NIC where:\n"
577 			"       timeout   = enable bypass after watchdog timeout.\n"
578 			"       os_on     = enable bypass when OS/board is powered on.\n"
579 			"       os_off    = enable bypass when OS/board is powered off.\n"
580 			"       power_on  = enable bypass when power supply is turned on.\n"
581 			"       power_off = enable bypass when power supply is turned off."
582 			"\n\n"
583 
584 			"set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
585 			"   Set the bypass watchdog timeout to 'n' seconds"
586 			" where 0 = instant.\n\n"
587 
588 			"show bypass config (port_id)\n"
589 			"   Show the bypass configuration for a bypass enabled NIC"
590 			" using the lowest port on the NIC.\n\n"
591 
592 #ifdef RTE_LIBRTE_PMD_BOND
593 			"create bonded device (mode) (socket)\n"
594 			"	Create a new bonded device with specific bonding mode and socket.\n\n"
595 
596 			"add bonding slave (slave_id) (port_id)\n"
597 			"	Add a slave device to a bonded device.\n\n"
598 
599 			"remove bonding slave (slave_id) (port_id)\n"
600 			"	Remove a slave device from a bonded device.\n\n"
601 
602 			"set bonding mode (value) (port_id)\n"
603 			"	Set the bonding mode on a bonded device.\n\n"
604 
605 			"set bonding primary (slave_id) (port_id)\n"
606 			"	Set the primary slave for a bonded device.\n\n"
607 
608 			"show bonding config (port_id)\n"
609 			"	Show the bonding config for port_id.\n\n"
610 
611 			"set bonding mac_addr (port_id) (address)\n"
612 			"	Set the MAC address of a bonded device.\n\n"
613 
614 			"set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)"
615 			"	Set Aggregation mode for IEEE802.3AD (mode 4)"
616 
617 			"set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
618 			"	Set the transmit balance policy for bonded device running in balance mode.\n\n"
619 
620 			"set bonding mon_period (port_id) (value)\n"
621 			"	Set the bonding link status monitoring polling period in ms.\n\n"
622 
623 			"set bonding lacp dedicated_queues <port_id> (enable|disable)\n"
624 			"	Enable/disable dedicated queues for LACP control traffic.\n\n"
625 
626 #endif
627 			"set link-up port (port_id)\n"
628 			"	Set link up for a port.\n\n"
629 
630 			"set link-down port (port_id)\n"
631 			"	Set link down for a port.\n\n"
632 
633 			"E-tag set insertion on port-tag-id (value)"
634 			" port (port_id) vf (vf_id)\n"
635 			"    Enable E-tag insertion for a VF on a port\n\n"
636 
637 			"E-tag set insertion off port (port_id) vf (vf_id)\n"
638 			"    Disable E-tag insertion for a VF on a port\n\n"
639 
640 			"E-tag set stripping (on|off) port (port_id)\n"
641 			"    Enable/disable E-tag stripping on a port\n\n"
642 
643 			"E-tag set forwarding (on|off) port (port_id)\n"
644 			"    Enable/disable E-tag based forwarding"
645 			" on a port\n\n"
646 
647 			"E-tag set filter add e-tag-id (value) dst-pool"
648 			" (pool_id) port (port_id)\n"
649 			"    Add an E-tag forwarding filter on a port\n\n"
650 
651 			"E-tag set filter del e-tag-id (value) port (port_id)\n"
652 			"    Delete an E-tag forwarding filter on a port\n\n"
653 
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) ptype_mask (ptype_mask)\n"
673 			"    set packet types classification for a specific port\n\n"
674 
675 			"set port (port_id) queue-region region_id (value) "
676 			"queue_start_index (value) queue_num (value)\n"
677 			"    Set a queue region on a port\n\n"
678 
679 			"set port (port_id) queue-region region_id (value) "
680 			"flowtype (value)\n"
681 			"    Set a flowtype region index on a port\n\n"
682 
683 			"set port (port_id) queue-region UP (value) region_id (value)\n"
684 			"    Set the mapping of User Priority to "
685 			"queue region on a port\n\n"
686 
687 			"set port (port_id) queue-region flush (on|off)\n"
688 			"    flush all queue region related configuration\n\n"
689 
690 			"show port meter cap (port_id)\n"
691 			"    Show port meter capability information\n\n"
692 
693 			"add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs)\n"
694 			"    meter profile add - srtcm rfc 2697\n\n"
695 
696 			"add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs)\n"
697 			"    meter profile add - trtcm rfc 2698\n\n"
698 
699 			"add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs)\n"
700 			"    meter profile add - trtcm rfc 4115\n\n"
701 
702 			"del port meter profile (port_id) (profile_id)\n"
703 			"    meter profile delete\n\n"
704 
705 			"create port meter (port_id) (mtr_id) (profile_id) (meter_enable)\n"
706 			"(g_action) (y_action) (r_action) (stats_mask) (shared)\n"
707 			"(use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n"
708 			"(dscp_tbl_entry63)]\n"
709 			"    meter create\n\n"
710 
711 			"enable port meter (port_id) (mtr_id)\n"
712 			"    meter enable\n\n"
713 
714 			"disable port meter (port_id) (mtr_id)\n"
715 			"    meter disable\n\n"
716 
717 			"del port meter (port_id) (mtr_id)\n"
718 			"    meter delete\n\n"
719 
720 			"set port meter profile (port_id) (mtr_id) (profile_id)\n"
721 			"    meter update meter profile\n\n"
722 
723 			"set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n"
724 			"(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n"
725 			"    update meter dscp table entries\n\n"
726 
727 			"set port meter policer action (port_id) (mtr_id) (action_mask)\n"
728 			"(action0) [(action1) (action2)]\n"
729 			"    meter update policer action\n\n"
730 
731 			"set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
732 			"    meter update stats\n\n"
733 
734 			"show port (port_id) queue-region\n"
735 			"    show all queue region related configuration info\n\n"
736 
737 			, list_pkt_forwarding_modes()
738 		);
739 	}
740 
741 	if (show_all || !strcmp(res->section, "ports")) {
742 
743 		cmdline_printf(
744 			cl,
745 			"\n"
746 			"Port Operations:\n"
747 			"----------------\n\n"
748 
749 			"port start (port_id|all)\n"
750 			"    Start all ports or port_id.\n\n"
751 
752 			"port stop (port_id|all)\n"
753 			"    Stop all ports or port_id.\n\n"
754 
755 			"port close (port_id|all)\n"
756 			"    Close all ports or port_id.\n\n"
757 
758 			"port reset (port_id|all)\n"
759 			"    Reset all ports or port_id.\n\n"
760 
761 			"port attach (ident)\n"
762 			"    Attach physical or virtual dev by pci address or virtual device name\n\n"
763 
764 			"port detach (port_id)\n"
765 			"    Detach physical or virtual dev by port_id\n\n"
766 
767 			"port config (port_id|all)"
768 			" speed (10|100|1000|10000|25000|40000|50000|100000|auto)"
769 			" duplex (half|full|auto)\n"
770 			"    Set speed and duplex for all ports or port_id\n\n"
771 
772 			"port config (port_id|all) loopback (mode)\n"
773 			"    Set loopback mode for all ports or port_id\n\n"
774 
775 			"port config all (rxq|txq|rxd|txd) (value)\n"
776 			"    Set number for rxq/txq/rxd/txd.\n\n"
777 
778 			"port config all max-pkt-len (value)\n"
779 			"    Set the max packet length.\n\n"
780 
781 			"port config all max-lro-pkt-size (value)\n"
782 			"    Set the max LRO aggregated packet size.\n\n"
783 
784 			"port config all drop-en (on|off)\n"
785 			"    Enable or disable packet drop on all RX queues of all ports when no "
786 			"receive buffers available.\n\n"
787 
788 			"port config all rss (all|default|ip|tcp|udp|sctp|"
789 			"ether|port|vxlan|geneve|nvgre|vxlan-gpe|none|<flowtype_id>)\n"
790 			"    Set the RSS mode.\n\n"
791 
792 			"port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
793 			"    Set the RSS redirection table.\n\n"
794 
795 			"port config (port_id) dcb vt (on|off) (traffic_class)"
796 			" pfc (on|off)\n"
797 			"    Set the DCB mode.\n\n"
798 
799 			"port config all burst (value)\n"
800 			"    Set the number of packets per burst.\n\n"
801 
802 			"port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
803 			" (value)\n"
804 			"    Set the ring prefetch/host/writeback threshold"
805 			" for tx/rx queue.\n\n"
806 
807 			"port config all (txfreet|txrst|rxfreet) (value)\n"
808 			"    Set free threshold for rx/tx, or set"
809 			" tx rs bit threshold.\n\n"
810 			"port config mtu X value\n"
811 			"    Set the MTU of port X to a given value\n\n"
812 
813 			"port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n"
814 			"    Set a rx/tx queue's ring size configuration, the new"
815 			" value will take effect after command that (re-)start the port"
816 			" or command that setup the specific queue\n\n"
817 
818 			"port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
819 			"    Start/stop a rx/tx queue of port X. Only take effect"
820 			" when port X is started\n\n"
821 
822 			"port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n"
823 			"    Switch on/off a deferred start of port X rx/tx queue. Only"
824 			" take effect when port X is stopped.\n\n"
825 
826 			"port (port_id) (rxq|txq) (queue_id) setup\n"
827 			"    Setup a rx/tx queue of port X.\n\n"
828 
829 			"port config (port_id|all) l2-tunnel E-tag ether-type"
830 			" (value)\n"
831 			"    Set the value of E-tag ether-type.\n\n"
832 
833 			"port config (port_id|all) l2-tunnel E-tag"
834 			" (enable|disable)\n"
835 			"    Enable/disable the E-tag support.\n\n"
836 
837 			"port config (port_id) pctype mapping reset\n"
838 			"    Reset flow type to pctype mapping on a port\n\n"
839 
840 			"port config (port_id) pctype mapping update"
841 			" (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
842 			"    Update a flow type to pctype mapping item on a port\n\n"
843 
844 			"port config (port_id) pctype (pctype_id) hash_inset|"
845 			"fdir_inset|fdir_flx_inset get|set|clear field\n"
846 			" (field_idx)\n"
847 			"    Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n"
848 
849 			"port config (port_id) pctype (pctype_id) hash_inset|"
850 			"fdir_inset|fdir_flx_inset clear all"
851 			"    Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n"
852 
853 			"port config (port_id) udp_tunnel_port add|rm vxlan|geneve (udp_port)\n\n"
854 			"    Add/remove UDP tunnel port for tunneling offload\n\n"
855 
856 			"port config <port_id> rx_offload vlan_strip|"
857 			"ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
858 			"outer_ipv4_cksum|macsec_strip|header_split|"
859 			"vlan_filter|vlan_extend|jumbo_frame|"
860 			"scatter|timestamp|security|keep_crc on|off\n"
861 			"     Enable or disable a per port Rx offloading"
862 			" on all Rx queues of a port\n\n"
863 
864 			"port (port_id) rxq (queue_id) rx_offload vlan_strip|"
865 			"ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
866 			"outer_ipv4_cksum|macsec_strip|header_split|"
867 			"vlan_filter|vlan_extend|jumbo_frame|"
868 			"scatter|timestamp|security|keep_crc on|off\n"
869 			"    Enable or disable a per queue Rx offloading"
870 			" only on a specific Rx queue\n\n"
871 
872 			"port config (port_id) tx_offload vlan_insert|"
873 			"ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
874 			"udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
875 			"gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|"
876 			"macsec_insert|mt_lockfree|multi_segs|mbuf_fast_free|"
877 			"security|match_metadata on|off\n"
878 			"    Enable or disable a per port Tx offloading"
879 			" on all Tx queues of a port\n\n"
880 
881 			"port (port_id) txq (queue_id) tx_offload vlan_insert|"
882 			"ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
883 			"udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
884 			"gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|macsec_insert"
885 			"|mt_lockfree|multi_segs|mbuf_fast_free|security"
886 			" on|off\n"
887 			"    Enable or disable a per queue Tx offloading"
888 			" only on a specific Tx queue\n\n"
889 
890 			"bpf-load rx|tx (port) (queue) (J|M|B) (file_name)\n"
891 			"    Load an eBPF program as a callback"
892 			" for particular RX/TX queue\n\n"
893 
894 			"bpf-unload rx|tx (port) (queue)\n"
895 			"    Unload previously loaded eBPF program"
896 			" for particular RX/TX queue\n\n"
897 
898 			"port config (port_id) tx_metadata (value)\n"
899 			"    Set Tx metadata value per port. Testpmd will add this value"
900 			" to any Tx packet sent from this port\n\n"
901 		);
902 	}
903 
904 	if (show_all || !strcmp(res->section, "registers")) {
905 
906 		cmdline_printf(
907 			cl,
908 			"\n"
909 			"Registers:\n"
910 			"----------\n\n"
911 
912 			"read reg (port_id) (address)\n"
913 			"    Display value of a port register.\n\n"
914 
915 			"read regfield (port_id) (address) (bit_x) (bit_y)\n"
916 			"    Display a port register bit field.\n\n"
917 
918 			"read regbit (port_id) (address) (bit_x)\n"
919 			"    Display a single port register bit.\n\n"
920 
921 			"write reg (port_id) (address) (value)\n"
922 			"    Set value of a port register.\n\n"
923 
924 			"write regfield (port_id) (address) (bit_x) (bit_y)"
925 			" (value)\n"
926 			"    Set bit field of a port register.\n\n"
927 
928 			"write regbit (port_id) (address) (bit_x) (value)\n"
929 			"    Set single bit value of a port register.\n\n"
930 		);
931 	}
932 	if (show_all || !strcmp(res->section, "filters")) {
933 
934 		cmdline_printf(
935 			cl,
936 			"\n"
937 			"filters:\n"
938 			"--------\n\n"
939 
940 			"ethertype_filter (port_id) (add|del)"
941 			" (mac_addr|mac_ignr) (mac_address) ethertype"
942 			" (ether_type) (drop|fwd) queue (queue_id)\n"
943 			"    Add/Del an ethertype filter.\n\n"
944 
945 			"2tuple_filter (port_id) (add|del)"
946 			" dst_port (dst_port_value) protocol (protocol_value)"
947 			" mask (mask_value) tcp_flags (tcp_flags_value)"
948 			" priority (prio_value) queue (queue_id)\n"
949 			"    Add/Del a 2tuple filter.\n\n"
950 
951 			"5tuple_filter (port_id) (add|del)"
952 			" dst_ip (dst_address) src_ip (src_address)"
953 			" dst_port (dst_port_value) src_port (src_port_value)"
954 			" protocol (protocol_value)"
955 			" mask (mask_value) tcp_flags (tcp_flags_value)"
956 			" priority (prio_value) queue (queue_id)\n"
957 			"    Add/Del a 5tuple filter.\n\n"
958 
959 			"syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
960 			"    Add/Del syn filter.\n\n"
961 
962 			"flex_filter (port_id) (add|del) len (len_value)"
963 			" bytes (bytes_value) mask (mask_value)"
964 			" priority (prio_value) queue (queue_id)\n"
965 			"    Add/Del a flex filter.\n\n"
966 
967 			"flow_director_filter (port_id) mode IP (add|del|update)"
968 			" flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
969 			" src (src_ip_address) dst (dst_ip_address)"
970 			" tos (tos_value) proto (proto_value) ttl (ttl_value)"
971 			" vlan (vlan_value) flexbytes (flexbytes_value)"
972 			" (drop|fwd) pf|vf(vf_id) queue (queue_id)"
973 			" fd_id (fd_id_value)\n"
974 			"    Add/Del an IP type flow director filter.\n\n"
975 
976 			"flow_director_filter (port_id) mode IP (add|del|update)"
977 			" flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
978 			" src (src_ip_address) (src_port)"
979 			" dst (dst_ip_address) (dst_port)"
980 			" tos (tos_value) ttl (ttl_value)"
981 			" vlan (vlan_value) flexbytes (flexbytes_value)"
982 			" (drop|fwd) pf|vf(vf_id) queue (queue_id)"
983 			" fd_id (fd_id_value)\n"
984 			"    Add/Del an UDP/TCP type flow director filter.\n\n"
985 
986 			"flow_director_filter (port_id) mode IP (add|del|update)"
987 			" flow (ipv4-sctp|ipv6-sctp)"
988 			" src (src_ip_address) (src_port)"
989 			" dst (dst_ip_address) (dst_port)"
990 			" tag (verification_tag) "
991 			" tos (tos_value) ttl (ttl_value)"
992 			" vlan (vlan_value)"
993 			" flexbytes (flexbytes_value) (drop|fwd)"
994 			" pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
995 			"    Add/Del a SCTP type flow director filter.\n\n"
996 
997 			"flow_director_filter (port_id) mode IP (add|del|update)"
998 			" flow l2_payload ether (ethertype)"
999 			" flexbytes (flexbytes_value) (drop|fwd)"
1000 			" pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
1001 			"    Add/Del a l2 payload type flow director filter.\n\n"
1002 
1003 			"flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
1004 			" mac (mac_address) vlan (vlan_value)"
1005 			" flexbytes (flexbytes_value) (drop|fwd)"
1006 			" queue (queue_id) fd_id (fd_id_value)\n"
1007 			"    Add/Del a MAC-VLAN flow director filter.\n\n"
1008 
1009 			"flow_director_filter (port_id) mode Tunnel (add|del|update)"
1010 			" mac (mac_address) vlan (vlan_value)"
1011 			" tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
1012 			" flexbytes (flexbytes_value) (drop|fwd)"
1013 			" queue (queue_id) fd_id (fd_id_value)\n"
1014 			"    Add/Del a Tunnel flow director filter.\n\n"
1015 
1016 			"flow_director_filter (port_id) mode raw (add|del|update)"
1017 			" flow (flow_id) (drop|fwd) queue (queue_id)"
1018 			" fd_id (fd_id_value) packet (packet file name)\n"
1019 			"    Add/Del a raw type flow director filter.\n\n"
1020 
1021 			"flush_flow_director (port_id)\n"
1022 			"    Flush all flow director entries of a device.\n\n"
1023 
1024 			"flow_director_mask (port_id) mode IP vlan (vlan_value)"
1025 			" src_mask (ipv4_src) (ipv6_src) (src_port)"
1026 			" dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
1027 			"    Set flow director IP mask.\n\n"
1028 
1029 			"flow_director_mask (port_id) mode MAC-VLAN"
1030 			" vlan (vlan_value)\n"
1031 			"    Set flow director MAC-VLAN mask.\n\n"
1032 
1033 			"flow_director_mask (port_id) mode Tunnel"
1034 			" vlan (vlan_value) mac (mac_value)"
1035 			" tunnel-type (tunnel_type_value)"
1036 			" tunnel-id (tunnel_id_value)\n"
1037 			"    Set flow director Tunnel mask.\n\n"
1038 
1039 			"flow_director_flex_mask (port_id)"
1040 			" flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
1041 			"ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
1042 			" (mask)\n"
1043 			"    Configure mask of flex payload.\n\n"
1044 
1045 			"flow_director_flex_payload (port_id)"
1046 			" (raw|l2|l3|l4) (config)\n"
1047 			"    Configure flex payload selection.\n\n"
1048 
1049 			"get_sym_hash_ena_per_port (port_id)\n"
1050 			"    get symmetric hash enable configuration per port.\n\n"
1051 
1052 			"set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
1053 			"    set symmetric hash enable configuration per port"
1054 			" to enable or disable.\n\n"
1055 
1056 			"get_hash_global_config (port_id)\n"
1057 			"    Get the global configurations of hash filters.\n\n"
1058 
1059 			"set_hash_global_config (port_id) (toeplitz|simple_xor|symmetric_toeplitz|default)"
1060 			" (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1061 			"ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
1062 			" (enable|disable)\n"
1063 			"    Set the global configurations of hash filters.\n\n"
1064 
1065 			"set_hash_input_set (port_id) (ipv4|ipv4-frag|"
1066 			"ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1067 			"ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1068 			"l2_payload|<flowtype_id>) (ovlan|ivlan|src-ipv4|dst-ipv4|"
1069 			"src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
1070 			"ipv6-next-header|udp-src-port|udp-dst-port|"
1071 			"tcp-src-port|tcp-dst-port|sctp-src-port|"
1072 			"sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
1073 			"fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
1074 			"fld-8th|none) (select|add)\n"
1075 			"    Set the input set for hash.\n\n"
1076 
1077 			"set_fdir_input_set (port_id) "
1078 			"(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1079 			"ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1080 			"l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
1081 			"dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
1082 			"ipv6-next-header|ipv6-hop-limits|udp-src-port|"
1083 			"udp-dst-port|tcp-src-port|tcp-dst-port|"
1084 			"sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
1085 			" (select|add)\n"
1086 			"    Set the input set for FDir.\n\n"
1087 
1088 			"flow validate {port_id}"
1089 			" [group {group_id}] [priority {level}]"
1090 			" [ingress] [egress]"
1091 			" pattern {item} [/ {item} [...]] / end"
1092 			" actions {action} [/ {action} [...]] / end\n"
1093 			"    Check whether a flow rule can be created.\n\n"
1094 
1095 			"flow create {port_id}"
1096 			" [group {group_id}] [priority {level}]"
1097 			" [ingress] [egress]"
1098 			" pattern {item} [/ {item} [...]] / end"
1099 			" actions {action} [/ {action} [...]] / end\n"
1100 			"    Create a flow rule.\n\n"
1101 
1102 			"flow destroy {port_id} rule {rule_id} [...]\n"
1103 			"    Destroy specific flow rules.\n\n"
1104 
1105 			"flow flush {port_id}\n"
1106 			"    Destroy all flow rules.\n\n"
1107 
1108 			"flow query {port_id} {rule_id} {action}\n"
1109 			"    Query an existing flow rule.\n\n"
1110 
1111 			"flow list {port_id} [group {group_id}] [...]\n"
1112 			"    List existing flow rules sorted by priority,"
1113 			" filtered by group identifiers.\n\n"
1114 
1115 			"flow isolate {port_id} {boolean}\n"
1116 			"    Restrict ingress traffic to the defined"
1117 			" flow rules\n\n"
1118 
1119 			"set vxlan ip-version (ipv4|ipv6) vni (vni) udp-src"
1120 			" (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst"
1121 			" (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n"
1122 			"       Configure the VXLAN encapsulation for flows.\n\n"
1123 
1124 			"set vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)"
1125 			" udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)"
1126 			" ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)"
1127 			" eth-dst (eth-dst)\n"
1128 			"       Configure the VXLAN encapsulation for flows.\n\n"
1129 
1130 			"set vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src"
1131 			" (udp-src) udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl)"
1132 			" ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src)"
1133 			" eth-dst (eth-dst)\n"
1134 			"       Configure the VXLAN encapsulation for flows.\n\n"
1135 
1136 			"set nvgre ip-version (ipv4|ipv6) tni (tni) ip-src"
1137 			" (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst"
1138 			" (eth-dst)\n"
1139 			"       Configure the NVGRE encapsulation for flows.\n\n"
1140 
1141 			"set nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)"
1142 			" ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)"
1143 			" eth-src (eth-src) eth-dst (eth-dst)\n"
1144 			"       Configure the NVGRE encapsulation for flows.\n\n"
1145 
1146 			"set raw_encap {flow items}\n"
1147 			"	Configure the encapsulation with raw data.\n\n"
1148 
1149 			"set raw_decap {flow items}\n"
1150 			"	Configure the decapsulation with raw data.\n\n"
1151 
1152 		);
1153 	}
1154 
1155 	if (show_all || !strcmp(res->section, "traffic_management")) {
1156 		cmdline_printf(
1157 			cl,
1158 			"\n"
1159 			"Traffic Management:\n"
1160 			"--------------\n"
1161 			"show port tm cap (port_id)\n"
1162 			"       Display the port TM capability.\n\n"
1163 
1164 			"show port tm level cap (port_id) (level_id)\n"
1165 			"       Display the port TM hierarchical level capability.\n\n"
1166 
1167 			"show port tm node cap (port_id) (node_id)\n"
1168 			"       Display the port TM node capability.\n\n"
1169 
1170 			"show port tm node type (port_id) (node_id)\n"
1171 			"       Display the port TM node type.\n\n"
1172 
1173 			"show port tm node stats (port_id) (node_id) (clear)\n"
1174 			"       Display the port TM node stats.\n\n"
1175 
1176 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
1177 			"set port tm hierarchy default (port_id)\n"
1178 			"       Set default traffic Management hierarchy on a port\n\n"
1179 #endif
1180 
1181 			"add port tm node shaper profile (port_id) (shaper_profile_id)"
1182 			" (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)"
1183 			" (packet_length_adjust)\n"
1184 			"       Add port tm node private shaper profile.\n\n"
1185 
1186 			"del port tm node shaper profile (port_id) (shaper_profile_id)\n"
1187 			"       Delete port tm node private shaper profile.\n\n"
1188 
1189 			"add port tm node shared shaper (port_id) (shared_shaper_id)"
1190 			" (shaper_profile_id)\n"
1191 			"       Add/update port tm node shared shaper.\n\n"
1192 
1193 			"del port tm node shared shaper (port_id) (shared_shaper_id)\n"
1194 			"       Delete port tm node shared shaper.\n\n"
1195 
1196 			"set port tm node shaper profile (port_id) (node_id)"
1197 			" (shaper_profile_id)\n"
1198 			"       Set port tm node shaper profile.\n\n"
1199 
1200 			"add port tm node wred profile (port_id) (wred_profile_id)"
1201 			" (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
1202 			" (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
1203 			" (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
1204 			"       Add port tm node wred profile.\n\n"
1205 
1206 			"del port tm node wred profile (port_id) (wred_profile_id)\n"
1207 			"       Delete port tm node wred profile.\n\n"
1208 
1209 			"add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
1210 			" (priority) (weight) (level_id) (shaper_profile_id)"
1211 			" (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1212 			" [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1213 			"       Add port tm nonleaf node.\n\n"
1214 
1215 			"add port tm leaf node (port_id) (node_id) (parent_node_id)"
1216 			" (priority) (weight) (level_id) (shaper_profile_id)"
1217 			" (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
1218 			" [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1219 			"       Add port tm leaf node.\n\n"
1220 
1221 			"del port tm node (port_id) (node_id)\n"
1222 			"       Delete port tm node.\n\n"
1223 
1224 			"set port tm node parent (port_id) (node_id) (parent_node_id)"
1225 			" (priority) (weight)\n"
1226 			"       Set port tm node parent.\n\n"
1227 
1228 			"suspend port tm node (port_id) (node_id)"
1229 			"       Suspend tm node.\n\n"
1230 
1231 			"resume port tm node (port_id) (node_id)"
1232 			"       Resume tm node.\n\n"
1233 
1234 			"port tm hierarchy commit (port_id) (clean_on_fail)\n"
1235 			"       Commit tm hierarchy.\n\n"
1236 
1237 			"set port tm mark ip_ecn (port) (green) (yellow)"
1238 			" (red)\n"
1239 			"    Enables/Disables the traffic management marking"
1240 			" for IP ECN (Explicit Congestion Notification)"
1241 			" packets on a given port\n\n"
1242 
1243 			"set port tm mark ip_dscp (port) (green) (yellow)"
1244 			" (red)\n"
1245 			"    Enables/Disables the traffic management marking"
1246 			" on the port for IP dscp packets\n\n"
1247 
1248 			"set port tm mark vlan_dei (port) (green) (yellow)"
1249 			" (red)\n"
1250 			"    Enables/Disables the traffic management marking"
1251 			" on the port for VLAN packets with DEI enabled\n\n"
1252 		);
1253 	}
1254 
1255 	if (show_all || !strcmp(res->section, "devices")) {
1256 		cmdline_printf(
1257 			cl,
1258 			"\n"
1259 			"Device Operations:\n"
1260 			"--------------\n"
1261 			"device detach (identifier)\n"
1262 			"       Detach device by identifier.\n\n"
1263 		);
1264 	}
1265 
1266 }
1267 
1268 cmdline_parse_token_string_t cmd_help_long_help =
1269 	TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1270 
1271 cmdline_parse_token_string_t cmd_help_long_section =
1272 	TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1273 			"all#control#display#config#"
1274 			"ports#registers#filters#traffic_management#devices");
1275 
1276 cmdline_parse_inst_t cmd_help_long = {
1277 	.f = cmd_help_long_parsed,
1278 	.data = NULL,
1279 	.help_str = "help all|control|display|config|ports|register|"
1280 		"filters|traffic_management|devices: "
1281 		"Show help",
1282 	.tokens = {
1283 		(void *)&cmd_help_long_help,
1284 		(void *)&cmd_help_long_section,
1285 		NULL,
1286 	},
1287 };
1288 
1289 
1290 /* *** start/stop/close all ports *** */
1291 struct cmd_operate_port_result {
1292 	cmdline_fixed_string_t keyword;
1293 	cmdline_fixed_string_t name;
1294 	cmdline_fixed_string_t value;
1295 };
1296 
1297 static void cmd_operate_port_parsed(void *parsed_result,
1298 				__attribute__((unused)) struct cmdline *cl,
1299 				__attribute__((unused)) void *data)
1300 {
1301 	struct cmd_operate_port_result *res = parsed_result;
1302 
1303 	if (!strcmp(res->name, "start"))
1304 		start_port(RTE_PORT_ALL);
1305 	else if (!strcmp(res->name, "stop"))
1306 		stop_port(RTE_PORT_ALL);
1307 	else if (!strcmp(res->name, "close"))
1308 		close_port(RTE_PORT_ALL);
1309 	else if (!strcmp(res->name, "reset"))
1310 		reset_port(RTE_PORT_ALL);
1311 	else
1312 		printf("Unknown parameter\n");
1313 }
1314 
1315 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1316 	TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1317 								"port");
1318 cmdline_parse_token_string_t cmd_operate_port_all_port =
1319 	TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1320 						"start#stop#close#reset");
1321 cmdline_parse_token_string_t cmd_operate_port_all_all =
1322 	TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1323 
1324 cmdline_parse_inst_t cmd_operate_port = {
1325 	.f = cmd_operate_port_parsed,
1326 	.data = NULL,
1327 	.help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports",
1328 	.tokens = {
1329 		(void *)&cmd_operate_port_all_cmd,
1330 		(void *)&cmd_operate_port_all_port,
1331 		(void *)&cmd_operate_port_all_all,
1332 		NULL,
1333 	},
1334 };
1335 
1336 /* *** start/stop/close specific port *** */
1337 struct cmd_operate_specific_port_result {
1338 	cmdline_fixed_string_t keyword;
1339 	cmdline_fixed_string_t name;
1340 	uint8_t value;
1341 };
1342 
1343 static void cmd_operate_specific_port_parsed(void *parsed_result,
1344 			__attribute__((unused)) struct cmdline *cl,
1345 				__attribute__((unused)) void *data)
1346 {
1347 	struct cmd_operate_specific_port_result *res = parsed_result;
1348 
1349 	if (!strcmp(res->name, "start"))
1350 		start_port(res->value);
1351 	else if (!strcmp(res->name, "stop"))
1352 		stop_port(res->value);
1353 	else if (!strcmp(res->name, "close"))
1354 		close_port(res->value);
1355 	else if (!strcmp(res->name, "reset"))
1356 		reset_port(res->value);
1357 	else
1358 		printf("Unknown parameter\n");
1359 }
1360 
1361 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1362 	TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1363 							keyword, "port");
1364 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1365 	TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1366 						name, "start#stop#close#reset");
1367 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1368 	TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1369 							value, UINT8);
1370 
1371 cmdline_parse_inst_t cmd_operate_specific_port = {
1372 	.f = cmd_operate_specific_port_parsed,
1373 	.data = NULL,
1374 	.help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id",
1375 	.tokens = {
1376 		(void *)&cmd_operate_specific_port_cmd,
1377 		(void *)&cmd_operate_specific_port_port,
1378 		(void *)&cmd_operate_specific_port_id,
1379 		NULL,
1380 	},
1381 };
1382 
1383 /* *** enable port setup (after attach) via iterator or event *** */
1384 struct cmd_set_port_setup_on_result {
1385 	cmdline_fixed_string_t set;
1386 	cmdline_fixed_string_t port;
1387 	cmdline_fixed_string_t setup;
1388 	cmdline_fixed_string_t on;
1389 	cmdline_fixed_string_t mode;
1390 };
1391 
1392 static void cmd_set_port_setup_on_parsed(void *parsed_result,
1393 				__attribute__((unused)) struct cmdline *cl,
1394 				__attribute__((unused)) void *data)
1395 {
1396 	struct cmd_set_port_setup_on_result *res = parsed_result;
1397 
1398 	if (strcmp(res->mode, "event") == 0)
1399 		setup_on_probe_event = true;
1400 	else if (strcmp(res->mode, "iterator") == 0)
1401 		setup_on_probe_event = false;
1402 	else
1403 		printf("Unknown mode\n");
1404 }
1405 
1406 cmdline_parse_token_string_t cmd_set_port_setup_on_set =
1407 	TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1408 			set, "set");
1409 cmdline_parse_token_string_t cmd_set_port_setup_on_port =
1410 	TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1411 			port, "port");
1412 cmdline_parse_token_string_t cmd_set_port_setup_on_setup =
1413 	TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1414 			setup, "setup");
1415 cmdline_parse_token_string_t cmd_set_port_setup_on_on =
1416 	TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1417 			on, "on");
1418 cmdline_parse_token_string_t cmd_set_port_setup_on_mode =
1419 	TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1420 			mode, "iterator#event");
1421 
1422 cmdline_parse_inst_t cmd_set_port_setup_on = {
1423 	.f = cmd_set_port_setup_on_parsed,
1424 	.data = NULL,
1425 	.help_str = "set port setup on iterator|event",
1426 	.tokens = {
1427 		(void *)&cmd_set_port_setup_on_set,
1428 		(void *)&cmd_set_port_setup_on_port,
1429 		(void *)&cmd_set_port_setup_on_setup,
1430 		(void *)&cmd_set_port_setup_on_on,
1431 		(void *)&cmd_set_port_setup_on_mode,
1432 		NULL,
1433 	},
1434 };
1435 
1436 /* *** attach a specified port *** */
1437 struct cmd_operate_attach_port_result {
1438 	cmdline_fixed_string_t port;
1439 	cmdline_fixed_string_t keyword;
1440 	cmdline_fixed_string_t identifier;
1441 };
1442 
1443 static void cmd_operate_attach_port_parsed(void *parsed_result,
1444 				__attribute__((unused)) struct cmdline *cl,
1445 				__attribute__((unused)) void *data)
1446 {
1447 	struct cmd_operate_attach_port_result *res = parsed_result;
1448 
1449 	if (!strcmp(res->keyword, "attach"))
1450 		attach_port(res->identifier);
1451 	else
1452 		printf("Unknown parameter\n");
1453 }
1454 
1455 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1456 	TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1457 			port, "port");
1458 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1459 	TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1460 			keyword, "attach");
1461 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1462 	TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1463 			identifier, NULL);
1464 
1465 cmdline_parse_inst_t cmd_operate_attach_port = {
1466 	.f = cmd_operate_attach_port_parsed,
1467 	.data = NULL,
1468 	.help_str = "port attach <identifier>: "
1469 		"(identifier: pci address or virtual dev name)",
1470 	.tokens = {
1471 		(void *)&cmd_operate_attach_port_port,
1472 		(void *)&cmd_operate_attach_port_keyword,
1473 		(void *)&cmd_operate_attach_port_identifier,
1474 		NULL,
1475 	},
1476 };
1477 
1478 /* *** detach a specified port *** */
1479 struct cmd_operate_detach_port_result {
1480 	cmdline_fixed_string_t port;
1481 	cmdline_fixed_string_t keyword;
1482 	portid_t port_id;
1483 };
1484 
1485 static void cmd_operate_detach_port_parsed(void *parsed_result,
1486 				__attribute__((unused)) struct cmdline *cl,
1487 				__attribute__((unused)) void *data)
1488 {
1489 	struct cmd_operate_detach_port_result *res = parsed_result;
1490 
1491 	if (!strcmp(res->keyword, "detach"))
1492 		detach_port_device(res->port_id);
1493 	else
1494 		printf("Unknown parameter\n");
1495 }
1496 
1497 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1498 	TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1499 			port, "port");
1500 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1501 	TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1502 			keyword, "detach");
1503 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1504 	TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1505 			port_id, UINT16);
1506 
1507 cmdline_parse_inst_t cmd_operate_detach_port = {
1508 	.f = cmd_operate_detach_port_parsed,
1509 	.data = NULL,
1510 	.help_str = "port detach <port_id>",
1511 	.tokens = {
1512 		(void *)&cmd_operate_detach_port_port,
1513 		(void *)&cmd_operate_detach_port_keyword,
1514 		(void *)&cmd_operate_detach_port_port_id,
1515 		NULL,
1516 	},
1517 };
1518 
1519 /* *** detach device by identifier *** */
1520 struct cmd_operate_detach_device_result {
1521 	cmdline_fixed_string_t device;
1522 	cmdline_fixed_string_t keyword;
1523 	cmdline_fixed_string_t identifier;
1524 };
1525 
1526 static void cmd_operate_detach_device_parsed(void *parsed_result,
1527 				__attribute__((unused)) struct cmdline *cl,
1528 				__attribute__((unused)) void *data)
1529 {
1530 	struct cmd_operate_detach_device_result *res = parsed_result;
1531 
1532 	if (!strcmp(res->keyword, "detach"))
1533 		detach_device(res->identifier);
1534 	else
1535 		printf("Unknown parameter\n");
1536 }
1537 
1538 cmdline_parse_token_string_t cmd_operate_detach_device_device =
1539 	TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1540 			device, "device");
1541 cmdline_parse_token_string_t cmd_operate_detach_device_keyword =
1542 	TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1543 			keyword, "detach");
1544 cmdline_parse_token_string_t cmd_operate_detach_device_identifier =
1545 	TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1546 			identifier, NULL);
1547 
1548 cmdline_parse_inst_t cmd_operate_detach_device = {
1549 	.f = cmd_operate_detach_device_parsed,
1550 	.data = NULL,
1551 	.help_str = "device detach <identifier>:"
1552 		"(identifier: pci address or virtual dev name)",
1553 	.tokens = {
1554 		(void *)&cmd_operate_detach_device_device,
1555 		(void *)&cmd_operate_detach_device_keyword,
1556 		(void *)&cmd_operate_detach_device_identifier,
1557 		NULL,
1558 	},
1559 };
1560 /* *** configure speed for all ports *** */
1561 struct cmd_config_speed_all {
1562 	cmdline_fixed_string_t port;
1563 	cmdline_fixed_string_t keyword;
1564 	cmdline_fixed_string_t all;
1565 	cmdline_fixed_string_t item1;
1566 	cmdline_fixed_string_t item2;
1567 	cmdline_fixed_string_t value1;
1568 	cmdline_fixed_string_t value2;
1569 };
1570 
1571 static int
1572 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1573 {
1574 
1575 	int duplex;
1576 
1577 	if (!strcmp(duplexstr, "half")) {
1578 		duplex = ETH_LINK_HALF_DUPLEX;
1579 	} else if (!strcmp(duplexstr, "full")) {
1580 		duplex = ETH_LINK_FULL_DUPLEX;
1581 	} else if (!strcmp(duplexstr, "auto")) {
1582 		duplex = ETH_LINK_FULL_DUPLEX;
1583 	} else {
1584 		printf("Unknown duplex parameter\n");
1585 		return -1;
1586 	}
1587 
1588 	if (!strcmp(speedstr, "10")) {
1589 		*speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1590 				ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1591 	} else if (!strcmp(speedstr, "100")) {
1592 		*speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1593 				ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1594 	} else {
1595 		if (duplex != ETH_LINK_FULL_DUPLEX) {
1596 			printf("Invalid speed/duplex parameters\n");
1597 			return -1;
1598 		}
1599 		if (!strcmp(speedstr, "1000")) {
1600 			*speed = ETH_LINK_SPEED_1G;
1601 		} else if (!strcmp(speedstr, "10000")) {
1602 			*speed = ETH_LINK_SPEED_10G;
1603 		} else if (!strcmp(speedstr, "25000")) {
1604 			*speed = ETH_LINK_SPEED_25G;
1605 		} else if (!strcmp(speedstr, "40000")) {
1606 			*speed = ETH_LINK_SPEED_40G;
1607 		} else if (!strcmp(speedstr, "50000")) {
1608 			*speed = ETH_LINK_SPEED_50G;
1609 		} else if (!strcmp(speedstr, "100000")) {
1610 			*speed = ETH_LINK_SPEED_100G;
1611 		} else if (!strcmp(speedstr, "auto")) {
1612 			*speed = ETH_LINK_SPEED_AUTONEG;
1613 		} else {
1614 			printf("Unknown speed parameter\n");
1615 			return -1;
1616 		}
1617 	}
1618 
1619 	return 0;
1620 }
1621 
1622 static void
1623 cmd_config_speed_all_parsed(void *parsed_result,
1624 			__attribute__((unused)) struct cmdline *cl,
1625 			__attribute__((unused)) void *data)
1626 {
1627 	struct cmd_config_speed_all *res = parsed_result;
1628 	uint32_t link_speed;
1629 	portid_t pid;
1630 
1631 	if (!all_ports_stopped()) {
1632 		printf("Please stop all ports first\n");
1633 		return;
1634 	}
1635 
1636 	if (parse_and_check_speed_duplex(res->value1, res->value2,
1637 			&link_speed) < 0)
1638 		return;
1639 
1640 	RTE_ETH_FOREACH_DEV(pid) {
1641 		ports[pid].dev_conf.link_speeds = link_speed;
1642 	}
1643 
1644 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1645 }
1646 
1647 cmdline_parse_token_string_t cmd_config_speed_all_port =
1648 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1649 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1650 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1651 							"config");
1652 cmdline_parse_token_string_t cmd_config_speed_all_all =
1653 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1654 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1655 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1656 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1657 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1658 				"10#100#1000#10000#25000#40000#50000#100000#auto");
1659 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1660 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1661 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1662 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1663 						"half#full#auto");
1664 
1665 cmdline_parse_inst_t cmd_config_speed_all = {
1666 	.f = cmd_config_speed_all_parsed,
1667 	.data = NULL,
1668 	.help_str = "port config all speed "
1669 		"10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1670 							"half|full|auto",
1671 	.tokens = {
1672 		(void *)&cmd_config_speed_all_port,
1673 		(void *)&cmd_config_speed_all_keyword,
1674 		(void *)&cmd_config_speed_all_all,
1675 		(void *)&cmd_config_speed_all_item1,
1676 		(void *)&cmd_config_speed_all_value1,
1677 		(void *)&cmd_config_speed_all_item2,
1678 		(void *)&cmd_config_speed_all_value2,
1679 		NULL,
1680 	},
1681 };
1682 
1683 /* *** configure speed for specific port *** */
1684 struct cmd_config_speed_specific {
1685 	cmdline_fixed_string_t port;
1686 	cmdline_fixed_string_t keyword;
1687 	portid_t id;
1688 	cmdline_fixed_string_t item1;
1689 	cmdline_fixed_string_t item2;
1690 	cmdline_fixed_string_t value1;
1691 	cmdline_fixed_string_t value2;
1692 };
1693 
1694 static void
1695 cmd_config_speed_specific_parsed(void *parsed_result,
1696 				__attribute__((unused)) struct cmdline *cl,
1697 				__attribute__((unused)) void *data)
1698 {
1699 	struct cmd_config_speed_specific *res = parsed_result;
1700 	uint32_t link_speed;
1701 
1702 	if (!all_ports_stopped()) {
1703 		printf("Please stop all ports first\n");
1704 		return;
1705 	}
1706 
1707 	if (port_id_is_invalid(res->id, ENABLED_WARN))
1708 		return;
1709 
1710 	if (parse_and_check_speed_duplex(res->value1, res->value2,
1711 			&link_speed) < 0)
1712 		return;
1713 
1714 	ports[res->id].dev_conf.link_speeds = link_speed;
1715 
1716 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1717 }
1718 
1719 
1720 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1721 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1722 								"port");
1723 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1724 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1725 								"config");
1726 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1727 	TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT16);
1728 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1729 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1730 								"speed");
1731 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1732 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1733 				"10#100#1000#10000#25000#40000#50000#100000#auto");
1734 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1735 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1736 								"duplex");
1737 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1738 	TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1739 							"half#full#auto");
1740 
1741 cmdline_parse_inst_t cmd_config_speed_specific = {
1742 	.f = cmd_config_speed_specific_parsed,
1743 	.data = NULL,
1744 	.help_str = "port config <port_id> speed "
1745 		"10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1746 							"half|full|auto",
1747 	.tokens = {
1748 		(void *)&cmd_config_speed_specific_port,
1749 		(void *)&cmd_config_speed_specific_keyword,
1750 		(void *)&cmd_config_speed_specific_id,
1751 		(void *)&cmd_config_speed_specific_item1,
1752 		(void *)&cmd_config_speed_specific_value1,
1753 		(void *)&cmd_config_speed_specific_item2,
1754 		(void *)&cmd_config_speed_specific_value2,
1755 		NULL,
1756 	},
1757 };
1758 
1759 /* *** configure loopback for all ports *** */
1760 struct cmd_config_loopback_all {
1761 	cmdline_fixed_string_t port;
1762 	cmdline_fixed_string_t keyword;
1763 	cmdline_fixed_string_t all;
1764 	cmdline_fixed_string_t item;
1765 	uint32_t mode;
1766 };
1767 
1768 static void
1769 cmd_config_loopback_all_parsed(void *parsed_result,
1770 			__attribute__((unused)) struct cmdline *cl,
1771 			__attribute__((unused)) void *data)
1772 {
1773 	struct cmd_config_loopback_all *res = parsed_result;
1774 	portid_t pid;
1775 
1776 	if (!all_ports_stopped()) {
1777 		printf("Please stop all ports first\n");
1778 		return;
1779 	}
1780 
1781 	RTE_ETH_FOREACH_DEV(pid) {
1782 		ports[pid].dev_conf.lpbk_mode = res->mode;
1783 	}
1784 
1785 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1786 }
1787 
1788 cmdline_parse_token_string_t cmd_config_loopback_all_port =
1789 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1790 cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1791 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1792 							"config");
1793 cmdline_parse_token_string_t cmd_config_loopback_all_all =
1794 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1795 cmdline_parse_token_string_t cmd_config_loopback_all_item =
1796 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1797 							"loopback");
1798 cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1799 	TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, UINT32);
1800 
1801 cmdline_parse_inst_t cmd_config_loopback_all = {
1802 	.f = cmd_config_loopback_all_parsed,
1803 	.data = NULL,
1804 	.help_str = "port config all loopback <mode>",
1805 	.tokens = {
1806 		(void *)&cmd_config_loopback_all_port,
1807 		(void *)&cmd_config_loopback_all_keyword,
1808 		(void *)&cmd_config_loopback_all_all,
1809 		(void *)&cmd_config_loopback_all_item,
1810 		(void *)&cmd_config_loopback_all_mode,
1811 		NULL,
1812 	},
1813 };
1814 
1815 /* *** configure loopback for specific port *** */
1816 struct cmd_config_loopback_specific {
1817 	cmdline_fixed_string_t port;
1818 	cmdline_fixed_string_t keyword;
1819 	uint16_t port_id;
1820 	cmdline_fixed_string_t item;
1821 	uint32_t mode;
1822 };
1823 
1824 static void
1825 cmd_config_loopback_specific_parsed(void *parsed_result,
1826 				__attribute__((unused)) struct cmdline *cl,
1827 				__attribute__((unused)) void *data)
1828 {
1829 	struct cmd_config_loopback_specific *res = parsed_result;
1830 
1831 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1832 		return;
1833 
1834 	if (!port_is_stopped(res->port_id)) {
1835 		printf("Please stop port %u first\n", res->port_id);
1836 		return;
1837 	}
1838 
1839 	ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1840 
1841 	cmd_reconfig_device_queue(res->port_id, 1, 1);
1842 }
1843 
1844 
1845 cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1846 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1847 								"port");
1848 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1849 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1850 								"config");
1851 cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1852 	TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1853 								UINT16);
1854 cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1855 	TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1856 								"loopback");
1857 cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1858 	TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1859 			      UINT32);
1860 
1861 cmdline_parse_inst_t cmd_config_loopback_specific = {
1862 	.f = cmd_config_loopback_specific_parsed,
1863 	.data = NULL,
1864 	.help_str = "port config <port_id> loopback <mode>",
1865 	.tokens = {
1866 		(void *)&cmd_config_loopback_specific_port,
1867 		(void *)&cmd_config_loopback_specific_keyword,
1868 		(void *)&cmd_config_loopback_specific_id,
1869 		(void *)&cmd_config_loopback_specific_item,
1870 		(void *)&cmd_config_loopback_specific_mode,
1871 		NULL,
1872 	},
1873 };
1874 
1875 /* *** configure txq/rxq, txd/rxd *** */
1876 struct cmd_config_rx_tx {
1877 	cmdline_fixed_string_t port;
1878 	cmdline_fixed_string_t keyword;
1879 	cmdline_fixed_string_t all;
1880 	cmdline_fixed_string_t name;
1881 	uint16_t value;
1882 };
1883 
1884 static void
1885 cmd_config_rx_tx_parsed(void *parsed_result,
1886 			__attribute__((unused)) struct cmdline *cl,
1887 			__attribute__((unused)) void *data)
1888 {
1889 	struct cmd_config_rx_tx *res = parsed_result;
1890 
1891 	if (!all_ports_stopped()) {
1892 		printf("Please stop all ports first\n");
1893 		return;
1894 	}
1895 	if (!strcmp(res->name, "rxq")) {
1896 		if (!res->value && !nb_txq) {
1897 			printf("Warning: Either rx or tx queues should be non zero\n");
1898 			return;
1899 		}
1900 		if (check_nb_rxq(res->value) != 0)
1901 			return;
1902 		nb_rxq = res->value;
1903 	}
1904 	else if (!strcmp(res->name, "txq")) {
1905 		if (!res->value && !nb_rxq) {
1906 			printf("Warning: Either rx or tx queues should be non zero\n");
1907 			return;
1908 		}
1909 		if (check_nb_txq(res->value) != 0)
1910 			return;
1911 		nb_txq = res->value;
1912 	}
1913 	else if (!strcmp(res->name, "rxd")) {
1914 		if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1915 			printf("rxd %d invalid - must be > 0 && <= %d\n",
1916 					res->value, RTE_TEST_RX_DESC_MAX);
1917 			return;
1918 		}
1919 		nb_rxd = res->value;
1920 	} else if (!strcmp(res->name, "txd")) {
1921 		if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1922 			printf("txd %d invalid - must be > 0 && <= %d\n",
1923 					res->value, RTE_TEST_TX_DESC_MAX);
1924 			return;
1925 		}
1926 		nb_txd = res->value;
1927 	} else {
1928 		printf("Unknown parameter\n");
1929 		return;
1930 	}
1931 
1932 	fwd_config_setup();
1933 
1934 	init_port_config();
1935 
1936 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1937 }
1938 
1939 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1940 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1941 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1942 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1943 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1944 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1945 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1946 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1947 						"rxq#txq#rxd#txd");
1948 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1949 	TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1950 
1951 cmdline_parse_inst_t cmd_config_rx_tx = {
1952 	.f = cmd_config_rx_tx_parsed,
1953 	.data = NULL,
1954 	.help_str = "port config all rxq|txq|rxd|txd <value>",
1955 	.tokens = {
1956 		(void *)&cmd_config_rx_tx_port,
1957 		(void *)&cmd_config_rx_tx_keyword,
1958 		(void *)&cmd_config_rx_tx_all,
1959 		(void *)&cmd_config_rx_tx_name,
1960 		(void *)&cmd_config_rx_tx_value,
1961 		NULL,
1962 	},
1963 };
1964 
1965 /* *** config max packet length *** */
1966 struct cmd_config_max_pkt_len_result {
1967 	cmdline_fixed_string_t port;
1968 	cmdline_fixed_string_t keyword;
1969 	cmdline_fixed_string_t all;
1970 	cmdline_fixed_string_t name;
1971 	uint32_t value;
1972 };
1973 
1974 static void
1975 cmd_config_max_pkt_len_parsed(void *parsed_result,
1976 				__attribute__((unused)) struct cmdline *cl,
1977 				__attribute__((unused)) void *data)
1978 {
1979 	struct cmd_config_max_pkt_len_result *res = parsed_result;
1980 	portid_t pid;
1981 
1982 	if (!all_ports_stopped()) {
1983 		printf("Please stop all ports first\n");
1984 		return;
1985 	}
1986 
1987 	RTE_ETH_FOREACH_DEV(pid) {
1988 		struct rte_port *port = &ports[pid];
1989 		uint64_t rx_offloads = port->dev_conf.rxmode.offloads;
1990 
1991 		if (!strcmp(res->name, "max-pkt-len")) {
1992 			if (res->value < RTE_ETHER_MIN_LEN) {
1993 				printf("max-pkt-len can not be less than %d\n",
1994 						RTE_ETHER_MIN_LEN);
1995 				return;
1996 			}
1997 			if (res->value == port->dev_conf.rxmode.max_rx_pkt_len)
1998 				return;
1999 
2000 			port->dev_conf.rxmode.max_rx_pkt_len = res->value;
2001 			if (res->value > RTE_ETHER_MAX_LEN)
2002 				rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
2003 			else
2004 				rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
2005 			port->dev_conf.rxmode.offloads = rx_offloads;
2006 		} else {
2007 			printf("Unknown parameter\n");
2008 			return;
2009 		}
2010 	}
2011 
2012 	init_port_config();
2013 
2014 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2015 }
2016 
2017 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
2018 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
2019 								"port");
2020 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
2021 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
2022 								"config");
2023 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
2024 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
2025 								"all");
2026 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
2027 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
2028 								"max-pkt-len");
2029 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
2030 	TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
2031 								UINT32);
2032 
2033 cmdline_parse_inst_t cmd_config_max_pkt_len = {
2034 	.f = cmd_config_max_pkt_len_parsed,
2035 	.data = NULL,
2036 	.help_str = "port config all max-pkt-len <value>",
2037 	.tokens = {
2038 		(void *)&cmd_config_max_pkt_len_port,
2039 		(void *)&cmd_config_max_pkt_len_keyword,
2040 		(void *)&cmd_config_max_pkt_len_all,
2041 		(void *)&cmd_config_max_pkt_len_name,
2042 		(void *)&cmd_config_max_pkt_len_value,
2043 		NULL,
2044 	},
2045 };
2046 
2047 /* *** config max LRO aggregated packet size *** */
2048 struct cmd_config_max_lro_pkt_size_result {
2049 	cmdline_fixed_string_t port;
2050 	cmdline_fixed_string_t keyword;
2051 	cmdline_fixed_string_t all;
2052 	cmdline_fixed_string_t name;
2053 	uint32_t value;
2054 };
2055 
2056 static void
2057 cmd_config_max_lro_pkt_size_parsed(void *parsed_result,
2058 				__attribute__((unused)) struct cmdline *cl,
2059 				__attribute__((unused)) void *data)
2060 {
2061 	struct cmd_config_max_lro_pkt_size_result *res = parsed_result;
2062 	portid_t pid;
2063 
2064 	if (!all_ports_stopped()) {
2065 		printf("Please stop all ports first\n");
2066 		return;
2067 	}
2068 
2069 	RTE_ETH_FOREACH_DEV(pid) {
2070 		struct rte_port *port = &ports[pid];
2071 
2072 		if (!strcmp(res->name, "max-lro-pkt-size")) {
2073 			if (res->value ==
2074 					port->dev_conf.rxmode.max_lro_pkt_size)
2075 				return;
2076 
2077 			port->dev_conf.rxmode.max_lro_pkt_size = res->value;
2078 		} else {
2079 			printf("Unknown parameter\n");
2080 			return;
2081 		}
2082 	}
2083 
2084 	init_port_config();
2085 
2086 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2087 }
2088 
2089 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_port =
2090 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2091 				 port, "port");
2092 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_keyword =
2093 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2094 				 keyword, "config");
2095 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_all =
2096 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2097 				 all, "all");
2098 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_name =
2099 	TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2100 				 name, "max-lro-pkt-size");
2101 cmdline_parse_token_num_t cmd_config_max_lro_pkt_size_value =
2102 	TOKEN_NUM_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2103 			      value, UINT32);
2104 
2105 cmdline_parse_inst_t cmd_config_max_lro_pkt_size = {
2106 	.f = cmd_config_max_lro_pkt_size_parsed,
2107 	.data = NULL,
2108 	.help_str = "port config all max-lro-pkt-size <value>",
2109 	.tokens = {
2110 		(void *)&cmd_config_max_lro_pkt_size_port,
2111 		(void *)&cmd_config_max_lro_pkt_size_keyword,
2112 		(void *)&cmd_config_max_lro_pkt_size_all,
2113 		(void *)&cmd_config_max_lro_pkt_size_name,
2114 		(void *)&cmd_config_max_lro_pkt_size_value,
2115 		NULL,
2116 	},
2117 };
2118 
2119 /* *** configure port MTU *** */
2120 struct cmd_config_mtu_result {
2121 	cmdline_fixed_string_t port;
2122 	cmdline_fixed_string_t keyword;
2123 	cmdline_fixed_string_t mtu;
2124 	portid_t port_id;
2125 	uint16_t value;
2126 };
2127 
2128 static void
2129 cmd_config_mtu_parsed(void *parsed_result,
2130 		      __attribute__((unused)) struct cmdline *cl,
2131 		      __attribute__((unused)) void *data)
2132 {
2133 	struct cmd_config_mtu_result *res = parsed_result;
2134 
2135 	if (res->value < RTE_ETHER_MIN_LEN) {
2136 		printf("mtu cannot be less than %d\n", RTE_ETHER_MIN_LEN);
2137 		return;
2138 	}
2139 	port_mtu_set(res->port_id, res->value);
2140 }
2141 
2142 cmdline_parse_token_string_t cmd_config_mtu_port =
2143 	TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
2144 				 "port");
2145 cmdline_parse_token_string_t cmd_config_mtu_keyword =
2146 	TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2147 				 "config");
2148 cmdline_parse_token_string_t cmd_config_mtu_mtu =
2149 	TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2150 				 "mtu");
2151 cmdline_parse_token_num_t cmd_config_mtu_port_id =
2152 	TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT16);
2153 cmdline_parse_token_num_t cmd_config_mtu_value =
2154 	TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
2155 
2156 cmdline_parse_inst_t cmd_config_mtu = {
2157 	.f = cmd_config_mtu_parsed,
2158 	.data = NULL,
2159 	.help_str = "port config mtu <port_id> <value>",
2160 	.tokens = {
2161 		(void *)&cmd_config_mtu_port,
2162 		(void *)&cmd_config_mtu_keyword,
2163 		(void *)&cmd_config_mtu_mtu,
2164 		(void *)&cmd_config_mtu_port_id,
2165 		(void *)&cmd_config_mtu_value,
2166 		NULL,
2167 	},
2168 };
2169 
2170 /* *** configure rx mode *** */
2171 struct cmd_config_rx_mode_flag {
2172 	cmdline_fixed_string_t port;
2173 	cmdline_fixed_string_t keyword;
2174 	cmdline_fixed_string_t all;
2175 	cmdline_fixed_string_t name;
2176 	cmdline_fixed_string_t value;
2177 };
2178 
2179 static void
2180 cmd_config_rx_mode_flag_parsed(void *parsed_result,
2181 				__attribute__((unused)) struct cmdline *cl,
2182 				__attribute__((unused)) void *data)
2183 {
2184 	struct cmd_config_rx_mode_flag *res = parsed_result;
2185 
2186 	if (!all_ports_stopped()) {
2187 		printf("Please stop all ports first\n");
2188 		return;
2189 	}
2190 
2191 	if (!strcmp(res->name, "drop-en")) {
2192 		if (!strcmp(res->value, "on"))
2193 			rx_drop_en = 1;
2194 		else if (!strcmp(res->value, "off"))
2195 			rx_drop_en = 0;
2196 		else {
2197 			printf("Unknown parameter\n");
2198 			return;
2199 		}
2200 	} else {
2201 		printf("Unknown parameter\n");
2202 		return;
2203 	}
2204 
2205 	init_port_config();
2206 
2207 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2208 }
2209 
2210 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
2211 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
2212 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
2213 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
2214 								"config");
2215 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2216 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2217 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2218 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2219 					"drop-en");
2220 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2221 	TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2222 							"on#off");
2223 
2224 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2225 	.f = cmd_config_rx_mode_flag_parsed,
2226 	.data = NULL,
2227 	.help_str = "port config all drop-en on|off",
2228 	.tokens = {
2229 		(void *)&cmd_config_rx_mode_flag_port,
2230 		(void *)&cmd_config_rx_mode_flag_keyword,
2231 		(void *)&cmd_config_rx_mode_flag_all,
2232 		(void *)&cmd_config_rx_mode_flag_name,
2233 		(void *)&cmd_config_rx_mode_flag_value,
2234 		NULL,
2235 	},
2236 };
2237 
2238 /* *** configure rss *** */
2239 struct cmd_config_rss {
2240 	cmdline_fixed_string_t port;
2241 	cmdline_fixed_string_t keyword;
2242 	cmdline_fixed_string_t all;
2243 	cmdline_fixed_string_t name;
2244 	cmdline_fixed_string_t value;
2245 };
2246 
2247 static void
2248 cmd_config_rss_parsed(void *parsed_result,
2249 			__attribute__((unused)) struct cmdline *cl,
2250 			__attribute__((unused)) void *data)
2251 {
2252 	struct cmd_config_rss *res = parsed_result;
2253 	struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2254 	struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2255 	int use_default = 0;
2256 	int all_updated = 1;
2257 	int diag;
2258 	uint16_t i;
2259 	int ret;
2260 
2261 	if (!strcmp(res->value, "all"))
2262 		rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
2263 				ETH_RSS_UDP | ETH_RSS_SCTP |
2264 					ETH_RSS_L2_PAYLOAD;
2265 	else if (!strcmp(res->value, "ip"))
2266 		rss_conf.rss_hf = ETH_RSS_IP;
2267 	else if (!strcmp(res->value, "udp"))
2268 		rss_conf.rss_hf = ETH_RSS_UDP;
2269 	else if (!strcmp(res->value, "tcp"))
2270 		rss_conf.rss_hf = ETH_RSS_TCP;
2271 	else if (!strcmp(res->value, "sctp"))
2272 		rss_conf.rss_hf = ETH_RSS_SCTP;
2273 	else if (!strcmp(res->value, "ether"))
2274 		rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
2275 	else if (!strcmp(res->value, "port"))
2276 		rss_conf.rss_hf = ETH_RSS_PORT;
2277 	else if (!strcmp(res->value, "vxlan"))
2278 		rss_conf.rss_hf = ETH_RSS_VXLAN;
2279 	else if (!strcmp(res->value, "geneve"))
2280 		rss_conf.rss_hf = ETH_RSS_GENEVE;
2281 	else if (!strcmp(res->value, "nvgre"))
2282 		rss_conf.rss_hf = ETH_RSS_NVGRE;
2283 	else if (!strcmp(res->value, "l3-src-only"))
2284 		rss_conf.rss_hf = ETH_RSS_L3_SRC_ONLY;
2285 	else if (!strcmp(res->value, "l3-dst-only"))
2286 		rss_conf.rss_hf = ETH_RSS_L3_DST_ONLY;
2287 	else if (!strcmp(res->value, "l4-src-only"))
2288 		rss_conf.rss_hf = ETH_RSS_L4_SRC_ONLY;
2289 	else if (!strcmp(res->value, "l4-dst-only"))
2290 		rss_conf.rss_hf = ETH_RSS_L4_DST_ONLY;
2291 	else if (!strcmp(res->value, "none"))
2292 		rss_conf.rss_hf = 0;
2293 	else if (!strcmp(res->value, "default"))
2294 		use_default = 1;
2295 	else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2296 						atoi(res->value) < 64)
2297 		rss_conf.rss_hf = 1ULL << atoi(res->value);
2298 	else {
2299 		printf("Unknown parameter\n");
2300 		return;
2301 	}
2302 	rss_conf.rss_key = NULL;
2303 	/* Update global configuration for RSS types. */
2304 	RTE_ETH_FOREACH_DEV(i) {
2305 		struct rte_eth_rss_conf local_rss_conf;
2306 
2307 		ret = eth_dev_info_get_print_err(i, &dev_info);
2308 		if (ret != 0)
2309 			return;
2310 
2311 		if (use_default)
2312 			rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2313 
2314 		local_rss_conf = rss_conf;
2315 		local_rss_conf.rss_hf = rss_conf.rss_hf &
2316 			dev_info.flow_type_rss_offloads;
2317 		if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2318 			printf("Port %u modified RSS hash function based on hardware support,"
2319 				"requested:%#"PRIx64" configured:%#"PRIx64"\n",
2320 				i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2321 		}
2322 		diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2323 		if (diag < 0) {
2324 			all_updated = 0;
2325 			printf("Configuration of RSS hash at ethernet port %d "
2326 				"failed with error (%d): %s.\n",
2327 				i, -diag, strerror(-diag));
2328 		}
2329 	}
2330 	if (all_updated && !use_default)
2331 		rss_hf = rss_conf.rss_hf;
2332 }
2333 
2334 cmdline_parse_token_string_t cmd_config_rss_port =
2335 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2336 cmdline_parse_token_string_t cmd_config_rss_keyword =
2337 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2338 cmdline_parse_token_string_t cmd_config_rss_all =
2339 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2340 cmdline_parse_token_string_t cmd_config_rss_name =
2341 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2342 cmdline_parse_token_string_t cmd_config_rss_value =
2343 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2344 
2345 cmdline_parse_inst_t cmd_config_rss = {
2346 	.f = cmd_config_rss_parsed,
2347 	.data = NULL,
2348 	.help_str = "port config all rss "
2349 		"all|default|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|vxlan-gpe|none|<flowtype_id>",
2350 	.tokens = {
2351 		(void *)&cmd_config_rss_port,
2352 		(void *)&cmd_config_rss_keyword,
2353 		(void *)&cmd_config_rss_all,
2354 		(void *)&cmd_config_rss_name,
2355 		(void *)&cmd_config_rss_value,
2356 		NULL,
2357 	},
2358 };
2359 
2360 /* *** configure rss hash key *** */
2361 struct cmd_config_rss_hash_key {
2362 	cmdline_fixed_string_t port;
2363 	cmdline_fixed_string_t config;
2364 	portid_t port_id;
2365 	cmdline_fixed_string_t rss_hash_key;
2366 	cmdline_fixed_string_t rss_type;
2367 	cmdline_fixed_string_t key;
2368 };
2369 
2370 static uint8_t
2371 hexa_digit_to_value(char hexa_digit)
2372 {
2373 	if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2374 		return (uint8_t) (hexa_digit - '0');
2375 	if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2376 		return (uint8_t) ((hexa_digit - 'a') + 10);
2377 	if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2378 		return (uint8_t) ((hexa_digit - 'A') + 10);
2379 	/* Invalid hexa digit */
2380 	return 0xFF;
2381 }
2382 
2383 static uint8_t
2384 parse_and_check_key_hexa_digit(char *key, int idx)
2385 {
2386 	uint8_t hexa_v;
2387 
2388 	hexa_v = hexa_digit_to_value(key[idx]);
2389 	if (hexa_v == 0xFF)
2390 		printf("invalid key: character %c at position %d is not a "
2391 		       "valid hexa digit\n", key[idx], idx);
2392 	return hexa_v;
2393 }
2394 
2395 static void
2396 cmd_config_rss_hash_key_parsed(void *parsed_result,
2397 			       __attribute__((unused)) struct cmdline *cl,
2398 			       __attribute__((unused)) void *data)
2399 {
2400 	struct cmd_config_rss_hash_key *res = parsed_result;
2401 	uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2402 	uint8_t xdgt0;
2403 	uint8_t xdgt1;
2404 	int i;
2405 	struct rte_eth_dev_info dev_info;
2406 	uint8_t hash_key_size;
2407 	uint32_t key_len;
2408 	int ret;
2409 
2410 	ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2411 	if (ret != 0)
2412 		return;
2413 
2414 	if (dev_info.hash_key_size > 0 &&
2415 			dev_info.hash_key_size <= sizeof(hash_key))
2416 		hash_key_size = dev_info.hash_key_size;
2417 	else {
2418 		printf("dev_info did not provide a valid hash key size\n");
2419 		return;
2420 	}
2421 	/* Check the length of the RSS hash key */
2422 	key_len = strlen(res->key);
2423 	if (key_len != (hash_key_size * 2)) {
2424 		printf("key length: %d invalid - key must be a string of %d"
2425 			   " hexa-decimal numbers\n",
2426 			   (int) key_len, hash_key_size * 2);
2427 		return;
2428 	}
2429 	/* Translate RSS hash key into binary representation */
2430 	for (i = 0; i < hash_key_size; i++) {
2431 		xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2432 		if (xdgt0 == 0xFF)
2433 			return;
2434 		xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2435 		if (xdgt1 == 0xFF)
2436 			return;
2437 		hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2438 	}
2439 	port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2440 			hash_key_size);
2441 }
2442 
2443 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2444 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2445 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2446 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2447 				 "config");
2448 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2449 	TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16);
2450 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2451 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2452 				 rss_hash_key, "rss-hash-key");
2453 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2454 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2455 				 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2456 				 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2457 				 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2458 				 "ipv6-tcp-ex#ipv6-udp-ex#"
2459 				 "l3-src-only#l3-dst-only#l4-src-only#l4-dst-only");
2460 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2461 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2462 
2463 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2464 	.f = cmd_config_rss_hash_key_parsed,
2465 	.data = NULL,
2466 	.help_str = "port config <port_id> rss-hash-key "
2467 		"ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2468 		"ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2469 		"l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|"
2470 		"l3-src-only|l3-dst-only|l4-src-only|l4-dst-only "
2471 		"<string of hex digits (variable length, NIC dependent)>",
2472 	.tokens = {
2473 		(void *)&cmd_config_rss_hash_key_port,
2474 		(void *)&cmd_config_rss_hash_key_config,
2475 		(void *)&cmd_config_rss_hash_key_port_id,
2476 		(void *)&cmd_config_rss_hash_key_rss_hash_key,
2477 		(void *)&cmd_config_rss_hash_key_rss_type,
2478 		(void *)&cmd_config_rss_hash_key_value,
2479 		NULL,
2480 	},
2481 };
2482 
2483 /* *** configure port rxq/txq ring size *** */
2484 struct cmd_config_rxtx_ring_size {
2485 	cmdline_fixed_string_t port;
2486 	cmdline_fixed_string_t config;
2487 	portid_t portid;
2488 	cmdline_fixed_string_t rxtxq;
2489 	uint16_t qid;
2490 	cmdline_fixed_string_t rsize;
2491 	uint16_t size;
2492 };
2493 
2494 static void
2495 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2496 				 __attribute__((unused)) struct cmdline *cl,
2497 				 __attribute__((unused)) void *data)
2498 {
2499 	struct cmd_config_rxtx_ring_size *res = parsed_result;
2500 	struct rte_port *port;
2501 	uint8_t isrx;
2502 
2503 	if (port_id_is_invalid(res->portid, ENABLED_WARN))
2504 		return;
2505 
2506 	if (res->portid == (portid_t)RTE_PORT_ALL) {
2507 		printf("Invalid port id\n");
2508 		return;
2509 	}
2510 
2511 	port = &ports[res->portid];
2512 
2513 	if (!strcmp(res->rxtxq, "rxq"))
2514 		isrx = 1;
2515 	else if (!strcmp(res->rxtxq, "txq"))
2516 		isrx = 0;
2517 	else {
2518 		printf("Unknown parameter\n");
2519 		return;
2520 	}
2521 
2522 	if (isrx && rx_queue_id_is_invalid(res->qid))
2523 		return;
2524 	else if (!isrx && tx_queue_id_is_invalid(res->qid))
2525 		return;
2526 
2527 	if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2528 		printf("Invalid rx ring_size, must > rx_free_thresh: %d\n",
2529 		       rx_free_thresh);
2530 		return;
2531 	}
2532 
2533 	if (isrx)
2534 		port->nb_rx_desc[res->qid] = res->size;
2535 	else
2536 		port->nb_tx_desc[res->qid] = res->size;
2537 
2538 	cmd_reconfig_device_queue(res->portid, 0, 1);
2539 }
2540 
2541 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2542 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2543 				 port, "port");
2544 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2545 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2546 				 config, "config");
2547 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2548 	TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2549 				 portid, UINT16);
2550 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2551 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2552 				 rxtxq, "rxq#txq");
2553 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2554 	TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2555 			      qid, UINT16);
2556 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2557 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2558 				 rsize, "ring_size");
2559 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2560 	TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2561 			      size, UINT16);
2562 
2563 cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2564 	.f = cmd_config_rxtx_ring_size_parsed,
2565 	.data = NULL,
2566 	.help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2567 	.tokens = {
2568 		(void *)&cmd_config_rxtx_ring_size_port,
2569 		(void *)&cmd_config_rxtx_ring_size_config,
2570 		(void *)&cmd_config_rxtx_ring_size_portid,
2571 		(void *)&cmd_config_rxtx_ring_size_rxtxq,
2572 		(void *)&cmd_config_rxtx_ring_size_qid,
2573 		(void *)&cmd_config_rxtx_ring_size_rsize,
2574 		(void *)&cmd_config_rxtx_ring_size_size,
2575 		NULL,
2576 	},
2577 };
2578 
2579 /* *** configure port rxq/txq start/stop *** */
2580 struct cmd_config_rxtx_queue {
2581 	cmdline_fixed_string_t port;
2582 	portid_t portid;
2583 	cmdline_fixed_string_t rxtxq;
2584 	uint16_t qid;
2585 	cmdline_fixed_string_t opname;
2586 };
2587 
2588 static void
2589 cmd_config_rxtx_queue_parsed(void *parsed_result,
2590 			__attribute__((unused)) struct cmdline *cl,
2591 			__attribute__((unused)) void *data)
2592 {
2593 	struct cmd_config_rxtx_queue *res = parsed_result;
2594 	uint8_t isrx;
2595 	uint8_t isstart;
2596 	int ret = 0;
2597 
2598 	if (test_done == 0) {
2599 		printf("Please stop forwarding first\n");
2600 		return;
2601 	}
2602 
2603 	if (port_id_is_invalid(res->portid, ENABLED_WARN))
2604 		return;
2605 
2606 	if (port_is_started(res->portid) != 1) {
2607 		printf("Please start port %u first\n", res->portid);
2608 		return;
2609 	}
2610 
2611 	if (!strcmp(res->rxtxq, "rxq"))
2612 		isrx = 1;
2613 	else if (!strcmp(res->rxtxq, "txq"))
2614 		isrx = 0;
2615 	else {
2616 		printf("Unknown parameter\n");
2617 		return;
2618 	}
2619 
2620 	if (isrx && rx_queue_id_is_invalid(res->qid))
2621 		return;
2622 	else if (!isrx && tx_queue_id_is_invalid(res->qid))
2623 		return;
2624 
2625 	if (!strcmp(res->opname, "start"))
2626 		isstart = 1;
2627 	else if (!strcmp(res->opname, "stop"))
2628 		isstart = 0;
2629 	else {
2630 		printf("Unknown parameter\n");
2631 		return;
2632 	}
2633 
2634 	if (isstart && isrx)
2635 		ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2636 	else if (!isstart && isrx)
2637 		ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2638 	else if (isstart && !isrx)
2639 		ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2640 	else
2641 		ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2642 
2643 	if (ret == -ENOTSUP)
2644 		printf("Function not supported in PMD driver\n");
2645 }
2646 
2647 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2648 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2649 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2650 	TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16);
2651 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2652 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2653 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2654 	TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
2655 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2656 	TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2657 						"start#stop");
2658 
2659 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2660 	.f = cmd_config_rxtx_queue_parsed,
2661 	.data = NULL,
2662 	.help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2663 	.tokens = {
2664 		(void *)&cmd_config_rxtx_queue_port,
2665 		(void *)&cmd_config_rxtx_queue_portid,
2666 		(void *)&cmd_config_rxtx_queue_rxtxq,
2667 		(void *)&cmd_config_rxtx_queue_qid,
2668 		(void *)&cmd_config_rxtx_queue_opname,
2669 		NULL,
2670 	},
2671 };
2672 
2673 /* *** configure port rxq/txq deferred start on/off *** */
2674 struct cmd_config_deferred_start_rxtx_queue {
2675 	cmdline_fixed_string_t port;
2676 	portid_t port_id;
2677 	cmdline_fixed_string_t rxtxq;
2678 	uint16_t qid;
2679 	cmdline_fixed_string_t opname;
2680 	cmdline_fixed_string_t state;
2681 };
2682 
2683 static void
2684 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2685 			__attribute__((unused)) struct cmdline *cl,
2686 			__attribute__((unused)) void *data)
2687 {
2688 	struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2689 	struct rte_port *port;
2690 	uint8_t isrx;
2691 	uint8_t ison;
2692 	uint8_t needreconfig = 0;
2693 
2694 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2695 		return;
2696 
2697 	if (port_is_started(res->port_id) != 0) {
2698 		printf("Please stop port %u first\n", res->port_id);
2699 		return;
2700 	}
2701 
2702 	port = &ports[res->port_id];
2703 
2704 	isrx = !strcmp(res->rxtxq, "rxq");
2705 
2706 	if (isrx && rx_queue_id_is_invalid(res->qid))
2707 		return;
2708 	else if (!isrx && tx_queue_id_is_invalid(res->qid))
2709 		return;
2710 
2711 	ison = !strcmp(res->state, "on");
2712 
2713 	if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) {
2714 		port->rx_conf[res->qid].rx_deferred_start = ison;
2715 		needreconfig = 1;
2716 	} else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) {
2717 		port->tx_conf[res->qid].tx_deferred_start = ison;
2718 		needreconfig = 1;
2719 	}
2720 
2721 	if (needreconfig)
2722 		cmd_reconfig_device_queue(res->port_id, 0, 1);
2723 }
2724 
2725 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2726 	TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2727 						port, "port");
2728 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2729 	TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2730 						port_id, UINT16);
2731 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2732 	TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2733 						rxtxq, "rxq#txq");
2734 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2735 	TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2736 						qid, UINT16);
2737 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2738 	TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2739 						opname, "deferred_start");
2740 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2741 	TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2742 						state, "on#off");
2743 
2744 cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
2745 	.f = cmd_config_deferred_start_rxtx_queue_parsed,
2746 	.data = NULL,
2747 	.help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
2748 	.tokens = {
2749 		(void *)&cmd_config_deferred_start_rxtx_queue_port,
2750 		(void *)&cmd_config_deferred_start_rxtx_queue_port_id,
2751 		(void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
2752 		(void *)&cmd_config_deferred_start_rxtx_queue_qid,
2753 		(void *)&cmd_config_deferred_start_rxtx_queue_opname,
2754 		(void *)&cmd_config_deferred_start_rxtx_queue_state,
2755 		NULL,
2756 	},
2757 };
2758 
2759 /* *** configure port rxq/txq setup *** */
2760 struct cmd_setup_rxtx_queue {
2761 	cmdline_fixed_string_t port;
2762 	portid_t portid;
2763 	cmdline_fixed_string_t rxtxq;
2764 	uint16_t qid;
2765 	cmdline_fixed_string_t setup;
2766 };
2767 
2768 /* Common CLI fields for queue setup */
2769 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2770 	TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2771 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2772 	TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, UINT16);
2773 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2774 	TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2775 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2776 	TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, UINT16);
2777 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2778 	TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2779 
2780 static void
2781 cmd_setup_rxtx_queue_parsed(
2782 	void *parsed_result,
2783 	__attribute__((unused)) struct cmdline *cl,
2784 	__attribute__((unused)) void *data)
2785 {
2786 	struct cmd_setup_rxtx_queue *res = parsed_result;
2787 	struct rte_port *port;
2788 	struct rte_mempool *mp;
2789 	unsigned int socket_id;
2790 	uint8_t isrx = 0;
2791 	int ret;
2792 
2793 	if (port_id_is_invalid(res->portid, ENABLED_WARN))
2794 		return;
2795 
2796 	if (res->portid == (portid_t)RTE_PORT_ALL) {
2797 		printf("Invalid port id\n");
2798 		return;
2799 	}
2800 
2801 	if (!strcmp(res->rxtxq, "rxq"))
2802 		isrx = 1;
2803 	else if (!strcmp(res->rxtxq, "txq"))
2804 		isrx = 0;
2805 	else {
2806 		printf("Unknown parameter\n");
2807 		return;
2808 	}
2809 
2810 	if (isrx && rx_queue_id_is_invalid(res->qid)) {
2811 		printf("Invalid rx queue\n");
2812 		return;
2813 	} else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2814 		printf("Invalid tx queue\n");
2815 		return;
2816 	}
2817 
2818 	port = &ports[res->portid];
2819 	if (isrx) {
2820 		socket_id = rxring_numa[res->portid];
2821 		if (!numa_support || socket_id == NUMA_NO_CONFIG)
2822 			socket_id = port->socket_id;
2823 
2824 		mp = mbuf_pool_find(socket_id);
2825 		if (mp == NULL) {
2826 			printf("Failed to setup RX queue: "
2827 				"No mempool allocation"
2828 				" on the socket %d\n",
2829 				rxring_numa[res->portid]);
2830 			return;
2831 		}
2832 		ret = rte_eth_rx_queue_setup(res->portid,
2833 					     res->qid,
2834 					     port->nb_rx_desc[res->qid],
2835 					     socket_id,
2836 					     &port->rx_conf[res->qid],
2837 					     mp);
2838 		if (ret)
2839 			printf("Failed to setup RX queue\n");
2840 	} else {
2841 		socket_id = txring_numa[res->portid];
2842 		if (!numa_support || socket_id == NUMA_NO_CONFIG)
2843 			socket_id = port->socket_id;
2844 
2845 		ret = rte_eth_tx_queue_setup(res->portid,
2846 					     res->qid,
2847 					     port->nb_tx_desc[res->qid],
2848 					     socket_id,
2849 					     &port->tx_conf[res->qid]);
2850 		if (ret)
2851 			printf("Failed to setup TX queue\n");
2852 	}
2853 }
2854 
2855 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2856 	.f = cmd_setup_rxtx_queue_parsed,
2857 	.data = NULL,
2858 	.help_str = "port <port_id> rxq|txq <queue_idx> setup",
2859 	.tokens = {
2860 		(void *)&cmd_setup_rxtx_queue_port,
2861 		(void *)&cmd_setup_rxtx_queue_portid,
2862 		(void *)&cmd_setup_rxtx_queue_rxtxq,
2863 		(void *)&cmd_setup_rxtx_queue_qid,
2864 		(void *)&cmd_setup_rxtx_queue_setup,
2865 		NULL,
2866 	},
2867 };
2868 
2869 
2870 /* *** Configure RSS RETA *** */
2871 struct cmd_config_rss_reta {
2872 	cmdline_fixed_string_t port;
2873 	cmdline_fixed_string_t keyword;
2874 	portid_t port_id;
2875 	cmdline_fixed_string_t name;
2876 	cmdline_fixed_string_t list_name;
2877 	cmdline_fixed_string_t list_of_items;
2878 };
2879 
2880 static int
2881 parse_reta_config(const char *str,
2882 		  struct rte_eth_rss_reta_entry64 *reta_conf,
2883 		  uint16_t nb_entries)
2884 {
2885 	int i;
2886 	unsigned size;
2887 	uint16_t hash_index, idx, shift;
2888 	uint16_t nb_queue;
2889 	char s[256];
2890 	const char *p, *p0 = str;
2891 	char *end;
2892 	enum fieldnames {
2893 		FLD_HASH_INDEX = 0,
2894 		FLD_QUEUE,
2895 		_NUM_FLD
2896 	};
2897 	unsigned long int_fld[_NUM_FLD];
2898 	char *str_fld[_NUM_FLD];
2899 
2900 	while ((p = strchr(p0,'(')) != NULL) {
2901 		++p;
2902 		if((p0 = strchr(p,')')) == NULL)
2903 			return -1;
2904 
2905 		size = p0 - p;
2906 		if(size >= sizeof(s))
2907 			return -1;
2908 
2909 		snprintf(s, sizeof(s), "%.*s", size, p);
2910 		if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2911 			return -1;
2912 		for (i = 0; i < _NUM_FLD; i++) {
2913 			errno = 0;
2914 			int_fld[i] = strtoul(str_fld[i], &end, 0);
2915 			if (errno != 0 || end == str_fld[i] ||
2916 					int_fld[i] > 65535)
2917 				return -1;
2918 		}
2919 
2920 		hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2921 		nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2922 
2923 		if (hash_index >= nb_entries) {
2924 			printf("Invalid RETA hash index=%d\n", hash_index);
2925 			return -1;
2926 		}
2927 
2928 		idx = hash_index / RTE_RETA_GROUP_SIZE;
2929 		shift = hash_index % RTE_RETA_GROUP_SIZE;
2930 		reta_conf[idx].mask |= (1ULL << shift);
2931 		reta_conf[idx].reta[shift] = nb_queue;
2932 	}
2933 
2934 	return 0;
2935 }
2936 
2937 static void
2938 cmd_set_rss_reta_parsed(void *parsed_result,
2939 			__attribute__((unused)) struct cmdline *cl,
2940 			__attribute__((unused)) void *data)
2941 {
2942 	int ret;
2943 	struct rte_eth_dev_info dev_info;
2944 	struct rte_eth_rss_reta_entry64 reta_conf[8];
2945 	struct cmd_config_rss_reta *res = parsed_result;
2946 
2947 	ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2948 	if (ret != 0)
2949 		return;
2950 
2951 	if (dev_info.reta_size == 0) {
2952 		printf("Redirection table size is 0 which is "
2953 					"invalid for RSS\n");
2954 		return;
2955 	} else
2956 		printf("The reta size of port %d is %u\n",
2957 			res->port_id, dev_info.reta_size);
2958 	if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2959 		printf("Currently do not support more than %u entries of "
2960 			"redirection table\n", ETH_RSS_RETA_SIZE_512);
2961 		return;
2962 	}
2963 
2964 	memset(reta_conf, 0, sizeof(reta_conf));
2965 	if (!strcmp(res->list_name, "reta")) {
2966 		if (parse_reta_config(res->list_of_items, reta_conf,
2967 						dev_info.reta_size)) {
2968 			printf("Invalid RSS Redirection Table "
2969 					"config entered\n");
2970 			return;
2971 		}
2972 		ret = rte_eth_dev_rss_reta_update(res->port_id,
2973 				reta_conf, dev_info.reta_size);
2974 		if (ret != 0)
2975 			printf("Bad redirection table parameter, "
2976 					"return code = %d \n", ret);
2977 	}
2978 }
2979 
2980 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2981 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2982 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2983 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2984 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2985 	TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16);
2986 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2987 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2988 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2989 	TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2990 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2991         TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2992                                  NULL);
2993 cmdline_parse_inst_t cmd_config_rss_reta = {
2994 	.f = cmd_set_rss_reta_parsed,
2995 	.data = NULL,
2996 	.help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2997 	.tokens = {
2998 		(void *)&cmd_config_rss_reta_port,
2999 		(void *)&cmd_config_rss_reta_keyword,
3000 		(void *)&cmd_config_rss_reta_port_id,
3001 		(void *)&cmd_config_rss_reta_name,
3002 		(void *)&cmd_config_rss_reta_list_name,
3003 		(void *)&cmd_config_rss_reta_list_of_items,
3004 		NULL,
3005 	},
3006 };
3007 
3008 /* *** SHOW PORT RETA INFO *** */
3009 struct cmd_showport_reta {
3010 	cmdline_fixed_string_t show;
3011 	cmdline_fixed_string_t port;
3012 	portid_t port_id;
3013 	cmdline_fixed_string_t rss;
3014 	cmdline_fixed_string_t reta;
3015 	uint16_t size;
3016 	cmdline_fixed_string_t list_of_items;
3017 };
3018 
3019 static int
3020 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
3021 			   uint16_t nb_entries,
3022 			   char *str)
3023 {
3024 	uint32_t size;
3025 	const char *p, *p0 = str;
3026 	char s[256];
3027 	char *end;
3028 	char *str_fld[8];
3029 	uint16_t i;
3030 	uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
3031 			RTE_RETA_GROUP_SIZE;
3032 	int ret;
3033 
3034 	p = strchr(p0, '(');
3035 	if (p == NULL)
3036 		return -1;
3037 	p++;
3038 	p0 = strchr(p, ')');
3039 	if (p0 == NULL)
3040 		return -1;
3041 	size = p0 - p;
3042 	if (size >= sizeof(s)) {
3043 		printf("The string size exceeds the internal buffer size\n");
3044 		return -1;
3045 	}
3046 	snprintf(s, sizeof(s), "%.*s", size, p);
3047 	ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
3048 	if (ret <= 0 || ret != num) {
3049 		printf("The bits of masks do not match the number of "
3050 					"reta entries: %u\n", num);
3051 		return -1;
3052 	}
3053 	for (i = 0; i < ret; i++)
3054 		conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
3055 
3056 	return 0;
3057 }
3058 
3059 static void
3060 cmd_showport_reta_parsed(void *parsed_result,
3061 			 __attribute__((unused)) struct cmdline *cl,
3062 			 __attribute__((unused)) void *data)
3063 {
3064 	struct cmd_showport_reta *res = parsed_result;
3065 	struct rte_eth_rss_reta_entry64 reta_conf[8];
3066 	struct rte_eth_dev_info dev_info;
3067 	uint16_t max_reta_size;
3068 	int ret;
3069 
3070 	ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3071 	if (ret != 0)
3072 		return;
3073 
3074 	max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
3075 	if (res->size == 0 || res->size > max_reta_size) {
3076 		printf("Invalid redirection table size: %u (1-%u)\n",
3077 			res->size, max_reta_size);
3078 		return;
3079 	}
3080 
3081 	memset(reta_conf, 0, sizeof(reta_conf));
3082 	if (showport_parse_reta_config(reta_conf, res->size,
3083 				res->list_of_items) < 0) {
3084 		printf("Invalid string: %s for reta masks\n",
3085 					res->list_of_items);
3086 		return;
3087 	}
3088 	port_rss_reta_info(res->port_id, reta_conf, res->size);
3089 }
3090 
3091 cmdline_parse_token_string_t cmd_showport_reta_show =
3092 	TOKEN_STRING_INITIALIZER(struct  cmd_showport_reta, show, "show");
3093 cmdline_parse_token_string_t cmd_showport_reta_port =
3094 	TOKEN_STRING_INITIALIZER(struct  cmd_showport_reta, port, "port");
3095 cmdline_parse_token_num_t cmd_showport_reta_port_id =
3096 	TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16);
3097 cmdline_parse_token_string_t cmd_showport_reta_rss =
3098 	TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
3099 cmdline_parse_token_string_t cmd_showport_reta_reta =
3100 	TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
3101 cmdline_parse_token_num_t cmd_showport_reta_size =
3102 	TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
3103 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
3104 	TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
3105 					list_of_items, NULL);
3106 
3107 cmdline_parse_inst_t cmd_showport_reta = {
3108 	.f = cmd_showport_reta_parsed,
3109 	.data = NULL,
3110 	.help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
3111 	.tokens = {
3112 		(void *)&cmd_showport_reta_show,
3113 		(void *)&cmd_showport_reta_port,
3114 		(void *)&cmd_showport_reta_port_id,
3115 		(void *)&cmd_showport_reta_rss,
3116 		(void *)&cmd_showport_reta_reta,
3117 		(void *)&cmd_showport_reta_size,
3118 		(void *)&cmd_showport_reta_list_of_items,
3119 		NULL,
3120 	},
3121 };
3122 
3123 /* *** Show RSS hash configuration *** */
3124 struct cmd_showport_rss_hash {
3125 	cmdline_fixed_string_t show;
3126 	cmdline_fixed_string_t port;
3127 	portid_t port_id;
3128 	cmdline_fixed_string_t rss_hash;
3129 	cmdline_fixed_string_t rss_type;
3130 	cmdline_fixed_string_t key; /* optional argument */
3131 };
3132 
3133 static void cmd_showport_rss_hash_parsed(void *parsed_result,
3134 				__attribute__((unused)) struct cmdline *cl,
3135 				void *show_rss_key)
3136 {
3137 	struct cmd_showport_rss_hash *res = parsed_result;
3138 
3139 	port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
3140 }
3141 
3142 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
3143 	TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
3144 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
3145 	TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
3146 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
3147 	TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16);
3148 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
3149 	TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
3150 				 "rss-hash");
3151 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
3152 	TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
3153 
3154 cmdline_parse_inst_t cmd_showport_rss_hash = {
3155 	.f = cmd_showport_rss_hash_parsed,
3156 	.data = NULL,
3157 	.help_str = "show port <port_id> rss-hash",
3158 	.tokens = {
3159 		(void *)&cmd_showport_rss_hash_show,
3160 		(void *)&cmd_showport_rss_hash_port,
3161 		(void *)&cmd_showport_rss_hash_port_id,
3162 		(void *)&cmd_showport_rss_hash_rss_hash,
3163 		NULL,
3164 	},
3165 };
3166 
3167 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
3168 	.f = cmd_showport_rss_hash_parsed,
3169 	.data = (void *)1,
3170 	.help_str = "show port <port_id> rss-hash key",
3171 	.tokens = {
3172 		(void *)&cmd_showport_rss_hash_show,
3173 		(void *)&cmd_showport_rss_hash_port,
3174 		(void *)&cmd_showport_rss_hash_port_id,
3175 		(void *)&cmd_showport_rss_hash_rss_hash,
3176 		(void *)&cmd_showport_rss_hash_rss_key,
3177 		NULL,
3178 	},
3179 };
3180 
3181 /* *** Configure DCB *** */
3182 struct cmd_config_dcb {
3183 	cmdline_fixed_string_t port;
3184 	cmdline_fixed_string_t config;
3185 	portid_t port_id;
3186 	cmdline_fixed_string_t dcb;
3187 	cmdline_fixed_string_t vt;
3188 	cmdline_fixed_string_t vt_en;
3189 	uint8_t num_tcs;
3190 	cmdline_fixed_string_t pfc;
3191 	cmdline_fixed_string_t pfc_en;
3192 };
3193 
3194 static void
3195 cmd_config_dcb_parsed(void *parsed_result,
3196                         __attribute__((unused)) struct cmdline *cl,
3197                         __attribute__((unused)) void *data)
3198 {
3199 	struct cmd_config_dcb *res = parsed_result;
3200 	portid_t port_id = res->port_id;
3201 	struct rte_port *port;
3202 	uint8_t pfc_en;
3203 	int ret;
3204 
3205 	port = &ports[port_id];
3206 	/** Check if the port is not started **/
3207 	if (port->port_status != RTE_PORT_STOPPED) {
3208 		printf("Please stop port %d first\n", port_id);
3209 		return;
3210 	}
3211 
3212 	if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
3213 		printf("The invalid number of traffic class,"
3214 			" only 4 or 8 allowed.\n");
3215 		return;
3216 	}
3217 
3218 	if (nb_fwd_lcores < res->num_tcs) {
3219 		printf("nb_cores shouldn't be less than number of TCs.\n");
3220 		return;
3221 	}
3222 	if (!strncmp(res->pfc_en, "on", 2))
3223 		pfc_en = 1;
3224 	else
3225 		pfc_en = 0;
3226 
3227 	/* DCB in VT mode */
3228 	if (!strncmp(res->vt_en, "on", 2))
3229 		ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3230 				(enum rte_eth_nb_tcs)res->num_tcs,
3231 				pfc_en);
3232 	else
3233 		ret = init_port_dcb_config(port_id, DCB_ENABLED,
3234 				(enum rte_eth_nb_tcs)res->num_tcs,
3235 				pfc_en);
3236 
3237 
3238 	if (ret != 0) {
3239 		printf("Cannot initialize network ports.\n");
3240 		return;
3241 	}
3242 
3243 	cmd_reconfig_device_queue(port_id, 1, 1);
3244 }
3245 
3246 cmdline_parse_token_string_t cmd_config_dcb_port =
3247         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3248 cmdline_parse_token_string_t cmd_config_dcb_config =
3249         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3250 cmdline_parse_token_num_t cmd_config_dcb_port_id =
3251 	TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16);
3252 cmdline_parse_token_string_t cmd_config_dcb_dcb =
3253         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3254 cmdline_parse_token_string_t cmd_config_dcb_vt =
3255         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3256 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3257         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3258 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3259         TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
3260 cmdline_parse_token_string_t cmd_config_dcb_pfc=
3261         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3262 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
3263         TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
3264 
3265 cmdline_parse_inst_t cmd_config_dcb = {
3266 	.f = cmd_config_dcb_parsed,
3267 	.data = NULL,
3268 	.help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
3269 	.tokens = {
3270 		(void *)&cmd_config_dcb_port,
3271 		(void *)&cmd_config_dcb_config,
3272 		(void *)&cmd_config_dcb_port_id,
3273 		(void *)&cmd_config_dcb_dcb,
3274 		(void *)&cmd_config_dcb_vt,
3275 		(void *)&cmd_config_dcb_vt_en,
3276 		(void *)&cmd_config_dcb_num_tcs,
3277 		(void *)&cmd_config_dcb_pfc,
3278 		(void *)&cmd_config_dcb_pfc_en,
3279                 NULL,
3280         },
3281 };
3282 
3283 /* *** configure number of packets per burst *** */
3284 struct cmd_config_burst {
3285 	cmdline_fixed_string_t port;
3286 	cmdline_fixed_string_t keyword;
3287 	cmdline_fixed_string_t all;
3288 	cmdline_fixed_string_t name;
3289 	uint16_t value;
3290 };
3291 
3292 static void
3293 cmd_config_burst_parsed(void *parsed_result,
3294 			__attribute__((unused)) struct cmdline *cl,
3295 			__attribute__((unused)) void *data)
3296 {
3297 	struct cmd_config_burst *res = parsed_result;
3298 	struct rte_eth_dev_info dev_info;
3299 	uint16_t rec_nb_pkts;
3300 	int ret;
3301 
3302 	if (!all_ports_stopped()) {
3303 		printf("Please stop all ports first\n");
3304 		return;
3305 	}
3306 
3307 	if (!strcmp(res->name, "burst")) {
3308 		if (res->value == 0) {
3309 			/* If user gives a value of zero, query the PMD for
3310 			 * its recommended Rx burst size. Testpmd uses a single
3311 			 * size for all ports, so assume all ports are the same
3312 			 * NIC model and use the values from Port 0.
3313 			 */
3314 			ret = eth_dev_info_get_print_err(0, &dev_info);
3315 			if (ret != 0)
3316 				return;
3317 
3318 			rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3319 
3320 			if (rec_nb_pkts == 0) {
3321 				printf("PMD does not recommend a burst size.\n"
3322 					"User provided value must be between"
3323 					" 1 and %d\n", MAX_PKT_BURST);
3324 				return;
3325 			} else if (rec_nb_pkts > MAX_PKT_BURST) {
3326 				printf("PMD recommended burst size of %d"
3327 					" exceeds maximum value of %d\n",
3328 					rec_nb_pkts, MAX_PKT_BURST);
3329 				return;
3330 			}
3331 			printf("Using PMD-provided burst value of %d\n",
3332 				rec_nb_pkts);
3333 			nb_pkt_per_burst = rec_nb_pkts;
3334 		} else if (res->value > MAX_PKT_BURST) {
3335 			printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
3336 			return;
3337 		} else
3338 			nb_pkt_per_burst = res->value;
3339 	} else {
3340 		printf("Unknown parameter\n");
3341 		return;
3342 	}
3343 
3344 	init_port_config();
3345 
3346 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3347 }
3348 
3349 cmdline_parse_token_string_t cmd_config_burst_port =
3350 	TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3351 cmdline_parse_token_string_t cmd_config_burst_keyword =
3352 	TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3353 cmdline_parse_token_string_t cmd_config_burst_all =
3354 	TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3355 cmdline_parse_token_string_t cmd_config_burst_name =
3356 	TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3357 cmdline_parse_token_num_t cmd_config_burst_value =
3358 	TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
3359 
3360 cmdline_parse_inst_t cmd_config_burst = {
3361 	.f = cmd_config_burst_parsed,
3362 	.data = NULL,
3363 	.help_str = "port config all burst <value>",
3364 	.tokens = {
3365 		(void *)&cmd_config_burst_port,
3366 		(void *)&cmd_config_burst_keyword,
3367 		(void *)&cmd_config_burst_all,
3368 		(void *)&cmd_config_burst_name,
3369 		(void *)&cmd_config_burst_value,
3370 		NULL,
3371 	},
3372 };
3373 
3374 /* *** configure rx/tx queues *** */
3375 struct cmd_config_thresh {
3376 	cmdline_fixed_string_t port;
3377 	cmdline_fixed_string_t keyword;
3378 	cmdline_fixed_string_t all;
3379 	cmdline_fixed_string_t name;
3380 	uint8_t value;
3381 };
3382 
3383 static void
3384 cmd_config_thresh_parsed(void *parsed_result,
3385 			__attribute__((unused)) struct cmdline *cl,
3386 			__attribute__((unused)) void *data)
3387 {
3388 	struct cmd_config_thresh *res = parsed_result;
3389 
3390 	if (!all_ports_stopped()) {
3391 		printf("Please stop all ports first\n");
3392 		return;
3393 	}
3394 
3395 	if (!strcmp(res->name, "txpt"))
3396 		tx_pthresh = res->value;
3397 	else if(!strcmp(res->name, "txht"))
3398 		tx_hthresh = res->value;
3399 	else if(!strcmp(res->name, "txwt"))
3400 		tx_wthresh = res->value;
3401 	else if(!strcmp(res->name, "rxpt"))
3402 		rx_pthresh = res->value;
3403 	else if(!strcmp(res->name, "rxht"))
3404 		rx_hthresh = res->value;
3405 	else if(!strcmp(res->name, "rxwt"))
3406 		rx_wthresh = res->value;
3407 	else {
3408 		printf("Unknown parameter\n");
3409 		return;
3410 	}
3411 
3412 	init_port_config();
3413 
3414 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3415 }
3416 
3417 cmdline_parse_token_string_t cmd_config_thresh_port =
3418 	TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3419 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3420 	TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3421 cmdline_parse_token_string_t cmd_config_thresh_all =
3422 	TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3423 cmdline_parse_token_string_t cmd_config_thresh_name =
3424 	TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3425 				"txpt#txht#txwt#rxpt#rxht#rxwt");
3426 cmdline_parse_token_num_t cmd_config_thresh_value =
3427 	TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
3428 
3429 cmdline_parse_inst_t cmd_config_thresh = {
3430 	.f = cmd_config_thresh_parsed,
3431 	.data = NULL,
3432 	.help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3433 	.tokens = {
3434 		(void *)&cmd_config_thresh_port,
3435 		(void *)&cmd_config_thresh_keyword,
3436 		(void *)&cmd_config_thresh_all,
3437 		(void *)&cmd_config_thresh_name,
3438 		(void *)&cmd_config_thresh_value,
3439 		NULL,
3440 	},
3441 };
3442 
3443 /* *** configure free/rs threshold *** */
3444 struct cmd_config_threshold {
3445 	cmdline_fixed_string_t port;
3446 	cmdline_fixed_string_t keyword;
3447 	cmdline_fixed_string_t all;
3448 	cmdline_fixed_string_t name;
3449 	uint16_t value;
3450 };
3451 
3452 static void
3453 cmd_config_threshold_parsed(void *parsed_result,
3454 			__attribute__((unused)) struct cmdline *cl,
3455 			__attribute__((unused)) void *data)
3456 {
3457 	struct cmd_config_threshold *res = parsed_result;
3458 
3459 	if (!all_ports_stopped()) {
3460 		printf("Please stop all ports first\n");
3461 		return;
3462 	}
3463 
3464 	if (!strcmp(res->name, "txfreet"))
3465 		tx_free_thresh = res->value;
3466 	else if (!strcmp(res->name, "txrst"))
3467 		tx_rs_thresh = res->value;
3468 	else if (!strcmp(res->name, "rxfreet"))
3469 		rx_free_thresh = res->value;
3470 	else {
3471 		printf("Unknown parameter\n");
3472 		return;
3473 	}
3474 
3475 	init_port_config();
3476 
3477 	cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3478 }
3479 
3480 cmdline_parse_token_string_t cmd_config_threshold_port =
3481 	TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3482 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3483 	TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3484 								"config");
3485 cmdline_parse_token_string_t cmd_config_threshold_all =
3486 	TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3487 cmdline_parse_token_string_t cmd_config_threshold_name =
3488 	TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3489 						"txfreet#txrst#rxfreet");
3490 cmdline_parse_token_num_t cmd_config_threshold_value =
3491 	TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
3492 
3493 cmdline_parse_inst_t cmd_config_threshold = {
3494 	.f = cmd_config_threshold_parsed,
3495 	.data = NULL,
3496 	.help_str = "port config all txfreet|txrst|rxfreet <value>",
3497 	.tokens = {
3498 		(void *)&cmd_config_threshold_port,
3499 		(void *)&cmd_config_threshold_keyword,
3500 		(void *)&cmd_config_threshold_all,
3501 		(void *)&cmd_config_threshold_name,
3502 		(void *)&cmd_config_threshold_value,
3503 		NULL,
3504 	},
3505 };
3506 
3507 /* *** stop *** */
3508 struct cmd_stop_result {
3509 	cmdline_fixed_string_t stop;
3510 };
3511 
3512 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
3513 			    __attribute__((unused)) struct cmdline *cl,
3514 			    __attribute__((unused)) void *data)
3515 {
3516 	stop_packet_forwarding();
3517 }
3518 
3519 cmdline_parse_token_string_t cmd_stop_stop =
3520 	TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3521 
3522 cmdline_parse_inst_t cmd_stop = {
3523 	.f = cmd_stop_parsed,
3524 	.data = NULL,
3525 	.help_str = "stop: Stop packet forwarding",
3526 	.tokens = {
3527 		(void *)&cmd_stop_stop,
3528 		NULL,
3529 	},
3530 };
3531 
3532 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3533 
3534 unsigned int
3535 parse_item_list(char* str, const char* item_name, unsigned int max_items,
3536 		unsigned int *parsed_items, int check_unique_values)
3537 {
3538 	unsigned int nb_item;
3539 	unsigned int value;
3540 	unsigned int i;
3541 	unsigned int j;
3542 	int value_ok;
3543 	char c;
3544 
3545 	/*
3546 	 * First parse all items in the list and store their value.
3547 	 */
3548 	value = 0;
3549 	nb_item = 0;
3550 	value_ok = 0;
3551 	for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3552 		c = str[i];
3553 		if ((c >= '0') && (c <= '9')) {
3554 			value = (unsigned int) (value * 10 + (c - '0'));
3555 			value_ok = 1;
3556 			continue;
3557 		}
3558 		if (c != ',') {
3559 			printf("character %c is not a decimal digit\n", c);
3560 			return 0;
3561 		}
3562 		if (! value_ok) {
3563 			printf("No valid value before comma\n");
3564 			return 0;
3565 		}
3566 		if (nb_item < max_items) {
3567 			parsed_items[nb_item] = value;
3568 			value_ok = 0;
3569 			value = 0;
3570 		}
3571 		nb_item++;
3572 	}
3573 	if (nb_item >= max_items) {
3574 		printf("Number of %s = %u > %u (maximum items)\n",
3575 		       item_name, nb_item + 1, max_items);
3576 		return 0;
3577 	}
3578 	parsed_items[nb_item++] = value;
3579 	if (! check_unique_values)
3580 		return nb_item;
3581 
3582 	/*
3583 	 * Then, check that all values in the list are differents.
3584 	 * No optimization here...
3585 	 */
3586 	for (i = 0; i < nb_item; i++) {
3587 		for (j = i + 1; j < nb_item; j++) {
3588 			if (parsed_items[j] == parsed_items[i]) {
3589 				printf("duplicated %s %u at index %u and %u\n",
3590 				       item_name, parsed_items[i], i, j);
3591 				return 0;
3592 			}
3593 		}
3594 	}
3595 	return nb_item;
3596 }
3597 
3598 struct cmd_set_list_result {
3599 	cmdline_fixed_string_t cmd_keyword;
3600 	cmdline_fixed_string_t list_name;
3601 	cmdline_fixed_string_t list_of_items;
3602 };
3603 
3604 static void cmd_set_list_parsed(void *parsed_result,
3605 				__attribute__((unused)) struct cmdline *cl,
3606 				__attribute__((unused)) void *data)
3607 {
3608 	struct cmd_set_list_result *res;
3609 	union {
3610 		unsigned int lcorelist[RTE_MAX_LCORE];
3611 		unsigned int portlist[RTE_MAX_ETHPORTS];
3612 	} parsed_items;
3613 	unsigned int nb_item;
3614 
3615 	if (test_done == 0) {
3616 		printf("Please stop forwarding first\n");
3617 		return;
3618 	}
3619 
3620 	res = parsed_result;
3621 	if (!strcmp(res->list_name, "corelist")) {
3622 		nb_item = parse_item_list(res->list_of_items, "core",
3623 					  RTE_MAX_LCORE,
3624 					  parsed_items.lcorelist, 1);
3625 		if (nb_item > 0) {
3626 			set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3627 			fwd_config_setup();
3628 		}
3629 		return;
3630 	}
3631 	if (!strcmp(res->list_name, "portlist")) {
3632 		nb_item = parse_item_list(res->list_of_items, "port",
3633 					  RTE_MAX_ETHPORTS,
3634 					  parsed_items.portlist, 1);
3635 		if (nb_item > 0) {
3636 			set_fwd_ports_list(parsed_items.portlist, nb_item);
3637 			fwd_config_setup();
3638 		}
3639 	}
3640 }
3641 
3642 cmdline_parse_token_string_t cmd_set_list_keyword =
3643 	TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3644 				 "set");
3645 cmdline_parse_token_string_t cmd_set_list_name =
3646 	TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3647 				 "corelist#portlist");
3648 cmdline_parse_token_string_t cmd_set_list_of_items =
3649 	TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3650 				 NULL);
3651 
3652 cmdline_parse_inst_t cmd_set_fwd_list = {
3653 	.f = cmd_set_list_parsed,
3654 	.data = NULL,
3655 	.help_str = "set corelist|portlist <list0[,list1]*>",
3656 	.tokens = {
3657 		(void *)&cmd_set_list_keyword,
3658 		(void *)&cmd_set_list_name,
3659 		(void *)&cmd_set_list_of_items,
3660 		NULL,
3661 	},
3662 };
3663 
3664 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3665 
3666 struct cmd_setmask_result {
3667 	cmdline_fixed_string_t set;
3668 	cmdline_fixed_string_t mask;
3669 	uint64_t hexavalue;
3670 };
3671 
3672 static void cmd_set_mask_parsed(void *parsed_result,
3673 				__attribute__((unused)) struct cmdline *cl,
3674 				__attribute__((unused)) void *data)
3675 {
3676 	struct cmd_setmask_result *res = parsed_result;
3677 
3678 	if (test_done == 0) {
3679 		printf("Please stop forwarding first\n");
3680 		return;
3681 	}
3682 	if (!strcmp(res->mask, "coremask")) {
3683 		set_fwd_lcores_mask(res->hexavalue);
3684 		fwd_config_setup();
3685 	} else if (!strcmp(res->mask, "portmask")) {
3686 		set_fwd_ports_mask(res->hexavalue);
3687 		fwd_config_setup();
3688 	}
3689 }
3690 
3691 cmdline_parse_token_string_t cmd_setmask_set =
3692 	TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3693 cmdline_parse_token_string_t cmd_setmask_mask =
3694 	TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3695 				 "coremask#portmask");
3696 cmdline_parse_token_num_t cmd_setmask_value =
3697 	TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
3698 
3699 cmdline_parse_inst_t cmd_set_fwd_mask = {
3700 	.f = cmd_set_mask_parsed,
3701 	.data = NULL,
3702 	.help_str = "set coremask|portmask <hexadecimal value>",
3703 	.tokens = {
3704 		(void *)&cmd_setmask_set,
3705 		(void *)&cmd_setmask_mask,
3706 		(void *)&cmd_setmask_value,
3707 		NULL,
3708 	},
3709 };
3710 
3711 /*
3712  * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3713  */
3714 struct cmd_set_result {
3715 	cmdline_fixed_string_t set;
3716 	cmdline_fixed_string_t what;
3717 	uint16_t value;
3718 };
3719 
3720 static void cmd_set_parsed(void *parsed_result,
3721 			   __attribute__((unused)) struct cmdline *cl,
3722 			   __attribute__((unused)) void *data)
3723 {
3724 	struct cmd_set_result *res = parsed_result;
3725 	if (!strcmp(res->what, "nbport")) {
3726 		set_fwd_ports_number(res->value);
3727 		fwd_config_setup();
3728 	} else if (!strcmp(res->what, "nbcore")) {
3729 		set_fwd_lcores_number(res->value);
3730 		fwd_config_setup();
3731 	} else if (!strcmp(res->what, "burst"))
3732 		set_nb_pkt_per_burst(res->value);
3733 	else if (!strcmp(res->what, "verbose"))
3734 		set_verbose_level(res->value);
3735 }
3736 
3737 cmdline_parse_token_string_t cmd_set_set =
3738 	TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3739 cmdline_parse_token_string_t cmd_set_what =
3740 	TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3741 				 "nbport#nbcore#burst#verbose");
3742 cmdline_parse_token_num_t cmd_set_value =
3743 	TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
3744 
3745 cmdline_parse_inst_t cmd_set_numbers = {
3746 	.f = cmd_set_parsed,
3747 	.data = NULL,
3748 	.help_str = "set nbport|nbcore|burst|verbose <value>",
3749 	.tokens = {
3750 		(void *)&cmd_set_set,
3751 		(void *)&cmd_set_what,
3752 		(void *)&cmd_set_value,
3753 		NULL,
3754 	},
3755 };
3756 
3757 /* *** SET LOG LEVEL CONFIGURATION *** */
3758 
3759 struct cmd_set_log_result {
3760 	cmdline_fixed_string_t set;
3761 	cmdline_fixed_string_t log;
3762 	cmdline_fixed_string_t type;
3763 	uint32_t level;
3764 };
3765 
3766 static void
3767 cmd_set_log_parsed(void *parsed_result,
3768 		   __attribute__((unused)) struct cmdline *cl,
3769 		   __attribute__((unused)) void *data)
3770 {
3771 	struct cmd_set_log_result *res;
3772 	int ret;
3773 
3774 	res = parsed_result;
3775 	if (!strcmp(res->type, "global"))
3776 		rte_log_set_global_level(res->level);
3777 	else {
3778 		ret = rte_log_set_level_regexp(res->type, res->level);
3779 		if (ret < 0)
3780 			printf("Unable to set log level\n");
3781 	}
3782 }
3783 
3784 cmdline_parse_token_string_t cmd_set_log_set =
3785 	TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3786 cmdline_parse_token_string_t cmd_set_log_log =
3787 	TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3788 cmdline_parse_token_string_t cmd_set_log_type =
3789 	TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3790 cmdline_parse_token_num_t cmd_set_log_level =
3791 	TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, UINT32);
3792 
3793 cmdline_parse_inst_t cmd_set_log = {
3794 	.f = cmd_set_log_parsed,
3795 	.data = NULL,
3796 	.help_str = "set log global|<type> <level>",
3797 	.tokens = {
3798 		(void *)&cmd_set_log_set,
3799 		(void *)&cmd_set_log_log,
3800 		(void *)&cmd_set_log_type,
3801 		(void *)&cmd_set_log_level,
3802 		NULL,
3803 	},
3804 };
3805 
3806 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3807 
3808 struct cmd_set_txpkts_result {
3809 	cmdline_fixed_string_t cmd_keyword;
3810 	cmdline_fixed_string_t txpkts;
3811 	cmdline_fixed_string_t seg_lengths;
3812 };
3813 
3814 static void
3815 cmd_set_txpkts_parsed(void *parsed_result,
3816 		      __attribute__((unused)) struct cmdline *cl,
3817 		      __attribute__((unused)) void *data)
3818 {
3819 	struct cmd_set_txpkts_result *res;
3820 	unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3821 	unsigned int nb_segs;
3822 
3823 	res = parsed_result;
3824 	nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3825 				  RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3826 	if (nb_segs > 0)
3827 		set_tx_pkt_segments(seg_lengths, nb_segs);
3828 }
3829 
3830 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3831 	TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3832 				 cmd_keyword, "set");
3833 cmdline_parse_token_string_t cmd_set_txpkts_name =
3834 	TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3835 				 txpkts, "txpkts");
3836 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3837 	TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3838 				 seg_lengths, NULL);
3839 
3840 cmdline_parse_inst_t cmd_set_txpkts = {
3841 	.f = cmd_set_txpkts_parsed,
3842 	.data = NULL,
3843 	.help_str = "set txpkts <len0[,len1]*>",
3844 	.tokens = {
3845 		(void *)&cmd_set_txpkts_keyword,
3846 		(void *)&cmd_set_txpkts_name,
3847 		(void *)&cmd_set_txpkts_lengths,
3848 		NULL,
3849 	},
3850 };
3851 
3852 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
3853 
3854 struct cmd_set_txsplit_result {
3855 	cmdline_fixed_string_t cmd_keyword;
3856 	cmdline_fixed_string_t txsplit;
3857 	cmdline_fixed_string_t mode;
3858 };
3859 
3860 static void
3861 cmd_set_txsplit_parsed(void *parsed_result,
3862 		      __attribute__((unused)) struct cmdline *cl,
3863 		      __attribute__((unused)) void *data)
3864 {
3865 	struct cmd_set_txsplit_result *res;
3866 
3867 	res = parsed_result;
3868 	set_tx_pkt_split(res->mode);
3869 }
3870 
3871 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
3872 	TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3873 				 cmd_keyword, "set");
3874 cmdline_parse_token_string_t cmd_set_txsplit_name =
3875 	TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3876 				 txsplit, "txsplit");
3877 cmdline_parse_token_string_t cmd_set_txsplit_mode =
3878 	TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3879 				 mode, NULL);
3880 
3881 cmdline_parse_inst_t cmd_set_txsplit = {
3882 	.f = cmd_set_txsplit_parsed,
3883 	.data = NULL,
3884 	.help_str = "set txsplit on|off|rand",
3885 	.tokens = {
3886 		(void *)&cmd_set_txsplit_keyword,
3887 		(void *)&cmd_set_txsplit_name,
3888 		(void *)&cmd_set_txsplit_mode,
3889 		NULL,
3890 	},
3891 };
3892 
3893 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
3894 struct cmd_rx_vlan_filter_all_result {
3895 	cmdline_fixed_string_t rx_vlan;
3896 	cmdline_fixed_string_t what;
3897 	cmdline_fixed_string_t all;
3898 	portid_t port_id;
3899 };
3900 
3901 static void
3902 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
3903 			      __attribute__((unused)) struct cmdline *cl,
3904 			      __attribute__((unused)) void *data)
3905 {
3906 	struct cmd_rx_vlan_filter_all_result *res = parsed_result;
3907 
3908 	if (!strcmp(res->what, "add"))
3909 		rx_vlan_all_filter_set(res->port_id, 1);
3910 	else
3911 		rx_vlan_all_filter_set(res->port_id, 0);
3912 }
3913 
3914 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
3915 	TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3916 				 rx_vlan, "rx_vlan");
3917 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
3918 	TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3919 				 what, "add#rm");
3920 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
3921 	TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3922 				 all, "all");
3923 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
3924 	TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3925 			      port_id, UINT16);
3926 
3927 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
3928 	.f = cmd_rx_vlan_filter_all_parsed,
3929 	.data = NULL,
3930 	.help_str = "rx_vlan add|rm all <port_id>: "
3931 		"Add/Remove all identifiers to/from the set of VLAN "
3932 		"identifiers filtered by a port",
3933 	.tokens = {
3934 		(void *)&cmd_rx_vlan_filter_all_rx_vlan,
3935 		(void *)&cmd_rx_vlan_filter_all_what,
3936 		(void *)&cmd_rx_vlan_filter_all_all,
3937 		(void *)&cmd_rx_vlan_filter_all_portid,
3938 		NULL,
3939 	},
3940 };
3941 
3942 /* *** VLAN OFFLOAD SET ON A PORT *** */
3943 struct cmd_vlan_offload_result {
3944 	cmdline_fixed_string_t vlan;
3945 	cmdline_fixed_string_t set;
3946 	cmdline_fixed_string_t vlan_type;
3947 	cmdline_fixed_string_t what;
3948 	cmdline_fixed_string_t on;
3949 	cmdline_fixed_string_t port_id;
3950 };
3951 
3952 static void
3953 cmd_vlan_offload_parsed(void *parsed_result,
3954 			  __attribute__((unused)) struct cmdline *cl,
3955 			  __attribute__((unused)) void *data)
3956 {
3957 	int on;
3958 	struct cmd_vlan_offload_result *res = parsed_result;
3959 	char *str;
3960 	int i, len = 0;
3961 	portid_t port_id = 0;
3962 	unsigned int tmp;
3963 
3964 	str = res->port_id;
3965 	len = strnlen(str, STR_TOKEN_SIZE);
3966 	i = 0;
3967 	/* Get port_id first */
3968 	while(i < len){
3969 		if(str[i] == ',')
3970 			break;
3971 
3972 		i++;
3973 	}
3974 	str[i]='\0';
3975 	tmp = strtoul(str, NULL, 0);
3976 	/* If port_id greater that what portid_t can represent, return */
3977 	if(tmp >= RTE_MAX_ETHPORTS)
3978 		return;
3979 	port_id = (portid_t)tmp;
3980 
3981 	if (!strcmp(res->on, "on"))
3982 		on = 1;
3983 	else
3984 		on = 0;
3985 
3986 	if (!strcmp(res->what, "strip"))
3987 		rx_vlan_strip_set(port_id,  on);
3988 	else if(!strcmp(res->what, "stripq")){
3989 		uint16_t queue_id = 0;
3990 
3991 		/* No queue_id, return */
3992 		if(i + 1 >= len) {
3993 			printf("must specify (port,queue_id)\n");
3994 			return;
3995 		}
3996 		tmp = strtoul(str + i + 1, NULL, 0);
3997 		/* If queue_id greater that what 16-bits can represent, return */
3998 		if(tmp > 0xffff)
3999 			return;
4000 
4001 		queue_id = (uint16_t)tmp;
4002 		rx_vlan_strip_set_on_queue(port_id, queue_id, on);
4003 	}
4004 	else if (!strcmp(res->what, "filter"))
4005 		rx_vlan_filter_set(port_id, on);
4006 	else if (!strcmp(res->what, "qinq_strip"))
4007 		rx_vlan_qinq_strip_set(port_id, on);
4008 	else
4009 		vlan_extend_set(port_id, on);
4010 
4011 	return;
4012 }
4013 
4014 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
4015 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4016 				 vlan, "vlan");
4017 cmdline_parse_token_string_t cmd_vlan_offload_set =
4018 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4019 				 set, "set");
4020 cmdline_parse_token_string_t cmd_vlan_offload_what =
4021 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4022 				what, "strip#filter#qinq_strip#extend#stripq");
4023 cmdline_parse_token_string_t cmd_vlan_offload_on =
4024 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4025 			      on, "on#off");
4026 cmdline_parse_token_string_t cmd_vlan_offload_portid =
4027 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4028 			      port_id, NULL);
4029 
4030 cmdline_parse_inst_t cmd_vlan_offload = {
4031 	.f = cmd_vlan_offload_parsed,
4032 	.data = NULL,
4033 	.help_str = "vlan set strip|filter|qinq_strip|extend|stripq on|off "
4034 		"<port_id[,queue_id]>: "
4035 		"Strip/Filter/QinQ for rx side Extend for both rx/tx sides",
4036 	.tokens = {
4037 		(void *)&cmd_vlan_offload_vlan,
4038 		(void *)&cmd_vlan_offload_set,
4039 		(void *)&cmd_vlan_offload_what,
4040 		(void *)&cmd_vlan_offload_on,
4041 		(void *)&cmd_vlan_offload_portid,
4042 		NULL,
4043 	},
4044 };
4045 
4046 /* *** VLAN TPID SET ON A PORT *** */
4047 struct cmd_vlan_tpid_result {
4048 	cmdline_fixed_string_t vlan;
4049 	cmdline_fixed_string_t set;
4050 	cmdline_fixed_string_t vlan_type;
4051 	cmdline_fixed_string_t what;
4052 	uint16_t tp_id;
4053 	portid_t port_id;
4054 };
4055 
4056 static void
4057 cmd_vlan_tpid_parsed(void *parsed_result,
4058 			  __attribute__((unused)) struct cmdline *cl,
4059 			  __attribute__((unused)) void *data)
4060 {
4061 	struct cmd_vlan_tpid_result *res = parsed_result;
4062 	enum rte_vlan_type vlan_type;
4063 
4064 	if (!strcmp(res->vlan_type, "inner"))
4065 		vlan_type = ETH_VLAN_TYPE_INNER;
4066 	else if (!strcmp(res->vlan_type, "outer"))
4067 		vlan_type = ETH_VLAN_TYPE_OUTER;
4068 	else {
4069 		printf("Unknown vlan type\n");
4070 		return;
4071 	}
4072 	vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
4073 }
4074 
4075 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
4076 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4077 				 vlan, "vlan");
4078 cmdline_parse_token_string_t cmd_vlan_tpid_set =
4079 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4080 				 set, "set");
4081 cmdline_parse_token_string_t cmd_vlan_type =
4082 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4083 				 vlan_type, "inner#outer");
4084 cmdline_parse_token_string_t cmd_vlan_tpid_what =
4085 	TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4086 				 what, "tpid");
4087 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
4088 	TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4089 			      tp_id, UINT16);
4090 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
4091 	TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4092 			      port_id, UINT16);
4093 
4094 cmdline_parse_inst_t cmd_vlan_tpid = {
4095 	.f = cmd_vlan_tpid_parsed,
4096 	.data = NULL,
4097 	.help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
4098 		"Set the VLAN Ether type",
4099 	.tokens = {
4100 		(void *)&cmd_vlan_tpid_vlan,
4101 		(void *)&cmd_vlan_tpid_set,
4102 		(void *)&cmd_vlan_type,
4103 		(void *)&cmd_vlan_tpid_what,
4104 		(void *)&cmd_vlan_tpid_tpid,
4105 		(void *)&cmd_vlan_tpid_portid,
4106 		NULL,
4107 	},
4108 };
4109 
4110 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4111 struct cmd_rx_vlan_filter_result {
4112 	cmdline_fixed_string_t rx_vlan;
4113 	cmdline_fixed_string_t what;
4114 	uint16_t vlan_id;
4115 	portid_t port_id;
4116 };
4117 
4118 static void
4119 cmd_rx_vlan_filter_parsed(void *parsed_result,
4120 			  __attribute__((unused)) struct cmdline *cl,
4121 			  __attribute__((unused)) void *data)
4122 {
4123 	struct cmd_rx_vlan_filter_result *res = parsed_result;
4124 
4125 	if (!strcmp(res->what, "add"))
4126 		rx_vft_set(res->port_id, res->vlan_id, 1);
4127 	else
4128 		rx_vft_set(res->port_id, res->vlan_id, 0);
4129 }
4130 
4131 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
4132 	TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4133 				 rx_vlan, "rx_vlan");
4134 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
4135 	TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4136 				 what, "add#rm");
4137 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
4138 	TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4139 			      vlan_id, UINT16);
4140 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
4141 	TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4142 			      port_id, UINT16);
4143 
4144 cmdline_parse_inst_t cmd_rx_vlan_filter = {
4145 	.f = cmd_rx_vlan_filter_parsed,
4146 	.data = NULL,
4147 	.help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
4148 		"Add/Remove a VLAN identifier to/from the set of VLAN "
4149 		"identifiers filtered by a port",
4150 	.tokens = {
4151 		(void *)&cmd_rx_vlan_filter_rx_vlan,
4152 		(void *)&cmd_rx_vlan_filter_what,
4153 		(void *)&cmd_rx_vlan_filter_vlanid,
4154 		(void *)&cmd_rx_vlan_filter_portid,
4155 		NULL,
4156 	},
4157 };
4158 
4159 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4160 struct cmd_tx_vlan_set_result {
4161 	cmdline_fixed_string_t tx_vlan;
4162 	cmdline_fixed_string_t set;
4163 	portid_t port_id;
4164 	uint16_t vlan_id;
4165 };
4166 
4167 static void
4168 cmd_tx_vlan_set_parsed(void *parsed_result,
4169 		       __attribute__((unused)) struct cmdline *cl,
4170 		       __attribute__((unused)) void *data)
4171 {
4172 	struct cmd_tx_vlan_set_result *res = parsed_result;
4173 
4174 	if (!port_is_stopped(res->port_id)) {
4175 		printf("Please stop port %d first\n", res->port_id);
4176 		return;
4177 	}
4178 
4179 	tx_vlan_set(res->port_id, res->vlan_id);
4180 
4181 	cmd_reconfig_device_queue(res->port_id, 1, 1);
4182 }
4183 
4184 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4185 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4186 				 tx_vlan, "tx_vlan");
4187 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4188 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4189 				 set, "set");
4190 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4191 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4192 			      port_id, UINT16);
4193 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
4194 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4195 			      vlan_id, UINT16);
4196 
4197 cmdline_parse_inst_t cmd_tx_vlan_set = {
4198 	.f = cmd_tx_vlan_set_parsed,
4199 	.data = NULL,
4200 	.help_str = "tx_vlan set <port_id> <vlan_id>: "
4201 		"Enable hardware insertion of a single VLAN header "
4202 		"with a given TAG Identifier in packets sent on a port",
4203 	.tokens = {
4204 		(void *)&cmd_tx_vlan_set_tx_vlan,
4205 		(void *)&cmd_tx_vlan_set_set,
4206 		(void *)&cmd_tx_vlan_set_portid,
4207 		(void *)&cmd_tx_vlan_set_vlanid,
4208 		NULL,
4209 	},
4210 };
4211 
4212 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4213 struct cmd_tx_vlan_set_qinq_result {
4214 	cmdline_fixed_string_t tx_vlan;
4215 	cmdline_fixed_string_t set;
4216 	portid_t port_id;
4217 	uint16_t vlan_id;
4218 	uint16_t vlan_id_outer;
4219 };
4220 
4221 static void
4222 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4223 			    __attribute__((unused)) struct cmdline *cl,
4224 			    __attribute__((unused)) void *data)
4225 {
4226 	struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
4227 
4228 	if (!port_is_stopped(res->port_id)) {
4229 		printf("Please stop port %d first\n", res->port_id);
4230 		return;
4231 	}
4232 
4233 	tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
4234 
4235 	cmd_reconfig_device_queue(res->port_id, 1, 1);
4236 }
4237 
4238 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
4239 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4240 		tx_vlan, "tx_vlan");
4241 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
4242 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4243 		set, "set");
4244 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
4245 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4246 		port_id, UINT16);
4247 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
4248 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4249 		vlan_id, UINT16);
4250 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
4251 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4252 		vlan_id_outer, UINT16);
4253 
4254 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
4255 	.f = cmd_tx_vlan_set_qinq_parsed,
4256 	.data = NULL,
4257 	.help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
4258 		"Enable hardware insertion of double VLAN header "
4259 		"with given TAG Identifiers in packets sent on a port",
4260 	.tokens = {
4261 		(void *)&cmd_tx_vlan_set_qinq_tx_vlan,
4262 		(void *)&cmd_tx_vlan_set_qinq_set,
4263 		(void *)&cmd_tx_vlan_set_qinq_portid,
4264 		(void *)&cmd_tx_vlan_set_qinq_vlanid,
4265 		(void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
4266 		NULL,
4267 	},
4268 };
4269 
4270 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
4271 struct cmd_tx_vlan_set_pvid_result {
4272 	cmdline_fixed_string_t tx_vlan;
4273 	cmdline_fixed_string_t set;
4274 	cmdline_fixed_string_t pvid;
4275 	portid_t port_id;
4276 	uint16_t vlan_id;
4277 	cmdline_fixed_string_t mode;
4278 };
4279 
4280 static void
4281 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
4282 			    __attribute__((unused)) struct cmdline *cl,
4283 			    __attribute__((unused)) void *data)
4284 {
4285 	struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
4286 
4287 	if (strcmp(res->mode, "on") == 0)
4288 		tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
4289 	else
4290 		tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
4291 }
4292 
4293 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
4294 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4295 				 tx_vlan, "tx_vlan");
4296 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
4297 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4298 				 set, "set");
4299 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
4300 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4301 				 pvid, "pvid");
4302 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
4303 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4304 			     port_id, UINT16);
4305 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
4306 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4307 			      vlan_id, UINT16);
4308 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
4309 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4310 				 mode, "on#off");
4311 
4312 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
4313 	.f = cmd_tx_vlan_set_pvid_parsed,
4314 	.data = NULL,
4315 	.help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
4316 	.tokens = {
4317 		(void *)&cmd_tx_vlan_set_pvid_tx_vlan,
4318 		(void *)&cmd_tx_vlan_set_pvid_set,
4319 		(void *)&cmd_tx_vlan_set_pvid_pvid,
4320 		(void *)&cmd_tx_vlan_set_pvid_port_id,
4321 		(void *)&cmd_tx_vlan_set_pvid_vlan_id,
4322 		(void *)&cmd_tx_vlan_set_pvid_mode,
4323 		NULL,
4324 	},
4325 };
4326 
4327 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4328 struct cmd_tx_vlan_reset_result {
4329 	cmdline_fixed_string_t tx_vlan;
4330 	cmdline_fixed_string_t reset;
4331 	portid_t port_id;
4332 };
4333 
4334 static void
4335 cmd_tx_vlan_reset_parsed(void *parsed_result,
4336 			 __attribute__((unused)) struct cmdline *cl,
4337 			 __attribute__((unused)) void *data)
4338 {
4339 	struct cmd_tx_vlan_reset_result *res = parsed_result;
4340 
4341 	if (!port_is_stopped(res->port_id)) {
4342 		printf("Please stop port %d first\n", res->port_id);
4343 		return;
4344 	}
4345 
4346 	tx_vlan_reset(res->port_id);
4347 
4348 	cmd_reconfig_device_queue(res->port_id, 1, 1);
4349 }
4350 
4351 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4352 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4353 				 tx_vlan, "tx_vlan");
4354 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4355 	TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4356 				 reset, "reset");
4357 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4358 	TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4359 			      port_id, UINT16);
4360 
4361 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4362 	.f = cmd_tx_vlan_reset_parsed,
4363 	.data = NULL,
4364 	.help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4365 		"VLAN header in packets sent on a port",
4366 	.tokens = {
4367 		(void *)&cmd_tx_vlan_reset_tx_vlan,
4368 		(void *)&cmd_tx_vlan_reset_reset,
4369 		(void *)&cmd_tx_vlan_reset_portid,
4370 		NULL,
4371 	},
4372 };
4373 
4374 
4375 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4376 struct cmd_csum_result {
4377 	cmdline_fixed_string_t csum;
4378 	cmdline_fixed_string_t mode;
4379 	cmdline_fixed_string_t proto;
4380 	cmdline_fixed_string_t hwsw;
4381 	portid_t port_id;
4382 };
4383 
4384 static void
4385 csum_show(int port_id)
4386 {
4387 	struct rte_eth_dev_info dev_info;
4388 	uint64_t tx_offloads;
4389 	int ret;
4390 
4391 	tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4392 	printf("Parse tunnel is %s\n",
4393 		(ports[port_id].parse_tunnel) ? "on" : "off");
4394 	printf("IP checksum offload is %s\n",
4395 		(tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4396 	printf("UDP checksum offload is %s\n",
4397 		(tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4398 	printf("TCP checksum offload is %s\n",
4399 		(tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4400 	printf("SCTP checksum offload is %s\n",
4401 		(tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4402 	printf("Outer-Ip checksum offload is %s\n",
4403 		(tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4404 	printf("Outer-Udp checksum offload is %s\n",
4405 		(tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
4406 
4407 	/* display warnings if configuration is not supported by the NIC */
4408 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
4409 	if (ret != 0)
4410 		return;
4411 
4412 	if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
4413 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4414 		printf("Warning: hardware IP checksum enabled but not "
4415 			"supported by port %d\n", port_id);
4416 	}
4417 	if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
4418 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
4419 		printf("Warning: hardware UDP checksum enabled but not "
4420 			"supported by port %d\n", port_id);
4421 	}
4422 	if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
4423 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
4424 		printf("Warning: hardware TCP checksum enabled but not "
4425 			"supported by port %d\n", port_id);
4426 	}
4427 	if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
4428 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4429 		printf("Warning: hardware SCTP checksum enabled but not "
4430 			"supported by port %d\n", port_id);
4431 	}
4432 	if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4433 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4434 		printf("Warning: hardware outer IP checksum enabled but not "
4435 			"supported by port %d\n", port_id);
4436 	}
4437 	if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
4438 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)
4439 			== 0) {
4440 		printf("Warning: hardware outer UDP checksum enabled but not "
4441 			"supported by port %d\n", port_id);
4442 	}
4443 }
4444 
4445 static void
4446 cmd_config_queue_tx_offloads(struct rte_port *port)
4447 {
4448 	int k;
4449 
4450 	/* Apply queue tx offloads configuration */
4451 	for (k = 0; k < port->dev_info.max_rx_queues; k++)
4452 		port->tx_conf[k].offloads =
4453 			port->dev_conf.txmode.offloads;
4454 }
4455 
4456 static void
4457 cmd_csum_parsed(void *parsed_result,
4458 		       __attribute__((unused)) struct cmdline *cl,
4459 		       __attribute__((unused)) void *data)
4460 {
4461 	struct cmd_csum_result *res = parsed_result;
4462 	int hw = 0;
4463 	uint64_t csum_offloads = 0;
4464 	struct rte_eth_dev_info dev_info;
4465 	int ret;
4466 
4467 	if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4468 		printf("invalid port %d\n", res->port_id);
4469 		return;
4470 	}
4471 	if (!port_is_stopped(res->port_id)) {
4472 		printf("Please stop port %d first\n", res->port_id);
4473 		return;
4474 	}
4475 
4476 	ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4477 	if (ret != 0)
4478 		return;
4479 
4480 	if (!strcmp(res->mode, "set")) {
4481 
4482 		if (!strcmp(res->hwsw, "hw"))
4483 			hw = 1;
4484 
4485 		if (!strcmp(res->proto, "ip")) {
4486 			if (hw == 0 || (dev_info.tx_offload_capa &
4487 						DEV_TX_OFFLOAD_IPV4_CKSUM)) {
4488 				csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
4489 			} else {
4490 				printf("IP checksum offload is not supported "
4491 				       "by port %u\n", res->port_id);
4492 			}
4493 		} else if (!strcmp(res->proto, "udp")) {
4494 			if (hw == 0 || (dev_info.tx_offload_capa &
4495 						DEV_TX_OFFLOAD_UDP_CKSUM)) {
4496 				csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
4497 			} else {
4498 				printf("UDP checksum offload is not supported "
4499 				       "by port %u\n", res->port_id);
4500 			}
4501 		} else if (!strcmp(res->proto, "tcp")) {
4502 			if (hw == 0 || (dev_info.tx_offload_capa &
4503 						DEV_TX_OFFLOAD_TCP_CKSUM)) {
4504 				csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
4505 			} else {
4506 				printf("TCP checksum offload is not supported "
4507 				       "by port %u\n", res->port_id);
4508 			}
4509 		} else if (!strcmp(res->proto, "sctp")) {
4510 			if (hw == 0 || (dev_info.tx_offload_capa &
4511 						DEV_TX_OFFLOAD_SCTP_CKSUM)) {
4512 				csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
4513 			} else {
4514 				printf("SCTP checksum offload is not supported "
4515 				       "by port %u\n", res->port_id);
4516 			}
4517 		} else if (!strcmp(res->proto, "outer-ip")) {
4518 			if (hw == 0 || (dev_info.tx_offload_capa &
4519 					DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4520 				csum_offloads |=
4521 						DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4522 			} else {
4523 				printf("Outer IP checksum offload is not "
4524 				       "supported by port %u\n", res->port_id);
4525 			}
4526 		} else if (!strcmp(res->proto, "outer-udp")) {
4527 			if (hw == 0 || (dev_info.tx_offload_capa &
4528 					DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
4529 				csum_offloads |=
4530 						DEV_TX_OFFLOAD_OUTER_UDP_CKSUM;
4531 			} else {
4532 				printf("Outer UDP checksum offload is not "
4533 				       "supported by port %u\n", res->port_id);
4534 			}
4535 		}
4536 
4537 		if (hw) {
4538 			ports[res->port_id].dev_conf.txmode.offloads |=
4539 							csum_offloads;
4540 		} else {
4541 			ports[res->port_id].dev_conf.txmode.offloads &=
4542 							(~csum_offloads);
4543 		}
4544 		cmd_config_queue_tx_offloads(&ports[res->port_id]);
4545 	}
4546 	csum_show(res->port_id);
4547 
4548 	cmd_reconfig_device_queue(res->port_id, 1, 1);
4549 }
4550 
4551 cmdline_parse_token_string_t cmd_csum_csum =
4552 	TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4553 				csum, "csum");
4554 cmdline_parse_token_string_t cmd_csum_mode =
4555 	TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4556 				mode, "set");
4557 cmdline_parse_token_string_t cmd_csum_proto =
4558 	TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4559 				proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
4560 cmdline_parse_token_string_t cmd_csum_hwsw =
4561 	TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4562 				hwsw, "hw#sw");
4563 cmdline_parse_token_num_t cmd_csum_portid =
4564 	TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4565 				port_id, UINT16);
4566 
4567 cmdline_parse_inst_t cmd_csum_set = {
4568 	.f = cmd_csum_parsed,
4569 	.data = NULL,
4570 	.help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
4571 		"Enable/Disable hardware calculation of L3/L4 checksum when "
4572 		"using csum forward engine",
4573 	.tokens = {
4574 		(void *)&cmd_csum_csum,
4575 		(void *)&cmd_csum_mode,
4576 		(void *)&cmd_csum_proto,
4577 		(void *)&cmd_csum_hwsw,
4578 		(void *)&cmd_csum_portid,
4579 		NULL,
4580 	},
4581 };
4582 
4583 cmdline_parse_token_string_t cmd_csum_mode_show =
4584 	TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4585 				mode, "show");
4586 
4587 cmdline_parse_inst_t cmd_csum_show = {
4588 	.f = cmd_csum_parsed,
4589 	.data = NULL,
4590 	.help_str = "csum show <port_id>: Show checksum offload configuration",
4591 	.tokens = {
4592 		(void *)&cmd_csum_csum,
4593 		(void *)&cmd_csum_mode_show,
4594 		(void *)&cmd_csum_portid,
4595 		NULL,
4596 	},
4597 };
4598 
4599 /* Enable/disable tunnel parsing */
4600 struct cmd_csum_tunnel_result {
4601 	cmdline_fixed_string_t csum;
4602 	cmdline_fixed_string_t parse;
4603 	cmdline_fixed_string_t onoff;
4604 	portid_t port_id;
4605 };
4606 
4607 static void
4608 cmd_csum_tunnel_parsed(void *parsed_result,
4609 		       __attribute__((unused)) struct cmdline *cl,
4610 		       __attribute__((unused)) void *data)
4611 {
4612 	struct cmd_csum_tunnel_result *res = parsed_result;
4613 
4614 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4615 		return;
4616 
4617 	if (!strcmp(res->onoff, "on"))
4618 		ports[res->port_id].parse_tunnel = 1;
4619 	else
4620 		ports[res->port_id].parse_tunnel = 0;
4621 
4622 	csum_show(res->port_id);
4623 }
4624 
4625 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4626 	TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4627 				csum, "csum");
4628 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4629 	TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4630 				parse, "parse-tunnel");
4631 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4632 	TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4633 				onoff, "on#off");
4634 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4635 	TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4636 				port_id, UINT16);
4637 
4638 cmdline_parse_inst_t cmd_csum_tunnel = {
4639 	.f = cmd_csum_tunnel_parsed,
4640 	.data = NULL,
4641 	.help_str = "csum parse-tunnel on|off <port_id>: "
4642 		"Enable/Disable parsing of tunnels for csum engine",
4643 	.tokens = {
4644 		(void *)&cmd_csum_tunnel_csum,
4645 		(void *)&cmd_csum_tunnel_parse,
4646 		(void *)&cmd_csum_tunnel_onoff,
4647 		(void *)&cmd_csum_tunnel_portid,
4648 		NULL,
4649 	},
4650 };
4651 
4652 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4653 struct cmd_tso_set_result {
4654 	cmdline_fixed_string_t tso;
4655 	cmdline_fixed_string_t mode;
4656 	uint16_t tso_segsz;
4657 	portid_t port_id;
4658 };
4659 
4660 static void
4661 cmd_tso_set_parsed(void *parsed_result,
4662 		       __attribute__((unused)) struct cmdline *cl,
4663 		       __attribute__((unused)) void *data)
4664 {
4665 	struct cmd_tso_set_result *res = parsed_result;
4666 	struct rte_eth_dev_info dev_info;
4667 	int ret;
4668 
4669 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4670 		return;
4671 	if (!port_is_stopped(res->port_id)) {
4672 		printf("Please stop port %d first\n", res->port_id);
4673 		return;
4674 	}
4675 
4676 	if (!strcmp(res->mode, "set"))
4677 		ports[res->port_id].tso_segsz = res->tso_segsz;
4678 
4679 	ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4680 	if (ret != 0)
4681 		return;
4682 
4683 	if ((ports[res->port_id].tso_segsz != 0) &&
4684 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4685 		printf("Error: TSO is not supported by port %d\n",
4686 		       res->port_id);
4687 		return;
4688 	}
4689 
4690 	if (ports[res->port_id].tso_segsz == 0) {
4691 		ports[res->port_id].dev_conf.txmode.offloads &=
4692 						~DEV_TX_OFFLOAD_TCP_TSO;
4693 		printf("TSO for non-tunneled packets is disabled\n");
4694 	} else {
4695 		ports[res->port_id].dev_conf.txmode.offloads |=
4696 						DEV_TX_OFFLOAD_TCP_TSO;
4697 		printf("TSO segment size for non-tunneled packets is %d\n",
4698 			ports[res->port_id].tso_segsz);
4699 	}
4700 	cmd_config_queue_tx_offloads(&ports[res->port_id]);
4701 
4702 	/* display warnings if configuration is not supported by the NIC */
4703 	ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4704 	if (ret != 0)
4705 		return;
4706 
4707 	if ((ports[res->port_id].tso_segsz != 0) &&
4708 		(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4709 		printf("Warning: TSO enabled but not "
4710 			"supported by port %d\n", res->port_id);
4711 	}
4712 
4713 	cmd_reconfig_device_queue(res->port_id, 1, 1);
4714 }
4715 
4716 cmdline_parse_token_string_t cmd_tso_set_tso =
4717 	TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4718 				tso, "tso");
4719 cmdline_parse_token_string_t cmd_tso_set_mode =
4720 	TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4721 				mode, "set");
4722 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4723 	TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4724 				tso_segsz, UINT16);
4725 cmdline_parse_token_num_t cmd_tso_set_portid =
4726 	TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4727 				port_id, UINT16);
4728 
4729 cmdline_parse_inst_t cmd_tso_set = {
4730 	.f = cmd_tso_set_parsed,
4731 	.data = NULL,
4732 	.help_str = "tso set <tso_segsz> <port_id>: "
4733 		"Set TSO segment size of non-tunneled packets for csum engine "
4734 		"(0 to disable)",
4735 	.tokens = {
4736 		(void *)&cmd_tso_set_tso,
4737 		(void *)&cmd_tso_set_mode,
4738 		(void *)&cmd_tso_set_tso_segsz,
4739 		(void *)&cmd_tso_set_portid,
4740 		NULL,
4741 	},
4742 };
4743 
4744 cmdline_parse_token_string_t cmd_tso_show_mode =
4745 	TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4746 				mode, "show");
4747 
4748 
4749 cmdline_parse_inst_t cmd_tso_show = {
4750 	.f = cmd_tso_set_parsed,
4751 	.data = NULL,
4752 	.help_str = "tso show <port_id>: "
4753 		"Show TSO segment size of non-tunneled packets for csum engine",
4754 	.tokens = {
4755 		(void *)&cmd_tso_set_tso,
4756 		(void *)&cmd_tso_show_mode,
4757 		(void *)&cmd_tso_set_portid,
4758 		NULL,
4759 	},
4760 };
4761 
4762 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
4763 struct cmd_tunnel_tso_set_result {
4764 	cmdline_fixed_string_t tso;
4765 	cmdline_fixed_string_t mode;
4766 	uint16_t tso_segsz;
4767 	portid_t port_id;
4768 };
4769 
4770 static struct rte_eth_dev_info
4771 check_tunnel_tso_nic_support(portid_t port_id)
4772 {
4773 	struct rte_eth_dev_info dev_info;
4774 
4775 	if (eth_dev_info_get_print_err(port_id, &dev_info) != 0)
4776 		return dev_info;
4777 
4778 	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
4779 		printf("Warning: VXLAN TUNNEL TSO not supported therefore "
4780 		       "not enabled for port %d\n", port_id);
4781 	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
4782 		printf("Warning: GRE TUNNEL TSO	not supported therefore "
4783 		       "not enabled for port %d\n", port_id);
4784 	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
4785 		printf("Warning: IPIP TUNNEL TSO not supported therefore "
4786 		       "not enabled for port %d\n", port_id);
4787 	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
4788 		printf("Warning: GENEVE TUNNEL TSO not supported therefore "
4789 		       "not enabled for port %d\n", port_id);
4790 	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
4791 		printf("Warning: IP TUNNEL TSO not supported therefore "
4792 		       "not enabled for port %d\n", port_id);
4793 	if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
4794 		printf("Warning: UDP TUNNEL TSO not supported therefore "
4795 		       "not enabled for port %d\n", port_id);
4796 	return dev_info;
4797 }
4798 
4799 static void
4800 cmd_tunnel_tso_set_parsed(void *parsed_result,
4801 			  __attribute__((unused)) struct cmdline *cl,
4802 			  __attribute__((unused)) void *data)
4803 {
4804 	struct cmd_tunnel_tso_set_result *res = parsed_result;
4805 	struct rte_eth_dev_info dev_info;
4806 
4807 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4808 		return;
4809 	if (!port_is_stopped(res->port_id)) {
4810 		printf("Please stop port %d first\n", res->port_id);
4811 		return;
4812 	}
4813 
4814 	if (!strcmp(res->mode, "set"))
4815 		ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
4816 
4817 	dev_info = check_tunnel_tso_nic_support(res->port_id);
4818 	if (ports[res->port_id].tunnel_tso_segsz == 0) {
4819 		ports[res->port_id].dev_conf.txmode.offloads &=
4820 			~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4821 			  DEV_TX_OFFLOAD_GRE_TNL_TSO |
4822 			  DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4823 			  DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4824 			  DEV_TX_OFFLOAD_IP_TNL_TSO |
4825 			  DEV_TX_OFFLOAD_UDP_TNL_TSO);
4826 		printf("TSO for tunneled packets is disabled\n");
4827 	} else {
4828 		uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4829 					 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4830 					 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4831 					 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4832 					 DEV_TX_OFFLOAD_IP_TNL_TSO |
4833 					 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4834 
4835 		ports[res->port_id].dev_conf.txmode.offloads |=
4836 			(tso_offloads & dev_info.tx_offload_capa);
4837 		printf("TSO segment size for tunneled packets is %d\n",
4838 			ports[res->port_id].tunnel_tso_segsz);
4839 
4840 		/* Below conditions are needed to make it work:
4841 		 * (1) tunnel TSO is supported by the NIC;
4842 		 * (2) "csum parse_tunnel" must be set so that tunneled pkts
4843 		 * are recognized;
4844 		 * (3) for tunneled pkts with outer L3 of IPv4,
4845 		 * "csum set outer-ip" must be set to hw, because after tso,
4846 		 * total_len of outer IP header is changed, and the checksum
4847 		 * of outer IP header calculated by sw should be wrong; that
4848 		 * is not necessary for IPv6 tunneled pkts because there's no
4849 		 * checksum in IP header anymore.
4850 		 */
4851 
4852 		if (!ports[res->port_id].parse_tunnel)
4853 			printf("Warning: csum parse_tunnel must be set "
4854 				"so that tunneled packets are recognized\n");
4855 		if (!(ports[res->port_id].dev_conf.txmode.offloads &
4856 		      DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
4857 			printf("Warning: csum set outer-ip must be set to hw "
4858 				"if outer L3 is IPv4; not necessary for IPv6\n");
4859 	}
4860 
4861 	cmd_config_queue_tx_offloads(&ports[res->port_id]);
4862 	cmd_reconfig_device_queue(res->port_id, 1, 1);
4863 }
4864 
4865 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
4866 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4867 				tso, "tunnel_tso");
4868 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
4869 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4870 				mode, "set");
4871 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
4872 	TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4873 				tso_segsz, UINT16);
4874 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
4875 	TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4876 				port_id, UINT16);
4877 
4878 cmdline_parse_inst_t cmd_tunnel_tso_set = {
4879 	.f = cmd_tunnel_tso_set_parsed,
4880 	.data = NULL,
4881 	.help_str = "tunnel_tso set <tso_segsz> <port_id>: "
4882 		"Set TSO segment size of tunneled packets for csum engine "
4883 		"(0 to disable)",
4884 	.tokens = {
4885 		(void *)&cmd_tunnel_tso_set_tso,
4886 		(void *)&cmd_tunnel_tso_set_mode,
4887 		(void *)&cmd_tunnel_tso_set_tso_segsz,
4888 		(void *)&cmd_tunnel_tso_set_portid,
4889 		NULL,
4890 	},
4891 };
4892 
4893 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
4894 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4895 				mode, "show");
4896 
4897 
4898 cmdline_parse_inst_t cmd_tunnel_tso_show = {
4899 	.f = cmd_tunnel_tso_set_parsed,
4900 	.data = NULL,
4901 	.help_str = "tunnel_tso show <port_id> "
4902 		"Show TSO segment size of tunneled packets for csum engine",
4903 	.tokens = {
4904 		(void *)&cmd_tunnel_tso_set_tso,
4905 		(void *)&cmd_tunnel_tso_show_mode,
4906 		(void *)&cmd_tunnel_tso_set_portid,
4907 		NULL,
4908 	},
4909 };
4910 
4911 /* *** SET GRO FOR A PORT *** */
4912 struct cmd_gro_enable_result {
4913 	cmdline_fixed_string_t cmd_set;
4914 	cmdline_fixed_string_t cmd_port;
4915 	cmdline_fixed_string_t cmd_keyword;
4916 	cmdline_fixed_string_t cmd_onoff;
4917 	portid_t cmd_pid;
4918 };
4919 
4920 static void
4921 cmd_gro_enable_parsed(void *parsed_result,
4922 		__attribute__((unused)) struct cmdline *cl,
4923 		__attribute__((unused)) void *data)
4924 {
4925 	struct cmd_gro_enable_result *res;
4926 
4927 	res = parsed_result;
4928 	if (!strcmp(res->cmd_keyword, "gro"))
4929 		setup_gro(res->cmd_onoff, res->cmd_pid);
4930 }
4931 
4932 cmdline_parse_token_string_t cmd_gro_enable_set =
4933 	TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4934 			cmd_set, "set");
4935 cmdline_parse_token_string_t cmd_gro_enable_port =
4936 	TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4937 			cmd_keyword, "port");
4938 cmdline_parse_token_num_t cmd_gro_enable_pid =
4939 	TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
4940 			cmd_pid, UINT16);
4941 cmdline_parse_token_string_t cmd_gro_enable_keyword =
4942 	TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4943 			cmd_keyword, "gro");
4944 cmdline_parse_token_string_t cmd_gro_enable_onoff =
4945 	TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4946 			cmd_onoff, "on#off");
4947 
4948 cmdline_parse_inst_t cmd_gro_enable = {
4949 	.f = cmd_gro_enable_parsed,
4950 	.data = NULL,
4951 	.help_str = "set port <port_id> gro on|off",
4952 	.tokens = {
4953 		(void *)&cmd_gro_enable_set,
4954 		(void *)&cmd_gro_enable_port,
4955 		(void *)&cmd_gro_enable_pid,
4956 		(void *)&cmd_gro_enable_keyword,
4957 		(void *)&cmd_gro_enable_onoff,
4958 		NULL,
4959 	},
4960 };
4961 
4962 /* *** DISPLAY GRO CONFIGURATION *** */
4963 struct cmd_gro_show_result {
4964 	cmdline_fixed_string_t cmd_show;
4965 	cmdline_fixed_string_t cmd_port;
4966 	cmdline_fixed_string_t cmd_keyword;
4967 	portid_t cmd_pid;
4968 };
4969 
4970 static void
4971 cmd_gro_show_parsed(void *parsed_result,
4972 		__attribute__((unused)) struct cmdline *cl,
4973 		__attribute__((unused)) void *data)
4974 {
4975 	struct cmd_gro_show_result *res;
4976 
4977 	res = parsed_result;
4978 	if (!strcmp(res->cmd_keyword, "gro"))
4979 		show_gro(res->cmd_pid);
4980 }
4981 
4982 cmdline_parse_token_string_t cmd_gro_show_show =
4983 	TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4984 			cmd_show, "show");
4985 cmdline_parse_token_string_t cmd_gro_show_port =
4986 	TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4987 			cmd_port, "port");
4988 cmdline_parse_token_num_t cmd_gro_show_pid =
4989 	TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
4990 			cmd_pid, UINT16);
4991 cmdline_parse_token_string_t cmd_gro_show_keyword =
4992 	TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4993 			cmd_keyword, "gro");
4994 
4995 cmdline_parse_inst_t cmd_gro_show = {
4996 	.f = cmd_gro_show_parsed,
4997 	.data = NULL,
4998 	.help_str = "show port <port_id> gro",
4999 	.tokens = {
5000 		(void *)&cmd_gro_show_show,
5001 		(void *)&cmd_gro_show_port,
5002 		(void *)&cmd_gro_show_pid,
5003 		(void *)&cmd_gro_show_keyword,
5004 		NULL,
5005 	},
5006 };
5007 
5008 /* *** SET FLUSH CYCLES FOR GRO *** */
5009 struct cmd_gro_flush_result {
5010 	cmdline_fixed_string_t cmd_set;
5011 	cmdline_fixed_string_t cmd_keyword;
5012 	cmdline_fixed_string_t cmd_flush;
5013 	uint8_t cmd_cycles;
5014 };
5015 
5016 static void
5017 cmd_gro_flush_parsed(void *parsed_result,
5018 		__attribute__((unused)) struct cmdline *cl,
5019 		__attribute__((unused)) void *data)
5020 {
5021 	struct cmd_gro_flush_result *res;
5022 
5023 	res = parsed_result;
5024 	if ((!strcmp(res->cmd_keyword, "gro")) &&
5025 			(!strcmp(res->cmd_flush, "flush")))
5026 		setup_gro_flush_cycles(res->cmd_cycles);
5027 }
5028 
5029 cmdline_parse_token_string_t cmd_gro_flush_set =
5030 	TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5031 			cmd_set, "set");
5032 cmdline_parse_token_string_t cmd_gro_flush_keyword =
5033 	TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5034 			cmd_keyword, "gro");
5035 cmdline_parse_token_string_t cmd_gro_flush_flush =
5036 	TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5037 			cmd_flush, "flush");
5038 cmdline_parse_token_num_t cmd_gro_flush_cycles =
5039 	TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
5040 			cmd_cycles, UINT8);
5041 
5042 cmdline_parse_inst_t cmd_gro_flush = {
5043 	.f = cmd_gro_flush_parsed,
5044 	.data = NULL,
5045 	.help_str = "set gro flush <cycles>",
5046 	.tokens = {
5047 		(void *)&cmd_gro_flush_set,
5048 		(void *)&cmd_gro_flush_keyword,
5049 		(void *)&cmd_gro_flush_flush,
5050 		(void *)&cmd_gro_flush_cycles,
5051 		NULL,
5052 	},
5053 };
5054 
5055 /* *** ENABLE/DISABLE GSO *** */
5056 struct cmd_gso_enable_result {
5057 	cmdline_fixed_string_t cmd_set;
5058 	cmdline_fixed_string_t cmd_port;
5059 	cmdline_fixed_string_t cmd_keyword;
5060 	cmdline_fixed_string_t cmd_mode;
5061 	portid_t cmd_pid;
5062 };
5063 
5064 static void
5065 cmd_gso_enable_parsed(void *parsed_result,
5066 		__attribute__((unused)) struct cmdline *cl,
5067 		__attribute__((unused)) void *data)
5068 {
5069 	struct cmd_gso_enable_result *res;
5070 
5071 	res = parsed_result;
5072 	if (!strcmp(res->cmd_keyword, "gso"))
5073 		setup_gso(res->cmd_mode, res->cmd_pid);
5074 }
5075 
5076 cmdline_parse_token_string_t cmd_gso_enable_set =
5077 	TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5078 			cmd_set, "set");
5079 cmdline_parse_token_string_t cmd_gso_enable_port =
5080 	TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5081 			cmd_port, "port");
5082 cmdline_parse_token_string_t cmd_gso_enable_keyword =
5083 	TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5084 			cmd_keyword, "gso");
5085 cmdline_parse_token_string_t cmd_gso_enable_mode =
5086 	TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5087 			cmd_mode, "on#off");
5088 cmdline_parse_token_num_t cmd_gso_enable_pid =
5089 	TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
5090 			cmd_pid, UINT16);
5091 
5092 cmdline_parse_inst_t cmd_gso_enable = {
5093 	.f = cmd_gso_enable_parsed,
5094 	.data = NULL,
5095 	.help_str = "set port <port_id> gso on|off",
5096 	.tokens = {
5097 		(void *)&cmd_gso_enable_set,
5098 		(void *)&cmd_gso_enable_port,
5099 		(void *)&cmd_gso_enable_pid,
5100 		(void *)&cmd_gso_enable_keyword,
5101 		(void *)&cmd_gso_enable_mode,
5102 		NULL,
5103 	},
5104 };
5105 
5106 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
5107 struct cmd_gso_size_result {
5108 	cmdline_fixed_string_t cmd_set;
5109 	cmdline_fixed_string_t cmd_keyword;
5110 	cmdline_fixed_string_t cmd_segsz;
5111 	uint16_t cmd_size;
5112 };
5113 
5114 static void
5115 cmd_gso_size_parsed(void *parsed_result,
5116 		       __attribute__((unused)) struct cmdline *cl,
5117 		       __attribute__((unused)) void *data)
5118 {
5119 	struct cmd_gso_size_result *res = parsed_result;
5120 
5121 	if (test_done == 0) {
5122 		printf("Before setting GSO segsz, please first"
5123 				" stop fowarding\n");
5124 		return;
5125 	}
5126 
5127 	if (!strcmp(res->cmd_keyword, "gso") &&
5128 			!strcmp(res->cmd_segsz, "segsz")) {
5129 		if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
5130 			printf("gso_size should be larger than %zu."
5131 					" Please input a legal value\n",
5132 					RTE_GSO_SEG_SIZE_MIN);
5133 		else
5134 			gso_max_segment_size = res->cmd_size;
5135 	}
5136 }
5137 
5138 cmdline_parse_token_string_t cmd_gso_size_set =
5139 	TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5140 				cmd_set, "set");
5141 cmdline_parse_token_string_t cmd_gso_size_keyword =
5142 	TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5143 				cmd_keyword, "gso");
5144 cmdline_parse_token_string_t cmd_gso_size_segsz =
5145 	TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5146 				cmd_segsz, "segsz");
5147 cmdline_parse_token_num_t cmd_gso_size_size =
5148 	TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
5149 				cmd_size, UINT16);
5150 
5151 cmdline_parse_inst_t cmd_gso_size = {
5152 	.f = cmd_gso_size_parsed,
5153 	.data = NULL,
5154 	.help_str = "set gso segsz <length>",
5155 	.tokens = {
5156 		(void *)&cmd_gso_size_set,
5157 		(void *)&cmd_gso_size_keyword,
5158 		(void *)&cmd_gso_size_segsz,
5159 		(void *)&cmd_gso_size_size,
5160 		NULL,
5161 	},
5162 };
5163 
5164 /* *** SHOW GSO CONFIGURATION *** */
5165 struct cmd_gso_show_result {
5166 	cmdline_fixed_string_t cmd_show;
5167 	cmdline_fixed_string_t cmd_port;
5168 	cmdline_fixed_string_t cmd_keyword;
5169 	portid_t cmd_pid;
5170 };
5171 
5172 static void
5173 cmd_gso_show_parsed(void *parsed_result,
5174 		       __attribute__((unused)) struct cmdline *cl,
5175 		       __attribute__((unused)) void *data)
5176 {
5177 	struct cmd_gso_show_result *res = parsed_result;
5178 
5179 	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
5180 		printf("invalid port id %u\n", res->cmd_pid);
5181 		return;
5182 	}
5183 	if (!strcmp(res->cmd_keyword, "gso")) {
5184 		if (gso_ports[res->cmd_pid].enable) {
5185 			printf("Max GSO'd packet size: %uB\n"
5186 					"Supported GSO types: TCP/IPv4, "
5187 					"UDP/IPv4, VxLAN with inner "
5188 					"TCP/IPv4 packet, GRE with inner "
5189 					"TCP/IPv4 packet\n",
5190 					gso_max_segment_size);
5191 		} else
5192 			printf("GSO is not enabled on Port %u\n", res->cmd_pid);
5193 	}
5194 }
5195 
5196 cmdline_parse_token_string_t cmd_gso_show_show =
5197 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5198 		cmd_show, "show");
5199 cmdline_parse_token_string_t cmd_gso_show_port =
5200 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5201 		cmd_port, "port");
5202 cmdline_parse_token_string_t cmd_gso_show_keyword =
5203 	TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5204 				cmd_keyword, "gso");
5205 cmdline_parse_token_num_t cmd_gso_show_pid =
5206 	TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
5207 				cmd_pid, UINT16);
5208 
5209 cmdline_parse_inst_t cmd_gso_show = {
5210 	.f = cmd_gso_show_parsed,
5211 	.data = NULL,
5212 	.help_str = "show port <port_id> gso",
5213 	.tokens = {
5214 		(void *)&cmd_gso_show_show,
5215 		(void *)&cmd_gso_show_port,
5216 		(void *)&cmd_gso_show_pid,
5217 		(void *)&cmd_gso_show_keyword,
5218 		NULL,
5219 	},
5220 };
5221 
5222 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
5223 struct cmd_set_flush_rx {
5224 	cmdline_fixed_string_t set;
5225 	cmdline_fixed_string_t flush_rx;
5226 	cmdline_fixed_string_t mode;
5227 };
5228 
5229 static void
5230 cmd_set_flush_rx_parsed(void *parsed_result,
5231 		__attribute__((unused)) struct cmdline *cl,
5232 		__attribute__((unused)) void *data)
5233 {
5234 	struct cmd_set_flush_rx *res = parsed_result;
5235 	no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5236 }
5237 
5238 cmdline_parse_token_string_t cmd_setflushrx_set =
5239 	TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5240 			set, "set");
5241 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
5242 	TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5243 			flush_rx, "flush_rx");
5244 cmdline_parse_token_string_t cmd_setflushrx_mode =
5245 	TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5246 			mode, "on#off");
5247 
5248 
5249 cmdline_parse_inst_t cmd_set_flush_rx = {
5250 	.f = cmd_set_flush_rx_parsed,
5251 	.help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
5252 	.data = NULL,
5253 	.tokens = {
5254 		(void *)&cmd_setflushrx_set,
5255 		(void *)&cmd_setflushrx_flush_rx,
5256 		(void *)&cmd_setflushrx_mode,
5257 		NULL,
5258 	},
5259 };
5260 
5261 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
5262 struct cmd_set_link_check {
5263 	cmdline_fixed_string_t set;
5264 	cmdline_fixed_string_t link_check;
5265 	cmdline_fixed_string_t mode;
5266 };
5267 
5268 static void
5269 cmd_set_link_check_parsed(void *parsed_result,
5270 		__attribute__((unused)) struct cmdline *cl,
5271 		__attribute__((unused)) void *data)
5272 {
5273 	struct cmd_set_link_check *res = parsed_result;
5274 	no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5275 }
5276 
5277 cmdline_parse_token_string_t cmd_setlinkcheck_set =
5278 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5279 			set, "set");
5280 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
5281 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5282 			link_check, "link_check");
5283 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
5284 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5285 			mode, "on#off");
5286 
5287 
5288 cmdline_parse_inst_t cmd_set_link_check = {
5289 	.f = cmd_set_link_check_parsed,
5290 	.help_str = "set link_check on|off: Enable/Disable link status check "
5291 	            "when starting/stopping a port",
5292 	.data = NULL,
5293 	.tokens = {
5294 		(void *)&cmd_setlinkcheck_set,
5295 		(void *)&cmd_setlinkcheck_link_check,
5296 		(void *)&cmd_setlinkcheck_mode,
5297 		NULL,
5298 	},
5299 };
5300 
5301 /* *** SET NIC BYPASS MODE *** */
5302 struct cmd_set_bypass_mode_result {
5303 	cmdline_fixed_string_t set;
5304 	cmdline_fixed_string_t bypass;
5305 	cmdline_fixed_string_t mode;
5306 	cmdline_fixed_string_t value;
5307 	portid_t port_id;
5308 };
5309 
5310 static void
5311 cmd_set_bypass_mode_parsed(void *parsed_result,
5312 		__attribute__((unused)) struct cmdline *cl,
5313 		__attribute__((unused)) void *data)
5314 {
5315 	struct cmd_set_bypass_mode_result *res = parsed_result;
5316 	portid_t port_id = res->port_id;
5317 	int32_t rc = -EINVAL;
5318 
5319 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5320 	uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5321 
5322 	if (!strcmp(res->value, "bypass"))
5323 		bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5324 	else if (!strcmp(res->value, "isolate"))
5325 		bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5326 	else
5327 		bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5328 
5329 	/* Set the bypass mode for the relevant port. */
5330 	rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
5331 #endif
5332 	if (rc != 0)
5333 		printf("\t Failed to set bypass mode for port = %d.\n", port_id);
5334 }
5335 
5336 cmdline_parse_token_string_t cmd_setbypass_mode_set =
5337 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5338 			set, "set");
5339 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
5340 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5341 			bypass, "bypass");
5342 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
5343 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5344 			mode, "mode");
5345 cmdline_parse_token_string_t cmd_setbypass_mode_value =
5346 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5347 			value, "normal#bypass#isolate");
5348 cmdline_parse_token_num_t cmd_setbypass_mode_port =
5349 	TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
5350 				port_id, UINT16);
5351 
5352 cmdline_parse_inst_t cmd_set_bypass_mode = {
5353 	.f = cmd_set_bypass_mode_parsed,
5354 	.help_str = "set bypass mode normal|bypass|isolate <port_id>: "
5355 	            "Set the NIC bypass mode for port_id",
5356 	.data = NULL,
5357 	.tokens = {
5358 		(void *)&cmd_setbypass_mode_set,
5359 		(void *)&cmd_setbypass_mode_bypass,
5360 		(void *)&cmd_setbypass_mode_mode,
5361 		(void *)&cmd_setbypass_mode_value,
5362 		(void *)&cmd_setbypass_mode_port,
5363 		NULL,
5364 	},
5365 };
5366 
5367 /* *** SET NIC BYPASS EVENT *** */
5368 struct cmd_set_bypass_event_result {
5369 	cmdline_fixed_string_t set;
5370 	cmdline_fixed_string_t bypass;
5371 	cmdline_fixed_string_t event;
5372 	cmdline_fixed_string_t event_value;
5373 	cmdline_fixed_string_t mode;
5374 	cmdline_fixed_string_t mode_value;
5375 	portid_t port_id;
5376 };
5377 
5378 static void
5379 cmd_set_bypass_event_parsed(void *parsed_result,
5380 		__attribute__((unused)) struct cmdline *cl,
5381 		__attribute__((unused)) void *data)
5382 {
5383 	int32_t rc = -EINVAL;
5384 	struct cmd_set_bypass_event_result *res = parsed_result;
5385 	portid_t port_id = res->port_id;
5386 
5387 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5388 	uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5389 	uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5390 
5391 	if (!strcmp(res->event_value, "timeout"))
5392 		bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
5393 	else if (!strcmp(res->event_value, "os_on"))
5394 		bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
5395 	else if (!strcmp(res->event_value, "os_off"))
5396 		bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5397 	else if (!strcmp(res->event_value, "power_on"))
5398 		bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5399 	else if (!strcmp(res->event_value, "power_off"))
5400 		bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5401 	else
5402 		bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5403 
5404 	if (!strcmp(res->mode_value, "bypass"))
5405 		bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5406 	else if (!strcmp(res->mode_value, "isolate"))
5407 		bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5408 	else
5409 		bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5410 
5411 	/* Set the watchdog timeout. */
5412 	if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5413 
5414 		rc = -EINVAL;
5415 		if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5416 			rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5417 							   bypass_timeout);
5418 		}
5419 		if (rc != 0) {
5420 			printf("Failed to set timeout value %u "
5421 			"for port %d, errto code: %d.\n",
5422 			bypass_timeout, port_id, rc);
5423 		}
5424 	}
5425 
5426 	/* Set the bypass event to transition to bypass mode. */
5427 	rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5428 					      bypass_mode);
5429 #endif
5430 
5431 	if (rc != 0)
5432 		printf("\t Failed to set bypass event for port = %d.\n",
5433 		       port_id);
5434 }
5435 
5436 cmdline_parse_token_string_t cmd_setbypass_event_set =
5437 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5438 			set, "set");
5439 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5440 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5441 			bypass, "bypass");
5442 cmdline_parse_token_string_t cmd_setbypass_event_event =
5443 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5444 			event, "event");
5445 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5446 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5447 			event_value, "none#timeout#os_off#os_on#power_on#power_off");
5448 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5449 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5450 			mode, "mode");
5451 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5452 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5453 			mode_value, "normal#bypass#isolate");
5454 cmdline_parse_token_num_t cmd_setbypass_event_port =
5455 	TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5456 				port_id, UINT16);
5457 
5458 cmdline_parse_inst_t cmd_set_bypass_event = {
5459 	.f = cmd_set_bypass_event_parsed,
5460 	.help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5461 		"power_off mode normal|bypass|isolate <port_id>: "
5462 		"Set the NIC bypass event mode for port_id",
5463 	.data = NULL,
5464 	.tokens = {
5465 		(void *)&cmd_setbypass_event_set,
5466 		(void *)&cmd_setbypass_event_bypass,
5467 		(void *)&cmd_setbypass_event_event,
5468 		(void *)&cmd_setbypass_event_event_value,
5469 		(void *)&cmd_setbypass_event_mode,
5470 		(void *)&cmd_setbypass_event_mode_value,
5471 		(void *)&cmd_setbypass_event_port,
5472 		NULL,
5473 	},
5474 };
5475 
5476 
5477 /* *** SET NIC BYPASS TIMEOUT *** */
5478 struct cmd_set_bypass_timeout_result {
5479 	cmdline_fixed_string_t set;
5480 	cmdline_fixed_string_t bypass;
5481 	cmdline_fixed_string_t timeout;
5482 	cmdline_fixed_string_t value;
5483 };
5484 
5485 static void
5486 cmd_set_bypass_timeout_parsed(void *parsed_result,
5487 		__attribute__((unused)) struct cmdline *cl,
5488 		__attribute__((unused)) void *data)
5489 {
5490 	__rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5491 
5492 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5493 	if (!strcmp(res->value, "1.5"))
5494 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5495 	else if (!strcmp(res->value, "2"))
5496 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5497 	else if (!strcmp(res->value, "3"))
5498 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5499 	else if (!strcmp(res->value, "4"))
5500 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5501 	else if (!strcmp(res->value, "8"))
5502 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5503 	else if (!strcmp(res->value, "16"))
5504 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5505 	else if (!strcmp(res->value, "32"))
5506 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5507 	else
5508 		bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5509 #endif
5510 }
5511 
5512 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5513 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5514 			set, "set");
5515 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5516 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5517 			bypass, "bypass");
5518 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5519 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5520 			timeout, "timeout");
5521 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5522 	TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5523 			value, "0#1.5#2#3#4#8#16#32");
5524 
5525 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5526 	.f = cmd_set_bypass_timeout_parsed,
5527 	.help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5528 		"Set the NIC bypass watchdog timeout in seconds",
5529 	.data = NULL,
5530 	.tokens = {
5531 		(void *)&cmd_setbypass_timeout_set,
5532 		(void *)&cmd_setbypass_timeout_bypass,
5533 		(void *)&cmd_setbypass_timeout_timeout,
5534 		(void *)&cmd_setbypass_timeout_value,
5535 		NULL,
5536 	},
5537 };
5538 
5539 /* *** SHOW NIC BYPASS MODE *** */
5540 struct cmd_show_bypass_config_result {
5541 	cmdline_fixed_string_t show;
5542 	cmdline_fixed_string_t bypass;
5543 	cmdline_fixed_string_t config;
5544 	portid_t port_id;
5545 };
5546 
5547 static void
5548 cmd_show_bypass_config_parsed(void *parsed_result,
5549 		__attribute__((unused)) struct cmdline *cl,
5550 		__attribute__((unused)) void *data)
5551 {
5552 	struct cmd_show_bypass_config_result *res = parsed_result;
5553 	portid_t port_id = res->port_id;
5554 	int rc = -EINVAL;
5555 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5556 	uint32_t event_mode;
5557 	uint32_t bypass_mode;
5558 	uint32_t timeout = bypass_timeout;
5559 	int i;
5560 
5561 	static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5562 		{"off", "1.5", "2", "3", "4", "8", "16", "32"};
5563 	static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5564 		{"UNKNOWN", "normal", "bypass", "isolate"};
5565 	static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5566 		"NONE",
5567 		"OS/board on",
5568 		"power supply on",
5569 		"OS/board off",
5570 		"power supply off",
5571 		"timeout"};
5572 	int num_events = (sizeof events) / (sizeof events[0]);
5573 
5574 	/* Display the bypass mode.*/
5575 	if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5576 		printf("\tFailed to get bypass mode for port = %d\n", port_id);
5577 		return;
5578 	}
5579 	else {
5580 		if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5581 			bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5582 
5583 		printf("\tbypass mode    = %s\n",  modes[bypass_mode]);
5584 	}
5585 
5586 	/* Display the bypass timeout.*/
5587 	if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5588 		timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5589 
5590 	printf("\tbypass timeout = %s\n", timeouts[timeout]);
5591 
5592 	/* Display the bypass events and associated modes. */
5593 	for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < num_events; i++) {
5594 
5595 		if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5596 			printf("\tFailed to get bypass mode for event = %s\n",
5597 				events[i]);
5598 		} else {
5599 			if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5600 				event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5601 
5602 			printf("\tbypass event: %-16s = %s\n", events[i],
5603 				modes[event_mode]);
5604 		}
5605 	}
5606 #endif
5607 	if (rc != 0)
5608 		printf("\tFailed to get bypass configuration for port = %d\n",
5609 		       port_id);
5610 }
5611 
5612 cmdline_parse_token_string_t cmd_showbypass_config_show =
5613 	TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5614 			show, "show");
5615 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5616 	TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5617 			bypass, "bypass");
5618 cmdline_parse_token_string_t cmd_showbypass_config_config =
5619 	TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5620 			config, "config");
5621 cmdline_parse_token_num_t cmd_showbypass_config_port =
5622 	TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5623 				port_id, UINT16);
5624 
5625 cmdline_parse_inst_t cmd_show_bypass_config = {
5626 	.f = cmd_show_bypass_config_parsed,
5627 	.help_str = "show bypass config <port_id>: "
5628 	            "Show the NIC bypass config for port_id",
5629 	.data = NULL,
5630 	.tokens = {
5631 		(void *)&cmd_showbypass_config_show,
5632 		(void *)&cmd_showbypass_config_bypass,
5633 		(void *)&cmd_showbypass_config_config,
5634 		(void *)&cmd_showbypass_config_port,
5635 		NULL,
5636 	},
5637 };
5638 
5639 #ifdef RTE_LIBRTE_PMD_BOND
5640 /* *** SET BONDING MODE *** */
5641 struct cmd_set_bonding_mode_result {
5642 	cmdline_fixed_string_t set;
5643 	cmdline_fixed_string_t bonding;
5644 	cmdline_fixed_string_t mode;
5645 	uint8_t value;
5646 	portid_t port_id;
5647 };
5648 
5649 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5650 		__attribute__((unused))  struct cmdline *cl,
5651 		__attribute__((unused)) void *data)
5652 {
5653 	struct cmd_set_bonding_mode_result *res = parsed_result;
5654 	portid_t port_id = res->port_id;
5655 
5656 	/* Set the bonding mode for the relevant port. */
5657 	if (0 != rte_eth_bond_mode_set(port_id, res->value))
5658 		printf("\t Failed to set bonding mode for port = %d.\n", port_id);
5659 }
5660 
5661 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5662 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5663 		set, "set");
5664 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5665 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5666 		bonding, "bonding");
5667 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5668 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5669 		mode, "mode");
5670 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5671 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5672 		value, UINT8);
5673 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5674 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5675 		port_id, UINT16);
5676 
5677 cmdline_parse_inst_t cmd_set_bonding_mode = {
5678 		.f = cmd_set_bonding_mode_parsed,
5679 		.help_str = "set bonding mode <mode_value> <port_id>: "
5680 			"Set the bonding mode for port_id",
5681 		.data = NULL,
5682 		.tokens = {
5683 				(void *) &cmd_setbonding_mode_set,
5684 				(void *) &cmd_setbonding_mode_bonding,
5685 				(void *) &cmd_setbonding_mode_mode,
5686 				(void *) &cmd_setbonding_mode_value,
5687 				(void *) &cmd_setbonding_mode_port,
5688 				NULL
5689 		}
5690 };
5691 
5692 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5693 struct cmd_set_bonding_lacp_dedicated_queues_result {
5694 	cmdline_fixed_string_t set;
5695 	cmdline_fixed_string_t bonding;
5696 	cmdline_fixed_string_t lacp;
5697 	cmdline_fixed_string_t dedicated_queues;
5698 	portid_t port_id;
5699 	cmdline_fixed_string_t mode;
5700 };
5701 
5702 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5703 		__attribute__((unused))  struct cmdline *cl,
5704 		__attribute__((unused)) void *data)
5705 {
5706 	struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5707 	portid_t port_id = res->port_id;
5708 	struct rte_port *port;
5709 
5710 	port = &ports[port_id];
5711 
5712 	/** Check if the port is not started **/
5713 	if (port->port_status != RTE_PORT_STOPPED) {
5714 		printf("Please stop port %d first\n", port_id);
5715 		return;
5716 	}
5717 
5718 	if (!strcmp(res->mode, "enable")) {
5719 		if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5720 			printf("Dedicate queues for LACP control packets"
5721 					" enabled\n");
5722 		else
5723 			printf("Enabling dedicate queues for LACP control "
5724 					"packets on port %d failed\n", port_id);
5725 	} else if (!strcmp(res->mode, "disable")) {
5726 		if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5727 			printf("Dedicated queues for LACP control packets "
5728 					"disabled\n");
5729 		else
5730 			printf("Disabling dedicated queues for LACP control "
5731 					"traffic on port %d failed\n", port_id);
5732 	}
5733 }
5734 
5735 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5736 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5737 		set, "set");
5738 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
5739 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5740 		bonding, "bonding");
5741 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
5742 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5743 		lacp, "lacp");
5744 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
5745 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5746 		dedicated_queues, "dedicated_queues");
5747 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
5748 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5749 		port_id, UINT16);
5750 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
5751 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5752 		mode, "enable#disable");
5753 
5754 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
5755 		.f = cmd_set_bonding_lacp_dedicated_queues_parsed,
5756 		.help_str = "set bonding lacp dedicated_queues <port_id> "
5757 			"enable|disable: "
5758 			"Enable/disable dedicated queues for LACP control traffic for port_id",
5759 		.data = NULL,
5760 		.tokens = {
5761 			(void *)&cmd_setbonding_lacp_dedicated_queues_set,
5762 			(void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
5763 			(void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
5764 			(void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
5765 			(void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
5766 			(void *)&cmd_setbonding_lacp_dedicated_queues_mode,
5767 			NULL
5768 		}
5769 };
5770 
5771 /* *** SET BALANCE XMIT POLICY *** */
5772 struct cmd_set_bonding_balance_xmit_policy_result {
5773 	cmdline_fixed_string_t set;
5774 	cmdline_fixed_string_t bonding;
5775 	cmdline_fixed_string_t balance_xmit_policy;
5776 	portid_t port_id;
5777 	cmdline_fixed_string_t policy;
5778 };
5779 
5780 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
5781 		__attribute__((unused))  struct cmdline *cl,
5782 		__attribute__((unused)) void *data)
5783 {
5784 	struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
5785 	portid_t port_id = res->port_id;
5786 	uint8_t policy;
5787 
5788 	if (!strcmp(res->policy, "l2")) {
5789 		policy = BALANCE_XMIT_POLICY_LAYER2;
5790 	} else if (!strcmp(res->policy, "l23")) {
5791 		policy = BALANCE_XMIT_POLICY_LAYER23;
5792 	} else if (!strcmp(res->policy, "l34")) {
5793 		policy = BALANCE_XMIT_POLICY_LAYER34;
5794 	} else {
5795 		printf("\t Invalid xmit policy selection");
5796 		return;
5797 	}
5798 
5799 	/* Set the bonding mode for the relevant port. */
5800 	if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
5801 		printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
5802 				port_id);
5803 	}
5804 }
5805 
5806 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
5807 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5808 		set, "set");
5809 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
5810 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5811 		bonding, "bonding");
5812 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
5813 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5814 		balance_xmit_policy, "balance_xmit_policy");
5815 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
5816 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5817 		port_id, UINT16);
5818 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
5819 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5820 		policy, "l2#l23#l34");
5821 
5822 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
5823 		.f = cmd_set_bonding_balance_xmit_policy_parsed,
5824 		.help_str = "set bonding balance_xmit_policy <port_id> "
5825 			"l2|l23|l34: "
5826 			"Set the bonding balance_xmit_policy for port_id",
5827 		.data = NULL,
5828 		.tokens = {
5829 				(void *)&cmd_setbonding_balance_xmit_policy_set,
5830 				(void *)&cmd_setbonding_balance_xmit_policy_bonding,
5831 				(void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
5832 				(void *)&cmd_setbonding_balance_xmit_policy_port,
5833 				(void *)&cmd_setbonding_balance_xmit_policy_policy,
5834 				NULL
5835 		}
5836 };
5837 
5838 /* *** SHOW NIC BONDING CONFIGURATION *** */
5839 struct cmd_show_bonding_config_result {
5840 	cmdline_fixed_string_t show;
5841 	cmdline_fixed_string_t bonding;
5842 	cmdline_fixed_string_t config;
5843 	portid_t port_id;
5844 };
5845 
5846 static void cmd_show_bonding_config_parsed(void *parsed_result,
5847 		__attribute__((unused))  struct cmdline *cl,
5848 		__attribute__((unused)) void *data)
5849 {
5850 	struct cmd_show_bonding_config_result *res = parsed_result;
5851 	int bonding_mode, agg_mode;
5852 	portid_t slaves[RTE_MAX_ETHPORTS];
5853 	int num_slaves, num_active_slaves;
5854 	int primary_id;
5855 	int i;
5856 	portid_t port_id = res->port_id;
5857 
5858 	/* Display the bonding mode.*/
5859 	bonding_mode = rte_eth_bond_mode_get(port_id);
5860 	if (bonding_mode < 0) {
5861 		printf("\tFailed to get bonding mode for port = %d\n", port_id);
5862 		return;
5863 	} else
5864 		printf("\tBonding mode: %d\n", bonding_mode);
5865 
5866 	if (bonding_mode == BONDING_MODE_BALANCE) {
5867 		int balance_xmit_policy;
5868 
5869 		balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
5870 		if (balance_xmit_policy < 0) {
5871 			printf("\tFailed to get balance xmit policy for port = %d\n",
5872 					port_id);
5873 			return;
5874 		} else {
5875 			printf("\tBalance Xmit Policy: ");
5876 
5877 			switch (balance_xmit_policy) {
5878 			case BALANCE_XMIT_POLICY_LAYER2:
5879 				printf("BALANCE_XMIT_POLICY_LAYER2");
5880 				break;
5881 			case BALANCE_XMIT_POLICY_LAYER23:
5882 				printf("BALANCE_XMIT_POLICY_LAYER23");
5883 				break;
5884 			case BALANCE_XMIT_POLICY_LAYER34:
5885 				printf("BALANCE_XMIT_POLICY_LAYER34");
5886 				break;
5887 			}
5888 			printf("\n");
5889 		}
5890 	}
5891 
5892 	if (bonding_mode == BONDING_MODE_8023AD) {
5893 		agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
5894 		printf("\tIEEE802.3AD Aggregator Mode: ");
5895 		switch (agg_mode) {
5896 		case AGG_BANDWIDTH:
5897 			printf("bandwidth");
5898 			break;
5899 		case AGG_STABLE:
5900 			printf("stable");
5901 			break;
5902 		case AGG_COUNT:
5903 			printf("count");
5904 			break;
5905 		}
5906 		printf("\n");
5907 	}
5908 
5909 	num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
5910 
5911 	if (num_slaves < 0) {
5912 		printf("\tFailed to get slave list for port = %d\n", port_id);
5913 		return;
5914 	}
5915 	if (num_slaves > 0) {
5916 		printf("\tSlaves (%d): [", num_slaves);
5917 		for (i = 0; i < num_slaves - 1; i++)
5918 			printf("%d ", slaves[i]);
5919 
5920 		printf("%d]\n", slaves[num_slaves - 1]);
5921 	} else {
5922 		printf("\tSlaves: []\n");
5923 
5924 	}
5925 
5926 	num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
5927 			RTE_MAX_ETHPORTS);
5928 
5929 	if (num_active_slaves < 0) {
5930 		printf("\tFailed to get active slave list for port = %d\n", port_id);
5931 		return;
5932 	}
5933 	if (num_active_slaves > 0) {
5934 		printf("\tActive Slaves (%d): [", num_active_slaves);
5935 		for (i = 0; i < num_active_slaves - 1; i++)
5936 			printf("%d ", slaves[i]);
5937 
5938 		printf("%d]\n", slaves[num_active_slaves - 1]);
5939 
5940 	} else {
5941 		printf("\tActive Slaves: []\n");
5942 
5943 	}
5944 
5945 	primary_id = rte_eth_bond_primary_get(port_id);
5946 	if (primary_id < 0) {
5947 		printf("\tFailed to get primary slave for port = %d\n", port_id);
5948 		return;
5949 	} else
5950 		printf("\tPrimary: [%d]\n", primary_id);
5951 
5952 }
5953 
5954 cmdline_parse_token_string_t cmd_showbonding_config_show =
5955 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5956 		show, "show");
5957 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
5958 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5959 		bonding, "bonding");
5960 cmdline_parse_token_string_t cmd_showbonding_config_config =
5961 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5962 		config, "config");
5963 cmdline_parse_token_num_t cmd_showbonding_config_port =
5964 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
5965 		port_id, UINT16);
5966 
5967 cmdline_parse_inst_t cmd_show_bonding_config = {
5968 		.f = cmd_show_bonding_config_parsed,
5969 		.help_str = "show bonding config <port_id>: "
5970 			"Show the bonding config for port_id",
5971 		.data = NULL,
5972 		.tokens = {
5973 				(void *)&cmd_showbonding_config_show,
5974 				(void *)&cmd_showbonding_config_bonding,
5975 				(void *)&cmd_showbonding_config_config,
5976 				(void *)&cmd_showbonding_config_port,
5977 				NULL
5978 		}
5979 };
5980 
5981 /* *** SET BONDING PRIMARY *** */
5982 struct cmd_set_bonding_primary_result {
5983 	cmdline_fixed_string_t set;
5984 	cmdline_fixed_string_t bonding;
5985 	cmdline_fixed_string_t primary;
5986 	portid_t slave_id;
5987 	portid_t port_id;
5988 };
5989 
5990 static void cmd_set_bonding_primary_parsed(void *parsed_result,
5991 		__attribute__((unused))  struct cmdline *cl,
5992 		__attribute__((unused)) void *data)
5993 {
5994 	struct cmd_set_bonding_primary_result *res = parsed_result;
5995 	portid_t master_port_id = res->port_id;
5996 	portid_t slave_port_id = res->slave_id;
5997 
5998 	/* Set the primary slave for a bonded device. */
5999 	if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
6000 		printf("\t Failed to set primary slave for port = %d.\n",
6001 				master_port_id);
6002 		return;
6003 	}
6004 	init_port_config();
6005 }
6006 
6007 cmdline_parse_token_string_t cmd_setbonding_primary_set =
6008 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6009 		set, "set");
6010 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
6011 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6012 		bonding, "bonding");
6013 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
6014 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6015 		primary, "primary");
6016 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
6017 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6018 		slave_id, UINT16);
6019 cmdline_parse_token_num_t cmd_setbonding_primary_port =
6020 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6021 		port_id, UINT16);
6022 
6023 cmdline_parse_inst_t cmd_set_bonding_primary = {
6024 		.f = cmd_set_bonding_primary_parsed,
6025 		.help_str = "set bonding primary <slave_id> <port_id>: "
6026 			"Set the primary slave for port_id",
6027 		.data = NULL,
6028 		.tokens = {
6029 				(void *)&cmd_setbonding_primary_set,
6030 				(void *)&cmd_setbonding_primary_bonding,
6031 				(void *)&cmd_setbonding_primary_primary,
6032 				(void *)&cmd_setbonding_primary_slave,
6033 				(void *)&cmd_setbonding_primary_port,
6034 				NULL
6035 		}
6036 };
6037 
6038 /* *** ADD SLAVE *** */
6039 struct cmd_add_bonding_slave_result {
6040 	cmdline_fixed_string_t add;
6041 	cmdline_fixed_string_t bonding;
6042 	cmdline_fixed_string_t slave;
6043 	portid_t slave_id;
6044 	portid_t port_id;
6045 };
6046 
6047 static void cmd_add_bonding_slave_parsed(void *parsed_result,
6048 		__attribute__((unused))  struct cmdline *cl,
6049 		__attribute__((unused)) void *data)
6050 {
6051 	struct cmd_add_bonding_slave_result *res = parsed_result;
6052 	portid_t master_port_id = res->port_id;
6053 	portid_t slave_port_id = res->slave_id;
6054 
6055 	/* add the slave for a bonded device. */
6056 	if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
6057 		printf("\t Failed to add slave %d to master port = %d.\n",
6058 				slave_port_id, master_port_id);
6059 		return;
6060 	}
6061 	init_port_config();
6062 	set_port_slave_flag(slave_port_id);
6063 }
6064 
6065 cmdline_parse_token_string_t cmd_addbonding_slave_add =
6066 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6067 		add, "add");
6068 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
6069 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6070 		bonding, "bonding");
6071 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
6072 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6073 		slave, "slave");
6074 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
6075 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6076 		slave_id, UINT16);
6077 cmdline_parse_token_num_t cmd_addbonding_slave_port =
6078 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6079 		port_id, UINT16);
6080 
6081 cmdline_parse_inst_t cmd_add_bonding_slave = {
6082 		.f = cmd_add_bonding_slave_parsed,
6083 		.help_str = "add bonding slave <slave_id> <port_id>: "
6084 			"Add a slave device to a bonded device",
6085 		.data = NULL,
6086 		.tokens = {
6087 				(void *)&cmd_addbonding_slave_add,
6088 				(void *)&cmd_addbonding_slave_bonding,
6089 				(void *)&cmd_addbonding_slave_slave,
6090 				(void *)&cmd_addbonding_slave_slaveid,
6091 				(void *)&cmd_addbonding_slave_port,
6092 				NULL
6093 		}
6094 };
6095 
6096 /* *** REMOVE SLAVE *** */
6097 struct cmd_remove_bonding_slave_result {
6098 	cmdline_fixed_string_t remove;
6099 	cmdline_fixed_string_t bonding;
6100 	cmdline_fixed_string_t slave;
6101 	portid_t slave_id;
6102 	portid_t port_id;
6103 };
6104 
6105 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
6106 		__attribute__((unused))  struct cmdline *cl,
6107 		__attribute__((unused)) void *data)
6108 {
6109 	struct cmd_remove_bonding_slave_result *res = parsed_result;
6110 	portid_t master_port_id = res->port_id;
6111 	portid_t slave_port_id = res->slave_id;
6112 
6113 	/* remove the slave from a bonded device. */
6114 	if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
6115 		printf("\t Failed to remove slave %d from master port = %d.\n",
6116 				slave_port_id, master_port_id);
6117 		return;
6118 	}
6119 	init_port_config();
6120 	clear_port_slave_flag(slave_port_id);
6121 }
6122 
6123 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
6124 		TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6125 				remove, "remove");
6126 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
6127 		TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6128 				bonding, "bonding");
6129 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
6130 		TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6131 				slave, "slave");
6132 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
6133 		TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6134 				slave_id, UINT16);
6135 cmdline_parse_token_num_t cmd_removebonding_slave_port =
6136 		TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6137 				port_id, UINT16);
6138 
6139 cmdline_parse_inst_t cmd_remove_bonding_slave = {
6140 		.f = cmd_remove_bonding_slave_parsed,
6141 		.help_str = "remove bonding slave <slave_id> <port_id>: "
6142 			"Remove a slave device from a bonded device",
6143 		.data = NULL,
6144 		.tokens = {
6145 				(void *)&cmd_removebonding_slave_remove,
6146 				(void *)&cmd_removebonding_slave_bonding,
6147 				(void *)&cmd_removebonding_slave_slave,
6148 				(void *)&cmd_removebonding_slave_slaveid,
6149 				(void *)&cmd_removebonding_slave_port,
6150 				NULL
6151 		}
6152 };
6153 
6154 /* *** CREATE BONDED DEVICE *** */
6155 struct cmd_create_bonded_device_result {
6156 	cmdline_fixed_string_t create;
6157 	cmdline_fixed_string_t bonded;
6158 	cmdline_fixed_string_t device;
6159 	uint8_t mode;
6160 	uint8_t socket;
6161 };
6162 
6163 static int bond_dev_num = 0;
6164 
6165 static void cmd_create_bonded_device_parsed(void *parsed_result,
6166 		__attribute__((unused))  struct cmdline *cl,
6167 		__attribute__((unused)) void *data)
6168 {
6169 	struct cmd_create_bonded_device_result *res = parsed_result;
6170 	char ethdev_name[RTE_ETH_NAME_MAX_LEN];
6171 	int port_id;
6172 	int ret;
6173 
6174 	if (test_done == 0) {
6175 		printf("Please stop forwarding first\n");
6176 		return;
6177 	}
6178 
6179 	snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
6180 			bond_dev_num++);
6181 
6182 	/* Create a new bonded device. */
6183 	port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
6184 	if (port_id < 0) {
6185 		printf("\t Failed to create bonded device.\n");
6186 		return;
6187 	} else {
6188 		printf("Created new bonded device %s on (port %d).\n", ethdev_name,
6189 				port_id);
6190 
6191 		/* Update number of ports */
6192 		nb_ports = rte_eth_dev_count_avail();
6193 		reconfig(port_id, res->socket);
6194 		ret = rte_eth_promiscuous_enable(port_id);
6195 		if (ret != 0)
6196 			printf("Failed to enable promiscuous mode for port %u: %s - ignore\n",
6197 				port_id, rte_strerror(-ret));
6198 
6199 		ports[port_id].need_setup = 0;
6200 		ports[port_id].port_status = RTE_PORT_STOPPED;
6201 	}
6202 
6203 }
6204 
6205 cmdline_parse_token_string_t cmd_createbonded_device_create =
6206 		TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6207 				create, "create");
6208 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
6209 		TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6210 				bonded, "bonded");
6211 cmdline_parse_token_string_t cmd_createbonded_device_device =
6212 		TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6213 				device, "device");
6214 cmdline_parse_token_num_t cmd_createbonded_device_mode =
6215 		TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6216 				mode, UINT8);
6217 cmdline_parse_token_num_t cmd_createbonded_device_socket =
6218 		TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6219 				socket, UINT8);
6220 
6221 cmdline_parse_inst_t cmd_create_bonded_device = {
6222 		.f = cmd_create_bonded_device_parsed,
6223 		.help_str = "create bonded device <mode> <socket>: "
6224 			"Create a new bonded device with specific bonding mode and socket",
6225 		.data = NULL,
6226 		.tokens = {
6227 				(void *)&cmd_createbonded_device_create,
6228 				(void *)&cmd_createbonded_device_bonded,
6229 				(void *)&cmd_createbonded_device_device,
6230 				(void *)&cmd_createbonded_device_mode,
6231 				(void *)&cmd_createbonded_device_socket,
6232 				NULL
6233 		}
6234 };
6235 
6236 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
6237 struct cmd_set_bond_mac_addr_result {
6238 	cmdline_fixed_string_t set;
6239 	cmdline_fixed_string_t bonding;
6240 	cmdline_fixed_string_t mac_addr;
6241 	uint16_t port_num;
6242 	struct rte_ether_addr address;
6243 };
6244 
6245 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
6246 		__attribute__((unused))  struct cmdline *cl,
6247 		__attribute__((unused)) void *data)
6248 {
6249 	struct cmd_set_bond_mac_addr_result *res = parsed_result;
6250 	int ret;
6251 
6252 	if (port_id_is_invalid(res->port_num, ENABLED_WARN))
6253 		return;
6254 
6255 	ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
6256 
6257 	/* check the return value and print it if is < 0 */
6258 	if (ret < 0)
6259 		printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6260 }
6261 
6262 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
6263 		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
6264 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
6265 		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
6266 				"bonding");
6267 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
6268 		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
6269 				"mac_addr");
6270 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
6271 		TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
6272 				port_num, UINT16);
6273 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
6274 		TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
6275 
6276 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
6277 		.f = cmd_set_bond_mac_addr_parsed,
6278 		.data = (void *) 0,
6279 		.help_str = "set bonding mac_addr <port_id> <mac_addr>",
6280 		.tokens = {
6281 				(void *)&cmd_set_bond_mac_addr_set,
6282 				(void *)&cmd_set_bond_mac_addr_bonding,
6283 				(void *)&cmd_set_bond_mac_addr_mac,
6284 				(void *)&cmd_set_bond_mac_addr_portnum,
6285 				(void *)&cmd_set_bond_mac_addr_addr,
6286 				NULL
6287 		}
6288 };
6289 
6290 
6291 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
6292 struct cmd_set_bond_mon_period_result {
6293 	cmdline_fixed_string_t set;
6294 	cmdline_fixed_string_t bonding;
6295 	cmdline_fixed_string_t mon_period;
6296 	uint16_t port_num;
6297 	uint32_t period_ms;
6298 };
6299 
6300 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
6301 		__attribute__((unused))  struct cmdline *cl,
6302 		__attribute__((unused)) void *data)
6303 {
6304 	struct cmd_set_bond_mon_period_result *res = parsed_result;
6305 	int ret;
6306 
6307 	ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
6308 
6309 	/* check the return value and print it if is < 0 */
6310 	if (ret < 0)
6311 		printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6312 }
6313 
6314 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
6315 		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6316 				set, "set");
6317 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
6318 		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6319 				bonding, "bonding");
6320 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
6321 		TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6322 				mon_period,	"mon_period");
6323 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
6324 		TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6325 				port_num, UINT16);
6326 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
6327 		TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6328 				period_ms, UINT32);
6329 
6330 cmdline_parse_inst_t cmd_set_bond_mon_period = {
6331 		.f = cmd_set_bond_mon_period_parsed,
6332 		.data = (void *) 0,
6333 		.help_str = "set bonding mon_period <port_id> <period_ms>",
6334 		.tokens = {
6335 				(void *)&cmd_set_bond_mon_period_set,
6336 				(void *)&cmd_set_bond_mon_period_bonding,
6337 				(void *)&cmd_set_bond_mon_period_mon_period,
6338 				(void *)&cmd_set_bond_mon_period_portnum,
6339 				(void *)&cmd_set_bond_mon_period_period_ms,
6340 				NULL
6341 		}
6342 };
6343 
6344 
6345 
6346 struct cmd_set_bonding_agg_mode_policy_result {
6347 	cmdline_fixed_string_t set;
6348 	cmdline_fixed_string_t bonding;
6349 	cmdline_fixed_string_t agg_mode;
6350 	uint16_t port_num;
6351 	cmdline_fixed_string_t policy;
6352 };
6353 
6354 
6355 static void
6356 cmd_set_bonding_agg_mode(void *parsed_result,
6357 		__attribute__((unused)) struct cmdline *cl,
6358 		__attribute__((unused)) void *data)
6359 {
6360 	struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
6361 	uint8_t policy = AGG_BANDWIDTH;
6362 
6363 	if (!strcmp(res->policy, "bandwidth"))
6364 		policy = AGG_BANDWIDTH;
6365 	else if (!strcmp(res->policy, "stable"))
6366 		policy = AGG_STABLE;
6367 	else if (!strcmp(res->policy, "count"))
6368 		policy = AGG_COUNT;
6369 
6370 	rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
6371 }
6372 
6373 
6374 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
6375 	TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6376 				set, "set");
6377 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
6378 	TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6379 				bonding, "bonding");
6380 
6381 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
6382 	TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6383 				agg_mode, "agg_mode");
6384 
6385 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
6386 	TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6387 				port_num, UINT16);
6388 
6389 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6390 	TOKEN_STRING_INITIALIZER(
6391 			struct cmd_set_bonding_balance_xmit_policy_result,
6392 		policy, "stable#bandwidth#count");
6393 
6394 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6395 	.f = cmd_set_bonding_agg_mode,
6396 	.data = (void *) 0,
6397 	.help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6398 	.tokens = {
6399 			(void *)&cmd_set_bonding_agg_mode_set,
6400 			(void *)&cmd_set_bonding_agg_mode_bonding,
6401 			(void *)&cmd_set_bonding_agg_mode_agg_mode,
6402 			(void *)&cmd_set_bonding_agg_mode_portnum,
6403 			(void *)&cmd_set_bonding_agg_mode_policy_string,
6404 			NULL
6405 		}
6406 };
6407 
6408 
6409 #endif /* RTE_LIBRTE_PMD_BOND */
6410 
6411 /* *** SET FORWARDING MODE *** */
6412 struct cmd_set_fwd_mode_result {
6413 	cmdline_fixed_string_t set;
6414 	cmdline_fixed_string_t fwd;
6415 	cmdline_fixed_string_t mode;
6416 };
6417 
6418 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6419 				    __attribute__((unused)) struct cmdline *cl,
6420 				    __attribute__((unused)) void *data)
6421 {
6422 	struct cmd_set_fwd_mode_result *res = parsed_result;
6423 
6424 	retry_enabled = 0;
6425 	set_pkt_forwarding_mode(res->mode);
6426 }
6427 
6428 cmdline_parse_token_string_t cmd_setfwd_set =
6429 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6430 cmdline_parse_token_string_t cmd_setfwd_fwd =
6431 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6432 cmdline_parse_token_string_t cmd_setfwd_mode =
6433 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6434 		"" /* defined at init */);
6435 
6436 cmdline_parse_inst_t cmd_set_fwd_mode = {
6437 	.f = cmd_set_fwd_mode_parsed,
6438 	.data = NULL,
6439 	.help_str = NULL, /* defined at init */
6440 	.tokens = {
6441 		(void *)&cmd_setfwd_set,
6442 		(void *)&cmd_setfwd_fwd,
6443 		(void *)&cmd_setfwd_mode,
6444 		NULL,
6445 	},
6446 };
6447 
6448 static void cmd_set_fwd_mode_init(void)
6449 {
6450 	char *modes, *c;
6451 	static char token[128];
6452 	static char help[256];
6453 	cmdline_parse_token_string_t *token_struct;
6454 
6455 	modes = list_pkt_forwarding_modes();
6456 	snprintf(help, sizeof(help), "set fwd %s: "
6457 		"Set packet forwarding mode", modes);
6458 	cmd_set_fwd_mode.help_str = help;
6459 
6460 	/* string token separator is # */
6461 	for (c = token; *modes != '\0'; modes++)
6462 		if (*modes == '|')
6463 			*c++ = '#';
6464 		else
6465 			*c++ = *modes;
6466 	token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6467 	token_struct->string_data.str = token;
6468 }
6469 
6470 /* *** SET RETRY FORWARDING MODE *** */
6471 struct cmd_set_fwd_retry_mode_result {
6472 	cmdline_fixed_string_t set;
6473 	cmdline_fixed_string_t fwd;
6474 	cmdline_fixed_string_t mode;
6475 	cmdline_fixed_string_t retry;
6476 };
6477 
6478 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6479 			    __attribute__((unused)) struct cmdline *cl,
6480 			    __attribute__((unused)) void *data)
6481 {
6482 	struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6483 
6484 	retry_enabled = 1;
6485 	set_pkt_forwarding_mode(res->mode);
6486 }
6487 
6488 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6489 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6490 			set, "set");
6491 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6492 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6493 			fwd, "fwd");
6494 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6495 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6496 			mode,
6497 		"" /* defined at init */);
6498 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6499 	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6500 			retry, "retry");
6501 
6502 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6503 	.f = cmd_set_fwd_retry_mode_parsed,
6504 	.data = NULL,
6505 	.help_str = NULL, /* defined at init */
6506 	.tokens = {
6507 		(void *)&cmd_setfwd_retry_set,
6508 		(void *)&cmd_setfwd_retry_fwd,
6509 		(void *)&cmd_setfwd_retry_mode,
6510 		(void *)&cmd_setfwd_retry_retry,
6511 		NULL,
6512 	},
6513 };
6514 
6515 static void cmd_set_fwd_retry_mode_init(void)
6516 {
6517 	char *modes, *c;
6518 	static char token[128];
6519 	static char help[256];
6520 	cmdline_parse_token_string_t *token_struct;
6521 
6522 	modes = list_pkt_forwarding_retry_modes();
6523 	snprintf(help, sizeof(help), "set fwd %s retry: "
6524 		"Set packet forwarding mode with retry", modes);
6525 	cmd_set_fwd_retry_mode.help_str = help;
6526 
6527 	/* string token separator is # */
6528 	for (c = token; *modes != '\0'; modes++)
6529 		if (*modes == '|')
6530 			*c++ = '#';
6531 		else
6532 			*c++ = *modes;
6533 	token_struct = (cmdline_parse_token_string_t *)
6534 		cmd_set_fwd_retry_mode.tokens[2];
6535 	token_struct->string_data.str = token;
6536 }
6537 
6538 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6539 struct cmd_set_burst_tx_retry_result {
6540 	cmdline_fixed_string_t set;
6541 	cmdline_fixed_string_t burst;
6542 	cmdline_fixed_string_t tx;
6543 	cmdline_fixed_string_t delay;
6544 	uint32_t time;
6545 	cmdline_fixed_string_t retry;
6546 	uint32_t retry_num;
6547 };
6548 
6549 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6550 					__attribute__((unused)) struct cmdline *cl,
6551 					__attribute__((unused)) void *data)
6552 {
6553 	struct cmd_set_burst_tx_retry_result *res = parsed_result;
6554 
6555 	if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6556 		&& !strcmp(res->tx, "tx")) {
6557 		if (!strcmp(res->delay, "delay"))
6558 			burst_tx_delay_time = res->time;
6559 		if (!strcmp(res->retry, "retry"))
6560 			burst_tx_retry_num = res->retry_num;
6561 	}
6562 
6563 }
6564 
6565 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6566 	TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6567 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6568 	TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6569 				 "burst");
6570 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6571 	TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6572 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6573 	TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6574 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6575 	TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
6576 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6577 	TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6578 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6579 	TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
6580 
6581 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6582 	.f = cmd_set_burst_tx_retry_parsed,
6583 	.help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6584 	.tokens = {
6585 		(void *)&cmd_set_burst_tx_retry_set,
6586 		(void *)&cmd_set_burst_tx_retry_burst,
6587 		(void *)&cmd_set_burst_tx_retry_tx,
6588 		(void *)&cmd_set_burst_tx_retry_delay,
6589 		(void *)&cmd_set_burst_tx_retry_time,
6590 		(void *)&cmd_set_burst_tx_retry_retry,
6591 		(void *)&cmd_set_burst_tx_retry_retry_num,
6592 		NULL,
6593 	},
6594 };
6595 
6596 /* *** SET PROMISC MODE *** */
6597 struct cmd_set_promisc_mode_result {
6598 	cmdline_fixed_string_t set;
6599 	cmdline_fixed_string_t promisc;
6600 	cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6601 	uint16_t port_num;               /* valid if "allports" argument == 0 */
6602 	cmdline_fixed_string_t mode;
6603 };
6604 
6605 static void cmd_set_promisc_mode_parsed(void *parsed_result,
6606 					__attribute__((unused)) struct cmdline *cl,
6607 					void *allports)
6608 {
6609 	struct cmd_set_promisc_mode_result *res = parsed_result;
6610 	int enable;
6611 	portid_t i;
6612 
6613 	if (!strcmp(res->mode, "on"))
6614 		enable = 1;
6615 	else
6616 		enable = 0;
6617 
6618 	/* all ports */
6619 	if (allports) {
6620 		RTE_ETH_FOREACH_DEV(i)
6621 			eth_set_promisc_mode(i, enable);
6622 	} else {
6623 		eth_set_promisc_mode(res->port_num, enable);
6624 	}
6625 }
6626 
6627 cmdline_parse_token_string_t cmd_setpromisc_set =
6628 	TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6629 cmdline_parse_token_string_t cmd_setpromisc_promisc =
6630 	TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6631 				 "promisc");
6632 cmdline_parse_token_string_t cmd_setpromisc_portall =
6633 	TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6634 				 "all");
6635 cmdline_parse_token_num_t cmd_setpromisc_portnum =
6636 	TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6637 			      UINT16);
6638 cmdline_parse_token_string_t cmd_setpromisc_mode =
6639 	TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6640 				 "on#off");
6641 
6642 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6643 	.f = cmd_set_promisc_mode_parsed,
6644 	.data = (void *)1,
6645 	.help_str = "set promisc all on|off: Set promisc mode for all ports",
6646 	.tokens = {
6647 		(void *)&cmd_setpromisc_set,
6648 		(void *)&cmd_setpromisc_promisc,
6649 		(void *)&cmd_setpromisc_portall,
6650 		(void *)&cmd_setpromisc_mode,
6651 		NULL,
6652 	},
6653 };
6654 
6655 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6656 	.f = cmd_set_promisc_mode_parsed,
6657 	.data = (void *)0,
6658 	.help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6659 	.tokens = {
6660 		(void *)&cmd_setpromisc_set,
6661 		(void *)&cmd_setpromisc_promisc,
6662 		(void *)&cmd_setpromisc_portnum,
6663 		(void *)&cmd_setpromisc_mode,
6664 		NULL,
6665 	},
6666 };
6667 
6668 /* *** SET ALLMULTI MODE *** */
6669 struct cmd_set_allmulti_mode_result {
6670 	cmdline_fixed_string_t set;
6671 	cmdline_fixed_string_t allmulti;
6672 	cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6673 	uint16_t port_num;               /* valid if "allports" argument == 0 */
6674 	cmdline_fixed_string_t mode;
6675 };
6676 
6677 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6678 					__attribute__((unused)) struct cmdline *cl,
6679 					void *allports)
6680 {
6681 	struct cmd_set_allmulti_mode_result *res = parsed_result;
6682 	int enable;
6683 	portid_t i;
6684 
6685 	if (!strcmp(res->mode, "on"))
6686 		enable = 1;
6687 	else
6688 		enable = 0;
6689 
6690 	/* all ports */
6691 	if (allports) {
6692 		RTE_ETH_FOREACH_DEV(i) {
6693 			eth_set_allmulticast_mode(i, enable);
6694 		}
6695 	}
6696 	else {
6697 		eth_set_allmulticast_mode(res->port_num, enable);
6698 	}
6699 }
6700 
6701 cmdline_parse_token_string_t cmd_setallmulti_set =
6702 	TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6703 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6704 	TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6705 				 "allmulti");
6706 cmdline_parse_token_string_t cmd_setallmulti_portall =
6707 	TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6708 				 "all");
6709 cmdline_parse_token_num_t cmd_setallmulti_portnum =
6710 	TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6711 			      UINT16);
6712 cmdline_parse_token_string_t cmd_setallmulti_mode =
6713 	TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6714 				 "on#off");
6715 
6716 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6717 	.f = cmd_set_allmulti_mode_parsed,
6718 	.data = (void *)1,
6719 	.help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6720 	.tokens = {
6721 		(void *)&cmd_setallmulti_set,
6722 		(void *)&cmd_setallmulti_allmulti,
6723 		(void *)&cmd_setallmulti_portall,
6724 		(void *)&cmd_setallmulti_mode,
6725 		NULL,
6726 	},
6727 };
6728 
6729 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6730 	.f = cmd_set_allmulti_mode_parsed,
6731 	.data = (void *)0,
6732 	.help_str = "set allmulti <port_id> on|off: "
6733 		"Set allmulti mode on port_id",
6734 	.tokens = {
6735 		(void *)&cmd_setallmulti_set,
6736 		(void *)&cmd_setallmulti_allmulti,
6737 		(void *)&cmd_setallmulti_portnum,
6738 		(void *)&cmd_setallmulti_mode,
6739 		NULL,
6740 	},
6741 };
6742 
6743 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
6744 struct cmd_link_flow_ctrl_set_result {
6745 	cmdline_fixed_string_t set;
6746 	cmdline_fixed_string_t flow_ctrl;
6747 	cmdline_fixed_string_t rx;
6748 	cmdline_fixed_string_t rx_lfc_mode;
6749 	cmdline_fixed_string_t tx;
6750 	cmdline_fixed_string_t tx_lfc_mode;
6751 	cmdline_fixed_string_t mac_ctrl_frame_fwd;
6752 	cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
6753 	cmdline_fixed_string_t autoneg_str;
6754 	cmdline_fixed_string_t autoneg;
6755 	cmdline_fixed_string_t hw_str;
6756 	uint32_t high_water;
6757 	cmdline_fixed_string_t lw_str;
6758 	uint32_t low_water;
6759 	cmdline_fixed_string_t pt_str;
6760 	uint16_t pause_time;
6761 	cmdline_fixed_string_t xon_str;
6762 	uint16_t send_xon;
6763 	portid_t port_id;
6764 };
6765 
6766 cmdline_parse_token_string_t cmd_lfc_set_set =
6767 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6768 				set, "set");
6769 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
6770 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6771 				flow_ctrl, "flow_ctrl");
6772 cmdline_parse_token_string_t cmd_lfc_set_rx =
6773 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6774 				rx, "rx");
6775 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
6776 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6777 				rx_lfc_mode, "on#off");
6778 cmdline_parse_token_string_t cmd_lfc_set_tx =
6779 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6780 				tx, "tx");
6781 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
6782 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6783 				tx_lfc_mode, "on#off");
6784 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
6785 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6786 				hw_str, "high_water");
6787 cmdline_parse_token_num_t cmd_lfc_set_high_water =
6788 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6789 				high_water, UINT32);
6790 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
6791 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6792 				lw_str, "low_water");
6793 cmdline_parse_token_num_t cmd_lfc_set_low_water =
6794 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6795 				low_water, UINT32);
6796 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
6797 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6798 				pt_str, "pause_time");
6799 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
6800 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6801 				pause_time, UINT16);
6802 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
6803 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6804 				xon_str, "send_xon");
6805 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
6806 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6807 				send_xon, UINT16);
6808 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
6809 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6810 				mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
6811 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6812 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6813 				mac_ctrl_frame_fwd_mode, "on#off");
6814 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6815 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6816 				autoneg_str, "autoneg");
6817 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6818 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6819 				autoneg, "on#off");
6820 cmdline_parse_token_num_t cmd_lfc_set_portid =
6821 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6822 				port_id, UINT16);
6823 
6824 /* forward declaration */
6825 static void
6826 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6827 			      void *data);
6828 
6829 cmdline_parse_inst_t cmd_link_flow_control_set = {
6830 	.f = cmd_link_flow_ctrl_set_parsed,
6831 	.data = NULL,
6832 	.help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6833 		"<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6834 		"autoneg on|off <port_id>: Configure the Ethernet flow control",
6835 	.tokens = {
6836 		(void *)&cmd_lfc_set_set,
6837 		(void *)&cmd_lfc_set_flow_ctrl,
6838 		(void *)&cmd_lfc_set_rx,
6839 		(void *)&cmd_lfc_set_rx_mode,
6840 		(void *)&cmd_lfc_set_tx,
6841 		(void *)&cmd_lfc_set_tx_mode,
6842 		(void *)&cmd_lfc_set_high_water,
6843 		(void *)&cmd_lfc_set_low_water,
6844 		(void *)&cmd_lfc_set_pause_time,
6845 		(void *)&cmd_lfc_set_send_xon,
6846 		(void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6847 		(void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6848 		(void *)&cmd_lfc_set_autoneg_str,
6849 		(void *)&cmd_lfc_set_autoneg,
6850 		(void *)&cmd_lfc_set_portid,
6851 		NULL,
6852 	},
6853 };
6854 
6855 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6856 	.f = cmd_link_flow_ctrl_set_parsed,
6857 	.data = (void *)&cmd_link_flow_control_set_rx,
6858 	.help_str = "set flow_ctrl rx on|off <port_id>: "
6859 		"Change rx flow control parameter",
6860 	.tokens = {
6861 		(void *)&cmd_lfc_set_set,
6862 		(void *)&cmd_lfc_set_flow_ctrl,
6863 		(void *)&cmd_lfc_set_rx,
6864 		(void *)&cmd_lfc_set_rx_mode,
6865 		(void *)&cmd_lfc_set_portid,
6866 		NULL,
6867 	},
6868 };
6869 
6870 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6871 	.f = cmd_link_flow_ctrl_set_parsed,
6872 	.data = (void *)&cmd_link_flow_control_set_tx,
6873 	.help_str = "set flow_ctrl tx on|off <port_id>: "
6874 		"Change tx flow control parameter",
6875 	.tokens = {
6876 		(void *)&cmd_lfc_set_set,
6877 		(void *)&cmd_lfc_set_flow_ctrl,
6878 		(void *)&cmd_lfc_set_tx,
6879 		(void *)&cmd_lfc_set_tx_mode,
6880 		(void *)&cmd_lfc_set_portid,
6881 		NULL,
6882 	},
6883 };
6884 
6885 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
6886 	.f = cmd_link_flow_ctrl_set_parsed,
6887 	.data = (void *)&cmd_link_flow_control_set_hw,
6888 	.help_str = "set flow_ctrl high_water <value> <port_id>: "
6889 		"Change high water flow control parameter",
6890 	.tokens = {
6891 		(void *)&cmd_lfc_set_set,
6892 		(void *)&cmd_lfc_set_flow_ctrl,
6893 		(void *)&cmd_lfc_set_high_water_str,
6894 		(void *)&cmd_lfc_set_high_water,
6895 		(void *)&cmd_lfc_set_portid,
6896 		NULL,
6897 	},
6898 };
6899 
6900 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
6901 	.f = cmd_link_flow_ctrl_set_parsed,
6902 	.data = (void *)&cmd_link_flow_control_set_lw,
6903 	.help_str = "set flow_ctrl low_water <value> <port_id>: "
6904 		"Change low water flow control parameter",
6905 	.tokens = {
6906 		(void *)&cmd_lfc_set_set,
6907 		(void *)&cmd_lfc_set_flow_ctrl,
6908 		(void *)&cmd_lfc_set_low_water_str,
6909 		(void *)&cmd_lfc_set_low_water,
6910 		(void *)&cmd_lfc_set_portid,
6911 		NULL,
6912 	},
6913 };
6914 
6915 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
6916 	.f = cmd_link_flow_ctrl_set_parsed,
6917 	.data = (void *)&cmd_link_flow_control_set_pt,
6918 	.help_str = "set flow_ctrl pause_time <value> <port_id>: "
6919 		"Change pause time flow control parameter",
6920 	.tokens = {
6921 		(void *)&cmd_lfc_set_set,
6922 		(void *)&cmd_lfc_set_flow_ctrl,
6923 		(void *)&cmd_lfc_set_pause_time_str,
6924 		(void *)&cmd_lfc_set_pause_time,
6925 		(void *)&cmd_lfc_set_portid,
6926 		NULL,
6927 	},
6928 };
6929 
6930 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
6931 	.f = cmd_link_flow_ctrl_set_parsed,
6932 	.data = (void *)&cmd_link_flow_control_set_xon,
6933 	.help_str = "set flow_ctrl send_xon <value> <port_id>: "
6934 		"Change send_xon flow control parameter",
6935 	.tokens = {
6936 		(void *)&cmd_lfc_set_set,
6937 		(void *)&cmd_lfc_set_flow_ctrl,
6938 		(void *)&cmd_lfc_set_send_xon_str,
6939 		(void *)&cmd_lfc_set_send_xon,
6940 		(void *)&cmd_lfc_set_portid,
6941 		NULL,
6942 	},
6943 };
6944 
6945 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
6946 	.f = cmd_link_flow_ctrl_set_parsed,
6947 	.data = (void *)&cmd_link_flow_control_set_macfwd,
6948 	.help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
6949 		"Change mac ctrl fwd flow control parameter",
6950 	.tokens = {
6951 		(void *)&cmd_lfc_set_set,
6952 		(void *)&cmd_lfc_set_flow_ctrl,
6953 		(void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6954 		(void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6955 		(void *)&cmd_lfc_set_portid,
6956 		NULL,
6957 	},
6958 };
6959 
6960 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
6961 	.f = cmd_link_flow_ctrl_set_parsed,
6962 	.data = (void *)&cmd_link_flow_control_set_autoneg,
6963 	.help_str = "set flow_ctrl autoneg on|off <port_id>: "
6964 		"Change autoneg flow control parameter",
6965 	.tokens = {
6966 		(void *)&cmd_lfc_set_set,
6967 		(void *)&cmd_lfc_set_flow_ctrl,
6968 		(void *)&cmd_lfc_set_autoneg_str,
6969 		(void *)&cmd_lfc_set_autoneg,
6970 		(void *)&cmd_lfc_set_portid,
6971 		NULL,
6972 	},
6973 };
6974 
6975 static void
6976 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
6977 			      __attribute__((unused)) struct cmdline *cl,
6978 			      void *data)
6979 {
6980 	struct cmd_link_flow_ctrl_set_result *res = parsed_result;
6981 	cmdline_parse_inst_t *cmd = data;
6982 	struct rte_eth_fc_conf fc_conf;
6983 	int rx_fc_en = 0;
6984 	int tx_fc_en = 0;
6985 	int ret;
6986 
6987 	/*
6988 	 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6989 	 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6990 	 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6991 	 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6992 	 */
6993 	static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
6994 			{RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
6995 	};
6996 
6997 	/* Partial command line, retrieve current configuration */
6998 	if (cmd) {
6999 		ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
7000 		if (ret != 0) {
7001 			printf("cannot get current flow ctrl parameters, return"
7002 			       "code = %d\n", ret);
7003 			return;
7004 		}
7005 
7006 		if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
7007 		    (fc_conf.mode == RTE_FC_FULL))
7008 			rx_fc_en = 1;
7009 		if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
7010 		    (fc_conf.mode == RTE_FC_FULL))
7011 			tx_fc_en = 1;
7012 	}
7013 
7014 	if (!cmd || cmd == &cmd_link_flow_control_set_rx)
7015 		rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
7016 
7017 	if (!cmd || cmd == &cmd_link_flow_control_set_tx)
7018 		tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
7019 
7020 	fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
7021 
7022 	if (!cmd || cmd == &cmd_link_flow_control_set_hw)
7023 		fc_conf.high_water = res->high_water;
7024 
7025 	if (!cmd || cmd == &cmd_link_flow_control_set_lw)
7026 		fc_conf.low_water = res->low_water;
7027 
7028 	if (!cmd || cmd == &cmd_link_flow_control_set_pt)
7029 		fc_conf.pause_time = res->pause_time;
7030 
7031 	if (!cmd || cmd == &cmd_link_flow_control_set_xon)
7032 		fc_conf.send_xon = res->send_xon;
7033 
7034 	if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
7035 		if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
7036 			fc_conf.mac_ctrl_frame_fwd = 1;
7037 		else
7038 			fc_conf.mac_ctrl_frame_fwd = 0;
7039 	}
7040 
7041 	if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
7042 		fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
7043 
7044 	ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
7045 	if (ret != 0)
7046 		printf("bad flow contrl parameter, return code = %d \n", ret);
7047 }
7048 
7049 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
7050 struct cmd_priority_flow_ctrl_set_result {
7051 	cmdline_fixed_string_t set;
7052 	cmdline_fixed_string_t pfc_ctrl;
7053 	cmdline_fixed_string_t rx;
7054 	cmdline_fixed_string_t rx_pfc_mode;
7055 	cmdline_fixed_string_t tx;
7056 	cmdline_fixed_string_t tx_pfc_mode;
7057 	uint32_t high_water;
7058 	uint32_t low_water;
7059 	uint16_t pause_time;
7060 	uint8_t  priority;
7061 	portid_t port_id;
7062 };
7063 
7064 static void
7065 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
7066 		       __attribute__((unused)) struct cmdline *cl,
7067 		       __attribute__((unused)) void *data)
7068 {
7069 	struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
7070 	struct rte_eth_pfc_conf pfc_conf;
7071 	int rx_fc_enable, tx_fc_enable;
7072 	int ret;
7073 
7074 	/*
7075 	 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7076 	 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7077 	 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7078 	 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7079 	 */
7080 	static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
7081 			{RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
7082 	};
7083 
7084 	rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
7085 	tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
7086 	pfc_conf.fc.mode       = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
7087 	pfc_conf.fc.high_water = res->high_water;
7088 	pfc_conf.fc.low_water  = res->low_water;
7089 	pfc_conf.fc.pause_time = res->pause_time;
7090 	pfc_conf.priority      = res->priority;
7091 
7092 	ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
7093 	if (ret != 0)
7094 		printf("bad priority flow contrl parameter, return code = %d \n", ret);
7095 }
7096 
7097 cmdline_parse_token_string_t cmd_pfc_set_set =
7098 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7099 				set, "set");
7100 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
7101 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7102 				pfc_ctrl, "pfc_ctrl");
7103 cmdline_parse_token_string_t cmd_pfc_set_rx =
7104 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7105 				rx, "rx");
7106 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
7107 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7108 				rx_pfc_mode, "on#off");
7109 cmdline_parse_token_string_t cmd_pfc_set_tx =
7110 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7111 				tx, "tx");
7112 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
7113 	TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7114 				tx_pfc_mode, "on#off");
7115 cmdline_parse_token_num_t cmd_pfc_set_high_water =
7116 	TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7117 				high_water, UINT32);
7118 cmdline_parse_token_num_t cmd_pfc_set_low_water =
7119 	TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7120 				low_water, UINT32);
7121 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
7122 	TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7123 				pause_time, UINT16);
7124 cmdline_parse_token_num_t cmd_pfc_set_priority =
7125 	TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7126 				priority, UINT8);
7127 cmdline_parse_token_num_t cmd_pfc_set_portid =
7128 	TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7129 				port_id, UINT16);
7130 
7131 cmdline_parse_inst_t cmd_priority_flow_control_set = {
7132 	.f = cmd_priority_flow_ctrl_set_parsed,
7133 	.data = NULL,
7134 	.help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
7135 		"<pause_time> <priority> <port_id>: "
7136 		"Configure the Ethernet priority flow control",
7137 	.tokens = {
7138 		(void *)&cmd_pfc_set_set,
7139 		(void *)&cmd_pfc_set_flow_ctrl,
7140 		(void *)&cmd_pfc_set_rx,
7141 		(void *)&cmd_pfc_set_rx_mode,
7142 		(void *)&cmd_pfc_set_tx,
7143 		(void *)&cmd_pfc_set_tx_mode,
7144 		(void *)&cmd_pfc_set_high_water,
7145 		(void *)&cmd_pfc_set_low_water,
7146 		(void *)&cmd_pfc_set_pause_time,
7147 		(void *)&cmd_pfc_set_priority,
7148 		(void *)&cmd_pfc_set_portid,
7149 		NULL,
7150 	},
7151 };
7152 
7153 /* *** RESET CONFIGURATION *** */
7154 struct cmd_reset_result {
7155 	cmdline_fixed_string_t reset;
7156 	cmdline_fixed_string_t def;
7157 };
7158 
7159 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
7160 			     struct cmdline *cl,
7161 			     __attribute__((unused)) void *data)
7162 {
7163 	cmdline_printf(cl, "Reset to default forwarding configuration...\n");
7164 	set_def_fwd_config();
7165 }
7166 
7167 cmdline_parse_token_string_t cmd_reset_set =
7168 	TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
7169 cmdline_parse_token_string_t cmd_reset_def =
7170 	TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
7171 				 "default");
7172 
7173 cmdline_parse_inst_t cmd_reset = {
7174 	.f = cmd_reset_parsed,
7175 	.data = NULL,
7176 	.help_str = "set default: Reset default forwarding configuration",
7177 	.tokens = {
7178 		(void *)&cmd_reset_set,
7179 		(void *)&cmd_reset_def,
7180 		NULL,
7181 	},
7182 };
7183 
7184 /* *** START FORWARDING *** */
7185 struct cmd_start_result {
7186 	cmdline_fixed_string_t start;
7187 };
7188 
7189 cmdline_parse_token_string_t cmd_start_start =
7190 	TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
7191 
7192 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
7193 			     __attribute__((unused)) struct cmdline *cl,
7194 			     __attribute__((unused)) void *data)
7195 {
7196 	start_packet_forwarding(0);
7197 }
7198 
7199 cmdline_parse_inst_t cmd_start = {
7200 	.f = cmd_start_parsed,
7201 	.data = NULL,
7202 	.help_str = "start: Start packet forwarding",
7203 	.tokens = {
7204 		(void *)&cmd_start_start,
7205 		NULL,
7206 	},
7207 };
7208 
7209 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7210 struct cmd_start_tx_first_result {
7211 	cmdline_fixed_string_t start;
7212 	cmdline_fixed_string_t tx_first;
7213 };
7214 
7215 static void
7216 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
7217 			  __attribute__((unused)) struct cmdline *cl,
7218 			  __attribute__((unused)) void *data)
7219 {
7220 	start_packet_forwarding(1);
7221 }
7222 
7223 cmdline_parse_token_string_t cmd_start_tx_first_start =
7224 	TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7225 				 "start");
7226 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7227 	TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7228 				 tx_first, "tx_first");
7229 
7230 cmdline_parse_inst_t cmd_start_tx_first = {
7231 	.f = cmd_start_tx_first_parsed,
7232 	.data = NULL,
7233 	.help_str = "start tx_first: Start packet forwarding, "
7234 		"after sending 1 burst of packets",
7235 	.tokens = {
7236 		(void *)&cmd_start_tx_first_start,
7237 		(void *)&cmd_start_tx_first_tx_first,
7238 		NULL,
7239 	},
7240 };
7241 
7242 /* *** START FORWARDING WITH N TX BURST FIRST *** */
7243 struct cmd_start_tx_first_n_result {
7244 	cmdline_fixed_string_t start;
7245 	cmdline_fixed_string_t tx_first;
7246 	uint32_t tx_num;
7247 };
7248 
7249 static void
7250 cmd_start_tx_first_n_parsed(void *parsed_result,
7251 			  __attribute__((unused)) struct cmdline *cl,
7252 			  __attribute__((unused)) void *data)
7253 {
7254 	struct cmd_start_tx_first_n_result *res = parsed_result;
7255 
7256 	start_packet_forwarding(res->tx_num);
7257 }
7258 
7259 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7260 	TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7261 			start, "start");
7262 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7263 	TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7264 			tx_first, "tx_first");
7265 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7266 	TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7267 			tx_num, UINT32);
7268 
7269 cmdline_parse_inst_t cmd_start_tx_first_n = {
7270 	.f = cmd_start_tx_first_n_parsed,
7271 	.data = NULL,
7272 	.help_str = "start tx_first <num>: "
7273 		"packet forwarding, after sending <num> bursts of packets",
7274 	.tokens = {
7275 		(void *)&cmd_start_tx_first_n_start,
7276 		(void *)&cmd_start_tx_first_n_tx_first,
7277 		(void *)&cmd_start_tx_first_n_tx_num,
7278 		NULL,
7279 	},
7280 };
7281 
7282 /* *** SET LINK UP *** */
7283 struct cmd_set_link_up_result {
7284 	cmdline_fixed_string_t set;
7285 	cmdline_fixed_string_t link_up;
7286 	cmdline_fixed_string_t port;
7287 	portid_t port_id;
7288 };
7289 
7290 cmdline_parse_token_string_t cmd_set_link_up_set =
7291 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7292 cmdline_parse_token_string_t cmd_set_link_up_link_up =
7293 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7294 				"link-up");
7295 cmdline_parse_token_string_t cmd_set_link_up_port =
7296 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7297 cmdline_parse_token_num_t cmd_set_link_up_port_id =
7298 	TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16);
7299 
7300 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
7301 			     __attribute__((unused)) struct cmdline *cl,
7302 			     __attribute__((unused)) void *data)
7303 {
7304 	struct cmd_set_link_up_result *res = parsed_result;
7305 	dev_set_link_up(res->port_id);
7306 }
7307 
7308 cmdline_parse_inst_t cmd_set_link_up = {
7309 	.f = cmd_set_link_up_parsed,
7310 	.data = NULL,
7311 	.help_str = "set link-up port <port id>",
7312 	.tokens = {
7313 		(void *)&cmd_set_link_up_set,
7314 		(void *)&cmd_set_link_up_link_up,
7315 		(void *)&cmd_set_link_up_port,
7316 		(void *)&cmd_set_link_up_port_id,
7317 		NULL,
7318 	},
7319 };
7320 
7321 /* *** SET LINK DOWN *** */
7322 struct cmd_set_link_down_result {
7323 	cmdline_fixed_string_t set;
7324 	cmdline_fixed_string_t link_down;
7325 	cmdline_fixed_string_t port;
7326 	portid_t port_id;
7327 };
7328 
7329 cmdline_parse_token_string_t cmd_set_link_down_set =
7330 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
7331 cmdline_parse_token_string_t cmd_set_link_down_link_down =
7332 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
7333 				"link-down");
7334 cmdline_parse_token_string_t cmd_set_link_down_port =
7335 	TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
7336 cmdline_parse_token_num_t cmd_set_link_down_port_id =
7337 	TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16);
7338 
7339 static void cmd_set_link_down_parsed(
7340 				__attribute__((unused)) void *parsed_result,
7341 				__attribute__((unused)) struct cmdline *cl,
7342 				__attribute__((unused)) void *data)
7343 {
7344 	struct cmd_set_link_down_result *res = parsed_result;
7345 	dev_set_link_down(res->port_id);
7346 }
7347 
7348 cmdline_parse_inst_t cmd_set_link_down = {
7349 	.f = cmd_set_link_down_parsed,
7350 	.data = NULL,
7351 	.help_str = "set link-down port <port id>",
7352 	.tokens = {
7353 		(void *)&cmd_set_link_down_set,
7354 		(void *)&cmd_set_link_down_link_down,
7355 		(void *)&cmd_set_link_down_port,
7356 		(void *)&cmd_set_link_down_port_id,
7357 		NULL,
7358 	},
7359 };
7360 
7361 /* *** SHOW CFG *** */
7362 struct cmd_showcfg_result {
7363 	cmdline_fixed_string_t show;
7364 	cmdline_fixed_string_t cfg;
7365 	cmdline_fixed_string_t what;
7366 };
7367 
7368 static void cmd_showcfg_parsed(void *parsed_result,
7369 			       __attribute__((unused)) struct cmdline *cl,
7370 			       __attribute__((unused)) void *data)
7371 {
7372 	struct cmd_showcfg_result *res = parsed_result;
7373 	if (!strcmp(res->what, "rxtx"))
7374 		rxtx_config_display();
7375 	else if (!strcmp(res->what, "cores"))
7376 		fwd_lcores_config_display();
7377 	else if (!strcmp(res->what, "fwd"))
7378 		pkt_fwd_config_display(&cur_fwd_config);
7379 	else if (!strcmp(res->what, "txpkts"))
7380 		show_tx_pkt_segments();
7381 }
7382 
7383 cmdline_parse_token_string_t cmd_showcfg_show =
7384 	TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7385 cmdline_parse_token_string_t cmd_showcfg_port =
7386 	TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7387 cmdline_parse_token_string_t cmd_showcfg_what =
7388 	TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7389 				 "rxtx#cores#fwd#txpkts");
7390 
7391 cmdline_parse_inst_t cmd_showcfg = {
7392 	.f = cmd_showcfg_parsed,
7393 	.data = NULL,
7394 	.help_str = "show config rxtx|cores|fwd|txpkts",
7395 	.tokens = {
7396 		(void *)&cmd_showcfg_show,
7397 		(void *)&cmd_showcfg_port,
7398 		(void *)&cmd_showcfg_what,
7399 		NULL,
7400 	},
7401 };
7402 
7403 /* *** SHOW ALL PORT INFO *** */
7404 struct cmd_showportall_result {
7405 	cmdline_fixed_string_t show;
7406 	cmdline_fixed_string_t port;
7407 	cmdline_fixed_string_t what;
7408 	cmdline_fixed_string_t all;
7409 };
7410 
7411 static void cmd_showportall_parsed(void *parsed_result,
7412 				__attribute__((unused)) struct cmdline *cl,
7413 				__attribute__((unused)) void *data)
7414 {
7415 	portid_t i;
7416 
7417 	struct cmd_showportall_result *res = parsed_result;
7418 	if (!strcmp(res->show, "clear")) {
7419 		if (!strcmp(res->what, "stats"))
7420 			RTE_ETH_FOREACH_DEV(i)
7421 				nic_stats_clear(i);
7422 		else if (!strcmp(res->what, "xstats"))
7423 			RTE_ETH_FOREACH_DEV(i)
7424 				nic_xstats_clear(i);
7425 	} else if (!strcmp(res->what, "info"))
7426 		RTE_ETH_FOREACH_DEV(i)
7427 			port_infos_display(i);
7428 	else if (!strcmp(res->what, "summary")) {
7429 		port_summary_header_display();
7430 		RTE_ETH_FOREACH_DEV(i)
7431 			port_summary_display(i);
7432 	}
7433 	else if (!strcmp(res->what, "stats"))
7434 		RTE_ETH_FOREACH_DEV(i)
7435 			nic_stats_display(i);
7436 	else if (!strcmp(res->what, "xstats"))
7437 		RTE_ETH_FOREACH_DEV(i)
7438 			nic_xstats_display(i);
7439 	else if (!strcmp(res->what, "fdir"))
7440 		RTE_ETH_FOREACH_DEV(i)
7441 			fdir_get_infos(i);
7442 	else if (!strcmp(res->what, "stat_qmap"))
7443 		RTE_ETH_FOREACH_DEV(i)
7444 			nic_stats_mapping_display(i);
7445 	else if (!strcmp(res->what, "dcb_tc"))
7446 		RTE_ETH_FOREACH_DEV(i)
7447 			port_dcb_info_display(i);
7448 	else if (!strcmp(res->what, "cap"))
7449 		RTE_ETH_FOREACH_DEV(i)
7450 			port_offload_cap_display(i);
7451 }
7452 
7453 cmdline_parse_token_string_t cmd_showportall_show =
7454 	TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7455 				 "show#clear");
7456 cmdline_parse_token_string_t cmd_showportall_port =
7457 	TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7458 cmdline_parse_token_string_t cmd_showportall_what =
7459 	TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7460 				 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7461 cmdline_parse_token_string_t cmd_showportall_all =
7462 	TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7463 cmdline_parse_inst_t cmd_showportall = {
7464 	.f = cmd_showportall_parsed,
7465 	.data = NULL,
7466 	.help_str = "show|clear port "
7467 		"info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
7468 	.tokens = {
7469 		(void *)&cmd_showportall_show,
7470 		(void *)&cmd_showportall_port,
7471 		(void *)&cmd_showportall_what,
7472 		(void *)&cmd_showportall_all,
7473 		NULL,
7474 	},
7475 };
7476 
7477 /* *** SHOW PORT INFO *** */
7478 struct cmd_showport_result {
7479 	cmdline_fixed_string_t show;
7480 	cmdline_fixed_string_t port;
7481 	cmdline_fixed_string_t what;
7482 	uint16_t portnum;
7483 };
7484 
7485 static void cmd_showport_parsed(void *parsed_result,
7486 				__attribute__((unused)) struct cmdline *cl,
7487 				__attribute__((unused)) void *data)
7488 {
7489 	struct cmd_showport_result *res = parsed_result;
7490 	if (!strcmp(res->show, "clear")) {
7491 		if (!strcmp(res->what, "stats"))
7492 			nic_stats_clear(res->portnum);
7493 		else if (!strcmp(res->what, "xstats"))
7494 			nic_xstats_clear(res->portnum);
7495 	} else if (!strcmp(res->what, "info"))
7496 		port_infos_display(res->portnum);
7497 	else if (!strcmp(res->what, "summary")) {
7498 		port_summary_header_display();
7499 		port_summary_display(res->portnum);
7500 	}
7501 	else if (!strcmp(res->what, "stats"))
7502 		nic_stats_display(res->portnum);
7503 	else if (!strcmp(res->what, "xstats"))
7504 		nic_xstats_display(res->portnum);
7505 	else if (!strcmp(res->what, "fdir"))
7506 		 fdir_get_infos(res->portnum);
7507 	else if (!strcmp(res->what, "stat_qmap"))
7508 		nic_stats_mapping_display(res->portnum);
7509 	else if (!strcmp(res->what, "dcb_tc"))
7510 		port_dcb_info_display(res->portnum);
7511 	else if (!strcmp(res->what, "cap"))
7512 		port_offload_cap_display(res->portnum);
7513 }
7514 
7515 cmdline_parse_token_string_t cmd_showport_show =
7516 	TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7517 				 "show#clear");
7518 cmdline_parse_token_string_t cmd_showport_port =
7519 	TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7520 cmdline_parse_token_string_t cmd_showport_what =
7521 	TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7522 				 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7523 cmdline_parse_token_num_t cmd_showport_portnum =
7524 	TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
7525 
7526 cmdline_parse_inst_t cmd_showport = {
7527 	.f = cmd_showport_parsed,
7528 	.data = NULL,
7529 	.help_str = "show|clear port "
7530 		"info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
7531 		"<port_id>",
7532 	.tokens = {
7533 		(void *)&cmd_showport_show,
7534 		(void *)&cmd_showport_port,
7535 		(void *)&cmd_showport_what,
7536 		(void *)&cmd_showport_portnum,
7537 		NULL,
7538 	},
7539 };
7540 
7541 /* *** SHOW DEVICE INFO *** */
7542 struct cmd_showdevice_result {
7543 	cmdline_fixed_string_t show;
7544 	cmdline_fixed_string_t device;
7545 	cmdline_fixed_string_t what;
7546 	cmdline_fixed_string_t identifier;
7547 };
7548 
7549 static void cmd_showdevice_parsed(void *parsed_result,
7550 				__attribute__((unused)) struct cmdline *cl,
7551 				__attribute__((unused)) void *data)
7552 {
7553 	struct cmd_showdevice_result *res = parsed_result;
7554 	if (!strcmp(res->what, "info")) {
7555 		if (!strcmp(res->identifier, "all"))
7556 			device_infos_display(NULL);
7557 		else
7558 			device_infos_display(res->identifier);
7559 	}
7560 }
7561 
7562 cmdline_parse_token_string_t cmd_showdevice_show =
7563 	TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show,
7564 				 "show");
7565 cmdline_parse_token_string_t cmd_showdevice_device =
7566 	TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device");
7567 cmdline_parse_token_string_t cmd_showdevice_what =
7568 	TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what,
7569 				 "info");
7570 cmdline_parse_token_string_t cmd_showdevice_identifier =
7571 	TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result,
7572 			identifier, NULL);
7573 
7574 cmdline_parse_inst_t cmd_showdevice = {
7575 	.f = cmd_showdevice_parsed,
7576 	.data = NULL,
7577 	.help_str = "show device info <identifier>|all",
7578 	.tokens = {
7579 		(void *)&cmd_showdevice_show,
7580 		(void *)&cmd_showdevice_device,
7581 		(void *)&cmd_showdevice_what,
7582 		(void *)&cmd_showdevice_identifier,
7583 		NULL,
7584 	},
7585 };
7586 /* *** SHOW QUEUE INFO *** */
7587 struct cmd_showqueue_result {
7588 	cmdline_fixed_string_t show;
7589 	cmdline_fixed_string_t type;
7590 	cmdline_fixed_string_t what;
7591 	uint16_t portnum;
7592 	uint16_t queuenum;
7593 };
7594 
7595 static void
7596 cmd_showqueue_parsed(void *parsed_result,
7597 	__attribute__((unused)) struct cmdline *cl,
7598 	__attribute__((unused)) void *data)
7599 {
7600 	struct cmd_showqueue_result *res = parsed_result;
7601 
7602 	if (!strcmp(res->type, "rxq"))
7603 		rx_queue_infos_display(res->portnum, res->queuenum);
7604 	else if (!strcmp(res->type, "txq"))
7605 		tx_queue_infos_display(res->portnum, res->queuenum);
7606 }
7607 
7608 cmdline_parse_token_string_t cmd_showqueue_show =
7609 	TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
7610 cmdline_parse_token_string_t cmd_showqueue_type =
7611 	TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
7612 cmdline_parse_token_string_t cmd_showqueue_what =
7613 	TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
7614 cmdline_parse_token_num_t cmd_showqueue_portnum =
7615 	TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16);
7616 cmdline_parse_token_num_t cmd_showqueue_queuenum =
7617 	TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
7618 
7619 cmdline_parse_inst_t cmd_showqueue = {
7620 	.f = cmd_showqueue_parsed,
7621 	.data = NULL,
7622 	.help_str = "show rxq|txq info <port_id> <queue_id>",
7623 	.tokens = {
7624 		(void *)&cmd_showqueue_show,
7625 		(void *)&cmd_showqueue_type,
7626 		(void *)&cmd_showqueue_what,
7627 		(void *)&cmd_showqueue_portnum,
7628 		(void *)&cmd_showqueue_queuenum,
7629 		NULL,
7630 	},
7631 };
7632 
7633 /* show/clear fwd engine statistics */
7634 struct fwd_result {
7635 	cmdline_fixed_string_t action;
7636 	cmdline_fixed_string_t fwd;
7637 	cmdline_fixed_string_t stats;
7638 	cmdline_fixed_string_t all;
7639 };
7640 
7641 cmdline_parse_token_string_t cmd_fwd_action =
7642 	TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
7643 cmdline_parse_token_string_t cmd_fwd_fwd =
7644 	TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
7645 cmdline_parse_token_string_t cmd_fwd_stats =
7646 	TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
7647 cmdline_parse_token_string_t cmd_fwd_all =
7648 	TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
7649 
7650 static void
7651 cmd_showfwdall_parsed(void *parsed_result,
7652 		      __rte_unused struct cmdline *cl,
7653 		      __rte_unused void *data)
7654 {
7655 	struct fwd_result *res = parsed_result;
7656 
7657 	if (!strcmp(res->action, "show"))
7658 		fwd_stats_display();
7659 	else
7660 		fwd_stats_reset();
7661 }
7662 
7663 static cmdline_parse_inst_t cmd_showfwdall = {
7664 	.f = cmd_showfwdall_parsed,
7665 	.data = NULL,
7666 	.help_str = "show|clear fwd stats all",
7667 	.tokens = {
7668 		(void *)&cmd_fwd_action,
7669 		(void *)&cmd_fwd_fwd,
7670 		(void *)&cmd_fwd_stats,
7671 		(void *)&cmd_fwd_all,
7672 		NULL,
7673 	},
7674 };
7675 
7676 /* *** READ PORT REGISTER *** */
7677 struct cmd_read_reg_result {
7678 	cmdline_fixed_string_t read;
7679 	cmdline_fixed_string_t reg;
7680 	portid_t port_id;
7681 	uint32_t reg_off;
7682 };
7683 
7684 static void
7685 cmd_read_reg_parsed(void *parsed_result,
7686 		    __attribute__((unused)) struct cmdline *cl,
7687 		    __attribute__((unused)) void *data)
7688 {
7689 	struct cmd_read_reg_result *res = parsed_result;
7690 	port_reg_display(res->port_id, res->reg_off);
7691 }
7692 
7693 cmdline_parse_token_string_t cmd_read_reg_read =
7694 	TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
7695 cmdline_parse_token_string_t cmd_read_reg_reg =
7696 	TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
7697 cmdline_parse_token_num_t cmd_read_reg_port_id =
7698 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16);
7699 cmdline_parse_token_num_t cmd_read_reg_reg_off =
7700 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
7701 
7702 cmdline_parse_inst_t cmd_read_reg = {
7703 	.f = cmd_read_reg_parsed,
7704 	.data = NULL,
7705 	.help_str = "read reg <port_id> <reg_off>",
7706 	.tokens = {
7707 		(void *)&cmd_read_reg_read,
7708 		(void *)&cmd_read_reg_reg,
7709 		(void *)&cmd_read_reg_port_id,
7710 		(void *)&cmd_read_reg_reg_off,
7711 		NULL,
7712 	},
7713 };
7714 
7715 /* *** READ PORT REGISTER BIT FIELD *** */
7716 struct cmd_read_reg_bit_field_result {
7717 	cmdline_fixed_string_t read;
7718 	cmdline_fixed_string_t regfield;
7719 	portid_t port_id;
7720 	uint32_t reg_off;
7721 	uint8_t bit1_pos;
7722 	uint8_t bit2_pos;
7723 };
7724 
7725 static void
7726 cmd_read_reg_bit_field_parsed(void *parsed_result,
7727 			      __attribute__((unused)) struct cmdline *cl,
7728 			      __attribute__((unused)) void *data)
7729 {
7730 	struct cmd_read_reg_bit_field_result *res = parsed_result;
7731 	port_reg_bit_field_display(res->port_id, res->reg_off,
7732 				   res->bit1_pos, res->bit2_pos);
7733 }
7734 
7735 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
7736 	TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
7737 				 "read");
7738 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
7739 	TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
7740 				 regfield, "regfield");
7741 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
7742 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
7743 			      UINT16);
7744 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
7745 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
7746 			      UINT32);
7747 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
7748 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
7749 			      UINT8);
7750 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
7751 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
7752 			      UINT8);
7753 
7754 cmdline_parse_inst_t cmd_read_reg_bit_field = {
7755 	.f = cmd_read_reg_bit_field_parsed,
7756 	.data = NULL,
7757 	.help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
7758 	"Read register bit field between bit_x and bit_y included",
7759 	.tokens = {
7760 		(void *)&cmd_read_reg_bit_field_read,
7761 		(void *)&cmd_read_reg_bit_field_regfield,
7762 		(void *)&cmd_read_reg_bit_field_port_id,
7763 		(void *)&cmd_read_reg_bit_field_reg_off,
7764 		(void *)&cmd_read_reg_bit_field_bit1_pos,
7765 		(void *)&cmd_read_reg_bit_field_bit2_pos,
7766 		NULL,
7767 	},
7768 };
7769 
7770 /* *** READ PORT REGISTER BIT *** */
7771 struct cmd_read_reg_bit_result {
7772 	cmdline_fixed_string_t read;
7773 	cmdline_fixed_string_t regbit;
7774 	portid_t port_id;
7775 	uint32_t reg_off;
7776 	uint8_t bit_pos;
7777 };
7778 
7779 static void
7780 cmd_read_reg_bit_parsed(void *parsed_result,
7781 			__attribute__((unused)) struct cmdline *cl,
7782 			__attribute__((unused)) void *data)
7783 {
7784 	struct cmd_read_reg_bit_result *res = parsed_result;
7785 	port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
7786 }
7787 
7788 cmdline_parse_token_string_t cmd_read_reg_bit_read =
7789 	TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
7790 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
7791 	TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
7792 				 regbit, "regbit");
7793 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
7794 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16);
7795 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
7796 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
7797 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
7798 	TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
7799 
7800 cmdline_parse_inst_t cmd_read_reg_bit = {
7801 	.f = cmd_read_reg_bit_parsed,
7802 	.data = NULL,
7803 	.help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
7804 	.tokens = {
7805 		(void *)&cmd_read_reg_bit_read,
7806 		(void *)&cmd_read_reg_bit_regbit,
7807 		(void *)&cmd_read_reg_bit_port_id,
7808 		(void *)&cmd_read_reg_bit_reg_off,
7809 		(void *)&cmd_read_reg_bit_bit_pos,
7810 		NULL,
7811 	},
7812 };
7813 
7814 /* *** WRITE PORT REGISTER *** */
7815 struct cmd_write_reg_result {
7816 	cmdline_fixed_string_t write;
7817 	cmdline_fixed_string_t reg;
7818 	portid_t port_id;
7819 	uint32_t reg_off;
7820 	uint32_t value;
7821 };
7822 
7823 static void
7824 cmd_write_reg_parsed(void *parsed_result,
7825 		     __attribute__((unused)) struct cmdline *cl,
7826 		     __attribute__((unused)) void *data)
7827 {
7828 	struct cmd_write_reg_result *res = parsed_result;
7829 	port_reg_set(res->port_id, res->reg_off, res->value);
7830 }
7831 
7832 cmdline_parse_token_string_t cmd_write_reg_write =
7833 	TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
7834 cmdline_parse_token_string_t cmd_write_reg_reg =
7835 	TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
7836 cmdline_parse_token_num_t cmd_write_reg_port_id =
7837 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16);
7838 cmdline_parse_token_num_t cmd_write_reg_reg_off =
7839 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
7840 cmdline_parse_token_num_t cmd_write_reg_value =
7841 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
7842 
7843 cmdline_parse_inst_t cmd_write_reg = {
7844 	.f = cmd_write_reg_parsed,
7845 	.data = NULL,
7846 	.help_str = "write reg <port_id> <reg_off> <reg_value>",
7847 	.tokens = {
7848 		(void *)&cmd_write_reg_write,
7849 		(void *)&cmd_write_reg_reg,
7850 		(void *)&cmd_write_reg_port_id,
7851 		(void *)&cmd_write_reg_reg_off,
7852 		(void *)&cmd_write_reg_value,
7853 		NULL,
7854 	},
7855 };
7856 
7857 /* *** WRITE PORT REGISTER BIT FIELD *** */
7858 struct cmd_write_reg_bit_field_result {
7859 	cmdline_fixed_string_t write;
7860 	cmdline_fixed_string_t regfield;
7861 	portid_t port_id;
7862 	uint32_t reg_off;
7863 	uint8_t bit1_pos;
7864 	uint8_t bit2_pos;
7865 	uint32_t value;
7866 };
7867 
7868 static void
7869 cmd_write_reg_bit_field_parsed(void *parsed_result,
7870 			       __attribute__((unused)) struct cmdline *cl,
7871 			       __attribute__((unused)) void *data)
7872 {
7873 	struct cmd_write_reg_bit_field_result *res = parsed_result;
7874 	port_reg_bit_field_set(res->port_id, res->reg_off,
7875 			  res->bit1_pos, res->bit2_pos, res->value);
7876 }
7877 
7878 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
7879 	TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
7880 				 "write");
7881 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
7882 	TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
7883 				 regfield, "regfield");
7884 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
7885 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
7886 			      UINT16);
7887 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
7888 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
7889 			      UINT32);
7890 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
7891 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
7892 			      UINT8);
7893 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
7894 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
7895 			      UINT8);
7896 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
7897 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
7898 			      UINT32);
7899 
7900 cmdline_parse_inst_t cmd_write_reg_bit_field = {
7901 	.f = cmd_write_reg_bit_field_parsed,
7902 	.data = NULL,
7903 	.help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
7904 		"<reg_value>: "
7905 		"Set register bit field between bit_x and bit_y included",
7906 	.tokens = {
7907 		(void *)&cmd_write_reg_bit_field_write,
7908 		(void *)&cmd_write_reg_bit_field_regfield,
7909 		(void *)&cmd_write_reg_bit_field_port_id,
7910 		(void *)&cmd_write_reg_bit_field_reg_off,
7911 		(void *)&cmd_write_reg_bit_field_bit1_pos,
7912 		(void *)&cmd_write_reg_bit_field_bit2_pos,
7913 		(void *)&cmd_write_reg_bit_field_value,
7914 		NULL,
7915 	},
7916 };
7917 
7918 /* *** WRITE PORT REGISTER BIT *** */
7919 struct cmd_write_reg_bit_result {
7920 	cmdline_fixed_string_t write;
7921 	cmdline_fixed_string_t regbit;
7922 	portid_t port_id;
7923 	uint32_t reg_off;
7924 	uint8_t bit_pos;
7925 	uint8_t value;
7926 };
7927 
7928 static void
7929 cmd_write_reg_bit_parsed(void *parsed_result,
7930 			 __attribute__((unused)) struct cmdline *cl,
7931 			 __attribute__((unused)) void *data)
7932 {
7933 	struct cmd_write_reg_bit_result *res = parsed_result;
7934 	port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
7935 }
7936 
7937 cmdline_parse_token_string_t cmd_write_reg_bit_write =
7938 	TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
7939 				 "write");
7940 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
7941 	TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
7942 				 regbit, "regbit");
7943 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
7944 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16);
7945 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
7946 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
7947 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
7948 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
7949 cmdline_parse_token_num_t cmd_write_reg_bit_value =
7950 	TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
7951 
7952 cmdline_parse_inst_t cmd_write_reg_bit = {
7953 	.f = cmd_write_reg_bit_parsed,
7954 	.data = NULL,
7955 	.help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
7956 		"0 <= bit_x <= 31",
7957 	.tokens = {
7958 		(void *)&cmd_write_reg_bit_write,
7959 		(void *)&cmd_write_reg_bit_regbit,
7960 		(void *)&cmd_write_reg_bit_port_id,
7961 		(void *)&cmd_write_reg_bit_reg_off,
7962 		(void *)&cmd_write_reg_bit_bit_pos,
7963 		(void *)&cmd_write_reg_bit_value,
7964 		NULL,
7965 	},
7966 };
7967 
7968 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
7969 struct cmd_read_rxd_txd_result {
7970 	cmdline_fixed_string_t read;
7971 	cmdline_fixed_string_t rxd_txd;
7972 	portid_t port_id;
7973 	uint16_t queue_id;
7974 	uint16_t desc_id;
7975 };
7976 
7977 static void
7978 cmd_read_rxd_txd_parsed(void *parsed_result,
7979 			__attribute__((unused)) struct cmdline *cl,
7980 			__attribute__((unused)) void *data)
7981 {
7982 	struct cmd_read_rxd_txd_result *res = parsed_result;
7983 
7984 	if (!strcmp(res->rxd_txd, "rxd"))
7985 		rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7986 	else if (!strcmp(res->rxd_txd, "txd"))
7987 		tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7988 }
7989 
7990 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
7991 	TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
7992 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
7993 	TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
7994 				 "rxd#txd");
7995 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
7996 	TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16);
7997 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
7998 	TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
7999 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
8000 	TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
8001 
8002 cmdline_parse_inst_t cmd_read_rxd_txd = {
8003 	.f = cmd_read_rxd_txd_parsed,
8004 	.data = NULL,
8005 	.help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
8006 	.tokens = {
8007 		(void *)&cmd_read_rxd_txd_read,
8008 		(void *)&cmd_read_rxd_txd_rxd_txd,
8009 		(void *)&cmd_read_rxd_txd_port_id,
8010 		(void *)&cmd_read_rxd_txd_queue_id,
8011 		(void *)&cmd_read_rxd_txd_desc_id,
8012 		NULL,
8013 	},
8014 };
8015 
8016 /* *** QUIT *** */
8017 struct cmd_quit_result {
8018 	cmdline_fixed_string_t quit;
8019 };
8020 
8021 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
8022 			    struct cmdline *cl,
8023 			    __attribute__((unused)) void *data)
8024 {
8025 	cmdline_quit(cl);
8026 }
8027 
8028 cmdline_parse_token_string_t cmd_quit_quit =
8029 	TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
8030 
8031 cmdline_parse_inst_t cmd_quit = {
8032 	.f = cmd_quit_parsed,
8033 	.data = NULL,
8034 	.help_str = "quit: Exit application",
8035 	.tokens = {
8036 		(void *)&cmd_quit_quit,
8037 		NULL,
8038 	},
8039 };
8040 
8041 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
8042 struct cmd_mac_addr_result {
8043 	cmdline_fixed_string_t mac_addr_cmd;
8044 	cmdline_fixed_string_t what;
8045 	uint16_t port_num;
8046 	struct rte_ether_addr address;
8047 };
8048 
8049 static void cmd_mac_addr_parsed(void *parsed_result,
8050 		__attribute__((unused)) struct cmdline *cl,
8051 		__attribute__((unused)) void *data)
8052 {
8053 	struct cmd_mac_addr_result *res = parsed_result;
8054 	int ret;
8055 
8056 	if (strcmp(res->what, "add") == 0)
8057 		ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
8058 	else if (strcmp(res->what, "set") == 0)
8059 		ret = rte_eth_dev_default_mac_addr_set(res->port_num,
8060 						       &res->address);
8061 	else
8062 		ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
8063 
8064 	/* check the return value and print it if is < 0 */
8065 	if(ret < 0)
8066 		printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
8067 
8068 }
8069 
8070 cmdline_parse_token_string_t cmd_mac_addr_cmd =
8071 	TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
8072 				"mac_addr");
8073 cmdline_parse_token_string_t cmd_mac_addr_what =
8074 	TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
8075 				"add#remove#set");
8076 cmdline_parse_token_num_t cmd_mac_addr_portnum =
8077 		TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
8078 					UINT16);
8079 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
8080 		TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
8081 
8082 cmdline_parse_inst_t cmd_mac_addr = {
8083 	.f = cmd_mac_addr_parsed,
8084 	.data = (void *)0,
8085 	.help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
8086 			"Add/Remove/Set MAC address on port_id",
8087 	.tokens = {
8088 		(void *)&cmd_mac_addr_cmd,
8089 		(void *)&cmd_mac_addr_what,
8090 		(void *)&cmd_mac_addr_portnum,
8091 		(void *)&cmd_mac_addr_addr,
8092 		NULL,
8093 	},
8094 };
8095 
8096 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
8097 struct cmd_eth_peer_result {
8098 	cmdline_fixed_string_t set;
8099 	cmdline_fixed_string_t eth_peer;
8100 	portid_t port_id;
8101 	cmdline_fixed_string_t peer_addr;
8102 };
8103 
8104 static void cmd_set_eth_peer_parsed(void *parsed_result,
8105 			__attribute__((unused)) struct cmdline *cl,
8106 			__attribute__((unused)) void *data)
8107 {
8108 		struct cmd_eth_peer_result *res = parsed_result;
8109 
8110 		if (test_done == 0) {
8111 			printf("Please stop forwarding first\n");
8112 			return;
8113 		}
8114 		if (!strcmp(res->eth_peer, "eth-peer")) {
8115 			set_fwd_eth_peer(res->port_id, res->peer_addr);
8116 			fwd_config_setup();
8117 		}
8118 }
8119 cmdline_parse_token_string_t cmd_eth_peer_set =
8120 	TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
8121 cmdline_parse_token_string_t cmd_eth_peer =
8122 	TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
8123 cmdline_parse_token_num_t cmd_eth_peer_port_id =
8124 	TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, UINT16);
8125 cmdline_parse_token_string_t cmd_eth_peer_addr =
8126 	TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
8127 
8128 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
8129 	.f = cmd_set_eth_peer_parsed,
8130 	.data = NULL,
8131 	.help_str = "set eth-peer <port_id> <peer_mac>",
8132 	.tokens = {
8133 		(void *)&cmd_eth_peer_set,
8134 		(void *)&cmd_eth_peer,
8135 		(void *)&cmd_eth_peer_port_id,
8136 		(void *)&cmd_eth_peer_addr,
8137 		NULL,
8138 	},
8139 };
8140 
8141 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
8142 struct cmd_set_qmap_result {
8143 	cmdline_fixed_string_t set;
8144 	cmdline_fixed_string_t qmap;
8145 	cmdline_fixed_string_t what;
8146 	portid_t port_id;
8147 	uint16_t queue_id;
8148 	uint8_t map_value;
8149 };
8150 
8151 static void
8152 cmd_set_qmap_parsed(void *parsed_result,
8153 		       __attribute__((unused)) struct cmdline *cl,
8154 		       __attribute__((unused)) void *data)
8155 {
8156 	struct cmd_set_qmap_result *res = parsed_result;
8157 	int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
8158 
8159 	set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
8160 }
8161 
8162 cmdline_parse_token_string_t cmd_setqmap_set =
8163 	TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8164 				 set, "set");
8165 cmdline_parse_token_string_t cmd_setqmap_qmap =
8166 	TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8167 				 qmap, "stat_qmap");
8168 cmdline_parse_token_string_t cmd_setqmap_what =
8169 	TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8170 				 what, "tx#rx");
8171 cmdline_parse_token_num_t cmd_setqmap_portid =
8172 	TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8173 			      port_id, UINT16);
8174 cmdline_parse_token_num_t cmd_setqmap_queueid =
8175 	TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8176 			      queue_id, UINT16);
8177 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
8178 	TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8179 			      map_value, UINT8);
8180 
8181 cmdline_parse_inst_t cmd_set_qmap = {
8182 	.f = cmd_set_qmap_parsed,
8183 	.data = NULL,
8184 	.help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
8185 		"Set statistics mapping value on tx|rx queue_id of port_id",
8186 	.tokens = {
8187 		(void *)&cmd_setqmap_set,
8188 		(void *)&cmd_setqmap_qmap,
8189 		(void *)&cmd_setqmap_what,
8190 		(void *)&cmd_setqmap_portid,
8191 		(void *)&cmd_setqmap_queueid,
8192 		(void *)&cmd_setqmap_mapvalue,
8193 		NULL,
8194 	},
8195 };
8196 
8197 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS  DISPLAY *** */
8198 struct cmd_set_xstats_hide_zero_result {
8199 	cmdline_fixed_string_t keyword;
8200 	cmdline_fixed_string_t name;
8201 	cmdline_fixed_string_t on_off;
8202 };
8203 
8204 static void
8205 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
8206 			__attribute__((unused)) struct cmdline *cl,
8207 			__attribute__((unused)) void *data)
8208 {
8209 	struct cmd_set_xstats_hide_zero_result *res;
8210 	uint16_t on_off = 0;
8211 
8212 	res = parsed_result;
8213 	on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8214 	set_xstats_hide_zero(on_off);
8215 }
8216 
8217 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
8218 	TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8219 				 keyword, "set");
8220 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
8221 	TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8222 				 name, "xstats-hide-zero");
8223 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
8224 	TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8225 				 on_off, "on#off");
8226 
8227 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
8228 	.f = cmd_set_xstats_hide_zero_parsed,
8229 	.data = NULL,
8230 	.help_str = "set xstats-hide-zero on|off",
8231 	.tokens = {
8232 		(void *)&cmd_set_xstats_hide_zero_keyword,
8233 		(void *)&cmd_set_xstats_hide_zero_name,
8234 		(void *)&cmd_set_xstats_hide_zero_on_off,
8235 		NULL,
8236 	},
8237 };
8238 
8239 /* *** CONFIGURE UNICAST HASH TABLE *** */
8240 struct cmd_set_uc_hash_table {
8241 	cmdline_fixed_string_t set;
8242 	cmdline_fixed_string_t port;
8243 	portid_t port_id;
8244 	cmdline_fixed_string_t what;
8245 	struct rte_ether_addr address;
8246 	cmdline_fixed_string_t mode;
8247 };
8248 
8249 static void
8250 cmd_set_uc_hash_parsed(void *parsed_result,
8251 		       __attribute__((unused)) struct cmdline *cl,
8252 		       __attribute__((unused)) void *data)
8253 {
8254 	int ret=0;
8255 	struct cmd_set_uc_hash_table *res = parsed_result;
8256 
8257 	int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8258 
8259 	if (strcmp(res->what, "uta") == 0)
8260 		ret = rte_eth_dev_uc_hash_table_set(res->port_id,
8261 						&res->address,(uint8_t)is_on);
8262 	if (ret < 0)
8263 		printf("bad unicast hash table parameter, return code = %d \n", ret);
8264 
8265 }
8266 
8267 cmdline_parse_token_string_t cmd_set_uc_hash_set =
8268 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8269 				 set, "set");
8270 cmdline_parse_token_string_t cmd_set_uc_hash_port =
8271 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8272 				 port, "port");
8273 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
8274 	TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
8275 			      port_id, UINT16);
8276 cmdline_parse_token_string_t cmd_set_uc_hash_what =
8277 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8278 				 what, "uta");
8279 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
8280 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
8281 				address);
8282 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
8283 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8284 				 mode, "on#off");
8285 
8286 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
8287 	.f = cmd_set_uc_hash_parsed,
8288 	.data = NULL,
8289 	.help_str = "set port <port_id> uta <mac_addr> on|off)",
8290 	.tokens = {
8291 		(void *)&cmd_set_uc_hash_set,
8292 		(void *)&cmd_set_uc_hash_port,
8293 		(void *)&cmd_set_uc_hash_portid,
8294 		(void *)&cmd_set_uc_hash_what,
8295 		(void *)&cmd_set_uc_hash_mac,
8296 		(void *)&cmd_set_uc_hash_mode,
8297 		NULL,
8298 	},
8299 };
8300 
8301 struct cmd_set_uc_all_hash_table {
8302 	cmdline_fixed_string_t set;
8303 	cmdline_fixed_string_t port;
8304 	portid_t port_id;
8305 	cmdline_fixed_string_t what;
8306 	cmdline_fixed_string_t value;
8307 	cmdline_fixed_string_t mode;
8308 };
8309 
8310 static void
8311 cmd_set_uc_all_hash_parsed(void *parsed_result,
8312 		       __attribute__((unused)) struct cmdline *cl,
8313 		       __attribute__((unused)) void *data)
8314 {
8315 	int ret=0;
8316 	struct cmd_set_uc_all_hash_table *res = parsed_result;
8317 
8318 	int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8319 
8320 	if ((strcmp(res->what, "uta") == 0) &&
8321 		(strcmp(res->value, "all") == 0))
8322 		ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
8323 	if (ret < 0)
8324 		printf("bad unicast hash table parameter,"
8325 			"return code = %d \n", ret);
8326 }
8327 
8328 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
8329 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8330 				 set, "set");
8331 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
8332 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8333 				 port, "port");
8334 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
8335 	TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
8336 			      port_id, UINT16);
8337 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
8338 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8339 				 what, "uta");
8340 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
8341 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8342 				value,"all");
8343 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
8344 	TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8345 				 mode, "on#off");
8346 
8347 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
8348 	.f = cmd_set_uc_all_hash_parsed,
8349 	.data = NULL,
8350 	.help_str = "set port <port_id> uta all on|off",
8351 	.tokens = {
8352 		(void *)&cmd_set_uc_all_hash_set,
8353 		(void *)&cmd_set_uc_all_hash_port,
8354 		(void *)&cmd_set_uc_all_hash_portid,
8355 		(void *)&cmd_set_uc_all_hash_what,
8356 		(void *)&cmd_set_uc_all_hash_value,
8357 		(void *)&cmd_set_uc_all_hash_mode,
8358 		NULL,
8359 	},
8360 };
8361 
8362 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
8363 struct cmd_set_vf_macvlan_filter {
8364 	cmdline_fixed_string_t set;
8365 	cmdline_fixed_string_t port;
8366 	portid_t port_id;
8367 	cmdline_fixed_string_t vf;
8368 	uint8_t vf_id;
8369 	struct rte_ether_addr address;
8370 	cmdline_fixed_string_t filter_type;
8371 	cmdline_fixed_string_t mode;
8372 };
8373 
8374 static void
8375 cmd_set_vf_macvlan_parsed(void *parsed_result,
8376 		       __attribute__((unused)) struct cmdline *cl,
8377 		       __attribute__((unused)) void *data)
8378 {
8379 	int is_on, ret = 0;
8380 	struct cmd_set_vf_macvlan_filter *res = parsed_result;
8381 	struct rte_eth_mac_filter filter;
8382 
8383 	memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
8384 
8385 	rte_memcpy(&filter.mac_addr, &res->address, RTE_ETHER_ADDR_LEN);
8386 
8387 	/* set VF MAC filter */
8388 	filter.is_vf = 1;
8389 
8390 	/* set VF ID */
8391 	filter.dst_id = res->vf_id;
8392 
8393 	if (!strcmp(res->filter_type, "exact-mac"))
8394 		filter.filter_type = RTE_MAC_PERFECT_MATCH;
8395 	else if (!strcmp(res->filter_type, "exact-mac-vlan"))
8396 		filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
8397 	else if (!strcmp(res->filter_type, "hashmac"))
8398 		filter.filter_type = RTE_MAC_HASH_MATCH;
8399 	else if (!strcmp(res->filter_type, "hashmac-vlan"))
8400 		filter.filter_type = RTE_MACVLAN_HASH_MATCH;
8401 
8402 	is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8403 
8404 	if (is_on)
8405 		ret = rte_eth_dev_filter_ctrl(res->port_id,
8406 					RTE_ETH_FILTER_MACVLAN,
8407 					RTE_ETH_FILTER_ADD,
8408 					 &filter);
8409 	else
8410 		ret = rte_eth_dev_filter_ctrl(res->port_id,
8411 					RTE_ETH_FILTER_MACVLAN,
8412 					RTE_ETH_FILTER_DELETE,
8413 					&filter);
8414 
8415 	if (ret < 0)
8416 		printf("bad set MAC hash parameter, return code = %d\n", ret);
8417 
8418 }
8419 
8420 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
8421 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8422 				 set, "set");
8423 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
8424 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8425 				 port, "port");
8426 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
8427 	TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8428 			      port_id, UINT16);
8429 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
8430 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8431 				 vf, "vf");
8432 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
8433 	TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8434 				vf_id, UINT8);
8435 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
8436 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8437 				address);
8438 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
8439 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8440 				filter_type, "exact-mac#exact-mac-vlan"
8441 				"#hashmac#hashmac-vlan");
8442 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
8443 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8444 				 mode, "on#off");
8445 
8446 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
8447 	.f = cmd_set_vf_macvlan_parsed,
8448 	.data = NULL,
8449 	.help_str = "set port <port_id> vf <vf_id> <mac_addr> "
8450 		"exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
8451 		"Exact match rule: exact match of MAC or MAC and VLAN; "
8452 		"hash match rule: hash match of MAC and exact match of VLAN",
8453 	.tokens = {
8454 		(void *)&cmd_set_vf_macvlan_set,
8455 		(void *)&cmd_set_vf_macvlan_port,
8456 		(void *)&cmd_set_vf_macvlan_portid,
8457 		(void *)&cmd_set_vf_macvlan_vf,
8458 		(void *)&cmd_set_vf_macvlan_vf_id,
8459 		(void *)&cmd_set_vf_macvlan_mac,
8460 		(void *)&cmd_set_vf_macvlan_filter_type,
8461 		(void *)&cmd_set_vf_macvlan_mode,
8462 		NULL,
8463 	},
8464 };
8465 
8466 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
8467 struct cmd_set_vf_traffic {
8468 	cmdline_fixed_string_t set;
8469 	cmdline_fixed_string_t port;
8470 	portid_t port_id;
8471 	cmdline_fixed_string_t vf;
8472 	uint8_t vf_id;
8473 	cmdline_fixed_string_t what;
8474 	cmdline_fixed_string_t mode;
8475 };
8476 
8477 static void
8478 cmd_set_vf_traffic_parsed(void *parsed_result,
8479 		       __attribute__((unused)) struct cmdline *cl,
8480 		       __attribute__((unused)) void *data)
8481 {
8482 	struct cmd_set_vf_traffic *res = parsed_result;
8483 	int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
8484 	int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8485 
8486 	set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
8487 }
8488 
8489 cmdline_parse_token_string_t cmd_setvf_traffic_set =
8490 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8491 				 set, "set");
8492 cmdline_parse_token_string_t cmd_setvf_traffic_port =
8493 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8494 				 port, "port");
8495 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8496 	TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8497 			      port_id, UINT16);
8498 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8499 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8500 				 vf, "vf");
8501 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8502 	TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8503 			      vf_id, UINT8);
8504 cmdline_parse_token_string_t cmd_setvf_traffic_what =
8505 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8506 				 what, "tx#rx");
8507 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8508 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8509 				 mode, "on#off");
8510 
8511 cmdline_parse_inst_t cmd_set_vf_traffic = {
8512 	.f = cmd_set_vf_traffic_parsed,
8513 	.data = NULL,
8514 	.help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8515 	.tokens = {
8516 		(void *)&cmd_setvf_traffic_set,
8517 		(void *)&cmd_setvf_traffic_port,
8518 		(void *)&cmd_setvf_traffic_portid,
8519 		(void *)&cmd_setvf_traffic_vf,
8520 		(void *)&cmd_setvf_traffic_vfid,
8521 		(void *)&cmd_setvf_traffic_what,
8522 		(void *)&cmd_setvf_traffic_mode,
8523 		NULL,
8524 	},
8525 };
8526 
8527 /* *** CONFIGURE VF RECEIVE MODE *** */
8528 struct cmd_set_vf_rxmode {
8529 	cmdline_fixed_string_t set;
8530 	cmdline_fixed_string_t port;
8531 	portid_t port_id;
8532 	cmdline_fixed_string_t vf;
8533 	uint8_t vf_id;
8534 	cmdline_fixed_string_t what;
8535 	cmdline_fixed_string_t mode;
8536 	cmdline_fixed_string_t on;
8537 };
8538 
8539 static void
8540 cmd_set_vf_rxmode_parsed(void *parsed_result,
8541 		       __attribute__((unused)) struct cmdline *cl,
8542 		       __attribute__((unused)) void *data)
8543 {
8544 	int ret = -ENOTSUP;
8545 	uint16_t vf_rxmode = 0;
8546 	struct cmd_set_vf_rxmode *res = parsed_result;
8547 
8548 	int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8549 	if (!strcmp(res->what,"rxmode")) {
8550 		if (!strcmp(res->mode, "AUPE"))
8551 			vf_rxmode |= ETH_VMDQ_ACCEPT_UNTAG;
8552 		else if (!strcmp(res->mode, "ROPE"))
8553 			vf_rxmode |= ETH_VMDQ_ACCEPT_HASH_UC;
8554 		else if (!strcmp(res->mode, "BAM"))
8555 			vf_rxmode |= ETH_VMDQ_ACCEPT_BROADCAST;
8556 		else if (!strncmp(res->mode, "MPE",3))
8557 			vf_rxmode |= ETH_VMDQ_ACCEPT_MULTICAST;
8558 	}
8559 
8560 	RTE_SET_USED(is_on);
8561 
8562 #ifdef RTE_LIBRTE_IXGBE_PMD
8563 	if (ret == -ENOTSUP)
8564 		ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8565 						  vf_rxmode, (uint8_t)is_on);
8566 #endif
8567 #ifdef RTE_LIBRTE_BNXT_PMD
8568 	if (ret == -ENOTSUP)
8569 		ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8570 						 vf_rxmode, (uint8_t)is_on);
8571 #endif
8572 	if (ret < 0)
8573 		printf("bad VF receive mode parameter, return code = %d \n",
8574 		ret);
8575 }
8576 
8577 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8578 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8579 				 set, "set");
8580 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8581 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8582 				 port, "port");
8583 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8584 	TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8585 			      port_id, UINT16);
8586 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8587 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8588 				 vf, "vf");
8589 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8590 	TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8591 			      vf_id, UINT8);
8592 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
8593 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8594 				 what, "rxmode");
8595 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
8596 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8597 				 mode, "AUPE#ROPE#BAM#MPE");
8598 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
8599 	TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8600 				 on, "on#off");
8601 
8602 cmdline_parse_inst_t cmd_set_vf_rxmode = {
8603 	.f = cmd_set_vf_rxmode_parsed,
8604 	.data = NULL,
8605 	.help_str = "set port <port_id> vf <vf_id> rxmode "
8606 		"AUPE|ROPE|BAM|MPE on|off",
8607 	.tokens = {
8608 		(void *)&cmd_set_vf_rxmode_set,
8609 		(void *)&cmd_set_vf_rxmode_port,
8610 		(void *)&cmd_set_vf_rxmode_portid,
8611 		(void *)&cmd_set_vf_rxmode_vf,
8612 		(void *)&cmd_set_vf_rxmode_vfid,
8613 		(void *)&cmd_set_vf_rxmode_what,
8614 		(void *)&cmd_set_vf_rxmode_mode,
8615 		(void *)&cmd_set_vf_rxmode_on,
8616 		NULL,
8617 	},
8618 };
8619 
8620 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
8621 struct cmd_vf_mac_addr_result {
8622 	cmdline_fixed_string_t mac_addr_cmd;
8623 	cmdline_fixed_string_t what;
8624 	cmdline_fixed_string_t port;
8625 	uint16_t port_num;
8626 	cmdline_fixed_string_t vf;
8627 	uint8_t vf_num;
8628 	struct rte_ether_addr address;
8629 };
8630 
8631 static void cmd_vf_mac_addr_parsed(void *parsed_result,
8632 		__attribute__((unused)) struct cmdline *cl,
8633 		__attribute__((unused)) void *data)
8634 {
8635 	struct cmd_vf_mac_addr_result *res = parsed_result;
8636 	int ret = -ENOTSUP;
8637 
8638 	if (strcmp(res->what, "add") != 0)
8639 		return;
8640 
8641 #ifdef RTE_LIBRTE_I40E_PMD
8642 	if (ret == -ENOTSUP)
8643 		ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
8644 						   &res->address);
8645 #endif
8646 #ifdef RTE_LIBRTE_BNXT_PMD
8647 	if (ret == -ENOTSUP)
8648 		ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
8649 						res->vf_num);
8650 #endif
8651 
8652 	if(ret < 0)
8653 		printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
8654 
8655 }
8656 
8657 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
8658 	TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8659 				mac_addr_cmd,"mac_addr");
8660 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
8661 	TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8662 				what,"add");
8663 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
8664 	TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8665 				port,"port");
8666 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
8667 	TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8668 				port_num, UINT16);
8669 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
8670 	TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8671 				vf,"vf");
8672 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
8673 	TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8674 				vf_num, UINT8);
8675 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
8676 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
8677 				address);
8678 
8679 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
8680 	.f = cmd_vf_mac_addr_parsed,
8681 	.data = (void *)0,
8682 	.help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
8683 		"Add MAC address filtering for a VF on port_id",
8684 	.tokens = {
8685 		(void *)&cmd_vf_mac_addr_cmd,
8686 		(void *)&cmd_vf_mac_addr_what,
8687 		(void *)&cmd_vf_mac_addr_port,
8688 		(void *)&cmd_vf_mac_addr_portnum,
8689 		(void *)&cmd_vf_mac_addr_vf,
8690 		(void *)&cmd_vf_mac_addr_vfnum,
8691 		(void *)&cmd_vf_mac_addr_addr,
8692 		NULL,
8693 	},
8694 };
8695 
8696 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
8697 struct cmd_vf_rx_vlan_filter {
8698 	cmdline_fixed_string_t rx_vlan;
8699 	cmdline_fixed_string_t what;
8700 	uint16_t vlan_id;
8701 	cmdline_fixed_string_t port;
8702 	portid_t port_id;
8703 	cmdline_fixed_string_t vf;
8704 	uint64_t vf_mask;
8705 };
8706 
8707 static void
8708 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
8709 			  __attribute__((unused)) struct cmdline *cl,
8710 			  __attribute__((unused)) void *data)
8711 {
8712 	struct cmd_vf_rx_vlan_filter *res = parsed_result;
8713 	int ret = -ENOTSUP;
8714 
8715 	__rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
8716 
8717 #ifdef RTE_LIBRTE_IXGBE_PMD
8718 	if (ret == -ENOTSUP)
8719 		ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
8720 				res->vlan_id, res->vf_mask, is_add);
8721 #endif
8722 #ifdef RTE_LIBRTE_I40E_PMD
8723 	if (ret == -ENOTSUP)
8724 		ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
8725 				res->vlan_id, res->vf_mask, is_add);
8726 #endif
8727 #ifdef RTE_LIBRTE_BNXT_PMD
8728 	if (ret == -ENOTSUP)
8729 		ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
8730 				res->vlan_id, res->vf_mask, is_add);
8731 #endif
8732 
8733 	switch (ret) {
8734 	case 0:
8735 		break;
8736 	case -EINVAL:
8737 		printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
8738 				res->vlan_id, res->vf_mask);
8739 		break;
8740 	case -ENODEV:
8741 		printf("invalid port_id %d\n", res->port_id);
8742 		break;
8743 	case -ENOTSUP:
8744 		printf("function not implemented or supported\n");
8745 		break;
8746 	default:
8747 		printf("programming error: (%s)\n", strerror(-ret));
8748 	}
8749 }
8750 
8751 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
8752 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8753 				 rx_vlan, "rx_vlan");
8754 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
8755 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8756 				 what, "add#rm");
8757 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
8758 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8759 			      vlan_id, UINT16);
8760 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
8761 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8762 				 port, "port");
8763 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
8764 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8765 			      port_id, UINT16);
8766 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
8767 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8768 				 vf, "vf");
8769 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
8770 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8771 			      vf_mask, UINT64);
8772 
8773 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
8774 	.f = cmd_vf_rx_vlan_filter_parsed,
8775 	.data = NULL,
8776 	.help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
8777 		"(vf_mask = hexadecimal VF mask)",
8778 	.tokens = {
8779 		(void *)&cmd_vf_rx_vlan_filter_rx_vlan,
8780 		(void *)&cmd_vf_rx_vlan_filter_what,
8781 		(void *)&cmd_vf_rx_vlan_filter_vlanid,
8782 		(void *)&cmd_vf_rx_vlan_filter_port,
8783 		(void *)&cmd_vf_rx_vlan_filter_portid,
8784 		(void *)&cmd_vf_rx_vlan_filter_vf,
8785 		(void *)&cmd_vf_rx_vlan_filter_vf_mask,
8786 		NULL,
8787 	},
8788 };
8789 
8790 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
8791 struct cmd_queue_rate_limit_result {
8792 	cmdline_fixed_string_t set;
8793 	cmdline_fixed_string_t port;
8794 	uint16_t port_num;
8795 	cmdline_fixed_string_t queue;
8796 	uint8_t queue_num;
8797 	cmdline_fixed_string_t rate;
8798 	uint16_t rate_num;
8799 };
8800 
8801 static void cmd_queue_rate_limit_parsed(void *parsed_result,
8802 		__attribute__((unused)) struct cmdline *cl,
8803 		__attribute__((unused)) void *data)
8804 {
8805 	struct cmd_queue_rate_limit_result *res = parsed_result;
8806 	int ret = 0;
8807 
8808 	if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8809 		&& (strcmp(res->queue, "queue") == 0)
8810 		&& (strcmp(res->rate, "rate") == 0))
8811 		ret = set_queue_rate_limit(res->port_num, res->queue_num,
8812 					res->rate_num);
8813 	if (ret < 0)
8814 		printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
8815 
8816 }
8817 
8818 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
8819 	TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8820 				set, "set");
8821 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
8822 	TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8823 				port, "port");
8824 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
8825 	TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8826 				port_num, UINT16);
8827 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
8828 	TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8829 				queue, "queue");
8830 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
8831 	TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8832 				queue_num, UINT8);
8833 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
8834 	TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8835 				rate, "rate");
8836 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
8837 	TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8838 				rate_num, UINT16);
8839 
8840 cmdline_parse_inst_t cmd_queue_rate_limit = {
8841 	.f = cmd_queue_rate_limit_parsed,
8842 	.data = (void *)0,
8843 	.help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
8844 		"Set rate limit for a queue on port_id",
8845 	.tokens = {
8846 		(void *)&cmd_queue_rate_limit_set,
8847 		(void *)&cmd_queue_rate_limit_port,
8848 		(void *)&cmd_queue_rate_limit_portnum,
8849 		(void *)&cmd_queue_rate_limit_queue,
8850 		(void *)&cmd_queue_rate_limit_queuenum,
8851 		(void *)&cmd_queue_rate_limit_rate,
8852 		(void *)&cmd_queue_rate_limit_ratenum,
8853 		NULL,
8854 	},
8855 };
8856 
8857 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
8858 struct cmd_vf_rate_limit_result {
8859 	cmdline_fixed_string_t set;
8860 	cmdline_fixed_string_t port;
8861 	uint16_t port_num;
8862 	cmdline_fixed_string_t vf;
8863 	uint8_t vf_num;
8864 	cmdline_fixed_string_t rate;
8865 	uint16_t rate_num;
8866 	cmdline_fixed_string_t q_msk;
8867 	uint64_t q_msk_val;
8868 };
8869 
8870 static void cmd_vf_rate_limit_parsed(void *parsed_result,
8871 		__attribute__((unused)) struct cmdline *cl,
8872 		__attribute__((unused)) void *data)
8873 {
8874 	struct cmd_vf_rate_limit_result *res = parsed_result;
8875 	int ret = 0;
8876 
8877 	if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8878 		&& (strcmp(res->vf, "vf") == 0)
8879 		&& (strcmp(res->rate, "rate") == 0)
8880 		&& (strcmp(res->q_msk, "queue_mask") == 0))
8881 		ret = set_vf_rate_limit(res->port_num, res->vf_num,
8882 					res->rate_num, res->q_msk_val);
8883 	if (ret < 0)
8884 		printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
8885 
8886 }
8887 
8888 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
8889 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8890 				set, "set");
8891 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
8892 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8893 				port, "port");
8894 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
8895 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8896 				port_num, UINT16);
8897 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
8898 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8899 				vf, "vf");
8900 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
8901 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8902 				vf_num, UINT8);
8903 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
8904 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8905 				rate, "rate");
8906 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
8907 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8908 				rate_num, UINT16);
8909 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
8910 	TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8911 				q_msk, "queue_mask");
8912 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
8913 	TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8914 				q_msk_val, UINT64);
8915 
8916 cmdline_parse_inst_t cmd_vf_rate_limit = {
8917 	.f = cmd_vf_rate_limit_parsed,
8918 	.data = (void *)0,
8919 	.help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
8920 		"queue_mask <queue_mask_value>: "
8921 		"Set rate limit for queues of VF on port_id",
8922 	.tokens = {
8923 		(void *)&cmd_vf_rate_limit_set,
8924 		(void *)&cmd_vf_rate_limit_port,
8925 		(void *)&cmd_vf_rate_limit_portnum,
8926 		(void *)&cmd_vf_rate_limit_vf,
8927 		(void *)&cmd_vf_rate_limit_vfnum,
8928 		(void *)&cmd_vf_rate_limit_rate,
8929 		(void *)&cmd_vf_rate_limit_ratenum,
8930 		(void *)&cmd_vf_rate_limit_q_msk,
8931 		(void *)&cmd_vf_rate_limit_q_msk_val,
8932 		NULL,
8933 	},
8934 };
8935 
8936 /* *** ADD TUNNEL FILTER OF A PORT *** */
8937 struct cmd_tunnel_filter_result {
8938 	cmdline_fixed_string_t cmd;
8939 	cmdline_fixed_string_t what;
8940 	portid_t port_id;
8941 	struct rte_ether_addr outer_mac;
8942 	struct rte_ether_addr inner_mac;
8943 	cmdline_ipaddr_t ip_value;
8944 	uint16_t inner_vlan;
8945 	cmdline_fixed_string_t tunnel_type;
8946 	cmdline_fixed_string_t filter_type;
8947 	uint32_t tenant_id;
8948 	uint16_t queue_num;
8949 };
8950 
8951 static void
8952 cmd_tunnel_filter_parsed(void *parsed_result,
8953 			  __attribute__((unused)) struct cmdline *cl,
8954 			  __attribute__((unused)) void *data)
8955 {
8956 	struct cmd_tunnel_filter_result *res = parsed_result;
8957 	struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
8958 	int ret = 0;
8959 
8960 	memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
8961 
8962 	rte_ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
8963 	rte_ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
8964 	tunnel_filter_conf.inner_vlan = res->inner_vlan;
8965 
8966 	if (res->ip_value.family == AF_INET) {
8967 		tunnel_filter_conf.ip_addr.ipv4_addr =
8968 			res->ip_value.addr.ipv4.s_addr;
8969 		tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
8970 	} else {
8971 		memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
8972 			&(res->ip_value.addr.ipv6),
8973 			sizeof(struct in6_addr));
8974 		tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
8975 	}
8976 
8977 	if (!strcmp(res->filter_type, "imac-ivlan"))
8978 		tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
8979 	else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
8980 		tunnel_filter_conf.filter_type =
8981 			RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
8982 	else if (!strcmp(res->filter_type, "imac-tenid"))
8983 		tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
8984 	else if (!strcmp(res->filter_type, "imac"))
8985 		tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
8986 	else if (!strcmp(res->filter_type, "omac-imac-tenid"))
8987 		tunnel_filter_conf.filter_type =
8988 			RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
8989 	else if (!strcmp(res->filter_type, "oip"))
8990 		tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
8991 	else if (!strcmp(res->filter_type, "iip"))
8992 		tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
8993 	else {
8994 		printf("The filter type is not supported");
8995 		return;
8996 	}
8997 
8998 	if (!strcmp(res->tunnel_type, "vxlan"))
8999 		tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
9000 	else if (!strcmp(res->tunnel_type, "vxlan-gpe"))
9001 		tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9002 	else if (!strcmp(res->tunnel_type, "nvgre"))
9003 		tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
9004 	else if (!strcmp(res->tunnel_type, "ipingre"))
9005 		tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
9006 	else {
9007 		printf("The tunnel type %s not supported.\n", res->tunnel_type);
9008 		return;
9009 	}
9010 
9011 	tunnel_filter_conf.tenant_id = res->tenant_id;
9012 	tunnel_filter_conf.queue_id = res->queue_num;
9013 	if (!strcmp(res->what, "add"))
9014 		ret = rte_eth_dev_filter_ctrl(res->port_id,
9015 					RTE_ETH_FILTER_TUNNEL,
9016 					RTE_ETH_FILTER_ADD,
9017 					&tunnel_filter_conf);
9018 	else
9019 		ret = rte_eth_dev_filter_ctrl(res->port_id,
9020 					RTE_ETH_FILTER_TUNNEL,
9021 					RTE_ETH_FILTER_DELETE,
9022 					&tunnel_filter_conf);
9023 	if (ret < 0)
9024 		printf("cmd_tunnel_filter_parsed error: (%s)\n",
9025 				strerror(-ret));
9026 
9027 }
9028 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
9029 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9030 	cmd, "tunnel_filter");
9031 cmdline_parse_token_string_t cmd_tunnel_filter_what =
9032 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9033 	what, "add#rm");
9034 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
9035 	TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9036 	port_id, UINT16);
9037 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
9038 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
9039 	outer_mac);
9040 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
9041 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
9042 	inner_mac);
9043 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
9044 	TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9045 	inner_vlan, UINT16);
9046 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
9047 	TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
9048 	ip_value);
9049 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
9050 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9051 	tunnel_type, "vxlan#nvgre#ipingre#vxlan-gpe");
9052 
9053 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
9054 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9055 	filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
9056 		"imac#omac-imac-tenid");
9057 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
9058 	TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9059 	tenant_id, UINT32);
9060 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
9061 	TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9062 	queue_num, UINT16);
9063 
9064 cmdline_parse_inst_t cmd_tunnel_filter = {
9065 	.f = cmd_tunnel_filter_parsed,
9066 	.data = (void *)0,
9067 	.help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
9068 		"<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
9069 		"imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
9070 		"<queue_id>: Add/Rm tunnel filter of a port",
9071 	.tokens = {
9072 		(void *)&cmd_tunnel_filter_cmd,
9073 		(void *)&cmd_tunnel_filter_what,
9074 		(void *)&cmd_tunnel_filter_port_id,
9075 		(void *)&cmd_tunnel_filter_outer_mac,
9076 		(void *)&cmd_tunnel_filter_inner_mac,
9077 		(void *)&cmd_tunnel_filter_ip_value,
9078 		(void *)&cmd_tunnel_filter_innner_vlan,
9079 		(void *)&cmd_tunnel_filter_tunnel_type,
9080 		(void *)&cmd_tunnel_filter_filter_type,
9081 		(void *)&cmd_tunnel_filter_tenant_id,
9082 		(void *)&cmd_tunnel_filter_queue_num,
9083 		NULL,
9084 	},
9085 };
9086 
9087 /* *** CONFIGURE TUNNEL UDP PORT *** */
9088 struct cmd_tunnel_udp_config {
9089 	cmdline_fixed_string_t cmd;
9090 	cmdline_fixed_string_t what;
9091 	uint16_t udp_port;
9092 	portid_t port_id;
9093 };
9094 
9095 static void
9096 cmd_tunnel_udp_config_parsed(void *parsed_result,
9097 			  __attribute__((unused)) struct cmdline *cl,
9098 			  __attribute__((unused)) void *data)
9099 {
9100 	struct cmd_tunnel_udp_config *res = parsed_result;
9101 	struct rte_eth_udp_tunnel tunnel_udp;
9102 	int ret;
9103 
9104 	tunnel_udp.udp_port = res->udp_port;
9105 
9106 	if (!strcmp(res->cmd, "rx_vxlan_port"))
9107 		tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9108 
9109 	if (!strcmp(res->what, "add"))
9110 		ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9111 						      &tunnel_udp);
9112 	else
9113 		ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9114 							 &tunnel_udp);
9115 
9116 	if (ret < 0)
9117 		printf("udp tunneling add error: (%s)\n", strerror(-ret));
9118 }
9119 
9120 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
9121 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9122 				cmd, "rx_vxlan_port");
9123 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
9124 	TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9125 				what, "add#rm");
9126 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
9127 	TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9128 				udp_port, UINT16);
9129 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
9130 	TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9131 				port_id, UINT16);
9132 
9133 cmdline_parse_inst_t cmd_tunnel_udp_config = {
9134 	.f = cmd_tunnel_udp_config_parsed,
9135 	.data = (void *)0,
9136 	.help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
9137 		"Add/Remove a tunneling UDP port filter",
9138 	.tokens = {
9139 		(void *)&cmd_tunnel_udp_config_cmd,
9140 		(void *)&cmd_tunnel_udp_config_what,
9141 		(void *)&cmd_tunnel_udp_config_udp_port,
9142 		(void *)&cmd_tunnel_udp_config_port_id,
9143 		NULL,
9144 	},
9145 };
9146 
9147 struct cmd_config_tunnel_udp_port {
9148 	cmdline_fixed_string_t port;
9149 	cmdline_fixed_string_t config;
9150 	portid_t port_id;
9151 	cmdline_fixed_string_t udp_tunnel_port;
9152 	cmdline_fixed_string_t action;
9153 	cmdline_fixed_string_t tunnel_type;
9154 	uint16_t udp_port;
9155 };
9156 
9157 static void
9158 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
9159 			       __attribute__((unused)) struct cmdline *cl,
9160 			       __attribute__((unused)) void *data)
9161 {
9162 	struct cmd_config_tunnel_udp_port *res = parsed_result;
9163 	struct rte_eth_udp_tunnel tunnel_udp;
9164 	int ret = 0;
9165 
9166 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9167 		return;
9168 
9169 	tunnel_udp.udp_port = res->udp_port;
9170 
9171 	if (!strcmp(res->tunnel_type, "vxlan")) {
9172 		tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9173 	} else if (!strcmp(res->tunnel_type, "geneve")) {
9174 		tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE;
9175 	} else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
9176 		tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9177 	} else {
9178 		printf("Invalid tunnel type\n");
9179 		return;
9180 	}
9181 
9182 	if (!strcmp(res->action, "add"))
9183 		ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9184 						      &tunnel_udp);
9185 	else
9186 		ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9187 							 &tunnel_udp);
9188 
9189 	if (ret < 0)
9190 		printf("udp tunneling port add error: (%s)\n", strerror(-ret));
9191 }
9192 
9193 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
9194 	TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
9195 				 "port");
9196 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
9197 	TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
9198 				 "config");
9199 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
9200 	TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
9201 			      UINT16);
9202 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
9203 	TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
9204 				 udp_tunnel_port,
9205 				 "udp_tunnel_port");
9206 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
9207 	TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
9208 				 "add#rm");
9209 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
9210 	TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
9211 				 "vxlan#geneve#vxlan-gpe");
9212 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
9213 	TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
9214 			      UINT16);
9215 
9216 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
9217 	.f = cmd_cfg_tunnel_udp_port_parsed,
9218 	.data = NULL,
9219 	.help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|geneve|vxlan-gpe <udp_port>",
9220 	.tokens = {
9221 		(void *)&cmd_config_tunnel_udp_port_port,
9222 		(void *)&cmd_config_tunnel_udp_port_config,
9223 		(void *)&cmd_config_tunnel_udp_port_port_id,
9224 		(void *)&cmd_config_tunnel_udp_port_tunnel_port,
9225 		(void *)&cmd_config_tunnel_udp_port_action,
9226 		(void *)&cmd_config_tunnel_udp_port_tunnel_type,
9227 		(void *)&cmd_config_tunnel_udp_port_value,
9228 		NULL,
9229 	},
9230 };
9231 
9232 /* *** GLOBAL CONFIG *** */
9233 struct cmd_global_config_result {
9234 	cmdline_fixed_string_t cmd;
9235 	portid_t port_id;
9236 	cmdline_fixed_string_t cfg_type;
9237 	uint8_t len;
9238 };
9239 
9240 static void
9241 cmd_global_config_parsed(void *parsed_result,
9242 			 __attribute__((unused)) struct cmdline *cl,
9243 			 __attribute__((unused)) void *data)
9244 {
9245 	struct cmd_global_config_result *res = parsed_result;
9246 	struct rte_eth_global_cfg conf;
9247 	int ret;
9248 
9249 	memset(&conf, 0, sizeof(conf));
9250 	conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
9251 	conf.cfg.gre_key_len = res->len;
9252 	ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
9253 				      RTE_ETH_FILTER_SET, &conf);
9254 	if (ret != 0)
9255 		printf("Global config error\n");
9256 }
9257 
9258 cmdline_parse_token_string_t cmd_global_config_cmd =
9259 	TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
9260 		"global_config");
9261 cmdline_parse_token_num_t cmd_global_config_port_id =
9262 	TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id,
9263 			       UINT16);
9264 cmdline_parse_token_string_t cmd_global_config_type =
9265 	TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
9266 		cfg_type, "gre-key-len");
9267 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
9268 	TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
9269 		len, UINT8);
9270 
9271 cmdline_parse_inst_t cmd_global_config = {
9272 	.f = cmd_global_config_parsed,
9273 	.data = (void *)NULL,
9274 	.help_str = "global_config <port_id> gre-key-len <key_len>",
9275 	.tokens = {
9276 		(void *)&cmd_global_config_cmd,
9277 		(void *)&cmd_global_config_port_id,
9278 		(void *)&cmd_global_config_type,
9279 		(void *)&cmd_global_config_gre_key_len,
9280 		NULL,
9281 	},
9282 };
9283 
9284 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
9285 struct cmd_set_mirror_mask_result {
9286 	cmdline_fixed_string_t set;
9287 	cmdline_fixed_string_t port;
9288 	portid_t port_id;
9289 	cmdline_fixed_string_t mirror;
9290 	uint8_t rule_id;
9291 	cmdline_fixed_string_t what;
9292 	cmdline_fixed_string_t value;
9293 	cmdline_fixed_string_t dstpool;
9294 	uint8_t dstpool_id;
9295 	cmdline_fixed_string_t on;
9296 };
9297 
9298 cmdline_parse_token_string_t cmd_mirror_mask_set =
9299 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9300 				set, "set");
9301 cmdline_parse_token_string_t cmd_mirror_mask_port =
9302 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9303 				port, "port");
9304 cmdline_parse_token_num_t cmd_mirror_mask_portid =
9305 	TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9306 				port_id, UINT16);
9307 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
9308 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9309 				mirror, "mirror-rule");
9310 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
9311 	TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9312 				rule_id, UINT8);
9313 cmdline_parse_token_string_t cmd_mirror_mask_what =
9314 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9315 				what, "pool-mirror-up#pool-mirror-down"
9316 				      "#vlan-mirror");
9317 cmdline_parse_token_string_t cmd_mirror_mask_value =
9318 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9319 				value, NULL);
9320 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
9321 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9322 				dstpool, "dst-pool");
9323 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
9324 	TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9325 				dstpool_id, UINT8);
9326 cmdline_parse_token_string_t cmd_mirror_mask_on =
9327 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9328 				on, "on#off");
9329 
9330 static void
9331 cmd_set_mirror_mask_parsed(void *parsed_result,
9332 		       __attribute__((unused)) struct cmdline *cl,
9333 		       __attribute__((unused)) void *data)
9334 {
9335 	int ret,nb_item,i;
9336 	struct cmd_set_mirror_mask_result *res = parsed_result;
9337 	struct rte_eth_mirror_conf mr_conf;
9338 
9339 	memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9340 
9341 	unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
9342 
9343 	mr_conf.dst_pool = res->dstpool_id;
9344 
9345 	if (!strcmp(res->what, "pool-mirror-up")) {
9346 		mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9347 		mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
9348 	} else if (!strcmp(res->what, "pool-mirror-down")) {
9349 		mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9350 		mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
9351 	} else if (!strcmp(res->what, "vlan-mirror")) {
9352 		mr_conf.rule_type = ETH_MIRROR_VLAN;
9353 		nb_item = parse_item_list(res->value, "vlan",
9354 				ETH_MIRROR_MAX_VLANS, vlan_list, 1);
9355 		if (nb_item <= 0)
9356 			return;
9357 
9358 		for (i = 0; i < nb_item; i++) {
9359 			if (vlan_list[i] > RTE_ETHER_MAX_VLAN_ID) {
9360 				printf("Invalid vlan_id: must be < 4096\n");
9361 				return;
9362 			}
9363 
9364 			mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
9365 			mr_conf.vlan.vlan_mask |= 1ULL << i;
9366 		}
9367 	}
9368 
9369 	if (!strcmp(res->on, "on"))
9370 		ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9371 						res->rule_id, 1);
9372 	else
9373 		ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9374 						res->rule_id, 0);
9375 	if (ret < 0)
9376 		printf("mirror rule add error: (%s)\n", strerror(-ret));
9377 }
9378 
9379 cmdline_parse_inst_t cmd_set_mirror_mask = {
9380 		.f = cmd_set_mirror_mask_parsed,
9381 		.data = NULL,
9382 		.help_str = "set port <port_id> mirror-rule <rule_id> "
9383 			"pool-mirror-up|pool-mirror-down|vlan-mirror "
9384 			"<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
9385 		.tokens = {
9386 			(void *)&cmd_mirror_mask_set,
9387 			(void *)&cmd_mirror_mask_port,
9388 			(void *)&cmd_mirror_mask_portid,
9389 			(void *)&cmd_mirror_mask_mirror,
9390 			(void *)&cmd_mirror_mask_ruleid,
9391 			(void *)&cmd_mirror_mask_what,
9392 			(void *)&cmd_mirror_mask_value,
9393 			(void *)&cmd_mirror_mask_dstpool,
9394 			(void *)&cmd_mirror_mask_poolid,
9395 			(void *)&cmd_mirror_mask_on,
9396 			NULL,
9397 		},
9398 };
9399 
9400 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
9401 struct cmd_set_mirror_link_result {
9402 	cmdline_fixed_string_t set;
9403 	cmdline_fixed_string_t port;
9404 	portid_t port_id;
9405 	cmdline_fixed_string_t mirror;
9406 	uint8_t rule_id;
9407 	cmdline_fixed_string_t what;
9408 	cmdline_fixed_string_t dstpool;
9409 	uint8_t dstpool_id;
9410 	cmdline_fixed_string_t on;
9411 };
9412 
9413 cmdline_parse_token_string_t cmd_mirror_link_set =
9414 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9415 				 set, "set");
9416 cmdline_parse_token_string_t cmd_mirror_link_port =
9417 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9418 				port, "port");
9419 cmdline_parse_token_num_t cmd_mirror_link_portid =
9420 	TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9421 				port_id, UINT16);
9422 cmdline_parse_token_string_t cmd_mirror_link_mirror =
9423 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9424 				mirror, "mirror-rule");
9425 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
9426 	TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9427 			    rule_id, UINT8);
9428 cmdline_parse_token_string_t cmd_mirror_link_what =
9429 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9430 				what, "uplink-mirror#downlink-mirror");
9431 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
9432 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9433 				dstpool, "dst-pool");
9434 cmdline_parse_token_num_t cmd_mirror_link_poolid =
9435 	TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9436 				dstpool_id, UINT8);
9437 cmdline_parse_token_string_t cmd_mirror_link_on =
9438 	TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9439 				on, "on#off");
9440 
9441 static void
9442 cmd_set_mirror_link_parsed(void *parsed_result,
9443 		       __attribute__((unused)) struct cmdline *cl,
9444 		       __attribute__((unused)) void *data)
9445 {
9446 	int ret;
9447 	struct cmd_set_mirror_link_result *res = parsed_result;
9448 	struct rte_eth_mirror_conf mr_conf;
9449 
9450 	memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9451 	if (!strcmp(res->what, "uplink-mirror"))
9452 		mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
9453 	else
9454 		mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
9455 
9456 	mr_conf.dst_pool = res->dstpool_id;
9457 
9458 	if (!strcmp(res->on, "on"))
9459 		ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9460 						res->rule_id, 1);
9461 	else
9462 		ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9463 						res->rule_id, 0);
9464 
9465 	/* check the return value and print it if is < 0 */
9466 	if (ret < 0)
9467 		printf("mirror rule add error: (%s)\n", strerror(-ret));
9468 
9469 }
9470 
9471 cmdline_parse_inst_t cmd_set_mirror_link = {
9472 		.f = cmd_set_mirror_link_parsed,
9473 		.data = NULL,
9474 		.help_str = "set port <port_id> mirror-rule <rule_id> "
9475 			"uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
9476 		.tokens = {
9477 			(void *)&cmd_mirror_link_set,
9478 			(void *)&cmd_mirror_link_port,
9479 			(void *)&cmd_mirror_link_portid,
9480 			(void *)&cmd_mirror_link_mirror,
9481 			(void *)&cmd_mirror_link_ruleid,
9482 			(void *)&cmd_mirror_link_what,
9483 			(void *)&cmd_mirror_link_dstpool,
9484 			(void *)&cmd_mirror_link_poolid,
9485 			(void *)&cmd_mirror_link_on,
9486 			NULL,
9487 		},
9488 };
9489 
9490 /* *** RESET VM MIRROR RULE *** */
9491 struct cmd_rm_mirror_rule_result {
9492 	cmdline_fixed_string_t reset;
9493 	cmdline_fixed_string_t port;
9494 	portid_t port_id;
9495 	cmdline_fixed_string_t mirror;
9496 	uint8_t rule_id;
9497 };
9498 
9499 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
9500 	TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9501 				 reset, "reset");
9502 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
9503 	TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9504 				port, "port");
9505 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
9506 	TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9507 				port_id, UINT16);
9508 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
9509 	TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9510 				mirror, "mirror-rule");
9511 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
9512 	TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9513 				rule_id, UINT8);
9514 
9515 static void
9516 cmd_reset_mirror_rule_parsed(void *parsed_result,
9517 		       __attribute__((unused)) struct cmdline *cl,
9518 		       __attribute__((unused)) void *data)
9519 {
9520 	int ret;
9521 	struct cmd_set_mirror_link_result *res = parsed_result;
9522         /* check rule_id */
9523 	ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
9524 	if(ret < 0)
9525 		printf("mirror rule remove error: (%s)\n", strerror(-ret));
9526 }
9527 
9528 cmdline_parse_inst_t cmd_reset_mirror_rule = {
9529 		.f = cmd_reset_mirror_rule_parsed,
9530 		.data = NULL,
9531 		.help_str = "reset port <port_id> mirror-rule <rule_id>",
9532 		.tokens = {
9533 			(void *)&cmd_rm_mirror_rule_reset,
9534 			(void *)&cmd_rm_mirror_rule_port,
9535 			(void *)&cmd_rm_mirror_rule_portid,
9536 			(void *)&cmd_rm_mirror_rule_mirror,
9537 			(void *)&cmd_rm_mirror_rule_ruleid,
9538 			NULL,
9539 		},
9540 };
9541 
9542 /* ******************************************************************************** */
9543 
9544 struct cmd_dump_result {
9545 	cmdline_fixed_string_t dump;
9546 };
9547 
9548 static void
9549 dump_struct_sizes(void)
9550 {
9551 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9552 	DUMP_SIZE(struct rte_mbuf);
9553 	DUMP_SIZE(struct rte_mempool);
9554 	DUMP_SIZE(struct rte_ring);
9555 #undef DUMP_SIZE
9556 }
9557 
9558 static void cmd_dump_parsed(void *parsed_result,
9559 			    __attribute__((unused)) struct cmdline *cl,
9560 			    __attribute__((unused)) void *data)
9561 {
9562 	struct cmd_dump_result *res = parsed_result;
9563 
9564 	if (!strcmp(res->dump, "dump_physmem"))
9565 		rte_dump_physmem_layout(stdout);
9566 	else if (!strcmp(res->dump, "dump_memzone"))
9567 		rte_memzone_dump(stdout);
9568 	else if (!strcmp(res->dump, "dump_struct_sizes"))
9569 		dump_struct_sizes();
9570 	else if (!strcmp(res->dump, "dump_ring"))
9571 		rte_ring_list_dump(stdout);
9572 	else if (!strcmp(res->dump, "dump_mempool"))
9573 		rte_mempool_list_dump(stdout);
9574 	else if (!strcmp(res->dump, "dump_devargs"))
9575 		rte_devargs_dump(stdout);
9576 	else if (!strcmp(res->dump, "dump_log_types"))
9577 		rte_log_dump(stdout);
9578 }
9579 
9580 cmdline_parse_token_string_t cmd_dump_dump =
9581 	TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9582 		"dump_physmem#"
9583 		"dump_memzone#"
9584 		"dump_struct_sizes#"
9585 		"dump_ring#"
9586 		"dump_mempool#"
9587 		"dump_devargs#"
9588 		"dump_log_types");
9589 
9590 cmdline_parse_inst_t cmd_dump = {
9591 	.f = cmd_dump_parsed,  /* function to call */
9592 	.data = NULL,      /* 2nd arg of func */
9593 	.help_str = "Dump status",
9594 	.tokens = {        /* token list, NULL terminated */
9595 		(void *)&cmd_dump_dump,
9596 		NULL,
9597 	},
9598 };
9599 
9600 /* ******************************************************************************** */
9601 
9602 struct cmd_dump_one_result {
9603 	cmdline_fixed_string_t dump;
9604 	cmdline_fixed_string_t name;
9605 };
9606 
9607 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9608 				__attribute__((unused)) void *data)
9609 {
9610 	struct cmd_dump_one_result *res = parsed_result;
9611 
9612 	if (!strcmp(res->dump, "dump_ring")) {
9613 		struct rte_ring *r;
9614 		r = rte_ring_lookup(res->name);
9615 		if (r == NULL) {
9616 			cmdline_printf(cl, "Cannot find ring\n");
9617 			return;
9618 		}
9619 		rte_ring_dump(stdout, r);
9620 	} else if (!strcmp(res->dump, "dump_mempool")) {
9621 		struct rte_mempool *mp;
9622 		mp = rte_mempool_lookup(res->name);
9623 		if (mp == NULL) {
9624 			cmdline_printf(cl, "Cannot find mempool\n");
9625 			return;
9626 		}
9627 		rte_mempool_dump(stdout, mp);
9628 	}
9629 }
9630 
9631 cmdline_parse_token_string_t cmd_dump_one_dump =
9632 	TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9633 				 "dump_ring#dump_mempool");
9634 
9635 cmdline_parse_token_string_t cmd_dump_one_name =
9636 	TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9637 
9638 cmdline_parse_inst_t cmd_dump_one = {
9639 	.f = cmd_dump_one_parsed,  /* function to call */
9640 	.data = NULL,      /* 2nd arg of func */
9641 	.help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9642 	.tokens = {        /* token list, NULL terminated */
9643 		(void *)&cmd_dump_one_dump,
9644 		(void *)&cmd_dump_one_name,
9645 		NULL,
9646 	},
9647 };
9648 
9649 /* *** Add/Del syn filter *** */
9650 struct cmd_syn_filter_result {
9651 	cmdline_fixed_string_t filter;
9652 	portid_t port_id;
9653 	cmdline_fixed_string_t ops;
9654 	cmdline_fixed_string_t priority;
9655 	cmdline_fixed_string_t high;
9656 	cmdline_fixed_string_t queue;
9657 	uint16_t queue_id;
9658 };
9659 
9660 static void
9661 cmd_syn_filter_parsed(void *parsed_result,
9662 			__attribute__((unused)) struct cmdline *cl,
9663 			__attribute__((unused)) void *data)
9664 {
9665 	struct cmd_syn_filter_result *res = parsed_result;
9666 	struct rte_eth_syn_filter syn_filter;
9667 	int ret = 0;
9668 
9669 	ret = rte_eth_dev_filter_supported(res->port_id,
9670 					RTE_ETH_FILTER_SYN);
9671 	if (ret < 0) {
9672 		printf("syn filter is not supported on port %u.\n",
9673 				res->port_id);
9674 		return;
9675 	}
9676 
9677 	memset(&syn_filter, 0, sizeof(syn_filter));
9678 
9679 	if (!strcmp(res->ops, "add")) {
9680 		if (!strcmp(res->high, "high"))
9681 			syn_filter.hig_pri = 1;
9682 		else
9683 			syn_filter.hig_pri = 0;
9684 
9685 		syn_filter.queue = res->queue_id;
9686 		ret = rte_eth_dev_filter_ctrl(res->port_id,
9687 						RTE_ETH_FILTER_SYN,
9688 						RTE_ETH_FILTER_ADD,
9689 						&syn_filter);
9690 	} else
9691 		ret = rte_eth_dev_filter_ctrl(res->port_id,
9692 						RTE_ETH_FILTER_SYN,
9693 						RTE_ETH_FILTER_DELETE,
9694 						&syn_filter);
9695 
9696 	if (ret < 0)
9697 		printf("syn filter programming error: (%s)\n",
9698 				strerror(-ret));
9699 }
9700 
9701 cmdline_parse_token_string_t cmd_syn_filter_filter =
9702 	TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9703 	filter, "syn_filter");
9704 cmdline_parse_token_num_t cmd_syn_filter_port_id =
9705 	TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9706 	port_id, UINT16);
9707 cmdline_parse_token_string_t cmd_syn_filter_ops =
9708 	TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9709 	ops, "add#del");
9710 cmdline_parse_token_string_t cmd_syn_filter_priority =
9711 	TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9712 				priority, "priority");
9713 cmdline_parse_token_string_t cmd_syn_filter_high =
9714 	TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9715 				high, "high#low");
9716 cmdline_parse_token_string_t cmd_syn_filter_queue =
9717 	TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9718 				queue, "queue");
9719 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
9720 	TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9721 				queue_id, UINT16);
9722 
9723 cmdline_parse_inst_t cmd_syn_filter = {
9724 	.f = cmd_syn_filter_parsed,
9725 	.data = NULL,
9726 	.help_str = "syn_filter <port_id> add|del priority high|low queue "
9727 		"<queue_id>: Add/Delete syn filter",
9728 	.tokens = {
9729 		(void *)&cmd_syn_filter_filter,
9730 		(void *)&cmd_syn_filter_port_id,
9731 		(void *)&cmd_syn_filter_ops,
9732 		(void *)&cmd_syn_filter_priority,
9733 		(void *)&cmd_syn_filter_high,
9734 		(void *)&cmd_syn_filter_queue,
9735 		(void *)&cmd_syn_filter_queue_id,
9736 		NULL,
9737 	},
9738 };
9739 
9740 /* *** queue region set *** */
9741 struct cmd_queue_region_result {
9742 	cmdline_fixed_string_t set;
9743 	cmdline_fixed_string_t port;
9744 	portid_t port_id;
9745 	cmdline_fixed_string_t cmd;
9746 	cmdline_fixed_string_t region;
9747 	uint8_t  region_id;
9748 	cmdline_fixed_string_t queue_start_index;
9749 	uint8_t  queue_id;
9750 	cmdline_fixed_string_t queue_num;
9751 	uint8_t  queue_num_value;
9752 };
9753 
9754 static void
9755 cmd_queue_region_parsed(void *parsed_result,
9756 			__attribute__((unused)) struct cmdline *cl,
9757 			__attribute__((unused)) void *data)
9758 {
9759 	struct cmd_queue_region_result *res = parsed_result;
9760 	int ret = -ENOTSUP;
9761 #ifdef RTE_LIBRTE_I40E_PMD
9762 	struct rte_pmd_i40e_queue_region_conf region_conf;
9763 	enum rte_pmd_i40e_queue_region_op op_type;
9764 #endif
9765 
9766 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9767 		return;
9768 
9769 #ifdef RTE_LIBRTE_I40E_PMD
9770 	memset(&region_conf, 0, sizeof(region_conf));
9771 	op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
9772 	region_conf.region_id = res->region_id;
9773 	region_conf.queue_num = res->queue_num_value;
9774 	region_conf.queue_start_index = res->queue_id;
9775 
9776 	ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9777 				op_type, &region_conf);
9778 #endif
9779 
9780 	switch (ret) {
9781 	case 0:
9782 		break;
9783 	case -ENOTSUP:
9784 		printf("function not implemented or supported\n");
9785 		break;
9786 	default:
9787 		printf("queue region config error: (%s)\n", strerror(-ret));
9788 	}
9789 }
9790 
9791 cmdline_parse_token_string_t cmd_queue_region_set =
9792 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9793 		set, "set");
9794 cmdline_parse_token_string_t cmd_queue_region_port =
9795 	TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
9796 cmdline_parse_token_num_t cmd_queue_region_port_id =
9797 	TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9798 				port_id, UINT16);
9799 cmdline_parse_token_string_t cmd_queue_region_cmd =
9800 	TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9801 				 cmd, "queue-region");
9802 cmdline_parse_token_string_t cmd_queue_region_id =
9803 	TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9804 				region, "region_id");
9805 cmdline_parse_token_num_t cmd_queue_region_index =
9806 	TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9807 				region_id, UINT8);
9808 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
9809 	TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9810 				queue_start_index, "queue_start_index");
9811 cmdline_parse_token_num_t cmd_queue_region_queue_id =
9812 	TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9813 				queue_id, UINT8);
9814 cmdline_parse_token_string_t cmd_queue_region_queue_num =
9815 	TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9816 				queue_num, "queue_num");
9817 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
9818 	TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9819 				queue_num_value, UINT8);
9820 
9821 cmdline_parse_inst_t cmd_queue_region = {
9822 	.f = cmd_queue_region_parsed,
9823 	.data = NULL,
9824 	.help_str = "set port <port_id> queue-region region_id <value> "
9825 		"queue_start_index <value> queue_num <value>: Set a queue region",
9826 	.tokens = {
9827 		(void *)&cmd_queue_region_set,
9828 		(void *)&cmd_queue_region_port,
9829 		(void *)&cmd_queue_region_port_id,
9830 		(void *)&cmd_queue_region_cmd,
9831 		(void *)&cmd_queue_region_id,
9832 		(void *)&cmd_queue_region_index,
9833 		(void *)&cmd_queue_region_queue_start_index,
9834 		(void *)&cmd_queue_region_queue_id,
9835 		(void *)&cmd_queue_region_queue_num,
9836 		(void *)&cmd_queue_region_queue_num_value,
9837 		NULL,
9838 	},
9839 };
9840 
9841 /* *** queue region and flowtype set *** */
9842 struct cmd_region_flowtype_result {
9843 	cmdline_fixed_string_t set;
9844 	cmdline_fixed_string_t port;
9845 	portid_t port_id;
9846 	cmdline_fixed_string_t cmd;
9847 	cmdline_fixed_string_t region;
9848 	uint8_t  region_id;
9849 	cmdline_fixed_string_t flowtype;
9850 	uint8_t  flowtype_id;
9851 };
9852 
9853 static void
9854 cmd_region_flowtype_parsed(void *parsed_result,
9855 			__attribute__((unused)) struct cmdline *cl,
9856 			__attribute__((unused)) void *data)
9857 {
9858 	struct cmd_region_flowtype_result *res = parsed_result;
9859 	int ret = -ENOTSUP;
9860 #ifdef RTE_LIBRTE_I40E_PMD
9861 	struct rte_pmd_i40e_queue_region_conf region_conf;
9862 	enum rte_pmd_i40e_queue_region_op op_type;
9863 #endif
9864 
9865 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9866 		return;
9867 
9868 #ifdef RTE_LIBRTE_I40E_PMD
9869 	memset(&region_conf, 0, sizeof(region_conf));
9870 
9871 	op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
9872 	region_conf.region_id = res->region_id;
9873 	region_conf.hw_flowtype = res->flowtype_id;
9874 
9875 	ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9876 			op_type, &region_conf);
9877 #endif
9878 
9879 	switch (ret) {
9880 	case 0:
9881 		break;
9882 	case -ENOTSUP:
9883 		printf("function not implemented or supported\n");
9884 		break;
9885 	default:
9886 		printf("region flowtype config error: (%s)\n", strerror(-ret));
9887 	}
9888 }
9889 
9890 cmdline_parse_token_string_t cmd_region_flowtype_set =
9891 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9892 				set, "set");
9893 cmdline_parse_token_string_t cmd_region_flowtype_port =
9894 	TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9895 				port, "port");
9896 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
9897 	TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9898 				port_id, UINT16);
9899 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
9900 	TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9901 				cmd, "queue-region");
9902 cmdline_parse_token_string_t cmd_region_flowtype_index =
9903 	TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9904 				region, "region_id");
9905 cmdline_parse_token_num_t cmd_region_flowtype_id =
9906 	TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9907 				region_id, UINT8);
9908 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
9909 	TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9910 				flowtype, "flowtype");
9911 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
9912 	TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9913 				flowtype_id, UINT8);
9914 cmdline_parse_inst_t cmd_region_flowtype = {
9915 	.f = cmd_region_flowtype_parsed,
9916 	.data = NULL,
9917 	.help_str = "set port <port_id> queue-region region_id <value> "
9918 		"flowtype <value>: Set a flowtype region index",
9919 	.tokens = {
9920 		(void *)&cmd_region_flowtype_set,
9921 		(void *)&cmd_region_flowtype_port,
9922 		(void *)&cmd_region_flowtype_port_index,
9923 		(void *)&cmd_region_flowtype_cmd,
9924 		(void *)&cmd_region_flowtype_index,
9925 		(void *)&cmd_region_flowtype_id,
9926 		(void *)&cmd_region_flowtype_flow_index,
9927 		(void *)&cmd_region_flowtype_flow_id,
9928 		NULL,
9929 	},
9930 };
9931 
9932 /* *** User Priority (UP) to queue region (region_id) set *** */
9933 struct cmd_user_priority_region_result {
9934 	cmdline_fixed_string_t set;
9935 	cmdline_fixed_string_t port;
9936 	portid_t port_id;
9937 	cmdline_fixed_string_t cmd;
9938 	cmdline_fixed_string_t user_priority;
9939 	uint8_t  user_priority_id;
9940 	cmdline_fixed_string_t region;
9941 	uint8_t  region_id;
9942 };
9943 
9944 static void
9945 cmd_user_priority_region_parsed(void *parsed_result,
9946 			__attribute__((unused)) struct cmdline *cl,
9947 			__attribute__((unused)) void *data)
9948 {
9949 	struct cmd_user_priority_region_result *res = parsed_result;
9950 	int ret = -ENOTSUP;
9951 #ifdef RTE_LIBRTE_I40E_PMD
9952 	struct rte_pmd_i40e_queue_region_conf region_conf;
9953 	enum rte_pmd_i40e_queue_region_op op_type;
9954 #endif
9955 
9956 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9957 		return;
9958 
9959 #ifdef RTE_LIBRTE_I40E_PMD
9960 	memset(&region_conf, 0, sizeof(region_conf));
9961 	op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
9962 	region_conf.user_priority = res->user_priority_id;
9963 	region_conf.region_id = res->region_id;
9964 
9965 	ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9966 				op_type, &region_conf);
9967 #endif
9968 
9969 	switch (ret) {
9970 	case 0:
9971 		break;
9972 	case -ENOTSUP:
9973 		printf("function not implemented or supported\n");
9974 		break;
9975 	default:
9976 		printf("user_priority region config error: (%s)\n",
9977 				strerror(-ret));
9978 	}
9979 }
9980 
9981 cmdline_parse_token_string_t cmd_user_priority_region_set =
9982 	TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9983 				set, "set");
9984 cmdline_parse_token_string_t cmd_user_priority_region_port =
9985 	TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9986 				port, "port");
9987 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
9988 	TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9989 				port_id, UINT16);
9990 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
9991 	TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9992 				cmd, "queue-region");
9993 cmdline_parse_token_string_t cmd_user_priority_region_UP =
9994 	TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9995 				user_priority, "UP");
9996 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
9997 	TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9998 				user_priority_id, UINT8);
9999 cmdline_parse_token_string_t cmd_user_priority_region_region =
10000 	TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10001 				region, "region_id");
10002 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
10003 	TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10004 				region_id, UINT8);
10005 
10006 cmdline_parse_inst_t cmd_user_priority_region = {
10007 	.f = cmd_user_priority_region_parsed,
10008 	.data = NULL,
10009 	.help_str = "set port <port_id> queue-region UP <value> "
10010 		"region_id <value>: Set the mapping of User Priority (UP) "
10011 		"to queue region (region_id) ",
10012 	.tokens = {
10013 		(void *)&cmd_user_priority_region_set,
10014 		(void *)&cmd_user_priority_region_port,
10015 		(void *)&cmd_user_priority_region_port_index,
10016 		(void *)&cmd_user_priority_region_cmd,
10017 		(void *)&cmd_user_priority_region_UP,
10018 		(void *)&cmd_user_priority_region_UP_id,
10019 		(void *)&cmd_user_priority_region_region,
10020 		(void *)&cmd_user_priority_region_region_id,
10021 		NULL,
10022 	},
10023 };
10024 
10025 /* *** flush all queue region related configuration *** */
10026 struct cmd_flush_queue_region_result {
10027 	cmdline_fixed_string_t set;
10028 	cmdline_fixed_string_t port;
10029 	portid_t port_id;
10030 	cmdline_fixed_string_t cmd;
10031 	cmdline_fixed_string_t flush;
10032 	cmdline_fixed_string_t what;
10033 };
10034 
10035 static void
10036 cmd_flush_queue_region_parsed(void *parsed_result,
10037 			__attribute__((unused)) struct cmdline *cl,
10038 			__attribute__((unused)) void *data)
10039 {
10040 	struct cmd_flush_queue_region_result *res = parsed_result;
10041 	int ret = -ENOTSUP;
10042 #ifdef RTE_LIBRTE_I40E_PMD
10043 	struct rte_pmd_i40e_queue_region_conf region_conf;
10044 	enum rte_pmd_i40e_queue_region_op op_type;
10045 #endif
10046 
10047 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10048 		return;
10049 
10050 #ifdef RTE_LIBRTE_I40E_PMD
10051 	memset(&region_conf, 0, sizeof(region_conf));
10052 
10053 	if (strcmp(res->what, "on") == 0)
10054 		op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
10055 	else
10056 		op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
10057 
10058 	ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10059 				op_type, &region_conf);
10060 #endif
10061 
10062 	switch (ret) {
10063 	case 0:
10064 		break;
10065 	case -ENOTSUP:
10066 		printf("function not implemented or supported\n");
10067 		break;
10068 	default:
10069 		printf("queue region config flush error: (%s)\n",
10070 				strerror(-ret));
10071 	}
10072 }
10073 
10074 cmdline_parse_token_string_t cmd_flush_queue_region_set =
10075 	TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10076 				set, "set");
10077 cmdline_parse_token_string_t cmd_flush_queue_region_port =
10078 	TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10079 				port, "port");
10080 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
10081 	TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
10082 				port_id, UINT16);
10083 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
10084 	TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10085 				cmd, "queue-region");
10086 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
10087 	TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10088 				flush, "flush");
10089 cmdline_parse_token_string_t cmd_flush_queue_region_what =
10090 	TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10091 				what, "on#off");
10092 
10093 cmdline_parse_inst_t cmd_flush_queue_region = {
10094 	.f = cmd_flush_queue_region_parsed,
10095 	.data = NULL,
10096 	.help_str = "set port <port_id> queue-region flush on|off"
10097 		": flush all queue region related configuration",
10098 	.tokens = {
10099 		(void *)&cmd_flush_queue_region_set,
10100 		(void *)&cmd_flush_queue_region_port,
10101 		(void *)&cmd_flush_queue_region_port_index,
10102 		(void *)&cmd_flush_queue_region_cmd,
10103 		(void *)&cmd_flush_queue_region_flush,
10104 		(void *)&cmd_flush_queue_region_what,
10105 		NULL,
10106 	},
10107 };
10108 
10109 /* *** get all queue region related configuration info *** */
10110 struct cmd_show_queue_region_info {
10111 	cmdline_fixed_string_t show;
10112 	cmdline_fixed_string_t port;
10113 	portid_t port_id;
10114 	cmdline_fixed_string_t cmd;
10115 };
10116 
10117 static void
10118 cmd_show_queue_region_info_parsed(void *parsed_result,
10119 			__attribute__((unused)) struct cmdline *cl,
10120 			__attribute__((unused)) void *data)
10121 {
10122 	struct cmd_show_queue_region_info *res = parsed_result;
10123 	int ret = -ENOTSUP;
10124 #ifdef RTE_LIBRTE_I40E_PMD
10125 	struct rte_pmd_i40e_queue_regions rte_pmd_regions;
10126 	enum rte_pmd_i40e_queue_region_op op_type;
10127 #endif
10128 
10129 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10130 		return;
10131 
10132 #ifdef RTE_LIBRTE_I40E_PMD
10133 	memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
10134 
10135 	op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
10136 
10137 	ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10138 					op_type, &rte_pmd_regions);
10139 
10140 	port_queue_region_info_display(res->port_id, &rte_pmd_regions);
10141 #endif
10142 
10143 	switch (ret) {
10144 	case 0:
10145 		break;
10146 	case -ENOTSUP:
10147 		printf("function not implemented or supported\n");
10148 		break;
10149 	default:
10150 		printf("queue region config info show error: (%s)\n",
10151 				strerror(-ret));
10152 	}
10153 }
10154 
10155 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
10156 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10157 				show, "show");
10158 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
10159 	TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10160 				port, "port");
10161 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
10162 	TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
10163 				port_id, UINT16);
10164 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
10165 	TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10166 				cmd, "queue-region");
10167 
10168 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
10169 	.f = cmd_show_queue_region_info_parsed,
10170 	.data = NULL,
10171 	.help_str = "show port <port_id> queue-region"
10172 		": show all queue region related configuration info",
10173 	.tokens = {
10174 		(void *)&cmd_show_queue_region_info_get,
10175 		(void *)&cmd_show_queue_region_info_port,
10176 		(void *)&cmd_show_queue_region_info_port_index,
10177 		(void *)&cmd_show_queue_region_info_cmd,
10178 		NULL,
10179 	},
10180 };
10181 
10182 /* *** ADD/REMOVE A 2tuple FILTER *** */
10183 struct cmd_2tuple_filter_result {
10184 	cmdline_fixed_string_t filter;
10185 	portid_t port_id;
10186 	cmdline_fixed_string_t ops;
10187 	cmdline_fixed_string_t dst_port;
10188 	uint16_t dst_port_value;
10189 	cmdline_fixed_string_t protocol;
10190 	uint8_t protocol_value;
10191 	cmdline_fixed_string_t mask;
10192 	uint8_t  mask_value;
10193 	cmdline_fixed_string_t tcp_flags;
10194 	uint8_t tcp_flags_value;
10195 	cmdline_fixed_string_t priority;
10196 	uint8_t  priority_value;
10197 	cmdline_fixed_string_t queue;
10198 	uint16_t  queue_id;
10199 };
10200 
10201 static void
10202 cmd_2tuple_filter_parsed(void *parsed_result,
10203 			__attribute__((unused)) struct cmdline *cl,
10204 			__attribute__((unused)) void *data)
10205 {
10206 	struct rte_eth_ntuple_filter filter;
10207 	struct cmd_2tuple_filter_result *res = parsed_result;
10208 	int ret = 0;
10209 
10210 	ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
10211 	if (ret < 0) {
10212 		printf("ntuple filter is not supported on port %u.\n",
10213 			res->port_id);
10214 		return;
10215 	}
10216 
10217 	memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
10218 
10219 	filter.flags = RTE_2TUPLE_FLAGS;
10220 	filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
10221 	filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
10222 	filter.proto = res->protocol_value;
10223 	filter.priority = res->priority_value;
10224 	if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
10225 		printf("nonzero tcp_flags is only meaningful"
10226 			" when protocol is TCP.\n");
10227 		return;
10228 	}
10229 	if (res->tcp_flags_value > RTE_NTUPLE_TCP_FLAGS_MASK) {
10230 		printf("invalid TCP flags.\n");
10231 		return;
10232 	}
10233 
10234 	if (res->tcp_flags_value != 0) {
10235 		filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
10236 		filter.tcp_flags = res->tcp_flags_value;
10237 	}
10238 
10239 	/* need convert to big endian. */
10240 	filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
10241 	filter.queue = res->queue_id;
10242 
10243 	if (!strcmp(res->ops, "add"))
10244 		ret = rte_eth_dev_filter_ctrl(res->port_id,
10245 				RTE_ETH_FILTER_NTUPLE,
10246 				RTE_ETH_FILTER_ADD,
10247 				&filter);
10248 	else
10249 		ret = rte_eth_dev_filter_ctrl(res->port_id,
10250 				RTE_ETH_FILTER_NTUPLE,
10251 				RTE_ETH_FILTER_DELETE,
10252 				&filter);
10253 	if (ret < 0)
10254 		printf("2tuple filter programming error: (%s)\n",
10255 			strerror(-ret));
10256 
10257 }
10258 
10259 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
10260 	TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10261 				 filter, "2tuple_filter");
10262 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
10263 	TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10264 				port_id, UINT16);
10265 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
10266 	TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10267 				 ops, "add#del");
10268 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
10269 	TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10270 				dst_port, "dst_port");
10271 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
10272 	TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10273 				dst_port_value, UINT16);
10274 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
10275 	TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10276 				protocol, "protocol");
10277 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
10278 	TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10279 				protocol_value, UINT8);
10280 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
10281 	TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10282 				mask, "mask");
10283 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
10284 	TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10285 				mask_value, INT8);
10286 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
10287 	TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10288 				tcp_flags, "tcp_flags");
10289 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
10290 	TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10291 				tcp_flags_value, UINT8);
10292 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
10293 	TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10294 				priority, "priority");
10295 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
10296 	TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10297 				priority_value, UINT8);
10298 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
10299 	TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10300 				queue, "queue");
10301 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
10302 	TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10303 				queue_id, UINT16);
10304 
10305 cmdline_parse_inst_t cmd_2tuple_filter = {
10306 	.f = cmd_2tuple_filter_parsed,
10307 	.data = NULL,
10308 	.help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
10309 		"<value> mask <value> tcp_flags <value> priority <value> queue "
10310 		"<queue_id>: Add a 2tuple filter",
10311 	.tokens = {
10312 		(void *)&cmd_2tuple_filter_filter,
10313 		(void *)&cmd_2tuple_filter_port_id,
10314 		(void *)&cmd_2tuple_filter_ops,
10315 		(void *)&cmd_2tuple_filter_dst_port,
10316 		(void *)&cmd_2tuple_filter_dst_port_value,
10317 		(void *)&cmd_2tuple_filter_protocol,
10318 		(void *)&cmd_2tuple_filter_protocol_value,
10319 		(void *)&cmd_2tuple_filter_mask,
10320 		(void *)&cmd_2tuple_filter_mask_value,
10321 		(void *)&cmd_2tuple_filter_tcp_flags,
10322 		(void *)&cmd_2tuple_filter_tcp_flags_value,
10323 		(void *)&cmd_2tuple_filter_priority,
10324 		(void *)&cmd_2tuple_filter_priority_value,
10325 		(void *)&cmd_2tuple_filter_queue,
10326 		(void *)&cmd_2tuple_filter_queue_id,
10327 		NULL,
10328 	},
10329 };
10330 
10331 /* *** ADD/REMOVE A 5tuple FILTER *** */
10332 struct cmd_5tuple_filter_result {
10333 	cmdline_fixed_string_t filter;
10334 	portid_t port_id;
10335 	cmdline_fixed_string_t ops;
10336 	cmdline_fixed_string_t dst_ip;
10337 	cmdline_ipaddr_t dst_ip_value;
10338 	cmdline_fixed_string_t src_ip;
10339 	cmdline_ipaddr_t src_ip_value;
10340 	cmdline_fixed_string_t dst_port;
10341 	uint16_t dst_port_value;
10342 	cmdline_fixed_string_t src_port;
10343 	uint16_t src_port_value;
10344 	cmdline_fixed_string_t protocol;
10345 	uint8_t protocol_value;
10346 	cmdline_fixed_string_t mask;
10347 	uint8_t  mask_value;
10348 	cmdline_fixed_string_t tcp_flags;
10349 	uint8_t tcp_flags_value;
10350 	cmdline_fixed_string_t priority;
10351 	uint8_t  priority_value;
10352 	cmdline_fixed_string_t queue;
10353 	uint16_t  queue_id;
10354 };
10355 
10356 static void
10357 cmd_5tuple_filter_parsed(void *parsed_result,
10358 			__attribute__((unused)) struct cmdline *cl,
10359 			__attribute__((unused)) void *data)
10360 {
10361 	struct rte_eth_ntuple_filter filter;
10362 	struct cmd_5tuple_filter_result *res = parsed_result;
10363 	int ret = 0;
10364 
10365 	ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
10366 	if (ret < 0) {
10367 		printf("ntuple filter is not supported on port %u.\n",
10368 			res->port_id);
10369 		return;
10370 	}
10371 
10372 	memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
10373 
10374 	filter.flags = RTE_5TUPLE_FLAGS;
10375 	filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
10376 	filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
10377 	filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
10378 	filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
10379 	filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
10380 	filter.proto = res->protocol_value;
10381 	filter.priority = res->priority_value;
10382 	if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
10383 		printf("nonzero tcp_flags is only meaningful"
10384 			" when protocol is TCP.\n");
10385 		return;
10386 	}
10387 	if (res->tcp_flags_value > RTE_NTUPLE_TCP_FLAGS_MASK) {
10388 		printf("invalid TCP flags.\n");
10389 		return;
10390 	}
10391 
10392 	if (res->tcp_flags_value != 0) {
10393 		filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
10394 		filter.tcp_flags = res->tcp_flags_value;
10395 	}
10396 
10397 	if (res->dst_ip_value.family == AF_INET)
10398 		/* no need to convert, already big endian. */
10399 		filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
10400 	else {
10401 		if (filter.dst_ip_mask == 0) {
10402 			printf("can not support ipv6 involved compare.\n");
10403 			return;
10404 		}
10405 		filter.dst_ip = 0;
10406 	}
10407 
10408 	if (res->src_ip_value.family == AF_INET)
10409 		/* no need to convert, already big endian. */
10410 		filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
10411 	else {
10412 		if (filter.src_ip_mask == 0) {
10413 			printf("can not support ipv6 involved compare.\n");
10414 			return;
10415 		}
10416 		filter.src_ip = 0;
10417 	}
10418 	/* need convert to big endian. */
10419 	filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
10420 	filter.src_port = rte_cpu_to_be_16(res->src_port_value);
10421 	filter.queue = res->queue_id;
10422 
10423 	if (!strcmp(res->ops, "add"))
10424 		ret = rte_eth_dev_filter_ctrl(res->port_id,
10425 				RTE_ETH_FILTER_NTUPLE,
10426 				RTE_ETH_FILTER_ADD,
10427 				&filter);
10428 	else
10429 		ret = rte_eth_dev_filter_ctrl(res->port_id,
10430 				RTE_ETH_FILTER_NTUPLE,
10431 				RTE_ETH_FILTER_DELETE,
10432 				&filter);
10433 	if (ret < 0)
10434 		printf("5tuple filter programming error: (%s)\n",
10435 			strerror(-ret));
10436 }
10437 
10438 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
10439 	TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10440 				 filter, "5tuple_filter");
10441 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
10442 	TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10443 				port_id, UINT16);
10444 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
10445 	TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10446 				 ops, "add#del");
10447 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
10448 	TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10449 				dst_ip, "dst_ip");
10450 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
10451 	TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10452 				dst_ip_value);
10453 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
10454 	TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10455 				src_ip, "src_ip");
10456 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
10457 	TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10458 				src_ip_value);
10459 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
10460 	TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10461 				dst_port, "dst_port");
10462 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
10463 	TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10464 				dst_port_value, UINT16);
10465 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
10466 	TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10467 				src_port, "src_port");
10468 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
10469 	TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10470 				src_port_value, UINT16);
10471 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
10472 	TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10473 				protocol, "protocol");
10474 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
10475 	TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10476 				protocol_value, UINT8);
10477 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
10478 	TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10479 				mask, "mask");
10480 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
10481 	TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10482 				mask_value, INT8);
10483 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
10484 	TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10485 				tcp_flags, "tcp_flags");
10486 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
10487 	TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10488 				tcp_flags_value, UINT8);
10489 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
10490 	TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10491 				priority, "priority");
10492 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
10493 	TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10494 				priority_value, UINT8);
10495 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
10496 	TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10497 				queue, "queue");
10498 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
10499 	TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10500 				queue_id, UINT16);
10501 
10502 cmdline_parse_inst_t cmd_5tuple_filter = {
10503 	.f = cmd_5tuple_filter_parsed,
10504 	.data = NULL,
10505 	.help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
10506 		"src_ip <value> dst_port <value> src_port <value> "
10507 		"protocol <value>  mask <value> tcp_flags <value> "
10508 		"priority <value> queue <queue_id>: Add/Del a 5tuple filter",
10509 	.tokens = {
10510 		(void *)&cmd_5tuple_filter_filter,
10511 		(void *)&cmd_5tuple_filter_port_id,
10512 		(void *)&cmd_5tuple_filter_ops,
10513 		(void *)&cmd_5tuple_filter_dst_ip,
10514 		(void *)&cmd_5tuple_filter_dst_ip_value,
10515 		(void *)&cmd_5tuple_filter_src_ip,
10516 		(void *)&cmd_5tuple_filter_src_ip_value,
10517 		(void *)&cmd_5tuple_filter_dst_port,
10518 		(void *)&cmd_5tuple_filter_dst_port_value,
10519 		(void *)&cmd_5tuple_filter_src_port,
10520 		(void *)&cmd_5tuple_filter_src_port_value,
10521 		(void *)&cmd_5tuple_filter_protocol,
10522 		(void *)&cmd_5tuple_filter_protocol_value,
10523 		(void *)&cmd_5tuple_filter_mask,
10524 		(void *)&cmd_5tuple_filter_mask_value,
10525 		(void *)&cmd_5tuple_filter_tcp_flags,
10526 		(void *)&cmd_5tuple_filter_tcp_flags_value,
10527 		(void *)&cmd_5tuple_filter_priority,
10528 		(void *)&cmd_5tuple_filter_priority_value,
10529 		(void *)&cmd_5tuple_filter_queue,
10530 		(void *)&cmd_5tuple_filter_queue_id,
10531 		NULL,
10532 	},
10533 };
10534 
10535 /* *** ADD/REMOVE A flex FILTER *** */
10536 struct cmd_flex_filter_result {
10537 	cmdline_fixed_string_t filter;
10538 	cmdline_fixed_string_t ops;
10539 	portid_t port_id;
10540 	cmdline_fixed_string_t len;
10541 	uint8_t len_value;
10542 	cmdline_fixed_string_t bytes;
10543 	cmdline_fixed_string_t bytes_value;
10544 	cmdline_fixed_string_t mask;
10545 	cmdline_fixed_string_t mask_value;
10546 	cmdline_fixed_string_t priority;
10547 	uint8_t priority_value;
10548 	cmdline_fixed_string_t queue;
10549 	uint16_t queue_id;
10550 };
10551 
10552 static int xdigit2val(unsigned char c)
10553 {
10554 	int val;
10555 	if (isdigit(c))
10556 		val = c - '0';
10557 	else if (isupper(c))
10558 		val = c - 'A' + 10;
10559 	else
10560 		val = c - 'a' + 10;
10561 	return val;
10562 }
10563 
10564 static void
10565 cmd_flex_filter_parsed(void *parsed_result,
10566 			  __attribute__((unused)) struct cmdline *cl,
10567 			  __attribute__((unused)) void *data)
10568 {
10569 	int ret = 0;
10570 	struct rte_eth_flex_filter filter;
10571 	struct cmd_flex_filter_result *res = parsed_result;
10572 	char *bytes_ptr, *mask_ptr;
10573 	uint16_t len, i, j = 0;
10574 	char c;
10575 	int val;
10576 	uint8_t byte = 0;
10577 
10578 	if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
10579 		printf("the len exceed the max length 128\n");
10580 		return;
10581 	}
10582 	memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
10583 	filter.len = res->len_value;
10584 	filter.priority = res->priority_value;
10585 	filter.queue = res->queue_id;
10586 	bytes_ptr = res->bytes_value;
10587 	mask_ptr = res->mask_value;
10588 
10589 	 /* translate bytes string to array. */
10590 	if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
10591 		(bytes_ptr[1] == 'X')))
10592 		bytes_ptr += 2;
10593 	len = strnlen(bytes_ptr, res->len_value * 2);
10594 	if (len == 0 || (len % 8 != 0)) {
10595 		printf("please check len and bytes input\n");
10596 		return;
10597 	}
10598 	for (i = 0; i < len; i++) {
10599 		c = bytes_ptr[i];
10600 		if (isxdigit(c) == 0) {
10601 			/* invalid characters. */
10602 			printf("invalid input\n");
10603 			return;
10604 		}
10605 		val = xdigit2val(c);
10606 		if (i % 2) {
10607 			byte |= val;
10608 			filter.bytes[j] = byte;
10609 			printf("bytes[%d]:%02x ", j, filter.bytes[j]);
10610 			j++;
10611 			byte = 0;
10612 		} else
10613 			byte |= val << 4;
10614 	}
10615 	printf("\n");
10616 	 /* translate mask string to uint8_t array. */
10617 	if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
10618 		(mask_ptr[1] == 'X')))
10619 		mask_ptr += 2;
10620 	len = strnlen(mask_ptr, (res->len_value + 3) / 4);
10621 	if (len == 0) {
10622 		printf("invalid input\n");
10623 		return;
10624 	}
10625 	j = 0;
10626 	byte = 0;
10627 	for (i = 0; i < len; i++) {
10628 		c = mask_ptr[i];
10629 		if (isxdigit(c) == 0) {
10630 			/* invalid characters. */
10631 			printf("invalid input\n");
10632 			return;
10633 		}
10634 		val = xdigit2val(c);
10635 		if (i % 2) {
10636 			byte |= val;
10637 			filter.mask[j] = byte;
10638 			printf("mask[%d]:%02x ", j, filter.mask[j]);
10639 			j++;
10640 			byte = 0;
10641 		} else
10642 			byte |= val << 4;
10643 	}
10644 	printf("\n");
10645 
10646 	if (!strcmp(res->ops, "add"))
10647 		ret = rte_eth_dev_filter_ctrl(res->port_id,
10648 				RTE_ETH_FILTER_FLEXIBLE,
10649 				RTE_ETH_FILTER_ADD,
10650 				&filter);
10651 	else
10652 		ret = rte_eth_dev_filter_ctrl(res->port_id,
10653 				RTE_ETH_FILTER_FLEXIBLE,
10654 				RTE_ETH_FILTER_DELETE,
10655 				&filter);
10656 
10657 	if (ret < 0)
10658 		printf("flex filter setting error: (%s)\n", strerror(-ret));
10659 }
10660 
10661 cmdline_parse_token_string_t cmd_flex_filter_filter =
10662 	TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10663 				filter, "flex_filter");
10664 cmdline_parse_token_num_t cmd_flex_filter_port_id =
10665 	TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10666 				port_id, UINT16);
10667 cmdline_parse_token_string_t cmd_flex_filter_ops =
10668 	TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10669 				ops, "add#del");
10670 cmdline_parse_token_string_t cmd_flex_filter_len =
10671 	TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10672 				len, "len");
10673 cmdline_parse_token_num_t cmd_flex_filter_len_value =
10674 	TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10675 				len_value, UINT8);
10676 cmdline_parse_token_string_t cmd_flex_filter_bytes =
10677 	TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10678 				bytes, "bytes");
10679 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
10680 	TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10681 				bytes_value, NULL);
10682 cmdline_parse_token_string_t cmd_flex_filter_mask =
10683 	TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10684 				mask, "mask");
10685 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
10686 	TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10687 				mask_value, NULL);
10688 cmdline_parse_token_string_t cmd_flex_filter_priority =
10689 	TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10690 				priority, "priority");
10691 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
10692 	TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10693 				priority_value, UINT8);
10694 cmdline_parse_token_string_t cmd_flex_filter_queue =
10695 	TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10696 				queue, "queue");
10697 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
10698 	TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10699 				queue_id, UINT16);
10700 cmdline_parse_inst_t cmd_flex_filter = {
10701 	.f = cmd_flex_filter_parsed,
10702 	.data = NULL,
10703 	.help_str = "flex_filter <port_id> add|del len <value> bytes "
10704 		"<value> mask <value> priority <value> queue <queue_id>: "
10705 		"Add/Del a flex filter",
10706 	.tokens = {
10707 		(void *)&cmd_flex_filter_filter,
10708 		(void *)&cmd_flex_filter_port_id,
10709 		(void *)&cmd_flex_filter_ops,
10710 		(void *)&cmd_flex_filter_len,
10711 		(void *)&cmd_flex_filter_len_value,
10712 		(void *)&cmd_flex_filter_bytes,
10713 		(void *)&cmd_flex_filter_bytes_value,
10714 		(void *)&cmd_flex_filter_mask,
10715 		(void *)&cmd_flex_filter_mask_value,
10716 		(void *)&cmd_flex_filter_priority,
10717 		(void *)&cmd_flex_filter_priority_value,
10718 		(void *)&cmd_flex_filter_queue,
10719 		(void *)&cmd_flex_filter_queue_id,
10720 		NULL,
10721 	},
10722 };
10723 
10724 /* *** Filters Control *** */
10725 
10726 /* *** deal with ethertype filter *** */
10727 struct cmd_ethertype_filter_result {
10728 	cmdline_fixed_string_t filter;
10729 	portid_t port_id;
10730 	cmdline_fixed_string_t ops;
10731 	cmdline_fixed_string_t mac;
10732 	struct rte_ether_addr mac_addr;
10733 	cmdline_fixed_string_t ethertype;
10734 	uint16_t ethertype_value;
10735 	cmdline_fixed_string_t drop;
10736 	cmdline_fixed_string_t queue;
10737 	uint16_t  queue_id;
10738 };
10739 
10740 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
10741 	TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10742 				 filter, "ethertype_filter");
10743 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
10744 	TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10745 			      port_id, UINT16);
10746 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
10747 	TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10748 				 ops, "add#del");
10749 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
10750 	TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10751 				 mac, "mac_addr#mac_ignr");
10752 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
10753 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
10754 				     mac_addr);
10755 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
10756 	TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10757 				 ethertype, "ethertype");
10758 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
10759 	TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10760 			      ethertype_value, UINT16);
10761 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
10762 	TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10763 				 drop, "drop#fwd");
10764 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
10765 	TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10766 				 queue, "queue");
10767 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
10768 	TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10769 			      queue_id, UINT16);
10770 
10771 static void
10772 cmd_ethertype_filter_parsed(void *parsed_result,
10773 			  __attribute__((unused)) struct cmdline *cl,
10774 			  __attribute__((unused)) void *data)
10775 {
10776 	struct cmd_ethertype_filter_result *res = parsed_result;
10777 	struct rte_eth_ethertype_filter filter;
10778 	int ret = 0;
10779 
10780 	ret = rte_eth_dev_filter_supported(res->port_id,
10781 			RTE_ETH_FILTER_ETHERTYPE);
10782 	if (ret < 0) {
10783 		printf("ethertype filter is not supported on port %u.\n",
10784 			res->port_id);
10785 		return;
10786 	}
10787 
10788 	memset(&filter, 0, sizeof(filter));
10789 	if (!strcmp(res->mac, "mac_addr")) {
10790 		filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
10791 		rte_memcpy(&filter.mac_addr, &res->mac_addr,
10792 			sizeof(struct rte_ether_addr));
10793 	}
10794 	if (!strcmp(res->drop, "drop"))
10795 		filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
10796 	filter.ether_type = res->ethertype_value;
10797 	filter.queue = res->queue_id;
10798 
10799 	if (!strcmp(res->ops, "add"))
10800 		ret = rte_eth_dev_filter_ctrl(res->port_id,
10801 				RTE_ETH_FILTER_ETHERTYPE,
10802 				RTE_ETH_FILTER_ADD,
10803 				&filter);
10804 	else
10805 		ret = rte_eth_dev_filter_ctrl(res->port_id,
10806 				RTE_ETH_FILTER_ETHERTYPE,
10807 				RTE_ETH_FILTER_DELETE,
10808 				&filter);
10809 	if (ret < 0)
10810 		printf("ethertype filter programming error: (%s)\n",
10811 			strerror(-ret));
10812 }
10813 
10814 cmdline_parse_inst_t cmd_ethertype_filter = {
10815 	.f = cmd_ethertype_filter_parsed,
10816 	.data = NULL,
10817 	.help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
10818 		"<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
10819 		"Add or delete an ethertype filter entry",
10820 	.tokens = {
10821 		(void *)&cmd_ethertype_filter_filter,
10822 		(void *)&cmd_ethertype_filter_port_id,
10823 		(void *)&cmd_ethertype_filter_ops,
10824 		(void *)&cmd_ethertype_filter_mac,
10825 		(void *)&cmd_ethertype_filter_mac_addr,
10826 		(void *)&cmd_ethertype_filter_ethertype,
10827 		(void *)&cmd_ethertype_filter_ethertype_value,
10828 		(void *)&cmd_ethertype_filter_drop,
10829 		(void *)&cmd_ethertype_filter_queue,
10830 		(void *)&cmd_ethertype_filter_queue_id,
10831 		NULL,
10832 	},
10833 };
10834 
10835 /* *** deal with flow director filter *** */
10836 struct cmd_flow_director_result {
10837 	cmdline_fixed_string_t flow_director_filter;
10838 	portid_t port_id;
10839 	cmdline_fixed_string_t mode;
10840 	cmdline_fixed_string_t mode_value;
10841 	cmdline_fixed_string_t ops;
10842 	cmdline_fixed_string_t flow;
10843 	cmdline_fixed_string_t flow_type;
10844 	cmdline_fixed_string_t ether;
10845 	uint16_t ether_type;
10846 	cmdline_fixed_string_t src;
10847 	cmdline_ipaddr_t ip_src;
10848 	uint16_t port_src;
10849 	cmdline_fixed_string_t dst;
10850 	cmdline_ipaddr_t ip_dst;
10851 	uint16_t port_dst;
10852 	cmdline_fixed_string_t verify_tag;
10853 	uint32_t verify_tag_value;
10854 	cmdline_fixed_string_t tos;
10855 	uint8_t tos_value;
10856 	cmdline_fixed_string_t proto;
10857 	uint8_t proto_value;
10858 	cmdline_fixed_string_t ttl;
10859 	uint8_t ttl_value;
10860 	cmdline_fixed_string_t vlan;
10861 	uint16_t vlan_value;
10862 	cmdline_fixed_string_t flexbytes;
10863 	cmdline_fixed_string_t flexbytes_value;
10864 	cmdline_fixed_string_t pf_vf;
10865 	cmdline_fixed_string_t drop;
10866 	cmdline_fixed_string_t queue;
10867 	uint16_t  queue_id;
10868 	cmdline_fixed_string_t fd_id;
10869 	uint32_t  fd_id_value;
10870 	cmdline_fixed_string_t mac;
10871 	struct rte_ether_addr mac_addr;
10872 	cmdline_fixed_string_t tunnel;
10873 	cmdline_fixed_string_t tunnel_type;
10874 	cmdline_fixed_string_t tunnel_id;
10875 	uint32_t tunnel_id_value;
10876 	cmdline_fixed_string_t packet;
10877 	char filepath[];
10878 };
10879 
10880 static inline int
10881 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
10882 {
10883 	char s[256];
10884 	const char *p, *p0 = q_arg;
10885 	char *end;
10886 	unsigned long int_fld;
10887 	char *str_fld[max_num];
10888 	int i;
10889 	unsigned size;
10890 	int ret = -1;
10891 
10892 	p = strchr(p0, '(');
10893 	if (p == NULL)
10894 		return -1;
10895 	++p;
10896 	p0 = strchr(p, ')');
10897 	if (p0 == NULL)
10898 		return -1;
10899 
10900 	size = p0 - p;
10901 	if (size >= sizeof(s))
10902 		return -1;
10903 
10904 	snprintf(s, sizeof(s), "%.*s", size, p);
10905 	ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10906 	if (ret < 0 || ret > max_num)
10907 		return -1;
10908 	for (i = 0; i < ret; i++) {
10909 		errno = 0;
10910 		int_fld = strtoul(str_fld[i], &end, 0);
10911 		if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
10912 			return -1;
10913 		flexbytes[i] = (uint8_t)int_fld;
10914 	}
10915 	return ret;
10916 }
10917 
10918 static uint16_t
10919 str2flowtype(char *string)
10920 {
10921 	uint8_t i = 0;
10922 	static const struct {
10923 		char str[32];
10924 		uint16_t type;
10925 	} flowtype_str[] = {
10926 		{"raw", RTE_ETH_FLOW_RAW},
10927 		{"ipv4", RTE_ETH_FLOW_IPV4},
10928 		{"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10929 		{"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10930 		{"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10931 		{"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10932 		{"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10933 		{"ipv6", RTE_ETH_FLOW_IPV6},
10934 		{"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10935 		{"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10936 		{"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10937 		{"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10938 		{"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10939 		{"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10940 	};
10941 
10942 	for (i = 0; i < RTE_DIM(flowtype_str); i++) {
10943 		if (!strcmp(flowtype_str[i].str, string))
10944 			return flowtype_str[i].type;
10945 	}
10946 
10947 	if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
10948 		return (uint16_t)atoi(string);
10949 
10950 	return RTE_ETH_FLOW_UNKNOWN;
10951 }
10952 
10953 static enum rte_eth_fdir_tunnel_type
10954 str2fdir_tunneltype(char *string)
10955 {
10956 	uint8_t i = 0;
10957 
10958 	static const struct {
10959 		char str[32];
10960 		enum rte_eth_fdir_tunnel_type type;
10961 	} tunneltype_str[] = {
10962 		{"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
10963 		{"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
10964 	};
10965 
10966 	for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
10967 		if (!strcmp(tunneltype_str[i].str, string))
10968 			return tunneltype_str[i].type;
10969 	}
10970 	return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
10971 }
10972 
10973 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10974 do { \
10975 	if ((ip_addr).family == AF_INET) \
10976 		(ip) = (ip_addr).addr.ipv4.s_addr; \
10977 	else { \
10978 		printf("invalid parameter.\n"); \
10979 		return; \
10980 	} \
10981 } while (0)
10982 
10983 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10984 do { \
10985 	if ((ip_addr).family == AF_INET6) \
10986 		rte_memcpy(&(ip), \
10987 				 &((ip_addr).addr.ipv6), \
10988 				 sizeof(struct in6_addr)); \
10989 	else { \
10990 		printf("invalid parameter.\n"); \
10991 		return; \
10992 	} \
10993 } while (0)
10994 
10995 static void
10996 cmd_flow_director_filter_parsed(void *parsed_result,
10997 			  __attribute__((unused)) struct cmdline *cl,
10998 			  __attribute__((unused)) void *data)
10999 {
11000 	struct cmd_flow_director_result *res = parsed_result;
11001 	struct rte_eth_fdir_filter entry;
11002 	uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
11003 	char *end;
11004 	unsigned long vf_id;
11005 	int ret = 0;
11006 
11007 	ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
11008 	if (ret < 0) {
11009 		printf("flow director is not supported on port %u.\n",
11010 			res->port_id);
11011 		return;
11012 	}
11013 	memset(flexbytes, 0, sizeof(flexbytes));
11014 	memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
11015 
11016 	if (fdir_conf.mode ==  RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
11017 		if (strcmp(res->mode_value, "MAC-VLAN")) {
11018 			printf("Please set mode to MAC-VLAN.\n");
11019 			return;
11020 		}
11021 	} else if (fdir_conf.mode ==  RTE_FDIR_MODE_PERFECT_TUNNEL) {
11022 		if (strcmp(res->mode_value, "Tunnel")) {
11023 			printf("Please set mode to Tunnel.\n");
11024 			return;
11025 		}
11026 	} else {
11027 		if (!strcmp(res->mode_value, "raw")) {
11028 #ifdef RTE_LIBRTE_I40E_PMD
11029 			struct rte_pmd_i40e_flow_type_mapping
11030 					mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
11031 			struct rte_pmd_i40e_pkt_template_conf conf;
11032 			uint16_t flow_type = str2flowtype(res->flow_type);
11033 			uint16_t i, port = res->port_id;
11034 			uint8_t add;
11035 
11036 			memset(&conf, 0, sizeof(conf));
11037 
11038 			if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
11039 				printf("Invalid flow type specified.\n");
11040 				return;
11041 			}
11042 			ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
11043 								 mapping);
11044 			if (ret)
11045 				return;
11046 			if (mapping[flow_type].pctype == 0ULL) {
11047 				printf("Invalid flow type specified.\n");
11048 				return;
11049 			}
11050 			for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
11051 				if (mapping[flow_type].pctype & (1ULL << i)) {
11052 					conf.input.pctype = i;
11053 					break;
11054 				}
11055 			}
11056 
11057 			conf.input.packet = open_file(res->filepath,
11058 						&conf.input.length);
11059 			if (!conf.input.packet)
11060 				return;
11061 			if (!strcmp(res->drop, "drop"))
11062 				conf.action.behavior =
11063 					RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
11064 			else
11065 				conf.action.behavior =
11066 					RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
11067 			conf.action.report_status =
11068 					RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
11069 			conf.action.rx_queue = res->queue_id;
11070 			conf.soft_id = res->fd_id_value;
11071 			add  = strcmp(res->ops, "del") ? 1 : 0;
11072 			ret = rte_pmd_i40e_flow_add_del_packet_template(port,
11073 									&conf,
11074 									add);
11075 			if (ret < 0)
11076 				printf("flow director config error: (%s)\n",
11077 				       strerror(-ret));
11078 			close_file(conf.input.packet);
11079 #endif
11080 			return;
11081 		} else if (strcmp(res->mode_value, "IP")) {
11082 			printf("Please set mode to IP or raw.\n");
11083 			return;
11084 		}
11085 		entry.input.flow_type = str2flowtype(res->flow_type);
11086 	}
11087 
11088 	ret = parse_flexbytes(res->flexbytes_value,
11089 					flexbytes,
11090 					RTE_ETH_FDIR_MAX_FLEXLEN);
11091 	if (ret < 0) {
11092 		printf("error: Cannot parse flexbytes input.\n");
11093 		return;
11094 	}
11095 
11096 	switch (entry.input.flow_type) {
11097 	case RTE_ETH_FLOW_FRAG_IPV4:
11098 	case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
11099 		entry.input.flow.ip4_flow.proto = res->proto_value;
11100 		/* fall-through */
11101 	case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
11102 	case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
11103 		IPV4_ADDR_TO_UINT(res->ip_dst,
11104 			entry.input.flow.ip4_flow.dst_ip);
11105 		IPV4_ADDR_TO_UINT(res->ip_src,
11106 			entry.input.flow.ip4_flow.src_ip);
11107 		entry.input.flow.ip4_flow.tos = res->tos_value;
11108 		entry.input.flow.ip4_flow.ttl = res->ttl_value;
11109 		/* need convert to big endian. */
11110 		entry.input.flow.udp4_flow.dst_port =
11111 				rte_cpu_to_be_16(res->port_dst);
11112 		entry.input.flow.udp4_flow.src_port =
11113 				rte_cpu_to_be_16(res->port_src);
11114 		break;
11115 	case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
11116 		IPV4_ADDR_TO_UINT(res->ip_dst,
11117 			entry.input.flow.sctp4_flow.ip.dst_ip);
11118 		IPV4_ADDR_TO_UINT(res->ip_src,
11119 			entry.input.flow.sctp4_flow.ip.src_ip);
11120 		entry.input.flow.ip4_flow.tos = res->tos_value;
11121 		entry.input.flow.ip4_flow.ttl = res->ttl_value;
11122 		/* need convert to big endian. */
11123 		entry.input.flow.sctp4_flow.dst_port =
11124 				rte_cpu_to_be_16(res->port_dst);
11125 		entry.input.flow.sctp4_flow.src_port =
11126 				rte_cpu_to_be_16(res->port_src);
11127 		entry.input.flow.sctp4_flow.verify_tag =
11128 				rte_cpu_to_be_32(res->verify_tag_value);
11129 		break;
11130 	case RTE_ETH_FLOW_FRAG_IPV6:
11131 	case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
11132 		entry.input.flow.ipv6_flow.proto = res->proto_value;
11133 		/* fall-through */
11134 	case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
11135 	case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
11136 		IPV6_ADDR_TO_ARRAY(res->ip_dst,
11137 			entry.input.flow.ipv6_flow.dst_ip);
11138 		IPV6_ADDR_TO_ARRAY(res->ip_src,
11139 			entry.input.flow.ipv6_flow.src_ip);
11140 		entry.input.flow.ipv6_flow.tc = res->tos_value;
11141 		entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
11142 		/* need convert to big endian. */
11143 		entry.input.flow.udp6_flow.dst_port =
11144 				rte_cpu_to_be_16(res->port_dst);
11145 		entry.input.flow.udp6_flow.src_port =
11146 				rte_cpu_to_be_16(res->port_src);
11147 		break;
11148 	case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
11149 		IPV6_ADDR_TO_ARRAY(res->ip_dst,
11150 			entry.input.flow.sctp6_flow.ip.dst_ip);
11151 		IPV6_ADDR_TO_ARRAY(res->ip_src,
11152 			entry.input.flow.sctp6_flow.ip.src_ip);
11153 		entry.input.flow.ipv6_flow.tc = res->tos_value;
11154 		entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
11155 		/* need convert to big endian. */
11156 		entry.input.flow.sctp6_flow.dst_port =
11157 				rte_cpu_to_be_16(res->port_dst);
11158 		entry.input.flow.sctp6_flow.src_port =
11159 				rte_cpu_to_be_16(res->port_src);
11160 		entry.input.flow.sctp6_flow.verify_tag =
11161 				rte_cpu_to_be_32(res->verify_tag_value);
11162 		break;
11163 	case RTE_ETH_FLOW_L2_PAYLOAD:
11164 		entry.input.flow.l2_flow.ether_type =
11165 			rte_cpu_to_be_16(res->ether_type);
11166 		break;
11167 	default:
11168 		break;
11169 	}
11170 
11171 	if (fdir_conf.mode ==  RTE_FDIR_MODE_PERFECT_MAC_VLAN)
11172 		rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
11173 				 &res->mac_addr,
11174 				 sizeof(struct rte_ether_addr));
11175 
11176 	if (fdir_conf.mode ==  RTE_FDIR_MODE_PERFECT_TUNNEL) {
11177 		rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
11178 				 &res->mac_addr,
11179 				 sizeof(struct rte_ether_addr));
11180 		entry.input.flow.tunnel_flow.tunnel_type =
11181 			str2fdir_tunneltype(res->tunnel_type);
11182 		entry.input.flow.tunnel_flow.tunnel_id =
11183 			rte_cpu_to_be_32(res->tunnel_id_value);
11184 	}
11185 
11186 	rte_memcpy(entry.input.flow_ext.flexbytes,
11187 		   flexbytes,
11188 		   RTE_ETH_FDIR_MAX_FLEXLEN);
11189 
11190 	entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
11191 
11192 	entry.action.flex_off = 0;  /*use 0 by default */
11193 	if (!strcmp(res->drop, "drop"))
11194 		entry.action.behavior = RTE_ETH_FDIR_REJECT;
11195 	else
11196 		entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
11197 
11198 	if (fdir_conf.mode !=  RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
11199 	    fdir_conf.mode !=  RTE_FDIR_MODE_PERFECT_TUNNEL) {
11200 		if (!strcmp(res->pf_vf, "pf"))
11201 			entry.input.flow_ext.is_vf = 0;
11202 		else if (!strncmp(res->pf_vf, "vf", 2)) {
11203 			struct rte_eth_dev_info dev_info;
11204 
11205 			ret = eth_dev_info_get_print_err(res->port_id,
11206 						&dev_info);
11207 			if (ret != 0)
11208 				return;
11209 
11210 			errno = 0;
11211 			vf_id = strtoul(res->pf_vf + 2, &end, 10);
11212 			if (errno != 0 || *end != '\0' ||
11213 			    vf_id >= dev_info.max_vfs) {
11214 				printf("invalid parameter %s.\n", res->pf_vf);
11215 				return;
11216 			}
11217 			entry.input.flow_ext.is_vf = 1;
11218 			entry.input.flow_ext.dst_id = (uint16_t)vf_id;
11219 		} else {
11220 			printf("invalid parameter %s.\n", res->pf_vf);
11221 			return;
11222 		}
11223 	}
11224 
11225 	/* set to report FD ID by default */
11226 	entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
11227 	entry.action.rx_queue = res->queue_id;
11228 	entry.soft_id = res->fd_id_value;
11229 	if (!strcmp(res->ops, "add"))
11230 		ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11231 					     RTE_ETH_FILTER_ADD, &entry);
11232 	else if (!strcmp(res->ops, "del"))
11233 		ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11234 					     RTE_ETH_FILTER_DELETE, &entry);
11235 	else
11236 		ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11237 					     RTE_ETH_FILTER_UPDATE, &entry);
11238 	if (ret < 0)
11239 		printf("flow director programming error: (%s)\n",
11240 			strerror(-ret));
11241 }
11242 
11243 cmdline_parse_token_string_t cmd_flow_director_filter =
11244 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11245 				 flow_director_filter, "flow_director_filter");
11246 cmdline_parse_token_num_t cmd_flow_director_port_id =
11247 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11248 			      port_id, UINT16);
11249 cmdline_parse_token_string_t cmd_flow_director_ops =
11250 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11251 				 ops, "add#del#update");
11252 cmdline_parse_token_string_t cmd_flow_director_flow =
11253 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11254 				 flow, "flow");
11255 cmdline_parse_token_string_t cmd_flow_director_flow_type =
11256 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11257 		flow_type, NULL);
11258 cmdline_parse_token_string_t cmd_flow_director_ether =
11259 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11260 				 ether, "ether");
11261 cmdline_parse_token_num_t cmd_flow_director_ether_type =
11262 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11263 			      ether_type, UINT16);
11264 cmdline_parse_token_string_t cmd_flow_director_src =
11265 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11266 				 src, "src");
11267 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
11268 	TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
11269 				 ip_src);
11270 cmdline_parse_token_num_t cmd_flow_director_port_src =
11271 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11272 			      port_src, UINT16);
11273 cmdline_parse_token_string_t cmd_flow_director_dst =
11274 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11275 				 dst, "dst");
11276 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
11277 	TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
11278 				 ip_dst);
11279 cmdline_parse_token_num_t cmd_flow_director_port_dst =
11280 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11281 			      port_dst, UINT16);
11282 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
11283 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11284 				  verify_tag, "verify_tag");
11285 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
11286 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11287 			      verify_tag_value, UINT32);
11288 cmdline_parse_token_string_t cmd_flow_director_tos =
11289 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11290 				 tos, "tos");
11291 cmdline_parse_token_num_t cmd_flow_director_tos_value =
11292 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11293 			      tos_value, UINT8);
11294 cmdline_parse_token_string_t cmd_flow_director_proto =
11295 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11296 				 proto, "proto");
11297 cmdline_parse_token_num_t cmd_flow_director_proto_value =
11298 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11299 			      proto_value, UINT8);
11300 cmdline_parse_token_string_t cmd_flow_director_ttl =
11301 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11302 				 ttl, "ttl");
11303 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
11304 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11305 			      ttl_value, UINT8);
11306 cmdline_parse_token_string_t cmd_flow_director_vlan =
11307 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11308 				 vlan, "vlan");
11309 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
11310 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11311 			      vlan_value, UINT16);
11312 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
11313 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11314 				 flexbytes, "flexbytes");
11315 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
11316 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11317 			      flexbytes_value, NULL);
11318 cmdline_parse_token_string_t cmd_flow_director_drop =
11319 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11320 				 drop, "drop#fwd");
11321 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
11322 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11323 			      pf_vf, NULL);
11324 cmdline_parse_token_string_t cmd_flow_director_queue =
11325 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11326 				 queue, "queue");
11327 cmdline_parse_token_num_t cmd_flow_director_queue_id =
11328 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11329 			      queue_id, UINT16);
11330 cmdline_parse_token_string_t cmd_flow_director_fd_id =
11331 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11332 				 fd_id, "fd_id");
11333 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
11334 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11335 			      fd_id_value, UINT32);
11336 
11337 cmdline_parse_token_string_t cmd_flow_director_mode =
11338 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11339 				 mode, "mode");
11340 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
11341 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11342 				 mode_value, "IP");
11343 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
11344 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11345 				 mode_value, "MAC-VLAN");
11346 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
11347 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11348 				 mode_value, "Tunnel");
11349 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
11350 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11351 				 mode_value, "raw");
11352 cmdline_parse_token_string_t cmd_flow_director_mac =
11353 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11354 				 mac, "mac");
11355 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
11356 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
11357 				    mac_addr);
11358 cmdline_parse_token_string_t cmd_flow_director_tunnel =
11359 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11360 				 tunnel, "tunnel");
11361 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
11362 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11363 				 tunnel_type, "NVGRE#VxLAN");
11364 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
11365 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11366 				 tunnel_id, "tunnel-id");
11367 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
11368 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11369 			      tunnel_id_value, UINT32);
11370 cmdline_parse_token_string_t cmd_flow_director_packet =
11371 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11372 				 packet, "packet");
11373 cmdline_parse_token_string_t cmd_flow_director_filepath =
11374 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11375 				 filepath, NULL);
11376 
11377 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
11378 	.f = cmd_flow_director_filter_parsed,
11379 	.data = NULL,
11380 	.help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
11381 		" ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
11382 		"ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
11383 		"l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
11384 		"proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
11385 		"flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> "
11386 		"fd_id <fd_id_value>: "
11387 		"Add or delete an ip flow director entry on NIC",
11388 	.tokens = {
11389 		(void *)&cmd_flow_director_filter,
11390 		(void *)&cmd_flow_director_port_id,
11391 		(void *)&cmd_flow_director_mode,
11392 		(void *)&cmd_flow_director_mode_ip,
11393 		(void *)&cmd_flow_director_ops,
11394 		(void *)&cmd_flow_director_flow,
11395 		(void *)&cmd_flow_director_flow_type,
11396 		(void *)&cmd_flow_director_src,
11397 		(void *)&cmd_flow_director_ip_src,
11398 		(void *)&cmd_flow_director_dst,
11399 		(void *)&cmd_flow_director_ip_dst,
11400 		(void *)&cmd_flow_director_tos,
11401 		(void *)&cmd_flow_director_tos_value,
11402 		(void *)&cmd_flow_director_proto,
11403 		(void *)&cmd_flow_director_proto_value,
11404 		(void *)&cmd_flow_director_ttl,
11405 		(void *)&cmd_flow_director_ttl_value,
11406 		(void *)&cmd_flow_director_vlan,
11407 		(void *)&cmd_flow_director_vlan_value,
11408 		(void *)&cmd_flow_director_flexbytes,
11409 		(void *)&cmd_flow_director_flexbytes_value,
11410 		(void *)&cmd_flow_director_drop,
11411 		(void *)&cmd_flow_director_pf_vf,
11412 		(void *)&cmd_flow_director_queue,
11413 		(void *)&cmd_flow_director_queue_id,
11414 		(void *)&cmd_flow_director_fd_id,
11415 		(void *)&cmd_flow_director_fd_id_value,
11416 		NULL,
11417 	},
11418 };
11419 
11420 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
11421 	.f = cmd_flow_director_filter_parsed,
11422 	.data = NULL,
11423 	.help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
11424 		"director entry on NIC",
11425 	.tokens = {
11426 		(void *)&cmd_flow_director_filter,
11427 		(void *)&cmd_flow_director_port_id,
11428 		(void *)&cmd_flow_director_mode,
11429 		(void *)&cmd_flow_director_mode_ip,
11430 		(void *)&cmd_flow_director_ops,
11431 		(void *)&cmd_flow_director_flow,
11432 		(void *)&cmd_flow_director_flow_type,
11433 		(void *)&cmd_flow_director_src,
11434 		(void *)&cmd_flow_director_ip_src,
11435 		(void *)&cmd_flow_director_port_src,
11436 		(void *)&cmd_flow_director_dst,
11437 		(void *)&cmd_flow_director_ip_dst,
11438 		(void *)&cmd_flow_director_port_dst,
11439 		(void *)&cmd_flow_director_tos,
11440 		(void *)&cmd_flow_director_tos_value,
11441 		(void *)&cmd_flow_director_ttl,
11442 		(void *)&cmd_flow_director_ttl_value,
11443 		(void *)&cmd_flow_director_vlan,
11444 		(void *)&cmd_flow_director_vlan_value,
11445 		(void *)&cmd_flow_director_flexbytes,
11446 		(void *)&cmd_flow_director_flexbytes_value,
11447 		(void *)&cmd_flow_director_drop,
11448 		(void *)&cmd_flow_director_pf_vf,
11449 		(void *)&cmd_flow_director_queue,
11450 		(void *)&cmd_flow_director_queue_id,
11451 		(void *)&cmd_flow_director_fd_id,
11452 		(void *)&cmd_flow_director_fd_id_value,
11453 		NULL,
11454 	},
11455 };
11456 
11457 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
11458 	.f = cmd_flow_director_filter_parsed,
11459 	.data = NULL,
11460 	.help_str = "flow_director_filter ... : Add or delete a sctp flow "
11461 		"director entry on NIC",
11462 	.tokens = {
11463 		(void *)&cmd_flow_director_filter,
11464 		(void *)&cmd_flow_director_port_id,
11465 		(void *)&cmd_flow_director_mode,
11466 		(void *)&cmd_flow_director_mode_ip,
11467 		(void *)&cmd_flow_director_ops,
11468 		(void *)&cmd_flow_director_flow,
11469 		(void *)&cmd_flow_director_flow_type,
11470 		(void *)&cmd_flow_director_src,
11471 		(void *)&cmd_flow_director_ip_src,
11472 		(void *)&cmd_flow_director_port_src,
11473 		(void *)&cmd_flow_director_dst,
11474 		(void *)&cmd_flow_director_ip_dst,
11475 		(void *)&cmd_flow_director_port_dst,
11476 		(void *)&cmd_flow_director_verify_tag,
11477 		(void *)&cmd_flow_director_verify_tag_value,
11478 		(void *)&cmd_flow_director_tos,
11479 		(void *)&cmd_flow_director_tos_value,
11480 		(void *)&cmd_flow_director_ttl,
11481 		(void *)&cmd_flow_director_ttl_value,
11482 		(void *)&cmd_flow_director_vlan,
11483 		(void *)&cmd_flow_director_vlan_value,
11484 		(void *)&cmd_flow_director_flexbytes,
11485 		(void *)&cmd_flow_director_flexbytes_value,
11486 		(void *)&cmd_flow_director_drop,
11487 		(void *)&cmd_flow_director_pf_vf,
11488 		(void *)&cmd_flow_director_queue,
11489 		(void *)&cmd_flow_director_queue_id,
11490 		(void *)&cmd_flow_director_fd_id,
11491 		(void *)&cmd_flow_director_fd_id_value,
11492 		NULL,
11493 	},
11494 };
11495 
11496 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
11497 	.f = cmd_flow_director_filter_parsed,
11498 	.data = NULL,
11499 	.help_str = "flow_director_filter ... : Add or delete a L2 flow "
11500 		"director entry on NIC",
11501 	.tokens = {
11502 		(void *)&cmd_flow_director_filter,
11503 		(void *)&cmd_flow_director_port_id,
11504 		(void *)&cmd_flow_director_mode,
11505 		(void *)&cmd_flow_director_mode_ip,
11506 		(void *)&cmd_flow_director_ops,
11507 		(void *)&cmd_flow_director_flow,
11508 		(void *)&cmd_flow_director_flow_type,
11509 		(void *)&cmd_flow_director_ether,
11510 		(void *)&cmd_flow_director_ether_type,
11511 		(void *)&cmd_flow_director_flexbytes,
11512 		(void *)&cmd_flow_director_flexbytes_value,
11513 		(void *)&cmd_flow_director_drop,
11514 		(void *)&cmd_flow_director_pf_vf,
11515 		(void *)&cmd_flow_director_queue,
11516 		(void *)&cmd_flow_director_queue_id,
11517 		(void *)&cmd_flow_director_fd_id,
11518 		(void *)&cmd_flow_director_fd_id_value,
11519 		NULL,
11520 	},
11521 };
11522 
11523 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
11524 	.f = cmd_flow_director_filter_parsed,
11525 	.data = NULL,
11526 	.help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
11527 		"director entry on NIC",
11528 	.tokens = {
11529 		(void *)&cmd_flow_director_filter,
11530 		(void *)&cmd_flow_director_port_id,
11531 		(void *)&cmd_flow_director_mode,
11532 		(void *)&cmd_flow_director_mode_mac_vlan,
11533 		(void *)&cmd_flow_director_ops,
11534 		(void *)&cmd_flow_director_mac,
11535 		(void *)&cmd_flow_director_mac_addr,
11536 		(void *)&cmd_flow_director_vlan,
11537 		(void *)&cmd_flow_director_vlan_value,
11538 		(void *)&cmd_flow_director_flexbytes,
11539 		(void *)&cmd_flow_director_flexbytes_value,
11540 		(void *)&cmd_flow_director_drop,
11541 		(void *)&cmd_flow_director_queue,
11542 		(void *)&cmd_flow_director_queue_id,
11543 		(void *)&cmd_flow_director_fd_id,
11544 		(void *)&cmd_flow_director_fd_id_value,
11545 		NULL,
11546 	},
11547 };
11548 
11549 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
11550 	.f = cmd_flow_director_filter_parsed,
11551 	.data = NULL,
11552 	.help_str = "flow_director_filter ... : Add or delete a tunnel flow "
11553 		"director entry on NIC",
11554 	.tokens = {
11555 		(void *)&cmd_flow_director_filter,
11556 		(void *)&cmd_flow_director_port_id,
11557 		(void *)&cmd_flow_director_mode,
11558 		(void *)&cmd_flow_director_mode_tunnel,
11559 		(void *)&cmd_flow_director_ops,
11560 		(void *)&cmd_flow_director_mac,
11561 		(void *)&cmd_flow_director_mac_addr,
11562 		(void *)&cmd_flow_director_vlan,
11563 		(void *)&cmd_flow_director_vlan_value,
11564 		(void *)&cmd_flow_director_tunnel,
11565 		(void *)&cmd_flow_director_tunnel_type,
11566 		(void *)&cmd_flow_director_tunnel_id,
11567 		(void *)&cmd_flow_director_tunnel_id_value,
11568 		(void *)&cmd_flow_director_flexbytes,
11569 		(void *)&cmd_flow_director_flexbytes_value,
11570 		(void *)&cmd_flow_director_drop,
11571 		(void *)&cmd_flow_director_queue,
11572 		(void *)&cmd_flow_director_queue_id,
11573 		(void *)&cmd_flow_director_fd_id,
11574 		(void *)&cmd_flow_director_fd_id_value,
11575 		NULL,
11576 	},
11577 };
11578 
11579 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
11580 	.f = cmd_flow_director_filter_parsed,
11581 	.data = NULL,
11582 	.help_str = "flow_director_filter ... : Add or delete a raw flow "
11583 		"director entry on NIC",
11584 	.tokens = {
11585 		(void *)&cmd_flow_director_filter,
11586 		(void *)&cmd_flow_director_port_id,
11587 		(void *)&cmd_flow_director_mode,
11588 		(void *)&cmd_flow_director_mode_raw,
11589 		(void *)&cmd_flow_director_ops,
11590 		(void *)&cmd_flow_director_flow,
11591 		(void *)&cmd_flow_director_flow_type,
11592 		(void *)&cmd_flow_director_drop,
11593 		(void *)&cmd_flow_director_queue,
11594 		(void *)&cmd_flow_director_queue_id,
11595 		(void *)&cmd_flow_director_fd_id,
11596 		(void *)&cmd_flow_director_fd_id_value,
11597 		(void *)&cmd_flow_director_packet,
11598 		(void *)&cmd_flow_director_filepath,
11599 		NULL,
11600 	},
11601 };
11602 
11603 struct cmd_flush_flow_director_result {
11604 	cmdline_fixed_string_t flush_flow_director;
11605 	portid_t port_id;
11606 };
11607 
11608 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
11609 	TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
11610 				 flush_flow_director, "flush_flow_director");
11611 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
11612 	TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
11613 			      port_id, UINT16);
11614 
11615 static void
11616 cmd_flush_flow_director_parsed(void *parsed_result,
11617 			  __attribute__((unused)) struct cmdline *cl,
11618 			  __attribute__((unused)) void *data)
11619 {
11620 	struct cmd_flow_director_result *res = parsed_result;
11621 	int ret = 0;
11622 
11623 	ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
11624 	if (ret < 0) {
11625 		printf("flow director is not supported on port %u.\n",
11626 			res->port_id);
11627 		return;
11628 	}
11629 
11630 	ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11631 			RTE_ETH_FILTER_FLUSH, NULL);
11632 	if (ret < 0)
11633 		printf("flow director table flushing error: (%s)\n",
11634 			strerror(-ret));
11635 }
11636 
11637 cmdline_parse_inst_t cmd_flush_flow_director = {
11638 	.f = cmd_flush_flow_director_parsed,
11639 	.data = NULL,
11640 	.help_str = "flush_flow_director <port_id>: "
11641 		"Flush all flow director entries of a device on NIC",
11642 	.tokens = {
11643 		(void *)&cmd_flush_flow_director_flush,
11644 		(void *)&cmd_flush_flow_director_port_id,
11645 		NULL,
11646 	},
11647 };
11648 
11649 /* *** deal with flow director mask *** */
11650 struct cmd_flow_director_mask_result {
11651 	cmdline_fixed_string_t flow_director_mask;
11652 	portid_t port_id;
11653 	cmdline_fixed_string_t mode;
11654 	cmdline_fixed_string_t mode_value;
11655 	cmdline_fixed_string_t vlan;
11656 	uint16_t vlan_mask;
11657 	cmdline_fixed_string_t src_mask;
11658 	cmdline_ipaddr_t ipv4_src;
11659 	cmdline_ipaddr_t ipv6_src;
11660 	uint16_t port_src;
11661 	cmdline_fixed_string_t dst_mask;
11662 	cmdline_ipaddr_t ipv4_dst;
11663 	cmdline_ipaddr_t ipv6_dst;
11664 	uint16_t port_dst;
11665 	cmdline_fixed_string_t mac;
11666 	uint8_t mac_addr_byte_mask;
11667 	cmdline_fixed_string_t tunnel_id;
11668 	uint32_t tunnel_id_mask;
11669 	cmdline_fixed_string_t tunnel_type;
11670 	uint8_t tunnel_type_mask;
11671 };
11672 
11673 static void
11674 cmd_flow_director_mask_parsed(void *parsed_result,
11675 			  __attribute__((unused)) struct cmdline *cl,
11676 			  __attribute__((unused)) void *data)
11677 {
11678 	struct cmd_flow_director_mask_result *res = parsed_result;
11679 	struct rte_eth_fdir_masks *mask;
11680 	struct rte_port *port;
11681 
11682 	port = &ports[res->port_id];
11683 	/** Check if the port is not started **/
11684 	if (port->port_status != RTE_PORT_STOPPED) {
11685 		printf("Please stop port %d first\n", res->port_id);
11686 		return;
11687 	}
11688 
11689 	mask = &port->dev_conf.fdir_conf.mask;
11690 
11691 	if (fdir_conf.mode ==  RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
11692 		if (strcmp(res->mode_value, "MAC-VLAN")) {
11693 			printf("Please set mode to MAC-VLAN.\n");
11694 			return;
11695 		}
11696 
11697 		mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11698 	} else if (fdir_conf.mode ==  RTE_FDIR_MODE_PERFECT_TUNNEL) {
11699 		if (strcmp(res->mode_value, "Tunnel")) {
11700 			printf("Please set mode to Tunnel.\n");
11701 			return;
11702 		}
11703 
11704 		mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11705 		mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
11706 		mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
11707 		mask->tunnel_type_mask = res->tunnel_type_mask;
11708 	} else {
11709 		if (strcmp(res->mode_value, "IP")) {
11710 			printf("Please set mode to IP.\n");
11711 			return;
11712 		}
11713 
11714 		mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11715 		IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
11716 		IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
11717 		IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
11718 		IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
11719 		mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
11720 		mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
11721 	}
11722 
11723 	cmd_reconfig_device_queue(res->port_id, 1, 1);
11724 }
11725 
11726 cmdline_parse_token_string_t cmd_flow_director_mask =
11727 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11728 				 flow_director_mask, "flow_director_mask");
11729 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
11730 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11731 			      port_id, UINT16);
11732 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
11733 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11734 				 vlan, "vlan");
11735 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
11736 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11737 			      vlan_mask, UINT16);
11738 cmdline_parse_token_string_t cmd_flow_director_mask_src =
11739 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11740 				 src_mask, "src_mask");
11741 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
11742 	TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11743 				 ipv4_src);
11744 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
11745 	TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11746 				 ipv6_src);
11747 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
11748 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11749 			      port_src, UINT16);
11750 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
11751 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11752 				 dst_mask, "dst_mask");
11753 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
11754 	TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11755 				 ipv4_dst);
11756 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
11757 	TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11758 				 ipv6_dst);
11759 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
11760 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11761 			      port_dst, UINT16);
11762 
11763 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
11764 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11765 				 mode, "mode");
11766 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
11767 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11768 				 mode_value, "IP");
11769 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
11770 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11771 				 mode_value, "MAC-VLAN");
11772 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
11773 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11774 				 mode_value, "Tunnel");
11775 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
11776 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11777 				 mac, "mac");
11778 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
11779 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11780 			      mac_addr_byte_mask, UINT8);
11781 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
11782 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11783 				 tunnel_type, "tunnel-type");
11784 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
11785 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11786 			      tunnel_type_mask, UINT8);
11787 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
11788 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11789 				 tunnel_id, "tunnel-id");
11790 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
11791 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11792 			      tunnel_id_mask, UINT32);
11793 
11794 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
11795 	.f = cmd_flow_director_mask_parsed,
11796 	.data = NULL,
11797 	.help_str = "flow_director_mask ... : "
11798 		"Set IP mode flow director's mask on NIC",
11799 	.tokens = {
11800 		(void *)&cmd_flow_director_mask,
11801 		(void *)&cmd_flow_director_mask_port_id,
11802 		(void *)&cmd_flow_director_mask_mode,
11803 		(void *)&cmd_flow_director_mask_mode_ip,
11804 		(void *)&cmd_flow_director_mask_vlan,
11805 		(void *)&cmd_flow_director_mask_vlan_value,
11806 		(void *)&cmd_flow_director_mask_src,
11807 		(void *)&cmd_flow_director_mask_ipv4_src,
11808 		(void *)&cmd_flow_director_mask_ipv6_src,
11809 		(void *)&cmd_flow_director_mask_port_src,
11810 		(void *)&cmd_flow_director_mask_dst,
11811 		(void *)&cmd_flow_director_mask_ipv4_dst,
11812 		(void *)&cmd_flow_director_mask_ipv6_dst,
11813 		(void *)&cmd_flow_director_mask_port_dst,
11814 		NULL,
11815 	},
11816 };
11817 
11818 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
11819 	.f = cmd_flow_director_mask_parsed,
11820 	.data = NULL,
11821 	.help_str = "flow_director_mask ... : Set MAC VLAN mode "
11822 		"flow director's mask on NIC",
11823 	.tokens = {
11824 		(void *)&cmd_flow_director_mask,
11825 		(void *)&cmd_flow_director_mask_port_id,
11826 		(void *)&cmd_flow_director_mask_mode,
11827 		(void *)&cmd_flow_director_mask_mode_mac_vlan,
11828 		(void *)&cmd_flow_director_mask_vlan,
11829 		(void *)&cmd_flow_director_mask_vlan_value,
11830 		NULL,
11831 	},
11832 };
11833 
11834 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
11835 	.f = cmd_flow_director_mask_parsed,
11836 	.data = NULL,
11837 	.help_str = "flow_director_mask ... : Set tunnel mode "
11838 		"flow director's mask on NIC",
11839 	.tokens = {
11840 		(void *)&cmd_flow_director_mask,
11841 		(void *)&cmd_flow_director_mask_port_id,
11842 		(void *)&cmd_flow_director_mask_mode,
11843 		(void *)&cmd_flow_director_mask_mode_tunnel,
11844 		(void *)&cmd_flow_director_mask_vlan,
11845 		(void *)&cmd_flow_director_mask_vlan_value,
11846 		(void *)&cmd_flow_director_mask_mac,
11847 		(void *)&cmd_flow_director_mask_mac_value,
11848 		(void *)&cmd_flow_director_mask_tunnel_type,
11849 		(void *)&cmd_flow_director_mask_tunnel_type_value,
11850 		(void *)&cmd_flow_director_mask_tunnel_id,
11851 		(void *)&cmd_flow_director_mask_tunnel_id_value,
11852 		NULL,
11853 	},
11854 };
11855 
11856 /* *** deal with flow director mask on flexible payload *** */
11857 struct cmd_flow_director_flex_mask_result {
11858 	cmdline_fixed_string_t flow_director_flexmask;
11859 	portid_t port_id;
11860 	cmdline_fixed_string_t flow;
11861 	cmdline_fixed_string_t flow_type;
11862 	cmdline_fixed_string_t mask;
11863 };
11864 
11865 static void
11866 cmd_flow_director_flex_mask_parsed(void *parsed_result,
11867 			  __attribute__((unused)) struct cmdline *cl,
11868 			  __attribute__((unused)) void *data)
11869 {
11870 	struct cmd_flow_director_flex_mask_result *res = parsed_result;
11871 	struct rte_eth_fdir_info fdir_info;
11872 	struct rte_eth_fdir_flex_mask flex_mask;
11873 	struct rte_port *port;
11874 	uint64_t flow_type_mask;
11875 	uint16_t i;
11876 	int ret;
11877 
11878 	port = &ports[res->port_id];
11879 	/** Check if the port is not started **/
11880 	if (port->port_status != RTE_PORT_STOPPED) {
11881 		printf("Please stop port %d first\n", res->port_id);
11882 		return;
11883 	}
11884 
11885 	memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
11886 	ret = parse_flexbytes(res->mask,
11887 			flex_mask.mask,
11888 			RTE_ETH_FDIR_MAX_FLEXLEN);
11889 	if (ret < 0) {
11890 		printf("error: Cannot parse mask input.\n");
11891 		return;
11892 	}
11893 
11894 	memset(&fdir_info, 0, sizeof(fdir_info));
11895 	ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11896 				RTE_ETH_FILTER_INFO, &fdir_info);
11897 	if (ret < 0) {
11898 		printf("Cannot get FDir filter info\n");
11899 		return;
11900 	}
11901 
11902 	if (!strcmp(res->flow_type, "none")) {
11903 		/* means don't specify the flow type */
11904 		flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
11905 		for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
11906 			memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
11907 			       0, sizeof(struct rte_eth_fdir_flex_mask));
11908 		port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
11909 		rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
11910 				 &flex_mask,
11911 				 sizeof(struct rte_eth_fdir_flex_mask));
11912 		cmd_reconfig_device_queue(res->port_id, 1, 1);
11913 		return;
11914 	}
11915 	flow_type_mask = fdir_info.flow_types_mask[0];
11916 	if (!strcmp(res->flow_type, "all")) {
11917 		if (!flow_type_mask) {
11918 			printf("No flow type supported\n");
11919 			return;
11920 		}
11921 		for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
11922 			if (flow_type_mask & (1ULL << i)) {
11923 				flex_mask.flow_type = i;
11924 				fdir_set_flex_mask(res->port_id, &flex_mask);
11925 			}
11926 		}
11927 		cmd_reconfig_device_queue(res->port_id, 1, 1);
11928 		return;
11929 	}
11930 	flex_mask.flow_type = str2flowtype(res->flow_type);
11931 	if (!(flow_type_mask & (1ULL << flex_mask.flow_type))) {
11932 		printf("Flow type %s not supported on port %d\n",
11933 				res->flow_type, res->port_id);
11934 		return;
11935 	}
11936 	fdir_set_flex_mask(res->port_id, &flex_mask);
11937 	cmd_reconfig_device_queue(res->port_id, 1, 1);
11938 }
11939 
11940 cmdline_parse_token_string_t cmd_flow_director_flexmask =
11941 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11942 				 flow_director_flexmask,
11943 				 "flow_director_flex_mask");
11944 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
11945 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11946 			      port_id, UINT16);
11947 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
11948 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11949 				 flow, "flow");
11950 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
11951 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11952 		flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
11953 		"ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
11954 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
11955 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11956 				 mask, NULL);
11957 
11958 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
11959 	.f = cmd_flow_director_flex_mask_parsed,
11960 	.data = NULL,
11961 	.help_str = "flow_director_flex_mask ... : "
11962 		"Set flow director's flex mask on NIC",
11963 	.tokens = {
11964 		(void *)&cmd_flow_director_flexmask,
11965 		(void *)&cmd_flow_director_flexmask_port_id,
11966 		(void *)&cmd_flow_director_flexmask_flow,
11967 		(void *)&cmd_flow_director_flexmask_flow_type,
11968 		(void *)&cmd_flow_director_flexmask_mask,
11969 		NULL,
11970 	},
11971 };
11972 
11973 /* *** deal with flow director flexible payload configuration *** */
11974 struct cmd_flow_director_flexpayload_result {
11975 	cmdline_fixed_string_t flow_director_flexpayload;
11976 	portid_t port_id;
11977 	cmdline_fixed_string_t payload_layer;
11978 	cmdline_fixed_string_t payload_cfg;
11979 };
11980 
11981 static inline int
11982 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
11983 {
11984 	char s[256];
11985 	const char *p, *p0 = q_arg;
11986 	char *end;
11987 	unsigned long int_fld;
11988 	char *str_fld[max_num];
11989 	int i;
11990 	unsigned size;
11991 	int ret = -1;
11992 
11993 	p = strchr(p0, '(');
11994 	if (p == NULL)
11995 		return -1;
11996 	++p;
11997 	p0 = strchr(p, ')');
11998 	if (p0 == NULL)
11999 		return -1;
12000 
12001 	size = p0 - p;
12002 	if (size >= sizeof(s))
12003 		return -1;
12004 
12005 	snprintf(s, sizeof(s), "%.*s", size, p);
12006 	ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
12007 	if (ret < 0 || ret > max_num)
12008 		return -1;
12009 	for (i = 0; i < ret; i++) {
12010 		errno = 0;
12011 		int_fld = strtoul(str_fld[i], &end, 0);
12012 		if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
12013 			return -1;
12014 		offsets[i] = (uint16_t)int_fld;
12015 	}
12016 	return ret;
12017 }
12018 
12019 static void
12020 cmd_flow_director_flxpld_parsed(void *parsed_result,
12021 			  __attribute__((unused)) struct cmdline *cl,
12022 			  __attribute__((unused)) void *data)
12023 {
12024 	struct cmd_flow_director_flexpayload_result *res = parsed_result;
12025 	struct rte_eth_flex_payload_cfg flex_cfg;
12026 	struct rte_port *port;
12027 	int ret = 0;
12028 
12029 	port = &ports[res->port_id];
12030 	/** Check if the port is not started **/
12031 	if (port->port_status != RTE_PORT_STOPPED) {
12032 		printf("Please stop port %d first\n", res->port_id);
12033 		return;
12034 	}
12035 
12036 	memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
12037 
12038 	if (!strcmp(res->payload_layer, "raw"))
12039 		flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
12040 	else if (!strcmp(res->payload_layer, "l2"))
12041 		flex_cfg.type = RTE_ETH_L2_PAYLOAD;
12042 	else if (!strcmp(res->payload_layer, "l3"))
12043 		flex_cfg.type = RTE_ETH_L3_PAYLOAD;
12044 	else if (!strcmp(res->payload_layer, "l4"))
12045 		flex_cfg.type = RTE_ETH_L4_PAYLOAD;
12046 
12047 	ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
12048 			    RTE_ETH_FDIR_MAX_FLEXLEN);
12049 	if (ret < 0) {
12050 		printf("error: Cannot parse flex payload input.\n");
12051 		return;
12052 	}
12053 
12054 	fdir_set_flex_payload(res->port_id, &flex_cfg);
12055 	cmd_reconfig_device_queue(res->port_id, 1, 1);
12056 }
12057 
12058 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
12059 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12060 				 flow_director_flexpayload,
12061 				 "flow_director_flex_payload");
12062 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
12063 	TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12064 			      port_id, UINT16);
12065 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
12066 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12067 				 payload_layer, "raw#l2#l3#l4");
12068 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
12069 	TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12070 				 payload_cfg, NULL);
12071 
12072 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
12073 	.f = cmd_flow_director_flxpld_parsed,
12074 	.data = NULL,
12075 	.help_str = "flow_director_flexpayload ... : "
12076 		"Set flow director's flex payload on NIC",
12077 	.tokens = {
12078 		(void *)&cmd_flow_director_flexpayload,
12079 		(void *)&cmd_flow_director_flexpayload_port_id,
12080 		(void *)&cmd_flow_director_flexpayload_payload_layer,
12081 		(void *)&cmd_flow_director_flexpayload_payload_cfg,
12082 		NULL,
12083 	},
12084 };
12085 
12086 /* Generic flow interface command. */
12087 extern cmdline_parse_inst_t cmd_flow;
12088 
12089 /* *** Classification Filters Control *** */
12090 /* *** Get symmetric hash enable per port *** */
12091 struct cmd_get_sym_hash_ena_per_port_result {
12092 	cmdline_fixed_string_t get_sym_hash_ena_per_port;
12093 	portid_t port_id;
12094 };
12095 
12096 static void
12097 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
12098 				 __rte_unused struct cmdline *cl,
12099 				 __rte_unused void *data)
12100 {
12101 	struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
12102 	struct rte_eth_hash_filter_info info;
12103 	int ret;
12104 
12105 	if (rte_eth_dev_filter_supported(res->port_id,
12106 				RTE_ETH_FILTER_HASH) < 0) {
12107 		printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
12108 							res->port_id);
12109 		return;
12110 	}
12111 
12112 	memset(&info, 0, sizeof(info));
12113 	info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
12114 	ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12115 						RTE_ETH_FILTER_GET, &info);
12116 
12117 	if (ret < 0) {
12118 		printf("Cannot get symmetric hash enable per port "
12119 					"on port %u\n", res->port_id);
12120 		return;
12121 	}
12122 
12123 	printf("Symmetric hash is %s on port %u\n", info.info.enable ?
12124 				"enabled" : "disabled", res->port_id);
12125 }
12126 
12127 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
12128 	TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
12129 		get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
12130 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
12131 	TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
12132 		port_id, UINT16);
12133 
12134 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
12135 	.f = cmd_get_sym_hash_per_port_parsed,
12136 	.data = NULL,
12137 	.help_str = "get_sym_hash_ena_per_port <port_id>",
12138 	.tokens = {
12139 		(void *)&cmd_get_sym_hash_ena_per_port_all,
12140 		(void *)&cmd_get_sym_hash_ena_per_port_port_id,
12141 		NULL,
12142 	},
12143 };
12144 
12145 /* *** Set symmetric hash enable per port *** */
12146 struct cmd_set_sym_hash_ena_per_port_result {
12147 	cmdline_fixed_string_t set_sym_hash_ena_per_port;
12148 	cmdline_fixed_string_t enable;
12149 	portid_t port_id;
12150 };
12151 
12152 static void
12153 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
12154 				 __rte_unused struct cmdline *cl,
12155 				 __rte_unused void *data)
12156 {
12157 	struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
12158 	struct rte_eth_hash_filter_info info;
12159 	int ret;
12160 
12161 	if (rte_eth_dev_filter_supported(res->port_id,
12162 				RTE_ETH_FILTER_HASH) < 0) {
12163 		printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
12164 							res->port_id);
12165 		return;
12166 	}
12167 
12168 	memset(&info, 0, sizeof(info));
12169 	info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
12170 	if (!strcmp(res->enable, "enable"))
12171 		info.info.enable = 1;
12172 	ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12173 					RTE_ETH_FILTER_SET, &info);
12174 	if (ret < 0) {
12175 		printf("Cannot set symmetric hash enable per port on "
12176 					"port %u\n", res->port_id);
12177 		return;
12178 	}
12179 	printf("Symmetric hash has been set to %s on port %u\n",
12180 					res->enable, res->port_id);
12181 }
12182 
12183 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
12184 	TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12185 		set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
12186 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
12187 	TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12188 		port_id, UINT16);
12189 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
12190 	TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12191 		enable, "enable#disable");
12192 
12193 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
12194 	.f = cmd_set_sym_hash_per_port_parsed,
12195 	.data = NULL,
12196 	.help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
12197 	.tokens = {
12198 		(void *)&cmd_set_sym_hash_ena_per_port_all,
12199 		(void *)&cmd_set_sym_hash_ena_per_port_port_id,
12200 		(void *)&cmd_set_sym_hash_ena_per_port_enable,
12201 		NULL,
12202 	},
12203 };
12204 
12205 /* Get global config of hash function */
12206 struct cmd_get_hash_global_config_result {
12207 	cmdline_fixed_string_t get_hash_global_config;
12208 	portid_t port_id;
12209 };
12210 
12211 static char *
12212 flowtype_to_str(uint16_t ftype)
12213 {
12214 	uint16_t i;
12215 	static struct {
12216 		char str[16];
12217 		uint16_t ftype;
12218 	} ftype_table[] = {
12219 		{"ipv4", RTE_ETH_FLOW_IPV4},
12220 		{"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
12221 		{"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
12222 		{"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
12223 		{"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
12224 		{"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
12225 		{"ipv6", RTE_ETH_FLOW_IPV6},
12226 		{"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
12227 		{"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
12228 		{"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
12229 		{"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
12230 		{"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
12231 		{"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
12232 		{"port", RTE_ETH_FLOW_PORT},
12233 		{"vxlan", RTE_ETH_FLOW_VXLAN},
12234 		{"geneve", RTE_ETH_FLOW_GENEVE},
12235 		{"nvgre", RTE_ETH_FLOW_NVGRE},
12236 		{"vxlan-gpe", RTE_ETH_FLOW_VXLAN_GPE},
12237 	};
12238 
12239 	for (i = 0; i < RTE_DIM(ftype_table); i++) {
12240 		if (ftype_table[i].ftype == ftype)
12241 			return ftype_table[i].str;
12242 	}
12243 
12244 	return NULL;
12245 }
12246 
12247 static void
12248 cmd_get_hash_global_config_parsed(void *parsed_result,
12249 				  __rte_unused struct cmdline *cl,
12250 				  __rte_unused void *data)
12251 {
12252 	struct cmd_get_hash_global_config_result *res = parsed_result;
12253 	struct rte_eth_hash_filter_info info;
12254 	uint32_t idx, offset;
12255 	uint16_t i;
12256 	char *str;
12257 	int ret;
12258 
12259 	if (rte_eth_dev_filter_supported(res->port_id,
12260 			RTE_ETH_FILTER_HASH) < 0) {
12261 		printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
12262 							res->port_id);
12263 		return;
12264 	}
12265 
12266 	memset(&info, 0, sizeof(info));
12267 	info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
12268 	ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12269 					RTE_ETH_FILTER_GET, &info);
12270 	if (ret < 0) {
12271 		printf("Cannot get hash global configurations by port %d\n",
12272 							res->port_id);
12273 		return;
12274 	}
12275 
12276 	switch (info.info.global_conf.hash_func) {
12277 	case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
12278 		printf("Hash function is Toeplitz\n");
12279 		break;
12280 	case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
12281 		printf("Hash function is Simple XOR\n");
12282 		break;
12283 	case RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ:
12284 		printf("Hash function is Symmetric Toeplitz\n");
12285 		break;
12286 	default:
12287 		printf("Unknown hash function\n");
12288 		break;
12289 	}
12290 
12291 	for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
12292 		idx = i / UINT64_BIT;
12293 		offset = i % UINT64_BIT;
12294 		if (!(info.info.global_conf.valid_bit_mask[idx] &
12295 						(1ULL << offset)))
12296 			continue;
12297 		str = flowtype_to_str(i);
12298 		if (!str)
12299 			continue;
12300 		printf("Symmetric hash is %s globally for flow type %s "
12301 							"by port %d\n",
12302 			((info.info.global_conf.sym_hash_enable_mask[idx] &
12303 			(1ULL << offset)) ? "enabled" : "disabled"), str,
12304 							res->port_id);
12305 	}
12306 }
12307 
12308 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
12309 	TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
12310 		get_hash_global_config, "get_hash_global_config");
12311 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
12312 	TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
12313 		port_id, UINT16);
12314 
12315 cmdline_parse_inst_t cmd_get_hash_global_config = {
12316 	.f = cmd_get_hash_global_config_parsed,
12317 	.data = NULL,
12318 	.help_str = "get_hash_global_config <port_id>",
12319 	.tokens = {
12320 		(void *)&cmd_get_hash_global_config_all,
12321 		(void *)&cmd_get_hash_global_config_port_id,
12322 		NULL,
12323 	},
12324 };
12325 
12326 /* Set global config of hash function */
12327 struct cmd_set_hash_global_config_result {
12328 	cmdline_fixed_string_t set_hash_global_config;
12329 	portid_t port_id;
12330 	cmdline_fixed_string_t hash_func;
12331 	cmdline_fixed_string_t flow_type;
12332 	cmdline_fixed_string_t enable;
12333 };
12334 
12335 static void
12336 cmd_set_hash_global_config_parsed(void *parsed_result,
12337 				  __rte_unused struct cmdline *cl,
12338 				  __rte_unused void *data)
12339 {
12340 	struct cmd_set_hash_global_config_result *res = parsed_result;
12341 	struct rte_eth_hash_filter_info info;
12342 	uint32_t ftype, idx, offset;
12343 	int ret;
12344 
12345 	if (rte_eth_dev_filter_supported(res->port_id,
12346 				RTE_ETH_FILTER_HASH) < 0) {
12347 		printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
12348 							res->port_id);
12349 		return;
12350 	}
12351 	memset(&info, 0, sizeof(info));
12352 	info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
12353 	if (!strcmp(res->hash_func, "toeplitz"))
12354 		info.info.global_conf.hash_func =
12355 			RTE_ETH_HASH_FUNCTION_TOEPLITZ;
12356 	else if (!strcmp(res->hash_func, "simple_xor"))
12357 		info.info.global_conf.hash_func =
12358 			RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
12359 	else if (!strcmp(res->hash_func, "symmetric_toeplitz"))
12360 		info.info.global_conf.hash_func =
12361 			RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ;
12362 	else if (!strcmp(res->hash_func, "default"))
12363 		info.info.global_conf.hash_func =
12364 			RTE_ETH_HASH_FUNCTION_DEFAULT;
12365 
12366 	ftype = str2flowtype(res->flow_type);
12367 	idx = ftype / UINT64_BIT;
12368 	offset = ftype % UINT64_BIT;
12369 	info.info.global_conf.valid_bit_mask[idx] |= (1ULL << offset);
12370 	if (!strcmp(res->enable, "enable"))
12371 		info.info.global_conf.sym_hash_enable_mask[idx] |=
12372 						(1ULL << offset);
12373 	ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12374 					RTE_ETH_FILTER_SET, &info);
12375 	if (ret < 0)
12376 		printf("Cannot set global hash configurations by port %d\n",
12377 							res->port_id);
12378 	else
12379 		printf("Global hash configurations have been set "
12380 			"successfully by port %d\n", res->port_id);
12381 }
12382 
12383 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
12384 	TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12385 		set_hash_global_config, "set_hash_global_config");
12386 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
12387 	TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
12388 		port_id, UINT16);
12389 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
12390 	TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12391 		hash_func, "toeplitz#simple_xor#symmetric_toeplitz#default");
12392 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
12393 	TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12394 		flow_type,
12395 		"ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
12396 		"ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12397 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
12398 	TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12399 		enable, "enable#disable");
12400 
12401 cmdline_parse_inst_t cmd_set_hash_global_config = {
12402 	.f = cmd_set_hash_global_config_parsed,
12403 	.data = NULL,
12404 	.help_str = "set_hash_global_config <port_id> "
12405 		"toeplitz|simple_xor|symmetric_toeplitz|default "
12406 		"ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12407 		"ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
12408 		"l2_payload enable|disable",
12409 	.tokens = {
12410 		(void *)&cmd_set_hash_global_config_all,
12411 		(void *)&cmd_set_hash_global_config_port_id,
12412 		(void *)&cmd_set_hash_global_config_hash_func,
12413 		(void *)&cmd_set_hash_global_config_flow_type,
12414 		(void *)&cmd_set_hash_global_config_enable,
12415 		NULL,
12416 	},
12417 };
12418 
12419 /* Set hash input set */
12420 struct cmd_set_hash_input_set_result {
12421 	cmdline_fixed_string_t set_hash_input_set;
12422 	portid_t port_id;
12423 	cmdline_fixed_string_t flow_type;
12424 	cmdline_fixed_string_t inset_field;
12425 	cmdline_fixed_string_t select;
12426 };
12427 
12428 static enum rte_eth_input_set_field
12429 str2inset(char *string)
12430 {
12431 	uint16_t i;
12432 
12433 	static const struct {
12434 		char str[32];
12435 		enum rte_eth_input_set_field inset;
12436 	} inset_table[] = {
12437 		{"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
12438 		{"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
12439 		{"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
12440 		{"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
12441 		{"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
12442 		{"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
12443 		{"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
12444 		{"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
12445 		{"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
12446 		{"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
12447 		{"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
12448 		{"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
12449 		{"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
12450 		{"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
12451 		{"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
12452 		{"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
12453 		{"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
12454 		{"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
12455 		{"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
12456 		{"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
12457 		{"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
12458 		{"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
12459 		{"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
12460 		{"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
12461 		{"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
12462 		{"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
12463 		{"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
12464 		{"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
12465 		{"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
12466 		{"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
12467 		{"none", RTE_ETH_INPUT_SET_NONE},
12468 	};
12469 
12470 	for (i = 0; i < RTE_DIM(inset_table); i++) {
12471 		if (!strcmp(string, inset_table[i].str))
12472 			return inset_table[i].inset;
12473 	}
12474 
12475 	return RTE_ETH_INPUT_SET_UNKNOWN;
12476 }
12477 
12478 static void
12479 cmd_set_hash_input_set_parsed(void *parsed_result,
12480 			      __rte_unused struct cmdline *cl,
12481 			      __rte_unused void *data)
12482 {
12483 	struct cmd_set_hash_input_set_result *res = parsed_result;
12484 	struct rte_eth_hash_filter_info info;
12485 
12486 	memset(&info, 0, sizeof(info));
12487 	info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
12488 	info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12489 	info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12490 	info.info.input_set_conf.inset_size = 1;
12491 	if (!strcmp(res->select, "select"))
12492 		info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12493 	else if (!strcmp(res->select, "add"))
12494 		info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12495 	rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12496 				RTE_ETH_FILTER_SET, &info);
12497 }
12498 
12499 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
12500 	TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12501 		set_hash_input_set, "set_hash_input_set");
12502 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
12503 	TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
12504 		port_id, UINT16);
12505 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
12506 	TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12507 		flow_type, NULL);
12508 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
12509 	TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12510 		inset_field,
12511 		"ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12512 		"ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
12513 		"udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
12514 		"sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
12515 		"fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
12516 		"fld-8th#none");
12517 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
12518 	TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12519 		select, "select#add");
12520 
12521 cmdline_parse_inst_t cmd_set_hash_input_set = {
12522 	.f = cmd_set_hash_input_set_parsed,
12523 	.data = NULL,
12524 	.help_str = "set_hash_input_set <port_id> "
12525 	"ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12526 	"ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
12527 	"ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
12528 	"ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
12529 	"tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
12530 	"gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
12531 	"fld-7th|fld-8th|none select|add",
12532 	.tokens = {
12533 		(void *)&cmd_set_hash_input_set_cmd,
12534 		(void *)&cmd_set_hash_input_set_port_id,
12535 		(void *)&cmd_set_hash_input_set_flow_type,
12536 		(void *)&cmd_set_hash_input_set_field,
12537 		(void *)&cmd_set_hash_input_set_select,
12538 		NULL,
12539 	},
12540 };
12541 
12542 /* Set flow director input set */
12543 struct cmd_set_fdir_input_set_result {
12544 	cmdline_fixed_string_t set_fdir_input_set;
12545 	portid_t port_id;
12546 	cmdline_fixed_string_t flow_type;
12547 	cmdline_fixed_string_t inset_field;
12548 	cmdline_fixed_string_t select;
12549 };
12550 
12551 static void
12552 cmd_set_fdir_input_set_parsed(void *parsed_result,
12553 	__rte_unused struct cmdline *cl,
12554 	__rte_unused void *data)
12555 {
12556 	struct cmd_set_fdir_input_set_result *res = parsed_result;
12557 	struct rte_eth_fdir_filter_info info;
12558 
12559 	memset(&info, 0, sizeof(info));
12560 	info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
12561 	info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12562 	info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12563 	info.info.input_set_conf.inset_size = 1;
12564 	if (!strcmp(res->select, "select"))
12565 		info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12566 	else if (!strcmp(res->select, "add"))
12567 		info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12568 	rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
12569 		RTE_ETH_FILTER_SET, &info);
12570 }
12571 
12572 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
12573 	TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12574 	set_fdir_input_set, "set_fdir_input_set");
12575 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
12576 	TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
12577 	port_id, UINT16);
12578 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
12579 	TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12580 	flow_type,
12581 	"ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
12582 	"ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12583 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
12584 	TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12585 	inset_field,
12586 	"ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12587 	"ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
12588 	"ipv6-hop-limits#udp-src-port#udp-dst-port#"
12589 	"tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
12590 	"sctp-veri-tag#none");
12591 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
12592 	TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12593 	select, "select#add");
12594 
12595 cmdline_parse_inst_t cmd_set_fdir_input_set = {
12596 	.f = cmd_set_fdir_input_set_parsed,
12597 	.data = NULL,
12598 	.help_str = "set_fdir_input_set <port_id> "
12599 	"ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12600 	"ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
12601 	"ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
12602 	"ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
12603 	"ipv6-hop-limits|udp-src-port|udp-dst-port|"
12604 	"tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
12605 	"sctp-veri-tag|none select|add",
12606 	.tokens = {
12607 		(void *)&cmd_set_fdir_input_set_cmd,
12608 		(void *)&cmd_set_fdir_input_set_port_id,
12609 		(void *)&cmd_set_fdir_input_set_flow_type,
12610 		(void *)&cmd_set_fdir_input_set_field,
12611 		(void *)&cmd_set_fdir_input_set_select,
12612 		NULL,
12613 	},
12614 };
12615 
12616 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
12617 struct cmd_mcast_addr_result {
12618 	cmdline_fixed_string_t mcast_addr_cmd;
12619 	cmdline_fixed_string_t what;
12620 	uint16_t port_num;
12621 	struct rte_ether_addr mc_addr;
12622 };
12623 
12624 static void cmd_mcast_addr_parsed(void *parsed_result,
12625 		__attribute__((unused)) struct cmdline *cl,
12626 		__attribute__((unused)) void *data)
12627 {
12628 	struct cmd_mcast_addr_result *res = parsed_result;
12629 
12630 	if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
12631 		printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
12632 		       res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
12633 		       res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
12634 		       res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
12635 		return;
12636 	}
12637 	if (strcmp(res->what, "add") == 0)
12638 		mcast_addr_add(res->port_num, &res->mc_addr);
12639 	else
12640 		mcast_addr_remove(res->port_num, &res->mc_addr);
12641 }
12642 
12643 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
12644 	TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
12645 				 mcast_addr_cmd, "mcast_addr");
12646 cmdline_parse_token_string_t cmd_mcast_addr_what =
12647 	TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
12648 				 "add#remove");
12649 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
12650 	TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
12651 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
12652 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
12653 
12654 cmdline_parse_inst_t cmd_mcast_addr = {
12655 	.f = cmd_mcast_addr_parsed,
12656 	.data = (void *)0,
12657 	.help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
12658 		"Add/Remove multicast MAC address on port_id",
12659 	.tokens = {
12660 		(void *)&cmd_mcast_addr_cmd,
12661 		(void *)&cmd_mcast_addr_what,
12662 		(void *)&cmd_mcast_addr_portnum,
12663 		(void *)&cmd_mcast_addr_addr,
12664 		NULL,
12665 	},
12666 };
12667 
12668 /* l2 tunnel config
12669  * only support E-tag now.
12670  */
12671 
12672 /* Ether type config */
12673 struct cmd_config_l2_tunnel_eth_type_result {
12674 	cmdline_fixed_string_t port;
12675 	cmdline_fixed_string_t config;
12676 	cmdline_fixed_string_t all;
12677 	portid_t id;
12678 	cmdline_fixed_string_t l2_tunnel;
12679 	cmdline_fixed_string_t l2_tunnel_type;
12680 	cmdline_fixed_string_t eth_type;
12681 	uint16_t eth_type_val;
12682 };
12683 
12684 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
12685 	TOKEN_STRING_INITIALIZER
12686 		(struct cmd_config_l2_tunnel_eth_type_result,
12687 		 port, "port");
12688 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
12689 	TOKEN_STRING_INITIALIZER
12690 		(struct cmd_config_l2_tunnel_eth_type_result,
12691 		 config, "config");
12692 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
12693 	TOKEN_STRING_INITIALIZER
12694 		(struct cmd_config_l2_tunnel_eth_type_result,
12695 		 all, "all");
12696 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
12697 	TOKEN_NUM_INITIALIZER
12698 		(struct cmd_config_l2_tunnel_eth_type_result,
12699 		 id, UINT16);
12700 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
12701 	TOKEN_STRING_INITIALIZER
12702 		(struct cmd_config_l2_tunnel_eth_type_result,
12703 		 l2_tunnel, "l2-tunnel");
12704 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
12705 	TOKEN_STRING_INITIALIZER
12706 		(struct cmd_config_l2_tunnel_eth_type_result,
12707 		 l2_tunnel_type, "E-tag");
12708 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
12709 	TOKEN_STRING_INITIALIZER
12710 		(struct cmd_config_l2_tunnel_eth_type_result,
12711 		 eth_type, "ether-type");
12712 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
12713 	TOKEN_NUM_INITIALIZER
12714 		(struct cmd_config_l2_tunnel_eth_type_result,
12715 		 eth_type_val, UINT16);
12716 
12717 static enum rte_eth_tunnel_type
12718 str2fdir_l2_tunnel_type(char *string)
12719 {
12720 	uint32_t i = 0;
12721 
12722 	static const struct {
12723 		char str[32];
12724 		enum rte_eth_tunnel_type type;
12725 	} l2_tunnel_type_str[] = {
12726 		{"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
12727 	};
12728 
12729 	for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
12730 		if (!strcmp(l2_tunnel_type_str[i].str, string))
12731 			return l2_tunnel_type_str[i].type;
12732 	}
12733 	return RTE_TUNNEL_TYPE_NONE;
12734 }
12735 
12736 /* ether type config for all ports */
12737 static void
12738 cmd_config_l2_tunnel_eth_type_all_parsed
12739 	(void *parsed_result,
12740 	 __attribute__((unused)) struct cmdline *cl,
12741 	 __attribute__((unused)) void *data)
12742 {
12743 	struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
12744 	struct rte_eth_l2_tunnel_conf entry;
12745 	portid_t pid;
12746 
12747 	entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12748 	entry.ether_type = res->eth_type_val;
12749 
12750 	RTE_ETH_FOREACH_DEV(pid) {
12751 		rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
12752 	}
12753 }
12754 
12755 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
12756 	.f = cmd_config_l2_tunnel_eth_type_all_parsed,
12757 	.data = NULL,
12758 	.help_str = "port config all l2-tunnel E-tag ether-type <value>",
12759 	.tokens = {
12760 		(void *)&cmd_config_l2_tunnel_eth_type_port,
12761 		(void *)&cmd_config_l2_tunnel_eth_type_config,
12762 		(void *)&cmd_config_l2_tunnel_eth_type_all_str,
12763 		(void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12764 		(void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12765 		(void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12766 		(void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12767 		NULL,
12768 	},
12769 };
12770 
12771 /* ether type config for a specific port */
12772 static void
12773 cmd_config_l2_tunnel_eth_type_specific_parsed(
12774 	void *parsed_result,
12775 	__attribute__((unused)) struct cmdline *cl,
12776 	__attribute__((unused)) void *data)
12777 {
12778 	struct cmd_config_l2_tunnel_eth_type_result *res =
12779 		 parsed_result;
12780 	struct rte_eth_l2_tunnel_conf entry;
12781 
12782 	if (port_id_is_invalid(res->id, ENABLED_WARN))
12783 		return;
12784 
12785 	entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12786 	entry.ether_type = res->eth_type_val;
12787 
12788 	rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
12789 }
12790 
12791 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
12792 	.f = cmd_config_l2_tunnel_eth_type_specific_parsed,
12793 	.data = NULL,
12794 	.help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
12795 	.tokens = {
12796 		(void *)&cmd_config_l2_tunnel_eth_type_port,
12797 		(void *)&cmd_config_l2_tunnel_eth_type_config,
12798 		(void *)&cmd_config_l2_tunnel_eth_type_id,
12799 		(void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12800 		(void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12801 		(void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12802 		(void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12803 		NULL,
12804 	},
12805 };
12806 
12807 /* Enable/disable l2 tunnel */
12808 struct cmd_config_l2_tunnel_en_dis_result {
12809 	cmdline_fixed_string_t port;
12810 	cmdline_fixed_string_t config;
12811 	cmdline_fixed_string_t all;
12812 	portid_t id;
12813 	cmdline_fixed_string_t l2_tunnel;
12814 	cmdline_fixed_string_t l2_tunnel_type;
12815 	cmdline_fixed_string_t en_dis;
12816 };
12817 
12818 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
12819 	TOKEN_STRING_INITIALIZER
12820 		(struct cmd_config_l2_tunnel_en_dis_result,
12821 		 port, "port");
12822 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
12823 	TOKEN_STRING_INITIALIZER
12824 		(struct cmd_config_l2_tunnel_en_dis_result,
12825 		 config, "config");
12826 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
12827 	TOKEN_STRING_INITIALIZER
12828 		(struct cmd_config_l2_tunnel_en_dis_result,
12829 		 all, "all");
12830 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
12831 	TOKEN_NUM_INITIALIZER
12832 		(struct cmd_config_l2_tunnel_en_dis_result,
12833 		 id, UINT16);
12834 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
12835 	TOKEN_STRING_INITIALIZER
12836 		(struct cmd_config_l2_tunnel_en_dis_result,
12837 		 l2_tunnel, "l2-tunnel");
12838 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
12839 	TOKEN_STRING_INITIALIZER
12840 		(struct cmd_config_l2_tunnel_en_dis_result,
12841 		 l2_tunnel_type, "E-tag");
12842 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
12843 	TOKEN_STRING_INITIALIZER
12844 		(struct cmd_config_l2_tunnel_en_dis_result,
12845 		 en_dis, "enable#disable");
12846 
12847 /* enable/disable l2 tunnel for all ports */
12848 static void
12849 cmd_config_l2_tunnel_en_dis_all_parsed(
12850 	void *parsed_result,
12851 	__attribute__((unused)) struct cmdline *cl,
12852 	__attribute__((unused)) void *data)
12853 {
12854 	struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
12855 	struct rte_eth_l2_tunnel_conf entry;
12856 	portid_t pid;
12857 	uint8_t en;
12858 
12859 	entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12860 
12861 	if (!strcmp("enable", res->en_dis))
12862 		en = 1;
12863 	else
12864 		en = 0;
12865 
12866 	RTE_ETH_FOREACH_DEV(pid) {
12867 		rte_eth_dev_l2_tunnel_offload_set(pid,
12868 						  &entry,
12869 						  ETH_L2_TUNNEL_ENABLE_MASK,
12870 						  en);
12871 	}
12872 }
12873 
12874 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
12875 	.f = cmd_config_l2_tunnel_en_dis_all_parsed,
12876 	.data = NULL,
12877 	.help_str = "port config all l2-tunnel E-tag enable|disable",
12878 	.tokens = {
12879 		(void *)&cmd_config_l2_tunnel_en_dis_port,
12880 		(void *)&cmd_config_l2_tunnel_en_dis_config,
12881 		(void *)&cmd_config_l2_tunnel_en_dis_all_str,
12882 		(void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12883 		(void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12884 		(void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12885 		NULL,
12886 	},
12887 };
12888 
12889 /* enable/disable l2 tunnel for a port */
12890 static void
12891 cmd_config_l2_tunnel_en_dis_specific_parsed(
12892 	void *parsed_result,
12893 	__attribute__((unused)) struct cmdline *cl,
12894 	__attribute__((unused)) void *data)
12895 {
12896 	struct cmd_config_l2_tunnel_en_dis_result *res =
12897 		parsed_result;
12898 	struct rte_eth_l2_tunnel_conf entry;
12899 
12900 	if (port_id_is_invalid(res->id, ENABLED_WARN))
12901 		return;
12902 
12903 	entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12904 
12905 	if (!strcmp("enable", res->en_dis))
12906 		rte_eth_dev_l2_tunnel_offload_set(res->id,
12907 						  &entry,
12908 						  ETH_L2_TUNNEL_ENABLE_MASK,
12909 						  1);
12910 	else
12911 		rte_eth_dev_l2_tunnel_offload_set(res->id,
12912 						  &entry,
12913 						  ETH_L2_TUNNEL_ENABLE_MASK,
12914 						  0);
12915 }
12916 
12917 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
12918 	.f = cmd_config_l2_tunnel_en_dis_specific_parsed,
12919 	.data = NULL,
12920 	.help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
12921 	.tokens = {
12922 		(void *)&cmd_config_l2_tunnel_en_dis_port,
12923 		(void *)&cmd_config_l2_tunnel_en_dis_config,
12924 		(void *)&cmd_config_l2_tunnel_en_dis_id,
12925 		(void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12926 		(void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12927 		(void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12928 		NULL,
12929 	},
12930 };
12931 
12932 /* E-tag configuration */
12933 
12934 /* Common result structure for all E-tag configuration */
12935 struct cmd_config_e_tag_result {
12936 	cmdline_fixed_string_t e_tag;
12937 	cmdline_fixed_string_t set;
12938 	cmdline_fixed_string_t insertion;
12939 	cmdline_fixed_string_t stripping;
12940 	cmdline_fixed_string_t forwarding;
12941 	cmdline_fixed_string_t filter;
12942 	cmdline_fixed_string_t add;
12943 	cmdline_fixed_string_t del;
12944 	cmdline_fixed_string_t on;
12945 	cmdline_fixed_string_t off;
12946 	cmdline_fixed_string_t on_off;
12947 	cmdline_fixed_string_t port_tag_id;
12948 	uint32_t port_tag_id_val;
12949 	cmdline_fixed_string_t e_tag_id;
12950 	uint16_t e_tag_id_val;
12951 	cmdline_fixed_string_t dst_pool;
12952 	uint8_t dst_pool_val;
12953 	cmdline_fixed_string_t port;
12954 	portid_t port_id;
12955 	cmdline_fixed_string_t vf;
12956 	uint8_t vf_id;
12957 };
12958 
12959 /* Common CLI fields for all E-tag configuration */
12960 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
12961 	TOKEN_STRING_INITIALIZER
12962 		(struct cmd_config_e_tag_result,
12963 		 e_tag, "E-tag");
12964 cmdline_parse_token_string_t cmd_config_e_tag_set =
12965 	TOKEN_STRING_INITIALIZER
12966 		(struct cmd_config_e_tag_result,
12967 		 set, "set");
12968 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
12969 	TOKEN_STRING_INITIALIZER
12970 		(struct cmd_config_e_tag_result,
12971 		 insertion, "insertion");
12972 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
12973 	TOKEN_STRING_INITIALIZER
12974 		(struct cmd_config_e_tag_result,
12975 		 stripping, "stripping");
12976 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
12977 	TOKEN_STRING_INITIALIZER
12978 		(struct cmd_config_e_tag_result,
12979 		 forwarding, "forwarding");
12980 cmdline_parse_token_string_t cmd_config_e_tag_filter =
12981 	TOKEN_STRING_INITIALIZER
12982 		(struct cmd_config_e_tag_result,
12983 		 filter, "filter");
12984 cmdline_parse_token_string_t cmd_config_e_tag_add =
12985 	TOKEN_STRING_INITIALIZER
12986 		(struct cmd_config_e_tag_result,
12987 		 add, "add");
12988 cmdline_parse_token_string_t cmd_config_e_tag_del =
12989 	TOKEN_STRING_INITIALIZER
12990 		(struct cmd_config_e_tag_result,
12991 		 del, "del");
12992 cmdline_parse_token_string_t cmd_config_e_tag_on =
12993 	TOKEN_STRING_INITIALIZER
12994 		(struct cmd_config_e_tag_result,
12995 		 on, "on");
12996 cmdline_parse_token_string_t cmd_config_e_tag_off =
12997 	TOKEN_STRING_INITIALIZER
12998 		(struct cmd_config_e_tag_result,
12999 		 off, "off");
13000 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
13001 	TOKEN_STRING_INITIALIZER
13002 		(struct cmd_config_e_tag_result,
13003 		 on_off, "on#off");
13004 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
13005 	TOKEN_STRING_INITIALIZER
13006 		(struct cmd_config_e_tag_result,
13007 		 port_tag_id, "port-tag-id");
13008 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
13009 	TOKEN_NUM_INITIALIZER
13010 		(struct cmd_config_e_tag_result,
13011 		 port_tag_id_val, UINT32);
13012 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
13013 	TOKEN_STRING_INITIALIZER
13014 		(struct cmd_config_e_tag_result,
13015 		 e_tag_id, "e-tag-id");
13016 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
13017 	TOKEN_NUM_INITIALIZER
13018 		(struct cmd_config_e_tag_result,
13019 		 e_tag_id_val, UINT16);
13020 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
13021 	TOKEN_STRING_INITIALIZER
13022 		(struct cmd_config_e_tag_result,
13023 		 dst_pool, "dst-pool");
13024 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
13025 	TOKEN_NUM_INITIALIZER
13026 		(struct cmd_config_e_tag_result,
13027 		 dst_pool_val, UINT8);
13028 cmdline_parse_token_string_t cmd_config_e_tag_port =
13029 	TOKEN_STRING_INITIALIZER
13030 		(struct cmd_config_e_tag_result,
13031 		 port, "port");
13032 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
13033 	TOKEN_NUM_INITIALIZER
13034 		(struct cmd_config_e_tag_result,
13035 		 port_id, UINT16);
13036 cmdline_parse_token_string_t cmd_config_e_tag_vf =
13037 	TOKEN_STRING_INITIALIZER
13038 		(struct cmd_config_e_tag_result,
13039 		 vf, "vf");
13040 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
13041 	TOKEN_NUM_INITIALIZER
13042 		(struct cmd_config_e_tag_result,
13043 		 vf_id, UINT8);
13044 
13045 /* E-tag insertion configuration */
13046 static void
13047 cmd_config_e_tag_insertion_en_parsed(
13048 	void *parsed_result,
13049 	__attribute__((unused)) struct cmdline *cl,
13050 	__attribute__((unused)) void *data)
13051 {
13052 	struct cmd_config_e_tag_result *res =
13053 		parsed_result;
13054 	struct rte_eth_l2_tunnel_conf entry;
13055 
13056 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13057 		return;
13058 
13059 	entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13060 	entry.tunnel_id = res->port_tag_id_val;
13061 	entry.vf_id = res->vf_id;
13062 	rte_eth_dev_l2_tunnel_offload_set(res->port_id,
13063 					  &entry,
13064 					  ETH_L2_TUNNEL_INSERTION_MASK,
13065 					  1);
13066 }
13067 
13068 static void
13069 cmd_config_e_tag_insertion_dis_parsed(
13070 	void *parsed_result,
13071 	__attribute__((unused)) struct cmdline *cl,
13072 	__attribute__((unused)) void *data)
13073 {
13074 	struct cmd_config_e_tag_result *res =
13075 		parsed_result;
13076 	struct rte_eth_l2_tunnel_conf entry;
13077 
13078 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13079 		return;
13080 
13081 	entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13082 	entry.vf_id = res->vf_id;
13083 
13084 	rte_eth_dev_l2_tunnel_offload_set(res->port_id,
13085 					  &entry,
13086 					  ETH_L2_TUNNEL_INSERTION_MASK,
13087 					  0);
13088 }
13089 
13090 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
13091 	.f = cmd_config_e_tag_insertion_en_parsed,
13092 	.data = NULL,
13093 	.help_str = "E-tag ... : E-tag insertion enable",
13094 	.tokens = {
13095 		(void *)&cmd_config_e_tag_e_tag,
13096 		(void *)&cmd_config_e_tag_set,
13097 		(void *)&cmd_config_e_tag_insertion,
13098 		(void *)&cmd_config_e_tag_on,
13099 		(void *)&cmd_config_e_tag_port_tag_id,
13100 		(void *)&cmd_config_e_tag_port_tag_id_val,
13101 		(void *)&cmd_config_e_tag_port,
13102 		(void *)&cmd_config_e_tag_port_id,
13103 		(void *)&cmd_config_e_tag_vf,
13104 		(void *)&cmd_config_e_tag_vf_id,
13105 		NULL,
13106 	},
13107 };
13108 
13109 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
13110 	.f = cmd_config_e_tag_insertion_dis_parsed,
13111 	.data = NULL,
13112 	.help_str = "E-tag ... : E-tag insertion disable",
13113 	.tokens = {
13114 		(void *)&cmd_config_e_tag_e_tag,
13115 		(void *)&cmd_config_e_tag_set,
13116 		(void *)&cmd_config_e_tag_insertion,
13117 		(void *)&cmd_config_e_tag_off,
13118 		(void *)&cmd_config_e_tag_port,
13119 		(void *)&cmd_config_e_tag_port_id,
13120 		(void *)&cmd_config_e_tag_vf,
13121 		(void *)&cmd_config_e_tag_vf_id,
13122 		NULL,
13123 	},
13124 };
13125 
13126 /* E-tag stripping configuration */
13127 static void
13128 cmd_config_e_tag_stripping_parsed(
13129 	void *parsed_result,
13130 	__attribute__((unused)) struct cmdline *cl,
13131 	__attribute__((unused)) void *data)
13132 {
13133 	struct cmd_config_e_tag_result *res =
13134 		parsed_result;
13135 	struct rte_eth_l2_tunnel_conf entry;
13136 
13137 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13138 		return;
13139 
13140 	entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13141 
13142 	if (!strcmp(res->on_off, "on"))
13143 		rte_eth_dev_l2_tunnel_offload_set
13144 			(res->port_id,
13145 			 &entry,
13146 			 ETH_L2_TUNNEL_STRIPPING_MASK,
13147 			 1);
13148 	else
13149 		rte_eth_dev_l2_tunnel_offload_set
13150 			(res->port_id,
13151 			 &entry,
13152 			 ETH_L2_TUNNEL_STRIPPING_MASK,
13153 			 0);
13154 }
13155 
13156 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
13157 	.f = cmd_config_e_tag_stripping_parsed,
13158 	.data = NULL,
13159 	.help_str = "E-tag ... : E-tag stripping enable/disable",
13160 	.tokens = {
13161 		(void *)&cmd_config_e_tag_e_tag,
13162 		(void *)&cmd_config_e_tag_set,
13163 		(void *)&cmd_config_e_tag_stripping,
13164 		(void *)&cmd_config_e_tag_on_off,
13165 		(void *)&cmd_config_e_tag_port,
13166 		(void *)&cmd_config_e_tag_port_id,
13167 		NULL,
13168 	},
13169 };
13170 
13171 /* E-tag forwarding configuration */
13172 static void
13173 cmd_config_e_tag_forwarding_parsed(
13174 	void *parsed_result,
13175 	__attribute__((unused)) struct cmdline *cl,
13176 	__attribute__((unused)) void *data)
13177 {
13178 	struct cmd_config_e_tag_result *res = parsed_result;
13179 	struct rte_eth_l2_tunnel_conf entry;
13180 
13181 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13182 		return;
13183 
13184 	entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13185 
13186 	if (!strcmp(res->on_off, "on"))
13187 		rte_eth_dev_l2_tunnel_offload_set
13188 			(res->port_id,
13189 			 &entry,
13190 			 ETH_L2_TUNNEL_FORWARDING_MASK,
13191 			 1);
13192 	else
13193 		rte_eth_dev_l2_tunnel_offload_set
13194 			(res->port_id,
13195 			 &entry,
13196 			 ETH_L2_TUNNEL_FORWARDING_MASK,
13197 			 0);
13198 }
13199 
13200 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
13201 	.f = cmd_config_e_tag_forwarding_parsed,
13202 	.data = NULL,
13203 	.help_str = "E-tag ... : E-tag forwarding enable/disable",
13204 	.tokens = {
13205 		(void *)&cmd_config_e_tag_e_tag,
13206 		(void *)&cmd_config_e_tag_set,
13207 		(void *)&cmd_config_e_tag_forwarding,
13208 		(void *)&cmd_config_e_tag_on_off,
13209 		(void *)&cmd_config_e_tag_port,
13210 		(void *)&cmd_config_e_tag_port_id,
13211 		NULL,
13212 	},
13213 };
13214 
13215 /* E-tag filter configuration */
13216 static void
13217 cmd_config_e_tag_filter_add_parsed(
13218 	void *parsed_result,
13219 	__attribute__((unused)) struct cmdline *cl,
13220 	__attribute__((unused)) void *data)
13221 {
13222 	struct cmd_config_e_tag_result *res = parsed_result;
13223 	struct rte_eth_l2_tunnel_conf entry;
13224 	int ret = 0;
13225 
13226 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13227 		return;
13228 
13229 	if (res->e_tag_id_val > 0x3fff) {
13230 		printf("e-tag-id must be equal or less than 0x3fff.\n");
13231 		return;
13232 	}
13233 
13234 	ret = rte_eth_dev_filter_supported(res->port_id,
13235 					   RTE_ETH_FILTER_L2_TUNNEL);
13236 	if (ret < 0) {
13237 		printf("E-tag filter is not supported on port %u.\n",
13238 		       res->port_id);
13239 		return;
13240 	}
13241 
13242 	entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13243 	entry.tunnel_id = res->e_tag_id_val;
13244 	entry.pool = res->dst_pool_val;
13245 
13246 	ret = rte_eth_dev_filter_ctrl(res->port_id,
13247 				      RTE_ETH_FILTER_L2_TUNNEL,
13248 				      RTE_ETH_FILTER_ADD,
13249 				      &entry);
13250 	if (ret < 0)
13251 		printf("E-tag filter programming error: (%s)\n",
13252 		       strerror(-ret));
13253 }
13254 
13255 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
13256 	.f = cmd_config_e_tag_filter_add_parsed,
13257 	.data = NULL,
13258 	.help_str = "E-tag ... : E-tag filter add",
13259 	.tokens = {
13260 		(void *)&cmd_config_e_tag_e_tag,
13261 		(void *)&cmd_config_e_tag_set,
13262 		(void *)&cmd_config_e_tag_filter,
13263 		(void *)&cmd_config_e_tag_add,
13264 		(void *)&cmd_config_e_tag_e_tag_id,
13265 		(void *)&cmd_config_e_tag_e_tag_id_val,
13266 		(void *)&cmd_config_e_tag_dst_pool,
13267 		(void *)&cmd_config_e_tag_dst_pool_val,
13268 		(void *)&cmd_config_e_tag_port,
13269 		(void *)&cmd_config_e_tag_port_id,
13270 		NULL,
13271 	},
13272 };
13273 
13274 static void
13275 cmd_config_e_tag_filter_del_parsed(
13276 	void *parsed_result,
13277 	__attribute__((unused)) struct cmdline *cl,
13278 	__attribute__((unused)) void *data)
13279 {
13280 	struct cmd_config_e_tag_result *res = parsed_result;
13281 	struct rte_eth_l2_tunnel_conf entry;
13282 	int ret = 0;
13283 
13284 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13285 		return;
13286 
13287 	if (res->e_tag_id_val > 0x3fff) {
13288 		printf("e-tag-id must be less than 0x3fff.\n");
13289 		return;
13290 	}
13291 
13292 	ret = rte_eth_dev_filter_supported(res->port_id,
13293 					   RTE_ETH_FILTER_L2_TUNNEL);
13294 	if (ret < 0) {
13295 		printf("E-tag filter is not supported on port %u.\n",
13296 		       res->port_id);
13297 		return;
13298 	}
13299 
13300 	entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13301 	entry.tunnel_id = res->e_tag_id_val;
13302 
13303 	ret = rte_eth_dev_filter_ctrl(res->port_id,
13304 				      RTE_ETH_FILTER_L2_TUNNEL,
13305 				      RTE_ETH_FILTER_DELETE,
13306 				      &entry);
13307 	if (ret < 0)
13308 		printf("E-tag filter programming error: (%s)\n",
13309 		       strerror(-ret));
13310 }
13311 
13312 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
13313 	.f = cmd_config_e_tag_filter_del_parsed,
13314 	.data = NULL,
13315 	.help_str = "E-tag ... : E-tag filter delete",
13316 	.tokens = {
13317 		(void *)&cmd_config_e_tag_e_tag,
13318 		(void *)&cmd_config_e_tag_set,
13319 		(void *)&cmd_config_e_tag_filter,
13320 		(void *)&cmd_config_e_tag_del,
13321 		(void *)&cmd_config_e_tag_e_tag_id,
13322 		(void *)&cmd_config_e_tag_e_tag_id_val,
13323 		(void *)&cmd_config_e_tag_port,
13324 		(void *)&cmd_config_e_tag_port_id,
13325 		NULL,
13326 	},
13327 };
13328 
13329 /* vf vlan anti spoof configuration */
13330 
13331 /* Common result structure for vf vlan anti spoof */
13332 struct cmd_vf_vlan_anti_spoof_result {
13333 	cmdline_fixed_string_t set;
13334 	cmdline_fixed_string_t vf;
13335 	cmdline_fixed_string_t vlan;
13336 	cmdline_fixed_string_t antispoof;
13337 	portid_t port_id;
13338 	uint32_t vf_id;
13339 	cmdline_fixed_string_t on_off;
13340 };
13341 
13342 /* Common CLI fields for vf vlan anti spoof enable disable */
13343 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
13344 	TOKEN_STRING_INITIALIZER
13345 		(struct cmd_vf_vlan_anti_spoof_result,
13346 		 set, "set");
13347 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
13348 	TOKEN_STRING_INITIALIZER
13349 		(struct cmd_vf_vlan_anti_spoof_result,
13350 		 vf, "vf");
13351 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
13352 	TOKEN_STRING_INITIALIZER
13353 		(struct cmd_vf_vlan_anti_spoof_result,
13354 		 vlan, "vlan");
13355 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
13356 	TOKEN_STRING_INITIALIZER
13357 		(struct cmd_vf_vlan_anti_spoof_result,
13358 		 antispoof, "antispoof");
13359 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
13360 	TOKEN_NUM_INITIALIZER
13361 		(struct cmd_vf_vlan_anti_spoof_result,
13362 		 port_id, UINT16);
13363 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
13364 	TOKEN_NUM_INITIALIZER
13365 		(struct cmd_vf_vlan_anti_spoof_result,
13366 		 vf_id, UINT32);
13367 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
13368 	TOKEN_STRING_INITIALIZER
13369 		(struct cmd_vf_vlan_anti_spoof_result,
13370 		 on_off, "on#off");
13371 
13372 static void
13373 cmd_set_vf_vlan_anti_spoof_parsed(
13374 	void *parsed_result,
13375 	__attribute__((unused)) struct cmdline *cl,
13376 	__attribute__((unused)) void *data)
13377 {
13378 	struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
13379 	int ret = -ENOTSUP;
13380 
13381 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13382 
13383 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13384 		return;
13385 
13386 #ifdef RTE_LIBRTE_IXGBE_PMD
13387 	if (ret == -ENOTSUP)
13388 		ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
13389 				res->vf_id, is_on);
13390 #endif
13391 #ifdef RTE_LIBRTE_I40E_PMD
13392 	if (ret == -ENOTSUP)
13393 		ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
13394 				res->vf_id, is_on);
13395 #endif
13396 #ifdef RTE_LIBRTE_BNXT_PMD
13397 	if (ret == -ENOTSUP)
13398 		ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
13399 				res->vf_id, is_on);
13400 #endif
13401 
13402 	switch (ret) {
13403 	case 0:
13404 		break;
13405 	case -EINVAL:
13406 		printf("invalid vf_id %d\n", res->vf_id);
13407 		break;
13408 	case -ENODEV:
13409 		printf("invalid port_id %d\n", res->port_id);
13410 		break;
13411 	case -ENOTSUP:
13412 		printf("function not implemented\n");
13413 		break;
13414 	default:
13415 		printf("programming error: (%s)\n", strerror(-ret));
13416 	}
13417 }
13418 
13419 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
13420 	.f = cmd_set_vf_vlan_anti_spoof_parsed,
13421 	.data = NULL,
13422 	.help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
13423 	.tokens = {
13424 		(void *)&cmd_vf_vlan_anti_spoof_set,
13425 		(void *)&cmd_vf_vlan_anti_spoof_vf,
13426 		(void *)&cmd_vf_vlan_anti_spoof_vlan,
13427 		(void *)&cmd_vf_vlan_anti_spoof_antispoof,
13428 		(void *)&cmd_vf_vlan_anti_spoof_port_id,
13429 		(void *)&cmd_vf_vlan_anti_spoof_vf_id,
13430 		(void *)&cmd_vf_vlan_anti_spoof_on_off,
13431 		NULL,
13432 	},
13433 };
13434 
13435 /* vf mac anti spoof configuration */
13436 
13437 /* Common result structure for vf mac anti spoof */
13438 struct cmd_vf_mac_anti_spoof_result {
13439 	cmdline_fixed_string_t set;
13440 	cmdline_fixed_string_t vf;
13441 	cmdline_fixed_string_t mac;
13442 	cmdline_fixed_string_t antispoof;
13443 	portid_t port_id;
13444 	uint32_t vf_id;
13445 	cmdline_fixed_string_t on_off;
13446 };
13447 
13448 /* Common CLI fields for vf mac anti spoof enable disable */
13449 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
13450 	TOKEN_STRING_INITIALIZER
13451 		(struct cmd_vf_mac_anti_spoof_result,
13452 		 set, "set");
13453 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
13454 	TOKEN_STRING_INITIALIZER
13455 		(struct cmd_vf_mac_anti_spoof_result,
13456 		 vf, "vf");
13457 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
13458 	TOKEN_STRING_INITIALIZER
13459 		(struct cmd_vf_mac_anti_spoof_result,
13460 		 mac, "mac");
13461 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
13462 	TOKEN_STRING_INITIALIZER
13463 		(struct cmd_vf_mac_anti_spoof_result,
13464 		 antispoof, "antispoof");
13465 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
13466 	TOKEN_NUM_INITIALIZER
13467 		(struct cmd_vf_mac_anti_spoof_result,
13468 		 port_id, UINT16);
13469 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
13470 	TOKEN_NUM_INITIALIZER
13471 		(struct cmd_vf_mac_anti_spoof_result,
13472 		 vf_id, UINT32);
13473 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
13474 	TOKEN_STRING_INITIALIZER
13475 		(struct cmd_vf_mac_anti_spoof_result,
13476 		 on_off, "on#off");
13477 
13478 static void
13479 cmd_set_vf_mac_anti_spoof_parsed(
13480 	void *parsed_result,
13481 	__attribute__((unused)) struct cmdline *cl,
13482 	__attribute__((unused)) void *data)
13483 {
13484 	struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
13485 	int ret = -ENOTSUP;
13486 
13487 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13488 
13489 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13490 		return;
13491 
13492 #ifdef RTE_LIBRTE_IXGBE_PMD
13493 	if (ret == -ENOTSUP)
13494 		ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
13495 			res->vf_id, is_on);
13496 #endif
13497 #ifdef RTE_LIBRTE_I40E_PMD
13498 	if (ret == -ENOTSUP)
13499 		ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
13500 			res->vf_id, is_on);
13501 #endif
13502 #ifdef RTE_LIBRTE_BNXT_PMD
13503 	if (ret == -ENOTSUP)
13504 		ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
13505 			res->vf_id, is_on);
13506 #endif
13507 
13508 	switch (ret) {
13509 	case 0:
13510 		break;
13511 	case -EINVAL:
13512 		printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13513 		break;
13514 	case -ENODEV:
13515 		printf("invalid port_id %d\n", res->port_id);
13516 		break;
13517 	case -ENOTSUP:
13518 		printf("function not implemented\n");
13519 		break;
13520 	default:
13521 		printf("programming error: (%s)\n", strerror(-ret));
13522 	}
13523 }
13524 
13525 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
13526 	.f = cmd_set_vf_mac_anti_spoof_parsed,
13527 	.data = NULL,
13528 	.help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
13529 	.tokens = {
13530 		(void *)&cmd_vf_mac_anti_spoof_set,
13531 		(void *)&cmd_vf_mac_anti_spoof_vf,
13532 		(void *)&cmd_vf_mac_anti_spoof_mac,
13533 		(void *)&cmd_vf_mac_anti_spoof_antispoof,
13534 		(void *)&cmd_vf_mac_anti_spoof_port_id,
13535 		(void *)&cmd_vf_mac_anti_spoof_vf_id,
13536 		(void *)&cmd_vf_mac_anti_spoof_on_off,
13537 		NULL,
13538 	},
13539 };
13540 
13541 /* vf vlan strip queue configuration */
13542 
13543 /* Common result structure for vf mac anti spoof */
13544 struct cmd_vf_vlan_stripq_result {
13545 	cmdline_fixed_string_t set;
13546 	cmdline_fixed_string_t vf;
13547 	cmdline_fixed_string_t vlan;
13548 	cmdline_fixed_string_t stripq;
13549 	portid_t port_id;
13550 	uint16_t vf_id;
13551 	cmdline_fixed_string_t on_off;
13552 };
13553 
13554 /* Common CLI fields for vf vlan strip enable disable */
13555 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
13556 	TOKEN_STRING_INITIALIZER
13557 		(struct cmd_vf_vlan_stripq_result,
13558 		 set, "set");
13559 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
13560 	TOKEN_STRING_INITIALIZER
13561 		(struct cmd_vf_vlan_stripq_result,
13562 		 vf, "vf");
13563 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
13564 	TOKEN_STRING_INITIALIZER
13565 		(struct cmd_vf_vlan_stripq_result,
13566 		 vlan, "vlan");
13567 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
13568 	TOKEN_STRING_INITIALIZER
13569 		(struct cmd_vf_vlan_stripq_result,
13570 		 stripq, "stripq");
13571 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
13572 	TOKEN_NUM_INITIALIZER
13573 		(struct cmd_vf_vlan_stripq_result,
13574 		 port_id, UINT16);
13575 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
13576 	TOKEN_NUM_INITIALIZER
13577 		(struct cmd_vf_vlan_stripq_result,
13578 		 vf_id, UINT16);
13579 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
13580 	TOKEN_STRING_INITIALIZER
13581 		(struct cmd_vf_vlan_stripq_result,
13582 		 on_off, "on#off");
13583 
13584 static void
13585 cmd_set_vf_vlan_stripq_parsed(
13586 	void *parsed_result,
13587 	__attribute__((unused)) struct cmdline *cl,
13588 	__attribute__((unused)) void *data)
13589 {
13590 	struct cmd_vf_vlan_stripq_result *res = parsed_result;
13591 	int ret = -ENOTSUP;
13592 
13593 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13594 
13595 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13596 		return;
13597 
13598 #ifdef RTE_LIBRTE_IXGBE_PMD
13599 	if (ret == -ENOTSUP)
13600 		ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
13601 			res->vf_id, is_on);
13602 #endif
13603 #ifdef RTE_LIBRTE_I40E_PMD
13604 	if (ret == -ENOTSUP)
13605 		ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
13606 			res->vf_id, is_on);
13607 #endif
13608 #ifdef RTE_LIBRTE_BNXT_PMD
13609 	if (ret == -ENOTSUP)
13610 		ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
13611 			res->vf_id, is_on);
13612 #endif
13613 
13614 	switch (ret) {
13615 	case 0:
13616 		break;
13617 	case -EINVAL:
13618 		printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13619 		break;
13620 	case -ENODEV:
13621 		printf("invalid port_id %d\n", res->port_id);
13622 		break;
13623 	case -ENOTSUP:
13624 		printf("function not implemented\n");
13625 		break;
13626 	default:
13627 		printf("programming error: (%s)\n", strerror(-ret));
13628 	}
13629 }
13630 
13631 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
13632 	.f = cmd_set_vf_vlan_stripq_parsed,
13633 	.data = NULL,
13634 	.help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
13635 	.tokens = {
13636 		(void *)&cmd_vf_vlan_stripq_set,
13637 		(void *)&cmd_vf_vlan_stripq_vf,
13638 		(void *)&cmd_vf_vlan_stripq_vlan,
13639 		(void *)&cmd_vf_vlan_stripq_stripq,
13640 		(void *)&cmd_vf_vlan_stripq_port_id,
13641 		(void *)&cmd_vf_vlan_stripq_vf_id,
13642 		(void *)&cmd_vf_vlan_stripq_on_off,
13643 		NULL,
13644 	},
13645 };
13646 
13647 /* vf vlan insert configuration */
13648 
13649 /* Common result structure for vf vlan insert */
13650 struct cmd_vf_vlan_insert_result {
13651 	cmdline_fixed_string_t set;
13652 	cmdline_fixed_string_t vf;
13653 	cmdline_fixed_string_t vlan;
13654 	cmdline_fixed_string_t insert;
13655 	portid_t port_id;
13656 	uint16_t vf_id;
13657 	uint16_t vlan_id;
13658 };
13659 
13660 /* Common CLI fields for vf vlan insert enable disable */
13661 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
13662 	TOKEN_STRING_INITIALIZER
13663 		(struct cmd_vf_vlan_insert_result,
13664 		 set, "set");
13665 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
13666 	TOKEN_STRING_INITIALIZER
13667 		(struct cmd_vf_vlan_insert_result,
13668 		 vf, "vf");
13669 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
13670 	TOKEN_STRING_INITIALIZER
13671 		(struct cmd_vf_vlan_insert_result,
13672 		 vlan, "vlan");
13673 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
13674 	TOKEN_STRING_INITIALIZER
13675 		(struct cmd_vf_vlan_insert_result,
13676 		 insert, "insert");
13677 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
13678 	TOKEN_NUM_INITIALIZER
13679 		(struct cmd_vf_vlan_insert_result,
13680 		 port_id, UINT16);
13681 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
13682 	TOKEN_NUM_INITIALIZER
13683 		(struct cmd_vf_vlan_insert_result,
13684 		 vf_id, UINT16);
13685 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
13686 	TOKEN_NUM_INITIALIZER
13687 		(struct cmd_vf_vlan_insert_result,
13688 		 vlan_id, UINT16);
13689 
13690 static void
13691 cmd_set_vf_vlan_insert_parsed(
13692 	void *parsed_result,
13693 	__attribute__((unused)) struct cmdline *cl,
13694 	__attribute__((unused)) void *data)
13695 {
13696 	struct cmd_vf_vlan_insert_result *res = parsed_result;
13697 	int ret = -ENOTSUP;
13698 
13699 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13700 		return;
13701 
13702 #ifdef RTE_LIBRTE_IXGBE_PMD
13703 	if (ret == -ENOTSUP)
13704 		ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
13705 			res->vlan_id);
13706 #endif
13707 #ifdef RTE_LIBRTE_I40E_PMD
13708 	if (ret == -ENOTSUP)
13709 		ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
13710 			res->vlan_id);
13711 #endif
13712 #ifdef RTE_LIBRTE_BNXT_PMD
13713 	if (ret == -ENOTSUP)
13714 		ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
13715 			res->vlan_id);
13716 #endif
13717 
13718 	switch (ret) {
13719 	case 0:
13720 		break;
13721 	case -EINVAL:
13722 		printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
13723 		break;
13724 	case -ENODEV:
13725 		printf("invalid port_id %d\n", res->port_id);
13726 		break;
13727 	case -ENOTSUP:
13728 		printf("function not implemented\n");
13729 		break;
13730 	default:
13731 		printf("programming error: (%s)\n", strerror(-ret));
13732 	}
13733 }
13734 
13735 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
13736 	.f = cmd_set_vf_vlan_insert_parsed,
13737 	.data = NULL,
13738 	.help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
13739 	.tokens = {
13740 		(void *)&cmd_vf_vlan_insert_set,
13741 		(void *)&cmd_vf_vlan_insert_vf,
13742 		(void *)&cmd_vf_vlan_insert_vlan,
13743 		(void *)&cmd_vf_vlan_insert_insert,
13744 		(void *)&cmd_vf_vlan_insert_port_id,
13745 		(void *)&cmd_vf_vlan_insert_vf_id,
13746 		(void *)&cmd_vf_vlan_insert_vlan_id,
13747 		NULL,
13748 	},
13749 };
13750 
13751 /* tx loopback configuration */
13752 
13753 /* Common result structure for tx loopback */
13754 struct cmd_tx_loopback_result {
13755 	cmdline_fixed_string_t set;
13756 	cmdline_fixed_string_t tx;
13757 	cmdline_fixed_string_t loopback;
13758 	portid_t port_id;
13759 	cmdline_fixed_string_t on_off;
13760 };
13761 
13762 /* Common CLI fields for tx loopback enable disable */
13763 cmdline_parse_token_string_t cmd_tx_loopback_set =
13764 	TOKEN_STRING_INITIALIZER
13765 		(struct cmd_tx_loopback_result,
13766 		 set, "set");
13767 cmdline_parse_token_string_t cmd_tx_loopback_tx =
13768 	TOKEN_STRING_INITIALIZER
13769 		(struct cmd_tx_loopback_result,
13770 		 tx, "tx");
13771 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
13772 	TOKEN_STRING_INITIALIZER
13773 		(struct cmd_tx_loopback_result,
13774 		 loopback, "loopback");
13775 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
13776 	TOKEN_NUM_INITIALIZER
13777 		(struct cmd_tx_loopback_result,
13778 		 port_id, UINT16);
13779 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
13780 	TOKEN_STRING_INITIALIZER
13781 		(struct cmd_tx_loopback_result,
13782 		 on_off, "on#off");
13783 
13784 static void
13785 cmd_set_tx_loopback_parsed(
13786 	void *parsed_result,
13787 	__attribute__((unused)) struct cmdline *cl,
13788 	__attribute__((unused)) void *data)
13789 {
13790 	struct cmd_tx_loopback_result *res = parsed_result;
13791 	int ret = -ENOTSUP;
13792 
13793 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13794 
13795 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13796 		return;
13797 
13798 #ifdef RTE_LIBRTE_IXGBE_PMD
13799 	if (ret == -ENOTSUP)
13800 		ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
13801 #endif
13802 #ifdef RTE_LIBRTE_I40E_PMD
13803 	if (ret == -ENOTSUP)
13804 		ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
13805 #endif
13806 #ifdef RTE_LIBRTE_BNXT_PMD
13807 	if (ret == -ENOTSUP)
13808 		ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
13809 #endif
13810 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD
13811 	if (ret == -ENOTSUP)
13812 		ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
13813 #endif
13814 
13815 	switch (ret) {
13816 	case 0:
13817 		break;
13818 	case -EINVAL:
13819 		printf("invalid is_on %d\n", is_on);
13820 		break;
13821 	case -ENODEV:
13822 		printf("invalid port_id %d\n", res->port_id);
13823 		break;
13824 	case -ENOTSUP:
13825 		printf("function not implemented\n");
13826 		break;
13827 	default:
13828 		printf("programming error: (%s)\n", strerror(-ret));
13829 	}
13830 }
13831 
13832 cmdline_parse_inst_t cmd_set_tx_loopback = {
13833 	.f = cmd_set_tx_loopback_parsed,
13834 	.data = NULL,
13835 	.help_str = "set tx loopback <port_id> on|off",
13836 	.tokens = {
13837 		(void *)&cmd_tx_loopback_set,
13838 		(void *)&cmd_tx_loopback_tx,
13839 		(void *)&cmd_tx_loopback_loopback,
13840 		(void *)&cmd_tx_loopback_port_id,
13841 		(void *)&cmd_tx_loopback_on_off,
13842 		NULL,
13843 	},
13844 };
13845 
13846 /* all queues drop enable configuration */
13847 
13848 /* Common result structure for all queues drop enable */
13849 struct cmd_all_queues_drop_en_result {
13850 	cmdline_fixed_string_t set;
13851 	cmdline_fixed_string_t all;
13852 	cmdline_fixed_string_t queues;
13853 	cmdline_fixed_string_t drop;
13854 	portid_t port_id;
13855 	cmdline_fixed_string_t on_off;
13856 };
13857 
13858 /* Common CLI fields for tx loopback enable disable */
13859 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
13860 	TOKEN_STRING_INITIALIZER
13861 		(struct cmd_all_queues_drop_en_result,
13862 		 set, "set");
13863 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
13864 	TOKEN_STRING_INITIALIZER
13865 		(struct cmd_all_queues_drop_en_result,
13866 		 all, "all");
13867 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
13868 	TOKEN_STRING_INITIALIZER
13869 		(struct cmd_all_queues_drop_en_result,
13870 		 queues, "queues");
13871 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
13872 	TOKEN_STRING_INITIALIZER
13873 		(struct cmd_all_queues_drop_en_result,
13874 		 drop, "drop");
13875 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
13876 	TOKEN_NUM_INITIALIZER
13877 		(struct cmd_all_queues_drop_en_result,
13878 		 port_id, UINT16);
13879 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
13880 	TOKEN_STRING_INITIALIZER
13881 		(struct cmd_all_queues_drop_en_result,
13882 		 on_off, "on#off");
13883 
13884 static void
13885 cmd_set_all_queues_drop_en_parsed(
13886 	void *parsed_result,
13887 	__attribute__((unused)) struct cmdline *cl,
13888 	__attribute__((unused)) void *data)
13889 {
13890 	struct cmd_all_queues_drop_en_result *res = parsed_result;
13891 	int ret = -ENOTSUP;
13892 	int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13893 
13894 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13895 		return;
13896 
13897 #ifdef RTE_LIBRTE_IXGBE_PMD
13898 	if (ret == -ENOTSUP)
13899 		ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
13900 #endif
13901 #ifdef RTE_LIBRTE_BNXT_PMD
13902 	if (ret == -ENOTSUP)
13903 		ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
13904 #endif
13905 	switch (ret) {
13906 	case 0:
13907 		break;
13908 	case -EINVAL:
13909 		printf("invalid is_on %d\n", is_on);
13910 		break;
13911 	case -ENODEV:
13912 		printf("invalid port_id %d\n", res->port_id);
13913 		break;
13914 	case -ENOTSUP:
13915 		printf("function not implemented\n");
13916 		break;
13917 	default:
13918 		printf("programming error: (%s)\n", strerror(-ret));
13919 	}
13920 }
13921 
13922 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
13923 	.f = cmd_set_all_queues_drop_en_parsed,
13924 	.data = NULL,
13925 	.help_str = "set all queues drop <port_id> on|off",
13926 	.tokens = {
13927 		(void *)&cmd_all_queues_drop_en_set,
13928 		(void *)&cmd_all_queues_drop_en_all,
13929 		(void *)&cmd_all_queues_drop_en_queues,
13930 		(void *)&cmd_all_queues_drop_en_drop,
13931 		(void *)&cmd_all_queues_drop_en_port_id,
13932 		(void *)&cmd_all_queues_drop_en_on_off,
13933 		NULL,
13934 	},
13935 };
13936 
13937 /* vf split drop enable configuration */
13938 
13939 /* Common result structure for vf split drop enable */
13940 struct cmd_vf_split_drop_en_result {
13941 	cmdline_fixed_string_t set;
13942 	cmdline_fixed_string_t vf;
13943 	cmdline_fixed_string_t split;
13944 	cmdline_fixed_string_t drop;
13945 	portid_t port_id;
13946 	uint16_t vf_id;
13947 	cmdline_fixed_string_t on_off;
13948 };
13949 
13950 /* Common CLI fields for vf split drop enable disable */
13951 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
13952 	TOKEN_STRING_INITIALIZER
13953 		(struct cmd_vf_split_drop_en_result,
13954 		 set, "set");
13955 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
13956 	TOKEN_STRING_INITIALIZER
13957 		(struct cmd_vf_split_drop_en_result,
13958 		 vf, "vf");
13959 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
13960 	TOKEN_STRING_INITIALIZER
13961 		(struct cmd_vf_split_drop_en_result,
13962 		 split, "split");
13963 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
13964 	TOKEN_STRING_INITIALIZER
13965 		(struct cmd_vf_split_drop_en_result,
13966 		 drop, "drop");
13967 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
13968 	TOKEN_NUM_INITIALIZER
13969 		(struct cmd_vf_split_drop_en_result,
13970 		 port_id, UINT16);
13971 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
13972 	TOKEN_NUM_INITIALIZER
13973 		(struct cmd_vf_split_drop_en_result,
13974 		 vf_id, UINT16);
13975 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
13976 	TOKEN_STRING_INITIALIZER
13977 		(struct cmd_vf_split_drop_en_result,
13978 		 on_off, "on#off");
13979 
13980 static void
13981 cmd_set_vf_split_drop_en_parsed(
13982 	void *parsed_result,
13983 	__attribute__((unused)) struct cmdline *cl,
13984 	__attribute__((unused)) void *data)
13985 {
13986 	struct cmd_vf_split_drop_en_result *res = parsed_result;
13987 	int ret = -ENOTSUP;
13988 	int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13989 
13990 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13991 		return;
13992 
13993 #ifdef RTE_LIBRTE_IXGBE_PMD
13994 	ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
13995 			is_on);
13996 #endif
13997 	switch (ret) {
13998 	case 0:
13999 		break;
14000 	case -EINVAL:
14001 		printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14002 		break;
14003 	case -ENODEV:
14004 		printf("invalid port_id %d\n", res->port_id);
14005 		break;
14006 	case -ENOTSUP:
14007 		printf("not supported on port %d\n", res->port_id);
14008 		break;
14009 	default:
14010 		printf("programming error: (%s)\n", strerror(-ret));
14011 	}
14012 }
14013 
14014 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
14015 	.f = cmd_set_vf_split_drop_en_parsed,
14016 	.data = NULL,
14017 	.help_str = "set vf split drop <port_id> <vf_id> on|off",
14018 	.tokens = {
14019 		(void *)&cmd_vf_split_drop_en_set,
14020 		(void *)&cmd_vf_split_drop_en_vf,
14021 		(void *)&cmd_vf_split_drop_en_split,
14022 		(void *)&cmd_vf_split_drop_en_drop,
14023 		(void *)&cmd_vf_split_drop_en_port_id,
14024 		(void *)&cmd_vf_split_drop_en_vf_id,
14025 		(void *)&cmd_vf_split_drop_en_on_off,
14026 		NULL,
14027 	},
14028 };
14029 
14030 /* vf mac address configuration */
14031 
14032 /* Common result structure for vf mac address */
14033 struct cmd_set_vf_mac_addr_result {
14034 	cmdline_fixed_string_t set;
14035 	cmdline_fixed_string_t vf;
14036 	cmdline_fixed_string_t mac;
14037 	cmdline_fixed_string_t addr;
14038 	portid_t port_id;
14039 	uint16_t vf_id;
14040 	struct rte_ether_addr mac_addr;
14041 
14042 };
14043 
14044 /* Common CLI fields for vf split drop enable disable */
14045 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
14046 	TOKEN_STRING_INITIALIZER
14047 		(struct cmd_set_vf_mac_addr_result,
14048 		 set, "set");
14049 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
14050 	TOKEN_STRING_INITIALIZER
14051 		(struct cmd_set_vf_mac_addr_result,
14052 		 vf, "vf");
14053 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
14054 	TOKEN_STRING_INITIALIZER
14055 		(struct cmd_set_vf_mac_addr_result,
14056 		 mac, "mac");
14057 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
14058 	TOKEN_STRING_INITIALIZER
14059 		(struct cmd_set_vf_mac_addr_result,
14060 		 addr, "addr");
14061 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
14062 	TOKEN_NUM_INITIALIZER
14063 		(struct cmd_set_vf_mac_addr_result,
14064 		 port_id, UINT16);
14065 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
14066 	TOKEN_NUM_INITIALIZER
14067 		(struct cmd_set_vf_mac_addr_result,
14068 		 vf_id, UINT16);
14069 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
14070 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
14071 		 mac_addr);
14072 
14073 static void
14074 cmd_set_vf_mac_addr_parsed(
14075 	void *parsed_result,
14076 	__attribute__((unused)) struct cmdline *cl,
14077 	__attribute__((unused)) void *data)
14078 {
14079 	struct cmd_set_vf_mac_addr_result *res = parsed_result;
14080 	int ret = -ENOTSUP;
14081 
14082 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14083 		return;
14084 
14085 #ifdef RTE_LIBRTE_IXGBE_PMD
14086 	if (ret == -ENOTSUP)
14087 		ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
14088 				&res->mac_addr);
14089 #endif
14090 #ifdef RTE_LIBRTE_I40E_PMD
14091 	if (ret == -ENOTSUP)
14092 		ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
14093 				&res->mac_addr);
14094 #endif
14095 #ifdef RTE_LIBRTE_BNXT_PMD
14096 	if (ret == -ENOTSUP)
14097 		ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
14098 				&res->mac_addr);
14099 #endif
14100 
14101 	switch (ret) {
14102 	case 0:
14103 		break;
14104 	case -EINVAL:
14105 		printf("invalid vf_id %d or mac_addr\n", res->vf_id);
14106 		break;
14107 	case -ENODEV:
14108 		printf("invalid port_id %d\n", res->port_id);
14109 		break;
14110 	case -ENOTSUP:
14111 		printf("function not implemented\n");
14112 		break;
14113 	default:
14114 		printf("programming error: (%s)\n", strerror(-ret));
14115 	}
14116 }
14117 
14118 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
14119 	.f = cmd_set_vf_mac_addr_parsed,
14120 	.data = NULL,
14121 	.help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
14122 	.tokens = {
14123 		(void *)&cmd_set_vf_mac_addr_set,
14124 		(void *)&cmd_set_vf_mac_addr_vf,
14125 		(void *)&cmd_set_vf_mac_addr_mac,
14126 		(void *)&cmd_set_vf_mac_addr_addr,
14127 		(void *)&cmd_set_vf_mac_addr_port_id,
14128 		(void *)&cmd_set_vf_mac_addr_vf_id,
14129 		(void *)&cmd_set_vf_mac_addr_mac_addr,
14130 		NULL,
14131 	},
14132 };
14133 
14134 /* MACsec configuration */
14135 
14136 /* Common result structure for MACsec offload enable */
14137 struct cmd_macsec_offload_on_result {
14138 	cmdline_fixed_string_t set;
14139 	cmdline_fixed_string_t macsec;
14140 	cmdline_fixed_string_t offload;
14141 	portid_t port_id;
14142 	cmdline_fixed_string_t on;
14143 	cmdline_fixed_string_t encrypt;
14144 	cmdline_fixed_string_t en_on_off;
14145 	cmdline_fixed_string_t replay_protect;
14146 	cmdline_fixed_string_t rp_on_off;
14147 };
14148 
14149 /* Common CLI fields for MACsec offload disable */
14150 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
14151 	TOKEN_STRING_INITIALIZER
14152 		(struct cmd_macsec_offload_on_result,
14153 		 set, "set");
14154 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
14155 	TOKEN_STRING_INITIALIZER
14156 		(struct cmd_macsec_offload_on_result,
14157 		 macsec, "macsec");
14158 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
14159 	TOKEN_STRING_INITIALIZER
14160 		(struct cmd_macsec_offload_on_result,
14161 		 offload, "offload");
14162 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
14163 	TOKEN_NUM_INITIALIZER
14164 		(struct cmd_macsec_offload_on_result,
14165 		 port_id, UINT16);
14166 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
14167 	TOKEN_STRING_INITIALIZER
14168 		(struct cmd_macsec_offload_on_result,
14169 		 on, "on");
14170 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
14171 	TOKEN_STRING_INITIALIZER
14172 		(struct cmd_macsec_offload_on_result,
14173 		 encrypt, "encrypt");
14174 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
14175 	TOKEN_STRING_INITIALIZER
14176 		(struct cmd_macsec_offload_on_result,
14177 		 en_on_off, "on#off");
14178 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
14179 	TOKEN_STRING_INITIALIZER
14180 		(struct cmd_macsec_offload_on_result,
14181 		 replay_protect, "replay-protect");
14182 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
14183 	TOKEN_STRING_INITIALIZER
14184 		(struct cmd_macsec_offload_on_result,
14185 		 rp_on_off, "on#off");
14186 
14187 static void
14188 cmd_set_macsec_offload_on_parsed(
14189 	void *parsed_result,
14190 	__attribute__((unused)) struct cmdline *cl,
14191 	__attribute__((unused)) void *data)
14192 {
14193 	struct cmd_macsec_offload_on_result *res = parsed_result;
14194 	int ret = -ENOTSUP;
14195 	portid_t port_id = res->port_id;
14196 	int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
14197 	int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
14198 	struct rte_eth_dev_info dev_info;
14199 
14200 	if (port_id_is_invalid(port_id, ENABLED_WARN))
14201 		return;
14202 	if (!port_is_stopped(port_id)) {
14203 		printf("Please stop port %d first\n", port_id);
14204 		return;
14205 	}
14206 
14207 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
14208 	if (ret != 0)
14209 		return;
14210 
14211 	if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
14212 #ifdef RTE_LIBRTE_IXGBE_PMD
14213 		ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
14214 #endif
14215 	}
14216 	RTE_SET_USED(en);
14217 	RTE_SET_USED(rp);
14218 
14219 	switch (ret) {
14220 	case 0:
14221 		ports[port_id].dev_conf.txmode.offloads |=
14222 						DEV_TX_OFFLOAD_MACSEC_INSERT;
14223 		cmd_reconfig_device_queue(port_id, 1, 1);
14224 		break;
14225 	case -ENODEV:
14226 		printf("invalid port_id %d\n", port_id);
14227 		break;
14228 	case -ENOTSUP:
14229 		printf("not supported on port %d\n", port_id);
14230 		break;
14231 	default:
14232 		printf("programming error: (%s)\n", strerror(-ret));
14233 	}
14234 }
14235 
14236 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
14237 	.f = cmd_set_macsec_offload_on_parsed,
14238 	.data = NULL,
14239 	.help_str = "set macsec offload <port_id> on "
14240 		"encrypt on|off replay-protect on|off",
14241 	.tokens = {
14242 		(void *)&cmd_macsec_offload_on_set,
14243 		(void *)&cmd_macsec_offload_on_macsec,
14244 		(void *)&cmd_macsec_offload_on_offload,
14245 		(void *)&cmd_macsec_offload_on_port_id,
14246 		(void *)&cmd_macsec_offload_on_on,
14247 		(void *)&cmd_macsec_offload_on_encrypt,
14248 		(void *)&cmd_macsec_offload_on_en_on_off,
14249 		(void *)&cmd_macsec_offload_on_replay_protect,
14250 		(void *)&cmd_macsec_offload_on_rp_on_off,
14251 		NULL,
14252 	},
14253 };
14254 
14255 /* Common result structure for MACsec offload disable */
14256 struct cmd_macsec_offload_off_result {
14257 	cmdline_fixed_string_t set;
14258 	cmdline_fixed_string_t macsec;
14259 	cmdline_fixed_string_t offload;
14260 	portid_t port_id;
14261 	cmdline_fixed_string_t off;
14262 };
14263 
14264 /* Common CLI fields for MACsec offload disable */
14265 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
14266 	TOKEN_STRING_INITIALIZER
14267 		(struct cmd_macsec_offload_off_result,
14268 		 set, "set");
14269 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
14270 	TOKEN_STRING_INITIALIZER
14271 		(struct cmd_macsec_offload_off_result,
14272 		 macsec, "macsec");
14273 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
14274 	TOKEN_STRING_INITIALIZER
14275 		(struct cmd_macsec_offload_off_result,
14276 		 offload, "offload");
14277 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
14278 	TOKEN_NUM_INITIALIZER
14279 		(struct cmd_macsec_offload_off_result,
14280 		 port_id, UINT16);
14281 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
14282 	TOKEN_STRING_INITIALIZER
14283 		(struct cmd_macsec_offload_off_result,
14284 		 off, "off");
14285 
14286 static void
14287 cmd_set_macsec_offload_off_parsed(
14288 	void *parsed_result,
14289 	__attribute__((unused)) struct cmdline *cl,
14290 	__attribute__((unused)) void *data)
14291 {
14292 	struct cmd_macsec_offload_off_result *res = parsed_result;
14293 	int ret = -ENOTSUP;
14294 	struct rte_eth_dev_info dev_info;
14295 	portid_t port_id = res->port_id;
14296 
14297 	if (port_id_is_invalid(port_id, ENABLED_WARN))
14298 		return;
14299 	if (!port_is_stopped(port_id)) {
14300 		printf("Please stop port %d first\n", port_id);
14301 		return;
14302 	}
14303 
14304 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
14305 	if (ret != 0)
14306 		return;
14307 
14308 	if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
14309 #ifdef RTE_LIBRTE_IXGBE_PMD
14310 		ret = rte_pmd_ixgbe_macsec_disable(port_id);
14311 #endif
14312 	}
14313 	switch (ret) {
14314 	case 0:
14315 		ports[port_id].dev_conf.txmode.offloads &=
14316 						~DEV_TX_OFFLOAD_MACSEC_INSERT;
14317 		cmd_reconfig_device_queue(port_id, 1, 1);
14318 		break;
14319 	case -ENODEV:
14320 		printf("invalid port_id %d\n", port_id);
14321 		break;
14322 	case -ENOTSUP:
14323 		printf("not supported on port %d\n", port_id);
14324 		break;
14325 	default:
14326 		printf("programming error: (%s)\n", strerror(-ret));
14327 	}
14328 }
14329 
14330 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
14331 	.f = cmd_set_macsec_offload_off_parsed,
14332 	.data = NULL,
14333 	.help_str = "set macsec offload <port_id> off",
14334 	.tokens = {
14335 		(void *)&cmd_macsec_offload_off_set,
14336 		(void *)&cmd_macsec_offload_off_macsec,
14337 		(void *)&cmd_macsec_offload_off_offload,
14338 		(void *)&cmd_macsec_offload_off_port_id,
14339 		(void *)&cmd_macsec_offload_off_off,
14340 		NULL,
14341 	},
14342 };
14343 
14344 /* Common result structure for MACsec secure connection configure */
14345 struct cmd_macsec_sc_result {
14346 	cmdline_fixed_string_t set;
14347 	cmdline_fixed_string_t macsec;
14348 	cmdline_fixed_string_t sc;
14349 	cmdline_fixed_string_t tx_rx;
14350 	portid_t port_id;
14351 	struct rte_ether_addr mac;
14352 	uint16_t pi;
14353 };
14354 
14355 /* Common CLI fields for MACsec secure connection configure */
14356 cmdline_parse_token_string_t cmd_macsec_sc_set =
14357 	TOKEN_STRING_INITIALIZER
14358 		(struct cmd_macsec_sc_result,
14359 		 set, "set");
14360 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
14361 	TOKEN_STRING_INITIALIZER
14362 		(struct cmd_macsec_sc_result,
14363 		 macsec, "macsec");
14364 cmdline_parse_token_string_t cmd_macsec_sc_sc =
14365 	TOKEN_STRING_INITIALIZER
14366 		(struct cmd_macsec_sc_result,
14367 		 sc, "sc");
14368 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
14369 	TOKEN_STRING_INITIALIZER
14370 		(struct cmd_macsec_sc_result,
14371 		 tx_rx, "tx#rx");
14372 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
14373 	TOKEN_NUM_INITIALIZER
14374 		(struct cmd_macsec_sc_result,
14375 		 port_id, UINT16);
14376 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
14377 	TOKEN_ETHERADDR_INITIALIZER
14378 		(struct cmd_macsec_sc_result,
14379 		 mac);
14380 cmdline_parse_token_num_t cmd_macsec_sc_pi =
14381 	TOKEN_NUM_INITIALIZER
14382 		(struct cmd_macsec_sc_result,
14383 		 pi, UINT16);
14384 
14385 static void
14386 cmd_set_macsec_sc_parsed(
14387 	void *parsed_result,
14388 	__attribute__((unused)) struct cmdline *cl,
14389 	__attribute__((unused)) void *data)
14390 {
14391 	struct cmd_macsec_sc_result *res = parsed_result;
14392 	int ret = -ENOTSUP;
14393 	int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14394 
14395 #ifdef RTE_LIBRTE_IXGBE_PMD
14396 	ret = is_tx ?
14397 		rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
14398 				res->mac.addr_bytes) :
14399 		rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
14400 				res->mac.addr_bytes, res->pi);
14401 #endif
14402 	RTE_SET_USED(is_tx);
14403 
14404 	switch (ret) {
14405 	case 0:
14406 		break;
14407 	case -ENODEV:
14408 		printf("invalid port_id %d\n", res->port_id);
14409 		break;
14410 	case -ENOTSUP:
14411 		printf("not supported on port %d\n", res->port_id);
14412 		break;
14413 	default:
14414 		printf("programming error: (%s)\n", strerror(-ret));
14415 	}
14416 }
14417 
14418 cmdline_parse_inst_t cmd_set_macsec_sc = {
14419 	.f = cmd_set_macsec_sc_parsed,
14420 	.data = NULL,
14421 	.help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
14422 	.tokens = {
14423 		(void *)&cmd_macsec_sc_set,
14424 		(void *)&cmd_macsec_sc_macsec,
14425 		(void *)&cmd_macsec_sc_sc,
14426 		(void *)&cmd_macsec_sc_tx_rx,
14427 		(void *)&cmd_macsec_sc_port_id,
14428 		(void *)&cmd_macsec_sc_mac,
14429 		(void *)&cmd_macsec_sc_pi,
14430 		NULL,
14431 	},
14432 };
14433 
14434 /* Common result structure for MACsec secure connection configure */
14435 struct cmd_macsec_sa_result {
14436 	cmdline_fixed_string_t set;
14437 	cmdline_fixed_string_t macsec;
14438 	cmdline_fixed_string_t sa;
14439 	cmdline_fixed_string_t tx_rx;
14440 	portid_t port_id;
14441 	uint8_t idx;
14442 	uint8_t an;
14443 	uint32_t pn;
14444 	cmdline_fixed_string_t key;
14445 };
14446 
14447 /* Common CLI fields for MACsec secure connection configure */
14448 cmdline_parse_token_string_t cmd_macsec_sa_set =
14449 	TOKEN_STRING_INITIALIZER
14450 		(struct cmd_macsec_sa_result,
14451 		 set, "set");
14452 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
14453 	TOKEN_STRING_INITIALIZER
14454 		(struct cmd_macsec_sa_result,
14455 		 macsec, "macsec");
14456 cmdline_parse_token_string_t cmd_macsec_sa_sa =
14457 	TOKEN_STRING_INITIALIZER
14458 		(struct cmd_macsec_sa_result,
14459 		 sa, "sa");
14460 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
14461 	TOKEN_STRING_INITIALIZER
14462 		(struct cmd_macsec_sa_result,
14463 		 tx_rx, "tx#rx");
14464 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
14465 	TOKEN_NUM_INITIALIZER
14466 		(struct cmd_macsec_sa_result,
14467 		 port_id, UINT16);
14468 cmdline_parse_token_num_t cmd_macsec_sa_idx =
14469 	TOKEN_NUM_INITIALIZER
14470 		(struct cmd_macsec_sa_result,
14471 		 idx, UINT8);
14472 cmdline_parse_token_num_t cmd_macsec_sa_an =
14473 	TOKEN_NUM_INITIALIZER
14474 		(struct cmd_macsec_sa_result,
14475 		 an, UINT8);
14476 cmdline_parse_token_num_t cmd_macsec_sa_pn =
14477 	TOKEN_NUM_INITIALIZER
14478 		(struct cmd_macsec_sa_result,
14479 		 pn, UINT32);
14480 cmdline_parse_token_string_t cmd_macsec_sa_key =
14481 	TOKEN_STRING_INITIALIZER
14482 		(struct cmd_macsec_sa_result,
14483 		 key, NULL);
14484 
14485 static void
14486 cmd_set_macsec_sa_parsed(
14487 	void *parsed_result,
14488 	__attribute__((unused)) struct cmdline *cl,
14489 	__attribute__((unused)) void *data)
14490 {
14491 	struct cmd_macsec_sa_result *res = parsed_result;
14492 	int ret = -ENOTSUP;
14493 	int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14494 	uint8_t key[16] = { 0 };
14495 	uint8_t xdgt0;
14496 	uint8_t xdgt1;
14497 	int key_len;
14498 	int i;
14499 
14500 	key_len = strlen(res->key) / 2;
14501 	if (key_len > 16)
14502 		key_len = 16;
14503 
14504 	for (i = 0; i < key_len; i++) {
14505 		xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
14506 		if (xdgt0 == 0xFF)
14507 			return;
14508 		xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
14509 		if (xdgt1 == 0xFF)
14510 			return;
14511 		key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
14512 	}
14513 
14514 #ifdef RTE_LIBRTE_IXGBE_PMD
14515 	ret = is_tx ?
14516 		rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
14517 			res->idx, res->an, res->pn, key) :
14518 		rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
14519 			res->idx, res->an, res->pn, key);
14520 #endif
14521 	RTE_SET_USED(is_tx);
14522 	RTE_SET_USED(key);
14523 
14524 	switch (ret) {
14525 	case 0:
14526 		break;
14527 	case -EINVAL:
14528 		printf("invalid idx %d or an %d\n", res->idx, res->an);
14529 		break;
14530 	case -ENODEV:
14531 		printf("invalid port_id %d\n", res->port_id);
14532 		break;
14533 	case -ENOTSUP:
14534 		printf("not supported on port %d\n", res->port_id);
14535 		break;
14536 	default:
14537 		printf("programming error: (%s)\n", strerror(-ret));
14538 	}
14539 }
14540 
14541 cmdline_parse_inst_t cmd_set_macsec_sa = {
14542 	.f = cmd_set_macsec_sa_parsed,
14543 	.data = NULL,
14544 	.help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
14545 	.tokens = {
14546 		(void *)&cmd_macsec_sa_set,
14547 		(void *)&cmd_macsec_sa_macsec,
14548 		(void *)&cmd_macsec_sa_sa,
14549 		(void *)&cmd_macsec_sa_tx_rx,
14550 		(void *)&cmd_macsec_sa_port_id,
14551 		(void *)&cmd_macsec_sa_idx,
14552 		(void *)&cmd_macsec_sa_an,
14553 		(void *)&cmd_macsec_sa_pn,
14554 		(void *)&cmd_macsec_sa_key,
14555 		NULL,
14556 	},
14557 };
14558 
14559 /* VF unicast promiscuous mode configuration */
14560 
14561 /* Common result structure for VF unicast promiscuous mode */
14562 struct cmd_vf_promisc_result {
14563 	cmdline_fixed_string_t set;
14564 	cmdline_fixed_string_t vf;
14565 	cmdline_fixed_string_t promisc;
14566 	portid_t port_id;
14567 	uint32_t vf_id;
14568 	cmdline_fixed_string_t on_off;
14569 };
14570 
14571 /* Common CLI fields for VF unicast promiscuous mode enable disable */
14572 cmdline_parse_token_string_t cmd_vf_promisc_set =
14573 	TOKEN_STRING_INITIALIZER
14574 		(struct cmd_vf_promisc_result,
14575 		 set, "set");
14576 cmdline_parse_token_string_t cmd_vf_promisc_vf =
14577 	TOKEN_STRING_INITIALIZER
14578 		(struct cmd_vf_promisc_result,
14579 		 vf, "vf");
14580 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
14581 	TOKEN_STRING_INITIALIZER
14582 		(struct cmd_vf_promisc_result,
14583 		 promisc, "promisc");
14584 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
14585 	TOKEN_NUM_INITIALIZER
14586 		(struct cmd_vf_promisc_result,
14587 		 port_id, UINT16);
14588 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
14589 	TOKEN_NUM_INITIALIZER
14590 		(struct cmd_vf_promisc_result,
14591 		 vf_id, UINT32);
14592 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
14593 	TOKEN_STRING_INITIALIZER
14594 		(struct cmd_vf_promisc_result,
14595 		 on_off, "on#off");
14596 
14597 static void
14598 cmd_set_vf_promisc_parsed(
14599 	void *parsed_result,
14600 	__attribute__((unused)) struct cmdline *cl,
14601 	__attribute__((unused)) void *data)
14602 {
14603 	struct cmd_vf_promisc_result *res = parsed_result;
14604 	int ret = -ENOTSUP;
14605 
14606 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14607 
14608 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14609 		return;
14610 
14611 #ifdef RTE_LIBRTE_I40E_PMD
14612 	ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
14613 						  res->vf_id, is_on);
14614 #endif
14615 
14616 	switch (ret) {
14617 	case 0:
14618 		break;
14619 	case -EINVAL:
14620 		printf("invalid vf_id %d\n", res->vf_id);
14621 		break;
14622 	case -ENODEV:
14623 		printf("invalid port_id %d\n", res->port_id);
14624 		break;
14625 	case -ENOTSUP:
14626 		printf("function not implemented\n");
14627 		break;
14628 	default:
14629 		printf("programming error: (%s)\n", strerror(-ret));
14630 	}
14631 }
14632 
14633 cmdline_parse_inst_t cmd_set_vf_promisc = {
14634 	.f = cmd_set_vf_promisc_parsed,
14635 	.data = NULL,
14636 	.help_str = "set vf promisc <port_id> <vf_id> on|off: "
14637 		"Set unicast promiscuous mode for a VF from the PF",
14638 	.tokens = {
14639 		(void *)&cmd_vf_promisc_set,
14640 		(void *)&cmd_vf_promisc_vf,
14641 		(void *)&cmd_vf_promisc_promisc,
14642 		(void *)&cmd_vf_promisc_port_id,
14643 		(void *)&cmd_vf_promisc_vf_id,
14644 		(void *)&cmd_vf_promisc_on_off,
14645 		NULL,
14646 	},
14647 };
14648 
14649 /* VF multicast promiscuous mode configuration */
14650 
14651 /* Common result structure for VF multicast promiscuous mode */
14652 struct cmd_vf_allmulti_result {
14653 	cmdline_fixed_string_t set;
14654 	cmdline_fixed_string_t vf;
14655 	cmdline_fixed_string_t allmulti;
14656 	portid_t port_id;
14657 	uint32_t vf_id;
14658 	cmdline_fixed_string_t on_off;
14659 };
14660 
14661 /* Common CLI fields for VF multicast promiscuous mode enable disable */
14662 cmdline_parse_token_string_t cmd_vf_allmulti_set =
14663 	TOKEN_STRING_INITIALIZER
14664 		(struct cmd_vf_allmulti_result,
14665 		 set, "set");
14666 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
14667 	TOKEN_STRING_INITIALIZER
14668 		(struct cmd_vf_allmulti_result,
14669 		 vf, "vf");
14670 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
14671 	TOKEN_STRING_INITIALIZER
14672 		(struct cmd_vf_allmulti_result,
14673 		 allmulti, "allmulti");
14674 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
14675 	TOKEN_NUM_INITIALIZER
14676 		(struct cmd_vf_allmulti_result,
14677 		 port_id, UINT16);
14678 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
14679 	TOKEN_NUM_INITIALIZER
14680 		(struct cmd_vf_allmulti_result,
14681 		 vf_id, UINT32);
14682 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
14683 	TOKEN_STRING_INITIALIZER
14684 		(struct cmd_vf_allmulti_result,
14685 		 on_off, "on#off");
14686 
14687 static void
14688 cmd_set_vf_allmulti_parsed(
14689 	void *parsed_result,
14690 	__attribute__((unused)) struct cmdline *cl,
14691 	__attribute__((unused)) void *data)
14692 {
14693 	struct cmd_vf_allmulti_result *res = parsed_result;
14694 	int ret = -ENOTSUP;
14695 
14696 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14697 
14698 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14699 		return;
14700 
14701 #ifdef RTE_LIBRTE_I40E_PMD
14702 	ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
14703 						    res->vf_id, is_on);
14704 #endif
14705 
14706 	switch (ret) {
14707 	case 0:
14708 		break;
14709 	case -EINVAL:
14710 		printf("invalid vf_id %d\n", res->vf_id);
14711 		break;
14712 	case -ENODEV:
14713 		printf("invalid port_id %d\n", res->port_id);
14714 		break;
14715 	case -ENOTSUP:
14716 		printf("function not implemented\n");
14717 		break;
14718 	default:
14719 		printf("programming error: (%s)\n", strerror(-ret));
14720 	}
14721 }
14722 
14723 cmdline_parse_inst_t cmd_set_vf_allmulti = {
14724 	.f = cmd_set_vf_allmulti_parsed,
14725 	.data = NULL,
14726 	.help_str = "set vf allmulti <port_id> <vf_id> on|off: "
14727 		"Set multicast promiscuous mode for a VF from the PF",
14728 	.tokens = {
14729 		(void *)&cmd_vf_allmulti_set,
14730 		(void *)&cmd_vf_allmulti_vf,
14731 		(void *)&cmd_vf_allmulti_allmulti,
14732 		(void *)&cmd_vf_allmulti_port_id,
14733 		(void *)&cmd_vf_allmulti_vf_id,
14734 		(void *)&cmd_vf_allmulti_on_off,
14735 		NULL,
14736 	},
14737 };
14738 
14739 /* vf broadcast mode configuration */
14740 
14741 /* Common result structure for vf broadcast */
14742 struct cmd_set_vf_broadcast_result {
14743 	cmdline_fixed_string_t set;
14744 	cmdline_fixed_string_t vf;
14745 	cmdline_fixed_string_t broadcast;
14746 	portid_t port_id;
14747 	uint16_t vf_id;
14748 	cmdline_fixed_string_t on_off;
14749 };
14750 
14751 /* Common CLI fields for vf broadcast enable disable */
14752 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
14753 	TOKEN_STRING_INITIALIZER
14754 		(struct cmd_set_vf_broadcast_result,
14755 		 set, "set");
14756 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
14757 	TOKEN_STRING_INITIALIZER
14758 		(struct cmd_set_vf_broadcast_result,
14759 		 vf, "vf");
14760 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
14761 	TOKEN_STRING_INITIALIZER
14762 		(struct cmd_set_vf_broadcast_result,
14763 		 broadcast, "broadcast");
14764 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
14765 	TOKEN_NUM_INITIALIZER
14766 		(struct cmd_set_vf_broadcast_result,
14767 		 port_id, UINT16);
14768 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
14769 	TOKEN_NUM_INITIALIZER
14770 		(struct cmd_set_vf_broadcast_result,
14771 		 vf_id, UINT16);
14772 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
14773 	TOKEN_STRING_INITIALIZER
14774 		(struct cmd_set_vf_broadcast_result,
14775 		 on_off, "on#off");
14776 
14777 static void
14778 cmd_set_vf_broadcast_parsed(
14779 	void *parsed_result,
14780 	__attribute__((unused)) struct cmdline *cl,
14781 	__attribute__((unused)) void *data)
14782 {
14783 	struct cmd_set_vf_broadcast_result *res = parsed_result;
14784 	int ret = -ENOTSUP;
14785 
14786 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14787 
14788 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14789 		return;
14790 
14791 #ifdef RTE_LIBRTE_I40E_PMD
14792 	ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
14793 					    res->vf_id, is_on);
14794 #endif
14795 
14796 	switch (ret) {
14797 	case 0:
14798 		break;
14799 	case -EINVAL:
14800 		printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14801 		break;
14802 	case -ENODEV:
14803 		printf("invalid port_id %d\n", res->port_id);
14804 		break;
14805 	case -ENOTSUP:
14806 		printf("function not implemented\n");
14807 		break;
14808 	default:
14809 		printf("programming error: (%s)\n", strerror(-ret));
14810 	}
14811 }
14812 
14813 cmdline_parse_inst_t cmd_set_vf_broadcast = {
14814 	.f = cmd_set_vf_broadcast_parsed,
14815 	.data = NULL,
14816 	.help_str = "set vf broadcast <port_id> <vf_id> on|off",
14817 	.tokens = {
14818 		(void *)&cmd_set_vf_broadcast_set,
14819 		(void *)&cmd_set_vf_broadcast_vf,
14820 		(void *)&cmd_set_vf_broadcast_broadcast,
14821 		(void *)&cmd_set_vf_broadcast_port_id,
14822 		(void *)&cmd_set_vf_broadcast_vf_id,
14823 		(void *)&cmd_set_vf_broadcast_on_off,
14824 		NULL,
14825 	},
14826 };
14827 
14828 /* vf vlan tag configuration */
14829 
14830 /* Common result structure for vf vlan tag */
14831 struct cmd_set_vf_vlan_tag_result {
14832 	cmdline_fixed_string_t set;
14833 	cmdline_fixed_string_t vf;
14834 	cmdline_fixed_string_t vlan;
14835 	cmdline_fixed_string_t tag;
14836 	portid_t port_id;
14837 	uint16_t vf_id;
14838 	cmdline_fixed_string_t on_off;
14839 };
14840 
14841 /* Common CLI fields for vf vlan tag enable disable */
14842 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
14843 	TOKEN_STRING_INITIALIZER
14844 		(struct cmd_set_vf_vlan_tag_result,
14845 		 set, "set");
14846 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
14847 	TOKEN_STRING_INITIALIZER
14848 		(struct cmd_set_vf_vlan_tag_result,
14849 		 vf, "vf");
14850 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
14851 	TOKEN_STRING_INITIALIZER
14852 		(struct cmd_set_vf_vlan_tag_result,
14853 		 vlan, "vlan");
14854 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
14855 	TOKEN_STRING_INITIALIZER
14856 		(struct cmd_set_vf_vlan_tag_result,
14857 		 tag, "tag");
14858 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
14859 	TOKEN_NUM_INITIALIZER
14860 		(struct cmd_set_vf_vlan_tag_result,
14861 		 port_id, UINT16);
14862 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
14863 	TOKEN_NUM_INITIALIZER
14864 		(struct cmd_set_vf_vlan_tag_result,
14865 		 vf_id, UINT16);
14866 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
14867 	TOKEN_STRING_INITIALIZER
14868 		(struct cmd_set_vf_vlan_tag_result,
14869 		 on_off, "on#off");
14870 
14871 static void
14872 cmd_set_vf_vlan_tag_parsed(
14873 	void *parsed_result,
14874 	__attribute__((unused)) struct cmdline *cl,
14875 	__attribute__((unused)) void *data)
14876 {
14877 	struct cmd_set_vf_vlan_tag_result *res = parsed_result;
14878 	int ret = -ENOTSUP;
14879 
14880 	__rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14881 
14882 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14883 		return;
14884 
14885 #ifdef RTE_LIBRTE_I40E_PMD
14886 	ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
14887 					   res->vf_id, is_on);
14888 #endif
14889 
14890 	switch (ret) {
14891 	case 0:
14892 		break;
14893 	case -EINVAL:
14894 		printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14895 		break;
14896 	case -ENODEV:
14897 		printf("invalid port_id %d\n", res->port_id);
14898 		break;
14899 	case -ENOTSUP:
14900 		printf("function not implemented\n");
14901 		break;
14902 	default:
14903 		printf("programming error: (%s)\n", strerror(-ret));
14904 	}
14905 }
14906 
14907 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
14908 	.f = cmd_set_vf_vlan_tag_parsed,
14909 	.data = NULL,
14910 	.help_str = "set vf vlan tag <port_id> <vf_id> on|off",
14911 	.tokens = {
14912 		(void *)&cmd_set_vf_vlan_tag_set,
14913 		(void *)&cmd_set_vf_vlan_tag_vf,
14914 		(void *)&cmd_set_vf_vlan_tag_vlan,
14915 		(void *)&cmd_set_vf_vlan_tag_tag,
14916 		(void *)&cmd_set_vf_vlan_tag_port_id,
14917 		(void *)&cmd_set_vf_vlan_tag_vf_id,
14918 		(void *)&cmd_set_vf_vlan_tag_on_off,
14919 		NULL,
14920 	},
14921 };
14922 
14923 /* Common definition of VF and TC TX bandwidth configuration */
14924 struct cmd_vf_tc_bw_result {
14925 	cmdline_fixed_string_t set;
14926 	cmdline_fixed_string_t vf;
14927 	cmdline_fixed_string_t tc;
14928 	cmdline_fixed_string_t tx;
14929 	cmdline_fixed_string_t min_bw;
14930 	cmdline_fixed_string_t max_bw;
14931 	cmdline_fixed_string_t strict_link_prio;
14932 	portid_t port_id;
14933 	uint16_t vf_id;
14934 	uint8_t tc_no;
14935 	uint32_t bw;
14936 	cmdline_fixed_string_t bw_list;
14937 	uint8_t tc_map;
14938 };
14939 
14940 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
14941 	TOKEN_STRING_INITIALIZER
14942 		(struct cmd_vf_tc_bw_result,
14943 		 set, "set");
14944 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
14945 	TOKEN_STRING_INITIALIZER
14946 		(struct cmd_vf_tc_bw_result,
14947 		 vf, "vf");
14948 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
14949 	TOKEN_STRING_INITIALIZER
14950 		(struct cmd_vf_tc_bw_result,
14951 		 tc, "tc");
14952 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
14953 	TOKEN_STRING_INITIALIZER
14954 		(struct cmd_vf_tc_bw_result,
14955 		 tx, "tx");
14956 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
14957 	TOKEN_STRING_INITIALIZER
14958 		(struct cmd_vf_tc_bw_result,
14959 		 strict_link_prio, "strict-link-priority");
14960 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
14961 	TOKEN_STRING_INITIALIZER
14962 		(struct cmd_vf_tc_bw_result,
14963 		 min_bw, "min-bandwidth");
14964 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
14965 	TOKEN_STRING_INITIALIZER
14966 		(struct cmd_vf_tc_bw_result,
14967 		 max_bw, "max-bandwidth");
14968 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
14969 	TOKEN_NUM_INITIALIZER
14970 		(struct cmd_vf_tc_bw_result,
14971 		 port_id, UINT16);
14972 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
14973 	TOKEN_NUM_INITIALIZER
14974 		(struct cmd_vf_tc_bw_result,
14975 		 vf_id, UINT16);
14976 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
14977 	TOKEN_NUM_INITIALIZER
14978 		(struct cmd_vf_tc_bw_result,
14979 		 tc_no, UINT8);
14980 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
14981 	TOKEN_NUM_INITIALIZER
14982 		(struct cmd_vf_tc_bw_result,
14983 		 bw, UINT32);
14984 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
14985 	TOKEN_STRING_INITIALIZER
14986 		(struct cmd_vf_tc_bw_result,
14987 		 bw_list, NULL);
14988 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
14989 	TOKEN_NUM_INITIALIZER
14990 		(struct cmd_vf_tc_bw_result,
14991 		 tc_map, UINT8);
14992 
14993 /* VF max bandwidth setting */
14994 static void
14995 cmd_vf_max_bw_parsed(
14996 	void *parsed_result,
14997 	__attribute__((unused)) struct cmdline *cl,
14998 	__attribute__((unused)) void *data)
14999 {
15000 	struct cmd_vf_tc_bw_result *res = parsed_result;
15001 	int ret = -ENOTSUP;
15002 
15003 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15004 		return;
15005 
15006 #ifdef RTE_LIBRTE_I40E_PMD
15007 	ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
15008 					 res->vf_id, res->bw);
15009 #endif
15010 
15011 	switch (ret) {
15012 	case 0:
15013 		break;
15014 	case -EINVAL:
15015 		printf("invalid vf_id %d or bandwidth %d\n",
15016 		       res->vf_id, res->bw);
15017 		break;
15018 	case -ENODEV:
15019 		printf("invalid port_id %d\n", res->port_id);
15020 		break;
15021 	case -ENOTSUP:
15022 		printf("function not implemented\n");
15023 		break;
15024 	default:
15025 		printf("programming error: (%s)\n", strerror(-ret));
15026 	}
15027 }
15028 
15029 cmdline_parse_inst_t cmd_vf_max_bw = {
15030 	.f = cmd_vf_max_bw_parsed,
15031 	.data = NULL,
15032 	.help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
15033 	.tokens = {
15034 		(void *)&cmd_vf_tc_bw_set,
15035 		(void *)&cmd_vf_tc_bw_vf,
15036 		(void *)&cmd_vf_tc_bw_tx,
15037 		(void *)&cmd_vf_tc_bw_max_bw,
15038 		(void *)&cmd_vf_tc_bw_port_id,
15039 		(void *)&cmd_vf_tc_bw_vf_id,
15040 		(void *)&cmd_vf_tc_bw_bw,
15041 		NULL,
15042 	},
15043 };
15044 
15045 static int
15046 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
15047 			   uint8_t *tc_num,
15048 			   char *str)
15049 {
15050 	uint32_t size;
15051 	const char *p, *p0 = str;
15052 	char s[256];
15053 	char *end;
15054 	char *str_fld[16];
15055 	uint16_t i;
15056 	int ret;
15057 
15058 	p = strchr(p0, '(');
15059 	if (p == NULL) {
15060 		printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
15061 		return -1;
15062 	}
15063 	p++;
15064 	p0 = strchr(p, ')');
15065 	if (p0 == NULL) {
15066 		printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
15067 		return -1;
15068 	}
15069 	size = p0 - p;
15070 	if (size >= sizeof(s)) {
15071 		printf("The string size exceeds the internal buffer size\n");
15072 		return -1;
15073 	}
15074 	snprintf(s, sizeof(s), "%.*s", size, p);
15075 	ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
15076 	if (ret <= 0) {
15077 		printf("Failed to get the bandwidth list. ");
15078 		return -1;
15079 	}
15080 	*tc_num = ret;
15081 	for (i = 0; i < ret; i++)
15082 		bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
15083 
15084 	return 0;
15085 }
15086 
15087 /* TC min bandwidth setting */
15088 static void
15089 cmd_vf_tc_min_bw_parsed(
15090 	void *parsed_result,
15091 	__attribute__((unused)) struct cmdline *cl,
15092 	__attribute__((unused)) void *data)
15093 {
15094 	struct cmd_vf_tc_bw_result *res = parsed_result;
15095 	uint8_t tc_num;
15096 	uint8_t bw[16];
15097 	int ret = -ENOTSUP;
15098 
15099 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15100 		return;
15101 
15102 	ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
15103 	if (ret)
15104 		return;
15105 
15106 #ifdef RTE_LIBRTE_I40E_PMD
15107 	ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
15108 					      tc_num, bw);
15109 #endif
15110 
15111 	switch (ret) {
15112 	case 0:
15113 		break;
15114 	case -EINVAL:
15115 		printf("invalid vf_id %d or bandwidth\n", res->vf_id);
15116 		break;
15117 	case -ENODEV:
15118 		printf("invalid port_id %d\n", res->port_id);
15119 		break;
15120 	case -ENOTSUP:
15121 		printf("function not implemented\n");
15122 		break;
15123 	default:
15124 		printf("programming error: (%s)\n", strerror(-ret));
15125 	}
15126 }
15127 
15128 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
15129 	.f = cmd_vf_tc_min_bw_parsed,
15130 	.data = NULL,
15131 	.help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
15132 		    " <bw1, bw2, ...>",
15133 	.tokens = {
15134 		(void *)&cmd_vf_tc_bw_set,
15135 		(void *)&cmd_vf_tc_bw_vf,
15136 		(void *)&cmd_vf_tc_bw_tc,
15137 		(void *)&cmd_vf_tc_bw_tx,
15138 		(void *)&cmd_vf_tc_bw_min_bw,
15139 		(void *)&cmd_vf_tc_bw_port_id,
15140 		(void *)&cmd_vf_tc_bw_vf_id,
15141 		(void *)&cmd_vf_tc_bw_bw_list,
15142 		NULL,
15143 	},
15144 };
15145 
15146 static void
15147 cmd_tc_min_bw_parsed(
15148 	void *parsed_result,
15149 	__attribute__((unused)) struct cmdline *cl,
15150 	__attribute__((unused)) void *data)
15151 {
15152 	struct cmd_vf_tc_bw_result *res = parsed_result;
15153 	struct rte_port *port;
15154 	uint8_t tc_num;
15155 	uint8_t bw[16];
15156 	int ret = -ENOTSUP;
15157 
15158 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15159 		return;
15160 
15161 	port = &ports[res->port_id];
15162 	/** Check if the port is not started **/
15163 	if (port->port_status != RTE_PORT_STOPPED) {
15164 		printf("Please stop port %d first\n", res->port_id);
15165 		return;
15166 	}
15167 
15168 	ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
15169 	if (ret)
15170 		return;
15171 
15172 #ifdef RTE_LIBRTE_IXGBE_PMD
15173 	ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
15174 #endif
15175 
15176 	switch (ret) {
15177 	case 0:
15178 		break;
15179 	case -EINVAL:
15180 		printf("invalid bandwidth\n");
15181 		break;
15182 	case -ENODEV:
15183 		printf("invalid port_id %d\n", res->port_id);
15184 		break;
15185 	case -ENOTSUP:
15186 		printf("function not implemented\n");
15187 		break;
15188 	default:
15189 		printf("programming error: (%s)\n", strerror(-ret));
15190 	}
15191 }
15192 
15193 cmdline_parse_inst_t cmd_tc_min_bw = {
15194 	.f = cmd_tc_min_bw_parsed,
15195 	.data = NULL,
15196 	.help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
15197 	.tokens = {
15198 		(void *)&cmd_vf_tc_bw_set,
15199 		(void *)&cmd_vf_tc_bw_tc,
15200 		(void *)&cmd_vf_tc_bw_tx,
15201 		(void *)&cmd_vf_tc_bw_min_bw,
15202 		(void *)&cmd_vf_tc_bw_port_id,
15203 		(void *)&cmd_vf_tc_bw_bw_list,
15204 		NULL,
15205 	},
15206 };
15207 
15208 /* TC max bandwidth setting */
15209 static void
15210 cmd_vf_tc_max_bw_parsed(
15211 	void *parsed_result,
15212 	__attribute__((unused)) struct cmdline *cl,
15213 	__attribute__((unused)) void *data)
15214 {
15215 	struct cmd_vf_tc_bw_result *res = parsed_result;
15216 	int ret = -ENOTSUP;
15217 
15218 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15219 		return;
15220 
15221 #ifdef RTE_LIBRTE_I40E_PMD
15222 	ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
15223 					    res->tc_no, res->bw);
15224 #endif
15225 
15226 	switch (ret) {
15227 	case 0:
15228 		break;
15229 	case -EINVAL:
15230 		printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
15231 		       res->vf_id, res->tc_no, res->bw);
15232 		break;
15233 	case -ENODEV:
15234 		printf("invalid port_id %d\n", res->port_id);
15235 		break;
15236 	case -ENOTSUP:
15237 		printf("function not implemented\n");
15238 		break;
15239 	default:
15240 		printf("programming error: (%s)\n", strerror(-ret));
15241 	}
15242 }
15243 
15244 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
15245 	.f = cmd_vf_tc_max_bw_parsed,
15246 	.data = NULL,
15247 	.help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
15248 		    " <bandwidth>",
15249 	.tokens = {
15250 		(void *)&cmd_vf_tc_bw_set,
15251 		(void *)&cmd_vf_tc_bw_vf,
15252 		(void *)&cmd_vf_tc_bw_tc,
15253 		(void *)&cmd_vf_tc_bw_tx,
15254 		(void *)&cmd_vf_tc_bw_max_bw,
15255 		(void *)&cmd_vf_tc_bw_port_id,
15256 		(void *)&cmd_vf_tc_bw_vf_id,
15257 		(void *)&cmd_vf_tc_bw_tc_no,
15258 		(void *)&cmd_vf_tc_bw_bw,
15259 		NULL,
15260 	},
15261 };
15262 
15263 
15264 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
15265 
15266 /* *** Set Port default Traffic Management Hierarchy *** */
15267 struct cmd_set_port_tm_hierarchy_default_result {
15268 	cmdline_fixed_string_t set;
15269 	cmdline_fixed_string_t port;
15270 	cmdline_fixed_string_t tm;
15271 	cmdline_fixed_string_t hierarchy;
15272 	cmdline_fixed_string_t def;
15273 	portid_t port_id;
15274 };
15275 
15276 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_set =
15277 	TOKEN_STRING_INITIALIZER(
15278 		struct cmd_set_port_tm_hierarchy_default_result, set, "set");
15279 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_port =
15280 	TOKEN_STRING_INITIALIZER(
15281 		struct cmd_set_port_tm_hierarchy_default_result, port, "port");
15282 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_tm =
15283 	TOKEN_STRING_INITIALIZER(
15284 		struct cmd_set_port_tm_hierarchy_default_result, tm, "tm");
15285 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_hierarchy =
15286 	TOKEN_STRING_INITIALIZER(
15287 		struct cmd_set_port_tm_hierarchy_default_result,
15288 			hierarchy, "hierarchy");
15289 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_default =
15290 	TOKEN_STRING_INITIALIZER(
15291 		struct cmd_set_port_tm_hierarchy_default_result,
15292 			def, "default");
15293 cmdline_parse_token_num_t cmd_set_port_tm_hierarchy_default_port_id =
15294 	TOKEN_NUM_INITIALIZER(
15295 		struct cmd_set_port_tm_hierarchy_default_result,
15296 			port_id, UINT16);
15297 
15298 static void cmd_set_port_tm_hierarchy_default_parsed(void *parsed_result,
15299 	__attribute__((unused)) struct cmdline *cl,
15300 	__attribute__((unused)) void *data)
15301 {
15302 	struct cmd_set_port_tm_hierarchy_default_result *res = parsed_result;
15303 	struct rte_port *p;
15304 	portid_t port_id = res->port_id;
15305 
15306 	if (port_id_is_invalid(port_id, ENABLED_WARN))
15307 		return;
15308 
15309 	p = &ports[port_id];
15310 
15311 	/* Forward mode: tm */
15312 	if (strcmp(cur_fwd_config.fwd_eng->fwd_mode_name, "softnic")) {
15313 		printf("  softnicfwd mode not enabled(error)\n");
15314 		return;
15315 	}
15316 
15317 	/* Set the default tm hierarchy */
15318 	p->softport.default_tm_hierarchy_enable = 1;
15319 }
15320 
15321 cmdline_parse_inst_t cmd_set_port_tm_hierarchy_default = {
15322 	.f = cmd_set_port_tm_hierarchy_default_parsed,
15323 	.data = NULL,
15324 	.help_str = "set port tm hierarchy default <port_id>",
15325 	.tokens = {
15326 		(void *)&cmd_set_port_tm_hierarchy_default_set,
15327 		(void *)&cmd_set_port_tm_hierarchy_default_port,
15328 		(void *)&cmd_set_port_tm_hierarchy_default_tm,
15329 		(void *)&cmd_set_port_tm_hierarchy_default_hierarchy,
15330 		(void *)&cmd_set_port_tm_hierarchy_default_default,
15331 		(void *)&cmd_set_port_tm_hierarchy_default_port_id,
15332 		NULL,
15333 	},
15334 };
15335 #endif
15336 
15337 /** Set VXLAN encapsulation details */
15338 struct cmd_set_vxlan_result {
15339 	cmdline_fixed_string_t set;
15340 	cmdline_fixed_string_t vxlan;
15341 	cmdline_fixed_string_t pos_token;
15342 	cmdline_fixed_string_t ip_version;
15343 	uint32_t vlan_present:1;
15344 	uint32_t vni;
15345 	uint16_t udp_src;
15346 	uint16_t udp_dst;
15347 	cmdline_ipaddr_t ip_src;
15348 	cmdline_ipaddr_t ip_dst;
15349 	uint16_t tci;
15350 	uint8_t tos;
15351 	uint8_t ttl;
15352 	struct rte_ether_addr eth_src;
15353 	struct rte_ether_addr eth_dst;
15354 };
15355 
15356 cmdline_parse_token_string_t cmd_set_vxlan_set =
15357 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
15358 cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
15359 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
15360 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
15361 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15362 				 "vxlan-tos-ttl");
15363 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
15364 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15365 				 "vxlan-with-vlan");
15366 cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
15367 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15368 				 "ip-version");
15369 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
15370 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
15371 				 "ipv4#ipv6");
15372 cmdline_parse_token_string_t cmd_set_vxlan_vni =
15373 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15374 				 "vni");
15375 cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
15376 	TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, UINT32);
15377 cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
15378 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15379 				 "udp-src");
15380 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
15381 	TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, UINT16);
15382 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
15383 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15384 				 "udp-dst");
15385 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
15386 	TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, UINT16);
15387 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
15388 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15389 				 "ip-tos");
15390 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
15391 	TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, UINT8);
15392 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
15393 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15394 				 "ip-ttl");
15395 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
15396 	TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, UINT8);
15397 cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
15398 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15399 				 "ip-src");
15400 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
15401 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
15402 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
15403 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15404 				 "ip-dst");
15405 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
15406 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
15407 cmdline_parse_token_string_t cmd_set_vxlan_vlan =
15408 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15409 				 "vlan-tci");
15410 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
15411 	TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, UINT16);
15412 cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
15413 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15414 				 "eth-src");
15415 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
15416 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
15417 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
15418 	TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15419 				 "eth-dst");
15420 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
15421 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
15422 
15423 static void cmd_set_vxlan_parsed(void *parsed_result,
15424 	__attribute__((unused)) struct cmdline *cl,
15425 	__attribute__((unused)) void *data)
15426 {
15427 	struct cmd_set_vxlan_result *res = parsed_result;
15428 	union {
15429 		uint32_t vxlan_id;
15430 		uint8_t vni[4];
15431 	} id = {
15432 		.vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
15433 	};
15434 
15435 	vxlan_encap_conf.select_tos_ttl = 0;
15436 	if (strcmp(res->vxlan, "vxlan") == 0)
15437 		vxlan_encap_conf.select_vlan = 0;
15438 	else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
15439 		vxlan_encap_conf.select_vlan = 1;
15440 	else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
15441 		vxlan_encap_conf.select_vlan = 0;
15442 		vxlan_encap_conf.select_tos_ttl = 1;
15443 	}
15444 	if (strcmp(res->ip_version, "ipv4") == 0)
15445 		vxlan_encap_conf.select_ipv4 = 1;
15446 	else if (strcmp(res->ip_version, "ipv6") == 0)
15447 		vxlan_encap_conf.select_ipv4 = 0;
15448 	else
15449 		return;
15450 	rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
15451 	vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
15452 	vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
15453 	vxlan_encap_conf.ip_tos = res->tos;
15454 	vxlan_encap_conf.ip_ttl = res->ttl;
15455 	if (vxlan_encap_conf.select_ipv4) {
15456 		IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
15457 		IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
15458 	} else {
15459 		IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
15460 		IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
15461 	}
15462 	if (vxlan_encap_conf.select_vlan)
15463 		vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15464 	rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
15465 		   RTE_ETHER_ADDR_LEN);
15466 	rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15467 		   RTE_ETHER_ADDR_LEN);
15468 }
15469 
15470 cmdline_parse_inst_t cmd_set_vxlan = {
15471 	.f = cmd_set_vxlan_parsed,
15472 	.data = NULL,
15473 	.help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
15474 		" <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
15475 		" eth-src <eth-src> eth-dst <eth-dst>",
15476 	.tokens = {
15477 		(void *)&cmd_set_vxlan_set,
15478 		(void *)&cmd_set_vxlan_vxlan,
15479 		(void *)&cmd_set_vxlan_ip_version,
15480 		(void *)&cmd_set_vxlan_ip_version_value,
15481 		(void *)&cmd_set_vxlan_vni,
15482 		(void *)&cmd_set_vxlan_vni_value,
15483 		(void *)&cmd_set_vxlan_udp_src,
15484 		(void *)&cmd_set_vxlan_udp_src_value,
15485 		(void *)&cmd_set_vxlan_udp_dst,
15486 		(void *)&cmd_set_vxlan_udp_dst_value,
15487 		(void *)&cmd_set_vxlan_ip_src,
15488 		(void *)&cmd_set_vxlan_ip_src_value,
15489 		(void *)&cmd_set_vxlan_ip_dst,
15490 		(void *)&cmd_set_vxlan_ip_dst_value,
15491 		(void *)&cmd_set_vxlan_eth_src,
15492 		(void *)&cmd_set_vxlan_eth_src_value,
15493 		(void *)&cmd_set_vxlan_eth_dst,
15494 		(void *)&cmd_set_vxlan_eth_dst_value,
15495 		NULL,
15496 	},
15497 };
15498 
15499 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
15500 	.f = cmd_set_vxlan_parsed,
15501 	.data = NULL,
15502 	.help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
15503 		" <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
15504 		" ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15505 		" eth-dst <eth-dst>",
15506 	.tokens = {
15507 		(void *)&cmd_set_vxlan_set,
15508 		(void *)&cmd_set_vxlan_vxlan_tos_ttl,
15509 		(void *)&cmd_set_vxlan_ip_version,
15510 		(void *)&cmd_set_vxlan_ip_version_value,
15511 		(void *)&cmd_set_vxlan_vni,
15512 		(void *)&cmd_set_vxlan_vni_value,
15513 		(void *)&cmd_set_vxlan_udp_src,
15514 		(void *)&cmd_set_vxlan_udp_src_value,
15515 		(void *)&cmd_set_vxlan_udp_dst,
15516 		(void *)&cmd_set_vxlan_udp_dst_value,
15517 		(void *)&cmd_set_vxlan_ip_tos,
15518 		(void *)&cmd_set_vxlan_ip_tos_value,
15519 		(void *)&cmd_set_vxlan_ip_ttl,
15520 		(void *)&cmd_set_vxlan_ip_ttl_value,
15521 		(void *)&cmd_set_vxlan_ip_src,
15522 		(void *)&cmd_set_vxlan_ip_src_value,
15523 		(void *)&cmd_set_vxlan_ip_dst,
15524 		(void *)&cmd_set_vxlan_ip_dst_value,
15525 		(void *)&cmd_set_vxlan_eth_src,
15526 		(void *)&cmd_set_vxlan_eth_src_value,
15527 		(void *)&cmd_set_vxlan_eth_dst,
15528 		(void *)&cmd_set_vxlan_eth_dst_value,
15529 		NULL,
15530 	},
15531 };
15532 
15533 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
15534 	.f = cmd_set_vxlan_parsed,
15535 	.data = NULL,
15536 	.help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
15537 		" udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
15538 		" <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
15539 		" <eth-dst>",
15540 	.tokens = {
15541 		(void *)&cmd_set_vxlan_set,
15542 		(void *)&cmd_set_vxlan_vxlan_with_vlan,
15543 		(void *)&cmd_set_vxlan_ip_version,
15544 		(void *)&cmd_set_vxlan_ip_version_value,
15545 		(void *)&cmd_set_vxlan_vni,
15546 		(void *)&cmd_set_vxlan_vni_value,
15547 		(void *)&cmd_set_vxlan_udp_src,
15548 		(void *)&cmd_set_vxlan_udp_src_value,
15549 		(void *)&cmd_set_vxlan_udp_dst,
15550 		(void *)&cmd_set_vxlan_udp_dst_value,
15551 		(void *)&cmd_set_vxlan_ip_src,
15552 		(void *)&cmd_set_vxlan_ip_src_value,
15553 		(void *)&cmd_set_vxlan_ip_dst,
15554 		(void *)&cmd_set_vxlan_ip_dst_value,
15555 		(void *)&cmd_set_vxlan_vlan,
15556 		(void *)&cmd_set_vxlan_vlan_value,
15557 		(void *)&cmd_set_vxlan_eth_src,
15558 		(void *)&cmd_set_vxlan_eth_src_value,
15559 		(void *)&cmd_set_vxlan_eth_dst,
15560 		(void *)&cmd_set_vxlan_eth_dst_value,
15561 		NULL,
15562 	},
15563 };
15564 
15565 /** Set NVGRE encapsulation details */
15566 struct cmd_set_nvgre_result {
15567 	cmdline_fixed_string_t set;
15568 	cmdline_fixed_string_t nvgre;
15569 	cmdline_fixed_string_t pos_token;
15570 	cmdline_fixed_string_t ip_version;
15571 	uint32_t tni;
15572 	cmdline_ipaddr_t ip_src;
15573 	cmdline_ipaddr_t ip_dst;
15574 	uint16_t tci;
15575 	struct rte_ether_addr eth_src;
15576 	struct rte_ether_addr eth_dst;
15577 };
15578 
15579 cmdline_parse_token_string_t cmd_set_nvgre_set =
15580 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
15581 cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
15582 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
15583 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
15584 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
15585 				 "nvgre-with-vlan");
15586 cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
15587 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15588 				 "ip-version");
15589 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
15590 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
15591 				 "ipv4#ipv6");
15592 cmdline_parse_token_string_t cmd_set_nvgre_tni =
15593 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15594 				 "tni");
15595 cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
15596 	TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, UINT32);
15597 cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
15598 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15599 				 "ip-src");
15600 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
15601 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
15602 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
15603 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15604 				 "ip-dst");
15605 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
15606 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
15607 cmdline_parse_token_string_t cmd_set_nvgre_vlan =
15608 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15609 				 "vlan-tci");
15610 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
15611 	TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, UINT16);
15612 cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
15613 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15614 				 "eth-src");
15615 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
15616 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
15617 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
15618 	TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15619 				 "eth-dst");
15620 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
15621 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
15622 
15623 static void cmd_set_nvgre_parsed(void *parsed_result,
15624 	__attribute__((unused)) struct cmdline *cl,
15625 	__attribute__((unused)) void *data)
15626 {
15627 	struct cmd_set_nvgre_result *res = parsed_result;
15628 	union {
15629 		uint32_t nvgre_tni;
15630 		uint8_t tni[4];
15631 	} id = {
15632 		.nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
15633 	};
15634 
15635 	if (strcmp(res->nvgre, "nvgre") == 0)
15636 		nvgre_encap_conf.select_vlan = 0;
15637 	else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
15638 		nvgre_encap_conf.select_vlan = 1;
15639 	if (strcmp(res->ip_version, "ipv4") == 0)
15640 		nvgre_encap_conf.select_ipv4 = 1;
15641 	else if (strcmp(res->ip_version, "ipv6") == 0)
15642 		nvgre_encap_conf.select_ipv4 = 0;
15643 	else
15644 		return;
15645 	rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
15646 	if (nvgre_encap_conf.select_ipv4) {
15647 		IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
15648 		IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
15649 	} else {
15650 		IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
15651 		IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
15652 	}
15653 	if (nvgre_encap_conf.select_vlan)
15654 		nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15655 	rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
15656 		   RTE_ETHER_ADDR_LEN);
15657 	rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15658 		   RTE_ETHER_ADDR_LEN);
15659 }
15660 
15661 cmdline_parse_inst_t cmd_set_nvgre = {
15662 	.f = cmd_set_nvgre_parsed,
15663 	.data = NULL,
15664 	.help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
15665 		" <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15666 		" eth-dst <eth-dst>",
15667 	.tokens = {
15668 		(void *)&cmd_set_nvgre_set,
15669 		(void *)&cmd_set_nvgre_nvgre,
15670 		(void *)&cmd_set_nvgre_ip_version,
15671 		(void *)&cmd_set_nvgre_ip_version_value,
15672 		(void *)&cmd_set_nvgre_tni,
15673 		(void *)&cmd_set_nvgre_tni_value,
15674 		(void *)&cmd_set_nvgre_ip_src,
15675 		(void *)&cmd_set_nvgre_ip_src_value,
15676 		(void *)&cmd_set_nvgre_ip_dst,
15677 		(void *)&cmd_set_nvgre_ip_dst_value,
15678 		(void *)&cmd_set_nvgre_eth_src,
15679 		(void *)&cmd_set_nvgre_eth_src_value,
15680 		(void *)&cmd_set_nvgre_eth_dst,
15681 		(void *)&cmd_set_nvgre_eth_dst_value,
15682 		NULL,
15683 	},
15684 };
15685 
15686 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
15687 	.f = cmd_set_nvgre_parsed,
15688 	.data = NULL,
15689 	.help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
15690 		" ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
15691 		" eth-src <eth-src> eth-dst <eth-dst>",
15692 	.tokens = {
15693 		(void *)&cmd_set_nvgre_set,
15694 		(void *)&cmd_set_nvgre_nvgre_with_vlan,
15695 		(void *)&cmd_set_nvgre_ip_version,
15696 		(void *)&cmd_set_nvgre_ip_version_value,
15697 		(void *)&cmd_set_nvgre_tni,
15698 		(void *)&cmd_set_nvgre_tni_value,
15699 		(void *)&cmd_set_nvgre_ip_src,
15700 		(void *)&cmd_set_nvgre_ip_src_value,
15701 		(void *)&cmd_set_nvgre_ip_dst,
15702 		(void *)&cmd_set_nvgre_ip_dst_value,
15703 		(void *)&cmd_set_nvgre_vlan,
15704 		(void *)&cmd_set_nvgre_vlan_value,
15705 		(void *)&cmd_set_nvgre_eth_src,
15706 		(void *)&cmd_set_nvgre_eth_src_value,
15707 		(void *)&cmd_set_nvgre_eth_dst,
15708 		(void *)&cmd_set_nvgre_eth_dst_value,
15709 		NULL,
15710 	},
15711 };
15712 
15713 /** Set L2 encapsulation details */
15714 struct cmd_set_l2_encap_result {
15715 	cmdline_fixed_string_t set;
15716 	cmdline_fixed_string_t l2_encap;
15717 	cmdline_fixed_string_t pos_token;
15718 	cmdline_fixed_string_t ip_version;
15719 	uint32_t vlan_present:1;
15720 	uint16_t tci;
15721 	struct rte_ether_addr eth_src;
15722 	struct rte_ether_addr eth_dst;
15723 };
15724 
15725 cmdline_parse_token_string_t cmd_set_l2_encap_set =
15726 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
15727 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
15728 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
15729 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
15730 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
15731 				 "l2_encap-with-vlan");
15732 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
15733 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15734 				 "ip-version");
15735 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
15736 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
15737 				 "ipv4#ipv6");
15738 cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
15739 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15740 				 "vlan-tci");
15741 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
15742 	TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, UINT16);
15743 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
15744 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15745 				 "eth-src");
15746 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
15747 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
15748 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
15749 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15750 				 "eth-dst");
15751 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
15752 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
15753 
15754 static void cmd_set_l2_encap_parsed(void *parsed_result,
15755 	__attribute__((unused)) struct cmdline *cl,
15756 	__attribute__((unused)) void *data)
15757 {
15758 	struct cmd_set_l2_encap_result *res = parsed_result;
15759 
15760 	if (strcmp(res->l2_encap, "l2_encap") == 0)
15761 		l2_encap_conf.select_vlan = 0;
15762 	else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
15763 		l2_encap_conf.select_vlan = 1;
15764 	if (strcmp(res->ip_version, "ipv4") == 0)
15765 		l2_encap_conf.select_ipv4 = 1;
15766 	else if (strcmp(res->ip_version, "ipv6") == 0)
15767 		l2_encap_conf.select_ipv4 = 0;
15768 	else
15769 		return;
15770 	if (l2_encap_conf.select_vlan)
15771 		l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15772 	rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
15773 		   RTE_ETHER_ADDR_LEN);
15774 	rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15775 		   RTE_ETHER_ADDR_LEN);
15776 }
15777 
15778 cmdline_parse_inst_t cmd_set_l2_encap = {
15779 	.f = cmd_set_l2_encap_parsed,
15780 	.data = NULL,
15781 	.help_str = "set l2_encap ip-version ipv4|ipv6"
15782 		" eth-src <eth-src> eth-dst <eth-dst>",
15783 	.tokens = {
15784 		(void *)&cmd_set_l2_encap_set,
15785 		(void *)&cmd_set_l2_encap_l2_encap,
15786 		(void *)&cmd_set_l2_encap_ip_version,
15787 		(void *)&cmd_set_l2_encap_ip_version_value,
15788 		(void *)&cmd_set_l2_encap_eth_src,
15789 		(void *)&cmd_set_l2_encap_eth_src_value,
15790 		(void *)&cmd_set_l2_encap_eth_dst,
15791 		(void *)&cmd_set_l2_encap_eth_dst_value,
15792 		NULL,
15793 	},
15794 };
15795 
15796 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
15797 	.f = cmd_set_l2_encap_parsed,
15798 	.data = NULL,
15799 	.help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
15800 		" vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
15801 	.tokens = {
15802 		(void *)&cmd_set_l2_encap_set,
15803 		(void *)&cmd_set_l2_encap_l2_encap_with_vlan,
15804 		(void *)&cmd_set_l2_encap_ip_version,
15805 		(void *)&cmd_set_l2_encap_ip_version_value,
15806 		(void *)&cmd_set_l2_encap_vlan,
15807 		(void *)&cmd_set_l2_encap_vlan_value,
15808 		(void *)&cmd_set_l2_encap_eth_src,
15809 		(void *)&cmd_set_l2_encap_eth_src_value,
15810 		(void *)&cmd_set_l2_encap_eth_dst,
15811 		(void *)&cmd_set_l2_encap_eth_dst_value,
15812 		NULL,
15813 	},
15814 };
15815 
15816 /** Set L2 decapsulation details */
15817 struct cmd_set_l2_decap_result {
15818 	cmdline_fixed_string_t set;
15819 	cmdline_fixed_string_t l2_decap;
15820 	cmdline_fixed_string_t pos_token;
15821 	uint32_t vlan_present:1;
15822 };
15823 
15824 cmdline_parse_token_string_t cmd_set_l2_decap_set =
15825 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
15826 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
15827 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
15828 				 "l2_decap");
15829 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
15830 	TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
15831 				 "l2_decap-with-vlan");
15832 
15833 static void cmd_set_l2_decap_parsed(void *parsed_result,
15834 	__attribute__((unused)) struct cmdline *cl,
15835 	__attribute__((unused)) void *data)
15836 {
15837 	struct cmd_set_l2_decap_result *res = parsed_result;
15838 
15839 	if (strcmp(res->l2_decap, "l2_decap") == 0)
15840 		l2_decap_conf.select_vlan = 0;
15841 	else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
15842 		l2_decap_conf.select_vlan = 1;
15843 }
15844 
15845 cmdline_parse_inst_t cmd_set_l2_decap = {
15846 	.f = cmd_set_l2_decap_parsed,
15847 	.data = NULL,
15848 	.help_str = "set l2_decap",
15849 	.tokens = {
15850 		(void *)&cmd_set_l2_decap_set,
15851 		(void *)&cmd_set_l2_decap_l2_decap,
15852 		NULL,
15853 	},
15854 };
15855 
15856 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
15857 	.f = cmd_set_l2_decap_parsed,
15858 	.data = NULL,
15859 	.help_str = "set l2_decap-with-vlan",
15860 	.tokens = {
15861 		(void *)&cmd_set_l2_decap_set,
15862 		(void *)&cmd_set_l2_decap_l2_decap_with_vlan,
15863 		NULL,
15864 	},
15865 };
15866 
15867 /** Set MPLSoGRE encapsulation details */
15868 struct cmd_set_mplsogre_encap_result {
15869 	cmdline_fixed_string_t set;
15870 	cmdline_fixed_string_t mplsogre;
15871 	cmdline_fixed_string_t pos_token;
15872 	cmdline_fixed_string_t ip_version;
15873 	uint32_t vlan_present:1;
15874 	uint32_t label;
15875 	cmdline_ipaddr_t ip_src;
15876 	cmdline_ipaddr_t ip_dst;
15877 	uint16_t tci;
15878 	struct rte_ether_addr eth_src;
15879 	struct rte_ether_addr eth_dst;
15880 };
15881 
15882 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
15883 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
15884 				 "set");
15885 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
15886 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
15887 				 "mplsogre_encap");
15888 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
15889 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15890 				 mplsogre, "mplsogre_encap-with-vlan");
15891 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
15892 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15893 				 pos_token, "ip-version");
15894 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
15895 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15896 				 ip_version, "ipv4#ipv6");
15897 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
15898 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15899 				 pos_token, "label");
15900 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
15901 	TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
15902 			      UINT32);
15903 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
15904 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15905 				 pos_token, "ip-src");
15906 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
15907 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
15908 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
15909 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15910 				 pos_token, "ip-dst");
15911 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
15912 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
15913 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
15914 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15915 				 pos_token, "vlan-tci");
15916 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
15917 	TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
15918 			      UINT16);
15919 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
15920 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15921 				 pos_token, "eth-src");
15922 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
15923 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15924 				    eth_src);
15925 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
15926 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15927 				 pos_token, "eth-dst");
15928 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
15929 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15930 				    eth_dst);
15931 
15932 static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
15933 	__attribute__((unused)) struct cmdline *cl,
15934 	__attribute__((unused)) void *data)
15935 {
15936 	struct cmd_set_mplsogre_encap_result *res = parsed_result;
15937 	union {
15938 		uint32_t mplsogre_label;
15939 		uint8_t label[4];
15940 	} id = {
15941 		.mplsogre_label = rte_cpu_to_be_32(res->label<<12),
15942 	};
15943 
15944 	if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
15945 		mplsogre_encap_conf.select_vlan = 0;
15946 	else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
15947 		mplsogre_encap_conf.select_vlan = 1;
15948 	if (strcmp(res->ip_version, "ipv4") == 0)
15949 		mplsogre_encap_conf.select_ipv4 = 1;
15950 	else if (strcmp(res->ip_version, "ipv6") == 0)
15951 		mplsogre_encap_conf.select_ipv4 = 0;
15952 	else
15953 		return;
15954 	rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
15955 	if (mplsogre_encap_conf.select_ipv4) {
15956 		IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
15957 		IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
15958 	} else {
15959 		IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
15960 		IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
15961 	}
15962 	if (mplsogre_encap_conf.select_vlan)
15963 		mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15964 	rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
15965 		   RTE_ETHER_ADDR_LEN);
15966 	rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15967 		   RTE_ETHER_ADDR_LEN);
15968 }
15969 
15970 cmdline_parse_inst_t cmd_set_mplsogre_encap = {
15971 	.f = cmd_set_mplsogre_encap_parsed,
15972 	.data = NULL,
15973 	.help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
15974 		" ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15975 		" eth-dst <eth-dst>",
15976 	.tokens = {
15977 		(void *)&cmd_set_mplsogre_encap_set,
15978 		(void *)&cmd_set_mplsogre_encap_mplsogre_encap,
15979 		(void *)&cmd_set_mplsogre_encap_ip_version,
15980 		(void *)&cmd_set_mplsogre_encap_ip_version_value,
15981 		(void *)&cmd_set_mplsogre_encap_label,
15982 		(void *)&cmd_set_mplsogre_encap_label_value,
15983 		(void *)&cmd_set_mplsogre_encap_ip_src,
15984 		(void *)&cmd_set_mplsogre_encap_ip_src_value,
15985 		(void *)&cmd_set_mplsogre_encap_ip_dst,
15986 		(void *)&cmd_set_mplsogre_encap_ip_dst_value,
15987 		(void *)&cmd_set_mplsogre_encap_eth_src,
15988 		(void *)&cmd_set_mplsogre_encap_eth_src_value,
15989 		(void *)&cmd_set_mplsogre_encap_eth_dst,
15990 		(void *)&cmd_set_mplsogre_encap_eth_dst_value,
15991 		NULL,
15992 	},
15993 };
15994 
15995 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
15996 	.f = cmd_set_mplsogre_encap_parsed,
15997 	.data = NULL,
15998 	.help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
15999 		" label <label> ip-src <ip-src> ip-dst <ip-dst>"
16000 		" vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
16001 	.tokens = {
16002 		(void *)&cmd_set_mplsogre_encap_set,
16003 		(void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
16004 		(void *)&cmd_set_mplsogre_encap_ip_version,
16005 		(void *)&cmd_set_mplsogre_encap_ip_version_value,
16006 		(void *)&cmd_set_mplsogre_encap_label,
16007 		(void *)&cmd_set_mplsogre_encap_label_value,
16008 		(void *)&cmd_set_mplsogre_encap_ip_src,
16009 		(void *)&cmd_set_mplsogre_encap_ip_src_value,
16010 		(void *)&cmd_set_mplsogre_encap_ip_dst,
16011 		(void *)&cmd_set_mplsogre_encap_ip_dst_value,
16012 		(void *)&cmd_set_mplsogre_encap_vlan,
16013 		(void *)&cmd_set_mplsogre_encap_vlan_value,
16014 		(void *)&cmd_set_mplsogre_encap_eth_src,
16015 		(void *)&cmd_set_mplsogre_encap_eth_src_value,
16016 		(void *)&cmd_set_mplsogre_encap_eth_dst,
16017 		(void *)&cmd_set_mplsogre_encap_eth_dst_value,
16018 		NULL,
16019 	},
16020 };
16021 
16022 /** Set MPLSoGRE decapsulation details */
16023 struct cmd_set_mplsogre_decap_result {
16024 	cmdline_fixed_string_t set;
16025 	cmdline_fixed_string_t mplsogre;
16026 	cmdline_fixed_string_t pos_token;
16027 	cmdline_fixed_string_t ip_version;
16028 	uint32_t vlan_present:1;
16029 };
16030 
16031 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
16032 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
16033 				 "set");
16034 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
16035 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
16036 				 "mplsogre_decap");
16037 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
16038 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
16039 				 mplsogre, "mplsogre_decap-with-vlan");
16040 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
16041 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
16042 				 pos_token, "ip-version");
16043 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
16044 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
16045 				 ip_version, "ipv4#ipv6");
16046 
16047 static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
16048 	__attribute__((unused)) struct cmdline *cl,
16049 	__attribute__((unused)) void *data)
16050 {
16051 	struct cmd_set_mplsogre_decap_result *res = parsed_result;
16052 
16053 	if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
16054 		mplsogre_decap_conf.select_vlan = 0;
16055 	else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
16056 		mplsogre_decap_conf.select_vlan = 1;
16057 	if (strcmp(res->ip_version, "ipv4") == 0)
16058 		mplsogre_decap_conf.select_ipv4 = 1;
16059 	else if (strcmp(res->ip_version, "ipv6") == 0)
16060 		mplsogre_decap_conf.select_ipv4 = 0;
16061 }
16062 
16063 cmdline_parse_inst_t cmd_set_mplsogre_decap = {
16064 	.f = cmd_set_mplsogre_decap_parsed,
16065 	.data = NULL,
16066 	.help_str = "set mplsogre_decap ip-version ipv4|ipv6",
16067 	.tokens = {
16068 		(void *)&cmd_set_mplsogre_decap_set,
16069 		(void *)&cmd_set_mplsogre_decap_mplsogre_decap,
16070 		(void *)&cmd_set_mplsogre_decap_ip_version,
16071 		(void *)&cmd_set_mplsogre_decap_ip_version_value,
16072 		NULL,
16073 	},
16074 };
16075 
16076 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
16077 	.f = cmd_set_mplsogre_decap_parsed,
16078 	.data = NULL,
16079 	.help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
16080 	.tokens = {
16081 		(void *)&cmd_set_mplsogre_decap_set,
16082 		(void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
16083 		(void *)&cmd_set_mplsogre_decap_ip_version,
16084 		(void *)&cmd_set_mplsogre_decap_ip_version_value,
16085 		NULL,
16086 	},
16087 };
16088 
16089 /** Set MPLSoUDP encapsulation details */
16090 struct cmd_set_mplsoudp_encap_result {
16091 	cmdline_fixed_string_t set;
16092 	cmdline_fixed_string_t mplsoudp;
16093 	cmdline_fixed_string_t pos_token;
16094 	cmdline_fixed_string_t ip_version;
16095 	uint32_t vlan_present:1;
16096 	uint32_t label;
16097 	uint16_t udp_src;
16098 	uint16_t udp_dst;
16099 	cmdline_ipaddr_t ip_src;
16100 	cmdline_ipaddr_t ip_dst;
16101 	uint16_t tci;
16102 	struct rte_ether_addr eth_src;
16103 	struct rte_ether_addr eth_dst;
16104 };
16105 
16106 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
16107 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
16108 				 "set");
16109 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
16110 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
16111 				 "mplsoudp_encap");
16112 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
16113 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16114 				 mplsoudp, "mplsoudp_encap-with-vlan");
16115 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
16116 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16117 				 pos_token, "ip-version");
16118 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
16119 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16120 				 ip_version, "ipv4#ipv6");
16121 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
16122 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16123 				 pos_token, "label");
16124 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
16125 	TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
16126 			      UINT32);
16127 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
16128 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16129 				 pos_token, "udp-src");
16130 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
16131 	TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
16132 			      UINT16);
16133 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
16134 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16135 				 pos_token, "udp-dst");
16136 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
16137 	TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
16138 			      UINT16);
16139 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
16140 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16141 				 pos_token, "ip-src");
16142 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
16143 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
16144 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
16145 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16146 				 pos_token, "ip-dst");
16147 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
16148 	TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
16149 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
16150 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16151 				 pos_token, "vlan-tci");
16152 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
16153 	TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
16154 			      UINT16);
16155 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
16156 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16157 				 pos_token, "eth-src");
16158 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
16159 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16160 				    eth_src);
16161 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
16162 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16163 				 pos_token, "eth-dst");
16164 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
16165 	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16166 				    eth_dst);
16167 
16168 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
16169 	__attribute__((unused)) struct cmdline *cl,
16170 	__attribute__((unused)) void *data)
16171 {
16172 	struct cmd_set_mplsoudp_encap_result *res = parsed_result;
16173 	union {
16174 		uint32_t mplsoudp_label;
16175 		uint8_t label[4];
16176 	} id = {
16177 		.mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
16178 	};
16179 
16180 	if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
16181 		mplsoudp_encap_conf.select_vlan = 0;
16182 	else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
16183 		mplsoudp_encap_conf.select_vlan = 1;
16184 	if (strcmp(res->ip_version, "ipv4") == 0)
16185 		mplsoudp_encap_conf.select_ipv4 = 1;
16186 	else if (strcmp(res->ip_version, "ipv6") == 0)
16187 		mplsoudp_encap_conf.select_ipv4 = 0;
16188 	else
16189 		return;
16190 	rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
16191 	mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
16192 	mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
16193 	if (mplsoudp_encap_conf.select_ipv4) {
16194 		IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
16195 		IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
16196 	} else {
16197 		IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
16198 		IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
16199 	}
16200 	if (mplsoudp_encap_conf.select_vlan)
16201 		mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
16202 	rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
16203 		   RTE_ETHER_ADDR_LEN);
16204 	rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
16205 		   RTE_ETHER_ADDR_LEN);
16206 }
16207 
16208 cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
16209 	.f = cmd_set_mplsoudp_encap_parsed,
16210 	.data = NULL,
16211 	.help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
16212 		" udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
16213 		" ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
16214 	.tokens = {
16215 		(void *)&cmd_set_mplsoudp_encap_set,
16216 		(void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
16217 		(void *)&cmd_set_mplsoudp_encap_ip_version,
16218 		(void *)&cmd_set_mplsoudp_encap_ip_version_value,
16219 		(void *)&cmd_set_mplsoudp_encap_label,
16220 		(void *)&cmd_set_mplsoudp_encap_label_value,
16221 		(void *)&cmd_set_mplsoudp_encap_udp_src,
16222 		(void *)&cmd_set_mplsoudp_encap_udp_src_value,
16223 		(void *)&cmd_set_mplsoudp_encap_udp_dst,
16224 		(void *)&cmd_set_mplsoudp_encap_udp_dst_value,
16225 		(void *)&cmd_set_mplsoudp_encap_ip_src,
16226 		(void *)&cmd_set_mplsoudp_encap_ip_src_value,
16227 		(void *)&cmd_set_mplsoudp_encap_ip_dst,
16228 		(void *)&cmd_set_mplsoudp_encap_ip_dst_value,
16229 		(void *)&cmd_set_mplsoudp_encap_eth_src,
16230 		(void *)&cmd_set_mplsoudp_encap_eth_src_value,
16231 		(void *)&cmd_set_mplsoudp_encap_eth_dst,
16232 		(void *)&cmd_set_mplsoudp_encap_eth_dst_value,
16233 		NULL,
16234 	},
16235 };
16236 
16237 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
16238 	.f = cmd_set_mplsoudp_encap_parsed,
16239 	.data = NULL,
16240 	.help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
16241 		" label <label> udp-src <udp-src> udp-dst <udp-dst>"
16242 		" ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
16243 		" eth-src <eth-src> eth-dst <eth-dst>",
16244 	.tokens = {
16245 		(void *)&cmd_set_mplsoudp_encap_set,
16246 		(void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
16247 		(void *)&cmd_set_mplsoudp_encap_ip_version,
16248 		(void *)&cmd_set_mplsoudp_encap_ip_version_value,
16249 		(void *)&cmd_set_mplsoudp_encap_label,
16250 		(void *)&cmd_set_mplsoudp_encap_label_value,
16251 		(void *)&cmd_set_mplsoudp_encap_udp_src,
16252 		(void *)&cmd_set_mplsoudp_encap_udp_src_value,
16253 		(void *)&cmd_set_mplsoudp_encap_udp_dst,
16254 		(void *)&cmd_set_mplsoudp_encap_udp_dst_value,
16255 		(void *)&cmd_set_mplsoudp_encap_ip_src,
16256 		(void *)&cmd_set_mplsoudp_encap_ip_src_value,
16257 		(void *)&cmd_set_mplsoudp_encap_ip_dst,
16258 		(void *)&cmd_set_mplsoudp_encap_ip_dst_value,
16259 		(void *)&cmd_set_mplsoudp_encap_vlan,
16260 		(void *)&cmd_set_mplsoudp_encap_vlan_value,
16261 		(void *)&cmd_set_mplsoudp_encap_eth_src,
16262 		(void *)&cmd_set_mplsoudp_encap_eth_src_value,
16263 		(void *)&cmd_set_mplsoudp_encap_eth_dst,
16264 		(void *)&cmd_set_mplsoudp_encap_eth_dst_value,
16265 		NULL,
16266 	},
16267 };
16268 
16269 /** Set MPLSoUDP decapsulation details */
16270 struct cmd_set_mplsoudp_decap_result {
16271 	cmdline_fixed_string_t set;
16272 	cmdline_fixed_string_t mplsoudp;
16273 	cmdline_fixed_string_t pos_token;
16274 	cmdline_fixed_string_t ip_version;
16275 	uint32_t vlan_present:1;
16276 };
16277 
16278 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
16279 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
16280 				 "set");
16281 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
16282 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
16283 				 "mplsoudp_decap");
16284 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
16285 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16286 				 mplsoudp, "mplsoudp_decap-with-vlan");
16287 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
16288 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16289 				 pos_token, "ip-version");
16290 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
16291 	TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16292 				 ip_version, "ipv4#ipv6");
16293 
16294 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
16295 	__attribute__((unused)) struct cmdline *cl,
16296 	__attribute__((unused)) void *data)
16297 {
16298 	struct cmd_set_mplsoudp_decap_result *res = parsed_result;
16299 
16300 	if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
16301 		mplsoudp_decap_conf.select_vlan = 0;
16302 	else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
16303 		mplsoudp_decap_conf.select_vlan = 1;
16304 	if (strcmp(res->ip_version, "ipv4") == 0)
16305 		mplsoudp_decap_conf.select_ipv4 = 1;
16306 	else if (strcmp(res->ip_version, "ipv6") == 0)
16307 		mplsoudp_decap_conf.select_ipv4 = 0;
16308 }
16309 
16310 cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
16311 	.f = cmd_set_mplsoudp_decap_parsed,
16312 	.data = NULL,
16313 	.help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
16314 	.tokens = {
16315 		(void *)&cmd_set_mplsoudp_decap_set,
16316 		(void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
16317 		(void *)&cmd_set_mplsoudp_decap_ip_version,
16318 		(void *)&cmd_set_mplsoudp_decap_ip_version_value,
16319 		NULL,
16320 	},
16321 };
16322 
16323 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
16324 	.f = cmd_set_mplsoudp_decap_parsed,
16325 	.data = NULL,
16326 	.help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
16327 	.tokens = {
16328 		(void *)&cmd_set_mplsoudp_decap_set,
16329 		(void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
16330 		(void *)&cmd_set_mplsoudp_decap_ip_version,
16331 		(void *)&cmd_set_mplsoudp_decap_ip_version_value,
16332 		NULL,
16333 	},
16334 };
16335 
16336 /* Strict link priority scheduling mode setting */
16337 static void
16338 cmd_strict_link_prio_parsed(
16339 	void *parsed_result,
16340 	__attribute__((unused)) struct cmdline *cl,
16341 	__attribute__((unused)) void *data)
16342 {
16343 	struct cmd_vf_tc_bw_result *res = parsed_result;
16344 	int ret = -ENOTSUP;
16345 
16346 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16347 		return;
16348 
16349 #ifdef RTE_LIBRTE_I40E_PMD
16350 	ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
16351 #endif
16352 
16353 	switch (ret) {
16354 	case 0:
16355 		break;
16356 	case -EINVAL:
16357 		printf("invalid tc_bitmap 0x%x\n", res->tc_map);
16358 		break;
16359 	case -ENODEV:
16360 		printf("invalid port_id %d\n", res->port_id);
16361 		break;
16362 	case -ENOTSUP:
16363 		printf("function not implemented\n");
16364 		break;
16365 	default:
16366 		printf("programming error: (%s)\n", strerror(-ret));
16367 	}
16368 }
16369 
16370 cmdline_parse_inst_t cmd_strict_link_prio = {
16371 	.f = cmd_strict_link_prio_parsed,
16372 	.data = NULL,
16373 	.help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
16374 	.tokens = {
16375 		(void *)&cmd_vf_tc_bw_set,
16376 		(void *)&cmd_vf_tc_bw_tx,
16377 		(void *)&cmd_vf_tc_bw_strict_link_prio,
16378 		(void *)&cmd_vf_tc_bw_port_id,
16379 		(void *)&cmd_vf_tc_bw_tc_map,
16380 		NULL,
16381 	},
16382 };
16383 
16384 /* Load dynamic device personalization*/
16385 struct cmd_ddp_add_result {
16386 	cmdline_fixed_string_t ddp;
16387 	cmdline_fixed_string_t add;
16388 	portid_t port_id;
16389 	char filepath[];
16390 };
16391 
16392 cmdline_parse_token_string_t cmd_ddp_add_ddp =
16393 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
16394 cmdline_parse_token_string_t cmd_ddp_add_add =
16395 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
16396 cmdline_parse_token_num_t cmd_ddp_add_port_id =
16397 	TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
16398 cmdline_parse_token_string_t cmd_ddp_add_filepath =
16399 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
16400 
16401 static void
16402 cmd_ddp_add_parsed(
16403 	void *parsed_result,
16404 	__attribute__((unused)) struct cmdline *cl,
16405 	__attribute__((unused)) void *data)
16406 {
16407 	struct cmd_ddp_add_result *res = parsed_result;
16408 	uint8_t *buff;
16409 	uint32_t size;
16410 	char *filepath;
16411 	char *file_fld[2];
16412 	int file_num;
16413 	int ret = -ENOTSUP;
16414 
16415 	if (!all_ports_stopped()) {
16416 		printf("Please stop all ports first\n");
16417 		return;
16418 	}
16419 
16420 	filepath = strdup(res->filepath);
16421 	if (filepath == NULL) {
16422 		printf("Failed to allocate memory\n");
16423 		return;
16424 	}
16425 	file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
16426 
16427 	buff = open_file(file_fld[0], &size);
16428 	if (!buff) {
16429 		free((void *)filepath);
16430 		return;
16431 	}
16432 
16433 #ifdef RTE_LIBRTE_I40E_PMD
16434 	if (ret == -ENOTSUP)
16435 		ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16436 					       buff, size,
16437 					       RTE_PMD_I40E_PKG_OP_WR_ADD);
16438 #endif
16439 
16440 	if (ret == -EEXIST)
16441 		printf("Profile has already existed.\n");
16442 	else if (ret < 0)
16443 		printf("Failed to load profile.\n");
16444 	else if (file_num == 2)
16445 		save_file(file_fld[1], buff, size);
16446 
16447 	close_file(buff);
16448 	free((void *)filepath);
16449 }
16450 
16451 cmdline_parse_inst_t cmd_ddp_add = {
16452 	.f = cmd_ddp_add_parsed,
16453 	.data = NULL,
16454 	.help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
16455 	.tokens = {
16456 		(void *)&cmd_ddp_add_ddp,
16457 		(void *)&cmd_ddp_add_add,
16458 		(void *)&cmd_ddp_add_port_id,
16459 		(void *)&cmd_ddp_add_filepath,
16460 		NULL,
16461 	},
16462 };
16463 
16464 /* Delete dynamic device personalization*/
16465 struct cmd_ddp_del_result {
16466 	cmdline_fixed_string_t ddp;
16467 	cmdline_fixed_string_t del;
16468 	portid_t port_id;
16469 	char filepath[];
16470 };
16471 
16472 cmdline_parse_token_string_t cmd_ddp_del_ddp =
16473 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
16474 cmdline_parse_token_string_t cmd_ddp_del_del =
16475 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
16476 cmdline_parse_token_num_t cmd_ddp_del_port_id =
16477 	TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
16478 cmdline_parse_token_string_t cmd_ddp_del_filepath =
16479 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
16480 
16481 static void
16482 cmd_ddp_del_parsed(
16483 	void *parsed_result,
16484 	__attribute__((unused)) struct cmdline *cl,
16485 	__attribute__((unused)) void *data)
16486 {
16487 	struct cmd_ddp_del_result *res = parsed_result;
16488 	uint8_t *buff;
16489 	uint32_t size;
16490 	int ret = -ENOTSUP;
16491 
16492 	if (!all_ports_stopped()) {
16493 		printf("Please stop all ports first\n");
16494 		return;
16495 	}
16496 
16497 	buff = open_file(res->filepath, &size);
16498 	if (!buff)
16499 		return;
16500 
16501 #ifdef RTE_LIBRTE_I40E_PMD
16502 	if (ret == -ENOTSUP)
16503 		ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16504 					       buff, size,
16505 					       RTE_PMD_I40E_PKG_OP_WR_DEL);
16506 #endif
16507 
16508 	if (ret == -EACCES)
16509 		printf("Profile does not exist.\n");
16510 	else if (ret < 0)
16511 		printf("Failed to delete profile.\n");
16512 
16513 	close_file(buff);
16514 }
16515 
16516 cmdline_parse_inst_t cmd_ddp_del = {
16517 	.f = cmd_ddp_del_parsed,
16518 	.data = NULL,
16519 	.help_str = "ddp del <port_id> <backup_profile_path>",
16520 	.tokens = {
16521 		(void *)&cmd_ddp_del_ddp,
16522 		(void *)&cmd_ddp_del_del,
16523 		(void *)&cmd_ddp_del_port_id,
16524 		(void *)&cmd_ddp_del_filepath,
16525 		NULL,
16526 	},
16527 };
16528 
16529 /* Get dynamic device personalization profile info */
16530 struct cmd_ddp_info_result {
16531 	cmdline_fixed_string_t ddp;
16532 	cmdline_fixed_string_t get;
16533 	cmdline_fixed_string_t info;
16534 	char filepath[];
16535 };
16536 
16537 cmdline_parse_token_string_t cmd_ddp_info_ddp =
16538 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
16539 cmdline_parse_token_string_t cmd_ddp_info_get =
16540 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
16541 cmdline_parse_token_string_t cmd_ddp_info_info =
16542 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
16543 cmdline_parse_token_string_t cmd_ddp_info_filepath =
16544 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
16545 
16546 static void
16547 cmd_ddp_info_parsed(
16548 	void *parsed_result,
16549 	__attribute__((unused)) struct cmdline *cl,
16550 	__attribute__((unused)) void *data)
16551 {
16552 	struct cmd_ddp_info_result *res = parsed_result;
16553 	uint8_t *pkg;
16554 	uint32_t pkg_size;
16555 	int ret = -ENOTSUP;
16556 #ifdef RTE_LIBRTE_I40E_PMD
16557 	uint32_t i, j, n;
16558 	uint8_t *buff;
16559 	uint32_t buff_size = 0;
16560 	struct rte_pmd_i40e_profile_info info;
16561 	uint32_t dev_num = 0;
16562 	struct rte_pmd_i40e_ddp_device_id *devs;
16563 	uint32_t proto_num = 0;
16564 	struct rte_pmd_i40e_proto_info *proto = NULL;
16565 	uint32_t pctype_num = 0;
16566 	struct rte_pmd_i40e_ptype_info *pctype;
16567 	uint32_t ptype_num = 0;
16568 	struct rte_pmd_i40e_ptype_info *ptype;
16569 	uint8_t proto_id;
16570 
16571 #endif
16572 
16573 	pkg = open_file(res->filepath, &pkg_size);
16574 	if (!pkg)
16575 		return;
16576 
16577 #ifdef RTE_LIBRTE_I40E_PMD
16578 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16579 				(uint8_t *)&info, sizeof(info),
16580 				RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
16581 	if (!ret) {
16582 		printf("Global Track id:       0x%x\n", info.track_id);
16583 		printf("Global Version:        %d.%d.%d.%d\n",
16584 			info.version.major,
16585 			info.version.minor,
16586 			info.version.update,
16587 			info.version.draft);
16588 		printf("Global Package name:   %s\n\n", info.name);
16589 	}
16590 
16591 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16592 				(uint8_t *)&info, sizeof(info),
16593 				RTE_PMD_I40E_PKG_INFO_HEADER);
16594 	if (!ret) {
16595 		printf("i40e Profile Track id: 0x%x\n", info.track_id);
16596 		printf("i40e Profile Version:  %d.%d.%d.%d\n",
16597 			info.version.major,
16598 			info.version.minor,
16599 			info.version.update,
16600 			info.version.draft);
16601 		printf("i40e Profile name:     %s\n\n", info.name);
16602 	}
16603 
16604 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16605 				(uint8_t *)&buff_size, sizeof(buff_size),
16606 				RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
16607 	if (!ret && buff_size) {
16608 		buff = (uint8_t *)malloc(buff_size);
16609 		if (buff) {
16610 			ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16611 						buff, buff_size,
16612 						RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
16613 			if (!ret)
16614 				printf("Package Notes:\n%s\n\n", buff);
16615 			free(buff);
16616 		}
16617 	}
16618 
16619 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16620 				(uint8_t *)&dev_num, sizeof(dev_num),
16621 				RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
16622 	if (!ret && dev_num) {
16623 		buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
16624 		devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
16625 		if (devs) {
16626 			ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16627 						(uint8_t *)devs, buff_size,
16628 						RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
16629 			if (!ret) {
16630 				printf("List of supported devices:\n");
16631 				for (i = 0; i < dev_num; i++) {
16632 					printf("  %04X:%04X %04X:%04X\n",
16633 						devs[i].vendor_dev_id >> 16,
16634 						devs[i].vendor_dev_id & 0xFFFF,
16635 						devs[i].sub_vendor_dev_id >> 16,
16636 						devs[i].sub_vendor_dev_id & 0xFFFF);
16637 				}
16638 				printf("\n");
16639 			}
16640 			free(devs);
16641 		}
16642 	}
16643 
16644 	/* get information about protocols and packet types */
16645 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16646 		(uint8_t *)&proto_num, sizeof(proto_num),
16647 		RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
16648 	if (ret || !proto_num)
16649 		goto no_print_return;
16650 
16651 	buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
16652 	proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
16653 	if (!proto)
16654 		goto no_print_return;
16655 
16656 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
16657 					buff_size,
16658 					RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
16659 	if (!ret) {
16660 		printf("List of used protocols:\n");
16661 		for (i = 0; i < proto_num; i++)
16662 			printf("  %2u: %s\n", proto[i].proto_id,
16663 			       proto[i].name);
16664 		printf("\n");
16665 	}
16666 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16667 		(uint8_t *)&pctype_num, sizeof(pctype_num),
16668 		RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
16669 	if (ret || !pctype_num)
16670 		goto no_print_pctypes;
16671 
16672 	buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16673 	pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16674 	if (!pctype)
16675 		goto no_print_pctypes;
16676 
16677 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
16678 					buff_size,
16679 					RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
16680 	if (ret) {
16681 		free(pctype);
16682 		goto no_print_pctypes;
16683 	}
16684 
16685 	printf("List of defined packet classification types:\n");
16686 	for (i = 0; i < pctype_num; i++) {
16687 		printf("  %2u:", pctype[i].ptype_id);
16688 		for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
16689 			proto_id = pctype[i].protocols[j];
16690 			if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
16691 				for (n = 0; n < proto_num; n++) {
16692 					if (proto[n].proto_id == proto_id) {
16693 						printf(" %s", proto[n].name);
16694 						break;
16695 					}
16696 				}
16697 			}
16698 		}
16699 		printf("\n");
16700 	}
16701 	printf("\n");
16702 	free(pctype);
16703 
16704 no_print_pctypes:
16705 
16706 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
16707 					sizeof(ptype_num),
16708 					RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
16709 	if (ret || !ptype_num)
16710 		goto no_print_return;
16711 
16712 	buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16713 	ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16714 	if (!ptype)
16715 		goto no_print_return;
16716 
16717 	ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
16718 					buff_size,
16719 					RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
16720 	if (ret) {
16721 		free(ptype);
16722 		goto no_print_return;
16723 	}
16724 	printf("List of defined packet types:\n");
16725 	for (i = 0; i < ptype_num; i++) {
16726 		printf("  %2u:", ptype[i].ptype_id);
16727 		for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
16728 			proto_id = ptype[i].protocols[j];
16729 			if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
16730 				for (n = 0; n < proto_num; n++) {
16731 					if (proto[n].proto_id == proto_id) {
16732 						printf(" %s", proto[n].name);
16733 						break;
16734 					}
16735 				}
16736 			}
16737 		}
16738 		printf("\n");
16739 	}
16740 	free(ptype);
16741 	printf("\n");
16742 
16743 	ret = 0;
16744 no_print_return:
16745 	if (proto)
16746 		free(proto);
16747 #endif
16748 	if (ret == -ENOTSUP)
16749 		printf("Function not supported in PMD driver\n");
16750 	close_file(pkg);
16751 }
16752 
16753 cmdline_parse_inst_t cmd_ddp_get_info = {
16754 	.f = cmd_ddp_info_parsed,
16755 	.data = NULL,
16756 	.help_str = "ddp get info <profile_path>",
16757 	.tokens = {
16758 		(void *)&cmd_ddp_info_ddp,
16759 		(void *)&cmd_ddp_info_get,
16760 		(void *)&cmd_ddp_info_info,
16761 		(void *)&cmd_ddp_info_filepath,
16762 		NULL,
16763 	},
16764 };
16765 
16766 /* Get dynamic device personalization profile info list*/
16767 #define PROFILE_INFO_SIZE 48
16768 #define MAX_PROFILE_NUM 16
16769 
16770 struct cmd_ddp_get_list_result {
16771 	cmdline_fixed_string_t ddp;
16772 	cmdline_fixed_string_t get;
16773 	cmdline_fixed_string_t list;
16774 	portid_t port_id;
16775 };
16776 
16777 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
16778 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
16779 cmdline_parse_token_string_t cmd_ddp_get_list_get =
16780 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
16781 cmdline_parse_token_string_t cmd_ddp_get_list_list =
16782 	TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
16783 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
16784 	TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
16785 
16786 static void
16787 cmd_ddp_get_list_parsed(
16788 	__attribute__((unused)) void *parsed_result,
16789 	__attribute__((unused)) struct cmdline *cl,
16790 	__attribute__((unused)) void *data)
16791 {
16792 #ifdef RTE_LIBRTE_I40E_PMD
16793 	struct cmd_ddp_get_list_result *res = parsed_result;
16794 	struct rte_pmd_i40e_profile_list *p_list;
16795 	struct rte_pmd_i40e_profile_info *p_info;
16796 	uint32_t p_num;
16797 	uint32_t size;
16798 	uint32_t i;
16799 #endif
16800 	int ret = -ENOTSUP;
16801 
16802 #ifdef RTE_LIBRTE_I40E_PMD
16803 	size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
16804 	p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
16805 	if (!p_list)
16806 		printf("%s: Failed to malloc buffer\n", __func__);
16807 
16808 	if (ret == -ENOTSUP)
16809 		ret = rte_pmd_i40e_get_ddp_list(res->port_id,
16810 						(uint8_t *)p_list, size);
16811 
16812 	if (!ret) {
16813 		p_num = p_list->p_count;
16814 		printf("Profile number is: %d\n\n", p_num);
16815 
16816 		for (i = 0; i < p_num; i++) {
16817 			p_info = &p_list->p_info[i];
16818 			printf("Profile %d:\n", i);
16819 			printf("Track id:     0x%x\n", p_info->track_id);
16820 			printf("Version:      %d.%d.%d.%d\n",
16821 			       p_info->version.major,
16822 			       p_info->version.minor,
16823 			       p_info->version.update,
16824 			       p_info->version.draft);
16825 			printf("Profile name: %s\n\n", p_info->name);
16826 		}
16827 	}
16828 
16829 	free(p_list);
16830 #endif
16831 
16832 	if (ret < 0)
16833 		printf("Failed to get ddp list\n");
16834 }
16835 
16836 cmdline_parse_inst_t cmd_ddp_get_list = {
16837 	.f = cmd_ddp_get_list_parsed,
16838 	.data = NULL,
16839 	.help_str = "ddp get list <port_id>",
16840 	.tokens = {
16841 		(void *)&cmd_ddp_get_list_ddp,
16842 		(void *)&cmd_ddp_get_list_get,
16843 		(void *)&cmd_ddp_get_list_list,
16844 		(void *)&cmd_ddp_get_list_port_id,
16845 		NULL,
16846 	},
16847 };
16848 
16849 /* Configure input set */
16850 struct cmd_cfg_input_set_result {
16851 	cmdline_fixed_string_t port;
16852 	cmdline_fixed_string_t cfg;
16853 	portid_t port_id;
16854 	cmdline_fixed_string_t pctype;
16855 	uint8_t pctype_id;
16856 	cmdline_fixed_string_t inset_type;
16857 	cmdline_fixed_string_t opt;
16858 	cmdline_fixed_string_t field;
16859 	uint8_t field_idx;
16860 };
16861 
16862 static void
16863 cmd_cfg_input_set_parsed(
16864 	__attribute__((unused)) void *parsed_result,
16865 	__attribute__((unused)) struct cmdline *cl,
16866 	__attribute__((unused)) void *data)
16867 {
16868 #ifdef RTE_LIBRTE_I40E_PMD
16869 	struct cmd_cfg_input_set_result *res = parsed_result;
16870 	enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
16871 	struct rte_pmd_i40e_inset inset;
16872 #endif
16873 	int ret = -ENOTSUP;
16874 
16875 	if (!all_ports_stopped()) {
16876 		printf("Please stop all ports first\n");
16877 		return;
16878 	}
16879 
16880 #ifdef RTE_LIBRTE_I40E_PMD
16881 	if (!strcmp(res->inset_type, "hash_inset"))
16882 		inset_type = INSET_HASH;
16883 	else if (!strcmp(res->inset_type, "fdir_inset"))
16884 		inset_type = INSET_FDIR;
16885 	else if (!strcmp(res->inset_type, "fdir_flx_inset"))
16886 		inset_type = INSET_FDIR_FLX;
16887 	ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
16888 				     &inset, inset_type);
16889 	if (ret) {
16890 		printf("Failed to get input set.\n");
16891 		return;
16892 	}
16893 
16894 	if (!strcmp(res->opt, "get")) {
16895 		ret = rte_pmd_i40e_inset_field_get(inset.inset,
16896 						   res->field_idx);
16897 		if (ret)
16898 			printf("Field index %d is enabled.\n", res->field_idx);
16899 		else
16900 			printf("Field index %d is disabled.\n", res->field_idx);
16901 		return;
16902 	} else if (!strcmp(res->opt, "set"))
16903 		ret = rte_pmd_i40e_inset_field_set(&inset.inset,
16904 						   res->field_idx);
16905 	else if (!strcmp(res->opt, "clear"))
16906 		ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
16907 						     res->field_idx);
16908 	if (ret) {
16909 		printf("Failed to configure input set field.\n");
16910 		return;
16911 	}
16912 
16913 	ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
16914 				     &inset, inset_type);
16915 	if (ret) {
16916 		printf("Failed to set input set.\n");
16917 		return;
16918 	}
16919 #endif
16920 
16921 	if (ret == -ENOTSUP)
16922 		printf("Function not supported\n");
16923 }
16924 
16925 cmdline_parse_token_string_t cmd_cfg_input_set_port =
16926 	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16927 				 port, "port");
16928 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
16929 	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16930 				 cfg, "config");
16931 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
16932 	TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16933 			      port_id, UINT16);
16934 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
16935 	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16936 				 pctype, "pctype");
16937 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
16938 	TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16939 			      pctype_id, UINT8);
16940 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
16941 	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16942 				 inset_type,
16943 				 "hash_inset#fdir_inset#fdir_flx_inset");
16944 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
16945 	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16946 				 opt, "get#set#clear");
16947 cmdline_parse_token_string_t cmd_cfg_input_set_field =
16948 	TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16949 				 field, "field");
16950 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
16951 	TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16952 			      field_idx, UINT8);
16953 
16954 cmdline_parse_inst_t cmd_cfg_input_set = {
16955 	.f = cmd_cfg_input_set_parsed,
16956 	.data = NULL,
16957 	.help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
16958 		    "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
16959 	.tokens = {
16960 		(void *)&cmd_cfg_input_set_port,
16961 		(void *)&cmd_cfg_input_set_cfg,
16962 		(void *)&cmd_cfg_input_set_port_id,
16963 		(void *)&cmd_cfg_input_set_pctype,
16964 		(void *)&cmd_cfg_input_set_pctype_id,
16965 		(void *)&cmd_cfg_input_set_inset_type,
16966 		(void *)&cmd_cfg_input_set_opt,
16967 		(void *)&cmd_cfg_input_set_field,
16968 		(void *)&cmd_cfg_input_set_field_idx,
16969 		NULL,
16970 	},
16971 };
16972 
16973 /* Clear input set */
16974 struct cmd_clear_input_set_result {
16975 	cmdline_fixed_string_t port;
16976 	cmdline_fixed_string_t cfg;
16977 	portid_t port_id;
16978 	cmdline_fixed_string_t pctype;
16979 	uint8_t pctype_id;
16980 	cmdline_fixed_string_t inset_type;
16981 	cmdline_fixed_string_t clear;
16982 	cmdline_fixed_string_t all;
16983 };
16984 
16985 static void
16986 cmd_clear_input_set_parsed(
16987 	__attribute__((unused)) void *parsed_result,
16988 	__attribute__((unused)) struct cmdline *cl,
16989 	__attribute__((unused)) void *data)
16990 {
16991 #ifdef RTE_LIBRTE_I40E_PMD
16992 	struct cmd_clear_input_set_result *res = parsed_result;
16993 	enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
16994 	struct rte_pmd_i40e_inset inset;
16995 #endif
16996 	int ret = -ENOTSUP;
16997 
16998 	if (!all_ports_stopped()) {
16999 		printf("Please stop all ports first\n");
17000 		return;
17001 	}
17002 
17003 #ifdef RTE_LIBRTE_I40E_PMD
17004 	if (!strcmp(res->inset_type, "hash_inset"))
17005 		inset_type = INSET_HASH;
17006 	else if (!strcmp(res->inset_type, "fdir_inset"))
17007 		inset_type = INSET_FDIR;
17008 	else if (!strcmp(res->inset_type, "fdir_flx_inset"))
17009 		inset_type = INSET_FDIR_FLX;
17010 
17011 	memset(&inset, 0, sizeof(inset));
17012 
17013 	ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
17014 				     &inset, inset_type);
17015 	if (ret) {
17016 		printf("Failed to clear input set.\n");
17017 		return;
17018 	}
17019 
17020 #endif
17021 
17022 	if (ret == -ENOTSUP)
17023 		printf("Function not supported\n");
17024 }
17025 
17026 cmdline_parse_token_string_t cmd_clear_input_set_port =
17027 	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17028 				 port, "port");
17029 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
17030 	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17031 				 cfg, "config");
17032 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
17033 	TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
17034 			      port_id, UINT16);
17035 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
17036 	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17037 				 pctype, "pctype");
17038 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
17039 	TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
17040 			      pctype_id, UINT8);
17041 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
17042 	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17043 				 inset_type,
17044 				 "hash_inset#fdir_inset#fdir_flx_inset");
17045 cmdline_parse_token_string_t cmd_clear_input_set_clear =
17046 	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17047 				 clear, "clear");
17048 cmdline_parse_token_string_t cmd_clear_input_set_all =
17049 	TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17050 				 all, "all");
17051 
17052 cmdline_parse_inst_t cmd_clear_input_set = {
17053 	.f = cmd_clear_input_set_parsed,
17054 	.data = NULL,
17055 	.help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
17056 		    "fdir_inset|fdir_flx_inset clear all",
17057 	.tokens = {
17058 		(void *)&cmd_clear_input_set_port,
17059 		(void *)&cmd_clear_input_set_cfg,
17060 		(void *)&cmd_clear_input_set_port_id,
17061 		(void *)&cmd_clear_input_set_pctype,
17062 		(void *)&cmd_clear_input_set_pctype_id,
17063 		(void *)&cmd_clear_input_set_inset_type,
17064 		(void *)&cmd_clear_input_set_clear,
17065 		(void *)&cmd_clear_input_set_all,
17066 		NULL,
17067 	},
17068 };
17069 
17070 /* show vf stats */
17071 
17072 /* Common result structure for show vf stats */
17073 struct cmd_show_vf_stats_result {
17074 	cmdline_fixed_string_t show;
17075 	cmdline_fixed_string_t vf;
17076 	cmdline_fixed_string_t stats;
17077 	portid_t port_id;
17078 	uint16_t vf_id;
17079 };
17080 
17081 /* Common CLI fields show vf stats*/
17082 cmdline_parse_token_string_t cmd_show_vf_stats_show =
17083 	TOKEN_STRING_INITIALIZER
17084 		(struct cmd_show_vf_stats_result,
17085 		 show, "show");
17086 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
17087 	TOKEN_STRING_INITIALIZER
17088 		(struct cmd_show_vf_stats_result,
17089 		 vf, "vf");
17090 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
17091 	TOKEN_STRING_INITIALIZER
17092 		(struct cmd_show_vf_stats_result,
17093 		 stats, "stats");
17094 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
17095 	TOKEN_NUM_INITIALIZER
17096 		(struct cmd_show_vf_stats_result,
17097 		 port_id, UINT16);
17098 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
17099 	TOKEN_NUM_INITIALIZER
17100 		(struct cmd_show_vf_stats_result,
17101 		 vf_id, UINT16);
17102 
17103 static void
17104 cmd_show_vf_stats_parsed(
17105 	void *parsed_result,
17106 	__attribute__((unused)) struct cmdline *cl,
17107 	__attribute__((unused)) void *data)
17108 {
17109 	struct cmd_show_vf_stats_result *res = parsed_result;
17110 	struct rte_eth_stats stats;
17111 	int ret = -ENOTSUP;
17112 	static const char *nic_stats_border = "########################";
17113 
17114 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17115 		return;
17116 
17117 	memset(&stats, 0, sizeof(stats));
17118 
17119 #ifdef RTE_LIBRTE_I40E_PMD
17120 	if (ret == -ENOTSUP)
17121 		ret = rte_pmd_i40e_get_vf_stats(res->port_id,
17122 						res->vf_id,
17123 						&stats);
17124 #endif
17125 #ifdef RTE_LIBRTE_BNXT_PMD
17126 	if (ret == -ENOTSUP)
17127 		ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
17128 						res->vf_id,
17129 						&stats);
17130 #endif
17131 
17132 	switch (ret) {
17133 	case 0:
17134 		break;
17135 	case -EINVAL:
17136 		printf("invalid vf_id %d\n", res->vf_id);
17137 		break;
17138 	case -ENODEV:
17139 		printf("invalid port_id %d\n", res->port_id);
17140 		break;
17141 	case -ENOTSUP:
17142 		printf("function not implemented\n");
17143 		break;
17144 	default:
17145 		printf("programming error: (%s)\n", strerror(-ret));
17146 	}
17147 
17148 	printf("\n  %s NIC statistics for port %-2d vf %-2d %s\n",
17149 		nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
17150 
17151 	printf("  RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes:  "
17152 	       "%-"PRIu64"\n",
17153 	       stats.ipackets, stats.imissed, stats.ibytes);
17154 	printf("  RX-errors: %-"PRIu64"\n", stats.ierrors);
17155 	printf("  RX-nombuf:  %-10"PRIu64"\n",
17156 	       stats.rx_nombuf);
17157 	printf("  TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes:  "
17158 	       "%-"PRIu64"\n",
17159 	       stats.opackets, stats.oerrors, stats.obytes);
17160 
17161 	printf("  %s############################%s\n",
17162 			       nic_stats_border, nic_stats_border);
17163 }
17164 
17165 cmdline_parse_inst_t cmd_show_vf_stats = {
17166 	.f = cmd_show_vf_stats_parsed,
17167 	.data = NULL,
17168 	.help_str = "show vf stats <port_id> <vf_id>",
17169 	.tokens = {
17170 		(void *)&cmd_show_vf_stats_show,
17171 		(void *)&cmd_show_vf_stats_vf,
17172 		(void *)&cmd_show_vf_stats_stats,
17173 		(void *)&cmd_show_vf_stats_port_id,
17174 		(void *)&cmd_show_vf_stats_vf_id,
17175 		NULL,
17176 	},
17177 };
17178 
17179 /* clear vf stats */
17180 
17181 /* Common result structure for clear vf stats */
17182 struct cmd_clear_vf_stats_result {
17183 	cmdline_fixed_string_t clear;
17184 	cmdline_fixed_string_t vf;
17185 	cmdline_fixed_string_t stats;
17186 	portid_t port_id;
17187 	uint16_t vf_id;
17188 };
17189 
17190 /* Common CLI fields clear vf stats*/
17191 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
17192 	TOKEN_STRING_INITIALIZER
17193 		(struct cmd_clear_vf_stats_result,
17194 		 clear, "clear");
17195 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
17196 	TOKEN_STRING_INITIALIZER
17197 		(struct cmd_clear_vf_stats_result,
17198 		 vf, "vf");
17199 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
17200 	TOKEN_STRING_INITIALIZER
17201 		(struct cmd_clear_vf_stats_result,
17202 		 stats, "stats");
17203 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
17204 	TOKEN_NUM_INITIALIZER
17205 		(struct cmd_clear_vf_stats_result,
17206 		 port_id, UINT16);
17207 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
17208 	TOKEN_NUM_INITIALIZER
17209 		(struct cmd_clear_vf_stats_result,
17210 		 vf_id, UINT16);
17211 
17212 static void
17213 cmd_clear_vf_stats_parsed(
17214 	void *parsed_result,
17215 	__attribute__((unused)) struct cmdline *cl,
17216 	__attribute__((unused)) void *data)
17217 {
17218 	struct cmd_clear_vf_stats_result *res = parsed_result;
17219 	int ret = -ENOTSUP;
17220 
17221 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17222 		return;
17223 
17224 #ifdef RTE_LIBRTE_I40E_PMD
17225 	if (ret == -ENOTSUP)
17226 		ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
17227 						  res->vf_id);
17228 #endif
17229 #ifdef RTE_LIBRTE_BNXT_PMD
17230 	if (ret == -ENOTSUP)
17231 		ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
17232 						  res->vf_id);
17233 #endif
17234 
17235 	switch (ret) {
17236 	case 0:
17237 		break;
17238 	case -EINVAL:
17239 		printf("invalid vf_id %d\n", res->vf_id);
17240 		break;
17241 	case -ENODEV:
17242 		printf("invalid port_id %d\n", res->port_id);
17243 		break;
17244 	case -ENOTSUP:
17245 		printf("function not implemented\n");
17246 		break;
17247 	default:
17248 		printf("programming error: (%s)\n", strerror(-ret));
17249 	}
17250 }
17251 
17252 cmdline_parse_inst_t cmd_clear_vf_stats = {
17253 	.f = cmd_clear_vf_stats_parsed,
17254 	.data = NULL,
17255 	.help_str = "clear vf stats <port_id> <vf_id>",
17256 	.tokens = {
17257 		(void *)&cmd_clear_vf_stats_clear,
17258 		(void *)&cmd_clear_vf_stats_vf,
17259 		(void *)&cmd_clear_vf_stats_stats,
17260 		(void *)&cmd_clear_vf_stats_port_id,
17261 		(void *)&cmd_clear_vf_stats_vf_id,
17262 		NULL,
17263 	},
17264 };
17265 
17266 /* port config pctype mapping reset */
17267 
17268 /* Common result structure for port config pctype mapping reset */
17269 struct cmd_pctype_mapping_reset_result {
17270 	cmdline_fixed_string_t port;
17271 	cmdline_fixed_string_t config;
17272 	portid_t port_id;
17273 	cmdline_fixed_string_t pctype;
17274 	cmdline_fixed_string_t mapping;
17275 	cmdline_fixed_string_t reset;
17276 };
17277 
17278 /* Common CLI fields for port config pctype mapping reset*/
17279 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
17280 	TOKEN_STRING_INITIALIZER
17281 		(struct cmd_pctype_mapping_reset_result,
17282 		 port, "port");
17283 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
17284 	TOKEN_STRING_INITIALIZER
17285 		(struct cmd_pctype_mapping_reset_result,
17286 		 config, "config");
17287 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
17288 	TOKEN_NUM_INITIALIZER
17289 		(struct cmd_pctype_mapping_reset_result,
17290 		 port_id, UINT16);
17291 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
17292 	TOKEN_STRING_INITIALIZER
17293 		(struct cmd_pctype_mapping_reset_result,
17294 		 pctype, "pctype");
17295 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
17296 	TOKEN_STRING_INITIALIZER
17297 		(struct cmd_pctype_mapping_reset_result,
17298 		 mapping, "mapping");
17299 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
17300 	TOKEN_STRING_INITIALIZER
17301 		(struct cmd_pctype_mapping_reset_result,
17302 		 reset, "reset");
17303 
17304 static void
17305 cmd_pctype_mapping_reset_parsed(
17306 	void *parsed_result,
17307 	__attribute__((unused)) struct cmdline *cl,
17308 	__attribute__((unused)) void *data)
17309 {
17310 	struct cmd_pctype_mapping_reset_result *res = parsed_result;
17311 	int ret = -ENOTSUP;
17312 
17313 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17314 		return;
17315 
17316 #ifdef RTE_LIBRTE_I40E_PMD
17317 	ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
17318 #endif
17319 
17320 	switch (ret) {
17321 	case 0:
17322 		break;
17323 	case -ENODEV:
17324 		printf("invalid port_id %d\n", res->port_id);
17325 		break;
17326 	case -ENOTSUP:
17327 		printf("function not implemented\n");
17328 		break;
17329 	default:
17330 		printf("programming error: (%s)\n", strerror(-ret));
17331 	}
17332 }
17333 
17334 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
17335 	.f = cmd_pctype_mapping_reset_parsed,
17336 	.data = NULL,
17337 	.help_str = "port config <port_id> pctype mapping reset",
17338 	.tokens = {
17339 		(void *)&cmd_pctype_mapping_reset_port,
17340 		(void *)&cmd_pctype_mapping_reset_config,
17341 		(void *)&cmd_pctype_mapping_reset_port_id,
17342 		(void *)&cmd_pctype_mapping_reset_pctype,
17343 		(void *)&cmd_pctype_mapping_reset_mapping,
17344 		(void *)&cmd_pctype_mapping_reset_reset,
17345 		NULL,
17346 	},
17347 };
17348 
17349 /* show port pctype mapping */
17350 
17351 /* Common result structure for show port pctype mapping */
17352 struct cmd_pctype_mapping_get_result {
17353 	cmdline_fixed_string_t show;
17354 	cmdline_fixed_string_t port;
17355 	portid_t port_id;
17356 	cmdline_fixed_string_t pctype;
17357 	cmdline_fixed_string_t mapping;
17358 };
17359 
17360 /* Common CLI fields for pctype mapping get */
17361 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
17362 	TOKEN_STRING_INITIALIZER
17363 		(struct cmd_pctype_mapping_get_result,
17364 		 show, "show");
17365 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
17366 	TOKEN_STRING_INITIALIZER
17367 		(struct cmd_pctype_mapping_get_result,
17368 		 port, "port");
17369 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
17370 	TOKEN_NUM_INITIALIZER
17371 		(struct cmd_pctype_mapping_get_result,
17372 		 port_id, UINT16);
17373 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
17374 	TOKEN_STRING_INITIALIZER
17375 		(struct cmd_pctype_mapping_get_result,
17376 		 pctype, "pctype");
17377 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
17378 	TOKEN_STRING_INITIALIZER
17379 		(struct cmd_pctype_mapping_get_result,
17380 		 mapping, "mapping");
17381 
17382 static void
17383 cmd_pctype_mapping_get_parsed(
17384 	void *parsed_result,
17385 	__attribute__((unused)) struct cmdline *cl,
17386 	__attribute__((unused)) void *data)
17387 {
17388 	struct cmd_pctype_mapping_get_result *res = parsed_result;
17389 	int ret = -ENOTSUP;
17390 #ifdef RTE_LIBRTE_I40E_PMD
17391 	struct rte_pmd_i40e_flow_type_mapping
17392 				mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
17393 	int i, j, first_pctype;
17394 #endif
17395 
17396 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17397 		return;
17398 
17399 #ifdef RTE_LIBRTE_I40E_PMD
17400 	ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
17401 #endif
17402 
17403 	switch (ret) {
17404 	case 0:
17405 		break;
17406 	case -ENODEV:
17407 		printf("invalid port_id %d\n", res->port_id);
17408 		return;
17409 	case -ENOTSUP:
17410 		printf("function not implemented\n");
17411 		return;
17412 	default:
17413 		printf("programming error: (%s)\n", strerror(-ret));
17414 		return;
17415 	}
17416 
17417 #ifdef RTE_LIBRTE_I40E_PMD
17418 	for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
17419 		if (mapping[i].pctype != 0ULL) {
17420 			first_pctype = 1;
17421 
17422 			printf("pctype: ");
17423 			for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
17424 				if (mapping[i].pctype & (1ULL << j)) {
17425 					printf(first_pctype ?
17426 					       "%02d" : ",%02d", j);
17427 					first_pctype = 0;
17428 				}
17429 			}
17430 			printf("  ->  flowtype: %02d\n", mapping[i].flow_type);
17431 		}
17432 	}
17433 #endif
17434 }
17435 
17436 cmdline_parse_inst_t cmd_pctype_mapping_get = {
17437 	.f = cmd_pctype_mapping_get_parsed,
17438 	.data = NULL,
17439 	.help_str = "show port <port_id> pctype mapping",
17440 	.tokens = {
17441 		(void *)&cmd_pctype_mapping_get_show,
17442 		(void *)&cmd_pctype_mapping_get_port,
17443 		(void *)&cmd_pctype_mapping_get_port_id,
17444 		(void *)&cmd_pctype_mapping_get_pctype,
17445 		(void *)&cmd_pctype_mapping_get_mapping,
17446 		NULL,
17447 	},
17448 };
17449 
17450 /* port config pctype mapping update */
17451 
17452 /* Common result structure for port config pctype mapping update */
17453 struct cmd_pctype_mapping_update_result {
17454 	cmdline_fixed_string_t port;
17455 	cmdline_fixed_string_t config;
17456 	portid_t port_id;
17457 	cmdline_fixed_string_t pctype;
17458 	cmdline_fixed_string_t mapping;
17459 	cmdline_fixed_string_t update;
17460 	cmdline_fixed_string_t pctype_list;
17461 	uint16_t flow_type;
17462 };
17463 
17464 /* Common CLI fields for pctype mapping update*/
17465 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
17466 	TOKEN_STRING_INITIALIZER
17467 		(struct cmd_pctype_mapping_update_result,
17468 		 port, "port");
17469 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
17470 	TOKEN_STRING_INITIALIZER
17471 		(struct cmd_pctype_mapping_update_result,
17472 		 config, "config");
17473 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
17474 	TOKEN_NUM_INITIALIZER
17475 		(struct cmd_pctype_mapping_update_result,
17476 		 port_id, UINT16);
17477 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
17478 	TOKEN_STRING_INITIALIZER
17479 		(struct cmd_pctype_mapping_update_result,
17480 		 pctype, "pctype");
17481 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
17482 	TOKEN_STRING_INITIALIZER
17483 		(struct cmd_pctype_mapping_update_result,
17484 		 mapping, "mapping");
17485 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
17486 	TOKEN_STRING_INITIALIZER
17487 		(struct cmd_pctype_mapping_update_result,
17488 		 update, "update");
17489 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
17490 	TOKEN_STRING_INITIALIZER
17491 		(struct cmd_pctype_mapping_update_result,
17492 		 pctype_list, NULL);
17493 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
17494 	TOKEN_NUM_INITIALIZER
17495 		(struct cmd_pctype_mapping_update_result,
17496 		 flow_type, UINT16);
17497 
17498 static void
17499 cmd_pctype_mapping_update_parsed(
17500 	void *parsed_result,
17501 	__attribute__((unused)) struct cmdline *cl,
17502 	__attribute__((unused)) void *data)
17503 {
17504 	struct cmd_pctype_mapping_update_result *res = parsed_result;
17505 	int ret = -ENOTSUP;
17506 #ifdef RTE_LIBRTE_I40E_PMD
17507 	struct rte_pmd_i40e_flow_type_mapping mapping;
17508 	unsigned int i;
17509 	unsigned int nb_item;
17510 	unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
17511 #endif
17512 
17513 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17514 		return;
17515 
17516 #ifdef RTE_LIBRTE_I40E_PMD
17517 	nb_item = parse_item_list(res->pctype_list, "pctypes",
17518 				  RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
17519 	mapping.flow_type = res->flow_type;
17520 	for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
17521 		mapping.pctype |= (1ULL << pctype_list[i]);
17522 	ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
17523 						&mapping,
17524 						1,
17525 						0);
17526 #endif
17527 
17528 	switch (ret) {
17529 	case 0:
17530 		break;
17531 	case -EINVAL:
17532 		printf("invalid pctype or flow type\n");
17533 		break;
17534 	case -ENODEV:
17535 		printf("invalid port_id %d\n", res->port_id);
17536 		break;
17537 	case -ENOTSUP:
17538 		printf("function not implemented\n");
17539 		break;
17540 	default:
17541 		printf("programming error: (%s)\n", strerror(-ret));
17542 	}
17543 }
17544 
17545 cmdline_parse_inst_t cmd_pctype_mapping_update = {
17546 	.f = cmd_pctype_mapping_update_parsed,
17547 	.data = NULL,
17548 	.help_str = "port config <port_id> pctype mapping update"
17549 	" <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
17550 	.tokens = {
17551 		(void *)&cmd_pctype_mapping_update_port,
17552 		(void *)&cmd_pctype_mapping_update_config,
17553 		(void *)&cmd_pctype_mapping_update_port_id,
17554 		(void *)&cmd_pctype_mapping_update_pctype,
17555 		(void *)&cmd_pctype_mapping_update_mapping,
17556 		(void *)&cmd_pctype_mapping_update_update,
17557 		(void *)&cmd_pctype_mapping_update_pc_type,
17558 		(void *)&cmd_pctype_mapping_update_flow_type,
17559 		NULL,
17560 	},
17561 };
17562 
17563 /* ptype mapping get */
17564 
17565 /* Common result structure for ptype mapping get */
17566 struct cmd_ptype_mapping_get_result {
17567 	cmdline_fixed_string_t ptype;
17568 	cmdline_fixed_string_t mapping;
17569 	cmdline_fixed_string_t get;
17570 	portid_t port_id;
17571 	uint8_t valid_only;
17572 };
17573 
17574 /* Common CLI fields for ptype mapping get */
17575 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
17576 	TOKEN_STRING_INITIALIZER
17577 		(struct cmd_ptype_mapping_get_result,
17578 		 ptype, "ptype");
17579 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
17580 	TOKEN_STRING_INITIALIZER
17581 		(struct cmd_ptype_mapping_get_result,
17582 		 mapping, "mapping");
17583 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
17584 	TOKEN_STRING_INITIALIZER
17585 		(struct cmd_ptype_mapping_get_result,
17586 		 get, "get");
17587 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
17588 	TOKEN_NUM_INITIALIZER
17589 		(struct cmd_ptype_mapping_get_result,
17590 		 port_id, UINT16);
17591 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
17592 	TOKEN_NUM_INITIALIZER
17593 		(struct cmd_ptype_mapping_get_result,
17594 		 valid_only, UINT8);
17595 
17596 static void
17597 cmd_ptype_mapping_get_parsed(
17598 	void *parsed_result,
17599 	__attribute__((unused)) struct cmdline *cl,
17600 	__attribute__((unused)) void *data)
17601 {
17602 	struct cmd_ptype_mapping_get_result *res = parsed_result;
17603 	int ret = -ENOTSUP;
17604 #ifdef RTE_LIBRTE_I40E_PMD
17605 	int max_ptype_num = 256;
17606 	struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
17607 	uint16_t count;
17608 	int i;
17609 #endif
17610 
17611 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17612 		return;
17613 
17614 #ifdef RTE_LIBRTE_I40E_PMD
17615 	ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
17616 					mapping,
17617 					max_ptype_num,
17618 					&count,
17619 					res->valid_only);
17620 #endif
17621 
17622 	switch (ret) {
17623 	case 0:
17624 		break;
17625 	case -ENODEV:
17626 		printf("invalid port_id %d\n", res->port_id);
17627 		break;
17628 	case -ENOTSUP:
17629 		printf("function not implemented\n");
17630 		break;
17631 	default:
17632 		printf("programming error: (%s)\n", strerror(-ret));
17633 	}
17634 
17635 #ifdef RTE_LIBRTE_I40E_PMD
17636 	if (!ret) {
17637 		for (i = 0; i < count; i++)
17638 			printf("%3d\t0x%08x\n",
17639 				mapping[i].hw_ptype, mapping[i].sw_ptype);
17640 	}
17641 #endif
17642 }
17643 
17644 cmdline_parse_inst_t cmd_ptype_mapping_get = {
17645 	.f = cmd_ptype_mapping_get_parsed,
17646 	.data = NULL,
17647 	.help_str = "ptype mapping get <port_id> <valid_only>",
17648 	.tokens = {
17649 		(void *)&cmd_ptype_mapping_get_ptype,
17650 		(void *)&cmd_ptype_mapping_get_mapping,
17651 		(void *)&cmd_ptype_mapping_get_get,
17652 		(void *)&cmd_ptype_mapping_get_port_id,
17653 		(void *)&cmd_ptype_mapping_get_valid_only,
17654 		NULL,
17655 	},
17656 };
17657 
17658 /* ptype mapping replace */
17659 
17660 /* Common result structure for ptype mapping replace */
17661 struct cmd_ptype_mapping_replace_result {
17662 	cmdline_fixed_string_t ptype;
17663 	cmdline_fixed_string_t mapping;
17664 	cmdline_fixed_string_t replace;
17665 	portid_t port_id;
17666 	uint32_t target;
17667 	uint8_t mask;
17668 	uint32_t pkt_type;
17669 };
17670 
17671 /* Common CLI fields for ptype mapping replace */
17672 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
17673 	TOKEN_STRING_INITIALIZER
17674 		(struct cmd_ptype_mapping_replace_result,
17675 		 ptype, "ptype");
17676 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
17677 	TOKEN_STRING_INITIALIZER
17678 		(struct cmd_ptype_mapping_replace_result,
17679 		 mapping, "mapping");
17680 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
17681 	TOKEN_STRING_INITIALIZER
17682 		(struct cmd_ptype_mapping_replace_result,
17683 		 replace, "replace");
17684 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
17685 	TOKEN_NUM_INITIALIZER
17686 		(struct cmd_ptype_mapping_replace_result,
17687 		 port_id, UINT16);
17688 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
17689 	TOKEN_NUM_INITIALIZER
17690 		(struct cmd_ptype_mapping_replace_result,
17691 		 target, UINT32);
17692 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
17693 	TOKEN_NUM_INITIALIZER
17694 		(struct cmd_ptype_mapping_replace_result,
17695 		 mask, UINT8);
17696 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
17697 	TOKEN_NUM_INITIALIZER
17698 		(struct cmd_ptype_mapping_replace_result,
17699 		 pkt_type, UINT32);
17700 
17701 static void
17702 cmd_ptype_mapping_replace_parsed(
17703 	void *parsed_result,
17704 	__attribute__((unused)) struct cmdline *cl,
17705 	__attribute__((unused)) void *data)
17706 {
17707 	struct cmd_ptype_mapping_replace_result *res = parsed_result;
17708 	int ret = -ENOTSUP;
17709 
17710 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17711 		return;
17712 
17713 #ifdef RTE_LIBRTE_I40E_PMD
17714 	ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
17715 					res->target,
17716 					res->mask,
17717 					res->pkt_type);
17718 #endif
17719 
17720 	switch (ret) {
17721 	case 0:
17722 		break;
17723 	case -EINVAL:
17724 		printf("invalid ptype 0x%8x or 0x%8x\n",
17725 				res->target, res->pkt_type);
17726 		break;
17727 	case -ENODEV:
17728 		printf("invalid port_id %d\n", res->port_id);
17729 		break;
17730 	case -ENOTSUP:
17731 		printf("function not implemented\n");
17732 		break;
17733 	default:
17734 		printf("programming error: (%s)\n", strerror(-ret));
17735 	}
17736 }
17737 
17738 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
17739 	.f = cmd_ptype_mapping_replace_parsed,
17740 	.data = NULL,
17741 	.help_str =
17742 		"ptype mapping replace <port_id> <target> <mask> <pkt_type>",
17743 	.tokens = {
17744 		(void *)&cmd_ptype_mapping_replace_ptype,
17745 		(void *)&cmd_ptype_mapping_replace_mapping,
17746 		(void *)&cmd_ptype_mapping_replace_replace,
17747 		(void *)&cmd_ptype_mapping_replace_port_id,
17748 		(void *)&cmd_ptype_mapping_replace_target,
17749 		(void *)&cmd_ptype_mapping_replace_mask,
17750 		(void *)&cmd_ptype_mapping_replace_pkt_type,
17751 		NULL,
17752 	},
17753 };
17754 
17755 /* ptype mapping reset */
17756 
17757 /* Common result structure for ptype mapping reset */
17758 struct cmd_ptype_mapping_reset_result {
17759 	cmdline_fixed_string_t ptype;
17760 	cmdline_fixed_string_t mapping;
17761 	cmdline_fixed_string_t reset;
17762 	portid_t port_id;
17763 };
17764 
17765 /* Common CLI fields for ptype mapping reset*/
17766 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
17767 	TOKEN_STRING_INITIALIZER
17768 		(struct cmd_ptype_mapping_reset_result,
17769 		 ptype, "ptype");
17770 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
17771 	TOKEN_STRING_INITIALIZER
17772 		(struct cmd_ptype_mapping_reset_result,
17773 		 mapping, "mapping");
17774 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
17775 	TOKEN_STRING_INITIALIZER
17776 		(struct cmd_ptype_mapping_reset_result,
17777 		 reset, "reset");
17778 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
17779 	TOKEN_NUM_INITIALIZER
17780 		(struct cmd_ptype_mapping_reset_result,
17781 		 port_id, UINT16);
17782 
17783 static void
17784 cmd_ptype_mapping_reset_parsed(
17785 	void *parsed_result,
17786 	__attribute__((unused)) struct cmdline *cl,
17787 	__attribute__((unused)) void *data)
17788 {
17789 	struct cmd_ptype_mapping_reset_result *res = parsed_result;
17790 	int ret = -ENOTSUP;
17791 
17792 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17793 		return;
17794 
17795 #ifdef RTE_LIBRTE_I40E_PMD
17796 	ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
17797 #endif
17798 
17799 	switch (ret) {
17800 	case 0:
17801 		break;
17802 	case -ENODEV:
17803 		printf("invalid port_id %d\n", res->port_id);
17804 		break;
17805 	case -ENOTSUP:
17806 		printf("function not implemented\n");
17807 		break;
17808 	default:
17809 		printf("programming error: (%s)\n", strerror(-ret));
17810 	}
17811 }
17812 
17813 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
17814 	.f = cmd_ptype_mapping_reset_parsed,
17815 	.data = NULL,
17816 	.help_str = "ptype mapping reset <port_id>",
17817 	.tokens = {
17818 		(void *)&cmd_ptype_mapping_reset_ptype,
17819 		(void *)&cmd_ptype_mapping_reset_mapping,
17820 		(void *)&cmd_ptype_mapping_reset_reset,
17821 		(void *)&cmd_ptype_mapping_reset_port_id,
17822 		NULL,
17823 	},
17824 };
17825 
17826 /* ptype mapping update */
17827 
17828 /* Common result structure for ptype mapping update */
17829 struct cmd_ptype_mapping_update_result {
17830 	cmdline_fixed_string_t ptype;
17831 	cmdline_fixed_string_t mapping;
17832 	cmdline_fixed_string_t reset;
17833 	portid_t port_id;
17834 	uint8_t hw_ptype;
17835 	uint32_t sw_ptype;
17836 };
17837 
17838 /* Common CLI fields for ptype mapping update*/
17839 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
17840 	TOKEN_STRING_INITIALIZER
17841 		(struct cmd_ptype_mapping_update_result,
17842 		 ptype, "ptype");
17843 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
17844 	TOKEN_STRING_INITIALIZER
17845 		(struct cmd_ptype_mapping_update_result,
17846 		 mapping, "mapping");
17847 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
17848 	TOKEN_STRING_INITIALIZER
17849 		(struct cmd_ptype_mapping_update_result,
17850 		 reset, "update");
17851 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
17852 	TOKEN_NUM_INITIALIZER
17853 		(struct cmd_ptype_mapping_update_result,
17854 		 port_id, UINT16);
17855 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
17856 	TOKEN_NUM_INITIALIZER
17857 		(struct cmd_ptype_mapping_update_result,
17858 		 hw_ptype, UINT8);
17859 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
17860 	TOKEN_NUM_INITIALIZER
17861 		(struct cmd_ptype_mapping_update_result,
17862 		 sw_ptype, UINT32);
17863 
17864 static void
17865 cmd_ptype_mapping_update_parsed(
17866 	void *parsed_result,
17867 	__attribute__((unused)) struct cmdline *cl,
17868 	__attribute__((unused)) void *data)
17869 {
17870 	struct cmd_ptype_mapping_update_result *res = parsed_result;
17871 	int ret = -ENOTSUP;
17872 #ifdef RTE_LIBRTE_I40E_PMD
17873 	struct rte_pmd_i40e_ptype_mapping mapping;
17874 #endif
17875 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17876 		return;
17877 
17878 #ifdef RTE_LIBRTE_I40E_PMD
17879 	mapping.hw_ptype = res->hw_ptype;
17880 	mapping.sw_ptype = res->sw_ptype;
17881 	ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
17882 						&mapping,
17883 						1,
17884 						0);
17885 #endif
17886 
17887 	switch (ret) {
17888 	case 0:
17889 		break;
17890 	case -EINVAL:
17891 		printf("invalid ptype 0x%8x\n", res->sw_ptype);
17892 		break;
17893 	case -ENODEV:
17894 		printf("invalid port_id %d\n", res->port_id);
17895 		break;
17896 	case -ENOTSUP:
17897 		printf("function not implemented\n");
17898 		break;
17899 	default:
17900 		printf("programming error: (%s)\n", strerror(-ret));
17901 	}
17902 }
17903 
17904 cmdline_parse_inst_t cmd_ptype_mapping_update = {
17905 	.f = cmd_ptype_mapping_update_parsed,
17906 	.data = NULL,
17907 	.help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
17908 	.tokens = {
17909 		(void *)&cmd_ptype_mapping_update_ptype,
17910 		(void *)&cmd_ptype_mapping_update_mapping,
17911 		(void *)&cmd_ptype_mapping_update_update,
17912 		(void *)&cmd_ptype_mapping_update_port_id,
17913 		(void *)&cmd_ptype_mapping_update_hw_ptype,
17914 		(void *)&cmd_ptype_mapping_update_sw_ptype,
17915 		NULL,
17916 	},
17917 };
17918 
17919 /* Common result structure for file commands */
17920 struct cmd_cmdfile_result {
17921 	cmdline_fixed_string_t load;
17922 	cmdline_fixed_string_t filename;
17923 };
17924 
17925 /* Common CLI fields for file commands */
17926 cmdline_parse_token_string_t cmd_load_cmdfile =
17927 	TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
17928 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
17929 	TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
17930 
17931 static void
17932 cmd_load_from_file_parsed(
17933 	void *parsed_result,
17934 	__attribute__((unused)) struct cmdline *cl,
17935 	__attribute__((unused)) void *data)
17936 {
17937 	struct cmd_cmdfile_result *res = parsed_result;
17938 
17939 	cmdline_read_from_file(res->filename);
17940 }
17941 
17942 cmdline_parse_inst_t cmd_load_from_file = {
17943 	.f = cmd_load_from_file_parsed,
17944 	.data = NULL,
17945 	.help_str = "load <filename>",
17946 	.tokens = {
17947 		(void *)&cmd_load_cmdfile,
17948 		(void *)&cmd_load_cmdfile_filename,
17949 		NULL,
17950 	},
17951 };
17952 
17953 /* Get Rx offloads capabilities */
17954 struct cmd_rx_offload_get_capa_result {
17955 	cmdline_fixed_string_t show;
17956 	cmdline_fixed_string_t port;
17957 	portid_t port_id;
17958 	cmdline_fixed_string_t rx_offload;
17959 	cmdline_fixed_string_t capabilities;
17960 };
17961 
17962 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
17963 	TOKEN_STRING_INITIALIZER
17964 		(struct cmd_rx_offload_get_capa_result,
17965 		 show, "show");
17966 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
17967 	TOKEN_STRING_INITIALIZER
17968 		(struct cmd_rx_offload_get_capa_result,
17969 		 port, "port");
17970 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
17971 	TOKEN_NUM_INITIALIZER
17972 		(struct cmd_rx_offload_get_capa_result,
17973 		 port_id, UINT16);
17974 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
17975 	TOKEN_STRING_INITIALIZER
17976 		(struct cmd_rx_offload_get_capa_result,
17977 		 rx_offload, "rx_offload");
17978 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
17979 	TOKEN_STRING_INITIALIZER
17980 		(struct cmd_rx_offload_get_capa_result,
17981 		 capabilities, "capabilities");
17982 
17983 static void
17984 print_rx_offloads(uint64_t offloads)
17985 {
17986 	uint64_t single_offload;
17987 	int begin;
17988 	int end;
17989 	int bit;
17990 
17991 	if (offloads == 0)
17992 		return;
17993 
17994 	begin = __builtin_ctzll(offloads);
17995 	end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
17996 
17997 	single_offload = 1ULL << begin;
17998 	for (bit = begin; bit < end; bit++) {
17999 		if (offloads & single_offload)
18000 			printf(" %s",
18001 			       rte_eth_dev_rx_offload_name(single_offload));
18002 		single_offload <<= 1;
18003 	}
18004 }
18005 
18006 static void
18007 cmd_rx_offload_get_capa_parsed(
18008 	void *parsed_result,
18009 	__attribute__((unused)) struct cmdline *cl,
18010 	__attribute__((unused)) void *data)
18011 {
18012 	struct cmd_rx_offload_get_capa_result *res = parsed_result;
18013 	struct rte_eth_dev_info dev_info;
18014 	portid_t port_id = res->port_id;
18015 	uint64_t queue_offloads;
18016 	uint64_t port_offloads;
18017 	int ret;
18018 
18019 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
18020 	if (ret != 0)
18021 		return;
18022 
18023 	queue_offloads = dev_info.rx_queue_offload_capa;
18024 	port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
18025 
18026 	printf("Rx Offloading Capabilities of port %d :\n", port_id);
18027 	printf("  Per Queue :");
18028 	print_rx_offloads(queue_offloads);
18029 
18030 	printf("\n");
18031 	printf("  Per Port  :");
18032 	print_rx_offloads(port_offloads);
18033 	printf("\n\n");
18034 }
18035 
18036 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
18037 	.f = cmd_rx_offload_get_capa_parsed,
18038 	.data = NULL,
18039 	.help_str = "show port <port_id> rx_offload capabilities",
18040 	.tokens = {
18041 		(void *)&cmd_rx_offload_get_capa_show,
18042 		(void *)&cmd_rx_offload_get_capa_port,
18043 		(void *)&cmd_rx_offload_get_capa_port_id,
18044 		(void *)&cmd_rx_offload_get_capa_rx_offload,
18045 		(void *)&cmd_rx_offload_get_capa_capabilities,
18046 		NULL,
18047 	}
18048 };
18049 
18050 /* Get Rx offloads configuration */
18051 struct cmd_rx_offload_get_configuration_result {
18052 	cmdline_fixed_string_t show;
18053 	cmdline_fixed_string_t port;
18054 	portid_t port_id;
18055 	cmdline_fixed_string_t rx_offload;
18056 	cmdline_fixed_string_t configuration;
18057 };
18058 
18059 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
18060 	TOKEN_STRING_INITIALIZER
18061 		(struct cmd_rx_offload_get_configuration_result,
18062 		 show, "show");
18063 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
18064 	TOKEN_STRING_INITIALIZER
18065 		(struct cmd_rx_offload_get_configuration_result,
18066 		 port, "port");
18067 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
18068 	TOKEN_NUM_INITIALIZER
18069 		(struct cmd_rx_offload_get_configuration_result,
18070 		 port_id, UINT16);
18071 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
18072 	TOKEN_STRING_INITIALIZER
18073 		(struct cmd_rx_offload_get_configuration_result,
18074 		 rx_offload, "rx_offload");
18075 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
18076 	TOKEN_STRING_INITIALIZER
18077 		(struct cmd_rx_offload_get_configuration_result,
18078 		 configuration, "configuration");
18079 
18080 static void
18081 cmd_rx_offload_get_configuration_parsed(
18082 	void *parsed_result,
18083 	__attribute__((unused)) struct cmdline *cl,
18084 	__attribute__((unused)) void *data)
18085 {
18086 	struct cmd_rx_offload_get_configuration_result *res = parsed_result;
18087 	struct rte_eth_dev_info dev_info;
18088 	portid_t port_id = res->port_id;
18089 	struct rte_port *port = &ports[port_id];
18090 	uint64_t port_offloads;
18091 	uint64_t queue_offloads;
18092 	uint16_t nb_rx_queues;
18093 	int q;
18094 	int ret;
18095 
18096 	printf("Rx Offloading Configuration of port %d :\n", port_id);
18097 
18098 	port_offloads = port->dev_conf.rxmode.offloads;
18099 	printf("  Port :");
18100 	print_rx_offloads(port_offloads);
18101 	printf("\n");
18102 
18103 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
18104 	if (ret != 0)
18105 		return;
18106 
18107 	nb_rx_queues = dev_info.nb_rx_queues;
18108 	for (q = 0; q < nb_rx_queues; q++) {
18109 		queue_offloads = port->rx_conf[q].offloads;
18110 		printf("  Queue[%2d] :", q);
18111 		print_rx_offloads(queue_offloads);
18112 		printf("\n");
18113 	}
18114 	printf("\n");
18115 }
18116 
18117 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
18118 	.f = cmd_rx_offload_get_configuration_parsed,
18119 	.data = NULL,
18120 	.help_str = "show port <port_id> rx_offload configuration",
18121 	.tokens = {
18122 		(void *)&cmd_rx_offload_get_configuration_show,
18123 		(void *)&cmd_rx_offload_get_configuration_port,
18124 		(void *)&cmd_rx_offload_get_configuration_port_id,
18125 		(void *)&cmd_rx_offload_get_configuration_rx_offload,
18126 		(void *)&cmd_rx_offload_get_configuration_configuration,
18127 		NULL,
18128 	}
18129 };
18130 
18131 /* Enable/Disable a per port offloading */
18132 struct cmd_config_per_port_rx_offload_result {
18133 	cmdline_fixed_string_t port;
18134 	cmdline_fixed_string_t config;
18135 	portid_t port_id;
18136 	cmdline_fixed_string_t rx_offload;
18137 	cmdline_fixed_string_t offload;
18138 	cmdline_fixed_string_t on_off;
18139 };
18140 
18141 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
18142 	TOKEN_STRING_INITIALIZER
18143 		(struct cmd_config_per_port_rx_offload_result,
18144 		 port, "port");
18145 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
18146 	TOKEN_STRING_INITIALIZER
18147 		(struct cmd_config_per_port_rx_offload_result,
18148 		 config, "config");
18149 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
18150 	TOKEN_NUM_INITIALIZER
18151 		(struct cmd_config_per_port_rx_offload_result,
18152 		 port_id, UINT16);
18153 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
18154 	TOKEN_STRING_INITIALIZER
18155 		(struct cmd_config_per_port_rx_offload_result,
18156 		 rx_offload, "rx_offload");
18157 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
18158 	TOKEN_STRING_INITIALIZER
18159 		(struct cmd_config_per_port_rx_offload_result,
18160 		 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
18161 			   "qinq_strip#outer_ipv4_cksum#macsec_strip#"
18162 			   "header_split#vlan_filter#vlan_extend#jumbo_frame#"
18163 			   "scatter#timestamp#security#keep_crc#rss_hash");
18164 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
18165 	TOKEN_STRING_INITIALIZER
18166 		(struct cmd_config_per_port_rx_offload_result,
18167 		 on_off, "on#off");
18168 
18169 static uint64_t
18170 search_rx_offload(const char *name)
18171 {
18172 	uint64_t single_offload;
18173 	const char *single_name;
18174 	int found = 0;
18175 	unsigned int bit;
18176 
18177 	single_offload = 1;
18178 	for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
18179 		single_name = rte_eth_dev_rx_offload_name(single_offload);
18180 		if (!strcasecmp(single_name, name)) {
18181 			found = 1;
18182 			break;
18183 		}
18184 		single_offload <<= 1;
18185 	}
18186 
18187 	if (found)
18188 		return single_offload;
18189 
18190 	return 0;
18191 }
18192 
18193 static void
18194 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
18195 				__attribute__((unused)) struct cmdline *cl,
18196 				__attribute__((unused)) void *data)
18197 {
18198 	struct cmd_config_per_port_rx_offload_result *res = parsed_result;
18199 	portid_t port_id = res->port_id;
18200 	struct rte_eth_dev_info dev_info;
18201 	struct rte_port *port = &ports[port_id];
18202 	uint64_t single_offload;
18203 	uint16_t nb_rx_queues;
18204 	int q;
18205 	int ret;
18206 
18207 	if (port->port_status != RTE_PORT_STOPPED) {
18208 		printf("Error: Can't config offload when Port %d "
18209 		       "is not stopped\n", port_id);
18210 		return;
18211 	}
18212 
18213 	single_offload = search_rx_offload(res->offload);
18214 	if (single_offload == 0) {
18215 		printf("Unknown offload name: %s\n", res->offload);
18216 		return;
18217 	}
18218 
18219 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
18220 	if (ret != 0)
18221 		return;
18222 
18223 	nb_rx_queues = dev_info.nb_rx_queues;
18224 	if (!strcmp(res->on_off, "on")) {
18225 		port->dev_conf.rxmode.offloads |= single_offload;
18226 		for (q = 0; q < nb_rx_queues; q++)
18227 			port->rx_conf[q].offloads |= single_offload;
18228 	} else {
18229 		port->dev_conf.rxmode.offloads &= ~single_offload;
18230 		for (q = 0; q < nb_rx_queues; q++)
18231 			port->rx_conf[q].offloads &= ~single_offload;
18232 	}
18233 
18234 	cmd_reconfig_device_queue(port_id, 1, 1);
18235 }
18236 
18237 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
18238 	.f = cmd_config_per_port_rx_offload_parsed,
18239 	.data = NULL,
18240 	.help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
18241 		    "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
18242 		    "macsec_strip|header_split|vlan_filter|vlan_extend|"
18243 		    "jumbo_frame|scatter|timestamp|security|keep_crc|rss_hash "
18244 		    "on|off",
18245 	.tokens = {
18246 		(void *)&cmd_config_per_port_rx_offload_result_port,
18247 		(void *)&cmd_config_per_port_rx_offload_result_config,
18248 		(void *)&cmd_config_per_port_rx_offload_result_port_id,
18249 		(void *)&cmd_config_per_port_rx_offload_result_rx_offload,
18250 		(void *)&cmd_config_per_port_rx_offload_result_offload,
18251 		(void *)&cmd_config_per_port_rx_offload_result_on_off,
18252 		NULL,
18253 	}
18254 };
18255 
18256 /* Enable/Disable a per queue offloading */
18257 struct cmd_config_per_queue_rx_offload_result {
18258 	cmdline_fixed_string_t port;
18259 	portid_t port_id;
18260 	cmdline_fixed_string_t rxq;
18261 	uint16_t queue_id;
18262 	cmdline_fixed_string_t rx_offload;
18263 	cmdline_fixed_string_t offload;
18264 	cmdline_fixed_string_t on_off;
18265 };
18266 
18267 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
18268 	TOKEN_STRING_INITIALIZER
18269 		(struct cmd_config_per_queue_rx_offload_result,
18270 		 port, "port");
18271 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
18272 	TOKEN_NUM_INITIALIZER
18273 		(struct cmd_config_per_queue_rx_offload_result,
18274 		 port_id, UINT16);
18275 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
18276 	TOKEN_STRING_INITIALIZER
18277 		(struct cmd_config_per_queue_rx_offload_result,
18278 		 rxq, "rxq");
18279 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
18280 	TOKEN_NUM_INITIALIZER
18281 		(struct cmd_config_per_queue_rx_offload_result,
18282 		 queue_id, UINT16);
18283 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
18284 	TOKEN_STRING_INITIALIZER
18285 		(struct cmd_config_per_queue_rx_offload_result,
18286 		 rx_offload, "rx_offload");
18287 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
18288 	TOKEN_STRING_INITIALIZER
18289 		(struct cmd_config_per_queue_rx_offload_result,
18290 		 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
18291 			   "qinq_strip#outer_ipv4_cksum#macsec_strip#"
18292 			   "header_split#vlan_filter#vlan_extend#jumbo_frame#"
18293 			   "scatter#timestamp#security#keep_crc");
18294 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
18295 	TOKEN_STRING_INITIALIZER
18296 		(struct cmd_config_per_queue_rx_offload_result,
18297 		 on_off, "on#off");
18298 
18299 static void
18300 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
18301 				__attribute__((unused)) struct cmdline *cl,
18302 				__attribute__((unused)) void *data)
18303 {
18304 	struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
18305 	struct rte_eth_dev_info dev_info;
18306 	portid_t port_id = res->port_id;
18307 	uint16_t queue_id = res->queue_id;
18308 	struct rte_port *port = &ports[port_id];
18309 	uint64_t single_offload;
18310 	int ret;
18311 
18312 	if (port->port_status != RTE_PORT_STOPPED) {
18313 		printf("Error: Can't config offload when Port %d "
18314 		       "is not stopped\n", port_id);
18315 		return;
18316 	}
18317 
18318 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
18319 	if (ret != 0)
18320 		return;
18321 
18322 	if (queue_id >= dev_info.nb_rx_queues) {
18323 		printf("Error: input queue_id should be 0 ... "
18324 		       "%d\n", dev_info.nb_rx_queues - 1);
18325 		return;
18326 	}
18327 
18328 	single_offload = search_rx_offload(res->offload);
18329 	if (single_offload == 0) {
18330 		printf("Unknown offload name: %s\n", res->offload);
18331 		return;
18332 	}
18333 
18334 	if (!strcmp(res->on_off, "on"))
18335 		port->rx_conf[queue_id].offloads |= single_offload;
18336 	else
18337 		port->rx_conf[queue_id].offloads &= ~single_offload;
18338 
18339 	cmd_reconfig_device_queue(port_id, 1, 1);
18340 }
18341 
18342 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
18343 	.f = cmd_config_per_queue_rx_offload_parsed,
18344 	.data = NULL,
18345 	.help_str = "port <port_id> rxq <queue_id> rx_offload "
18346 		    "vlan_strip|ipv4_cksum|"
18347 		    "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
18348 		    "macsec_strip|header_split|vlan_filter|vlan_extend|"
18349 		    "jumbo_frame|scatter|timestamp|security|keep_crc "
18350 		    "on|off",
18351 	.tokens = {
18352 		(void *)&cmd_config_per_queue_rx_offload_result_port,
18353 		(void *)&cmd_config_per_queue_rx_offload_result_port_id,
18354 		(void *)&cmd_config_per_queue_rx_offload_result_rxq,
18355 		(void *)&cmd_config_per_queue_rx_offload_result_queue_id,
18356 		(void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
18357 		(void *)&cmd_config_per_queue_rx_offload_result_offload,
18358 		(void *)&cmd_config_per_queue_rx_offload_result_on_off,
18359 		NULL,
18360 	}
18361 };
18362 
18363 /* Get Tx offloads capabilities */
18364 struct cmd_tx_offload_get_capa_result {
18365 	cmdline_fixed_string_t show;
18366 	cmdline_fixed_string_t port;
18367 	portid_t port_id;
18368 	cmdline_fixed_string_t tx_offload;
18369 	cmdline_fixed_string_t capabilities;
18370 };
18371 
18372 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
18373 	TOKEN_STRING_INITIALIZER
18374 		(struct cmd_tx_offload_get_capa_result,
18375 		 show, "show");
18376 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
18377 	TOKEN_STRING_INITIALIZER
18378 		(struct cmd_tx_offload_get_capa_result,
18379 		 port, "port");
18380 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
18381 	TOKEN_NUM_INITIALIZER
18382 		(struct cmd_tx_offload_get_capa_result,
18383 		 port_id, UINT16);
18384 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
18385 	TOKEN_STRING_INITIALIZER
18386 		(struct cmd_tx_offload_get_capa_result,
18387 		 tx_offload, "tx_offload");
18388 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
18389 	TOKEN_STRING_INITIALIZER
18390 		(struct cmd_tx_offload_get_capa_result,
18391 		 capabilities, "capabilities");
18392 
18393 static void
18394 print_tx_offloads(uint64_t offloads)
18395 {
18396 	uint64_t single_offload;
18397 	int begin;
18398 	int end;
18399 	int bit;
18400 
18401 	if (offloads == 0)
18402 		return;
18403 
18404 	begin = __builtin_ctzll(offloads);
18405 	end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
18406 
18407 	single_offload = 1ULL << begin;
18408 	for (bit = begin; bit < end; bit++) {
18409 		if (offloads & single_offload)
18410 			printf(" %s",
18411 			       rte_eth_dev_tx_offload_name(single_offload));
18412 		single_offload <<= 1;
18413 	}
18414 }
18415 
18416 static void
18417 cmd_tx_offload_get_capa_parsed(
18418 	void *parsed_result,
18419 	__attribute__((unused)) struct cmdline *cl,
18420 	__attribute__((unused)) void *data)
18421 {
18422 	struct cmd_tx_offload_get_capa_result *res = parsed_result;
18423 	struct rte_eth_dev_info dev_info;
18424 	portid_t port_id = res->port_id;
18425 	uint64_t queue_offloads;
18426 	uint64_t port_offloads;
18427 	int ret;
18428 
18429 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
18430 	if (ret != 0)
18431 		return;
18432 
18433 	queue_offloads = dev_info.tx_queue_offload_capa;
18434 	port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
18435 
18436 	printf("Tx Offloading Capabilities of port %d :\n", port_id);
18437 	printf("  Per Queue :");
18438 	print_tx_offloads(queue_offloads);
18439 
18440 	printf("\n");
18441 	printf("  Per Port  :");
18442 	print_tx_offloads(port_offloads);
18443 	printf("\n\n");
18444 }
18445 
18446 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
18447 	.f = cmd_tx_offload_get_capa_parsed,
18448 	.data = NULL,
18449 	.help_str = "show port <port_id> tx_offload capabilities",
18450 	.tokens = {
18451 		(void *)&cmd_tx_offload_get_capa_show,
18452 		(void *)&cmd_tx_offload_get_capa_port,
18453 		(void *)&cmd_tx_offload_get_capa_port_id,
18454 		(void *)&cmd_tx_offload_get_capa_tx_offload,
18455 		(void *)&cmd_tx_offload_get_capa_capabilities,
18456 		NULL,
18457 	}
18458 };
18459 
18460 /* Get Tx offloads configuration */
18461 struct cmd_tx_offload_get_configuration_result {
18462 	cmdline_fixed_string_t show;
18463 	cmdline_fixed_string_t port;
18464 	portid_t port_id;
18465 	cmdline_fixed_string_t tx_offload;
18466 	cmdline_fixed_string_t configuration;
18467 };
18468 
18469 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
18470 	TOKEN_STRING_INITIALIZER
18471 		(struct cmd_tx_offload_get_configuration_result,
18472 		 show, "show");
18473 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
18474 	TOKEN_STRING_INITIALIZER
18475 		(struct cmd_tx_offload_get_configuration_result,
18476 		 port, "port");
18477 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
18478 	TOKEN_NUM_INITIALIZER
18479 		(struct cmd_tx_offload_get_configuration_result,
18480 		 port_id, UINT16);
18481 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
18482 	TOKEN_STRING_INITIALIZER
18483 		(struct cmd_tx_offload_get_configuration_result,
18484 		 tx_offload, "tx_offload");
18485 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
18486 	TOKEN_STRING_INITIALIZER
18487 		(struct cmd_tx_offload_get_configuration_result,
18488 		 configuration, "configuration");
18489 
18490 static void
18491 cmd_tx_offload_get_configuration_parsed(
18492 	void *parsed_result,
18493 	__attribute__((unused)) struct cmdline *cl,
18494 	__attribute__((unused)) void *data)
18495 {
18496 	struct cmd_tx_offload_get_configuration_result *res = parsed_result;
18497 	struct rte_eth_dev_info dev_info;
18498 	portid_t port_id = res->port_id;
18499 	struct rte_port *port = &ports[port_id];
18500 	uint64_t port_offloads;
18501 	uint64_t queue_offloads;
18502 	uint16_t nb_tx_queues;
18503 	int q;
18504 	int ret;
18505 
18506 	printf("Tx Offloading Configuration of port %d :\n", port_id);
18507 
18508 	port_offloads = port->dev_conf.txmode.offloads;
18509 	printf("  Port :");
18510 	print_tx_offloads(port_offloads);
18511 	printf("\n");
18512 
18513 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
18514 	if (ret != 0)
18515 		return;
18516 
18517 	nb_tx_queues = dev_info.nb_tx_queues;
18518 	for (q = 0; q < nb_tx_queues; q++) {
18519 		queue_offloads = port->tx_conf[q].offloads;
18520 		printf("  Queue[%2d] :", q);
18521 		print_tx_offloads(queue_offloads);
18522 		printf("\n");
18523 	}
18524 	printf("\n");
18525 }
18526 
18527 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
18528 	.f = cmd_tx_offload_get_configuration_parsed,
18529 	.data = NULL,
18530 	.help_str = "show port <port_id> tx_offload configuration",
18531 	.tokens = {
18532 		(void *)&cmd_tx_offload_get_configuration_show,
18533 		(void *)&cmd_tx_offload_get_configuration_port,
18534 		(void *)&cmd_tx_offload_get_configuration_port_id,
18535 		(void *)&cmd_tx_offload_get_configuration_tx_offload,
18536 		(void *)&cmd_tx_offload_get_configuration_configuration,
18537 		NULL,
18538 	}
18539 };
18540 
18541 /* Enable/Disable a per port offloading */
18542 struct cmd_config_per_port_tx_offload_result {
18543 	cmdline_fixed_string_t port;
18544 	cmdline_fixed_string_t config;
18545 	portid_t port_id;
18546 	cmdline_fixed_string_t tx_offload;
18547 	cmdline_fixed_string_t offload;
18548 	cmdline_fixed_string_t on_off;
18549 };
18550 
18551 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
18552 	TOKEN_STRING_INITIALIZER
18553 		(struct cmd_config_per_port_tx_offload_result,
18554 		 port, "port");
18555 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
18556 	TOKEN_STRING_INITIALIZER
18557 		(struct cmd_config_per_port_tx_offload_result,
18558 		 config, "config");
18559 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
18560 	TOKEN_NUM_INITIALIZER
18561 		(struct cmd_config_per_port_tx_offload_result,
18562 		 port_id, UINT16);
18563 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
18564 	TOKEN_STRING_INITIALIZER
18565 		(struct cmd_config_per_port_tx_offload_result,
18566 		 tx_offload, "tx_offload");
18567 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
18568 	TOKEN_STRING_INITIALIZER
18569 		(struct cmd_config_per_port_tx_offload_result,
18570 		 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18571 			  "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18572 			  "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18573 			  "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18574 			  "mt_lockfree#multi_segs#mbuf_fast_free#security#"
18575 			  "match_metadata");
18576 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
18577 	TOKEN_STRING_INITIALIZER
18578 		(struct cmd_config_per_port_tx_offload_result,
18579 		 on_off, "on#off");
18580 
18581 static uint64_t
18582 search_tx_offload(const char *name)
18583 {
18584 	uint64_t single_offload;
18585 	const char *single_name;
18586 	int found = 0;
18587 	unsigned int bit;
18588 
18589 	single_offload = 1;
18590 	for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
18591 		single_name = rte_eth_dev_tx_offload_name(single_offload);
18592 		if (single_name == NULL)
18593 			break;
18594 		if (!strcasecmp(single_name, name)) {
18595 			found = 1;
18596 			break;
18597 		} else if (!strcasecmp(single_name, "UNKNOWN"))
18598 			break;
18599 		single_offload <<= 1;
18600 	}
18601 
18602 	if (found)
18603 		return single_offload;
18604 
18605 	return 0;
18606 }
18607 
18608 static void
18609 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
18610 				__attribute__((unused)) struct cmdline *cl,
18611 				__attribute__((unused)) void *data)
18612 {
18613 	struct cmd_config_per_port_tx_offload_result *res = parsed_result;
18614 	portid_t port_id = res->port_id;
18615 	struct rte_eth_dev_info dev_info;
18616 	struct rte_port *port = &ports[port_id];
18617 	uint64_t single_offload;
18618 	uint16_t nb_tx_queues;
18619 	int q;
18620 	int ret;
18621 
18622 	if (port->port_status != RTE_PORT_STOPPED) {
18623 		printf("Error: Can't config offload when Port %d "
18624 		       "is not stopped\n", port_id);
18625 		return;
18626 	}
18627 
18628 	single_offload = search_tx_offload(res->offload);
18629 	if (single_offload == 0) {
18630 		printf("Unknown offload name: %s\n", res->offload);
18631 		return;
18632 	}
18633 
18634 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
18635 	if (ret != 0)
18636 		return;
18637 
18638 	nb_tx_queues = dev_info.nb_tx_queues;
18639 	if (!strcmp(res->on_off, "on")) {
18640 		port->dev_conf.txmode.offloads |= single_offload;
18641 		for (q = 0; q < nb_tx_queues; q++)
18642 			port->tx_conf[q].offloads |= single_offload;
18643 	} else {
18644 		port->dev_conf.txmode.offloads &= ~single_offload;
18645 		for (q = 0; q < nb_tx_queues; q++)
18646 			port->tx_conf[q].offloads &= ~single_offload;
18647 	}
18648 
18649 	cmd_reconfig_device_queue(port_id, 1, 1);
18650 }
18651 
18652 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
18653 	.f = cmd_config_per_port_tx_offload_parsed,
18654 	.data = NULL,
18655 	.help_str = "port config <port_id> tx_offload "
18656 		    "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
18657 		    "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
18658 		    "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
18659 		    "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
18660 		    "mt_lockfree|multi_segs|mbuf_fast_free|security|"
18661 		    "match_metadata on|off",
18662 	.tokens = {
18663 		(void *)&cmd_config_per_port_tx_offload_result_port,
18664 		(void *)&cmd_config_per_port_tx_offload_result_config,
18665 		(void *)&cmd_config_per_port_tx_offload_result_port_id,
18666 		(void *)&cmd_config_per_port_tx_offload_result_tx_offload,
18667 		(void *)&cmd_config_per_port_tx_offload_result_offload,
18668 		(void *)&cmd_config_per_port_tx_offload_result_on_off,
18669 		NULL,
18670 	}
18671 };
18672 
18673 /* Enable/Disable a per queue offloading */
18674 struct cmd_config_per_queue_tx_offload_result {
18675 	cmdline_fixed_string_t port;
18676 	portid_t port_id;
18677 	cmdline_fixed_string_t txq;
18678 	uint16_t queue_id;
18679 	cmdline_fixed_string_t tx_offload;
18680 	cmdline_fixed_string_t offload;
18681 	cmdline_fixed_string_t on_off;
18682 };
18683 
18684 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
18685 	TOKEN_STRING_INITIALIZER
18686 		(struct cmd_config_per_queue_tx_offload_result,
18687 		 port, "port");
18688 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
18689 	TOKEN_NUM_INITIALIZER
18690 		(struct cmd_config_per_queue_tx_offload_result,
18691 		 port_id, UINT16);
18692 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
18693 	TOKEN_STRING_INITIALIZER
18694 		(struct cmd_config_per_queue_tx_offload_result,
18695 		 txq, "txq");
18696 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
18697 	TOKEN_NUM_INITIALIZER
18698 		(struct cmd_config_per_queue_tx_offload_result,
18699 		 queue_id, UINT16);
18700 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
18701 	TOKEN_STRING_INITIALIZER
18702 		(struct cmd_config_per_queue_tx_offload_result,
18703 		 tx_offload, "tx_offload");
18704 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
18705 	TOKEN_STRING_INITIALIZER
18706 		(struct cmd_config_per_queue_tx_offload_result,
18707 		 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18708 			  "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18709 			  "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18710 			  "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18711 			  "mt_lockfree#multi_segs#mbuf_fast_free#security");
18712 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
18713 	TOKEN_STRING_INITIALIZER
18714 		(struct cmd_config_per_queue_tx_offload_result,
18715 		 on_off, "on#off");
18716 
18717 static void
18718 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
18719 				__attribute__((unused)) struct cmdline *cl,
18720 				__attribute__((unused)) void *data)
18721 {
18722 	struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
18723 	struct rte_eth_dev_info dev_info;
18724 	portid_t port_id = res->port_id;
18725 	uint16_t queue_id = res->queue_id;
18726 	struct rte_port *port = &ports[port_id];
18727 	uint64_t single_offload;
18728 	int ret;
18729 
18730 	if (port->port_status != RTE_PORT_STOPPED) {
18731 		printf("Error: Can't config offload when Port %d "
18732 		       "is not stopped\n", port_id);
18733 		return;
18734 	}
18735 
18736 	ret = eth_dev_info_get_print_err(port_id, &dev_info);
18737 	if (ret != 0)
18738 		return;
18739 
18740 	if (queue_id >= dev_info.nb_tx_queues) {
18741 		printf("Error: input queue_id should be 0 ... "
18742 		       "%d\n", dev_info.nb_tx_queues - 1);
18743 		return;
18744 	}
18745 
18746 	single_offload = search_tx_offload(res->offload);
18747 	if (single_offload == 0) {
18748 		printf("Unknown offload name: %s\n", res->offload);
18749 		return;
18750 	}
18751 
18752 	if (!strcmp(res->on_off, "on"))
18753 		port->tx_conf[queue_id].offloads |= single_offload;
18754 	else
18755 		port->tx_conf[queue_id].offloads &= ~single_offload;
18756 
18757 	cmd_reconfig_device_queue(port_id, 1, 1);
18758 }
18759 
18760 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
18761 	.f = cmd_config_per_queue_tx_offload_parsed,
18762 	.data = NULL,
18763 	.help_str = "port <port_id> txq <queue_id> tx_offload "
18764 		    "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
18765 		    "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
18766 		    "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
18767 		    "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
18768 		    "mt_lockfree|multi_segs|mbuf_fast_free|security "
18769 		    "on|off",
18770 	.tokens = {
18771 		(void *)&cmd_config_per_queue_tx_offload_result_port,
18772 		(void *)&cmd_config_per_queue_tx_offload_result_port_id,
18773 		(void *)&cmd_config_per_queue_tx_offload_result_txq,
18774 		(void *)&cmd_config_per_queue_tx_offload_result_queue_id,
18775 		(void *)&cmd_config_per_queue_tx_offload_result_txoffload,
18776 		(void *)&cmd_config_per_queue_tx_offload_result_offload,
18777 		(void *)&cmd_config_per_queue_tx_offload_result_on_off,
18778 		NULL,
18779 	}
18780 };
18781 
18782 /* *** configure tx_metadata for specific port *** */
18783 struct cmd_config_tx_metadata_specific_result {
18784 	cmdline_fixed_string_t port;
18785 	cmdline_fixed_string_t keyword;
18786 	uint16_t port_id;
18787 	cmdline_fixed_string_t item;
18788 	uint32_t value;
18789 };
18790 
18791 static void
18792 cmd_config_tx_metadata_specific_parsed(void *parsed_result,
18793 				__attribute__((unused)) struct cmdline *cl,
18794 				__attribute__((unused)) void *data)
18795 {
18796 	struct cmd_config_tx_metadata_specific_result *res = parsed_result;
18797 
18798 	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
18799 		return;
18800 	ports[res->port_id].tx_metadata = res->value;
18801 	/* Add/remove callback to insert valid metadata in every Tx packet. */
18802 	if (ports[res->port_id].tx_metadata)
18803 		add_tx_md_callback(res->port_id);
18804 	else
18805 		remove_tx_md_callback(res->port_id);
18806 	rte_flow_dynf_metadata_register();
18807 }
18808 
18809 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
18810 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18811 			port, "port");
18812 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
18813 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18814 			keyword, "config");
18815 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
18816 	TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18817 			port_id, UINT16);
18818 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
18819 	TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18820 			item, "tx_metadata");
18821 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
18822 	TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18823 			value, UINT32);
18824 
18825 cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
18826 	.f = cmd_config_tx_metadata_specific_parsed,
18827 	.data = NULL,
18828 	.help_str = "port config <port_id> tx_metadata <value>",
18829 	.tokens = {
18830 		(void *)&cmd_config_tx_metadata_specific_port,
18831 		(void *)&cmd_config_tx_metadata_specific_keyword,
18832 		(void *)&cmd_config_tx_metadata_specific_id,
18833 		(void *)&cmd_config_tx_metadata_specific_item,
18834 		(void *)&cmd_config_tx_metadata_specific_value,
18835 		NULL,
18836 	},
18837 };
18838 
18839 /* *** display tx_metadata per port configuration *** */
18840 struct cmd_show_tx_metadata_result {
18841 	cmdline_fixed_string_t cmd_show;
18842 	cmdline_fixed_string_t cmd_port;
18843 	cmdline_fixed_string_t cmd_keyword;
18844 	portid_t cmd_pid;
18845 };
18846 
18847 static void
18848 cmd_show_tx_metadata_parsed(void *parsed_result,
18849 		__attribute__((unused)) struct cmdline *cl,
18850 		__attribute__((unused)) void *data)
18851 {
18852 	struct cmd_show_tx_metadata_result *res = parsed_result;
18853 
18854 	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
18855 		printf("invalid port id %u\n", res->cmd_pid);
18856 		return;
18857 	}
18858 	if (!strcmp(res->cmd_keyword, "tx_metadata")) {
18859 		printf("Port %u tx_metadata: %u\n", res->cmd_pid,
18860 			rte_be_to_cpu_32(ports[res->cmd_pid].tx_metadata));
18861 	}
18862 }
18863 
18864 cmdline_parse_token_string_t cmd_show_tx_metadata_show =
18865 	TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
18866 			cmd_show, "show");
18867 cmdline_parse_token_string_t cmd_show_tx_metadata_port =
18868 	TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
18869 			cmd_port, "port");
18870 cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
18871 	TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
18872 			cmd_pid, UINT16);
18873 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
18874 	TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
18875 			cmd_keyword, "tx_metadata");
18876 
18877 cmdline_parse_inst_t cmd_show_tx_metadata = {
18878 	.f = cmd_show_tx_metadata_parsed,
18879 	.data = NULL,
18880 	.help_str = "show port <port_id> tx_metadata",
18881 	.tokens = {
18882 		(void *)&cmd_show_tx_metadata_show,
18883 		(void *)&cmd_show_tx_metadata_port,
18884 		(void *)&cmd_show_tx_metadata_pid,
18885 		(void *)&cmd_show_tx_metadata_keyword,
18886 		NULL,
18887 	},
18888 };
18889 
18890 /* show port supported ptypes */
18891 
18892 /* Common result structure for show port ptypes */
18893 struct cmd_show_port_supported_ptypes_result {
18894 	cmdline_fixed_string_t show;
18895 	cmdline_fixed_string_t port;
18896 	portid_t port_id;
18897 	cmdline_fixed_string_t ptypes;
18898 };
18899 
18900 /* Common CLI fields for show port ptypes */
18901 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =
18902 	TOKEN_STRING_INITIALIZER
18903 		(struct cmd_show_port_supported_ptypes_result,
18904 		 show, "show");
18905 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
18906 	TOKEN_STRING_INITIALIZER
18907 		(struct cmd_show_port_supported_ptypes_result,
18908 		 port, "port");
18909 cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =
18910 	TOKEN_NUM_INITIALIZER
18911 		(struct cmd_show_port_supported_ptypes_result,
18912 		 port_id, UINT16);
18913 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =
18914 	TOKEN_STRING_INITIALIZER
18915 		(struct cmd_show_port_supported_ptypes_result,
18916 		 ptypes, "ptypes");
18917 
18918 static void
18919 cmd_show_port_supported_ptypes_parsed(
18920 	void *parsed_result,
18921 	__attribute__((unused)) struct cmdline *cl,
18922 	__attribute__((unused)) void *data)
18923 {
18924 #define RSVD_PTYPE_MASK       0xf0000000
18925 #define MAX_PTYPES_PER_LAYER  16
18926 #define LTYPE_NAMESIZE        32
18927 #define PTYPE_NAMESIZE        256
18928 	struct cmd_show_port_supported_ptypes_result *res = parsed_result;
18929 	char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE];
18930 	uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
18931 	uint32_t ptypes[MAX_PTYPES_PER_LAYER];
18932 	uint16_t port_id = res->port_id;
18933 	int ret, i;
18934 
18935 	ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0);
18936 	if (ret < 0)
18937 		return;
18938 
18939 	while (ptype_mask != RSVD_PTYPE_MASK) {
18940 
18941 		switch (ptype_mask) {
18942 		case RTE_PTYPE_L2_MASK:
18943 			strlcpy(ltype, "L2", sizeof(ltype));
18944 			break;
18945 		case RTE_PTYPE_L3_MASK:
18946 			strlcpy(ltype, "L3", sizeof(ltype));
18947 			break;
18948 		case RTE_PTYPE_L4_MASK:
18949 			strlcpy(ltype, "L4", sizeof(ltype));
18950 			break;
18951 		case RTE_PTYPE_TUNNEL_MASK:
18952 			strlcpy(ltype, "Tunnel", sizeof(ltype));
18953 			break;
18954 		case RTE_PTYPE_INNER_L2_MASK:
18955 			strlcpy(ltype, "Inner L2", sizeof(ltype));
18956 			break;
18957 		case RTE_PTYPE_INNER_L3_MASK:
18958 			strlcpy(ltype, "Inner L3", sizeof(ltype));
18959 			break;
18960 		case RTE_PTYPE_INNER_L4_MASK:
18961 			strlcpy(ltype, "Inner L4", sizeof(ltype));
18962 			break;
18963 		default:
18964 			return;
18965 		}
18966 
18967 		ret = rte_eth_dev_get_supported_ptypes(res->port_id,
18968 						       ptype_mask, ptypes,
18969 						       MAX_PTYPES_PER_LAYER);
18970 
18971 		if (ret > 0)
18972 			printf("Supported %s ptypes:\n", ltype);
18973 		else
18974 			printf("%s ptypes unsupported\n", ltype);
18975 
18976 		for (i = 0; i < ret; ++i) {
18977 			rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
18978 			printf("%s\n", buf);
18979 		}
18980 
18981 		ptype_mask <<= 4;
18982 	}
18983 }
18984 
18985 cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
18986 	.f = cmd_show_port_supported_ptypes_parsed,
18987 	.data = NULL,
18988 	.help_str = "show port <port_id> ptypes",
18989 	.tokens = {
18990 		(void *)&cmd_show_port_supported_ptypes_show,
18991 		(void *)&cmd_show_port_supported_ptypes_port,
18992 		(void *)&cmd_show_port_supported_ptypes_port_id,
18993 		(void *)&cmd_show_port_supported_ptypes_ptypes,
18994 		NULL,
18995 	},
18996 };
18997 
18998 /* *** display rx/tx descriptor status *** */
18999 struct cmd_show_rx_tx_desc_status_result {
19000 	cmdline_fixed_string_t cmd_show;
19001 	cmdline_fixed_string_t cmd_port;
19002 	cmdline_fixed_string_t cmd_keyword;
19003 	cmdline_fixed_string_t cmd_desc;
19004 	cmdline_fixed_string_t cmd_status;
19005 	portid_t cmd_pid;
19006 	portid_t cmd_qid;
19007 	portid_t cmd_did;
19008 };
19009 
19010 static void
19011 cmd_show_rx_tx_desc_status_parsed(void *parsed_result,
19012 		__attribute__((unused)) struct cmdline *cl,
19013 		__attribute__((unused)) void *data)
19014 {
19015 	struct cmd_show_rx_tx_desc_status_result *res = parsed_result;
19016 	int rc;
19017 
19018 	if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
19019 		printf("invalid port id %u\n", res->cmd_pid);
19020 		return;
19021 	}
19022 
19023 	if (!strcmp(res->cmd_keyword, "rxq")) {
19024 		rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid,
19025 					     res->cmd_did);
19026 		if (rc < 0) {
19027 			printf("Invalid queueid = %d\n", res->cmd_qid);
19028 			return;
19029 		}
19030 		if (rc == RTE_ETH_RX_DESC_AVAIL)
19031 			printf("Desc status = AVAILABLE\n");
19032 		else if (rc == RTE_ETH_RX_DESC_DONE)
19033 			printf("Desc status = DONE\n");
19034 		else
19035 			printf("Desc status = UNAVAILABLE\n");
19036 	} else if (!strcmp(res->cmd_keyword, "txq")) {
19037 		rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid,
19038 					     res->cmd_did);
19039 		if (rc < 0) {
19040 			printf("Invalid queueid = %d\n", res->cmd_qid);
19041 			return;
19042 		}
19043 		if (rc == RTE_ETH_TX_DESC_FULL)
19044 			printf("Desc status = FULL\n");
19045 		else if (rc == RTE_ETH_TX_DESC_DONE)
19046 			printf("Desc status = DONE\n");
19047 		else
19048 			printf("Desc status = UNAVAILABLE\n");
19049 	}
19050 }
19051 
19052 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show =
19053 	TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19054 			cmd_show, "show");
19055 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port =
19056 	TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19057 			cmd_port, "port");
19058 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid =
19059 	TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19060 			cmd_pid, UINT16);
19061 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword =
19062 	TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19063 			cmd_keyword, "rxq#txq");
19064 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid =
19065 	TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19066 			cmd_qid, UINT16);
19067 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc =
19068 	TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19069 			cmd_desc, "desc");
19070 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did =
19071 	TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19072 			cmd_did, UINT16);
19073 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status =
19074 	TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19075 			cmd_status, "status");
19076 cmdline_parse_inst_t cmd_show_rx_tx_desc_status = {
19077 	.f = cmd_show_rx_tx_desc_status_parsed,
19078 	.data = NULL,
19079 	.help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> "
19080 		"status",
19081 	.tokens = {
19082 		(void *)&cmd_show_rx_tx_desc_status_show,
19083 		(void *)&cmd_show_rx_tx_desc_status_port,
19084 		(void *)&cmd_show_rx_tx_desc_status_pid,
19085 		(void *)&cmd_show_rx_tx_desc_status_keyword,
19086 		(void *)&cmd_show_rx_tx_desc_status_qid,
19087 		(void *)&cmd_show_rx_tx_desc_status_desc,
19088 		(void *)&cmd_show_rx_tx_desc_status_did,
19089 		(void *)&cmd_show_rx_tx_desc_status_status,
19090 		NULL,
19091 	},
19092 };
19093 
19094 /* Common result structure for set port ptypes */
19095 struct cmd_set_port_ptypes_result {
19096 	cmdline_fixed_string_t set;
19097 	cmdline_fixed_string_t port;
19098 	portid_t port_id;
19099 	cmdline_fixed_string_t ptype_mask;
19100 	uint32_t mask;
19101 };
19102 
19103 /* Common CLI fields for set port ptypes */
19104 cmdline_parse_token_string_t cmd_set_port_ptypes_set =
19105 	TOKEN_STRING_INITIALIZER
19106 		(struct cmd_set_port_ptypes_result,
19107 		 set, "set");
19108 cmdline_parse_token_string_t cmd_set_port_ptypes_port =
19109 	TOKEN_STRING_INITIALIZER
19110 		(struct cmd_set_port_ptypes_result,
19111 		 port, "port");
19112 cmdline_parse_token_num_t cmd_set_port_ptypes_port_id =
19113 	TOKEN_NUM_INITIALIZER
19114 		(struct cmd_set_port_ptypes_result,
19115 		 port_id, UINT16);
19116 cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str =
19117 	TOKEN_STRING_INITIALIZER
19118 		(struct cmd_set_port_ptypes_result,
19119 		 ptype_mask, "ptype_mask");
19120 cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 =
19121 	TOKEN_NUM_INITIALIZER
19122 		(struct cmd_set_port_ptypes_result,
19123 		 mask, UINT32);
19124 
19125 static void
19126 cmd_set_port_ptypes_parsed(
19127 	void *parsed_result,
19128 	__attribute__((unused)) struct cmdline *cl,
19129 	__attribute__((unused)) void *data)
19130 {
19131 	struct cmd_set_port_ptypes_result *res = parsed_result;
19132 #define PTYPE_NAMESIZE        256
19133 	char ptype_name[PTYPE_NAMESIZE];
19134 	uint16_t port_id = res->port_id;
19135 	uint32_t ptype_mask = res->mask;
19136 	int ret, i;
19137 
19138 	ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK,
19139 					       NULL, 0);
19140 	if (ret <= 0) {
19141 		printf("Port %d doesn't support any ptypes.\n", port_id);
19142 		return;
19143 	}
19144 
19145 	uint32_t ptypes[ret];
19146 
19147 	ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret);
19148 	if (ret < 0) {
19149 		printf("Unable to set requested ptypes for Port %d\n", port_id);
19150 		return;
19151 	}
19152 
19153 	printf("Successfully set following ptypes for Port %d\n", port_id);
19154 	for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) {
19155 		rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name));
19156 		printf("%s\n", ptype_name);
19157 	}
19158 
19159 	clear_ptypes = false;
19160 }
19161 
19162 cmdline_parse_inst_t cmd_set_port_ptypes = {
19163 	.f = cmd_set_port_ptypes_parsed,
19164 	.data = NULL,
19165 	.help_str = "set port <port_id> ptype_mask <mask>",
19166 	.tokens = {
19167 		(void *)&cmd_set_port_ptypes_set,
19168 		(void *)&cmd_set_port_ptypes_port,
19169 		(void *)&cmd_set_port_ptypes_port_id,
19170 		(void *)&cmd_set_port_ptypes_mask_str,
19171 		(void *)&cmd_set_port_ptypes_mask_u32,
19172 		NULL,
19173 	},
19174 };
19175 
19176 /* ******************************************************************************** */
19177 
19178 /* list of instructions */
19179 cmdline_parse_ctx_t main_ctx[] = {
19180 	(cmdline_parse_inst_t *)&cmd_help_brief,
19181 	(cmdline_parse_inst_t *)&cmd_help_long,
19182 	(cmdline_parse_inst_t *)&cmd_quit,
19183 	(cmdline_parse_inst_t *)&cmd_load_from_file,
19184 	(cmdline_parse_inst_t *)&cmd_showport,
19185 	(cmdline_parse_inst_t *)&cmd_showqueue,
19186 	(cmdline_parse_inst_t *)&cmd_showportall,
19187 	(cmdline_parse_inst_t *)&cmd_showdevice,
19188 	(cmdline_parse_inst_t *)&cmd_showcfg,
19189 	(cmdline_parse_inst_t *)&cmd_showfwdall,
19190 	(cmdline_parse_inst_t *)&cmd_start,
19191 	(cmdline_parse_inst_t *)&cmd_start_tx_first,
19192 	(cmdline_parse_inst_t *)&cmd_start_tx_first_n,
19193 	(cmdline_parse_inst_t *)&cmd_set_link_up,
19194 	(cmdline_parse_inst_t *)&cmd_set_link_down,
19195 	(cmdline_parse_inst_t *)&cmd_reset,
19196 	(cmdline_parse_inst_t *)&cmd_set_numbers,
19197 	(cmdline_parse_inst_t *)&cmd_set_log,
19198 	(cmdline_parse_inst_t *)&cmd_set_txpkts,
19199 	(cmdline_parse_inst_t *)&cmd_set_txsplit,
19200 	(cmdline_parse_inst_t *)&cmd_set_fwd_list,
19201 	(cmdline_parse_inst_t *)&cmd_set_fwd_mask,
19202 	(cmdline_parse_inst_t *)&cmd_set_fwd_mode,
19203 	(cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
19204 	(cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
19205 	(cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
19206 	(cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
19207 	(cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
19208 	(cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
19209 	(cmdline_parse_inst_t *)&cmd_set_flush_rx,
19210 	(cmdline_parse_inst_t *)&cmd_set_link_check,
19211 	(cmdline_parse_inst_t *)&cmd_set_bypass_mode,
19212 	(cmdline_parse_inst_t *)&cmd_set_bypass_event,
19213 	(cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
19214 	(cmdline_parse_inst_t *)&cmd_show_bypass_config,
19215 #ifdef RTE_LIBRTE_PMD_BOND
19216 	(cmdline_parse_inst_t *) &cmd_set_bonding_mode,
19217 	(cmdline_parse_inst_t *) &cmd_show_bonding_config,
19218 	(cmdline_parse_inst_t *) &cmd_set_bonding_primary,
19219 	(cmdline_parse_inst_t *) &cmd_add_bonding_slave,
19220 	(cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
19221 	(cmdline_parse_inst_t *) &cmd_create_bonded_device,
19222 	(cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
19223 	(cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
19224 	(cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
19225 	(cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
19226 	(cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
19227 #endif
19228 	(cmdline_parse_inst_t *)&cmd_vlan_offload,
19229 	(cmdline_parse_inst_t *)&cmd_vlan_tpid,
19230 	(cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
19231 	(cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
19232 	(cmdline_parse_inst_t *)&cmd_tx_vlan_set,
19233 	(cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
19234 	(cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
19235 	(cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
19236 	(cmdline_parse_inst_t *)&cmd_csum_set,
19237 	(cmdline_parse_inst_t *)&cmd_csum_show,
19238 	(cmdline_parse_inst_t *)&cmd_csum_tunnel,
19239 	(cmdline_parse_inst_t *)&cmd_tso_set,
19240 	(cmdline_parse_inst_t *)&cmd_tso_show,
19241 	(cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
19242 	(cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
19243 	(cmdline_parse_inst_t *)&cmd_gro_enable,
19244 	(cmdline_parse_inst_t *)&cmd_gro_flush,
19245 	(cmdline_parse_inst_t *)&cmd_gro_show,
19246 	(cmdline_parse_inst_t *)&cmd_gso_enable,
19247 	(cmdline_parse_inst_t *)&cmd_gso_size,
19248 	(cmdline_parse_inst_t *)&cmd_gso_show,
19249 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set,
19250 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
19251 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
19252 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
19253 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
19254 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
19255 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
19256 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
19257 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
19258 	(cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
19259 	(cmdline_parse_inst_t *)&cmd_config_dcb,
19260 	(cmdline_parse_inst_t *)&cmd_read_reg,
19261 	(cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
19262 	(cmdline_parse_inst_t *)&cmd_read_reg_bit,
19263 	(cmdline_parse_inst_t *)&cmd_write_reg,
19264 	(cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
19265 	(cmdline_parse_inst_t *)&cmd_write_reg_bit,
19266 	(cmdline_parse_inst_t *)&cmd_read_rxd_txd,
19267 	(cmdline_parse_inst_t *)&cmd_stop,
19268 	(cmdline_parse_inst_t *)&cmd_mac_addr,
19269 	(cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
19270 	(cmdline_parse_inst_t *)&cmd_set_qmap,
19271 	(cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
19272 	(cmdline_parse_inst_t *)&cmd_operate_port,
19273 	(cmdline_parse_inst_t *)&cmd_operate_specific_port,
19274 	(cmdline_parse_inst_t *)&cmd_operate_attach_port,
19275 	(cmdline_parse_inst_t *)&cmd_operate_detach_port,
19276 	(cmdline_parse_inst_t *)&cmd_operate_detach_device,
19277 	(cmdline_parse_inst_t *)&cmd_set_port_setup_on,
19278 	(cmdline_parse_inst_t *)&cmd_config_speed_all,
19279 	(cmdline_parse_inst_t *)&cmd_config_speed_specific,
19280 	(cmdline_parse_inst_t *)&cmd_config_loopback_all,
19281 	(cmdline_parse_inst_t *)&cmd_config_loopback_specific,
19282 	(cmdline_parse_inst_t *)&cmd_config_rx_tx,
19283 	(cmdline_parse_inst_t *)&cmd_config_mtu,
19284 	(cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
19285 	(cmdline_parse_inst_t *)&cmd_config_max_lro_pkt_size,
19286 	(cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
19287 	(cmdline_parse_inst_t *)&cmd_config_rss,
19288 	(cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
19289 	(cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
19290 	(cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
19291 	(cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
19292 	(cmdline_parse_inst_t *)&cmd_config_rss_reta,
19293 	(cmdline_parse_inst_t *)&cmd_showport_reta,
19294 	(cmdline_parse_inst_t *)&cmd_config_burst,
19295 	(cmdline_parse_inst_t *)&cmd_config_thresh,
19296 	(cmdline_parse_inst_t *)&cmd_config_threshold,
19297 	(cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
19298 	(cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
19299 	(cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
19300 	(cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
19301 	(cmdline_parse_inst_t *)&cmd_queue_rate_limit,
19302 	(cmdline_parse_inst_t *)&cmd_tunnel_filter,
19303 	(cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
19304 	(cmdline_parse_inst_t *)&cmd_global_config,
19305 	(cmdline_parse_inst_t *)&cmd_set_mirror_mask,
19306 	(cmdline_parse_inst_t *)&cmd_set_mirror_link,
19307 	(cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
19308 	(cmdline_parse_inst_t *)&cmd_showport_rss_hash,
19309 	(cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
19310 	(cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
19311 	(cmdline_parse_inst_t *)&cmd_dump,
19312 	(cmdline_parse_inst_t *)&cmd_dump_one,
19313 	(cmdline_parse_inst_t *)&cmd_ethertype_filter,
19314 	(cmdline_parse_inst_t *)&cmd_syn_filter,
19315 	(cmdline_parse_inst_t *)&cmd_2tuple_filter,
19316 	(cmdline_parse_inst_t *)&cmd_5tuple_filter,
19317 	(cmdline_parse_inst_t *)&cmd_flex_filter,
19318 	(cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
19319 	(cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
19320 	(cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
19321 	(cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
19322 	(cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
19323 	(cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
19324 	(cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
19325 	(cmdline_parse_inst_t *)&cmd_flush_flow_director,
19326 	(cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
19327 	(cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
19328 	(cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
19329 	(cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
19330 	(cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
19331 	(cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
19332 	(cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
19333 	(cmdline_parse_inst_t *)&cmd_get_hash_global_config,
19334 	(cmdline_parse_inst_t *)&cmd_set_hash_global_config,
19335 	(cmdline_parse_inst_t *)&cmd_set_hash_input_set,
19336 	(cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
19337 	(cmdline_parse_inst_t *)&cmd_flow,
19338 	(cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
19339 	(cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
19340 	(cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
19341 	(cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
19342 	(cmdline_parse_inst_t *)&cmd_create_port_meter,
19343 	(cmdline_parse_inst_t *)&cmd_enable_port_meter,
19344 	(cmdline_parse_inst_t *)&cmd_disable_port_meter,
19345 	(cmdline_parse_inst_t *)&cmd_del_port_meter,
19346 	(cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
19347 	(cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
19348 	(cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
19349 	(cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
19350 	(cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
19351 	(cmdline_parse_inst_t *)&cmd_mcast_addr,
19352 	(cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
19353 	(cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
19354 	(cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
19355 	(cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
19356 	(cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
19357 	(cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
19358 	(cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
19359 	(cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
19360 	(cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
19361 	(cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
19362 	(cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
19363 	(cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
19364 	(cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
19365 	(cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
19366 	(cmdline_parse_inst_t *)&cmd_set_tx_loopback,
19367 	(cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
19368 	(cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
19369 	(cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
19370 	(cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
19371 	(cmdline_parse_inst_t *)&cmd_set_macsec_sc,
19372 	(cmdline_parse_inst_t *)&cmd_set_macsec_sa,
19373 	(cmdline_parse_inst_t *)&cmd_set_vf_traffic,
19374 	(cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
19375 	(cmdline_parse_inst_t *)&cmd_vf_rate_limit,
19376 	(cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
19377 	(cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
19378 	(cmdline_parse_inst_t *)&cmd_set_vf_promisc,
19379 	(cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
19380 	(cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
19381 	(cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
19382 	(cmdline_parse_inst_t *)&cmd_vf_max_bw,
19383 	(cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
19384 	(cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
19385 	(cmdline_parse_inst_t *)&cmd_strict_link_prio,
19386 	(cmdline_parse_inst_t *)&cmd_tc_min_bw,
19387 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
19388 	(cmdline_parse_inst_t *)&cmd_set_port_tm_hierarchy_default,
19389 #endif
19390 	(cmdline_parse_inst_t *)&cmd_set_vxlan,
19391 	(cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl,
19392 	(cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
19393 	(cmdline_parse_inst_t *)&cmd_set_nvgre,
19394 	(cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
19395 	(cmdline_parse_inst_t *)&cmd_set_l2_encap,
19396 	(cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
19397 	(cmdline_parse_inst_t *)&cmd_set_l2_decap,
19398 	(cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
19399 	(cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
19400 	(cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
19401 	(cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
19402 	(cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
19403 	(cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
19404 	(cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
19405 	(cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
19406 	(cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
19407 	(cmdline_parse_inst_t *)&cmd_ddp_add,
19408 	(cmdline_parse_inst_t *)&cmd_ddp_del,
19409 	(cmdline_parse_inst_t *)&cmd_ddp_get_list,
19410 	(cmdline_parse_inst_t *)&cmd_ddp_get_info,
19411 	(cmdline_parse_inst_t *)&cmd_cfg_input_set,
19412 	(cmdline_parse_inst_t *)&cmd_clear_input_set,
19413 	(cmdline_parse_inst_t *)&cmd_show_vf_stats,
19414 	(cmdline_parse_inst_t *)&cmd_clear_vf_stats,
19415 	(cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes,
19416 	(cmdline_parse_inst_t *)&cmd_set_port_ptypes,
19417 	(cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
19418 	(cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
19419 	(cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
19420 	(cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
19421 
19422 	(cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
19423 	(cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
19424 	(cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
19425 	(cmdline_parse_inst_t *)&cmd_queue_region,
19426 	(cmdline_parse_inst_t *)&cmd_region_flowtype,
19427 	(cmdline_parse_inst_t *)&cmd_user_priority_region,
19428 	(cmdline_parse_inst_t *)&cmd_flush_queue_region,
19429 	(cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
19430 	(cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
19431 	(cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
19432 	(cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
19433 	(cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
19434 	(cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
19435 	(cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
19436 	(cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
19437 	(cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
19438 	(cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
19439 	(cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
19440 	(cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
19441 	(cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
19442 	(cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
19443 	(cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
19444 	(cmdline_parse_inst_t *)&cmd_del_port_tm_node,
19445 	(cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
19446 	(cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
19447 	(cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
19448 	(cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
19449 	(cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
19450 	(cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
19451 	(cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
19452 	(cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
19453 	(cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
19454 	(cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
19455 	(cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
19456 	(cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
19457 	(cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
19458 	(cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
19459 	(cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
19460 	(cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
19461 #ifdef RTE_LIBRTE_BPF
19462 	(cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
19463 	(cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
19464 #endif
19465 	(cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
19466 	(cmdline_parse_inst_t *)&cmd_show_tx_metadata,
19467 	(cmdline_parse_inst_t *)&cmd_show_rx_tx_desc_status,
19468 	(cmdline_parse_inst_t *)&cmd_set_raw,
19469 	(cmdline_parse_inst_t *)&cmd_show_set_raw,
19470 	(cmdline_parse_inst_t *)&cmd_show_set_raw_all,
19471 	NULL,
19472 };
19473 
19474 /* read cmdline commands from file */
19475 void
19476 cmdline_read_from_file(const char *filename)
19477 {
19478 	struct cmdline *cl;
19479 
19480 	cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
19481 	if (cl == NULL) {
19482 		printf("Failed to create file based cmdline context: %s\n",
19483 		       filename);
19484 		return;
19485 	}
19486 
19487 	cmdline_interact(cl);
19488 	cmdline_quit(cl);
19489 
19490 	cmdline_free(cl);
19491 
19492 	printf("Read CLI commands from %s\n", filename);
19493 }
19494 
19495 /* prompt function, called from main on MASTER lcore */
19496 void
19497 prompt(void)
19498 {
19499 	/* initialize non-constant commands */
19500 	cmd_set_fwd_mode_init();
19501 	cmd_set_fwd_retry_mode_init();
19502 
19503 	testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
19504 	if (testpmd_cl == NULL)
19505 		return;
19506 	cmdline_interact(testpmd_cl);
19507 	cmdline_stdin_exit(testpmd_cl);
19508 }
19509 
19510 void
19511 prompt_exit(void)
19512 {
19513 	if (testpmd_cl != NULL)
19514 		cmdline_quit(testpmd_cl);
19515 }
19516 
19517 static void
19518 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
19519 {
19520 	if (id == (portid_t)RTE_PORT_ALL) {
19521 		portid_t pid;
19522 
19523 		RTE_ETH_FOREACH_DEV(pid) {
19524 			/* check if need_reconfig has been set to 1 */
19525 			if (ports[pid].need_reconfig == 0)
19526 				ports[pid].need_reconfig = dev;
19527 			/* check if need_reconfig_queues has been set to 1 */
19528 			if (ports[pid].need_reconfig_queues == 0)
19529 				ports[pid].need_reconfig_queues = queue;
19530 		}
19531 	} else if (!port_id_is_invalid(id, DISABLED_WARN)) {
19532 		/* check if need_reconfig has been set to 1 */
19533 		if (ports[id].need_reconfig == 0)
19534 			ports[id].need_reconfig = dev;
19535 		/* check if need_reconfig_queues has been set to 1 */
19536 		if (ports[id].need_reconfig_queues == 0)
19537 			ports[id].need_reconfig_queues = queue;
19538 	}
19539 }
19540