1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2016 Intel Corporation.
3 * Copyright(c) 2014 6WIND S.A.
14 #include <sys/socket.h>
15 #include <netinet/in.h>
17 #include <sys/queue.h>
19 #include <rte_common.h>
20 #include <rte_byteorder.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>
29 #include <rte_per_lcore.h>
30 #include <rte_lcore.h>
31 #include <rte_atomic.h>
32 #include <rte_branch_prediction.h>
34 #include <rte_mempool.h>
35 #include <rte_interrupts.h>
37 #include <rte_ether.h>
38 #include <rte_ethdev.h>
39 #include <rte_string_fns.h>
40 #include <rte_devargs.h>
43 #include <rte_mbuf_dyn.h>
45 #include <cmdline_rdline.h>
46 #include <cmdline_parse.h>
47 #include <cmdline_parse_num.h>
48 #include <cmdline_parse_string.h>
49 #include <cmdline_parse_ipaddr.h>
50 #include <cmdline_parse_etheraddr.h>
51 #include <cmdline_socket.h>
53 #ifdef RTE_LIBRTE_PMD_BOND
54 #include <rte_eth_bond.h>
55 #include <rte_eth_bond_8023ad.h>
57 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD
58 #include <rte_pmd_dpaa.h>
60 #ifdef RTE_LIBRTE_IXGBE_PMD
61 #include <rte_pmd_ixgbe.h>
63 #ifdef RTE_LIBRTE_I40E_PMD
64 #include <rte_pmd_i40e.h>
66 #ifdef RTE_LIBRTE_BNXT_PMD
67 #include <rte_pmd_bnxt.h>
70 #include "cmdline_mtr.h"
71 #include "cmdline_tm.h"
74 static struct cmdline *testpmd_cl;
76 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
78 /* *** Help command with introduction. *** */
79 struct cmd_help_brief_result {
80 cmdline_fixed_string_t help;
83 static void cmd_help_brief_parsed(__attribute__((unused)) void *parsed_result,
85 __attribute__((unused)) void *data)
90 "Help is available for the following sections:\n\n"
91 " help control : Start and stop forwarding.\n"
92 " help display : Displaying port, stats and config "
94 " help config : Configuration information.\n"
95 " help ports : Configuring ports.\n"
96 " help registers : Reading and setting port registers.\n"
97 " help filters : Filters configuration help.\n"
98 " help traffic_management : Traffic Management commmands.\n"
99 " help devices : Device related cmds.\n"
100 " help all : All of the above sections.\n\n"
105 cmdline_parse_token_string_t cmd_help_brief_help =
106 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
108 cmdline_parse_inst_t cmd_help_brief = {
109 .f = cmd_help_brief_parsed,
111 .help_str = "help: Show help",
113 (void *)&cmd_help_brief_help,
118 /* *** Help command with help sections. *** */
119 struct cmd_help_long_result {
120 cmdline_fixed_string_t help;
121 cmdline_fixed_string_t section;
124 static void cmd_help_long_parsed(void *parsed_result,
126 __attribute__((unused)) void *data)
129 struct cmd_help_long_result *res = parsed_result;
131 if (!strcmp(res->section, "all"))
134 if (show_all || !strcmp(res->section, "control")) {
139 "Control forwarding:\n"
140 "-------------------\n\n"
143 " Start packet forwarding with current configuration.\n\n"
146 " Start packet forwarding with current config"
147 " after sending one burst of packets.\n\n"
150 " Stop packet forwarding, and display accumulated"
154 " Quit to prompt.\n\n"
158 if (show_all || !strcmp(res->section, "display")) {
166 "show port (info|stats|summary|xstats|fdir|stat_qmap|dcb_tc|cap) (port_id|all)\n"
167 " Display information for port_id, or all.\n\n"
169 "show port X rss reta (size) (mask0,mask1,...)\n"
170 " Display the rss redirection table entry indicated"
171 " by masks on port X. size is used to indicate the"
172 " hardware supported reta size\n\n"
174 "show port (port_id) rss-hash [key]\n"
175 " Display the RSS hash functions and RSS hash key of port\n\n"
177 "clear port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n"
178 " Clear information for port_id, or all.\n\n"
180 "show (rxq|txq) info (port_id) (queue_id)\n"
181 " Display information for configured RX/TX queue.\n\n"
183 "show config (rxtx|cores|fwd|txpkts)\n"
184 " Display the given configuration.\n\n"
186 "read rxd (port_id) (queue_id) (rxd_id)\n"
187 " Display an RX descriptor of a port RX queue.\n\n"
189 "read txd (port_id) (queue_id) (txd_id)\n"
190 " Display a TX descriptor of a port TX queue.\n\n"
192 "ddp get list (port_id)\n"
193 " Get ddp profile info list\n\n"
195 "ddp get info (profile_path)\n"
196 " Get ddp profile information.\n\n"
198 "show vf stats (port_id) (vf_id)\n"
199 " Display a VF's statistics.\n\n"
201 "clear vf stats (port_id) (vf_id)\n"
202 " Reset a VF's statistics.\n\n"
204 "show port (port_id) pctype mapping\n"
205 " Get flow ptype to pctype mapping on a port\n\n"
207 "show port meter stats (port_id) (meter_id) (clear)\n"
208 " Get meter stats on a port\n\n"
210 "show fwd stats all\n"
211 " Display statistics for all fwd engines.\n\n"
213 "clear fwd stats all\n"
214 " Clear statistics for all fwd engines.\n\n"
216 "show port (port_id) rx_offload capabilities\n"
217 " List all per queue and per port Rx offloading"
218 " capabilities of a port\n\n"
220 "show port (port_id) rx_offload configuration\n"
221 " List port level and all queue level"
222 " Rx offloading configuration\n\n"
224 "show port (port_id) tx_offload capabilities\n"
225 " List all per queue and per port"
226 " Tx offloading capabilities of a port\n\n"
228 "show port (port_id) tx_offload configuration\n"
229 " List port level and all queue level"
230 " Tx offloading configuration\n\n"
232 "show port (port_id) tx_metadata\n"
233 " Show Tx metadata value set"
234 " for a specific port\n\n"
236 "show port (port_id) ptypes\n"
237 " Show port supported ptypes"
238 " for a specific port\n\n"
240 "show device info (<identifier>|all)"
241 " Show general information about devices probed.\n\n"
243 "show port (port_id) rxq|txq (queue_id) desc (desc_id) status"
244 " Show status of rx|tx descriptor.\n\n"
246 "show port (port_id) macs|mcast_macs"
247 " Display list of mac addresses added to port.\n\n"
251 if (show_all || !strcmp(res->section, "config")) {
257 "Configuration changes only become active when"
258 " forwarding is started/restarted.\n\n"
261 " Reset forwarding to the default configuration.\n\n"
263 "set verbose (level)\n"
264 " Set the debug verbosity level X.\n\n"
266 "set log global|(type) (level)\n"
267 " Set the log level.\n\n"
270 " Set number of ports.\n\n"
273 " Set number of cores.\n\n"
275 "set coremask (mask)\n"
276 " Set the forwarding cores hexadecimal mask.\n\n"
278 "set portmask (mask)\n"
279 " Set the forwarding ports hexadecimal mask.\n\n"
282 " Set number of packets per burst.\n\n"
284 "set burst tx delay (microseconds) retry (num)\n"
285 " Set the transmit delay time and number of retries,"
286 " effective when retry is enabled.\n\n"
288 "set txpkts (x[,y]*)\n"
289 " Set the length of each segment of TXONLY"
290 " and optionally CSUM packets.\n\n"
292 "set txsplit (off|on|rand)\n"
293 " Set the split policy for the TX packets."
294 " Right now only applicable for CSUM and TXONLY"
297 "set corelist (x[,y]*)\n"
298 " Set the list of forwarding cores.\n\n"
300 "set portlist (x[,y]*)\n"
301 " Set the list of forwarding ports.\n\n"
303 "set port setup on (iterator|event)\n"
304 " Select how attached port is retrieved for setup.\n\n"
306 "set tx loopback (port_id) (on|off)\n"
307 " Enable or disable tx loopback.\n\n"
309 "set all queues drop (port_id) (on|off)\n"
310 " Set drop enable bit for all queues.\n\n"
312 "set vf split drop (port_id) (vf_id) (on|off)\n"
313 " Set split drop enable bit for a VF from the PF.\n\n"
315 "set vf mac antispoof (port_id) (vf_id) (on|off).\n"
316 " Set MAC antispoof for a VF from the PF.\n\n"
318 "set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n"
319 " Enable MACsec offload.\n\n"
321 "set macsec offload (port_id) off\n"
322 " Disable MACsec offload.\n\n"
324 "set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
325 " Configure MACsec secure connection (SC).\n\n"
327 "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n"
328 " Configure MACsec secure association (SA).\n\n"
330 "set vf broadcast (port_id) (vf_id) (on|off)\n"
331 " Set VF broadcast for a VF from the PF.\n\n"
333 "vlan set stripq (on|off) (port_id,queue_id)\n"
334 " Set the VLAN strip for a queue on a port.\n\n"
336 "set vf vlan stripq (port_id) (vf_id) (on|off)\n"
337 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
339 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
340 " Set VLAN insert for a VF from the PF.\n\n"
342 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
343 " Set VLAN antispoof for a VF from the PF.\n\n"
345 "set vf vlan tag (port_id) (vf_id) (on|off)\n"
346 " Set VLAN tag for a VF from the PF.\n\n"
348 "set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n"
349 " Set a VF's max bandwidth(Mbps).\n\n"
351 "set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n"
352 " Set all TCs' min bandwidth(%%) on a VF.\n\n"
354 "set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n"
355 " Set a TC's max bandwidth(Mbps) on a VF.\n\n"
357 "set tx strict-link-priority (port_id) (tc_bitmap)\n"
358 " Set some TCs' strict link priority mode on a physical port.\n\n"
360 "set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n"
361 " Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n"
363 "vlan set (strip|filter|qinq_strip|extend) (on|off) (port_id)\n"
364 " Set the VLAN strip or filter or qinq strip or extend\n\n"
366 "vlan set (inner|outer) tpid (value) (port_id)\n"
367 " Set the VLAN TPID for Packet Filtering on"
370 "rx_vlan add (vlan_id|all) (port_id)\n"
371 " Add a vlan_id, or all identifiers, to the set"
372 " of VLAN identifiers filtered by port_id.\n\n"
374 "rx_vlan rm (vlan_id|all) (port_id)\n"
375 " Remove a vlan_id, or all identifiers, from the set"
376 " of VLAN identifiers filtered by port_id.\n\n"
378 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
379 " Add a vlan_id, to the set of VLAN identifiers"
380 "filtered for VF(s) from port_id.\n\n"
382 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
383 " Remove a vlan_id, to the set of VLAN identifiers"
384 "filtered for VF(s) from port_id.\n\n"
386 "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) "
387 "(inner_vlan) (vxlan|nvgre|ipingre|vxlan-gpe) (imac-ivlan|imac-ivlan-tenid|"
388 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
389 " add a tunnel filter of a port.\n\n"
391 "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) "
392 "(inner_vlan) (vxlan|nvgre|ipingre|vxlan-gpe) (imac-ivlan|imac-ivlan-tenid|"
393 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
394 " remove a tunnel filter of a port.\n\n"
396 "rx_vxlan_port add (udp_port) (port_id)\n"
397 " Add an UDP port for VXLAN packet filter on a port\n\n"
399 "rx_vxlan_port rm (udp_port) (port_id)\n"
400 " Remove an UDP port for VXLAN packet filter on a port\n\n"
402 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
403 " Set hardware insertion of VLAN IDs (single or double VLAN "
404 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
406 "tx_vlan set pvid port_id vlan_id (on|off)\n"
407 " Set port based TX VLAN insertion.\n\n"
409 "tx_vlan reset (port_id)\n"
410 " Disable hardware insertion of a VLAN header in"
411 " packets sent on a port.\n\n"
413 "csum set (ip|udp|tcp|sctp|outer-ip|outer-udp) (hw|sw) (port_id)\n"
414 " Select hardware or software calculation of the"
415 " checksum when transmitting a packet using the"
416 " csum forward engine.\n"
417 " ip|udp|tcp|sctp always concern the inner layer.\n"
418 " outer-ip concerns the outer IP layer in"
419 " outer-udp concerns the outer UDP layer in"
420 " case the packet is recognized as a tunnel packet by"
421 " the forward engine (vxlan, gre and ipip are supported)\n"
422 " Please check the NIC datasheet for HW limits.\n\n"
424 "csum parse-tunnel (on|off) (tx_port_id)\n"
425 " If disabled, treat tunnel packets as non-tunneled"
426 " packets (treat inner headers as payload). The port\n"
427 " argument is the port used for TX in csum forward"
430 "csum show (port_id)\n"
431 " Display tx checksum offload configuration\n\n"
433 "tso set (segsize) (portid)\n"
434 " Enable TCP Segmentation Offload in csum forward"
436 " Please check the NIC datasheet for HW limits.\n\n"
439 " Display the status of TCP Segmentation Offload.\n\n"
441 "set port (port_id) gro on|off\n"
442 " Enable or disable Generic Receive Offload in"
443 " csum forwarding engine.\n\n"
445 "show port (port_id) gro\n"
446 " Display GRO configuration.\n\n"
448 "set gro flush (cycles)\n"
449 " Set the cycle to flush GROed packets from"
450 " reassembly tables.\n\n"
452 "set port (port_id) gso (on|off)"
453 " Enable or disable Generic Segmentation Offload in"
454 " csum forwarding engine.\n\n"
456 "set gso segsz (length)\n"
457 " Set max packet length for output GSO segments,"
458 " including packet header and payload.\n\n"
460 "show port (port_id) gso\n"
461 " Show GSO configuration.\n\n"
464 " Set packet forwarding mode.\n\n"
466 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
467 " Add a MAC address on port_id.\n\n"
469 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
470 " Remove a MAC address from port_id.\n\n"
472 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
473 " Set the default MAC address for port_id.\n\n"
475 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
476 " Add a MAC address for a VF on the port.\n\n"
478 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
479 " Set the MAC address for a VF from the PF.\n\n"
481 "set eth-peer (port_id) (peer_addr)\n"
482 " set the peer address for certain port.\n\n"
484 "set port (port_id) uta (mac_address|all) (on|off)\n"
485 " Add/Remove a or all unicast hash filter(s)"
488 "set promisc (port_id|all) (on|off)\n"
489 " Set the promiscuous mode on port_id, or all.\n\n"
491 "set allmulti (port_id|all) (on|off)\n"
492 " Set the allmulti mode on port_id, or all.\n\n"
494 "set vf promisc (port_id) (vf_id) (on|off)\n"
495 " Set unicast promiscuous mode for a VF from the PF.\n\n"
497 "set vf allmulti (port_id) (vf_id) (on|off)\n"
498 " Set multicast promiscuous mode for a VF from the PF.\n\n"
500 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
501 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
502 " (on|off) autoneg (on|off) (port_id)\n"
503 "set flow_ctrl rx (on|off) (portid)\n"
504 "set flow_ctrl tx (on|off) (portid)\n"
505 "set flow_ctrl high_water (high_water) (portid)\n"
506 "set flow_ctrl low_water (low_water) (portid)\n"
507 "set flow_ctrl pause_time (pause_time) (portid)\n"
508 "set flow_ctrl send_xon (send_xon) (portid)\n"
509 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
510 "set flow_ctrl autoneg (on|off) (port_id)\n"
511 " Set the link flow control parameter on a port.\n\n"
513 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
514 " (low_water) (pause_time) (priority) (port_id)\n"
515 " Set the priority flow control parameter on a"
518 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
519 " Set statistics mapping (qmapping 0..15) for RX/TX"
521 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
522 " on port 0 to mapping 5.\n\n"
524 "set xstats-hide-zero on|off\n"
525 " Set the option to hide the zero values"
526 " for xstats display.\n"
528 "set port (port_id) vf (vf_id) rx|tx on|off\n"
529 " Enable/Disable a VF receive/tranmit from a port\n\n"
531 "set port (port_id) vf (vf_id) (mac_addr)"
532 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
533 " Add/Remove unicast or multicast MAC addr filter"
536 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
538 " AUPE:accepts untagged VLAN;"
539 "ROPE:accept unicast hash\n\n"
540 " BAM:accepts broadcast packets;"
541 "MPE:accepts all multicast packets\n\n"
542 " Enable/Disable a VF receive mode of a port\n\n"
544 "set port (port_id) queue (queue_id) rate (rate_num)\n"
545 " Set rate limit for a queue of a port\n\n"
547 "set port (port_id) vf (vf_id) rate (rate_num) "
548 "queue_mask (queue_mask_value)\n"
549 " Set rate limit for queues in VF of a port\n\n"
551 "set port (port_id) mirror-rule (rule_id)"
552 " (pool-mirror-up|pool-mirror-down|vlan-mirror)"
553 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
554 " Set pool or vlan type mirror rule on a port.\n"
555 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
556 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
559 "set port (port_id) mirror-rule (rule_id)"
560 " (uplink-mirror|downlink-mirror) dst-pool"
561 " (pool_id) (on|off)\n"
562 " Set uplink or downlink type mirror rule on a port.\n"
563 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
564 " 0 on' enable mirror income traffic to pool 0.\n\n"
566 "reset port (port_id) mirror-rule (rule_id)\n"
567 " Reset a mirror rule.\n\n"
569 "set flush_rx (on|off)\n"
570 " Flush (default) or don't flush RX streams before"
571 " forwarding. Mainly used with PCAP drivers.\n\n"
573 "set bypass mode (normal|bypass|isolate) (port_id)\n"
574 " Set the bypass mode for the lowest port on bypass enabled"
577 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
578 "mode (normal|bypass|isolate) (port_id)\n"
579 " Set the event required to initiate specified bypass mode for"
580 " the lowest port on a bypass enabled NIC where:\n"
581 " timeout = enable bypass after watchdog timeout.\n"
582 " os_on = enable bypass when OS/board is powered on.\n"
583 " os_off = enable bypass when OS/board is powered off.\n"
584 " power_on = enable bypass when power supply is turned on.\n"
585 " power_off = enable bypass when power supply is turned off."
588 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
589 " Set the bypass watchdog timeout to 'n' seconds"
590 " where 0 = instant.\n\n"
592 "show bypass config (port_id)\n"
593 " Show the bypass configuration for a bypass enabled NIC"
594 " using the lowest port on the NIC.\n\n"
596 #ifdef RTE_LIBRTE_PMD_BOND
597 "create bonded device (mode) (socket)\n"
598 " Create a new bonded device with specific bonding mode and socket.\n\n"
600 "add bonding slave (slave_id) (port_id)\n"
601 " Add a slave device to a bonded device.\n\n"
603 "remove bonding slave (slave_id) (port_id)\n"
604 " Remove a slave device from a bonded device.\n\n"
606 "set bonding mode (value) (port_id)\n"
607 " Set the bonding mode on a bonded device.\n\n"
609 "set bonding primary (slave_id) (port_id)\n"
610 " Set the primary slave for a bonded device.\n\n"
612 "show bonding config (port_id)\n"
613 " Show the bonding config for port_id.\n\n"
615 "set bonding mac_addr (port_id) (address)\n"
616 " Set the MAC address of a bonded device.\n\n"
618 "set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)"
619 " Set Aggregation mode for IEEE802.3AD (mode 4)"
621 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
622 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
624 "set bonding mon_period (port_id) (value)\n"
625 " Set the bonding link status monitoring polling period in ms.\n\n"
627 "set bonding lacp dedicated_queues <port_id> (enable|disable)\n"
628 " Enable/disable dedicated queues for LACP control traffic.\n\n"
631 "set link-up port (port_id)\n"
632 " Set link up for a port.\n\n"
634 "set link-down port (port_id)\n"
635 " Set link down for a port.\n\n"
637 "E-tag set insertion on port-tag-id (value)"
638 " port (port_id) vf (vf_id)\n"
639 " Enable E-tag insertion for a VF on a port\n\n"
641 "E-tag set insertion off port (port_id) vf (vf_id)\n"
642 " Disable E-tag insertion for a VF on a port\n\n"
644 "E-tag set stripping (on|off) port (port_id)\n"
645 " Enable/disable E-tag stripping on a port\n\n"
647 "E-tag set forwarding (on|off) port (port_id)\n"
648 " Enable/disable E-tag based forwarding"
651 "E-tag set filter add e-tag-id (value) dst-pool"
652 " (pool_id) port (port_id)\n"
653 " Add an E-tag forwarding filter on a port\n\n"
655 "E-tag set filter del e-tag-id (value) port (port_id)\n"
656 " Delete an E-tag forwarding filter on a port\n\n"
658 "ddp add (port_id) (profile_path[,backup_profile_path])\n"
659 " Load a profile package on a port\n\n"
661 "ddp del (port_id) (backup_profile_path)\n"
662 " Delete a profile package from a port\n\n"
664 "ptype mapping get (port_id) (valid_only)\n"
665 " Get ptype mapping on a port\n\n"
667 "ptype mapping replace (port_id) (target) (mask) (pky_type)\n"
668 " Replace target with the pkt_type in ptype mapping\n\n"
670 "ptype mapping reset (port_id)\n"
671 " Reset ptype mapping on a port\n\n"
673 "ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n"
674 " Update a ptype mapping item on a port\n\n"
676 "set port (port_id) ptype_mask (ptype_mask)\n"
677 " set packet types classification for a specific port\n\n"
679 "set port (port_id) queue-region region_id (value) "
680 "queue_start_index (value) queue_num (value)\n"
681 " Set a queue region on a port\n\n"
683 "set port (port_id) queue-region region_id (value) "
685 " Set a flowtype region index on a port\n\n"
687 "set port (port_id) queue-region UP (value) region_id (value)\n"
688 " Set the mapping of User Priority to "
689 "queue region on a port\n\n"
691 "set port (port_id) queue-region flush (on|off)\n"
692 " flush all queue region related configuration\n\n"
694 "show port meter cap (port_id)\n"
695 " Show port meter capability information\n\n"
697 "add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs)\n"
698 " meter profile add - srtcm rfc 2697\n\n"
700 "add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs)\n"
701 " meter profile add - trtcm rfc 2698\n\n"
703 "add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs)\n"
704 " meter profile add - trtcm rfc 4115\n\n"
706 "del port meter profile (port_id) (profile_id)\n"
707 " meter profile delete\n\n"
709 "create port meter (port_id) (mtr_id) (profile_id) (meter_enable)\n"
710 "(g_action) (y_action) (r_action) (stats_mask) (shared)\n"
711 "(use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n"
712 "(dscp_tbl_entry63)]\n"
715 "enable port meter (port_id) (mtr_id)\n"
718 "disable port meter (port_id) (mtr_id)\n"
721 "del port meter (port_id) (mtr_id)\n"
724 "set port meter profile (port_id) (mtr_id) (profile_id)\n"
725 " meter update meter profile\n\n"
727 "set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n"
728 "(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n"
729 " update meter dscp table entries\n\n"
731 "set port meter policer action (port_id) (mtr_id) (action_mask)\n"
732 "(action0) [(action1) (action2)]\n"
733 " meter update policer action\n\n"
735 "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
736 " meter update stats\n\n"
738 "show port (port_id) queue-region\n"
739 " show all queue region related configuration info\n\n"
741 , list_pkt_forwarding_modes()
745 if (show_all || !strcmp(res->section, "ports")) {
751 "----------------\n\n"
753 "port start (port_id|all)\n"
754 " Start all ports or port_id.\n\n"
756 "port stop (port_id|all)\n"
757 " Stop all ports or port_id.\n\n"
759 "port close (port_id|all)\n"
760 " Close all ports or port_id.\n\n"
762 "port reset (port_id|all)\n"
763 " Reset all ports or port_id.\n\n"
765 "port attach (ident)\n"
766 " Attach physical or virtual dev by pci address or virtual device name\n\n"
768 "port detach (port_id)\n"
769 " Detach physical or virtual dev by port_id\n\n"
771 "port config (port_id|all)"
772 " speed (10|100|1000|10000|25000|40000|50000|100000|auto)"
773 " duplex (half|full|auto)\n"
774 " Set speed and duplex for all ports or port_id\n\n"
776 "port config (port_id|all) loopback (mode)\n"
777 " Set loopback mode for all ports or port_id\n\n"
779 "port config all (rxq|txq|rxd|txd) (value)\n"
780 " Set number for rxq/txq/rxd/txd.\n\n"
782 "port config all max-pkt-len (value)\n"
783 " Set the max packet length.\n\n"
785 "port config all max-lro-pkt-size (value)\n"
786 " Set the max LRO aggregated packet size.\n\n"
788 "port config all drop-en (on|off)\n"
789 " Enable or disable packet drop on all RX queues of all ports when no "
790 "receive buffers available.\n\n"
792 "port config all rss (all|default|ip|tcp|udp|sctp|"
793 "ether|port|vxlan|geneve|nvgre|vxlan-gpe|none|<flowtype_id>)\n"
794 " Set the RSS mode.\n\n"
796 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
797 " Set the RSS redirection table.\n\n"
799 "port config (port_id) dcb vt (on|off) (traffic_class)"
801 " Set the DCB mode.\n\n"
803 "port config all burst (value)\n"
804 " Set the number of packets per burst.\n\n"
806 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
808 " Set the ring prefetch/host/writeback threshold"
809 " for tx/rx queue.\n\n"
811 "port config all (txfreet|txrst|rxfreet) (value)\n"
812 " Set free threshold for rx/tx, or set"
813 " tx rs bit threshold.\n\n"
814 "port config mtu X value\n"
815 " Set the MTU of port X to a given value\n\n"
817 "port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n"
818 " Set a rx/tx queue's ring size configuration, the new"
819 " value will take effect after command that (re-)start the port"
820 " or command that setup the specific queue\n\n"
822 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
823 " Start/stop a rx/tx queue of port X. Only take effect"
824 " when port X is started\n\n"
826 "port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n"
827 " Switch on/off a deferred start of port X rx/tx queue. Only"
828 " take effect when port X is stopped.\n\n"
830 "port (port_id) (rxq|txq) (queue_id) setup\n"
831 " Setup a rx/tx queue of port X.\n\n"
833 "port config (port_id|all) l2-tunnel E-tag ether-type"
835 " Set the value of E-tag ether-type.\n\n"
837 "port config (port_id|all) l2-tunnel E-tag"
838 " (enable|disable)\n"
839 " Enable/disable the E-tag support.\n\n"
841 "port config (port_id) pctype mapping reset\n"
842 " Reset flow type to pctype mapping on a port\n\n"
844 "port config (port_id) pctype mapping update"
845 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
846 " Update a flow type to pctype mapping item on a port\n\n"
848 "port config (port_id) pctype (pctype_id) hash_inset|"
849 "fdir_inset|fdir_flx_inset get|set|clear field\n"
851 " Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n"
853 "port config (port_id) pctype (pctype_id) hash_inset|"
854 "fdir_inset|fdir_flx_inset clear all"
855 " Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n"
857 "port config (port_id) udp_tunnel_port add|rm vxlan|geneve (udp_port)\n\n"
858 " Add/remove UDP tunnel port for tunneling offload\n\n"
860 "port config <port_id> rx_offload vlan_strip|"
861 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
862 "outer_ipv4_cksum|macsec_strip|header_split|"
863 "vlan_filter|vlan_extend|jumbo_frame|"
864 "scatter|timestamp|security|keep_crc on|off\n"
865 " Enable or disable a per port Rx offloading"
866 " on all Rx queues of a port\n\n"
868 "port (port_id) rxq (queue_id) rx_offload vlan_strip|"
869 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
870 "outer_ipv4_cksum|macsec_strip|header_split|"
871 "vlan_filter|vlan_extend|jumbo_frame|"
872 "scatter|timestamp|security|keep_crc on|off\n"
873 " Enable or disable a per queue Rx offloading"
874 " only on a specific Rx queue\n\n"
876 "port config (port_id) tx_offload vlan_insert|"
877 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
878 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
879 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|"
880 "macsec_insert|mt_lockfree|multi_segs|mbuf_fast_free|"
882 " Enable or disable a per port Tx offloading"
883 " on all Tx queues of a port\n\n"
885 "port (port_id) txq (queue_id) tx_offload vlan_insert|"
886 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
887 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
888 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|macsec_insert"
889 "|mt_lockfree|multi_segs|mbuf_fast_free|security"
891 " Enable or disable a per queue Tx offloading"
892 " only on a specific Tx queue\n\n"
894 "bpf-load rx|tx (port) (queue) (J|M|B) (file_name)\n"
895 " Load an eBPF program as a callback"
896 " for particular RX/TX queue\n\n"
898 "bpf-unload rx|tx (port) (queue)\n"
899 " Unload previously loaded eBPF program"
900 " for particular RX/TX queue\n\n"
902 "port config (port_id) tx_metadata (value)\n"
903 " Set Tx metadata value per port. Testpmd will add this value"
904 " to any Tx packet sent from this port\n\n"
906 "port config (port_id) dynf (name) set|clear\n"
907 " Register a dynf and Set/clear this flag on Tx. "
908 "Testpmd will set this value to any Tx packet "
909 "sent from this port\n\n"
913 if (show_all || !strcmp(res->section, "registers")) {
921 "read reg (port_id) (address)\n"
922 " Display value of a port register.\n\n"
924 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
925 " Display a port register bit field.\n\n"
927 "read regbit (port_id) (address) (bit_x)\n"
928 " Display a single port register bit.\n\n"
930 "write reg (port_id) (address) (value)\n"
931 " Set value of a port register.\n\n"
933 "write regfield (port_id) (address) (bit_x) (bit_y)"
935 " Set bit field of a port register.\n\n"
937 "write regbit (port_id) (address) (bit_x) (value)\n"
938 " Set single bit value of a port register.\n\n"
941 if (show_all || !strcmp(res->section, "filters")) {
949 "ethertype_filter (port_id) (add|del)"
950 " (mac_addr|mac_ignr) (mac_address) ethertype"
951 " (ether_type) (drop|fwd) queue (queue_id)\n"
952 " Add/Del an ethertype filter.\n\n"
954 "2tuple_filter (port_id) (add|del)"
955 " dst_port (dst_port_value) protocol (protocol_value)"
956 " mask (mask_value) tcp_flags (tcp_flags_value)"
957 " priority (prio_value) queue (queue_id)\n"
958 " Add/Del a 2tuple filter.\n\n"
960 "5tuple_filter (port_id) (add|del)"
961 " dst_ip (dst_address) src_ip (src_address)"
962 " dst_port (dst_port_value) src_port (src_port_value)"
963 " protocol (protocol_value)"
964 " mask (mask_value) tcp_flags (tcp_flags_value)"
965 " priority (prio_value) queue (queue_id)\n"
966 " Add/Del a 5tuple filter.\n\n"
968 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
969 " Add/Del syn filter.\n\n"
971 "flex_filter (port_id) (add|del) len (len_value)"
972 " bytes (bytes_value) mask (mask_value)"
973 " priority (prio_value) queue (queue_id)\n"
974 " Add/Del a flex filter.\n\n"
976 "flow_director_filter (port_id) mode IP (add|del|update)"
977 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
978 " src (src_ip_address) dst (dst_ip_address)"
979 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
980 " vlan (vlan_value) flexbytes (flexbytes_value)"
981 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
982 " fd_id (fd_id_value)\n"
983 " Add/Del an IP type flow director filter.\n\n"
985 "flow_director_filter (port_id) mode IP (add|del|update)"
986 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
987 " src (src_ip_address) (src_port)"
988 " dst (dst_ip_address) (dst_port)"
989 " tos (tos_value) ttl (ttl_value)"
990 " vlan (vlan_value) flexbytes (flexbytes_value)"
991 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
992 " fd_id (fd_id_value)\n"
993 " Add/Del an UDP/TCP type flow director filter.\n\n"
995 "flow_director_filter (port_id) mode IP (add|del|update)"
996 " flow (ipv4-sctp|ipv6-sctp)"
997 " src (src_ip_address) (src_port)"
998 " dst (dst_ip_address) (dst_port)"
999 " tag (verification_tag) "
1000 " tos (tos_value) ttl (ttl_value)"
1001 " vlan (vlan_value)"
1002 " flexbytes (flexbytes_value) (drop|fwd)"
1003 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
1004 " Add/Del a SCTP type flow director filter.\n\n"
1006 "flow_director_filter (port_id) mode IP (add|del|update)"
1007 " flow l2_payload ether (ethertype)"
1008 " flexbytes (flexbytes_value) (drop|fwd)"
1009 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
1010 " Add/Del a l2 payload type flow director filter.\n\n"
1012 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
1013 " mac (mac_address) vlan (vlan_value)"
1014 " flexbytes (flexbytes_value) (drop|fwd)"
1015 " queue (queue_id) fd_id (fd_id_value)\n"
1016 " Add/Del a MAC-VLAN flow director filter.\n\n"
1018 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
1019 " mac (mac_address) vlan (vlan_value)"
1020 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
1021 " flexbytes (flexbytes_value) (drop|fwd)"
1022 " queue (queue_id) fd_id (fd_id_value)\n"
1023 " Add/Del a Tunnel flow director filter.\n\n"
1025 "flow_director_filter (port_id) mode raw (add|del|update)"
1026 " flow (flow_id) (drop|fwd) queue (queue_id)"
1027 " fd_id (fd_id_value) packet (packet file name)\n"
1028 " Add/Del a raw type flow director filter.\n\n"
1030 "flush_flow_director (port_id)\n"
1031 " Flush all flow director entries of a device.\n\n"
1033 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
1034 " src_mask (ipv4_src) (ipv6_src) (src_port)"
1035 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
1036 " Set flow director IP mask.\n\n"
1038 "flow_director_mask (port_id) mode MAC-VLAN"
1039 " vlan (vlan_value)\n"
1040 " Set flow director MAC-VLAN mask.\n\n"
1042 "flow_director_mask (port_id) mode Tunnel"
1043 " vlan (vlan_value) mac (mac_value)"
1044 " tunnel-type (tunnel_type_value)"
1045 " tunnel-id (tunnel_id_value)\n"
1046 " Set flow director Tunnel mask.\n\n"
1048 "flow_director_flex_mask (port_id)"
1049 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
1050 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
1052 " Configure mask of flex payload.\n\n"
1054 "flow_director_flex_payload (port_id)"
1055 " (raw|l2|l3|l4) (config)\n"
1056 " Configure flex payload selection.\n\n"
1058 "get_sym_hash_ena_per_port (port_id)\n"
1059 " get symmetric hash enable configuration per port.\n\n"
1061 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
1062 " set symmetric hash enable configuration per port"
1063 " to enable or disable.\n\n"
1065 "get_hash_global_config (port_id)\n"
1066 " Get the global configurations of hash filters.\n\n"
1068 "set_hash_global_config (port_id) (toeplitz|simple_xor|symmetric_toeplitz|default)"
1069 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1070 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
1071 " (enable|disable)\n"
1072 " Set the global configurations of hash filters.\n\n"
1074 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
1075 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1076 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1077 "l2_payload|<flowtype_id>) (ovlan|ivlan|src-ipv4|dst-ipv4|"
1078 "src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
1079 "ipv6-next-header|udp-src-port|udp-dst-port|"
1080 "tcp-src-port|tcp-dst-port|sctp-src-port|"
1081 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
1082 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
1083 "fld-8th|none) (select|add)\n"
1084 " Set the input set for hash.\n\n"
1086 "set_fdir_input_set (port_id) "
1087 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1088 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1089 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
1090 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
1091 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
1092 "udp-dst-port|tcp-src-port|tcp-dst-port|"
1093 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
1095 " Set the input set for FDir.\n\n"
1097 "flow validate {port_id}"
1098 " [group {group_id}] [priority {level}]"
1099 " [ingress] [egress]"
1100 " pattern {item} [/ {item} [...]] / end"
1101 " actions {action} [/ {action} [...]] / end\n"
1102 " Check whether a flow rule can be created.\n\n"
1104 "flow create {port_id}"
1105 " [group {group_id}] [priority {level}]"
1106 " [ingress] [egress]"
1107 " pattern {item} [/ {item} [...]] / end"
1108 " actions {action} [/ {action} [...]] / end\n"
1109 " Create a flow rule.\n\n"
1111 "flow destroy {port_id} rule {rule_id} [...]\n"
1112 " Destroy specific flow rules.\n\n"
1114 "flow flush {port_id}\n"
1115 " Destroy all flow rules.\n\n"
1117 "flow query {port_id} {rule_id} {action}\n"
1118 " Query an existing flow rule.\n\n"
1120 "flow list {port_id} [group {group_id}] [...]\n"
1121 " List existing flow rules sorted by priority,"
1122 " filtered by group identifiers.\n\n"
1124 "flow isolate {port_id} {boolean}\n"
1125 " Restrict ingress traffic to the defined"
1128 "set vxlan ip-version (ipv4|ipv6) vni (vni) udp-src"
1129 " (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst"
1130 " (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n"
1131 " Configure the VXLAN encapsulation for flows.\n\n"
1133 "set vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)"
1134 " udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)"
1135 " ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)"
1136 " eth-dst (eth-dst)\n"
1137 " Configure the VXLAN encapsulation for flows.\n\n"
1139 "set vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src"
1140 " (udp-src) udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl)"
1141 " ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src)"
1142 " eth-dst (eth-dst)\n"
1143 " Configure the VXLAN encapsulation for flows.\n\n"
1145 "set nvgre ip-version (ipv4|ipv6) tni (tni) ip-src"
1146 " (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst"
1148 " Configure the NVGRE encapsulation for flows.\n\n"
1150 "set nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)"
1151 " ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)"
1152 " eth-src (eth-src) eth-dst (eth-dst)\n"
1153 " Configure the NVGRE encapsulation for flows.\n\n"
1155 "set raw_encap {flow items}\n"
1156 " Configure the encapsulation with raw data.\n\n"
1158 "set raw_decap {flow items}\n"
1159 " Configure the decapsulation with raw data.\n\n"
1164 if (show_all || !strcmp(res->section, "traffic_management")) {
1168 "Traffic Management:\n"
1170 "show port tm cap (port_id)\n"
1171 " Display the port TM capability.\n\n"
1173 "show port tm level cap (port_id) (level_id)\n"
1174 " Display the port TM hierarchical level capability.\n\n"
1176 "show port tm node cap (port_id) (node_id)\n"
1177 " Display the port TM node capability.\n\n"
1179 "show port tm node type (port_id) (node_id)\n"
1180 " Display the port TM node type.\n\n"
1182 "show port tm node stats (port_id) (node_id) (clear)\n"
1183 " Display the port TM node stats.\n\n"
1185 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
1186 "set port tm hierarchy default (port_id)\n"
1187 " Set default traffic Management hierarchy on a port\n\n"
1190 "add port tm node shaper profile (port_id) (shaper_profile_id)"
1191 " (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)"
1192 " (packet_length_adjust)\n"
1193 " Add port tm node private shaper profile.\n\n"
1195 "del port tm node shaper profile (port_id) (shaper_profile_id)\n"
1196 " Delete port tm node private shaper profile.\n\n"
1198 "add port tm node shared shaper (port_id) (shared_shaper_id)"
1199 " (shaper_profile_id)\n"
1200 " Add/update port tm node shared shaper.\n\n"
1202 "del port tm node shared shaper (port_id) (shared_shaper_id)\n"
1203 " Delete port tm node shared shaper.\n\n"
1205 "set port tm node shaper profile (port_id) (node_id)"
1206 " (shaper_profile_id)\n"
1207 " Set port tm node shaper profile.\n\n"
1209 "add port tm node wred profile (port_id) (wred_profile_id)"
1210 " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
1211 " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
1212 " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
1213 " Add port tm node wred profile.\n\n"
1215 "del port tm node wred profile (port_id) (wred_profile_id)\n"
1216 " Delete port tm node wred profile.\n\n"
1218 "add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
1219 " (priority) (weight) (level_id) (shaper_profile_id)"
1220 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1221 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1222 " Add port tm nonleaf node.\n\n"
1224 "add port tm leaf node (port_id) (node_id) (parent_node_id)"
1225 " (priority) (weight) (level_id) (shaper_profile_id)"
1226 " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
1227 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1228 " Add port tm leaf node.\n\n"
1230 "del port tm node (port_id) (node_id)\n"
1231 " Delete port tm node.\n\n"
1233 "set port tm node parent (port_id) (node_id) (parent_node_id)"
1234 " (priority) (weight)\n"
1235 " Set port tm node parent.\n\n"
1237 "suspend port tm node (port_id) (node_id)"
1238 " Suspend tm node.\n\n"
1240 "resume port tm node (port_id) (node_id)"
1241 " Resume tm node.\n\n"
1243 "port tm hierarchy commit (port_id) (clean_on_fail)\n"
1244 " Commit tm hierarchy.\n\n"
1246 "set port tm mark ip_ecn (port) (green) (yellow)"
1248 " Enables/Disables the traffic management marking"
1249 " for IP ECN (Explicit Congestion Notification)"
1250 " packets on a given port\n\n"
1252 "set port tm mark ip_dscp (port) (green) (yellow)"
1254 " Enables/Disables the traffic management marking"
1255 " on the port for IP dscp packets\n\n"
1257 "set port tm mark vlan_dei (port) (green) (yellow)"
1259 " Enables/Disables the traffic management marking"
1260 " on the port for VLAN packets with DEI enabled\n\n"
1264 if (show_all || !strcmp(res->section, "devices")) {
1268 "Device Operations:\n"
1270 "device detach (identifier)\n"
1271 " Detach device by identifier.\n\n"
1277 cmdline_parse_token_string_t cmd_help_long_help =
1278 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1280 cmdline_parse_token_string_t cmd_help_long_section =
1281 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1282 "all#control#display#config#"
1283 "ports#registers#filters#traffic_management#devices");
1285 cmdline_parse_inst_t cmd_help_long = {
1286 .f = cmd_help_long_parsed,
1288 .help_str = "help all|control|display|config|ports|register|"
1289 "filters|traffic_management|devices: "
1292 (void *)&cmd_help_long_help,
1293 (void *)&cmd_help_long_section,
1299 /* *** start/stop/close all ports *** */
1300 struct cmd_operate_port_result {
1301 cmdline_fixed_string_t keyword;
1302 cmdline_fixed_string_t name;
1303 cmdline_fixed_string_t value;
1306 static void cmd_operate_port_parsed(void *parsed_result,
1307 __attribute__((unused)) struct cmdline *cl,
1308 __attribute__((unused)) void *data)
1310 struct cmd_operate_port_result *res = parsed_result;
1312 if (!strcmp(res->name, "start"))
1313 start_port(RTE_PORT_ALL);
1314 else if (!strcmp(res->name, "stop"))
1315 stop_port(RTE_PORT_ALL);
1316 else if (!strcmp(res->name, "close"))
1317 close_port(RTE_PORT_ALL);
1318 else if (!strcmp(res->name, "reset"))
1319 reset_port(RTE_PORT_ALL);
1321 printf("Unknown parameter\n");
1324 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1325 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1327 cmdline_parse_token_string_t cmd_operate_port_all_port =
1328 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1329 "start#stop#close#reset");
1330 cmdline_parse_token_string_t cmd_operate_port_all_all =
1331 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1333 cmdline_parse_inst_t cmd_operate_port = {
1334 .f = cmd_operate_port_parsed,
1336 .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports",
1338 (void *)&cmd_operate_port_all_cmd,
1339 (void *)&cmd_operate_port_all_port,
1340 (void *)&cmd_operate_port_all_all,
1345 /* *** start/stop/close specific port *** */
1346 struct cmd_operate_specific_port_result {
1347 cmdline_fixed_string_t keyword;
1348 cmdline_fixed_string_t name;
1352 static void cmd_operate_specific_port_parsed(void *parsed_result,
1353 __attribute__((unused)) struct cmdline *cl,
1354 __attribute__((unused)) void *data)
1356 struct cmd_operate_specific_port_result *res = parsed_result;
1358 if (!strcmp(res->name, "start"))
1359 start_port(res->value);
1360 else if (!strcmp(res->name, "stop"))
1361 stop_port(res->value);
1362 else if (!strcmp(res->name, "close"))
1363 close_port(res->value);
1364 else if (!strcmp(res->name, "reset"))
1365 reset_port(res->value);
1367 printf("Unknown parameter\n");
1370 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1371 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1373 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1374 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1375 name, "start#stop#close#reset");
1376 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1377 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1380 cmdline_parse_inst_t cmd_operate_specific_port = {
1381 .f = cmd_operate_specific_port_parsed,
1383 .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id",
1385 (void *)&cmd_operate_specific_port_cmd,
1386 (void *)&cmd_operate_specific_port_port,
1387 (void *)&cmd_operate_specific_port_id,
1392 /* *** enable port setup (after attach) via iterator or event *** */
1393 struct cmd_set_port_setup_on_result {
1394 cmdline_fixed_string_t set;
1395 cmdline_fixed_string_t port;
1396 cmdline_fixed_string_t setup;
1397 cmdline_fixed_string_t on;
1398 cmdline_fixed_string_t mode;
1401 static void cmd_set_port_setup_on_parsed(void *parsed_result,
1402 __attribute__((unused)) struct cmdline *cl,
1403 __attribute__((unused)) void *data)
1405 struct cmd_set_port_setup_on_result *res = parsed_result;
1407 if (strcmp(res->mode, "event") == 0)
1408 setup_on_probe_event = true;
1409 else if (strcmp(res->mode, "iterator") == 0)
1410 setup_on_probe_event = false;
1412 printf("Unknown mode\n");
1415 cmdline_parse_token_string_t cmd_set_port_setup_on_set =
1416 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1418 cmdline_parse_token_string_t cmd_set_port_setup_on_port =
1419 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1421 cmdline_parse_token_string_t cmd_set_port_setup_on_setup =
1422 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1424 cmdline_parse_token_string_t cmd_set_port_setup_on_on =
1425 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1427 cmdline_parse_token_string_t cmd_set_port_setup_on_mode =
1428 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1429 mode, "iterator#event");
1431 cmdline_parse_inst_t cmd_set_port_setup_on = {
1432 .f = cmd_set_port_setup_on_parsed,
1434 .help_str = "set port setup on iterator|event",
1436 (void *)&cmd_set_port_setup_on_set,
1437 (void *)&cmd_set_port_setup_on_port,
1438 (void *)&cmd_set_port_setup_on_setup,
1439 (void *)&cmd_set_port_setup_on_on,
1440 (void *)&cmd_set_port_setup_on_mode,
1445 /* *** attach a specified port *** */
1446 struct cmd_operate_attach_port_result {
1447 cmdline_fixed_string_t port;
1448 cmdline_fixed_string_t keyword;
1449 cmdline_fixed_string_t identifier;
1452 static void cmd_operate_attach_port_parsed(void *parsed_result,
1453 __attribute__((unused)) struct cmdline *cl,
1454 __attribute__((unused)) void *data)
1456 struct cmd_operate_attach_port_result *res = parsed_result;
1458 if (!strcmp(res->keyword, "attach"))
1459 attach_port(res->identifier);
1461 printf("Unknown parameter\n");
1464 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1465 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1467 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1468 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1470 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1471 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1474 cmdline_parse_inst_t cmd_operate_attach_port = {
1475 .f = cmd_operate_attach_port_parsed,
1477 .help_str = "port attach <identifier>: "
1478 "(identifier: pci address or virtual dev name)",
1480 (void *)&cmd_operate_attach_port_port,
1481 (void *)&cmd_operate_attach_port_keyword,
1482 (void *)&cmd_operate_attach_port_identifier,
1487 /* *** detach a specified port *** */
1488 struct cmd_operate_detach_port_result {
1489 cmdline_fixed_string_t port;
1490 cmdline_fixed_string_t keyword;
1494 static void cmd_operate_detach_port_parsed(void *parsed_result,
1495 __attribute__((unused)) struct cmdline *cl,
1496 __attribute__((unused)) void *data)
1498 struct cmd_operate_detach_port_result *res = parsed_result;
1500 if (!strcmp(res->keyword, "detach"))
1501 detach_port_device(res->port_id);
1503 printf("Unknown parameter\n");
1506 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1507 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1509 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1510 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1512 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1513 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1516 cmdline_parse_inst_t cmd_operate_detach_port = {
1517 .f = cmd_operate_detach_port_parsed,
1519 .help_str = "port detach <port_id>",
1521 (void *)&cmd_operate_detach_port_port,
1522 (void *)&cmd_operate_detach_port_keyword,
1523 (void *)&cmd_operate_detach_port_port_id,
1528 /* *** detach device by identifier *** */
1529 struct cmd_operate_detach_device_result {
1530 cmdline_fixed_string_t device;
1531 cmdline_fixed_string_t keyword;
1532 cmdline_fixed_string_t identifier;
1535 static void cmd_operate_detach_device_parsed(void *parsed_result,
1536 __attribute__((unused)) struct cmdline *cl,
1537 __attribute__((unused)) void *data)
1539 struct cmd_operate_detach_device_result *res = parsed_result;
1541 if (!strcmp(res->keyword, "detach"))
1542 detach_device(res->identifier);
1544 printf("Unknown parameter\n");
1547 cmdline_parse_token_string_t cmd_operate_detach_device_device =
1548 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1550 cmdline_parse_token_string_t cmd_operate_detach_device_keyword =
1551 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1553 cmdline_parse_token_string_t cmd_operate_detach_device_identifier =
1554 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1557 cmdline_parse_inst_t cmd_operate_detach_device = {
1558 .f = cmd_operate_detach_device_parsed,
1560 .help_str = "device detach <identifier>:"
1561 "(identifier: pci address or virtual dev name)",
1563 (void *)&cmd_operate_detach_device_device,
1564 (void *)&cmd_operate_detach_device_keyword,
1565 (void *)&cmd_operate_detach_device_identifier,
1569 /* *** configure speed for all ports *** */
1570 struct cmd_config_speed_all {
1571 cmdline_fixed_string_t port;
1572 cmdline_fixed_string_t keyword;
1573 cmdline_fixed_string_t all;
1574 cmdline_fixed_string_t item1;
1575 cmdline_fixed_string_t item2;
1576 cmdline_fixed_string_t value1;
1577 cmdline_fixed_string_t value2;
1581 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1586 if (!strcmp(duplexstr, "half")) {
1587 duplex = ETH_LINK_HALF_DUPLEX;
1588 } else if (!strcmp(duplexstr, "full")) {
1589 duplex = ETH_LINK_FULL_DUPLEX;
1590 } else if (!strcmp(duplexstr, "auto")) {
1591 duplex = ETH_LINK_FULL_DUPLEX;
1593 printf("Unknown duplex parameter\n");
1597 if (!strcmp(speedstr, "10")) {
1598 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1599 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1600 } else if (!strcmp(speedstr, "100")) {
1601 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1602 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1604 if (duplex != ETH_LINK_FULL_DUPLEX) {
1605 printf("Invalid speed/duplex parameters\n");
1608 if (!strcmp(speedstr, "1000")) {
1609 *speed = ETH_LINK_SPEED_1G;
1610 } else if (!strcmp(speedstr, "10000")) {
1611 *speed = ETH_LINK_SPEED_10G;
1612 } else if (!strcmp(speedstr, "25000")) {
1613 *speed = ETH_LINK_SPEED_25G;
1614 } else if (!strcmp(speedstr, "40000")) {
1615 *speed = ETH_LINK_SPEED_40G;
1616 } else if (!strcmp(speedstr, "50000")) {
1617 *speed = ETH_LINK_SPEED_50G;
1618 } else if (!strcmp(speedstr, "100000")) {
1619 *speed = ETH_LINK_SPEED_100G;
1620 } else if (!strcmp(speedstr, "auto")) {
1621 *speed = ETH_LINK_SPEED_AUTONEG;
1623 printf("Unknown speed parameter\n");
1632 cmd_config_speed_all_parsed(void *parsed_result,
1633 __attribute__((unused)) struct cmdline *cl,
1634 __attribute__((unused)) void *data)
1636 struct cmd_config_speed_all *res = parsed_result;
1637 uint32_t link_speed;
1640 if (!all_ports_stopped()) {
1641 printf("Please stop all ports first\n");
1645 if (parse_and_check_speed_duplex(res->value1, res->value2,
1649 RTE_ETH_FOREACH_DEV(pid) {
1650 ports[pid].dev_conf.link_speeds = link_speed;
1653 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1656 cmdline_parse_token_string_t cmd_config_speed_all_port =
1657 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1658 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1659 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1661 cmdline_parse_token_string_t cmd_config_speed_all_all =
1662 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1663 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1664 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1665 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1666 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1667 "10#100#1000#10000#25000#40000#50000#100000#auto");
1668 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1669 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1670 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1671 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1674 cmdline_parse_inst_t cmd_config_speed_all = {
1675 .f = cmd_config_speed_all_parsed,
1677 .help_str = "port config all speed "
1678 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1681 (void *)&cmd_config_speed_all_port,
1682 (void *)&cmd_config_speed_all_keyword,
1683 (void *)&cmd_config_speed_all_all,
1684 (void *)&cmd_config_speed_all_item1,
1685 (void *)&cmd_config_speed_all_value1,
1686 (void *)&cmd_config_speed_all_item2,
1687 (void *)&cmd_config_speed_all_value2,
1692 /* *** configure speed for specific port *** */
1693 struct cmd_config_speed_specific {
1694 cmdline_fixed_string_t port;
1695 cmdline_fixed_string_t keyword;
1697 cmdline_fixed_string_t item1;
1698 cmdline_fixed_string_t item2;
1699 cmdline_fixed_string_t value1;
1700 cmdline_fixed_string_t value2;
1704 cmd_config_speed_specific_parsed(void *parsed_result,
1705 __attribute__((unused)) struct cmdline *cl,
1706 __attribute__((unused)) void *data)
1708 struct cmd_config_speed_specific *res = parsed_result;
1709 uint32_t link_speed;
1711 if (!all_ports_stopped()) {
1712 printf("Please stop all ports first\n");
1716 if (port_id_is_invalid(res->id, ENABLED_WARN))
1719 if (parse_and_check_speed_duplex(res->value1, res->value2,
1723 ports[res->id].dev_conf.link_speeds = link_speed;
1725 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1729 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1730 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1732 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1733 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1735 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1736 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT16);
1737 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1738 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1740 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1741 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1742 "10#100#1000#10000#25000#40000#50000#100000#auto");
1743 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1744 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1746 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1747 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1750 cmdline_parse_inst_t cmd_config_speed_specific = {
1751 .f = cmd_config_speed_specific_parsed,
1753 .help_str = "port config <port_id> speed "
1754 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1757 (void *)&cmd_config_speed_specific_port,
1758 (void *)&cmd_config_speed_specific_keyword,
1759 (void *)&cmd_config_speed_specific_id,
1760 (void *)&cmd_config_speed_specific_item1,
1761 (void *)&cmd_config_speed_specific_value1,
1762 (void *)&cmd_config_speed_specific_item2,
1763 (void *)&cmd_config_speed_specific_value2,
1768 /* *** configure loopback for all ports *** */
1769 struct cmd_config_loopback_all {
1770 cmdline_fixed_string_t port;
1771 cmdline_fixed_string_t keyword;
1772 cmdline_fixed_string_t all;
1773 cmdline_fixed_string_t item;
1778 cmd_config_loopback_all_parsed(void *parsed_result,
1779 __attribute__((unused)) struct cmdline *cl,
1780 __attribute__((unused)) void *data)
1782 struct cmd_config_loopback_all *res = parsed_result;
1785 if (!all_ports_stopped()) {
1786 printf("Please stop all ports first\n");
1790 RTE_ETH_FOREACH_DEV(pid) {
1791 ports[pid].dev_conf.lpbk_mode = res->mode;
1794 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1797 cmdline_parse_token_string_t cmd_config_loopback_all_port =
1798 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1799 cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1800 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1802 cmdline_parse_token_string_t cmd_config_loopback_all_all =
1803 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1804 cmdline_parse_token_string_t cmd_config_loopback_all_item =
1805 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1807 cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1808 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, UINT32);
1810 cmdline_parse_inst_t cmd_config_loopback_all = {
1811 .f = cmd_config_loopback_all_parsed,
1813 .help_str = "port config all loopback <mode>",
1815 (void *)&cmd_config_loopback_all_port,
1816 (void *)&cmd_config_loopback_all_keyword,
1817 (void *)&cmd_config_loopback_all_all,
1818 (void *)&cmd_config_loopback_all_item,
1819 (void *)&cmd_config_loopback_all_mode,
1824 /* *** configure loopback for specific port *** */
1825 struct cmd_config_loopback_specific {
1826 cmdline_fixed_string_t port;
1827 cmdline_fixed_string_t keyword;
1829 cmdline_fixed_string_t item;
1834 cmd_config_loopback_specific_parsed(void *parsed_result,
1835 __attribute__((unused)) struct cmdline *cl,
1836 __attribute__((unused)) void *data)
1838 struct cmd_config_loopback_specific *res = parsed_result;
1840 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1843 if (!port_is_stopped(res->port_id)) {
1844 printf("Please stop port %u first\n", res->port_id);
1848 ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1850 cmd_reconfig_device_queue(res->port_id, 1, 1);
1854 cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1855 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1857 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1858 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1860 cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1861 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1863 cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1864 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1866 cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1867 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1870 cmdline_parse_inst_t cmd_config_loopback_specific = {
1871 .f = cmd_config_loopback_specific_parsed,
1873 .help_str = "port config <port_id> loopback <mode>",
1875 (void *)&cmd_config_loopback_specific_port,
1876 (void *)&cmd_config_loopback_specific_keyword,
1877 (void *)&cmd_config_loopback_specific_id,
1878 (void *)&cmd_config_loopback_specific_item,
1879 (void *)&cmd_config_loopback_specific_mode,
1884 /* *** configure txq/rxq, txd/rxd *** */
1885 struct cmd_config_rx_tx {
1886 cmdline_fixed_string_t port;
1887 cmdline_fixed_string_t keyword;
1888 cmdline_fixed_string_t all;
1889 cmdline_fixed_string_t name;
1894 cmd_config_rx_tx_parsed(void *parsed_result,
1895 __attribute__((unused)) struct cmdline *cl,
1896 __attribute__((unused)) void *data)
1898 struct cmd_config_rx_tx *res = parsed_result;
1900 if (!all_ports_stopped()) {
1901 printf("Please stop all ports first\n");
1904 if (!strcmp(res->name, "rxq")) {
1905 if (!res->value && !nb_txq) {
1906 printf("Warning: Either rx or tx queues should be non zero\n");
1909 if (check_nb_rxq(res->value) != 0)
1911 nb_rxq = res->value;
1913 else if (!strcmp(res->name, "txq")) {
1914 if (!res->value && !nb_rxq) {
1915 printf("Warning: Either rx or tx queues should be non zero\n");
1918 if (check_nb_txq(res->value) != 0)
1920 nb_txq = res->value;
1922 else if (!strcmp(res->name, "rxd")) {
1923 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1924 printf("rxd %d invalid - must be > 0 && <= %d\n",
1925 res->value, RTE_TEST_RX_DESC_MAX);
1928 nb_rxd = res->value;
1929 } else if (!strcmp(res->name, "txd")) {
1930 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1931 printf("txd %d invalid - must be > 0 && <= %d\n",
1932 res->value, RTE_TEST_TX_DESC_MAX);
1935 nb_txd = res->value;
1937 printf("Unknown parameter\n");
1945 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1948 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1949 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1950 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1951 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1952 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1953 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1954 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1955 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1957 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1958 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1960 cmdline_parse_inst_t cmd_config_rx_tx = {
1961 .f = cmd_config_rx_tx_parsed,
1963 .help_str = "port config all rxq|txq|rxd|txd <value>",
1965 (void *)&cmd_config_rx_tx_port,
1966 (void *)&cmd_config_rx_tx_keyword,
1967 (void *)&cmd_config_rx_tx_all,
1968 (void *)&cmd_config_rx_tx_name,
1969 (void *)&cmd_config_rx_tx_value,
1974 /* *** config max packet length *** */
1975 struct cmd_config_max_pkt_len_result {
1976 cmdline_fixed_string_t port;
1977 cmdline_fixed_string_t keyword;
1978 cmdline_fixed_string_t all;
1979 cmdline_fixed_string_t name;
1984 cmd_config_max_pkt_len_parsed(void *parsed_result,
1985 __attribute__((unused)) struct cmdline *cl,
1986 __attribute__((unused)) void *data)
1988 struct cmd_config_max_pkt_len_result *res = parsed_result;
1991 if (!all_ports_stopped()) {
1992 printf("Please stop all ports first\n");
1996 RTE_ETH_FOREACH_DEV(pid) {
1997 struct rte_port *port = &ports[pid];
1998 uint64_t rx_offloads = port->dev_conf.rxmode.offloads;
2000 if (!strcmp(res->name, "max-pkt-len")) {
2001 if (res->value < RTE_ETHER_MIN_LEN) {
2002 printf("max-pkt-len can not be less than %d\n",
2006 if (res->value == port->dev_conf.rxmode.max_rx_pkt_len)
2009 port->dev_conf.rxmode.max_rx_pkt_len = res->value;
2010 if (res->value > RTE_ETHER_MAX_LEN)
2011 rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
2013 rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
2014 port->dev_conf.rxmode.offloads = rx_offloads;
2016 printf("Unknown parameter\n");
2023 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2026 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
2027 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
2029 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
2030 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
2032 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
2033 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
2035 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
2036 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
2038 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
2039 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
2042 cmdline_parse_inst_t cmd_config_max_pkt_len = {
2043 .f = cmd_config_max_pkt_len_parsed,
2045 .help_str = "port config all max-pkt-len <value>",
2047 (void *)&cmd_config_max_pkt_len_port,
2048 (void *)&cmd_config_max_pkt_len_keyword,
2049 (void *)&cmd_config_max_pkt_len_all,
2050 (void *)&cmd_config_max_pkt_len_name,
2051 (void *)&cmd_config_max_pkt_len_value,
2056 /* *** config max LRO aggregated packet size *** */
2057 struct cmd_config_max_lro_pkt_size_result {
2058 cmdline_fixed_string_t port;
2059 cmdline_fixed_string_t keyword;
2060 cmdline_fixed_string_t all;
2061 cmdline_fixed_string_t name;
2066 cmd_config_max_lro_pkt_size_parsed(void *parsed_result,
2067 __attribute__((unused)) struct cmdline *cl,
2068 __attribute__((unused)) void *data)
2070 struct cmd_config_max_lro_pkt_size_result *res = parsed_result;
2073 if (!all_ports_stopped()) {
2074 printf("Please stop all ports first\n");
2078 RTE_ETH_FOREACH_DEV(pid) {
2079 struct rte_port *port = &ports[pid];
2081 if (!strcmp(res->name, "max-lro-pkt-size")) {
2083 port->dev_conf.rxmode.max_lro_pkt_size)
2086 port->dev_conf.rxmode.max_lro_pkt_size = res->value;
2088 printf("Unknown parameter\n");
2095 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2098 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_port =
2099 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2101 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_keyword =
2102 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2104 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_all =
2105 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2107 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_name =
2108 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2109 name, "max-lro-pkt-size");
2110 cmdline_parse_token_num_t cmd_config_max_lro_pkt_size_value =
2111 TOKEN_NUM_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2114 cmdline_parse_inst_t cmd_config_max_lro_pkt_size = {
2115 .f = cmd_config_max_lro_pkt_size_parsed,
2117 .help_str = "port config all max-lro-pkt-size <value>",
2119 (void *)&cmd_config_max_lro_pkt_size_port,
2120 (void *)&cmd_config_max_lro_pkt_size_keyword,
2121 (void *)&cmd_config_max_lro_pkt_size_all,
2122 (void *)&cmd_config_max_lro_pkt_size_name,
2123 (void *)&cmd_config_max_lro_pkt_size_value,
2128 /* *** configure port MTU *** */
2129 struct cmd_config_mtu_result {
2130 cmdline_fixed_string_t port;
2131 cmdline_fixed_string_t keyword;
2132 cmdline_fixed_string_t mtu;
2138 cmd_config_mtu_parsed(void *parsed_result,
2139 __attribute__((unused)) struct cmdline *cl,
2140 __attribute__((unused)) void *data)
2142 struct cmd_config_mtu_result *res = parsed_result;
2144 if (res->value < RTE_ETHER_MIN_LEN) {
2145 printf("mtu cannot be less than %d\n", RTE_ETHER_MIN_LEN);
2148 port_mtu_set(res->port_id, res->value);
2151 cmdline_parse_token_string_t cmd_config_mtu_port =
2152 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
2154 cmdline_parse_token_string_t cmd_config_mtu_keyword =
2155 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2157 cmdline_parse_token_string_t cmd_config_mtu_mtu =
2158 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2160 cmdline_parse_token_num_t cmd_config_mtu_port_id =
2161 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT16);
2162 cmdline_parse_token_num_t cmd_config_mtu_value =
2163 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
2165 cmdline_parse_inst_t cmd_config_mtu = {
2166 .f = cmd_config_mtu_parsed,
2168 .help_str = "port config mtu <port_id> <value>",
2170 (void *)&cmd_config_mtu_port,
2171 (void *)&cmd_config_mtu_keyword,
2172 (void *)&cmd_config_mtu_mtu,
2173 (void *)&cmd_config_mtu_port_id,
2174 (void *)&cmd_config_mtu_value,
2179 /* *** configure rx mode *** */
2180 struct cmd_config_rx_mode_flag {
2181 cmdline_fixed_string_t port;
2182 cmdline_fixed_string_t keyword;
2183 cmdline_fixed_string_t all;
2184 cmdline_fixed_string_t name;
2185 cmdline_fixed_string_t value;
2189 cmd_config_rx_mode_flag_parsed(void *parsed_result,
2190 __attribute__((unused)) struct cmdline *cl,
2191 __attribute__((unused)) void *data)
2193 struct cmd_config_rx_mode_flag *res = parsed_result;
2195 if (!all_ports_stopped()) {
2196 printf("Please stop all ports first\n");
2200 if (!strcmp(res->name, "drop-en")) {
2201 if (!strcmp(res->value, "on"))
2203 else if (!strcmp(res->value, "off"))
2206 printf("Unknown parameter\n");
2210 printf("Unknown parameter\n");
2216 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2219 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
2220 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
2221 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
2222 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
2224 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2225 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2226 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2227 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2229 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2230 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2233 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2234 .f = cmd_config_rx_mode_flag_parsed,
2236 .help_str = "port config all drop-en on|off",
2238 (void *)&cmd_config_rx_mode_flag_port,
2239 (void *)&cmd_config_rx_mode_flag_keyword,
2240 (void *)&cmd_config_rx_mode_flag_all,
2241 (void *)&cmd_config_rx_mode_flag_name,
2242 (void *)&cmd_config_rx_mode_flag_value,
2247 /* *** configure rss *** */
2248 struct cmd_config_rss {
2249 cmdline_fixed_string_t port;
2250 cmdline_fixed_string_t keyword;
2251 cmdline_fixed_string_t all;
2252 cmdline_fixed_string_t name;
2253 cmdline_fixed_string_t value;
2257 cmd_config_rss_parsed(void *parsed_result,
2258 __attribute__((unused)) struct cmdline *cl,
2259 __attribute__((unused)) void *data)
2261 struct cmd_config_rss *res = parsed_result;
2262 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2263 struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2264 int use_default = 0;
2265 int all_updated = 1;
2270 if (!strcmp(res->value, "all"))
2271 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
2272 ETH_RSS_UDP | ETH_RSS_SCTP |
2274 else if (!strcmp(res->value, "ip"))
2275 rss_conf.rss_hf = ETH_RSS_IP;
2276 else if (!strcmp(res->value, "udp"))
2277 rss_conf.rss_hf = ETH_RSS_UDP;
2278 else if (!strcmp(res->value, "tcp"))
2279 rss_conf.rss_hf = ETH_RSS_TCP;
2280 else if (!strcmp(res->value, "sctp"))
2281 rss_conf.rss_hf = ETH_RSS_SCTP;
2282 else if (!strcmp(res->value, "ether"))
2283 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
2284 else if (!strcmp(res->value, "port"))
2285 rss_conf.rss_hf = ETH_RSS_PORT;
2286 else if (!strcmp(res->value, "vxlan"))
2287 rss_conf.rss_hf = ETH_RSS_VXLAN;
2288 else if (!strcmp(res->value, "geneve"))
2289 rss_conf.rss_hf = ETH_RSS_GENEVE;
2290 else if (!strcmp(res->value, "nvgre"))
2291 rss_conf.rss_hf = ETH_RSS_NVGRE;
2292 else if (!strcmp(res->value, "l3-src-only"))
2293 rss_conf.rss_hf = ETH_RSS_L3_SRC_ONLY;
2294 else if (!strcmp(res->value, "l3-dst-only"))
2295 rss_conf.rss_hf = ETH_RSS_L3_DST_ONLY;
2296 else if (!strcmp(res->value, "l4-src-only"))
2297 rss_conf.rss_hf = ETH_RSS_L4_SRC_ONLY;
2298 else if (!strcmp(res->value, "l4-dst-only"))
2299 rss_conf.rss_hf = ETH_RSS_L4_DST_ONLY;
2300 else if (!strcmp(res->value, "none"))
2301 rss_conf.rss_hf = 0;
2302 else if (!strcmp(res->value, "default"))
2304 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2305 atoi(res->value) < 64)
2306 rss_conf.rss_hf = 1ULL << atoi(res->value);
2308 printf("Unknown parameter\n");
2311 rss_conf.rss_key = NULL;
2312 /* Update global configuration for RSS types. */
2313 RTE_ETH_FOREACH_DEV(i) {
2314 struct rte_eth_rss_conf local_rss_conf;
2316 ret = eth_dev_info_get_print_err(i, &dev_info);
2321 rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2323 local_rss_conf = rss_conf;
2324 local_rss_conf.rss_hf = rss_conf.rss_hf &
2325 dev_info.flow_type_rss_offloads;
2326 if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2327 printf("Port %u modified RSS hash function based on hardware support,"
2328 "requested:%#"PRIx64" configured:%#"PRIx64"\n",
2329 i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2331 diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2334 printf("Configuration of RSS hash at ethernet port %d "
2335 "failed with error (%d): %s.\n",
2336 i, -diag, strerror(-diag));
2339 if (all_updated && !use_default)
2340 rss_hf = rss_conf.rss_hf;
2343 cmdline_parse_token_string_t cmd_config_rss_port =
2344 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2345 cmdline_parse_token_string_t cmd_config_rss_keyword =
2346 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2347 cmdline_parse_token_string_t cmd_config_rss_all =
2348 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2349 cmdline_parse_token_string_t cmd_config_rss_name =
2350 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2351 cmdline_parse_token_string_t cmd_config_rss_value =
2352 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2354 cmdline_parse_inst_t cmd_config_rss = {
2355 .f = cmd_config_rss_parsed,
2357 .help_str = "port config all rss "
2358 "all|default|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|vxlan-gpe|none|<flowtype_id>",
2360 (void *)&cmd_config_rss_port,
2361 (void *)&cmd_config_rss_keyword,
2362 (void *)&cmd_config_rss_all,
2363 (void *)&cmd_config_rss_name,
2364 (void *)&cmd_config_rss_value,
2369 /* *** configure rss hash key *** */
2370 struct cmd_config_rss_hash_key {
2371 cmdline_fixed_string_t port;
2372 cmdline_fixed_string_t config;
2374 cmdline_fixed_string_t rss_hash_key;
2375 cmdline_fixed_string_t rss_type;
2376 cmdline_fixed_string_t key;
2380 hexa_digit_to_value(char hexa_digit)
2382 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2383 return (uint8_t) (hexa_digit - '0');
2384 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2385 return (uint8_t) ((hexa_digit - 'a') + 10);
2386 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2387 return (uint8_t) ((hexa_digit - 'A') + 10);
2388 /* Invalid hexa digit */
2393 parse_and_check_key_hexa_digit(char *key, int idx)
2397 hexa_v = hexa_digit_to_value(key[idx]);
2399 printf("invalid key: character %c at position %d is not a "
2400 "valid hexa digit\n", key[idx], idx);
2405 cmd_config_rss_hash_key_parsed(void *parsed_result,
2406 __attribute__((unused)) struct cmdline *cl,
2407 __attribute__((unused)) void *data)
2409 struct cmd_config_rss_hash_key *res = parsed_result;
2410 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2414 struct rte_eth_dev_info dev_info;
2415 uint8_t hash_key_size;
2419 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2423 if (dev_info.hash_key_size > 0 &&
2424 dev_info.hash_key_size <= sizeof(hash_key))
2425 hash_key_size = dev_info.hash_key_size;
2427 printf("dev_info did not provide a valid hash key size\n");
2430 /* Check the length of the RSS hash key */
2431 key_len = strlen(res->key);
2432 if (key_len != (hash_key_size * 2)) {
2433 printf("key length: %d invalid - key must be a string of %d"
2434 " hexa-decimal numbers\n",
2435 (int) key_len, hash_key_size * 2);
2438 /* Translate RSS hash key into binary representation */
2439 for (i = 0; i < hash_key_size; i++) {
2440 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2443 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2446 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2448 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2452 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2453 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2454 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2455 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2457 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2458 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16);
2459 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2460 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2461 rss_hash_key, "rss-hash-key");
2462 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2463 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2464 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2465 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2466 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2467 "ipv6-tcp-ex#ipv6-udp-ex#"
2468 "l3-src-only#l3-dst-only#l4-src-only#l4-dst-only");
2469 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2470 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2472 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2473 .f = cmd_config_rss_hash_key_parsed,
2475 .help_str = "port config <port_id> rss-hash-key "
2476 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2477 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2478 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|"
2479 "l3-src-only|l3-dst-only|l4-src-only|l4-dst-only "
2480 "<string of hex digits (variable length, NIC dependent)>",
2482 (void *)&cmd_config_rss_hash_key_port,
2483 (void *)&cmd_config_rss_hash_key_config,
2484 (void *)&cmd_config_rss_hash_key_port_id,
2485 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2486 (void *)&cmd_config_rss_hash_key_rss_type,
2487 (void *)&cmd_config_rss_hash_key_value,
2492 /* *** configure port rxq/txq ring size *** */
2493 struct cmd_config_rxtx_ring_size {
2494 cmdline_fixed_string_t port;
2495 cmdline_fixed_string_t config;
2497 cmdline_fixed_string_t rxtxq;
2499 cmdline_fixed_string_t rsize;
2504 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2505 __attribute__((unused)) struct cmdline *cl,
2506 __attribute__((unused)) void *data)
2508 struct cmd_config_rxtx_ring_size *res = parsed_result;
2509 struct rte_port *port;
2512 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2515 if (res->portid == (portid_t)RTE_PORT_ALL) {
2516 printf("Invalid port id\n");
2520 port = &ports[res->portid];
2522 if (!strcmp(res->rxtxq, "rxq"))
2524 else if (!strcmp(res->rxtxq, "txq"))
2527 printf("Unknown parameter\n");
2531 if (isrx && rx_queue_id_is_invalid(res->qid))
2533 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2536 if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2537 printf("Invalid rx ring_size, must > rx_free_thresh: %d\n",
2543 port->nb_rx_desc[res->qid] = res->size;
2545 port->nb_tx_desc[res->qid] = res->size;
2547 cmd_reconfig_device_queue(res->portid, 0, 1);
2550 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2551 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2553 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2554 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2556 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2557 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2559 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2560 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2562 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2563 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2565 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2566 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2567 rsize, "ring_size");
2568 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2569 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2572 cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2573 .f = cmd_config_rxtx_ring_size_parsed,
2575 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2577 (void *)&cmd_config_rxtx_ring_size_port,
2578 (void *)&cmd_config_rxtx_ring_size_config,
2579 (void *)&cmd_config_rxtx_ring_size_portid,
2580 (void *)&cmd_config_rxtx_ring_size_rxtxq,
2581 (void *)&cmd_config_rxtx_ring_size_qid,
2582 (void *)&cmd_config_rxtx_ring_size_rsize,
2583 (void *)&cmd_config_rxtx_ring_size_size,
2588 /* *** configure port rxq/txq start/stop *** */
2589 struct cmd_config_rxtx_queue {
2590 cmdline_fixed_string_t port;
2592 cmdline_fixed_string_t rxtxq;
2594 cmdline_fixed_string_t opname;
2598 cmd_config_rxtx_queue_parsed(void *parsed_result,
2599 __attribute__((unused)) struct cmdline *cl,
2600 __attribute__((unused)) void *data)
2602 struct cmd_config_rxtx_queue *res = parsed_result;
2607 if (test_done == 0) {
2608 printf("Please stop forwarding first\n");
2612 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2615 if (port_is_started(res->portid) != 1) {
2616 printf("Please start port %u first\n", res->portid);
2620 if (!strcmp(res->rxtxq, "rxq"))
2622 else if (!strcmp(res->rxtxq, "txq"))
2625 printf("Unknown parameter\n");
2629 if (isrx && rx_queue_id_is_invalid(res->qid))
2631 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2634 if (!strcmp(res->opname, "start"))
2636 else if (!strcmp(res->opname, "stop"))
2639 printf("Unknown parameter\n");
2643 if (isstart && isrx)
2644 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2645 else if (!isstart && isrx)
2646 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2647 else if (isstart && !isrx)
2648 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2650 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2652 if (ret == -ENOTSUP)
2653 printf("Function not supported in PMD driver\n");
2656 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2657 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2658 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2659 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16);
2660 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2661 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2662 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2663 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
2664 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2665 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2668 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2669 .f = cmd_config_rxtx_queue_parsed,
2671 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2673 (void *)&cmd_config_rxtx_queue_port,
2674 (void *)&cmd_config_rxtx_queue_portid,
2675 (void *)&cmd_config_rxtx_queue_rxtxq,
2676 (void *)&cmd_config_rxtx_queue_qid,
2677 (void *)&cmd_config_rxtx_queue_opname,
2682 /* *** configure port rxq/txq deferred start on/off *** */
2683 struct cmd_config_deferred_start_rxtx_queue {
2684 cmdline_fixed_string_t port;
2686 cmdline_fixed_string_t rxtxq;
2688 cmdline_fixed_string_t opname;
2689 cmdline_fixed_string_t state;
2693 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2694 __attribute__((unused)) struct cmdline *cl,
2695 __attribute__((unused)) void *data)
2697 struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2698 struct rte_port *port;
2701 uint8_t needreconfig = 0;
2703 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2706 if (port_is_started(res->port_id) != 0) {
2707 printf("Please stop port %u first\n", res->port_id);
2711 port = &ports[res->port_id];
2713 isrx = !strcmp(res->rxtxq, "rxq");
2715 if (isrx && rx_queue_id_is_invalid(res->qid))
2717 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2720 ison = !strcmp(res->state, "on");
2722 if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) {
2723 port->rx_conf[res->qid].rx_deferred_start = ison;
2725 } else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) {
2726 port->tx_conf[res->qid].tx_deferred_start = ison;
2731 cmd_reconfig_device_queue(res->port_id, 0, 1);
2734 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2735 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2737 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2738 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2740 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2741 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2743 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2744 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2746 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2747 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2748 opname, "deferred_start");
2749 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2750 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2753 cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
2754 .f = cmd_config_deferred_start_rxtx_queue_parsed,
2756 .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
2758 (void *)&cmd_config_deferred_start_rxtx_queue_port,
2759 (void *)&cmd_config_deferred_start_rxtx_queue_port_id,
2760 (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
2761 (void *)&cmd_config_deferred_start_rxtx_queue_qid,
2762 (void *)&cmd_config_deferred_start_rxtx_queue_opname,
2763 (void *)&cmd_config_deferred_start_rxtx_queue_state,
2768 /* *** configure port rxq/txq setup *** */
2769 struct cmd_setup_rxtx_queue {
2770 cmdline_fixed_string_t port;
2772 cmdline_fixed_string_t rxtxq;
2774 cmdline_fixed_string_t setup;
2777 /* Common CLI fields for queue setup */
2778 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2779 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2780 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2781 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, UINT16);
2782 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2783 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2784 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2785 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, UINT16);
2786 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2787 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2790 cmd_setup_rxtx_queue_parsed(
2791 void *parsed_result,
2792 __attribute__((unused)) struct cmdline *cl,
2793 __attribute__((unused)) void *data)
2795 struct cmd_setup_rxtx_queue *res = parsed_result;
2796 struct rte_port *port;
2797 struct rte_mempool *mp;
2798 unsigned int socket_id;
2802 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2805 if (res->portid == (portid_t)RTE_PORT_ALL) {
2806 printf("Invalid port id\n");
2810 if (!strcmp(res->rxtxq, "rxq"))
2812 else if (!strcmp(res->rxtxq, "txq"))
2815 printf("Unknown parameter\n");
2819 if (isrx && rx_queue_id_is_invalid(res->qid)) {
2820 printf("Invalid rx queue\n");
2822 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2823 printf("Invalid tx queue\n");
2827 port = &ports[res->portid];
2829 socket_id = rxring_numa[res->portid];
2830 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2831 socket_id = port->socket_id;
2833 mp = mbuf_pool_find(socket_id);
2835 printf("Failed to setup RX queue: "
2836 "No mempool allocation"
2837 " on the socket %d\n",
2838 rxring_numa[res->portid]);
2841 ret = rte_eth_rx_queue_setup(res->portid,
2843 port->nb_rx_desc[res->qid],
2845 &port->rx_conf[res->qid],
2848 printf("Failed to setup RX queue\n");
2850 socket_id = txring_numa[res->portid];
2851 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2852 socket_id = port->socket_id;
2854 ret = rte_eth_tx_queue_setup(res->portid,
2856 port->nb_tx_desc[res->qid],
2858 &port->tx_conf[res->qid]);
2860 printf("Failed to setup TX queue\n");
2864 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2865 .f = cmd_setup_rxtx_queue_parsed,
2867 .help_str = "port <port_id> rxq|txq <queue_idx> setup",
2869 (void *)&cmd_setup_rxtx_queue_port,
2870 (void *)&cmd_setup_rxtx_queue_portid,
2871 (void *)&cmd_setup_rxtx_queue_rxtxq,
2872 (void *)&cmd_setup_rxtx_queue_qid,
2873 (void *)&cmd_setup_rxtx_queue_setup,
2879 /* *** Configure RSS RETA *** */
2880 struct cmd_config_rss_reta {
2881 cmdline_fixed_string_t port;
2882 cmdline_fixed_string_t keyword;
2884 cmdline_fixed_string_t name;
2885 cmdline_fixed_string_t list_name;
2886 cmdline_fixed_string_t list_of_items;
2890 parse_reta_config(const char *str,
2891 struct rte_eth_rss_reta_entry64 *reta_conf,
2892 uint16_t nb_entries)
2896 uint16_t hash_index, idx, shift;
2899 const char *p, *p0 = str;
2906 unsigned long int_fld[_NUM_FLD];
2907 char *str_fld[_NUM_FLD];
2909 while ((p = strchr(p0,'(')) != NULL) {
2911 if((p0 = strchr(p,')')) == NULL)
2915 if(size >= sizeof(s))
2918 snprintf(s, sizeof(s), "%.*s", size, p);
2919 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2921 for (i = 0; i < _NUM_FLD; i++) {
2923 int_fld[i] = strtoul(str_fld[i], &end, 0);
2924 if (errno != 0 || end == str_fld[i] ||
2929 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2930 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2932 if (hash_index >= nb_entries) {
2933 printf("Invalid RETA hash index=%d\n", hash_index);
2937 idx = hash_index / RTE_RETA_GROUP_SIZE;
2938 shift = hash_index % RTE_RETA_GROUP_SIZE;
2939 reta_conf[idx].mask |= (1ULL << shift);
2940 reta_conf[idx].reta[shift] = nb_queue;
2947 cmd_set_rss_reta_parsed(void *parsed_result,
2948 __attribute__((unused)) struct cmdline *cl,
2949 __attribute__((unused)) void *data)
2952 struct rte_eth_dev_info dev_info;
2953 struct rte_eth_rss_reta_entry64 reta_conf[8];
2954 struct cmd_config_rss_reta *res = parsed_result;
2956 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2960 if (dev_info.reta_size == 0) {
2961 printf("Redirection table size is 0 which is "
2962 "invalid for RSS\n");
2965 printf("The reta size of port %d is %u\n",
2966 res->port_id, dev_info.reta_size);
2967 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2968 printf("Currently do not support more than %u entries of "
2969 "redirection table\n", ETH_RSS_RETA_SIZE_512);
2973 memset(reta_conf, 0, sizeof(reta_conf));
2974 if (!strcmp(res->list_name, "reta")) {
2975 if (parse_reta_config(res->list_of_items, reta_conf,
2976 dev_info.reta_size)) {
2977 printf("Invalid RSS Redirection Table "
2978 "config entered\n");
2981 ret = rte_eth_dev_rss_reta_update(res->port_id,
2982 reta_conf, dev_info.reta_size);
2984 printf("Bad redirection table parameter, "
2985 "return code = %d \n", ret);
2989 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2990 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2991 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2992 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2993 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2994 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16);
2995 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2996 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2997 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2998 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2999 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
3000 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
3002 cmdline_parse_inst_t cmd_config_rss_reta = {
3003 .f = cmd_set_rss_reta_parsed,
3005 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
3007 (void *)&cmd_config_rss_reta_port,
3008 (void *)&cmd_config_rss_reta_keyword,
3009 (void *)&cmd_config_rss_reta_port_id,
3010 (void *)&cmd_config_rss_reta_name,
3011 (void *)&cmd_config_rss_reta_list_name,
3012 (void *)&cmd_config_rss_reta_list_of_items,
3017 /* *** SHOW PORT RETA INFO *** */
3018 struct cmd_showport_reta {
3019 cmdline_fixed_string_t show;
3020 cmdline_fixed_string_t port;
3022 cmdline_fixed_string_t rss;
3023 cmdline_fixed_string_t reta;
3025 cmdline_fixed_string_t list_of_items;
3029 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
3030 uint16_t nb_entries,
3034 const char *p, *p0 = str;
3039 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
3040 RTE_RETA_GROUP_SIZE;
3043 p = strchr(p0, '(');
3047 p0 = strchr(p, ')');
3051 if (size >= sizeof(s)) {
3052 printf("The string size exceeds the internal buffer size\n");
3055 snprintf(s, sizeof(s), "%.*s", size, p);
3056 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
3057 if (ret <= 0 || ret != num) {
3058 printf("The bits of masks do not match the number of "
3059 "reta entries: %u\n", num);
3062 for (i = 0; i < ret; i++)
3063 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
3069 cmd_showport_reta_parsed(void *parsed_result,
3070 __attribute__((unused)) struct cmdline *cl,
3071 __attribute__((unused)) void *data)
3073 struct cmd_showport_reta *res = parsed_result;
3074 struct rte_eth_rss_reta_entry64 reta_conf[8];
3075 struct rte_eth_dev_info dev_info;
3076 uint16_t max_reta_size;
3079 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3083 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
3084 if (res->size == 0 || res->size > max_reta_size) {
3085 printf("Invalid redirection table size: %u (1-%u)\n",
3086 res->size, max_reta_size);
3090 memset(reta_conf, 0, sizeof(reta_conf));
3091 if (showport_parse_reta_config(reta_conf, res->size,
3092 res->list_of_items) < 0) {
3093 printf("Invalid string: %s for reta masks\n",
3094 res->list_of_items);
3097 port_rss_reta_info(res->port_id, reta_conf, res->size);
3100 cmdline_parse_token_string_t cmd_showport_reta_show =
3101 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
3102 cmdline_parse_token_string_t cmd_showport_reta_port =
3103 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
3104 cmdline_parse_token_num_t cmd_showport_reta_port_id =
3105 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16);
3106 cmdline_parse_token_string_t cmd_showport_reta_rss =
3107 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
3108 cmdline_parse_token_string_t cmd_showport_reta_reta =
3109 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
3110 cmdline_parse_token_num_t cmd_showport_reta_size =
3111 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
3112 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
3113 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
3114 list_of_items, NULL);
3116 cmdline_parse_inst_t cmd_showport_reta = {
3117 .f = cmd_showport_reta_parsed,
3119 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
3121 (void *)&cmd_showport_reta_show,
3122 (void *)&cmd_showport_reta_port,
3123 (void *)&cmd_showport_reta_port_id,
3124 (void *)&cmd_showport_reta_rss,
3125 (void *)&cmd_showport_reta_reta,
3126 (void *)&cmd_showport_reta_size,
3127 (void *)&cmd_showport_reta_list_of_items,
3132 /* *** Show RSS hash configuration *** */
3133 struct cmd_showport_rss_hash {
3134 cmdline_fixed_string_t show;
3135 cmdline_fixed_string_t port;
3137 cmdline_fixed_string_t rss_hash;
3138 cmdline_fixed_string_t rss_type;
3139 cmdline_fixed_string_t key; /* optional argument */
3142 static void cmd_showport_rss_hash_parsed(void *parsed_result,
3143 __attribute__((unused)) struct cmdline *cl,
3146 struct cmd_showport_rss_hash *res = parsed_result;
3148 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
3151 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
3152 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
3153 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
3154 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
3155 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
3156 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16);
3157 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
3158 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
3160 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
3161 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
3163 cmdline_parse_inst_t cmd_showport_rss_hash = {
3164 .f = cmd_showport_rss_hash_parsed,
3166 .help_str = "show port <port_id> rss-hash",
3168 (void *)&cmd_showport_rss_hash_show,
3169 (void *)&cmd_showport_rss_hash_port,
3170 (void *)&cmd_showport_rss_hash_port_id,
3171 (void *)&cmd_showport_rss_hash_rss_hash,
3176 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
3177 .f = cmd_showport_rss_hash_parsed,
3179 .help_str = "show port <port_id> rss-hash key",
3181 (void *)&cmd_showport_rss_hash_show,
3182 (void *)&cmd_showport_rss_hash_port,
3183 (void *)&cmd_showport_rss_hash_port_id,
3184 (void *)&cmd_showport_rss_hash_rss_hash,
3185 (void *)&cmd_showport_rss_hash_rss_key,
3190 /* *** Configure DCB *** */
3191 struct cmd_config_dcb {
3192 cmdline_fixed_string_t port;
3193 cmdline_fixed_string_t config;
3195 cmdline_fixed_string_t dcb;
3196 cmdline_fixed_string_t vt;
3197 cmdline_fixed_string_t vt_en;
3199 cmdline_fixed_string_t pfc;
3200 cmdline_fixed_string_t pfc_en;
3204 cmd_config_dcb_parsed(void *parsed_result,
3205 __attribute__((unused)) struct cmdline *cl,
3206 __attribute__((unused)) void *data)
3208 struct cmd_config_dcb *res = parsed_result;
3209 portid_t port_id = res->port_id;
3210 struct rte_port *port;
3214 port = &ports[port_id];
3215 /** Check if the port is not started **/
3216 if (port->port_status != RTE_PORT_STOPPED) {
3217 printf("Please stop port %d first\n", port_id);
3221 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
3222 printf("The invalid number of traffic class,"
3223 " only 4 or 8 allowed.\n");
3227 if (nb_fwd_lcores < res->num_tcs) {
3228 printf("nb_cores shouldn't be less than number of TCs.\n");
3231 if (!strncmp(res->pfc_en, "on", 2))
3236 /* DCB in VT mode */
3237 if (!strncmp(res->vt_en, "on", 2))
3238 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3239 (enum rte_eth_nb_tcs)res->num_tcs,
3242 ret = init_port_dcb_config(port_id, DCB_ENABLED,
3243 (enum rte_eth_nb_tcs)res->num_tcs,
3248 printf("Cannot initialize network ports.\n");
3252 cmd_reconfig_device_queue(port_id, 1, 1);
3255 cmdline_parse_token_string_t cmd_config_dcb_port =
3256 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3257 cmdline_parse_token_string_t cmd_config_dcb_config =
3258 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3259 cmdline_parse_token_num_t cmd_config_dcb_port_id =
3260 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16);
3261 cmdline_parse_token_string_t cmd_config_dcb_dcb =
3262 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3263 cmdline_parse_token_string_t cmd_config_dcb_vt =
3264 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3265 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3266 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3267 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3268 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
3269 cmdline_parse_token_string_t cmd_config_dcb_pfc=
3270 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3271 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
3272 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
3274 cmdline_parse_inst_t cmd_config_dcb = {
3275 .f = cmd_config_dcb_parsed,
3277 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
3279 (void *)&cmd_config_dcb_port,
3280 (void *)&cmd_config_dcb_config,
3281 (void *)&cmd_config_dcb_port_id,
3282 (void *)&cmd_config_dcb_dcb,
3283 (void *)&cmd_config_dcb_vt,
3284 (void *)&cmd_config_dcb_vt_en,
3285 (void *)&cmd_config_dcb_num_tcs,
3286 (void *)&cmd_config_dcb_pfc,
3287 (void *)&cmd_config_dcb_pfc_en,
3292 /* *** configure number of packets per burst *** */
3293 struct cmd_config_burst {
3294 cmdline_fixed_string_t port;
3295 cmdline_fixed_string_t keyword;
3296 cmdline_fixed_string_t all;
3297 cmdline_fixed_string_t name;
3302 cmd_config_burst_parsed(void *parsed_result,
3303 __attribute__((unused)) struct cmdline *cl,
3304 __attribute__((unused)) void *data)
3306 struct cmd_config_burst *res = parsed_result;
3307 struct rte_eth_dev_info dev_info;
3308 uint16_t rec_nb_pkts;
3311 if (!all_ports_stopped()) {
3312 printf("Please stop all ports first\n");
3316 if (!strcmp(res->name, "burst")) {
3317 if (res->value == 0) {
3318 /* If user gives a value of zero, query the PMD for
3319 * its recommended Rx burst size. Testpmd uses a single
3320 * size for all ports, so assume all ports are the same
3321 * NIC model and use the values from Port 0.
3323 ret = eth_dev_info_get_print_err(0, &dev_info);
3327 rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3329 if (rec_nb_pkts == 0) {
3330 printf("PMD does not recommend a burst size.\n"
3331 "User provided value must be between"
3332 " 1 and %d\n", MAX_PKT_BURST);
3334 } else if (rec_nb_pkts > MAX_PKT_BURST) {
3335 printf("PMD recommended burst size of %d"
3336 " exceeds maximum value of %d\n",
3337 rec_nb_pkts, MAX_PKT_BURST);
3340 printf("Using PMD-provided burst value of %d\n",
3342 nb_pkt_per_burst = rec_nb_pkts;
3343 } else if (res->value > MAX_PKT_BURST) {
3344 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
3347 nb_pkt_per_burst = res->value;
3349 printf("Unknown parameter\n");
3355 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3358 cmdline_parse_token_string_t cmd_config_burst_port =
3359 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3360 cmdline_parse_token_string_t cmd_config_burst_keyword =
3361 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3362 cmdline_parse_token_string_t cmd_config_burst_all =
3363 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3364 cmdline_parse_token_string_t cmd_config_burst_name =
3365 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3366 cmdline_parse_token_num_t cmd_config_burst_value =
3367 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
3369 cmdline_parse_inst_t cmd_config_burst = {
3370 .f = cmd_config_burst_parsed,
3372 .help_str = "port config all burst <value>",
3374 (void *)&cmd_config_burst_port,
3375 (void *)&cmd_config_burst_keyword,
3376 (void *)&cmd_config_burst_all,
3377 (void *)&cmd_config_burst_name,
3378 (void *)&cmd_config_burst_value,
3383 /* *** configure rx/tx queues *** */
3384 struct cmd_config_thresh {
3385 cmdline_fixed_string_t port;
3386 cmdline_fixed_string_t keyword;
3387 cmdline_fixed_string_t all;
3388 cmdline_fixed_string_t name;
3393 cmd_config_thresh_parsed(void *parsed_result,
3394 __attribute__((unused)) struct cmdline *cl,
3395 __attribute__((unused)) void *data)
3397 struct cmd_config_thresh *res = parsed_result;
3399 if (!all_ports_stopped()) {
3400 printf("Please stop all ports first\n");
3404 if (!strcmp(res->name, "txpt"))
3405 tx_pthresh = res->value;
3406 else if(!strcmp(res->name, "txht"))
3407 tx_hthresh = res->value;
3408 else if(!strcmp(res->name, "txwt"))
3409 tx_wthresh = res->value;
3410 else if(!strcmp(res->name, "rxpt"))
3411 rx_pthresh = res->value;
3412 else if(!strcmp(res->name, "rxht"))
3413 rx_hthresh = res->value;
3414 else if(!strcmp(res->name, "rxwt"))
3415 rx_wthresh = res->value;
3417 printf("Unknown parameter\n");
3423 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3426 cmdline_parse_token_string_t cmd_config_thresh_port =
3427 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3428 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3429 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3430 cmdline_parse_token_string_t cmd_config_thresh_all =
3431 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3432 cmdline_parse_token_string_t cmd_config_thresh_name =
3433 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3434 "txpt#txht#txwt#rxpt#rxht#rxwt");
3435 cmdline_parse_token_num_t cmd_config_thresh_value =
3436 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
3438 cmdline_parse_inst_t cmd_config_thresh = {
3439 .f = cmd_config_thresh_parsed,
3441 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3443 (void *)&cmd_config_thresh_port,
3444 (void *)&cmd_config_thresh_keyword,
3445 (void *)&cmd_config_thresh_all,
3446 (void *)&cmd_config_thresh_name,
3447 (void *)&cmd_config_thresh_value,
3452 /* *** configure free/rs threshold *** */
3453 struct cmd_config_threshold {
3454 cmdline_fixed_string_t port;
3455 cmdline_fixed_string_t keyword;
3456 cmdline_fixed_string_t all;
3457 cmdline_fixed_string_t name;
3462 cmd_config_threshold_parsed(void *parsed_result,
3463 __attribute__((unused)) struct cmdline *cl,
3464 __attribute__((unused)) void *data)
3466 struct cmd_config_threshold *res = parsed_result;
3468 if (!all_ports_stopped()) {
3469 printf("Please stop all ports first\n");
3473 if (!strcmp(res->name, "txfreet"))
3474 tx_free_thresh = res->value;
3475 else if (!strcmp(res->name, "txrst"))
3476 tx_rs_thresh = res->value;
3477 else if (!strcmp(res->name, "rxfreet"))
3478 rx_free_thresh = res->value;
3480 printf("Unknown parameter\n");
3486 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3489 cmdline_parse_token_string_t cmd_config_threshold_port =
3490 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3491 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3492 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3494 cmdline_parse_token_string_t cmd_config_threshold_all =
3495 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3496 cmdline_parse_token_string_t cmd_config_threshold_name =
3497 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3498 "txfreet#txrst#rxfreet");
3499 cmdline_parse_token_num_t cmd_config_threshold_value =
3500 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
3502 cmdline_parse_inst_t cmd_config_threshold = {
3503 .f = cmd_config_threshold_parsed,
3505 .help_str = "port config all txfreet|txrst|rxfreet <value>",
3507 (void *)&cmd_config_threshold_port,
3508 (void *)&cmd_config_threshold_keyword,
3509 (void *)&cmd_config_threshold_all,
3510 (void *)&cmd_config_threshold_name,
3511 (void *)&cmd_config_threshold_value,
3517 struct cmd_stop_result {
3518 cmdline_fixed_string_t stop;
3521 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
3522 __attribute__((unused)) struct cmdline *cl,
3523 __attribute__((unused)) void *data)
3525 stop_packet_forwarding();
3528 cmdline_parse_token_string_t cmd_stop_stop =
3529 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3531 cmdline_parse_inst_t cmd_stop = {
3532 .f = cmd_stop_parsed,
3534 .help_str = "stop: Stop packet forwarding",
3536 (void *)&cmd_stop_stop,
3541 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3544 parse_item_list(char* str, const char* item_name, unsigned int max_items,
3545 unsigned int *parsed_items, int check_unique_values)
3547 unsigned int nb_item;
3555 * First parse all items in the list and store their value.
3560 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3562 if ((c >= '0') && (c <= '9')) {
3563 value = (unsigned int) (value * 10 + (c - '0'));
3568 printf("character %c is not a decimal digit\n", c);
3572 printf("No valid value before comma\n");
3575 if (nb_item < max_items) {
3576 parsed_items[nb_item] = value;
3582 if (nb_item >= max_items) {
3583 printf("Number of %s = %u > %u (maximum items)\n",
3584 item_name, nb_item + 1, max_items);
3587 parsed_items[nb_item++] = value;
3588 if (! check_unique_values)
3592 * Then, check that all values in the list are differents.
3593 * No optimization here...
3595 for (i = 0; i < nb_item; i++) {
3596 for (j = i + 1; j < nb_item; j++) {
3597 if (parsed_items[j] == parsed_items[i]) {
3598 printf("duplicated %s %u at index %u and %u\n",
3599 item_name, parsed_items[i], i, j);
3607 struct cmd_set_list_result {
3608 cmdline_fixed_string_t cmd_keyword;
3609 cmdline_fixed_string_t list_name;
3610 cmdline_fixed_string_t list_of_items;
3613 static void cmd_set_list_parsed(void *parsed_result,
3614 __attribute__((unused)) struct cmdline *cl,
3615 __attribute__((unused)) void *data)
3617 struct cmd_set_list_result *res;
3619 unsigned int lcorelist[RTE_MAX_LCORE];
3620 unsigned int portlist[RTE_MAX_ETHPORTS];
3622 unsigned int nb_item;
3624 if (test_done == 0) {
3625 printf("Please stop forwarding first\n");
3629 res = parsed_result;
3630 if (!strcmp(res->list_name, "corelist")) {
3631 nb_item = parse_item_list(res->list_of_items, "core",
3633 parsed_items.lcorelist, 1);
3635 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3640 if (!strcmp(res->list_name, "portlist")) {
3641 nb_item = parse_item_list(res->list_of_items, "port",
3643 parsed_items.portlist, 1);
3645 set_fwd_ports_list(parsed_items.portlist, nb_item);
3651 cmdline_parse_token_string_t cmd_set_list_keyword =
3652 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3654 cmdline_parse_token_string_t cmd_set_list_name =
3655 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3656 "corelist#portlist");
3657 cmdline_parse_token_string_t cmd_set_list_of_items =
3658 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3661 cmdline_parse_inst_t cmd_set_fwd_list = {
3662 .f = cmd_set_list_parsed,
3664 .help_str = "set corelist|portlist <list0[,list1]*>",
3666 (void *)&cmd_set_list_keyword,
3667 (void *)&cmd_set_list_name,
3668 (void *)&cmd_set_list_of_items,
3673 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3675 struct cmd_setmask_result {
3676 cmdline_fixed_string_t set;
3677 cmdline_fixed_string_t mask;
3681 static void cmd_set_mask_parsed(void *parsed_result,
3682 __attribute__((unused)) struct cmdline *cl,
3683 __attribute__((unused)) void *data)
3685 struct cmd_setmask_result *res = parsed_result;
3687 if (test_done == 0) {
3688 printf("Please stop forwarding first\n");
3691 if (!strcmp(res->mask, "coremask")) {
3692 set_fwd_lcores_mask(res->hexavalue);
3694 } else if (!strcmp(res->mask, "portmask")) {
3695 set_fwd_ports_mask(res->hexavalue);
3700 cmdline_parse_token_string_t cmd_setmask_set =
3701 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3702 cmdline_parse_token_string_t cmd_setmask_mask =
3703 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3704 "coremask#portmask");
3705 cmdline_parse_token_num_t cmd_setmask_value =
3706 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
3708 cmdline_parse_inst_t cmd_set_fwd_mask = {
3709 .f = cmd_set_mask_parsed,
3711 .help_str = "set coremask|portmask <hexadecimal value>",
3713 (void *)&cmd_setmask_set,
3714 (void *)&cmd_setmask_mask,
3715 (void *)&cmd_setmask_value,
3721 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3723 struct cmd_set_result {
3724 cmdline_fixed_string_t set;
3725 cmdline_fixed_string_t what;
3729 static void cmd_set_parsed(void *parsed_result,
3730 __attribute__((unused)) struct cmdline *cl,
3731 __attribute__((unused)) void *data)
3733 struct cmd_set_result *res = parsed_result;
3734 if (!strcmp(res->what, "nbport")) {
3735 set_fwd_ports_number(res->value);
3737 } else if (!strcmp(res->what, "nbcore")) {
3738 set_fwd_lcores_number(res->value);
3740 } else if (!strcmp(res->what, "burst"))
3741 set_nb_pkt_per_burst(res->value);
3742 else if (!strcmp(res->what, "verbose"))
3743 set_verbose_level(res->value);
3746 cmdline_parse_token_string_t cmd_set_set =
3747 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3748 cmdline_parse_token_string_t cmd_set_what =
3749 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3750 "nbport#nbcore#burst#verbose");
3751 cmdline_parse_token_num_t cmd_set_value =
3752 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
3754 cmdline_parse_inst_t cmd_set_numbers = {
3755 .f = cmd_set_parsed,
3757 .help_str = "set nbport|nbcore|burst|verbose <value>",
3759 (void *)&cmd_set_set,
3760 (void *)&cmd_set_what,
3761 (void *)&cmd_set_value,
3766 /* *** SET LOG LEVEL CONFIGURATION *** */
3768 struct cmd_set_log_result {
3769 cmdline_fixed_string_t set;
3770 cmdline_fixed_string_t log;
3771 cmdline_fixed_string_t type;
3776 cmd_set_log_parsed(void *parsed_result,
3777 __attribute__((unused)) struct cmdline *cl,
3778 __attribute__((unused)) void *data)
3780 struct cmd_set_log_result *res;
3783 res = parsed_result;
3784 if (!strcmp(res->type, "global"))
3785 rte_log_set_global_level(res->level);
3787 ret = rte_log_set_level_regexp(res->type, res->level);
3789 printf("Unable to set log level\n");
3793 cmdline_parse_token_string_t cmd_set_log_set =
3794 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3795 cmdline_parse_token_string_t cmd_set_log_log =
3796 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3797 cmdline_parse_token_string_t cmd_set_log_type =
3798 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3799 cmdline_parse_token_num_t cmd_set_log_level =
3800 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, UINT32);
3802 cmdline_parse_inst_t cmd_set_log = {
3803 .f = cmd_set_log_parsed,
3805 .help_str = "set log global|<type> <level>",
3807 (void *)&cmd_set_log_set,
3808 (void *)&cmd_set_log_log,
3809 (void *)&cmd_set_log_type,
3810 (void *)&cmd_set_log_level,
3815 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3817 struct cmd_set_txpkts_result {
3818 cmdline_fixed_string_t cmd_keyword;
3819 cmdline_fixed_string_t txpkts;
3820 cmdline_fixed_string_t seg_lengths;
3824 cmd_set_txpkts_parsed(void *parsed_result,
3825 __attribute__((unused)) struct cmdline *cl,
3826 __attribute__((unused)) void *data)
3828 struct cmd_set_txpkts_result *res;
3829 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3830 unsigned int nb_segs;
3832 res = parsed_result;
3833 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3834 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3836 set_tx_pkt_segments(seg_lengths, nb_segs);
3839 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3840 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3841 cmd_keyword, "set");
3842 cmdline_parse_token_string_t cmd_set_txpkts_name =
3843 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3845 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3846 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3849 cmdline_parse_inst_t cmd_set_txpkts = {
3850 .f = cmd_set_txpkts_parsed,
3852 .help_str = "set txpkts <len0[,len1]*>",
3854 (void *)&cmd_set_txpkts_keyword,
3855 (void *)&cmd_set_txpkts_name,
3856 (void *)&cmd_set_txpkts_lengths,
3861 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
3863 struct cmd_set_txsplit_result {
3864 cmdline_fixed_string_t cmd_keyword;
3865 cmdline_fixed_string_t txsplit;
3866 cmdline_fixed_string_t mode;
3870 cmd_set_txsplit_parsed(void *parsed_result,
3871 __attribute__((unused)) struct cmdline *cl,
3872 __attribute__((unused)) void *data)
3874 struct cmd_set_txsplit_result *res;
3876 res = parsed_result;
3877 set_tx_pkt_split(res->mode);
3880 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
3881 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3882 cmd_keyword, "set");
3883 cmdline_parse_token_string_t cmd_set_txsplit_name =
3884 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3885 txsplit, "txsplit");
3886 cmdline_parse_token_string_t cmd_set_txsplit_mode =
3887 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3890 cmdline_parse_inst_t cmd_set_txsplit = {
3891 .f = cmd_set_txsplit_parsed,
3893 .help_str = "set txsplit on|off|rand",
3895 (void *)&cmd_set_txsplit_keyword,
3896 (void *)&cmd_set_txsplit_name,
3897 (void *)&cmd_set_txsplit_mode,
3902 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
3903 struct cmd_rx_vlan_filter_all_result {
3904 cmdline_fixed_string_t rx_vlan;
3905 cmdline_fixed_string_t what;
3906 cmdline_fixed_string_t all;
3911 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
3912 __attribute__((unused)) struct cmdline *cl,
3913 __attribute__((unused)) void *data)
3915 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
3917 if (!strcmp(res->what, "add"))
3918 rx_vlan_all_filter_set(res->port_id, 1);
3920 rx_vlan_all_filter_set(res->port_id, 0);
3923 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
3924 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3925 rx_vlan, "rx_vlan");
3926 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
3927 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3929 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
3930 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3932 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
3933 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3936 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
3937 .f = cmd_rx_vlan_filter_all_parsed,
3939 .help_str = "rx_vlan add|rm all <port_id>: "
3940 "Add/Remove all identifiers to/from the set of VLAN "
3941 "identifiers filtered by a port",
3943 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
3944 (void *)&cmd_rx_vlan_filter_all_what,
3945 (void *)&cmd_rx_vlan_filter_all_all,
3946 (void *)&cmd_rx_vlan_filter_all_portid,
3951 /* *** VLAN OFFLOAD SET ON A PORT *** */
3952 struct cmd_vlan_offload_result {
3953 cmdline_fixed_string_t vlan;
3954 cmdline_fixed_string_t set;
3955 cmdline_fixed_string_t vlan_type;
3956 cmdline_fixed_string_t what;
3957 cmdline_fixed_string_t on;
3958 cmdline_fixed_string_t port_id;
3962 cmd_vlan_offload_parsed(void *parsed_result,
3963 __attribute__((unused)) struct cmdline *cl,
3964 __attribute__((unused)) void *data)
3967 struct cmd_vlan_offload_result *res = parsed_result;
3970 portid_t port_id = 0;
3974 len = strnlen(str, STR_TOKEN_SIZE);
3976 /* Get port_id first */
3984 tmp = strtoul(str, NULL, 0);
3985 /* If port_id greater that what portid_t can represent, return */
3986 if(tmp >= RTE_MAX_ETHPORTS)
3988 port_id = (portid_t)tmp;
3990 if (!strcmp(res->on, "on"))
3995 if (!strcmp(res->what, "strip"))
3996 rx_vlan_strip_set(port_id, on);
3997 else if(!strcmp(res->what, "stripq")){
3998 uint16_t queue_id = 0;
4000 /* No queue_id, return */
4002 printf("must specify (port,queue_id)\n");
4005 tmp = strtoul(str + i + 1, NULL, 0);
4006 /* If queue_id greater that what 16-bits can represent, return */
4010 queue_id = (uint16_t)tmp;
4011 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
4013 else if (!strcmp(res->what, "filter"))
4014 rx_vlan_filter_set(port_id, on);
4015 else if (!strcmp(res->what, "qinq_strip"))
4016 rx_vlan_qinq_strip_set(port_id, on);
4018 vlan_extend_set(port_id, on);
4023 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
4024 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4026 cmdline_parse_token_string_t cmd_vlan_offload_set =
4027 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4029 cmdline_parse_token_string_t cmd_vlan_offload_what =
4030 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4031 what, "strip#filter#qinq_strip#extend#stripq");
4032 cmdline_parse_token_string_t cmd_vlan_offload_on =
4033 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4035 cmdline_parse_token_string_t cmd_vlan_offload_portid =
4036 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4039 cmdline_parse_inst_t cmd_vlan_offload = {
4040 .f = cmd_vlan_offload_parsed,
4042 .help_str = "vlan set strip|filter|qinq_strip|extend|stripq on|off "
4043 "<port_id[,queue_id]>: "
4044 "Strip/Filter/QinQ for rx side Extend for both rx/tx sides",
4046 (void *)&cmd_vlan_offload_vlan,
4047 (void *)&cmd_vlan_offload_set,
4048 (void *)&cmd_vlan_offload_what,
4049 (void *)&cmd_vlan_offload_on,
4050 (void *)&cmd_vlan_offload_portid,
4055 /* *** VLAN TPID SET ON A PORT *** */
4056 struct cmd_vlan_tpid_result {
4057 cmdline_fixed_string_t vlan;
4058 cmdline_fixed_string_t set;
4059 cmdline_fixed_string_t vlan_type;
4060 cmdline_fixed_string_t what;
4066 cmd_vlan_tpid_parsed(void *parsed_result,
4067 __attribute__((unused)) struct cmdline *cl,
4068 __attribute__((unused)) void *data)
4070 struct cmd_vlan_tpid_result *res = parsed_result;
4071 enum rte_vlan_type vlan_type;
4073 if (!strcmp(res->vlan_type, "inner"))
4074 vlan_type = ETH_VLAN_TYPE_INNER;
4075 else if (!strcmp(res->vlan_type, "outer"))
4076 vlan_type = ETH_VLAN_TYPE_OUTER;
4078 printf("Unknown vlan type\n");
4081 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
4084 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
4085 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4087 cmdline_parse_token_string_t cmd_vlan_tpid_set =
4088 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4090 cmdline_parse_token_string_t cmd_vlan_type =
4091 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4092 vlan_type, "inner#outer");
4093 cmdline_parse_token_string_t cmd_vlan_tpid_what =
4094 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4096 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
4097 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4099 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
4100 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4103 cmdline_parse_inst_t cmd_vlan_tpid = {
4104 .f = cmd_vlan_tpid_parsed,
4106 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
4107 "Set the VLAN Ether type",
4109 (void *)&cmd_vlan_tpid_vlan,
4110 (void *)&cmd_vlan_tpid_set,
4111 (void *)&cmd_vlan_type,
4112 (void *)&cmd_vlan_tpid_what,
4113 (void *)&cmd_vlan_tpid_tpid,
4114 (void *)&cmd_vlan_tpid_portid,
4119 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4120 struct cmd_rx_vlan_filter_result {
4121 cmdline_fixed_string_t rx_vlan;
4122 cmdline_fixed_string_t what;
4128 cmd_rx_vlan_filter_parsed(void *parsed_result,
4129 __attribute__((unused)) struct cmdline *cl,
4130 __attribute__((unused)) void *data)
4132 struct cmd_rx_vlan_filter_result *res = parsed_result;
4134 if (!strcmp(res->what, "add"))
4135 rx_vft_set(res->port_id, res->vlan_id, 1);
4137 rx_vft_set(res->port_id, res->vlan_id, 0);
4140 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
4141 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4142 rx_vlan, "rx_vlan");
4143 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
4144 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4146 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
4147 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4149 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
4150 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4153 cmdline_parse_inst_t cmd_rx_vlan_filter = {
4154 .f = cmd_rx_vlan_filter_parsed,
4156 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
4157 "Add/Remove a VLAN identifier to/from the set of VLAN "
4158 "identifiers filtered by a port",
4160 (void *)&cmd_rx_vlan_filter_rx_vlan,
4161 (void *)&cmd_rx_vlan_filter_what,
4162 (void *)&cmd_rx_vlan_filter_vlanid,
4163 (void *)&cmd_rx_vlan_filter_portid,
4168 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4169 struct cmd_tx_vlan_set_result {
4170 cmdline_fixed_string_t tx_vlan;
4171 cmdline_fixed_string_t set;
4177 cmd_tx_vlan_set_parsed(void *parsed_result,
4178 __attribute__((unused)) struct cmdline *cl,
4179 __attribute__((unused)) void *data)
4181 struct cmd_tx_vlan_set_result *res = parsed_result;
4183 if (!port_is_stopped(res->port_id)) {
4184 printf("Please stop port %d first\n", res->port_id);
4188 tx_vlan_set(res->port_id, res->vlan_id);
4190 cmd_reconfig_device_queue(res->port_id, 1, 1);
4193 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4194 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4195 tx_vlan, "tx_vlan");
4196 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4197 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4199 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4200 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4202 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
4203 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4206 cmdline_parse_inst_t cmd_tx_vlan_set = {
4207 .f = cmd_tx_vlan_set_parsed,
4209 .help_str = "tx_vlan set <port_id> <vlan_id>: "
4210 "Enable hardware insertion of a single VLAN header "
4211 "with a given TAG Identifier in packets sent on a port",
4213 (void *)&cmd_tx_vlan_set_tx_vlan,
4214 (void *)&cmd_tx_vlan_set_set,
4215 (void *)&cmd_tx_vlan_set_portid,
4216 (void *)&cmd_tx_vlan_set_vlanid,
4221 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4222 struct cmd_tx_vlan_set_qinq_result {
4223 cmdline_fixed_string_t tx_vlan;
4224 cmdline_fixed_string_t set;
4227 uint16_t vlan_id_outer;
4231 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4232 __attribute__((unused)) struct cmdline *cl,
4233 __attribute__((unused)) void *data)
4235 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
4237 if (!port_is_stopped(res->port_id)) {
4238 printf("Please stop port %d first\n", res->port_id);
4242 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
4244 cmd_reconfig_device_queue(res->port_id, 1, 1);
4247 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
4248 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4249 tx_vlan, "tx_vlan");
4250 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
4251 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4253 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
4254 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4256 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
4257 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4259 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
4260 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4261 vlan_id_outer, UINT16);
4263 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
4264 .f = cmd_tx_vlan_set_qinq_parsed,
4266 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
4267 "Enable hardware insertion of double VLAN header "
4268 "with given TAG Identifiers in packets sent on a port",
4270 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
4271 (void *)&cmd_tx_vlan_set_qinq_set,
4272 (void *)&cmd_tx_vlan_set_qinq_portid,
4273 (void *)&cmd_tx_vlan_set_qinq_vlanid,
4274 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
4279 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
4280 struct cmd_tx_vlan_set_pvid_result {
4281 cmdline_fixed_string_t tx_vlan;
4282 cmdline_fixed_string_t set;
4283 cmdline_fixed_string_t pvid;
4286 cmdline_fixed_string_t mode;
4290 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
4291 __attribute__((unused)) struct cmdline *cl,
4292 __attribute__((unused)) void *data)
4294 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
4296 if (strcmp(res->mode, "on") == 0)
4297 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
4299 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
4302 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
4303 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4304 tx_vlan, "tx_vlan");
4305 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
4306 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4308 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
4309 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4311 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
4312 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4314 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
4315 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4317 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
4318 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4321 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
4322 .f = cmd_tx_vlan_set_pvid_parsed,
4324 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
4326 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
4327 (void *)&cmd_tx_vlan_set_pvid_set,
4328 (void *)&cmd_tx_vlan_set_pvid_pvid,
4329 (void *)&cmd_tx_vlan_set_pvid_port_id,
4330 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
4331 (void *)&cmd_tx_vlan_set_pvid_mode,
4336 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4337 struct cmd_tx_vlan_reset_result {
4338 cmdline_fixed_string_t tx_vlan;
4339 cmdline_fixed_string_t reset;
4344 cmd_tx_vlan_reset_parsed(void *parsed_result,
4345 __attribute__((unused)) struct cmdline *cl,
4346 __attribute__((unused)) void *data)
4348 struct cmd_tx_vlan_reset_result *res = parsed_result;
4350 if (!port_is_stopped(res->port_id)) {
4351 printf("Please stop port %d first\n", res->port_id);
4355 tx_vlan_reset(res->port_id);
4357 cmd_reconfig_device_queue(res->port_id, 1, 1);
4360 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4361 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4362 tx_vlan, "tx_vlan");
4363 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4364 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4366 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4367 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4370 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4371 .f = cmd_tx_vlan_reset_parsed,
4373 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4374 "VLAN header in packets sent on a port",
4376 (void *)&cmd_tx_vlan_reset_tx_vlan,
4377 (void *)&cmd_tx_vlan_reset_reset,
4378 (void *)&cmd_tx_vlan_reset_portid,
4384 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4385 struct cmd_csum_result {
4386 cmdline_fixed_string_t csum;
4387 cmdline_fixed_string_t mode;
4388 cmdline_fixed_string_t proto;
4389 cmdline_fixed_string_t hwsw;
4394 csum_show(int port_id)
4396 struct rte_eth_dev_info dev_info;
4397 uint64_t tx_offloads;
4400 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4401 printf("Parse tunnel is %s\n",
4402 (ports[port_id].parse_tunnel) ? "on" : "off");
4403 printf("IP checksum offload is %s\n",
4404 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4405 printf("UDP checksum offload is %s\n",
4406 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4407 printf("TCP checksum offload is %s\n",
4408 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4409 printf("SCTP checksum offload is %s\n",
4410 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4411 printf("Outer-Ip checksum offload is %s\n",
4412 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4413 printf("Outer-Udp checksum offload is %s\n",
4414 (tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
4416 /* display warnings if configuration is not supported by the NIC */
4417 ret = eth_dev_info_get_print_err(port_id, &dev_info);
4421 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
4422 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4423 printf("Warning: hardware IP checksum enabled but not "
4424 "supported by port %d\n", port_id);
4426 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
4427 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
4428 printf("Warning: hardware UDP checksum enabled but not "
4429 "supported by port %d\n", port_id);
4431 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
4432 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
4433 printf("Warning: hardware TCP checksum enabled but not "
4434 "supported by port %d\n", port_id);
4436 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
4437 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4438 printf("Warning: hardware SCTP checksum enabled but not "
4439 "supported by port %d\n", port_id);
4441 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4442 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4443 printf("Warning: hardware outer IP checksum enabled but not "
4444 "supported by port %d\n", port_id);
4446 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
4447 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)
4449 printf("Warning: hardware outer UDP checksum enabled but not "
4450 "supported by port %d\n", port_id);
4455 cmd_config_queue_tx_offloads(struct rte_port *port)
4459 /* Apply queue tx offloads configuration */
4460 for (k = 0; k < port->dev_info.max_rx_queues; k++)
4461 port->tx_conf[k].offloads =
4462 port->dev_conf.txmode.offloads;
4466 cmd_csum_parsed(void *parsed_result,
4467 __attribute__((unused)) struct cmdline *cl,
4468 __attribute__((unused)) void *data)
4470 struct cmd_csum_result *res = parsed_result;
4472 uint64_t csum_offloads = 0;
4473 struct rte_eth_dev_info dev_info;
4476 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4477 printf("invalid port %d\n", res->port_id);
4480 if (!port_is_stopped(res->port_id)) {
4481 printf("Please stop port %d first\n", res->port_id);
4485 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4489 if (!strcmp(res->mode, "set")) {
4491 if (!strcmp(res->hwsw, "hw"))
4494 if (!strcmp(res->proto, "ip")) {
4495 if (hw == 0 || (dev_info.tx_offload_capa &
4496 DEV_TX_OFFLOAD_IPV4_CKSUM)) {
4497 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
4499 printf("IP checksum offload is not supported "
4500 "by port %u\n", res->port_id);
4502 } else if (!strcmp(res->proto, "udp")) {
4503 if (hw == 0 || (dev_info.tx_offload_capa &
4504 DEV_TX_OFFLOAD_UDP_CKSUM)) {
4505 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
4507 printf("UDP checksum offload is not supported "
4508 "by port %u\n", res->port_id);
4510 } else if (!strcmp(res->proto, "tcp")) {
4511 if (hw == 0 || (dev_info.tx_offload_capa &
4512 DEV_TX_OFFLOAD_TCP_CKSUM)) {
4513 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
4515 printf("TCP checksum offload is not supported "
4516 "by port %u\n", res->port_id);
4518 } else if (!strcmp(res->proto, "sctp")) {
4519 if (hw == 0 || (dev_info.tx_offload_capa &
4520 DEV_TX_OFFLOAD_SCTP_CKSUM)) {
4521 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
4523 printf("SCTP checksum offload is not supported "
4524 "by port %u\n", res->port_id);
4526 } else if (!strcmp(res->proto, "outer-ip")) {
4527 if (hw == 0 || (dev_info.tx_offload_capa &
4528 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4530 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4532 printf("Outer IP checksum offload is not "
4533 "supported by port %u\n", res->port_id);
4535 } else if (!strcmp(res->proto, "outer-udp")) {
4536 if (hw == 0 || (dev_info.tx_offload_capa &
4537 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
4539 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM;
4541 printf("Outer UDP checksum offload is not "
4542 "supported by port %u\n", res->port_id);
4547 ports[res->port_id].dev_conf.txmode.offloads |=
4550 ports[res->port_id].dev_conf.txmode.offloads &=
4553 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4555 csum_show(res->port_id);
4557 cmd_reconfig_device_queue(res->port_id, 1, 1);
4560 cmdline_parse_token_string_t cmd_csum_csum =
4561 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4563 cmdline_parse_token_string_t cmd_csum_mode =
4564 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4566 cmdline_parse_token_string_t cmd_csum_proto =
4567 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4568 proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
4569 cmdline_parse_token_string_t cmd_csum_hwsw =
4570 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4572 cmdline_parse_token_num_t cmd_csum_portid =
4573 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4576 cmdline_parse_inst_t cmd_csum_set = {
4577 .f = cmd_csum_parsed,
4579 .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
4580 "Enable/Disable hardware calculation of L3/L4 checksum when "
4581 "using csum forward engine",
4583 (void *)&cmd_csum_csum,
4584 (void *)&cmd_csum_mode,
4585 (void *)&cmd_csum_proto,
4586 (void *)&cmd_csum_hwsw,
4587 (void *)&cmd_csum_portid,
4592 cmdline_parse_token_string_t cmd_csum_mode_show =
4593 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4596 cmdline_parse_inst_t cmd_csum_show = {
4597 .f = cmd_csum_parsed,
4599 .help_str = "csum show <port_id>: Show checksum offload configuration",
4601 (void *)&cmd_csum_csum,
4602 (void *)&cmd_csum_mode_show,
4603 (void *)&cmd_csum_portid,
4608 /* Enable/disable tunnel parsing */
4609 struct cmd_csum_tunnel_result {
4610 cmdline_fixed_string_t csum;
4611 cmdline_fixed_string_t parse;
4612 cmdline_fixed_string_t onoff;
4617 cmd_csum_tunnel_parsed(void *parsed_result,
4618 __attribute__((unused)) struct cmdline *cl,
4619 __attribute__((unused)) void *data)
4621 struct cmd_csum_tunnel_result *res = parsed_result;
4623 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4626 if (!strcmp(res->onoff, "on"))
4627 ports[res->port_id].parse_tunnel = 1;
4629 ports[res->port_id].parse_tunnel = 0;
4631 csum_show(res->port_id);
4634 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4635 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4637 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4638 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4639 parse, "parse-tunnel");
4640 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4641 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4643 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4644 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4647 cmdline_parse_inst_t cmd_csum_tunnel = {
4648 .f = cmd_csum_tunnel_parsed,
4650 .help_str = "csum parse-tunnel on|off <port_id>: "
4651 "Enable/Disable parsing of tunnels for csum engine",
4653 (void *)&cmd_csum_tunnel_csum,
4654 (void *)&cmd_csum_tunnel_parse,
4655 (void *)&cmd_csum_tunnel_onoff,
4656 (void *)&cmd_csum_tunnel_portid,
4661 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4662 struct cmd_tso_set_result {
4663 cmdline_fixed_string_t tso;
4664 cmdline_fixed_string_t mode;
4670 cmd_tso_set_parsed(void *parsed_result,
4671 __attribute__((unused)) struct cmdline *cl,
4672 __attribute__((unused)) void *data)
4674 struct cmd_tso_set_result *res = parsed_result;
4675 struct rte_eth_dev_info dev_info;
4678 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4680 if (!port_is_stopped(res->port_id)) {
4681 printf("Please stop port %d first\n", res->port_id);
4685 if (!strcmp(res->mode, "set"))
4686 ports[res->port_id].tso_segsz = res->tso_segsz;
4688 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4692 if ((ports[res->port_id].tso_segsz != 0) &&
4693 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4694 printf("Error: TSO is not supported by port %d\n",
4699 if (ports[res->port_id].tso_segsz == 0) {
4700 ports[res->port_id].dev_conf.txmode.offloads &=
4701 ~DEV_TX_OFFLOAD_TCP_TSO;
4702 printf("TSO for non-tunneled packets is disabled\n");
4704 ports[res->port_id].dev_conf.txmode.offloads |=
4705 DEV_TX_OFFLOAD_TCP_TSO;
4706 printf("TSO segment size for non-tunneled packets is %d\n",
4707 ports[res->port_id].tso_segsz);
4709 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4711 /* display warnings if configuration is not supported by the NIC */
4712 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4716 if ((ports[res->port_id].tso_segsz != 0) &&
4717 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4718 printf("Warning: TSO enabled but not "
4719 "supported by port %d\n", res->port_id);
4722 cmd_reconfig_device_queue(res->port_id, 1, 1);
4725 cmdline_parse_token_string_t cmd_tso_set_tso =
4726 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4728 cmdline_parse_token_string_t cmd_tso_set_mode =
4729 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4731 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4732 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4734 cmdline_parse_token_num_t cmd_tso_set_portid =
4735 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4738 cmdline_parse_inst_t cmd_tso_set = {
4739 .f = cmd_tso_set_parsed,
4741 .help_str = "tso set <tso_segsz> <port_id>: "
4742 "Set TSO segment size of non-tunneled packets for csum engine "
4745 (void *)&cmd_tso_set_tso,
4746 (void *)&cmd_tso_set_mode,
4747 (void *)&cmd_tso_set_tso_segsz,
4748 (void *)&cmd_tso_set_portid,
4753 cmdline_parse_token_string_t cmd_tso_show_mode =
4754 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4758 cmdline_parse_inst_t cmd_tso_show = {
4759 .f = cmd_tso_set_parsed,
4761 .help_str = "tso show <port_id>: "
4762 "Show TSO segment size of non-tunneled packets for csum engine",
4764 (void *)&cmd_tso_set_tso,
4765 (void *)&cmd_tso_show_mode,
4766 (void *)&cmd_tso_set_portid,
4771 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
4772 struct cmd_tunnel_tso_set_result {
4773 cmdline_fixed_string_t tso;
4774 cmdline_fixed_string_t mode;
4779 static struct rte_eth_dev_info
4780 check_tunnel_tso_nic_support(portid_t port_id)
4782 struct rte_eth_dev_info dev_info;
4784 if (eth_dev_info_get_print_err(port_id, &dev_info) != 0)
4787 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
4788 printf("Warning: VXLAN TUNNEL TSO not supported therefore "
4789 "not enabled for port %d\n", port_id);
4790 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
4791 printf("Warning: GRE TUNNEL TSO not supported therefore "
4792 "not enabled for port %d\n", port_id);
4793 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
4794 printf("Warning: IPIP TUNNEL TSO not supported therefore "
4795 "not enabled for port %d\n", port_id);
4796 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
4797 printf("Warning: GENEVE TUNNEL TSO not supported therefore "
4798 "not enabled for port %d\n", port_id);
4799 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
4800 printf("Warning: IP TUNNEL TSO not supported therefore "
4801 "not enabled for port %d\n", port_id);
4802 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
4803 printf("Warning: UDP TUNNEL TSO not supported therefore "
4804 "not enabled for port %d\n", port_id);
4809 cmd_tunnel_tso_set_parsed(void *parsed_result,
4810 __attribute__((unused)) struct cmdline *cl,
4811 __attribute__((unused)) void *data)
4813 struct cmd_tunnel_tso_set_result *res = parsed_result;
4814 struct rte_eth_dev_info dev_info;
4816 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4818 if (!port_is_stopped(res->port_id)) {
4819 printf("Please stop port %d first\n", res->port_id);
4823 if (!strcmp(res->mode, "set"))
4824 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
4826 dev_info = check_tunnel_tso_nic_support(res->port_id);
4827 if (ports[res->port_id].tunnel_tso_segsz == 0) {
4828 ports[res->port_id].dev_conf.txmode.offloads &=
4829 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4830 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4831 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4832 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4833 DEV_TX_OFFLOAD_IP_TNL_TSO |
4834 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4835 printf("TSO for tunneled packets is disabled\n");
4837 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4838 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4839 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4840 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4841 DEV_TX_OFFLOAD_IP_TNL_TSO |
4842 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4844 ports[res->port_id].dev_conf.txmode.offloads |=
4845 (tso_offloads & dev_info.tx_offload_capa);
4846 printf("TSO segment size for tunneled packets is %d\n",
4847 ports[res->port_id].tunnel_tso_segsz);
4849 /* Below conditions are needed to make it work:
4850 * (1) tunnel TSO is supported by the NIC;
4851 * (2) "csum parse_tunnel" must be set so that tunneled pkts
4853 * (3) for tunneled pkts with outer L3 of IPv4,
4854 * "csum set outer-ip" must be set to hw, because after tso,
4855 * total_len of outer IP header is changed, and the checksum
4856 * of outer IP header calculated by sw should be wrong; that
4857 * is not necessary for IPv6 tunneled pkts because there's no
4858 * checksum in IP header anymore.
4861 if (!ports[res->port_id].parse_tunnel)
4862 printf("Warning: csum parse_tunnel must be set "
4863 "so that tunneled packets are recognized\n");
4864 if (!(ports[res->port_id].dev_conf.txmode.offloads &
4865 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
4866 printf("Warning: csum set outer-ip must be set to hw "
4867 "if outer L3 is IPv4; not necessary for IPv6\n");
4870 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4871 cmd_reconfig_device_queue(res->port_id, 1, 1);
4874 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
4875 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4877 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
4878 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4880 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
4881 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4883 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
4884 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4887 cmdline_parse_inst_t cmd_tunnel_tso_set = {
4888 .f = cmd_tunnel_tso_set_parsed,
4890 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
4891 "Set TSO segment size of tunneled packets for csum engine "
4894 (void *)&cmd_tunnel_tso_set_tso,
4895 (void *)&cmd_tunnel_tso_set_mode,
4896 (void *)&cmd_tunnel_tso_set_tso_segsz,
4897 (void *)&cmd_tunnel_tso_set_portid,
4902 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
4903 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4907 cmdline_parse_inst_t cmd_tunnel_tso_show = {
4908 .f = cmd_tunnel_tso_set_parsed,
4910 .help_str = "tunnel_tso show <port_id> "
4911 "Show TSO segment size of tunneled packets for csum engine",
4913 (void *)&cmd_tunnel_tso_set_tso,
4914 (void *)&cmd_tunnel_tso_show_mode,
4915 (void *)&cmd_tunnel_tso_set_portid,
4920 /* *** SET GRO FOR A PORT *** */
4921 struct cmd_gro_enable_result {
4922 cmdline_fixed_string_t cmd_set;
4923 cmdline_fixed_string_t cmd_port;
4924 cmdline_fixed_string_t cmd_keyword;
4925 cmdline_fixed_string_t cmd_onoff;
4930 cmd_gro_enable_parsed(void *parsed_result,
4931 __attribute__((unused)) struct cmdline *cl,
4932 __attribute__((unused)) void *data)
4934 struct cmd_gro_enable_result *res;
4936 res = parsed_result;
4937 if (!strcmp(res->cmd_keyword, "gro"))
4938 setup_gro(res->cmd_onoff, res->cmd_pid);
4941 cmdline_parse_token_string_t cmd_gro_enable_set =
4942 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4944 cmdline_parse_token_string_t cmd_gro_enable_port =
4945 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4946 cmd_keyword, "port");
4947 cmdline_parse_token_num_t cmd_gro_enable_pid =
4948 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
4950 cmdline_parse_token_string_t cmd_gro_enable_keyword =
4951 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4952 cmd_keyword, "gro");
4953 cmdline_parse_token_string_t cmd_gro_enable_onoff =
4954 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4955 cmd_onoff, "on#off");
4957 cmdline_parse_inst_t cmd_gro_enable = {
4958 .f = cmd_gro_enable_parsed,
4960 .help_str = "set port <port_id> gro on|off",
4962 (void *)&cmd_gro_enable_set,
4963 (void *)&cmd_gro_enable_port,
4964 (void *)&cmd_gro_enable_pid,
4965 (void *)&cmd_gro_enable_keyword,
4966 (void *)&cmd_gro_enable_onoff,
4971 /* *** DISPLAY GRO CONFIGURATION *** */
4972 struct cmd_gro_show_result {
4973 cmdline_fixed_string_t cmd_show;
4974 cmdline_fixed_string_t cmd_port;
4975 cmdline_fixed_string_t cmd_keyword;
4980 cmd_gro_show_parsed(void *parsed_result,
4981 __attribute__((unused)) struct cmdline *cl,
4982 __attribute__((unused)) void *data)
4984 struct cmd_gro_show_result *res;
4986 res = parsed_result;
4987 if (!strcmp(res->cmd_keyword, "gro"))
4988 show_gro(res->cmd_pid);
4991 cmdline_parse_token_string_t cmd_gro_show_show =
4992 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4994 cmdline_parse_token_string_t cmd_gro_show_port =
4995 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4997 cmdline_parse_token_num_t cmd_gro_show_pid =
4998 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
5000 cmdline_parse_token_string_t cmd_gro_show_keyword =
5001 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5002 cmd_keyword, "gro");
5004 cmdline_parse_inst_t cmd_gro_show = {
5005 .f = cmd_gro_show_parsed,
5007 .help_str = "show port <port_id> gro",
5009 (void *)&cmd_gro_show_show,
5010 (void *)&cmd_gro_show_port,
5011 (void *)&cmd_gro_show_pid,
5012 (void *)&cmd_gro_show_keyword,
5017 /* *** SET FLUSH CYCLES FOR GRO *** */
5018 struct cmd_gro_flush_result {
5019 cmdline_fixed_string_t cmd_set;
5020 cmdline_fixed_string_t cmd_keyword;
5021 cmdline_fixed_string_t cmd_flush;
5026 cmd_gro_flush_parsed(void *parsed_result,
5027 __attribute__((unused)) struct cmdline *cl,
5028 __attribute__((unused)) void *data)
5030 struct cmd_gro_flush_result *res;
5032 res = parsed_result;
5033 if ((!strcmp(res->cmd_keyword, "gro")) &&
5034 (!strcmp(res->cmd_flush, "flush")))
5035 setup_gro_flush_cycles(res->cmd_cycles);
5038 cmdline_parse_token_string_t cmd_gro_flush_set =
5039 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5041 cmdline_parse_token_string_t cmd_gro_flush_keyword =
5042 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5043 cmd_keyword, "gro");
5044 cmdline_parse_token_string_t cmd_gro_flush_flush =
5045 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5046 cmd_flush, "flush");
5047 cmdline_parse_token_num_t cmd_gro_flush_cycles =
5048 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
5051 cmdline_parse_inst_t cmd_gro_flush = {
5052 .f = cmd_gro_flush_parsed,
5054 .help_str = "set gro flush <cycles>",
5056 (void *)&cmd_gro_flush_set,
5057 (void *)&cmd_gro_flush_keyword,
5058 (void *)&cmd_gro_flush_flush,
5059 (void *)&cmd_gro_flush_cycles,
5064 /* *** ENABLE/DISABLE GSO *** */
5065 struct cmd_gso_enable_result {
5066 cmdline_fixed_string_t cmd_set;
5067 cmdline_fixed_string_t cmd_port;
5068 cmdline_fixed_string_t cmd_keyword;
5069 cmdline_fixed_string_t cmd_mode;
5074 cmd_gso_enable_parsed(void *parsed_result,
5075 __attribute__((unused)) struct cmdline *cl,
5076 __attribute__((unused)) void *data)
5078 struct cmd_gso_enable_result *res;
5080 res = parsed_result;
5081 if (!strcmp(res->cmd_keyword, "gso"))
5082 setup_gso(res->cmd_mode, res->cmd_pid);
5085 cmdline_parse_token_string_t cmd_gso_enable_set =
5086 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5088 cmdline_parse_token_string_t cmd_gso_enable_port =
5089 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5091 cmdline_parse_token_string_t cmd_gso_enable_keyword =
5092 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5093 cmd_keyword, "gso");
5094 cmdline_parse_token_string_t cmd_gso_enable_mode =
5095 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5096 cmd_mode, "on#off");
5097 cmdline_parse_token_num_t cmd_gso_enable_pid =
5098 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
5101 cmdline_parse_inst_t cmd_gso_enable = {
5102 .f = cmd_gso_enable_parsed,
5104 .help_str = "set port <port_id> gso on|off",
5106 (void *)&cmd_gso_enable_set,
5107 (void *)&cmd_gso_enable_port,
5108 (void *)&cmd_gso_enable_pid,
5109 (void *)&cmd_gso_enable_keyword,
5110 (void *)&cmd_gso_enable_mode,
5115 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
5116 struct cmd_gso_size_result {
5117 cmdline_fixed_string_t cmd_set;
5118 cmdline_fixed_string_t cmd_keyword;
5119 cmdline_fixed_string_t cmd_segsz;
5124 cmd_gso_size_parsed(void *parsed_result,
5125 __attribute__((unused)) struct cmdline *cl,
5126 __attribute__((unused)) void *data)
5128 struct cmd_gso_size_result *res = parsed_result;
5130 if (test_done == 0) {
5131 printf("Before setting GSO segsz, please first"
5132 " stop fowarding\n");
5136 if (!strcmp(res->cmd_keyword, "gso") &&
5137 !strcmp(res->cmd_segsz, "segsz")) {
5138 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
5139 printf("gso_size should be larger than %zu."
5140 " Please input a legal value\n",
5141 RTE_GSO_SEG_SIZE_MIN);
5143 gso_max_segment_size = res->cmd_size;
5147 cmdline_parse_token_string_t cmd_gso_size_set =
5148 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5150 cmdline_parse_token_string_t cmd_gso_size_keyword =
5151 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5152 cmd_keyword, "gso");
5153 cmdline_parse_token_string_t cmd_gso_size_segsz =
5154 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5155 cmd_segsz, "segsz");
5156 cmdline_parse_token_num_t cmd_gso_size_size =
5157 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
5160 cmdline_parse_inst_t cmd_gso_size = {
5161 .f = cmd_gso_size_parsed,
5163 .help_str = "set gso segsz <length>",
5165 (void *)&cmd_gso_size_set,
5166 (void *)&cmd_gso_size_keyword,
5167 (void *)&cmd_gso_size_segsz,
5168 (void *)&cmd_gso_size_size,
5173 /* *** SHOW GSO CONFIGURATION *** */
5174 struct cmd_gso_show_result {
5175 cmdline_fixed_string_t cmd_show;
5176 cmdline_fixed_string_t cmd_port;
5177 cmdline_fixed_string_t cmd_keyword;
5182 cmd_gso_show_parsed(void *parsed_result,
5183 __attribute__((unused)) struct cmdline *cl,
5184 __attribute__((unused)) void *data)
5186 struct cmd_gso_show_result *res = parsed_result;
5188 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
5189 printf("invalid port id %u\n", res->cmd_pid);
5192 if (!strcmp(res->cmd_keyword, "gso")) {
5193 if (gso_ports[res->cmd_pid].enable) {
5194 printf("Max GSO'd packet size: %uB\n"
5195 "Supported GSO types: TCP/IPv4, "
5196 "UDP/IPv4, VxLAN with inner "
5197 "TCP/IPv4 packet, GRE with inner "
5198 "TCP/IPv4 packet\n",
5199 gso_max_segment_size);
5201 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
5205 cmdline_parse_token_string_t cmd_gso_show_show =
5206 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5208 cmdline_parse_token_string_t cmd_gso_show_port =
5209 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5211 cmdline_parse_token_string_t cmd_gso_show_keyword =
5212 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5213 cmd_keyword, "gso");
5214 cmdline_parse_token_num_t cmd_gso_show_pid =
5215 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
5218 cmdline_parse_inst_t cmd_gso_show = {
5219 .f = cmd_gso_show_parsed,
5221 .help_str = "show port <port_id> gso",
5223 (void *)&cmd_gso_show_show,
5224 (void *)&cmd_gso_show_port,
5225 (void *)&cmd_gso_show_pid,
5226 (void *)&cmd_gso_show_keyword,
5231 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
5232 struct cmd_set_flush_rx {
5233 cmdline_fixed_string_t set;
5234 cmdline_fixed_string_t flush_rx;
5235 cmdline_fixed_string_t mode;
5239 cmd_set_flush_rx_parsed(void *parsed_result,
5240 __attribute__((unused)) struct cmdline *cl,
5241 __attribute__((unused)) void *data)
5243 struct cmd_set_flush_rx *res = parsed_result;
5244 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5247 cmdline_parse_token_string_t cmd_setflushrx_set =
5248 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5250 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
5251 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5252 flush_rx, "flush_rx");
5253 cmdline_parse_token_string_t cmd_setflushrx_mode =
5254 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5258 cmdline_parse_inst_t cmd_set_flush_rx = {
5259 .f = cmd_set_flush_rx_parsed,
5260 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
5263 (void *)&cmd_setflushrx_set,
5264 (void *)&cmd_setflushrx_flush_rx,
5265 (void *)&cmd_setflushrx_mode,
5270 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
5271 struct cmd_set_link_check {
5272 cmdline_fixed_string_t set;
5273 cmdline_fixed_string_t link_check;
5274 cmdline_fixed_string_t mode;
5278 cmd_set_link_check_parsed(void *parsed_result,
5279 __attribute__((unused)) struct cmdline *cl,
5280 __attribute__((unused)) void *data)
5282 struct cmd_set_link_check *res = parsed_result;
5283 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5286 cmdline_parse_token_string_t cmd_setlinkcheck_set =
5287 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5289 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
5290 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5291 link_check, "link_check");
5292 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
5293 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5297 cmdline_parse_inst_t cmd_set_link_check = {
5298 .f = cmd_set_link_check_parsed,
5299 .help_str = "set link_check on|off: Enable/Disable link status check "
5300 "when starting/stopping a port",
5303 (void *)&cmd_setlinkcheck_set,
5304 (void *)&cmd_setlinkcheck_link_check,
5305 (void *)&cmd_setlinkcheck_mode,
5310 /* *** SET NIC BYPASS MODE *** */
5311 struct cmd_set_bypass_mode_result {
5312 cmdline_fixed_string_t set;
5313 cmdline_fixed_string_t bypass;
5314 cmdline_fixed_string_t mode;
5315 cmdline_fixed_string_t value;
5320 cmd_set_bypass_mode_parsed(void *parsed_result,
5321 __attribute__((unused)) struct cmdline *cl,
5322 __attribute__((unused)) void *data)
5324 struct cmd_set_bypass_mode_result *res = parsed_result;
5325 portid_t port_id = res->port_id;
5326 int32_t rc = -EINVAL;
5328 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5329 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5331 if (!strcmp(res->value, "bypass"))
5332 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5333 else if (!strcmp(res->value, "isolate"))
5334 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5336 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5338 /* Set the bypass mode for the relevant port. */
5339 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
5342 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
5345 cmdline_parse_token_string_t cmd_setbypass_mode_set =
5346 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5348 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
5349 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5351 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
5352 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5354 cmdline_parse_token_string_t cmd_setbypass_mode_value =
5355 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5356 value, "normal#bypass#isolate");
5357 cmdline_parse_token_num_t cmd_setbypass_mode_port =
5358 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
5361 cmdline_parse_inst_t cmd_set_bypass_mode = {
5362 .f = cmd_set_bypass_mode_parsed,
5363 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
5364 "Set the NIC bypass mode for port_id",
5367 (void *)&cmd_setbypass_mode_set,
5368 (void *)&cmd_setbypass_mode_bypass,
5369 (void *)&cmd_setbypass_mode_mode,
5370 (void *)&cmd_setbypass_mode_value,
5371 (void *)&cmd_setbypass_mode_port,
5376 /* *** SET NIC BYPASS EVENT *** */
5377 struct cmd_set_bypass_event_result {
5378 cmdline_fixed_string_t set;
5379 cmdline_fixed_string_t bypass;
5380 cmdline_fixed_string_t event;
5381 cmdline_fixed_string_t event_value;
5382 cmdline_fixed_string_t mode;
5383 cmdline_fixed_string_t mode_value;
5388 cmd_set_bypass_event_parsed(void *parsed_result,
5389 __attribute__((unused)) struct cmdline *cl,
5390 __attribute__((unused)) void *data)
5392 int32_t rc = -EINVAL;
5393 struct cmd_set_bypass_event_result *res = parsed_result;
5394 portid_t port_id = res->port_id;
5396 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5397 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5398 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5400 if (!strcmp(res->event_value, "timeout"))
5401 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
5402 else if (!strcmp(res->event_value, "os_on"))
5403 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
5404 else if (!strcmp(res->event_value, "os_off"))
5405 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5406 else if (!strcmp(res->event_value, "power_on"))
5407 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5408 else if (!strcmp(res->event_value, "power_off"))
5409 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5411 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5413 if (!strcmp(res->mode_value, "bypass"))
5414 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5415 else if (!strcmp(res->mode_value, "isolate"))
5416 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5418 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5420 /* Set the watchdog timeout. */
5421 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5424 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5425 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5429 printf("Failed to set timeout value %u "
5430 "for port %d, errto code: %d.\n",
5431 bypass_timeout, port_id, rc);
5435 /* Set the bypass event to transition to bypass mode. */
5436 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5441 printf("\t Failed to set bypass event for port = %d.\n",
5445 cmdline_parse_token_string_t cmd_setbypass_event_set =
5446 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5448 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5449 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5451 cmdline_parse_token_string_t cmd_setbypass_event_event =
5452 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5454 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5455 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5456 event_value, "none#timeout#os_off#os_on#power_on#power_off");
5457 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5458 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5460 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5461 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5462 mode_value, "normal#bypass#isolate");
5463 cmdline_parse_token_num_t cmd_setbypass_event_port =
5464 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5467 cmdline_parse_inst_t cmd_set_bypass_event = {
5468 .f = cmd_set_bypass_event_parsed,
5469 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5470 "power_off mode normal|bypass|isolate <port_id>: "
5471 "Set the NIC bypass event mode for port_id",
5474 (void *)&cmd_setbypass_event_set,
5475 (void *)&cmd_setbypass_event_bypass,
5476 (void *)&cmd_setbypass_event_event,
5477 (void *)&cmd_setbypass_event_event_value,
5478 (void *)&cmd_setbypass_event_mode,
5479 (void *)&cmd_setbypass_event_mode_value,
5480 (void *)&cmd_setbypass_event_port,
5486 /* *** SET NIC BYPASS TIMEOUT *** */
5487 struct cmd_set_bypass_timeout_result {
5488 cmdline_fixed_string_t set;
5489 cmdline_fixed_string_t bypass;
5490 cmdline_fixed_string_t timeout;
5491 cmdline_fixed_string_t value;
5495 cmd_set_bypass_timeout_parsed(void *parsed_result,
5496 __attribute__((unused)) struct cmdline *cl,
5497 __attribute__((unused)) void *data)
5499 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5501 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5502 if (!strcmp(res->value, "1.5"))
5503 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5504 else if (!strcmp(res->value, "2"))
5505 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5506 else if (!strcmp(res->value, "3"))
5507 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5508 else if (!strcmp(res->value, "4"))
5509 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5510 else if (!strcmp(res->value, "8"))
5511 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5512 else if (!strcmp(res->value, "16"))
5513 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5514 else if (!strcmp(res->value, "32"))
5515 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5517 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5521 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5522 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5524 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5525 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5527 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5528 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5529 timeout, "timeout");
5530 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5531 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5532 value, "0#1.5#2#3#4#8#16#32");
5534 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5535 .f = cmd_set_bypass_timeout_parsed,
5536 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5537 "Set the NIC bypass watchdog timeout in seconds",
5540 (void *)&cmd_setbypass_timeout_set,
5541 (void *)&cmd_setbypass_timeout_bypass,
5542 (void *)&cmd_setbypass_timeout_timeout,
5543 (void *)&cmd_setbypass_timeout_value,
5548 /* *** SHOW NIC BYPASS MODE *** */
5549 struct cmd_show_bypass_config_result {
5550 cmdline_fixed_string_t show;
5551 cmdline_fixed_string_t bypass;
5552 cmdline_fixed_string_t config;
5557 cmd_show_bypass_config_parsed(void *parsed_result,
5558 __attribute__((unused)) struct cmdline *cl,
5559 __attribute__((unused)) void *data)
5561 struct cmd_show_bypass_config_result *res = parsed_result;
5562 portid_t port_id = res->port_id;
5564 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5565 uint32_t event_mode;
5566 uint32_t bypass_mode;
5567 uint32_t timeout = bypass_timeout;
5570 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5571 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
5572 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5573 {"UNKNOWN", "normal", "bypass", "isolate"};
5574 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5581 int num_events = (sizeof events) / (sizeof events[0]);
5583 /* Display the bypass mode.*/
5584 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5585 printf("\tFailed to get bypass mode for port = %d\n", port_id);
5589 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5590 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5592 printf("\tbypass mode = %s\n", modes[bypass_mode]);
5595 /* Display the bypass timeout.*/
5596 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5597 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5599 printf("\tbypass timeout = %s\n", timeouts[timeout]);
5601 /* Display the bypass events and associated modes. */
5602 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < num_events; i++) {
5604 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5605 printf("\tFailed to get bypass mode for event = %s\n",
5608 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5609 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5611 printf("\tbypass event: %-16s = %s\n", events[i],
5617 printf("\tFailed to get bypass configuration for port = %d\n",
5621 cmdline_parse_token_string_t cmd_showbypass_config_show =
5622 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5624 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5625 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5627 cmdline_parse_token_string_t cmd_showbypass_config_config =
5628 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5630 cmdline_parse_token_num_t cmd_showbypass_config_port =
5631 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5634 cmdline_parse_inst_t cmd_show_bypass_config = {
5635 .f = cmd_show_bypass_config_parsed,
5636 .help_str = "show bypass config <port_id>: "
5637 "Show the NIC bypass config for port_id",
5640 (void *)&cmd_showbypass_config_show,
5641 (void *)&cmd_showbypass_config_bypass,
5642 (void *)&cmd_showbypass_config_config,
5643 (void *)&cmd_showbypass_config_port,
5648 #ifdef RTE_LIBRTE_PMD_BOND
5649 /* *** SET BONDING MODE *** */
5650 struct cmd_set_bonding_mode_result {
5651 cmdline_fixed_string_t set;
5652 cmdline_fixed_string_t bonding;
5653 cmdline_fixed_string_t mode;
5658 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5659 __attribute__((unused)) struct cmdline *cl,
5660 __attribute__((unused)) void *data)
5662 struct cmd_set_bonding_mode_result *res = parsed_result;
5663 portid_t port_id = res->port_id;
5665 /* Set the bonding mode for the relevant port. */
5666 if (0 != rte_eth_bond_mode_set(port_id, res->value))
5667 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
5670 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5671 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5673 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5674 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5675 bonding, "bonding");
5676 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5677 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5679 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5680 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5682 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5683 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5686 cmdline_parse_inst_t cmd_set_bonding_mode = {
5687 .f = cmd_set_bonding_mode_parsed,
5688 .help_str = "set bonding mode <mode_value> <port_id>: "
5689 "Set the bonding mode for port_id",
5692 (void *) &cmd_setbonding_mode_set,
5693 (void *) &cmd_setbonding_mode_bonding,
5694 (void *) &cmd_setbonding_mode_mode,
5695 (void *) &cmd_setbonding_mode_value,
5696 (void *) &cmd_setbonding_mode_port,
5701 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5702 struct cmd_set_bonding_lacp_dedicated_queues_result {
5703 cmdline_fixed_string_t set;
5704 cmdline_fixed_string_t bonding;
5705 cmdline_fixed_string_t lacp;
5706 cmdline_fixed_string_t dedicated_queues;
5708 cmdline_fixed_string_t mode;
5711 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5712 __attribute__((unused)) struct cmdline *cl,
5713 __attribute__((unused)) void *data)
5715 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5716 portid_t port_id = res->port_id;
5717 struct rte_port *port;
5719 port = &ports[port_id];
5721 /** Check if the port is not started **/
5722 if (port->port_status != RTE_PORT_STOPPED) {
5723 printf("Please stop port %d first\n", port_id);
5727 if (!strcmp(res->mode, "enable")) {
5728 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5729 printf("Dedicate queues for LACP control packets"
5732 printf("Enabling dedicate queues for LACP control "
5733 "packets on port %d failed\n", port_id);
5734 } else if (!strcmp(res->mode, "disable")) {
5735 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5736 printf("Dedicated queues for LACP control packets "
5739 printf("Disabling dedicated queues for LACP control "
5740 "traffic on port %d failed\n", port_id);
5744 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5745 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5747 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
5748 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5749 bonding, "bonding");
5750 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
5751 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5753 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
5754 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5755 dedicated_queues, "dedicated_queues");
5756 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
5757 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5759 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
5760 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5761 mode, "enable#disable");
5763 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
5764 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
5765 .help_str = "set bonding lacp dedicated_queues <port_id> "
5767 "Enable/disable dedicated queues for LACP control traffic for port_id",
5770 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
5771 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
5772 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
5773 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
5774 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
5775 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
5780 /* *** SET BALANCE XMIT POLICY *** */
5781 struct cmd_set_bonding_balance_xmit_policy_result {
5782 cmdline_fixed_string_t set;
5783 cmdline_fixed_string_t bonding;
5784 cmdline_fixed_string_t balance_xmit_policy;
5786 cmdline_fixed_string_t policy;
5789 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
5790 __attribute__((unused)) struct cmdline *cl,
5791 __attribute__((unused)) void *data)
5793 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
5794 portid_t port_id = res->port_id;
5797 if (!strcmp(res->policy, "l2")) {
5798 policy = BALANCE_XMIT_POLICY_LAYER2;
5799 } else if (!strcmp(res->policy, "l23")) {
5800 policy = BALANCE_XMIT_POLICY_LAYER23;
5801 } else if (!strcmp(res->policy, "l34")) {
5802 policy = BALANCE_XMIT_POLICY_LAYER34;
5804 printf("\t Invalid xmit policy selection");
5808 /* Set the bonding mode for the relevant port. */
5809 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
5810 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
5815 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
5816 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5818 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
5819 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5820 bonding, "bonding");
5821 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
5822 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5823 balance_xmit_policy, "balance_xmit_policy");
5824 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
5825 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5827 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
5828 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5829 policy, "l2#l23#l34");
5831 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
5832 .f = cmd_set_bonding_balance_xmit_policy_parsed,
5833 .help_str = "set bonding balance_xmit_policy <port_id> "
5835 "Set the bonding balance_xmit_policy for port_id",
5838 (void *)&cmd_setbonding_balance_xmit_policy_set,
5839 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
5840 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
5841 (void *)&cmd_setbonding_balance_xmit_policy_port,
5842 (void *)&cmd_setbonding_balance_xmit_policy_policy,
5847 /* *** SHOW NIC BONDING CONFIGURATION *** */
5848 struct cmd_show_bonding_config_result {
5849 cmdline_fixed_string_t show;
5850 cmdline_fixed_string_t bonding;
5851 cmdline_fixed_string_t config;
5855 static void cmd_show_bonding_config_parsed(void *parsed_result,
5856 __attribute__((unused)) struct cmdline *cl,
5857 __attribute__((unused)) void *data)
5859 struct cmd_show_bonding_config_result *res = parsed_result;
5860 int bonding_mode, agg_mode;
5861 portid_t slaves[RTE_MAX_ETHPORTS];
5862 int num_slaves, num_active_slaves;
5865 portid_t port_id = res->port_id;
5867 /* Display the bonding mode.*/
5868 bonding_mode = rte_eth_bond_mode_get(port_id);
5869 if (bonding_mode < 0) {
5870 printf("\tFailed to get bonding mode for port = %d\n", port_id);
5873 printf("\tBonding mode: %d\n", bonding_mode);
5875 if (bonding_mode == BONDING_MODE_BALANCE) {
5876 int balance_xmit_policy;
5878 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
5879 if (balance_xmit_policy < 0) {
5880 printf("\tFailed to get balance xmit policy for port = %d\n",
5884 printf("\tBalance Xmit Policy: ");
5886 switch (balance_xmit_policy) {
5887 case BALANCE_XMIT_POLICY_LAYER2:
5888 printf("BALANCE_XMIT_POLICY_LAYER2");
5890 case BALANCE_XMIT_POLICY_LAYER23:
5891 printf("BALANCE_XMIT_POLICY_LAYER23");
5893 case BALANCE_XMIT_POLICY_LAYER34:
5894 printf("BALANCE_XMIT_POLICY_LAYER34");
5901 if (bonding_mode == BONDING_MODE_8023AD) {
5902 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
5903 printf("\tIEEE802.3AD Aggregator Mode: ");
5906 printf("bandwidth");
5918 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
5920 if (num_slaves < 0) {
5921 printf("\tFailed to get slave list for port = %d\n", port_id);
5924 if (num_slaves > 0) {
5925 printf("\tSlaves (%d): [", num_slaves);
5926 for (i = 0; i < num_slaves - 1; i++)
5927 printf("%d ", slaves[i]);
5929 printf("%d]\n", slaves[num_slaves - 1]);
5931 printf("\tSlaves: []\n");
5935 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
5938 if (num_active_slaves < 0) {
5939 printf("\tFailed to get active slave list for port = %d\n", port_id);
5942 if (num_active_slaves > 0) {
5943 printf("\tActive Slaves (%d): [", num_active_slaves);
5944 for (i = 0; i < num_active_slaves - 1; i++)
5945 printf("%d ", slaves[i]);
5947 printf("%d]\n", slaves[num_active_slaves - 1]);
5950 printf("\tActive Slaves: []\n");
5954 primary_id = rte_eth_bond_primary_get(port_id);
5955 if (primary_id < 0) {
5956 printf("\tFailed to get primary slave for port = %d\n", port_id);
5959 printf("\tPrimary: [%d]\n", primary_id);
5963 cmdline_parse_token_string_t cmd_showbonding_config_show =
5964 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5966 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
5967 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5968 bonding, "bonding");
5969 cmdline_parse_token_string_t cmd_showbonding_config_config =
5970 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5972 cmdline_parse_token_num_t cmd_showbonding_config_port =
5973 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
5976 cmdline_parse_inst_t cmd_show_bonding_config = {
5977 .f = cmd_show_bonding_config_parsed,
5978 .help_str = "show bonding config <port_id>: "
5979 "Show the bonding config for port_id",
5982 (void *)&cmd_showbonding_config_show,
5983 (void *)&cmd_showbonding_config_bonding,
5984 (void *)&cmd_showbonding_config_config,
5985 (void *)&cmd_showbonding_config_port,
5990 /* *** SET BONDING PRIMARY *** */
5991 struct cmd_set_bonding_primary_result {
5992 cmdline_fixed_string_t set;
5993 cmdline_fixed_string_t bonding;
5994 cmdline_fixed_string_t primary;
5999 static void cmd_set_bonding_primary_parsed(void *parsed_result,
6000 __attribute__((unused)) struct cmdline *cl,
6001 __attribute__((unused)) void *data)
6003 struct cmd_set_bonding_primary_result *res = parsed_result;
6004 portid_t master_port_id = res->port_id;
6005 portid_t slave_port_id = res->slave_id;
6007 /* Set the primary slave for a bonded device. */
6008 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
6009 printf("\t Failed to set primary slave for port = %d.\n",
6016 cmdline_parse_token_string_t cmd_setbonding_primary_set =
6017 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6019 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
6020 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6021 bonding, "bonding");
6022 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
6023 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6024 primary, "primary");
6025 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
6026 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6028 cmdline_parse_token_num_t cmd_setbonding_primary_port =
6029 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6032 cmdline_parse_inst_t cmd_set_bonding_primary = {
6033 .f = cmd_set_bonding_primary_parsed,
6034 .help_str = "set bonding primary <slave_id> <port_id>: "
6035 "Set the primary slave for port_id",
6038 (void *)&cmd_setbonding_primary_set,
6039 (void *)&cmd_setbonding_primary_bonding,
6040 (void *)&cmd_setbonding_primary_primary,
6041 (void *)&cmd_setbonding_primary_slave,
6042 (void *)&cmd_setbonding_primary_port,
6047 /* *** ADD SLAVE *** */
6048 struct cmd_add_bonding_slave_result {
6049 cmdline_fixed_string_t add;
6050 cmdline_fixed_string_t bonding;
6051 cmdline_fixed_string_t slave;
6056 static void cmd_add_bonding_slave_parsed(void *parsed_result,
6057 __attribute__((unused)) struct cmdline *cl,
6058 __attribute__((unused)) void *data)
6060 struct cmd_add_bonding_slave_result *res = parsed_result;
6061 portid_t master_port_id = res->port_id;
6062 portid_t slave_port_id = res->slave_id;
6064 /* add the slave for a bonded device. */
6065 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
6066 printf("\t Failed to add slave %d to master port = %d.\n",
6067 slave_port_id, master_port_id);
6071 set_port_slave_flag(slave_port_id);
6074 cmdline_parse_token_string_t cmd_addbonding_slave_add =
6075 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6077 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
6078 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6079 bonding, "bonding");
6080 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
6081 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6083 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
6084 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6086 cmdline_parse_token_num_t cmd_addbonding_slave_port =
6087 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6090 cmdline_parse_inst_t cmd_add_bonding_slave = {
6091 .f = cmd_add_bonding_slave_parsed,
6092 .help_str = "add bonding slave <slave_id> <port_id>: "
6093 "Add a slave device to a bonded device",
6096 (void *)&cmd_addbonding_slave_add,
6097 (void *)&cmd_addbonding_slave_bonding,
6098 (void *)&cmd_addbonding_slave_slave,
6099 (void *)&cmd_addbonding_slave_slaveid,
6100 (void *)&cmd_addbonding_slave_port,
6105 /* *** REMOVE SLAVE *** */
6106 struct cmd_remove_bonding_slave_result {
6107 cmdline_fixed_string_t remove;
6108 cmdline_fixed_string_t bonding;
6109 cmdline_fixed_string_t slave;
6114 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
6115 __attribute__((unused)) struct cmdline *cl,
6116 __attribute__((unused)) void *data)
6118 struct cmd_remove_bonding_slave_result *res = parsed_result;
6119 portid_t master_port_id = res->port_id;
6120 portid_t slave_port_id = res->slave_id;
6122 /* remove the slave from a bonded device. */
6123 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
6124 printf("\t Failed to remove slave %d from master port = %d.\n",
6125 slave_port_id, master_port_id);
6129 clear_port_slave_flag(slave_port_id);
6132 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
6133 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6135 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
6136 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6137 bonding, "bonding");
6138 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
6139 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6141 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
6142 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6144 cmdline_parse_token_num_t cmd_removebonding_slave_port =
6145 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6148 cmdline_parse_inst_t cmd_remove_bonding_slave = {
6149 .f = cmd_remove_bonding_slave_parsed,
6150 .help_str = "remove bonding slave <slave_id> <port_id>: "
6151 "Remove a slave device from a bonded device",
6154 (void *)&cmd_removebonding_slave_remove,
6155 (void *)&cmd_removebonding_slave_bonding,
6156 (void *)&cmd_removebonding_slave_slave,
6157 (void *)&cmd_removebonding_slave_slaveid,
6158 (void *)&cmd_removebonding_slave_port,
6163 /* *** CREATE BONDED DEVICE *** */
6164 struct cmd_create_bonded_device_result {
6165 cmdline_fixed_string_t create;
6166 cmdline_fixed_string_t bonded;
6167 cmdline_fixed_string_t device;
6172 static int bond_dev_num = 0;
6174 static void cmd_create_bonded_device_parsed(void *parsed_result,
6175 __attribute__((unused)) struct cmdline *cl,
6176 __attribute__((unused)) void *data)
6178 struct cmd_create_bonded_device_result *res = parsed_result;
6179 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
6183 if (test_done == 0) {
6184 printf("Please stop forwarding first\n");
6188 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
6191 /* Create a new bonded device. */
6192 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
6194 printf("\t Failed to create bonded device.\n");
6197 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
6200 /* Update number of ports */
6201 nb_ports = rte_eth_dev_count_avail();
6202 reconfig(port_id, res->socket);
6203 ret = rte_eth_promiscuous_enable(port_id);
6205 printf("Failed to enable promiscuous mode for port %u: %s - ignore\n",
6206 port_id, rte_strerror(-ret));
6208 ports[port_id].need_setup = 0;
6209 ports[port_id].port_status = RTE_PORT_STOPPED;
6214 cmdline_parse_token_string_t cmd_createbonded_device_create =
6215 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6217 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
6218 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6220 cmdline_parse_token_string_t cmd_createbonded_device_device =
6221 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6223 cmdline_parse_token_num_t cmd_createbonded_device_mode =
6224 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6226 cmdline_parse_token_num_t cmd_createbonded_device_socket =
6227 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6230 cmdline_parse_inst_t cmd_create_bonded_device = {
6231 .f = cmd_create_bonded_device_parsed,
6232 .help_str = "create bonded device <mode> <socket>: "
6233 "Create a new bonded device with specific bonding mode and socket",
6236 (void *)&cmd_createbonded_device_create,
6237 (void *)&cmd_createbonded_device_bonded,
6238 (void *)&cmd_createbonded_device_device,
6239 (void *)&cmd_createbonded_device_mode,
6240 (void *)&cmd_createbonded_device_socket,
6245 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
6246 struct cmd_set_bond_mac_addr_result {
6247 cmdline_fixed_string_t set;
6248 cmdline_fixed_string_t bonding;
6249 cmdline_fixed_string_t mac_addr;
6251 struct rte_ether_addr address;
6254 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
6255 __attribute__((unused)) struct cmdline *cl,
6256 __attribute__((unused)) void *data)
6258 struct cmd_set_bond_mac_addr_result *res = parsed_result;
6261 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
6264 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
6266 /* check the return value and print it if is < 0 */
6268 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6271 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
6272 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
6273 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
6274 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
6276 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
6277 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
6279 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
6280 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
6282 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
6283 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
6285 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
6286 .f = cmd_set_bond_mac_addr_parsed,
6288 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
6290 (void *)&cmd_set_bond_mac_addr_set,
6291 (void *)&cmd_set_bond_mac_addr_bonding,
6292 (void *)&cmd_set_bond_mac_addr_mac,
6293 (void *)&cmd_set_bond_mac_addr_portnum,
6294 (void *)&cmd_set_bond_mac_addr_addr,
6300 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
6301 struct cmd_set_bond_mon_period_result {
6302 cmdline_fixed_string_t set;
6303 cmdline_fixed_string_t bonding;
6304 cmdline_fixed_string_t mon_period;
6309 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
6310 __attribute__((unused)) struct cmdline *cl,
6311 __attribute__((unused)) void *data)
6313 struct cmd_set_bond_mon_period_result *res = parsed_result;
6316 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
6318 /* check the return value and print it if is < 0 */
6320 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6323 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
6324 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6326 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
6327 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6328 bonding, "bonding");
6329 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
6330 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6331 mon_period, "mon_period");
6332 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
6333 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6335 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
6336 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6339 cmdline_parse_inst_t cmd_set_bond_mon_period = {
6340 .f = cmd_set_bond_mon_period_parsed,
6342 .help_str = "set bonding mon_period <port_id> <period_ms>",
6344 (void *)&cmd_set_bond_mon_period_set,
6345 (void *)&cmd_set_bond_mon_period_bonding,
6346 (void *)&cmd_set_bond_mon_period_mon_period,
6347 (void *)&cmd_set_bond_mon_period_portnum,
6348 (void *)&cmd_set_bond_mon_period_period_ms,
6355 struct cmd_set_bonding_agg_mode_policy_result {
6356 cmdline_fixed_string_t set;
6357 cmdline_fixed_string_t bonding;
6358 cmdline_fixed_string_t agg_mode;
6360 cmdline_fixed_string_t policy;
6365 cmd_set_bonding_agg_mode(void *parsed_result,
6366 __attribute__((unused)) struct cmdline *cl,
6367 __attribute__((unused)) void *data)
6369 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
6370 uint8_t policy = AGG_BANDWIDTH;
6372 if (!strcmp(res->policy, "bandwidth"))
6373 policy = AGG_BANDWIDTH;
6374 else if (!strcmp(res->policy, "stable"))
6375 policy = AGG_STABLE;
6376 else if (!strcmp(res->policy, "count"))
6379 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
6383 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
6384 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6386 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
6387 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6388 bonding, "bonding");
6390 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
6391 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6392 agg_mode, "agg_mode");
6394 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
6395 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6398 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6399 TOKEN_STRING_INITIALIZER(
6400 struct cmd_set_bonding_balance_xmit_policy_result,
6401 policy, "stable#bandwidth#count");
6403 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6404 .f = cmd_set_bonding_agg_mode,
6406 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6408 (void *)&cmd_set_bonding_agg_mode_set,
6409 (void *)&cmd_set_bonding_agg_mode_bonding,
6410 (void *)&cmd_set_bonding_agg_mode_agg_mode,
6411 (void *)&cmd_set_bonding_agg_mode_portnum,
6412 (void *)&cmd_set_bonding_agg_mode_policy_string,
6418 #endif /* RTE_LIBRTE_PMD_BOND */
6420 /* *** SET FORWARDING MODE *** */
6421 struct cmd_set_fwd_mode_result {
6422 cmdline_fixed_string_t set;
6423 cmdline_fixed_string_t fwd;
6424 cmdline_fixed_string_t mode;
6427 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6428 __attribute__((unused)) struct cmdline *cl,
6429 __attribute__((unused)) void *data)
6431 struct cmd_set_fwd_mode_result *res = parsed_result;
6434 set_pkt_forwarding_mode(res->mode);
6437 cmdline_parse_token_string_t cmd_setfwd_set =
6438 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6439 cmdline_parse_token_string_t cmd_setfwd_fwd =
6440 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6441 cmdline_parse_token_string_t cmd_setfwd_mode =
6442 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6443 "" /* defined at init */);
6445 cmdline_parse_inst_t cmd_set_fwd_mode = {
6446 .f = cmd_set_fwd_mode_parsed,
6448 .help_str = NULL, /* defined at init */
6450 (void *)&cmd_setfwd_set,
6451 (void *)&cmd_setfwd_fwd,
6452 (void *)&cmd_setfwd_mode,
6457 static void cmd_set_fwd_mode_init(void)
6460 static char token[128];
6461 static char help[256];
6462 cmdline_parse_token_string_t *token_struct;
6464 modes = list_pkt_forwarding_modes();
6465 snprintf(help, sizeof(help), "set fwd %s: "
6466 "Set packet forwarding mode", modes);
6467 cmd_set_fwd_mode.help_str = help;
6469 /* string token separator is # */
6470 for (c = token; *modes != '\0'; modes++)
6475 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6476 token_struct->string_data.str = token;
6479 /* *** SET RETRY FORWARDING MODE *** */
6480 struct cmd_set_fwd_retry_mode_result {
6481 cmdline_fixed_string_t set;
6482 cmdline_fixed_string_t fwd;
6483 cmdline_fixed_string_t mode;
6484 cmdline_fixed_string_t retry;
6487 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6488 __attribute__((unused)) struct cmdline *cl,
6489 __attribute__((unused)) void *data)
6491 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6494 set_pkt_forwarding_mode(res->mode);
6497 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6498 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6500 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6501 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6503 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6504 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6506 "" /* defined at init */);
6507 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6508 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6511 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6512 .f = cmd_set_fwd_retry_mode_parsed,
6514 .help_str = NULL, /* defined at init */
6516 (void *)&cmd_setfwd_retry_set,
6517 (void *)&cmd_setfwd_retry_fwd,
6518 (void *)&cmd_setfwd_retry_mode,
6519 (void *)&cmd_setfwd_retry_retry,
6524 static void cmd_set_fwd_retry_mode_init(void)
6527 static char token[128];
6528 static char help[256];
6529 cmdline_parse_token_string_t *token_struct;
6531 modes = list_pkt_forwarding_retry_modes();
6532 snprintf(help, sizeof(help), "set fwd %s retry: "
6533 "Set packet forwarding mode with retry", modes);
6534 cmd_set_fwd_retry_mode.help_str = help;
6536 /* string token separator is # */
6537 for (c = token; *modes != '\0'; modes++)
6542 token_struct = (cmdline_parse_token_string_t *)
6543 cmd_set_fwd_retry_mode.tokens[2];
6544 token_struct->string_data.str = token;
6547 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6548 struct cmd_set_burst_tx_retry_result {
6549 cmdline_fixed_string_t set;
6550 cmdline_fixed_string_t burst;
6551 cmdline_fixed_string_t tx;
6552 cmdline_fixed_string_t delay;
6554 cmdline_fixed_string_t retry;
6558 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6559 __attribute__((unused)) struct cmdline *cl,
6560 __attribute__((unused)) void *data)
6562 struct cmd_set_burst_tx_retry_result *res = parsed_result;
6564 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6565 && !strcmp(res->tx, "tx")) {
6566 if (!strcmp(res->delay, "delay"))
6567 burst_tx_delay_time = res->time;
6568 if (!strcmp(res->retry, "retry"))
6569 burst_tx_retry_num = res->retry_num;
6574 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6575 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6576 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6577 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6579 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6580 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6581 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6582 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6583 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6584 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
6585 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6586 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6587 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6588 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
6590 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6591 .f = cmd_set_burst_tx_retry_parsed,
6592 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6594 (void *)&cmd_set_burst_tx_retry_set,
6595 (void *)&cmd_set_burst_tx_retry_burst,
6596 (void *)&cmd_set_burst_tx_retry_tx,
6597 (void *)&cmd_set_burst_tx_retry_delay,
6598 (void *)&cmd_set_burst_tx_retry_time,
6599 (void *)&cmd_set_burst_tx_retry_retry,
6600 (void *)&cmd_set_burst_tx_retry_retry_num,
6605 /* *** SET PROMISC MODE *** */
6606 struct cmd_set_promisc_mode_result {
6607 cmdline_fixed_string_t set;
6608 cmdline_fixed_string_t promisc;
6609 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6610 uint16_t port_num; /* valid if "allports" argument == 0 */
6611 cmdline_fixed_string_t mode;
6614 static void cmd_set_promisc_mode_parsed(void *parsed_result,
6615 __attribute__((unused)) struct cmdline *cl,
6618 struct cmd_set_promisc_mode_result *res = parsed_result;
6622 if (!strcmp(res->mode, "on"))
6629 RTE_ETH_FOREACH_DEV(i)
6630 eth_set_promisc_mode(i, enable);
6632 eth_set_promisc_mode(res->port_num, enable);
6636 cmdline_parse_token_string_t cmd_setpromisc_set =
6637 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6638 cmdline_parse_token_string_t cmd_setpromisc_promisc =
6639 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6641 cmdline_parse_token_string_t cmd_setpromisc_portall =
6642 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6644 cmdline_parse_token_num_t cmd_setpromisc_portnum =
6645 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6647 cmdline_parse_token_string_t cmd_setpromisc_mode =
6648 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6651 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6652 .f = cmd_set_promisc_mode_parsed,
6654 .help_str = "set promisc all on|off: Set promisc mode for all ports",
6656 (void *)&cmd_setpromisc_set,
6657 (void *)&cmd_setpromisc_promisc,
6658 (void *)&cmd_setpromisc_portall,
6659 (void *)&cmd_setpromisc_mode,
6664 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6665 .f = cmd_set_promisc_mode_parsed,
6667 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6669 (void *)&cmd_setpromisc_set,
6670 (void *)&cmd_setpromisc_promisc,
6671 (void *)&cmd_setpromisc_portnum,
6672 (void *)&cmd_setpromisc_mode,
6677 /* *** SET ALLMULTI MODE *** */
6678 struct cmd_set_allmulti_mode_result {
6679 cmdline_fixed_string_t set;
6680 cmdline_fixed_string_t allmulti;
6681 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6682 uint16_t port_num; /* valid if "allports" argument == 0 */
6683 cmdline_fixed_string_t mode;
6686 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6687 __attribute__((unused)) struct cmdline *cl,
6690 struct cmd_set_allmulti_mode_result *res = parsed_result;
6694 if (!strcmp(res->mode, "on"))
6701 RTE_ETH_FOREACH_DEV(i) {
6702 eth_set_allmulticast_mode(i, enable);
6706 eth_set_allmulticast_mode(res->port_num, enable);
6710 cmdline_parse_token_string_t cmd_setallmulti_set =
6711 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6712 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6713 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6715 cmdline_parse_token_string_t cmd_setallmulti_portall =
6716 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6718 cmdline_parse_token_num_t cmd_setallmulti_portnum =
6719 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6721 cmdline_parse_token_string_t cmd_setallmulti_mode =
6722 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6725 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6726 .f = cmd_set_allmulti_mode_parsed,
6728 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6730 (void *)&cmd_setallmulti_set,
6731 (void *)&cmd_setallmulti_allmulti,
6732 (void *)&cmd_setallmulti_portall,
6733 (void *)&cmd_setallmulti_mode,
6738 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6739 .f = cmd_set_allmulti_mode_parsed,
6741 .help_str = "set allmulti <port_id> on|off: "
6742 "Set allmulti mode on port_id",
6744 (void *)&cmd_setallmulti_set,
6745 (void *)&cmd_setallmulti_allmulti,
6746 (void *)&cmd_setallmulti_portnum,
6747 (void *)&cmd_setallmulti_mode,
6752 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
6753 struct cmd_link_flow_ctrl_set_result {
6754 cmdline_fixed_string_t set;
6755 cmdline_fixed_string_t flow_ctrl;
6756 cmdline_fixed_string_t rx;
6757 cmdline_fixed_string_t rx_lfc_mode;
6758 cmdline_fixed_string_t tx;
6759 cmdline_fixed_string_t tx_lfc_mode;
6760 cmdline_fixed_string_t mac_ctrl_frame_fwd;
6761 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
6762 cmdline_fixed_string_t autoneg_str;
6763 cmdline_fixed_string_t autoneg;
6764 cmdline_fixed_string_t hw_str;
6765 uint32_t high_water;
6766 cmdline_fixed_string_t lw_str;
6768 cmdline_fixed_string_t pt_str;
6769 uint16_t pause_time;
6770 cmdline_fixed_string_t xon_str;
6775 cmdline_parse_token_string_t cmd_lfc_set_set =
6776 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6778 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
6779 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6780 flow_ctrl, "flow_ctrl");
6781 cmdline_parse_token_string_t cmd_lfc_set_rx =
6782 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6784 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
6785 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6786 rx_lfc_mode, "on#off");
6787 cmdline_parse_token_string_t cmd_lfc_set_tx =
6788 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6790 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
6791 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6792 tx_lfc_mode, "on#off");
6793 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
6794 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6795 hw_str, "high_water");
6796 cmdline_parse_token_num_t cmd_lfc_set_high_water =
6797 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6798 high_water, UINT32);
6799 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
6800 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6801 lw_str, "low_water");
6802 cmdline_parse_token_num_t cmd_lfc_set_low_water =
6803 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6805 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
6806 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6807 pt_str, "pause_time");
6808 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
6809 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6810 pause_time, UINT16);
6811 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
6812 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6813 xon_str, "send_xon");
6814 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
6815 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6817 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
6818 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6819 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
6820 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6821 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6822 mac_ctrl_frame_fwd_mode, "on#off");
6823 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6824 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6825 autoneg_str, "autoneg");
6826 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6827 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6829 cmdline_parse_token_num_t cmd_lfc_set_portid =
6830 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6833 /* forward declaration */
6835 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6838 cmdline_parse_inst_t cmd_link_flow_control_set = {
6839 .f = cmd_link_flow_ctrl_set_parsed,
6841 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6842 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6843 "autoneg on|off <port_id>: Configure the Ethernet flow control",
6845 (void *)&cmd_lfc_set_set,
6846 (void *)&cmd_lfc_set_flow_ctrl,
6847 (void *)&cmd_lfc_set_rx,
6848 (void *)&cmd_lfc_set_rx_mode,
6849 (void *)&cmd_lfc_set_tx,
6850 (void *)&cmd_lfc_set_tx_mode,
6851 (void *)&cmd_lfc_set_high_water,
6852 (void *)&cmd_lfc_set_low_water,
6853 (void *)&cmd_lfc_set_pause_time,
6854 (void *)&cmd_lfc_set_send_xon,
6855 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6856 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6857 (void *)&cmd_lfc_set_autoneg_str,
6858 (void *)&cmd_lfc_set_autoneg,
6859 (void *)&cmd_lfc_set_portid,
6864 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6865 .f = cmd_link_flow_ctrl_set_parsed,
6866 .data = (void *)&cmd_link_flow_control_set_rx,
6867 .help_str = "set flow_ctrl rx on|off <port_id>: "
6868 "Change rx flow control parameter",
6870 (void *)&cmd_lfc_set_set,
6871 (void *)&cmd_lfc_set_flow_ctrl,
6872 (void *)&cmd_lfc_set_rx,
6873 (void *)&cmd_lfc_set_rx_mode,
6874 (void *)&cmd_lfc_set_portid,
6879 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6880 .f = cmd_link_flow_ctrl_set_parsed,
6881 .data = (void *)&cmd_link_flow_control_set_tx,
6882 .help_str = "set flow_ctrl tx on|off <port_id>: "
6883 "Change tx flow control parameter",
6885 (void *)&cmd_lfc_set_set,
6886 (void *)&cmd_lfc_set_flow_ctrl,
6887 (void *)&cmd_lfc_set_tx,
6888 (void *)&cmd_lfc_set_tx_mode,
6889 (void *)&cmd_lfc_set_portid,
6894 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
6895 .f = cmd_link_flow_ctrl_set_parsed,
6896 .data = (void *)&cmd_link_flow_control_set_hw,
6897 .help_str = "set flow_ctrl high_water <value> <port_id>: "
6898 "Change high water flow control parameter",
6900 (void *)&cmd_lfc_set_set,
6901 (void *)&cmd_lfc_set_flow_ctrl,
6902 (void *)&cmd_lfc_set_high_water_str,
6903 (void *)&cmd_lfc_set_high_water,
6904 (void *)&cmd_lfc_set_portid,
6909 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
6910 .f = cmd_link_flow_ctrl_set_parsed,
6911 .data = (void *)&cmd_link_flow_control_set_lw,
6912 .help_str = "set flow_ctrl low_water <value> <port_id>: "
6913 "Change low water flow control parameter",
6915 (void *)&cmd_lfc_set_set,
6916 (void *)&cmd_lfc_set_flow_ctrl,
6917 (void *)&cmd_lfc_set_low_water_str,
6918 (void *)&cmd_lfc_set_low_water,
6919 (void *)&cmd_lfc_set_portid,
6924 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
6925 .f = cmd_link_flow_ctrl_set_parsed,
6926 .data = (void *)&cmd_link_flow_control_set_pt,
6927 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
6928 "Change pause time flow control parameter",
6930 (void *)&cmd_lfc_set_set,
6931 (void *)&cmd_lfc_set_flow_ctrl,
6932 (void *)&cmd_lfc_set_pause_time_str,
6933 (void *)&cmd_lfc_set_pause_time,
6934 (void *)&cmd_lfc_set_portid,
6939 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
6940 .f = cmd_link_flow_ctrl_set_parsed,
6941 .data = (void *)&cmd_link_flow_control_set_xon,
6942 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
6943 "Change send_xon flow control parameter",
6945 (void *)&cmd_lfc_set_set,
6946 (void *)&cmd_lfc_set_flow_ctrl,
6947 (void *)&cmd_lfc_set_send_xon_str,
6948 (void *)&cmd_lfc_set_send_xon,
6949 (void *)&cmd_lfc_set_portid,
6954 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
6955 .f = cmd_link_flow_ctrl_set_parsed,
6956 .data = (void *)&cmd_link_flow_control_set_macfwd,
6957 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
6958 "Change mac ctrl fwd flow control parameter",
6960 (void *)&cmd_lfc_set_set,
6961 (void *)&cmd_lfc_set_flow_ctrl,
6962 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6963 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6964 (void *)&cmd_lfc_set_portid,
6969 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
6970 .f = cmd_link_flow_ctrl_set_parsed,
6971 .data = (void *)&cmd_link_flow_control_set_autoneg,
6972 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
6973 "Change autoneg flow control parameter",
6975 (void *)&cmd_lfc_set_set,
6976 (void *)&cmd_lfc_set_flow_ctrl,
6977 (void *)&cmd_lfc_set_autoneg_str,
6978 (void *)&cmd_lfc_set_autoneg,
6979 (void *)&cmd_lfc_set_portid,
6985 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
6986 __attribute__((unused)) struct cmdline *cl,
6989 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
6990 cmdline_parse_inst_t *cmd = data;
6991 struct rte_eth_fc_conf fc_conf;
6997 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6998 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6999 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7000 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7002 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
7003 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7006 /* Partial command line, retrieve current configuration */
7008 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
7010 printf("cannot get current flow ctrl parameters, return"
7011 "code = %d\n", ret);
7015 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
7016 (fc_conf.mode == RTE_FC_FULL))
7018 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
7019 (fc_conf.mode == RTE_FC_FULL))
7023 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
7024 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
7026 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
7027 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
7029 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
7031 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
7032 fc_conf.high_water = res->high_water;
7034 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
7035 fc_conf.low_water = res->low_water;
7037 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
7038 fc_conf.pause_time = res->pause_time;
7040 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
7041 fc_conf.send_xon = res->send_xon;
7043 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
7044 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
7045 fc_conf.mac_ctrl_frame_fwd = 1;
7047 fc_conf.mac_ctrl_frame_fwd = 0;
7050 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
7051 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
7053 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
7055 printf("bad flow contrl parameter, return code = %d \n", ret);
7058 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
7059 struct cmd_priority_flow_ctrl_set_result {
7060 cmdline_fixed_string_t set;
7061 cmdline_fixed_string_t pfc_ctrl;
7062 cmdline_fixed_string_t rx;
7063 cmdline_fixed_string_t rx_pfc_mode;
7064 cmdline_fixed_string_t tx;
7065 cmdline_fixed_string_t tx_pfc_mode;
7066 uint32_t high_water;
7068 uint16_t pause_time;
7074 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
7075 __attribute__((unused)) struct cmdline *cl,
7076 __attribute__((unused)) void *data)
7078 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
7079 struct rte_eth_pfc_conf pfc_conf;
7080 int rx_fc_enable, tx_fc_enable;
7084 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7085 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7086 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7087 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7089 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
7090 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
7093 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
7094 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
7095 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
7096 pfc_conf.fc.high_water = res->high_water;
7097 pfc_conf.fc.low_water = res->low_water;
7098 pfc_conf.fc.pause_time = res->pause_time;
7099 pfc_conf.priority = res->priority;
7101 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
7103 printf("bad priority flow contrl parameter, return code = %d \n", ret);
7106 cmdline_parse_token_string_t cmd_pfc_set_set =
7107 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7109 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
7110 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7111 pfc_ctrl, "pfc_ctrl");
7112 cmdline_parse_token_string_t cmd_pfc_set_rx =
7113 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7115 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
7116 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7117 rx_pfc_mode, "on#off");
7118 cmdline_parse_token_string_t cmd_pfc_set_tx =
7119 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7121 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
7122 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7123 tx_pfc_mode, "on#off");
7124 cmdline_parse_token_num_t cmd_pfc_set_high_water =
7125 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7126 high_water, UINT32);
7127 cmdline_parse_token_num_t cmd_pfc_set_low_water =
7128 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7130 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
7131 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7132 pause_time, UINT16);
7133 cmdline_parse_token_num_t cmd_pfc_set_priority =
7134 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7136 cmdline_parse_token_num_t cmd_pfc_set_portid =
7137 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7140 cmdline_parse_inst_t cmd_priority_flow_control_set = {
7141 .f = cmd_priority_flow_ctrl_set_parsed,
7143 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
7144 "<pause_time> <priority> <port_id>: "
7145 "Configure the Ethernet priority flow control",
7147 (void *)&cmd_pfc_set_set,
7148 (void *)&cmd_pfc_set_flow_ctrl,
7149 (void *)&cmd_pfc_set_rx,
7150 (void *)&cmd_pfc_set_rx_mode,
7151 (void *)&cmd_pfc_set_tx,
7152 (void *)&cmd_pfc_set_tx_mode,
7153 (void *)&cmd_pfc_set_high_water,
7154 (void *)&cmd_pfc_set_low_water,
7155 (void *)&cmd_pfc_set_pause_time,
7156 (void *)&cmd_pfc_set_priority,
7157 (void *)&cmd_pfc_set_portid,
7162 /* *** RESET CONFIGURATION *** */
7163 struct cmd_reset_result {
7164 cmdline_fixed_string_t reset;
7165 cmdline_fixed_string_t def;
7168 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
7170 __attribute__((unused)) void *data)
7172 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
7173 set_def_fwd_config();
7176 cmdline_parse_token_string_t cmd_reset_set =
7177 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
7178 cmdline_parse_token_string_t cmd_reset_def =
7179 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
7182 cmdline_parse_inst_t cmd_reset = {
7183 .f = cmd_reset_parsed,
7185 .help_str = "set default: Reset default forwarding configuration",
7187 (void *)&cmd_reset_set,
7188 (void *)&cmd_reset_def,
7193 /* *** START FORWARDING *** */
7194 struct cmd_start_result {
7195 cmdline_fixed_string_t start;
7198 cmdline_parse_token_string_t cmd_start_start =
7199 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
7201 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
7202 __attribute__((unused)) struct cmdline *cl,
7203 __attribute__((unused)) void *data)
7205 start_packet_forwarding(0);
7208 cmdline_parse_inst_t cmd_start = {
7209 .f = cmd_start_parsed,
7211 .help_str = "start: Start packet forwarding",
7213 (void *)&cmd_start_start,
7218 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7219 struct cmd_start_tx_first_result {
7220 cmdline_fixed_string_t start;
7221 cmdline_fixed_string_t tx_first;
7225 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
7226 __attribute__((unused)) struct cmdline *cl,
7227 __attribute__((unused)) void *data)
7229 start_packet_forwarding(1);
7232 cmdline_parse_token_string_t cmd_start_tx_first_start =
7233 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7235 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7236 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7237 tx_first, "tx_first");
7239 cmdline_parse_inst_t cmd_start_tx_first = {
7240 .f = cmd_start_tx_first_parsed,
7242 .help_str = "start tx_first: Start packet forwarding, "
7243 "after sending 1 burst of packets",
7245 (void *)&cmd_start_tx_first_start,
7246 (void *)&cmd_start_tx_first_tx_first,
7251 /* *** START FORWARDING WITH N TX BURST FIRST *** */
7252 struct cmd_start_tx_first_n_result {
7253 cmdline_fixed_string_t start;
7254 cmdline_fixed_string_t tx_first;
7259 cmd_start_tx_first_n_parsed(void *parsed_result,
7260 __attribute__((unused)) struct cmdline *cl,
7261 __attribute__((unused)) void *data)
7263 struct cmd_start_tx_first_n_result *res = parsed_result;
7265 start_packet_forwarding(res->tx_num);
7268 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7269 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7271 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7272 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7273 tx_first, "tx_first");
7274 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7275 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7278 cmdline_parse_inst_t cmd_start_tx_first_n = {
7279 .f = cmd_start_tx_first_n_parsed,
7281 .help_str = "start tx_first <num>: "
7282 "packet forwarding, after sending <num> bursts of packets",
7284 (void *)&cmd_start_tx_first_n_start,
7285 (void *)&cmd_start_tx_first_n_tx_first,
7286 (void *)&cmd_start_tx_first_n_tx_num,
7291 /* *** SET LINK UP *** */
7292 struct cmd_set_link_up_result {
7293 cmdline_fixed_string_t set;
7294 cmdline_fixed_string_t link_up;
7295 cmdline_fixed_string_t port;
7299 cmdline_parse_token_string_t cmd_set_link_up_set =
7300 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7301 cmdline_parse_token_string_t cmd_set_link_up_link_up =
7302 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7304 cmdline_parse_token_string_t cmd_set_link_up_port =
7305 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7306 cmdline_parse_token_num_t cmd_set_link_up_port_id =
7307 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16);
7309 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
7310 __attribute__((unused)) struct cmdline *cl,
7311 __attribute__((unused)) void *data)
7313 struct cmd_set_link_up_result *res = parsed_result;
7314 dev_set_link_up(res->port_id);
7317 cmdline_parse_inst_t cmd_set_link_up = {
7318 .f = cmd_set_link_up_parsed,
7320 .help_str = "set link-up port <port id>",
7322 (void *)&cmd_set_link_up_set,
7323 (void *)&cmd_set_link_up_link_up,
7324 (void *)&cmd_set_link_up_port,
7325 (void *)&cmd_set_link_up_port_id,
7330 /* *** SET LINK DOWN *** */
7331 struct cmd_set_link_down_result {
7332 cmdline_fixed_string_t set;
7333 cmdline_fixed_string_t link_down;
7334 cmdline_fixed_string_t port;
7338 cmdline_parse_token_string_t cmd_set_link_down_set =
7339 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
7340 cmdline_parse_token_string_t cmd_set_link_down_link_down =
7341 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
7343 cmdline_parse_token_string_t cmd_set_link_down_port =
7344 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
7345 cmdline_parse_token_num_t cmd_set_link_down_port_id =
7346 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16);
7348 static void cmd_set_link_down_parsed(
7349 __attribute__((unused)) void *parsed_result,
7350 __attribute__((unused)) struct cmdline *cl,
7351 __attribute__((unused)) void *data)
7353 struct cmd_set_link_down_result *res = parsed_result;
7354 dev_set_link_down(res->port_id);
7357 cmdline_parse_inst_t cmd_set_link_down = {
7358 .f = cmd_set_link_down_parsed,
7360 .help_str = "set link-down port <port id>",
7362 (void *)&cmd_set_link_down_set,
7363 (void *)&cmd_set_link_down_link_down,
7364 (void *)&cmd_set_link_down_port,
7365 (void *)&cmd_set_link_down_port_id,
7370 /* *** SHOW CFG *** */
7371 struct cmd_showcfg_result {
7372 cmdline_fixed_string_t show;
7373 cmdline_fixed_string_t cfg;
7374 cmdline_fixed_string_t what;
7377 static void cmd_showcfg_parsed(void *parsed_result,
7378 __attribute__((unused)) struct cmdline *cl,
7379 __attribute__((unused)) void *data)
7381 struct cmd_showcfg_result *res = parsed_result;
7382 if (!strcmp(res->what, "rxtx"))
7383 rxtx_config_display();
7384 else if (!strcmp(res->what, "cores"))
7385 fwd_lcores_config_display();
7386 else if (!strcmp(res->what, "fwd"))
7387 pkt_fwd_config_display(&cur_fwd_config);
7388 else if (!strcmp(res->what, "txpkts"))
7389 show_tx_pkt_segments();
7392 cmdline_parse_token_string_t cmd_showcfg_show =
7393 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7394 cmdline_parse_token_string_t cmd_showcfg_port =
7395 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7396 cmdline_parse_token_string_t cmd_showcfg_what =
7397 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7398 "rxtx#cores#fwd#txpkts");
7400 cmdline_parse_inst_t cmd_showcfg = {
7401 .f = cmd_showcfg_parsed,
7403 .help_str = "show config rxtx|cores|fwd|txpkts",
7405 (void *)&cmd_showcfg_show,
7406 (void *)&cmd_showcfg_port,
7407 (void *)&cmd_showcfg_what,
7412 /* *** SHOW ALL PORT INFO *** */
7413 struct cmd_showportall_result {
7414 cmdline_fixed_string_t show;
7415 cmdline_fixed_string_t port;
7416 cmdline_fixed_string_t what;
7417 cmdline_fixed_string_t all;
7420 static void cmd_showportall_parsed(void *parsed_result,
7421 __attribute__((unused)) struct cmdline *cl,
7422 __attribute__((unused)) void *data)
7426 struct cmd_showportall_result *res = parsed_result;
7427 if (!strcmp(res->show, "clear")) {
7428 if (!strcmp(res->what, "stats"))
7429 RTE_ETH_FOREACH_DEV(i)
7431 else if (!strcmp(res->what, "xstats"))
7432 RTE_ETH_FOREACH_DEV(i)
7433 nic_xstats_clear(i);
7434 } else if (!strcmp(res->what, "info"))
7435 RTE_ETH_FOREACH_DEV(i)
7436 port_infos_display(i);
7437 else if (!strcmp(res->what, "summary")) {
7438 port_summary_header_display();
7439 RTE_ETH_FOREACH_DEV(i)
7440 port_summary_display(i);
7442 else if (!strcmp(res->what, "stats"))
7443 RTE_ETH_FOREACH_DEV(i)
7444 nic_stats_display(i);
7445 else if (!strcmp(res->what, "xstats"))
7446 RTE_ETH_FOREACH_DEV(i)
7447 nic_xstats_display(i);
7448 else if (!strcmp(res->what, "fdir"))
7449 RTE_ETH_FOREACH_DEV(i)
7451 else if (!strcmp(res->what, "stat_qmap"))
7452 RTE_ETH_FOREACH_DEV(i)
7453 nic_stats_mapping_display(i);
7454 else if (!strcmp(res->what, "dcb_tc"))
7455 RTE_ETH_FOREACH_DEV(i)
7456 port_dcb_info_display(i);
7457 else if (!strcmp(res->what, "cap"))
7458 RTE_ETH_FOREACH_DEV(i)
7459 port_offload_cap_display(i);
7462 cmdline_parse_token_string_t cmd_showportall_show =
7463 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7465 cmdline_parse_token_string_t cmd_showportall_port =
7466 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7467 cmdline_parse_token_string_t cmd_showportall_what =
7468 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7469 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7470 cmdline_parse_token_string_t cmd_showportall_all =
7471 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7472 cmdline_parse_inst_t cmd_showportall = {
7473 .f = cmd_showportall_parsed,
7475 .help_str = "show|clear port "
7476 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
7478 (void *)&cmd_showportall_show,
7479 (void *)&cmd_showportall_port,
7480 (void *)&cmd_showportall_what,
7481 (void *)&cmd_showportall_all,
7486 /* *** SHOW PORT INFO *** */
7487 struct cmd_showport_result {
7488 cmdline_fixed_string_t show;
7489 cmdline_fixed_string_t port;
7490 cmdline_fixed_string_t what;
7494 static void cmd_showport_parsed(void *parsed_result,
7495 __attribute__((unused)) struct cmdline *cl,
7496 __attribute__((unused)) void *data)
7498 struct cmd_showport_result *res = parsed_result;
7499 if (!strcmp(res->show, "clear")) {
7500 if (!strcmp(res->what, "stats"))
7501 nic_stats_clear(res->portnum);
7502 else if (!strcmp(res->what, "xstats"))
7503 nic_xstats_clear(res->portnum);
7504 } else if (!strcmp(res->what, "info"))
7505 port_infos_display(res->portnum);
7506 else if (!strcmp(res->what, "summary")) {
7507 port_summary_header_display();
7508 port_summary_display(res->portnum);
7510 else if (!strcmp(res->what, "stats"))
7511 nic_stats_display(res->portnum);
7512 else if (!strcmp(res->what, "xstats"))
7513 nic_xstats_display(res->portnum);
7514 else if (!strcmp(res->what, "fdir"))
7515 fdir_get_infos(res->portnum);
7516 else if (!strcmp(res->what, "stat_qmap"))
7517 nic_stats_mapping_display(res->portnum);
7518 else if (!strcmp(res->what, "dcb_tc"))
7519 port_dcb_info_display(res->portnum);
7520 else if (!strcmp(res->what, "cap"))
7521 port_offload_cap_display(res->portnum);
7524 cmdline_parse_token_string_t cmd_showport_show =
7525 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7527 cmdline_parse_token_string_t cmd_showport_port =
7528 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7529 cmdline_parse_token_string_t cmd_showport_what =
7530 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7531 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7532 cmdline_parse_token_num_t cmd_showport_portnum =
7533 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
7535 cmdline_parse_inst_t cmd_showport = {
7536 .f = cmd_showport_parsed,
7538 .help_str = "show|clear port "
7539 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
7542 (void *)&cmd_showport_show,
7543 (void *)&cmd_showport_port,
7544 (void *)&cmd_showport_what,
7545 (void *)&cmd_showport_portnum,
7550 /* *** SHOW DEVICE INFO *** */
7551 struct cmd_showdevice_result {
7552 cmdline_fixed_string_t show;
7553 cmdline_fixed_string_t device;
7554 cmdline_fixed_string_t what;
7555 cmdline_fixed_string_t identifier;
7558 static void cmd_showdevice_parsed(void *parsed_result,
7559 __attribute__((unused)) struct cmdline *cl,
7560 __attribute__((unused)) void *data)
7562 struct cmd_showdevice_result *res = parsed_result;
7563 if (!strcmp(res->what, "info")) {
7564 if (!strcmp(res->identifier, "all"))
7565 device_infos_display(NULL);
7567 device_infos_display(res->identifier);
7571 cmdline_parse_token_string_t cmd_showdevice_show =
7572 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show,
7574 cmdline_parse_token_string_t cmd_showdevice_device =
7575 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device");
7576 cmdline_parse_token_string_t cmd_showdevice_what =
7577 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what,
7579 cmdline_parse_token_string_t cmd_showdevice_identifier =
7580 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result,
7583 cmdline_parse_inst_t cmd_showdevice = {
7584 .f = cmd_showdevice_parsed,
7586 .help_str = "show device info <identifier>|all",
7588 (void *)&cmd_showdevice_show,
7589 (void *)&cmd_showdevice_device,
7590 (void *)&cmd_showdevice_what,
7591 (void *)&cmd_showdevice_identifier,
7595 /* *** SHOW QUEUE INFO *** */
7596 struct cmd_showqueue_result {
7597 cmdline_fixed_string_t show;
7598 cmdline_fixed_string_t type;
7599 cmdline_fixed_string_t what;
7605 cmd_showqueue_parsed(void *parsed_result,
7606 __attribute__((unused)) struct cmdline *cl,
7607 __attribute__((unused)) void *data)
7609 struct cmd_showqueue_result *res = parsed_result;
7611 if (!strcmp(res->type, "rxq"))
7612 rx_queue_infos_display(res->portnum, res->queuenum);
7613 else if (!strcmp(res->type, "txq"))
7614 tx_queue_infos_display(res->portnum, res->queuenum);
7617 cmdline_parse_token_string_t cmd_showqueue_show =
7618 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
7619 cmdline_parse_token_string_t cmd_showqueue_type =
7620 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
7621 cmdline_parse_token_string_t cmd_showqueue_what =
7622 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
7623 cmdline_parse_token_num_t cmd_showqueue_portnum =
7624 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16);
7625 cmdline_parse_token_num_t cmd_showqueue_queuenum =
7626 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
7628 cmdline_parse_inst_t cmd_showqueue = {
7629 .f = cmd_showqueue_parsed,
7631 .help_str = "show rxq|txq info <port_id> <queue_id>",
7633 (void *)&cmd_showqueue_show,
7634 (void *)&cmd_showqueue_type,
7635 (void *)&cmd_showqueue_what,
7636 (void *)&cmd_showqueue_portnum,
7637 (void *)&cmd_showqueue_queuenum,
7642 /* show/clear fwd engine statistics */
7644 cmdline_fixed_string_t action;
7645 cmdline_fixed_string_t fwd;
7646 cmdline_fixed_string_t stats;
7647 cmdline_fixed_string_t all;
7650 cmdline_parse_token_string_t cmd_fwd_action =
7651 TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
7652 cmdline_parse_token_string_t cmd_fwd_fwd =
7653 TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
7654 cmdline_parse_token_string_t cmd_fwd_stats =
7655 TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
7656 cmdline_parse_token_string_t cmd_fwd_all =
7657 TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
7660 cmd_showfwdall_parsed(void *parsed_result,
7661 __rte_unused struct cmdline *cl,
7662 __rte_unused void *data)
7664 struct fwd_result *res = parsed_result;
7666 if (!strcmp(res->action, "show"))
7667 fwd_stats_display();
7672 static cmdline_parse_inst_t cmd_showfwdall = {
7673 .f = cmd_showfwdall_parsed,
7675 .help_str = "show|clear fwd stats all",
7677 (void *)&cmd_fwd_action,
7678 (void *)&cmd_fwd_fwd,
7679 (void *)&cmd_fwd_stats,
7680 (void *)&cmd_fwd_all,
7685 /* *** READ PORT REGISTER *** */
7686 struct cmd_read_reg_result {
7687 cmdline_fixed_string_t read;
7688 cmdline_fixed_string_t reg;
7694 cmd_read_reg_parsed(void *parsed_result,
7695 __attribute__((unused)) struct cmdline *cl,
7696 __attribute__((unused)) void *data)
7698 struct cmd_read_reg_result *res = parsed_result;
7699 port_reg_display(res->port_id, res->reg_off);
7702 cmdline_parse_token_string_t cmd_read_reg_read =
7703 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
7704 cmdline_parse_token_string_t cmd_read_reg_reg =
7705 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
7706 cmdline_parse_token_num_t cmd_read_reg_port_id =
7707 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16);
7708 cmdline_parse_token_num_t cmd_read_reg_reg_off =
7709 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
7711 cmdline_parse_inst_t cmd_read_reg = {
7712 .f = cmd_read_reg_parsed,
7714 .help_str = "read reg <port_id> <reg_off>",
7716 (void *)&cmd_read_reg_read,
7717 (void *)&cmd_read_reg_reg,
7718 (void *)&cmd_read_reg_port_id,
7719 (void *)&cmd_read_reg_reg_off,
7724 /* *** READ PORT REGISTER BIT FIELD *** */
7725 struct cmd_read_reg_bit_field_result {
7726 cmdline_fixed_string_t read;
7727 cmdline_fixed_string_t regfield;
7735 cmd_read_reg_bit_field_parsed(void *parsed_result,
7736 __attribute__((unused)) struct cmdline *cl,
7737 __attribute__((unused)) void *data)
7739 struct cmd_read_reg_bit_field_result *res = parsed_result;
7740 port_reg_bit_field_display(res->port_id, res->reg_off,
7741 res->bit1_pos, res->bit2_pos);
7744 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
7745 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
7747 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
7748 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
7749 regfield, "regfield");
7750 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
7751 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
7753 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
7754 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
7756 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
7757 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
7759 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
7760 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
7763 cmdline_parse_inst_t cmd_read_reg_bit_field = {
7764 .f = cmd_read_reg_bit_field_parsed,
7766 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
7767 "Read register bit field between bit_x and bit_y included",
7769 (void *)&cmd_read_reg_bit_field_read,
7770 (void *)&cmd_read_reg_bit_field_regfield,
7771 (void *)&cmd_read_reg_bit_field_port_id,
7772 (void *)&cmd_read_reg_bit_field_reg_off,
7773 (void *)&cmd_read_reg_bit_field_bit1_pos,
7774 (void *)&cmd_read_reg_bit_field_bit2_pos,
7779 /* *** READ PORT REGISTER BIT *** */
7780 struct cmd_read_reg_bit_result {
7781 cmdline_fixed_string_t read;
7782 cmdline_fixed_string_t regbit;
7789 cmd_read_reg_bit_parsed(void *parsed_result,
7790 __attribute__((unused)) struct cmdline *cl,
7791 __attribute__((unused)) void *data)
7793 struct cmd_read_reg_bit_result *res = parsed_result;
7794 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
7797 cmdline_parse_token_string_t cmd_read_reg_bit_read =
7798 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
7799 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
7800 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
7802 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
7803 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16);
7804 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
7805 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
7806 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
7807 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
7809 cmdline_parse_inst_t cmd_read_reg_bit = {
7810 .f = cmd_read_reg_bit_parsed,
7812 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
7814 (void *)&cmd_read_reg_bit_read,
7815 (void *)&cmd_read_reg_bit_regbit,
7816 (void *)&cmd_read_reg_bit_port_id,
7817 (void *)&cmd_read_reg_bit_reg_off,
7818 (void *)&cmd_read_reg_bit_bit_pos,
7823 /* *** WRITE PORT REGISTER *** */
7824 struct cmd_write_reg_result {
7825 cmdline_fixed_string_t write;
7826 cmdline_fixed_string_t reg;
7833 cmd_write_reg_parsed(void *parsed_result,
7834 __attribute__((unused)) struct cmdline *cl,
7835 __attribute__((unused)) void *data)
7837 struct cmd_write_reg_result *res = parsed_result;
7838 port_reg_set(res->port_id, res->reg_off, res->value);
7841 cmdline_parse_token_string_t cmd_write_reg_write =
7842 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
7843 cmdline_parse_token_string_t cmd_write_reg_reg =
7844 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
7845 cmdline_parse_token_num_t cmd_write_reg_port_id =
7846 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16);
7847 cmdline_parse_token_num_t cmd_write_reg_reg_off =
7848 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
7849 cmdline_parse_token_num_t cmd_write_reg_value =
7850 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
7852 cmdline_parse_inst_t cmd_write_reg = {
7853 .f = cmd_write_reg_parsed,
7855 .help_str = "write reg <port_id> <reg_off> <reg_value>",
7857 (void *)&cmd_write_reg_write,
7858 (void *)&cmd_write_reg_reg,
7859 (void *)&cmd_write_reg_port_id,
7860 (void *)&cmd_write_reg_reg_off,
7861 (void *)&cmd_write_reg_value,
7866 /* *** WRITE PORT REGISTER BIT FIELD *** */
7867 struct cmd_write_reg_bit_field_result {
7868 cmdline_fixed_string_t write;
7869 cmdline_fixed_string_t regfield;
7878 cmd_write_reg_bit_field_parsed(void *parsed_result,
7879 __attribute__((unused)) struct cmdline *cl,
7880 __attribute__((unused)) void *data)
7882 struct cmd_write_reg_bit_field_result *res = parsed_result;
7883 port_reg_bit_field_set(res->port_id, res->reg_off,
7884 res->bit1_pos, res->bit2_pos, res->value);
7887 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
7888 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
7890 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
7891 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
7892 regfield, "regfield");
7893 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
7894 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
7896 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
7897 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
7899 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
7900 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
7902 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
7903 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
7905 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
7906 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
7909 cmdline_parse_inst_t cmd_write_reg_bit_field = {
7910 .f = cmd_write_reg_bit_field_parsed,
7912 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
7914 "Set register bit field between bit_x and bit_y included",
7916 (void *)&cmd_write_reg_bit_field_write,
7917 (void *)&cmd_write_reg_bit_field_regfield,
7918 (void *)&cmd_write_reg_bit_field_port_id,
7919 (void *)&cmd_write_reg_bit_field_reg_off,
7920 (void *)&cmd_write_reg_bit_field_bit1_pos,
7921 (void *)&cmd_write_reg_bit_field_bit2_pos,
7922 (void *)&cmd_write_reg_bit_field_value,
7927 /* *** WRITE PORT REGISTER BIT *** */
7928 struct cmd_write_reg_bit_result {
7929 cmdline_fixed_string_t write;
7930 cmdline_fixed_string_t regbit;
7938 cmd_write_reg_bit_parsed(void *parsed_result,
7939 __attribute__((unused)) struct cmdline *cl,
7940 __attribute__((unused)) void *data)
7942 struct cmd_write_reg_bit_result *res = parsed_result;
7943 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
7946 cmdline_parse_token_string_t cmd_write_reg_bit_write =
7947 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
7949 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
7950 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
7952 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
7953 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16);
7954 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
7955 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
7956 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
7957 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
7958 cmdline_parse_token_num_t cmd_write_reg_bit_value =
7959 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
7961 cmdline_parse_inst_t cmd_write_reg_bit = {
7962 .f = cmd_write_reg_bit_parsed,
7964 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
7967 (void *)&cmd_write_reg_bit_write,
7968 (void *)&cmd_write_reg_bit_regbit,
7969 (void *)&cmd_write_reg_bit_port_id,
7970 (void *)&cmd_write_reg_bit_reg_off,
7971 (void *)&cmd_write_reg_bit_bit_pos,
7972 (void *)&cmd_write_reg_bit_value,
7977 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
7978 struct cmd_read_rxd_txd_result {
7979 cmdline_fixed_string_t read;
7980 cmdline_fixed_string_t rxd_txd;
7987 cmd_read_rxd_txd_parsed(void *parsed_result,
7988 __attribute__((unused)) struct cmdline *cl,
7989 __attribute__((unused)) void *data)
7991 struct cmd_read_rxd_txd_result *res = parsed_result;
7993 if (!strcmp(res->rxd_txd, "rxd"))
7994 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7995 else if (!strcmp(res->rxd_txd, "txd"))
7996 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7999 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
8000 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
8001 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
8002 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
8004 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
8005 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16);
8006 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
8007 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
8008 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
8009 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
8011 cmdline_parse_inst_t cmd_read_rxd_txd = {
8012 .f = cmd_read_rxd_txd_parsed,
8014 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
8016 (void *)&cmd_read_rxd_txd_read,
8017 (void *)&cmd_read_rxd_txd_rxd_txd,
8018 (void *)&cmd_read_rxd_txd_port_id,
8019 (void *)&cmd_read_rxd_txd_queue_id,
8020 (void *)&cmd_read_rxd_txd_desc_id,
8026 struct cmd_quit_result {
8027 cmdline_fixed_string_t quit;
8030 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
8032 __attribute__((unused)) void *data)
8037 cmdline_parse_token_string_t cmd_quit_quit =
8038 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
8040 cmdline_parse_inst_t cmd_quit = {
8041 .f = cmd_quit_parsed,
8043 .help_str = "quit: Exit application",
8045 (void *)&cmd_quit_quit,
8050 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
8051 struct cmd_mac_addr_result {
8052 cmdline_fixed_string_t mac_addr_cmd;
8053 cmdline_fixed_string_t what;
8055 struct rte_ether_addr address;
8058 static void cmd_mac_addr_parsed(void *parsed_result,
8059 __attribute__((unused)) struct cmdline *cl,
8060 __attribute__((unused)) void *data)
8062 struct cmd_mac_addr_result *res = parsed_result;
8065 if (strcmp(res->what, "add") == 0)
8066 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
8067 else if (strcmp(res->what, "set") == 0)
8068 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
8071 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
8073 /* check the return value and print it if is < 0 */
8075 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
8079 cmdline_parse_token_string_t cmd_mac_addr_cmd =
8080 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
8082 cmdline_parse_token_string_t cmd_mac_addr_what =
8083 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
8085 cmdline_parse_token_num_t cmd_mac_addr_portnum =
8086 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
8088 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
8089 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
8091 cmdline_parse_inst_t cmd_mac_addr = {
8092 .f = cmd_mac_addr_parsed,
8094 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
8095 "Add/Remove/Set MAC address on port_id",
8097 (void *)&cmd_mac_addr_cmd,
8098 (void *)&cmd_mac_addr_what,
8099 (void *)&cmd_mac_addr_portnum,
8100 (void *)&cmd_mac_addr_addr,
8105 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
8106 struct cmd_eth_peer_result {
8107 cmdline_fixed_string_t set;
8108 cmdline_fixed_string_t eth_peer;
8110 cmdline_fixed_string_t peer_addr;
8113 static void cmd_set_eth_peer_parsed(void *parsed_result,
8114 __attribute__((unused)) struct cmdline *cl,
8115 __attribute__((unused)) void *data)
8117 struct cmd_eth_peer_result *res = parsed_result;
8119 if (test_done == 0) {
8120 printf("Please stop forwarding first\n");
8123 if (!strcmp(res->eth_peer, "eth-peer")) {
8124 set_fwd_eth_peer(res->port_id, res->peer_addr);
8128 cmdline_parse_token_string_t cmd_eth_peer_set =
8129 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
8130 cmdline_parse_token_string_t cmd_eth_peer =
8131 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
8132 cmdline_parse_token_num_t cmd_eth_peer_port_id =
8133 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, UINT16);
8134 cmdline_parse_token_string_t cmd_eth_peer_addr =
8135 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
8137 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
8138 .f = cmd_set_eth_peer_parsed,
8140 .help_str = "set eth-peer <port_id> <peer_mac>",
8142 (void *)&cmd_eth_peer_set,
8143 (void *)&cmd_eth_peer,
8144 (void *)&cmd_eth_peer_port_id,
8145 (void *)&cmd_eth_peer_addr,
8150 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
8151 struct cmd_set_qmap_result {
8152 cmdline_fixed_string_t set;
8153 cmdline_fixed_string_t qmap;
8154 cmdline_fixed_string_t what;
8161 cmd_set_qmap_parsed(void *parsed_result,
8162 __attribute__((unused)) struct cmdline *cl,
8163 __attribute__((unused)) void *data)
8165 struct cmd_set_qmap_result *res = parsed_result;
8166 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
8168 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
8171 cmdline_parse_token_string_t cmd_setqmap_set =
8172 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8174 cmdline_parse_token_string_t cmd_setqmap_qmap =
8175 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8177 cmdline_parse_token_string_t cmd_setqmap_what =
8178 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8180 cmdline_parse_token_num_t cmd_setqmap_portid =
8181 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8183 cmdline_parse_token_num_t cmd_setqmap_queueid =
8184 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8186 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
8187 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8190 cmdline_parse_inst_t cmd_set_qmap = {
8191 .f = cmd_set_qmap_parsed,
8193 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
8194 "Set statistics mapping value on tx|rx queue_id of port_id",
8196 (void *)&cmd_setqmap_set,
8197 (void *)&cmd_setqmap_qmap,
8198 (void *)&cmd_setqmap_what,
8199 (void *)&cmd_setqmap_portid,
8200 (void *)&cmd_setqmap_queueid,
8201 (void *)&cmd_setqmap_mapvalue,
8206 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
8207 struct cmd_set_xstats_hide_zero_result {
8208 cmdline_fixed_string_t keyword;
8209 cmdline_fixed_string_t name;
8210 cmdline_fixed_string_t on_off;
8214 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
8215 __attribute__((unused)) struct cmdline *cl,
8216 __attribute__((unused)) void *data)
8218 struct cmd_set_xstats_hide_zero_result *res;
8219 uint16_t on_off = 0;
8221 res = parsed_result;
8222 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8223 set_xstats_hide_zero(on_off);
8226 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
8227 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8229 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
8230 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8231 name, "xstats-hide-zero");
8232 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
8233 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8236 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
8237 .f = cmd_set_xstats_hide_zero_parsed,
8239 .help_str = "set xstats-hide-zero on|off",
8241 (void *)&cmd_set_xstats_hide_zero_keyword,
8242 (void *)&cmd_set_xstats_hide_zero_name,
8243 (void *)&cmd_set_xstats_hide_zero_on_off,
8248 /* *** CONFIGURE UNICAST HASH TABLE *** */
8249 struct cmd_set_uc_hash_table {
8250 cmdline_fixed_string_t set;
8251 cmdline_fixed_string_t port;
8253 cmdline_fixed_string_t what;
8254 struct rte_ether_addr address;
8255 cmdline_fixed_string_t mode;
8259 cmd_set_uc_hash_parsed(void *parsed_result,
8260 __attribute__((unused)) struct cmdline *cl,
8261 __attribute__((unused)) void *data)
8264 struct cmd_set_uc_hash_table *res = parsed_result;
8266 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8268 if (strcmp(res->what, "uta") == 0)
8269 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
8270 &res->address,(uint8_t)is_on);
8272 printf("bad unicast hash table parameter, return code = %d \n", ret);
8276 cmdline_parse_token_string_t cmd_set_uc_hash_set =
8277 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8279 cmdline_parse_token_string_t cmd_set_uc_hash_port =
8280 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8282 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
8283 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
8285 cmdline_parse_token_string_t cmd_set_uc_hash_what =
8286 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8288 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
8289 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
8291 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
8292 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8295 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
8296 .f = cmd_set_uc_hash_parsed,
8298 .help_str = "set port <port_id> uta <mac_addr> on|off)",
8300 (void *)&cmd_set_uc_hash_set,
8301 (void *)&cmd_set_uc_hash_port,
8302 (void *)&cmd_set_uc_hash_portid,
8303 (void *)&cmd_set_uc_hash_what,
8304 (void *)&cmd_set_uc_hash_mac,
8305 (void *)&cmd_set_uc_hash_mode,
8310 struct cmd_set_uc_all_hash_table {
8311 cmdline_fixed_string_t set;
8312 cmdline_fixed_string_t port;
8314 cmdline_fixed_string_t what;
8315 cmdline_fixed_string_t value;
8316 cmdline_fixed_string_t mode;
8320 cmd_set_uc_all_hash_parsed(void *parsed_result,
8321 __attribute__((unused)) struct cmdline *cl,
8322 __attribute__((unused)) void *data)
8325 struct cmd_set_uc_all_hash_table *res = parsed_result;
8327 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8329 if ((strcmp(res->what, "uta") == 0) &&
8330 (strcmp(res->value, "all") == 0))
8331 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
8333 printf("bad unicast hash table parameter,"
8334 "return code = %d \n", ret);
8337 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
8338 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8340 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
8341 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8343 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
8344 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
8346 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
8347 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8349 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
8350 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8352 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
8353 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8356 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
8357 .f = cmd_set_uc_all_hash_parsed,
8359 .help_str = "set port <port_id> uta all on|off",
8361 (void *)&cmd_set_uc_all_hash_set,
8362 (void *)&cmd_set_uc_all_hash_port,
8363 (void *)&cmd_set_uc_all_hash_portid,
8364 (void *)&cmd_set_uc_all_hash_what,
8365 (void *)&cmd_set_uc_all_hash_value,
8366 (void *)&cmd_set_uc_all_hash_mode,
8371 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
8372 struct cmd_set_vf_macvlan_filter {
8373 cmdline_fixed_string_t set;
8374 cmdline_fixed_string_t port;
8376 cmdline_fixed_string_t vf;
8378 struct rte_ether_addr address;
8379 cmdline_fixed_string_t filter_type;
8380 cmdline_fixed_string_t mode;
8384 cmd_set_vf_macvlan_parsed(void *parsed_result,
8385 __attribute__((unused)) struct cmdline *cl,
8386 __attribute__((unused)) void *data)
8389 struct cmd_set_vf_macvlan_filter *res = parsed_result;
8390 struct rte_eth_mac_filter filter;
8392 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
8394 rte_memcpy(&filter.mac_addr, &res->address, RTE_ETHER_ADDR_LEN);
8396 /* set VF MAC filter */
8400 filter.dst_id = res->vf_id;
8402 if (!strcmp(res->filter_type, "exact-mac"))
8403 filter.filter_type = RTE_MAC_PERFECT_MATCH;
8404 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
8405 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
8406 else if (!strcmp(res->filter_type, "hashmac"))
8407 filter.filter_type = RTE_MAC_HASH_MATCH;
8408 else if (!strcmp(res->filter_type, "hashmac-vlan"))
8409 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
8411 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8414 ret = rte_eth_dev_filter_ctrl(res->port_id,
8415 RTE_ETH_FILTER_MACVLAN,
8419 ret = rte_eth_dev_filter_ctrl(res->port_id,
8420 RTE_ETH_FILTER_MACVLAN,
8421 RTE_ETH_FILTER_DELETE,
8425 printf("bad set MAC hash parameter, return code = %d\n", ret);
8429 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
8430 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8432 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
8433 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8435 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
8436 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8438 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
8439 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8441 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
8442 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8444 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
8445 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8447 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
8448 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8449 filter_type, "exact-mac#exact-mac-vlan"
8450 "#hashmac#hashmac-vlan");
8451 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
8452 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8455 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
8456 .f = cmd_set_vf_macvlan_parsed,
8458 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
8459 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
8460 "Exact match rule: exact match of MAC or MAC and VLAN; "
8461 "hash match rule: hash match of MAC and exact match of VLAN",
8463 (void *)&cmd_set_vf_macvlan_set,
8464 (void *)&cmd_set_vf_macvlan_port,
8465 (void *)&cmd_set_vf_macvlan_portid,
8466 (void *)&cmd_set_vf_macvlan_vf,
8467 (void *)&cmd_set_vf_macvlan_vf_id,
8468 (void *)&cmd_set_vf_macvlan_mac,
8469 (void *)&cmd_set_vf_macvlan_filter_type,
8470 (void *)&cmd_set_vf_macvlan_mode,
8475 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
8476 struct cmd_set_vf_traffic {
8477 cmdline_fixed_string_t set;
8478 cmdline_fixed_string_t port;
8480 cmdline_fixed_string_t vf;
8482 cmdline_fixed_string_t what;
8483 cmdline_fixed_string_t mode;
8487 cmd_set_vf_traffic_parsed(void *parsed_result,
8488 __attribute__((unused)) struct cmdline *cl,
8489 __attribute__((unused)) void *data)
8491 struct cmd_set_vf_traffic *res = parsed_result;
8492 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
8493 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8495 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
8498 cmdline_parse_token_string_t cmd_setvf_traffic_set =
8499 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8501 cmdline_parse_token_string_t cmd_setvf_traffic_port =
8502 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8504 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8505 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8507 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8508 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8510 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8511 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8513 cmdline_parse_token_string_t cmd_setvf_traffic_what =
8514 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8516 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8517 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8520 cmdline_parse_inst_t cmd_set_vf_traffic = {
8521 .f = cmd_set_vf_traffic_parsed,
8523 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8525 (void *)&cmd_setvf_traffic_set,
8526 (void *)&cmd_setvf_traffic_port,
8527 (void *)&cmd_setvf_traffic_portid,
8528 (void *)&cmd_setvf_traffic_vf,
8529 (void *)&cmd_setvf_traffic_vfid,
8530 (void *)&cmd_setvf_traffic_what,
8531 (void *)&cmd_setvf_traffic_mode,
8536 /* *** CONFIGURE VF RECEIVE MODE *** */
8537 struct cmd_set_vf_rxmode {
8538 cmdline_fixed_string_t set;
8539 cmdline_fixed_string_t port;
8541 cmdline_fixed_string_t vf;
8543 cmdline_fixed_string_t what;
8544 cmdline_fixed_string_t mode;
8545 cmdline_fixed_string_t on;
8549 cmd_set_vf_rxmode_parsed(void *parsed_result,
8550 __attribute__((unused)) struct cmdline *cl,
8551 __attribute__((unused)) void *data)
8554 uint16_t vf_rxmode = 0;
8555 struct cmd_set_vf_rxmode *res = parsed_result;
8557 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8558 if (!strcmp(res->what,"rxmode")) {
8559 if (!strcmp(res->mode, "AUPE"))
8560 vf_rxmode |= ETH_VMDQ_ACCEPT_UNTAG;
8561 else if (!strcmp(res->mode, "ROPE"))
8562 vf_rxmode |= ETH_VMDQ_ACCEPT_HASH_UC;
8563 else if (!strcmp(res->mode, "BAM"))
8564 vf_rxmode |= ETH_VMDQ_ACCEPT_BROADCAST;
8565 else if (!strncmp(res->mode, "MPE",3))
8566 vf_rxmode |= ETH_VMDQ_ACCEPT_MULTICAST;
8569 RTE_SET_USED(is_on);
8571 #ifdef RTE_LIBRTE_IXGBE_PMD
8572 if (ret == -ENOTSUP)
8573 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8574 vf_rxmode, (uint8_t)is_on);
8576 #ifdef RTE_LIBRTE_BNXT_PMD
8577 if (ret == -ENOTSUP)
8578 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8579 vf_rxmode, (uint8_t)is_on);
8582 printf("bad VF receive mode parameter, return code = %d \n",
8586 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8587 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8589 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8590 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8592 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8593 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8595 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8596 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8598 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8599 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8601 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
8602 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8604 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
8605 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8606 mode, "AUPE#ROPE#BAM#MPE");
8607 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
8608 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8611 cmdline_parse_inst_t cmd_set_vf_rxmode = {
8612 .f = cmd_set_vf_rxmode_parsed,
8614 .help_str = "set port <port_id> vf <vf_id> rxmode "
8615 "AUPE|ROPE|BAM|MPE on|off",
8617 (void *)&cmd_set_vf_rxmode_set,
8618 (void *)&cmd_set_vf_rxmode_port,
8619 (void *)&cmd_set_vf_rxmode_portid,
8620 (void *)&cmd_set_vf_rxmode_vf,
8621 (void *)&cmd_set_vf_rxmode_vfid,
8622 (void *)&cmd_set_vf_rxmode_what,
8623 (void *)&cmd_set_vf_rxmode_mode,
8624 (void *)&cmd_set_vf_rxmode_on,
8629 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
8630 struct cmd_vf_mac_addr_result {
8631 cmdline_fixed_string_t mac_addr_cmd;
8632 cmdline_fixed_string_t what;
8633 cmdline_fixed_string_t port;
8635 cmdline_fixed_string_t vf;
8637 struct rte_ether_addr address;
8640 static void cmd_vf_mac_addr_parsed(void *parsed_result,
8641 __attribute__((unused)) struct cmdline *cl,
8642 __attribute__((unused)) void *data)
8644 struct cmd_vf_mac_addr_result *res = parsed_result;
8647 if (strcmp(res->what, "add") != 0)
8650 #ifdef RTE_LIBRTE_I40E_PMD
8651 if (ret == -ENOTSUP)
8652 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
8655 #ifdef RTE_LIBRTE_BNXT_PMD
8656 if (ret == -ENOTSUP)
8657 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
8662 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
8666 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
8667 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8668 mac_addr_cmd,"mac_addr");
8669 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
8670 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8672 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
8673 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8675 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
8676 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8678 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
8679 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8681 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
8682 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8684 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
8685 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
8688 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
8689 .f = cmd_vf_mac_addr_parsed,
8691 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
8692 "Add MAC address filtering for a VF on port_id",
8694 (void *)&cmd_vf_mac_addr_cmd,
8695 (void *)&cmd_vf_mac_addr_what,
8696 (void *)&cmd_vf_mac_addr_port,
8697 (void *)&cmd_vf_mac_addr_portnum,
8698 (void *)&cmd_vf_mac_addr_vf,
8699 (void *)&cmd_vf_mac_addr_vfnum,
8700 (void *)&cmd_vf_mac_addr_addr,
8705 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
8706 struct cmd_vf_rx_vlan_filter {
8707 cmdline_fixed_string_t rx_vlan;
8708 cmdline_fixed_string_t what;
8710 cmdline_fixed_string_t port;
8712 cmdline_fixed_string_t vf;
8717 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
8718 __attribute__((unused)) struct cmdline *cl,
8719 __attribute__((unused)) void *data)
8721 struct cmd_vf_rx_vlan_filter *res = parsed_result;
8724 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
8726 #ifdef RTE_LIBRTE_IXGBE_PMD
8727 if (ret == -ENOTSUP)
8728 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
8729 res->vlan_id, res->vf_mask, is_add);
8731 #ifdef RTE_LIBRTE_I40E_PMD
8732 if (ret == -ENOTSUP)
8733 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
8734 res->vlan_id, res->vf_mask, is_add);
8736 #ifdef RTE_LIBRTE_BNXT_PMD
8737 if (ret == -ENOTSUP)
8738 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
8739 res->vlan_id, res->vf_mask, is_add);
8746 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
8747 res->vlan_id, res->vf_mask);
8750 printf("invalid port_id %d\n", res->port_id);
8753 printf("function not implemented or supported\n");
8756 printf("programming error: (%s)\n", strerror(-ret));
8760 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
8761 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8762 rx_vlan, "rx_vlan");
8763 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
8764 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8766 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
8767 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8769 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
8770 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8772 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
8773 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8775 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
8776 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8778 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
8779 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8782 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
8783 .f = cmd_vf_rx_vlan_filter_parsed,
8785 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
8786 "(vf_mask = hexadecimal VF mask)",
8788 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
8789 (void *)&cmd_vf_rx_vlan_filter_what,
8790 (void *)&cmd_vf_rx_vlan_filter_vlanid,
8791 (void *)&cmd_vf_rx_vlan_filter_port,
8792 (void *)&cmd_vf_rx_vlan_filter_portid,
8793 (void *)&cmd_vf_rx_vlan_filter_vf,
8794 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
8799 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
8800 struct cmd_queue_rate_limit_result {
8801 cmdline_fixed_string_t set;
8802 cmdline_fixed_string_t port;
8804 cmdline_fixed_string_t queue;
8806 cmdline_fixed_string_t rate;
8810 static void cmd_queue_rate_limit_parsed(void *parsed_result,
8811 __attribute__((unused)) struct cmdline *cl,
8812 __attribute__((unused)) void *data)
8814 struct cmd_queue_rate_limit_result *res = parsed_result;
8817 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8818 && (strcmp(res->queue, "queue") == 0)
8819 && (strcmp(res->rate, "rate") == 0))
8820 ret = set_queue_rate_limit(res->port_num, res->queue_num,
8823 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
8827 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
8828 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8830 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
8831 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8833 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
8834 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8836 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
8837 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8839 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
8840 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8842 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
8843 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8845 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
8846 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8849 cmdline_parse_inst_t cmd_queue_rate_limit = {
8850 .f = cmd_queue_rate_limit_parsed,
8852 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
8853 "Set rate limit for a queue on port_id",
8855 (void *)&cmd_queue_rate_limit_set,
8856 (void *)&cmd_queue_rate_limit_port,
8857 (void *)&cmd_queue_rate_limit_portnum,
8858 (void *)&cmd_queue_rate_limit_queue,
8859 (void *)&cmd_queue_rate_limit_queuenum,
8860 (void *)&cmd_queue_rate_limit_rate,
8861 (void *)&cmd_queue_rate_limit_ratenum,
8866 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
8867 struct cmd_vf_rate_limit_result {
8868 cmdline_fixed_string_t set;
8869 cmdline_fixed_string_t port;
8871 cmdline_fixed_string_t vf;
8873 cmdline_fixed_string_t rate;
8875 cmdline_fixed_string_t q_msk;
8879 static void cmd_vf_rate_limit_parsed(void *parsed_result,
8880 __attribute__((unused)) struct cmdline *cl,
8881 __attribute__((unused)) void *data)
8883 struct cmd_vf_rate_limit_result *res = parsed_result;
8886 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8887 && (strcmp(res->vf, "vf") == 0)
8888 && (strcmp(res->rate, "rate") == 0)
8889 && (strcmp(res->q_msk, "queue_mask") == 0))
8890 ret = set_vf_rate_limit(res->port_num, res->vf_num,
8891 res->rate_num, res->q_msk_val);
8893 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
8897 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
8898 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8900 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
8901 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8903 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
8904 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8906 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
8907 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8909 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
8910 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8912 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
8913 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8915 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
8916 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8918 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
8919 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8920 q_msk, "queue_mask");
8921 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
8922 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8925 cmdline_parse_inst_t cmd_vf_rate_limit = {
8926 .f = cmd_vf_rate_limit_parsed,
8928 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
8929 "queue_mask <queue_mask_value>: "
8930 "Set rate limit for queues of VF on port_id",
8932 (void *)&cmd_vf_rate_limit_set,
8933 (void *)&cmd_vf_rate_limit_port,
8934 (void *)&cmd_vf_rate_limit_portnum,
8935 (void *)&cmd_vf_rate_limit_vf,
8936 (void *)&cmd_vf_rate_limit_vfnum,
8937 (void *)&cmd_vf_rate_limit_rate,
8938 (void *)&cmd_vf_rate_limit_ratenum,
8939 (void *)&cmd_vf_rate_limit_q_msk,
8940 (void *)&cmd_vf_rate_limit_q_msk_val,
8945 /* *** ADD TUNNEL FILTER OF A PORT *** */
8946 struct cmd_tunnel_filter_result {
8947 cmdline_fixed_string_t cmd;
8948 cmdline_fixed_string_t what;
8950 struct rte_ether_addr outer_mac;
8951 struct rte_ether_addr inner_mac;
8952 cmdline_ipaddr_t ip_value;
8953 uint16_t inner_vlan;
8954 cmdline_fixed_string_t tunnel_type;
8955 cmdline_fixed_string_t filter_type;
8961 cmd_tunnel_filter_parsed(void *parsed_result,
8962 __attribute__((unused)) struct cmdline *cl,
8963 __attribute__((unused)) void *data)
8965 struct cmd_tunnel_filter_result *res = parsed_result;
8966 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
8969 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
8971 rte_ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
8972 rte_ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
8973 tunnel_filter_conf.inner_vlan = res->inner_vlan;
8975 if (res->ip_value.family == AF_INET) {
8976 tunnel_filter_conf.ip_addr.ipv4_addr =
8977 res->ip_value.addr.ipv4.s_addr;
8978 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
8980 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
8981 &(res->ip_value.addr.ipv6),
8982 sizeof(struct in6_addr));
8983 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
8986 if (!strcmp(res->filter_type, "imac-ivlan"))
8987 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
8988 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
8989 tunnel_filter_conf.filter_type =
8990 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
8991 else if (!strcmp(res->filter_type, "imac-tenid"))
8992 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
8993 else if (!strcmp(res->filter_type, "imac"))
8994 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
8995 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
8996 tunnel_filter_conf.filter_type =
8997 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
8998 else if (!strcmp(res->filter_type, "oip"))
8999 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
9000 else if (!strcmp(res->filter_type, "iip"))
9001 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
9003 printf("The filter type is not supported");
9007 if (!strcmp(res->tunnel_type, "vxlan"))
9008 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
9009 else if (!strcmp(res->tunnel_type, "vxlan-gpe"))
9010 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9011 else if (!strcmp(res->tunnel_type, "nvgre"))
9012 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
9013 else if (!strcmp(res->tunnel_type, "ipingre"))
9014 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
9016 printf("The tunnel type %s not supported.\n", res->tunnel_type);
9020 tunnel_filter_conf.tenant_id = res->tenant_id;
9021 tunnel_filter_conf.queue_id = res->queue_num;
9022 if (!strcmp(res->what, "add"))
9023 ret = rte_eth_dev_filter_ctrl(res->port_id,
9024 RTE_ETH_FILTER_TUNNEL,
9026 &tunnel_filter_conf);
9028 ret = rte_eth_dev_filter_ctrl(res->port_id,
9029 RTE_ETH_FILTER_TUNNEL,
9030 RTE_ETH_FILTER_DELETE,
9031 &tunnel_filter_conf);
9033 printf("cmd_tunnel_filter_parsed error: (%s)\n",
9037 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
9038 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9039 cmd, "tunnel_filter");
9040 cmdline_parse_token_string_t cmd_tunnel_filter_what =
9041 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9043 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
9044 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9046 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
9047 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
9049 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
9050 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
9052 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
9053 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9054 inner_vlan, UINT16);
9055 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
9056 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
9058 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
9059 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9060 tunnel_type, "vxlan#nvgre#ipingre#vxlan-gpe");
9062 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
9063 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9064 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
9065 "imac#omac-imac-tenid");
9066 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
9067 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9069 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
9070 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9073 cmdline_parse_inst_t cmd_tunnel_filter = {
9074 .f = cmd_tunnel_filter_parsed,
9076 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
9077 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
9078 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
9079 "<queue_id>: Add/Rm tunnel filter of a port",
9081 (void *)&cmd_tunnel_filter_cmd,
9082 (void *)&cmd_tunnel_filter_what,
9083 (void *)&cmd_tunnel_filter_port_id,
9084 (void *)&cmd_tunnel_filter_outer_mac,
9085 (void *)&cmd_tunnel_filter_inner_mac,
9086 (void *)&cmd_tunnel_filter_ip_value,
9087 (void *)&cmd_tunnel_filter_innner_vlan,
9088 (void *)&cmd_tunnel_filter_tunnel_type,
9089 (void *)&cmd_tunnel_filter_filter_type,
9090 (void *)&cmd_tunnel_filter_tenant_id,
9091 (void *)&cmd_tunnel_filter_queue_num,
9096 /* *** CONFIGURE TUNNEL UDP PORT *** */
9097 struct cmd_tunnel_udp_config {
9098 cmdline_fixed_string_t cmd;
9099 cmdline_fixed_string_t what;
9105 cmd_tunnel_udp_config_parsed(void *parsed_result,
9106 __attribute__((unused)) struct cmdline *cl,
9107 __attribute__((unused)) void *data)
9109 struct cmd_tunnel_udp_config *res = parsed_result;
9110 struct rte_eth_udp_tunnel tunnel_udp;
9113 tunnel_udp.udp_port = res->udp_port;
9115 if (!strcmp(res->cmd, "rx_vxlan_port"))
9116 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9118 if (!strcmp(res->what, "add"))
9119 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9122 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9126 printf("udp tunneling add error: (%s)\n", strerror(-ret));
9129 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
9130 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9131 cmd, "rx_vxlan_port");
9132 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
9133 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9135 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
9136 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9138 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
9139 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9142 cmdline_parse_inst_t cmd_tunnel_udp_config = {
9143 .f = cmd_tunnel_udp_config_parsed,
9145 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
9146 "Add/Remove a tunneling UDP port filter",
9148 (void *)&cmd_tunnel_udp_config_cmd,
9149 (void *)&cmd_tunnel_udp_config_what,
9150 (void *)&cmd_tunnel_udp_config_udp_port,
9151 (void *)&cmd_tunnel_udp_config_port_id,
9156 struct cmd_config_tunnel_udp_port {
9157 cmdline_fixed_string_t port;
9158 cmdline_fixed_string_t config;
9160 cmdline_fixed_string_t udp_tunnel_port;
9161 cmdline_fixed_string_t action;
9162 cmdline_fixed_string_t tunnel_type;
9167 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
9168 __attribute__((unused)) struct cmdline *cl,
9169 __attribute__((unused)) void *data)
9171 struct cmd_config_tunnel_udp_port *res = parsed_result;
9172 struct rte_eth_udp_tunnel tunnel_udp;
9175 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9178 tunnel_udp.udp_port = res->udp_port;
9180 if (!strcmp(res->tunnel_type, "vxlan")) {
9181 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9182 } else if (!strcmp(res->tunnel_type, "geneve")) {
9183 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE;
9184 } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
9185 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9187 printf("Invalid tunnel type\n");
9191 if (!strcmp(res->action, "add"))
9192 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9195 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9199 printf("udp tunneling port add error: (%s)\n", strerror(-ret));
9202 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
9203 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
9205 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
9206 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
9208 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
9209 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
9211 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
9212 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
9215 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
9216 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
9218 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
9219 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
9220 "vxlan#geneve#vxlan-gpe");
9221 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
9222 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
9225 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
9226 .f = cmd_cfg_tunnel_udp_port_parsed,
9228 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|geneve|vxlan-gpe <udp_port>",
9230 (void *)&cmd_config_tunnel_udp_port_port,
9231 (void *)&cmd_config_tunnel_udp_port_config,
9232 (void *)&cmd_config_tunnel_udp_port_port_id,
9233 (void *)&cmd_config_tunnel_udp_port_tunnel_port,
9234 (void *)&cmd_config_tunnel_udp_port_action,
9235 (void *)&cmd_config_tunnel_udp_port_tunnel_type,
9236 (void *)&cmd_config_tunnel_udp_port_value,
9241 /* *** GLOBAL CONFIG *** */
9242 struct cmd_global_config_result {
9243 cmdline_fixed_string_t cmd;
9245 cmdline_fixed_string_t cfg_type;
9250 cmd_global_config_parsed(void *parsed_result,
9251 __attribute__((unused)) struct cmdline *cl,
9252 __attribute__((unused)) void *data)
9254 struct cmd_global_config_result *res = parsed_result;
9255 struct rte_eth_global_cfg conf;
9258 memset(&conf, 0, sizeof(conf));
9259 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
9260 conf.cfg.gre_key_len = res->len;
9261 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
9262 RTE_ETH_FILTER_SET, &conf);
9264 printf("Global config error\n");
9267 cmdline_parse_token_string_t cmd_global_config_cmd =
9268 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
9270 cmdline_parse_token_num_t cmd_global_config_port_id =
9271 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id,
9273 cmdline_parse_token_string_t cmd_global_config_type =
9274 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
9275 cfg_type, "gre-key-len");
9276 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
9277 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
9280 cmdline_parse_inst_t cmd_global_config = {
9281 .f = cmd_global_config_parsed,
9282 .data = (void *)NULL,
9283 .help_str = "global_config <port_id> gre-key-len <key_len>",
9285 (void *)&cmd_global_config_cmd,
9286 (void *)&cmd_global_config_port_id,
9287 (void *)&cmd_global_config_type,
9288 (void *)&cmd_global_config_gre_key_len,
9293 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
9294 struct cmd_set_mirror_mask_result {
9295 cmdline_fixed_string_t set;
9296 cmdline_fixed_string_t port;
9298 cmdline_fixed_string_t mirror;
9300 cmdline_fixed_string_t what;
9301 cmdline_fixed_string_t value;
9302 cmdline_fixed_string_t dstpool;
9304 cmdline_fixed_string_t on;
9307 cmdline_parse_token_string_t cmd_mirror_mask_set =
9308 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9310 cmdline_parse_token_string_t cmd_mirror_mask_port =
9311 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9313 cmdline_parse_token_num_t cmd_mirror_mask_portid =
9314 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9316 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
9317 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9318 mirror, "mirror-rule");
9319 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
9320 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9322 cmdline_parse_token_string_t cmd_mirror_mask_what =
9323 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9324 what, "pool-mirror-up#pool-mirror-down"
9326 cmdline_parse_token_string_t cmd_mirror_mask_value =
9327 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9329 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
9330 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9331 dstpool, "dst-pool");
9332 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
9333 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9335 cmdline_parse_token_string_t cmd_mirror_mask_on =
9336 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9340 cmd_set_mirror_mask_parsed(void *parsed_result,
9341 __attribute__((unused)) struct cmdline *cl,
9342 __attribute__((unused)) void *data)
9345 struct cmd_set_mirror_mask_result *res = parsed_result;
9346 struct rte_eth_mirror_conf mr_conf;
9348 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9350 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
9352 mr_conf.dst_pool = res->dstpool_id;
9354 if (!strcmp(res->what, "pool-mirror-up")) {
9355 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9356 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
9357 } else if (!strcmp(res->what, "pool-mirror-down")) {
9358 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9359 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
9360 } else if (!strcmp(res->what, "vlan-mirror")) {
9361 mr_conf.rule_type = ETH_MIRROR_VLAN;
9362 nb_item = parse_item_list(res->value, "vlan",
9363 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
9367 for (i = 0; i < nb_item; i++) {
9368 if (vlan_list[i] > RTE_ETHER_MAX_VLAN_ID) {
9369 printf("Invalid vlan_id: must be < 4096\n");
9373 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
9374 mr_conf.vlan.vlan_mask |= 1ULL << i;
9378 if (!strcmp(res->on, "on"))
9379 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9382 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9385 printf("mirror rule add error: (%s)\n", strerror(-ret));
9388 cmdline_parse_inst_t cmd_set_mirror_mask = {
9389 .f = cmd_set_mirror_mask_parsed,
9391 .help_str = "set port <port_id> mirror-rule <rule_id> "
9392 "pool-mirror-up|pool-mirror-down|vlan-mirror "
9393 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
9395 (void *)&cmd_mirror_mask_set,
9396 (void *)&cmd_mirror_mask_port,
9397 (void *)&cmd_mirror_mask_portid,
9398 (void *)&cmd_mirror_mask_mirror,
9399 (void *)&cmd_mirror_mask_ruleid,
9400 (void *)&cmd_mirror_mask_what,
9401 (void *)&cmd_mirror_mask_value,
9402 (void *)&cmd_mirror_mask_dstpool,
9403 (void *)&cmd_mirror_mask_poolid,
9404 (void *)&cmd_mirror_mask_on,
9409 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
9410 struct cmd_set_mirror_link_result {
9411 cmdline_fixed_string_t set;
9412 cmdline_fixed_string_t port;
9414 cmdline_fixed_string_t mirror;
9416 cmdline_fixed_string_t what;
9417 cmdline_fixed_string_t dstpool;
9419 cmdline_fixed_string_t on;
9422 cmdline_parse_token_string_t cmd_mirror_link_set =
9423 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9425 cmdline_parse_token_string_t cmd_mirror_link_port =
9426 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9428 cmdline_parse_token_num_t cmd_mirror_link_portid =
9429 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9431 cmdline_parse_token_string_t cmd_mirror_link_mirror =
9432 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9433 mirror, "mirror-rule");
9434 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
9435 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9437 cmdline_parse_token_string_t cmd_mirror_link_what =
9438 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9439 what, "uplink-mirror#downlink-mirror");
9440 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
9441 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9442 dstpool, "dst-pool");
9443 cmdline_parse_token_num_t cmd_mirror_link_poolid =
9444 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9446 cmdline_parse_token_string_t cmd_mirror_link_on =
9447 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9451 cmd_set_mirror_link_parsed(void *parsed_result,
9452 __attribute__((unused)) struct cmdline *cl,
9453 __attribute__((unused)) void *data)
9456 struct cmd_set_mirror_link_result *res = parsed_result;
9457 struct rte_eth_mirror_conf mr_conf;
9459 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9460 if (!strcmp(res->what, "uplink-mirror"))
9461 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
9463 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
9465 mr_conf.dst_pool = res->dstpool_id;
9467 if (!strcmp(res->on, "on"))
9468 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9471 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9474 /* check the return value and print it if is < 0 */
9476 printf("mirror rule add error: (%s)\n", strerror(-ret));
9480 cmdline_parse_inst_t cmd_set_mirror_link = {
9481 .f = cmd_set_mirror_link_parsed,
9483 .help_str = "set port <port_id> mirror-rule <rule_id> "
9484 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
9486 (void *)&cmd_mirror_link_set,
9487 (void *)&cmd_mirror_link_port,
9488 (void *)&cmd_mirror_link_portid,
9489 (void *)&cmd_mirror_link_mirror,
9490 (void *)&cmd_mirror_link_ruleid,
9491 (void *)&cmd_mirror_link_what,
9492 (void *)&cmd_mirror_link_dstpool,
9493 (void *)&cmd_mirror_link_poolid,
9494 (void *)&cmd_mirror_link_on,
9499 /* *** RESET VM MIRROR RULE *** */
9500 struct cmd_rm_mirror_rule_result {
9501 cmdline_fixed_string_t reset;
9502 cmdline_fixed_string_t port;
9504 cmdline_fixed_string_t mirror;
9508 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
9509 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9511 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
9512 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9514 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
9515 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9517 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
9518 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9519 mirror, "mirror-rule");
9520 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
9521 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9525 cmd_reset_mirror_rule_parsed(void *parsed_result,
9526 __attribute__((unused)) struct cmdline *cl,
9527 __attribute__((unused)) void *data)
9530 struct cmd_set_mirror_link_result *res = parsed_result;
9532 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
9534 printf("mirror rule remove error: (%s)\n", strerror(-ret));
9537 cmdline_parse_inst_t cmd_reset_mirror_rule = {
9538 .f = cmd_reset_mirror_rule_parsed,
9540 .help_str = "reset port <port_id> mirror-rule <rule_id>",
9542 (void *)&cmd_rm_mirror_rule_reset,
9543 (void *)&cmd_rm_mirror_rule_port,
9544 (void *)&cmd_rm_mirror_rule_portid,
9545 (void *)&cmd_rm_mirror_rule_mirror,
9546 (void *)&cmd_rm_mirror_rule_ruleid,
9551 /* ******************************************************************************** */
9553 struct cmd_dump_result {
9554 cmdline_fixed_string_t dump;
9558 dump_struct_sizes(void)
9560 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9561 DUMP_SIZE(struct rte_mbuf);
9562 DUMP_SIZE(struct rte_mempool);
9563 DUMP_SIZE(struct rte_ring);
9567 static void cmd_dump_parsed(void *parsed_result,
9568 __attribute__((unused)) struct cmdline *cl,
9569 __attribute__((unused)) void *data)
9571 struct cmd_dump_result *res = parsed_result;
9573 if (!strcmp(res->dump, "dump_physmem"))
9574 rte_dump_physmem_layout(stdout);
9575 else if (!strcmp(res->dump, "dump_memzone"))
9576 rte_memzone_dump(stdout);
9577 else if (!strcmp(res->dump, "dump_struct_sizes"))
9578 dump_struct_sizes();
9579 else if (!strcmp(res->dump, "dump_ring"))
9580 rte_ring_list_dump(stdout);
9581 else if (!strcmp(res->dump, "dump_mempool"))
9582 rte_mempool_list_dump(stdout);
9583 else if (!strcmp(res->dump, "dump_devargs"))
9584 rte_devargs_dump(stdout);
9585 else if (!strcmp(res->dump, "dump_log_types"))
9586 rte_log_dump(stdout);
9589 cmdline_parse_token_string_t cmd_dump_dump =
9590 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9593 "dump_struct_sizes#"
9599 cmdline_parse_inst_t cmd_dump = {
9600 .f = cmd_dump_parsed, /* function to call */
9601 .data = NULL, /* 2nd arg of func */
9602 .help_str = "Dump status",
9603 .tokens = { /* token list, NULL terminated */
9604 (void *)&cmd_dump_dump,
9609 /* ******************************************************************************** */
9611 struct cmd_dump_one_result {
9612 cmdline_fixed_string_t dump;
9613 cmdline_fixed_string_t name;
9616 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9617 __attribute__((unused)) void *data)
9619 struct cmd_dump_one_result *res = parsed_result;
9621 if (!strcmp(res->dump, "dump_ring")) {
9623 r = rte_ring_lookup(res->name);
9625 cmdline_printf(cl, "Cannot find ring\n");
9628 rte_ring_dump(stdout, r);
9629 } else if (!strcmp(res->dump, "dump_mempool")) {
9630 struct rte_mempool *mp;
9631 mp = rte_mempool_lookup(res->name);
9633 cmdline_printf(cl, "Cannot find mempool\n");
9636 rte_mempool_dump(stdout, mp);
9640 cmdline_parse_token_string_t cmd_dump_one_dump =
9641 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9642 "dump_ring#dump_mempool");
9644 cmdline_parse_token_string_t cmd_dump_one_name =
9645 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9647 cmdline_parse_inst_t cmd_dump_one = {
9648 .f = cmd_dump_one_parsed, /* function to call */
9649 .data = NULL, /* 2nd arg of func */
9650 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9651 .tokens = { /* token list, NULL terminated */
9652 (void *)&cmd_dump_one_dump,
9653 (void *)&cmd_dump_one_name,
9658 /* *** Add/Del syn filter *** */
9659 struct cmd_syn_filter_result {
9660 cmdline_fixed_string_t filter;
9662 cmdline_fixed_string_t ops;
9663 cmdline_fixed_string_t priority;
9664 cmdline_fixed_string_t high;
9665 cmdline_fixed_string_t queue;
9670 cmd_syn_filter_parsed(void *parsed_result,
9671 __attribute__((unused)) struct cmdline *cl,
9672 __attribute__((unused)) void *data)
9674 struct cmd_syn_filter_result *res = parsed_result;
9675 struct rte_eth_syn_filter syn_filter;
9678 ret = rte_eth_dev_filter_supported(res->port_id,
9679 RTE_ETH_FILTER_SYN);
9681 printf("syn filter is not supported on port %u.\n",
9686 memset(&syn_filter, 0, sizeof(syn_filter));
9688 if (!strcmp(res->ops, "add")) {
9689 if (!strcmp(res->high, "high"))
9690 syn_filter.hig_pri = 1;
9692 syn_filter.hig_pri = 0;
9694 syn_filter.queue = res->queue_id;
9695 ret = rte_eth_dev_filter_ctrl(res->port_id,
9700 ret = rte_eth_dev_filter_ctrl(res->port_id,
9702 RTE_ETH_FILTER_DELETE,
9706 printf("syn filter programming error: (%s)\n",
9710 cmdline_parse_token_string_t cmd_syn_filter_filter =
9711 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9712 filter, "syn_filter");
9713 cmdline_parse_token_num_t cmd_syn_filter_port_id =
9714 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9716 cmdline_parse_token_string_t cmd_syn_filter_ops =
9717 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9719 cmdline_parse_token_string_t cmd_syn_filter_priority =
9720 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9721 priority, "priority");
9722 cmdline_parse_token_string_t cmd_syn_filter_high =
9723 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9725 cmdline_parse_token_string_t cmd_syn_filter_queue =
9726 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9728 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
9729 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9732 cmdline_parse_inst_t cmd_syn_filter = {
9733 .f = cmd_syn_filter_parsed,
9735 .help_str = "syn_filter <port_id> add|del priority high|low queue "
9736 "<queue_id>: Add/Delete syn filter",
9738 (void *)&cmd_syn_filter_filter,
9739 (void *)&cmd_syn_filter_port_id,
9740 (void *)&cmd_syn_filter_ops,
9741 (void *)&cmd_syn_filter_priority,
9742 (void *)&cmd_syn_filter_high,
9743 (void *)&cmd_syn_filter_queue,
9744 (void *)&cmd_syn_filter_queue_id,
9749 /* *** queue region set *** */
9750 struct cmd_queue_region_result {
9751 cmdline_fixed_string_t set;
9752 cmdline_fixed_string_t port;
9754 cmdline_fixed_string_t cmd;
9755 cmdline_fixed_string_t region;
9757 cmdline_fixed_string_t queue_start_index;
9759 cmdline_fixed_string_t queue_num;
9760 uint8_t queue_num_value;
9764 cmd_queue_region_parsed(void *parsed_result,
9765 __attribute__((unused)) struct cmdline *cl,
9766 __attribute__((unused)) void *data)
9768 struct cmd_queue_region_result *res = parsed_result;
9770 #ifdef RTE_LIBRTE_I40E_PMD
9771 struct rte_pmd_i40e_queue_region_conf region_conf;
9772 enum rte_pmd_i40e_queue_region_op op_type;
9775 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9778 #ifdef RTE_LIBRTE_I40E_PMD
9779 memset(®ion_conf, 0, sizeof(region_conf));
9780 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
9781 region_conf.region_id = res->region_id;
9782 region_conf.queue_num = res->queue_num_value;
9783 region_conf.queue_start_index = res->queue_id;
9785 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9786 op_type, ®ion_conf);
9793 printf("function not implemented or supported\n");
9796 printf("queue region config error: (%s)\n", strerror(-ret));
9800 cmdline_parse_token_string_t cmd_queue_region_set =
9801 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9803 cmdline_parse_token_string_t cmd_queue_region_port =
9804 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
9805 cmdline_parse_token_num_t cmd_queue_region_port_id =
9806 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9808 cmdline_parse_token_string_t cmd_queue_region_cmd =
9809 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9810 cmd, "queue-region");
9811 cmdline_parse_token_string_t cmd_queue_region_id =
9812 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9813 region, "region_id");
9814 cmdline_parse_token_num_t cmd_queue_region_index =
9815 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9817 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
9818 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9819 queue_start_index, "queue_start_index");
9820 cmdline_parse_token_num_t cmd_queue_region_queue_id =
9821 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9823 cmdline_parse_token_string_t cmd_queue_region_queue_num =
9824 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9825 queue_num, "queue_num");
9826 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
9827 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9828 queue_num_value, UINT8);
9830 cmdline_parse_inst_t cmd_queue_region = {
9831 .f = cmd_queue_region_parsed,
9833 .help_str = "set port <port_id> queue-region region_id <value> "
9834 "queue_start_index <value> queue_num <value>: Set a queue region",
9836 (void *)&cmd_queue_region_set,
9837 (void *)&cmd_queue_region_port,
9838 (void *)&cmd_queue_region_port_id,
9839 (void *)&cmd_queue_region_cmd,
9840 (void *)&cmd_queue_region_id,
9841 (void *)&cmd_queue_region_index,
9842 (void *)&cmd_queue_region_queue_start_index,
9843 (void *)&cmd_queue_region_queue_id,
9844 (void *)&cmd_queue_region_queue_num,
9845 (void *)&cmd_queue_region_queue_num_value,
9850 /* *** queue region and flowtype set *** */
9851 struct cmd_region_flowtype_result {
9852 cmdline_fixed_string_t set;
9853 cmdline_fixed_string_t port;
9855 cmdline_fixed_string_t cmd;
9856 cmdline_fixed_string_t region;
9858 cmdline_fixed_string_t flowtype;
9859 uint8_t flowtype_id;
9863 cmd_region_flowtype_parsed(void *parsed_result,
9864 __attribute__((unused)) struct cmdline *cl,
9865 __attribute__((unused)) void *data)
9867 struct cmd_region_flowtype_result *res = parsed_result;
9869 #ifdef RTE_LIBRTE_I40E_PMD
9870 struct rte_pmd_i40e_queue_region_conf region_conf;
9871 enum rte_pmd_i40e_queue_region_op op_type;
9874 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9877 #ifdef RTE_LIBRTE_I40E_PMD
9878 memset(®ion_conf, 0, sizeof(region_conf));
9880 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
9881 region_conf.region_id = res->region_id;
9882 region_conf.hw_flowtype = res->flowtype_id;
9884 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9885 op_type, ®ion_conf);
9892 printf("function not implemented or supported\n");
9895 printf("region flowtype config error: (%s)\n", strerror(-ret));
9899 cmdline_parse_token_string_t cmd_region_flowtype_set =
9900 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9902 cmdline_parse_token_string_t cmd_region_flowtype_port =
9903 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9905 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
9906 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9908 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
9909 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9910 cmd, "queue-region");
9911 cmdline_parse_token_string_t cmd_region_flowtype_index =
9912 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9913 region, "region_id");
9914 cmdline_parse_token_num_t cmd_region_flowtype_id =
9915 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9917 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
9918 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9919 flowtype, "flowtype");
9920 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
9921 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9922 flowtype_id, UINT8);
9923 cmdline_parse_inst_t cmd_region_flowtype = {
9924 .f = cmd_region_flowtype_parsed,
9926 .help_str = "set port <port_id> queue-region region_id <value> "
9927 "flowtype <value>: Set a flowtype region index",
9929 (void *)&cmd_region_flowtype_set,
9930 (void *)&cmd_region_flowtype_port,
9931 (void *)&cmd_region_flowtype_port_index,
9932 (void *)&cmd_region_flowtype_cmd,
9933 (void *)&cmd_region_flowtype_index,
9934 (void *)&cmd_region_flowtype_id,
9935 (void *)&cmd_region_flowtype_flow_index,
9936 (void *)&cmd_region_flowtype_flow_id,
9941 /* *** User Priority (UP) to queue region (region_id) set *** */
9942 struct cmd_user_priority_region_result {
9943 cmdline_fixed_string_t set;
9944 cmdline_fixed_string_t port;
9946 cmdline_fixed_string_t cmd;
9947 cmdline_fixed_string_t user_priority;
9948 uint8_t user_priority_id;
9949 cmdline_fixed_string_t region;
9954 cmd_user_priority_region_parsed(void *parsed_result,
9955 __attribute__((unused)) struct cmdline *cl,
9956 __attribute__((unused)) void *data)
9958 struct cmd_user_priority_region_result *res = parsed_result;
9960 #ifdef RTE_LIBRTE_I40E_PMD
9961 struct rte_pmd_i40e_queue_region_conf region_conf;
9962 enum rte_pmd_i40e_queue_region_op op_type;
9965 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9968 #ifdef RTE_LIBRTE_I40E_PMD
9969 memset(®ion_conf, 0, sizeof(region_conf));
9970 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
9971 region_conf.user_priority = res->user_priority_id;
9972 region_conf.region_id = res->region_id;
9974 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9975 op_type, ®ion_conf);
9982 printf("function not implemented or supported\n");
9985 printf("user_priority region config error: (%s)\n",
9990 cmdline_parse_token_string_t cmd_user_priority_region_set =
9991 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9993 cmdline_parse_token_string_t cmd_user_priority_region_port =
9994 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9996 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
9997 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9999 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
10000 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10001 cmd, "queue-region");
10002 cmdline_parse_token_string_t cmd_user_priority_region_UP =
10003 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10004 user_priority, "UP");
10005 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
10006 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10007 user_priority_id, UINT8);
10008 cmdline_parse_token_string_t cmd_user_priority_region_region =
10009 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10010 region, "region_id");
10011 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
10012 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10015 cmdline_parse_inst_t cmd_user_priority_region = {
10016 .f = cmd_user_priority_region_parsed,
10018 .help_str = "set port <port_id> queue-region UP <value> "
10019 "region_id <value>: Set the mapping of User Priority (UP) "
10020 "to queue region (region_id) ",
10022 (void *)&cmd_user_priority_region_set,
10023 (void *)&cmd_user_priority_region_port,
10024 (void *)&cmd_user_priority_region_port_index,
10025 (void *)&cmd_user_priority_region_cmd,
10026 (void *)&cmd_user_priority_region_UP,
10027 (void *)&cmd_user_priority_region_UP_id,
10028 (void *)&cmd_user_priority_region_region,
10029 (void *)&cmd_user_priority_region_region_id,
10034 /* *** flush all queue region related configuration *** */
10035 struct cmd_flush_queue_region_result {
10036 cmdline_fixed_string_t set;
10037 cmdline_fixed_string_t port;
10039 cmdline_fixed_string_t cmd;
10040 cmdline_fixed_string_t flush;
10041 cmdline_fixed_string_t what;
10045 cmd_flush_queue_region_parsed(void *parsed_result,
10046 __attribute__((unused)) struct cmdline *cl,
10047 __attribute__((unused)) void *data)
10049 struct cmd_flush_queue_region_result *res = parsed_result;
10050 int ret = -ENOTSUP;
10051 #ifdef RTE_LIBRTE_I40E_PMD
10052 struct rte_pmd_i40e_queue_region_conf region_conf;
10053 enum rte_pmd_i40e_queue_region_op op_type;
10056 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10059 #ifdef RTE_LIBRTE_I40E_PMD
10060 memset(®ion_conf, 0, sizeof(region_conf));
10062 if (strcmp(res->what, "on") == 0)
10063 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
10065 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
10067 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10068 op_type, ®ion_conf);
10075 printf("function not implemented or supported\n");
10078 printf("queue region config flush error: (%s)\n",
10083 cmdline_parse_token_string_t cmd_flush_queue_region_set =
10084 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10086 cmdline_parse_token_string_t cmd_flush_queue_region_port =
10087 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10089 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
10090 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
10092 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
10093 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10094 cmd, "queue-region");
10095 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
10096 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10098 cmdline_parse_token_string_t cmd_flush_queue_region_what =
10099 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10102 cmdline_parse_inst_t cmd_flush_queue_region = {
10103 .f = cmd_flush_queue_region_parsed,
10105 .help_str = "set port <port_id> queue-region flush on|off"
10106 ": flush all queue region related configuration",
10108 (void *)&cmd_flush_queue_region_set,
10109 (void *)&cmd_flush_queue_region_port,
10110 (void *)&cmd_flush_queue_region_port_index,
10111 (void *)&cmd_flush_queue_region_cmd,
10112 (void *)&cmd_flush_queue_region_flush,
10113 (void *)&cmd_flush_queue_region_what,
10118 /* *** get all queue region related configuration info *** */
10119 struct cmd_show_queue_region_info {
10120 cmdline_fixed_string_t show;
10121 cmdline_fixed_string_t port;
10123 cmdline_fixed_string_t cmd;
10127 cmd_show_queue_region_info_parsed(void *parsed_result,
10128 __attribute__((unused)) struct cmdline *cl,
10129 __attribute__((unused)) void *data)
10131 struct cmd_show_queue_region_info *res = parsed_result;
10132 int ret = -ENOTSUP;
10133 #ifdef RTE_LIBRTE_I40E_PMD
10134 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
10135 enum rte_pmd_i40e_queue_region_op op_type;
10138 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10141 #ifdef RTE_LIBRTE_I40E_PMD
10142 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
10144 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
10146 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10147 op_type, &rte_pmd_regions);
10149 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
10156 printf("function not implemented or supported\n");
10159 printf("queue region config info show error: (%s)\n",
10164 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
10165 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10167 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
10168 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10170 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
10171 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
10173 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
10174 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10175 cmd, "queue-region");
10177 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
10178 .f = cmd_show_queue_region_info_parsed,
10180 .help_str = "show port <port_id> queue-region"
10181 ": show all queue region related configuration info",
10183 (void *)&cmd_show_queue_region_info_get,
10184 (void *)&cmd_show_queue_region_info_port,
10185 (void *)&cmd_show_queue_region_info_port_index,
10186 (void *)&cmd_show_queue_region_info_cmd,
10191 /* *** ADD/REMOVE A 2tuple FILTER *** */
10192 struct cmd_2tuple_filter_result {
10193 cmdline_fixed_string_t filter;
10195 cmdline_fixed_string_t ops;
10196 cmdline_fixed_string_t dst_port;
10197 uint16_t dst_port_value;
10198 cmdline_fixed_string_t protocol;
10199 uint8_t protocol_value;
10200 cmdline_fixed_string_t mask;
10201 uint8_t mask_value;
10202 cmdline_fixed_string_t tcp_flags;
10203 uint8_t tcp_flags_value;
10204 cmdline_fixed_string_t priority;
10205 uint8_t priority_value;
10206 cmdline_fixed_string_t queue;
10211 cmd_2tuple_filter_parsed(void *parsed_result,
10212 __attribute__((unused)) struct cmdline *cl,
10213 __attribute__((unused)) void *data)
10215 struct rte_eth_ntuple_filter filter;
10216 struct cmd_2tuple_filter_result *res = parsed_result;
10219 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
10221 printf("ntuple filter is not supported on port %u.\n",
10226 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
10228 filter.flags = RTE_2TUPLE_FLAGS;
10229 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
10230 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
10231 filter.proto = res->protocol_value;
10232 filter.priority = res->priority_value;
10233 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
10234 printf("nonzero tcp_flags is only meaningful"
10235 " when protocol is TCP.\n");
10238 if (res->tcp_flags_value > RTE_NTUPLE_TCP_FLAGS_MASK) {
10239 printf("invalid TCP flags.\n");
10243 if (res->tcp_flags_value != 0) {
10244 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
10245 filter.tcp_flags = res->tcp_flags_value;
10248 /* need convert to big endian. */
10249 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
10250 filter.queue = res->queue_id;
10252 if (!strcmp(res->ops, "add"))
10253 ret = rte_eth_dev_filter_ctrl(res->port_id,
10254 RTE_ETH_FILTER_NTUPLE,
10255 RTE_ETH_FILTER_ADD,
10258 ret = rte_eth_dev_filter_ctrl(res->port_id,
10259 RTE_ETH_FILTER_NTUPLE,
10260 RTE_ETH_FILTER_DELETE,
10263 printf("2tuple filter programming error: (%s)\n",
10268 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
10269 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10270 filter, "2tuple_filter");
10271 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
10272 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10274 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
10275 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10277 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
10278 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10279 dst_port, "dst_port");
10280 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
10281 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10282 dst_port_value, UINT16);
10283 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
10284 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10285 protocol, "protocol");
10286 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
10287 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10288 protocol_value, UINT8);
10289 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
10290 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10292 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
10293 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10295 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
10296 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10297 tcp_flags, "tcp_flags");
10298 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
10299 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10300 tcp_flags_value, UINT8);
10301 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
10302 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10303 priority, "priority");
10304 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
10305 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10306 priority_value, UINT8);
10307 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
10308 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10310 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
10311 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10314 cmdline_parse_inst_t cmd_2tuple_filter = {
10315 .f = cmd_2tuple_filter_parsed,
10317 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
10318 "<value> mask <value> tcp_flags <value> priority <value> queue "
10319 "<queue_id>: Add a 2tuple filter",
10321 (void *)&cmd_2tuple_filter_filter,
10322 (void *)&cmd_2tuple_filter_port_id,
10323 (void *)&cmd_2tuple_filter_ops,
10324 (void *)&cmd_2tuple_filter_dst_port,
10325 (void *)&cmd_2tuple_filter_dst_port_value,
10326 (void *)&cmd_2tuple_filter_protocol,
10327 (void *)&cmd_2tuple_filter_protocol_value,
10328 (void *)&cmd_2tuple_filter_mask,
10329 (void *)&cmd_2tuple_filter_mask_value,
10330 (void *)&cmd_2tuple_filter_tcp_flags,
10331 (void *)&cmd_2tuple_filter_tcp_flags_value,
10332 (void *)&cmd_2tuple_filter_priority,
10333 (void *)&cmd_2tuple_filter_priority_value,
10334 (void *)&cmd_2tuple_filter_queue,
10335 (void *)&cmd_2tuple_filter_queue_id,
10340 /* *** ADD/REMOVE A 5tuple FILTER *** */
10341 struct cmd_5tuple_filter_result {
10342 cmdline_fixed_string_t filter;
10344 cmdline_fixed_string_t ops;
10345 cmdline_fixed_string_t dst_ip;
10346 cmdline_ipaddr_t dst_ip_value;
10347 cmdline_fixed_string_t src_ip;
10348 cmdline_ipaddr_t src_ip_value;
10349 cmdline_fixed_string_t dst_port;
10350 uint16_t dst_port_value;
10351 cmdline_fixed_string_t src_port;
10352 uint16_t src_port_value;
10353 cmdline_fixed_string_t protocol;
10354 uint8_t protocol_value;
10355 cmdline_fixed_string_t mask;
10356 uint8_t mask_value;
10357 cmdline_fixed_string_t tcp_flags;
10358 uint8_t tcp_flags_value;
10359 cmdline_fixed_string_t priority;
10360 uint8_t priority_value;
10361 cmdline_fixed_string_t queue;
10366 cmd_5tuple_filter_parsed(void *parsed_result,
10367 __attribute__((unused)) struct cmdline *cl,
10368 __attribute__((unused)) void *data)
10370 struct rte_eth_ntuple_filter filter;
10371 struct cmd_5tuple_filter_result *res = parsed_result;
10374 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
10376 printf("ntuple filter is not supported on port %u.\n",
10381 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
10383 filter.flags = RTE_5TUPLE_FLAGS;
10384 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
10385 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
10386 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
10387 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
10388 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
10389 filter.proto = res->protocol_value;
10390 filter.priority = res->priority_value;
10391 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
10392 printf("nonzero tcp_flags is only meaningful"
10393 " when protocol is TCP.\n");
10396 if (res->tcp_flags_value > RTE_NTUPLE_TCP_FLAGS_MASK) {
10397 printf("invalid TCP flags.\n");
10401 if (res->tcp_flags_value != 0) {
10402 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
10403 filter.tcp_flags = res->tcp_flags_value;
10406 if (res->dst_ip_value.family == AF_INET)
10407 /* no need to convert, already big endian. */
10408 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
10410 if (filter.dst_ip_mask == 0) {
10411 printf("can not support ipv6 involved compare.\n");
10417 if (res->src_ip_value.family == AF_INET)
10418 /* no need to convert, already big endian. */
10419 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
10421 if (filter.src_ip_mask == 0) {
10422 printf("can not support ipv6 involved compare.\n");
10427 /* need convert to big endian. */
10428 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
10429 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
10430 filter.queue = res->queue_id;
10432 if (!strcmp(res->ops, "add"))
10433 ret = rte_eth_dev_filter_ctrl(res->port_id,
10434 RTE_ETH_FILTER_NTUPLE,
10435 RTE_ETH_FILTER_ADD,
10438 ret = rte_eth_dev_filter_ctrl(res->port_id,
10439 RTE_ETH_FILTER_NTUPLE,
10440 RTE_ETH_FILTER_DELETE,
10443 printf("5tuple filter programming error: (%s)\n",
10447 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
10448 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10449 filter, "5tuple_filter");
10450 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
10451 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10453 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
10454 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10456 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
10457 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10459 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
10460 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10462 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
10463 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10465 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
10466 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10468 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
10469 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10470 dst_port, "dst_port");
10471 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
10472 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10473 dst_port_value, UINT16);
10474 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
10475 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10476 src_port, "src_port");
10477 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
10478 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10479 src_port_value, UINT16);
10480 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
10481 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10482 protocol, "protocol");
10483 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
10484 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10485 protocol_value, UINT8);
10486 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
10487 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10489 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
10490 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10492 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
10493 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10494 tcp_flags, "tcp_flags");
10495 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
10496 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10497 tcp_flags_value, UINT8);
10498 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
10499 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10500 priority, "priority");
10501 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
10502 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10503 priority_value, UINT8);
10504 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
10505 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10507 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
10508 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10511 cmdline_parse_inst_t cmd_5tuple_filter = {
10512 .f = cmd_5tuple_filter_parsed,
10514 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
10515 "src_ip <value> dst_port <value> src_port <value> "
10516 "protocol <value> mask <value> tcp_flags <value> "
10517 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
10519 (void *)&cmd_5tuple_filter_filter,
10520 (void *)&cmd_5tuple_filter_port_id,
10521 (void *)&cmd_5tuple_filter_ops,
10522 (void *)&cmd_5tuple_filter_dst_ip,
10523 (void *)&cmd_5tuple_filter_dst_ip_value,
10524 (void *)&cmd_5tuple_filter_src_ip,
10525 (void *)&cmd_5tuple_filter_src_ip_value,
10526 (void *)&cmd_5tuple_filter_dst_port,
10527 (void *)&cmd_5tuple_filter_dst_port_value,
10528 (void *)&cmd_5tuple_filter_src_port,
10529 (void *)&cmd_5tuple_filter_src_port_value,
10530 (void *)&cmd_5tuple_filter_protocol,
10531 (void *)&cmd_5tuple_filter_protocol_value,
10532 (void *)&cmd_5tuple_filter_mask,
10533 (void *)&cmd_5tuple_filter_mask_value,
10534 (void *)&cmd_5tuple_filter_tcp_flags,
10535 (void *)&cmd_5tuple_filter_tcp_flags_value,
10536 (void *)&cmd_5tuple_filter_priority,
10537 (void *)&cmd_5tuple_filter_priority_value,
10538 (void *)&cmd_5tuple_filter_queue,
10539 (void *)&cmd_5tuple_filter_queue_id,
10544 /* *** ADD/REMOVE A flex FILTER *** */
10545 struct cmd_flex_filter_result {
10546 cmdline_fixed_string_t filter;
10547 cmdline_fixed_string_t ops;
10549 cmdline_fixed_string_t len;
10551 cmdline_fixed_string_t bytes;
10552 cmdline_fixed_string_t bytes_value;
10553 cmdline_fixed_string_t mask;
10554 cmdline_fixed_string_t mask_value;
10555 cmdline_fixed_string_t priority;
10556 uint8_t priority_value;
10557 cmdline_fixed_string_t queue;
10561 static int xdigit2val(unsigned char c)
10566 else if (isupper(c))
10567 val = c - 'A' + 10;
10569 val = c - 'a' + 10;
10574 cmd_flex_filter_parsed(void *parsed_result,
10575 __attribute__((unused)) struct cmdline *cl,
10576 __attribute__((unused)) void *data)
10579 struct rte_eth_flex_filter filter;
10580 struct cmd_flex_filter_result *res = parsed_result;
10581 char *bytes_ptr, *mask_ptr;
10582 uint16_t len, i, j = 0;
10587 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
10588 printf("the len exceed the max length 128\n");
10591 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
10592 filter.len = res->len_value;
10593 filter.priority = res->priority_value;
10594 filter.queue = res->queue_id;
10595 bytes_ptr = res->bytes_value;
10596 mask_ptr = res->mask_value;
10598 /* translate bytes string to array. */
10599 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
10600 (bytes_ptr[1] == 'X')))
10602 len = strnlen(bytes_ptr, res->len_value * 2);
10603 if (len == 0 || (len % 8 != 0)) {
10604 printf("please check len and bytes input\n");
10607 for (i = 0; i < len; i++) {
10609 if (isxdigit(c) == 0) {
10610 /* invalid characters. */
10611 printf("invalid input\n");
10614 val = xdigit2val(c);
10617 filter.bytes[j] = byte;
10618 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
10625 /* translate mask string to uint8_t array. */
10626 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
10627 (mask_ptr[1] == 'X')))
10629 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
10631 printf("invalid input\n");
10636 for (i = 0; i < len; i++) {
10638 if (isxdigit(c) == 0) {
10639 /* invalid characters. */
10640 printf("invalid input\n");
10643 val = xdigit2val(c);
10646 filter.mask[j] = byte;
10647 printf("mask[%d]:%02x ", j, filter.mask[j]);
10655 if (!strcmp(res->ops, "add"))
10656 ret = rte_eth_dev_filter_ctrl(res->port_id,
10657 RTE_ETH_FILTER_FLEXIBLE,
10658 RTE_ETH_FILTER_ADD,
10661 ret = rte_eth_dev_filter_ctrl(res->port_id,
10662 RTE_ETH_FILTER_FLEXIBLE,
10663 RTE_ETH_FILTER_DELETE,
10667 printf("flex filter setting error: (%s)\n", strerror(-ret));
10670 cmdline_parse_token_string_t cmd_flex_filter_filter =
10671 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10672 filter, "flex_filter");
10673 cmdline_parse_token_num_t cmd_flex_filter_port_id =
10674 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10676 cmdline_parse_token_string_t cmd_flex_filter_ops =
10677 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10679 cmdline_parse_token_string_t cmd_flex_filter_len =
10680 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10682 cmdline_parse_token_num_t cmd_flex_filter_len_value =
10683 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10685 cmdline_parse_token_string_t cmd_flex_filter_bytes =
10686 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10688 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
10689 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10690 bytes_value, NULL);
10691 cmdline_parse_token_string_t cmd_flex_filter_mask =
10692 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10694 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
10695 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10697 cmdline_parse_token_string_t cmd_flex_filter_priority =
10698 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10699 priority, "priority");
10700 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
10701 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10702 priority_value, UINT8);
10703 cmdline_parse_token_string_t cmd_flex_filter_queue =
10704 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10706 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
10707 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10709 cmdline_parse_inst_t cmd_flex_filter = {
10710 .f = cmd_flex_filter_parsed,
10712 .help_str = "flex_filter <port_id> add|del len <value> bytes "
10713 "<value> mask <value> priority <value> queue <queue_id>: "
10714 "Add/Del a flex filter",
10716 (void *)&cmd_flex_filter_filter,
10717 (void *)&cmd_flex_filter_port_id,
10718 (void *)&cmd_flex_filter_ops,
10719 (void *)&cmd_flex_filter_len,
10720 (void *)&cmd_flex_filter_len_value,
10721 (void *)&cmd_flex_filter_bytes,
10722 (void *)&cmd_flex_filter_bytes_value,
10723 (void *)&cmd_flex_filter_mask,
10724 (void *)&cmd_flex_filter_mask_value,
10725 (void *)&cmd_flex_filter_priority,
10726 (void *)&cmd_flex_filter_priority_value,
10727 (void *)&cmd_flex_filter_queue,
10728 (void *)&cmd_flex_filter_queue_id,
10733 /* *** Filters Control *** */
10735 /* *** deal with ethertype filter *** */
10736 struct cmd_ethertype_filter_result {
10737 cmdline_fixed_string_t filter;
10739 cmdline_fixed_string_t ops;
10740 cmdline_fixed_string_t mac;
10741 struct rte_ether_addr mac_addr;
10742 cmdline_fixed_string_t ethertype;
10743 uint16_t ethertype_value;
10744 cmdline_fixed_string_t drop;
10745 cmdline_fixed_string_t queue;
10749 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
10750 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10751 filter, "ethertype_filter");
10752 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
10753 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10755 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
10756 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10758 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
10759 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10760 mac, "mac_addr#mac_ignr");
10761 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
10762 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
10764 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
10765 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10766 ethertype, "ethertype");
10767 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
10768 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10769 ethertype_value, UINT16);
10770 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
10771 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10773 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
10774 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10776 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
10777 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10781 cmd_ethertype_filter_parsed(void *parsed_result,
10782 __attribute__((unused)) struct cmdline *cl,
10783 __attribute__((unused)) void *data)
10785 struct cmd_ethertype_filter_result *res = parsed_result;
10786 struct rte_eth_ethertype_filter filter;
10789 ret = rte_eth_dev_filter_supported(res->port_id,
10790 RTE_ETH_FILTER_ETHERTYPE);
10792 printf("ethertype filter is not supported on port %u.\n",
10797 memset(&filter, 0, sizeof(filter));
10798 if (!strcmp(res->mac, "mac_addr")) {
10799 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
10800 rte_memcpy(&filter.mac_addr, &res->mac_addr,
10801 sizeof(struct rte_ether_addr));
10803 if (!strcmp(res->drop, "drop"))
10804 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
10805 filter.ether_type = res->ethertype_value;
10806 filter.queue = res->queue_id;
10808 if (!strcmp(res->ops, "add"))
10809 ret = rte_eth_dev_filter_ctrl(res->port_id,
10810 RTE_ETH_FILTER_ETHERTYPE,
10811 RTE_ETH_FILTER_ADD,
10814 ret = rte_eth_dev_filter_ctrl(res->port_id,
10815 RTE_ETH_FILTER_ETHERTYPE,
10816 RTE_ETH_FILTER_DELETE,
10819 printf("ethertype filter programming error: (%s)\n",
10823 cmdline_parse_inst_t cmd_ethertype_filter = {
10824 .f = cmd_ethertype_filter_parsed,
10826 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
10827 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
10828 "Add or delete an ethertype filter entry",
10830 (void *)&cmd_ethertype_filter_filter,
10831 (void *)&cmd_ethertype_filter_port_id,
10832 (void *)&cmd_ethertype_filter_ops,
10833 (void *)&cmd_ethertype_filter_mac,
10834 (void *)&cmd_ethertype_filter_mac_addr,
10835 (void *)&cmd_ethertype_filter_ethertype,
10836 (void *)&cmd_ethertype_filter_ethertype_value,
10837 (void *)&cmd_ethertype_filter_drop,
10838 (void *)&cmd_ethertype_filter_queue,
10839 (void *)&cmd_ethertype_filter_queue_id,
10844 /* *** deal with flow director filter *** */
10845 struct cmd_flow_director_result {
10846 cmdline_fixed_string_t flow_director_filter;
10848 cmdline_fixed_string_t mode;
10849 cmdline_fixed_string_t mode_value;
10850 cmdline_fixed_string_t ops;
10851 cmdline_fixed_string_t flow;
10852 cmdline_fixed_string_t flow_type;
10853 cmdline_fixed_string_t ether;
10854 uint16_t ether_type;
10855 cmdline_fixed_string_t src;
10856 cmdline_ipaddr_t ip_src;
10858 cmdline_fixed_string_t dst;
10859 cmdline_ipaddr_t ip_dst;
10861 cmdline_fixed_string_t verify_tag;
10862 uint32_t verify_tag_value;
10863 cmdline_fixed_string_t tos;
10865 cmdline_fixed_string_t proto;
10866 uint8_t proto_value;
10867 cmdline_fixed_string_t ttl;
10869 cmdline_fixed_string_t vlan;
10870 uint16_t vlan_value;
10871 cmdline_fixed_string_t flexbytes;
10872 cmdline_fixed_string_t flexbytes_value;
10873 cmdline_fixed_string_t pf_vf;
10874 cmdline_fixed_string_t drop;
10875 cmdline_fixed_string_t queue;
10877 cmdline_fixed_string_t fd_id;
10878 uint32_t fd_id_value;
10879 cmdline_fixed_string_t mac;
10880 struct rte_ether_addr mac_addr;
10881 cmdline_fixed_string_t tunnel;
10882 cmdline_fixed_string_t tunnel_type;
10883 cmdline_fixed_string_t tunnel_id;
10884 uint32_t tunnel_id_value;
10885 cmdline_fixed_string_t packet;
10890 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
10893 const char *p, *p0 = q_arg;
10895 unsigned long int_fld;
10896 char *str_fld[max_num];
10901 p = strchr(p0, '(');
10905 p0 = strchr(p, ')');
10910 if (size >= sizeof(s))
10913 snprintf(s, sizeof(s), "%.*s", size, p);
10914 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10915 if (ret < 0 || ret > max_num)
10917 for (i = 0; i < ret; i++) {
10919 int_fld = strtoul(str_fld[i], &end, 0);
10920 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
10922 flexbytes[i] = (uint8_t)int_fld;
10928 str2flowtype(char *string)
10931 static const struct {
10934 } flowtype_str[] = {
10935 {"raw", RTE_ETH_FLOW_RAW},
10936 {"ipv4", RTE_ETH_FLOW_IPV4},
10937 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10938 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10939 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10940 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10941 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10942 {"ipv6", RTE_ETH_FLOW_IPV6},
10943 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10944 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10945 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10946 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10947 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10948 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10951 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
10952 if (!strcmp(flowtype_str[i].str, string))
10953 return flowtype_str[i].type;
10956 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
10957 return (uint16_t)atoi(string);
10959 return RTE_ETH_FLOW_UNKNOWN;
10962 static enum rte_eth_fdir_tunnel_type
10963 str2fdir_tunneltype(char *string)
10967 static const struct {
10969 enum rte_eth_fdir_tunnel_type type;
10970 } tunneltype_str[] = {
10971 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
10972 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
10975 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
10976 if (!strcmp(tunneltype_str[i].str, string))
10977 return tunneltype_str[i].type;
10979 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
10982 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10984 if ((ip_addr).family == AF_INET) \
10985 (ip) = (ip_addr).addr.ipv4.s_addr; \
10987 printf("invalid parameter.\n"); \
10992 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10994 if ((ip_addr).family == AF_INET6) \
10995 rte_memcpy(&(ip), \
10996 &((ip_addr).addr.ipv6), \
10997 sizeof(struct in6_addr)); \
10999 printf("invalid parameter.\n"); \
11005 cmd_flow_director_filter_parsed(void *parsed_result,
11006 __attribute__((unused)) struct cmdline *cl,
11007 __attribute__((unused)) void *data)
11009 struct cmd_flow_director_result *res = parsed_result;
11010 struct rte_eth_fdir_filter entry;
11011 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
11013 unsigned long vf_id;
11016 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
11018 printf("flow director is not supported on port %u.\n",
11022 memset(flexbytes, 0, sizeof(flexbytes));
11023 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
11025 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
11026 if (strcmp(res->mode_value, "MAC-VLAN")) {
11027 printf("Please set mode to MAC-VLAN.\n");
11030 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11031 if (strcmp(res->mode_value, "Tunnel")) {
11032 printf("Please set mode to Tunnel.\n");
11036 if (!strcmp(res->mode_value, "raw")) {
11037 #ifdef RTE_LIBRTE_I40E_PMD
11038 struct rte_pmd_i40e_flow_type_mapping
11039 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
11040 struct rte_pmd_i40e_pkt_template_conf conf;
11041 uint16_t flow_type = str2flowtype(res->flow_type);
11042 uint16_t i, port = res->port_id;
11045 memset(&conf, 0, sizeof(conf));
11047 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
11048 printf("Invalid flow type specified.\n");
11051 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
11055 if (mapping[flow_type].pctype == 0ULL) {
11056 printf("Invalid flow type specified.\n");
11059 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
11060 if (mapping[flow_type].pctype & (1ULL << i)) {
11061 conf.input.pctype = i;
11066 conf.input.packet = open_file(res->filepath,
11067 &conf.input.length);
11068 if (!conf.input.packet)
11070 if (!strcmp(res->drop, "drop"))
11071 conf.action.behavior =
11072 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
11074 conf.action.behavior =
11075 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
11076 conf.action.report_status =
11077 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
11078 conf.action.rx_queue = res->queue_id;
11079 conf.soft_id = res->fd_id_value;
11080 add = strcmp(res->ops, "del") ? 1 : 0;
11081 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
11085 printf("flow director config error: (%s)\n",
11087 close_file(conf.input.packet);
11090 } else if (strcmp(res->mode_value, "IP")) {
11091 printf("Please set mode to IP or raw.\n");
11094 entry.input.flow_type = str2flowtype(res->flow_type);
11097 ret = parse_flexbytes(res->flexbytes_value,
11099 RTE_ETH_FDIR_MAX_FLEXLEN);
11101 printf("error: Cannot parse flexbytes input.\n");
11105 switch (entry.input.flow_type) {
11106 case RTE_ETH_FLOW_FRAG_IPV4:
11107 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
11108 entry.input.flow.ip4_flow.proto = res->proto_value;
11110 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
11111 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
11112 IPV4_ADDR_TO_UINT(res->ip_dst,
11113 entry.input.flow.ip4_flow.dst_ip);
11114 IPV4_ADDR_TO_UINT(res->ip_src,
11115 entry.input.flow.ip4_flow.src_ip);
11116 entry.input.flow.ip4_flow.tos = res->tos_value;
11117 entry.input.flow.ip4_flow.ttl = res->ttl_value;
11118 /* need convert to big endian. */
11119 entry.input.flow.udp4_flow.dst_port =
11120 rte_cpu_to_be_16(res->port_dst);
11121 entry.input.flow.udp4_flow.src_port =
11122 rte_cpu_to_be_16(res->port_src);
11124 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
11125 IPV4_ADDR_TO_UINT(res->ip_dst,
11126 entry.input.flow.sctp4_flow.ip.dst_ip);
11127 IPV4_ADDR_TO_UINT(res->ip_src,
11128 entry.input.flow.sctp4_flow.ip.src_ip);
11129 entry.input.flow.ip4_flow.tos = res->tos_value;
11130 entry.input.flow.ip4_flow.ttl = res->ttl_value;
11131 /* need convert to big endian. */
11132 entry.input.flow.sctp4_flow.dst_port =
11133 rte_cpu_to_be_16(res->port_dst);
11134 entry.input.flow.sctp4_flow.src_port =
11135 rte_cpu_to_be_16(res->port_src);
11136 entry.input.flow.sctp4_flow.verify_tag =
11137 rte_cpu_to_be_32(res->verify_tag_value);
11139 case RTE_ETH_FLOW_FRAG_IPV6:
11140 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
11141 entry.input.flow.ipv6_flow.proto = res->proto_value;
11143 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
11144 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
11145 IPV6_ADDR_TO_ARRAY(res->ip_dst,
11146 entry.input.flow.ipv6_flow.dst_ip);
11147 IPV6_ADDR_TO_ARRAY(res->ip_src,
11148 entry.input.flow.ipv6_flow.src_ip);
11149 entry.input.flow.ipv6_flow.tc = res->tos_value;
11150 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
11151 /* need convert to big endian. */
11152 entry.input.flow.udp6_flow.dst_port =
11153 rte_cpu_to_be_16(res->port_dst);
11154 entry.input.flow.udp6_flow.src_port =
11155 rte_cpu_to_be_16(res->port_src);
11157 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
11158 IPV6_ADDR_TO_ARRAY(res->ip_dst,
11159 entry.input.flow.sctp6_flow.ip.dst_ip);
11160 IPV6_ADDR_TO_ARRAY(res->ip_src,
11161 entry.input.flow.sctp6_flow.ip.src_ip);
11162 entry.input.flow.ipv6_flow.tc = res->tos_value;
11163 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
11164 /* need convert to big endian. */
11165 entry.input.flow.sctp6_flow.dst_port =
11166 rte_cpu_to_be_16(res->port_dst);
11167 entry.input.flow.sctp6_flow.src_port =
11168 rte_cpu_to_be_16(res->port_src);
11169 entry.input.flow.sctp6_flow.verify_tag =
11170 rte_cpu_to_be_32(res->verify_tag_value);
11172 case RTE_ETH_FLOW_L2_PAYLOAD:
11173 entry.input.flow.l2_flow.ether_type =
11174 rte_cpu_to_be_16(res->ether_type);
11180 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
11181 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
11183 sizeof(struct rte_ether_addr));
11185 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11186 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
11188 sizeof(struct rte_ether_addr));
11189 entry.input.flow.tunnel_flow.tunnel_type =
11190 str2fdir_tunneltype(res->tunnel_type);
11191 entry.input.flow.tunnel_flow.tunnel_id =
11192 rte_cpu_to_be_32(res->tunnel_id_value);
11195 rte_memcpy(entry.input.flow_ext.flexbytes,
11197 RTE_ETH_FDIR_MAX_FLEXLEN);
11199 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
11201 entry.action.flex_off = 0; /*use 0 by default */
11202 if (!strcmp(res->drop, "drop"))
11203 entry.action.behavior = RTE_ETH_FDIR_REJECT;
11205 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
11207 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
11208 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
11209 if (!strcmp(res->pf_vf, "pf"))
11210 entry.input.flow_ext.is_vf = 0;
11211 else if (!strncmp(res->pf_vf, "vf", 2)) {
11212 struct rte_eth_dev_info dev_info;
11214 ret = eth_dev_info_get_print_err(res->port_id,
11220 vf_id = strtoul(res->pf_vf + 2, &end, 10);
11221 if (errno != 0 || *end != '\0' ||
11222 vf_id >= dev_info.max_vfs) {
11223 printf("invalid parameter %s.\n", res->pf_vf);
11226 entry.input.flow_ext.is_vf = 1;
11227 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
11229 printf("invalid parameter %s.\n", res->pf_vf);
11234 /* set to report FD ID by default */
11235 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
11236 entry.action.rx_queue = res->queue_id;
11237 entry.soft_id = res->fd_id_value;
11238 if (!strcmp(res->ops, "add"))
11239 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11240 RTE_ETH_FILTER_ADD, &entry);
11241 else if (!strcmp(res->ops, "del"))
11242 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11243 RTE_ETH_FILTER_DELETE, &entry);
11245 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11246 RTE_ETH_FILTER_UPDATE, &entry);
11248 printf("flow director programming error: (%s)\n",
11252 cmdline_parse_token_string_t cmd_flow_director_filter =
11253 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11254 flow_director_filter, "flow_director_filter");
11255 cmdline_parse_token_num_t cmd_flow_director_port_id =
11256 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11258 cmdline_parse_token_string_t cmd_flow_director_ops =
11259 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11260 ops, "add#del#update");
11261 cmdline_parse_token_string_t cmd_flow_director_flow =
11262 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11264 cmdline_parse_token_string_t cmd_flow_director_flow_type =
11265 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11267 cmdline_parse_token_string_t cmd_flow_director_ether =
11268 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11270 cmdline_parse_token_num_t cmd_flow_director_ether_type =
11271 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11272 ether_type, UINT16);
11273 cmdline_parse_token_string_t cmd_flow_director_src =
11274 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11276 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
11277 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
11279 cmdline_parse_token_num_t cmd_flow_director_port_src =
11280 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11282 cmdline_parse_token_string_t cmd_flow_director_dst =
11283 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11285 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
11286 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
11288 cmdline_parse_token_num_t cmd_flow_director_port_dst =
11289 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11291 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
11292 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11293 verify_tag, "verify_tag");
11294 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
11295 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11296 verify_tag_value, UINT32);
11297 cmdline_parse_token_string_t cmd_flow_director_tos =
11298 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11300 cmdline_parse_token_num_t cmd_flow_director_tos_value =
11301 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11303 cmdline_parse_token_string_t cmd_flow_director_proto =
11304 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11306 cmdline_parse_token_num_t cmd_flow_director_proto_value =
11307 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11308 proto_value, UINT8);
11309 cmdline_parse_token_string_t cmd_flow_director_ttl =
11310 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11312 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
11313 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11315 cmdline_parse_token_string_t cmd_flow_director_vlan =
11316 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11318 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
11319 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11320 vlan_value, UINT16);
11321 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
11322 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11323 flexbytes, "flexbytes");
11324 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
11325 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11326 flexbytes_value, NULL);
11327 cmdline_parse_token_string_t cmd_flow_director_drop =
11328 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11330 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
11331 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11333 cmdline_parse_token_string_t cmd_flow_director_queue =
11334 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11336 cmdline_parse_token_num_t cmd_flow_director_queue_id =
11337 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11339 cmdline_parse_token_string_t cmd_flow_director_fd_id =
11340 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11342 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
11343 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11344 fd_id_value, UINT32);
11346 cmdline_parse_token_string_t cmd_flow_director_mode =
11347 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11349 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
11350 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11352 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
11353 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11354 mode_value, "MAC-VLAN");
11355 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
11356 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11357 mode_value, "Tunnel");
11358 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
11359 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11360 mode_value, "raw");
11361 cmdline_parse_token_string_t cmd_flow_director_mac =
11362 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11364 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
11365 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
11367 cmdline_parse_token_string_t cmd_flow_director_tunnel =
11368 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11370 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
11371 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11372 tunnel_type, "NVGRE#VxLAN");
11373 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
11374 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11375 tunnel_id, "tunnel-id");
11376 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
11377 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11378 tunnel_id_value, UINT32);
11379 cmdline_parse_token_string_t cmd_flow_director_packet =
11380 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11382 cmdline_parse_token_string_t cmd_flow_director_filepath =
11383 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11386 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
11387 .f = cmd_flow_director_filter_parsed,
11389 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
11390 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
11391 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
11392 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
11393 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
11394 "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> "
11395 "fd_id <fd_id_value>: "
11396 "Add or delete an ip flow director entry on NIC",
11398 (void *)&cmd_flow_director_filter,
11399 (void *)&cmd_flow_director_port_id,
11400 (void *)&cmd_flow_director_mode,
11401 (void *)&cmd_flow_director_mode_ip,
11402 (void *)&cmd_flow_director_ops,
11403 (void *)&cmd_flow_director_flow,
11404 (void *)&cmd_flow_director_flow_type,
11405 (void *)&cmd_flow_director_src,
11406 (void *)&cmd_flow_director_ip_src,
11407 (void *)&cmd_flow_director_dst,
11408 (void *)&cmd_flow_director_ip_dst,
11409 (void *)&cmd_flow_director_tos,
11410 (void *)&cmd_flow_director_tos_value,
11411 (void *)&cmd_flow_director_proto,
11412 (void *)&cmd_flow_director_proto_value,
11413 (void *)&cmd_flow_director_ttl,
11414 (void *)&cmd_flow_director_ttl_value,
11415 (void *)&cmd_flow_director_vlan,
11416 (void *)&cmd_flow_director_vlan_value,
11417 (void *)&cmd_flow_director_flexbytes,
11418 (void *)&cmd_flow_director_flexbytes_value,
11419 (void *)&cmd_flow_director_drop,
11420 (void *)&cmd_flow_director_pf_vf,
11421 (void *)&cmd_flow_director_queue,
11422 (void *)&cmd_flow_director_queue_id,
11423 (void *)&cmd_flow_director_fd_id,
11424 (void *)&cmd_flow_director_fd_id_value,
11429 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
11430 .f = cmd_flow_director_filter_parsed,
11432 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
11433 "director entry on NIC",
11435 (void *)&cmd_flow_director_filter,
11436 (void *)&cmd_flow_director_port_id,
11437 (void *)&cmd_flow_director_mode,
11438 (void *)&cmd_flow_director_mode_ip,
11439 (void *)&cmd_flow_director_ops,
11440 (void *)&cmd_flow_director_flow,
11441 (void *)&cmd_flow_director_flow_type,
11442 (void *)&cmd_flow_director_src,
11443 (void *)&cmd_flow_director_ip_src,
11444 (void *)&cmd_flow_director_port_src,
11445 (void *)&cmd_flow_director_dst,
11446 (void *)&cmd_flow_director_ip_dst,
11447 (void *)&cmd_flow_director_port_dst,
11448 (void *)&cmd_flow_director_tos,
11449 (void *)&cmd_flow_director_tos_value,
11450 (void *)&cmd_flow_director_ttl,
11451 (void *)&cmd_flow_director_ttl_value,
11452 (void *)&cmd_flow_director_vlan,
11453 (void *)&cmd_flow_director_vlan_value,
11454 (void *)&cmd_flow_director_flexbytes,
11455 (void *)&cmd_flow_director_flexbytes_value,
11456 (void *)&cmd_flow_director_drop,
11457 (void *)&cmd_flow_director_pf_vf,
11458 (void *)&cmd_flow_director_queue,
11459 (void *)&cmd_flow_director_queue_id,
11460 (void *)&cmd_flow_director_fd_id,
11461 (void *)&cmd_flow_director_fd_id_value,
11466 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
11467 .f = cmd_flow_director_filter_parsed,
11469 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
11470 "director entry on NIC",
11472 (void *)&cmd_flow_director_filter,
11473 (void *)&cmd_flow_director_port_id,
11474 (void *)&cmd_flow_director_mode,
11475 (void *)&cmd_flow_director_mode_ip,
11476 (void *)&cmd_flow_director_ops,
11477 (void *)&cmd_flow_director_flow,
11478 (void *)&cmd_flow_director_flow_type,
11479 (void *)&cmd_flow_director_src,
11480 (void *)&cmd_flow_director_ip_src,
11481 (void *)&cmd_flow_director_port_src,
11482 (void *)&cmd_flow_director_dst,
11483 (void *)&cmd_flow_director_ip_dst,
11484 (void *)&cmd_flow_director_port_dst,
11485 (void *)&cmd_flow_director_verify_tag,
11486 (void *)&cmd_flow_director_verify_tag_value,
11487 (void *)&cmd_flow_director_tos,
11488 (void *)&cmd_flow_director_tos_value,
11489 (void *)&cmd_flow_director_ttl,
11490 (void *)&cmd_flow_director_ttl_value,
11491 (void *)&cmd_flow_director_vlan,
11492 (void *)&cmd_flow_director_vlan_value,
11493 (void *)&cmd_flow_director_flexbytes,
11494 (void *)&cmd_flow_director_flexbytes_value,
11495 (void *)&cmd_flow_director_drop,
11496 (void *)&cmd_flow_director_pf_vf,
11497 (void *)&cmd_flow_director_queue,
11498 (void *)&cmd_flow_director_queue_id,
11499 (void *)&cmd_flow_director_fd_id,
11500 (void *)&cmd_flow_director_fd_id_value,
11505 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
11506 .f = cmd_flow_director_filter_parsed,
11508 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
11509 "director entry on NIC",
11511 (void *)&cmd_flow_director_filter,
11512 (void *)&cmd_flow_director_port_id,
11513 (void *)&cmd_flow_director_mode,
11514 (void *)&cmd_flow_director_mode_ip,
11515 (void *)&cmd_flow_director_ops,
11516 (void *)&cmd_flow_director_flow,
11517 (void *)&cmd_flow_director_flow_type,
11518 (void *)&cmd_flow_director_ether,
11519 (void *)&cmd_flow_director_ether_type,
11520 (void *)&cmd_flow_director_flexbytes,
11521 (void *)&cmd_flow_director_flexbytes_value,
11522 (void *)&cmd_flow_director_drop,
11523 (void *)&cmd_flow_director_pf_vf,
11524 (void *)&cmd_flow_director_queue,
11525 (void *)&cmd_flow_director_queue_id,
11526 (void *)&cmd_flow_director_fd_id,
11527 (void *)&cmd_flow_director_fd_id_value,
11532 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
11533 .f = cmd_flow_director_filter_parsed,
11535 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
11536 "director entry on NIC",
11538 (void *)&cmd_flow_director_filter,
11539 (void *)&cmd_flow_director_port_id,
11540 (void *)&cmd_flow_director_mode,
11541 (void *)&cmd_flow_director_mode_mac_vlan,
11542 (void *)&cmd_flow_director_ops,
11543 (void *)&cmd_flow_director_mac,
11544 (void *)&cmd_flow_director_mac_addr,
11545 (void *)&cmd_flow_director_vlan,
11546 (void *)&cmd_flow_director_vlan_value,
11547 (void *)&cmd_flow_director_flexbytes,
11548 (void *)&cmd_flow_director_flexbytes_value,
11549 (void *)&cmd_flow_director_drop,
11550 (void *)&cmd_flow_director_queue,
11551 (void *)&cmd_flow_director_queue_id,
11552 (void *)&cmd_flow_director_fd_id,
11553 (void *)&cmd_flow_director_fd_id_value,
11558 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
11559 .f = cmd_flow_director_filter_parsed,
11561 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
11562 "director entry on NIC",
11564 (void *)&cmd_flow_director_filter,
11565 (void *)&cmd_flow_director_port_id,
11566 (void *)&cmd_flow_director_mode,
11567 (void *)&cmd_flow_director_mode_tunnel,
11568 (void *)&cmd_flow_director_ops,
11569 (void *)&cmd_flow_director_mac,
11570 (void *)&cmd_flow_director_mac_addr,
11571 (void *)&cmd_flow_director_vlan,
11572 (void *)&cmd_flow_director_vlan_value,
11573 (void *)&cmd_flow_director_tunnel,
11574 (void *)&cmd_flow_director_tunnel_type,
11575 (void *)&cmd_flow_director_tunnel_id,
11576 (void *)&cmd_flow_director_tunnel_id_value,
11577 (void *)&cmd_flow_director_flexbytes,
11578 (void *)&cmd_flow_director_flexbytes_value,
11579 (void *)&cmd_flow_director_drop,
11580 (void *)&cmd_flow_director_queue,
11581 (void *)&cmd_flow_director_queue_id,
11582 (void *)&cmd_flow_director_fd_id,
11583 (void *)&cmd_flow_director_fd_id_value,
11588 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
11589 .f = cmd_flow_director_filter_parsed,
11591 .help_str = "flow_director_filter ... : Add or delete a raw flow "
11592 "director entry on NIC",
11594 (void *)&cmd_flow_director_filter,
11595 (void *)&cmd_flow_director_port_id,
11596 (void *)&cmd_flow_director_mode,
11597 (void *)&cmd_flow_director_mode_raw,
11598 (void *)&cmd_flow_director_ops,
11599 (void *)&cmd_flow_director_flow,
11600 (void *)&cmd_flow_director_flow_type,
11601 (void *)&cmd_flow_director_drop,
11602 (void *)&cmd_flow_director_queue,
11603 (void *)&cmd_flow_director_queue_id,
11604 (void *)&cmd_flow_director_fd_id,
11605 (void *)&cmd_flow_director_fd_id_value,
11606 (void *)&cmd_flow_director_packet,
11607 (void *)&cmd_flow_director_filepath,
11612 struct cmd_flush_flow_director_result {
11613 cmdline_fixed_string_t flush_flow_director;
11617 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
11618 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
11619 flush_flow_director, "flush_flow_director");
11620 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
11621 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
11625 cmd_flush_flow_director_parsed(void *parsed_result,
11626 __attribute__((unused)) struct cmdline *cl,
11627 __attribute__((unused)) void *data)
11629 struct cmd_flow_director_result *res = parsed_result;
11632 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
11634 printf("flow director is not supported on port %u.\n",
11639 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11640 RTE_ETH_FILTER_FLUSH, NULL);
11642 printf("flow director table flushing error: (%s)\n",
11646 cmdline_parse_inst_t cmd_flush_flow_director = {
11647 .f = cmd_flush_flow_director_parsed,
11649 .help_str = "flush_flow_director <port_id>: "
11650 "Flush all flow director entries of a device on NIC",
11652 (void *)&cmd_flush_flow_director_flush,
11653 (void *)&cmd_flush_flow_director_port_id,
11658 /* *** deal with flow director mask *** */
11659 struct cmd_flow_director_mask_result {
11660 cmdline_fixed_string_t flow_director_mask;
11662 cmdline_fixed_string_t mode;
11663 cmdline_fixed_string_t mode_value;
11664 cmdline_fixed_string_t vlan;
11665 uint16_t vlan_mask;
11666 cmdline_fixed_string_t src_mask;
11667 cmdline_ipaddr_t ipv4_src;
11668 cmdline_ipaddr_t ipv6_src;
11670 cmdline_fixed_string_t dst_mask;
11671 cmdline_ipaddr_t ipv4_dst;
11672 cmdline_ipaddr_t ipv6_dst;
11674 cmdline_fixed_string_t mac;
11675 uint8_t mac_addr_byte_mask;
11676 cmdline_fixed_string_t tunnel_id;
11677 uint32_t tunnel_id_mask;
11678 cmdline_fixed_string_t tunnel_type;
11679 uint8_t tunnel_type_mask;
11683 cmd_flow_director_mask_parsed(void *parsed_result,
11684 __attribute__((unused)) struct cmdline *cl,
11685 __attribute__((unused)) void *data)
11687 struct cmd_flow_director_mask_result *res = parsed_result;
11688 struct rte_eth_fdir_masks *mask;
11689 struct rte_port *port;
11691 port = &ports[res->port_id];
11692 /** Check if the port is not started **/
11693 if (port->port_status != RTE_PORT_STOPPED) {
11694 printf("Please stop port %d first\n", res->port_id);
11698 mask = &port->dev_conf.fdir_conf.mask;
11700 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
11701 if (strcmp(res->mode_value, "MAC-VLAN")) {
11702 printf("Please set mode to MAC-VLAN.\n");
11706 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11707 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11708 if (strcmp(res->mode_value, "Tunnel")) {
11709 printf("Please set mode to Tunnel.\n");
11713 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11714 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
11715 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
11716 mask->tunnel_type_mask = res->tunnel_type_mask;
11718 if (strcmp(res->mode_value, "IP")) {
11719 printf("Please set mode to IP.\n");
11723 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11724 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
11725 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
11726 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
11727 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
11728 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
11729 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
11732 cmd_reconfig_device_queue(res->port_id, 1, 1);
11735 cmdline_parse_token_string_t cmd_flow_director_mask =
11736 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11737 flow_director_mask, "flow_director_mask");
11738 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
11739 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11741 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
11742 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11744 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
11745 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11746 vlan_mask, UINT16);
11747 cmdline_parse_token_string_t cmd_flow_director_mask_src =
11748 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11749 src_mask, "src_mask");
11750 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
11751 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11753 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
11754 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11756 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
11757 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11759 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
11760 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11761 dst_mask, "dst_mask");
11762 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
11763 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11765 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
11766 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11768 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
11769 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11772 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
11773 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11775 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
11776 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11778 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
11779 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11780 mode_value, "MAC-VLAN");
11781 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
11782 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11783 mode_value, "Tunnel");
11784 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
11785 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11787 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
11788 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11789 mac_addr_byte_mask, UINT8);
11790 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
11791 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11792 tunnel_type, "tunnel-type");
11793 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
11794 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11795 tunnel_type_mask, UINT8);
11796 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
11797 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11798 tunnel_id, "tunnel-id");
11799 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
11800 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11801 tunnel_id_mask, UINT32);
11803 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
11804 .f = cmd_flow_director_mask_parsed,
11806 .help_str = "flow_director_mask ... : "
11807 "Set IP mode flow director's mask on NIC",
11809 (void *)&cmd_flow_director_mask,
11810 (void *)&cmd_flow_director_mask_port_id,
11811 (void *)&cmd_flow_director_mask_mode,
11812 (void *)&cmd_flow_director_mask_mode_ip,
11813 (void *)&cmd_flow_director_mask_vlan,
11814 (void *)&cmd_flow_director_mask_vlan_value,
11815 (void *)&cmd_flow_director_mask_src,
11816 (void *)&cmd_flow_director_mask_ipv4_src,
11817 (void *)&cmd_flow_director_mask_ipv6_src,
11818 (void *)&cmd_flow_director_mask_port_src,
11819 (void *)&cmd_flow_director_mask_dst,
11820 (void *)&cmd_flow_director_mask_ipv4_dst,
11821 (void *)&cmd_flow_director_mask_ipv6_dst,
11822 (void *)&cmd_flow_director_mask_port_dst,
11827 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
11828 .f = cmd_flow_director_mask_parsed,
11830 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
11831 "flow director's mask on NIC",
11833 (void *)&cmd_flow_director_mask,
11834 (void *)&cmd_flow_director_mask_port_id,
11835 (void *)&cmd_flow_director_mask_mode,
11836 (void *)&cmd_flow_director_mask_mode_mac_vlan,
11837 (void *)&cmd_flow_director_mask_vlan,
11838 (void *)&cmd_flow_director_mask_vlan_value,
11843 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
11844 .f = cmd_flow_director_mask_parsed,
11846 .help_str = "flow_director_mask ... : Set tunnel mode "
11847 "flow director's mask on NIC",
11849 (void *)&cmd_flow_director_mask,
11850 (void *)&cmd_flow_director_mask_port_id,
11851 (void *)&cmd_flow_director_mask_mode,
11852 (void *)&cmd_flow_director_mask_mode_tunnel,
11853 (void *)&cmd_flow_director_mask_vlan,
11854 (void *)&cmd_flow_director_mask_vlan_value,
11855 (void *)&cmd_flow_director_mask_mac,
11856 (void *)&cmd_flow_director_mask_mac_value,
11857 (void *)&cmd_flow_director_mask_tunnel_type,
11858 (void *)&cmd_flow_director_mask_tunnel_type_value,
11859 (void *)&cmd_flow_director_mask_tunnel_id,
11860 (void *)&cmd_flow_director_mask_tunnel_id_value,
11865 /* *** deal with flow director mask on flexible payload *** */
11866 struct cmd_flow_director_flex_mask_result {
11867 cmdline_fixed_string_t flow_director_flexmask;
11869 cmdline_fixed_string_t flow;
11870 cmdline_fixed_string_t flow_type;
11871 cmdline_fixed_string_t mask;
11875 cmd_flow_director_flex_mask_parsed(void *parsed_result,
11876 __attribute__((unused)) struct cmdline *cl,
11877 __attribute__((unused)) void *data)
11879 struct cmd_flow_director_flex_mask_result *res = parsed_result;
11880 struct rte_eth_fdir_info fdir_info;
11881 struct rte_eth_fdir_flex_mask flex_mask;
11882 struct rte_port *port;
11883 uint64_t flow_type_mask;
11887 port = &ports[res->port_id];
11888 /** Check if the port is not started **/
11889 if (port->port_status != RTE_PORT_STOPPED) {
11890 printf("Please stop port %d first\n", res->port_id);
11894 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
11895 ret = parse_flexbytes(res->mask,
11897 RTE_ETH_FDIR_MAX_FLEXLEN);
11899 printf("error: Cannot parse mask input.\n");
11903 memset(&fdir_info, 0, sizeof(fdir_info));
11904 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11905 RTE_ETH_FILTER_INFO, &fdir_info);
11907 printf("Cannot get FDir filter info\n");
11911 if (!strcmp(res->flow_type, "none")) {
11912 /* means don't specify the flow type */
11913 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
11914 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
11915 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
11916 0, sizeof(struct rte_eth_fdir_flex_mask));
11917 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
11918 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
11920 sizeof(struct rte_eth_fdir_flex_mask));
11921 cmd_reconfig_device_queue(res->port_id, 1, 1);
11924 flow_type_mask = fdir_info.flow_types_mask[0];
11925 if (!strcmp(res->flow_type, "all")) {
11926 if (!flow_type_mask) {
11927 printf("No flow type supported\n");
11930 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
11931 if (flow_type_mask & (1ULL << i)) {
11932 flex_mask.flow_type = i;
11933 fdir_set_flex_mask(res->port_id, &flex_mask);
11936 cmd_reconfig_device_queue(res->port_id, 1, 1);
11939 flex_mask.flow_type = str2flowtype(res->flow_type);
11940 if (!(flow_type_mask & (1ULL << flex_mask.flow_type))) {
11941 printf("Flow type %s not supported on port %d\n",
11942 res->flow_type, res->port_id);
11945 fdir_set_flex_mask(res->port_id, &flex_mask);
11946 cmd_reconfig_device_queue(res->port_id, 1, 1);
11949 cmdline_parse_token_string_t cmd_flow_director_flexmask =
11950 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11951 flow_director_flexmask,
11952 "flow_director_flex_mask");
11953 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
11954 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11956 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
11957 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11959 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
11960 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11961 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
11962 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
11963 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
11964 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11967 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
11968 .f = cmd_flow_director_flex_mask_parsed,
11970 .help_str = "flow_director_flex_mask ... : "
11971 "Set flow director's flex mask on NIC",
11973 (void *)&cmd_flow_director_flexmask,
11974 (void *)&cmd_flow_director_flexmask_port_id,
11975 (void *)&cmd_flow_director_flexmask_flow,
11976 (void *)&cmd_flow_director_flexmask_flow_type,
11977 (void *)&cmd_flow_director_flexmask_mask,
11982 /* *** deal with flow director flexible payload configuration *** */
11983 struct cmd_flow_director_flexpayload_result {
11984 cmdline_fixed_string_t flow_director_flexpayload;
11986 cmdline_fixed_string_t payload_layer;
11987 cmdline_fixed_string_t payload_cfg;
11991 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
11994 const char *p, *p0 = q_arg;
11996 unsigned long int_fld;
11997 char *str_fld[max_num];
12002 p = strchr(p0, '(');
12006 p0 = strchr(p, ')');
12011 if (size >= sizeof(s))
12014 snprintf(s, sizeof(s), "%.*s", size, p);
12015 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
12016 if (ret < 0 || ret > max_num)
12018 for (i = 0; i < ret; i++) {
12020 int_fld = strtoul(str_fld[i], &end, 0);
12021 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
12023 offsets[i] = (uint16_t)int_fld;
12029 cmd_flow_director_flxpld_parsed(void *parsed_result,
12030 __attribute__((unused)) struct cmdline *cl,
12031 __attribute__((unused)) void *data)
12033 struct cmd_flow_director_flexpayload_result *res = parsed_result;
12034 struct rte_eth_flex_payload_cfg flex_cfg;
12035 struct rte_port *port;
12038 port = &ports[res->port_id];
12039 /** Check if the port is not started **/
12040 if (port->port_status != RTE_PORT_STOPPED) {
12041 printf("Please stop port %d first\n", res->port_id);
12045 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
12047 if (!strcmp(res->payload_layer, "raw"))
12048 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
12049 else if (!strcmp(res->payload_layer, "l2"))
12050 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
12051 else if (!strcmp(res->payload_layer, "l3"))
12052 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
12053 else if (!strcmp(res->payload_layer, "l4"))
12054 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
12056 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
12057 RTE_ETH_FDIR_MAX_FLEXLEN);
12059 printf("error: Cannot parse flex payload input.\n");
12063 fdir_set_flex_payload(res->port_id, &flex_cfg);
12064 cmd_reconfig_device_queue(res->port_id, 1, 1);
12067 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
12068 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12069 flow_director_flexpayload,
12070 "flow_director_flex_payload");
12071 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
12072 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12074 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
12075 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12076 payload_layer, "raw#l2#l3#l4");
12077 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
12078 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12079 payload_cfg, NULL);
12081 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
12082 .f = cmd_flow_director_flxpld_parsed,
12084 .help_str = "flow_director_flexpayload ... : "
12085 "Set flow director's flex payload on NIC",
12087 (void *)&cmd_flow_director_flexpayload,
12088 (void *)&cmd_flow_director_flexpayload_port_id,
12089 (void *)&cmd_flow_director_flexpayload_payload_layer,
12090 (void *)&cmd_flow_director_flexpayload_payload_cfg,
12095 /* Generic flow interface command. */
12096 extern cmdline_parse_inst_t cmd_flow;
12098 /* *** Classification Filters Control *** */
12099 /* *** Get symmetric hash enable per port *** */
12100 struct cmd_get_sym_hash_ena_per_port_result {
12101 cmdline_fixed_string_t get_sym_hash_ena_per_port;
12106 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
12107 __rte_unused struct cmdline *cl,
12108 __rte_unused void *data)
12110 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
12111 struct rte_eth_hash_filter_info info;
12114 if (rte_eth_dev_filter_supported(res->port_id,
12115 RTE_ETH_FILTER_HASH) < 0) {
12116 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
12121 memset(&info, 0, sizeof(info));
12122 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
12123 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12124 RTE_ETH_FILTER_GET, &info);
12127 printf("Cannot get symmetric hash enable per port "
12128 "on port %u\n", res->port_id);
12132 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
12133 "enabled" : "disabled", res->port_id);
12136 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
12137 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
12138 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
12139 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
12140 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
12143 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
12144 .f = cmd_get_sym_hash_per_port_parsed,
12146 .help_str = "get_sym_hash_ena_per_port <port_id>",
12148 (void *)&cmd_get_sym_hash_ena_per_port_all,
12149 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
12154 /* *** Set symmetric hash enable per port *** */
12155 struct cmd_set_sym_hash_ena_per_port_result {
12156 cmdline_fixed_string_t set_sym_hash_ena_per_port;
12157 cmdline_fixed_string_t enable;
12162 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
12163 __rte_unused struct cmdline *cl,
12164 __rte_unused void *data)
12166 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
12167 struct rte_eth_hash_filter_info info;
12170 if (rte_eth_dev_filter_supported(res->port_id,
12171 RTE_ETH_FILTER_HASH) < 0) {
12172 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
12177 memset(&info, 0, sizeof(info));
12178 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
12179 if (!strcmp(res->enable, "enable"))
12180 info.info.enable = 1;
12181 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12182 RTE_ETH_FILTER_SET, &info);
12184 printf("Cannot set symmetric hash enable per port on "
12185 "port %u\n", res->port_id);
12188 printf("Symmetric hash has been set to %s on port %u\n",
12189 res->enable, res->port_id);
12192 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
12193 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12194 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
12195 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
12196 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12198 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
12199 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12200 enable, "enable#disable");
12202 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
12203 .f = cmd_set_sym_hash_per_port_parsed,
12205 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
12207 (void *)&cmd_set_sym_hash_ena_per_port_all,
12208 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
12209 (void *)&cmd_set_sym_hash_ena_per_port_enable,
12214 /* Get global config of hash function */
12215 struct cmd_get_hash_global_config_result {
12216 cmdline_fixed_string_t get_hash_global_config;
12221 flowtype_to_str(uint16_t ftype)
12227 } ftype_table[] = {
12228 {"ipv4", RTE_ETH_FLOW_IPV4},
12229 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
12230 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
12231 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
12232 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
12233 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
12234 {"ipv6", RTE_ETH_FLOW_IPV6},
12235 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
12236 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
12237 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
12238 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
12239 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
12240 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
12241 {"port", RTE_ETH_FLOW_PORT},
12242 {"vxlan", RTE_ETH_FLOW_VXLAN},
12243 {"geneve", RTE_ETH_FLOW_GENEVE},
12244 {"nvgre", RTE_ETH_FLOW_NVGRE},
12245 {"vxlan-gpe", RTE_ETH_FLOW_VXLAN_GPE},
12248 for (i = 0; i < RTE_DIM(ftype_table); i++) {
12249 if (ftype_table[i].ftype == ftype)
12250 return ftype_table[i].str;
12257 cmd_get_hash_global_config_parsed(void *parsed_result,
12258 __rte_unused struct cmdline *cl,
12259 __rte_unused void *data)
12261 struct cmd_get_hash_global_config_result *res = parsed_result;
12262 struct rte_eth_hash_filter_info info;
12263 uint32_t idx, offset;
12268 if (rte_eth_dev_filter_supported(res->port_id,
12269 RTE_ETH_FILTER_HASH) < 0) {
12270 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
12275 memset(&info, 0, sizeof(info));
12276 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
12277 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12278 RTE_ETH_FILTER_GET, &info);
12280 printf("Cannot get hash global configurations by port %d\n",
12285 switch (info.info.global_conf.hash_func) {
12286 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
12287 printf("Hash function is Toeplitz\n");
12289 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
12290 printf("Hash function is Simple XOR\n");
12292 case RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ:
12293 printf("Hash function is Symmetric Toeplitz\n");
12296 printf("Unknown hash function\n");
12300 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
12301 idx = i / UINT64_BIT;
12302 offset = i % UINT64_BIT;
12303 if (!(info.info.global_conf.valid_bit_mask[idx] &
12306 str = flowtype_to_str(i);
12309 printf("Symmetric hash is %s globally for flow type %s "
12311 ((info.info.global_conf.sym_hash_enable_mask[idx] &
12312 (1ULL << offset)) ? "enabled" : "disabled"), str,
12317 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
12318 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
12319 get_hash_global_config, "get_hash_global_config");
12320 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
12321 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
12324 cmdline_parse_inst_t cmd_get_hash_global_config = {
12325 .f = cmd_get_hash_global_config_parsed,
12327 .help_str = "get_hash_global_config <port_id>",
12329 (void *)&cmd_get_hash_global_config_all,
12330 (void *)&cmd_get_hash_global_config_port_id,
12335 /* Set global config of hash function */
12336 struct cmd_set_hash_global_config_result {
12337 cmdline_fixed_string_t set_hash_global_config;
12339 cmdline_fixed_string_t hash_func;
12340 cmdline_fixed_string_t flow_type;
12341 cmdline_fixed_string_t enable;
12345 cmd_set_hash_global_config_parsed(void *parsed_result,
12346 __rte_unused struct cmdline *cl,
12347 __rte_unused void *data)
12349 struct cmd_set_hash_global_config_result *res = parsed_result;
12350 struct rte_eth_hash_filter_info info;
12351 uint32_t ftype, idx, offset;
12354 if (rte_eth_dev_filter_supported(res->port_id,
12355 RTE_ETH_FILTER_HASH) < 0) {
12356 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
12360 memset(&info, 0, sizeof(info));
12361 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
12362 if (!strcmp(res->hash_func, "toeplitz"))
12363 info.info.global_conf.hash_func =
12364 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
12365 else if (!strcmp(res->hash_func, "simple_xor"))
12366 info.info.global_conf.hash_func =
12367 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
12368 else if (!strcmp(res->hash_func, "symmetric_toeplitz"))
12369 info.info.global_conf.hash_func =
12370 RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ;
12371 else if (!strcmp(res->hash_func, "default"))
12372 info.info.global_conf.hash_func =
12373 RTE_ETH_HASH_FUNCTION_DEFAULT;
12375 ftype = str2flowtype(res->flow_type);
12376 idx = ftype / UINT64_BIT;
12377 offset = ftype % UINT64_BIT;
12378 info.info.global_conf.valid_bit_mask[idx] |= (1ULL << offset);
12379 if (!strcmp(res->enable, "enable"))
12380 info.info.global_conf.sym_hash_enable_mask[idx] |=
12382 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12383 RTE_ETH_FILTER_SET, &info);
12385 printf("Cannot set global hash configurations by port %d\n",
12388 printf("Global hash configurations have been set "
12389 "successfully by port %d\n", res->port_id);
12392 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
12393 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12394 set_hash_global_config, "set_hash_global_config");
12395 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
12396 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
12398 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
12399 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12400 hash_func, "toeplitz#simple_xor#symmetric_toeplitz#default");
12401 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
12402 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12404 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
12405 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12406 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
12407 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12408 enable, "enable#disable");
12410 cmdline_parse_inst_t cmd_set_hash_global_config = {
12411 .f = cmd_set_hash_global_config_parsed,
12413 .help_str = "set_hash_global_config <port_id> "
12414 "toeplitz|simple_xor|symmetric_toeplitz|default "
12415 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12416 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
12417 "l2_payload enable|disable",
12419 (void *)&cmd_set_hash_global_config_all,
12420 (void *)&cmd_set_hash_global_config_port_id,
12421 (void *)&cmd_set_hash_global_config_hash_func,
12422 (void *)&cmd_set_hash_global_config_flow_type,
12423 (void *)&cmd_set_hash_global_config_enable,
12428 /* Set hash input set */
12429 struct cmd_set_hash_input_set_result {
12430 cmdline_fixed_string_t set_hash_input_set;
12432 cmdline_fixed_string_t flow_type;
12433 cmdline_fixed_string_t inset_field;
12434 cmdline_fixed_string_t select;
12437 static enum rte_eth_input_set_field
12438 str2inset(char *string)
12442 static const struct {
12444 enum rte_eth_input_set_field inset;
12445 } inset_table[] = {
12446 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
12447 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
12448 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
12449 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
12450 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
12451 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
12452 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
12453 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
12454 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
12455 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
12456 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
12457 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
12458 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
12459 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
12460 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
12461 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
12462 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
12463 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
12464 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
12465 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
12466 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
12467 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
12468 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
12469 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
12470 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
12471 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
12472 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
12473 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
12474 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
12475 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
12476 {"none", RTE_ETH_INPUT_SET_NONE},
12479 for (i = 0; i < RTE_DIM(inset_table); i++) {
12480 if (!strcmp(string, inset_table[i].str))
12481 return inset_table[i].inset;
12484 return RTE_ETH_INPUT_SET_UNKNOWN;
12488 cmd_set_hash_input_set_parsed(void *parsed_result,
12489 __rte_unused struct cmdline *cl,
12490 __rte_unused void *data)
12492 struct cmd_set_hash_input_set_result *res = parsed_result;
12493 struct rte_eth_hash_filter_info info;
12495 memset(&info, 0, sizeof(info));
12496 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
12497 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12498 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12499 info.info.input_set_conf.inset_size = 1;
12500 if (!strcmp(res->select, "select"))
12501 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12502 else if (!strcmp(res->select, "add"))
12503 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12504 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12505 RTE_ETH_FILTER_SET, &info);
12508 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
12509 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12510 set_hash_input_set, "set_hash_input_set");
12511 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
12512 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
12514 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
12515 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12517 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
12518 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12520 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12521 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
12522 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
12523 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
12524 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
12526 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
12527 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12528 select, "select#add");
12530 cmdline_parse_inst_t cmd_set_hash_input_set = {
12531 .f = cmd_set_hash_input_set_parsed,
12533 .help_str = "set_hash_input_set <port_id> "
12534 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12535 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
12536 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
12537 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
12538 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
12539 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
12540 "fld-7th|fld-8th|none select|add",
12542 (void *)&cmd_set_hash_input_set_cmd,
12543 (void *)&cmd_set_hash_input_set_port_id,
12544 (void *)&cmd_set_hash_input_set_flow_type,
12545 (void *)&cmd_set_hash_input_set_field,
12546 (void *)&cmd_set_hash_input_set_select,
12551 /* Set flow director input set */
12552 struct cmd_set_fdir_input_set_result {
12553 cmdline_fixed_string_t set_fdir_input_set;
12555 cmdline_fixed_string_t flow_type;
12556 cmdline_fixed_string_t inset_field;
12557 cmdline_fixed_string_t select;
12561 cmd_set_fdir_input_set_parsed(void *parsed_result,
12562 __rte_unused struct cmdline *cl,
12563 __rte_unused void *data)
12565 struct cmd_set_fdir_input_set_result *res = parsed_result;
12566 struct rte_eth_fdir_filter_info info;
12568 memset(&info, 0, sizeof(info));
12569 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
12570 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12571 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12572 info.info.input_set_conf.inset_size = 1;
12573 if (!strcmp(res->select, "select"))
12574 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12575 else if (!strcmp(res->select, "add"))
12576 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12577 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
12578 RTE_ETH_FILTER_SET, &info);
12581 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
12582 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12583 set_fdir_input_set, "set_fdir_input_set");
12584 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
12585 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
12587 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
12588 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12590 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
12591 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12592 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
12593 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12595 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12596 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
12597 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
12598 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
12599 "sctp-veri-tag#none");
12600 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
12601 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12602 select, "select#add");
12604 cmdline_parse_inst_t cmd_set_fdir_input_set = {
12605 .f = cmd_set_fdir_input_set_parsed,
12607 .help_str = "set_fdir_input_set <port_id> "
12608 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12609 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
12610 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
12611 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
12612 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
12613 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
12614 "sctp-veri-tag|none select|add",
12616 (void *)&cmd_set_fdir_input_set_cmd,
12617 (void *)&cmd_set_fdir_input_set_port_id,
12618 (void *)&cmd_set_fdir_input_set_flow_type,
12619 (void *)&cmd_set_fdir_input_set_field,
12620 (void *)&cmd_set_fdir_input_set_select,
12625 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
12626 struct cmd_mcast_addr_result {
12627 cmdline_fixed_string_t mcast_addr_cmd;
12628 cmdline_fixed_string_t what;
12630 struct rte_ether_addr mc_addr;
12633 static void cmd_mcast_addr_parsed(void *parsed_result,
12634 __attribute__((unused)) struct cmdline *cl,
12635 __attribute__((unused)) void *data)
12637 struct cmd_mcast_addr_result *res = parsed_result;
12639 if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
12640 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
12641 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
12642 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
12643 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
12646 if (strcmp(res->what, "add") == 0)
12647 mcast_addr_add(res->port_num, &res->mc_addr);
12649 mcast_addr_remove(res->port_num, &res->mc_addr);
12652 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
12653 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
12654 mcast_addr_cmd, "mcast_addr");
12655 cmdline_parse_token_string_t cmd_mcast_addr_what =
12656 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
12658 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
12659 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
12660 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
12661 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
12663 cmdline_parse_inst_t cmd_mcast_addr = {
12664 .f = cmd_mcast_addr_parsed,
12666 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
12667 "Add/Remove multicast MAC address on port_id",
12669 (void *)&cmd_mcast_addr_cmd,
12670 (void *)&cmd_mcast_addr_what,
12671 (void *)&cmd_mcast_addr_portnum,
12672 (void *)&cmd_mcast_addr_addr,
12677 /* l2 tunnel config
12678 * only support E-tag now.
12681 /* Ether type config */
12682 struct cmd_config_l2_tunnel_eth_type_result {
12683 cmdline_fixed_string_t port;
12684 cmdline_fixed_string_t config;
12685 cmdline_fixed_string_t all;
12687 cmdline_fixed_string_t l2_tunnel;
12688 cmdline_fixed_string_t l2_tunnel_type;
12689 cmdline_fixed_string_t eth_type;
12690 uint16_t eth_type_val;
12693 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
12694 TOKEN_STRING_INITIALIZER
12695 (struct cmd_config_l2_tunnel_eth_type_result,
12697 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
12698 TOKEN_STRING_INITIALIZER
12699 (struct cmd_config_l2_tunnel_eth_type_result,
12701 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
12702 TOKEN_STRING_INITIALIZER
12703 (struct cmd_config_l2_tunnel_eth_type_result,
12705 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
12706 TOKEN_NUM_INITIALIZER
12707 (struct cmd_config_l2_tunnel_eth_type_result,
12709 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
12710 TOKEN_STRING_INITIALIZER
12711 (struct cmd_config_l2_tunnel_eth_type_result,
12712 l2_tunnel, "l2-tunnel");
12713 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
12714 TOKEN_STRING_INITIALIZER
12715 (struct cmd_config_l2_tunnel_eth_type_result,
12716 l2_tunnel_type, "E-tag");
12717 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
12718 TOKEN_STRING_INITIALIZER
12719 (struct cmd_config_l2_tunnel_eth_type_result,
12720 eth_type, "ether-type");
12721 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
12722 TOKEN_NUM_INITIALIZER
12723 (struct cmd_config_l2_tunnel_eth_type_result,
12724 eth_type_val, UINT16);
12726 static enum rte_eth_tunnel_type
12727 str2fdir_l2_tunnel_type(char *string)
12731 static const struct {
12733 enum rte_eth_tunnel_type type;
12734 } l2_tunnel_type_str[] = {
12735 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
12738 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
12739 if (!strcmp(l2_tunnel_type_str[i].str, string))
12740 return l2_tunnel_type_str[i].type;
12742 return RTE_TUNNEL_TYPE_NONE;
12745 /* ether type config for all ports */
12747 cmd_config_l2_tunnel_eth_type_all_parsed
12748 (void *parsed_result,
12749 __attribute__((unused)) struct cmdline *cl,
12750 __attribute__((unused)) void *data)
12752 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
12753 struct rte_eth_l2_tunnel_conf entry;
12756 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12757 entry.ether_type = res->eth_type_val;
12759 RTE_ETH_FOREACH_DEV(pid) {
12760 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
12764 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
12765 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
12767 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
12769 (void *)&cmd_config_l2_tunnel_eth_type_port,
12770 (void *)&cmd_config_l2_tunnel_eth_type_config,
12771 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
12772 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12773 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12774 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12775 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12780 /* ether type config for a specific port */
12782 cmd_config_l2_tunnel_eth_type_specific_parsed(
12783 void *parsed_result,
12784 __attribute__((unused)) struct cmdline *cl,
12785 __attribute__((unused)) void *data)
12787 struct cmd_config_l2_tunnel_eth_type_result *res =
12789 struct rte_eth_l2_tunnel_conf entry;
12791 if (port_id_is_invalid(res->id, ENABLED_WARN))
12794 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12795 entry.ether_type = res->eth_type_val;
12797 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
12800 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
12801 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
12803 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
12805 (void *)&cmd_config_l2_tunnel_eth_type_port,
12806 (void *)&cmd_config_l2_tunnel_eth_type_config,
12807 (void *)&cmd_config_l2_tunnel_eth_type_id,
12808 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12809 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12810 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12811 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12816 /* Enable/disable l2 tunnel */
12817 struct cmd_config_l2_tunnel_en_dis_result {
12818 cmdline_fixed_string_t port;
12819 cmdline_fixed_string_t config;
12820 cmdline_fixed_string_t all;
12822 cmdline_fixed_string_t l2_tunnel;
12823 cmdline_fixed_string_t l2_tunnel_type;
12824 cmdline_fixed_string_t en_dis;
12827 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
12828 TOKEN_STRING_INITIALIZER
12829 (struct cmd_config_l2_tunnel_en_dis_result,
12831 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
12832 TOKEN_STRING_INITIALIZER
12833 (struct cmd_config_l2_tunnel_en_dis_result,
12835 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
12836 TOKEN_STRING_INITIALIZER
12837 (struct cmd_config_l2_tunnel_en_dis_result,
12839 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
12840 TOKEN_NUM_INITIALIZER
12841 (struct cmd_config_l2_tunnel_en_dis_result,
12843 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
12844 TOKEN_STRING_INITIALIZER
12845 (struct cmd_config_l2_tunnel_en_dis_result,
12846 l2_tunnel, "l2-tunnel");
12847 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
12848 TOKEN_STRING_INITIALIZER
12849 (struct cmd_config_l2_tunnel_en_dis_result,
12850 l2_tunnel_type, "E-tag");
12851 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
12852 TOKEN_STRING_INITIALIZER
12853 (struct cmd_config_l2_tunnel_en_dis_result,
12854 en_dis, "enable#disable");
12856 /* enable/disable l2 tunnel for all ports */
12858 cmd_config_l2_tunnel_en_dis_all_parsed(
12859 void *parsed_result,
12860 __attribute__((unused)) struct cmdline *cl,
12861 __attribute__((unused)) void *data)
12863 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
12864 struct rte_eth_l2_tunnel_conf entry;
12868 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12870 if (!strcmp("enable", res->en_dis))
12875 RTE_ETH_FOREACH_DEV(pid) {
12876 rte_eth_dev_l2_tunnel_offload_set(pid,
12878 ETH_L2_TUNNEL_ENABLE_MASK,
12883 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
12884 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
12886 .help_str = "port config all l2-tunnel E-tag enable|disable",
12888 (void *)&cmd_config_l2_tunnel_en_dis_port,
12889 (void *)&cmd_config_l2_tunnel_en_dis_config,
12890 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
12891 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12892 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12893 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12898 /* enable/disable l2 tunnel for a port */
12900 cmd_config_l2_tunnel_en_dis_specific_parsed(
12901 void *parsed_result,
12902 __attribute__((unused)) struct cmdline *cl,
12903 __attribute__((unused)) void *data)
12905 struct cmd_config_l2_tunnel_en_dis_result *res =
12907 struct rte_eth_l2_tunnel_conf entry;
12909 if (port_id_is_invalid(res->id, ENABLED_WARN))
12912 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12914 if (!strcmp("enable", res->en_dis))
12915 rte_eth_dev_l2_tunnel_offload_set(res->id,
12917 ETH_L2_TUNNEL_ENABLE_MASK,
12920 rte_eth_dev_l2_tunnel_offload_set(res->id,
12922 ETH_L2_TUNNEL_ENABLE_MASK,
12926 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
12927 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
12929 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
12931 (void *)&cmd_config_l2_tunnel_en_dis_port,
12932 (void *)&cmd_config_l2_tunnel_en_dis_config,
12933 (void *)&cmd_config_l2_tunnel_en_dis_id,
12934 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12935 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12936 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12941 /* E-tag configuration */
12943 /* Common result structure for all E-tag configuration */
12944 struct cmd_config_e_tag_result {
12945 cmdline_fixed_string_t e_tag;
12946 cmdline_fixed_string_t set;
12947 cmdline_fixed_string_t insertion;
12948 cmdline_fixed_string_t stripping;
12949 cmdline_fixed_string_t forwarding;
12950 cmdline_fixed_string_t filter;
12951 cmdline_fixed_string_t add;
12952 cmdline_fixed_string_t del;
12953 cmdline_fixed_string_t on;
12954 cmdline_fixed_string_t off;
12955 cmdline_fixed_string_t on_off;
12956 cmdline_fixed_string_t port_tag_id;
12957 uint32_t port_tag_id_val;
12958 cmdline_fixed_string_t e_tag_id;
12959 uint16_t e_tag_id_val;
12960 cmdline_fixed_string_t dst_pool;
12961 uint8_t dst_pool_val;
12962 cmdline_fixed_string_t port;
12964 cmdline_fixed_string_t vf;
12968 /* Common CLI fields for all E-tag configuration */
12969 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
12970 TOKEN_STRING_INITIALIZER
12971 (struct cmd_config_e_tag_result,
12973 cmdline_parse_token_string_t cmd_config_e_tag_set =
12974 TOKEN_STRING_INITIALIZER
12975 (struct cmd_config_e_tag_result,
12977 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
12978 TOKEN_STRING_INITIALIZER
12979 (struct cmd_config_e_tag_result,
12980 insertion, "insertion");
12981 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
12982 TOKEN_STRING_INITIALIZER
12983 (struct cmd_config_e_tag_result,
12984 stripping, "stripping");
12985 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
12986 TOKEN_STRING_INITIALIZER
12987 (struct cmd_config_e_tag_result,
12988 forwarding, "forwarding");
12989 cmdline_parse_token_string_t cmd_config_e_tag_filter =
12990 TOKEN_STRING_INITIALIZER
12991 (struct cmd_config_e_tag_result,
12993 cmdline_parse_token_string_t cmd_config_e_tag_add =
12994 TOKEN_STRING_INITIALIZER
12995 (struct cmd_config_e_tag_result,
12997 cmdline_parse_token_string_t cmd_config_e_tag_del =
12998 TOKEN_STRING_INITIALIZER
12999 (struct cmd_config_e_tag_result,
13001 cmdline_parse_token_string_t cmd_config_e_tag_on =
13002 TOKEN_STRING_INITIALIZER
13003 (struct cmd_config_e_tag_result,
13005 cmdline_parse_token_string_t cmd_config_e_tag_off =
13006 TOKEN_STRING_INITIALIZER
13007 (struct cmd_config_e_tag_result,
13009 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
13010 TOKEN_STRING_INITIALIZER
13011 (struct cmd_config_e_tag_result,
13013 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
13014 TOKEN_STRING_INITIALIZER
13015 (struct cmd_config_e_tag_result,
13016 port_tag_id, "port-tag-id");
13017 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
13018 TOKEN_NUM_INITIALIZER
13019 (struct cmd_config_e_tag_result,
13020 port_tag_id_val, UINT32);
13021 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
13022 TOKEN_STRING_INITIALIZER
13023 (struct cmd_config_e_tag_result,
13024 e_tag_id, "e-tag-id");
13025 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
13026 TOKEN_NUM_INITIALIZER
13027 (struct cmd_config_e_tag_result,
13028 e_tag_id_val, UINT16);
13029 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
13030 TOKEN_STRING_INITIALIZER
13031 (struct cmd_config_e_tag_result,
13032 dst_pool, "dst-pool");
13033 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
13034 TOKEN_NUM_INITIALIZER
13035 (struct cmd_config_e_tag_result,
13036 dst_pool_val, UINT8);
13037 cmdline_parse_token_string_t cmd_config_e_tag_port =
13038 TOKEN_STRING_INITIALIZER
13039 (struct cmd_config_e_tag_result,
13041 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
13042 TOKEN_NUM_INITIALIZER
13043 (struct cmd_config_e_tag_result,
13045 cmdline_parse_token_string_t cmd_config_e_tag_vf =
13046 TOKEN_STRING_INITIALIZER
13047 (struct cmd_config_e_tag_result,
13049 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
13050 TOKEN_NUM_INITIALIZER
13051 (struct cmd_config_e_tag_result,
13054 /* E-tag insertion configuration */
13056 cmd_config_e_tag_insertion_en_parsed(
13057 void *parsed_result,
13058 __attribute__((unused)) struct cmdline *cl,
13059 __attribute__((unused)) void *data)
13061 struct cmd_config_e_tag_result *res =
13063 struct rte_eth_l2_tunnel_conf entry;
13065 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13068 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13069 entry.tunnel_id = res->port_tag_id_val;
13070 entry.vf_id = res->vf_id;
13071 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
13073 ETH_L2_TUNNEL_INSERTION_MASK,
13078 cmd_config_e_tag_insertion_dis_parsed(
13079 void *parsed_result,
13080 __attribute__((unused)) struct cmdline *cl,
13081 __attribute__((unused)) void *data)
13083 struct cmd_config_e_tag_result *res =
13085 struct rte_eth_l2_tunnel_conf entry;
13087 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13090 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13091 entry.vf_id = res->vf_id;
13093 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
13095 ETH_L2_TUNNEL_INSERTION_MASK,
13099 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
13100 .f = cmd_config_e_tag_insertion_en_parsed,
13102 .help_str = "E-tag ... : E-tag insertion enable",
13104 (void *)&cmd_config_e_tag_e_tag,
13105 (void *)&cmd_config_e_tag_set,
13106 (void *)&cmd_config_e_tag_insertion,
13107 (void *)&cmd_config_e_tag_on,
13108 (void *)&cmd_config_e_tag_port_tag_id,
13109 (void *)&cmd_config_e_tag_port_tag_id_val,
13110 (void *)&cmd_config_e_tag_port,
13111 (void *)&cmd_config_e_tag_port_id,
13112 (void *)&cmd_config_e_tag_vf,
13113 (void *)&cmd_config_e_tag_vf_id,
13118 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
13119 .f = cmd_config_e_tag_insertion_dis_parsed,
13121 .help_str = "E-tag ... : E-tag insertion disable",
13123 (void *)&cmd_config_e_tag_e_tag,
13124 (void *)&cmd_config_e_tag_set,
13125 (void *)&cmd_config_e_tag_insertion,
13126 (void *)&cmd_config_e_tag_off,
13127 (void *)&cmd_config_e_tag_port,
13128 (void *)&cmd_config_e_tag_port_id,
13129 (void *)&cmd_config_e_tag_vf,
13130 (void *)&cmd_config_e_tag_vf_id,
13135 /* E-tag stripping configuration */
13137 cmd_config_e_tag_stripping_parsed(
13138 void *parsed_result,
13139 __attribute__((unused)) struct cmdline *cl,
13140 __attribute__((unused)) void *data)
13142 struct cmd_config_e_tag_result *res =
13144 struct rte_eth_l2_tunnel_conf entry;
13146 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13149 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13151 if (!strcmp(res->on_off, "on"))
13152 rte_eth_dev_l2_tunnel_offload_set
13155 ETH_L2_TUNNEL_STRIPPING_MASK,
13158 rte_eth_dev_l2_tunnel_offload_set
13161 ETH_L2_TUNNEL_STRIPPING_MASK,
13165 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
13166 .f = cmd_config_e_tag_stripping_parsed,
13168 .help_str = "E-tag ... : E-tag stripping enable/disable",
13170 (void *)&cmd_config_e_tag_e_tag,
13171 (void *)&cmd_config_e_tag_set,
13172 (void *)&cmd_config_e_tag_stripping,
13173 (void *)&cmd_config_e_tag_on_off,
13174 (void *)&cmd_config_e_tag_port,
13175 (void *)&cmd_config_e_tag_port_id,
13180 /* E-tag forwarding configuration */
13182 cmd_config_e_tag_forwarding_parsed(
13183 void *parsed_result,
13184 __attribute__((unused)) struct cmdline *cl,
13185 __attribute__((unused)) void *data)
13187 struct cmd_config_e_tag_result *res = parsed_result;
13188 struct rte_eth_l2_tunnel_conf entry;
13190 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13193 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13195 if (!strcmp(res->on_off, "on"))
13196 rte_eth_dev_l2_tunnel_offload_set
13199 ETH_L2_TUNNEL_FORWARDING_MASK,
13202 rte_eth_dev_l2_tunnel_offload_set
13205 ETH_L2_TUNNEL_FORWARDING_MASK,
13209 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
13210 .f = cmd_config_e_tag_forwarding_parsed,
13212 .help_str = "E-tag ... : E-tag forwarding enable/disable",
13214 (void *)&cmd_config_e_tag_e_tag,
13215 (void *)&cmd_config_e_tag_set,
13216 (void *)&cmd_config_e_tag_forwarding,
13217 (void *)&cmd_config_e_tag_on_off,
13218 (void *)&cmd_config_e_tag_port,
13219 (void *)&cmd_config_e_tag_port_id,
13224 /* E-tag filter configuration */
13226 cmd_config_e_tag_filter_add_parsed(
13227 void *parsed_result,
13228 __attribute__((unused)) struct cmdline *cl,
13229 __attribute__((unused)) void *data)
13231 struct cmd_config_e_tag_result *res = parsed_result;
13232 struct rte_eth_l2_tunnel_conf entry;
13235 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13238 if (res->e_tag_id_val > 0x3fff) {
13239 printf("e-tag-id must be equal or less than 0x3fff.\n");
13243 ret = rte_eth_dev_filter_supported(res->port_id,
13244 RTE_ETH_FILTER_L2_TUNNEL);
13246 printf("E-tag filter is not supported on port %u.\n",
13251 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13252 entry.tunnel_id = res->e_tag_id_val;
13253 entry.pool = res->dst_pool_val;
13255 ret = rte_eth_dev_filter_ctrl(res->port_id,
13256 RTE_ETH_FILTER_L2_TUNNEL,
13257 RTE_ETH_FILTER_ADD,
13260 printf("E-tag filter programming error: (%s)\n",
13264 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
13265 .f = cmd_config_e_tag_filter_add_parsed,
13267 .help_str = "E-tag ... : E-tag filter add",
13269 (void *)&cmd_config_e_tag_e_tag,
13270 (void *)&cmd_config_e_tag_set,
13271 (void *)&cmd_config_e_tag_filter,
13272 (void *)&cmd_config_e_tag_add,
13273 (void *)&cmd_config_e_tag_e_tag_id,
13274 (void *)&cmd_config_e_tag_e_tag_id_val,
13275 (void *)&cmd_config_e_tag_dst_pool,
13276 (void *)&cmd_config_e_tag_dst_pool_val,
13277 (void *)&cmd_config_e_tag_port,
13278 (void *)&cmd_config_e_tag_port_id,
13284 cmd_config_e_tag_filter_del_parsed(
13285 void *parsed_result,
13286 __attribute__((unused)) struct cmdline *cl,
13287 __attribute__((unused)) void *data)
13289 struct cmd_config_e_tag_result *res = parsed_result;
13290 struct rte_eth_l2_tunnel_conf entry;
13293 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13296 if (res->e_tag_id_val > 0x3fff) {
13297 printf("e-tag-id must be less than 0x3fff.\n");
13301 ret = rte_eth_dev_filter_supported(res->port_id,
13302 RTE_ETH_FILTER_L2_TUNNEL);
13304 printf("E-tag filter is not supported on port %u.\n",
13309 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13310 entry.tunnel_id = res->e_tag_id_val;
13312 ret = rte_eth_dev_filter_ctrl(res->port_id,
13313 RTE_ETH_FILTER_L2_TUNNEL,
13314 RTE_ETH_FILTER_DELETE,
13317 printf("E-tag filter programming error: (%s)\n",
13321 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
13322 .f = cmd_config_e_tag_filter_del_parsed,
13324 .help_str = "E-tag ... : E-tag filter delete",
13326 (void *)&cmd_config_e_tag_e_tag,
13327 (void *)&cmd_config_e_tag_set,
13328 (void *)&cmd_config_e_tag_filter,
13329 (void *)&cmd_config_e_tag_del,
13330 (void *)&cmd_config_e_tag_e_tag_id,
13331 (void *)&cmd_config_e_tag_e_tag_id_val,
13332 (void *)&cmd_config_e_tag_port,
13333 (void *)&cmd_config_e_tag_port_id,
13338 /* vf vlan anti spoof configuration */
13340 /* Common result structure for vf vlan anti spoof */
13341 struct cmd_vf_vlan_anti_spoof_result {
13342 cmdline_fixed_string_t set;
13343 cmdline_fixed_string_t vf;
13344 cmdline_fixed_string_t vlan;
13345 cmdline_fixed_string_t antispoof;
13348 cmdline_fixed_string_t on_off;
13351 /* Common CLI fields for vf vlan anti spoof enable disable */
13352 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
13353 TOKEN_STRING_INITIALIZER
13354 (struct cmd_vf_vlan_anti_spoof_result,
13356 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
13357 TOKEN_STRING_INITIALIZER
13358 (struct cmd_vf_vlan_anti_spoof_result,
13360 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
13361 TOKEN_STRING_INITIALIZER
13362 (struct cmd_vf_vlan_anti_spoof_result,
13364 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
13365 TOKEN_STRING_INITIALIZER
13366 (struct cmd_vf_vlan_anti_spoof_result,
13367 antispoof, "antispoof");
13368 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
13369 TOKEN_NUM_INITIALIZER
13370 (struct cmd_vf_vlan_anti_spoof_result,
13372 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
13373 TOKEN_NUM_INITIALIZER
13374 (struct cmd_vf_vlan_anti_spoof_result,
13376 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
13377 TOKEN_STRING_INITIALIZER
13378 (struct cmd_vf_vlan_anti_spoof_result,
13382 cmd_set_vf_vlan_anti_spoof_parsed(
13383 void *parsed_result,
13384 __attribute__((unused)) struct cmdline *cl,
13385 __attribute__((unused)) void *data)
13387 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
13388 int ret = -ENOTSUP;
13390 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13392 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13395 #ifdef RTE_LIBRTE_IXGBE_PMD
13396 if (ret == -ENOTSUP)
13397 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
13398 res->vf_id, is_on);
13400 #ifdef RTE_LIBRTE_I40E_PMD
13401 if (ret == -ENOTSUP)
13402 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
13403 res->vf_id, is_on);
13405 #ifdef RTE_LIBRTE_BNXT_PMD
13406 if (ret == -ENOTSUP)
13407 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
13408 res->vf_id, is_on);
13415 printf("invalid vf_id %d\n", res->vf_id);
13418 printf("invalid port_id %d\n", res->port_id);
13421 printf("function not implemented\n");
13424 printf("programming error: (%s)\n", strerror(-ret));
13428 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
13429 .f = cmd_set_vf_vlan_anti_spoof_parsed,
13431 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
13433 (void *)&cmd_vf_vlan_anti_spoof_set,
13434 (void *)&cmd_vf_vlan_anti_spoof_vf,
13435 (void *)&cmd_vf_vlan_anti_spoof_vlan,
13436 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
13437 (void *)&cmd_vf_vlan_anti_spoof_port_id,
13438 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
13439 (void *)&cmd_vf_vlan_anti_spoof_on_off,
13444 /* vf mac anti spoof configuration */
13446 /* Common result structure for vf mac anti spoof */
13447 struct cmd_vf_mac_anti_spoof_result {
13448 cmdline_fixed_string_t set;
13449 cmdline_fixed_string_t vf;
13450 cmdline_fixed_string_t mac;
13451 cmdline_fixed_string_t antispoof;
13454 cmdline_fixed_string_t on_off;
13457 /* Common CLI fields for vf mac anti spoof enable disable */
13458 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
13459 TOKEN_STRING_INITIALIZER
13460 (struct cmd_vf_mac_anti_spoof_result,
13462 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
13463 TOKEN_STRING_INITIALIZER
13464 (struct cmd_vf_mac_anti_spoof_result,
13466 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
13467 TOKEN_STRING_INITIALIZER
13468 (struct cmd_vf_mac_anti_spoof_result,
13470 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
13471 TOKEN_STRING_INITIALIZER
13472 (struct cmd_vf_mac_anti_spoof_result,
13473 antispoof, "antispoof");
13474 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
13475 TOKEN_NUM_INITIALIZER
13476 (struct cmd_vf_mac_anti_spoof_result,
13478 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
13479 TOKEN_NUM_INITIALIZER
13480 (struct cmd_vf_mac_anti_spoof_result,
13482 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
13483 TOKEN_STRING_INITIALIZER
13484 (struct cmd_vf_mac_anti_spoof_result,
13488 cmd_set_vf_mac_anti_spoof_parsed(
13489 void *parsed_result,
13490 __attribute__((unused)) struct cmdline *cl,
13491 __attribute__((unused)) void *data)
13493 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
13494 int ret = -ENOTSUP;
13496 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13498 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13501 #ifdef RTE_LIBRTE_IXGBE_PMD
13502 if (ret == -ENOTSUP)
13503 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
13504 res->vf_id, is_on);
13506 #ifdef RTE_LIBRTE_I40E_PMD
13507 if (ret == -ENOTSUP)
13508 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
13509 res->vf_id, is_on);
13511 #ifdef RTE_LIBRTE_BNXT_PMD
13512 if (ret == -ENOTSUP)
13513 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
13514 res->vf_id, is_on);
13521 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13524 printf("invalid port_id %d\n", res->port_id);
13527 printf("function not implemented\n");
13530 printf("programming error: (%s)\n", strerror(-ret));
13534 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
13535 .f = cmd_set_vf_mac_anti_spoof_parsed,
13537 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
13539 (void *)&cmd_vf_mac_anti_spoof_set,
13540 (void *)&cmd_vf_mac_anti_spoof_vf,
13541 (void *)&cmd_vf_mac_anti_spoof_mac,
13542 (void *)&cmd_vf_mac_anti_spoof_antispoof,
13543 (void *)&cmd_vf_mac_anti_spoof_port_id,
13544 (void *)&cmd_vf_mac_anti_spoof_vf_id,
13545 (void *)&cmd_vf_mac_anti_spoof_on_off,
13550 /* vf vlan strip queue configuration */
13552 /* Common result structure for vf mac anti spoof */
13553 struct cmd_vf_vlan_stripq_result {
13554 cmdline_fixed_string_t set;
13555 cmdline_fixed_string_t vf;
13556 cmdline_fixed_string_t vlan;
13557 cmdline_fixed_string_t stripq;
13560 cmdline_fixed_string_t on_off;
13563 /* Common CLI fields for vf vlan strip enable disable */
13564 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
13565 TOKEN_STRING_INITIALIZER
13566 (struct cmd_vf_vlan_stripq_result,
13568 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
13569 TOKEN_STRING_INITIALIZER
13570 (struct cmd_vf_vlan_stripq_result,
13572 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
13573 TOKEN_STRING_INITIALIZER
13574 (struct cmd_vf_vlan_stripq_result,
13576 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
13577 TOKEN_STRING_INITIALIZER
13578 (struct cmd_vf_vlan_stripq_result,
13580 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
13581 TOKEN_NUM_INITIALIZER
13582 (struct cmd_vf_vlan_stripq_result,
13584 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
13585 TOKEN_NUM_INITIALIZER
13586 (struct cmd_vf_vlan_stripq_result,
13588 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
13589 TOKEN_STRING_INITIALIZER
13590 (struct cmd_vf_vlan_stripq_result,
13594 cmd_set_vf_vlan_stripq_parsed(
13595 void *parsed_result,
13596 __attribute__((unused)) struct cmdline *cl,
13597 __attribute__((unused)) void *data)
13599 struct cmd_vf_vlan_stripq_result *res = parsed_result;
13600 int ret = -ENOTSUP;
13602 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13604 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13607 #ifdef RTE_LIBRTE_IXGBE_PMD
13608 if (ret == -ENOTSUP)
13609 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
13610 res->vf_id, is_on);
13612 #ifdef RTE_LIBRTE_I40E_PMD
13613 if (ret == -ENOTSUP)
13614 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
13615 res->vf_id, is_on);
13617 #ifdef RTE_LIBRTE_BNXT_PMD
13618 if (ret == -ENOTSUP)
13619 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
13620 res->vf_id, is_on);
13627 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13630 printf("invalid port_id %d\n", res->port_id);
13633 printf("function not implemented\n");
13636 printf("programming error: (%s)\n", strerror(-ret));
13640 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
13641 .f = cmd_set_vf_vlan_stripq_parsed,
13643 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
13645 (void *)&cmd_vf_vlan_stripq_set,
13646 (void *)&cmd_vf_vlan_stripq_vf,
13647 (void *)&cmd_vf_vlan_stripq_vlan,
13648 (void *)&cmd_vf_vlan_stripq_stripq,
13649 (void *)&cmd_vf_vlan_stripq_port_id,
13650 (void *)&cmd_vf_vlan_stripq_vf_id,
13651 (void *)&cmd_vf_vlan_stripq_on_off,
13656 /* vf vlan insert configuration */
13658 /* Common result structure for vf vlan insert */
13659 struct cmd_vf_vlan_insert_result {
13660 cmdline_fixed_string_t set;
13661 cmdline_fixed_string_t vf;
13662 cmdline_fixed_string_t vlan;
13663 cmdline_fixed_string_t insert;
13669 /* Common CLI fields for vf vlan insert enable disable */
13670 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
13671 TOKEN_STRING_INITIALIZER
13672 (struct cmd_vf_vlan_insert_result,
13674 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
13675 TOKEN_STRING_INITIALIZER
13676 (struct cmd_vf_vlan_insert_result,
13678 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
13679 TOKEN_STRING_INITIALIZER
13680 (struct cmd_vf_vlan_insert_result,
13682 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
13683 TOKEN_STRING_INITIALIZER
13684 (struct cmd_vf_vlan_insert_result,
13686 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
13687 TOKEN_NUM_INITIALIZER
13688 (struct cmd_vf_vlan_insert_result,
13690 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
13691 TOKEN_NUM_INITIALIZER
13692 (struct cmd_vf_vlan_insert_result,
13694 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
13695 TOKEN_NUM_INITIALIZER
13696 (struct cmd_vf_vlan_insert_result,
13700 cmd_set_vf_vlan_insert_parsed(
13701 void *parsed_result,
13702 __attribute__((unused)) struct cmdline *cl,
13703 __attribute__((unused)) void *data)
13705 struct cmd_vf_vlan_insert_result *res = parsed_result;
13706 int ret = -ENOTSUP;
13708 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13711 #ifdef RTE_LIBRTE_IXGBE_PMD
13712 if (ret == -ENOTSUP)
13713 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
13716 #ifdef RTE_LIBRTE_I40E_PMD
13717 if (ret == -ENOTSUP)
13718 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
13721 #ifdef RTE_LIBRTE_BNXT_PMD
13722 if (ret == -ENOTSUP)
13723 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
13731 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
13734 printf("invalid port_id %d\n", res->port_id);
13737 printf("function not implemented\n");
13740 printf("programming error: (%s)\n", strerror(-ret));
13744 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
13745 .f = cmd_set_vf_vlan_insert_parsed,
13747 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
13749 (void *)&cmd_vf_vlan_insert_set,
13750 (void *)&cmd_vf_vlan_insert_vf,
13751 (void *)&cmd_vf_vlan_insert_vlan,
13752 (void *)&cmd_vf_vlan_insert_insert,
13753 (void *)&cmd_vf_vlan_insert_port_id,
13754 (void *)&cmd_vf_vlan_insert_vf_id,
13755 (void *)&cmd_vf_vlan_insert_vlan_id,
13760 /* tx loopback configuration */
13762 /* Common result structure for tx loopback */
13763 struct cmd_tx_loopback_result {
13764 cmdline_fixed_string_t set;
13765 cmdline_fixed_string_t tx;
13766 cmdline_fixed_string_t loopback;
13768 cmdline_fixed_string_t on_off;
13771 /* Common CLI fields for tx loopback enable disable */
13772 cmdline_parse_token_string_t cmd_tx_loopback_set =
13773 TOKEN_STRING_INITIALIZER
13774 (struct cmd_tx_loopback_result,
13776 cmdline_parse_token_string_t cmd_tx_loopback_tx =
13777 TOKEN_STRING_INITIALIZER
13778 (struct cmd_tx_loopback_result,
13780 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
13781 TOKEN_STRING_INITIALIZER
13782 (struct cmd_tx_loopback_result,
13783 loopback, "loopback");
13784 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
13785 TOKEN_NUM_INITIALIZER
13786 (struct cmd_tx_loopback_result,
13788 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
13789 TOKEN_STRING_INITIALIZER
13790 (struct cmd_tx_loopback_result,
13794 cmd_set_tx_loopback_parsed(
13795 void *parsed_result,
13796 __attribute__((unused)) struct cmdline *cl,
13797 __attribute__((unused)) void *data)
13799 struct cmd_tx_loopback_result *res = parsed_result;
13800 int ret = -ENOTSUP;
13802 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13804 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13807 #ifdef RTE_LIBRTE_IXGBE_PMD
13808 if (ret == -ENOTSUP)
13809 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
13811 #ifdef RTE_LIBRTE_I40E_PMD
13812 if (ret == -ENOTSUP)
13813 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
13815 #ifdef RTE_LIBRTE_BNXT_PMD
13816 if (ret == -ENOTSUP)
13817 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
13819 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD
13820 if (ret == -ENOTSUP)
13821 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
13828 printf("invalid is_on %d\n", is_on);
13831 printf("invalid port_id %d\n", res->port_id);
13834 printf("function not implemented\n");
13837 printf("programming error: (%s)\n", strerror(-ret));
13841 cmdline_parse_inst_t cmd_set_tx_loopback = {
13842 .f = cmd_set_tx_loopback_parsed,
13844 .help_str = "set tx loopback <port_id> on|off",
13846 (void *)&cmd_tx_loopback_set,
13847 (void *)&cmd_tx_loopback_tx,
13848 (void *)&cmd_tx_loopback_loopback,
13849 (void *)&cmd_tx_loopback_port_id,
13850 (void *)&cmd_tx_loopback_on_off,
13855 /* all queues drop enable configuration */
13857 /* Common result structure for all queues drop enable */
13858 struct cmd_all_queues_drop_en_result {
13859 cmdline_fixed_string_t set;
13860 cmdline_fixed_string_t all;
13861 cmdline_fixed_string_t queues;
13862 cmdline_fixed_string_t drop;
13864 cmdline_fixed_string_t on_off;
13867 /* Common CLI fields for tx loopback enable disable */
13868 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
13869 TOKEN_STRING_INITIALIZER
13870 (struct cmd_all_queues_drop_en_result,
13872 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
13873 TOKEN_STRING_INITIALIZER
13874 (struct cmd_all_queues_drop_en_result,
13876 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
13877 TOKEN_STRING_INITIALIZER
13878 (struct cmd_all_queues_drop_en_result,
13880 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
13881 TOKEN_STRING_INITIALIZER
13882 (struct cmd_all_queues_drop_en_result,
13884 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
13885 TOKEN_NUM_INITIALIZER
13886 (struct cmd_all_queues_drop_en_result,
13888 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
13889 TOKEN_STRING_INITIALIZER
13890 (struct cmd_all_queues_drop_en_result,
13894 cmd_set_all_queues_drop_en_parsed(
13895 void *parsed_result,
13896 __attribute__((unused)) struct cmdline *cl,
13897 __attribute__((unused)) void *data)
13899 struct cmd_all_queues_drop_en_result *res = parsed_result;
13900 int ret = -ENOTSUP;
13901 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13903 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13906 #ifdef RTE_LIBRTE_IXGBE_PMD
13907 if (ret == -ENOTSUP)
13908 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
13910 #ifdef RTE_LIBRTE_BNXT_PMD
13911 if (ret == -ENOTSUP)
13912 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
13918 printf("invalid is_on %d\n", is_on);
13921 printf("invalid port_id %d\n", res->port_id);
13924 printf("function not implemented\n");
13927 printf("programming error: (%s)\n", strerror(-ret));
13931 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
13932 .f = cmd_set_all_queues_drop_en_parsed,
13934 .help_str = "set all queues drop <port_id> on|off",
13936 (void *)&cmd_all_queues_drop_en_set,
13937 (void *)&cmd_all_queues_drop_en_all,
13938 (void *)&cmd_all_queues_drop_en_queues,
13939 (void *)&cmd_all_queues_drop_en_drop,
13940 (void *)&cmd_all_queues_drop_en_port_id,
13941 (void *)&cmd_all_queues_drop_en_on_off,
13946 /* vf split drop enable configuration */
13948 /* Common result structure for vf split drop enable */
13949 struct cmd_vf_split_drop_en_result {
13950 cmdline_fixed_string_t set;
13951 cmdline_fixed_string_t vf;
13952 cmdline_fixed_string_t split;
13953 cmdline_fixed_string_t drop;
13956 cmdline_fixed_string_t on_off;
13959 /* Common CLI fields for vf split drop enable disable */
13960 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
13961 TOKEN_STRING_INITIALIZER
13962 (struct cmd_vf_split_drop_en_result,
13964 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
13965 TOKEN_STRING_INITIALIZER
13966 (struct cmd_vf_split_drop_en_result,
13968 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
13969 TOKEN_STRING_INITIALIZER
13970 (struct cmd_vf_split_drop_en_result,
13972 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
13973 TOKEN_STRING_INITIALIZER
13974 (struct cmd_vf_split_drop_en_result,
13976 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
13977 TOKEN_NUM_INITIALIZER
13978 (struct cmd_vf_split_drop_en_result,
13980 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
13981 TOKEN_NUM_INITIALIZER
13982 (struct cmd_vf_split_drop_en_result,
13984 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
13985 TOKEN_STRING_INITIALIZER
13986 (struct cmd_vf_split_drop_en_result,
13990 cmd_set_vf_split_drop_en_parsed(
13991 void *parsed_result,
13992 __attribute__((unused)) struct cmdline *cl,
13993 __attribute__((unused)) void *data)
13995 struct cmd_vf_split_drop_en_result *res = parsed_result;
13996 int ret = -ENOTSUP;
13997 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13999 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14002 #ifdef RTE_LIBRTE_IXGBE_PMD
14003 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
14010 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14013 printf("invalid port_id %d\n", res->port_id);
14016 printf("not supported on port %d\n", res->port_id);
14019 printf("programming error: (%s)\n", strerror(-ret));
14023 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
14024 .f = cmd_set_vf_split_drop_en_parsed,
14026 .help_str = "set vf split drop <port_id> <vf_id> on|off",
14028 (void *)&cmd_vf_split_drop_en_set,
14029 (void *)&cmd_vf_split_drop_en_vf,
14030 (void *)&cmd_vf_split_drop_en_split,
14031 (void *)&cmd_vf_split_drop_en_drop,
14032 (void *)&cmd_vf_split_drop_en_port_id,
14033 (void *)&cmd_vf_split_drop_en_vf_id,
14034 (void *)&cmd_vf_split_drop_en_on_off,
14039 /* vf mac address configuration */
14041 /* Common result structure for vf mac address */
14042 struct cmd_set_vf_mac_addr_result {
14043 cmdline_fixed_string_t set;
14044 cmdline_fixed_string_t vf;
14045 cmdline_fixed_string_t mac;
14046 cmdline_fixed_string_t addr;
14049 struct rte_ether_addr mac_addr;
14053 /* Common CLI fields for vf split drop enable disable */
14054 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
14055 TOKEN_STRING_INITIALIZER
14056 (struct cmd_set_vf_mac_addr_result,
14058 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
14059 TOKEN_STRING_INITIALIZER
14060 (struct cmd_set_vf_mac_addr_result,
14062 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
14063 TOKEN_STRING_INITIALIZER
14064 (struct cmd_set_vf_mac_addr_result,
14066 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
14067 TOKEN_STRING_INITIALIZER
14068 (struct cmd_set_vf_mac_addr_result,
14070 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
14071 TOKEN_NUM_INITIALIZER
14072 (struct cmd_set_vf_mac_addr_result,
14074 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
14075 TOKEN_NUM_INITIALIZER
14076 (struct cmd_set_vf_mac_addr_result,
14078 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
14079 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
14083 cmd_set_vf_mac_addr_parsed(
14084 void *parsed_result,
14085 __attribute__((unused)) struct cmdline *cl,
14086 __attribute__((unused)) void *data)
14088 struct cmd_set_vf_mac_addr_result *res = parsed_result;
14089 int ret = -ENOTSUP;
14091 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14094 #ifdef RTE_LIBRTE_IXGBE_PMD
14095 if (ret == -ENOTSUP)
14096 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
14099 #ifdef RTE_LIBRTE_I40E_PMD
14100 if (ret == -ENOTSUP)
14101 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
14104 #ifdef RTE_LIBRTE_BNXT_PMD
14105 if (ret == -ENOTSUP)
14106 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
14114 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
14117 printf("invalid port_id %d\n", res->port_id);
14120 printf("function not implemented\n");
14123 printf("programming error: (%s)\n", strerror(-ret));
14127 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
14128 .f = cmd_set_vf_mac_addr_parsed,
14130 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
14132 (void *)&cmd_set_vf_mac_addr_set,
14133 (void *)&cmd_set_vf_mac_addr_vf,
14134 (void *)&cmd_set_vf_mac_addr_mac,
14135 (void *)&cmd_set_vf_mac_addr_addr,
14136 (void *)&cmd_set_vf_mac_addr_port_id,
14137 (void *)&cmd_set_vf_mac_addr_vf_id,
14138 (void *)&cmd_set_vf_mac_addr_mac_addr,
14143 /* MACsec configuration */
14145 /* Common result structure for MACsec offload enable */
14146 struct cmd_macsec_offload_on_result {
14147 cmdline_fixed_string_t set;
14148 cmdline_fixed_string_t macsec;
14149 cmdline_fixed_string_t offload;
14151 cmdline_fixed_string_t on;
14152 cmdline_fixed_string_t encrypt;
14153 cmdline_fixed_string_t en_on_off;
14154 cmdline_fixed_string_t replay_protect;
14155 cmdline_fixed_string_t rp_on_off;
14158 /* Common CLI fields for MACsec offload disable */
14159 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
14160 TOKEN_STRING_INITIALIZER
14161 (struct cmd_macsec_offload_on_result,
14163 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
14164 TOKEN_STRING_INITIALIZER
14165 (struct cmd_macsec_offload_on_result,
14167 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
14168 TOKEN_STRING_INITIALIZER
14169 (struct cmd_macsec_offload_on_result,
14170 offload, "offload");
14171 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
14172 TOKEN_NUM_INITIALIZER
14173 (struct cmd_macsec_offload_on_result,
14175 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
14176 TOKEN_STRING_INITIALIZER
14177 (struct cmd_macsec_offload_on_result,
14179 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
14180 TOKEN_STRING_INITIALIZER
14181 (struct cmd_macsec_offload_on_result,
14182 encrypt, "encrypt");
14183 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
14184 TOKEN_STRING_INITIALIZER
14185 (struct cmd_macsec_offload_on_result,
14186 en_on_off, "on#off");
14187 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
14188 TOKEN_STRING_INITIALIZER
14189 (struct cmd_macsec_offload_on_result,
14190 replay_protect, "replay-protect");
14191 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
14192 TOKEN_STRING_INITIALIZER
14193 (struct cmd_macsec_offload_on_result,
14194 rp_on_off, "on#off");
14197 cmd_set_macsec_offload_on_parsed(
14198 void *parsed_result,
14199 __attribute__((unused)) struct cmdline *cl,
14200 __attribute__((unused)) void *data)
14202 struct cmd_macsec_offload_on_result *res = parsed_result;
14203 int ret = -ENOTSUP;
14204 portid_t port_id = res->port_id;
14205 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
14206 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
14207 struct rte_eth_dev_info dev_info;
14209 if (port_id_is_invalid(port_id, ENABLED_WARN))
14211 if (!port_is_stopped(port_id)) {
14212 printf("Please stop port %d first\n", port_id);
14216 ret = eth_dev_info_get_print_err(port_id, &dev_info);
14220 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
14221 #ifdef RTE_LIBRTE_IXGBE_PMD
14222 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
14230 ports[port_id].dev_conf.txmode.offloads |=
14231 DEV_TX_OFFLOAD_MACSEC_INSERT;
14232 cmd_reconfig_device_queue(port_id, 1, 1);
14235 printf("invalid port_id %d\n", port_id);
14238 printf("not supported on port %d\n", port_id);
14241 printf("programming error: (%s)\n", strerror(-ret));
14245 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
14246 .f = cmd_set_macsec_offload_on_parsed,
14248 .help_str = "set macsec offload <port_id> on "
14249 "encrypt on|off replay-protect on|off",
14251 (void *)&cmd_macsec_offload_on_set,
14252 (void *)&cmd_macsec_offload_on_macsec,
14253 (void *)&cmd_macsec_offload_on_offload,
14254 (void *)&cmd_macsec_offload_on_port_id,
14255 (void *)&cmd_macsec_offload_on_on,
14256 (void *)&cmd_macsec_offload_on_encrypt,
14257 (void *)&cmd_macsec_offload_on_en_on_off,
14258 (void *)&cmd_macsec_offload_on_replay_protect,
14259 (void *)&cmd_macsec_offload_on_rp_on_off,
14264 /* Common result structure for MACsec offload disable */
14265 struct cmd_macsec_offload_off_result {
14266 cmdline_fixed_string_t set;
14267 cmdline_fixed_string_t macsec;
14268 cmdline_fixed_string_t offload;
14270 cmdline_fixed_string_t off;
14273 /* Common CLI fields for MACsec offload disable */
14274 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
14275 TOKEN_STRING_INITIALIZER
14276 (struct cmd_macsec_offload_off_result,
14278 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
14279 TOKEN_STRING_INITIALIZER
14280 (struct cmd_macsec_offload_off_result,
14282 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
14283 TOKEN_STRING_INITIALIZER
14284 (struct cmd_macsec_offload_off_result,
14285 offload, "offload");
14286 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
14287 TOKEN_NUM_INITIALIZER
14288 (struct cmd_macsec_offload_off_result,
14290 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
14291 TOKEN_STRING_INITIALIZER
14292 (struct cmd_macsec_offload_off_result,
14296 cmd_set_macsec_offload_off_parsed(
14297 void *parsed_result,
14298 __attribute__((unused)) struct cmdline *cl,
14299 __attribute__((unused)) void *data)
14301 struct cmd_macsec_offload_off_result *res = parsed_result;
14302 int ret = -ENOTSUP;
14303 struct rte_eth_dev_info dev_info;
14304 portid_t port_id = res->port_id;
14306 if (port_id_is_invalid(port_id, ENABLED_WARN))
14308 if (!port_is_stopped(port_id)) {
14309 printf("Please stop port %d first\n", port_id);
14313 ret = eth_dev_info_get_print_err(port_id, &dev_info);
14317 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
14318 #ifdef RTE_LIBRTE_IXGBE_PMD
14319 ret = rte_pmd_ixgbe_macsec_disable(port_id);
14324 ports[port_id].dev_conf.txmode.offloads &=
14325 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
14326 cmd_reconfig_device_queue(port_id, 1, 1);
14329 printf("invalid port_id %d\n", port_id);
14332 printf("not supported on port %d\n", port_id);
14335 printf("programming error: (%s)\n", strerror(-ret));
14339 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
14340 .f = cmd_set_macsec_offload_off_parsed,
14342 .help_str = "set macsec offload <port_id> off",
14344 (void *)&cmd_macsec_offload_off_set,
14345 (void *)&cmd_macsec_offload_off_macsec,
14346 (void *)&cmd_macsec_offload_off_offload,
14347 (void *)&cmd_macsec_offload_off_port_id,
14348 (void *)&cmd_macsec_offload_off_off,
14353 /* Common result structure for MACsec secure connection configure */
14354 struct cmd_macsec_sc_result {
14355 cmdline_fixed_string_t set;
14356 cmdline_fixed_string_t macsec;
14357 cmdline_fixed_string_t sc;
14358 cmdline_fixed_string_t tx_rx;
14360 struct rte_ether_addr mac;
14364 /* Common CLI fields for MACsec secure connection configure */
14365 cmdline_parse_token_string_t cmd_macsec_sc_set =
14366 TOKEN_STRING_INITIALIZER
14367 (struct cmd_macsec_sc_result,
14369 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
14370 TOKEN_STRING_INITIALIZER
14371 (struct cmd_macsec_sc_result,
14373 cmdline_parse_token_string_t cmd_macsec_sc_sc =
14374 TOKEN_STRING_INITIALIZER
14375 (struct cmd_macsec_sc_result,
14377 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
14378 TOKEN_STRING_INITIALIZER
14379 (struct cmd_macsec_sc_result,
14381 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
14382 TOKEN_NUM_INITIALIZER
14383 (struct cmd_macsec_sc_result,
14385 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
14386 TOKEN_ETHERADDR_INITIALIZER
14387 (struct cmd_macsec_sc_result,
14389 cmdline_parse_token_num_t cmd_macsec_sc_pi =
14390 TOKEN_NUM_INITIALIZER
14391 (struct cmd_macsec_sc_result,
14395 cmd_set_macsec_sc_parsed(
14396 void *parsed_result,
14397 __attribute__((unused)) struct cmdline *cl,
14398 __attribute__((unused)) void *data)
14400 struct cmd_macsec_sc_result *res = parsed_result;
14401 int ret = -ENOTSUP;
14402 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14404 #ifdef RTE_LIBRTE_IXGBE_PMD
14406 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
14407 res->mac.addr_bytes) :
14408 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
14409 res->mac.addr_bytes, res->pi);
14411 RTE_SET_USED(is_tx);
14417 printf("invalid port_id %d\n", res->port_id);
14420 printf("not supported on port %d\n", res->port_id);
14423 printf("programming error: (%s)\n", strerror(-ret));
14427 cmdline_parse_inst_t cmd_set_macsec_sc = {
14428 .f = cmd_set_macsec_sc_parsed,
14430 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
14432 (void *)&cmd_macsec_sc_set,
14433 (void *)&cmd_macsec_sc_macsec,
14434 (void *)&cmd_macsec_sc_sc,
14435 (void *)&cmd_macsec_sc_tx_rx,
14436 (void *)&cmd_macsec_sc_port_id,
14437 (void *)&cmd_macsec_sc_mac,
14438 (void *)&cmd_macsec_sc_pi,
14443 /* Common result structure for MACsec secure connection configure */
14444 struct cmd_macsec_sa_result {
14445 cmdline_fixed_string_t set;
14446 cmdline_fixed_string_t macsec;
14447 cmdline_fixed_string_t sa;
14448 cmdline_fixed_string_t tx_rx;
14453 cmdline_fixed_string_t key;
14456 /* Common CLI fields for MACsec secure connection configure */
14457 cmdline_parse_token_string_t cmd_macsec_sa_set =
14458 TOKEN_STRING_INITIALIZER
14459 (struct cmd_macsec_sa_result,
14461 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
14462 TOKEN_STRING_INITIALIZER
14463 (struct cmd_macsec_sa_result,
14465 cmdline_parse_token_string_t cmd_macsec_sa_sa =
14466 TOKEN_STRING_INITIALIZER
14467 (struct cmd_macsec_sa_result,
14469 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
14470 TOKEN_STRING_INITIALIZER
14471 (struct cmd_macsec_sa_result,
14473 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
14474 TOKEN_NUM_INITIALIZER
14475 (struct cmd_macsec_sa_result,
14477 cmdline_parse_token_num_t cmd_macsec_sa_idx =
14478 TOKEN_NUM_INITIALIZER
14479 (struct cmd_macsec_sa_result,
14481 cmdline_parse_token_num_t cmd_macsec_sa_an =
14482 TOKEN_NUM_INITIALIZER
14483 (struct cmd_macsec_sa_result,
14485 cmdline_parse_token_num_t cmd_macsec_sa_pn =
14486 TOKEN_NUM_INITIALIZER
14487 (struct cmd_macsec_sa_result,
14489 cmdline_parse_token_string_t cmd_macsec_sa_key =
14490 TOKEN_STRING_INITIALIZER
14491 (struct cmd_macsec_sa_result,
14495 cmd_set_macsec_sa_parsed(
14496 void *parsed_result,
14497 __attribute__((unused)) struct cmdline *cl,
14498 __attribute__((unused)) void *data)
14500 struct cmd_macsec_sa_result *res = parsed_result;
14501 int ret = -ENOTSUP;
14502 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14503 uint8_t key[16] = { 0 };
14509 key_len = strlen(res->key) / 2;
14513 for (i = 0; i < key_len; i++) {
14514 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
14517 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
14520 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
14523 #ifdef RTE_LIBRTE_IXGBE_PMD
14525 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
14526 res->idx, res->an, res->pn, key) :
14527 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
14528 res->idx, res->an, res->pn, key);
14530 RTE_SET_USED(is_tx);
14537 printf("invalid idx %d or an %d\n", res->idx, res->an);
14540 printf("invalid port_id %d\n", res->port_id);
14543 printf("not supported on port %d\n", res->port_id);
14546 printf("programming error: (%s)\n", strerror(-ret));
14550 cmdline_parse_inst_t cmd_set_macsec_sa = {
14551 .f = cmd_set_macsec_sa_parsed,
14553 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
14555 (void *)&cmd_macsec_sa_set,
14556 (void *)&cmd_macsec_sa_macsec,
14557 (void *)&cmd_macsec_sa_sa,
14558 (void *)&cmd_macsec_sa_tx_rx,
14559 (void *)&cmd_macsec_sa_port_id,
14560 (void *)&cmd_macsec_sa_idx,
14561 (void *)&cmd_macsec_sa_an,
14562 (void *)&cmd_macsec_sa_pn,
14563 (void *)&cmd_macsec_sa_key,
14568 /* VF unicast promiscuous mode configuration */
14570 /* Common result structure for VF unicast promiscuous mode */
14571 struct cmd_vf_promisc_result {
14572 cmdline_fixed_string_t set;
14573 cmdline_fixed_string_t vf;
14574 cmdline_fixed_string_t promisc;
14577 cmdline_fixed_string_t on_off;
14580 /* Common CLI fields for VF unicast promiscuous mode enable disable */
14581 cmdline_parse_token_string_t cmd_vf_promisc_set =
14582 TOKEN_STRING_INITIALIZER
14583 (struct cmd_vf_promisc_result,
14585 cmdline_parse_token_string_t cmd_vf_promisc_vf =
14586 TOKEN_STRING_INITIALIZER
14587 (struct cmd_vf_promisc_result,
14589 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
14590 TOKEN_STRING_INITIALIZER
14591 (struct cmd_vf_promisc_result,
14592 promisc, "promisc");
14593 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
14594 TOKEN_NUM_INITIALIZER
14595 (struct cmd_vf_promisc_result,
14597 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
14598 TOKEN_NUM_INITIALIZER
14599 (struct cmd_vf_promisc_result,
14601 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
14602 TOKEN_STRING_INITIALIZER
14603 (struct cmd_vf_promisc_result,
14607 cmd_set_vf_promisc_parsed(
14608 void *parsed_result,
14609 __attribute__((unused)) struct cmdline *cl,
14610 __attribute__((unused)) void *data)
14612 struct cmd_vf_promisc_result *res = parsed_result;
14613 int ret = -ENOTSUP;
14615 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14617 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14620 #ifdef RTE_LIBRTE_I40E_PMD
14621 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
14622 res->vf_id, is_on);
14629 printf("invalid vf_id %d\n", res->vf_id);
14632 printf("invalid port_id %d\n", res->port_id);
14635 printf("function not implemented\n");
14638 printf("programming error: (%s)\n", strerror(-ret));
14642 cmdline_parse_inst_t cmd_set_vf_promisc = {
14643 .f = cmd_set_vf_promisc_parsed,
14645 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
14646 "Set unicast promiscuous mode for a VF from the PF",
14648 (void *)&cmd_vf_promisc_set,
14649 (void *)&cmd_vf_promisc_vf,
14650 (void *)&cmd_vf_promisc_promisc,
14651 (void *)&cmd_vf_promisc_port_id,
14652 (void *)&cmd_vf_promisc_vf_id,
14653 (void *)&cmd_vf_promisc_on_off,
14658 /* VF multicast promiscuous mode configuration */
14660 /* Common result structure for VF multicast promiscuous mode */
14661 struct cmd_vf_allmulti_result {
14662 cmdline_fixed_string_t set;
14663 cmdline_fixed_string_t vf;
14664 cmdline_fixed_string_t allmulti;
14667 cmdline_fixed_string_t on_off;
14670 /* Common CLI fields for VF multicast promiscuous mode enable disable */
14671 cmdline_parse_token_string_t cmd_vf_allmulti_set =
14672 TOKEN_STRING_INITIALIZER
14673 (struct cmd_vf_allmulti_result,
14675 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
14676 TOKEN_STRING_INITIALIZER
14677 (struct cmd_vf_allmulti_result,
14679 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
14680 TOKEN_STRING_INITIALIZER
14681 (struct cmd_vf_allmulti_result,
14682 allmulti, "allmulti");
14683 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
14684 TOKEN_NUM_INITIALIZER
14685 (struct cmd_vf_allmulti_result,
14687 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
14688 TOKEN_NUM_INITIALIZER
14689 (struct cmd_vf_allmulti_result,
14691 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
14692 TOKEN_STRING_INITIALIZER
14693 (struct cmd_vf_allmulti_result,
14697 cmd_set_vf_allmulti_parsed(
14698 void *parsed_result,
14699 __attribute__((unused)) struct cmdline *cl,
14700 __attribute__((unused)) void *data)
14702 struct cmd_vf_allmulti_result *res = parsed_result;
14703 int ret = -ENOTSUP;
14705 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14707 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14710 #ifdef RTE_LIBRTE_I40E_PMD
14711 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
14712 res->vf_id, is_on);
14719 printf("invalid vf_id %d\n", res->vf_id);
14722 printf("invalid port_id %d\n", res->port_id);
14725 printf("function not implemented\n");
14728 printf("programming error: (%s)\n", strerror(-ret));
14732 cmdline_parse_inst_t cmd_set_vf_allmulti = {
14733 .f = cmd_set_vf_allmulti_parsed,
14735 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
14736 "Set multicast promiscuous mode for a VF from the PF",
14738 (void *)&cmd_vf_allmulti_set,
14739 (void *)&cmd_vf_allmulti_vf,
14740 (void *)&cmd_vf_allmulti_allmulti,
14741 (void *)&cmd_vf_allmulti_port_id,
14742 (void *)&cmd_vf_allmulti_vf_id,
14743 (void *)&cmd_vf_allmulti_on_off,
14748 /* vf broadcast mode configuration */
14750 /* Common result structure for vf broadcast */
14751 struct cmd_set_vf_broadcast_result {
14752 cmdline_fixed_string_t set;
14753 cmdline_fixed_string_t vf;
14754 cmdline_fixed_string_t broadcast;
14757 cmdline_fixed_string_t on_off;
14760 /* Common CLI fields for vf broadcast enable disable */
14761 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
14762 TOKEN_STRING_INITIALIZER
14763 (struct cmd_set_vf_broadcast_result,
14765 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
14766 TOKEN_STRING_INITIALIZER
14767 (struct cmd_set_vf_broadcast_result,
14769 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
14770 TOKEN_STRING_INITIALIZER
14771 (struct cmd_set_vf_broadcast_result,
14772 broadcast, "broadcast");
14773 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
14774 TOKEN_NUM_INITIALIZER
14775 (struct cmd_set_vf_broadcast_result,
14777 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
14778 TOKEN_NUM_INITIALIZER
14779 (struct cmd_set_vf_broadcast_result,
14781 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
14782 TOKEN_STRING_INITIALIZER
14783 (struct cmd_set_vf_broadcast_result,
14787 cmd_set_vf_broadcast_parsed(
14788 void *parsed_result,
14789 __attribute__((unused)) struct cmdline *cl,
14790 __attribute__((unused)) void *data)
14792 struct cmd_set_vf_broadcast_result *res = parsed_result;
14793 int ret = -ENOTSUP;
14795 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14797 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14800 #ifdef RTE_LIBRTE_I40E_PMD
14801 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
14802 res->vf_id, is_on);
14809 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14812 printf("invalid port_id %d\n", res->port_id);
14815 printf("function not implemented\n");
14818 printf("programming error: (%s)\n", strerror(-ret));
14822 cmdline_parse_inst_t cmd_set_vf_broadcast = {
14823 .f = cmd_set_vf_broadcast_parsed,
14825 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
14827 (void *)&cmd_set_vf_broadcast_set,
14828 (void *)&cmd_set_vf_broadcast_vf,
14829 (void *)&cmd_set_vf_broadcast_broadcast,
14830 (void *)&cmd_set_vf_broadcast_port_id,
14831 (void *)&cmd_set_vf_broadcast_vf_id,
14832 (void *)&cmd_set_vf_broadcast_on_off,
14837 /* vf vlan tag configuration */
14839 /* Common result structure for vf vlan tag */
14840 struct cmd_set_vf_vlan_tag_result {
14841 cmdline_fixed_string_t set;
14842 cmdline_fixed_string_t vf;
14843 cmdline_fixed_string_t vlan;
14844 cmdline_fixed_string_t tag;
14847 cmdline_fixed_string_t on_off;
14850 /* Common CLI fields for vf vlan tag enable disable */
14851 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
14852 TOKEN_STRING_INITIALIZER
14853 (struct cmd_set_vf_vlan_tag_result,
14855 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
14856 TOKEN_STRING_INITIALIZER
14857 (struct cmd_set_vf_vlan_tag_result,
14859 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
14860 TOKEN_STRING_INITIALIZER
14861 (struct cmd_set_vf_vlan_tag_result,
14863 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
14864 TOKEN_STRING_INITIALIZER
14865 (struct cmd_set_vf_vlan_tag_result,
14867 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
14868 TOKEN_NUM_INITIALIZER
14869 (struct cmd_set_vf_vlan_tag_result,
14871 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
14872 TOKEN_NUM_INITIALIZER
14873 (struct cmd_set_vf_vlan_tag_result,
14875 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
14876 TOKEN_STRING_INITIALIZER
14877 (struct cmd_set_vf_vlan_tag_result,
14881 cmd_set_vf_vlan_tag_parsed(
14882 void *parsed_result,
14883 __attribute__((unused)) struct cmdline *cl,
14884 __attribute__((unused)) void *data)
14886 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
14887 int ret = -ENOTSUP;
14889 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14891 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14894 #ifdef RTE_LIBRTE_I40E_PMD
14895 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
14896 res->vf_id, is_on);
14903 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14906 printf("invalid port_id %d\n", res->port_id);
14909 printf("function not implemented\n");
14912 printf("programming error: (%s)\n", strerror(-ret));
14916 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
14917 .f = cmd_set_vf_vlan_tag_parsed,
14919 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
14921 (void *)&cmd_set_vf_vlan_tag_set,
14922 (void *)&cmd_set_vf_vlan_tag_vf,
14923 (void *)&cmd_set_vf_vlan_tag_vlan,
14924 (void *)&cmd_set_vf_vlan_tag_tag,
14925 (void *)&cmd_set_vf_vlan_tag_port_id,
14926 (void *)&cmd_set_vf_vlan_tag_vf_id,
14927 (void *)&cmd_set_vf_vlan_tag_on_off,
14932 /* Common definition of VF and TC TX bandwidth configuration */
14933 struct cmd_vf_tc_bw_result {
14934 cmdline_fixed_string_t set;
14935 cmdline_fixed_string_t vf;
14936 cmdline_fixed_string_t tc;
14937 cmdline_fixed_string_t tx;
14938 cmdline_fixed_string_t min_bw;
14939 cmdline_fixed_string_t max_bw;
14940 cmdline_fixed_string_t strict_link_prio;
14945 cmdline_fixed_string_t bw_list;
14949 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
14950 TOKEN_STRING_INITIALIZER
14951 (struct cmd_vf_tc_bw_result,
14953 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
14954 TOKEN_STRING_INITIALIZER
14955 (struct cmd_vf_tc_bw_result,
14957 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
14958 TOKEN_STRING_INITIALIZER
14959 (struct cmd_vf_tc_bw_result,
14961 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
14962 TOKEN_STRING_INITIALIZER
14963 (struct cmd_vf_tc_bw_result,
14965 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
14966 TOKEN_STRING_INITIALIZER
14967 (struct cmd_vf_tc_bw_result,
14968 strict_link_prio, "strict-link-priority");
14969 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
14970 TOKEN_STRING_INITIALIZER
14971 (struct cmd_vf_tc_bw_result,
14972 min_bw, "min-bandwidth");
14973 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
14974 TOKEN_STRING_INITIALIZER
14975 (struct cmd_vf_tc_bw_result,
14976 max_bw, "max-bandwidth");
14977 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
14978 TOKEN_NUM_INITIALIZER
14979 (struct cmd_vf_tc_bw_result,
14981 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
14982 TOKEN_NUM_INITIALIZER
14983 (struct cmd_vf_tc_bw_result,
14985 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
14986 TOKEN_NUM_INITIALIZER
14987 (struct cmd_vf_tc_bw_result,
14989 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
14990 TOKEN_NUM_INITIALIZER
14991 (struct cmd_vf_tc_bw_result,
14993 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
14994 TOKEN_STRING_INITIALIZER
14995 (struct cmd_vf_tc_bw_result,
14997 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
14998 TOKEN_NUM_INITIALIZER
14999 (struct cmd_vf_tc_bw_result,
15002 /* VF max bandwidth setting */
15004 cmd_vf_max_bw_parsed(
15005 void *parsed_result,
15006 __attribute__((unused)) struct cmdline *cl,
15007 __attribute__((unused)) void *data)
15009 struct cmd_vf_tc_bw_result *res = parsed_result;
15010 int ret = -ENOTSUP;
15012 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15015 #ifdef RTE_LIBRTE_I40E_PMD
15016 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
15017 res->vf_id, res->bw);
15024 printf("invalid vf_id %d or bandwidth %d\n",
15025 res->vf_id, res->bw);
15028 printf("invalid port_id %d\n", res->port_id);
15031 printf("function not implemented\n");
15034 printf("programming error: (%s)\n", strerror(-ret));
15038 cmdline_parse_inst_t cmd_vf_max_bw = {
15039 .f = cmd_vf_max_bw_parsed,
15041 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
15043 (void *)&cmd_vf_tc_bw_set,
15044 (void *)&cmd_vf_tc_bw_vf,
15045 (void *)&cmd_vf_tc_bw_tx,
15046 (void *)&cmd_vf_tc_bw_max_bw,
15047 (void *)&cmd_vf_tc_bw_port_id,
15048 (void *)&cmd_vf_tc_bw_vf_id,
15049 (void *)&cmd_vf_tc_bw_bw,
15055 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
15060 const char *p, *p0 = str;
15067 p = strchr(p0, '(');
15069 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
15073 p0 = strchr(p, ')');
15075 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
15079 if (size >= sizeof(s)) {
15080 printf("The string size exceeds the internal buffer size\n");
15083 snprintf(s, sizeof(s), "%.*s", size, p);
15084 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
15086 printf("Failed to get the bandwidth list. ");
15090 for (i = 0; i < ret; i++)
15091 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
15096 /* TC min bandwidth setting */
15098 cmd_vf_tc_min_bw_parsed(
15099 void *parsed_result,
15100 __attribute__((unused)) struct cmdline *cl,
15101 __attribute__((unused)) void *data)
15103 struct cmd_vf_tc_bw_result *res = parsed_result;
15106 int ret = -ENOTSUP;
15108 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15111 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
15115 #ifdef RTE_LIBRTE_I40E_PMD
15116 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
15124 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
15127 printf("invalid port_id %d\n", res->port_id);
15130 printf("function not implemented\n");
15133 printf("programming error: (%s)\n", strerror(-ret));
15137 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
15138 .f = cmd_vf_tc_min_bw_parsed,
15140 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
15141 " <bw1, bw2, ...>",
15143 (void *)&cmd_vf_tc_bw_set,
15144 (void *)&cmd_vf_tc_bw_vf,
15145 (void *)&cmd_vf_tc_bw_tc,
15146 (void *)&cmd_vf_tc_bw_tx,
15147 (void *)&cmd_vf_tc_bw_min_bw,
15148 (void *)&cmd_vf_tc_bw_port_id,
15149 (void *)&cmd_vf_tc_bw_vf_id,
15150 (void *)&cmd_vf_tc_bw_bw_list,
15156 cmd_tc_min_bw_parsed(
15157 void *parsed_result,
15158 __attribute__((unused)) struct cmdline *cl,
15159 __attribute__((unused)) void *data)
15161 struct cmd_vf_tc_bw_result *res = parsed_result;
15162 struct rte_port *port;
15165 int ret = -ENOTSUP;
15167 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15170 port = &ports[res->port_id];
15171 /** Check if the port is not started **/
15172 if (port->port_status != RTE_PORT_STOPPED) {
15173 printf("Please stop port %d first\n", res->port_id);
15177 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
15181 #ifdef RTE_LIBRTE_IXGBE_PMD
15182 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
15189 printf("invalid bandwidth\n");
15192 printf("invalid port_id %d\n", res->port_id);
15195 printf("function not implemented\n");
15198 printf("programming error: (%s)\n", strerror(-ret));
15202 cmdline_parse_inst_t cmd_tc_min_bw = {
15203 .f = cmd_tc_min_bw_parsed,
15205 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
15207 (void *)&cmd_vf_tc_bw_set,
15208 (void *)&cmd_vf_tc_bw_tc,
15209 (void *)&cmd_vf_tc_bw_tx,
15210 (void *)&cmd_vf_tc_bw_min_bw,
15211 (void *)&cmd_vf_tc_bw_port_id,
15212 (void *)&cmd_vf_tc_bw_bw_list,
15217 /* TC max bandwidth setting */
15219 cmd_vf_tc_max_bw_parsed(
15220 void *parsed_result,
15221 __attribute__((unused)) struct cmdline *cl,
15222 __attribute__((unused)) void *data)
15224 struct cmd_vf_tc_bw_result *res = parsed_result;
15225 int ret = -ENOTSUP;
15227 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15230 #ifdef RTE_LIBRTE_I40E_PMD
15231 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
15232 res->tc_no, res->bw);
15239 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
15240 res->vf_id, res->tc_no, res->bw);
15243 printf("invalid port_id %d\n", res->port_id);
15246 printf("function not implemented\n");
15249 printf("programming error: (%s)\n", strerror(-ret));
15253 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
15254 .f = cmd_vf_tc_max_bw_parsed,
15256 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
15259 (void *)&cmd_vf_tc_bw_set,
15260 (void *)&cmd_vf_tc_bw_vf,
15261 (void *)&cmd_vf_tc_bw_tc,
15262 (void *)&cmd_vf_tc_bw_tx,
15263 (void *)&cmd_vf_tc_bw_max_bw,
15264 (void *)&cmd_vf_tc_bw_port_id,
15265 (void *)&cmd_vf_tc_bw_vf_id,
15266 (void *)&cmd_vf_tc_bw_tc_no,
15267 (void *)&cmd_vf_tc_bw_bw,
15273 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
15275 /* *** Set Port default Traffic Management Hierarchy *** */
15276 struct cmd_set_port_tm_hierarchy_default_result {
15277 cmdline_fixed_string_t set;
15278 cmdline_fixed_string_t port;
15279 cmdline_fixed_string_t tm;
15280 cmdline_fixed_string_t hierarchy;
15281 cmdline_fixed_string_t def;
15285 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_set =
15286 TOKEN_STRING_INITIALIZER(
15287 struct cmd_set_port_tm_hierarchy_default_result, set, "set");
15288 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_port =
15289 TOKEN_STRING_INITIALIZER(
15290 struct cmd_set_port_tm_hierarchy_default_result, port, "port");
15291 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_tm =
15292 TOKEN_STRING_INITIALIZER(
15293 struct cmd_set_port_tm_hierarchy_default_result, tm, "tm");
15294 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_hierarchy =
15295 TOKEN_STRING_INITIALIZER(
15296 struct cmd_set_port_tm_hierarchy_default_result,
15297 hierarchy, "hierarchy");
15298 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_default =
15299 TOKEN_STRING_INITIALIZER(
15300 struct cmd_set_port_tm_hierarchy_default_result,
15302 cmdline_parse_token_num_t cmd_set_port_tm_hierarchy_default_port_id =
15303 TOKEN_NUM_INITIALIZER(
15304 struct cmd_set_port_tm_hierarchy_default_result,
15307 static void cmd_set_port_tm_hierarchy_default_parsed(void *parsed_result,
15308 __attribute__((unused)) struct cmdline *cl,
15309 __attribute__((unused)) void *data)
15311 struct cmd_set_port_tm_hierarchy_default_result *res = parsed_result;
15312 struct rte_port *p;
15313 portid_t port_id = res->port_id;
15315 if (port_id_is_invalid(port_id, ENABLED_WARN))
15318 p = &ports[port_id];
15320 /* Forward mode: tm */
15321 if (strcmp(cur_fwd_config.fwd_eng->fwd_mode_name, "softnic")) {
15322 printf(" softnicfwd mode not enabled(error)\n");
15326 /* Set the default tm hierarchy */
15327 p->softport.default_tm_hierarchy_enable = 1;
15330 cmdline_parse_inst_t cmd_set_port_tm_hierarchy_default = {
15331 .f = cmd_set_port_tm_hierarchy_default_parsed,
15333 .help_str = "set port tm hierarchy default <port_id>",
15335 (void *)&cmd_set_port_tm_hierarchy_default_set,
15336 (void *)&cmd_set_port_tm_hierarchy_default_port,
15337 (void *)&cmd_set_port_tm_hierarchy_default_tm,
15338 (void *)&cmd_set_port_tm_hierarchy_default_hierarchy,
15339 (void *)&cmd_set_port_tm_hierarchy_default_default,
15340 (void *)&cmd_set_port_tm_hierarchy_default_port_id,
15346 /** Set VXLAN encapsulation details */
15347 struct cmd_set_vxlan_result {
15348 cmdline_fixed_string_t set;
15349 cmdline_fixed_string_t vxlan;
15350 cmdline_fixed_string_t pos_token;
15351 cmdline_fixed_string_t ip_version;
15352 uint32_t vlan_present:1;
15356 cmdline_ipaddr_t ip_src;
15357 cmdline_ipaddr_t ip_dst;
15361 struct rte_ether_addr eth_src;
15362 struct rte_ether_addr eth_dst;
15365 cmdline_parse_token_string_t cmd_set_vxlan_set =
15366 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
15367 cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
15368 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
15369 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
15370 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15372 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
15373 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15374 "vxlan-with-vlan");
15375 cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
15376 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15378 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
15379 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
15381 cmdline_parse_token_string_t cmd_set_vxlan_vni =
15382 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15384 cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
15385 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, UINT32);
15386 cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
15387 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15389 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
15390 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, UINT16);
15391 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
15392 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15394 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
15395 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, UINT16);
15396 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
15397 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15399 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
15400 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, UINT8);
15401 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
15402 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15404 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
15405 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, UINT8);
15406 cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
15407 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15409 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
15410 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
15411 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
15412 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15414 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
15415 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
15416 cmdline_parse_token_string_t cmd_set_vxlan_vlan =
15417 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15419 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
15420 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, UINT16);
15421 cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
15422 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15424 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
15425 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
15426 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
15427 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15429 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
15430 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
15432 static void cmd_set_vxlan_parsed(void *parsed_result,
15433 __attribute__((unused)) struct cmdline *cl,
15434 __attribute__((unused)) void *data)
15436 struct cmd_set_vxlan_result *res = parsed_result;
15441 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
15444 vxlan_encap_conf.select_tos_ttl = 0;
15445 if (strcmp(res->vxlan, "vxlan") == 0)
15446 vxlan_encap_conf.select_vlan = 0;
15447 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
15448 vxlan_encap_conf.select_vlan = 1;
15449 else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
15450 vxlan_encap_conf.select_vlan = 0;
15451 vxlan_encap_conf.select_tos_ttl = 1;
15453 if (strcmp(res->ip_version, "ipv4") == 0)
15454 vxlan_encap_conf.select_ipv4 = 1;
15455 else if (strcmp(res->ip_version, "ipv6") == 0)
15456 vxlan_encap_conf.select_ipv4 = 0;
15459 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
15460 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
15461 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
15462 vxlan_encap_conf.ip_tos = res->tos;
15463 vxlan_encap_conf.ip_ttl = res->ttl;
15464 if (vxlan_encap_conf.select_ipv4) {
15465 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
15466 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
15468 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
15469 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
15471 if (vxlan_encap_conf.select_vlan)
15472 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15473 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
15474 RTE_ETHER_ADDR_LEN);
15475 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15476 RTE_ETHER_ADDR_LEN);
15479 cmdline_parse_inst_t cmd_set_vxlan = {
15480 .f = cmd_set_vxlan_parsed,
15482 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
15483 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
15484 " eth-src <eth-src> eth-dst <eth-dst>",
15486 (void *)&cmd_set_vxlan_set,
15487 (void *)&cmd_set_vxlan_vxlan,
15488 (void *)&cmd_set_vxlan_ip_version,
15489 (void *)&cmd_set_vxlan_ip_version_value,
15490 (void *)&cmd_set_vxlan_vni,
15491 (void *)&cmd_set_vxlan_vni_value,
15492 (void *)&cmd_set_vxlan_udp_src,
15493 (void *)&cmd_set_vxlan_udp_src_value,
15494 (void *)&cmd_set_vxlan_udp_dst,
15495 (void *)&cmd_set_vxlan_udp_dst_value,
15496 (void *)&cmd_set_vxlan_ip_src,
15497 (void *)&cmd_set_vxlan_ip_src_value,
15498 (void *)&cmd_set_vxlan_ip_dst,
15499 (void *)&cmd_set_vxlan_ip_dst_value,
15500 (void *)&cmd_set_vxlan_eth_src,
15501 (void *)&cmd_set_vxlan_eth_src_value,
15502 (void *)&cmd_set_vxlan_eth_dst,
15503 (void *)&cmd_set_vxlan_eth_dst_value,
15508 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
15509 .f = cmd_set_vxlan_parsed,
15511 .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
15512 " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
15513 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15514 " eth-dst <eth-dst>",
15516 (void *)&cmd_set_vxlan_set,
15517 (void *)&cmd_set_vxlan_vxlan_tos_ttl,
15518 (void *)&cmd_set_vxlan_ip_version,
15519 (void *)&cmd_set_vxlan_ip_version_value,
15520 (void *)&cmd_set_vxlan_vni,
15521 (void *)&cmd_set_vxlan_vni_value,
15522 (void *)&cmd_set_vxlan_udp_src,
15523 (void *)&cmd_set_vxlan_udp_src_value,
15524 (void *)&cmd_set_vxlan_udp_dst,
15525 (void *)&cmd_set_vxlan_udp_dst_value,
15526 (void *)&cmd_set_vxlan_ip_tos,
15527 (void *)&cmd_set_vxlan_ip_tos_value,
15528 (void *)&cmd_set_vxlan_ip_ttl,
15529 (void *)&cmd_set_vxlan_ip_ttl_value,
15530 (void *)&cmd_set_vxlan_ip_src,
15531 (void *)&cmd_set_vxlan_ip_src_value,
15532 (void *)&cmd_set_vxlan_ip_dst,
15533 (void *)&cmd_set_vxlan_ip_dst_value,
15534 (void *)&cmd_set_vxlan_eth_src,
15535 (void *)&cmd_set_vxlan_eth_src_value,
15536 (void *)&cmd_set_vxlan_eth_dst,
15537 (void *)&cmd_set_vxlan_eth_dst_value,
15542 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
15543 .f = cmd_set_vxlan_parsed,
15545 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
15546 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
15547 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
15550 (void *)&cmd_set_vxlan_set,
15551 (void *)&cmd_set_vxlan_vxlan_with_vlan,
15552 (void *)&cmd_set_vxlan_ip_version,
15553 (void *)&cmd_set_vxlan_ip_version_value,
15554 (void *)&cmd_set_vxlan_vni,
15555 (void *)&cmd_set_vxlan_vni_value,
15556 (void *)&cmd_set_vxlan_udp_src,
15557 (void *)&cmd_set_vxlan_udp_src_value,
15558 (void *)&cmd_set_vxlan_udp_dst,
15559 (void *)&cmd_set_vxlan_udp_dst_value,
15560 (void *)&cmd_set_vxlan_ip_src,
15561 (void *)&cmd_set_vxlan_ip_src_value,
15562 (void *)&cmd_set_vxlan_ip_dst,
15563 (void *)&cmd_set_vxlan_ip_dst_value,
15564 (void *)&cmd_set_vxlan_vlan,
15565 (void *)&cmd_set_vxlan_vlan_value,
15566 (void *)&cmd_set_vxlan_eth_src,
15567 (void *)&cmd_set_vxlan_eth_src_value,
15568 (void *)&cmd_set_vxlan_eth_dst,
15569 (void *)&cmd_set_vxlan_eth_dst_value,
15574 /** Set NVGRE encapsulation details */
15575 struct cmd_set_nvgre_result {
15576 cmdline_fixed_string_t set;
15577 cmdline_fixed_string_t nvgre;
15578 cmdline_fixed_string_t pos_token;
15579 cmdline_fixed_string_t ip_version;
15581 cmdline_ipaddr_t ip_src;
15582 cmdline_ipaddr_t ip_dst;
15584 struct rte_ether_addr eth_src;
15585 struct rte_ether_addr eth_dst;
15588 cmdline_parse_token_string_t cmd_set_nvgre_set =
15589 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
15590 cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
15591 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
15592 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
15593 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
15594 "nvgre-with-vlan");
15595 cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
15596 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15598 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
15599 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
15601 cmdline_parse_token_string_t cmd_set_nvgre_tni =
15602 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15604 cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
15605 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, UINT32);
15606 cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
15607 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15609 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
15610 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
15611 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
15612 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15614 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
15615 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
15616 cmdline_parse_token_string_t cmd_set_nvgre_vlan =
15617 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15619 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
15620 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, UINT16);
15621 cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
15622 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15624 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
15625 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
15626 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
15627 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15629 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
15630 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
15632 static void cmd_set_nvgre_parsed(void *parsed_result,
15633 __attribute__((unused)) struct cmdline *cl,
15634 __attribute__((unused)) void *data)
15636 struct cmd_set_nvgre_result *res = parsed_result;
15638 uint32_t nvgre_tni;
15641 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
15644 if (strcmp(res->nvgre, "nvgre") == 0)
15645 nvgre_encap_conf.select_vlan = 0;
15646 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
15647 nvgre_encap_conf.select_vlan = 1;
15648 if (strcmp(res->ip_version, "ipv4") == 0)
15649 nvgre_encap_conf.select_ipv4 = 1;
15650 else if (strcmp(res->ip_version, "ipv6") == 0)
15651 nvgre_encap_conf.select_ipv4 = 0;
15654 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
15655 if (nvgre_encap_conf.select_ipv4) {
15656 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
15657 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
15659 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
15660 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
15662 if (nvgre_encap_conf.select_vlan)
15663 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15664 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
15665 RTE_ETHER_ADDR_LEN);
15666 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15667 RTE_ETHER_ADDR_LEN);
15670 cmdline_parse_inst_t cmd_set_nvgre = {
15671 .f = cmd_set_nvgre_parsed,
15673 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
15674 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15675 " eth-dst <eth-dst>",
15677 (void *)&cmd_set_nvgre_set,
15678 (void *)&cmd_set_nvgre_nvgre,
15679 (void *)&cmd_set_nvgre_ip_version,
15680 (void *)&cmd_set_nvgre_ip_version_value,
15681 (void *)&cmd_set_nvgre_tni,
15682 (void *)&cmd_set_nvgre_tni_value,
15683 (void *)&cmd_set_nvgre_ip_src,
15684 (void *)&cmd_set_nvgre_ip_src_value,
15685 (void *)&cmd_set_nvgre_ip_dst,
15686 (void *)&cmd_set_nvgre_ip_dst_value,
15687 (void *)&cmd_set_nvgre_eth_src,
15688 (void *)&cmd_set_nvgre_eth_src_value,
15689 (void *)&cmd_set_nvgre_eth_dst,
15690 (void *)&cmd_set_nvgre_eth_dst_value,
15695 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
15696 .f = cmd_set_nvgre_parsed,
15698 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
15699 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
15700 " eth-src <eth-src> eth-dst <eth-dst>",
15702 (void *)&cmd_set_nvgre_set,
15703 (void *)&cmd_set_nvgre_nvgre_with_vlan,
15704 (void *)&cmd_set_nvgre_ip_version,
15705 (void *)&cmd_set_nvgre_ip_version_value,
15706 (void *)&cmd_set_nvgre_tni,
15707 (void *)&cmd_set_nvgre_tni_value,
15708 (void *)&cmd_set_nvgre_ip_src,
15709 (void *)&cmd_set_nvgre_ip_src_value,
15710 (void *)&cmd_set_nvgre_ip_dst,
15711 (void *)&cmd_set_nvgre_ip_dst_value,
15712 (void *)&cmd_set_nvgre_vlan,
15713 (void *)&cmd_set_nvgre_vlan_value,
15714 (void *)&cmd_set_nvgre_eth_src,
15715 (void *)&cmd_set_nvgre_eth_src_value,
15716 (void *)&cmd_set_nvgre_eth_dst,
15717 (void *)&cmd_set_nvgre_eth_dst_value,
15722 /** Set L2 encapsulation details */
15723 struct cmd_set_l2_encap_result {
15724 cmdline_fixed_string_t set;
15725 cmdline_fixed_string_t l2_encap;
15726 cmdline_fixed_string_t pos_token;
15727 cmdline_fixed_string_t ip_version;
15728 uint32_t vlan_present:1;
15730 struct rte_ether_addr eth_src;
15731 struct rte_ether_addr eth_dst;
15734 cmdline_parse_token_string_t cmd_set_l2_encap_set =
15735 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
15736 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
15737 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
15738 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
15739 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
15740 "l2_encap-with-vlan");
15741 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
15742 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15744 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
15745 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
15747 cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
15748 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15750 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
15751 TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, UINT16);
15752 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
15753 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15755 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
15756 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
15757 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
15758 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15760 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
15761 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
15763 static void cmd_set_l2_encap_parsed(void *parsed_result,
15764 __attribute__((unused)) struct cmdline *cl,
15765 __attribute__((unused)) void *data)
15767 struct cmd_set_l2_encap_result *res = parsed_result;
15769 if (strcmp(res->l2_encap, "l2_encap") == 0)
15770 l2_encap_conf.select_vlan = 0;
15771 else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
15772 l2_encap_conf.select_vlan = 1;
15773 if (strcmp(res->ip_version, "ipv4") == 0)
15774 l2_encap_conf.select_ipv4 = 1;
15775 else if (strcmp(res->ip_version, "ipv6") == 0)
15776 l2_encap_conf.select_ipv4 = 0;
15779 if (l2_encap_conf.select_vlan)
15780 l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15781 rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
15782 RTE_ETHER_ADDR_LEN);
15783 rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15784 RTE_ETHER_ADDR_LEN);
15787 cmdline_parse_inst_t cmd_set_l2_encap = {
15788 .f = cmd_set_l2_encap_parsed,
15790 .help_str = "set l2_encap ip-version ipv4|ipv6"
15791 " eth-src <eth-src> eth-dst <eth-dst>",
15793 (void *)&cmd_set_l2_encap_set,
15794 (void *)&cmd_set_l2_encap_l2_encap,
15795 (void *)&cmd_set_l2_encap_ip_version,
15796 (void *)&cmd_set_l2_encap_ip_version_value,
15797 (void *)&cmd_set_l2_encap_eth_src,
15798 (void *)&cmd_set_l2_encap_eth_src_value,
15799 (void *)&cmd_set_l2_encap_eth_dst,
15800 (void *)&cmd_set_l2_encap_eth_dst_value,
15805 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
15806 .f = cmd_set_l2_encap_parsed,
15808 .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
15809 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
15811 (void *)&cmd_set_l2_encap_set,
15812 (void *)&cmd_set_l2_encap_l2_encap_with_vlan,
15813 (void *)&cmd_set_l2_encap_ip_version,
15814 (void *)&cmd_set_l2_encap_ip_version_value,
15815 (void *)&cmd_set_l2_encap_vlan,
15816 (void *)&cmd_set_l2_encap_vlan_value,
15817 (void *)&cmd_set_l2_encap_eth_src,
15818 (void *)&cmd_set_l2_encap_eth_src_value,
15819 (void *)&cmd_set_l2_encap_eth_dst,
15820 (void *)&cmd_set_l2_encap_eth_dst_value,
15825 /** Set L2 decapsulation details */
15826 struct cmd_set_l2_decap_result {
15827 cmdline_fixed_string_t set;
15828 cmdline_fixed_string_t l2_decap;
15829 cmdline_fixed_string_t pos_token;
15830 uint32_t vlan_present:1;
15833 cmdline_parse_token_string_t cmd_set_l2_decap_set =
15834 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
15835 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
15836 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
15838 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
15839 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
15840 "l2_decap-with-vlan");
15842 static void cmd_set_l2_decap_parsed(void *parsed_result,
15843 __attribute__((unused)) struct cmdline *cl,
15844 __attribute__((unused)) void *data)
15846 struct cmd_set_l2_decap_result *res = parsed_result;
15848 if (strcmp(res->l2_decap, "l2_decap") == 0)
15849 l2_decap_conf.select_vlan = 0;
15850 else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
15851 l2_decap_conf.select_vlan = 1;
15854 cmdline_parse_inst_t cmd_set_l2_decap = {
15855 .f = cmd_set_l2_decap_parsed,
15857 .help_str = "set l2_decap",
15859 (void *)&cmd_set_l2_decap_set,
15860 (void *)&cmd_set_l2_decap_l2_decap,
15865 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
15866 .f = cmd_set_l2_decap_parsed,
15868 .help_str = "set l2_decap-with-vlan",
15870 (void *)&cmd_set_l2_decap_set,
15871 (void *)&cmd_set_l2_decap_l2_decap_with_vlan,
15876 /** Set MPLSoGRE encapsulation details */
15877 struct cmd_set_mplsogre_encap_result {
15878 cmdline_fixed_string_t set;
15879 cmdline_fixed_string_t mplsogre;
15880 cmdline_fixed_string_t pos_token;
15881 cmdline_fixed_string_t ip_version;
15882 uint32_t vlan_present:1;
15884 cmdline_ipaddr_t ip_src;
15885 cmdline_ipaddr_t ip_dst;
15887 struct rte_ether_addr eth_src;
15888 struct rte_ether_addr eth_dst;
15891 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
15892 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
15894 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
15895 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
15897 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
15898 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15899 mplsogre, "mplsogre_encap-with-vlan");
15900 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
15901 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15902 pos_token, "ip-version");
15903 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
15904 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15905 ip_version, "ipv4#ipv6");
15906 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
15907 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15908 pos_token, "label");
15909 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
15910 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
15912 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
15913 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15914 pos_token, "ip-src");
15915 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
15916 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
15917 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
15918 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15919 pos_token, "ip-dst");
15920 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
15921 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
15922 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
15923 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15924 pos_token, "vlan-tci");
15925 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
15926 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
15928 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
15929 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15930 pos_token, "eth-src");
15931 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
15932 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15934 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
15935 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15936 pos_token, "eth-dst");
15937 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
15938 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15941 static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
15942 __attribute__((unused)) struct cmdline *cl,
15943 __attribute__((unused)) void *data)
15945 struct cmd_set_mplsogre_encap_result *res = parsed_result;
15947 uint32_t mplsogre_label;
15950 .mplsogre_label = rte_cpu_to_be_32(res->label<<12),
15953 if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
15954 mplsogre_encap_conf.select_vlan = 0;
15955 else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
15956 mplsogre_encap_conf.select_vlan = 1;
15957 if (strcmp(res->ip_version, "ipv4") == 0)
15958 mplsogre_encap_conf.select_ipv4 = 1;
15959 else if (strcmp(res->ip_version, "ipv6") == 0)
15960 mplsogre_encap_conf.select_ipv4 = 0;
15963 rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
15964 if (mplsogre_encap_conf.select_ipv4) {
15965 IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
15966 IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
15968 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
15969 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
15971 if (mplsogre_encap_conf.select_vlan)
15972 mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15973 rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
15974 RTE_ETHER_ADDR_LEN);
15975 rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15976 RTE_ETHER_ADDR_LEN);
15979 cmdline_parse_inst_t cmd_set_mplsogre_encap = {
15980 .f = cmd_set_mplsogre_encap_parsed,
15982 .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
15983 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15984 " eth-dst <eth-dst>",
15986 (void *)&cmd_set_mplsogre_encap_set,
15987 (void *)&cmd_set_mplsogre_encap_mplsogre_encap,
15988 (void *)&cmd_set_mplsogre_encap_ip_version,
15989 (void *)&cmd_set_mplsogre_encap_ip_version_value,
15990 (void *)&cmd_set_mplsogre_encap_label,
15991 (void *)&cmd_set_mplsogre_encap_label_value,
15992 (void *)&cmd_set_mplsogre_encap_ip_src,
15993 (void *)&cmd_set_mplsogre_encap_ip_src_value,
15994 (void *)&cmd_set_mplsogre_encap_ip_dst,
15995 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
15996 (void *)&cmd_set_mplsogre_encap_eth_src,
15997 (void *)&cmd_set_mplsogre_encap_eth_src_value,
15998 (void *)&cmd_set_mplsogre_encap_eth_dst,
15999 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
16004 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
16005 .f = cmd_set_mplsogre_encap_parsed,
16007 .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
16008 " label <label> ip-src <ip-src> ip-dst <ip-dst>"
16009 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
16011 (void *)&cmd_set_mplsogre_encap_set,
16012 (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
16013 (void *)&cmd_set_mplsogre_encap_ip_version,
16014 (void *)&cmd_set_mplsogre_encap_ip_version_value,
16015 (void *)&cmd_set_mplsogre_encap_label,
16016 (void *)&cmd_set_mplsogre_encap_label_value,
16017 (void *)&cmd_set_mplsogre_encap_ip_src,
16018 (void *)&cmd_set_mplsogre_encap_ip_src_value,
16019 (void *)&cmd_set_mplsogre_encap_ip_dst,
16020 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
16021 (void *)&cmd_set_mplsogre_encap_vlan,
16022 (void *)&cmd_set_mplsogre_encap_vlan_value,
16023 (void *)&cmd_set_mplsogre_encap_eth_src,
16024 (void *)&cmd_set_mplsogre_encap_eth_src_value,
16025 (void *)&cmd_set_mplsogre_encap_eth_dst,
16026 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
16031 /** Set MPLSoGRE decapsulation details */
16032 struct cmd_set_mplsogre_decap_result {
16033 cmdline_fixed_string_t set;
16034 cmdline_fixed_string_t mplsogre;
16035 cmdline_fixed_string_t pos_token;
16036 cmdline_fixed_string_t ip_version;
16037 uint32_t vlan_present:1;
16040 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
16041 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
16043 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
16044 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
16046 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
16047 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
16048 mplsogre, "mplsogre_decap-with-vlan");
16049 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
16050 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
16051 pos_token, "ip-version");
16052 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
16053 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
16054 ip_version, "ipv4#ipv6");
16056 static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
16057 __attribute__((unused)) struct cmdline *cl,
16058 __attribute__((unused)) void *data)
16060 struct cmd_set_mplsogre_decap_result *res = parsed_result;
16062 if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
16063 mplsogre_decap_conf.select_vlan = 0;
16064 else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
16065 mplsogre_decap_conf.select_vlan = 1;
16066 if (strcmp(res->ip_version, "ipv4") == 0)
16067 mplsogre_decap_conf.select_ipv4 = 1;
16068 else if (strcmp(res->ip_version, "ipv6") == 0)
16069 mplsogre_decap_conf.select_ipv4 = 0;
16072 cmdline_parse_inst_t cmd_set_mplsogre_decap = {
16073 .f = cmd_set_mplsogre_decap_parsed,
16075 .help_str = "set mplsogre_decap ip-version ipv4|ipv6",
16077 (void *)&cmd_set_mplsogre_decap_set,
16078 (void *)&cmd_set_mplsogre_decap_mplsogre_decap,
16079 (void *)&cmd_set_mplsogre_decap_ip_version,
16080 (void *)&cmd_set_mplsogre_decap_ip_version_value,
16085 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
16086 .f = cmd_set_mplsogre_decap_parsed,
16088 .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
16090 (void *)&cmd_set_mplsogre_decap_set,
16091 (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
16092 (void *)&cmd_set_mplsogre_decap_ip_version,
16093 (void *)&cmd_set_mplsogre_decap_ip_version_value,
16098 /** Set MPLSoUDP encapsulation details */
16099 struct cmd_set_mplsoudp_encap_result {
16100 cmdline_fixed_string_t set;
16101 cmdline_fixed_string_t mplsoudp;
16102 cmdline_fixed_string_t pos_token;
16103 cmdline_fixed_string_t ip_version;
16104 uint32_t vlan_present:1;
16108 cmdline_ipaddr_t ip_src;
16109 cmdline_ipaddr_t ip_dst;
16111 struct rte_ether_addr eth_src;
16112 struct rte_ether_addr eth_dst;
16115 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
16116 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
16118 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
16119 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
16121 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
16122 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16123 mplsoudp, "mplsoudp_encap-with-vlan");
16124 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
16125 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16126 pos_token, "ip-version");
16127 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
16128 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16129 ip_version, "ipv4#ipv6");
16130 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
16131 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16132 pos_token, "label");
16133 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
16134 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
16136 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
16137 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16138 pos_token, "udp-src");
16139 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
16140 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
16142 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
16143 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16144 pos_token, "udp-dst");
16145 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
16146 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
16148 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
16149 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16150 pos_token, "ip-src");
16151 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
16152 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
16153 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
16154 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16155 pos_token, "ip-dst");
16156 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
16157 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
16158 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
16159 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16160 pos_token, "vlan-tci");
16161 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
16162 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
16164 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
16165 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16166 pos_token, "eth-src");
16167 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
16168 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16170 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
16171 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16172 pos_token, "eth-dst");
16173 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
16174 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16177 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
16178 __attribute__((unused)) struct cmdline *cl,
16179 __attribute__((unused)) void *data)
16181 struct cmd_set_mplsoudp_encap_result *res = parsed_result;
16183 uint32_t mplsoudp_label;
16186 .mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
16189 if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
16190 mplsoudp_encap_conf.select_vlan = 0;
16191 else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
16192 mplsoudp_encap_conf.select_vlan = 1;
16193 if (strcmp(res->ip_version, "ipv4") == 0)
16194 mplsoudp_encap_conf.select_ipv4 = 1;
16195 else if (strcmp(res->ip_version, "ipv6") == 0)
16196 mplsoudp_encap_conf.select_ipv4 = 0;
16199 rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
16200 mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
16201 mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
16202 if (mplsoudp_encap_conf.select_ipv4) {
16203 IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
16204 IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
16206 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
16207 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
16209 if (mplsoudp_encap_conf.select_vlan)
16210 mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
16211 rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
16212 RTE_ETHER_ADDR_LEN);
16213 rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
16214 RTE_ETHER_ADDR_LEN);
16217 cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
16218 .f = cmd_set_mplsoudp_encap_parsed,
16220 .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
16221 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
16222 " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
16224 (void *)&cmd_set_mplsoudp_encap_set,
16225 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
16226 (void *)&cmd_set_mplsoudp_encap_ip_version,
16227 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
16228 (void *)&cmd_set_mplsoudp_encap_label,
16229 (void *)&cmd_set_mplsoudp_encap_label_value,
16230 (void *)&cmd_set_mplsoudp_encap_udp_src,
16231 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
16232 (void *)&cmd_set_mplsoudp_encap_udp_dst,
16233 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
16234 (void *)&cmd_set_mplsoudp_encap_ip_src,
16235 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
16236 (void *)&cmd_set_mplsoudp_encap_ip_dst,
16237 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
16238 (void *)&cmd_set_mplsoudp_encap_eth_src,
16239 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
16240 (void *)&cmd_set_mplsoudp_encap_eth_dst,
16241 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
16246 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
16247 .f = cmd_set_mplsoudp_encap_parsed,
16249 .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
16250 " label <label> udp-src <udp-src> udp-dst <udp-dst>"
16251 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
16252 " eth-src <eth-src> eth-dst <eth-dst>",
16254 (void *)&cmd_set_mplsoudp_encap_set,
16255 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
16256 (void *)&cmd_set_mplsoudp_encap_ip_version,
16257 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
16258 (void *)&cmd_set_mplsoudp_encap_label,
16259 (void *)&cmd_set_mplsoudp_encap_label_value,
16260 (void *)&cmd_set_mplsoudp_encap_udp_src,
16261 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
16262 (void *)&cmd_set_mplsoudp_encap_udp_dst,
16263 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
16264 (void *)&cmd_set_mplsoudp_encap_ip_src,
16265 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
16266 (void *)&cmd_set_mplsoudp_encap_ip_dst,
16267 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
16268 (void *)&cmd_set_mplsoudp_encap_vlan,
16269 (void *)&cmd_set_mplsoudp_encap_vlan_value,
16270 (void *)&cmd_set_mplsoudp_encap_eth_src,
16271 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
16272 (void *)&cmd_set_mplsoudp_encap_eth_dst,
16273 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
16278 /** Set MPLSoUDP decapsulation details */
16279 struct cmd_set_mplsoudp_decap_result {
16280 cmdline_fixed_string_t set;
16281 cmdline_fixed_string_t mplsoudp;
16282 cmdline_fixed_string_t pos_token;
16283 cmdline_fixed_string_t ip_version;
16284 uint32_t vlan_present:1;
16287 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
16288 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
16290 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
16291 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
16293 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
16294 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16295 mplsoudp, "mplsoudp_decap-with-vlan");
16296 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
16297 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16298 pos_token, "ip-version");
16299 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
16300 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16301 ip_version, "ipv4#ipv6");
16303 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
16304 __attribute__((unused)) struct cmdline *cl,
16305 __attribute__((unused)) void *data)
16307 struct cmd_set_mplsoudp_decap_result *res = parsed_result;
16309 if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
16310 mplsoudp_decap_conf.select_vlan = 0;
16311 else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
16312 mplsoudp_decap_conf.select_vlan = 1;
16313 if (strcmp(res->ip_version, "ipv4") == 0)
16314 mplsoudp_decap_conf.select_ipv4 = 1;
16315 else if (strcmp(res->ip_version, "ipv6") == 0)
16316 mplsoudp_decap_conf.select_ipv4 = 0;
16319 cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
16320 .f = cmd_set_mplsoudp_decap_parsed,
16322 .help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
16324 (void *)&cmd_set_mplsoudp_decap_set,
16325 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
16326 (void *)&cmd_set_mplsoudp_decap_ip_version,
16327 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
16332 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
16333 .f = cmd_set_mplsoudp_decap_parsed,
16335 .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
16337 (void *)&cmd_set_mplsoudp_decap_set,
16338 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
16339 (void *)&cmd_set_mplsoudp_decap_ip_version,
16340 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
16345 /* Strict link priority scheduling mode setting */
16347 cmd_strict_link_prio_parsed(
16348 void *parsed_result,
16349 __attribute__((unused)) struct cmdline *cl,
16350 __attribute__((unused)) void *data)
16352 struct cmd_vf_tc_bw_result *res = parsed_result;
16353 int ret = -ENOTSUP;
16355 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16358 #ifdef RTE_LIBRTE_I40E_PMD
16359 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
16366 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
16369 printf("invalid port_id %d\n", res->port_id);
16372 printf("function not implemented\n");
16375 printf("programming error: (%s)\n", strerror(-ret));
16379 cmdline_parse_inst_t cmd_strict_link_prio = {
16380 .f = cmd_strict_link_prio_parsed,
16382 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
16384 (void *)&cmd_vf_tc_bw_set,
16385 (void *)&cmd_vf_tc_bw_tx,
16386 (void *)&cmd_vf_tc_bw_strict_link_prio,
16387 (void *)&cmd_vf_tc_bw_port_id,
16388 (void *)&cmd_vf_tc_bw_tc_map,
16393 /* Load dynamic device personalization*/
16394 struct cmd_ddp_add_result {
16395 cmdline_fixed_string_t ddp;
16396 cmdline_fixed_string_t add;
16401 cmdline_parse_token_string_t cmd_ddp_add_ddp =
16402 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
16403 cmdline_parse_token_string_t cmd_ddp_add_add =
16404 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
16405 cmdline_parse_token_num_t cmd_ddp_add_port_id =
16406 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
16407 cmdline_parse_token_string_t cmd_ddp_add_filepath =
16408 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
16411 cmd_ddp_add_parsed(
16412 void *parsed_result,
16413 __attribute__((unused)) struct cmdline *cl,
16414 __attribute__((unused)) void *data)
16416 struct cmd_ddp_add_result *res = parsed_result;
16422 int ret = -ENOTSUP;
16424 if (!all_ports_stopped()) {
16425 printf("Please stop all ports first\n");
16429 filepath = strdup(res->filepath);
16430 if (filepath == NULL) {
16431 printf("Failed to allocate memory\n");
16434 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
16436 buff = open_file(file_fld[0], &size);
16438 free((void *)filepath);
16442 #ifdef RTE_LIBRTE_I40E_PMD
16443 if (ret == -ENOTSUP)
16444 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16446 RTE_PMD_I40E_PKG_OP_WR_ADD);
16449 if (ret == -EEXIST)
16450 printf("Profile has already existed.\n");
16452 printf("Failed to load profile.\n");
16453 else if (file_num == 2)
16454 save_file(file_fld[1], buff, size);
16457 free((void *)filepath);
16460 cmdline_parse_inst_t cmd_ddp_add = {
16461 .f = cmd_ddp_add_parsed,
16463 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
16465 (void *)&cmd_ddp_add_ddp,
16466 (void *)&cmd_ddp_add_add,
16467 (void *)&cmd_ddp_add_port_id,
16468 (void *)&cmd_ddp_add_filepath,
16473 /* Delete dynamic device personalization*/
16474 struct cmd_ddp_del_result {
16475 cmdline_fixed_string_t ddp;
16476 cmdline_fixed_string_t del;
16481 cmdline_parse_token_string_t cmd_ddp_del_ddp =
16482 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
16483 cmdline_parse_token_string_t cmd_ddp_del_del =
16484 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
16485 cmdline_parse_token_num_t cmd_ddp_del_port_id =
16486 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
16487 cmdline_parse_token_string_t cmd_ddp_del_filepath =
16488 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
16491 cmd_ddp_del_parsed(
16492 void *parsed_result,
16493 __attribute__((unused)) struct cmdline *cl,
16494 __attribute__((unused)) void *data)
16496 struct cmd_ddp_del_result *res = parsed_result;
16499 int ret = -ENOTSUP;
16501 if (!all_ports_stopped()) {
16502 printf("Please stop all ports first\n");
16506 buff = open_file(res->filepath, &size);
16510 #ifdef RTE_LIBRTE_I40E_PMD
16511 if (ret == -ENOTSUP)
16512 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16514 RTE_PMD_I40E_PKG_OP_WR_DEL);
16517 if (ret == -EACCES)
16518 printf("Profile does not exist.\n");
16520 printf("Failed to delete profile.\n");
16525 cmdline_parse_inst_t cmd_ddp_del = {
16526 .f = cmd_ddp_del_parsed,
16528 .help_str = "ddp del <port_id> <backup_profile_path>",
16530 (void *)&cmd_ddp_del_ddp,
16531 (void *)&cmd_ddp_del_del,
16532 (void *)&cmd_ddp_del_port_id,
16533 (void *)&cmd_ddp_del_filepath,
16538 /* Get dynamic device personalization profile info */
16539 struct cmd_ddp_info_result {
16540 cmdline_fixed_string_t ddp;
16541 cmdline_fixed_string_t get;
16542 cmdline_fixed_string_t info;
16546 cmdline_parse_token_string_t cmd_ddp_info_ddp =
16547 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
16548 cmdline_parse_token_string_t cmd_ddp_info_get =
16549 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
16550 cmdline_parse_token_string_t cmd_ddp_info_info =
16551 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
16552 cmdline_parse_token_string_t cmd_ddp_info_filepath =
16553 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
16556 cmd_ddp_info_parsed(
16557 void *parsed_result,
16558 __attribute__((unused)) struct cmdline *cl,
16559 __attribute__((unused)) void *data)
16561 struct cmd_ddp_info_result *res = parsed_result;
16564 int ret = -ENOTSUP;
16565 #ifdef RTE_LIBRTE_I40E_PMD
16568 uint32_t buff_size = 0;
16569 struct rte_pmd_i40e_profile_info info;
16570 uint32_t dev_num = 0;
16571 struct rte_pmd_i40e_ddp_device_id *devs;
16572 uint32_t proto_num = 0;
16573 struct rte_pmd_i40e_proto_info *proto = NULL;
16574 uint32_t pctype_num = 0;
16575 struct rte_pmd_i40e_ptype_info *pctype;
16576 uint32_t ptype_num = 0;
16577 struct rte_pmd_i40e_ptype_info *ptype;
16582 pkg = open_file(res->filepath, &pkg_size);
16586 #ifdef RTE_LIBRTE_I40E_PMD
16587 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16588 (uint8_t *)&info, sizeof(info),
16589 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
16591 printf("Global Track id: 0x%x\n", info.track_id);
16592 printf("Global Version: %d.%d.%d.%d\n",
16593 info.version.major,
16594 info.version.minor,
16595 info.version.update,
16596 info.version.draft);
16597 printf("Global Package name: %s\n\n", info.name);
16600 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16601 (uint8_t *)&info, sizeof(info),
16602 RTE_PMD_I40E_PKG_INFO_HEADER);
16604 printf("i40e Profile Track id: 0x%x\n", info.track_id);
16605 printf("i40e Profile Version: %d.%d.%d.%d\n",
16606 info.version.major,
16607 info.version.minor,
16608 info.version.update,
16609 info.version.draft);
16610 printf("i40e Profile name: %s\n\n", info.name);
16613 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16614 (uint8_t *)&buff_size, sizeof(buff_size),
16615 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
16616 if (!ret && buff_size) {
16617 buff = (uint8_t *)malloc(buff_size);
16619 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16621 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
16623 printf("Package Notes:\n%s\n\n", buff);
16628 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16629 (uint8_t *)&dev_num, sizeof(dev_num),
16630 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
16631 if (!ret && dev_num) {
16632 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
16633 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
16635 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16636 (uint8_t *)devs, buff_size,
16637 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
16639 printf("List of supported devices:\n");
16640 for (i = 0; i < dev_num; i++) {
16641 printf(" %04X:%04X %04X:%04X\n",
16642 devs[i].vendor_dev_id >> 16,
16643 devs[i].vendor_dev_id & 0xFFFF,
16644 devs[i].sub_vendor_dev_id >> 16,
16645 devs[i].sub_vendor_dev_id & 0xFFFF);
16653 /* get information about protocols and packet types */
16654 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16655 (uint8_t *)&proto_num, sizeof(proto_num),
16656 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
16657 if (ret || !proto_num)
16658 goto no_print_return;
16660 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
16661 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
16663 goto no_print_return;
16665 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
16667 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
16669 printf("List of used protocols:\n");
16670 for (i = 0; i < proto_num; i++)
16671 printf(" %2u: %s\n", proto[i].proto_id,
16675 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16676 (uint8_t *)&pctype_num, sizeof(pctype_num),
16677 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
16678 if (ret || !pctype_num)
16679 goto no_print_pctypes;
16681 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16682 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16684 goto no_print_pctypes;
16686 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
16688 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
16691 goto no_print_pctypes;
16694 printf("List of defined packet classification types:\n");
16695 for (i = 0; i < pctype_num; i++) {
16696 printf(" %2u:", pctype[i].ptype_id);
16697 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
16698 proto_id = pctype[i].protocols[j];
16699 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
16700 for (n = 0; n < proto_num; n++) {
16701 if (proto[n].proto_id == proto_id) {
16702 printf(" %s", proto[n].name);
16715 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
16717 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
16718 if (ret || !ptype_num)
16719 goto no_print_return;
16721 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16722 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16724 goto no_print_return;
16726 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
16728 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
16731 goto no_print_return;
16733 printf("List of defined packet types:\n");
16734 for (i = 0; i < ptype_num; i++) {
16735 printf(" %2u:", ptype[i].ptype_id);
16736 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
16737 proto_id = ptype[i].protocols[j];
16738 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
16739 for (n = 0; n < proto_num; n++) {
16740 if (proto[n].proto_id == proto_id) {
16741 printf(" %s", proto[n].name);
16757 if (ret == -ENOTSUP)
16758 printf("Function not supported in PMD driver\n");
16762 cmdline_parse_inst_t cmd_ddp_get_info = {
16763 .f = cmd_ddp_info_parsed,
16765 .help_str = "ddp get info <profile_path>",
16767 (void *)&cmd_ddp_info_ddp,
16768 (void *)&cmd_ddp_info_get,
16769 (void *)&cmd_ddp_info_info,
16770 (void *)&cmd_ddp_info_filepath,
16775 /* Get dynamic device personalization profile info list*/
16776 #define PROFILE_INFO_SIZE 48
16777 #define MAX_PROFILE_NUM 16
16779 struct cmd_ddp_get_list_result {
16780 cmdline_fixed_string_t ddp;
16781 cmdline_fixed_string_t get;
16782 cmdline_fixed_string_t list;
16786 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
16787 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
16788 cmdline_parse_token_string_t cmd_ddp_get_list_get =
16789 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
16790 cmdline_parse_token_string_t cmd_ddp_get_list_list =
16791 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
16792 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
16793 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
16796 cmd_ddp_get_list_parsed(
16797 __attribute__((unused)) void *parsed_result,
16798 __attribute__((unused)) struct cmdline *cl,
16799 __attribute__((unused)) void *data)
16801 #ifdef RTE_LIBRTE_I40E_PMD
16802 struct cmd_ddp_get_list_result *res = parsed_result;
16803 struct rte_pmd_i40e_profile_list *p_list;
16804 struct rte_pmd_i40e_profile_info *p_info;
16809 int ret = -ENOTSUP;
16811 #ifdef RTE_LIBRTE_I40E_PMD
16812 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
16813 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
16815 printf("%s: Failed to malloc buffer\n", __func__);
16817 if (ret == -ENOTSUP)
16818 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
16819 (uint8_t *)p_list, size);
16822 p_num = p_list->p_count;
16823 printf("Profile number is: %d\n\n", p_num);
16825 for (i = 0; i < p_num; i++) {
16826 p_info = &p_list->p_info[i];
16827 printf("Profile %d:\n", i);
16828 printf("Track id: 0x%x\n", p_info->track_id);
16829 printf("Version: %d.%d.%d.%d\n",
16830 p_info->version.major,
16831 p_info->version.minor,
16832 p_info->version.update,
16833 p_info->version.draft);
16834 printf("Profile name: %s\n\n", p_info->name);
16842 printf("Failed to get ddp list\n");
16845 cmdline_parse_inst_t cmd_ddp_get_list = {
16846 .f = cmd_ddp_get_list_parsed,
16848 .help_str = "ddp get list <port_id>",
16850 (void *)&cmd_ddp_get_list_ddp,
16851 (void *)&cmd_ddp_get_list_get,
16852 (void *)&cmd_ddp_get_list_list,
16853 (void *)&cmd_ddp_get_list_port_id,
16858 /* Configure input set */
16859 struct cmd_cfg_input_set_result {
16860 cmdline_fixed_string_t port;
16861 cmdline_fixed_string_t cfg;
16863 cmdline_fixed_string_t pctype;
16865 cmdline_fixed_string_t inset_type;
16866 cmdline_fixed_string_t opt;
16867 cmdline_fixed_string_t field;
16872 cmd_cfg_input_set_parsed(
16873 __attribute__((unused)) void *parsed_result,
16874 __attribute__((unused)) struct cmdline *cl,
16875 __attribute__((unused)) void *data)
16877 #ifdef RTE_LIBRTE_I40E_PMD
16878 struct cmd_cfg_input_set_result *res = parsed_result;
16879 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
16880 struct rte_pmd_i40e_inset inset;
16882 int ret = -ENOTSUP;
16884 if (!all_ports_stopped()) {
16885 printf("Please stop all ports first\n");
16889 #ifdef RTE_LIBRTE_I40E_PMD
16890 if (!strcmp(res->inset_type, "hash_inset"))
16891 inset_type = INSET_HASH;
16892 else if (!strcmp(res->inset_type, "fdir_inset"))
16893 inset_type = INSET_FDIR;
16894 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
16895 inset_type = INSET_FDIR_FLX;
16896 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
16897 &inset, inset_type);
16899 printf("Failed to get input set.\n");
16903 if (!strcmp(res->opt, "get")) {
16904 ret = rte_pmd_i40e_inset_field_get(inset.inset,
16907 printf("Field index %d is enabled.\n", res->field_idx);
16909 printf("Field index %d is disabled.\n", res->field_idx);
16911 } else if (!strcmp(res->opt, "set"))
16912 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
16914 else if (!strcmp(res->opt, "clear"))
16915 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
16918 printf("Failed to configure input set field.\n");
16922 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
16923 &inset, inset_type);
16925 printf("Failed to set input set.\n");
16930 if (ret == -ENOTSUP)
16931 printf("Function not supported\n");
16934 cmdline_parse_token_string_t cmd_cfg_input_set_port =
16935 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16937 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
16938 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16940 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
16941 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16943 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
16944 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16946 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
16947 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16949 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
16950 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16952 "hash_inset#fdir_inset#fdir_flx_inset");
16953 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
16954 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16955 opt, "get#set#clear");
16956 cmdline_parse_token_string_t cmd_cfg_input_set_field =
16957 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16959 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
16960 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16963 cmdline_parse_inst_t cmd_cfg_input_set = {
16964 .f = cmd_cfg_input_set_parsed,
16966 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
16967 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
16969 (void *)&cmd_cfg_input_set_port,
16970 (void *)&cmd_cfg_input_set_cfg,
16971 (void *)&cmd_cfg_input_set_port_id,
16972 (void *)&cmd_cfg_input_set_pctype,
16973 (void *)&cmd_cfg_input_set_pctype_id,
16974 (void *)&cmd_cfg_input_set_inset_type,
16975 (void *)&cmd_cfg_input_set_opt,
16976 (void *)&cmd_cfg_input_set_field,
16977 (void *)&cmd_cfg_input_set_field_idx,
16982 /* Clear input set */
16983 struct cmd_clear_input_set_result {
16984 cmdline_fixed_string_t port;
16985 cmdline_fixed_string_t cfg;
16987 cmdline_fixed_string_t pctype;
16989 cmdline_fixed_string_t inset_type;
16990 cmdline_fixed_string_t clear;
16991 cmdline_fixed_string_t all;
16995 cmd_clear_input_set_parsed(
16996 __attribute__((unused)) void *parsed_result,
16997 __attribute__((unused)) struct cmdline *cl,
16998 __attribute__((unused)) void *data)
17000 #ifdef RTE_LIBRTE_I40E_PMD
17001 struct cmd_clear_input_set_result *res = parsed_result;
17002 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
17003 struct rte_pmd_i40e_inset inset;
17005 int ret = -ENOTSUP;
17007 if (!all_ports_stopped()) {
17008 printf("Please stop all ports first\n");
17012 #ifdef RTE_LIBRTE_I40E_PMD
17013 if (!strcmp(res->inset_type, "hash_inset"))
17014 inset_type = INSET_HASH;
17015 else if (!strcmp(res->inset_type, "fdir_inset"))
17016 inset_type = INSET_FDIR;
17017 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
17018 inset_type = INSET_FDIR_FLX;
17020 memset(&inset, 0, sizeof(inset));
17022 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
17023 &inset, inset_type);
17025 printf("Failed to clear input set.\n");
17031 if (ret == -ENOTSUP)
17032 printf("Function not supported\n");
17035 cmdline_parse_token_string_t cmd_clear_input_set_port =
17036 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17038 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
17039 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17041 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
17042 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
17044 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
17045 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17047 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
17048 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
17050 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
17051 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17053 "hash_inset#fdir_inset#fdir_flx_inset");
17054 cmdline_parse_token_string_t cmd_clear_input_set_clear =
17055 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17057 cmdline_parse_token_string_t cmd_clear_input_set_all =
17058 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17061 cmdline_parse_inst_t cmd_clear_input_set = {
17062 .f = cmd_clear_input_set_parsed,
17064 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
17065 "fdir_inset|fdir_flx_inset clear all",
17067 (void *)&cmd_clear_input_set_port,
17068 (void *)&cmd_clear_input_set_cfg,
17069 (void *)&cmd_clear_input_set_port_id,
17070 (void *)&cmd_clear_input_set_pctype,
17071 (void *)&cmd_clear_input_set_pctype_id,
17072 (void *)&cmd_clear_input_set_inset_type,
17073 (void *)&cmd_clear_input_set_clear,
17074 (void *)&cmd_clear_input_set_all,
17079 /* show vf stats */
17081 /* Common result structure for show vf stats */
17082 struct cmd_show_vf_stats_result {
17083 cmdline_fixed_string_t show;
17084 cmdline_fixed_string_t vf;
17085 cmdline_fixed_string_t stats;
17090 /* Common CLI fields show vf stats*/
17091 cmdline_parse_token_string_t cmd_show_vf_stats_show =
17092 TOKEN_STRING_INITIALIZER
17093 (struct cmd_show_vf_stats_result,
17095 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
17096 TOKEN_STRING_INITIALIZER
17097 (struct cmd_show_vf_stats_result,
17099 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
17100 TOKEN_STRING_INITIALIZER
17101 (struct cmd_show_vf_stats_result,
17103 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
17104 TOKEN_NUM_INITIALIZER
17105 (struct cmd_show_vf_stats_result,
17107 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
17108 TOKEN_NUM_INITIALIZER
17109 (struct cmd_show_vf_stats_result,
17113 cmd_show_vf_stats_parsed(
17114 void *parsed_result,
17115 __attribute__((unused)) struct cmdline *cl,
17116 __attribute__((unused)) void *data)
17118 struct cmd_show_vf_stats_result *res = parsed_result;
17119 struct rte_eth_stats stats;
17120 int ret = -ENOTSUP;
17121 static const char *nic_stats_border = "########################";
17123 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17126 memset(&stats, 0, sizeof(stats));
17128 #ifdef RTE_LIBRTE_I40E_PMD
17129 if (ret == -ENOTSUP)
17130 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
17134 #ifdef RTE_LIBRTE_BNXT_PMD
17135 if (ret == -ENOTSUP)
17136 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
17145 printf("invalid vf_id %d\n", res->vf_id);
17148 printf("invalid port_id %d\n", res->port_id);
17151 printf("function not implemented\n");
17154 printf("programming error: (%s)\n", strerror(-ret));
17157 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
17158 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
17160 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
17162 stats.ipackets, stats.imissed, stats.ibytes);
17163 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
17164 printf(" RX-nombuf: %-10"PRIu64"\n",
17166 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
17168 stats.opackets, stats.oerrors, stats.obytes);
17170 printf(" %s############################%s\n",
17171 nic_stats_border, nic_stats_border);
17174 cmdline_parse_inst_t cmd_show_vf_stats = {
17175 .f = cmd_show_vf_stats_parsed,
17177 .help_str = "show vf stats <port_id> <vf_id>",
17179 (void *)&cmd_show_vf_stats_show,
17180 (void *)&cmd_show_vf_stats_vf,
17181 (void *)&cmd_show_vf_stats_stats,
17182 (void *)&cmd_show_vf_stats_port_id,
17183 (void *)&cmd_show_vf_stats_vf_id,
17188 /* clear vf stats */
17190 /* Common result structure for clear vf stats */
17191 struct cmd_clear_vf_stats_result {
17192 cmdline_fixed_string_t clear;
17193 cmdline_fixed_string_t vf;
17194 cmdline_fixed_string_t stats;
17199 /* Common CLI fields clear vf stats*/
17200 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
17201 TOKEN_STRING_INITIALIZER
17202 (struct cmd_clear_vf_stats_result,
17204 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
17205 TOKEN_STRING_INITIALIZER
17206 (struct cmd_clear_vf_stats_result,
17208 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
17209 TOKEN_STRING_INITIALIZER
17210 (struct cmd_clear_vf_stats_result,
17212 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
17213 TOKEN_NUM_INITIALIZER
17214 (struct cmd_clear_vf_stats_result,
17216 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
17217 TOKEN_NUM_INITIALIZER
17218 (struct cmd_clear_vf_stats_result,
17222 cmd_clear_vf_stats_parsed(
17223 void *parsed_result,
17224 __attribute__((unused)) struct cmdline *cl,
17225 __attribute__((unused)) void *data)
17227 struct cmd_clear_vf_stats_result *res = parsed_result;
17228 int ret = -ENOTSUP;
17230 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17233 #ifdef RTE_LIBRTE_I40E_PMD
17234 if (ret == -ENOTSUP)
17235 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
17238 #ifdef RTE_LIBRTE_BNXT_PMD
17239 if (ret == -ENOTSUP)
17240 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
17248 printf("invalid vf_id %d\n", res->vf_id);
17251 printf("invalid port_id %d\n", res->port_id);
17254 printf("function not implemented\n");
17257 printf("programming error: (%s)\n", strerror(-ret));
17261 cmdline_parse_inst_t cmd_clear_vf_stats = {
17262 .f = cmd_clear_vf_stats_parsed,
17264 .help_str = "clear vf stats <port_id> <vf_id>",
17266 (void *)&cmd_clear_vf_stats_clear,
17267 (void *)&cmd_clear_vf_stats_vf,
17268 (void *)&cmd_clear_vf_stats_stats,
17269 (void *)&cmd_clear_vf_stats_port_id,
17270 (void *)&cmd_clear_vf_stats_vf_id,
17275 /* port config pctype mapping reset */
17277 /* Common result structure for port config pctype mapping reset */
17278 struct cmd_pctype_mapping_reset_result {
17279 cmdline_fixed_string_t port;
17280 cmdline_fixed_string_t config;
17282 cmdline_fixed_string_t pctype;
17283 cmdline_fixed_string_t mapping;
17284 cmdline_fixed_string_t reset;
17287 /* Common CLI fields for port config pctype mapping reset*/
17288 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
17289 TOKEN_STRING_INITIALIZER
17290 (struct cmd_pctype_mapping_reset_result,
17292 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
17293 TOKEN_STRING_INITIALIZER
17294 (struct cmd_pctype_mapping_reset_result,
17296 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
17297 TOKEN_NUM_INITIALIZER
17298 (struct cmd_pctype_mapping_reset_result,
17300 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
17301 TOKEN_STRING_INITIALIZER
17302 (struct cmd_pctype_mapping_reset_result,
17304 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
17305 TOKEN_STRING_INITIALIZER
17306 (struct cmd_pctype_mapping_reset_result,
17307 mapping, "mapping");
17308 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
17309 TOKEN_STRING_INITIALIZER
17310 (struct cmd_pctype_mapping_reset_result,
17314 cmd_pctype_mapping_reset_parsed(
17315 void *parsed_result,
17316 __attribute__((unused)) struct cmdline *cl,
17317 __attribute__((unused)) void *data)
17319 struct cmd_pctype_mapping_reset_result *res = parsed_result;
17320 int ret = -ENOTSUP;
17322 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17325 #ifdef RTE_LIBRTE_I40E_PMD
17326 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
17333 printf("invalid port_id %d\n", res->port_id);
17336 printf("function not implemented\n");
17339 printf("programming error: (%s)\n", strerror(-ret));
17343 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
17344 .f = cmd_pctype_mapping_reset_parsed,
17346 .help_str = "port config <port_id> pctype mapping reset",
17348 (void *)&cmd_pctype_mapping_reset_port,
17349 (void *)&cmd_pctype_mapping_reset_config,
17350 (void *)&cmd_pctype_mapping_reset_port_id,
17351 (void *)&cmd_pctype_mapping_reset_pctype,
17352 (void *)&cmd_pctype_mapping_reset_mapping,
17353 (void *)&cmd_pctype_mapping_reset_reset,
17358 /* show port pctype mapping */
17360 /* Common result structure for show port pctype mapping */
17361 struct cmd_pctype_mapping_get_result {
17362 cmdline_fixed_string_t show;
17363 cmdline_fixed_string_t port;
17365 cmdline_fixed_string_t pctype;
17366 cmdline_fixed_string_t mapping;
17369 /* Common CLI fields for pctype mapping get */
17370 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
17371 TOKEN_STRING_INITIALIZER
17372 (struct cmd_pctype_mapping_get_result,
17374 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
17375 TOKEN_STRING_INITIALIZER
17376 (struct cmd_pctype_mapping_get_result,
17378 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
17379 TOKEN_NUM_INITIALIZER
17380 (struct cmd_pctype_mapping_get_result,
17382 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
17383 TOKEN_STRING_INITIALIZER
17384 (struct cmd_pctype_mapping_get_result,
17386 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
17387 TOKEN_STRING_INITIALIZER
17388 (struct cmd_pctype_mapping_get_result,
17389 mapping, "mapping");
17392 cmd_pctype_mapping_get_parsed(
17393 void *parsed_result,
17394 __attribute__((unused)) struct cmdline *cl,
17395 __attribute__((unused)) void *data)
17397 struct cmd_pctype_mapping_get_result *res = parsed_result;
17398 int ret = -ENOTSUP;
17399 #ifdef RTE_LIBRTE_I40E_PMD
17400 struct rte_pmd_i40e_flow_type_mapping
17401 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
17402 int i, j, first_pctype;
17405 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17408 #ifdef RTE_LIBRTE_I40E_PMD
17409 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
17416 printf("invalid port_id %d\n", res->port_id);
17419 printf("function not implemented\n");
17422 printf("programming error: (%s)\n", strerror(-ret));
17426 #ifdef RTE_LIBRTE_I40E_PMD
17427 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
17428 if (mapping[i].pctype != 0ULL) {
17431 printf("pctype: ");
17432 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
17433 if (mapping[i].pctype & (1ULL << j)) {
17434 printf(first_pctype ?
17435 "%02d" : ",%02d", j);
17439 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
17445 cmdline_parse_inst_t cmd_pctype_mapping_get = {
17446 .f = cmd_pctype_mapping_get_parsed,
17448 .help_str = "show port <port_id> pctype mapping",
17450 (void *)&cmd_pctype_mapping_get_show,
17451 (void *)&cmd_pctype_mapping_get_port,
17452 (void *)&cmd_pctype_mapping_get_port_id,
17453 (void *)&cmd_pctype_mapping_get_pctype,
17454 (void *)&cmd_pctype_mapping_get_mapping,
17459 /* port config pctype mapping update */
17461 /* Common result structure for port config pctype mapping update */
17462 struct cmd_pctype_mapping_update_result {
17463 cmdline_fixed_string_t port;
17464 cmdline_fixed_string_t config;
17466 cmdline_fixed_string_t pctype;
17467 cmdline_fixed_string_t mapping;
17468 cmdline_fixed_string_t update;
17469 cmdline_fixed_string_t pctype_list;
17470 uint16_t flow_type;
17473 /* Common CLI fields for pctype mapping update*/
17474 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
17475 TOKEN_STRING_INITIALIZER
17476 (struct cmd_pctype_mapping_update_result,
17478 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
17479 TOKEN_STRING_INITIALIZER
17480 (struct cmd_pctype_mapping_update_result,
17482 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
17483 TOKEN_NUM_INITIALIZER
17484 (struct cmd_pctype_mapping_update_result,
17486 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
17487 TOKEN_STRING_INITIALIZER
17488 (struct cmd_pctype_mapping_update_result,
17490 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
17491 TOKEN_STRING_INITIALIZER
17492 (struct cmd_pctype_mapping_update_result,
17493 mapping, "mapping");
17494 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
17495 TOKEN_STRING_INITIALIZER
17496 (struct cmd_pctype_mapping_update_result,
17498 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
17499 TOKEN_STRING_INITIALIZER
17500 (struct cmd_pctype_mapping_update_result,
17501 pctype_list, NULL);
17502 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
17503 TOKEN_NUM_INITIALIZER
17504 (struct cmd_pctype_mapping_update_result,
17505 flow_type, UINT16);
17508 cmd_pctype_mapping_update_parsed(
17509 void *parsed_result,
17510 __attribute__((unused)) struct cmdline *cl,
17511 __attribute__((unused)) void *data)
17513 struct cmd_pctype_mapping_update_result *res = parsed_result;
17514 int ret = -ENOTSUP;
17515 #ifdef RTE_LIBRTE_I40E_PMD
17516 struct rte_pmd_i40e_flow_type_mapping mapping;
17518 unsigned int nb_item;
17519 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
17522 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17525 #ifdef RTE_LIBRTE_I40E_PMD
17526 nb_item = parse_item_list(res->pctype_list, "pctypes",
17527 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
17528 mapping.flow_type = res->flow_type;
17529 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
17530 mapping.pctype |= (1ULL << pctype_list[i]);
17531 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
17541 printf("invalid pctype or flow type\n");
17544 printf("invalid port_id %d\n", res->port_id);
17547 printf("function not implemented\n");
17550 printf("programming error: (%s)\n", strerror(-ret));
17554 cmdline_parse_inst_t cmd_pctype_mapping_update = {
17555 .f = cmd_pctype_mapping_update_parsed,
17557 .help_str = "port config <port_id> pctype mapping update"
17558 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
17560 (void *)&cmd_pctype_mapping_update_port,
17561 (void *)&cmd_pctype_mapping_update_config,
17562 (void *)&cmd_pctype_mapping_update_port_id,
17563 (void *)&cmd_pctype_mapping_update_pctype,
17564 (void *)&cmd_pctype_mapping_update_mapping,
17565 (void *)&cmd_pctype_mapping_update_update,
17566 (void *)&cmd_pctype_mapping_update_pc_type,
17567 (void *)&cmd_pctype_mapping_update_flow_type,
17572 /* ptype mapping get */
17574 /* Common result structure for ptype mapping get */
17575 struct cmd_ptype_mapping_get_result {
17576 cmdline_fixed_string_t ptype;
17577 cmdline_fixed_string_t mapping;
17578 cmdline_fixed_string_t get;
17580 uint8_t valid_only;
17583 /* Common CLI fields for ptype mapping get */
17584 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
17585 TOKEN_STRING_INITIALIZER
17586 (struct cmd_ptype_mapping_get_result,
17588 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
17589 TOKEN_STRING_INITIALIZER
17590 (struct cmd_ptype_mapping_get_result,
17591 mapping, "mapping");
17592 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
17593 TOKEN_STRING_INITIALIZER
17594 (struct cmd_ptype_mapping_get_result,
17596 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
17597 TOKEN_NUM_INITIALIZER
17598 (struct cmd_ptype_mapping_get_result,
17600 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
17601 TOKEN_NUM_INITIALIZER
17602 (struct cmd_ptype_mapping_get_result,
17603 valid_only, UINT8);
17606 cmd_ptype_mapping_get_parsed(
17607 void *parsed_result,
17608 __attribute__((unused)) struct cmdline *cl,
17609 __attribute__((unused)) void *data)
17611 struct cmd_ptype_mapping_get_result *res = parsed_result;
17612 int ret = -ENOTSUP;
17613 #ifdef RTE_LIBRTE_I40E_PMD
17614 int max_ptype_num = 256;
17615 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
17620 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17623 #ifdef RTE_LIBRTE_I40E_PMD
17624 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
17635 printf("invalid port_id %d\n", res->port_id);
17638 printf("function not implemented\n");
17641 printf("programming error: (%s)\n", strerror(-ret));
17644 #ifdef RTE_LIBRTE_I40E_PMD
17646 for (i = 0; i < count; i++)
17647 printf("%3d\t0x%08x\n",
17648 mapping[i].hw_ptype, mapping[i].sw_ptype);
17653 cmdline_parse_inst_t cmd_ptype_mapping_get = {
17654 .f = cmd_ptype_mapping_get_parsed,
17656 .help_str = "ptype mapping get <port_id> <valid_only>",
17658 (void *)&cmd_ptype_mapping_get_ptype,
17659 (void *)&cmd_ptype_mapping_get_mapping,
17660 (void *)&cmd_ptype_mapping_get_get,
17661 (void *)&cmd_ptype_mapping_get_port_id,
17662 (void *)&cmd_ptype_mapping_get_valid_only,
17667 /* ptype mapping replace */
17669 /* Common result structure for ptype mapping replace */
17670 struct cmd_ptype_mapping_replace_result {
17671 cmdline_fixed_string_t ptype;
17672 cmdline_fixed_string_t mapping;
17673 cmdline_fixed_string_t replace;
17680 /* Common CLI fields for ptype mapping replace */
17681 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
17682 TOKEN_STRING_INITIALIZER
17683 (struct cmd_ptype_mapping_replace_result,
17685 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
17686 TOKEN_STRING_INITIALIZER
17687 (struct cmd_ptype_mapping_replace_result,
17688 mapping, "mapping");
17689 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
17690 TOKEN_STRING_INITIALIZER
17691 (struct cmd_ptype_mapping_replace_result,
17692 replace, "replace");
17693 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
17694 TOKEN_NUM_INITIALIZER
17695 (struct cmd_ptype_mapping_replace_result,
17697 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
17698 TOKEN_NUM_INITIALIZER
17699 (struct cmd_ptype_mapping_replace_result,
17701 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
17702 TOKEN_NUM_INITIALIZER
17703 (struct cmd_ptype_mapping_replace_result,
17705 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
17706 TOKEN_NUM_INITIALIZER
17707 (struct cmd_ptype_mapping_replace_result,
17711 cmd_ptype_mapping_replace_parsed(
17712 void *parsed_result,
17713 __attribute__((unused)) struct cmdline *cl,
17714 __attribute__((unused)) void *data)
17716 struct cmd_ptype_mapping_replace_result *res = parsed_result;
17717 int ret = -ENOTSUP;
17719 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17722 #ifdef RTE_LIBRTE_I40E_PMD
17723 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
17733 printf("invalid ptype 0x%8x or 0x%8x\n",
17734 res->target, res->pkt_type);
17737 printf("invalid port_id %d\n", res->port_id);
17740 printf("function not implemented\n");
17743 printf("programming error: (%s)\n", strerror(-ret));
17747 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
17748 .f = cmd_ptype_mapping_replace_parsed,
17751 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
17753 (void *)&cmd_ptype_mapping_replace_ptype,
17754 (void *)&cmd_ptype_mapping_replace_mapping,
17755 (void *)&cmd_ptype_mapping_replace_replace,
17756 (void *)&cmd_ptype_mapping_replace_port_id,
17757 (void *)&cmd_ptype_mapping_replace_target,
17758 (void *)&cmd_ptype_mapping_replace_mask,
17759 (void *)&cmd_ptype_mapping_replace_pkt_type,
17764 /* ptype mapping reset */
17766 /* Common result structure for ptype mapping reset */
17767 struct cmd_ptype_mapping_reset_result {
17768 cmdline_fixed_string_t ptype;
17769 cmdline_fixed_string_t mapping;
17770 cmdline_fixed_string_t reset;
17774 /* Common CLI fields for ptype mapping reset*/
17775 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
17776 TOKEN_STRING_INITIALIZER
17777 (struct cmd_ptype_mapping_reset_result,
17779 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
17780 TOKEN_STRING_INITIALIZER
17781 (struct cmd_ptype_mapping_reset_result,
17782 mapping, "mapping");
17783 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
17784 TOKEN_STRING_INITIALIZER
17785 (struct cmd_ptype_mapping_reset_result,
17787 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
17788 TOKEN_NUM_INITIALIZER
17789 (struct cmd_ptype_mapping_reset_result,
17793 cmd_ptype_mapping_reset_parsed(
17794 void *parsed_result,
17795 __attribute__((unused)) struct cmdline *cl,
17796 __attribute__((unused)) void *data)
17798 struct cmd_ptype_mapping_reset_result *res = parsed_result;
17799 int ret = -ENOTSUP;
17801 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17804 #ifdef RTE_LIBRTE_I40E_PMD
17805 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
17812 printf("invalid port_id %d\n", res->port_id);
17815 printf("function not implemented\n");
17818 printf("programming error: (%s)\n", strerror(-ret));
17822 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
17823 .f = cmd_ptype_mapping_reset_parsed,
17825 .help_str = "ptype mapping reset <port_id>",
17827 (void *)&cmd_ptype_mapping_reset_ptype,
17828 (void *)&cmd_ptype_mapping_reset_mapping,
17829 (void *)&cmd_ptype_mapping_reset_reset,
17830 (void *)&cmd_ptype_mapping_reset_port_id,
17835 /* ptype mapping update */
17837 /* Common result structure for ptype mapping update */
17838 struct cmd_ptype_mapping_update_result {
17839 cmdline_fixed_string_t ptype;
17840 cmdline_fixed_string_t mapping;
17841 cmdline_fixed_string_t reset;
17847 /* Common CLI fields for ptype mapping update*/
17848 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
17849 TOKEN_STRING_INITIALIZER
17850 (struct cmd_ptype_mapping_update_result,
17852 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
17853 TOKEN_STRING_INITIALIZER
17854 (struct cmd_ptype_mapping_update_result,
17855 mapping, "mapping");
17856 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
17857 TOKEN_STRING_INITIALIZER
17858 (struct cmd_ptype_mapping_update_result,
17860 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
17861 TOKEN_NUM_INITIALIZER
17862 (struct cmd_ptype_mapping_update_result,
17864 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
17865 TOKEN_NUM_INITIALIZER
17866 (struct cmd_ptype_mapping_update_result,
17868 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
17869 TOKEN_NUM_INITIALIZER
17870 (struct cmd_ptype_mapping_update_result,
17874 cmd_ptype_mapping_update_parsed(
17875 void *parsed_result,
17876 __attribute__((unused)) struct cmdline *cl,
17877 __attribute__((unused)) void *data)
17879 struct cmd_ptype_mapping_update_result *res = parsed_result;
17880 int ret = -ENOTSUP;
17881 #ifdef RTE_LIBRTE_I40E_PMD
17882 struct rte_pmd_i40e_ptype_mapping mapping;
17884 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17887 #ifdef RTE_LIBRTE_I40E_PMD
17888 mapping.hw_ptype = res->hw_ptype;
17889 mapping.sw_ptype = res->sw_ptype;
17890 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
17900 printf("invalid ptype 0x%8x\n", res->sw_ptype);
17903 printf("invalid port_id %d\n", res->port_id);
17906 printf("function not implemented\n");
17909 printf("programming error: (%s)\n", strerror(-ret));
17913 cmdline_parse_inst_t cmd_ptype_mapping_update = {
17914 .f = cmd_ptype_mapping_update_parsed,
17916 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
17918 (void *)&cmd_ptype_mapping_update_ptype,
17919 (void *)&cmd_ptype_mapping_update_mapping,
17920 (void *)&cmd_ptype_mapping_update_update,
17921 (void *)&cmd_ptype_mapping_update_port_id,
17922 (void *)&cmd_ptype_mapping_update_hw_ptype,
17923 (void *)&cmd_ptype_mapping_update_sw_ptype,
17928 /* Common result structure for file commands */
17929 struct cmd_cmdfile_result {
17930 cmdline_fixed_string_t load;
17931 cmdline_fixed_string_t filename;
17934 /* Common CLI fields for file commands */
17935 cmdline_parse_token_string_t cmd_load_cmdfile =
17936 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
17937 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
17938 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
17941 cmd_load_from_file_parsed(
17942 void *parsed_result,
17943 __attribute__((unused)) struct cmdline *cl,
17944 __attribute__((unused)) void *data)
17946 struct cmd_cmdfile_result *res = parsed_result;
17948 cmdline_read_from_file(res->filename);
17951 cmdline_parse_inst_t cmd_load_from_file = {
17952 .f = cmd_load_from_file_parsed,
17954 .help_str = "load <filename>",
17956 (void *)&cmd_load_cmdfile,
17957 (void *)&cmd_load_cmdfile_filename,
17962 /* Get Rx offloads capabilities */
17963 struct cmd_rx_offload_get_capa_result {
17964 cmdline_fixed_string_t show;
17965 cmdline_fixed_string_t port;
17967 cmdline_fixed_string_t rx_offload;
17968 cmdline_fixed_string_t capabilities;
17971 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
17972 TOKEN_STRING_INITIALIZER
17973 (struct cmd_rx_offload_get_capa_result,
17975 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
17976 TOKEN_STRING_INITIALIZER
17977 (struct cmd_rx_offload_get_capa_result,
17979 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
17980 TOKEN_NUM_INITIALIZER
17981 (struct cmd_rx_offload_get_capa_result,
17983 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
17984 TOKEN_STRING_INITIALIZER
17985 (struct cmd_rx_offload_get_capa_result,
17986 rx_offload, "rx_offload");
17987 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
17988 TOKEN_STRING_INITIALIZER
17989 (struct cmd_rx_offload_get_capa_result,
17990 capabilities, "capabilities");
17993 print_rx_offloads(uint64_t offloads)
17995 uint64_t single_offload;
18003 begin = __builtin_ctzll(offloads);
18004 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
18006 single_offload = 1ULL << begin;
18007 for (bit = begin; bit < end; bit++) {
18008 if (offloads & single_offload)
18010 rte_eth_dev_rx_offload_name(single_offload));
18011 single_offload <<= 1;
18016 cmd_rx_offload_get_capa_parsed(
18017 void *parsed_result,
18018 __attribute__((unused)) struct cmdline *cl,
18019 __attribute__((unused)) void *data)
18021 struct cmd_rx_offload_get_capa_result *res = parsed_result;
18022 struct rte_eth_dev_info dev_info;
18023 portid_t port_id = res->port_id;
18024 uint64_t queue_offloads;
18025 uint64_t port_offloads;
18028 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18032 queue_offloads = dev_info.rx_queue_offload_capa;
18033 port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
18035 printf("Rx Offloading Capabilities of port %d :\n", port_id);
18036 printf(" Per Queue :");
18037 print_rx_offloads(queue_offloads);
18040 printf(" Per Port :");
18041 print_rx_offloads(port_offloads);
18045 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
18046 .f = cmd_rx_offload_get_capa_parsed,
18048 .help_str = "show port <port_id> rx_offload capabilities",
18050 (void *)&cmd_rx_offload_get_capa_show,
18051 (void *)&cmd_rx_offload_get_capa_port,
18052 (void *)&cmd_rx_offload_get_capa_port_id,
18053 (void *)&cmd_rx_offload_get_capa_rx_offload,
18054 (void *)&cmd_rx_offload_get_capa_capabilities,
18059 /* Get Rx offloads configuration */
18060 struct cmd_rx_offload_get_configuration_result {
18061 cmdline_fixed_string_t show;
18062 cmdline_fixed_string_t port;
18064 cmdline_fixed_string_t rx_offload;
18065 cmdline_fixed_string_t configuration;
18068 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
18069 TOKEN_STRING_INITIALIZER
18070 (struct cmd_rx_offload_get_configuration_result,
18072 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
18073 TOKEN_STRING_INITIALIZER
18074 (struct cmd_rx_offload_get_configuration_result,
18076 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
18077 TOKEN_NUM_INITIALIZER
18078 (struct cmd_rx_offload_get_configuration_result,
18080 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
18081 TOKEN_STRING_INITIALIZER
18082 (struct cmd_rx_offload_get_configuration_result,
18083 rx_offload, "rx_offload");
18084 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
18085 TOKEN_STRING_INITIALIZER
18086 (struct cmd_rx_offload_get_configuration_result,
18087 configuration, "configuration");
18090 cmd_rx_offload_get_configuration_parsed(
18091 void *parsed_result,
18092 __attribute__((unused)) struct cmdline *cl,
18093 __attribute__((unused)) void *data)
18095 struct cmd_rx_offload_get_configuration_result *res = parsed_result;
18096 struct rte_eth_dev_info dev_info;
18097 portid_t port_id = res->port_id;
18098 struct rte_port *port = &ports[port_id];
18099 uint64_t port_offloads;
18100 uint64_t queue_offloads;
18101 uint16_t nb_rx_queues;
18105 printf("Rx Offloading Configuration of port %d :\n", port_id);
18107 port_offloads = port->dev_conf.rxmode.offloads;
18109 print_rx_offloads(port_offloads);
18112 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18116 nb_rx_queues = dev_info.nb_rx_queues;
18117 for (q = 0; q < nb_rx_queues; q++) {
18118 queue_offloads = port->rx_conf[q].offloads;
18119 printf(" Queue[%2d] :", q);
18120 print_rx_offloads(queue_offloads);
18126 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
18127 .f = cmd_rx_offload_get_configuration_parsed,
18129 .help_str = "show port <port_id> rx_offload configuration",
18131 (void *)&cmd_rx_offload_get_configuration_show,
18132 (void *)&cmd_rx_offload_get_configuration_port,
18133 (void *)&cmd_rx_offload_get_configuration_port_id,
18134 (void *)&cmd_rx_offload_get_configuration_rx_offload,
18135 (void *)&cmd_rx_offload_get_configuration_configuration,
18140 /* Enable/Disable a per port offloading */
18141 struct cmd_config_per_port_rx_offload_result {
18142 cmdline_fixed_string_t port;
18143 cmdline_fixed_string_t config;
18145 cmdline_fixed_string_t rx_offload;
18146 cmdline_fixed_string_t offload;
18147 cmdline_fixed_string_t on_off;
18150 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
18151 TOKEN_STRING_INITIALIZER
18152 (struct cmd_config_per_port_rx_offload_result,
18154 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
18155 TOKEN_STRING_INITIALIZER
18156 (struct cmd_config_per_port_rx_offload_result,
18158 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
18159 TOKEN_NUM_INITIALIZER
18160 (struct cmd_config_per_port_rx_offload_result,
18162 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
18163 TOKEN_STRING_INITIALIZER
18164 (struct cmd_config_per_port_rx_offload_result,
18165 rx_offload, "rx_offload");
18166 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
18167 TOKEN_STRING_INITIALIZER
18168 (struct cmd_config_per_port_rx_offload_result,
18169 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
18170 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
18171 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
18172 "scatter#timestamp#security#keep_crc#rss_hash");
18173 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
18174 TOKEN_STRING_INITIALIZER
18175 (struct cmd_config_per_port_rx_offload_result,
18179 search_rx_offload(const char *name)
18181 uint64_t single_offload;
18182 const char *single_name;
18186 single_offload = 1;
18187 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
18188 single_name = rte_eth_dev_rx_offload_name(single_offload);
18189 if (!strcasecmp(single_name, name)) {
18193 single_offload <<= 1;
18197 return single_offload;
18203 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
18204 __attribute__((unused)) struct cmdline *cl,
18205 __attribute__((unused)) void *data)
18207 struct cmd_config_per_port_rx_offload_result *res = parsed_result;
18208 portid_t port_id = res->port_id;
18209 struct rte_eth_dev_info dev_info;
18210 struct rte_port *port = &ports[port_id];
18211 uint64_t single_offload;
18212 uint16_t nb_rx_queues;
18216 if (port->port_status != RTE_PORT_STOPPED) {
18217 printf("Error: Can't config offload when Port %d "
18218 "is not stopped\n", port_id);
18222 single_offload = search_rx_offload(res->offload);
18223 if (single_offload == 0) {
18224 printf("Unknown offload name: %s\n", res->offload);
18228 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18232 nb_rx_queues = dev_info.nb_rx_queues;
18233 if (!strcmp(res->on_off, "on")) {
18234 port->dev_conf.rxmode.offloads |= single_offload;
18235 for (q = 0; q < nb_rx_queues; q++)
18236 port->rx_conf[q].offloads |= single_offload;
18238 port->dev_conf.rxmode.offloads &= ~single_offload;
18239 for (q = 0; q < nb_rx_queues; q++)
18240 port->rx_conf[q].offloads &= ~single_offload;
18243 cmd_reconfig_device_queue(port_id, 1, 1);
18246 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
18247 .f = cmd_config_per_port_rx_offload_parsed,
18249 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
18250 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
18251 "macsec_strip|header_split|vlan_filter|vlan_extend|"
18252 "jumbo_frame|scatter|timestamp|security|keep_crc|rss_hash "
18255 (void *)&cmd_config_per_port_rx_offload_result_port,
18256 (void *)&cmd_config_per_port_rx_offload_result_config,
18257 (void *)&cmd_config_per_port_rx_offload_result_port_id,
18258 (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
18259 (void *)&cmd_config_per_port_rx_offload_result_offload,
18260 (void *)&cmd_config_per_port_rx_offload_result_on_off,
18265 /* Enable/Disable a per queue offloading */
18266 struct cmd_config_per_queue_rx_offload_result {
18267 cmdline_fixed_string_t port;
18269 cmdline_fixed_string_t rxq;
18271 cmdline_fixed_string_t rx_offload;
18272 cmdline_fixed_string_t offload;
18273 cmdline_fixed_string_t on_off;
18276 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
18277 TOKEN_STRING_INITIALIZER
18278 (struct cmd_config_per_queue_rx_offload_result,
18280 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
18281 TOKEN_NUM_INITIALIZER
18282 (struct cmd_config_per_queue_rx_offload_result,
18284 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
18285 TOKEN_STRING_INITIALIZER
18286 (struct cmd_config_per_queue_rx_offload_result,
18288 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
18289 TOKEN_NUM_INITIALIZER
18290 (struct cmd_config_per_queue_rx_offload_result,
18292 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
18293 TOKEN_STRING_INITIALIZER
18294 (struct cmd_config_per_queue_rx_offload_result,
18295 rx_offload, "rx_offload");
18296 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
18297 TOKEN_STRING_INITIALIZER
18298 (struct cmd_config_per_queue_rx_offload_result,
18299 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
18300 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
18301 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
18302 "scatter#timestamp#security#keep_crc");
18303 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
18304 TOKEN_STRING_INITIALIZER
18305 (struct cmd_config_per_queue_rx_offload_result,
18309 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
18310 __attribute__((unused)) struct cmdline *cl,
18311 __attribute__((unused)) void *data)
18313 struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
18314 struct rte_eth_dev_info dev_info;
18315 portid_t port_id = res->port_id;
18316 uint16_t queue_id = res->queue_id;
18317 struct rte_port *port = &ports[port_id];
18318 uint64_t single_offload;
18321 if (port->port_status != RTE_PORT_STOPPED) {
18322 printf("Error: Can't config offload when Port %d "
18323 "is not stopped\n", port_id);
18327 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18331 if (queue_id >= dev_info.nb_rx_queues) {
18332 printf("Error: input queue_id should be 0 ... "
18333 "%d\n", dev_info.nb_rx_queues - 1);
18337 single_offload = search_rx_offload(res->offload);
18338 if (single_offload == 0) {
18339 printf("Unknown offload name: %s\n", res->offload);
18343 if (!strcmp(res->on_off, "on"))
18344 port->rx_conf[queue_id].offloads |= single_offload;
18346 port->rx_conf[queue_id].offloads &= ~single_offload;
18348 cmd_reconfig_device_queue(port_id, 1, 1);
18351 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
18352 .f = cmd_config_per_queue_rx_offload_parsed,
18354 .help_str = "port <port_id> rxq <queue_id> rx_offload "
18355 "vlan_strip|ipv4_cksum|"
18356 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
18357 "macsec_strip|header_split|vlan_filter|vlan_extend|"
18358 "jumbo_frame|scatter|timestamp|security|keep_crc "
18361 (void *)&cmd_config_per_queue_rx_offload_result_port,
18362 (void *)&cmd_config_per_queue_rx_offload_result_port_id,
18363 (void *)&cmd_config_per_queue_rx_offload_result_rxq,
18364 (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
18365 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
18366 (void *)&cmd_config_per_queue_rx_offload_result_offload,
18367 (void *)&cmd_config_per_queue_rx_offload_result_on_off,
18372 /* Get Tx offloads capabilities */
18373 struct cmd_tx_offload_get_capa_result {
18374 cmdline_fixed_string_t show;
18375 cmdline_fixed_string_t port;
18377 cmdline_fixed_string_t tx_offload;
18378 cmdline_fixed_string_t capabilities;
18381 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
18382 TOKEN_STRING_INITIALIZER
18383 (struct cmd_tx_offload_get_capa_result,
18385 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
18386 TOKEN_STRING_INITIALIZER
18387 (struct cmd_tx_offload_get_capa_result,
18389 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
18390 TOKEN_NUM_INITIALIZER
18391 (struct cmd_tx_offload_get_capa_result,
18393 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
18394 TOKEN_STRING_INITIALIZER
18395 (struct cmd_tx_offload_get_capa_result,
18396 tx_offload, "tx_offload");
18397 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
18398 TOKEN_STRING_INITIALIZER
18399 (struct cmd_tx_offload_get_capa_result,
18400 capabilities, "capabilities");
18403 print_tx_offloads(uint64_t offloads)
18405 uint64_t single_offload;
18413 begin = __builtin_ctzll(offloads);
18414 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
18416 single_offload = 1ULL << begin;
18417 for (bit = begin; bit < end; bit++) {
18418 if (offloads & single_offload)
18420 rte_eth_dev_tx_offload_name(single_offload));
18421 single_offload <<= 1;
18426 cmd_tx_offload_get_capa_parsed(
18427 void *parsed_result,
18428 __attribute__((unused)) struct cmdline *cl,
18429 __attribute__((unused)) void *data)
18431 struct cmd_tx_offload_get_capa_result *res = parsed_result;
18432 struct rte_eth_dev_info dev_info;
18433 portid_t port_id = res->port_id;
18434 uint64_t queue_offloads;
18435 uint64_t port_offloads;
18438 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18442 queue_offloads = dev_info.tx_queue_offload_capa;
18443 port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
18445 printf("Tx Offloading Capabilities of port %d :\n", port_id);
18446 printf(" Per Queue :");
18447 print_tx_offloads(queue_offloads);
18450 printf(" Per Port :");
18451 print_tx_offloads(port_offloads);
18455 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
18456 .f = cmd_tx_offload_get_capa_parsed,
18458 .help_str = "show port <port_id> tx_offload capabilities",
18460 (void *)&cmd_tx_offload_get_capa_show,
18461 (void *)&cmd_tx_offload_get_capa_port,
18462 (void *)&cmd_tx_offload_get_capa_port_id,
18463 (void *)&cmd_tx_offload_get_capa_tx_offload,
18464 (void *)&cmd_tx_offload_get_capa_capabilities,
18469 /* Get Tx offloads configuration */
18470 struct cmd_tx_offload_get_configuration_result {
18471 cmdline_fixed_string_t show;
18472 cmdline_fixed_string_t port;
18474 cmdline_fixed_string_t tx_offload;
18475 cmdline_fixed_string_t configuration;
18478 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
18479 TOKEN_STRING_INITIALIZER
18480 (struct cmd_tx_offload_get_configuration_result,
18482 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
18483 TOKEN_STRING_INITIALIZER
18484 (struct cmd_tx_offload_get_configuration_result,
18486 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
18487 TOKEN_NUM_INITIALIZER
18488 (struct cmd_tx_offload_get_configuration_result,
18490 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
18491 TOKEN_STRING_INITIALIZER
18492 (struct cmd_tx_offload_get_configuration_result,
18493 tx_offload, "tx_offload");
18494 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
18495 TOKEN_STRING_INITIALIZER
18496 (struct cmd_tx_offload_get_configuration_result,
18497 configuration, "configuration");
18500 cmd_tx_offload_get_configuration_parsed(
18501 void *parsed_result,
18502 __attribute__((unused)) struct cmdline *cl,
18503 __attribute__((unused)) void *data)
18505 struct cmd_tx_offload_get_configuration_result *res = parsed_result;
18506 struct rte_eth_dev_info dev_info;
18507 portid_t port_id = res->port_id;
18508 struct rte_port *port = &ports[port_id];
18509 uint64_t port_offloads;
18510 uint64_t queue_offloads;
18511 uint16_t nb_tx_queues;
18515 printf("Tx Offloading Configuration of port %d :\n", port_id);
18517 port_offloads = port->dev_conf.txmode.offloads;
18519 print_tx_offloads(port_offloads);
18522 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18526 nb_tx_queues = dev_info.nb_tx_queues;
18527 for (q = 0; q < nb_tx_queues; q++) {
18528 queue_offloads = port->tx_conf[q].offloads;
18529 printf(" Queue[%2d] :", q);
18530 print_tx_offloads(queue_offloads);
18536 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
18537 .f = cmd_tx_offload_get_configuration_parsed,
18539 .help_str = "show port <port_id> tx_offload configuration",
18541 (void *)&cmd_tx_offload_get_configuration_show,
18542 (void *)&cmd_tx_offload_get_configuration_port,
18543 (void *)&cmd_tx_offload_get_configuration_port_id,
18544 (void *)&cmd_tx_offload_get_configuration_tx_offload,
18545 (void *)&cmd_tx_offload_get_configuration_configuration,
18550 /* Enable/Disable a per port offloading */
18551 struct cmd_config_per_port_tx_offload_result {
18552 cmdline_fixed_string_t port;
18553 cmdline_fixed_string_t config;
18555 cmdline_fixed_string_t tx_offload;
18556 cmdline_fixed_string_t offload;
18557 cmdline_fixed_string_t on_off;
18560 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
18561 TOKEN_STRING_INITIALIZER
18562 (struct cmd_config_per_port_tx_offload_result,
18564 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
18565 TOKEN_STRING_INITIALIZER
18566 (struct cmd_config_per_port_tx_offload_result,
18568 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
18569 TOKEN_NUM_INITIALIZER
18570 (struct cmd_config_per_port_tx_offload_result,
18572 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
18573 TOKEN_STRING_INITIALIZER
18574 (struct cmd_config_per_port_tx_offload_result,
18575 tx_offload, "tx_offload");
18576 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
18577 TOKEN_STRING_INITIALIZER
18578 (struct cmd_config_per_port_tx_offload_result,
18579 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18580 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18581 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18582 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18583 "mt_lockfree#multi_segs#mbuf_fast_free#security");
18584 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
18585 TOKEN_STRING_INITIALIZER
18586 (struct cmd_config_per_port_tx_offload_result,
18590 search_tx_offload(const char *name)
18592 uint64_t single_offload;
18593 const char *single_name;
18597 single_offload = 1;
18598 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
18599 single_name = rte_eth_dev_tx_offload_name(single_offload);
18600 if (single_name == NULL)
18602 if (!strcasecmp(single_name, name)) {
18605 } else if (!strcasecmp(single_name, "UNKNOWN"))
18607 single_offload <<= 1;
18611 return single_offload;
18617 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
18618 __attribute__((unused)) struct cmdline *cl,
18619 __attribute__((unused)) void *data)
18621 struct cmd_config_per_port_tx_offload_result *res = parsed_result;
18622 portid_t port_id = res->port_id;
18623 struct rte_eth_dev_info dev_info;
18624 struct rte_port *port = &ports[port_id];
18625 uint64_t single_offload;
18626 uint16_t nb_tx_queues;
18630 if (port->port_status != RTE_PORT_STOPPED) {
18631 printf("Error: Can't config offload when Port %d "
18632 "is not stopped\n", port_id);
18636 single_offload = search_tx_offload(res->offload);
18637 if (single_offload == 0) {
18638 printf("Unknown offload name: %s\n", res->offload);
18642 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18646 nb_tx_queues = dev_info.nb_tx_queues;
18647 if (!strcmp(res->on_off, "on")) {
18648 port->dev_conf.txmode.offloads |= single_offload;
18649 for (q = 0; q < nb_tx_queues; q++)
18650 port->tx_conf[q].offloads |= single_offload;
18652 port->dev_conf.txmode.offloads &= ~single_offload;
18653 for (q = 0; q < nb_tx_queues; q++)
18654 port->tx_conf[q].offloads &= ~single_offload;
18657 cmd_reconfig_device_queue(port_id, 1, 1);
18660 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
18661 .f = cmd_config_per_port_tx_offload_parsed,
18663 .help_str = "port config <port_id> tx_offload "
18664 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
18665 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
18666 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
18667 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
18668 "mt_lockfree|multi_segs|mbuf_fast_free|security on|off",
18670 (void *)&cmd_config_per_port_tx_offload_result_port,
18671 (void *)&cmd_config_per_port_tx_offload_result_config,
18672 (void *)&cmd_config_per_port_tx_offload_result_port_id,
18673 (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
18674 (void *)&cmd_config_per_port_tx_offload_result_offload,
18675 (void *)&cmd_config_per_port_tx_offload_result_on_off,
18680 /* Enable/Disable a per queue offloading */
18681 struct cmd_config_per_queue_tx_offload_result {
18682 cmdline_fixed_string_t port;
18684 cmdline_fixed_string_t txq;
18686 cmdline_fixed_string_t tx_offload;
18687 cmdline_fixed_string_t offload;
18688 cmdline_fixed_string_t on_off;
18691 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
18692 TOKEN_STRING_INITIALIZER
18693 (struct cmd_config_per_queue_tx_offload_result,
18695 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
18696 TOKEN_NUM_INITIALIZER
18697 (struct cmd_config_per_queue_tx_offload_result,
18699 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
18700 TOKEN_STRING_INITIALIZER
18701 (struct cmd_config_per_queue_tx_offload_result,
18703 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
18704 TOKEN_NUM_INITIALIZER
18705 (struct cmd_config_per_queue_tx_offload_result,
18707 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
18708 TOKEN_STRING_INITIALIZER
18709 (struct cmd_config_per_queue_tx_offload_result,
18710 tx_offload, "tx_offload");
18711 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
18712 TOKEN_STRING_INITIALIZER
18713 (struct cmd_config_per_queue_tx_offload_result,
18714 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18715 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18716 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18717 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18718 "mt_lockfree#multi_segs#mbuf_fast_free#security");
18719 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
18720 TOKEN_STRING_INITIALIZER
18721 (struct cmd_config_per_queue_tx_offload_result,
18725 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
18726 __attribute__((unused)) struct cmdline *cl,
18727 __attribute__((unused)) void *data)
18729 struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
18730 struct rte_eth_dev_info dev_info;
18731 portid_t port_id = res->port_id;
18732 uint16_t queue_id = res->queue_id;
18733 struct rte_port *port = &ports[port_id];
18734 uint64_t single_offload;
18737 if (port->port_status != RTE_PORT_STOPPED) {
18738 printf("Error: Can't config offload when Port %d "
18739 "is not stopped\n", port_id);
18743 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18747 if (queue_id >= dev_info.nb_tx_queues) {
18748 printf("Error: input queue_id should be 0 ... "
18749 "%d\n", dev_info.nb_tx_queues - 1);
18753 single_offload = search_tx_offload(res->offload);
18754 if (single_offload == 0) {
18755 printf("Unknown offload name: %s\n", res->offload);
18759 if (!strcmp(res->on_off, "on"))
18760 port->tx_conf[queue_id].offloads |= single_offload;
18762 port->tx_conf[queue_id].offloads &= ~single_offload;
18764 cmd_reconfig_device_queue(port_id, 1, 1);
18767 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
18768 .f = cmd_config_per_queue_tx_offload_parsed,
18770 .help_str = "port <port_id> txq <queue_id> tx_offload "
18771 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
18772 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
18773 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
18774 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
18775 "mt_lockfree|multi_segs|mbuf_fast_free|security "
18778 (void *)&cmd_config_per_queue_tx_offload_result_port,
18779 (void *)&cmd_config_per_queue_tx_offload_result_port_id,
18780 (void *)&cmd_config_per_queue_tx_offload_result_txq,
18781 (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
18782 (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
18783 (void *)&cmd_config_per_queue_tx_offload_result_offload,
18784 (void *)&cmd_config_per_queue_tx_offload_result_on_off,
18789 /* *** configure tx_metadata for specific port *** */
18790 struct cmd_config_tx_metadata_specific_result {
18791 cmdline_fixed_string_t port;
18792 cmdline_fixed_string_t keyword;
18794 cmdline_fixed_string_t item;
18799 cmd_config_tx_metadata_specific_parsed(void *parsed_result,
18800 __attribute__((unused)) struct cmdline *cl,
18801 __attribute__((unused)) void *data)
18803 struct cmd_config_tx_metadata_specific_result *res = parsed_result;
18805 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
18807 ports[res->port_id].tx_metadata = res->value;
18808 /* Add/remove callback to insert valid metadata in every Tx packet. */
18809 if (ports[res->port_id].tx_metadata)
18810 add_tx_md_callback(res->port_id);
18812 remove_tx_md_callback(res->port_id);
18813 rte_flow_dynf_metadata_register();
18816 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
18817 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18819 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
18820 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18821 keyword, "config");
18822 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
18823 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18825 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
18826 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18827 item, "tx_metadata");
18828 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
18829 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18832 cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
18833 .f = cmd_config_tx_metadata_specific_parsed,
18835 .help_str = "port config <port_id> tx_metadata <value>",
18837 (void *)&cmd_config_tx_metadata_specific_port,
18838 (void *)&cmd_config_tx_metadata_specific_keyword,
18839 (void *)&cmd_config_tx_metadata_specific_id,
18840 (void *)&cmd_config_tx_metadata_specific_item,
18841 (void *)&cmd_config_tx_metadata_specific_value,
18846 /* *** set dynf *** */
18847 struct cmd_config_tx_dynf_specific_result {
18848 cmdline_fixed_string_t port;
18849 cmdline_fixed_string_t keyword;
18851 cmdline_fixed_string_t item;
18852 cmdline_fixed_string_t name;
18853 cmdline_fixed_string_t value;
18857 cmd_config_dynf_specific_parsed(void *parsed_result,
18858 __attribute__((unused)) struct cmdline *cl,
18859 __attribute__((unused)) void *data)
18861 struct cmd_config_tx_dynf_specific_result *res = parsed_result;
18862 struct rte_mbuf_dynflag desc_flag;
18864 uint64_t old_port_flags;
18866 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
18868 flag = rte_mbuf_dynflag_lookup(res->name, NULL);
18870 strcpy(desc_flag.name, res->name);
18871 desc_flag.flags = 0;
18872 flag = rte_mbuf_dynflag_register(&desc_flag);
18874 printf("Can't register flag\n");
18877 strcpy(dynf_names[flag], res->name);
18879 old_port_flags = ports[res->port_id].mbuf_dynf;
18880 if (!strcmp(res->value, "set")) {
18881 ports[res->port_id].mbuf_dynf |= 1UL << flag;
18882 if (old_port_flags == 0)
18883 add_tx_dynf_callback(res->port_id);
18885 ports[res->port_id].mbuf_dynf &= ~(1UL << flag);
18886 if (ports[res->port_id].mbuf_dynf == 0)
18887 remove_tx_dynf_callback(res->port_id);
18891 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_port =
18892 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
18894 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_keyword =
18895 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
18896 keyword, "config");
18897 cmdline_parse_token_num_t cmd_config_tx_dynf_specific_port_id =
18898 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
18900 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_item =
18901 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
18903 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_name =
18904 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
18906 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_value =
18907 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
18908 value, "set#clear");
18910 cmdline_parse_inst_t cmd_config_tx_dynf_specific = {
18911 .f = cmd_config_dynf_specific_parsed,
18913 .help_str = "port config <port id> dynf <name> set|clear",
18915 (void *)&cmd_config_tx_dynf_specific_port,
18916 (void *)&cmd_config_tx_dynf_specific_keyword,
18917 (void *)&cmd_config_tx_dynf_specific_port_id,
18918 (void *)&cmd_config_tx_dynf_specific_item,
18919 (void *)&cmd_config_tx_dynf_specific_name,
18920 (void *)&cmd_config_tx_dynf_specific_value,
18925 /* *** display tx_metadata per port configuration *** */
18926 struct cmd_show_tx_metadata_result {
18927 cmdline_fixed_string_t cmd_show;
18928 cmdline_fixed_string_t cmd_port;
18929 cmdline_fixed_string_t cmd_keyword;
18934 cmd_show_tx_metadata_parsed(void *parsed_result,
18935 __attribute__((unused)) struct cmdline *cl,
18936 __attribute__((unused)) void *data)
18938 struct cmd_show_tx_metadata_result *res = parsed_result;
18940 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
18941 printf("invalid port id %u\n", res->cmd_pid);
18944 if (!strcmp(res->cmd_keyword, "tx_metadata")) {
18945 printf("Port %u tx_metadata: %u\n", res->cmd_pid,
18946 ports[res->cmd_pid].tx_metadata);
18950 cmdline_parse_token_string_t cmd_show_tx_metadata_show =
18951 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
18953 cmdline_parse_token_string_t cmd_show_tx_metadata_port =
18954 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
18956 cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
18957 TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
18959 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
18960 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
18961 cmd_keyword, "tx_metadata");
18963 cmdline_parse_inst_t cmd_show_tx_metadata = {
18964 .f = cmd_show_tx_metadata_parsed,
18966 .help_str = "show port <port_id> tx_metadata",
18968 (void *)&cmd_show_tx_metadata_show,
18969 (void *)&cmd_show_tx_metadata_port,
18970 (void *)&cmd_show_tx_metadata_pid,
18971 (void *)&cmd_show_tx_metadata_keyword,
18976 /* show port supported ptypes */
18978 /* Common result structure for show port ptypes */
18979 struct cmd_show_port_supported_ptypes_result {
18980 cmdline_fixed_string_t show;
18981 cmdline_fixed_string_t port;
18983 cmdline_fixed_string_t ptypes;
18986 /* Common CLI fields for show port ptypes */
18987 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =
18988 TOKEN_STRING_INITIALIZER
18989 (struct cmd_show_port_supported_ptypes_result,
18991 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
18992 TOKEN_STRING_INITIALIZER
18993 (struct cmd_show_port_supported_ptypes_result,
18995 cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =
18996 TOKEN_NUM_INITIALIZER
18997 (struct cmd_show_port_supported_ptypes_result,
18999 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =
19000 TOKEN_STRING_INITIALIZER
19001 (struct cmd_show_port_supported_ptypes_result,
19005 cmd_show_port_supported_ptypes_parsed(
19006 void *parsed_result,
19007 __attribute__((unused)) struct cmdline *cl,
19008 __attribute__((unused)) void *data)
19010 #define RSVD_PTYPE_MASK 0xf0000000
19011 #define MAX_PTYPES_PER_LAYER 16
19012 #define LTYPE_NAMESIZE 32
19013 #define PTYPE_NAMESIZE 256
19014 struct cmd_show_port_supported_ptypes_result *res = parsed_result;
19015 char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE];
19016 uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
19017 uint32_t ptypes[MAX_PTYPES_PER_LAYER];
19018 uint16_t port_id = res->port_id;
19021 ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0);
19025 while (ptype_mask != RSVD_PTYPE_MASK) {
19027 switch (ptype_mask) {
19028 case RTE_PTYPE_L2_MASK:
19029 strlcpy(ltype, "L2", sizeof(ltype));
19031 case RTE_PTYPE_L3_MASK:
19032 strlcpy(ltype, "L3", sizeof(ltype));
19034 case RTE_PTYPE_L4_MASK:
19035 strlcpy(ltype, "L4", sizeof(ltype));
19037 case RTE_PTYPE_TUNNEL_MASK:
19038 strlcpy(ltype, "Tunnel", sizeof(ltype));
19040 case RTE_PTYPE_INNER_L2_MASK:
19041 strlcpy(ltype, "Inner L2", sizeof(ltype));
19043 case RTE_PTYPE_INNER_L3_MASK:
19044 strlcpy(ltype, "Inner L3", sizeof(ltype));
19046 case RTE_PTYPE_INNER_L4_MASK:
19047 strlcpy(ltype, "Inner L4", sizeof(ltype));
19053 ret = rte_eth_dev_get_supported_ptypes(res->port_id,
19054 ptype_mask, ptypes,
19055 MAX_PTYPES_PER_LAYER);
19058 printf("Supported %s ptypes:\n", ltype);
19060 printf("%s ptypes unsupported\n", ltype);
19062 for (i = 0; i < ret; ++i) {
19063 rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
19064 printf("%s\n", buf);
19071 cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
19072 .f = cmd_show_port_supported_ptypes_parsed,
19074 .help_str = "show port <port_id> ptypes",
19076 (void *)&cmd_show_port_supported_ptypes_show,
19077 (void *)&cmd_show_port_supported_ptypes_port,
19078 (void *)&cmd_show_port_supported_ptypes_port_id,
19079 (void *)&cmd_show_port_supported_ptypes_ptypes,
19084 /* *** display rx/tx descriptor status *** */
19085 struct cmd_show_rx_tx_desc_status_result {
19086 cmdline_fixed_string_t cmd_show;
19087 cmdline_fixed_string_t cmd_port;
19088 cmdline_fixed_string_t cmd_keyword;
19089 cmdline_fixed_string_t cmd_desc;
19090 cmdline_fixed_string_t cmd_status;
19097 cmd_show_rx_tx_desc_status_parsed(void *parsed_result,
19098 __attribute__((unused)) struct cmdline *cl,
19099 __attribute__((unused)) void *data)
19101 struct cmd_show_rx_tx_desc_status_result *res = parsed_result;
19104 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
19105 printf("invalid port id %u\n", res->cmd_pid);
19109 if (!strcmp(res->cmd_keyword, "rxq")) {
19110 rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid,
19113 printf("Invalid queueid = %d\n", res->cmd_qid);
19116 if (rc == RTE_ETH_RX_DESC_AVAIL)
19117 printf("Desc status = AVAILABLE\n");
19118 else if (rc == RTE_ETH_RX_DESC_DONE)
19119 printf("Desc status = DONE\n");
19121 printf("Desc status = UNAVAILABLE\n");
19122 } else if (!strcmp(res->cmd_keyword, "txq")) {
19123 rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid,
19126 printf("Invalid queueid = %d\n", res->cmd_qid);
19129 if (rc == RTE_ETH_TX_DESC_FULL)
19130 printf("Desc status = FULL\n");
19131 else if (rc == RTE_ETH_TX_DESC_DONE)
19132 printf("Desc status = DONE\n");
19134 printf("Desc status = UNAVAILABLE\n");
19138 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show =
19139 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19141 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port =
19142 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19144 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid =
19145 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19147 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword =
19148 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19149 cmd_keyword, "rxq#txq");
19150 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid =
19151 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19153 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc =
19154 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19156 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did =
19157 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19159 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status =
19160 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19161 cmd_status, "status");
19162 cmdline_parse_inst_t cmd_show_rx_tx_desc_status = {
19163 .f = cmd_show_rx_tx_desc_status_parsed,
19165 .help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> "
19168 (void *)&cmd_show_rx_tx_desc_status_show,
19169 (void *)&cmd_show_rx_tx_desc_status_port,
19170 (void *)&cmd_show_rx_tx_desc_status_pid,
19171 (void *)&cmd_show_rx_tx_desc_status_keyword,
19172 (void *)&cmd_show_rx_tx_desc_status_qid,
19173 (void *)&cmd_show_rx_tx_desc_status_desc,
19174 (void *)&cmd_show_rx_tx_desc_status_did,
19175 (void *)&cmd_show_rx_tx_desc_status_status,
19180 /* Common result structure for set port ptypes */
19181 struct cmd_set_port_ptypes_result {
19182 cmdline_fixed_string_t set;
19183 cmdline_fixed_string_t port;
19185 cmdline_fixed_string_t ptype_mask;
19189 /* Common CLI fields for set port ptypes */
19190 cmdline_parse_token_string_t cmd_set_port_ptypes_set =
19191 TOKEN_STRING_INITIALIZER
19192 (struct cmd_set_port_ptypes_result,
19194 cmdline_parse_token_string_t cmd_set_port_ptypes_port =
19195 TOKEN_STRING_INITIALIZER
19196 (struct cmd_set_port_ptypes_result,
19198 cmdline_parse_token_num_t cmd_set_port_ptypes_port_id =
19199 TOKEN_NUM_INITIALIZER
19200 (struct cmd_set_port_ptypes_result,
19202 cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str =
19203 TOKEN_STRING_INITIALIZER
19204 (struct cmd_set_port_ptypes_result,
19205 ptype_mask, "ptype_mask");
19206 cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 =
19207 TOKEN_NUM_INITIALIZER
19208 (struct cmd_set_port_ptypes_result,
19212 cmd_set_port_ptypes_parsed(
19213 void *parsed_result,
19214 __attribute__((unused)) struct cmdline *cl,
19215 __attribute__((unused)) void *data)
19217 struct cmd_set_port_ptypes_result *res = parsed_result;
19218 #define PTYPE_NAMESIZE 256
19219 char ptype_name[PTYPE_NAMESIZE];
19220 uint16_t port_id = res->port_id;
19221 uint32_t ptype_mask = res->mask;
19224 ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK,
19227 printf("Port %d doesn't support any ptypes.\n", port_id);
19231 uint32_t ptypes[ret];
19233 ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret);
19235 printf("Unable to set requested ptypes for Port %d\n", port_id);
19239 printf("Successfully set following ptypes for Port %d\n", port_id);
19240 for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) {
19241 rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name));
19242 printf("%s\n", ptype_name);
19245 clear_ptypes = false;
19248 cmdline_parse_inst_t cmd_set_port_ptypes = {
19249 .f = cmd_set_port_ptypes_parsed,
19251 .help_str = "set port <port_id> ptype_mask <mask>",
19253 (void *)&cmd_set_port_ptypes_set,
19254 (void *)&cmd_set_port_ptypes_port,
19255 (void *)&cmd_set_port_ptypes_port_id,
19256 (void *)&cmd_set_port_ptypes_mask_str,
19257 (void *)&cmd_set_port_ptypes_mask_u32,
19262 /* *** display mac addresses added to a port *** */
19263 struct cmd_showport_macs_result {
19264 cmdline_fixed_string_t cmd_show;
19265 cmdline_fixed_string_t cmd_port;
19266 cmdline_fixed_string_t cmd_keyword;
19271 cmd_showport_macs_parsed(void *parsed_result,
19272 __attribute__((unused)) struct cmdline *cl,
19273 __attribute__((unused)) void *data)
19275 struct cmd_showport_macs_result *res = parsed_result;
19277 if (port_id_is_invalid(res->cmd_pid, ENABLED_WARN))
19280 if (!strcmp(res->cmd_keyword, "macs"))
19281 show_macs(res->cmd_pid);
19282 else if (!strcmp(res->cmd_keyword, "mcast_macs"))
19283 show_mcast_macs(res->cmd_pid);
19286 cmdline_parse_token_string_t cmd_showport_macs_show =
19287 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
19289 cmdline_parse_token_string_t cmd_showport_macs_port =
19290 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
19292 cmdline_parse_token_num_t cmd_showport_macs_pid =
19293 TOKEN_NUM_INITIALIZER(struct cmd_showport_macs_result,
19295 cmdline_parse_token_string_t cmd_showport_macs_keyword =
19296 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
19297 cmd_keyword, "macs#mcast_macs");
19299 cmdline_parse_inst_t cmd_showport_macs = {
19300 .f = cmd_showport_macs_parsed,
19302 .help_str = "show port <port_id> macs|mcast_macs",
19304 (void *)&cmd_showport_macs_show,
19305 (void *)&cmd_showport_macs_port,
19306 (void *)&cmd_showport_macs_pid,
19307 (void *)&cmd_showport_macs_keyword,
19312 /* ******************************************************************************** */
19314 /* list of instructions */
19315 cmdline_parse_ctx_t main_ctx[] = {
19316 (cmdline_parse_inst_t *)&cmd_help_brief,
19317 (cmdline_parse_inst_t *)&cmd_help_long,
19318 (cmdline_parse_inst_t *)&cmd_quit,
19319 (cmdline_parse_inst_t *)&cmd_load_from_file,
19320 (cmdline_parse_inst_t *)&cmd_showport,
19321 (cmdline_parse_inst_t *)&cmd_showqueue,
19322 (cmdline_parse_inst_t *)&cmd_showportall,
19323 (cmdline_parse_inst_t *)&cmd_showdevice,
19324 (cmdline_parse_inst_t *)&cmd_showcfg,
19325 (cmdline_parse_inst_t *)&cmd_showfwdall,
19326 (cmdline_parse_inst_t *)&cmd_start,
19327 (cmdline_parse_inst_t *)&cmd_start_tx_first,
19328 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
19329 (cmdline_parse_inst_t *)&cmd_set_link_up,
19330 (cmdline_parse_inst_t *)&cmd_set_link_down,
19331 (cmdline_parse_inst_t *)&cmd_reset,
19332 (cmdline_parse_inst_t *)&cmd_set_numbers,
19333 (cmdline_parse_inst_t *)&cmd_set_log,
19334 (cmdline_parse_inst_t *)&cmd_set_txpkts,
19335 (cmdline_parse_inst_t *)&cmd_set_txsplit,
19336 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
19337 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
19338 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
19339 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
19340 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
19341 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
19342 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
19343 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
19344 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
19345 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
19346 (cmdline_parse_inst_t *)&cmd_set_link_check,
19347 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
19348 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
19349 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
19350 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
19351 #ifdef RTE_LIBRTE_PMD_BOND
19352 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
19353 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
19354 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
19355 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
19356 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
19357 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
19358 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
19359 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
19360 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
19361 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
19362 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
19364 (cmdline_parse_inst_t *)&cmd_vlan_offload,
19365 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
19366 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
19367 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
19368 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
19369 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
19370 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
19371 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
19372 (cmdline_parse_inst_t *)&cmd_csum_set,
19373 (cmdline_parse_inst_t *)&cmd_csum_show,
19374 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
19375 (cmdline_parse_inst_t *)&cmd_tso_set,
19376 (cmdline_parse_inst_t *)&cmd_tso_show,
19377 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
19378 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
19379 (cmdline_parse_inst_t *)&cmd_gro_enable,
19380 (cmdline_parse_inst_t *)&cmd_gro_flush,
19381 (cmdline_parse_inst_t *)&cmd_gro_show,
19382 (cmdline_parse_inst_t *)&cmd_gso_enable,
19383 (cmdline_parse_inst_t *)&cmd_gso_size,
19384 (cmdline_parse_inst_t *)&cmd_gso_show,
19385 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
19386 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
19387 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
19388 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
19389 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
19390 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
19391 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
19392 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
19393 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
19394 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
19395 (cmdline_parse_inst_t *)&cmd_config_dcb,
19396 (cmdline_parse_inst_t *)&cmd_read_reg,
19397 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
19398 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
19399 (cmdline_parse_inst_t *)&cmd_write_reg,
19400 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
19401 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
19402 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
19403 (cmdline_parse_inst_t *)&cmd_stop,
19404 (cmdline_parse_inst_t *)&cmd_mac_addr,
19405 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
19406 (cmdline_parse_inst_t *)&cmd_set_qmap,
19407 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
19408 (cmdline_parse_inst_t *)&cmd_operate_port,
19409 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
19410 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
19411 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
19412 (cmdline_parse_inst_t *)&cmd_operate_detach_device,
19413 (cmdline_parse_inst_t *)&cmd_set_port_setup_on,
19414 (cmdline_parse_inst_t *)&cmd_config_speed_all,
19415 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
19416 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
19417 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
19418 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
19419 (cmdline_parse_inst_t *)&cmd_config_mtu,
19420 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
19421 (cmdline_parse_inst_t *)&cmd_config_max_lro_pkt_size,
19422 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
19423 (cmdline_parse_inst_t *)&cmd_config_rss,
19424 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
19425 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
19426 (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
19427 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
19428 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
19429 (cmdline_parse_inst_t *)&cmd_showport_reta,
19430 (cmdline_parse_inst_t *)&cmd_showport_macs,
19431 (cmdline_parse_inst_t *)&cmd_config_burst,
19432 (cmdline_parse_inst_t *)&cmd_config_thresh,
19433 (cmdline_parse_inst_t *)&cmd_config_threshold,
19434 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
19435 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
19436 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
19437 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
19438 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
19439 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
19440 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
19441 (cmdline_parse_inst_t *)&cmd_global_config,
19442 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
19443 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
19444 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
19445 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
19446 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
19447 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
19448 (cmdline_parse_inst_t *)&cmd_dump,
19449 (cmdline_parse_inst_t *)&cmd_dump_one,
19450 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
19451 (cmdline_parse_inst_t *)&cmd_syn_filter,
19452 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
19453 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
19454 (cmdline_parse_inst_t *)&cmd_flex_filter,
19455 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
19456 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
19457 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
19458 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
19459 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
19460 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
19461 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
19462 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
19463 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
19464 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
19465 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
19466 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
19467 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
19468 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
19469 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
19470 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
19471 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
19472 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
19473 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
19474 (cmdline_parse_inst_t *)&cmd_flow,
19475 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
19476 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
19477 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
19478 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
19479 (cmdline_parse_inst_t *)&cmd_create_port_meter,
19480 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
19481 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
19482 (cmdline_parse_inst_t *)&cmd_del_port_meter,
19483 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
19484 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
19485 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
19486 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
19487 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
19488 (cmdline_parse_inst_t *)&cmd_mcast_addr,
19489 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
19490 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
19491 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
19492 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
19493 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
19494 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
19495 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
19496 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
19497 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
19498 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
19499 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
19500 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
19501 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
19502 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
19503 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
19504 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
19505 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
19506 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
19507 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
19508 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
19509 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
19510 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
19511 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
19512 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
19513 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
19514 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
19515 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
19516 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
19517 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
19518 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
19519 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
19520 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
19521 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
19522 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
19523 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
19524 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
19525 (cmdline_parse_inst_t *)&cmd_set_port_tm_hierarchy_default,
19527 (cmdline_parse_inst_t *)&cmd_set_vxlan,
19528 (cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl,
19529 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
19530 (cmdline_parse_inst_t *)&cmd_set_nvgre,
19531 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
19532 (cmdline_parse_inst_t *)&cmd_set_l2_encap,
19533 (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
19534 (cmdline_parse_inst_t *)&cmd_set_l2_decap,
19535 (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
19536 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
19537 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
19538 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
19539 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
19540 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
19541 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
19542 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
19543 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
19544 (cmdline_parse_inst_t *)&cmd_ddp_add,
19545 (cmdline_parse_inst_t *)&cmd_ddp_del,
19546 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
19547 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
19548 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
19549 (cmdline_parse_inst_t *)&cmd_clear_input_set,
19550 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
19551 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
19552 (cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes,
19553 (cmdline_parse_inst_t *)&cmd_set_port_ptypes,
19554 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
19555 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
19556 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
19557 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
19559 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
19560 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
19561 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
19562 (cmdline_parse_inst_t *)&cmd_queue_region,
19563 (cmdline_parse_inst_t *)&cmd_region_flowtype,
19564 (cmdline_parse_inst_t *)&cmd_user_priority_region,
19565 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
19566 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
19567 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
19568 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
19569 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
19570 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
19571 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
19572 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
19573 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
19574 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
19575 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
19576 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
19577 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
19578 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
19579 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
19580 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
19581 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
19582 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
19583 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
19584 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
19585 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
19586 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
19587 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
19588 (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
19589 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
19590 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
19591 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
19592 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
19593 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
19594 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
19595 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
19596 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
19597 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
19598 #ifdef RTE_LIBRTE_BPF
19599 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
19600 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
19602 (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
19603 (cmdline_parse_inst_t *)&cmd_show_tx_metadata,
19604 (cmdline_parse_inst_t *)&cmd_show_rx_tx_desc_status,
19605 (cmdline_parse_inst_t *)&cmd_set_raw,
19606 (cmdline_parse_inst_t *)&cmd_show_set_raw,
19607 (cmdline_parse_inst_t *)&cmd_show_set_raw_all,
19608 (cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific,
19612 /* read cmdline commands from file */
19614 cmdline_read_from_file(const char *filename)
19616 struct cmdline *cl;
19618 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
19620 printf("Failed to create file based cmdline context: %s\n",
19625 cmdline_interact(cl);
19630 printf("Read CLI commands from %s\n", filename);
19633 /* prompt function, called from main on MASTER lcore */
19637 /* initialize non-constant commands */
19638 cmd_set_fwd_mode_init();
19639 cmd_set_fwd_retry_mode_init();
19641 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
19642 if (testpmd_cl == NULL)
19644 cmdline_interact(testpmd_cl);
19645 cmdline_stdin_exit(testpmd_cl);
19651 if (testpmd_cl != NULL)
19652 cmdline_quit(testpmd_cl);
19656 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
19658 if (id == (portid_t)RTE_PORT_ALL) {
19661 RTE_ETH_FOREACH_DEV(pid) {
19662 /* check if need_reconfig has been set to 1 */
19663 if (ports[pid].need_reconfig == 0)
19664 ports[pid].need_reconfig = dev;
19665 /* check if need_reconfig_queues has been set to 1 */
19666 if (ports[pid].need_reconfig_queues == 0)
19667 ports[pid].need_reconfig_queues = queue;
19669 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
19670 /* check if need_reconfig has been set to 1 */
19671 if (ports[id].need_reconfig == 0)
19672 ports[id].need_reconfig = dev;
19673 /* check if need_reconfig_queues has been set to 1 */
19674 if (ports[id].need_reconfig_queues == 0)
19675 ports[id].need_reconfig_queues = queue;