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>
54 #include <rte_eth_bond.h>
55 #include <rte_eth_bond_8023ad.h>
57 #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA
58 #include <rte_pmd_dpaa.h>
61 #include <rte_pmd_ixgbe.h>
64 #include <rte_pmd_i40e.h>
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(__rte_unused void *parsed_result,
85 __rte_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 commands.\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 __rte_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 port_id (module_eeprom|eeprom)\n"
170 " Display the module EEPROM or EEPROM information for port_id.\n\n"
172 "show port X rss reta (size) (mask0,mask1,...)\n"
173 " Display the rss redirection table entry indicated"
174 " by masks on port X. size is used to indicate the"
175 " hardware supported reta size\n\n"
177 "show port (port_id) rss-hash [key]\n"
178 " Display the RSS hash functions and RSS hash key of port\n\n"
180 "clear port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n"
181 " Clear information for port_id, or all.\n\n"
183 "show (rxq|txq) info (port_id) (queue_id)\n"
184 " Display information for configured RX/TX queue.\n\n"
186 "show config (rxtx|cores|fwd|rxoffs|rxpkts|txpkts)\n"
187 " Display the given configuration.\n\n"
189 "read rxd (port_id) (queue_id) (rxd_id)\n"
190 " Display an RX descriptor of a port RX queue.\n\n"
192 "read txd (port_id) (queue_id) (txd_id)\n"
193 " Display a TX descriptor of a port TX queue.\n\n"
195 "ddp get list (port_id)\n"
196 " Get ddp profile info list\n\n"
198 "ddp get info (profile_path)\n"
199 " Get ddp profile information.\n\n"
201 "show vf stats (port_id) (vf_id)\n"
202 " Display a VF's statistics.\n\n"
204 "clear vf stats (port_id) (vf_id)\n"
205 " Reset a VF's statistics.\n\n"
207 "show port (port_id) pctype mapping\n"
208 " Get flow ptype to pctype mapping on a port\n\n"
210 "show port meter stats (port_id) (meter_id) (clear)\n"
211 " Get meter stats on a port\n\n"
213 "show fwd stats all\n"
214 " Display statistics for all fwd engines.\n\n"
216 "clear fwd stats all\n"
217 " Clear statistics for all fwd engines.\n\n"
219 "show port (port_id) rx_offload capabilities\n"
220 " List all per queue and per port Rx offloading"
221 " capabilities of a port\n\n"
223 "show port (port_id) rx_offload configuration\n"
224 " List port level and all queue level"
225 " Rx offloading configuration\n\n"
227 "show port (port_id) tx_offload capabilities\n"
228 " List all per queue and per port"
229 " Tx offloading capabilities of a port\n\n"
231 "show port (port_id) tx_offload configuration\n"
232 " List port level and all queue level"
233 " Tx offloading configuration\n\n"
235 "show port (port_id) tx_metadata\n"
236 " Show Tx metadata value set"
237 " for a specific port\n\n"
239 "show port (port_id) ptypes\n"
240 " Show port supported ptypes"
241 " for a specific port\n\n"
243 "show device info (<identifier>|all)"
244 " Show general information about devices probed.\n\n"
246 "show port (port_id) rxq|txq (queue_id) desc (desc_id) status"
247 " Show status of rx|tx descriptor.\n\n"
249 "show port (port_id) macs|mcast_macs"
250 " Display list of mac addresses added to port.\n\n"
252 "show port (port_id) fec capabilities"
253 " Show fec capabilities of a port.\n\n"
255 "show port (port_id) fec_mode"
256 " Show fec mode of a port.\n\n"
260 if (show_all || !strcmp(res->section, "config")) {
266 "Configuration changes only become active when"
267 " forwarding is started/restarted.\n\n"
270 " Reset forwarding to the default configuration.\n\n"
272 "set verbose (level)\n"
273 " Set the debug verbosity level X.\n\n"
275 "set log global|(type) (level)\n"
276 " Set the log level.\n\n"
279 " Set number of ports.\n\n"
282 " Set number of cores.\n\n"
284 "set coremask (mask)\n"
285 " Set the forwarding cores hexadecimal mask.\n\n"
287 "set portmask (mask)\n"
288 " Set the forwarding ports hexadecimal mask.\n\n"
291 " Set number of packets per burst.\n\n"
293 "set burst tx delay (microseconds) retry (num)\n"
294 " Set the transmit delay time and number of retries,"
295 " effective when retry is enabled.\n\n"
297 "set rxoffs (x[,y]*)\n"
298 " Set the offset of each packet segment on"
299 " receiving if split feature is engaged."
300 " Affects only the queues configured with split"
303 "set rxpkts (x[,y]*)\n"
304 " Set the length of each segment to scatter"
305 " packets on receiving if split feature is engaged."
306 " Affects only the queues configured with split"
309 "set txpkts (x[,y]*)\n"
310 " Set the length of each segment of TXONLY"
311 " and optionally CSUM packets.\n\n"
313 "set txsplit (off|on|rand)\n"
314 " Set the split policy for the TX packets."
315 " Right now only applicable for CSUM and TXONLY"
318 "set txtimes (x, y)\n"
319 " Set the scheduling on timestamps"
320 " timings for the TXONLY mode\n\n"
322 "set corelist (x[,y]*)\n"
323 " Set the list of forwarding cores.\n\n"
325 "set portlist (x[,y]*)\n"
326 " Set the list of forwarding ports.\n\n"
328 "set port setup on (iterator|event)\n"
329 " Select how attached port is retrieved for setup.\n\n"
331 "set tx loopback (port_id) (on|off)\n"
332 " Enable or disable tx loopback.\n\n"
334 "set all queues drop (port_id) (on|off)\n"
335 " Set drop enable bit for all queues.\n\n"
337 "set vf split drop (port_id) (vf_id) (on|off)\n"
338 " Set split drop enable bit for a VF from the PF.\n\n"
340 "set vf mac antispoof (port_id) (vf_id) (on|off).\n"
341 " Set MAC antispoof for a VF from the PF.\n\n"
343 "set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n"
344 " Enable MACsec offload.\n\n"
346 "set macsec offload (port_id) off\n"
347 " Disable MACsec offload.\n\n"
349 "set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
350 " Configure MACsec secure connection (SC).\n\n"
352 "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n"
353 " Configure MACsec secure association (SA).\n\n"
355 "set vf broadcast (port_id) (vf_id) (on|off)\n"
356 " Set VF broadcast for a VF from the PF.\n\n"
358 "vlan set stripq (on|off) (port_id,queue_id)\n"
359 " Set the VLAN strip for a queue on a port.\n\n"
361 "set vf vlan stripq (port_id) (vf_id) (on|off)\n"
362 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
364 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
365 " Set VLAN insert for a VF from the PF.\n\n"
367 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
368 " Set VLAN antispoof for a VF from the PF.\n\n"
370 "set vf vlan tag (port_id) (vf_id) (on|off)\n"
371 " Set VLAN tag for a VF from the PF.\n\n"
373 "set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n"
374 " Set a VF's max bandwidth(Mbps).\n\n"
376 "set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n"
377 " Set all TCs' min bandwidth(%%) on a VF.\n\n"
379 "set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n"
380 " Set a TC's max bandwidth(Mbps) on a VF.\n\n"
382 "set tx strict-link-priority (port_id) (tc_bitmap)\n"
383 " Set some TCs' strict link priority mode on a physical port.\n\n"
385 "set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n"
386 " Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n"
388 "vlan set (strip|filter|qinq_strip|extend) (on|off) (port_id)\n"
389 " Set the VLAN strip or filter or qinq strip or extend\n\n"
391 "vlan set (inner|outer) tpid (value) (port_id)\n"
392 " Set the VLAN TPID for Packet Filtering on"
395 "rx_vlan add (vlan_id|all) (port_id)\n"
396 " Add a vlan_id, or all identifiers, to the set"
397 " of VLAN identifiers filtered by port_id.\n\n"
399 "rx_vlan rm (vlan_id|all) (port_id)\n"
400 " Remove a vlan_id, or all identifiers, from the set"
401 " of VLAN identifiers filtered by port_id.\n\n"
403 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
404 " Add a vlan_id, to the set of VLAN identifiers"
405 "filtered for VF(s) from port_id.\n\n"
407 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
408 " Remove a vlan_id, to the set of VLAN identifiers"
409 "filtered for VF(s) from port_id.\n\n"
411 "rx_vxlan_port add (udp_port) (port_id)\n"
412 " Add an UDP port for VXLAN packet filter on a port\n\n"
414 "rx_vxlan_port rm (udp_port) (port_id)\n"
415 " Remove an UDP port for VXLAN packet filter on a port\n\n"
417 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
418 " Set hardware insertion of VLAN IDs (single or double VLAN "
419 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
421 "tx_vlan set pvid port_id vlan_id (on|off)\n"
422 " Set port based TX VLAN insertion.\n\n"
424 "tx_vlan reset (port_id)\n"
425 " Disable hardware insertion of a VLAN header in"
426 " packets sent on a port.\n\n"
428 "csum set (ip|udp|tcp|sctp|outer-ip|outer-udp) (hw|sw) (port_id)\n"
429 " Select hardware or software calculation of the"
430 " checksum when transmitting a packet using the"
431 " csum forward engine.\n"
432 " ip|udp|tcp|sctp always concern the inner layer.\n"
433 " outer-ip concerns the outer IP layer in"
434 " outer-udp concerns the outer UDP layer in"
435 " case the packet is recognized as a tunnel packet by"
436 " the forward engine (vxlan, gre and ipip are supported)\n"
437 " Please check the NIC datasheet for HW limits.\n\n"
439 "csum parse-tunnel (on|off) (tx_port_id)\n"
440 " If disabled, treat tunnel packets as non-tunneled"
441 " packets (treat inner headers as payload). The port\n"
442 " argument is the port used for TX in csum forward"
445 "csum show (port_id)\n"
446 " Display tx checksum offload configuration\n\n"
448 "tso set (segsize) (portid)\n"
449 " Enable TCP Segmentation Offload in csum forward"
451 " Please check the NIC datasheet for HW limits.\n\n"
454 " Display the status of TCP Segmentation Offload.\n\n"
456 "set port (port_id) gro on|off\n"
457 " Enable or disable Generic Receive Offload in"
458 " csum forwarding engine.\n\n"
460 "show port (port_id) gro\n"
461 " Display GRO configuration.\n\n"
463 "set gro flush (cycles)\n"
464 " Set the cycle to flush GROed packets from"
465 " reassembly tables.\n\n"
467 "set port (port_id) gso (on|off)"
468 " Enable or disable Generic Segmentation Offload in"
469 " csum forwarding engine.\n\n"
471 "set gso segsz (length)\n"
472 " Set max packet length for output GSO segments,"
473 " including packet header and payload.\n\n"
475 "show port (port_id) gso\n"
476 " Show GSO configuration.\n\n"
479 " Set packet forwarding mode.\n\n"
481 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
482 " Add a MAC address on port_id.\n\n"
484 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
485 " Remove a MAC address from port_id.\n\n"
487 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
488 " Set the default MAC address for port_id.\n\n"
490 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
491 " Add a MAC address for a VF on the port.\n\n"
493 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
494 " Set the MAC address for a VF from the PF.\n\n"
496 "set eth-peer (port_id) (peer_addr)\n"
497 " set the peer address for certain port.\n\n"
499 "set port (port_id) uta (mac_address|all) (on|off)\n"
500 " Add/Remove a or all unicast hash filter(s)"
503 "set promisc (port_id|all) (on|off)\n"
504 " Set the promiscuous mode on port_id, or all.\n\n"
506 "set allmulti (port_id|all) (on|off)\n"
507 " Set the allmulti mode on port_id, or all.\n\n"
509 "set vf promisc (port_id) (vf_id) (on|off)\n"
510 " Set unicast promiscuous mode for a VF from the PF.\n\n"
512 "set vf allmulti (port_id) (vf_id) (on|off)\n"
513 " Set multicast promiscuous mode for a VF from the PF.\n\n"
515 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
516 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
517 " (on|off) autoneg (on|off) (port_id)\n"
518 "set flow_ctrl rx (on|off) (portid)\n"
519 "set flow_ctrl tx (on|off) (portid)\n"
520 "set flow_ctrl high_water (high_water) (portid)\n"
521 "set flow_ctrl low_water (low_water) (portid)\n"
522 "set flow_ctrl pause_time (pause_time) (portid)\n"
523 "set flow_ctrl send_xon (send_xon) (portid)\n"
524 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
525 "set flow_ctrl autoneg (on|off) (port_id)\n"
526 " Set the link flow control parameter on a port.\n\n"
528 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
529 " (low_water) (pause_time) (priority) (port_id)\n"
530 " Set the priority flow control parameter on a"
533 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
534 " Set statistics mapping (qmapping 0..15) for RX/TX"
536 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
537 " on port 0 to mapping 5.\n\n"
539 "set xstats-hide-zero on|off\n"
540 " Set the option to hide the zero values"
541 " for xstats display.\n"
543 "set record-core-cycles on|off\n"
544 " Set the option to enable measurement of CPU cycles.\n"
546 "set record-burst-stats on|off\n"
547 " Set the option to enable display of RX and TX bursts.\n"
549 "set port (port_id) vf (vf_id) rx|tx on|off\n"
550 " Enable/Disable a VF receive/tranmit from a port\n\n"
552 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
554 " AUPE:accepts untagged VLAN;"
555 "ROPE:accept unicast hash\n\n"
556 " BAM:accepts broadcast packets;"
557 "MPE:accepts all multicast packets\n\n"
558 " Enable/Disable a VF receive mode of a port\n\n"
560 "set port (port_id) queue (queue_id) rate (rate_num)\n"
561 " Set rate limit for a queue of a port\n\n"
563 "set port (port_id) vf (vf_id) rate (rate_num) "
564 "queue_mask (queue_mask_value)\n"
565 " Set rate limit for queues in VF of a port\n\n"
567 "set port (port_id) mirror-rule (rule_id)"
568 " (pool-mirror-up|pool-mirror-down|vlan-mirror)"
569 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
570 " Set pool or vlan type mirror rule on a port.\n"
571 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
572 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
575 "set port (port_id) mirror-rule (rule_id)"
576 " (uplink-mirror|downlink-mirror) dst-pool"
577 " (pool_id) (on|off)\n"
578 " Set uplink or downlink type mirror rule on a port.\n"
579 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
580 " 0 on' enable mirror income traffic to pool 0.\n\n"
582 "reset port (port_id) mirror-rule (rule_id)\n"
583 " Reset a mirror rule.\n\n"
585 "set flush_rx (on|off)\n"
586 " Flush (default) or don't flush RX streams before"
587 " forwarding. Mainly used with PCAP drivers.\n\n"
589 "set bypass mode (normal|bypass|isolate) (port_id)\n"
590 " Set the bypass mode for the lowest port on bypass enabled"
593 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
594 "mode (normal|bypass|isolate) (port_id)\n"
595 " Set the event required to initiate specified bypass mode for"
596 " the lowest port on a bypass enabled NIC where:\n"
597 " timeout = enable bypass after watchdog timeout.\n"
598 " os_on = enable bypass when OS/board is powered on.\n"
599 " os_off = enable bypass when OS/board is powered off.\n"
600 " power_on = enable bypass when power supply is turned on.\n"
601 " power_off = enable bypass when power supply is turned off."
604 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
605 " Set the bypass watchdog timeout to 'n' seconds"
606 " where 0 = instant.\n\n"
608 "show bypass config (port_id)\n"
609 " Show the bypass configuration for a bypass enabled NIC"
610 " using the lowest port on the NIC.\n\n"
613 "create bonded device (mode) (socket)\n"
614 " Create a new bonded device with specific bonding mode and socket.\n\n"
616 "add bonding slave (slave_id) (port_id)\n"
617 " Add a slave device to a bonded device.\n\n"
619 "remove bonding slave (slave_id) (port_id)\n"
620 " Remove a slave device from a bonded device.\n\n"
622 "set bonding mode (value) (port_id)\n"
623 " Set the bonding mode on a bonded device.\n\n"
625 "set bonding primary (slave_id) (port_id)\n"
626 " Set the primary slave for a bonded device.\n\n"
628 "show bonding config (port_id)\n"
629 " Show the bonding config for port_id.\n\n"
631 "set bonding mac_addr (port_id) (address)\n"
632 " Set the MAC address of a bonded device.\n\n"
634 "set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)"
635 " Set Aggregation mode for IEEE802.3AD (mode 4)"
637 "set bonding balance_xmit_policy (port_id) (l2|l23|l34)\n"
638 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
640 "set bonding mon_period (port_id) (value)\n"
641 " Set the bonding link status monitoring polling period in ms.\n\n"
643 "set bonding lacp dedicated_queues <port_id> (enable|disable)\n"
644 " Enable/disable dedicated queues for LACP control traffic.\n\n"
647 "set link-up port (port_id)\n"
648 " Set link up for a port.\n\n"
650 "set link-down port (port_id)\n"
651 " Set link down for a port.\n\n"
653 "E-tag set insertion on port-tag-id (value)"
654 " port (port_id) vf (vf_id)\n"
655 " Enable E-tag insertion for a VF on a port\n\n"
657 "E-tag set insertion off port (port_id) vf (vf_id)\n"
658 " Disable E-tag insertion for a VF on a port\n\n"
660 "E-tag set stripping (on|off) port (port_id)\n"
661 " Enable/disable E-tag stripping on a port\n\n"
663 "E-tag set forwarding (on|off) port (port_id)\n"
664 " Enable/disable E-tag based forwarding"
667 "E-tag set filter add e-tag-id (value) dst-pool"
668 " (pool_id) port (port_id)\n"
669 " Add an E-tag forwarding filter on a port\n\n"
671 "E-tag set filter del e-tag-id (value) port (port_id)\n"
672 " Delete an E-tag forwarding filter on a port\n\n"
674 "ddp add (port_id) (profile_path[,backup_profile_path])\n"
675 " Load a profile package on a port\n\n"
677 "ddp del (port_id) (backup_profile_path)\n"
678 " Delete a profile package from a port\n\n"
680 "ptype mapping get (port_id) (valid_only)\n"
681 " Get ptype mapping on a port\n\n"
683 "ptype mapping replace (port_id) (target) (mask) (pky_type)\n"
684 " Replace target with the pkt_type in ptype mapping\n\n"
686 "ptype mapping reset (port_id)\n"
687 " Reset ptype mapping on a port\n\n"
689 "ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n"
690 " Update a ptype mapping item on a port\n\n"
692 "set port (port_id) ptype_mask (ptype_mask)\n"
693 " set packet types classification for a specific port\n\n"
695 "set port (port_id) queue-region region_id (value) "
696 "queue_start_index (value) queue_num (value)\n"
697 " Set a queue region on a port\n\n"
699 "set port (port_id) queue-region region_id (value) "
701 " Set a flowtype region index on a port\n\n"
703 "set port (port_id) queue-region UP (value) region_id (value)\n"
704 " Set the mapping of User Priority to "
705 "queue region on a port\n\n"
707 "set port (port_id) queue-region flush (on|off)\n"
708 " flush all queue region related configuration\n\n"
710 "show port meter cap (port_id)\n"
711 " Show port meter capability information\n\n"
713 "add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs)\n"
714 " meter profile add - srtcm rfc 2697\n\n"
716 "add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs)\n"
717 " meter profile add - trtcm rfc 2698\n\n"
719 "add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs)\n"
720 " meter profile add - trtcm rfc 4115\n\n"
722 "del port meter profile (port_id) (profile_id)\n"
723 " meter profile delete\n\n"
725 "create port meter (port_id) (mtr_id) (profile_id) (meter_enable)\n"
726 "(g_action) (y_action) (r_action) (stats_mask) (shared)\n"
727 "(use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n"
728 "(dscp_tbl_entry63)]\n"
731 "enable port meter (port_id) (mtr_id)\n"
734 "disable port meter (port_id) (mtr_id)\n"
737 "del port meter (port_id) (mtr_id)\n"
740 "set port meter profile (port_id) (mtr_id) (profile_id)\n"
741 " meter update meter profile\n\n"
743 "set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n"
744 "(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n"
745 " update meter dscp table entries\n\n"
747 "set port meter policer action (port_id) (mtr_id) (action_mask)\n"
748 "(action0) [(action1) (action2)]\n"
749 " meter update policer action\n\n"
751 "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
752 " meter update stats\n\n"
754 "show port (port_id) queue-region\n"
755 " show all queue region related configuration info\n\n"
757 "set port (port_id) fec_mode auto|off|rs|baser\n"
758 " set fec mode for a specific port\n\n"
760 , list_pkt_forwarding_modes()
764 if (show_all || !strcmp(res->section, "ports")) {
770 "----------------\n\n"
772 "port start (port_id|all)\n"
773 " Start all ports or port_id.\n\n"
775 "port stop (port_id|all)\n"
776 " Stop all ports or port_id.\n\n"
778 "port close (port_id|all)\n"
779 " Close all ports or port_id.\n\n"
781 "port reset (port_id|all)\n"
782 " Reset all ports or port_id.\n\n"
784 "port attach (ident)\n"
785 " Attach physical or virtual dev by pci address or virtual device name\n\n"
787 "port detach (port_id)\n"
788 " Detach physical or virtual dev by port_id\n\n"
790 "port config (port_id|all)"
791 " speed (10|100|1000|10000|25000|40000|50000|100000|200000|auto)"
792 " duplex (half|full|auto)\n"
793 " Set speed and duplex for all ports or port_id\n\n"
795 "port config (port_id|all) loopback (mode)\n"
796 " Set loopback mode for all ports or port_id\n\n"
798 "port config all (rxq|txq|rxd|txd) (value)\n"
799 " Set number for rxq/txq/rxd/txd.\n\n"
801 "port config all max-pkt-len (value)\n"
802 " Set the max packet length.\n\n"
804 "port config all max-lro-pkt-size (value)\n"
805 " Set the max LRO aggregated packet size.\n\n"
807 "port config all drop-en (on|off)\n"
808 " Enable or disable packet drop on all RX queues of all ports when no "
809 "receive buffers available.\n\n"
811 "port config all rss (all|default|ip|tcp|udp|sctp|"
812 "ether|port|vxlan|geneve|nvgre|vxlan-gpe|none|level-default|"
813 "level-outer|level-inner|<flowtype_id>)\n"
814 " Set the RSS mode.\n\n"
816 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
817 " Set the RSS redirection table.\n\n"
819 "port config (port_id) dcb vt (on|off) (traffic_class)"
821 " Set the DCB mode.\n\n"
823 "port config all burst (value)\n"
824 " Set the number of packets per burst.\n\n"
826 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
828 " Set the ring prefetch/host/writeback threshold"
829 " for tx/rx queue.\n\n"
831 "port config all (txfreet|txrst|rxfreet) (value)\n"
832 " Set free threshold for rx/tx, or set"
833 " tx rs bit threshold.\n\n"
834 "port config mtu X value\n"
835 " Set the MTU of port X to a given value\n\n"
837 "port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n"
838 " Set a rx/tx queue's ring size configuration, the new"
839 " value will take effect after command that (re-)start the port"
840 " or command that setup the specific queue\n\n"
842 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
843 " Start/stop a rx/tx queue of port X. Only take effect"
844 " when port X is started\n\n"
846 "port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n"
847 " Switch on/off a deferred start of port X rx/tx queue. Only"
848 " take effect when port X is stopped.\n\n"
850 "port (port_id) (rxq|txq) (queue_id) setup\n"
851 " Setup a rx/tx queue of port X.\n\n"
853 "port config (port_id|all) l2-tunnel E-tag ether-type"
855 " Set the value of E-tag ether-type.\n\n"
857 "port config (port_id|all) l2-tunnel E-tag"
858 " (enable|disable)\n"
859 " Enable/disable the E-tag support.\n\n"
861 "port config (port_id) pctype mapping reset\n"
862 " Reset flow type to pctype mapping on a port\n\n"
864 "port config (port_id) pctype mapping update"
865 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
866 " Update a flow type to pctype mapping item on a port\n\n"
868 "port config (port_id) pctype (pctype_id) hash_inset|"
869 "fdir_inset|fdir_flx_inset get|set|clear field\n"
871 " Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n"
873 "port config (port_id) pctype (pctype_id) hash_inset|"
874 "fdir_inset|fdir_flx_inset clear all"
875 " Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n"
877 "port config (port_id) udp_tunnel_port add|rm vxlan|geneve (udp_port)\n\n"
878 " Add/remove UDP tunnel port for tunneling offload\n\n"
880 "port config <port_id> rx_offload vlan_strip|"
881 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
882 "outer_ipv4_cksum|macsec_strip|header_split|"
883 "vlan_filter|vlan_extend|jumbo_frame|scatter|"
884 "buffer_split|timestamp|security|keep_crc on|off\n"
885 " Enable or disable a per port Rx offloading"
886 " on all Rx queues of a port\n\n"
888 "port (port_id) rxq (queue_id) rx_offload vlan_strip|"
889 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
890 "outer_ipv4_cksum|macsec_strip|header_split|"
891 "vlan_filter|vlan_extend|jumbo_frame|scatter|"
892 "buffer_split|timestamp|security|keep_crc on|off\n"
893 " Enable or disable a per queue Rx offloading"
894 " only on a specific Rx queue\n\n"
896 "port config (port_id) tx_offload vlan_insert|"
897 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
898 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
899 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|"
900 "macsec_insert|mt_lockfree|multi_segs|mbuf_fast_free|"
902 " Enable or disable a per port Tx offloading"
903 " on all Tx queues of a port\n\n"
905 "port (port_id) txq (queue_id) tx_offload vlan_insert|"
906 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
907 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
908 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|macsec_insert"
909 "|mt_lockfree|multi_segs|mbuf_fast_free|security"
911 " Enable or disable a per queue Tx offloading"
912 " only on a specific Tx queue\n\n"
914 "bpf-load rx|tx (port) (queue) (J|M|B) (file_name)\n"
915 " Load an eBPF program as a callback"
916 " for particular RX/TX queue\n\n"
918 "bpf-unload rx|tx (port) (queue)\n"
919 " Unload previously loaded eBPF program"
920 " for particular RX/TX queue\n\n"
922 "port config (port_id) tx_metadata (value)\n"
923 " Set Tx metadata value per port. Testpmd will add this value"
924 " to any Tx packet sent from this port\n\n"
926 "port config (port_id) dynf (name) set|clear\n"
927 " Register a dynf and Set/clear this flag on Tx. "
928 "Testpmd will set this value to any Tx packet "
929 "sent from this port\n\n"
933 if (show_all || !strcmp(res->section, "registers")) {
941 "read reg (port_id) (address)\n"
942 " Display value of a port register.\n\n"
944 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
945 " Display a port register bit field.\n\n"
947 "read regbit (port_id) (address) (bit_x)\n"
948 " Display a single port register bit.\n\n"
950 "write reg (port_id) (address) (value)\n"
951 " Set value of a port register.\n\n"
953 "write regfield (port_id) (address) (bit_x) (bit_y)"
955 " Set bit field of a port register.\n\n"
957 "write regbit (port_id) (address) (bit_x) (value)\n"
958 " Set single bit value of a port register.\n\n"
961 if (show_all || !strcmp(res->section, "filters")) {
969 "flow_director_filter (port_id) mode IP (add|del|update)"
970 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
971 " src (src_ip_address) dst (dst_ip_address)"
972 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
973 " vlan (vlan_value) flexbytes (flexbytes_value)"
974 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
975 " fd_id (fd_id_value)\n"
976 " Add/Del an IP type flow director filter.\n\n"
978 "flow_director_filter (port_id) mode IP (add|del|update)"
979 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
980 " src (src_ip_address) (src_port)"
981 " dst (dst_ip_address) (dst_port)"
982 " tos (tos_value) ttl (ttl_value)"
983 " vlan (vlan_value) flexbytes (flexbytes_value)"
984 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
985 " fd_id (fd_id_value)\n"
986 " Add/Del an UDP/TCP type flow director filter.\n\n"
988 "flow_director_filter (port_id) mode IP (add|del|update)"
989 " flow (ipv4-sctp|ipv6-sctp)"
990 " src (src_ip_address) (src_port)"
991 " dst (dst_ip_address) (dst_port)"
992 " tag (verification_tag) "
993 " tos (tos_value) ttl (ttl_value)"
995 " flexbytes (flexbytes_value) (drop|fwd)"
996 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
997 " Add/Del a SCTP type flow director filter.\n\n"
999 "flow_director_filter (port_id) mode IP (add|del|update)"
1000 " flow l2_payload ether (ethertype)"
1001 " flexbytes (flexbytes_value) (drop|fwd)"
1002 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
1003 " Add/Del a l2 payload type flow director filter.\n\n"
1005 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
1006 " mac (mac_address) vlan (vlan_value)"
1007 " flexbytes (flexbytes_value) (drop|fwd)"
1008 " queue (queue_id) fd_id (fd_id_value)\n"
1009 " Add/Del a MAC-VLAN flow director filter.\n\n"
1011 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
1012 " mac (mac_address) vlan (vlan_value)"
1013 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
1014 " flexbytes (flexbytes_value) (drop|fwd)"
1015 " queue (queue_id) fd_id (fd_id_value)\n"
1016 " Add/Del a Tunnel flow director filter.\n\n"
1018 "flow_director_filter (port_id) mode raw (add|del|update)"
1019 " flow (flow_id) (drop|fwd) queue (queue_id)"
1020 " fd_id (fd_id_value) packet (packet file name)\n"
1021 " Add/Del a raw type flow director filter.\n\n"
1023 "flush_flow_director (port_id)\n"
1024 " Flush all flow director entries of a device.\n\n"
1026 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
1027 " src_mask (ipv4_src) (ipv6_src) (src_port)"
1028 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
1029 " Set flow director IP mask.\n\n"
1031 "flow_director_mask (port_id) mode MAC-VLAN"
1032 " vlan (vlan_value)\n"
1033 " Set flow director MAC-VLAN mask.\n\n"
1035 "flow_director_mask (port_id) mode Tunnel"
1036 " vlan (vlan_value) mac (mac_value)"
1037 " tunnel-type (tunnel_type_value)"
1038 " tunnel-id (tunnel_id_value)\n"
1039 " Set flow director Tunnel mask.\n\n"
1041 "flow_director_flex_mask (port_id)"
1042 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
1043 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
1045 " Configure mask of flex payload.\n\n"
1047 "flow_director_flex_payload (port_id)"
1048 " (raw|l2|l3|l4) (config)\n"
1049 " Configure flex payload selection.\n\n"
1051 "get_sym_hash_ena_per_port (port_id)\n"
1052 " get symmetric hash enable configuration per port.\n\n"
1054 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
1055 " set symmetric hash enable configuration per port"
1056 " to enable or disable.\n\n"
1058 "get_hash_global_config (port_id)\n"
1059 " Get the global configurations of hash filters.\n\n"
1061 "set_hash_global_config (port_id) (toeplitz|simple_xor|symmetric_toeplitz|default)"
1062 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1063 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
1064 " (enable|disable)\n"
1065 " Set the global configurations of hash filters.\n\n"
1067 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
1068 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1069 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1070 "l2_payload|<flowtype_id>) (ovlan|ivlan|src-ipv4|dst-ipv4|"
1071 "src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
1072 "ipv6-next-header|udp-src-port|udp-dst-port|"
1073 "tcp-src-port|tcp-dst-port|sctp-src-port|"
1074 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
1075 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
1076 "fld-8th|none) (select|add)\n"
1077 " Set the input set for hash.\n\n"
1079 "set_fdir_input_set (port_id) "
1080 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1081 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1082 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
1083 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
1084 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
1085 "udp-dst-port|tcp-src-port|tcp-dst-port|"
1086 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
1088 " Set the input set for FDir.\n\n"
1090 "flow validate {port_id}"
1091 " [group {group_id}] [priority {level}]"
1092 " [ingress] [egress]"
1093 " pattern {item} [/ {item} [...]] / end"
1094 " actions {action} [/ {action} [...]] / end\n"
1095 " Check whether a flow rule can be created.\n\n"
1097 "flow create {port_id}"
1098 " [group {group_id}] [priority {level}]"
1099 " [ingress] [egress]"
1100 " pattern {item} [/ {item} [...]] / end"
1101 " actions {action} [/ {action} [...]] / end\n"
1102 " Create a flow rule.\n\n"
1104 "flow destroy {port_id} rule {rule_id} [...]\n"
1105 " Destroy specific flow rules.\n\n"
1107 "flow flush {port_id}\n"
1108 " Destroy all flow rules.\n\n"
1110 "flow query {port_id} {rule_id} {action}\n"
1111 " Query an existing flow rule.\n\n"
1113 "flow list {port_id} [group {group_id}] [...]\n"
1114 " List existing flow rules sorted by priority,"
1115 " filtered by group identifiers.\n\n"
1117 "flow isolate {port_id} {boolean}\n"
1118 " Restrict ingress traffic to the defined"
1121 "flow aged {port_id} [destroy]\n"
1122 " List and destroy aged flows"
1125 "flow shared_action {port_id} create"
1126 " [action_id {shared_action_id}]"
1127 " [ingress] [egress]"
1128 " action {action} / end\n"
1129 " Create shared action.\n\n"
1131 "flow shared_action {port_id} update"
1132 " {shared_action_id} action {action} / end\n"
1133 " Update shared action.\n\n"
1135 "flow shared_action {port_id} destroy"
1136 " action_id {shared_action_id} [...]\n"
1137 " Destroy specific shared actions.\n\n"
1139 "flow shared_action {port_id} query"
1140 " {shared_action_id}\n"
1141 " Query an existing shared action.\n\n"
1143 "set vxlan ip-version (ipv4|ipv6) vni (vni) udp-src"
1144 " (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst"
1145 " (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n"
1146 " Configure the VXLAN encapsulation for flows.\n\n"
1148 "set vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)"
1149 " udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)"
1150 " ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)"
1151 " eth-dst (eth-dst)\n"
1152 " Configure the VXLAN encapsulation for flows.\n\n"
1154 "set vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src"
1155 " (udp-src) udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl)"
1156 " ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src)"
1157 " eth-dst (eth-dst)\n"
1158 " Configure the VXLAN encapsulation for flows.\n\n"
1160 "set nvgre ip-version (ipv4|ipv6) tni (tni) ip-src"
1161 " (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst"
1163 " Configure the NVGRE encapsulation for flows.\n\n"
1165 "set nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)"
1166 " ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)"
1167 " eth-src (eth-src) eth-dst (eth-dst)\n"
1168 " Configure the NVGRE encapsulation for flows.\n\n"
1170 "set raw_encap {flow items}\n"
1171 " Configure the encapsulation with raw data.\n\n"
1173 "set raw_decap {flow items}\n"
1174 " Configure the decapsulation with raw data.\n\n"
1179 if (show_all || !strcmp(res->section, "traffic_management")) {
1183 "Traffic Management:\n"
1185 "show port tm cap (port_id)\n"
1186 " Display the port TM capability.\n\n"
1188 "show port tm level cap (port_id) (level_id)\n"
1189 " Display the port TM hierarchical level capability.\n\n"
1191 "show port tm node cap (port_id) (node_id)\n"
1192 " Display the port TM node capability.\n\n"
1194 "show port tm node type (port_id) (node_id)\n"
1195 " Display the port TM node type.\n\n"
1197 "show port tm node stats (port_id) (node_id) (clear)\n"
1198 " Display the port TM node stats.\n\n"
1200 "add port tm node shaper profile (port_id) (shaper_profile_id)"
1201 " (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)"
1202 " (packet_length_adjust) (packet_mode)\n"
1203 " Add port tm node private shaper profile.\n\n"
1205 "del port tm node shaper profile (port_id) (shaper_profile_id)\n"
1206 " Delete port tm node private shaper profile.\n\n"
1208 "add port tm node shared shaper (port_id) (shared_shaper_id)"
1209 " (shaper_profile_id)\n"
1210 " Add/update port tm node shared shaper.\n\n"
1212 "del port tm node shared shaper (port_id) (shared_shaper_id)\n"
1213 " Delete port tm node shared shaper.\n\n"
1215 "set port tm node shaper profile (port_id) (node_id)"
1216 " (shaper_profile_id)\n"
1217 " Set port tm node shaper profile.\n\n"
1219 "add port tm node wred profile (port_id) (wred_profile_id)"
1220 " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
1221 " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
1222 " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
1223 " Add port tm node wred profile.\n\n"
1225 "del port tm node wred profile (port_id) (wred_profile_id)\n"
1226 " Delete port tm node wred profile.\n\n"
1228 "add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
1229 " (priority) (weight) (level_id) (shaper_profile_id)"
1230 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1231 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1232 " Add port tm nonleaf node.\n\n"
1234 "add port tm nonleaf node pktmode (port_id) (node_id) (parent_node_id)"
1235 " (priority) (weight) (level_id) (shaper_profile_id)"
1236 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1237 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1238 " Add port tm nonleaf node with pkt mode enabled.\n\n"
1240 "add port tm leaf node (port_id) (node_id) (parent_node_id)"
1241 " (priority) (weight) (level_id) (shaper_profile_id)"
1242 " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
1243 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1244 " Add port tm leaf node.\n\n"
1246 "del port tm node (port_id) (node_id)\n"
1247 " Delete port tm node.\n\n"
1249 "set port tm node parent (port_id) (node_id) (parent_node_id)"
1250 " (priority) (weight)\n"
1251 " Set port tm node parent.\n\n"
1253 "suspend port tm node (port_id) (node_id)"
1254 " Suspend tm node.\n\n"
1256 "resume port tm node (port_id) (node_id)"
1257 " Resume tm node.\n\n"
1259 "port tm hierarchy commit (port_id) (clean_on_fail)\n"
1260 " Commit tm hierarchy.\n\n"
1262 "set port tm mark ip_ecn (port) (green) (yellow)"
1264 " Enables/Disables the traffic management marking"
1265 " for IP ECN (Explicit Congestion Notification)"
1266 " packets on a given port\n\n"
1268 "set port tm mark ip_dscp (port) (green) (yellow)"
1270 " Enables/Disables the traffic management marking"
1271 " on the port for IP dscp packets\n\n"
1273 "set port tm mark vlan_dei (port) (green) (yellow)"
1275 " Enables/Disables the traffic management marking"
1276 " on the port for VLAN packets with DEI enabled\n\n"
1280 if (show_all || !strcmp(res->section, "devices")) {
1284 "Device Operations:\n"
1286 "device detach (identifier)\n"
1287 " Detach device by identifier.\n\n"
1293 cmdline_parse_token_string_t cmd_help_long_help =
1294 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1296 cmdline_parse_token_string_t cmd_help_long_section =
1297 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1298 "all#control#display#config#"
1299 "ports#registers#filters#traffic_management#devices");
1301 cmdline_parse_inst_t cmd_help_long = {
1302 .f = cmd_help_long_parsed,
1304 .help_str = "help all|control|display|config|ports|register|"
1305 "filters|traffic_management|devices: "
1308 (void *)&cmd_help_long_help,
1309 (void *)&cmd_help_long_section,
1315 /* *** start/stop/close all ports *** */
1316 struct cmd_operate_port_result {
1317 cmdline_fixed_string_t keyword;
1318 cmdline_fixed_string_t name;
1319 cmdline_fixed_string_t value;
1322 static void cmd_operate_port_parsed(void *parsed_result,
1323 __rte_unused struct cmdline *cl,
1324 __rte_unused void *data)
1326 struct cmd_operate_port_result *res = parsed_result;
1328 if (!strcmp(res->name, "start"))
1329 start_port(RTE_PORT_ALL);
1330 else if (!strcmp(res->name, "stop"))
1331 stop_port(RTE_PORT_ALL);
1332 else if (!strcmp(res->name, "close"))
1333 close_port(RTE_PORT_ALL);
1334 else if (!strcmp(res->name, "reset"))
1335 reset_port(RTE_PORT_ALL);
1337 printf("Unknown parameter\n");
1340 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1341 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1343 cmdline_parse_token_string_t cmd_operate_port_all_port =
1344 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1345 "start#stop#close#reset");
1346 cmdline_parse_token_string_t cmd_operate_port_all_all =
1347 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1349 cmdline_parse_inst_t cmd_operate_port = {
1350 .f = cmd_operate_port_parsed,
1352 .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports",
1354 (void *)&cmd_operate_port_all_cmd,
1355 (void *)&cmd_operate_port_all_port,
1356 (void *)&cmd_operate_port_all_all,
1361 /* *** start/stop/close specific port *** */
1362 struct cmd_operate_specific_port_result {
1363 cmdline_fixed_string_t keyword;
1364 cmdline_fixed_string_t name;
1368 static void cmd_operate_specific_port_parsed(void *parsed_result,
1369 __rte_unused struct cmdline *cl,
1370 __rte_unused void *data)
1372 struct cmd_operate_specific_port_result *res = parsed_result;
1374 if (!strcmp(res->name, "start"))
1375 start_port(res->value);
1376 else if (!strcmp(res->name, "stop"))
1377 stop_port(res->value);
1378 else if (!strcmp(res->name, "close"))
1379 close_port(res->value);
1380 else if (!strcmp(res->name, "reset"))
1381 reset_port(res->value);
1383 printf("Unknown parameter\n");
1386 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1387 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1389 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1390 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1391 name, "start#stop#close#reset");
1392 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1393 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1396 cmdline_parse_inst_t cmd_operate_specific_port = {
1397 .f = cmd_operate_specific_port_parsed,
1399 .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id",
1401 (void *)&cmd_operate_specific_port_cmd,
1402 (void *)&cmd_operate_specific_port_port,
1403 (void *)&cmd_operate_specific_port_id,
1408 /* *** enable port setup (after attach) via iterator or event *** */
1409 struct cmd_set_port_setup_on_result {
1410 cmdline_fixed_string_t set;
1411 cmdline_fixed_string_t port;
1412 cmdline_fixed_string_t setup;
1413 cmdline_fixed_string_t on;
1414 cmdline_fixed_string_t mode;
1417 static void cmd_set_port_setup_on_parsed(void *parsed_result,
1418 __rte_unused struct cmdline *cl,
1419 __rte_unused void *data)
1421 struct cmd_set_port_setup_on_result *res = parsed_result;
1423 if (strcmp(res->mode, "event") == 0)
1424 setup_on_probe_event = true;
1425 else if (strcmp(res->mode, "iterator") == 0)
1426 setup_on_probe_event = false;
1428 printf("Unknown mode\n");
1431 cmdline_parse_token_string_t cmd_set_port_setup_on_set =
1432 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1434 cmdline_parse_token_string_t cmd_set_port_setup_on_port =
1435 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1437 cmdline_parse_token_string_t cmd_set_port_setup_on_setup =
1438 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1440 cmdline_parse_token_string_t cmd_set_port_setup_on_on =
1441 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1443 cmdline_parse_token_string_t cmd_set_port_setup_on_mode =
1444 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1445 mode, "iterator#event");
1447 cmdline_parse_inst_t cmd_set_port_setup_on = {
1448 .f = cmd_set_port_setup_on_parsed,
1450 .help_str = "set port setup on iterator|event",
1452 (void *)&cmd_set_port_setup_on_set,
1453 (void *)&cmd_set_port_setup_on_port,
1454 (void *)&cmd_set_port_setup_on_setup,
1455 (void *)&cmd_set_port_setup_on_on,
1456 (void *)&cmd_set_port_setup_on_mode,
1461 /* *** attach a specified port *** */
1462 struct cmd_operate_attach_port_result {
1463 cmdline_fixed_string_t port;
1464 cmdline_fixed_string_t keyword;
1465 cmdline_multi_string_t identifier;
1468 static void cmd_operate_attach_port_parsed(void *parsed_result,
1469 __rte_unused struct cmdline *cl,
1470 __rte_unused void *data)
1472 struct cmd_operate_attach_port_result *res = parsed_result;
1474 if (!strcmp(res->keyword, "attach"))
1475 attach_port(res->identifier);
1477 printf("Unknown parameter\n");
1480 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1481 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1483 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1484 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1486 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1487 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1488 identifier, TOKEN_STRING_MULTI);
1490 cmdline_parse_inst_t cmd_operate_attach_port = {
1491 .f = cmd_operate_attach_port_parsed,
1493 .help_str = "port attach <identifier>: "
1494 "(identifier: pci address or virtual dev name)",
1496 (void *)&cmd_operate_attach_port_port,
1497 (void *)&cmd_operate_attach_port_keyword,
1498 (void *)&cmd_operate_attach_port_identifier,
1503 /* *** detach a specified port *** */
1504 struct cmd_operate_detach_port_result {
1505 cmdline_fixed_string_t port;
1506 cmdline_fixed_string_t keyword;
1510 static void cmd_operate_detach_port_parsed(void *parsed_result,
1511 __rte_unused struct cmdline *cl,
1512 __rte_unused void *data)
1514 struct cmd_operate_detach_port_result *res = parsed_result;
1516 if (!strcmp(res->keyword, "detach")) {
1517 RTE_ETH_VALID_PORTID_OR_RET(res->port_id);
1518 detach_port_device(res->port_id);
1520 printf("Unknown parameter\n");
1524 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1525 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1527 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1528 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1530 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1531 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1534 cmdline_parse_inst_t cmd_operate_detach_port = {
1535 .f = cmd_operate_detach_port_parsed,
1537 .help_str = "port detach <port_id>",
1539 (void *)&cmd_operate_detach_port_port,
1540 (void *)&cmd_operate_detach_port_keyword,
1541 (void *)&cmd_operate_detach_port_port_id,
1546 /* *** detach device by identifier *** */
1547 struct cmd_operate_detach_device_result {
1548 cmdline_fixed_string_t device;
1549 cmdline_fixed_string_t keyword;
1550 cmdline_fixed_string_t identifier;
1553 static void cmd_operate_detach_device_parsed(void *parsed_result,
1554 __rte_unused struct cmdline *cl,
1555 __rte_unused void *data)
1557 struct cmd_operate_detach_device_result *res = parsed_result;
1559 if (!strcmp(res->keyword, "detach"))
1560 detach_devargs(res->identifier);
1562 printf("Unknown parameter\n");
1565 cmdline_parse_token_string_t cmd_operate_detach_device_device =
1566 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1568 cmdline_parse_token_string_t cmd_operate_detach_device_keyword =
1569 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1571 cmdline_parse_token_string_t cmd_operate_detach_device_identifier =
1572 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1575 cmdline_parse_inst_t cmd_operate_detach_device = {
1576 .f = cmd_operate_detach_device_parsed,
1578 .help_str = "device detach <identifier>:"
1579 "(identifier: pci address or virtual dev name)",
1581 (void *)&cmd_operate_detach_device_device,
1582 (void *)&cmd_operate_detach_device_keyword,
1583 (void *)&cmd_operate_detach_device_identifier,
1587 /* *** configure speed for all ports *** */
1588 struct cmd_config_speed_all {
1589 cmdline_fixed_string_t port;
1590 cmdline_fixed_string_t keyword;
1591 cmdline_fixed_string_t all;
1592 cmdline_fixed_string_t item1;
1593 cmdline_fixed_string_t item2;
1594 cmdline_fixed_string_t value1;
1595 cmdline_fixed_string_t value2;
1599 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1604 if (!strcmp(duplexstr, "half")) {
1605 duplex = ETH_LINK_HALF_DUPLEX;
1606 } else if (!strcmp(duplexstr, "full")) {
1607 duplex = ETH_LINK_FULL_DUPLEX;
1608 } else if (!strcmp(duplexstr, "auto")) {
1609 duplex = ETH_LINK_FULL_DUPLEX;
1611 printf("Unknown duplex parameter\n");
1615 if (!strcmp(speedstr, "10")) {
1616 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1617 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1618 } else if (!strcmp(speedstr, "100")) {
1619 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1620 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1622 if (duplex != ETH_LINK_FULL_DUPLEX) {
1623 printf("Invalid speed/duplex parameters\n");
1626 if (!strcmp(speedstr, "1000")) {
1627 *speed = ETH_LINK_SPEED_1G;
1628 } else if (!strcmp(speedstr, "10000")) {
1629 *speed = ETH_LINK_SPEED_10G;
1630 } else if (!strcmp(speedstr, "25000")) {
1631 *speed = ETH_LINK_SPEED_25G;
1632 } else if (!strcmp(speedstr, "40000")) {
1633 *speed = ETH_LINK_SPEED_40G;
1634 } else if (!strcmp(speedstr, "50000")) {
1635 *speed = ETH_LINK_SPEED_50G;
1636 } else if (!strcmp(speedstr, "100000")) {
1637 *speed = ETH_LINK_SPEED_100G;
1638 } else if (!strcmp(speedstr, "200000")) {
1639 *speed = ETH_LINK_SPEED_200G;
1640 } else if (!strcmp(speedstr, "auto")) {
1641 *speed = ETH_LINK_SPEED_AUTONEG;
1643 printf("Unknown speed parameter\n");
1652 cmd_config_speed_all_parsed(void *parsed_result,
1653 __rte_unused struct cmdline *cl,
1654 __rte_unused void *data)
1656 struct cmd_config_speed_all *res = parsed_result;
1657 uint32_t link_speed;
1660 if (!all_ports_stopped()) {
1661 printf("Please stop all ports first\n");
1665 if (parse_and_check_speed_duplex(res->value1, res->value2,
1669 RTE_ETH_FOREACH_DEV(pid) {
1670 ports[pid].dev_conf.link_speeds = link_speed;
1673 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1676 cmdline_parse_token_string_t cmd_config_speed_all_port =
1677 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1678 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1679 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1681 cmdline_parse_token_string_t cmd_config_speed_all_all =
1682 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1683 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1684 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1685 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1686 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1687 "10#100#1000#10000#25000#40000#50000#100000#200000#auto");
1688 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1689 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1690 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1691 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1694 cmdline_parse_inst_t cmd_config_speed_all = {
1695 .f = cmd_config_speed_all_parsed,
1697 .help_str = "port config all speed "
1698 "10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex "
1701 (void *)&cmd_config_speed_all_port,
1702 (void *)&cmd_config_speed_all_keyword,
1703 (void *)&cmd_config_speed_all_all,
1704 (void *)&cmd_config_speed_all_item1,
1705 (void *)&cmd_config_speed_all_value1,
1706 (void *)&cmd_config_speed_all_item2,
1707 (void *)&cmd_config_speed_all_value2,
1712 /* *** configure speed for specific port *** */
1713 struct cmd_config_speed_specific {
1714 cmdline_fixed_string_t port;
1715 cmdline_fixed_string_t keyword;
1717 cmdline_fixed_string_t item1;
1718 cmdline_fixed_string_t item2;
1719 cmdline_fixed_string_t value1;
1720 cmdline_fixed_string_t value2;
1724 cmd_config_speed_specific_parsed(void *parsed_result,
1725 __rte_unused struct cmdline *cl,
1726 __rte_unused void *data)
1728 struct cmd_config_speed_specific *res = parsed_result;
1729 uint32_t link_speed;
1731 if (!all_ports_stopped()) {
1732 printf("Please stop all ports first\n");
1736 if (port_id_is_invalid(res->id, ENABLED_WARN))
1739 if (parse_and_check_speed_duplex(res->value1, res->value2,
1743 ports[res->id].dev_conf.link_speeds = link_speed;
1745 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1749 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1750 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1752 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1753 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1755 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1756 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT16);
1757 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1758 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1760 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1761 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1762 "10#100#1000#10000#25000#40000#50000#100000#200000#auto");
1763 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1764 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1766 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1767 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1770 cmdline_parse_inst_t cmd_config_speed_specific = {
1771 .f = cmd_config_speed_specific_parsed,
1773 .help_str = "port config <port_id> speed "
1774 "10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex "
1777 (void *)&cmd_config_speed_specific_port,
1778 (void *)&cmd_config_speed_specific_keyword,
1779 (void *)&cmd_config_speed_specific_id,
1780 (void *)&cmd_config_speed_specific_item1,
1781 (void *)&cmd_config_speed_specific_value1,
1782 (void *)&cmd_config_speed_specific_item2,
1783 (void *)&cmd_config_speed_specific_value2,
1788 /* *** configure loopback for all ports *** */
1789 struct cmd_config_loopback_all {
1790 cmdline_fixed_string_t port;
1791 cmdline_fixed_string_t keyword;
1792 cmdline_fixed_string_t all;
1793 cmdline_fixed_string_t item;
1798 cmd_config_loopback_all_parsed(void *parsed_result,
1799 __rte_unused struct cmdline *cl,
1800 __rte_unused void *data)
1802 struct cmd_config_loopback_all *res = parsed_result;
1805 if (!all_ports_stopped()) {
1806 printf("Please stop all ports first\n");
1810 RTE_ETH_FOREACH_DEV(pid) {
1811 ports[pid].dev_conf.lpbk_mode = res->mode;
1814 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1817 cmdline_parse_token_string_t cmd_config_loopback_all_port =
1818 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1819 cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1820 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1822 cmdline_parse_token_string_t cmd_config_loopback_all_all =
1823 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1824 cmdline_parse_token_string_t cmd_config_loopback_all_item =
1825 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1827 cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1828 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, UINT32);
1830 cmdline_parse_inst_t cmd_config_loopback_all = {
1831 .f = cmd_config_loopback_all_parsed,
1833 .help_str = "port config all loopback <mode>",
1835 (void *)&cmd_config_loopback_all_port,
1836 (void *)&cmd_config_loopback_all_keyword,
1837 (void *)&cmd_config_loopback_all_all,
1838 (void *)&cmd_config_loopback_all_item,
1839 (void *)&cmd_config_loopback_all_mode,
1844 /* *** configure loopback for specific port *** */
1845 struct cmd_config_loopback_specific {
1846 cmdline_fixed_string_t port;
1847 cmdline_fixed_string_t keyword;
1849 cmdline_fixed_string_t item;
1854 cmd_config_loopback_specific_parsed(void *parsed_result,
1855 __rte_unused struct cmdline *cl,
1856 __rte_unused void *data)
1858 struct cmd_config_loopback_specific *res = parsed_result;
1860 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1863 if (!port_is_stopped(res->port_id)) {
1864 printf("Please stop port %u first\n", res->port_id);
1868 ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1870 cmd_reconfig_device_queue(res->port_id, 1, 1);
1874 cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1875 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1877 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1878 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1880 cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1881 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1883 cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1884 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1886 cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1887 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1890 cmdline_parse_inst_t cmd_config_loopback_specific = {
1891 .f = cmd_config_loopback_specific_parsed,
1893 .help_str = "port config <port_id> loopback <mode>",
1895 (void *)&cmd_config_loopback_specific_port,
1896 (void *)&cmd_config_loopback_specific_keyword,
1897 (void *)&cmd_config_loopback_specific_id,
1898 (void *)&cmd_config_loopback_specific_item,
1899 (void *)&cmd_config_loopback_specific_mode,
1904 /* *** configure txq/rxq, txd/rxd *** */
1905 struct cmd_config_rx_tx {
1906 cmdline_fixed_string_t port;
1907 cmdline_fixed_string_t keyword;
1908 cmdline_fixed_string_t all;
1909 cmdline_fixed_string_t name;
1914 cmd_config_rx_tx_parsed(void *parsed_result,
1915 __rte_unused struct cmdline *cl,
1916 __rte_unused void *data)
1918 struct cmd_config_rx_tx *res = parsed_result;
1920 if (!all_ports_stopped()) {
1921 printf("Please stop all ports first\n");
1924 if (!strcmp(res->name, "rxq")) {
1925 if (!res->value && !nb_txq) {
1926 printf("Warning: Either rx or tx queues should be non zero\n");
1929 if (check_nb_rxq(res->value) != 0)
1931 nb_rxq = res->value;
1933 else if (!strcmp(res->name, "txq")) {
1934 if (!res->value && !nb_rxq) {
1935 printf("Warning: Either rx or tx queues should be non zero\n");
1938 if (check_nb_txq(res->value) != 0)
1940 nb_txq = res->value;
1942 else if (!strcmp(res->name, "rxd")) {
1943 if (check_nb_rxd(res->value) != 0)
1945 nb_rxd = res->value;
1946 } else if (!strcmp(res->name, "txd")) {
1947 if (check_nb_txd(res->value) != 0)
1950 nb_txd = res->value;
1952 printf("Unknown parameter\n");
1960 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1963 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1964 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1965 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1966 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1967 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1968 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1969 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1970 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1972 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1973 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1975 cmdline_parse_inst_t cmd_config_rx_tx = {
1976 .f = cmd_config_rx_tx_parsed,
1978 .help_str = "port config all rxq|txq|rxd|txd <value>",
1980 (void *)&cmd_config_rx_tx_port,
1981 (void *)&cmd_config_rx_tx_keyword,
1982 (void *)&cmd_config_rx_tx_all,
1983 (void *)&cmd_config_rx_tx_name,
1984 (void *)&cmd_config_rx_tx_value,
1989 /* *** config max packet length *** */
1990 struct cmd_config_max_pkt_len_result {
1991 cmdline_fixed_string_t port;
1992 cmdline_fixed_string_t keyword;
1993 cmdline_fixed_string_t all;
1994 cmdline_fixed_string_t name;
1999 cmd_config_max_pkt_len_parsed(void *parsed_result,
2000 __rte_unused struct cmdline *cl,
2001 __rte_unused void *data)
2003 struct cmd_config_max_pkt_len_result *res = parsed_result;
2006 if (!all_ports_stopped()) {
2007 printf("Please stop all ports first\n");
2011 RTE_ETH_FOREACH_DEV(pid) {
2012 struct rte_port *port = &ports[pid];
2013 uint64_t rx_offloads = port->dev_conf.rxmode.offloads;
2015 if (!strcmp(res->name, "max-pkt-len")) {
2016 if (res->value < RTE_ETHER_MIN_LEN) {
2017 printf("max-pkt-len can not be less than %d\n",
2021 if (res->value == port->dev_conf.rxmode.max_rx_pkt_len)
2024 port->dev_conf.rxmode.max_rx_pkt_len = res->value;
2025 if (res->value > RTE_ETHER_MAX_LEN)
2026 rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
2028 rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
2029 port->dev_conf.rxmode.offloads = rx_offloads;
2031 printf("Unknown parameter\n");
2038 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2041 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
2042 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
2044 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
2045 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
2047 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
2048 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
2050 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
2051 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
2053 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
2054 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
2057 cmdline_parse_inst_t cmd_config_max_pkt_len = {
2058 .f = cmd_config_max_pkt_len_parsed,
2060 .help_str = "port config all max-pkt-len <value>",
2062 (void *)&cmd_config_max_pkt_len_port,
2063 (void *)&cmd_config_max_pkt_len_keyword,
2064 (void *)&cmd_config_max_pkt_len_all,
2065 (void *)&cmd_config_max_pkt_len_name,
2066 (void *)&cmd_config_max_pkt_len_value,
2071 /* *** config max LRO aggregated packet size *** */
2072 struct cmd_config_max_lro_pkt_size_result {
2073 cmdline_fixed_string_t port;
2074 cmdline_fixed_string_t keyword;
2075 cmdline_fixed_string_t all;
2076 cmdline_fixed_string_t name;
2081 cmd_config_max_lro_pkt_size_parsed(void *parsed_result,
2082 __rte_unused struct cmdline *cl,
2083 __rte_unused void *data)
2085 struct cmd_config_max_lro_pkt_size_result *res = parsed_result;
2088 if (!all_ports_stopped()) {
2089 printf("Please stop all ports first\n");
2093 RTE_ETH_FOREACH_DEV(pid) {
2094 struct rte_port *port = &ports[pid];
2096 if (!strcmp(res->name, "max-lro-pkt-size")) {
2098 port->dev_conf.rxmode.max_lro_pkt_size)
2101 port->dev_conf.rxmode.max_lro_pkt_size = res->value;
2103 printf("Unknown parameter\n");
2110 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2113 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_port =
2114 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2116 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_keyword =
2117 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2119 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_all =
2120 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2122 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_name =
2123 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2124 name, "max-lro-pkt-size");
2125 cmdline_parse_token_num_t cmd_config_max_lro_pkt_size_value =
2126 TOKEN_NUM_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2129 cmdline_parse_inst_t cmd_config_max_lro_pkt_size = {
2130 .f = cmd_config_max_lro_pkt_size_parsed,
2132 .help_str = "port config all max-lro-pkt-size <value>",
2134 (void *)&cmd_config_max_lro_pkt_size_port,
2135 (void *)&cmd_config_max_lro_pkt_size_keyword,
2136 (void *)&cmd_config_max_lro_pkt_size_all,
2137 (void *)&cmd_config_max_lro_pkt_size_name,
2138 (void *)&cmd_config_max_lro_pkt_size_value,
2143 /* *** configure port MTU *** */
2144 struct cmd_config_mtu_result {
2145 cmdline_fixed_string_t port;
2146 cmdline_fixed_string_t keyword;
2147 cmdline_fixed_string_t mtu;
2153 cmd_config_mtu_parsed(void *parsed_result,
2154 __rte_unused struct cmdline *cl,
2155 __rte_unused void *data)
2157 struct cmd_config_mtu_result *res = parsed_result;
2159 if (res->value < RTE_ETHER_MIN_LEN) {
2160 printf("mtu cannot be less than %d\n", RTE_ETHER_MIN_LEN);
2163 port_mtu_set(res->port_id, res->value);
2166 cmdline_parse_token_string_t cmd_config_mtu_port =
2167 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
2169 cmdline_parse_token_string_t cmd_config_mtu_keyword =
2170 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2172 cmdline_parse_token_string_t cmd_config_mtu_mtu =
2173 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2175 cmdline_parse_token_num_t cmd_config_mtu_port_id =
2176 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT16);
2177 cmdline_parse_token_num_t cmd_config_mtu_value =
2178 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
2180 cmdline_parse_inst_t cmd_config_mtu = {
2181 .f = cmd_config_mtu_parsed,
2183 .help_str = "port config mtu <port_id> <value>",
2185 (void *)&cmd_config_mtu_port,
2186 (void *)&cmd_config_mtu_keyword,
2187 (void *)&cmd_config_mtu_mtu,
2188 (void *)&cmd_config_mtu_port_id,
2189 (void *)&cmd_config_mtu_value,
2194 /* *** configure rx mode *** */
2195 struct cmd_config_rx_mode_flag {
2196 cmdline_fixed_string_t port;
2197 cmdline_fixed_string_t keyword;
2198 cmdline_fixed_string_t all;
2199 cmdline_fixed_string_t name;
2200 cmdline_fixed_string_t value;
2204 cmd_config_rx_mode_flag_parsed(void *parsed_result,
2205 __rte_unused struct cmdline *cl,
2206 __rte_unused void *data)
2208 struct cmd_config_rx_mode_flag *res = parsed_result;
2210 if (!all_ports_stopped()) {
2211 printf("Please stop all ports first\n");
2215 if (!strcmp(res->name, "drop-en")) {
2216 if (!strcmp(res->value, "on"))
2218 else if (!strcmp(res->value, "off"))
2221 printf("Unknown parameter\n");
2225 printf("Unknown parameter\n");
2231 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2234 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
2235 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
2236 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
2237 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
2239 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2240 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2241 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2242 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2244 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2245 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2248 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2249 .f = cmd_config_rx_mode_flag_parsed,
2251 .help_str = "port config all drop-en on|off",
2253 (void *)&cmd_config_rx_mode_flag_port,
2254 (void *)&cmd_config_rx_mode_flag_keyword,
2255 (void *)&cmd_config_rx_mode_flag_all,
2256 (void *)&cmd_config_rx_mode_flag_name,
2257 (void *)&cmd_config_rx_mode_flag_value,
2262 /* *** configure rss *** */
2263 struct cmd_config_rss {
2264 cmdline_fixed_string_t port;
2265 cmdline_fixed_string_t keyword;
2266 cmdline_fixed_string_t all;
2267 cmdline_fixed_string_t name;
2268 cmdline_fixed_string_t value;
2272 cmd_config_rss_parsed(void *parsed_result,
2273 __rte_unused struct cmdline *cl,
2274 __rte_unused void *data)
2276 struct cmd_config_rss *res = parsed_result;
2277 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2278 struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2279 int use_default = 0;
2280 int all_updated = 1;
2285 if (!strcmp(res->value, "all"))
2286 rss_conf.rss_hf = ETH_RSS_ETH | ETH_RSS_VLAN | ETH_RSS_IP |
2287 ETH_RSS_TCP | ETH_RSS_UDP | ETH_RSS_SCTP |
2288 ETH_RSS_L2_PAYLOAD | ETH_RSS_L2TPV3 | ETH_RSS_ESP |
2289 ETH_RSS_AH | ETH_RSS_PFCP | ETH_RSS_GTPU;
2290 else if (!strcmp(res->value, "eth"))
2291 rss_conf.rss_hf = ETH_RSS_ETH;
2292 else if (!strcmp(res->value, "vlan"))
2293 rss_conf.rss_hf = ETH_RSS_VLAN;
2294 else if (!strcmp(res->value, "ip"))
2295 rss_conf.rss_hf = ETH_RSS_IP;
2296 else if (!strcmp(res->value, "udp"))
2297 rss_conf.rss_hf = ETH_RSS_UDP;
2298 else if (!strcmp(res->value, "tcp"))
2299 rss_conf.rss_hf = ETH_RSS_TCP;
2300 else if (!strcmp(res->value, "sctp"))
2301 rss_conf.rss_hf = ETH_RSS_SCTP;
2302 else if (!strcmp(res->value, "ether"))
2303 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
2304 else if (!strcmp(res->value, "port"))
2305 rss_conf.rss_hf = ETH_RSS_PORT;
2306 else if (!strcmp(res->value, "vxlan"))
2307 rss_conf.rss_hf = ETH_RSS_VXLAN;
2308 else if (!strcmp(res->value, "geneve"))
2309 rss_conf.rss_hf = ETH_RSS_GENEVE;
2310 else if (!strcmp(res->value, "nvgre"))
2311 rss_conf.rss_hf = ETH_RSS_NVGRE;
2312 else if (!strcmp(res->value, "l3-pre32"))
2313 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE32;
2314 else if (!strcmp(res->value, "l3-pre40"))
2315 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE40;
2316 else if (!strcmp(res->value, "l3-pre48"))
2317 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE48;
2318 else if (!strcmp(res->value, "l3-pre56"))
2319 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE56;
2320 else if (!strcmp(res->value, "l3-pre64"))
2321 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE64;
2322 else if (!strcmp(res->value, "l3-pre96"))
2323 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE96;
2324 else if (!strcmp(res->value, "l3-src-only"))
2325 rss_conf.rss_hf = ETH_RSS_L3_SRC_ONLY;
2326 else if (!strcmp(res->value, "l3-dst-only"))
2327 rss_conf.rss_hf = ETH_RSS_L3_DST_ONLY;
2328 else if (!strcmp(res->value, "l4-src-only"))
2329 rss_conf.rss_hf = ETH_RSS_L4_SRC_ONLY;
2330 else if (!strcmp(res->value, "l4-dst-only"))
2331 rss_conf.rss_hf = ETH_RSS_L4_DST_ONLY;
2332 else if (!strcmp(res->value, "l2-src-only"))
2333 rss_conf.rss_hf = ETH_RSS_L2_SRC_ONLY;
2334 else if (!strcmp(res->value, "l2-dst-only"))
2335 rss_conf.rss_hf = ETH_RSS_L2_DST_ONLY;
2336 else if (!strcmp(res->value, "l2tpv3"))
2337 rss_conf.rss_hf = ETH_RSS_L2TPV3;
2338 else if (!strcmp(res->value, "esp"))
2339 rss_conf.rss_hf = ETH_RSS_ESP;
2340 else if (!strcmp(res->value, "ah"))
2341 rss_conf.rss_hf = ETH_RSS_AH;
2342 else if (!strcmp(res->value, "pfcp"))
2343 rss_conf.rss_hf = ETH_RSS_PFCP;
2344 else if (!strcmp(res->value, "pppoe"))
2345 rss_conf.rss_hf = ETH_RSS_PPPOE;
2346 else if (!strcmp(res->value, "gtpu"))
2347 rss_conf.rss_hf = ETH_RSS_GTPU;
2348 else if (!strcmp(res->value, "none"))
2349 rss_conf.rss_hf = 0;
2350 else if (!strcmp(res->value, "level-default")) {
2351 rss_hf &= (~ETH_RSS_LEVEL_MASK);
2352 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_PMD_DEFAULT);
2353 } else if (!strcmp(res->value, "level-outer")) {
2354 rss_hf &= (~ETH_RSS_LEVEL_MASK);
2355 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_OUTERMOST);
2356 } else if (!strcmp(res->value, "level-inner")) {
2357 rss_hf &= (~ETH_RSS_LEVEL_MASK);
2358 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_INNERMOST);
2359 } else if (!strcmp(res->value, "default"))
2361 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2362 atoi(res->value) < 64)
2363 rss_conf.rss_hf = 1ULL << atoi(res->value);
2365 printf("Unknown parameter\n");
2368 rss_conf.rss_key = NULL;
2369 /* Update global configuration for RSS types. */
2370 RTE_ETH_FOREACH_DEV(i) {
2371 struct rte_eth_rss_conf local_rss_conf;
2373 ret = eth_dev_info_get_print_err(i, &dev_info);
2378 rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2380 local_rss_conf = rss_conf;
2381 local_rss_conf.rss_hf = rss_conf.rss_hf &
2382 dev_info.flow_type_rss_offloads;
2383 if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2384 printf("Port %u modified RSS hash function based on hardware support,"
2385 "requested:%#"PRIx64" configured:%#"PRIx64"\n",
2386 i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2388 diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2391 printf("Configuration of RSS hash at ethernet port %d "
2392 "failed with error (%d): %s.\n",
2393 i, -diag, strerror(-diag));
2396 if (all_updated && !use_default) {
2397 rss_hf = rss_conf.rss_hf;
2398 printf("rss_hf %#"PRIx64"\n", rss_hf);
2402 cmdline_parse_token_string_t cmd_config_rss_port =
2403 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2404 cmdline_parse_token_string_t cmd_config_rss_keyword =
2405 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2406 cmdline_parse_token_string_t cmd_config_rss_all =
2407 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2408 cmdline_parse_token_string_t cmd_config_rss_name =
2409 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2410 cmdline_parse_token_string_t cmd_config_rss_value =
2411 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2413 cmdline_parse_inst_t cmd_config_rss = {
2414 .f = cmd_config_rss_parsed,
2416 .help_str = "port config all rss "
2417 "all|default|eth|vlan|ip|tcp|udp|sctp|ether|port|vxlan|geneve|"
2418 "nvgre|vxlan-gpe|l2tpv3|esp|ah|pfcp|none|level-default|"
2419 "level-outer|level-inner|<flowtype_id>",
2421 (void *)&cmd_config_rss_port,
2422 (void *)&cmd_config_rss_keyword,
2423 (void *)&cmd_config_rss_all,
2424 (void *)&cmd_config_rss_name,
2425 (void *)&cmd_config_rss_value,
2430 /* *** configure rss hash key *** */
2431 struct cmd_config_rss_hash_key {
2432 cmdline_fixed_string_t port;
2433 cmdline_fixed_string_t config;
2435 cmdline_fixed_string_t rss_hash_key;
2436 cmdline_fixed_string_t rss_type;
2437 cmdline_fixed_string_t key;
2441 hexa_digit_to_value(char hexa_digit)
2443 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2444 return (uint8_t) (hexa_digit - '0');
2445 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2446 return (uint8_t) ((hexa_digit - 'a') + 10);
2447 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2448 return (uint8_t) ((hexa_digit - 'A') + 10);
2449 /* Invalid hexa digit */
2454 parse_and_check_key_hexa_digit(char *key, int idx)
2458 hexa_v = hexa_digit_to_value(key[idx]);
2460 printf("invalid key: character %c at position %d is not a "
2461 "valid hexa digit\n", key[idx], idx);
2466 cmd_config_rss_hash_key_parsed(void *parsed_result,
2467 __rte_unused struct cmdline *cl,
2468 __rte_unused void *data)
2470 struct cmd_config_rss_hash_key *res = parsed_result;
2471 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2475 struct rte_eth_dev_info dev_info;
2476 uint8_t hash_key_size;
2480 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2484 if (dev_info.hash_key_size > 0 &&
2485 dev_info.hash_key_size <= sizeof(hash_key))
2486 hash_key_size = dev_info.hash_key_size;
2488 printf("dev_info did not provide a valid hash key size\n");
2491 /* Check the length of the RSS hash key */
2492 key_len = strlen(res->key);
2493 if (key_len != (hash_key_size * 2)) {
2494 printf("key length: %d invalid - key must be a string of %d"
2495 " hexa-decimal numbers\n",
2496 (int) key_len, hash_key_size * 2);
2499 /* Translate RSS hash key into binary representation */
2500 for (i = 0; i < hash_key_size; i++) {
2501 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2504 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2507 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2509 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2513 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2514 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2515 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2516 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2518 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2519 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16);
2520 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2521 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2522 rss_hash_key, "rss-hash-key");
2523 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2524 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2525 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2526 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2527 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2528 "ipv6-tcp-ex#ipv6-udp-ex#"
2529 "l3-src-only#l3-dst-only#l4-src-only#l4-dst-only#"
2530 "l2-src-only#l2-dst-only#s-vlan#c-vlan#"
2531 "l2tpv3#esp#ah#pfcp#pppoe#gtpu");
2532 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2533 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2535 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2536 .f = cmd_config_rss_hash_key_parsed,
2538 .help_str = "port config <port_id> rss-hash-key "
2539 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2540 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2541 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|"
2542 "l3-src-only|l3-dst-only|l4-src-only|l4-dst-only|"
2543 "l2-src-only|l2-dst-only|s-vlan|c-vlan|"
2544 "l2tpv3|esp|ah|pfcp|pppoe|gtpu "
2545 "<string of hex digits (variable length, NIC dependent)>",
2547 (void *)&cmd_config_rss_hash_key_port,
2548 (void *)&cmd_config_rss_hash_key_config,
2549 (void *)&cmd_config_rss_hash_key_port_id,
2550 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2551 (void *)&cmd_config_rss_hash_key_rss_type,
2552 (void *)&cmd_config_rss_hash_key_value,
2557 /* *** configure port rxq/txq ring size *** */
2558 struct cmd_config_rxtx_ring_size {
2559 cmdline_fixed_string_t port;
2560 cmdline_fixed_string_t config;
2562 cmdline_fixed_string_t rxtxq;
2564 cmdline_fixed_string_t rsize;
2569 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2570 __rte_unused struct cmdline *cl,
2571 __rte_unused void *data)
2573 struct cmd_config_rxtx_ring_size *res = parsed_result;
2574 struct rte_port *port;
2577 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2580 if (res->portid == (portid_t)RTE_PORT_ALL) {
2581 printf("Invalid port id\n");
2585 port = &ports[res->portid];
2587 if (!strcmp(res->rxtxq, "rxq"))
2589 else if (!strcmp(res->rxtxq, "txq"))
2592 printf("Unknown parameter\n");
2596 if (isrx && rx_queue_id_is_invalid(res->qid))
2598 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2601 if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2602 printf("Invalid rx ring_size, must > rx_free_thresh: %d\n",
2608 port->nb_rx_desc[res->qid] = res->size;
2610 port->nb_tx_desc[res->qid] = res->size;
2612 cmd_reconfig_device_queue(res->portid, 0, 1);
2615 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2616 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2618 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2619 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2621 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2622 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2624 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2625 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2627 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2628 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2630 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2631 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2632 rsize, "ring_size");
2633 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2634 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2637 cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2638 .f = cmd_config_rxtx_ring_size_parsed,
2640 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2642 (void *)&cmd_config_rxtx_ring_size_port,
2643 (void *)&cmd_config_rxtx_ring_size_config,
2644 (void *)&cmd_config_rxtx_ring_size_portid,
2645 (void *)&cmd_config_rxtx_ring_size_rxtxq,
2646 (void *)&cmd_config_rxtx_ring_size_qid,
2647 (void *)&cmd_config_rxtx_ring_size_rsize,
2648 (void *)&cmd_config_rxtx_ring_size_size,
2653 /* *** configure port rxq/txq start/stop *** */
2654 struct cmd_config_rxtx_queue {
2655 cmdline_fixed_string_t port;
2657 cmdline_fixed_string_t rxtxq;
2659 cmdline_fixed_string_t opname;
2663 cmd_config_rxtx_queue_parsed(void *parsed_result,
2664 __rte_unused struct cmdline *cl,
2665 __rte_unused void *data)
2667 struct cmd_config_rxtx_queue *res = parsed_result;
2672 if (test_done == 0) {
2673 printf("Please stop forwarding first\n");
2677 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2680 if (port_is_started(res->portid) != 1) {
2681 printf("Please start port %u first\n", res->portid);
2685 if (!strcmp(res->rxtxq, "rxq"))
2687 else if (!strcmp(res->rxtxq, "txq"))
2690 printf("Unknown parameter\n");
2694 if (isrx && rx_queue_id_is_invalid(res->qid))
2696 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2699 if (!strcmp(res->opname, "start"))
2701 else if (!strcmp(res->opname, "stop"))
2704 printf("Unknown parameter\n");
2708 if (isstart && isrx)
2709 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2710 else if (!isstart && isrx)
2711 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2712 else if (isstart && !isrx)
2713 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2715 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2717 if (ret == -ENOTSUP)
2718 printf("Function not supported in PMD driver\n");
2721 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2722 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2723 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2724 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16);
2725 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2726 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2727 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2728 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
2729 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2730 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2733 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2734 .f = cmd_config_rxtx_queue_parsed,
2736 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2738 (void *)&cmd_config_rxtx_queue_port,
2739 (void *)&cmd_config_rxtx_queue_portid,
2740 (void *)&cmd_config_rxtx_queue_rxtxq,
2741 (void *)&cmd_config_rxtx_queue_qid,
2742 (void *)&cmd_config_rxtx_queue_opname,
2747 /* *** configure port rxq/txq deferred start on/off *** */
2748 struct cmd_config_deferred_start_rxtx_queue {
2749 cmdline_fixed_string_t port;
2751 cmdline_fixed_string_t rxtxq;
2753 cmdline_fixed_string_t opname;
2754 cmdline_fixed_string_t state;
2758 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2759 __rte_unused struct cmdline *cl,
2760 __rte_unused void *data)
2762 struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2763 struct rte_port *port;
2766 uint8_t needreconfig = 0;
2768 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2771 if (port_is_started(res->port_id) != 0) {
2772 printf("Please stop port %u first\n", res->port_id);
2776 port = &ports[res->port_id];
2778 isrx = !strcmp(res->rxtxq, "rxq");
2780 if (isrx && rx_queue_id_is_invalid(res->qid))
2782 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2785 ison = !strcmp(res->state, "on");
2787 if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) {
2788 port->rx_conf[res->qid].rx_deferred_start = ison;
2790 } else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) {
2791 port->tx_conf[res->qid].tx_deferred_start = ison;
2796 cmd_reconfig_device_queue(res->port_id, 0, 1);
2799 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2800 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2802 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2803 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2805 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2806 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2808 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2809 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2811 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2812 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2813 opname, "deferred_start");
2814 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2815 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2818 cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
2819 .f = cmd_config_deferred_start_rxtx_queue_parsed,
2821 .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
2823 (void *)&cmd_config_deferred_start_rxtx_queue_port,
2824 (void *)&cmd_config_deferred_start_rxtx_queue_port_id,
2825 (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
2826 (void *)&cmd_config_deferred_start_rxtx_queue_qid,
2827 (void *)&cmd_config_deferred_start_rxtx_queue_opname,
2828 (void *)&cmd_config_deferred_start_rxtx_queue_state,
2833 /* *** configure port rxq/txq setup *** */
2834 struct cmd_setup_rxtx_queue {
2835 cmdline_fixed_string_t port;
2837 cmdline_fixed_string_t rxtxq;
2839 cmdline_fixed_string_t setup;
2842 /* Common CLI fields for queue setup */
2843 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2844 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2845 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2846 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, UINT16);
2847 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2848 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2849 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2850 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, UINT16);
2851 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2852 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2855 cmd_setup_rxtx_queue_parsed(
2856 void *parsed_result,
2857 __rte_unused struct cmdline *cl,
2858 __rte_unused void *data)
2860 struct cmd_setup_rxtx_queue *res = parsed_result;
2861 struct rte_port *port;
2862 struct rte_mempool *mp;
2863 unsigned int socket_id;
2867 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2870 if (res->portid == (portid_t)RTE_PORT_ALL) {
2871 printf("Invalid port id\n");
2875 if (!strcmp(res->rxtxq, "rxq"))
2877 else if (!strcmp(res->rxtxq, "txq"))
2880 printf("Unknown parameter\n");
2884 if (isrx && rx_queue_id_is_invalid(res->qid)) {
2885 printf("Invalid rx queue\n");
2887 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2888 printf("Invalid tx queue\n");
2892 port = &ports[res->portid];
2894 socket_id = rxring_numa[res->portid];
2895 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2896 socket_id = port->socket_id;
2898 mp = mbuf_pool_find(socket_id, 0);
2900 printf("Failed to setup RX queue: "
2901 "No mempool allocation"
2902 " on the socket %d\n",
2903 rxring_numa[res->portid]);
2906 ret = rx_queue_setup(res->portid,
2908 port->nb_rx_desc[res->qid],
2910 &port->rx_conf[res->qid],
2913 printf("Failed to setup RX queue\n");
2915 socket_id = txring_numa[res->portid];
2916 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2917 socket_id = port->socket_id;
2919 ret = rte_eth_tx_queue_setup(res->portid,
2921 port->nb_tx_desc[res->qid],
2923 &port->tx_conf[res->qid]);
2925 printf("Failed to setup TX queue\n");
2929 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2930 .f = cmd_setup_rxtx_queue_parsed,
2932 .help_str = "port <port_id> rxq|txq <queue_idx> setup",
2934 (void *)&cmd_setup_rxtx_queue_port,
2935 (void *)&cmd_setup_rxtx_queue_portid,
2936 (void *)&cmd_setup_rxtx_queue_rxtxq,
2937 (void *)&cmd_setup_rxtx_queue_qid,
2938 (void *)&cmd_setup_rxtx_queue_setup,
2944 /* *** Configure RSS RETA *** */
2945 struct cmd_config_rss_reta {
2946 cmdline_fixed_string_t port;
2947 cmdline_fixed_string_t keyword;
2949 cmdline_fixed_string_t name;
2950 cmdline_fixed_string_t list_name;
2951 cmdline_fixed_string_t list_of_items;
2955 parse_reta_config(const char *str,
2956 struct rte_eth_rss_reta_entry64 *reta_conf,
2957 uint16_t nb_entries)
2961 uint16_t hash_index, idx, shift;
2964 const char *p, *p0 = str;
2971 unsigned long int_fld[_NUM_FLD];
2972 char *str_fld[_NUM_FLD];
2974 while ((p = strchr(p0,'(')) != NULL) {
2976 if((p0 = strchr(p,')')) == NULL)
2980 if(size >= sizeof(s))
2983 snprintf(s, sizeof(s), "%.*s", size, p);
2984 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2986 for (i = 0; i < _NUM_FLD; i++) {
2988 int_fld[i] = strtoul(str_fld[i], &end, 0);
2989 if (errno != 0 || end == str_fld[i] ||
2994 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2995 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2997 if (hash_index >= nb_entries) {
2998 printf("Invalid RETA hash index=%d\n", hash_index);
3002 idx = hash_index / RTE_RETA_GROUP_SIZE;
3003 shift = hash_index % RTE_RETA_GROUP_SIZE;
3004 reta_conf[idx].mask |= (1ULL << shift);
3005 reta_conf[idx].reta[shift] = nb_queue;
3012 cmd_set_rss_reta_parsed(void *parsed_result,
3013 __rte_unused struct cmdline *cl,
3014 __rte_unused void *data)
3017 struct rte_eth_dev_info dev_info;
3018 struct rte_eth_rss_reta_entry64 reta_conf[8];
3019 struct cmd_config_rss_reta *res = parsed_result;
3021 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3025 if (dev_info.reta_size == 0) {
3026 printf("Redirection table size is 0 which is "
3027 "invalid for RSS\n");
3030 printf("The reta size of port %d is %u\n",
3031 res->port_id, dev_info.reta_size);
3032 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
3033 printf("Currently do not support more than %u entries of "
3034 "redirection table\n", ETH_RSS_RETA_SIZE_512);
3038 memset(reta_conf, 0, sizeof(reta_conf));
3039 if (!strcmp(res->list_name, "reta")) {
3040 if (parse_reta_config(res->list_of_items, reta_conf,
3041 dev_info.reta_size)) {
3042 printf("Invalid RSS Redirection Table "
3043 "config entered\n");
3046 ret = rte_eth_dev_rss_reta_update(res->port_id,
3047 reta_conf, dev_info.reta_size);
3049 printf("Bad redirection table parameter, "
3050 "return code = %d \n", ret);
3054 cmdline_parse_token_string_t cmd_config_rss_reta_port =
3055 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
3056 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
3057 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
3058 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
3059 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16);
3060 cmdline_parse_token_string_t cmd_config_rss_reta_name =
3061 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
3062 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
3063 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
3064 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
3065 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
3067 cmdline_parse_inst_t cmd_config_rss_reta = {
3068 .f = cmd_set_rss_reta_parsed,
3070 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
3072 (void *)&cmd_config_rss_reta_port,
3073 (void *)&cmd_config_rss_reta_keyword,
3074 (void *)&cmd_config_rss_reta_port_id,
3075 (void *)&cmd_config_rss_reta_name,
3076 (void *)&cmd_config_rss_reta_list_name,
3077 (void *)&cmd_config_rss_reta_list_of_items,
3082 /* *** SHOW PORT RETA INFO *** */
3083 struct cmd_showport_reta {
3084 cmdline_fixed_string_t show;
3085 cmdline_fixed_string_t port;
3087 cmdline_fixed_string_t rss;
3088 cmdline_fixed_string_t reta;
3090 cmdline_fixed_string_t list_of_items;
3094 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
3095 uint16_t nb_entries,
3099 const char *p, *p0 = str;
3104 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
3105 RTE_RETA_GROUP_SIZE;
3108 p = strchr(p0, '(');
3112 p0 = strchr(p, ')');
3116 if (size >= sizeof(s)) {
3117 printf("The string size exceeds the internal buffer size\n");
3120 snprintf(s, sizeof(s), "%.*s", size, p);
3121 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
3122 if (ret <= 0 || ret != num) {
3123 printf("The bits of masks do not match the number of "
3124 "reta entries: %u\n", num);
3127 for (i = 0; i < ret; i++)
3128 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
3134 cmd_showport_reta_parsed(void *parsed_result,
3135 __rte_unused struct cmdline *cl,
3136 __rte_unused void *data)
3138 struct cmd_showport_reta *res = parsed_result;
3139 struct rte_eth_rss_reta_entry64 reta_conf[8];
3140 struct rte_eth_dev_info dev_info;
3141 uint16_t max_reta_size;
3144 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3148 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
3149 if (res->size == 0 || res->size > max_reta_size) {
3150 printf("Invalid redirection table size: %u (1-%u)\n",
3151 res->size, max_reta_size);
3155 memset(reta_conf, 0, sizeof(reta_conf));
3156 if (showport_parse_reta_config(reta_conf, res->size,
3157 res->list_of_items) < 0) {
3158 printf("Invalid string: %s for reta masks\n",
3159 res->list_of_items);
3162 port_rss_reta_info(res->port_id, reta_conf, res->size);
3165 cmdline_parse_token_string_t cmd_showport_reta_show =
3166 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
3167 cmdline_parse_token_string_t cmd_showport_reta_port =
3168 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
3169 cmdline_parse_token_num_t cmd_showport_reta_port_id =
3170 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16);
3171 cmdline_parse_token_string_t cmd_showport_reta_rss =
3172 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
3173 cmdline_parse_token_string_t cmd_showport_reta_reta =
3174 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
3175 cmdline_parse_token_num_t cmd_showport_reta_size =
3176 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
3177 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
3178 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
3179 list_of_items, NULL);
3181 cmdline_parse_inst_t cmd_showport_reta = {
3182 .f = cmd_showport_reta_parsed,
3184 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
3186 (void *)&cmd_showport_reta_show,
3187 (void *)&cmd_showport_reta_port,
3188 (void *)&cmd_showport_reta_port_id,
3189 (void *)&cmd_showport_reta_rss,
3190 (void *)&cmd_showport_reta_reta,
3191 (void *)&cmd_showport_reta_size,
3192 (void *)&cmd_showport_reta_list_of_items,
3197 /* *** Show RSS hash configuration *** */
3198 struct cmd_showport_rss_hash {
3199 cmdline_fixed_string_t show;
3200 cmdline_fixed_string_t port;
3202 cmdline_fixed_string_t rss_hash;
3203 cmdline_fixed_string_t rss_type;
3204 cmdline_fixed_string_t key; /* optional argument */
3207 static void cmd_showport_rss_hash_parsed(void *parsed_result,
3208 __rte_unused struct cmdline *cl,
3211 struct cmd_showport_rss_hash *res = parsed_result;
3213 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
3216 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
3217 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
3218 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
3219 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
3220 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
3221 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16);
3222 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
3223 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
3225 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
3226 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
3228 cmdline_parse_inst_t cmd_showport_rss_hash = {
3229 .f = cmd_showport_rss_hash_parsed,
3231 .help_str = "show port <port_id> rss-hash",
3233 (void *)&cmd_showport_rss_hash_show,
3234 (void *)&cmd_showport_rss_hash_port,
3235 (void *)&cmd_showport_rss_hash_port_id,
3236 (void *)&cmd_showport_rss_hash_rss_hash,
3241 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
3242 .f = cmd_showport_rss_hash_parsed,
3244 .help_str = "show port <port_id> rss-hash key",
3246 (void *)&cmd_showport_rss_hash_show,
3247 (void *)&cmd_showport_rss_hash_port,
3248 (void *)&cmd_showport_rss_hash_port_id,
3249 (void *)&cmd_showport_rss_hash_rss_hash,
3250 (void *)&cmd_showport_rss_hash_rss_key,
3255 /* *** Configure DCB *** */
3256 struct cmd_config_dcb {
3257 cmdline_fixed_string_t port;
3258 cmdline_fixed_string_t config;
3260 cmdline_fixed_string_t dcb;
3261 cmdline_fixed_string_t vt;
3262 cmdline_fixed_string_t vt_en;
3264 cmdline_fixed_string_t pfc;
3265 cmdline_fixed_string_t pfc_en;
3269 cmd_config_dcb_parsed(void *parsed_result,
3270 __rte_unused struct cmdline *cl,
3271 __rte_unused void *data)
3273 struct cmd_config_dcb *res = parsed_result;
3274 portid_t port_id = res->port_id;
3275 struct rte_port *port;
3279 port = &ports[port_id];
3280 /** Check if the port is not started **/
3281 if (port->port_status != RTE_PORT_STOPPED) {
3282 printf("Please stop port %d first\n", port_id);
3286 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
3287 printf("The invalid number of traffic class,"
3288 " only 4 or 8 allowed.\n");
3292 if (nb_fwd_lcores < res->num_tcs) {
3293 printf("nb_cores shouldn't be less than number of TCs.\n");
3296 if (!strncmp(res->pfc_en, "on", 2))
3301 /* DCB in VT mode */
3302 if (!strncmp(res->vt_en, "on", 2))
3303 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3304 (enum rte_eth_nb_tcs)res->num_tcs,
3307 ret = init_port_dcb_config(port_id, DCB_ENABLED,
3308 (enum rte_eth_nb_tcs)res->num_tcs,
3313 printf("Cannot initialize network ports.\n");
3317 cmd_reconfig_device_queue(port_id, 1, 1);
3320 cmdline_parse_token_string_t cmd_config_dcb_port =
3321 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3322 cmdline_parse_token_string_t cmd_config_dcb_config =
3323 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3324 cmdline_parse_token_num_t cmd_config_dcb_port_id =
3325 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16);
3326 cmdline_parse_token_string_t cmd_config_dcb_dcb =
3327 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3328 cmdline_parse_token_string_t cmd_config_dcb_vt =
3329 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3330 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3331 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3332 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3333 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
3334 cmdline_parse_token_string_t cmd_config_dcb_pfc=
3335 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3336 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
3337 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
3339 cmdline_parse_inst_t cmd_config_dcb = {
3340 .f = cmd_config_dcb_parsed,
3342 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
3344 (void *)&cmd_config_dcb_port,
3345 (void *)&cmd_config_dcb_config,
3346 (void *)&cmd_config_dcb_port_id,
3347 (void *)&cmd_config_dcb_dcb,
3348 (void *)&cmd_config_dcb_vt,
3349 (void *)&cmd_config_dcb_vt_en,
3350 (void *)&cmd_config_dcb_num_tcs,
3351 (void *)&cmd_config_dcb_pfc,
3352 (void *)&cmd_config_dcb_pfc_en,
3357 /* *** configure number of packets per burst *** */
3358 struct cmd_config_burst {
3359 cmdline_fixed_string_t port;
3360 cmdline_fixed_string_t keyword;
3361 cmdline_fixed_string_t all;
3362 cmdline_fixed_string_t name;
3367 cmd_config_burst_parsed(void *parsed_result,
3368 __rte_unused struct cmdline *cl,
3369 __rte_unused void *data)
3371 struct cmd_config_burst *res = parsed_result;
3372 struct rte_eth_dev_info dev_info;
3373 uint16_t rec_nb_pkts;
3376 if (!all_ports_stopped()) {
3377 printf("Please stop all ports first\n");
3381 if (!strcmp(res->name, "burst")) {
3382 if (res->value == 0) {
3383 /* If user gives a value of zero, query the PMD for
3384 * its recommended Rx burst size. Testpmd uses a single
3385 * size for all ports, so assume all ports are the same
3386 * NIC model and use the values from Port 0.
3388 ret = eth_dev_info_get_print_err(0, &dev_info);
3392 rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3394 if (rec_nb_pkts == 0) {
3395 printf("PMD does not recommend a burst size.\n"
3396 "User provided value must be between"
3397 " 1 and %d\n", MAX_PKT_BURST);
3399 } else if (rec_nb_pkts > MAX_PKT_BURST) {
3400 printf("PMD recommended burst size of %d"
3401 " exceeds maximum value of %d\n",
3402 rec_nb_pkts, MAX_PKT_BURST);
3405 printf("Using PMD-provided burst value of %d\n",
3407 nb_pkt_per_burst = rec_nb_pkts;
3408 } else if (res->value > MAX_PKT_BURST) {
3409 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
3412 nb_pkt_per_burst = res->value;
3414 printf("Unknown parameter\n");
3420 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3423 cmdline_parse_token_string_t cmd_config_burst_port =
3424 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3425 cmdline_parse_token_string_t cmd_config_burst_keyword =
3426 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3427 cmdline_parse_token_string_t cmd_config_burst_all =
3428 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3429 cmdline_parse_token_string_t cmd_config_burst_name =
3430 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3431 cmdline_parse_token_num_t cmd_config_burst_value =
3432 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
3434 cmdline_parse_inst_t cmd_config_burst = {
3435 .f = cmd_config_burst_parsed,
3437 .help_str = "port config all burst <value>",
3439 (void *)&cmd_config_burst_port,
3440 (void *)&cmd_config_burst_keyword,
3441 (void *)&cmd_config_burst_all,
3442 (void *)&cmd_config_burst_name,
3443 (void *)&cmd_config_burst_value,
3448 /* *** configure rx/tx queues *** */
3449 struct cmd_config_thresh {
3450 cmdline_fixed_string_t port;
3451 cmdline_fixed_string_t keyword;
3452 cmdline_fixed_string_t all;
3453 cmdline_fixed_string_t name;
3458 cmd_config_thresh_parsed(void *parsed_result,
3459 __rte_unused struct cmdline *cl,
3460 __rte_unused void *data)
3462 struct cmd_config_thresh *res = parsed_result;
3464 if (!all_ports_stopped()) {
3465 printf("Please stop all ports first\n");
3469 if (!strcmp(res->name, "txpt"))
3470 tx_pthresh = res->value;
3471 else if(!strcmp(res->name, "txht"))
3472 tx_hthresh = res->value;
3473 else if(!strcmp(res->name, "txwt"))
3474 tx_wthresh = res->value;
3475 else if(!strcmp(res->name, "rxpt"))
3476 rx_pthresh = res->value;
3477 else if(!strcmp(res->name, "rxht"))
3478 rx_hthresh = res->value;
3479 else if(!strcmp(res->name, "rxwt"))
3480 rx_wthresh = res->value;
3482 printf("Unknown parameter\n");
3488 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3491 cmdline_parse_token_string_t cmd_config_thresh_port =
3492 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3493 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3494 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3495 cmdline_parse_token_string_t cmd_config_thresh_all =
3496 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3497 cmdline_parse_token_string_t cmd_config_thresh_name =
3498 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3499 "txpt#txht#txwt#rxpt#rxht#rxwt");
3500 cmdline_parse_token_num_t cmd_config_thresh_value =
3501 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
3503 cmdline_parse_inst_t cmd_config_thresh = {
3504 .f = cmd_config_thresh_parsed,
3506 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3508 (void *)&cmd_config_thresh_port,
3509 (void *)&cmd_config_thresh_keyword,
3510 (void *)&cmd_config_thresh_all,
3511 (void *)&cmd_config_thresh_name,
3512 (void *)&cmd_config_thresh_value,
3517 /* *** configure free/rs threshold *** */
3518 struct cmd_config_threshold {
3519 cmdline_fixed_string_t port;
3520 cmdline_fixed_string_t keyword;
3521 cmdline_fixed_string_t all;
3522 cmdline_fixed_string_t name;
3527 cmd_config_threshold_parsed(void *parsed_result,
3528 __rte_unused struct cmdline *cl,
3529 __rte_unused void *data)
3531 struct cmd_config_threshold *res = parsed_result;
3533 if (!all_ports_stopped()) {
3534 printf("Please stop all ports first\n");
3538 if (!strcmp(res->name, "txfreet"))
3539 tx_free_thresh = res->value;
3540 else if (!strcmp(res->name, "txrst"))
3541 tx_rs_thresh = res->value;
3542 else if (!strcmp(res->name, "rxfreet"))
3543 rx_free_thresh = res->value;
3545 printf("Unknown parameter\n");
3551 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3554 cmdline_parse_token_string_t cmd_config_threshold_port =
3555 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3556 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3557 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3559 cmdline_parse_token_string_t cmd_config_threshold_all =
3560 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3561 cmdline_parse_token_string_t cmd_config_threshold_name =
3562 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3563 "txfreet#txrst#rxfreet");
3564 cmdline_parse_token_num_t cmd_config_threshold_value =
3565 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
3567 cmdline_parse_inst_t cmd_config_threshold = {
3568 .f = cmd_config_threshold_parsed,
3570 .help_str = "port config all txfreet|txrst|rxfreet <value>",
3572 (void *)&cmd_config_threshold_port,
3573 (void *)&cmd_config_threshold_keyword,
3574 (void *)&cmd_config_threshold_all,
3575 (void *)&cmd_config_threshold_name,
3576 (void *)&cmd_config_threshold_value,
3582 struct cmd_stop_result {
3583 cmdline_fixed_string_t stop;
3586 static void cmd_stop_parsed(__rte_unused void *parsed_result,
3587 __rte_unused struct cmdline *cl,
3588 __rte_unused void *data)
3590 stop_packet_forwarding();
3593 cmdline_parse_token_string_t cmd_stop_stop =
3594 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3596 cmdline_parse_inst_t cmd_stop = {
3597 .f = cmd_stop_parsed,
3599 .help_str = "stop: Stop packet forwarding",
3601 (void *)&cmd_stop_stop,
3606 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3609 parse_item_list(char* str, const char* item_name, unsigned int max_items,
3610 unsigned int *parsed_items, int check_unique_values)
3612 unsigned int nb_item;
3620 * First parse all items in the list and store their value.
3625 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3627 if ((c >= '0') && (c <= '9')) {
3628 value = (unsigned int) (value * 10 + (c - '0'));
3633 printf("character %c is not a decimal digit\n", c);
3637 printf("No valid value before comma\n");
3640 if (nb_item < max_items) {
3641 parsed_items[nb_item] = value;
3647 if (nb_item >= max_items) {
3648 printf("Number of %s = %u > %u (maximum items)\n",
3649 item_name, nb_item + 1, max_items);
3652 parsed_items[nb_item++] = value;
3653 if (! check_unique_values)
3657 * Then, check that all values in the list are differents.
3658 * No optimization here...
3660 for (i = 0; i < nb_item; i++) {
3661 for (j = i + 1; j < nb_item; j++) {
3662 if (parsed_items[j] == parsed_items[i]) {
3663 printf("duplicated %s %u at index %u and %u\n",
3664 item_name, parsed_items[i], i, j);
3672 struct cmd_set_list_result {
3673 cmdline_fixed_string_t cmd_keyword;
3674 cmdline_fixed_string_t list_name;
3675 cmdline_fixed_string_t list_of_items;
3678 static void cmd_set_list_parsed(void *parsed_result,
3679 __rte_unused struct cmdline *cl,
3680 __rte_unused void *data)
3682 struct cmd_set_list_result *res;
3684 unsigned int lcorelist[RTE_MAX_LCORE];
3685 unsigned int portlist[RTE_MAX_ETHPORTS];
3687 unsigned int nb_item;
3689 if (test_done == 0) {
3690 printf("Please stop forwarding first\n");
3694 res = parsed_result;
3695 if (!strcmp(res->list_name, "corelist")) {
3696 nb_item = parse_item_list(res->list_of_items, "core",
3698 parsed_items.lcorelist, 1);
3700 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3705 if (!strcmp(res->list_name, "portlist")) {
3706 nb_item = parse_item_list(res->list_of_items, "port",
3708 parsed_items.portlist, 1);
3710 set_fwd_ports_list(parsed_items.portlist, nb_item);
3716 cmdline_parse_token_string_t cmd_set_list_keyword =
3717 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3719 cmdline_parse_token_string_t cmd_set_list_name =
3720 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3721 "corelist#portlist");
3722 cmdline_parse_token_string_t cmd_set_list_of_items =
3723 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3726 cmdline_parse_inst_t cmd_set_fwd_list = {
3727 .f = cmd_set_list_parsed,
3729 .help_str = "set corelist|portlist <list0[,list1]*>",
3731 (void *)&cmd_set_list_keyword,
3732 (void *)&cmd_set_list_name,
3733 (void *)&cmd_set_list_of_items,
3738 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3740 struct cmd_setmask_result {
3741 cmdline_fixed_string_t set;
3742 cmdline_fixed_string_t mask;
3746 static void cmd_set_mask_parsed(void *parsed_result,
3747 __rte_unused struct cmdline *cl,
3748 __rte_unused void *data)
3750 struct cmd_setmask_result *res = parsed_result;
3752 if (test_done == 0) {
3753 printf("Please stop forwarding first\n");
3756 if (!strcmp(res->mask, "coremask")) {
3757 set_fwd_lcores_mask(res->hexavalue);
3759 } else if (!strcmp(res->mask, "portmask")) {
3760 set_fwd_ports_mask(res->hexavalue);
3765 cmdline_parse_token_string_t cmd_setmask_set =
3766 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3767 cmdline_parse_token_string_t cmd_setmask_mask =
3768 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3769 "coremask#portmask");
3770 cmdline_parse_token_num_t cmd_setmask_value =
3771 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
3773 cmdline_parse_inst_t cmd_set_fwd_mask = {
3774 .f = cmd_set_mask_parsed,
3776 .help_str = "set coremask|portmask <hexadecimal value>",
3778 (void *)&cmd_setmask_set,
3779 (void *)&cmd_setmask_mask,
3780 (void *)&cmd_setmask_value,
3786 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3788 struct cmd_set_result {
3789 cmdline_fixed_string_t set;
3790 cmdline_fixed_string_t what;
3794 static void cmd_set_parsed(void *parsed_result,
3795 __rte_unused struct cmdline *cl,
3796 __rte_unused void *data)
3798 struct cmd_set_result *res = parsed_result;
3799 if (!strcmp(res->what, "nbport")) {
3800 set_fwd_ports_number(res->value);
3802 } else if (!strcmp(res->what, "nbcore")) {
3803 set_fwd_lcores_number(res->value);
3805 } else if (!strcmp(res->what, "burst"))
3806 set_nb_pkt_per_burst(res->value);
3807 else if (!strcmp(res->what, "verbose"))
3808 set_verbose_level(res->value);
3811 cmdline_parse_token_string_t cmd_set_set =
3812 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3813 cmdline_parse_token_string_t cmd_set_what =
3814 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3815 "nbport#nbcore#burst#verbose");
3816 cmdline_parse_token_num_t cmd_set_value =
3817 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
3819 cmdline_parse_inst_t cmd_set_numbers = {
3820 .f = cmd_set_parsed,
3822 .help_str = "set nbport|nbcore|burst|verbose <value>",
3824 (void *)&cmd_set_set,
3825 (void *)&cmd_set_what,
3826 (void *)&cmd_set_value,
3831 /* *** SET LOG LEVEL CONFIGURATION *** */
3833 struct cmd_set_log_result {
3834 cmdline_fixed_string_t set;
3835 cmdline_fixed_string_t log;
3836 cmdline_fixed_string_t type;
3841 cmd_set_log_parsed(void *parsed_result,
3842 __rte_unused struct cmdline *cl,
3843 __rte_unused void *data)
3845 struct cmd_set_log_result *res;
3848 res = parsed_result;
3849 if (!strcmp(res->type, "global"))
3850 rte_log_set_global_level(res->level);
3852 ret = rte_log_set_level_regexp(res->type, res->level);
3854 printf("Unable to set log level\n");
3858 cmdline_parse_token_string_t cmd_set_log_set =
3859 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3860 cmdline_parse_token_string_t cmd_set_log_log =
3861 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3862 cmdline_parse_token_string_t cmd_set_log_type =
3863 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3864 cmdline_parse_token_num_t cmd_set_log_level =
3865 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, UINT32);
3867 cmdline_parse_inst_t cmd_set_log = {
3868 .f = cmd_set_log_parsed,
3870 .help_str = "set log global|<type> <level>",
3872 (void *)&cmd_set_log_set,
3873 (void *)&cmd_set_log_log,
3874 (void *)&cmd_set_log_type,
3875 (void *)&cmd_set_log_level,
3880 /* *** SET SEGMENT OFFSETS OF RX PACKETS SPLIT *** */
3882 struct cmd_set_rxoffs_result {
3883 cmdline_fixed_string_t cmd_keyword;
3884 cmdline_fixed_string_t rxoffs;
3885 cmdline_fixed_string_t seg_offsets;
3889 cmd_set_rxoffs_parsed(void *parsed_result,
3890 __rte_unused struct cmdline *cl,
3891 __rte_unused void *data)
3893 struct cmd_set_rxoffs_result *res;
3894 unsigned int seg_offsets[MAX_SEGS_BUFFER_SPLIT];
3895 unsigned int nb_segs;
3897 res = parsed_result;
3898 nb_segs = parse_item_list(res->seg_offsets, "segment offsets",
3899 MAX_SEGS_BUFFER_SPLIT, seg_offsets, 0);
3901 set_rx_pkt_offsets(seg_offsets, nb_segs);
3904 cmdline_parse_token_string_t cmd_set_rxoffs_keyword =
3905 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3906 cmd_keyword, "set");
3907 cmdline_parse_token_string_t cmd_set_rxoffs_name =
3908 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3910 cmdline_parse_token_string_t cmd_set_rxoffs_offsets =
3911 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3914 cmdline_parse_inst_t cmd_set_rxoffs = {
3915 .f = cmd_set_rxoffs_parsed,
3917 .help_str = "set rxoffs <len0[,len1]*>",
3919 (void *)&cmd_set_rxoffs_keyword,
3920 (void *)&cmd_set_rxoffs_name,
3921 (void *)&cmd_set_rxoffs_offsets,
3926 /* *** SET SEGMENT LENGTHS OF RX PACKETS SPLIT *** */
3928 struct cmd_set_rxpkts_result {
3929 cmdline_fixed_string_t cmd_keyword;
3930 cmdline_fixed_string_t rxpkts;
3931 cmdline_fixed_string_t seg_lengths;
3935 cmd_set_rxpkts_parsed(void *parsed_result,
3936 __rte_unused struct cmdline *cl,
3937 __rte_unused void *data)
3939 struct cmd_set_rxpkts_result *res;
3940 unsigned int seg_lengths[MAX_SEGS_BUFFER_SPLIT];
3941 unsigned int nb_segs;
3943 res = parsed_result;
3944 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3945 MAX_SEGS_BUFFER_SPLIT, seg_lengths, 0);
3947 set_rx_pkt_segments(seg_lengths, nb_segs);
3950 cmdline_parse_token_string_t cmd_set_rxpkts_keyword =
3951 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3952 cmd_keyword, "set");
3953 cmdline_parse_token_string_t cmd_set_rxpkts_name =
3954 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3956 cmdline_parse_token_string_t cmd_set_rxpkts_lengths =
3957 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3960 cmdline_parse_inst_t cmd_set_rxpkts = {
3961 .f = cmd_set_rxpkts_parsed,
3963 .help_str = "set rxpkts <len0[,len1]*>",
3965 (void *)&cmd_set_rxpkts_keyword,
3966 (void *)&cmd_set_rxpkts_name,
3967 (void *)&cmd_set_rxpkts_lengths,
3972 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3974 struct cmd_set_txpkts_result {
3975 cmdline_fixed_string_t cmd_keyword;
3976 cmdline_fixed_string_t txpkts;
3977 cmdline_fixed_string_t seg_lengths;
3981 cmd_set_txpkts_parsed(void *parsed_result,
3982 __rte_unused struct cmdline *cl,
3983 __rte_unused void *data)
3985 struct cmd_set_txpkts_result *res;
3986 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3987 unsigned int nb_segs;
3989 res = parsed_result;
3990 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3991 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3993 set_tx_pkt_segments(seg_lengths, nb_segs);
3996 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3997 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3998 cmd_keyword, "set");
3999 cmdline_parse_token_string_t cmd_set_txpkts_name =
4000 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4002 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
4003 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4006 cmdline_parse_inst_t cmd_set_txpkts = {
4007 .f = cmd_set_txpkts_parsed,
4009 .help_str = "set txpkts <len0[,len1]*>",
4011 (void *)&cmd_set_txpkts_keyword,
4012 (void *)&cmd_set_txpkts_name,
4013 (void *)&cmd_set_txpkts_lengths,
4018 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
4020 struct cmd_set_txsplit_result {
4021 cmdline_fixed_string_t cmd_keyword;
4022 cmdline_fixed_string_t txsplit;
4023 cmdline_fixed_string_t mode;
4027 cmd_set_txsplit_parsed(void *parsed_result,
4028 __rte_unused struct cmdline *cl,
4029 __rte_unused void *data)
4031 struct cmd_set_txsplit_result *res;
4033 res = parsed_result;
4034 set_tx_pkt_split(res->mode);
4037 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
4038 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4039 cmd_keyword, "set");
4040 cmdline_parse_token_string_t cmd_set_txsplit_name =
4041 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4042 txsplit, "txsplit");
4043 cmdline_parse_token_string_t cmd_set_txsplit_mode =
4044 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4047 cmdline_parse_inst_t cmd_set_txsplit = {
4048 .f = cmd_set_txsplit_parsed,
4050 .help_str = "set txsplit on|off|rand",
4052 (void *)&cmd_set_txsplit_keyword,
4053 (void *)&cmd_set_txsplit_name,
4054 (void *)&cmd_set_txsplit_mode,
4059 /* *** SET TIMES FOR TXONLY PACKETS SCHEDULING ON TIMESTAMPS *** */
4061 struct cmd_set_txtimes_result {
4062 cmdline_fixed_string_t cmd_keyword;
4063 cmdline_fixed_string_t txtimes;
4064 cmdline_fixed_string_t tx_times;
4068 cmd_set_txtimes_parsed(void *parsed_result,
4069 __rte_unused struct cmdline *cl,
4070 __rte_unused void *data)
4072 struct cmd_set_txtimes_result *res;
4073 unsigned int tx_times[2] = {0, 0};
4074 unsigned int n_times;
4076 res = parsed_result;
4077 n_times = parse_item_list(res->tx_times, "tx times",
4080 set_tx_pkt_times(tx_times);
4083 cmdline_parse_token_string_t cmd_set_txtimes_keyword =
4084 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4085 cmd_keyword, "set");
4086 cmdline_parse_token_string_t cmd_set_txtimes_name =
4087 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4088 txtimes, "txtimes");
4089 cmdline_parse_token_string_t cmd_set_txtimes_value =
4090 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4093 cmdline_parse_inst_t cmd_set_txtimes = {
4094 .f = cmd_set_txtimes_parsed,
4096 .help_str = "set txtimes <inter_burst>,<intra_burst>",
4098 (void *)&cmd_set_txtimes_keyword,
4099 (void *)&cmd_set_txtimes_name,
4100 (void *)&cmd_set_txtimes_value,
4105 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
4106 struct cmd_rx_vlan_filter_all_result {
4107 cmdline_fixed_string_t rx_vlan;
4108 cmdline_fixed_string_t what;
4109 cmdline_fixed_string_t all;
4114 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
4115 __rte_unused struct cmdline *cl,
4116 __rte_unused void *data)
4118 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
4120 if (!strcmp(res->what, "add"))
4121 rx_vlan_all_filter_set(res->port_id, 1);
4123 rx_vlan_all_filter_set(res->port_id, 0);
4126 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
4127 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4128 rx_vlan, "rx_vlan");
4129 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
4130 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4132 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
4133 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4135 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
4136 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4139 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
4140 .f = cmd_rx_vlan_filter_all_parsed,
4142 .help_str = "rx_vlan add|rm all <port_id>: "
4143 "Add/Remove all identifiers to/from the set of VLAN "
4144 "identifiers filtered by a port",
4146 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
4147 (void *)&cmd_rx_vlan_filter_all_what,
4148 (void *)&cmd_rx_vlan_filter_all_all,
4149 (void *)&cmd_rx_vlan_filter_all_portid,
4154 /* *** VLAN OFFLOAD SET ON A PORT *** */
4155 struct cmd_vlan_offload_result {
4156 cmdline_fixed_string_t vlan;
4157 cmdline_fixed_string_t set;
4158 cmdline_fixed_string_t vlan_type;
4159 cmdline_fixed_string_t what;
4160 cmdline_fixed_string_t on;
4161 cmdline_fixed_string_t port_id;
4165 cmd_vlan_offload_parsed(void *parsed_result,
4166 __rte_unused struct cmdline *cl,
4167 __rte_unused void *data)
4170 struct cmd_vlan_offload_result *res = parsed_result;
4173 portid_t port_id = 0;
4177 len = strnlen(str, STR_TOKEN_SIZE);
4179 /* Get port_id first */
4187 tmp = strtoul(str, NULL, 0);
4188 /* If port_id greater that what portid_t can represent, return */
4189 if(tmp >= RTE_MAX_ETHPORTS)
4191 port_id = (portid_t)tmp;
4193 if (!strcmp(res->on, "on"))
4198 if (!strcmp(res->what, "strip"))
4199 rx_vlan_strip_set(port_id, on);
4200 else if(!strcmp(res->what, "stripq")){
4201 uint16_t queue_id = 0;
4203 /* No queue_id, return */
4205 printf("must specify (port,queue_id)\n");
4208 tmp = strtoul(str + i + 1, NULL, 0);
4209 /* If queue_id greater that what 16-bits can represent, return */
4213 queue_id = (uint16_t)tmp;
4214 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
4216 else if (!strcmp(res->what, "filter"))
4217 rx_vlan_filter_set(port_id, on);
4218 else if (!strcmp(res->what, "qinq_strip"))
4219 rx_vlan_qinq_strip_set(port_id, on);
4221 vlan_extend_set(port_id, on);
4226 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
4227 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4229 cmdline_parse_token_string_t cmd_vlan_offload_set =
4230 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4232 cmdline_parse_token_string_t cmd_vlan_offload_what =
4233 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4234 what, "strip#filter#qinq_strip#extend#stripq");
4235 cmdline_parse_token_string_t cmd_vlan_offload_on =
4236 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4238 cmdline_parse_token_string_t cmd_vlan_offload_portid =
4239 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4242 cmdline_parse_inst_t cmd_vlan_offload = {
4243 .f = cmd_vlan_offload_parsed,
4245 .help_str = "vlan set strip|filter|qinq_strip|extend|stripq on|off "
4246 "<port_id[,queue_id]>: "
4247 "Strip/Filter/QinQ for rx side Extend for both rx/tx sides",
4249 (void *)&cmd_vlan_offload_vlan,
4250 (void *)&cmd_vlan_offload_set,
4251 (void *)&cmd_vlan_offload_what,
4252 (void *)&cmd_vlan_offload_on,
4253 (void *)&cmd_vlan_offload_portid,
4258 /* *** VLAN TPID SET ON A PORT *** */
4259 struct cmd_vlan_tpid_result {
4260 cmdline_fixed_string_t vlan;
4261 cmdline_fixed_string_t set;
4262 cmdline_fixed_string_t vlan_type;
4263 cmdline_fixed_string_t what;
4269 cmd_vlan_tpid_parsed(void *parsed_result,
4270 __rte_unused struct cmdline *cl,
4271 __rte_unused void *data)
4273 struct cmd_vlan_tpid_result *res = parsed_result;
4274 enum rte_vlan_type vlan_type;
4276 if (!strcmp(res->vlan_type, "inner"))
4277 vlan_type = ETH_VLAN_TYPE_INNER;
4278 else if (!strcmp(res->vlan_type, "outer"))
4279 vlan_type = ETH_VLAN_TYPE_OUTER;
4281 printf("Unknown vlan type\n");
4284 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
4287 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
4288 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4290 cmdline_parse_token_string_t cmd_vlan_tpid_set =
4291 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4293 cmdline_parse_token_string_t cmd_vlan_type =
4294 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4295 vlan_type, "inner#outer");
4296 cmdline_parse_token_string_t cmd_vlan_tpid_what =
4297 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4299 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
4300 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4302 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
4303 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4306 cmdline_parse_inst_t cmd_vlan_tpid = {
4307 .f = cmd_vlan_tpid_parsed,
4309 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
4310 "Set the VLAN Ether type",
4312 (void *)&cmd_vlan_tpid_vlan,
4313 (void *)&cmd_vlan_tpid_set,
4314 (void *)&cmd_vlan_type,
4315 (void *)&cmd_vlan_tpid_what,
4316 (void *)&cmd_vlan_tpid_tpid,
4317 (void *)&cmd_vlan_tpid_portid,
4322 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4323 struct cmd_rx_vlan_filter_result {
4324 cmdline_fixed_string_t rx_vlan;
4325 cmdline_fixed_string_t what;
4331 cmd_rx_vlan_filter_parsed(void *parsed_result,
4332 __rte_unused struct cmdline *cl,
4333 __rte_unused void *data)
4335 struct cmd_rx_vlan_filter_result *res = parsed_result;
4337 if (!strcmp(res->what, "add"))
4338 rx_vft_set(res->port_id, res->vlan_id, 1);
4340 rx_vft_set(res->port_id, res->vlan_id, 0);
4343 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
4344 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4345 rx_vlan, "rx_vlan");
4346 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
4347 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4349 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
4350 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4352 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
4353 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4356 cmdline_parse_inst_t cmd_rx_vlan_filter = {
4357 .f = cmd_rx_vlan_filter_parsed,
4359 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
4360 "Add/Remove a VLAN identifier to/from the set of VLAN "
4361 "identifiers filtered by a port",
4363 (void *)&cmd_rx_vlan_filter_rx_vlan,
4364 (void *)&cmd_rx_vlan_filter_what,
4365 (void *)&cmd_rx_vlan_filter_vlanid,
4366 (void *)&cmd_rx_vlan_filter_portid,
4371 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4372 struct cmd_tx_vlan_set_result {
4373 cmdline_fixed_string_t tx_vlan;
4374 cmdline_fixed_string_t set;
4380 cmd_tx_vlan_set_parsed(void *parsed_result,
4381 __rte_unused struct cmdline *cl,
4382 __rte_unused void *data)
4384 struct cmd_tx_vlan_set_result *res = parsed_result;
4386 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4389 if (!port_is_stopped(res->port_id)) {
4390 printf("Please stop port %d first\n", res->port_id);
4394 tx_vlan_set(res->port_id, res->vlan_id);
4396 cmd_reconfig_device_queue(res->port_id, 1, 1);
4399 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4400 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4401 tx_vlan, "tx_vlan");
4402 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4403 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4405 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4406 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4408 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
4409 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4412 cmdline_parse_inst_t cmd_tx_vlan_set = {
4413 .f = cmd_tx_vlan_set_parsed,
4415 .help_str = "tx_vlan set <port_id> <vlan_id>: "
4416 "Enable hardware insertion of a single VLAN header "
4417 "with a given TAG Identifier in packets sent on a port",
4419 (void *)&cmd_tx_vlan_set_tx_vlan,
4420 (void *)&cmd_tx_vlan_set_set,
4421 (void *)&cmd_tx_vlan_set_portid,
4422 (void *)&cmd_tx_vlan_set_vlanid,
4427 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4428 struct cmd_tx_vlan_set_qinq_result {
4429 cmdline_fixed_string_t tx_vlan;
4430 cmdline_fixed_string_t set;
4433 uint16_t vlan_id_outer;
4437 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4438 __rte_unused struct cmdline *cl,
4439 __rte_unused void *data)
4441 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
4443 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4446 if (!port_is_stopped(res->port_id)) {
4447 printf("Please stop port %d first\n", res->port_id);
4451 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
4453 cmd_reconfig_device_queue(res->port_id, 1, 1);
4456 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
4457 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4458 tx_vlan, "tx_vlan");
4459 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
4460 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4462 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
4463 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4465 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
4466 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4468 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
4469 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4470 vlan_id_outer, UINT16);
4472 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
4473 .f = cmd_tx_vlan_set_qinq_parsed,
4475 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
4476 "Enable hardware insertion of double VLAN header "
4477 "with given TAG Identifiers in packets sent on a port",
4479 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
4480 (void *)&cmd_tx_vlan_set_qinq_set,
4481 (void *)&cmd_tx_vlan_set_qinq_portid,
4482 (void *)&cmd_tx_vlan_set_qinq_vlanid,
4483 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
4488 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
4489 struct cmd_tx_vlan_set_pvid_result {
4490 cmdline_fixed_string_t tx_vlan;
4491 cmdline_fixed_string_t set;
4492 cmdline_fixed_string_t pvid;
4495 cmdline_fixed_string_t mode;
4499 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
4500 __rte_unused struct cmdline *cl,
4501 __rte_unused void *data)
4503 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
4505 if (strcmp(res->mode, "on") == 0)
4506 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
4508 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
4511 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
4512 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4513 tx_vlan, "tx_vlan");
4514 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
4515 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4517 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
4518 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4520 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
4521 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4523 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
4524 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4526 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
4527 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4530 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
4531 .f = cmd_tx_vlan_set_pvid_parsed,
4533 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
4535 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
4536 (void *)&cmd_tx_vlan_set_pvid_set,
4537 (void *)&cmd_tx_vlan_set_pvid_pvid,
4538 (void *)&cmd_tx_vlan_set_pvid_port_id,
4539 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
4540 (void *)&cmd_tx_vlan_set_pvid_mode,
4545 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4546 struct cmd_tx_vlan_reset_result {
4547 cmdline_fixed_string_t tx_vlan;
4548 cmdline_fixed_string_t reset;
4553 cmd_tx_vlan_reset_parsed(void *parsed_result,
4554 __rte_unused struct cmdline *cl,
4555 __rte_unused void *data)
4557 struct cmd_tx_vlan_reset_result *res = parsed_result;
4559 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4562 if (!port_is_stopped(res->port_id)) {
4563 printf("Please stop port %d first\n", res->port_id);
4567 tx_vlan_reset(res->port_id);
4569 cmd_reconfig_device_queue(res->port_id, 1, 1);
4572 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4573 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4574 tx_vlan, "tx_vlan");
4575 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4576 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4578 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4579 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4582 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4583 .f = cmd_tx_vlan_reset_parsed,
4585 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4586 "VLAN header in packets sent on a port",
4588 (void *)&cmd_tx_vlan_reset_tx_vlan,
4589 (void *)&cmd_tx_vlan_reset_reset,
4590 (void *)&cmd_tx_vlan_reset_portid,
4596 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4597 struct cmd_csum_result {
4598 cmdline_fixed_string_t csum;
4599 cmdline_fixed_string_t mode;
4600 cmdline_fixed_string_t proto;
4601 cmdline_fixed_string_t hwsw;
4606 csum_show(int port_id)
4608 struct rte_eth_dev_info dev_info;
4609 uint64_t tx_offloads;
4612 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4613 printf("Parse tunnel is %s\n",
4614 (ports[port_id].parse_tunnel) ? "on" : "off");
4615 printf("IP checksum offload is %s\n",
4616 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4617 printf("UDP checksum offload is %s\n",
4618 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4619 printf("TCP checksum offload is %s\n",
4620 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4621 printf("SCTP checksum offload is %s\n",
4622 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4623 printf("Outer-Ip checksum offload is %s\n",
4624 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4625 printf("Outer-Udp checksum offload is %s\n",
4626 (tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
4628 /* display warnings if configuration is not supported by the NIC */
4629 ret = eth_dev_info_get_print_err(port_id, &dev_info);
4633 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
4634 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4635 printf("Warning: hardware IP checksum enabled but not "
4636 "supported by port %d\n", port_id);
4638 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
4639 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
4640 printf("Warning: hardware UDP checksum enabled but not "
4641 "supported by port %d\n", port_id);
4643 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
4644 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
4645 printf("Warning: hardware TCP checksum enabled but not "
4646 "supported by port %d\n", port_id);
4648 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
4649 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4650 printf("Warning: hardware SCTP checksum enabled but not "
4651 "supported by port %d\n", port_id);
4653 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4654 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4655 printf("Warning: hardware outer IP checksum enabled but not "
4656 "supported by port %d\n", port_id);
4658 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
4659 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)
4661 printf("Warning: hardware outer UDP checksum enabled but not "
4662 "supported by port %d\n", port_id);
4667 cmd_config_queue_tx_offloads(struct rte_port *port)
4671 /* Apply queue tx offloads configuration */
4672 for (k = 0; k < port->dev_info.max_rx_queues; k++)
4673 port->tx_conf[k].offloads =
4674 port->dev_conf.txmode.offloads;
4678 cmd_csum_parsed(void *parsed_result,
4679 __rte_unused struct cmdline *cl,
4680 __rte_unused void *data)
4682 struct cmd_csum_result *res = parsed_result;
4684 uint64_t csum_offloads = 0;
4685 struct rte_eth_dev_info dev_info;
4688 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4689 printf("invalid port %d\n", res->port_id);
4692 if (!port_is_stopped(res->port_id)) {
4693 printf("Please stop port %d first\n", res->port_id);
4697 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4701 if (!strcmp(res->mode, "set")) {
4703 if (!strcmp(res->hwsw, "hw"))
4706 if (!strcmp(res->proto, "ip")) {
4707 if (hw == 0 || (dev_info.tx_offload_capa &
4708 DEV_TX_OFFLOAD_IPV4_CKSUM)) {
4709 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
4711 printf("IP checksum offload is not supported "
4712 "by port %u\n", res->port_id);
4714 } else if (!strcmp(res->proto, "udp")) {
4715 if (hw == 0 || (dev_info.tx_offload_capa &
4716 DEV_TX_OFFLOAD_UDP_CKSUM)) {
4717 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
4719 printf("UDP checksum offload is not supported "
4720 "by port %u\n", res->port_id);
4722 } else if (!strcmp(res->proto, "tcp")) {
4723 if (hw == 0 || (dev_info.tx_offload_capa &
4724 DEV_TX_OFFLOAD_TCP_CKSUM)) {
4725 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
4727 printf("TCP checksum offload is not supported "
4728 "by port %u\n", res->port_id);
4730 } else if (!strcmp(res->proto, "sctp")) {
4731 if (hw == 0 || (dev_info.tx_offload_capa &
4732 DEV_TX_OFFLOAD_SCTP_CKSUM)) {
4733 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
4735 printf("SCTP checksum offload is not supported "
4736 "by port %u\n", res->port_id);
4738 } else if (!strcmp(res->proto, "outer-ip")) {
4739 if (hw == 0 || (dev_info.tx_offload_capa &
4740 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4742 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4744 printf("Outer IP checksum offload is not "
4745 "supported by port %u\n", res->port_id);
4747 } else if (!strcmp(res->proto, "outer-udp")) {
4748 if (hw == 0 || (dev_info.tx_offload_capa &
4749 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
4751 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM;
4753 printf("Outer UDP checksum offload is not "
4754 "supported by port %u\n", res->port_id);
4759 ports[res->port_id].dev_conf.txmode.offloads |=
4762 ports[res->port_id].dev_conf.txmode.offloads &=
4765 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4767 csum_show(res->port_id);
4769 cmd_reconfig_device_queue(res->port_id, 1, 1);
4772 cmdline_parse_token_string_t cmd_csum_csum =
4773 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4775 cmdline_parse_token_string_t cmd_csum_mode =
4776 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4778 cmdline_parse_token_string_t cmd_csum_proto =
4779 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4780 proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
4781 cmdline_parse_token_string_t cmd_csum_hwsw =
4782 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4784 cmdline_parse_token_num_t cmd_csum_portid =
4785 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4788 cmdline_parse_inst_t cmd_csum_set = {
4789 .f = cmd_csum_parsed,
4791 .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
4792 "Enable/Disable hardware calculation of L3/L4 checksum when "
4793 "using csum forward engine",
4795 (void *)&cmd_csum_csum,
4796 (void *)&cmd_csum_mode,
4797 (void *)&cmd_csum_proto,
4798 (void *)&cmd_csum_hwsw,
4799 (void *)&cmd_csum_portid,
4804 cmdline_parse_token_string_t cmd_csum_mode_show =
4805 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4808 cmdline_parse_inst_t cmd_csum_show = {
4809 .f = cmd_csum_parsed,
4811 .help_str = "csum show <port_id>: Show checksum offload configuration",
4813 (void *)&cmd_csum_csum,
4814 (void *)&cmd_csum_mode_show,
4815 (void *)&cmd_csum_portid,
4820 /* Enable/disable tunnel parsing */
4821 struct cmd_csum_tunnel_result {
4822 cmdline_fixed_string_t csum;
4823 cmdline_fixed_string_t parse;
4824 cmdline_fixed_string_t onoff;
4829 cmd_csum_tunnel_parsed(void *parsed_result,
4830 __rte_unused struct cmdline *cl,
4831 __rte_unused void *data)
4833 struct cmd_csum_tunnel_result *res = parsed_result;
4835 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4838 if (!strcmp(res->onoff, "on"))
4839 ports[res->port_id].parse_tunnel = 1;
4841 ports[res->port_id].parse_tunnel = 0;
4843 csum_show(res->port_id);
4846 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4847 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4849 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4850 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4851 parse, "parse-tunnel");
4852 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4853 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4855 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4856 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4859 cmdline_parse_inst_t cmd_csum_tunnel = {
4860 .f = cmd_csum_tunnel_parsed,
4862 .help_str = "csum parse-tunnel on|off <port_id>: "
4863 "Enable/Disable parsing of tunnels for csum engine",
4865 (void *)&cmd_csum_tunnel_csum,
4866 (void *)&cmd_csum_tunnel_parse,
4867 (void *)&cmd_csum_tunnel_onoff,
4868 (void *)&cmd_csum_tunnel_portid,
4873 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4874 struct cmd_tso_set_result {
4875 cmdline_fixed_string_t tso;
4876 cmdline_fixed_string_t mode;
4882 cmd_tso_set_parsed(void *parsed_result,
4883 __rte_unused struct cmdline *cl,
4884 __rte_unused void *data)
4886 struct cmd_tso_set_result *res = parsed_result;
4887 struct rte_eth_dev_info dev_info;
4890 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4892 if (!port_is_stopped(res->port_id)) {
4893 printf("Please stop port %d first\n", res->port_id);
4897 if (!strcmp(res->mode, "set"))
4898 ports[res->port_id].tso_segsz = res->tso_segsz;
4900 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4904 if ((ports[res->port_id].tso_segsz != 0) &&
4905 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4906 printf("Error: TSO is not supported by port %d\n",
4911 if (ports[res->port_id].tso_segsz == 0) {
4912 ports[res->port_id].dev_conf.txmode.offloads &=
4913 ~DEV_TX_OFFLOAD_TCP_TSO;
4914 printf("TSO for non-tunneled packets is disabled\n");
4916 ports[res->port_id].dev_conf.txmode.offloads |=
4917 DEV_TX_OFFLOAD_TCP_TSO;
4918 printf("TSO segment size for non-tunneled packets is %d\n",
4919 ports[res->port_id].tso_segsz);
4921 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4923 /* display warnings if configuration is not supported by the NIC */
4924 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4928 if ((ports[res->port_id].tso_segsz != 0) &&
4929 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4930 printf("Warning: TSO enabled but not "
4931 "supported by port %d\n", res->port_id);
4934 cmd_reconfig_device_queue(res->port_id, 1, 1);
4937 cmdline_parse_token_string_t cmd_tso_set_tso =
4938 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4940 cmdline_parse_token_string_t cmd_tso_set_mode =
4941 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4943 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4944 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4946 cmdline_parse_token_num_t cmd_tso_set_portid =
4947 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4950 cmdline_parse_inst_t cmd_tso_set = {
4951 .f = cmd_tso_set_parsed,
4953 .help_str = "tso set <tso_segsz> <port_id>: "
4954 "Set TSO segment size of non-tunneled packets for csum engine "
4957 (void *)&cmd_tso_set_tso,
4958 (void *)&cmd_tso_set_mode,
4959 (void *)&cmd_tso_set_tso_segsz,
4960 (void *)&cmd_tso_set_portid,
4965 cmdline_parse_token_string_t cmd_tso_show_mode =
4966 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4970 cmdline_parse_inst_t cmd_tso_show = {
4971 .f = cmd_tso_set_parsed,
4973 .help_str = "tso show <port_id>: "
4974 "Show TSO segment size of non-tunneled packets for csum engine",
4976 (void *)&cmd_tso_set_tso,
4977 (void *)&cmd_tso_show_mode,
4978 (void *)&cmd_tso_set_portid,
4983 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
4984 struct cmd_tunnel_tso_set_result {
4985 cmdline_fixed_string_t tso;
4986 cmdline_fixed_string_t mode;
4991 static struct rte_eth_dev_info
4992 check_tunnel_tso_nic_support(portid_t port_id)
4994 struct rte_eth_dev_info dev_info;
4996 if (eth_dev_info_get_print_err(port_id, &dev_info) != 0)
4999 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
5000 printf("Warning: VXLAN TUNNEL TSO not supported therefore "
5001 "not enabled for port %d\n", port_id);
5002 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
5003 printf("Warning: GRE TUNNEL TSO not supported therefore "
5004 "not enabled for port %d\n", port_id);
5005 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
5006 printf("Warning: IPIP TUNNEL TSO not supported therefore "
5007 "not enabled for port %d\n", port_id);
5008 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
5009 printf("Warning: GENEVE TUNNEL TSO not supported therefore "
5010 "not enabled for port %d\n", port_id);
5011 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
5012 printf("Warning: IP TUNNEL TSO not supported therefore "
5013 "not enabled for port %d\n", port_id);
5014 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
5015 printf("Warning: UDP TUNNEL TSO not supported therefore "
5016 "not enabled for port %d\n", port_id);
5021 cmd_tunnel_tso_set_parsed(void *parsed_result,
5022 __rte_unused struct cmdline *cl,
5023 __rte_unused void *data)
5025 struct cmd_tunnel_tso_set_result *res = parsed_result;
5026 struct rte_eth_dev_info dev_info;
5028 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
5030 if (!port_is_stopped(res->port_id)) {
5031 printf("Please stop port %d first\n", res->port_id);
5035 if (!strcmp(res->mode, "set"))
5036 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
5038 dev_info = check_tunnel_tso_nic_support(res->port_id);
5039 if (ports[res->port_id].tunnel_tso_segsz == 0) {
5040 ports[res->port_id].dev_conf.txmode.offloads &=
5041 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
5042 DEV_TX_OFFLOAD_GRE_TNL_TSO |
5043 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
5044 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
5045 DEV_TX_OFFLOAD_IP_TNL_TSO |
5046 DEV_TX_OFFLOAD_UDP_TNL_TSO);
5047 printf("TSO for tunneled packets is disabled\n");
5049 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
5050 DEV_TX_OFFLOAD_GRE_TNL_TSO |
5051 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
5052 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
5053 DEV_TX_OFFLOAD_IP_TNL_TSO |
5054 DEV_TX_OFFLOAD_UDP_TNL_TSO);
5056 ports[res->port_id].dev_conf.txmode.offloads |=
5057 (tso_offloads & dev_info.tx_offload_capa);
5058 printf("TSO segment size for tunneled packets is %d\n",
5059 ports[res->port_id].tunnel_tso_segsz);
5061 /* Below conditions are needed to make it work:
5062 * (1) tunnel TSO is supported by the NIC;
5063 * (2) "csum parse_tunnel" must be set so that tunneled pkts
5065 * (3) for tunneled pkts with outer L3 of IPv4,
5066 * "csum set outer-ip" must be set to hw, because after tso,
5067 * total_len of outer IP header is changed, and the checksum
5068 * of outer IP header calculated by sw should be wrong; that
5069 * is not necessary for IPv6 tunneled pkts because there's no
5070 * checksum in IP header anymore.
5073 if (!ports[res->port_id].parse_tunnel)
5074 printf("Warning: csum parse_tunnel must be set "
5075 "so that tunneled packets are recognized\n");
5076 if (!(ports[res->port_id].dev_conf.txmode.offloads &
5077 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
5078 printf("Warning: csum set outer-ip must be set to hw "
5079 "if outer L3 is IPv4; not necessary for IPv6\n");
5082 cmd_config_queue_tx_offloads(&ports[res->port_id]);
5083 cmd_reconfig_device_queue(res->port_id, 1, 1);
5086 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
5087 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5089 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
5090 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5092 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
5093 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5095 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
5096 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5099 cmdline_parse_inst_t cmd_tunnel_tso_set = {
5100 .f = cmd_tunnel_tso_set_parsed,
5102 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
5103 "Set TSO segment size of tunneled packets for csum engine "
5106 (void *)&cmd_tunnel_tso_set_tso,
5107 (void *)&cmd_tunnel_tso_set_mode,
5108 (void *)&cmd_tunnel_tso_set_tso_segsz,
5109 (void *)&cmd_tunnel_tso_set_portid,
5114 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
5115 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5119 cmdline_parse_inst_t cmd_tunnel_tso_show = {
5120 .f = cmd_tunnel_tso_set_parsed,
5122 .help_str = "tunnel_tso show <port_id> "
5123 "Show TSO segment size of tunneled packets for csum engine",
5125 (void *)&cmd_tunnel_tso_set_tso,
5126 (void *)&cmd_tunnel_tso_show_mode,
5127 (void *)&cmd_tunnel_tso_set_portid,
5132 /* *** SET GRO FOR A PORT *** */
5133 struct cmd_gro_enable_result {
5134 cmdline_fixed_string_t cmd_set;
5135 cmdline_fixed_string_t cmd_port;
5136 cmdline_fixed_string_t cmd_keyword;
5137 cmdline_fixed_string_t cmd_onoff;
5142 cmd_gro_enable_parsed(void *parsed_result,
5143 __rte_unused struct cmdline *cl,
5144 __rte_unused void *data)
5146 struct cmd_gro_enable_result *res;
5148 res = parsed_result;
5149 if (!strcmp(res->cmd_keyword, "gro"))
5150 setup_gro(res->cmd_onoff, res->cmd_pid);
5153 cmdline_parse_token_string_t cmd_gro_enable_set =
5154 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5156 cmdline_parse_token_string_t cmd_gro_enable_port =
5157 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5158 cmd_keyword, "port");
5159 cmdline_parse_token_num_t cmd_gro_enable_pid =
5160 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
5162 cmdline_parse_token_string_t cmd_gro_enable_keyword =
5163 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5164 cmd_keyword, "gro");
5165 cmdline_parse_token_string_t cmd_gro_enable_onoff =
5166 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5167 cmd_onoff, "on#off");
5169 cmdline_parse_inst_t cmd_gro_enable = {
5170 .f = cmd_gro_enable_parsed,
5172 .help_str = "set port <port_id> gro on|off",
5174 (void *)&cmd_gro_enable_set,
5175 (void *)&cmd_gro_enable_port,
5176 (void *)&cmd_gro_enable_pid,
5177 (void *)&cmd_gro_enable_keyword,
5178 (void *)&cmd_gro_enable_onoff,
5183 /* *** DISPLAY GRO CONFIGURATION *** */
5184 struct cmd_gro_show_result {
5185 cmdline_fixed_string_t cmd_show;
5186 cmdline_fixed_string_t cmd_port;
5187 cmdline_fixed_string_t cmd_keyword;
5192 cmd_gro_show_parsed(void *parsed_result,
5193 __rte_unused struct cmdline *cl,
5194 __rte_unused void *data)
5196 struct cmd_gro_show_result *res;
5198 res = parsed_result;
5199 if (!strcmp(res->cmd_keyword, "gro"))
5200 show_gro(res->cmd_pid);
5203 cmdline_parse_token_string_t cmd_gro_show_show =
5204 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5206 cmdline_parse_token_string_t cmd_gro_show_port =
5207 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5209 cmdline_parse_token_num_t cmd_gro_show_pid =
5210 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
5212 cmdline_parse_token_string_t cmd_gro_show_keyword =
5213 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5214 cmd_keyword, "gro");
5216 cmdline_parse_inst_t cmd_gro_show = {
5217 .f = cmd_gro_show_parsed,
5219 .help_str = "show port <port_id> gro",
5221 (void *)&cmd_gro_show_show,
5222 (void *)&cmd_gro_show_port,
5223 (void *)&cmd_gro_show_pid,
5224 (void *)&cmd_gro_show_keyword,
5229 /* *** SET FLUSH CYCLES FOR GRO *** */
5230 struct cmd_gro_flush_result {
5231 cmdline_fixed_string_t cmd_set;
5232 cmdline_fixed_string_t cmd_keyword;
5233 cmdline_fixed_string_t cmd_flush;
5238 cmd_gro_flush_parsed(void *parsed_result,
5239 __rte_unused struct cmdline *cl,
5240 __rte_unused void *data)
5242 struct cmd_gro_flush_result *res;
5244 res = parsed_result;
5245 if ((!strcmp(res->cmd_keyword, "gro")) &&
5246 (!strcmp(res->cmd_flush, "flush")))
5247 setup_gro_flush_cycles(res->cmd_cycles);
5250 cmdline_parse_token_string_t cmd_gro_flush_set =
5251 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5253 cmdline_parse_token_string_t cmd_gro_flush_keyword =
5254 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5255 cmd_keyword, "gro");
5256 cmdline_parse_token_string_t cmd_gro_flush_flush =
5257 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5258 cmd_flush, "flush");
5259 cmdline_parse_token_num_t cmd_gro_flush_cycles =
5260 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
5263 cmdline_parse_inst_t cmd_gro_flush = {
5264 .f = cmd_gro_flush_parsed,
5266 .help_str = "set gro flush <cycles>",
5268 (void *)&cmd_gro_flush_set,
5269 (void *)&cmd_gro_flush_keyword,
5270 (void *)&cmd_gro_flush_flush,
5271 (void *)&cmd_gro_flush_cycles,
5276 /* *** ENABLE/DISABLE GSO *** */
5277 struct cmd_gso_enable_result {
5278 cmdline_fixed_string_t cmd_set;
5279 cmdline_fixed_string_t cmd_port;
5280 cmdline_fixed_string_t cmd_keyword;
5281 cmdline_fixed_string_t cmd_mode;
5286 cmd_gso_enable_parsed(void *parsed_result,
5287 __rte_unused struct cmdline *cl,
5288 __rte_unused void *data)
5290 struct cmd_gso_enable_result *res;
5292 res = parsed_result;
5293 if (!strcmp(res->cmd_keyword, "gso"))
5294 setup_gso(res->cmd_mode, res->cmd_pid);
5297 cmdline_parse_token_string_t cmd_gso_enable_set =
5298 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5300 cmdline_parse_token_string_t cmd_gso_enable_port =
5301 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5303 cmdline_parse_token_string_t cmd_gso_enable_keyword =
5304 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5305 cmd_keyword, "gso");
5306 cmdline_parse_token_string_t cmd_gso_enable_mode =
5307 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5308 cmd_mode, "on#off");
5309 cmdline_parse_token_num_t cmd_gso_enable_pid =
5310 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
5313 cmdline_parse_inst_t cmd_gso_enable = {
5314 .f = cmd_gso_enable_parsed,
5316 .help_str = "set port <port_id> gso on|off",
5318 (void *)&cmd_gso_enable_set,
5319 (void *)&cmd_gso_enable_port,
5320 (void *)&cmd_gso_enable_pid,
5321 (void *)&cmd_gso_enable_keyword,
5322 (void *)&cmd_gso_enable_mode,
5327 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
5328 struct cmd_gso_size_result {
5329 cmdline_fixed_string_t cmd_set;
5330 cmdline_fixed_string_t cmd_keyword;
5331 cmdline_fixed_string_t cmd_segsz;
5336 cmd_gso_size_parsed(void *parsed_result,
5337 __rte_unused struct cmdline *cl,
5338 __rte_unused void *data)
5340 struct cmd_gso_size_result *res = parsed_result;
5342 if (test_done == 0) {
5343 printf("Before setting GSO segsz, please first"
5344 " stop forwarding\n");
5348 if (!strcmp(res->cmd_keyword, "gso") &&
5349 !strcmp(res->cmd_segsz, "segsz")) {
5350 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
5351 printf("gso_size should be larger than %zu."
5352 " Please input a legal value\n",
5353 RTE_GSO_SEG_SIZE_MIN);
5355 gso_max_segment_size = res->cmd_size;
5359 cmdline_parse_token_string_t cmd_gso_size_set =
5360 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5362 cmdline_parse_token_string_t cmd_gso_size_keyword =
5363 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5364 cmd_keyword, "gso");
5365 cmdline_parse_token_string_t cmd_gso_size_segsz =
5366 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5367 cmd_segsz, "segsz");
5368 cmdline_parse_token_num_t cmd_gso_size_size =
5369 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
5372 cmdline_parse_inst_t cmd_gso_size = {
5373 .f = cmd_gso_size_parsed,
5375 .help_str = "set gso segsz <length>",
5377 (void *)&cmd_gso_size_set,
5378 (void *)&cmd_gso_size_keyword,
5379 (void *)&cmd_gso_size_segsz,
5380 (void *)&cmd_gso_size_size,
5385 /* *** SHOW GSO CONFIGURATION *** */
5386 struct cmd_gso_show_result {
5387 cmdline_fixed_string_t cmd_show;
5388 cmdline_fixed_string_t cmd_port;
5389 cmdline_fixed_string_t cmd_keyword;
5394 cmd_gso_show_parsed(void *parsed_result,
5395 __rte_unused struct cmdline *cl,
5396 __rte_unused void *data)
5398 struct cmd_gso_show_result *res = parsed_result;
5400 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
5401 printf("invalid port id %u\n", res->cmd_pid);
5404 if (!strcmp(res->cmd_keyword, "gso")) {
5405 if (gso_ports[res->cmd_pid].enable) {
5406 printf("Max GSO'd packet size: %uB\n"
5407 "Supported GSO types: TCP/IPv4, "
5408 "UDP/IPv4, VxLAN with inner "
5409 "TCP/IPv4 packet, GRE with inner "
5410 "TCP/IPv4 packet\n",
5411 gso_max_segment_size);
5413 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
5417 cmdline_parse_token_string_t cmd_gso_show_show =
5418 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5420 cmdline_parse_token_string_t cmd_gso_show_port =
5421 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5423 cmdline_parse_token_string_t cmd_gso_show_keyword =
5424 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5425 cmd_keyword, "gso");
5426 cmdline_parse_token_num_t cmd_gso_show_pid =
5427 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
5430 cmdline_parse_inst_t cmd_gso_show = {
5431 .f = cmd_gso_show_parsed,
5433 .help_str = "show port <port_id> gso",
5435 (void *)&cmd_gso_show_show,
5436 (void *)&cmd_gso_show_port,
5437 (void *)&cmd_gso_show_pid,
5438 (void *)&cmd_gso_show_keyword,
5443 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
5444 struct cmd_set_flush_rx {
5445 cmdline_fixed_string_t set;
5446 cmdline_fixed_string_t flush_rx;
5447 cmdline_fixed_string_t mode;
5451 cmd_set_flush_rx_parsed(void *parsed_result,
5452 __rte_unused struct cmdline *cl,
5453 __rte_unused void *data)
5455 struct cmd_set_flush_rx *res = parsed_result;
5456 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5459 cmdline_parse_token_string_t cmd_setflushrx_set =
5460 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5462 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
5463 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5464 flush_rx, "flush_rx");
5465 cmdline_parse_token_string_t cmd_setflushrx_mode =
5466 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5470 cmdline_parse_inst_t cmd_set_flush_rx = {
5471 .f = cmd_set_flush_rx_parsed,
5472 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
5475 (void *)&cmd_setflushrx_set,
5476 (void *)&cmd_setflushrx_flush_rx,
5477 (void *)&cmd_setflushrx_mode,
5482 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
5483 struct cmd_set_link_check {
5484 cmdline_fixed_string_t set;
5485 cmdline_fixed_string_t link_check;
5486 cmdline_fixed_string_t mode;
5490 cmd_set_link_check_parsed(void *parsed_result,
5491 __rte_unused struct cmdline *cl,
5492 __rte_unused void *data)
5494 struct cmd_set_link_check *res = parsed_result;
5495 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5498 cmdline_parse_token_string_t cmd_setlinkcheck_set =
5499 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5501 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
5502 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5503 link_check, "link_check");
5504 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
5505 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5509 cmdline_parse_inst_t cmd_set_link_check = {
5510 .f = cmd_set_link_check_parsed,
5511 .help_str = "set link_check on|off: Enable/Disable link status check "
5512 "when starting/stopping a port",
5515 (void *)&cmd_setlinkcheck_set,
5516 (void *)&cmd_setlinkcheck_link_check,
5517 (void *)&cmd_setlinkcheck_mode,
5522 /* *** SET NIC BYPASS MODE *** */
5523 struct cmd_set_bypass_mode_result {
5524 cmdline_fixed_string_t set;
5525 cmdline_fixed_string_t bypass;
5526 cmdline_fixed_string_t mode;
5527 cmdline_fixed_string_t value;
5532 cmd_set_bypass_mode_parsed(void *parsed_result,
5533 __rte_unused struct cmdline *cl,
5534 __rte_unused void *data)
5536 struct cmd_set_bypass_mode_result *res = parsed_result;
5537 portid_t port_id = res->port_id;
5538 int32_t rc = -EINVAL;
5540 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5541 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5543 if (!strcmp(res->value, "bypass"))
5544 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5545 else if (!strcmp(res->value, "isolate"))
5546 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5548 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5550 /* Set the bypass mode for the relevant port. */
5551 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
5554 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
5557 cmdline_parse_token_string_t cmd_setbypass_mode_set =
5558 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5560 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
5561 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5563 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
5564 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5566 cmdline_parse_token_string_t cmd_setbypass_mode_value =
5567 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5568 value, "normal#bypass#isolate");
5569 cmdline_parse_token_num_t cmd_setbypass_mode_port =
5570 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
5573 cmdline_parse_inst_t cmd_set_bypass_mode = {
5574 .f = cmd_set_bypass_mode_parsed,
5575 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
5576 "Set the NIC bypass mode for port_id",
5579 (void *)&cmd_setbypass_mode_set,
5580 (void *)&cmd_setbypass_mode_bypass,
5581 (void *)&cmd_setbypass_mode_mode,
5582 (void *)&cmd_setbypass_mode_value,
5583 (void *)&cmd_setbypass_mode_port,
5588 /* *** SET NIC BYPASS EVENT *** */
5589 struct cmd_set_bypass_event_result {
5590 cmdline_fixed_string_t set;
5591 cmdline_fixed_string_t bypass;
5592 cmdline_fixed_string_t event;
5593 cmdline_fixed_string_t event_value;
5594 cmdline_fixed_string_t mode;
5595 cmdline_fixed_string_t mode_value;
5600 cmd_set_bypass_event_parsed(void *parsed_result,
5601 __rte_unused struct cmdline *cl,
5602 __rte_unused void *data)
5604 int32_t rc = -EINVAL;
5605 struct cmd_set_bypass_event_result *res = parsed_result;
5606 portid_t port_id = res->port_id;
5608 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5609 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5610 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5612 if (!strcmp(res->event_value, "timeout"))
5613 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
5614 else if (!strcmp(res->event_value, "os_on"))
5615 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
5616 else if (!strcmp(res->event_value, "os_off"))
5617 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5618 else if (!strcmp(res->event_value, "power_on"))
5619 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5620 else if (!strcmp(res->event_value, "power_off"))
5621 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5623 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5625 if (!strcmp(res->mode_value, "bypass"))
5626 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5627 else if (!strcmp(res->mode_value, "isolate"))
5628 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5630 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5632 /* Set the watchdog timeout. */
5633 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5636 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5637 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5641 printf("Failed to set timeout value %u "
5642 "for port %d, errto code: %d.\n",
5643 bypass_timeout, port_id, rc);
5647 /* Set the bypass event to transition to bypass mode. */
5648 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5653 printf("\t Failed to set bypass event for port = %d.\n",
5657 cmdline_parse_token_string_t cmd_setbypass_event_set =
5658 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5660 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5661 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5663 cmdline_parse_token_string_t cmd_setbypass_event_event =
5664 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5666 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5667 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5668 event_value, "none#timeout#os_off#os_on#power_on#power_off");
5669 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5670 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5672 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5673 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5674 mode_value, "normal#bypass#isolate");
5675 cmdline_parse_token_num_t cmd_setbypass_event_port =
5676 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5679 cmdline_parse_inst_t cmd_set_bypass_event = {
5680 .f = cmd_set_bypass_event_parsed,
5681 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5682 "power_off mode normal|bypass|isolate <port_id>: "
5683 "Set the NIC bypass event mode for port_id",
5686 (void *)&cmd_setbypass_event_set,
5687 (void *)&cmd_setbypass_event_bypass,
5688 (void *)&cmd_setbypass_event_event,
5689 (void *)&cmd_setbypass_event_event_value,
5690 (void *)&cmd_setbypass_event_mode,
5691 (void *)&cmd_setbypass_event_mode_value,
5692 (void *)&cmd_setbypass_event_port,
5698 /* *** SET NIC BYPASS TIMEOUT *** */
5699 struct cmd_set_bypass_timeout_result {
5700 cmdline_fixed_string_t set;
5701 cmdline_fixed_string_t bypass;
5702 cmdline_fixed_string_t timeout;
5703 cmdline_fixed_string_t value;
5707 cmd_set_bypass_timeout_parsed(void *parsed_result,
5708 __rte_unused struct cmdline *cl,
5709 __rte_unused void *data)
5711 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5713 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5714 if (!strcmp(res->value, "1.5"))
5715 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5716 else if (!strcmp(res->value, "2"))
5717 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5718 else if (!strcmp(res->value, "3"))
5719 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5720 else if (!strcmp(res->value, "4"))
5721 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5722 else if (!strcmp(res->value, "8"))
5723 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5724 else if (!strcmp(res->value, "16"))
5725 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5726 else if (!strcmp(res->value, "32"))
5727 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5729 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5733 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5734 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5736 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5737 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5739 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5740 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5741 timeout, "timeout");
5742 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5743 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5744 value, "0#1.5#2#3#4#8#16#32");
5746 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5747 .f = cmd_set_bypass_timeout_parsed,
5748 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5749 "Set the NIC bypass watchdog timeout in seconds",
5752 (void *)&cmd_setbypass_timeout_set,
5753 (void *)&cmd_setbypass_timeout_bypass,
5754 (void *)&cmd_setbypass_timeout_timeout,
5755 (void *)&cmd_setbypass_timeout_value,
5760 /* *** SHOW NIC BYPASS MODE *** */
5761 struct cmd_show_bypass_config_result {
5762 cmdline_fixed_string_t show;
5763 cmdline_fixed_string_t bypass;
5764 cmdline_fixed_string_t config;
5769 cmd_show_bypass_config_parsed(void *parsed_result,
5770 __rte_unused struct cmdline *cl,
5771 __rte_unused void *data)
5773 struct cmd_show_bypass_config_result *res = parsed_result;
5774 portid_t port_id = res->port_id;
5776 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5777 uint32_t event_mode;
5778 uint32_t bypass_mode;
5779 uint32_t timeout = bypass_timeout;
5782 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5783 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
5784 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5785 {"UNKNOWN", "normal", "bypass", "isolate"};
5786 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5794 /* Display the bypass mode.*/
5795 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5796 printf("\tFailed to get bypass mode for port = %d\n", port_id);
5800 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5801 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5803 printf("\tbypass mode = %s\n", modes[bypass_mode]);
5806 /* Display the bypass timeout.*/
5807 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5808 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5810 printf("\tbypass timeout = %s\n", timeouts[timeout]);
5812 /* Display the bypass events and associated modes. */
5813 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < RTE_DIM(events); i++) {
5815 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5816 printf("\tFailed to get bypass mode for event = %s\n",
5819 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5820 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5822 printf("\tbypass event: %-16s = %s\n", events[i],
5828 printf("\tFailed to get bypass configuration for port = %d\n",
5832 cmdline_parse_token_string_t cmd_showbypass_config_show =
5833 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5835 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5836 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5838 cmdline_parse_token_string_t cmd_showbypass_config_config =
5839 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5841 cmdline_parse_token_num_t cmd_showbypass_config_port =
5842 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5845 cmdline_parse_inst_t cmd_show_bypass_config = {
5846 .f = cmd_show_bypass_config_parsed,
5847 .help_str = "show bypass config <port_id>: "
5848 "Show the NIC bypass config for port_id",
5851 (void *)&cmd_showbypass_config_show,
5852 (void *)&cmd_showbypass_config_bypass,
5853 (void *)&cmd_showbypass_config_config,
5854 (void *)&cmd_showbypass_config_port,
5860 /* *** SET BONDING MODE *** */
5861 struct cmd_set_bonding_mode_result {
5862 cmdline_fixed_string_t set;
5863 cmdline_fixed_string_t bonding;
5864 cmdline_fixed_string_t mode;
5869 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5870 __rte_unused struct cmdline *cl,
5871 __rte_unused void *data)
5873 struct cmd_set_bonding_mode_result *res = parsed_result;
5874 portid_t port_id = res->port_id;
5876 /* Set the bonding mode for the relevant port. */
5877 if (0 != rte_eth_bond_mode_set(port_id, res->value))
5878 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
5881 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5882 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5884 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5885 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5886 bonding, "bonding");
5887 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5888 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5890 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5891 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5893 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5894 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5897 cmdline_parse_inst_t cmd_set_bonding_mode = {
5898 .f = cmd_set_bonding_mode_parsed,
5899 .help_str = "set bonding mode <mode_value> <port_id>: "
5900 "Set the bonding mode for port_id",
5903 (void *) &cmd_setbonding_mode_set,
5904 (void *) &cmd_setbonding_mode_bonding,
5905 (void *) &cmd_setbonding_mode_mode,
5906 (void *) &cmd_setbonding_mode_value,
5907 (void *) &cmd_setbonding_mode_port,
5912 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5913 struct cmd_set_bonding_lacp_dedicated_queues_result {
5914 cmdline_fixed_string_t set;
5915 cmdline_fixed_string_t bonding;
5916 cmdline_fixed_string_t lacp;
5917 cmdline_fixed_string_t dedicated_queues;
5919 cmdline_fixed_string_t mode;
5922 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5923 __rte_unused struct cmdline *cl,
5924 __rte_unused void *data)
5926 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5927 portid_t port_id = res->port_id;
5928 struct rte_port *port;
5930 port = &ports[port_id];
5932 /** Check if the port is not started **/
5933 if (port->port_status != RTE_PORT_STOPPED) {
5934 printf("Please stop port %d first\n", port_id);
5938 if (!strcmp(res->mode, "enable")) {
5939 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5940 printf("Dedicate queues for LACP control packets"
5943 printf("Enabling dedicate queues for LACP control "
5944 "packets on port %d failed\n", port_id);
5945 } else if (!strcmp(res->mode, "disable")) {
5946 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5947 printf("Dedicated queues for LACP control packets "
5950 printf("Disabling dedicated queues for LACP control "
5951 "traffic on port %d failed\n", port_id);
5955 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5956 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5958 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
5959 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5960 bonding, "bonding");
5961 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
5962 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5964 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
5965 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5966 dedicated_queues, "dedicated_queues");
5967 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
5968 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5970 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
5971 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5972 mode, "enable#disable");
5974 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
5975 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
5976 .help_str = "set bonding lacp dedicated_queues <port_id> "
5978 "Enable/disable dedicated queues for LACP control traffic for port_id",
5981 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
5982 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
5983 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
5984 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
5985 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
5986 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
5991 /* *** SET BALANCE XMIT POLICY *** */
5992 struct cmd_set_bonding_balance_xmit_policy_result {
5993 cmdline_fixed_string_t set;
5994 cmdline_fixed_string_t bonding;
5995 cmdline_fixed_string_t balance_xmit_policy;
5997 cmdline_fixed_string_t policy;
6000 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
6001 __rte_unused struct cmdline *cl,
6002 __rte_unused void *data)
6004 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
6005 portid_t port_id = res->port_id;
6008 if (!strcmp(res->policy, "l2")) {
6009 policy = BALANCE_XMIT_POLICY_LAYER2;
6010 } else if (!strcmp(res->policy, "l23")) {
6011 policy = BALANCE_XMIT_POLICY_LAYER23;
6012 } else if (!strcmp(res->policy, "l34")) {
6013 policy = BALANCE_XMIT_POLICY_LAYER34;
6015 printf("\t Invalid xmit policy selection");
6019 /* Set the bonding mode for the relevant port. */
6020 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
6021 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
6026 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
6027 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6029 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
6030 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6031 bonding, "bonding");
6032 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
6033 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6034 balance_xmit_policy, "balance_xmit_policy");
6035 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
6036 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6038 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
6039 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6040 policy, "l2#l23#l34");
6042 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
6043 .f = cmd_set_bonding_balance_xmit_policy_parsed,
6044 .help_str = "set bonding balance_xmit_policy <port_id> "
6046 "Set the bonding balance_xmit_policy for port_id",
6049 (void *)&cmd_setbonding_balance_xmit_policy_set,
6050 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
6051 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
6052 (void *)&cmd_setbonding_balance_xmit_policy_port,
6053 (void *)&cmd_setbonding_balance_xmit_policy_policy,
6058 /* *** SHOW NIC BONDING CONFIGURATION *** */
6059 struct cmd_show_bonding_config_result {
6060 cmdline_fixed_string_t show;
6061 cmdline_fixed_string_t bonding;
6062 cmdline_fixed_string_t config;
6066 static void cmd_show_bonding_config_parsed(void *parsed_result,
6067 __rte_unused struct cmdline *cl,
6068 __rte_unused void *data)
6070 struct cmd_show_bonding_config_result *res = parsed_result;
6071 int bonding_mode, agg_mode;
6072 portid_t slaves[RTE_MAX_ETHPORTS];
6073 int num_slaves, num_active_slaves;
6076 portid_t port_id = res->port_id;
6078 /* Display the bonding mode.*/
6079 bonding_mode = rte_eth_bond_mode_get(port_id);
6080 if (bonding_mode < 0) {
6081 printf("\tFailed to get bonding mode for port = %d\n", port_id);
6084 printf("\tBonding mode: %d\n", bonding_mode);
6086 if (bonding_mode == BONDING_MODE_BALANCE) {
6087 int balance_xmit_policy;
6089 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
6090 if (balance_xmit_policy < 0) {
6091 printf("\tFailed to get balance xmit policy for port = %d\n",
6095 printf("\tBalance Xmit Policy: ");
6097 switch (balance_xmit_policy) {
6098 case BALANCE_XMIT_POLICY_LAYER2:
6099 printf("BALANCE_XMIT_POLICY_LAYER2");
6101 case BALANCE_XMIT_POLICY_LAYER23:
6102 printf("BALANCE_XMIT_POLICY_LAYER23");
6104 case BALANCE_XMIT_POLICY_LAYER34:
6105 printf("BALANCE_XMIT_POLICY_LAYER34");
6112 if (bonding_mode == BONDING_MODE_8023AD) {
6113 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
6114 printf("\tIEEE802.3AD Aggregator Mode: ");
6117 printf("bandwidth");
6129 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
6131 if (num_slaves < 0) {
6132 printf("\tFailed to get slave list for port = %d\n", port_id);
6135 if (num_slaves > 0) {
6136 printf("\tSlaves (%d): [", num_slaves);
6137 for (i = 0; i < num_slaves - 1; i++)
6138 printf("%d ", slaves[i]);
6140 printf("%d]\n", slaves[num_slaves - 1]);
6142 printf("\tSlaves: []\n");
6146 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
6149 if (num_active_slaves < 0) {
6150 printf("\tFailed to get active slave list for port = %d\n", port_id);
6153 if (num_active_slaves > 0) {
6154 printf("\tActive Slaves (%d): [", num_active_slaves);
6155 for (i = 0; i < num_active_slaves - 1; i++)
6156 printf("%d ", slaves[i]);
6158 printf("%d]\n", slaves[num_active_slaves - 1]);
6161 printf("\tActive Slaves: []\n");
6165 primary_id = rte_eth_bond_primary_get(port_id);
6166 if (primary_id < 0) {
6167 printf("\tFailed to get primary slave for port = %d\n", port_id);
6170 printf("\tPrimary: [%d]\n", primary_id);
6174 cmdline_parse_token_string_t cmd_showbonding_config_show =
6175 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6177 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
6178 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6179 bonding, "bonding");
6180 cmdline_parse_token_string_t cmd_showbonding_config_config =
6181 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6183 cmdline_parse_token_num_t cmd_showbonding_config_port =
6184 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
6187 cmdline_parse_inst_t cmd_show_bonding_config = {
6188 .f = cmd_show_bonding_config_parsed,
6189 .help_str = "show bonding config <port_id>: "
6190 "Show the bonding config for port_id",
6193 (void *)&cmd_showbonding_config_show,
6194 (void *)&cmd_showbonding_config_bonding,
6195 (void *)&cmd_showbonding_config_config,
6196 (void *)&cmd_showbonding_config_port,
6201 /* *** SET BONDING PRIMARY *** */
6202 struct cmd_set_bonding_primary_result {
6203 cmdline_fixed_string_t set;
6204 cmdline_fixed_string_t bonding;
6205 cmdline_fixed_string_t primary;
6210 static void cmd_set_bonding_primary_parsed(void *parsed_result,
6211 __rte_unused struct cmdline *cl,
6212 __rte_unused void *data)
6214 struct cmd_set_bonding_primary_result *res = parsed_result;
6215 portid_t master_port_id = res->port_id;
6216 portid_t slave_port_id = res->slave_id;
6218 /* Set the primary slave for a bonded device. */
6219 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
6220 printf("\t Failed to set primary slave for port = %d.\n",
6227 cmdline_parse_token_string_t cmd_setbonding_primary_set =
6228 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6230 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
6231 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6232 bonding, "bonding");
6233 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
6234 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6235 primary, "primary");
6236 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
6237 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6239 cmdline_parse_token_num_t cmd_setbonding_primary_port =
6240 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6243 cmdline_parse_inst_t cmd_set_bonding_primary = {
6244 .f = cmd_set_bonding_primary_parsed,
6245 .help_str = "set bonding primary <slave_id> <port_id>: "
6246 "Set the primary slave for port_id",
6249 (void *)&cmd_setbonding_primary_set,
6250 (void *)&cmd_setbonding_primary_bonding,
6251 (void *)&cmd_setbonding_primary_primary,
6252 (void *)&cmd_setbonding_primary_slave,
6253 (void *)&cmd_setbonding_primary_port,
6258 /* *** ADD SLAVE *** */
6259 struct cmd_add_bonding_slave_result {
6260 cmdline_fixed_string_t add;
6261 cmdline_fixed_string_t bonding;
6262 cmdline_fixed_string_t slave;
6267 static void cmd_add_bonding_slave_parsed(void *parsed_result,
6268 __rte_unused struct cmdline *cl,
6269 __rte_unused void *data)
6271 struct cmd_add_bonding_slave_result *res = parsed_result;
6272 portid_t master_port_id = res->port_id;
6273 portid_t slave_port_id = res->slave_id;
6275 /* add the slave for a bonded device. */
6276 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
6277 printf("\t Failed to add slave %d to master port = %d.\n",
6278 slave_port_id, master_port_id);
6282 set_port_slave_flag(slave_port_id);
6285 cmdline_parse_token_string_t cmd_addbonding_slave_add =
6286 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6288 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
6289 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6290 bonding, "bonding");
6291 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
6292 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6294 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
6295 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6297 cmdline_parse_token_num_t cmd_addbonding_slave_port =
6298 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6301 cmdline_parse_inst_t cmd_add_bonding_slave = {
6302 .f = cmd_add_bonding_slave_parsed,
6303 .help_str = "add bonding slave <slave_id> <port_id>: "
6304 "Add a slave device to a bonded device",
6307 (void *)&cmd_addbonding_slave_add,
6308 (void *)&cmd_addbonding_slave_bonding,
6309 (void *)&cmd_addbonding_slave_slave,
6310 (void *)&cmd_addbonding_slave_slaveid,
6311 (void *)&cmd_addbonding_slave_port,
6316 /* *** REMOVE SLAVE *** */
6317 struct cmd_remove_bonding_slave_result {
6318 cmdline_fixed_string_t remove;
6319 cmdline_fixed_string_t bonding;
6320 cmdline_fixed_string_t slave;
6325 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
6326 __rte_unused struct cmdline *cl,
6327 __rte_unused void *data)
6329 struct cmd_remove_bonding_slave_result *res = parsed_result;
6330 portid_t master_port_id = res->port_id;
6331 portid_t slave_port_id = res->slave_id;
6333 /* remove the slave from a bonded device. */
6334 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
6335 printf("\t Failed to remove slave %d from master port = %d.\n",
6336 slave_port_id, master_port_id);
6340 clear_port_slave_flag(slave_port_id);
6343 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
6344 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6346 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
6347 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6348 bonding, "bonding");
6349 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
6350 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6352 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
6353 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6355 cmdline_parse_token_num_t cmd_removebonding_slave_port =
6356 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6359 cmdline_parse_inst_t cmd_remove_bonding_slave = {
6360 .f = cmd_remove_bonding_slave_parsed,
6361 .help_str = "remove bonding slave <slave_id> <port_id>: "
6362 "Remove a slave device from a bonded device",
6365 (void *)&cmd_removebonding_slave_remove,
6366 (void *)&cmd_removebonding_slave_bonding,
6367 (void *)&cmd_removebonding_slave_slave,
6368 (void *)&cmd_removebonding_slave_slaveid,
6369 (void *)&cmd_removebonding_slave_port,
6374 /* *** CREATE BONDED DEVICE *** */
6375 struct cmd_create_bonded_device_result {
6376 cmdline_fixed_string_t create;
6377 cmdline_fixed_string_t bonded;
6378 cmdline_fixed_string_t device;
6383 static int bond_dev_num = 0;
6385 static void cmd_create_bonded_device_parsed(void *parsed_result,
6386 __rte_unused struct cmdline *cl,
6387 __rte_unused void *data)
6389 struct cmd_create_bonded_device_result *res = parsed_result;
6390 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
6394 if (test_done == 0) {
6395 printf("Please stop forwarding first\n");
6399 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
6402 /* Create a new bonded device. */
6403 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
6405 printf("\t Failed to create bonded device.\n");
6408 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
6411 /* Update number of ports */
6412 nb_ports = rte_eth_dev_count_avail();
6413 reconfig(port_id, res->socket);
6414 ret = rte_eth_promiscuous_enable(port_id);
6416 printf("Failed to enable promiscuous mode for port %u: %s - ignore\n",
6417 port_id, rte_strerror(-ret));
6419 ports[port_id].need_setup = 0;
6420 ports[port_id].port_status = RTE_PORT_STOPPED;
6425 cmdline_parse_token_string_t cmd_createbonded_device_create =
6426 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6428 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
6429 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6431 cmdline_parse_token_string_t cmd_createbonded_device_device =
6432 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6434 cmdline_parse_token_num_t cmd_createbonded_device_mode =
6435 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6437 cmdline_parse_token_num_t cmd_createbonded_device_socket =
6438 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6441 cmdline_parse_inst_t cmd_create_bonded_device = {
6442 .f = cmd_create_bonded_device_parsed,
6443 .help_str = "create bonded device <mode> <socket>: "
6444 "Create a new bonded device with specific bonding mode and socket",
6447 (void *)&cmd_createbonded_device_create,
6448 (void *)&cmd_createbonded_device_bonded,
6449 (void *)&cmd_createbonded_device_device,
6450 (void *)&cmd_createbonded_device_mode,
6451 (void *)&cmd_createbonded_device_socket,
6456 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
6457 struct cmd_set_bond_mac_addr_result {
6458 cmdline_fixed_string_t set;
6459 cmdline_fixed_string_t bonding;
6460 cmdline_fixed_string_t mac_addr;
6462 struct rte_ether_addr address;
6465 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
6466 __rte_unused struct cmdline *cl,
6467 __rte_unused void *data)
6469 struct cmd_set_bond_mac_addr_result *res = parsed_result;
6472 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
6475 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
6477 /* check the return value and print it if is < 0 */
6479 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6482 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
6483 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
6484 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
6485 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
6487 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
6488 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
6490 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
6491 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
6493 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
6494 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
6496 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
6497 .f = cmd_set_bond_mac_addr_parsed,
6499 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
6501 (void *)&cmd_set_bond_mac_addr_set,
6502 (void *)&cmd_set_bond_mac_addr_bonding,
6503 (void *)&cmd_set_bond_mac_addr_mac,
6504 (void *)&cmd_set_bond_mac_addr_portnum,
6505 (void *)&cmd_set_bond_mac_addr_addr,
6511 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
6512 struct cmd_set_bond_mon_period_result {
6513 cmdline_fixed_string_t set;
6514 cmdline_fixed_string_t bonding;
6515 cmdline_fixed_string_t mon_period;
6520 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
6521 __rte_unused struct cmdline *cl,
6522 __rte_unused void *data)
6524 struct cmd_set_bond_mon_period_result *res = parsed_result;
6527 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
6529 /* check the return value and print it if is < 0 */
6531 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6534 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
6535 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6537 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
6538 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6539 bonding, "bonding");
6540 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
6541 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6542 mon_period, "mon_period");
6543 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
6544 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6546 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
6547 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6550 cmdline_parse_inst_t cmd_set_bond_mon_period = {
6551 .f = cmd_set_bond_mon_period_parsed,
6553 .help_str = "set bonding mon_period <port_id> <period_ms>",
6555 (void *)&cmd_set_bond_mon_period_set,
6556 (void *)&cmd_set_bond_mon_period_bonding,
6557 (void *)&cmd_set_bond_mon_period_mon_period,
6558 (void *)&cmd_set_bond_mon_period_portnum,
6559 (void *)&cmd_set_bond_mon_period_period_ms,
6566 struct cmd_set_bonding_agg_mode_policy_result {
6567 cmdline_fixed_string_t set;
6568 cmdline_fixed_string_t bonding;
6569 cmdline_fixed_string_t agg_mode;
6571 cmdline_fixed_string_t policy;
6576 cmd_set_bonding_agg_mode(void *parsed_result,
6577 __rte_unused struct cmdline *cl,
6578 __rte_unused void *data)
6580 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
6581 uint8_t policy = AGG_BANDWIDTH;
6583 if (!strcmp(res->policy, "bandwidth"))
6584 policy = AGG_BANDWIDTH;
6585 else if (!strcmp(res->policy, "stable"))
6586 policy = AGG_STABLE;
6587 else if (!strcmp(res->policy, "count"))
6590 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
6594 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
6595 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6597 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
6598 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6599 bonding, "bonding");
6601 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
6602 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6603 agg_mode, "agg_mode");
6605 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
6606 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6609 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6610 TOKEN_STRING_INITIALIZER(
6611 struct cmd_set_bonding_balance_xmit_policy_result,
6612 policy, "stable#bandwidth#count");
6614 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6615 .f = cmd_set_bonding_agg_mode,
6617 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6619 (void *)&cmd_set_bonding_agg_mode_set,
6620 (void *)&cmd_set_bonding_agg_mode_bonding,
6621 (void *)&cmd_set_bonding_agg_mode_agg_mode,
6622 (void *)&cmd_set_bonding_agg_mode_portnum,
6623 (void *)&cmd_set_bonding_agg_mode_policy_string,
6629 #endif /* RTE_NET_BOND */
6631 /* *** SET FORWARDING MODE *** */
6632 struct cmd_set_fwd_mode_result {
6633 cmdline_fixed_string_t set;
6634 cmdline_fixed_string_t fwd;
6635 cmdline_fixed_string_t mode;
6638 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6639 __rte_unused struct cmdline *cl,
6640 __rte_unused void *data)
6642 struct cmd_set_fwd_mode_result *res = parsed_result;
6645 set_pkt_forwarding_mode(res->mode);
6648 cmdline_parse_token_string_t cmd_setfwd_set =
6649 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6650 cmdline_parse_token_string_t cmd_setfwd_fwd =
6651 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6652 cmdline_parse_token_string_t cmd_setfwd_mode =
6653 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6654 "" /* defined at init */);
6656 cmdline_parse_inst_t cmd_set_fwd_mode = {
6657 .f = cmd_set_fwd_mode_parsed,
6659 .help_str = NULL, /* defined at init */
6661 (void *)&cmd_setfwd_set,
6662 (void *)&cmd_setfwd_fwd,
6663 (void *)&cmd_setfwd_mode,
6668 static void cmd_set_fwd_mode_init(void)
6671 static char token[128];
6672 static char help[256];
6673 cmdline_parse_token_string_t *token_struct;
6675 modes = list_pkt_forwarding_modes();
6676 snprintf(help, sizeof(help), "set fwd %s: "
6677 "Set packet forwarding mode", modes);
6678 cmd_set_fwd_mode.help_str = help;
6680 /* string token separator is # */
6681 for (c = token; *modes != '\0'; modes++)
6686 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6687 token_struct->string_data.str = token;
6690 /* *** SET RETRY FORWARDING MODE *** */
6691 struct cmd_set_fwd_retry_mode_result {
6692 cmdline_fixed_string_t set;
6693 cmdline_fixed_string_t fwd;
6694 cmdline_fixed_string_t mode;
6695 cmdline_fixed_string_t retry;
6698 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6699 __rte_unused struct cmdline *cl,
6700 __rte_unused void *data)
6702 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6705 set_pkt_forwarding_mode(res->mode);
6708 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6709 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6711 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6712 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6714 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6715 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6717 "" /* defined at init */);
6718 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6719 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6722 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6723 .f = cmd_set_fwd_retry_mode_parsed,
6725 .help_str = NULL, /* defined at init */
6727 (void *)&cmd_setfwd_retry_set,
6728 (void *)&cmd_setfwd_retry_fwd,
6729 (void *)&cmd_setfwd_retry_mode,
6730 (void *)&cmd_setfwd_retry_retry,
6735 static void cmd_set_fwd_retry_mode_init(void)
6738 static char token[128];
6739 static char help[256];
6740 cmdline_parse_token_string_t *token_struct;
6742 modes = list_pkt_forwarding_retry_modes();
6743 snprintf(help, sizeof(help), "set fwd %s retry: "
6744 "Set packet forwarding mode with retry", modes);
6745 cmd_set_fwd_retry_mode.help_str = help;
6747 /* string token separator is # */
6748 for (c = token; *modes != '\0'; modes++)
6753 token_struct = (cmdline_parse_token_string_t *)
6754 cmd_set_fwd_retry_mode.tokens[2];
6755 token_struct->string_data.str = token;
6758 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6759 struct cmd_set_burst_tx_retry_result {
6760 cmdline_fixed_string_t set;
6761 cmdline_fixed_string_t burst;
6762 cmdline_fixed_string_t tx;
6763 cmdline_fixed_string_t delay;
6765 cmdline_fixed_string_t retry;
6769 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6770 __rte_unused struct cmdline *cl,
6771 __rte_unused void *data)
6773 struct cmd_set_burst_tx_retry_result *res = parsed_result;
6775 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6776 && !strcmp(res->tx, "tx")) {
6777 if (!strcmp(res->delay, "delay"))
6778 burst_tx_delay_time = res->time;
6779 if (!strcmp(res->retry, "retry"))
6780 burst_tx_retry_num = res->retry_num;
6785 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6786 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6787 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6788 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6790 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6791 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6792 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6793 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6794 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6795 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
6796 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6797 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6798 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6799 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
6801 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6802 .f = cmd_set_burst_tx_retry_parsed,
6803 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6805 (void *)&cmd_set_burst_tx_retry_set,
6806 (void *)&cmd_set_burst_tx_retry_burst,
6807 (void *)&cmd_set_burst_tx_retry_tx,
6808 (void *)&cmd_set_burst_tx_retry_delay,
6809 (void *)&cmd_set_burst_tx_retry_time,
6810 (void *)&cmd_set_burst_tx_retry_retry,
6811 (void *)&cmd_set_burst_tx_retry_retry_num,
6816 /* *** SET PROMISC MODE *** */
6817 struct cmd_set_promisc_mode_result {
6818 cmdline_fixed_string_t set;
6819 cmdline_fixed_string_t promisc;
6820 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6821 uint16_t port_num; /* valid if "allports" argument == 0 */
6822 cmdline_fixed_string_t mode;
6825 static void cmd_set_promisc_mode_parsed(void *parsed_result,
6826 __rte_unused struct cmdline *cl,
6829 struct cmd_set_promisc_mode_result *res = parsed_result;
6833 if (!strcmp(res->mode, "on"))
6840 RTE_ETH_FOREACH_DEV(i)
6841 eth_set_promisc_mode(i, enable);
6843 eth_set_promisc_mode(res->port_num, enable);
6847 cmdline_parse_token_string_t cmd_setpromisc_set =
6848 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6849 cmdline_parse_token_string_t cmd_setpromisc_promisc =
6850 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6852 cmdline_parse_token_string_t cmd_setpromisc_portall =
6853 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6855 cmdline_parse_token_num_t cmd_setpromisc_portnum =
6856 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6858 cmdline_parse_token_string_t cmd_setpromisc_mode =
6859 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6862 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6863 .f = cmd_set_promisc_mode_parsed,
6865 .help_str = "set promisc all on|off: Set promisc mode for all ports",
6867 (void *)&cmd_setpromisc_set,
6868 (void *)&cmd_setpromisc_promisc,
6869 (void *)&cmd_setpromisc_portall,
6870 (void *)&cmd_setpromisc_mode,
6875 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6876 .f = cmd_set_promisc_mode_parsed,
6878 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6880 (void *)&cmd_setpromisc_set,
6881 (void *)&cmd_setpromisc_promisc,
6882 (void *)&cmd_setpromisc_portnum,
6883 (void *)&cmd_setpromisc_mode,
6888 /* *** SET ALLMULTI MODE *** */
6889 struct cmd_set_allmulti_mode_result {
6890 cmdline_fixed_string_t set;
6891 cmdline_fixed_string_t allmulti;
6892 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6893 uint16_t port_num; /* valid if "allports" argument == 0 */
6894 cmdline_fixed_string_t mode;
6897 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6898 __rte_unused struct cmdline *cl,
6901 struct cmd_set_allmulti_mode_result *res = parsed_result;
6905 if (!strcmp(res->mode, "on"))
6912 RTE_ETH_FOREACH_DEV(i) {
6913 eth_set_allmulticast_mode(i, enable);
6917 eth_set_allmulticast_mode(res->port_num, enable);
6921 cmdline_parse_token_string_t cmd_setallmulti_set =
6922 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6923 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6924 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6926 cmdline_parse_token_string_t cmd_setallmulti_portall =
6927 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6929 cmdline_parse_token_num_t cmd_setallmulti_portnum =
6930 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6932 cmdline_parse_token_string_t cmd_setallmulti_mode =
6933 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6936 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6937 .f = cmd_set_allmulti_mode_parsed,
6939 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6941 (void *)&cmd_setallmulti_set,
6942 (void *)&cmd_setallmulti_allmulti,
6943 (void *)&cmd_setallmulti_portall,
6944 (void *)&cmd_setallmulti_mode,
6949 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6950 .f = cmd_set_allmulti_mode_parsed,
6952 .help_str = "set allmulti <port_id> on|off: "
6953 "Set allmulti mode on port_id",
6955 (void *)&cmd_setallmulti_set,
6956 (void *)&cmd_setallmulti_allmulti,
6957 (void *)&cmd_setallmulti_portnum,
6958 (void *)&cmd_setallmulti_mode,
6963 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
6964 struct cmd_link_flow_ctrl_set_result {
6965 cmdline_fixed_string_t set;
6966 cmdline_fixed_string_t flow_ctrl;
6967 cmdline_fixed_string_t rx;
6968 cmdline_fixed_string_t rx_lfc_mode;
6969 cmdline_fixed_string_t tx;
6970 cmdline_fixed_string_t tx_lfc_mode;
6971 cmdline_fixed_string_t mac_ctrl_frame_fwd;
6972 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
6973 cmdline_fixed_string_t autoneg_str;
6974 cmdline_fixed_string_t autoneg;
6975 cmdline_fixed_string_t hw_str;
6976 uint32_t high_water;
6977 cmdline_fixed_string_t lw_str;
6979 cmdline_fixed_string_t pt_str;
6980 uint16_t pause_time;
6981 cmdline_fixed_string_t xon_str;
6986 cmdline_parse_token_string_t cmd_lfc_set_set =
6987 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6989 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
6990 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6991 flow_ctrl, "flow_ctrl");
6992 cmdline_parse_token_string_t cmd_lfc_set_rx =
6993 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6995 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
6996 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6997 rx_lfc_mode, "on#off");
6998 cmdline_parse_token_string_t cmd_lfc_set_tx =
6999 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7001 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
7002 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7003 tx_lfc_mode, "on#off");
7004 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
7005 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7006 hw_str, "high_water");
7007 cmdline_parse_token_num_t cmd_lfc_set_high_water =
7008 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7009 high_water, UINT32);
7010 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
7011 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7012 lw_str, "low_water");
7013 cmdline_parse_token_num_t cmd_lfc_set_low_water =
7014 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7016 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
7017 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7018 pt_str, "pause_time");
7019 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
7020 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7021 pause_time, UINT16);
7022 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
7023 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7024 xon_str, "send_xon");
7025 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
7026 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7028 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
7029 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7030 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
7031 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
7032 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7033 mac_ctrl_frame_fwd_mode, "on#off");
7034 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
7035 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7036 autoneg_str, "autoneg");
7037 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
7038 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7040 cmdline_parse_token_num_t cmd_lfc_set_portid =
7041 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7044 /* forward declaration */
7046 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
7049 cmdline_parse_inst_t cmd_link_flow_control_set = {
7050 .f = cmd_link_flow_ctrl_set_parsed,
7052 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
7053 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
7054 "autoneg on|off <port_id>: Configure the Ethernet flow control",
7056 (void *)&cmd_lfc_set_set,
7057 (void *)&cmd_lfc_set_flow_ctrl,
7058 (void *)&cmd_lfc_set_rx,
7059 (void *)&cmd_lfc_set_rx_mode,
7060 (void *)&cmd_lfc_set_tx,
7061 (void *)&cmd_lfc_set_tx_mode,
7062 (void *)&cmd_lfc_set_high_water,
7063 (void *)&cmd_lfc_set_low_water,
7064 (void *)&cmd_lfc_set_pause_time,
7065 (void *)&cmd_lfc_set_send_xon,
7066 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
7067 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
7068 (void *)&cmd_lfc_set_autoneg_str,
7069 (void *)&cmd_lfc_set_autoneg,
7070 (void *)&cmd_lfc_set_portid,
7075 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
7076 .f = cmd_link_flow_ctrl_set_parsed,
7077 .data = (void *)&cmd_link_flow_control_set_rx,
7078 .help_str = "set flow_ctrl rx on|off <port_id>: "
7079 "Change rx flow control parameter",
7081 (void *)&cmd_lfc_set_set,
7082 (void *)&cmd_lfc_set_flow_ctrl,
7083 (void *)&cmd_lfc_set_rx,
7084 (void *)&cmd_lfc_set_rx_mode,
7085 (void *)&cmd_lfc_set_portid,
7090 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
7091 .f = cmd_link_flow_ctrl_set_parsed,
7092 .data = (void *)&cmd_link_flow_control_set_tx,
7093 .help_str = "set flow_ctrl tx on|off <port_id>: "
7094 "Change tx flow control parameter",
7096 (void *)&cmd_lfc_set_set,
7097 (void *)&cmd_lfc_set_flow_ctrl,
7098 (void *)&cmd_lfc_set_tx,
7099 (void *)&cmd_lfc_set_tx_mode,
7100 (void *)&cmd_lfc_set_portid,
7105 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
7106 .f = cmd_link_flow_ctrl_set_parsed,
7107 .data = (void *)&cmd_link_flow_control_set_hw,
7108 .help_str = "set flow_ctrl high_water <value> <port_id>: "
7109 "Change high water flow control parameter",
7111 (void *)&cmd_lfc_set_set,
7112 (void *)&cmd_lfc_set_flow_ctrl,
7113 (void *)&cmd_lfc_set_high_water_str,
7114 (void *)&cmd_lfc_set_high_water,
7115 (void *)&cmd_lfc_set_portid,
7120 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
7121 .f = cmd_link_flow_ctrl_set_parsed,
7122 .data = (void *)&cmd_link_flow_control_set_lw,
7123 .help_str = "set flow_ctrl low_water <value> <port_id>: "
7124 "Change low water flow control parameter",
7126 (void *)&cmd_lfc_set_set,
7127 (void *)&cmd_lfc_set_flow_ctrl,
7128 (void *)&cmd_lfc_set_low_water_str,
7129 (void *)&cmd_lfc_set_low_water,
7130 (void *)&cmd_lfc_set_portid,
7135 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
7136 .f = cmd_link_flow_ctrl_set_parsed,
7137 .data = (void *)&cmd_link_flow_control_set_pt,
7138 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
7139 "Change pause time flow control parameter",
7141 (void *)&cmd_lfc_set_set,
7142 (void *)&cmd_lfc_set_flow_ctrl,
7143 (void *)&cmd_lfc_set_pause_time_str,
7144 (void *)&cmd_lfc_set_pause_time,
7145 (void *)&cmd_lfc_set_portid,
7150 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
7151 .f = cmd_link_flow_ctrl_set_parsed,
7152 .data = (void *)&cmd_link_flow_control_set_xon,
7153 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
7154 "Change send_xon flow control parameter",
7156 (void *)&cmd_lfc_set_set,
7157 (void *)&cmd_lfc_set_flow_ctrl,
7158 (void *)&cmd_lfc_set_send_xon_str,
7159 (void *)&cmd_lfc_set_send_xon,
7160 (void *)&cmd_lfc_set_portid,
7165 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
7166 .f = cmd_link_flow_ctrl_set_parsed,
7167 .data = (void *)&cmd_link_flow_control_set_macfwd,
7168 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
7169 "Change mac ctrl fwd flow control parameter",
7171 (void *)&cmd_lfc_set_set,
7172 (void *)&cmd_lfc_set_flow_ctrl,
7173 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
7174 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
7175 (void *)&cmd_lfc_set_portid,
7180 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
7181 .f = cmd_link_flow_ctrl_set_parsed,
7182 .data = (void *)&cmd_link_flow_control_set_autoneg,
7183 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
7184 "Change autoneg flow control parameter",
7186 (void *)&cmd_lfc_set_set,
7187 (void *)&cmd_lfc_set_flow_ctrl,
7188 (void *)&cmd_lfc_set_autoneg_str,
7189 (void *)&cmd_lfc_set_autoneg,
7190 (void *)&cmd_lfc_set_portid,
7196 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
7197 __rte_unused struct cmdline *cl,
7200 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
7201 cmdline_parse_inst_t *cmd = data;
7202 struct rte_eth_fc_conf fc_conf;
7208 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7209 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7210 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7211 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7213 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
7214 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7217 /* Partial command line, retrieve current configuration */
7219 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
7221 printf("cannot get current flow ctrl parameters, return"
7222 "code = %d\n", ret);
7226 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
7227 (fc_conf.mode == RTE_FC_FULL))
7229 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
7230 (fc_conf.mode == RTE_FC_FULL))
7234 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
7235 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
7237 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
7238 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
7240 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
7242 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
7243 fc_conf.high_water = res->high_water;
7245 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
7246 fc_conf.low_water = res->low_water;
7248 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
7249 fc_conf.pause_time = res->pause_time;
7251 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
7252 fc_conf.send_xon = res->send_xon;
7254 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
7255 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
7256 fc_conf.mac_ctrl_frame_fwd = 1;
7258 fc_conf.mac_ctrl_frame_fwd = 0;
7261 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
7262 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
7264 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
7266 printf("bad flow contrl parameter, return code = %d \n", ret);
7269 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
7270 struct cmd_priority_flow_ctrl_set_result {
7271 cmdline_fixed_string_t set;
7272 cmdline_fixed_string_t pfc_ctrl;
7273 cmdline_fixed_string_t rx;
7274 cmdline_fixed_string_t rx_pfc_mode;
7275 cmdline_fixed_string_t tx;
7276 cmdline_fixed_string_t tx_pfc_mode;
7277 uint32_t high_water;
7279 uint16_t pause_time;
7285 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
7286 __rte_unused struct cmdline *cl,
7287 __rte_unused void *data)
7289 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
7290 struct rte_eth_pfc_conf pfc_conf;
7291 int rx_fc_enable, tx_fc_enable;
7295 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7296 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7297 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7298 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7300 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
7301 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7304 memset(&pfc_conf, 0, sizeof(struct rte_eth_pfc_conf));
7305 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
7306 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
7307 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
7308 pfc_conf.fc.high_water = res->high_water;
7309 pfc_conf.fc.low_water = res->low_water;
7310 pfc_conf.fc.pause_time = res->pause_time;
7311 pfc_conf.priority = res->priority;
7313 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
7315 printf("bad priority flow contrl parameter, return code = %d \n", ret);
7318 cmdline_parse_token_string_t cmd_pfc_set_set =
7319 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7321 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
7322 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7323 pfc_ctrl, "pfc_ctrl");
7324 cmdline_parse_token_string_t cmd_pfc_set_rx =
7325 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7327 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
7328 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7329 rx_pfc_mode, "on#off");
7330 cmdline_parse_token_string_t cmd_pfc_set_tx =
7331 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7333 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
7334 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7335 tx_pfc_mode, "on#off");
7336 cmdline_parse_token_num_t cmd_pfc_set_high_water =
7337 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7338 high_water, UINT32);
7339 cmdline_parse_token_num_t cmd_pfc_set_low_water =
7340 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7342 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
7343 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7344 pause_time, UINT16);
7345 cmdline_parse_token_num_t cmd_pfc_set_priority =
7346 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7348 cmdline_parse_token_num_t cmd_pfc_set_portid =
7349 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7352 cmdline_parse_inst_t cmd_priority_flow_control_set = {
7353 .f = cmd_priority_flow_ctrl_set_parsed,
7355 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
7356 "<pause_time> <priority> <port_id>: "
7357 "Configure the Ethernet priority flow control",
7359 (void *)&cmd_pfc_set_set,
7360 (void *)&cmd_pfc_set_flow_ctrl,
7361 (void *)&cmd_pfc_set_rx,
7362 (void *)&cmd_pfc_set_rx_mode,
7363 (void *)&cmd_pfc_set_tx,
7364 (void *)&cmd_pfc_set_tx_mode,
7365 (void *)&cmd_pfc_set_high_water,
7366 (void *)&cmd_pfc_set_low_water,
7367 (void *)&cmd_pfc_set_pause_time,
7368 (void *)&cmd_pfc_set_priority,
7369 (void *)&cmd_pfc_set_portid,
7374 /* *** RESET CONFIGURATION *** */
7375 struct cmd_reset_result {
7376 cmdline_fixed_string_t reset;
7377 cmdline_fixed_string_t def;
7380 static void cmd_reset_parsed(__rte_unused void *parsed_result,
7382 __rte_unused void *data)
7384 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
7385 set_def_fwd_config();
7388 cmdline_parse_token_string_t cmd_reset_set =
7389 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
7390 cmdline_parse_token_string_t cmd_reset_def =
7391 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
7394 cmdline_parse_inst_t cmd_reset = {
7395 .f = cmd_reset_parsed,
7397 .help_str = "set default: Reset default forwarding configuration",
7399 (void *)&cmd_reset_set,
7400 (void *)&cmd_reset_def,
7405 /* *** START FORWARDING *** */
7406 struct cmd_start_result {
7407 cmdline_fixed_string_t start;
7410 cmdline_parse_token_string_t cmd_start_start =
7411 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
7413 static void cmd_start_parsed(__rte_unused void *parsed_result,
7414 __rte_unused struct cmdline *cl,
7415 __rte_unused void *data)
7417 start_packet_forwarding(0);
7420 cmdline_parse_inst_t cmd_start = {
7421 .f = cmd_start_parsed,
7423 .help_str = "start: Start packet forwarding",
7425 (void *)&cmd_start_start,
7430 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7431 struct cmd_start_tx_first_result {
7432 cmdline_fixed_string_t start;
7433 cmdline_fixed_string_t tx_first;
7437 cmd_start_tx_first_parsed(__rte_unused void *parsed_result,
7438 __rte_unused struct cmdline *cl,
7439 __rte_unused void *data)
7441 start_packet_forwarding(1);
7444 cmdline_parse_token_string_t cmd_start_tx_first_start =
7445 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7447 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7448 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7449 tx_first, "tx_first");
7451 cmdline_parse_inst_t cmd_start_tx_first = {
7452 .f = cmd_start_tx_first_parsed,
7454 .help_str = "start tx_first: Start packet forwarding, "
7455 "after sending 1 burst of packets",
7457 (void *)&cmd_start_tx_first_start,
7458 (void *)&cmd_start_tx_first_tx_first,
7463 /* *** START FORWARDING WITH N TX BURST FIRST *** */
7464 struct cmd_start_tx_first_n_result {
7465 cmdline_fixed_string_t start;
7466 cmdline_fixed_string_t tx_first;
7471 cmd_start_tx_first_n_parsed(void *parsed_result,
7472 __rte_unused struct cmdline *cl,
7473 __rte_unused void *data)
7475 struct cmd_start_tx_first_n_result *res = parsed_result;
7477 start_packet_forwarding(res->tx_num);
7480 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7481 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7483 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7484 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7485 tx_first, "tx_first");
7486 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7487 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7490 cmdline_parse_inst_t cmd_start_tx_first_n = {
7491 .f = cmd_start_tx_first_n_parsed,
7493 .help_str = "start tx_first <num>: "
7494 "packet forwarding, after sending <num> bursts of packets",
7496 (void *)&cmd_start_tx_first_n_start,
7497 (void *)&cmd_start_tx_first_n_tx_first,
7498 (void *)&cmd_start_tx_first_n_tx_num,
7503 /* *** SET LINK UP *** */
7504 struct cmd_set_link_up_result {
7505 cmdline_fixed_string_t set;
7506 cmdline_fixed_string_t link_up;
7507 cmdline_fixed_string_t port;
7511 cmdline_parse_token_string_t cmd_set_link_up_set =
7512 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7513 cmdline_parse_token_string_t cmd_set_link_up_link_up =
7514 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7516 cmdline_parse_token_string_t cmd_set_link_up_port =
7517 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7518 cmdline_parse_token_num_t cmd_set_link_up_port_id =
7519 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16);
7521 static void cmd_set_link_up_parsed(__rte_unused void *parsed_result,
7522 __rte_unused struct cmdline *cl,
7523 __rte_unused void *data)
7525 struct cmd_set_link_up_result *res = parsed_result;
7526 dev_set_link_up(res->port_id);
7529 cmdline_parse_inst_t cmd_set_link_up = {
7530 .f = cmd_set_link_up_parsed,
7532 .help_str = "set link-up port <port id>",
7534 (void *)&cmd_set_link_up_set,
7535 (void *)&cmd_set_link_up_link_up,
7536 (void *)&cmd_set_link_up_port,
7537 (void *)&cmd_set_link_up_port_id,
7542 /* *** SET LINK DOWN *** */
7543 struct cmd_set_link_down_result {
7544 cmdline_fixed_string_t set;
7545 cmdline_fixed_string_t link_down;
7546 cmdline_fixed_string_t port;
7550 cmdline_parse_token_string_t cmd_set_link_down_set =
7551 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
7552 cmdline_parse_token_string_t cmd_set_link_down_link_down =
7553 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
7555 cmdline_parse_token_string_t cmd_set_link_down_port =
7556 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
7557 cmdline_parse_token_num_t cmd_set_link_down_port_id =
7558 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16);
7560 static void cmd_set_link_down_parsed(
7561 __rte_unused void *parsed_result,
7562 __rte_unused struct cmdline *cl,
7563 __rte_unused void *data)
7565 struct cmd_set_link_down_result *res = parsed_result;
7566 dev_set_link_down(res->port_id);
7569 cmdline_parse_inst_t cmd_set_link_down = {
7570 .f = cmd_set_link_down_parsed,
7572 .help_str = "set link-down port <port id>",
7574 (void *)&cmd_set_link_down_set,
7575 (void *)&cmd_set_link_down_link_down,
7576 (void *)&cmd_set_link_down_port,
7577 (void *)&cmd_set_link_down_port_id,
7582 /* *** SHOW CFG *** */
7583 struct cmd_showcfg_result {
7584 cmdline_fixed_string_t show;
7585 cmdline_fixed_string_t cfg;
7586 cmdline_fixed_string_t what;
7589 static void cmd_showcfg_parsed(void *parsed_result,
7590 __rte_unused struct cmdline *cl,
7591 __rte_unused void *data)
7593 struct cmd_showcfg_result *res = parsed_result;
7594 if (!strcmp(res->what, "rxtx"))
7595 rxtx_config_display();
7596 else if (!strcmp(res->what, "cores"))
7597 fwd_lcores_config_display();
7598 else if (!strcmp(res->what, "fwd"))
7599 pkt_fwd_config_display(&cur_fwd_config);
7600 else if (!strcmp(res->what, "rxoffs"))
7601 show_rx_pkt_offsets();
7602 else if (!strcmp(res->what, "rxpkts"))
7603 show_rx_pkt_segments();
7604 else if (!strcmp(res->what, "txpkts"))
7605 show_tx_pkt_segments();
7606 else if (!strcmp(res->what, "txtimes"))
7607 show_tx_pkt_times();
7610 cmdline_parse_token_string_t cmd_showcfg_show =
7611 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7612 cmdline_parse_token_string_t cmd_showcfg_port =
7613 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7614 cmdline_parse_token_string_t cmd_showcfg_what =
7615 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7616 "rxtx#cores#fwd#rxoffs#rxpkts#txpkts#txtimes");
7618 cmdline_parse_inst_t cmd_showcfg = {
7619 .f = cmd_showcfg_parsed,
7621 .help_str = "show config rxtx|cores|fwd|rxoffs|rxpkts|txpkts|txtimes",
7623 (void *)&cmd_showcfg_show,
7624 (void *)&cmd_showcfg_port,
7625 (void *)&cmd_showcfg_what,
7630 /* *** SHOW ALL PORT INFO *** */
7631 struct cmd_showportall_result {
7632 cmdline_fixed_string_t show;
7633 cmdline_fixed_string_t port;
7634 cmdline_fixed_string_t what;
7635 cmdline_fixed_string_t all;
7638 static void cmd_showportall_parsed(void *parsed_result,
7639 __rte_unused struct cmdline *cl,
7640 __rte_unused void *data)
7644 struct cmd_showportall_result *res = parsed_result;
7645 if (!strcmp(res->show, "clear")) {
7646 if (!strcmp(res->what, "stats"))
7647 RTE_ETH_FOREACH_DEV(i)
7649 else if (!strcmp(res->what, "xstats"))
7650 RTE_ETH_FOREACH_DEV(i)
7651 nic_xstats_clear(i);
7652 } else if (!strcmp(res->what, "info"))
7653 RTE_ETH_FOREACH_DEV(i)
7654 port_infos_display(i);
7655 else if (!strcmp(res->what, "summary")) {
7656 port_summary_header_display();
7657 RTE_ETH_FOREACH_DEV(i)
7658 port_summary_display(i);
7660 else if (!strcmp(res->what, "stats"))
7661 RTE_ETH_FOREACH_DEV(i)
7662 nic_stats_display(i);
7663 else if (!strcmp(res->what, "xstats"))
7664 RTE_ETH_FOREACH_DEV(i)
7665 nic_xstats_display(i);
7666 else if (!strcmp(res->what, "fdir"))
7667 RTE_ETH_FOREACH_DEV(i)
7669 else if (!strcmp(res->what, "stat_qmap"))
7670 RTE_ETH_FOREACH_DEV(i)
7671 nic_stats_mapping_display(i);
7672 else if (!strcmp(res->what, "dcb_tc"))
7673 RTE_ETH_FOREACH_DEV(i)
7674 port_dcb_info_display(i);
7675 else if (!strcmp(res->what, "cap"))
7676 RTE_ETH_FOREACH_DEV(i)
7677 port_offload_cap_display(i);
7680 cmdline_parse_token_string_t cmd_showportall_show =
7681 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7683 cmdline_parse_token_string_t cmd_showportall_port =
7684 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7685 cmdline_parse_token_string_t cmd_showportall_what =
7686 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7687 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7688 cmdline_parse_token_string_t cmd_showportall_all =
7689 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7690 cmdline_parse_inst_t cmd_showportall = {
7691 .f = cmd_showportall_parsed,
7693 .help_str = "show|clear port "
7694 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
7696 (void *)&cmd_showportall_show,
7697 (void *)&cmd_showportall_port,
7698 (void *)&cmd_showportall_what,
7699 (void *)&cmd_showportall_all,
7704 /* *** SHOW PORT INFO *** */
7705 struct cmd_showport_result {
7706 cmdline_fixed_string_t show;
7707 cmdline_fixed_string_t port;
7708 cmdline_fixed_string_t what;
7712 static void cmd_showport_parsed(void *parsed_result,
7713 __rte_unused struct cmdline *cl,
7714 __rte_unused void *data)
7716 struct cmd_showport_result *res = parsed_result;
7717 if (!strcmp(res->show, "clear")) {
7718 if (!strcmp(res->what, "stats"))
7719 nic_stats_clear(res->portnum);
7720 else if (!strcmp(res->what, "xstats"))
7721 nic_xstats_clear(res->portnum);
7722 } else if (!strcmp(res->what, "info"))
7723 port_infos_display(res->portnum);
7724 else if (!strcmp(res->what, "summary")) {
7725 port_summary_header_display();
7726 port_summary_display(res->portnum);
7728 else if (!strcmp(res->what, "stats"))
7729 nic_stats_display(res->portnum);
7730 else if (!strcmp(res->what, "xstats"))
7731 nic_xstats_display(res->portnum);
7732 else if (!strcmp(res->what, "fdir"))
7733 fdir_get_infos(res->portnum);
7734 else if (!strcmp(res->what, "stat_qmap"))
7735 nic_stats_mapping_display(res->portnum);
7736 else if (!strcmp(res->what, "dcb_tc"))
7737 port_dcb_info_display(res->portnum);
7738 else if (!strcmp(res->what, "cap"))
7739 port_offload_cap_display(res->portnum);
7742 cmdline_parse_token_string_t cmd_showport_show =
7743 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7745 cmdline_parse_token_string_t cmd_showport_port =
7746 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7747 cmdline_parse_token_string_t cmd_showport_what =
7748 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7749 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7750 cmdline_parse_token_num_t cmd_showport_portnum =
7751 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
7753 cmdline_parse_inst_t cmd_showport = {
7754 .f = cmd_showport_parsed,
7756 .help_str = "show|clear port "
7757 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
7760 (void *)&cmd_showport_show,
7761 (void *)&cmd_showport_port,
7762 (void *)&cmd_showport_what,
7763 (void *)&cmd_showport_portnum,
7768 /* *** SHOW DEVICE INFO *** */
7769 struct cmd_showdevice_result {
7770 cmdline_fixed_string_t show;
7771 cmdline_fixed_string_t device;
7772 cmdline_fixed_string_t what;
7773 cmdline_fixed_string_t identifier;
7776 static void cmd_showdevice_parsed(void *parsed_result,
7777 __rte_unused struct cmdline *cl,
7778 __rte_unused void *data)
7780 struct cmd_showdevice_result *res = parsed_result;
7781 if (!strcmp(res->what, "info")) {
7782 if (!strcmp(res->identifier, "all"))
7783 device_infos_display(NULL);
7785 device_infos_display(res->identifier);
7789 cmdline_parse_token_string_t cmd_showdevice_show =
7790 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show,
7792 cmdline_parse_token_string_t cmd_showdevice_device =
7793 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device");
7794 cmdline_parse_token_string_t cmd_showdevice_what =
7795 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what,
7797 cmdline_parse_token_string_t cmd_showdevice_identifier =
7798 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result,
7801 cmdline_parse_inst_t cmd_showdevice = {
7802 .f = cmd_showdevice_parsed,
7804 .help_str = "show device info <identifier>|all",
7806 (void *)&cmd_showdevice_show,
7807 (void *)&cmd_showdevice_device,
7808 (void *)&cmd_showdevice_what,
7809 (void *)&cmd_showdevice_identifier,
7814 /* *** SHOW MODULE EEPROM/EEPROM port INFO *** */
7815 struct cmd_showeeprom_result {
7816 cmdline_fixed_string_t show;
7817 cmdline_fixed_string_t port;
7819 cmdline_fixed_string_t type;
7822 static void cmd_showeeprom_parsed(void *parsed_result,
7823 __rte_unused struct cmdline *cl,
7824 __rte_unused void *data)
7826 struct cmd_showeeprom_result *res = parsed_result;
7828 if (!strcmp(res->type, "eeprom"))
7829 port_eeprom_display(res->portnum);
7830 else if (!strcmp(res->type, "module_eeprom"))
7831 port_module_eeprom_display(res->portnum);
7833 printf("Unknown argument\n");
7836 cmdline_parse_token_string_t cmd_showeeprom_show =
7837 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, show, "show");
7838 cmdline_parse_token_string_t cmd_showeeprom_port =
7839 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, port, "port");
7840 cmdline_parse_token_num_t cmd_showeeprom_portnum =
7841 TOKEN_NUM_INITIALIZER(struct cmd_showeeprom_result, portnum, UINT16);
7842 cmdline_parse_token_string_t cmd_showeeprom_type =
7843 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, type, "module_eeprom#eeprom");
7845 cmdline_parse_inst_t cmd_showeeprom = {
7846 .f = cmd_showeeprom_parsed,
7848 .help_str = "show port <port_id> module_eeprom|eeprom",
7850 (void *)&cmd_showeeprom_show,
7851 (void *)&cmd_showeeprom_port,
7852 (void *)&cmd_showeeprom_portnum,
7853 (void *)&cmd_showeeprom_type,
7858 /* *** SHOW QUEUE INFO *** */
7859 struct cmd_showqueue_result {
7860 cmdline_fixed_string_t show;
7861 cmdline_fixed_string_t type;
7862 cmdline_fixed_string_t what;
7868 cmd_showqueue_parsed(void *parsed_result,
7869 __rte_unused struct cmdline *cl,
7870 __rte_unused void *data)
7872 struct cmd_showqueue_result *res = parsed_result;
7874 if (!strcmp(res->type, "rxq"))
7875 rx_queue_infos_display(res->portnum, res->queuenum);
7876 else if (!strcmp(res->type, "txq"))
7877 tx_queue_infos_display(res->portnum, res->queuenum);
7880 cmdline_parse_token_string_t cmd_showqueue_show =
7881 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
7882 cmdline_parse_token_string_t cmd_showqueue_type =
7883 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
7884 cmdline_parse_token_string_t cmd_showqueue_what =
7885 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
7886 cmdline_parse_token_num_t cmd_showqueue_portnum =
7887 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16);
7888 cmdline_parse_token_num_t cmd_showqueue_queuenum =
7889 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
7891 cmdline_parse_inst_t cmd_showqueue = {
7892 .f = cmd_showqueue_parsed,
7894 .help_str = "show rxq|txq info <port_id> <queue_id>",
7896 (void *)&cmd_showqueue_show,
7897 (void *)&cmd_showqueue_type,
7898 (void *)&cmd_showqueue_what,
7899 (void *)&cmd_showqueue_portnum,
7900 (void *)&cmd_showqueue_queuenum,
7905 /* show/clear fwd engine statistics */
7907 cmdline_fixed_string_t action;
7908 cmdline_fixed_string_t fwd;
7909 cmdline_fixed_string_t stats;
7910 cmdline_fixed_string_t all;
7913 cmdline_parse_token_string_t cmd_fwd_action =
7914 TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
7915 cmdline_parse_token_string_t cmd_fwd_fwd =
7916 TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
7917 cmdline_parse_token_string_t cmd_fwd_stats =
7918 TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
7919 cmdline_parse_token_string_t cmd_fwd_all =
7920 TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
7923 cmd_showfwdall_parsed(void *parsed_result,
7924 __rte_unused struct cmdline *cl,
7925 __rte_unused void *data)
7927 struct fwd_result *res = parsed_result;
7929 if (!strcmp(res->action, "show"))
7930 fwd_stats_display();
7935 static cmdline_parse_inst_t cmd_showfwdall = {
7936 .f = cmd_showfwdall_parsed,
7938 .help_str = "show|clear fwd stats all",
7940 (void *)&cmd_fwd_action,
7941 (void *)&cmd_fwd_fwd,
7942 (void *)&cmd_fwd_stats,
7943 (void *)&cmd_fwd_all,
7948 /* *** READ PORT REGISTER *** */
7949 struct cmd_read_reg_result {
7950 cmdline_fixed_string_t read;
7951 cmdline_fixed_string_t reg;
7957 cmd_read_reg_parsed(void *parsed_result,
7958 __rte_unused struct cmdline *cl,
7959 __rte_unused void *data)
7961 struct cmd_read_reg_result *res = parsed_result;
7962 port_reg_display(res->port_id, res->reg_off);
7965 cmdline_parse_token_string_t cmd_read_reg_read =
7966 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
7967 cmdline_parse_token_string_t cmd_read_reg_reg =
7968 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
7969 cmdline_parse_token_num_t cmd_read_reg_port_id =
7970 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16);
7971 cmdline_parse_token_num_t cmd_read_reg_reg_off =
7972 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
7974 cmdline_parse_inst_t cmd_read_reg = {
7975 .f = cmd_read_reg_parsed,
7977 .help_str = "read reg <port_id> <reg_off>",
7979 (void *)&cmd_read_reg_read,
7980 (void *)&cmd_read_reg_reg,
7981 (void *)&cmd_read_reg_port_id,
7982 (void *)&cmd_read_reg_reg_off,
7987 /* *** READ PORT REGISTER BIT FIELD *** */
7988 struct cmd_read_reg_bit_field_result {
7989 cmdline_fixed_string_t read;
7990 cmdline_fixed_string_t regfield;
7998 cmd_read_reg_bit_field_parsed(void *parsed_result,
7999 __rte_unused struct cmdline *cl,
8000 __rte_unused void *data)
8002 struct cmd_read_reg_bit_field_result *res = parsed_result;
8003 port_reg_bit_field_display(res->port_id, res->reg_off,
8004 res->bit1_pos, res->bit2_pos);
8007 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
8008 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
8010 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
8011 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
8012 regfield, "regfield");
8013 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
8014 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
8016 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
8017 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
8019 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
8020 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
8022 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
8023 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
8026 cmdline_parse_inst_t cmd_read_reg_bit_field = {
8027 .f = cmd_read_reg_bit_field_parsed,
8029 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
8030 "Read register bit field between bit_x and bit_y included",
8032 (void *)&cmd_read_reg_bit_field_read,
8033 (void *)&cmd_read_reg_bit_field_regfield,
8034 (void *)&cmd_read_reg_bit_field_port_id,
8035 (void *)&cmd_read_reg_bit_field_reg_off,
8036 (void *)&cmd_read_reg_bit_field_bit1_pos,
8037 (void *)&cmd_read_reg_bit_field_bit2_pos,
8042 /* *** READ PORT REGISTER BIT *** */
8043 struct cmd_read_reg_bit_result {
8044 cmdline_fixed_string_t read;
8045 cmdline_fixed_string_t regbit;
8052 cmd_read_reg_bit_parsed(void *parsed_result,
8053 __rte_unused struct cmdline *cl,
8054 __rte_unused void *data)
8056 struct cmd_read_reg_bit_result *res = parsed_result;
8057 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
8060 cmdline_parse_token_string_t cmd_read_reg_bit_read =
8061 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
8062 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
8063 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
8065 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
8066 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16);
8067 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
8068 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
8069 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
8070 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
8072 cmdline_parse_inst_t cmd_read_reg_bit = {
8073 .f = cmd_read_reg_bit_parsed,
8075 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
8077 (void *)&cmd_read_reg_bit_read,
8078 (void *)&cmd_read_reg_bit_regbit,
8079 (void *)&cmd_read_reg_bit_port_id,
8080 (void *)&cmd_read_reg_bit_reg_off,
8081 (void *)&cmd_read_reg_bit_bit_pos,
8086 /* *** WRITE PORT REGISTER *** */
8087 struct cmd_write_reg_result {
8088 cmdline_fixed_string_t write;
8089 cmdline_fixed_string_t reg;
8096 cmd_write_reg_parsed(void *parsed_result,
8097 __rte_unused struct cmdline *cl,
8098 __rte_unused void *data)
8100 struct cmd_write_reg_result *res = parsed_result;
8101 port_reg_set(res->port_id, res->reg_off, res->value);
8104 cmdline_parse_token_string_t cmd_write_reg_write =
8105 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
8106 cmdline_parse_token_string_t cmd_write_reg_reg =
8107 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
8108 cmdline_parse_token_num_t cmd_write_reg_port_id =
8109 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16);
8110 cmdline_parse_token_num_t cmd_write_reg_reg_off =
8111 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
8112 cmdline_parse_token_num_t cmd_write_reg_value =
8113 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
8115 cmdline_parse_inst_t cmd_write_reg = {
8116 .f = cmd_write_reg_parsed,
8118 .help_str = "write reg <port_id> <reg_off> <reg_value>",
8120 (void *)&cmd_write_reg_write,
8121 (void *)&cmd_write_reg_reg,
8122 (void *)&cmd_write_reg_port_id,
8123 (void *)&cmd_write_reg_reg_off,
8124 (void *)&cmd_write_reg_value,
8129 /* *** WRITE PORT REGISTER BIT FIELD *** */
8130 struct cmd_write_reg_bit_field_result {
8131 cmdline_fixed_string_t write;
8132 cmdline_fixed_string_t regfield;
8141 cmd_write_reg_bit_field_parsed(void *parsed_result,
8142 __rte_unused struct cmdline *cl,
8143 __rte_unused void *data)
8145 struct cmd_write_reg_bit_field_result *res = parsed_result;
8146 port_reg_bit_field_set(res->port_id, res->reg_off,
8147 res->bit1_pos, res->bit2_pos, res->value);
8150 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
8151 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
8153 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
8154 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
8155 regfield, "regfield");
8156 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
8157 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
8159 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
8160 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
8162 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
8163 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
8165 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
8166 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
8168 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
8169 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
8172 cmdline_parse_inst_t cmd_write_reg_bit_field = {
8173 .f = cmd_write_reg_bit_field_parsed,
8175 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
8177 "Set register bit field between bit_x and bit_y included",
8179 (void *)&cmd_write_reg_bit_field_write,
8180 (void *)&cmd_write_reg_bit_field_regfield,
8181 (void *)&cmd_write_reg_bit_field_port_id,
8182 (void *)&cmd_write_reg_bit_field_reg_off,
8183 (void *)&cmd_write_reg_bit_field_bit1_pos,
8184 (void *)&cmd_write_reg_bit_field_bit2_pos,
8185 (void *)&cmd_write_reg_bit_field_value,
8190 /* *** WRITE PORT REGISTER BIT *** */
8191 struct cmd_write_reg_bit_result {
8192 cmdline_fixed_string_t write;
8193 cmdline_fixed_string_t regbit;
8201 cmd_write_reg_bit_parsed(void *parsed_result,
8202 __rte_unused struct cmdline *cl,
8203 __rte_unused void *data)
8205 struct cmd_write_reg_bit_result *res = parsed_result;
8206 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
8209 cmdline_parse_token_string_t cmd_write_reg_bit_write =
8210 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
8212 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
8213 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
8215 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
8216 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16);
8217 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
8218 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
8219 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
8220 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
8221 cmdline_parse_token_num_t cmd_write_reg_bit_value =
8222 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
8224 cmdline_parse_inst_t cmd_write_reg_bit = {
8225 .f = cmd_write_reg_bit_parsed,
8227 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
8230 (void *)&cmd_write_reg_bit_write,
8231 (void *)&cmd_write_reg_bit_regbit,
8232 (void *)&cmd_write_reg_bit_port_id,
8233 (void *)&cmd_write_reg_bit_reg_off,
8234 (void *)&cmd_write_reg_bit_bit_pos,
8235 (void *)&cmd_write_reg_bit_value,
8240 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
8241 struct cmd_read_rxd_txd_result {
8242 cmdline_fixed_string_t read;
8243 cmdline_fixed_string_t rxd_txd;
8250 cmd_read_rxd_txd_parsed(void *parsed_result,
8251 __rte_unused struct cmdline *cl,
8252 __rte_unused void *data)
8254 struct cmd_read_rxd_txd_result *res = parsed_result;
8256 if (!strcmp(res->rxd_txd, "rxd"))
8257 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8258 else if (!strcmp(res->rxd_txd, "txd"))
8259 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8262 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
8263 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
8264 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
8265 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
8267 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
8268 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16);
8269 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
8270 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
8271 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
8272 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
8274 cmdline_parse_inst_t cmd_read_rxd_txd = {
8275 .f = cmd_read_rxd_txd_parsed,
8277 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
8279 (void *)&cmd_read_rxd_txd_read,
8280 (void *)&cmd_read_rxd_txd_rxd_txd,
8281 (void *)&cmd_read_rxd_txd_port_id,
8282 (void *)&cmd_read_rxd_txd_queue_id,
8283 (void *)&cmd_read_rxd_txd_desc_id,
8289 struct cmd_quit_result {
8290 cmdline_fixed_string_t quit;
8293 static void cmd_quit_parsed(__rte_unused void *parsed_result,
8295 __rte_unused void *data)
8300 cmdline_parse_token_string_t cmd_quit_quit =
8301 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
8303 cmdline_parse_inst_t cmd_quit = {
8304 .f = cmd_quit_parsed,
8306 .help_str = "quit: Exit application",
8308 (void *)&cmd_quit_quit,
8313 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
8314 struct cmd_mac_addr_result {
8315 cmdline_fixed_string_t mac_addr_cmd;
8316 cmdline_fixed_string_t what;
8318 struct rte_ether_addr address;
8321 static void cmd_mac_addr_parsed(void *parsed_result,
8322 __rte_unused struct cmdline *cl,
8323 __rte_unused void *data)
8325 struct cmd_mac_addr_result *res = parsed_result;
8328 if (strcmp(res->what, "add") == 0)
8329 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
8330 else if (strcmp(res->what, "set") == 0)
8331 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
8334 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
8336 /* check the return value and print it if is < 0 */
8338 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
8342 cmdline_parse_token_string_t cmd_mac_addr_cmd =
8343 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
8345 cmdline_parse_token_string_t cmd_mac_addr_what =
8346 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
8348 cmdline_parse_token_num_t cmd_mac_addr_portnum =
8349 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
8351 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
8352 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
8354 cmdline_parse_inst_t cmd_mac_addr = {
8355 .f = cmd_mac_addr_parsed,
8357 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
8358 "Add/Remove/Set MAC address on port_id",
8360 (void *)&cmd_mac_addr_cmd,
8361 (void *)&cmd_mac_addr_what,
8362 (void *)&cmd_mac_addr_portnum,
8363 (void *)&cmd_mac_addr_addr,
8368 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
8369 struct cmd_eth_peer_result {
8370 cmdline_fixed_string_t set;
8371 cmdline_fixed_string_t eth_peer;
8373 cmdline_fixed_string_t peer_addr;
8376 static void cmd_set_eth_peer_parsed(void *parsed_result,
8377 __rte_unused struct cmdline *cl,
8378 __rte_unused void *data)
8380 struct cmd_eth_peer_result *res = parsed_result;
8382 if (test_done == 0) {
8383 printf("Please stop forwarding first\n");
8386 if (!strcmp(res->eth_peer, "eth-peer")) {
8387 set_fwd_eth_peer(res->port_id, res->peer_addr);
8391 cmdline_parse_token_string_t cmd_eth_peer_set =
8392 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
8393 cmdline_parse_token_string_t cmd_eth_peer =
8394 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
8395 cmdline_parse_token_num_t cmd_eth_peer_port_id =
8396 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, UINT16);
8397 cmdline_parse_token_string_t cmd_eth_peer_addr =
8398 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
8400 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
8401 .f = cmd_set_eth_peer_parsed,
8403 .help_str = "set eth-peer <port_id> <peer_mac>",
8405 (void *)&cmd_eth_peer_set,
8406 (void *)&cmd_eth_peer,
8407 (void *)&cmd_eth_peer_port_id,
8408 (void *)&cmd_eth_peer_addr,
8413 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
8414 struct cmd_set_qmap_result {
8415 cmdline_fixed_string_t set;
8416 cmdline_fixed_string_t qmap;
8417 cmdline_fixed_string_t what;
8424 cmd_set_qmap_parsed(void *parsed_result,
8425 __rte_unused struct cmdline *cl,
8426 __rte_unused void *data)
8428 struct cmd_set_qmap_result *res = parsed_result;
8429 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
8431 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
8434 cmdline_parse_token_string_t cmd_setqmap_set =
8435 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8437 cmdline_parse_token_string_t cmd_setqmap_qmap =
8438 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8440 cmdline_parse_token_string_t cmd_setqmap_what =
8441 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8443 cmdline_parse_token_num_t cmd_setqmap_portid =
8444 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8446 cmdline_parse_token_num_t cmd_setqmap_queueid =
8447 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8449 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
8450 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8453 cmdline_parse_inst_t cmd_set_qmap = {
8454 .f = cmd_set_qmap_parsed,
8456 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
8457 "Set statistics mapping value on tx|rx queue_id of port_id",
8459 (void *)&cmd_setqmap_set,
8460 (void *)&cmd_setqmap_qmap,
8461 (void *)&cmd_setqmap_what,
8462 (void *)&cmd_setqmap_portid,
8463 (void *)&cmd_setqmap_queueid,
8464 (void *)&cmd_setqmap_mapvalue,
8469 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
8470 struct cmd_set_xstats_hide_zero_result {
8471 cmdline_fixed_string_t keyword;
8472 cmdline_fixed_string_t name;
8473 cmdline_fixed_string_t on_off;
8477 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
8478 __rte_unused struct cmdline *cl,
8479 __rte_unused void *data)
8481 struct cmd_set_xstats_hide_zero_result *res;
8482 uint16_t on_off = 0;
8484 res = parsed_result;
8485 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8486 set_xstats_hide_zero(on_off);
8489 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
8490 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8492 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
8493 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8494 name, "xstats-hide-zero");
8495 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
8496 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8499 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
8500 .f = cmd_set_xstats_hide_zero_parsed,
8502 .help_str = "set xstats-hide-zero on|off",
8504 (void *)&cmd_set_xstats_hide_zero_keyword,
8505 (void *)&cmd_set_xstats_hide_zero_name,
8506 (void *)&cmd_set_xstats_hide_zero_on_off,
8511 /* *** SET OPTION TO ENABLE MEASUREMENT OF CPU CYCLES *** */
8512 struct cmd_set_record_core_cycles_result {
8513 cmdline_fixed_string_t keyword;
8514 cmdline_fixed_string_t name;
8515 cmdline_fixed_string_t on_off;
8519 cmd_set_record_core_cycles_parsed(void *parsed_result,
8520 __rte_unused struct cmdline *cl,
8521 __rte_unused void *data)
8523 struct cmd_set_record_core_cycles_result *res;
8524 uint16_t on_off = 0;
8526 res = parsed_result;
8527 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8528 set_record_core_cycles(on_off);
8531 cmdline_parse_token_string_t cmd_set_record_core_cycles_keyword =
8532 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8534 cmdline_parse_token_string_t cmd_set_record_core_cycles_name =
8535 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8536 name, "record-core-cycles");
8537 cmdline_parse_token_string_t cmd_set_record_core_cycles_on_off =
8538 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8541 cmdline_parse_inst_t cmd_set_record_core_cycles = {
8542 .f = cmd_set_record_core_cycles_parsed,
8544 .help_str = "set record-core-cycles on|off",
8546 (void *)&cmd_set_record_core_cycles_keyword,
8547 (void *)&cmd_set_record_core_cycles_name,
8548 (void *)&cmd_set_record_core_cycles_on_off,
8553 /* *** SET OPTION TO ENABLE DISPLAY OF RX AND TX BURSTS *** */
8554 struct cmd_set_record_burst_stats_result {
8555 cmdline_fixed_string_t keyword;
8556 cmdline_fixed_string_t name;
8557 cmdline_fixed_string_t on_off;
8561 cmd_set_record_burst_stats_parsed(void *parsed_result,
8562 __rte_unused struct cmdline *cl,
8563 __rte_unused void *data)
8565 struct cmd_set_record_burst_stats_result *res;
8566 uint16_t on_off = 0;
8568 res = parsed_result;
8569 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8570 set_record_burst_stats(on_off);
8573 cmdline_parse_token_string_t cmd_set_record_burst_stats_keyword =
8574 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8576 cmdline_parse_token_string_t cmd_set_record_burst_stats_name =
8577 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8578 name, "record-burst-stats");
8579 cmdline_parse_token_string_t cmd_set_record_burst_stats_on_off =
8580 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8583 cmdline_parse_inst_t cmd_set_record_burst_stats = {
8584 .f = cmd_set_record_burst_stats_parsed,
8586 .help_str = "set record-burst-stats on|off",
8588 (void *)&cmd_set_record_burst_stats_keyword,
8589 (void *)&cmd_set_record_burst_stats_name,
8590 (void *)&cmd_set_record_burst_stats_on_off,
8595 /* *** CONFIGURE UNICAST HASH TABLE *** */
8596 struct cmd_set_uc_hash_table {
8597 cmdline_fixed_string_t set;
8598 cmdline_fixed_string_t port;
8600 cmdline_fixed_string_t what;
8601 struct rte_ether_addr address;
8602 cmdline_fixed_string_t mode;
8606 cmd_set_uc_hash_parsed(void *parsed_result,
8607 __rte_unused struct cmdline *cl,
8608 __rte_unused void *data)
8611 struct cmd_set_uc_hash_table *res = parsed_result;
8613 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8615 if (strcmp(res->what, "uta") == 0)
8616 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
8617 &res->address,(uint8_t)is_on);
8619 printf("bad unicast hash table parameter, return code = %d \n", ret);
8623 cmdline_parse_token_string_t cmd_set_uc_hash_set =
8624 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8626 cmdline_parse_token_string_t cmd_set_uc_hash_port =
8627 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8629 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
8630 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
8632 cmdline_parse_token_string_t cmd_set_uc_hash_what =
8633 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8635 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
8636 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
8638 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
8639 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8642 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
8643 .f = cmd_set_uc_hash_parsed,
8645 .help_str = "set port <port_id> uta <mac_addr> on|off)",
8647 (void *)&cmd_set_uc_hash_set,
8648 (void *)&cmd_set_uc_hash_port,
8649 (void *)&cmd_set_uc_hash_portid,
8650 (void *)&cmd_set_uc_hash_what,
8651 (void *)&cmd_set_uc_hash_mac,
8652 (void *)&cmd_set_uc_hash_mode,
8657 struct cmd_set_uc_all_hash_table {
8658 cmdline_fixed_string_t set;
8659 cmdline_fixed_string_t port;
8661 cmdline_fixed_string_t what;
8662 cmdline_fixed_string_t value;
8663 cmdline_fixed_string_t mode;
8667 cmd_set_uc_all_hash_parsed(void *parsed_result,
8668 __rte_unused struct cmdline *cl,
8669 __rte_unused void *data)
8672 struct cmd_set_uc_all_hash_table *res = parsed_result;
8674 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8676 if ((strcmp(res->what, "uta") == 0) &&
8677 (strcmp(res->value, "all") == 0))
8678 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
8680 printf("bad unicast hash table parameter,"
8681 "return code = %d \n", ret);
8684 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
8685 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8687 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
8688 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8690 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
8691 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
8693 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
8694 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8696 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
8697 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8699 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
8700 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8703 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
8704 .f = cmd_set_uc_all_hash_parsed,
8706 .help_str = "set port <port_id> uta all on|off",
8708 (void *)&cmd_set_uc_all_hash_set,
8709 (void *)&cmd_set_uc_all_hash_port,
8710 (void *)&cmd_set_uc_all_hash_portid,
8711 (void *)&cmd_set_uc_all_hash_what,
8712 (void *)&cmd_set_uc_all_hash_value,
8713 (void *)&cmd_set_uc_all_hash_mode,
8718 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
8719 struct cmd_set_vf_traffic {
8720 cmdline_fixed_string_t set;
8721 cmdline_fixed_string_t port;
8723 cmdline_fixed_string_t vf;
8725 cmdline_fixed_string_t what;
8726 cmdline_fixed_string_t mode;
8730 cmd_set_vf_traffic_parsed(void *parsed_result,
8731 __rte_unused struct cmdline *cl,
8732 __rte_unused void *data)
8734 struct cmd_set_vf_traffic *res = parsed_result;
8735 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
8736 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8738 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
8741 cmdline_parse_token_string_t cmd_setvf_traffic_set =
8742 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8744 cmdline_parse_token_string_t cmd_setvf_traffic_port =
8745 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8747 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8748 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8750 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8751 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8753 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8754 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8756 cmdline_parse_token_string_t cmd_setvf_traffic_what =
8757 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8759 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8760 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8763 cmdline_parse_inst_t cmd_set_vf_traffic = {
8764 .f = cmd_set_vf_traffic_parsed,
8766 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8768 (void *)&cmd_setvf_traffic_set,
8769 (void *)&cmd_setvf_traffic_port,
8770 (void *)&cmd_setvf_traffic_portid,
8771 (void *)&cmd_setvf_traffic_vf,
8772 (void *)&cmd_setvf_traffic_vfid,
8773 (void *)&cmd_setvf_traffic_what,
8774 (void *)&cmd_setvf_traffic_mode,
8779 /* *** CONFIGURE VF RECEIVE MODE *** */
8780 struct cmd_set_vf_rxmode {
8781 cmdline_fixed_string_t set;
8782 cmdline_fixed_string_t port;
8784 cmdline_fixed_string_t vf;
8786 cmdline_fixed_string_t what;
8787 cmdline_fixed_string_t mode;
8788 cmdline_fixed_string_t on;
8792 cmd_set_vf_rxmode_parsed(void *parsed_result,
8793 __rte_unused struct cmdline *cl,
8794 __rte_unused void *data)
8797 uint16_t vf_rxmode = 0;
8798 struct cmd_set_vf_rxmode *res = parsed_result;
8800 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8801 if (!strcmp(res->what,"rxmode")) {
8802 if (!strcmp(res->mode, "AUPE"))
8803 vf_rxmode |= ETH_VMDQ_ACCEPT_UNTAG;
8804 else if (!strcmp(res->mode, "ROPE"))
8805 vf_rxmode |= ETH_VMDQ_ACCEPT_HASH_UC;
8806 else if (!strcmp(res->mode, "BAM"))
8807 vf_rxmode |= ETH_VMDQ_ACCEPT_BROADCAST;
8808 else if (!strncmp(res->mode, "MPE",3))
8809 vf_rxmode |= ETH_VMDQ_ACCEPT_MULTICAST;
8812 RTE_SET_USED(is_on);
8814 #ifdef RTE_NET_IXGBE
8815 if (ret == -ENOTSUP)
8816 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8817 vf_rxmode, (uint8_t)is_on);
8820 if (ret == -ENOTSUP)
8821 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8822 vf_rxmode, (uint8_t)is_on);
8825 printf("bad VF receive mode parameter, return code = %d \n",
8829 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8830 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8832 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8833 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8835 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8836 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8838 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8839 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8841 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8842 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8844 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
8845 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8847 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
8848 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8849 mode, "AUPE#ROPE#BAM#MPE");
8850 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
8851 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8854 cmdline_parse_inst_t cmd_set_vf_rxmode = {
8855 .f = cmd_set_vf_rxmode_parsed,
8857 .help_str = "set port <port_id> vf <vf_id> rxmode "
8858 "AUPE|ROPE|BAM|MPE on|off",
8860 (void *)&cmd_set_vf_rxmode_set,
8861 (void *)&cmd_set_vf_rxmode_port,
8862 (void *)&cmd_set_vf_rxmode_portid,
8863 (void *)&cmd_set_vf_rxmode_vf,
8864 (void *)&cmd_set_vf_rxmode_vfid,
8865 (void *)&cmd_set_vf_rxmode_what,
8866 (void *)&cmd_set_vf_rxmode_mode,
8867 (void *)&cmd_set_vf_rxmode_on,
8872 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
8873 struct cmd_vf_mac_addr_result {
8874 cmdline_fixed_string_t mac_addr_cmd;
8875 cmdline_fixed_string_t what;
8876 cmdline_fixed_string_t port;
8878 cmdline_fixed_string_t vf;
8880 struct rte_ether_addr address;
8883 static void cmd_vf_mac_addr_parsed(void *parsed_result,
8884 __rte_unused struct cmdline *cl,
8885 __rte_unused void *data)
8887 struct cmd_vf_mac_addr_result *res = parsed_result;
8890 if (strcmp(res->what, "add") != 0)
8894 if (ret == -ENOTSUP)
8895 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
8899 if (ret == -ENOTSUP)
8900 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
8905 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
8909 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
8910 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8911 mac_addr_cmd,"mac_addr");
8912 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
8913 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8915 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
8916 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8918 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
8919 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8921 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
8922 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8924 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
8925 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8927 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
8928 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
8931 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
8932 .f = cmd_vf_mac_addr_parsed,
8934 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
8935 "Add MAC address filtering for a VF on port_id",
8937 (void *)&cmd_vf_mac_addr_cmd,
8938 (void *)&cmd_vf_mac_addr_what,
8939 (void *)&cmd_vf_mac_addr_port,
8940 (void *)&cmd_vf_mac_addr_portnum,
8941 (void *)&cmd_vf_mac_addr_vf,
8942 (void *)&cmd_vf_mac_addr_vfnum,
8943 (void *)&cmd_vf_mac_addr_addr,
8948 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
8949 struct cmd_vf_rx_vlan_filter {
8950 cmdline_fixed_string_t rx_vlan;
8951 cmdline_fixed_string_t what;
8953 cmdline_fixed_string_t port;
8955 cmdline_fixed_string_t vf;
8960 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
8961 __rte_unused struct cmdline *cl,
8962 __rte_unused void *data)
8964 struct cmd_vf_rx_vlan_filter *res = parsed_result;
8967 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
8969 #ifdef RTE_NET_IXGBE
8970 if (ret == -ENOTSUP)
8971 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
8972 res->vlan_id, res->vf_mask, is_add);
8975 if (ret == -ENOTSUP)
8976 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
8977 res->vlan_id, res->vf_mask, is_add);
8980 if (ret == -ENOTSUP)
8981 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
8982 res->vlan_id, res->vf_mask, is_add);
8989 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
8990 res->vlan_id, res->vf_mask);
8993 printf("invalid port_id %d\n", res->port_id);
8996 printf("function not implemented or supported\n");
8999 printf("programming error: (%s)\n", strerror(-ret));
9003 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
9004 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9005 rx_vlan, "rx_vlan");
9006 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
9007 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9009 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
9010 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9012 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
9013 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9015 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
9016 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9018 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
9019 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9021 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
9022 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9025 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
9026 .f = cmd_vf_rx_vlan_filter_parsed,
9028 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
9029 "(vf_mask = hexadecimal VF mask)",
9031 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
9032 (void *)&cmd_vf_rx_vlan_filter_what,
9033 (void *)&cmd_vf_rx_vlan_filter_vlanid,
9034 (void *)&cmd_vf_rx_vlan_filter_port,
9035 (void *)&cmd_vf_rx_vlan_filter_portid,
9036 (void *)&cmd_vf_rx_vlan_filter_vf,
9037 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
9042 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
9043 struct cmd_queue_rate_limit_result {
9044 cmdline_fixed_string_t set;
9045 cmdline_fixed_string_t port;
9047 cmdline_fixed_string_t queue;
9049 cmdline_fixed_string_t rate;
9053 static void cmd_queue_rate_limit_parsed(void *parsed_result,
9054 __rte_unused struct cmdline *cl,
9055 __rte_unused void *data)
9057 struct cmd_queue_rate_limit_result *res = parsed_result;
9060 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9061 && (strcmp(res->queue, "queue") == 0)
9062 && (strcmp(res->rate, "rate") == 0))
9063 ret = set_queue_rate_limit(res->port_num, res->queue_num,
9066 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
9070 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
9071 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9073 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
9074 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9076 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
9077 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9079 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
9080 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9082 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
9083 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9085 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
9086 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9088 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
9089 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9092 cmdline_parse_inst_t cmd_queue_rate_limit = {
9093 .f = cmd_queue_rate_limit_parsed,
9095 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
9096 "Set rate limit for a queue on port_id",
9098 (void *)&cmd_queue_rate_limit_set,
9099 (void *)&cmd_queue_rate_limit_port,
9100 (void *)&cmd_queue_rate_limit_portnum,
9101 (void *)&cmd_queue_rate_limit_queue,
9102 (void *)&cmd_queue_rate_limit_queuenum,
9103 (void *)&cmd_queue_rate_limit_rate,
9104 (void *)&cmd_queue_rate_limit_ratenum,
9109 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
9110 struct cmd_vf_rate_limit_result {
9111 cmdline_fixed_string_t set;
9112 cmdline_fixed_string_t port;
9114 cmdline_fixed_string_t vf;
9116 cmdline_fixed_string_t rate;
9118 cmdline_fixed_string_t q_msk;
9122 static void cmd_vf_rate_limit_parsed(void *parsed_result,
9123 __rte_unused struct cmdline *cl,
9124 __rte_unused void *data)
9126 struct cmd_vf_rate_limit_result *res = parsed_result;
9129 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9130 && (strcmp(res->vf, "vf") == 0)
9131 && (strcmp(res->rate, "rate") == 0)
9132 && (strcmp(res->q_msk, "queue_mask") == 0))
9133 ret = set_vf_rate_limit(res->port_num, res->vf_num,
9134 res->rate_num, res->q_msk_val);
9136 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
9140 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
9141 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9143 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
9144 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9146 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
9147 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9149 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
9150 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9152 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
9153 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9155 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
9156 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9158 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
9159 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9161 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
9162 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9163 q_msk, "queue_mask");
9164 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
9165 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9168 cmdline_parse_inst_t cmd_vf_rate_limit = {
9169 .f = cmd_vf_rate_limit_parsed,
9171 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
9172 "queue_mask <queue_mask_value>: "
9173 "Set rate limit for queues of VF on port_id",
9175 (void *)&cmd_vf_rate_limit_set,
9176 (void *)&cmd_vf_rate_limit_port,
9177 (void *)&cmd_vf_rate_limit_portnum,
9178 (void *)&cmd_vf_rate_limit_vf,
9179 (void *)&cmd_vf_rate_limit_vfnum,
9180 (void *)&cmd_vf_rate_limit_rate,
9181 (void *)&cmd_vf_rate_limit_ratenum,
9182 (void *)&cmd_vf_rate_limit_q_msk,
9183 (void *)&cmd_vf_rate_limit_q_msk_val,
9188 /* *** CONFIGURE TUNNEL UDP PORT *** */
9189 struct cmd_tunnel_udp_config {
9190 cmdline_fixed_string_t cmd;
9191 cmdline_fixed_string_t what;
9197 cmd_tunnel_udp_config_parsed(void *parsed_result,
9198 __rte_unused struct cmdline *cl,
9199 __rte_unused void *data)
9201 struct cmd_tunnel_udp_config *res = parsed_result;
9202 struct rte_eth_udp_tunnel tunnel_udp;
9205 tunnel_udp.udp_port = res->udp_port;
9207 if (!strcmp(res->cmd, "rx_vxlan_port"))
9208 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9210 if (!strcmp(res->what, "add"))
9211 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9214 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9218 printf("udp tunneling add error: (%s)\n", strerror(-ret));
9221 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
9222 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9223 cmd, "rx_vxlan_port");
9224 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
9225 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9227 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
9228 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9230 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
9231 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9234 cmdline_parse_inst_t cmd_tunnel_udp_config = {
9235 .f = cmd_tunnel_udp_config_parsed,
9237 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
9238 "Add/Remove a tunneling UDP port filter",
9240 (void *)&cmd_tunnel_udp_config_cmd,
9241 (void *)&cmd_tunnel_udp_config_what,
9242 (void *)&cmd_tunnel_udp_config_udp_port,
9243 (void *)&cmd_tunnel_udp_config_port_id,
9248 struct cmd_config_tunnel_udp_port {
9249 cmdline_fixed_string_t port;
9250 cmdline_fixed_string_t config;
9252 cmdline_fixed_string_t udp_tunnel_port;
9253 cmdline_fixed_string_t action;
9254 cmdline_fixed_string_t tunnel_type;
9259 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
9260 __rte_unused struct cmdline *cl,
9261 __rte_unused void *data)
9263 struct cmd_config_tunnel_udp_port *res = parsed_result;
9264 struct rte_eth_udp_tunnel tunnel_udp;
9267 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9270 tunnel_udp.udp_port = res->udp_port;
9272 if (!strcmp(res->tunnel_type, "vxlan")) {
9273 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9274 } else if (!strcmp(res->tunnel_type, "geneve")) {
9275 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE;
9276 } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
9277 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9279 printf("Invalid tunnel type\n");
9283 if (!strcmp(res->action, "add"))
9284 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9287 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9291 printf("udp tunneling port add error: (%s)\n", strerror(-ret));
9294 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
9295 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
9297 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
9298 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
9300 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
9301 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
9303 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
9304 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
9307 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
9308 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
9310 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
9311 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
9312 "vxlan#geneve#vxlan-gpe");
9313 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
9314 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
9317 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
9318 .f = cmd_cfg_tunnel_udp_port_parsed,
9320 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|geneve|vxlan-gpe <udp_port>",
9322 (void *)&cmd_config_tunnel_udp_port_port,
9323 (void *)&cmd_config_tunnel_udp_port_config,
9324 (void *)&cmd_config_tunnel_udp_port_port_id,
9325 (void *)&cmd_config_tunnel_udp_port_tunnel_port,
9326 (void *)&cmd_config_tunnel_udp_port_action,
9327 (void *)&cmd_config_tunnel_udp_port_tunnel_type,
9328 (void *)&cmd_config_tunnel_udp_port_value,
9333 /* *** GLOBAL CONFIG *** */
9334 struct cmd_global_config_result {
9335 cmdline_fixed_string_t cmd;
9337 cmdline_fixed_string_t cfg_type;
9342 cmd_global_config_parsed(void *parsed_result,
9343 __rte_unused struct cmdline *cl,
9344 __rte_unused void *data)
9346 struct cmd_global_config_result *res = parsed_result;
9347 struct rte_eth_global_cfg conf;
9350 memset(&conf, 0, sizeof(conf));
9351 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
9352 conf.cfg.gre_key_len = res->len;
9353 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
9354 RTE_ETH_FILTER_SET, &conf);
9356 if (ret == -ENOTSUP)
9357 ret = rte_pmd_i40e_set_gre_key_len(res->port_id, res->len);
9360 printf("Global config error\n");
9363 cmdline_parse_token_string_t cmd_global_config_cmd =
9364 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
9366 cmdline_parse_token_num_t cmd_global_config_port_id =
9367 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id,
9369 cmdline_parse_token_string_t cmd_global_config_type =
9370 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
9371 cfg_type, "gre-key-len");
9372 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
9373 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
9376 cmdline_parse_inst_t cmd_global_config = {
9377 .f = cmd_global_config_parsed,
9378 .data = (void *)NULL,
9379 .help_str = "global_config <port_id> gre-key-len <key_len>",
9381 (void *)&cmd_global_config_cmd,
9382 (void *)&cmd_global_config_port_id,
9383 (void *)&cmd_global_config_type,
9384 (void *)&cmd_global_config_gre_key_len,
9389 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
9390 struct cmd_set_mirror_mask_result {
9391 cmdline_fixed_string_t set;
9392 cmdline_fixed_string_t port;
9394 cmdline_fixed_string_t mirror;
9396 cmdline_fixed_string_t what;
9397 cmdline_fixed_string_t value;
9398 cmdline_fixed_string_t dstpool;
9400 cmdline_fixed_string_t on;
9403 cmdline_parse_token_string_t cmd_mirror_mask_set =
9404 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9406 cmdline_parse_token_string_t cmd_mirror_mask_port =
9407 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9409 cmdline_parse_token_num_t cmd_mirror_mask_portid =
9410 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9412 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
9413 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9414 mirror, "mirror-rule");
9415 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
9416 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9418 cmdline_parse_token_string_t cmd_mirror_mask_what =
9419 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9420 what, "pool-mirror-up#pool-mirror-down"
9422 cmdline_parse_token_string_t cmd_mirror_mask_value =
9423 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9425 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
9426 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9427 dstpool, "dst-pool");
9428 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
9429 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9431 cmdline_parse_token_string_t cmd_mirror_mask_on =
9432 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9436 cmd_set_mirror_mask_parsed(void *parsed_result,
9437 __rte_unused struct cmdline *cl,
9438 __rte_unused void *data)
9441 struct cmd_set_mirror_mask_result *res = parsed_result;
9442 struct rte_eth_mirror_conf mr_conf;
9444 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9446 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
9448 mr_conf.dst_pool = res->dstpool_id;
9450 if (!strcmp(res->what, "pool-mirror-up")) {
9451 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9452 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
9453 } else if (!strcmp(res->what, "pool-mirror-down")) {
9454 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9455 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
9456 } else if (!strcmp(res->what, "vlan-mirror")) {
9457 mr_conf.rule_type = ETH_MIRROR_VLAN;
9458 nb_item = parse_item_list(res->value, "vlan",
9459 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
9463 for (i = 0; i < nb_item; i++) {
9464 if (vlan_list[i] > RTE_ETHER_MAX_VLAN_ID) {
9465 printf("Invalid vlan_id: must be < 4096\n");
9469 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
9470 mr_conf.vlan.vlan_mask |= 1ULL << i;
9474 if (!strcmp(res->on, "on"))
9475 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9478 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9481 printf("mirror rule add error: (%s)\n", strerror(-ret));
9484 cmdline_parse_inst_t cmd_set_mirror_mask = {
9485 .f = cmd_set_mirror_mask_parsed,
9487 .help_str = "set port <port_id> mirror-rule <rule_id> "
9488 "pool-mirror-up|pool-mirror-down|vlan-mirror "
9489 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
9491 (void *)&cmd_mirror_mask_set,
9492 (void *)&cmd_mirror_mask_port,
9493 (void *)&cmd_mirror_mask_portid,
9494 (void *)&cmd_mirror_mask_mirror,
9495 (void *)&cmd_mirror_mask_ruleid,
9496 (void *)&cmd_mirror_mask_what,
9497 (void *)&cmd_mirror_mask_value,
9498 (void *)&cmd_mirror_mask_dstpool,
9499 (void *)&cmd_mirror_mask_poolid,
9500 (void *)&cmd_mirror_mask_on,
9505 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
9506 struct cmd_set_mirror_link_result {
9507 cmdline_fixed_string_t set;
9508 cmdline_fixed_string_t port;
9510 cmdline_fixed_string_t mirror;
9512 cmdline_fixed_string_t what;
9513 cmdline_fixed_string_t dstpool;
9515 cmdline_fixed_string_t on;
9518 cmdline_parse_token_string_t cmd_mirror_link_set =
9519 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9521 cmdline_parse_token_string_t cmd_mirror_link_port =
9522 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9524 cmdline_parse_token_num_t cmd_mirror_link_portid =
9525 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9527 cmdline_parse_token_string_t cmd_mirror_link_mirror =
9528 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9529 mirror, "mirror-rule");
9530 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
9531 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9533 cmdline_parse_token_string_t cmd_mirror_link_what =
9534 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9535 what, "uplink-mirror#downlink-mirror");
9536 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
9537 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9538 dstpool, "dst-pool");
9539 cmdline_parse_token_num_t cmd_mirror_link_poolid =
9540 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9542 cmdline_parse_token_string_t cmd_mirror_link_on =
9543 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9547 cmd_set_mirror_link_parsed(void *parsed_result,
9548 __rte_unused struct cmdline *cl,
9549 __rte_unused void *data)
9552 struct cmd_set_mirror_link_result *res = parsed_result;
9553 struct rte_eth_mirror_conf mr_conf;
9555 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9556 if (!strcmp(res->what, "uplink-mirror"))
9557 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
9559 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
9561 mr_conf.dst_pool = res->dstpool_id;
9563 if (!strcmp(res->on, "on"))
9564 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9567 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9570 /* check the return value and print it if is < 0 */
9572 printf("mirror rule add error: (%s)\n", strerror(-ret));
9576 cmdline_parse_inst_t cmd_set_mirror_link = {
9577 .f = cmd_set_mirror_link_parsed,
9579 .help_str = "set port <port_id> mirror-rule <rule_id> "
9580 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
9582 (void *)&cmd_mirror_link_set,
9583 (void *)&cmd_mirror_link_port,
9584 (void *)&cmd_mirror_link_portid,
9585 (void *)&cmd_mirror_link_mirror,
9586 (void *)&cmd_mirror_link_ruleid,
9587 (void *)&cmd_mirror_link_what,
9588 (void *)&cmd_mirror_link_dstpool,
9589 (void *)&cmd_mirror_link_poolid,
9590 (void *)&cmd_mirror_link_on,
9595 /* *** RESET VM MIRROR RULE *** */
9596 struct cmd_rm_mirror_rule_result {
9597 cmdline_fixed_string_t reset;
9598 cmdline_fixed_string_t port;
9600 cmdline_fixed_string_t mirror;
9604 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
9605 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9607 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
9608 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9610 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
9611 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9613 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
9614 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9615 mirror, "mirror-rule");
9616 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
9617 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9621 cmd_reset_mirror_rule_parsed(void *parsed_result,
9622 __rte_unused struct cmdline *cl,
9623 __rte_unused void *data)
9626 struct cmd_set_mirror_link_result *res = parsed_result;
9628 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
9630 printf("mirror rule remove error: (%s)\n", strerror(-ret));
9633 cmdline_parse_inst_t cmd_reset_mirror_rule = {
9634 .f = cmd_reset_mirror_rule_parsed,
9636 .help_str = "reset port <port_id> mirror-rule <rule_id>",
9638 (void *)&cmd_rm_mirror_rule_reset,
9639 (void *)&cmd_rm_mirror_rule_port,
9640 (void *)&cmd_rm_mirror_rule_portid,
9641 (void *)&cmd_rm_mirror_rule_mirror,
9642 (void *)&cmd_rm_mirror_rule_ruleid,
9647 /* ******************************************************************************** */
9649 struct cmd_dump_result {
9650 cmdline_fixed_string_t dump;
9654 dump_struct_sizes(void)
9656 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9657 DUMP_SIZE(struct rte_mbuf);
9658 DUMP_SIZE(struct rte_mempool);
9659 DUMP_SIZE(struct rte_ring);
9664 /* Dump the socket memory statistics on console */
9666 dump_socket_mem(FILE *f)
9668 struct rte_malloc_socket_stats socket_stats;
9673 unsigned int n_alloc = 0;
9674 unsigned int n_free = 0;
9675 static size_t last_allocs;
9676 static size_t last_total;
9679 for (i = 0; i < RTE_MAX_NUMA_NODES; i++) {
9680 if (rte_malloc_get_socket_stats(i, &socket_stats) ||
9681 !socket_stats.heap_totalsz_bytes)
9683 total += socket_stats.heap_totalsz_bytes;
9684 alloc += socket_stats.heap_allocsz_bytes;
9685 free += socket_stats.heap_freesz_bytes;
9686 n_alloc += socket_stats.alloc_count;
9687 n_free += socket_stats.free_count;
9689 "Socket %u: size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9691 (double)socket_stats.heap_totalsz_bytes / (1024 * 1024),
9692 (double)socket_stats.heap_allocsz_bytes / (1024 * 1024),
9693 (double)socket_stats.heap_allocsz_bytes * 100 /
9694 (double)socket_stats.heap_totalsz_bytes,
9695 (double)socket_stats.heap_freesz_bytes / (1024 * 1024),
9696 socket_stats.alloc_count,
9697 socket_stats.free_count);
9700 "Total : size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9701 (double)total / (1024 * 1024), (double)alloc / (1024 * 1024),
9702 (double)alloc * 100 / (double)total,
9703 (double)free / (1024 * 1024),
9706 fprintf(stdout, "Memory total change: %.6lf(M), allocation change: %.6lf(M)\n",
9707 ((double)total - (double)last_total) / (1024 * 1024),
9708 (double)(alloc - (double)last_allocs) / 1024 / 1024);
9709 last_allocs = alloc;
9713 static void cmd_dump_parsed(void *parsed_result,
9714 __rte_unused struct cmdline *cl,
9715 __rte_unused void *data)
9717 struct cmd_dump_result *res = parsed_result;
9719 if (!strcmp(res->dump, "dump_physmem"))
9720 rte_dump_physmem_layout(stdout);
9721 else if (!strcmp(res->dump, "dump_socket_mem"))
9722 dump_socket_mem(stdout);
9723 else if (!strcmp(res->dump, "dump_memzone"))
9724 rte_memzone_dump(stdout);
9725 else if (!strcmp(res->dump, "dump_struct_sizes"))
9726 dump_struct_sizes();
9727 else if (!strcmp(res->dump, "dump_ring"))
9728 rte_ring_list_dump(stdout);
9729 else if (!strcmp(res->dump, "dump_mempool"))
9730 rte_mempool_list_dump(stdout);
9731 else if (!strcmp(res->dump, "dump_devargs"))
9732 rte_devargs_dump(stdout);
9733 else if (!strcmp(res->dump, "dump_log_types"))
9734 rte_log_dump(stdout);
9737 cmdline_parse_token_string_t cmd_dump_dump =
9738 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9742 "dump_struct_sizes#"
9748 cmdline_parse_inst_t cmd_dump = {
9749 .f = cmd_dump_parsed, /* function to call */
9750 .data = NULL, /* 2nd arg of func */
9751 .help_str = "Dump status",
9752 .tokens = { /* token list, NULL terminated */
9753 (void *)&cmd_dump_dump,
9758 /* ******************************************************************************** */
9760 struct cmd_dump_one_result {
9761 cmdline_fixed_string_t dump;
9762 cmdline_fixed_string_t name;
9765 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9766 __rte_unused void *data)
9768 struct cmd_dump_one_result *res = parsed_result;
9770 if (!strcmp(res->dump, "dump_ring")) {
9772 r = rte_ring_lookup(res->name);
9774 cmdline_printf(cl, "Cannot find ring\n");
9777 rte_ring_dump(stdout, r);
9778 } else if (!strcmp(res->dump, "dump_mempool")) {
9779 struct rte_mempool *mp;
9780 mp = rte_mempool_lookup(res->name);
9782 cmdline_printf(cl, "Cannot find mempool\n");
9785 rte_mempool_dump(stdout, mp);
9789 cmdline_parse_token_string_t cmd_dump_one_dump =
9790 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9791 "dump_ring#dump_mempool");
9793 cmdline_parse_token_string_t cmd_dump_one_name =
9794 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9796 cmdline_parse_inst_t cmd_dump_one = {
9797 .f = cmd_dump_one_parsed, /* function to call */
9798 .data = NULL, /* 2nd arg of func */
9799 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9800 .tokens = { /* token list, NULL terminated */
9801 (void *)&cmd_dump_one_dump,
9802 (void *)&cmd_dump_one_name,
9807 /* *** queue region set *** */
9808 struct cmd_queue_region_result {
9809 cmdline_fixed_string_t set;
9810 cmdline_fixed_string_t port;
9812 cmdline_fixed_string_t cmd;
9813 cmdline_fixed_string_t region;
9815 cmdline_fixed_string_t queue_start_index;
9817 cmdline_fixed_string_t queue_num;
9818 uint8_t queue_num_value;
9822 cmd_queue_region_parsed(void *parsed_result,
9823 __rte_unused struct cmdline *cl,
9824 __rte_unused void *data)
9826 struct cmd_queue_region_result *res = parsed_result;
9829 struct rte_pmd_i40e_queue_region_conf region_conf;
9830 enum rte_pmd_i40e_queue_region_op op_type;
9833 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9837 memset(®ion_conf, 0, sizeof(region_conf));
9838 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
9839 region_conf.region_id = res->region_id;
9840 region_conf.queue_num = res->queue_num_value;
9841 region_conf.queue_start_index = res->queue_id;
9843 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9844 op_type, ®ion_conf);
9851 printf("function not implemented or supported\n");
9854 printf("queue region config error: (%s)\n", strerror(-ret));
9858 cmdline_parse_token_string_t cmd_queue_region_set =
9859 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9861 cmdline_parse_token_string_t cmd_queue_region_port =
9862 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
9863 cmdline_parse_token_num_t cmd_queue_region_port_id =
9864 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9866 cmdline_parse_token_string_t cmd_queue_region_cmd =
9867 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9868 cmd, "queue-region");
9869 cmdline_parse_token_string_t cmd_queue_region_id =
9870 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9871 region, "region_id");
9872 cmdline_parse_token_num_t cmd_queue_region_index =
9873 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9875 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
9876 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9877 queue_start_index, "queue_start_index");
9878 cmdline_parse_token_num_t cmd_queue_region_queue_id =
9879 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9881 cmdline_parse_token_string_t cmd_queue_region_queue_num =
9882 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9883 queue_num, "queue_num");
9884 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
9885 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9886 queue_num_value, UINT8);
9888 cmdline_parse_inst_t cmd_queue_region = {
9889 .f = cmd_queue_region_parsed,
9891 .help_str = "set port <port_id> queue-region region_id <value> "
9892 "queue_start_index <value> queue_num <value>: Set a queue region",
9894 (void *)&cmd_queue_region_set,
9895 (void *)&cmd_queue_region_port,
9896 (void *)&cmd_queue_region_port_id,
9897 (void *)&cmd_queue_region_cmd,
9898 (void *)&cmd_queue_region_id,
9899 (void *)&cmd_queue_region_index,
9900 (void *)&cmd_queue_region_queue_start_index,
9901 (void *)&cmd_queue_region_queue_id,
9902 (void *)&cmd_queue_region_queue_num,
9903 (void *)&cmd_queue_region_queue_num_value,
9908 /* *** queue region and flowtype set *** */
9909 struct cmd_region_flowtype_result {
9910 cmdline_fixed_string_t set;
9911 cmdline_fixed_string_t port;
9913 cmdline_fixed_string_t cmd;
9914 cmdline_fixed_string_t region;
9916 cmdline_fixed_string_t flowtype;
9917 uint8_t flowtype_id;
9921 cmd_region_flowtype_parsed(void *parsed_result,
9922 __rte_unused struct cmdline *cl,
9923 __rte_unused void *data)
9925 struct cmd_region_flowtype_result *res = parsed_result;
9928 struct rte_pmd_i40e_queue_region_conf region_conf;
9929 enum rte_pmd_i40e_queue_region_op op_type;
9932 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9936 memset(®ion_conf, 0, sizeof(region_conf));
9938 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
9939 region_conf.region_id = res->region_id;
9940 region_conf.hw_flowtype = res->flowtype_id;
9942 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9943 op_type, ®ion_conf);
9950 printf("function not implemented or supported\n");
9953 printf("region flowtype config error: (%s)\n", strerror(-ret));
9957 cmdline_parse_token_string_t cmd_region_flowtype_set =
9958 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9960 cmdline_parse_token_string_t cmd_region_flowtype_port =
9961 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9963 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
9964 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9966 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
9967 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9968 cmd, "queue-region");
9969 cmdline_parse_token_string_t cmd_region_flowtype_index =
9970 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9971 region, "region_id");
9972 cmdline_parse_token_num_t cmd_region_flowtype_id =
9973 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9975 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
9976 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9977 flowtype, "flowtype");
9978 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
9979 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9980 flowtype_id, UINT8);
9981 cmdline_parse_inst_t cmd_region_flowtype = {
9982 .f = cmd_region_flowtype_parsed,
9984 .help_str = "set port <port_id> queue-region region_id <value> "
9985 "flowtype <value>: Set a flowtype region index",
9987 (void *)&cmd_region_flowtype_set,
9988 (void *)&cmd_region_flowtype_port,
9989 (void *)&cmd_region_flowtype_port_index,
9990 (void *)&cmd_region_flowtype_cmd,
9991 (void *)&cmd_region_flowtype_index,
9992 (void *)&cmd_region_flowtype_id,
9993 (void *)&cmd_region_flowtype_flow_index,
9994 (void *)&cmd_region_flowtype_flow_id,
9999 /* *** User Priority (UP) to queue region (region_id) set *** */
10000 struct cmd_user_priority_region_result {
10001 cmdline_fixed_string_t set;
10002 cmdline_fixed_string_t port;
10004 cmdline_fixed_string_t cmd;
10005 cmdline_fixed_string_t user_priority;
10006 uint8_t user_priority_id;
10007 cmdline_fixed_string_t region;
10012 cmd_user_priority_region_parsed(void *parsed_result,
10013 __rte_unused struct cmdline *cl,
10014 __rte_unused void *data)
10016 struct cmd_user_priority_region_result *res = parsed_result;
10017 int ret = -ENOTSUP;
10018 #ifdef RTE_NET_I40E
10019 struct rte_pmd_i40e_queue_region_conf region_conf;
10020 enum rte_pmd_i40e_queue_region_op op_type;
10023 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10026 #ifdef RTE_NET_I40E
10027 memset(®ion_conf, 0, sizeof(region_conf));
10028 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
10029 region_conf.user_priority = res->user_priority_id;
10030 region_conf.region_id = res->region_id;
10032 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10033 op_type, ®ion_conf);
10040 printf("function not implemented or supported\n");
10043 printf("user_priority region config error: (%s)\n",
10048 cmdline_parse_token_string_t cmd_user_priority_region_set =
10049 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10051 cmdline_parse_token_string_t cmd_user_priority_region_port =
10052 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10054 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
10055 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10057 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
10058 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10059 cmd, "queue-region");
10060 cmdline_parse_token_string_t cmd_user_priority_region_UP =
10061 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10062 user_priority, "UP");
10063 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
10064 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10065 user_priority_id, UINT8);
10066 cmdline_parse_token_string_t cmd_user_priority_region_region =
10067 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10068 region, "region_id");
10069 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
10070 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10073 cmdline_parse_inst_t cmd_user_priority_region = {
10074 .f = cmd_user_priority_region_parsed,
10076 .help_str = "set port <port_id> queue-region UP <value> "
10077 "region_id <value>: Set the mapping of User Priority (UP) "
10078 "to queue region (region_id) ",
10080 (void *)&cmd_user_priority_region_set,
10081 (void *)&cmd_user_priority_region_port,
10082 (void *)&cmd_user_priority_region_port_index,
10083 (void *)&cmd_user_priority_region_cmd,
10084 (void *)&cmd_user_priority_region_UP,
10085 (void *)&cmd_user_priority_region_UP_id,
10086 (void *)&cmd_user_priority_region_region,
10087 (void *)&cmd_user_priority_region_region_id,
10092 /* *** flush all queue region related configuration *** */
10093 struct cmd_flush_queue_region_result {
10094 cmdline_fixed_string_t set;
10095 cmdline_fixed_string_t port;
10097 cmdline_fixed_string_t cmd;
10098 cmdline_fixed_string_t flush;
10099 cmdline_fixed_string_t what;
10103 cmd_flush_queue_region_parsed(void *parsed_result,
10104 __rte_unused struct cmdline *cl,
10105 __rte_unused void *data)
10107 struct cmd_flush_queue_region_result *res = parsed_result;
10108 int ret = -ENOTSUP;
10109 #ifdef RTE_NET_I40E
10110 struct rte_pmd_i40e_queue_region_conf region_conf;
10111 enum rte_pmd_i40e_queue_region_op op_type;
10114 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10117 #ifdef RTE_NET_I40E
10118 memset(®ion_conf, 0, sizeof(region_conf));
10120 if (strcmp(res->what, "on") == 0)
10121 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
10123 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
10125 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10126 op_type, ®ion_conf);
10133 printf("function not implemented or supported\n");
10136 printf("queue region config flush error: (%s)\n",
10141 cmdline_parse_token_string_t cmd_flush_queue_region_set =
10142 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10144 cmdline_parse_token_string_t cmd_flush_queue_region_port =
10145 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10147 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
10148 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
10150 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
10151 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10152 cmd, "queue-region");
10153 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
10154 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10156 cmdline_parse_token_string_t cmd_flush_queue_region_what =
10157 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10160 cmdline_parse_inst_t cmd_flush_queue_region = {
10161 .f = cmd_flush_queue_region_parsed,
10163 .help_str = "set port <port_id> queue-region flush on|off"
10164 ": flush all queue region related configuration",
10166 (void *)&cmd_flush_queue_region_set,
10167 (void *)&cmd_flush_queue_region_port,
10168 (void *)&cmd_flush_queue_region_port_index,
10169 (void *)&cmd_flush_queue_region_cmd,
10170 (void *)&cmd_flush_queue_region_flush,
10171 (void *)&cmd_flush_queue_region_what,
10176 /* *** get all queue region related configuration info *** */
10177 struct cmd_show_queue_region_info {
10178 cmdline_fixed_string_t show;
10179 cmdline_fixed_string_t port;
10181 cmdline_fixed_string_t cmd;
10185 cmd_show_queue_region_info_parsed(void *parsed_result,
10186 __rte_unused struct cmdline *cl,
10187 __rte_unused void *data)
10189 struct cmd_show_queue_region_info *res = parsed_result;
10190 int ret = -ENOTSUP;
10191 #ifdef RTE_NET_I40E
10192 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
10193 enum rte_pmd_i40e_queue_region_op op_type;
10196 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10199 #ifdef RTE_NET_I40E
10200 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
10202 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
10204 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10205 op_type, &rte_pmd_regions);
10207 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
10214 printf("function not implemented or supported\n");
10217 printf("queue region config info show error: (%s)\n",
10222 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
10223 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10225 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
10226 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10228 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
10229 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
10231 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
10232 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10233 cmd, "queue-region");
10235 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
10236 .f = cmd_show_queue_region_info_parsed,
10238 .help_str = "show port <port_id> queue-region"
10239 ": show all queue region related configuration info",
10241 (void *)&cmd_show_queue_region_info_get,
10242 (void *)&cmd_show_queue_region_info_port,
10243 (void *)&cmd_show_queue_region_info_port_index,
10244 (void *)&cmd_show_queue_region_info_cmd,
10249 /* *** Filters Control *** */
10251 /* *** deal with flow director filter *** */
10252 struct cmd_flow_director_result {
10253 cmdline_fixed_string_t flow_director_filter;
10255 cmdline_fixed_string_t mode;
10256 cmdline_fixed_string_t mode_value;
10257 cmdline_fixed_string_t ops;
10258 cmdline_fixed_string_t flow;
10259 cmdline_fixed_string_t flow_type;
10260 cmdline_fixed_string_t ether;
10261 uint16_t ether_type;
10262 cmdline_fixed_string_t src;
10263 cmdline_ipaddr_t ip_src;
10265 cmdline_fixed_string_t dst;
10266 cmdline_ipaddr_t ip_dst;
10268 cmdline_fixed_string_t verify_tag;
10269 uint32_t verify_tag_value;
10270 cmdline_fixed_string_t tos;
10272 cmdline_fixed_string_t proto;
10273 uint8_t proto_value;
10274 cmdline_fixed_string_t ttl;
10276 cmdline_fixed_string_t vlan;
10277 uint16_t vlan_value;
10278 cmdline_fixed_string_t flexbytes;
10279 cmdline_fixed_string_t flexbytes_value;
10280 cmdline_fixed_string_t pf_vf;
10281 cmdline_fixed_string_t drop;
10282 cmdline_fixed_string_t queue;
10284 cmdline_fixed_string_t fd_id;
10285 uint32_t fd_id_value;
10286 cmdline_fixed_string_t mac;
10287 struct rte_ether_addr mac_addr;
10288 cmdline_fixed_string_t tunnel;
10289 cmdline_fixed_string_t tunnel_type;
10290 cmdline_fixed_string_t tunnel_id;
10291 uint32_t tunnel_id_value;
10292 cmdline_fixed_string_t packet;
10297 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
10300 const char *p, *p0 = q_arg;
10302 unsigned long int_fld;
10303 char *str_fld[max_num];
10308 p = strchr(p0, '(');
10312 p0 = strchr(p, ')');
10317 if (size >= sizeof(s))
10320 snprintf(s, sizeof(s), "%.*s", size, p);
10321 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10322 if (ret < 0 || ret > max_num)
10324 for (i = 0; i < ret; i++) {
10326 int_fld = strtoul(str_fld[i], &end, 0);
10327 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
10329 flexbytes[i] = (uint8_t)int_fld;
10335 str2flowtype(char *string)
10338 static const struct {
10341 } flowtype_str[] = {
10342 {"raw", RTE_ETH_FLOW_RAW},
10343 {"ipv4", RTE_ETH_FLOW_IPV4},
10344 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10345 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10346 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10347 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10348 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10349 {"ipv6", RTE_ETH_FLOW_IPV6},
10350 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10351 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10352 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10353 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10354 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10355 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10358 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
10359 if (!strcmp(flowtype_str[i].str, string))
10360 return flowtype_str[i].type;
10363 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
10364 return (uint16_t)atoi(string);
10366 return RTE_ETH_FLOW_UNKNOWN;
10369 static enum rte_eth_fdir_tunnel_type
10370 str2fdir_tunneltype(char *string)
10374 static const struct {
10376 enum rte_eth_fdir_tunnel_type type;
10377 } tunneltype_str[] = {
10378 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
10379 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
10382 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
10383 if (!strcmp(tunneltype_str[i].str, string))
10384 return tunneltype_str[i].type;
10386 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
10389 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10391 if ((ip_addr).family == AF_INET) \
10392 (ip) = (ip_addr).addr.ipv4.s_addr; \
10394 printf("invalid parameter.\n"); \
10399 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10401 if ((ip_addr).family == AF_INET6) \
10402 rte_memcpy(&(ip), \
10403 &((ip_addr).addr.ipv6), \
10404 sizeof(struct in6_addr)); \
10406 printf("invalid parameter.\n"); \
10412 cmd_flow_director_filter_parsed(void *parsed_result,
10413 __rte_unused struct cmdline *cl,
10414 __rte_unused void *data)
10416 struct cmd_flow_director_result *res = parsed_result;
10417 struct rte_eth_fdir_filter entry;
10418 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
10420 unsigned long vf_id;
10423 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
10425 printf("flow director is not supported on port %u.\n",
10429 memset(flexbytes, 0, sizeof(flexbytes));
10430 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
10432 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10433 if (strcmp(res->mode_value, "MAC-VLAN")) {
10434 printf("Please set mode to MAC-VLAN.\n");
10437 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10438 if (strcmp(res->mode_value, "Tunnel")) {
10439 printf("Please set mode to Tunnel.\n");
10443 if (!strcmp(res->mode_value, "raw")) {
10444 #ifdef RTE_NET_I40E
10445 struct rte_pmd_i40e_flow_type_mapping
10446 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
10447 struct rte_pmd_i40e_pkt_template_conf conf;
10448 uint16_t flow_type = str2flowtype(res->flow_type);
10449 uint16_t i, port = res->port_id;
10452 memset(&conf, 0, sizeof(conf));
10454 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
10455 printf("Invalid flow type specified.\n");
10458 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
10462 if (mapping[flow_type].pctype == 0ULL) {
10463 printf("Invalid flow type specified.\n");
10466 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
10467 if (mapping[flow_type].pctype & (1ULL << i)) {
10468 conf.input.pctype = i;
10473 conf.input.packet = open_file(res->filepath,
10474 &conf.input.length);
10475 if (!conf.input.packet)
10477 if (!strcmp(res->drop, "drop"))
10478 conf.action.behavior =
10479 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
10481 conf.action.behavior =
10482 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
10483 conf.action.report_status =
10484 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
10485 conf.action.rx_queue = res->queue_id;
10486 conf.soft_id = res->fd_id_value;
10487 add = strcmp(res->ops, "del") ? 1 : 0;
10488 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
10492 printf("flow director config error: (%s)\n",
10494 close_file(conf.input.packet);
10497 } else if (strcmp(res->mode_value, "IP")) {
10498 printf("Please set mode to IP or raw.\n");
10501 entry.input.flow_type = str2flowtype(res->flow_type);
10504 ret = parse_flexbytes(res->flexbytes_value,
10506 RTE_ETH_FDIR_MAX_FLEXLEN);
10508 printf("error: Cannot parse flexbytes input.\n");
10512 switch (entry.input.flow_type) {
10513 case RTE_ETH_FLOW_FRAG_IPV4:
10514 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
10515 entry.input.flow.ip4_flow.proto = res->proto_value;
10517 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
10518 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
10519 IPV4_ADDR_TO_UINT(res->ip_dst,
10520 entry.input.flow.ip4_flow.dst_ip);
10521 IPV4_ADDR_TO_UINT(res->ip_src,
10522 entry.input.flow.ip4_flow.src_ip);
10523 entry.input.flow.ip4_flow.tos = res->tos_value;
10524 entry.input.flow.ip4_flow.ttl = res->ttl_value;
10525 /* need convert to big endian. */
10526 entry.input.flow.udp4_flow.dst_port =
10527 rte_cpu_to_be_16(res->port_dst);
10528 entry.input.flow.udp4_flow.src_port =
10529 rte_cpu_to_be_16(res->port_src);
10531 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
10532 IPV4_ADDR_TO_UINT(res->ip_dst,
10533 entry.input.flow.sctp4_flow.ip.dst_ip);
10534 IPV4_ADDR_TO_UINT(res->ip_src,
10535 entry.input.flow.sctp4_flow.ip.src_ip);
10536 entry.input.flow.ip4_flow.tos = res->tos_value;
10537 entry.input.flow.ip4_flow.ttl = res->ttl_value;
10538 /* need convert to big endian. */
10539 entry.input.flow.sctp4_flow.dst_port =
10540 rte_cpu_to_be_16(res->port_dst);
10541 entry.input.flow.sctp4_flow.src_port =
10542 rte_cpu_to_be_16(res->port_src);
10543 entry.input.flow.sctp4_flow.verify_tag =
10544 rte_cpu_to_be_32(res->verify_tag_value);
10546 case RTE_ETH_FLOW_FRAG_IPV6:
10547 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
10548 entry.input.flow.ipv6_flow.proto = res->proto_value;
10550 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
10551 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
10552 IPV6_ADDR_TO_ARRAY(res->ip_dst,
10553 entry.input.flow.ipv6_flow.dst_ip);
10554 IPV6_ADDR_TO_ARRAY(res->ip_src,
10555 entry.input.flow.ipv6_flow.src_ip);
10556 entry.input.flow.ipv6_flow.tc = res->tos_value;
10557 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
10558 /* need convert to big endian. */
10559 entry.input.flow.udp6_flow.dst_port =
10560 rte_cpu_to_be_16(res->port_dst);
10561 entry.input.flow.udp6_flow.src_port =
10562 rte_cpu_to_be_16(res->port_src);
10564 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
10565 IPV6_ADDR_TO_ARRAY(res->ip_dst,
10566 entry.input.flow.sctp6_flow.ip.dst_ip);
10567 IPV6_ADDR_TO_ARRAY(res->ip_src,
10568 entry.input.flow.sctp6_flow.ip.src_ip);
10569 entry.input.flow.ipv6_flow.tc = res->tos_value;
10570 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
10571 /* need convert to big endian. */
10572 entry.input.flow.sctp6_flow.dst_port =
10573 rte_cpu_to_be_16(res->port_dst);
10574 entry.input.flow.sctp6_flow.src_port =
10575 rte_cpu_to_be_16(res->port_src);
10576 entry.input.flow.sctp6_flow.verify_tag =
10577 rte_cpu_to_be_32(res->verify_tag_value);
10579 case RTE_ETH_FLOW_L2_PAYLOAD:
10580 entry.input.flow.l2_flow.ether_type =
10581 rte_cpu_to_be_16(res->ether_type);
10587 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
10588 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
10590 sizeof(struct rte_ether_addr));
10592 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10593 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
10595 sizeof(struct rte_ether_addr));
10596 entry.input.flow.tunnel_flow.tunnel_type =
10597 str2fdir_tunneltype(res->tunnel_type);
10598 entry.input.flow.tunnel_flow.tunnel_id =
10599 rte_cpu_to_be_32(res->tunnel_id_value);
10602 rte_memcpy(entry.input.flow_ext.flexbytes,
10604 RTE_ETH_FDIR_MAX_FLEXLEN);
10606 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
10608 entry.action.flex_off = 0; /*use 0 by default */
10609 if (!strcmp(res->drop, "drop"))
10610 entry.action.behavior = RTE_ETH_FDIR_REJECT;
10612 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
10614 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
10615 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
10616 if (!strcmp(res->pf_vf, "pf"))
10617 entry.input.flow_ext.is_vf = 0;
10618 else if (!strncmp(res->pf_vf, "vf", 2)) {
10619 struct rte_eth_dev_info dev_info;
10621 ret = eth_dev_info_get_print_err(res->port_id,
10627 vf_id = strtoul(res->pf_vf + 2, &end, 10);
10628 if (errno != 0 || *end != '\0' ||
10629 vf_id >= dev_info.max_vfs) {
10630 printf("invalid parameter %s.\n", res->pf_vf);
10633 entry.input.flow_ext.is_vf = 1;
10634 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
10636 printf("invalid parameter %s.\n", res->pf_vf);
10641 /* set to report FD ID by default */
10642 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
10643 entry.action.rx_queue = res->queue_id;
10644 entry.soft_id = res->fd_id_value;
10645 if (!strcmp(res->ops, "add"))
10646 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10647 RTE_ETH_FILTER_ADD, &entry);
10648 else if (!strcmp(res->ops, "del"))
10649 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10650 RTE_ETH_FILTER_DELETE, &entry);
10652 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10653 RTE_ETH_FILTER_UPDATE, &entry);
10655 printf("flow director programming error: (%s)\n",
10659 cmdline_parse_token_string_t cmd_flow_director_filter =
10660 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10661 flow_director_filter, "flow_director_filter");
10662 cmdline_parse_token_num_t cmd_flow_director_port_id =
10663 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10665 cmdline_parse_token_string_t cmd_flow_director_ops =
10666 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10667 ops, "add#del#update");
10668 cmdline_parse_token_string_t cmd_flow_director_flow =
10669 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10671 cmdline_parse_token_string_t cmd_flow_director_flow_type =
10672 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10674 cmdline_parse_token_string_t cmd_flow_director_ether =
10675 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10677 cmdline_parse_token_num_t cmd_flow_director_ether_type =
10678 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10679 ether_type, UINT16);
10680 cmdline_parse_token_string_t cmd_flow_director_src =
10681 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10683 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
10684 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10686 cmdline_parse_token_num_t cmd_flow_director_port_src =
10687 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10689 cmdline_parse_token_string_t cmd_flow_director_dst =
10690 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10692 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
10693 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10695 cmdline_parse_token_num_t cmd_flow_director_port_dst =
10696 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10698 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
10699 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10700 verify_tag, "verify_tag");
10701 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
10702 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10703 verify_tag_value, UINT32);
10704 cmdline_parse_token_string_t cmd_flow_director_tos =
10705 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10707 cmdline_parse_token_num_t cmd_flow_director_tos_value =
10708 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10710 cmdline_parse_token_string_t cmd_flow_director_proto =
10711 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10713 cmdline_parse_token_num_t cmd_flow_director_proto_value =
10714 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10715 proto_value, UINT8);
10716 cmdline_parse_token_string_t cmd_flow_director_ttl =
10717 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10719 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
10720 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10722 cmdline_parse_token_string_t cmd_flow_director_vlan =
10723 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10725 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
10726 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10727 vlan_value, UINT16);
10728 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
10729 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10730 flexbytes, "flexbytes");
10731 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
10732 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10733 flexbytes_value, NULL);
10734 cmdline_parse_token_string_t cmd_flow_director_drop =
10735 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10737 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
10738 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10740 cmdline_parse_token_string_t cmd_flow_director_queue =
10741 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10743 cmdline_parse_token_num_t cmd_flow_director_queue_id =
10744 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10746 cmdline_parse_token_string_t cmd_flow_director_fd_id =
10747 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10749 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
10750 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10751 fd_id_value, UINT32);
10753 cmdline_parse_token_string_t cmd_flow_director_mode =
10754 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10756 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
10757 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10759 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
10760 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10761 mode_value, "MAC-VLAN");
10762 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
10763 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10764 mode_value, "Tunnel");
10765 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
10766 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10767 mode_value, "raw");
10768 cmdline_parse_token_string_t cmd_flow_director_mac =
10769 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10771 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
10772 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
10774 cmdline_parse_token_string_t cmd_flow_director_tunnel =
10775 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10777 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
10778 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10779 tunnel_type, "NVGRE#VxLAN");
10780 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
10781 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10782 tunnel_id, "tunnel-id");
10783 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
10784 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10785 tunnel_id_value, UINT32);
10786 cmdline_parse_token_string_t cmd_flow_director_packet =
10787 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10789 cmdline_parse_token_string_t cmd_flow_director_filepath =
10790 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10793 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
10794 .f = cmd_flow_director_filter_parsed,
10796 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
10797 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
10798 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
10799 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
10800 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
10801 "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> "
10802 "fd_id <fd_id_value>: "
10803 "Add or delete an ip flow director entry on NIC",
10805 (void *)&cmd_flow_director_filter,
10806 (void *)&cmd_flow_director_port_id,
10807 (void *)&cmd_flow_director_mode,
10808 (void *)&cmd_flow_director_mode_ip,
10809 (void *)&cmd_flow_director_ops,
10810 (void *)&cmd_flow_director_flow,
10811 (void *)&cmd_flow_director_flow_type,
10812 (void *)&cmd_flow_director_src,
10813 (void *)&cmd_flow_director_ip_src,
10814 (void *)&cmd_flow_director_dst,
10815 (void *)&cmd_flow_director_ip_dst,
10816 (void *)&cmd_flow_director_tos,
10817 (void *)&cmd_flow_director_tos_value,
10818 (void *)&cmd_flow_director_proto,
10819 (void *)&cmd_flow_director_proto_value,
10820 (void *)&cmd_flow_director_ttl,
10821 (void *)&cmd_flow_director_ttl_value,
10822 (void *)&cmd_flow_director_vlan,
10823 (void *)&cmd_flow_director_vlan_value,
10824 (void *)&cmd_flow_director_flexbytes,
10825 (void *)&cmd_flow_director_flexbytes_value,
10826 (void *)&cmd_flow_director_drop,
10827 (void *)&cmd_flow_director_pf_vf,
10828 (void *)&cmd_flow_director_queue,
10829 (void *)&cmd_flow_director_queue_id,
10830 (void *)&cmd_flow_director_fd_id,
10831 (void *)&cmd_flow_director_fd_id_value,
10836 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
10837 .f = cmd_flow_director_filter_parsed,
10839 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
10840 "director entry on NIC",
10842 (void *)&cmd_flow_director_filter,
10843 (void *)&cmd_flow_director_port_id,
10844 (void *)&cmd_flow_director_mode,
10845 (void *)&cmd_flow_director_mode_ip,
10846 (void *)&cmd_flow_director_ops,
10847 (void *)&cmd_flow_director_flow,
10848 (void *)&cmd_flow_director_flow_type,
10849 (void *)&cmd_flow_director_src,
10850 (void *)&cmd_flow_director_ip_src,
10851 (void *)&cmd_flow_director_port_src,
10852 (void *)&cmd_flow_director_dst,
10853 (void *)&cmd_flow_director_ip_dst,
10854 (void *)&cmd_flow_director_port_dst,
10855 (void *)&cmd_flow_director_tos,
10856 (void *)&cmd_flow_director_tos_value,
10857 (void *)&cmd_flow_director_ttl,
10858 (void *)&cmd_flow_director_ttl_value,
10859 (void *)&cmd_flow_director_vlan,
10860 (void *)&cmd_flow_director_vlan_value,
10861 (void *)&cmd_flow_director_flexbytes,
10862 (void *)&cmd_flow_director_flexbytes_value,
10863 (void *)&cmd_flow_director_drop,
10864 (void *)&cmd_flow_director_pf_vf,
10865 (void *)&cmd_flow_director_queue,
10866 (void *)&cmd_flow_director_queue_id,
10867 (void *)&cmd_flow_director_fd_id,
10868 (void *)&cmd_flow_director_fd_id_value,
10873 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
10874 .f = cmd_flow_director_filter_parsed,
10876 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
10877 "director entry on NIC",
10879 (void *)&cmd_flow_director_filter,
10880 (void *)&cmd_flow_director_port_id,
10881 (void *)&cmd_flow_director_mode,
10882 (void *)&cmd_flow_director_mode_ip,
10883 (void *)&cmd_flow_director_ops,
10884 (void *)&cmd_flow_director_flow,
10885 (void *)&cmd_flow_director_flow_type,
10886 (void *)&cmd_flow_director_src,
10887 (void *)&cmd_flow_director_ip_src,
10888 (void *)&cmd_flow_director_port_src,
10889 (void *)&cmd_flow_director_dst,
10890 (void *)&cmd_flow_director_ip_dst,
10891 (void *)&cmd_flow_director_port_dst,
10892 (void *)&cmd_flow_director_verify_tag,
10893 (void *)&cmd_flow_director_verify_tag_value,
10894 (void *)&cmd_flow_director_tos,
10895 (void *)&cmd_flow_director_tos_value,
10896 (void *)&cmd_flow_director_ttl,
10897 (void *)&cmd_flow_director_ttl_value,
10898 (void *)&cmd_flow_director_vlan,
10899 (void *)&cmd_flow_director_vlan_value,
10900 (void *)&cmd_flow_director_flexbytes,
10901 (void *)&cmd_flow_director_flexbytes_value,
10902 (void *)&cmd_flow_director_drop,
10903 (void *)&cmd_flow_director_pf_vf,
10904 (void *)&cmd_flow_director_queue,
10905 (void *)&cmd_flow_director_queue_id,
10906 (void *)&cmd_flow_director_fd_id,
10907 (void *)&cmd_flow_director_fd_id_value,
10912 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
10913 .f = cmd_flow_director_filter_parsed,
10915 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
10916 "director entry on NIC",
10918 (void *)&cmd_flow_director_filter,
10919 (void *)&cmd_flow_director_port_id,
10920 (void *)&cmd_flow_director_mode,
10921 (void *)&cmd_flow_director_mode_ip,
10922 (void *)&cmd_flow_director_ops,
10923 (void *)&cmd_flow_director_flow,
10924 (void *)&cmd_flow_director_flow_type,
10925 (void *)&cmd_flow_director_ether,
10926 (void *)&cmd_flow_director_ether_type,
10927 (void *)&cmd_flow_director_flexbytes,
10928 (void *)&cmd_flow_director_flexbytes_value,
10929 (void *)&cmd_flow_director_drop,
10930 (void *)&cmd_flow_director_pf_vf,
10931 (void *)&cmd_flow_director_queue,
10932 (void *)&cmd_flow_director_queue_id,
10933 (void *)&cmd_flow_director_fd_id,
10934 (void *)&cmd_flow_director_fd_id_value,
10939 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
10940 .f = cmd_flow_director_filter_parsed,
10942 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
10943 "director entry on NIC",
10945 (void *)&cmd_flow_director_filter,
10946 (void *)&cmd_flow_director_port_id,
10947 (void *)&cmd_flow_director_mode,
10948 (void *)&cmd_flow_director_mode_mac_vlan,
10949 (void *)&cmd_flow_director_ops,
10950 (void *)&cmd_flow_director_mac,
10951 (void *)&cmd_flow_director_mac_addr,
10952 (void *)&cmd_flow_director_vlan,
10953 (void *)&cmd_flow_director_vlan_value,
10954 (void *)&cmd_flow_director_flexbytes,
10955 (void *)&cmd_flow_director_flexbytes_value,
10956 (void *)&cmd_flow_director_drop,
10957 (void *)&cmd_flow_director_queue,
10958 (void *)&cmd_flow_director_queue_id,
10959 (void *)&cmd_flow_director_fd_id,
10960 (void *)&cmd_flow_director_fd_id_value,
10965 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
10966 .f = cmd_flow_director_filter_parsed,
10968 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
10969 "director entry on NIC",
10971 (void *)&cmd_flow_director_filter,
10972 (void *)&cmd_flow_director_port_id,
10973 (void *)&cmd_flow_director_mode,
10974 (void *)&cmd_flow_director_mode_tunnel,
10975 (void *)&cmd_flow_director_ops,
10976 (void *)&cmd_flow_director_mac,
10977 (void *)&cmd_flow_director_mac_addr,
10978 (void *)&cmd_flow_director_vlan,
10979 (void *)&cmd_flow_director_vlan_value,
10980 (void *)&cmd_flow_director_tunnel,
10981 (void *)&cmd_flow_director_tunnel_type,
10982 (void *)&cmd_flow_director_tunnel_id,
10983 (void *)&cmd_flow_director_tunnel_id_value,
10984 (void *)&cmd_flow_director_flexbytes,
10985 (void *)&cmd_flow_director_flexbytes_value,
10986 (void *)&cmd_flow_director_drop,
10987 (void *)&cmd_flow_director_queue,
10988 (void *)&cmd_flow_director_queue_id,
10989 (void *)&cmd_flow_director_fd_id,
10990 (void *)&cmd_flow_director_fd_id_value,
10995 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
10996 .f = cmd_flow_director_filter_parsed,
10998 .help_str = "flow_director_filter ... : Add or delete a raw flow "
10999 "director entry on NIC",
11001 (void *)&cmd_flow_director_filter,
11002 (void *)&cmd_flow_director_port_id,
11003 (void *)&cmd_flow_director_mode,
11004 (void *)&cmd_flow_director_mode_raw,
11005 (void *)&cmd_flow_director_ops,
11006 (void *)&cmd_flow_director_flow,
11007 (void *)&cmd_flow_director_flow_type,
11008 (void *)&cmd_flow_director_drop,
11009 (void *)&cmd_flow_director_queue,
11010 (void *)&cmd_flow_director_queue_id,
11011 (void *)&cmd_flow_director_fd_id,
11012 (void *)&cmd_flow_director_fd_id_value,
11013 (void *)&cmd_flow_director_packet,
11014 (void *)&cmd_flow_director_filepath,
11019 struct cmd_flush_flow_director_result {
11020 cmdline_fixed_string_t flush_flow_director;
11024 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
11025 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
11026 flush_flow_director, "flush_flow_director");
11027 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
11028 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
11032 cmd_flush_flow_director_parsed(void *parsed_result,
11033 __rte_unused struct cmdline *cl,
11034 __rte_unused void *data)
11036 struct cmd_flow_director_result *res = parsed_result;
11039 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
11041 printf("flow director is not supported on port %u.\n",
11046 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11047 RTE_ETH_FILTER_FLUSH, NULL);
11049 printf("flow director table flushing error: (%s)\n",
11053 cmdline_parse_inst_t cmd_flush_flow_director = {
11054 .f = cmd_flush_flow_director_parsed,
11056 .help_str = "flush_flow_director <port_id>: "
11057 "Flush all flow director entries of a device on NIC",
11059 (void *)&cmd_flush_flow_director_flush,
11060 (void *)&cmd_flush_flow_director_port_id,
11065 /* *** deal with flow director mask *** */
11066 struct cmd_flow_director_mask_result {
11067 cmdline_fixed_string_t flow_director_mask;
11069 cmdline_fixed_string_t mode;
11070 cmdline_fixed_string_t mode_value;
11071 cmdline_fixed_string_t vlan;
11072 uint16_t vlan_mask;
11073 cmdline_fixed_string_t src_mask;
11074 cmdline_ipaddr_t ipv4_src;
11075 cmdline_ipaddr_t ipv6_src;
11077 cmdline_fixed_string_t dst_mask;
11078 cmdline_ipaddr_t ipv4_dst;
11079 cmdline_ipaddr_t ipv6_dst;
11081 cmdline_fixed_string_t mac;
11082 uint8_t mac_addr_byte_mask;
11083 cmdline_fixed_string_t tunnel_id;
11084 uint32_t tunnel_id_mask;
11085 cmdline_fixed_string_t tunnel_type;
11086 uint8_t tunnel_type_mask;
11090 cmd_flow_director_mask_parsed(void *parsed_result,
11091 __rte_unused struct cmdline *cl,
11092 __rte_unused void *data)
11094 struct cmd_flow_director_mask_result *res = parsed_result;
11095 struct rte_eth_fdir_masks *mask;
11096 struct rte_port *port;
11098 port = &ports[res->port_id];
11099 /** Check if the port is not started **/
11100 if (port->port_status != RTE_PORT_STOPPED) {
11101 printf("Please stop port %d first\n", res->port_id);
11105 mask = &port->dev_conf.fdir_conf.mask;
11107 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
11108 if (strcmp(res->mode_value, "MAC-VLAN")) {
11109 printf("Please set mode to MAC-VLAN.\n");
11113 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11114 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11115 if (strcmp(res->mode_value, "Tunnel")) {
11116 printf("Please set mode to Tunnel.\n");
11120 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11121 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
11122 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
11123 mask->tunnel_type_mask = res->tunnel_type_mask;
11125 if (strcmp(res->mode_value, "IP")) {
11126 printf("Please set mode to IP.\n");
11130 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11131 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
11132 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
11133 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
11134 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
11135 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
11136 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
11139 cmd_reconfig_device_queue(res->port_id, 1, 1);
11142 cmdline_parse_token_string_t cmd_flow_director_mask =
11143 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11144 flow_director_mask, "flow_director_mask");
11145 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
11146 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11148 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
11149 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11151 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
11152 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11153 vlan_mask, UINT16);
11154 cmdline_parse_token_string_t cmd_flow_director_mask_src =
11155 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11156 src_mask, "src_mask");
11157 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
11158 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11160 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
11161 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11163 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
11164 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11166 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
11167 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11168 dst_mask, "dst_mask");
11169 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
11170 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11172 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
11173 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11175 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
11176 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11179 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
11180 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11182 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
11183 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11185 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
11186 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11187 mode_value, "MAC-VLAN");
11188 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
11189 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11190 mode_value, "Tunnel");
11191 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
11192 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11194 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
11195 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11196 mac_addr_byte_mask, UINT8);
11197 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
11198 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11199 tunnel_type, "tunnel-type");
11200 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
11201 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11202 tunnel_type_mask, UINT8);
11203 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
11204 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11205 tunnel_id, "tunnel-id");
11206 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
11207 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11208 tunnel_id_mask, UINT32);
11210 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
11211 .f = cmd_flow_director_mask_parsed,
11213 .help_str = "flow_director_mask ... : "
11214 "Set IP mode flow director's mask on NIC",
11216 (void *)&cmd_flow_director_mask,
11217 (void *)&cmd_flow_director_mask_port_id,
11218 (void *)&cmd_flow_director_mask_mode,
11219 (void *)&cmd_flow_director_mask_mode_ip,
11220 (void *)&cmd_flow_director_mask_vlan,
11221 (void *)&cmd_flow_director_mask_vlan_value,
11222 (void *)&cmd_flow_director_mask_src,
11223 (void *)&cmd_flow_director_mask_ipv4_src,
11224 (void *)&cmd_flow_director_mask_ipv6_src,
11225 (void *)&cmd_flow_director_mask_port_src,
11226 (void *)&cmd_flow_director_mask_dst,
11227 (void *)&cmd_flow_director_mask_ipv4_dst,
11228 (void *)&cmd_flow_director_mask_ipv6_dst,
11229 (void *)&cmd_flow_director_mask_port_dst,
11234 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
11235 .f = cmd_flow_director_mask_parsed,
11237 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
11238 "flow director's mask on NIC",
11240 (void *)&cmd_flow_director_mask,
11241 (void *)&cmd_flow_director_mask_port_id,
11242 (void *)&cmd_flow_director_mask_mode,
11243 (void *)&cmd_flow_director_mask_mode_mac_vlan,
11244 (void *)&cmd_flow_director_mask_vlan,
11245 (void *)&cmd_flow_director_mask_vlan_value,
11250 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
11251 .f = cmd_flow_director_mask_parsed,
11253 .help_str = "flow_director_mask ... : Set tunnel mode "
11254 "flow director's mask on NIC",
11256 (void *)&cmd_flow_director_mask,
11257 (void *)&cmd_flow_director_mask_port_id,
11258 (void *)&cmd_flow_director_mask_mode,
11259 (void *)&cmd_flow_director_mask_mode_tunnel,
11260 (void *)&cmd_flow_director_mask_vlan,
11261 (void *)&cmd_flow_director_mask_vlan_value,
11262 (void *)&cmd_flow_director_mask_mac,
11263 (void *)&cmd_flow_director_mask_mac_value,
11264 (void *)&cmd_flow_director_mask_tunnel_type,
11265 (void *)&cmd_flow_director_mask_tunnel_type_value,
11266 (void *)&cmd_flow_director_mask_tunnel_id,
11267 (void *)&cmd_flow_director_mask_tunnel_id_value,
11272 /* *** deal with flow director mask on flexible payload *** */
11273 struct cmd_flow_director_flex_mask_result {
11274 cmdline_fixed_string_t flow_director_flexmask;
11276 cmdline_fixed_string_t flow;
11277 cmdline_fixed_string_t flow_type;
11278 cmdline_fixed_string_t mask;
11282 cmd_flow_director_flex_mask_parsed(void *parsed_result,
11283 __rte_unused struct cmdline *cl,
11284 __rte_unused void *data)
11286 struct cmd_flow_director_flex_mask_result *res = parsed_result;
11287 struct rte_eth_fdir_info fdir_info;
11288 struct rte_eth_fdir_flex_mask flex_mask;
11289 struct rte_port *port;
11290 uint64_t flow_type_mask;
11294 port = &ports[res->port_id];
11295 /** Check if the port is not started **/
11296 if (port->port_status != RTE_PORT_STOPPED) {
11297 printf("Please stop port %d first\n", res->port_id);
11301 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
11302 ret = parse_flexbytes(res->mask,
11304 RTE_ETH_FDIR_MAX_FLEXLEN);
11306 printf("error: Cannot parse mask input.\n");
11310 memset(&fdir_info, 0, sizeof(fdir_info));
11311 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11312 RTE_ETH_FILTER_INFO, &fdir_info);
11314 printf("Cannot get FDir filter info\n");
11318 if (!strcmp(res->flow_type, "none")) {
11319 /* means don't specify the flow type */
11320 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
11321 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
11322 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
11323 0, sizeof(struct rte_eth_fdir_flex_mask));
11324 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
11325 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
11327 sizeof(struct rte_eth_fdir_flex_mask));
11328 cmd_reconfig_device_queue(res->port_id, 1, 1);
11331 flow_type_mask = fdir_info.flow_types_mask[0];
11332 if (!strcmp(res->flow_type, "all")) {
11333 if (!flow_type_mask) {
11334 printf("No flow type supported\n");
11337 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
11338 if (flow_type_mask & (1ULL << i)) {
11339 flex_mask.flow_type = i;
11340 fdir_set_flex_mask(res->port_id, &flex_mask);
11343 cmd_reconfig_device_queue(res->port_id, 1, 1);
11346 flex_mask.flow_type = str2flowtype(res->flow_type);
11347 if (!(flow_type_mask & (1ULL << flex_mask.flow_type))) {
11348 printf("Flow type %s not supported on port %d\n",
11349 res->flow_type, res->port_id);
11352 fdir_set_flex_mask(res->port_id, &flex_mask);
11353 cmd_reconfig_device_queue(res->port_id, 1, 1);
11356 cmdline_parse_token_string_t cmd_flow_director_flexmask =
11357 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11358 flow_director_flexmask,
11359 "flow_director_flex_mask");
11360 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
11361 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11363 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
11364 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11366 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
11367 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11368 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
11369 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
11370 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
11371 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11374 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
11375 .f = cmd_flow_director_flex_mask_parsed,
11377 .help_str = "flow_director_flex_mask ... : "
11378 "Set flow director's flex mask on NIC",
11380 (void *)&cmd_flow_director_flexmask,
11381 (void *)&cmd_flow_director_flexmask_port_id,
11382 (void *)&cmd_flow_director_flexmask_flow,
11383 (void *)&cmd_flow_director_flexmask_flow_type,
11384 (void *)&cmd_flow_director_flexmask_mask,
11389 /* *** deal with flow director flexible payload configuration *** */
11390 struct cmd_flow_director_flexpayload_result {
11391 cmdline_fixed_string_t flow_director_flexpayload;
11393 cmdline_fixed_string_t payload_layer;
11394 cmdline_fixed_string_t payload_cfg;
11398 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
11401 const char *p, *p0 = q_arg;
11403 unsigned long int_fld;
11404 char *str_fld[max_num];
11409 p = strchr(p0, '(');
11413 p0 = strchr(p, ')');
11418 if (size >= sizeof(s))
11421 snprintf(s, sizeof(s), "%.*s", size, p);
11422 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
11423 if (ret < 0 || ret > max_num)
11425 for (i = 0; i < ret; i++) {
11427 int_fld = strtoul(str_fld[i], &end, 0);
11428 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
11430 offsets[i] = (uint16_t)int_fld;
11436 cmd_flow_director_flxpld_parsed(void *parsed_result,
11437 __rte_unused struct cmdline *cl,
11438 __rte_unused void *data)
11440 struct cmd_flow_director_flexpayload_result *res = parsed_result;
11441 struct rte_eth_flex_payload_cfg flex_cfg;
11442 struct rte_port *port;
11445 port = &ports[res->port_id];
11446 /** Check if the port is not started **/
11447 if (port->port_status != RTE_PORT_STOPPED) {
11448 printf("Please stop port %d first\n", res->port_id);
11452 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
11454 if (!strcmp(res->payload_layer, "raw"))
11455 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
11456 else if (!strcmp(res->payload_layer, "l2"))
11457 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
11458 else if (!strcmp(res->payload_layer, "l3"))
11459 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
11460 else if (!strcmp(res->payload_layer, "l4"))
11461 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
11463 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
11464 RTE_ETH_FDIR_MAX_FLEXLEN);
11466 printf("error: Cannot parse flex payload input.\n");
11470 fdir_set_flex_payload(res->port_id, &flex_cfg);
11471 cmd_reconfig_device_queue(res->port_id, 1, 1);
11474 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
11475 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11476 flow_director_flexpayload,
11477 "flow_director_flex_payload");
11478 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
11479 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11481 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
11482 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11483 payload_layer, "raw#l2#l3#l4");
11484 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
11485 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11486 payload_cfg, NULL);
11488 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
11489 .f = cmd_flow_director_flxpld_parsed,
11491 .help_str = "flow_director_flexpayload ... : "
11492 "Set flow director's flex payload on NIC",
11494 (void *)&cmd_flow_director_flexpayload,
11495 (void *)&cmd_flow_director_flexpayload_port_id,
11496 (void *)&cmd_flow_director_flexpayload_payload_layer,
11497 (void *)&cmd_flow_director_flexpayload_payload_cfg,
11502 /* Generic flow interface command. */
11503 extern cmdline_parse_inst_t cmd_flow;
11505 /* *** Classification Filters Control *** */
11506 /* *** Get symmetric hash enable per port *** */
11507 struct cmd_get_sym_hash_ena_per_port_result {
11508 cmdline_fixed_string_t get_sym_hash_ena_per_port;
11513 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
11514 __rte_unused struct cmdline *cl,
11515 __rte_unused void *data)
11517 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
11518 struct rte_eth_hash_filter_info info;
11521 if (rte_eth_dev_filter_supported(res->port_id,
11522 RTE_ETH_FILTER_HASH) < 0) {
11523 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
11528 memset(&info, 0, sizeof(info));
11529 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
11530 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11531 RTE_ETH_FILTER_GET, &info);
11534 printf("Cannot get symmetric hash enable per port "
11535 "on port %u\n", res->port_id);
11539 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
11540 "enabled" : "disabled", res->port_id);
11543 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
11544 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
11545 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
11546 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
11547 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
11550 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
11551 .f = cmd_get_sym_hash_per_port_parsed,
11553 .help_str = "get_sym_hash_ena_per_port <port_id>",
11555 (void *)&cmd_get_sym_hash_ena_per_port_all,
11556 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
11561 /* *** Set symmetric hash enable per port *** */
11562 struct cmd_set_sym_hash_ena_per_port_result {
11563 cmdline_fixed_string_t set_sym_hash_ena_per_port;
11564 cmdline_fixed_string_t enable;
11569 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
11570 __rte_unused struct cmdline *cl,
11571 __rte_unused void *data)
11573 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
11574 struct rte_eth_hash_filter_info info;
11577 if (rte_eth_dev_filter_supported(res->port_id,
11578 RTE_ETH_FILTER_HASH) < 0) {
11579 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
11584 memset(&info, 0, sizeof(info));
11585 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
11586 if (!strcmp(res->enable, "enable"))
11587 info.info.enable = 1;
11588 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11589 RTE_ETH_FILTER_SET, &info);
11591 printf("Cannot set symmetric hash enable per port on "
11592 "port %u\n", res->port_id);
11595 printf("Symmetric hash has been set to %s on port %u\n",
11596 res->enable, res->port_id);
11599 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
11600 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11601 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
11602 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
11603 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11605 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
11606 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11607 enable, "enable#disable");
11609 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
11610 .f = cmd_set_sym_hash_per_port_parsed,
11612 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
11614 (void *)&cmd_set_sym_hash_ena_per_port_all,
11615 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
11616 (void *)&cmd_set_sym_hash_ena_per_port_enable,
11621 /* Get global config of hash function */
11622 struct cmd_get_hash_global_config_result {
11623 cmdline_fixed_string_t get_hash_global_config;
11628 flowtype_to_str(uint16_t ftype)
11634 } ftype_table[] = {
11635 {"ipv4", RTE_ETH_FLOW_IPV4},
11636 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
11637 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
11638 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
11639 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
11640 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
11641 {"ipv6", RTE_ETH_FLOW_IPV6},
11642 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
11643 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
11644 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
11645 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
11646 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
11647 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
11648 {"port", RTE_ETH_FLOW_PORT},
11649 {"vxlan", RTE_ETH_FLOW_VXLAN},
11650 {"geneve", RTE_ETH_FLOW_GENEVE},
11651 {"nvgre", RTE_ETH_FLOW_NVGRE},
11652 {"vxlan-gpe", RTE_ETH_FLOW_VXLAN_GPE},
11655 for (i = 0; i < RTE_DIM(ftype_table); i++) {
11656 if (ftype_table[i].ftype == ftype)
11657 return ftype_table[i].str;
11664 cmd_get_hash_global_config_parsed(void *parsed_result,
11665 __rte_unused struct cmdline *cl,
11666 __rte_unused void *data)
11668 struct cmd_get_hash_global_config_result *res = parsed_result;
11669 struct rte_eth_hash_filter_info info;
11670 uint32_t idx, offset;
11675 if (rte_eth_dev_filter_supported(res->port_id,
11676 RTE_ETH_FILTER_HASH) < 0) {
11677 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
11682 memset(&info, 0, sizeof(info));
11683 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
11684 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11685 RTE_ETH_FILTER_GET, &info);
11687 printf("Cannot get hash global configurations by port %d\n",
11692 switch (info.info.global_conf.hash_func) {
11693 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
11694 printf("Hash function is Toeplitz\n");
11696 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
11697 printf("Hash function is Simple XOR\n");
11699 case RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ:
11700 printf("Hash function is Symmetric Toeplitz\n");
11703 printf("Unknown hash function\n");
11707 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
11708 idx = i / UINT64_BIT;
11709 offset = i % UINT64_BIT;
11710 if (!(info.info.global_conf.valid_bit_mask[idx] &
11713 str = flowtype_to_str(i);
11716 printf("Symmetric hash is %s globally for flow type %s "
11718 ((info.info.global_conf.sym_hash_enable_mask[idx] &
11719 (1ULL << offset)) ? "enabled" : "disabled"), str,
11724 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
11725 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
11726 get_hash_global_config, "get_hash_global_config");
11727 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
11728 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
11731 cmdline_parse_inst_t cmd_get_hash_global_config = {
11732 .f = cmd_get_hash_global_config_parsed,
11734 .help_str = "get_hash_global_config <port_id>",
11736 (void *)&cmd_get_hash_global_config_all,
11737 (void *)&cmd_get_hash_global_config_port_id,
11742 /* Set global config of hash function */
11743 struct cmd_set_hash_global_config_result {
11744 cmdline_fixed_string_t set_hash_global_config;
11746 cmdline_fixed_string_t hash_func;
11747 cmdline_fixed_string_t flow_type;
11748 cmdline_fixed_string_t enable;
11752 cmd_set_hash_global_config_parsed(void *parsed_result,
11753 __rte_unused struct cmdline *cl,
11754 __rte_unused void *data)
11756 struct cmd_set_hash_global_config_result *res = parsed_result;
11757 struct rte_eth_hash_filter_info info;
11758 uint32_t ftype, idx, offset;
11761 if (rte_eth_dev_filter_supported(res->port_id,
11762 RTE_ETH_FILTER_HASH) < 0) {
11763 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
11767 memset(&info, 0, sizeof(info));
11768 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
11769 if (!strcmp(res->hash_func, "toeplitz"))
11770 info.info.global_conf.hash_func =
11771 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
11772 else if (!strcmp(res->hash_func, "simple_xor"))
11773 info.info.global_conf.hash_func =
11774 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
11775 else if (!strcmp(res->hash_func, "symmetric_toeplitz"))
11776 info.info.global_conf.hash_func =
11777 RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ;
11778 else if (!strcmp(res->hash_func, "default"))
11779 info.info.global_conf.hash_func =
11780 RTE_ETH_HASH_FUNCTION_DEFAULT;
11782 ftype = str2flowtype(res->flow_type);
11783 idx = ftype / UINT64_BIT;
11784 offset = ftype % UINT64_BIT;
11785 info.info.global_conf.valid_bit_mask[idx] |= (1ULL << offset);
11786 if (!strcmp(res->enable, "enable"))
11787 info.info.global_conf.sym_hash_enable_mask[idx] |=
11789 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11790 RTE_ETH_FILTER_SET, &info);
11792 printf("Cannot set global hash configurations by port %d\n",
11795 printf("Global hash configurations have been set "
11796 "successfully by port %d\n", res->port_id);
11799 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
11800 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11801 set_hash_global_config, "set_hash_global_config");
11802 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
11803 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
11805 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
11806 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11807 hash_func, "toeplitz#simple_xor#symmetric_toeplitz#default");
11808 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
11809 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11811 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
11812 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
11813 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
11814 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11815 enable, "enable#disable");
11817 cmdline_parse_inst_t cmd_set_hash_global_config = {
11818 .f = cmd_set_hash_global_config_parsed,
11820 .help_str = "set_hash_global_config <port_id> "
11821 "toeplitz|simple_xor|symmetric_toeplitz|default "
11822 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11823 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
11824 "l2_payload enable|disable",
11826 (void *)&cmd_set_hash_global_config_all,
11827 (void *)&cmd_set_hash_global_config_port_id,
11828 (void *)&cmd_set_hash_global_config_hash_func,
11829 (void *)&cmd_set_hash_global_config_flow_type,
11830 (void *)&cmd_set_hash_global_config_enable,
11835 /* Set hash input set */
11836 struct cmd_set_hash_input_set_result {
11837 cmdline_fixed_string_t set_hash_input_set;
11839 cmdline_fixed_string_t flow_type;
11840 cmdline_fixed_string_t inset_field;
11841 cmdline_fixed_string_t select;
11844 static enum rte_eth_input_set_field
11845 str2inset(char *string)
11849 static const struct {
11851 enum rte_eth_input_set_field inset;
11852 } inset_table[] = {
11853 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
11854 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
11855 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
11856 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
11857 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
11858 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
11859 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
11860 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
11861 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
11862 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
11863 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
11864 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
11865 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
11866 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
11867 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
11868 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
11869 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
11870 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
11871 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
11872 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
11873 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
11874 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
11875 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
11876 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
11877 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
11878 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
11879 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
11880 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
11881 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
11882 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
11883 {"none", RTE_ETH_INPUT_SET_NONE},
11886 for (i = 0; i < RTE_DIM(inset_table); i++) {
11887 if (!strcmp(string, inset_table[i].str))
11888 return inset_table[i].inset;
11891 return RTE_ETH_INPUT_SET_UNKNOWN;
11895 cmd_set_hash_input_set_parsed(void *parsed_result,
11896 __rte_unused struct cmdline *cl,
11897 __rte_unused void *data)
11899 struct cmd_set_hash_input_set_result *res = parsed_result;
11900 struct rte_eth_hash_filter_info info;
11902 memset(&info, 0, sizeof(info));
11903 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
11904 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
11905 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
11906 info.info.input_set_conf.inset_size = 1;
11907 if (!strcmp(res->select, "select"))
11908 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
11909 else if (!strcmp(res->select, "add"))
11910 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
11911 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11912 RTE_ETH_FILTER_SET, &info);
11915 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
11916 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11917 set_hash_input_set, "set_hash_input_set");
11918 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
11919 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
11921 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
11922 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11924 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
11925 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11927 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
11928 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
11929 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
11930 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
11931 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
11933 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
11934 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11935 select, "select#add");
11937 cmdline_parse_inst_t cmd_set_hash_input_set = {
11938 .f = cmd_set_hash_input_set_parsed,
11940 .help_str = "set_hash_input_set <port_id> "
11941 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11942 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
11943 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
11944 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
11945 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
11946 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
11947 "fld-7th|fld-8th|none select|add",
11949 (void *)&cmd_set_hash_input_set_cmd,
11950 (void *)&cmd_set_hash_input_set_port_id,
11951 (void *)&cmd_set_hash_input_set_flow_type,
11952 (void *)&cmd_set_hash_input_set_field,
11953 (void *)&cmd_set_hash_input_set_select,
11958 /* Set flow director input set */
11959 struct cmd_set_fdir_input_set_result {
11960 cmdline_fixed_string_t set_fdir_input_set;
11962 cmdline_fixed_string_t flow_type;
11963 cmdline_fixed_string_t inset_field;
11964 cmdline_fixed_string_t select;
11968 cmd_set_fdir_input_set_parsed(void *parsed_result,
11969 __rte_unused struct cmdline *cl,
11970 __rte_unused void *data)
11972 struct cmd_set_fdir_input_set_result *res = parsed_result;
11973 struct rte_eth_fdir_filter_info info;
11975 memset(&info, 0, sizeof(info));
11976 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
11977 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
11978 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
11979 info.info.input_set_conf.inset_size = 1;
11980 if (!strcmp(res->select, "select"))
11981 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
11982 else if (!strcmp(res->select, "add"))
11983 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
11984 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11985 RTE_ETH_FILTER_SET, &info);
11988 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
11989 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11990 set_fdir_input_set, "set_fdir_input_set");
11991 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
11992 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
11994 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
11995 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11997 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
11998 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
11999 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
12000 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12002 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12003 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
12004 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
12005 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
12006 "sctp-veri-tag#none");
12007 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
12008 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12009 select, "select#add");
12011 cmdline_parse_inst_t cmd_set_fdir_input_set = {
12012 .f = cmd_set_fdir_input_set_parsed,
12014 .help_str = "set_fdir_input_set <port_id> "
12015 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12016 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
12017 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
12018 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
12019 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
12020 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
12021 "sctp-veri-tag|none select|add",
12023 (void *)&cmd_set_fdir_input_set_cmd,
12024 (void *)&cmd_set_fdir_input_set_port_id,
12025 (void *)&cmd_set_fdir_input_set_flow_type,
12026 (void *)&cmd_set_fdir_input_set_field,
12027 (void *)&cmd_set_fdir_input_set_select,
12032 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
12033 struct cmd_mcast_addr_result {
12034 cmdline_fixed_string_t mcast_addr_cmd;
12035 cmdline_fixed_string_t what;
12037 struct rte_ether_addr mc_addr;
12040 static void cmd_mcast_addr_parsed(void *parsed_result,
12041 __rte_unused struct cmdline *cl,
12042 __rte_unused void *data)
12044 struct cmd_mcast_addr_result *res = parsed_result;
12046 if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
12047 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
12048 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
12049 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
12050 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
12053 if (strcmp(res->what, "add") == 0)
12054 mcast_addr_add(res->port_num, &res->mc_addr);
12056 mcast_addr_remove(res->port_num, &res->mc_addr);
12059 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
12060 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
12061 mcast_addr_cmd, "mcast_addr");
12062 cmdline_parse_token_string_t cmd_mcast_addr_what =
12063 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
12065 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
12066 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
12067 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
12068 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
12070 cmdline_parse_inst_t cmd_mcast_addr = {
12071 .f = cmd_mcast_addr_parsed,
12073 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
12074 "Add/Remove multicast MAC address on port_id",
12076 (void *)&cmd_mcast_addr_cmd,
12077 (void *)&cmd_mcast_addr_what,
12078 (void *)&cmd_mcast_addr_portnum,
12079 (void *)&cmd_mcast_addr_addr,
12084 /* l2 tunnel config
12085 * only support E-tag now.
12088 /* Ether type config */
12089 struct cmd_config_l2_tunnel_eth_type_result {
12090 cmdline_fixed_string_t port;
12091 cmdline_fixed_string_t config;
12092 cmdline_fixed_string_t all;
12094 cmdline_fixed_string_t l2_tunnel;
12095 cmdline_fixed_string_t l2_tunnel_type;
12096 cmdline_fixed_string_t eth_type;
12097 uint16_t eth_type_val;
12100 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
12101 TOKEN_STRING_INITIALIZER
12102 (struct cmd_config_l2_tunnel_eth_type_result,
12104 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
12105 TOKEN_STRING_INITIALIZER
12106 (struct cmd_config_l2_tunnel_eth_type_result,
12108 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
12109 TOKEN_STRING_INITIALIZER
12110 (struct cmd_config_l2_tunnel_eth_type_result,
12112 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
12113 TOKEN_NUM_INITIALIZER
12114 (struct cmd_config_l2_tunnel_eth_type_result,
12116 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
12117 TOKEN_STRING_INITIALIZER
12118 (struct cmd_config_l2_tunnel_eth_type_result,
12119 l2_tunnel, "l2-tunnel");
12120 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
12121 TOKEN_STRING_INITIALIZER
12122 (struct cmd_config_l2_tunnel_eth_type_result,
12123 l2_tunnel_type, "E-tag");
12124 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
12125 TOKEN_STRING_INITIALIZER
12126 (struct cmd_config_l2_tunnel_eth_type_result,
12127 eth_type, "ether-type");
12128 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
12129 TOKEN_NUM_INITIALIZER
12130 (struct cmd_config_l2_tunnel_eth_type_result,
12131 eth_type_val, UINT16);
12133 static enum rte_eth_tunnel_type
12134 str2fdir_l2_tunnel_type(char *string)
12138 static const struct {
12140 enum rte_eth_tunnel_type type;
12141 } l2_tunnel_type_str[] = {
12142 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
12145 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
12146 if (!strcmp(l2_tunnel_type_str[i].str, string))
12147 return l2_tunnel_type_str[i].type;
12149 return RTE_TUNNEL_TYPE_NONE;
12152 /* ether type config for all ports */
12154 cmd_config_l2_tunnel_eth_type_all_parsed
12155 (void *parsed_result,
12156 __rte_unused struct cmdline *cl,
12157 __rte_unused void *data)
12159 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
12160 struct rte_eth_l2_tunnel_conf entry;
12163 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12164 entry.ether_type = res->eth_type_val;
12166 RTE_ETH_FOREACH_DEV(pid) {
12167 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
12171 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
12172 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
12174 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
12176 (void *)&cmd_config_l2_tunnel_eth_type_port,
12177 (void *)&cmd_config_l2_tunnel_eth_type_config,
12178 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
12179 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12180 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12181 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12182 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12187 /* ether type config for a specific port */
12189 cmd_config_l2_tunnel_eth_type_specific_parsed(
12190 void *parsed_result,
12191 __rte_unused struct cmdline *cl,
12192 __rte_unused void *data)
12194 struct cmd_config_l2_tunnel_eth_type_result *res =
12196 struct rte_eth_l2_tunnel_conf entry;
12198 if (port_id_is_invalid(res->id, ENABLED_WARN))
12201 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12202 entry.ether_type = res->eth_type_val;
12204 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
12207 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
12208 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
12210 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
12212 (void *)&cmd_config_l2_tunnel_eth_type_port,
12213 (void *)&cmd_config_l2_tunnel_eth_type_config,
12214 (void *)&cmd_config_l2_tunnel_eth_type_id,
12215 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12216 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12217 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12218 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12223 /* Enable/disable l2 tunnel */
12224 struct cmd_config_l2_tunnel_en_dis_result {
12225 cmdline_fixed_string_t port;
12226 cmdline_fixed_string_t config;
12227 cmdline_fixed_string_t all;
12229 cmdline_fixed_string_t l2_tunnel;
12230 cmdline_fixed_string_t l2_tunnel_type;
12231 cmdline_fixed_string_t en_dis;
12234 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
12235 TOKEN_STRING_INITIALIZER
12236 (struct cmd_config_l2_tunnel_en_dis_result,
12238 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
12239 TOKEN_STRING_INITIALIZER
12240 (struct cmd_config_l2_tunnel_en_dis_result,
12242 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
12243 TOKEN_STRING_INITIALIZER
12244 (struct cmd_config_l2_tunnel_en_dis_result,
12246 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
12247 TOKEN_NUM_INITIALIZER
12248 (struct cmd_config_l2_tunnel_en_dis_result,
12250 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
12251 TOKEN_STRING_INITIALIZER
12252 (struct cmd_config_l2_tunnel_en_dis_result,
12253 l2_tunnel, "l2-tunnel");
12254 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
12255 TOKEN_STRING_INITIALIZER
12256 (struct cmd_config_l2_tunnel_en_dis_result,
12257 l2_tunnel_type, "E-tag");
12258 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
12259 TOKEN_STRING_INITIALIZER
12260 (struct cmd_config_l2_tunnel_en_dis_result,
12261 en_dis, "enable#disable");
12263 /* enable/disable l2 tunnel for all ports */
12265 cmd_config_l2_tunnel_en_dis_all_parsed(
12266 void *parsed_result,
12267 __rte_unused struct cmdline *cl,
12268 __rte_unused void *data)
12270 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
12271 struct rte_eth_l2_tunnel_conf entry;
12275 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12277 if (!strcmp("enable", res->en_dis))
12282 RTE_ETH_FOREACH_DEV(pid) {
12283 rte_eth_dev_l2_tunnel_offload_set(pid,
12285 ETH_L2_TUNNEL_ENABLE_MASK,
12290 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
12291 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
12293 .help_str = "port config all l2-tunnel E-tag enable|disable",
12295 (void *)&cmd_config_l2_tunnel_en_dis_port,
12296 (void *)&cmd_config_l2_tunnel_en_dis_config,
12297 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
12298 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12299 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12300 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12305 /* enable/disable l2 tunnel for a port */
12307 cmd_config_l2_tunnel_en_dis_specific_parsed(
12308 void *parsed_result,
12309 __rte_unused struct cmdline *cl,
12310 __rte_unused void *data)
12312 struct cmd_config_l2_tunnel_en_dis_result *res =
12314 struct rte_eth_l2_tunnel_conf entry;
12316 if (port_id_is_invalid(res->id, ENABLED_WARN))
12319 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12321 if (!strcmp("enable", res->en_dis))
12322 rte_eth_dev_l2_tunnel_offload_set(res->id,
12324 ETH_L2_TUNNEL_ENABLE_MASK,
12327 rte_eth_dev_l2_tunnel_offload_set(res->id,
12329 ETH_L2_TUNNEL_ENABLE_MASK,
12333 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
12334 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
12336 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
12338 (void *)&cmd_config_l2_tunnel_en_dis_port,
12339 (void *)&cmd_config_l2_tunnel_en_dis_config,
12340 (void *)&cmd_config_l2_tunnel_en_dis_id,
12341 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12342 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12343 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12348 /* E-tag configuration */
12350 /* Common result structure for all E-tag configuration */
12351 struct cmd_config_e_tag_result {
12352 cmdline_fixed_string_t e_tag;
12353 cmdline_fixed_string_t set;
12354 cmdline_fixed_string_t insertion;
12355 cmdline_fixed_string_t stripping;
12356 cmdline_fixed_string_t forwarding;
12357 cmdline_fixed_string_t filter;
12358 cmdline_fixed_string_t add;
12359 cmdline_fixed_string_t del;
12360 cmdline_fixed_string_t on;
12361 cmdline_fixed_string_t off;
12362 cmdline_fixed_string_t on_off;
12363 cmdline_fixed_string_t port_tag_id;
12364 uint32_t port_tag_id_val;
12365 cmdline_fixed_string_t e_tag_id;
12366 uint16_t e_tag_id_val;
12367 cmdline_fixed_string_t dst_pool;
12368 uint8_t dst_pool_val;
12369 cmdline_fixed_string_t port;
12371 cmdline_fixed_string_t vf;
12375 /* Common CLI fields for all E-tag configuration */
12376 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
12377 TOKEN_STRING_INITIALIZER
12378 (struct cmd_config_e_tag_result,
12380 cmdline_parse_token_string_t cmd_config_e_tag_set =
12381 TOKEN_STRING_INITIALIZER
12382 (struct cmd_config_e_tag_result,
12384 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
12385 TOKEN_STRING_INITIALIZER
12386 (struct cmd_config_e_tag_result,
12387 insertion, "insertion");
12388 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
12389 TOKEN_STRING_INITIALIZER
12390 (struct cmd_config_e_tag_result,
12391 stripping, "stripping");
12392 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
12393 TOKEN_STRING_INITIALIZER
12394 (struct cmd_config_e_tag_result,
12395 forwarding, "forwarding");
12396 cmdline_parse_token_string_t cmd_config_e_tag_filter =
12397 TOKEN_STRING_INITIALIZER
12398 (struct cmd_config_e_tag_result,
12400 cmdline_parse_token_string_t cmd_config_e_tag_add =
12401 TOKEN_STRING_INITIALIZER
12402 (struct cmd_config_e_tag_result,
12404 cmdline_parse_token_string_t cmd_config_e_tag_del =
12405 TOKEN_STRING_INITIALIZER
12406 (struct cmd_config_e_tag_result,
12408 cmdline_parse_token_string_t cmd_config_e_tag_on =
12409 TOKEN_STRING_INITIALIZER
12410 (struct cmd_config_e_tag_result,
12412 cmdline_parse_token_string_t cmd_config_e_tag_off =
12413 TOKEN_STRING_INITIALIZER
12414 (struct cmd_config_e_tag_result,
12416 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
12417 TOKEN_STRING_INITIALIZER
12418 (struct cmd_config_e_tag_result,
12420 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
12421 TOKEN_STRING_INITIALIZER
12422 (struct cmd_config_e_tag_result,
12423 port_tag_id, "port-tag-id");
12424 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
12425 TOKEN_NUM_INITIALIZER
12426 (struct cmd_config_e_tag_result,
12427 port_tag_id_val, UINT32);
12428 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
12429 TOKEN_STRING_INITIALIZER
12430 (struct cmd_config_e_tag_result,
12431 e_tag_id, "e-tag-id");
12432 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
12433 TOKEN_NUM_INITIALIZER
12434 (struct cmd_config_e_tag_result,
12435 e_tag_id_val, UINT16);
12436 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
12437 TOKEN_STRING_INITIALIZER
12438 (struct cmd_config_e_tag_result,
12439 dst_pool, "dst-pool");
12440 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
12441 TOKEN_NUM_INITIALIZER
12442 (struct cmd_config_e_tag_result,
12443 dst_pool_val, UINT8);
12444 cmdline_parse_token_string_t cmd_config_e_tag_port =
12445 TOKEN_STRING_INITIALIZER
12446 (struct cmd_config_e_tag_result,
12448 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
12449 TOKEN_NUM_INITIALIZER
12450 (struct cmd_config_e_tag_result,
12452 cmdline_parse_token_string_t cmd_config_e_tag_vf =
12453 TOKEN_STRING_INITIALIZER
12454 (struct cmd_config_e_tag_result,
12456 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
12457 TOKEN_NUM_INITIALIZER
12458 (struct cmd_config_e_tag_result,
12461 /* E-tag insertion configuration */
12463 cmd_config_e_tag_insertion_en_parsed(
12464 void *parsed_result,
12465 __rte_unused struct cmdline *cl,
12466 __rte_unused void *data)
12468 struct cmd_config_e_tag_result *res =
12470 struct rte_eth_l2_tunnel_conf entry;
12472 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12475 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12476 entry.tunnel_id = res->port_tag_id_val;
12477 entry.vf_id = res->vf_id;
12478 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12480 ETH_L2_TUNNEL_INSERTION_MASK,
12485 cmd_config_e_tag_insertion_dis_parsed(
12486 void *parsed_result,
12487 __rte_unused struct cmdline *cl,
12488 __rte_unused void *data)
12490 struct cmd_config_e_tag_result *res =
12492 struct rte_eth_l2_tunnel_conf entry;
12494 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12497 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12498 entry.vf_id = res->vf_id;
12500 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12502 ETH_L2_TUNNEL_INSERTION_MASK,
12506 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
12507 .f = cmd_config_e_tag_insertion_en_parsed,
12509 .help_str = "E-tag ... : E-tag insertion enable",
12511 (void *)&cmd_config_e_tag_e_tag,
12512 (void *)&cmd_config_e_tag_set,
12513 (void *)&cmd_config_e_tag_insertion,
12514 (void *)&cmd_config_e_tag_on,
12515 (void *)&cmd_config_e_tag_port_tag_id,
12516 (void *)&cmd_config_e_tag_port_tag_id_val,
12517 (void *)&cmd_config_e_tag_port,
12518 (void *)&cmd_config_e_tag_port_id,
12519 (void *)&cmd_config_e_tag_vf,
12520 (void *)&cmd_config_e_tag_vf_id,
12525 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
12526 .f = cmd_config_e_tag_insertion_dis_parsed,
12528 .help_str = "E-tag ... : E-tag insertion disable",
12530 (void *)&cmd_config_e_tag_e_tag,
12531 (void *)&cmd_config_e_tag_set,
12532 (void *)&cmd_config_e_tag_insertion,
12533 (void *)&cmd_config_e_tag_off,
12534 (void *)&cmd_config_e_tag_port,
12535 (void *)&cmd_config_e_tag_port_id,
12536 (void *)&cmd_config_e_tag_vf,
12537 (void *)&cmd_config_e_tag_vf_id,
12542 /* E-tag stripping configuration */
12544 cmd_config_e_tag_stripping_parsed(
12545 void *parsed_result,
12546 __rte_unused struct cmdline *cl,
12547 __rte_unused void *data)
12549 struct cmd_config_e_tag_result *res =
12551 struct rte_eth_l2_tunnel_conf entry;
12553 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12556 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12558 if (!strcmp(res->on_off, "on"))
12559 rte_eth_dev_l2_tunnel_offload_set
12562 ETH_L2_TUNNEL_STRIPPING_MASK,
12565 rte_eth_dev_l2_tunnel_offload_set
12568 ETH_L2_TUNNEL_STRIPPING_MASK,
12572 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
12573 .f = cmd_config_e_tag_stripping_parsed,
12575 .help_str = "E-tag ... : E-tag stripping enable/disable",
12577 (void *)&cmd_config_e_tag_e_tag,
12578 (void *)&cmd_config_e_tag_set,
12579 (void *)&cmd_config_e_tag_stripping,
12580 (void *)&cmd_config_e_tag_on_off,
12581 (void *)&cmd_config_e_tag_port,
12582 (void *)&cmd_config_e_tag_port_id,
12587 /* E-tag forwarding configuration */
12589 cmd_config_e_tag_forwarding_parsed(
12590 void *parsed_result,
12591 __rte_unused struct cmdline *cl,
12592 __rte_unused void *data)
12594 struct cmd_config_e_tag_result *res = parsed_result;
12595 struct rte_eth_l2_tunnel_conf entry;
12597 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12600 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12602 if (!strcmp(res->on_off, "on"))
12603 rte_eth_dev_l2_tunnel_offload_set
12606 ETH_L2_TUNNEL_FORWARDING_MASK,
12609 rte_eth_dev_l2_tunnel_offload_set
12612 ETH_L2_TUNNEL_FORWARDING_MASK,
12616 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
12617 .f = cmd_config_e_tag_forwarding_parsed,
12619 .help_str = "E-tag ... : E-tag forwarding enable/disable",
12621 (void *)&cmd_config_e_tag_e_tag,
12622 (void *)&cmd_config_e_tag_set,
12623 (void *)&cmd_config_e_tag_forwarding,
12624 (void *)&cmd_config_e_tag_on_off,
12625 (void *)&cmd_config_e_tag_port,
12626 (void *)&cmd_config_e_tag_port_id,
12631 /* E-tag filter configuration */
12633 cmd_config_e_tag_filter_add_parsed(
12634 void *parsed_result,
12635 __rte_unused struct cmdline *cl,
12636 __rte_unused void *data)
12638 struct cmd_config_e_tag_result *res = parsed_result;
12639 struct rte_eth_l2_tunnel_conf entry;
12642 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12645 if (res->e_tag_id_val > 0x3fff) {
12646 printf("e-tag-id must be equal or less than 0x3fff.\n");
12650 ret = rte_eth_dev_filter_supported(res->port_id,
12651 RTE_ETH_FILTER_L2_TUNNEL);
12653 printf("E-tag filter is not supported on port %u.\n",
12658 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12659 entry.tunnel_id = res->e_tag_id_val;
12660 entry.pool = res->dst_pool_val;
12662 ret = rte_eth_dev_filter_ctrl(res->port_id,
12663 RTE_ETH_FILTER_L2_TUNNEL,
12664 RTE_ETH_FILTER_ADD,
12667 printf("E-tag filter programming error: (%s)\n",
12671 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
12672 .f = cmd_config_e_tag_filter_add_parsed,
12674 .help_str = "E-tag ... : E-tag filter add",
12676 (void *)&cmd_config_e_tag_e_tag,
12677 (void *)&cmd_config_e_tag_set,
12678 (void *)&cmd_config_e_tag_filter,
12679 (void *)&cmd_config_e_tag_add,
12680 (void *)&cmd_config_e_tag_e_tag_id,
12681 (void *)&cmd_config_e_tag_e_tag_id_val,
12682 (void *)&cmd_config_e_tag_dst_pool,
12683 (void *)&cmd_config_e_tag_dst_pool_val,
12684 (void *)&cmd_config_e_tag_port,
12685 (void *)&cmd_config_e_tag_port_id,
12691 cmd_config_e_tag_filter_del_parsed(
12692 void *parsed_result,
12693 __rte_unused struct cmdline *cl,
12694 __rte_unused void *data)
12696 struct cmd_config_e_tag_result *res = parsed_result;
12697 struct rte_eth_l2_tunnel_conf entry;
12700 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12703 if (res->e_tag_id_val > 0x3fff) {
12704 printf("e-tag-id must be less than 0x3fff.\n");
12708 ret = rte_eth_dev_filter_supported(res->port_id,
12709 RTE_ETH_FILTER_L2_TUNNEL);
12711 printf("E-tag filter is not supported on port %u.\n",
12716 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12717 entry.tunnel_id = res->e_tag_id_val;
12719 ret = rte_eth_dev_filter_ctrl(res->port_id,
12720 RTE_ETH_FILTER_L2_TUNNEL,
12721 RTE_ETH_FILTER_DELETE,
12724 printf("E-tag filter programming error: (%s)\n",
12728 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
12729 .f = cmd_config_e_tag_filter_del_parsed,
12731 .help_str = "E-tag ... : E-tag filter delete",
12733 (void *)&cmd_config_e_tag_e_tag,
12734 (void *)&cmd_config_e_tag_set,
12735 (void *)&cmd_config_e_tag_filter,
12736 (void *)&cmd_config_e_tag_del,
12737 (void *)&cmd_config_e_tag_e_tag_id,
12738 (void *)&cmd_config_e_tag_e_tag_id_val,
12739 (void *)&cmd_config_e_tag_port,
12740 (void *)&cmd_config_e_tag_port_id,
12745 /* vf vlan anti spoof configuration */
12747 /* Common result structure for vf vlan anti spoof */
12748 struct cmd_vf_vlan_anti_spoof_result {
12749 cmdline_fixed_string_t set;
12750 cmdline_fixed_string_t vf;
12751 cmdline_fixed_string_t vlan;
12752 cmdline_fixed_string_t antispoof;
12755 cmdline_fixed_string_t on_off;
12758 /* Common CLI fields for vf vlan anti spoof enable disable */
12759 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
12760 TOKEN_STRING_INITIALIZER
12761 (struct cmd_vf_vlan_anti_spoof_result,
12763 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
12764 TOKEN_STRING_INITIALIZER
12765 (struct cmd_vf_vlan_anti_spoof_result,
12767 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
12768 TOKEN_STRING_INITIALIZER
12769 (struct cmd_vf_vlan_anti_spoof_result,
12771 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
12772 TOKEN_STRING_INITIALIZER
12773 (struct cmd_vf_vlan_anti_spoof_result,
12774 antispoof, "antispoof");
12775 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
12776 TOKEN_NUM_INITIALIZER
12777 (struct cmd_vf_vlan_anti_spoof_result,
12779 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
12780 TOKEN_NUM_INITIALIZER
12781 (struct cmd_vf_vlan_anti_spoof_result,
12783 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
12784 TOKEN_STRING_INITIALIZER
12785 (struct cmd_vf_vlan_anti_spoof_result,
12789 cmd_set_vf_vlan_anti_spoof_parsed(
12790 void *parsed_result,
12791 __rte_unused struct cmdline *cl,
12792 __rte_unused void *data)
12794 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
12795 int ret = -ENOTSUP;
12797 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12799 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12802 #ifdef RTE_NET_IXGBE
12803 if (ret == -ENOTSUP)
12804 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
12805 res->vf_id, is_on);
12807 #ifdef RTE_NET_I40E
12808 if (ret == -ENOTSUP)
12809 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
12810 res->vf_id, is_on);
12812 #ifdef RTE_NET_BNXT
12813 if (ret == -ENOTSUP)
12814 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
12815 res->vf_id, is_on);
12822 printf("invalid vf_id %d\n", res->vf_id);
12825 printf("invalid port_id %d\n", res->port_id);
12828 printf("function not implemented\n");
12831 printf("programming error: (%s)\n", strerror(-ret));
12835 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
12836 .f = cmd_set_vf_vlan_anti_spoof_parsed,
12838 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
12840 (void *)&cmd_vf_vlan_anti_spoof_set,
12841 (void *)&cmd_vf_vlan_anti_spoof_vf,
12842 (void *)&cmd_vf_vlan_anti_spoof_vlan,
12843 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
12844 (void *)&cmd_vf_vlan_anti_spoof_port_id,
12845 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
12846 (void *)&cmd_vf_vlan_anti_spoof_on_off,
12851 /* vf mac anti spoof configuration */
12853 /* Common result structure for vf mac anti spoof */
12854 struct cmd_vf_mac_anti_spoof_result {
12855 cmdline_fixed_string_t set;
12856 cmdline_fixed_string_t vf;
12857 cmdline_fixed_string_t mac;
12858 cmdline_fixed_string_t antispoof;
12861 cmdline_fixed_string_t on_off;
12864 /* Common CLI fields for vf mac anti spoof enable disable */
12865 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
12866 TOKEN_STRING_INITIALIZER
12867 (struct cmd_vf_mac_anti_spoof_result,
12869 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
12870 TOKEN_STRING_INITIALIZER
12871 (struct cmd_vf_mac_anti_spoof_result,
12873 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
12874 TOKEN_STRING_INITIALIZER
12875 (struct cmd_vf_mac_anti_spoof_result,
12877 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
12878 TOKEN_STRING_INITIALIZER
12879 (struct cmd_vf_mac_anti_spoof_result,
12880 antispoof, "antispoof");
12881 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
12882 TOKEN_NUM_INITIALIZER
12883 (struct cmd_vf_mac_anti_spoof_result,
12885 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
12886 TOKEN_NUM_INITIALIZER
12887 (struct cmd_vf_mac_anti_spoof_result,
12889 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
12890 TOKEN_STRING_INITIALIZER
12891 (struct cmd_vf_mac_anti_spoof_result,
12895 cmd_set_vf_mac_anti_spoof_parsed(
12896 void *parsed_result,
12897 __rte_unused struct cmdline *cl,
12898 __rte_unused void *data)
12900 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
12901 int ret = -ENOTSUP;
12903 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12905 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12908 #ifdef RTE_NET_IXGBE
12909 if (ret == -ENOTSUP)
12910 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
12911 res->vf_id, is_on);
12913 #ifdef RTE_NET_I40E
12914 if (ret == -ENOTSUP)
12915 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
12916 res->vf_id, is_on);
12918 #ifdef RTE_NET_BNXT
12919 if (ret == -ENOTSUP)
12920 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
12921 res->vf_id, is_on);
12928 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12931 printf("invalid port_id %d\n", res->port_id);
12934 printf("function not implemented\n");
12937 printf("programming error: (%s)\n", strerror(-ret));
12941 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
12942 .f = cmd_set_vf_mac_anti_spoof_parsed,
12944 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
12946 (void *)&cmd_vf_mac_anti_spoof_set,
12947 (void *)&cmd_vf_mac_anti_spoof_vf,
12948 (void *)&cmd_vf_mac_anti_spoof_mac,
12949 (void *)&cmd_vf_mac_anti_spoof_antispoof,
12950 (void *)&cmd_vf_mac_anti_spoof_port_id,
12951 (void *)&cmd_vf_mac_anti_spoof_vf_id,
12952 (void *)&cmd_vf_mac_anti_spoof_on_off,
12957 /* vf vlan strip queue configuration */
12959 /* Common result structure for vf mac anti spoof */
12960 struct cmd_vf_vlan_stripq_result {
12961 cmdline_fixed_string_t set;
12962 cmdline_fixed_string_t vf;
12963 cmdline_fixed_string_t vlan;
12964 cmdline_fixed_string_t stripq;
12967 cmdline_fixed_string_t on_off;
12970 /* Common CLI fields for vf vlan strip enable disable */
12971 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
12972 TOKEN_STRING_INITIALIZER
12973 (struct cmd_vf_vlan_stripq_result,
12975 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
12976 TOKEN_STRING_INITIALIZER
12977 (struct cmd_vf_vlan_stripq_result,
12979 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
12980 TOKEN_STRING_INITIALIZER
12981 (struct cmd_vf_vlan_stripq_result,
12983 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
12984 TOKEN_STRING_INITIALIZER
12985 (struct cmd_vf_vlan_stripq_result,
12987 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
12988 TOKEN_NUM_INITIALIZER
12989 (struct cmd_vf_vlan_stripq_result,
12991 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
12992 TOKEN_NUM_INITIALIZER
12993 (struct cmd_vf_vlan_stripq_result,
12995 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
12996 TOKEN_STRING_INITIALIZER
12997 (struct cmd_vf_vlan_stripq_result,
13001 cmd_set_vf_vlan_stripq_parsed(
13002 void *parsed_result,
13003 __rte_unused struct cmdline *cl,
13004 __rte_unused void *data)
13006 struct cmd_vf_vlan_stripq_result *res = parsed_result;
13007 int ret = -ENOTSUP;
13009 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13011 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13014 #ifdef RTE_NET_IXGBE
13015 if (ret == -ENOTSUP)
13016 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
13017 res->vf_id, is_on);
13019 #ifdef RTE_NET_I40E
13020 if (ret == -ENOTSUP)
13021 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
13022 res->vf_id, is_on);
13024 #ifdef RTE_NET_BNXT
13025 if (ret == -ENOTSUP)
13026 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
13027 res->vf_id, is_on);
13034 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13037 printf("invalid port_id %d\n", res->port_id);
13040 printf("function not implemented\n");
13043 printf("programming error: (%s)\n", strerror(-ret));
13047 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
13048 .f = cmd_set_vf_vlan_stripq_parsed,
13050 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
13052 (void *)&cmd_vf_vlan_stripq_set,
13053 (void *)&cmd_vf_vlan_stripq_vf,
13054 (void *)&cmd_vf_vlan_stripq_vlan,
13055 (void *)&cmd_vf_vlan_stripq_stripq,
13056 (void *)&cmd_vf_vlan_stripq_port_id,
13057 (void *)&cmd_vf_vlan_stripq_vf_id,
13058 (void *)&cmd_vf_vlan_stripq_on_off,
13063 /* vf vlan insert configuration */
13065 /* Common result structure for vf vlan insert */
13066 struct cmd_vf_vlan_insert_result {
13067 cmdline_fixed_string_t set;
13068 cmdline_fixed_string_t vf;
13069 cmdline_fixed_string_t vlan;
13070 cmdline_fixed_string_t insert;
13076 /* Common CLI fields for vf vlan insert enable disable */
13077 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
13078 TOKEN_STRING_INITIALIZER
13079 (struct cmd_vf_vlan_insert_result,
13081 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
13082 TOKEN_STRING_INITIALIZER
13083 (struct cmd_vf_vlan_insert_result,
13085 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
13086 TOKEN_STRING_INITIALIZER
13087 (struct cmd_vf_vlan_insert_result,
13089 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
13090 TOKEN_STRING_INITIALIZER
13091 (struct cmd_vf_vlan_insert_result,
13093 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
13094 TOKEN_NUM_INITIALIZER
13095 (struct cmd_vf_vlan_insert_result,
13097 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
13098 TOKEN_NUM_INITIALIZER
13099 (struct cmd_vf_vlan_insert_result,
13101 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
13102 TOKEN_NUM_INITIALIZER
13103 (struct cmd_vf_vlan_insert_result,
13107 cmd_set_vf_vlan_insert_parsed(
13108 void *parsed_result,
13109 __rte_unused struct cmdline *cl,
13110 __rte_unused void *data)
13112 struct cmd_vf_vlan_insert_result *res = parsed_result;
13113 int ret = -ENOTSUP;
13115 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13118 #ifdef RTE_NET_IXGBE
13119 if (ret == -ENOTSUP)
13120 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
13123 #ifdef RTE_NET_I40E
13124 if (ret == -ENOTSUP)
13125 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
13128 #ifdef RTE_NET_BNXT
13129 if (ret == -ENOTSUP)
13130 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
13138 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
13141 printf("invalid port_id %d\n", res->port_id);
13144 printf("function not implemented\n");
13147 printf("programming error: (%s)\n", strerror(-ret));
13151 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
13152 .f = cmd_set_vf_vlan_insert_parsed,
13154 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
13156 (void *)&cmd_vf_vlan_insert_set,
13157 (void *)&cmd_vf_vlan_insert_vf,
13158 (void *)&cmd_vf_vlan_insert_vlan,
13159 (void *)&cmd_vf_vlan_insert_insert,
13160 (void *)&cmd_vf_vlan_insert_port_id,
13161 (void *)&cmd_vf_vlan_insert_vf_id,
13162 (void *)&cmd_vf_vlan_insert_vlan_id,
13167 /* tx loopback configuration */
13169 /* Common result structure for tx loopback */
13170 struct cmd_tx_loopback_result {
13171 cmdline_fixed_string_t set;
13172 cmdline_fixed_string_t tx;
13173 cmdline_fixed_string_t loopback;
13175 cmdline_fixed_string_t on_off;
13178 /* Common CLI fields for tx loopback enable disable */
13179 cmdline_parse_token_string_t cmd_tx_loopback_set =
13180 TOKEN_STRING_INITIALIZER
13181 (struct cmd_tx_loopback_result,
13183 cmdline_parse_token_string_t cmd_tx_loopback_tx =
13184 TOKEN_STRING_INITIALIZER
13185 (struct cmd_tx_loopback_result,
13187 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
13188 TOKEN_STRING_INITIALIZER
13189 (struct cmd_tx_loopback_result,
13190 loopback, "loopback");
13191 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
13192 TOKEN_NUM_INITIALIZER
13193 (struct cmd_tx_loopback_result,
13195 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
13196 TOKEN_STRING_INITIALIZER
13197 (struct cmd_tx_loopback_result,
13201 cmd_set_tx_loopback_parsed(
13202 void *parsed_result,
13203 __rte_unused struct cmdline *cl,
13204 __rte_unused void *data)
13206 struct cmd_tx_loopback_result *res = parsed_result;
13207 int ret = -ENOTSUP;
13209 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13211 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13214 #ifdef RTE_NET_IXGBE
13215 if (ret == -ENOTSUP)
13216 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
13218 #ifdef RTE_NET_I40E
13219 if (ret == -ENOTSUP)
13220 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
13222 #ifdef RTE_NET_BNXT
13223 if (ret == -ENOTSUP)
13224 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
13226 #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA
13227 if (ret == -ENOTSUP)
13228 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
13235 printf("invalid is_on %d\n", is_on);
13238 printf("invalid port_id %d\n", res->port_id);
13241 printf("function not implemented\n");
13244 printf("programming error: (%s)\n", strerror(-ret));
13248 cmdline_parse_inst_t cmd_set_tx_loopback = {
13249 .f = cmd_set_tx_loopback_parsed,
13251 .help_str = "set tx loopback <port_id> on|off",
13253 (void *)&cmd_tx_loopback_set,
13254 (void *)&cmd_tx_loopback_tx,
13255 (void *)&cmd_tx_loopback_loopback,
13256 (void *)&cmd_tx_loopback_port_id,
13257 (void *)&cmd_tx_loopback_on_off,
13262 /* all queues drop enable configuration */
13264 /* Common result structure for all queues drop enable */
13265 struct cmd_all_queues_drop_en_result {
13266 cmdline_fixed_string_t set;
13267 cmdline_fixed_string_t all;
13268 cmdline_fixed_string_t queues;
13269 cmdline_fixed_string_t drop;
13271 cmdline_fixed_string_t on_off;
13274 /* Common CLI fields for tx loopback enable disable */
13275 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
13276 TOKEN_STRING_INITIALIZER
13277 (struct cmd_all_queues_drop_en_result,
13279 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
13280 TOKEN_STRING_INITIALIZER
13281 (struct cmd_all_queues_drop_en_result,
13283 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
13284 TOKEN_STRING_INITIALIZER
13285 (struct cmd_all_queues_drop_en_result,
13287 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
13288 TOKEN_STRING_INITIALIZER
13289 (struct cmd_all_queues_drop_en_result,
13291 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
13292 TOKEN_NUM_INITIALIZER
13293 (struct cmd_all_queues_drop_en_result,
13295 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
13296 TOKEN_STRING_INITIALIZER
13297 (struct cmd_all_queues_drop_en_result,
13301 cmd_set_all_queues_drop_en_parsed(
13302 void *parsed_result,
13303 __rte_unused struct cmdline *cl,
13304 __rte_unused void *data)
13306 struct cmd_all_queues_drop_en_result *res = parsed_result;
13307 int ret = -ENOTSUP;
13308 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13310 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13313 #ifdef RTE_NET_IXGBE
13314 if (ret == -ENOTSUP)
13315 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
13317 #ifdef RTE_NET_BNXT
13318 if (ret == -ENOTSUP)
13319 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
13325 printf("invalid is_on %d\n", is_on);
13328 printf("invalid port_id %d\n", res->port_id);
13331 printf("function not implemented\n");
13334 printf("programming error: (%s)\n", strerror(-ret));
13338 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
13339 .f = cmd_set_all_queues_drop_en_parsed,
13341 .help_str = "set all queues drop <port_id> on|off",
13343 (void *)&cmd_all_queues_drop_en_set,
13344 (void *)&cmd_all_queues_drop_en_all,
13345 (void *)&cmd_all_queues_drop_en_queues,
13346 (void *)&cmd_all_queues_drop_en_drop,
13347 (void *)&cmd_all_queues_drop_en_port_id,
13348 (void *)&cmd_all_queues_drop_en_on_off,
13353 /* vf split drop enable configuration */
13355 /* Common result structure for vf split drop enable */
13356 struct cmd_vf_split_drop_en_result {
13357 cmdline_fixed_string_t set;
13358 cmdline_fixed_string_t vf;
13359 cmdline_fixed_string_t split;
13360 cmdline_fixed_string_t drop;
13363 cmdline_fixed_string_t on_off;
13366 /* Common CLI fields for vf split drop enable disable */
13367 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
13368 TOKEN_STRING_INITIALIZER
13369 (struct cmd_vf_split_drop_en_result,
13371 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
13372 TOKEN_STRING_INITIALIZER
13373 (struct cmd_vf_split_drop_en_result,
13375 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
13376 TOKEN_STRING_INITIALIZER
13377 (struct cmd_vf_split_drop_en_result,
13379 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
13380 TOKEN_STRING_INITIALIZER
13381 (struct cmd_vf_split_drop_en_result,
13383 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
13384 TOKEN_NUM_INITIALIZER
13385 (struct cmd_vf_split_drop_en_result,
13387 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
13388 TOKEN_NUM_INITIALIZER
13389 (struct cmd_vf_split_drop_en_result,
13391 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
13392 TOKEN_STRING_INITIALIZER
13393 (struct cmd_vf_split_drop_en_result,
13397 cmd_set_vf_split_drop_en_parsed(
13398 void *parsed_result,
13399 __rte_unused struct cmdline *cl,
13400 __rte_unused void *data)
13402 struct cmd_vf_split_drop_en_result *res = parsed_result;
13403 int ret = -ENOTSUP;
13404 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13406 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13409 #ifdef RTE_NET_IXGBE
13410 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
13417 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13420 printf("invalid port_id %d\n", res->port_id);
13423 printf("not supported on port %d\n", res->port_id);
13426 printf("programming error: (%s)\n", strerror(-ret));
13430 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
13431 .f = cmd_set_vf_split_drop_en_parsed,
13433 .help_str = "set vf split drop <port_id> <vf_id> on|off",
13435 (void *)&cmd_vf_split_drop_en_set,
13436 (void *)&cmd_vf_split_drop_en_vf,
13437 (void *)&cmd_vf_split_drop_en_split,
13438 (void *)&cmd_vf_split_drop_en_drop,
13439 (void *)&cmd_vf_split_drop_en_port_id,
13440 (void *)&cmd_vf_split_drop_en_vf_id,
13441 (void *)&cmd_vf_split_drop_en_on_off,
13446 /* vf mac address configuration */
13448 /* Common result structure for vf mac address */
13449 struct cmd_set_vf_mac_addr_result {
13450 cmdline_fixed_string_t set;
13451 cmdline_fixed_string_t vf;
13452 cmdline_fixed_string_t mac;
13453 cmdline_fixed_string_t addr;
13456 struct rte_ether_addr mac_addr;
13460 /* Common CLI fields for vf split drop enable disable */
13461 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
13462 TOKEN_STRING_INITIALIZER
13463 (struct cmd_set_vf_mac_addr_result,
13465 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
13466 TOKEN_STRING_INITIALIZER
13467 (struct cmd_set_vf_mac_addr_result,
13469 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
13470 TOKEN_STRING_INITIALIZER
13471 (struct cmd_set_vf_mac_addr_result,
13473 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
13474 TOKEN_STRING_INITIALIZER
13475 (struct cmd_set_vf_mac_addr_result,
13477 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
13478 TOKEN_NUM_INITIALIZER
13479 (struct cmd_set_vf_mac_addr_result,
13481 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
13482 TOKEN_NUM_INITIALIZER
13483 (struct cmd_set_vf_mac_addr_result,
13485 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
13486 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
13490 cmd_set_vf_mac_addr_parsed(
13491 void *parsed_result,
13492 __rte_unused struct cmdline *cl,
13493 __rte_unused void *data)
13495 struct cmd_set_vf_mac_addr_result *res = parsed_result;
13496 int ret = -ENOTSUP;
13498 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13501 #ifdef RTE_NET_IXGBE
13502 if (ret == -ENOTSUP)
13503 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
13506 #ifdef RTE_NET_I40E
13507 if (ret == -ENOTSUP)
13508 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
13511 #ifdef RTE_NET_BNXT
13512 if (ret == -ENOTSUP)
13513 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
13521 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
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_addr = {
13535 .f = cmd_set_vf_mac_addr_parsed,
13537 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
13539 (void *)&cmd_set_vf_mac_addr_set,
13540 (void *)&cmd_set_vf_mac_addr_vf,
13541 (void *)&cmd_set_vf_mac_addr_mac,
13542 (void *)&cmd_set_vf_mac_addr_addr,
13543 (void *)&cmd_set_vf_mac_addr_port_id,
13544 (void *)&cmd_set_vf_mac_addr_vf_id,
13545 (void *)&cmd_set_vf_mac_addr_mac_addr,
13550 /* MACsec configuration */
13552 /* Common result structure for MACsec offload enable */
13553 struct cmd_macsec_offload_on_result {
13554 cmdline_fixed_string_t set;
13555 cmdline_fixed_string_t macsec;
13556 cmdline_fixed_string_t offload;
13558 cmdline_fixed_string_t on;
13559 cmdline_fixed_string_t encrypt;
13560 cmdline_fixed_string_t en_on_off;
13561 cmdline_fixed_string_t replay_protect;
13562 cmdline_fixed_string_t rp_on_off;
13565 /* Common CLI fields for MACsec offload disable */
13566 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
13567 TOKEN_STRING_INITIALIZER
13568 (struct cmd_macsec_offload_on_result,
13570 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
13571 TOKEN_STRING_INITIALIZER
13572 (struct cmd_macsec_offload_on_result,
13574 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
13575 TOKEN_STRING_INITIALIZER
13576 (struct cmd_macsec_offload_on_result,
13577 offload, "offload");
13578 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
13579 TOKEN_NUM_INITIALIZER
13580 (struct cmd_macsec_offload_on_result,
13582 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
13583 TOKEN_STRING_INITIALIZER
13584 (struct cmd_macsec_offload_on_result,
13586 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
13587 TOKEN_STRING_INITIALIZER
13588 (struct cmd_macsec_offload_on_result,
13589 encrypt, "encrypt");
13590 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
13591 TOKEN_STRING_INITIALIZER
13592 (struct cmd_macsec_offload_on_result,
13593 en_on_off, "on#off");
13594 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
13595 TOKEN_STRING_INITIALIZER
13596 (struct cmd_macsec_offload_on_result,
13597 replay_protect, "replay-protect");
13598 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
13599 TOKEN_STRING_INITIALIZER
13600 (struct cmd_macsec_offload_on_result,
13601 rp_on_off, "on#off");
13604 cmd_set_macsec_offload_on_parsed(
13605 void *parsed_result,
13606 __rte_unused struct cmdline *cl,
13607 __rte_unused void *data)
13609 struct cmd_macsec_offload_on_result *res = parsed_result;
13610 int ret = -ENOTSUP;
13611 portid_t port_id = res->port_id;
13612 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
13613 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
13614 struct rte_eth_dev_info dev_info;
13616 if (port_id_is_invalid(port_id, ENABLED_WARN))
13618 if (!port_is_stopped(port_id)) {
13619 printf("Please stop port %d first\n", port_id);
13623 ret = eth_dev_info_get_print_err(port_id, &dev_info);
13627 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
13628 #ifdef RTE_NET_IXGBE
13629 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
13637 ports[port_id].dev_conf.txmode.offloads |=
13638 DEV_TX_OFFLOAD_MACSEC_INSERT;
13639 cmd_reconfig_device_queue(port_id, 1, 1);
13642 printf("invalid port_id %d\n", port_id);
13645 printf("not supported on port %d\n", port_id);
13648 printf("programming error: (%s)\n", strerror(-ret));
13652 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
13653 .f = cmd_set_macsec_offload_on_parsed,
13655 .help_str = "set macsec offload <port_id> on "
13656 "encrypt on|off replay-protect on|off",
13658 (void *)&cmd_macsec_offload_on_set,
13659 (void *)&cmd_macsec_offload_on_macsec,
13660 (void *)&cmd_macsec_offload_on_offload,
13661 (void *)&cmd_macsec_offload_on_port_id,
13662 (void *)&cmd_macsec_offload_on_on,
13663 (void *)&cmd_macsec_offload_on_encrypt,
13664 (void *)&cmd_macsec_offload_on_en_on_off,
13665 (void *)&cmd_macsec_offload_on_replay_protect,
13666 (void *)&cmd_macsec_offload_on_rp_on_off,
13671 /* Common result structure for MACsec offload disable */
13672 struct cmd_macsec_offload_off_result {
13673 cmdline_fixed_string_t set;
13674 cmdline_fixed_string_t macsec;
13675 cmdline_fixed_string_t offload;
13677 cmdline_fixed_string_t off;
13680 /* Common CLI fields for MACsec offload disable */
13681 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
13682 TOKEN_STRING_INITIALIZER
13683 (struct cmd_macsec_offload_off_result,
13685 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
13686 TOKEN_STRING_INITIALIZER
13687 (struct cmd_macsec_offload_off_result,
13689 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
13690 TOKEN_STRING_INITIALIZER
13691 (struct cmd_macsec_offload_off_result,
13692 offload, "offload");
13693 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
13694 TOKEN_NUM_INITIALIZER
13695 (struct cmd_macsec_offload_off_result,
13697 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
13698 TOKEN_STRING_INITIALIZER
13699 (struct cmd_macsec_offload_off_result,
13703 cmd_set_macsec_offload_off_parsed(
13704 void *parsed_result,
13705 __rte_unused struct cmdline *cl,
13706 __rte_unused void *data)
13708 struct cmd_macsec_offload_off_result *res = parsed_result;
13709 int ret = -ENOTSUP;
13710 struct rte_eth_dev_info dev_info;
13711 portid_t port_id = res->port_id;
13713 if (port_id_is_invalid(port_id, ENABLED_WARN))
13715 if (!port_is_stopped(port_id)) {
13716 printf("Please stop port %d first\n", port_id);
13720 ret = eth_dev_info_get_print_err(port_id, &dev_info);
13724 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
13725 #ifdef RTE_NET_IXGBE
13726 ret = rte_pmd_ixgbe_macsec_disable(port_id);
13731 ports[port_id].dev_conf.txmode.offloads &=
13732 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
13733 cmd_reconfig_device_queue(port_id, 1, 1);
13736 printf("invalid port_id %d\n", port_id);
13739 printf("not supported on port %d\n", port_id);
13742 printf("programming error: (%s)\n", strerror(-ret));
13746 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
13747 .f = cmd_set_macsec_offload_off_parsed,
13749 .help_str = "set macsec offload <port_id> off",
13751 (void *)&cmd_macsec_offload_off_set,
13752 (void *)&cmd_macsec_offload_off_macsec,
13753 (void *)&cmd_macsec_offload_off_offload,
13754 (void *)&cmd_macsec_offload_off_port_id,
13755 (void *)&cmd_macsec_offload_off_off,
13760 /* Common result structure for MACsec secure connection configure */
13761 struct cmd_macsec_sc_result {
13762 cmdline_fixed_string_t set;
13763 cmdline_fixed_string_t macsec;
13764 cmdline_fixed_string_t sc;
13765 cmdline_fixed_string_t tx_rx;
13767 struct rte_ether_addr mac;
13771 /* Common CLI fields for MACsec secure connection configure */
13772 cmdline_parse_token_string_t cmd_macsec_sc_set =
13773 TOKEN_STRING_INITIALIZER
13774 (struct cmd_macsec_sc_result,
13776 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
13777 TOKEN_STRING_INITIALIZER
13778 (struct cmd_macsec_sc_result,
13780 cmdline_parse_token_string_t cmd_macsec_sc_sc =
13781 TOKEN_STRING_INITIALIZER
13782 (struct cmd_macsec_sc_result,
13784 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
13785 TOKEN_STRING_INITIALIZER
13786 (struct cmd_macsec_sc_result,
13788 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
13789 TOKEN_NUM_INITIALIZER
13790 (struct cmd_macsec_sc_result,
13792 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
13793 TOKEN_ETHERADDR_INITIALIZER
13794 (struct cmd_macsec_sc_result,
13796 cmdline_parse_token_num_t cmd_macsec_sc_pi =
13797 TOKEN_NUM_INITIALIZER
13798 (struct cmd_macsec_sc_result,
13802 cmd_set_macsec_sc_parsed(
13803 void *parsed_result,
13804 __rte_unused struct cmdline *cl,
13805 __rte_unused void *data)
13807 struct cmd_macsec_sc_result *res = parsed_result;
13808 int ret = -ENOTSUP;
13809 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
13811 #ifdef RTE_NET_IXGBE
13813 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
13814 res->mac.addr_bytes) :
13815 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
13816 res->mac.addr_bytes, res->pi);
13818 RTE_SET_USED(is_tx);
13824 printf("invalid port_id %d\n", res->port_id);
13827 printf("not supported on port %d\n", res->port_id);
13830 printf("programming error: (%s)\n", strerror(-ret));
13834 cmdline_parse_inst_t cmd_set_macsec_sc = {
13835 .f = cmd_set_macsec_sc_parsed,
13837 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
13839 (void *)&cmd_macsec_sc_set,
13840 (void *)&cmd_macsec_sc_macsec,
13841 (void *)&cmd_macsec_sc_sc,
13842 (void *)&cmd_macsec_sc_tx_rx,
13843 (void *)&cmd_macsec_sc_port_id,
13844 (void *)&cmd_macsec_sc_mac,
13845 (void *)&cmd_macsec_sc_pi,
13850 /* Common result structure for MACsec secure connection configure */
13851 struct cmd_macsec_sa_result {
13852 cmdline_fixed_string_t set;
13853 cmdline_fixed_string_t macsec;
13854 cmdline_fixed_string_t sa;
13855 cmdline_fixed_string_t tx_rx;
13860 cmdline_fixed_string_t key;
13863 /* Common CLI fields for MACsec secure connection configure */
13864 cmdline_parse_token_string_t cmd_macsec_sa_set =
13865 TOKEN_STRING_INITIALIZER
13866 (struct cmd_macsec_sa_result,
13868 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
13869 TOKEN_STRING_INITIALIZER
13870 (struct cmd_macsec_sa_result,
13872 cmdline_parse_token_string_t cmd_macsec_sa_sa =
13873 TOKEN_STRING_INITIALIZER
13874 (struct cmd_macsec_sa_result,
13876 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
13877 TOKEN_STRING_INITIALIZER
13878 (struct cmd_macsec_sa_result,
13880 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
13881 TOKEN_NUM_INITIALIZER
13882 (struct cmd_macsec_sa_result,
13884 cmdline_parse_token_num_t cmd_macsec_sa_idx =
13885 TOKEN_NUM_INITIALIZER
13886 (struct cmd_macsec_sa_result,
13888 cmdline_parse_token_num_t cmd_macsec_sa_an =
13889 TOKEN_NUM_INITIALIZER
13890 (struct cmd_macsec_sa_result,
13892 cmdline_parse_token_num_t cmd_macsec_sa_pn =
13893 TOKEN_NUM_INITIALIZER
13894 (struct cmd_macsec_sa_result,
13896 cmdline_parse_token_string_t cmd_macsec_sa_key =
13897 TOKEN_STRING_INITIALIZER
13898 (struct cmd_macsec_sa_result,
13902 cmd_set_macsec_sa_parsed(
13903 void *parsed_result,
13904 __rte_unused struct cmdline *cl,
13905 __rte_unused void *data)
13907 struct cmd_macsec_sa_result *res = parsed_result;
13908 int ret = -ENOTSUP;
13909 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
13910 uint8_t key[16] = { 0 };
13916 key_len = strlen(res->key) / 2;
13920 for (i = 0; i < key_len; i++) {
13921 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
13924 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
13927 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
13930 #ifdef RTE_NET_IXGBE
13932 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
13933 res->idx, res->an, res->pn, key) :
13934 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
13935 res->idx, res->an, res->pn, key);
13937 RTE_SET_USED(is_tx);
13944 printf("invalid idx %d or an %d\n", res->idx, res->an);
13947 printf("invalid port_id %d\n", res->port_id);
13950 printf("not supported on port %d\n", res->port_id);
13953 printf("programming error: (%s)\n", strerror(-ret));
13957 cmdline_parse_inst_t cmd_set_macsec_sa = {
13958 .f = cmd_set_macsec_sa_parsed,
13960 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
13962 (void *)&cmd_macsec_sa_set,
13963 (void *)&cmd_macsec_sa_macsec,
13964 (void *)&cmd_macsec_sa_sa,
13965 (void *)&cmd_macsec_sa_tx_rx,
13966 (void *)&cmd_macsec_sa_port_id,
13967 (void *)&cmd_macsec_sa_idx,
13968 (void *)&cmd_macsec_sa_an,
13969 (void *)&cmd_macsec_sa_pn,
13970 (void *)&cmd_macsec_sa_key,
13975 /* VF unicast promiscuous mode configuration */
13977 /* Common result structure for VF unicast promiscuous mode */
13978 struct cmd_vf_promisc_result {
13979 cmdline_fixed_string_t set;
13980 cmdline_fixed_string_t vf;
13981 cmdline_fixed_string_t promisc;
13984 cmdline_fixed_string_t on_off;
13987 /* Common CLI fields for VF unicast promiscuous mode enable disable */
13988 cmdline_parse_token_string_t cmd_vf_promisc_set =
13989 TOKEN_STRING_INITIALIZER
13990 (struct cmd_vf_promisc_result,
13992 cmdline_parse_token_string_t cmd_vf_promisc_vf =
13993 TOKEN_STRING_INITIALIZER
13994 (struct cmd_vf_promisc_result,
13996 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
13997 TOKEN_STRING_INITIALIZER
13998 (struct cmd_vf_promisc_result,
13999 promisc, "promisc");
14000 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
14001 TOKEN_NUM_INITIALIZER
14002 (struct cmd_vf_promisc_result,
14004 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
14005 TOKEN_NUM_INITIALIZER
14006 (struct cmd_vf_promisc_result,
14008 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
14009 TOKEN_STRING_INITIALIZER
14010 (struct cmd_vf_promisc_result,
14014 cmd_set_vf_promisc_parsed(
14015 void *parsed_result,
14016 __rte_unused struct cmdline *cl,
14017 __rte_unused void *data)
14019 struct cmd_vf_promisc_result *res = parsed_result;
14020 int ret = -ENOTSUP;
14022 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14024 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14027 #ifdef RTE_NET_I40E
14028 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
14029 res->vf_id, is_on);
14036 printf("invalid vf_id %d\n", res->vf_id);
14039 printf("invalid port_id %d\n", res->port_id);
14042 printf("function not implemented\n");
14045 printf("programming error: (%s)\n", strerror(-ret));
14049 cmdline_parse_inst_t cmd_set_vf_promisc = {
14050 .f = cmd_set_vf_promisc_parsed,
14052 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
14053 "Set unicast promiscuous mode for a VF from the PF",
14055 (void *)&cmd_vf_promisc_set,
14056 (void *)&cmd_vf_promisc_vf,
14057 (void *)&cmd_vf_promisc_promisc,
14058 (void *)&cmd_vf_promisc_port_id,
14059 (void *)&cmd_vf_promisc_vf_id,
14060 (void *)&cmd_vf_promisc_on_off,
14065 /* VF multicast promiscuous mode configuration */
14067 /* Common result structure for VF multicast promiscuous mode */
14068 struct cmd_vf_allmulti_result {
14069 cmdline_fixed_string_t set;
14070 cmdline_fixed_string_t vf;
14071 cmdline_fixed_string_t allmulti;
14074 cmdline_fixed_string_t on_off;
14077 /* Common CLI fields for VF multicast promiscuous mode enable disable */
14078 cmdline_parse_token_string_t cmd_vf_allmulti_set =
14079 TOKEN_STRING_INITIALIZER
14080 (struct cmd_vf_allmulti_result,
14082 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
14083 TOKEN_STRING_INITIALIZER
14084 (struct cmd_vf_allmulti_result,
14086 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
14087 TOKEN_STRING_INITIALIZER
14088 (struct cmd_vf_allmulti_result,
14089 allmulti, "allmulti");
14090 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
14091 TOKEN_NUM_INITIALIZER
14092 (struct cmd_vf_allmulti_result,
14094 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
14095 TOKEN_NUM_INITIALIZER
14096 (struct cmd_vf_allmulti_result,
14098 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
14099 TOKEN_STRING_INITIALIZER
14100 (struct cmd_vf_allmulti_result,
14104 cmd_set_vf_allmulti_parsed(
14105 void *parsed_result,
14106 __rte_unused struct cmdline *cl,
14107 __rte_unused void *data)
14109 struct cmd_vf_allmulti_result *res = parsed_result;
14110 int ret = -ENOTSUP;
14112 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14114 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14117 #ifdef RTE_NET_I40E
14118 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
14119 res->vf_id, is_on);
14126 printf("invalid vf_id %d\n", res->vf_id);
14129 printf("invalid port_id %d\n", res->port_id);
14132 printf("function not implemented\n");
14135 printf("programming error: (%s)\n", strerror(-ret));
14139 cmdline_parse_inst_t cmd_set_vf_allmulti = {
14140 .f = cmd_set_vf_allmulti_parsed,
14142 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
14143 "Set multicast promiscuous mode for a VF from the PF",
14145 (void *)&cmd_vf_allmulti_set,
14146 (void *)&cmd_vf_allmulti_vf,
14147 (void *)&cmd_vf_allmulti_allmulti,
14148 (void *)&cmd_vf_allmulti_port_id,
14149 (void *)&cmd_vf_allmulti_vf_id,
14150 (void *)&cmd_vf_allmulti_on_off,
14155 /* vf broadcast mode configuration */
14157 /* Common result structure for vf broadcast */
14158 struct cmd_set_vf_broadcast_result {
14159 cmdline_fixed_string_t set;
14160 cmdline_fixed_string_t vf;
14161 cmdline_fixed_string_t broadcast;
14164 cmdline_fixed_string_t on_off;
14167 /* Common CLI fields for vf broadcast enable disable */
14168 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
14169 TOKEN_STRING_INITIALIZER
14170 (struct cmd_set_vf_broadcast_result,
14172 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
14173 TOKEN_STRING_INITIALIZER
14174 (struct cmd_set_vf_broadcast_result,
14176 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
14177 TOKEN_STRING_INITIALIZER
14178 (struct cmd_set_vf_broadcast_result,
14179 broadcast, "broadcast");
14180 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
14181 TOKEN_NUM_INITIALIZER
14182 (struct cmd_set_vf_broadcast_result,
14184 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
14185 TOKEN_NUM_INITIALIZER
14186 (struct cmd_set_vf_broadcast_result,
14188 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
14189 TOKEN_STRING_INITIALIZER
14190 (struct cmd_set_vf_broadcast_result,
14194 cmd_set_vf_broadcast_parsed(
14195 void *parsed_result,
14196 __rte_unused struct cmdline *cl,
14197 __rte_unused void *data)
14199 struct cmd_set_vf_broadcast_result *res = parsed_result;
14200 int ret = -ENOTSUP;
14202 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14204 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14207 #ifdef RTE_NET_I40E
14208 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
14209 res->vf_id, is_on);
14216 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14219 printf("invalid port_id %d\n", res->port_id);
14222 printf("function not implemented\n");
14225 printf("programming error: (%s)\n", strerror(-ret));
14229 cmdline_parse_inst_t cmd_set_vf_broadcast = {
14230 .f = cmd_set_vf_broadcast_parsed,
14232 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
14234 (void *)&cmd_set_vf_broadcast_set,
14235 (void *)&cmd_set_vf_broadcast_vf,
14236 (void *)&cmd_set_vf_broadcast_broadcast,
14237 (void *)&cmd_set_vf_broadcast_port_id,
14238 (void *)&cmd_set_vf_broadcast_vf_id,
14239 (void *)&cmd_set_vf_broadcast_on_off,
14244 /* vf vlan tag configuration */
14246 /* Common result structure for vf vlan tag */
14247 struct cmd_set_vf_vlan_tag_result {
14248 cmdline_fixed_string_t set;
14249 cmdline_fixed_string_t vf;
14250 cmdline_fixed_string_t vlan;
14251 cmdline_fixed_string_t tag;
14254 cmdline_fixed_string_t on_off;
14257 /* Common CLI fields for vf vlan tag enable disable */
14258 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
14259 TOKEN_STRING_INITIALIZER
14260 (struct cmd_set_vf_vlan_tag_result,
14262 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
14263 TOKEN_STRING_INITIALIZER
14264 (struct cmd_set_vf_vlan_tag_result,
14266 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
14267 TOKEN_STRING_INITIALIZER
14268 (struct cmd_set_vf_vlan_tag_result,
14270 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
14271 TOKEN_STRING_INITIALIZER
14272 (struct cmd_set_vf_vlan_tag_result,
14274 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
14275 TOKEN_NUM_INITIALIZER
14276 (struct cmd_set_vf_vlan_tag_result,
14278 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
14279 TOKEN_NUM_INITIALIZER
14280 (struct cmd_set_vf_vlan_tag_result,
14282 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
14283 TOKEN_STRING_INITIALIZER
14284 (struct cmd_set_vf_vlan_tag_result,
14288 cmd_set_vf_vlan_tag_parsed(
14289 void *parsed_result,
14290 __rte_unused struct cmdline *cl,
14291 __rte_unused void *data)
14293 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
14294 int ret = -ENOTSUP;
14296 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14298 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14301 #ifdef RTE_NET_I40E
14302 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
14303 res->vf_id, is_on);
14310 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14313 printf("invalid port_id %d\n", res->port_id);
14316 printf("function not implemented\n");
14319 printf("programming error: (%s)\n", strerror(-ret));
14323 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
14324 .f = cmd_set_vf_vlan_tag_parsed,
14326 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
14328 (void *)&cmd_set_vf_vlan_tag_set,
14329 (void *)&cmd_set_vf_vlan_tag_vf,
14330 (void *)&cmd_set_vf_vlan_tag_vlan,
14331 (void *)&cmd_set_vf_vlan_tag_tag,
14332 (void *)&cmd_set_vf_vlan_tag_port_id,
14333 (void *)&cmd_set_vf_vlan_tag_vf_id,
14334 (void *)&cmd_set_vf_vlan_tag_on_off,
14339 /* Common definition of VF and TC TX bandwidth configuration */
14340 struct cmd_vf_tc_bw_result {
14341 cmdline_fixed_string_t set;
14342 cmdline_fixed_string_t vf;
14343 cmdline_fixed_string_t tc;
14344 cmdline_fixed_string_t tx;
14345 cmdline_fixed_string_t min_bw;
14346 cmdline_fixed_string_t max_bw;
14347 cmdline_fixed_string_t strict_link_prio;
14352 cmdline_fixed_string_t bw_list;
14356 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
14357 TOKEN_STRING_INITIALIZER
14358 (struct cmd_vf_tc_bw_result,
14360 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
14361 TOKEN_STRING_INITIALIZER
14362 (struct cmd_vf_tc_bw_result,
14364 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
14365 TOKEN_STRING_INITIALIZER
14366 (struct cmd_vf_tc_bw_result,
14368 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
14369 TOKEN_STRING_INITIALIZER
14370 (struct cmd_vf_tc_bw_result,
14372 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
14373 TOKEN_STRING_INITIALIZER
14374 (struct cmd_vf_tc_bw_result,
14375 strict_link_prio, "strict-link-priority");
14376 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
14377 TOKEN_STRING_INITIALIZER
14378 (struct cmd_vf_tc_bw_result,
14379 min_bw, "min-bandwidth");
14380 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
14381 TOKEN_STRING_INITIALIZER
14382 (struct cmd_vf_tc_bw_result,
14383 max_bw, "max-bandwidth");
14384 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
14385 TOKEN_NUM_INITIALIZER
14386 (struct cmd_vf_tc_bw_result,
14388 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
14389 TOKEN_NUM_INITIALIZER
14390 (struct cmd_vf_tc_bw_result,
14392 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
14393 TOKEN_NUM_INITIALIZER
14394 (struct cmd_vf_tc_bw_result,
14396 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
14397 TOKEN_NUM_INITIALIZER
14398 (struct cmd_vf_tc_bw_result,
14400 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
14401 TOKEN_STRING_INITIALIZER
14402 (struct cmd_vf_tc_bw_result,
14404 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
14405 TOKEN_NUM_INITIALIZER
14406 (struct cmd_vf_tc_bw_result,
14409 /* VF max bandwidth setting */
14411 cmd_vf_max_bw_parsed(
14412 void *parsed_result,
14413 __rte_unused struct cmdline *cl,
14414 __rte_unused void *data)
14416 struct cmd_vf_tc_bw_result *res = parsed_result;
14417 int ret = -ENOTSUP;
14419 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14422 #ifdef RTE_NET_I40E
14423 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
14424 res->vf_id, res->bw);
14431 printf("invalid vf_id %d or bandwidth %d\n",
14432 res->vf_id, res->bw);
14435 printf("invalid port_id %d\n", res->port_id);
14438 printf("function not implemented\n");
14441 printf("programming error: (%s)\n", strerror(-ret));
14445 cmdline_parse_inst_t cmd_vf_max_bw = {
14446 .f = cmd_vf_max_bw_parsed,
14448 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
14450 (void *)&cmd_vf_tc_bw_set,
14451 (void *)&cmd_vf_tc_bw_vf,
14452 (void *)&cmd_vf_tc_bw_tx,
14453 (void *)&cmd_vf_tc_bw_max_bw,
14454 (void *)&cmd_vf_tc_bw_port_id,
14455 (void *)&cmd_vf_tc_bw_vf_id,
14456 (void *)&cmd_vf_tc_bw_bw,
14462 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
14467 const char *p, *p0 = str;
14474 p = strchr(p0, '(');
14476 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14480 p0 = strchr(p, ')');
14482 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14486 if (size >= sizeof(s)) {
14487 printf("The string size exceeds the internal buffer size\n");
14490 snprintf(s, sizeof(s), "%.*s", size, p);
14491 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
14493 printf("Failed to get the bandwidth list. ");
14497 for (i = 0; i < ret; i++)
14498 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
14503 /* TC min bandwidth setting */
14505 cmd_vf_tc_min_bw_parsed(
14506 void *parsed_result,
14507 __rte_unused struct cmdline *cl,
14508 __rte_unused void *data)
14510 struct cmd_vf_tc_bw_result *res = parsed_result;
14513 int ret = -ENOTSUP;
14515 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14518 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
14522 #ifdef RTE_NET_I40E
14523 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
14531 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
14534 printf("invalid port_id %d\n", res->port_id);
14537 printf("function not implemented\n");
14540 printf("programming error: (%s)\n", strerror(-ret));
14544 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
14545 .f = cmd_vf_tc_min_bw_parsed,
14547 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
14548 " <bw1, bw2, ...>",
14550 (void *)&cmd_vf_tc_bw_set,
14551 (void *)&cmd_vf_tc_bw_vf,
14552 (void *)&cmd_vf_tc_bw_tc,
14553 (void *)&cmd_vf_tc_bw_tx,
14554 (void *)&cmd_vf_tc_bw_min_bw,
14555 (void *)&cmd_vf_tc_bw_port_id,
14556 (void *)&cmd_vf_tc_bw_vf_id,
14557 (void *)&cmd_vf_tc_bw_bw_list,
14563 cmd_tc_min_bw_parsed(
14564 void *parsed_result,
14565 __rte_unused struct cmdline *cl,
14566 __rte_unused void *data)
14568 struct cmd_vf_tc_bw_result *res = parsed_result;
14569 struct rte_port *port;
14572 int ret = -ENOTSUP;
14574 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14577 port = &ports[res->port_id];
14578 /** Check if the port is not started **/
14579 if (port->port_status != RTE_PORT_STOPPED) {
14580 printf("Please stop port %d first\n", res->port_id);
14584 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
14588 #ifdef RTE_NET_IXGBE
14589 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
14596 printf("invalid bandwidth\n");
14599 printf("invalid port_id %d\n", res->port_id);
14602 printf("function not implemented\n");
14605 printf("programming error: (%s)\n", strerror(-ret));
14609 cmdline_parse_inst_t cmd_tc_min_bw = {
14610 .f = cmd_tc_min_bw_parsed,
14612 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
14614 (void *)&cmd_vf_tc_bw_set,
14615 (void *)&cmd_vf_tc_bw_tc,
14616 (void *)&cmd_vf_tc_bw_tx,
14617 (void *)&cmd_vf_tc_bw_min_bw,
14618 (void *)&cmd_vf_tc_bw_port_id,
14619 (void *)&cmd_vf_tc_bw_bw_list,
14624 /* TC max bandwidth setting */
14626 cmd_vf_tc_max_bw_parsed(
14627 void *parsed_result,
14628 __rte_unused struct cmdline *cl,
14629 __rte_unused void *data)
14631 struct cmd_vf_tc_bw_result *res = parsed_result;
14632 int ret = -ENOTSUP;
14634 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14637 #ifdef RTE_NET_I40E
14638 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
14639 res->tc_no, res->bw);
14646 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
14647 res->vf_id, res->tc_no, res->bw);
14650 printf("invalid port_id %d\n", res->port_id);
14653 printf("function not implemented\n");
14656 printf("programming error: (%s)\n", strerror(-ret));
14660 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
14661 .f = cmd_vf_tc_max_bw_parsed,
14663 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
14666 (void *)&cmd_vf_tc_bw_set,
14667 (void *)&cmd_vf_tc_bw_vf,
14668 (void *)&cmd_vf_tc_bw_tc,
14669 (void *)&cmd_vf_tc_bw_tx,
14670 (void *)&cmd_vf_tc_bw_max_bw,
14671 (void *)&cmd_vf_tc_bw_port_id,
14672 (void *)&cmd_vf_tc_bw_vf_id,
14673 (void *)&cmd_vf_tc_bw_tc_no,
14674 (void *)&cmd_vf_tc_bw_bw,
14679 /** Set VXLAN encapsulation details */
14680 struct cmd_set_vxlan_result {
14681 cmdline_fixed_string_t set;
14682 cmdline_fixed_string_t vxlan;
14683 cmdline_fixed_string_t pos_token;
14684 cmdline_fixed_string_t ip_version;
14685 uint32_t vlan_present:1;
14689 cmdline_ipaddr_t ip_src;
14690 cmdline_ipaddr_t ip_dst;
14694 struct rte_ether_addr eth_src;
14695 struct rte_ether_addr eth_dst;
14698 cmdline_parse_token_string_t cmd_set_vxlan_set =
14699 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
14700 cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
14701 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
14702 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
14703 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
14705 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
14706 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
14707 "vxlan-with-vlan");
14708 cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
14709 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
14711 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
14712 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
14714 cmdline_parse_token_string_t cmd_set_vxlan_vni =
14715 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
14717 cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
14718 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, UINT32);
14719 cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
14720 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
14722 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
14723 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, UINT16);
14724 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
14725 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
14727 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
14728 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, UINT16);
14729 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
14730 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
14732 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
14733 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, UINT8);
14734 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
14735 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
14737 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
14738 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, UINT8);
14739 cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
14740 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
14742 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
14743 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
14744 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
14745 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
14747 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
14748 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
14749 cmdline_parse_token_string_t cmd_set_vxlan_vlan =
14750 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
14752 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
14753 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, UINT16);
14754 cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
14755 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
14757 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
14758 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
14759 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
14760 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
14762 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
14763 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
14765 static void cmd_set_vxlan_parsed(void *parsed_result,
14766 __rte_unused struct cmdline *cl,
14767 __rte_unused void *data)
14769 struct cmd_set_vxlan_result *res = parsed_result;
14774 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
14777 vxlan_encap_conf.select_tos_ttl = 0;
14778 if (strcmp(res->vxlan, "vxlan") == 0)
14779 vxlan_encap_conf.select_vlan = 0;
14780 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
14781 vxlan_encap_conf.select_vlan = 1;
14782 else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
14783 vxlan_encap_conf.select_vlan = 0;
14784 vxlan_encap_conf.select_tos_ttl = 1;
14786 if (strcmp(res->ip_version, "ipv4") == 0)
14787 vxlan_encap_conf.select_ipv4 = 1;
14788 else if (strcmp(res->ip_version, "ipv6") == 0)
14789 vxlan_encap_conf.select_ipv4 = 0;
14792 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
14793 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
14794 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
14795 vxlan_encap_conf.ip_tos = res->tos;
14796 vxlan_encap_conf.ip_ttl = res->ttl;
14797 if (vxlan_encap_conf.select_ipv4) {
14798 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
14799 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
14801 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
14802 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
14804 if (vxlan_encap_conf.select_vlan)
14805 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
14806 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
14807 RTE_ETHER_ADDR_LEN);
14808 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
14809 RTE_ETHER_ADDR_LEN);
14812 cmdline_parse_inst_t cmd_set_vxlan = {
14813 .f = cmd_set_vxlan_parsed,
14815 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
14816 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
14817 " eth-src <eth-src> eth-dst <eth-dst>",
14819 (void *)&cmd_set_vxlan_set,
14820 (void *)&cmd_set_vxlan_vxlan,
14821 (void *)&cmd_set_vxlan_ip_version,
14822 (void *)&cmd_set_vxlan_ip_version_value,
14823 (void *)&cmd_set_vxlan_vni,
14824 (void *)&cmd_set_vxlan_vni_value,
14825 (void *)&cmd_set_vxlan_udp_src,
14826 (void *)&cmd_set_vxlan_udp_src_value,
14827 (void *)&cmd_set_vxlan_udp_dst,
14828 (void *)&cmd_set_vxlan_udp_dst_value,
14829 (void *)&cmd_set_vxlan_ip_src,
14830 (void *)&cmd_set_vxlan_ip_src_value,
14831 (void *)&cmd_set_vxlan_ip_dst,
14832 (void *)&cmd_set_vxlan_ip_dst_value,
14833 (void *)&cmd_set_vxlan_eth_src,
14834 (void *)&cmd_set_vxlan_eth_src_value,
14835 (void *)&cmd_set_vxlan_eth_dst,
14836 (void *)&cmd_set_vxlan_eth_dst_value,
14841 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
14842 .f = cmd_set_vxlan_parsed,
14844 .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
14845 " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
14846 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
14847 " eth-dst <eth-dst>",
14849 (void *)&cmd_set_vxlan_set,
14850 (void *)&cmd_set_vxlan_vxlan_tos_ttl,
14851 (void *)&cmd_set_vxlan_ip_version,
14852 (void *)&cmd_set_vxlan_ip_version_value,
14853 (void *)&cmd_set_vxlan_vni,
14854 (void *)&cmd_set_vxlan_vni_value,
14855 (void *)&cmd_set_vxlan_udp_src,
14856 (void *)&cmd_set_vxlan_udp_src_value,
14857 (void *)&cmd_set_vxlan_udp_dst,
14858 (void *)&cmd_set_vxlan_udp_dst_value,
14859 (void *)&cmd_set_vxlan_ip_tos,
14860 (void *)&cmd_set_vxlan_ip_tos_value,
14861 (void *)&cmd_set_vxlan_ip_ttl,
14862 (void *)&cmd_set_vxlan_ip_ttl_value,
14863 (void *)&cmd_set_vxlan_ip_src,
14864 (void *)&cmd_set_vxlan_ip_src_value,
14865 (void *)&cmd_set_vxlan_ip_dst,
14866 (void *)&cmd_set_vxlan_ip_dst_value,
14867 (void *)&cmd_set_vxlan_eth_src,
14868 (void *)&cmd_set_vxlan_eth_src_value,
14869 (void *)&cmd_set_vxlan_eth_dst,
14870 (void *)&cmd_set_vxlan_eth_dst_value,
14875 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
14876 .f = cmd_set_vxlan_parsed,
14878 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
14879 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
14880 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
14883 (void *)&cmd_set_vxlan_set,
14884 (void *)&cmd_set_vxlan_vxlan_with_vlan,
14885 (void *)&cmd_set_vxlan_ip_version,
14886 (void *)&cmd_set_vxlan_ip_version_value,
14887 (void *)&cmd_set_vxlan_vni,
14888 (void *)&cmd_set_vxlan_vni_value,
14889 (void *)&cmd_set_vxlan_udp_src,
14890 (void *)&cmd_set_vxlan_udp_src_value,
14891 (void *)&cmd_set_vxlan_udp_dst,
14892 (void *)&cmd_set_vxlan_udp_dst_value,
14893 (void *)&cmd_set_vxlan_ip_src,
14894 (void *)&cmd_set_vxlan_ip_src_value,
14895 (void *)&cmd_set_vxlan_ip_dst,
14896 (void *)&cmd_set_vxlan_ip_dst_value,
14897 (void *)&cmd_set_vxlan_vlan,
14898 (void *)&cmd_set_vxlan_vlan_value,
14899 (void *)&cmd_set_vxlan_eth_src,
14900 (void *)&cmd_set_vxlan_eth_src_value,
14901 (void *)&cmd_set_vxlan_eth_dst,
14902 (void *)&cmd_set_vxlan_eth_dst_value,
14907 /** Set NVGRE encapsulation details */
14908 struct cmd_set_nvgre_result {
14909 cmdline_fixed_string_t set;
14910 cmdline_fixed_string_t nvgre;
14911 cmdline_fixed_string_t pos_token;
14912 cmdline_fixed_string_t ip_version;
14914 cmdline_ipaddr_t ip_src;
14915 cmdline_ipaddr_t ip_dst;
14917 struct rte_ether_addr eth_src;
14918 struct rte_ether_addr eth_dst;
14921 cmdline_parse_token_string_t cmd_set_nvgre_set =
14922 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
14923 cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
14924 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
14925 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
14926 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
14927 "nvgre-with-vlan");
14928 cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
14929 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
14931 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
14932 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
14934 cmdline_parse_token_string_t cmd_set_nvgre_tni =
14935 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
14937 cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
14938 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, UINT32);
14939 cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
14940 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
14942 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
14943 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
14944 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
14945 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
14947 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
14948 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
14949 cmdline_parse_token_string_t cmd_set_nvgre_vlan =
14950 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
14952 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
14953 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, UINT16);
14954 cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
14955 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
14957 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
14958 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
14959 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
14960 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
14962 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
14963 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
14965 static void cmd_set_nvgre_parsed(void *parsed_result,
14966 __rte_unused struct cmdline *cl,
14967 __rte_unused void *data)
14969 struct cmd_set_nvgre_result *res = parsed_result;
14971 uint32_t nvgre_tni;
14974 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
14977 if (strcmp(res->nvgre, "nvgre") == 0)
14978 nvgre_encap_conf.select_vlan = 0;
14979 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
14980 nvgre_encap_conf.select_vlan = 1;
14981 if (strcmp(res->ip_version, "ipv4") == 0)
14982 nvgre_encap_conf.select_ipv4 = 1;
14983 else if (strcmp(res->ip_version, "ipv6") == 0)
14984 nvgre_encap_conf.select_ipv4 = 0;
14987 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
14988 if (nvgre_encap_conf.select_ipv4) {
14989 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
14990 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
14992 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
14993 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
14995 if (nvgre_encap_conf.select_vlan)
14996 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
14997 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
14998 RTE_ETHER_ADDR_LEN);
14999 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15000 RTE_ETHER_ADDR_LEN);
15003 cmdline_parse_inst_t cmd_set_nvgre = {
15004 .f = cmd_set_nvgre_parsed,
15006 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
15007 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15008 " eth-dst <eth-dst>",
15010 (void *)&cmd_set_nvgre_set,
15011 (void *)&cmd_set_nvgre_nvgre,
15012 (void *)&cmd_set_nvgre_ip_version,
15013 (void *)&cmd_set_nvgre_ip_version_value,
15014 (void *)&cmd_set_nvgre_tni,
15015 (void *)&cmd_set_nvgre_tni_value,
15016 (void *)&cmd_set_nvgre_ip_src,
15017 (void *)&cmd_set_nvgre_ip_src_value,
15018 (void *)&cmd_set_nvgre_ip_dst,
15019 (void *)&cmd_set_nvgre_ip_dst_value,
15020 (void *)&cmd_set_nvgre_eth_src,
15021 (void *)&cmd_set_nvgre_eth_src_value,
15022 (void *)&cmd_set_nvgre_eth_dst,
15023 (void *)&cmd_set_nvgre_eth_dst_value,
15028 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
15029 .f = cmd_set_nvgre_parsed,
15031 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
15032 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
15033 " eth-src <eth-src> eth-dst <eth-dst>",
15035 (void *)&cmd_set_nvgre_set,
15036 (void *)&cmd_set_nvgre_nvgre_with_vlan,
15037 (void *)&cmd_set_nvgre_ip_version,
15038 (void *)&cmd_set_nvgre_ip_version_value,
15039 (void *)&cmd_set_nvgre_tni,
15040 (void *)&cmd_set_nvgre_tni_value,
15041 (void *)&cmd_set_nvgre_ip_src,
15042 (void *)&cmd_set_nvgre_ip_src_value,
15043 (void *)&cmd_set_nvgre_ip_dst,
15044 (void *)&cmd_set_nvgre_ip_dst_value,
15045 (void *)&cmd_set_nvgre_vlan,
15046 (void *)&cmd_set_nvgre_vlan_value,
15047 (void *)&cmd_set_nvgre_eth_src,
15048 (void *)&cmd_set_nvgre_eth_src_value,
15049 (void *)&cmd_set_nvgre_eth_dst,
15050 (void *)&cmd_set_nvgre_eth_dst_value,
15055 /** Set L2 encapsulation details */
15056 struct cmd_set_l2_encap_result {
15057 cmdline_fixed_string_t set;
15058 cmdline_fixed_string_t l2_encap;
15059 cmdline_fixed_string_t pos_token;
15060 cmdline_fixed_string_t ip_version;
15061 uint32_t vlan_present:1;
15063 struct rte_ether_addr eth_src;
15064 struct rte_ether_addr eth_dst;
15067 cmdline_parse_token_string_t cmd_set_l2_encap_set =
15068 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
15069 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
15070 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
15071 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
15072 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
15073 "l2_encap-with-vlan");
15074 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
15075 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15077 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
15078 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
15080 cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
15081 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15083 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
15084 TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, UINT16);
15085 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
15086 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15088 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
15089 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
15090 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
15091 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15093 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
15094 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
15096 static void cmd_set_l2_encap_parsed(void *parsed_result,
15097 __rte_unused struct cmdline *cl,
15098 __rte_unused void *data)
15100 struct cmd_set_l2_encap_result *res = parsed_result;
15102 if (strcmp(res->l2_encap, "l2_encap") == 0)
15103 l2_encap_conf.select_vlan = 0;
15104 else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
15105 l2_encap_conf.select_vlan = 1;
15106 if (strcmp(res->ip_version, "ipv4") == 0)
15107 l2_encap_conf.select_ipv4 = 1;
15108 else if (strcmp(res->ip_version, "ipv6") == 0)
15109 l2_encap_conf.select_ipv4 = 0;
15112 if (l2_encap_conf.select_vlan)
15113 l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15114 rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
15115 RTE_ETHER_ADDR_LEN);
15116 rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15117 RTE_ETHER_ADDR_LEN);
15120 cmdline_parse_inst_t cmd_set_l2_encap = {
15121 .f = cmd_set_l2_encap_parsed,
15123 .help_str = "set l2_encap ip-version ipv4|ipv6"
15124 " eth-src <eth-src> eth-dst <eth-dst>",
15126 (void *)&cmd_set_l2_encap_set,
15127 (void *)&cmd_set_l2_encap_l2_encap,
15128 (void *)&cmd_set_l2_encap_ip_version,
15129 (void *)&cmd_set_l2_encap_ip_version_value,
15130 (void *)&cmd_set_l2_encap_eth_src,
15131 (void *)&cmd_set_l2_encap_eth_src_value,
15132 (void *)&cmd_set_l2_encap_eth_dst,
15133 (void *)&cmd_set_l2_encap_eth_dst_value,
15138 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
15139 .f = cmd_set_l2_encap_parsed,
15141 .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
15142 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
15144 (void *)&cmd_set_l2_encap_set,
15145 (void *)&cmd_set_l2_encap_l2_encap_with_vlan,
15146 (void *)&cmd_set_l2_encap_ip_version,
15147 (void *)&cmd_set_l2_encap_ip_version_value,
15148 (void *)&cmd_set_l2_encap_vlan,
15149 (void *)&cmd_set_l2_encap_vlan_value,
15150 (void *)&cmd_set_l2_encap_eth_src,
15151 (void *)&cmd_set_l2_encap_eth_src_value,
15152 (void *)&cmd_set_l2_encap_eth_dst,
15153 (void *)&cmd_set_l2_encap_eth_dst_value,
15158 /** Set L2 decapsulation details */
15159 struct cmd_set_l2_decap_result {
15160 cmdline_fixed_string_t set;
15161 cmdline_fixed_string_t l2_decap;
15162 cmdline_fixed_string_t pos_token;
15163 uint32_t vlan_present:1;
15166 cmdline_parse_token_string_t cmd_set_l2_decap_set =
15167 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
15168 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
15169 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
15171 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
15172 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
15173 "l2_decap-with-vlan");
15175 static void cmd_set_l2_decap_parsed(void *parsed_result,
15176 __rte_unused struct cmdline *cl,
15177 __rte_unused void *data)
15179 struct cmd_set_l2_decap_result *res = parsed_result;
15181 if (strcmp(res->l2_decap, "l2_decap") == 0)
15182 l2_decap_conf.select_vlan = 0;
15183 else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
15184 l2_decap_conf.select_vlan = 1;
15187 cmdline_parse_inst_t cmd_set_l2_decap = {
15188 .f = cmd_set_l2_decap_parsed,
15190 .help_str = "set l2_decap",
15192 (void *)&cmd_set_l2_decap_set,
15193 (void *)&cmd_set_l2_decap_l2_decap,
15198 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
15199 .f = cmd_set_l2_decap_parsed,
15201 .help_str = "set l2_decap-with-vlan",
15203 (void *)&cmd_set_l2_decap_set,
15204 (void *)&cmd_set_l2_decap_l2_decap_with_vlan,
15209 /** Set MPLSoGRE encapsulation details */
15210 struct cmd_set_mplsogre_encap_result {
15211 cmdline_fixed_string_t set;
15212 cmdline_fixed_string_t mplsogre;
15213 cmdline_fixed_string_t pos_token;
15214 cmdline_fixed_string_t ip_version;
15215 uint32_t vlan_present:1;
15217 cmdline_ipaddr_t ip_src;
15218 cmdline_ipaddr_t ip_dst;
15220 struct rte_ether_addr eth_src;
15221 struct rte_ether_addr eth_dst;
15224 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
15225 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
15227 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
15228 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
15230 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
15231 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15232 mplsogre, "mplsogre_encap-with-vlan");
15233 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
15234 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15235 pos_token, "ip-version");
15236 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
15237 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15238 ip_version, "ipv4#ipv6");
15239 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
15240 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15241 pos_token, "label");
15242 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
15243 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
15245 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
15246 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15247 pos_token, "ip-src");
15248 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
15249 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
15250 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
15251 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15252 pos_token, "ip-dst");
15253 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
15254 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
15255 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
15256 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15257 pos_token, "vlan-tci");
15258 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
15259 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
15261 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
15262 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15263 pos_token, "eth-src");
15264 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
15265 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15267 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
15268 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15269 pos_token, "eth-dst");
15270 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
15271 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15274 static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
15275 __rte_unused struct cmdline *cl,
15276 __rte_unused void *data)
15278 struct cmd_set_mplsogre_encap_result *res = parsed_result;
15280 uint32_t mplsogre_label;
15283 .mplsogre_label = rte_cpu_to_be_32(res->label<<12),
15286 if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
15287 mplsogre_encap_conf.select_vlan = 0;
15288 else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
15289 mplsogre_encap_conf.select_vlan = 1;
15290 if (strcmp(res->ip_version, "ipv4") == 0)
15291 mplsogre_encap_conf.select_ipv4 = 1;
15292 else if (strcmp(res->ip_version, "ipv6") == 0)
15293 mplsogre_encap_conf.select_ipv4 = 0;
15296 rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
15297 if (mplsogre_encap_conf.select_ipv4) {
15298 IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
15299 IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
15301 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
15302 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
15304 if (mplsogre_encap_conf.select_vlan)
15305 mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15306 rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
15307 RTE_ETHER_ADDR_LEN);
15308 rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15309 RTE_ETHER_ADDR_LEN);
15312 cmdline_parse_inst_t cmd_set_mplsogre_encap = {
15313 .f = cmd_set_mplsogre_encap_parsed,
15315 .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
15316 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15317 " eth-dst <eth-dst>",
15319 (void *)&cmd_set_mplsogre_encap_set,
15320 (void *)&cmd_set_mplsogre_encap_mplsogre_encap,
15321 (void *)&cmd_set_mplsogre_encap_ip_version,
15322 (void *)&cmd_set_mplsogre_encap_ip_version_value,
15323 (void *)&cmd_set_mplsogre_encap_label,
15324 (void *)&cmd_set_mplsogre_encap_label_value,
15325 (void *)&cmd_set_mplsogre_encap_ip_src,
15326 (void *)&cmd_set_mplsogre_encap_ip_src_value,
15327 (void *)&cmd_set_mplsogre_encap_ip_dst,
15328 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
15329 (void *)&cmd_set_mplsogre_encap_eth_src,
15330 (void *)&cmd_set_mplsogre_encap_eth_src_value,
15331 (void *)&cmd_set_mplsogre_encap_eth_dst,
15332 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
15337 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
15338 .f = cmd_set_mplsogre_encap_parsed,
15340 .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
15341 " label <label> ip-src <ip-src> ip-dst <ip-dst>"
15342 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
15344 (void *)&cmd_set_mplsogre_encap_set,
15345 (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
15346 (void *)&cmd_set_mplsogre_encap_ip_version,
15347 (void *)&cmd_set_mplsogre_encap_ip_version_value,
15348 (void *)&cmd_set_mplsogre_encap_label,
15349 (void *)&cmd_set_mplsogre_encap_label_value,
15350 (void *)&cmd_set_mplsogre_encap_ip_src,
15351 (void *)&cmd_set_mplsogre_encap_ip_src_value,
15352 (void *)&cmd_set_mplsogre_encap_ip_dst,
15353 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
15354 (void *)&cmd_set_mplsogre_encap_vlan,
15355 (void *)&cmd_set_mplsogre_encap_vlan_value,
15356 (void *)&cmd_set_mplsogre_encap_eth_src,
15357 (void *)&cmd_set_mplsogre_encap_eth_src_value,
15358 (void *)&cmd_set_mplsogre_encap_eth_dst,
15359 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
15364 /** Set MPLSoGRE decapsulation details */
15365 struct cmd_set_mplsogre_decap_result {
15366 cmdline_fixed_string_t set;
15367 cmdline_fixed_string_t mplsogre;
15368 cmdline_fixed_string_t pos_token;
15369 cmdline_fixed_string_t ip_version;
15370 uint32_t vlan_present:1;
15373 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
15374 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
15376 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
15377 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
15379 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
15380 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
15381 mplsogre, "mplsogre_decap-with-vlan");
15382 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
15383 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
15384 pos_token, "ip-version");
15385 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
15386 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
15387 ip_version, "ipv4#ipv6");
15389 static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
15390 __rte_unused struct cmdline *cl,
15391 __rte_unused void *data)
15393 struct cmd_set_mplsogre_decap_result *res = parsed_result;
15395 if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
15396 mplsogre_decap_conf.select_vlan = 0;
15397 else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
15398 mplsogre_decap_conf.select_vlan = 1;
15399 if (strcmp(res->ip_version, "ipv4") == 0)
15400 mplsogre_decap_conf.select_ipv4 = 1;
15401 else if (strcmp(res->ip_version, "ipv6") == 0)
15402 mplsogre_decap_conf.select_ipv4 = 0;
15405 cmdline_parse_inst_t cmd_set_mplsogre_decap = {
15406 .f = cmd_set_mplsogre_decap_parsed,
15408 .help_str = "set mplsogre_decap ip-version ipv4|ipv6",
15410 (void *)&cmd_set_mplsogre_decap_set,
15411 (void *)&cmd_set_mplsogre_decap_mplsogre_decap,
15412 (void *)&cmd_set_mplsogre_decap_ip_version,
15413 (void *)&cmd_set_mplsogre_decap_ip_version_value,
15418 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
15419 .f = cmd_set_mplsogre_decap_parsed,
15421 .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
15423 (void *)&cmd_set_mplsogre_decap_set,
15424 (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
15425 (void *)&cmd_set_mplsogre_decap_ip_version,
15426 (void *)&cmd_set_mplsogre_decap_ip_version_value,
15431 /** Set MPLSoUDP encapsulation details */
15432 struct cmd_set_mplsoudp_encap_result {
15433 cmdline_fixed_string_t set;
15434 cmdline_fixed_string_t mplsoudp;
15435 cmdline_fixed_string_t pos_token;
15436 cmdline_fixed_string_t ip_version;
15437 uint32_t vlan_present:1;
15441 cmdline_ipaddr_t ip_src;
15442 cmdline_ipaddr_t ip_dst;
15444 struct rte_ether_addr eth_src;
15445 struct rte_ether_addr eth_dst;
15448 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
15449 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
15451 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
15452 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
15454 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
15455 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15456 mplsoudp, "mplsoudp_encap-with-vlan");
15457 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
15458 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15459 pos_token, "ip-version");
15460 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
15461 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15462 ip_version, "ipv4#ipv6");
15463 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
15464 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15465 pos_token, "label");
15466 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
15467 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
15469 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
15470 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15471 pos_token, "udp-src");
15472 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
15473 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
15475 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
15476 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15477 pos_token, "udp-dst");
15478 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
15479 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
15481 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
15482 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15483 pos_token, "ip-src");
15484 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
15485 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
15486 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
15487 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15488 pos_token, "ip-dst");
15489 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
15490 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
15491 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
15492 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15493 pos_token, "vlan-tci");
15494 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
15495 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
15497 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
15498 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15499 pos_token, "eth-src");
15500 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
15501 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15503 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
15504 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15505 pos_token, "eth-dst");
15506 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
15507 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15510 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
15511 __rte_unused struct cmdline *cl,
15512 __rte_unused void *data)
15514 struct cmd_set_mplsoudp_encap_result *res = parsed_result;
15516 uint32_t mplsoudp_label;
15519 .mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
15522 if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
15523 mplsoudp_encap_conf.select_vlan = 0;
15524 else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
15525 mplsoudp_encap_conf.select_vlan = 1;
15526 if (strcmp(res->ip_version, "ipv4") == 0)
15527 mplsoudp_encap_conf.select_ipv4 = 1;
15528 else if (strcmp(res->ip_version, "ipv6") == 0)
15529 mplsoudp_encap_conf.select_ipv4 = 0;
15532 rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
15533 mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
15534 mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
15535 if (mplsoudp_encap_conf.select_ipv4) {
15536 IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
15537 IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
15539 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
15540 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
15542 if (mplsoudp_encap_conf.select_vlan)
15543 mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15544 rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
15545 RTE_ETHER_ADDR_LEN);
15546 rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15547 RTE_ETHER_ADDR_LEN);
15550 cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
15551 .f = cmd_set_mplsoudp_encap_parsed,
15553 .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
15554 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
15555 " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
15557 (void *)&cmd_set_mplsoudp_encap_set,
15558 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
15559 (void *)&cmd_set_mplsoudp_encap_ip_version,
15560 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
15561 (void *)&cmd_set_mplsoudp_encap_label,
15562 (void *)&cmd_set_mplsoudp_encap_label_value,
15563 (void *)&cmd_set_mplsoudp_encap_udp_src,
15564 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
15565 (void *)&cmd_set_mplsoudp_encap_udp_dst,
15566 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
15567 (void *)&cmd_set_mplsoudp_encap_ip_src,
15568 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
15569 (void *)&cmd_set_mplsoudp_encap_ip_dst,
15570 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
15571 (void *)&cmd_set_mplsoudp_encap_eth_src,
15572 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
15573 (void *)&cmd_set_mplsoudp_encap_eth_dst,
15574 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
15579 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
15580 .f = cmd_set_mplsoudp_encap_parsed,
15582 .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
15583 " label <label> udp-src <udp-src> udp-dst <udp-dst>"
15584 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
15585 " eth-src <eth-src> eth-dst <eth-dst>",
15587 (void *)&cmd_set_mplsoudp_encap_set,
15588 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
15589 (void *)&cmd_set_mplsoudp_encap_ip_version,
15590 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
15591 (void *)&cmd_set_mplsoudp_encap_label,
15592 (void *)&cmd_set_mplsoudp_encap_label_value,
15593 (void *)&cmd_set_mplsoudp_encap_udp_src,
15594 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
15595 (void *)&cmd_set_mplsoudp_encap_udp_dst,
15596 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
15597 (void *)&cmd_set_mplsoudp_encap_ip_src,
15598 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
15599 (void *)&cmd_set_mplsoudp_encap_ip_dst,
15600 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
15601 (void *)&cmd_set_mplsoudp_encap_vlan,
15602 (void *)&cmd_set_mplsoudp_encap_vlan_value,
15603 (void *)&cmd_set_mplsoudp_encap_eth_src,
15604 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
15605 (void *)&cmd_set_mplsoudp_encap_eth_dst,
15606 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
15611 /** Set MPLSoUDP decapsulation details */
15612 struct cmd_set_mplsoudp_decap_result {
15613 cmdline_fixed_string_t set;
15614 cmdline_fixed_string_t mplsoudp;
15615 cmdline_fixed_string_t pos_token;
15616 cmdline_fixed_string_t ip_version;
15617 uint32_t vlan_present:1;
15620 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
15621 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
15623 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
15624 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
15626 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
15627 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
15628 mplsoudp, "mplsoudp_decap-with-vlan");
15629 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
15630 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
15631 pos_token, "ip-version");
15632 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
15633 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
15634 ip_version, "ipv4#ipv6");
15636 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
15637 __rte_unused struct cmdline *cl,
15638 __rte_unused void *data)
15640 struct cmd_set_mplsoudp_decap_result *res = parsed_result;
15642 if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
15643 mplsoudp_decap_conf.select_vlan = 0;
15644 else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
15645 mplsoudp_decap_conf.select_vlan = 1;
15646 if (strcmp(res->ip_version, "ipv4") == 0)
15647 mplsoudp_decap_conf.select_ipv4 = 1;
15648 else if (strcmp(res->ip_version, "ipv6") == 0)
15649 mplsoudp_decap_conf.select_ipv4 = 0;
15652 cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
15653 .f = cmd_set_mplsoudp_decap_parsed,
15655 .help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
15657 (void *)&cmd_set_mplsoudp_decap_set,
15658 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
15659 (void *)&cmd_set_mplsoudp_decap_ip_version,
15660 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
15665 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
15666 .f = cmd_set_mplsoudp_decap_parsed,
15668 .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
15670 (void *)&cmd_set_mplsoudp_decap_set,
15671 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
15672 (void *)&cmd_set_mplsoudp_decap_ip_version,
15673 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
15678 /* Strict link priority scheduling mode setting */
15680 cmd_strict_link_prio_parsed(
15681 void *parsed_result,
15682 __rte_unused struct cmdline *cl,
15683 __rte_unused void *data)
15685 struct cmd_vf_tc_bw_result *res = parsed_result;
15686 int ret = -ENOTSUP;
15688 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15691 #ifdef RTE_NET_I40E
15692 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
15699 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
15702 printf("invalid port_id %d\n", res->port_id);
15705 printf("function not implemented\n");
15708 printf("programming error: (%s)\n", strerror(-ret));
15712 cmdline_parse_inst_t cmd_strict_link_prio = {
15713 .f = cmd_strict_link_prio_parsed,
15715 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
15717 (void *)&cmd_vf_tc_bw_set,
15718 (void *)&cmd_vf_tc_bw_tx,
15719 (void *)&cmd_vf_tc_bw_strict_link_prio,
15720 (void *)&cmd_vf_tc_bw_port_id,
15721 (void *)&cmd_vf_tc_bw_tc_map,
15726 /* Load dynamic device personalization*/
15727 struct cmd_ddp_add_result {
15728 cmdline_fixed_string_t ddp;
15729 cmdline_fixed_string_t add;
15734 cmdline_parse_token_string_t cmd_ddp_add_ddp =
15735 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
15736 cmdline_parse_token_string_t cmd_ddp_add_add =
15737 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
15738 cmdline_parse_token_num_t cmd_ddp_add_port_id =
15739 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
15740 cmdline_parse_token_string_t cmd_ddp_add_filepath =
15741 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
15744 cmd_ddp_add_parsed(
15745 void *parsed_result,
15746 __rte_unused struct cmdline *cl,
15747 __rte_unused void *data)
15749 struct cmd_ddp_add_result *res = parsed_result;
15755 int ret = -ENOTSUP;
15757 if (!all_ports_stopped()) {
15758 printf("Please stop all ports first\n");
15762 filepath = strdup(res->filepath);
15763 if (filepath == NULL) {
15764 printf("Failed to allocate memory\n");
15767 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
15769 buff = open_file(file_fld[0], &size);
15771 free((void *)filepath);
15775 #ifdef RTE_NET_I40E
15776 if (ret == -ENOTSUP)
15777 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
15779 RTE_PMD_I40E_PKG_OP_WR_ADD);
15782 if (ret == -EEXIST)
15783 printf("Profile has already existed.\n");
15785 printf("Failed to load profile.\n");
15786 else if (file_num == 2)
15787 save_file(file_fld[1], buff, size);
15790 free((void *)filepath);
15793 cmdline_parse_inst_t cmd_ddp_add = {
15794 .f = cmd_ddp_add_parsed,
15796 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
15798 (void *)&cmd_ddp_add_ddp,
15799 (void *)&cmd_ddp_add_add,
15800 (void *)&cmd_ddp_add_port_id,
15801 (void *)&cmd_ddp_add_filepath,
15806 /* Delete dynamic device personalization*/
15807 struct cmd_ddp_del_result {
15808 cmdline_fixed_string_t ddp;
15809 cmdline_fixed_string_t del;
15814 cmdline_parse_token_string_t cmd_ddp_del_ddp =
15815 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
15816 cmdline_parse_token_string_t cmd_ddp_del_del =
15817 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
15818 cmdline_parse_token_num_t cmd_ddp_del_port_id =
15819 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
15820 cmdline_parse_token_string_t cmd_ddp_del_filepath =
15821 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
15824 cmd_ddp_del_parsed(
15825 void *parsed_result,
15826 __rte_unused struct cmdline *cl,
15827 __rte_unused void *data)
15829 struct cmd_ddp_del_result *res = parsed_result;
15832 int ret = -ENOTSUP;
15834 if (!all_ports_stopped()) {
15835 printf("Please stop all ports first\n");
15839 buff = open_file(res->filepath, &size);
15843 #ifdef RTE_NET_I40E
15844 if (ret == -ENOTSUP)
15845 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
15847 RTE_PMD_I40E_PKG_OP_WR_DEL);
15850 if (ret == -EACCES)
15851 printf("Profile does not exist.\n");
15853 printf("Failed to delete profile.\n");
15858 cmdline_parse_inst_t cmd_ddp_del = {
15859 .f = cmd_ddp_del_parsed,
15861 .help_str = "ddp del <port_id> <backup_profile_path>",
15863 (void *)&cmd_ddp_del_ddp,
15864 (void *)&cmd_ddp_del_del,
15865 (void *)&cmd_ddp_del_port_id,
15866 (void *)&cmd_ddp_del_filepath,
15871 /* Get dynamic device personalization profile info */
15872 struct cmd_ddp_info_result {
15873 cmdline_fixed_string_t ddp;
15874 cmdline_fixed_string_t get;
15875 cmdline_fixed_string_t info;
15879 cmdline_parse_token_string_t cmd_ddp_info_ddp =
15880 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
15881 cmdline_parse_token_string_t cmd_ddp_info_get =
15882 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
15883 cmdline_parse_token_string_t cmd_ddp_info_info =
15884 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
15885 cmdline_parse_token_string_t cmd_ddp_info_filepath =
15886 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
15889 cmd_ddp_info_parsed(
15890 void *parsed_result,
15891 __rte_unused struct cmdline *cl,
15892 __rte_unused void *data)
15894 struct cmd_ddp_info_result *res = parsed_result;
15897 int ret = -ENOTSUP;
15898 #ifdef RTE_NET_I40E
15901 uint32_t buff_size = 0;
15902 struct rte_pmd_i40e_profile_info info;
15903 uint32_t dev_num = 0;
15904 struct rte_pmd_i40e_ddp_device_id *devs;
15905 uint32_t proto_num = 0;
15906 struct rte_pmd_i40e_proto_info *proto = NULL;
15907 uint32_t pctype_num = 0;
15908 struct rte_pmd_i40e_ptype_info *pctype;
15909 uint32_t ptype_num = 0;
15910 struct rte_pmd_i40e_ptype_info *ptype;
15915 pkg = open_file(res->filepath, &pkg_size);
15919 #ifdef RTE_NET_I40E
15920 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15921 (uint8_t *)&info, sizeof(info),
15922 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
15924 printf("Global Track id: 0x%x\n", info.track_id);
15925 printf("Global Version: %d.%d.%d.%d\n",
15926 info.version.major,
15927 info.version.minor,
15928 info.version.update,
15929 info.version.draft);
15930 printf("Global Package name: %s\n\n", info.name);
15933 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15934 (uint8_t *)&info, sizeof(info),
15935 RTE_PMD_I40E_PKG_INFO_HEADER);
15937 printf("i40e Profile Track id: 0x%x\n", info.track_id);
15938 printf("i40e Profile Version: %d.%d.%d.%d\n",
15939 info.version.major,
15940 info.version.minor,
15941 info.version.update,
15942 info.version.draft);
15943 printf("i40e Profile name: %s\n\n", info.name);
15946 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15947 (uint8_t *)&buff_size, sizeof(buff_size),
15948 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
15949 if (!ret && buff_size) {
15950 buff = (uint8_t *)malloc(buff_size);
15952 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15954 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
15956 printf("Package Notes:\n%s\n\n", buff);
15961 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15962 (uint8_t *)&dev_num, sizeof(dev_num),
15963 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
15964 if (!ret && dev_num) {
15965 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
15966 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
15968 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15969 (uint8_t *)devs, buff_size,
15970 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
15972 printf("List of supported devices:\n");
15973 for (i = 0; i < dev_num; i++) {
15974 printf(" %04X:%04X %04X:%04X\n",
15975 devs[i].vendor_dev_id >> 16,
15976 devs[i].vendor_dev_id & 0xFFFF,
15977 devs[i].sub_vendor_dev_id >> 16,
15978 devs[i].sub_vendor_dev_id & 0xFFFF);
15986 /* get information about protocols and packet types */
15987 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15988 (uint8_t *)&proto_num, sizeof(proto_num),
15989 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
15990 if (ret || !proto_num)
15991 goto no_print_return;
15993 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
15994 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
15996 goto no_print_return;
15998 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
16000 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
16002 printf("List of used protocols:\n");
16003 for (i = 0; i < proto_num; i++)
16004 printf(" %2u: %s\n", proto[i].proto_id,
16008 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16009 (uint8_t *)&pctype_num, sizeof(pctype_num),
16010 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
16011 if (ret || !pctype_num)
16012 goto no_print_pctypes;
16014 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16015 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16017 goto no_print_pctypes;
16019 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
16021 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
16024 goto no_print_pctypes;
16027 printf("List of defined packet classification types:\n");
16028 for (i = 0; i < pctype_num; i++) {
16029 printf(" %2u:", pctype[i].ptype_id);
16030 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
16031 proto_id = pctype[i].protocols[j];
16032 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
16033 for (n = 0; n < proto_num; n++) {
16034 if (proto[n].proto_id == proto_id) {
16035 printf(" %s", proto[n].name);
16048 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
16050 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
16051 if (ret || !ptype_num)
16052 goto no_print_return;
16054 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16055 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16057 goto no_print_return;
16059 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
16061 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
16064 goto no_print_return;
16066 printf("List of defined packet types:\n");
16067 for (i = 0; i < ptype_num; i++) {
16068 printf(" %2u:", ptype[i].ptype_id);
16069 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
16070 proto_id = ptype[i].protocols[j];
16071 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
16072 for (n = 0; n < proto_num; n++) {
16073 if (proto[n].proto_id == proto_id) {
16074 printf(" %s", proto[n].name);
16090 if (ret == -ENOTSUP)
16091 printf("Function not supported in PMD driver\n");
16095 cmdline_parse_inst_t cmd_ddp_get_info = {
16096 .f = cmd_ddp_info_parsed,
16098 .help_str = "ddp get info <profile_path>",
16100 (void *)&cmd_ddp_info_ddp,
16101 (void *)&cmd_ddp_info_get,
16102 (void *)&cmd_ddp_info_info,
16103 (void *)&cmd_ddp_info_filepath,
16108 /* Get dynamic device personalization profile info list*/
16109 #define PROFILE_INFO_SIZE 48
16110 #define MAX_PROFILE_NUM 16
16112 struct cmd_ddp_get_list_result {
16113 cmdline_fixed_string_t ddp;
16114 cmdline_fixed_string_t get;
16115 cmdline_fixed_string_t list;
16119 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
16120 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
16121 cmdline_parse_token_string_t cmd_ddp_get_list_get =
16122 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
16123 cmdline_parse_token_string_t cmd_ddp_get_list_list =
16124 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
16125 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
16126 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
16129 cmd_ddp_get_list_parsed(
16130 __rte_unused void *parsed_result,
16131 __rte_unused struct cmdline *cl,
16132 __rte_unused void *data)
16134 #ifdef RTE_NET_I40E
16135 struct cmd_ddp_get_list_result *res = parsed_result;
16136 struct rte_pmd_i40e_profile_list *p_list;
16137 struct rte_pmd_i40e_profile_info *p_info;
16142 int ret = -ENOTSUP;
16144 #ifdef RTE_NET_I40E
16145 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
16146 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
16148 printf("%s: Failed to malloc buffer\n", __func__);
16152 if (ret == -ENOTSUP)
16153 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
16154 (uint8_t *)p_list, size);
16157 p_num = p_list->p_count;
16158 printf("Profile number is: %d\n\n", p_num);
16160 for (i = 0; i < p_num; i++) {
16161 p_info = &p_list->p_info[i];
16162 printf("Profile %d:\n", i);
16163 printf("Track id: 0x%x\n", p_info->track_id);
16164 printf("Version: %d.%d.%d.%d\n",
16165 p_info->version.major,
16166 p_info->version.minor,
16167 p_info->version.update,
16168 p_info->version.draft);
16169 printf("Profile name: %s\n\n", p_info->name);
16177 printf("Failed to get ddp list\n");
16180 cmdline_parse_inst_t cmd_ddp_get_list = {
16181 .f = cmd_ddp_get_list_parsed,
16183 .help_str = "ddp get list <port_id>",
16185 (void *)&cmd_ddp_get_list_ddp,
16186 (void *)&cmd_ddp_get_list_get,
16187 (void *)&cmd_ddp_get_list_list,
16188 (void *)&cmd_ddp_get_list_port_id,
16193 /* Configure input set */
16194 struct cmd_cfg_input_set_result {
16195 cmdline_fixed_string_t port;
16196 cmdline_fixed_string_t cfg;
16198 cmdline_fixed_string_t pctype;
16200 cmdline_fixed_string_t inset_type;
16201 cmdline_fixed_string_t opt;
16202 cmdline_fixed_string_t field;
16207 cmd_cfg_input_set_parsed(
16208 __rte_unused void *parsed_result,
16209 __rte_unused struct cmdline *cl,
16210 __rte_unused void *data)
16212 #ifdef RTE_NET_I40E
16213 struct cmd_cfg_input_set_result *res = parsed_result;
16214 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
16215 struct rte_pmd_i40e_inset inset;
16217 int ret = -ENOTSUP;
16219 if (!all_ports_stopped()) {
16220 printf("Please stop all ports first\n");
16224 #ifdef RTE_NET_I40E
16225 if (!strcmp(res->inset_type, "hash_inset"))
16226 inset_type = INSET_HASH;
16227 else if (!strcmp(res->inset_type, "fdir_inset"))
16228 inset_type = INSET_FDIR;
16229 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
16230 inset_type = INSET_FDIR_FLX;
16231 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
16232 &inset, inset_type);
16234 printf("Failed to get input set.\n");
16238 if (!strcmp(res->opt, "get")) {
16239 ret = rte_pmd_i40e_inset_field_get(inset.inset,
16242 printf("Field index %d is enabled.\n", res->field_idx);
16244 printf("Field index %d is disabled.\n", res->field_idx);
16246 } else if (!strcmp(res->opt, "set"))
16247 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
16249 else if (!strcmp(res->opt, "clear"))
16250 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
16253 printf("Failed to configure input set field.\n");
16257 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
16258 &inset, inset_type);
16260 printf("Failed to set input set.\n");
16265 if (ret == -ENOTSUP)
16266 printf("Function not supported\n");
16269 cmdline_parse_token_string_t cmd_cfg_input_set_port =
16270 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16272 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
16273 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16275 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
16276 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16278 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
16279 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16281 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
16282 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16284 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
16285 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16287 "hash_inset#fdir_inset#fdir_flx_inset");
16288 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
16289 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16290 opt, "get#set#clear");
16291 cmdline_parse_token_string_t cmd_cfg_input_set_field =
16292 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16294 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
16295 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16298 cmdline_parse_inst_t cmd_cfg_input_set = {
16299 .f = cmd_cfg_input_set_parsed,
16301 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
16302 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
16304 (void *)&cmd_cfg_input_set_port,
16305 (void *)&cmd_cfg_input_set_cfg,
16306 (void *)&cmd_cfg_input_set_port_id,
16307 (void *)&cmd_cfg_input_set_pctype,
16308 (void *)&cmd_cfg_input_set_pctype_id,
16309 (void *)&cmd_cfg_input_set_inset_type,
16310 (void *)&cmd_cfg_input_set_opt,
16311 (void *)&cmd_cfg_input_set_field,
16312 (void *)&cmd_cfg_input_set_field_idx,
16317 /* Clear input set */
16318 struct cmd_clear_input_set_result {
16319 cmdline_fixed_string_t port;
16320 cmdline_fixed_string_t cfg;
16322 cmdline_fixed_string_t pctype;
16324 cmdline_fixed_string_t inset_type;
16325 cmdline_fixed_string_t clear;
16326 cmdline_fixed_string_t all;
16330 cmd_clear_input_set_parsed(
16331 __rte_unused void *parsed_result,
16332 __rte_unused struct cmdline *cl,
16333 __rte_unused void *data)
16335 #ifdef RTE_NET_I40E
16336 struct cmd_clear_input_set_result *res = parsed_result;
16337 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
16338 struct rte_pmd_i40e_inset inset;
16340 int ret = -ENOTSUP;
16342 if (!all_ports_stopped()) {
16343 printf("Please stop all ports first\n");
16347 #ifdef RTE_NET_I40E
16348 if (!strcmp(res->inset_type, "hash_inset"))
16349 inset_type = INSET_HASH;
16350 else if (!strcmp(res->inset_type, "fdir_inset"))
16351 inset_type = INSET_FDIR;
16352 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
16353 inset_type = INSET_FDIR_FLX;
16355 memset(&inset, 0, sizeof(inset));
16357 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
16358 &inset, inset_type);
16360 printf("Failed to clear input set.\n");
16366 if (ret == -ENOTSUP)
16367 printf("Function not supported\n");
16370 cmdline_parse_token_string_t cmd_clear_input_set_port =
16371 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16373 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
16374 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16376 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
16377 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
16379 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
16380 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16382 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
16383 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
16385 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
16386 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16388 "hash_inset#fdir_inset#fdir_flx_inset");
16389 cmdline_parse_token_string_t cmd_clear_input_set_clear =
16390 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16392 cmdline_parse_token_string_t cmd_clear_input_set_all =
16393 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16396 cmdline_parse_inst_t cmd_clear_input_set = {
16397 .f = cmd_clear_input_set_parsed,
16399 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
16400 "fdir_inset|fdir_flx_inset clear all",
16402 (void *)&cmd_clear_input_set_port,
16403 (void *)&cmd_clear_input_set_cfg,
16404 (void *)&cmd_clear_input_set_port_id,
16405 (void *)&cmd_clear_input_set_pctype,
16406 (void *)&cmd_clear_input_set_pctype_id,
16407 (void *)&cmd_clear_input_set_inset_type,
16408 (void *)&cmd_clear_input_set_clear,
16409 (void *)&cmd_clear_input_set_all,
16414 /* show vf stats */
16416 /* Common result structure for show vf stats */
16417 struct cmd_show_vf_stats_result {
16418 cmdline_fixed_string_t show;
16419 cmdline_fixed_string_t vf;
16420 cmdline_fixed_string_t stats;
16425 /* Common CLI fields show vf stats*/
16426 cmdline_parse_token_string_t cmd_show_vf_stats_show =
16427 TOKEN_STRING_INITIALIZER
16428 (struct cmd_show_vf_stats_result,
16430 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
16431 TOKEN_STRING_INITIALIZER
16432 (struct cmd_show_vf_stats_result,
16434 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
16435 TOKEN_STRING_INITIALIZER
16436 (struct cmd_show_vf_stats_result,
16438 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
16439 TOKEN_NUM_INITIALIZER
16440 (struct cmd_show_vf_stats_result,
16442 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
16443 TOKEN_NUM_INITIALIZER
16444 (struct cmd_show_vf_stats_result,
16448 cmd_show_vf_stats_parsed(
16449 void *parsed_result,
16450 __rte_unused struct cmdline *cl,
16451 __rte_unused void *data)
16453 struct cmd_show_vf_stats_result *res = parsed_result;
16454 struct rte_eth_stats stats;
16455 int ret = -ENOTSUP;
16456 static const char *nic_stats_border = "########################";
16458 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16461 memset(&stats, 0, sizeof(stats));
16463 #ifdef RTE_NET_I40E
16464 if (ret == -ENOTSUP)
16465 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
16469 #ifdef RTE_NET_BNXT
16470 if (ret == -ENOTSUP)
16471 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
16480 printf("invalid vf_id %d\n", res->vf_id);
16483 printf("invalid port_id %d\n", res->port_id);
16486 printf("function not implemented\n");
16489 printf("programming error: (%s)\n", strerror(-ret));
16492 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
16493 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
16495 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
16497 stats.ipackets, stats.imissed, stats.ibytes);
16498 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
16499 printf(" RX-nombuf: %-10"PRIu64"\n",
16501 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
16503 stats.opackets, stats.oerrors, stats.obytes);
16505 printf(" %s############################%s\n",
16506 nic_stats_border, nic_stats_border);
16509 cmdline_parse_inst_t cmd_show_vf_stats = {
16510 .f = cmd_show_vf_stats_parsed,
16512 .help_str = "show vf stats <port_id> <vf_id>",
16514 (void *)&cmd_show_vf_stats_show,
16515 (void *)&cmd_show_vf_stats_vf,
16516 (void *)&cmd_show_vf_stats_stats,
16517 (void *)&cmd_show_vf_stats_port_id,
16518 (void *)&cmd_show_vf_stats_vf_id,
16523 /* clear vf stats */
16525 /* Common result structure for clear vf stats */
16526 struct cmd_clear_vf_stats_result {
16527 cmdline_fixed_string_t clear;
16528 cmdline_fixed_string_t vf;
16529 cmdline_fixed_string_t stats;
16534 /* Common CLI fields clear vf stats*/
16535 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
16536 TOKEN_STRING_INITIALIZER
16537 (struct cmd_clear_vf_stats_result,
16539 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
16540 TOKEN_STRING_INITIALIZER
16541 (struct cmd_clear_vf_stats_result,
16543 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
16544 TOKEN_STRING_INITIALIZER
16545 (struct cmd_clear_vf_stats_result,
16547 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
16548 TOKEN_NUM_INITIALIZER
16549 (struct cmd_clear_vf_stats_result,
16551 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
16552 TOKEN_NUM_INITIALIZER
16553 (struct cmd_clear_vf_stats_result,
16557 cmd_clear_vf_stats_parsed(
16558 void *parsed_result,
16559 __rte_unused struct cmdline *cl,
16560 __rte_unused void *data)
16562 struct cmd_clear_vf_stats_result *res = parsed_result;
16563 int ret = -ENOTSUP;
16565 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16568 #ifdef RTE_NET_I40E
16569 if (ret == -ENOTSUP)
16570 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
16573 #ifdef RTE_NET_BNXT
16574 if (ret == -ENOTSUP)
16575 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
16583 printf("invalid vf_id %d\n", res->vf_id);
16586 printf("invalid port_id %d\n", res->port_id);
16589 printf("function not implemented\n");
16592 printf("programming error: (%s)\n", strerror(-ret));
16596 cmdline_parse_inst_t cmd_clear_vf_stats = {
16597 .f = cmd_clear_vf_stats_parsed,
16599 .help_str = "clear vf stats <port_id> <vf_id>",
16601 (void *)&cmd_clear_vf_stats_clear,
16602 (void *)&cmd_clear_vf_stats_vf,
16603 (void *)&cmd_clear_vf_stats_stats,
16604 (void *)&cmd_clear_vf_stats_port_id,
16605 (void *)&cmd_clear_vf_stats_vf_id,
16610 /* port config pctype mapping reset */
16612 /* Common result structure for port config pctype mapping reset */
16613 struct cmd_pctype_mapping_reset_result {
16614 cmdline_fixed_string_t port;
16615 cmdline_fixed_string_t config;
16617 cmdline_fixed_string_t pctype;
16618 cmdline_fixed_string_t mapping;
16619 cmdline_fixed_string_t reset;
16622 /* Common CLI fields for port config pctype mapping reset*/
16623 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
16624 TOKEN_STRING_INITIALIZER
16625 (struct cmd_pctype_mapping_reset_result,
16627 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
16628 TOKEN_STRING_INITIALIZER
16629 (struct cmd_pctype_mapping_reset_result,
16631 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
16632 TOKEN_NUM_INITIALIZER
16633 (struct cmd_pctype_mapping_reset_result,
16635 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
16636 TOKEN_STRING_INITIALIZER
16637 (struct cmd_pctype_mapping_reset_result,
16639 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
16640 TOKEN_STRING_INITIALIZER
16641 (struct cmd_pctype_mapping_reset_result,
16642 mapping, "mapping");
16643 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
16644 TOKEN_STRING_INITIALIZER
16645 (struct cmd_pctype_mapping_reset_result,
16649 cmd_pctype_mapping_reset_parsed(
16650 void *parsed_result,
16651 __rte_unused struct cmdline *cl,
16652 __rte_unused void *data)
16654 struct cmd_pctype_mapping_reset_result *res = parsed_result;
16655 int ret = -ENOTSUP;
16657 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16660 #ifdef RTE_NET_I40E
16661 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
16668 printf("invalid port_id %d\n", res->port_id);
16671 printf("function not implemented\n");
16674 printf("programming error: (%s)\n", strerror(-ret));
16678 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
16679 .f = cmd_pctype_mapping_reset_parsed,
16681 .help_str = "port config <port_id> pctype mapping reset",
16683 (void *)&cmd_pctype_mapping_reset_port,
16684 (void *)&cmd_pctype_mapping_reset_config,
16685 (void *)&cmd_pctype_mapping_reset_port_id,
16686 (void *)&cmd_pctype_mapping_reset_pctype,
16687 (void *)&cmd_pctype_mapping_reset_mapping,
16688 (void *)&cmd_pctype_mapping_reset_reset,
16693 /* show port pctype mapping */
16695 /* Common result structure for show port pctype mapping */
16696 struct cmd_pctype_mapping_get_result {
16697 cmdline_fixed_string_t show;
16698 cmdline_fixed_string_t port;
16700 cmdline_fixed_string_t pctype;
16701 cmdline_fixed_string_t mapping;
16704 /* Common CLI fields for pctype mapping get */
16705 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
16706 TOKEN_STRING_INITIALIZER
16707 (struct cmd_pctype_mapping_get_result,
16709 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
16710 TOKEN_STRING_INITIALIZER
16711 (struct cmd_pctype_mapping_get_result,
16713 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
16714 TOKEN_NUM_INITIALIZER
16715 (struct cmd_pctype_mapping_get_result,
16717 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
16718 TOKEN_STRING_INITIALIZER
16719 (struct cmd_pctype_mapping_get_result,
16721 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
16722 TOKEN_STRING_INITIALIZER
16723 (struct cmd_pctype_mapping_get_result,
16724 mapping, "mapping");
16727 cmd_pctype_mapping_get_parsed(
16728 void *parsed_result,
16729 __rte_unused struct cmdline *cl,
16730 __rte_unused void *data)
16732 struct cmd_pctype_mapping_get_result *res = parsed_result;
16733 int ret = -ENOTSUP;
16734 #ifdef RTE_NET_I40E
16735 struct rte_pmd_i40e_flow_type_mapping
16736 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
16737 int i, j, first_pctype;
16740 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16743 #ifdef RTE_NET_I40E
16744 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
16751 printf("invalid port_id %d\n", res->port_id);
16754 printf("function not implemented\n");
16757 printf("programming error: (%s)\n", strerror(-ret));
16761 #ifdef RTE_NET_I40E
16762 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
16763 if (mapping[i].pctype != 0ULL) {
16766 printf("pctype: ");
16767 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
16768 if (mapping[i].pctype & (1ULL << j)) {
16769 printf(first_pctype ?
16770 "%02d" : ",%02d", j);
16774 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
16780 cmdline_parse_inst_t cmd_pctype_mapping_get = {
16781 .f = cmd_pctype_mapping_get_parsed,
16783 .help_str = "show port <port_id> pctype mapping",
16785 (void *)&cmd_pctype_mapping_get_show,
16786 (void *)&cmd_pctype_mapping_get_port,
16787 (void *)&cmd_pctype_mapping_get_port_id,
16788 (void *)&cmd_pctype_mapping_get_pctype,
16789 (void *)&cmd_pctype_mapping_get_mapping,
16794 /* port config pctype mapping update */
16796 /* Common result structure for port config pctype mapping update */
16797 struct cmd_pctype_mapping_update_result {
16798 cmdline_fixed_string_t port;
16799 cmdline_fixed_string_t config;
16801 cmdline_fixed_string_t pctype;
16802 cmdline_fixed_string_t mapping;
16803 cmdline_fixed_string_t update;
16804 cmdline_fixed_string_t pctype_list;
16805 uint16_t flow_type;
16808 /* Common CLI fields for pctype mapping update*/
16809 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
16810 TOKEN_STRING_INITIALIZER
16811 (struct cmd_pctype_mapping_update_result,
16813 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
16814 TOKEN_STRING_INITIALIZER
16815 (struct cmd_pctype_mapping_update_result,
16817 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
16818 TOKEN_NUM_INITIALIZER
16819 (struct cmd_pctype_mapping_update_result,
16821 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
16822 TOKEN_STRING_INITIALIZER
16823 (struct cmd_pctype_mapping_update_result,
16825 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
16826 TOKEN_STRING_INITIALIZER
16827 (struct cmd_pctype_mapping_update_result,
16828 mapping, "mapping");
16829 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
16830 TOKEN_STRING_INITIALIZER
16831 (struct cmd_pctype_mapping_update_result,
16833 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
16834 TOKEN_STRING_INITIALIZER
16835 (struct cmd_pctype_mapping_update_result,
16836 pctype_list, NULL);
16837 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
16838 TOKEN_NUM_INITIALIZER
16839 (struct cmd_pctype_mapping_update_result,
16840 flow_type, UINT16);
16843 cmd_pctype_mapping_update_parsed(
16844 void *parsed_result,
16845 __rte_unused struct cmdline *cl,
16846 __rte_unused void *data)
16848 struct cmd_pctype_mapping_update_result *res = parsed_result;
16849 int ret = -ENOTSUP;
16850 #ifdef RTE_NET_I40E
16851 struct rte_pmd_i40e_flow_type_mapping mapping;
16853 unsigned int nb_item;
16854 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
16857 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16860 #ifdef RTE_NET_I40E
16861 nb_item = parse_item_list(res->pctype_list, "pctypes",
16862 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
16863 mapping.flow_type = res->flow_type;
16864 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
16865 mapping.pctype |= (1ULL << pctype_list[i]);
16866 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
16876 printf("invalid pctype or flow type\n");
16879 printf("invalid port_id %d\n", res->port_id);
16882 printf("function not implemented\n");
16885 printf("programming error: (%s)\n", strerror(-ret));
16889 cmdline_parse_inst_t cmd_pctype_mapping_update = {
16890 .f = cmd_pctype_mapping_update_parsed,
16892 .help_str = "port config <port_id> pctype mapping update"
16893 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
16895 (void *)&cmd_pctype_mapping_update_port,
16896 (void *)&cmd_pctype_mapping_update_config,
16897 (void *)&cmd_pctype_mapping_update_port_id,
16898 (void *)&cmd_pctype_mapping_update_pctype,
16899 (void *)&cmd_pctype_mapping_update_mapping,
16900 (void *)&cmd_pctype_mapping_update_update,
16901 (void *)&cmd_pctype_mapping_update_pc_type,
16902 (void *)&cmd_pctype_mapping_update_flow_type,
16907 /* ptype mapping get */
16909 /* Common result structure for ptype mapping get */
16910 struct cmd_ptype_mapping_get_result {
16911 cmdline_fixed_string_t ptype;
16912 cmdline_fixed_string_t mapping;
16913 cmdline_fixed_string_t get;
16915 uint8_t valid_only;
16918 /* Common CLI fields for ptype mapping get */
16919 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
16920 TOKEN_STRING_INITIALIZER
16921 (struct cmd_ptype_mapping_get_result,
16923 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
16924 TOKEN_STRING_INITIALIZER
16925 (struct cmd_ptype_mapping_get_result,
16926 mapping, "mapping");
16927 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
16928 TOKEN_STRING_INITIALIZER
16929 (struct cmd_ptype_mapping_get_result,
16931 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
16932 TOKEN_NUM_INITIALIZER
16933 (struct cmd_ptype_mapping_get_result,
16935 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
16936 TOKEN_NUM_INITIALIZER
16937 (struct cmd_ptype_mapping_get_result,
16938 valid_only, UINT8);
16941 cmd_ptype_mapping_get_parsed(
16942 void *parsed_result,
16943 __rte_unused struct cmdline *cl,
16944 __rte_unused void *data)
16946 struct cmd_ptype_mapping_get_result *res = parsed_result;
16947 int ret = -ENOTSUP;
16948 #ifdef RTE_NET_I40E
16949 int max_ptype_num = 256;
16950 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
16955 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16958 #ifdef RTE_NET_I40E
16959 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
16970 printf("invalid port_id %d\n", res->port_id);
16973 printf("function not implemented\n");
16976 printf("programming error: (%s)\n", strerror(-ret));
16979 #ifdef RTE_NET_I40E
16981 for (i = 0; i < count; i++)
16982 printf("%3d\t0x%08x\n",
16983 mapping[i].hw_ptype, mapping[i].sw_ptype);
16988 cmdline_parse_inst_t cmd_ptype_mapping_get = {
16989 .f = cmd_ptype_mapping_get_parsed,
16991 .help_str = "ptype mapping get <port_id> <valid_only>",
16993 (void *)&cmd_ptype_mapping_get_ptype,
16994 (void *)&cmd_ptype_mapping_get_mapping,
16995 (void *)&cmd_ptype_mapping_get_get,
16996 (void *)&cmd_ptype_mapping_get_port_id,
16997 (void *)&cmd_ptype_mapping_get_valid_only,
17002 /* ptype mapping replace */
17004 /* Common result structure for ptype mapping replace */
17005 struct cmd_ptype_mapping_replace_result {
17006 cmdline_fixed_string_t ptype;
17007 cmdline_fixed_string_t mapping;
17008 cmdline_fixed_string_t replace;
17015 /* Common CLI fields for ptype mapping replace */
17016 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
17017 TOKEN_STRING_INITIALIZER
17018 (struct cmd_ptype_mapping_replace_result,
17020 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
17021 TOKEN_STRING_INITIALIZER
17022 (struct cmd_ptype_mapping_replace_result,
17023 mapping, "mapping");
17024 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
17025 TOKEN_STRING_INITIALIZER
17026 (struct cmd_ptype_mapping_replace_result,
17027 replace, "replace");
17028 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
17029 TOKEN_NUM_INITIALIZER
17030 (struct cmd_ptype_mapping_replace_result,
17032 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
17033 TOKEN_NUM_INITIALIZER
17034 (struct cmd_ptype_mapping_replace_result,
17036 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
17037 TOKEN_NUM_INITIALIZER
17038 (struct cmd_ptype_mapping_replace_result,
17040 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
17041 TOKEN_NUM_INITIALIZER
17042 (struct cmd_ptype_mapping_replace_result,
17046 cmd_ptype_mapping_replace_parsed(
17047 void *parsed_result,
17048 __rte_unused struct cmdline *cl,
17049 __rte_unused void *data)
17051 struct cmd_ptype_mapping_replace_result *res = parsed_result;
17052 int ret = -ENOTSUP;
17054 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17057 #ifdef RTE_NET_I40E
17058 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
17068 printf("invalid ptype 0x%8x or 0x%8x\n",
17069 res->target, res->pkt_type);
17072 printf("invalid port_id %d\n", res->port_id);
17075 printf("function not implemented\n");
17078 printf("programming error: (%s)\n", strerror(-ret));
17082 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
17083 .f = cmd_ptype_mapping_replace_parsed,
17086 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
17088 (void *)&cmd_ptype_mapping_replace_ptype,
17089 (void *)&cmd_ptype_mapping_replace_mapping,
17090 (void *)&cmd_ptype_mapping_replace_replace,
17091 (void *)&cmd_ptype_mapping_replace_port_id,
17092 (void *)&cmd_ptype_mapping_replace_target,
17093 (void *)&cmd_ptype_mapping_replace_mask,
17094 (void *)&cmd_ptype_mapping_replace_pkt_type,
17099 /* ptype mapping reset */
17101 /* Common result structure for ptype mapping reset */
17102 struct cmd_ptype_mapping_reset_result {
17103 cmdline_fixed_string_t ptype;
17104 cmdline_fixed_string_t mapping;
17105 cmdline_fixed_string_t reset;
17109 /* Common CLI fields for ptype mapping reset*/
17110 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
17111 TOKEN_STRING_INITIALIZER
17112 (struct cmd_ptype_mapping_reset_result,
17114 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
17115 TOKEN_STRING_INITIALIZER
17116 (struct cmd_ptype_mapping_reset_result,
17117 mapping, "mapping");
17118 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
17119 TOKEN_STRING_INITIALIZER
17120 (struct cmd_ptype_mapping_reset_result,
17122 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
17123 TOKEN_NUM_INITIALIZER
17124 (struct cmd_ptype_mapping_reset_result,
17128 cmd_ptype_mapping_reset_parsed(
17129 void *parsed_result,
17130 __rte_unused struct cmdline *cl,
17131 __rte_unused void *data)
17133 struct cmd_ptype_mapping_reset_result *res = parsed_result;
17134 int ret = -ENOTSUP;
17136 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17139 #ifdef RTE_NET_I40E
17140 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
17147 printf("invalid port_id %d\n", res->port_id);
17150 printf("function not implemented\n");
17153 printf("programming error: (%s)\n", strerror(-ret));
17157 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
17158 .f = cmd_ptype_mapping_reset_parsed,
17160 .help_str = "ptype mapping reset <port_id>",
17162 (void *)&cmd_ptype_mapping_reset_ptype,
17163 (void *)&cmd_ptype_mapping_reset_mapping,
17164 (void *)&cmd_ptype_mapping_reset_reset,
17165 (void *)&cmd_ptype_mapping_reset_port_id,
17170 /* ptype mapping update */
17172 /* Common result structure for ptype mapping update */
17173 struct cmd_ptype_mapping_update_result {
17174 cmdline_fixed_string_t ptype;
17175 cmdline_fixed_string_t mapping;
17176 cmdline_fixed_string_t reset;
17182 /* Common CLI fields for ptype mapping update*/
17183 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
17184 TOKEN_STRING_INITIALIZER
17185 (struct cmd_ptype_mapping_update_result,
17187 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
17188 TOKEN_STRING_INITIALIZER
17189 (struct cmd_ptype_mapping_update_result,
17190 mapping, "mapping");
17191 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
17192 TOKEN_STRING_INITIALIZER
17193 (struct cmd_ptype_mapping_update_result,
17195 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
17196 TOKEN_NUM_INITIALIZER
17197 (struct cmd_ptype_mapping_update_result,
17199 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
17200 TOKEN_NUM_INITIALIZER
17201 (struct cmd_ptype_mapping_update_result,
17203 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
17204 TOKEN_NUM_INITIALIZER
17205 (struct cmd_ptype_mapping_update_result,
17209 cmd_ptype_mapping_update_parsed(
17210 void *parsed_result,
17211 __rte_unused struct cmdline *cl,
17212 __rte_unused void *data)
17214 struct cmd_ptype_mapping_update_result *res = parsed_result;
17215 int ret = -ENOTSUP;
17216 #ifdef RTE_NET_I40E
17217 struct rte_pmd_i40e_ptype_mapping mapping;
17219 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17222 #ifdef RTE_NET_I40E
17223 mapping.hw_ptype = res->hw_ptype;
17224 mapping.sw_ptype = res->sw_ptype;
17225 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
17235 printf("invalid ptype 0x%8x\n", res->sw_ptype);
17238 printf("invalid port_id %d\n", res->port_id);
17241 printf("function not implemented\n");
17244 printf("programming error: (%s)\n", strerror(-ret));
17248 cmdline_parse_inst_t cmd_ptype_mapping_update = {
17249 .f = cmd_ptype_mapping_update_parsed,
17251 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
17253 (void *)&cmd_ptype_mapping_update_ptype,
17254 (void *)&cmd_ptype_mapping_update_mapping,
17255 (void *)&cmd_ptype_mapping_update_update,
17256 (void *)&cmd_ptype_mapping_update_port_id,
17257 (void *)&cmd_ptype_mapping_update_hw_ptype,
17258 (void *)&cmd_ptype_mapping_update_sw_ptype,
17263 /* Common result structure for file commands */
17264 struct cmd_cmdfile_result {
17265 cmdline_fixed_string_t load;
17266 cmdline_fixed_string_t filename;
17269 /* Common CLI fields for file commands */
17270 cmdline_parse_token_string_t cmd_load_cmdfile =
17271 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
17272 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
17273 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
17276 cmd_load_from_file_parsed(
17277 void *parsed_result,
17278 __rte_unused struct cmdline *cl,
17279 __rte_unused void *data)
17281 struct cmd_cmdfile_result *res = parsed_result;
17283 cmdline_read_from_file(res->filename);
17286 cmdline_parse_inst_t cmd_load_from_file = {
17287 .f = cmd_load_from_file_parsed,
17289 .help_str = "load <filename>",
17291 (void *)&cmd_load_cmdfile,
17292 (void *)&cmd_load_cmdfile_filename,
17297 /* Get Rx offloads capabilities */
17298 struct cmd_rx_offload_get_capa_result {
17299 cmdline_fixed_string_t show;
17300 cmdline_fixed_string_t port;
17302 cmdline_fixed_string_t rx_offload;
17303 cmdline_fixed_string_t capabilities;
17306 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
17307 TOKEN_STRING_INITIALIZER
17308 (struct cmd_rx_offload_get_capa_result,
17310 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
17311 TOKEN_STRING_INITIALIZER
17312 (struct cmd_rx_offload_get_capa_result,
17314 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
17315 TOKEN_NUM_INITIALIZER
17316 (struct cmd_rx_offload_get_capa_result,
17318 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
17319 TOKEN_STRING_INITIALIZER
17320 (struct cmd_rx_offload_get_capa_result,
17321 rx_offload, "rx_offload");
17322 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
17323 TOKEN_STRING_INITIALIZER
17324 (struct cmd_rx_offload_get_capa_result,
17325 capabilities, "capabilities");
17328 print_rx_offloads(uint64_t offloads)
17330 uint64_t single_offload;
17338 begin = __builtin_ctzll(offloads);
17339 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
17341 single_offload = 1ULL << begin;
17342 for (bit = begin; bit < end; bit++) {
17343 if (offloads & single_offload)
17345 rte_eth_dev_rx_offload_name(single_offload));
17346 single_offload <<= 1;
17351 cmd_rx_offload_get_capa_parsed(
17352 void *parsed_result,
17353 __rte_unused struct cmdline *cl,
17354 __rte_unused void *data)
17356 struct cmd_rx_offload_get_capa_result *res = parsed_result;
17357 struct rte_eth_dev_info dev_info;
17358 portid_t port_id = res->port_id;
17359 uint64_t queue_offloads;
17360 uint64_t port_offloads;
17363 ret = eth_dev_info_get_print_err(port_id, &dev_info);
17367 queue_offloads = dev_info.rx_queue_offload_capa;
17368 port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
17370 printf("Rx Offloading Capabilities of port %d :\n", port_id);
17371 printf(" Per Queue :");
17372 print_rx_offloads(queue_offloads);
17375 printf(" Per Port :");
17376 print_rx_offloads(port_offloads);
17380 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
17381 .f = cmd_rx_offload_get_capa_parsed,
17383 .help_str = "show port <port_id> rx_offload capabilities",
17385 (void *)&cmd_rx_offload_get_capa_show,
17386 (void *)&cmd_rx_offload_get_capa_port,
17387 (void *)&cmd_rx_offload_get_capa_port_id,
17388 (void *)&cmd_rx_offload_get_capa_rx_offload,
17389 (void *)&cmd_rx_offload_get_capa_capabilities,
17394 /* Get Rx offloads configuration */
17395 struct cmd_rx_offload_get_configuration_result {
17396 cmdline_fixed_string_t show;
17397 cmdline_fixed_string_t port;
17399 cmdline_fixed_string_t rx_offload;
17400 cmdline_fixed_string_t configuration;
17403 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
17404 TOKEN_STRING_INITIALIZER
17405 (struct cmd_rx_offload_get_configuration_result,
17407 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
17408 TOKEN_STRING_INITIALIZER
17409 (struct cmd_rx_offload_get_configuration_result,
17411 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
17412 TOKEN_NUM_INITIALIZER
17413 (struct cmd_rx_offload_get_configuration_result,
17415 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
17416 TOKEN_STRING_INITIALIZER
17417 (struct cmd_rx_offload_get_configuration_result,
17418 rx_offload, "rx_offload");
17419 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
17420 TOKEN_STRING_INITIALIZER
17421 (struct cmd_rx_offload_get_configuration_result,
17422 configuration, "configuration");
17425 cmd_rx_offload_get_configuration_parsed(
17426 void *parsed_result,
17427 __rte_unused struct cmdline *cl,
17428 __rte_unused void *data)
17430 struct cmd_rx_offload_get_configuration_result *res = parsed_result;
17431 struct rte_eth_dev_info dev_info;
17432 portid_t port_id = res->port_id;
17433 struct rte_port *port = &ports[port_id];
17434 uint64_t port_offloads;
17435 uint64_t queue_offloads;
17436 uint16_t nb_rx_queues;
17440 printf("Rx Offloading Configuration of port %d :\n", port_id);
17442 port_offloads = port->dev_conf.rxmode.offloads;
17444 print_rx_offloads(port_offloads);
17447 ret = eth_dev_info_get_print_err(port_id, &dev_info);
17451 nb_rx_queues = dev_info.nb_rx_queues;
17452 for (q = 0; q < nb_rx_queues; q++) {
17453 queue_offloads = port->rx_conf[q].offloads;
17454 printf(" Queue[%2d] :", q);
17455 print_rx_offloads(queue_offloads);
17461 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
17462 .f = cmd_rx_offload_get_configuration_parsed,
17464 .help_str = "show port <port_id> rx_offload configuration",
17466 (void *)&cmd_rx_offload_get_configuration_show,
17467 (void *)&cmd_rx_offload_get_configuration_port,
17468 (void *)&cmd_rx_offload_get_configuration_port_id,
17469 (void *)&cmd_rx_offload_get_configuration_rx_offload,
17470 (void *)&cmd_rx_offload_get_configuration_configuration,
17475 /* Enable/Disable a per port offloading */
17476 struct cmd_config_per_port_rx_offload_result {
17477 cmdline_fixed_string_t port;
17478 cmdline_fixed_string_t config;
17480 cmdline_fixed_string_t rx_offload;
17481 cmdline_fixed_string_t offload;
17482 cmdline_fixed_string_t on_off;
17485 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
17486 TOKEN_STRING_INITIALIZER
17487 (struct cmd_config_per_port_rx_offload_result,
17489 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
17490 TOKEN_STRING_INITIALIZER
17491 (struct cmd_config_per_port_rx_offload_result,
17493 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
17494 TOKEN_NUM_INITIALIZER
17495 (struct cmd_config_per_port_rx_offload_result,
17497 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
17498 TOKEN_STRING_INITIALIZER
17499 (struct cmd_config_per_port_rx_offload_result,
17500 rx_offload, "rx_offload");
17501 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
17502 TOKEN_STRING_INITIALIZER
17503 (struct cmd_config_per_port_rx_offload_result,
17504 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
17505 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
17506 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
17507 "scatter#buffer_split#timestamp#security#"
17508 "keep_crc#rss_hash");
17509 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
17510 TOKEN_STRING_INITIALIZER
17511 (struct cmd_config_per_port_rx_offload_result,
17515 search_rx_offload(const char *name)
17517 uint64_t single_offload;
17518 const char *single_name;
17522 single_offload = 1;
17523 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
17524 single_name = rte_eth_dev_rx_offload_name(single_offload);
17525 if (!strcasecmp(single_name, name)) {
17529 single_offload <<= 1;
17533 return single_offload;
17539 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
17540 __rte_unused struct cmdline *cl,
17541 __rte_unused void *data)
17543 struct cmd_config_per_port_rx_offload_result *res = parsed_result;
17544 portid_t port_id = res->port_id;
17545 struct rte_eth_dev_info dev_info;
17546 struct rte_port *port = &ports[port_id];
17547 uint64_t single_offload;
17548 uint16_t nb_rx_queues;
17552 if (port->port_status != RTE_PORT_STOPPED) {
17553 printf("Error: Can't config offload when Port %d "
17554 "is not stopped\n", port_id);
17558 single_offload = search_rx_offload(res->offload);
17559 if (single_offload == 0) {
17560 printf("Unknown offload name: %s\n", res->offload);
17564 ret = eth_dev_info_get_print_err(port_id, &dev_info);
17568 nb_rx_queues = dev_info.nb_rx_queues;
17569 if (!strcmp(res->on_off, "on")) {
17570 port->dev_conf.rxmode.offloads |= single_offload;
17571 for (q = 0; q < nb_rx_queues; q++)
17572 port->rx_conf[q].offloads |= single_offload;
17574 port->dev_conf.rxmode.offloads &= ~single_offload;
17575 for (q = 0; q < nb_rx_queues; q++)
17576 port->rx_conf[q].offloads &= ~single_offload;
17579 cmd_reconfig_device_queue(port_id, 1, 1);
17582 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
17583 .f = cmd_config_per_port_rx_offload_parsed,
17585 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
17586 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
17587 "macsec_strip|header_split|vlan_filter|vlan_extend|"
17588 "jumbo_frame|scatter|buffer_split|timestamp|security|"
17589 "keep_crc|rss_hash on|off",
17591 (void *)&cmd_config_per_port_rx_offload_result_port,
17592 (void *)&cmd_config_per_port_rx_offload_result_config,
17593 (void *)&cmd_config_per_port_rx_offload_result_port_id,
17594 (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
17595 (void *)&cmd_config_per_port_rx_offload_result_offload,
17596 (void *)&cmd_config_per_port_rx_offload_result_on_off,
17601 /* Enable/Disable a per queue offloading */
17602 struct cmd_config_per_queue_rx_offload_result {
17603 cmdline_fixed_string_t port;
17605 cmdline_fixed_string_t rxq;
17607 cmdline_fixed_string_t rx_offload;
17608 cmdline_fixed_string_t offload;
17609 cmdline_fixed_string_t on_off;
17612 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
17613 TOKEN_STRING_INITIALIZER
17614 (struct cmd_config_per_queue_rx_offload_result,
17616 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
17617 TOKEN_NUM_INITIALIZER
17618 (struct cmd_config_per_queue_rx_offload_result,
17620 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
17621 TOKEN_STRING_INITIALIZER
17622 (struct cmd_config_per_queue_rx_offload_result,
17624 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
17625 TOKEN_NUM_INITIALIZER
17626 (struct cmd_config_per_queue_rx_offload_result,
17628 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
17629 TOKEN_STRING_INITIALIZER
17630 (struct cmd_config_per_queue_rx_offload_result,
17631 rx_offload, "rx_offload");
17632 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
17633 TOKEN_STRING_INITIALIZER
17634 (struct cmd_config_per_queue_rx_offload_result,
17635 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
17636 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
17637 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
17638 "scatter#buffer_split#timestamp#security#keep_crc");
17639 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
17640 TOKEN_STRING_INITIALIZER
17641 (struct cmd_config_per_queue_rx_offload_result,
17645 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
17646 __rte_unused struct cmdline *cl,
17647 __rte_unused void *data)
17649 struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
17650 struct rte_eth_dev_info dev_info;
17651 portid_t port_id = res->port_id;
17652 uint16_t queue_id = res->queue_id;
17653 struct rte_port *port = &ports[port_id];
17654 uint64_t single_offload;
17657 if (port->port_status != RTE_PORT_STOPPED) {
17658 printf("Error: Can't config offload when Port %d "
17659 "is not stopped\n", port_id);
17663 ret = eth_dev_info_get_print_err(port_id, &dev_info);
17667 if (queue_id >= dev_info.nb_rx_queues) {
17668 printf("Error: input queue_id should be 0 ... "
17669 "%d\n", dev_info.nb_rx_queues - 1);
17673 single_offload = search_rx_offload(res->offload);
17674 if (single_offload == 0) {
17675 printf("Unknown offload name: %s\n", res->offload);
17679 if (!strcmp(res->on_off, "on"))
17680 port->rx_conf[queue_id].offloads |= single_offload;
17682 port->rx_conf[queue_id].offloads &= ~single_offload;
17684 cmd_reconfig_device_queue(port_id, 1, 1);
17687 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
17688 .f = cmd_config_per_queue_rx_offload_parsed,
17690 .help_str = "port <port_id> rxq <queue_id> rx_offload "
17691 "vlan_strip|ipv4_cksum|"
17692 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
17693 "macsec_strip|header_split|vlan_filter|vlan_extend|"
17694 "jumbo_frame|scatter|buffer_split|timestamp|security|"
17697 (void *)&cmd_config_per_queue_rx_offload_result_port,
17698 (void *)&cmd_config_per_queue_rx_offload_result_port_id,
17699 (void *)&cmd_config_per_queue_rx_offload_result_rxq,
17700 (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
17701 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
17702 (void *)&cmd_config_per_queue_rx_offload_result_offload,
17703 (void *)&cmd_config_per_queue_rx_offload_result_on_off,
17708 /* Get Tx offloads capabilities */
17709 struct cmd_tx_offload_get_capa_result {
17710 cmdline_fixed_string_t show;
17711 cmdline_fixed_string_t port;
17713 cmdline_fixed_string_t tx_offload;
17714 cmdline_fixed_string_t capabilities;
17717 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
17718 TOKEN_STRING_INITIALIZER
17719 (struct cmd_tx_offload_get_capa_result,
17721 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
17722 TOKEN_STRING_INITIALIZER
17723 (struct cmd_tx_offload_get_capa_result,
17725 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
17726 TOKEN_NUM_INITIALIZER
17727 (struct cmd_tx_offload_get_capa_result,
17729 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
17730 TOKEN_STRING_INITIALIZER
17731 (struct cmd_tx_offload_get_capa_result,
17732 tx_offload, "tx_offload");
17733 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
17734 TOKEN_STRING_INITIALIZER
17735 (struct cmd_tx_offload_get_capa_result,
17736 capabilities, "capabilities");
17739 print_tx_offloads(uint64_t offloads)
17741 uint64_t single_offload;
17749 begin = __builtin_ctzll(offloads);
17750 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
17752 single_offload = 1ULL << begin;
17753 for (bit = begin; bit < end; bit++) {
17754 if (offloads & single_offload)
17756 rte_eth_dev_tx_offload_name(single_offload));
17757 single_offload <<= 1;
17762 cmd_tx_offload_get_capa_parsed(
17763 void *parsed_result,
17764 __rte_unused struct cmdline *cl,
17765 __rte_unused void *data)
17767 struct cmd_tx_offload_get_capa_result *res = parsed_result;
17768 struct rte_eth_dev_info dev_info;
17769 portid_t port_id = res->port_id;
17770 uint64_t queue_offloads;
17771 uint64_t port_offloads;
17774 ret = eth_dev_info_get_print_err(port_id, &dev_info);
17778 queue_offloads = dev_info.tx_queue_offload_capa;
17779 port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
17781 printf("Tx Offloading Capabilities of port %d :\n", port_id);
17782 printf(" Per Queue :");
17783 print_tx_offloads(queue_offloads);
17786 printf(" Per Port :");
17787 print_tx_offloads(port_offloads);
17791 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
17792 .f = cmd_tx_offload_get_capa_parsed,
17794 .help_str = "show port <port_id> tx_offload capabilities",
17796 (void *)&cmd_tx_offload_get_capa_show,
17797 (void *)&cmd_tx_offload_get_capa_port,
17798 (void *)&cmd_tx_offload_get_capa_port_id,
17799 (void *)&cmd_tx_offload_get_capa_tx_offload,
17800 (void *)&cmd_tx_offload_get_capa_capabilities,
17805 /* Get Tx offloads configuration */
17806 struct cmd_tx_offload_get_configuration_result {
17807 cmdline_fixed_string_t show;
17808 cmdline_fixed_string_t port;
17810 cmdline_fixed_string_t tx_offload;
17811 cmdline_fixed_string_t configuration;
17814 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
17815 TOKEN_STRING_INITIALIZER
17816 (struct cmd_tx_offload_get_configuration_result,
17818 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
17819 TOKEN_STRING_INITIALIZER
17820 (struct cmd_tx_offload_get_configuration_result,
17822 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
17823 TOKEN_NUM_INITIALIZER
17824 (struct cmd_tx_offload_get_configuration_result,
17826 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
17827 TOKEN_STRING_INITIALIZER
17828 (struct cmd_tx_offload_get_configuration_result,
17829 tx_offload, "tx_offload");
17830 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
17831 TOKEN_STRING_INITIALIZER
17832 (struct cmd_tx_offload_get_configuration_result,
17833 configuration, "configuration");
17836 cmd_tx_offload_get_configuration_parsed(
17837 void *parsed_result,
17838 __rte_unused struct cmdline *cl,
17839 __rte_unused void *data)
17841 struct cmd_tx_offload_get_configuration_result *res = parsed_result;
17842 struct rte_eth_dev_info dev_info;
17843 portid_t port_id = res->port_id;
17844 struct rte_port *port = &ports[port_id];
17845 uint64_t port_offloads;
17846 uint64_t queue_offloads;
17847 uint16_t nb_tx_queues;
17851 printf("Tx Offloading Configuration of port %d :\n", port_id);
17853 port_offloads = port->dev_conf.txmode.offloads;
17855 print_tx_offloads(port_offloads);
17858 ret = eth_dev_info_get_print_err(port_id, &dev_info);
17862 nb_tx_queues = dev_info.nb_tx_queues;
17863 for (q = 0; q < nb_tx_queues; q++) {
17864 queue_offloads = port->tx_conf[q].offloads;
17865 printf(" Queue[%2d] :", q);
17866 print_tx_offloads(queue_offloads);
17872 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
17873 .f = cmd_tx_offload_get_configuration_parsed,
17875 .help_str = "show port <port_id> tx_offload configuration",
17877 (void *)&cmd_tx_offload_get_configuration_show,
17878 (void *)&cmd_tx_offload_get_configuration_port,
17879 (void *)&cmd_tx_offload_get_configuration_port_id,
17880 (void *)&cmd_tx_offload_get_configuration_tx_offload,
17881 (void *)&cmd_tx_offload_get_configuration_configuration,
17886 /* Enable/Disable a per port offloading */
17887 struct cmd_config_per_port_tx_offload_result {
17888 cmdline_fixed_string_t port;
17889 cmdline_fixed_string_t config;
17891 cmdline_fixed_string_t tx_offload;
17892 cmdline_fixed_string_t offload;
17893 cmdline_fixed_string_t on_off;
17896 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
17897 TOKEN_STRING_INITIALIZER
17898 (struct cmd_config_per_port_tx_offload_result,
17900 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
17901 TOKEN_STRING_INITIALIZER
17902 (struct cmd_config_per_port_tx_offload_result,
17904 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
17905 TOKEN_NUM_INITIALIZER
17906 (struct cmd_config_per_port_tx_offload_result,
17908 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
17909 TOKEN_STRING_INITIALIZER
17910 (struct cmd_config_per_port_tx_offload_result,
17911 tx_offload, "tx_offload");
17912 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
17913 TOKEN_STRING_INITIALIZER
17914 (struct cmd_config_per_port_tx_offload_result,
17915 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
17916 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
17917 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
17918 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
17919 "mt_lockfree#multi_segs#mbuf_fast_free#security#"
17920 "send_on_timestamp");
17921 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
17922 TOKEN_STRING_INITIALIZER
17923 (struct cmd_config_per_port_tx_offload_result,
17927 search_tx_offload(const char *name)
17929 uint64_t single_offload;
17930 const char *single_name;
17934 single_offload = 1;
17935 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
17936 single_name = rte_eth_dev_tx_offload_name(single_offload);
17937 if (single_name == NULL)
17939 if (!strcasecmp(single_name, name)) {
17942 } else if (!strcasecmp(single_name, "UNKNOWN"))
17944 single_offload <<= 1;
17948 return single_offload;
17954 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
17955 __rte_unused struct cmdline *cl,
17956 __rte_unused void *data)
17958 struct cmd_config_per_port_tx_offload_result *res = parsed_result;
17959 portid_t port_id = res->port_id;
17960 struct rte_eth_dev_info dev_info;
17961 struct rte_port *port = &ports[port_id];
17962 uint64_t single_offload;
17963 uint16_t nb_tx_queues;
17967 if (port->port_status != RTE_PORT_STOPPED) {
17968 printf("Error: Can't config offload when Port %d "
17969 "is not stopped\n", port_id);
17973 single_offload = search_tx_offload(res->offload);
17974 if (single_offload == 0) {
17975 printf("Unknown offload name: %s\n", res->offload);
17979 ret = eth_dev_info_get_print_err(port_id, &dev_info);
17983 nb_tx_queues = dev_info.nb_tx_queues;
17984 if (!strcmp(res->on_off, "on")) {
17985 port->dev_conf.txmode.offloads |= single_offload;
17986 for (q = 0; q < nb_tx_queues; q++)
17987 port->tx_conf[q].offloads |= single_offload;
17989 port->dev_conf.txmode.offloads &= ~single_offload;
17990 for (q = 0; q < nb_tx_queues; q++)
17991 port->tx_conf[q].offloads &= ~single_offload;
17994 cmd_reconfig_device_queue(port_id, 1, 1);
17997 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
17998 .f = cmd_config_per_port_tx_offload_parsed,
18000 .help_str = "port config <port_id> tx_offload "
18001 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
18002 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
18003 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
18004 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
18005 "mt_lockfree|multi_segs|mbuf_fast_free|security|"
18006 "send_on_timestamp on|off",
18008 (void *)&cmd_config_per_port_tx_offload_result_port,
18009 (void *)&cmd_config_per_port_tx_offload_result_config,
18010 (void *)&cmd_config_per_port_tx_offload_result_port_id,
18011 (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
18012 (void *)&cmd_config_per_port_tx_offload_result_offload,
18013 (void *)&cmd_config_per_port_tx_offload_result_on_off,
18018 /* Enable/Disable a per queue offloading */
18019 struct cmd_config_per_queue_tx_offload_result {
18020 cmdline_fixed_string_t port;
18022 cmdline_fixed_string_t txq;
18024 cmdline_fixed_string_t tx_offload;
18025 cmdline_fixed_string_t offload;
18026 cmdline_fixed_string_t on_off;
18029 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
18030 TOKEN_STRING_INITIALIZER
18031 (struct cmd_config_per_queue_tx_offload_result,
18033 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
18034 TOKEN_NUM_INITIALIZER
18035 (struct cmd_config_per_queue_tx_offload_result,
18037 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
18038 TOKEN_STRING_INITIALIZER
18039 (struct cmd_config_per_queue_tx_offload_result,
18041 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
18042 TOKEN_NUM_INITIALIZER
18043 (struct cmd_config_per_queue_tx_offload_result,
18045 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
18046 TOKEN_STRING_INITIALIZER
18047 (struct cmd_config_per_queue_tx_offload_result,
18048 tx_offload, "tx_offload");
18049 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
18050 TOKEN_STRING_INITIALIZER
18051 (struct cmd_config_per_queue_tx_offload_result,
18052 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18053 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18054 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18055 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18056 "mt_lockfree#multi_segs#mbuf_fast_free#security");
18057 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
18058 TOKEN_STRING_INITIALIZER
18059 (struct cmd_config_per_queue_tx_offload_result,
18063 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
18064 __rte_unused struct cmdline *cl,
18065 __rte_unused void *data)
18067 struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
18068 struct rte_eth_dev_info dev_info;
18069 portid_t port_id = res->port_id;
18070 uint16_t queue_id = res->queue_id;
18071 struct rte_port *port = &ports[port_id];
18072 uint64_t single_offload;
18075 if (port->port_status != RTE_PORT_STOPPED) {
18076 printf("Error: Can't config offload when Port %d "
18077 "is not stopped\n", port_id);
18081 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18085 if (queue_id >= dev_info.nb_tx_queues) {
18086 printf("Error: input queue_id should be 0 ... "
18087 "%d\n", dev_info.nb_tx_queues - 1);
18091 single_offload = search_tx_offload(res->offload);
18092 if (single_offload == 0) {
18093 printf("Unknown offload name: %s\n", res->offload);
18097 if (!strcmp(res->on_off, "on"))
18098 port->tx_conf[queue_id].offloads |= single_offload;
18100 port->tx_conf[queue_id].offloads &= ~single_offload;
18102 cmd_reconfig_device_queue(port_id, 1, 1);
18105 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
18106 .f = cmd_config_per_queue_tx_offload_parsed,
18108 .help_str = "port <port_id> txq <queue_id> tx_offload "
18109 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
18110 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
18111 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
18112 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
18113 "mt_lockfree|multi_segs|mbuf_fast_free|security "
18116 (void *)&cmd_config_per_queue_tx_offload_result_port,
18117 (void *)&cmd_config_per_queue_tx_offload_result_port_id,
18118 (void *)&cmd_config_per_queue_tx_offload_result_txq,
18119 (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
18120 (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
18121 (void *)&cmd_config_per_queue_tx_offload_result_offload,
18122 (void *)&cmd_config_per_queue_tx_offload_result_on_off,
18127 /* *** configure tx_metadata for specific port *** */
18128 struct cmd_config_tx_metadata_specific_result {
18129 cmdline_fixed_string_t port;
18130 cmdline_fixed_string_t keyword;
18132 cmdline_fixed_string_t item;
18137 cmd_config_tx_metadata_specific_parsed(void *parsed_result,
18138 __rte_unused struct cmdline *cl,
18139 __rte_unused void *data)
18141 struct cmd_config_tx_metadata_specific_result *res = parsed_result;
18143 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
18145 ports[res->port_id].tx_metadata = res->value;
18146 /* Add/remove callback to insert valid metadata in every Tx packet. */
18147 if (ports[res->port_id].tx_metadata)
18148 add_tx_md_callback(res->port_id);
18150 remove_tx_md_callback(res->port_id);
18151 rte_flow_dynf_metadata_register();
18154 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
18155 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18157 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
18158 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18159 keyword, "config");
18160 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
18161 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18163 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
18164 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18165 item, "tx_metadata");
18166 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
18167 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18170 cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
18171 .f = cmd_config_tx_metadata_specific_parsed,
18173 .help_str = "port config <port_id> tx_metadata <value>",
18175 (void *)&cmd_config_tx_metadata_specific_port,
18176 (void *)&cmd_config_tx_metadata_specific_keyword,
18177 (void *)&cmd_config_tx_metadata_specific_id,
18178 (void *)&cmd_config_tx_metadata_specific_item,
18179 (void *)&cmd_config_tx_metadata_specific_value,
18184 /* *** set dynf *** */
18185 struct cmd_config_tx_dynf_specific_result {
18186 cmdline_fixed_string_t port;
18187 cmdline_fixed_string_t keyword;
18189 cmdline_fixed_string_t item;
18190 cmdline_fixed_string_t name;
18191 cmdline_fixed_string_t value;
18195 cmd_config_dynf_specific_parsed(void *parsed_result,
18196 __rte_unused struct cmdline *cl,
18197 __rte_unused void *data)
18199 struct cmd_config_tx_dynf_specific_result *res = parsed_result;
18200 struct rte_mbuf_dynflag desc_flag;
18202 uint64_t old_port_flags;
18204 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
18206 flag = rte_mbuf_dynflag_lookup(res->name, NULL);
18208 if (strlcpy(desc_flag.name, res->name,
18209 RTE_MBUF_DYN_NAMESIZE) >= RTE_MBUF_DYN_NAMESIZE) {
18210 printf("Flag name too long\n");
18213 desc_flag.flags = 0;
18214 flag = rte_mbuf_dynflag_register(&desc_flag);
18216 printf("Can't register flag\n");
18219 strcpy(dynf_names[flag], desc_flag.name);
18221 old_port_flags = ports[res->port_id].mbuf_dynf;
18222 if (!strcmp(res->value, "set")) {
18223 ports[res->port_id].mbuf_dynf |= 1UL << flag;
18224 if (old_port_flags == 0)
18225 add_tx_dynf_callback(res->port_id);
18227 ports[res->port_id].mbuf_dynf &= ~(1UL << flag);
18228 if (ports[res->port_id].mbuf_dynf == 0)
18229 remove_tx_dynf_callback(res->port_id);
18233 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_port =
18234 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
18236 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_keyword =
18237 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
18238 keyword, "config");
18239 cmdline_parse_token_num_t cmd_config_tx_dynf_specific_port_id =
18240 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
18242 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_item =
18243 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
18245 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_name =
18246 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
18248 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_value =
18249 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
18250 value, "set#clear");
18252 cmdline_parse_inst_t cmd_config_tx_dynf_specific = {
18253 .f = cmd_config_dynf_specific_parsed,
18255 .help_str = "port config <port id> dynf <name> set|clear",
18257 (void *)&cmd_config_tx_dynf_specific_port,
18258 (void *)&cmd_config_tx_dynf_specific_keyword,
18259 (void *)&cmd_config_tx_dynf_specific_port_id,
18260 (void *)&cmd_config_tx_dynf_specific_item,
18261 (void *)&cmd_config_tx_dynf_specific_name,
18262 (void *)&cmd_config_tx_dynf_specific_value,
18267 /* *** display tx_metadata per port configuration *** */
18268 struct cmd_show_tx_metadata_result {
18269 cmdline_fixed_string_t cmd_show;
18270 cmdline_fixed_string_t cmd_port;
18271 cmdline_fixed_string_t cmd_keyword;
18276 cmd_show_tx_metadata_parsed(void *parsed_result,
18277 __rte_unused struct cmdline *cl,
18278 __rte_unused void *data)
18280 struct cmd_show_tx_metadata_result *res = parsed_result;
18282 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
18283 printf("invalid port id %u\n", res->cmd_pid);
18286 if (!strcmp(res->cmd_keyword, "tx_metadata")) {
18287 printf("Port %u tx_metadata: %u\n", res->cmd_pid,
18288 ports[res->cmd_pid].tx_metadata);
18292 cmdline_parse_token_string_t cmd_show_tx_metadata_show =
18293 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
18295 cmdline_parse_token_string_t cmd_show_tx_metadata_port =
18296 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
18298 cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
18299 TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
18301 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
18302 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
18303 cmd_keyword, "tx_metadata");
18305 cmdline_parse_inst_t cmd_show_tx_metadata = {
18306 .f = cmd_show_tx_metadata_parsed,
18308 .help_str = "show port <port_id> tx_metadata",
18310 (void *)&cmd_show_tx_metadata_show,
18311 (void *)&cmd_show_tx_metadata_port,
18312 (void *)&cmd_show_tx_metadata_pid,
18313 (void *)&cmd_show_tx_metadata_keyword,
18318 /* *** show fec capability per port configuration *** */
18319 struct cmd_show_fec_capability_result {
18320 cmdline_fixed_string_t cmd_show;
18321 cmdline_fixed_string_t cmd_port;
18322 cmdline_fixed_string_t cmd_fec;
18323 cmdline_fixed_string_t cmd_keyword;
18328 cmd_show_fec_capability_parsed(void *parsed_result,
18329 __rte_unused struct cmdline *cl,
18330 __rte_unused void *data)
18332 #define FEC_CAP_NUM 2
18333 struct cmd_show_fec_capability_result *res = parsed_result;
18334 struct rte_eth_fec_capa speed_fec_capa[FEC_CAP_NUM];
18335 unsigned int num = FEC_CAP_NUM;
18336 unsigned int ret_num;
18339 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
18340 printf("Invalid port id %u\n", res->cmd_pid);
18344 ret = rte_eth_fec_get_capability(res->cmd_pid, speed_fec_capa, num);
18345 if (ret == -ENOTSUP) {
18346 printf("Function not implemented\n");
18348 } else if (ret < 0) {
18349 printf("Get FEC capability failed\n");
18353 ret_num = (unsigned int)ret;
18354 show_fec_capability(ret_num, speed_fec_capa);
18357 cmdline_parse_token_string_t cmd_show_fec_capability_show =
18358 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
18360 cmdline_parse_token_string_t cmd_show_fec_capability_port =
18361 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
18363 cmdline_parse_token_num_t cmd_show_fec_capability_pid =
18364 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_capability_result,
18366 cmdline_parse_token_string_t cmd_show_fec_capability_fec =
18367 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
18369 cmdline_parse_token_string_t cmd_show_fec_capability_keyword =
18370 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
18371 cmd_keyword, "capabilities");
18373 cmdline_parse_inst_t cmd_show_capability = {
18374 .f = cmd_show_fec_capability_parsed,
18376 .help_str = "show port <port_id> fec capabilities",
18378 (void *)&cmd_show_fec_capability_show,
18379 (void *)&cmd_show_fec_capability_port,
18380 (void *)&cmd_show_fec_capability_pid,
18381 (void *)&cmd_show_fec_capability_fec,
18382 (void *)&cmd_show_fec_capability_keyword,
18387 /* *** show fec mode per port configuration *** */
18388 struct cmd_show_fec_metadata_result {
18389 cmdline_fixed_string_t cmd_show;
18390 cmdline_fixed_string_t cmd_port;
18391 cmdline_fixed_string_t cmd_keyword;
18396 cmd_show_fec_mode_parsed(void *parsed_result,
18397 __rte_unused struct cmdline *cl,
18398 __rte_unused void *data)
18400 #define FEC_NAME_SIZE 16
18401 struct cmd_show_fec_metadata_result *res = parsed_result;
18403 char buf[FEC_NAME_SIZE];
18406 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
18407 printf("Invalid port id %u\n", res->cmd_pid);
18410 ret = rte_eth_fec_get(res->cmd_pid, &mode);
18411 if (ret == -ENOTSUP) {
18412 printf("Function not implemented\n");
18414 } else if (ret < 0) {
18415 printf("Get FEC mode failed\n");
18420 case RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC):
18421 strlcpy(buf, "off", sizeof(buf));
18423 case RTE_ETH_FEC_MODE_CAPA_MASK(AUTO):
18424 strlcpy(buf, "auto", sizeof(buf));
18426 case RTE_ETH_FEC_MODE_CAPA_MASK(BASER):
18427 strlcpy(buf, "baser", sizeof(buf));
18429 case RTE_ETH_FEC_MODE_CAPA_MASK(RS):
18430 strlcpy(buf, "rs", sizeof(buf));
18436 printf("%s\n", buf);
18439 cmdline_parse_token_string_t cmd_show_fec_mode_show =
18440 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
18442 cmdline_parse_token_string_t cmd_show_fec_mode_port =
18443 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
18445 cmdline_parse_token_num_t cmd_show_fec_mode_pid =
18446 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_metadata_result,
18448 cmdline_parse_token_string_t cmd_show_fec_mode_keyword =
18449 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
18450 cmd_keyword, "fec_mode");
18452 cmdline_parse_inst_t cmd_show_fec_mode = {
18453 .f = cmd_show_fec_mode_parsed,
18455 .help_str = "show port <port_id> fec_mode",
18457 (void *)&cmd_show_fec_mode_show,
18458 (void *)&cmd_show_fec_mode_port,
18459 (void *)&cmd_show_fec_mode_pid,
18460 (void *)&cmd_show_fec_mode_keyword,
18465 /* *** set fec mode per port configuration *** */
18466 struct cmd_set_port_fec_mode {
18467 cmdline_fixed_string_t set;
18468 cmdline_fixed_string_t port;
18470 cmdline_fixed_string_t fec_mode;
18471 cmdline_fixed_string_t fec_value;
18474 /* Common CLI fields for set fec mode */
18475 cmdline_parse_token_string_t cmd_set_port_fec_mode_set =
18476 TOKEN_STRING_INITIALIZER
18477 (struct cmd_set_port_fec_mode,
18479 cmdline_parse_token_string_t cmd_set_port_fec_mode_port =
18480 TOKEN_STRING_INITIALIZER
18481 (struct cmd_set_port_fec_mode,
18483 cmdline_parse_token_num_t cmd_set_port_fec_mode_port_id =
18484 TOKEN_NUM_INITIALIZER
18485 (struct cmd_set_port_fec_mode,
18487 cmdline_parse_token_string_t cmd_set_port_fec_mode_str =
18488 TOKEN_STRING_INITIALIZER
18489 (struct cmd_set_port_fec_mode,
18490 fec_mode, "fec_mode");
18491 cmdline_parse_token_string_t cmd_set_port_fec_mode_value =
18492 TOKEN_STRING_INITIALIZER
18493 (struct cmd_set_port_fec_mode,
18497 cmd_set_port_fec_mode_parsed(
18498 void *parsed_result,
18499 __rte_unused struct cmdline *cl,
18500 __rte_unused void *data)
18502 struct cmd_set_port_fec_mode *res = parsed_result;
18503 uint16_t port_id = res->port_id;
18507 ret = parse_fec_mode(res->fec_value, &mode);
18509 printf("Unknown fec mode: %s for Port %d\n", res->fec_value,
18514 ret = rte_eth_fec_set(port_id, mode);
18515 if (ret == -ENOTSUP) {
18516 printf("Function not implemented\n");
18518 } else if (ret < 0) {
18519 printf("Set FEC mode failed\n");
18524 cmdline_parse_inst_t cmd_set_fec_mode = {
18525 .f = cmd_set_port_fec_mode_parsed,
18527 .help_str = "set port <port_id> fec_mode auto|off|rs|baser",
18529 (void *)&cmd_set_port_fec_mode_set,
18530 (void *)&cmd_set_port_fec_mode_port,
18531 (void *)&cmd_set_port_fec_mode_port_id,
18532 (void *)&cmd_set_port_fec_mode_str,
18533 (void *)&cmd_set_port_fec_mode_value,
18538 /* show port supported ptypes */
18540 /* Common result structure for show port ptypes */
18541 struct cmd_show_port_supported_ptypes_result {
18542 cmdline_fixed_string_t show;
18543 cmdline_fixed_string_t port;
18545 cmdline_fixed_string_t ptypes;
18548 /* Common CLI fields for show port ptypes */
18549 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =
18550 TOKEN_STRING_INITIALIZER
18551 (struct cmd_show_port_supported_ptypes_result,
18553 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
18554 TOKEN_STRING_INITIALIZER
18555 (struct cmd_show_port_supported_ptypes_result,
18557 cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =
18558 TOKEN_NUM_INITIALIZER
18559 (struct cmd_show_port_supported_ptypes_result,
18561 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =
18562 TOKEN_STRING_INITIALIZER
18563 (struct cmd_show_port_supported_ptypes_result,
18567 cmd_show_port_supported_ptypes_parsed(
18568 void *parsed_result,
18569 __rte_unused struct cmdline *cl,
18570 __rte_unused void *data)
18572 #define RSVD_PTYPE_MASK 0xf0000000
18573 #define MAX_PTYPES_PER_LAYER 16
18574 #define LTYPE_NAMESIZE 32
18575 #define PTYPE_NAMESIZE 256
18576 struct cmd_show_port_supported_ptypes_result *res = parsed_result;
18577 char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE];
18578 uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
18579 uint32_t ptypes[MAX_PTYPES_PER_LAYER];
18580 uint16_t port_id = res->port_id;
18583 ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0);
18587 while (ptype_mask != RSVD_PTYPE_MASK) {
18589 switch (ptype_mask) {
18590 case RTE_PTYPE_L2_MASK:
18591 strlcpy(ltype, "L2", sizeof(ltype));
18593 case RTE_PTYPE_L3_MASK:
18594 strlcpy(ltype, "L3", sizeof(ltype));
18596 case RTE_PTYPE_L4_MASK:
18597 strlcpy(ltype, "L4", sizeof(ltype));
18599 case RTE_PTYPE_TUNNEL_MASK:
18600 strlcpy(ltype, "Tunnel", sizeof(ltype));
18602 case RTE_PTYPE_INNER_L2_MASK:
18603 strlcpy(ltype, "Inner L2", sizeof(ltype));
18605 case RTE_PTYPE_INNER_L3_MASK:
18606 strlcpy(ltype, "Inner L3", sizeof(ltype));
18608 case RTE_PTYPE_INNER_L4_MASK:
18609 strlcpy(ltype, "Inner L4", sizeof(ltype));
18615 ret = rte_eth_dev_get_supported_ptypes(res->port_id,
18616 ptype_mask, ptypes,
18617 MAX_PTYPES_PER_LAYER);
18620 printf("Supported %s ptypes:\n", ltype);
18622 printf("%s ptypes unsupported\n", ltype);
18624 for (i = 0; i < ret; ++i) {
18625 rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
18626 printf("%s\n", buf);
18633 cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
18634 .f = cmd_show_port_supported_ptypes_parsed,
18636 .help_str = "show port <port_id> ptypes",
18638 (void *)&cmd_show_port_supported_ptypes_show,
18639 (void *)&cmd_show_port_supported_ptypes_port,
18640 (void *)&cmd_show_port_supported_ptypes_port_id,
18641 (void *)&cmd_show_port_supported_ptypes_ptypes,
18646 /* *** display rx/tx descriptor status *** */
18647 struct cmd_show_rx_tx_desc_status_result {
18648 cmdline_fixed_string_t cmd_show;
18649 cmdline_fixed_string_t cmd_port;
18650 cmdline_fixed_string_t cmd_keyword;
18651 cmdline_fixed_string_t cmd_desc;
18652 cmdline_fixed_string_t cmd_status;
18659 cmd_show_rx_tx_desc_status_parsed(void *parsed_result,
18660 __rte_unused struct cmdline *cl,
18661 __rte_unused void *data)
18663 struct cmd_show_rx_tx_desc_status_result *res = parsed_result;
18666 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
18667 printf("invalid port id %u\n", res->cmd_pid);
18671 if (!strcmp(res->cmd_keyword, "rxq")) {
18672 rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid,
18675 printf("Invalid queueid = %d\n", res->cmd_qid);
18678 if (rc == RTE_ETH_RX_DESC_AVAIL)
18679 printf("Desc status = AVAILABLE\n");
18680 else if (rc == RTE_ETH_RX_DESC_DONE)
18681 printf("Desc status = DONE\n");
18683 printf("Desc status = UNAVAILABLE\n");
18684 } else if (!strcmp(res->cmd_keyword, "txq")) {
18685 rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid,
18688 printf("Invalid queueid = %d\n", res->cmd_qid);
18691 if (rc == RTE_ETH_TX_DESC_FULL)
18692 printf("Desc status = FULL\n");
18693 else if (rc == RTE_ETH_TX_DESC_DONE)
18694 printf("Desc status = DONE\n");
18696 printf("Desc status = UNAVAILABLE\n");
18700 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show =
18701 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
18703 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port =
18704 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
18706 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid =
18707 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
18709 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword =
18710 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
18711 cmd_keyword, "rxq#txq");
18712 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid =
18713 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
18715 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc =
18716 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
18718 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did =
18719 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
18721 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status =
18722 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
18723 cmd_status, "status");
18724 cmdline_parse_inst_t cmd_show_rx_tx_desc_status = {
18725 .f = cmd_show_rx_tx_desc_status_parsed,
18727 .help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> "
18730 (void *)&cmd_show_rx_tx_desc_status_show,
18731 (void *)&cmd_show_rx_tx_desc_status_port,
18732 (void *)&cmd_show_rx_tx_desc_status_pid,
18733 (void *)&cmd_show_rx_tx_desc_status_keyword,
18734 (void *)&cmd_show_rx_tx_desc_status_qid,
18735 (void *)&cmd_show_rx_tx_desc_status_desc,
18736 (void *)&cmd_show_rx_tx_desc_status_did,
18737 (void *)&cmd_show_rx_tx_desc_status_status,
18742 /* Common result structure for set port ptypes */
18743 struct cmd_set_port_ptypes_result {
18744 cmdline_fixed_string_t set;
18745 cmdline_fixed_string_t port;
18747 cmdline_fixed_string_t ptype_mask;
18751 /* Common CLI fields for set port ptypes */
18752 cmdline_parse_token_string_t cmd_set_port_ptypes_set =
18753 TOKEN_STRING_INITIALIZER
18754 (struct cmd_set_port_ptypes_result,
18756 cmdline_parse_token_string_t cmd_set_port_ptypes_port =
18757 TOKEN_STRING_INITIALIZER
18758 (struct cmd_set_port_ptypes_result,
18760 cmdline_parse_token_num_t cmd_set_port_ptypes_port_id =
18761 TOKEN_NUM_INITIALIZER
18762 (struct cmd_set_port_ptypes_result,
18764 cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str =
18765 TOKEN_STRING_INITIALIZER
18766 (struct cmd_set_port_ptypes_result,
18767 ptype_mask, "ptype_mask");
18768 cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 =
18769 TOKEN_NUM_INITIALIZER
18770 (struct cmd_set_port_ptypes_result,
18774 cmd_set_port_ptypes_parsed(
18775 void *parsed_result,
18776 __rte_unused struct cmdline *cl,
18777 __rte_unused void *data)
18779 struct cmd_set_port_ptypes_result *res = parsed_result;
18780 #define PTYPE_NAMESIZE 256
18781 char ptype_name[PTYPE_NAMESIZE];
18782 uint16_t port_id = res->port_id;
18783 uint32_t ptype_mask = res->mask;
18786 ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK,
18789 printf("Port %d doesn't support any ptypes.\n", port_id);
18793 uint32_t ptypes[ret];
18795 ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret);
18797 printf("Unable to set requested ptypes for Port %d\n", port_id);
18801 printf("Successfully set following ptypes for Port %d\n", port_id);
18802 for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) {
18803 rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name));
18804 printf("%s\n", ptype_name);
18807 clear_ptypes = false;
18810 cmdline_parse_inst_t cmd_set_port_ptypes = {
18811 .f = cmd_set_port_ptypes_parsed,
18813 .help_str = "set port <port_id> ptype_mask <mask>",
18815 (void *)&cmd_set_port_ptypes_set,
18816 (void *)&cmd_set_port_ptypes_port,
18817 (void *)&cmd_set_port_ptypes_port_id,
18818 (void *)&cmd_set_port_ptypes_mask_str,
18819 (void *)&cmd_set_port_ptypes_mask_u32,
18824 /* *** display mac addresses added to a port *** */
18825 struct cmd_showport_macs_result {
18826 cmdline_fixed_string_t cmd_show;
18827 cmdline_fixed_string_t cmd_port;
18828 cmdline_fixed_string_t cmd_keyword;
18833 cmd_showport_macs_parsed(void *parsed_result,
18834 __rte_unused struct cmdline *cl,
18835 __rte_unused void *data)
18837 struct cmd_showport_macs_result *res = parsed_result;
18839 if (port_id_is_invalid(res->cmd_pid, ENABLED_WARN))
18842 if (!strcmp(res->cmd_keyword, "macs"))
18843 show_macs(res->cmd_pid);
18844 else if (!strcmp(res->cmd_keyword, "mcast_macs"))
18845 show_mcast_macs(res->cmd_pid);
18848 cmdline_parse_token_string_t cmd_showport_macs_show =
18849 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
18851 cmdline_parse_token_string_t cmd_showport_macs_port =
18852 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
18854 cmdline_parse_token_num_t cmd_showport_macs_pid =
18855 TOKEN_NUM_INITIALIZER(struct cmd_showport_macs_result,
18857 cmdline_parse_token_string_t cmd_showport_macs_keyword =
18858 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
18859 cmd_keyword, "macs#mcast_macs");
18861 cmdline_parse_inst_t cmd_showport_macs = {
18862 .f = cmd_showport_macs_parsed,
18864 .help_str = "show port <port_id> macs|mcast_macs",
18866 (void *)&cmd_showport_macs_show,
18867 (void *)&cmd_showport_macs_port,
18868 (void *)&cmd_showport_macs_pid,
18869 (void *)&cmd_showport_macs_keyword,
18874 /* ******************************************************************************** */
18876 /* list of instructions */
18877 cmdline_parse_ctx_t main_ctx[] = {
18878 (cmdline_parse_inst_t *)&cmd_help_brief,
18879 (cmdline_parse_inst_t *)&cmd_help_long,
18880 (cmdline_parse_inst_t *)&cmd_quit,
18881 (cmdline_parse_inst_t *)&cmd_load_from_file,
18882 (cmdline_parse_inst_t *)&cmd_showport,
18883 (cmdline_parse_inst_t *)&cmd_showqueue,
18884 (cmdline_parse_inst_t *)&cmd_showeeprom,
18885 (cmdline_parse_inst_t *)&cmd_showportall,
18886 (cmdline_parse_inst_t *)&cmd_showdevice,
18887 (cmdline_parse_inst_t *)&cmd_showcfg,
18888 (cmdline_parse_inst_t *)&cmd_showfwdall,
18889 (cmdline_parse_inst_t *)&cmd_start,
18890 (cmdline_parse_inst_t *)&cmd_start_tx_first,
18891 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
18892 (cmdline_parse_inst_t *)&cmd_set_link_up,
18893 (cmdline_parse_inst_t *)&cmd_set_link_down,
18894 (cmdline_parse_inst_t *)&cmd_reset,
18895 (cmdline_parse_inst_t *)&cmd_set_numbers,
18896 (cmdline_parse_inst_t *)&cmd_set_log,
18897 (cmdline_parse_inst_t *)&cmd_set_rxoffs,
18898 (cmdline_parse_inst_t *)&cmd_set_rxpkts,
18899 (cmdline_parse_inst_t *)&cmd_set_txpkts,
18900 (cmdline_parse_inst_t *)&cmd_set_txsplit,
18901 (cmdline_parse_inst_t *)&cmd_set_txtimes,
18902 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
18903 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
18904 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
18905 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
18906 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
18907 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
18908 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
18909 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
18910 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
18911 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
18912 (cmdline_parse_inst_t *)&cmd_set_link_check,
18913 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
18914 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
18915 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
18916 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
18917 #ifdef RTE_NET_BOND
18918 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
18919 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
18920 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
18921 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
18922 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
18923 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
18924 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
18925 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
18926 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
18927 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
18928 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
18930 (cmdline_parse_inst_t *)&cmd_vlan_offload,
18931 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
18932 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
18933 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
18934 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
18935 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
18936 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
18937 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
18938 (cmdline_parse_inst_t *)&cmd_csum_set,
18939 (cmdline_parse_inst_t *)&cmd_csum_show,
18940 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
18941 (cmdline_parse_inst_t *)&cmd_tso_set,
18942 (cmdline_parse_inst_t *)&cmd_tso_show,
18943 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
18944 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
18945 (cmdline_parse_inst_t *)&cmd_gro_enable,
18946 (cmdline_parse_inst_t *)&cmd_gro_flush,
18947 (cmdline_parse_inst_t *)&cmd_gro_show,
18948 (cmdline_parse_inst_t *)&cmd_gso_enable,
18949 (cmdline_parse_inst_t *)&cmd_gso_size,
18950 (cmdline_parse_inst_t *)&cmd_gso_show,
18951 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
18952 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
18953 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
18954 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
18955 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
18956 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
18957 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
18958 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
18959 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
18960 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
18961 (cmdline_parse_inst_t *)&cmd_config_dcb,
18962 (cmdline_parse_inst_t *)&cmd_read_reg,
18963 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
18964 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
18965 (cmdline_parse_inst_t *)&cmd_write_reg,
18966 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
18967 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
18968 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
18969 (cmdline_parse_inst_t *)&cmd_stop,
18970 (cmdline_parse_inst_t *)&cmd_mac_addr,
18971 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
18972 (cmdline_parse_inst_t *)&cmd_set_qmap,
18973 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
18974 (cmdline_parse_inst_t *)&cmd_set_record_core_cycles,
18975 (cmdline_parse_inst_t *)&cmd_set_record_burst_stats,
18976 (cmdline_parse_inst_t *)&cmd_operate_port,
18977 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
18978 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
18979 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
18980 (cmdline_parse_inst_t *)&cmd_operate_detach_device,
18981 (cmdline_parse_inst_t *)&cmd_set_port_setup_on,
18982 (cmdline_parse_inst_t *)&cmd_config_speed_all,
18983 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
18984 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
18985 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
18986 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
18987 (cmdline_parse_inst_t *)&cmd_config_mtu,
18988 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
18989 (cmdline_parse_inst_t *)&cmd_config_max_lro_pkt_size,
18990 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
18991 (cmdline_parse_inst_t *)&cmd_config_rss,
18992 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
18993 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
18994 (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
18995 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
18996 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
18997 (cmdline_parse_inst_t *)&cmd_showport_reta,
18998 (cmdline_parse_inst_t *)&cmd_showport_macs,
18999 (cmdline_parse_inst_t *)&cmd_config_burst,
19000 (cmdline_parse_inst_t *)&cmd_config_thresh,
19001 (cmdline_parse_inst_t *)&cmd_config_threshold,
19002 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
19003 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
19004 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
19005 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
19006 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
19007 (cmdline_parse_inst_t *)&cmd_global_config,
19008 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
19009 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
19010 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
19011 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
19012 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
19013 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
19014 (cmdline_parse_inst_t *)&cmd_dump,
19015 (cmdline_parse_inst_t *)&cmd_dump_one,
19016 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
19017 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
19018 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
19019 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
19020 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
19021 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
19022 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
19023 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
19024 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
19025 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
19026 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
19027 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
19028 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
19029 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
19030 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
19031 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
19032 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
19033 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
19034 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
19035 (cmdline_parse_inst_t *)&cmd_flow,
19036 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
19037 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
19038 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
19039 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
19040 (cmdline_parse_inst_t *)&cmd_create_port_meter,
19041 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
19042 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
19043 (cmdline_parse_inst_t *)&cmd_del_port_meter,
19044 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
19045 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
19046 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
19047 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
19048 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
19049 (cmdline_parse_inst_t *)&cmd_mcast_addr,
19050 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
19051 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
19052 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
19053 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
19054 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
19055 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
19056 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
19057 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
19058 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
19059 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
19060 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
19061 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
19062 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
19063 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
19064 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
19065 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
19066 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
19067 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
19068 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
19069 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
19070 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
19071 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
19072 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
19073 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
19074 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
19075 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
19076 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
19077 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
19078 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
19079 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
19080 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
19081 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
19082 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
19083 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
19084 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
19085 (cmdline_parse_inst_t *)&cmd_set_vxlan,
19086 (cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl,
19087 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
19088 (cmdline_parse_inst_t *)&cmd_set_nvgre,
19089 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
19090 (cmdline_parse_inst_t *)&cmd_set_l2_encap,
19091 (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
19092 (cmdline_parse_inst_t *)&cmd_set_l2_decap,
19093 (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
19094 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
19095 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
19096 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
19097 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
19098 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
19099 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
19100 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
19101 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
19102 (cmdline_parse_inst_t *)&cmd_ddp_add,
19103 (cmdline_parse_inst_t *)&cmd_ddp_del,
19104 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
19105 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
19106 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
19107 (cmdline_parse_inst_t *)&cmd_clear_input_set,
19108 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
19109 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
19110 (cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes,
19111 (cmdline_parse_inst_t *)&cmd_set_port_ptypes,
19112 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
19113 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
19114 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
19115 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
19117 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
19118 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
19119 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
19120 (cmdline_parse_inst_t *)&cmd_queue_region,
19121 (cmdline_parse_inst_t *)&cmd_region_flowtype,
19122 (cmdline_parse_inst_t *)&cmd_user_priority_region,
19123 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
19124 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
19125 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
19126 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
19127 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
19128 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
19129 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
19130 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
19131 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
19132 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
19133 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
19134 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
19135 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
19136 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
19137 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
19138 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node_pmode,
19139 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
19140 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
19141 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
19142 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
19143 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
19144 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
19145 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
19146 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
19147 (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
19148 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
19149 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
19150 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
19151 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
19152 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
19153 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
19154 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
19155 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
19156 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
19158 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
19159 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
19161 (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
19162 (cmdline_parse_inst_t *)&cmd_show_tx_metadata,
19163 (cmdline_parse_inst_t *)&cmd_show_rx_tx_desc_status,
19164 (cmdline_parse_inst_t *)&cmd_set_raw,
19165 (cmdline_parse_inst_t *)&cmd_show_set_raw,
19166 (cmdline_parse_inst_t *)&cmd_show_set_raw_all,
19167 (cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific,
19168 (cmdline_parse_inst_t *)&cmd_show_fec_mode,
19169 (cmdline_parse_inst_t *)&cmd_set_fec_mode,
19170 (cmdline_parse_inst_t *)&cmd_show_capability,
19174 /* read cmdline commands from file */
19176 cmdline_read_from_file(const char *filename)
19178 struct cmdline *cl;
19180 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
19182 printf("Failed to create file based cmdline context: %s\n",
19187 cmdline_interact(cl);
19192 printf("Read CLI commands from %s\n", filename);
19195 /* prompt function, called from main on MAIN lcore */
19199 /* initialize non-constant commands */
19200 cmd_set_fwd_mode_init();
19201 cmd_set_fwd_retry_mode_init();
19203 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
19204 if (testpmd_cl == NULL)
19206 cmdline_interact(testpmd_cl);
19207 cmdline_stdin_exit(testpmd_cl);
19213 if (testpmd_cl != NULL)
19214 cmdline_quit(testpmd_cl);
19218 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
19220 if (id == (portid_t)RTE_PORT_ALL) {
19223 RTE_ETH_FOREACH_DEV(pid) {
19224 /* check if need_reconfig has been set to 1 */
19225 if (ports[pid].need_reconfig == 0)
19226 ports[pid].need_reconfig = dev;
19227 /* check if need_reconfig_queues has been set to 1 */
19228 if (ports[pid].need_reconfig_queues == 0)
19229 ports[pid].need_reconfig_queues = queue;
19231 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
19232 /* check if need_reconfig has been set to 1 */
19233 if (ports[id].need_reconfig == 0)
19234 ports[id].need_reconfig = dev;
19235 /* check if need_reconfig_queues has been set to 1 */
19236 if (ports[id].need_reconfig_queues == 0)
19237 ports[id].need_reconfig_queues = queue;