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 "ddp add (port_id) (profile_path[,backup_profile_path])\n"
668 " Load a profile package on a port\n\n"
670 "ddp del (port_id) (backup_profile_path)\n"
671 " Delete a profile package from a port\n\n"
673 "ptype mapping get (port_id) (valid_only)\n"
674 " Get ptype mapping on a port\n\n"
676 "ptype mapping replace (port_id) (target) (mask) (pky_type)\n"
677 " Replace target with the pkt_type in ptype mapping\n\n"
679 "ptype mapping reset (port_id)\n"
680 " Reset ptype mapping on a port\n\n"
682 "ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n"
683 " Update a ptype mapping item on a port\n\n"
685 "set port (port_id) ptype_mask (ptype_mask)\n"
686 " set packet types classification for a specific port\n\n"
688 "set port (port_id) queue-region region_id (value) "
689 "queue_start_index (value) queue_num (value)\n"
690 " Set a queue region on a port\n\n"
692 "set port (port_id) queue-region region_id (value) "
694 " Set a flowtype region index on a port\n\n"
696 "set port (port_id) queue-region UP (value) region_id (value)\n"
697 " Set the mapping of User Priority to "
698 "queue region on a port\n\n"
700 "set port (port_id) queue-region flush (on|off)\n"
701 " flush all queue region related configuration\n\n"
703 "show port meter cap (port_id)\n"
704 " Show port meter capability information\n\n"
706 "add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs)\n"
707 " meter profile add - srtcm rfc 2697\n\n"
709 "add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs)\n"
710 " meter profile add - trtcm rfc 2698\n\n"
712 "add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs)\n"
713 " meter profile add - trtcm rfc 4115\n\n"
715 "del port meter profile (port_id) (profile_id)\n"
716 " meter profile delete\n\n"
718 "create port meter (port_id) (mtr_id) (profile_id) (meter_enable)\n"
719 "(g_action) (y_action) (r_action) (stats_mask) (shared)\n"
720 "(use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n"
721 "(dscp_tbl_entry63)]\n"
724 "enable port meter (port_id) (mtr_id)\n"
727 "disable port meter (port_id) (mtr_id)\n"
730 "del port meter (port_id) (mtr_id)\n"
733 "set port meter profile (port_id) (mtr_id) (profile_id)\n"
734 " meter update meter profile\n\n"
736 "set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n"
737 "(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n"
738 " update meter dscp table entries\n\n"
740 "set port meter policer action (port_id) (mtr_id) (action_mask)\n"
741 "(action0) [(action1) (action2)]\n"
742 " meter update policer action\n\n"
744 "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
745 " meter update stats\n\n"
747 "show port (port_id) queue-region\n"
748 " show all queue region related configuration info\n\n"
750 "set port (port_id) fec_mode auto|off|rs|baser\n"
751 " set fec mode for a specific port\n\n"
753 , list_pkt_forwarding_modes()
757 if (show_all || !strcmp(res->section, "ports")) {
763 "----------------\n\n"
765 "port start (port_id|all)\n"
766 " Start all ports or port_id.\n\n"
768 "port stop (port_id|all)\n"
769 " Stop all ports or port_id.\n\n"
771 "port close (port_id|all)\n"
772 " Close all ports or port_id.\n\n"
774 "port reset (port_id|all)\n"
775 " Reset all ports or port_id.\n\n"
777 "port attach (ident)\n"
778 " Attach physical or virtual dev by pci address or virtual device name\n\n"
780 "port detach (port_id)\n"
781 " Detach physical or virtual dev by port_id\n\n"
783 "port config (port_id|all)"
784 " speed (10|100|1000|10000|25000|40000|50000|100000|200000|auto)"
785 " duplex (half|full|auto)\n"
786 " Set speed and duplex for all ports or port_id\n\n"
788 "port config (port_id|all) loopback (mode)\n"
789 " Set loopback mode for all ports or port_id\n\n"
791 "port config all (rxq|txq|rxd|txd) (value)\n"
792 " Set number for rxq/txq/rxd/txd.\n\n"
794 "port config all max-pkt-len (value)\n"
795 " Set the max packet length.\n\n"
797 "port config all max-lro-pkt-size (value)\n"
798 " Set the max LRO aggregated packet size.\n\n"
800 "port config all drop-en (on|off)\n"
801 " Enable or disable packet drop on all RX queues of all ports when no "
802 "receive buffers available.\n\n"
804 "port config all rss (all|default|ip|tcp|udp|sctp|"
805 "ether|port|vxlan|geneve|nvgre|vxlan-gpe|none|level-default|"
806 "level-outer|level-inner|<flowtype_id>)\n"
807 " Set the RSS mode.\n\n"
809 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
810 " Set the RSS redirection table.\n\n"
812 "port config (port_id) dcb vt (on|off) (traffic_class)"
814 " Set the DCB mode.\n\n"
816 "port config all burst (value)\n"
817 " Set the number of packets per burst.\n\n"
819 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
821 " Set the ring prefetch/host/writeback threshold"
822 " for tx/rx queue.\n\n"
824 "port config all (txfreet|txrst|rxfreet) (value)\n"
825 " Set free threshold for rx/tx, or set"
826 " tx rs bit threshold.\n\n"
827 "port config mtu X value\n"
828 " Set the MTU of port X to a given value\n\n"
830 "port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n"
831 " Set a rx/tx queue's ring size configuration, the new"
832 " value will take effect after command that (re-)start the port"
833 " or command that setup the specific queue\n\n"
835 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
836 " Start/stop a rx/tx queue of port X. Only take effect"
837 " when port X is started\n\n"
839 "port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n"
840 " Switch on/off a deferred start of port X rx/tx queue. Only"
841 " take effect when port X is stopped.\n\n"
843 "port (port_id) (rxq|txq) (queue_id) setup\n"
844 " Setup a rx/tx queue of port X.\n\n"
846 "port config (port_id|all) l2-tunnel E-tag ether-type"
848 " Set the value of E-tag ether-type.\n\n"
850 "port config (port_id|all) l2-tunnel E-tag"
851 " (enable|disable)\n"
852 " Enable/disable the E-tag support.\n\n"
854 "port config (port_id) pctype mapping reset\n"
855 " Reset flow type to pctype mapping on a port\n\n"
857 "port config (port_id) pctype mapping update"
858 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
859 " Update a flow type to pctype mapping item on a port\n\n"
861 "port config (port_id) pctype (pctype_id) hash_inset|"
862 "fdir_inset|fdir_flx_inset get|set|clear field\n"
864 " Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n"
866 "port config (port_id) pctype (pctype_id) hash_inset|"
867 "fdir_inset|fdir_flx_inset clear all"
868 " Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n"
870 "port config (port_id) udp_tunnel_port add|rm vxlan|geneve (udp_port)\n\n"
871 " Add/remove UDP tunnel port for tunneling offload\n\n"
873 "port config <port_id> rx_offload vlan_strip|"
874 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
875 "outer_ipv4_cksum|macsec_strip|header_split|"
876 "vlan_filter|vlan_extend|jumbo_frame|scatter|"
877 "buffer_split|timestamp|security|keep_crc on|off\n"
878 " Enable or disable a per port Rx offloading"
879 " on all Rx queues of a port\n\n"
881 "port (port_id) rxq (queue_id) rx_offload vlan_strip|"
882 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
883 "outer_ipv4_cksum|macsec_strip|header_split|"
884 "vlan_filter|vlan_extend|jumbo_frame|scatter|"
885 "buffer_split|timestamp|security|keep_crc on|off\n"
886 " Enable or disable a per queue Rx offloading"
887 " only on a specific Rx queue\n\n"
889 "port config (port_id) tx_offload vlan_insert|"
890 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
891 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
892 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|"
893 "macsec_insert|mt_lockfree|multi_segs|mbuf_fast_free|"
895 " Enable or disable a per port Tx offloading"
896 " on all Tx queues of a port\n\n"
898 "port (port_id) txq (queue_id) tx_offload vlan_insert|"
899 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
900 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
901 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|macsec_insert"
902 "|mt_lockfree|multi_segs|mbuf_fast_free|security"
904 " Enable or disable a per queue Tx offloading"
905 " only on a specific Tx queue\n\n"
907 "bpf-load rx|tx (port) (queue) (J|M|B) (file_name)\n"
908 " Load an eBPF program as a callback"
909 " for particular RX/TX queue\n\n"
911 "bpf-unload rx|tx (port) (queue)\n"
912 " Unload previously loaded eBPF program"
913 " for particular RX/TX queue\n\n"
915 "port config (port_id) tx_metadata (value)\n"
916 " Set Tx metadata value per port. Testpmd will add this value"
917 " to any Tx packet sent from this port\n\n"
919 "port config (port_id) dynf (name) set|clear\n"
920 " Register a dynf and Set/clear this flag on Tx. "
921 "Testpmd will set this value to any Tx packet "
922 "sent from this port\n\n"
926 if (show_all || !strcmp(res->section, "registers")) {
934 "read reg (port_id) (address)\n"
935 " Display value of a port register.\n\n"
937 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
938 " Display a port register bit field.\n\n"
940 "read regbit (port_id) (address) (bit_x)\n"
941 " Display a single port register bit.\n\n"
943 "write reg (port_id) (address) (value)\n"
944 " Set value of a port register.\n\n"
946 "write regfield (port_id) (address) (bit_x) (bit_y)"
948 " Set bit field of a port register.\n\n"
950 "write regbit (port_id) (address) (bit_x) (value)\n"
951 " Set single bit value of a port register.\n\n"
954 if (show_all || !strcmp(res->section, "filters")) {
962 "flow_director_filter (port_id) mode IP (add|del|update)"
963 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
964 " src (src_ip_address) dst (dst_ip_address)"
965 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
966 " vlan (vlan_value) flexbytes (flexbytes_value)"
967 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
968 " fd_id (fd_id_value)\n"
969 " Add/Del an IP type flow director filter.\n\n"
971 "flow_director_filter (port_id) mode IP (add|del|update)"
972 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
973 " src (src_ip_address) (src_port)"
974 " dst (dst_ip_address) (dst_port)"
975 " tos (tos_value) ttl (ttl_value)"
976 " vlan (vlan_value) flexbytes (flexbytes_value)"
977 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
978 " fd_id (fd_id_value)\n"
979 " Add/Del an UDP/TCP type flow director filter.\n\n"
981 "flow_director_filter (port_id) mode IP (add|del|update)"
982 " flow (ipv4-sctp|ipv6-sctp)"
983 " src (src_ip_address) (src_port)"
984 " dst (dst_ip_address) (dst_port)"
985 " tag (verification_tag) "
986 " tos (tos_value) ttl (ttl_value)"
988 " flexbytes (flexbytes_value) (drop|fwd)"
989 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
990 " Add/Del a SCTP type flow director filter.\n\n"
992 "flow_director_filter (port_id) mode IP (add|del|update)"
993 " flow l2_payload ether (ethertype)"
994 " flexbytes (flexbytes_value) (drop|fwd)"
995 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
996 " Add/Del a l2 payload type flow director filter.\n\n"
998 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
999 " mac (mac_address) vlan (vlan_value)"
1000 " flexbytes (flexbytes_value) (drop|fwd)"
1001 " queue (queue_id) fd_id (fd_id_value)\n"
1002 " Add/Del a MAC-VLAN flow director filter.\n\n"
1004 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
1005 " mac (mac_address) vlan (vlan_value)"
1006 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
1007 " flexbytes (flexbytes_value) (drop|fwd)"
1008 " queue (queue_id) fd_id (fd_id_value)\n"
1009 " Add/Del a Tunnel flow director filter.\n\n"
1011 "flow_director_filter (port_id) mode raw (add|del|update)"
1012 " flow (flow_id) (drop|fwd) queue (queue_id)"
1013 " fd_id (fd_id_value) packet (packet file name)\n"
1014 " Add/Del a raw type flow director filter.\n\n"
1016 "flush_flow_director (port_id)\n"
1017 " Flush all flow director entries of a device.\n\n"
1019 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
1020 " src_mask (ipv4_src) (ipv6_src) (src_port)"
1021 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
1022 " Set flow director IP mask.\n\n"
1024 "flow_director_mask (port_id) mode MAC-VLAN"
1025 " vlan (vlan_value)\n"
1026 " Set flow director MAC-VLAN mask.\n\n"
1028 "flow_director_mask (port_id) mode Tunnel"
1029 " vlan (vlan_value) mac (mac_value)"
1030 " tunnel-type (tunnel_type_value)"
1031 " tunnel-id (tunnel_id_value)\n"
1032 " Set flow director Tunnel mask.\n\n"
1034 "flow_director_flex_mask (port_id)"
1035 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
1036 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
1038 " Configure mask of flex payload.\n\n"
1040 "flow_director_flex_payload (port_id)"
1041 " (raw|l2|l3|l4) (config)\n"
1042 " Configure flex payload selection.\n\n"
1044 "set_fdir_input_set (port_id) "
1045 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1046 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1047 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
1048 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
1049 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
1050 "udp-dst-port|tcp-src-port|tcp-dst-port|"
1051 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
1053 " Set the input set for FDir.\n\n"
1055 "flow validate {port_id}"
1056 " [group {group_id}] [priority {level}]"
1057 " [ingress] [egress]"
1058 " pattern {item} [/ {item} [...]] / end"
1059 " actions {action} [/ {action} [...]] / end\n"
1060 " Check whether a flow rule can be created.\n\n"
1062 "flow create {port_id}"
1063 " [group {group_id}] [priority {level}]"
1064 " [ingress] [egress]"
1065 " pattern {item} [/ {item} [...]] / end"
1066 " actions {action} [/ {action} [...]] / end\n"
1067 " Create a flow rule.\n\n"
1069 "flow destroy {port_id} rule {rule_id} [...]\n"
1070 " Destroy specific flow rules.\n\n"
1072 "flow flush {port_id}\n"
1073 " Destroy all flow rules.\n\n"
1075 "flow query {port_id} {rule_id} {action}\n"
1076 " Query an existing flow rule.\n\n"
1078 "flow list {port_id} [group {group_id}] [...]\n"
1079 " List existing flow rules sorted by priority,"
1080 " filtered by group identifiers.\n\n"
1082 "flow isolate {port_id} {boolean}\n"
1083 " Restrict ingress traffic to the defined"
1086 "flow aged {port_id} [destroy]\n"
1087 " List and destroy aged flows"
1090 "flow shared_action {port_id} create"
1091 " [action_id {shared_action_id}]"
1092 " [ingress] [egress]"
1093 " action {action} / end\n"
1094 " Create shared action.\n\n"
1096 "flow shared_action {port_id} update"
1097 " {shared_action_id} action {action} / end\n"
1098 " Update shared action.\n\n"
1100 "flow shared_action {port_id} destroy"
1101 " action_id {shared_action_id} [...]\n"
1102 " Destroy specific shared actions.\n\n"
1104 "flow shared_action {port_id} query"
1105 " {shared_action_id}\n"
1106 " Query an existing shared action.\n\n"
1108 "set vxlan ip-version (ipv4|ipv6) vni (vni) udp-src"
1109 " (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst"
1110 " (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n"
1111 " Configure the VXLAN encapsulation for flows.\n\n"
1113 "set vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)"
1114 " udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)"
1115 " ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)"
1116 " eth-dst (eth-dst)\n"
1117 " Configure the VXLAN encapsulation for flows.\n\n"
1119 "set vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src"
1120 " (udp-src) udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl)"
1121 " ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src)"
1122 " eth-dst (eth-dst)\n"
1123 " Configure the VXLAN encapsulation for flows.\n\n"
1125 "set nvgre ip-version (ipv4|ipv6) tni (tni) ip-src"
1126 " (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst"
1128 " Configure the NVGRE encapsulation for flows.\n\n"
1130 "set nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)"
1131 " ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)"
1132 " eth-src (eth-src) eth-dst (eth-dst)\n"
1133 " Configure the NVGRE encapsulation for flows.\n\n"
1135 "set raw_encap {flow items}\n"
1136 " Configure the encapsulation with raw data.\n\n"
1138 "set raw_decap {flow items}\n"
1139 " Configure the decapsulation with raw data.\n\n"
1144 if (show_all || !strcmp(res->section, "traffic_management")) {
1148 "Traffic Management:\n"
1150 "show port tm cap (port_id)\n"
1151 " Display the port TM capability.\n\n"
1153 "show port tm level cap (port_id) (level_id)\n"
1154 " Display the port TM hierarchical level capability.\n\n"
1156 "show port tm node cap (port_id) (node_id)\n"
1157 " Display the port TM node capability.\n\n"
1159 "show port tm node type (port_id) (node_id)\n"
1160 " Display the port TM node type.\n\n"
1162 "show port tm node stats (port_id) (node_id) (clear)\n"
1163 " Display the port TM node stats.\n\n"
1165 "add port tm node shaper profile (port_id) (shaper_profile_id)"
1166 " (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)"
1167 " (packet_length_adjust) (packet_mode)\n"
1168 " Add port tm node private shaper profile.\n\n"
1170 "del port tm node shaper profile (port_id) (shaper_profile_id)\n"
1171 " Delete port tm node private shaper profile.\n\n"
1173 "add port tm node shared shaper (port_id) (shared_shaper_id)"
1174 " (shaper_profile_id)\n"
1175 " Add/update port tm node shared shaper.\n\n"
1177 "del port tm node shared shaper (port_id) (shared_shaper_id)\n"
1178 " Delete port tm node shared shaper.\n\n"
1180 "set port tm node shaper profile (port_id) (node_id)"
1181 " (shaper_profile_id)\n"
1182 " Set port tm node shaper profile.\n\n"
1184 "add port tm node wred profile (port_id) (wred_profile_id)"
1185 " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
1186 " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
1187 " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
1188 " Add port tm node wred profile.\n\n"
1190 "del port tm node wred profile (port_id) (wred_profile_id)\n"
1191 " Delete port tm node wred profile.\n\n"
1193 "add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
1194 " (priority) (weight) (level_id) (shaper_profile_id)"
1195 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1196 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1197 " Add port tm nonleaf node.\n\n"
1199 "add port tm nonleaf node pktmode (port_id) (node_id) (parent_node_id)"
1200 " (priority) (weight) (level_id) (shaper_profile_id)"
1201 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1202 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1203 " Add port tm nonleaf node with pkt mode enabled.\n\n"
1205 "add port tm leaf node (port_id) (node_id) (parent_node_id)"
1206 " (priority) (weight) (level_id) (shaper_profile_id)"
1207 " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
1208 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1209 " Add port tm leaf node.\n\n"
1211 "del port tm node (port_id) (node_id)\n"
1212 " Delete port tm node.\n\n"
1214 "set port tm node parent (port_id) (node_id) (parent_node_id)"
1215 " (priority) (weight)\n"
1216 " Set port tm node parent.\n\n"
1218 "suspend port tm node (port_id) (node_id)"
1219 " Suspend tm node.\n\n"
1221 "resume port tm node (port_id) (node_id)"
1222 " Resume tm node.\n\n"
1224 "port tm hierarchy commit (port_id) (clean_on_fail)\n"
1225 " Commit tm hierarchy.\n\n"
1227 "set port tm mark ip_ecn (port) (green) (yellow)"
1229 " Enables/Disables the traffic management marking"
1230 " for IP ECN (Explicit Congestion Notification)"
1231 " packets on a given port\n\n"
1233 "set port tm mark ip_dscp (port) (green) (yellow)"
1235 " Enables/Disables the traffic management marking"
1236 " on the port for IP dscp packets\n\n"
1238 "set port tm mark vlan_dei (port) (green) (yellow)"
1240 " Enables/Disables the traffic management marking"
1241 " on the port for VLAN packets with DEI enabled\n\n"
1245 if (show_all || !strcmp(res->section, "devices")) {
1249 "Device Operations:\n"
1251 "device detach (identifier)\n"
1252 " Detach device by identifier.\n\n"
1258 cmdline_parse_token_string_t cmd_help_long_help =
1259 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1261 cmdline_parse_token_string_t cmd_help_long_section =
1262 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1263 "all#control#display#config#"
1264 "ports#registers#filters#traffic_management#devices");
1266 cmdline_parse_inst_t cmd_help_long = {
1267 .f = cmd_help_long_parsed,
1269 .help_str = "help all|control|display|config|ports|register|"
1270 "filters|traffic_management|devices: "
1273 (void *)&cmd_help_long_help,
1274 (void *)&cmd_help_long_section,
1280 /* *** start/stop/close all ports *** */
1281 struct cmd_operate_port_result {
1282 cmdline_fixed_string_t keyword;
1283 cmdline_fixed_string_t name;
1284 cmdline_fixed_string_t value;
1287 static void cmd_operate_port_parsed(void *parsed_result,
1288 __rte_unused struct cmdline *cl,
1289 __rte_unused void *data)
1291 struct cmd_operate_port_result *res = parsed_result;
1293 if (!strcmp(res->name, "start"))
1294 start_port(RTE_PORT_ALL);
1295 else if (!strcmp(res->name, "stop"))
1296 stop_port(RTE_PORT_ALL);
1297 else if (!strcmp(res->name, "close"))
1298 close_port(RTE_PORT_ALL);
1299 else if (!strcmp(res->name, "reset"))
1300 reset_port(RTE_PORT_ALL);
1302 printf("Unknown parameter\n");
1305 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1306 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1308 cmdline_parse_token_string_t cmd_operate_port_all_port =
1309 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1310 "start#stop#close#reset");
1311 cmdline_parse_token_string_t cmd_operate_port_all_all =
1312 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1314 cmdline_parse_inst_t cmd_operate_port = {
1315 .f = cmd_operate_port_parsed,
1317 .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports",
1319 (void *)&cmd_operate_port_all_cmd,
1320 (void *)&cmd_operate_port_all_port,
1321 (void *)&cmd_operate_port_all_all,
1326 /* *** start/stop/close specific port *** */
1327 struct cmd_operate_specific_port_result {
1328 cmdline_fixed_string_t keyword;
1329 cmdline_fixed_string_t name;
1333 static void cmd_operate_specific_port_parsed(void *parsed_result,
1334 __rte_unused struct cmdline *cl,
1335 __rte_unused void *data)
1337 struct cmd_operate_specific_port_result *res = parsed_result;
1339 if (!strcmp(res->name, "start"))
1340 start_port(res->value);
1341 else if (!strcmp(res->name, "stop"))
1342 stop_port(res->value);
1343 else if (!strcmp(res->name, "close"))
1344 close_port(res->value);
1345 else if (!strcmp(res->name, "reset"))
1346 reset_port(res->value);
1348 printf("Unknown parameter\n");
1351 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1352 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1354 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1355 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1356 name, "start#stop#close#reset");
1357 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1358 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1361 cmdline_parse_inst_t cmd_operate_specific_port = {
1362 .f = cmd_operate_specific_port_parsed,
1364 .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id",
1366 (void *)&cmd_operate_specific_port_cmd,
1367 (void *)&cmd_operate_specific_port_port,
1368 (void *)&cmd_operate_specific_port_id,
1373 /* *** enable port setup (after attach) via iterator or event *** */
1374 struct cmd_set_port_setup_on_result {
1375 cmdline_fixed_string_t set;
1376 cmdline_fixed_string_t port;
1377 cmdline_fixed_string_t setup;
1378 cmdline_fixed_string_t on;
1379 cmdline_fixed_string_t mode;
1382 static void cmd_set_port_setup_on_parsed(void *parsed_result,
1383 __rte_unused struct cmdline *cl,
1384 __rte_unused void *data)
1386 struct cmd_set_port_setup_on_result *res = parsed_result;
1388 if (strcmp(res->mode, "event") == 0)
1389 setup_on_probe_event = true;
1390 else if (strcmp(res->mode, "iterator") == 0)
1391 setup_on_probe_event = false;
1393 printf("Unknown mode\n");
1396 cmdline_parse_token_string_t cmd_set_port_setup_on_set =
1397 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1399 cmdline_parse_token_string_t cmd_set_port_setup_on_port =
1400 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1402 cmdline_parse_token_string_t cmd_set_port_setup_on_setup =
1403 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1405 cmdline_parse_token_string_t cmd_set_port_setup_on_on =
1406 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1408 cmdline_parse_token_string_t cmd_set_port_setup_on_mode =
1409 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1410 mode, "iterator#event");
1412 cmdline_parse_inst_t cmd_set_port_setup_on = {
1413 .f = cmd_set_port_setup_on_parsed,
1415 .help_str = "set port setup on iterator|event",
1417 (void *)&cmd_set_port_setup_on_set,
1418 (void *)&cmd_set_port_setup_on_port,
1419 (void *)&cmd_set_port_setup_on_setup,
1420 (void *)&cmd_set_port_setup_on_on,
1421 (void *)&cmd_set_port_setup_on_mode,
1426 /* *** attach a specified port *** */
1427 struct cmd_operate_attach_port_result {
1428 cmdline_fixed_string_t port;
1429 cmdline_fixed_string_t keyword;
1430 cmdline_multi_string_t identifier;
1433 static void cmd_operate_attach_port_parsed(void *parsed_result,
1434 __rte_unused struct cmdline *cl,
1435 __rte_unused void *data)
1437 struct cmd_operate_attach_port_result *res = parsed_result;
1439 if (!strcmp(res->keyword, "attach"))
1440 attach_port(res->identifier);
1442 printf("Unknown parameter\n");
1445 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1446 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1448 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1449 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1451 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1452 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1453 identifier, TOKEN_STRING_MULTI);
1455 cmdline_parse_inst_t cmd_operate_attach_port = {
1456 .f = cmd_operate_attach_port_parsed,
1458 .help_str = "port attach <identifier>: "
1459 "(identifier: pci address or virtual dev name)",
1461 (void *)&cmd_operate_attach_port_port,
1462 (void *)&cmd_operate_attach_port_keyword,
1463 (void *)&cmd_operate_attach_port_identifier,
1468 /* *** detach a specified port *** */
1469 struct cmd_operate_detach_port_result {
1470 cmdline_fixed_string_t port;
1471 cmdline_fixed_string_t keyword;
1475 static void cmd_operate_detach_port_parsed(void *parsed_result,
1476 __rte_unused struct cmdline *cl,
1477 __rte_unused void *data)
1479 struct cmd_operate_detach_port_result *res = parsed_result;
1481 if (!strcmp(res->keyword, "detach")) {
1482 RTE_ETH_VALID_PORTID_OR_RET(res->port_id);
1483 detach_port_device(res->port_id);
1485 printf("Unknown parameter\n");
1489 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1490 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1492 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1493 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1495 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1496 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1499 cmdline_parse_inst_t cmd_operate_detach_port = {
1500 .f = cmd_operate_detach_port_parsed,
1502 .help_str = "port detach <port_id>",
1504 (void *)&cmd_operate_detach_port_port,
1505 (void *)&cmd_operate_detach_port_keyword,
1506 (void *)&cmd_operate_detach_port_port_id,
1511 /* *** detach device by identifier *** */
1512 struct cmd_operate_detach_device_result {
1513 cmdline_fixed_string_t device;
1514 cmdline_fixed_string_t keyword;
1515 cmdline_fixed_string_t identifier;
1518 static void cmd_operate_detach_device_parsed(void *parsed_result,
1519 __rte_unused struct cmdline *cl,
1520 __rte_unused void *data)
1522 struct cmd_operate_detach_device_result *res = parsed_result;
1524 if (!strcmp(res->keyword, "detach"))
1525 detach_devargs(res->identifier);
1527 printf("Unknown parameter\n");
1530 cmdline_parse_token_string_t cmd_operate_detach_device_device =
1531 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1533 cmdline_parse_token_string_t cmd_operate_detach_device_keyword =
1534 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1536 cmdline_parse_token_string_t cmd_operate_detach_device_identifier =
1537 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1540 cmdline_parse_inst_t cmd_operate_detach_device = {
1541 .f = cmd_operate_detach_device_parsed,
1543 .help_str = "device detach <identifier>:"
1544 "(identifier: pci address or virtual dev name)",
1546 (void *)&cmd_operate_detach_device_device,
1547 (void *)&cmd_operate_detach_device_keyword,
1548 (void *)&cmd_operate_detach_device_identifier,
1552 /* *** configure speed for all ports *** */
1553 struct cmd_config_speed_all {
1554 cmdline_fixed_string_t port;
1555 cmdline_fixed_string_t keyword;
1556 cmdline_fixed_string_t all;
1557 cmdline_fixed_string_t item1;
1558 cmdline_fixed_string_t item2;
1559 cmdline_fixed_string_t value1;
1560 cmdline_fixed_string_t value2;
1564 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1569 if (!strcmp(duplexstr, "half")) {
1570 duplex = ETH_LINK_HALF_DUPLEX;
1571 } else if (!strcmp(duplexstr, "full")) {
1572 duplex = ETH_LINK_FULL_DUPLEX;
1573 } else if (!strcmp(duplexstr, "auto")) {
1574 duplex = ETH_LINK_FULL_DUPLEX;
1576 printf("Unknown duplex parameter\n");
1580 if (!strcmp(speedstr, "10")) {
1581 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1582 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1583 } else if (!strcmp(speedstr, "100")) {
1584 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1585 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1587 if (duplex != ETH_LINK_FULL_DUPLEX) {
1588 printf("Invalid speed/duplex parameters\n");
1591 if (!strcmp(speedstr, "1000")) {
1592 *speed = ETH_LINK_SPEED_1G;
1593 } else if (!strcmp(speedstr, "10000")) {
1594 *speed = ETH_LINK_SPEED_10G;
1595 } else if (!strcmp(speedstr, "25000")) {
1596 *speed = ETH_LINK_SPEED_25G;
1597 } else if (!strcmp(speedstr, "40000")) {
1598 *speed = ETH_LINK_SPEED_40G;
1599 } else if (!strcmp(speedstr, "50000")) {
1600 *speed = ETH_LINK_SPEED_50G;
1601 } else if (!strcmp(speedstr, "100000")) {
1602 *speed = ETH_LINK_SPEED_100G;
1603 } else if (!strcmp(speedstr, "200000")) {
1604 *speed = ETH_LINK_SPEED_200G;
1605 } else if (!strcmp(speedstr, "auto")) {
1606 *speed = ETH_LINK_SPEED_AUTONEG;
1608 printf("Unknown speed parameter\n");
1617 cmd_config_speed_all_parsed(void *parsed_result,
1618 __rte_unused struct cmdline *cl,
1619 __rte_unused void *data)
1621 struct cmd_config_speed_all *res = parsed_result;
1622 uint32_t link_speed;
1625 if (!all_ports_stopped()) {
1626 printf("Please stop all ports first\n");
1630 if (parse_and_check_speed_duplex(res->value1, res->value2,
1634 RTE_ETH_FOREACH_DEV(pid) {
1635 ports[pid].dev_conf.link_speeds = link_speed;
1638 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1641 cmdline_parse_token_string_t cmd_config_speed_all_port =
1642 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1643 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1644 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1646 cmdline_parse_token_string_t cmd_config_speed_all_all =
1647 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1648 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1649 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1650 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1651 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1652 "10#100#1000#10000#25000#40000#50000#100000#200000#auto");
1653 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1654 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1655 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1656 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1659 cmdline_parse_inst_t cmd_config_speed_all = {
1660 .f = cmd_config_speed_all_parsed,
1662 .help_str = "port config all speed "
1663 "10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex "
1666 (void *)&cmd_config_speed_all_port,
1667 (void *)&cmd_config_speed_all_keyword,
1668 (void *)&cmd_config_speed_all_all,
1669 (void *)&cmd_config_speed_all_item1,
1670 (void *)&cmd_config_speed_all_value1,
1671 (void *)&cmd_config_speed_all_item2,
1672 (void *)&cmd_config_speed_all_value2,
1677 /* *** configure speed for specific port *** */
1678 struct cmd_config_speed_specific {
1679 cmdline_fixed_string_t port;
1680 cmdline_fixed_string_t keyword;
1682 cmdline_fixed_string_t item1;
1683 cmdline_fixed_string_t item2;
1684 cmdline_fixed_string_t value1;
1685 cmdline_fixed_string_t value2;
1689 cmd_config_speed_specific_parsed(void *parsed_result,
1690 __rte_unused struct cmdline *cl,
1691 __rte_unused void *data)
1693 struct cmd_config_speed_specific *res = parsed_result;
1694 uint32_t link_speed;
1696 if (!all_ports_stopped()) {
1697 printf("Please stop all ports first\n");
1701 if (port_id_is_invalid(res->id, ENABLED_WARN))
1704 if (parse_and_check_speed_duplex(res->value1, res->value2,
1708 ports[res->id].dev_conf.link_speeds = link_speed;
1710 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1714 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1715 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1717 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1718 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1720 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1721 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT16);
1722 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1723 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1725 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1726 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1727 "10#100#1000#10000#25000#40000#50000#100000#200000#auto");
1728 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1729 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1731 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1732 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1735 cmdline_parse_inst_t cmd_config_speed_specific = {
1736 .f = cmd_config_speed_specific_parsed,
1738 .help_str = "port config <port_id> speed "
1739 "10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex "
1742 (void *)&cmd_config_speed_specific_port,
1743 (void *)&cmd_config_speed_specific_keyword,
1744 (void *)&cmd_config_speed_specific_id,
1745 (void *)&cmd_config_speed_specific_item1,
1746 (void *)&cmd_config_speed_specific_value1,
1747 (void *)&cmd_config_speed_specific_item2,
1748 (void *)&cmd_config_speed_specific_value2,
1753 /* *** configure loopback for all ports *** */
1754 struct cmd_config_loopback_all {
1755 cmdline_fixed_string_t port;
1756 cmdline_fixed_string_t keyword;
1757 cmdline_fixed_string_t all;
1758 cmdline_fixed_string_t item;
1763 cmd_config_loopback_all_parsed(void *parsed_result,
1764 __rte_unused struct cmdline *cl,
1765 __rte_unused void *data)
1767 struct cmd_config_loopback_all *res = parsed_result;
1770 if (!all_ports_stopped()) {
1771 printf("Please stop all ports first\n");
1775 RTE_ETH_FOREACH_DEV(pid) {
1776 ports[pid].dev_conf.lpbk_mode = res->mode;
1779 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1782 cmdline_parse_token_string_t cmd_config_loopback_all_port =
1783 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1784 cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1785 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1787 cmdline_parse_token_string_t cmd_config_loopback_all_all =
1788 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1789 cmdline_parse_token_string_t cmd_config_loopback_all_item =
1790 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1792 cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1793 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, UINT32);
1795 cmdline_parse_inst_t cmd_config_loopback_all = {
1796 .f = cmd_config_loopback_all_parsed,
1798 .help_str = "port config all loopback <mode>",
1800 (void *)&cmd_config_loopback_all_port,
1801 (void *)&cmd_config_loopback_all_keyword,
1802 (void *)&cmd_config_loopback_all_all,
1803 (void *)&cmd_config_loopback_all_item,
1804 (void *)&cmd_config_loopback_all_mode,
1809 /* *** configure loopback for specific port *** */
1810 struct cmd_config_loopback_specific {
1811 cmdline_fixed_string_t port;
1812 cmdline_fixed_string_t keyword;
1814 cmdline_fixed_string_t item;
1819 cmd_config_loopback_specific_parsed(void *parsed_result,
1820 __rte_unused struct cmdline *cl,
1821 __rte_unused void *data)
1823 struct cmd_config_loopback_specific *res = parsed_result;
1825 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1828 if (!port_is_stopped(res->port_id)) {
1829 printf("Please stop port %u first\n", res->port_id);
1833 ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1835 cmd_reconfig_device_queue(res->port_id, 1, 1);
1839 cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1840 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1842 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1843 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1845 cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1846 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1848 cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1849 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1851 cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1852 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1855 cmdline_parse_inst_t cmd_config_loopback_specific = {
1856 .f = cmd_config_loopback_specific_parsed,
1858 .help_str = "port config <port_id> loopback <mode>",
1860 (void *)&cmd_config_loopback_specific_port,
1861 (void *)&cmd_config_loopback_specific_keyword,
1862 (void *)&cmd_config_loopback_specific_id,
1863 (void *)&cmd_config_loopback_specific_item,
1864 (void *)&cmd_config_loopback_specific_mode,
1869 /* *** configure txq/rxq, txd/rxd *** */
1870 struct cmd_config_rx_tx {
1871 cmdline_fixed_string_t port;
1872 cmdline_fixed_string_t keyword;
1873 cmdline_fixed_string_t all;
1874 cmdline_fixed_string_t name;
1879 cmd_config_rx_tx_parsed(void *parsed_result,
1880 __rte_unused struct cmdline *cl,
1881 __rte_unused void *data)
1883 struct cmd_config_rx_tx *res = parsed_result;
1885 if (!all_ports_stopped()) {
1886 printf("Please stop all ports first\n");
1889 if (!strcmp(res->name, "rxq")) {
1890 if (!res->value && !nb_txq) {
1891 printf("Warning: Either rx or tx queues should be non zero\n");
1894 if (check_nb_rxq(res->value) != 0)
1896 nb_rxq = res->value;
1898 else if (!strcmp(res->name, "txq")) {
1899 if (!res->value && !nb_rxq) {
1900 printf("Warning: Either rx or tx queues should be non zero\n");
1903 if (check_nb_txq(res->value) != 0)
1905 nb_txq = res->value;
1907 else if (!strcmp(res->name, "rxd")) {
1908 if (check_nb_rxd(res->value) != 0)
1910 nb_rxd = res->value;
1911 } else if (!strcmp(res->name, "txd")) {
1912 if (check_nb_txd(res->value) != 0)
1915 nb_txd = res->value;
1917 printf("Unknown parameter\n");
1925 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1928 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1929 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1930 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1931 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1932 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1933 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1934 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1935 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1937 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1938 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1940 cmdline_parse_inst_t cmd_config_rx_tx = {
1941 .f = cmd_config_rx_tx_parsed,
1943 .help_str = "port config all rxq|txq|rxd|txd <value>",
1945 (void *)&cmd_config_rx_tx_port,
1946 (void *)&cmd_config_rx_tx_keyword,
1947 (void *)&cmd_config_rx_tx_all,
1948 (void *)&cmd_config_rx_tx_name,
1949 (void *)&cmd_config_rx_tx_value,
1954 /* *** config max packet length *** */
1955 struct cmd_config_max_pkt_len_result {
1956 cmdline_fixed_string_t port;
1957 cmdline_fixed_string_t keyword;
1958 cmdline_fixed_string_t all;
1959 cmdline_fixed_string_t name;
1964 cmd_config_max_pkt_len_parsed(void *parsed_result,
1965 __rte_unused struct cmdline *cl,
1966 __rte_unused void *data)
1968 struct cmd_config_max_pkt_len_result *res = parsed_result;
1971 if (!all_ports_stopped()) {
1972 printf("Please stop all ports first\n");
1976 RTE_ETH_FOREACH_DEV(pid) {
1977 struct rte_port *port = &ports[pid];
1978 uint64_t rx_offloads = port->dev_conf.rxmode.offloads;
1980 if (!strcmp(res->name, "max-pkt-len")) {
1981 if (res->value < RTE_ETHER_MIN_LEN) {
1982 printf("max-pkt-len can not be less than %d\n",
1986 if (res->value == port->dev_conf.rxmode.max_rx_pkt_len)
1989 port->dev_conf.rxmode.max_rx_pkt_len = res->value;
1990 if (res->value > RTE_ETHER_MAX_LEN)
1991 rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
1993 rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
1994 port->dev_conf.rxmode.offloads = rx_offloads;
1996 printf("Unknown parameter\n");
2003 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2006 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
2007 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
2009 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
2010 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
2012 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
2013 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
2015 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
2016 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
2018 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
2019 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
2022 cmdline_parse_inst_t cmd_config_max_pkt_len = {
2023 .f = cmd_config_max_pkt_len_parsed,
2025 .help_str = "port config all max-pkt-len <value>",
2027 (void *)&cmd_config_max_pkt_len_port,
2028 (void *)&cmd_config_max_pkt_len_keyword,
2029 (void *)&cmd_config_max_pkt_len_all,
2030 (void *)&cmd_config_max_pkt_len_name,
2031 (void *)&cmd_config_max_pkt_len_value,
2036 /* *** config max LRO aggregated packet size *** */
2037 struct cmd_config_max_lro_pkt_size_result {
2038 cmdline_fixed_string_t port;
2039 cmdline_fixed_string_t keyword;
2040 cmdline_fixed_string_t all;
2041 cmdline_fixed_string_t name;
2046 cmd_config_max_lro_pkt_size_parsed(void *parsed_result,
2047 __rte_unused struct cmdline *cl,
2048 __rte_unused void *data)
2050 struct cmd_config_max_lro_pkt_size_result *res = parsed_result;
2053 if (!all_ports_stopped()) {
2054 printf("Please stop all ports first\n");
2058 RTE_ETH_FOREACH_DEV(pid) {
2059 struct rte_port *port = &ports[pid];
2061 if (!strcmp(res->name, "max-lro-pkt-size")) {
2063 port->dev_conf.rxmode.max_lro_pkt_size)
2066 port->dev_conf.rxmode.max_lro_pkt_size = res->value;
2068 printf("Unknown parameter\n");
2075 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2078 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_port =
2079 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2081 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_keyword =
2082 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2084 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_all =
2085 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2087 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_name =
2088 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2089 name, "max-lro-pkt-size");
2090 cmdline_parse_token_num_t cmd_config_max_lro_pkt_size_value =
2091 TOKEN_NUM_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2094 cmdline_parse_inst_t cmd_config_max_lro_pkt_size = {
2095 .f = cmd_config_max_lro_pkt_size_parsed,
2097 .help_str = "port config all max-lro-pkt-size <value>",
2099 (void *)&cmd_config_max_lro_pkt_size_port,
2100 (void *)&cmd_config_max_lro_pkt_size_keyword,
2101 (void *)&cmd_config_max_lro_pkt_size_all,
2102 (void *)&cmd_config_max_lro_pkt_size_name,
2103 (void *)&cmd_config_max_lro_pkt_size_value,
2108 /* *** configure port MTU *** */
2109 struct cmd_config_mtu_result {
2110 cmdline_fixed_string_t port;
2111 cmdline_fixed_string_t keyword;
2112 cmdline_fixed_string_t mtu;
2118 cmd_config_mtu_parsed(void *parsed_result,
2119 __rte_unused struct cmdline *cl,
2120 __rte_unused void *data)
2122 struct cmd_config_mtu_result *res = parsed_result;
2124 if (res->value < RTE_ETHER_MIN_LEN) {
2125 printf("mtu cannot be less than %d\n", RTE_ETHER_MIN_LEN);
2128 port_mtu_set(res->port_id, res->value);
2131 cmdline_parse_token_string_t cmd_config_mtu_port =
2132 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
2134 cmdline_parse_token_string_t cmd_config_mtu_keyword =
2135 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2137 cmdline_parse_token_string_t cmd_config_mtu_mtu =
2138 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2140 cmdline_parse_token_num_t cmd_config_mtu_port_id =
2141 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT16);
2142 cmdline_parse_token_num_t cmd_config_mtu_value =
2143 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
2145 cmdline_parse_inst_t cmd_config_mtu = {
2146 .f = cmd_config_mtu_parsed,
2148 .help_str = "port config mtu <port_id> <value>",
2150 (void *)&cmd_config_mtu_port,
2151 (void *)&cmd_config_mtu_keyword,
2152 (void *)&cmd_config_mtu_mtu,
2153 (void *)&cmd_config_mtu_port_id,
2154 (void *)&cmd_config_mtu_value,
2159 /* *** configure rx mode *** */
2160 struct cmd_config_rx_mode_flag {
2161 cmdline_fixed_string_t port;
2162 cmdline_fixed_string_t keyword;
2163 cmdline_fixed_string_t all;
2164 cmdline_fixed_string_t name;
2165 cmdline_fixed_string_t value;
2169 cmd_config_rx_mode_flag_parsed(void *parsed_result,
2170 __rte_unused struct cmdline *cl,
2171 __rte_unused void *data)
2173 struct cmd_config_rx_mode_flag *res = parsed_result;
2175 if (!all_ports_stopped()) {
2176 printf("Please stop all ports first\n");
2180 if (!strcmp(res->name, "drop-en")) {
2181 if (!strcmp(res->value, "on"))
2183 else if (!strcmp(res->value, "off"))
2186 printf("Unknown parameter\n");
2190 printf("Unknown parameter\n");
2196 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2199 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
2200 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
2201 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
2202 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
2204 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2205 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2206 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2207 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2209 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2210 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2213 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2214 .f = cmd_config_rx_mode_flag_parsed,
2216 .help_str = "port config all drop-en on|off",
2218 (void *)&cmd_config_rx_mode_flag_port,
2219 (void *)&cmd_config_rx_mode_flag_keyword,
2220 (void *)&cmd_config_rx_mode_flag_all,
2221 (void *)&cmd_config_rx_mode_flag_name,
2222 (void *)&cmd_config_rx_mode_flag_value,
2227 /* *** configure rss *** */
2228 struct cmd_config_rss {
2229 cmdline_fixed_string_t port;
2230 cmdline_fixed_string_t keyword;
2231 cmdline_fixed_string_t all;
2232 cmdline_fixed_string_t name;
2233 cmdline_fixed_string_t value;
2237 cmd_config_rss_parsed(void *parsed_result,
2238 __rte_unused struct cmdline *cl,
2239 __rte_unused void *data)
2241 struct cmd_config_rss *res = parsed_result;
2242 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2243 struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2244 int use_default = 0;
2245 int all_updated = 1;
2250 if (!strcmp(res->value, "all"))
2251 rss_conf.rss_hf = ETH_RSS_ETH | ETH_RSS_VLAN | ETH_RSS_IP |
2252 ETH_RSS_TCP | ETH_RSS_UDP | ETH_RSS_SCTP |
2253 ETH_RSS_L2_PAYLOAD | ETH_RSS_L2TPV3 | ETH_RSS_ESP |
2254 ETH_RSS_AH | ETH_RSS_PFCP | ETH_RSS_GTPU;
2255 else if (!strcmp(res->value, "eth"))
2256 rss_conf.rss_hf = ETH_RSS_ETH;
2257 else if (!strcmp(res->value, "vlan"))
2258 rss_conf.rss_hf = ETH_RSS_VLAN;
2259 else if (!strcmp(res->value, "ip"))
2260 rss_conf.rss_hf = ETH_RSS_IP;
2261 else if (!strcmp(res->value, "udp"))
2262 rss_conf.rss_hf = ETH_RSS_UDP;
2263 else if (!strcmp(res->value, "tcp"))
2264 rss_conf.rss_hf = ETH_RSS_TCP;
2265 else if (!strcmp(res->value, "sctp"))
2266 rss_conf.rss_hf = ETH_RSS_SCTP;
2267 else if (!strcmp(res->value, "ether"))
2268 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
2269 else if (!strcmp(res->value, "port"))
2270 rss_conf.rss_hf = ETH_RSS_PORT;
2271 else if (!strcmp(res->value, "vxlan"))
2272 rss_conf.rss_hf = ETH_RSS_VXLAN;
2273 else if (!strcmp(res->value, "geneve"))
2274 rss_conf.rss_hf = ETH_RSS_GENEVE;
2275 else if (!strcmp(res->value, "nvgre"))
2276 rss_conf.rss_hf = ETH_RSS_NVGRE;
2277 else if (!strcmp(res->value, "l3-pre32"))
2278 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE32;
2279 else if (!strcmp(res->value, "l3-pre40"))
2280 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE40;
2281 else if (!strcmp(res->value, "l3-pre48"))
2282 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE48;
2283 else if (!strcmp(res->value, "l3-pre56"))
2284 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE56;
2285 else if (!strcmp(res->value, "l3-pre64"))
2286 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE64;
2287 else if (!strcmp(res->value, "l3-pre96"))
2288 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE96;
2289 else if (!strcmp(res->value, "l3-src-only"))
2290 rss_conf.rss_hf = ETH_RSS_L3_SRC_ONLY;
2291 else if (!strcmp(res->value, "l3-dst-only"))
2292 rss_conf.rss_hf = ETH_RSS_L3_DST_ONLY;
2293 else if (!strcmp(res->value, "l4-src-only"))
2294 rss_conf.rss_hf = ETH_RSS_L4_SRC_ONLY;
2295 else if (!strcmp(res->value, "l4-dst-only"))
2296 rss_conf.rss_hf = ETH_RSS_L4_DST_ONLY;
2297 else if (!strcmp(res->value, "l2-src-only"))
2298 rss_conf.rss_hf = ETH_RSS_L2_SRC_ONLY;
2299 else if (!strcmp(res->value, "l2-dst-only"))
2300 rss_conf.rss_hf = ETH_RSS_L2_DST_ONLY;
2301 else if (!strcmp(res->value, "l2tpv3"))
2302 rss_conf.rss_hf = ETH_RSS_L2TPV3;
2303 else if (!strcmp(res->value, "esp"))
2304 rss_conf.rss_hf = ETH_RSS_ESP;
2305 else if (!strcmp(res->value, "ah"))
2306 rss_conf.rss_hf = ETH_RSS_AH;
2307 else if (!strcmp(res->value, "pfcp"))
2308 rss_conf.rss_hf = ETH_RSS_PFCP;
2309 else if (!strcmp(res->value, "pppoe"))
2310 rss_conf.rss_hf = ETH_RSS_PPPOE;
2311 else if (!strcmp(res->value, "gtpu"))
2312 rss_conf.rss_hf = ETH_RSS_GTPU;
2313 else if (!strcmp(res->value, "none"))
2314 rss_conf.rss_hf = 0;
2315 else if (!strcmp(res->value, "level-default")) {
2316 rss_hf &= (~ETH_RSS_LEVEL_MASK);
2317 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_PMD_DEFAULT);
2318 } else if (!strcmp(res->value, "level-outer")) {
2319 rss_hf &= (~ETH_RSS_LEVEL_MASK);
2320 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_OUTERMOST);
2321 } else if (!strcmp(res->value, "level-inner")) {
2322 rss_hf &= (~ETH_RSS_LEVEL_MASK);
2323 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_INNERMOST);
2324 } else if (!strcmp(res->value, "default"))
2326 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2327 atoi(res->value) < 64)
2328 rss_conf.rss_hf = 1ULL << atoi(res->value);
2330 printf("Unknown parameter\n");
2333 rss_conf.rss_key = NULL;
2334 /* Update global configuration for RSS types. */
2335 RTE_ETH_FOREACH_DEV(i) {
2336 struct rte_eth_rss_conf local_rss_conf;
2338 ret = eth_dev_info_get_print_err(i, &dev_info);
2343 rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2345 local_rss_conf = rss_conf;
2346 local_rss_conf.rss_hf = rss_conf.rss_hf &
2347 dev_info.flow_type_rss_offloads;
2348 if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2349 printf("Port %u modified RSS hash function based on hardware support,"
2350 "requested:%#"PRIx64" configured:%#"PRIx64"\n",
2351 i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2353 diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2356 printf("Configuration of RSS hash at ethernet port %d "
2357 "failed with error (%d): %s.\n",
2358 i, -diag, strerror(-diag));
2361 if (all_updated && !use_default) {
2362 rss_hf = rss_conf.rss_hf;
2363 printf("rss_hf %#"PRIx64"\n", rss_hf);
2367 cmdline_parse_token_string_t cmd_config_rss_port =
2368 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2369 cmdline_parse_token_string_t cmd_config_rss_keyword =
2370 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2371 cmdline_parse_token_string_t cmd_config_rss_all =
2372 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2373 cmdline_parse_token_string_t cmd_config_rss_name =
2374 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2375 cmdline_parse_token_string_t cmd_config_rss_value =
2376 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2378 cmdline_parse_inst_t cmd_config_rss = {
2379 .f = cmd_config_rss_parsed,
2381 .help_str = "port config all rss "
2382 "all|default|eth|vlan|ip|tcp|udp|sctp|ether|port|vxlan|geneve|"
2383 "nvgre|vxlan-gpe|l2tpv3|esp|ah|pfcp|none|level-default|"
2384 "level-outer|level-inner|<flowtype_id>",
2386 (void *)&cmd_config_rss_port,
2387 (void *)&cmd_config_rss_keyword,
2388 (void *)&cmd_config_rss_all,
2389 (void *)&cmd_config_rss_name,
2390 (void *)&cmd_config_rss_value,
2395 /* *** configure rss hash key *** */
2396 struct cmd_config_rss_hash_key {
2397 cmdline_fixed_string_t port;
2398 cmdline_fixed_string_t config;
2400 cmdline_fixed_string_t rss_hash_key;
2401 cmdline_fixed_string_t rss_type;
2402 cmdline_fixed_string_t key;
2406 hexa_digit_to_value(char hexa_digit)
2408 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2409 return (uint8_t) (hexa_digit - '0');
2410 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2411 return (uint8_t) ((hexa_digit - 'a') + 10);
2412 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2413 return (uint8_t) ((hexa_digit - 'A') + 10);
2414 /* Invalid hexa digit */
2419 parse_and_check_key_hexa_digit(char *key, int idx)
2423 hexa_v = hexa_digit_to_value(key[idx]);
2425 printf("invalid key: character %c at position %d is not a "
2426 "valid hexa digit\n", key[idx], idx);
2431 cmd_config_rss_hash_key_parsed(void *parsed_result,
2432 __rte_unused struct cmdline *cl,
2433 __rte_unused void *data)
2435 struct cmd_config_rss_hash_key *res = parsed_result;
2436 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2440 struct rte_eth_dev_info dev_info;
2441 uint8_t hash_key_size;
2445 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2449 if (dev_info.hash_key_size > 0 &&
2450 dev_info.hash_key_size <= sizeof(hash_key))
2451 hash_key_size = dev_info.hash_key_size;
2453 printf("dev_info did not provide a valid hash key size\n");
2456 /* Check the length of the RSS hash key */
2457 key_len = strlen(res->key);
2458 if (key_len != (hash_key_size * 2)) {
2459 printf("key length: %d invalid - key must be a string of %d"
2460 " hexa-decimal numbers\n",
2461 (int) key_len, hash_key_size * 2);
2464 /* Translate RSS hash key into binary representation */
2465 for (i = 0; i < hash_key_size; i++) {
2466 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2469 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2472 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2474 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2478 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2479 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2480 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2481 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2483 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2484 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16);
2485 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2486 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2487 rss_hash_key, "rss-hash-key");
2488 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2489 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2490 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2491 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2492 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2493 "ipv6-tcp-ex#ipv6-udp-ex#"
2494 "l3-src-only#l3-dst-only#l4-src-only#l4-dst-only#"
2495 "l2-src-only#l2-dst-only#s-vlan#c-vlan#"
2496 "l2tpv3#esp#ah#pfcp#pppoe#gtpu");
2497 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2498 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2500 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2501 .f = cmd_config_rss_hash_key_parsed,
2503 .help_str = "port config <port_id> rss-hash-key "
2504 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2505 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2506 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|"
2507 "l3-src-only|l3-dst-only|l4-src-only|l4-dst-only|"
2508 "l2-src-only|l2-dst-only|s-vlan|c-vlan|"
2509 "l2tpv3|esp|ah|pfcp|pppoe|gtpu "
2510 "<string of hex digits (variable length, NIC dependent)>",
2512 (void *)&cmd_config_rss_hash_key_port,
2513 (void *)&cmd_config_rss_hash_key_config,
2514 (void *)&cmd_config_rss_hash_key_port_id,
2515 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2516 (void *)&cmd_config_rss_hash_key_rss_type,
2517 (void *)&cmd_config_rss_hash_key_value,
2522 /* *** configure port rxq/txq ring size *** */
2523 struct cmd_config_rxtx_ring_size {
2524 cmdline_fixed_string_t port;
2525 cmdline_fixed_string_t config;
2527 cmdline_fixed_string_t rxtxq;
2529 cmdline_fixed_string_t rsize;
2534 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2535 __rte_unused struct cmdline *cl,
2536 __rte_unused void *data)
2538 struct cmd_config_rxtx_ring_size *res = parsed_result;
2539 struct rte_port *port;
2542 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2545 if (res->portid == (portid_t)RTE_PORT_ALL) {
2546 printf("Invalid port id\n");
2550 port = &ports[res->portid];
2552 if (!strcmp(res->rxtxq, "rxq"))
2554 else if (!strcmp(res->rxtxq, "txq"))
2557 printf("Unknown parameter\n");
2561 if (isrx && rx_queue_id_is_invalid(res->qid))
2563 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2566 if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2567 printf("Invalid rx ring_size, must > rx_free_thresh: %d\n",
2573 port->nb_rx_desc[res->qid] = res->size;
2575 port->nb_tx_desc[res->qid] = res->size;
2577 cmd_reconfig_device_queue(res->portid, 0, 1);
2580 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2581 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2583 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2584 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2586 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2587 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2589 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2590 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2592 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2593 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2595 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2596 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2597 rsize, "ring_size");
2598 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2599 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2602 cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2603 .f = cmd_config_rxtx_ring_size_parsed,
2605 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2607 (void *)&cmd_config_rxtx_ring_size_port,
2608 (void *)&cmd_config_rxtx_ring_size_config,
2609 (void *)&cmd_config_rxtx_ring_size_portid,
2610 (void *)&cmd_config_rxtx_ring_size_rxtxq,
2611 (void *)&cmd_config_rxtx_ring_size_qid,
2612 (void *)&cmd_config_rxtx_ring_size_rsize,
2613 (void *)&cmd_config_rxtx_ring_size_size,
2618 /* *** configure port rxq/txq start/stop *** */
2619 struct cmd_config_rxtx_queue {
2620 cmdline_fixed_string_t port;
2622 cmdline_fixed_string_t rxtxq;
2624 cmdline_fixed_string_t opname;
2628 cmd_config_rxtx_queue_parsed(void *parsed_result,
2629 __rte_unused struct cmdline *cl,
2630 __rte_unused void *data)
2632 struct cmd_config_rxtx_queue *res = parsed_result;
2637 if (test_done == 0) {
2638 printf("Please stop forwarding first\n");
2642 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2645 if (port_is_started(res->portid) != 1) {
2646 printf("Please start port %u first\n", res->portid);
2650 if (!strcmp(res->rxtxq, "rxq"))
2652 else if (!strcmp(res->rxtxq, "txq"))
2655 printf("Unknown parameter\n");
2659 if (isrx && rx_queue_id_is_invalid(res->qid))
2661 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2664 if (!strcmp(res->opname, "start"))
2666 else if (!strcmp(res->opname, "stop"))
2669 printf("Unknown parameter\n");
2673 if (isstart && isrx)
2674 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2675 else if (!isstart && isrx)
2676 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2677 else if (isstart && !isrx)
2678 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2680 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2682 if (ret == -ENOTSUP)
2683 printf("Function not supported in PMD driver\n");
2686 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2687 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2688 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2689 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16);
2690 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2691 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2692 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2693 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
2694 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2695 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2698 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2699 .f = cmd_config_rxtx_queue_parsed,
2701 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2703 (void *)&cmd_config_rxtx_queue_port,
2704 (void *)&cmd_config_rxtx_queue_portid,
2705 (void *)&cmd_config_rxtx_queue_rxtxq,
2706 (void *)&cmd_config_rxtx_queue_qid,
2707 (void *)&cmd_config_rxtx_queue_opname,
2712 /* *** configure port rxq/txq deferred start on/off *** */
2713 struct cmd_config_deferred_start_rxtx_queue {
2714 cmdline_fixed_string_t port;
2716 cmdline_fixed_string_t rxtxq;
2718 cmdline_fixed_string_t opname;
2719 cmdline_fixed_string_t state;
2723 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2724 __rte_unused struct cmdline *cl,
2725 __rte_unused void *data)
2727 struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2728 struct rte_port *port;
2731 uint8_t needreconfig = 0;
2733 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2736 if (port_is_started(res->port_id) != 0) {
2737 printf("Please stop port %u first\n", res->port_id);
2741 port = &ports[res->port_id];
2743 isrx = !strcmp(res->rxtxq, "rxq");
2745 if (isrx && rx_queue_id_is_invalid(res->qid))
2747 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2750 ison = !strcmp(res->state, "on");
2752 if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) {
2753 port->rx_conf[res->qid].rx_deferred_start = ison;
2755 } else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) {
2756 port->tx_conf[res->qid].tx_deferred_start = ison;
2761 cmd_reconfig_device_queue(res->port_id, 0, 1);
2764 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2765 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2767 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2768 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2770 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2771 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2773 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2774 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2776 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2777 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2778 opname, "deferred_start");
2779 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2780 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2783 cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
2784 .f = cmd_config_deferred_start_rxtx_queue_parsed,
2786 .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
2788 (void *)&cmd_config_deferred_start_rxtx_queue_port,
2789 (void *)&cmd_config_deferred_start_rxtx_queue_port_id,
2790 (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
2791 (void *)&cmd_config_deferred_start_rxtx_queue_qid,
2792 (void *)&cmd_config_deferred_start_rxtx_queue_opname,
2793 (void *)&cmd_config_deferred_start_rxtx_queue_state,
2798 /* *** configure port rxq/txq setup *** */
2799 struct cmd_setup_rxtx_queue {
2800 cmdline_fixed_string_t port;
2802 cmdline_fixed_string_t rxtxq;
2804 cmdline_fixed_string_t setup;
2807 /* Common CLI fields for queue setup */
2808 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2809 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2810 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2811 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, UINT16);
2812 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2813 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2814 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2815 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, UINT16);
2816 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2817 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2820 cmd_setup_rxtx_queue_parsed(
2821 void *parsed_result,
2822 __rte_unused struct cmdline *cl,
2823 __rte_unused void *data)
2825 struct cmd_setup_rxtx_queue *res = parsed_result;
2826 struct rte_port *port;
2827 struct rte_mempool *mp;
2828 unsigned int socket_id;
2832 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2835 if (res->portid == (portid_t)RTE_PORT_ALL) {
2836 printf("Invalid port id\n");
2840 if (!strcmp(res->rxtxq, "rxq"))
2842 else if (!strcmp(res->rxtxq, "txq"))
2845 printf("Unknown parameter\n");
2849 if (isrx && rx_queue_id_is_invalid(res->qid)) {
2850 printf("Invalid rx queue\n");
2852 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2853 printf("Invalid tx queue\n");
2857 port = &ports[res->portid];
2859 socket_id = rxring_numa[res->portid];
2860 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2861 socket_id = port->socket_id;
2863 mp = mbuf_pool_find(socket_id, 0);
2865 printf("Failed to setup RX queue: "
2866 "No mempool allocation"
2867 " on the socket %d\n",
2868 rxring_numa[res->portid]);
2871 ret = rx_queue_setup(res->portid,
2873 port->nb_rx_desc[res->qid],
2875 &port->rx_conf[res->qid],
2878 printf("Failed to setup RX queue\n");
2880 socket_id = txring_numa[res->portid];
2881 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2882 socket_id = port->socket_id;
2884 ret = rte_eth_tx_queue_setup(res->portid,
2886 port->nb_tx_desc[res->qid],
2888 &port->tx_conf[res->qid]);
2890 printf("Failed to setup TX queue\n");
2894 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2895 .f = cmd_setup_rxtx_queue_parsed,
2897 .help_str = "port <port_id> rxq|txq <queue_idx> setup",
2899 (void *)&cmd_setup_rxtx_queue_port,
2900 (void *)&cmd_setup_rxtx_queue_portid,
2901 (void *)&cmd_setup_rxtx_queue_rxtxq,
2902 (void *)&cmd_setup_rxtx_queue_qid,
2903 (void *)&cmd_setup_rxtx_queue_setup,
2909 /* *** Configure RSS RETA *** */
2910 struct cmd_config_rss_reta {
2911 cmdline_fixed_string_t port;
2912 cmdline_fixed_string_t keyword;
2914 cmdline_fixed_string_t name;
2915 cmdline_fixed_string_t list_name;
2916 cmdline_fixed_string_t list_of_items;
2920 parse_reta_config(const char *str,
2921 struct rte_eth_rss_reta_entry64 *reta_conf,
2922 uint16_t nb_entries)
2926 uint16_t hash_index, idx, shift;
2929 const char *p, *p0 = str;
2936 unsigned long int_fld[_NUM_FLD];
2937 char *str_fld[_NUM_FLD];
2939 while ((p = strchr(p0,'(')) != NULL) {
2941 if((p0 = strchr(p,')')) == NULL)
2945 if(size >= sizeof(s))
2948 snprintf(s, sizeof(s), "%.*s", size, p);
2949 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2951 for (i = 0; i < _NUM_FLD; i++) {
2953 int_fld[i] = strtoul(str_fld[i], &end, 0);
2954 if (errno != 0 || end == str_fld[i] ||
2959 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2960 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2962 if (hash_index >= nb_entries) {
2963 printf("Invalid RETA hash index=%d\n", hash_index);
2967 idx = hash_index / RTE_RETA_GROUP_SIZE;
2968 shift = hash_index % RTE_RETA_GROUP_SIZE;
2969 reta_conf[idx].mask |= (1ULL << shift);
2970 reta_conf[idx].reta[shift] = nb_queue;
2977 cmd_set_rss_reta_parsed(void *parsed_result,
2978 __rte_unused struct cmdline *cl,
2979 __rte_unused void *data)
2982 struct rte_eth_dev_info dev_info;
2983 struct rte_eth_rss_reta_entry64 reta_conf[8];
2984 struct cmd_config_rss_reta *res = parsed_result;
2986 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2990 if (dev_info.reta_size == 0) {
2991 printf("Redirection table size is 0 which is "
2992 "invalid for RSS\n");
2995 printf("The reta size of port %d is %u\n",
2996 res->port_id, dev_info.reta_size);
2997 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2998 printf("Currently do not support more than %u entries of "
2999 "redirection table\n", ETH_RSS_RETA_SIZE_512);
3003 memset(reta_conf, 0, sizeof(reta_conf));
3004 if (!strcmp(res->list_name, "reta")) {
3005 if (parse_reta_config(res->list_of_items, reta_conf,
3006 dev_info.reta_size)) {
3007 printf("Invalid RSS Redirection Table "
3008 "config entered\n");
3011 ret = rte_eth_dev_rss_reta_update(res->port_id,
3012 reta_conf, dev_info.reta_size);
3014 printf("Bad redirection table parameter, "
3015 "return code = %d \n", ret);
3019 cmdline_parse_token_string_t cmd_config_rss_reta_port =
3020 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
3021 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
3022 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
3023 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
3024 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16);
3025 cmdline_parse_token_string_t cmd_config_rss_reta_name =
3026 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
3027 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
3028 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
3029 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
3030 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
3032 cmdline_parse_inst_t cmd_config_rss_reta = {
3033 .f = cmd_set_rss_reta_parsed,
3035 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
3037 (void *)&cmd_config_rss_reta_port,
3038 (void *)&cmd_config_rss_reta_keyword,
3039 (void *)&cmd_config_rss_reta_port_id,
3040 (void *)&cmd_config_rss_reta_name,
3041 (void *)&cmd_config_rss_reta_list_name,
3042 (void *)&cmd_config_rss_reta_list_of_items,
3047 /* *** SHOW PORT RETA INFO *** */
3048 struct cmd_showport_reta {
3049 cmdline_fixed_string_t show;
3050 cmdline_fixed_string_t port;
3052 cmdline_fixed_string_t rss;
3053 cmdline_fixed_string_t reta;
3055 cmdline_fixed_string_t list_of_items;
3059 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
3060 uint16_t nb_entries,
3064 const char *p, *p0 = str;
3069 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
3070 RTE_RETA_GROUP_SIZE;
3073 p = strchr(p0, '(');
3077 p0 = strchr(p, ')');
3081 if (size >= sizeof(s)) {
3082 printf("The string size exceeds the internal buffer size\n");
3085 snprintf(s, sizeof(s), "%.*s", size, p);
3086 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
3087 if (ret <= 0 || ret != num) {
3088 printf("The bits of masks do not match the number of "
3089 "reta entries: %u\n", num);
3092 for (i = 0; i < ret; i++)
3093 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
3099 cmd_showport_reta_parsed(void *parsed_result,
3100 __rte_unused struct cmdline *cl,
3101 __rte_unused void *data)
3103 struct cmd_showport_reta *res = parsed_result;
3104 struct rte_eth_rss_reta_entry64 reta_conf[8];
3105 struct rte_eth_dev_info dev_info;
3106 uint16_t max_reta_size;
3109 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3113 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
3114 if (res->size == 0 || res->size > max_reta_size) {
3115 printf("Invalid redirection table size: %u (1-%u)\n",
3116 res->size, max_reta_size);
3120 memset(reta_conf, 0, sizeof(reta_conf));
3121 if (showport_parse_reta_config(reta_conf, res->size,
3122 res->list_of_items) < 0) {
3123 printf("Invalid string: %s for reta masks\n",
3124 res->list_of_items);
3127 port_rss_reta_info(res->port_id, reta_conf, res->size);
3130 cmdline_parse_token_string_t cmd_showport_reta_show =
3131 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
3132 cmdline_parse_token_string_t cmd_showport_reta_port =
3133 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
3134 cmdline_parse_token_num_t cmd_showport_reta_port_id =
3135 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16);
3136 cmdline_parse_token_string_t cmd_showport_reta_rss =
3137 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
3138 cmdline_parse_token_string_t cmd_showport_reta_reta =
3139 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
3140 cmdline_parse_token_num_t cmd_showport_reta_size =
3141 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
3142 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
3143 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
3144 list_of_items, NULL);
3146 cmdline_parse_inst_t cmd_showport_reta = {
3147 .f = cmd_showport_reta_parsed,
3149 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
3151 (void *)&cmd_showport_reta_show,
3152 (void *)&cmd_showport_reta_port,
3153 (void *)&cmd_showport_reta_port_id,
3154 (void *)&cmd_showport_reta_rss,
3155 (void *)&cmd_showport_reta_reta,
3156 (void *)&cmd_showport_reta_size,
3157 (void *)&cmd_showport_reta_list_of_items,
3162 /* *** Show RSS hash configuration *** */
3163 struct cmd_showport_rss_hash {
3164 cmdline_fixed_string_t show;
3165 cmdline_fixed_string_t port;
3167 cmdline_fixed_string_t rss_hash;
3168 cmdline_fixed_string_t rss_type;
3169 cmdline_fixed_string_t key; /* optional argument */
3172 static void cmd_showport_rss_hash_parsed(void *parsed_result,
3173 __rte_unused struct cmdline *cl,
3176 struct cmd_showport_rss_hash *res = parsed_result;
3178 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
3181 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
3182 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
3183 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
3184 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
3185 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
3186 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16);
3187 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
3188 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
3190 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
3191 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
3193 cmdline_parse_inst_t cmd_showport_rss_hash = {
3194 .f = cmd_showport_rss_hash_parsed,
3196 .help_str = "show port <port_id> rss-hash",
3198 (void *)&cmd_showport_rss_hash_show,
3199 (void *)&cmd_showport_rss_hash_port,
3200 (void *)&cmd_showport_rss_hash_port_id,
3201 (void *)&cmd_showport_rss_hash_rss_hash,
3206 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
3207 .f = cmd_showport_rss_hash_parsed,
3209 .help_str = "show port <port_id> rss-hash key",
3211 (void *)&cmd_showport_rss_hash_show,
3212 (void *)&cmd_showport_rss_hash_port,
3213 (void *)&cmd_showport_rss_hash_port_id,
3214 (void *)&cmd_showport_rss_hash_rss_hash,
3215 (void *)&cmd_showport_rss_hash_rss_key,
3220 /* *** Configure DCB *** */
3221 struct cmd_config_dcb {
3222 cmdline_fixed_string_t port;
3223 cmdline_fixed_string_t config;
3225 cmdline_fixed_string_t dcb;
3226 cmdline_fixed_string_t vt;
3227 cmdline_fixed_string_t vt_en;
3229 cmdline_fixed_string_t pfc;
3230 cmdline_fixed_string_t pfc_en;
3234 cmd_config_dcb_parsed(void *parsed_result,
3235 __rte_unused struct cmdline *cl,
3236 __rte_unused void *data)
3238 struct cmd_config_dcb *res = parsed_result;
3239 portid_t port_id = res->port_id;
3240 struct rte_port *port;
3244 port = &ports[port_id];
3245 /** Check if the port is not started **/
3246 if (port->port_status != RTE_PORT_STOPPED) {
3247 printf("Please stop port %d first\n", port_id);
3251 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
3252 printf("The invalid number of traffic class,"
3253 " only 4 or 8 allowed.\n");
3257 if (nb_fwd_lcores < res->num_tcs) {
3258 printf("nb_cores shouldn't be less than number of TCs.\n");
3261 if (!strncmp(res->pfc_en, "on", 2))
3266 /* DCB in VT mode */
3267 if (!strncmp(res->vt_en, "on", 2))
3268 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3269 (enum rte_eth_nb_tcs)res->num_tcs,
3272 ret = init_port_dcb_config(port_id, DCB_ENABLED,
3273 (enum rte_eth_nb_tcs)res->num_tcs,
3278 printf("Cannot initialize network ports.\n");
3282 cmd_reconfig_device_queue(port_id, 1, 1);
3285 cmdline_parse_token_string_t cmd_config_dcb_port =
3286 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3287 cmdline_parse_token_string_t cmd_config_dcb_config =
3288 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3289 cmdline_parse_token_num_t cmd_config_dcb_port_id =
3290 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16);
3291 cmdline_parse_token_string_t cmd_config_dcb_dcb =
3292 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3293 cmdline_parse_token_string_t cmd_config_dcb_vt =
3294 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3295 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3296 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3297 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3298 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
3299 cmdline_parse_token_string_t cmd_config_dcb_pfc=
3300 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3301 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
3302 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
3304 cmdline_parse_inst_t cmd_config_dcb = {
3305 .f = cmd_config_dcb_parsed,
3307 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
3309 (void *)&cmd_config_dcb_port,
3310 (void *)&cmd_config_dcb_config,
3311 (void *)&cmd_config_dcb_port_id,
3312 (void *)&cmd_config_dcb_dcb,
3313 (void *)&cmd_config_dcb_vt,
3314 (void *)&cmd_config_dcb_vt_en,
3315 (void *)&cmd_config_dcb_num_tcs,
3316 (void *)&cmd_config_dcb_pfc,
3317 (void *)&cmd_config_dcb_pfc_en,
3322 /* *** configure number of packets per burst *** */
3323 struct cmd_config_burst {
3324 cmdline_fixed_string_t port;
3325 cmdline_fixed_string_t keyword;
3326 cmdline_fixed_string_t all;
3327 cmdline_fixed_string_t name;
3332 cmd_config_burst_parsed(void *parsed_result,
3333 __rte_unused struct cmdline *cl,
3334 __rte_unused void *data)
3336 struct cmd_config_burst *res = parsed_result;
3337 struct rte_eth_dev_info dev_info;
3338 uint16_t rec_nb_pkts;
3341 if (!all_ports_stopped()) {
3342 printf("Please stop all ports first\n");
3346 if (!strcmp(res->name, "burst")) {
3347 if (res->value == 0) {
3348 /* If user gives a value of zero, query the PMD for
3349 * its recommended Rx burst size. Testpmd uses a single
3350 * size for all ports, so assume all ports are the same
3351 * NIC model and use the values from Port 0.
3353 ret = eth_dev_info_get_print_err(0, &dev_info);
3357 rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3359 if (rec_nb_pkts == 0) {
3360 printf("PMD does not recommend a burst size.\n"
3361 "User provided value must be between"
3362 " 1 and %d\n", MAX_PKT_BURST);
3364 } else if (rec_nb_pkts > MAX_PKT_BURST) {
3365 printf("PMD recommended burst size of %d"
3366 " exceeds maximum value of %d\n",
3367 rec_nb_pkts, MAX_PKT_BURST);
3370 printf("Using PMD-provided burst value of %d\n",
3372 nb_pkt_per_burst = rec_nb_pkts;
3373 } else if (res->value > MAX_PKT_BURST) {
3374 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
3377 nb_pkt_per_burst = res->value;
3379 printf("Unknown parameter\n");
3385 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3388 cmdline_parse_token_string_t cmd_config_burst_port =
3389 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3390 cmdline_parse_token_string_t cmd_config_burst_keyword =
3391 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3392 cmdline_parse_token_string_t cmd_config_burst_all =
3393 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3394 cmdline_parse_token_string_t cmd_config_burst_name =
3395 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3396 cmdline_parse_token_num_t cmd_config_burst_value =
3397 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
3399 cmdline_parse_inst_t cmd_config_burst = {
3400 .f = cmd_config_burst_parsed,
3402 .help_str = "port config all burst <value>",
3404 (void *)&cmd_config_burst_port,
3405 (void *)&cmd_config_burst_keyword,
3406 (void *)&cmd_config_burst_all,
3407 (void *)&cmd_config_burst_name,
3408 (void *)&cmd_config_burst_value,
3413 /* *** configure rx/tx queues *** */
3414 struct cmd_config_thresh {
3415 cmdline_fixed_string_t port;
3416 cmdline_fixed_string_t keyword;
3417 cmdline_fixed_string_t all;
3418 cmdline_fixed_string_t name;
3423 cmd_config_thresh_parsed(void *parsed_result,
3424 __rte_unused struct cmdline *cl,
3425 __rte_unused void *data)
3427 struct cmd_config_thresh *res = parsed_result;
3429 if (!all_ports_stopped()) {
3430 printf("Please stop all ports first\n");
3434 if (!strcmp(res->name, "txpt"))
3435 tx_pthresh = res->value;
3436 else if(!strcmp(res->name, "txht"))
3437 tx_hthresh = res->value;
3438 else if(!strcmp(res->name, "txwt"))
3439 tx_wthresh = res->value;
3440 else if(!strcmp(res->name, "rxpt"))
3441 rx_pthresh = res->value;
3442 else if(!strcmp(res->name, "rxht"))
3443 rx_hthresh = res->value;
3444 else if(!strcmp(res->name, "rxwt"))
3445 rx_wthresh = res->value;
3447 printf("Unknown parameter\n");
3453 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3456 cmdline_parse_token_string_t cmd_config_thresh_port =
3457 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3458 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3459 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3460 cmdline_parse_token_string_t cmd_config_thresh_all =
3461 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3462 cmdline_parse_token_string_t cmd_config_thresh_name =
3463 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3464 "txpt#txht#txwt#rxpt#rxht#rxwt");
3465 cmdline_parse_token_num_t cmd_config_thresh_value =
3466 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
3468 cmdline_parse_inst_t cmd_config_thresh = {
3469 .f = cmd_config_thresh_parsed,
3471 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3473 (void *)&cmd_config_thresh_port,
3474 (void *)&cmd_config_thresh_keyword,
3475 (void *)&cmd_config_thresh_all,
3476 (void *)&cmd_config_thresh_name,
3477 (void *)&cmd_config_thresh_value,
3482 /* *** configure free/rs threshold *** */
3483 struct cmd_config_threshold {
3484 cmdline_fixed_string_t port;
3485 cmdline_fixed_string_t keyword;
3486 cmdline_fixed_string_t all;
3487 cmdline_fixed_string_t name;
3492 cmd_config_threshold_parsed(void *parsed_result,
3493 __rte_unused struct cmdline *cl,
3494 __rte_unused void *data)
3496 struct cmd_config_threshold *res = parsed_result;
3498 if (!all_ports_stopped()) {
3499 printf("Please stop all ports first\n");
3503 if (!strcmp(res->name, "txfreet"))
3504 tx_free_thresh = res->value;
3505 else if (!strcmp(res->name, "txrst"))
3506 tx_rs_thresh = res->value;
3507 else if (!strcmp(res->name, "rxfreet"))
3508 rx_free_thresh = res->value;
3510 printf("Unknown parameter\n");
3516 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3519 cmdline_parse_token_string_t cmd_config_threshold_port =
3520 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3521 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3522 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3524 cmdline_parse_token_string_t cmd_config_threshold_all =
3525 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3526 cmdline_parse_token_string_t cmd_config_threshold_name =
3527 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3528 "txfreet#txrst#rxfreet");
3529 cmdline_parse_token_num_t cmd_config_threshold_value =
3530 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
3532 cmdline_parse_inst_t cmd_config_threshold = {
3533 .f = cmd_config_threshold_parsed,
3535 .help_str = "port config all txfreet|txrst|rxfreet <value>",
3537 (void *)&cmd_config_threshold_port,
3538 (void *)&cmd_config_threshold_keyword,
3539 (void *)&cmd_config_threshold_all,
3540 (void *)&cmd_config_threshold_name,
3541 (void *)&cmd_config_threshold_value,
3547 struct cmd_stop_result {
3548 cmdline_fixed_string_t stop;
3551 static void cmd_stop_parsed(__rte_unused void *parsed_result,
3552 __rte_unused struct cmdline *cl,
3553 __rte_unused void *data)
3555 stop_packet_forwarding();
3558 cmdline_parse_token_string_t cmd_stop_stop =
3559 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3561 cmdline_parse_inst_t cmd_stop = {
3562 .f = cmd_stop_parsed,
3564 .help_str = "stop: Stop packet forwarding",
3566 (void *)&cmd_stop_stop,
3571 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3574 parse_item_list(char* str, const char* item_name, unsigned int max_items,
3575 unsigned int *parsed_items, int check_unique_values)
3577 unsigned int nb_item;
3585 * First parse all items in the list and store their value.
3590 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3592 if ((c >= '0') && (c <= '9')) {
3593 value = (unsigned int) (value * 10 + (c - '0'));
3598 printf("character %c is not a decimal digit\n", c);
3602 printf("No valid value before comma\n");
3605 if (nb_item < max_items) {
3606 parsed_items[nb_item] = value;
3612 if (nb_item >= max_items) {
3613 printf("Number of %s = %u > %u (maximum items)\n",
3614 item_name, nb_item + 1, max_items);
3617 parsed_items[nb_item++] = value;
3618 if (! check_unique_values)
3622 * Then, check that all values in the list are differents.
3623 * No optimization here...
3625 for (i = 0; i < nb_item; i++) {
3626 for (j = i + 1; j < nb_item; j++) {
3627 if (parsed_items[j] == parsed_items[i]) {
3628 printf("duplicated %s %u at index %u and %u\n",
3629 item_name, parsed_items[i], i, j);
3637 struct cmd_set_list_result {
3638 cmdline_fixed_string_t cmd_keyword;
3639 cmdline_fixed_string_t list_name;
3640 cmdline_fixed_string_t list_of_items;
3643 static void cmd_set_list_parsed(void *parsed_result,
3644 __rte_unused struct cmdline *cl,
3645 __rte_unused void *data)
3647 struct cmd_set_list_result *res;
3649 unsigned int lcorelist[RTE_MAX_LCORE];
3650 unsigned int portlist[RTE_MAX_ETHPORTS];
3652 unsigned int nb_item;
3654 if (test_done == 0) {
3655 printf("Please stop forwarding first\n");
3659 res = parsed_result;
3660 if (!strcmp(res->list_name, "corelist")) {
3661 nb_item = parse_item_list(res->list_of_items, "core",
3663 parsed_items.lcorelist, 1);
3665 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3670 if (!strcmp(res->list_name, "portlist")) {
3671 nb_item = parse_item_list(res->list_of_items, "port",
3673 parsed_items.portlist, 1);
3675 set_fwd_ports_list(parsed_items.portlist, nb_item);
3681 cmdline_parse_token_string_t cmd_set_list_keyword =
3682 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3684 cmdline_parse_token_string_t cmd_set_list_name =
3685 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3686 "corelist#portlist");
3687 cmdline_parse_token_string_t cmd_set_list_of_items =
3688 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3691 cmdline_parse_inst_t cmd_set_fwd_list = {
3692 .f = cmd_set_list_parsed,
3694 .help_str = "set corelist|portlist <list0[,list1]*>",
3696 (void *)&cmd_set_list_keyword,
3697 (void *)&cmd_set_list_name,
3698 (void *)&cmd_set_list_of_items,
3703 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3705 struct cmd_setmask_result {
3706 cmdline_fixed_string_t set;
3707 cmdline_fixed_string_t mask;
3711 static void cmd_set_mask_parsed(void *parsed_result,
3712 __rte_unused struct cmdline *cl,
3713 __rte_unused void *data)
3715 struct cmd_setmask_result *res = parsed_result;
3717 if (test_done == 0) {
3718 printf("Please stop forwarding first\n");
3721 if (!strcmp(res->mask, "coremask")) {
3722 set_fwd_lcores_mask(res->hexavalue);
3724 } else if (!strcmp(res->mask, "portmask")) {
3725 set_fwd_ports_mask(res->hexavalue);
3730 cmdline_parse_token_string_t cmd_setmask_set =
3731 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3732 cmdline_parse_token_string_t cmd_setmask_mask =
3733 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3734 "coremask#portmask");
3735 cmdline_parse_token_num_t cmd_setmask_value =
3736 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
3738 cmdline_parse_inst_t cmd_set_fwd_mask = {
3739 .f = cmd_set_mask_parsed,
3741 .help_str = "set coremask|portmask <hexadecimal value>",
3743 (void *)&cmd_setmask_set,
3744 (void *)&cmd_setmask_mask,
3745 (void *)&cmd_setmask_value,
3751 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3753 struct cmd_set_result {
3754 cmdline_fixed_string_t set;
3755 cmdline_fixed_string_t what;
3759 static void cmd_set_parsed(void *parsed_result,
3760 __rte_unused struct cmdline *cl,
3761 __rte_unused void *data)
3763 struct cmd_set_result *res = parsed_result;
3764 if (!strcmp(res->what, "nbport")) {
3765 set_fwd_ports_number(res->value);
3767 } else if (!strcmp(res->what, "nbcore")) {
3768 set_fwd_lcores_number(res->value);
3770 } else if (!strcmp(res->what, "burst"))
3771 set_nb_pkt_per_burst(res->value);
3772 else if (!strcmp(res->what, "verbose"))
3773 set_verbose_level(res->value);
3776 cmdline_parse_token_string_t cmd_set_set =
3777 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3778 cmdline_parse_token_string_t cmd_set_what =
3779 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3780 "nbport#nbcore#burst#verbose");
3781 cmdline_parse_token_num_t cmd_set_value =
3782 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
3784 cmdline_parse_inst_t cmd_set_numbers = {
3785 .f = cmd_set_parsed,
3787 .help_str = "set nbport|nbcore|burst|verbose <value>",
3789 (void *)&cmd_set_set,
3790 (void *)&cmd_set_what,
3791 (void *)&cmd_set_value,
3796 /* *** SET LOG LEVEL CONFIGURATION *** */
3798 struct cmd_set_log_result {
3799 cmdline_fixed_string_t set;
3800 cmdline_fixed_string_t log;
3801 cmdline_fixed_string_t type;
3806 cmd_set_log_parsed(void *parsed_result,
3807 __rte_unused struct cmdline *cl,
3808 __rte_unused void *data)
3810 struct cmd_set_log_result *res;
3813 res = parsed_result;
3814 if (!strcmp(res->type, "global"))
3815 rte_log_set_global_level(res->level);
3817 ret = rte_log_set_level_regexp(res->type, res->level);
3819 printf("Unable to set log level\n");
3823 cmdline_parse_token_string_t cmd_set_log_set =
3824 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3825 cmdline_parse_token_string_t cmd_set_log_log =
3826 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3827 cmdline_parse_token_string_t cmd_set_log_type =
3828 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3829 cmdline_parse_token_num_t cmd_set_log_level =
3830 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, UINT32);
3832 cmdline_parse_inst_t cmd_set_log = {
3833 .f = cmd_set_log_parsed,
3835 .help_str = "set log global|<type> <level>",
3837 (void *)&cmd_set_log_set,
3838 (void *)&cmd_set_log_log,
3839 (void *)&cmd_set_log_type,
3840 (void *)&cmd_set_log_level,
3845 /* *** SET SEGMENT OFFSETS OF RX PACKETS SPLIT *** */
3847 struct cmd_set_rxoffs_result {
3848 cmdline_fixed_string_t cmd_keyword;
3849 cmdline_fixed_string_t rxoffs;
3850 cmdline_fixed_string_t seg_offsets;
3854 cmd_set_rxoffs_parsed(void *parsed_result,
3855 __rte_unused struct cmdline *cl,
3856 __rte_unused void *data)
3858 struct cmd_set_rxoffs_result *res;
3859 unsigned int seg_offsets[MAX_SEGS_BUFFER_SPLIT];
3860 unsigned int nb_segs;
3862 res = parsed_result;
3863 nb_segs = parse_item_list(res->seg_offsets, "segment offsets",
3864 MAX_SEGS_BUFFER_SPLIT, seg_offsets, 0);
3866 set_rx_pkt_offsets(seg_offsets, nb_segs);
3869 cmdline_parse_token_string_t cmd_set_rxoffs_keyword =
3870 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3871 cmd_keyword, "set");
3872 cmdline_parse_token_string_t cmd_set_rxoffs_name =
3873 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3875 cmdline_parse_token_string_t cmd_set_rxoffs_offsets =
3876 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3879 cmdline_parse_inst_t cmd_set_rxoffs = {
3880 .f = cmd_set_rxoffs_parsed,
3882 .help_str = "set rxoffs <len0[,len1]*>",
3884 (void *)&cmd_set_rxoffs_keyword,
3885 (void *)&cmd_set_rxoffs_name,
3886 (void *)&cmd_set_rxoffs_offsets,
3891 /* *** SET SEGMENT LENGTHS OF RX PACKETS SPLIT *** */
3893 struct cmd_set_rxpkts_result {
3894 cmdline_fixed_string_t cmd_keyword;
3895 cmdline_fixed_string_t rxpkts;
3896 cmdline_fixed_string_t seg_lengths;
3900 cmd_set_rxpkts_parsed(void *parsed_result,
3901 __rte_unused struct cmdline *cl,
3902 __rte_unused void *data)
3904 struct cmd_set_rxpkts_result *res;
3905 unsigned int seg_lengths[MAX_SEGS_BUFFER_SPLIT];
3906 unsigned int nb_segs;
3908 res = parsed_result;
3909 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3910 MAX_SEGS_BUFFER_SPLIT, seg_lengths, 0);
3912 set_rx_pkt_segments(seg_lengths, nb_segs);
3915 cmdline_parse_token_string_t cmd_set_rxpkts_keyword =
3916 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3917 cmd_keyword, "set");
3918 cmdline_parse_token_string_t cmd_set_rxpkts_name =
3919 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3921 cmdline_parse_token_string_t cmd_set_rxpkts_lengths =
3922 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3925 cmdline_parse_inst_t cmd_set_rxpkts = {
3926 .f = cmd_set_rxpkts_parsed,
3928 .help_str = "set rxpkts <len0[,len1]*>",
3930 (void *)&cmd_set_rxpkts_keyword,
3931 (void *)&cmd_set_rxpkts_name,
3932 (void *)&cmd_set_rxpkts_lengths,
3937 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3939 struct cmd_set_txpkts_result {
3940 cmdline_fixed_string_t cmd_keyword;
3941 cmdline_fixed_string_t txpkts;
3942 cmdline_fixed_string_t seg_lengths;
3946 cmd_set_txpkts_parsed(void *parsed_result,
3947 __rte_unused struct cmdline *cl,
3948 __rte_unused void *data)
3950 struct cmd_set_txpkts_result *res;
3951 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3952 unsigned int nb_segs;
3954 res = parsed_result;
3955 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3956 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3958 set_tx_pkt_segments(seg_lengths, nb_segs);
3961 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3962 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3963 cmd_keyword, "set");
3964 cmdline_parse_token_string_t cmd_set_txpkts_name =
3965 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3967 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3968 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3971 cmdline_parse_inst_t cmd_set_txpkts = {
3972 .f = cmd_set_txpkts_parsed,
3974 .help_str = "set txpkts <len0[,len1]*>",
3976 (void *)&cmd_set_txpkts_keyword,
3977 (void *)&cmd_set_txpkts_name,
3978 (void *)&cmd_set_txpkts_lengths,
3983 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
3985 struct cmd_set_txsplit_result {
3986 cmdline_fixed_string_t cmd_keyword;
3987 cmdline_fixed_string_t txsplit;
3988 cmdline_fixed_string_t mode;
3992 cmd_set_txsplit_parsed(void *parsed_result,
3993 __rte_unused struct cmdline *cl,
3994 __rte_unused void *data)
3996 struct cmd_set_txsplit_result *res;
3998 res = parsed_result;
3999 set_tx_pkt_split(res->mode);
4002 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
4003 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4004 cmd_keyword, "set");
4005 cmdline_parse_token_string_t cmd_set_txsplit_name =
4006 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4007 txsplit, "txsplit");
4008 cmdline_parse_token_string_t cmd_set_txsplit_mode =
4009 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4012 cmdline_parse_inst_t cmd_set_txsplit = {
4013 .f = cmd_set_txsplit_parsed,
4015 .help_str = "set txsplit on|off|rand",
4017 (void *)&cmd_set_txsplit_keyword,
4018 (void *)&cmd_set_txsplit_name,
4019 (void *)&cmd_set_txsplit_mode,
4024 /* *** SET TIMES FOR TXONLY PACKETS SCHEDULING ON TIMESTAMPS *** */
4026 struct cmd_set_txtimes_result {
4027 cmdline_fixed_string_t cmd_keyword;
4028 cmdline_fixed_string_t txtimes;
4029 cmdline_fixed_string_t tx_times;
4033 cmd_set_txtimes_parsed(void *parsed_result,
4034 __rte_unused struct cmdline *cl,
4035 __rte_unused void *data)
4037 struct cmd_set_txtimes_result *res;
4038 unsigned int tx_times[2] = {0, 0};
4039 unsigned int n_times;
4041 res = parsed_result;
4042 n_times = parse_item_list(res->tx_times, "tx times",
4045 set_tx_pkt_times(tx_times);
4048 cmdline_parse_token_string_t cmd_set_txtimes_keyword =
4049 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4050 cmd_keyword, "set");
4051 cmdline_parse_token_string_t cmd_set_txtimes_name =
4052 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4053 txtimes, "txtimes");
4054 cmdline_parse_token_string_t cmd_set_txtimes_value =
4055 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4058 cmdline_parse_inst_t cmd_set_txtimes = {
4059 .f = cmd_set_txtimes_parsed,
4061 .help_str = "set txtimes <inter_burst>,<intra_burst>",
4063 (void *)&cmd_set_txtimes_keyword,
4064 (void *)&cmd_set_txtimes_name,
4065 (void *)&cmd_set_txtimes_value,
4070 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
4071 struct cmd_rx_vlan_filter_all_result {
4072 cmdline_fixed_string_t rx_vlan;
4073 cmdline_fixed_string_t what;
4074 cmdline_fixed_string_t all;
4079 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
4080 __rte_unused struct cmdline *cl,
4081 __rte_unused void *data)
4083 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
4085 if (!strcmp(res->what, "add"))
4086 rx_vlan_all_filter_set(res->port_id, 1);
4088 rx_vlan_all_filter_set(res->port_id, 0);
4091 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
4092 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4093 rx_vlan, "rx_vlan");
4094 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
4095 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4097 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
4098 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4100 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
4101 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4104 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
4105 .f = cmd_rx_vlan_filter_all_parsed,
4107 .help_str = "rx_vlan add|rm all <port_id>: "
4108 "Add/Remove all identifiers to/from the set of VLAN "
4109 "identifiers filtered by a port",
4111 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
4112 (void *)&cmd_rx_vlan_filter_all_what,
4113 (void *)&cmd_rx_vlan_filter_all_all,
4114 (void *)&cmd_rx_vlan_filter_all_portid,
4119 /* *** VLAN OFFLOAD SET ON A PORT *** */
4120 struct cmd_vlan_offload_result {
4121 cmdline_fixed_string_t vlan;
4122 cmdline_fixed_string_t set;
4123 cmdline_fixed_string_t vlan_type;
4124 cmdline_fixed_string_t what;
4125 cmdline_fixed_string_t on;
4126 cmdline_fixed_string_t port_id;
4130 cmd_vlan_offload_parsed(void *parsed_result,
4131 __rte_unused struct cmdline *cl,
4132 __rte_unused void *data)
4135 struct cmd_vlan_offload_result *res = parsed_result;
4138 portid_t port_id = 0;
4142 len = strnlen(str, STR_TOKEN_SIZE);
4144 /* Get port_id first */
4152 tmp = strtoul(str, NULL, 0);
4153 /* If port_id greater that what portid_t can represent, return */
4154 if(tmp >= RTE_MAX_ETHPORTS)
4156 port_id = (portid_t)tmp;
4158 if (!strcmp(res->on, "on"))
4163 if (!strcmp(res->what, "strip"))
4164 rx_vlan_strip_set(port_id, on);
4165 else if(!strcmp(res->what, "stripq")){
4166 uint16_t queue_id = 0;
4168 /* No queue_id, return */
4170 printf("must specify (port,queue_id)\n");
4173 tmp = strtoul(str + i + 1, NULL, 0);
4174 /* If queue_id greater that what 16-bits can represent, return */
4178 queue_id = (uint16_t)tmp;
4179 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
4181 else if (!strcmp(res->what, "filter"))
4182 rx_vlan_filter_set(port_id, on);
4183 else if (!strcmp(res->what, "qinq_strip"))
4184 rx_vlan_qinq_strip_set(port_id, on);
4186 vlan_extend_set(port_id, on);
4191 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
4192 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4194 cmdline_parse_token_string_t cmd_vlan_offload_set =
4195 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4197 cmdline_parse_token_string_t cmd_vlan_offload_what =
4198 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4199 what, "strip#filter#qinq_strip#extend#stripq");
4200 cmdline_parse_token_string_t cmd_vlan_offload_on =
4201 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4203 cmdline_parse_token_string_t cmd_vlan_offload_portid =
4204 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4207 cmdline_parse_inst_t cmd_vlan_offload = {
4208 .f = cmd_vlan_offload_parsed,
4210 .help_str = "vlan set strip|filter|qinq_strip|extend|stripq on|off "
4211 "<port_id[,queue_id]>: "
4212 "Strip/Filter/QinQ for rx side Extend for both rx/tx sides",
4214 (void *)&cmd_vlan_offload_vlan,
4215 (void *)&cmd_vlan_offload_set,
4216 (void *)&cmd_vlan_offload_what,
4217 (void *)&cmd_vlan_offload_on,
4218 (void *)&cmd_vlan_offload_portid,
4223 /* *** VLAN TPID SET ON A PORT *** */
4224 struct cmd_vlan_tpid_result {
4225 cmdline_fixed_string_t vlan;
4226 cmdline_fixed_string_t set;
4227 cmdline_fixed_string_t vlan_type;
4228 cmdline_fixed_string_t what;
4234 cmd_vlan_tpid_parsed(void *parsed_result,
4235 __rte_unused struct cmdline *cl,
4236 __rte_unused void *data)
4238 struct cmd_vlan_tpid_result *res = parsed_result;
4239 enum rte_vlan_type vlan_type;
4241 if (!strcmp(res->vlan_type, "inner"))
4242 vlan_type = ETH_VLAN_TYPE_INNER;
4243 else if (!strcmp(res->vlan_type, "outer"))
4244 vlan_type = ETH_VLAN_TYPE_OUTER;
4246 printf("Unknown vlan type\n");
4249 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
4252 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
4253 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4255 cmdline_parse_token_string_t cmd_vlan_tpid_set =
4256 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4258 cmdline_parse_token_string_t cmd_vlan_type =
4259 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4260 vlan_type, "inner#outer");
4261 cmdline_parse_token_string_t cmd_vlan_tpid_what =
4262 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4264 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
4265 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4267 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
4268 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4271 cmdline_parse_inst_t cmd_vlan_tpid = {
4272 .f = cmd_vlan_tpid_parsed,
4274 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
4275 "Set the VLAN Ether type",
4277 (void *)&cmd_vlan_tpid_vlan,
4278 (void *)&cmd_vlan_tpid_set,
4279 (void *)&cmd_vlan_type,
4280 (void *)&cmd_vlan_tpid_what,
4281 (void *)&cmd_vlan_tpid_tpid,
4282 (void *)&cmd_vlan_tpid_portid,
4287 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4288 struct cmd_rx_vlan_filter_result {
4289 cmdline_fixed_string_t rx_vlan;
4290 cmdline_fixed_string_t what;
4296 cmd_rx_vlan_filter_parsed(void *parsed_result,
4297 __rte_unused struct cmdline *cl,
4298 __rte_unused void *data)
4300 struct cmd_rx_vlan_filter_result *res = parsed_result;
4302 if (!strcmp(res->what, "add"))
4303 rx_vft_set(res->port_id, res->vlan_id, 1);
4305 rx_vft_set(res->port_id, res->vlan_id, 0);
4308 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
4309 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4310 rx_vlan, "rx_vlan");
4311 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
4312 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4314 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
4315 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4317 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
4318 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4321 cmdline_parse_inst_t cmd_rx_vlan_filter = {
4322 .f = cmd_rx_vlan_filter_parsed,
4324 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
4325 "Add/Remove a VLAN identifier to/from the set of VLAN "
4326 "identifiers filtered by a port",
4328 (void *)&cmd_rx_vlan_filter_rx_vlan,
4329 (void *)&cmd_rx_vlan_filter_what,
4330 (void *)&cmd_rx_vlan_filter_vlanid,
4331 (void *)&cmd_rx_vlan_filter_portid,
4336 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4337 struct cmd_tx_vlan_set_result {
4338 cmdline_fixed_string_t tx_vlan;
4339 cmdline_fixed_string_t set;
4345 cmd_tx_vlan_set_parsed(void *parsed_result,
4346 __rte_unused struct cmdline *cl,
4347 __rte_unused void *data)
4349 struct cmd_tx_vlan_set_result *res = parsed_result;
4351 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4354 if (!port_is_stopped(res->port_id)) {
4355 printf("Please stop port %d first\n", res->port_id);
4359 tx_vlan_set(res->port_id, res->vlan_id);
4361 cmd_reconfig_device_queue(res->port_id, 1, 1);
4364 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4365 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4366 tx_vlan, "tx_vlan");
4367 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4368 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4370 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4371 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4373 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
4374 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4377 cmdline_parse_inst_t cmd_tx_vlan_set = {
4378 .f = cmd_tx_vlan_set_parsed,
4380 .help_str = "tx_vlan set <port_id> <vlan_id>: "
4381 "Enable hardware insertion of a single VLAN header "
4382 "with a given TAG Identifier in packets sent on a port",
4384 (void *)&cmd_tx_vlan_set_tx_vlan,
4385 (void *)&cmd_tx_vlan_set_set,
4386 (void *)&cmd_tx_vlan_set_portid,
4387 (void *)&cmd_tx_vlan_set_vlanid,
4392 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4393 struct cmd_tx_vlan_set_qinq_result {
4394 cmdline_fixed_string_t tx_vlan;
4395 cmdline_fixed_string_t set;
4398 uint16_t vlan_id_outer;
4402 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4403 __rte_unused struct cmdline *cl,
4404 __rte_unused void *data)
4406 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
4408 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4411 if (!port_is_stopped(res->port_id)) {
4412 printf("Please stop port %d first\n", res->port_id);
4416 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
4418 cmd_reconfig_device_queue(res->port_id, 1, 1);
4421 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
4422 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4423 tx_vlan, "tx_vlan");
4424 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
4425 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4427 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
4428 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4430 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
4431 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4433 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
4434 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4435 vlan_id_outer, UINT16);
4437 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
4438 .f = cmd_tx_vlan_set_qinq_parsed,
4440 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
4441 "Enable hardware insertion of double VLAN header "
4442 "with given TAG Identifiers in packets sent on a port",
4444 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
4445 (void *)&cmd_tx_vlan_set_qinq_set,
4446 (void *)&cmd_tx_vlan_set_qinq_portid,
4447 (void *)&cmd_tx_vlan_set_qinq_vlanid,
4448 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
4453 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
4454 struct cmd_tx_vlan_set_pvid_result {
4455 cmdline_fixed_string_t tx_vlan;
4456 cmdline_fixed_string_t set;
4457 cmdline_fixed_string_t pvid;
4460 cmdline_fixed_string_t mode;
4464 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
4465 __rte_unused struct cmdline *cl,
4466 __rte_unused void *data)
4468 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
4470 if (strcmp(res->mode, "on") == 0)
4471 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
4473 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
4476 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
4477 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4478 tx_vlan, "tx_vlan");
4479 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
4480 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4482 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
4483 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4485 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
4486 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4488 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
4489 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4491 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
4492 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4495 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
4496 .f = cmd_tx_vlan_set_pvid_parsed,
4498 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
4500 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
4501 (void *)&cmd_tx_vlan_set_pvid_set,
4502 (void *)&cmd_tx_vlan_set_pvid_pvid,
4503 (void *)&cmd_tx_vlan_set_pvid_port_id,
4504 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
4505 (void *)&cmd_tx_vlan_set_pvid_mode,
4510 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4511 struct cmd_tx_vlan_reset_result {
4512 cmdline_fixed_string_t tx_vlan;
4513 cmdline_fixed_string_t reset;
4518 cmd_tx_vlan_reset_parsed(void *parsed_result,
4519 __rte_unused struct cmdline *cl,
4520 __rte_unused void *data)
4522 struct cmd_tx_vlan_reset_result *res = parsed_result;
4524 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4527 if (!port_is_stopped(res->port_id)) {
4528 printf("Please stop port %d first\n", res->port_id);
4532 tx_vlan_reset(res->port_id);
4534 cmd_reconfig_device_queue(res->port_id, 1, 1);
4537 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4538 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4539 tx_vlan, "tx_vlan");
4540 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4541 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4543 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4544 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4547 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4548 .f = cmd_tx_vlan_reset_parsed,
4550 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4551 "VLAN header in packets sent on a port",
4553 (void *)&cmd_tx_vlan_reset_tx_vlan,
4554 (void *)&cmd_tx_vlan_reset_reset,
4555 (void *)&cmd_tx_vlan_reset_portid,
4561 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4562 struct cmd_csum_result {
4563 cmdline_fixed_string_t csum;
4564 cmdline_fixed_string_t mode;
4565 cmdline_fixed_string_t proto;
4566 cmdline_fixed_string_t hwsw;
4571 csum_show(int port_id)
4573 struct rte_eth_dev_info dev_info;
4574 uint64_t tx_offloads;
4577 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4578 printf("Parse tunnel is %s\n",
4579 (ports[port_id].parse_tunnel) ? "on" : "off");
4580 printf("IP checksum offload is %s\n",
4581 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4582 printf("UDP checksum offload is %s\n",
4583 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4584 printf("TCP checksum offload is %s\n",
4585 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4586 printf("SCTP checksum offload is %s\n",
4587 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4588 printf("Outer-Ip checksum offload is %s\n",
4589 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4590 printf("Outer-Udp checksum offload is %s\n",
4591 (tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
4593 /* display warnings if configuration is not supported by the NIC */
4594 ret = eth_dev_info_get_print_err(port_id, &dev_info);
4598 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
4599 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4600 printf("Warning: hardware IP checksum enabled but not "
4601 "supported by port %d\n", port_id);
4603 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
4604 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
4605 printf("Warning: hardware UDP checksum enabled but not "
4606 "supported by port %d\n", port_id);
4608 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
4609 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
4610 printf("Warning: hardware TCP checksum enabled but not "
4611 "supported by port %d\n", port_id);
4613 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
4614 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4615 printf("Warning: hardware SCTP checksum enabled but not "
4616 "supported by port %d\n", port_id);
4618 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4619 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4620 printf("Warning: hardware outer IP checksum enabled but not "
4621 "supported by port %d\n", port_id);
4623 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
4624 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)
4626 printf("Warning: hardware outer UDP checksum enabled but not "
4627 "supported by port %d\n", port_id);
4632 cmd_config_queue_tx_offloads(struct rte_port *port)
4636 /* Apply queue tx offloads configuration */
4637 for (k = 0; k < port->dev_info.max_rx_queues; k++)
4638 port->tx_conf[k].offloads =
4639 port->dev_conf.txmode.offloads;
4643 cmd_csum_parsed(void *parsed_result,
4644 __rte_unused struct cmdline *cl,
4645 __rte_unused void *data)
4647 struct cmd_csum_result *res = parsed_result;
4649 uint64_t csum_offloads = 0;
4650 struct rte_eth_dev_info dev_info;
4653 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4654 printf("invalid port %d\n", res->port_id);
4657 if (!port_is_stopped(res->port_id)) {
4658 printf("Please stop port %d first\n", res->port_id);
4662 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4666 if (!strcmp(res->mode, "set")) {
4668 if (!strcmp(res->hwsw, "hw"))
4671 if (!strcmp(res->proto, "ip")) {
4672 if (hw == 0 || (dev_info.tx_offload_capa &
4673 DEV_TX_OFFLOAD_IPV4_CKSUM)) {
4674 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
4676 printf("IP checksum offload is not supported "
4677 "by port %u\n", res->port_id);
4679 } else if (!strcmp(res->proto, "udp")) {
4680 if (hw == 0 || (dev_info.tx_offload_capa &
4681 DEV_TX_OFFLOAD_UDP_CKSUM)) {
4682 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
4684 printf("UDP checksum offload is not supported "
4685 "by port %u\n", res->port_id);
4687 } else if (!strcmp(res->proto, "tcp")) {
4688 if (hw == 0 || (dev_info.tx_offload_capa &
4689 DEV_TX_OFFLOAD_TCP_CKSUM)) {
4690 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
4692 printf("TCP checksum offload is not supported "
4693 "by port %u\n", res->port_id);
4695 } else if (!strcmp(res->proto, "sctp")) {
4696 if (hw == 0 || (dev_info.tx_offload_capa &
4697 DEV_TX_OFFLOAD_SCTP_CKSUM)) {
4698 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
4700 printf("SCTP checksum offload is not supported "
4701 "by port %u\n", res->port_id);
4703 } else if (!strcmp(res->proto, "outer-ip")) {
4704 if (hw == 0 || (dev_info.tx_offload_capa &
4705 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4707 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4709 printf("Outer IP checksum offload is not "
4710 "supported by port %u\n", res->port_id);
4712 } else if (!strcmp(res->proto, "outer-udp")) {
4713 if (hw == 0 || (dev_info.tx_offload_capa &
4714 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
4716 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM;
4718 printf("Outer UDP checksum offload is not "
4719 "supported by port %u\n", res->port_id);
4724 ports[res->port_id].dev_conf.txmode.offloads |=
4727 ports[res->port_id].dev_conf.txmode.offloads &=
4730 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4732 csum_show(res->port_id);
4734 cmd_reconfig_device_queue(res->port_id, 1, 1);
4737 cmdline_parse_token_string_t cmd_csum_csum =
4738 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4740 cmdline_parse_token_string_t cmd_csum_mode =
4741 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4743 cmdline_parse_token_string_t cmd_csum_proto =
4744 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4745 proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
4746 cmdline_parse_token_string_t cmd_csum_hwsw =
4747 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4749 cmdline_parse_token_num_t cmd_csum_portid =
4750 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4753 cmdline_parse_inst_t cmd_csum_set = {
4754 .f = cmd_csum_parsed,
4756 .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
4757 "Enable/Disable hardware calculation of L3/L4 checksum when "
4758 "using csum forward engine",
4760 (void *)&cmd_csum_csum,
4761 (void *)&cmd_csum_mode,
4762 (void *)&cmd_csum_proto,
4763 (void *)&cmd_csum_hwsw,
4764 (void *)&cmd_csum_portid,
4769 cmdline_parse_token_string_t cmd_csum_mode_show =
4770 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4773 cmdline_parse_inst_t cmd_csum_show = {
4774 .f = cmd_csum_parsed,
4776 .help_str = "csum show <port_id>: Show checksum offload configuration",
4778 (void *)&cmd_csum_csum,
4779 (void *)&cmd_csum_mode_show,
4780 (void *)&cmd_csum_portid,
4785 /* Enable/disable tunnel parsing */
4786 struct cmd_csum_tunnel_result {
4787 cmdline_fixed_string_t csum;
4788 cmdline_fixed_string_t parse;
4789 cmdline_fixed_string_t onoff;
4794 cmd_csum_tunnel_parsed(void *parsed_result,
4795 __rte_unused struct cmdline *cl,
4796 __rte_unused void *data)
4798 struct cmd_csum_tunnel_result *res = parsed_result;
4800 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4803 if (!strcmp(res->onoff, "on"))
4804 ports[res->port_id].parse_tunnel = 1;
4806 ports[res->port_id].parse_tunnel = 0;
4808 csum_show(res->port_id);
4811 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4812 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4814 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4815 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4816 parse, "parse-tunnel");
4817 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4818 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4820 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4821 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4824 cmdline_parse_inst_t cmd_csum_tunnel = {
4825 .f = cmd_csum_tunnel_parsed,
4827 .help_str = "csum parse-tunnel on|off <port_id>: "
4828 "Enable/Disable parsing of tunnels for csum engine",
4830 (void *)&cmd_csum_tunnel_csum,
4831 (void *)&cmd_csum_tunnel_parse,
4832 (void *)&cmd_csum_tunnel_onoff,
4833 (void *)&cmd_csum_tunnel_portid,
4838 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4839 struct cmd_tso_set_result {
4840 cmdline_fixed_string_t tso;
4841 cmdline_fixed_string_t mode;
4847 cmd_tso_set_parsed(void *parsed_result,
4848 __rte_unused struct cmdline *cl,
4849 __rte_unused void *data)
4851 struct cmd_tso_set_result *res = parsed_result;
4852 struct rte_eth_dev_info dev_info;
4855 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4857 if (!port_is_stopped(res->port_id)) {
4858 printf("Please stop port %d first\n", res->port_id);
4862 if (!strcmp(res->mode, "set"))
4863 ports[res->port_id].tso_segsz = res->tso_segsz;
4865 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4869 if ((ports[res->port_id].tso_segsz != 0) &&
4870 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4871 printf("Error: TSO is not supported by port %d\n",
4876 if (ports[res->port_id].tso_segsz == 0) {
4877 ports[res->port_id].dev_conf.txmode.offloads &=
4878 ~DEV_TX_OFFLOAD_TCP_TSO;
4879 printf("TSO for non-tunneled packets is disabled\n");
4881 ports[res->port_id].dev_conf.txmode.offloads |=
4882 DEV_TX_OFFLOAD_TCP_TSO;
4883 printf("TSO segment size for non-tunneled packets is %d\n",
4884 ports[res->port_id].tso_segsz);
4886 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4888 /* display warnings if configuration is not supported by the NIC */
4889 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4893 if ((ports[res->port_id].tso_segsz != 0) &&
4894 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4895 printf("Warning: TSO enabled but not "
4896 "supported by port %d\n", res->port_id);
4899 cmd_reconfig_device_queue(res->port_id, 1, 1);
4902 cmdline_parse_token_string_t cmd_tso_set_tso =
4903 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4905 cmdline_parse_token_string_t cmd_tso_set_mode =
4906 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4908 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4909 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4911 cmdline_parse_token_num_t cmd_tso_set_portid =
4912 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4915 cmdline_parse_inst_t cmd_tso_set = {
4916 .f = cmd_tso_set_parsed,
4918 .help_str = "tso set <tso_segsz> <port_id>: "
4919 "Set TSO segment size of non-tunneled packets for csum engine "
4922 (void *)&cmd_tso_set_tso,
4923 (void *)&cmd_tso_set_mode,
4924 (void *)&cmd_tso_set_tso_segsz,
4925 (void *)&cmd_tso_set_portid,
4930 cmdline_parse_token_string_t cmd_tso_show_mode =
4931 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4935 cmdline_parse_inst_t cmd_tso_show = {
4936 .f = cmd_tso_set_parsed,
4938 .help_str = "tso show <port_id>: "
4939 "Show TSO segment size of non-tunneled packets for csum engine",
4941 (void *)&cmd_tso_set_tso,
4942 (void *)&cmd_tso_show_mode,
4943 (void *)&cmd_tso_set_portid,
4948 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
4949 struct cmd_tunnel_tso_set_result {
4950 cmdline_fixed_string_t tso;
4951 cmdline_fixed_string_t mode;
4956 static struct rte_eth_dev_info
4957 check_tunnel_tso_nic_support(portid_t port_id)
4959 struct rte_eth_dev_info dev_info;
4961 if (eth_dev_info_get_print_err(port_id, &dev_info) != 0)
4964 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
4965 printf("Warning: VXLAN TUNNEL TSO not supported therefore "
4966 "not enabled for port %d\n", port_id);
4967 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
4968 printf("Warning: GRE TUNNEL TSO not supported therefore "
4969 "not enabled for port %d\n", port_id);
4970 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
4971 printf("Warning: IPIP TUNNEL TSO not supported therefore "
4972 "not enabled for port %d\n", port_id);
4973 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
4974 printf("Warning: GENEVE TUNNEL TSO not supported therefore "
4975 "not enabled for port %d\n", port_id);
4976 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
4977 printf("Warning: IP TUNNEL TSO not supported therefore "
4978 "not enabled for port %d\n", port_id);
4979 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
4980 printf("Warning: UDP TUNNEL TSO not supported therefore "
4981 "not enabled for port %d\n", port_id);
4986 cmd_tunnel_tso_set_parsed(void *parsed_result,
4987 __rte_unused struct cmdline *cl,
4988 __rte_unused void *data)
4990 struct cmd_tunnel_tso_set_result *res = parsed_result;
4991 struct rte_eth_dev_info dev_info;
4993 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4995 if (!port_is_stopped(res->port_id)) {
4996 printf("Please stop port %d first\n", res->port_id);
5000 if (!strcmp(res->mode, "set"))
5001 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
5003 dev_info = check_tunnel_tso_nic_support(res->port_id);
5004 if (ports[res->port_id].tunnel_tso_segsz == 0) {
5005 ports[res->port_id].dev_conf.txmode.offloads &=
5006 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
5007 DEV_TX_OFFLOAD_GRE_TNL_TSO |
5008 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
5009 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
5010 DEV_TX_OFFLOAD_IP_TNL_TSO |
5011 DEV_TX_OFFLOAD_UDP_TNL_TSO);
5012 printf("TSO for tunneled packets is disabled\n");
5014 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
5015 DEV_TX_OFFLOAD_GRE_TNL_TSO |
5016 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
5017 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
5018 DEV_TX_OFFLOAD_IP_TNL_TSO |
5019 DEV_TX_OFFLOAD_UDP_TNL_TSO);
5021 ports[res->port_id].dev_conf.txmode.offloads |=
5022 (tso_offloads & dev_info.tx_offload_capa);
5023 printf("TSO segment size for tunneled packets is %d\n",
5024 ports[res->port_id].tunnel_tso_segsz);
5026 /* Below conditions are needed to make it work:
5027 * (1) tunnel TSO is supported by the NIC;
5028 * (2) "csum parse_tunnel" must be set so that tunneled pkts
5030 * (3) for tunneled pkts with outer L3 of IPv4,
5031 * "csum set outer-ip" must be set to hw, because after tso,
5032 * total_len of outer IP header is changed, and the checksum
5033 * of outer IP header calculated by sw should be wrong; that
5034 * is not necessary for IPv6 tunneled pkts because there's no
5035 * checksum in IP header anymore.
5038 if (!ports[res->port_id].parse_tunnel)
5039 printf("Warning: csum parse_tunnel must be set "
5040 "so that tunneled packets are recognized\n");
5041 if (!(ports[res->port_id].dev_conf.txmode.offloads &
5042 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
5043 printf("Warning: csum set outer-ip must be set to hw "
5044 "if outer L3 is IPv4; not necessary for IPv6\n");
5047 cmd_config_queue_tx_offloads(&ports[res->port_id]);
5048 cmd_reconfig_device_queue(res->port_id, 1, 1);
5051 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
5052 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5054 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
5055 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5057 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
5058 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5060 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
5061 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5064 cmdline_parse_inst_t cmd_tunnel_tso_set = {
5065 .f = cmd_tunnel_tso_set_parsed,
5067 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
5068 "Set TSO segment size of tunneled packets for csum engine "
5071 (void *)&cmd_tunnel_tso_set_tso,
5072 (void *)&cmd_tunnel_tso_set_mode,
5073 (void *)&cmd_tunnel_tso_set_tso_segsz,
5074 (void *)&cmd_tunnel_tso_set_portid,
5079 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
5080 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5084 cmdline_parse_inst_t cmd_tunnel_tso_show = {
5085 .f = cmd_tunnel_tso_set_parsed,
5087 .help_str = "tunnel_tso show <port_id> "
5088 "Show TSO segment size of tunneled packets for csum engine",
5090 (void *)&cmd_tunnel_tso_set_tso,
5091 (void *)&cmd_tunnel_tso_show_mode,
5092 (void *)&cmd_tunnel_tso_set_portid,
5097 /* *** SET GRO FOR A PORT *** */
5098 struct cmd_gro_enable_result {
5099 cmdline_fixed_string_t cmd_set;
5100 cmdline_fixed_string_t cmd_port;
5101 cmdline_fixed_string_t cmd_keyword;
5102 cmdline_fixed_string_t cmd_onoff;
5107 cmd_gro_enable_parsed(void *parsed_result,
5108 __rte_unused struct cmdline *cl,
5109 __rte_unused void *data)
5111 struct cmd_gro_enable_result *res;
5113 res = parsed_result;
5114 if (!strcmp(res->cmd_keyword, "gro"))
5115 setup_gro(res->cmd_onoff, res->cmd_pid);
5118 cmdline_parse_token_string_t cmd_gro_enable_set =
5119 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5121 cmdline_parse_token_string_t cmd_gro_enable_port =
5122 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5123 cmd_keyword, "port");
5124 cmdline_parse_token_num_t cmd_gro_enable_pid =
5125 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
5127 cmdline_parse_token_string_t cmd_gro_enable_keyword =
5128 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5129 cmd_keyword, "gro");
5130 cmdline_parse_token_string_t cmd_gro_enable_onoff =
5131 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5132 cmd_onoff, "on#off");
5134 cmdline_parse_inst_t cmd_gro_enable = {
5135 .f = cmd_gro_enable_parsed,
5137 .help_str = "set port <port_id> gro on|off",
5139 (void *)&cmd_gro_enable_set,
5140 (void *)&cmd_gro_enable_port,
5141 (void *)&cmd_gro_enable_pid,
5142 (void *)&cmd_gro_enable_keyword,
5143 (void *)&cmd_gro_enable_onoff,
5148 /* *** DISPLAY GRO CONFIGURATION *** */
5149 struct cmd_gro_show_result {
5150 cmdline_fixed_string_t cmd_show;
5151 cmdline_fixed_string_t cmd_port;
5152 cmdline_fixed_string_t cmd_keyword;
5157 cmd_gro_show_parsed(void *parsed_result,
5158 __rte_unused struct cmdline *cl,
5159 __rte_unused void *data)
5161 struct cmd_gro_show_result *res;
5163 res = parsed_result;
5164 if (!strcmp(res->cmd_keyword, "gro"))
5165 show_gro(res->cmd_pid);
5168 cmdline_parse_token_string_t cmd_gro_show_show =
5169 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5171 cmdline_parse_token_string_t cmd_gro_show_port =
5172 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5174 cmdline_parse_token_num_t cmd_gro_show_pid =
5175 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
5177 cmdline_parse_token_string_t cmd_gro_show_keyword =
5178 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5179 cmd_keyword, "gro");
5181 cmdline_parse_inst_t cmd_gro_show = {
5182 .f = cmd_gro_show_parsed,
5184 .help_str = "show port <port_id> gro",
5186 (void *)&cmd_gro_show_show,
5187 (void *)&cmd_gro_show_port,
5188 (void *)&cmd_gro_show_pid,
5189 (void *)&cmd_gro_show_keyword,
5194 /* *** SET FLUSH CYCLES FOR GRO *** */
5195 struct cmd_gro_flush_result {
5196 cmdline_fixed_string_t cmd_set;
5197 cmdline_fixed_string_t cmd_keyword;
5198 cmdline_fixed_string_t cmd_flush;
5203 cmd_gro_flush_parsed(void *parsed_result,
5204 __rte_unused struct cmdline *cl,
5205 __rte_unused void *data)
5207 struct cmd_gro_flush_result *res;
5209 res = parsed_result;
5210 if ((!strcmp(res->cmd_keyword, "gro")) &&
5211 (!strcmp(res->cmd_flush, "flush")))
5212 setup_gro_flush_cycles(res->cmd_cycles);
5215 cmdline_parse_token_string_t cmd_gro_flush_set =
5216 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5218 cmdline_parse_token_string_t cmd_gro_flush_keyword =
5219 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5220 cmd_keyword, "gro");
5221 cmdline_parse_token_string_t cmd_gro_flush_flush =
5222 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5223 cmd_flush, "flush");
5224 cmdline_parse_token_num_t cmd_gro_flush_cycles =
5225 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
5228 cmdline_parse_inst_t cmd_gro_flush = {
5229 .f = cmd_gro_flush_parsed,
5231 .help_str = "set gro flush <cycles>",
5233 (void *)&cmd_gro_flush_set,
5234 (void *)&cmd_gro_flush_keyword,
5235 (void *)&cmd_gro_flush_flush,
5236 (void *)&cmd_gro_flush_cycles,
5241 /* *** ENABLE/DISABLE GSO *** */
5242 struct cmd_gso_enable_result {
5243 cmdline_fixed_string_t cmd_set;
5244 cmdline_fixed_string_t cmd_port;
5245 cmdline_fixed_string_t cmd_keyword;
5246 cmdline_fixed_string_t cmd_mode;
5251 cmd_gso_enable_parsed(void *parsed_result,
5252 __rte_unused struct cmdline *cl,
5253 __rte_unused void *data)
5255 struct cmd_gso_enable_result *res;
5257 res = parsed_result;
5258 if (!strcmp(res->cmd_keyword, "gso"))
5259 setup_gso(res->cmd_mode, res->cmd_pid);
5262 cmdline_parse_token_string_t cmd_gso_enable_set =
5263 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5265 cmdline_parse_token_string_t cmd_gso_enable_port =
5266 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5268 cmdline_parse_token_string_t cmd_gso_enable_keyword =
5269 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5270 cmd_keyword, "gso");
5271 cmdline_parse_token_string_t cmd_gso_enable_mode =
5272 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5273 cmd_mode, "on#off");
5274 cmdline_parse_token_num_t cmd_gso_enable_pid =
5275 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
5278 cmdline_parse_inst_t cmd_gso_enable = {
5279 .f = cmd_gso_enable_parsed,
5281 .help_str = "set port <port_id> gso on|off",
5283 (void *)&cmd_gso_enable_set,
5284 (void *)&cmd_gso_enable_port,
5285 (void *)&cmd_gso_enable_pid,
5286 (void *)&cmd_gso_enable_keyword,
5287 (void *)&cmd_gso_enable_mode,
5292 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
5293 struct cmd_gso_size_result {
5294 cmdline_fixed_string_t cmd_set;
5295 cmdline_fixed_string_t cmd_keyword;
5296 cmdline_fixed_string_t cmd_segsz;
5301 cmd_gso_size_parsed(void *parsed_result,
5302 __rte_unused struct cmdline *cl,
5303 __rte_unused void *data)
5305 struct cmd_gso_size_result *res = parsed_result;
5307 if (test_done == 0) {
5308 printf("Before setting GSO segsz, please first"
5309 " stop forwarding\n");
5313 if (!strcmp(res->cmd_keyword, "gso") &&
5314 !strcmp(res->cmd_segsz, "segsz")) {
5315 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
5316 printf("gso_size should be larger than %zu."
5317 " Please input a legal value\n",
5318 RTE_GSO_SEG_SIZE_MIN);
5320 gso_max_segment_size = res->cmd_size;
5324 cmdline_parse_token_string_t cmd_gso_size_set =
5325 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5327 cmdline_parse_token_string_t cmd_gso_size_keyword =
5328 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5329 cmd_keyword, "gso");
5330 cmdline_parse_token_string_t cmd_gso_size_segsz =
5331 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5332 cmd_segsz, "segsz");
5333 cmdline_parse_token_num_t cmd_gso_size_size =
5334 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
5337 cmdline_parse_inst_t cmd_gso_size = {
5338 .f = cmd_gso_size_parsed,
5340 .help_str = "set gso segsz <length>",
5342 (void *)&cmd_gso_size_set,
5343 (void *)&cmd_gso_size_keyword,
5344 (void *)&cmd_gso_size_segsz,
5345 (void *)&cmd_gso_size_size,
5350 /* *** SHOW GSO CONFIGURATION *** */
5351 struct cmd_gso_show_result {
5352 cmdline_fixed_string_t cmd_show;
5353 cmdline_fixed_string_t cmd_port;
5354 cmdline_fixed_string_t cmd_keyword;
5359 cmd_gso_show_parsed(void *parsed_result,
5360 __rte_unused struct cmdline *cl,
5361 __rte_unused void *data)
5363 struct cmd_gso_show_result *res = parsed_result;
5365 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
5366 printf("invalid port id %u\n", res->cmd_pid);
5369 if (!strcmp(res->cmd_keyword, "gso")) {
5370 if (gso_ports[res->cmd_pid].enable) {
5371 printf("Max GSO'd packet size: %uB\n"
5372 "Supported GSO types: TCP/IPv4, "
5373 "UDP/IPv4, VxLAN with inner "
5374 "TCP/IPv4 packet, GRE with inner "
5375 "TCP/IPv4 packet\n",
5376 gso_max_segment_size);
5378 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
5382 cmdline_parse_token_string_t cmd_gso_show_show =
5383 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5385 cmdline_parse_token_string_t cmd_gso_show_port =
5386 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5388 cmdline_parse_token_string_t cmd_gso_show_keyword =
5389 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5390 cmd_keyword, "gso");
5391 cmdline_parse_token_num_t cmd_gso_show_pid =
5392 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
5395 cmdline_parse_inst_t cmd_gso_show = {
5396 .f = cmd_gso_show_parsed,
5398 .help_str = "show port <port_id> gso",
5400 (void *)&cmd_gso_show_show,
5401 (void *)&cmd_gso_show_port,
5402 (void *)&cmd_gso_show_pid,
5403 (void *)&cmd_gso_show_keyword,
5408 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
5409 struct cmd_set_flush_rx {
5410 cmdline_fixed_string_t set;
5411 cmdline_fixed_string_t flush_rx;
5412 cmdline_fixed_string_t mode;
5416 cmd_set_flush_rx_parsed(void *parsed_result,
5417 __rte_unused struct cmdline *cl,
5418 __rte_unused void *data)
5420 struct cmd_set_flush_rx *res = parsed_result;
5421 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5424 cmdline_parse_token_string_t cmd_setflushrx_set =
5425 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5427 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
5428 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5429 flush_rx, "flush_rx");
5430 cmdline_parse_token_string_t cmd_setflushrx_mode =
5431 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5435 cmdline_parse_inst_t cmd_set_flush_rx = {
5436 .f = cmd_set_flush_rx_parsed,
5437 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
5440 (void *)&cmd_setflushrx_set,
5441 (void *)&cmd_setflushrx_flush_rx,
5442 (void *)&cmd_setflushrx_mode,
5447 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
5448 struct cmd_set_link_check {
5449 cmdline_fixed_string_t set;
5450 cmdline_fixed_string_t link_check;
5451 cmdline_fixed_string_t mode;
5455 cmd_set_link_check_parsed(void *parsed_result,
5456 __rte_unused struct cmdline *cl,
5457 __rte_unused void *data)
5459 struct cmd_set_link_check *res = parsed_result;
5460 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5463 cmdline_parse_token_string_t cmd_setlinkcheck_set =
5464 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5466 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
5467 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5468 link_check, "link_check");
5469 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
5470 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5474 cmdline_parse_inst_t cmd_set_link_check = {
5475 .f = cmd_set_link_check_parsed,
5476 .help_str = "set link_check on|off: Enable/Disable link status check "
5477 "when starting/stopping a port",
5480 (void *)&cmd_setlinkcheck_set,
5481 (void *)&cmd_setlinkcheck_link_check,
5482 (void *)&cmd_setlinkcheck_mode,
5487 /* *** SET NIC BYPASS MODE *** */
5488 struct cmd_set_bypass_mode_result {
5489 cmdline_fixed_string_t set;
5490 cmdline_fixed_string_t bypass;
5491 cmdline_fixed_string_t mode;
5492 cmdline_fixed_string_t value;
5497 cmd_set_bypass_mode_parsed(void *parsed_result,
5498 __rte_unused struct cmdline *cl,
5499 __rte_unused void *data)
5501 struct cmd_set_bypass_mode_result *res = parsed_result;
5502 portid_t port_id = res->port_id;
5503 int32_t rc = -EINVAL;
5505 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5506 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5508 if (!strcmp(res->value, "bypass"))
5509 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5510 else if (!strcmp(res->value, "isolate"))
5511 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5513 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5515 /* Set the bypass mode for the relevant port. */
5516 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
5519 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
5522 cmdline_parse_token_string_t cmd_setbypass_mode_set =
5523 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5525 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
5526 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5528 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
5529 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5531 cmdline_parse_token_string_t cmd_setbypass_mode_value =
5532 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5533 value, "normal#bypass#isolate");
5534 cmdline_parse_token_num_t cmd_setbypass_mode_port =
5535 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
5538 cmdline_parse_inst_t cmd_set_bypass_mode = {
5539 .f = cmd_set_bypass_mode_parsed,
5540 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
5541 "Set the NIC bypass mode for port_id",
5544 (void *)&cmd_setbypass_mode_set,
5545 (void *)&cmd_setbypass_mode_bypass,
5546 (void *)&cmd_setbypass_mode_mode,
5547 (void *)&cmd_setbypass_mode_value,
5548 (void *)&cmd_setbypass_mode_port,
5553 /* *** SET NIC BYPASS EVENT *** */
5554 struct cmd_set_bypass_event_result {
5555 cmdline_fixed_string_t set;
5556 cmdline_fixed_string_t bypass;
5557 cmdline_fixed_string_t event;
5558 cmdline_fixed_string_t event_value;
5559 cmdline_fixed_string_t mode;
5560 cmdline_fixed_string_t mode_value;
5565 cmd_set_bypass_event_parsed(void *parsed_result,
5566 __rte_unused struct cmdline *cl,
5567 __rte_unused void *data)
5569 int32_t rc = -EINVAL;
5570 struct cmd_set_bypass_event_result *res = parsed_result;
5571 portid_t port_id = res->port_id;
5573 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5574 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5575 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5577 if (!strcmp(res->event_value, "timeout"))
5578 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
5579 else if (!strcmp(res->event_value, "os_on"))
5580 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
5581 else if (!strcmp(res->event_value, "os_off"))
5582 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5583 else if (!strcmp(res->event_value, "power_on"))
5584 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5585 else if (!strcmp(res->event_value, "power_off"))
5586 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5588 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5590 if (!strcmp(res->mode_value, "bypass"))
5591 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5592 else if (!strcmp(res->mode_value, "isolate"))
5593 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5595 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5597 /* Set the watchdog timeout. */
5598 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5601 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5602 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5606 printf("Failed to set timeout value %u "
5607 "for port %d, errto code: %d.\n",
5608 bypass_timeout, port_id, rc);
5612 /* Set the bypass event to transition to bypass mode. */
5613 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5618 printf("\t Failed to set bypass event for port = %d.\n",
5622 cmdline_parse_token_string_t cmd_setbypass_event_set =
5623 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5625 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5626 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5628 cmdline_parse_token_string_t cmd_setbypass_event_event =
5629 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5631 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5632 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5633 event_value, "none#timeout#os_off#os_on#power_on#power_off");
5634 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5635 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5637 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5638 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5639 mode_value, "normal#bypass#isolate");
5640 cmdline_parse_token_num_t cmd_setbypass_event_port =
5641 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5644 cmdline_parse_inst_t cmd_set_bypass_event = {
5645 .f = cmd_set_bypass_event_parsed,
5646 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5647 "power_off mode normal|bypass|isolate <port_id>: "
5648 "Set the NIC bypass event mode for port_id",
5651 (void *)&cmd_setbypass_event_set,
5652 (void *)&cmd_setbypass_event_bypass,
5653 (void *)&cmd_setbypass_event_event,
5654 (void *)&cmd_setbypass_event_event_value,
5655 (void *)&cmd_setbypass_event_mode,
5656 (void *)&cmd_setbypass_event_mode_value,
5657 (void *)&cmd_setbypass_event_port,
5663 /* *** SET NIC BYPASS TIMEOUT *** */
5664 struct cmd_set_bypass_timeout_result {
5665 cmdline_fixed_string_t set;
5666 cmdline_fixed_string_t bypass;
5667 cmdline_fixed_string_t timeout;
5668 cmdline_fixed_string_t value;
5672 cmd_set_bypass_timeout_parsed(void *parsed_result,
5673 __rte_unused struct cmdline *cl,
5674 __rte_unused void *data)
5676 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5678 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5679 if (!strcmp(res->value, "1.5"))
5680 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5681 else if (!strcmp(res->value, "2"))
5682 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5683 else if (!strcmp(res->value, "3"))
5684 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5685 else if (!strcmp(res->value, "4"))
5686 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5687 else if (!strcmp(res->value, "8"))
5688 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5689 else if (!strcmp(res->value, "16"))
5690 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5691 else if (!strcmp(res->value, "32"))
5692 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5694 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5698 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5699 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5701 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5702 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5704 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5705 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5706 timeout, "timeout");
5707 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5708 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5709 value, "0#1.5#2#3#4#8#16#32");
5711 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5712 .f = cmd_set_bypass_timeout_parsed,
5713 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5714 "Set the NIC bypass watchdog timeout in seconds",
5717 (void *)&cmd_setbypass_timeout_set,
5718 (void *)&cmd_setbypass_timeout_bypass,
5719 (void *)&cmd_setbypass_timeout_timeout,
5720 (void *)&cmd_setbypass_timeout_value,
5725 /* *** SHOW NIC BYPASS MODE *** */
5726 struct cmd_show_bypass_config_result {
5727 cmdline_fixed_string_t show;
5728 cmdline_fixed_string_t bypass;
5729 cmdline_fixed_string_t config;
5734 cmd_show_bypass_config_parsed(void *parsed_result,
5735 __rte_unused struct cmdline *cl,
5736 __rte_unused void *data)
5738 struct cmd_show_bypass_config_result *res = parsed_result;
5739 portid_t port_id = res->port_id;
5741 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5742 uint32_t event_mode;
5743 uint32_t bypass_mode;
5744 uint32_t timeout = bypass_timeout;
5747 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5748 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
5749 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5750 {"UNKNOWN", "normal", "bypass", "isolate"};
5751 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5759 /* Display the bypass mode.*/
5760 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5761 printf("\tFailed to get bypass mode for port = %d\n", port_id);
5765 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5766 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5768 printf("\tbypass mode = %s\n", modes[bypass_mode]);
5771 /* Display the bypass timeout.*/
5772 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5773 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5775 printf("\tbypass timeout = %s\n", timeouts[timeout]);
5777 /* Display the bypass events and associated modes. */
5778 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < RTE_DIM(events); i++) {
5780 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5781 printf("\tFailed to get bypass mode for event = %s\n",
5784 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5785 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5787 printf("\tbypass event: %-16s = %s\n", events[i],
5793 printf("\tFailed to get bypass configuration for port = %d\n",
5797 cmdline_parse_token_string_t cmd_showbypass_config_show =
5798 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5800 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5801 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5803 cmdline_parse_token_string_t cmd_showbypass_config_config =
5804 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5806 cmdline_parse_token_num_t cmd_showbypass_config_port =
5807 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5810 cmdline_parse_inst_t cmd_show_bypass_config = {
5811 .f = cmd_show_bypass_config_parsed,
5812 .help_str = "show bypass config <port_id>: "
5813 "Show the NIC bypass config for port_id",
5816 (void *)&cmd_showbypass_config_show,
5817 (void *)&cmd_showbypass_config_bypass,
5818 (void *)&cmd_showbypass_config_config,
5819 (void *)&cmd_showbypass_config_port,
5825 /* *** SET BONDING MODE *** */
5826 struct cmd_set_bonding_mode_result {
5827 cmdline_fixed_string_t set;
5828 cmdline_fixed_string_t bonding;
5829 cmdline_fixed_string_t mode;
5834 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5835 __rte_unused struct cmdline *cl,
5836 __rte_unused void *data)
5838 struct cmd_set_bonding_mode_result *res = parsed_result;
5839 portid_t port_id = res->port_id;
5841 /* Set the bonding mode for the relevant port. */
5842 if (0 != rte_eth_bond_mode_set(port_id, res->value))
5843 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
5846 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5847 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5849 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5850 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5851 bonding, "bonding");
5852 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5853 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5855 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5856 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5858 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5859 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5862 cmdline_parse_inst_t cmd_set_bonding_mode = {
5863 .f = cmd_set_bonding_mode_parsed,
5864 .help_str = "set bonding mode <mode_value> <port_id>: "
5865 "Set the bonding mode for port_id",
5868 (void *) &cmd_setbonding_mode_set,
5869 (void *) &cmd_setbonding_mode_bonding,
5870 (void *) &cmd_setbonding_mode_mode,
5871 (void *) &cmd_setbonding_mode_value,
5872 (void *) &cmd_setbonding_mode_port,
5877 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5878 struct cmd_set_bonding_lacp_dedicated_queues_result {
5879 cmdline_fixed_string_t set;
5880 cmdline_fixed_string_t bonding;
5881 cmdline_fixed_string_t lacp;
5882 cmdline_fixed_string_t dedicated_queues;
5884 cmdline_fixed_string_t mode;
5887 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5888 __rte_unused struct cmdline *cl,
5889 __rte_unused void *data)
5891 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5892 portid_t port_id = res->port_id;
5893 struct rte_port *port;
5895 port = &ports[port_id];
5897 /** Check if the port is not started **/
5898 if (port->port_status != RTE_PORT_STOPPED) {
5899 printf("Please stop port %d first\n", port_id);
5903 if (!strcmp(res->mode, "enable")) {
5904 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5905 printf("Dedicate queues for LACP control packets"
5908 printf("Enabling dedicate queues for LACP control "
5909 "packets on port %d failed\n", port_id);
5910 } else if (!strcmp(res->mode, "disable")) {
5911 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5912 printf("Dedicated queues for LACP control packets "
5915 printf("Disabling dedicated queues for LACP control "
5916 "traffic on port %d failed\n", port_id);
5920 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5921 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5923 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
5924 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5925 bonding, "bonding");
5926 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
5927 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5929 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
5930 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5931 dedicated_queues, "dedicated_queues");
5932 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
5933 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5935 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
5936 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5937 mode, "enable#disable");
5939 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
5940 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
5941 .help_str = "set bonding lacp dedicated_queues <port_id> "
5943 "Enable/disable dedicated queues for LACP control traffic for port_id",
5946 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
5947 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
5948 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
5949 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
5950 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
5951 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
5956 /* *** SET BALANCE XMIT POLICY *** */
5957 struct cmd_set_bonding_balance_xmit_policy_result {
5958 cmdline_fixed_string_t set;
5959 cmdline_fixed_string_t bonding;
5960 cmdline_fixed_string_t balance_xmit_policy;
5962 cmdline_fixed_string_t policy;
5965 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
5966 __rte_unused struct cmdline *cl,
5967 __rte_unused void *data)
5969 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
5970 portid_t port_id = res->port_id;
5973 if (!strcmp(res->policy, "l2")) {
5974 policy = BALANCE_XMIT_POLICY_LAYER2;
5975 } else if (!strcmp(res->policy, "l23")) {
5976 policy = BALANCE_XMIT_POLICY_LAYER23;
5977 } else if (!strcmp(res->policy, "l34")) {
5978 policy = BALANCE_XMIT_POLICY_LAYER34;
5980 printf("\t Invalid xmit policy selection");
5984 /* Set the bonding mode for the relevant port. */
5985 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
5986 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
5991 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
5992 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5994 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
5995 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5996 bonding, "bonding");
5997 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
5998 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5999 balance_xmit_policy, "balance_xmit_policy");
6000 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
6001 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6003 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
6004 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6005 policy, "l2#l23#l34");
6007 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
6008 .f = cmd_set_bonding_balance_xmit_policy_parsed,
6009 .help_str = "set bonding balance_xmit_policy <port_id> "
6011 "Set the bonding balance_xmit_policy for port_id",
6014 (void *)&cmd_setbonding_balance_xmit_policy_set,
6015 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
6016 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
6017 (void *)&cmd_setbonding_balance_xmit_policy_port,
6018 (void *)&cmd_setbonding_balance_xmit_policy_policy,
6023 /* *** SHOW NIC BONDING CONFIGURATION *** */
6024 struct cmd_show_bonding_config_result {
6025 cmdline_fixed_string_t show;
6026 cmdline_fixed_string_t bonding;
6027 cmdline_fixed_string_t config;
6031 static void cmd_show_bonding_config_parsed(void *parsed_result,
6032 __rte_unused struct cmdline *cl,
6033 __rte_unused void *data)
6035 struct cmd_show_bonding_config_result *res = parsed_result;
6036 int bonding_mode, agg_mode;
6037 portid_t slaves[RTE_MAX_ETHPORTS];
6038 int num_slaves, num_active_slaves;
6041 portid_t port_id = res->port_id;
6043 /* Display the bonding mode.*/
6044 bonding_mode = rte_eth_bond_mode_get(port_id);
6045 if (bonding_mode < 0) {
6046 printf("\tFailed to get bonding mode for port = %d\n", port_id);
6049 printf("\tBonding mode: %d\n", bonding_mode);
6051 if (bonding_mode == BONDING_MODE_BALANCE) {
6052 int balance_xmit_policy;
6054 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
6055 if (balance_xmit_policy < 0) {
6056 printf("\tFailed to get balance xmit policy for port = %d\n",
6060 printf("\tBalance Xmit Policy: ");
6062 switch (balance_xmit_policy) {
6063 case BALANCE_XMIT_POLICY_LAYER2:
6064 printf("BALANCE_XMIT_POLICY_LAYER2");
6066 case BALANCE_XMIT_POLICY_LAYER23:
6067 printf("BALANCE_XMIT_POLICY_LAYER23");
6069 case BALANCE_XMIT_POLICY_LAYER34:
6070 printf("BALANCE_XMIT_POLICY_LAYER34");
6077 if (bonding_mode == BONDING_MODE_8023AD) {
6078 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
6079 printf("\tIEEE802.3AD Aggregator Mode: ");
6082 printf("bandwidth");
6094 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
6096 if (num_slaves < 0) {
6097 printf("\tFailed to get slave list for port = %d\n", port_id);
6100 if (num_slaves > 0) {
6101 printf("\tSlaves (%d): [", num_slaves);
6102 for (i = 0; i < num_slaves - 1; i++)
6103 printf("%d ", slaves[i]);
6105 printf("%d]\n", slaves[num_slaves - 1]);
6107 printf("\tSlaves: []\n");
6111 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
6114 if (num_active_slaves < 0) {
6115 printf("\tFailed to get active slave list for port = %d\n", port_id);
6118 if (num_active_slaves > 0) {
6119 printf("\tActive Slaves (%d): [", num_active_slaves);
6120 for (i = 0; i < num_active_slaves - 1; i++)
6121 printf("%d ", slaves[i]);
6123 printf("%d]\n", slaves[num_active_slaves - 1]);
6126 printf("\tActive Slaves: []\n");
6130 primary_id = rte_eth_bond_primary_get(port_id);
6131 if (primary_id < 0) {
6132 printf("\tFailed to get primary slave for port = %d\n", port_id);
6135 printf("\tPrimary: [%d]\n", primary_id);
6139 cmdline_parse_token_string_t cmd_showbonding_config_show =
6140 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6142 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
6143 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6144 bonding, "bonding");
6145 cmdline_parse_token_string_t cmd_showbonding_config_config =
6146 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6148 cmdline_parse_token_num_t cmd_showbonding_config_port =
6149 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
6152 cmdline_parse_inst_t cmd_show_bonding_config = {
6153 .f = cmd_show_bonding_config_parsed,
6154 .help_str = "show bonding config <port_id>: "
6155 "Show the bonding config for port_id",
6158 (void *)&cmd_showbonding_config_show,
6159 (void *)&cmd_showbonding_config_bonding,
6160 (void *)&cmd_showbonding_config_config,
6161 (void *)&cmd_showbonding_config_port,
6166 /* *** SET BONDING PRIMARY *** */
6167 struct cmd_set_bonding_primary_result {
6168 cmdline_fixed_string_t set;
6169 cmdline_fixed_string_t bonding;
6170 cmdline_fixed_string_t primary;
6175 static void cmd_set_bonding_primary_parsed(void *parsed_result,
6176 __rte_unused struct cmdline *cl,
6177 __rte_unused void *data)
6179 struct cmd_set_bonding_primary_result *res = parsed_result;
6180 portid_t master_port_id = res->port_id;
6181 portid_t slave_port_id = res->slave_id;
6183 /* Set the primary slave for a bonded device. */
6184 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
6185 printf("\t Failed to set primary slave for port = %d.\n",
6192 cmdline_parse_token_string_t cmd_setbonding_primary_set =
6193 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6195 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
6196 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6197 bonding, "bonding");
6198 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
6199 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6200 primary, "primary");
6201 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
6202 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6204 cmdline_parse_token_num_t cmd_setbonding_primary_port =
6205 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6208 cmdline_parse_inst_t cmd_set_bonding_primary = {
6209 .f = cmd_set_bonding_primary_parsed,
6210 .help_str = "set bonding primary <slave_id> <port_id>: "
6211 "Set the primary slave for port_id",
6214 (void *)&cmd_setbonding_primary_set,
6215 (void *)&cmd_setbonding_primary_bonding,
6216 (void *)&cmd_setbonding_primary_primary,
6217 (void *)&cmd_setbonding_primary_slave,
6218 (void *)&cmd_setbonding_primary_port,
6223 /* *** ADD SLAVE *** */
6224 struct cmd_add_bonding_slave_result {
6225 cmdline_fixed_string_t add;
6226 cmdline_fixed_string_t bonding;
6227 cmdline_fixed_string_t slave;
6232 static void cmd_add_bonding_slave_parsed(void *parsed_result,
6233 __rte_unused struct cmdline *cl,
6234 __rte_unused void *data)
6236 struct cmd_add_bonding_slave_result *res = parsed_result;
6237 portid_t master_port_id = res->port_id;
6238 portid_t slave_port_id = res->slave_id;
6240 /* add the slave for a bonded device. */
6241 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
6242 printf("\t Failed to add slave %d to master port = %d.\n",
6243 slave_port_id, master_port_id);
6247 set_port_slave_flag(slave_port_id);
6250 cmdline_parse_token_string_t cmd_addbonding_slave_add =
6251 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6253 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
6254 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6255 bonding, "bonding");
6256 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
6257 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6259 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
6260 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6262 cmdline_parse_token_num_t cmd_addbonding_slave_port =
6263 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6266 cmdline_parse_inst_t cmd_add_bonding_slave = {
6267 .f = cmd_add_bonding_slave_parsed,
6268 .help_str = "add bonding slave <slave_id> <port_id>: "
6269 "Add a slave device to a bonded device",
6272 (void *)&cmd_addbonding_slave_add,
6273 (void *)&cmd_addbonding_slave_bonding,
6274 (void *)&cmd_addbonding_slave_slave,
6275 (void *)&cmd_addbonding_slave_slaveid,
6276 (void *)&cmd_addbonding_slave_port,
6281 /* *** REMOVE SLAVE *** */
6282 struct cmd_remove_bonding_slave_result {
6283 cmdline_fixed_string_t remove;
6284 cmdline_fixed_string_t bonding;
6285 cmdline_fixed_string_t slave;
6290 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
6291 __rte_unused struct cmdline *cl,
6292 __rte_unused void *data)
6294 struct cmd_remove_bonding_slave_result *res = parsed_result;
6295 portid_t master_port_id = res->port_id;
6296 portid_t slave_port_id = res->slave_id;
6298 /* remove the slave from a bonded device. */
6299 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
6300 printf("\t Failed to remove slave %d from master port = %d.\n",
6301 slave_port_id, master_port_id);
6305 clear_port_slave_flag(slave_port_id);
6308 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
6309 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6311 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
6312 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6313 bonding, "bonding");
6314 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
6315 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6317 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
6318 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6320 cmdline_parse_token_num_t cmd_removebonding_slave_port =
6321 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6324 cmdline_parse_inst_t cmd_remove_bonding_slave = {
6325 .f = cmd_remove_bonding_slave_parsed,
6326 .help_str = "remove bonding slave <slave_id> <port_id>: "
6327 "Remove a slave device from a bonded device",
6330 (void *)&cmd_removebonding_slave_remove,
6331 (void *)&cmd_removebonding_slave_bonding,
6332 (void *)&cmd_removebonding_slave_slave,
6333 (void *)&cmd_removebonding_slave_slaveid,
6334 (void *)&cmd_removebonding_slave_port,
6339 /* *** CREATE BONDED DEVICE *** */
6340 struct cmd_create_bonded_device_result {
6341 cmdline_fixed_string_t create;
6342 cmdline_fixed_string_t bonded;
6343 cmdline_fixed_string_t device;
6348 static int bond_dev_num = 0;
6350 static void cmd_create_bonded_device_parsed(void *parsed_result,
6351 __rte_unused struct cmdline *cl,
6352 __rte_unused void *data)
6354 struct cmd_create_bonded_device_result *res = parsed_result;
6355 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
6359 if (test_done == 0) {
6360 printf("Please stop forwarding first\n");
6364 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
6367 /* Create a new bonded device. */
6368 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
6370 printf("\t Failed to create bonded device.\n");
6373 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
6376 /* Update number of ports */
6377 nb_ports = rte_eth_dev_count_avail();
6378 reconfig(port_id, res->socket);
6379 ret = rte_eth_promiscuous_enable(port_id);
6381 printf("Failed to enable promiscuous mode for port %u: %s - ignore\n",
6382 port_id, rte_strerror(-ret));
6384 ports[port_id].need_setup = 0;
6385 ports[port_id].port_status = RTE_PORT_STOPPED;
6390 cmdline_parse_token_string_t cmd_createbonded_device_create =
6391 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6393 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
6394 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6396 cmdline_parse_token_string_t cmd_createbonded_device_device =
6397 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6399 cmdline_parse_token_num_t cmd_createbonded_device_mode =
6400 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6402 cmdline_parse_token_num_t cmd_createbonded_device_socket =
6403 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6406 cmdline_parse_inst_t cmd_create_bonded_device = {
6407 .f = cmd_create_bonded_device_parsed,
6408 .help_str = "create bonded device <mode> <socket>: "
6409 "Create a new bonded device with specific bonding mode and socket",
6412 (void *)&cmd_createbonded_device_create,
6413 (void *)&cmd_createbonded_device_bonded,
6414 (void *)&cmd_createbonded_device_device,
6415 (void *)&cmd_createbonded_device_mode,
6416 (void *)&cmd_createbonded_device_socket,
6421 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
6422 struct cmd_set_bond_mac_addr_result {
6423 cmdline_fixed_string_t set;
6424 cmdline_fixed_string_t bonding;
6425 cmdline_fixed_string_t mac_addr;
6427 struct rte_ether_addr address;
6430 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
6431 __rte_unused struct cmdline *cl,
6432 __rte_unused void *data)
6434 struct cmd_set_bond_mac_addr_result *res = parsed_result;
6437 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
6440 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
6442 /* check the return value and print it if is < 0 */
6444 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6447 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
6448 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
6449 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
6450 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
6452 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
6453 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
6455 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
6456 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
6458 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
6459 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
6461 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
6462 .f = cmd_set_bond_mac_addr_parsed,
6464 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
6466 (void *)&cmd_set_bond_mac_addr_set,
6467 (void *)&cmd_set_bond_mac_addr_bonding,
6468 (void *)&cmd_set_bond_mac_addr_mac,
6469 (void *)&cmd_set_bond_mac_addr_portnum,
6470 (void *)&cmd_set_bond_mac_addr_addr,
6476 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
6477 struct cmd_set_bond_mon_period_result {
6478 cmdline_fixed_string_t set;
6479 cmdline_fixed_string_t bonding;
6480 cmdline_fixed_string_t mon_period;
6485 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
6486 __rte_unused struct cmdline *cl,
6487 __rte_unused void *data)
6489 struct cmd_set_bond_mon_period_result *res = parsed_result;
6492 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
6494 /* check the return value and print it if is < 0 */
6496 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6499 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
6500 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6502 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
6503 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6504 bonding, "bonding");
6505 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
6506 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6507 mon_period, "mon_period");
6508 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
6509 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6511 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
6512 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6515 cmdline_parse_inst_t cmd_set_bond_mon_period = {
6516 .f = cmd_set_bond_mon_period_parsed,
6518 .help_str = "set bonding mon_period <port_id> <period_ms>",
6520 (void *)&cmd_set_bond_mon_period_set,
6521 (void *)&cmd_set_bond_mon_period_bonding,
6522 (void *)&cmd_set_bond_mon_period_mon_period,
6523 (void *)&cmd_set_bond_mon_period_portnum,
6524 (void *)&cmd_set_bond_mon_period_period_ms,
6531 struct cmd_set_bonding_agg_mode_policy_result {
6532 cmdline_fixed_string_t set;
6533 cmdline_fixed_string_t bonding;
6534 cmdline_fixed_string_t agg_mode;
6536 cmdline_fixed_string_t policy;
6541 cmd_set_bonding_agg_mode(void *parsed_result,
6542 __rte_unused struct cmdline *cl,
6543 __rte_unused void *data)
6545 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
6546 uint8_t policy = AGG_BANDWIDTH;
6548 if (!strcmp(res->policy, "bandwidth"))
6549 policy = AGG_BANDWIDTH;
6550 else if (!strcmp(res->policy, "stable"))
6551 policy = AGG_STABLE;
6552 else if (!strcmp(res->policy, "count"))
6555 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
6559 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
6560 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6562 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
6563 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6564 bonding, "bonding");
6566 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
6567 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6568 agg_mode, "agg_mode");
6570 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
6571 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6574 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6575 TOKEN_STRING_INITIALIZER(
6576 struct cmd_set_bonding_balance_xmit_policy_result,
6577 policy, "stable#bandwidth#count");
6579 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6580 .f = cmd_set_bonding_agg_mode,
6582 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6584 (void *)&cmd_set_bonding_agg_mode_set,
6585 (void *)&cmd_set_bonding_agg_mode_bonding,
6586 (void *)&cmd_set_bonding_agg_mode_agg_mode,
6587 (void *)&cmd_set_bonding_agg_mode_portnum,
6588 (void *)&cmd_set_bonding_agg_mode_policy_string,
6594 #endif /* RTE_NET_BOND */
6596 /* *** SET FORWARDING MODE *** */
6597 struct cmd_set_fwd_mode_result {
6598 cmdline_fixed_string_t set;
6599 cmdline_fixed_string_t fwd;
6600 cmdline_fixed_string_t mode;
6603 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6604 __rte_unused struct cmdline *cl,
6605 __rte_unused void *data)
6607 struct cmd_set_fwd_mode_result *res = parsed_result;
6610 set_pkt_forwarding_mode(res->mode);
6613 cmdline_parse_token_string_t cmd_setfwd_set =
6614 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6615 cmdline_parse_token_string_t cmd_setfwd_fwd =
6616 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6617 cmdline_parse_token_string_t cmd_setfwd_mode =
6618 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6619 "" /* defined at init */);
6621 cmdline_parse_inst_t cmd_set_fwd_mode = {
6622 .f = cmd_set_fwd_mode_parsed,
6624 .help_str = NULL, /* defined at init */
6626 (void *)&cmd_setfwd_set,
6627 (void *)&cmd_setfwd_fwd,
6628 (void *)&cmd_setfwd_mode,
6633 static void cmd_set_fwd_mode_init(void)
6636 static char token[128];
6637 static char help[256];
6638 cmdline_parse_token_string_t *token_struct;
6640 modes = list_pkt_forwarding_modes();
6641 snprintf(help, sizeof(help), "set fwd %s: "
6642 "Set packet forwarding mode", modes);
6643 cmd_set_fwd_mode.help_str = help;
6645 /* string token separator is # */
6646 for (c = token; *modes != '\0'; modes++)
6651 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6652 token_struct->string_data.str = token;
6655 /* *** SET RETRY FORWARDING MODE *** */
6656 struct cmd_set_fwd_retry_mode_result {
6657 cmdline_fixed_string_t set;
6658 cmdline_fixed_string_t fwd;
6659 cmdline_fixed_string_t mode;
6660 cmdline_fixed_string_t retry;
6663 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6664 __rte_unused struct cmdline *cl,
6665 __rte_unused void *data)
6667 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6670 set_pkt_forwarding_mode(res->mode);
6673 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6674 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6676 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6677 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6679 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6680 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6682 "" /* defined at init */);
6683 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6684 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6687 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6688 .f = cmd_set_fwd_retry_mode_parsed,
6690 .help_str = NULL, /* defined at init */
6692 (void *)&cmd_setfwd_retry_set,
6693 (void *)&cmd_setfwd_retry_fwd,
6694 (void *)&cmd_setfwd_retry_mode,
6695 (void *)&cmd_setfwd_retry_retry,
6700 static void cmd_set_fwd_retry_mode_init(void)
6703 static char token[128];
6704 static char help[256];
6705 cmdline_parse_token_string_t *token_struct;
6707 modes = list_pkt_forwarding_retry_modes();
6708 snprintf(help, sizeof(help), "set fwd %s retry: "
6709 "Set packet forwarding mode with retry", modes);
6710 cmd_set_fwd_retry_mode.help_str = help;
6712 /* string token separator is # */
6713 for (c = token; *modes != '\0'; modes++)
6718 token_struct = (cmdline_parse_token_string_t *)
6719 cmd_set_fwd_retry_mode.tokens[2];
6720 token_struct->string_data.str = token;
6723 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6724 struct cmd_set_burst_tx_retry_result {
6725 cmdline_fixed_string_t set;
6726 cmdline_fixed_string_t burst;
6727 cmdline_fixed_string_t tx;
6728 cmdline_fixed_string_t delay;
6730 cmdline_fixed_string_t retry;
6734 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6735 __rte_unused struct cmdline *cl,
6736 __rte_unused void *data)
6738 struct cmd_set_burst_tx_retry_result *res = parsed_result;
6740 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6741 && !strcmp(res->tx, "tx")) {
6742 if (!strcmp(res->delay, "delay"))
6743 burst_tx_delay_time = res->time;
6744 if (!strcmp(res->retry, "retry"))
6745 burst_tx_retry_num = res->retry_num;
6750 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6751 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6752 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6753 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6755 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6756 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6757 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6758 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6759 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6760 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
6761 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6762 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6763 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6764 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
6766 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6767 .f = cmd_set_burst_tx_retry_parsed,
6768 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6770 (void *)&cmd_set_burst_tx_retry_set,
6771 (void *)&cmd_set_burst_tx_retry_burst,
6772 (void *)&cmd_set_burst_tx_retry_tx,
6773 (void *)&cmd_set_burst_tx_retry_delay,
6774 (void *)&cmd_set_burst_tx_retry_time,
6775 (void *)&cmd_set_burst_tx_retry_retry,
6776 (void *)&cmd_set_burst_tx_retry_retry_num,
6781 /* *** SET PROMISC MODE *** */
6782 struct cmd_set_promisc_mode_result {
6783 cmdline_fixed_string_t set;
6784 cmdline_fixed_string_t promisc;
6785 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6786 uint16_t port_num; /* valid if "allports" argument == 0 */
6787 cmdline_fixed_string_t mode;
6790 static void cmd_set_promisc_mode_parsed(void *parsed_result,
6791 __rte_unused struct cmdline *cl,
6794 struct cmd_set_promisc_mode_result *res = parsed_result;
6798 if (!strcmp(res->mode, "on"))
6805 RTE_ETH_FOREACH_DEV(i)
6806 eth_set_promisc_mode(i, enable);
6808 eth_set_promisc_mode(res->port_num, enable);
6812 cmdline_parse_token_string_t cmd_setpromisc_set =
6813 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6814 cmdline_parse_token_string_t cmd_setpromisc_promisc =
6815 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6817 cmdline_parse_token_string_t cmd_setpromisc_portall =
6818 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6820 cmdline_parse_token_num_t cmd_setpromisc_portnum =
6821 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6823 cmdline_parse_token_string_t cmd_setpromisc_mode =
6824 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6827 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6828 .f = cmd_set_promisc_mode_parsed,
6830 .help_str = "set promisc all on|off: Set promisc mode for all ports",
6832 (void *)&cmd_setpromisc_set,
6833 (void *)&cmd_setpromisc_promisc,
6834 (void *)&cmd_setpromisc_portall,
6835 (void *)&cmd_setpromisc_mode,
6840 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6841 .f = cmd_set_promisc_mode_parsed,
6843 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6845 (void *)&cmd_setpromisc_set,
6846 (void *)&cmd_setpromisc_promisc,
6847 (void *)&cmd_setpromisc_portnum,
6848 (void *)&cmd_setpromisc_mode,
6853 /* *** SET ALLMULTI MODE *** */
6854 struct cmd_set_allmulti_mode_result {
6855 cmdline_fixed_string_t set;
6856 cmdline_fixed_string_t allmulti;
6857 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6858 uint16_t port_num; /* valid if "allports" argument == 0 */
6859 cmdline_fixed_string_t mode;
6862 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6863 __rte_unused struct cmdline *cl,
6866 struct cmd_set_allmulti_mode_result *res = parsed_result;
6870 if (!strcmp(res->mode, "on"))
6877 RTE_ETH_FOREACH_DEV(i) {
6878 eth_set_allmulticast_mode(i, enable);
6882 eth_set_allmulticast_mode(res->port_num, enable);
6886 cmdline_parse_token_string_t cmd_setallmulti_set =
6887 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6888 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6889 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6891 cmdline_parse_token_string_t cmd_setallmulti_portall =
6892 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6894 cmdline_parse_token_num_t cmd_setallmulti_portnum =
6895 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6897 cmdline_parse_token_string_t cmd_setallmulti_mode =
6898 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6901 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6902 .f = cmd_set_allmulti_mode_parsed,
6904 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6906 (void *)&cmd_setallmulti_set,
6907 (void *)&cmd_setallmulti_allmulti,
6908 (void *)&cmd_setallmulti_portall,
6909 (void *)&cmd_setallmulti_mode,
6914 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6915 .f = cmd_set_allmulti_mode_parsed,
6917 .help_str = "set allmulti <port_id> on|off: "
6918 "Set allmulti mode on port_id",
6920 (void *)&cmd_setallmulti_set,
6921 (void *)&cmd_setallmulti_allmulti,
6922 (void *)&cmd_setallmulti_portnum,
6923 (void *)&cmd_setallmulti_mode,
6928 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
6929 struct cmd_link_flow_ctrl_set_result {
6930 cmdline_fixed_string_t set;
6931 cmdline_fixed_string_t flow_ctrl;
6932 cmdline_fixed_string_t rx;
6933 cmdline_fixed_string_t rx_lfc_mode;
6934 cmdline_fixed_string_t tx;
6935 cmdline_fixed_string_t tx_lfc_mode;
6936 cmdline_fixed_string_t mac_ctrl_frame_fwd;
6937 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
6938 cmdline_fixed_string_t autoneg_str;
6939 cmdline_fixed_string_t autoneg;
6940 cmdline_fixed_string_t hw_str;
6941 uint32_t high_water;
6942 cmdline_fixed_string_t lw_str;
6944 cmdline_fixed_string_t pt_str;
6945 uint16_t pause_time;
6946 cmdline_fixed_string_t xon_str;
6951 cmdline_parse_token_string_t cmd_lfc_set_set =
6952 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6954 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
6955 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6956 flow_ctrl, "flow_ctrl");
6957 cmdline_parse_token_string_t cmd_lfc_set_rx =
6958 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6960 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
6961 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6962 rx_lfc_mode, "on#off");
6963 cmdline_parse_token_string_t cmd_lfc_set_tx =
6964 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6966 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
6967 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6968 tx_lfc_mode, "on#off");
6969 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
6970 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6971 hw_str, "high_water");
6972 cmdline_parse_token_num_t cmd_lfc_set_high_water =
6973 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6974 high_water, UINT32);
6975 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
6976 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6977 lw_str, "low_water");
6978 cmdline_parse_token_num_t cmd_lfc_set_low_water =
6979 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6981 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
6982 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6983 pt_str, "pause_time");
6984 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
6985 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6986 pause_time, UINT16);
6987 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
6988 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6989 xon_str, "send_xon");
6990 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
6991 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6993 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
6994 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6995 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
6996 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6997 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6998 mac_ctrl_frame_fwd_mode, "on#off");
6999 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
7000 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7001 autoneg_str, "autoneg");
7002 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
7003 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7005 cmdline_parse_token_num_t cmd_lfc_set_portid =
7006 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7009 /* forward declaration */
7011 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
7014 cmdline_parse_inst_t cmd_link_flow_control_set = {
7015 .f = cmd_link_flow_ctrl_set_parsed,
7017 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
7018 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
7019 "autoneg on|off <port_id>: Configure the Ethernet flow control",
7021 (void *)&cmd_lfc_set_set,
7022 (void *)&cmd_lfc_set_flow_ctrl,
7023 (void *)&cmd_lfc_set_rx,
7024 (void *)&cmd_lfc_set_rx_mode,
7025 (void *)&cmd_lfc_set_tx,
7026 (void *)&cmd_lfc_set_tx_mode,
7027 (void *)&cmd_lfc_set_high_water,
7028 (void *)&cmd_lfc_set_low_water,
7029 (void *)&cmd_lfc_set_pause_time,
7030 (void *)&cmd_lfc_set_send_xon,
7031 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
7032 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
7033 (void *)&cmd_lfc_set_autoneg_str,
7034 (void *)&cmd_lfc_set_autoneg,
7035 (void *)&cmd_lfc_set_portid,
7040 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
7041 .f = cmd_link_flow_ctrl_set_parsed,
7042 .data = (void *)&cmd_link_flow_control_set_rx,
7043 .help_str = "set flow_ctrl rx on|off <port_id>: "
7044 "Change rx flow control parameter",
7046 (void *)&cmd_lfc_set_set,
7047 (void *)&cmd_lfc_set_flow_ctrl,
7048 (void *)&cmd_lfc_set_rx,
7049 (void *)&cmd_lfc_set_rx_mode,
7050 (void *)&cmd_lfc_set_portid,
7055 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
7056 .f = cmd_link_flow_ctrl_set_parsed,
7057 .data = (void *)&cmd_link_flow_control_set_tx,
7058 .help_str = "set flow_ctrl tx on|off <port_id>: "
7059 "Change tx flow control parameter",
7061 (void *)&cmd_lfc_set_set,
7062 (void *)&cmd_lfc_set_flow_ctrl,
7063 (void *)&cmd_lfc_set_tx,
7064 (void *)&cmd_lfc_set_tx_mode,
7065 (void *)&cmd_lfc_set_portid,
7070 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
7071 .f = cmd_link_flow_ctrl_set_parsed,
7072 .data = (void *)&cmd_link_flow_control_set_hw,
7073 .help_str = "set flow_ctrl high_water <value> <port_id>: "
7074 "Change high water flow control parameter",
7076 (void *)&cmd_lfc_set_set,
7077 (void *)&cmd_lfc_set_flow_ctrl,
7078 (void *)&cmd_lfc_set_high_water_str,
7079 (void *)&cmd_lfc_set_high_water,
7080 (void *)&cmd_lfc_set_portid,
7085 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
7086 .f = cmd_link_flow_ctrl_set_parsed,
7087 .data = (void *)&cmd_link_flow_control_set_lw,
7088 .help_str = "set flow_ctrl low_water <value> <port_id>: "
7089 "Change low water flow control parameter",
7091 (void *)&cmd_lfc_set_set,
7092 (void *)&cmd_lfc_set_flow_ctrl,
7093 (void *)&cmd_lfc_set_low_water_str,
7094 (void *)&cmd_lfc_set_low_water,
7095 (void *)&cmd_lfc_set_portid,
7100 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
7101 .f = cmd_link_flow_ctrl_set_parsed,
7102 .data = (void *)&cmd_link_flow_control_set_pt,
7103 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
7104 "Change pause time flow control parameter",
7106 (void *)&cmd_lfc_set_set,
7107 (void *)&cmd_lfc_set_flow_ctrl,
7108 (void *)&cmd_lfc_set_pause_time_str,
7109 (void *)&cmd_lfc_set_pause_time,
7110 (void *)&cmd_lfc_set_portid,
7115 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
7116 .f = cmd_link_flow_ctrl_set_parsed,
7117 .data = (void *)&cmd_link_flow_control_set_xon,
7118 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
7119 "Change send_xon flow control parameter",
7121 (void *)&cmd_lfc_set_set,
7122 (void *)&cmd_lfc_set_flow_ctrl,
7123 (void *)&cmd_lfc_set_send_xon_str,
7124 (void *)&cmd_lfc_set_send_xon,
7125 (void *)&cmd_lfc_set_portid,
7130 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
7131 .f = cmd_link_flow_ctrl_set_parsed,
7132 .data = (void *)&cmd_link_flow_control_set_macfwd,
7133 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
7134 "Change mac ctrl fwd flow control parameter",
7136 (void *)&cmd_lfc_set_set,
7137 (void *)&cmd_lfc_set_flow_ctrl,
7138 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
7139 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
7140 (void *)&cmd_lfc_set_portid,
7145 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
7146 .f = cmd_link_flow_ctrl_set_parsed,
7147 .data = (void *)&cmd_link_flow_control_set_autoneg,
7148 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
7149 "Change autoneg flow control parameter",
7151 (void *)&cmd_lfc_set_set,
7152 (void *)&cmd_lfc_set_flow_ctrl,
7153 (void *)&cmd_lfc_set_autoneg_str,
7154 (void *)&cmd_lfc_set_autoneg,
7155 (void *)&cmd_lfc_set_portid,
7161 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
7162 __rte_unused struct cmdline *cl,
7165 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
7166 cmdline_parse_inst_t *cmd = data;
7167 struct rte_eth_fc_conf fc_conf;
7173 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7174 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7175 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7176 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7178 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
7179 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7182 /* Partial command line, retrieve current configuration */
7184 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
7186 printf("cannot get current flow ctrl parameters, return"
7187 "code = %d\n", ret);
7191 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
7192 (fc_conf.mode == RTE_FC_FULL))
7194 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
7195 (fc_conf.mode == RTE_FC_FULL))
7199 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
7200 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
7202 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
7203 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
7205 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
7207 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
7208 fc_conf.high_water = res->high_water;
7210 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
7211 fc_conf.low_water = res->low_water;
7213 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
7214 fc_conf.pause_time = res->pause_time;
7216 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
7217 fc_conf.send_xon = res->send_xon;
7219 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
7220 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
7221 fc_conf.mac_ctrl_frame_fwd = 1;
7223 fc_conf.mac_ctrl_frame_fwd = 0;
7226 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
7227 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
7229 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
7231 printf("bad flow contrl parameter, return code = %d \n", ret);
7234 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
7235 struct cmd_priority_flow_ctrl_set_result {
7236 cmdline_fixed_string_t set;
7237 cmdline_fixed_string_t pfc_ctrl;
7238 cmdline_fixed_string_t rx;
7239 cmdline_fixed_string_t rx_pfc_mode;
7240 cmdline_fixed_string_t tx;
7241 cmdline_fixed_string_t tx_pfc_mode;
7242 uint32_t high_water;
7244 uint16_t pause_time;
7250 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
7251 __rte_unused struct cmdline *cl,
7252 __rte_unused void *data)
7254 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
7255 struct rte_eth_pfc_conf pfc_conf;
7256 int rx_fc_enable, tx_fc_enable;
7260 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7261 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7262 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7263 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7265 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
7266 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7269 memset(&pfc_conf, 0, sizeof(struct rte_eth_pfc_conf));
7270 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
7271 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
7272 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
7273 pfc_conf.fc.high_water = res->high_water;
7274 pfc_conf.fc.low_water = res->low_water;
7275 pfc_conf.fc.pause_time = res->pause_time;
7276 pfc_conf.priority = res->priority;
7278 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
7280 printf("bad priority flow contrl parameter, return code = %d \n", ret);
7283 cmdline_parse_token_string_t cmd_pfc_set_set =
7284 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7286 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
7287 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7288 pfc_ctrl, "pfc_ctrl");
7289 cmdline_parse_token_string_t cmd_pfc_set_rx =
7290 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7292 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
7293 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7294 rx_pfc_mode, "on#off");
7295 cmdline_parse_token_string_t cmd_pfc_set_tx =
7296 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7298 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
7299 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7300 tx_pfc_mode, "on#off");
7301 cmdline_parse_token_num_t cmd_pfc_set_high_water =
7302 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7303 high_water, UINT32);
7304 cmdline_parse_token_num_t cmd_pfc_set_low_water =
7305 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7307 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
7308 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7309 pause_time, UINT16);
7310 cmdline_parse_token_num_t cmd_pfc_set_priority =
7311 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7313 cmdline_parse_token_num_t cmd_pfc_set_portid =
7314 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7317 cmdline_parse_inst_t cmd_priority_flow_control_set = {
7318 .f = cmd_priority_flow_ctrl_set_parsed,
7320 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
7321 "<pause_time> <priority> <port_id>: "
7322 "Configure the Ethernet priority flow control",
7324 (void *)&cmd_pfc_set_set,
7325 (void *)&cmd_pfc_set_flow_ctrl,
7326 (void *)&cmd_pfc_set_rx,
7327 (void *)&cmd_pfc_set_rx_mode,
7328 (void *)&cmd_pfc_set_tx,
7329 (void *)&cmd_pfc_set_tx_mode,
7330 (void *)&cmd_pfc_set_high_water,
7331 (void *)&cmd_pfc_set_low_water,
7332 (void *)&cmd_pfc_set_pause_time,
7333 (void *)&cmd_pfc_set_priority,
7334 (void *)&cmd_pfc_set_portid,
7339 /* *** RESET CONFIGURATION *** */
7340 struct cmd_reset_result {
7341 cmdline_fixed_string_t reset;
7342 cmdline_fixed_string_t def;
7345 static void cmd_reset_parsed(__rte_unused void *parsed_result,
7347 __rte_unused void *data)
7349 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
7350 set_def_fwd_config();
7353 cmdline_parse_token_string_t cmd_reset_set =
7354 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
7355 cmdline_parse_token_string_t cmd_reset_def =
7356 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
7359 cmdline_parse_inst_t cmd_reset = {
7360 .f = cmd_reset_parsed,
7362 .help_str = "set default: Reset default forwarding configuration",
7364 (void *)&cmd_reset_set,
7365 (void *)&cmd_reset_def,
7370 /* *** START FORWARDING *** */
7371 struct cmd_start_result {
7372 cmdline_fixed_string_t start;
7375 cmdline_parse_token_string_t cmd_start_start =
7376 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
7378 static void cmd_start_parsed(__rte_unused void *parsed_result,
7379 __rte_unused struct cmdline *cl,
7380 __rte_unused void *data)
7382 start_packet_forwarding(0);
7385 cmdline_parse_inst_t cmd_start = {
7386 .f = cmd_start_parsed,
7388 .help_str = "start: Start packet forwarding",
7390 (void *)&cmd_start_start,
7395 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7396 struct cmd_start_tx_first_result {
7397 cmdline_fixed_string_t start;
7398 cmdline_fixed_string_t tx_first;
7402 cmd_start_tx_first_parsed(__rte_unused void *parsed_result,
7403 __rte_unused struct cmdline *cl,
7404 __rte_unused void *data)
7406 start_packet_forwarding(1);
7409 cmdline_parse_token_string_t cmd_start_tx_first_start =
7410 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7412 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7413 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7414 tx_first, "tx_first");
7416 cmdline_parse_inst_t cmd_start_tx_first = {
7417 .f = cmd_start_tx_first_parsed,
7419 .help_str = "start tx_first: Start packet forwarding, "
7420 "after sending 1 burst of packets",
7422 (void *)&cmd_start_tx_first_start,
7423 (void *)&cmd_start_tx_first_tx_first,
7428 /* *** START FORWARDING WITH N TX BURST FIRST *** */
7429 struct cmd_start_tx_first_n_result {
7430 cmdline_fixed_string_t start;
7431 cmdline_fixed_string_t tx_first;
7436 cmd_start_tx_first_n_parsed(void *parsed_result,
7437 __rte_unused struct cmdline *cl,
7438 __rte_unused void *data)
7440 struct cmd_start_tx_first_n_result *res = parsed_result;
7442 start_packet_forwarding(res->tx_num);
7445 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7446 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7448 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7449 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7450 tx_first, "tx_first");
7451 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7452 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7455 cmdline_parse_inst_t cmd_start_tx_first_n = {
7456 .f = cmd_start_tx_first_n_parsed,
7458 .help_str = "start tx_first <num>: "
7459 "packet forwarding, after sending <num> bursts of packets",
7461 (void *)&cmd_start_tx_first_n_start,
7462 (void *)&cmd_start_tx_first_n_tx_first,
7463 (void *)&cmd_start_tx_first_n_tx_num,
7468 /* *** SET LINK UP *** */
7469 struct cmd_set_link_up_result {
7470 cmdline_fixed_string_t set;
7471 cmdline_fixed_string_t link_up;
7472 cmdline_fixed_string_t port;
7476 cmdline_parse_token_string_t cmd_set_link_up_set =
7477 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7478 cmdline_parse_token_string_t cmd_set_link_up_link_up =
7479 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7481 cmdline_parse_token_string_t cmd_set_link_up_port =
7482 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7483 cmdline_parse_token_num_t cmd_set_link_up_port_id =
7484 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16);
7486 static void cmd_set_link_up_parsed(__rte_unused void *parsed_result,
7487 __rte_unused struct cmdline *cl,
7488 __rte_unused void *data)
7490 struct cmd_set_link_up_result *res = parsed_result;
7491 dev_set_link_up(res->port_id);
7494 cmdline_parse_inst_t cmd_set_link_up = {
7495 .f = cmd_set_link_up_parsed,
7497 .help_str = "set link-up port <port id>",
7499 (void *)&cmd_set_link_up_set,
7500 (void *)&cmd_set_link_up_link_up,
7501 (void *)&cmd_set_link_up_port,
7502 (void *)&cmd_set_link_up_port_id,
7507 /* *** SET LINK DOWN *** */
7508 struct cmd_set_link_down_result {
7509 cmdline_fixed_string_t set;
7510 cmdline_fixed_string_t link_down;
7511 cmdline_fixed_string_t port;
7515 cmdline_parse_token_string_t cmd_set_link_down_set =
7516 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
7517 cmdline_parse_token_string_t cmd_set_link_down_link_down =
7518 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
7520 cmdline_parse_token_string_t cmd_set_link_down_port =
7521 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
7522 cmdline_parse_token_num_t cmd_set_link_down_port_id =
7523 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16);
7525 static void cmd_set_link_down_parsed(
7526 __rte_unused void *parsed_result,
7527 __rte_unused struct cmdline *cl,
7528 __rte_unused void *data)
7530 struct cmd_set_link_down_result *res = parsed_result;
7531 dev_set_link_down(res->port_id);
7534 cmdline_parse_inst_t cmd_set_link_down = {
7535 .f = cmd_set_link_down_parsed,
7537 .help_str = "set link-down port <port id>",
7539 (void *)&cmd_set_link_down_set,
7540 (void *)&cmd_set_link_down_link_down,
7541 (void *)&cmd_set_link_down_port,
7542 (void *)&cmd_set_link_down_port_id,
7547 /* *** SHOW CFG *** */
7548 struct cmd_showcfg_result {
7549 cmdline_fixed_string_t show;
7550 cmdline_fixed_string_t cfg;
7551 cmdline_fixed_string_t what;
7554 static void cmd_showcfg_parsed(void *parsed_result,
7555 __rte_unused struct cmdline *cl,
7556 __rte_unused void *data)
7558 struct cmd_showcfg_result *res = parsed_result;
7559 if (!strcmp(res->what, "rxtx"))
7560 rxtx_config_display();
7561 else if (!strcmp(res->what, "cores"))
7562 fwd_lcores_config_display();
7563 else if (!strcmp(res->what, "fwd"))
7564 pkt_fwd_config_display(&cur_fwd_config);
7565 else if (!strcmp(res->what, "rxoffs"))
7566 show_rx_pkt_offsets();
7567 else if (!strcmp(res->what, "rxpkts"))
7568 show_rx_pkt_segments();
7569 else if (!strcmp(res->what, "txpkts"))
7570 show_tx_pkt_segments();
7571 else if (!strcmp(res->what, "txtimes"))
7572 show_tx_pkt_times();
7575 cmdline_parse_token_string_t cmd_showcfg_show =
7576 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7577 cmdline_parse_token_string_t cmd_showcfg_port =
7578 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7579 cmdline_parse_token_string_t cmd_showcfg_what =
7580 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7581 "rxtx#cores#fwd#rxoffs#rxpkts#txpkts#txtimes");
7583 cmdline_parse_inst_t cmd_showcfg = {
7584 .f = cmd_showcfg_parsed,
7586 .help_str = "show config rxtx|cores|fwd|rxoffs|rxpkts|txpkts|txtimes",
7588 (void *)&cmd_showcfg_show,
7589 (void *)&cmd_showcfg_port,
7590 (void *)&cmd_showcfg_what,
7595 /* *** SHOW ALL PORT INFO *** */
7596 struct cmd_showportall_result {
7597 cmdline_fixed_string_t show;
7598 cmdline_fixed_string_t port;
7599 cmdline_fixed_string_t what;
7600 cmdline_fixed_string_t all;
7603 static void cmd_showportall_parsed(void *parsed_result,
7604 __rte_unused struct cmdline *cl,
7605 __rte_unused void *data)
7609 struct cmd_showportall_result *res = parsed_result;
7610 if (!strcmp(res->show, "clear")) {
7611 if (!strcmp(res->what, "stats"))
7612 RTE_ETH_FOREACH_DEV(i)
7614 else if (!strcmp(res->what, "xstats"))
7615 RTE_ETH_FOREACH_DEV(i)
7616 nic_xstats_clear(i);
7617 } else if (!strcmp(res->what, "info"))
7618 RTE_ETH_FOREACH_DEV(i)
7619 port_infos_display(i);
7620 else if (!strcmp(res->what, "summary")) {
7621 port_summary_header_display();
7622 RTE_ETH_FOREACH_DEV(i)
7623 port_summary_display(i);
7625 else if (!strcmp(res->what, "stats"))
7626 RTE_ETH_FOREACH_DEV(i)
7627 nic_stats_display(i);
7628 else if (!strcmp(res->what, "xstats"))
7629 RTE_ETH_FOREACH_DEV(i)
7630 nic_xstats_display(i);
7631 else if (!strcmp(res->what, "fdir"))
7632 RTE_ETH_FOREACH_DEV(i)
7634 else if (!strcmp(res->what, "stat_qmap"))
7635 RTE_ETH_FOREACH_DEV(i)
7636 nic_stats_mapping_display(i);
7637 else if (!strcmp(res->what, "dcb_tc"))
7638 RTE_ETH_FOREACH_DEV(i)
7639 port_dcb_info_display(i);
7640 else if (!strcmp(res->what, "cap"))
7641 RTE_ETH_FOREACH_DEV(i)
7642 port_offload_cap_display(i);
7645 cmdline_parse_token_string_t cmd_showportall_show =
7646 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7648 cmdline_parse_token_string_t cmd_showportall_port =
7649 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7650 cmdline_parse_token_string_t cmd_showportall_what =
7651 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7652 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7653 cmdline_parse_token_string_t cmd_showportall_all =
7654 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7655 cmdline_parse_inst_t cmd_showportall = {
7656 .f = cmd_showportall_parsed,
7658 .help_str = "show|clear port "
7659 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
7661 (void *)&cmd_showportall_show,
7662 (void *)&cmd_showportall_port,
7663 (void *)&cmd_showportall_what,
7664 (void *)&cmd_showportall_all,
7669 /* *** SHOW PORT INFO *** */
7670 struct cmd_showport_result {
7671 cmdline_fixed_string_t show;
7672 cmdline_fixed_string_t port;
7673 cmdline_fixed_string_t what;
7677 static void cmd_showport_parsed(void *parsed_result,
7678 __rte_unused struct cmdline *cl,
7679 __rte_unused void *data)
7681 struct cmd_showport_result *res = parsed_result;
7682 if (!strcmp(res->show, "clear")) {
7683 if (!strcmp(res->what, "stats"))
7684 nic_stats_clear(res->portnum);
7685 else if (!strcmp(res->what, "xstats"))
7686 nic_xstats_clear(res->portnum);
7687 } else if (!strcmp(res->what, "info"))
7688 port_infos_display(res->portnum);
7689 else if (!strcmp(res->what, "summary")) {
7690 port_summary_header_display();
7691 port_summary_display(res->portnum);
7693 else if (!strcmp(res->what, "stats"))
7694 nic_stats_display(res->portnum);
7695 else if (!strcmp(res->what, "xstats"))
7696 nic_xstats_display(res->portnum);
7697 else if (!strcmp(res->what, "fdir"))
7698 fdir_get_infos(res->portnum);
7699 else if (!strcmp(res->what, "stat_qmap"))
7700 nic_stats_mapping_display(res->portnum);
7701 else if (!strcmp(res->what, "dcb_tc"))
7702 port_dcb_info_display(res->portnum);
7703 else if (!strcmp(res->what, "cap"))
7704 port_offload_cap_display(res->portnum);
7707 cmdline_parse_token_string_t cmd_showport_show =
7708 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7710 cmdline_parse_token_string_t cmd_showport_port =
7711 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7712 cmdline_parse_token_string_t cmd_showport_what =
7713 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7714 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7715 cmdline_parse_token_num_t cmd_showport_portnum =
7716 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
7718 cmdline_parse_inst_t cmd_showport = {
7719 .f = cmd_showport_parsed,
7721 .help_str = "show|clear port "
7722 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
7725 (void *)&cmd_showport_show,
7726 (void *)&cmd_showport_port,
7727 (void *)&cmd_showport_what,
7728 (void *)&cmd_showport_portnum,
7733 /* *** SHOW DEVICE INFO *** */
7734 struct cmd_showdevice_result {
7735 cmdline_fixed_string_t show;
7736 cmdline_fixed_string_t device;
7737 cmdline_fixed_string_t what;
7738 cmdline_fixed_string_t identifier;
7741 static void cmd_showdevice_parsed(void *parsed_result,
7742 __rte_unused struct cmdline *cl,
7743 __rte_unused void *data)
7745 struct cmd_showdevice_result *res = parsed_result;
7746 if (!strcmp(res->what, "info")) {
7747 if (!strcmp(res->identifier, "all"))
7748 device_infos_display(NULL);
7750 device_infos_display(res->identifier);
7754 cmdline_parse_token_string_t cmd_showdevice_show =
7755 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show,
7757 cmdline_parse_token_string_t cmd_showdevice_device =
7758 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device");
7759 cmdline_parse_token_string_t cmd_showdevice_what =
7760 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what,
7762 cmdline_parse_token_string_t cmd_showdevice_identifier =
7763 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result,
7766 cmdline_parse_inst_t cmd_showdevice = {
7767 .f = cmd_showdevice_parsed,
7769 .help_str = "show device info <identifier>|all",
7771 (void *)&cmd_showdevice_show,
7772 (void *)&cmd_showdevice_device,
7773 (void *)&cmd_showdevice_what,
7774 (void *)&cmd_showdevice_identifier,
7779 /* *** SHOW MODULE EEPROM/EEPROM port INFO *** */
7780 struct cmd_showeeprom_result {
7781 cmdline_fixed_string_t show;
7782 cmdline_fixed_string_t port;
7784 cmdline_fixed_string_t type;
7787 static void cmd_showeeprom_parsed(void *parsed_result,
7788 __rte_unused struct cmdline *cl,
7789 __rte_unused void *data)
7791 struct cmd_showeeprom_result *res = parsed_result;
7793 if (!strcmp(res->type, "eeprom"))
7794 port_eeprom_display(res->portnum);
7795 else if (!strcmp(res->type, "module_eeprom"))
7796 port_module_eeprom_display(res->portnum);
7798 printf("Unknown argument\n");
7801 cmdline_parse_token_string_t cmd_showeeprom_show =
7802 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, show, "show");
7803 cmdline_parse_token_string_t cmd_showeeprom_port =
7804 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, port, "port");
7805 cmdline_parse_token_num_t cmd_showeeprom_portnum =
7806 TOKEN_NUM_INITIALIZER(struct cmd_showeeprom_result, portnum, UINT16);
7807 cmdline_parse_token_string_t cmd_showeeprom_type =
7808 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, type, "module_eeprom#eeprom");
7810 cmdline_parse_inst_t cmd_showeeprom = {
7811 .f = cmd_showeeprom_parsed,
7813 .help_str = "show port <port_id> module_eeprom|eeprom",
7815 (void *)&cmd_showeeprom_show,
7816 (void *)&cmd_showeeprom_port,
7817 (void *)&cmd_showeeprom_portnum,
7818 (void *)&cmd_showeeprom_type,
7823 /* *** SHOW QUEUE INFO *** */
7824 struct cmd_showqueue_result {
7825 cmdline_fixed_string_t show;
7826 cmdline_fixed_string_t type;
7827 cmdline_fixed_string_t what;
7833 cmd_showqueue_parsed(void *parsed_result,
7834 __rte_unused struct cmdline *cl,
7835 __rte_unused void *data)
7837 struct cmd_showqueue_result *res = parsed_result;
7839 if (!strcmp(res->type, "rxq"))
7840 rx_queue_infos_display(res->portnum, res->queuenum);
7841 else if (!strcmp(res->type, "txq"))
7842 tx_queue_infos_display(res->portnum, res->queuenum);
7845 cmdline_parse_token_string_t cmd_showqueue_show =
7846 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
7847 cmdline_parse_token_string_t cmd_showqueue_type =
7848 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
7849 cmdline_parse_token_string_t cmd_showqueue_what =
7850 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
7851 cmdline_parse_token_num_t cmd_showqueue_portnum =
7852 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16);
7853 cmdline_parse_token_num_t cmd_showqueue_queuenum =
7854 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
7856 cmdline_parse_inst_t cmd_showqueue = {
7857 .f = cmd_showqueue_parsed,
7859 .help_str = "show rxq|txq info <port_id> <queue_id>",
7861 (void *)&cmd_showqueue_show,
7862 (void *)&cmd_showqueue_type,
7863 (void *)&cmd_showqueue_what,
7864 (void *)&cmd_showqueue_portnum,
7865 (void *)&cmd_showqueue_queuenum,
7870 /* show/clear fwd engine statistics */
7872 cmdline_fixed_string_t action;
7873 cmdline_fixed_string_t fwd;
7874 cmdline_fixed_string_t stats;
7875 cmdline_fixed_string_t all;
7878 cmdline_parse_token_string_t cmd_fwd_action =
7879 TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
7880 cmdline_parse_token_string_t cmd_fwd_fwd =
7881 TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
7882 cmdline_parse_token_string_t cmd_fwd_stats =
7883 TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
7884 cmdline_parse_token_string_t cmd_fwd_all =
7885 TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
7888 cmd_showfwdall_parsed(void *parsed_result,
7889 __rte_unused struct cmdline *cl,
7890 __rte_unused void *data)
7892 struct fwd_result *res = parsed_result;
7894 if (!strcmp(res->action, "show"))
7895 fwd_stats_display();
7900 static cmdline_parse_inst_t cmd_showfwdall = {
7901 .f = cmd_showfwdall_parsed,
7903 .help_str = "show|clear fwd stats all",
7905 (void *)&cmd_fwd_action,
7906 (void *)&cmd_fwd_fwd,
7907 (void *)&cmd_fwd_stats,
7908 (void *)&cmd_fwd_all,
7913 /* *** READ PORT REGISTER *** */
7914 struct cmd_read_reg_result {
7915 cmdline_fixed_string_t read;
7916 cmdline_fixed_string_t reg;
7922 cmd_read_reg_parsed(void *parsed_result,
7923 __rte_unused struct cmdline *cl,
7924 __rte_unused void *data)
7926 struct cmd_read_reg_result *res = parsed_result;
7927 port_reg_display(res->port_id, res->reg_off);
7930 cmdline_parse_token_string_t cmd_read_reg_read =
7931 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
7932 cmdline_parse_token_string_t cmd_read_reg_reg =
7933 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
7934 cmdline_parse_token_num_t cmd_read_reg_port_id =
7935 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16);
7936 cmdline_parse_token_num_t cmd_read_reg_reg_off =
7937 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
7939 cmdline_parse_inst_t cmd_read_reg = {
7940 .f = cmd_read_reg_parsed,
7942 .help_str = "read reg <port_id> <reg_off>",
7944 (void *)&cmd_read_reg_read,
7945 (void *)&cmd_read_reg_reg,
7946 (void *)&cmd_read_reg_port_id,
7947 (void *)&cmd_read_reg_reg_off,
7952 /* *** READ PORT REGISTER BIT FIELD *** */
7953 struct cmd_read_reg_bit_field_result {
7954 cmdline_fixed_string_t read;
7955 cmdline_fixed_string_t regfield;
7963 cmd_read_reg_bit_field_parsed(void *parsed_result,
7964 __rte_unused struct cmdline *cl,
7965 __rte_unused void *data)
7967 struct cmd_read_reg_bit_field_result *res = parsed_result;
7968 port_reg_bit_field_display(res->port_id, res->reg_off,
7969 res->bit1_pos, res->bit2_pos);
7972 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
7973 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
7975 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
7976 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
7977 regfield, "regfield");
7978 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
7979 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
7981 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
7982 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
7984 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
7985 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
7987 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
7988 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
7991 cmdline_parse_inst_t cmd_read_reg_bit_field = {
7992 .f = cmd_read_reg_bit_field_parsed,
7994 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
7995 "Read register bit field between bit_x and bit_y included",
7997 (void *)&cmd_read_reg_bit_field_read,
7998 (void *)&cmd_read_reg_bit_field_regfield,
7999 (void *)&cmd_read_reg_bit_field_port_id,
8000 (void *)&cmd_read_reg_bit_field_reg_off,
8001 (void *)&cmd_read_reg_bit_field_bit1_pos,
8002 (void *)&cmd_read_reg_bit_field_bit2_pos,
8007 /* *** READ PORT REGISTER BIT *** */
8008 struct cmd_read_reg_bit_result {
8009 cmdline_fixed_string_t read;
8010 cmdline_fixed_string_t regbit;
8017 cmd_read_reg_bit_parsed(void *parsed_result,
8018 __rte_unused struct cmdline *cl,
8019 __rte_unused void *data)
8021 struct cmd_read_reg_bit_result *res = parsed_result;
8022 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
8025 cmdline_parse_token_string_t cmd_read_reg_bit_read =
8026 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
8027 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
8028 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
8030 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
8031 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16);
8032 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
8033 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
8034 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
8035 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
8037 cmdline_parse_inst_t cmd_read_reg_bit = {
8038 .f = cmd_read_reg_bit_parsed,
8040 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
8042 (void *)&cmd_read_reg_bit_read,
8043 (void *)&cmd_read_reg_bit_regbit,
8044 (void *)&cmd_read_reg_bit_port_id,
8045 (void *)&cmd_read_reg_bit_reg_off,
8046 (void *)&cmd_read_reg_bit_bit_pos,
8051 /* *** WRITE PORT REGISTER *** */
8052 struct cmd_write_reg_result {
8053 cmdline_fixed_string_t write;
8054 cmdline_fixed_string_t reg;
8061 cmd_write_reg_parsed(void *parsed_result,
8062 __rte_unused struct cmdline *cl,
8063 __rte_unused void *data)
8065 struct cmd_write_reg_result *res = parsed_result;
8066 port_reg_set(res->port_id, res->reg_off, res->value);
8069 cmdline_parse_token_string_t cmd_write_reg_write =
8070 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
8071 cmdline_parse_token_string_t cmd_write_reg_reg =
8072 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
8073 cmdline_parse_token_num_t cmd_write_reg_port_id =
8074 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16);
8075 cmdline_parse_token_num_t cmd_write_reg_reg_off =
8076 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
8077 cmdline_parse_token_num_t cmd_write_reg_value =
8078 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
8080 cmdline_parse_inst_t cmd_write_reg = {
8081 .f = cmd_write_reg_parsed,
8083 .help_str = "write reg <port_id> <reg_off> <reg_value>",
8085 (void *)&cmd_write_reg_write,
8086 (void *)&cmd_write_reg_reg,
8087 (void *)&cmd_write_reg_port_id,
8088 (void *)&cmd_write_reg_reg_off,
8089 (void *)&cmd_write_reg_value,
8094 /* *** WRITE PORT REGISTER BIT FIELD *** */
8095 struct cmd_write_reg_bit_field_result {
8096 cmdline_fixed_string_t write;
8097 cmdline_fixed_string_t regfield;
8106 cmd_write_reg_bit_field_parsed(void *parsed_result,
8107 __rte_unused struct cmdline *cl,
8108 __rte_unused void *data)
8110 struct cmd_write_reg_bit_field_result *res = parsed_result;
8111 port_reg_bit_field_set(res->port_id, res->reg_off,
8112 res->bit1_pos, res->bit2_pos, res->value);
8115 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
8116 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
8118 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
8119 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
8120 regfield, "regfield");
8121 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
8122 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
8124 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
8125 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
8127 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
8128 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
8130 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
8131 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
8133 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
8134 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
8137 cmdline_parse_inst_t cmd_write_reg_bit_field = {
8138 .f = cmd_write_reg_bit_field_parsed,
8140 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
8142 "Set register bit field between bit_x and bit_y included",
8144 (void *)&cmd_write_reg_bit_field_write,
8145 (void *)&cmd_write_reg_bit_field_regfield,
8146 (void *)&cmd_write_reg_bit_field_port_id,
8147 (void *)&cmd_write_reg_bit_field_reg_off,
8148 (void *)&cmd_write_reg_bit_field_bit1_pos,
8149 (void *)&cmd_write_reg_bit_field_bit2_pos,
8150 (void *)&cmd_write_reg_bit_field_value,
8155 /* *** WRITE PORT REGISTER BIT *** */
8156 struct cmd_write_reg_bit_result {
8157 cmdline_fixed_string_t write;
8158 cmdline_fixed_string_t regbit;
8166 cmd_write_reg_bit_parsed(void *parsed_result,
8167 __rte_unused struct cmdline *cl,
8168 __rte_unused void *data)
8170 struct cmd_write_reg_bit_result *res = parsed_result;
8171 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
8174 cmdline_parse_token_string_t cmd_write_reg_bit_write =
8175 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
8177 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
8178 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
8180 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
8181 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16);
8182 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
8183 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
8184 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
8185 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
8186 cmdline_parse_token_num_t cmd_write_reg_bit_value =
8187 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
8189 cmdline_parse_inst_t cmd_write_reg_bit = {
8190 .f = cmd_write_reg_bit_parsed,
8192 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
8195 (void *)&cmd_write_reg_bit_write,
8196 (void *)&cmd_write_reg_bit_regbit,
8197 (void *)&cmd_write_reg_bit_port_id,
8198 (void *)&cmd_write_reg_bit_reg_off,
8199 (void *)&cmd_write_reg_bit_bit_pos,
8200 (void *)&cmd_write_reg_bit_value,
8205 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
8206 struct cmd_read_rxd_txd_result {
8207 cmdline_fixed_string_t read;
8208 cmdline_fixed_string_t rxd_txd;
8215 cmd_read_rxd_txd_parsed(void *parsed_result,
8216 __rte_unused struct cmdline *cl,
8217 __rte_unused void *data)
8219 struct cmd_read_rxd_txd_result *res = parsed_result;
8221 if (!strcmp(res->rxd_txd, "rxd"))
8222 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8223 else if (!strcmp(res->rxd_txd, "txd"))
8224 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8227 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
8228 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
8229 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
8230 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
8232 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
8233 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16);
8234 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
8235 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
8236 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
8237 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
8239 cmdline_parse_inst_t cmd_read_rxd_txd = {
8240 .f = cmd_read_rxd_txd_parsed,
8242 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
8244 (void *)&cmd_read_rxd_txd_read,
8245 (void *)&cmd_read_rxd_txd_rxd_txd,
8246 (void *)&cmd_read_rxd_txd_port_id,
8247 (void *)&cmd_read_rxd_txd_queue_id,
8248 (void *)&cmd_read_rxd_txd_desc_id,
8254 struct cmd_quit_result {
8255 cmdline_fixed_string_t quit;
8258 static void cmd_quit_parsed(__rte_unused void *parsed_result,
8260 __rte_unused void *data)
8265 cmdline_parse_token_string_t cmd_quit_quit =
8266 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
8268 cmdline_parse_inst_t cmd_quit = {
8269 .f = cmd_quit_parsed,
8271 .help_str = "quit: Exit application",
8273 (void *)&cmd_quit_quit,
8278 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
8279 struct cmd_mac_addr_result {
8280 cmdline_fixed_string_t mac_addr_cmd;
8281 cmdline_fixed_string_t what;
8283 struct rte_ether_addr address;
8286 static void cmd_mac_addr_parsed(void *parsed_result,
8287 __rte_unused struct cmdline *cl,
8288 __rte_unused void *data)
8290 struct cmd_mac_addr_result *res = parsed_result;
8293 if (strcmp(res->what, "add") == 0)
8294 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
8295 else if (strcmp(res->what, "set") == 0)
8296 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
8299 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
8301 /* check the return value and print it if is < 0 */
8303 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
8307 cmdline_parse_token_string_t cmd_mac_addr_cmd =
8308 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
8310 cmdline_parse_token_string_t cmd_mac_addr_what =
8311 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
8313 cmdline_parse_token_num_t cmd_mac_addr_portnum =
8314 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
8316 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
8317 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
8319 cmdline_parse_inst_t cmd_mac_addr = {
8320 .f = cmd_mac_addr_parsed,
8322 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
8323 "Add/Remove/Set MAC address on port_id",
8325 (void *)&cmd_mac_addr_cmd,
8326 (void *)&cmd_mac_addr_what,
8327 (void *)&cmd_mac_addr_portnum,
8328 (void *)&cmd_mac_addr_addr,
8333 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
8334 struct cmd_eth_peer_result {
8335 cmdline_fixed_string_t set;
8336 cmdline_fixed_string_t eth_peer;
8338 cmdline_fixed_string_t peer_addr;
8341 static void cmd_set_eth_peer_parsed(void *parsed_result,
8342 __rte_unused struct cmdline *cl,
8343 __rte_unused void *data)
8345 struct cmd_eth_peer_result *res = parsed_result;
8347 if (test_done == 0) {
8348 printf("Please stop forwarding first\n");
8351 if (!strcmp(res->eth_peer, "eth-peer")) {
8352 set_fwd_eth_peer(res->port_id, res->peer_addr);
8356 cmdline_parse_token_string_t cmd_eth_peer_set =
8357 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
8358 cmdline_parse_token_string_t cmd_eth_peer =
8359 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
8360 cmdline_parse_token_num_t cmd_eth_peer_port_id =
8361 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, UINT16);
8362 cmdline_parse_token_string_t cmd_eth_peer_addr =
8363 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
8365 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
8366 .f = cmd_set_eth_peer_parsed,
8368 .help_str = "set eth-peer <port_id> <peer_mac>",
8370 (void *)&cmd_eth_peer_set,
8371 (void *)&cmd_eth_peer,
8372 (void *)&cmd_eth_peer_port_id,
8373 (void *)&cmd_eth_peer_addr,
8378 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
8379 struct cmd_set_qmap_result {
8380 cmdline_fixed_string_t set;
8381 cmdline_fixed_string_t qmap;
8382 cmdline_fixed_string_t what;
8389 cmd_set_qmap_parsed(void *parsed_result,
8390 __rte_unused struct cmdline *cl,
8391 __rte_unused void *data)
8393 struct cmd_set_qmap_result *res = parsed_result;
8394 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
8396 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
8399 cmdline_parse_token_string_t cmd_setqmap_set =
8400 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8402 cmdline_parse_token_string_t cmd_setqmap_qmap =
8403 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8405 cmdline_parse_token_string_t cmd_setqmap_what =
8406 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8408 cmdline_parse_token_num_t cmd_setqmap_portid =
8409 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8411 cmdline_parse_token_num_t cmd_setqmap_queueid =
8412 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8414 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
8415 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8418 cmdline_parse_inst_t cmd_set_qmap = {
8419 .f = cmd_set_qmap_parsed,
8421 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
8422 "Set statistics mapping value on tx|rx queue_id of port_id",
8424 (void *)&cmd_setqmap_set,
8425 (void *)&cmd_setqmap_qmap,
8426 (void *)&cmd_setqmap_what,
8427 (void *)&cmd_setqmap_portid,
8428 (void *)&cmd_setqmap_queueid,
8429 (void *)&cmd_setqmap_mapvalue,
8434 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
8435 struct cmd_set_xstats_hide_zero_result {
8436 cmdline_fixed_string_t keyword;
8437 cmdline_fixed_string_t name;
8438 cmdline_fixed_string_t on_off;
8442 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
8443 __rte_unused struct cmdline *cl,
8444 __rte_unused void *data)
8446 struct cmd_set_xstats_hide_zero_result *res;
8447 uint16_t on_off = 0;
8449 res = parsed_result;
8450 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8451 set_xstats_hide_zero(on_off);
8454 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
8455 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8457 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
8458 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8459 name, "xstats-hide-zero");
8460 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
8461 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8464 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
8465 .f = cmd_set_xstats_hide_zero_parsed,
8467 .help_str = "set xstats-hide-zero on|off",
8469 (void *)&cmd_set_xstats_hide_zero_keyword,
8470 (void *)&cmd_set_xstats_hide_zero_name,
8471 (void *)&cmd_set_xstats_hide_zero_on_off,
8476 /* *** SET OPTION TO ENABLE MEASUREMENT OF CPU CYCLES *** */
8477 struct cmd_set_record_core_cycles_result {
8478 cmdline_fixed_string_t keyword;
8479 cmdline_fixed_string_t name;
8480 cmdline_fixed_string_t on_off;
8484 cmd_set_record_core_cycles_parsed(void *parsed_result,
8485 __rte_unused struct cmdline *cl,
8486 __rte_unused void *data)
8488 struct cmd_set_record_core_cycles_result *res;
8489 uint16_t on_off = 0;
8491 res = parsed_result;
8492 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8493 set_record_core_cycles(on_off);
8496 cmdline_parse_token_string_t cmd_set_record_core_cycles_keyword =
8497 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8499 cmdline_parse_token_string_t cmd_set_record_core_cycles_name =
8500 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8501 name, "record-core-cycles");
8502 cmdline_parse_token_string_t cmd_set_record_core_cycles_on_off =
8503 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8506 cmdline_parse_inst_t cmd_set_record_core_cycles = {
8507 .f = cmd_set_record_core_cycles_parsed,
8509 .help_str = "set record-core-cycles on|off",
8511 (void *)&cmd_set_record_core_cycles_keyword,
8512 (void *)&cmd_set_record_core_cycles_name,
8513 (void *)&cmd_set_record_core_cycles_on_off,
8518 /* *** SET OPTION TO ENABLE DISPLAY OF RX AND TX BURSTS *** */
8519 struct cmd_set_record_burst_stats_result {
8520 cmdline_fixed_string_t keyword;
8521 cmdline_fixed_string_t name;
8522 cmdline_fixed_string_t on_off;
8526 cmd_set_record_burst_stats_parsed(void *parsed_result,
8527 __rte_unused struct cmdline *cl,
8528 __rte_unused void *data)
8530 struct cmd_set_record_burst_stats_result *res;
8531 uint16_t on_off = 0;
8533 res = parsed_result;
8534 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8535 set_record_burst_stats(on_off);
8538 cmdline_parse_token_string_t cmd_set_record_burst_stats_keyword =
8539 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8541 cmdline_parse_token_string_t cmd_set_record_burst_stats_name =
8542 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8543 name, "record-burst-stats");
8544 cmdline_parse_token_string_t cmd_set_record_burst_stats_on_off =
8545 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8548 cmdline_parse_inst_t cmd_set_record_burst_stats = {
8549 .f = cmd_set_record_burst_stats_parsed,
8551 .help_str = "set record-burst-stats on|off",
8553 (void *)&cmd_set_record_burst_stats_keyword,
8554 (void *)&cmd_set_record_burst_stats_name,
8555 (void *)&cmd_set_record_burst_stats_on_off,
8560 /* *** CONFIGURE UNICAST HASH TABLE *** */
8561 struct cmd_set_uc_hash_table {
8562 cmdline_fixed_string_t set;
8563 cmdline_fixed_string_t port;
8565 cmdline_fixed_string_t what;
8566 struct rte_ether_addr address;
8567 cmdline_fixed_string_t mode;
8571 cmd_set_uc_hash_parsed(void *parsed_result,
8572 __rte_unused struct cmdline *cl,
8573 __rte_unused void *data)
8576 struct cmd_set_uc_hash_table *res = parsed_result;
8578 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8580 if (strcmp(res->what, "uta") == 0)
8581 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
8582 &res->address,(uint8_t)is_on);
8584 printf("bad unicast hash table parameter, return code = %d \n", ret);
8588 cmdline_parse_token_string_t cmd_set_uc_hash_set =
8589 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8591 cmdline_parse_token_string_t cmd_set_uc_hash_port =
8592 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8594 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
8595 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
8597 cmdline_parse_token_string_t cmd_set_uc_hash_what =
8598 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8600 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
8601 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
8603 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
8604 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8607 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
8608 .f = cmd_set_uc_hash_parsed,
8610 .help_str = "set port <port_id> uta <mac_addr> on|off)",
8612 (void *)&cmd_set_uc_hash_set,
8613 (void *)&cmd_set_uc_hash_port,
8614 (void *)&cmd_set_uc_hash_portid,
8615 (void *)&cmd_set_uc_hash_what,
8616 (void *)&cmd_set_uc_hash_mac,
8617 (void *)&cmd_set_uc_hash_mode,
8622 struct cmd_set_uc_all_hash_table {
8623 cmdline_fixed_string_t set;
8624 cmdline_fixed_string_t port;
8626 cmdline_fixed_string_t what;
8627 cmdline_fixed_string_t value;
8628 cmdline_fixed_string_t mode;
8632 cmd_set_uc_all_hash_parsed(void *parsed_result,
8633 __rte_unused struct cmdline *cl,
8634 __rte_unused void *data)
8637 struct cmd_set_uc_all_hash_table *res = parsed_result;
8639 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8641 if ((strcmp(res->what, "uta") == 0) &&
8642 (strcmp(res->value, "all") == 0))
8643 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
8645 printf("bad unicast hash table parameter,"
8646 "return code = %d \n", ret);
8649 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
8650 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8652 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
8653 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8655 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
8656 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
8658 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
8659 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8661 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
8662 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8664 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
8665 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8668 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
8669 .f = cmd_set_uc_all_hash_parsed,
8671 .help_str = "set port <port_id> uta all on|off",
8673 (void *)&cmd_set_uc_all_hash_set,
8674 (void *)&cmd_set_uc_all_hash_port,
8675 (void *)&cmd_set_uc_all_hash_portid,
8676 (void *)&cmd_set_uc_all_hash_what,
8677 (void *)&cmd_set_uc_all_hash_value,
8678 (void *)&cmd_set_uc_all_hash_mode,
8683 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
8684 struct cmd_set_vf_traffic {
8685 cmdline_fixed_string_t set;
8686 cmdline_fixed_string_t port;
8688 cmdline_fixed_string_t vf;
8690 cmdline_fixed_string_t what;
8691 cmdline_fixed_string_t mode;
8695 cmd_set_vf_traffic_parsed(void *parsed_result,
8696 __rte_unused struct cmdline *cl,
8697 __rte_unused void *data)
8699 struct cmd_set_vf_traffic *res = parsed_result;
8700 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
8701 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8703 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
8706 cmdline_parse_token_string_t cmd_setvf_traffic_set =
8707 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8709 cmdline_parse_token_string_t cmd_setvf_traffic_port =
8710 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8712 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8713 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8715 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8716 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8718 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8719 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8721 cmdline_parse_token_string_t cmd_setvf_traffic_what =
8722 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8724 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8725 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8728 cmdline_parse_inst_t cmd_set_vf_traffic = {
8729 .f = cmd_set_vf_traffic_parsed,
8731 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8733 (void *)&cmd_setvf_traffic_set,
8734 (void *)&cmd_setvf_traffic_port,
8735 (void *)&cmd_setvf_traffic_portid,
8736 (void *)&cmd_setvf_traffic_vf,
8737 (void *)&cmd_setvf_traffic_vfid,
8738 (void *)&cmd_setvf_traffic_what,
8739 (void *)&cmd_setvf_traffic_mode,
8744 /* *** CONFIGURE VF RECEIVE MODE *** */
8745 struct cmd_set_vf_rxmode {
8746 cmdline_fixed_string_t set;
8747 cmdline_fixed_string_t port;
8749 cmdline_fixed_string_t vf;
8751 cmdline_fixed_string_t what;
8752 cmdline_fixed_string_t mode;
8753 cmdline_fixed_string_t on;
8757 cmd_set_vf_rxmode_parsed(void *parsed_result,
8758 __rte_unused struct cmdline *cl,
8759 __rte_unused void *data)
8762 uint16_t vf_rxmode = 0;
8763 struct cmd_set_vf_rxmode *res = parsed_result;
8765 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8766 if (!strcmp(res->what,"rxmode")) {
8767 if (!strcmp(res->mode, "AUPE"))
8768 vf_rxmode |= ETH_VMDQ_ACCEPT_UNTAG;
8769 else if (!strcmp(res->mode, "ROPE"))
8770 vf_rxmode |= ETH_VMDQ_ACCEPT_HASH_UC;
8771 else if (!strcmp(res->mode, "BAM"))
8772 vf_rxmode |= ETH_VMDQ_ACCEPT_BROADCAST;
8773 else if (!strncmp(res->mode, "MPE",3))
8774 vf_rxmode |= ETH_VMDQ_ACCEPT_MULTICAST;
8777 RTE_SET_USED(is_on);
8779 #ifdef RTE_NET_IXGBE
8780 if (ret == -ENOTSUP)
8781 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8782 vf_rxmode, (uint8_t)is_on);
8785 if (ret == -ENOTSUP)
8786 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8787 vf_rxmode, (uint8_t)is_on);
8790 printf("bad VF receive mode parameter, return code = %d \n",
8794 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8795 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8797 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8798 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8800 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8801 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8803 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8804 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8806 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8807 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8809 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
8810 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8812 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
8813 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8814 mode, "AUPE#ROPE#BAM#MPE");
8815 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
8816 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8819 cmdline_parse_inst_t cmd_set_vf_rxmode = {
8820 .f = cmd_set_vf_rxmode_parsed,
8822 .help_str = "set port <port_id> vf <vf_id> rxmode "
8823 "AUPE|ROPE|BAM|MPE on|off",
8825 (void *)&cmd_set_vf_rxmode_set,
8826 (void *)&cmd_set_vf_rxmode_port,
8827 (void *)&cmd_set_vf_rxmode_portid,
8828 (void *)&cmd_set_vf_rxmode_vf,
8829 (void *)&cmd_set_vf_rxmode_vfid,
8830 (void *)&cmd_set_vf_rxmode_what,
8831 (void *)&cmd_set_vf_rxmode_mode,
8832 (void *)&cmd_set_vf_rxmode_on,
8837 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
8838 struct cmd_vf_mac_addr_result {
8839 cmdline_fixed_string_t mac_addr_cmd;
8840 cmdline_fixed_string_t what;
8841 cmdline_fixed_string_t port;
8843 cmdline_fixed_string_t vf;
8845 struct rte_ether_addr address;
8848 static void cmd_vf_mac_addr_parsed(void *parsed_result,
8849 __rte_unused struct cmdline *cl,
8850 __rte_unused void *data)
8852 struct cmd_vf_mac_addr_result *res = parsed_result;
8855 if (strcmp(res->what, "add") != 0)
8859 if (ret == -ENOTSUP)
8860 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
8864 if (ret == -ENOTSUP)
8865 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
8870 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
8874 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
8875 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8876 mac_addr_cmd,"mac_addr");
8877 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
8878 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8880 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
8881 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8883 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
8884 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8886 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
8887 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8889 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
8890 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8892 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
8893 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
8896 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
8897 .f = cmd_vf_mac_addr_parsed,
8899 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
8900 "Add MAC address filtering for a VF on port_id",
8902 (void *)&cmd_vf_mac_addr_cmd,
8903 (void *)&cmd_vf_mac_addr_what,
8904 (void *)&cmd_vf_mac_addr_port,
8905 (void *)&cmd_vf_mac_addr_portnum,
8906 (void *)&cmd_vf_mac_addr_vf,
8907 (void *)&cmd_vf_mac_addr_vfnum,
8908 (void *)&cmd_vf_mac_addr_addr,
8913 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
8914 struct cmd_vf_rx_vlan_filter {
8915 cmdline_fixed_string_t rx_vlan;
8916 cmdline_fixed_string_t what;
8918 cmdline_fixed_string_t port;
8920 cmdline_fixed_string_t vf;
8925 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
8926 __rte_unused struct cmdline *cl,
8927 __rte_unused void *data)
8929 struct cmd_vf_rx_vlan_filter *res = parsed_result;
8932 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
8934 #ifdef RTE_NET_IXGBE
8935 if (ret == -ENOTSUP)
8936 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
8937 res->vlan_id, res->vf_mask, is_add);
8940 if (ret == -ENOTSUP)
8941 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
8942 res->vlan_id, res->vf_mask, is_add);
8945 if (ret == -ENOTSUP)
8946 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
8947 res->vlan_id, res->vf_mask, is_add);
8954 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
8955 res->vlan_id, res->vf_mask);
8958 printf("invalid port_id %d\n", res->port_id);
8961 printf("function not implemented or supported\n");
8964 printf("programming error: (%s)\n", strerror(-ret));
8968 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
8969 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8970 rx_vlan, "rx_vlan");
8971 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
8972 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8974 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
8975 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8977 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
8978 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8980 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
8981 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8983 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
8984 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8986 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
8987 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8990 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
8991 .f = cmd_vf_rx_vlan_filter_parsed,
8993 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
8994 "(vf_mask = hexadecimal VF mask)",
8996 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
8997 (void *)&cmd_vf_rx_vlan_filter_what,
8998 (void *)&cmd_vf_rx_vlan_filter_vlanid,
8999 (void *)&cmd_vf_rx_vlan_filter_port,
9000 (void *)&cmd_vf_rx_vlan_filter_portid,
9001 (void *)&cmd_vf_rx_vlan_filter_vf,
9002 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
9007 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
9008 struct cmd_queue_rate_limit_result {
9009 cmdline_fixed_string_t set;
9010 cmdline_fixed_string_t port;
9012 cmdline_fixed_string_t queue;
9014 cmdline_fixed_string_t rate;
9018 static void cmd_queue_rate_limit_parsed(void *parsed_result,
9019 __rte_unused struct cmdline *cl,
9020 __rte_unused void *data)
9022 struct cmd_queue_rate_limit_result *res = parsed_result;
9025 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9026 && (strcmp(res->queue, "queue") == 0)
9027 && (strcmp(res->rate, "rate") == 0))
9028 ret = set_queue_rate_limit(res->port_num, res->queue_num,
9031 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
9035 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
9036 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9038 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
9039 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9041 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
9042 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9044 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
9045 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9047 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
9048 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9050 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
9051 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9053 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
9054 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9057 cmdline_parse_inst_t cmd_queue_rate_limit = {
9058 .f = cmd_queue_rate_limit_parsed,
9060 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
9061 "Set rate limit for a queue on port_id",
9063 (void *)&cmd_queue_rate_limit_set,
9064 (void *)&cmd_queue_rate_limit_port,
9065 (void *)&cmd_queue_rate_limit_portnum,
9066 (void *)&cmd_queue_rate_limit_queue,
9067 (void *)&cmd_queue_rate_limit_queuenum,
9068 (void *)&cmd_queue_rate_limit_rate,
9069 (void *)&cmd_queue_rate_limit_ratenum,
9074 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
9075 struct cmd_vf_rate_limit_result {
9076 cmdline_fixed_string_t set;
9077 cmdline_fixed_string_t port;
9079 cmdline_fixed_string_t vf;
9081 cmdline_fixed_string_t rate;
9083 cmdline_fixed_string_t q_msk;
9087 static void cmd_vf_rate_limit_parsed(void *parsed_result,
9088 __rte_unused struct cmdline *cl,
9089 __rte_unused void *data)
9091 struct cmd_vf_rate_limit_result *res = parsed_result;
9094 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9095 && (strcmp(res->vf, "vf") == 0)
9096 && (strcmp(res->rate, "rate") == 0)
9097 && (strcmp(res->q_msk, "queue_mask") == 0))
9098 ret = set_vf_rate_limit(res->port_num, res->vf_num,
9099 res->rate_num, res->q_msk_val);
9101 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
9105 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
9106 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9108 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
9109 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9111 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
9112 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9114 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
9115 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9117 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
9118 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9120 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
9121 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9123 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
9124 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9126 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
9127 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9128 q_msk, "queue_mask");
9129 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
9130 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9133 cmdline_parse_inst_t cmd_vf_rate_limit = {
9134 .f = cmd_vf_rate_limit_parsed,
9136 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
9137 "queue_mask <queue_mask_value>: "
9138 "Set rate limit for queues of VF on port_id",
9140 (void *)&cmd_vf_rate_limit_set,
9141 (void *)&cmd_vf_rate_limit_port,
9142 (void *)&cmd_vf_rate_limit_portnum,
9143 (void *)&cmd_vf_rate_limit_vf,
9144 (void *)&cmd_vf_rate_limit_vfnum,
9145 (void *)&cmd_vf_rate_limit_rate,
9146 (void *)&cmd_vf_rate_limit_ratenum,
9147 (void *)&cmd_vf_rate_limit_q_msk,
9148 (void *)&cmd_vf_rate_limit_q_msk_val,
9153 /* *** CONFIGURE TUNNEL UDP PORT *** */
9154 struct cmd_tunnel_udp_config {
9155 cmdline_fixed_string_t cmd;
9156 cmdline_fixed_string_t what;
9162 cmd_tunnel_udp_config_parsed(void *parsed_result,
9163 __rte_unused struct cmdline *cl,
9164 __rte_unused void *data)
9166 struct cmd_tunnel_udp_config *res = parsed_result;
9167 struct rte_eth_udp_tunnel tunnel_udp;
9170 tunnel_udp.udp_port = res->udp_port;
9172 if (!strcmp(res->cmd, "rx_vxlan_port"))
9173 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9175 if (!strcmp(res->what, "add"))
9176 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9179 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9183 printf("udp tunneling add error: (%s)\n", strerror(-ret));
9186 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
9187 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9188 cmd, "rx_vxlan_port");
9189 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
9190 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9192 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
9193 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9195 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
9196 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9199 cmdline_parse_inst_t cmd_tunnel_udp_config = {
9200 .f = cmd_tunnel_udp_config_parsed,
9202 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
9203 "Add/Remove a tunneling UDP port filter",
9205 (void *)&cmd_tunnel_udp_config_cmd,
9206 (void *)&cmd_tunnel_udp_config_what,
9207 (void *)&cmd_tunnel_udp_config_udp_port,
9208 (void *)&cmd_tunnel_udp_config_port_id,
9213 struct cmd_config_tunnel_udp_port {
9214 cmdline_fixed_string_t port;
9215 cmdline_fixed_string_t config;
9217 cmdline_fixed_string_t udp_tunnel_port;
9218 cmdline_fixed_string_t action;
9219 cmdline_fixed_string_t tunnel_type;
9224 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
9225 __rte_unused struct cmdline *cl,
9226 __rte_unused void *data)
9228 struct cmd_config_tunnel_udp_port *res = parsed_result;
9229 struct rte_eth_udp_tunnel tunnel_udp;
9232 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9235 tunnel_udp.udp_port = res->udp_port;
9237 if (!strcmp(res->tunnel_type, "vxlan")) {
9238 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9239 } else if (!strcmp(res->tunnel_type, "geneve")) {
9240 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE;
9241 } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
9242 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9244 printf("Invalid tunnel type\n");
9248 if (!strcmp(res->action, "add"))
9249 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9252 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9256 printf("udp tunneling port add error: (%s)\n", strerror(-ret));
9259 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
9260 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
9262 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
9263 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
9265 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
9266 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
9268 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
9269 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
9272 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
9273 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
9275 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
9276 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
9277 "vxlan#geneve#vxlan-gpe");
9278 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
9279 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
9282 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
9283 .f = cmd_cfg_tunnel_udp_port_parsed,
9285 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|geneve|vxlan-gpe <udp_port>",
9287 (void *)&cmd_config_tunnel_udp_port_port,
9288 (void *)&cmd_config_tunnel_udp_port_config,
9289 (void *)&cmd_config_tunnel_udp_port_port_id,
9290 (void *)&cmd_config_tunnel_udp_port_tunnel_port,
9291 (void *)&cmd_config_tunnel_udp_port_action,
9292 (void *)&cmd_config_tunnel_udp_port_tunnel_type,
9293 (void *)&cmd_config_tunnel_udp_port_value,
9298 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
9299 struct cmd_set_mirror_mask_result {
9300 cmdline_fixed_string_t set;
9301 cmdline_fixed_string_t port;
9303 cmdline_fixed_string_t mirror;
9305 cmdline_fixed_string_t what;
9306 cmdline_fixed_string_t value;
9307 cmdline_fixed_string_t dstpool;
9309 cmdline_fixed_string_t on;
9312 cmdline_parse_token_string_t cmd_mirror_mask_set =
9313 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9315 cmdline_parse_token_string_t cmd_mirror_mask_port =
9316 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9318 cmdline_parse_token_num_t cmd_mirror_mask_portid =
9319 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9321 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
9322 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9323 mirror, "mirror-rule");
9324 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
9325 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9327 cmdline_parse_token_string_t cmd_mirror_mask_what =
9328 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9329 what, "pool-mirror-up#pool-mirror-down"
9331 cmdline_parse_token_string_t cmd_mirror_mask_value =
9332 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9334 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
9335 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9336 dstpool, "dst-pool");
9337 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
9338 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9340 cmdline_parse_token_string_t cmd_mirror_mask_on =
9341 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9345 cmd_set_mirror_mask_parsed(void *parsed_result,
9346 __rte_unused struct cmdline *cl,
9347 __rte_unused void *data)
9350 struct cmd_set_mirror_mask_result *res = parsed_result;
9351 struct rte_eth_mirror_conf mr_conf;
9353 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9355 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
9357 mr_conf.dst_pool = res->dstpool_id;
9359 if (!strcmp(res->what, "pool-mirror-up")) {
9360 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9361 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
9362 } else if (!strcmp(res->what, "pool-mirror-down")) {
9363 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9364 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
9365 } else if (!strcmp(res->what, "vlan-mirror")) {
9366 mr_conf.rule_type = ETH_MIRROR_VLAN;
9367 nb_item = parse_item_list(res->value, "vlan",
9368 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
9372 for (i = 0; i < nb_item; i++) {
9373 if (vlan_list[i] > RTE_ETHER_MAX_VLAN_ID) {
9374 printf("Invalid vlan_id: must be < 4096\n");
9378 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
9379 mr_conf.vlan.vlan_mask |= 1ULL << i;
9383 if (!strcmp(res->on, "on"))
9384 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9387 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9390 printf("mirror rule add error: (%s)\n", strerror(-ret));
9393 cmdline_parse_inst_t cmd_set_mirror_mask = {
9394 .f = cmd_set_mirror_mask_parsed,
9396 .help_str = "set port <port_id> mirror-rule <rule_id> "
9397 "pool-mirror-up|pool-mirror-down|vlan-mirror "
9398 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
9400 (void *)&cmd_mirror_mask_set,
9401 (void *)&cmd_mirror_mask_port,
9402 (void *)&cmd_mirror_mask_portid,
9403 (void *)&cmd_mirror_mask_mirror,
9404 (void *)&cmd_mirror_mask_ruleid,
9405 (void *)&cmd_mirror_mask_what,
9406 (void *)&cmd_mirror_mask_value,
9407 (void *)&cmd_mirror_mask_dstpool,
9408 (void *)&cmd_mirror_mask_poolid,
9409 (void *)&cmd_mirror_mask_on,
9414 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
9415 struct cmd_set_mirror_link_result {
9416 cmdline_fixed_string_t set;
9417 cmdline_fixed_string_t port;
9419 cmdline_fixed_string_t mirror;
9421 cmdline_fixed_string_t what;
9422 cmdline_fixed_string_t dstpool;
9424 cmdline_fixed_string_t on;
9427 cmdline_parse_token_string_t cmd_mirror_link_set =
9428 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9430 cmdline_parse_token_string_t cmd_mirror_link_port =
9431 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9433 cmdline_parse_token_num_t cmd_mirror_link_portid =
9434 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9436 cmdline_parse_token_string_t cmd_mirror_link_mirror =
9437 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9438 mirror, "mirror-rule");
9439 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
9440 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9442 cmdline_parse_token_string_t cmd_mirror_link_what =
9443 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9444 what, "uplink-mirror#downlink-mirror");
9445 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
9446 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9447 dstpool, "dst-pool");
9448 cmdline_parse_token_num_t cmd_mirror_link_poolid =
9449 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9451 cmdline_parse_token_string_t cmd_mirror_link_on =
9452 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9456 cmd_set_mirror_link_parsed(void *parsed_result,
9457 __rte_unused struct cmdline *cl,
9458 __rte_unused void *data)
9461 struct cmd_set_mirror_link_result *res = parsed_result;
9462 struct rte_eth_mirror_conf mr_conf;
9464 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9465 if (!strcmp(res->what, "uplink-mirror"))
9466 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
9468 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
9470 mr_conf.dst_pool = res->dstpool_id;
9472 if (!strcmp(res->on, "on"))
9473 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9476 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9479 /* check the return value and print it if is < 0 */
9481 printf("mirror rule add error: (%s)\n", strerror(-ret));
9485 cmdline_parse_inst_t cmd_set_mirror_link = {
9486 .f = cmd_set_mirror_link_parsed,
9488 .help_str = "set port <port_id> mirror-rule <rule_id> "
9489 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
9491 (void *)&cmd_mirror_link_set,
9492 (void *)&cmd_mirror_link_port,
9493 (void *)&cmd_mirror_link_portid,
9494 (void *)&cmd_mirror_link_mirror,
9495 (void *)&cmd_mirror_link_ruleid,
9496 (void *)&cmd_mirror_link_what,
9497 (void *)&cmd_mirror_link_dstpool,
9498 (void *)&cmd_mirror_link_poolid,
9499 (void *)&cmd_mirror_link_on,
9504 /* *** RESET VM MIRROR RULE *** */
9505 struct cmd_rm_mirror_rule_result {
9506 cmdline_fixed_string_t reset;
9507 cmdline_fixed_string_t port;
9509 cmdline_fixed_string_t mirror;
9513 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
9514 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9516 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
9517 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9519 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
9520 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9522 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
9523 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9524 mirror, "mirror-rule");
9525 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
9526 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9530 cmd_reset_mirror_rule_parsed(void *parsed_result,
9531 __rte_unused struct cmdline *cl,
9532 __rte_unused void *data)
9535 struct cmd_set_mirror_link_result *res = parsed_result;
9537 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
9539 printf("mirror rule remove error: (%s)\n", strerror(-ret));
9542 cmdline_parse_inst_t cmd_reset_mirror_rule = {
9543 .f = cmd_reset_mirror_rule_parsed,
9545 .help_str = "reset port <port_id> mirror-rule <rule_id>",
9547 (void *)&cmd_rm_mirror_rule_reset,
9548 (void *)&cmd_rm_mirror_rule_port,
9549 (void *)&cmd_rm_mirror_rule_portid,
9550 (void *)&cmd_rm_mirror_rule_mirror,
9551 (void *)&cmd_rm_mirror_rule_ruleid,
9556 /* ******************************************************************************** */
9558 struct cmd_dump_result {
9559 cmdline_fixed_string_t dump;
9563 dump_struct_sizes(void)
9565 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9566 DUMP_SIZE(struct rte_mbuf);
9567 DUMP_SIZE(struct rte_mempool);
9568 DUMP_SIZE(struct rte_ring);
9573 /* Dump the socket memory statistics on console */
9575 dump_socket_mem(FILE *f)
9577 struct rte_malloc_socket_stats socket_stats;
9582 unsigned int n_alloc = 0;
9583 unsigned int n_free = 0;
9584 static size_t last_allocs;
9585 static size_t last_total;
9588 for (i = 0; i < RTE_MAX_NUMA_NODES; i++) {
9589 if (rte_malloc_get_socket_stats(i, &socket_stats) ||
9590 !socket_stats.heap_totalsz_bytes)
9592 total += socket_stats.heap_totalsz_bytes;
9593 alloc += socket_stats.heap_allocsz_bytes;
9594 free += socket_stats.heap_freesz_bytes;
9595 n_alloc += socket_stats.alloc_count;
9596 n_free += socket_stats.free_count;
9598 "Socket %u: size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9600 (double)socket_stats.heap_totalsz_bytes / (1024 * 1024),
9601 (double)socket_stats.heap_allocsz_bytes / (1024 * 1024),
9602 (double)socket_stats.heap_allocsz_bytes * 100 /
9603 (double)socket_stats.heap_totalsz_bytes,
9604 (double)socket_stats.heap_freesz_bytes / (1024 * 1024),
9605 socket_stats.alloc_count,
9606 socket_stats.free_count);
9609 "Total : size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9610 (double)total / (1024 * 1024), (double)alloc / (1024 * 1024),
9611 (double)alloc * 100 / (double)total,
9612 (double)free / (1024 * 1024),
9615 fprintf(stdout, "Memory total change: %.6lf(M), allocation change: %.6lf(M)\n",
9616 ((double)total - (double)last_total) / (1024 * 1024),
9617 (double)(alloc - (double)last_allocs) / 1024 / 1024);
9618 last_allocs = alloc;
9622 static void cmd_dump_parsed(void *parsed_result,
9623 __rte_unused struct cmdline *cl,
9624 __rte_unused void *data)
9626 struct cmd_dump_result *res = parsed_result;
9628 if (!strcmp(res->dump, "dump_physmem"))
9629 rte_dump_physmem_layout(stdout);
9630 else if (!strcmp(res->dump, "dump_socket_mem"))
9631 dump_socket_mem(stdout);
9632 else if (!strcmp(res->dump, "dump_memzone"))
9633 rte_memzone_dump(stdout);
9634 else if (!strcmp(res->dump, "dump_struct_sizes"))
9635 dump_struct_sizes();
9636 else if (!strcmp(res->dump, "dump_ring"))
9637 rte_ring_list_dump(stdout);
9638 else if (!strcmp(res->dump, "dump_mempool"))
9639 rte_mempool_list_dump(stdout);
9640 else if (!strcmp(res->dump, "dump_devargs"))
9641 rte_devargs_dump(stdout);
9642 else if (!strcmp(res->dump, "dump_log_types"))
9643 rte_log_dump(stdout);
9646 cmdline_parse_token_string_t cmd_dump_dump =
9647 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9651 "dump_struct_sizes#"
9657 cmdline_parse_inst_t cmd_dump = {
9658 .f = cmd_dump_parsed, /* function to call */
9659 .data = NULL, /* 2nd arg of func */
9660 .help_str = "Dump status",
9661 .tokens = { /* token list, NULL terminated */
9662 (void *)&cmd_dump_dump,
9667 /* ******************************************************************************** */
9669 struct cmd_dump_one_result {
9670 cmdline_fixed_string_t dump;
9671 cmdline_fixed_string_t name;
9674 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9675 __rte_unused void *data)
9677 struct cmd_dump_one_result *res = parsed_result;
9679 if (!strcmp(res->dump, "dump_ring")) {
9681 r = rte_ring_lookup(res->name);
9683 cmdline_printf(cl, "Cannot find ring\n");
9686 rte_ring_dump(stdout, r);
9687 } else if (!strcmp(res->dump, "dump_mempool")) {
9688 struct rte_mempool *mp;
9689 mp = rte_mempool_lookup(res->name);
9691 cmdline_printf(cl, "Cannot find mempool\n");
9694 rte_mempool_dump(stdout, mp);
9698 cmdline_parse_token_string_t cmd_dump_one_dump =
9699 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9700 "dump_ring#dump_mempool");
9702 cmdline_parse_token_string_t cmd_dump_one_name =
9703 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9705 cmdline_parse_inst_t cmd_dump_one = {
9706 .f = cmd_dump_one_parsed, /* function to call */
9707 .data = NULL, /* 2nd arg of func */
9708 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9709 .tokens = { /* token list, NULL terminated */
9710 (void *)&cmd_dump_one_dump,
9711 (void *)&cmd_dump_one_name,
9716 /* *** queue region set *** */
9717 struct cmd_queue_region_result {
9718 cmdline_fixed_string_t set;
9719 cmdline_fixed_string_t port;
9721 cmdline_fixed_string_t cmd;
9722 cmdline_fixed_string_t region;
9724 cmdline_fixed_string_t queue_start_index;
9726 cmdline_fixed_string_t queue_num;
9727 uint8_t queue_num_value;
9731 cmd_queue_region_parsed(void *parsed_result,
9732 __rte_unused struct cmdline *cl,
9733 __rte_unused void *data)
9735 struct cmd_queue_region_result *res = parsed_result;
9738 struct rte_pmd_i40e_queue_region_conf region_conf;
9739 enum rte_pmd_i40e_queue_region_op op_type;
9742 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9746 memset(®ion_conf, 0, sizeof(region_conf));
9747 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
9748 region_conf.region_id = res->region_id;
9749 region_conf.queue_num = res->queue_num_value;
9750 region_conf.queue_start_index = res->queue_id;
9752 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9753 op_type, ®ion_conf);
9760 printf("function not implemented or supported\n");
9763 printf("queue region config error: (%s)\n", strerror(-ret));
9767 cmdline_parse_token_string_t cmd_queue_region_set =
9768 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9770 cmdline_parse_token_string_t cmd_queue_region_port =
9771 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
9772 cmdline_parse_token_num_t cmd_queue_region_port_id =
9773 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9775 cmdline_parse_token_string_t cmd_queue_region_cmd =
9776 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9777 cmd, "queue-region");
9778 cmdline_parse_token_string_t cmd_queue_region_id =
9779 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9780 region, "region_id");
9781 cmdline_parse_token_num_t cmd_queue_region_index =
9782 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9784 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
9785 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9786 queue_start_index, "queue_start_index");
9787 cmdline_parse_token_num_t cmd_queue_region_queue_id =
9788 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9790 cmdline_parse_token_string_t cmd_queue_region_queue_num =
9791 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9792 queue_num, "queue_num");
9793 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
9794 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9795 queue_num_value, UINT8);
9797 cmdline_parse_inst_t cmd_queue_region = {
9798 .f = cmd_queue_region_parsed,
9800 .help_str = "set port <port_id> queue-region region_id <value> "
9801 "queue_start_index <value> queue_num <value>: Set a queue region",
9803 (void *)&cmd_queue_region_set,
9804 (void *)&cmd_queue_region_port,
9805 (void *)&cmd_queue_region_port_id,
9806 (void *)&cmd_queue_region_cmd,
9807 (void *)&cmd_queue_region_id,
9808 (void *)&cmd_queue_region_index,
9809 (void *)&cmd_queue_region_queue_start_index,
9810 (void *)&cmd_queue_region_queue_id,
9811 (void *)&cmd_queue_region_queue_num,
9812 (void *)&cmd_queue_region_queue_num_value,
9817 /* *** queue region and flowtype set *** */
9818 struct cmd_region_flowtype_result {
9819 cmdline_fixed_string_t set;
9820 cmdline_fixed_string_t port;
9822 cmdline_fixed_string_t cmd;
9823 cmdline_fixed_string_t region;
9825 cmdline_fixed_string_t flowtype;
9826 uint8_t flowtype_id;
9830 cmd_region_flowtype_parsed(void *parsed_result,
9831 __rte_unused struct cmdline *cl,
9832 __rte_unused void *data)
9834 struct cmd_region_flowtype_result *res = parsed_result;
9837 struct rte_pmd_i40e_queue_region_conf region_conf;
9838 enum rte_pmd_i40e_queue_region_op op_type;
9841 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9845 memset(®ion_conf, 0, sizeof(region_conf));
9847 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
9848 region_conf.region_id = res->region_id;
9849 region_conf.hw_flowtype = res->flowtype_id;
9851 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9852 op_type, ®ion_conf);
9859 printf("function not implemented or supported\n");
9862 printf("region flowtype config error: (%s)\n", strerror(-ret));
9866 cmdline_parse_token_string_t cmd_region_flowtype_set =
9867 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9869 cmdline_parse_token_string_t cmd_region_flowtype_port =
9870 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9872 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
9873 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9875 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
9876 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9877 cmd, "queue-region");
9878 cmdline_parse_token_string_t cmd_region_flowtype_index =
9879 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9880 region, "region_id");
9881 cmdline_parse_token_num_t cmd_region_flowtype_id =
9882 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9884 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
9885 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9886 flowtype, "flowtype");
9887 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
9888 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9889 flowtype_id, UINT8);
9890 cmdline_parse_inst_t cmd_region_flowtype = {
9891 .f = cmd_region_flowtype_parsed,
9893 .help_str = "set port <port_id> queue-region region_id <value> "
9894 "flowtype <value>: Set a flowtype region index",
9896 (void *)&cmd_region_flowtype_set,
9897 (void *)&cmd_region_flowtype_port,
9898 (void *)&cmd_region_flowtype_port_index,
9899 (void *)&cmd_region_flowtype_cmd,
9900 (void *)&cmd_region_flowtype_index,
9901 (void *)&cmd_region_flowtype_id,
9902 (void *)&cmd_region_flowtype_flow_index,
9903 (void *)&cmd_region_flowtype_flow_id,
9908 /* *** User Priority (UP) to queue region (region_id) set *** */
9909 struct cmd_user_priority_region_result {
9910 cmdline_fixed_string_t set;
9911 cmdline_fixed_string_t port;
9913 cmdline_fixed_string_t cmd;
9914 cmdline_fixed_string_t user_priority;
9915 uint8_t user_priority_id;
9916 cmdline_fixed_string_t region;
9921 cmd_user_priority_region_parsed(void *parsed_result,
9922 __rte_unused struct cmdline *cl,
9923 __rte_unused void *data)
9925 struct cmd_user_priority_region_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));
9937 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
9938 region_conf.user_priority = res->user_priority_id;
9939 region_conf.region_id = res->region_id;
9941 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9942 op_type, ®ion_conf);
9949 printf("function not implemented or supported\n");
9952 printf("user_priority region config error: (%s)\n",
9957 cmdline_parse_token_string_t cmd_user_priority_region_set =
9958 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9960 cmdline_parse_token_string_t cmd_user_priority_region_port =
9961 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9963 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
9964 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9966 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
9967 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9968 cmd, "queue-region");
9969 cmdline_parse_token_string_t cmd_user_priority_region_UP =
9970 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9971 user_priority, "UP");
9972 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
9973 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9974 user_priority_id, UINT8);
9975 cmdline_parse_token_string_t cmd_user_priority_region_region =
9976 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9977 region, "region_id");
9978 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
9979 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9982 cmdline_parse_inst_t cmd_user_priority_region = {
9983 .f = cmd_user_priority_region_parsed,
9985 .help_str = "set port <port_id> queue-region UP <value> "
9986 "region_id <value>: Set the mapping of User Priority (UP) "
9987 "to queue region (region_id) ",
9989 (void *)&cmd_user_priority_region_set,
9990 (void *)&cmd_user_priority_region_port,
9991 (void *)&cmd_user_priority_region_port_index,
9992 (void *)&cmd_user_priority_region_cmd,
9993 (void *)&cmd_user_priority_region_UP,
9994 (void *)&cmd_user_priority_region_UP_id,
9995 (void *)&cmd_user_priority_region_region,
9996 (void *)&cmd_user_priority_region_region_id,
10001 /* *** flush all queue region related configuration *** */
10002 struct cmd_flush_queue_region_result {
10003 cmdline_fixed_string_t set;
10004 cmdline_fixed_string_t port;
10006 cmdline_fixed_string_t cmd;
10007 cmdline_fixed_string_t flush;
10008 cmdline_fixed_string_t what;
10012 cmd_flush_queue_region_parsed(void *parsed_result,
10013 __rte_unused struct cmdline *cl,
10014 __rte_unused void *data)
10016 struct cmd_flush_queue_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));
10029 if (strcmp(res->what, "on") == 0)
10030 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
10032 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
10034 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10035 op_type, ®ion_conf);
10042 printf("function not implemented or supported\n");
10045 printf("queue region config flush error: (%s)\n",
10050 cmdline_parse_token_string_t cmd_flush_queue_region_set =
10051 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10053 cmdline_parse_token_string_t cmd_flush_queue_region_port =
10054 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10056 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
10057 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
10059 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
10060 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10061 cmd, "queue-region");
10062 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
10063 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10065 cmdline_parse_token_string_t cmd_flush_queue_region_what =
10066 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10069 cmdline_parse_inst_t cmd_flush_queue_region = {
10070 .f = cmd_flush_queue_region_parsed,
10072 .help_str = "set port <port_id> queue-region flush on|off"
10073 ": flush all queue region related configuration",
10075 (void *)&cmd_flush_queue_region_set,
10076 (void *)&cmd_flush_queue_region_port,
10077 (void *)&cmd_flush_queue_region_port_index,
10078 (void *)&cmd_flush_queue_region_cmd,
10079 (void *)&cmd_flush_queue_region_flush,
10080 (void *)&cmd_flush_queue_region_what,
10085 /* *** get all queue region related configuration info *** */
10086 struct cmd_show_queue_region_info {
10087 cmdline_fixed_string_t show;
10088 cmdline_fixed_string_t port;
10090 cmdline_fixed_string_t cmd;
10094 cmd_show_queue_region_info_parsed(void *parsed_result,
10095 __rte_unused struct cmdline *cl,
10096 __rte_unused void *data)
10098 struct cmd_show_queue_region_info *res = parsed_result;
10099 int ret = -ENOTSUP;
10100 #ifdef RTE_NET_I40E
10101 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
10102 enum rte_pmd_i40e_queue_region_op op_type;
10105 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10108 #ifdef RTE_NET_I40E
10109 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
10111 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
10113 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10114 op_type, &rte_pmd_regions);
10116 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
10123 printf("function not implemented or supported\n");
10126 printf("queue region config info show error: (%s)\n",
10131 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
10132 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10134 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
10135 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10137 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
10138 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
10140 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
10141 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10142 cmd, "queue-region");
10144 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
10145 .f = cmd_show_queue_region_info_parsed,
10147 .help_str = "show port <port_id> queue-region"
10148 ": show all queue region related configuration info",
10150 (void *)&cmd_show_queue_region_info_get,
10151 (void *)&cmd_show_queue_region_info_port,
10152 (void *)&cmd_show_queue_region_info_port_index,
10153 (void *)&cmd_show_queue_region_info_cmd,
10158 /* *** Filters Control *** */
10160 /* *** deal with flow director filter *** */
10161 struct cmd_flow_director_result {
10162 cmdline_fixed_string_t flow_director_filter;
10164 cmdline_fixed_string_t mode;
10165 cmdline_fixed_string_t mode_value;
10166 cmdline_fixed_string_t ops;
10167 cmdline_fixed_string_t flow;
10168 cmdline_fixed_string_t flow_type;
10169 cmdline_fixed_string_t ether;
10170 uint16_t ether_type;
10171 cmdline_fixed_string_t src;
10172 cmdline_ipaddr_t ip_src;
10174 cmdline_fixed_string_t dst;
10175 cmdline_ipaddr_t ip_dst;
10177 cmdline_fixed_string_t verify_tag;
10178 uint32_t verify_tag_value;
10179 cmdline_fixed_string_t tos;
10181 cmdline_fixed_string_t proto;
10182 uint8_t proto_value;
10183 cmdline_fixed_string_t ttl;
10185 cmdline_fixed_string_t vlan;
10186 uint16_t vlan_value;
10187 cmdline_fixed_string_t flexbytes;
10188 cmdline_fixed_string_t flexbytes_value;
10189 cmdline_fixed_string_t pf_vf;
10190 cmdline_fixed_string_t drop;
10191 cmdline_fixed_string_t queue;
10193 cmdline_fixed_string_t fd_id;
10194 uint32_t fd_id_value;
10195 cmdline_fixed_string_t mac;
10196 struct rte_ether_addr mac_addr;
10197 cmdline_fixed_string_t tunnel;
10198 cmdline_fixed_string_t tunnel_type;
10199 cmdline_fixed_string_t tunnel_id;
10200 uint32_t tunnel_id_value;
10201 cmdline_fixed_string_t packet;
10206 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
10209 const char *p, *p0 = q_arg;
10211 unsigned long int_fld;
10212 char *str_fld[max_num];
10217 p = strchr(p0, '(');
10221 p0 = strchr(p, ')');
10226 if (size >= sizeof(s))
10229 snprintf(s, sizeof(s), "%.*s", size, p);
10230 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10231 if (ret < 0 || ret > max_num)
10233 for (i = 0; i < ret; i++) {
10235 int_fld = strtoul(str_fld[i], &end, 0);
10236 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
10238 flexbytes[i] = (uint8_t)int_fld;
10244 str2flowtype(char *string)
10247 static const struct {
10250 } flowtype_str[] = {
10251 {"raw", RTE_ETH_FLOW_RAW},
10252 {"ipv4", RTE_ETH_FLOW_IPV4},
10253 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10254 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10255 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10256 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10257 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10258 {"ipv6", RTE_ETH_FLOW_IPV6},
10259 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10260 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10261 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10262 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10263 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10264 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10267 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
10268 if (!strcmp(flowtype_str[i].str, string))
10269 return flowtype_str[i].type;
10272 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
10273 return (uint16_t)atoi(string);
10275 return RTE_ETH_FLOW_UNKNOWN;
10278 static enum rte_eth_fdir_tunnel_type
10279 str2fdir_tunneltype(char *string)
10283 static const struct {
10285 enum rte_eth_fdir_tunnel_type type;
10286 } tunneltype_str[] = {
10287 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
10288 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
10291 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
10292 if (!strcmp(tunneltype_str[i].str, string))
10293 return tunneltype_str[i].type;
10295 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
10298 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10300 if ((ip_addr).family == AF_INET) \
10301 (ip) = (ip_addr).addr.ipv4.s_addr; \
10303 printf("invalid parameter.\n"); \
10308 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10310 if ((ip_addr).family == AF_INET6) \
10311 rte_memcpy(&(ip), \
10312 &((ip_addr).addr.ipv6), \
10313 sizeof(struct in6_addr)); \
10315 printf("invalid parameter.\n"); \
10321 cmd_flow_director_filter_parsed(void *parsed_result,
10322 __rte_unused struct cmdline *cl,
10323 __rte_unused void *data)
10325 struct cmd_flow_director_result *res = parsed_result;
10326 struct rte_eth_fdir_filter entry;
10327 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
10329 unsigned long vf_id;
10332 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
10334 printf("flow director is not supported on port %u.\n",
10338 memset(flexbytes, 0, sizeof(flexbytes));
10339 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
10341 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10342 if (strcmp(res->mode_value, "MAC-VLAN")) {
10343 printf("Please set mode to MAC-VLAN.\n");
10346 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10347 if (strcmp(res->mode_value, "Tunnel")) {
10348 printf("Please set mode to Tunnel.\n");
10352 if (!strcmp(res->mode_value, "raw")) {
10353 #ifdef RTE_NET_I40E
10354 struct rte_pmd_i40e_flow_type_mapping
10355 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
10356 struct rte_pmd_i40e_pkt_template_conf conf;
10357 uint16_t flow_type = str2flowtype(res->flow_type);
10358 uint16_t i, port = res->port_id;
10361 memset(&conf, 0, sizeof(conf));
10363 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
10364 printf("Invalid flow type specified.\n");
10367 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
10371 if (mapping[flow_type].pctype == 0ULL) {
10372 printf("Invalid flow type specified.\n");
10375 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
10376 if (mapping[flow_type].pctype & (1ULL << i)) {
10377 conf.input.pctype = i;
10382 conf.input.packet = open_file(res->filepath,
10383 &conf.input.length);
10384 if (!conf.input.packet)
10386 if (!strcmp(res->drop, "drop"))
10387 conf.action.behavior =
10388 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
10390 conf.action.behavior =
10391 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
10392 conf.action.report_status =
10393 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
10394 conf.action.rx_queue = res->queue_id;
10395 conf.soft_id = res->fd_id_value;
10396 add = strcmp(res->ops, "del") ? 1 : 0;
10397 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
10401 printf("flow director config error: (%s)\n",
10403 close_file(conf.input.packet);
10406 } else if (strcmp(res->mode_value, "IP")) {
10407 printf("Please set mode to IP or raw.\n");
10410 entry.input.flow_type = str2flowtype(res->flow_type);
10413 ret = parse_flexbytes(res->flexbytes_value,
10415 RTE_ETH_FDIR_MAX_FLEXLEN);
10417 printf("error: Cannot parse flexbytes input.\n");
10421 switch (entry.input.flow_type) {
10422 case RTE_ETH_FLOW_FRAG_IPV4:
10423 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
10424 entry.input.flow.ip4_flow.proto = res->proto_value;
10426 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
10427 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
10428 IPV4_ADDR_TO_UINT(res->ip_dst,
10429 entry.input.flow.ip4_flow.dst_ip);
10430 IPV4_ADDR_TO_UINT(res->ip_src,
10431 entry.input.flow.ip4_flow.src_ip);
10432 entry.input.flow.ip4_flow.tos = res->tos_value;
10433 entry.input.flow.ip4_flow.ttl = res->ttl_value;
10434 /* need convert to big endian. */
10435 entry.input.flow.udp4_flow.dst_port =
10436 rte_cpu_to_be_16(res->port_dst);
10437 entry.input.flow.udp4_flow.src_port =
10438 rte_cpu_to_be_16(res->port_src);
10440 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
10441 IPV4_ADDR_TO_UINT(res->ip_dst,
10442 entry.input.flow.sctp4_flow.ip.dst_ip);
10443 IPV4_ADDR_TO_UINT(res->ip_src,
10444 entry.input.flow.sctp4_flow.ip.src_ip);
10445 entry.input.flow.ip4_flow.tos = res->tos_value;
10446 entry.input.flow.ip4_flow.ttl = res->ttl_value;
10447 /* need convert to big endian. */
10448 entry.input.flow.sctp4_flow.dst_port =
10449 rte_cpu_to_be_16(res->port_dst);
10450 entry.input.flow.sctp4_flow.src_port =
10451 rte_cpu_to_be_16(res->port_src);
10452 entry.input.flow.sctp4_flow.verify_tag =
10453 rte_cpu_to_be_32(res->verify_tag_value);
10455 case RTE_ETH_FLOW_FRAG_IPV6:
10456 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
10457 entry.input.flow.ipv6_flow.proto = res->proto_value;
10459 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
10460 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
10461 IPV6_ADDR_TO_ARRAY(res->ip_dst,
10462 entry.input.flow.ipv6_flow.dst_ip);
10463 IPV6_ADDR_TO_ARRAY(res->ip_src,
10464 entry.input.flow.ipv6_flow.src_ip);
10465 entry.input.flow.ipv6_flow.tc = res->tos_value;
10466 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
10467 /* need convert to big endian. */
10468 entry.input.flow.udp6_flow.dst_port =
10469 rte_cpu_to_be_16(res->port_dst);
10470 entry.input.flow.udp6_flow.src_port =
10471 rte_cpu_to_be_16(res->port_src);
10473 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
10474 IPV6_ADDR_TO_ARRAY(res->ip_dst,
10475 entry.input.flow.sctp6_flow.ip.dst_ip);
10476 IPV6_ADDR_TO_ARRAY(res->ip_src,
10477 entry.input.flow.sctp6_flow.ip.src_ip);
10478 entry.input.flow.ipv6_flow.tc = res->tos_value;
10479 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
10480 /* need convert to big endian. */
10481 entry.input.flow.sctp6_flow.dst_port =
10482 rte_cpu_to_be_16(res->port_dst);
10483 entry.input.flow.sctp6_flow.src_port =
10484 rte_cpu_to_be_16(res->port_src);
10485 entry.input.flow.sctp6_flow.verify_tag =
10486 rte_cpu_to_be_32(res->verify_tag_value);
10488 case RTE_ETH_FLOW_L2_PAYLOAD:
10489 entry.input.flow.l2_flow.ether_type =
10490 rte_cpu_to_be_16(res->ether_type);
10496 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
10497 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
10499 sizeof(struct rte_ether_addr));
10501 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10502 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
10504 sizeof(struct rte_ether_addr));
10505 entry.input.flow.tunnel_flow.tunnel_type =
10506 str2fdir_tunneltype(res->tunnel_type);
10507 entry.input.flow.tunnel_flow.tunnel_id =
10508 rte_cpu_to_be_32(res->tunnel_id_value);
10511 rte_memcpy(entry.input.flow_ext.flexbytes,
10513 RTE_ETH_FDIR_MAX_FLEXLEN);
10515 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
10517 entry.action.flex_off = 0; /*use 0 by default */
10518 if (!strcmp(res->drop, "drop"))
10519 entry.action.behavior = RTE_ETH_FDIR_REJECT;
10521 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
10523 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
10524 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
10525 if (!strcmp(res->pf_vf, "pf"))
10526 entry.input.flow_ext.is_vf = 0;
10527 else if (!strncmp(res->pf_vf, "vf", 2)) {
10528 struct rte_eth_dev_info dev_info;
10530 ret = eth_dev_info_get_print_err(res->port_id,
10536 vf_id = strtoul(res->pf_vf + 2, &end, 10);
10537 if (errno != 0 || *end != '\0' ||
10538 vf_id >= dev_info.max_vfs) {
10539 printf("invalid parameter %s.\n", res->pf_vf);
10542 entry.input.flow_ext.is_vf = 1;
10543 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
10545 printf("invalid parameter %s.\n", res->pf_vf);
10550 /* set to report FD ID by default */
10551 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
10552 entry.action.rx_queue = res->queue_id;
10553 entry.soft_id = res->fd_id_value;
10554 if (!strcmp(res->ops, "add"))
10555 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10556 RTE_ETH_FILTER_ADD, &entry);
10557 else if (!strcmp(res->ops, "del"))
10558 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10559 RTE_ETH_FILTER_DELETE, &entry);
10561 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10562 RTE_ETH_FILTER_UPDATE, &entry);
10564 printf("flow director programming error: (%s)\n",
10568 cmdline_parse_token_string_t cmd_flow_director_filter =
10569 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10570 flow_director_filter, "flow_director_filter");
10571 cmdline_parse_token_num_t cmd_flow_director_port_id =
10572 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10574 cmdline_parse_token_string_t cmd_flow_director_ops =
10575 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10576 ops, "add#del#update");
10577 cmdline_parse_token_string_t cmd_flow_director_flow =
10578 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10580 cmdline_parse_token_string_t cmd_flow_director_flow_type =
10581 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10583 cmdline_parse_token_string_t cmd_flow_director_ether =
10584 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10586 cmdline_parse_token_num_t cmd_flow_director_ether_type =
10587 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10588 ether_type, UINT16);
10589 cmdline_parse_token_string_t cmd_flow_director_src =
10590 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10592 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
10593 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10595 cmdline_parse_token_num_t cmd_flow_director_port_src =
10596 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10598 cmdline_parse_token_string_t cmd_flow_director_dst =
10599 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10601 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
10602 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10604 cmdline_parse_token_num_t cmd_flow_director_port_dst =
10605 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10607 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
10608 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10609 verify_tag, "verify_tag");
10610 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
10611 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10612 verify_tag_value, UINT32);
10613 cmdline_parse_token_string_t cmd_flow_director_tos =
10614 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10616 cmdline_parse_token_num_t cmd_flow_director_tos_value =
10617 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10619 cmdline_parse_token_string_t cmd_flow_director_proto =
10620 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10622 cmdline_parse_token_num_t cmd_flow_director_proto_value =
10623 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10624 proto_value, UINT8);
10625 cmdline_parse_token_string_t cmd_flow_director_ttl =
10626 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10628 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
10629 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10631 cmdline_parse_token_string_t cmd_flow_director_vlan =
10632 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10634 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
10635 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10636 vlan_value, UINT16);
10637 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
10638 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10639 flexbytes, "flexbytes");
10640 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
10641 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10642 flexbytes_value, NULL);
10643 cmdline_parse_token_string_t cmd_flow_director_drop =
10644 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10646 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
10647 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10649 cmdline_parse_token_string_t cmd_flow_director_queue =
10650 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10652 cmdline_parse_token_num_t cmd_flow_director_queue_id =
10653 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10655 cmdline_parse_token_string_t cmd_flow_director_fd_id =
10656 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10658 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
10659 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10660 fd_id_value, UINT32);
10662 cmdline_parse_token_string_t cmd_flow_director_mode =
10663 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10665 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
10666 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10668 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
10669 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10670 mode_value, "MAC-VLAN");
10671 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
10672 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10673 mode_value, "Tunnel");
10674 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
10675 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10676 mode_value, "raw");
10677 cmdline_parse_token_string_t cmd_flow_director_mac =
10678 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10680 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
10681 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
10683 cmdline_parse_token_string_t cmd_flow_director_tunnel =
10684 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10686 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
10687 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10688 tunnel_type, "NVGRE#VxLAN");
10689 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
10690 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10691 tunnel_id, "tunnel-id");
10692 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
10693 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10694 tunnel_id_value, UINT32);
10695 cmdline_parse_token_string_t cmd_flow_director_packet =
10696 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10698 cmdline_parse_token_string_t cmd_flow_director_filepath =
10699 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10702 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
10703 .f = cmd_flow_director_filter_parsed,
10705 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
10706 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
10707 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
10708 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
10709 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
10710 "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> "
10711 "fd_id <fd_id_value>: "
10712 "Add or delete an ip flow director entry on NIC",
10714 (void *)&cmd_flow_director_filter,
10715 (void *)&cmd_flow_director_port_id,
10716 (void *)&cmd_flow_director_mode,
10717 (void *)&cmd_flow_director_mode_ip,
10718 (void *)&cmd_flow_director_ops,
10719 (void *)&cmd_flow_director_flow,
10720 (void *)&cmd_flow_director_flow_type,
10721 (void *)&cmd_flow_director_src,
10722 (void *)&cmd_flow_director_ip_src,
10723 (void *)&cmd_flow_director_dst,
10724 (void *)&cmd_flow_director_ip_dst,
10725 (void *)&cmd_flow_director_tos,
10726 (void *)&cmd_flow_director_tos_value,
10727 (void *)&cmd_flow_director_proto,
10728 (void *)&cmd_flow_director_proto_value,
10729 (void *)&cmd_flow_director_ttl,
10730 (void *)&cmd_flow_director_ttl_value,
10731 (void *)&cmd_flow_director_vlan,
10732 (void *)&cmd_flow_director_vlan_value,
10733 (void *)&cmd_flow_director_flexbytes,
10734 (void *)&cmd_flow_director_flexbytes_value,
10735 (void *)&cmd_flow_director_drop,
10736 (void *)&cmd_flow_director_pf_vf,
10737 (void *)&cmd_flow_director_queue,
10738 (void *)&cmd_flow_director_queue_id,
10739 (void *)&cmd_flow_director_fd_id,
10740 (void *)&cmd_flow_director_fd_id_value,
10745 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
10746 .f = cmd_flow_director_filter_parsed,
10748 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
10749 "director entry on NIC",
10751 (void *)&cmd_flow_director_filter,
10752 (void *)&cmd_flow_director_port_id,
10753 (void *)&cmd_flow_director_mode,
10754 (void *)&cmd_flow_director_mode_ip,
10755 (void *)&cmd_flow_director_ops,
10756 (void *)&cmd_flow_director_flow,
10757 (void *)&cmd_flow_director_flow_type,
10758 (void *)&cmd_flow_director_src,
10759 (void *)&cmd_flow_director_ip_src,
10760 (void *)&cmd_flow_director_port_src,
10761 (void *)&cmd_flow_director_dst,
10762 (void *)&cmd_flow_director_ip_dst,
10763 (void *)&cmd_flow_director_port_dst,
10764 (void *)&cmd_flow_director_tos,
10765 (void *)&cmd_flow_director_tos_value,
10766 (void *)&cmd_flow_director_ttl,
10767 (void *)&cmd_flow_director_ttl_value,
10768 (void *)&cmd_flow_director_vlan,
10769 (void *)&cmd_flow_director_vlan_value,
10770 (void *)&cmd_flow_director_flexbytes,
10771 (void *)&cmd_flow_director_flexbytes_value,
10772 (void *)&cmd_flow_director_drop,
10773 (void *)&cmd_flow_director_pf_vf,
10774 (void *)&cmd_flow_director_queue,
10775 (void *)&cmd_flow_director_queue_id,
10776 (void *)&cmd_flow_director_fd_id,
10777 (void *)&cmd_flow_director_fd_id_value,
10782 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
10783 .f = cmd_flow_director_filter_parsed,
10785 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
10786 "director entry on NIC",
10788 (void *)&cmd_flow_director_filter,
10789 (void *)&cmd_flow_director_port_id,
10790 (void *)&cmd_flow_director_mode,
10791 (void *)&cmd_flow_director_mode_ip,
10792 (void *)&cmd_flow_director_ops,
10793 (void *)&cmd_flow_director_flow,
10794 (void *)&cmd_flow_director_flow_type,
10795 (void *)&cmd_flow_director_src,
10796 (void *)&cmd_flow_director_ip_src,
10797 (void *)&cmd_flow_director_port_src,
10798 (void *)&cmd_flow_director_dst,
10799 (void *)&cmd_flow_director_ip_dst,
10800 (void *)&cmd_flow_director_port_dst,
10801 (void *)&cmd_flow_director_verify_tag,
10802 (void *)&cmd_flow_director_verify_tag_value,
10803 (void *)&cmd_flow_director_tos,
10804 (void *)&cmd_flow_director_tos_value,
10805 (void *)&cmd_flow_director_ttl,
10806 (void *)&cmd_flow_director_ttl_value,
10807 (void *)&cmd_flow_director_vlan,
10808 (void *)&cmd_flow_director_vlan_value,
10809 (void *)&cmd_flow_director_flexbytes,
10810 (void *)&cmd_flow_director_flexbytes_value,
10811 (void *)&cmd_flow_director_drop,
10812 (void *)&cmd_flow_director_pf_vf,
10813 (void *)&cmd_flow_director_queue,
10814 (void *)&cmd_flow_director_queue_id,
10815 (void *)&cmd_flow_director_fd_id,
10816 (void *)&cmd_flow_director_fd_id_value,
10821 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
10822 .f = cmd_flow_director_filter_parsed,
10824 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
10825 "director entry on NIC",
10827 (void *)&cmd_flow_director_filter,
10828 (void *)&cmd_flow_director_port_id,
10829 (void *)&cmd_flow_director_mode,
10830 (void *)&cmd_flow_director_mode_ip,
10831 (void *)&cmd_flow_director_ops,
10832 (void *)&cmd_flow_director_flow,
10833 (void *)&cmd_flow_director_flow_type,
10834 (void *)&cmd_flow_director_ether,
10835 (void *)&cmd_flow_director_ether_type,
10836 (void *)&cmd_flow_director_flexbytes,
10837 (void *)&cmd_flow_director_flexbytes_value,
10838 (void *)&cmd_flow_director_drop,
10839 (void *)&cmd_flow_director_pf_vf,
10840 (void *)&cmd_flow_director_queue,
10841 (void *)&cmd_flow_director_queue_id,
10842 (void *)&cmd_flow_director_fd_id,
10843 (void *)&cmd_flow_director_fd_id_value,
10848 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
10849 .f = cmd_flow_director_filter_parsed,
10851 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
10852 "director entry on NIC",
10854 (void *)&cmd_flow_director_filter,
10855 (void *)&cmd_flow_director_port_id,
10856 (void *)&cmd_flow_director_mode,
10857 (void *)&cmd_flow_director_mode_mac_vlan,
10858 (void *)&cmd_flow_director_ops,
10859 (void *)&cmd_flow_director_mac,
10860 (void *)&cmd_flow_director_mac_addr,
10861 (void *)&cmd_flow_director_vlan,
10862 (void *)&cmd_flow_director_vlan_value,
10863 (void *)&cmd_flow_director_flexbytes,
10864 (void *)&cmd_flow_director_flexbytes_value,
10865 (void *)&cmd_flow_director_drop,
10866 (void *)&cmd_flow_director_queue,
10867 (void *)&cmd_flow_director_queue_id,
10868 (void *)&cmd_flow_director_fd_id,
10869 (void *)&cmd_flow_director_fd_id_value,
10874 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
10875 .f = cmd_flow_director_filter_parsed,
10877 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
10878 "director entry on NIC",
10880 (void *)&cmd_flow_director_filter,
10881 (void *)&cmd_flow_director_port_id,
10882 (void *)&cmd_flow_director_mode,
10883 (void *)&cmd_flow_director_mode_tunnel,
10884 (void *)&cmd_flow_director_ops,
10885 (void *)&cmd_flow_director_mac,
10886 (void *)&cmd_flow_director_mac_addr,
10887 (void *)&cmd_flow_director_vlan,
10888 (void *)&cmd_flow_director_vlan_value,
10889 (void *)&cmd_flow_director_tunnel,
10890 (void *)&cmd_flow_director_tunnel_type,
10891 (void *)&cmd_flow_director_tunnel_id,
10892 (void *)&cmd_flow_director_tunnel_id_value,
10893 (void *)&cmd_flow_director_flexbytes,
10894 (void *)&cmd_flow_director_flexbytes_value,
10895 (void *)&cmd_flow_director_drop,
10896 (void *)&cmd_flow_director_queue,
10897 (void *)&cmd_flow_director_queue_id,
10898 (void *)&cmd_flow_director_fd_id,
10899 (void *)&cmd_flow_director_fd_id_value,
10904 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
10905 .f = cmd_flow_director_filter_parsed,
10907 .help_str = "flow_director_filter ... : Add or delete a raw flow "
10908 "director entry on NIC",
10910 (void *)&cmd_flow_director_filter,
10911 (void *)&cmd_flow_director_port_id,
10912 (void *)&cmd_flow_director_mode,
10913 (void *)&cmd_flow_director_mode_raw,
10914 (void *)&cmd_flow_director_ops,
10915 (void *)&cmd_flow_director_flow,
10916 (void *)&cmd_flow_director_flow_type,
10917 (void *)&cmd_flow_director_drop,
10918 (void *)&cmd_flow_director_queue,
10919 (void *)&cmd_flow_director_queue_id,
10920 (void *)&cmd_flow_director_fd_id,
10921 (void *)&cmd_flow_director_fd_id_value,
10922 (void *)&cmd_flow_director_packet,
10923 (void *)&cmd_flow_director_filepath,
10928 struct cmd_flush_flow_director_result {
10929 cmdline_fixed_string_t flush_flow_director;
10933 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
10934 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
10935 flush_flow_director, "flush_flow_director");
10936 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
10937 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
10941 cmd_flush_flow_director_parsed(void *parsed_result,
10942 __rte_unused struct cmdline *cl,
10943 __rte_unused void *data)
10945 struct cmd_flow_director_result *res = parsed_result;
10948 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
10950 printf("flow director is not supported on port %u.\n",
10955 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10956 RTE_ETH_FILTER_FLUSH, NULL);
10958 printf("flow director table flushing error: (%s)\n",
10962 cmdline_parse_inst_t cmd_flush_flow_director = {
10963 .f = cmd_flush_flow_director_parsed,
10965 .help_str = "flush_flow_director <port_id>: "
10966 "Flush all flow director entries of a device on NIC",
10968 (void *)&cmd_flush_flow_director_flush,
10969 (void *)&cmd_flush_flow_director_port_id,
10974 /* *** deal with flow director mask *** */
10975 struct cmd_flow_director_mask_result {
10976 cmdline_fixed_string_t flow_director_mask;
10978 cmdline_fixed_string_t mode;
10979 cmdline_fixed_string_t mode_value;
10980 cmdline_fixed_string_t vlan;
10981 uint16_t vlan_mask;
10982 cmdline_fixed_string_t src_mask;
10983 cmdline_ipaddr_t ipv4_src;
10984 cmdline_ipaddr_t ipv6_src;
10986 cmdline_fixed_string_t dst_mask;
10987 cmdline_ipaddr_t ipv4_dst;
10988 cmdline_ipaddr_t ipv6_dst;
10990 cmdline_fixed_string_t mac;
10991 uint8_t mac_addr_byte_mask;
10992 cmdline_fixed_string_t tunnel_id;
10993 uint32_t tunnel_id_mask;
10994 cmdline_fixed_string_t tunnel_type;
10995 uint8_t tunnel_type_mask;
10999 cmd_flow_director_mask_parsed(void *parsed_result,
11000 __rte_unused struct cmdline *cl,
11001 __rte_unused void *data)
11003 struct cmd_flow_director_mask_result *res = parsed_result;
11004 struct rte_eth_fdir_masks *mask;
11005 struct rte_port *port;
11007 port = &ports[res->port_id];
11008 /** Check if the port is not started **/
11009 if (port->port_status != RTE_PORT_STOPPED) {
11010 printf("Please stop port %d first\n", res->port_id);
11014 mask = &port->dev_conf.fdir_conf.mask;
11016 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
11017 if (strcmp(res->mode_value, "MAC-VLAN")) {
11018 printf("Please set mode to MAC-VLAN.\n");
11022 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11023 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11024 if (strcmp(res->mode_value, "Tunnel")) {
11025 printf("Please set mode to Tunnel.\n");
11029 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11030 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
11031 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
11032 mask->tunnel_type_mask = res->tunnel_type_mask;
11034 if (strcmp(res->mode_value, "IP")) {
11035 printf("Please set mode to IP.\n");
11039 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11040 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
11041 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
11042 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
11043 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
11044 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
11045 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
11048 cmd_reconfig_device_queue(res->port_id, 1, 1);
11051 cmdline_parse_token_string_t cmd_flow_director_mask =
11052 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11053 flow_director_mask, "flow_director_mask");
11054 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
11055 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11057 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
11058 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11060 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
11061 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11062 vlan_mask, UINT16);
11063 cmdline_parse_token_string_t cmd_flow_director_mask_src =
11064 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11065 src_mask, "src_mask");
11066 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
11067 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11069 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
11070 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11072 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
11073 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11075 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
11076 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11077 dst_mask, "dst_mask");
11078 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
11079 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11081 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
11082 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11084 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
11085 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11088 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
11089 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11091 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
11092 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11094 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
11095 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11096 mode_value, "MAC-VLAN");
11097 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
11098 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11099 mode_value, "Tunnel");
11100 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
11101 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11103 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
11104 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11105 mac_addr_byte_mask, UINT8);
11106 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
11107 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11108 tunnel_type, "tunnel-type");
11109 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
11110 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11111 tunnel_type_mask, UINT8);
11112 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
11113 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11114 tunnel_id, "tunnel-id");
11115 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
11116 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11117 tunnel_id_mask, UINT32);
11119 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
11120 .f = cmd_flow_director_mask_parsed,
11122 .help_str = "flow_director_mask ... : "
11123 "Set IP mode flow director's mask on NIC",
11125 (void *)&cmd_flow_director_mask,
11126 (void *)&cmd_flow_director_mask_port_id,
11127 (void *)&cmd_flow_director_mask_mode,
11128 (void *)&cmd_flow_director_mask_mode_ip,
11129 (void *)&cmd_flow_director_mask_vlan,
11130 (void *)&cmd_flow_director_mask_vlan_value,
11131 (void *)&cmd_flow_director_mask_src,
11132 (void *)&cmd_flow_director_mask_ipv4_src,
11133 (void *)&cmd_flow_director_mask_ipv6_src,
11134 (void *)&cmd_flow_director_mask_port_src,
11135 (void *)&cmd_flow_director_mask_dst,
11136 (void *)&cmd_flow_director_mask_ipv4_dst,
11137 (void *)&cmd_flow_director_mask_ipv6_dst,
11138 (void *)&cmd_flow_director_mask_port_dst,
11143 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
11144 .f = cmd_flow_director_mask_parsed,
11146 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
11147 "flow director's mask on NIC",
11149 (void *)&cmd_flow_director_mask,
11150 (void *)&cmd_flow_director_mask_port_id,
11151 (void *)&cmd_flow_director_mask_mode,
11152 (void *)&cmd_flow_director_mask_mode_mac_vlan,
11153 (void *)&cmd_flow_director_mask_vlan,
11154 (void *)&cmd_flow_director_mask_vlan_value,
11159 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
11160 .f = cmd_flow_director_mask_parsed,
11162 .help_str = "flow_director_mask ... : Set tunnel mode "
11163 "flow director's mask on NIC",
11165 (void *)&cmd_flow_director_mask,
11166 (void *)&cmd_flow_director_mask_port_id,
11167 (void *)&cmd_flow_director_mask_mode,
11168 (void *)&cmd_flow_director_mask_mode_tunnel,
11169 (void *)&cmd_flow_director_mask_vlan,
11170 (void *)&cmd_flow_director_mask_vlan_value,
11171 (void *)&cmd_flow_director_mask_mac,
11172 (void *)&cmd_flow_director_mask_mac_value,
11173 (void *)&cmd_flow_director_mask_tunnel_type,
11174 (void *)&cmd_flow_director_mask_tunnel_type_value,
11175 (void *)&cmd_flow_director_mask_tunnel_id,
11176 (void *)&cmd_flow_director_mask_tunnel_id_value,
11181 /* *** deal with flow director mask on flexible payload *** */
11182 struct cmd_flow_director_flex_mask_result {
11183 cmdline_fixed_string_t flow_director_flexmask;
11185 cmdline_fixed_string_t flow;
11186 cmdline_fixed_string_t flow_type;
11187 cmdline_fixed_string_t mask;
11191 cmd_flow_director_flex_mask_parsed(void *parsed_result,
11192 __rte_unused struct cmdline *cl,
11193 __rte_unused void *data)
11195 struct cmd_flow_director_flex_mask_result *res = parsed_result;
11196 struct rte_eth_fdir_info fdir_info;
11197 struct rte_eth_fdir_flex_mask flex_mask;
11198 struct rte_port *port;
11199 uint64_t flow_type_mask;
11203 port = &ports[res->port_id];
11204 /** Check if the port is not started **/
11205 if (port->port_status != RTE_PORT_STOPPED) {
11206 printf("Please stop port %d first\n", res->port_id);
11210 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
11211 ret = parse_flexbytes(res->mask,
11213 RTE_ETH_FDIR_MAX_FLEXLEN);
11215 printf("error: Cannot parse mask input.\n");
11219 memset(&fdir_info, 0, sizeof(fdir_info));
11220 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11221 RTE_ETH_FILTER_INFO, &fdir_info);
11223 printf("Cannot get FDir filter info\n");
11227 if (!strcmp(res->flow_type, "none")) {
11228 /* means don't specify the flow type */
11229 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
11230 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
11231 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
11232 0, sizeof(struct rte_eth_fdir_flex_mask));
11233 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
11234 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
11236 sizeof(struct rte_eth_fdir_flex_mask));
11237 cmd_reconfig_device_queue(res->port_id, 1, 1);
11240 flow_type_mask = fdir_info.flow_types_mask[0];
11241 if (!strcmp(res->flow_type, "all")) {
11242 if (!flow_type_mask) {
11243 printf("No flow type supported\n");
11246 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
11247 if (flow_type_mask & (1ULL << i)) {
11248 flex_mask.flow_type = i;
11249 fdir_set_flex_mask(res->port_id, &flex_mask);
11252 cmd_reconfig_device_queue(res->port_id, 1, 1);
11255 flex_mask.flow_type = str2flowtype(res->flow_type);
11256 if (!(flow_type_mask & (1ULL << flex_mask.flow_type))) {
11257 printf("Flow type %s not supported on port %d\n",
11258 res->flow_type, res->port_id);
11261 fdir_set_flex_mask(res->port_id, &flex_mask);
11262 cmd_reconfig_device_queue(res->port_id, 1, 1);
11265 cmdline_parse_token_string_t cmd_flow_director_flexmask =
11266 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11267 flow_director_flexmask,
11268 "flow_director_flex_mask");
11269 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
11270 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11272 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
11273 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11275 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
11276 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11277 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
11278 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
11279 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
11280 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11283 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
11284 .f = cmd_flow_director_flex_mask_parsed,
11286 .help_str = "flow_director_flex_mask ... : "
11287 "Set flow director's flex mask on NIC",
11289 (void *)&cmd_flow_director_flexmask,
11290 (void *)&cmd_flow_director_flexmask_port_id,
11291 (void *)&cmd_flow_director_flexmask_flow,
11292 (void *)&cmd_flow_director_flexmask_flow_type,
11293 (void *)&cmd_flow_director_flexmask_mask,
11298 /* *** deal with flow director flexible payload configuration *** */
11299 struct cmd_flow_director_flexpayload_result {
11300 cmdline_fixed_string_t flow_director_flexpayload;
11302 cmdline_fixed_string_t payload_layer;
11303 cmdline_fixed_string_t payload_cfg;
11307 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
11310 const char *p, *p0 = q_arg;
11312 unsigned long int_fld;
11313 char *str_fld[max_num];
11318 p = strchr(p0, '(');
11322 p0 = strchr(p, ')');
11327 if (size >= sizeof(s))
11330 snprintf(s, sizeof(s), "%.*s", size, p);
11331 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
11332 if (ret < 0 || ret > max_num)
11334 for (i = 0; i < ret; i++) {
11336 int_fld = strtoul(str_fld[i], &end, 0);
11337 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
11339 offsets[i] = (uint16_t)int_fld;
11345 cmd_flow_director_flxpld_parsed(void *parsed_result,
11346 __rte_unused struct cmdline *cl,
11347 __rte_unused void *data)
11349 struct cmd_flow_director_flexpayload_result *res = parsed_result;
11350 struct rte_eth_flex_payload_cfg flex_cfg;
11351 struct rte_port *port;
11354 port = &ports[res->port_id];
11355 /** Check if the port is not started **/
11356 if (port->port_status != RTE_PORT_STOPPED) {
11357 printf("Please stop port %d first\n", res->port_id);
11361 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
11363 if (!strcmp(res->payload_layer, "raw"))
11364 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
11365 else if (!strcmp(res->payload_layer, "l2"))
11366 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
11367 else if (!strcmp(res->payload_layer, "l3"))
11368 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
11369 else if (!strcmp(res->payload_layer, "l4"))
11370 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
11372 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
11373 RTE_ETH_FDIR_MAX_FLEXLEN);
11375 printf("error: Cannot parse flex payload input.\n");
11379 fdir_set_flex_payload(res->port_id, &flex_cfg);
11380 cmd_reconfig_device_queue(res->port_id, 1, 1);
11383 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
11384 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11385 flow_director_flexpayload,
11386 "flow_director_flex_payload");
11387 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
11388 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11390 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
11391 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11392 payload_layer, "raw#l2#l3#l4");
11393 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
11394 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11395 payload_cfg, NULL);
11397 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
11398 .f = cmd_flow_director_flxpld_parsed,
11400 .help_str = "flow_director_flexpayload ... : "
11401 "Set flow director's flex payload on NIC",
11403 (void *)&cmd_flow_director_flexpayload,
11404 (void *)&cmd_flow_director_flexpayload_port_id,
11405 (void *)&cmd_flow_director_flexpayload_payload_layer,
11406 (void *)&cmd_flow_director_flexpayload_payload_cfg,
11411 /* Generic flow interface command. */
11412 extern cmdline_parse_inst_t cmd_flow;
11414 /* *** Classification Filters Control *** */
11416 static enum rte_eth_input_set_field
11417 str2inset(char *string)
11421 static const struct {
11423 enum rte_eth_input_set_field inset;
11424 } inset_table[] = {
11425 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
11426 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
11427 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
11428 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
11429 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
11430 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
11431 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
11432 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
11433 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
11434 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
11435 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
11436 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
11437 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
11438 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
11439 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
11440 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
11441 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
11442 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
11443 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
11444 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
11445 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
11446 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
11447 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
11448 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
11449 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
11450 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
11451 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
11452 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
11453 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
11454 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
11455 {"none", RTE_ETH_INPUT_SET_NONE},
11458 for (i = 0; i < RTE_DIM(inset_table); i++) {
11459 if (!strcmp(string, inset_table[i].str))
11460 return inset_table[i].inset;
11463 return RTE_ETH_INPUT_SET_UNKNOWN;
11466 /* Set flow director input set */
11467 struct cmd_set_fdir_input_set_result {
11468 cmdline_fixed_string_t set_fdir_input_set;
11470 cmdline_fixed_string_t flow_type;
11471 cmdline_fixed_string_t inset_field;
11472 cmdline_fixed_string_t select;
11476 cmd_set_fdir_input_set_parsed(void *parsed_result,
11477 __rte_unused struct cmdline *cl,
11478 __rte_unused void *data)
11480 struct cmd_set_fdir_input_set_result *res = parsed_result;
11481 struct rte_eth_fdir_filter_info info;
11483 memset(&info, 0, sizeof(info));
11484 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
11485 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
11486 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
11487 info.info.input_set_conf.inset_size = 1;
11488 if (!strcmp(res->select, "select"))
11489 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
11490 else if (!strcmp(res->select, "add"))
11491 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
11492 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11493 RTE_ETH_FILTER_SET, &info);
11496 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
11497 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11498 set_fdir_input_set, "set_fdir_input_set");
11499 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
11500 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
11502 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
11503 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11505 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
11506 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
11507 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
11508 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11510 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
11511 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
11512 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
11513 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
11514 "sctp-veri-tag#none");
11515 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
11516 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11517 select, "select#add");
11519 cmdline_parse_inst_t cmd_set_fdir_input_set = {
11520 .f = cmd_set_fdir_input_set_parsed,
11522 .help_str = "set_fdir_input_set <port_id> "
11523 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11524 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
11525 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
11526 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
11527 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
11528 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
11529 "sctp-veri-tag|none select|add",
11531 (void *)&cmd_set_fdir_input_set_cmd,
11532 (void *)&cmd_set_fdir_input_set_port_id,
11533 (void *)&cmd_set_fdir_input_set_flow_type,
11534 (void *)&cmd_set_fdir_input_set_field,
11535 (void *)&cmd_set_fdir_input_set_select,
11540 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
11541 struct cmd_mcast_addr_result {
11542 cmdline_fixed_string_t mcast_addr_cmd;
11543 cmdline_fixed_string_t what;
11545 struct rte_ether_addr mc_addr;
11548 static void cmd_mcast_addr_parsed(void *parsed_result,
11549 __rte_unused struct cmdline *cl,
11550 __rte_unused void *data)
11552 struct cmd_mcast_addr_result *res = parsed_result;
11554 if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
11555 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
11556 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
11557 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
11558 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
11561 if (strcmp(res->what, "add") == 0)
11562 mcast_addr_add(res->port_num, &res->mc_addr);
11564 mcast_addr_remove(res->port_num, &res->mc_addr);
11567 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
11568 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
11569 mcast_addr_cmd, "mcast_addr");
11570 cmdline_parse_token_string_t cmd_mcast_addr_what =
11571 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
11573 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
11574 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
11575 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
11576 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
11578 cmdline_parse_inst_t cmd_mcast_addr = {
11579 .f = cmd_mcast_addr_parsed,
11581 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
11582 "Add/Remove multicast MAC address on port_id",
11584 (void *)&cmd_mcast_addr_cmd,
11585 (void *)&cmd_mcast_addr_what,
11586 (void *)&cmd_mcast_addr_portnum,
11587 (void *)&cmd_mcast_addr_addr,
11592 /* l2 tunnel config
11593 * only support E-tag now.
11596 /* Ether type config */
11597 struct cmd_config_l2_tunnel_eth_type_result {
11598 cmdline_fixed_string_t port;
11599 cmdline_fixed_string_t config;
11600 cmdline_fixed_string_t all;
11602 cmdline_fixed_string_t l2_tunnel;
11603 cmdline_fixed_string_t l2_tunnel_type;
11604 cmdline_fixed_string_t eth_type;
11605 uint16_t eth_type_val;
11608 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
11609 TOKEN_STRING_INITIALIZER
11610 (struct cmd_config_l2_tunnel_eth_type_result,
11612 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
11613 TOKEN_STRING_INITIALIZER
11614 (struct cmd_config_l2_tunnel_eth_type_result,
11616 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
11617 TOKEN_STRING_INITIALIZER
11618 (struct cmd_config_l2_tunnel_eth_type_result,
11620 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
11621 TOKEN_NUM_INITIALIZER
11622 (struct cmd_config_l2_tunnel_eth_type_result,
11624 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
11625 TOKEN_STRING_INITIALIZER
11626 (struct cmd_config_l2_tunnel_eth_type_result,
11627 l2_tunnel, "l2-tunnel");
11628 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
11629 TOKEN_STRING_INITIALIZER
11630 (struct cmd_config_l2_tunnel_eth_type_result,
11631 l2_tunnel_type, "E-tag");
11632 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
11633 TOKEN_STRING_INITIALIZER
11634 (struct cmd_config_l2_tunnel_eth_type_result,
11635 eth_type, "ether-type");
11636 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
11637 TOKEN_NUM_INITIALIZER
11638 (struct cmd_config_l2_tunnel_eth_type_result,
11639 eth_type_val, UINT16);
11641 static enum rte_eth_tunnel_type
11642 str2fdir_l2_tunnel_type(char *string)
11646 static const struct {
11648 enum rte_eth_tunnel_type type;
11649 } l2_tunnel_type_str[] = {
11650 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
11653 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
11654 if (!strcmp(l2_tunnel_type_str[i].str, string))
11655 return l2_tunnel_type_str[i].type;
11657 return RTE_TUNNEL_TYPE_NONE;
11660 /* ether type config for all ports */
11662 cmd_config_l2_tunnel_eth_type_all_parsed
11663 (void *parsed_result,
11664 __rte_unused struct cmdline *cl,
11665 __rte_unused void *data)
11667 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
11668 struct rte_eth_l2_tunnel_conf entry;
11671 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11672 entry.ether_type = res->eth_type_val;
11674 RTE_ETH_FOREACH_DEV(pid) {
11675 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
11679 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
11680 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
11682 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
11684 (void *)&cmd_config_l2_tunnel_eth_type_port,
11685 (void *)&cmd_config_l2_tunnel_eth_type_config,
11686 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
11687 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
11688 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
11689 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
11690 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
11695 /* ether type config for a specific port */
11697 cmd_config_l2_tunnel_eth_type_specific_parsed(
11698 void *parsed_result,
11699 __rte_unused struct cmdline *cl,
11700 __rte_unused void *data)
11702 struct cmd_config_l2_tunnel_eth_type_result *res =
11704 struct rte_eth_l2_tunnel_conf entry;
11706 if (port_id_is_invalid(res->id, ENABLED_WARN))
11709 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11710 entry.ether_type = res->eth_type_val;
11712 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
11715 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
11716 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
11718 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
11720 (void *)&cmd_config_l2_tunnel_eth_type_port,
11721 (void *)&cmd_config_l2_tunnel_eth_type_config,
11722 (void *)&cmd_config_l2_tunnel_eth_type_id,
11723 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
11724 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
11725 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
11726 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
11731 /* Enable/disable l2 tunnel */
11732 struct cmd_config_l2_tunnel_en_dis_result {
11733 cmdline_fixed_string_t port;
11734 cmdline_fixed_string_t config;
11735 cmdline_fixed_string_t all;
11737 cmdline_fixed_string_t l2_tunnel;
11738 cmdline_fixed_string_t l2_tunnel_type;
11739 cmdline_fixed_string_t en_dis;
11742 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
11743 TOKEN_STRING_INITIALIZER
11744 (struct cmd_config_l2_tunnel_en_dis_result,
11746 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
11747 TOKEN_STRING_INITIALIZER
11748 (struct cmd_config_l2_tunnel_en_dis_result,
11750 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
11751 TOKEN_STRING_INITIALIZER
11752 (struct cmd_config_l2_tunnel_en_dis_result,
11754 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
11755 TOKEN_NUM_INITIALIZER
11756 (struct cmd_config_l2_tunnel_en_dis_result,
11758 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
11759 TOKEN_STRING_INITIALIZER
11760 (struct cmd_config_l2_tunnel_en_dis_result,
11761 l2_tunnel, "l2-tunnel");
11762 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
11763 TOKEN_STRING_INITIALIZER
11764 (struct cmd_config_l2_tunnel_en_dis_result,
11765 l2_tunnel_type, "E-tag");
11766 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
11767 TOKEN_STRING_INITIALIZER
11768 (struct cmd_config_l2_tunnel_en_dis_result,
11769 en_dis, "enable#disable");
11771 /* enable/disable l2 tunnel for all ports */
11773 cmd_config_l2_tunnel_en_dis_all_parsed(
11774 void *parsed_result,
11775 __rte_unused struct cmdline *cl,
11776 __rte_unused void *data)
11778 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
11779 struct rte_eth_l2_tunnel_conf entry;
11783 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11785 if (!strcmp("enable", res->en_dis))
11790 RTE_ETH_FOREACH_DEV(pid) {
11791 rte_eth_dev_l2_tunnel_offload_set(pid,
11793 ETH_L2_TUNNEL_ENABLE_MASK,
11798 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
11799 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
11801 .help_str = "port config all l2-tunnel E-tag enable|disable",
11803 (void *)&cmd_config_l2_tunnel_en_dis_port,
11804 (void *)&cmd_config_l2_tunnel_en_dis_config,
11805 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
11806 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
11807 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
11808 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
11813 /* enable/disable l2 tunnel for a port */
11815 cmd_config_l2_tunnel_en_dis_specific_parsed(
11816 void *parsed_result,
11817 __rte_unused struct cmdline *cl,
11818 __rte_unused void *data)
11820 struct cmd_config_l2_tunnel_en_dis_result *res =
11822 struct rte_eth_l2_tunnel_conf entry;
11824 if (port_id_is_invalid(res->id, ENABLED_WARN))
11827 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11829 if (!strcmp("enable", res->en_dis))
11830 rte_eth_dev_l2_tunnel_offload_set(res->id,
11832 ETH_L2_TUNNEL_ENABLE_MASK,
11835 rte_eth_dev_l2_tunnel_offload_set(res->id,
11837 ETH_L2_TUNNEL_ENABLE_MASK,
11841 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
11842 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
11844 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
11846 (void *)&cmd_config_l2_tunnel_en_dis_port,
11847 (void *)&cmd_config_l2_tunnel_en_dis_config,
11848 (void *)&cmd_config_l2_tunnel_en_dis_id,
11849 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
11850 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
11851 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
11856 /* E-tag configuration */
11858 /* Common result structure for all E-tag configuration */
11859 struct cmd_config_e_tag_result {
11860 cmdline_fixed_string_t e_tag;
11861 cmdline_fixed_string_t set;
11862 cmdline_fixed_string_t insertion;
11863 cmdline_fixed_string_t stripping;
11864 cmdline_fixed_string_t forwarding;
11865 cmdline_fixed_string_t filter;
11866 cmdline_fixed_string_t add;
11867 cmdline_fixed_string_t del;
11868 cmdline_fixed_string_t on;
11869 cmdline_fixed_string_t off;
11870 cmdline_fixed_string_t on_off;
11871 cmdline_fixed_string_t port_tag_id;
11872 uint32_t port_tag_id_val;
11873 cmdline_fixed_string_t e_tag_id;
11874 uint16_t e_tag_id_val;
11875 cmdline_fixed_string_t dst_pool;
11876 uint8_t dst_pool_val;
11877 cmdline_fixed_string_t port;
11879 cmdline_fixed_string_t vf;
11883 /* Common CLI fields for all E-tag configuration */
11884 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
11885 TOKEN_STRING_INITIALIZER
11886 (struct cmd_config_e_tag_result,
11888 cmdline_parse_token_string_t cmd_config_e_tag_set =
11889 TOKEN_STRING_INITIALIZER
11890 (struct cmd_config_e_tag_result,
11892 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
11893 TOKEN_STRING_INITIALIZER
11894 (struct cmd_config_e_tag_result,
11895 insertion, "insertion");
11896 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
11897 TOKEN_STRING_INITIALIZER
11898 (struct cmd_config_e_tag_result,
11899 stripping, "stripping");
11900 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
11901 TOKEN_STRING_INITIALIZER
11902 (struct cmd_config_e_tag_result,
11903 forwarding, "forwarding");
11904 cmdline_parse_token_string_t cmd_config_e_tag_filter =
11905 TOKEN_STRING_INITIALIZER
11906 (struct cmd_config_e_tag_result,
11908 cmdline_parse_token_string_t cmd_config_e_tag_add =
11909 TOKEN_STRING_INITIALIZER
11910 (struct cmd_config_e_tag_result,
11912 cmdline_parse_token_string_t cmd_config_e_tag_del =
11913 TOKEN_STRING_INITIALIZER
11914 (struct cmd_config_e_tag_result,
11916 cmdline_parse_token_string_t cmd_config_e_tag_on =
11917 TOKEN_STRING_INITIALIZER
11918 (struct cmd_config_e_tag_result,
11920 cmdline_parse_token_string_t cmd_config_e_tag_off =
11921 TOKEN_STRING_INITIALIZER
11922 (struct cmd_config_e_tag_result,
11924 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
11925 TOKEN_STRING_INITIALIZER
11926 (struct cmd_config_e_tag_result,
11928 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
11929 TOKEN_STRING_INITIALIZER
11930 (struct cmd_config_e_tag_result,
11931 port_tag_id, "port-tag-id");
11932 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
11933 TOKEN_NUM_INITIALIZER
11934 (struct cmd_config_e_tag_result,
11935 port_tag_id_val, UINT32);
11936 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
11937 TOKEN_STRING_INITIALIZER
11938 (struct cmd_config_e_tag_result,
11939 e_tag_id, "e-tag-id");
11940 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
11941 TOKEN_NUM_INITIALIZER
11942 (struct cmd_config_e_tag_result,
11943 e_tag_id_val, UINT16);
11944 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
11945 TOKEN_STRING_INITIALIZER
11946 (struct cmd_config_e_tag_result,
11947 dst_pool, "dst-pool");
11948 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
11949 TOKEN_NUM_INITIALIZER
11950 (struct cmd_config_e_tag_result,
11951 dst_pool_val, UINT8);
11952 cmdline_parse_token_string_t cmd_config_e_tag_port =
11953 TOKEN_STRING_INITIALIZER
11954 (struct cmd_config_e_tag_result,
11956 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
11957 TOKEN_NUM_INITIALIZER
11958 (struct cmd_config_e_tag_result,
11960 cmdline_parse_token_string_t cmd_config_e_tag_vf =
11961 TOKEN_STRING_INITIALIZER
11962 (struct cmd_config_e_tag_result,
11964 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
11965 TOKEN_NUM_INITIALIZER
11966 (struct cmd_config_e_tag_result,
11969 /* E-tag insertion configuration */
11971 cmd_config_e_tag_insertion_en_parsed(
11972 void *parsed_result,
11973 __rte_unused struct cmdline *cl,
11974 __rte_unused void *data)
11976 struct cmd_config_e_tag_result *res =
11978 struct rte_eth_l2_tunnel_conf entry;
11980 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11983 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11984 entry.tunnel_id = res->port_tag_id_val;
11985 entry.vf_id = res->vf_id;
11986 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
11988 ETH_L2_TUNNEL_INSERTION_MASK,
11993 cmd_config_e_tag_insertion_dis_parsed(
11994 void *parsed_result,
11995 __rte_unused struct cmdline *cl,
11996 __rte_unused void *data)
11998 struct cmd_config_e_tag_result *res =
12000 struct rte_eth_l2_tunnel_conf entry;
12002 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12005 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12006 entry.vf_id = res->vf_id;
12008 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12010 ETH_L2_TUNNEL_INSERTION_MASK,
12014 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
12015 .f = cmd_config_e_tag_insertion_en_parsed,
12017 .help_str = "E-tag ... : E-tag insertion enable",
12019 (void *)&cmd_config_e_tag_e_tag,
12020 (void *)&cmd_config_e_tag_set,
12021 (void *)&cmd_config_e_tag_insertion,
12022 (void *)&cmd_config_e_tag_on,
12023 (void *)&cmd_config_e_tag_port_tag_id,
12024 (void *)&cmd_config_e_tag_port_tag_id_val,
12025 (void *)&cmd_config_e_tag_port,
12026 (void *)&cmd_config_e_tag_port_id,
12027 (void *)&cmd_config_e_tag_vf,
12028 (void *)&cmd_config_e_tag_vf_id,
12033 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
12034 .f = cmd_config_e_tag_insertion_dis_parsed,
12036 .help_str = "E-tag ... : E-tag insertion disable",
12038 (void *)&cmd_config_e_tag_e_tag,
12039 (void *)&cmd_config_e_tag_set,
12040 (void *)&cmd_config_e_tag_insertion,
12041 (void *)&cmd_config_e_tag_off,
12042 (void *)&cmd_config_e_tag_port,
12043 (void *)&cmd_config_e_tag_port_id,
12044 (void *)&cmd_config_e_tag_vf,
12045 (void *)&cmd_config_e_tag_vf_id,
12050 /* E-tag stripping configuration */
12052 cmd_config_e_tag_stripping_parsed(
12053 void *parsed_result,
12054 __rte_unused struct cmdline *cl,
12055 __rte_unused void *data)
12057 struct cmd_config_e_tag_result *res =
12059 struct rte_eth_l2_tunnel_conf entry;
12061 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12064 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12066 if (!strcmp(res->on_off, "on"))
12067 rte_eth_dev_l2_tunnel_offload_set
12070 ETH_L2_TUNNEL_STRIPPING_MASK,
12073 rte_eth_dev_l2_tunnel_offload_set
12076 ETH_L2_TUNNEL_STRIPPING_MASK,
12080 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
12081 .f = cmd_config_e_tag_stripping_parsed,
12083 .help_str = "E-tag ... : E-tag stripping enable/disable",
12085 (void *)&cmd_config_e_tag_e_tag,
12086 (void *)&cmd_config_e_tag_set,
12087 (void *)&cmd_config_e_tag_stripping,
12088 (void *)&cmd_config_e_tag_on_off,
12089 (void *)&cmd_config_e_tag_port,
12090 (void *)&cmd_config_e_tag_port_id,
12095 /* E-tag forwarding configuration */
12097 cmd_config_e_tag_forwarding_parsed(
12098 void *parsed_result,
12099 __rte_unused struct cmdline *cl,
12100 __rte_unused void *data)
12102 struct cmd_config_e_tag_result *res = parsed_result;
12103 struct rte_eth_l2_tunnel_conf entry;
12105 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12108 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12110 if (!strcmp(res->on_off, "on"))
12111 rte_eth_dev_l2_tunnel_offload_set
12114 ETH_L2_TUNNEL_FORWARDING_MASK,
12117 rte_eth_dev_l2_tunnel_offload_set
12120 ETH_L2_TUNNEL_FORWARDING_MASK,
12124 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
12125 .f = cmd_config_e_tag_forwarding_parsed,
12127 .help_str = "E-tag ... : E-tag forwarding enable/disable",
12129 (void *)&cmd_config_e_tag_e_tag,
12130 (void *)&cmd_config_e_tag_set,
12131 (void *)&cmd_config_e_tag_forwarding,
12132 (void *)&cmd_config_e_tag_on_off,
12133 (void *)&cmd_config_e_tag_port,
12134 (void *)&cmd_config_e_tag_port_id,
12139 /* vf vlan anti spoof configuration */
12141 /* Common result structure for vf vlan anti spoof */
12142 struct cmd_vf_vlan_anti_spoof_result {
12143 cmdline_fixed_string_t set;
12144 cmdline_fixed_string_t vf;
12145 cmdline_fixed_string_t vlan;
12146 cmdline_fixed_string_t antispoof;
12149 cmdline_fixed_string_t on_off;
12152 /* Common CLI fields for vf vlan anti spoof enable disable */
12153 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
12154 TOKEN_STRING_INITIALIZER
12155 (struct cmd_vf_vlan_anti_spoof_result,
12157 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
12158 TOKEN_STRING_INITIALIZER
12159 (struct cmd_vf_vlan_anti_spoof_result,
12161 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
12162 TOKEN_STRING_INITIALIZER
12163 (struct cmd_vf_vlan_anti_spoof_result,
12165 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
12166 TOKEN_STRING_INITIALIZER
12167 (struct cmd_vf_vlan_anti_spoof_result,
12168 antispoof, "antispoof");
12169 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
12170 TOKEN_NUM_INITIALIZER
12171 (struct cmd_vf_vlan_anti_spoof_result,
12173 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
12174 TOKEN_NUM_INITIALIZER
12175 (struct cmd_vf_vlan_anti_spoof_result,
12177 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
12178 TOKEN_STRING_INITIALIZER
12179 (struct cmd_vf_vlan_anti_spoof_result,
12183 cmd_set_vf_vlan_anti_spoof_parsed(
12184 void *parsed_result,
12185 __rte_unused struct cmdline *cl,
12186 __rte_unused void *data)
12188 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
12189 int ret = -ENOTSUP;
12191 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12193 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12196 #ifdef RTE_NET_IXGBE
12197 if (ret == -ENOTSUP)
12198 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
12199 res->vf_id, is_on);
12201 #ifdef RTE_NET_I40E
12202 if (ret == -ENOTSUP)
12203 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
12204 res->vf_id, is_on);
12206 #ifdef RTE_NET_BNXT
12207 if (ret == -ENOTSUP)
12208 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
12209 res->vf_id, is_on);
12216 printf("invalid vf_id %d\n", res->vf_id);
12219 printf("invalid port_id %d\n", res->port_id);
12222 printf("function not implemented\n");
12225 printf("programming error: (%s)\n", strerror(-ret));
12229 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
12230 .f = cmd_set_vf_vlan_anti_spoof_parsed,
12232 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
12234 (void *)&cmd_vf_vlan_anti_spoof_set,
12235 (void *)&cmd_vf_vlan_anti_spoof_vf,
12236 (void *)&cmd_vf_vlan_anti_spoof_vlan,
12237 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
12238 (void *)&cmd_vf_vlan_anti_spoof_port_id,
12239 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
12240 (void *)&cmd_vf_vlan_anti_spoof_on_off,
12245 /* vf mac anti spoof configuration */
12247 /* Common result structure for vf mac anti spoof */
12248 struct cmd_vf_mac_anti_spoof_result {
12249 cmdline_fixed_string_t set;
12250 cmdline_fixed_string_t vf;
12251 cmdline_fixed_string_t mac;
12252 cmdline_fixed_string_t antispoof;
12255 cmdline_fixed_string_t on_off;
12258 /* Common CLI fields for vf mac anti spoof enable disable */
12259 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
12260 TOKEN_STRING_INITIALIZER
12261 (struct cmd_vf_mac_anti_spoof_result,
12263 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
12264 TOKEN_STRING_INITIALIZER
12265 (struct cmd_vf_mac_anti_spoof_result,
12267 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
12268 TOKEN_STRING_INITIALIZER
12269 (struct cmd_vf_mac_anti_spoof_result,
12271 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
12272 TOKEN_STRING_INITIALIZER
12273 (struct cmd_vf_mac_anti_spoof_result,
12274 antispoof, "antispoof");
12275 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
12276 TOKEN_NUM_INITIALIZER
12277 (struct cmd_vf_mac_anti_spoof_result,
12279 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
12280 TOKEN_NUM_INITIALIZER
12281 (struct cmd_vf_mac_anti_spoof_result,
12283 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
12284 TOKEN_STRING_INITIALIZER
12285 (struct cmd_vf_mac_anti_spoof_result,
12289 cmd_set_vf_mac_anti_spoof_parsed(
12290 void *parsed_result,
12291 __rte_unused struct cmdline *cl,
12292 __rte_unused void *data)
12294 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
12295 int ret = -ENOTSUP;
12297 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12299 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12302 #ifdef RTE_NET_IXGBE
12303 if (ret == -ENOTSUP)
12304 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
12305 res->vf_id, is_on);
12307 #ifdef RTE_NET_I40E
12308 if (ret == -ENOTSUP)
12309 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
12310 res->vf_id, is_on);
12312 #ifdef RTE_NET_BNXT
12313 if (ret == -ENOTSUP)
12314 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
12315 res->vf_id, is_on);
12322 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12325 printf("invalid port_id %d\n", res->port_id);
12328 printf("function not implemented\n");
12331 printf("programming error: (%s)\n", strerror(-ret));
12335 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
12336 .f = cmd_set_vf_mac_anti_spoof_parsed,
12338 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
12340 (void *)&cmd_vf_mac_anti_spoof_set,
12341 (void *)&cmd_vf_mac_anti_spoof_vf,
12342 (void *)&cmd_vf_mac_anti_spoof_mac,
12343 (void *)&cmd_vf_mac_anti_spoof_antispoof,
12344 (void *)&cmd_vf_mac_anti_spoof_port_id,
12345 (void *)&cmd_vf_mac_anti_spoof_vf_id,
12346 (void *)&cmd_vf_mac_anti_spoof_on_off,
12351 /* vf vlan strip queue configuration */
12353 /* Common result structure for vf mac anti spoof */
12354 struct cmd_vf_vlan_stripq_result {
12355 cmdline_fixed_string_t set;
12356 cmdline_fixed_string_t vf;
12357 cmdline_fixed_string_t vlan;
12358 cmdline_fixed_string_t stripq;
12361 cmdline_fixed_string_t on_off;
12364 /* Common CLI fields for vf vlan strip enable disable */
12365 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
12366 TOKEN_STRING_INITIALIZER
12367 (struct cmd_vf_vlan_stripq_result,
12369 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
12370 TOKEN_STRING_INITIALIZER
12371 (struct cmd_vf_vlan_stripq_result,
12373 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
12374 TOKEN_STRING_INITIALIZER
12375 (struct cmd_vf_vlan_stripq_result,
12377 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
12378 TOKEN_STRING_INITIALIZER
12379 (struct cmd_vf_vlan_stripq_result,
12381 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
12382 TOKEN_NUM_INITIALIZER
12383 (struct cmd_vf_vlan_stripq_result,
12385 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
12386 TOKEN_NUM_INITIALIZER
12387 (struct cmd_vf_vlan_stripq_result,
12389 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
12390 TOKEN_STRING_INITIALIZER
12391 (struct cmd_vf_vlan_stripq_result,
12395 cmd_set_vf_vlan_stripq_parsed(
12396 void *parsed_result,
12397 __rte_unused struct cmdline *cl,
12398 __rte_unused void *data)
12400 struct cmd_vf_vlan_stripq_result *res = parsed_result;
12401 int ret = -ENOTSUP;
12403 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12405 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12408 #ifdef RTE_NET_IXGBE
12409 if (ret == -ENOTSUP)
12410 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
12411 res->vf_id, is_on);
12413 #ifdef RTE_NET_I40E
12414 if (ret == -ENOTSUP)
12415 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
12416 res->vf_id, is_on);
12418 #ifdef RTE_NET_BNXT
12419 if (ret == -ENOTSUP)
12420 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
12421 res->vf_id, is_on);
12428 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12431 printf("invalid port_id %d\n", res->port_id);
12434 printf("function not implemented\n");
12437 printf("programming error: (%s)\n", strerror(-ret));
12441 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
12442 .f = cmd_set_vf_vlan_stripq_parsed,
12444 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
12446 (void *)&cmd_vf_vlan_stripq_set,
12447 (void *)&cmd_vf_vlan_stripq_vf,
12448 (void *)&cmd_vf_vlan_stripq_vlan,
12449 (void *)&cmd_vf_vlan_stripq_stripq,
12450 (void *)&cmd_vf_vlan_stripq_port_id,
12451 (void *)&cmd_vf_vlan_stripq_vf_id,
12452 (void *)&cmd_vf_vlan_stripq_on_off,
12457 /* vf vlan insert configuration */
12459 /* Common result structure for vf vlan insert */
12460 struct cmd_vf_vlan_insert_result {
12461 cmdline_fixed_string_t set;
12462 cmdline_fixed_string_t vf;
12463 cmdline_fixed_string_t vlan;
12464 cmdline_fixed_string_t insert;
12470 /* Common CLI fields for vf vlan insert enable disable */
12471 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
12472 TOKEN_STRING_INITIALIZER
12473 (struct cmd_vf_vlan_insert_result,
12475 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
12476 TOKEN_STRING_INITIALIZER
12477 (struct cmd_vf_vlan_insert_result,
12479 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
12480 TOKEN_STRING_INITIALIZER
12481 (struct cmd_vf_vlan_insert_result,
12483 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
12484 TOKEN_STRING_INITIALIZER
12485 (struct cmd_vf_vlan_insert_result,
12487 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
12488 TOKEN_NUM_INITIALIZER
12489 (struct cmd_vf_vlan_insert_result,
12491 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
12492 TOKEN_NUM_INITIALIZER
12493 (struct cmd_vf_vlan_insert_result,
12495 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
12496 TOKEN_NUM_INITIALIZER
12497 (struct cmd_vf_vlan_insert_result,
12501 cmd_set_vf_vlan_insert_parsed(
12502 void *parsed_result,
12503 __rte_unused struct cmdline *cl,
12504 __rte_unused void *data)
12506 struct cmd_vf_vlan_insert_result *res = parsed_result;
12507 int ret = -ENOTSUP;
12509 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12512 #ifdef RTE_NET_IXGBE
12513 if (ret == -ENOTSUP)
12514 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
12517 #ifdef RTE_NET_I40E
12518 if (ret == -ENOTSUP)
12519 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
12522 #ifdef RTE_NET_BNXT
12523 if (ret == -ENOTSUP)
12524 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
12532 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
12535 printf("invalid port_id %d\n", res->port_id);
12538 printf("function not implemented\n");
12541 printf("programming error: (%s)\n", strerror(-ret));
12545 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
12546 .f = cmd_set_vf_vlan_insert_parsed,
12548 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
12550 (void *)&cmd_vf_vlan_insert_set,
12551 (void *)&cmd_vf_vlan_insert_vf,
12552 (void *)&cmd_vf_vlan_insert_vlan,
12553 (void *)&cmd_vf_vlan_insert_insert,
12554 (void *)&cmd_vf_vlan_insert_port_id,
12555 (void *)&cmd_vf_vlan_insert_vf_id,
12556 (void *)&cmd_vf_vlan_insert_vlan_id,
12561 /* tx loopback configuration */
12563 /* Common result structure for tx loopback */
12564 struct cmd_tx_loopback_result {
12565 cmdline_fixed_string_t set;
12566 cmdline_fixed_string_t tx;
12567 cmdline_fixed_string_t loopback;
12569 cmdline_fixed_string_t on_off;
12572 /* Common CLI fields for tx loopback enable disable */
12573 cmdline_parse_token_string_t cmd_tx_loopback_set =
12574 TOKEN_STRING_INITIALIZER
12575 (struct cmd_tx_loopback_result,
12577 cmdline_parse_token_string_t cmd_tx_loopback_tx =
12578 TOKEN_STRING_INITIALIZER
12579 (struct cmd_tx_loopback_result,
12581 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
12582 TOKEN_STRING_INITIALIZER
12583 (struct cmd_tx_loopback_result,
12584 loopback, "loopback");
12585 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
12586 TOKEN_NUM_INITIALIZER
12587 (struct cmd_tx_loopback_result,
12589 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
12590 TOKEN_STRING_INITIALIZER
12591 (struct cmd_tx_loopback_result,
12595 cmd_set_tx_loopback_parsed(
12596 void *parsed_result,
12597 __rte_unused struct cmdline *cl,
12598 __rte_unused void *data)
12600 struct cmd_tx_loopback_result *res = parsed_result;
12601 int ret = -ENOTSUP;
12603 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12605 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12608 #ifdef RTE_NET_IXGBE
12609 if (ret == -ENOTSUP)
12610 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
12612 #ifdef RTE_NET_I40E
12613 if (ret == -ENOTSUP)
12614 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
12616 #ifdef RTE_NET_BNXT
12617 if (ret == -ENOTSUP)
12618 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
12620 #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA
12621 if (ret == -ENOTSUP)
12622 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
12629 printf("invalid is_on %d\n", is_on);
12632 printf("invalid port_id %d\n", res->port_id);
12635 printf("function not implemented\n");
12638 printf("programming error: (%s)\n", strerror(-ret));
12642 cmdline_parse_inst_t cmd_set_tx_loopback = {
12643 .f = cmd_set_tx_loopback_parsed,
12645 .help_str = "set tx loopback <port_id> on|off",
12647 (void *)&cmd_tx_loopback_set,
12648 (void *)&cmd_tx_loopback_tx,
12649 (void *)&cmd_tx_loopback_loopback,
12650 (void *)&cmd_tx_loopback_port_id,
12651 (void *)&cmd_tx_loopback_on_off,
12656 /* all queues drop enable configuration */
12658 /* Common result structure for all queues drop enable */
12659 struct cmd_all_queues_drop_en_result {
12660 cmdline_fixed_string_t set;
12661 cmdline_fixed_string_t all;
12662 cmdline_fixed_string_t queues;
12663 cmdline_fixed_string_t drop;
12665 cmdline_fixed_string_t on_off;
12668 /* Common CLI fields for tx loopback enable disable */
12669 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
12670 TOKEN_STRING_INITIALIZER
12671 (struct cmd_all_queues_drop_en_result,
12673 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
12674 TOKEN_STRING_INITIALIZER
12675 (struct cmd_all_queues_drop_en_result,
12677 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
12678 TOKEN_STRING_INITIALIZER
12679 (struct cmd_all_queues_drop_en_result,
12681 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
12682 TOKEN_STRING_INITIALIZER
12683 (struct cmd_all_queues_drop_en_result,
12685 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
12686 TOKEN_NUM_INITIALIZER
12687 (struct cmd_all_queues_drop_en_result,
12689 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
12690 TOKEN_STRING_INITIALIZER
12691 (struct cmd_all_queues_drop_en_result,
12695 cmd_set_all_queues_drop_en_parsed(
12696 void *parsed_result,
12697 __rte_unused struct cmdline *cl,
12698 __rte_unused void *data)
12700 struct cmd_all_queues_drop_en_result *res = parsed_result;
12701 int ret = -ENOTSUP;
12702 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12704 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12707 #ifdef RTE_NET_IXGBE
12708 if (ret == -ENOTSUP)
12709 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
12711 #ifdef RTE_NET_BNXT
12712 if (ret == -ENOTSUP)
12713 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
12719 printf("invalid is_on %d\n", is_on);
12722 printf("invalid port_id %d\n", res->port_id);
12725 printf("function not implemented\n");
12728 printf("programming error: (%s)\n", strerror(-ret));
12732 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
12733 .f = cmd_set_all_queues_drop_en_parsed,
12735 .help_str = "set all queues drop <port_id> on|off",
12737 (void *)&cmd_all_queues_drop_en_set,
12738 (void *)&cmd_all_queues_drop_en_all,
12739 (void *)&cmd_all_queues_drop_en_queues,
12740 (void *)&cmd_all_queues_drop_en_drop,
12741 (void *)&cmd_all_queues_drop_en_port_id,
12742 (void *)&cmd_all_queues_drop_en_on_off,
12747 /* vf split drop enable configuration */
12749 /* Common result structure for vf split drop enable */
12750 struct cmd_vf_split_drop_en_result {
12751 cmdline_fixed_string_t set;
12752 cmdline_fixed_string_t vf;
12753 cmdline_fixed_string_t split;
12754 cmdline_fixed_string_t drop;
12757 cmdline_fixed_string_t on_off;
12760 /* Common CLI fields for vf split drop enable disable */
12761 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
12762 TOKEN_STRING_INITIALIZER
12763 (struct cmd_vf_split_drop_en_result,
12765 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
12766 TOKEN_STRING_INITIALIZER
12767 (struct cmd_vf_split_drop_en_result,
12769 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
12770 TOKEN_STRING_INITIALIZER
12771 (struct cmd_vf_split_drop_en_result,
12773 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
12774 TOKEN_STRING_INITIALIZER
12775 (struct cmd_vf_split_drop_en_result,
12777 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
12778 TOKEN_NUM_INITIALIZER
12779 (struct cmd_vf_split_drop_en_result,
12781 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
12782 TOKEN_NUM_INITIALIZER
12783 (struct cmd_vf_split_drop_en_result,
12785 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
12786 TOKEN_STRING_INITIALIZER
12787 (struct cmd_vf_split_drop_en_result,
12791 cmd_set_vf_split_drop_en_parsed(
12792 void *parsed_result,
12793 __rte_unused struct cmdline *cl,
12794 __rte_unused void *data)
12796 struct cmd_vf_split_drop_en_result *res = parsed_result;
12797 int ret = -ENOTSUP;
12798 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12800 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12803 #ifdef RTE_NET_IXGBE
12804 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
12811 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12814 printf("invalid port_id %d\n", res->port_id);
12817 printf("not supported on port %d\n", res->port_id);
12820 printf("programming error: (%s)\n", strerror(-ret));
12824 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
12825 .f = cmd_set_vf_split_drop_en_parsed,
12827 .help_str = "set vf split drop <port_id> <vf_id> on|off",
12829 (void *)&cmd_vf_split_drop_en_set,
12830 (void *)&cmd_vf_split_drop_en_vf,
12831 (void *)&cmd_vf_split_drop_en_split,
12832 (void *)&cmd_vf_split_drop_en_drop,
12833 (void *)&cmd_vf_split_drop_en_port_id,
12834 (void *)&cmd_vf_split_drop_en_vf_id,
12835 (void *)&cmd_vf_split_drop_en_on_off,
12840 /* vf mac address configuration */
12842 /* Common result structure for vf mac address */
12843 struct cmd_set_vf_mac_addr_result {
12844 cmdline_fixed_string_t set;
12845 cmdline_fixed_string_t vf;
12846 cmdline_fixed_string_t mac;
12847 cmdline_fixed_string_t addr;
12850 struct rte_ether_addr mac_addr;
12854 /* Common CLI fields for vf split drop enable disable */
12855 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
12856 TOKEN_STRING_INITIALIZER
12857 (struct cmd_set_vf_mac_addr_result,
12859 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
12860 TOKEN_STRING_INITIALIZER
12861 (struct cmd_set_vf_mac_addr_result,
12863 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
12864 TOKEN_STRING_INITIALIZER
12865 (struct cmd_set_vf_mac_addr_result,
12867 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
12868 TOKEN_STRING_INITIALIZER
12869 (struct cmd_set_vf_mac_addr_result,
12871 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
12872 TOKEN_NUM_INITIALIZER
12873 (struct cmd_set_vf_mac_addr_result,
12875 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
12876 TOKEN_NUM_INITIALIZER
12877 (struct cmd_set_vf_mac_addr_result,
12879 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
12880 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
12884 cmd_set_vf_mac_addr_parsed(
12885 void *parsed_result,
12886 __rte_unused struct cmdline *cl,
12887 __rte_unused void *data)
12889 struct cmd_set_vf_mac_addr_result *res = parsed_result;
12890 int ret = -ENOTSUP;
12892 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12895 #ifdef RTE_NET_IXGBE
12896 if (ret == -ENOTSUP)
12897 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
12900 #ifdef RTE_NET_I40E
12901 if (ret == -ENOTSUP)
12902 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
12905 #ifdef RTE_NET_BNXT
12906 if (ret == -ENOTSUP)
12907 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
12915 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
12918 printf("invalid port_id %d\n", res->port_id);
12921 printf("function not implemented\n");
12924 printf("programming error: (%s)\n", strerror(-ret));
12928 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
12929 .f = cmd_set_vf_mac_addr_parsed,
12931 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
12933 (void *)&cmd_set_vf_mac_addr_set,
12934 (void *)&cmd_set_vf_mac_addr_vf,
12935 (void *)&cmd_set_vf_mac_addr_mac,
12936 (void *)&cmd_set_vf_mac_addr_addr,
12937 (void *)&cmd_set_vf_mac_addr_port_id,
12938 (void *)&cmd_set_vf_mac_addr_vf_id,
12939 (void *)&cmd_set_vf_mac_addr_mac_addr,
12944 /* MACsec configuration */
12946 /* Common result structure for MACsec offload enable */
12947 struct cmd_macsec_offload_on_result {
12948 cmdline_fixed_string_t set;
12949 cmdline_fixed_string_t macsec;
12950 cmdline_fixed_string_t offload;
12952 cmdline_fixed_string_t on;
12953 cmdline_fixed_string_t encrypt;
12954 cmdline_fixed_string_t en_on_off;
12955 cmdline_fixed_string_t replay_protect;
12956 cmdline_fixed_string_t rp_on_off;
12959 /* Common CLI fields for MACsec offload disable */
12960 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
12961 TOKEN_STRING_INITIALIZER
12962 (struct cmd_macsec_offload_on_result,
12964 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
12965 TOKEN_STRING_INITIALIZER
12966 (struct cmd_macsec_offload_on_result,
12968 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
12969 TOKEN_STRING_INITIALIZER
12970 (struct cmd_macsec_offload_on_result,
12971 offload, "offload");
12972 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
12973 TOKEN_NUM_INITIALIZER
12974 (struct cmd_macsec_offload_on_result,
12976 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
12977 TOKEN_STRING_INITIALIZER
12978 (struct cmd_macsec_offload_on_result,
12980 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
12981 TOKEN_STRING_INITIALIZER
12982 (struct cmd_macsec_offload_on_result,
12983 encrypt, "encrypt");
12984 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
12985 TOKEN_STRING_INITIALIZER
12986 (struct cmd_macsec_offload_on_result,
12987 en_on_off, "on#off");
12988 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
12989 TOKEN_STRING_INITIALIZER
12990 (struct cmd_macsec_offload_on_result,
12991 replay_protect, "replay-protect");
12992 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
12993 TOKEN_STRING_INITIALIZER
12994 (struct cmd_macsec_offload_on_result,
12995 rp_on_off, "on#off");
12998 cmd_set_macsec_offload_on_parsed(
12999 void *parsed_result,
13000 __rte_unused struct cmdline *cl,
13001 __rte_unused void *data)
13003 struct cmd_macsec_offload_on_result *res = parsed_result;
13004 int ret = -ENOTSUP;
13005 portid_t port_id = res->port_id;
13006 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
13007 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
13008 struct rte_eth_dev_info dev_info;
13010 if (port_id_is_invalid(port_id, ENABLED_WARN))
13012 if (!port_is_stopped(port_id)) {
13013 printf("Please stop port %d first\n", port_id);
13017 ret = eth_dev_info_get_print_err(port_id, &dev_info);
13021 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
13022 #ifdef RTE_NET_IXGBE
13023 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
13031 ports[port_id].dev_conf.txmode.offloads |=
13032 DEV_TX_OFFLOAD_MACSEC_INSERT;
13033 cmd_reconfig_device_queue(port_id, 1, 1);
13036 printf("invalid port_id %d\n", port_id);
13039 printf("not supported on port %d\n", port_id);
13042 printf("programming error: (%s)\n", strerror(-ret));
13046 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
13047 .f = cmd_set_macsec_offload_on_parsed,
13049 .help_str = "set macsec offload <port_id> on "
13050 "encrypt on|off replay-protect on|off",
13052 (void *)&cmd_macsec_offload_on_set,
13053 (void *)&cmd_macsec_offload_on_macsec,
13054 (void *)&cmd_macsec_offload_on_offload,
13055 (void *)&cmd_macsec_offload_on_port_id,
13056 (void *)&cmd_macsec_offload_on_on,
13057 (void *)&cmd_macsec_offload_on_encrypt,
13058 (void *)&cmd_macsec_offload_on_en_on_off,
13059 (void *)&cmd_macsec_offload_on_replay_protect,
13060 (void *)&cmd_macsec_offload_on_rp_on_off,
13065 /* Common result structure for MACsec offload disable */
13066 struct cmd_macsec_offload_off_result {
13067 cmdline_fixed_string_t set;
13068 cmdline_fixed_string_t macsec;
13069 cmdline_fixed_string_t offload;
13071 cmdline_fixed_string_t off;
13074 /* Common CLI fields for MACsec offload disable */
13075 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
13076 TOKEN_STRING_INITIALIZER
13077 (struct cmd_macsec_offload_off_result,
13079 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
13080 TOKEN_STRING_INITIALIZER
13081 (struct cmd_macsec_offload_off_result,
13083 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
13084 TOKEN_STRING_INITIALIZER
13085 (struct cmd_macsec_offload_off_result,
13086 offload, "offload");
13087 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
13088 TOKEN_NUM_INITIALIZER
13089 (struct cmd_macsec_offload_off_result,
13091 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
13092 TOKEN_STRING_INITIALIZER
13093 (struct cmd_macsec_offload_off_result,
13097 cmd_set_macsec_offload_off_parsed(
13098 void *parsed_result,
13099 __rte_unused struct cmdline *cl,
13100 __rte_unused void *data)
13102 struct cmd_macsec_offload_off_result *res = parsed_result;
13103 int ret = -ENOTSUP;
13104 struct rte_eth_dev_info dev_info;
13105 portid_t port_id = res->port_id;
13107 if (port_id_is_invalid(port_id, ENABLED_WARN))
13109 if (!port_is_stopped(port_id)) {
13110 printf("Please stop port %d first\n", port_id);
13114 ret = eth_dev_info_get_print_err(port_id, &dev_info);
13118 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
13119 #ifdef RTE_NET_IXGBE
13120 ret = rte_pmd_ixgbe_macsec_disable(port_id);
13125 ports[port_id].dev_conf.txmode.offloads &=
13126 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
13127 cmd_reconfig_device_queue(port_id, 1, 1);
13130 printf("invalid port_id %d\n", port_id);
13133 printf("not supported on port %d\n", port_id);
13136 printf("programming error: (%s)\n", strerror(-ret));
13140 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
13141 .f = cmd_set_macsec_offload_off_parsed,
13143 .help_str = "set macsec offload <port_id> off",
13145 (void *)&cmd_macsec_offload_off_set,
13146 (void *)&cmd_macsec_offload_off_macsec,
13147 (void *)&cmd_macsec_offload_off_offload,
13148 (void *)&cmd_macsec_offload_off_port_id,
13149 (void *)&cmd_macsec_offload_off_off,
13154 /* Common result structure for MACsec secure connection configure */
13155 struct cmd_macsec_sc_result {
13156 cmdline_fixed_string_t set;
13157 cmdline_fixed_string_t macsec;
13158 cmdline_fixed_string_t sc;
13159 cmdline_fixed_string_t tx_rx;
13161 struct rte_ether_addr mac;
13165 /* Common CLI fields for MACsec secure connection configure */
13166 cmdline_parse_token_string_t cmd_macsec_sc_set =
13167 TOKEN_STRING_INITIALIZER
13168 (struct cmd_macsec_sc_result,
13170 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
13171 TOKEN_STRING_INITIALIZER
13172 (struct cmd_macsec_sc_result,
13174 cmdline_parse_token_string_t cmd_macsec_sc_sc =
13175 TOKEN_STRING_INITIALIZER
13176 (struct cmd_macsec_sc_result,
13178 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
13179 TOKEN_STRING_INITIALIZER
13180 (struct cmd_macsec_sc_result,
13182 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
13183 TOKEN_NUM_INITIALIZER
13184 (struct cmd_macsec_sc_result,
13186 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
13187 TOKEN_ETHERADDR_INITIALIZER
13188 (struct cmd_macsec_sc_result,
13190 cmdline_parse_token_num_t cmd_macsec_sc_pi =
13191 TOKEN_NUM_INITIALIZER
13192 (struct cmd_macsec_sc_result,
13196 cmd_set_macsec_sc_parsed(
13197 void *parsed_result,
13198 __rte_unused struct cmdline *cl,
13199 __rte_unused void *data)
13201 struct cmd_macsec_sc_result *res = parsed_result;
13202 int ret = -ENOTSUP;
13203 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
13205 #ifdef RTE_NET_IXGBE
13207 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
13208 res->mac.addr_bytes) :
13209 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
13210 res->mac.addr_bytes, res->pi);
13212 RTE_SET_USED(is_tx);
13218 printf("invalid port_id %d\n", res->port_id);
13221 printf("not supported on port %d\n", res->port_id);
13224 printf("programming error: (%s)\n", strerror(-ret));
13228 cmdline_parse_inst_t cmd_set_macsec_sc = {
13229 .f = cmd_set_macsec_sc_parsed,
13231 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
13233 (void *)&cmd_macsec_sc_set,
13234 (void *)&cmd_macsec_sc_macsec,
13235 (void *)&cmd_macsec_sc_sc,
13236 (void *)&cmd_macsec_sc_tx_rx,
13237 (void *)&cmd_macsec_sc_port_id,
13238 (void *)&cmd_macsec_sc_mac,
13239 (void *)&cmd_macsec_sc_pi,
13244 /* Common result structure for MACsec secure connection configure */
13245 struct cmd_macsec_sa_result {
13246 cmdline_fixed_string_t set;
13247 cmdline_fixed_string_t macsec;
13248 cmdline_fixed_string_t sa;
13249 cmdline_fixed_string_t tx_rx;
13254 cmdline_fixed_string_t key;
13257 /* Common CLI fields for MACsec secure connection configure */
13258 cmdline_parse_token_string_t cmd_macsec_sa_set =
13259 TOKEN_STRING_INITIALIZER
13260 (struct cmd_macsec_sa_result,
13262 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
13263 TOKEN_STRING_INITIALIZER
13264 (struct cmd_macsec_sa_result,
13266 cmdline_parse_token_string_t cmd_macsec_sa_sa =
13267 TOKEN_STRING_INITIALIZER
13268 (struct cmd_macsec_sa_result,
13270 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
13271 TOKEN_STRING_INITIALIZER
13272 (struct cmd_macsec_sa_result,
13274 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
13275 TOKEN_NUM_INITIALIZER
13276 (struct cmd_macsec_sa_result,
13278 cmdline_parse_token_num_t cmd_macsec_sa_idx =
13279 TOKEN_NUM_INITIALIZER
13280 (struct cmd_macsec_sa_result,
13282 cmdline_parse_token_num_t cmd_macsec_sa_an =
13283 TOKEN_NUM_INITIALIZER
13284 (struct cmd_macsec_sa_result,
13286 cmdline_parse_token_num_t cmd_macsec_sa_pn =
13287 TOKEN_NUM_INITIALIZER
13288 (struct cmd_macsec_sa_result,
13290 cmdline_parse_token_string_t cmd_macsec_sa_key =
13291 TOKEN_STRING_INITIALIZER
13292 (struct cmd_macsec_sa_result,
13296 cmd_set_macsec_sa_parsed(
13297 void *parsed_result,
13298 __rte_unused struct cmdline *cl,
13299 __rte_unused void *data)
13301 struct cmd_macsec_sa_result *res = parsed_result;
13302 int ret = -ENOTSUP;
13303 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
13304 uint8_t key[16] = { 0 };
13310 key_len = strlen(res->key) / 2;
13314 for (i = 0; i < key_len; i++) {
13315 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
13318 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
13321 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
13324 #ifdef RTE_NET_IXGBE
13326 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
13327 res->idx, res->an, res->pn, key) :
13328 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
13329 res->idx, res->an, res->pn, key);
13331 RTE_SET_USED(is_tx);
13338 printf("invalid idx %d or an %d\n", res->idx, res->an);
13341 printf("invalid port_id %d\n", res->port_id);
13344 printf("not supported on port %d\n", res->port_id);
13347 printf("programming error: (%s)\n", strerror(-ret));
13351 cmdline_parse_inst_t cmd_set_macsec_sa = {
13352 .f = cmd_set_macsec_sa_parsed,
13354 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
13356 (void *)&cmd_macsec_sa_set,
13357 (void *)&cmd_macsec_sa_macsec,
13358 (void *)&cmd_macsec_sa_sa,
13359 (void *)&cmd_macsec_sa_tx_rx,
13360 (void *)&cmd_macsec_sa_port_id,
13361 (void *)&cmd_macsec_sa_idx,
13362 (void *)&cmd_macsec_sa_an,
13363 (void *)&cmd_macsec_sa_pn,
13364 (void *)&cmd_macsec_sa_key,
13369 /* VF unicast promiscuous mode configuration */
13371 /* Common result structure for VF unicast promiscuous mode */
13372 struct cmd_vf_promisc_result {
13373 cmdline_fixed_string_t set;
13374 cmdline_fixed_string_t vf;
13375 cmdline_fixed_string_t promisc;
13378 cmdline_fixed_string_t on_off;
13381 /* Common CLI fields for VF unicast promiscuous mode enable disable */
13382 cmdline_parse_token_string_t cmd_vf_promisc_set =
13383 TOKEN_STRING_INITIALIZER
13384 (struct cmd_vf_promisc_result,
13386 cmdline_parse_token_string_t cmd_vf_promisc_vf =
13387 TOKEN_STRING_INITIALIZER
13388 (struct cmd_vf_promisc_result,
13390 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
13391 TOKEN_STRING_INITIALIZER
13392 (struct cmd_vf_promisc_result,
13393 promisc, "promisc");
13394 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
13395 TOKEN_NUM_INITIALIZER
13396 (struct cmd_vf_promisc_result,
13398 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
13399 TOKEN_NUM_INITIALIZER
13400 (struct cmd_vf_promisc_result,
13402 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
13403 TOKEN_STRING_INITIALIZER
13404 (struct cmd_vf_promisc_result,
13408 cmd_set_vf_promisc_parsed(
13409 void *parsed_result,
13410 __rte_unused struct cmdline *cl,
13411 __rte_unused void *data)
13413 struct cmd_vf_promisc_result *res = parsed_result;
13414 int ret = -ENOTSUP;
13416 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13418 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13421 #ifdef RTE_NET_I40E
13422 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
13423 res->vf_id, is_on);
13430 printf("invalid vf_id %d\n", res->vf_id);
13433 printf("invalid port_id %d\n", res->port_id);
13436 printf("function not implemented\n");
13439 printf("programming error: (%s)\n", strerror(-ret));
13443 cmdline_parse_inst_t cmd_set_vf_promisc = {
13444 .f = cmd_set_vf_promisc_parsed,
13446 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
13447 "Set unicast promiscuous mode for a VF from the PF",
13449 (void *)&cmd_vf_promisc_set,
13450 (void *)&cmd_vf_promisc_vf,
13451 (void *)&cmd_vf_promisc_promisc,
13452 (void *)&cmd_vf_promisc_port_id,
13453 (void *)&cmd_vf_promisc_vf_id,
13454 (void *)&cmd_vf_promisc_on_off,
13459 /* VF multicast promiscuous mode configuration */
13461 /* Common result structure for VF multicast promiscuous mode */
13462 struct cmd_vf_allmulti_result {
13463 cmdline_fixed_string_t set;
13464 cmdline_fixed_string_t vf;
13465 cmdline_fixed_string_t allmulti;
13468 cmdline_fixed_string_t on_off;
13471 /* Common CLI fields for VF multicast promiscuous mode enable disable */
13472 cmdline_parse_token_string_t cmd_vf_allmulti_set =
13473 TOKEN_STRING_INITIALIZER
13474 (struct cmd_vf_allmulti_result,
13476 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
13477 TOKEN_STRING_INITIALIZER
13478 (struct cmd_vf_allmulti_result,
13480 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
13481 TOKEN_STRING_INITIALIZER
13482 (struct cmd_vf_allmulti_result,
13483 allmulti, "allmulti");
13484 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
13485 TOKEN_NUM_INITIALIZER
13486 (struct cmd_vf_allmulti_result,
13488 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
13489 TOKEN_NUM_INITIALIZER
13490 (struct cmd_vf_allmulti_result,
13492 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
13493 TOKEN_STRING_INITIALIZER
13494 (struct cmd_vf_allmulti_result,
13498 cmd_set_vf_allmulti_parsed(
13499 void *parsed_result,
13500 __rte_unused struct cmdline *cl,
13501 __rte_unused void *data)
13503 struct cmd_vf_allmulti_result *res = parsed_result;
13504 int ret = -ENOTSUP;
13506 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13508 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13511 #ifdef RTE_NET_I40E
13512 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
13513 res->vf_id, is_on);
13520 printf("invalid vf_id %d\n", res->vf_id);
13523 printf("invalid port_id %d\n", res->port_id);
13526 printf("function not implemented\n");
13529 printf("programming error: (%s)\n", strerror(-ret));
13533 cmdline_parse_inst_t cmd_set_vf_allmulti = {
13534 .f = cmd_set_vf_allmulti_parsed,
13536 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
13537 "Set multicast promiscuous mode for a VF from the PF",
13539 (void *)&cmd_vf_allmulti_set,
13540 (void *)&cmd_vf_allmulti_vf,
13541 (void *)&cmd_vf_allmulti_allmulti,
13542 (void *)&cmd_vf_allmulti_port_id,
13543 (void *)&cmd_vf_allmulti_vf_id,
13544 (void *)&cmd_vf_allmulti_on_off,
13549 /* vf broadcast mode configuration */
13551 /* Common result structure for vf broadcast */
13552 struct cmd_set_vf_broadcast_result {
13553 cmdline_fixed_string_t set;
13554 cmdline_fixed_string_t vf;
13555 cmdline_fixed_string_t broadcast;
13558 cmdline_fixed_string_t on_off;
13561 /* Common CLI fields for vf broadcast enable disable */
13562 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
13563 TOKEN_STRING_INITIALIZER
13564 (struct cmd_set_vf_broadcast_result,
13566 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
13567 TOKEN_STRING_INITIALIZER
13568 (struct cmd_set_vf_broadcast_result,
13570 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
13571 TOKEN_STRING_INITIALIZER
13572 (struct cmd_set_vf_broadcast_result,
13573 broadcast, "broadcast");
13574 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
13575 TOKEN_NUM_INITIALIZER
13576 (struct cmd_set_vf_broadcast_result,
13578 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
13579 TOKEN_NUM_INITIALIZER
13580 (struct cmd_set_vf_broadcast_result,
13582 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
13583 TOKEN_STRING_INITIALIZER
13584 (struct cmd_set_vf_broadcast_result,
13588 cmd_set_vf_broadcast_parsed(
13589 void *parsed_result,
13590 __rte_unused struct cmdline *cl,
13591 __rte_unused void *data)
13593 struct cmd_set_vf_broadcast_result *res = parsed_result;
13594 int ret = -ENOTSUP;
13596 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13598 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13601 #ifdef RTE_NET_I40E
13602 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
13603 res->vf_id, is_on);
13610 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13613 printf("invalid port_id %d\n", res->port_id);
13616 printf("function not implemented\n");
13619 printf("programming error: (%s)\n", strerror(-ret));
13623 cmdline_parse_inst_t cmd_set_vf_broadcast = {
13624 .f = cmd_set_vf_broadcast_parsed,
13626 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
13628 (void *)&cmd_set_vf_broadcast_set,
13629 (void *)&cmd_set_vf_broadcast_vf,
13630 (void *)&cmd_set_vf_broadcast_broadcast,
13631 (void *)&cmd_set_vf_broadcast_port_id,
13632 (void *)&cmd_set_vf_broadcast_vf_id,
13633 (void *)&cmd_set_vf_broadcast_on_off,
13638 /* vf vlan tag configuration */
13640 /* Common result structure for vf vlan tag */
13641 struct cmd_set_vf_vlan_tag_result {
13642 cmdline_fixed_string_t set;
13643 cmdline_fixed_string_t vf;
13644 cmdline_fixed_string_t vlan;
13645 cmdline_fixed_string_t tag;
13648 cmdline_fixed_string_t on_off;
13651 /* Common CLI fields for vf vlan tag enable disable */
13652 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
13653 TOKEN_STRING_INITIALIZER
13654 (struct cmd_set_vf_vlan_tag_result,
13656 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
13657 TOKEN_STRING_INITIALIZER
13658 (struct cmd_set_vf_vlan_tag_result,
13660 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
13661 TOKEN_STRING_INITIALIZER
13662 (struct cmd_set_vf_vlan_tag_result,
13664 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
13665 TOKEN_STRING_INITIALIZER
13666 (struct cmd_set_vf_vlan_tag_result,
13668 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
13669 TOKEN_NUM_INITIALIZER
13670 (struct cmd_set_vf_vlan_tag_result,
13672 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
13673 TOKEN_NUM_INITIALIZER
13674 (struct cmd_set_vf_vlan_tag_result,
13676 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
13677 TOKEN_STRING_INITIALIZER
13678 (struct cmd_set_vf_vlan_tag_result,
13682 cmd_set_vf_vlan_tag_parsed(
13683 void *parsed_result,
13684 __rte_unused struct cmdline *cl,
13685 __rte_unused void *data)
13687 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
13688 int ret = -ENOTSUP;
13690 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13692 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13695 #ifdef RTE_NET_I40E
13696 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
13697 res->vf_id, is_on);
13704 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13707 printf("invalid port_id %d\n", res->port_id);
13710 printf("function not implemented\n");
13713 printf("programming error: (%s)\n", strerror(-ret));
13717 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
13718 .f = cmd_set_vf_vlan_tag_parsed,
13720 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
13722 (void *)&cmd_set_vf_vlan_tag_set,
13723 (void *)&cmd_set_vf_vlan_tag_vf,
13724 (void *)&cmd_set_vf_vlan_tag_vlan,
13725 (void *)&cmd_set_vf_vlan_tag_tag,
13726 (void *)&cmd_set_vf_vlan_tag_port_id,
13727 (void *)&cmd_set_vf_vlan_tag_vf_id,
13728 (void *)&cmd_set_vf_vlan_tag_on_off,
13733 /* Common definition of VF and TC TX bandwidth configuration */
13734 struct cmd_vf_tc_bw_result {
13735 cmdline_fixed_string_t set;
13736 cmdline_fixed_string_t vf;
13737 cmdline_fixed_string_t tc;
13738 cmdline_fixed_string_t tx;
13739 cmdline_fixed_string_t min_bw;
13740 cmdline_fixed_string_t max_bw;
13741 cmdline_fixed_string_t strict_link_prio;
13746 cmdline_fixed_string_t bw_list;
13750 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
13751 TOKEN_STRING_INITIALIZER
13752 (struct cmd_vf_tc_bw_result,
13754 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
13755 TOKEN_STRING_INITIALIZER
13756 (struct cmd_vf_tc_bw_result,
13758 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
13759 TOKEN_STRING_INITIALIZER
13760 (struct cmd_vf_tc_bw_result,
13762 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
13763 TOKEN_STRING_INITIALIZER
13764 (struct cmd_vf_tc_bw_result,
13766 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
13767 TOKEN_STRING_INITIALIZER
13768 (struct cmd_vf_tc_bw_result,
13769 strict_link_prio, "strict-link-priority");
13770 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
13771 TOKEN_STRING_INITIALIZER
13772 (struct cmd_vf_tc_bw_result,
13773 min_bw, "min-bandwidth");
13774 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
13775 TOKEN_STRING_INITIALIZER
13776 (struct cmd_vf_tc_bw_result,
13777 max_bw, "max-bandwidth");
13778 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
13779 TOKEN_NUM_INITIALIZER
13780 (struct cmd_vf_tc_bw_result,
13782 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
13783 TOKEN_NUM_INITIALIZER
13784 (struct cmd_vf_tc_bw_result,
13786 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
13787 TOKEN_NUM_INITIALIZER
13788 (struct cmd_vf_tc_bw_result,
13790 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
13791 TOKEN_NUM_INITIALIZER
13792 (struct cmd_vf_tc_bw_result,
13794 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
13795 TOKEN_STRING_INITIALIZER
13796 (struct cmd_vf_tc_bw_result,
13798 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
13799 TOKEN_NUM_INITIALIZER
13800 (struct cmd_vf_tc_bw_result,
13803 /* VF max bandwidth setting */
13805 cmd_vf_max_bw_parsed(
13806 void *parsed_result,
13807 __rte_unused struct cmdline *cl,
13808 __rte_unused void *data)
13810 struct cmd_vf_tc_bw_result *res = parsed_result;
13811 int ret = -ENOTSUP;
13813 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13816 #ifdef RTE_NET_I40E
13817 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
13818 res->vf_id, res->bw);
13825 printf("invalid vf_id %d or bandwidth %d\n",
13826 res->vf_id, res->bw);
13829 printf("invalid port_id %d\n", res->port_id);
13832 printf("function not implemented\n");
13835 printf("programming error: (%s)\n", strerror(-ret));
13839 cmdline_parse_inst_t cmd_vf_max_bw = {
13840 .f = cmd_vf_max_bw_parsed,
13842 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
13844 (void *)&cmd_vf_tc_bw_set,
13845 (void *)&cmd_vf_tc_bw_vf,
13846 (void *)&cmd_vf_tc_bw_tx,
13847 (void *)&cmd_vf_tc_bw_max_bw,
13848 (void *)&cmd_vf_tc_bw_port_id,
13849 (void *)&cmd_vf_tc_bw_vf_id,
13850 (void *)&cmd_vf_tc_bw_bw,
13856 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
13861 const char *p, *p0 = str;
13868 p = strchr(p0, '(');
13870 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
13874 p0 = strchr(p, ')');
13876 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
13880 if (size >= sizeof(s)) {
13881 printf("The string size exceeds the internal buffer size\n");
13884 snprintf(s, sizeof(s), "%.*s", size, p);
13885 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
13887 printf("Failed to get the bandwidth list. ");
13891 for (i = 0; i < ret; i++)
13892 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
13897 /* TC min bandwidth setting */
13899 cmd_vf_tc_min_bw_parsed(
13900 void *parsed_result,
13901 __rte_unused struct cmdline *cl,
13902 __rte_unused void *data)
13904 struct cmd_vf_tc_bw_result *res = parsed_result;
13907 int ret = -ENOTSUP;
13909 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13912 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
13916 #ifdef RTE_NET_I40E
13917 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
13925 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
13928 printf("invalid port_id %d\n", res->port_id);
13931 printf("function not implemented\n");
13934 printf("programming error: (%s)\n", strerror(-ret));
13938 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
13939 .f = cmd_vf_tc_min_bw_parsed,
13941 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
13942 " <bw1, bw2, ...>",
13944 (void *)&cmd_vf_tc_bw_set,
13945 (void *)&cmd_vf_tc_bw_vf,
13946 (void *)&cmd_vf_tc_bw_tc,
13947 (void *)&cmd_vf_tc_bw_tx,
13948 (void *)&cmd_vf_tc_bw_min_bw,
13949 (void *)&cmd_vf_tc_bw_port_id,
13950 (void *)&cmd_vf_tc_bw_vf_id,
13951 (void *)&cmd_vf_tc_bw_bw_list,
13957 cmd_tc_min_bw_parsed(
13958 void *parsed_result,
13959 __rte_unused struct cmdline *cl,
13960 __rte_unused void *data)
13962 struct cmd_vf_tc_bw_result *res = parsed_result;
13963 struct rte_port *port;
13966 int ret = -ENOTSUP;
13968 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13971 port = &ports[res->port_id];
13972 /** Check if the port is not started **/
13973 if (port->port_status != RTE_PORT_STOPPED) {
13974 printf("Please stop port %d first\n", res->port_id);
13978 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
13982 #ifdef RTE_NET_IXGBE
13983 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
13990 printf("invalid bandwidth\n");
13993 printf("invalid port_id %d\n", res->port_id);
13996 printf("function not implemented\n");
13999 printf("programming error: (%s)\n", strerror(-ret));
14003 cmdline_parse_inst_t cmd_tc_min_bw = {
14004 .f = cmd_tc_min_bw_parsed,
14006 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
14008 (void *)&cmd_vf_tc_bw_set,
14009 (void *)&cmd_vf_tc_bw_tc,
14010 (void *)&cmd_vf_tc_bw_tx,
14011 (void *)&cmd_vf_tc_bw_min_bw,
14012 (void *)&cmd_vf_tc_bw_port_id,
14013 (void *)&cmd_vf_tc_bw_bw_list,
14018 /* TC max bandwidth setting */
14020 cmd_vf_tc_max_bw_parsed(
14021 void *parsed_result,
14022 __rte_unused struct cmdline *cl,
14023 __rte_unused void *data)
14025 struct cmd_vf_tc_bw_result *res = parsed_result;
14026 int ret = -ENOTSUP;
14028 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14031 #ifdef RTE_NET_I40E
14032 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
14033 res->tc_no, res->bw);
14040 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
14041 res->vf_id, res->tc_no, res->bw);
14044 printf("invalid port_id %d\n", res->port_id);
14047 printf("function not implemented\n");
14050 printf("programming error: (%s)\n", strerror(-ret));
14054 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
14055 .f = cmd_vf_tc_max_bw_parsed,
14057 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
14060 (void *)&cmd_vf_tc_bw_set,
14061 (void *)&cmd_vf_tc_bw_vf,
14062 (void *)&cmd_vf_tc_bw_tc,
14063 (void *)&cmd_vf_tc_bw_tx,
14064 (void *)&cmd_vf_tc_bw_max_bw,
14065 (void *)&cmd_vf_tc_bw_port_id,
14066 (void *)&cmd_vf_tc_bw_vf_id,
14067 (void *)&cmd_vf_tc_bw_tc_no,
14068 (void *)&cmd_vf_tc_bw_bw,
14073 /** Set VXLAN encapsulation details */
14074 struct cmd_set_vxlan_result {
14075 cmdline_fixed_string_t set;
14076 cmdline_fixed_string_t vxlan;
14077 cmdline_fixed_string_t pos_token;
14078 cmdline_fixed_string_t ip_version;
14079 uint32_t vlan_present:1;
14083 cmdline_ipaddr_t ip_src;
14084 cmdline_ipaddr_t ip_dst;
14088 struct rte_ether_addr eth_src;
14089 struct rte_ether_addr eth_dst;
14092 cmdline_parse_token_string_t cmd_set_vxlan_set =
14093 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
14094 cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
14095 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
14096 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
14097 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
14099 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
14100 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
14101 "vxlan-with-vlan");
14102 cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
14103 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
14105 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
14106 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
14108 cmdline_parse_token_string_t cmd_set_vxlan_vni =
14109 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
14111 cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
14112 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, UINT32);
14113 cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
14114 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
14116 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
14117 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, UINT16);
14118 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
14119 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
14121 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
14122 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, UINT16);
14123 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
14124 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
14126 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
14127 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, UINT8);
14128 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
14129 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
14131 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
14132 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, UINT8);
14133 cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
14134 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
14136 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
14137 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
14138 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
14139 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
14141 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
14142 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
14143 cmdline_parse_token_string_t cmd_set_vxlan_vlan =
14144 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
14146 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
14147 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, UINT16);
14148 cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
14149 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
14151 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
14152 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
14153 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
14154 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
14156 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
14157 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
14159 static void cmd_set_vxlan_parsed(void *parsed_result,
14160 __rte_unused struct cmdline *cl,
14161 __rte_unused void *data)
14163 struct cmd_set_vxlan_result *res = parsed_result;
14168 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
14171 vxlan_encap_conf.select_tos_ttl = 0;
14172 if (strcmp(res->vxlan, "vxlan") == 0)
14173 vxlan_encap_conf.select_vlan = 0;
14174 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
14175 vxlan_encap_conf.select_vlan = 1;
14176 else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
14177 vxlan_encap_conf.select_vlan = 0;
14178 vxlan_encap_conf.select_tos_ttl = 1;
14180 if (strcmp(res->ip_version, "ipv4") == 0)
14181 vxlan_encap_conf.select_ipv4 = 1;
14182 else if (strcmp(res->ip_version, "ipv6") == 0)
14183 vxlan_encap_conf.select_ipv4 = 0;
14186 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
14187 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
14188 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
14189 vxlan_encap_conf.ip_tos = res->tos;
14190 vxlan_encap_conf.ip_ttl = res->ttl;
14191 if (vxlan_encap_conf.select_ipv4) {
14192 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
14193 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
14195 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
14196 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
14198 if (vxlan_encap_conf.select_vlan)
14199 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
14200 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
14201 RTE_ETHER_ADDR_LEN);
14202 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
14203 RTE_ETHER_ADDR_LEN);
14206 cmdline_parse_inst_t cmd_set_vxlan = {
14207 .f = cmd_set_vxlan_parsed,
14209 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
14210 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
14211 " eth-src <eth-src> eth-dst <eth-dst>",
14213 (void *)&cmd_set_vxlan_set,
14214 (void *)&cmd_set_vxlan_vxlan,
14215 (void *)&cmd_set_vxlan_ip_version,
14216 (void *)&cmd_set_vxlan_ip_version_value,
14217 (void *)&cmd_set_vxlan_vni,
14218 (void *)&cmd_set_vxlan_vni_value,
14219 (void *)&cmd_set_vxlan_udp_src,
14220 (void *)&cmd_set_vxlan_udp_src_value,
14221 (void *)&cmd_set_vxlan_udp_dst,
14222 (void *)&cmd_set_vxlan_udp_dst_value,
14223 (void *)&cmd_set_vxlan_ip_src,
14224 (void *)&cmd_set_vxlan_ip_src_value,
14225 (void *)&cmd_set_vxlan_ip_dst,
14226 (void *)&cmd_set_vxlan_ip_dst_value,
14227 (void *)&cmd_set_vxlan_eth_src,
14228 (void *)&cmd_set_vxlan_eth_src_value,
14229 (void *)&cmd_set_vxlan_eth_dst,
14230 (void *)&cmd_set_vxlan_eth_dst_value,
14235 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
14236 .f = cmd_set_vxlan_parsed,
14238 .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
14239 " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
14240 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
14241 " eth-dst <eth-dst>",
14243 (void *)&cmd_set_vxlan_set,
14244 (void *)&cmd_set_vxlan_vxlan_tos_ttl,
14245 (void *)&cmd_set_vxlan_ip_version,
14246 (void *)&cmd_set_vxlan_ip_version_value,
14247 (void *)&cmd_set_vxlan_vni,
14248 (void *)&cmd_set_vxlan_vni_value,
14249 (void *)&cmd_set_vxlan_udp_src,
14250 (void *)&cmd_set_vxlan_udp_src_value,
14251 (void *)&cmd_set_vxlan_udp_dst,
14252 (void *)&cmd_set_vxlan_udp_dst_value,
14253 (void *)&cmd_set_vxlan_ip_tos,
14254 (void *)&cmd_set_vxlan_ip_tos_value,
14255 (void *)&cmd_set_vxlan_ip_ttl,
14256 (void *)&cmd_set_vxlan_ip_ttl_value,
14257 (void *)&cmd_set_vxlan_ip_src,
14258 (void *)&cmd_set_vxlan_ip_src_value,
14259 (void *)&cmd_set_vxlan_ip_dst,
14260 (void *)&cmd_set_vxlan_ip_dst_value,
14261 (void *)&cmd_set_vxlan_eth_src,
14262 (void *)&cmd_set_vxlan_eth_src_value,
14263 (void *)&cmd_set_vxlan_eth_dst,
14264 (void *)&cmd_set_vxlan_eth_dst_value,
14269 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
14270 .f = cmd_set_vxlan_parsed,
14272 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
14273 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
14274 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
14277 (void *)&cmd_set_vxlan_set,
14278 (void *)&cmd_set_vxlan_vxlan_with_vlan,
14279 (void *)&cmd_set_vxlan_ip_version,
14280 (void *)&cmd_set_vxlan_ip_version_value,
14281 (void *)&cmd_set_vxlan_vni,
14282 (void *)&cmd_set_vxlan_vni_value,
14283 (void *)&cmd_set_vxlan_udp_src,
14284 (void *)&cmd_set_vxlan_udp_src_value,
14285 (void *)&cmd_set_vxlan_udp_dst,
14286 (void *)&cmd_set_vxlan_udp_dst_value,
14287 (void *)&cmd_set_vxlan_ip_src,
14288 (void *)&cmd_set_vxlan_ip_src_value,
14289 (void *)&cmd_set_vxlan_ip_dst,
14290 (void *)&cmd_set_vxlan_ip_dst_value,
14291 (void *)&cmd_set_vxlan_vlan,
14292 (void *)&cmd_set_vxlan_vlan_value,
14293 (void *)&cmd_set_vxlan_eth_src,
14294 (void *)&cmd_set_vxlan_eth_src_value,
14295 (void *)&cmd_set_vxlan_eth_dst,
14296 (void *)&cmd_set_vxlan_eth_dst_value,
14301 /** Set NVGRE encapsulation details */
14302 struct cmd_set_nvgre_result {
14303 cmdline_fixed_string_t set;
14304 cmdline_fixed_string_t nvgre;
14305 cmdline_fixed_string_t pos_token;
14306 cmdline_fixed_string_t ip_version;
14308 cmdline_ipaddr_t ip_src;
14309 cmdline_ipaddr_t ip_dst;
14311 struct rte_ether_addr eth_src;
14312 struct rte_ether_addr eth_dst;
14315 cmdline_parse_token_string_t cmd_set_nvgre_set =
14316 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
14317 cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
14318 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
14319 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
14320 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
14321 "nvgre-with-vlan");
14322 cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
14323 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
14325 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
14326 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
14328 cmdline_parse_token_string_t cmd_set_nvgre_tni =
14329 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
14331 cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
14332 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, UINT32);
14333 cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
14334 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
14336 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
14337 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
14338 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
14339 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
14341 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
14342 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
14343 cmdline_parse_token_string_t cmd_set_nvgre_vlan =
14344 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
14346 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
14347 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, UINT16);
14348 cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
14349 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
14351 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
14352 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
14353 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
14354 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
14356 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
14357 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
14359 static void cmd_set_nvgre_parsed(void *parsed_result,
14360 __rte_unused struct cmdline *cl,
14361 __rte_unused void *data)
14363 struct cmd_set_nvgre_result *res = parsed_result;
14365 uint32_t nvgre_tni;
14368 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
14371 if (strcmp(res->nvgre, "nvgre") == 0)
14372 nvgre_encap_conf.select_vlan = 0;
14373 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
14374 nvgre_encap_conf.select_vlan = 1;
14375 if (strcmp(res->ip_version, "ipv4") == 0)
14376 nvgre_encap_conf.select_ipv4 = 1;
14377 else if (strcmp(res->ip_version, "ipv6") == 0)
14378 nvgre_encap_conf.select_ipv4 = 0;
14381 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
14382 if (nvgre_encap_conf.select_ipv4) {
14383 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
14384 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
14386 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
14387 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
14389 if (nvgre_encap_conf.select_vlan)
14390 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
14391 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
14392 RTE_ETHER_ADDR_LEN);
14393 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
14394 RTE_ETHER_ADDR_LEN);
14397 cmdline_parse_inst_t cmd_set_nvgre = {
14398 .f = cmd_set_nvgre_parsed,
14400 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
14401 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
14402 " eth-dst <eth-dst>",
14404 (void *)&cmd_set_nvgre_set,
14405 (void *)&cmd_set_nvgre_nvgre,
14406 (void *)&cmd_set_nvgre_ip_version,
14407 (void *)&cmd_set_nvgre_ip_version_value,
14408 (void *)&cmd_set_nvgre_tni,
14409 (void *)&cmd_set_nvgre_tni_value,
14410 (void *)&cmd_set_nvgre_ip_src,
14411 (void *)&cmd_set_nvgre_ip_src_value,
14412 (void *)&cmd_set_nvgre_ip_dst,
14413 (void *)&cmd_set_nvgre_ip_dst_value,
14414 (void *)&cmd_set_nvgre_eth_src,
14415 (void *)&cmd_set_nvgre_eth_src_value,
14416 (void *)&cmd_set_nvgre_eth_dst,
14417 (void *)&cmd_set_nvgre_eth_dst_value,
14422 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
14423 .f = cmd_set_nvgre_parsed,
14425 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
14426 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
14427 " eth-src <eth-src> eth-dst <eth-dst>",
14429 (void *)&cmd_set_nvgre_set,
14430 (void *)&cmd_set_nvgre_nvgre_with_vlan,
14431 (void *)&cmd_set_nvgre_ip_version,
14432 (void *)&cmd_set_nvgre_ip_version_value,
14433 (void *)&cmd_set_nvgre_tni,
14434 (void *)&cmd_set_nvgre_tni_value,
14435 (void *)&cmd_set_nvgre_ip_src,
14436 (void *)&cmd_set_nvgre_ip_src_value,
14437 (void *)&cmd_set_nvgre_ip_dst,
14438 (void *)&cmd_set_nvgre_ip_dst_value,
14439 (void *)&cmd_set_nvgre_vlan,
14440 (void *)&cmd_set_nvgre_vlan_value,
14441 (void *)&cmd_set_nvgre_eth_src,
14442 (void *)&cmd_set_nvgre_eth_src_value,
14443 (void *)&cmd_set_nvgre_eth_dst,
14444 (void *)&cmd_set_nvgre_eth_dst_value,
14449 /** Set L2 encapsulation details */
14450 struct cmd_set_l2_encap_result {
14451 cmdline_fixed_string_t set;
14452 cmdline_fixed_string_t l2_encap;
14453 cmdline_fixed_string_t pos_token;
14454 cmdline_fixed_string_t ip_version;
14455 uint32_t vlan_present:1;
14457 struct rte_ether_addr eth_src;
14458 struct rte_ether_addr eth_dst;
14461 cmdline_parse_token_string_t cmd_set_l2_encap_set =
14462 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
14463 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
14464 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
14465 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
14466 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
14467 "l2_encap-with-vlan");
14468 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
14469 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
14471 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
14472 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
14474 cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
14475 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
14477 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
14478 TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, UINT16);
14479 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
14480 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
14482 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
14483 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
14484 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
14485 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
14487 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
14488 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
14490 static void cmd_set_l2_encap_parsed(void *parsed_result,
14491 __rte_unused struct cmdline *cl,
14492 __rte_unused void *data)
14494 struct cmd_set_l2_encap_result *res = parsed_result;
14496 if (strcmp(res->l2_encap, "l2_encap") == 0)
14497 l2_encap_conf.select_vlan = 0;
14498 else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
14499 l2_encap_conf.select_vlan = 1;
14500 if (strcmp(res->ip_version, "ipv4") == 0)
14501 l2_encap_conf.select_ipv4 = 1;
14502 else if (strcmp(res->ip_version, "ipv6") == 0)
14503 l2_encap_conf.select_ipv4 = 0;
14506 if (l2_encap_conf.select_vlan)
14507 l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
14508 rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
14509 RTE_ETHER_ADDR_LEN);
14510 rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
14511 RTE_ETHER_ADDR_LEN);
14514 cmdline_parse_inst_t cmd_set_l2_encap = {
14515 .f = cmd_set_l2_encap_parsed,
14517 .help_str = "set l2_encap ip-version ipv4|ipv6"
14518 " eth-src <eth-src> eth-dst <eth-dst>",
14520 (void *)&cmd_set_l2_encap_set,
14521 (void *)&cmd_set_l2_encap_l2_encap,
14522 (void *)&cmd_set_l2_encap_ip_version,
14523 (void *)&cmd_set_l2_encap_ip_version_value,
14524 (void *)&cmd_set_l2_encap_eth_src,
14525 (void *)&cmd_set_l2_encap_eth_src_value,
14526 (void *)&cmd_set_l2_encap_eth_dst,
14527 (void *)&cmd_set_l2_encap_eth_dst_value,
14532 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
14533 .f = cmd_set_l2_encap_parsed,
14535 .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
14536 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
14538 (void *)&cmd_set_l2_encap_set,
14539 (void *)&cmd_set_l2_encap_l2_encap_with_vlan,
14540 (void *)&cmd_set_l2_encap_ip_version,
14541 (void *)&cmd_set_l2_encap_ip_version_value,
14542 (void *)&cmd_set_l2_encap_vlan,
14543 (void *)&cmd_set_l2_encap_vlan_value,
14544 (void *)&cmd_set_l2_encap_eth_src,
14545 (void *)&cmd_set_l2_encap_eth_src_value,
14546 (void *)&cmd_set_l2_encap_eth_dst,
14547 (void *)&cmd_set_l2_encap_eth_dst_value,
14552 /** Set L2 decapsulation details */
14553 struct cmd_set_l2_decap_result {
14554 cmdline_fixed_string_t set;
14555 cmdline_fixed_string_t l2_decap;
14556 cmdline_fixed_string_t pos_token;
14557 uint32_t vlan_present:1;
14560 cmdline_parse_token_string_t cmd_set_l2_decap_set =
14561 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
14562 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
14563 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
14565 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
14566 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
14567 "l2_decap-with-vlan");
14569 static void cmd_set_l2_decap_parsed(void *parsed_result,
14570 __rte_unused struct cmdline *cl,
14571 __rte_unused void *data)
14573 struct cmd_set_l2_decap_result *res = parsed_result;
14575 if (strcmp(res->l2_decap, "l2_decap") == 0)
14576 l2_decap_conf.select_vlan = 0;
14577 else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
14578 l2_decap_conf.select_vlan = 1;
14581 cmdline_parse_inst_t cmd_set_l2_decap = {
14582 .f = cmd_set_l2_decap_parsed,
14584 .help_str = "set l2_decap",
14586 (void *)&cmd_set_l2_decap_set,
14587 (void *)&cmd_set_l2_decap_l2_decap,
14592 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
14593 .f = cmd_set_l2_decap_parsed,
14595 .help_str = "set l2_decap-with-vlan",
14597 (void *)&cmd_set_l2_decap_set,
14598 (void *)&cmd_set_l2_decap_l2_decap_with_vlan,
14603 /** Set MPLSoGRE encapsulation details */
14604 struct cmd_set_mplsogre_encap_result {
14605 cmdline_fixed_string_t set;
14606 cmdline_fixed_string_t mplsogre;
14607 cmdline_fixed_string_t pos_token;
14608 cmdline_fixed_string_t ip_version;
14609 uint32_t vlan_present:1;
14611 cmdline_ipaddr_t ip_src;
14612 cmdline_ipaddr_t ip_dst;
14614 struct rte_ether_addr eth_src;
14615 struct rte_ether_addr eth_dst;
14618 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
14619 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
14621 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
14622 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
14624 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
14625 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
14626 mplsogre, "mplsogre_encap-with-vlan");
14627 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
14628 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
14629 pos_token, "ip-version");
14630 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
14631 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
14632 ip_version, "ipv4#ipv6");
14633 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
14634 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
14635 pos_token, "label");
14636 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
14637 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
14639 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
14640 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
14641 pos_token, "ip-src");
14642 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
14643 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
14644 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
14645 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
14646 pos_token, "ip-dst");
14647 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
14648 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
14649 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
14650 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
14651 pos_token, "vlan-tci");
14652 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
14653 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
14655 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
14656 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
14657 pos_token, "eth-src");
14658 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
14659 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
14661 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
14662 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
14663 pos_token, "eth-dst");
14664 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
14665 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
14668 static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
14669 __rte_unused struct cmdline *cl,
14670 __rte_unused void *data)
14672 struct cmd_set_mplsogre_encap_result *res = parsed_result;
14674 uint32_t mplsogre_label;
14677 .mplsogre_label = rte_cpu_to_be_32(res->label<<12),
14680 if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
14681 mplsogre_encap_conf.select_vlan = 0;
14682 else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
14683 mplsogre_encap_conf.select_vlan = 1;
14684 if (strcmp(res->ip_version, "ipv4") == 0)
14685 mplsogre_encap_conf.select_ipv4 = 1;
14686 else if (strcmp(res->ip_version, "ipv6") == 0)
14687 mplsogre_encap_conf.select_ipv4 = 0;
14690 rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
14691 if (mplsogre_encap_conf.select_ipv4) {
14692 IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
14693 IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
14695 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
14696 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
14698 if (mplsogre_encap_conf.select_vlan)
14699 mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
14700 rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
14701 RTE_ETHER_ADDR_LEN);
14702 rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
14703 RTE_ETHER_ADDR_LEN);
14706 cmdline_parse_inst_t cmd_set_mplsogre_encap = {
14707 .f = cmd_set_mplsogre_encap_parsed,
14709 .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
14710 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
14711 " eth-dst <eth-dst>",
14713 (void *)&cmd_set_mplsogre_encap_set,
14714 (void *)&cmd_set_mplsogre_encap_mplsogre_encap,
14715 (void *)&cmd_set_mplsogre_encap_ip_version,
14716 (void *)&cmd_set_mplsogre_encap_ip_version_value,
14717 (void *)&cmd_set_mplsogre_encap_label,
14718 (void *)&cmd_set_mplsogre_encap_label_value,
14719 (void *)&cmd_set_mplsogre_encap_ip_src,
14720 (void *)&cmd_set_mplsogre_encap_ip_src_value,
14721 (void *)&cmd_set_mplsogre_encap_ip_dst,
14722 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
14723 (void *)&cmd_set_mplsogre_encap_eth_src,
14724 (void *)&cmd_set_mplsogre_encap_eth_src_value,
14725 (void *)&cmd_set_mplsogre_encap_eth_dst,
14726 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
14731 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
14732 .f = cmd_set_mplsogre_encap_parsed,
14734 .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
14735 " label <label> ip-src <ip-src> ip-dst <ip-dst>"
14736 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
14738 (void *)&cmd_set_mplsogre_encap_set,
14739 (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
14740 (void *)&cmd_set_mplsogre_encap_ip_version,
14741 (void *)&cmd_set_mplsogre_encap_ip_version_value,
14742 (void *)&cmd_set_mplsogre_encap_label,
14743 (void *)&cmd_set_mplsogre_encap_label_value,
14744 (void *)&cmd_set_mplsogre_encap_ip_src,
14745 (void *)&cmd_set_mplsogre_encap_ip_src_value,
14746 (void *)&cmd_set_mplsogre_encap_ip_dst,
14747 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
14748 (void *)&cmd_set_mplsogre_encap_vlan,
14749 (void *)&cmd_set_mplsogre_encap_vlan_value,
14750 (void *)&cmd_set_mplsogre_encap_eth_src,
14751 (void *)&cmd_set_mplsogre_encap_eth_src_value,
14752 (void *)&cmd_set_mplsogre_encap_eth_dst,
14753 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
14758 /** Set MPLSoGRE decapsulation details */
14759 struct cmd_set_mplsogre_decap_result {
14760 cmdline_fixed_string_t set;
14761 cmdline_fixed_string_t mplsogre;
14762 cmdline_fixed_string_t pos_token;
14763 cmdline_fixed_string_t ip_version;
14764 uint32_t vlan_present:1;
14767 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
14768 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
14770 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
14771 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
14773 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
14774 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
14775 mplsogre, "mplsogre_decap-with-vlan");
14776 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
14777 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
14778 pos_token, "ip-version");
14779 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
14780 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
14781 ip_version, "ipv4#ipv6");
14783 static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
14784 __rte_unused struct cmdline *cl,
14785 __rte_unused void *data)
14787 struct cmd_set_mplsogre_decap_result *res = parsed_result;
14789 if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
14790 mplsogre_decap_conf.select_vlan = 0;
14791 else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
14792 mplsogre_decap_conf.select_vlan = 1;
14793 if (strcmp(res->ip_version, "ipv4") == 0)
14794 mplsogre_decap_conf.select_ipv4 = 1;
14795 else if (strcmp(res->ip_version, "ipv6") == 0)
14796 mplsogre_decap_conf.select_ipv4 = 0;
14799 cmdline_parse_inst_t cmd_set_mplsogre_decap = {
14800 .f = cmd_set_mplsogre_decap_parsed,
14802 .help_str = "set mplsogre_decap ip-version ipv4|ipv6",
14804 (void *)&cmd_set_mplsogre_decap_set,
14805 (void *)&cmd_set_mplsogre_decap_mplsogre_decap,
14806 (void *)&cmd_set_mplsogre_decap_ip_version,
14807 (void *)&cmd_set_mplsogre_decap_ip_version_value,
14812 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
14813 .f = cmd_set_mplsogre_decap_parsed,
14815 .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
14817 (void *)&cmd_set_mplsogre_decap_set,
14818 (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
14819 (void *)&cmd_set_mplsogre_decap_ip_version,
14820 (void *)&cmd_set_mplsogre_decap_ip_version_value,
14825 /** Set MPLSoUDP encapsulation details */
14826 struct cmd_set_mplsoudp_encap_result {
14827 cmdline_fixed_string_t set;
14828 cmdline_fixed_string_t mplsoudp;
14829 cmdline_fixed_string_t pos_token;
14830 cmdline_fixed_string_t ip_version;
14831 uint32_t vlan_present:1;
14835 cmdline_ipaddr_t ip_src;
14836 cmdline_ipaddr_t ip_dst;
14838 struct rte_ether_addr eth_src;
14839 struct rte_ether_addr eth_dst;
14842 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
14843 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
14845 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
14846 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
14848 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
14849 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
14850 mplsoudp, "mplsoudp_encap-with-vlan");
14851 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
14852 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
14853 pos_token, "ip-version");
14854 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
14855 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
14856 ip_version, "ipv4#ipv6");
14857 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
14858 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
14859 pos_token, "label");
14860 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
14861 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
14863 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
14864 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
14865 pos_token, "udp-src");
14866 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
14867 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
14869 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
14870 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
14871 pos_token, "udp-dst");
14872 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
14873 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
14875 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
14876 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
14877 pos_token, "ip-src");
14878 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
14879 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
14880 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
14881 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
14882 pos_token, "ip-dst");
14883 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
14884 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
14885 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
14886 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
14887 pos_token, "vlan-tci");
14888 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
14889 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
14891 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
14892 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
14893 pos_token, "eth-src");
14894 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
14895 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
14897 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
14898 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
14899 pos_token, "eth-dst");
14900 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
14901 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
14904 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
14905 __rte_unused struct cmdline *cl,
14906 __rte_unused void *data)
14908 struct cmd_set_mplsoudp_encap_result *res = parsed_result;
14910 uint32_t mplsoudp_label;
14913 .mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
14916 if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
14917 mplsoudp_encap_conf.select_vlan = 0;
14918 else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
14919 mplsoudp_encap_conf.select_vlan = 1;
14920 if (strcmp(res->ip_version, "ipv4") == 0)
14921 mplsoudp_encap_conf.select_ipv4 = 1;
14922 else if (strcmp(res->ip_version, "ipv6") == 0)
14923 mplsoudp_encap_conf.select_ipv4 = 0;
14926 rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
14927 mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
14928 mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
14929 if (mplsoudp_encap_conf.select_ipv4) {
14930 IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
14931 IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
14933 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
14934 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
14936 if (mplsoudp_encap_conf.select_vlan)
14937 mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
14938 rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
14939 RTE_ETHER_ADDR_LEN);
14940 rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
14941 RTE_ETHER_ADDR_LEN);
14944 cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
14945 .f = cmd_set_mplsoudp_encap_parsed,
14947 .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
14948 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
14949 " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
14951 (void *)&cmd_set_mplsoudp_encap_set,
14952 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
14953 (void *)&cmd_set_mplsoudp_encap_ip_version,
14954 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
14955 (void *)&cmd_set_mplsoudp_encap_label,
14956 (void *)&cmd_set_mplsoudp_encap_label_value,
14957 (void *)&cmd_set_mplsoudp_encap_udp_src,
14958 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
14959 (void *)&cmd_set_mplsoudp_encap_udp_dst,
14960 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
14961 (void *)&cmd_set_mplsoudp_encap_ip_src,
14962 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
14963 (void *)&cmd_set_mplsoudp_encap_ip_dst,
14964 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
14965 (void *)&cmd_set_mplsoudp_encap_eth_src,
14966 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
14967 (void *)&cmd_set_mplsoudp_encap_eth_dst,
14968 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
14973 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
14974 .f = cmd_set_mplsoudp_encap_parsed,
14976 .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
14977 " label <label> udp-src <udp-src> udp-dst <udp-dst>"
14978 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
14979 " eth-src <eth-src> eth-dst <eth-dst>",
14981 (void *)&cmd_set_mplsoudp_encap_set,
14982 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
14983 (void *)&cmd_set_mplsoudp_encap_ip_version,
14984 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
14985 (void *)&cmd_set_mplsoudp_encap_label,
14986 (void *)&cmd_set_mplsoudp_encap_label_value,
14987 (void *)&cmd_set_mplsoudp_encap_udp_src,
14988 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
14989 (void *)&cmd_set_mplsoudp_encap_udp_dst,
14990 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
14991 (void *)&cmd_set_mplsoudp_encap_ip_src,
14992 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
14993 (void *)&cmd_set_mplsoudp_encap_ip_dst,
14994 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
14995 (void *)&cmd_set_mplsoudp_encap_vlan,
14996 (void *)&cmd_set_mplsoudp_encap_vlan_value,
14997 (void *)&cmd_set_mplsoudp_encap_eth_src,
14998 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
14999 (void *)&cmd_set_mplsoudp_encap_eth_dst,
15000 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
15005 /** Set MPLSoUDP decapsulation details */
15006 struct cmd_set_mplsoudp_decap_result {
15007 cmdline_fixed_string_t set;
15008 cmdline_fixed_string_t mplsoudp;
15009 cmdline_fixed_string_t pos_token;
15010 cmdline_fixed_string_t ip_version;
15011 uint32_t vlan_present:1;
15014 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
15015 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
15017 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
15018 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
15020 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
15021 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
15022 mplsoudp, "mplsoudp_decap-with-vlan");
15023 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
15024 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
15025 pos_token, "ip-version");
15026 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
15027 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
15028 ip_version, "ipv4#ipv6");
15030 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
15031 __rte_unused struct cmdline *cl,
15032 __rte_unused void *data)
15034 struct cmd_set_mplsoudp_decap_result *res = parsed_result;
15036 if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
15037 mplsoudp_decap_conf.select_vlan = 0;
15038 else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
15039 mplsoudp_decap_conf.select_vlan = 1;
15040 if (strcmp(res->ip_version, "ipv4") == 0)
15041 mplsoudp_decap_conf.select_ipv4 = 1;
15042 else if (strcmp(res->ip_version, "ipv6") == 0)
15043 mplsoudp_decap_conf.select_ipv4 = 0;
15046 cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
15047 .f = cmd_set_mplsoudp_decap_parsed,
15049 .help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
15051 (void *)&cmd_set_mplsoudp_decap_set,
15052 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
15053 (void *)&cmd_set_mplsoudp_decap_ip_version,
15054 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
15059 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
15060 .f = cmd_set_mplsoudp_decap_parsed,
15062 .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
15064 (void *)&cmd_set_mplsoudp_decap_set,
15065 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
15066 (void *)&cmd_set_mplsoudp_decap_ip_version,
15067 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
15072 /* Strict link priority scheduling mode setting */
15074 cmd_strict_link_prio_parsed(
15075 void *parsed_result,
15076 __rte_unused struct cmdline *cl,
15077 __rte_unused void *data)
15079 struct cmd_vf_tc_bw_result *res = parsed_result;
15080 int ret = -ENOTSUP;
15082 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15085 #ifdef RTE_NET_I40E
15086 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
15093 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
15096 printf("invalid port_id %d\n", res->port_id);
15099 printf("function not implemented\n");
15102 printf("programming error: (%s)\n", strerror(-ret));
15106 cmdline_parse_inst_t cmd_strict_link_prio = {
15107 .f = cmd_strict_link_prio_parsed,
15109 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
15111 (void *)&cmd_vf_tc_bw_set,
15112 (void *)&cmd_vf_tc_bw_tx,
15113 (void *)&cmd_vf_tc_bw_strict_link_prio,
15114 (void *)&cmd_vf_tc_bw_port_id,
15115 (void *)&cmd_vf_tc_bw_tc_map,
15120 /* Load dynamic device personalization*/
15121 struct cmd_ddp_add_result {
15122 cmdline_fixed_string_t ddp;
15123 cmdline_fixed_string_t add;
15128 cmdline_parse_token_string_t cmd_ddp_add_ddp =
15129 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
15130 cmdline_parse_token_string_t cmd_ddp_add_add =
15131 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
15132 cmdline_parse_token_num_t cmd_ddp_add_port_id =
15133 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
15134 cmdline_parse_token_string_t cmd_ddp_add_filepath =
15135 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
15138 cmd_ddp_add_parsed(
15139 void *parsed_result,
15140 __rte_unused struct cmdline *cl,
15141 __rte_unused void *data)
15143 struct cmd_ddp_add_result *res = parsed_result;
15149 int ret = -ENOTSUP;
15151 if (!all_ports_stopped()) {
15152 printf("Please stop all ports first\n");
15156 filepath = strdup(res->filepath);
15157 if (filepath == NULL) {
15158 printf("Failed to allocate memory\n");
15161 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
15163 buff = open_file(file_fld[0], &size);
15165 free((void *)filepath);
15169 #ifdef RTE_NET_I40E
15170 if (ret == -ENOTSUP)
15171 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
15173 RTE_PMD_I40E_PKG_OP_WR_ADD);
15176 if (ret == -EEXIST)
15177 printf("Profile has already existed.\n");
15179 printf("Failed to load profile.\n");
15180 else if (file_num == 2)
15181 save_file(file_fld[1], buff, size);
15184 free((void *)filepath);
15187 cmdline_parse_inst_t cmd_ddp_add = {
15188 .f = cmd_ddp_add_parsed,
15190 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
15192 (void *)&cmd_ddp_add_ddp,
15193 (void *)&cmd_ddp_add_add,
15194 (void *)&cmd_ddp_add_port_id,
15195 (void *)&cmd_ddp_add_filepath,
15200 /* Delete dynamic device personalization*/
15201 struct cmd_ddp_del_result {
15202 cmdline_fixed_string_t ddp;
15203 cmdline_fixed_string_t del;
15208 cmdline_parse_token_string_t cmd_ddp_del_ddp =
15209 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
15210 cmdline_parse_token_string_t cmd_ddp_del_del =
15211 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
15212 cmdline_parse_token_num_t cmd_ddp_del_port_id =
15213 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
15214 cmdline_parse_token_string_t cmd_ddp_del_filepath =
15215 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
15218 cmd_ddp_del_parsed(
15219 void *parsed_result,
15220 __rte_unused struct cmdline *cl,
15221 __rte_unused void *data)
15223 struct cmd_ddp_del_result *res = parsed_result;
15226 int ret = -ENOTSUP;
15228 if (!all_ports_stopped()) {
15229 printf("Please stop all ports first\n");
15233 buff = open_file(res->filepath, &size);
15237 #ifdef RTE_NET_I40E
15238 if (ret == -ENOTSUP)
15239 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
15241 RTE_PMD_I40E_PKG_OP_WR_DEL);
15244 if (ret == -EACCES)
15245 printf("Profile does not exist.\n");
15247 printf("Failed to delete profile.\n");
15252 cmdline_parse_inst_t cmd_ddp_del = {
15253 .f = cmd_ddp_del_parsed,
15255 .help_str = "ddp del <port_id> <backup_profile_path>",
15257 (void *)&cmd_ddp_del_ddp,
15258 (void *)&cmd_ddp_del_del,
15259 (void *)&cmd_ddp_del_port_id,
15260 (void *)&cmd_ddp_del_filepath,
15265 /* Get dynamic device personalization profile info */
15266 struct cmd_ddp_info_result {
15267 cmdline_fixed_string_t ddp;
15268 cmdline_fixed_string_t get;
15269 cmdline_fixed_string_t info;
15273 cmdline_parse_token_string_t cmd_ddp_info_ddp =
15274 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
15275 cmdline_parse_token_string_t cmd_ddp_info_get =
15276 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
15277 cmdline_parse_token_string_t cmd_ddp_info_info =
15278 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
15279 cmdline_parse_token_string_t cmd_ddp_info_filepath =
15280 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
15283 cmd_ddp_info_parsed(
15284 void *parsed_result,
15285 __rte_unused struct cmdline *cl,
15286 __rte_unused void *data)
15288 struct cmd_ddp_info_result *res = parsed_result;
15291 int ret = -ENOTSUP;
15292 #ifdef RTE_NET_I40E
15295 uint32_t buff_size = 0;
15296 struct rte_pmd_i40e_profile_info info;
15297 uint32_t dev_num = 0;
15298 struct rte_pmd_i40e_ddp_device_id *devs;
15299 uint32_t proto_num = 0;
15300 struct rte_pmd_i40e_proto_info *proto = NULL;
15301 uint32_t pctype_num = 0;
15302 struct rte_pmd_i40e_ptype_info *pctype;
15303 uint32_t ptype_num = 0;
15304 struct rte_pmd_i40e_ptype_info *ptype;
15309 pkg = open_file(res->filepath, &pkg_size);
15313 #ifdef RTE_NET_I40E
15314 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15315 (uint8_t *)&info, sizeof(info),
15316 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
15318 printf("Global Track id: 0x%x\n", info.track_id);
15319 printf("Global Version: %d.%d.%d.%d\n",
15320 info.version.major,
15321 info.version.minor,
15322 info.version.update,
15323 info.version.draft);
15324 printf("Global Package name: %s\n\n", info.name);
15327 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15328 (uint8_t *)&info, sizeof(info),
15329 RTE_PMD_I40E_PKG_INFO_HEADER);
15331 printf("i40e Profile Track id: 0x%x\n", info.track_id);
15332 printf("i40e Profile Version: %d.%d.%d.%d\n",
15333 info.version.major,
15334 info.version.minor,
15335 info.version.update,
15336 info.version.draft);
15337 printf("i40e Profile name: %s\n\n", info.name);
15340 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15341 (uint8_t *)&buff_size, sizeof(buff_size),
15342 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
15343 if (!ret && buff_size) {
15344 buff = (uint8_t *)malloc(buff_size);
15346 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15348 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
15350 printf("Package Notes:\n%s\n\n", buff);
15355 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15356 (uint8_t *)&dev_num, sizeof(dev_num),
15357 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
15358 if (!ret && dev_num) {
15359 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
15360 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
15362 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15363 (uint8_t *)devs, buff_size,
15364 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
15366 printf("List of supported devices:\n");
15367 for (i = 0; i < dev_num; i++) {
15368 printf(" %04X:%04X %04X:%04X\n",
15369 devs[i].vendor_dev_id >> 16,
15370 devs[i].vendor_dev_id & 0xFFFF,
15371 devs[i].sub_vendor_dev_id >> 16,
15372 devs[i].sub_vendor_dev_id & 0xFFFF);
15380 /* get information about protocols and packet types */
15381 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15382 (uint8_t *)&proto_num, sizeof(proto_num),
15383 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
15384 if (ret || !proto_num)
15385 goto no_print_return;
15387 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
15388 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
15390 goto no_print_return;
15392 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
15394 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
15396 printf("List of used protocols:\n");
15397 for (i = 0; i < proto_num; i++)
15398 printf(" %2u: %s\n", proto[i].proto_id,
15402 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15403 (uint8_t *)&pctype_num, sizeof(pctype_num),
15404 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
15405 if (ret || !pctype_num)
15406 goto no_print_pctypes;
15408 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
15409 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
15411 goto no_print_pctypes;
15413 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
15415 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
15418 goto no_print_pctypes;
15421 printf("List of defined packet classification types:\n");
15422 for (i = 0; i < pctype_num; i++) {
15423 printf(" %2u:", pctype[i].ptype_id);
15424 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
15425 proto_id = pctype[i].protocols[j];
15426 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
15427 for (n = 0; n < proto_num; n++) {
15428 if (proto[n].proto_id == proto_id) {
15429 printf(" %s", proto[n].name);
15442 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
15444 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
15445 if (ret || !ptype_num)
15446 goto no_print_return;
15448 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
15449 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
15451 goto no_print_return;
15453 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
15455 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
15458 goto no_print_return;
15460 printf("List of defined packet types:\n");
15461 for (i = 0; i < ptype_num; i++) {
15462 printf(" %2u:", ptype[i].ptype_id);
15463 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
15464 proto_id = ptype[i].protocols[j];
15465 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
15466 for (n = 0; n < proto_num; n++) {
15467 if (proto[n].proto_id == proto_id) {
15468 printf(" %s", proto[n].name);
15484 if (ret == -ENOTSUP)
15485 printf("Function not supported in PMD driver\n");
15489 cmdline_parse_inst_t cmd_ddp_get_info = {
15490 .f = cmd_ddp_info_parsed,
15492 .help_str = "ddp get info <profile_path>",
15494 (void *)&cmd_ddp_info_ddp,
15495 (void *)&cmd_ddp_info_get,
15496 (void *)&cmd_ddp_info_info,
15497 (void *)&cmd_ddp_info_filepath,
15502 /* Get dynamic device personalization profile info list*/
15503 #define PROFILE_INFO_SIZE 48
15504 #define MAX_PROFILE_NUM 16
15506 struct cmd_ddp_get_list_result {
15507 cmdline_fixed_string_t ddp;
15508 cmdline_fixed_string_t get;
15509 cmdline_fixed_string_t list;
15513 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
15514 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
15515 cmdline_parse_token_string_t cmd_ddp_get_list_get =
15516 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
15517 cmdline_parse_token_string_t cmd_ddp_get_list_list =
15518 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
15519 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
15520 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
15523 cmd_ddp_get_list_parsed(
15524 __rte_unused void *parsed_result,
15525 __rte_unused struct cmdline *cl,
15526 __rte_unused void *data)
15528 #ifdef RTE_NET_I40E
15529 struct cmd_ddp_get_list_result *res = parsed_result;
15530 struct rte_pmd_i40e_profile_list *p_list;
15531 struct rte_pmd_i40e_profile_info *p_info;
15536 int ret = -ENOTSUP;
15538 #ifdef RTE_NET_I40E
15539 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
15540 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
15542 printf("%s: Failed to malloc buffer\n", __func__);
15546 if (ret == -ENOTSUP)
15547 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
15548 (uint8_t *)p_list, size);
15551 p_num = p_list->p_count;
15552 printf("Profile number is: %d\n\n", p_num);
15554 for (i = 0; i < p_num; i++) {
15555 p_info = &p_list->p_info[i];
15556 printf("Profile %d:\n", i);
15557 printf("Track id: 0x%x\n", p_info->track_id);
15558 printf("Version: %d.%d.%d.%d\n",
15559 p_info->version.major,
15560 p_info->version.minor,
15561 p_info->version.update,
15562 p_info->version.draft);
15563 printf("Profile name: %s\n\n", p_info->name);
15571 printf("Failed to get ddp list\n");
15574 cmdline_parse_inst_t cmd_ddp_get_list = {
15575 .f = cmd_ddp_get_list_parsed,
15577 .help_str = "ddp get list <port_id>",
15579 (void *)&cmd_ddp_get_list_ddp,
15580 (void *)&cmd_ddp_get_list_get,
15581 (void *)&cmd_ddp_get_list_list,
15582 (void *)&cmd_ddp_get_list_port_id,
15587 /* Configure input set */
15588 struct cmd_cfg_input_set_result {
15589 cmdline_fixed_string_t port;
15590 cmdline_fixed_string_t cfg;
15592 cmdline_fixed_string_t pctype;
15594 cmdline_fixed_string_t inset_type;
15595 cmdline_fixed_string_t opt;
15596 cmdline_fixed_string_t field;
15601 cmd_cfg_input_set_parsed(
15602 __rte_unused void *parsed_result,
15603 __rte_unused struct cmdline *cl,
15604 __rte_unused void *data)
15606 #ifdef RTE_NET_I40E
15607 struct cmd_cfg_input_set_result *res = parsed_result;
15608 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
15609 struct rte_pmd_i40e_inset inset;
15611 int ret = -ENOTSUP;
15613 if (!all_ports_stopped()) {
15614 printf("Please stop all ports first\n");
15618 #ifdef RTE_NET_I40E
15619 if (!strcmp(res->inset_type, "hash_inset"))
15620 inset_type = INSET_HASH;
15621 else if (!strcmp(res->inset_type, "fdir_inset"))
15622 inset_type = INSET_FDIR;
15623 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
15624 inset_type = INSET_FDIR_FLX;
15625 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
15626 &inset, inset_type);
15628 printf("Failed to get input set.\n");
15632 if (!strcmp(res->opt, "get")) {
15633 ret = rte_pmd_i40e_inset_field_get(inset.inset,
15636 printf("Field index %d is enabled.\n", res->field_idx);
15638 printf("Field index %d is disabled.\n", res->field_idx);
15640 } else if (!strcmp(res->opt, "set"))
15641 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
15643 else if (!strcmp(res->opt, "clear"))
15644 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
15647 printf("Failed to configure input set field.\n");
15651 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
15652 &inset, inset_type);
15654 printf("Failed to set input set.\n");
15659 if (ret == -ENOTSUP)
15660 printf("Function not supported\n");
15663 cmdline_parse_token_string_t cmd_cfg_input_set_port =
15664 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15666 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
15667 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15669 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
15670 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15672 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
15673 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15675 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
15676 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15678 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
15679 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15681 "hash_inset#fdir_inset#fdir_flx_inset");
15682 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
15683 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15684 opt, "get#set#clear");
15685 cmdline_parse_token_string_t cmd_cfg_input_set_field =
15686 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15688 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
15689 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15692 cmdline_parse_inst_t cmd_cfg_input_set = {
15693 .f = cmd_cfg_input_set_parsed,
15695 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
15696 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
15698 (void *)&cmd_cfg_input_set_port,
15699 (void *)&cmd_cfg_input_set_cfg,
15700 (void *)&cmd_cfg_input_set_port_id,
15701 (void *)&cmd_cfg_input_set_pctype,
15702 (void *)&cmd_cfg_input_set_pctype_id,
15703 (void *)&cmd_cfg_input_set_inset_type,
15704 (void *)&cmd_cfg_input_set_opt,
15705 (void *)&cmd_cfg_input_set_field,
15706 (void *)&cmd_cfg_input_set_field_idx,
15711 /* Clear input set */
15712 struct cmd_clear_input_set_result {
15713 cmdline_fixed_string_t port;
15714 cmdline_fixed_string_t cfg;
15716 cmdline_fixed_string_t pctype;
15718 cmdline_fixed_string_t inset_type;
15719 cmdline_fixed_string_t clear;
15720 cmdline_fixed_string_t all;
15724 cmd_clear_input_set_parsed(
15725 __rte_unused void *parsed_result,
15726 __rte_unused struct cmdline *cl,
15727 __rte_unused void *data)
15729 #ifdef RTE_NET_I40E
15730 struct cmd_clear_input_set_result *res = parsed_result;
15731 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
15732 struct rte_pmd_i40e_inset inset;
15734 int ret = -ENOTSUP;
15736 if (!all_ports_stopped()) {
15737 printf("Please stop all ports first\n");
15741 #ifdef RTE_NET_I40E
15742 if (!strcmp(res->inset_type, "hash_inset"))
15743 inset_type = INSET_HASH;
15744 else if (!strcmp(res->inset_type, "fdir_inset"))
15745 inset_type = INSET_FDIR;
15746 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
15747 inset_type = INSET_FDIR_FLX;
15749 memset(&inset, 0, sizeof(inset));
15751 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
15752 &inset, inset_type);
15754 printf("Failed to clear input set.\n");
15760 if (ret == -ENOTSUP)
15761 printf("Function not supported\n");
15764 cmdline_parse_token_string_t cmd_clear_input_set_port =
15765 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15767 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
15768 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15770 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
15771 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
15773 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
15774 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15776 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
15777 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
15779 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
15780 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15782 "hash_inset#fdir_inset#fdir_flx_inset");
15783 cmdline_parse_token_string_t cmd_clear_input_set_clear =
15784 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15786 cmdline_parse_token_string_t cmd_clear_input_set_all =
15787 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15790 cmdline_parse_inst_t cmd_clear_input_set = {
15791 .f = cmd_clear_input_set_parsed,
15793 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
15794 "fdir_inset|fdir_flx_inset clear all",
15796 (void *)&cmd_clear_input_set_port,
15797 (void *)&cmd_clear_input_set_cfg,
15798 (void *)&cmd_clear_input_set_port_id,
15799 (void *)&cmd_clear_input_set_pctype,
15800 (void *)&cmd_clear_input_set_pctype_id,
15801 (void *)&cmd_clear_input_set_inset_type,
15802 (void *)&cmd_clear_input_set_clear,
15803 (void *)&cmd_clear_input_set_all,
15808 /* show vf stats */
15810 /* Common result structure for show vf stats */
15811 struct cmd_show_vf_stats_result {
15812 cmdline_fixed_string_t show;
15813 cmdline_fixed_string_t vf;
15814 cmdline_fixed_string_t stats;
15819 /* Common CLI fields show vf stats*/
15820 cmdline_parse_token_string_t cmd_show_vf_stats_show =
15821 TOKEN_STRING_INITIALIZER
15822 (struct cmd_show_vf_stats_result,
15824 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
15825 TOKEN_STRING_INITIALIZER
15826 (struct cmd_show_vf_stats_result,
15828 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
15829 TOKEN_STRING_INITIALIZER
15830 (struct cmd_show_vf_stats_result,
15832 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
15833 TOKEN_NUM_INITIALIZER
15834 (struct cmd_show_vf_stats_result,
15836 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
15837 TOKEN_NUM_INITIALIZER
15838 (struct cmd_show_vf_stats_result,
15842 cmd_show_vf_stats_parsed(
15843 void *parsed_result,
15844 __rte_unused struct cmdline *cl,
15845 __rte_unused void *data)
15847 struct cmd_show_vf_stats_result *res = parsed_result;
15848 struct rte_eth_stats stats;
15849 int ret = -ENOTSUP;
15850 static const char *nic_stats_border = "########################";
15852 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15855 memset(&stats, 0, sizeof(stats));
15857 #ifdef RTE_NET_I40E
15858 if (ret == -ENOTSUP)
15859 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
15863 #ifdef RTE_NET_BNXT
15864 if (ret == -ENOTSUP)
15865 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
15874 printf("invalid vf_id %d\n", res->vf_id);
15877 printf("invalid port_id %d\n", res->port_id);
15880 printf("function not implemented\n");
15883 printf("programming error: (%s)\n", strerror(-ret));
15886 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
15887 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
15889 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
15891 stats.ipackets, stats.imissed, stats.ibytes);
15892 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
15893 printf(" RX-nombuf: %-10"PRIu64"\n",
15895 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
15897 stats.opackets, stats.oerrors, stats.obytes);
15899 printf(" %s############################%s\n",
15900 nic_stats_border, nic_stats_border);
15903 cmdline_parse_inst_t cmd_show_vf_stats = {
15904 .f = cmd_show_vf_stats_parsed,
15906 .help_str = "show vf stats <port_id> <vf_id>",
15908 (void *)&cmd_show_vf_stats_show,
15909 (void *)&cmd_show_vf_stats_vf,
15910 (void *)&cmd_show_vf_stats_stats,
15911 (void *)&cmd_show_vf_stats_port_id,
15912 (void *)&cmd_show_vf_stats_vf_id,
15917 /* clear vf stats */
15919 /* Common result structure for clear vf stats */
15920 struct cmd_clear_vf_stats_result {
15921 cmdline_fixed_string_t clear;
15922 cmdline_fixed_string_t vf;
15923 cmdline_fixed_string_t stats;
15928 /* Common CLI fields clear vf stats*/
15929 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
15930 TOKEN_STRING_INITIALIZER
15931 (struct cmd_clear_vf_stats_result,
15933 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
15934 TOKEN_STRING_INITIALIZER
15935 (struct cmd_clear_vf_stats_result,
15937 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
15938 TOKEN_STRING_INITIALIZER
15939 (struct cmd_clear_vf_stats_result,
15941 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
15942 TOKEN_NUM_INITIALIZER
15943 (struct cmd_clear_vf_stats_result,
15945 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
15946 TOKEN_NUM_INITIALIZER
15947 (struct cmd_clear_vf_stats_result,
15951 cmd_clear_vf_stats_parsed(
15952 void *parsed_result,
15953 __rte_unused struct cmdline *cl,
15954 __rte_unused void *data)
15956 struct cmd_clear_vf_stats_result *res = parsed_result;
15957 int ret = -ENOTSUP;
15959 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15962 #ifdef RTE_NET_I40E
15963 if (ret == -ENOTSUP)
15964 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
15967 #ifdef RTE_NET_BNXT
15968 if (ret == -ENOTSUP)
15969 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
15977 printf("invalid vf_id %d\n", res->vf_id);
15980 printf("invalid port_id %d\n", res->port_id);
15983 printf("function not implemented\n");
15986 printf("programming error: (%s)\n", strerror(-ret));
15990 cmdline_parse_inst_t cmd_clear_vf_stats = {
15991 .f = cmd_clear_vf_stats_parsed,
15993 .help_str = "clear vf stats <port_id> <vf_id>",
15995 (void *)&cmd_clear_vf_stats_clear,
15996 (void *)&cmd_clear_vf_stats_vf,
15997 (void *)&cmd_clear_vf_stats_stats,
15998 (void *)&cmd_clear_vf_stats_port_id,
15999 (void *)&cmd_clear_vf_stats_vf_id,
16004 /* port config pctype mapping reset */
16006 /* Common result structure for port config pctype mapping reset */
16007 struct cmd_pctype_mapping_reset_result {
16008 cmdline_fixed_string_t port;
16009 cmdline_fixed_string_t config;
16011 cmdline_fixed_string_t pctype;
16012 cmdline_fixed_string_t mapping;
16013 cmdline_fixed_string_t reset;
16016 /* Common CLI fields for port config pctype mapping reset*/
16017 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
16018 TOKEN_STRING_INITIALIZER
16019 (struct cmd_pctype_mapping_reset_result,
16021 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
16022 TOKEN_STRING_INITIALIZER
16023 (struct cmd_pctype_mapping_reset_result,
16025 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
16026 TOKEN_NUM_INITIALIZER
16027 (struct cmd_pctype_mapping_reset_result,
16029 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
16030 TOKEN_STRING_INITIALIZER
16031 (struct cmd_pctype_mapping_reset_result,
16033 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
16034 TOKEN_STRING_INITIALIZER
16035 (struct cmd_pctype_mapping_reset_result,
16036 mapping, "mapping");
16037 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
16038 TOKEN_STRING_INITIALIZER
16039 (struct cmd_pctype_mapping_reset_result,
16043 cmd_pctype_mapping_reset_parsed(
16044 void *parsed_result,
16045 __rte_unused struct cmdline *cl,
16046 __rte_unused void *data)
16048 struct cmd_pctype_mapping_reset_result *res = parsed_result;
16049 int ret = -ENOTSUP;
16051 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16054 #ifdef RTE_NET_I40E
16055 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
16062 printf("invalid port_id %d\n", res->port_id);
16065 printf("function not implemented\n");
16068 printf("programming error: (%s)\n", strerror(-ret));
16072 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
16073 .f = cmd_pctype_mapping_reset_parsed,
16075 .help_str = "port config <port_id> pctype mapping reset",
16077 (void *)&cmd_pctype_mapping_reset_port,
16078 (void *)&cmd_pctype_mapping_reset_config,
16079 (void *)&cmd_pctype_mapping_reset_port_id,
16080 (void *)&cmd_pctype_mapping_reset_pctype,
16081 (void *)&cmd_pctype_mapping_reset_mapping,
16082 (void *)&cmd_pctype_mapping_reset_reset,
16087 /* show port pctype mapping */
16089 /* Common result structure for show port pctype mapping */
16090 struct cmd_pctype_mapping_get_result {
16091 cmdline_fixed_string_t show;
16092 cmdline_fixed_string_t port;
16094 cmdline_fixed_string_t pctype;
16095 cmdline_fixed_string_t mapping;
16098 /* Common CLI fields for pctype mapping get */
16099 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
16100 TOKEN_STRING_INITIALIZER
16101 (struct cmd_pctype_mapping_get_result,
16103 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
16104 TOKEN_STRING_INITIALIZER
16105 (struct cmd_pctype_mapping_get_result,
16107 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
16108 TOKEN_NUM_INITIALIZER
16109 (struct cmd_pctype_mapping_get_result,
16111 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
16112 TOKEN_STRING_INITIALIZER
16113 (struct cmd_pctype_mapping_get_result,
16115 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
16116 TOKEN_STRING_INITIALIZER
16117 (struct cmd_pctype_mapping_get_result,
16118 mapping, "mapping");
16121 cmd_pctype_mapping_get_parsed(
16122 void *parsed_result,
16123 __rte_unused struct cmdline *cl,
16124 __rte_unused void *data)
16126 struct cmd_pctype_mapping_get_result *res = parsed_result;
16127 int ret = -ENOTSUP;
16128 #ifdef RTE_NET_I40E
16129 struct rte_pmd_i40e_flow_type_mapping
16130 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
16131 int i, j, first_pctype;
16134 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16137 #ifdef RTE_NET_I40E
16138 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
16145 printf("invalid port_id %d\n", res->port_id);
16148 printf("function not implemented\n");
16151 printf("programming error: (%s)\n", strerror(-ret));
16155 #ifdef RTE_NET_I40E
16156 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
16157 if (mapping[i].pctype != 0ULL) {
16160 printf("pctype: ");
16161 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
16162 if (mapping[i].pctype & (1ULL << j)) {
16163 printf(first_pctype ?
16164 "%02d" : ",%02d", j);
16168 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
16174 cmdline_parse_inst_t cmd_pctype_mapping_get = {
16175 .f = cmd_pctype_mapping_get_parsed,
16177 .help_str = "show port <port_id> pctype mapping",
16179 (void *)&cmd_pctype_mapping_get_show,
16180 (void *)&cmd_pctype_mapping_get_port,
16181 (void *)&cmd_pctype_mapping_get_port_id,
16182 (void *)&cmd_pctype_mapping_get_pctype,
16183 (void *)&cmd_pctype_mapping_get_mapping,
16188 /* port config pctype mapping update */
16190 /* Common result structure for port config pctype mapping update */
16191 struct cmd_pctype_mapping_update_result {
16192 cmdline_fixed_string_t port;
16193 cmdline_fixed_string_t config;
16195 cmdline_fixed_string_t pctype;
16196 cmdline_fixed_string_t mapping;
16197 cmdline_fixed_string_t update;
16198 cmdline_fixed_string_t pctype_list;
16199 uint16_t flow_type;
16202 /* Common CLI fields for pctype mapping update*/
16203 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
16204 TOKEN_STRING_INITIALIZER
16205 (struct cmd_pctype_mapping_update_result,
16207 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
16208 TOKEN_STRING_INITIALIZER
16209 (struct cmd_pctype_mapping_update_result,
16211 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
16212 TOKEN_NUM_INITIALIZER
16213 (struct cmd_pctype_mapping_update_result,
16215 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
16216 TOKEN_STRING_INITIALIZER
16217 (struct cmd_pctype_mapping_update_result,
16219 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
16220 TOKEN_STRING_INITIALIZER
16221 (struct cmd_pctype_mapping_update_result,
16222 mapping, "mapping");
16223 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
16224 TOKEN_STRING_INITIALIZER
16225 (struct cmd_pctype_mapping_update_result,
16227 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
16228 TOKEN_STRING_INITIALIZER
16229 (struct cmd_pctype_mapping_update_result,
16230 pctype_list, NULL);
16231 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
16232 TOKEN_NUM_INITIALIZER
16233 (struct cmd_pctype_mapping_update_result,
16234 flow_type, UINT16);
16237 cmd_pctype_mapping_update_parsed(
16238 void *parsed_result,
16239 __rte_unused struct cmdline *cl,
16240 __rte_unused void *data)
16242 struct cmd_pctype_mapping_update_result *res = parsed_result;
16243 int ret = -ENOTSUP;
16244 #ifdef RTE_NET_I40E
16245 struct rte_pmd_i40e_flow_type_mapping mapping;
16247 unsigned int nb_item;
16248 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
16251 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16254 #ifdef RTE_NET_I40E
16255 nb_item = parse_item_list(res->pctype_list, "pctypes",
16256 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
16257 mapping.flow_type = res->flow_type;
16258 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
16259 mapping.pctype |= (1ULL << pctype_list[i]);
16260 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
16270 printf("invalid pctype or flow type\n");
16273 printf("invalid port_id %d\n", res->port_id);
16276 printf("function not implemented\n");
16279 printf("programming error: (%s)\n", strerror(-ret));
16283 cmdline_parse_inst_t cmd_pctype_mapping_update = {
16284 .f = cmd_pctype_mapping_update_parsed,
16286 .help_str = "port config <port_id> pctype mapping update"
16287 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
16289 (void *)&cmd_pctype_mapping_update_port,
16290 (void *)&cmd_pctype_mapping_update_config,
16291 (void *)&cmd_pctype_mapping_update_port_id,
16292 (void *)&cmd_pctype_mapping_update_pctype,
16293 (void *)&cmd_pctype_mapping_update_mapping,
16294 (void *)&cmd_pctype_mapping_update_update,
16295 (void *)&cmd_pctype_mapping_update_pc_type,
16296 (void *)&cmd_pctype_mapping_update_flow_type,
16301 /* ptype mapping get */
16303 /* Common result structure for ptype mapping get */
16304 struct cmd_ptype_mapping_get_result {
16305 cmdline_fixed_string_t ptype;
16306 cmdline_fixed_string_t mapping;
16307 cmdline_fixed_string_t get;
16309 uint8_t valid_only;
16312 /* Common CLI fields for ptype mapping get */
16313 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
16314 TOKEN_STRING_INITIALIZER
16315 (struct cmd_ptype_mapping_get_result,
16317 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
16318 TOKEN_STRING_INITIALIZER
16319 (struct cmd_ptype_mapping_get_result,
16320 mapping, "mapping");
16321 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
16322 TOKEN_STRING_INITIALIZER
16323 (struct cmd_ptype_mapping_get_result,
16325 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
16326 TOKEN_NUM_INITIALIZER
16327 (struct cmd_ptype_mapping_get_result,
16329 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
16330 TOKEN_NUM_INITIALIZER
16331 (struct cmd_ptype_mapping_get_result,
16332 valid_only, UINT8);
16335 cmd_ptype_mapping_get_parsed(
16336 void *parsed_result,
16337 __rte_unused struct cmdline *cl,
16338 __rte_unused void *data)
16340 struct cmd_ptype_mapping_get_result *res = parsed_result;
16341 int ret = -ENOTSUP;
16342 #ifdef RTE_NET_I40E
16343 int max_ptype_num = 256;
16344 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
16349 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16352 #ifdef RTE_NET_I40E
16353 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
16364 printf("invalid port_id %d\n", res->port_id);
16367 printf("function not implemented\n");
16370 printf("programming error: (%s)\n", strerror(-ret));
16373 #ifdef RTE_NET_I40E
16375 for (i = 0; i < count; i++)
16376 printf("%3d\t0x%08x\n",
16377 mapping[i].hw_ptype, mapping[i].sw_ptype);
16382 cmdline_parse_inst_t cmd_ptype_mapping_get = {
16383 .f = cmd_ptype_mapping_get_parsed,
16385 .help_str = "ptype mapping get <port_id> <valid_only>",
16387 (void *)&cmd_ptype_mapping_get_ptype,
16388 (void *)&cmd_ptype_mapping_get_mapping,
16389 (void *)&cmd_ptype_mapping_get_get,
16390 (void *)&cmd_ptype_mapping_get_port_id,
16391 (void *)&cmd_ptype_mapping_get_valid_only,
16396 /* ptype mapping replace */
16398 /* Common result structure for ptype mapping replace */
16399 struct cmd_ptype_mapping_replace_result {
16400 cmdline_fixed_string_t ptype;
16401 cmdline_fixed_string_t mapping;
16402 cmdline_fixed_string_t replace;
16409 /* Common CLI fields for ptype mapping replace */
16410 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
16411 TOKEN_STRING_INITIALIZER
16412 (struct cmd_ptype_mapping_replace_result,
16414 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
16415 TOKEN_STRING_INITIALIZER
16416 (struct cmd_ptype_mapping_replace_result,
16417 mapping, "mapping");
16418 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
16419 TOKEN_STRING_INITIALIZER
16420 (struct cmd_ptype_mapping_replace_result,
16421 replace, "replace");
16422 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
16423 TOKEN_NUM_INITIALIZER
16424 (struct cmd_ptype_mapping_replace_result,
16426 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
16427 TOKEN_NUM_INITIALIZER
16428 (struct cmd_ptype_mapping_replace_result,
16430 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
16431 TOKEN_NUM_INITIALIZER
16432 (struct cmd_ptype_mapping_replace_result,
16434 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
16435 TOKEN_NUM_INITIALIZER
16436 (struct cmd_ptype_mapping_replace_result,
16440 cmd_ptype_mapping_replace_parsed(
16441 void *parsed_result,
16442 __rte_unused struct cmdline *cl,
16443 __rte_unused void *data)
16445 struct cmd_ptype_mapping_replace_result *res = parsed_result;
16446 int ret = -ENOTSUP;
16448 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16451 #ifdef RTE_NET_I40E
16452 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
16462 printf("invalid ptype 0x%8x or 0x%8x\n",
16463 res->target, res->pkt_type);
16466 printf("invalid port_id %d\n", res->port_id);
16469 printf("function not implemented\n");
16472 printf("programming error: (%s)\n", strerror(-ret));
16476 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
16477 .f = cmd_ptype_mapping_replace_parsed,
16480 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
16482 (void *)&cmd_ptype_mapping_replace_ptype,
16483 (void *)&cmd_ptype_mapping_replace_mapping,
16484 (void *)&cmd_ptype_mapping_replace_replace,
16485 (void *)&cmd_ptype_mapping_replace_port_id,
16486 (void *)&cmd_ptype_mapping_replace_target,
16487 (void *)&cmd_ptype_mapping_replace_mask,
16488 (void *)&cmd_ptype_mapping_replace_pkt_type,
16493 /* ptype mapping reset */
16495 /* Common result structure for ptype mapping reset */
16496 struct cmd_ptype_mapping_reset_result {
16497 cmdline_fixed_string_t ptype;
16498 cmdline_fixed_string_t mapping;
16499 cmdline_fixed_string_t reset;
16503 /* Common CLI fields for ptype mapping reset*/
16504 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
16505 TOKEN_STRING_INITIALIZER
16506 (struct cmd_ptype_mapping_reset_result,
16508 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
16509 TOKEN_STRING_INITIALIZER
16510 (struct cmd_ptype_mapping_reset_result,
16511 mapping, "mapping");
16512 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
16513 TOKEN_STRING_INITIALIZER
16514 (struct cmd_ptype_mapping_reset_result,
16516 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
16517 TOKEN_NUM_INITIALIZER
16518 (struct cmd_ptype_mapping_reset_result,
16522 cmd_ptype_mapping_reset_parsed(
16523 void *parsed_result,
16524 __rte_unused struct cmdline *cl,
16525 __rte_unused void *data)
16527 struct cmd_ptype_mapping_reset_result *res = parsed_result;
16528 int ret = -ENOTSUP;
16530 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16533 #ifdef RTE_NET_I40E
16534 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
16541 printf("invalid port_id %d\n", res->port_id);
16544 printf("function not implemented\n");
16547 printf("programming error: (%s)\n", strerror(-ret));
16551 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
16552 .f = cmd_ptype_mapping_reset_parsed,
16554 .help_str = "ptype mapping reset <port_id>",
16556 (void *)&cmd_ptype_mapping_reset_ptype,
16557 (void *)&cmd_ptype_mapping_reset_mapping,
16558 (void *)&cmd_ptype_mapping_reset_reset,
16559 (void *)&cmd_ptype_mapping_reset_port_id,
16564 /* ptype mapping update */
16566 /* Common result structure for ptype mapping update */
16567 struct cmd_ptype_mapping_update_result {
16568 cmdline_fixed_string_t ptype;
16569 cmdline_fixed_string_t mapping;
16570 cmdline_fixed_string_t reset;
16576 /* Common CLI fields for ptype mapping update*/
16577 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
16578 TOKEN_STRING_INITIALIZER
16579 (struct cmd_ptype_mapping_update_result,
16581 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
16582 TOKEN_STRING_INITIALIZER
16583 (struct cmd_ptype_mapping_update_result,
16584 mapping, "mapping");
16585 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
16586 TOKEN_STRING_INITIALIZER
16587 (struct cmd_ptype_mapping_update_result,
16589 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
16590 TOKEN_NUM_INITIALIZER
16591 (struct cmd_ptype_mapping_update_result,
16593 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
16594 TOKEN_NUM_INITIALIZER
16595 (struct cmd_ptype_mapping_update_result,
16597 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
16598 TOKEN_NUM_INITIALIZER
16599 (struct cmd_ptype_mapping_update_result,
16603 cmd_ptype_mapping_update_parsed(
16604 void *parsed_result,
16605 __rte_unused struct cmdline *cl,
16606 __rte_unused void *data)
16608 struct cmd_ptype_mapping_update_result *res = parsed_result;
16609 int ret = -ENOTSUP;
16610 #ifdef RTE_NET_I40E
16611 struct rte_pmd_i40e_ptype_mapping mapping;
16613 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16616 #ifdef RTE_NET_I40E
16617 mapping.hw_ptype = res->hw_ptype;
16618 mapping.sw_ptype = res->sw_ptype;
16619 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
16629 printf("invalid ptype 0x%8x\n", res->sw_ptype);
16632 printf("invalid port_id %d\n", res->port_id);
16635 printf("function not implemented\n");
16638 printf("programming error: (%s)\n", strerror(-ret));
16642 cmdline_parse_inst_t cmd_ptype_mapping_update = {
16643 .f = cmd_ptype_mapping_update_parsed,
16645 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
16647 (void *)&cmd_ptype_mapping_update_ptype,
16648 (void *)&cmd_ptype_mapping_update_mapping,
16649 (void *)&cmd_ptype_mapping_update_update,
16650 (void *)&cmd_ptype_mapping_update_port_id,
16651 (void *)&cmd_ptype_mapping_update_hw_ptype,
16652 (void *)&cmd_ptype_mapping_update_sw_ptype,
16657 /* Common result structure for file commands */
16658 struct cmd_cmdfile_result {
16659 cmdline_fixed_string_t load;
16660 cmdline_fixed_string_t filename;
16663 /* Common CLI fields for file commands */
16664 cmdline_parse_token_string_t cmd_load_cmdfile =
16665 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
16666 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
16667 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
16670 cmd_load_from_file_parsed(
16671 void *parsed_result,
16672 __rte_unused struct cmdline *cl,
16673 __rte_unused void *data)
16675 struct cmd_cmdfile_result *res = parsed_result;
16677 cmdline_read_from_file(res->filename);
16680 cmdline_parse_inst_t cmd_load_from_file = {
16681 .f = cmd_load_from_file_parsed,
16683 .help_str = "load <filename>",
16685 (void *)&cmd_load_cmdfile,
16686 (void *)&cmd_load_cmdfile_filename,
16691 /* Get Rx offloads capabilities */
16692 struct cmd_rx_offload_get_capa_result {
16693 cmdline_fixed_string_t show;
16694 cmdline_fixed_string_t port;
16696 cmdline_fixed_string_t rx_offload;
16697 cmdline_fixed_string_t capabilities;
16700 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
16701 TOKEN_STRING_INITIALIZER
16702 (struct cmd_rx_offload_get_capa_result,
16704 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
16705 TOKEN_STRING_INITIALIZER
16706 (struct cmd_rx_offload_get_capa_result,
16708 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
16709 TOKEN_NUM_INITIALIZER
16710 (struct cmd_rx_offload_get_capa_result,
16712 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
16713 TOKEN_STRING_INITIALIZER
16714 (struct cmd_rx_offload_get_capa_result,
16715 rx_offload, "rx_offload");
16716 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
16717 TOKEN_STRING_INITIALIZER
16718 (struct cmd_rx_offload_get_capa_result,
16719 capabilities, "capabilities");
16722 print_rx_offloads(uint64_t offloads)
16724 uint64_t single_offload;
16732 begin = __builtin_ctzll(offloads);
16733 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
16735 single_offload = 1ULL << begin;
16736 for (bit = begin; bit < end; bit++) {
16737 if (offloads & single_offload)
16739 rte_eth_dev_rx_offload_name(single_offload));
16740 single_offload <<= 1;
16745 cmd_rx_offload_get_capa_parsed(
16746 void *parsed_result,
16747 __rte_unused struct cmdline *cl,
16748 __rte_unused void *data)
16750 struct cmd_rx_offload_get_capa_result *res = parsed_result;
16751 struct rte_eth_dev_info dev_info;
16752 portid_t port_id = res->port_id;
16753 uint64_t queue_offloads;
16754 uint64_t port_offloads;
16757 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16761 queue_offloads = dev_info.rx_queue_offload_capa;
16762 port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
16764 printf("Rx Offloading Capabilities of port %d :\n", port_id);
16765 printf(" Per Queue :");
16766 print_rx_offloads(queue_offloads);
16769 printf(" Per Port :");
16770 print_rx_offloads(port_offloads);
16774 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
16775 .f = cmd_rx_offload_get_capa_parsed,
16777 .help_str = "show port <port_id> rx_offload capabilities",
16779 (void *)&cmd_rx_offload_get_capa_show,
16780 (void *)&cmd_rx_offload_get_capa_port,
16781 (void *)&cmd_rx_offload_get_capa_port_id,
16782 (void *)&cmd_rx_offload_get_capa_rx_offload,
16783 (void *)&cmd_rx_offload_get_capa_capabilities,
16788 /* Get Rx offloads configuration */
16789 struct cmd_rx_offload_get_configuration_result {
16790 cmdline_fixed_string_t show;
16791 cmdline_fixed_string_t port;
16793 cmdline_fixed_string_t rx_offload;
16794 cmdline_fixed_string_t configuration;
16797 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
16798 TOKEN_STRING_INITIALIZER
16799 (struct cmd_rx_offload_get_configuration_result,
16801 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
16802 TOKEN_STRING_INITIALIZER
16803 (struct cmd_rx_offload_get_configuration_result,
16805 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
16806 TOKEN_NUM_INITIALIZER
16807 (struct cmd_rx_offload_get_configuration_result,
16809 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
16810 TOKEN_STRING_INITIALIZER
16811 (struct cmd_rx_offload_get_configuration_result,
16812 rx_offload, "rx_offload");
16813 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
16814 TOKEN_STRING_INITIALIZER
16815 (struct cmd_rx_offload_get_configuration_result,
16816 configuration, "configuration");
16819 cmd_rx_offload_get_configuration_parsed(
16820 void *parsed_result,
16821 __rte_unused struct cmdline *cl,
16822 __rte_unused void *data)
16824 struct cmd_rx_offload_get_configuration_result *res = parsed_result;
16825 struct rte_eth_dev_info dev_info;
16826 portid_t port_id = res->port_id;
16827 struct rte_port *port = &ports[port_id];
16828 uint64_t port_offloads;
16829 uint64_t queue_offloads;
16830 uint16_t nb_rx_queues;
16834 printf("Rx Offloading Configuration of port %d :\n", port_id);
16836 port_offloads = port->dev_conf.rxmode.offloads;
16838 print_rx_offloads(port_offloads);
16841 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16845 nb_rx_queues = dev_info.nb_rx_queues;
16846 for (q = 0; q < nb_rx_queues; q++) {
16847 queue_offloads = port->rx_conf[q].offloads;
16848 printf(" Queue[%2d] :", q);
16849 print_rx_offloads(queue_offloads);
16855 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
16856 .f = cmd_rx_offload_get_configuration_parsed,
16858 .help_str = "show port <port_id> rx_offload configuration",
16860 (void *)&cmd_rx_offload_get_configuration_show,
16861 (void *)&cmd_rx_offload_get_configuration_port,
16862 (void *)&cmd_rx_offload_get_configuration_port_id,
16863 (void *)&cmd_rx_offload_get_configuration_rx_offload,
16864 (void *)&cmd_rx_offload_get_configuration_configuration,
16869 /* Enable/Disable a per port offloading */
16870 struct cmd_config_per_port_rx_offload_result {
16871 cmdline_fixed_string_t port;
16872 cmdline_fixed_string_t config;
16874 cmdline_fixed_string_t rx_offload;
16875 cmdline_fixed_string_t offload;
16876 cmdline_fixed_string_t on_off;
16879 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
16880 TOKEN_STRING_INITIALIZER
16881 (struct cmd_config_per_port_rx_offload_result,
16883 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
16884 TOKEN_STRING_INITIALIZER
16885 (struct cmd_config_per_port_rx_offload_result,
16887 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
16888 TOKEN_NUM_INITIALIZER
16889 (struct cmd_config_per_port_rx_offload_result,
16891 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
16892 TOKEN_STRING_INITIALIZER
16893 (struct cmd_config_per_port_rx_offload_result,
16894 rx_offload, "rx_offload");
16895 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
16896 TOKEN_STRING_INITIALIZER
16897 (struct cmd_config_per_port_rx_offload_result,
16898 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
16899 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
16900 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
16901 "scatter#buffer_split#timestamp#security#"
16902 "keep_crc#rss_hash");
16903 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
16904 TOKEN_STRING_INITIALIZER
16905 (struct cmd_config_per_port_rx_offload_result,
16909 search_rx_offload(const char *name)
16911 uint64_t single_offload;
16912 const char *single_name;
16916 single_offload = 1;
16917 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
16918 single_name = rte_eth_dev_rx_offload_name(single_offload);
16919 if (!strcasecmp(single_name, name)) {
16923 single_offload <<= 1;
16927 return single_offload;
16933 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
16934 __rte_unused struct cmdline *cl,
16935 __rte_unused void *data)
16937 struct cmd_config_per_port_rx_offload_result *res = parsed_result;
16938 portid_t port_id = res->port_id;
16939 struct rte_eth_dev_info dev_info;
16940 struct rte_port *port = &ports[port_id];
16941 uint64_t single_offload;
16942 uint16_t nb_rx_queues;
16946 if (port->port_status != RTE_PORT_STOPPED) {
16947 printf("Error: Can't config offload when Port %d "
16948 "is not stopped\n", port_id);
16952 single_offload = search_rx_offload(res->offload);
16953 if (single_offload == 0) {
16954 printf("Unknown offload name: %s\n", res->offload);
16958 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16962 nb_rx_queues = dev_info.nb_rx_queues;
16963 if (!strcmp(res->on_off, "on")) {
16964 port->dev_conf.rxmode.offloads |= single_offload;
16965 for (q = 0; q < nb_rx_queues; q++)
16966 port->rx_conf[q].offloads |= single_offload;
16968 port->dev_conf.rxmode.offloads &= ~single_offload;
16969 for (q = 0; q < nb_rx_queues; q++)
16970 port->rx_conf[q].offloads &= ~single_offload;
16973 cmd_reconfig_device_queue(port_id, 1, 1);
16976 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
16977 .f = cmd_config_per_port_rx_offload_parsed,
16979 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
16980 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
16981 "macsec_strip|header_split|vlan_filter|vlan_extend|"
16982 "jumbo_frame|scatter|buffer_split|timestamp|security|"
16983 "keep_crc|rss_hash on|off",
16985 (void *)&cmd_config_per_port_rx_offload_result_port,
16986 (void *)&cmd_config_per_port_rx_offload_result_config,
16987 (void *)&cmd_config_per_port_rx_offload_result_port_id,
16988 (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
16989 (void *)&cmd_config_per_port_rx_offload_result_offload,
16990 (void *)&cmd_config_per_port_rx_offload_result_on_off,
16995 /* Enable/Disable a per queue offloading */
16996 struct cmd_config_per_queue_rx_offload_result {
16997 cmdline_fixed_string_t port;
16999 cmdline_fixed_string_t rxq;
17001 cmdline_fixed_string_t rx_offload;
17002 cmdline_fixed_string_t offload;
17003 cmdline_fixed_string_t on_off;
17006 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
17007 TOKEN_STRING_INITIALIZER
17008 (struct cmd_config_per_queue_rx_offload_result,
17010 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
17011 TOKEN_NUM_INITIALIZER
17012 (struct cmd_config_per_queue_rx_offload_result,
17014 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
17015 TOKEN_STRING_INITIALIZER
17016 (struct cmd_config_per_queue_rx_offload_result,
17018 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
17019 TOKEN_NUM_INITIALIZER
17020 (struct cmd_config_per_queue_rx_offload_result,
17022 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
17023 TOKEN_STRING_INITIALIZER
17024 (struct cmd_config_per_queue_rx_offload_result,
17025 rx_offload, "rx_offload");
17026 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
17027 TOKEN_STRING_INITIALIZER
17028 (struct cmd_config_per_queue_rx_offload_result,
17029 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
17030 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
17031 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
17032 "scatter#buffer_split#timestamp#security#keep_crc");
17033 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
17034 TOKEN_STRING_INITIALIZER
17035 (struct cmd_config_per_queue_rx_offload_result,
17039 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
17040 __rte_unused struct cmdline *cl,
17041 __rte_unused void *data)
17043 struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
17044 struct rte_eth_dev_info dev_info;
17045 portid_t port_id = res->port_id;
17046 uint16_t queue_id = res->queue_id;
17047 struct rte_port *port = &ports[port_id];
17048 uint64_t single_offload;
17051 if (port->port_status != RTE_PORT_STOPPED) {
17052 printf("Error: Can't config offload when Port %d "
17053 "is not stopped\n", port_id);
17057 ret = eth_dev_info_get_print_err(port_id, &dev_info);
17061 if (queue_id >= dev_info.nb_rx_queues) {
17062 printf("Error: input queue_id should be 0 ... "
17063 "%d\n", dev_info.nb_rx_queues - 1);
17067 single_offload = search_rx_offload(res->offload);
17068 if (single_offload == 0) {
17069 printf("Unknown offload name: %s\n", res->offload);
17073 if (!strcmp(res->on_off, "on"))
17074 port->rx_conf[queue_id].offloads |= single_offload;
17076 port->rx_conf[queue_id].offloads &= ~single_offload;
17078 cmd_reconfig_device_queue(port_id, 1, 1);
17081 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
17082 .f = cmd_config_per_queue_rx_offload_parsed,
17084 .help_str = "port <port_id> rxq <queue_id> rx_offload "
17085 "vlan_strip|ipv4_cksum|"
17086 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
17087 "macsec_strip|header_split|vlan_filter|vlan_extend|"
17088 "jumbo_frame|scatter|buffer_split|timestamp|security|"
17091 (void *)&cmd_config_per_queue_rx_offload_result_port,
17092 (void *)&cmd_config_per_queue_rx_offload_result_port_id,
17093 (void *)&cmd_config_per_queue_rx_offload_result_rxq,
17094 (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
17095 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
17096 (void *)&cmd_config_per_queue_rx_offload_result_offload,
17097 (void *)&cmd_config_per_queue_rx_offload_result_on_off,
17102 /* Get Tx offloads capabilities */
17103 struct cmd_tx_offload_get_capa_result {
17104 cmdline_fixed_string_t show;
17105 cmdline_fixed_string_t port;
17107 cmdline_fixed_string_t tx_offload;
17108 cmdline_fixed_string_t capabilities;
17111 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
17112 TOKEN_STRING_INITIALIZER
17113 (struct cmd_tx_offload_get_capa_result,
17115 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
17116 TOKEN_STRING_INITIALIZER
17117 (struct cmd_tx_offload_get_capa_result,
17119 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
17120 TOKEN_NUM_INITIALIZER
17121 (struct cmd_tx_offload_get_capa_result,
17123 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
17124 TOKEN_STRING_INITIALIZER
17125 (struct cmd_tx_offload_get_capa_result,
17126 tx_offload, "tx_offload");
17127 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
17128 TOKEN_STRING_INITIALIZER
17129 (struct cmd_tx_offload_get_capa_result,
17130 capabilities, "capabilities");
17133 print_tx_offloads(uint64_t offloads)
17135 uint64_t single_offload;
17143 begin = __builtin_ctzll(offloads);
17144 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
17146 single_offload = 1ULL << begin;
17147 for (bit = begin; bit < end; bit++) {
17148 if (offloads & single_offload)
17150 rte_eth_dev_tx_offload_name(single_offload));
17151 single_offload <<= 1;
17156 cmd_tx_offload_get_capa_parsed(
17157 void *parsed_result,
17158 __rte_unused struct cmdline *cl,
17159 __rte_unused void *data)
17161 struct cmd_tx_offload_get_capa_result *res = parsed_result;
17162 struct rte_eth_dev_info dev_info;
17163 portid_t port_id = res->port_id;
17164 uint64_t queue_offloads;
17165 uint64_t port_offloads;
17168 ret = eth_dev_info_get_print_err(port_id, &dev_info);
17172 queue_offloads = dev_info.tx_queue_offload_capa;
17173 port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
17175 printf("Tx Offloading Capabilities of port %d :\n", port_id);
17176 printf(" Per Queue :");
17177 print_tx_offloads(queue_offloads);
17180 printf(" Per Port :");
17181 print_tx_offloads(port_offloads);
17185 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
17186 .f = cmd_tx_offload_get_capa_parsed,
17188 .help_str = "show port <port_id> tx_offload capabilities",
17190 (void *)&cmd_tx_offload_get_capa_show,
17191 (void *)&cmd_tx_offload_get_capa_port,
17192 (void *)&cmd_tx_offload_get_capa_port_id,
17193 (void *)&cmd_tx_offload_get_capa_tx_offload,
17194 (void *)&cmd_tx_offload_get_capa_capabilities,
17199 /* Get Tx offloads configuration */
17200 struct cmd_tx_offload_get_configuration_result {
17201 cmdline_fixed_string_t show;
17202 cmdline_fixed_string_t port;
17204 cmdline_fixed_string_t tx_offload;
17205 cmdline_fixed_string_t configuration;
17208 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
17209 TOKEN_STRING_INITIALIZER
17210 (struct cmd_tx_offload_get_configuration_result,
17212 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
17213 TOKEN_STRING_INITIALIZER
17214 (struct cmd_tx_offload_get_configuration_result,
17216 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
17217 TOKEN_NUM_INITIALIZER
17218 (struct cmd_tx_offload_get_configuration_result,
17220 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
17221 TOKEN_STRING_INITIALIZER
17222 (struct cmd_tx_offload_get_configuration_result,
17223 tx_offload, "tx_offload");
17224 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
17225 TOKEN_STRING_INITIALIZER
17226 (struct cmd_tx_offload_get_configuration_result,
17227 configuration, "configuration");
17230 cmd_tx_offload_get_configuration_parsed(
17231 void *parsed_result,
17232 __rte_unused struct cmdline *cl,
17233 __rte_unused void *data)
17235 struct cmd_tx_offload_get_configuration_result *res = parsed_result;
17236 struct rte_eth_dev_info dev_info;
17237 portid_t port_id = res->port_id;
17238 struct rte_port *port = &ports[port_id];
17239 uint64_t port_offloads;
17240 uint64_t queue_offloads;
17241 uint16_t nb_tx_queues;
17245 printf("Tx Offloading Configuration of port %d :\n", port_id);
17247 port_offloads = port->dev_conf.txmode.offloads;
17249 print_tx_offloads(port_offloads);
17252 ret = eth_dev_info_get_print_err(port_id, &dev_info);
17256 nb_tx_queues = dev_info.nb_tx_queues;
17257 for (q = 0; q < nb_tx_queues; q++) {
17258 queue_offloads = port->tx_conf[q].offloads;
17259 printf(" Queue[%2d] :", q);
17260 print_tx_offloads(queue_offloads);
17266 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
17267 .f = cmd_tx_offload_get_configuration_parsed,
17269 .help_str = "show port <port_id> tx_offload configuration",
17271 (void *)&cmd_tx_offload_get_configuration_show,
17272 (void *)&cmd_tx_offload_get_configuration_port,
17273 (void *)&cmd_tx_offload_get_configuration_port_id,
17274 (void *)&cmd_tx_offload_get_configuration_tx_offload,
17275 (void *)&cmd_tx_offload_get_configuration_configuration,
17280 /* Enable/Disable a per port offloading */
17281 struct cmd_config_per_port_tx_offload_result {
17282 cmdline_fixed_string_t port;
17283 cmdline_fixed_string_t config;
17285 cmdline_fixed_string_t tx_offload;
17286 cmdline_fixed_string_t offload;
17287 cmdline_fixed_string_t on_off;
17290 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
17291 TOKEN_STRING_INITIALIZER
17292 (struct cmd_config_per_port_tx_offload_result,
17294 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
17295 TOKEN_STRING_INITIALIZER
17296 (struct cmd_config_per_port_tx_offload_result,
17298 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
17299 TOKEN_NUM_INITIALIZER
17300 (struct cmd_config_per_port_tx_offload_result,
17302 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
17303 TOKEN_STRING_INITIALIZER
17304 (struct cmd_config_per_port_tx_offload_result,
17305 tx_offload, "tx_offload");
17306 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
17307 TOKEN_STRING_INITIALIZER
17308 (struct cmd_config_per_port_tx_offload_result,
17309 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
17310 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
17311 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
17312 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
17313 "mt_lockfree#multi_segs#mbuf_fast_free#security#"
17314 "send_on_timestamp");
17315 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
17316 TOKEN_STRING_INITIALIZER
17317 (struct cmd_config_per_port_tx_offload_result,
17321 search_tx_offload(const char *name)
17323 uint64_t single_offload;
17324 const char *single_name;
17328 single_offload = 1;
17329 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
17330 single_name = rte_eth_dev_tx_offload_name(single_offload);
17331 if (single_name == NULL)
17333 if (!strcasecmp(single_name, name)) {
17336 } else if (!strcasecmp(single_name, "UNKNOWN"))
17338 single_offload <<= 1;
17342 return single_offload;
17348 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
17349 __rte_unused struct cmdline *cl,
17350 __rte_unused void *data)
17352 struct cmd_config_per_port_tx_offload_result *res = parsed_result;
17353 portid_t port_id = res->port_id;
17354 struct rte_eth_dev_info dev_info;
17355 struct rte_port *port = &ports[port_id];
17356 uint64_t single_offload;
17357 uint16_t nb_tx_queues;
17361 if (port->port_status != RTE_PORT_STOPPED) {
17362 printf("Error: Can't config offload when Port %d "
17363 "is not stopped\n", port_id);
17367 single_offload = search_tx_offload(res->offload);
17368 if (single_offload == 0) {
17369 printf("Unknown offload name: %s\n", res->offload);
17373 ret = eth_dev_info_get_print_err(port_id, &dev_info);
17377 nb_tx_queues = dev_info.nb_tx_queues;
17378 if (!strcmp(res->on_off, "on")) {
17379 port->dev_conf.txmode.offloads |= single_offload;
17380 for (q = 0; q < nb_tx_queues; q++)
17381 port->tx_conf[q].offloads |= single_offload;
17383 port->dev_conf.txmode.offloads &= ~single_offload;
17384 for (q = 0; q < nb_tx_queues; q++)
17385 port->tx_conf[q].offloads &= ~single_offload;
17388 cmd_reconfig_device_queue(port_id, 1, 1);
17391 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
17392 .f = cmd_config_per_port_tx_offload_parsed,
17394 .help_str = "port config <port_id> tx_offload "
17395 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
17396 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
17397 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
17398 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
17399 "mt_lockfree|multi_segs|mbuf_fast_free|security|"
17400 "send_on_timestamp on|off",
17402 (void *)&cmd_config_per_port_tx_offload_result_port,
17403 (void *)&cmd_config_per_port_tx_offload_result_config,
17404 (void *)&cmd_config_per_port_tx_offload_result_port_id,
17405 (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
17406 (void *)&cmd_config_per_port_tx_offload_result_offload,
17407 (void *)&cmd_config_per_port_tx_offload_result_on_off,
17412 /* Enable/Disable a per queue offloading */
17413 struct cmd_config_per_queue_tx_offload_result {
17414 cmdline_fixed_string_t port;
17416 cmdline_fixed_string_t txq;
17418 cmdline_fixed_string_t tx_offload;
17419 cmdline_fixed_string_t offload;
17420 cmdline_fixed_string_t on_off;
17423 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
17424 TOKEN_STRING_INITIALIZER
17425 (struct cmd_config_per_queue_tx_offload_result,
17427 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
17428 TOKEN_NUM_INITIALIZER
17429 (struct cmd_config_per_queue_tx_offload_result,
17431 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
17432 TOKEN_STRING_INITIALIZER
17433 (struct cmd_config_per_queue_tx_offload_result,
17435 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
17436 TOKEN_NUM_INITIALIZER
17437 (struct cmd_config_per_queue_tx_offload_result,
17439 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
17440 TOKEN_STRING_INITIALIZER
17441 (struct cmd_config_per_queue_tx_offload_result,
17442 tx_offload, "tx_offload");
17443 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
17444 TOKEN_STRING_INITIALIZER
17445 (struct cmd_config_per_queue_tx_offload_result,
17446 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
17447 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
17448 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
17449 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
17450 "mt_lockfree#multi_segs#mbuf_fast_free#security");
17451 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
17452 TOKEN_STRING_INITIALIZER
17453 (struct cmd_config_per_queue_tx_offload_result,
17457 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
17458 __rte_unused struct cmdline *cl,
17459 __rte_unused void *data)
17461 struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
17462 struct rte_eth_dev_info dev_info;
17463 portid_t port_id = res->port_id;
17464 uint16_t queue_id = res->queue_id;
17465 struct rte_port *port = &ports[port_id];
17466 uint64_t single_offload;
17469 if (port->port_status != RTE_PORT_STOPPED) {
17470 printf("Error: Can't config offload when Port %d "
17471 "is not stopped\n", port_id);
17475 ret = eth_dev_info_get_print_err(port_id, &dev_info);
17479 if (queue_id >= dev_info.nb_tx_queues) {
17480 printf("Error: input queue_id should be 0 ... "
17481 "%d\n", dev_info.nb_tx_queues - 1);
17485 single_offload = search_tx_offload(res->offload);
17486 if (single_offload == 0) {
17487 printf("Unknown offload name: %s\n", res->offload);
17491 if (!strcmp(res->on_off, "on"))
17492 port->tx_conf[queue_id].offloads |= single_offload;
17494 port->tx_conf[queue_id].offloads &= ~single_offload;
17496 cmd_reconfig_device_queue(port_id, 1, 1);
17499 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
17500 .f = cmd_config_per_queue_tx_offload_parsed,
17502 .help_str = "port <port_id> txq <queue_id> tx_offload "
17503 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
17504 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
17505 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
17506 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
17507 "mt_lockfree|multi_segs|mbuf_fast_free|security "
17510 (void *)&cmd_config_per_queue_tx_offload_result_port,
17511 (void *)&cmd_config_per_queue_tx_offload_result_port_id,
17512 (void *)&cmd_config_per_queue_tx_offload_result_txq,
17513 (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
17514 (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
17515 (void *)&cmd_config_per_queue_tx_offload_result_offload,
17516 (void *)&cmd_config_per_queue_tx_offload_result_on_off,
17521 /* *** configure tx_metadata for specific port *** */
17522 struct cmd_config_tx_metadata_specific_result {
17523 cmdline_fixed_string_t port;
17524 cmdline_fixed_string_t keyword;
17526 cmdline_fixed_string_t item;
17531 cmd_config_tx_metadata_specific_parsed(void *parsed_result,
17532 __rte_unused struct cmdline *cl,
17533 __rte_unused void *data)
17535 struct cmd_config_tx_metadata_specific_result *res = parsed_result;
17537 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17539 ports[res->port_id].tx_metadata = res->value;
17540 /* Add/remove callback to insert valid metadata in every Tx packet. */
17541 if (ports[res->port_id].tx_metadata)
17542 add_tx_md_callback(res->port_id);
17544 remove_tx_md_callback(res->port_id);
17545 rte_flow_dynf_metadata_register();
17548 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
17549 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
17551 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
17552 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
17553 keyword, "config");
17554 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
17555 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
17557 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
17558 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
17559 item, "tx_metadata");
17560 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
17561 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
17564 cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
17565 .f = cmd_config_tx_metadata_specific_parsed,
17567 .help_str = "port config <port_id> tx_metadata <value>",
17569 (void *)&cmd_config_tx_metadata_specific_port,
17570 (void *)&cmd_config_tx_metadata_specific_keyword,
17571 (void *)&cmd_config_tx_metadata_specific_id,
17572 (void *)&cmd_config_tx_metadata_specific_item,
17573 (void *)&cmd_config_tx_metadata_specific_value,
17578 /* *** set dynf *** */
17579 struct cmd_config_tx_dynf_specific_result {
17580 cmdline_fixed_string_t port;
17581 cmdline_fixed_string_t keyword;
17583 cmdline_fixed_string_t item;
17584 cmdline_fixed_string_t name;
17585 cmdline_fixed_string_t value;
17589 cmd_config_dynf_specific_parsed(void *parsed_result,
17590 __rte_unused struct cmdline *cl,
17591 __rte_unused void *data)
17593 struct cmd_config_tx_dynf_specific_result *res = parsed_result;
17594 struct rte_mbuf_dynflag desc_flag;
17596 uint64_t old_port_flags;
17598 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17600 flag = rte_mbuf_dynflag_lookup(res->name, NULL);
17602 if (strlcpy(desc_flag.name, res->name,
17603 RTE_MBUF_DYN_NAMESIZE) >= RTE_MBUF_DYN_NAMESIZE) {
17604 printf("Flag name too long\n");
17607 desc_flag.flags = 0;
17608 flag = rte_mbuf_dynflag_register(&desc_flag);
17610 printf("Can't register flag\n");
17613 strcpy(dynf_names[flag], desc_flag.name);
17615 old_port_flags = ports[res->port_id].mbuf_dynf;
17616 if (!strcmp(res->value, "set")) {
17617 ports[res->port_id].mbuf_dynf |= 1UL << flag;
17618 if (old_port_flags == 0)
17619 add_tx_dynf_callback(res->port_id);
17621 ports[res->port_id].mbuf_dynf &= ~(1UL << flag);
17622 if (ports[res->port_id].mbuf_dynf == 0)
17623 remove_tx_dynf_callback(res->port_id);
17627 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_port =
17628 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
17630 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_keyword =
17631 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
17632 keyword, "config");
17633 cmdline_parse_token_num_t cmd_config_tx_dynf_specific_port_id =
17634 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
17636 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_item =
17637 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
17639 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_name =
17640 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
17642 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_value =
17643 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
17644 value, "set#clear");
17646 cmdline_parse_inst_t cmd_config_tx_dynf_specific = {
17647 .f = cmd_config_dynf_specific_parsed,
17649 .help_str = "port config <port id> dynf <name> set|clear",
17651 (void *)&cmd_config_tx_dynf_specific_port,
17652 (void *)&cmd_config_tx_dynf_specific_keyword,
17653 (void *)&cmd_config_tx_dynf_specific_port_id,
17654 (void *)&cmd_config_tx_dynf_specific_item,
17655 (void *)&cmd_config_tx_dynf_specific_name,
17656 (void *)&cmd_config_tx_dynf_specific_value,
17661 /* *** display tx_metadata per port configuration *** */
17662 struct cmd_show_tx_metadata_result {
17663 cmdline_fixed_string_t cmd_show;
17664 cmdline_fixed_string_t cmd_port;
17665 cmdline_fixed_string_t cmd_keyword;
17670 cmd_show_tx_metadata_parsed(void *parsed_result,
17671 __rte_unused struct cmdline *cl,
17672 __rte_unused void *data)
17674 struct cmd_show_tx_metadata_result *res = parsed_result;
17676 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17677 printf("invalid port id %u\n", res->cmd_pid);
17680 if (!strcmp(res->cmd_keyword, "tx_metadata")) {
17681 printf("Port %u tx_metadata: %u\n", res->cmd_pid,
17682 ports[res->cmd_pid].tx_metadata);
17686 cmdline_parse_token_string_t cmd_show_tx_metadata_show =
17687 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
17689 cmdline_parse_token_string_t cmd_show_tx_metadata_port =
17690 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
17692 cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
17693 TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
17695 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
17696 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
17697 cmd_keyword, "tx_metadata");
17699 cmdline_parse_inst_t cmd_show_tx_metadata = {
17700 .f = cmd_show_tx_metadata_parsed,
17702 .help_str = "show port <port_id> tx_metadata",
17704 (void *)&cmd_show_tx_metadata_show,
17705 (void *)&cmd_show_tx_metadata_port,
17706 (void *)&cmd_show_tx_metadata_pid,
17707 (void *)&cmd_show_tx_metadata_keyword,
17712 /* *** show fec capability per port configuration *** */
17713 struct cmd_show_fec_capability_result {
17714 cmdline_fixed_string_t cmd_show;
17715 cmdline_fixed_string_t cmd_port;
17716 cmdline_fixed_string_t cmd_fec;
17717 cmdline_fixed_string_t cmd_keyword;
17722 cmd_show_fec_capability_parsed(void *parsed_result,
17723 __rte_unused struct cmdline *cl,
17724 __rte_unused void *data)
17726 #define FEC_CAP_NUM 2
17727 struct cmd_show_fec_capability_result *res = parsed_result;
17728 struct rte_eth_fec_capa speed_fec_capa[FEC_CAP_NUM];
17729 unsigned int num = FEC_CAP_NUM;
17730 unsigned int ret_num;
17733 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17734 printf("Invalid port id %u\n", res->cmd_pid);
17738 ret = rte_eth_fec_get_capability(res->cmd_pid, speed_fec_capa, num);
17739 if (ret == -ENOTSUP) {
17740 printf("Function not implemented\n");
17742 } else if (ret < 0) {
17743 printf("Get FEC capability failed\n");
17747 ret_num = (unsigned int)ret;
17748 show_fec_capability(ret_num, speed_fec_capa);
17751 cmdline_parse_token_string_t cmd_show_fec_capability_show =
17752 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
17754 cmdline_parse_token_string_t cmd_show_fec_capability_port =
17755 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
17757 cmdline_parse_token_num_t cmd_show_fec_capability_pid =
17758 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_capability_result,
17760 cmdline_parse_token_string_t cmd_show_fec_capability_fec =
17761 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
17763 cmdline_parse_token_string_t cmd_show_fec_capability_keyword =
17764 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
17765 cmd_keyword, "capabilities");
17767 cmdline_parse_inst_t cmd_show_capability = {
17768 .f = cmd_show_fec_capability_parsed,
17770 .help_str = "show port <port_id> fec capabilities",
17772 (void *)&cmd_show_fec_capability_show,
17773 (void *)&cmd_show_fec_capability_port,
17774 (void *)&cmd_show_fec_capability_pid,
17775 (void *)&cmd_show_fec_capability_fec,
17776 (void *)&cmd_show_fec_capability_keyword,
17781 /* *** show fec mode per port configuration *** */
17782 struct cmd_show_fec_metadata_result {
17783 cmdline_fixed_string_t cmd_show;
17784 cmdline_fixed_string_t cmd_port;
17785 cmdline_fixed_string_t cmd_keyword;
17790 cmd_show_fec_mode_parsed(void *parsed_result,
17791 __rte_unused struct cmdline *cl,
17792 __rte_unused void *data)
17794 #define FEC_NAME_SIZE 16
17795 struct cmd_show_fec_metadata_result *res = parsed_result;
17797 char buf[FEC_NAME_SIZE];
17800 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17801 printf("Invalid port id %u\n", res->cmd_pid);
17804 ret = rte_eth_fec_get(res->cmd_pid, &mode);
17805 if (ret == -ENOTSUP) {
17806 printf("Function not implemented\n");
17808 } else if (ret < 0) {
17809 printf("Get FEC mode failed\n");
17814 case RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC):
17815 strlcpy(buf, "off", sizeof(buf));
17817 case RTE_ETH_FEC_MODE_CAPA_MASK(AUTO):
17818 strlcpy(buf, "auto", sizeof(buf));
17820 case RTE_ETH_FEC_MODE_CAPA_MASK(BASER):
17821 strlcpy(buf, "baser", sizeof(buf));
17823 case RTE_ETH_FEC_MODE_CAPA_MASK(RS):
17824 strlcpy(buf, "rs", sizeof(buf));
17830 printf("%s\n", buf);
17833 cmdline_parse_token_string_t cmd_show_fec_mode_show =
17834 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
17836 cmdline_parse_token_string_t cmd_show_fec_mode_port =
17837 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
17839 cmdline_parse_token_num_t cmd_show_fec_mode_pid =
17840 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_metadata_result,
17842 cmdline_parse_token_string_t cmd_show_fec_mode_keyword =
17843 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
17844 cmd_keyword, "fec_mode");
17846 cmdline_parse_inst_t cmd_show_fec_mode = {
17847 .f = cmd_show_fec_mode_parsed,
17849 .help_str = "show port <port_id> fec_mode",
17851 (void *)&cmd_show_fec_mode_show,
17852 (void *)&cmd_show_fec_mode_port,
17853 (void *)&cmd_show_fec_mode_pid,
17854 (void *)&cmd_show_fec_mode_keyword,
17859 /* *** set fec mode per port configuration *** */
17860 struct cmd_set_port_fec_mode {
17861 cmdline_fixed_string_t set;
17862 cmdline_fixed_string_t port;
17864 cmdline_fixed_string_t fec_mode;
17865 cmdline_fixed_string_t fec_value;
17868 /* Common CLI fields for set fec mode */
17869 cmdline_parse_token_string_t cmd_set_port_fec_mode_set =
17870 TOKEN_STRING_INITIALIZER
17871 (struct cmd_set_port_fec_mode,
17873 cmdline_parse_token_string_t cmd_set_port_fec_mode_port =
17874 TOKEN_STRING_INITIALIZER
17875 (struct cmd_set_port_fec_mode,
17877 cmdline_parse_token_num_t cmd_set_port_fec_mode_port_id =
17878 TOKEN_NUM_INITIALIZER
17879 (struct cmd_set_port_fec_mode,
17881 cmdline_parse_token_string_t cmd_set_port_fec_mode_str =
17882 TOKEN_STRING_INITIALIZER
17883 (struct cmd_set_port_fec_mode,
17884 fec_mode, "fec_mode");
17885 cmdline_parse_token_string_t cmd_set_port_fec_mode_value =
17886 TOKEN_STRING_INITIALIZER
17887 (struct cmd_set_port_fec_mode,
17891 cmd_set_port_fec_mode_parsed(
17892 void *parsed_result,
17893 __rte_unused struct cmdline *cl,
17894 __rte_unused void *data)
17896 struct cmd_set_port_fec_mode *res = parsed_result;
17897 uint16_t port_id = res->port_id;
17901 ret = parse_fec_mode(res->fec_value, &mode);
17903 printf("Unknown fec mode: %s for Port %d\n", res->fec_value,
17908 ret = rte_eth_fec_set(port_id, mode);
17909 if (ret == -ENOTSUP) {
17910 printf("Function not implemented\n");
17912 } else if (ret < 0) {
17913 printf("Set FEC mode failed\n");
17918 cmdline_parse_inst_t cmd_set_fec_mode = {
17919 .f = cmd_set_port_fec_mode_parsed,
17921 .help_str = "set port <port_id> fec_mode auto|off|rs|baser",
17923 (void *)&cmd_set_port_fec_mode_set,
17924 (void *)&cmd_set_port_fec_mode_port,
17925 (void *)&cmd_set_port_fec_mode_port_id,
17926 (void *)&cmd_set_port_fec_mode_str,
17927 (void *)&cmd_set_port_fec_mode_value,
17932 /* show port supported ptypes */
17934 /* Common result structure for show port ptypes */
17935 struct cmd_show_port_supported_ptypes_result {
17936 cmdline_fixed_string_t show;
17937 cmdline_fixed_string_t port;
17939 cmdline_fixed_string_t ptypes;
17942 /* Common CLI fields for show port ptypes */
17943 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =
17944 TOKEN_STRING_INITIALIZER
17945 (struct cmd_show_port_supported_ptypes_result,
17947 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
17948 TOKEN_STRING_INITIALIZER
17949 (struct cmd_show_port_supported_ptypes_result,
17951 cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =
17952 TOKEN_NUM_INITIALIZER
17953 (struct cmd_show_port_supported_ptypes_result,
17955 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =
17956 TOKEN_STRING_INITIALIZER
17957 (struct cmd_show_port_supported_ptypes_result,
17961 cmd_show_port_supported_ptypes_parsed(
17962 void *parsed_result,
17963 __rte_unused struct cmdline *cl,
17964 __rte_unused void *data)
17966 #define RSVD_PTYPE_MASK 0xf0000000
17967 #define MAX_PTYPES_PER_LAYER 16
17968 #define LTYPE_NAMESIZE 32
17969 #define PTYPE_NAMESIZE 256
17970 struct cmd_show_port_supported_ptypes_result *res = parsed_result;
17971 char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE];
17972 uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
17973 uint32_t ptypes[MAX_PTYPES_PER_LAYER];
17974 uint16_t port_id = res->port_id;
17977 ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0);
17981 while (ptype_mask != RSVD_PTYPE_MASK) {
17983 switch (ptype_mask) {
17984 case RTE_PTYPE_L2_MASK:
17985 strlcpy(ltype, "L2", sizeof(ltype));
17987 case RTE_PTYPE_L3_MASK:
17988 strlcpy(ltype, "L3", sizeof(ltype));
17990 case RTE_PTYPE_L4_MASK:
17991 strlcpy(ltype, "L4", sizeof(ltype));
17993 case RTE_PTYPE_TUNNEL_MASK:
17994 strlcpy(ltype, "Tunnel", sizeof(ltype));
17996 case RTE_PTYPE_INNER_L2_MASK:
17997 strlcpy(ltype, "Inner L2", sizeof(ltype));
17999 case RTE_PTYPE_INNER_L3_MASK:
18000 strlcpy(ltype, "Inner L3", sizeof(ltype));
18002 case RTE_PTYPE_INNER_L4_MASK:
18003 strlcpy(ltype, "Inner L4", sizeof(ltype));
18009 ret = rte_eth_dev_get_supported_ptypes(res->port_id,
18010 ptype_mask, ptypes,
18011 MAX_PTYPES_PER_LAYER);
18014 printf("Supported %s ptypes:\n", ltype);
18016 printf("%s ptypes unsupported\n", ltype);
18018 for (i = 0; i < ret; ++i) {
18019 rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
18020 printf("%s\n", buf);
18027 cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
18028 .f = cmd_show_port_supported_ptypes_parsed,
18030 .help_str = "show port <port_id> ptypes",
18032 (void *)&cmd_show_port_supported_ptypes_show,
18033 (void *)&cmd_show_port_supported_ptypes_port,
18034 (void *)&cmd_show_port_supported_ptypes_port_id,
18035 (void *)&cmd_show_port_supported_ptypes_ptypes,
18040 /* *** display rx/tx descriptor status *** */
18041 struct cmd_show_rx_tx_desc_status_result {
18042 cmdline_fixed_string_t cmd_show;
18043 cmdline_fixed_string_t cmd_port;
18044 cmdline_fixed_string_t cmd_keyword;
18045 cmdline_fixed_string_t cmd_desc;
18046 cmdline_fixed_string_t cmd_status;
18053 cmd_show_rx_tx_desc_status_parsed(void *parsed_result,
18054 __rte_unused struct cmdline *cl,
18055 __rte_unused void *data)
18057 struct cmd_show_rx_tx_desc_status_result *res = parsed_result;
18060 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
18061 printf("invalid port id %u\n", res->cmd_pid);
18065 if (!strcmp(res->cmd_keyword, "rxq")) {
18066 rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid,
18069 printf("Invalid queueid = %d\n", res->cmd_qid);
18072 if (rc == RTE_ETH_RX_DESC_AVAIL)
18073 printf("Desc status = AVAILABLE\n");
18074 else if (rc == RTE_ETH_RX_DESC_DONE)
18075 printf("Desc status = DONE\n");
18077 printf("Desc status = UNAVAILABLE\n");
18078 } else if (!strcmp(res->cmd_keyword, "txq")) {
18079 rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid,
18082 printf("Invalid queueid = %d\n", res->cmd_qid);
18085 if (rc == RTE_ETH_TX_DESC_FULL)
18086 printf("Desc status = FULL\n");
18087 else if (rc == RTE_ETH_TX_DESC_DONE)
18088 printf("Desc status = DONE\n");
18090 printf("Desc status = UNAVAILABLE\n");
18094 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show =
18095 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
18097 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port =
18098 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
18100 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid =
18101 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
18103 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword =
18104 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
18105 cmd_keyword, "rxq#txq");
18106 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid =
18107 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
18109 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc =
18110 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
18112 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did =
18113 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
18115 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status =
18116 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
18117 cmd_status, "status");
18118 cmdline_parse_inst_t cmd_show_rx_tx_desc_status = {
18119 .f = cmd_show_rx_tx_desc_status_parsed,
18121 .help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> "
18124 (void *)&cmd_show_rx_tx_desc_status_show,
18125 (void *)&cmd_show_rx_tx_desc_status_port,
18126 (void *)&cmd_show_rx_tx_desc_status_pid,
18127 (void *)&cmd_show_rx_tx_desc_status_keyword,
18128 (void *)&cmd_show_rx_tx_desc_status_qid,
18129 (void *)&cmd_show_rx_tx_desc_status_desc,
18130 (void *)&cmd_show_rx_tx_desc_status_did,
18131 (void *)&cmd_show_rx_tx_desc_status_status,
18136 /* Common result structure for set port ptypes */
18137 struct cmd_set_port_ptypes_result {
18138 cmdline_fixed_string_t set;
18139 cmdline_fixed_string_t port;
18141 cmdline_fixed_string_t ptype_mask;
18145 /* Common CLI fields for set port ptypes */
18146 cmdline_parse_token_string_t cmd_set_port_ptypes_set =
18147 TOKEN_STRING_INITIALIZER
18148 (struct cmd_set_port_ptypes_result,
18150 cmdline_parse_token_string_t cmd_set_port_ptypes_port =
18151 TOKEN_STRING_INITIALIZER
18152 (struct cmd_set_port_ptypes_result,
18154 cmdline_parse_token_num_t cmd_set_port_ptypes_port_id =
18155 TOKEN_NUM_INITIALIZER
18156 (struct cmd_set_port_ptypes_result,
18158 cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str =
18159 TOKEN_STRING_INITIALIZER
18160 (struct cmd_set_port_ptypes_result,
18161 ptype_mask, "ptype_mask");
18162 cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 =
18163 TOKEN_NUM_INITIALIZER
18164 (struct cmd_set_port_ptypes_result,
18168 cmd_set_port_ptypes_parsed(
18169 void *parsed_result,
18170 __rte_unused struct cmdline *cl,
18171 __rte_unused void *data)
18173 struct cmd_set_port_ptypes_result *res = parsed_result;
18174 #define PTYPE_NAMESIZE 256
18175 char ptype_name[PTYPE_NAMESIZE];
18176 uint16_t port_id = res->port_id;
18177 uint32_t ptype_mask = res->mask;
18180 ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK,
18183 printf("Port %d doesn't support any ptypes.\n", port_id);
18187 uint32_t ptypes[ret];
18189 ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret);
18191 printf("Unable to set requested ptypes for Port %d\n", port_id);
18195 printf("Successfully set following ptypes for Port %d\n", port_id);
18196 for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) {
18197 rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name));
18198 printf("%s\n", ptype_name);
18201 clear_ptypes = false;
18204 cmdline_parse_inst_t cmd_set_port_ptypes = {
18205 .f = cmd_set_port_ptypes_parsed,
18207 .help_str = "set port <port_id> ptype_mask <mask>",
18209 (void *)&cmd_set_port_ptypes_set,
18210 (void *)&cmd_set_port_ptypes_port,
18211 (void *)&cmd_set_port_ptypes_port_id,
18212 (void *)&cmd_set_port_ptypes_mask_str,
18213 (void *)&cmd_set_port_ptypes_mask_u32,
18218 /* *** display mac addresses added to a port *** */
18219 struct cmd_showport_macs_result {
18220 cmdline_fixed_string_t cmd_show;
18221 cmdline_fixed_string_t cmd_port;
18222 cmdline_fixed_string_t cmd_keyword;
18227 cmd_showport_macs_parsed(void *parsed_result,
18228 __rte_unused struct cmdline *cl,
18229 __rte_unused void *data)
18231 struct cmd_showport_macs_result *res = parsed_result;
18233 if (port_id_is_invalid(res->cmd_pid, ENABLED_WARN))
18236 if (!strcmp(res->cmd_keyword, "macs"))
18237 show_macs(res->cmd_pid);
18238 else if (!strcmp(res->cmd_keyword, "mcast_macs"))
18239 show_mcast_macs(res->cmd_pid);
18242 cmdline_parse_token_string_t cmd_showport_macs_show =
18243 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
18245 cmdline_parse_token_string_t cmd_showport_macs_port =
18246 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
18248 cmdline_parse_token_num_t cmd_showport_macs_pid =
18249 TOKEN_NUM_INITIALIZER(struct cmd_showport_macs_result,
18251 cmdline_parse_token_string_t cmd_showport_macs_keyword =
18252 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
18253 cmd_keyword, "macs#mcast_macs");
18255 cmdline_parse_inst_t cmd_showport_macs = {
18256 .f = cmd_showport_macs_parsed,
18258 .help_str = "show port <port_id> macs|mcast_macs",
18260 (void *)&cmd_showport_macs_show,
18261 (void *)&cmd_showport_macs_port,
18262 (void *)&cmd_showport_macs_pid,
18263 (void *)&cmd_showport_macs_keyword,
18268 /* ******************************************************************************** */
18270 /* list of instructions */
18271 cmdline_parse_ctx_t main_ctx[] = {
18272 (cmdline_parse_inst_t *)&cmd_help_brief,
18273 (cmdline_parse_inst_t *)&cmd_help_long,
18274 (cmdline_parse_inst_t *)&cmd_quit,
18275 (cmdline_parse_inst_t *)&cmd_load_from_file,
18276 (cmdline_parse_inst_t *)&cmd_showport,
18277 (cmdline_parse_inst_t *)&cmd_showqueue,
18278 (cmdline_parse_inst_t *)&cmd_showeeprom,
18279 (cmdline_parse_inst_t *)&cmd_showportall,
18280 (cmdline_parse_inst_t *)&cmd_showdevice,
18281 (cmdline_parse_inst_t *)&cmd_showcfg,
18282 (cmdline_parse_inst_t *)&cmd_showfwdall,
18283 (cmdline_parse_inst_t *)&cmd_start,
18284 (cmdline_parse_inst_t *)&cmd_start_tx_first,
18285 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
18286 (cmdline_parse_inst_t *)&cmd_set_link_up,
18287 (cmdline_parse_inst_t *)&cmd_set_link_down,
18288 (cmdline_parse_inst_t *)&cmd_reset,
18289 (cmdline_parse_inst_t *)&cmd_set_numbers,
18290 (cmdline_parse_inst_t *)&cmd_set_log,
18291 (cmdline_parse_inst_t *)&cmd_set_rxoffs,
18292 (cmdline_parse_inst_t *)&cmd_set_rxpkts,
18293 (cmdline_parse_inst_t *)&cmd_set_txpkts,
18294 (cmdline_parse_inst_t *)&cmd_set_txsplit,
18295 (cmdline_parse_inst_t *)&cmd_set_txtimes,
18296 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
18297 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
18298 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
18299 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
18300 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
18301 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
18302 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
18303 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
18304 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
18305 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
18306 (cmdline_parse_inst_t *)&cmd_set_link_check,
18307 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
18308 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
18309 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
18310 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
18311 #ifdef RTE_NET_BOND
18312 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
18313 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
18314 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
18315 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
18316 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
18317 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
18318 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
18319 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
18320 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
18321 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
18322 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
18324 (cmdline_parse_inst_t *)&cmd_vlan_offload,
18325 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
18326 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
18327 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
18328 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
18329 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
18330 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
18331 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
18332 (cmdline_parse_inst_t *)&cmd_csum_set,
18333 (cmdline_parse_inst_t *)&cmd_csum_show,
18334 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
18335 (cmdline_parse_inst_t *)&cmd_tso_set,
18336 (cmdline_parse_inst_t *)&cmd_tso_show,
18337 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
18338 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
18339 (cmdline_parse_inst_t *)&cmd_gro_enable,
18340 (cmdline_parse_inst_t *)&cmd_gro_flush,
18341 (cmdline_parse_inst_t *)&cmd_gro_show,
18342 (cmdline_parse_inst_t *)&cmd_gso_enable,
18343 (cmdline_parse_inst_t *)&cmd_gso_size,
18344 (cmdline_parse_inst_t *)&cmd_gso_show,
18345 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
18346 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
18347 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
18348 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
18349 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
18350 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
18351 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
18352 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
18353 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
18354 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
18355 (cmdline_parse_inst_t *)&cmd_config_dcb,
18356 (cmdline_parse_inst_t *)&cmd_read_reg,
18357 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
18358 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
18359 (cmdline_parse_inst_t *)&cmd_write_reg,
18360 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
18361 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
18362 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
18363 (cmdline_parse_inst_t *)&cmd_stop,
18364 (cmdline_parse_inst_t *)&cmd_mac_addr,
18365 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
18366 (cmdline_parse_inst_t *)&cmd_set_qmap,
18367 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
18368 (cmdline_parse_inst_t *)&cmd_set_record_core_cycles,
18369 (cmdline_parse_inst_t *)&cmd_set_record_burst_stats,
18370 (cmdline_parse_inst_t *)&cmd_operate_port,
18371 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
18372 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
18373 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
18374 (cmdline_parse_inst_t *)&cmd_operate_detach_device,
18375 (cmdline_parse_inst_t *)&cmd_set_port_setup_on,
18376 (cmdline_parse_inst_t *)&cmd_config_speed_all,
18377 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
18378 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
18379 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
18380 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
18381 (cmdline_parse_inst_t *)&cmd_config_mtu,
18382 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
18383 (cmdline_parse_inst_t *)&cmd_config_max_lro_pkt_size,
18384 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
18385 (cmdline_parse_inst_t *)&cmd_config_rss,
18386 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
18387 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
18388 (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
18389 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
18390 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
18391 (cmdline_parse_inst_t *)&cmd_showport_reta,
18392 (cmdline_parse_inst_t *)&cmd_showport_macs,
18393 (cmdline_parse_inst_t *)&cmd_config_burst,
18394 (cmdline_parse_inst_t *)&cmd_config_thresh,
18395 (cmdline_parse_inst_t *)&cmd_config_threshold,
18396 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
18397 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
18398 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
18399 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
18400 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
18401 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
18402 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
18403 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
18404 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
18405 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
18406 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
18407 (cmdline_parse_inst_t *)&cmd_dump,
18408 (cmdline_parse_inst_t *)&cmd_dump_one,
18409 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
18410 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
18411 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
18412 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
18413 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
18414 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
18415 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
18416 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
18417 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
18418 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
18419 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
18420 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
18421 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
18422 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
18423 (cmdline_parse_inst_t *)&cmd_flow,
18424 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
18425 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
18426 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
18427 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
18428 (cmdline_parse_inst_t *)&cmd_create_port_meter,
18429 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
18430 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
18431 (cmdline_parse_inst_t *)&cmd_del_port_meter,
18432 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
18433 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
18434 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
18435 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
18436 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
18437 (cmdline_parse_inst_t *)&cmd_mcast_addr,
18438 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
18439 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
18440 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
18441 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
18442 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
18443 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
18444 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
18445 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
18446 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
18447 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
18448 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
18449 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
18450 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
18451 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
18452 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
18453 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
18454 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
18455 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
18456 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
18457 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
18458 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
18459 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
18460 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
18461 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
18462 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
18463 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
18464 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
18465 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
18466 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
18467 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
18468 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
18469 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
18470 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
18471 (cmdline_parse_inst_t *)&cmd_set_vxlan,
18472 (cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl,
18473 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
18474 (cmdline_parse_inst_t *)&cmd_set_nvgre,
18475 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
18476 (cmdline_parse_inst_t *)&cmd_set_l2_encap,
18477 (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
18478 (cmdline_parse_inst_t *)&cmd_set_l2_decap,
18479 (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
18480 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
18481 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
18482 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
18483 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
18484 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
18485 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
18486 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
18487 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
18488 (cmdline_parse_inst_t *)&cmd_ddp_add,
18489 (cmdline_parse_inst_t *)&cmd_ddp_del,
18490 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
18491 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
18492 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
18493 (cmdline_parse_inst_t *)&cmd_clear_input_set,
18494 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
18495 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
18496 (cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes,
18497 (cmdline_parse_inst_t *)&cmd_set_port_ptypes,
18498 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
18499 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
18500 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
18501 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
18503 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
18504 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
18505 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
18506 (cmdline_parse_inst_t *)&cmd_queue_region,
18507 (cmdline_parse_inst_t *)&cmd_region_flowtype,
18508 (cmdline_parse_inst_t *)&cmd_user_priority_region,
18509 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
18510 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
18511 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
18512 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
18513 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
18514 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
18515 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
18516 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
18517 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
18518 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
18519 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
18520 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
18521 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
18522 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
18523 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
18524 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node_pmode,
18525 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
18526 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
18527 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
18528 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
18529 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
18530 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
18531 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
18532 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
18533 (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
18534 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
18535 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
18536 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
18537 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
18538 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
18539 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
18540 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
18541 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
18542 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
18544 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
18545 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
18547 (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
18548 (cmdline_parse_inst_t *)&cmd_show_tx_metadata,
18549 (cmdline_parse_inst_t *)&cmd_show_rx_tx_desc_status,
18550 (cmdline_parse_inst_t *)&cmd_set_raw,
18551 (cmdline_parse_inst_t *)&cmd_show_set_raw,
18552 (cmdline_parse_inst_t *)&cmd_show_set_raw_all,
18553 (cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific,
18554 (cmdline_parse_inst_t *)&cmd_show_fec_mode,
18555 (cmdline_parse_inst_t *)&cmd_set_fec_mode,
18556 (cmdline_parse_inst_t *)&cmd_show_capability,
18560 /* read cmdline commands from file */
18562 cmdline_read_from_file(const char *filename)
18564 struct cmdline *cl;
18566 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
18568 printf("Failed to create file based cmdline context: %s\n",
18573 cmdline_interact(cl);
18578 printf("Read CLI commands from %s\n", filename);
18581 /* prompt function, called from main on MAIN lcore */
18585 /* initialize non-constant commands */
18586 cmd_set_fwd_mode_init();
18587 cmd_set_fwd_retry_mode_init();
18589 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
18590 if (testpmd_cl == NULL)
18592 cmdline_interact(testpmd_cl);
18593 cmdline_stdin_exit(testpmd_cl);
18599 if (testpmd_cl != NULL)
18600 cmdline_quit(testpmd_cl);
18604 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
18606 if (id == (portid_t)RTE_PORT_ALL) {
18609 RTE_ETH_FOREACH_DEV(pid) {
18610 /* check if need_reconfig has been set to 1 */
18611 if (ports[pid].need_reconfig == 0)
18612 ports[pid].need_reconfig = dev;
18613 /* check if need_reconfig_queues has been set to 1 */
18614 if (ports[pid].need_reconfig_queues == 0)
18615 ports[pid].need_reconfig_queues = queue;
18617 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
18618 /* check if need_reconfig has been set to 1 */
18619 if (ports[id].need_reconfig == 0)
18620 ports[id].need_reconfig = dev;
18621 /* check if need_reconfig_queues has been set to 1 */
18622 if (ports[id].need_reconfig_queues == 0)
18623 ports[id].need_reconfig_queues = queue;