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 /* *** GLOBAL CONFIG *** */
9299 struct cmd_global_config_result {
9300 cmdline_fixed_string_t cmd;
9302 cmdline_fixed_string_t cfg_type;
9307 cmd_global_config_parsed(void *parsed_result,
9308 __rte_unused struct cmdline *cl,
9309 __rte_unused void *data)
9311 struct cmd_global_config_result *res = parsed_result;
9312 struct rte_eth_global_cfg conf;
9315 memset(&conf, 0, sizeof(conf));
9316 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
9317 conf.cfg.gre_key_len = res->len;
9318 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
9319 RTE_ETH_FILTER_SET, &conf);
9321 if (ret == -ENOTSUP)
9322 ret = rte_pmd_i40e_set_gre_key_len(res->port_id, res->len);
9325 printf("Global config error\n");
9328 cmdline_parse_token_string_t cmd_global_config_cmd =
9329 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
9331 cmdline_parse_token_num_t cmd_global_config_port_id =
9332 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id,
9334 cmdline_parse_token_string_t cmd_global_config_type =
9335 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
9336 cfg_type, "gre-key-len");
9337 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
9338 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
9341 cmdline_parse_inst_t cmd_global_config = {
9342 .f = cmd_global_config_parsed,
9343 .data = (void *)NULL,
9344 .help_str = "global_config <port_id> gre-key-len <key_len>",
9346 (void *)&cmd_global_config_cmd,
9347 (void *)&cmd_global_config_port_id,
9348 (void *)&cmd_global_config_type,
9349 (void *)&cmd_global_config_gre_key_len,
9354 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
9355 struct cmd_set_mirror_mask_result {
9356 cmdline_fixed_string_t set;
9357 cmdline_fixed_string_t port;
9359 cmdline_fixed_string_t mirror;
9361 cmdline_fixed_string_t what;
9362 cmdline_fixed_string_t value;
9363 cmdline_fixed_string_t dstpool;
9365 cmdline_fixed_string_t on;
9368 cmdline_parse_token_string_t cmd_mirror_mask_set =
9369 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9371 cmdline_parse_token_string_t cmd_mirror_mask_port =
9372 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9374 cmdline_parse_token_num_t cmd_mirror_mask_portid =
9375 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9377 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
9378 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9379 mirror, "mirror-rule");
9380 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
9381 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9383 cmdline_parse_token_string_t cmd_mirror_mask_what =
9384 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9385 what, "pool-mirror-up#pool-mirror-down"
9387 cmdline_parse_token_string_t cmd_mirror_mask_value =
9388 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9390 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
9391 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9392 dstpool, "dst-pool");
9393 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
9394 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9396 cmdline_parse_token_string_t cmd_mirror_mask_on =
9397 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9401 cmd_set_mirror_mask_parsed(void *parsed_result,
9402 __rte_unused struct cmdline *cl,
9403 __rte_unused void *data)
9406 struct cmd_set_mirror_mask_result *res = parsed_result;
9407 struct rte_eth_mirror_conf mr_conf;
9409 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9411 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
9413 mr_conf.dst_pool = res->dstpool_id;
9415 if (!strcmp(res->what, "pool-mirror-up")) {
9416 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9417 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
9418 } else if (!strcmp(res->what, "pool-mirror-down")) {
9419 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9420 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
9421 } else if (!strcmp(res->what, "vlan-mirror")) {
9422 mr_conf.rule_type = ETH_MIRROR_VLAN;
9423 nb_item = parse_item_list(res->value, "vlan",
9424 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
9428 for (i = 0; i < nb_item; i++) {
9429 if (vlan_list[i] > RTE_ETHER_MAX_VLAN_ID) {
9430 printf("Invalid vlan_id: must be < 4096\n");
9434 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
9435 mr_conf.vlan.vlan_mask |= 1ULL << i;
9439 if (!strcmp(res->on, "on"))
9440 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9443 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9446 printf("mirror rule add error: (%s)\n", strerror(-ret));
9449 cmdline_parse_inst_t cmd_set_mirror_mask = {
9450 .f = cmd_set_mirror_mask_parsed,
9452 .help_str = "set port <port_id> mirror-rule <rule_id> "
9453 "pool-mirror-up|pool-mirror-down|vlan-mirror "
9454 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
9456 (void *)&cmd_mirror_mask_set,
9457 (void *)&cmd_mirror_mask_port,
9458 (void *)&cmd_mirror_mask_portid,
9459 (void *)&cmd_mirror_mask_mirror,
9460 (void *)&cmd_mirror_mask_ruleid,
9461 (void *)&cmd_mirror_mask_what,
9462 (void *)&cmd_mirror_mask_value,
9463 (void *)&cmd_mirror_mask_dstpool,
9464 (void *)&cmd_mirror_mask_poolid,
9465 (void *)&cmd_mirror_mask_on,
9470 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
9471 struct cmd_set_mirror_link_result {
9472 cmdline_fixed_string_t set;
9473 cmdline_fixed_string_t port;
9475 cmdline_fixed_string_t mirror;
9477 cmdline_fixed_string_t what;
9478 cmdline_fixed_string_t dstpool;
9480 cmdline_fixed_string_t on;
9483 cmdline_parse_token_string_t cmd_mirror_link_set =
9484 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9486 cmdline_parse_token_string_t cmd_mirror_link_port =
9487 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9489 cmdline_parse_token_num_t cmd_mirror_link_portid =
9490 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9492 cmdline_parse_token_string_t cmd_mirror_link_mirror =
9493 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9494 mirror, "mirror-rule");
9495 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
9496 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9498 cmdline_parse_token_string_t cmd_mirror_link_what =
9499 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9500 what, "uplink-mirror#downlink-mirror");
9501 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
9502 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9503 dstpool, "dst-pool");
9504 cmdline_parse_token_num_t cmd_mirror_link_poolid =
9505 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9507 cmdline_parse_token_string_t cmd_mirror_link_on =
9508 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9512 cmd_set_mirror_link_parsed(void *parsed_result,
9513 __rte_unused struct cmdline *cl,
9514 __rte_unused void *data)
9517 struct cmd_set_mirror_link_result *res = parsed_result;
9518 struct rte_eth_mirror_conf mr_conf;
9520 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9521 if (!strcmp(res->what, "uplink-mirror"))
9522 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
9524 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
9526 mr_conf.dst_pool = res->dstpool_id;
9528 if (!strcmp(res->on, "on"))
9529 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9532 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9535 /* check the return value and print it if is < 0 */
9537 printf("mirror rule add error: (%s)\n", strerror(-ret));
9541 cmdline_parse_inst_t cmd_set_mirror_link = {
9542 .f = cmd_set_mirror_link_parsed,
9544 .help_str = "set port <port_id> mirror-rule <rule_id> "
9545 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
9547 (void *)&cmd_mirror_link_set,
9548 (void *)&cmd_mirror_link_port,
9549 (void *)&cmd_mirror_link_portid,
9550 (void *)&cmd_mirror_link_mirror,
9551 (void *)&cmd_mirror_link_ruleid,
9552 (void *)&cmd_mirror_link_what,
9553 (void *)&cmd_mirror_link_dstpool,
9554 (void *)&cmd_mirror_link_poolid,
9555 (void *)&cmd_mirror_link_on,
9560 /* *** RESET VM MIRROR RULE *** */
9561 struct cmd_rm_mirror_rule_result {
9562 cmdline_fixed_string_t reset;
9563 cmdline_fixed_string_t port;
9565 cmdline_fixed_string_t mirror;
9569 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
9570 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9572 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
9573 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9575 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
9576 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9578 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
9579 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9580 mirror, "mirror-rule");
9581 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
9582 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9586 cmd_reset_mirror_rule_parsed(void *parsed_result,
9587 __rte_unused struct cmdline *cl,
9588 __rte_unused void *data)
9591 struct cmd_set_mirror_link_result *res = parsed_result;
9593 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
9595 printf("mirror rule remove error: (%s)\n", strerror(-ret));
9598 cmdline_parse_inst_t cmd_reset_mirror_rule = {
9599 .f = cmd_reset_mirror_rule_parsed,
9601 .help_str = "reset port <port_id> mirror-rule <rule_id>",
9603 (void *)&cmd_rm_mirror_rule_reset,
9604 (void *)&cmd_rm_mirror_rule_port,
9605 (void *)&cmd_rm_mirror_rule_portid,
9606 (void *)&cmd_rm_mirror_rule_mirror,
9607 (void *)&cmd_rm_mirror_rule_ruleid,
9612 /* ******************************************************************************** */
9614 struct cmd_dump_result {
9615 cmdline_fixed_string_t dump;
9619 dump_struct_sizes(void)
9621 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9622 DUMP_SIZE(struct rte_mbuf);
9623 DUMP_SIZE(struct rte_mempool);
9624 DUMP_SIZE(struct rte_ring);
9629 /* Dump the socket memory statistics on console */
9631 dump_socket_mem(FILE *f)
9633 struct rte_malloc_socket_stats socket_stats;
9638 unsigned int n_alloc = 0;
9639 unsigned int n_free = 0;
9640 static size_t last_allocs;
9641 static size_t last_total;
9644 for (i = 0; i < RTE_MAX_NUMA_NODES; i++) {
9645 if (rte_malloc_get_socket_stats(i, &socket_stats) ||
9646 !socket_stats.heap_totalsz_bytes)
9648 total += socket_stats.heap_totalsz_bytes;
9649 alloc += socket_stats.heap_allocsz_bytes;
9650 free += socket_stats.heap_freesz_bytes;
9651 n_alloc += socket_stats.alloc_count;
9652 n_free += socket_stats.free_count;
9654 "Socket %u: size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9656 (double)socket_stats.heap_totalsz_bytes / (1024 * 1024),
9657 (double)socket_stats.heap_allocsz_bytes / (1024 * 1024),
9658 (double)socket_stats.heap_allocsz_bytes * 100 /
9659 (double)socket_stats.heap_totalsz_bytes,
9660 (double)socket_stats.heap_freesz_bytes / (1024 * 1024),
9661 socket_stats.alloc_count,
9662 socket_stats.free_count);
9665 "Total : size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9666 (double)total / (1024 * 1024), (double)alloc / (1024 * 1024),
9667 (double)alloc * 100 / (double)total,
9668 (double)free / (1024 * 1024),
9671 fprintf(stdout, "Memory total change: %.6lf(M), allocation change: %.6lf(M)\n",
9672 ((double)total - (double)last_total) / (1024 * 1024),
9673 (double)(alloc - (double)last_allocs) / 1024 / 1024);
9674 last_allocs = alloc;
9678 static void cmd_dump_parsed(void *parsed_result,
9679 __rte_unused struct cmdline *cl,
9680 __rte_unused void *data)
9682 struct cmd_dump_result *res = parsed_result;
9684 if (!strcmp(res->dump, "dump_physmem"))
9685 rte_dump_physmem_layout(stdout);
9686 else if (!strcmp(res->dump, "dump_socket_mem"))
9687 dump_socket_mem(stdout);
9688 else if (!strcmp(res->dump, "dump_memzone"))
9689 rte_memzone_dump(stdout);
9690 else if (!strcmp(res->dump, "dump_struct_sizes"))
9691 dump_struct_sizes();
9692 else if (!strcmp(res->dump, "dump_ring"))
9693 rte_ring_list_dump(stdout);
9694 else if (!strcmp(res->dump, "dump_mempool"))
9695 rte_mempool_list_dump(stdout);
9696 else if (!strcmp(res->dump, "dump_devargs"))
9697 rte_devargs_dump(stdout);
9698 else if (!strcmp(res->dump, "dump_log_types"))
9699 rte_log_dump(stdout);
9702 cmdline_parse_token_string_t cmd_dump_dump =
9703 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9707 "dump_struct_sizes#"
9713 cmdline_parse_inst_t cmd_dump = {
9714 .f = cmd_dump_parsed, /* function to call */
9715 .data = NULL, /* 2nd arg of func */
9716 .help_str = "Dump status",
9717 .tokens = { /* token list, NULL terminated */
9718 (void *)&cmd_dump_dump,
9723 /* ******************************************************************************** */
9725 struct cmd_dump_one_result {
9726 cmdline_fixed_string_t dump;
9727 cmdline_fixed_string_t name;
9730 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9731 __rte_unused void *data)
9733 struct cmd_dump_one_result *res = parsed_result;
9735 if (!strcmp(res->dump, "dump_ring")) {
9737 r = rte_ring_lookup(res->name);
9739 cmdline_printf(cl, "Cannot find ring\n");
9742 rte_ring_dump(stdout, r);
9743 } else if (!strcmp(res->dump, "dump_mempool")) {
9744 struct rte_mempool *mp;
9745 mp = rte_mempool_lookup(res->name);
9747 cmdline_printf(cl, "Cannot find mempool\n");
9750 rte_mempool_dump(stdout, mp);
9754 cmdline_parse_token_string_t cmd_dump_one_dump =
9755 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9756 "dump_ring#dump_mempool");
9758 cmdline_parse_token_string_t cmd_dump_one_name =
9759 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9761 cmdline_parse_inst_t cmd_dump_one = {
9762 .f = cmd_dump_one_parsed, /* function to call */
9763 .data = NULL, /* 2nd arg of func */
9764 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9765 .tokens = { /* token list, NULL terminated */
9766 (void *)&cmd_dump_one_dump,
9767 (void *)&cmd_dump_one_name,
9772 /* *** queue region set *** */
9773 struct cmd_queue_region_result {
9774 cmdline_fixed_string_t set;
9775 cmdline_fixed_string_t port;
9777 cmdline_fixed_string_t cmd;
9778 cmdline_fixed_string_t region;
9780 cmdline_fixed_string_t queue_start_index;
9782 cmdline_fixed_string_t queue_num;
9783 uint8_t queue_num_value;
9787 cmd_queue_region_parsed(void *parsed_result,
9788 __rte_unused struct cmdline *cl,
9789 __rte_unused void *data)
9791 struct cmd_queue_region_result *res = parsed_result;
9794 struct rte_pmd_i40e_queue_region_conf region_conf;
9795 enum rte_pmd_i40e_queue_region_op op_type;
9798 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9802 memset(®ion_conf, 0, sizeof(region_conf));
9803 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
9804 region_conf.region_id = res->region_id;
9805 region_conf.queue_num = res->queue_num_value;
9806 region_conf.queue_start_index = res->queue_id;
9808 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9809 op_type, ®ion_conf);
9816 printf("function not implemented or supported\n");
9819 printf("queue region config error: (%s)\n", strerror(-ret));
9823 cmdline_parse_token_string_t cmd_queue_region_set =
9824 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9826 cmdline_parse_token_string_t cmd_queue_region_port =
9827 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
9828 cmdline_parse_token_num_t cmd_queue_region_port_id =
9829 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9831 cmdline_parse_token_string_t cmd_queue_region_cmd =
9832 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9833 cmd, "queue-region");
9834 cmdline_parse_token_string_t cmd_queue_region_id =
9835 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9836 region, "region_id");
9837 cmdline_parse_token_num_t cmd_queue_region_index =
9838 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9840 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
9841 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9842 queue_start_index, "queue_start_index");
9843 cmdline_parse_token_num_t cmd_queue_region_queue_id =
9844 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9846 cmdline_parse_token_string_t cmd_queue_region_queue_num =
9847 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9848 queue_num, "queue_num");
9849 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
9850 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9851 queue_num_value, UINT8);
9853 cmdline_parse_inst_t cmd_queue_region = {
9854 .f = cmd_queue_region_parsed,
9856 .help_str = "set port <port_id> queue-region region_id <value> "
9857 "queue_start_index <value> queue_num <value>: Set a queue region",
9859 (void *)&cmd_queue_region_set,
9860 (void *)&cmd_queue_region_port,
9861 (void *)&cmd_queue_region_port_id,
9862 (void *)&cmd_queue_region_cmd,
9863 (void *)&cmd_queue_region_id,
9864 (void *)&cmd_queue_region_index,
9865 (void *)&cmd_queue_region_queue_start_index,
9866 (void *)&cmd_queue_region_queue_id,
9867 (void *)&cmd_queue_region_queue_num,
9868 (void *)&cmd_queue_region_queue_num_value,
9873 /* *** queue region and flowtype set *** */
9874 struct cmd_region_flowtype_result {
9875 cmdline_fixed_string_t set;
9876 cmdline_fixed_string_t port;
9878 cmdline_fixed_string_t cmd;
9879 cmdline_fixed_string_t region;
9881 cmdline_fixed_string_t flowtype;
9882 uint8_t flowtype_id;
9886 cmd_region_flowtype_parsed(void *parsed_result,
9887 __rte_unused struct cmdline *cl,
9888 __rte_unused void *data)
9890 struct cmd_region_flowtype_result *res = parsed_result;
9893 struct rte_pmd_i40e_queue_region_conf region_conf;
9894 enum rte_pmd_i40e_queue_region_op op_type;
9897 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9901 memset(®ion_conf, 0, sizeof(region_conf));
9903 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
9904 region_conf.region_id = res->region_id;
9905 region_conf.hw_flowtype = res->flowtype_id;
9907 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9908 op_type, ®ion_conf);
9915 printf("function not implemented or supported\n");
9918 printf("region flowtype config error: (%s)\n", strerror(-ret));
9922 cmdline_parse_token_string_t cmd_region_flowtype_set =
9923 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9925 cmdline_parse_token_string_t cmd_region_flowtype_port =
9926 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9928 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
9929 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9931 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
9932 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9933 cmd, "queue-region");
9934 cmdline_parse_token_string_t cmd_region_flowtype_index =
9935 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9936 region, "region_id");
9937 cmdline_parse_token_num_t cmd_region_flowtype_id =
9938 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9940 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
9941 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9942 flowtype, "flowtype");
9943 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
9944 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9945 flowtype_id, UINT8);
9946 cmdline_parse_inst_t cmd_region_flowtype = {
9947 .f = cmd_region_flowtype_parsed,
9949 .help_str = "set port <port_id> queue-region region_id <value> "
9950 "flowtype <value>: Set a flowtype region index",
9952 (void *)&cmd_region_flowtype_set,
9953 (void *)&cmd_region_flowtype_port,
9954 (void *)&cmd_region_flowtype_port_index,
9955 (void *)&cmd_region_flowtype_cmd,
9956 (void *)&cmd_region_flowtype_index,
9957 (void *)&cmd_region_flowtype_id,
9958 (void *)&cmd_region_flowtype_flow_index,
9959 (void *)&cmd_region_flowtype_flow_id,
9964 /* *** User Priority (UP) to queue region (region_id) set *** */
9965 struct cmd_user_priority_region_result {
9966 cmdline_fixed_string_t set;
9967 cmdline_fixed_string_t port;
9969 cmdline_fixed_string_t cmd;
9970 cmdline_fixed_string_t user_priority;
9971 uint8_t user_priority_id;
9972 cmdline_fixed_string_t region;
9977 cmd_user_priority_region_parsed(void *parsed_result,
9978 __rte_unused struct cmdline *cl,
9979 __rte_unused void *data)
9981 struct cmd_user_priority_region_result *res = parsed_result;
9984 struct rte_pmd_i40e_queue_region_conf region_conf;
9985 enum rte_pmd_i40e_queue_region_op op_type;
9988 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9992 memset(®ion_conf, 0, sizeof(region_conf));
9993 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
9994 region_conf.user_priority = res->user_priority_id;
9995 region_conf.region_id = res->region_id;
9997 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9998 op_type, ®ion_conf);
10005 printf("function not implemented or supported\n");
10008 printf("user_priority region config error: (%s)\n",
10013 cmdline_parse_token_string_t cmd_user_priority_region_set =
10014 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10016 cmdline_parse_token_string_t cmd_user_priority_region_port =
10017 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10019 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
10020 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10022 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
10023 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10024 cmd, "queue-region");
10025 cmdline_parse_token_string_t cmd_user_priority_region_UP =
10026 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10027 user_priority, "UP");
10028 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
10029 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10030 user_priority_id, UINT8);
10031 cmdline_parse_token_string_t cmd_user_priority_region_region =
10032 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10033 region, "region_id");
10034 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
10035 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10038 cmdline_parse_inst_t cmd_user_priority_region = {
10039 .f = cmd_user_priority_region_parsed,
10041 .help_str = "set port <port_id> queue-region UP <value> "
10042 "region_id <value>: Set the mapping of User Priority (UP) "
10043 "to queue region (region_id) ",
10045 (void *)&cmd_user_priority_region_set,
10046 (void *)&cmd_user_priority_region_port,
10047 (void *)&cmd_user_priority_region_port_index,
10048 (void *)&cmd_user_priority_region_cmd,
10049 (void *)&cmd_user_priority_region_UP,
10050 (void *)&cmd_user_priority_region_UP_id,
10051 (void *)&cmd_user_priority_region_region,
10052 (void *)&cmd_user_priority_region_region_id,
10057 /* *** flush all queue region related configuration *** */
10058 struct cmd_flush_queue_region_result {
10059 cmdline_fixed_string_t set;
10060 cmdline_fixed_string_t port;
10062 cmdline_fixed_string_t cmd;
10063 cmdline_fixed_string_t flush;
10064 cmdline_fixed_string_t what;
10068 cmd_flush_queue_region_parsed(void *parsed_result,
10069 __rte_unused struct cmdline *cl,
10070 __rte_unused void *data)
10072 struct cmd_flush_queue_region_result *res = parsed_result;
10073 int ret = -ENOTSUP;
10074 #ifdef RTE_NET_I40E
10075 struct rte_pmd_i40e_queue_region_conf region_conf;
10076 enum rte_pmd_i40e_queue_region_op op_type;
10079 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10082 #ifdef RTE_NET_I40E
10083 memset(®ion_conf, 0, sizeof(region_conf));
10085 if (strcmp(res->what, "on") == 0)
10086 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
10088 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
10090 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10091 op_type, ®ion_conf);
10098 printf("function not implemented or supported\n");
10101 printf("queue region config flush error: (%s)\n",
10106 cmdline_parse_token_string_t cmd_flush_queue_region_set =
10107 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10109 cmdline_parse_token_string_t cmd_flush_queue_region_port =
10110 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10112 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
10113 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
10115 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
10116 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10117 cmd, "queue-region");
10118 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
10119 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10121 cmdline_parse_token_string_t cmd_flush_queue_region_what =
10122 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10125 cmdline_parse_inst_t cmd_flush_queue_region = {
10126 .f = cmd_flush_queue_region_parsed,
10128 .help_str = "set port <port_id> queue-region flush on|off"
10129 ": flush all queue region related configuration",
10131 (void *)&cmd_flush_queue_region_set,
10132 (void *)&cmd_flush_queue_region_port,
10133 (void *)&cmd_flush_queue_region_port_index,
10134 (void *)&cmd_flush_queue_region_cmd,
10135 (void *)&cmd_flush_queue_region_flush,
10136 (void *)&cmd_flush_queue_region_what,
10141 /* *** get all queue region related configuration info *** */
10142 struct cmd_show_queue_region_info {
10143 cmdline_fixed_string_t show;
10144 cmdline_fixed_string_t port;
10146 cmdline_fixed_string_t cmd;
10150 cmd_show_queue_region_info_parsed(void *parsed_result,
10151 __rte_unused struct cmdline *cl,
10152 __rte_unused void *data)
10154 struct cmd_show_queue_region_info *res = parsed_result;
10155 int ret = -ENOTSUP;
10156 #ifdef RTE_NET_I40E
10157 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
10158 enum rte_pmd_i40e_queue_region_op op_type;
10161 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10164 #ifdef RTE_NET_I40E
10165 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
10167 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
10169 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10170 op_type, &rte_pmd_regions);
10172 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
10179 printf("function not implemented or supported\n");
10182 printf("queue region config info show error: (%s)\n",
10187 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
10188 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10190 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
10191 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10193 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
10194 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
10196 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
10197 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10198 cmd, "queue-region");
10200 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
10201 .f = cmd_show_queue_region_info_parsed,
10203 .help_str = "show port <port_id> queue-region"
10204 ": show all queue region related configuration info",
10206 (void *)&cmd_show_queue_region_info_get,
10207 (void *)&cmd_show_queue_region_info_port,
10208 (void *)&cmd_show_queue_region_info_port_index,
10209 (void *)&cmd_show_queue_region_info_cmd,
10214 /* *** Filters Control *** */
10216 /* *** deal with flow director filter *** */
10217 struct cmd_flow_director_result {
10218 cmdline_fixed_string_t flow_director_filter;
10220 cmdline_fixed_string_t mode;
10221 cmdline_fixed_string_t mode_value;
10222 cmdline_fixed_string_t ops;
10223 cmdline_fixed_string_t flow;
10224 cmdline_fixed_string_t flow_type;
10225 cmdline_fixed_string_t ether;
10226 uint16_t ether_type;
10227 cmdline_fixed_string_t src;
10228 cmdline_ipaddr_t ip_src;
10230 cmdline_fixed_string_t dst;
10231 cmdline_ipaddr_t ip_dst;
10233 cmdline_fixed_string_t verify_tag;
10234 uint32_t verify_tag_value;
10235 cmdline_fixed_string_t tos;
10237 cmdline_fixed_string_t proto;
10238 uint8_t proto_value;
10239 cmdline_fixed_string_t ttl;
10241 cmdline_fixed_string_t vlan;
10242 uint16_t vlan_value;
10243 cmdline_fixed_string_t flexbytes;
10244 cmdline_fixed_string_t flexbytes_value;
10245 cmdline_fixed_string_t pf_vf;
10246 cmdline_fixed_string_t drop;
10247 cmdline_fixed_string_t queue;
10249 cmdline_fixed_string_t fd_id;
10250 uint32_t fd_id_value;
10251 cmdline_fixed_string_t mac;
10252 struct rte_ether_addr mac_addr;
10253 cmdline_fixed_string_t tunnel;
10254 cmdline_fixed_string_t tunnel_type;
10255 cmdline_fixed_string_t tunnel_id;
10256 uint32_t tunnel_id_value;
10257 cmdline_fixed_string_t packet;
10262 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
10265 const char *p, *p0 = q_arg;
10267 unsigned long int_fld;
10268 char *str_fld[max_num];
10273 p = strchr(p0, '(');
10277 p0 = strchr(p, ')');
10282 if (size >= sizeof(s))
10285 snprintf(s, sizeof(s), "%.*s", size, p);
10286 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10287 if (ret < 0 || ret > max_num)
10289 for (i = 0; i < ret; i++) {
10291 int_fld = strtoul(str_fld[i], &end, 0);
10292 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
10294 flexbytes[i] = (uint8_t)int_fld;
10300 str2flowtype(char *string)
10303 static const struct {
10306 } flowtype_str[] = {
10307 {"raw", RTE_ETH_FLOW_RAW},
10308 {"ipv4", RTE_ETH_FLOW_IPV4},
10309 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10310 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10311 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10312 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10313 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10314 {"ipv6", RTE_ETH_FLOW_IPV6},
10315 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10316 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10317 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10318 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10319 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10320 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10323 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
10324 if (!strcmp(flowtype_str[i].str, string))
10325 return flowtype_str[i].type;
10328 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
10329 return (uint16_t)atoi(string);
10331 return RTE_ETH_FLOW_UNKNOWN;
10334 static enum rte_eth_fdir_tunnel_type
10335 str2fdir_tunneltype(char *string)
10339 static const struct {
10341 enum rte_eth_fdir_tunnel_type type;
10342 } tunneltype_str[] = {
10343 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
10344 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
10347 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
10348 if (!strcmp(tunneltype_str[i].str, string))
10349 return tunneltype_str[i].type;
10351 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
10354 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10356 if ((ip_addr).family == AF_INET) \
10357 (ip) = (ip_addr).addr.ipv4.s_addr; \
10359 printf("invalid parameter.\n"); \
10364 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10366 if ((ip_addr).family == AF_INET6) \
10367 rte_memcpy(&(ip), \
10368 &((ip_addr).addr.ipv6), \
10369 sizeof(struct in6_addr)); \
10371 printf("invalid parameter.\n"); \
10377 cmd_flow_director_filter_parsed(void *parsed_result,
10378 __rte_unused struct cmdline *cl,
10379 __rte_unused void *data)
10381 struct cmd_flow_director_result *res = parsed_result;
10382 struct rte_eth_fdir_filter entry;
10383 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
10385 unsigned long vf_id;
10388 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
10390 printf("flow director is not supported on port %u.\n",
10394 memset(flexbytes, 0, sizeof(flexbytes));
10395 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
10397 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10398 if (strcmp(res->mode_value, "MAC-VLAN")) {
10399 printf("Please set mode to MAC-VLAN.\n");
10402 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10403 if (strcmp(res->mode_value, "Tunnel")) {
10404 printf("Please set mode to Tunnel.\n");
10408 if (!strcmp(res->mode_value, "raw")) {
10409 #ifdef RTE_NET_I40E
10410 struct rte_pmd_i40e_flow_type_mapping
10411 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
10412 struct rte_pmd_i40e_pkt_template_conf conf;
10413 uint16_t flow_type = str2flowtype(res->flow_type);
10414 uint16_t i, port = res->port_id;
10417 memset(&conf, 0, sizeof(conf));
10419 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
10420 printf("Invalid flow type specified.\n");
10423 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
10427 if (mapping[flow_type].pctype == 0ULL) {
10428 printf("Invalid flow type specified.\n");
10431 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
10432 if (mapping[flow_type].pctype & (1ULL << i)) {
10433 conf.input.pctype = i;
10438 conf.input.packet = open_file(res->filepath,
10439 &conf.input.length);
10440 if (!conf.input.packet)
10442 if (!strcmp(res->drop, "drop"))
10443 conf.action.behavior =
10444 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
10446 conf.action.behavior =
10447 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
10448 conf.action.report_status =
10449 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
10450 conf.action.rx_queue = res->queue_id;
10451 conf.soft_id = res->fd_id_value;
10452 add = strcmp(res->ops, "del") ? 1 : 0;
10453 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
10457 printf("flow director config error: (%s)\n",
10459 close_file(conf.input.packet);
10462 } else if (strcmp(res->mode_value, "IP")) {
10463 printf("Please set mode to IP or raw.\n");
10466 entry.input.flow_type = str2flowtype(res->flow_type);
10469 ret = parse_flexbytes(res->flexbytes_value,
10471 RTE_ETH_FDIR_MAX_FLEXLEN);
10473 printf("error: Cannot parse flexbytes input.\n");
10477 switch (entry.input.flow_type) {
10478 case RTE_ETH_FLOW_FRAG_IPV4:
10479 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
10480 entry.input.flow.ip4_flow.proto = res->proto_value;
10482 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
10483 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
10484 IPV4_ADDR_TO_UINT(res->ip_dst,
10485 entry.input.flow.ip4_flow.dst_ip);
10486 IPV4_ADDR_TO_UINT(res->ip_src,
10487 entry.input.flow.ip4_flow.src_ip);
10488 entry.input.flow.ip4_flow.tos = res->tos_value;
10489 entry.input.flow.ip4_flow.ttl = res->ttl_value;
10490 /* need convert to big endian. */
10491 entry.input.flow.udp4_flow.dst_port =
10492 rte_cpu_to_be_16(res->port_dst);
10493 entry.input.flow.udp4_flow.src_port =
10494 rte_cpu_to_be_16(res->port_src);
10496 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
10497 IPV4_ADDR_TO_UINT(res->ip_dst,
10498 entry.input.flow.sctp4_flow.ip.dst_ip);
10499 IPV4_ADDR_TO_UINT(res->ip_src,
10500 entry.input.flow.sctp4_flow.ip.src_ip);
10501 entry.input.flow.ip4_flow.tos = res->tos_value;
10502 entry.input.flow.ip4_flow.ttl = res->ttl_value;
10503 /* need convert to big endian. */
10504 entry.input.flow.sctp4_flow.dst_port =
10505 rte_cpu_to_be_16(res->port_dst);
10506 entry.input.flow.sctp4_flow.src_port =
10507 rte_cpu_to_be_16(res->port_src);
10508 entry.input.flow.sctp4_flow.verify_tag =
10509 rte_cpu_to_be_32(res->verify_tag_value);
10511 case RTE_ETH_FLOW_FRAG_IPV6:
10512 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
10513 entry.input.flow.ipv6_flow.proto = res->proto_value;
10515 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
10516 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
10517 IPV6_ADDR_TO_ARRAY(res->ip_dst,
10518 entry.input.flow.ipv6_flow.dst_ip);
10519 IPV6_ADDR_TO_ARRAY(res->ip_src,
10520 entry.input.flow.ipv6_flow.src_ip);
10521 entry.input.flow.ipv6_flow.tc = res->tos_value;
10522 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
10523 /* need convert to big endian. */
10524 entry.input.flow.udp6_flow.dst_port =
10525 rte_cpu_to_be_16(res->port_dst);
10526 entry.input.flow.udp6_flow.src_port =
10527 rte_cpu_to_be_16(res->port_src);
10529 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
10530 IPV6_ADDR_TO_ARRAY(res->ip_dst,
10531 entry.input.flow.sctp6_flow.ip.dst_ip);
10532 IPV6_ADDR_TO_ARRAY(res->ip_src,
10533 entry.input.flow.sctp6_flow.ip.src_ip);
10534 entry.input.flow.ipv6_flow.tc = res->tos_value;
10535 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
10536 /* need convert to big endian. */
10537 entry.input.flow.sctp6_flow.dst_port =
10538 rte_cpu_to_be_16(res->port_dst);
10539 entry.input.flow.sctp6_flow.src_port =
10540 rte_cpu_to_be_16(res->port_src);
10541 entry.input.flow.sctp6_flow.verify_tag =
10542 rte_cpu_to_be_32(res->verify_tag_value);
10544 case RTE_ETH_FLOW_L2_PAYLOAD:
10545 entry.input.flow.l2_flow.ether_type =
10546 rte_cpu_to_be_16(res->ether_type);
10552 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
10553 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
10555 sizeof(struct rte_ether_addr));
10557 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10558 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
10560 sizeof(struct rte_ether_addr));
10561 entry.input.flow.tunnel_flow.tunnel_type =
10562 str2fdir_tunneltype(res->tunnel_type);
10563 entry.input.flow.tunnel_flow.tunnel_id =
10564 rte_cpu_to_be_32(res->tunnel_id_value);
10567 rte_memcpy(entry.input.flow_ext.flexbytes,
10569 RTE_ETH_FDIR_MAX_FLEXLEN);
10571 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
10573 entry.action.flex_off = 0; /*use 0 by default */
10574 if (!strcmp(res->drop, "drop"))
10575 entry.action.behavior = RTE_ETH_FDIR_REJECT;
10577 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
10579 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
10580 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
10581 if (!strcmp(res->pf_vf, "pf"))
10582 entry.input.flow_ext.is_vf = 0;
10583 else if (!strncmp(res->pf_vf, "vf", 2)) {
10584 struct rte_eth_dev_info dev_info;
10586 ret = eth_dev_info_get_print_err(res->port_id,
10592 vf_id = strtoul(res->pf_vf + 2, &end, 10);
10593 if (errno != 0 || *end != '\0' ||
10594 vf_id >= dev_info.max_vfs) {
10595 printf("invalid parameter %s.\n", res->pf_vf);
10598 entry.input.flow_ext.is_vf = 1;
10599 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
10601 printf("invalid parameter %s.\n", res->pf_vf);
10606 /* set to report FD ID by default */
10607 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
10608 entry.action.rx_queue = res->queue_id;
10609 entry.soft_id = res->fd_id_value;
10610 if (!strcmp(res->ops, "add"))
10611 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10612 RTE_ETH_FILTER_ADD, &entry);
10613 else if (!strcmp(res->ops, "del"))
10614 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10615 RTE_ETH_FILTER_DELETE, &entry);
10617 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10618 RTE_ETH_FILTER_UPDATE, &entry);
10620 printf("flow director programming error: (%s)\n",
10624 cmdline_parse_token_string_t cmd_flow_director_filter =
10625 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10626 flow_director_filter, "flow_director_filter");
10627 cmdline_parse_token_num_t cmd_flow_director_port_id =
10628 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10630 cmdline_parse_token_string_t cmd_flow_director_ops =
10631 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10632 ops, "add#del#update");
10633 cmdline_parse_token_string_t cmd_flow_director_flow =
10634 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10636 cmdline_parse_token_string_t cmd_flow_director_flow_type =
10637 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10639 cmdline_parse_token_string_t cmd_flow_director_ether =
10640 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10642 cmdline_parse_token_num_t cmd_flow_director_ether_type =
10643 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10644 ether_type, UINT16);
10645 cmdline_parse_token_string_t cmd_flow_director_src =
10646 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10648 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
10649 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10651 cmdline_parse_token_num_t cmd_flow_director_port_src =
10652 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10654 cmdline_parse_token_string_t cmd_flow_director_dst =
10655 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10657 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
10658 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10660 cmdline_parse_token_num_t cmd_flow_director_port_dst =
10661 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10663 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
10664 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10665 verify_tag, "verify_tag");
10666 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
10667 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10668 verify_tag_value, UINT32);
10669 cmdline_parse_token_string_t cmd_flow_director_tos =
10670 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10672 cmdline_parse_token_num_t cmd_flow_director_tos_value =
10673 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10675 cmdline_parse_token_string_t cmd_flow_director_proto =
10676 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10678 cmdline_parse_token_num_t cmd_flow_director_proto_value =
10679 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10680 proto_value, UINT8);
10681 cmdline_parse_token_string_t cmd_flow_director_ttl =
10682 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10684 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
10685 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10687 cmdline_parse_token_string_t cmd_flow_director_vlan =
10688 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10690 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
10691 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10692 vlan_value, UINT16);
10693 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
10694 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10695 flexbytes, "flexbytes");
10696 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
10697 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10698 flexbytes_value, NULL);
10699 cmdline_parse_token_string_t cmd_flow_director_drop =
10700 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10702 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
10703 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10705 cmdline_parse_token_string_t cmd_flow_director_queue =
10706 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10708 cmdline_parse_token_num_t cmd_flow_director_queue_id =
10709 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10711 cmdline_parse_token_string_t cmd_flow_director_fd_id =
10712 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10714 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
10715 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10716 fd_id_value, UINT32);
10718 cmdline_parse_token_string_t cmd_flow_director_mode =
10719 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10721 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
10722 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10724 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
10725 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10726 mode_value, "MAC-VLAN");
10727 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
10728 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10729 mode_value, "Tunnel");
10730 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
10731 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10732 mode_value, "raw");
10733 cmdline_parse_token_string_t cmd_flow_director_mac =
10734 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10736 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
10737 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
10739 cmdline_parse_token_string_t cmd_flow_director_tunnel =
10740 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10742 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
10743 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10744 tunnel_type, "NVGRE#VxLAN");
10745 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
10746 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10747 tunnel_id, "tunnel-id");
10748 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
10749 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10750 tunnel_id_value, UINT32);
10751 cmdline_parse_token_string_t cmd_flow_director_packet =
10752 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10754 cmdline_parse_token_string_t cmd_flow_director_filepath =
10755 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10758 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
10759 .f = cmd_flow_director_filter_parsed,
10761 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
10762 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
10763 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
10764 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
10765 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
10766 "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> "
10767 "fd_id <fd_id_value>: "
10768 "Add or delete an ip flow director entry on NIC",
10770 (void *)&cmd_flow_director_filter,
10771 (void *)&cmd_flow_director_port_id,
10772 (void *)&cmd_flow_director_mode,
10773 (void *)&cmd_flow_director_mode_ip,
10774 (void *)&cmd_flow_director_ops,
10775 (void *)&cmd_flow_director_flow,
10776 (void *)&cmd_flow_director_flow_type,
10777 (void *)&cmd_flow_director_src,
10778 (void *)&cmd_flow_director_ip_src,
10779 (void *)&cmd_flow_director_dst,
10780 (void *)&cmd_flow_director_ip_dst,
10781 (void *)&cmd_flow_director_tos,
10782 (void *)&cmd_flow_director_tos_value,
10783 (void *)&cmd_flow_director_proto,
10784 (void *)&cmd_flow_director_proto_value,
10785 (void *)&cmd_flow_director_ttl,
10786 (void *)&cmd_flow_director_ttl_value,
10787 (void *)&cmd_flow_director_vlan,
10788 (void *)&cmd_flow_director_vlan_value,
10789 (void *)&cmd_flow_director_flexbytes,
10790 (void *)&cmd_flow_director_flexbytes_value,
10791 (void *)&cmd_flow_director_drop,
10792 (void *)&cmd_flow_director_pf_vf,
10793 (void *)&cmd_flow_director_queue,
10794 (void *)&cmd_flow_director_queue_id,
10795 (void *)&cmd_flow_director_fd_id,
10796 (void *)&cmd_flow_director_fd_id_value,
10801 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
10802 .f = cmd_flow_director_filter_parsed,
10804 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
10805 "director entry on NIC",
10807 (void *)&cmd_flow_director_filter,
10808 (void *)&cmd_flow_director_port_id,
10809 (void *)&cmd_flow_director_mode,
10810 (void *)&cmd_flow_director_mode_ip,
10811 (void *)&cmd_flow_director_ops,
10812 (void *)&cmd_flow_director_flow,
10813 (void *)&cmd_flow_director_flow_type,
10814 (void *)&cmd_flow_director_src,
10815 (void *)&cmd_flow_director_ip_src,
10816 (void *)&cmd_flow_director_port_src,
10817 (void *)&cmd_flow_director_dst,
10818 (void *)&cmd_flow_director_ip_dst,
10819 (void *)&cmd_flow_director_port_dst,
10820 (void *)&cmd_flow_director_tos,
10821 (void *)&cmd_flow_director_tos_value,
10822 (void *)&cmd_flow_director_ttl,
10823 (void *)&cmd_flow_director_ttl_value,
10824 (void *)&cmd_flow_director_vlan,
10825 (void *)&cmd_flow_director_vlan_value,
10826 (void *)&cmd_flow_director_flexbytes,
10827 (void *)&cmd_flow_director_flexbytes_value,
10828 (void *)&cmd_flow_director_drop,
10829 (void *)&cmd_flow_director_pf_vf,
10830 (void *)&cmd_flow_director_queue,
10831 (void *)&cmd_flow_director_queue_id,
10832 (void *)&cmd_flow_director_fd_id,
10833 (void *)&cmd_flow_director_fd_id_value,
10838 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
10839 .f = cmd_flow_director_filter_parsed,
10841 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
10842 "director entry on NIC",
10844 (void *)&cmd_flow_director_filter,
10845 (void *)&cmd_flow_director_port_id,
10846 (void *)&cmd_flow_director_mode,
10847 (void *)&cmd_flow_director_mode_ip,
10848 (void *)&cmd_flow_director_ops,
10849 (void *)&cmd_flow_director_flow,
10850 (void *)&cmd_flow_director_flow_type,
10851 (void *)&cmd_flow_director_src,
10852 (void *)&cmd_flow_director_ip_src,
10853 (void *)&cmd_flow_director_port_src,
10854 (void *)&cmd_flow_director_dst,
10855 (void *)&cmd_flow_director_ip_dst,
10856 (void *)&cmd_flow_director_port_dst,
10857 (void *)&cmd_flow_director_verify_tag,
10858 (void *)&cmd_flow_director_verify_tag_value,
10859 (void *)&cmd_flow_director_tos,
10860 (void *)&cmd_flow_director_tos_value,
10861 (void *)&cmd_flow_director_ttl,
10862 (void *)&cmd_flow_director_ttl_value,
10863 (void *)&cmd_flow_director_vlan,
10864 (void *)&cmd_flow_director_vlan_value,
10865 (void *)&cmd_flow_director_flexbytes,
10866 (void *)&cmd_flow_director_flexbytes_value,
10867 (void *)&cmd_flow_director_drop,
10868 (void *)&cmd_flow_director_pf_vf,
10869 (void *)&cmd_flow_director_queue,
10870 (void *)&cmd_flow_director_queue_id,
10871 (void *)&cmd_flow_director_fd_id,
10872 (void *)&cmd_flow_director_fd_id_value,
10877 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
10878 .f = cmd_flow_director_filter_parsed,
10880 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
10881 "director entry on NIC",
10883 (void *)&cmd_flow_director_filter,
10884 (void *)&cmd_flow_director_port_id,
10885 (void *)&cmd_flow_director_mode,
10886 (void *)&cmd_flow_director_mode_ip,
10887 (void *)&cmd_flow_director_ops,
10888 (void *)&cmd_flow_director_flow,
10889 (void *)&cmd_flow_director_flow_type,
10890 (void *)&cmd_flow_director_ether,
10891 (void *)&cmd_flow_director_ether_type,
10892 (void *)&cmd_flow_director_flexbytes,
10893 (void *)&cmd_flow_director_flexbytes_value,
10894 (void *)&cmd_flow_director_drop,
10895 (void *)&cmd_flow_director_pf_vf,
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_mac_vlan_flow_director = {
10905 .f = cmd_flow_director_filter_parsed,
10907 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN 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_mac_vlan,
10914 (void *)&cmd_flow_director_ops,
10915 (void *)&cmd_flow_director_mac,
10916 (void *)&cmd_flow_director_mac_addr,
10917 (void *)&cmd_flow_director_vlan,
10918 (void *)&cmd_flow_director_vlan_value,
10919 (void *)&cmd_flow_director_flexbytes,
10920 (void *)&cmd_flow_director_flexbytes_value,
10921 (void *)&cmd_flow_director_drop,
10922 (void *)&cmd_flow_director_queue,
10923 (void *)&cmd_flow_director_queue_id,
10924 (void *)&cmd_flow_director_fd_id,
10925 (void *)&cmd_flow_director_fd_id_value,
10930 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
10931 .f = cmd_flow_director_filter_parsed,
10933 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
10934 "director entry on NIC",
10936 (void *)&cmd_flow_director_filter,
10937 (void *)&cmd_flow_director_port_id,
10938 (void *)&cmd_flow_director_mode,
10939 (void *)&cmd_flow_director_mode_tunnel,
10940 (void *)&cmd_flow_director_ops,
10941 (void *)&cmd_flow_director_mac,
10942 (void *)&cmd_flow_director_mac_addr,
10943 (void *)&cmd_flow_director_vlan,
10944 (void *)&cmd_flow_director_vlan_value,
10945 (void *)&cmd_flow_director_tunnel,
10946 (void *)&cmd_flow_director_tunnel_type,
10947 (void *)&cmd_flow_director_tunnel_id,
10948 (void *)&cmd_flow_director_tunnel_id_value,
10949 (void *)&cmd_flow_director_flexbytes,
10950 (void *)&cmd_flow_director_flexbytes_value,
10951 (void *)&cmd_flow_director_drop,
10952 (void *)&cmd_flow_director_queue,
10953 (void *)&cmd_flow_director_queue_id,
10954 (void *)&cmd_flow_director_fd_id,
10955 (void *)&cmd_flow_director_fd_id_value,
10960 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
10961 .f = cmd_flow_director_filter_parsed,
10963 .help_str = "flow_director_filter ... : Add or delete a raw flow "
10964 "director entry on NIC",
10966 (void *)&cmd_flow_director_filter,
10967 (void *)&cmd_flow_director_port_id,
10968 (void *)&cmd_flow_director_mode,
10969 (void *)&cmd_flow_director_mode_raw,
10970 (void *)&cmd_flow_director_ops,
10971 (void *)&cmd_flow_director_flow,
10972 (void *)&cmd_flow_director_flow_type,
10973 (void *)&cmd_flow_director_drop,
10974 (void *)&cmd_flow_director_queue,
10975 (void *)&cmd_flow_director_queue_id,
10976 (void *)&cmd_flow_director_fd_id,
10977 (void *)&cmd_flow_director_fd_id_value,
10978 (void *)&cmd_flow_director_packet,
10979 (void *)&cmd_flow_director_filepath,
10984 struct cmd_flush_flow_director_result {
10985 cmdline_fixed_string_t flush_flow_director;
10989 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
10990 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
10991 flush_flow_director, "flush_flow_director");
10992 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
10993 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
10997 cmd_flush_flow_director_parsed(void *parsed_result,
10998 __rte_unused struct cmdline *cl,
10999 __rte_unused void *data)
11001 struct cmd_flow_director_result *res = parsed_result;
11004 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
11006 printf("flow director is not supported on port %u.\n",
11011 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11012 RTE_ETH_FILTER_FLUSH, NULL);
11014 printf("flow director table flushing error: (%s)\n",
11018 cmdline_parse_inst_t cmd_flush_flow_director = {
11019 .f = cmd_flush_flow_director_parsed,
11021 .help_str = "flush_flow_director <port_id>: "
11022 "Flush all flow director entries of a device on NIC",
11024 (void *)&cmd_flush_flow_director_flush,
11025 (void *)&cmd_flush_flow_director_port_id,
11030 /* *** deal with flow director mask *** */
11031 struct cmd_flow_director_mask_result {
11032 cmdline_fixed_string_t flow_director_mask;
11034 cmdline_fixed_string_t mode;
11035 cmdline_fixed_string_t mode_value;
11036 cmdline_fixed_string_t vlan;
11037 uint16_t vlan_mask;
11038 cmdline_fixed_string_t src_mask;
11039 cmdline_ipaddr_t ipv4_src;
11040 cmdline_ipaddr_t ipv6_src;
11042 cmdline_fixed_string_t dst_mask;
11043 cmdline_ipaddr_t ipv4_dst;
11044 cmdline_ipaddr_t ipv6_dst;
11046 cmdline_fixed_string_t mac;
11047 uint8_t mac_addr_byte_mask;
11048 cmdline_fixed_string_t tunnel_id;
11049 uint32_t tunnel_id_mask;
11050 cmdline_fixed_string_t tunnel_type;
11051 uint8_t tunnel_type_mask;
11055 cmd_flow_director_mask_parsed(void *parsed_result,
11056 __rte_unused struct cmdline *cl,
11057 __rte_unused void *data)
11059 struct cmd_flow_director_mask_result *res = parsed_result;
11060 struct rte_eth_fdir_masks *mask;
11061 struct rte_port *port;
11063 port = &ports[res->port_id];
11064 /** Check if the port is not started **/
11065 if (port->port_status != RTE_PORT_STOPPED) {
11066 printf("Please stop port %d first\n", res->port_id);
11070 mask = &port->dev_conf.fdir_conf.mask;
11072 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
11073 if (strcmp(res->mode_value, "MAC-VLAN")) {
11074 printf("Please set mode to MAC-VLAN.\n");
11078 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11079 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11080 if (strcmp(res->mode_value, "Tunnel")) {
11081 printf("Please set mode to Tunnel.\n");
11085 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11086 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
11087 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
11088 mask->tunnel_type_mask = res->tunnel_type_mask;
11090 if (strcmp(res->mode_value, "IP")) {
11091 printf("Please set mode to IP.\n");
11095 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11096 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
11097 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
11098 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
11099 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
11100 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
11101 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
11104 cmd_reconfig_device_queue(res->port_id, 1, 1);
11107 cmdline_parse_token_string_t cmd_flow_director_mask =
11108 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11109 flow_director_mask, "flow_director_mask");
11110 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
11111 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11113 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
11114 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11116 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
11117 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11118 vlan_mask, UINT16);
11119 cmdline_parse_token_string_t cmd_flow_director_mask_src =
11120 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11121 src_mask, "src_mask");
11122 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
11123 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11125 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
11126 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11128 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
11129 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11131 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
11132 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11133 dst_mask, "dst_mask");
11134 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
11135 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11137 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
11138 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11140 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
11141 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11144 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
11145 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11147 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
11148 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11150 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
11151 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11152 mode_value, "MAC-VLAN");
11153 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
11154 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11155 mode_value, "Tunnel");
11156 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
11157 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11159 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
11160 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11161 mac_addr_byte_mask, UINT8);
11162 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
11163 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11164 tunnel_type, "tunnel-type");
11165 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
11166 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11167 tunnel_type_mask, UINT8);
11168 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
11169 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11170 tunnel_id, "tunnel-id");
11171 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
11172 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11173 tunnel_id_mask, UINT32);
11175 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
11176 .f = cmd_flow_director_mask_parsed,
11178 .help_str = "flow_director_mask ... : "
11179 "Set IP mode flow director's mask on NIC",
11181 (void *)&cmd_flow_director_mask,
11182 (void *)&cmd_flow_director_mask_port_id,
11183 (void *)&cmd_flow_director_mask_mode,
11184 (void *)&cmd_flow_director_mask_mode_ip,
11185 (void *)&cmd_flow_director_mask_vlan,
11186 (void *)&cmd_flow_director_mask_vlan_value,
11187 (void *)&cmd_flow_director_mask_src,
11188 (void *)&cmd_flow_director_mask_ipv4_src,
11189 (void *)&cmd_flow_director_mask_ipv6_src,
11190 (void *)&cmd_flow_director_mask_port_src,
11191 (void *)&cmd_flow_director_mask_dst,
11192 (void *)&cmd_flow_director_mask_ipv4_dst,
11193 (void *)&cmd_flow_director_mask_ipv6_dst,
11194 (void *)&cmd_flow_director_mask_port_dst,
11199 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
11200 .f = cmd_flow_director_mask_parsed,
11202 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
11203 "flow director's mask on NIC",
11205 (void *)&cmd_flow_director_mask,
11206 (void *)&cmd_flow_director_mask_port_id,
11207 (void *)&cmd_flow_director_mask_mode,
11208 (void *)&cmd_flow_director_mask_mode_mac_vlan,
11209 (void *)&cmd_flow_director_mask_vlan,
11210 (void *)&cmd_flow_director_mask_vlan_value,
11215 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
11216 .f = cmd_flow_director_mask_parsed,
11218 .help_str = "flow_director_mask ... : Set tunnel mode "
11219 "flow director's mask on NIC",
11221 (void *)&cmd_flow_director_mask,
11222 (void *)&cmd_flow_director_mask_port_id,
11223 (void *)&cmd_flow_director_mask_mode,
11224 (void *)&cmd_flow_director_mask_mode_tunnel,
11225 (void *)&cmd_flow_director_mask_vlan,
11226 (void *)&cmd_flow_director_mask_vlan_value,
11227 (void *)&cmd_flow_director_mask_mac,
11228 (void *)&cmd_flow_director_mask_mac_value,
11229 (void *)&cmd_flow_director_mask_tunnel_type,
11230 (void *)&cmd_flow_director_mask_tunnel_type_value,
11231 (void *)&cmd_flow_director_mask_tunnel_id,
11232 (void *)&cmd_flow_director_mask_tunnel_id_value,
11237 /* *** deal with flow director mask on flexible payload *** */
11238 struct cmd_flow_director_flex_mask_result {
11239 cmdline_fixed_string_t flow_director_flexmask;
11241 cmdline_fixed_string_t flow;
11242 cmdline_fixed_string_t flow_type;
11243 cmdline_fixed_string_t mask;
11247 cmd_flow_director_flex_mask_parsed(void *parsed_result,
11248 __rte_unused struct cmdline *cl,
11249 __rte_unused void *data)
11251 struct cmd_flow_director_flex_mask_result *res = parsed_result;
11252 struct rte_eth_fdir_info fdir_info;
11253 struct rte_eth_fdir_flex_mask flex_mask;
11254 struct rte_port *port;
11255 uint64_t flow_type_mask;
11259 port = &ports[res->port_id];
11260 /** Check if the port is not started **/
11261 if (port->port_status != RTE_PORT_STOPPED) {
11262 printf("Please stop port %d first\n", res->port_id);
11266 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
11267 ret = parse_flexbytes(res->mask,
11269 RTE_ETH_FDIR_MAX_FLEXLEN);
11271 printf("error: Cannot parse mask input.\n");
11275 memset(&fdir_info, 0, sizeof(fdir_info));
11276 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11277 RTE_ETH_FILTER_INFO, &fdir_info);
11279 printf("Cannot get FDir filter info\n");
11283 if (!strcmp(res->flow_type, "none")) {
11284 /* means don't specify the flow type */
11285 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
11286 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
11287 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
11288 0, sizeof(struct rte_eth_fdir_flex_mask));
11289 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
11290 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
11292 sizeof(struct rte_eth_fdir_flex_mask));
11293 cmd_reconfig_device_queue(res->port_id, 1, 1);
11296 flow_type_mask = fdir_info.flow_types_mask[0];
11297 if (!strcmp(res->flow_type, "all")) {
11298 if (!flow_type_mask) {
11299 printf("No flow type supported\n");
11302 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
11303 if (flow_type_mask & (1ULL << i)) {
11304 flex_mask.flow_type = i;
11305 fdir_set_flex_mask(res->port_id, &flex_mask);
11308 cmd_reconfig_device_queue(res->port_id, 1, 1);
11311 flex_mask.flow_type = str2flowtype(res->flow_type);
11312 if (!(flow_type_mask & (1ULL << flex_mask.flow_type))) {
11313 printf("Flow type %s not supported on port %d\n",
11314 res->flow_type, res->port_id);
11317 fdir_set_flex_mask(res->port_id, &flex_mask);
11318 cmd_reconfig_device_queue(res->port_id, 1, 1);
11321 cmdline_parse_token_string_t cmd_flow_director_flexmask =
11322 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11323 flow_director_flexmask,
11324 "flow_director_flex_mask");
11325 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
11326 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11328 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
11329 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11331 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
11332 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11333 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
11334 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
11335 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
11336 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11339 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
11340 .f = cmd_flow_director_flex_mask_parsed,
11342 .help_str = "flow_director_flex_mask ... : "
11343 "Set flow director's flex mask on NIC",
11345 (void *)&cmd_flow_director_flexmask,
11346 (void *)&cmd_flow_director_flexmask_port_id,
11347 (void *)&cmd_flow_director_flexmask_flow,
11348 (void *)&cmd_flow_director_flexmask_flow_type,
11349 (void *)&cmd_flow_director_flexmask_mask,
11354 /* *** deal with flow director flexible payload configuration *** */
11355 struct cmd_flow_director_flexpayload_result {
11356 cmdline_fixed_string_t flow_director_flexpayload;
11358 cmdline_fixed_string_t payload_layer;
11359 cmdline_fixed_string_t payload_cfg;
11363 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
11366 const char *p, *p0 = q_arg;
11368 unsigned long int_fld;
11369 char *str_fld[max_num];
11374 p = strchr(p0, '(');
11378 p0 = strchr(p, ')');
11383 if (size >= sizeof(s))
11386 snprintf(s, sizeof(s), "%.*s", size, p);
11387 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
11388 if (ret < 0 || ret > max_num)
11390 for (i = 0; i < ret; i++) {
11392 int_fld = strtoul(str_fld[i], &end, 0);
11393 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
11395 offsets[i] = (uint16_t)int_fld;
11401 cmd_flow_director_flxpld_parsed(void *parsed_result,
11402 __rte_unused struct cmdline *cl,
11403 __rte_unused void *data)
11405 struct cmd_flow_director_flexpayload_result *res = parsed_result;
11406 struct rte_eth_flex_payload_cfg flex_cfg;
11407 struct rte_port *port;
11410 port = &ports[res->port_id];
11411 /** Check if the port is not started **/
11412 if (port->port_status != RTE_PORT_STOPPED) {
11413 printf("Please stop port %d first\n", res->port_id);
11417 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
11419 if (!strcmp(res->payload_layer, "raw"))
11420 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
11421 else if (!strcmp(res->payload_layer, "l2"))
11422 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
11423 else if (!strcmp(res->payload_layer, "l3"))
11424 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
11425 else if (!strcmp(res->payload_layer, "l4"))
11426 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
11428 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
11429 RTE_ETH_FDIR_MAX_FLEXLEN);
11431 printf("error: Cannot parse flex payload input.\n");
11435 fdir_set_flex_payload(res->port_id, &flex_cfg);
11436 cmd_reconfig_device_queue(res->port_id, 1, 1);
11439 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
11440 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11441 flow_director_flexpayload,
11442 "flow_director_flex_payload");
11443 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
11444 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11446 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
11447 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11448 payload_layer, "raw#l2#l3#l4");
11449 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
11450 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11451 payload_cfg, NULL);
11453 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
11454 .f = cmd_flow_director_flxpld_parsed,
11456 .help_str = "flow_director_flexpayload ... : "
11457 "Set flow director's flex payload on NIC",
11459 (void *)&cmd_flow_director_flexpayload,
11460 (void *)&cmd_flow_director_flexpayload_port_id,
11461 (void *)&cmd_flow_director_flexpayload_payload_layer,
11462 (void *)&cmd_flow_director_flexpayload_payload_cfg,
11467 /* Generic flow interface command. */
11468 extern cmdline_parse_inst_t cmd_flow;
11470 /* *** Classification Filters Control *** */
11472 static enum rte_eth_input_set_field
11473 str2inset(char *string)
11477 static const struct {
11479 enum rte_eth_input_set_field inset;
11480 } inset_table[] = {
11481 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
11482 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
11483 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
11484 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
11485 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
11486 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
11487 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
11488 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
11489 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
11490 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
11491 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
11492 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
11493 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
11494 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
11495 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
11496 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
11497 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
11498 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
11499 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
11500 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
11501 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
11502 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
11503 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
11504 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
11505 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
11506 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
11507 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
11508 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
11509 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
11510 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
11511 {"none", RTE_ETH_INPUT_SET_NONE},
11514 for (i = 0; i < RTE_DIM(inset_table); i++) {
11515 if (!strcmp(string, inset_table[i].str))
11516 return inset_table[i].inset;
11519 return RTE_ETH_INPUT_SET_UNKNOWN;
11522 /* Set flow director input set */
11523 struct cmd_set_fdir_input_set_result {
11524 cmdline_fixed_string_t set_fdir_input_set;
11526 cmdline_fixed_string_t flow_type;
11527 cmdline_fixed_string_t inset_field;
11528 cmdline_fixed_string_t select;
11532 cmd_set_fdir_input_set_parsed(void *parsed_result,
11533 __rte_unused struct cmdline *cl,
11534 __rte_unused void *data)
11536 struct cmd_set_fdir_input_set_result *res = parsed_result;
11537 struct rte_eth_fdir_filter_info info;
11539 memset(&info, 0, sizeof(info));
11540 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
11541 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
11542 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
11543 info.info.input_set_conf.inset_size = 1;
11544 if (!strcmp(res->select, "select"))
11545 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
11546 else if (!strcmp(res->select, "add"))
11547 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
11548 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11549 RTE_ETH_FILTER_SET, &info);
11552 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
11553 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11554 set_fdir_input_set, "set_fdir_input_set");
11555 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
11556 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
11558 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
11559 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11561 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
11562 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
11563 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
11564 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11566 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
11567 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
11568 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
11569 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
11570 "sctp-veri-tag#none");
11571 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
11572 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11573 select, "select#add");
11575 cmdline_parse_inst_t cmd_set_fdir_input_set = {
11576 .f = cmd_set_fdir_input_set_parsed,
11578 .help_str = "set_fdir_input_set <port_id> "
11579 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11580 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
11581 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
11582 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
11583 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
11584 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
11585 "sctp-veri-tag|none select|add",
11587 (void *)&cmd_set_fdir_input_set_cmd,
11588 (void *)&cmd_set_fdir_input_set_port_id,
11589 (void *)&cmd_set_fdir_input_set_flow_type,
11590 (void *)&cmd_set_fdir_input_set_field,
11591 (void *)&cmd_set_fdir_input_set_select,
11596 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
11597 struct cmd_mcast_addr_result {
11598 cmdline_fixed_string_t mcast_addr_cmd;
11599 cmdline_fixed_string_t what;
11601 struct rte_ether_addr mc_addr;
11604 static void cmd_mcast_addr_parsed(void *parsed_result,
11605 __rte_unused struct cmdline *cl,
11606 __rte_unused void *data)
11608 struct cmd_mcast_addr_result *res = parsed_result;
11610 if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
11611 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
11612 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
11613 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
11614 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
11617 if (strcmp(res->what, "add") == 0)
11618 mcast_addr_add(res->port_num, &res->mc_addr);
11620 mcast_addr_remove(res->port_num, &res->mc_addr);
11623 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
11624 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
11625 mcast_addr_cmd, "mcast_addr");
11626 cmdline_parse_token_string_t cmd_mcast_addr_what =
11627 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
11629 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
11630 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
11631 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
11632 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
11634 cmdline_parse_inst_t cmd_mcast_addr = {
11635 .f = cmd_mcast_addr_parsed,
11637 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
11638 "Add/Remove multicast MAC address on port_id",
11640 (void *)&cmd_mcast_addr_cmd,
11641 (void *)&cmd_mcast_addr_what,
11642 (void *)&cmd_mcast_addr_portnum,
11643 (void *)&cmd_mcast_addr_addr,
11648 /* l2 tunnel config
11649 * only support E-tag now.
11652 /* Ether type config */
11653 struct cmd_config_l2_tunnel_eth_type_result {
11654 cmdline_fixed_string_t port;
11655 cmdline_fixed_string_t config;
11656 cmdline_fixed_string_t all;
11658 cmdline_fixed_string_t l2_tunnel;
11659 cmdline_fixed_string_t l2_tunnel_type;
11660 cmdline_fixed_string_t eth_type;
11661 uint16_t eth_type_val;
11664 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
11665 TOKEN_STRING_INITIALIZER
11666 (struct cmd_config_l2_tunnel_eth_type_result,
11668 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
11669 TOKEN_STRING_INITIALIZER
11670 (struct cmd_config_l2_tunnel_eth_type_result,
11672 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
11673 TOKEN_STRING_INITIALIZER
11674 (struct cmd_config_l2_tunnel_eth_type_result,
11676 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
11677 TOKEN_NUM_INITIALIZER
11678 (struct cmd_config_l2_tunnel_eth_type_result,
11680 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
11681 TOKEN_STRING_INITIALIZER
11682 (struct cmd_config_l2_tunnel_eth_type_result,
11683 l2_tunnel, "l2-tunnel");
11684 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
11685 TOKEN_STRING_INITIALIZER
11686 (struct cmd_config_l2_tunnel_eth_type_result,
11687 l2_tunnel_type, "E-tag");
11688 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
11689 TOKEN_STRING_INITIALIZER
11690 (struct cmd_config_l2_tunnel_eth_type_result,
11691 eth_type, "ether-type");
11692 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
11693 TOKEN_NUM_INITIALIZER
11694 (struct cmd_config_l2_tunnel_eth_type_result,
11695 eth_type_val, UINT16);
11697 static enum rte_eth_tunnel_type
11698 str2fdir_l2_tunnel_type(char *string)
11702 static const struct {
11704 enum rte_eth_tunnel_type type;
11705 } l2_tunnel_type_str[] = {
11706 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
11709 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
11710 if (!strcmp(l2_tunnel_type_str[i].str, string))
11711 return l2_tunnel_type_str[i].type;
11713 return RTE_TUNNEL_TYPE_NONE;
11716 /* ether type config for all ports */
11718 cmd_config_l2_tunnel_eth_type_all_parsed
11719 (void *parsed_result,
11720 __rte_unused struct cmdline *cl,
11721 __rte_unused void *data)
11723 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
11724 struct rte_eth_l2_tunnel_conf entry;
11727 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11728 entry.ether_type = res->eth_type_val;
11730 RTE_ETH_FOREACH_DEV(pid) {
11731 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
11735 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
11736 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
11738 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
11740 (void *)&cmd_config_l2_tunnel_eth_type_port,
11741 (void *)&cmd_config_l2_tunnel_eth_type_config,
11742 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
11743 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
11744 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
11745 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
11746 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
11751 /* ether type config for a specific port */
11753 cmd_config_l2_tunnel_eth_type_specific_parsed(
11754 void *parsed_result,
11755 __rte_unused struct cmdline *cl,
11756 __rte_unused void *data)
11758 struct cmd_config_l2_tunnel_eth_type_result *res =
11760 struct rte_eth_l2_tunnel_conf entry;
11762 if (port_id_is_invalid(res->id, ENABLED_WARN))
11765 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11766 entry.ether_type = res->eth_type_val;
11768 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
11771 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
11772 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
11774 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
11776 (void *)&cmd_config_l2_tunnel_eth_type_port,
11777 (void *)&cmd_config_l2_tunnel_eth_type_config,
11778 (void *)&cmd_config_l2_tunnel_eth_type_id,
11779 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
11780 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
11781 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
11782 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
11787 /* Enable/disable l2 tunnel */
11788 struct cmd_config_l2_tunnel_en_dis_result {
11789 cmdline_fixed_string_t port;
11790 cmdline_fixed_string_t config;
11791 cmdline_fixed_string_t all;
11793 cmdline_fixed_string_t l2_tunnel;
11794 cmdline_fixed_string_t l2_tunnel_type;
11795 cmdline_fixed_string_t en_dis;
11798 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
11799 TOKEN_STRING_INITIALIZER
11800 (struct cmd_config_l2_tunnel_en_dis_result,
11802 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
11803 TOKEN_STRING_INITIALIZER
11804 (struct cmd_config_l2_tunnel_en_dis_result,
11806 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
11807 TOKEN_STRING_INITIALIZER
11808 (struct cmd_config_l2_tunnel_en_dis_result,
11810 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
11811 TOKEN_NUM_INITIALIZER
11812 (struct cmd_config_l2_tunnel_en_dis_result,
11814 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
11815 TOKEN_STRING_INITIALIZER
11816 (struct cmd_config_l2_tunnel_en_dis_result,
11817 l2_tunnel, "l2-tunnel");
11818 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
11819 TOKEN_STRING_INITIALIZER
11820 (struct cmd_config_l2_tunnel_en_dis_result,
11821 l2_tunnel_type, "E-tag");
11822 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
11823 TOKEN_STRING_INITIALIZER
11824 (struct cmd_config_l2_tunnel_en_dis_result,
11825 en_dis, "enable#disable");
11827 /* enable/disable l2 tunnel for all ports */
11829 cmd_config_l2_tunnel_en_dis_all_parsed(
11830 void *parsed_result,
11831 __rte_unused struct cmdline *cl,
11832 __rte_unused void *data)
11834 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
11835 struct rte_eth_l2_tunnel_conf entry;
11839 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11841 if (!strcmp("enable", res->en_dis))
11846 RTE_ETH_FOREACH_DEV(pid) {
11847 rte_eth_dev_l2_tunnel_offload_set(pid,
11849 ETH_L2_TUNNEL_ENABLE_MASK,
11854 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
11855 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
11857 .help_str = "port config all l2-tunnel E-tag enable|disable",
11859 (void *)&cmd_config_l2_tunnel_en_dis_port,
11860 (void *)&cmd_config_l2_tunnel_en_dis_config,
11861 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
11862 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
11863 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
11864 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
11869 /* enable/disable l2 tunnel for a port */
11871 cmd_config_l2_tunnel_en_dis_specific_parsed(
11872 void *parsed_result,
11873 __rte_unused struct cmdline *cl,
11874 __rte_unused void *data)
11876 struct cmd_config_l2_tunnel_en_dis_result *res =
11878 struct rte_eth_l2_tunnel_conf entry;
11880 if (port_id_is_invalid(res->id, ENABLED_WARN))
11883 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11885 if (!strcmp("enable", res->en_dis))
11886 rte_eth_dev_l2_tunnel_offload_set(res->id,
11888 ETH_L2_TUNNEL_ENABLE_MASK,
11891 rte_eth_dev_l2_tunnel_offload_set(res->id,
11893 ETH_L2_TUNNEL_ENABLE_MASK,
11897 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
11898 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
11900 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
11902 (void *)&cmd_config_l2_tunnel_en_dis_port,
11903 (void *)&cmd_config_l2_tunnel_en_dis_config,
11904 (void *)&cmd_config_l2_tunnel_en_dis_id,
11905 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
11906 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
11907 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
11912 /* E-tag configuration */
11914 /* Common result structure for all E-tag configuration */
11915 struct cmd_config_e_tag_result {
11916 cmdline_fixed_string_t e_tag;
11917 cmdline_fixed_string_t set;
11918 cmdline_fixed_string_t insertion;
11919 cmdline_fixed_string_t stripping;
11920 cmdline_fixed_string_t forwarding;
11921 cmdline_fixed_string_t filter;
11922 cmdline_fixed_string_t add;
11923 cmdline_fixed_string_t del;
11924 cmdline_fixed_string_t on;
11925 cmdline_fixed_string_t off;
11926 cmdline_fixed_string_t on_off;
11927 cmdline_fixed_string_t port_tag_id;
11928 uint32_t port_tag_id_val;
11929 cmdline_fixed_string_t e_tag_id;
11930 uint16_t e_tag_id_val;
11931 cmdline_fixed_string_t dst_pool;
11932 uint8_t dst_pool_val;
11933 cmdline_fixed_string_t port;
11935 cmdline_fixed_string_t vf;
11939 /* Common CLI fields for all E-tag configuration */
11940 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
11941 TOKEN_STRING_INITIALIZER
11942 (struct cmd_config_e_tag_result,
11944 cmdline_parse_token_string_t cmd_config_e_tag_set =
11945 TOKEN_STRING_INITIALIZER
11946 (struct cmd_config_e_tag_result,
11948 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
11949 TOKEN_STRING_INITIALIZER
11950 (struct cmd_config_e_tag_result,
11951 insertion, "insertion");
11952 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
11953 TOKEN_STRING_INITIALIZER
11954 (struct cmd_config_e_tag_result,
11955 stripping, "stripping");
11956 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
11957 TOKEN_STRING_INITIALIZER
11958 (struct cmd_config_e_tag_result,
11959 forwarding, "forwarding");
11960 cmdline_parse_token_string_t cmd_config_e_tag_filter =
11961 TOKEN_STRING_INITIALIZER
11962 (struct cmd_config_e_tag_result,
11964 cmdline_parse_token_string_t cmd_config_e_tag_add =
11965 TOKEN_STRING_INITIALIZER
11966 (struct cmd_config_e_tag_result,
11968 cmdline_parse_token_string_t cmd_config_e_tag_del =
11969 TOKEN_STRING_INITIALIZER
11970 (struct cmd_config_e_tag_result,
11972 cmdline_parse_token_string_t cmd_config_e_tag_on =
11973 TOKEN_STRING_INITIALIZER
11974 (struct cmd_config_e_tag_result,
11976 cmdline_parse_token_string_t cmd_config_e_tag_off =
11977 TOKEN_STRING_INITIALIZER
11978 (struct cmd_config_e_tag_result,
11980 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
11981 TOKEN_STRING_INITIALIZER
11982 (struct cmd_config_e_tag_result,
11984 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
11985 TOKEN_STRING_INITIALIZER
11986 (struct cmd_config_e_tag_result,
11987 port_tag_id, "port-tag-id");
11988 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
11989 TOKEN_NUM_INITIALIZER
11990 (struct cmd_config_e_tag_result,
11991 port_tag_id_val, UINT32);
11992 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
11993 TOKEN_STRING_INITIALIZER
11994 (struct cmd_config_e_tag_result,
11995 e_tag_id, "e-tag-id");
11996 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
11997 TOKEN_NUM_INITIALIZER
11998 (struct cmd_config_e_tag_result,
11999 e_tag_id_val, UINT16);
12000 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
12001 TOKEN_STRING_INITIALIZER
12002 (struct cmd_config_e_tag_result,
12003 dst_pool, "dst-pool");
12004 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
12005 TOKEN_NUM_INITIALIZER
12006 (struct cmd_config_e_tag_result,
12007 dst_pool_val, UINT8);
12008 cmdline_parse_token_string_t cmd_config_e_tag_port =
12009 TOKEN_STRING_INITIALIZER
12010 (struct cmd_config_e_tag_result,
12012 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
12013 TOKEN_NUM_INITIALIZER
12014 (struct cmd_config_e_tag_result,
12016 cmdline_parse_token_string_t cmd_config_e_tag_vf =
12017 TOKEN_STRING_INITIALIZER
12018 (struct cmd_config_e_tag_result,
12020 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
12021 TOKEN_NUM_INITIALIZER
12022 (struct cmd_config_e_tag_result,
12025 /* E-tag insertion configuration */
12027 cmd_config_e_tag_insertion_en_parsed(
12028 void *parsed_result,
12029 __rte_unused struct cmdline *cl,
12030 __rte_unused void *data)
12032 struct cmd_config_e_tag_result *res =
12034 struct rte_eth_l2_tunnel_conf entry;
12036 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12039 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12040 entry.tunnel_id = res->port_tag_id_val;
12041 entry.vf_id = res->vf_id;
12042 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12044 ETH_L2_TUNNEL_INSERTION_MASK,
12049 cmd_config_e_tag_insertion_dis_parsed(
12050 void *parsed_result,
12051 __rte_unused struct cmdline *cl,
12052 __rte_unused void *data)
12054 struct cmd_config_e_tag_result *res =
12056 struct rte_eth_l2_tunnel_conf entry;
12058 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12061 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12062 entry.vf_id = res->vf_id;
12064 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12066 ETH_L2_TUNNEL_INSERTION_MASK,
12070 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
12071 .f = cmd_config_e_tag_insertion_en_parsed,
12073 .help_str = "E-tag ... : E-tag insertion enable",
12075 (void *)&cmd_config_e_tag_e_tag,
12076 (void *)&cmd_config_e_tag_set,
12077 (void *)&cmd_config_e_tag_insertion,
12078 (void *)&cmd_config_e_tag_on,
12079 (void *)&cmd_config_e_tag_port_tag_id,
12080 (void *)&cmd_config_e_tag_port_tag_id_val,
12081 (void *)&cmd_config_e_tag_port,
12082 (void *)&cmd_config_e_tag_port_id,
12083 (void *)&cmd_config_e_tag_vf,
12084 (void *)&cmd_config_e_tag_vf_id,
12089 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
12090 .f = cmd_config_e_tag_insertion_dis_parsed,
12092 .help_str = "E-tag ... : E-tag insertion disable",
12094 (void *)&cmd_config_e_tag_e_tag,
12095 (void *)&cmd_config_e_tag_set,
12096 (void *)&cmd_config_e_tag_insertion,
12097 (void *)&cmd_config_e_tag_off,
12098 (void *)&cmd_config_e_tag_port,
12099 (void *)&cmd_config_e_tag_port_id,
12100 (void *)&cmd_config_e_tag_vf,
12101 (void *)&cmd_config_e_tag_vf_id,
12106 /* E-tag stripping configuration */
12108 cmd_config_e_tag_stripping_parsed(
12109 void *parsed_result,
12110 __rte_unused struct cmdline *cl,
12111 __rte_unused void *data)
12113 struct cmd_config_e_tag_result *res =
12115 struct rte_eth_l2_tunnel_conf entry;
12117 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12120 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12122 if (!strcmp(res->on_off, "on"))
12123 rte_eth_dev_l2_tunnel_offload_set
12126 ETH_L2_TUNNEL_STRIPPING_MASK,
12129 rte_eth_dev_l2_tunnel_offload_set
12132 ETH_L2_TUNNEL_STRIPPING_MASK,
12136 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
12137 .f = cmd_config_e_tag_stripping_parsed,
12139 .help_str = "E-tag ... : E-tag stripping enable/disable",
12141 (void *)&cmd_config_e_tag_e_tag,
12142 (void *)&cmd_config_e_tag_set,
12143 (void *)&cmd_config_e_tag_stripping,
12144 (void *)&cmd_config_e_tag_on_off,
12145 (void *)&cmd_config_e_tag_port,
12146 (void *)&cmd_config_e_tag_port_id,
12151 /* E-tag forwarding configuration */
12153 cmd_config_e_tag_forwarding_parsed(
12154 void *parsed_result,
12155 __rte_unused struct cmdline *cl,
12156 __rte_unused void *data)
12158 struct cmd_config_e_tag_result *res = parsed_result;
12159 struct rte_eth_l2_tunnel_conf entry;
12161 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12164 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12166 if (!strcmp(res->on_off, "on"))
12167 rte_eth_dev_l2_tunnel_offload_set
12170 ETH_L2_TUNNEL_FORWARDING_MASK,
12173 rte_eth_dev_l2_tunnel_offload_set
12176 ETH_L2_TUNNEL_FORWARDING_MASK,
12180 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
12181 .f = cmd_config_e_tag_forwarding_parsed,
12183 .help_str = "E-tag ... : E-tag forwarding enable/disable",
12185 (void *)&cmd_config_e_tag_e_tag,
12186 (void *)&cmd_config_e_tag_set,
12187 (void *)&cmd_config_e_tag_forwarding,
12188 (void *)&cmd_config_e_tag_on_off,
12189 (void *)&cmd_config_e_tag_port,
12190 (void *)&cmd_config_e_tag_port_id,
12195 /* vf vlan anti spoof configuration */
12197 /* Common result structure for vf vlan anti spoof */
12198 struct cmd_vf_vlan_anti_spoof_result {
12199 cmdline_fixed_string_t set;
12200 cmdline_fixed_string_t vf;
12201 cmdline_fixed_string_t vlan;
12202 cmdline_fixed_string_t antispoof;
12205 cmdline_fixed_string_t on_off;
12208 /* Common CLI fields for vf vlan anti spoof enable disable */
12209 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
12210 TOKEN_STRING_INITIALIZER
12211 (struct cmd_vf_vlan_anti_spoof_result,
12213 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
12214 TOKEN_STRING_INITIALIZER
12215 (struct cmd_vf_vlan_anti_spoof_result,
12217 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
12218 TOKEN_STRING_INITIALIZER
12219 (struct cmd_vf_vlan_anti_spoof_result,
12221 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
12222 TOKEN_STRING_INITIALIZER
12223 (struct cmd_vf_vlan_anti_spoof_result,
12224 antispoof, "antispoof");
12225 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
12226 TOKEN_NUM_INITIALIZER
12227 (struct cmd_vf_vlan_anti_spoof_result,
12229 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
12230 TOKEN_NUM_INITIALIZER
12231 (struct cmd_vf_vlan_anti_spoof_result,
12233 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
12234 TOKEN_STRING_INITIALIZER
12235 (struct cmd_vf_vlan_anti_spoof_result,
12239 cmd_set_vf_vlan_anti_spoof_parsed(
12240 void *parsed_result,
12241 __rte_unused struct cmdline *cl,
12242 __rte_unused void *data)
12244 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
12245 int ret = -ENOTSUP;
12247 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12249 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12252 #ifdef RTE_NET_IXGBE
12253 if (ret == -ENOTSUP)
12254 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
12255 res->vf_id, is_on);
12257 #ifdef RTE_NET_I40E
12258 if (ret == -ENOTSUP)
12259 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
12260 res->vf_id, is_on);
12262 #ifdef RTE_NET_BNXT
12263 if (ret == -ENOTSUP)
12264 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
12265 res->vf_id, is_on);
12272 printf("invalid vf_id %d\n", res->vf_id);
12275 printf("invalid port_id %d\n", res->port_id);
12278 printf("function not implemented\n");
12281 printf("programming error: (%s)\n", strerror(-ret));
12285 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
12286 .f = cmd_set_vf_vlan_anti_spoof_parsed,
12288 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
12290 (void *)&cmd_vf_vlan_anti_spoof_set,
12291 (void *)&cmd_vf_vlan_anti_spoof_vf,
12292 (void *)&cmd_vf_vlan_anti_spoof_vlan,
12293 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
12294 (void *)&cmd_vf_vlan_anti_spoof_port_id,
12295 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
12296 (void *)&cmd_vf_vlan_anti_spoof_on_off,
12301 /* vf mac anti spoof configuration */
12303 /* Common result structure for vf mac anti spoof */
12304 struct cmd_vf_mac_anti_spoof_result {
12305 cmdline_fixed_string_t set;
12306 cmdline_fixed_string_t vf;
12307 cmdline_fixed_string_t mac;
12308 cmdline_fixed_string_t antispoof;
12311 cmdline_fixed_string_t on_off;
12314 /* Common CLI fields for vf mac anti spoof enable disable */
12315 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
12316 TOKEN_STRING_INITIALIZER
12317 (struct cmd_vf_mac_anti_spoof_result,
12319 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
12320 TOKEN_STRING_INITIALIZER
12321 (struct cmd_vf_mac_anti_spoof_result,
12323 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
12324 TOKEN_STRING_INITIALIZER
12325 (struct cmd_vf_mac_anti_spoof_result,
12327 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
12328 TOKEN_STRING_INITIALIZER
12329 (struct cmd_vf_mac_anti_spoof_result,
12330 antispoof, "antispoof");
12331 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
12332 TOKEN_NUM_INITIALIZER
12333 (struct cmd_vf_mac_anti_spoof_result,
12335 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
12336 TOKEN_NUM_INITIALIZER
12337 (struct cmd_vf_mac_anti_spoof_result,
12339 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
12340 TOKEN_STRING_INITIALIZER
12341 (struct cmd_vf_mac_anti_spoof_result,
12345 cmd_set_vf_mac_anti_spoof_parsed(
12346 void *parsed_result,
12347 __rte_unused struct cmdline *cl,
12348 __rte_unused void *data)
12350 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
12351 int ret = -ENOTSUP;
12353 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12355 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12358 #ifdef RTE_NET_IXGBE
12359 if (ret == -ENOTSUP)
12360 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
12361 res->vf_id, is_on);
12363 #ifdef RTE_NET_I40E
12364 if (ret == -ENOTSUP)
12365 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
12366 res->vf_id, is_on);
12368 #ifdef RTE_NET_BNXT
12369 if (ret == -ENOTSUP)
12370 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
12371 res->vf_id, is_on);
12378 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12381 printf("invalid port_id %d\n", res->port_id);
12384 printf("function not implemented\n");
12387 printf("programming error: (%s)\n", strerror(-ret));
12391 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
12392 .f = cmd_set_vf_mac_anti_spoof_parsed,
12394 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
12396 (void *)&cmd_vf_mac_anti_spoof_set,
12397 (void *)&cmd_vf_mac_anti_spoof_vf,
12398 (void *)&cmd_vf_mac_anti_spoof_mac,
12399 (void *)&cmd_vf_mac_anti_spoof_antispoof,
12400 (void *)&cmd_vf_mac_anti_spoof_port_id,
12401 (void *)&cmd_vf_mac_anti_spoof_vf_id,
12402 (void *)&cmd_vf_mac_anti_spoof_on_off,
12407 /* vf vlan strip queue configuration */
12409 /* Common result structure for vf mac anti spoof */
12410 struct cmd_vf_vlan_stripq_result {
12411 cmdline_fixed_string_t set;
12412 cmdline_fixed_string_t vf;
12413 cmdline_fixed_string_t vlan;
12414 cmdline_fixed_string_t stripq;
12417 cmdline_fixed_string_t on_off;
12420 /* Common CLI fields for vf vlan strip enable disable */
12421 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
12422 TOKEN_STRING_INITIALIZER
12423 (struct cmd_vf_vlan_stripq_result,
12425 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
12426 TOKEN_STRING_INITIALIZER
12427 (struct cmd_vf_vlan_stripq_result,
12429 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
12430 TOKEN_STRING_INITIALIZER
12431 (struct cmd_vf_vlan_stripq_result,
12433 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
12434 TOKEN_STRING_INITIALIZER
12435 (struct cmd_vf_vlan_stripq_result,
12437 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
12438 TOKEN_NUM_INITIALIZER
12439 (struct cmd_vf_vlan_stripq_result,
12441 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
12442 TOKEN_NUM_INITIALIZER
12443 (struct cmd_vf_vlan_stripq_result,
12445 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
12446 TOKEN_STRING_INITIALIZER
12447 (struct cmd_vf_vlan_stripq_result,
12451 cmd_set_vf_vlan_stripq_parsed(
12452 void *parsed_result,
12453 __rte_unused struct cmdline *cl,
12454 __rte_unused void *data)
12456 struct cmd_vf_vlan_stripq_result *res = parsed_result;
12457 int ret = -ENOTSUP;
12459 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12461 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12464 #ifdef RTE_NET_IXGBE
12465 if (ret == -ENOTSUP)
12466 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
12467 res->vf_id, is_on);
12469 #ifdef RTE_NET_I40E
12470 if (ret == -ENOTSUP)
12471 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
12472 res->vf_id, is_on);
12474 #ifdef RTE_NET_BNXT
12475 if (ret == -ENOTSUP)
12476 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
12477 res->vf_id, is_on);
12484 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12487 printf("invalid port_id %d\n", res->port_id);
12490 printf("function not implemented\n");
12493 printf("programming error: (%s)\n", strerror(-ret));
12497 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
12498 .f = cmd_set_vf_vlan_stripq_parsed,
12500 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
12502 (void *)&cmd_vf_vlan_stripq_set,
12503 (void *)&cmd_vf_vlan_stripq_vf,
12504 (void *)&cmd_vf_vlan_stripq_vlan,
12505 (void *)&cmd_vf_vlan_stripq_stripq,
12506 (void *)&cmd_vf_vlan_stripq_port_id,
12507 (void *)&cmd_vf_vlan_stripq_vf_id,
12508 (void *)&cmd_vf_vlan_stripq_on_off,
12513 /* vf vlan insert configuration */
12515 /* Common result structure for vf vlan insert */
12516 struct cmd_vf_vlan_insert_result {
12517 cmdline_fixed_string_t set;
12518 cmdline_fixed_string_t vf;
12519 cmdline_fixed_string_t vlan;
12520 cmdline_fixed_string_t insert;
12526 /* Common CLI fields for vf vlan insert enable disable */
12527 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
12528 TOKEN_STRING_INITIALIZER
12529 (struct cmd_vf_vlan_insert_result,
12531 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
12532 TOKEN_STRING_INITIALIZER
12533 (struct cmd_vf_vlan_insert_result,
12535 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
12536 TOKEN_STRING_INITIALIZER
12537 (struct cmd_vf_vlan_insert_result,
12539 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
12540 TOKEN_STRING_INITIALIZER
12541 (struct cmd_vf_vlan_insert_result,
12543 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
12544 TOKEN_NUM_INITIALIZER
12545 (struct cmd_vf_vlan_insert_result,
12547 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
12548 TOKEN_NUM_INITIALIZER
12549 (struct cmd_vf_vlan_insert_result,
12551 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
12552 TOKEN_NUM_INITIALIZER
12553 (struct cmd_vf_vlan_insert_result,
12557 cmd_set_vf_vlan_insert_parsed(
12558 void *parsed_result,
12559 __rte_unused struct cmdline *cl,
12560 __rte_unused void *data)
12562 struct cmd_vf_vlan_insert_result *res = parsed_result;
12563 int ret = -ENOTSUP;
12565 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12568 #ifdef RTE_NET_IXGBE
12569 if (ret == -ENOTSUP)
12570 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
12573 #ifdef RTE_NET_I40E
12574 if (ret == -ENOTSUP)
12575 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
12578 #ifdef RTE_NET_BNXT
12579 if (ret == -ENOTSUP)
12580 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
12588 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
12591 printf("invalid port_id %d\n", res->port_id);
12594 printf("function not implemented\n");
12597 printf("programming error: (%s)\n", strerror(-ret));
12601 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
12602 .f = cmd_set_vf_vlan_insert_parsed,
12604 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
12606 (void *)&cmd_vf_vlan_insert_set,
12607 (void *)&cmd_vf_vlan_insert_vf,
12608 (void *)&cmd_vf_vlan_insert_vlan,
12609 (void *)&cmd_vf_vlan_insert_insert,
12610 (void *)&cmd_vf_vlan_insert_port_id,
12611 (void *)&cmd_vf_vlan_insert_vf_id,
12612 (void *)&cmd_vf_vlan_insert_vlan_id,
12617 /* tx loopback configuration */
12619 /* Common result structure for tx loopback */
12620 struct cmd_tx_loopback_result {
12621 cmdline_fixed_string_t set;
12622 cmdline_fixed_string_t tx;
12623 cmdline_fixed_string_t loopback;
12625 cmdline_fixed_string_t on_off;
12628 /* Common CLI fields for tx loopback enable disable */
12629 cmdline_parse_token_string_t cmd_tx_loopback_set =
12630 TOKEN_STRING_INITIALIZER
12631 (struct cmd_tx_loopback_result,
12633 cmdline_parse_token_string_t cmd_tx_loopback_tx =
12634 TOKEN_STRING_INITIALIZER
12635 (struct cmd_tx_loopback_result,
12637 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
12638 TOKEN_STRING_INITIALIZER
12639 (struct cmd_tx_loopback_result,
12640 loopback, "loopback");
12641 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
12642 TOKEN_NUM_INITIALIZER
12643 (struct cmd_tx_loopback_result,
12645 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
12646 TOKEN_STRING_INITIALIZER
12647 (struct cmd_tx_loopback_result,
12651 cmd_set_tx_loopback_parsed(
12652 void *parsed_result,
12653 __rte_unused struct cmdline *cl,
12654 __rte_unused void *data)
12656 struct cmd_tx_loopback_result *res = parsed_result;
12657 int ret = -ENOTSUP;
12659 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12661 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12664 #ifdef RTE_NET_IXGBE
12665 if (ret == -ENOTSUP)
12666 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
12668 #ifdef RTE_NET_I40E
12669 if (ret == -ENOTSUP)
12670 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
12672 #ifdef RTE_NET_BNXT
12673 if (ret == -ENOTSUP)
12674 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
12676 #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA
12677 if (ret == -ENOTSUP)
12678 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
12685 printf("invalid is_on %d\n", is_on);
12688 printf("invalid port_id %d\n", res->port_id);
12691 printf("function not implemented\n");
12694 printf("programming error: (%s)\n", strerror(-ret));
12698 cmdline_parse_inst_t cmd_set_tx_loopback = {
12699 .f = cmd_set_tx_loopback_parsed,
12701 .help_str = "set tx loopback <port_id> on|off",
12703 (void *)&cmd_tx_loopback_set,
12704 (void *)&cmd_tx_loopback_tx,
12705 (void *)&cmd_tx_loopback_loopback,
12706 (void *)&cmd_tx_loopback_port_id,
12707 (void *)&cmd_tx_loopback_on_off,
12712 /* all queues drop enable configuration */
12714 /* Common result structure for all queues drop enable */
12715 struct cmd_all_queues_drop_en_result {
12716 cmdline_fixed_string_t set;
12717 cmdline_fixed_string_t all;
12718 cmdline_fixed_string_t queues;
12719 cmdline_fixed_string_t drop;
12721 cmdline_fixed_string_t on_off;
12724 /* Common CLI fields for tx loopback enable disable */
12725 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
12726 TOKEN_STRING_INITIALIZER
12727 (struct cmd_all_queues_drop_en_result,
12729 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
12730 TOKEN_STRING_INITIALIZER
12731 (struct cmd_all_queues_drop_en_result,
12733 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
12734 TOKEN_STRING_INITIALIZER
12735 (struct cmd_all_queues_drop_en_result,
12737 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
12738 TOKEN_STRING_INITIALIZER
12739 (struct cmd_all_queues_drop_en_result,
12741 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
12742 TOKEN_NUM_INITIALIZER
12743 (struct cmd_all_queues_drop_en_result,
12745 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
12746 TOKEN_STRING_INITIALIZER
12747 (struct cmd_all_queues_drop_en_result,
12751 cmd_set_all_queues_drop_en_parsed(
12752 void *parsed_result,
12753 __rte_unused struct cmdline *cl,
12754 __rte_unused void *data)
12756 struct cmd_all_queues_drop_en_result *res = parsed_result;
12757 int ret = -ENOTSUP;
12758 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12760 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12763 #ifdef RTE_NET_IXGBE
12764 if (ret == -ENOTSUP)
12765 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
12767 #ifdef RTE_NET_BNXT
12768 if (ret == -ENOTSUP)
12769 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
12775 printf("invalid is_on %d\n", is_on);
12778 printf("invalid port_id %d\n", res->port_id);
12781 printf("function not implemented\n");
12784 printf("programming error: (%s)\n", strerror(-ret));
12788 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
12789 .f = cmd_set_all_queues_drop_en_parsed,
12791 .help_str = "set all queues drop <port_id> on|off",
12793 (void *)&cmd_all_queues_drop_en_set,
12794 (void *)&cmd_all_queues_drop_en_all,
12795 (void *)&cmd_all_queues_drop_en_queues,
12796 (void *)&cmd_all_queues_drop_en_drop,
12797 (void *)&cmd_all_queues_drop_en_port_id,
12798 (void *)&cmd_all_queues_drop_en_on_off,
12803 /* vf split drop enable configuration */
12805 /* Common result structure for vf split drop enable */
12806 struct cmd_vf_split_drop_en_result {
12807 cmdline_fixed_string_t set;
12808 cmdline_fixed_string_t vf;
12809 cmdline_fixed_string_t split;
12810 cmdline_fixed_string_t drop;
12813 cmdline_fixed_string_t on_off;
12816 /* Common CLI fields for vf split drop enable disable */
12817 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
12818 TOKEN_STRING_INITIALIZER
12819 (struct cmd_vf_split_drop_en_result,
12821 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
12822 TOKEN_STRING_INITIALIZER
12823 (struct cmd_vf_split_drop_en_result,
12825 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
12826 TOKEN_STRING_INITIALIZER
12827 (struct cmd_vf_split_drop_en_result,
12829 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
12830 TOKEN_STRING_INITIALIZER
12831 (struct cmd_vf_split_drop_en_result,
12833 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
12834 TOKEN_NUM_INITIALIZER
12835 (struct cmd_vf_split_drop_en_result,
12837 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
12838 TOKEN_NUM_INITIALIZER
12839 (struct cmd_vf_split_drop_en_result,
12841 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
12842 TOKEN_STRING_INITIALIZER
12843 (struct cmd_vf_split_drop_en_result,
12847 cmd_set_vf_split_drop_en_parsed(
12848 void *parsed_result,
12849 __rte_unused struct cmdline *cl,
12850 __rte_unused void *data)
12852 struct cmd_vf_split_drop_en_result *res = parsed_result;
12853 int ret = -ENOTSUP;
12854 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12856 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12859 #ifdef RTE_NET_IXGBE
12860 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
12867 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12870 printf("invalid port_id %d\n", res->port_id);
12873 printf("not supported on port %d\n", res->port_id);
12876 printf("programming error: (%s)\n", strerror(-ret));
12880 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
12881 .f = cmd_set_vf_split_drop_en_parsed,
12883 .help_str = "set vf split drop <port_id> <vf_id> on|off",
12885 (void *)&cmd_vf_split_drop_en_set,
12886 (void *)&cmd_vf_split_drop_en_vf,
12887 (void *)&cmd_vf_split_drop_en_split,
12888 (void *)&cmd_vf_split_drop_en_drop,
12889 (void *)&cmd_vf_split_drop_en_port_id,
12890 (void *)&cmd_vf_split_drop_en_vf_id,
12891 (void *)&cmd_vf_split_drop_en_on_off,
12896 /* vf mac address configuration */
12898 /* Common result structure for vf mac address */
12899 struct cmd_set_vf_mac_addr_result {
12900 cmdline_fixed_string_t set;
12901 cmdline_fixed_string_t vf;
12902 cmdline_fixed_string_t mac;
12903 cmdline_fixed_string_t addr;
12906 struct rte_ether_addr mac_addr;
12910 /* Common CLI fields for vf split drop enable disable */
12911 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
12912 TOKEN_STRING_INITIALIZER
12913 (struct cmd_set_vf_mac_addr_result,
12915 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
12916 TOKEN_STRING_INITIALIZER
12917 (struct cmd_set_vf_mac_addr_result,
12919 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
12920 TOKEN_STRING_INITIALIZER
12921 (struct cmd_set_vf_mac_addr_result,
12923 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
12924 TOKEN_STRING_INITIALIZER
12925 (struct cmd_set_vf_mac_addr_result,
12927 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
12928 TOKEN_NUM_INITIALIZER
12929 (struct cmd_set_vf_mac_addr_result,
12931 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
12932 TOKEN_NUM_INITIALIZER
12933 (struct cmd_set_vf_mac_addr_result,
12935 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
12936 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
12940 cmd_set_vf_mac_addr_parsed(
12941 void *parsed_result,
12942 __rte_unused struct cmdline *cl,
12943 __rte_unused void *data)
12945 struct cmd_set_vf_mac_addr_result *res = parsed_result;
12946 int ret = -ENOTSUP;
12948 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12951 #ifdef RTE_NET_IXGBE
12952 if (ret == -ENOTSUP)
12953 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
12956 #ifdef RTE_NET_I40E
12957 if (ret == -ENOTSUP)
12958 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
12961 #ifdef RTE_NET_BNXT
12962 if (ret == -ENOTSUP)
12963 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
12971 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
12974 printf("invalid port_id %d\n", res->port_id);
12977 printf("function not implemented\n");
12980 printf("programming error: (%s)\n", strerror(-ret));
12984 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
12985 .f = cmd_set_vf_mac_addr_parsed,
12987 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
12989 (void *)&cmd_set_vf_mac_addr_set,
12990 (void *)&cmd_set_vf_mac_addr_vf,
12991 (void *)&cmd_set_vf_mac_addr_mac,
12992 (void *)&cmd_set_vf_mac_addr_addr,
12993 (void *)&cmd_set_vf_mac_addr_port_id,
12994 (void *)&cmd_set_vf_mac_addr_vf_id,
12995 (void *)&cmd_set_vf_mac_addr_mac_addr,
13000 /* MACsec configuration */
13002 /* Common result structure for MACsec offload enable */
13003 struct cmd_macsec_offload_on_result {
13004 cmdline_fixed_string_t set;
13005 cmdline_fixed_string_t macsec;
13006 cmdline_fixed_string_t offload;
13008 cmdline_fixed_string_t on;
13009 cmdline_fixed_string_t encrypt;
13010 cmdline_fixed_string_t en_on_off;
13011 cmdline_fixed_string_t replay_protect;
13012 cmdline_fixed_string_t rp_on_off;
13015 /* Common CLI fields for MACsec offload disable */
13016 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
13017 TOKEN_STRING_INITIALIZER
13018 (struct cmd_macsec_offload_on_result,
13020 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
13021 TOKEN_STRING_INITIALIZER
13022 (struct cmd_macsec_offload_on_result,
13024 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
13025 TOKEN_STRING_INITIALIZER
13026 (struct cmd_macsec_offload_on_result,
13027 offload, "offload");
13028 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
13029 TOKEN_NUM_INITIALIZER
13030 (struct cmd_macsec_offload_on_result,
13032 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
13033 TOKEN_STRING_INITIALIZER
13034 (struct cmd_macsec_offload_on_result,
13036 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
13037 TOKEN_STRING_INITIALIZER
13038 (struct cmd_macsec_offload_on_result,
13039 encrypt, "encrypt");
13040 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
13041 TOKEN_STRING_INITIALIZER
13042 (struct cmd_macsec_offload_on_result,
13043 en_on_off, "on#off");
13044 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
13045 TOKEN_STRING_INITIALIZER
13046 (struct cmd_macsec_offload_on_result,
13047 replay_protect, "replay-protect");
13048 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
13049 TOKEN_STRING_INITIALIZER
13050 (struct cmd_macsec_offload_on_result,
13051 rp_on_off, "on#off");
13054 cmd_set_macsec_offload_on_parsed(
13055 void *parsed_result,
13056 __rte_unused struct cmdline *cl,
13057 __rte_unused void *data)
13059 struct cmd_macsec_offload_on_result *res = parsed_result;
13060 int ret = -ENOTSUP;
13061 portid_t port_id = res->port_id;
13062 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
13063 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
13064 struct rte_eth_dev_info dev_info;
13066 if (port_id_is_invalid(port_id, ENABLED_WARN))
13068 if (!port_is_stopped(port_id)) {
13069 printf("Please stop port %d first\n", port_id);
13073 ret = eth_dev_info_get_print_err(port_id, &dev_info);
13077 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
13078 #ifdef RTE_NET_IXGBE
13079 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
13087 ports[port_id].dev_conf.txmode.offloads |=
13088 DEV_TX_OFFLOAD_MACSEC_INSERT;
13089 cmd_reconfig_device_queue(port_id, 1, 1);
13092 printf("invalid port_id %d\n", port_id);
13095 printf("not supported on port %d\n", port_id);
13098 printf("programming error: (%s)\n", strerror(-ret));
13102 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
13103 .f = cmd_set_macsec_offload_on_parsed,
13105 .help_str = "set macsec offload <port_id> on "
13106 "encrypt on|off replay-protect on|off",
13108 (void *)&cmd_macsec_offload_on_set,
13109 (void *)&cmd_macsec_offload_on_macsec,
13110 (void *)&cmd_macsec_offload_on_offload,
13111 (void *)&cmd_macsec_offload_on_port_id,
13112 (void *)&cmd_macsec_offload_on_on,
13113 (void *)&cmd_macsec_offload_on_encrypt,
13114 (void *)&cmd_macsec_offload_on_en_on_off,
13115 (void *)&cmd_macsec_offload_on_replay_protect,
13116 (void *)&cmd_macsec_offload_on_rp_on_off,
13121 /* Common result structure for MACsec offload disable */
13122 struct cmd_macsec_offload_off_result {
13123 cmdline_fixed_string_t set;
13124 cmdline_fixed_string_t macsec;
13125 cmdline_fixed_string_t offload;
13127 cmdline_fixed_string_t off;
13130 /* Common CLI fields for MACsec offload disable */
13131 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
13132 TOKEN_STRING_INITIALIZER
13133 (struct cmd_macsec_offload_off_result,
13135 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
13136 TOKEN_STRING_INITIALIZER
13137 (struct cmd_macsec_offload_off_result,
13139 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
13140 TOKEN_STRING_INITIALIZER
13141 (struct cmd_macsec_offload_off_result,
13142 offload, "offload");
13143 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
13144 TOKEN_NUM_INITIALIZER
13145 (struct cmd_macsec_offload_off_result,
13147 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
13148 TOKEN_STRING_INITIALIZER
13149 (struct cmd_macsec_offload_off_result,
13153 cmd_set_macsec_offload_off_parsed(
13154 void *parsed_result,
13155 __rte_unused struct cmdline *cl,
13156 __rte_unused void *data)
13158 struct cmd_macsec_offload_off_result *res = parsed_result;
13159 int ret = -ENOTSUP;
13160 struct rte_eth_dev_info dev_info;
13161 portid_t port_id = res->port_id;
13163 if (port_id_is_invalid(port_id, ENABLED_WARN))
13165 if (!port_is_stopped(port_id)) {
13166 printf("Please stop port %d first\n", port_id);
13170 ret = eth_dev_info_get_print_err(port_id, &dev_info);
13174 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
13175 #ifdef RTE_NET_IXGBE
13176 ret = rte_pmd_ixgbe_macsec_disable(port_id);
13181 ports[port_id].dev_conf.txmode.offloads &=
13182 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
13183 cmd_reconfig_device_queue(port_id, 1, 1);
13186 printf("invalid port_id %d\n", port_id);
13189 printf("not supported on port %d\n", port_id);
13192 printf("programming error: (%s)\n", strerror(-ret));
13196 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
13197 .f = cmd_set_macsec_offload_off_parsed,
13199 .help_str = "set macsec offload <port_id> off",
13201 (void *)&cmd_macsec_offload_off_set,
13202 (void *)&cmd_macsec_offload_off_macsec,
13203 (void *)&cmd_macsec_offload_off_offload,
13204 (void *)&cmd_macsec_offload_off_port_id,
13205 (void *)&cmd_macsec_offload_off_off,
13210 /* Common result structure for MACsec secure connection configure */
13211 struct cmd_macsec_sc_result {
13212 cmdline_fixed_string_t set;
13213 cmdline_fixed_string_t macsec;
13214 cmdline_fixed_string_t sc;
13215 cmdline_fixed_string_t tx_rx;
13217 struct rte_ether_addr mac;
13221 /* Common CLI fields for MACsec secure connection configure */
13222 cmdline_parse_token_string_t cmd_macsec_sc_set =
13223 TOKEN_STRING_INITIALIZER
13224 (struct cmd_macsec_sc_result,
13226 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
13227 TOKEN_STRING_INITIALIZER
13228 (struct cmd_macsec_sc_result,
13230 cmdline_parse_token_string_t cmd_macsec_sc_sc =
13231 TOKEN_STRING_INITIALIZER
13232 (struct cmd_macsec_sc_result,
13234 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
13235 TOKEN_STRING_INITIALIZER
13236 (struct cmd_macsec_sc_result,
13238 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
13239 TOKEN_NUM_INITIALIZER
13240 (struct cmd_macsec_sc_result,
13242 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
13243 TOKEN_ETHERADDR_INITIALIZER
13244 (struct cmd_macsec_sc_result,
13246 cmdline_parse_token_num_t cmd_macsec_sc_pi =
13247 TOKEN_NUM_INITIALIZER
13248 (struct cmd_macsec_sc_result,
13252 cmd_set_macsec_sc_parsed(
13253 void *parsed_result,
13254 __rte_unused struct cmdline *cl,
13255 __rte_unused void *data)
13257 struct cmd_macsec_sc_result *res = parsed_result;
13258 int ret = -ENOTSUP;
13259 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
13261 #ifdef RTE_NET_IXGBE
13263 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
13264 res->mac.addr_bytes) :
13265 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
13266 res->mac.addr_bytes, res->pi);
13268 RTE_SET_USED(is_tx);
13274 printf("invalid port_id %d\n", res->port_id);
13277 printf("not supported on port %d\n", res->port_id);
13280 printf("programming error: (%s)\n", strerror(-ret));
13284 cmdline_parse_inst_t cmd_set_macsec_sc = {
13285 .f = cmd_set_macsec_sc_parsed,
13287 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
13289 (void *)&cmd_macsec_sc_set,
13290 (void *)&cmd_macsec_sc_macsec,
13291 (void *)&cmd_macsec_sc_sc,
13292 (void *)&cmd_macsec_sc_tx_rx,
13293 (void *)&cmd_macsec_sc_port_id,
13294 (void *)&cmd_macsec_sc_mac,
13295 (void *)&cmd_macsec_sc_pi,
13300 /* Common result structure for MACsec secure connection configure */
13301 struct cmd_macsec_sa_result {
13302 cmdline_fixed_string_t set;
13303 cmdline_fixed_string_t macsec;
13304 cmdline_fixed_string_t sa;
13305 cmdline_fixed_string_t tx_rx;
13310 cmdline_fixed_string_t key;
13313 /* Common CLI fields for MACsec secure connection configure */
13314 cmdline_parse_token_string_t cmd_macsec_sa_set =
13315 TOKEN_STRING_INITIALIZER
13316 (struct cmd_macsec_sa_result,
13318 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
13319 TOKEN_STRING_INITIALIZER
13320 (struct cmd_macsec_sa_result,
13322 cmdline_parse_token_string_t cmd_macsec_sa_sa =
13323 TOKEN_STRING_INITIALIZER
13324 (struct cmd_macsec_sa_result,
13326 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
13327 TOKEN_STRING_INITIALIZER
13328 (struct cmd_macsec_sa_result,
13330 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
13331 TOKEN_NUM_INITIALIZER
13332 (struct cmd_macsec_sa_result,
13334 cmdline_parse_token_num_t cmd_macsec_sa_idx =
13335 TOKEN_NUM_INITIALIZER
13336 (struct cmd_macsec_sa_result,
13338 cmdline_parse_token_num_t cmd_macsec_sa_an =
13339 TOKEN_NUM_INITIALIZER
13340 (struct cmd_macsec_sa_result,
13342 cmdline_parse_token_num_t cmd_macsec_sa_pn =
13343 TOKEN_NUM_INITIALIZER
13344 (struct cmd_macsec_sa_result,
13346 cmdline_parse_token_string_t cmd_macsec_sa_key =
13347 TOKEN_STRING_INITIALIZER
13348 (struct cmd_macsec_sa_result,
13352 cmd_set_macsec_sa_parsed(
13353 void *parsed_result,
13354 __rte_unused struct cmdline *cl,
13355 __rte_unused void *data)
13357 struct cmd_macsec_sa_result *res = parsed_result;
13358 int ret = -ENOTSUP;
13359 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
13360 uint8_t key[16] = { 0 };
13366 key_len = strlen(res->key) / 2;
13370 for (i = 0; i < key_len; i++) {
13371 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
13374 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
13377 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
13380 #ifdef RTE_NET_IXGBE
13382 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
13383 res->idx, res->an, res->pn, key) :
13384 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
13385 res->idx, res->an, res->pn, key);
13387 RTE_SET_USED(is_tx);
13394 printf("invalid idx %d or an %d\n", res->idx, res->an);
13397 printf("invalid port_id %d\n", res->port_id);
13400 printf("not supported on port %d\n", res->port_id);
13403 printf("programming error: (%s)\n", strerror(-ret));
13407 cmdline_parse_inst_t cmd_set_macsec_sa = {
13408 .f = cmd_set_macsec_sa_parsed,
13410 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
13412 (void *)&cmd_macsec_sa_set,
13413 (void *)&cmd_macsec_sa_macsec,
13414 (void *)&cmd_macsec_sa_sa,
13415 (void *)&cmd_macsec_sa_tx_rx,
13416 (void *)&cmd_macsec_sa_port_id,
13417 (void *)&cmd_macsec_sa_idx,
13418 (void *)&cmd_macsec_sa_an,
13419 (void *)&cmd_macsec_sa_pn,
13420 (void *)&cmd_macsec_sa_key,
13425 /* VF unicast promiscuous mode configuration */
13427 /* Common result structure for VF unicast promiscuous mode */
13428 struct cmd_vf_promisc_result {
13429 cmdline_fixed_string_t set;
13430 cmdline_fixed_string_t vf;
13431 cmdline_fixed_string_t promisc;
13434 cmdline_fixed_string_t on_off;
13437 /* Common CLI fields for VF unicast promiscuous mode enable disable */
13438 cmdline_parse_token_string_t cmd_vf_promisc_set =
13439 TOKEN_STRING_INITIALIZER
13440 (struct cmd_vf_promisc_result,
13442 cmdline_parse_token_string_t cmd_vf_promisc_vf =
13443 TOKEN_STRING_INITIALIZER
13444 (struct cmd_vf_promisc_result,
13446 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
13447 TOKEN_STRING_INITIALIZER
13448 (struct cmd_vf_promisc_result,
13449 promisc, "promisc");
13450 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
13451 TOKEN_NUM_INITIALIZER
13452 (struct cmd_vf_promisc_result,
13454 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
13455 TOKEN_NUM_INITIALIZER
13456 (struct cmd_vf_promisc_result,
13458 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
13459 TOKEN_STRING_INITIALIZER
13460 (struct cmd_vf_promisc_result,
13464 cmd_set_vf_promisc_parsed(
13465 void *parsed_result,
13466 __rte_unused struct cmdline *cl,
13467 __rte_unused void *data)
13469 struct cmd_vf_promisc_result *res = parsed_result;
13470 int ret = -ENOTSUP;
13472 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13474 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13477 #ifdef RTE_NET_I40E
13478 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
13479 res->vf_id, is_on);
13486 printf("invalid vf_id %d\n", res->vf_id);
13489 printf("invalid port_id %d\n", res->port_id);
13492 printf("function not implemented\n");
13495 printf("programming error: (%s)\n", strerror(-ret));
13499 cmdline_parse_inst_t cmd_set_vf_promisc = {
13500 .f = cmd_set_vf_promisc_parsed,
13502 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
13503 "Set unicast promiscuous mode for a VF from the PF",
13505 (void *)&cmd_vf_promisc_set,
13506 (void *)&cmd_vf_promisc_vf,
13507 (void *)&cmd_vf_promisc_promisc,
13508 (void *)&cmd_vf_promisc_port_id,
13509 (void *)&cmd_vf_promisc_vf_id,
13510 (void *)&cmd_vf_promisc_on_off,
13515 /* VF multicast promiscuous mode configuration */
13517 /* Common result structure for VF multicast promiscuous mode */
13518 struct cmd_vf_allmulti_result {
13519 cmdline_fixed_string_t set;
13520 cmdline_fixed_string_t vf;
13521 cmdline_fixed_string_t allmulti;
13524 cmdline_fixed_string_t on_off;
13527 /* Common CLI fields for VF multicast promiscuous mode enable disable */
13528 cmdline_parse_token_string_t cmd_vf_allmulti_set =
13529 TOKEN_STRING_INITIALIZER
13530 (struct cmd_vf_allmulti_result,
13532 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
13533 TOKEN_STRING_INITIALIZER
13534 (struct cmd_vf_allmulti_result,
13536 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
13537 TOKEN_STRING_INITIALIZER
13538 (struct cmd_vf_allmulti_result,
13539 allmulti, "allmulti");
13540 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
13541 TOKEN_NUM_INITIALIZER
13542 (struct cmd_vf_allmulti_result,
13544 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
13545 TOKEN_NUM_INITIALIZER
13546 (struct cmd_vf_allmulti_result,
13548 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
13549 TOKEN_STRING_INITIALIZER
13550 (struct cmd_vf_allmulti_result,
13554 cmd_set_vf_allmulti_parsed(
13555 void *parsed_result,
13556 __rte_unused struct cmdline *cl,
13557 __rte_unused void *data)
13559 struct cmd_vf_allmulti_result *res = parsed_result;
13560 int ret = -ENOTSUP;
13562 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13564 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13567 #ifdef RTE_NET_I40E
13568 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
13569 res->vf_id, is_on);
13576 printf("invalid vf_id %d\n", res->vf_id);
13579 printf("invalid port_id %d\n", res->port_id);
13582 printf("function not implemented\n");
13585 printf("programming error: (%s)\n", strerror(-ret));
13589 cmdline_parse_inst_t cmd_set_vf_allmulti = {
13590 .f = cmd_set_vf_allmulti_parsed,
13592 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
13593 "Set multicast promiscuous mode for a VF from the PF",
13595 (void *)&cmd_vf_allmulti_set,
13596 (void *)&cmd_vf_allmulti_vf,
13597 (void *)&cmd_vf_allmulti_allmulti,
13598 (void *)&cmd_vf_allmulti_port_id,
13599 (void *)&cmd_vf_allmulti_vf_id,
13600 (void *)&cmd_vf_allmulti_on_off,
13605 /* vf broadcast mode configuration */
13607 /* Common result structure for vf broadcast */
13608 struct cmd_set_vf_broadcast_result {
13609 cmdline_fixed_string_t set;
13610 cmdline_fixed_string_t vf;
13611 cmdline_fixed_string_t broadcast;
13614 cmdline_fixed_string_t on_off;
13617 /* Common CLI fields for vf broadcast enable disable */
13618 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
13619 TOKEN_STRING_INITIALIZER
13620 (struct cmd_set_vf_broadcast_result,
13622 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
13623 TOKEN_STRING_INITIALIZER
13624 (struct cmd_set_vf_broadcast_result,
13626 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
13627 TOKEN_STRING_INITIALIZER
13628 (struct cmd_set_vf_broadcast_result,
13629 broadcast, "broadcast");
13630 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
13631 TOKEN_NUM_INITIALIZER
13632 (struct cmd_set_vf_broadcast_result,
13634 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
13635 TOKEN_NUM_INITIALIZER
13636 (struct cmd_set_vf_broadcast_result,
13638 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
13639 TOKEN_STRING_INITIALIZER
13640 (struct cmd_set_vf_broadcast_result,
13644 cmd_set_vf_broadcast_parsed(
13645 void *parsed_result,
13646 __rte_unused struct cmdline *cl,
13647 __rte_unused void *data)
13649 struct cmd_set_vf_broadcast_result *res = parsed_result;
13650 int ret = -ENOTSUP;
13652 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13654 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13657 #ifdef RTE_NET_I40E
13658 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
13659 res->vf_id, is_on);
13666 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13669 printf("invalid port_id %d\n", res->port_id);
13672 printf("function not implemented\n");
13675 printf("programming error: (%s)\n", strerror(-ret));
13679 cmdline_parse_inst_t cmd_set_vf_broadcast = {
13680 .f = cmd_set_vf_broadcast_parsed,
13682 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
13684 (void *)&cmd_set_vf_broadcast_set,
13685 (void *)&cmd_set_vf_broadcast_vf,
13686 (void *)&cmd_set_vf_broadcast_broadcast,
13687 (void *)&cmd_set_vf_broadcast_port_id,
13688 (void *)&cmd_set_vf_broadcast_vf_id,
13689 (void *)&cmd_set_vf_broadcast_on_off,
13694 /* vf vlan tag configuration */
13696 /* Common result structure for vf vlan tag */
13697 struct cmd_set_vf_vlan_tag_result {
13698 cmdline_fixed_string_t set;
13699 cmdline_fixed_string_t vf;
13700 cmdline_fixed_string_t vlan;
13701 cmdline_fixed_string_t tag;
13704 cmdline_fixed_string_t on_off;
13707 /* Common CLI fields for vf vlan tag enable disable */
13708 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
13709 TOKEN_STRING_INITIALIZER
13710 (struct cmd_set_vf_vlan_tag_result,
13712 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
13713 TOKEN_STRING_INITIALIZER
13714 (struct cmd_set_vf_vlan_tag_result,
13716 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
13717 TOKEN_STRING_INITIALIZER
13718 (struct cmd_set_vf_vlan_tag_result,
13720 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
13721 TOKEN_STRING_INITIALIZER
13722 (struct cmd_set_vf_vlan_tag_result,
13724 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
13725 TOKEN_NUM_INITIALIZER
13726 (struct cmd_set_vf_vlan_tag_result,
13728 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
13729 TOKEN_NUM_INITIALIZER
13730 (struct cmd_set_vf_vlan_tag_result,
13732 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
13733 TOKEN_STRING_INITIALIZER
13734 (struct cmd_set_vf_vlan_tag_result,
13738 cmd_set_vf_vlan_tag_parsed(
13739 void *parsed_result,
13740 __rte_unused struct cmdline *cl,
13741 __rte_unused void *data)
13743 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
13744 int ret = -ENOTSUP;
13746 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13748 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13751 #ifdef RTE_NET_I40E
13752 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
13753 res->vf_id, is_on);
13760 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13763 printf("invalid port_id %d\n", res->port_id);
13766 printf("function not implemented\n");
13769 printf("programming error: (%s)\n", strerror(-ret));
13773 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
13774 .f = cmd_set_vf_vlan_tag_parsed,
13776 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
13778 (void *)&cmd_set_vf_vlan_tag_set,
13779 (void *)&cmd_set_vf_vlan_tag_vf,
13780 (void *)&cmd_set_vf_vlan_tag_vlan,
13781 (void *)&cmd_set_vf_vlan_tag_tag,
13782 (void *)&cmd_set_vf_vlan_tag_port_id,
13783 (void *)&cmd_set_vf_vlan_tag_vf_id,
13784 (void *)&cmd_set_vf_vlan_tag_on_off,
13789 /* Common definition of VF and TC TX bandwidth configuration */
13790 struct cmd_vf_tc_bw_result {
13791 cmdline_fixed_string_t set;
13792 cmdline_fixed_string_t vf;
13793 cmdline_fixed_string_t tc;
13794 cmdline_fixed_string_t tx;
13795 cmdline_fixed_string_t min_bw;
13796 cmdline_fixed_string_t max_bw;
13797 cmdline_fixed_string_t strict_link_prio;
13802 cmdline_fixed_string_t bw_list;
13806 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
13807 TOKEN_STRING_INITIALIZER
13808 (struct cmd_vf_tc_bw_result,
13810 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
13811 TOKEN_STRING_INITIALIZER
13812 (struct cmd_vf_tc_bw_result,
13814 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
13815 TOKEN_STRING_INITIALIZER
13816 (struct cmd_vf_tc_bw_result,
13818 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
13819 TOKEN_STRING_INITIALIZER
13820 (struct cmd_vf_tc_bw_result,
13822 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
13823 TOKEN_STRING_INITIALIZER
13824 (struct cmd_vf_tc_bw_result,
13825 strict_link_prio, "strict-link-priority");
13826 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
13827 TOKEN_STRING_INITIALIZER
13828 (struct cmd_vf_tc_bw_result,
13829 min_bw, "min-bandwidth");
13830 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
13831 TOKEN_STRING_INITIALIZER
13832 (struct cmd_vf_tc_bw_result,
13833 max_bw, "max-bandwidth");
13834 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
13835 TOKEN_NUM_INITIALIZER
13836 (struct cmd_vf_tc_bw_result,
13838 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
13839 TOKEN_NUM_INITIALIZER
13840 (struct cmd_vf_tc_bw_result,
13842 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
13843 TOKEN_NUM_INITIALIZER
13844 (struct cmd_vf_tc_bw_result,
13846 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
13847 TOKEN_NUM_INITIALIZER
13848 (struct cmd_vf_tc_bw_result,
13850 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
13851 TOKEN_STRING_INITIALIZER
13852 (struct cmd_vf_tc_bw_result,
13854 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
13855 TOKEN_NUM_INITIALIZER
13856 (struct cmd_vf_tc_bw_result,
13859 /* VF max bandwidth setting */
13861 cmd_vf_max_bw_parsed(
13862 void *parsed_result,
13863 __rte_unused struct cmdline *cl,
13864 __rte_unused void *data)
13866 struct cmd_vf_tc_bw_result *res = parsed_result;
13867 int ret = -ENOTSUP;
13869 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13872 #ifdef RTE_NET_I40E
13873 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
13874 res->vf_id, res->bw);
13881 printf("invalid vf_id %d or bandwidth %d\n",
13882 res->vf_id, res->bw);
13885 printf("invalid port_id %d\n", res->port_id);
13888 printf("function not implemented\n");
13891 printf("programming error: (%s)\n", strerror(-ret));
13895 cmdline_parse_inst_t cmd_vf_max_bw = {
13896 .f = cmd_vf_max_bw_parsed,
13898 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
13900 (void *)&cmd_vf_tc_bw_set,
13901 (void *)&cmd_vf_tc_bw_vf,
13902 (void *)&cmd_vf_tc_bw_tx,
13903 (void *)&cmd_vf_tc_bw_max_bw,
13904 (void *)&cmd_vf_tc_bw_port_id,
13905 (void *)&cmd_vf_tc_bw_vf_id,
13906 (void *)&cmd_vf_tc_bw_bw,
13912 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
13917 const char *p, *p0 = str;
13924 p = strchr(p0, '(');
13926 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
13930 p0 = strchr(p, ')');
13932 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
13936 if (size >= sizeof(s)) {
13937 printf("The string size exceeds the internal buffer size\n");
13940 snprintf(s, sizeof(s), "%.*s", size, p);
13941 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
13943 printf("Failed to get the bandwidth list. ");
13947 for (i = 0; i < ret; i++)
13948 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
13953 /* TC min bandwidth setting */
13955 cmd_vf_tc_min_bw_parsed(
13956 void *parsed_result,
13957 __rte_unused struct cmdline *cl,
13958 __rte_unused void *data)
13960 struct cmd_vf_tc_bw_result *res = parsed_result;
13963 int ret = -ENOTSUP;
13965 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13968 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
13972 #ifdef RTE_NET_I40E
13973 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
13981 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
13984 printf("invalid port_id %d\n", res->port_id);
13987 printf("function not implemented\n");
13990 printf("programming error: (%s)\n", strerror(-ret));
13994 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
13995 .f = cmd_vf_tc_min_bw_parsed,
13997 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
13998 " <bw1, bw2, ...>",
14000 (void *)&cmd_vf_tc_bw_set,
14001 (void *)&cmd_vf_tc_bw_vf,
14002 (void *)&cmd_vf_tc_bw_tc,
14003 (void *)&cmd_vf_tc_bw_tx,
14004 (void *)&cmd_vf_tc_bw_min_bw,
14005 (void *)&cmd_vf_tc_bw_port_id,
14006 (void *)&cmd_vf_tc_bw_vf_id,
14007 (void *)&cmd_vf_tc_bw_bw_list,
14013 cmd_tc_min_bw_parsed(
14014 void *parsed_result,
14015 __rte_unused struct cmdline *cl,
14016 __rte_unused void *data)
14018 struct cmd_vf_tc_bw_result *res = parsed_result;
14019 struct rte_port *port;
14022 int ret = -ENOTSUP;
14024 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14027 port = &ports[res->port_id];
14028 /** Check if the port is not started **/
14029 if (port->port_status != RTE_PORT_STOPPED) {
14030 printf("Please stop port %d first\n", res->port_id);
14034 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
14038 #ifdef RTE_NET_IXGBE
14039 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
14046 printf("invalid bandwidth\n");
14049 printf("invalid port_id %d\n", res->port_id);
14052 printf("function not implemented\n");
14055 printf("programming error: (%s)\n", strerror(-ret));
14059 cmdline_parse_inst_t cmd_tc_min_bw = {
14060 .f = cmd_tc_min_bw_parsed,
14062 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
14064 (void *)&cmd_vf_tc_bw_set,
14065 (void *)&cmd_vf_tc_bw_tc,
14066 (void *)&cmd_vf_tc_bw_tx,
14067 (void *)&cmd_vf_tc_bw_min_bw,
14068 (void *)&cmd_vf_tc_bw_port_id,
14069 (void *)&cmd_vf_tc_bw_bw_list,
14074 /* TC max bandwidth setting */
14076 cmd_vf_tc_max_bw_parsed(
14077 void *parsed_result,
14078 __rte_unused struct cmdline *cl,
14079 __rte_unused void *data)
14081 struct cmd_vf_tc_bw_result *res = parsed_result;
14082 int ret = -ENOTSUP;
14084 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14087 #ifdef RTE_NET_I40E
14088 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
14089 res->tc_no, res->bw);
14096 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
14097 res->vf_id, res->tc_no, res->bw);
14100 printf("invalid port_id %d\n", res->port_id);
14103 printf("function not implemented\n");
14106 printf("programming error: (%s)\n", strerror(-ret));
14110 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
14111 .f = cmd_vf_tc_max_bw_parsed,
14113 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
14116 (void *)&cmd_vf_tc_bw_set,
14117 (void *)&cmd_vf_tc_bw_vf,
14118 (void *)&cmd_vf_tc_bw_tc,
14119 (void *)&cmd_vf_tc_bw_tx,
14120 (void *)&cmd_vf_tc_bw_max_bw,
14121 (void *)&cmd_vf_tc_bw_port_id,
14122 (void *)&cmd_vf_tc_bw_vf_id,
14123 (void *)&cmd_vf_tc_bw_tc_no,
14124 (void *)&cmd_vf_tc_bw_bw,
14129 /** Set VXLAN encapsulation details */
14130 struct cmd_set_vxlan_result {
14131 cmdline_fixed_string_t set;
14132 cmdline_fixed_string_t vxlan;
14133 cmdline_fixed_string_t pos_token;
14134 cmdline_fixed_string_t ip_version;
14135 uint32_t vlan_present:1;
14139 cmdline_ipaddr_t ip_src;
14140 cmdline_ipaddr_t ip_dst;
14144 struct rte_ether_addr eth_src;
14145 struct rte_ether_addr eth_dst;
14148 cmdline_parse_token_string_t cmd_set_vxlan_set =
14149 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
14150 cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
14151 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
14152 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
14153 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
14155 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
14156 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
14157 "vxlan-with-vlan");
14158 cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
14159 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
14161 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
14162 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
14164 cmdline_parse_token_string_t cmd_set_vxlan_vni =
14165 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
14167 cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
14168 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, UINT32);
14169 cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
14170 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
14172 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
14173 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, UINT16);
14174 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
14175 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
14177 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
14178 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, UINT16);
14179 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
14180 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
14182 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
14183 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, UINT8);
14184 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
14185 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
14187 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
14188 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, UINT8);
14189 cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
14190 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
14192 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
14193 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
14194 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
14195 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
14197 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
14198 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
14199 cmdline_parse_token_string_t cmd_set_vxlan_vlan =
14200 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
14202 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
14203 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, UINT16);
14204 cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
14205 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
14207 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
14208 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
14209 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
14210 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
14212 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
14213 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
14215 static void cmd_set_vxlan_parsed(void *parsed_result,
14216 __rte_unused struct cmdline *cl,
14217 __rte_unused void *data)
14219 struct cmd_set_vxlan_result *res = parsed_result;
14224 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
14227 vxlan_encap_conf.select_tos_ttl = 0;
14228 if (strcmp(res->vxlan, "vxlan") == 0)
14229 vxlan_encap_conf.select_vlan = 0;
14230 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
14231 vxlan_encap_conf.select_vlan = 1;
14232 else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
14233 vxlan_encap_conf.select_vlan = 0;
14234 vxlan_encap_conf.select_tos_ttl = 1;
14236 if (strcmp(res->ip_version, "ipv4") == 0)
14237 vxlan_encap_conf.select_ipv4 = 1;
14238 else if (strcmp(res->ip_version, "ipv6") == 0)
14239 vxlan_encap_conf.select_ipv4 = 0;
14242 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
14243 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
14244 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
14245 vxlan_encap_conf.ip_tos = res->tos;
14246 vxlan_encap_conf.ip_ttl = res->ttl;
14247 if (vxlan_encap_conf.select_ipv4) {
14248 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
14249 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
14251 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
14252 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
14254 if (vxlan_encap_conf.select_vlan)
14255 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
14256 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
14257 RTE_ETHER_ADDR_LEN);
14258 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
14259 RTE_ETHER_ADDR_LEN);
14262 cmdline_parse_inst_t cmd_set_vxlan = {
14263 .f = cmd_set_vxlan_parsed,
14265 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
14266 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
14267 " eth-src <eth-src> eth-dst <eth-dst>",
14269 (void *)&cmd_set_vxlan_set,
14270 (void *)&cmd_set_vxlan_vxlan,
14271 (void *)&cmd_set_vxlan_ip_version,
14272 (void *)&cmd_set_vxlan_ip_version_value,
14273 (void *)&cmd_set_vxlan_vni,
14274 (void *)&cmd_set_vxlan_vni_value,
14275 (void *)&cmd_set_vxlan_udp_src,
14276 (void *)&cmd_set_vxlan_udp_src_value,
14277 (void *)&cmd_set_vxlan_udp_dst,
14278 (void *)&cmd_set_vxlan_udp_dst_value,
14279 (void *)&cmd_set_vxlan_ip_src,
14280 (void *)&cmd_set_vxlan_ip_src_value,
14281 (void *)&cmd_set_vxlan_ip_dst,
14282 (void *)&cmd_set_vxlan_ip_dst_value,
14283 (void *)&cmd_set_vxlan_eth_src,
14284 (void *)&cmd_set_vxlan_eth_src_value,
14285 (void *)&cmd_set_vxlan_eth_dst,
14286 (void *)&cmd_set_vxlan_eth_dst_value,
14291 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
14292 .f = cmd_set_vxlan_parsed,
14294 .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
14295 " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
14296 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
14297 " eth-dst <eth-dst>",
14299 (void *)&cmd_set_vxlan_set,
14300 (void *)&cmd_set_vxlan_vxlan_tos_ttl,
14301 (void *)&cmd_set_vxlan_ip_version,
14302 (void *)&cmd_set_vxlan_ip_version_value,
14303 (void *)&cmd_set_vxlan_vni,
14304 (void *)&cmd_set_vxlan_vni_value,
14305 (void *)&cmd_set_vxlan_udp_src,
14306 (void *)&cmd_set_vxlan_udp_src_value,
14307 (void *)&cmd_set_vxlan_udp_dst,
14308 (void *)&cmd_set_vxlan_udp_dst_value,
14309 (void *)&cmd_set_vxlan_ip_tos,
14310 (void *)&cmd_set_vxlan_ip_tos_value,
14311 (void *)&cmd_set_vxlan_ip_ttl,
14312 (void *)&cmd_set_vxlan_ip_ttl_value,
14313 (void *)&cmd_set_vxlan_ip_src,
14314 (void *)&cmd_set_vxlan_ip_src_value,
14315 (void *)&cmd_set_vxlan_ip_dst,
14316 (void *)&cmd_set_vxlan_ip_dst_value,
14317 (void *)&cmd_set_vxlan_eth_src,
14318 (void *)&cmd_set_vxlan_eth_src_value,
14319 (void *)&cmd_set_vxlan_eth_dst,
14320 (void *)&cmd_set_vxlan_eth_dst_value,
14325 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
14326 .f = cmd_set_vxlan_parsed,
14328 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
14329 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
14330 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
14333 (void *)&cmd_set_vxlan_set,
14334 (void *)&cmd_set_vxlan_vxlan_with_vlan,
14335 (void *)&cmd_set_vxlan_ip_version,
14336 (void *)&cmd_set_vxlan_ip_version_value,
14337 (void *)&cmd_set_vxlan_vni,
14338 (void *)&cmd_set_vxlan_vni_value,
14339 (void *)&cmd_set_vxlan_udp_src,
14340 (void *)&cmd_set_vxlan_udp_src_value,
14341 (void *)&cmd_set_vxlan_udp_dst,
14342 (void *)&cmd_set_vxlan_udp_dst_value,
14343 (void *)&cmd_set_vxlan_ip_src,
14344 (void *)&cmd_set_vxlan_ip_src_value,
14345 (void *)&cmd_set_vxlan_ip_dst,
14346 (void *)&cmd_set_vxlan_ip_dst_value,
14347 (void *)&cmd_set_vxlan_vlan,
14348 (void *)&cmd_set_vxlan_vlan_value,
14349 (void *)&cmd_set_vxlan_eth_src,
14350 (void *)&cmd_set_vxlan_eth_src_value,
14351 (void *)&cmd_set_vxlan_eth_dst,
14352 (void *)&cmd_set_vxlan_eth_dst_value,
14357 /** Set NVGRE encapsulation details */
14358 struct cmd_set_nvgre_result {
14359 cmdline_fixed_string_t set;
14360 cmdline_fixed_string_t nvgre;
14361 cmdline_fixed_string_t pos_token;
14362 cmdline_fixed_string_t ip_version;
14364 cmdline_ipaddr_t ip_src;
14365 cmdline_ipaddr_t ip_dst;
14367 struct rte_ether_addr eth_src;
14368 struct rte_ether_addr eth_dst;
14371 cmdline_parse_token_string_t cmd_set_nvgre_set =
14372 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
14373 cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
14374 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
14375 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
14376 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
14377 "nvgre-with-vlan");
14378 cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
14379 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
14381 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
14382 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
14384 cmdline_parse_token_string_t cmd_set_nvgre_tni =
14385 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
14387 cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
14388 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, UINT32);
14389 cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
14390 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
14392 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
14393 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
14394 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
14395 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
14397 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
14398 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
14399 cmdline_parse_token_string_t cmd_set_nvgre_vlan =
14400 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
14402 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
14403 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, UINT16);
14404 cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
14405 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
14407 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
14408 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
14409 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
14410 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
14412 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
14413 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
14415 static void cmd_set_nvgre_parsed(void *parsed_result,
14416 __rte_unused struct cmdline *cl,
14417 __rte_unused void *data)
14419 struct cmd_set_nvgre_result *res = parsed_result;
14421 uint32_t nvgre_tni;
14424 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
14427 if (strcmp(res->nvgre, "nvgre") == 0)
14428 nvgre_encap_conf.select_vlan = 0;
14429 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
14430 nvgre_encap_conf.select_vlan = 1;
14431 if (strcmp(res->ip_version, "ipv4") == 0)
14432 nvgre_encap_conf.select_ipv4 = 1;
14433 else if (strcmp(res->ip_version, "ipv6") == 0)
14434 nvgre_encap_conf.select_ipv4 = 0;
14437 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
14438 if (nvgre_encap_conf.select_ipv4) {
14439 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
14440 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
14442 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
14443 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
14445 if (nvgre_encap_conf.select_vlan)
14446 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
14447 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
14448 RTE_ETHER_ADDR_LEN);
14449 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
14450 RTE_ETHER_ADDR_LEN);
14453 cmdline_parse_inst_t cmd_set_nvgre = {
14454 .f = cmd_set_nvgre_parsed,
14456 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
14457 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
14458 " eth-dst <eth-dst>",
14460 (void *)&cmd_set_nvgre_set,
14461 (void *)&cmd_set_nvgre_nvgre,
14462 (void *)&cmd_set_nvgre_ip_version,
14463 (void *)&cmd_set_nvgre_ip_version_value,
14464 (void *)&cmd_set_nvgre_tni,
14465 (void *)&cmd_set_nvgre_tni_value,
14466 (void *)&cmd_set_nvgre_ip_src,
14467 (void *)&cmd_set_nvgre_ip_src_value,
14468 (void *)&cmd_set_nvgre_ip_dst,
14469 (void *)&cmd_set_nvgre_ip_dst_value,
14470 (void *)&cmd_set_nvgre_eth_src,
14471 (void *)&cmd_set_nvgre_eth_src_value,
14472 (void *)&cmd_set_nvgre_eth_dst,
14473 (void *)&cmd_set_nvgre_eth_dst_value,
14478 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
14479 .f = cmd_set_nvgre_parsed,
14481 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
14482 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
14483 " eth-src <eth-src> eth-dst <eth-dst>",
14485 (void *)&cmd_set_nvgre_set,
14486 (void *)&cmd_set_nvgre_nvgre_with_vlan,
14487 (void *)&cmd_set_nvgre_ip_version,
14488 (void *)&cmd_set_nvgre_ip_version_value,
14489 (void *)&cmd_set_nvgre_tni,
14490 (void *)&cmd_set_nvgre_tni_value,
14491 (void *)&cmd_set_nvgre_ip_src,
14492 (void *)&cmd_set_nvgre_ip_src_value,
14493 (void *)&cmd_set_nvgre_ip_dst,
14494 (void *)&cmd_set_nvgre_ip_dst_value,
14495 (void *)&cmd_set_nvgre_vlan,
14496 (void *)&cmd_set_nvgre_vlan_value,
14497 (void *)&cmd_set_nvgre_eth_src,
14498 (void *)&cmd_set_nvgre_eth_src_value,
14499 (void *)&cmd_set_nvgre_eth_dst,
14500 (void *)&cmd_set_nvgre_eth_dst_value,
14505 /** Set L2 encapsulation details */
14506 struct cmd_set_l2_encap_result {
14507 cmdline_fixed_string_t set;
14508 cmdline_fixed_string_t l2_encap;
14509 cmdline_fixed_string_t pos_token;
14510 cmdline_fixed_string_t ip_version;
14511 uint32_t vlan_present:1;
14513 struct rte_ether_addr eth_src;
14514 struct rte_ether_addr eth_dst;
14517 cmdline_parse_token_string_t cmd_set_l2_encap_set =
14518 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
14519 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
14520 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
14521 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
14522 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
14523 "l2_encap-with-vlan");
14524 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
14525 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
14527 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
14528 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
14530 cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
14531 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
14533 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
14534 TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, UINT16);
14535 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
14536 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
14538 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
14539 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
14540 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
14541 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
14543 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
14544 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
14546 static void cmd_set_l2_encap_parsed(void *parsed_result,
14547 __rte_unused struct cmdline *cl,
14548 __rte_unused void *data)
14550 struct cmd_set_l2_encap_result *res = parsed_result;
14552 if (strcmp(res->l2_encap, "l2_encap") == 0)
14553 l2_encap_conf.select_vlan = 0;
14554 else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
14555 l2_encap_conf.select_vlan = 1;
14556 if (strcmp(res->ip_version, "ipv4") == 0)
14557 l2_encap_conf.select_ipv4 = 1;
14558 else if (strcmp(res->ip_version, "ipv6") == 0)
14559 l2_encap_conf.select_ipv4 = 0;
14562 if (l2_encap_conf.select_vlan)
14563 l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
14564 rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
14565 RTE_ETHER_ADDR_LEN);
14566 rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
14567 RTE_ETHER_ADDR_LEN);
14570 cmdline_parse_inst_t cmd_set_l2_encap = {
14571 .f = cmd_set_l2_encap_parsed,
14573 .help_str = "set l2_encap ip-version ipv4|ipv6"
14574 " eth-src <eth-src> eth-dst <eth-dst>",
14576 (void *)&cmd_set_l2_encap_set,
14577 (void *)&cmd_set_l2_encap_l2_encap,
14578 (void *)&cmd_set_l2_encap_ip_version,
14579 (void *)&cmd_set_l2_encap_ip_version_value,
14580 (void *)&cmd_set_l2_encap_eth_src,
14581 (void *)&cmd_set_l2_encap_eth_src_value,
14582 (void *)&cmd_set_l2_encap_eth_dst,
14583 (void *)&cmd_set_l2_encap_eth_dst_value,
14588 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
14589 .f = cmd_set_l2_encap_parsed,
14591 .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
14592 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
14594 (void *)&cmd_set_l2_encap_set,
14595 (void *)&cmd_set_l2_encap_l2_encap_with_vlan,
14596 (void *)&cmd_set_l2_encap_ip_version,
14597 (void *)&cmd_set_l2_encap_ip_version_value,
14598 (void *)&cmd_set_l2_encap_vlan,
14599 (void *)&cmd_set_l2_encap_vlan_value,
14600 (void *)&cmd_set_l2_encap_eth_src,
14601 (void *)&cmd_set_l2_encap_eth_src_value,
14602 (void *)&cmd_set_l2_encap_eth_dst,
14603 (void *)&cmd_set_l2_encap_eth_dst_value,
14608 /** Set L2 decapsulation details */
14609 struct cmd_set_l2_decap_result {
14610 cmdline_fixed_string_t set;
14611 cmdline_fixed_string_t l2_decap;
14612 cmdline_fixed_string_t pos_token;
14613 uint32_t vlan_present:1;
14616 cmdline_parse_token_string_t cmd_set_l2_decap_set =
14617 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
14618 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
14619 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
14621 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
14622 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
14623 "l2_decap-with-vlan");
14625 static void cmd_set_l2_decap_parsed(void *parsed_result,
14626 __rte_unused struct cmdline *cl,
14627 __rte_unused void *data)
14629 struct cmd_set_l2_decap_result *res = parsed_result;
14631 if (strcmp(res->l2_decap, "l2_decap") == 0)
14632 l2_decap_conf.select_vlan = 0;
14633 else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
14634 l2_decap_conf.select_vlan = 1;
14637 cmdline_parse_inst_t cmd_set_l2_decap = {
14638 .f = cmd_set_l2_decap_parsed,
14640 .help_str = "set l2_decap",
14642 (void *)&cmd_set_l2_decap_set,
14643 (void *)&cmd_set_l2_decap_l2_decap,
14648 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
14649 .f = cmd_set_l2_decap_parsed,
14651 .help_str = "set l2_decap-with-vlan",
14653 (void *)&cmd_set_l2_decap_set,
14654 (void *)&cmd_set_l2_decap_l2_decap_with_vlan,
14659 /** Set MPLSoGRE encapsulation details */
14660 struct cmd_set_mplsogre_encap_result {
14661 cmdline_fixed_string_t set;
14662 cmdline_fixed_string_t mplsogre;
14663 cmdline_fixed_string_t pos_token;
14664 cmdline_fixed_string_t ip_version;
14665 uint32_t vlan_present:1;
14667 cmdline_ipaddr_t ip_src;
14668 cmdline_ipaddr_t ip_dst;
14670 struct rte_ether_addr eth_src;
14671 struct rte_ether_addr eth_dst;
14674 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
14675 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
14677 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
14678 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
14680 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
14681 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
14682 mplsogre, "mplsogre_encap-with-vlan");
14683 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
14684 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
14685 pos_token, "ip-version");
14686 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
14687 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
14688 ip_version, "ipv4#ipv6");
14689 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
14690 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
14691 pos_token, "label");
14692 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
14693 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
14695 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
14696 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
14697 pos_token, "ip-src");
14698 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
14699 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
14700 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
14701 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
14702 pos_token, "ip-dst");
14703 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
14704 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
14705 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
14706 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
14707 pos_token, "vlan-tci");
14708 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
14709 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
14711 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
14712 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
14713 pos_token, "eth-src");
14714 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
14715 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
14717 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
14718 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
14719 pos_token, "eth-dst");
14720 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
14721 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
14724 static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
14725 __rte_unused struct cmdline *cl,
14726 __rte_unused void *data)
14728 struct cmd_set_mplsogre_encap_result *res = parsed_result;
14730 uint32_t mplsogre_label;
14733 .mplsogre_label = rte_cpu_to_be_32(res->label<<12),
14736 if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
14737 mplsogre_encap_conf.select_vlan = 0;
14738 else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
14739 mplsogre_encap_conf.select_vlan = 1;
14740 if (strcmp(res->ip_version, "ipv4") == 0)
14741 mplsogre_encap_conf.select_ipv4 = 1;
14742 else if (strcmp(res->ip_version, "ipv6") == 0)
14743 mplsogre_encap_conf.select_ipv4 = 0;
14746 rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
14747 if (mplsogre_encap_conf.select_ipv4) {
14748 IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
14749 IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
14751 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
14752 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
14754 if (mplsogre_encap_conf.select_vlan)
14755 mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
14756 rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
14757 RTE_ETHER_ADDR_LEN);
14758 rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
14759 RTE_ETHER_ADDR_LEN);
14762 cmdline_parse_inst_t cmd_set_mplsogre_encap = {
14763 .f = cmd_set_mplsogre_encap_parsed,
14765 .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
14766 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
14767 " eth-dst <eth-dst>",
14769 (void *)&cmd_set_mplsogre_encap_set,
14770 (void *)&cmd_set_mplsogre_encap_mplsogre_encap,
14771 (void *)&cmd_set_mplsogre_encap_ip_version,
14772 (void *)&cmd_set_mplsogre_encap_ip_version_value,
14773 (void *)&cmd_set_mplsogre_encap_label,
14774 (void *)&cmd_set_mplsogre_encap_label_value,
14775 (void *)&cmd_set_mplsogre_encap_ip_src,
14776 (void *)&cmd_set_mplsogre_encap_ip_src_value,
14777 (void *)&cmd_set_mplsogre_encap_ip_dst,
14778 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
14779 (void *)&cmd_set_mplsogre_encap_eth_src,
14780 (void *)&cmd_set_mplsogre_encap_eth_src_value,
14781 (void *)&cmd_set_mplsogre_encap_eth_dst,
14782 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
14787 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
14788 .f = cmd_set_mplsogre_encap_parsed,
14790 .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
14791 " label <label> ip-src <ip-src> ip-dst <ip-dst>"
14792 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
14794 (void *)&cmd_set_mplsogre_encap_set,
14795 (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
14796 (void *)&cmd_set_mplsogre_encap_ip_version,
14797 (void *)&cmd_set_mplsogre_encap_ip_version_value,
14798 (void *)&cmd_set_mplsogre_encap_label,
14799 (void *)&cmd_set_mplsogre_encap_label_value,
14800 (void *)&cmd_set_mplsogre_encap_ip_src,
14801 (void *)&cmd_set_mplsogre_encap_ip_src_value,
14802 (void *)&cmd_set_mplsogre_encap_ip_dst,
14803 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
14804 (void *)&cmd_set_mplsogre_encap_vlan,
14805 (void *)&cmd_set_mplsogre_encap_vlan_value,
14806 (void *)&cmd_set_mplsogre_encap_eth_src,
14807 (void *)&cmd_set_mplsogre_encap_eth_src_value,
14808 (void *)&cmd_set_mplsogre_encap_eth_dst,
14809 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
14814 /** Set MPLSoGRE decapsulation details */
14815 struct cmd_set_mplsogre_decap_result {
14816 cmdline_fixed_string_t set;
14817 cmdline_fixed_string_t mplsogre;
14818 cmdline_fixed_string_t pos_token;
14819 cmdline_fixed_string_t ip_version;
14820 uint32_t vlan_present:1;
14823 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
14824 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
14826 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
14827 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
14829 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
14830 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
14831 mplsogre, "mplsogre_decap-with-vlan");
14832 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
14833 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
14834 pos_token, "ip-version");
14835 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
14836 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
14837 ip_version, "ipv4#ipv6");
14839 static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
14840 __rte_unused struct cmdline *cl,
14841 __rte_unused void *data)
14843 struct cmd_set_mplsogre_decap_result *res = parsed_result;
14845 if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
14846 mplsogre_decap_conf.select_vlan = 0;
14847 else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
14848 mplsogre_decap_conf.select_vlan = 1;
14849 if (strcmp(res->ip_version, "ipv4") == 0)
14850 mplsogre_decap_conf.select_ipv4 = 1;
14851 else if (strcmp(res->ip_version, "ipv6") == 0)
14852 mplsogre_decap_conf.select_ipv4 = 0;
14855 cmdline_parse_inst_t cmd_set_mplsogre_decap = {
14856 .f = cmd_set_mplsogre_decap_parsed,
14858 .help_str = "set mplsogre_decap ip-version ipv4|ipv6",
14860 (void *)&cmd_set_mplsogre_decap_set,
14861 (void *)&cmd_set_mplsogre_decap_mplsogre_decap,
14862 (void *)&cmd_set_mplsogre_decap_ip_version,
14863 (void *)&cmd_set_mplsogre_decap_ip_version_value,
14868 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
14869 .f = cmd_set_mplsogre_decap_parsed,
14871 .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
14873 (void *)&cmd_set_mplsogre_decap_set,
14874 (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
14875 (void *)&cmd_set_mplsogre_decap_ip_version,
14876 (void *)&cmd_set_mplsogre_decap_ip_version_value,
14881 /** Set MPLSoUDP encapsulation details */
14882 struct cmd_set_mplsoudp_encap_result {
14883 cmdline_fixed_string_t set;
14884 cmdline_fixed_string_t mplsoudp;
14885 cmdline_fixed_string_t pos_token;
14886 cmdline_fixed_string_t ip_version;
14887 uint32_t vlan_present:1;
14891 cmdline_ipaddr_t ip_src;
14892 cmdline_ipaddr_t ip_dst;
14894 struct rte_ether_addr eth_src;
14895 struct rte_ether_addr eth_dst;
14898 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
14899 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
14901 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
14902 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
14904 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
14905 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
14906 mplsoudp, "mplsoudp_encap-with-vlan");
14907 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
14908 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
14909 pos_token, "ip-version");
14910 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
14911 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
14912 ip_version, "ipv4#ipv6");
14913 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
14914 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
14915 pos_token, "label");
14916 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
14917 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
14919 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
14920 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
14921 pos_token, "udp-src");
14922 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
14923 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
14925 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
14926 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
14927 pos_token, "udp-dst");
14928 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
14929 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
14931 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
14932 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
14933 pos_token, "ip-src");
14934 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
14935 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
14936 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
14937 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
14938 pos_token, "ip-dst");
14939 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
14940 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
14941 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
14942 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
14943 pos_token, "vlan-tci");
14944 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
14945 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
14947 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
14948 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
14949 pos_token, "eth-src");
14950 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
14951 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
14953 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
14954 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
14955 pos_token, "eth-dst");
14956 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
14957 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
14960 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
14961 __rte_unused struct cmdline *cl,
14962 __rte_unused void *data)
14964 struct cmd_set_mplsoudp_encap_result *res = parsed_result;
14966 uint32_t mplsoudp_label;
14969 .mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
14972 if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
14973 mplsoudp_encap_conf.select_vlan = 0;
14974 else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
14975 mplsoudp_encap_conf.select_vlan = 1;
14976 if (strcmp(res->ip_version, "ipv4") == 0)
14977 mplsoudp_encap_conf.select_ipv4 = 1;
14978 else if (strcmp(res->ip_version, "ipv6") == 0)
14979 mplsoudp_encap_conf.select_ipv4 = 0;
14982 rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
14983 mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
14984 mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
14985 if (mplsoudp_encap_conf.select_ipv4) {
14986 IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
14987 IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
14989 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
14990 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
14992 if (mplsoudp_encap_conf.select_vlan)
14993 mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
14994 rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
14995 RTE_ETHER_ADDR_LEN);
14996 rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
14997 RTE_ETHER_ADDR_LEN);
15000 cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
15001 .f = cmd_set_mplsoudp_encap_parsed,
15003 .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
15004 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
15005 " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
15007 (void *)&cmd_set_mplsoudp_encap_set,
15008 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
15009 (void *)&cmd_set_mplsoudp_encap_ip_version,
15010 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
15011 (void *)&cmd_set_mplsoudp_encap_label,
15012 (void *)&cmd_set_mplsoudp_encap_label_value,
15013 (void *)&cmd_set_mplsoudp_encap_udp_src,
15014 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
15015 (void *)&cmd_set_mplsoudp_encap_udp_dst,
15016 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
15017 (void *)&cmd_set_mplsoudp_encap_ip_src,
15018 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
15019 (void *)&cmd_set_mplsoudp_encap_ip_dst,
15020 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
15021 (void *)&cmd_set_mplsoudp_encap_eth_src,
15022 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
15023 (void *)&cmd_set_mplsoudp_encap_eth_dst,
15024 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
15029 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
15030 .f = cmd_set_mplsoudp_encap_parsed,
15032 .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
15033 " label <label> udp-src <udp-src> udp-dst <udp-dst>"
15034 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
15035 " eth-src <eth-src> eth-dst <eth-dst>",
15037 (void *)&cmd_set_mplsoudp_encap_set,
15038 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
15039 (void *)&cmd_set_mplsoudp_encap_ip_version,
15040 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
15041 (void *)&cmd_set_mplsoudp_encap_label,
15042 (void *)&cmd_set_mplsoudp_encap_label_value,
15043 (void *)&cmd_set_mplsoudp_encap_udp_src,
15044 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
15045 (void *)&cmd_set_mplsoudp_encap_udp_dst,
15046 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
15047 (void *)&cmd_set_mplsoudp_encap_ip_src,
15048 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
15049 (void *)&cmd_set_mplsoudp_encap_ip_dst,
15050 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
15051 (void *)&cmd_set_mplsoudp_encap_vlan,
15052 (void *)&cmd_set_mplsoudp_encap_vlan_value,
15053 (void *)&cmd_set_mplsoudp_encap_eth_src,
15054 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
15055 (void *)&cmd_set_mplsoudp_encap_eth_dst,
15056 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
15061 /** Set MPLSoUDP decapsulation details */
15062 struct cmd_set_mplsoudp_decap_result {
15063 cmdline_fixed_string_t set;
15064 cmdline_fixed_string_t mplsoudp;
15065 cmdline_fixed_string_t pos_token;
15066 cmdline_fixed_string_t ip_version;
15067 uint32_t vlan_present:1;
15070 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
15071 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
15073 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
15074 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
15076 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
15077 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
15078 mplsoudp, "mplsoudp_decap-with-vlan");
15079 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
15080 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
15081 pos_token, "ip-version");
15082 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
15083 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
15084 ip_version, "ipv4#ipv6");
15086 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
15087 __rte_unused struct cmdline *cl,
15088 __rte_unused void *data)
15090 struct cmd_set_mplsoudp_decap_result *res = parsed_result;
15092 if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
15093 mplsoudp_decap_conf.select_vlan = 0;
15094 else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
15095 mplsoudp_decap_conf.select_vlan = 1;
15096 if (strcmp(res->ip_version, "ipv4") == 0)
15097 mplsoudp_decap_conf.select_ipv4 = 1;
15098 else if (strcmp(res->ip_version, "ipv6") == 0)
15099 mplsoudp_decap_conf.select_ipv4 = 0;
15102 cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
15103 .f = cmd_set_mplsoudp_decap_parsed,
15105 .help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
15107 (void *)&cmd_set_mplsoudp_decap_set,
15108 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
15109 (void *)&cmd_set_mplsoudp_decap_ip_version,
15110 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
15115 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
15116 .f = cmd_set_mplsoudp_decap_parsed,
15118 .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
15120 (void *)&cmd_set_mplsoudp_decap_set,
15121 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
15122 (void *)&cmd_set_mplsoudp_decap_ip_version,
15123 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
15128 /* Strict link priority scheduling mode setting */
15130 cmd_strict_link_prio_parsed(
15131 void *parsed_result,
15132 __rte_unused struct cmdline *cl,
15133 __rte_unused void *data)
15135 struct cmd_vf_tc_bw_result *res = parsed_result;
15136 int ret = -ENOTSUP;
15138 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15141 #ifdef RTE_NET_I40E
15142 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
15149 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
15152 printf("invalid port_id %d\n", res->port_id);
15155 printf("function not implemented\n");
15158 printf("programming error: (%s)\n", strerror(-ret));
15162 cmdline_parse_inst_t cmd_strict_link_prio = {
15163 .f = cmd_strict_link_prio_parsed,
15165 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
15167 (void *)&cmd_vf_tc_bw_set,
15168 (void *)&cmd_vf_tc_bw_tx,
15169 (void *)&cmd_vf_tc_bw_strict_link_prio,
15170 (void *)&cmd_vf_tc_bw_port_id,
15171 (void *)&cmd_vf_tc_bw_tc_map,
15176 /* Load dynamic device personalization*/
15177 struct cmd_ddp_add_result {
15178 cmdline_fixed_string_t ddp;
15179 cmdline_fixed_string_t add;
15184 cmdline_parse_token_string_t cmd_ddp_add_ddp =
15185 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
15186 cmdline_parse_token_string_t cmd_ddp_add_add =
15187 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
15188 cmdline_parse_token_num_t cmd_ddp_add_port_id =
15189 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
15190 cmdline_parse_token_string_t cmd_ddp_add_filepath =
15191 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
15194 cmd_ddp_add_parsed(
15195 void *parsed_result,
15196 __rte_unused struct cmdline *cl,
15197 __rte_unused void *data)
15199 struct cmd_ddp_add_result *res = parsed_result;
15205 int ret = -ENOTSUP;
15207 if (!all_ports_stopped()) {
15208 printf("Please stop all ports first\n");
15212 filepath = strdup(res->filepath);
15213 if (filepath == NULL) {
15214 printf("Failed to allocate memory\n");
15217 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
15219 buff = open_file(file_fld[0], &size);
15221 free((void *)filepath);
15225 #ifdef RTE_NET_I40E
15226 if (ret == -ENOTSUP)
15227 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
15229 RTE_PMD_I40E_PKG_OP_WR_ADD);
15232 if (ret == -EEXIST)
15233 printf("Profile has already existed.\n");
15235 printf("Failed to load profile.\n");
15236 else if (file_num == 2)
15237 save_file(file_fld[1], buff, size);
15240 free((void *)filepath);
15243 cmdline_parse_inst_t cmd_ddp_add = {
15244 .f = cmd_ddp_add_parsed,
15246 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
15248 (void *)&cmd_ddp_add_ddp,
15249 (void *)&cmd_ddp_add_add,
15250 (void *)&cmd_ddp_add_port_id,
15251 (void *)&cmd_ddp_add_filepath,
15256 /* Delete dynamic device personalization*/
15257 struct cmd_ddp_del_result {
15258 cmdline_fixed_string_t ddp;
15259 cmdline_fixed_string_t del;
15264 cmdline_parse_token_string_t cmd_ddp_del_ddp =
15265 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
15266 cmdline_parse_token_string_t cmd_ddp_del_del =
15267 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
15268 cmdline_parse_token_num_t cmd_ddp_del_port_id =
15269 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
15270 cmdline_parse_token_string_t cmd_ddp_del_filepath =
15271 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
15274 cmd_ddp_del_parsed(
15275 void *parsed_result,
15276 __rte_unused struct cmdline *cl,
15277 __rte_unused void *data)
15279 struct cmd_ddp_del_result *res = parsed_result;
15282 int ret = -ENOTSUP;
15284 if (!all_ports_stopped()) {
15285 printf("Please stop all ports first\n");
15289 buff = open_file(res->filepath, &size);
15293 #ifdef RTE_NET_I40E
15294 if (ret == -ENOTSUP)
15295 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
15297 RTE_PMD_I40E_PKG_OP_WR_DEL);
15300 if (ret == -EACCES)
15301 printf("Profile does not exist.\n");
15303 printf("Failed to delete profile.\n");
15308 cmdline_parse_inst_t cmd_ddp_del = {
15309 .f = cmd_ddp_del_parsed,
15311 .help_str = "ddp del <port_id> <backup_profile_path>",
15313 (void *)&cmd_ddp_del_ddp,
15314 (void *)&cmd_ddp_del_del,
15315 (void *)&cmd_ddp_del_port_id,
15316 (void *)&cmd_ddp_del_filepath,
15321 /* Get dynamic device personalization profile info */
15322 struct cmd_ddp_info_result {
15323 cmdline_fixed_string_t ddp;
15324 cmdline_fixed_string_t get;
15325 cmdline_fixed_string_t info;
15329 cmdline_parse_token_string_t cmd_ddp_info_ddp =
15330 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
15331 cmdline_parse_token_string_t cmd_ddp_info_get =
15332 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
15333 cmdline_parse_token_string_t cmd_ddp_info_info =
15334 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
15335 cmdline_parse_token_string_t cmd_ddp_info_filepath =
15336 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
15339 cmd_ddp_info_parsed(
15340 void *parsed_result,
15341 __rte_unused struct cmdline *cl,
15342 __rte_unused void *data)
15344 struct cmd_ddp_info_result *res = parsed_result;
15347 int ret = -ENOTSUP;
15348 #ifdef RTE_NET_I40E
15351 uint32_t buff_size = 0;
15352 struct rte_pmd_i40e_profile_info info;
15353 uint32_t dev_num = 0;
15354 struct rte_pmd_i40e_ddp_device_id *devs;
15355 uint32_t proto_num = 0;
15356 struct rte_pmd_i40e_proto_info *proto = NULL;
15357 uint32_t pctype_num = 0;
15358 struct rte_pmd_i40e_ptype_info *pctype;
15359 uint32_t ptype_num = 0;
15360 struct rte_pmd_i40e_ptype_info *ptype;
15365 pkg = open_file(res->filepath, &pkg_size);
15369 #ifdef RTE_NET_I40E
15370 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15371 (uint8_t *)&info, sizeof(info),
15372 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
15374 printf("Global Track id: 0x%x\n", info.track_id);
15375 printf("Global Version: %d.%d.%d.%d\n",
15376 info.version.major,
15377 info.version.minor,
15378 info.version.update,
15379 info.version.draft);
15380 printf("Global Package name: %s\n\n", info.name);
15383 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15384 (uint8_t *)&info, sizeof(info),
15385 RTE_PMD_I40E_PKG_INFO_HEADER);
15387 printf("i40e Profile Track id: 0x%x\n", info.track_id);
15388 printf("i40e Profile Version: %d.%d.%d.%d\n",
15389 info.version.major,
15390 info.version.minor,
15391 info.version.update,
15392 info.version.draft);
15393 printf("i40e Profile name: %s\n\n", info.name);
15396 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15397 (uint8_t *)&buff_size, sizeof(buff_size),
15398 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
15399 if (!ret && buff_size) {
15400 buff = (uint8_t *)malloc(buff_size);
15402 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15404 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
15406 printf("Package Notes:\n%s\n\n", buff);
15411 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15412 (uint8_t *)&dev_num, sizeof(dev_num),
15413 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
15414 if (!ret && dev_num) {
15415 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
15416 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
15418 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15419 (uint8_t *)devs, buff_size,
15420 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
15422 printf("List of supported devices:\n");
15423 for (i = 0; i < dev_num; i++) {
15424 printf(" %04X:%04X %04X:%04X\n",
15425 devs[i].vendor_dev_id >> 16,
15426 devs[i].vendor_dev_id & 0xFFFF,
15427 devs[i].sub_vendor_dev_id >> 16,
15428 devs[i].sub_vendor_dev_id & 0xFFFF);
15436 /* get information about protocols and packet types */
15437 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15438 (uint8_t *)&proto_num, sizeof(proto_num),
15439 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
15440 if (ret || !proto_num)
15441 goto no_print_return;
15443 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
15444 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
15446 goto no_print_return;
15448 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
15450 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
15452 printf("List of used protocols:\n");
15453 for (i = 0; i < proto_num; i++)
15454 printf(" %2u: %s\n", proto[i].proto_id,
15458 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15459 (uint8_t *)&pctype_num, sizeof(pctype_num),
15460 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
15461 if (ret || !pctype_num)
15462 goto no_print_pctypes;
15464 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
15465 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
15467 goto no_print_pctypes;
15469 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
15471 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
15474 goto no_print_pctypes;
15477 printf("List of defined packet classification types:\n");
15478 for (i = 0; i < pctype_num; i++) {
15479 printf(" %2u:", pctype[i].ptype_id);
15480 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
15481 proto_id = pctype[i].protocols[j];
15482 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
15483 for (n = 0; n < proto_num; n++) {
15484 if (proto[n].proto_id == proto_id) {
15485 printf(" %s", proto[n].name);
15498 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
15500 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
15501 if (ret || !ptype_num)
15502 goto no_print_return;
15504 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
15505 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
15507 goto no_print_return;
15509 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
15511 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
15514 goto no_print_return;
15516 printf("List of defined packet types:\n");
15517 for (i = 0; i < ptype_num; i++) {
15518 printf(" %2u:", ptype[i].ptype_id);
15519 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
15520 proto_id = ptype[i].protocols[j];
15521 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
15522 for (n = 0; n < proto_num; n++) {
15523 if (proto[n].proto_id == proto_id) {
15524 printf(" %s", proto[n].name);
15540 if (ret == -ENOTSUP)
15541 printf("Function not supported in PMD driver\n");
15545 cmdline_parse_inst_t cmd_ddp_get_info = {
15546 .f = cmd_ddp_info_parsed,
15548 .help_str = "ddp get info <profile_path>",
15550 (void *)&cmd_ddp_info_ddp,
15551 (void *)&cmd_ddp_info_get,
15552 (void *)&cmd_ddp_info_info,
15553 (void *)&cmd_ddp_info_filepath,
15558 /* Get dynamic device personalization profile info list*/
15559 #define PROFILE_INFO_SIZE 48
15560 #define MAX_PROFILE_NUM 16
15562 struct cmd_ddp_get_list_result {
15563 cmdline_fixed_string_t ddp;
15564 cmdline_fixed_string_t get;
15565 cmdline_fixed_string_t list;
15569 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
15570 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
15571 cmdline_parse_token_string_t cmd_ddp_get_list_get =
15572 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
15573 cmdline_parse_token_string_t cmd_ddp_get_list_list =
15574 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
15575 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
15576 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
15579 cmd_ddp_get_list_parsed(
15580 __rte_unused void *parsed_result,
15581 __rte_unused struct cmdline *cl,
15582 __rte_unused void *data)
15584 #ifdef RTE_NET_I40E
15585 struct cmd_ddp_get_list_result *res = parsed_result;
15586 struct rte_pmd_i40e_profile_list *p_list;
15587 struct rte_pmd_i40e_profile_info *p_info;
15592 int ret = -ENOTSUP;
15594 #ifdef RTE_NET_I40E
15595 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
15596 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
15598 printf("%s: Failed to malloc buffer\n", __func__);
15602 if (ret == -ENOTSUP)
15603 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
15604 (uint8_t *)p_list, size);
15607 p_num = p_list->p_count;
15608 printf("Profile number is: %d\n\n", p_num);
15610 for (i = 0; i < p_num; i++) {
15611 p_info = &p_list->p_info[i];
15612 printf("Profile %d:\n", i);
15613 printf("Track id: 0x%x\n", p_info->track_id);
15614 printf("Version: %d.%d.%d.%d\n",
15615 p_info->version.major,
15616 p_info->version.minor,
15617 p_info->version.update,
15618 p_info->version.draft);
15619 printf("Profile name: %s\n\n", p_info->name);
15627 printf("Failed to get ddp list\n");
15630 cmdline_parse_inst_t cmd_ddp_get_list = {
15631 .f = cmd_ddp_get_list_parsed,
15633 .help_str = "ddp get list <port_id>",
15635 (void *)&cmd_ddp_get_list_ddp,
15636 (void *)&cmd_ddp_get_list_get,
15637 (void *)&cmd_ddp_get_list_list,
15638 (void *)&cmd_ddp_get_list_port_id,
15643 /* Configure input set */
15644 struct cmd_cfg_input_set_result {
15645 cmdline_fixed_string_t port;
15646 cmdline_fixed_string_t cfg;
15648 cmdline_fixed_string_t pctype;
15650 cmdline_fixed_string_t inset_type;
15651 cmdline_fixed_string_t opt;
15652 cmdline_fixed_string_t field;
15657 cmd_cfg_input_set_parsed(
15658 __rte_unused void *parsed_result,
15659 __rte_unused struct cmdline *cl,
15660 __rte_unused void *data)
15662 #ifdef RTE_NET_I40E
15663 struct cmd_cfg_input_set_result *res = parsed_result;
15664 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
15665 struct rte_pmd_i40e_inset inset;
15667 int ret = -ENOTSUP;
15669 if (!all_ports_stopped()) {
15670 printf("Please stop all ports first\n");
15674 #ifdef RTE_NET_I40E
15675 if (!strcmp(res->inset_type, "hash_inset"))
15676 inset_type = INSET_HASH;
15677 else if (!strcmp(res->inset_type, "fdir_inset"))
15678 inset_type = INSET_FDIR;
15679 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
15680 inset_type = INSET_FDIR_FLX;
15681 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
15682 &inset, inset_type);
15684 printf("Failed to get input set.\n");
15688 if (!strcmp(res->opt, "get")) {
15689 ret = rte_pmd_i40e_inset_field_get(inset.inset,
15692 printf("Field index %d is enabled.\n", res->field_idx);
15694 printf("Field index %d is disabled.\n", res->field_idx);
15696 } else if (!strcmp(res->opt, "set"))
15697 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
15699 else if (!strcmp(res->opt, "clear"))
15700 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
15703 printf("Failed to configure input set field.\n");
15707 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
15708 &inset, inset_type);
15710 printf("Failed to set input set.\n");
15715 if (ret == -ENOTSUP)
15716 printf("Function not supported\n");
15719 cmdline_parse_token_string_t cmd_cfg_input_set_port =
15720 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15722 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
15723 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15725 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
15726 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15728 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
15729 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15731 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
15732 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15734 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
15735 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15737 "hash_inset#fdir_inset#fdir_flx_inset");
15738 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
15739 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15740 opt, "get#set#clear");
15741 cmdline_parse_token_string_t cmd_cfg_input_set_field =
15742 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15744 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
15745 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15748 cmdline_parse_inst_t cmd_cfg_input_set = {
15749 .f = cmd_cfg_input_set_parsed,
15751 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
15752 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
15754 (void *)&cmd_cfg_input_set_port,
15755 (void *)&cmd_cfg_input_set_cfg,
15756 (void *)&cmd_cfg_input_set_port_id,
15757 (void *)&cmd_cfg_input_set_pctype,
15758 (void *)&cmd_cfg_input_set_pctype_id,
15759 (void *)&cmd_cfg_input_set_inset_type,
15760 (void *)&cmd_cfg_input_set_opt,
15761 (void *)&cmd_cfg_input_set_field,
15762 (void *)&cmd_cfg_input_set_field_idx,
15767 /* Clear input set */
15768 struct cmd_clear_input_set_result {
15769 cmdline_fixed_string_t port;
15770 cmdline_fixed_string_t cfg;
15772 cmdline_fixed_string_t pctype;
15774 cmdline_fixed_string_t inset_type;
15775 cmdline_fixed_string_t clear;
15776 cmdline_fixed_string_t all;
15780 cmd_clear_input_set_parsed(
15781 __rte_unused void *parsed_result,
15782 __rte_unused struct cmdline *cl,
15783 __rte_unused void *data)
15785 #ifdef RTE_NET_I40E
15786 struct cmd_clear_input_set_result *res = parsed_result;
15787 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
15788 struct rte_pmd_i40e_inset inset;
15790 int ret = -ENOTSUP;
15792 if (!all_ports_stopped()) {
15793 printf("Please stop all ports first\n");
15797 #ifdef RTE_NET_I40E
15798 if (!strcmp(res->inset_type, "hash_inset"))
15799 inset_type = INSET_HASH;
15800 else if (!strcmp(res->inset_type, "fdir_inset"))
15801 inset_type = INSET_FDIR;
15802 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
15803 inset_type = INSET_FDIR_FLX;
15805 memset(&inset, 0, sizeof(inset));
15807 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
15808 &inset, inset_type);
15810 printf("Failed to clear input set.\n");
15816 if (ret == -ENOTSUP)
15817 printf("Function not supported\n");
15820 cmdline_parse_token_string_t cmd_clear_input_set_port =
15821 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15823 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
15824 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15826 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
15827 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
15829 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
15830 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15832 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
15833 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
15835 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
15836 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15838 "hash_inset#fdir_inset#fdir_flx_inset");
15839 cmdline_parse_token_string_t cmd_clear_input_set_clear =
15840 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15842 cmdline_parse_token_string_t cmd_clear_input_set_all =
15843 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15846 cmdline_parse_inst_t cmd_clear_input_set = {
15847 .f = cmd_clear_input_set_parsed,
15849 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
15850 "fdir_inset|fdir_flx_inset clear all",
15852 (void *)&cmd_clear_input_set_port,
15853 (void *)&cmd_clear_input_set_cfg,
15854 (void *)&cmd_clear_input_set_port_id,
15855 (void *)&cmd_clear_input_set_pctype,
15856 (void *)&cmd_clear_input_set_pctype_id,
15857 (void *)&cmd_clear_input_set_inset_type,
15858 (void *)&cmd_clear_input_set_clear,
15859 (void *)&cmd_clear_input_set_all,
15864 /* show vf stats */
15866 /* Common result structure for show vf stats */
15867 struct cmd_show_vf_stats_result {
15868 cmdline_fixed_string_t show;
15869 cmdline_fixed_string_t vf;
15870 cmdline_fixed_string_t stats;
15875 /* Common CLI fields show vf stats*/
15876 cmdline_parse_token_string_t cmd_show_vf_stats_show =
15877 TOKEN_STRING_INITIALIZER
15878 (struct cmd_show_vf_stats_result,
15880 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
15881 TOKEN_STRING_INITIALIZER
15882 (struct cmd_show_vf_stats_result,
15884 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
15885 TOKEN_STRING_INITIALIZER
15886 (struct cmd_show_vf_stats_result,
15888 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
15889 TOKEN_NUM_INITIALIZER
15890 (struct cmd_show_vf_stats_result,
15892 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
15893 TOKEN_NUM_INITIALIZER
15894 (struct cmd_show_vf_stats_result,
15898 cmd_show_vf_stats_parsed(
15899 void *parsed_result,
15900 __rte_unused struct cmdline *cl,
15901 __rte_unused void *data)
15903 struct cmd_show_vf_stats_result *res = parsed_result;
15904 struct rte_eth_stats stats;
15905 int ret = -ENOTSUP;
15906 static const char *nic_stats_border = "########################";
15908 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15911 memset(&stats, 0, sizeof(stats));
15913 #ifdef RTE_NET_I40E
15914 if (ret == -ENOTSUP)
15915 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
15919 #ifdef RTE_NET_BNXT
15920 if (ret == -ENOTSUP)
15921 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
15930 printf("invalid vf_id %d\n", res->vf_id);
15933 printf("invalid port_id %d\n", res->port_id);
15936 printf("function not implemented\n");
15939 printf("programming error: (%s)\n", strerror(-ret));
15942 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
15943 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
15945 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
15947 stats.ipackets, stats.imissed, stats.ibytes);
15948 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
15949 printf(" RX-nombuf: %-10"PRIu64"\n",
15951 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
15953 stats.opackets, stats.oerrors, stats.obytes);
15955 printf(" %s############################%s\n",
15956 nic_stats_border, nic_stats_border);
15959 cmdline_parse_inst_t cmd_show_vf_stats = {
15960 .f = cmd_show_vf_stats_parsed,
15962 .help_str = "show vf stats <port_id> <vf_id>",
15964 (void *)&cmd_show_vf_stats_show,
15965 (void *)&cmd_show_vf_stats_vf,
15966 (void *)&cmd_show_vf_stats_stats,
15967 (void *)&cmd_show_vf_stats_port_id,
15968 (void *)&cmd_show_vf_stats_vf_id,
15973 /* clear vf stats */
15975 /* Common result structure for clear vf stats */
15976 struct cmd_clear_vf_stats_result {
15977 cmdline_fixed_string_t clear;
15978 cmdline_fixed_string_t vf;
15979 cmdline_fixed_string_t stats;
15984 /* Common CLI fields clear vf stats*/
15985 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
15986 TOKEN_STRING_INITIALIZER
15987 (struct cmd_clear_vf_stats_result,
15989 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
15990 TOKEN_STRING_INITIALIZER
15991 (struct cmd_clear_vf_stats_result,
15993 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
15994 TOKEN_STRING_INITIALIZER
15995 (struct cmd_clear_vf_stats_result,
15997 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
15998 TOKEN_NUM_INITIALIZER
15999 (struct cmd_clear_vf_stats_result,
16001 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
16002 TOKEN_NUM_INITIALIZER
16003 (struct cmd_clear_vf_stats_result,
16007 cmd_clear_vf_stats_parsed(
16008 void *parsed_result,
16009 __rte_unused struct cmdline *cl,
16010 __rte_unused void *data)
16012 struct cmd_clear_vf_stats_result *res = parsed_result;
16013 int ret = -ENOTSUP;
16015 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16018 #ifdef RTE_NET_I40E
16019 if (ret == -ENOTSUP)
16020 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
16023 #ifdef RTE_NET_BNXT
16024 if (ret == -ENOTSUP)
16025 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
16033 printf("invalid vf_id %d\n", res->vf_id);
16036 printf("invalid port_id %d\n", res->port_id);
16039 printf("function not implemented\n");
16042 printf("programming error: (%s)\n", strerror(-ret));
16046 cmdline_parse_inst_t cmd_clear_vf_stats = {
16047 .f = cmd_clear_vf_stats_parsed,
16049 .help_str = "clear vf stats <port_id> <vf_id>",
16051 (void *)&cmd_clear_vf_stats_clear,
16052 (void *)&cmd_clear_vf_stats_vf,
16053 (void *)&cmd_clear_vf_stats_stats,
16054 (void *)&cmd_clear_vf_stats_port_id,
16055 (void *)&cmd_clear_vf_stats_vf_id,
16060 /* port config pctype mapping reset */
16062 /* Common result structure for port config pctype mapping reset */
16063 struct cmd_pctype_mapping_reset_result {
16064 cmdline_fixed_string_t port;
16065 cmdline_fixed_string_t config;
16067 cmdline_fixed_string_t pctype;
16068 cmdline_fixed_string_t mapping;
16069 cmdline_fixed_string_t reset;
16072 /* Common CLI fields for port config pctype mapping reset*/
16073 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
16074 TOKEN_STRING_INITIALIZER
16075 (struct cmd_pctype_mapping_reset_result,
16077 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
16078 TOKEN_STRING_INITIALIZER
16079 (struct cmd_pctype_mapping_reset_result,
16081 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
16082 TOKEN_NUM_INITIALIZER
16083 (struct cmd_pctype_mapping_reset_result,
16085 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
16086 TOKEN_STRING_INITIALIZER
16087 (struct cmd_pctype_mapping_reset_result,
16089 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
16090 TOKEN_STRING_INITIALIZER
16091 (struct cmd_pctype_mapping_reset_result,
16092 mapping, "mapping");
16093 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
16094 TOKEN_STRING_INITIALIZER
16095 (struct cmd_pctype_mapping_reset_result,
16099 cmd_pctype_mapping_reset_parsed(
16100 void *parsed_result,
16101 __rte_unused struct cmdline *cl,
16102 __rte_unused void *data)
16104 struct cmd_pctype_mapping_reset_result *res = parsed_result;
16105 int ret = -ENOTSUP;
16107 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16110 #ifdef RTE_NET_I40E
16111 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
16118 printf("invalid port_id %d\n", res->port_id);
16121 printf("function not implemented\n");
16124 printf("programming error: (%s)\n", strerror(-ret));
16128 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
16129 .f = cmd_pctype_mapping_reset_parsed,
16131 .help_str = "port config <port_id> pctype mapping reset",
16133 (void *)&cmd_pctype_mapping_reset_port,
16134 (void *)&cmd_pctype_mapping_reset_config,
16135 (void *)&cmd_pctype_mapping_reset_port_id,
16136 (void *)&cmd_pctype_mapping_reset_pctype,
16137 (void *)&cmd_pctype_mapping_reset_mapping,
16138 (void *)&cmd_pctype_mapping_reset_reset,
16143 /* show port pctype mapping */
16145 /* Common result structure for show port pctype mapping */
16146 struct cmd_pctype_mapping_get_result {
16147 cmdline_fixed_string_t show;
16148 cmdline_fixed_string_t port;
16150 cmdline_fixed_string_t pctype;
16151 cmdline_fixed_string_t mapping;
16154 /* Common CLI fields for pctype mapping get */
16155 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
16156 TOKEN_STRING_INITIALIZER
16157 (struct cmd_pctype_mapping_get_result,
16159 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
16160 TOKEN_STRING_INITIALIZER
16161 (struct cmd_pctype_mapping_get_result,
16163 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
16164 TOKEN_NUM_INITIALIZER
16165 (struct cmd_pctype_mapping_get_result,
16167 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
16168 TOKEN_STRING_INITIALIZER
16169 (struct cmd_pctype_mapping_get_result,
16171 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
16172 TOKEN_STRING_INITIALIZER
16173 (struct cmd_pctype_mapping_get_result,
16174 mapping, "mapping");
16177 cmd_pctype_mapping_get_parsed(
16178 void *parsed_result,
16179 __rte_unused struct cmdline *cl,
16180 __rte_unused void *data)
16182 struct cmd_pctype_mapping_get_result *res = parsed_result;
16183 int ret = -ENOTSUP;
16184 #ifdef RTE_NET_I40E
16185 struct rte_pmd_i40e_flow_type_mapping
16186 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
16187 int i, j, first_pctype;
16190 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16193 #ifdef RTE_NET_I40E
16194 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
16201 printf("invalid port_id %d\n", res->port_id);
16204 printf("function not implemented\n");
16207 printf("programming error: (%s)\n", strerror(-ret));
16211 #ifdef RTE_NET_I40E
16212 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
16213 if (mapping[i].pctype != 0ULL) {
16216 printf("pctype: ");
16217 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
16218 if (mapping[i].pctype & (1ULL << j)) {
16219 printf(first_pctype ?
16220 "%02d" : ",%02d", j);
16224 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
16230 cmdline_parse_inst_t cmd_pctype_mapping_get = {
16231 .f = cmd_pctype_mapping_get_parsed,
16233 .help_str = "show port <port_id> pctype mapping",
16235 (void *)&cmd_pctype_mapping_get_show,
16236 (void *)&cmd_pctype_mapping_get_port,
16237 (void *)&cmd_pctype_mapping_get_port_id,
16238 (void *)&cmd_pctype_mapping_get_pctype,
16239 (void *)&cmd_pctype_mapping_get_mapping,
16244 /* port config pctype mapping update */
16246 /* Common result structure for port config pctype mapping update */
16247 struct cmd_pctype_mapping_update_result {
16248 cmdline_fixed_string_t port;
16249 cmdline_fixed_string_t config;
16251 cmdline_fixed_string_t pctype;
16252 cmdline_fixed_string_t mapping;
16253 cmdline_fixed_string_t update;
16254 cmdline_fixed_string_t pctype_list;
16255 uint16_t flow_type;
16258 /* Common CLI fields for pctype mapping update*/
16259 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
16260 TOKEN_STRING_INITIALIZER
16261 (struct cmd_pctype_mapping_update_result,
16263 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
16264 TOKEN_STRING_INITIALIZER
16265 (struct cmd_pctype_mapping_update_result,
16267 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
16268 TOKEN_NUM_INITIALIZER
16269 (struct cmd_pctype_mapping_update_result,
16271 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
16272 TOKEN_STRING_INITIALIZER
16273 (struct cmd_pctype_mapping_update_result,
16275 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
16276 TOKEN_STRING_INITIALIZER
16277 (struct cmd_pctype_mapping_update_result,
16278 mapping, "mapping");
16279 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
16280 TOKEN_STRING_INITIALIZER
16281 (struct cmd_pctype_mapping_update_result,
16283 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
16284 TOKEN_STRING_INITIALIZER
16285 (struct cmd_pctype_mapping_update_result,
16286 pctype_list, NULL);
16287 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
16288 TOKEN_NUM_INITIALIZER
16289 (struct cmd_pctype_mapping_update_result,
16290 flow_type, UINT16);
16293 cmd_pctype_mapping_update_parsed(
16294 void *parsed_result,
16295 __rte_unused struct cmdline *cl,
16296 __rte_unused void *data)
16298 struct cmd_pctype_mapping_update_result *res = parsed_result;
16299 int ret = -ENOTSUP;
16300 #ifdef RTE_NET_I40E
16301 struct rte_pmd_i40e_flow_type_mapping mapping;
16303 unsigned int nb_item;
16304 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
16307 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16310 #ifdef RTE_NET_I40E
16311 nb_item = parse_item_list(res->pctype_list, "pctypes",
16312 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
16313 mapping.flow_type = res->flow_type;
16314 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
16315 mapping.pctype |= (1ULL << pctype_list[i]);
16316 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
16326 printf("invalid pctype or flow type\n");
16329 printf("invalid port_id %d\n", res->port_id);
16332 printf("function not implemented\n");
16335 printf("programming error: (%s)\n", strerror(-ret));
16339 cmdline_parse_inst_t cmd_pctype_mapping_update = {
16340 .f = cmd_pctype_mapping_update_parsed,
16342 .help_str = "port config <port_id> pctype mapping update"
16343 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
16345 (void *)&cmd_pctype_mapping_update_port,
16346 (void *)&cmd_pctype_mapping_update_config,
16347 (void *)&cmd_pctype_mapping_update_port_id,
16348 (void *)&cmd_pctype_mapping_update_pctype,
16349 (void *)&cmd_pctype_mapping_update_mapping,
16350 (void *)&cmd_pctype_mapping_update_update,
16351 (void *)&cmd_pctype_mapping_update_pc_type,
16352 (void *)&cmd_pctype_mapping_update_flow_type,
16357 /* ptype mapping get */
16359 /* Common result structure for ptype mapping get */
16360 struct cmd_ptype_mapping_get_result {
16361 cmdline_fixed_string_t ptype;
16362 cmdline_fixed_string_t mapping;
16363 cmdline_fixed_string_t get;
16365 uint8_t valid_only;
16368 /* Common CLI fields for ptype mapping get */
16369 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
16370 TOKEN_STRING_INITIALIZER
16371 (struct cmd_ptype_mapping_get_result,
16373 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
16374 TOKEN_STRING_INITIALIZER
16375 (struct cmd_ptype_mapping_get_result,
16376 mapping, "mapping");
16377 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
16378 TOKEN_STRING_INITIALIZER
16379 (struct cmd_ptype_mapping_get_result,
16381 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
16382 TOKEN_NUM_INITIALIZER
16383 (struct cmd_ptype_mapping_get_result,
16385 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
16386 TOKEN_NUM_INITIALIZER
16387 (struct cmd_ptype_mapping_get_result,
16388 valid_only, UINT8);
16391 cmd_ptype_mapping_get_parsed(
16392 void *parsed_result,
16393 __rte_unused struct cmdline *cl,
16394 __rte_unused void *data)
16396 struct cmd_ptype_mapping_get_result *res = parsed_result;
16397 int ret = -ENOTSUP;
16398 #ifdef RTE_NET_I40E
16399 int max_ptype_num = 256;
16400 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
16405 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16408 #ifdef RTE_NET_I40E
16409 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
16420 printf("invalid port_id %d\n", res->port_id);
16423 printf("function not implemented\n");
16426 printf("programming error: (%s)\n", strerror(-ret));
16429 #ifdef RTE_NET_I40E
16431 for (i = 0; i < count; i++)
16432 printf("%3d\t0x%08x\n",
16433 mapping[i].hw_ptype, mapping[i].sw_ptype);
16438 cmdline_parse_inst_t cmd_ptype_mapping_get = {
16439 .f = cmd_ptype_mapping_get_parsed,
16441 .help_str = "ptype mapping get <port_id> <valid_only>",
16443 (void *)&cmd_ptype_mapping_get_ptype,
16444 (void *)&cmd_ptype_mapping_get_mapping,
16445 (void *)&cmd_ptype_mapping_get_get,
16446 (void *)&cmd_ptype_mapping_get_port_id,
16447 (void *)&cmd_ptype_mapping_get_valid_only,
16452 /* ptype mapping replace */
16454 /* Common result structure for ptype mapping replace */
16455 struct cmd_ptype_mapping_replace_result {
16456 cmdline_fixed_string_t ptype;
16457 cmdline_fixed_string_t mapping;
16458 cmdline_fixed_string_t replace;
16465 /* Common CLI fields for ptype mapping replace */
16466 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
16467 TOKEN_STRING_INITIALIZER
16468 (struct cmd_ptype_mapping_replace_result,
16470 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
16471 TOKEN_STRING_INITIALIZER
16472 (struct cmd_ptype_mapping_replace_result,
16473 mapping, "mapping");
16474 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
16475 TOKEN_STRING_INITIALIZER
16476 (struct cmd_ptype_mapping_replace_result,
16477 replace, "replace");
16478 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
16479 TOKEN_NUM_INITIALIZER
16480 (struct cmd_ptype_mapping_replace_result,
16482 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
16483 TOKEN_NUM_INITIALIZER
16484 (struct cmd_ptype_mapping_replace_result,
16486 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
16487 TOKEN_NUM_INITIALIZER
16488 (struct cmd_ptype_mapping_replace_result,
16490 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
16491 TOKEN_NUM_INITIALIZER
16492 (struct cmd_ptype_mapping_replace_result,
16496 cmd_ptype_mapping_replace_parsed(
16497 void *parsed_result,
16498 __rte_unused struct cmdline *cl,
16499 __rte_unused void *data)
16501 struct cmd_ptype_mapping_replace_result *res = parsed_result;
16502 int ret = -ENOTSUP;
16504 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16507 #ifdef RTE_NET_I40E
16508 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
16518 printf("invalid ptype 0x%8x or 0x%8x\n",
16519 res->target, res->pkt_type);
16522 printf("invalid port_id %d\n", res->port_id);
16525 printf("function not implemented\n");
16528 printf("programming error: (%s)\n", strerror(-ret));
16532 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
16533 .f = cmd_ptype_mapping_replace_parsed,
16536 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
16538 (void *)&cmd_ptype_mapping_replace_ptype,
16539 (void *)&cmd_ptype_mapping_replace_mapping,
16540 (void *)&cmd_ptype_mapping_replace_replace,
16541 (void *)&cmd_ptype_mapping_replace_port_id,
16542 (void *)&cmd_ptype_mapping_replace_target,
16543 (void *)&cmd_ptype_mapping_replace_mask,
16544 (void *)&cmd_ptype_mapping_replace_pkt_type,
16549 /* ptype mapping reset */
16551 /* Common result structure for ptype mapping reset */
16552 struct cmd_ptype_mapping_reset_result {
16553 cmdline_fixed_string_t ptype;
16554 cmdline_fixed_string_t mapping;
16555 cmdline_fixed_string_t reset;
16559 /* Common CLI fields for ptype mapping reset*/
16560 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
16561 TOKEN_STRING_INITIALIZER
16562 (struct cmd_ptype_mapping_reset_result,
16564 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
16565 TOKEN_STRING_INITIALIZER
16566 (struct cmd_ptype_mapping_reset_result,
16567 mapping, "mapping");
16568 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
16569 TOKEN_STRING_INITIALIZER
16570 (struct cmd_ptype_mapping_reset_result,
16572 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
16573 TOKEN_NUM_INITIALIZER
16574 (struct cmd_ptype_mapping_reset_result,
16578 cmd_ptype_mapping_reset_parsed(
16579 void *parsed_result,
16580 __rte_unused struct cmdline *cl,
16581 __rte_unused void *data)
16583 struct cmd_ptype_mapping_reset_result *res = parsed_result;
16584 int ret = -ENOTSUP;
16586 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16589 #ifdef RTE_NET_I40E
16590 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
16597 printf("invalid port_id %d\n", res->port_id);
16600 printf("function not implemented\n");
16603 printf("programming error: (%s)\n", strerror(-ret));
16607 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
16608 .f = cmd_ptype_mapping_reset_parsed,
16610 .help_str = "ptype mapping reset <port_id>",
16612 (void *)&cmd_ptype_mapping_reset_ptype,
16613 (void *)&cmd_ptype_mapping_reset_mapping,
16614 (void *)&cmd_ptype_mapping_reset_reset,
16615 (void *)&cmd_ptype_mapping_reset_port_id,
16620 /* ptype mapping update */
16622 /* Common result structure for ptype mapping update */
16623 struct cmd_ptype_mapping_update_result {
16624 cmdline_fixed_string_t ptype;
16625 cmdline_fixed_string_t mapping;
16626 cmdline_fixed_string_t reset;
16632 /* Common CLI fields for ptype mapping update*/
16633 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
16634 TOKEN_STRING_INITIALIZER
16635 (struct cmd_ptype_mapping_update_result,
16637 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
16638 TOKEN_STRING_INITIALIZER
16639 (struct cmd_ptype_mapping_update_result,
16640 mapping, "mapping");
16641 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
16642 TOKEN_STRING_INITIALIZER
16643 (struct cmd_ptype_mapping_update_result,
16645 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
16646 TOKEN_NUM_INITIALIZER
16647 (struct cmd_ptype_mapping_update_result,
16649 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
16650 TOKEN_NUM_INITIALIZER
16651 (struct cmd_ptype_mapping_update_result,
16653 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
16654 TOKEN_NUM_INITIALIZER
16655 (struct cmd_ptype_mapping_update_result,
16659 cmd_ptype_mapping_update_parsed(
16660 void *parsed_result,
16661 __rte_unused struct cmdline *cl,
16662 __rte_unused void *data)
16664 struct cmd_ptype_mapping_update_result *res = parsed_result;
16665 int ret = -ENOTSUP;
16666 #ifdef RTE_NET_I40E
16667 struct rte_pmd_i40e_ptype_mapping mapping;
16669 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16672 #ifdef RTE_NET_I40E
16673 mapping.hw_ptype = res->hw_ptype;
16674 mapping.sw_ptype = res->sw_ptype;
16675 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
16685 printf("invalid ptype 0x%8x\n", res->sw_ptype);
16688 printf("invalid port_id %d\n", res->port_id);
16691 printf("function not implemented\n");
16694 printf("programming error: (%s)\n", strerror(-ret));
16698 cmdline_parse_inst_t cmd_ptype_mapping_update = {
16699 .f = cmd_ptype_mapping_update_parsed,
16701 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
16703 (void *)&cmd_ptype_mapping_update_ptype,
16704 (void *)&cmd_ptype_mapping_update_mapping,
16705 (void *)&cmd_ptype_mapping_update_update,
16706 (void *)&cmd_ptype_mapping_update_port_id,
16707 (void *)&cmd_ptype_mapping_update_hw_ptype,
16708 (void *)&cmd_ptype_mapping_update_sw_ptype,
16713 /* Common result structure for file commands */
16714 struct cmd_cmdfile_result {
16715 cmdline_fixed_string_t load;
16716 cmdline_fixed_string_t filename;
16719 /* Common CLI fields for file commands */
16720 cmdline_parse_token_string_t cmd_load_cmdfile =
16721 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
16722 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
16723 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
16726 cmd_load_from_file_parsed(
16727 void *parsed_result,
16728 __rte_unused struct cmdline *cl,
16729 __rte_unused void *data)
16731 struct cmd_cmdfile_result *res = parsed_result;
16733 cmdline_read_from_file(res->filename);
16736 cmdline_parse_inst_t cmd_load_from_file = {
16737 .f = cmd_load_from_file_parsed,
16739 .help_str = "load <filename>",
16741 (void *)&cmd_load_cmdfile,
16742 (void *)&cmd_load_cmdfile_filename,
16747 /* Get Rx offloads capabilities */
16748 struct cmd_rx_offload_get_capa_result {
16749 cmdline_fixed_string_t show;
16750 cmdline_fixed_string_t port;
16752 cmdline_fixed_string_t rx_offload;
16753 cmdline_fixed_string_t capabilities;
16756 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
16757 TOKEN_STRING_INITIALIZER
16758 (struct cmd_rx_offload_get_capa_result,
16760 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
16761 TOKEN_STRING_INITIALIZER
16762 (struct cmd_rx_offload_get_capa_result,
16764 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
16765 TOKEN_NUM_INITIALIZER
16766 (struct cmd_rx_offload_get_capa_result,
16768 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
16769 TOKEN_STRING_INITIALIZER
16770 (struct cmd_rx_offload_get_capa_result,
16771 rx_offload, "rx_offload");
16772 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
16773 TOKEN_STRING_INITIALIZER
16774 (struct cmd_rx_offload_get_capa_result,
16775 capabilities, "capabilities");
16778 print_rx_offloads(uint64_t offloads)
16780 uint64_t single_offload;
16788 begin = __builtin_ctzll(offloads);
16789 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
16791 single_offload = 1ULL << begin;
16792 for (bit = begin; bit < end; bit++) {
16793 if (offloads & single_offload)
16795 rte_eth_dev_rx_offload_name(single_offload));
16796 single_offload <<= 1;
16801 cmd_rx_offload_get_capa_parsed(
16802 void *parsed_result,
16803 __rte_unused struct cmdline *cl,
16804 __rte_unused void *data)
16806 struct cmd_rx_offload_get_capa_result *res = parsed_result;
16807 struct rte_eth_dev_info dev_info;
16808 portid_t port_id = res->port_id;
16809 uint64_t queue_offloads;
16810 uint64_t port_offloads;
16813 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16817 queue_offloads = dev_info.rx_queue_offload_capa;
16818 port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
16820 printf("Rx Offloading Capabilities of port %d :\n", port_id);
16821 printf(" Per Queue :");
16822 print_rx_offloads(queue_offloads);
16825 printf(" Per Port :");
16826 print_rx_offloads(port_offloads);
16830 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
16831 .f = cmd_rx_offload_get_capa_parsed,
16833 .help_str = "show port <port_id> rx_offload capabilities",
16835 (void *)&cmd_rx_offload_get_capa_show,
16836 (void *)&cmd_rx_offload_get_capa_port,
16837 (void *)&cmd_rx_offload_get_capa_port_id,
16838 (void *)&cmd_rx_offload_get_capa_rx_offload,
16839 (void *)&cmd_rx_offload_get_capa_capabilities,
16844 /* Get Rx offloads configuration */
16845 struct cmd_rx_offload_get_configuration_result {
16846 cmdline_fixed_string_t show;
16847 cmdline_fixed_string_t port;
16849 cmdline_fixed_string_t rx_offload;
16850 cmdline_fixed_string_t configuration;
16853 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
16854 TOKEN_STRING_INITIALIZER
16855 (struct cmd_rx_offload_get_configuration_result,
16857 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
16858 TOKEN_STRING_INITIALIZER
16859 (struct cmd_rx_offload_get_configuration_result,
16861 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
16862 TOKEN_NUM_INITIALIZER
16863 (struct cmd_rx_offload_get_configuration_result,
16865 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
16866 TOKEN_STRING_INITIALIZER
16867 (struct cmd_rx_offload_get_configuration_result,
16868 rx_offload, "rx_offload");
16869 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
16870 TOKEN_STRING_INITIALIZER
16871 (struct cmd_rx_offload_get_configuration_result,
16872 configuration, "configuration");
16875 cmd_rx_offload_get_configuration_parsed(
16876 void *parsed_result,
16877 __rte_unused struct cmdline *cl,
16878 __rte_unused void *data)
16880 struct cmd_rx_offload_get_configuration_result *res = parsed_result;
16881 struct rte_eth_dev_info dev_info;
16882 portid_t port_id = res->port_id;
16883 struct rte_port *port = &ports[port_id];
16884 uint64_t port_offloads;
16885 uint64_t queue_offloads;
16886 uint16_t nb_rx_queues;
16890 printf("Rx Offloading Configuration of port %d :\n", port_id);
16892 port_offloads = port->dev_conf.rxmode.offloads;
16894 print_rx_offloads(port_offloads);
16897 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16901 nb_rx_queues = dev_info.nb_rx_queues;
16902 for (q = 0; q < nb_rx_queues; q++) {
16903 queue_offloads = port->rx_conf[q].offloads;
16904 printf(" Queue[%2d] :", q);
16905 print_rx_offloads(queue_offloads);
16911 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
16912 .f = cmd_rx_offload_get_configuration_parsed,
16914 .help_str = "show port <port_id> rx_offload configuration",
16916 (void *)&cmd_rx_offload_get_configuration_show,
16917 (void *)&cmd_rx_offload_get_configuration_port,
16918 (void *)&cmd_rx_offload_get_configuration_port_id,
16919 (void *)&cmd_rx_offload_get_configuration_rx_offload,
16920 (void *)&cmd_rx_offload_get_configuration_configuration,
16925 /* Enable/Disable a per port offloading */
16926 struct cmd_config_per_port_rx_offload_result {
16927 cmdline_fixed_string_t port;
16928 cmdline_fixed_string_t config;
16930 cmdline_fixed_string_t rx_offload;
16931 cmdline_fixed_string_t offload;
16932 cmdline_fixed_string_t on_off;
16935 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
16936 TOKEN_STRING_INITIALIZER
16937 (struct cmd_config_per_port_rx_offload_result,
16939 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
16940 TOKEN_STRING_INITIALIZER
16941 (struct cmd_config_per_port_rx_offload_result,
16943 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
16944 TOKEN_NUM_INITIALIZER
16945 (struct cmd_config_per_port_rx_offload_result,
16947 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
16948 TOKEN_STRING_INITIALIZER
16949 (struct cmd_config_per_port_rx_offload_result,
16950 rx_offload, "rx_offload");
16951 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
16952 TOKEN_STRING_INITIALIZER
16953 (struct cmd_config_per_port_rx_offload_result,
16954 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
16955 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
16956 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
16957 "scatter#buffer_split#timestamp#security#"
16958 "keep_crc#rss_hash");
16959 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
16960 TOKEN_STRING_INITIALIZER
16961 (struct cmd_config_per_port_rx_offload_result,
16965 search_rx_offload(const char *name)
16967 uint64_t single_offload;
16968 const char *single_name;
16972 single_offload = 1;
16973 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
16974 single_name = rte_eth_dev_rx_offload_name(single_offload);
16975 if (!strcasecmp(single_name, name)) {
16979 single_offload <<= 1;
16983 return single_offload;
16989 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
16990 __rte_unused struct cmdline *cl,
16991 __rte_unused void *data)
16993 struct cmd_config_per_port_rx_offload_result *res = parsed_result;
16994 portid_t port_id = res->port_id;
16995 struct rte_eth_dev_info dev_info;
16996 struct rte_port *port = &ports[port_id];
16997 uint64_t single_offload;
16998 uint16_t nb_rx_queues;
17002 if (port->port_status != RTE_PORT_STOPPED) {
17003 printf("Error: Can't config offload when Port %d "
17004 "is not stopped\n", port_id);
17008 single_offload = search_rx_offload(res->offload);
17009 if (single_offload == 0) {
17010 printf("Unknown offload name: %s\n", res->offload);
17014 ret = eth_dev_info_get_print_err(port_id, &dev_info);
17018 nb_rx_queues = dev_info.nb_rx_queues;
17019 if (!strcmp(res->on_off, "on")) {
17020 port->dev_conf.rxmode.offloads |= single_offload;
17021 for (q = 0; q < nb_rx_queues; q++)
17022 port->rx_conf[q].offloads |= single_offload;
17024 port->dev_conf.rxmode.offloads &= ~single_offload;
17025 for (q = 0; q < nb_rx_queues; q++)
17026 port->rx_conf[q].offloads &= ~single_offload;
17029 cmd_reconfig_device_queue(port_id, 1, 1);
17032 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
17033 .f = cmd_config_per_port_rx_offload_parsed,
17035 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
17036 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
17037 "macsec_strip|header_split|vlan_filter|vlan_extend|"
17038 "jumbo_frame|scatter|buffer_split|timestamp|security|"
17039 "keep_crc|rss_hash on|off",
17041 (void *)&cmd_config_per_port_rx_offload_result_port,
17042 (void *)&cmd_config_per_port_rx_offload_result_config,
17043 (void *)&cmd_config_per_port_rx_offload_result_port_id,
17044 (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
17045 (void *)&cmd_config_per_port_rx_offload_result_offload,
17046 (void *)&cmd_config_per_port_rx_offload_result_on_off,
17051 /* Enable/Disable a per queue offloading */
17052 struct cmd_config_per_queue_rx_offload_result {
17053 cmdline_fixed_string_t port;
17055 cmdline_fixed_string_t rxq;
17057 cmdline_fixed_string_t rx_offload;
17058 cmdline_fixed_string_t offload;
17059 cmdline_fixed_string_t on_off;
17062 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
17063 TOKEN_STRING_INITIALIZER
17064 (struct cmd_config_per_queue_rx_offload_result,
17066 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
17067 TOKEN_NUM_INITIALIZER
17068 (struct cmd_config_per_queue_rx_offload_result,
17070 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
17071 TOKEN_STRING_INITIALIZER
17072 (struct cmd_config_per_queue_rx_offload_result,
17074 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
17075 TOKEN_NUM_INITIALIZER
17076 (struct cmd_config_per_queue_rx_offload_result,
17078 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
17079 TOKEN_STRING_INITIALIZER
17080 (struct cmd_config_per_queue_rx_offload_result,
17081 rx_offload, "rx_offload");
17082 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
17083 TOKEN_STRING_INITIALIZER
17084 (struct cmd_config_per_queue_rx_offload_result,
17085 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
17086 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
17087 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
17088 "scatter#buffer_split#timestamp#security#keep_crc");
17089 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
17090 TOKEN_STRING_INITIALIZER
17091 (struct cmd_config_per_queue_rx_offload_result,
17095 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
17096 __rte_unused struct cmdline *cl,
17097 __rte_unused void *data)
17099 struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
17100 struct rte_eth_dev_info dev_info;
17101 portid_t port_id = res->port_id;
17102 uint16_t queue_id = res->queue_id;
17103 struct rte_port *port = &ports[port_id];
17104 uint64_t single_offload;
17107 if (port->port_status != RTE_PORT_STOPPED) {
17108 printf("Error: Can't config offload when Port %d "
17109 "is not stopped\n", port_id);
17113 ret = eth_dev_info_get_print_err(port_id, &dev_info);
17117 if (queue_id >= dev_info.nb_rx_queues) {
17118 printf("Error: input queue_id should be 0 ... "
17119 "%d\n", dev_info.nb_rx_queues - 1);
17123 single_offload = search_rx_offload(res->offload);
17124 if (single_offload == 0) {
17125 printf("Unknown offload name: %s\n", res->offload);
17129 if (!strcmp(res->on_off, "on"))
17130 port->rx_conf[queue_id].offloads |= single_offload;
17132 port->rx_conf[queue_id].offloads &= ~single_offload;
17134 cmd_reconfig_device_queue(port_id, 1, 1);
17137 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
17138 .f = cmd_config_per_queue_rx_offload_parsed,
17140 .help_str = "port <port_id> rxq <queue_id> rx_offload "
17141 "vlan_strip|ipv4_cksum|"
17142 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
17143 "macsec_strip|header_split|vlan_filter|vlan_extend|"
17144 "jumbo_frame|scatter|buffer_split|timestamp|security|"
17147 (void *)&cmd_config_per_queue_rx_offload_result_port,
17148 (void *)&cmd_config_per_queue_rx_offload_result_port_id,
17149 (void *)&cmd_config_per_queue_rx_offload_result_rxq,
17150 (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
17151 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
17152 (void *)&cmd_config_per_queue_rx_offload_result_offload,
17153 (void *)&cmd_config_per_queue_rx_offload_result_on_off,
17158 /* Get Tx offloads capabilities */
17159 struct cmd_tx_offload_get_capa_result {
17160 cmdline_fixed_string_t show;
17161 cmdline_fixed_string_t port;
17163 cmdline_fixed_string_t tx_offload;
17164 cmdline_fixed_string_t capabilities;
17167 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
17168 TOKEN_STRING_INITIALIZER
17169 (struct cmd_tx_offload_get_capa_result,
17171 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
17172 TOKEN_STRING_INITIALIZER
17173 (struct cmd_tx_offload_get_capa_result,
17175 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
17176 TOKEN_NUM_INITIALIZER
17177 (struct cmd_tx_offload_get_capa_result,
17179 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
17180 TOKEN_STRING_INITIALIZER
17181 (struct cmd_tx_offload_get_capa_result,
17182 tx_offload, "tx_offload");
17183 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
17184 TOKEN_STRING_INITIALIZER
17185 (struct cmd_tx_offload_get_capa_result,
17186 capabilities, "capabilities");
17189 print_tx_offloads(uint64_t offloads)
17191 uint64_t single_offload;
17199 begin = __builtin_ctzll(offloads);
17200 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
17202 single_offload = 1ULL << begin;
17203 for (bit = begin; bit < end; bit++) {
17204 if (offloads & single_offload)
17206 rte_eth_dev_tx_offload_name(single_offload));
17207 single_offload <<= 1;
17212 cmd_tx_offload_get_capa_parsed(
17213 void *parsed_result,
17214 __rte_unused struct cmdline *cl,
17215 __rte_unused void *data)
17217 struct cmd_tx_offload_get_capa_result *res = parsed_result;
17218 struct rte_eth_dev_info dev_info;
17219 portid_t port_id = res->port_id;
17220 uint64_t queue_offloads;
17221 uint64_t port_offloads;
17224 ret = eth_dev_info_get_print_err(port_id, &dev_info);
17228 queue_offloads = dev_info.tx_queue_offload_capa;
17229 port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
17231 printf("Tx Offloading Capabilities of port %d :\n", port_id);
17232 printf(" Per Queue :");
17233 print_tx_offloads(queue_offloads);
17236 printf(" Per Port :");
17237 print_tx_offloads(port_offloads);
17241 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
17242 .f = cmd_tx_offload_get_capa_parsed,
17244 .help_str = "show port <port_id> tx_offload capabilities",
17246 (void *)&cmd_tx_offload_get_capa_show,
17247 (void *)&cmd_tx_offload_get_capa_port,
17248 (void *)&cmd_tx_offload_get_capa_port_id,
17249 (void *)&cmd_tx_offload_get_capa_tx_offload,
17250 (void *)&cmd_tx_offload_get_capa_capabilities,
17255 /* Get Tx offloads configuration */
17256 struct cmd_tx_offload_get_configuration_result {
17257 cmdline_fixed_string_t show;
17258 cmdline_fixed_string_t port;
17260 cmdline_fixed_string_t tx_offload;
17261 cmdline_fixed_string_t configuration;
17264 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
17265 TOKEN_STRING_INITIALIZER
17266 (struct cmd_tx_offload_get_configuration_result,
17268 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
17269 TOKEN_STRING_INITIALIZER
17270 (struct cmd_tx_offload_get_configuration_result,
17272 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
17273 TOKEN_NUM_INITIALIZER
17274 (struct cmd_tx_offload_get_configuration_result,
17276 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
17277 TOKEN_STRING_INITIALIZER
17278 (struct cmd_tx_offload_get_configuration_result,
17279 tx_offload, "tx_offload");
17280 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
17281 TOKEN_STRING_INITIALIZER
17282 (struct cmd_tx_offload_get_configuration_result,
17283 configuration, "configuration");
17286 cmd_tx_offload_get_configuration_parsed(
17287 void *parsed_result,
17288 __rte_unused struct cmdline *cl,
17289 __rte_unused void *data)
17291 struct cmd_tx_offload_get_configuration_result *res = parsed_result;
17292 struct rte_eth_dev_info dev_info;
17293 portid_t port_id = res->port_id;
17294 struct rte_port *port = &ports[port_id];
17295 uint64_t port_offloads;
17296 uint64_t queue_offloads;
17297 uint16_t nb_tx_queues;
17301 printf("Tx Offloading Configuration of port %d :\n", port_id);
17303 port_offloads = port->dev_conf.txmode.offloads;
17305 print_tx_offloads(port_offloads);
17308 ret = eth_dev_info_get_print_err(port_id, &dev_info);
17312 nb_tx_queues = dev_info.nb_tx_queues;
17313 for (q = 0; q < nb_tx_queues; q++) {
17314 queue_offloads = port->tx_conf[q].offloads;
17315 printf(" Queue[%2d] :", q);
17316 print_tx_offloads(queue_offloads);
17322 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
17323 .f = cmd_tx_offload_get_configuration_parsed,
17325 .help_str = "show port <port_id> tx_offload configuration",
17327 (void *)&cmd_tx_offload_get_configuration_show,
17328 (void *)&cmd_tx_offload_get_configuration_port,
17329 (void *)&cmd_tx_offload_get_configuration_port_id,
17330 (void *)&cmd_tx_offload_get_configuration_tx_offload,
17331 (void *)&cmd_tx_offload_get_configuration_configuration,
17336 /* Enable/Disable a per port offloading */
17337 struct cmd_config_per_port_tx_offload_result {
17338 cmdline_fixed_string_t port;
17339 cmdline_fixed_string_t config;
17341 cmdline_fixed_string_t tx_offload;
17342 cmdline_fixed_string_t offload;
17343 cmdline_fixed_string_t on_off;
17346 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
17347 TOKEN_STRING_INITIALIZER
17348 (struct cmd_config_per_port_tx_offload_result,
17350 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
17351 TOKEN_STRING_INITIALIZER
17352 (struct cmd_config_per_port_tx_offload_result,
17354 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
17355 TOKEN_NUM_INITIALIZER
17356 (struct cmd_config_per_port_tx_offload_result,
17358 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
17359 TOKEN_STRING_INITIALIZER
17360 (struct cmd_config_per_port_tx_offload_result,
17361 tx_offload, "tx_offload");
17362 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
17363 TOKEN_STRING_INITIALIZER
17364 (struct cmd_config_per_port_tx_offload_result,
17365 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
17366 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
17367 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
17368 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
17369 "mt_lockfree#multi_segs#mbuf_fast_free#security#"
17370 "send_on_timestamp");
17371 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
17372 TOKEN_STRING_INITIALIZER
17373 (struct cmd_config_per_port_tx_offload_result,
17377 search_tx_offload(const char *name)
17379 uint64_t single_offload;
17380 const char *single_name;
17384 single_offload = 1;
17385 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
17386 single_name = rte_eth_dev_tx_offload_name(single_offload);
17387 if (single_name == NULL)
17389 if (!strcasecmp(single_name, name)) {
17392 } else if (!strcasecmp(single_name, "UNKNOWN"))
17394 single_offload <<= 1;
17398 return single_offload;
17404 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
17405 __rte_unused struct cmdline *cl,
17406 __rte_unused void *data)
17408 struct cmd_config_per_port_tx_offload_result *res = parsed_result;
17409 portid_t port_id = res->port_id;
17410 struct rte_eth_dev_info dev_info;
17411 struct rte_port *port = &ports[port_id];
17412 uint64_t single_offload;
17413 uint16_t nb_tx_queues;
17417 if (port->port_status != RTE_PORT_STOPPED) {
17418 printf("Error: Can't config offload when Port %d "
17419 "is not stopped\n", port_id);
17423 single_offload = search_tx_offload(res->offload);
17424 if (single_offload == 0) {
17425 printf("Unknown offload name: %s\n", res->offload);
17429 ret = eth_dev_info_get_print_err(port_id, &dev_info);
17433 nb_tx_queues = dev_info.nb_tx_queues;
17434 if (!strcmp(res->on_off, "on")) {
17435 port->dev_conf.txmode.offloads |= single_offload;
17436 for (q = 0; q < nb_tx_queues; q++)
17437 port->tx_conf[q].offloads |= single_offload;
17439 port->dev_conf.txmode.offloads &= ~single_offload;
17440 for (q = 0; q < nb_tx_queues; q++)
17441 port->tx_conf[q].offloads &= ~single_offload;
17444 cmd_reconfig_device_queue(port_id, 1, 1);
17447 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
17448 .f = cmd_config_per_port_tx_offload_parsed,
17450 .help_str = "port config <port_id> tx_offload "
17451 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
17452 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
17453 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
17454 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
17455 "mt_lockfree|multi_segs|mbuf_fast_free|security|"
17456 "send_on_timestamp on|off",
17458 (void *)&cmd_config_per_port_tx_offload_result_port,
17459 (void *)&cmd_config_per_port_tx_offload_result_config,
17460 (void *)&cmd_config_per_port_tx_offload_result_port_id,
17461 (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
17462 (void *)&cmd_config_per_port_tx_offload_result_offload,
17463 (void *)&cmd_config_per_port_tx_offload_result_on_off,
17468 /* Enable/Disable a per queue offloading */
17469 struct cmd_config_per_queue_tx_offload_result {
17470 cmdline_fixed_string_t port;
17472 cmdline_fixed_string_t txq;
17474 cmdline_fixed_string_t tx_offload;
17475 cmdline_fixed_string_t offload;
17476 cmdline_fixed_string_t on_off;
17479 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
17480 TOKEN_STRING_INITIALIZER
17481 (struct cmd_config_per_queue_tx_offload_result,
17483 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
17484 TOKEN_NUM_INITIALIZER
17485 (struct cmd_config_per_queue_tx_offload_result,
17487 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
17488 TOKEN_STRING_INITIALIZER
17489 (struct cmd_config_per_queue_tx_offload_result,
17491 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
17492 TOKEN_NUM_INITIALIZER
17493 (struct cmd_config_per_queue_tx_offload_result,
17495 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
17496 TOKEN_STRING_INITIALIZER
17497 (struct cmd_config_per_queue_tx_offload_result,
17498 tx_offload, "tx_offload");
17499 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
17500 TOKEN_STRING_INITIALIZER
17501 (struct cmd_config_per_queue_tx_offload_result,
17502 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
17503 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
17504 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
17505 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
17506 "mt_lockfree#multi_segs#mbuf_fast_free#security");
17507 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
17508 TOKEN_STRING_INITIALIZER
17509 (struct cmd_config_per_queue_tx_offload_result,
17513 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
17514 __rte_unused struct cmdline *cl,
17515 __rte_unused void *data)
17517 struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
17518 struct rte_eth_dev_info dev_info;
17519 portid_t port_id = res->port_id;
17520 uint16_t queue_id = res->queue_id;
17521 struct rte_port *port = &ports[port_id];
17522 uint64_t single_offload;
17525 if (port->port_status != RTE_PORT_STOPPED) {
17526 printf("Error: Can't config offload when Port %d "
17527 "is not stopped\n", port_id);
17531 ret = eth_dev_info_get_print_err(port_id, &dev_info);
17535 if (queue_id >= dev_info.nb_tx_queues) {
17536 printf("Error: input queue_id should be 0 ... "
17537 "%d\n", dev_info.nb_tx_queues - 1);
17541 single_offload = search_tx_offload(res->offload);
17542 if (single_offload == 0) {
17543 printf("Unknown offload name: %s\n", res->offload);
17547 if (!strcmp(res->on_off, "on"))
17548 port->tx_conf[queue_id].offloads |= single_offload;
17550 port->tx_conf[queue_id].offloads &= ~single_offload;
17552 cmd_reconfig_device_queue(port_id, 1, 1);
17555 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
17556 .f = cmd_config_per_queue_tx_offload_parsed,
17558 .help_str = "port <port_id> txq <queue_id> tx_offload "
17559 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
17560 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
17561 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
17562 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
17563 "mt_lockfree|multi_segs|mbuf_fast_free|security "
17566 (void *)&cmd_config_per_queue_tx_offload_result_port,
17567 (void *)&cmd_config_per_queue_tx_offload_result_port_id,
17568 (void *)&cmd_config_per_queue_tx_offload_result_txq,
17569 (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
17570 (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
17571 (void *)&cmd_config_per_queue_tx_offload_result_offload,
17572 (void *)&cmd_config_per_queue_tx_offload_result_on_off,
17577 /* *** configure tx_metadata for specific port *** */
17578 struct cmd_config_tx_metadata_specific_result {
17579 cmdline_fixed_string_t port;
17580 cmdline_fixed_string_t keyword;
17582 cmdline_fixed_string_t item;
17587 cmd_config_tx_metadata_specific_parsed(void *parsed_result,
17588 __rte_unused struct cmdline *cl,
17589 __rte_unused void *data)
17591 struct cmd_config_tx_metadata_specific_result *res = parsed_result;
17593 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17595 ports[res->port_id].tx_metadata = res->value;
17596 /* Add/remove callback to insert valid metadata in every Tx packet. */
17597 if (ports[res->port_id].tx_metadata)
17598 add_tx_md_callback(res->port_id);
17600 remove_tx_md_callback(res->port_id);
17601 rte_flow_dynf_metadata_register();
17604 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
17605 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
17607 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
17608 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
17609 keyword, "config");
17610 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
17611 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
17613 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
17614 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
17615 item, "tx_metadata");
17616 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
17617 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
17620 cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
17621 .f = cmd_config_tx_metadata_specific_parsed,
17623 .help_str = "port config <port_id> tx_metadata <value>",
17625 (void *)&cmd_config_tx_metadata_specific_port,
17626 (void *)&cmd_config_tx_metadata_specific_keyword,
17627 (void *)&cmd_config_tx_metadata_specific_id,
17628 (void *)&cmd_config_tx_metadata_specific_item,
17629 (void *)&cmd_config_tx_metadata_specific_value,
17634 /* *** set dynf *** */
17635 struct cmd_config_tx_dynf_specific_result {
17636 cmdline_fixed_string_t port;
17637 cmdline_fixed_string_t keyword;
17639 cmdline_fixed_string_t item;
17640 cmdline_fixed_string_t name;
17641 cmdline_fixed_string_t value;
17645 cmd_config_dynf_specific_parsed(void *parsed_result,
17646 __rte_unused struct cmdline *cl,
17647 __rte_unused void *data)
17649 struct cmd_config_tx_dynf_specific_result *res = parsed_result;
17650 struct rte_mbuf_dynflag desc_flag;
17652 uint64_t old_port_flags;
17654 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17656 flag = rte_mbuf_dynflag_lookup(res->name, NULL);
17658 if (strlcpy(desc_flag.name, res->name,
17659 RTE_MBUF_DYN_NAMESIZE) >= RTE_MBUF_DYN_NAMESIZE) {
17660 printf("Flag name too long\n");
17663 desc_flag.flags = 0;
17664 flag = rte_mbuf_dynflag_register(&desc_flag);
17666 printf("Can't register flag\n");
17669 strcpy(dynf_names[flag], desc_flag.name);
17671 old_port_flags = ports[res->port_id].mbuf_dynf;
17672 if (!strcmp(res->value, "set")) {
17673 ports[res->port_id].mbuf_dynf |= 1UL << flag;
17674 if (old_port_flags == 0)
17675 add_tx_dynf_callback(res->port_id);
17677 ports[res->port_id].mbuf_dynf &= ~(1UL << flag);
17678 if (ports[res->port_id].mbuf_dynf == 0)
17679 remove_tx_dynf_callback(res->port_id);
17683 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_port =
17684 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
17686 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_keyword =
17687 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
17688 keyword, "config");
17689 cmdline_parse_token_num_t cmd_config_tx_dynf_specific_port_id =
17690 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
17692 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_item =
17693 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
17695 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_name =
17696 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
17698 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_value =
17699 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
17700 value, "set#clear");
17702 cmdline_parse_inst_t cmd_config_tx_dynf_specific = {
17703 .f = cmd_config_dynf_specific_parsed,
17705 .help_str = "port config <port id> dynf <name> set|clear",
17707 (void *)&cmd_config_tx_dynf_specific_port,
17708 (void *)&cmd_config_tx_dynf_specific_keyword,
17709 (void *)&cmd_config_tx_dynf_specific_port_id,
17710 (void *)&cmd_config_tx_dynf_specific_item,
17711 (void *)&cmd_config_tx_dynf_specific_name,
17712 (void *)&cmd_config_tx_dynf_specific_value,
17717 /* *** display tx_metadata per port configuration *** */
17718 struct cmd_show_tx_metadata_result {
17719 cmdline_fixed_string_t cmd_show;
17720 cmdline_fixed_string_t cmd_port;
17721 cmdline_fixed_string_t cmd_keyword;
17726 cmd_show_tx_metadata_parsed(void *parsed_result,
17727 __rte_unused struct cmdline *cl,
17728 __rte_unused void *data)
17730 struct cmd_show_tx_metadata_result *res = parsed_result;
17732 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17733 printf("invalid port id %u\n", res->cmd_pid);
17736 if (!strcmp(res->cmd_keyword, "tx_metadata")) {
17737 printf("Port %u tx_metadata: %u\n", res->cmd_pid,
17738 ports[res->cmd_pid].tx_metadata);
17742 cmdline_parse_token_string_t cmd_show_tx_metadata_show =
17743 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
17745 cmdline_parse_token_string_t cmd_show_tx_metadata_port =
17746 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
17748 cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
17749 TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
17751 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
17752 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
17753 cmd_keyword, "tx_metadata");
17755 cmdline_parse_inst_t cmd_show_tx_metadata = {
17756 .f = cmd_show_tx_metadata_parsed,
17758 .help_str = "show port <port_id> tx_metadata",
17760 (void *)&cmd_show_tx_metadata_show,
17761 (void *)&cmd_show_tx_metadata_port,
17762 (void *)&cmd_show_tx_metadata_pid,
17763 (void *)&cmd_show_tx_metadata_keyword,
17768 /* *** show fec capability per port configuration *** */
17769 struct cmd_show_fec_capability_result {
17770 cmdline_fixed_string_t cmd_show;
17771 cmdline_fixed_string_t cmd_port;
17772 cmdline_fixed_string_t cmd_fec;
17773 cmdline_fixed_string_t cmd_keyword;
17778 cmd_show_fec_capability_parsed(void *parsed_result,
17779 __rte_unused struct cmdline *cl,
17780 __rte_unused void *data)
17782 #define FEC_CAP_NUM 2
17783 struct cmd_show_fec_capability_result *res = parsed_result;
17784 struct rte_eth_fec_capa speed_fec_capa[FEC_CAP_NUM];
17785 unsigned int num = FEC_CAP_NUM;
17786 unsigned int ret_num;
17789 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17790 printf("Invalid port id %u\n", res->cmd_pid);
17794 ret = rte_eth_fec_get_capability(res->cmd_pid, speed_fec_capa, num);
17795 if (ret == -ENOTSUP) {
17796 printf("Function not implemented\n");
17798 } else if (ret < 0) {
17799 printf("Get FEC capability failed\n");
17803 ret_num = (unsigned int)ret;
17804 show_fec_capability(ret_num, speed_fec_capa);
17807 cmdline_parse_token_string_t cmd_show_fec_capability_show =
17808 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
17810 cmdline_parse_token_string_t cmd_show_fec_capability_port =
17811 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
17813 cmdline_parse_token_num_t cmd_show_fec_capability_pid =
17814 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_capability_result,
17816 cmdline_parse_token_string_t cmd_show_fec_capability_fec =
17817 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
17819 cmdline_parse_token_string_t cmd_show_fec_capability_keyword =
17820 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
17821 cmd_keyword, "capabilities");
17823 cmdline_parse_inst_t cmd_show_capability = {
17824 .f = cmd_show_fec_capability_parsed,
17826 .help_str = "show port <port_id> fec capabilities",
17828 (void *)&cmd_show_fec_capability_show,
17829 (void *)&cmd_show_fec_capability_port,
17830 (void *)&cmd_show_fec_capability_pid,
17831 (void *)&cmd_show_fec_capability_fec,
17832 (void *)&cmd_show_fec_capability_keyword,
17837 /* *** show fec mode per port configuration *** */
17838 struct cmd_show_fec_metadata_result {
17839 cmdline_fixed_string_t cmd_show;
17840 cmdline_fixed_string_t cmd_port;
17841 cmdline_fixed_string_t cmd_keyword;
17846 cmd_show_fec_mode_parsed(void *parsed_result,
17847 __rte_unused struct cmdline *cl,
17848 __rte_unused void *data)
17850 #define FEC_NAME_SIZE 16
17851 struct cmd_show_fec_metadata_result *res = parsed_result;
17853 char buf[FEC_NAME_SIZE];
17856 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17857 printf("Invalid port id %u\n", res->cmd_pid);
17860 ret = rte_eth_fec_get(res->cmd_pid, &mode);
17861 if (ret == -ENOTSUP) {
17862 printf("Function not implemented\n");
17864 } else if (ret < 0) {
17865 printf("Get FEC mode failed\n");
17870 case RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC):
17871 strlcpy(buf, "off", sizeof(buf));
17873 case RTE_ETH_FEC_MODE_CAPA_MASK(AUTO):
17874 strlcpy(buf, "auto", sizeof(buf));
17876 case RTE_ETH_FEC_MODE_CAPA_MASK(BASER):
17877 strlcpy(buf, "baser", sizeof(buf));
17879 case RTE_ETH_FEC_MODE_CAPA_MASK(RS):
17880 strlcpy(buf, "rs", sizeof(buf));
17886 printf("%s\n", buf);
17889 cmdline_parse_token_string_t cmd_show_fec_mode_show =
17890 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
17892 cmdline_parse_token_string_t cmd_show_fec_mode_port =
17893 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
17895 cmdline_parse_token_num_t cmd_show_fec_mode_pid =
17896 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_metadata_result,
17898 cmdline_parse_token_string_t cmd_show_fec_mode_keyword =
17899 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
17900 cmd_keyword, "fec_mode");
17902 cmdline_parse_inst_t cmd_show_fec_mode = {
17903 .f = cmd_show_fec_mode_parsed,
17905 .help_str = "show port <port_id> fec_mode",
17907 (void *)&cmd_show_fec_mode_show,
17908 (void *)&cmd_show_fec_mode_port,
17909 (void *)&cmd_show_fec_mode_pid,
17910 (void *)&cmd_show_fec_mode_keyword,
17915 /* *** set fec mode per port configuration *** */
17916 struct cmd_set_port_fec_mode {
17917 cmdline_fixed_string_t set;
17918 cmdline_fixed_string_t port;
17920 cmdline_fixed_string_t fec_mode;
17921 cmdline_fixed_string_t fec_value;
17924 /* Common CLI fields for set fec mode */
17925 cmdline_parse_token_string_t cmd_set_port_fec_mode_set =
17926 TOKEN_STRING_INITIALIZER
17927 (struct cmd_set_port_fec_mode,
17929 cmdline_parse_token_string_t cmd_set_port_fec_mode_port =
17930 TOKEN_STRING_INITIALIZER
17931 (struct cmd_set_port_fec_mode,
17933 cmdline_parse_token_num_t cmd_set_port_fec_mode_port_id =
17934 TOKEN_NUM_INITIALIZER
17935 (struct cmd_set_port_fec_mode,
17937 cmdline_parse_token_string_t cmd_set_port_fec_mode_str =
17938 TOKEN_STRING_INITIALIZER
17939 (struct cmd_set_port_fec_mode,
17940 fec_mode, "fec_mode");
17941 cmdline_parse_token_string_t cmd_set_port_fec_mode_value =
17942 TOKEN_STRING_INITIALIZER
17943 (struct cmd_set_port_fec_mode,
17947 cmd_set_port_fec_mode_parsed(
17948 void *parsed_result,
17949 __rte_unused struct cmdline *cl,
17950 __rte_unused void *data)
17952 struct cmd_set_port_fec_mode *res = parsed_result;
17953 uint16_t port_id = res->port_id;
17957 ret = parse_fec_mode(res->fec_value, &mode);
17959 printf("Unknown fec mode: %s for Port %d\n", res->fec_value,
17964 ret = rte_eth_fec_set(port_id, mode);
17965 if (ret == -ENOTSUP) {
17966 printf("Function not implemented\n");
17968 } else if (ret < 0) {
17969 printf("Set FEC mode failed\n");
17974 cmdline_parse_inst_t cmd_set_fec_mode = {
17975 .f = cmd_set_port_fec_mode_parsed,
17977 .help_str = "set port <port_id> fec_mode auto|off|rs|baser",
17979 (void *)&cmd_set_port_fec_mode_set,
17980 (void *)&cmd_set_port_fec_mode_port,
17981 (void *)&cmd_set_port_fec_mode_port_id,
17982 (void *)&cmd_set_port_fec_mode_str,
17983 (void *)&cmd_set_port_fec_mode_value,
17988 /* show port supported ptypes */
17990 /* Common result structure for show port ptypes */
17991 struct cmd_show_port_supported_ptypes_result {
17992 cmdline_fixed_string_t show;
17993 cmdline_fixed_string_t port;
17995 cmdline_fixed_string_t ptypes;
17998 /* Common CLI fields for show port ptypes */
17999 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =
18000 TOKEN_STRING_INITIALIZER
18001 (struct cmd_show_port_supported_ptypes_result,
18003 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
18004 TOKEN_STRING_INITIALIZER
18005 (struct cmd_show_port_supported_ptypes_result,
18007 cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =
18008 TOKEN_NUM_INITIALIZER
18009 (struct cmd_show_port_supported_ptypes_result,
18011 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =
18012 TOKEN_STRING_INITIALIZER
18013 (struct cmd_show_port_supported_ptypes_result,
18017 cmd_show_port_supported_ptypes_parsed(
18018 void *parsed_result,
18019 __rte_unused struct cmdline *cl,
18020 __rte_unused void *data)
18022 #define RSVD_PTYPE_MASK 0xf0000000
18023 #define MAX_PTYPES_PER_LAYER 16
18024 #define LTYPE_NAMESIZE 32
18025 #define PTYPE_NAMESIZE 256
18026 struct cmd_show_port_supported_ptypes_result *res = parsed_result;
18027 char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE];
18028 uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
18029 uint32_t ptypes[MAX_PTYPES_PER_LAYER];
18030 uint16_t port_id = res->port_id;
18033 ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0);
18037 while (ptype_mask != RSVD_PTYPE_MASK) {
18039 switch (ptype_mask) {
18040 case RTE_PTYPE_L2_MASK:
18041 strlcpy(ltype, "L2", sizeof(ltype));
18043 case RTE_PTYPE_L3_MASK:
18044 strlcpy(ltype, "L3", sizeof(ltype));
18046 case RTE_PTYPE_L4_MASK:
18047 strlcpy(ltype, "L4", sizeof(ltype));
18049 case RTE_PTYPE_TUNNEL_MASK:
18050 strlcpy(ltype, "Tunnel", sizeof(ltype));
18052 case RTE_PTYPE_INNER_L2_MASK:
18053 strlcpy(ltype, "Inner L2", sizeof(ltype));
18055 case RTE_PTYPE_INNER_L3_MASK:
18056 strlcpy(ltype, "Inner L3", sizeof(ltype));
18058 case RTE_PTYPE_INNER_L4_MASK:
18059 strlcpy(ltype, "Inner L4", sizeof(ltype));
18065 ret = rte_eth_dev_get_supported_ptypes(res->port_id,
18066 ptype_mask, ptypes,
18067 MAX_PTYPES_PER_LAYER);
18070 printf("Supported %s ptypes:\n", ltype);
18072 printf("%s ptypes unsupported\n", ltype);
18074 for (i = 0; i < ret; ++i) {
18075 rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
18076 printf("%s\n", buf);
18083 cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
18084 .f = cmd_show_port_supported_ptypes_parsed,
18086 .help_str = "show port <port_id> ptypes",
18088 (void *)&cmd_show_port_supported_ptypes_show,
18089 (void *)&cmd_show_port_supported_ptypes_port,
18090 (void *)&cmd_show_port_supported_ptypes_port_id,
18091 (void *)&cmd_show_port_supported_ptypes_ptypes,
18096 /* *** display rx/tx descriptor status *** */
18097 struct cmd_show_rx_tx_desc_status_result {
18098 cmdline_fixed_string_t cmd_show;
18099 cmdline_fixed_string_t cmd_port;
18100 cmdline_fixed_string_t cmd_keyword;
18101 cmdline_fixed_string_t cmd_desc;
18102 cmdline_fixed_string_t cmd_status;
18109 cmd_show_rx_tx_desc_status_parsed(void *parsed_result,
18110 __rte_unused struct cmdline *cl,
18111 __rte_unused void *data)
18113 struct cmd_show_rx_tx_desc_status_result *res = parsed_result;
18116 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
18117 printf("invalid port id %u\n", res->cmd_pid);
18121 if (!strcmp(res->cmd_keyword, "rxq")) {
18122 rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid,
18125 printf("Invalid queueid = %d\n", res->cmd_qid);
18128 if (rc == RTE_ETH_RX_DESC_AVAIL)
18129 printf("Desc status = AVAILABLE\n");
18130 else if (rc == RTE_ETH_RX_DESC_DONE)
18131 printf("Desc status = DONE\n");
18133 printf("Desc status = UNAVAILABLE\n");
18134 } else if (!strcmp(res->cmd_keyword, "txq")) {
18135 rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid,
18138 printf("Invalid queueid = %d\n", res->cmd_qid);
18141 if (rc == RTE_ETH_TX_DESC_FULL)
18142 printf("Desc status = FULL\n");
18143 else if (rc == RTE_ETH_TX_DESC_DONE)
18144 printf("Desc status = DONE\n");
18146 printf("Desc status = UNAVAILABLE\n");
18150 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show =
18151 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
18153 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port =
18154 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
18156 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid =
18157 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
18159 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword =
18160 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
18161 cmd_keyword, "rxq#txq");
18162 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid =
18163 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
18165 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc =
18166 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
18168 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did =
18169 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
18171 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status =
18172 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
18173 cmd_status, "status");
18174 cmdline_parse_inst_t cmd_show_rx_tx_desc_status = {
18175 .f = cmd_show_rx_tx_desc_status_parsed,
18177 .help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> "
18180 (void *)&cmd_show_rx_tx_desc_status_show,
18181 (void *)&cmd_show_rx_tx_desc_status_port,
18182 (void *)&cmd_show_rx_tx_desc_status_pid,
18183 (void *)&cmd_show_rx_tx_desc_status_keyword,
18184 (void *)&cmd_show_rx_tx_desc_status_qid,
18185 (void *)&cmd_show_rx_tx_desc_status_desc,
18186 (void *)&cmd_show_rx_tx_desc_status_did,
18187 (void *)&cmd_show_rx_tx_desc_status_status,
18192 /* Common result structure for set port ptypes */
18193 struct cmd_set_port_ptypes_result {
18194 cmdline_fixed_string_t set;
18195 cmdline_fixed_string_t port;
18197 cmdline_fixed_string_t ptype_mask;
18201 /* Common CLI fields for set port ptypes */
18202 cmdline_parse_token_string_t cmd_set_port_ptypes_set =
18203 TOKEN_STRING_INITIALIZER
18204 (struct cmd_set_port_ptypes_result,
18206 cmdline_parse_token_string_t cmd_set_port_ptypes_port =
18207 TOKEN_STRING_INITIALIZER
18208 (struct cmd_set_port_ptypes_result,
18210 cmdline_parse_token_num_t cmd_set_port_ptypes_port_id =
18211 TOKEN_NUM_INITIALIZER
18212 (struct cmd_set_port_ptypes_result,
18214 cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str =
18215 TOKEN_STRING_INITIALIZER
18216 (struct cmd_set_port_ptypes_result,
18217 ptype_mask, "ptype_mask");
18218 cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 =
18219 TOKEN_NUM_INITIALIZER
18220 (struct cmd_set_port_ptypes_result,
18224 cmd_set_port_ptypes_parsed(
18225 void *parsed_result,
18226 __rte_unused struct cmdline *cl,
18227 __rte_unused void *data)
18229 struct cmd_set_port_ptypes_result *res = parsed_result;
18230 #define PTYPE_NAMESIZE 256
18231 char ptype_name[PTYPE_NAMESIZE];
18232 uint16_t port_id = res->port_id;
18233 uint32_t ptype_mask = res->mask;
18236 ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK,
18239 printf("Port %d doesn't support any ptypes.\n", port_id);
18243 uint32_t ptypes[ret];
18245 ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret);
18247 printf("Unable to set requested ptypes for Port %d\n", port_id);
18251 printf("Successfully set following ptypes for Port %d\n", port_id);
18252 for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) {
18253 rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name));
18254 printf("%s\n", ptype_name);
18257 clear_ptypes = false;
18260 cmdline_parse_inst_t cmd_set_port_ptypes = {
18261 .f = cmd_set_port_ptypes_parsed,
18263 .help_str = "set port <port_id> ptype_mask <mask>",
18265 (void *)&cmd_set_port_ptypes_set,
18266 (void *)&cmd_set_port_ptypes_port,
18267 (void *)&cmd_set_port_ptypes_port_id,
18268 (void *)&cmd_set_port_ptypes_mask_str,
18269 (void *)&cmd_set_port_ptypes_mask_u32,
18274 /* *** display mac addresses added to a port *** */
18275 struct cmd_showport_macs_result {
18276 cmdline_fixed_string_t cmd_show;
18277 cmdline_fixed_string_t cmd_port;
18278 cmdline_fixed_string_t cmd_keyword;
18283 cmd_showport_macs_parsed(void *parsed_result,
18284 __rte_unused struct cmdline *cl,
18285 __rte_unused void *data)
18287 struct cmd_showport_macs_result *res = parsed_result;
18289 if (port_id_is_invalid(res->cmd_pid, ENABLED_WARN))
18292 if (!strcmp(res->cmd_keyword, "macs"))
18293 show_macs(res->cmd_pid);
18294 else if (!strcmp(res->cmd_keyword, "mcast_macs"))
18295 show_mcast_macs(res->cmd_pid);
18298 cmdline_parse_token_string_t cmd_showport_macs_show =
18299 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
18301 cmdline_parse_token_string_t cmd_showport_macs_port =
18302 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
18304 cmdline_parse_token_num_t cmd_showport_macs_pid =
18305 TOKEN_NUM_INITIALIZER(struct cmd_showport_macs_result,
18307 cmdline_parse_token_string_t cmd_showport_macs_keyword =
18308 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
18309 cmd_keyword, "macs#mcast_macs");
18311 cmdline_parse_inst_t cmd_showport_macs = {
18312 .f = cmd_showport_macs_parsed,
18314 .help_str = "show port <port_id> macs|mcast_macs",
18316 (void *)&cmd_showport_macs_show,
18317 (void *)&cmd_showport_macs_port,
18318 (void *)&cmd_showport_macs_pid,
18319 (void *)&cmd_showport_macs_keyword,
18324 /* ******************************************************************************** */
18326 /* list of instructions */
18327 cmdline_parse_ctx_t main_ctx[] = {
18328 (cmdline_parse_inst_t *)&cmd_help_brief,
18329 (cmdline_parse_inst_t *)&cmd_help_long,
18330 (cmdline_parse_inst_t *)&cmd_quit,
18331 (cmdline_parse_inst_t *)&cmd_load_from_file,
18332 (cmdline_parse_inst_t *)&cmd_showport,
18333 (cmdline_parse_inst_t *)&cmd_showqueue,
18334 (cmdline_parse_inst_t *)&cmd_showeeprom,
18335 (cmdline_parse_inst_t *)&cmd_showportall,
18336 (cmdline_parse_inst_t *)&cmd_showdevice,
18337 (cmdline_parse_inst_t *)&cmd_showcfg,
18338 (cmdline_parse_inst_t *)&cmd_showfwdall,
18339 (cmdline_parse_inst_t *)&cmd_start,
18340 (cmdline_parse_inst_t *)&cmd_start_tx_first,
18341 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
18342 (cmdline_parse_inst_t *)&cmd_set_link_up,
18343 (cmdline_parse_inst_t *)&cmd_set_link_down,
18344 (cmdline_parse_inst_t *)&cmd_reset,
18345 (cmdline_parse_inst_t *)&cmd_set_numbers,
18346 (cmdline_parse_inst_t *)&cmd_set_log,
18347 (cmdline_parse_inst_t *)&cmd_set_rxoffs,
18348 (cmdline_parse_inst_t *)&cmd_set_rxpkts,
18349 (cmdline_parse_inst_t *)&cmd_set_txpkts,
18350 (cmdline_parse_inst_t *)&cmd_set_txsplit,
18351 (cmdline_parse_inst_t *)&cmd_set_txtimes,
18352 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
18353 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
18354 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
18355 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
18356 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
18357 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
18358 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
18359 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
18360 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
18361 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
18362 (cmdline_parse_inst_t *)&cmd_set_link_check,
18363 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
18364 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
18365 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
18366 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
18367 #ifdef RTE_NET_BOND
18368 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
18369 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
18370 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
18371 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
18372 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
18373 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
18374 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
18375 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
18376 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
18377 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
18378 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
18380 (cmdline_parse_inst_t *)&cmd_vlan_offload,
18381 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
18382 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
18383 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
18384 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
18385 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
18386 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
18387 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
18388 (cmdline_parse_inst_t *)&cmd_csum_set,
18389 (cmdline_parse_inst_t *)&cmd_csum_show,
18390 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
18391 (cmdline_parse_inst_t *)&cmd_tso_set,
18392 (cmdline_parse_inst_t *)&cmd_tso_show,
18393 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
18394 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
18395 (cmdline_parse_inst_t *)&cmd_gro_enable,
18396 (cmdline_parse_inst_t *)&cmd_gro_flush,
18397 (cmdline_parse_inst_t *)&cmd_gro_show,
18398 (cmdline_parse_inst_t *)&cmd_gso_enable,
18399 (cmdline_parse_inst_t *)&cmd_gso_size,
18400 (cmdline_parse_inst_t *)&cmd_gso_show,
18401 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
18402 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
18403 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
18404 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
18405 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
18406 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
18407 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
18408 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
18409 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
18410 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
18411 (cmdline_parse_inst_t *)&cmd_config_dcb,
18412 (cmdline_parse_inst_t *)&cmd_read_reg,
18413 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
18414 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
18415 (cmdline_parse_inst_t *)&cmd_write_reg,
18416 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
18417 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
18418 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
18419 (cmdline_parse_inst_t *)&cmd_stop,
18420 (cmdline_parse_inst_t *)&cmd_mac_addr,
18421 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
18422 (cmdline_parse_inst_t *)&cmd_set_qmap,
18423 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
18424 (cmdline_parse_inst_t *)&cmd_set_record_core_cycles,
18425 (cmdline_parse_inst_t *)&cmd_set_record_burst_stats,
18426 (cmdline_parse_inst_t *)&cmd_operate_port,
18427 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
18428 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
18429 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
18430 (cmdline_parse_inst_t *)&cmd_operate_detach_device,
18431 (cmdline_parse_inst_t *)&cmd_set_port_setup_on,
18432 (cmdline_parse_inst_t *)&cmd_config_speed_all,
18433 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
18434 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
18435 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
18436 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
18437 (cmdline_parse_inst_t *)&cmd_config_mtu,
18438 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
18439 (cmdline_parse_inst_t *)&cmd_config_max_lro_pkt_size,
18440 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
18441 (cmdline_parse_inst_t *)&cmd_config_rss,
18442 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
18443 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
18444 (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
18445 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
18446 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
18447 (cmdline_parse_inst_t *)&cmd_showport_reta,
18448 (cmdline_parse_inst_t *)&cmd_showport_macs,
18449 (cmdline_parse_inst_t *)&cmd_config_burst,
18450 (cmdline_parse_inst_t *)&cmd_config_thresh,
18451 (cmdline_parse_inst_t *)&cmd_config_threshold,
18452 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
18453 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
18454 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
18455 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
18456 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
18457 (cmdline_parse_inst_t *)&cmd_global_config,
18458 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
18459 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
18460 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
18461 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
18462 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
18463 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
18464 (cmdline_parse_inst_t *)&cmd_dump,
18465 (cmdline_parse_inst_t *)&cmd_dump_one,
18466 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
18467 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
18468 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
18469 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
18470 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
18471 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
18472 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
18473 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
18474 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
18475 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
18476 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
18477 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
18478 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
18479 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
18480 (cmdline_parse_inst_t *)&cmd_flow,
18481 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
18482 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
18483 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
18484 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
18485 (cmdline_parse_inst_t *)&cmd_create_port_meter,
18486 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
18487 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
18488 (cmdline_parse_inst_t *)&cmd_del_port_meter,
18489 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
18490 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
18491 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
18492 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
18493 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
18494 (cmdline_parse_inst_t *)&cmd_mcast_addr,
18495 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
18496 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
18497 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
18498 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
18499 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
18500 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
18501 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
18502 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
18503 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
18504 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
18505 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
18506 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
18507 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
18508 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
18509 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
18510 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
18511 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
18512 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
18513 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
18514 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
18515 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
18516 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
18517 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
18518 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
18519 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
18520 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
18521 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
18522 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
18523 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
18524 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
18525 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
18526 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
18527 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
18528 (cmdline_parse_inst_t *)&cmd_set_vxlan,
18529 (cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl,
18530 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
18531 (cmdline_parse_inst_t *)&cmd_set_nvgre,
18532 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
18533 (cmdline_parse_inst_t *)&cmd_set_l2_encap,
18534 (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
18535 (cmdline_parse_inst_t *)&cmd_set_l2_decap,
18536 (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
18537 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
18538 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
18539 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
18540 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
18541 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
18542 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
18543 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
18544 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
18545 (cmdline_parse_inst_t *)&cmd_ddp_add,
18546 (cmdline_parse_inst_t *)&cmd_ddp_del,
18547 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
18548 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
18549 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
18550 (cmdline_parse_inst_t *)&cmd_clear_input_set,
18551 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
18552 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
18553 (cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes,
18554 (cmdline_parse_inst_t *)&cmd_set_port_ptypes,
18555 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
18556 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
18557 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
18558 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
18560 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
18561 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
18562 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
18563 (cmdline_parse_inst_t *)&cmd_queue_region,
18564 (cmdline_parse_inst_t *)&cmd_region_flowtype,
18565 (cmdline_parse_inst_t *)&cmd_user_priority_region,
18566 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
18567 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
18568 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
18569 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
18570 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
18571 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
18572 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
18573 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
18574 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
18575 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
18576 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
18577 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
18578 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
18579 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
18580 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
18581 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node_pmode,
18582 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
18583 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
18584 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
18585 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
18586 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
18587 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
18588 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
18589 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
18590 (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
18591 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
18592 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
18593 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
18594 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
18595 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
18596 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
18597 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
18598 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
18599 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
18601 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
18602 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
18604 (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
18605 (cmdline_parse_inst_t *)&cmd_show_tx_metadata,
18606 (cmdline_parse_inst_t *)&cmd_show_rx_tx_desc_status,
18607 (cmdline_parse_inst_t *)&cmd_set_raw,
18608 (cmdline_parse_inst_t *)&cmd_show_set_raw,
18609 (cmdline_parse_inst_t *)&cmd_show_set_raw_all,
18610 (cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific,
18611 (cmdline_parse_inst_t *)&cmd_show_fec_mode,
18612 (cmdline_parse_inst_t *)&cmd_set_fec_mode,
18613 (cmdline_parse_inst_t *)&cmd_show_capability,
18617 /* read cmdline commands from file */
18619 cmdline_read_from_file(const char *filename)
18621 struct cmdline *cl;
18623 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
18625 printf("Failed to create file based cmdline context: %s\n",
18630 cmdline_interact(cl);
18635 printf("Read CLI commands from %s\n", filename);
18638 /* prompt function, called from main on MAIN lcore */
18642 /* initialize non-constant commands */
18643 cmd_set_fwd_mode_init();
18644 cmd_set_fwd_retry_mode_init();
18646 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
18647 if (testpmd_cl == NULL)
18649 cmdline_interact(testpmd_cl);
18650 cmdline_stdin_exit(testpmd_cl);
18656 if (testpmd_cl != NULL)
18657 cmdline_quit(testpmd_cl);
18661 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
18663 if (id == (portid_t)RTE_PORT_ALL) {
18666 RTE_ETH_FOREACH_DEV(pid) {
18667 /* check if need_reconfig has been set to 1 */
18668 if (ports[pid].need_reconfig == 0)
18669 ports[pid].need_reconfig = dev;
18670 /* check if need_reconfig_queues has been set to 1 */
18671 if (ports[pid].need_reconfig_queues == 0)
18672 ports[pid].need_reconfig_queues = queue;
18674 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
18675 /* check if need_reconfig has been set to 1 */
18676 if (ports[id].need_reconfig == 0)
18677 ports[id].need_reconfig = dev;
18678 /* check if need_reconfig_queues has been set to 1 */
18679 if (ports[id].need_reconfig_queues == 0)
18680 ports[id].need_reconfig_queues = queue;