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|dcb_tc) (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) (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) rxq (queue_id) desc used count\n"
250 " Show current number of filled receive"
251 " packet descriptors.\n\n"
253 "show port (port_id) macs|mcast_macs"
254 " Display list of mac addresses added to port.\n\n"
256 "show port (port_id) fec capabilities"
257 " Show fec capabilities of a port.\n\n"
259 "show port (port_id) fec_mode"
260 " Show fec mode of a port.\n\n"
264 if (show_all || !strcmp(res->section, "config")) {
270 "Configuration changes only become active when"
271 " forwarding is started/restarted.\n\n"
274 " Reset forwarding to the default configuration.\n\n"
276 "set verbose (level)\n"
277 " Set the debug verbosity level X.\n\n"
279 "set log global|(type) (level)\n"
280 " Set the log level.\n\n"
283 " Set number of ports.\n\n"
286 " Set number of cores.\n\n"
288 "set coremask (mask)\n"
289 " Set the forwarding cores hexadecimal mask.\n\n"
291 "set portmask (mask)\n"
292 " Set the forwarding ports hexadecimal mask.\n\n"
295 " Set number of packets per burst.\n\n"
297 "set burst tx delay (microseconds) retry (num)\n"
298 " Set the transmit delay time and number of retries,"
299 " effective when retry is enabled.\n\n"
301 "set rxoffs (x[,y]*)\n"
302 " Set the offset of each packet segment on"
303 " receiving if split feature is engaged."
304 " Affects only the queues configured with split"
307 "set rxpkts (x[,y]*)\n"
308 " Set the length of each segment to scatter"
309 " packets on receiving if split feature is engaged."
310 " Affects only the queues configured with split"
313 "set txpkts (x[,y]*)\n"
314 " Set the length of each segment of TXONLY"
315 " and optionally CSUM packets.\n\n"
317 "set txsplit (off|on|rand)\n"
318 " Set the split policy for the TX packets."
319 " Right now only applicable for CSUM and TXONLY"
322 "set txtimes (x, y)\n"
323 " Set the scheduling on timestamps"
324 " timings for the TXONLY mode\n\n"
326 "set corelist (x[,y]*)\n"
327 " Set the list of forwarding cores.\n\n"
329 "set portlist (x[,y]*)\n"
330 " Set the list of forwarding ports.\n\n"
332 "set port setup on (iterator|event)\n"
333 " Select how attached port is retrieved for setup.\n\n"
335 "set tx loopback (port_id) (on|off)\n"
336 " Enable or disable tx loopback.\n\n"
338 "set all queues drop (port_id) (on|off)\n"
339 " Set drop enable bit for all queues.\n\n"
341 "set vf split drop (port_id) (vf_id) (on|off)\n"
342 " Set split drop enable bit for a VF from the PF.\n\n"
344 "set vf mac antispoof (port_id) (vf_id) (on|off).\n"
345 " Set MAC antispoof for a VF from the PF.\n\n"
347 "set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n"
348 " Enable MACsec offload.\n\n"
350 "set macsec offload (port_id) off\n"
351 " Disable MACsec offload.\n\n"
353 "set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
354 " Configure MACsec secure connection (SC).\n\n"
356 "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n"
357 " Configure MACsec secure association (SA).\n\n"
359 "set vf broadcast (port_id) (vf_id) (on|off)\n"
360 " Set VF broadcast for a VF from the PF.\n\n"
362 "vlan set stripq (on|off) (port_id,queue_id)\n"
363 " Set the VLAN strip for a queue on a port.\n\n"
365 "set vf vlan stripq (port_id) (vf_id) (on|off)\n"
366 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
368 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
369 " Set VLAN insert for a VF from the PF.\n\n"
371 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
372 " Set VLAN antispoof for a VF from the PF.\n\n"
374 "set vf vlan tag (port_id) (vf_id) (on|off)\n"
375 " Set VLAN tag for a VF from the PF.\n\n"
377 "set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n"
378 " Set a VF's max bandwidth(Mbps).\n\n"
380 "set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n"
381 " Set all TCs' min bandwidth(%%) on a VF.\n\n"
383 "set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n"
384 " Set a TC's max bandwidth(Mbps) on a VF.\n\n"
386 "set tx strict-link-priority (port_id) (tc_bitmap)\n"
387 " Set some TCs' strict link priority mode on a physical port.\n\n"
389 "set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n"
390 " Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n"
392 "vlan set (strip|filter|qinq_strip|extend) (on|off) (port_id)\n"
393 " Set the VLAN strip or filter or qinq strip or extend\n\n"
395 "vlan set (inner|outer) tpid (value) (port_id)\n"
396 " Set the VLAN TPID for Packet Filtering on"
399 "rx_vlan add (vlan_id|all) (port_id)\n"
400 " Add a vlan_id, or all identifiers, to the set"
401 " of VLAN identifiers filtered by port_id.\n\n"
403 "rx_vlan rm (vlan_id|all) (port_id)\n"
404 " Remove a vlan_id, or all identifiers, from the set"
405 " of VLAN identifiers filtered by port_id.\n\n"
407 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
408 " Add a vlan_id, to the set of VLAN identifiers"
409 "filtered for VF(s) from port_id.\n\n"
411 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
412 " Remove a vlan_id, to the set of VLAN identifiers"
413 "filtered for VF(s) from port_id.\n\n"
415 "rx_vxlan_port add (udp_port) (port_id)\n"
416 " Add an UDP port for VXLAN packet filter on a port\n\n"
418 "rx_vxlan_port rm (udp_port) (port_id)\n"
419 " Remove an UDP port for VXLAN packet filter on a port\n\n"
421 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
422 " Set hardware insertion of VLAN IDs (single or double VLAN "
423 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
425 "tx_vlan set pvid port_id vlan_id (on|off)\n"
426 " Set port based TX VLAN insertion.\n\n"
428 "tx_vlan reset (port_id)\n"
429 " Disable hardware insertion of a VLAN header in"
430 " packets sent on a port.\n\n"
432 "csum set (ip|udp|tcp|sctp|outer-ip|outer-udp) (hw|sw) (port_id)\n"
433 " Select hardware or software calculation of the"
434 " checksum when transmitting a packet using the"
435 " csum forward engine.\n"
436 " ip|udp|tcp|sctp always concern the inner layer.\n"
437 " outer-ip concerns the outer IP layer in"
438 " outer-udp concerns the outer UDP layer in"
439 " case the packet is recognized as a tunnel packet by"
440 " the forward engine (vxlan, gre and ipip are supported)\n"
441 " Please check the NIC datasheet for HW limits.\n\n"
443 "csum parse-tunnel (on|off) (tx_port_id)\n"
444 " If disabled, treat tunnel packets as non-tunneled"
445 " packets (treat inner headers as payload). The port\n"
446 " argument is the port used for TX in csum forward"
449 "csum show (port_id)\n"
450 " Display tx checksum offload configuration\n\n"
452 "tso set (segsize) (portid)\n"
453 " Enable TCP Segmentation Offload in csum forward"
455 " Please check the NIC datasheet for HW limits.\n\n"
458 " Display the status of TCP Segmentation Offload.\n\n"
460 "set port (port_id) gro on|off\n"
461 " Enable or disable Generic Receive Offload in"
462 " csum forwarding engine.\n\n"
464 "show port (port_id) gro\n"
465 " Display GRO configuration.\n\n"
467 "set gro flush (cycles)\n"
468 " Set the cycle to flush GROed packets from"
469 " reassembly tables.\n\n"
471 "set port (port_id) gso (on|off)"
472 " Enable or disable Generic Segmentation Offload in"
473 " csum forwarding engine.\n\n"
475 "set gso segsz (length)\n"
476 " Set max packet length for output GSO segments,"
477 " including packet header and payload.\n\n"
479 "show port (port_id) gso\n"
480 " Show GSO configuration.\n\n"
483 " Set packet forwarding mode.\n\n"
485 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
486 " Add a MAC address on port_id.\n\n"
488 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
489 " Remove a MAC address from port_id.\n\n"
491 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
492 " Set the default MAC address for port_id.\n\n"
494 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
495 " Add a MAC address for a VF on the port.\n\n"
497 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
498 " Set the MAC address for a VF from the PF.\n\n"
500 "set eth-peer (port_id) (peer_addr)\n"
501 " set the peer address for certain port.\n\n"
503 "set port (port_id) uta (mac_address|all) (on|off)\n"
504 " Add/Remove a or all unicast hash filter(s)"
507 "set promisc (port_id|all) (on|off)\n"
508 " Set the promiscuous mode on port_id, or all.\n\n"
510 "set allmulti (port_id|all) (on|off)\n"
511 " Set the allmulti mode on port_id, or all.\n\n"
513 "set vf promisc (port_id) (vf_id) (on|off)\n"
514 " Set unicast promiscuous mode for a VF from the PF.\n\n"
516 "set vf allmulti (port_id) (vf_id) (on|off)\n"
517 " Set multicast promiscuous mode for a VF from the PF.\n\n"
519 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
520 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
521 " (on|off) autoneg (on|off) (port_id)\n"
522 "set flow_ctrl rx (on|off) (portid)\n"
523 "set flow_ctrl tx (on|off) (portid)\n"
524 "set flow_ctrl high_water (high_water) (portid)\n"
525 "set flow_ctrl low_water (low_water) (portid)\n"
526 "set flow_ctrl pause_time (pause_time) (portid)\n"
527 "set flow_ctrl send_xon (send_xon) (portid)\n"
528 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
529 "set flow_ctrl autoneg (on|off) (port_id)\n"
530 " Set the link flow control parameter on a port.\n\n"
532 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
533 " (low_water) (pause_time) (priority) (port_id)\n"
534 " Set the priority flow control parameter on a"
537 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
538 " Set statistics mapping (qmapping 0..15) for RX/TX"
540 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
541 " on port 0 to mapping 5.\n\n"
543 "set xstats-hide-zero on|off\n"
544 " Set the option to hide the zero values"
545 " for xstats display.\n"
547 "set record-core-cycles on|off\n"
548 " Set the option to enable measurement of CPU cycles.\n"
550 "set record-burst-stats on|off\n"
551 " Set the option to enable display of RX and TX bursts.\n"
553 "set port (port_id) vf (vf_id) rx|tx on|off\n"
554 " Enable/Disable a VF receive/tranmit from a port\n\n"
556 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
558 " AUPE:accepts untagged VLAN;"
559 "ROPE:accept unicast hash\n\n"
560 " BAM:accepts broadcast packets;"
561 "MPE:accepts all multicast packets\n\n"
562 " Enable/Disable a VF receive mode of a port\n\n"
564 "set port (port_id) queue (queue_id) rate (rate_num)\n"
565 " Set rate limit for a queue of a port\n\n"
567 "set port (port_id) vf (vf_id) rate (rate_num) "
568 "queue_mask (queue_mask_value)\n"
569 " Set rate limit for queues in VF of a port\n\n"
571 "set port (port_id) mirror-rule (rule_id)"
572 " (pool-mirror-up|pool-mirror-down|vlan-mirror)"
573 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
574 " Set pool or vlan type mirror rule on a port.\n"
575 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
576 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
579 "set port (port_id) mirror-rule (rule_id)"
580 " (uplink-mirror|downlink-mirror) dst-pool"
581 " (pool_id) (on|off)\n"
582 " Set uplink or downlink type mirror rule on a port.\n"
583 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
584 " 0 on' enable mirror income traffic to pool 0.\n\n"
586 "reset port (port_id) mirror-rule (rule_id)\n"
587 " Reset a mirror rule.\n\n"
589 "set flush_rx (on|off)\n"
590 " Flush (default) or don't flush RX streams before"
591 " forwarding. Mainly used with PCAP drivers.\n\n"
593 "set bypass mode (normal|bypass|isolate) (port_id)\n"
594 " Set the bypass mode for the lowest port on bypass enabled"
597 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
598 "mode (normal|bypass|isolate) (port_id)\n"
599 " Set the event required to initiate specified bypass mode for"
600 " the lowest port on a bypass enabled NIC where:\n"
601 " timeout = enable bypass after watchdog timeout.\n"
602 " os_on = enable bypass when OS/board is powered on.\n"
603 " os_off = enable bypass when OS/board is powered off.\n"
604 " power_on = enable bypass when power supply is turned on.\n"
605 " power_off = enable bypass when power supply is turned off."
608 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
609 " Set the bypass watchdog timeout to 'n' seconds"
610 " where 0 = instant.\n\n"
612 "show bypass config (port_id)\n"
613 " Show the bypass configuration for a bypass enabled NIC"
614 " using the lowest port on the NIC.\n\n"
617 "create bonded device (mode) (socket)\n"
618 " Create a new bonded device with specific bonding mode and socket.\n\n"
620 "add bonding slave (slave_id) (port_id)\n"
621 " Add a slave device to a bonded device.\n\n"
623 "remove bonding slave (slave_id) (port_id)\n"
624 " Remove a slave device from a bonded device.\n\n"
626 "set bonding mode (value) (port_id)\n"
627 " Set the bonding mode on a bonded device.\n\n"
629 "set bonding primary (slave_id) (port_id)\n"
630 " Set the primary slave for a bonded device.\n\n"
632 "show bonding config (port_id)\n"
633 " Show the bonding config for port_id.\n\n"
635 "set bonding mac_addr (port_id) (address)\n"
636 " Set the MAC address of a bonded device.\n\n"
638 "set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)"
639 " Set Aggregation mode for IEEE802.3AD (mode 4)"
641 "set bonding balance_xmit_policy (port_id) (l2|l23|l34)\n"
642 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
644 "set bonding mon_period (port_id) (value)\n"
645 " Set the bonding link status monitoring polling period in ms.\n\n"
647 "set bonding lacp dedicated_queues <port_id> (enable|disable)\n"
648 " Enable/disable dedicated queues for LACP control traffic.\n\n"
651 "set link-up port (port_id)\n"
652 " Set link up for a port.\n\n"
654 "set link-down port (port_id)\n"
655 " Set link down for a port.\n\n"
657 "ddp add (port_id) (profile_path[,backup_profile_path])\n"
658 " Load a profile package on a port\n\n"
660 "ddp del (port_id) (backup_profile_path)\n"
661 " Delete a profile package from a port\n\n"
663 "ptype mapping get (port_id) (valid_only)\n"
664 " Get ptype mapping on a port\n\n"
666 "ptype mapping replace (port_id) (target) (mask) (pky_type)\n"
667 " Replace target with the pkt_type in ptype mapping\n\n"
669 "ptype mapping reset (port_id)\n"
670 " Reset ptype mapping on a port\n\n"
672 "ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n"
673 " Update a ptype mapping item on a port\n\n"
675 "set port (port_id) ptype_mask (ptype_mask)\n"
676 " set packet types classification for a specific port\n\n"
678 "set port (port_id) queue-region region_id (value) "
679 "queue_start_index (value) queue_num (value)\n"
680 " Set a queue region on a port\n\n"
682 "set port (port_id) queue-region region_id (value) "
684 " Set a flowtype region index on a port\n\n"
686 "set port (port_id) queue-region UP (value) region_id (value)\n"
687 " Set the mapping of User Priority to "
688 "queue region on a port\n\n"
690 "set port (port_id) queue-region flush (on|off)\n"
691 " flush all queue region related configuration\n\n"
693 "show port meter cap (port_id)\n"
694 " Show port meter capability information\n\n"
696 "add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs) (packet_mode)\n"
697 " meter profile add - srtcm rfc 2697\n\n"
699 "add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs) (packet_mode)\n"
700 " meter profile add - trtcm rfc 2698\n\n"
702 "add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs) (packet_mode)\n"
703 " meter profile add - trtcm rfc 4115\n\n"
705 "del port meter profile (port_id) (profile_id)\n"
706 " meter profile delete\n\n"
708 "create port meter (port_id) (mtr_id) (profile_id) (policy_id) (meter_enable)\n"
709 "(stats_mask) (shared) (use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n"
710 "(dscp_tbl_entry63)]\n"
713 "enable port meter (port_id) (mtr_id)\n"
716 "disable port meter (port_id) (mtr_id)\n"
719 "del port meter (port_id) (mtr_id)\n"
722 "add port meter policy (port_id) (policy_id) g_actions (actions)\n"
723 "y_actions (actions) r_actions (actions)\n"
724 " meter policy add\n\n"
726 "del port meter policy (port_id) (policy_id)\n"
727 " meter policy delete\n\n"
729 "set port meter profile (port_id) (mtr_id) (profile_id)\n"
730 " meter update meter profile\n\n"
732 "set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n"
733 "(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n"
734 " update meter dscp table entries\n\n"
736 "set port meter policer action (port_id) (mtr_id) (action_mask)\n"
737 "(action0) [(action1) (action2)]\n"
738 " meter update policer action\n\n"
740 "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
741 " meter update stats\n\n"
743 "show port (port_id) queue-region\n"
744 " show all queue region related configuration info\n\n"
746 "set port (port_id) fec_mode auto|off|rs|baser\n"
747 " set fec mode for a specific port\n\n"
749 , list_pkt_forwarding_modes()
753 if (show_all || !strcmp(res->section, "ports")) {
759 "----------------\n\n"
761 "port start (port_id|all)\n"
762 " Start all ports or port_id.\n\n"
764 "port stop (port_id|all)\n"
765 " Stop all ports or port_id.\n\n"
767 "port close (port_id|all)\n"
768 " Close all ports or port_id.\n\n"
770 "port reset (port_id|all)\n"
771 " Reset all ports or port_id.\n\n"
773 "port attach (ident)\n"
774 " Attach physical or virtual dev by pci address or virtual device name\n\n"
776 "port detach (port_id)\n"
777 " Detach physical or virtual dev by port_id\n\n"
779 "port config (port_id|all)"
780 " speed (10|100|1000|10000|25000|40000|50000|100000|200000|auto)"
781 " duplex (half|full|auto)\n"
782 " Set speed and duplex for all ports or port_id\n\n"
784 "port config (port_id|all) loopback (mode)\n"
785 " Set loopback mode for all ports or port_id\n\n"
787 "port config all (rxq|txq|rxd|txd) (value)\n"
788 " Set number for rxq/txq/rxd/txd.\n\n"
790 "port config all max-pkt-len (value)\n"
791 " Set the max packet length.\n\n"
793 "port config all max-lro-pkt-size (value)\n"
794 " Set the max LRO aggregated packet size.\n\n"
796 "port config all drop-en (on|off)\n"
797 " Enable or disable packet drop on all RX queues of all ports when no "
798 "receive buffers available.\n\n"
800 "port config all rss (all|default|ip|tcp|udp|sctp|"
801 "ether|port|vxlan|geneve|nvgre|vxlan-gpe|ecpri|mpls|none|level-default|"
802 "level-outer|level-inner|<flowtype_id>)\n"
803 " Set the RSS mode.\n\n"
805 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
806 " Set the RSS redirection table.\n\n"
808 "port config (port_id) dcb vt (on|off) (traffic_class)"
810 " Set the DCB mode.\n\n"
812 "port config all burst (value)\n"
813 " Set the number of packets per burst.\n\n"
815 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
817 " Set the ring prefetch/host/writeback threshold"
818 " for tx/rx queue.\n\n"
820 "port config all (txfreet|txrst|rxfreet) (value)\n"
821 " Set free threshold for rx/tx, or set"
822 " tx rs bit threshold.\n\n"
823 "port config mtu X value\n"
824 " Set the MTU of port X to a given value\n\n"
826 "port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n"
827 " Set a rx/tx queue's ring size configuration, the new"
828 " value will take effect after command that (re-)start the port"
829 " or command that setup the specific queue\n\n"
831 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
832 " Start/stop a rx/tx queue of port X. Only take effect"
833 " when port X is started\n\n"
835 "port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n"
836 " Switch on/off a deferred start of port X rx/tx queue. Only"
837 " take effect when port X is stopped.\n\n"
839 "port (port_id) (rxq|txq) (queue_id) setup\n"
840 " Setup a rx/tx queue of port X.\n\n"
842 "port config (port_id) pctype mapping reset\n"
843 " Reset flow type to pctype mapping on a port\n\n"
845 "port config (port_id) pctype mapping update"
846 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
847 " Update a flow type to pctype mapping item on a port\n\n"
849 "port config (port_id) pctype (pctype_id) hash_inset|"
850 "fdir_inset|fdir_flx_inset get|set|clear field\n"
852 " Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n"
854 "port config (port_id) pctype (pctype_id) hash_inset|"
855 "fdir_inset|fdir_flx_inset clear all"
856 " Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n"
858 "port config (port_id) udp_tunnel_port add|rm vxlan|geneve|ecpri (udp_port)\n\n"
859 " Add/remove UDP tunnel port for tunneling offload\n\n"
861 "port config <port_id> rx_offload vlan_strip|"
862 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
863 "outer_ipv4_cksum|macsec_strip|header_split|"
864 "vlan_filter|vlan_extend|jumbo_frame|scatter|"
865 "buffer_split|timestamp|security|keep_crc on|off\n"
866 " Enable or disable a per port Rx offloading"
867 " on all Rx queues of a port\n\n"
869 "port (port_id) rxq (queue_id) rx_offload vlan_strip|"
870 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
871 "outer_ipv4_cksum|macsec_strip|header_split|"
872 "vlan_filter|vlan_extend|jumbo_frame|scatter|"
873 "buffer_split|timestamp|security|keep_crc on|off\n"
874 " Enable or disable a per queue Rx offloading"
875 " only on a specific Rx queue\n\n"
877 "port config (port_id) tx_offload vlan_insert|"
878 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
879 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
880 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|"
881 "macsec_insert|mt_lockfree|multi_segs|mbuf_fast_free|"
883 " Enable or disable a per port Tx offloading"
884 " on all Tx queues of a port\n\n"
886 "port (port_id) txq (queue_id) tx_offload vlan_insert|"
887 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
888 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
889 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|macsec_insert"
890 "|mt_lockfree|multi_segs|mbuf_fast_free|security"
892 " Enable or disable a per queue Tx offloading"
893 " only on a specific Tx queue\n\n"
895 "bpf-load rx|tx (port) (queue) (J|M|B) (file_name)\n"
896 " Load an eBPF program as a callback"
897 " for particular RX/TX queue\n\n"
899 "bpf-unload rx|tx (port) (queue)\n"
900 " Unload previously loaded eBPF program"
901 " for particular RX/TX queue\n\n"
903 "port config (port_id) tx_metadata (value)\n"
904 " Set Tx metadata value per port. Testpmd will add this value"
905 " to any Tx packet sent from this port\n\n"
907 "port config (port_id) dynf (name) set|clear\n"
908 " Register a dynf and Set/clear this flag on Tx. "
909 "Testpmd will set this value to any Tx packet "
910 "sent from this port\n\n"
914 if (show_all || !strcmp(res->section, "registers")) {
922 "read reg (port_id) (address)\n"
923 " Display value of a port register.\n\n"
925 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
926 " Display a port register bit field.\n\n"
928 "read regbit (port_id) (address) (bit_x)\n"
929 " Display a single port register bit.\n\n"
931 "write reg (port_id) (address) (value)\n"
932 " Set value of a port register.\n\n"
934 "write regfield (port_id) (address) (bit_x) (bit_y)"
936 " Set bit field of a port register.\n\n"
938 "write regbit (port_id) (address) (bit_x) (value)\n"
939 " Set single bit value of a port register.\n\n"
942 if (show_all || !strcmp(res->section, "filters")) {
951 "flow_director_filter (port_id) mode raw (add|del|update)"
952 " flow (flow_id) (drop|fwd) queue (queue_id)"
953 " fd_id (fd_id_value) packet (packet file name)\n"
954 " Add/Del a raw type flow director filter.\n\n"
957 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
958 " src_mask (ipv4_src) (ipv6_src) (src_port)"
959 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
960 " Set flow director IP mask.\n\n"
962 "flow_director_mask (port_id) mode MAC-VLAN"
963 " vlan (vlan_value)\n"
964 " Set flow director MAC-VLAN mask.\n\n"
966 "flow_director_mask (port_id) mode Tunnel"
967 " vlan (vlan_value) mac (mac_value)"
968 " tunnel-type (tunnel_type_value)"
969 " tunnel-id (tunnel_id_value)\n"
970 " Set flow director Tunnel mask.\n\n"
972 "flow_director_flex_payload (port_id)"
973 " (raw|l2|l3|l4) (config)\n"
974 " Configure flex payload selection.\n\n"
976 "flow validate {port_id}"
977 " [group {group_id}] [priority {level}]"
978 " [ingress] [egress]"
979 " pattern {item} [/ {item} [...]] / end"
980 " actions {action} [/ {action} [...]] / end\n"
981 " Check whether a flow rule can be created.\n\n"
983 "flow create {port_id}"
984 " [group {group_id}] [priority {level}]"
985 " [ingress] [egress]"
986 " pattern {item} [/ {item} [...]] / end"
987 " actions {action} [/ {action} [...]] / end\n"
988 " Create a flow rule.\n\n"
990 "flow destroy {port_id} rule {rule_id} [...]\n"
991 " Destroy specific flow rules.\n\n"
993 "flow flush {port_id}\n"
994 " Destroy all flow rules.\n\n"
996 "flow query {port_id} {rule_id} {action}\n"
997 " Query an existing flow rule.\n\n"
999 "flow list {port_id} [group {group_id}] [...]\n"
1000 " List existing flow rules sorted by priority,"
1001 " filtered by group identifiers.\n\n"
1003 "flow isolate {port_id} {boolean}\n"
1004 " Restrict ingress traffic to the defined"
1007 "flow aged {port_id} [destroy]\n"
1008 " List and destroy aged flows"
1011 "flow indirect_action {port_id} create"
1012 " [action_id {indirect_action_id}]"
1013 " [ingress] [egress]"
1014 " action {action} / end\n"
1015 " Create indirect action.\n\n"
1017 "flow indirect_action {port_id} update"
1018 " {indirect_action_id} action {action} / end\n"
1019 " Update indirect action.\n\n"
1021 "flow indirect_action {port_id} destroy"
1022 " action_id {indirect_action_id} [...]\n"
1023 " Destroy specific indirect actions.\n\n"
1025 "flow indirect_action {port_id} query"
1026 " {indirect_action_id}\n"
1027 " Query an existing indirect action.\n\n"
1029 "set vxlan ip-version (ipv4|ipv6) vni (vni) udp-src"
1030 " (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst"
1031 " (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n"
1032 " Configure the VXLAN encapsulation for flows.\n\n"
1034 "set vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)"
1035 " udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)"
1036 " ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)"
1037 " eth-dst (eth-dst)\n"
1038 " Configure the VXLAN encapsulation for flows.\n\n"
1040 "set vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src"
1041 " (udp-src) udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl)"
1042 " ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src)"
1043 " eth-dst (eth-dst)\n"
1044 " Configure the VXLAN encapsulation for flows.\n\n"
1046 "set nvgre ip-version (ipv4|ipv6) tni (tni) ip-src"
1047 " (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst"
1049 " Configure the NVGRE encapsulation for flows.\n\n"
1051 "set nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)"
1052 " ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)"
1053 " eth-src (eth-src) eth-dst (eth-dst)\n"
1054 " Configure the NVGRE encapsulation for flows.\n\n"
1056 "set raw_encap {flow items}\n"
1057 " Configure the encapsulation with raw data.\n\n"
1059 "set raw_decap {flow items}\n"
1060 " Configure the decapsulation with raw data.\n\n"
1065 if (show_all || !strcmp(res->section, "traffic_management")) {
1069 "Traffic Management:\n"
1071 "show port tm cap (port_id)\n"
1072 " Display the port TM capability.\n\n"
1074 "show port tm level cap (port_id) (level_id)\n"
1075 " Display the port TM hierarchical level capability.\n\n"
1077 "show port tm node cap (port_id) (node_id)\n"
1078 " Display the port TM node capability.\n\n"
1080 "show port tm node type (port_id) (node_id)\n"
1081 " Display the port TM node type.\n\n"
1083 "show port tm node stats (port_id) (node_id) (clear)\n"
1084 " Display the port TM node stats.\n\n"
1086 "add port tm node shaper profile (port_id) (shaper_profile_id)"
1087 " (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)"
1088 " (packet_length_adjust) (packet_mode)\n"
1089 " Add port tm node private shaper profile.\n\n"
1091 "del port tm node shaper profile (port_id) (shaper_profile_id)\n"
1092 " Delete port tm node private shaper profile.\n\n"
1094 "add port tm node shared shaper (port_id) (shared_shaper_id)"
1095 " (shaper_profile_id)\n"
1096 " Add/update port tm node shared shaper.\n\n"
1098 "del port tm node shared shaper (port_id) (shared_shaper_id)\n"
1099 " Delete port tm node shared shaper.\n\n"
1101 "set port tm node shaper profile (port_id) (node_id)"
1102 " (shaper_profile_id)\n"
1103 " Set port tm node shaper profile.\n\n"
1105 "add port tm node wred profile (port_id) (wred_profile_id)"
1106 " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
1107 " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
1108 " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
1109 " Add port tm node wred profile.\n\n"
1111 "del port tm node wred profile (port_id) (wred_profile_id)\n"
1112 " Delete port tm node wred profile.\n\n"
1114 "add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
1115 " (priority) (weight) (level_id) (shaper_profile_id)"
1116 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1117 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1118 " Add port tm nonleaf node.\n\n"
1120 "add port tm nonleaf node pktmode (port_id) (node_id) (parent_node_id)"
1121 " (priority) (weight) (level_id) (shaper_profile_id)"
1122 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1123 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1124 " Add port tm nonleaf node with pkt mode enabled.\n\n"
1126 "add port tm leaf node (port_id) (node_id) (parent_node_id)"
1127 " (priority) (weight) (level_id) (shaper_profile_id)"
1128 " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
1129 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1130 " Add port tm leaf node.\n\n"
1132 "del port tm node (port_id) (node_id)\n"
1133 " Delete port tm node.\n\n"
1135 "set port tm node parent (port_id) (node_id) (parent_node_id)"
1136 " (priority) (weight)\n"
1137 " Set port tm node parent.\n\n"
1139 "suspend port tm node (port_id) (node_id)"
1140 " Suspend tm node.\n\n"
1142 "resume port tm node (port_id) (node_id)"
1143 " Resume tm node.\n\n"
1145 "port tm hierarchy commit (port_id) (clean_on_fail)\n"
1146 " Commit tm hierarchy.\n\n"
1148 "set port tm mark ip_ecn (port) (green) (yellow)"
1150 " Enables/Disables the traffic management marking"
1151 " for IP ECN (Explicit Congestion Notification)"
1152 " packets on a given port\n\n"
1154 "set port tm mark ip_dscp (port) (green) (yellow)"
1156 " Enables/Disables the traffic management marking"
1157 " on the port for IP dscp packets\n\n"
1159 "set port tm mark vlan_dei (port) (green) (yellow)"
1161 " Enables/Disables the traffic management marking"
1162 " on the port for VLAN packets with DEI enabled\n\n"
1166 if (show_all || !strcmp(res->section, "devices")) {
1170 "Device Operations:\n"
1172 "device detach (identifier)\n"
1173 " Detach device by identifier.\n\n"
1179 cmdline_parse_token_string_t cmd_help_long_help =
1180 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1182 cmdline_parse_token_string_t cmd_help_long_section =
1183 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1184 "all#control#display#config#"
1185 "ports#registers#filters#traffic_management#devices");
1187 cmdline_parse_inst_t cmd_help_long = {
1188 .f = cmd_help_long_parsed,
1190 .help_str = "help all|control|display|config|ports|register|"
1191 "filters|traffic_management|devices: "
1194 (void *)&cmd_help_long_help,
1195 (void *)&cmd_help_long_section,
1201 /* *** start/stop/close all ports *** */
1202 struct cmd_operate_port_result {
1203 cmdline_fixed_string_t keyword;
1204 cmdline_fixed_string_t name;
1205 cmdline_fixed_string_t value;
1208 static void cmd_operate_port_parsed(void *parsed_result,
1209 __rte_unused struct cmdline *cl,
1210 __rte_unused void *data)
1212 struct cmd_operate_port_result *res = parsed_result;
1214 if (!strcmp(res->name, "start"))
1215 start_port(RTE_PORT_ALL);
1216 else if (!strcmp(res->name, "stop"))
1217 stop_port(RTE_PORT_ALL);
1218 else if (!strcmp(res->name, "close"))
1219 close_port(RTE_PORT_ALL);
1220 else if (!strcmp(res->name, "reset"))
1221 reset_port(RTE_PORT_ALL);
1223 printf("Unknown parameter\n");
1226 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1227 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1229 cmdline_parse_token_string_t cmd_operate_port_all_port =
1230 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1231 "start#stop#close#reset");
1232 cmdline_parse_token_string_t cmd_operate_port_all_all =
1233 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1235 cmdline_parse_inst_t cmd_operate_port = {
1236 .f = cmd_operate_port_parsed,
1238 .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports",
1240 (void *)&cmd_operate_port_all_cmd,
1241 (void *)&cmd_operate_port_all_port,
1242 (void *)&cmd_operate_port_all_all,
1247 /* *** start/stop/close specific port *** */
1248 struct cmd_operate_specific_port_result {
1249 cmdline_fixed_string_t keyword;
1250 cmdline_fixed_string_t name;
1254 static void cmd_operate_specific_port_parsed(void *parsed_result,
1255 __rte_unused struct cmdline *cl,
1256 __rte_unused void *data)
1258 struct cmd_operate_specific_port_result *res = parsed_result;
1260 if (!strcmp(res->name, "start"))
1261 start_port(res->value);
1262 else if (!strcmp(res->name, "stop"))
1263 stop_port(res->value);
1264 else if (!strcmp(res->name, "close"))
1265 close_port(res->value);
1266 else if (!strcmp(res->name, "reset"))
1267 reset_port(res->value);
1269 printf("Unknown parameter\n");
1272 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1273 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1275 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1276 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1277 name, "start#stop#close#reset");
1278 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1279 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1282 cmdline_parse_inst_t cmd_operate_specific_port = {
1283 .f = cmd_operate_specific_port_parsed,
1285 .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id",
1287 (void *)&cmd_operate_specific_port_cmd,
1288 (void *)&cmd_operate_specific_port_port,
1289 (void *)&cmd_operate_specific_port_id,
1294 /* *** enable port setup (after attach) via iterator or event *** */
1295 struct cmd_set_port_setup_on_result {
1296 cmdline_fixed_string_t set;
1297 cmdline_fixed_string_t port;
1298 cmdline_fixed_string_t setup;
1299 cmdline_fixed_string_t on;
1300 cmdline_fixed_string_t mode;
1303 static void cmd_set_port_setup_on_parsed(void *parsed_result,
1304 __rte_unused struct cmdline *cl,
1305 __rte_unused void *data)
1307 struct cmd_set_port_setup_on_result *res = parsed_result;
1309 if (strcmp(res->mode, "event") == 0)
1310 setup_on_probe_event = true;
1311 else if (strcmp(res->mode, "iterator") == 0)
1312 setup_on_probe_event = false;
1314 printf("Unknown mode\n");
1317 cmdline_parse_token_string_t cmd_set_port_setup_on_set =
1318 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1320 cmdline_parse_token_string_t cmd_set_port_setup_on_port =
1321 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1323 cmdline_parse_token_string_t cmd_set_port_setup_on_setup =
1324 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1326 cmdline_parse_token_string_t cmd_set_port_setup_on_on =
1327 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1329 cmdline_parse_token_string_t cmd_set_port_setup_on_mode =
1330 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1331 mode, "iterator#event");
1333 cmdline_parse_inst_t cmd_set_port_setup_on = {
1334 .f = cmd_set_port_setup_on_parsed,
1336 .help_str = "set port setup on iterator|event",
1338 (void *)&cmd_set_port_setup_on_set,
1339 (void *)&cmd_set_port_setup_on_port,
1340 (void *)&cmd_set_port_setup_on_setup,
1341 (void *)&cmd_set_port_setup_on_on,
1342 (void *)&cmd_set_port_setup_on_mode,
1347 /* *** attach a specified port *** */
1348 struct cmd_operate_attach_port_result {
1349 cmdline_fixed_string_t port;
1350 cmdline_fixed_string_t keyword;
1351 cmdline_multi_string_t identifier;
1354 static void cmd_operate_attach_port_parsed(void *parsed_result,
1355 __rte_unused struct cmdline *cl,
1356 __rte_unused void *data)
1358 struct cmd_operate_attach_port_result *res = parsed_result;
1360 if (!strcmp(res->keyword, "attach"))
1361 attach_port(res->identifier);
1363 printf("Unknown parameter\n");
1366 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1367 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1369 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1370 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1372 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1373 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1374 identifier, TOKEN_STRING_MULTI);
1376 cmdline_parse_inst_t cmd_operate_attach_port = {
1377 .f = cmd_operate_attach_port_parsed,
1379 .help_str = "port attach <identifier>: "
1380 "(identifier: pci address or virtual dev name)",
1382 (void *)&cmd_operate_attach_port_port,
1383 (void *)&cmd_operate_attach_port_keyword,
1384 (void *)&cmd_operate_attach_port_identifier,
1389 /* *** detach a specified port *** */
1390 struct cmd_operate_detach_port_result {
1391 cmdline_fixed_string_t port;
1392 cmdline_fixed_string_t keyword;
1396 static void cmd_operate_detach_port_parsed(void *parsed_result,
1397 __rte_unused struct cmdline *cl,
1398 __rte_unused void *data)
1400 struct cmd_operate_detach_port_result *res = parsed_result;
1402 if (!strcmp(res->keyword, "detach")) {
1403 RTE_ETH_VALID_PORTID_OR_RET(res->port_id);
1404 detach_port_device(res->port_id);
1406 printf("Unknown parameter\n");
1410 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1411 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1413 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1414 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1416 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1417 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1418 port_id, RTE_UINT16);
1420 cmdline_parse_inst_t cmd_operate_detach_port = {
1421 .f = cmd_operate_detach_port_parsed,
1423 .help_str = "port detach <port_id>",
1425 (void *)&cmd_operate_detach_port_port,
1426 (void *)&cmd_operate_detach_port_keyword,
1427 (void *)&cmd_operate_detach_port_port_id,
1432 /* *** detach device by identifier *** */
1433 struct cmd_operate_detach_device_result {
1434 cmdline_fixed_string_t device;
1435 cmdline_fixed_string_t keyword;
1436 cmdline_fixed_string_t identifier;
1439 static void cmd_operate_detach_device_parsed(void *parsed_result,
1440 __rte_unused struct cmdline *cl,
1441 __rte_unused void *data)
1443 struct cmd_operate_detach_device_result *res = parsed_result;
1445 if (!strcmp(res->keyword, "detach"))
1446 detach_devargs(res->identifier);
1448 printf("Unknown parameter\n");
1451 cmdline_parse_token_string_t cmd_operate_detach_device_device =
1452 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1454 cmdline_parse_token_string_t cmd_operate_detach_device_keyword =
1455 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1457 cmdline_parse_token_string_t cmd_operate_detach_device_identifier =
1458 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1461 cmdline_parse_inst_t cmd_operate_detach_device = {
1462 .f = cmd_operate_detach_device_parsed,
1464 .help_str = "device detach <identifier>:"
1465 "(identifier: pci address or virtual dev name)",
1467 (void *)&cmd_operate_detach_device_device,
1468 (void *)&cmd_operate_detach_device_keyword,
1469 (void *)&cmd_operate_detach_device_identifier,
1473 /* *** configure speed for all ports *** */
1474 struct cmd_config_speed_all {
1475 cmdline_fixed_string_t port;
1476 cmdline_fixed_string_t keyword;
1477 cmdline_fixed_string_t all;
1478 cmdline_fixed_string_t item1;
1479 cmdline_fixed_string_t item2;
1480 cmdline_fixed_string_t value1;
1481 cmdline_fixed_string_t value2;
1485 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1490 if (!strcmp(duplexstr, "half")) {
1491 duplex = ETH_LINK_HALF_DUPLEX;
1492 } else if (!strcmp(duplexstr, "full")) {
1493 duplex = ETH_LINK_FULL_DUPLEX;
1494 } else if (!strcmp(duplexstr, "auto")) {
1495 duplex = ETH_LINK_FULL_DUPLEX;
1497 printf("Unknown duplex parameter\n");
1501 if (!strcmp(speedstr, "10")) {
1502 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1503 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1504 } else if (!strcmp(speedstr, "100")) {
1505 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1506 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1508 if (duplex != ETH_LINK_FULL_DUPLEX) {
1509 printf("Invalid speed/duplex parameters\n");
1512 if (!strcmp(speedstr, "1000")) {
1513 *speed = ETH_LINK_SPEED_1G;
1514 } else if (!strcmp(speedstr, "10000")) {
1515 *speed = ETH_LINK_SPEED_10G;
1516 } else if (!strcmp(speedstr, "25000")) {
1517 *speed = ETH_LINK_SPEED_25G;
1518 } else if (!strcmp(speedstr, "40000")) {
1519 *speed = ETH_LINK_SPEED_40G;
1520 } else if (!strcmp(speedstr, "50000")) {
1521 *speed = ETH_LINK_SPEED_50G;
1522 } else if (!strcmp(speedstr, "100000")) {
1523 *speed = ETH_LINK_SPEED_100G;
1524 } else if (!strcmp(speedstr, "200000")) {
1525 *speed = ETH_LINK_SPEED_200G;
1526 } else if (!strcmp(speedstr, "auto")) {
1527 *speed = ETH_LINK_SPEED_AUTONEG;
1529 printf("Unknown speed parameter\n");
1534 if (*speed != ETH_LINK_SPEED_AUTONEG)
1535 *speed |= ETH_LINK_SPEED_FIXED;
1541 cmd_config_speed_all_parsed(void *parsed_result,
1542 __rte_unused struct cmdline *cl,
1543 __rte_unused void *data)
1545 struct cmd_config_speed_all *res = parsed_result;
1546 uint32_t link_speed;
1549 if (!all_ports_stopped()) {
1550 printf("Please stop all ports first\n");
1554 if (parse_and_check_speed_duplex(res->value1, res->value2,
1558 RTE_ETH_FOREACH_DEV(pid) {
1559 ports[pid].dev_conf.link_speeds = link_speed;
1562 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1565 cmdline_parse_token_string_t cmd_config_speed_all_port =
1566 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1567 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1568 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1570 cmdline_parse_token_string_t cmd_config_speed_all_all =
1571 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1572 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1573 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1574 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1575 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1576 "10#100#1000#10000#25000#40000#50000#100000#200000#auto");
1577 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1578 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1579 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1580 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1583 cmdline_parse_inst_t cmd_config_speed_all = {
1584 .f = cmd_config_speed_all_parsed,
1586 .help_str = "port config all speed "
1587 "10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex "
1590 (void *)&cmd_config_speed_all_port,
1591 (void *)&cmd_config_speed_all_keyword,
1592 (void *)&cmd_config_speed_all_all,
1593 (void *)&cmd_config_speed_all_item1,
1594 (void *)&cmd_config_speed_all_value1,
1595 (void *)&cmd_config_speed_all_item2,
1596 (void *)&cmd_config_speed_all_value2,
1601 /* *** configure speed for specific port *** */
1602 struct cmd_config_speed_specific {
1603 cmdline_fixed_string_t port;
1604 cmdline_fixed_string_t keyword;
1606 cmdline_fixed_string_t item1;
1607 cmdline_fixed_string_t item2;
1608 cmdline_fixed_string_t value1;
1609 cmdline_fixed_string_t value2;
1613 cmd_config_speed_specific_parsed(void *parsed_result,
1614 __rte_unused struct cmdline *cl,
1615 __rte_unused void *data)
1617 struct cmd_config_speed_specific *res = parsed_result;
1618 uint32_t link_speed;
1620 if (!all_ports_stopped()) {
1621 printf("Please stop all ports first\n");
1625 if (port_id_is_invalid(res->id, ENABLED_WARN))
1628 if (parse_and_check_speed_duplex(res->value1, res->value2,
1632 ports[res->id].dev_conf.link_speeds = link_speed;
1634 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1638 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1639 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1641 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1642 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1644 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1645 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, RTE_UINT16);
1646 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1647 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1649 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1650 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1651 "10#100#1000#10000#25000#40000#50000#100000#200000#auto");
1652 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1653 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1655 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1656 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1659 cmdline_parse_inst_t cmd_config_speed_specific = {
1660 .f = cmd_config_speed_specific_parsed,
1662 .help_str = "port config <port_id> speed "
1663 "10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex "
1666 (void *)&cmd_config_speed_specific_port,
1667 (void *)&cmd_config_speed_specific_keyword,
1668 (void *)&cmd_config_speed_specific_id,
1669 (void *)&cmd_config_speed_specific_item1,
1670 (void *)&cmd_config_speed_specific_value1,
1671 (void *)&cmd_config_speed_specific_item2,
1672 (void *)&cmd_config_speed_specific_value2,
1677 /* *** configure loopback for all ports *** */
1678 struct cmd_config_loopback_all {
1679 cmdline_fixed_string_t port;
1680 cmdline_fixed_string_t keyword;
1681 cmdline_fixed_string_t all;
1682 cmdline_fixed_string_t item;
1687 cmd_config_loopback_all_parsed(void *parsed_result,
1688 __rte_unused struct cmdline *cl,
1689 __rte_unused void *data)
1691 struct cmd_config_loopback_all *res = parsed_result;
1694 if (!all_ports_stopped()) {
1695 printf("Please stop all ports first\n");
1699 RTE_ETH_FOREACH_DEV(pid) {
1700 ports[pid].dev_conf.lpbk_mode = res->mode;
1703 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1706 cmdline_parse_token_string_t cmd_config_loopback_all_port =
1707 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1708 cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1709 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1711 cmdline_parse_token_string_t cmd_config_loopback_all_all =
1712 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1713 cmdline_parse_token_string_t cmd_config_loopback_all_item =
1714 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1716 cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1717 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, RTE_UINT32);
1719 cmdline_parse_inst_t cmd_config_loopback_all = {
1720 .f = cmd_config_loopback_all_parsed,
1722 .help_str = "port config all loopback <mode>",
1724 (void *)&cmd_config_loopback_all_port,
1725 (void *)&cmd_config_loopback_all_keyword,
1726 (void *)&cmd_config_loopback_all_all,
1727 (void *)&cmd_config_loopback_all_item,
1728 (void *)&cmd_config_loopback_all_mode,
1733 /* *** configure loopback for specific port *** */
1734 struct cmd_config_loopback_specific {
1735 cmdline_fixed_string_t port;
1736 cmdline_fixed_string_t keyword;
1738 cmdline_fixed_string_t item;
1743 cmd_config_loopback_specific_parsed(void *parsed_result,
1744 __rte_unused struct cmdline *cl,
1745 __rte_unused void *data)
1747 struct cmd_config_loopback_specific *res = parsed_result;
1749 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1752 if (!port_is_stopped(res->port_id)) {
1753 printf("Please stop port %u first\n", res->port_id);
1757 ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1759 cmd_reconfig_device_queue(res->port_id, 1, 1);
1763 cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1764 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1766 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1767 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1769 cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1770 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1772 cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1773 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1775 cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1776 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1779 cmdline_parse_inst_t cmd_config_loopback_specific = {
1780 .f = cmd_config_loopback_specific_parsed,
1782 .help_str = "port config <port_id> loopback <mode>",
1784 (void *)&cmd_config_loopback_specific_port,
1785 (void *)&cmd_config_loopback_specific_keyword,
1786 (void *)&cmd_config_loopback_specific_id,
1787 (void *)&cmd_config_loopback_specific_item,
1788 (void *)&cmd_config_loopback_specific_mode,
1793 /* *** configure txq/rxq, txd/rxd *** */
1794 struct cmd_config_rx_tx {
1795 cmdline_fixed_string_t port;
1796 cmdline_fixed_string_t keyword;
1797 cmdline_fixed_string_t all;
1798 cmdline_fixed_string_t name;
1803 cmd_config_rx_tx_parsed(void *parsed_result,
1804 __rte_unused struct cmdline *cl,
1805 __rte_unused void *data)
1807 struct cmd_config_rx_tx *res = parsed_result;
1809 if (!all_ports_stopped()) {
1810 printf("Please stop all ports first\n");
1813 if (!strcmp(res->name, "rxq")) {
1814 if (!res->value && !nb_txq) {
1815 printf("Warning: Either rx or tx queues should be non zero\n");
1818 if (check_nb_rxq(res->value) != 0)
1820 nb_rxq = res->value;
1822 else if (!strcmp(res->name, "txq")) {
1823 if (!res->value && !nb_rxq) {
1824 printf("Warning: Either rx or tx queues should be non zero\n");
1827 if (check_nb_txq(res->value) != 0)
1829 nb_txq = res->value;
1831 else if (!strcmp(res->name, "rxd")) {
1832 if (check_nb_rxd(res->value) != 0)
1834 nb_rxd = res->value;
1835 } else if (!strcmp(res->name, "txd")) {
1836 if (check_nb_txd(res->value) != 0)
1839 nb_txd = res->value;
1841 printf("Unknown parameter\n");
1849 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1852 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1853 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1854 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1855 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1856 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1857 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1858 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1859 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1861 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1862 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, RTE_UINT16);
1864 cmdline_parse_inst_t cmd_config_rx_tx = {
1865 .f = cmd_config_rx_tx_parsed,
1867 .help_str = "port config all rxq|txq|rxd|txd <value>",
1869 (void *)&cmd_config_rx_tx_port,
1870 (void *)&cmd_config_rx_tx_keyword,
1871 (void *)&cmd_config_rx_tx_all,
1872 (void *)&cmd_config_rx_tx_name,
1873 (void *)&cmd_config_rx_tx_value,
1878 /* *** config max packet length *** */
1879 struct cmd_config_max_pkt_len_result {
1880 cmdline_fixed_string_t port;
1881 cmdline_fixed_string_t keyword;
1882 cmdline_fixed_string_t all;
1883 cmdline_fixed_string_t name;
1888 cmd_config_max_pkt_len_parsed(void *parsed_result,
1889 __rte_unused struct cmdline *cl,
1890 __rte_unused void *data)
1892 struct cmd_config_max_pkt_len_result *res = parsed_result;
1893 uint32_t max_rx_pkt_len_backup = 0;
1897 if (!all_ports_stopped()) {
1898 printf("Please stop all ports first\n");
1902 RTE_ETH_FOREACH_DEV(pid) {
1903 struct rte_port *port = &ports[pid];
1905 if (!strcmp(res->name, "max-pkt-len")) {
1906 if (res->value < RTE_ETHER_MIN_LEN) {
1907 printf("max-pkt-len can not be less than %d\n",
1911 if (res->value == port->dev_conf.rxmode.max_rx_pkt_len)
1914 ret = eth_dev_info_get_print_err(pid, &port->dev_info);
1916 printf("rte_eth_dev_info_get() failed for port %u\n",
1921 max_rx_pkt_len_backup = port->dev_conf.rxmode.max_rx_pkt_len;
1923 port->dev_conf.rxmode.max_rx_pkt_len = res->value;
1924 if (update_jumbo_frame_offload(pid) != 0)
1925 port->dev_conf.rxmode.max_rx_pkt_len = max_rx_pkt_len_backup;
1927 printf("Unknown parameter\n");
1934 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1937 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1938 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1940 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1941 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1943 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1944 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1946 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1947 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1949 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1950 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1953 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1954 .f = cmd_config_max_pkt_len_parsed,
1956 .help_str = "port config all max-pkt-len <value>",
1958 (void *)&cmd_config_max_pkt_len_port,
1959 (void *)&cmd_config_max_pkt_len_keyword,
1960 (void *)&cmd_config_max_pkt_len_all,
1961 (void *)&cmd_config_max_pkt_len_name,
1962 (void *)&cmd_config_max_pkt_len_value,
1967 /* *** config max LRO aggregated packet size *** */
1968 struct cmd_config_max_lro_pkt_size_result {
1969 cmdline_fixed_string_t port;
1970 cmdline_fixed_string_t keyword;
1971 cmdline_fixed_string_t all;
1972 cmdline_fixed_string_t name;
1977 cmd_config_max_lro_pkt_size_parsed(void *parsed_result,
1978 __rte_unused struct cmdline *cl,
1979 __rte_unused void *data)
1981 struct cmd_config_max_lro_pkt_size_result *res = parsed_result;
1984 if (!all_ports_stopped()) {
1985 printf("Please stop all ports first\n");
1989 RTE_ETH_FOREACH_DEV(pid) {
1990 struct rte_port *port = &ports[pid];
1992 if (!strcmp(res->name, "max-lro-pkt-size")) {
1994 port->dev_conf.rxmode.max_lro_pkt_size)
1997 port->dev_conf.rxmode.max_lro_pkt_size = res->value;
1999 printf("Unknown parameter\n");
2006 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2009 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_port =
2010 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2012 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_keyword =
2013 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2015 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_all =
2016 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2018 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_name =
2019 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2020 name, "max-lro-pkt-size");
2021 cmdline_parse_token_num_t cmd_config_max_lro_pkt_size_value =
2022 TOKEN_NUM_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2025 cmdline_parse_inst_t cmd_config_max_lro_pkt_size = {
2026 .f = cmd_config_max_lro_pkt_size_parsed,
2028 .help_str = "port config all max-lro-pkt-size <value>",
2030 (void *)&cmd_config_max_lro_pkt_size_port,
2031 (void *)&cmd_config_max_lro_pkt_size_keyword,
2032 (void *)&cmd_config_max_lro_pkt_size_all,
2033 (void *)&cmd_config_max_lro_pkt_size_name,
2034 (void *)&cmd_config_max_lro_pkt_size_value,
2039 /* *** configure port MTU *** */
2040 struct cmd_config_mtu_result {
2041 cmdline_fixed_string_t port;
2042 cmdline_fixed_string_t keyword;
2043 cmdline_fixed_string_t mtu;
2049 cmd_config_mtu_parsed(void *parsed_result,
2050 __rte_unused struct cmdline *cl,
2051 __rte_unused void *data)
2053 struct cmd_config_mtu_result *res = parsed_result;
2055 if (res->value < RTE_ETHER_MIN_LEN) {
2056 printf("mtu cannot be less than %d\n", RTE_ETHER_MIN_LEN);
2059 port_mtu_set(res->port_id, res->value);
2062 cmdline_parse_token_string_t cmd_config_mtu_port =
2063 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
2065 cmdline_parse_token_string_t cmd_config_mtu_keyword =
2066 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2068 cmdline_parse_token_string_t cmd_config_mtu_mtu =
2069 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2071 cmdline_parse_token_num_t cmd_config_mtu_port_id =
2072 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id,
2074 cmdline_parse_token_num_t cmd_config_mtu_value =
2075 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value,
2078 cmdline_parse_inst_t cmd_config_mtu = {
2079 .f = cmd_config_mtu_parsed,
2081 .help_str = "port config mtu <port_id> <value>",
2083 (void *)&cmd_config_mtu_port,
2084 (void *)&cmd_config_mtu_keyword,
2085 (void *)&cmd_config_mtu_mtu,
2086 (void *)&cmd_config_mtu_port_id,
2087 (void *)&cmd_config_mtu_value,
2092 /* *** configure rx mode *** */
2093 struct cmd_config_rx_mode_flag {
2094 cmdline_fixed_string_t port;
2095 cmdline_fixed_string_t keyword;
2096 cmdline_fixed_string_t all;
2097 cmdline_fixed_string_t name;
2098 cmdline_fixed_string_t value;
2102 cmd_config_rx_mode_flag_parsed(void *parsed_result,
2103 __rte_unused struct cmdline *cl,
2104 __rte_unused void *data)
2106 struct cmd_config_rx_mode_flag *res = parsed_result;
2108 if (!all_ports_stopped()) {
2109 printf("Please stop all ports first\n");
2113 if (!strcmp(res->name, "drop-en")) {
2114 if (!strcmp(res->value, "on"))
2116 else if (!strcmp(res->value, "off"))
2119 printf("Unknown parameter\n");
2123 printf("Unknown parameter\n");
2129 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2132 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
2133 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
2134 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
2135 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
2137 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2138 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2139 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2140 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2142 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2143 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2146 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2147 .f = cmd_config_rx_mode_flag_parsed,
2149 .help_str = "port config all drop-en on|off",
2151 (void *)&cmd_config_rx_mode_flag_port,
2152 (void *)&cmd_config_rx_mode_flag_keyword,
2153 (void *)&cmd_config_rx_mode_flag_all,
2154 (void *)&cmd_config_rx_mode_flag_name,
2155 (void *)&cmd_config_rx_mode_flag_value,
2160 /* *** configure rss *** */
2161 struct cmd_config_rss {
2162 cmdline_fixed_string_t port;
2163 cmdline_fixed_string_t keyword;
2164 cmdline_fixed_string_t all;
2165 cmdline_fixed_string_t name;
2166 cmdline_fixed_string_t value;
2170 cmd_config_rss_parsed(void *parsed_result,
2171 __rte_unused struct cmdline *cl,
2172 __rte_unused void *data)
2174 struct cmd_config_rss *res = parsed_result;
2175 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2176 struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2177 int use_default = 0;
2178 int all_updated = 1;
2183 if (!strcmp(res->value, "all"))
2184 rss_conf.rss_hf = ETH_RSS_ETH | ETH_RSS_VLAN | ETH_RSS_IP |
2185 ETH_RSS_TCP | ETH_RSS_UDP | ETH_RSS_SCTP |
2186 ETH_RSS_L2_PAYLOAD | ETH_RSS_L2TPV3 | ETH_RSS_ESP |
2187 ETH_RSS_AH | ETH_RSS_PFCP | ETH_RSS_GTPU |
2189 else if (!strcmp(res->value, "eth"))
2190 rss_conf.rss_hf = ETH_RSS_ETH;
2191 else if (!strcmp(res->value, "vlan"))
2192 rss_conf.rss_hf = ETH_RSS_VLAN;
2193 else if (!strcmp(res->value, "ip"))
2194 rss_conf.rss_hf = ETH_RSS_IP;
2195 else if (!strcmp(res->value, "udp"))
2196 rss_conf.rss_hf = ETH_RSS_UDP;
2197 else if (!strcmp(res->value, "tcp"))
2198 rss_conf.rss_hf = ETH_RSS_TCP;
2199 else if (!strcmp(res->value, "sctp"))
2200 rss_conf.rss_hf = ETH_RSS_SCTP;
2201 else if (!strcmp(res->value, "ether"))
2202 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
2203 else if (!strcmp(res->value, "port"))
2204 rss_conf.rss_hf = ETH_RSS_PORT;
2205 else if (!strcmp(res->value, "vxlan"))
2206 rss_conf.rss_hf = ETH_RSS_VXLAN;
2207 else if (!strcmp(res->value, "geneve"))
2208 rss_conf.rss_hf = ETH_RSS_GENEVE;
2209 else if (!strcmp(res->value, "nvgre"))
2210 rss_conf.rss_hf = ETH_RSS_NVGRE;
2211 else if (!strcmp(res->value, "l3-pre32"))
2212 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE32;
2213 else if (!strcmp(res->value, "l3-pre40"))
2214 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE40;
2215 else if (!strcmp(res->value, "l3-pre48"))
2216 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE48;
2217 else if (!strcmp(res->value, "l3-pre56"))
2218 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE56;
2219 else if (!strcmp(res->value, "l3-pre64"))
2220 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE64;
2221 else if (!strcmp(res->value, "l3-pre96"))
2222 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE96;
2223 else if (!strcmp(res->value, "l3-src-only"))
2224 rss_conf.rss_hf = ETH_RSS_L3_SRC_ONLY;
2225 else if (!strcmp(res->value, "l3-dst-only"))
2226 rss_conf.rss_hf = ETH_RSS_L3_DST_ONLY;
2227 else if (!strcmp(res->value, "l4-src-only"))
2228 rss_conf.rss_hf = ETH_RSS_L4_SRC_ONLY;
2229 else if (!strcmp(res->value, "l4-dst-only"))
2230 rss_conf.rss_hf = ETH_RSS_L4_DST_ONLY;
2231 else if (!strcmp(res->value, "l2-src-only"))
2232 rss_conf.rss_hf = ETH_RSS_L2_SRC_ONLY;
2233 else if (!strcmp(res->value, "l2-dst-only"))
2234 rss_conf.rss_hf = ETH_RSS_L2_DST_ONLY;
2235 else if (!strcmp(res->value, "l2tpv3"))
2236 rss_conf.rss_hf = ETH_RSS_L2TPV3;
2237 else if (!strcmp(res->value, "esp"))
2238 rss_conf.rss_hf = ETH_RSS_ESP;
2239 else if (!strcmp(res->value, "ah"))
2240 rss_conf.rss_hf = ETH_RSS_AH;
2241 else if (!strcmp(res->value, "pfcp"))
2242 rss_conf.rss_hf = ETH_RSS_PFCP;
2243 else if (!strcmp(res->value, "pppoe"))
2244 rss_conf.rss_hf = ETH_RSS_PPPOE;
2245 else if (!strcmp(res->value, "gtpu"))
2246 rss_conf.rss_hf = ETH_RSS_GTPU;
2247 else if (!strcmp(res->value, "ecpri"))
2248 rss_conf.rss_hf = ETH_RSS_ECPRI;
2249 else if (!strcmp(res->value, "mpls"))
2250 rss_conf.rss_hf = ETH_RSS_MPLS;
2251 else if (!strcmp(res->value, "none"))
2252 rss_conf.rss_hf = 0;
2253 else if (!strcmp(res->value, "level-default")) {
2254 rss_hf &= (~ETH_RSS_LEVEL_MASK);
2255 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_PMD_DEFAULT);
2256 } else if (!strcmp(res->value, "level-outer")) {
2257 rss_hf &= (~ETH_RSS_LEVEL_MASK);
2258 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_OUTERMOST);
2259 } else if (!strcmp(res->value, "level-inner")) {
2260 rss_hf &= (~ETH_RSS_LEVEL_MASK);
2261 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_INNERMOST);
2262 } else if (!strcmp(res->value, "default"))
2264 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2265 atoi(res->value) < 64)
2266 rss_conf.rss_hf = 1ULL << atoi(res->value);
2268 printf("Unknown parameter\n");
2271 rss_conf.rss_key = NULL;
2272 /* Update global configuration for RSS types. */
2273 RTE_ETH_FOREACH_DEV(i) {
2274 struct rte_eth_rss_conf local_rss_conf;
2276 ret = eth_dev_info_get_print_err(i, &dev_info);
2281 rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2283 local_rss_conf = rss_conf;
2284 local_rss_conf.rss_hf = rss_conf.rss_hf &
2285 dev_info.flow_type_rss_offloads;
2286 if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2287 printf("Port %u modified RSS hash function based on hardware support,"
2288 "requested:%#"PRIx64" configured:%#"PRIx64"\n",
2289 i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2291 diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2294 printf("Configuration of RSS hash at ethernet port %d "
2295 "failed with error (%d): %s.\n",
2296 i, -diag, strerror(-diag));
2299 if (all_updated && !use_default) {
2300 rss_hf = rss_conf.rss_hf;
2301 printf("rss_hf %#"PRIx64"\n", rss_hf);
2305 cmdline_parse_token_string_t cmd_config_rss_port =
2306 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2307 cmdline_parse_token_string_t cmd_config_rss_keyword =
2308 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2309 cmdline_parse_token_string_t cmd_config_rss_all =
2310 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2311 cmdline_parse_token_string_t cmd_config_rss_name =
2312 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2313 cmdline_parse_token_string_t cmd_config_rss_value =
2314 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2316 cmdline_parse_inst_t cmd_config_rss = {
2317 .f = cmd_config_rss_parsed,
2319 .help_str = "port config all rss "
2320 "all|default|eth|vlan|ip|tcp|udp|sctp|ether|port|vxlan|geneve|"
2321 "nvgre|vxlan-gpe|l2tpv3|esp|ah|pfcp|ecpri|mpls|none|level-default|"
2322 "level-outer|level-inner|<flowtype_id>",
2324 (void *)&cmd_config_rss_port,
2325 (void *)&cmd_config_rss_keyword,
2326 (void *)&cmd_config_rss_all,
2327 (void *)&cmd_config_rss_name,
2328 (void *)&cmd_config_rss_value,
2333 /* *** configure rss hash key *** */
2334 struct cmd_config_rss_hash_key {
2335 cmdline_fixed_string_t port;
2336 cmdline_fixed_string_t config;
2338 cmdline_fixed_string_t rss_hash_key;
2339 cmdline_fixed_string_t rss_type;
2340 cmdline_fixed_string_t key;
2344 hexa_digit_to_value(char hexa_digit)
2346 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2347 return (uint8_t) (hexa_digit - '0');
2348 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2349 return (uint8_t) ((hexa_digit - 'a') + 10);
2350 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2351 return (uint8_t) ((hexa_digit - 'A') + 10);
2352 /* Invalid hexa digit */
2357 parse_and_check_key_hexa_digit(char *key, int idx)
2361 hexa_v = hexa_digit_to_value(key[idx]);
2363 printf("invalid key: character %c at position %d is not a "
2364 "valid hexa digit\n", key[idx], idx);
2369 cmd_config_rss_hash_key_parsed(void *parsed_result,
2370 __rte_unused struct cmdline *cl,
2371 __rte_unused void *data)
2373 struct cmd_config_rss_hash_key *res = parsed_result;
2374 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2378 struct rte_eth_dev_info dev_info;
2379 uint8_t hash_key_size;
2383 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2387 if (dev_info.hash_key_size > 0 &&
2388 dev_info.hash_key_size <= sizeof(hash_key))
2389 hash_key_size = dev_info.hash_key_size;
2391 printf("dev_info did not provide a valid hash key size\n");
2394 /* Check the length of the RSS hash key */
2395 key_len = strlen(res->key);
2396 if (key_len != (hash_key_size * 2)) {
2397 printf("key length: %d invalid - key must be a string of %d"
2398 " hexa-decimal numbers\n",
2399 (int) key_len, hash_key_size * 2);
2402 /* Translate RSS hash key into binary representation */
2403 for (i = 0; i < hash_key_size; i++) {
2404 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2407 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2410 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2412 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2416 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2417 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2418 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2419 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2421 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2422 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id,
2424 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2425 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2426 rss_hash_key, "rss-hash-key");
2427 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2428 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2429 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2430 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2431 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2432 "ipv6-tcp-ex#ipv6-udp-ex#"
2433 "l3-src-only#l3-dst-only#l4-src-only#l4-dst-only#"
2434 "l2-src-only#l2-dst-only#s-vlan#c-vlan#"
2435 "l2tpv3#esp#ah#pfcp#pppoe#gtpu#ecpri#mpls");
2436 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2437 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2439 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2440 .f = cmd_config_rss_hash_key_parsed,
2442 .help_str = "port config <port_id> rss-hash-key "
2443 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2444 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2445 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|"
2446 "l3-src-only|l3-dst-only|l4-src-only|l4-dst-only|"
2447 "l2-src-only|l2-dst-only|s-vlan|c-vlan|"
2448 "l2tpv3|esp|ah|pfcp|pppoe|gtpu|ecpri|mpls "
2449 "<string of hex digits (variable length, NIC dependent)>",
2451 (void *)&cmd_config_rss_hash_key_port,
2452 (void *)&cmd_config_rss_hash_key_config,
2453 (void *)&cmd_config_rss_hash_key_port_id,
2454 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2455 (void *)&cmd_config_rss_hash_key_rss_type,
2456 (void *)&cmd_config_rss_hash_key_value,
2461 /* *** configure port rxq/txq ring size *** */
2462 struct cmd_config_rxtx_ring_size {
2463 cmdline_fixed_string_t port;
2464 cmdline_fixed_string_t config;
2466 cmdline_fixed_string_t rxtxq;
2468 cmdline_fixed_string_t rsize;
2473 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2474 __rte_unused struct cmdline *cl,
2475 __rte_unused void *data)
2477 struct cmd_config_rxtx_ring_size *res = parsed_result;
2478 struct rte_port *port;
2481 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2484 if (res->portid == (portid_t)RTE_PORT_ALL) {
2485 printf("Invalid port id\n");
2489 port = &ports[res->portid];
2491 if (!strcmp(res->rxtxq, "rxq"))
2493 else if (!strcmp(res->rxtxq, "txq"))
2496 printf("Unknown parameter\n");
2500 if (isrx && rx_queue_id_is_invalid(res->qid))
2502 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2505 if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2506 printf("Invalid rx ring_size, must > rx_free_thresh: %d\n",
2512 port->nb_rx_desc[res->qid] = res->size;
2514 port->nb_tx_desc[res->qid] = res->size;
2516 cmd_reconfig_device_queue(res->portid, 0, 1);
2519 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2520 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2522 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2523 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2525 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2526 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2527 portid, RTE_UINT16);
2528 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2529 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2531 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2532 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2534 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2535 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2536 rsize, "ring_size");
2537 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2538 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2541 cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2542 .f = cmd_config_rxtx_ring_size_parsed,
2544 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2546 (void *)&cmd_config_rxtx_ring_size_port,
2547 (void *)&cmd_config_rxtx_ring_size_config,
2548 (void *)&cmd_config_rxtx_ring_size_portid,
2549 (void *)&cmd_config_rxtx_ring_size_rxtxq,
2550 (void *)&cmd_config_rxtx_ring_size_qid,
2551 (void *)&cmd_config_rxtx_ring_size_rsize,
2552 (void *)&cmd_config_rxtx_ring_size_size,
2557 /* *** configure port rxq/txq start/stop *** */
2558 struct cmd_config_rxtx_queue {
2559 cmdline_fixed_string_t port;
2561 cmdline_fixed_string_t rxtxq;
2563 cmdline_fixed_string_t opname;
2567 cmd_config_rxtx_queue_parsed(void *parsed_result,
2568 __rte_unused struct cmdline *cl,
2569 __rte_unused void *data)
2571 struct cmd_config_rxtx_queue *res = parsed_result;
2576 if (test_done == 0) {
2577 printf("Please stop forwarding first\n");
2581 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2584 if (port_is_started(res->portid) != 1) {
2585 printf("Please start port %u first\n", res->portid);
2589 if (!strcmp(res->rxtxq, "rxq"))
2591 else if (!strcmp(res->rxtxq, "txq"))
2594 printf("Unknown parameter\n");
2598 if (isrx && rx_queue_id_is_invalid(res->qid))
2600 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2603 if (!strcmp(res->opname, "start"))
2605 else if (!strcmp(res->opname, "stop"))
2608 printf("Unknown parameter\n");
2612 if (isstart && isrx)
2613 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2614 else if (!isstart && isrx)
2615 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2616 else if (isstart && !isrx)
2617 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2619 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2621 if (ret == -ENOTSUP)
2622 printf("Function not supported in PMD driver\n");
2625 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2626 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2627 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2628 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, RTE_UINT16);
2629 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2630 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2631 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2632 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, RTE_UINT16);
2633 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2634 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2637 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2638 .f = cmd_config_rxtx_queue_parsed,
2640 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2642 (void *)&cmd_config_rxtx_queue_port,
2643 (void *)&cmd_config_rxtx_queue_portid,
2644 (void *)&cmd_config_rxtx_queue_rxtxq,
2645 (void *)&cmd_config_rxtx_queue_qid,
2646 (void *)&cmd_config_rxtx_queue_opname,
2651 /* *** configure port rxq/txq deferred start on/off *** */
2652 struct cmd_config_deferred_start_rxtx_queue {
2653 cmdline_fixed_string_t port;
2655 cmdline_fixed_string_t rxtxq;
2657 cmdline_fixed_string_t opname;
2658 cmdline_fixed_string_t state;
2662 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2663 __rte_unused struct cmdline *cl,
2664 __rte_unused void *data)
2666 struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2667 struct rte_port *port;
2670 uint8_t needreconfig = 0;
2672 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2675 if (port_is_started(res->port_id) != 0) {
2676 printf("Please stop port %u first\n", res->port_id);
2680 port = &ports[res->port_id];
2682 isrx = !strcmp(res->rxtxq, "rxq");
2684 if (isrx && rx_queue_id_is_invalid(res->qid))
2686 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2689 ison = !strcmp(res->state, "on");
2691 if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) {
2692 port->rx_conf[res->qid].rx_deferred_start = ison;
2694 } else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) {
2695 port->tx_conf[res->qid].tx_deferred_start = ison;
2700 cmd_reconfig_device_queue(res->port_id, 0, 1);
2703 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2704 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2706 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2707 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2708 port_id, RTE_UINT16);
2709 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2710 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2712 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2713 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2715 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2716 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2717 opname, "deferred_start");
2718 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2719 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2722 cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
2723 .f = cmd_config_deferred_start_rxtx_queue_parsed,
2725 .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
2727 (void *)&cmd_config_deferred_start_rxtx_queue_port,
2728 (void *)&cmd_config_deferred_start_rxtx_queue_port_id,
2729 (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
2730 (void *)&cmd_config_deferred_start_rxtx_queue_qid,
2731 (void *)&cmd_config_deferred_start_rxtx_queue_opname,
2732 (void *)&cmd_config_deferred_start_rxtx_queue_state,
2737 /* *** configure port rxq/txq setup *** */
2738 struct cmd_setup_rxtx_queue {
2739 cmdline_fixed_string_t port;
2741 cmdline_fixed_string_t rxtxq;
2743 cmdline_fixed_string_t setup;
2746 /* Common CLI fields for queue setup */
2747 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2748 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2749 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2750 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, RTE_UINT16);
2751 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2752 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2753 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2754 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, RTE_UINT16);
2755 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2756 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2759 cmd_setup_rxtx_queue_parsed(
2760 void *parsed_result,
2761 __rte_unused struct cmdline *cl,
2762 __rte_unused void *data)
2764 struct cmd_setup_rxtx_queue *res = parsed_result;
2765 struct rte_port *port;
2766 struct rte_mempool *mp;
2767 unsigned int socket_id;
2771 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2774 if (res->portid == (portid_t)RTE_PORT_ALL) {
2775 printf("Invalid port id\n");
2779 if (!strcmp(res->rxtxq, "rxq"))
2781 else if (!strcmp(res->rxtxq, "txq"))
2784 printf("Unknown parameter\n");
2788 if (isrx && rx_queue_id_is_invalid(res->qid)) {
2789 printf("Invalid rx queue\n");
2791 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2792 printf("Invalid tx queue\n");
2796 port = &ports[res->portid];
2798 socket_id = rxring_numa[res->portid];
2799 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2800 socket_id = port->socket_id;
2802 mp = mbuf_pool_find(socket_id, 0);
2804 printf("Failed to setup RX queue: "
2805 "No mempool allocation"
2806 " on the socket %d\n",
2807 rxring_numa[res->portid]);
2810 ret = rx_queue_setup(res->portid,
2812 port->nb_rx_desc[res->qid],
2814 &port->rx_conf[res->qid],
2817 printf("Failed to setup RX queue\n");
2819 socket_id = txring_numa[res->portid];
2820 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2821 socket_id = port->socket_id;
2823 ret = rte_eth_tx_queue_setup(res->portid,
2825 port->nb_tx_desc[res->qid],
2827 &port->tx_conf[res->qid]);
2829 printf("Failed to setup TX queue\n");
2833 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2834 .f = cmd_setup_rxtx_queue_parsed,
2836 .help_str = "port <port_id> rxq|txq <queue_idx> setup",
2838 (void *)&cmd_setup_rxtx_queue_port,
2839 (void *)&cmd_setup_rxtx_queue_portid,
2840 (void *)&cmd_setup_rxtx_queue_rxtxq,
2841 (void *)&cmd_setup_rxtx_queue_qid,
2842 (void *)&cmd_setup_rxtx_queue_setup,
2848 /* *** Configure RSS RETA *** */
2849 struct cmd_config_rss_reta {
2850 cmdline_fixed_string_t port;
2851 cmdline_fixed_string_t keyword;
2853 cmdline_fixed_string_t name;
2854 cmdline_fixed_string_t list_name;
2855 cmdline_fixed_string_t list_of_items;
2859 parse_reta_config(const char *str,
2860 struct rte_eth_rss_reta_entry64 *reta_conf,
2861 uint16_t nb_entries)
2865 uint16_t hash_index, idx, shift;
2868 const char *p, *p0 = str;
2875 unsigned long int_fld[_NUM_FLD];
2876 char *str_fld[_NUM_FLD];
2878 while ((p = strchr(p0,'(')) != NULL) {
2880 if((p0 = strchr(p,')')) == NULL)
2884 if(size >= sizeof(s))
2887 snprintf(s, sizeof(s), "%.*s", size, p);
2888 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2890 for (i = 0; i < _NUM_FLD; i++) {
2892 int_fld[i] = strtoul(str_fld[i], &end, 0);
2893 if (errno != 0 || end == str_fld[i] ||
2898 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2899 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2901 if (hash_index >= nb_entries) {
2902 printf("Invalid RETA hash index=%d\n", hash_index);
2906 idx = hash_index / RTE_RETA_GROUP_SIZE;
2907 shift = hash_index % RTE_RETA_GROUP_SIZE;
2908 reta_conf[idx].mask |= (1ULL << shift);
2909 reta_conf[idx].reta[shift] = nb_queue;
2916 cmd_set_rss_reta_parsed(void *parsed_result,
2917 __rte_unused struct cmdline *cl,
2918 __rte_unused void *data)
2921 struct rte_eth_dev_info dev_info;
2922 struct rte_eth_rss_reta_entry64 reta_conf[8];
2923 struct cmd_config_rss_reta *res = parsed_result;
2925 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2929 if (dev_info.reta_size == 0) {
2930 printf("Redirection table size is 0 which is "
2931 "invalid for RSS\n");
2934 printf("The reta size of port %d is %u\n",
2935 res->port_id, dev_info.reta_size);
2936 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2937 printf("Currently do not support more than %u entries of "
2938 "redirection table\n", ETH_RSS_RETA_SIZE_512);
2942 memset(reta_conf, 0, sizeof(reta_conf));
2943 if (!strcmp(res->list_name, "reta")) {
2944 if (parse_reta_config(res->list_of_items, reta_conf,
2945 dev_info.reta_size)) {
2946 printf("Invalid RSS Redirection Table "
2947 "config entered\n");
2950 ret = rte_eth_dev_rss_reta_update(res->port_id,
2951 reta_conf, dev_info.reta_size);
2953 printf("Bad redirection table parameter, "
2954 "return code = %d \n", ret);
2958 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2959 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2960 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2961 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2962 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2963 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, RTE_UINT16);
2964 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2965 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2966 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2967 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2968 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2969 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2971 cmdline_parse_inst_t cmd_config_rss_reta = {
2972 .f = cmd_set_rss_reta_parsed,
2974 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2976 (void *)&cmd_config_rss_reta_port,
2977 (void *)&cmd_config_rss_reta_keyword,
2978 (void *)&cmd_config_rss_reta_port_id,
2979 (void *)&cmd_config_rss_reta_name,
2980 (void *)&cmd_config_rss_reta_list_name,
2981 (void *)&cmd_config_rss_reta_list_of_items,
2986 /* *** SHOW PORT RETA INFO *** */
2987 struct cmd_showport_reta {
2988 cmdline_fixed_string_t show;
2989 cmdline_fixed_string_t port;
2991 cmdline_fixed_string_t rss;
2992 cmdline_fixed_string_t reta;
2994 cmdline_fixed_string_t list_of_items;
2998 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2999 uint16_t nb_entries,
3003 const char *p, *p0 = str;
3008 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
3009 RTE_RETA_GROUP_SIZE;
3012 p = strchr(p0, '(');
3016 p0 = strchr(p, ')');
3020 if (size >= sizeof(s)) {
3021 printf("The string size exceeds the internal buffer size\n");
3024 snprintf(s, sizeof(s), "%.*s", size, p);
3025 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
3026 if (ret <= 0 || ret != num) {
3027 printf("The bits of masks do not match the number of "
3028 "reta entries: %u\n", num);
3031 for (i = 0; i < ret; i++)
3032 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
3038 cmd_showport_reta_parsed(void *parsed_result,
3039 __rte_unused struct cmdline *cl,
3040 __rte_unused void *data)
3042 struct cmd_showport_reta *res = parsed_result;
3043 struct rte_eth_rss_reta_entry64 reta_conf[8];
3044 struct rte_eth_dev_info dev_info;
3045 uint16_t max_reta_size;
3048 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3052 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
3053 if (res->size == 0 || res->size > max_reta_size) {
3054 printf("Invalid redirection table size: %u (1-%u)\n",
3055 res->size, max_reta_size);
3059 memset(reta_conf, 0, sizeof(reta_conf));
3060 if (showport_parse_reta_config(reta_conf, res->size,
3061 res->list_of_items) < 0) {
3062 printf("Invalid string: %s for reta masks\n",
3063 res->list_of_items);
3066 port_rss_reta_info(res->port_id, reta_conf, res->size);
3069 cmdline_parse_token_string_t cmd_showport_reta_show =
3070 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
3071 cmdline_parse_token_string_t cmd_showport_reta_port =
3072 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
3073 cmdline_parse_token_num_t cmd_showport_reta_port_id =
3074 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, RTE_UINT16);
3075 cmdline_parse_token_string_t cmd_showport_reta_rss =
3076 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
3077 cmdline_parse_token_string_t cmd_showport_reta_reta =
3078 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
3079 cmdline_parse_token_num_t cmd_showport_reta_size =
3080 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, RTE_UINT16);
3081 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
3082 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
3083 list_of_items, NULL);
3085 cmdline_parse_inst_t cmd_showport_reta = {
3086 .f = cmd_showport_reta_parsed,
3088 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
3090 (void *)&cmd_showport_reta_show,
3091 (void *)&cmd_showport_reta_port,
3092 (void *)&cmd_showport_reta_port_id,
3093 (void *)&cmd_showport_reta_rss,
3094 (void *)&cmd_showport_reta_reta,
3095 (void *)&cmd_showport_reta_size,
3096 (void *)&cmd_showport_reta_list_of_items,
3101 /* *** Show RSS hash configuration *** */
3102 struct cmd_showport_rss_hash {
3103 cmdline_fixed_string_t show;
3104 cmdline_fixed_string_t port;
3106 cmdline_fixed_string_t rss_hash;
3107 cmdline_fixed_string_t rss_type;
3108 cmdline_fixed_string_t key; /* optional argument */
3111 static void cmd_showport_rss_hash_parsed(void *parsed_result,
3112 __rte_unused struct cmdline *cl,
3115 struct cmd_showport_rss_hash *res = parsed_result;
3117 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
3120 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
3121 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
3122 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
3123 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
3124 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
3125 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id,
3127 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
3128 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
3130 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
3131 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
3133 cmdline_parse_inst_t cmd_showport_rss_hash = {
3134 .f = cmd_showport_rss_hash_parsed,
3136 .help_str = "show port <port_id> rss-hash",
3138 (void *)&cmd_showport_rss_hash_show,
3139 (void *)&cmd_showport_rss_hash_port,
3140 (void *)&cmd_showport_rss_hash_port_id,
3141 (void *)&cmd_showport_rss_hash_rss_hash,
3146 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
3147 .f = cmd_showport_rss_hash_parsed,
3149 .help_str = "show port <port_id> rss-hash key",
3151 (void *)&cmd_showport_rss_hash_show,
3152 (void *)&cmd_showport_rss_hash_port,
3153 (void *)&cmd_showport_rss_hash_port_id,
3154 (void *)&cmd_showport_rss_hash_rss_hash,
3155 (void *)&cmd_showport_rss_hash_rss_key,
3160 /* *** Configure DCB *** */
3161 struct cmd_config_dcb {
3162 cmdline_fixed_string_t port;
3163 cmdline_fixed_string_t config;
3165 cmdline_fixed_string_t dcb;
3166 cmdline_fixed_string_t vt;
3167 cmdline_fixed_string_t vt_en;
3169 cmdline_fixed_string_t pfc;
3170 cmdline_fixed_string_t pfc_en;
3174 cmd_config_dcb_parsed(void *parsed_result,
3175 __rte_unused struct cmdline *cl,
3176 __rte_unused void *data)
3178 struct cmd_config_dcb *res = parsed_result;
3179 portid_t port_id = res->port_id;
3180 struct rte_port *port;
3184 port = &ports[port_id];
3185 /** Check if the port is not started **/
3186 if (port->port_status != RTE_PORT_STOPPED) {
3187 printf("Please stop port %d first\n", port_id);
3191 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
3192 printf("The invalid number of traffic class,"
3193 " only 4 or 8 allowed.\n");
3197 if (nb_fwd_lcores < res->num_tcs) {
3198 printf("nb_cores shouldn't be less than number of TCs.\n");
3201 if (!strncmp(res->pfc_en, "on", 2))
3206 /* DCB in VT mode */
3207 if (!strncmp(res->vt_en, "on", 2))
3208 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3209 (enum rte_eth_nb_tcs)res->num_tcs,
3212 ret = init_port_dcb_config(port_id, DCB_ENABLED,
3213 (enum rte_eth_nb_tcs)res->num_tcs,
3218 printf("Cannot initialize network ports.\n");
3222 cmd_reconfig_device_queue(port_id, 1, 1);
3225 cmdline_parse_token_string_t cmd_config_dcb_port =
3226 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3227 cmdline_parse_token_string_t cmd_config_dcb_config =
3228 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3229 cmdline_parse_token_num_t cmd_config_dcb_port_id =
3230 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, RTE_UINT16);
3231 cmdline_parse_token_string_t cmd_config_dcb_dcb =
3232 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3233 cmdline_parse_token_string_t cmd_config_dcb_vt =
3234 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3235 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3236 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3237 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3238 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, RTE_UINT8);
3239 cmdline_parse_token_string_t cmd_config_dcb_pfc=
3240 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3241 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
3242 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
3244 cmdline_parse_inst_t cmd_config_dcb = {
3245 .f = cmd_config_dcb_parsed,
3247 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
3249 (void *)&cmd_config_dcb_port,
3250 (void *)&cmd_config_dcb_config,
3251 (void *)&cmd_config_dcb_port_id,
3252 (void *)&cmd_config_dcb_dcb,
3253 (void *)&cmd_config_dcb_vt,
3254 (void *)&cmd_config_dcb_vt_en,
3255 (void *)&cmd_config_dcb_num_tcs,
3256 (void *)&cmd_config_dcb_pfc,
3257 (void *)&cmd_config_dcb_pfc_en,
3262 /* *** configure number of packets per burst *** */
3263 struct cmd_config_burst {
3264 cmdline_fixed_string_t port;
3265 cmdline_fixed_string_t keyword;
3266 cmdline_fixed_string_t all;
3267 cmdline_fixed_string_t name;
3272 cmd_config_burst_parsed(void *parsed_result,
3273 __rte_unused struct cmdline *cl,
3274 __rte_unused void *data)
3276 struct cmd_config_burst *res = parsed_result;
3277 struct rte_eth_dev_info dev_info;
3278 uint16_t rec_nb_pkts;
3281 if (!all_ports_stopped()) {
3282 printf("Please stop all ports first\n");
3286 if (!strcmp(res->name, "burst")) {
3287 if (res->value == 0) {
3288 /* If user gives a value of zero, query the PMD for
3289 * its recommended Rx burst size. Testpmd uses a single
3290 * size for all ports, so assume all ports are the same
3291 * NIC model and use the values from Port 0.
3293 ret = eth_dev_info_get_print_err(0, &dev_info);
3297 rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3299 if (rec_nb_pkts == 0) {
3300 printf("PMD does not recommend a burst size.\n"
3301 "User provided value must be between"
3302 " 1 and %d\n", MAX_PKT_BURST);
3304 } else if (rec_nb_pkts > MAX_PKT_BURST) {
3305 printf("PMD recommended burst size of %d"
3306 " exceeds maximum value of %d\n",
3307 rec_nb_pkts, MAX_PKT_BURST);
3310 printf("Using PMD-provided burst value of %d\n",
3312 nb_pkt_per_burst = rec_nb_pkts;
3313 } else if (res->value > MAX_PKT_BURST) {
3314 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
3317 nb_pkt_per_burst = res->value;
3319 printf("Unknown parameter\n");
3325 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3328 cmdline_parse_token_string_t cmd_config_burst_port =
3329 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3330 cmdline_parse_token_string_t cmd_config_burst_keyword =
3331 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3332 cmdline_parse_token_string_t cmd_config_burst_all =
3333 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3334 cmdline_parse_token_string_t cmd_config_burst_name =
3335 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3336 cmdline_parse_token_num_t cmd_config_burst_value =
3337 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, RTE_UINT16);
3339 cmdline_parse_inst_t cmd_config_burst = {
3340 .f = cmd_config_burst_parsed,
3342 .help_str = "port config all burst <value>",
3344 (void *)&cmd_config_burst_port,
3345 (void *)&cmd_config_burst_keyword,
3346 (void *)&cmd_config_burst_all,
3347 (void *)&cmd_config_burst_name,
3348 (void *)&cmd_config_burst_value,
3353 /* *** configure rx/tx queues *** */
3354 struct cmd_config_thresh {
3355 cmdline_fixed_string_t port;
3356 cmdline_fixed_string_t keyword;
3357 cmdline_fixed_string_t all;
3358 cmdline_fixed_string_t name;
3363 cmd_config_thresh_parsed(void *parsed_result,
3364 __rte_unused struct cmdline *cl,
3365 __rte_unused void *data)
3367 struct cmd_config_thresh *res = parsed_result;
3369 if (!all_ports_stopped()) {
3370 printf("Please stop all ports first\n");
3374 if (!strcmp(res->name, "txpt"))
3375 tx_pthresh = res->value;
3376 else if(!strcmp(res->name, "txht"))
3377 tx_hthresh = res->value;
3378 else if(!strcmp(res->name, "txwt"))
3379 tx_wthresh = res->value;
3380 else if(!strcmp(res->name, "rxpt"))
3381 rx_pthresh = res->value;
3382 else if(!strcmp(res->name, "rxht"))
3383 rx_hthresh = res->value;
3384 else if(!strcmp(res->name, "rxwt"))
3385 rx_wthresh = res->value;
3387 printf("Unknown parameter\n");
3393 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3396 cmdline_parse_token_string_t cmd_config_thresh_port =
3397 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3398 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3399 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3400 cmdline_parse_token_string_t cmd_config_thresh_all =
3401 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3402 cmdline_parse_token_string_t cmd_config_thresh_name =
3403 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3404 "txpt#txht#txwt#rxpt#rxht#rxwt");
3405 cmdline_parse_token_num_t cmd_config_thresh_value =
3406 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, RTE_UINT8);
3408 cmdline_parse_inst_t cmd_config_thresh = {
3409 .f = cmd_config_thresh_parsed,
3411 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3413 (void *)&cmd_config_thresh_port,
3414 (void *)&cmd_config_thresh_keyword,
3415 (void *)&cmd_config_thresh_all,
3416 (void *)&cmd_config_thresh_name,
3417 (void *)&cmd_config_thresh_value,
3422 /* *** configure free/rs threshold *** */
3423 struct cmd_config_threshold {
3424 cmdline_fixed_string_t port;
3425 cmdline_fixed_string_t keyword;
3426 cmdline_fixed_string_t all;
3427 cmdline_fixed_string_t name;
3432 cmd_config_threshold_parsed(void *parsed_result,
3433 __rte_unused struct cmdline *cl,
3434 __rte_unused void *data)
3436 struct cmd_config_threshold *res = parsed_result;
3438 if (!all_ports_stopped()) {
3439 printf("Please stop all ports first\n");
3443 if (!strcmp(res->name, "txfreet"))
3444 tx_free_thresh = res->value;
3445 else if (!strcmp(res->name, "txrst"))
3446 tx_rs_thresh = res->value;
3447 else if (!strcmp(res->name, "rxfreet"))
3448 rx_free_thresh = res->value;
3450 printf("Unknown parameter\n");
3456 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3459 cmdline_parse_token_string_t cmd_config_threshold_port =
3460 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3461 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3462 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3464 cmdline_parse_token_string_t cmd_config_threshold_all =
3465 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3466 cmdline_parse_token_string_t cmd_config_threshold_name =
3467 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3468 "txfreet#txrst#rxfreet");
3469 cmdline_parse_token_num_t cmd_config_threshold_value =
3470 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, RTE_UINT16);
3472 cmdline_parse_inst_t cmd_config_threshold = {
3473 .f = cmd_config_threshold_parsed,
3475 .help_str = "port config all txfreet|txrst|rxfreet <value>",
3477 (void *)&cmd_config_threshold_port,
3478 (void *)&cmd_config_threshold_keyword,
3479 (void *)&cmd_config_threshold_all,
3480 (void *)&cmd_config_threshold_name,
3481 (void *)&cmd_config_threshold_value,
3487 struct cmd_stop_result {
3488 cmdline_fixed_string_t stop;
3491 static void cmd_stop_parsed(__rte_unused void *parsed_result,
3492 __rte_unused struct cmdline *cl,
3493 __rte_unused void *data)
3495 stop_packet_forwarding();
3498 cmdline_parse_token_string_t cmd_stop_stop =
3499 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3501 cmdline_parse_inst_t cmd_stop = {
3502 .f = cmd_stop_parsed,
3504 .help_str = "stop: Stop packet forwarding",
3506 (void *)&cmd_stop_stop,
3511 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3514 parse_item_list(char* str, const char* item_name, unsigned int max_items,
3515 unsigned int *parsed_items, int check_unique_values)
3517 unsigned int nb_item;
3525 * First parse all items in the list and store their value.
3530 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3532 if ((c >= '0') && (c <= '9')) {
3533 value = (unsigned int) (value * 10 + (c - '0'));
3538 printf("character %c is not a decimal digit\n", c);
3542 printf("No valid value before comma\n");
3545 if (nb_item < max_items) {
3546 parsed_items[nb_item] = value;
3552 if (nb_item >= max_items) {
3553 printf("Number of %s = %u > %u (maximum items)\n",
3554 item_name, nb_item + 1, max_items);
3557 parsed_items[nb_item++] = value;
3558 if (! check_unique_values)
3562 * Then, check that all values in the list are differents.
3563 * No optimization here...
3565 for (i = 0; i < nb_item; i++) {
3566 for (j = i + 1; j < nb_item; j++) {
3567 if (parsed_items[j] == parsed_items[i]) {
3568 printf("duplicated %s %u at index %u and %u\n",
3569 item_name, parsed_items[i], i, j);
3577 struct cmd_set_list_result {
3578 cmdline_fixed_string_t cmd_keyword;
3579 cmdline_fixed_string_t list_name;
3580 cmdline_fixed_string_t list_of_items;
3583 static void cmd_set_list_parsed(void *parsed_result,
3584 __rte_unused struct cmdline *cl,
3585 __rte_unused void *data)
3587 struct cmd_set_list_result *res;
3589 unsigned int lcorelist[RTE_MAX_LCORE];
3590 unsigned int portlist[RTE_MAX_ETHPORTS];
3592 unsigned int nb_item;
3594 if (test_done == 0) {
3595 printf("Please stop forwarding first\n");
3599 res = parsed_result;
3600 if (!strcmp(res->list_name, "corelist")) {
3601 nb_item = parse_item_list(res->list_of_items, "core",
3603 parsed_items.lcorelist, 1);
3605 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3610 if (!strcmp(res->list_name, "portlist")) {
3611 nb_item = parse_item_list(res->list_of_items, "port",
3613 parsed_items.portlist, 1);
3615 set_fwd_ports_list(parsed_items.portlist, nb_item);
3621 cmdline_parse_token_string_t cmd_set_list_keyword =
3622 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3624 cmdline_parse_token_string_t cmd_set_list_name =
3625 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3626 "corelist#portlist");
3627 cmdline_parse_token_string_t cmd_set_list_of_items =
3628 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3631 cmdline_parse_inst_t cmd_set_fwd_list = {
3632 .f = cmd_set_list_parsed,
3634 .help_str = "set corelist|portlist <list0[,list1]*>",
3636 (void *)&cmd_set_list_keyword,
3637 (void *)&cmd_set_list_name,
3638 (void *)&cmd_set_list_of_items,
3643 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3645 struct cmd_setmask_result {
3646 cmdline_fixed_string_t set;
3647 cmdline_fixed_string_t mask;
3651 static void cmd_set_mask_parsed(void *parsed_result,
3652 __rte_unused struct cmdline *cl,
3653 __rte_unused void *data)
3655 struct cmd_setmask_result *res = parsed_result;
3657 if (test_done == 0) {
3658 printf("Please stop forwarding first\n");
3661 if (!strcmp(res->mask, "coremask")) {
3662 set_fwd_lcores_mask(res->hexavalue);
3664 } else if (!strcmp(res->mask, "portmask")) {
3665 set_fwd_ports_mask(res->hexavalue);
3670 cmdline_parse_token_string_t cmd_setmask_set =
3671 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3672 cmdline_parse_token_string_t cmd_setmask_mask =
3673 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3674 "coremask#portmask");
3675 cmdline_parse_token_num_t cmd_setmask_value =
3676 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, RTE_UINT64);
3678 cmdline_parse_inst_t cmd_set_fwd_mask = {
3679 .f = cmd_set_mask_parsed,
3681 .help_str = "set coremask|portmask <hexadecimal value>",
3683 (void *)&cmd_setmask_set,
3684 (void *)&cmd_setmask_mask,
3685 (void *)&cmd_setmask_value,
3691 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3693 struct cmd_set_result {
3694 cmdline_fixed_string_t set;
3695 cmdline_fixed_string_t what;
3699 static void cmd_set_parsed(void *parsed_result,
3700 __rte_unused struct cmdline *cl,
3701 __rte_unused void *data)
3703 struct cmd_set_result *res = parsed_result;
3704 if (!strcmp(res->what, "nbport")) {
3705 set_fwd_ports_number(res->value);
3707 } else if (!strcmp(res->what, "nbcore")) {
3708 set_fwd_lcores_number(res->value);
3710 } else if (!strcmp(res->what, "burst"))
3711 set_nb_pkt_per_burst(res->value);
3712 else if (!strcmp(res->what, "verbose"))
3713 set_verbose_level(res->value);
3716 cmdline_parse_token_string_t cmd_set_set =
3717 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3718 cmdline_parse_token_string_t cmd_set_what =
3719 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3720 "nbport#nbcore#burst#verbose");
3721 cmdline_parse_token_num_t cmd_set_value =
3722 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, RTE_UINT16);
3724 cmdline_parse_inst_t cmd_set_numbers = {
3725 .f = cmd_set_parsed,
3727 .help_str = "set nbport|nbcore|burst|verbose <value>",
3729 (void *)&cmd_set_set,
3730 (void *)&cmd_set_what,
3731 (void *)&cmd_set_value,
3736 /* *** SET LOG LEVEL CONFIGURATION *** */
3738 struct cmd_set_log_result {
3739 cmdline_fixed_string_t set;
3740 cmdline_fixed_string_t log;
3741 cmdline_fixed_string_t type;
3746 cmd_set_log_parsed(void *parsed_result,
3747 __rte_unused struct cmdline *cl,
3748 __rte_unused void *data)
3750 struct cmd_set_log_result *res;
3753 res = parsed_result;
3754 if (!strcmp(res->type, "global"))
3755 rte_log_set_global_level(res->level);
3757 ret = rte_log_set_level_regexp(res->type, res->level);
3759 printf("Unable to set log level\n");
3763 cmdline_parse_token_string_t cmd_set_log_set =
3764 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3765 cmdline_parse_token_string_t cmd_set_log_log =
3766 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3767 cmdline_parse_token_string_t cmd_set_log_type =
3768 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3769 cmdline_parse_token_num_t cmd_set_log_level =
3770 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, RTE_UINT32);
3772 cmdline_parse_inst_t cmd_set_log = {
3773 .f = cmd_set_log_parsed,
3775 .help_str = "set log global|<type> <level>",
3777 (void *)&cmd_set_log_set,
3778 (void *)&cmd_set_log_log,
3779 (void *)&cmd_set_log_type,
3780 (void *)&cmd_set_log_level,
3785 /* *** SET SEGMENT OFFSETS OF RX PACKETS SPLIT *** */
3787 struct cmd_set_rxoffs_result {
3788 cmdline_fixed_string_t cmd_keyword;
3789 cmdline_fixed_string_t rxoffs;
3790 cmdline_fixed_string_t seg_offsets;
3794 cmd_set_rxoffs_parsed(void *parsed_result,
3795 __rte_unused struct cmdline *cl,
3796 __rte_unused void *data)
3798 struct cmd_set_rxoffs_result *res;
3799 unsigned int seg_offsets[MAX_SEGS_BUFFER_SPLIT];
3800 unsigned int nb_segs;
3802 res = parsed_result;
3803 nb_segs = parse_item_list(res->seg_offsets, "segment offsets",
3804 MAX_SEGS_BUFFER_SPLIT, seg_offsets, 0);
3806 set_rx_pkt_offsets(seg_offsets, nb_segs);
3807 cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
3810 cmdline_parse_token_string_t cmd_set_rxoffs_keyword =
3811 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3812 cmd_keyword, "set");
3813 cmdline_parse_token_string_t cmd_set_rxoffs_name =
3814 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3816 cmdline_parse_token_string_t cmd_set_rxoffs_offsets =
3817 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3820 cmdline_parse_inst_t cmd_set_rxoffs = {
3821 .f = cmd_set_rxoffs_parsed,
3823 .help_str = "set rxoffs <len0[,len1]*>",
3825 (void *)&cmd_set_rxoffs_keyword,
3826 (void *)&cmd_set_rxoffs_name,
3827 (void *)&cmd_set_rxoffs_offsets,
3832 /* *** SET SEGMENT LENGTHS OF RX PACKETS SPLIT *** */
3834 struct cmd_set_rxpkts_result {
3835 cmdline_fixed_string_t cmd_keyword;
3836 cmdline_fixed_string_t rxpkts;
3837 cmdline_fixed_string_t seg_lengths;
3841 cmd_set_rxpkts_parsed(void *parsed_result,
3842 __rte_unused struct cmdline *cl,
3843 __rte_unused void *data)
3845 struct cmd_set_rxpkts_result *res;
3846 unsigned int seg_lengths[MAX_SEGS_BUFFER_SPLIT];
3847 unsigned int nb_segs;
3849 res = parsed_result;
3850 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3851 MAX_SEGS_BUFFER_SPLIT, seg_lengths, 0);
3853 set_rx_pkt_segments(seg_lengths, nb_segs);
3854 cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
3857 cmdline_parse_token_string_t cmd_set_rxpkts_keyword =
3858 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3859 cmd_keyword, "set");
3860 cmdline_parse_token_string_t cmd_set_rxpkts_name =
3861 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3863 cmdline_parse_token_string_t cmd_set_rxpkts_lengths =
3864 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3867 cmdline_parse_inst_t cmd_set_rxpkts = {
3868 .f = cmd_set_rxpkts_parsed,
3870 .help_str = "set rxpkts <len0[,len1]*>",
3872 (void *)&cmd_set_rxpkts_keyword,
3873 (void *)&cmd_set_rxpkts_name,
3874 (void *)&cmd_set_rxpkts_lengths,
3879 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3881 struct cmd_set_txpkts_result {
3882 cmdline_fixed_string_t cmd_keyword;
3883 cmdline_fixed_string_t txpkts;
3884 cmdline_fixed_string_t seg_lengths;
3888 cmd_set_txpkts_parsed(void *parsed_result,
3889 __rte_unused struct cmdline *cl,
3890 __rte_unused void *data)
3892 struct cmd_set_txpkts_result *res;
3893 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3894 unsigned int nb_segs;
3896 res = parsed_result;
3897 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3898 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3900 set_tx_pkt_segments(seg_lengths, nb_segs);
3903 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3904 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3905 cmd_keyword, "set");
3906 cmdline_parse_token_string_t cmd_set_txpkts_name =
3907 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3909 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3910 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3913 cmdline_parse_inst_t cmd_set_txpkts = {
3914 .f = cmd_set_txpkts_parsed,
3916 .help_str = "set txpkts <len0[,len1]*>",
3918 (void *)&cmd_set_txpkts_keyword,
3919 (void *)&cmd_set_txpkts_name,
3920 (void *)&cmd_set_txpkts_lengths,
3925 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
3927 struct cmd_set_txsplit_result {
3928 cmdline_fixed_string_t cmd_keyword;
3929 cmdline_fixed_string_t txsplit;
3930 cmdline_fixed_string_t mode;
3934 cmd_set_txsplit_parsed(void *parsed_result,
3935 __rte_unused struct cmdline *cl,
3936 __rte_unused void *data)
3938 struct cmd_set_txsplit_result *res;
3940 res = parsed_result;
3941 set_tx_pkt_split(res->mode);
3944 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
3945 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3946 cmd_keyword, "set");
3947 cmdline_parse_token_string_t cmd_set_txsplit_name =
3948 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3949 txsplit, "txsplit");
3950 cmdline_parse_token_string_t cmd_set_txsplit_mode =
3951 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3954 cmdline_parse_inst_t cmd_set_txsplit = {
3955 .f = cmd_set_txsplit_parsed,
3957 .help_str = "set txsplit on|off|rand",
3959 (void *)&cmd_set_txsplit_keyword,
3960 (void *)&cmd_set_txsplit_name,
3961 (void *)&cmd_set_txsplit_mode,
3966 /* *** SET TIMES FOR TXONLY PACKETS SCHEDULING ON TIMESTAMPS *** */
3968 struct cmd_set_txtimes_result {
3969 cmdline_fixed_string_t cmd_keyword;
3970 cmdline_fixed_string_t txtimes;
3971 cmdline_fixed_string_t tx_times;
3975 cmd_set_txtimes_parsed(void *parsed_result,
3976 __rte_unused struct cmdline *cl,
3977 __rte_unused void *data)
3979 struct cmd_set_txtimes_result *res;
3980 unsigned int tx_times[2] = {0, 0};
3981 unsigned int n_times;
3983 res = parsed_result;
3984 n_times = parse_item_list(res->tx_times, "tx times",
3987 set_tx_pkt_times(tx_times);
3990 cmdline_parse_token_string_t cmd_set_txtimes_keyword =
3991 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
3992 cmd_keyword, "set");
3993 cmdline_parse_token_string_t cmd_set_txtimes_name =
3994 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
3995 txtimes, "txtimes");
3996 cmdline_parse_token_string_t cmd_set_txtimes_value =
3997 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4000 cmdline_parse_inst_t cmd_set_txtimes = {
4001 .f = cmd_set_txtimes_parsed,
4003 .help_str = "set txtimes <inter_burst>,<intra_burst>",
4005 (void *)&cmd_set_txtimes_keyword,
4006 (void *)&cmd_set_txtimes_name,
4007 (void *)&cmd_set_txtimes_value,
4012 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
4013 struct cmd_rx_vlan_filter_all_result {
4014 cmdline_fixed_string_t rx_vlan;
4015 cmdline_fixed_string_t what;
4016 cmdline_fixed_string_t all;
4021 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
4022 __rte_unused struct cmdline *cl,
4023 __rte_unused void *data)
4025 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
4027 if (!strcmp(res->what, "add"))
4028 rx_vlan_all_filter_set(res->port_id, 1);
4030 rx_vlan_all_filter_set(res->port_id, 0);
4033 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
4034 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4035 rx_vlan, "rx_vlan");
4036 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
4037 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4039 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
4040 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4042 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
4043 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4044 port_id, RTE_UINT16);
4046 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
4047 .f = cmd_rx_vlan_filter_all_parsed,
4049 .help_str = "rx_vlan add|rm all <port_id>: "
4050 "Add/Remove all identifiers to/from the set of VLAN "
4051 "identifiers filtered by a port",
4053 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
4054 (void *)&cmd_rx_vlan_filter_all_what,
4055 (void *)&cmd_rx_vlan_filter_all_all,
4056 (void *)&cmd_rx_vlan_filter_all_portid,
4061 /* *** VLAN OFFLOAD SET ON A PORT *** */
4062 struct cmd_vlan_offload_result {
4063 cmdline_fixed_string_t vlan;
4064 cmdline_fixed_string_t set;
4065 cmdline_fixed_string_t vlan_type;
4066 cmdline_fixed_string_t what;
4067 cmdline_fixed_string_t on;
4068 cmdline_fixed_string_t port_id;
4072 cmd_vlan_offload_parsed(void *parsed_result,
4073 __rte_unused struct cmdline *cl,
4074 __rte_unused void *data)
4077 struct cmd_vlan_offload_result *res = parsed_result;
4080 portid_t port_id = 0;
4084 len = strnlen(str, STR_TOKEN_SIZE);
4086 /* Get port_id first */
4094 tmp = strtoul(str, NULL, 0);
4095 /* If port_id greater that what portid_t can represent, return */
4096 if(tmp >= RTE_MAX_ETHPORTS)
4098 port_id = (portid_t)tmp;
4100 if (!strcmp(res->on, "on"))
4105 if (!strcmp(res->what, "strip"))
4106 rx_vlan_strip_set(port_id, on);
4107 else if(!strcmp(res->what, "stripq")){
4108 uint16_t queue_id = 0;
4110 /* No queue_id, return */
4112 printf("must specify (port,queue_id)\n");
4115 tmp = strtoul(str + i + 1, NULL, 0);
4116 /* If queue_id greater that what 16-bits can represent, return */
4120 queue_id = (uint16_t)tmp;
4121 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
4123 else if (!strcmp(res->what, "filter"))
4124 rx_vlan_filter_set(port_id, on);
4125 else if (!strcmp(res->what, "qinq_strip"))
4126 rx_vlan_qinq_strip_set(port_id, on);
4128 vlan_extend_set(port_id, on);
4133 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
4134 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4136 cmdline_parse_token_string_t cmd_vlan_offload_set =
4137 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4139 cmdline_parse_token_string_t cmd_vlan_offload_what =
4140 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4141 what, "strip#filter#qinq_strip#extend#stripq");
4142 cmdline_parse_token_string_t cmd_vlan_offload_on =
4143 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4145 cmdline_parse_token_string_t cmd_vlan_offload_portid =
4146 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4149 cmdline_parse_inst_t cmd_vlan_offload = {
4150 .f = cmd_vlan_offload_parsed,
4152 .help_str = "vlan set strip|filter|qinq_strip|extend|stripq on|off "
4153 "<port_id[,queue_id]>: "
4154 "Strip/Filter/QinQ for rx side Extend for both rx/tx sides",
4156 (void *)&cmd_vlan_offload_vlan,
4157 (void *)&cmd_vlan_offload_set,
4158 (void *)&cmd_vlan_offload_what,
4159 (void *)&cmd_vlan_offload_on,
4160 (void *)&cmd_vlan_offload_portid,
4165 /* *** VLAN TPID SET ON A PORT *** */
4166 struct cmd_vlan_tpid_result {
4167 cmdline_fixed_string_t vlan;
4168 cmdline_fixed_string_t set;
4169 cmdline_fixed_string_t vlan_type;
4170 cmdline_fixed_string_t what;
4176 cmd_vlan_tpid_parsed(void *parsed_result,
4177 __rte_unused struct cmdline *cl,
4178 __rte_unused void *data)
4180 struct cmd_vlan_tpid_result *res = parsed_result;
4181 enum rte_vlan_type vlan_type;
4183 if (!strcmp(res->vlan_type, "inner"))
4184 vlan_type = ETH_VLAN_TYPE_INNER;
4185 else if (!strcmp(res->vlan_type, "outer"))
4186 vlan_type = ETH_VLAN_TYPE_OUTER;
4188 printf("Unknown vlan type\n");
4191 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
4194 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
4195 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4197 cmdline_parse_token_string_t cmd_vlan_tpid_set =
4198 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4200 cmdline_parse_token_string_t cmd_vlan_type =
4201 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4202 vlan_type, "inner#outer");
4203 cmdline_parse_token_string_t cmd_vlan_tpid_what =
4204 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4206 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
4207 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4209 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
4210 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4211 port_id, RTE_UINT16);
4213 cmdline_parse_inst_t cmd_vlan_tpid = {
4214 .f = cmd_vlan_tpid_parsed,
4216 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
4217 "Set the VLAN Ether type",
4219 (void *)&cmd_vlan_tpid_vlan,
4220 (void *)&cmd_vlan_tpid_set,
4221 (void *)&cmd_vlan_type,
4222 (void *)&cmd_vlan_tpid_what,
4223 (void *)&cmd_vlan_tpid_tpid,
4224 (void *)&cmd_vlan_tpid_portid,
4229 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4230 struct cmd_rx_vlan_filter_result {
4231 cmdline_fixed_string_t rx_vlan;
4232 cmdline_fixed_string_t what;
4238 cmd_rx_vlan_filter_parsed(void *parsed_result,
4239 __rte_unused struct cmdline *cl,
4240 __rte_unused void *data)
4242 struct cmd_rx_vlan_filter_result *res = parsed_result;
4244 if (!strcmp(res->what, "add"))
4245 rx_vft_set(res->port_id, res->vlan_id, 1);
4247 rx_vft_set(res->port_id, res->vlan_id, 0);
4250 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
4251 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4252 rx_vlan, "rx_vlan");
4253 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
4254 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4256 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
4257 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4258 vlan_id, RTE_UINT16);
4259 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
4260 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4261 port_id, RTE_UINT16);
4263 cmdline_parse_inst_t cmd_rx_vlan_filter = {
4264 .f = cmd_rx_vlan_filter_parsed,
4266 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
4267 "Add/Remove a VLAN identifier to/from the set of VLAN "
4268 "identifiers filtered by a port",
4270 (void *)&cmd_rx_vlan_filter_rx_vlan,
4271 (void *)&cmd_rx_vlan_filter_what,
4272 (void *)&cmd_rx_vlan_filter_vlanid,
4273 (void *)&cmd_rx_vlan_filter_portid,
4278 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4279 struct cmd_tx_vlan_set_result {
4280 cmdline_fixed_string_t tx_vlan;
4281 cmdline_fixed_string_t set;
4287 cmd_tx_vlan_set_parsed(void *parsed_result,
4288 __rte_unused struct cmdline *cl,
4289 __rte_unused void *data)
4291 struct cmd_tx_vlan_set_result *res = parsed_result;
4293 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4296 if (!port_is_stopped(res->port_id)) {
4297 printf("Please stop port %d first\n", res->port_id);
4301 tx_vlan_set(res->port_id, res->vlan_id);
4303 cmd_reconfig_device_queue(res->port_id, 1, 1);
4306 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4307 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4308 tx_vlan, "tx_vlan");
4309 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4310 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4312 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4313 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4314 port_id, RTE_UINT16);
4315 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
4316 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4317 vlan_id, RTE_UINT16);
4319 cmdline_parse_inst_t cmd_tx_vlan_set = {
4320 .f = cmd_tx_vlan_set_parsed,
4322 .help_str = "tx_vlan set <port_id> <vlan_id>: "
4323 "Enable hardware insertion of a single VLAN header "
4324 "with a given TAG Identifier in packets sent on a port",
4326 (void *)&cmd_tx_vlan_set_tx_vlan,
4327 (void *)&cmd_tx_vlan_set_set,
4328 (void *)&cmd_tx_vlan_set_portid,
4329 (void *)&cmd_tx_vlan_set_vlanid,
4334 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4335 struct cmd_tx_vlan_set_qinq_result {
4336 cmdline_fixed_string_t tx_vlan;
4337 cmdline_fixed_string_t set;
4340 uint16_t vlan_id_outer;
4344 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4345 __rte_unused struct cmdline *cl,
4346 __rte_unused void *data)
4348 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
4350 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4353 if (!port_is_stopped(res->port_id)) {
4354 printf("Please stop port %d first\n", res->port_id);
4358 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
4360 cmd_reconfig_device_queue(res->port_id, 1, 1);
4363 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
4364 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4365 tx_vlan, "tx_vlan");
4366 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
4367 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4369 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
4370 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4371 port_id, RTE_UINT16);
4372 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
4373 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4374 vlan_id, RTE_UINT16);
4375 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
4376 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4377 vlan_id_outer, RTE_UINT16);
4379 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
4380 .f = cmd_tx_vlan_set_qinq_parsed,
4382 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
4383 "Enable hardware insertion of double VLAN header "
4384 "with given TAG Identifiers in packets sent on a port",
4386 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
4387 (void *)&cmd_tx_vlan_set_qinq_set,
4388 (void *)&cmd_tx_vlan_set_qinq_portid,
4389 (void *)&cmd_tx_vlan_set_qinq_vlanid,
4390 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
4395 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
4396 struct cmd_tx_vlan_set_pvid_result {
4397 cmdline_fixed_string_t tx_vlan;
4398 cmdline_fixed_string_t set;
4399 cmdline_fixed_string_t pvid;
4402 cmdline_fixed_string_t mode;
4406 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
4407 __rte_unused struct cmdline *cl,
4408 __rte_unused void *data)
4410 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
4412 if (strcmp(res->mode, "on") == 0)
4413 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
4415 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
4418 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
4419 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4420 tx_vlan, "tx_vlan");
4421 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
4422 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4424 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
4425 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4427 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
4428 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4429 port_id, RTE_UINT16);
4430 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
4431 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4432 vlan_id, RTE_UINT16);
4433 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
4434 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4437 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
4438 .f = cmd_tx_vlan_set_pvid_parsed,
4440 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
4442 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
4443 (void *)&cmd_tx_vlan_set_pvid_set,
4444 (void *)&cmd_tx_vlan_set_pvid_pvid,
4445 (void *)&cmd_tx_vlan_set_pvid_port_id,
4446 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
4447 (void *)&cmd_tx_vlan_set_pvid_mode,
4452 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4453 struct cmd_tx_vlan_reset_result {
4454 cmdline_fixed_string_t tx_vlan;
4455 cmdline_fixed_string_t reset;
4460 cmd_tx_vlan_reset_parsed(void *parsed_result,
4461 __rte_unused struct cmdline *cl,
4462 __rte_unused void *data)
4464 struct cmd_tx_vlan_reset_result *res = parsed_result;
4466 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4469 if (!port_is_stopped(res->port_id)) {
4470 printf("Please stop port %d first\n", res->port_id);
4474 tx_vlan_reset(res->port_id);
4476 cmd_reconfig_device_queue(res->port_id, 1, 1);
4479 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4480 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4481 tx_vlan, "tx_vlan");
4482 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4483 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4485 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4486 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4487 port_id, RTE_UINT16);
4489 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4490 .f = cmd_tx_vlan_reset_parsed,
4492 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4493 "VLAN header in packets sent on a port",
4495 (void *)&cmd_tx_vlan_reset_tx_vlan,
4496 (void *)&cmd_tx_vlan_reset_reset,
4497 (void *)&cmd_tx_vlan_reset_portid,
4503 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4504 struct cmd_csum_result {
4505 cmdline_fixed_string_t csum;
4506 cmdline_fixed_string_t mode;
4507 cmdline_fixed_string_t proto;
4508 cmdline_fixed_string_t hwsw;
4513 csum_show(int port_id)
4515 struct rte_eth_dev_info dev_info;
4516 uint64_t tx_offloads;
4519 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4520 printf("Parse tunnel is %s\n",
4521 (ports[port_id].parse_tunnel) ? "on" : "off");
4522 printf("IP checksum offload is %s\n",
4523 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4524 printf("UDP checksum offload is %s\n",
4525 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4526 printf("TCP checksum offload is %s\n",
4527 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4528 printf("SCTP checksum offload is %s\n",
4529 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4530 printf("Outer-Ip checksum offload is %s\n",
4531 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4532 printf("Outer-Udp checksum offload is %s\n",
4533 (tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
4535 /* display warnings if configuration is not supported by the NIC */
4536 ret = eth_dev_info_get_print_err(port_id, &dev_info);
4540 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
4541 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4542 printf("Warning: hardware IP checksum enabled but not "
4543 "supported by port %d\n", port_id);
4545 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
4546 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
4547 printf("Warning: hardware UDP checksum enabled but not "
4548 "supported by port %d\n", port_id);
4550 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
4551 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
4552 printf("Warning: hardware TCP checksum enabled but not "
4553 "supported by port %d\n", port_id);
4555 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
4556 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4557 printf("Warning: hardware SCTP checksum enabled but not "
4558 "supported by port %d\n", port_id);
4560 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4561 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4562 printf("Warning: hardware outer IP checksum enabled but not "
4563 "supported by port %d\n", port_id);
4565 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
4566 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)
4568 printf("Warning: hardware outer UDP checksum enabled but not "
4569 "supported by port %d\n", port_id);
4574 cmd_config_queue_tx_offloads(struct rte_port *port)
4578 /* Apply queue tx offloads configuration */
4579 for (k = 0; k < port->dev_info.max_rx_queues; k++)
4580 port->tx_conf[k].offloads =
4581 port->dev_conf.txmode.offloads;
4585 cmd_csum_parsed(void *parsed_result,
4586 __rte_unused struct cmdline *cl,
4587 __rte_unused void *data)
4589 struct cmd_csum_result *res = parsed_result;
4591 uint64_t csum_offloads = 0;
4592 struct rte_eth_dev_info dev_info;
4595 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4596 printf("invalid port %d\n", res->port_id);
4599 if (!port_is_stopped(res->port_id)) {
4600 printf("Please stop port %d first\n", res->port_id);
4604 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4608 if (!strcmp(res->mode, "set")) {
4610 if (!strcmp(res->hwsw, "hw"))
4613 if (!strcmp(res->proto, "ip")) {
4614 if (hw == 0 || (dev_info.tx_offload_capa &
4615 DEV_TX_OFFLOAD_IPV4_CKSUM)) {
4616 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
4618 printf("IP checksum offload is not supported "
4619 "by port %u\n", res->port_id);
4621 } else if (!strcmp(res->proto, "udp")) {
4622 if (hw == 0 || (dev_info.tx_offload_capa &
4623 DEV_TX_OFFLOAD_UDP_CKSUM)) {
4624 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
4626 printf("UDP checksum offload is not supported "
4627 "by port %u\n", res->port_id);
4629 } else if (!strcmp(res->proto, "tcp")) {
4630 if (hw == 0 || (dev_info.tx_offload_capa &
4631 DEV_TX_OFFLOAD_TCP_CKSUM)) {
4632 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
4634 printf("TCP checksum offload is not supported "
4635 "by port %u\n", res->port_id);
4637 } else if (!strcmp(res->proto, "sctp")) {
4638 if (hw == 0 || (dev_info.tx_offload_capa &
4639 DEV_TX_OFFLOAD_SCTP_CKSUM)) {
4640 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
4642 printf("SCTP checksum offload is not supported "
4643 "by port %u\n", res->port_id);
4645 } else if (!strcmp(res->proto, "outer-ip")) {
4646 if (hw == 0 || (dev_info.tx_offload_capa &
4647 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4649 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4651 printf("Outer IP checksum offload is not "
4652 "supported by port %u\n", res->port_id);
4654 } else if (!strcmp(res->proto, "outer-udp")) {
4655 if (hw == 0 || (dev_info.tx_offload_capa &
4656 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
4658 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM;
4660 printf("Outer UDP checksum offload is not "
4661 "supported by port %u\n", res->port_id);
4666 ports[res->port_id].dev_conf.txmode.offloads |=
4669 ports[res->port_id].dev_conf.txmode.offloads &=
4672 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4674 csum_show(res->port_id);
4676 cmd_reconfig_device_queue(res->port_id, 1, 1);
4679 cmdline_parse_token_string_t cmd_csum_csum =
4680 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4682 cmdline_parse_token_string_t cmd_csum_mode =
4683 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4685 cmdline_parse_token_string_t cmd_csum_proto =
4686 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4687 proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
4688 cmdline_parse_token_string_t cmd_csum_hwsw =
4689 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4691 cmdline_parse_token_num_t cmd_csum_portid =
4692 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4693 port_id, RTE_UINT16);
4695 cmdline_parse_inst_t cmd_csum_set = {
4696 .f = cmd_csum_parsed,
4698 .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
4699 "Enable/Disable hardware calculation of L3/L4 checksum when "
4700 "using csum forward engine",
4702 (void *)&cmd_csum_csum,
4703 (void *)&cmd_csum_mode,
4704 (void *)&cmd_csum_proto,
4705 (void *)&cmd_csum_hwsw,
4706 (void *)&cmd_csum_portid,
4711 cmdline_parse_token_string_t cmd_csum_mode_show =
4712 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4715 cmdline_parse_inst_t cmd_csum_show = {
4716 .f = cmd_csum_parsed,
4718 .help_str = "csum show <port_id>: Show checksum offload configuration",
4720 (void *)&cmd_csum_csum,
4721 (void *)&cmd_csum_mode_show,
4722 (void *)&cmd_csum_portid,
4727 /* Enable/disable tunnel parsing */
4728 struct cmd_csum_tunnel_result {
4729 cmdline_fixed_string_t csum;
4730 cmdline_fixed_string_t parse;
4731 cmdline_fixed_string_t onoff;
4736 cmd_csum_tunnel_parsed(void *parsed_result,
4737 __rte_unused struct cmdline *cl,
4738 __rte_unused void *data)
4740 struct cmd_csum_tunnel_result *res = parsed_result;
4742 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4745 if (!strcmp(res->onoff, "on"))
4746 ports[res->port_id].parse_tunnel = 1;
4748 ports[res->port_id].parse_tunnel = 0;
4750 csum_show(res->port_id);
4753 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4754 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4756 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4757 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4758 parse, "parse-tunnel");
4759 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4760 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4762 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4763 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4764 port_id, RTE_UINT16);
4766 cmdline_parse_inst_t cmd_csum_tunnel = {
4767 .f = cmd_csum_tunnel_parsed,
4769 .help_str = "csum parse-tunnel on|off <port_id>: "
4770 "Enable/Disable parsing of tunnels for csum engine",
4772 (void *)&cmd_csum_tunnel_csum,
4773 (void *)&cmd_csum_tunnel_parse,
4774 (void *)&cmd_csum_tunnel_onoff,
4775 (void *)&cmd_csum_tunnel_portid,
4780 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4781 struct cmd_tso_set_result {
4782 cmdline_fixed_string_t tso;
4783 cmdline_fixed_string_t mode;
4789 cmd_tso_set_parsed(void *parsed_result,
4790 __rte_unused struct cmdline *cl,
4791 __rte_unused void *data)
4793 struct cmd_tso_set_result *res = parsed_result;
4794 struct rte_eth_dev_info dev_info;
4797 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4799 if (!port_is_stopped(res->port_id)) {
4800 printf("Please stop port %d first\n", res->port_id);
4804 if (!strcmp(res->mode, "set"))
4805 ports[res->port_id].tso_segsz = res->tso_segsz;
4807 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4811 if ((ports[res->port_id].tso_segsz != 0) &&
4812 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4813 printf("Error: TSO is not supported by port %d\n",
4818 if (ports[res->port_id].tso_segsz == 0) {
4819 ports[res->port_id].dev_conf.txmode.offloads &=
4820 ~DEV_TX_OFFLOAD_TCP_TSO;
4821 printf("TSO for non-tunneled packets is disabled\n");
4823 ports[res->port_id].dev_conf.txmode.offloads |=
4824 DEV_TX_OFFLOAD_TCP_TSO;
4825 printf("TSO segment size for non-tunneled packets is %d\n",
4826 ports[res->port_id].tso_segsz);
4828 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4830 /* display warnings if configuration is not supported by the NIC */
4831 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4835 if ((ports[res->port_id].tso_segsz != 0) &&
4836 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4837 printf("Warning: TSO enabled but not "
4838 "supported by port %d\n", res->port_id);
4841 cmd_reconfig_device_queue(res->port_id, 1, 1);
4844 cmdline_parse_token_string_t cmd_tso_set_tso =
4845 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4847 cmdline_parse_token_string_t cmd_tso_set_mode =
4848 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4850 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4851 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4852 tso_segsz, RTE_UINT16);
4853 cmdline_parse_token_num_t cmd_tso_set_portid =
4854 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4855 port_id, RTE_UINT16);
4857 cmdline_parse_inst_t cmd_tso_set = {
4858 .f = cmd_tso_set_parsed,
4860 .help_str = "tso set <tso_segsz> <port_id>: "
4861 "Set TSO segment size of non-tunneled packets for csum engine "
4864 (void *)&cmd_tso_set_tso,
4865 (void *)&cmd_tso_set_mode,
4866 (void *)&cmd_tso_set_tso_segsz,
4867 (void *)&cmd_tso_set_portid,
4872 cmdline_parse_token_string_t cmd_tso_show_mode =
4873 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4877 cmdline_parse_inst_t cmd_tso_show = {
4878 .f = cmd_tso_set_parsed,
4880 .help_str = "tso show <port_id>: "
4881 "Show TSO segment size of non-tunneled packets for csum engine",
4883 (void *)&cmd_tso_set_tso,
4884 (void *)&cmd_tso_show_mode,
4885 (void *)&cmd_tso_set_portid,
4890 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
4891 struct cmd_tunnel_tso_set_result {
4892 cmdline_fixed_string_t tso;
4893 cmdline_fixed_string_t mode;
4898 static struct rte_eth_dev_info
4899 check_tunnel_tso_nic_support(portid_t port_id)
4901 struct rte_eth_dev_info dev_info;
4903 if (eth_dev_info_get_print_err(port_id, &dev_info) != 0)
4906 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
4907 printf("Warning: VXLAN TUNNEL TSO not supported therefore "
4908 "not enabled for port %d\n", port_id);
4909 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
4910 printf("Warning: GRE TUNNEL TSO not supported therefore "
4911 "not enabled for port %d\n", port_id);
4912 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
4913 printf("Warning: IPIP TUNNEL TSO not supported therefore "
4914 "not enabled for port %d\n", port_id);
4915 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
4916 printf("Warning: GENEVE TUNNEL TSO not supported therefore "
4917 "not enabled for port %d\n", port_id);
4918 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
4919 printf("Warning: IP TUNNEL TSO not supported therefore "
4920 "not enabled for port %d\n", port_id);
4921 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
4922 printf("Warning: UDP TUNNEL TSO not supported therefore "
4923 "not enabled for port %d\n", port_id);
4928 cmd_tunnel_tso_set_parsed(void *parsed_result,
4929 __rte_unused struct cmdline *cl,
4930 __rte_unused void *data)
4932 struct cmd_tunnel_tso_set_result *res = parsed_result;
4933 struct rte_eth_dev_info dev_info;
4935 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4937 if (!port_is_stopped(res->port_id)) {
4938 printf("Please stop port %d first\n", res->port_id);
4942 if (!strcmp(res->mode, "set"))
4943 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
4945 dev_info = check_tunnel_tso_nic_support(res->port_id);
4946 if (ports[res->port_id].tunnel_tso_segsz == 0) {
4947 ports[res->port_id].dev_conf.txmode.offloads &=
4948 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4949 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4950 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4951 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4952 DEV_TX_OFFLOAD_IP_TNL_TSO |
4953 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4954 printf("TSO for tunneled packets is disabled\n");
4956 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4957 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4958 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4959 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4960 DEV_TX_OFFLOAD_IP_TNL_TSO |
4961 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4963 ports[res->port_id].dev_conf.txmode.offloads |=
4964 (tso_offloads & dev_info.tx_offload_capa);
4965 printf("TSO segment size for tunneled packets is %d\n",
4966 ports[res->port_id].tunnel_tso_segsz);
4968 /* Below conditions are needed to make it work:
4969 * (1) tunnel TSO is supported by the NIC;
4970 * (2) "csum parse_tunnel" must be set so that tunneled pkts
4972 * (3) for tunneled pkts with outer L3 of IPv4,
4973 * "csum set outer-ip" must be set to hw, because after tso,
4974 * total_len of outer IP header is changed, and the checksum
4975 * of outer IP header calculated by sw should be wrong; that
4976 * is not necessary for IPv6 tunneled pkts because there's no
4977 * checksum in IP header anymore.
4980 if (!ports[res->port_id].parse_tunnel)
4981 printf("Warning: csum parse_tunnel must be set "
4982 "so that tunneled packets are recognized\n");
4983 if (!(ports[res->port_id].dev_conf.txmode.offloads &
4984 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
4985 printf("Warning: csum set outer-ip must be set to hw "
4986 "if outer L3 is IPv4; not necessary for IPv6\n");
4989 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4990 cmd_reconfig_device_queue(res->port_id, 1, 1);
4993 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
4994 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4996 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
4997 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4999 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
5000 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5001 tso_segsz, RTE_UINT16);
5002 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
5003 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5004 port_id, RTE_UINT16);
5006 cmdline_parse_inst_t cmd_tunnel_tso_set = {
5007 .f = cmd_tunnel_tso_set_parsed,
5009 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
5010 "Set TSO segment size of tunneled packets for csum engine "
5013 (void *)&cmd_tunnel_tso_set_tso,
5014 (void *)&cmd_tunnel_tso_set_mode,
5015 (void *)&cmd_tunnel_tso_set_tso_segsz,
5016 (void *)&cmd_tunnel_tso_set_portid,
5021 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
5022 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5026 cmdline_parse_inst_t cmd_tunnel_tso_show = {
5027 .f = cmd_tunnel_tso_set_parsed,
5029 .help_str = "tunnel_tso show <port_id> "
5030 "Show TSO segment size of tunneled packets for csum engine",
5032 (void *)&cmd_tunnel_tso_set_tso,
5033 (void *)&cmd_tunnel_tso_show_mode,
5034 (void *)&cmd_tunnel_tso_set_portid,
5039 /* *** SET GRO FOR A PORT *** */
5040 struct cmd_gro_enable_result {
5041 cmdline_fixed_string_t cmd_set;
5042 cmdline_fixed_string_t cmd_port;
5043 cmdline_fixed_string_t cmd_keyword;
5044 cmdline_fixed_string_t cmd_onoff;
5049 cmd_gro_enable_parsed(void *parsed_result,
5050 __rte_unused struct cmdline *cl,
5051 __rte_unused void *data)
5053 struct cmd_gro_enable_result *res;
5055 res = parsed_result;
5056 if (!strcmp(res->cmd_keyword, "gro"))
5057 setup_gro(res->cmd_onoff, res->cmd_pid);
5060 cmdline_parse_token_string_t cmd_gro_enable_set =
5061 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5063 cmdline_parse_token_string_t cmd_gro_enable_port =
5064 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5065 cmd_keyword, "port");
5066 cmdline_parse_token_num_t cmd_gro_enable_pid =
5067 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
5068 cmd_pid, RTE_UINT16);
5069 cmdline_parse_token_string_t cmd_gro_enable_keyword =
5070 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5071 cmd_keyword, "gro");
5072 cmdline_parse_token_string_t cmd_gro_enable_onoff =
5073 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5074 cmd_onoff, "on#off");
5076 cmdline_parse_inst_t cmd_gro_enable = {
5077 .f = cmd_gro_enable_parsed,
5079 .help_str = "set port <port_id> gro on|off",
5081 (void *)&cmd_gro_enable_set,
5082 (void *)&cmd_gro_enable_port,
5083 (void *)&cmd_gro_enable_pid,
5084 (void *)&cmd_gro_enable_keyword,
5085 (void *)&cmd_gro_enable_onoff,
5090 /* *** DISPLAY GRO CONFIGURATION *** */
5091 struct cmd_gro_show_result {
5092 cmdline_fixed_string_t cmd_show;
5093 cmdline_fixed_string_t cmd_port;
5094 cmdline_fixed_string_t cmd_keyword;
5099 cmd_gro_show_parsed(void *parsed_result,
5100 __rte_unused struct cmdline *cl,
5101 __rte_unused void *data)
5103 struct cmd_gro_show_result *res;
5105 res = parsed_result;
5106 if (!strcmp(res->cmd_keyword, "gro"))
5107 show_gro(res->cmd_pid);
5110 cmdline_parse_token_string_t cmd_gro_show_show =
5111 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5113 cmdline_parse_token_string_t cmd_gro_show_port =
5114 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5116 cmdline_parse_token_num_t cmd_gro_show_pid =
5117 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
5118 cmd_pid, RTE_UINT16);
5119 cmdline_parse_token_string_t cmd_gro_show_keyword =
5120 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5121 cmd_keyword, "gro");
5123 cmdline_parse_inst_t cmd_gro_show = {
5124 .f = cmd_gro_show_parsed,
5126 .help_str = "show port <port_id> gro",
5128 (void *)&cmd_gro_show_show,
5129 (void *)&cmd_gro_show_port,
5130 (void *)&cmd_gro_show_pid,
5131 (void *)&cmd_gro_show_keyword,
5136 /* *** SET FLUSH CYCLES FOR GRO *** */
5137 struct cmd_gro_flush_result {
5138 cmdline_fixed_string_t cmd_set;
5139 cmdline_fixed_string_t cmd_keyword;
5140 cmdline_fixed_string_t cmd_flush;
5145 cmd_gro_flush_parsed(void *parsed_result,
5146 __rte_unused struct cmdline *cl,
5147 __rte_unused void *data)
5149 struct cmd_gro_flush_result *res;
5151 res = parsed_result;
5152 if ((!strcmp(res->cmd_keyword, "gro")) &&
5153 (!strcmp(res->cmd_flush, "flush")))
5154 setup_gro_flush_cycles(res->cmd_cycles);
5157 cmdline_parse_token_string_t cmd_gro_flush_set =
5158 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5160 cmdline_parse_token_string_t cmd_gro_flush_keyword =
5161 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5162 cmd_keyword, "gro");
5163 cmdline_parse_token_string_t cmd_gro_flush_flush =
5164 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5165 cmd_flush, "flush");
5166 cmdline_parse_token_num_t cmd_gro_flush_cycles =
5167 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
5168 cmd_cycles, RTE_UINT8);
5170 cmdline_parse_inst_t cmd_gro_flush = {
5171 .f = cmd_gro_flush_parsed,
5173 .help_str = "set gro flush <cycles>",
5175 (void *)&cmd_gro_flush_set,
5176 (void *)&cmd_gro_flush_keyword,
5177 (void *)&cmd_gro_flush_flush,
5178 (void *)&cmd_gro_flush_cycles,
5183 /* *** ENABLE/DISABLE GSO *** */
5184 struct cmd_gso_enable_result {
5185 cmdline_fixed_string_t cmd_set;
5186 cmdline_fixed_string_t cmd_port;
5187 cmdline_fixed_string_t cmd_keyword;
5188 cmdline_fixed_string_t cmd_mode;
5193 cmd_gso_enable_parsed(void *parsed_result,
5194 __rte_unused struct cmdline *cl,
5195 __rte_unused void *data)
5197 struct cmd_gso_enable_result *res;
5199 res = parsed_result;
5200 if (!strcmp(res->cmd_keyword, "gso"))
5201 setup_gso(res->cmd_mode, res->cmd_pid);
5204 cmdline_parse_token_string_t cmd_gso_enable_set =
5205 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5207 cmdline_parse_token_string_t cmd_gso_enable_port =
5208 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5210 cmdline_parse_token_string_t cmd_gso_enable_keyword =
5211 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5212 cmd_keyword, "gso");
5213 cmdline_parse_token_string_t cmd_gso_enable_mode =
5214 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5215 cmd_mode, "on#off");
5216 cmdline_parse_token_num_t cmd_gso_enable_pid =
5217 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
5218 cmd_pid, RTE_UINT16);
5220 cmdline_parse_inst_t cmd_gso_enable = {
5221 .f = cmd_gso_enable_parsed,
5223 .help_str = "set port <port_id> gso on|off",
5225 (void *)&cmd_gso_enable_set,
5226 (void *)&cmd_gso_enable_port,
5227 (void *)&cmd_gso_enable_pid,
5228 (void *)&cmd_gso_enable_keyword,
5229 (void *)&cmd_gso_enable_mode,
5234 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
5235 struct cmd_gso_size_result {
5236 cmdline_fixed_string_t cmd_set;
5237 cmdline_fixed_string_t cmd_keyword;
5238 cmdline_fixed_string_t cmd_segsz;
5243 cmd_gso_size_parsed(void *parsed_result,
5244 __rte_unused struct cmdline *cl,
5245 __rte_unused void *data)
5247 struct cmd_gso_size_result *res = parsed_result;
5249 if (test_done == 0) {
5250 printf("Before setting GSO segsz, please first"
5251 " stop forwarding\n");
5255 if (!strcmp(res->cmd_keyword, "gso") &&
5256 !strcmp(res->cmd_segsz, "segsz")) {
5257 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
5258 printf("gso_size should be larger than %zu."
5259 " Please input a legal value\n",
5260 RTE_GSO_SEG_SIZE_MIN);
5262 gso_max_segment_size = res->cmd_size;
5266 cmdline_parse_token_string_t cmd_gso_size_set =
5267 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5269 cmdline_parse_token_string_t cmd_gso_size_keyword =
5270 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5271 cmd_keyword, "gso");
5272 cmdline_parse_token_string_t cmd_gso_size_segsz =
5273 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5274 cmd_segsz, "segsz");
5275 cmdline_parse_token_num_t cmd_gso_size_size =
5276 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
5277 cmd_size, RTE_UINT16);
5279 cmdline_parse_inst_t cmd_gso_size = {
5280 .f = cmd_gso_size_parsed,
5282 .help_str = "set gso segsz <length>",
5284 (void *)&cmd_gso_size_set,
5285 (void *)&cmd_gso_size_keyword,
5286 (void *)&cmd_gso_size_segsz,
5287 (void *)&cmd_gso_size_size,
5292 /* *** SHOW GSO CONFIGURATION *** */
5293 struct cmd_gso_show_result {
5294 cmdline_fixed_string_t cmd_show;
5295 cmdline_fixed_string_t cmd_port;
5296 cmdline_fixed_string_t cmd_keyword;
5301 cmd_gso_show_parsed(void *parsed_result,
5302 __rte_unused struct cmdline *cl,
5303 __rte_unused void *data)
5305 struct cmd_gso_show_result *res = parsed_result;
5307 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
5308 printf("invalid port id %u\n", res->cmd_pid);
5311 if (!strcmp(res->cmd_keyword, "gso")) {
5312 if (gso_ports[res->cmd_pid].enable) {
5313 printf("Max GSO'd packet size: %uB\n"
5314 "Supported GSO types: TCP/IPv4, "
5315 "UDP/IPv4, VxLAN with inner "
5316 "TCP/IPv4 packet, GRE with inner "
5317 "TCP/IPv4 packet\n",
5318 gso_max_segment_size);
5320 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
5324 cmdline_parse_token_string_t cmd_gso_show_show =
5325 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5327 cmdline_parse_token_string_t cmd_gso_show_port =
5328 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5330 cmdline_parse_token_string_t cmd_gso_show_keyword =
5331 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5332 cmd_keyword, "gso");
5333 cmdline_parse_token_num_t cmd_gso_show_pid =
5334 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
5335 cmd_pid, RTE_UINT16);
5337 cmdline_parse_inst_t cmd_gso_show = {
5338 .f = cmd_gso_show_parsed,
5340 .help_str = "show port <port_id> gso",
5342 (void *)&cmd_gso_show_show,
5343 (void *)&cmd_gso_show_port,
5344 (void *)&cmd_gso_show_pid,
5345 (void *)&cmd_gso_show_keyword,
5350 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
5351 struct cmd_set_flush_rx {
5352 cmdline_fixed_string_t set;
5353 cmdline_fixed_string_t flush_rx;
5354 cmdline_fixed_string_t mode;
5358 cmd_set_flush_rx_parsed(void *parsed_result,
5359 __rte_unused struct cmdline *cl,
5360 __rte_unused void *data)
5362 struct cmd_set_flush_rx *res = parsed_result;
5363 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5366 cmdline_parse_token_string_t cmd_setflushrx_set =
5367 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5369 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
5370 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5371 flush_rx, "flush_rx");
5372 cmdline_parse_token_string_t cmd_setflushrx_mode =
5373 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5377 cmdline_parse_inst_t cmd_set_flush_rx = {
5378 .f = cmd_set_flush_rx_parsed,
5379 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
5382 (void *)&cmd_setflushrx_set,
5383 (void *)&cmd_setflushrx_flush_rx,
5384 (void *)&cmd_setflushrx_mode,
5389 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
5390 struct cmd_set_link_check {
5391 cmdline_fixed_string_t set;
5392 cmdline_fixed_string_t link_check;
5393 cmdline_fixed_string_t mode;
5397 cmd_set_link_check_parsed(void *parsed_result,
5398 __rte_unused struct cmdline *cl,
5399 __rte_unused void *data)
5401 struct cmd_set_link_check *res = parsed_result;
5402 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5405 cmdline_parse_token_string_t cmd_setlinkcheck_set =
5406 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5408 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
5409 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5410 link_check, "link_check");
5411 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
5412 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5416 cmdline_parse_inst_t cmd_set_link_check = {
5417 .f = cmd_set_link_check_parsed,
5418 .help_str = "set link_check on|off: Enable/Disable link status check "
5419 "when starting/stopping a port",
5422 (void *)&cmd_setlinkcheck_set,
5423 (void *)&cmd_setlinkcheck_link_check,
5424 (void *)&cmd_setlinkcheck_mode,
5429 /* *** SET NIC BYPASS MODE *** */
5430 struct cmd_set_bypass_mode_result {
5431 cmdline_fixed_string_t set;
5432 cmdline_fixed_string_t bypass;
5433 cmdline_fixed_string_t mode;
5434 cmdline_fixed_string_t value;
5439 cmd_set_bypass_mode_parsed(void *parsed_result,
5440 __rte_unused struct cmdline *cl,
5441 __rte_unused void *data)
5443 struct cmd_set_bypass_mode_result *res = parsed_result;
5444 portid_t port_id = res->port_id;
5445 int32_t rc = -EINVAL;
5447 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5448 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5450 if (!strcmp(res->value, "bypass"))
5451 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5452 else if (!strcmp(res->value, "isolate"))
5453 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5455 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5457 /* Set the bypass mode for the relevant port. */
5458 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
5461 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
5464 cmdline_parse_token_string_t cmd_setbypass_mode_set =
5465 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5467 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
5468 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5470 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
5471 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5473 cmdline_parse_token_string_t cmd_setbypass_mode_value =
5474 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5475 value, "normal#bypass#isolate");
5476 cmdline_parse_token_num_t cmd_setbypass_mode_port =
5477 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
5478 port_id, RTE_UINT16);
5480 cmdline_parse_inst_t cmd_set_bypass_mode = {
5481 .f = cmd_set_bypass_mode_parsed,
5482 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
5483 "Set the NIC bypass mode for port_id",
5486 (void *)&cmd_setbypass_mode_set,
5487 (void *)&cmd_setbypass_mode_bypass,
5488 (void *)&cmd_setbypass_mode_mode,
5489 (void *)&cmd_setbypass_mode_value,
5490 (void *)&cmd_setbypass_mode_port,
5495 /* *** SET NIC BYPASS EVENT *** */
5496 struct cmd_set_bypass_event_result {
5497 cmdline_fixed_string_t set;
5498 cmdline_fixed_string_t bypass;
5499 cmdline_fixed_string_t event;
5500 cmdline_fixed_string_t event_value;
5501 cmdline_fixed_string_t mode;
5502 cmdline_fixed_string_t mode_value;
5507 cmd_set_bypass_event_parsed(void *parsed_result,
5508 __rte_unused struct cmdline *cl,
5509 __rte_unused void *data)
5511 int32_t rc = -EINVAL;
5512 struct cmd_set_bypass_event_result *res = parsed_result;
5513 portid_t port_id = res->port_id;
5515 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5516 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5517 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5519 if (!strcmp(res->event_value, "timeout"))
5520 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
5521 else if (!strcmp(res->event_value, "os_on"))
5522 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
5523 else if (!strcmp(res->event_value, "os_off"))
5524 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5525 else if (!strcmp(res->event_value, "power_on"))
5526 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5527 else if (!strcmp(res->event_value, "power_off"))
5528 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5530 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5532 if (!strcmp(res->mode_value, "bypass"))
5533 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5534 else if (!strcmp(res->mode_value, "isolate"))
5535 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5537 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5539 /* Set the watchdog timeout. */
5540 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5543 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5544 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5548 printf("Failed to set timeout value %u "
5549 "for port %d, errto code: %d.\n",
5550 bypass_timeout, port_id, rc);
5554 /* Set the bypass event to transition to bypass mode. */
5555 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5560 printf("\t Failed to set bypass event for port = %d.\n",
5564 cmdline_parse_token_string_t cmd_setbypass_event_set =
5565 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5567 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5568 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5570 cmdline_parse_token_string_t cmd_setbypass_event_event =
5571 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5573 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5574 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5575 event_value, "none#timeout#os_off#os_on#power_on#power_off");
5576 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5577 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5579 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5580 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5581 mode_value, "normal#bypass#isolate");
5582 cmdline_parse_token_num_t cmd_setbypass_event_port =
5583 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5584 port_id, RTE_UINT16);
5586 cmdline_parse_inst_t cmd_set_bypass_event = {
5587 .f = cmd_set_bypass_event_parsed,
5588 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5589 "power_off mode normal|bypass|isolate <port_id>: "
5590 "Set the NIC bypass event mode for port_id",
5593 (void *)&cmd_setbypass_event_set,
5594 (void *)&cmd_setbypass_event_bypass,
5595 (void *)&cmd_setbypass_event_event,
5596 (void *)&cmd_setbypass_event_event_value,
5597 (void *)&cmd_setbypass_event_mode,
5598 (void *)&cmd_setbypass_event_mode_value,
5599 (void *)&cmd_setbypass_event_port,
5605 /* *** SET NIC BYPASS TIMEOUT *** */
5606 struct cmd_set_bypass_timeout_result {
5607 cmdline_fixed_string_t set;
5608 cmdline_fixed_string_t bypass;
5609 cmdline_fixed_string_t timeout;
5610 cmdline_fixed_string_t value;
5614 cmd_set_bypass_timeout_parsed(void *parsed_result,
5615 __rte_unused struct cmdline *cl,
5616 __rte_unused void *data)
5618 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5620 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5621 if (!strcmp(res->value, "1.5"))
5622 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5623 else if (!strcmp(res->value, "2"))
5624 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5625 else if (!strcmp(res->value, "3"))
5626 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5627 else if (!strcmp(res->value, "4"))
5628 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5629 else if (!strcmp(res->value, "8"))
5630 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5631 else if (!strcmp(res->value, "16"))
5632 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5633 else if (!strcmp(res->value, "32"))
5634 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5636 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5640 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5641 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5643 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5644 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5646 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5647 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5648 timeout, "timeout");
5649 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5650 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5651 value, "0#1.5#2#3#4#8#16#32");
5653 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5654 .f = cmd_set_bypass_timeout_parsed,
5655 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5656 "Set the NIC bypass watchdog timeout in seconds",
5659 (void *)&cmd_setbypass_timeout_set,
5660 (void *)&cmd_setbypass_timeout_bypass,
5661 (void *)&cmd_setbypass_timeout_timeout,
5662 (void *)&cmd_setbypass_timeout_value,
5667 /* *** SHOW NIC BYPASS MODE *** */
5668 struct cmd_show_bypass_config_result {
5669 cmdline_fixed_string_t show;
5670 cmdline_fixed_string_t bypass;
5671 cmdline_fixed_string_t config;
5676 cmd_show_bypass_config_parsed(void *parsed_result,
5677 __rte_unused struct cmdline *cl,
5678 __rte_unused void *data)
5680 struct cmd_show_bypass_config_result *res = parsed_result;
5681 portid_t port_id = res->port_id;
5683 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5684 uint32_t event_mode;
5685 uint32_t bypass_mode;
5686 uint32_t timeout = bypass_timeout;
5689 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5690 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
5691 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5692 {"UNKNOWN", "normal", "bypass", "isolate"};
5693 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5701 /* Display the bypass mode.*/
5702 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5703 printf("\tFailed to get bypass mode for port = %d\n", port_id);
5707 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5708 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5710 printf("\tbypass mode = %s\n", modes[bypass_mode]);
5713 /* Display the bypass timeout.*/
5714 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5715 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5717 printf("\tbypass timeout = %s\n", timeouts[timeout]);
5719 /* Display the bypass events and associated modes. */
5720 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < RTE_DIM(events); i++) {
5722 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5723 printf("\tFailed to get bypass mode for event = %s\n",
5726 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5727 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5729 printf("\tbypass event: %-16s = %s\n", events[i],
5735 printf("\tFailed to get bypass configuration for port = %d\n",
5739 cmdline_parse_token_string_t cmd_showbypass_config_show =
5740 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5742 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5743 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5745 cmdline_parse_token_string_t cmd_showbypass_config_config =
5746 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5748 cmdline_parse_token_num_t cmd_showbypass_config_port =
5749 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5750 port_id, RTE_UINT16);
5752 cmdline_parse_inst_t cmd_show_bypass_config = {
5753 .f = cmd_show_bypass_config_parsed,
5754 .help_str = "show bypass config <port_id>: "
5755 "Show the NIC bypass config for port_id",
5758 (void *)&cmd_showbypass_config_show,
5759 (void *)&cmd_showbypass_config_bypass,
5760 (void *)&cmd_showbypass_config_config,
5761 (void *)&cmd_showbypass_config_port,
5767 /* *** SET BONDING MODE *** */
5768 struct cmd_set_bonding_mode_result {
5769 cmdline_fixed_string_t set;
5770 cmdline_fixed_string_t bonding;
5771 cmdline_fixed_string_t mode;
5776 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5777 __rte_unused struct cmdline *cl,
5778 __rte_unused void *data)
5780 struct cmd_set_bonding_mode_result *res = parsed_result;
5781 portid_t port_id = res->port_id;
5783 /* Set the bonding mode for the relevant port. */
5784 if (0 != rte_eth_bond_mode_set(port_id, res->value))
5785 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
5788 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5789 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5791 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5792 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5793 bonding, "bonding");
5794 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5795 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5797 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5798 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5800 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5801 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5802 port_id, RTE_UINT16);
5804 cmdline_parse_inst_t cmd_set_bonding_mode = {
5805 .f = cmd_set_bonding_mode_parsed,
5806 .help_str = "set bonding mode <mode_value> <port_id>: "
5807 "Set the bonding mode for port_id",
5810 (void *) &cmd_setbonding_mode_set,
5811 (void *) &cmd_setbonding_mode_bonding,
5812 (void *) &cmd_setbonding_mode_mode,
5813 (void *) &cmd_setbonding_mode_value,
5814 (void *) &cmd_setbonding_mode_port,
5819 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5820 struct cmd_set_bonding_lacp_dedicated_queues_result {
5821 cmdline_fixed_string_t set;
5822 cmdline_fixed_string_t bonding;
5823 cmdline_fixed_string_t lacp;
5824 cmdline_fixed_string_t dedicated_queues;
5826 cmdline_fixed_string_t mode;
5829 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5830 __rte_unused struct cmdline *cl,
5831 __rte_unused void *data)
5833 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5834 portid_t port_id = res->port_id;
5835 struct rte_port *port;
5837 port = &ports[port_id];
5839 /** Check if the port is not started **/
5840 if (port->port_status != RTE_PORT_STOPPED) {
5841 printf("Please stop port %d first\n", port_id);
5845 if (!strcmp(res->mode, "enable")) {
5846 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5847 printf("Dedicate queues for LACP control packets"
5850 printf("Enabling dedicate queues for LACP control "
5851 "packets on port %d failed\n", port_id);
5852 } else if (!strcmp(res->mode, "disable")) {
5853 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5854 printf("Dedicated queues for LACP control packets "
5857 printf("Disabling dedicated queues for LACP control "
5858 "traffic on port %d failed\n", port_id);
5862 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5863 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5865 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
5866 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5867 bonding, "bonding");
5868 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
5869 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5871 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
5872 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5873 dedicated_queues, "dedicated_queues");
5874 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
5875 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5876 port_id, RTE_UINT16);
5877 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
5878 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5879 mode, "enable#disable");
5881 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
5882 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
5883 .help_str = "set bonding lacp dedicated_queues <port_id> "
5885 "Enable/disable dedicated queues for LACP control traffic for port_id",
5888 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
5889 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
5890 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
5891 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
5892 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
5893 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
5898 /* *** SET BALANCE XMIT POLICY *** */
5899 struct cmd_set_bonding_balance_xmit_policy_result {
5900 cmdline_fixed_string_t set;
5901 cmdline_fixed_string_t bonding;
5902 cmdline_fixed_string_t balance_xmit_policy;
5904 cmdline_fixed_string_t policy;
5907 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
5908 __rte_unused struct cmdline *cl,
5909 __rte_unused void *data)
5911 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
5912 portid_t port_id = res->port_id;
5915 if (!strcmp(res->policy, "l2")) {
5916 policy = BALANCE_XMIT_POLICY_LAYER2;
5917 } else if (!strcmp(res->policy, "l23")) {
5918 policy = BALANCE_XMIT_POLICY_LAYER23;
5919 } else if (!strcmp(res->policy, "l34")) {
5920 policy = BALANCE_XMIT_POLICY_LAYER34;
5922 printf("\t Invalid xmit policy selection");
5926 /* Set the bonding mode for the relevant port. */
5927 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
5928 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
5933 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
5934 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5936 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
5937 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5938 bonding, "bonding");
5939 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
5940 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5941 balance_xmit_policy, "balance_xmit_policy");
5942 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
5943 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5944 port_id, RTE_UINT16);
5945 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
5946 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5947 policy, "l2#l23#l34");
5949 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
5950 .f = cmd_set_bonding_balance_xmit_policy_parsed,
5951 .help_str = "set bonding balance_xmit_policy <port_id> "
5953 "Set the bonding balance_xmit_policy for port_id",
5956 (void *)&cmd_setbonding_balance_xmit_policy_set,
5957 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
5958 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
5959 (void *)&cmd_setbonding_balance_xmit_policy_port,
5960 (void *)&cmd_setbonding_balance_xmit_policy_policy,
5965 /* *** SHOW NIC BONDING CONFIGURATION *** */
5966 struct cmd_show_bonding_config_result {
5967 cmdline_fixed_string_t show;
5968 cmdline_fixed_string_t bonding;
5969 cmdline_fixed_string_t config;
5973 static void cmd_show_bonding_config_parsed(void *parsed_result,
5974 __rte_unused struct cmdline *cl,
5975 __rte_unused void *data)
5977 struct cmd_show_bonding_config_result *res = parsed_result;
5978 int bonding_mode, agg_mode;
5979 portid_t slaves[RTE_MAX_ETHPORTS];
5980 int num_slaves, num_active_slaves;
5983 portid_t port_id = res->port_id;
5985 /* Display the bonding mode.*/
5986 bonding_mode = rte_eth_bond_mode_get(port_id);
5987 if (bonding_mode < 0) {
5988 printf("\tFailed to get bonding mode for port = %d\n", port_id);
5991 printf("\tBonding mode: %d\n", bonding_mode);
5993 if (bonding_mode == BONDING_MODE_BALANCE) {
5994 int balance_xmit_policy;
5996 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
5997 if (balance_xmit_policy < 0) {
5998 printf("\tFailed to get balance xmit policy for port = %d\n",
6002 printf("\tBalance Xmit Policy: ");
6004 switch (balance_xmit_policy) {
6005 case BALANCE_XMIT_POLICY_LAYER2:
6006 printf("BALANCE_XMIT_POLICY_LAYER2");
6008 case BALANCE_XMIT_POLICY_LAYER23:
6009 printf("BALANCE_XMIT_POLICY_LAYER23");
6011 case BALANCE_XMIT_POLICY_LAYER34:
6012 printf("BALANCE_XMIT_POLICY_LAYER34");
6019 if (bonding_mode == BONDING_MODE_8023AD) {
6020 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
6021 printf("\tIEEE802.3AD Aggregator Mode: ");
6024 printf("bandwidth");
6036 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
6038 if (num_slaves < 0) {
6039 printf("\tFailed to get slave list for port = %d\n", port_id);
6042 if (num_slaves > 0) {
6043 printf("\tSlaves (%d): [", num_slaves);
6044 for (i = 0; i < num_slaves - 1; i++)
6045 printf("%d ", slaves[i]);
6047 printf("%d]\n", slaves[num_slaves - 1]);
6049 printf("\tSlaves: []\n");
6053 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
6056 if (num_active_slaves < 0) {
6057 printf("\tFailed to get active slave list for port = %d\n", port_id);
6060 if (num_active_slaves > 0) {
6061 printf("\tActive Slaves (%d): [", num_active_slaves);
6062 for (i = 0; i < num_active_slaves - 1; i++)
6063 printf("%d ", slaves[i]);
6065 printf("%d]\n", slaves[num_active_slaves - 1]);
6068 printf("\tActive Slaves: []\n");
6072 primary_id = rte_eth_bond_primary_get(port_id);
6073 if (primary_id < 0) {
6074 printf("\tFailed to get primary slave for port = %d\n", port_id);
6077 printf("\tPrimary: [%d]\n", primary_id);
6081 cmdline_parse_token_string_t cmd_showbonding_config_show =
6082 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6084 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
6085 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6086 bonding, "bonding");
6087 cmdline_parse_token_string_t cmd_showbonding_config_config =
6088 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6090 cmdline_parse_token_num_t cmd_showbonding_config_port =
6091 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
6092 port_id, RTE_UINT16);
6094 cmdline_parse_inst_t cmd_show_bonding_config = {
6095 .f = cmd_show_bonding_config_parsed,
6096 .help_str = "show bonding config <port_id>: "
6097 "Show the bonding config for port_id",
6100 (void *)&cmd_showbonding_config_show,
6101 (void *)&cmd_showbonding_config_bonding,
6102 (void *)&cmd_showbonding_config_config,
6103 (void *)&cmd_showbonding_config_port,
6108 /* *** SET BONDING PRIMARY *** */
6109 struct cmd_set_bonding_primary_result {
6110 cmdline_fixed_string_t set;
6111 cmdline_fixed_string_t bonding;
6112 cmdline_fixed_string_t primary;
6117 static void cmd_set_bonding_primary_parsed(void *parsed_result,
6118 __rte_unused struct cmdline *cl,
6119 __rte_unused void *data)
6121 struct cmd_set_bonding_primary_result *res = parsed_result;
6122 portid_t master_port_id = res->port_id;
6123 portid_t slave_port_id = res->slave_id;
6125 /* Set the primary slave for a bonded device. */
6126 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
6127 printf("\t Failed to set primary slave for port = %d.\n",
6134 cmdline_parse_token_string_t cmd_setbonding_primary_set =
6135 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6137 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
6138 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6139 bonding, "bonding");
6140 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
6141 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6142 primary, "primary");
6143 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
6144 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6145 slave_id, RTE_UINT16);
6146 cmdline_parse_token_num_t cmd_setbonding_primary_port =
6147 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6148 port_id, RTE_UINT16);
6150 cmdline_parse_inst_t cmd_set_bonding_primary = {
6151 .f = cmd_set_bonding_primary_parsed,
6152 .help_str = "set bonding primary <slave_id> <port_id>: "
6153 "Set the primary slave for port_id",
6156 (void *)&cmd_setbonding_primary_set,
6157 (void *)&cmd_setbonding_primary_bonding,
6158 (void *)&cmd_setbonding_primary_primary,
6159 (void *)&cmd_setbonding_primary_slave,
6160 (void *)&cmd_setbonding_primary_port,
6165 /* *** ADD SLAVE *** */
6166 struct cmd_add_bonding_slave_result {
6167 cmdline_fixed_string_t add;
6168 cmdline_fixed_string_t bonding;
6169 cmdline_fixed_string_t slave;
6174 static void cmd_add_bonding_slave_parsed(void *parsed_result,
6175 __rte_unused struct cmdline *cl,
6176 __rte_unused void *data)
6178 struct cmd_add_bonding_slave_result *res = parsed_result;
6179 portid_t master_port_id = res->port_id;
6180 portid_t slave_port_id = res->slave_id;
6182 /* add the slave for a bonded device. */
6183 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
6184 printf("\t Failed to add slave %d to master port = %d.\n",
6185 slave_port_id, master_port_id);
6189 set_port_slave_flag(slave_port_id);
6192 cmdline_parse_token_string_t cmd_addbonding_slave_add =
6193 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6195 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
6196 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6197 bonding, "bonding");
6198 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
6199 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6201 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
6202 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6203 slave_id, RTE_UINT16);
6204 cmdline_parse_token_num_t cmd_addbonding_slave_port =
6205 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6206 port_id, RTE_UINT16);
6208 cmdline_parse_inst_t cmd_add_bonding_slave = {
6209 .f = cmd_add_bonding_slave_parsed,
6210 .help_str = "add bonding slave <slave_id> <port_id>: "
6211 "Add a slave device to a bonded device",
6214 (void *)&cmd_addbonding_slave_add,
6215 (void *)&cmd_addbonding_slave_bonding,
6216 (void *)&cmd_addbonding_slave_slave,
6217 (void *)&cmd_addbonding_slave_slaveid,
6218 (void *)&cmd_addbonding_slave_port,
6223 /* *** REMOVE SLAVE *** */
6224 struct cmd_remove_bonding_slave_result {
6225 cmdline_fixed_string_t remove;
6226 cmdline_fixed_string_t bonding;
6227 cmdline_fixed_string_t slave;
6232 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
6233 __rte_unused struct cmdline *cl,
6234 __rte_unused void *data)
6236 struct cmd_remove_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 /* remove the slave from a bonded device. */
6241 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
6242 printf("\t Failed to remove slave %d from master port = %d.\n",
6243 slave_port_id, master_port_id);
6247 clear_port_slave_flag(slave_port_id);
6250 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
6251 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6253 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
6254 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6255 bonding, "bonding");
6256 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
6257 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6259 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
6260 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6261 slave_id, RTE_UINT16);
6262 cmdline_parse_token_num_t cmd_removebonding_slave_port =
6263 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6264 port_id, RTE_UINT16);
6266 cmdline_parse_inst_t cmd_remove_bonding_slave = {
6267 .f = cmd_remove_bonding_slave_parsed,
6268 .help_str = "remove bonding slave <slave_id> <port_id>: "
6269 "Remove a slave device from a bonded device",
6272 (void *)&cmd_removebonding_slave_remove,
6273 (void *)&cmd_removebonding_slave_bonding,
6274 (void *)&cmd_removebonding_slave_slave,
6275 (void *)&cmd_removebonding_slave_slaveid,
6276 (void *)&cmd_removebonding_slave_port,
6281 /* *** CREATE BONDED DEVICE *** */
6282 struct cmd_create_bonded_device_result {
6283 cmdline_fixed_string_t create;
6284 cmdline_fixed_string_t bonded;
6285 cmdline_fixed_string_t device;
6290 static int bond_dev_num = 0;
6292 static void cmd_create_bonded_device_parsed(void *parsed_result,
6293 __rte_unused struct cmdline *cl,
6294 __rte_unused void *data)
6296 struct cmd_create_bonded_device_result *res = parsed_result;
6297 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
6301 if (test_done == 0) {
6302 printf("Please stop forwarding first\n");
6306 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
6309 /* Create a new bonded device. */
6310 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
6312 printf("\t Failed to create bonded device.\n");
6315 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
6318 /* Update number of ports */
6319 nb_ports = rte_eth_dev_count_avail();
6320 reconfig(port_id, res->socket);
6321 ret = rte_eth_promiscuous_enable(port_id);
6323 printf("Failed to enable promiscuous mode for port %u: %s - ignore\n",
6324 port_id, rte_strerror(-ret));
6326 ports[port_id].need_setup = 0;
6327 ports[port_id].port_status = RTE_PORT_STOPPED;
6332 cmdline_parse_token_string_t cmd_createbonded_device_create =
6333 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6335 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
6336 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6338 cmdline_parse_token_string_t cmd_createbonded_device_device =
6339 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6341 cmdline_parse_token_num_t cmd_createbonded_device_mode =
6342 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6344 cmdline_parse_token_num_t cmd_createbonded_device_socket =
6345 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6348 cmdline_parse_inst_t cmd_create_bonded_device = {
6349 .f = cmd_create_bonded_device_parsed,
6350 .help_str = "create bonded device <mode> <socket>: "
6351 "Create a new bonded device with specific bonding mode and socket",
6354 (void *)&cmd_createbonded_device_create,
6355 (void *)&cmd_createbonded_device_bonded,
6356 (void *)&cmd_createbonded_device_device,
6357 (void *)&cmd_createbonded_device_mode,
6358 (void *)&cmd_createbonded_device_socket,
6363 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
6364 struct cmd_set_bond_mac_addr_result {
6365 cmdline_fixed_string_t set;
6366 cmdline_fixed_string_t bonding;
6367 cmdline_fixed_string_t mac_addr;
6369 struct rte_ether_addr address;
6372 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
6373 __rte_unused struct cmdline *cl,
6374 __rte_unused void *data)
6376 struct cmd_set_bond_mac_addr_result *res = parsed_result;
6379 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
6382 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
6384 /* check the return value and print it if is < 0 */
6386 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6389 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
6390 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
6391 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
6392 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
6394 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
6395 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
6397 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
6398 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
6399 port_num, RTE_UINT16);
6400 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
6401 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
6403 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
6404 .f = cmd_set_bond_mac_addr_parsed,
6406 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
6408 (void *)&cmd_set_bond_mac_addr_set,
6409 (void *)&cmd_set_bond_mac_addr_bonding,
6410 (void *)&cmd_set_bond_mac_addr_mac,
6411 (void *)&cmd_set_bond_mac_addr_portnum,
6412 (void *)&cmd_set_bond_mac_addr_addr,
6418 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
6419 struct cmd_set_bond_mon_period_result {
6420 cmdline_fixed_string_t set;
6421 cmdline_fixed_string_t bonding;
6422 cmdline_fixed_string_t mon_period;
6427 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
6428 __rte_unused struct cmdline *cl,
6429 __rte_unused void *data)
6431 struct cmd_set_bond_mon_period_result *res = parsed_result;
6434 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
6436 /* check the return value and print it if is < 0 */
6438 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6441 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
6442 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6444 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
6445 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6446 bonding, "bonding");
6447 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
6448 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6449 mon_period, "mon_period");
6450 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
6451 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6452 port_num, RTE_UINT16);
6453 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
6454 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6455 period_ms, RTE_UINT32);
6457 cmdline_parse_inst_t cmd_set_bond_mon_period = {
6458 .f = cmd_set_bond_mon_period_parsed,
6460 .help_str = "set bonding mon_period <port_id> <period_ms>",
6462 (void *)&cmd_set_bond_mon_period_set,
6463 (void *)&cmd_set_bond_mon_period_bonding,
6464 (void *)&cmd_set_bond_mon_period_mon_period,
6465 (void *)&cmd_set_bond_mon_period_portnum,
6466 (void *)&cmd_set_bond_mon_period_period_ms,
6473 struct cmd_set_bonding_agg_mode_policy_result {
6474 cmdline_fixed_string_t set;
6475 cmdline_fixed_string_t bonding;
6476 cmdline_fixed_string_t agg_mode;
6478 cmdline_fixed_string_t policy;
6483 cmd_set_bonding_agg_mode(void *parsed_result,
6484 __rte_unused struct cmdline *cl,
6485 __rte_unused void *data)
6487 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
6488 uint8_t policy = AGG_BANDWIDTH;
6490 if (!strcmp(res->policy, "bandwidth"))
6491 policy = AGG_BANDWIDTH;
6492 else if (!strcmp(res->policy, "stable"))
6493 policy = AGG_STABLE;
6494 else if (!strcmp(res->policy, "count"))
6497 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
6501 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
6502 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6504 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
6505 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6506 bonding, "bonding");
6508 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
6509 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6510 agg_mode, "agg_mode");
6512 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
6513 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6514 port_num, RTE_UINT16);
6516 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6517 TOKEN_STRING_INITIALIZER(
6518 struct cmd_set_bonding_balance_xmit_policy_result,
6519 policy, "stable#bandwidth#count");
6521 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6522 .f = cmd_set_bonding_agg_mode,
6524 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6526 (void *)&cmd_set_bonding_agg_mode_set,
6527 (void *)&cmd_set_bonding_agg_mode_bonding,
6528 (void *)&cmd_set_bonding_agg_mode_agg_mode,
6529 (void *)&cmd_set_bonding_agg_mode_portnum,
6530 (void *)&cmd_set_bonding_agg_mode_policy_string,
6536 #endif /* RTE_NET_BOND */
6538 /* *** SET FORWARDING MODE *** */
6539 struct cmd_set_fwd_mode_result {
6540 cmdline_fixed_string_t set;
6541 cmdline_fixed_string_t fwd;
6542 cmdline_fixed_string_t mode;
6545 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6546 __rte_unused struct cmdline *cl,
6547 __rte_unused void *data)
6549 struct cmd_set_fwd_mode_result *res = parsed_result;
6552 set_pkt_forwarding_mode(res->mode);
6555 cmdline_parse_token_string_t cmd_setfwd_set =
6556 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6557 cmdline_parse_token_string_t cmd_setfwd_fwd =
6558 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6559 cmdline_parse_token_string_t cmd_setfwd_mode =
6560 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6561 "" /* defined at init */);
6563 cmdline_parse_inst_t cmd_set_fwd_mode = {
6564 .f = cmd_set_fwd_mode_parsed,
6566 .help_str = NULL, /* defined at init */
6568 (void *)&cmd_setfwd_set,
6569 (void *)&cmd_setfwd_fwd,
6570 (void *)&cmd_setfwd_mode,
6575 static void cmd_set_fwd_mode_init(void)
6578 static char token[128];
6579 static char help[256];
6580 cmdline_parse_token_string_t *token_struct;
6582 modes = list_pkt_forwarding_modes();
6583 snprintf(help, sizeof(help), "set fwd %s: "
6584 "Set packet forwarding mode", modes);
6585 cmd_set_fwd_mode.help_str = help;
6587 /* string token separator is # */
6588 for (c = token; *modes != '\0'; modes++)
6593 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6594 token_struct->string_data.str = token;
6597 /* *** SET RETRY FORWARDING MODE *** */
6598 struct cmd_set_fwd_retry_mode_result {
6599 cmdline_fixed_string_t set;
6600 cmdline_fixed_string_t fwd;
6601 cmdline_fixed_string_t mode;
6602 cmdline_fixed_string_t retry;
6605 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6606 __rte_unused struct cmdline *cl,
6607 __rte_unused void *data)
6609 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6612 set_pkt_forwarding_mode(res->mode);
6615 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6616 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6618 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6619 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6621 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6622 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6624 "" /* defined at init */);
6625 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6626 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6629 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6630 .f = cmd_set_fwd_retry_mode_parsed,
6632 .help_str = NULL, /* defined at init */
6634 (void *)&cmd_setfwd_retry_set,
6635 (void *)&cmd_setfwd_retry_fwd,
6636 (void *)&cmd_setfwd_retry_mode,
6637 (void *)&cmd_setfwd_retry_retry,
6642 static void cmd_set_fwd_retry_mode_init(void)
6645 static char token[128];
6646 static char help[256];
6647 cmdline_parse_token_string_t *token_struct;
6649 modes = list_pkt_forwarding_retry_modes();
6650 snprintf(help, sizeof(help), "set fwd %s retry: "
6651 "Set packet forwarding mode with retry", modes);
6652 cmd_set_fwd_retry_mode.help_str = help;
6654 /* string token separator is # */
6655 for (c = token; *modes != '\0'; modes++)
6660 token_struct = (cmdline_parse_token_string_t *)
6661 cmd_set_fwd_retry_mode.tokens[2];
6662 token_struct->string_data.str = token;
6665 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6666 struct cmd_set_burst_tx_retry_result {
6667 cmdline_fixed_string_t set;
6668 cmdline_fixed_string_t burst;
6669 cmdline_fixed_string_t tx;
6670 cmdline_fixed_string_t delay;
6672 cmdline_fixed_string_t retry;
6676 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6677 __rte_unused struct cmdline *cl,
6678 __rte_unused void *data)
6680 struct cmd_set_burst_tx_retry_result *res = parsed_result;
6682 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6683 && !strcmp(res->tx, "tx")) {
6684 if (!strcmp(res->delay, "delay"))
6685 burst_tx_delay_time = res->time;
6686 if (!strcmp(res->retry, "retry"))
6687 burst_tx_retry_num = res->retry_num;
6692 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6693 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6694 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6695 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6697 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6698 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6699 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6700 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6701 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6702 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time,
6704 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6705 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6706 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6707 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num,
6710 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6711 .f = cmd_set_burst_tx_retry_parsed,
6712 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6714 (void *)&cmd_set_burst_tx_retry_set,
6715 (void *)&cmd_set_burst_tx_retry_burst,
6716 (void *)&cmd_set_burst_tx_retry_tx,
6717 (void *)&cmd_set_burst_tx_retry_delay,
6718 (void *)&cmd_set_burst_tx_retry_time,
6719 (void *)&cmd_set_burst_tx_retry_retry,
6720 (void *)&cmd_set_burst_tx_retry_retry_num,
6725 /* *** SET PROMISC MODE *** */
6726 struct cmd_set_promisc_mode_result {
6727 cmdline_fixed_string_t set;
6728 cmdline_fixed_string_t promisc;
6729 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6730 uint16_t port_num; /* valid if "allports" argument == 0 */
6731 cmdline_fixed_string_t mode;
6734 static void cmd_set_promisc_mode_parsed(void *parsed_result,
6735 __rte_unused struct cmdline *cl,
6738 struct cmd_set_promisc_mode_result *res = parsed_result;
6742 if (!strcmp(res->mode, "on"))
6749 RTE_ETH_FOREACH_DEV(i)
6750 eth_set_promisc_mode(i, enable);
6752 eth_set_promisc_mode(res->port_num, enable);
6756 cmdline_parse_token_string_t cmd_setpromisc_set =
6757 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6758 cmdline_parse_token_string_t cmd_setpromisc_promisc =
6759 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6761 cmdline_parse_token_string_t cmd_setpromisc_portall =
6762 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6764 cmdline_parse_token_num_t cmd_setpromisc_portnum =
6765 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6767 cmdline_parse_token_string_t cmd_setpromisc_mode =
6768 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6771 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6772 .f = cmd_set_promisc_mode_parsed,
6774 .help_str = "set promisc all on|off: Set promisc mode for all ports",
6776 (void *)&cmd_setpromisc_set,
6777 (void *)&cmd_setpromisc_promisc,
6778 (void *)&cmd_setpromisc_portall,
6779 (void *)&cmd_setpromisc_mode,
6784 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6785 .f = cmd_set_promisc_mode_parsed,
6787 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6789 (void *)&cmd_setpromisc_set,
6790 (void *)&cmd_setpromisc_promisc,
6791 (void *)&cmd_setpromisc_portnum,
6792 (void *)&cmd_setpromisc_mode,
6797 /* *** SET ALLMULTI MODE *** */
6798 struct cmd_set_allmulti_mode_result {
6799 cmdline_fixed_string_t set;
6800 cmdline_fixed_string_t allmulti;
6801 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6802 uint16_t port_num; /* valid if "allports" argument == 0 */
6803 cmdline_fixed_string_t mode;
6806 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6807 __rte_unused struct cmdline *cl,
6810 struct cmd_set_allmulti_mode_result *res = parsed_result;
6814 if (!strcmp(res->mode, "on"))
6821 RTE_ETH_FOREACH_DEV(i) {
6822 eth_set_allmulticast_mode(i, enable);
6826 eth_set_allmulticast_mode(res->port_num, enable);
6830 cmdline_parse_token_string_t cmd_setallmulti_set =
6831 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6832 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6833 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6835 cmdline_parse_token_string_t cmd_setallmulti_portall =
6836 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6838 cmdline_parse_token_num_t cmd_setallmulti_portnum =
6839 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6841 cmdline_parse_token_string_t cmd_setallmulti_mode =
6842 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6845 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6846 .f = cmd_set_allmulti_mode_parsed,
6848 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6850 (void *)&cmd_setallmulti_set,
6851 (void *)&cmd_setallmulti_allmulti,
6852 (void *)&cmd_setallmulti_portall,
6853 (void *)&cmd_setallmulti_mode,
6858 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6859 .f = cmd_set_allmulti_mode_parsed,
6861 .help_str = "set allmulti <port_id> on|off: "
6862 "Set allmulti mode on port_id",
6864 (void *)&cmd_setallmulti_set,
6865 (void *)&cmd_setallmulti_allmulti,
6866 (void *)&cmd_setallmulti_portnum,
6867 (void *)&cmd_setallmulti_mode,
6872 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
6873 struct cmd_link_flow_ctrl_set_result {
6874 cmdline_fixed_string_t set;
6875 cmdline_fixed_string_t flow_ctrl;
6876 cmdline_fixed_string_t rx;
6877 cmdline_fixed_string_t rx_lfc_mode;
6878 cmdline_fixed_string_t tx;
6879 cmdline_fixed_string_t tx_lfc_mode;
6880 cmdline_fixed_string_t mac_ctrl_frame_fwd;
6881 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
6882 cmdline_fixed_string_t autoneg_str;
6883 cmdline_fixed_string_t autoneg;
6884 cmdline_fixed_string_t hw_str;
6885 uint32_t high_water;
6886 cmdline_fixed_string_t lw_str;
6888 cmdline_fixed_string_t pt_str;
6889 uint16_t pause_time;
6890 cmdline_fixed_string_t xon_str;
6895 cmdline_parse_token_string_t cmd_lfc_set_set =
6896 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6898 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
6899 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6900 flow_ctrl, "flow_ctrl");
6901 cmdline_parse_token_string_t cmd_lfc_set_rx =
6902 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6904 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
6905 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6906 rx_lfc_mode, "on#off");
6907 cmdline_parse_token_string_t cmd_lfc_set_tx =
6908 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6910 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
6911 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6912 tx_lfc_mode, "on#off");
6913 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
6914 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6915 hw_str, "high_water");
6916 cmdline_parse_token_num_t cmd_lfc_set_high_water =
6917 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6918 high_water, RTE_UINT32);
6919 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
6920 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6921 lw_str, "low_water");
6922 cmdline_parse_token_num_t cmd_lfc_set_low_water =
6923 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6924 low_water, RTE_UINT32);
6925 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
6926 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6927 pt_str, "pause_time");
6928 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
6929 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6930 pause_time, RTE_UINT16);
6931 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
6932 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6933 xon_str, "send_xon");
6934 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
6935 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6936 send_xon, RTE_UINT16);
6937 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
6938 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6939 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
6940 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6941 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6942 mac_ctrl_frame_fwd_mode, "on#off");
6943 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6944 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6945 autoneg_str, "autoneg");
6946 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6947 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6949 cmdline_parse_token_num_t cmd_lfc_set_portid =
6950 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6951 port_id, RTE_UINT16);
6953 /* forward declaration */
6955 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6958 cmdline_parse_inst_t cmd_link_flow_control_set = {
6959 .f = cmd_link_flow_ctrl_set_parsed,
6961 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6962 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6963 "autoneg on|off <port_id>: Configure the Ethernet flow control",
6965 (void *)&cmd_lfc_set_set,
6966 (void *)&cmd_lfc_set_flow_ctrl,
6967 (void *)&cmd_lfc_set_rx,
6968 (void *)&cmd_lfc_set_rx_mode,
6969 (void *)&cmd_lfc_set_tx,
6970 (void *)&cmd_lfc_set_tx_mode,
6971 (void *)&cmd_lfc_set_high_water,
6972 (void *)&cmd_lfc_set_low_water,
6973 (void *)&cmd_lfc_set_pause_time,
6974 (void *)&cmd_lfc_set_send_xon,
6975 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6976 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6977 (void *)&cmd_lfc_set_autoneg_str,
6978 (void *)&cmd_lfc_set_autoneg,
6979 (void *)&cmd_lfc_set_portid,
6984 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6985 .f = cmd_link_flow_ctrl_set_parsed,
6986 .data = (void *)&cmd_link_flow_control_set_rx,
6987 .help_str = "set flow_ctrl rx on|off <port_id>: "
6988 "Change rx flow control parameter",
6990 (void *)&cmd_lfc_set_set,
6991 (void *)&cmd_lfc_set_flow_ctrl,
6992 (void *)&cmd_lfc_set_rx,
6993 (void *)&cmd_lfc_set_rx_mode,
6994 (void *)&cmd_lfc_set_portid,
6999 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
7000 .f = cmd_link_flow_ctrl_set_parsed,
7001 .data = (void *)&cmd_link_flow_control_set_tx,
7002 .help_str = "set flow_ctrl tx on|off <port_id>: "
7003 "Change tx flow control parameter",
7005 (void *)&cmd_lfc_set_set,
7006 (void *)&cmd_lfc_set_flow_ctrl,
7007 (void *)&cmd_lfc_set_tx,
7008 (void *)&cmd_lfc_set_tx_mode,
7009 (void *)&cmd_lfc_set_portid,
7014 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
7015 .f = cmd_link_flow_ctrl_set_parsed,
7016 .data = (void *)&cmd_link_flow_control_set_hw,
7017 .help_str = "set flow_ctrl high_water <value> <port_id>: "
7018 "Change high water flow control parameter",
7020 (void *)&cmd_lfc_set_set,
7021 (void *)&cmd_lfc_set_flow_ctrl,
7022 (void *)&cmd_lfc_set_high_water_str,
7023 (void *)&cmd_lfc_set_high_water,
7024 (void *)&cmd_lfc_set_portid,
7029 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
7030 .f = cmd_link_flow_ctrl_set_parsed,
7031 .data = (void *)&cmd_link_flow_control_set_lw,
7032 .help_str = "set flow_ctrl low_water <value> <port_id>: "
7033 "Change low water flow control parameter",
7035 (void *)&cmd_lfc_set_set,
7036 (void *)&cmd_lfc_set_flow_ctrl,
7037 (void *)&cmd_lfc_set_low_water_str,
7038 (void *)&cmd_lfc_set_low_water,
7039 (void *)&cmd_lfc_set_portid,
7044 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
7045 .f = cmd_link_flow_ctrl_set_parsed,
7046 .data = (void *)&cmd_link_flow_control_set_pt,
7047 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
7048 "Change pause time flow control parameter",
7050 (void *)&cmd_lfc_set_set,
7051 (void *)&cmd_lfc_set_flow_ctrl,
7052 (void *)&cmd_lfc_set_pause_time_str,
7053 (void *)&cmd_lfc_set_pause_time,
7054 (void *)&cmd_lfc_set_portid,
7059 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
7060 .f = cmd_link_flow_ctrl_set_parsed,
7061 .data = (void *)&cmd_link_flow_control_set_xon,
7062 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
7063 "Change send_xon flow control parameter",
7065 (void *)&cmd_lfc_set_set,
7066 (void *)&cmd_lfc_set_flow_ctrl,
7067 (void *)&cmd_lfc_set_send_xon_str,
7068 (void *)&cmd_lfc_set_send_xon,
7069 (void *)&cmd_lfc_set_portid,
7074 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
7075 .f = cmd_link_flow_ctrl_set_parsed,
7076 .data = (void *)&cmd_link_flow_control_set_macfwd,
7077 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
7078 "Change mac ctrl fwd flow control parameter",
7080 (void *)&cmd_lfc_set_set,
7081 (void *)&cmd_lfc_set_flow_ctrl,
7082 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
7083 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
7084 (void *)&cmd_lfc_set_portid,
7089 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
7090 .f = cmd_link_flow_ctrl_set_parsed,
7091 .data = (void *)&cmd_link_flow_control_set_autoneg,
7092 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
7093 "Change autoneg flow control parameter",
7095 (void *)&cmd_lfc_set_set,
7096 (void *)&cmd_lfc_set_flow_ctrl,
7097 (void *)&cmd_lfc_set_autoneg_str,
7098 (void *)&cmd_lfc_set_autoneg,
7099 (void *)&cmd_lfc_set_portid,
7105 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
7106 __rte_unused struct cmdline *cl,
7109 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
7110 cmdline_parse_inst_t *cmd = data;
7111 struct rte_eth_fc_conf fc_conf;
7117 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7118 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7119 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7120 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7122 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
7123 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7126 /* Partial command line, retrieve current configuration */
7128 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
7130 printf("cannot get current flow ctrl parameters, return"
7131 "code = %d\n", ret);
7135 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
7136 (fc_conf.mode == RTE_FC_FULL))
7138 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
7139 (fc_conf.mode == RTE_FC_FULL))
7143 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
7144 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
7146 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
7147 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
7149 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
7151 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
7152 fc_conf.high_water = res->high_water;
7154 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
7155 fc_conf.low_water = res->low_water;
7157 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
7158 fc_conf.pause_time = res->pause_time;
7160 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
7161 fc_conf.send_xon = res->send_xon;
7163 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
7164 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
7165 fc_conf.mac_ctrl_frame_fwd = 1;
7167 fc_conf.mac_ctrl_frame_fwd = 0;
7170 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
7171 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
7173 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
7175 printf("bad flow contrl parameter, return code = %d \n", ret);
7178 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
7179 struct cmd_priority_flow_ctrl_set_result {
7180 cmdline_fixed_string_t set;
7181 cmdline_fixed_string_t pfc_ctrl;
7182 cmdline_fixed_string_t rx;
7183 cmdline_fixed_string_t rx_pfc_mode;
7184 cmdline_fixed_string_t tx;
7185 cmdline_fixed_string_t tx_pfc_mode;
7186 uint32_t high_water;
7188 uint16_t pause_time;
7194 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
7195 __rte_unused struct cmdline *cl,
7196 __rte_unused void *data)
7198 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
7199 struct rte_eth_pfc_conf pfc_conf;
7200 int rx_fc_enable, tx_fc_enable;
7204 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7205 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7206 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7207 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7209 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
7210 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7213 memset(&pfc_conf, 0, sizeof(struct rte_eth_pfc_conf));
7214 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
7215 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
7216 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
7217 pfc_conf.fc.high_water = res->high_water;
7218 pfc_conf.fc.low_water = res->low_water;
7219 pfc_conf.fc.pause_time = res->pause_time;
7220 pfc_conf.priority = res->priority;
7222 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
7224 printf("bad priority flow contrl parameter, return code = %d \n", ret);
7227 cmdline_parse_token_string_t cmd_pfc_set_set =
7228 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7230 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
7231 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7232 pfc_ctrl, "pfc_ctrl");
7233 cmdline_parse_token_string_t cmd_pfc_set_rx =
7234 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7236 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
7237 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7238 rx_pfc_mode, "on#off");
7239 cmdline_parse_token_string_t cmd_pfc_set_tx =
7240 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7242 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
7243 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7244 tx_pfc_mode, "on#off");
7245 cmdline_parse_token_num_t cmd_pfc_set_high_water =
7246 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7247 high_water, RTE_UINT32);
7248 cmdline_parse_token_num_t cmd_pfc_set_low_water =
7249 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7250 low_water, RTE_UINT32);
7251 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
7252 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7253 pause_time, RTE_UINT16);
7254 cmdline_parse_token_num_t cmd_pfc_set_priority =
7255 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7256 priority, RTE_UINT8);
7257 cmdline_parse_token_num_t cmd_pfc_set_portid =
7258 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7259 port_id, RTE_UINT16);
7261 cmdline_parse_inst_t cmd_priority_flow_control_set = {
7262 .f = cmd_priority_flow_ctrl_set_parsed,
7264 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
7265 "<pause_time> <priority> <port_id>: "
7266 "Configure the Ethernet priority flow control",
7268 (void *)&cmd_pfc_set_set,
7269 (void *)&cmd_pfc_set_flow_ctrl,
7270 (void *)&cmd_pfc_set_rx,
7271 (void *)&cmd_pfc_set_rx_mode,
7272 (void *)&cmd_pfc_set_tx,
7273 (void *)&cmd_pfc_set_tx_mode,
7274 (void *)&cmd_pfc_set_high_water,
7275 (void *)&cmd_pfc_set_low_water,
7276 (void *)&cmd_pfc_set_pause_time,
7277 (void *)&cmd_pfc_set_priority,
7278 (void *)&cmd_pfc_set_portid,
7283 /* *** RESET CONFIGURATION *** */
7284 struct cmd_reset_result {
7285 cmdline_fixed_string_t reset;
7286 cmdline_fixed_string_t def;
7289 static void cmd_reset_parsed(__rte_unused void *parsed_result,
7291 __rte_unused void *data)
7293 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
7294 set_def_fwd_config();
7297 cmdline_parse_token_string_t cmd_reset_set =
7298 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
7299 cmdline_parse_token_string_t cmd_reset_def =
7300 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
7303 cmdline_parse_inst_t cmd_reset = {
7304 .f = cmd_reset_parsed,
7306 .help_str = "set default: Reset default forwarding configuration",
7308 (void *)&cmd_reset_set,
7309 (void *)&cmd_reset_def,
7314 /* *** START FORWARDING *** */
7315 struct cmd_start_result {
7316 cmdline_fixed_string_t start;
7319 cmdline_parse_token_string_t cmd_start_start =
7320 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
7322 static void cmd_start_parsed(__rte_unused void *parsed_result,
7323 __rte_unused struct cmdline *cl,
7324 __rte_unused void *data)
7326 start_packet_forwarding(0);
7329 cmdline_parse_inst_t cmd_start = {
7330 .f = cmd_start_parsed,
7332 .help_str = "start: Start packet forwarding",
7334 (void *)&cmd_start_start,
7339 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7340 struct cmd_start_tx_first_result {
7341 cmdline_fixed_string_t start;
7342 cmdline_fixed_string_t tx_first;
7346 cmd_start_tx_first_parsed(__rte_unused void *parsed_result,
7347 __rte_unused struct cmdline *cl,
7348 __rte_unused void *data)
7350 start_packet_forwarding(1);
7353 cmdline_parse_token_string_t cmd_start_tx_first_start =
7354 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7356 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7357 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7358 tx_first, "tx_first");
7360 cmdline_parse_inst_t cmd_start_tx_first = {
7361 .f = cmd_start_tx_first_parsed,
7363 .help_str = "start tx_first: Start packet forwarding, "
7364 "after sending 1 burst of packets",
7366 (void *)&cmd_start_tx_first_start,
7367 (void *)&cmd_start_tx_first_tx_first,
7372 /* *** START FORWARDING WITH N TX BURST FIRST *** */
7373 struct cmd_start_tx_first_n_result {
7374 cmdline_fixed_string_t start;
7375 cmdline_fixed_string_t tx_first;
7380 cmd_start_tx_first_n_parsed(void *parsed_result,
7381 __rte_unused struct cmdline *cl,
7382 __rte_unused void *data)
7384 struct cmd_start_tx_first_n_result *res = parsed_result;
7386 start_packet_forwarding(res->tx_num);
7389 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7390 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7392 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7393 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7394 tx_first, "tx_first");
7395 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7396 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7397 tx_num, RTE_UINT32);
7399 cmdline_parse_inst_t cmd_start_tx_first_n = {
7400 .f = cmd_start_tx_first_n_parsed,
7402 .help_str = "start tx_first <num>: "
7403 "packet forwarding, after sending <num> bursts of packets",
7405 (void *)&cmd_start_tx_first_n_start,
7406 (void *)&cmd_start_tx_first_n_tx_first,
7407 (void *)&cmd_start_tx_first_n_tx_num,
7412 /* *** SET LINK UP *** */
7413 struct cmd_set_link_up_result {
7414 cmdline_fixed_string_t set;
7415 cmdline_fixed_string_t link_up;
7416 cmdline_fixed_string_t port;
7420 cmdline_parse_token_string_t cmd_set_link_up_set =
7421 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7422 cmdline_parse_token_string_t cmd_set_link_up_link_up =
7423 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7425 cmdline_parse_token_string_t cmd_set_link_up_port =
7426 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7427 cmdline_parse_token_num_t cmd_set_link_up_port_id =
7428 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id,
7431 static void cmd_set_link_up_parsed(__rte_unused void *parsed_result,
7432 __rte_unused struct cmdline *cl,
7433 __rte_unused void *data)
7435 struct cmd_set_link_up_result *res = parsed_result;
7436 dev_set_link_up(res->port_id);
7439 cmdline_parse_inst_t cmd_set_link_up = {
7440 .f = cmd_set_link_up_parsed,
7442 .help_str = "set link-up port <port id>",
7444 (void *)&cmd_set_link_up_set,
7445 (void *)&cmd_set_link_up_link_up,
7446 (void *)&cmd_set_link_up_port,
7447 (void *)&cmd_set_link_up_port_id,
7452 /* *** SET LINK DOWN *** */
7453 struct cmd_set_link_down_result {
7454 cmdline_fixed_string_t set;
7455 cmdline_fixed_string_t link_down;
7456 cmdline_fixed_string_t port;
7460 cmdline_parse_token_string_t cmd_set_link_down_set =
7461 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
7462 cmdline_parse_token_string_t cmd_set_link_down_link_down =
7463 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
7465 cmdline_parse_token_string_t cmd_set_link_down_port =
7466 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
7467 cmdline_parse_token_num_t cmd_set_link_down_port_id =
7468 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id,
7471 static void cmd_set_link_down_parsed(
7472 __rte_unused void *parsed_result,
7473 __rte_unused struct cmdline *cl,
7474 __rte_unused void *data)
7476 struct cmd_set_link_down_result *res = parsed_result;
7477 dev_set_link_down(res->port_id);
7480 cmdline_parse_inst_t cmd_set_link_down = {
7481 .f = cmd_set_link_down_parsed,
7483 .help_str = "set link-down port <port id>",
7485 (void *)&cmd_set_link_down_set,
7486 (void *)&cmd_set_link_down_link_down,
7487 (void *)&cmd_set_link_down_port,
7488 (void *)&cmd_set_link_down_port_id,
7493 /* *** SHOW CFG *** */
7494 struct cmd_showcfg_result {
7495 cmdline_fixed_string_t show;
7496 cmdline_fixed_string_t cfg;
7497 cmdline_fixed_string_t what;
7500 static void cmd_showcfg_parsed(void *parsed_result,
7501 __rte_unused struct cmdline *cl,
7502 __rte_unused void *data)
7504 struct cmd_showcfg_result *res = parsed_result;
7505 if (!strcmp(res->what, "rxtx"))
7506 rxtx_config_display();
7507 else if (!strcmp(res->what, "cores"))
7508 fwd_lcores_config_display();
7509 else if (!strcmp(res->what, "fwd"))
7510 pkt_fwd_config_display(&cur_fwd_config);
7511 else if (!strcmp(res->what, "rxoffs"))
7512 show_rx_pkt_offsets();
7513 else if (!strcmp(res->what, "rxpkts"))
7514 show_rx_pkt_segments();
7515 else if (!strcmp(res->what, "txpkts"))
7516 show_tx_pkt_segments();
7517 else if (!strcmp(res->what, "txtimes"))
7518 show_tx_pkt_times();
7521 cmdline_parse_token_string_t cmd_showcfg_show =
7522 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7523 cmdline_parse_token_string_t cmd_showcfg_port =
7524 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7525 cmdline_parse_token_string_t cmd_showcfg_what =
7526 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7527 "rxtx#cores#fwd#rxoffs#rxpkts#txpkts#txtimes");
7529 cmdline_parse_inst_t cmd_showcfg = {
7530 .f = cmd_showcfg_parsed,
7532 .help_str = "show config rxtx|cores|fwd|rxoffs|rxpkts|txpkts|txtimes",
7534 (void *)&cmd_showcfg_show,
7535 (void *)&cmd_showcfg_port,
7536 (void *)&cmd_showcfg_what,
7541 /* *** SHOW ALL PORT INFO *** */
7542 struct cmd_showportall_result {
7543 cmdline_fixed_string_t show;
7544 cmdline_fixed_string_t port;
7545 cmdline_fixed_string_t what;
7546 cmdline_fixed_string_t all;
7549 static void cmd_showportall_parsed(void *parsed_result,
7550 __rte_unused struct cmdline *cl,
7551 __rte_unused void *data)
7555 struct cmd_showportall_result *res = parsed_result;
7556 if (!strcmp(res->show, "clear")) {
7557 if (!strcmp(res->what, "stats"))
7558 RTE_ETH_FOREACH_DEV(i)
7560 else if (!strcmp(res->what, "xstats"))
7561 RTE_ETH_FOREACH_DEV(i)
7562 nic_xstats_clear(i);
7563 } else if (!strcmp(res->what, "info"))
7564 RTE_ETH_FOREACH_DEV(i)
7565 port_infos_display(i);
7566 else if (!strcmp(res->what, "summary")) {
7567 port_summary_header_display();
7568 RTE_ETH_FOREACH_DEV(i)
7569 port_summary_display(i);
7571 else if (!strcmp(res->what, "stats"))
7572 RTE_ETH_FOREACH_DEV(i)
7573 nic_stats_display(i);
7574 else if (!strcmp(res->what, "xstats"))
7575 RTE_ETH_FOREACH_DEV(i)
7576 nic_xstats_display(i);
7577 #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
7578 else if (!strcmp(res->what, "fdir"))
7579 RTE_ETH_FOREACH_DEV(i)
7582 else if (!strcmp(res->what, "dcb_tc"))
7583 RTE_ETH_FOREACH_DEV(i)
7584 port_dcb_info_display(i);
7587 cmdline_parse_token_string_t cmd_showportall_show =
7588 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7590 cmdline_parse_token_string_t cmd_showportall_port =
7591 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7592 cmdline_parse_token_string_t cmd_showportall_what =
7593 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7594 "info#summary#stats#xstats#fdir#dcb_tc");
7595 cmdline_parse_token_string_t cmd_showportall_all =
7596 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7597 cmdline_parse_inst_t cmd_showportall = {
7598 .f = cmd_showportall_parsed,
7600 .help_str = "show|clear port "
7601 "info|summary|stats|xstats|fdir|dcb_tc all",
7603 (void *)&cmd_showportall_show,
7604 (void *)&cmd_showportall_port,
7605 (void *)&cmd_showportall_what,
7606 (void *)&cmd_showportall_all,
7611 /* *** SHOW PORT INFO *** */
7612 struct cmd_showport_result {
7613 cmdline_fixed_string_t show;
7614 cmdline_fixed_string_t port;
7615 cmdline_fixed_string_t what;
7619 static void cmd_showport_parsed(void *parsed_result,
7620 __rte_unused struct cmdline *cl,
7621 __rte_unused void *data)
7623 struct cmd_showport_result *res = parsed_result;
7624 if (!strcmp(res->show, "clear")) {
7625 if (!strcmp(res->what, "stats"))
7626 nic_stats_clear(res->portnum);
7627 else if (!strcmp(res->what, "xstats"))
7628 nic_xstats_clear(res->portnum);
7629 } else if (!strcmp(res->what, "info"))
7630 port_infos_display(res->portnum);
7631 else if (!strcmp(res->what, "summary")) {
7632 port_summary_header_display();
7633 port_summary_display(res->portnum);
7635 else if (!strcmp(res->what, "stats"))
7636 nic_stats_display(res->portnum);
7637 else if (!strcmp(res->what, "xstats"))
7638 nic_xstats_display(res->portnum);
7639 #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
7640 else if (!strcmp(res->what, "fdir"))
7641 fdir_get_infos(res->portnum);
7643 else if (!strcmp(res->what, "dcb_tc"))
7644 port_dcb_info_display(res->portnum);
7647 cmdline_parse_token_string_t cmd_showport_show =
7648 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7650 cmdline_parse_token_string_t cmd_showport_port =
7651 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7652 cmdline_parse_token_string_t cmd_showport_what =
7653 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7654 "info#summary#stats#xstats#fdir#dcb_tc");
7655 cmdline_parse_token_num_t cmd_showport_portnum =
7656 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, RTE_UINT16);
7658 cmdline_parse_inst_t cmd_showport = {
7659 .f = cmd_showport_parsed,
7661 .help_str = "show|clear port "
7662 "info|summary|stats|xstats|fdir|dcb_tc "
7665 (void *)&cmd_showport_show,
7666 (void *)&cmd_showport_port,
7667 (void *)&cmd_showport_what,
7668 (void *)&cmd_showport_portnum,
7673 /* *** SHOW DEVICE INFO *** */
7674 struct cmd_showdevice_result {
7675 cmdline_fixed_string_t show;
7676 cmdline_fixed_string_t device;
7677 cmdline_fixed_string_t what;
7678 cmdline_fixed_string_t identifier;
7681 static void cmd_showdevice_parsed(void *parsed_result,
7682 __rte_unused struct cmdline *cl,
7683 __rte_unused void *data)
7685 struct cmd_showdevice_result *res = parsed_result;
7686 if (!strcmp(res->what, "info")) {
7687 if (!strcmp(res->identifier, "all"))
7688 device_infos_display(NULL);
7690 device_infos_display(res->identifier);
7694 cmdline_parse_token_string_t cmd_showdevice_show =
7695 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show,
7697 cmdline_parse_token_string_t cmd_showdevice_device =
7698 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device");
7699 cmdline_parse_token_string_t cmd_showdevice_what =
7700 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what,
7702 cmdline_parse_token_string_t cmd_showdevice_identifier =
7703 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result,
7706 cmdline_parse_inst_t cmd_showdevice = {
7707 .f = cmd_showdevice_parsed,
7709 .help_str = "show device info <identifier>|all",
7711 (void *)&cmd_showdevice_show,
7712 (void *)&cmd_showdevice_device,
7713 (void *)&cmd_showdevice_what,
7714 (void *)&cmd_showdevice_identifier,
7719 /* *** SHOW MODULE EEPROM/EEPROM port INFO *** */
7720 struct cmd_showeeprom_result {
7721 cmdline_fixed_string_t show;
7722 cmdline_fixed_string_t port;
7724 cmdline_fixed_string_t type;
7727 static void cmd_showeeprom_parsed(void *parsed_result,
7728 __rte_unused struct cmdline *cl,
7729 __rte_unused void *data)
7731 struct cmd_showeeprom_result *res = parsed_result;
7733 if (!strcmp(res->type, "eeprom"))
7734 port_eeprom_display(res->portnum);
7735 else if (!strcmp(res->type, "module_eeprom"))
7736 port_module_eeprom_display(res->portnum);
7738 printf("Unknown argument\n");
7741 cmdline_parse_token_string_t cmd_showeeprom_show =
7742 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, show, "show");
7743 cmdline_parse_token_string_t cmd_showeeprom_port =
7744 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, port, "port");
7745 cmdline_parse_token_num_t cmd_showeeprom_portnum =
7746 TOKEN_NUM_INITIALIZER(struct cmd_showeeprom_result, portnum,
7748 cmdline_parse_token_string_t cmd_showeeprom_type =
7749 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, type, "module_eeprom#eeprom");
7751 cmdline_parse_inst_t cmd_showeeprom = {
7752 .f = cmd_showeeprom_parsed,
7754 .help_str = "show port <port_id> module_eeprom|eeprom",
7756 (void *)&cmd_showeeprom_show,
7757 (void *)&cmd_showeeprom_port,
7758 (void *)&cmd_showeeprom_portnum,
7759 (void *)&cmd_showeeprom_type,
7764 /* *** SHOW QUEUE INFO *** */
7765 struct cmd_showqueue_result {
7766 cmdline_fixed_string_t show;
7767 cmdline_fixed_string_t type;
7768 cmdline_fixed_string_t what;
7774 cmd_showqueue_parsed(void *parsed_result,
7775 __rte_unused struct cmdline *cl,
7776 __rte_unused void *data)
7778 struct cmd_showqueue_result *res = parsed_result;
7780 if (!strcmp(res->type, "rxq"))
7781 rx_queue_infos_display(res->portnum, res->queuenum);
7782 else if (!strcmp(res->type, "txq"))
7783 tx_queue_infos_display(res->portnum, res->queuenum);
7786 cmdline_parse_token_string_t cmd_showqueue_show =
7787 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
7788 cmdline_parse_token_string_t cmd_showqueue_type =
7789 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
7790 cmdline_parse_token_string_t cmd_showqueue_what =
7791 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
7792 cmdline_parse_token_num_t cmd_showqueue_portnum =
7793 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum,
7795 cmdline_parse_token_num_t cmd_showqueue_queuenum =
7796 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum,
7799 cmdline_parse_inst_t cmd_showqueue = {
7800 .f = cmd_showqueue_parsed,
7802 .help_str = "show rxq|txq info <port_id> <queue_id>",
7804 (void *)&cmd_showqueue_show,
7805 (void *)&cmd_showqueue_type,
7806 (void *)&cmd_showqueue_what,
7807 (void *)&cmd_showqueue_portnum,
7808 (void *)&cmd_showqueue_queuenum,
7813 /* show/clear fwd engine statistics */
7815 cmdline_fixed_string_t action;
7816 cmdline_fixed_string_t fwd;
7817 cmdline_fixed_string_t stats;
7818 cmdline_fixed_string_t all;
7821 cmdline_parse_token_string_t cmd_fwd_action =
7822 TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
7823 cmdline_parse_token_string_t cmd_fwd_fwd =
7824 TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
7825 cmdline_parse_token_string_t cmd_fwd_stats =
7826 TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
7827 cmdline_parse_token_string_t cmd_fwd_all =
7828 TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
7831 cmd_showfwdall_parsed(void *parsed_result,
7832 __rte_unused struct cmdline *cl,
7833 __rte_unused void *data)
7835 struct fwd_result *res = parsed_result;
7837 if (!strcmp(res->action, "show"))
7838 fwd_stats_display();
7843 static cmdline_parse_inst_t cmd_showfwdall = {
7844 .f = cmd_showfwdall_parsed,
7846 .help_str = "show|clear fwd stats all",
7848 (void *)&cmd_fwd_action,
7849 (void *)&cmd_fwd_fwd,
7850 (void *)&cmd_fwd_stats,
7851 (void *)&cmd_fwd_all,
7856 /* *** READ PORT REGISTER *** */
7857 struct cmd_read_reg_result {
7858 cmdline_fixed_string_t read;
7859 cmdline_fixed_string_t reg;
7865 cmd_read_reg_parsed(void *parsed_result,
7866 __rte_unused struct cmdline *cl,
7867 __rte_unused void *data)
7869 struct cmd_read_reg_result *res = parsed_result;
7870 port_reg_display(res->port_id, res->reg_off);
7873 cmdline_parse_token_string_t cmd_read_reg_read =
7874 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
7875 cmdline_parse_token_string_t cmd_read_reg_reg =
7876 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
7877 cmdline_parse_token_num_t cmd_read_reg_port_id =
7878 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, RTE_UINT16);
7879 cmdline_parse_token_num_t cmd_read_reg_reg_off =
7880 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, RTE_UINT32);
7882 cmdline_parse_inst_t cmd_read_reg = {
7883 .f = cmd_read_reg_parsed,
7885 .help_str = "read reg <port_id> <reg_off>",
7887 (void *)&cmd_read_reg_read,
7888 (void *)&cmd_read_reg_reg,
7889 (void *)&cmd_read_reg_port_id,
7890 (void *)&cmd_read_reg_reg_off,
7895 /* *** READ PORT REGISTER BIT FIELD *** */
7896 struct cmd_read_reg_bit_field_result {
7897 cmdline_fixed_string_t read;
7898 cmdline_fixed_string_t regfield;
7906 cmd_read_reg_bit_field_parsed(void *parsed_result,
7907 __rte_unused struct cmdline *cl,
7908 __rte_unused void *data)
7910 struct cmd_read_reg_bit_field_result *res = parsed_result;
7911 port_reg_bit_field_display(res->port_id, res->reg_off,
7912 res->bit1_pos, res->bit2_pos);
7915 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
7916 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
7918 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
7919 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
7920 regfield, "regfield");
7921 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
7922 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
7924 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
7925 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
7927 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
7928 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
7930 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
7931 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
7934 cmdline_parse_inst_t cmd_read_reg_bit_field = {
7935 .f = cmd_read_reg_bit_field_parsed,
7937 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
7938 "Read register bit field between bit_x and bit_y included",
7940 (void *)&cmd_read_reg_bit_field_read,
7941 (void *)&cmd_read_reg_bit_field_regfield,
7942 (void *)&cmd_read_reg_bit_field_port_id,
7943 (void *)&cmd_read_reg_bit_field_reg_off,
7944 (void *)&cmd_read_reg_bit_field_bit1_pos,
7945 (void *)&cmd_read_reg_bit_field_bit2_pos,
7950 /* *** READ PORT REGISTER BIT *** */
7951 struct cmd_read_reg_bit_result {
7952 cmdline_fixed_string_t read;
7953 cmdline_fixed_string_t regbit;
7960 cmd_read_reg_bit_parsed(void *parsed_result,
7961 __rte_unused struct cmdline *cl,
7962 __rte_unused void *data)
7964 struct cmd_read_reg_bit_result *res = parsed_result;
7965 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
7968 cmdline_parse_token_string_t cmd_read_reg_bit_read =
7969 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
7970 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
7971 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
7973 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
7974 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id,
7976 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
7977 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off,
7979 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
7980 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos,
7983 cmdline_parse_inst_t cmd_read_reg_bit = {
7984 .f = cmd_read_reg_bit_parsed,
7986 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
7988 (void *)&cmd_read_reg_bit_read,
7989 (void *)&cmd_read_reg_bit_regbit,
7990 (void *)&cmd_read_reg_bit_port_id,
7991 (void *)&cmd_read_reg_bit_reg_off,
7992 (void *)&cmd_read_reg_bit_bit_pos,
7997 /* *** WRITE PORT REGISTER *** */
7998 struct cmd_write_reg_result {
7999 cmdline_fixed_string_t write;
8000 cmdline_fixed_string_t reg;
8007 cmd_write_reg_parsed(void *parsed_result,
8008 __rte_unused struct cmdline *cl,
8009 __rte_unused void *data)
8011 struct cmd_write_reg_result *res = parsed_result;
8012 port_reg_set(res->port_id, res->reg_off, res->value);
8015 cmdline_parse_token_string_t cmd_write_reg_write =
8016 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
8017 cmdline_parse_token_string_t cmd_write_reg_reg =
8018 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
8019 cmdline_parse_token_num_t cmd_write_reg_port_id =
8020 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, RTE_UINT16);
8021 cmdline_parse_token_num_t cmd_write_reg_reg_off =
8022 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, RTE_UINT32);
8023 cmdline_parse_token_num_t cmd_write_reg_value =
8024 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, RTE_UINT32);
8026 cmdline_parse_inst_t cmd_write_reg = {
8027 .f = cmd_write_reg_parsed,
8029 .help_str = "write reg <port_id> <reg_off> <reg_value>",
8031 (void *)&cmd_write_reg_write,
8032 (void *)&cmd_write_reg_reg,
8033 (void *)&cmd_write_reg_port_id,
8034 (void *)&cmd_write_reg_reg_off,
8035 (void *)&cmd_write_reg_value,
8040 /* *** WRITE PORT REGISTER BIT FIELD *** */
8041 struct cmd_write_reg_bit_field_result {
8042 cmdline_fixed_string_t write;
8043 cmdline_fixed_string_t regfield;
8052 cmd_write_reg_bit_field_parsed(void *parsed_result,
8053 __rte_unused struct cmdline *cl,
8054 __rte_unused void *data)
8056 struct cmd_write_reg_bit_field_result *res = parsed_result;
8057 port_reg_bit_field_set(res->port_id, res->reg_off,
8058 res->bit1_pos, res->bit2_pos, res->value);
8061 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
8062 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
8064 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
8065 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
8066 regfield, "regfield");
8067 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
8068 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
8070 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
8071 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
8073 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
8074 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
8076 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
8077 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
8079 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
8080 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
8083 cmdline_parse_inst_t cmd_write_reg_bit_field = {
8084 .f = cmd_write_reg_bit_field_parsed,
8086 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
8088 "Set register bit field between bit_x and bit_y included",
8090 (void *)&cmd_write_reg_bit_field_write,
8091 (void *)&cmd_write_reg_bit_field_regfield,
8092 (void *)&cmd_write_reg_bit_field_port_id,
8093 (void *)&cmd_write_reg_bit_field_reg_off,
8094 (void *)&cmd_write_reg_bit_field_bit1_pos,
8095 (void *)&cmd_write_reg_bit_field_bit2_pos,
8096 (void *)&cmd_write_reg_bit_field_value,
8101 /* *** WRITE PORT REGISTER BIT *** */
8102 struct cmd_write_reg_bit_result {
8103 cmdline_fixed_string_t write;
8104 cmdline_fixed_string_t regbit;
8112 cmd_write_reg_bit_parsed(void *parsed_result,
8113 __rte_unused struct cmdline *cl,
8114 __rte_unused void *data)
8116 struct cmd_write_reg_bit_result *res = parsed_result;
8117 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
8120 cmdline_parse_token_string_t cmd_write_reg_bit_write =
8121 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
8123 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
8124 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
8126 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
8127 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id,
8129 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
8130 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off,
8132 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
8133 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos,
8135 cmdline_parse_token_num_t cmd_write_reg_bit_value =
8136 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value,
8139 cmdline_parse_inst_t cmd_write_reg_bit = {
8140 .f = cmd_write_reg_bit_parsed,
8142 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
8145 (void *)&cmd_write_reg_bit_write,
8146 (void *)&cmd_write_reg_bit_regbit,
8147 (void *)&cmd_write_reg_bit_port_id,
8148 (void *)&cmd_write_reg_bit_reg_off,
8149 (void *)&cmd_write_reg_bit_bit_pos,
8150 (void *)&cmd_write_reg_bit_value,
8155 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
8156 struct cmd_read_rxd_txd_result {
8157 cmdline_fixed_string_t read;
8158 cmdline_fixed_string_t rxd_txd;
8165 cmd_read_rxd_txd_parsed(void *parsed_result,
8166 __rte_unused struct cmdline *cl,
8167 __rte_unused void *data)
8169 struct cmd_read_rxd_txd_result *res = parsed_result;
8171 if (!strcmp(res->rxd_txd, "rxd"))
8172 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8173 else if (!strcmp(res->rxd_txd, "txd"))
8174 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8177 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
8178 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
8179 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
8180 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
8182 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
8183 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id,
8185 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
8186 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id,
8188 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
8189 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id,
8192 cmdline_parse_inst_t cmd_read_rxd_txd = {
8193 .f = cmd_read_rxd_txd_parsed,
8195 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
8197 (void *)&cmd_read_rxd_txd_read,
8198 (void *)&cmd_read_rxd_txd_rxd_txd,
8199 (void *)&cmd_read_rxd_txd_port_id,
8200 (void *)&cmd_read_rxd_txd_queue_id,
8201 (void *)&cmd_read_rxd_txd_desc_id,
8207 struct cmd_quit_result {
8208 cmdline_fixed_string_t quit;
8211 static void cmd_quit_parsed(__rte_unused void *parsed_result,
8213 __rte_unused void *data)
8218 cmdline_parse_token_string_t cmd_quit_quit =
8219 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
8221 cmdline_parse_inst_t cmd_quit = {
8222 .f = cmd_quit_parsed,
8224 .help_str = "quit: Exit application",
8226 (void *)&cmd_quit_quit,
8231 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
8232 struct cmd_mac_addr_result {
8233 cmdline_fixed_string_t mac_addr_cmd;
8234 cmdline_fixed_string_t what;
8236 struct rte_ether_addr address;
8239 static void cmd_mac_addr_parsed(void *parsed_result,
8240 __rte_unused struct cmdline *cl,
8241 __rte_unused void *data)
8243 struct cmd_mac_addr_result *res = parsed_result;
8246 if (strcmp(res->what, "add") == 0)
8247 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
8248 else if (strcmp(res->what, "set") == 0)
8249 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
8252 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
8254 /* check the return value and print it if is < 0 */
8256 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
8260 cmdline_parse_token_string_t cmd_mac_addr_cmd =
8261 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
8263 cmdline_parse_token_string_t cmd_mac_addr_what =
8264 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
8266 cmdline_parse_token_num_t cmd_mac_addr_portnum =
8267 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
8269 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
8270 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
8272 cmdline_parse_inst_t cmd_mac_addr = {
8273 .f = cmd_mac_addr_parsed,
8275 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
8276 "Add/Remove/Set MAC address on port_id",
8278 (void *)&cmd_mac_addr_cmd,
8279 (void *)&cmd_mac_addr_what,
8280 (void *)&cmd_mac_addr_portnum,
8281 (void *)&cmd_mac_addr_addr,
8286 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
8287 struct cmd_eth_peer_result {
8288 cmdline_fixed_string_t set;
8289 cmdline_fixed_string_t eth_peer;
8291 cmdline_fixed_string_t peer_addr;
8294 static void cmd_set_eth_peer_parsed(void *parsed_result,
8295 __rte_unused struct cmdline *cl,
8296 __rte_unused void *data)
8298 struct cmd_eth_peer_result *res = parsed_result;
8300 if (test_done == 0) {
8301 printf("Please stop forwarding first\n");
8304 if (!strcmp(res->eth_peer, "eth-peer")) {
8305 set_fwd_eth_peer(res->port_id, res->peer_addr);
8309 cmdline_parse_token_string_t cmd_eth_peer_set =
8310 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
8311 cmdline_parse_token_string_t cmd_eth_peer =
8312 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
8313 cmdline_parse_token_num_t cmd_eth_peer_port_id =
8314 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id,
8316 cmdline_parse_token_string_t cmd_eth_peer_addr =
8317 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
8319 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
8320 .f = cmd_set_eth_peer_parsed,
8322 .help_str = "set eth-peer <port_id> <peer_mac>",
8324 (void *)&cmd_eth_peer_set,
8325 (void *)&cmd_eth_peer,
8326 (void *)&cmd_eth_peer_port_id,
8327 (void *)&cmd_eth_peer_addr,
8332 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
8333 struct cmd_set_qmap_result {
8334 cmdline_fixed_string_t set;
8335 cmdline_fixed_string_t qmap;
8336 cmdline_fixed_string_t what;
8343 cmd_set_qmap_parsed(void *parsed_result,
8344 __rte_unused struct cmdline *cl,
8345 __rte_unused void *data)
8347 struct cmd_set_qmap_result *res = parsed_result;
8348 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
8350 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
8353 cmdline_parse_token_string_t cmd_setqmap_set =
8354 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8356 cmdline_parse_token_string_t cmd_setqmap_qmap =
8357 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8359 cmdline_parse_token_string_t cmd_setqmap_what =
8360 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8362 cmdline_parse_token_num_t cmd_setqmap_portid =
8363 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8364 port_id, RTE_UINT16);
8365 cmdline_parse_token_num_t cmd_setqmap_queueid =
8366 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8367 queue_id, RTE_UINT16);
8368 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
8369 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8370 map_value, RTE_UINT8);
8372 cmdline_parse_inst_t cmd_set_qmap = {
8373 .f = cmd_set_qmap_parsed,
8375 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
8376 "Set statistics mapping value on tx|rx queue_id of port_id",
8378 (void *)&cmd_setqmap_set,
8379 (void *)&cmd_setqmap_qmap,
8380 (void *)&cmd_setqmap_what,
8381 (void *)&cmd_setqmap_portid,
8382 (void *)&cmd_setqmap_queueid,
8383 (void *)&cmd_setqmap_mapvalue,
8388 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
8389 struct cmd_set_xstats_hide_zero_result {
8390 cmdline_fixed_string_t keyword;
8391 cmdline_fixed_string_t name;
8392 cmdline_fixed_string_t on_off;
8396 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
8397 __rte_unused struct cmdline *cl,
8398 __rte_unused void *data)
8400 struct cmd_set_xstats_hide_zero_result *res;
8401 uint16_t on_off = 0;
8403 res = parsed_result;
8404 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8405 set_xstats_hide_zero(on_off);
8408 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
8409 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8411 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
8412 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8413 name, "xstats-hide-zero");
8414 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
8415 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8418 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
8419 .f = cmd_set_xstats_hide_zero_parsed,
8421 .help_str = "set xstats-hide-zero on|off",
8423 (void *)&cmd_set_xstats_hide_zero_keyword,
8424 (void *)&cmd_set_xstats_hide_zero_name,
8425 (void *)&cmd_set_xstats_hide_zero_on_off,
8430 /* *** SET OPTION TO ENABLE MEASUREMENT OF CPU CYCLES *** */
8431 struct cmd_set_record_core_cycles_result {
8432 cmdline_fixed_string_t keyword;
8433 cmdline_fixed_string_t name;
8434 cmdline_fixed_string_t on_off;
8438 cmd_set_record_core_cycles_parsed(void *parsed_result,
8439 __rte_unused struct cmdline *cl,
8440 __rte_unused void *data)
8442 struct cmd_set_record_core_cycles_result *res;
8443 uint16_t on_off = 0;
8445 res = parsed_result;
8446 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8447 set_record_core_cycles(on_off);
8450 cmdline_parse_token_string_t cmd_set_record_core_cycles_keyword =
8451 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8453 cmdline_parse_token_string_t cmd_set_record_core_cycles_name =
8454 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8455 name, "record-core-cycles");
8456 cmdline_parse_token_string_t cmd_set_record_core_cycles_on_off =
8457 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8460 cmdline_parse_inst_t cmd_set_record_core_cycles = {
8461 .f = cmd_set_record_core_cycles_parsed,
8463 .help_str = "set record-core-cycles on|off",
8465 (void *)&cmd_set_record_core_cycles_keyword,
8466 (void *)&cmd_set_record_core_cycles_name,
8467 (void *)&cmd_set_record_core_cycles_on_off,
8472 /* *** SET OPTION TO ENABLE DISPLAY OF RX AND TX BURSTS *** */
8473 struct cmd_set_record_burst_stats_result {
8474 cmdline_fixed_string_t keyword;
8475 cmdline_fixed_string_t name;
8476 cmdline_fixed_string_t on_off;
8480 cmd_set_record_burst_stats_parsed(void *parsed_result,
8481 __rte_unused struct cmdline *cl,
8482 __rte_unused void *data)
8484 struct cmd_set_record_burst_stats_result *res;
8485 uint16_t on_off = 0;
8487 res = parsed_result;
8488 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8489 set_record_burst_stats(on_off);
8492 cmdline_parse_token_string_t cmd_set_record_burst_stats_keyword =
8493 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8495 cmdline_parse_token_string_t cmd_set_record_burst_stats_name =
8496 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8497 name, "record-burst-stats");
8498 cmdline_parse_token_string_t cmd_set_record_burst_stats_on_off =
8499 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8502 cmdline_parse_inst_t cmd_set_record_burst_stats = {
8503 .f = cmd_set_record_burst_stats_parsed,
8505 .help_str = "set record-burst-stats on|off",
8507 (void *)&cmd_set_record_burst_stats_keyword,
8508 (void *)&cmd_set_record_burst_stats_name,
8509 (void *)&cmd_set_record_burst_stats_on_off,
8514 /* *** CONFIGURE UNICAST HASH TABLE *** */
8515 struct cmd_set_uc_hash_table {
8516 cmdline_fixed_string_t set;
8517 cmdline_fixed_string_t port;
8519 cmdline_fixed_string_t what;
8520 struct rte_ether_addr address;
8521 cmdline_fixed_string_t mode;
8525 cmd_set_uc_hash_parsed(void *parsed_result,
8526 __rte_unused struct cmdline *cl,
8527 __rte_unused void *data)
8530 struct cmd_set_uc_hash_table *res = parsed_result;
8532 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8534 if (strcmp(res->what, "uta") == 0)
8535 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
8536 &res->address,(uint8_t)is_on);
8538 printf("bad unicast hash table parameter, return code = %d \n", ret);
8542 cmdline_parse_token_string_t cmd_set_uc_hash_set =
8543 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8545 cmdline_parse_token_string_t cmd_set_uc_hash_port =
8546 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8548 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
8549 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
8550 port_id, RTE_UINT16);
8551 cmdline_parse_token_string_t cmd_set_uc_hash_what =
8552 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8554 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
8555 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
8557 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
8558 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8561 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
8562 .f = cmd_set_uc_hash_parsed,
8564 .help_str = "set port <port_id> uta <mac_addr> on|off)",
8566 (void *)&cmd_set_uc_hash_set,
8567 (void *)&cmd_set_uc_hash_port,
8568 (void *)&cmd_set_uc_hash_portid,
8569 (void *)&cmd_set_uc_hash_what,
8570 (void *)&cmd_set_uc_hash_mac,
8571 (void *)&cmd_set_uc_hash_mode,
8576 struct cmd_set_uc_all_hash_table {
8577 cmdline_fixed_string_t set;
8578 cmdline_fixed_string_t port;
8580 cmdline_fixed_string_t what;
8581 cmdline_fixed_string_t value;
8582 cmdline_fixed_string_t mode;
8586 cmd_set_uc_all_hash_parsed(void *parsed_result,
8587 __rte_unused struct cmdline *cl,
8588 __rte_unused void *data)
8591 struct cmd_set_uc_all_hash_table *res = parsed_result;
8593 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8595 if ((strcmp(res->what, "uta") == 0) &&
8596 (strcmp(res->value, "all") == 0))
8597 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
8599 printf("bad unicast hash table parameter,"
8600 "return code = %d \n", ret);
8603 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
8604 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8606 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
8607 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8609 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
8610 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
8611 port_id, RTE_UINT16);
8612 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
8613 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8615 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
8616 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8618 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
8619 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8622 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
8623 .f = cmd_set_uc_all_hash_parsed,
8625 .help_str = "set port <port_id> uta all on|off",
8627 (void *)&cmd_set_uc_all_hash_set,
8628 (void *)&cmd_set_uc_all_hash_port,
8629 (void *)&cmd_set_uc_all_hash_portid,
8630 (void *)&cmd_set_uc_all_hash_what,
8631 (void *)&cmd_set_uc_all_hash_value,
8632 (void *)&cmd_set_uc_all_hash_mode,
8637 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
8638 struct cmd_set_vf_traffic {
8639 cmdline_fixed_string_t set;
8640 cmdline_fixed_string_t port;
8642 cmdline_fixed_string_t vf;
8644 cmdline_fixed_string_t what;
8645 cmdline_fixed_string_t mode;
8649 cmd_set_vf_traffic_parsed(void *parsed_result,
8650 __rte_unused struct cmdline *cl,
8651 __rte_unused void *data)
8653 struct cmd_set_vf_traffic *res = parsed_result;
8654 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
8655 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8657 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
8660 cmdline_parse_token_string_t cmd_setvf_traffic_set =
8661 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8663 cmdline_parse_token_string_t cmd_setvf_traffic_port =
8664 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8666 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8667 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8668 port_id, RTE_UINT16);
8669 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8670 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8672 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8673 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8675 cmdline_parse_token_string_t cmd_setvf_traffic_what =
8676 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8678 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8679 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8682 cmdline_parse_inst_t cmd_set_vf_traffic = {
8683 .f = cmd_set_vf_traffic_parsed,
8685 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8687 (void *)&cmd_setvf_traffic_set,
8688 (void *)&cmd_setvf_traffic_port,
8689 (void *)&cmd_setvf_traffic_portid,
8690 (void *)&cmd_setvf_traffic_vf,
8691 (void *)&cmd_setvf_traffic_vfid,
8692 (void *)&cmd_setvf_traffic_what,
8693 (void *)&cmd_setvf_traffic_mode,
8698 /* *** CONFIGURE VF RECEIVE MODE *** */
8699 struct cmd_set_vf_rxmode {
8700 cmdline_fixed_string_t set;
8701 cmdline_fixed_string_t port;
8703 cmdline_fixed_string_t vf;
8705 cmdline_fixed_string_t what;
8706 cmdline_fixed_string_t mode;
8707 cmdline_fixed_string_t on;
8711 cmd_set_vf_rxmode_parsed(void *parsed_result,
8712 __rte_unused struct cmdline *cl,
8713 __rte_unused void *data)
8716 uint16_t vf_rxmode = 0;
8717 struct cmd_set_vf_rxmode *res = parsed_result;
8719 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8720 if (!strcmp(res->what,"rxmode")) {
8721 if (!strcmp(res->mode, "AUPE"))
8722 vf_rxmode |= ETH_VMDQ_ACCEPT_UNTAG;
8723 else if (!strcmp(res->mode, "ROPE"))
8724 vf_rxmode |= ETH_VMDQ_ACCEPT_HASH_UC;
8725 else if (!strcmp(res->mode, "BAM"))
8726 vf_rxmode |= ETH_VMDQ_ACCEPT_BROADCAST;
8727 else if (!strncmp(res->mode, "MPE",3))
8728 vf_rxmode |= ETH_VMDQ_ACCEPT_MULTICAST;
8731 RTE_SET_USED(is_on);
8733 #ifdef RTE_NET_IXGBE
8734 if (ret == -ENOTSUP)
8735 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8736 vf_rxmode, (uint8_t)is_on);
8739 if (ret == -ENOTSUP)
8740 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8741 vf_rxmode, (uint8_t)is_on);
8744 printf("bad VF receive mode parameter, return code = %d \n",
8748 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8749 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8751 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8752 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8754 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8755 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8756 port_id, RTE_UINT16);
8757 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8758 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8760 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8761 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8763 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
8764 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8766 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
8767 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8768 mode, "AUPE#ROPE#BAM#MPE");
8769 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
8770 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8773 cmdline_parse_inst_t cmd_set_vf_rxmode = {
8774 .f = cmd_set_vf_rxmode_parsed,
8776 .help_str = "set port <port_id> vf <vf_id> rxmode "
8777 "AUPE|ROPE|BAM|MPE on|off",
8779 (void *)&cmd_set_vf_rxmode_set,
8780 (void *)&cmd_set_vf_rxmode_port,
8781 (void *)&cmd_set_vf_rxmode_portid,
8782 (void *)&cmd_set_vf_rxmode_vf,
8783 (void *)&cmd_set_vf_rxmode_vfid,
8784 (void *)&cmd_set_vf_rxmode_what,
8785 (void *)&cmd_set_vf_rxmode_mode,
8786 (void *)&cmd_set_vf_rxmode_on,
8791 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
8792 struct cmd_vf_mac_addr_result {
8793 cmdline_fixed_string_t mac_addr_cmd;
8794 cmdline_fixed_string_t what;
8795 cmdline_fixed_string_t port;
8797 cmdline_fixed_string_t vf;
8799 struct rte_ether_addr address;
8802 static void cmd_vf_mac_addr_parsed(void *parsed_result,
8803 __rte_unused struct cmdline *cl,
8804 __rte_unused void *data)
8806 struct cmd_vf_mac_addr_result *res = parsed_result;
8809 if (strcmp(res->what, "add") != 0)
8813 if (ret == -ENOTSUP)
8814 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
8818 if (ret == -ENOTSUP)
8819 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
8824 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
8828 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
8829 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8830 mac_addr_cmd,"mac_addr");
8831 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
8832 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8834 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
8835 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8837 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
8838 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8839 port_num, RTE_UINT16);
8840 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
8841 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8843 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
8844 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8846 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
8847 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
8850 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
8851 .f = cmd_vf_mac_addr_parsed,
8853 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
8854 "Add MAC address filtering for a VF on port_id",
8856 (void *)&cmd_vf_mac_addr_cmd,
8857 (void *)&cmd_vf_mac_addr_what,
8858 (void *)&cmd_vf_mac_addr_port,
8859 (void *)&cmd_vf_mac_addr_portnum,
8860 (void *)&cmd_vf_mac_addr_vf,
8861 (void *)&cmd_vf_mac_addr_vfnum,
8862 (void *)&cmd_vf_mac_addr_addr,
8867 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
8868 struct cmd_vf_rx_vlan_filter {
8869 cmdline_fixed_string_t rx_vlan;
8870 cmdline_fixed_string_t what;
8872 cmdline_fixed_string_t port;
8874 cmdline_fixed_string_t vf;
8879 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
8880 __rte_unused struct cmdline *cl,
8881 __rte_unused void *data)
8883 struct cmd_vf_rx_vlan_filter *res = parsed_result;
8886 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
8888 #ifdef RTE_NET_IXGBE
8889 if (ret == -ENOTSUP)
8890 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
8891 res->vlan_id, res->vf_mask, is_add);
8894 if (ret == -ENOTSUP)
8895 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
8896 res->vlan_id, res->vf_mask, is_add);
8899 if (ret == -ENOTSUP)
8900 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
8901 res->vlan_id, res->vf_mask, is_add);
8908 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
8909 res->vlan_id, res->vf_mask);
8912 printf("invalid port_id %d\n", res->port_id);
8915 printf("function not implemented or supported\n");
8918 printf("programming error: (%s)\n", strerror(-ret));
8922 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
8923 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8924 rx_vlan, "rx_vlan");
8925 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
8926 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8928 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
8929 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8930 vlan_id, RTE_UINT16);
8931 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
8932 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8934 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
8935 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8936 port_id, RTE_UINT16);
8937 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
8938 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8940 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
8941 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8942 vf_mask, RTE_UINT64);
8944 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
8945 .f = cmd_vf_rx_vlan_filter_parsed,
8947 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
8948 "(vf_mask = hexadecimal VF mask)",
8950 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
8951 (void *)&cmd_vf_rx_vlan_filter_what,
8952 (void *)&cmd_vf_rx_vlan_filter_vlanid,
8953 (void *)&cmd_vf_rx_vlan_filter_port,
8954 (void *)&cmd_vf_rx_vlan_filter_portid,
8955 (void *)&cmd_vf_rx_vlan_filter_vf,
8956 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
8961 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
8962 struct cmd_queue_rate_limit_result {
8963 cmdline_fixed_string_t set;
8964 cmdline_fixed_string_t port;
8966 cmdline_fixed_string_t queue;
8968 cmdline_fixed_string_t rate;
8972 static void cmd_queue_rate_limit_parsed(void *parsed_result,
8973 __rte_unused struct cmdline *cl,
8974 __rte_unused void *data)
8976 struct cmd_queue_rate_limit_result *res = parsed_result;
8979 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8980 && (strcmp(res->queue, "queue") == 0)
8981 && (strcmp(res->rate, "rate") == 0))
8982 ret = set_queue_rate_limit(res->port_num, res->queue_num,
8985 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
8989 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
8990 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8992 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
8993 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8995 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
8996 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8997 port_num, RTE_UINT16);
8998 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
8999 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9001 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
9002 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9003 queue_num, RTE_UINT8);
9004 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
9005 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9007 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
9008 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9009 rate_num, RTE_UINT16);
9011 cmdline_parse_inst_t cmd_queue_rate_limit = {
9012 .f = cmd_queue_rate_limit_parsed,
9014 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
9015 "Set rate limit for a queue on port_id",
9017 (void *)&cmd_queue_rate_limit_set,
9018 (void *)&cmd_queue_rate_limit_port,
9019 (void *)&cmd_queue_rate_limit_portnum,
9020 (void *)&cmd_queue_rate_limit_queue,
9021 (void *)&cmd_queue_rate_limit_queuenum,
9022 (void *)&cmd_queue_rate_limit_rate,
9023 (void *)&cmd_queue_rate_limit_ratenum,
9028 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
9029 struct cmd_vf_rate_limit_result {
9030 cmdline_fixed_string_t set;
9031 cmdline_fixed_string_t port;
9033 cmdline_fixed_string_t vf;
9035 cmdline_fixed_string_t rate;
9037 cmdline_fixed_string_t q_msk;
9041 static void cmd_vf_rate_limit_parsed(void *parsed_result,
9042 __rte_unused struct cmdline *cl,
9043 __rte_unused void *data)
9045 struct cmd_vf_rate_limit_result *res = parsed_result;
9048 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9049 && (strcmp(res->vf, "vf") == 0)
9050 && (strcmp(res->rate, "rate") == 0)
9051 && (strcmp(res->q_msk, "queue_mask") == 0))
9052 ret = set_vf_rate_limit(res->port_num, res->vf_num,
9053 res->rate_num, res->q_msk_val);
9055 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
9059 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
9060 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9062 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
9063 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9065 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
9066 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9067 port_num, RTE_UINT16);
9068 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
9069 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9071 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
9072 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9074 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
9075 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9077 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
9078 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9079 rate_num, RTE_UINT16);
9080 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
9081 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9082 q_msk, "queue_mask");
9083 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
9084 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9085 q_msk_val, RTE_UINT64);
9087 cmdline_parse_inst_t cmd_vf_rate_limit = {
9088 .f = cmd_vf_rate_limit_parsed,
9090 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
9091 "queue_mask <queue_mask_value>: "
9092 "Set rate limit for queues of VF on port_id",
9094 (void *)&cmd_vf_rate_limit_set,
9095 (void *)&cmd_vf_rate_limit_port,
9096 (void *)&cmd_vf_rate_limit_portnum,
9097 (void *)&cmd_vf_rate_limit_vf,
9098 (void *)&cmd_vf_rate_limit_vfnum,
9099 (void *)&cmd_vf_rate_limit_rate,
9100 (void *)&cmd_vf_rate_limit_ratenum,
9101 (void *)&cmd_vf_rate_limit_q_msk,
9102 (void *)&cmd_vf_rate_limit_q_msk_val,
9107 /* *** CONFIGURE TUNNEL UDP PORT *** */
9108 struct cmd_tunnel_udp_config {
9109 cmdline_fixed_string_t rx_vxlan_port;
9110 cmdline_fixed_string_t what;
9116 cmd_tunnel_udp_config_parsed(void *parsed_result,
9117 __rte_unused struct cmdline *cl,
9118 __rte_unused void *data)
9120 struct cmd_tunnel_udp_config *res = parsed_result;
9121 struct rte_eth_udp_tunnel tunnel_udp;
9124 tunnel_udp.udp_port = res->udp_port;
9125 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9127 if (!strcmp(res->what, "add"))
9128 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9131 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9135 printf("udp tunneling add error: (%s)\n", strerror(-ret));
9138 cmdline_parse_token_string_t cmd_tunnel_udp_config_rx_vxlan_port =
9139 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9140 rx_vxlan_port, "rx_vxlan_port");
9141 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
9142 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9144 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
9145 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9146 udp_port, RTE_UINT16);
9147 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
9148 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9149 port_id, RTE_UINT16);
9151 cmdline_parse_inst_t cmd_tunnel_udp_config = {
9152 .f = cmd_tunnel_udp_config_parsed,
9154 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
9155 "Add/Remove a tunneling UDP port filter",
9157 (void *)&cmd_tunnel_udp_config_rx_vxlan_port,
9158 (void *)&cmd_tunnel_udp_config_what,
9159 (void *)&cmd_tunnel_udp_config_udp_port,
9160 (void *)&cmd_tunnel_udp_config_port_id,
9165 struct cmd_config_tunnel_udp_port {
9166 cmdline_fixed_string_t port;
9167 cmdline_fixed_string_t config;
9169 cmdline_fixed_string_t udp_tunnel_port;
9170 cmdline_fixed_string_t action;
9171 cmdline_fixed_string_t tunnel_type;
9176 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
9177 __rte_unused struct cmdline *cl,
9178 __rte_unused void *data)
9180 struct cmd_config_tunnel_udp_port *res = parsed_result;
9181 struct rte_eth_udp_tunnel tunnel_udp;
9184 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9187 tunnel_udp.udp_port = res->udp_port;
9189 if (!strcmp(res->tunnel_type, "vxlan")) {
9190 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9191 } else if (!strcmp(res->tunnel_type, "geneve")) {
9192 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE;
9193 } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
9194 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9195 } else if (!strcmp(res->tunnel_type, "ecpri")) {
9196 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_ECPRI;
9198 printf("Invalid tunnel type\n");
9202 if (!strcmp(res->action, "add"))
9203 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9206 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9210 printf("udp tunneling port add error: (%s)\n", strerror(-ret));
9213 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
9214 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
9216 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
9217 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
9219 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
9220 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
9222 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
9223 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
9226 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
9227 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
9229 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
9230 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
9231 "vxlan#geneve#vxlan-gpe#ecpri");
9232 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
9233 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
9236 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
9237 .f = cmd_cfg_tunnel_udp_port_parsed,
9239 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|"
9240 "geneve|vxlan-gpe|ecpri <udp_port>",
9242 (void *)&cmd_config_tunnel_udp_port_port,
9243 (void *)&cmd_config_tunnel_udp_port_config,
9244 (void *)&cmd_config_tunnel_udp_port_port_id,
9245 (void *)&cmd_config_tunnel_udp_port_tunnel_port,
9246 (void *)&cmd_config_tunnel_udp_port_action,
9247 (void *)&cmd_config_tunnel_udp_port_tunnel_type,
9248 (void *)&cmd_config_tunnel_udp_port_value,
9253 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
9254 struct cmd_set_mirror_mask_result {
9255 cmdline_fixed_string_t set;
9256 cmdline_fixed_string_t port;
9258 cmdline_fixed_string_t mirror;
9260 cmdline_fixed_string_t what;
9261 cmdline_fixed_string_t value;
9262 cmdline_fixed_string_t dstpool;
9264 cmdline_fixed_string_t on;
9267 cmdline_parse_token_string_t cmd_mirror_mask_set =
9268 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9270 cmdline_parse_token_string_t cmd_mirror_mask_port =
9271 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9273 cmdline_parse_token_num_t cmd_mirror_mask_portid =
9274 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9275 port_id, RTE_UINT16);
9276 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
9277 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9278 mirror, "mirror-rule");
9279 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
9280 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9281 rule_id, RTE_UINT8);
9282 cmdline_parse_token_string_t cmd_mirror_mask_what =
9283 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9284 what, "pool-mirror-up#pool-mirror-down"
9286 cmdline_parse_token_string_t cmd_mirror_mask_value =
9287 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9289 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
9290 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9291 dstpool, "dst-pool");
9292 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
9293 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9294 dstpool_id, RTE_UINT8);
9295 cmdline_parse_token_string_t cmd_mirror_mask_on =
9296 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9300 cmd_set_mirror_mask_parsed(void *parsed_result,
9301 __rte_unused struct cmdline *cl,
9302 __rte_unused void *data)
9305 struct cmd_set_mirror_mask_result *res = parsed_result;
9306 struct rte_eth_mirror_conf mr_conf;
9308 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9310 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
9312 mr_conf.dst_pool = res->dstpool_id;
9314 if (!strcmp(res->what, "pool-mirror-up")) {
9315 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9316 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
9317 } else if (!strcmp(res->what, "pool-mirror-down")) {
9318 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9319 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
9320 } else if (!strcmp(res->what, "vlan-mirror")) {
9321 mr_conf.rule_type = ETH_MIRROR_VLAN;
9322 nb_item = parse_item_list(res->value, "vlan",
9323 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
9327 for (i = 0; i < nb_item; i++) {
9328 if (vlan_list[i] > RTE_ETHER_MAX_VLAN_ID) {
9329 printf("Invalid vlan_id: must be < 4096\n");
9333 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
9334 mr_conf.vlan.vlan_mask |= 1ULL << i;
9338 if (!strcmp(res->on, "on"))
9339 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9342 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9345 printf("mirror rule add error: (%s)\n", strerror(-ret));
9348 cmdline_parse_inst_t cmd_set_mirror_mask = {
9349 .f = cmd_set_mirror_mask_parsed,
9351 .help_str = "set port <port_id> mirror-rule <rule_id> "
9352 "pool-mirror-up|pool-mirror-down|vlan-mirror "
9353 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
9355 (void *)&cmd_mirror_mask_set,
9356 (void *)&cmd_mirror_mask_port,
9357 (void *)&cmd_mirror_mask_portid,
9358 (void *)&cmd_mirror_mask_mirror,
9359 (void *)&cmd_mirror_mask_ruleid,
9360 (void *)&cmd_mirror_mask_what,
9361 (void *)&cmd_mirror_mask_value,
9362 (void *)&cmd_mirror_mask_dstpool,
9363 (void *)&cmd_mirror_mask_poolid,
9364 (void *)&cmd_mirror_mask_on,
9369 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
9370 struct cmd_set_mirror_link_result {
9371 cmdline_fixed_string_t set;
9372 cmdline_fixed_string_t port;
9374 cmdline_fixed_string_t mirror;
9376 cmdline_fixed_string_t what;
9377 cmdline_fixed_string_t dstpool;
9379 cmdline_fixed_string_t on;
9382 cmdline_parse_token_string_t cmd_mirror_link_set =
9383 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9385 cmdline_parse_token_string_t cmd_mirror_link_port =
9386 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9388 cmdline_parse_token_num_t cmd_mirror_link_portid =
9389 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9390 port_id, RTE_UINT16);
9391 cmdline_parse_token_string_t cmd_mirror_link_mirror =
9392 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9393 mirror, "mirror-rule");
9394 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
9395 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9396 rule_id, RTE_UINT8);
9397 cmdline_parse_token_string_t cmd_mirror_link_what =
9398 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9399 what, "uplink-mirror#downlink-mirror");
9400 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
9401 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9402 dstpool, "dst-pool");
9403 cmdline_parse_token_num_t cmd_mirror_link_poolid =
9404 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9405 dstpool_id, RTE_UINT8);
9406 cmdline_parse_token_string_t cmd_mirror_link_on =
9407 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9411 cmd_set_mirror_link_parsed(void *parsed_result,
9412 __rte_unused struct cmdline *cl,
9413 __rte_unused void *data)
9416 struct cmd_set_mirror_link_result *res = parsed_result;
9417 struct rte_eth_mirror_conf mr_conf;
9419 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9420 if (!strcmp(res->what, "uplink-mirror"))
9421 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
9423 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
9425 mr_conf.dst_pool = res->dstpool_id;
9427 if (!strcmp(res->on, "on"))
9428 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9431 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9434 /* check the return value and print it if is < 0 */
9436 printf("mirror rule add error: (%s)\n", strerror(-ret));
9440 cmdline_parse_inst_t cmd_set_mirror_link = {
9441 .f = cmd_set_mirror_link_parsed,
9443 .help_str = "set port <port_id> mirror-rule <rule_id> "
9444 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
9446 (void *)&cmd_mirror_link_set,
9447 (void *)&cmd_mirror_link_port,
9448 (void *)&cmd_mirror_link_portid,
9449 (void *)&cmd_mirror_link_mirror,
9450 (void *)&cmd_mirror_link_ruleid,
9451 (void *)&cmd_mirror_link_what,
9452 (void *)&cmd_mirror_link_dstpool,
9453 (void *)&cmd_mirror_link_poolid,
9454 (void *)&cmd_mirror_link_on,
9459 /* *** RESET VM MIRROR RULE *** */
9460 struct cmd_rm_mirror_rule_result {
9461 cmdline_fixed_string_t reset;
9462 cmdline_fixed_string_t port;
9464 cmdline_fixed_string_t mirror;
9468 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
9469 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9471 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
9472 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9474 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
9475 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9476 port_id, RTE_UINT16);
9477 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
9478 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9479 mirror, "mirror-rule");
9480 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
9481 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9482 rule_id, RTE_UINT8);
9485 cmd_reset_mirror_rule_parsed(void *parsed_result,
9486 __rte_unused struct cmdline *cl,
9487 __rte_unused void *data)
9490 struct cmd_set_mirror_link_result *res = parsed_result;
9492 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
9494 printf("mirror rule remove error: (%s)\n", strerror(-ret));
9497 cmdline_parse_inst_t cmd_reset_mirror_rule = {
9498 .f = cmd_reset_mirror_rule_parsed,
9500 .help_str = "reset port <port_id> mirror-rule <rule_id>",
9502 (void *)&cmd_rm_mirror_rule_reset,
9503 (void *)&cmd_rm_mirror_rule_port,
9504 (void *)&cmd_rm_mirror_rule_portid,
9505 (void *)&cmd_rm_mirror_rule_mirror,
9506 (void *)&cmd_rm_mirror_rule_ruleid,
9511 /* ******************************************************************************** */
9513 struct cmd_dump_result {
9514 cmdline_fixed_string_t dump;
9518 dump_struct_sizes(void)
9520 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9521 DUMP_SIZE(struct rte_mbuf);
9522 DUMP_SIZE(struct rte_mempool);
9523 DUMP_SIZE(struct rte_ring);
9528 /* Dump the socket memory statistics on console */
9530 dump_socket_mem(FILE *f)
9532 struct rte_malloc_socket_stats socket_stats;
9537 unsigned int n_alloc = 0;
9538 unsigned int n_free = 0;
9539 static size_t last_allocs;
9540 static size_t last_total;
9543 for (i = 0; i < RTE_MAX_NUMA_NODES; i++) {
9544 if (rte_malloc_get_socket_stats(i, &socket_stats) ||
9545 !socket_stats.heap_totalsz_bytes)
9547 total += socket_stats.heap_totalsz_bytes;
9548 alloc += socket_stats.heap_allocsz_bytes;
9549 free += socket_stats.heap_freesz_bytes;
9550 n_alloc += socket_stats.alloc_count;
9551 n_free += socket_stats.free_count;
9553 "Socket %u: size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9555 (double)socket_stats.heap_totalsz_bytes / (1024 * 1024),
9556 (double)socket_stats.heap_allocsz_bytes / (1024 * 1024),
9557 (double)socket_stats.heap_allocsz_bytes * 100 /
9558 (double)socket_stats.heap_totalsz_bytes,
9559 (double)socket_stats.heap_freesz_bytes / (1024 * 1024),
9560 socket_stats.alloc_count,
9561 socket_stats.free_count);
9564 "Total : size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9565 (double)total / (1024 * 1024), (double)alloc / (1024 * 1024),
9566 (double)alloc * 100 / (double)total,
9567 (double)free / (1024 * 1024),
9570 fprintf(stdout, "Memory total change: %.6lf(M), allocation change: %.6lf(M)\n",
9571 ((double)total - (double)last_total) / (1024 * 1024),
9572 (double)(alloc - (double)last_allocs) / 1024 / 1024);
9573 last_allocs = alloc;
9577 static void cmd_dump_parsed(void *parsed_result,
9578 __rte_unused struct cmdline *cl,
9579 __rte_unused void *data)
9581 struct cmd_dump_result *res = parsed_result;
9583 if (!strcmp(res->dump, "dump_physmem"))
9584 rte_dump_physmem_layout(stdout);
9585 else if (!strcmp(res->dump, "dump_socket_mem"))
9586 dump_socket_mem(stdout);
9587 else if (!strcmp(res->dump, "dump_memzone"))
9588 rte_memzone_dump(stdout);
9589 else if (!strcmp(res->dump, "dump_struct_sizes"))
9590 dump_struct_sizes();
9591 else if (!strcmp(res->dump, "dump_ring"))
9592 rte_ring_list_dump(stdout);
9593 else if (!strcmp(res->dump, "dump_mempool"))
9594 rte_mempool_list_dump(stdout);
9595 else if (!strcmp(res->dump, "dump_devargs"))
9596 rte_devargs_dump(stdout);
9597 else if (!strcmp(res->dump, "dump_log_types"))
9598 rte_log_dump(stdout);
9601 cmdline_parse_token_string_t cmd_dump_dump =
9602 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9606 "dump_struct_sizes#"
9612 cmdline_parse_inst_t cmd_dump = {
9613 .f = cmd_dump_parsed, /* function to call */
9614 .data = NULL, /* 2nd arg of func */
9615 .help_str = "Dump status",
9616 .tokens = { /* token list, NULL terminated */
9617 (void *)&cmd_dump_dump,
9622 /* ******************************************************************************** */
9624 struct cmd_dump_one_result {
9625 cmdline_fixed_string_t dump;
9626 cmdline_fixed_string_t name;
9629 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9630 __rte_unused void *data)
9632 struct cmd_dump_one_result *res = parsed_result;
9634 if (!strcmp(res->dump, "dump_ring")) {
9636 r = rte_ring_lookup(res->name);
9638 cmdline_printf(cl, "Cannot find ring\n");
9641 rte_ring_dump(stdout, r);
9642 } else if (!strcmp(res->dump, "dump_mempool")) {
9643 struct rte_mempool *mp;
9644 mp = rte_mempool_lookup(res->name);
9646 cmdline_printf(cl, "Cannot find mempool\n");
9649 rte_mempool_dump(stdout, mp);
9653 cmdline_parse_token_string_t cmd_dump_one_dump =
9654 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9655 "dump_ring#dump_mempool");
9657 cmdline_parse_token_string_t cmd_dump_one_name =
9658 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9660 cmdline_parse_inst_t cmd_dump_one = {
9661 .f = cmd_dump_one_parsed, /* function to call */
9662 .data = NULL, /* 2nd arg of func */
9663 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9664 .tokens = { /* token list, NULL terminated */
9665 (void *)&cmd_dump_one_dump,
9666 (void *)&cmd_dump_one_name,
9671 /* *** queue region set *** */
9672 struct cmd_queue_region_result {
9673 cmdline_fixed_string_t set;
9674 cmdline_fixed_string_t port;
9676 cmdline_fixed_string_t cmd;
9677 cmdline_fixed_string_t region;
9679 cmdline_fixed_string_t queue_start_index;
9681 cmdline_fixed_string_t queue_num;
9682 uint8_t queue_num_value;
9686 cmd_queue_region_parsed(void *parsed_result,
9687 __rte_unused struct cmdline *cl,
9688 __rte_unused void *data)
9690 struct cmd_queue_region_result *res = parsed_result;
9693 struct rte_pmd_i40e_queue_region_conf region_conf;
9694 enum rte_pmd_i40e_queue_region_op op_type;
9697 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9701 memset(®ion_conf, 0, sizeof(region_conf));
9702 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
9703 region_conf.region_id = res->region_id;
9704 region_conf.queue_num = res->queue_num_value;
9705 region_conf.queue_start_index = res->queue_id;
9707 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9708 op_type, ®ion_conf);
9715 printf("function not implemented or supported\n");
9718 printf("queue region config error: (%s)\n", strerror(-ret));
9722 cmdline_parse_token_string_t cmd_queue_region_set =
9723 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9725 cmdline_parse_token_string_t cmd_queue_region_port =
9726 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
9727 cmdline_parse_token_num_t cmd_queue_region_port_id =
9728 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9729 port_id, RTE_UINT16);
9730 cmdline_parse_token_string_t cmd_queue_region_cmd =
9731 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9732 cmd, "queue-region");
9733 cmdline_parse_token_string_t cmd_queue_region_id =
9734 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9735 region, "region_id");
9736 cmdline_parse_token_num_t cmd_queue_region_index =
9737 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9738 region_id, RTE_UINT8);
9739 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
9740 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9741 queue_start_index, "queue_start_index");
9742 cmdline_parse_token_num_t cmd_queue_region_queue_id =
9743 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9744 queue_id, RTE_UINT8);
9745 cmdline_parse_token_string_t cmd_queue_region_queue_num =
9746 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9747 queue_num, "queue_num");
9748 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
9749 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9750 queue_num_value, RTE_UINT8);
9752 cmdline_parse_inst_t cmd_queue_region = {
9753 .f = cmd_queue_region_parsed,
9755 .help_str = "set port <port_id> queue-region region_id <value> "
9756 "queue_start_index <value> queue_num <value>: Set a queue region",
9758 (void *)&cmd_queue_region_set,
9759 (void *)&cmd_queue_region_port,
9760 (void *)&cmd_queue_region_port_id,
9761 (void *)&cmd_queue_region_cmd,
9762 (void *)&cmd_queue_region_id,
9763 (void *)&cmd_queue_region_index,
9764 (void *)&cmd_queue_region_queue_start_index,
9765 (void *)&cmd_queue_region_queue_id,
9766 (void *)&cmd_queue_region_queue_num,
9767 (void *)&cmd_queue_region_queue_num_value,
9772 /* *** queue region and flowtype set *** */
9773 struct cmd_region_flowtype_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 flowtype;
9781 uint8_t flowtype_id;
9785 cmd_region_flowtype_parsed(void *parsed_result,
9786 __rte_unused struct cmdline *cl,
9787 __rte_unused void *data)
9789 struct cmd_region_flowtype_result *res = parsed_result;
9792 struct rte_pmd_i40e_queue_region_conf region_conf;
9793 enum rte_pmd_i40e_queue_region_op op_type;
9796 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9800 memset(®ion_conf, 0, sizeof(region_conf));
9802 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
9803 region_conf.region_id = res->region_id;
9804 region_conf.hw_flowtype = res->flowtype_id;
9806 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9807 op_type, ®ion_conf);
9814 printf("function not implemented or supported\n");
9817 printf("region flowtype config error: (%s)\n", strerror(-ret));
9821 cmdline_parse_token_string_t cmd_region_flowtype_set =
9822 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9824 cmdline_parse_token_string_t cmd_region_flowtype_port =
9825 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9827 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
9828 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9829 port_id, RTE_UINT16);
9830 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
9831 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9832 cmd, "queue-region");
9833 cmdline_parse_token_string_t cmd_region_flowtype_index =
9834 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9835 region, "region_id");
9836 cmdline_parse_token_num_t cmd_region_flowtype_id =
9837 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9838 region_id, RTE_UINT8);
9839 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
9840 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9841 flowtype, "flowtype");
9842 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
9843 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9844 flowtype_id, RTE_UINT8);
9845 cmdline_parse_inst_t cmd_region_flowtype = {
9846 .f = cmd_region_flowtype_parsed,
9848 .help_str = "set port <port_id> queue-region region_id <value> "
9849 "flowtype <value>: Set a flowtype region index",
9851 (void *)&cmd_region_flowtype_set,
9852 (void *)&cmd_region_flowtype_port,
9853 (void *)&cmd_region_flowtype_port_index,
9854 (void *)&cmd_region_flowtype_cmd,
9855 (void *)&cmd_region_flowtype_index,
9856 (void *)&cmd_region_flowtype_id,
9857 (void *)&cmd_region_flowtype_flow_index,
9858 (void *)&cmd_region_flowtype_flow_id,
9863 /* *** User Priority (UP) to queue region (region_id) set *** */
9864 struct cmd_user_priority_region_result {
9865 cmdline_fixed_string_t set;
9866 cmdline_fixed_string_t port;
9868 cmdline_fixed_string_t cmd;
9869 cmdline_fixed_string_t user_priority;
9870 uint8_t user_priority_id;
9871 cmdline_fixed_string_t region;
9876 cmd_user_priority_region_parsed(void *parsed_result,
9877 __rte_unused struct cmdline *cl,
9878 __rte_unused void *data)
9880 struct cmd_user_priority_region_result *res = parsed_result;
9883 struct rte_pmd_i40e_queue_region_conf region_conf;
9884 enum rte_pmd_i40e_queue_region_op op_type;
9887 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9891 memset(®ion_conf, 0, sizeof(region_conf));
9892 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
9893 region_conf.user_priority = res->user_priority_id;
9894 region_conf.region_id = res->region_id;
9896 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9897 op_type, ®ion_conf);
9904 printf("function not implemented or supported\n");
9907 printf("user_priority region config error: (%s)\n",
9912 cmdline_parse_token_string_t cmd_user_priority_region_set =
9913 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9915 cmdline_parse_token_string_t cmd_user_priority_region_port =
9916 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9918 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
9919 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9920 port_id, RTE_UINT16);
9921 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
9922 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9923 cmd, "queue-region");
9924 cmdline_parse_token_string_t cmd_user_priority_region_UP =
9925 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9926 user_priority, "UP");
9927 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
9928 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9929 user_priority_id, RTE_UINT8);
9930 cmdline_parse_token_string_t cmd_user_priority_region_region =
9931 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9932 region, "region_id");
9933 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
9934 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9935 region_id, RTE_UINT8);
9937 cmdline_parse_inst_t cmd_user_priority_region = {
9938 .f = cmd_user_priority_region_parsed,
9940 .help_str = "set port <port_id> queue-region UP <value> "
9941 "region_id <value>: Set the mapping of User Priority (UP) "
9942 "to queue region (region_id) ",
9944 (void *)&cmd_user_priority_region_set,
9945 (void *)&cmd_user_priority_region_port,
9946 (void *)&cmd_user_priority_region_port_index,
9947 (void *)&cmd_user_priority_region_cmd,
9948 (void *)&cmd_user_priority_region_UP,
9949 (void *)&cmd_user_priority_region_UP_id,
9950 (void *)&cmd_user_priority_region_region,
9951 (void *)&cmd_user_priority_region_region_id,
9956 /* *** flush all queue region related configuration *** */
9957 struct cmd_flush_queue_region_result {
9958 cmdline_fixed_string_t set;
9959 cmdline_fixed_string_t port;
9961 cmdline_fixed_string_t cmd;
9962 cmdline_fixed_string_t flush;
9963 cmdline_fixed_string_t what;
9967 cmd_flush_queue_region_parsed(void *parsed_result,
9968 __rte_unused struct cmdline *cl,
9969 __rte_unused void *data)
9971 struct cmd_flush_queue_region_result *res = parsed_result;
9974 struct rte_pmd_i40e_queue_region_conf region_conf;
9975 enum rte_pmd_i40e_queue_region_op op_type;
9978 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9982 memset(®ion_conf, 0, sizeof(region_conf));
9984 if (strcmp(res->what, "on") == 0)
9985 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
9987 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
9989 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9990 op_type, ®ion_conf);
9997 printf("function not implemented or supported\n");
10000 printf("queue region config flush error: (%s)\n",
10005 cmdline_parse_token_string_t cmd_flush_queue_region_set =
10006 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10008 cmdline_parse_token_string_t cmd_flush_queue_region_port =
10009 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10011 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
10012 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
10013 port_id, RTE_UINT16);
10014 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
10015 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10016 cmd, "queue-region");
10017 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
10018 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10020 cmdline_parse_token_string_t cmd_flush_queue_region_what =
10021 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10024 cmdline_parse_inst_t cmd_flush_queue_region = {
10025 .f = cmd_flush_queue_region_parsed,
10027 .help_str = "set port <port_id> queue-region flush on|off"
10028 ": flush all queue region related configuration",
10030 (void *)&cmd_flush_queue_region_set,
10031 (void *)&cmd_flush_queue_region_port,
10032 (void *)&cmd_flush_queue_region_port_index,
10033 (void *)&cmd_flush_queue_region_cmd,
10034 (void *)&cmd_flush_queue_region_flush,
10035 (void *)&cmd_flush_queue_region_what,
10040 /* *** get all queue region related configuration info *** */
10041 struct cmd_show_queue_region_info {
10042 cmdline_fixed_string_t show;
10043 cmdline_fixed_string_t port;
10045 cmdline_fixed_string_t cmd;
10049 cmd_show_queue_region_info_parsed(void *parsed_result,
10050 __rte_unused struct cmdline *cl,
10051 __rte_unused void *data)
10053 struct cmd_show_queue_region_info *res = parsed_result;
10054 int ret = -ENOTSUP;
10055 #ifdef RTE_NET_I40E
10056 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
10057 enum rte_pmd_i40e_queue_region_op op_type;
10060 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10063 #ifdef RTE_NET_I40E
10064 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
10066 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
10068 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10069 op_type, &rte_pmd_regions);
10071 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
10078 printf("function not implemented or supported\n");
10081 printf("queue region config info show error: (%s)\n",
10086 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
10087 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10089 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
10090 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10092 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
10093 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
10094 port_id, RTE_UINT16);
10095 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
10096 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10097 cmd, "queue-region");
10099 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
10100 .f = cmd_show_queue_region_info_parsed,
10102 .help_str = "show port <port_id> queue-region"
10103 ": show all queue region related configuration info",
10105 (void *)&cmd_show_queue_region_info_get,
10106 (void *)&cmd_show_queue_region_info_port,
10107 (void *)&cmd_show_queue_region_info_port_index,
10108 (void *)&cmd_show_queue_region_info_cmd,
10113 /* *** Filters Control *** */
10115 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10117 if ((ip_addr).family == AF_INET) \
10118 (ip) = (ip_addr).addr.ipv4.s_addr; \
10120 printf("invalid parameter.\n"); \
10125 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10127 if ((ip_addr).family == AF_INET6) \
10128 rte_memcpy(&(ip), \
10129 &((ip_addr).addr.ipv6), \
10130 sizeof(struct in6_addr)); \
10132 printf("invalid parameter.\n"); \
10137 #ifdef RTE_NET_I40E
10140 str2flowtype(char *string)
10143 static const struct {
10146 } flowtype_str[] = {
10147 {"raw", RTE_ETH_FLOW_RAW},
10148 {"ipv4", RTE_ETH_FLOW_IPV4},
10149 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10150 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10151 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10152 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10153 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10154 {"ipv6", RTE_ETH_FLOW_IPV6},
10155 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10156 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10157 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10158 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10159 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10160 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10163 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
10164 if (!strcmp(flowtype_str[i].str, string))
10165 return flowtype_str[i].type;
10168 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
10169 return (uint16_t)atoi(string);
10171 return RTE_ETH_FLOW_UNKNOWN;
10174 /* *** deal with flow director filter *** */
10175 struct cmd_flow_director_result {
10176 cmdline_fixed_string_t flow_director_filter;
10178 cmdline_fixed_string_t mode;
10179 cmdline_fixed_string_t mode_value;
10180 cmdline_fixed_string_t ops;
10181 cmdline_fixed_string_t flow;
10182 cmdline_fixed_string_t flow_type;
10183 cmdline_fixed_string_t drop;
10184 cmdline_fixed_string_t queue;
10186 cmdline_fixed_string_t fd_id;
10187 uint32_t fd_id_value;
10188 cmdline_fixed_string_t packet;
10193 cmd_flow_director_filter_parsed(void *parsed_result,
10194 __rte_unused struct cmdline *cl,
10195 __rte_unused void *data)
10197 struct cmd_flow_director_result *res = parsed_result;
10199 struct rte_pmd_i40e_flow_type_mapping
10200 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
10201 struct rte_pmd_i40e_pkt_template_conf conf;
10202 uint16_t flow_type = str2flowtype(res->flow_type);
10203 uint16_t i, port = res->port_id;
10206 memset(&conf, 0, sizeof(conf));
10208 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
10209 printf("Invalid flow type specified.\n");
10212 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
10216 if (mapping[flow_type].pctype == 0ULL) {
10217 printf("Invalid flow type specified.\n");
10220 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
10221 if (mapping[flow_type].pctype & (1ULL << i)) {
10222 conf.input.pctype = i;
10227 conf.input.packet = open_file(res->filepath,
10228 &conf.input.length);
10229 if (!conf.input.packet)
10231 if (!strcmp(res->drop, "drop"))
10232 conf.action.behavior =
10233 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
10235 conf.action.behavior =
10236 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
10237 conf.action.report_status =
10238 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
10239 conf.action.rx_queue = res->queue_id;
10240 conf.soft_id = res->fd_id_value;
10241 add = strcmp(res->ops, "del") ? 1 : 0;
10242 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
10246 printf("flow director config error: (%s)\n",
10248 close_file(conf.input.packet);
10251 cmdline_parse_token_string_t cmd_flow_director_filter =
10252 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10253 flow_director_filter, "flow_director_filter");
10254 cmdline_parse_token_num_t cmd_flow_director_port_id =
10255 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10256 port_id, RTE_UINT16);
10257 cmdline_parse_token_string_t cmd_flow_director_ops =
10258 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10259 ops, "add#del#update");
10260 cmdline_parse_token_string_t cmd_flow_director_flow =
10261 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10263 cmdline_parse_token_string_t cmd_flow_director_flow_type =
10264 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10266 cmdline_parse_token_string_t cmd_flow_director_drop =
10267 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10269 cmdline_parse_token_string_t cmd_flow_director_queue =
10270 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10272 cmdline_parse_token_num_t cmd_flow_director_queue_id =
10273 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10274 queue_id, RTE_UINT16);
10275 cmdline_parse_token_string_t cmd_flow_director_fd_id =
10276 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10278 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
10279 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10280 fd_id_value, RTE_UINT32);
10282 cmdline_parse_token_string_t cmd_flow_director_mode =
10283 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10285 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
10286 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10287 mode_value, "raw");
10288 cmdline_parse_token_string_t cmd_flow_director_packet =
10289 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10291 cmdline_parse_token_string_t cmd_flow_director_filepath =
10292 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10295 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
10296 .f = cmd_flow_director_filter_parsed,
10298 .help_str = "flow_director_filter ... : Add or delete a raw flow "
10299 "director entry on NIC",
10301 (void *)&cmd_flow_director_filter,
10302 (void *)&cmd_flow_director_port_id,
10303 (void *)&cmd_flow_director_mode,
10304 (void *)&cmd_flow_director_mode_raw,
10305 (void *)&cmd_flow_director_ops,
10306 (void *)&cmd_flow_director_flow,
10307 (void *)&cmd_flow_director_flow_type,
10308 (void *)&cmd_flow_director_drop,
10309 (void *)&cmd_flow_director_queue,
10310 (void *)&cmd_flow_director_queue_id,
10311 (void *)&cmd_flow_director_fd_id,
10312 (void *)&cmd_flow_director_fd_id_value,
10313 (void *)&cmd_flow_director_packet,
10314 (void *)&cmd_flow_director_filepath,
10319 #endif /* RTE_NET_I40E */
10321 /* *** deal with flow director mask *** */
10322 struct cmd_flow_director_mask_result {
10323 cmdline_fixed_string_t flow_director_mask;
10325 cmdline_fixed_string_t mode;
10326 cmdline_fixed_string_t mode_value;
10327 cmdline_fixed_string_t vlan;
10328 uint16_t vlan_mask;
10329 cmdline_fixed_string_t src_mask;
10330 cmdline_ipaddr_t ipv4_src;
10331 cmdline_ipaddr_t ipv6_src;
10333 cmdline_fixed_string_t dst_mask;
10334 cmdline_ipaddr_t ipv4_dst;
10335 cmdline_ipaddr_t ipv6_dst;
10337 cmdline_fixed_string_t mac;
10338 uint8_t mac_addr_byte_mask;
10339 cmdline_fixed_string_t tunnel_id;
10340 uint32_t tunnel_id_mask;
10341 cmdline_fixed_string_t tunnel_type;
10342 uint8_t tunnel_type_mask;
10346 cmd_flow_director_mask_parsed(void *parsed_result,
10347 __rte_unused struct cmdline *cl,
10348 __rte_unused void *data)
10350 struct cmd_flow_director_mask_result *res = parsed_result;
10351 struct rte_eth_fdir_masks *mask;
10352 struct rte_port *port;
10354 port = &ports[res->port_id];
10355 /** Check if the port is not started **/
10356 if (port->port_status != RTE_PORT_STOPPED) {
10357 printf("Please stop port %d first\n", res->port_id);
10361 mask = &port->dev_conf.fdir_conf.mask;
10363 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10364 if (strcmp(res->mode_value, "MAC-VLAN")) {
10365 printf("Please set mode to MAC-VLAN.\n");
10369 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10370 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10371 if (strcmp(res->mode_value, "Tunnel")) {
10372 printf("Please set mode to Tunnel.\n");
10376 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10377 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
10378 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
10379 mask->tunnel_type_mask = res->tunnel_type_mask;
10381 if (strcmp(res->mode_value, "IP")) {
10382 printf("Please set mode to IP.\n");
10386 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10387 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
10388 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
10389 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
10390 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
10391 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
10392 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
10395 cmd_reconfig_device_queue(res->port_id, 1, 1);
10398 cmdline_parse_token_string_t cmd_flow_director_mask =
10399 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10400 flow_director_mask, "flow_director_mask");
10401 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
10402 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10403 port_id, RTE_UINT16);
10404 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
10405 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10407 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
10408 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10409 vlan_mask, RTE_UINT16);
10410 cmdline_parse_token_string_t cmd_flow_director_mask_src =
10411 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10412 src_mask, "src_mask");
10413 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
10414 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10416 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
10417 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10419 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
10420 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10421 port_src, RTE_UINT16);
10422 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
10423 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10424 dst_mask, "dst_mask");
10425 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
10426 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10428 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
10429 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10431 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
10432 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10433 port_dst, RTE_UINT16);
10435 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
10436 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10438 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
10439 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10441 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
10442 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10443 mode_value, "MAC-VLAN");
10444 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
10445 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10446 mode_value, "Tunnel");
10447 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
10448 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10450 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
10451 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10452 mac_addr_byte_mask, RTE_UINT8);
10453 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
10454 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10455 tunnel_type, "tunnel-type");
10456 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
10457 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10458 tunnel_type_mask, RTE_UINT8);
10459 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
10460 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10461 tunnel_id, "tunnel-id");
10462 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
10463 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10464 tunnel_id_mask, RTE_UINT32);
10466 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
10467 .f = cmd_flow_director_mask_parsed,
10469 .help_str = "flow_director_mask ... : "
10470 "Set IP mode flow director's mask on NIC",
10472 (void *)&cmd_flow_director_mask,
10473 (void *)&cmd_flow_director_mask_port_id,
10474 (void *)&cmd_flow_director_mask_mode,
10475 (void *)&cmd_flow_director_mask_mode_ip,
10476 (void *)&cmd_flow_director_mask_vlan,
10477 (void *)&cmd_flow_director_mask_vlan_value,
10478 (void *)&cmd_flow_director_mask_src,
10479 (void *)&cmd_flow_director_mask_ipv4_src,
10480 (void *)&cmd_flow_director_mask_ipv6_src,
10481 (void *)&cmd_flow_director_mask_port_src,
10482 (void *)&cmd_flow_director_mask_dst,
10483 (void *)&cmd_flow_director_mask_ipv4_dst,
10484 (void *)&cmd_flow_director_mask_ipv6_dst,
10485 (void *)&cmd_flow_director_mask_port_dst,
10490 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
10491 .f = cmd_flow_director_mask_parsed,
10493 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
10494 "flow director's mask on NIC",
10496 (void *)&cmd_flow_director_mask,
10497 (void *)&cmd_flow_director_mask_port_id,
10498 (void *)&cmd_flow_director_mask_mode,
10499 (void *)&cmd_flow_director_mask_mode_mac_vlan,
10500 (void *)&cmd_flow_director_mask_vlan,
10501 (void *)&cmd_flow_director_mask_vlan_value,
10506 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
10507 .f = cmd_flow_director_mask_parsed,
10509 .help_str = "flow_director_mask ... : Set tunnel mode "
10510 "flow director's mask on NIC",
10512 (void *)&cmd_flow_director_mask,
10513 (void *)&cmd_flow_director_mask_port_id,
10514 (void *)&cmd_flow_director_mask_mode,
10515 (void *)&cmd_flow_director_mask_mode_tunnel,
10516 (void *)&cmd_flow_director_mask_vlan,
10517 (void *)&cmd_flow_director_mask_vlan_value,
10518 (void *)&cmd_flow_director_mask_mac,
10519 (void *)&cmd_flow_director_mask_mac_value,
10520 (void *)&cmd_flow_director_mask_tunnel_type,
10521 (void *)&cmd_flow_director_mask_tunnel_type_value,
10522 (void *)&cmd_flow_director_mask_tunnel_id,
10523 (void *)&cmd_flow_director_mask_tunnel_id_value,
10528 /* *** deal with flow director flexible payload configuration *** */
10529 struct cmd_flow_director_flexpayload_result {
10530 cmdline_fixed_string_t flow_director_flexpayload;
10532 cmdline_fixed_string_t payload_layer;
10533 cmdline_fixed_string_t payload_cfg;
10537 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
10540 const char *p, *p0 = q_arg;
10542 unsigned long int_fld;
10543 char *str_fld[max_num];
10548 p = strchr(p0, '(');
10552 p0 = strchr(p, ')');
10557 if (size >= sizeof(s))
10560 snprintf(s, sizeof(s), "%.*s", size, p);
10561 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10562 if (ret < 0 || ret > max_num)
10564 for (i = 0; i < ret; i++) {
10566 int_fld = strtoul(str_fld[i], &end, 0);
10567 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
10569 offsets[i] = (uint16_t)int_fld;
10575 cmd_flow_director_flxpld_parsed(void *parsed_result,
10576 __rte_unused struct cmdline *cl,
10577 __rte_unused void *data)
10579 struct cmd_flow_director_flexpayload_result *res = parsed_result;
10580 struct rte_eth_flex_payload_cfg flex_cfg;
10581 struct rte_port *port;
10584 port = &ports[res->port_id];
10585 /** Check if the port is not started **/
10586 if (port->port_status != RTE_PORT_STOPPED) {
10587 printf("Please stop port %d first\n", res->port_id);
10591 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
10593 if (!strcmp(res->payload_layer, "raw"))
10594 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
10595 else if (!strcmp(res->payload_layer, "l2"))
10596 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
10597 else if (!strcmp(res->payload_layer, "l3"))
10598 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
10599 else if (!strcmp(res->payload_layer, "l4"))
10600 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
10602 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
10603 RTE_ETH_FDIR_MAX_FLEXLEN);
10605 printf("error: Cannot parse flex payload input.\n");
10609 fdir_set_flex_payload(res->port_id, &flex_cfg);
10610 cmd_reconfig_device_queue(res->port_id, 1, 1);
10613 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
10614 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10615 flow_director_flexpayload,
10616 "flow_director_flex_payload");
10617 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
10618 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10619 port_id, RTE_UINT16);
10620 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
10621 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10622 payload_layer, "raw#l2#l3#l4");
10623 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
10624 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10625 payload_cfg, NULL);
10627 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
10628 .f = cmd_flow_director_flxpld_parsed,
10630 .help_str = "flow_director_flexpayload ... : "
10631 "Set flow director's flex payload on NIC",
10633 (void *)&cmd_flow_director_flexpayload,
10634 (void *)&cmd_flow_director_flexpayload_port_id,
10635 (void *)&cmd_flow_director_flexpayload_payload_layer,
10636 (void *)&cmd_flow_director_flexpayload_payload_cfg,
10641 /* Generic flow interface command. */
10642 extern cmdline_parse_inst_t cmd_flow;
10644 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
10645 struct cmd_mcast_addr_result {
10646 cmdline_fixed_string_t mcast_addr_cmd;
10647 cmdline_fixed_string_t what;
10649 struct rte_ether_addr mc_addr;
10652 static void cmd_mcast_addr_parsed(void *parsed_result,
10653 __rte_unused struct cmdline *cl,
10654 __rte_unused void *data)
10656 struct cmd_mcast_addr_result *res = parsed_result;
10658 if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
10659 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
10660 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
10661 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
10662 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
10665 if (strcmp(res->what, "add") == 0)
10666 mcast_addr_add(res->port_num, &res->mc_addr);
10668 mcast_addr_remove(res->port_num, &res->mc_addr);
10671 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
10672 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
10673 mcast_addr_cmd, "mcast_addr");
10674 cmdline_parse_token_string_t cmd_mcast_addr_what =
10675 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
10677 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
10678 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num,
10680 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
10681 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
10683 cmdline_parse_inst_t cmd_mcast_addr = {
10684 .f = cmd_mcast_addr_parsed,
10686 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
10687 "Add/Remove multicast MAC address on port_id",
10689 (void *)&cmd_mcast_addr_cmd,
10690 (void *)&cmd_mcast_addr_what,
10691 (void *)&cmd_mcast_addr_portnum,
10692 (void *)&cmd_mcast_addr_addr,
10697 /* vf vlan anti spoof configuration */
10699 /* Common result structure for vf vlan anti spoof */
10700 struct cmd_vf_vlan_anti_spoof_result {
10701 cmdline_fixed_string_t set;
10702 cmdline_fixed_string_t vf;
10703 cmdline_fixed_string_t vlan;
10704 cmdline_fixed_string_t antispoof;
10707 cmdline_fixed_string_t on_off;
10710 /* Common CLI fields for vf vlan anti spoof enable disable */
10711 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
10712 TOKEN_STRING_INITIALIZER
10713 (struct cmd_vf_vlan_anti_spoof_result,
10715 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
10716 TOKEN_STRING_INITIALIZER
10717 (struct cmd_vf_vlan_anti_spoof_result,
10719 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
10720 TOKEN_STRING_INITIALIZER
10721 (struct cmd_vf_vlan_anti_spoof_result,
10723 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
10724 TOKEN_STRING_INITIALIZER
10725 (struct cmd_vf_vlan_anti_spoof_result,
10726 antispoof, "antispoof");
10727 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
10728 TOKEN_NUM_INITIALIZER
10729 (struct cmd_vf_vlan_anti_spoof_result,
10730 port_id, RTE_UINT16);
10731 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
10732 TOKEN_NUM_INITIALIZER
10733 (struct cmd_vf_vlan_anti_spoof_result,
10734 vf_id, RTE_UINT32);
10735 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
10736 TOKEN_STRING_INITIALIZER
10737 (struct cmd_vf_vlan_anti_spoof_result,
10741 cmd_set_vf_vlan_anti_spoof_parsed(
10742 void *parsed_result,
10743 __rte_unused struct cmdline *cl,
10744 __rte_unused void *data)
10746 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
10747 int ret = -ENOTSUP;
10749 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
10751 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10754 #ifdef RTE_NET_IXGBE
10755 if (ret == -ENOTSUP)
10756 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
10757 res->vf_id, is_on);
10759 #ifdef RTE_NET_I40E
10760 if (ret == -ENOTSUP)
10761 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
10762 res->vf_id, is_on);
10764 #ifdef RTE_NET_BNXT
10765 if (ret == -ENOTSUP)
10766 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
10767 res->vf_id, is_on);
10774 printf("invalid vf_id %d\n", res->vf_id);
10777 printf("invalid port_id %d\n", res->port_id);
10780 printf("function not implemented\n");
10783 printf("programming error: (%s)\n", strerror(-ret));
10787 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
10788 .f = cmd_set_vf_vlan_anti_spoof_parsed,
10790 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
10792 (void *)&cmd_vf_vlan_anti_spoof_set,
10793 (void *)&cmd_vf_vlan_anti_spoof_vf,
10794 (void *)&cmd_vf_vlan_anti_spoof_vlan,
10795 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
10796 (void *)&cmd_vf_vlan_anti_spoof_port_id,
10797 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
10798 (void *)&cmd_vf_vlan_anti_spoof_on_off,
10803 /* vf mac anti spoof configuration */
10805 /* Common result structure for vf mac anti spoof */
10806 struct cmd_vf_mac_anti_spoof_result {
10807 cmdline_fixed_string_t set;
10808 cmdline_fixed_string_t vf;
10809 cmdline_fixed_string_t mac;
10810 cmdline_fixed_string_t antispoof;
10813 cmdline_fixed_string_t on_off;
10816 /* Common CLI fields for vf mac anti spoof enable disable */
10817 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
10818 TOKEN_STRING_INITIALIZER
10819 (struct cmd_vf_mac_anti_spoof_result,
10821 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
10822 TOKEN_STRING_INITIALIZER
10823 (struct cmd_vf_mac_anti_spoof_result,
10825 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
10826 TOKEN_STRING_INITIALIZER
10827 (struct cmd_vf_mac_anti_spoof_result,
10829 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
10830 TOKEN_STRING_INITIALIZER
10831 (struct cmd_vf_mac_anti_spoof_result,
10832 antispoof, "antispoof");
10833 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
10834 TOKEN_NUM_INITIALIZER
10835 (struct cmd_vf_mac_anti_spoof_result,
10836 port_id, RTE_UINT16);
10837 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
10838 TOKEN_NUM_INITIALIZER
10839 (struct cmd_vf_mac_anti_spoof_result,
10840 vf_id, RTE_UINT32);
10841 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
10842 TOKEN_STRING_INITIALIZER
10843 (struct cmd_vf_mac_anti_spoof_result,
10847 cmd_set_vf_mac_anti_spoof_parsed(
10848 void *parsed_result,
10849 __rte_unused struct cmdline *cl,
10850 __rte_unused void *data)
10852 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
10853 int ret = -ENOTSUP;
10855 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
10857 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10860 #ifdef RTE_NET_IXGBE
10861 if (ret == -ENOTSUP)
10862 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
10863 res->vf_id, is_on);
10865 #ifdef RTE_NET_I40E
10866 if (ret == -ENOTSUP)
10867 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
10868 res->vf_id, is_on);
10870 #ifdef RTE_NET_BNXT
10871 if (ret == -ENOTSUP)
10872 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
10873 res->vf_id, is_on);
10880 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
10883 printf("invalid port_id %d\n", res->port_id);
10886 printf("function not implemented\n");
10889 printf("programming error: (%s)\n", strerror(-ret));
10893 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
10894 .f = cmd_set_vf_mac_anti_spoof_parsed,
10896 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
10898 (void *)&cmd_vf_mac_anti_spoof_set,
10899 (void *)&cmd_vf_mac_anti_spoof_vf,
10900 (void *)&cmd_vf_mac_anti_spoof_mac,
10901 (void *)&cmd_vf_mac_anti_spoof_antispoof,
10902 (void *)&cmd_vf_mac_anti_spoof_port_id,
10903 (void *)&cmd_vf_mac_anti_spoof_vf_id,
10904 (void *)&cmd_vf_mac_anti_spoof_on_off,
10909 /* vf vlan strip queue configuration */
10911 /* Common result structure for vf mac anti spoof */
10912 struct cmd_vf_vlan_stripq_result {
10913 cmdline_fixed_string_t set;
10914 cmdline_fixed_string_t vf;
10915 cmdline_fixed_string_t vlan;
10916 cmdline_fixed_string_t stripq;
10919 cmdline_fixed_string_t on_off;
10922 /* Common CLI fields for vf vlan strip enable disable */
10923 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
10924 TOKEN_STRING_INITIALIZER
10925 (struct cmd_vf_vlan_stripq_result,
10927 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
10928 TOKEN_STRING_INITIALIZER
10929 (struct cmd_vf_vlan_stripq_result,
10931 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
10932 TOKEN_STRING_INITIALIZER
10933 (struct cmd_vf_vlan_stripq_result,
10935 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
10936 TOKEN_STRING_INITIALIZER
10937 (struct cmd_vf_vlan_stripq_result,
10939 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
10940 TOKEN_NUM_INITIALIZER
10941 (struct cmd_vf_vlan_stripq_result,
10942 port_id, RTE_UINT16);
10943 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
10944 TOKEN_NUM_INITIALIZER
10945 (struct cmd_vf_vlan_stripq_result,
10946 vf_id, RTE_UINT16);
10947 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
10948 TOKEN_STRING_INITIALIZER
10949 (struct cmd_vf_vlan_stripq_result,
10953 cmd_set_vf_vlan_stripq_parsed(
10954 void *parsed_result,
10955 __rte_unused struct cmdline *cl,
10956 __rte_unused void *data)
10958 struct cmd_vf_vlan_stripq_result *res = parsed_result;
10959 int ret = -ENOTSUP;
10961 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
10963 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10966 #ifdef RTE_NET_IXGBE
10967 if (ret == -ENOTSUP)
10968 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
10969 res->vf_id, is_on);
10971 #ifdef RTE_NET_I40E
10972 if (ret == -ENOTSUP)
10973 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
10974 res->vf_id, is_on);
10976 #ifdef RTE_NET_BNXT
10977 if (ret == -ENOTSUP)
10978 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
10979 res->vf_id, is_on);
10986 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
10989 printf("invalid port_id %d\n", res->port_id);
10992 printf("function not implemented\n");
10995 printf("programming error: (%s)\n", strerror(-ret));
10999 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
11000 .f = cmd_set_vf_vlan_stripq_parsed,
11002 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
11004 (void *)&cmd_vf_vlan_stripq_set,
11005 (void *)&cmd_vf_vlan_stripq_vf,
11006 (void *)&cmd_vf_vlan_stripq_vlan,
11007 (void *)&cmd_vf_vlan_stripq_stripq,
11008 (void *)&cmd_vf_vlan_stripq_port_id,
11009 (void *)&cmd_vf_vlan_stripq_vf_id,
11010 (void *)&cmd_vf_vlan_stripq_on_off,
11015 /* vf vlan insert configuration */
11017 /* Common result structure for vf vlan insert */
11018 struct cmd_vf_vlan_insert_result {
11019 cmdline_fixed_string_t set;
11020 cmdline_fixed_string_t vf;
11021 cmdline_fixed_string_t vlan;
11022 cmdline_fixed_string_t insert;
11028 /* Common CLI fields for vf vlan insert enable disable */
11029 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
11030 TOKEN_STRING_INITIALIZER
11031 (struct cmd_vf_vlan_insert_result,
11033 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
11034 TOKEN_STRING_INITIALIZER
11035 (struct cmd_vf_vlan_insert_result,
11037 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
11038 TOKEN_STRING_INITIALIZER
11039 (struct cmd_vf_vlan_insert_result,
11041 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
11042 TOKEN_STRING_INITIALIZER
11043 (struct cmd_vf_vlan_insert_result,
11045 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
11046 TOKEN_NUM_INITIALIZER
11047 (struct cmd_vf_vlan_insert_result,
11048 port_id, RTE_UINT16);
11049 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
11050 TOKEN_NUM_INITIALIZER
11051 (struct cmd_vf_vlan_insert_result,
11052 vf_id, RTE_UINT16);
11053 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
11054 TOKEN_NUM_INITIALIZER
11055 (struct cmd_vf_vlan_insert_result,
11056 vlan_id, RTE_UINT16);
11059 cmd_set_vf_vlan_insert_parsed(
11060 void *parsed_result,
11061 __rte_unused struct cmdline *cl,
11062 __rte_unused void *data)
11064 struct cmd_vf_vlan_insert_result *res = parsed_result;
11065 int ret = -ENOTSUP;
11067 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11070 #ifdef RTE_NET_IXGBE
11071 if (ret == -ENOTSUP)
11072 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
11075 #ifdef RTE_NET_I40E
11076 if (ret == -ENOTSUP)
11077 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
11080 #ifdef RTE_NET_BNXT
11081 if (ret == -ENOTSUP)
11082 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
11090 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
11093 printf("invalid port_id %d\n", res->port_id);
11096 printf("function not implemented\n");
11099 printf("programming error: (%s)\n", strerror(-ret));
11103 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
11104 .f = cmd_set_vf_vlan_insert_parsed,
11106 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
11108 (void *)&cmd_vf_vlan_insert_set,
11109 (void *)&cmd_vf_vlan_insert_vf,
11110 (void *)&cmd_vf_vlan_insert_vlan,
11111 (void *)&cmd_vf_vlan_insert_insert,
11112 (void *)&cmd_vf_vlan_insert_port_id,
11113 (void *)&cmd_vf_vlan_insert_vf_id,
11114 (void *)&cmd_vf_vlan_insert_vlan_id,
11119 /* tx loopback configuration */
11121 /* Common result structure for tx loopback */
11122 struct cmd_tx_loopback_result {
11123 cmdline_fixed_string_t set;
11124 cmdline_fixed_string_t tx;
11125 cmdline_fixed_string_t loopback;
11127 cmdline_fixed_string_t on_off;
11130 /* Common CLI fields for tx loopback enable disable */
11131 cmdline_parse_token_string_t cmd_tx_loopback_set =
11132 TOKEN_STRING_INITIALIZER
11133 (struct cmd_tx_loopback_result,
11135 cmdline_parse_token_string_t cmd_tx_loopback_tx =
11136 TOKEN_STRING_INITIALIZER
11137 (struct cmd_tx_loopback_result,
11139 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
11140 TOKEN_STRING_INITIALIZER
11141 (struct cmd_tx_loopback_result,
11142 loopback, "loopback");
11143 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
11144 TOKEN_NUM_INITIALIZER
11145 (struct cmd_tx_loopback_result,
11146 port_id, RTE_UINT16);
11147 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
11148 TOKEN_STRING_INITIALIZER
11149 (struct cmd_tx_loopback_result,
11153 cmd_set_tx_loopback_parsed(
11154 void *parsed_result,
11155 __rte_unused struct cmdline *cl,
11156 __rte_unused void *data)
11158 struct cmd_tx_loopback_result *res = parsed_result;
11159 int ret = -ENOTSUP;
11161 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11163 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11166 #ifdef RTE_NET_IXGBE
11167 if (ret == -ENOTSUP)
11168 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
11170 #ifdef RTE_NET_I40E
11171 if (ret == -ENOTSUP)
11172 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
11174 #ifdef RTE_NET_BNXT
11175 if (ret == -ENOTSUP)
11176 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
11178 #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA
11179 if (ret == -ENOTSUP)
11180 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
11187 printf("invalid is_on %d\n", is_on);
11190 printf("invalid port_id %d\n", res->port_id);
11193 printf("function not implemented\n");
11196 printf("programming error: (%s)\n", strerror(-ret));
11200 cmdline_parse_inst_t cmd_set_tx_loopback = {
11201 .f = cmd_set_tx_loopback_parsed,
11203 .help_str = "set tx loopback <port_id> on|off",
11205 (void *)&cmd_tx_loopback_set,
11206 (void *)&cmd_tx_loopback_tx,
11207 (void *)&cmd_tx_loopback_loopback,
11208 (void *)&cmd_tx_loopback_port_id,
11209 (void *)&cmd_tx_loopback_on_off,
11214 /* all queues drop enable configuration */
11216 /* Common result structure for all queues drop enable */
11217 struct cmd_all_queues_drop_en_result {
11218 cmdline_fixed_string_t set;
11219 cmdline_fixed_string_t all;
11220 cmdline_fixed_string_t queues;
11221 cmdline_fixed_string_t drop;
11223 cmdline_fixed_string_t on_off;
11226 /* Common CLI fields for tx loopback enable disable */
11227 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
11228 TOKEN_STRING_INITIALIZER
11229 (struct cmd_all_queues_drop_en_result,
11231 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
11232 TOKEN_STRING_INITIALIZER
11233 (struct cmd_all_queues_drop_en_result,
11235 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
11236 TOKEN_STRING_INITIALIZER
11237 (struct cmd_all_queues_drop_en_result,
11239 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
11240 TOKEN_STRING_INITIALIZER
11241 (struct cmd_all_queues_drop_en_result,
11243 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
11244 TOKEN_NUM_INITIALIZER
11245 (struct cmd_all_queues_drop_en_result,
11246 port_id, RTE_UINT16);
11247 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
11248 TOKEN_STRING_INITIALIZER
11249 (struct cmd_all_queues_drop_en_result,
11253 cmd_set_all_queues_drop_en_parsed(
11254 void *parsed_result,
11255 __rte_unused struct cmdline *cl,
11256 __rte_unused void *data)
11258 struct cmd_all_queues_drop_en_result *res = parsed_result;
11259 int ret = -ENOTSUP;
11260 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11262 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11265 #ifdef RTE_NET_IXGBE
11266 if (ret == -ENOTSUP)
11267 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
11269 #ifdef RTE_NET_BNXT
11270 if (ret == -ENOTSUP)
11271 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
11277 printf("invalid is_on %d\n", is_on);
11280 printf("invalid port_id %d\n", res->port_id);
11283 printf("function not implemented\n");
11286 printf("programming error: (%s)\n", strerror(-ret));
11290 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
11291 .f = cmd_set_all_queues_drop_en_parsed,
11293 .help_str = "set all queues drop <port_id> on|off",
11295 (void *)&cmd_all_queues_drop_en_set,
11296 (void *)&cmd_all_queues_drop_en_all,
11297 (void *)&cmd_all_queues_drop_en_queues,
11298 (void *)&cmd_all_queues_drop_en_drop,
11299 (void *)&cmd_all_queues_drop_en_port_id,
11300 (void *)&cmd_all_queues_drop_en_on_off,
11305 /* vf split drop enable configuration */
11307 /* Common result structure for vf split drop enable */
11308 struct cmd_vf_split_drop_en_result {
11309 cmdline_fixed_string_t set;
11310 cmdline_fixed_string_t vf;
11311 cmdline_fixed_string_t split;
11312 cmdline_fixed_string_t drop;
11315 cmdline_fixed_string_t on_off;
11318 /* Common CLI fields for vf split drop enable disable */
11319 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
11320 TOKEN_STRING_INITIALIZER
11321 (struct cmd_vf_split_drop_en_result,
11323 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
11324 TOKEN_STRING_INITIALIZER
11325 (struct cmd_vf_split_drop_en_result,
11327 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
11328 TOKEN_STRING_INITIALIZER
11329 (struct cmd_vf_split_drop_en_result,
11331 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
11332 TOKEN_STRING_INITIALIZER
11333 (struct cmd_vf_split_drop_en_result,
11335 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
11336 TOKEN_NUM_INITIALIZER
11337 (struct cmd_vf_split_drop_en_result,
11338 port_id, RTE_UINT16);
11339 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
11340 TOKEN_NUM_INITIALIZER
11341 (struct cmd_vf_split_drop_en_result,
11342 vf_id, RTE_UINT16);
11343 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
11344 TOKEN_STRING_INITIALIZER
11345 (struct cmd_vf_split_drop_en_result,
11349 cmd_set_vf_split_drop_en_parsed(
11350 void *parsed_result,
11351 __rte_unused struct cmdline *cl,
11352 __rte_unused void *data)
11354 struct cmd_vf_split_drop_en_result *res = parsed_result;
11355 int ret = -ENOTSUP;
11356 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11358 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11361 #ifdef RTE_NET_IXGBE
11362 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
11369 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11372 printf("invalid port_id %d\n", res->port_id);
11375 printf("not supported on port %d\n", res->port_id);
11378 printf("programming error: (%s)\n", strerror(-ret));
11382 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
11383 .f = cmd_set_vf_split_drop_en_parsed,
11385 .help_str = "set vf split drop <port_id> <vf_id> on|off",
11387 (void *)&cmd_vf_split_drop_en_set,
11388 (void *)&cmd_vf_split_drop_en_vf,
11389 (void *)&cmd_vf_split_drop_en_split,
11390 (void *)&cmd_vf_split_drop_en_drop,
11391 (void *)&cmd_vf_split_drop_en_port_id,
11392 (void *)&cmd_vf_split_drop_en_vf_id,
11393 (void *)&cmd_vf_split_drop_en_on_off,
11398 /* vf mac address configuration */
11400 /* Common result structure for vf mac address */
11401 struct cmd_set_vf_mac_addr_result {
11402 cmdline_fixed_string_t set;
11403 cmdline_fixed_string_t vf;
11404 cmdline_fixed_string_t mac;
11405 cmdline_fixed_string_t addr;
11408 struct rte_ether_addr mac_addr;
11412 /* Common CLI fields for vf split drop enable disable */
11413 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
11414 TOKEN_STRING_INITIALIZER
11415 (struct cmd_set_vf_mac_addr_result,
11417 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
11418 TOKEN_STRING_INITIALIZER
11419 (struct cmd_set_vf_mac_addr_result,
11421 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
11422 TOKEN_STRING_INITIALIZER
11423 (struct cmd_set_vf_mac_addr_result,
11425 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
11426 TOKEN_STRING_INITIALIZER
11427 (struct cmd_set_vf_mac_addr_result,
11429 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
11430 TOKEN_NUM_INITIALIZER
11431 (struct cmd_set_vf_mac_addr_result,
11432 port_id, RTE_UINT16);
11433 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
11434 TOKEN_NUM_INITIALIZER
11435 (struct cmd_set_vf_mac_addr_result,
11436 vf_id, RTE_UINT16);
11437 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
11438 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
11442 cmd_set_vf_mac_addr_parsed(
11443 void *parsed_result,
11444 __rte_unused struct cmdline *cl,
11445 __rte_unused void *data)
11447 struct cmd_set_vf_mac_addr_result *res = parsed_result;
11448 int ret = -ENOTSUP;
11450 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11453 #ifdef RTE_NET_IXGBE
11454 if (ret == -ENOTSUP)
11455 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
11458 #ifdef RTE_NET_I40E
11459 if (ret == -ENOTSUP)
11460 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
11463 #ifdef RTE_NET_BNXT
11464 if (ret == -ENOTSUP)
11465 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
11473 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
11476 printf("invalid port_id %d\n", res->port_id);
11479 printf("function not implemented\n");
11482 printf("programming error: (%s)\n", strerror(-ret));
11486 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
11487 .f = cmd_set_vf_mac_addr_parsed,
11489 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
11491 (void *)&cmd_set_vf_mac_addr_set,
11492 (void *)&cmd_set_vf_mac_addr_vf,
11493 (void *)&cmd_set_vf_mac_addr_mac,
11494 (void *)&cmd_set_vf_mac_addr_addr,
11495 (void *)&cmd_set_vf_mac_addr_port_id,
11496 (void *)&cmd_set_vf_mac_addr_vf_id,
11497 (void *)&cmd_set_vf_mac_addr_mac_addr,
11502 /* MACsec configuration */
11504 /* Common result structure for MACsec offload enable */
11505 struct cmd_macsec_offload_on_result {
11506 cmdline_fixed_string_t set;
11507 cmdline_fixed_string_t macsec;
11508 cmdline_fixed_string_t offload;
11510 cmdline_fixed_string_t on;
11511 cmdline_fixed_string_t encrypt;
11512 cmdline_fixed_string_t en_on_off;
11513 cmdline_fixed_string_t replay_protect;
11514 cmdline_fixed_string_t rp_on_off;
11517 /* Common CLI fields for MACsec offload disable */
11518 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
11519 TOKEN_STRING_INITIALIZER
11520 (struct cmd_macsec_offload_on_result,
11522 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
11523 TOKEN_STRING_INITIALIZER
11524 (struct cmd_macsec_offload_on_result,
11526 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
11527 TOKEN_STRING_INITIALIZER
11528 (struct cmd_macsec_offload_on_result,
11529 offload, "offload");
11530 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
11531 TOKEN_NUM_INITIALIZER
11532 (struct cmd_macsec_offload_on_result,
11533 port_id, RTE_UINT16);
11534 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
11535 TOKEN_STRING_INITIALIZER
11536 (struct cmd_macsec_offload_on_result,
11538 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
11539 TOKEN_STRING_INITIALIZER
11540 (struct cmd_macsec_offload_on_result,
11541 encrypt, "encrypt");
11542 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
11543 TOKEN_STRING_INITIALIZER
11544 (struct cmd_macsec_offload_on_result,
11545 en_on_off, "on#off");
11546 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
11547 TOKEN_STRING_INITIALIZER
11548 (struct cmd_macsec_offload_on_result,
11549 replay_protect, "replay-protect");
11550 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
11551 TOKEN_STRING_INITIALIZER
11552 (struct cmd_macsec_offload_on_result,
11553 rp_on_off, "on#off");
11556 cmd_set_macsec_offload_on_parsed(
11557 void *parsed_result,
11558 __rte_unused struct cmdline *cl,
11559 __rte_unused void *data)
11561 struct cmd_macsec_offload_on_result *res = parsed_result;
11562 int ret = -ENOTSUP;
11563 portid_t port_id = res->port_id;
11564 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
11565 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
11566 struct rte_eth_dev_info dev_info;
11568 if (port_id_is_invalid(port_id, ENABLED_WARN))
11570 if (!port_is_stopped(port_id)) {
11571 printf("Please stop port %d first\n", port_id);
11575 ret = eth_dev_info_get_print_err(port_id, &dev_info);
11579 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
11580 #ifdef RTE_NET_IXGBE
11581 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
11589 ports[port_id].dev_conf.txmode.offloads |=
11590 DEV_TX_OFFLOAD_MACSEC_INSERT;
11591 cmd_reconfig_device_queue(port_id, 1, 1);
11594 printf("invalid port_id %d\n", port_id);
11597 printf("not supported on port %d\n", port_id);
11600 printf("programming error: (%s)\n", strerror(-ret));
11604 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
11605 .f = cmd_set_macsec_offload_on_parsed,
11607 .help_str = "set macsec offload <port_id> on "
11608 "encrypt on|off replay-protect on|off",
11610 (void *)&cmd_macsec_offload_on_set,
11611 (void *)&cmd_macsec_offload_on_macsec,
11612 (void *)&cmd_macsec_offload_on_offload,
11613 (void *)&cmd_macsec_offload_on_port_id,
11614 (void *)&cmd_macsec_offload_on_on,
11615 (void *)&cmd_macsec_offload_on_encrypt,
11616 (void *)&cmd_macsec_offload_on_en_on_off,
11617 (void *)&cmd_macsec_offload_on_replay_protect,
11618 (void *)&cmd_macsec_offload_on_rp_on_off,
11623 /* Common result structure for MACsec offload disable */
11624 struct cmd_macsec_offload_off_result {
11625 cmdline_fixed_string_t set;
11626 cmdline_fixed_string_t macsec;
11627 cmdline_fixed_string_t offload;
11629 cmdline_fixed_string_t off;
11632 /* Common CLI fields for MACsec offload disable */
11633 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
11634 TOKEN_STRING_INITIALIZER
11635 (struct cmd_macsec_offload_off_result,
11637 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
11638 TOKEN_STRING_INITIALIZER
11639 (struct cmd_macsec_offload_off_result,
11641 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
11642 TOKEN_STRING_INITIALIZER
11643 (struct cmd_macsec_offload_off_result,
11644 offload, "offload");
11645 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
11646 TOKEN_NUM_INITIALIZER
11647 (struct cmd_macsec_offload_off_result,
11648 port_id, RTE_UINT16);
11649 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
11650 TOKEN_STRING_INITIALIZER
11651 (struct cmd_macsec_offload_off_result,
11655 cmd_set_macsec_offload_off_parsed(
11656 void *parsed_result,
11657 __rte_unused struct cmdline *cl,
11658 __rte_unused void *data)
11660 struct cmd_macsec_offload_off_result *res = parsed_result;
11661 int ret = -ENOTSUP;
11662 struct rte_eth_dev_info dev_info;
11663 portid_t port_id = res->port_id;
11665 if (port_id_is_invalid(port_id, ENABLED_WARN))
11667 if (!port_is_stopped(port_id)) {
11668 printf("Please stop port %d first\n", port_id);
11672 ret = eth_dev_info_get_print_err(port_id, &dev_info);
11676 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
11677 #ifdef RTE_NET_IXGBE
11678 ret = rte_pmd_ixgbe_macsec_disable(port_id);
11683 ports[port_id].dev_conf.txmode.offloads &=
11684 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
11685 cmd_reconfig_device_queue(port_id, 1, 1);
11688 printf("invalid port_id %d\n", port_id);
11691 printf("not supported on port %d\n", port_id);
11694 printf("programming error: (%s)\n", strerror(-ret));
11698 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
11699 .f = cmd_set_macsec_offload_off_parsed,
11701 .help_str = "set macsec offload <port_id> off",
11703 (void *)&cmd_macsec_offload_off_set,
11704 (void *)&cmd_macsec_offload_off_macsec,
11705 (void *)&cmd_macsec_offload_off_offload,
11706 (void *)&cmd_macsec_offload_off_port_id,
11707 (void *)&cmd_macsec_offload_off_off,
11712 /* Common result structure for MACsec secure connection configure */
11713 struct cmd_macsec_sc_result {
11714 cmdline_fixed_string_t set;
11715 cmdline_fixed_string_t macsec;
11716 cmdline_fixed_string_t sc;
11717 cmdline_fixed_string_t tx_rx;
11719 struct rte_ether_addr mac;
11723 /* Common CLI fields for MACsec secure connection configure */
11724 cmdline_parse_token_string_t cmd_macsec_sc_set =
11725 TOKEN_STRING_INITIALIZER
11726 (struct cmd_macsec_sc_result,
11728 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
11729 TOKEN_STRING_INITIALIZER
11730 (struct cmd_macsec_sc_result,
11732 cmdline_parse_token_string_t cmd_macsec_sc_sc =
11733 TOKEN_STRING_INITIALIZER
11734 (struct cmd_macsec_sc_result,
11736 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
11737 TOKEN_STRING_INITIALIZER
11738 (struct cmd_macsec_sc_result,
11740 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
11741 TOKEN_NUM_INITIALIZER
11742 (struct cmd_macsec_sc_result,
11743 port_id, RTE_UINT16);
11744 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
11745 TOKEN_ETHERADDR_INITIALIZER
11746 (struct cmd_macsec_sc_result,
11748 cmdline_parse_token_num_t cmd_macsec_sc_pi =
11749 TOKEN_NUM_INITIALIZER
11750 (struct cmd_macsec_sc_result,
11754 cmd_set_macsec_sc_parsed(
11755 void *parsed_result,
11756 __rte_unused struct cmdline *cl,
11757 __rte_unused void *data)
11759 struct cmd_macsec_sc_result *res = parsed_result;
11760 int ret = -ENOTSUP;
11761 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
11763 #ifdef RTE_NET_IXGBE
11765 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
11766 res->mac.addr_bytes) :
11767 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
11768 res->mac.addr_bytes, res->pi);
11770 RTE_SET_USED(is_tx);
11776 printf("invalid port_id %d\n", res->port_id);
11779 printf("not supported on port %d\n", res->port_id);
11782 printf("programming error: (%s)\n", strerror(-ret));
11786 cmdline_parse_inst_t cmd_set_macsec_sc = {
11787 .f = cmd_set_macsec_sc_parsed,
11789 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
11791 (void *)&cmd_macsec_sc_set,
11792 (void *)&cmd_macsec_sc_macsec,
11793 (void *)&cmd_macsec_sc_sc,
11794 (void *)&cmd_macsec_sc_tx_rx,
11795 (void *)&cmd_macsec_sc_port_id,
11796 (void *)&cmd_macsec_sc_mac,
11797 (void *)&cmd_macsec_sc_pi,
11802 /* Common result structure for MACsec secure connection configure */
11803 struct cmd_macsec_sa_result {
11804 cmdline_fixed_string_t set;
11805 cmdline_fixed_string_t macsec;
11806 cmdline_fixed_string_t sa;
11807 cmdline_fixed_string_t tx_rx;
11812 cmdline_fixed_string_t key;
11815 /* Common CLI fields for MACsec secure connection configure */
11816 cmdline_parse_token_string_t cmd_macsec_sa_set =
11817 TOKEN_STRING_INITIALIZER
11818 (struct cmd_macsec_sa_result,
11820 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
11821 TOKEN_STRING_INITIALIZER
11822 (struct cmd_macsec_sa_result,
11824 cmdline_parse_token_string_t cmd_macsec_sa_sa =
11825 TOKEN_STRING_INITIALIZER
11826 (struct cmd_macsec_sa_result,
11828 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
11829 TOKEN_STRING_INITIALIZER
11830 (struct cmd_macsec_sa_result,
11832 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
11833 TOKEN_NUM_INITIALIZER
11834 (struct cmd_macsec_sa_result,
11835 port_id, RTE_UINT16);
11836 cmdline_parse_token_num_t cmd_macsec_sa_idx =
11837 TOKEN_NUM_INITIALIZER
11838 (struct cmd_macsec_sa_result,
11840 cmdline_parse_token_num_t cmd_macsec_sa_an =
11841 TOKEN_NUM_INITIALIZER
11842 (struct cmd_macsec_sa_result,
11844 cmdline_parse_token_num_t cmd_macsec_sa_pn =
11845 TOKEN_NUM_INITIALIZER
11846 (struct cmd_macsec_sa_result,
11848 cmdline_parse_token_string_t cmd_macsec_sa_key =
11849 TOKEN_STRING_INITIALIZER
11850 (struct cmd_macsec_sa_result,
11854 cmd_set_macsec_sa_parsed(
11855 void *parsed_result,
11856 __rte_unused struct cmdline *cl,
11857 __rte_unused void *data)
11859 struct cmd_macsec_sa_result *res = parsed_result;
11860 int ret = -ENOTSUP;
11861 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
11862 uint8_t key[16] = { 0 };
11868 key_len = strlen(res->key) / 2;
11872 for (i = 0; i < key_len; i++) {
11873 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
11876 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
11879 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
11882 #ifdef RTE_NET_IXGBE
11884 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
11885 res->idx, res->an, res->pn, key) :
11886 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
11887 res->idx, res->an, res->pn, key);
11889 RTE_SET_USED(is_tx);
11896 printf("invalid idx %d or an %d\n", res->idx, res->an);
11899 printf("invalid port_id %d\n", res->port_id);
11902 printf("not supported on port %d\n", res->port_id);
11905 printf("programming error: (%s)\n", strerror(-ret));
11909 cmdline_parse_inst_t cmd_set_macsec_sa = {
11910 .f = cmd_set_macsec_sa_parsed,
11912 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
11914 (void *)&cmd_macsec_sa_set,
11915 (void *)&cmd_macsec_sa_macsec,
11916 (void *)&cmd_macsec_sa_sa,
11917 (void *)&cmd_macsec_sa_tx_rx,
11918 (void *)&cmd_macsec_sa_port_id,
11919 (void *)&cmd_macsec_sa_idx,
11920 (void *)&cmd_macsec_sa_an,
11921 (void *)&cmd_macsec_sa_pn,
11922 (void *)&cmd_macsec_sa_key,
11927 /* VF unicast promiscuous mode configuration */
11929 /* Common result structure for VF unicast promiscuous mode */
11930 struct cmd_vf_promisc_result {
11931 cmdline_fixed_string_t set;
11932 cmdline_fixed_string_t vf;
11933 cmdline_fixed_string_t promisc;
11936 cmdline_fixed_string_t on_off;
11939 /* Common CLI fields for VF unicast promiscuous mode enable disable */
11940 cmdline_parse_token_string_t cmd_vf_promisc_set =
11941 TOKEN_STRING_INITIALIZER
11942 (struct cmd_vf_promisc_result,
11944 cmdline_parse_token_string_t cmd_vf_promisc_vf =
11945 TOKEN_STRING_INITIALIZER
11946 (struct cmd_vf_promisc_result,
11948 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
11949 TOKEN_STRING_INITIALIZER
11950 (struct cmd_vf_promisc_result,
11951 promisc, "promisc");
11952 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
11953 TOKEN_NUM_INITIALIZER
11954 (struct cmd_vf_promisc_result,
11955 port_id, RTE_UINT16);
11956 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
11957 TOKEN_NUM_INITIALIZER
11958 (struct cmd_vf_promisc_result,
11959 vf_id, RTE_UINT32);
11960 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
11961 TOKEN_STRING_INITIALIZER
11962 (struct cmd_vf_promisc_result,
11966 cmd_set_vf_promisc_parsed(
11967 void *parsed_result,
11968 __rte_unused struct cmdline *cl,
11969 __rte_unused void *data)
11971 struct cmd_vf_promisc_result *res = parsed_result;
11972 int ret = -ENOTSUP;
11974 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11976 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11979 #ifdef RTE_NET_I40E
11980 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
11981 res->vf_id, is_on);
11988 printf("invalid vf_id %d\n", res->vf_id);
11991 printf("invalid port_id %d\n", res->port_id);
11994 printf("function not implemented\n");
11997 printf("programming error: (%s)\n", strerror(-ret));
12001 cmdline_parse_inst_t cmd_set_vf_promisc = {
12002 .f = cmd_set_vf_promisc_parsed,
12004 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
12005 "Set unicast promiscuous mode for a VF from the PF",
12007 (void *)&cmd_vf_promisc_set,
12008 (void *)&cmd_vf_promisc_vf,
12009 (void *)&cmd_vf_promisc_promisc,
12010 (void *)&cmd_vf_promisc_port_id,
12011 (void *)&cmd_vf_promisc_vf_id,
12012 (void *)&cmd_vf_promisc_on_off,
12017 /* VF multicast promiscuous mode configuration */
12019 /* Common result structure for VF multicast promiscuous mode */
12020 struct cmd_vf_allmulti_result {
12021 cmdline_fixed_string_t set;
12022 cmdline_fixed_string_t vf;
12023 cmdline_fixed_string_t allmulti;
12026 cmdline_fixed_string_t on_off;
12029 /* Common CLI fields for VF multicast promiscuous mode enable disable */
12030 cmdline_parse_token_string_t cmd_vf_allmulti_set =
12031 TOKEN_STRING_INITIALIZER
12032 (struct cmd_vf_allmulti_result,
12034 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
12035 TOKEN_STRING_INITIALIZER
12036 (struct cmd_vf_allmulti_result,
12038 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
12039 TOKEN_STRING_INITIALIZER
12040 (struct cmd_vf_allmulti_result,
12041 allmulti, "allmulti");
12042 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
12043 TOKEN_NUM_INITIALIZER
12044 (struct cmd_vf_allmulti_result,
12045 port_id, RTE_UINT16);
12046 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
12047 TOKEN_NUM_INITIALIZER
12048 (struct cmd_vf_allmulti_result,
12049 vf_id, RTE_UINT32);
12050 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
12051 TOKEN_STRING_INITIALIZER
12052 (struct cmd_vf_allmulti_result,
12056 cmd_set_vf_allmulti_parsed(
12057 void *parsed_result,
12058 __rte_unused struct cmdline *cl,
12059 __rte_unused void *data)
12061 struct cmd_vf_allmulti_result *res = parsed_result;
12062 int ret = -ENOTSUP;
12064 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12066 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12069 #ifdef RTE_NET_I40E
12070 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
12071 res->vf_id, is_on);
12078 printf("invalid vf_id %d\n", res->vf_id);
12081 printf("invalid port_id %d\n", res->port_id);
12084 printf("function not implemented\n");
12087 printf("programming error: (%s)\n", strerror(-ret));
12091 cmdline_parse_inst_t cmd_set_vf_allmulti = {
12092 .f = cmd_set_vf_allmulti_parsed,
12094 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
12095 "Set multicast promiscuous mode for a VF from the PF",
12097 (void *)&cmd_vf_allmulti_set,
12098 (void *)&cmd_vf_allmulti_vf,
12099 (void *)&cmd_vf_allmulti_allmulti,
12100 (void *)&cmd_vf_allmulti_port_id,
12101 (void *)&cmd_vf_allmulti_vf_id,
12102 (void *)&cmd_vf_allmulti_on_off,
12107 /* vf broadcast mode configuration */
12109 /* Common result structure for vf broadcast */
12110 struct cmd_set_vf_broadcast_result {
12111 cmdline_fixed_string_t set;
12112 cmdline_fixed_string_t vf;
12113 cmdline_fixed_string_t broadcast;
12116 cmdline_fixed_string_t on_off;
12119 /* Common CLI fields for vf broadcast enable disable */
12120 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
12121 TOKEN_STRING_INITIALIZER
12122 (struct cmd_set_vf_broadcast_result,
12124 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
12125 TOKEN_STRING_INITIALIZER
12126 (struct cmd_set_vf_broadcast_result,
12128 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
12129 TOKEN_STRING_INITIALIZER
12130 (struct cmd_set_vf_broadcast_result,
12131 broadcast, "broadcast");
12132 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
12133 TOKEN_NUM_INITIALIZER
12134 (struct cmd_set_vf_broadcast_result,
12135 port_id, RTE_UINT16);
12136 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
12137 TOKEN_NUM_INITIALIZER
12138 (struct cmd_set_vf_broadcast_result,
12139 vf_id, RTE_UINT16);
12140 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
12141 TOKEN_STRING_INITIALIZER
12142 (struct cmd_set_vf_broadcast_result,
12146 cmd_set_vf_broadcast_parsed(
12147 void *parsed_result,
12148 __rte_unused struct cmdline *cl,
12149 __rte_unused void *data)
12151 struct cmd_set_vf_broadcast_result *res = parsed_result;
12152 int ret = -ENOTSUP;
12154 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12156 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12159 #ifdef RTE_NET_I40E
12160 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
12161 res->vf_id, is_on);
12168 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12171 printf("invalid port_id %d\n", res->port_id);
12174 printf("function not implemented\n");
12177 printf("programming error: (%s)\n", strerror(-ret));
12181 cmdline_parse_inst_t cmd_set_vf_broadcast = {
12182 .f = cmd_set_vf_broadcast_parsed,
12184 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
12186 (void *)&cmd_set_vf_broadcast_set,
12187 (void *)&cmd_set_vf_broadcast_vf,
12188 (void *)&cmd_set_vf_broadcast_broadcast,
12189 (void *)&cmd_set_vf_broadcast_port_id,
12190 (void *)&cmd_set_vf_broadcast_vf_id,
12191 (void *)&cmd_set_vf_broadcast_on_off,
12196 /* vf vlan tag configuration */
12198 /* Common result structure for vf vlan tag */
12199 struct cmd_set_vf_vlan_tag_result {
12200 cmdline_fixed_string_t set;
12201 cmdline_fixed_string_t vf;
12202 cmdline_fixed_string_t vlan;
12203 cmdline_fixed_string_t tag;
12206 cmdline_fixed_string_t on_off;
12209 /* Common CLI fields for vf vlan tag enable disable */
12210 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
12211 TOKEN_STRING_INITIALIZER
12212 (struct cmd_set_vf_vlan_tag_result,
12214 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
12215 TOKEN_STRING_INITIALIZER
12216 (struct cmd_set_vf_vlan_tag_result,
12218 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
12219 TOKEN_STRING_INITIALIZER
12220 (struct cmd_set_vf_vlan_tag_result,
12222 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
12223 TOKEN_STRING_INITIALIZER
12224 (struct cmd_set_vf_vlan_tag_result,
12226 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
12227 TOKEN_NUM_INITIALIZER
12228 (struct cmd_set_vf_vlan_tag_result,
12229 port_id, RTE_UINT16);
12230 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
12231 TOKEN_NUM_INITIALIZER
12232 (struct cmd_set_vf_vlan_tag_result,
12233 vf_id, RTE_UINT16);
12234 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
12235 TOKEN_STRING_INITIALIZER
12236 (struct cmd_set_vf_vlan_tag_result,
12240 cmd_set_vf_vlan_tag_parsed(
12241 void *parsed_result,
12242 __rte_unused struct cmdline *cl,
12243 __rte_unused void *data)
12245 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
12246 int ret = -ENOTSUP;
12248 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12250 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12253 #ifdef RTE_NET_I40E
12254 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
12255 res->vf_id, is_on);
12262 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12265 printf("invalid port_id %d\n", res->port_id);
12268 printf("function not implemented\n");
12271 printf("programming error: (%s)\n", strerror(-ret));
12275 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
12276 .f = cmd_set_vf_vlan_tag_parsed,
12278 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
12280 (void *)&cmd_set_vf_vlan_tag_set,
12281 (void *)&cmd_set_vf_vlan_tag_vf,
12282 (void *)&cmd_set_vf_vlan_tag_vlan,
12283 (void *)&cmd_set_vf_vlan_tag_tag,
12284 (void *)&cmd_set_vf_vlan_tag_port_id,
12285 (void *)&cmd_set_vf_vlan_tag_vf_id,
12286 (void *)&cmd_set_vf_vlan_tag_on_off,
12291 /* Common definition of VF and TC TX bandwidth configuration */
12292 struct cmd_vf_tc_bw_result {
12293 cmdline_fixed_string_t set;
12294 cmdline_fixed_string_t vf;
12295 cmdline_fixed_string_t tc;
12296 cmdline_fixed_string_t tx;
12297 cmdline_fixed_string_t min_bw;
12298 cmdline_fixed_string_t max_bw;
12299 cmdline_fixed_string_t strict_link_prio;
12304 cmdline_fixed_string_t bw_list;
12308 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
12309 TOKEN_STRING_INITIALIZER
12310 (struct cmd_vf_tc_bw_result,
12312 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
12313 TOKEN_STRING_INITIALIZER
12314 (struct cmd_vf_tc_bw_result,
12316 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
12317 TOKEN_STRING_INITIALIZER
12318 (struct cmd_vf_tc_bw_result,
12320 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
12321 TOKEN_STRING_INITIALIZER
12322 (struct cmd_vf_tc_bw_result,
12324 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
12325 TOKEN_STRING_INITIALIZER
12326 (struct cmd_vf_tc_bw_result,
12327 strict_link_prio, "strict-link-priority");
12328 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
12329 TOKEN_STRING_INITIALIZER
12330 (struct cmd_vf_tc_bw_result,
12331 min_bw, "min-bandwidth");
12332 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
12333 TOKEN_STRING_INITIALIZER
12334 (struct cmd_vf_tc_bw_result,
12335 max_bw, "max-bandwidth");
12336 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
12337 TOKEN_NUM_INITIALIZER
12338 (struct cmd_vf_tc_bw_result,
12339 port_id, RTE_UINT16);
12340 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
12341 TOKEN_NUM_INITIALIZER
12342 (struct cmd_vf_tc_bw_result,
12343 vf_id, RTE_UINT16);
12344 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
12345 TOKEN_NUM_INITIALIZER
12346 (struct cmd_vf_tc_bw_result,
12348 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
12349 TOKEN_NUM_INITIALIZER
12350 (struct cmd_vf_tc_bw_result,
12352 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
12353 TOKEN_STRING_INITIALIZER
12354 (struct cmd_vf_tc_bw_result,
12356 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
12357 TOKEN_NUM_INITIALIZER
12358 (struct cmd_vf_tc_bw_result,
12359 tc_map, RTE_UINT8);
12361 /* VF max bandwidth setting */
12363 cmd_vf_max_bw_parsed(
12364 void *parsed_result,
12365 __rte_unused struct cmdline *cl,
12366 __rte_unused void *data)
12368 struct cmd_vf_tc_bw_result *res = parsed_result;
12369 int ret = -ENOTSUP;
12371 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12374 #ifdef RTE_NET_I40E
12375 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
12376 res->vf_id, res->bw);
12383 printf("invalid vf_id %d or bandwidth %d\n",
12384 res->vf_id, res->bw);
12387 printf("invalid port_id %d\n", res->port_id);
12390 printf("function not implemented\n");
12393 printf("programming error: (%s)\n", strerror(-ret));
12397 cmdline_parse_inst_t cmd_vf_max_bw = {
12398 .f = cmd_vf_max_bw_parsed,
12400 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
12402 (void *)&cmd_vf_tc_bw_set,
12403 (void *)&cmd_vf_tc_bw_vf,
12404 (void *)&cmd_vf_tc_bw_tx,
12405 (void *)&cmd_vf_tc_bw_max_bw,
12406 (void *)&cmd_vf_tc_bw_port_id,
12407 (void *)&cmd_vf_tc_bw_vf_id,
12408 (void *)&cmd_vf_tc_bw_bw,
12414 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
12419 const char *p, *p0 = str;
12426 p = strchr(p0, '(');
12428 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
12432 p0 = strchr(p, ')');
12434 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
12438 if (size >= sizeof(s)) {
12439 printf("The string size exceeds the internal buffer size\n");
12442 snprintf(s, sizeof(s), "%.*s", size, p);
12443 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
12445 printf("Failed to get the bandwidth list. ");
12449 for (i = 0; i < ret; i++)
12450 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
12455 /* TC min bandwidth setting */
12457 cmd_vf_tc_min_bw_parsed(
12458 void *parsed_result,
12459 __rte_unused struct cmdline *cl,
12460 __rte_unused void *data)
12462 struct cmd_vf_tc_bw_result *res = parsed_result;
12465 int ret = -ENOTSUP;
12467 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12470 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12474 #ifdef RTE_NET_I40E
12475 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
12483 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
12486 printf("invalid port_id %d\n", res->port_id);
12489 printf("function not implemented\n");
12492 printf("programming error: (%s)\n", strerror(-ret));
12496 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
12497 .f = cmd_vf_tc_min_bw_parsed,
12499 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
12500 " <bw1, bw2, ...>",
12502 (void *)&cmd_vf_tc_bw_set,
12503 (void *)&cmd_vf_tc_bw_vf,
12504 (void *)&cmd_vf_tc_bw_tc,
12505 (void *)&cmd_vf_tc_bw_tx,
12506 (void *)&cmd_vf_tc_bw_min_bw,
12507 (void *)&cmd_vf_tc_bw_port_id,
12508 (void *)&cmd_vf_tc_bw_vf_id,
12509 (void *)&cmd_vf_tc_bw_bw_list,
12515 cmd_tc_min_bw_parsed(
12516 void *parsed_result,
12517 __rte_unused struct cmdline *cl,
12518 __rte_unused void *data)
12520 struct cmd_vf_tc_bw_result *res = parsed_result;
12521 struct rte_port *port;
12524 int ret = -ENOTSUP;
12526 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12529 port = &ports[res->port_id];
12530 /** Check if the port is not started **/
12531 if (port->port_status != RTE_PORT_STOPPED) {
12532 printf("Please stop port %d first\n", res->port_id);
12536 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12540 #ifdef RTE_NET_IXGBE
12541 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
12548 printf("invalid bandwidth\n");
12551 printf("invalid port_id %d\n", res->port_id);
12554 printf("function not implemented\n");
12557 printf("programming error: (%s)\n", strerror(-ret));
12561 cmdline_parse_inst_t cmd_tc_min_bw = {
12562 .f = cmd_tc_min_bw_parsed,
12564 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
12566 (void *)&cmd_vf_tc_bw_set,
12567 (void *)&cmd_vf_tc_bw_tc,
12568 (void *)&cmd_vf_tc_bw_tx,
12569 (void *)&cmd_vf_tc_bw_min_bw,
12570 (void *)&cmd_vf_tc_bw_port_id,
12571 (void *)&cmd_vf_tc_bw_bw_list,
12576 /* TC max bandwidth setting */
12578 cmd_vf_tc_max_bw_parsed(
12579 void *parsed_result,
12580 __rte_unused struct cmdline *cl,
12581 __rte_unused void *data)
12583 struct cmd_vf_tc_bw_result *res = parsed_result;
12584 int ret = -ENOTSUP;
12586 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12589 #ifdef RTE_NET_I40E
12590 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
12591 res->tc_no, res->bw);
12598 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
12599 res->vf_id, res->tc_no, res->bw);
12602 printf("invalid port_id %d\n", res->port_id);
12605 printf("function not implemented\n");
12608 printf("programming error: (%s)\n", strerror(-ret));
12612 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
12613 .f = cmd_vf_tc_max_bw_parsed,
12615 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
12618 (void *)&cmd_vf_tc_bw_set,
12619 (void *)&cmd_vf_tc_bw_vf,
12620 (void *)&cmd_vf_tc_bw_tc,
12621 (void *)&cmd_vf_tc_bw_tx,
12622 (void *)&cmd_vf_tc_bw_max_bw,
12623 (void *)&cmd_vf_tc_bw_port_id,
12624 (void *)&cmd_vf_tc_bw_vf_id,
12625 (void *)&cmd_vf_tc_bw_tc_no,
12626 (void *)&cmd_vf_tc_bw_bw,
12631 /** Set VXLAN encapsulation details */
12632 struct cmd_set_vxlan_result {
12633 cmdline_fixed_string_t set;
12634 cmdline_fixed_string_t vxlan;
12635 cmdline_fixed_string_t pos_token;
12636 cmdline_fixed_string_t ip_version;
12637 uint32_t vlan_present:1;
12641 cmdline_ipaddr_t ip_src;
12642 cmdline_ipaddr_t ip_dst;
12646 struct rte_ether_addr eth_src;
12647 struct rte_ether_addr eth_dst;
12650 cmdline_parse_token_string_t cmd_set_vxlan_set =
12651 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
12652 cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
12653 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
12654 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
12655 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
12657 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
12658 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
12659 "vxlan-with-vlan");
12660 cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
12661 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12663 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
12664 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
12666 cmdline_parse_token_string_t cmd_set_vxlan_vni =
12667 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12669 cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
12670 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, RTE_UINT32);
12671 cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
12672 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12674 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
12675 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, RTE_UINT16);
12676 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
12677 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12679 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
12680 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, RTE_UINT16);
12681 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
12682 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12684 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
12685 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, RTE_UINT8);
12686 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
12687 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12689 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
12690 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, RTE_UINT8);
12691 cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
12692 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12694 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
12695 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
12696 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
12697 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12699 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
12700 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
12701 cmdline_parse_token_string_t cmd_set_vxlan_vlan =
12702 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12704 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
12705 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, RTE_UINT16);
12706 cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
12707 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12709 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
12710 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
12711 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
12712 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12714 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
12715 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
12717 static void cmd_set_vxlan_parsed(void *parsed_result,
12718 __rte_unused struct cmdline *cl,
12719 __rte_unused void *data)
12721 struct cmd_set_vxlan_result *res = parsed_result;
12726 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
12729 vxlan_encap_conf.select_tos_ttl = 0;
12730 if (strcmp(res->vxlan, "vxlan") == 0)
12731 vxlan_encap_conf.select_vlan = 0;
12732 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
12733 vxlan_encap_conf.select_vlan = 1;
12734 else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
12735 vxlan_encap_conf.select_vlan = 0;
12736 vxlan_encap_conf.select_tos_ttl = 1;
12738 if (strcmp(res->ip_version, "ipv4") == 0)
12739 vxlan_encap_conf.select_ipv4 = 1;
12740 else if (strcmp(res->ip_version, "ipv6") == 0)
12741 vxlan_encap_conf.select_ipv4 = 0;
12744 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
12745 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
12746 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
12747 vxlan_encap_conf.ip_tos = res->tos;
12748 vxlan_encap_conf.ip_ttl = res->ttl;
12749 if (vxlan_encap_conf.select_ipv4) {
12750 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
12751 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
12753 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
12754 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
12756 if (vxlan_encap_conf.select_vlan)
12757 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
12758 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
12759 RTE_ETHER_ADDR_LEN);
12760 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
12761 RTE_ETHER_ADDR_LEN);
12764 cmdline_parse_inst_t cmd_set_vxlan = {
12765 .f = cmd_set_vxlan_parsed,
12767 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
12768 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
12769 " eth-src <eth-src> eth-dst <eth-dst>",
12771 (void *)&cmd_set_vxlan_set,
12772 (void *)&cmd_set_vxlan_vxlan,
12773 (void *)&cmd_set_vxlan_ip_version,
12774 (void *)&cmd_set_vxlan_ip_version_value,
12775 (void *)&cmd_set_vxlan_vni,
12776 (void *)&cmd_set_vxlan_vni_value,
12777 (void *)&cmd_set_vxlan_udp_src,
12778 (void *)&cmd_set_vxlan_udp_src_value,
12779 (void *)&cmd_set_vxlan_udp_dst,
12780 (void *)&cmd_set_vxlan_udp_dst_value,
12781 (void *)&cmd_set_vxlan_ip_src,
12782 (void *)&cmd_set_vxlan_ip_src_value,
12783 (void *)&cmd_set_vxlan_ip_dst,
12784 (void *)&cmd_set_vxlan_ip_dst_value,
12785 (void *)&cmd_set_vxlan_eth_src,
12786 (void *)&cmd_set_vxlan_eth_src_value,
12787 (void *)&cmd_set_vxlan_eth_dst,
12788 (void *)&cmd_set_vxlan_eth_dst_value,
12793 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
12794 .f = cmd_set_vxlan_parsed,
12796 .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
12797 " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
12798 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
12799 " eth-dst <eth-dst>",
12801 (void *)&cmd_set_vxlan_set,
12802 (void *)&cmd_set_vxlan_vxlan_tos_ttl,
12803 (void *)&cmd_set_vxlan_ip_version,
12804 (void *)&cmd_set_vxlan_ip_version_value,
12805 (void *)&cmd_set_vxlan_vni,
12806 (void *)&cmd_set_vxlan_vni_value,
12807 (void *)&cmd_set_vxlan_udp_src,
12808 (void *)&cmd_set_vxlan_udp_src_value,
12809 (void *)&cmd_set_vxlan_udp_dst,
12810 (void *)&cmd_set_vxlan_udp_dst_value,
12811 (void *)&cmd_set_vxlan_ip_tos,
12812 (void *)&cmd_set_vxlan_ip_tos_value,
12813 (void *)&cmd_set_vxlan_ip_ttl,
12814 (void *)&cmd_set_vxlan_ip_ttl_value,
12815 (void *)&cmd_set_vxlan_ip_src,
12816 (void *)&cmd_set_vxlan_ip_src_value,
12817 (void *)&cmd_set_vxlan_ip_dst,
12818 (void *)&cmd_set_vxlan_ip_dst_value,
12819 (void *)&cmd_set_vxlan_eth_src,
12820 (void *)&cmd_set_vxlan_eth_src_value,
12821 (void *)&cmd_set_vxlan_eth_dst,
12822 (void *)&cmd_set_vxlan_eth_dst_value,
12827 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
12828 .f = cmd_set_vxlan_parsed,
12830 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
12831 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
12832 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
12835 (void *)&cmd_set_vxlan_set,
12836 (void *)&cmd_set_vxlan_vxlan_with_vlan,
12837 (void *)&cmd_set_vxlan_ip_version,
12838 (void *)&cmd_set_vxlan_ip_version_value,
12839 (void *)&cmd_set_vxlan_vni,
12840 (void *)&cmd_set_vxlan_vni_value,
12841 (void *)&cmd_set_vxlan_udp_src,
12842 (void *)&cmd_set_vxlan_udp_src_value,
12843 (void *)&cmd_set_vxlan_udp_dst,
12844 (void *)&cmd_set_vxlan_udp_dst_value,
12845 (void *)&cmd_set_vxlan_ip_src,
12846 (void *)&cmd_set_vxlan_ip_src_value,
12847 (void *)&cmd_set_vxlan_ip_dst,
12848 (void *)&cmd_set_vxlan_ip_dst_value,
12849 (void *)&cmd_set_vxlan_vlan,
12850 (void *)&cmd_set_vxlan_vlan_value,
12851 (void *)&cmd_set_vxlan_eth_src,
12852 (void *)&cmd_set_vxlan_eth_src_value,
12853 (void *)&cmd_set_vxlan_eth_dst,
12854 (void *)&cmd_set_vxlan_eth_dst_value,
12859 /** Set NVGRE encapsulation details */
12860 struct cmd_set_nvgre_result {
12861 cmdline_fixed_string_t set;
12862 cmdline_fixed_string_t nvgre;
12863 cmdline_fixed_string_t pos_token;
12864 cmdline_fixed_string_t ip_version;
12866 cmdline_ipaddr_t ip_src;
12867 cmdline_ipaddr_t ip_dst;
12869 struct rte_ether_addr eth_src;
12870 struct rte_ether_addr eth_dst;
12873 cmdline_parse_token_string_t cmd_set_nvgre_set =
12874 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
12875 cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
12876 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
12877 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
12878 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
12879 "nvgre-with-vlan");
12880 cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
12881 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
12883 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
12884 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
12886 cmdline_parse_token_string_t cmd_set_nvgre_tni =
12887 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
12889 cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
12890 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, RTE_UINT32);
12891 cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
12892 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
12894 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
12895 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
12896 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
12897 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
12899 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
12900 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
12901 cmdline_parse_token_string_t cmd_set_nvgre_vlan =
12902 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
12904 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
12905 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, RTE_UINT16);
12906 cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
12907 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
12909 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
12910 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
12911 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
12912 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
12914 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
12915 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
12917 static void cmd_set_nvgre_parsed(void *parsed_result,
12918 __rte_unused struct cmdline *cl,
12919 __rte_unused void *data)
12921 struct cmd_set_nvgre_result *res = parsed_result;
12923 uint32_t nvgre_tni;
12926 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
12929 if (strcmp(res->nvgre, "nvgre") == 0)
12930 nvgre_encap_conf.select_vlan = 0;
12931 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
12932 nvgre_encap_conf.select_vlan = 1;
12933 if (strcmp(res->ip_version, "ipv4") == 0)
12934 nvgre_encap_conf.select_ipv4 = 1;
12935 else if (strcmp(res->ip_version, "ipv6") == 0)
12936 nvgre_encap_conf.select_ipv4 = 0;
12939 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
12940 if (nvgre_encap_conf.select_ipv4) {
12941 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
12942 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
12944 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
12945 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
12947 if (nvgre_encap_conf.select_vlan)
12948 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
12949 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
12950 RTE_ETHER_ADDR_LEN);
12951 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
12952 RTE_ETHER_ADDR_LEN);
12955 cmdline_parse_inst_t cmd_set_nvgre = {
12956 .f = cmd_set_nvgre_parsed,
12958 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
12959 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
12960 " eth-dst <eth-dst>",
12962 (void *)&cmd_set_nvgre_set,
12963 (void *)&cmd_set_nvgre_nvgre,
12964 (void *)&cmd_set_nvgre_ip_version,
12965 (void *)&cmd_set_nvgre_ip_version_value,
12966 (void *)&cmd_set_nvgre_tni,
12967 (void *)&cmd_set_nvgre_tni_value,
12968 (void *)&cmd_set_nvgre_ip_src,
12969 (void *)&cmd_set_nvgre_ip_src_value,
12970 (void *)&cmd_set_nvgre_ip_dst,
12971 (void *)&cmd_set_nvgre_ip_dst_value,
12972 (void *)&cmd_set_nvgre_eth_src,
12973 (void *)&cmd_set_nvgre_eth_src_value,
12974 (void *)&cmd_set_nvgre_eth_dst,
12975 (void *)&cmd_set_nvgre_eth_dst_value,
12980 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
12981 .f = cmd_set_nvgre_parsed,
12983 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
12984 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
12985 " eth-src <eth-src> eth-dst <eth-dst>",
12987 (void *)&cmd_set_nvgre_set,
12988 (void *)&cmd_set_nvgre_nvgre_with_vlan,
12989 (void *)&cmd_set_nvgre_ip_version,
12990 (void *)&cmd_set_nvgre_ip_version_value,
12991 (void *)&cmd_set_nvgre_tni,
12992 (void *)&cmd_set_nvgre_tni_value,
12993 (void *)&cmd_set_nvgre_ip_src,
12994 (void *)&cmd_set_nvgre_ip_src_value,
12995 (void *)&cmd_set_nvgre_ip_dst,
12996 (void *)&cmd_set_nvgre_ip_dst_value,
12997 (void *)&cmd_set_nvgre_vlan,
12998 (void *)&cmd_set_nvgre_vlan_value,
12999 (void *)&cmd_set_nvgre_eth_src,
13000 (void *)&cmd_set_nvgre_eth_src_value,
13001 (void *)&cmd_set_nvgre_eth_dst,
13002 (void *)&cmd_set_nvgre_eth_dst_value,
13007 /** Set L2 encapsulation details */
13008 struct cmd_set_l2_encap_result {
13009 cmdline_fixed_string_t set;
13010 cmdline_fixed_string_t l2_encap;
13011 cmdline_fixed_string_t pos_token;
13012 cmdline_fixed_string_t ip_version;
13013 uint32_t vlan_present:1;
13015 struct rte_ether_addr eth_src;
13016 struct rte_ether_addr eth_dst;
13019 cmdline_parse_token_string_t cmd_set_l2_encap_set =
13020 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
13021 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
13022 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
13023 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
13024 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
13025 "l2_encap-with-vlan");
13026 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
13027 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13029 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
13030 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
13032 cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
13033 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13035 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
13036 TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, RTE_UINT16);
13037 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
13038 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13040 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
13041 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
13042 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
13043 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13045 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
13046 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
13048 static void cmd_set_l2_encap_parsed(void *parsed_result,
13049 __rte_unused struct cmdline *cl,
13050 __rte_unused void *data)
13052 struct cmd_set_l2_encap_result *res = parsed_result;
13054 if (strcmp(res->l2_encap, "l2_encap") == 0)
13055 l2_encap_conf.select_vlan = 0;
13056 else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
13057 l2_encap_conf.select_vlan = 1;
13058 if (strcmp(res->ip_version, "ipv4") == 0)
13059 l2_encap_conf.select_ipv4 = 1;
13060 else if (strcmp(res->ip_version, "ipv6") == 0)
13061 l2_encap_conf.select_ipv4 = 0;
13064 if (l2_encap_conf.select_vlan)
13065 l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13066 rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
13067 RTE_ETHER_ADDR_LEN);
13068 rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13069 RTE_ETHER_ADDR_LEN);
13072 cmdline_parse_inst_t cmd_set_l2_encap = {
13073 .f = cmd_set_l2_encap_parsed,
13075 .help_str = "set l2_encap ip-version ipv4|ipv6"
13076 " eth-src <eth-src> eth-dst <eth-dst>",
13078 (void *)&cmd_set_l2_encap_set,
13079 (void *)&cmd_set_l2_encap_l2_encap,
13080 (void *)&cmd_set_l2_encap_ip_version,
13081 (void *)&cmd_set_l2_encap_ip_version_value,
13082 (void *)&cmd_set_l2_encap_eth_src,
13083 (void *)&cmd_set_l2_encap_eth_src_value,
13084 (void *)&cmd_set_l2_encap_eth_dst,
13085 (void *)&cmd_set_l2_encap_eth_dst_value,
13090 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
13091 .f = cmd_set_l2_encap_parsed,
13093 .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
13094 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
13096 (void *)&cmd_set_l2_encap_set,
13097 (void *)&cmd_set_l2_encap_l2_encap_with_vlan,
13098 (void *)&cmd_set_l2_encap_ip_version,
13099 (void *)&cmd_set_l2_encap_ip_version_value,
13100 (void *)&cmd_set_l2_encap_vlan,
13101 (void *)&cmd_set_l2_encap_vlan_value,
13102 (void *)&cmd_set_l2_encap_eth_src,
13103 (void *)&cmd_set_l2_encap_eth_src_value,
13104 (void *)&cmd_set_l2_encap_eth_dst,
13105 (void *)&cmd_set_l2_encap_eth_dst_value,
13110 /** Set L2 decapsulation details */
13111 struct cmd_set_l2_decap_result {
13112 cmdline_fixed_string_t set;
13113 cmdline_fixed_string_t l2_decap;
13114 cmdline_fixed_string_t pos_token;
13115 uint32_t vlan_present:1;
13118 cmdline_parse_token_string_t cmd_set_l2_decap_set =
13119 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
13120 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
13121 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
13123 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
13124 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
13125 "l2_decap-with-vlan");
13127 static void cmd_set_l2_decap_parsed(void *parsed_result,
13128 __rte_unused struct cmdline *cl,
13129 __rte_unused void *data)
13131 struct cmd_set_l2_decap_result *res = parsed_result;
13133 if (strcmp(res->l2_decap, "l2_decap") == 0)
13134 l2_decap_conf.select_vlan = 0;
13135 else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
13136 l2_decap_conf.select_vlan = 1;
13139 cmdline_parse_inst_t cmd_set_l2_decap = {
13140 .f = cmd_set_l2_decap_parsed,
13142 .help_str = "set l2_decap",
13144 (void *)&cmd_set_l2_decap_set,
13145 (void *)&cmd_set_l2_decap_l2_decap,
13150 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
13151 .f = cmd_set_l2_decap_parsed,
13153 .help_str = "set l2_decap-with-vlan",
13155 (void *)&cmd_set_l2_decap_set,
13156 (void *)&cmd_set_l2_decap_l2_decap_with_vlan,
13161 /** Set MPLSoGRE encapsulation details */
13162 struct cmd_set_mplsogre_encap_result {
13163 cmdline_fixed_string_t set;
13164 cmdline_fixed_string_t mplsogre;
13165 cmdline_fixed_string_t pos_token;
13166 cmdline_fixed_string_t ip_version;
13167 uint32_t vlan_present:1;
13169 cmdline_ipaddr_t ip_src;
13170 cmdline_ipaddr_t ip_dst;
13172 struct rte_ether_addr eth_src;
13173 struct rte_ether_addr eth_dst;
13176 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
13177 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
13179 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
13180 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
13182 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
13183 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13184 mplsogre, "mplsogre_encap-with-vlan");
13185 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
13186 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13187 pos_token, "ip-version");
13188 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
13189 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13190 ip_version, "ipv4#ipv6");
13191 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
13192 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13193 pos_token, "label");
13194 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
13195 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
13197 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
13198 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13199 pos_token, "ip-src");
13200 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
13201 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
13202 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
13203 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13204 pos_token, "ip-dst");
13205 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
13206 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
13207 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
13208 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13209 pos_token, "vlan-tci");
13210 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
13211 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
13213 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
13214 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13215 pos_token, "eth-src");
13216 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
13217 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13219 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
13220 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13221 pos_token, "eth-dst");
13222 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
13223 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13226 static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
13227 __rte_unused struct cmdline *cl,
13228 __rte_unused void *data)
13230 struct cmd_set_mplsogre_encap_result *res = parsed_result;
13232 uint32_t mplsogre_label;
13235 .mplsogre_label = rte_cpu_to_be_32(res->label<<12),
13238 if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
13239 mplsogre_encap_conf.select_vlan = 0;
13240 else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
13241 mplsogre_encap_conf.select_vlan = 1;
13242 if (strcmp(res->ip_version, "ipv4") == 0)
13243 mplsogre_encap_conf.select_ipv4 = 1;
13244 else if (strcmp(res->ip_version, "ipv6") == 0)
13245 mplsogre_encap_conf.select_ipv4 = 0;
13248 rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
13249 if (mplsogre_encap_conf.select_ipv4) {
13250 IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
13251 IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
13253 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
13254 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
13256 if (mplsogre_encap_conf.select_vlan)
13257 mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13258 rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
13259 RTE_ETHER_ADDR_LEN);
13260 rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13261 RTE_ETHER_ADDR_LEN);
13264 cmdline_parse_inst_t cmd_set_mplsogre_encap = {
13265 .f = cmd_set_mplsogre_encap_parsed,
13267 .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
13268 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
13269 " eth-dst <eth-dst>",
13271 (void *)&cmd_set_mplsogre_encap_set,
13272 (void *)&cmd_set_mplsogre_encap_mplsogre_encap,
13273 (void *)&cmd_set_mplsogre_encap_ip_version,
13274 (void *)&cmd_set_mplsogre_encap_ip_version_value,
13275 (void *)&cmd_set_mplsogre_encap_label,
13276 (void *)&cmd_set_mplsogre_encap_label_value,
13277 (void *)&cmd_set_mplsogre_encap_ip_src,
13278 (void *)&cmd_set_mplsogre_encap_ip_src_value,
13279 (void *)&cmd_set_mplsogre_encap_ip_dst,
13280 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
13281 (void *)&cmd_set_mplsogre_encap_eth_src,
13282 (void *)&cmd_set_mplsogre_encap_eth_src_value,
13283 (void *)&cmd_set_mplsogre_encap_eth_dst,
13284 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
13289 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
13290 .f = cmd_set_mplsogre_encap_parsed,
13292 .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
13293 " label <label> ip-src <ip-src> ip-dst <ip-dst>"
13294 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
13296 (void *)&cmd_set_mplsogre_encap_set,
13297 (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
13298 (void *)&cmd_set_mplsogre_encap_ip_version,
13299 (void *)&cmd_set_mplsogre_encap_ip_version_value,
13300 (void *)&cmd_set_mplsogre_encap_label,
13301 (void *)&cmd_set_mplsogre_encap_label_value,
13302 (void *)&cmd_set_mplsogre_encap_ip_src,
13303 (void *)&cmd_set_mplsogre_encap_ip_src_value,
13304 (void *)&cmd_set_mplsogre_encap_ip_dst,
13305 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
13306 (void *)&cmd_set_mplsogre_encap_vlan,
13307 (void *)&cmd_set_mplsogre_encap_vlan_value,
13308 (void *)&cmd_set_mplsogre_encap_eth_src,
13309 (void *)&cmd_set_mplsogre_encap_eth_src_value,
13310 (void *)&cmd_set_mplsogre_encap_eth_dst,
13311 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
13316 /** Set MPLSoGRE decapsulation details */
13317 struct cmd_set_mplsogre_decap_result {
13318 cmdline_fixed_string_t set;
13319 cmdline_fixed_string_t mplsogre;
13320 cmdline_fixed_string_t pos_token;
13321 cmdline_fixed_string_t ip_version;
13322 uint32_t vlan_present:1;
13325 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
13326 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
13328 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
13329 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
13331 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
13332 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13333 mplsogre, "mplsogre_decap-with-vlan");
13334 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
13335 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13336 pos_token, "ip-version");
13337 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
13338 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13339 ip_version, "ipv4#ipv6");
13341 static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
13342 __rte_unused struct cmdline *cl,
13343 __rte_unused void *data)
13345 struct cmd_set_mplsogre_decap_result *res = parsed_result;
13347 if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
13348 mplsogre_decap_conf.select_vlan = 0;
13349 else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
13350 mplsogre_decap_conf.select_vlan = 1;
13351 if (strcmp(res->ip_version, "ipv4") == 0)
13352 mplsogre_decap_conf.select_ipv4 = 1;
13353 else if (strcmp(res->ip_version, "ipv6") == 0)
13354 mplsogre_decap_conf.select_ipv4 = 0;
13357 cmdline_parse_inst_t cmd_set_mplsogre_decap = {
13358 .f = cmd_set_mplsogre_decap_parsed,
13360 .help_str = "set mplsogre_decap ip-version ipv4|ipv6",
13362 (void *)&cmd_set_mplsogre_decap_set,
13363 (void *)&cmd_set_mplsogre_decap_mplsogre_decap,
13364 (void *)&cmd_set_mplsogre_decap_ip_version,
13365 (void *)&cmd_set_mplsogre_decap_ip_version_value,
13370 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
13371 .f = cmd_set_mplsogre_decap_parsed,
13373 .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
13375 (void *)&cmd_set_mplsogre_decap_set,
13376 (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
13377 (void *)&cmd_set_mplsogre_decap_ip_version,
13378 (void *)&cmd_set_mplsogre_decap_ip_version_value,
13383 /** Set MPLSoUDP encapsulation details */
13384 struct cmd_set_mplsoudp_encap_result {
13385 cmdline_fixed_string_t set;
13386 cmdline_fixed_string_t mplsoudp;
13387 cmdline_fixed_string_t pos_token;
13388 cmdline_fixed_string_t ip_version;
13389 uint32_t vlan_present:1;
13393 cmdline_ipaddr_t ip_src;
13394 cmdline_ipaddr_t ip_dst;
13396 struct rte_ether_addr eth_src;
13397 struct rte_ether_addr eth_dst;
13400 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
13401 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
13403 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
13404 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
13406 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
13407 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13408 mplsoudp, "mplsoudp_encap-with-vlan");
13409 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
13410 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13411 pos_token, "ip-version");
13412 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
13413 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13414 ip_version, "ipv4#ipv6");
13415 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
13416 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13417 pos_token, "label");
13418 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
13419 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
13421 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
13422 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13423 pos_token, "udp-src");
13424 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
13425 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
13427 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
13428 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13429 pos_token, "udp-dst");
13430 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
13431 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
13433 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
13434 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13435 pos_token, "ip-src");
13436 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
13437 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
13438 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
13439 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13440 pos_token, "ip-dst");
13441 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
13442 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
13443 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
13444 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13445 pos_token, "vlan-tci");
13446 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
13447 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
13449 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
13450 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13451 pos_token, "eth-src");
13452 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
13453 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13455 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
13456 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13457 pos_token, "eth-dst");
13458 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
13459 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13462 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
13463 __rte_unused struct cmdline *cl,
13464 __rte_unused void *data)
13466 struct cmd_set_mplsoudp_encap_result *res = parsed_result;
13468 uint32_t mplsoudp_label;
13471 .mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
13474 if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
13475 mplsoudp_encap_conf.select_vlan = 0;
13476 else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
13477 mplsoudp_encap_conf.select_vlan = 1;
13478 if (strcmp(res->ip_version, "ipv4") == 0)
13479 mplsoudp_encap_conf.select_ipv4 = 1;
13480 else if (strcmp(res->ip_version, "ipv6") == 0)
13481 mplsoudp_encap_conf.select_ipv4 = 0;
13484 rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
13485 mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
13486 mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
13487 if (mplsoudp_encap_conf.select_ipv4) {
13488 IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
13489 IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
13491 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
13492 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
13494 if (mplsoudp_encap_conf.select_vlan)
13495 mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13496 rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
13497 RTE_ETHER_ADDR_LEN);
13498 rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13499 RTE_ETHER_ADDR_LEN);
13502 cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
13503 .f = cmd_set_mplsoudp_encap_parsed,
13505 .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
13506 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
13507 " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
13509 (void *)&cmd_set_mplsoudp_encap_set,
13510 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
13511 (void *)&cmd_set_mplsoudp_encap_ip_version,
13512 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
13513 (void *)&cmd_set_mplsoudp_encap_label,
13514 (void *)&cmd_set_mplsoudp_encap_label_value,
13515 (void *)&cmd_set_mplsoudp_encap_udp_src,
13516 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
13517 (void *)&cmd_set_mplsoudp_encap_udp_dst,
13518 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
13519 (void *)&cmd_set_mplsoudp_encap_ip_src,
13520 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
13521 (void *)&cmd_set_mplsoudp_encap_ip_dst,
13522 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
13523 (void *)&cmd_set_mplsoudp_encap_eth_src,
13524 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
13525 (void *)&cmd_set_mplsoudp_encap_eth_dst,
13526 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
13531 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
13532 .f = cmd_set_mplsoudp_encap_parsed,
13534 .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
13535 " label <label> udp-src <udp-src> udp-dst <udp-dst>"
13536 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
13537 " eth-src <eth-src> eth-dst <eth-dst>",
13539 (void *)&cmd_set_mplsoudp_encap_set,
13540 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
13541 (void *)&cmd_set_mplsoudp_encap_ip_version,
13542 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
13543 (void *)&cmd_set_mplsoudp_encap_label,
13544 (void *)&cmd_set_mplsoudp_encap_label_value,
13545 (void *)&cmd_set_mplsoudp_encap_udp_src,
13546 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
13547 (void *)&cmd_set_mplsoudp_encap_udp_dst,
13548 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
13549 (void *)&cmd_set_mplsoudp_encap_ip_src,
13550 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
13551 (void *)&cmd_set_mplsoudp_encap_ip_dst,
13552 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
13553 (void *)&cmd_set_mplsoudp_encap_vlan,
13554 (void *)&cmd_set_mplsoudp_encap_vlan_value,
13555 (void *)&cmd_set_mplsoudp_encap_eth_src,
13556 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
13557 (void *)&cmd_set_mplsoudp_encap_eth_dst,
13558 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
13563 /** Set MPLSoUDP decapsulation details */
13564 struct cmd_set_mplsoudp_decap_result {
13565 cmdline_fixed_string_t set;
13566 cmdline_fixed_string_t mplsoudp;
13567 cmdline_fixed_string_t pos_token;
13568 cmdline_fixed_string_t ip_version;
13569 uint32_t vlan_present:1;
13572 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
13573 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
13575 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
13576 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
13578 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
13579 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
13580 mplsoudp, "mplsoudp_decap-with-vlan");
13581 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
13582 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
13583 pos_token, "ip-version");
13584 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
13585 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
13586 ip_version, "ipv4#ipv6");
13588 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
13589 __rte_unused struct cmdline *cl,
13590 __rte_unused void *data)
13592 struct cmd_set_mplsoudp_decap_result *res = parsed_result;
13594 if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
13595 mplsoudp_decap_conf.select_vlan = 0;
13596 else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
13597 mplsoudp_decap_conf.select_vlan = 1;
13598 if (strcmp(res->ip_version, "ipv4") == 0)
13599 mplsoudp_decap_conf.select_ipv4 = 1;
13600 else if (strcmp(res->ip_version, "ipv6") == 0)
13601 mplsoudp_decap_conf.select_ipv4 = 0;
13604 cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
13605 .f = cmd_set_mplsoudp_decap_parsed,
13607 .help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
13609 (void *)&cmd_set_mplsoudp_decap_set,
13610 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
13611 (void *)&cmd_set_mplsoudp_decap_ip_version,
13612 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
13617 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
13618 .f = cmd_set_mplsoudp_decap_parsed,
13620 .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
13622 (void *)&cmd_set_mplsoudp_decap_set,
13623 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
13624 (void *)&cmd_set_mplsoudp_decap_ip_version,
13625 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
13630 /** Set connection tracking object common details */
13631 struct cmd_set_conntrack_common_result {
13632 cmdline_fixed_string_t set;
13633 cmdline_fixed_string_t conntrack;
13634 cmdline_fixed_string_t common;
13635 cmdline_fixed_string_t peer;
13636 cmdline_fixed_string_t is_orig;
13637 cmdline_fixed_string_t enable;
13638 cmdline_fixed_string_t live;
13639 cmdline_fixed_string_t sack;
13640 cmdline_fixed_string_t cack;
13641 cmdline_fixed_string_t last_dir;
13642 cmdline_fixed_string_t liberal;
13643 cmdline_fixed_string_t state;
13644 cmdline_fixed_string_t max_ack_win;
13645 cmdline_fixed_string_t retrans;
13646 cmdline_fixed_string_t last_win;
13647 cmdline_fixed_string_t last_seq;
13648 cmdline_fixed_string_t last_ack;
13649 cmdline_fixed_string_t last_end;
13650 cmdline_fixed_string_t last_index;
13653 uint16_t peer_port;
13654 uint32_t is_original;
13669 cmdline_parse_token_string_t cmd_set_conntrack_set =
13670 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13672 cmdline_parse_token_string_t cmd_set_conntrack_conntrack =
13673 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13674 conntrack, "conntrack");
13675 cmdline_parse_token_string_t cmd_set_conntrack_common_com =
13676 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13678 cmdline_parse_token_string_t cmd_set_conntrack_common_peer =
13679 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13681 cmdline_parse_token_num_t cmd_set_conntrack_common_peer_value =
13682 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13683 peer_port, RTE_UINT16);
13684 cmdline_parse_token_string_t cmd_set_conntrack_common_is_orig =
13685 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13686 is_orig, "is_orig");
13687 cmdline_parse_token_num_t cmd_set_conntrack_common_is_orig_value =
13688 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13689 is_original, RTE_UINT32);
13690 cmdline_parse_token_string_t cmd_set_conntrack_common_enable =
13691 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13693 cmdline_parse_token_num_t cmd_set_conntrack_common_enable_value =
13694 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13696 cmdline_parse_token_string_t cmd_set_conntrack_common_live =
13697 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13699 cmdline_parse_token_num_t cmd_set_conntrack_common_live_value =
13700 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13701 is_live, RTE_UINT32);
13702 cmdline_parse_token_string_t cmd_set_conntrack_common_sack =
13703 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13705 cmdline_parse_token_num_t cmd_set_conntrack_common_sack_value =
13706 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13707 s_ack, RTE_UINT32);
13708 cmdline_parse_token_string_t cmd_set_conntrack_common_cack =
13709 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13711 cmdline_parse_token_num_t cmd_set_conntrack_common_cack_value =
13712 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13713 c_ack, RTE_UINT32);
13714 cmdline_parse_token_string_t cmd_set_conntrack_common_last_dir =
13715 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13716 last_dir, "last_dir");
13717 cmdline_parse_token_num_t cmd_set_conntrack_common_last_dir_value =
13718 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13720 cmdline_parse_token_string_t cmd_set_conntrack_common_liberal =
13721 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13722 liberal, "liberal");
13723 cmdline_parse_token_num_t cmd_set_conntrack_common_liberal_value =
13724 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13726 cmdline_parse_token_string_t cmd_set_conntrack_common_state =
13727 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13729 cmdline_parse_token_num_t cmd_set_conntrack_common_state_value =
13730 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13732 cmdline_parse_token_string_t cmd_set_conntrack_common_max_ackwin =
13733 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13734 max_ack_win, "max_ack_win");
13735 cmdline_parse_token_num_t cmd_set_conntrack_common_max_ackwin_value =
13736 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13737 factor, RTE_UINT8);
13738 cmdline_parse_token_string_t cmd_set_conntrack_common_retrans =
13739 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13741 cmdline_parse_token_num_t cmd_set_conntrack_common_retrans_value =
13742 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13743 re_num, RTE_UINT8);
13744 cmdline_parse_token_string_t cmd_set_conntrack_common_last_win =
13745 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13746 last_win, "last_win");
13747 cmdline_parse_token_num_t cmd_set_conntrack_common_last_win_value =
13748 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13750 cmdline_parse_token_string_t cmd_set_conntrack_common_last_seq =
13751 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13752 last_seq, "last_seq");
13753 cmdline_parse_token_num_t cmd_set_conntrack_common_last_seq_value =
13754 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13756 cmdline_parse_token_string_t cmd_set_conntrack_common_last_ack =
13757 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13758 last_ack, "last_ack");
13759 cmdline_parse_token_num_t cmd_set_conntrack_common_last_ack_value =
13760 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13762 cmdline_parse_token_string_t cmd_set_conntrack_common_last_end =
13763 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13764 last_end, "last_end");
13765 cmdline_parse_token_num_t cmd_set_conntrack_common_last_end_value =
13766 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13768 cmdline_parse_token_string_t cmd_set_conntrack_common_last_index =
13769 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13770 last_index, "last_index");
13771 cmdline_parse_token_num_t cmd_set_conntrack_common_last_index_value =
13772 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13775 static void cmd_set_conntrack_common_parsed(void *parsed_result,
13776 __rte_unused struct cmdline *cl,
13777 __rte_unused void *data)
13779 struct cmd_set_conntrack_common_result *res = parsed_result;
13781 /* No need to swap to big endian. */
13782 conntrack_context.peer_port = res->peer_port;
13783 conntrack_context.is_original_dir = res->is_original;
13784 conntrack_context.enable = res->en;
13785 conntrack_context.live_connection = res->is_live;
13786 conntrack_context.selective_ack = res->s_ack;
13787 conntrack_context.challenge_ack_passed = res->c_ack;
13788 conntrack_context.last_direction = res->ld;
13789 conntrack_context.liberal_mode = res->lb;
13790 conntrack_context.state = (enum rte_flow_conntrack_state)res->stat;
13791 conntrack_context.max_ack_window = res->factor;
13792 conntrack_context.retransmission_limit = res->re_num;
13793 conntrack_context.last_window = res->lw;
13794 conntrack_context.last_index =
13795 (enum rte_flow_conntrack_tcp_last_index)res->li;
13796 conntrack_context.last_seq = res->ls;
13797 conntrack_context.last_ack = res->la;
13798 conntrack_context.last_end = res->le;
13801 cmdline_parse_inst_t cmd_set_conntrack_common = {
13802 .f = cmd_set_conntrack_common_parsed,
13804 .help_str = "set conntrack com peer <port_id> is_orig <dir> enable <en>"
13805 " live <ack_seen> sack <en> cack <passed> last_dir <dir>"
13806 " liberal <en> state <s> max_ack_win <factor> r_lim <num>"
13807 " last_win <win> last_seq <seq> last_ack <ack> last_end <end>"
13808 " last_index <flag>",
13810 (void *)&cmd_set_conntrack_set,
13811 (void *)&cmd_set_conntrack_conntrack,
13812 (void *)&cmd_set_conntrack_common_com,
13813 (void *)&cmd_set_conntrack_common_peer,
13814 (void *)&cmd_set_conntrack_common_peer_value,
13815 (void *)&cmd_set_conntrack_common_is_orig,
13816 (void *)&cmd_set_conntrack_common_is_orig_value,
13817 (void *)&cmd_set_conntrack_common_enable,
13818 (void *)&cmd_set_conntrack_common_enable_value,
13819 (void *)&cmd_set_conntrack_common_live,
13820 (void *)&cmd_set_conntrack_common_live_value,
13821 (void *)&cmd_set_conntrack_common_sack,
13822 (void *)&cmd_set_conntrack_common_sack_value,
13823 (void *)&cmd_set_conntrack_common_cack,
13824 (void *)&cmd_set_conntrack_common_cack_value,
13825 (void *)&cmd_set_conntrack_common_last_dir,
13826 (void *)&cmd_set_conntrack_common_last_dir_value,
13827 (void *)&cmd_set_conntrack_common_liberal,
13828 (void *)&cmd_set_conntrack_common_liberal_value,
13829 (void *)&cmd_set_conntrack_common_state,
13830 (void *)&cmd_set_conntrack_common_state_value,
13831 (void *)&cmd_set_conntrack_common_max_ackwin,
13832 (void *)&cmd_set_conntrack_common_max_ackwin_value,
13833 (void *)&cmd_set_conntrack_common_retrans,
13834 (void *)&cmd_set_conntrack_common_retrans_value,
13835 (void *)&cmd_set_conntrack_common_last_win,
13836 (void *)&cmd_set_conntrack_common_last_win_value,
13837 (void *)&cmd_set_conntrack_common_last_seq,
13838 (void *)&cmd_set_conntrack_common_last_seq_value,
13839 (void *)&cmd_set_conntrack_common_last_ack,
13840 (void *)&cmd_set_conntrack_common_last_ack_value,
13841 (void *)&cmd_set_conntrack_common_last_end,
13842 (void *)&cmd_set_conntrack_common_last_end_value,
13843 (void *)&cmd_set_conntrack_common_last_index,
13844 (void *)&cmd_set_conntrack_common_last_index_value,
13849 /** Set connection tracking object both directions' details */
13850 struct cmd_set_conntrack_dir_result {
13851 cmdline_fixed_string_t set;
13852 cmdline_fixed_string_t conntrack;
13853 cmdline_fixed_string_t dir;
13854 cmdline_fixed_string_t scale;
13855 cmdline_fixed_string_t fin;
13856 cmdline_fixed_string_t ack_seen;
13857 cmdline_fixed_string_t unack;
13858 cmdline_fixed_string_t sent_end;
13859 cmdline_fixed_string_t reply_end;
13860 cmdline_fixed_string_t max_win;
13861 cmdline_fixed_string_t max_ack;
13872 cmdline_parse_token_string_t cmd_set_conntrack_dir_set =
13873 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
13875 cmdline_parse_token_string_t cmd_set_conntrack_dir_conntrack =
13876 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
13877 conntrack, "conntrack");
13878 cmdline_parse_token_string_t cmd_set_conntrack_dir_dir =
13879 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
13881 cmdline_parse_token_string_t cmd_set_conntrack_dir_scale =
13882 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
13884 cmdline_parse_token_num_t cmd_set_conntrack_dir_scale_value =
13885 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
13886 factor, RTE_UINT32);
13887 cmdline_parse_token_string_t cmd_set_conntrack_dir_fin =
13888 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
13890 cmdline_parse_token_num_t cmd_set_conntrack_dir_fin_value =
13891 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
13893 cmdline_parse_token_string_t cmd_set_conntrack_dir_ack =
13894 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
13895 ack_seen, "acked");
13896 cmdline_parse_token_num_t cmd_set_conntrack_dir_ack_value =
13897 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
13899 cmdline_parse_token_string_t cmd_set_conntrack_dir_unack_data =
13900 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
13901 unack, "unack_data");
13902 cmdline_parse_token_num_t cmd_set_conntrack_dir_unack_data_value =
13903 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
13905 cmdline_parse_token_string_t cmd_set_conntrack_dir_sent_end =
13906 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
13907 sent_end, "sent_end");
13908 cmdline_parse_token_num_t cmd_set_conntrack_dir_sent_end_value =
13909 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
13911 cmdline_parse_token_string_t cmd_set_conntrack_dir_reply_end =
13912 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
13913 reply_end, "reply_end");
13914 cmdline_parse_token_num_t cmd_set_conntrack_dir_reply_end_value =
13915 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
13917 cmdline_parse_token_string_t cmd_set_conntrack_dir_max_win =
13918 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
13919 max_win, "max_win");
13920 cmdline_parse_token_num_t cmd_set_conntrack_dir_max_win_value =
13921 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
13923 cmdline_parse_token_string_t cmd_set_conntrack_dir_max_ack =
13924 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
13925 max_ack, "max_ack");
13926 cmdline_parse_token_num_t cmd_set_conntrack_dir_max_ack_value =
13927 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
13930 static void cmd_set_conntrack_dir_parsed(void *parsed_result,
13931 __rte_unused struct cmdline *cl,
13932 __rte_unused void *data)
13934 struct cmd_set_conntrack_dir_result *res = parsed_result;
13935 struct rte_flow_tcp_dir_param *dir = NULL;
13937 if (strcmp(res->dir, "orig") == 0)
13938 dir = &conntrack_context.original_dir;
13939 else if (strcmp(res->dir, "rply") == 0)
13940 dir = &conntrack_context.reply_dir;
13943 dir->scale = res->factor;
13944 dir->close_initiated = res->f;
13945 dir->last_ack_seen = res->as;
13946 dir->data_unacked = res->un;
13947 dir->sent_end = res->se;
13948 dir->reply_end = res->re;
13949 dir->max_ack = res->ma;
13950 dir->max_win = res->mw;
13953 cmdline_parse_inst_t cmd_set_conntrack_dir = {
13954 .f = cmd_set_conntrack_dir_parsed,
13956 .help_str = "set conntrack orig|rply scale <factor> fin <sent>"
13957 " acked <seen> unack_data <unack> sent_end <sent>"
13958 " reply_end <reply> max_win <win> max_ack <ack>",
13960 (void *)&cmd_set_conntrack_set,
13961 (void *)&cmd_set_conntrack_conntrack,
13962 (void *)&cmd_set_conntrack_dir_dir,
13963 (void *)&cmd_set_conntrack_dir_scale,
13964 (void *)&cmd_set_conntrack_dir_scale_value,
13965 (void *)&cmd_set_conntrack_dir_fin,
13966 (void *)&cmd_set_conntrack_dir_fin_value,
13967 (void *)&cmd_set_conntrack_dir_ack,
13968 (void *)&cmd_set_conntrack_dir_ack_value,
13969 (void *)&cmd_set_conntrack_dir_unack_data,
13970 (void *)&cmd_set_conntrack_dir_unack_data_value,
13971 (void *)&cmd_set_conntrack_dir_sent_end,
13972 (void *)&cmd_set_conntrack_dir_sent_end_value,
13973 (void *)&cmd_set_conntrack_dir_reply_end,
13974 (void *)&cmd_set_conntrack_dir_reply_end_value,
13975 (void *)&cmd_set_conntrack_dir_max_win,
13976 (void *)&cmd_set_conntrack_dir_max_win_value,
13977 (void *)&cmd_set_conntrack_dir_max_ack,
13978 (void *)&cmd_set_conntrack_dir_max_ack_value,
13983 /* Strict link priority scheduling mode setting */
13985 cmd_strict_link_prio_parsed(
13986 void *parsed_result,
13987 __rte_unused struct cmdline *cl,
13988 __rte_unused void *data)
13990 struct cmd_vf_tc_bw_result *res = parsed_result;
13991 int ret = -ENOTSUP;
13993 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13996 #ifdef RTE_NET_I40E
13997 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
14004 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
14007 printf("invalid port_id %d\n", res->port_id);
14010 printf("function not implemented\n");
14013 printf("programming error: (%s)\n", strerror(-ret));
14017 cmdline_parse_inst_t cmd_strict_link_prio = {
14018 .f = cmd_strict_link_prio_parsed,
14020 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
14022 (void *)&cmd_vf_tc_bw_set,
14023 (void *)&cmd_vf_tc_bw_tx,
14024 (void *)&cmd_vf_tc_bw_strict_link_prio,
14025 (void *)&cmd_vf_tc_bw_port_id,
14026 (void *)&cmd_vf_tc_bw_tc_map,
14031 /* Load dynamic device personalization*/
14032 struct cmd_ddp_add_result {
14033 cmdline_fixed_string_t ddp;
14034 cmdline_fixed_string_t add;
14039 cmdline_parse_token_string_t cmd_ddp_add_ddp =
14040 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
14041 cmdline_parse_token_string_t cmd_ddp_add_add =
14042 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
14043 cmdline_parse_token_num_t cmd_ddp_add_port_id =
14044 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id,
14046 cmdline_parse_token_string_t cmd_ddp_add_filepath =
14047 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
14050 cmd_ddp_add_parsed(
14051 void *parsed_result,
14052 __rte_unused struct cmdline *cl,
14053 __rte_unused void *data)
14055 struct cmd_ddp_add_result *res = parsed_result;
14061 int ret = -ENOTSUP;
14063 if (!all_ports_stopped()) {
14064 printf("Please stop all ports first\n");
14068 filepath = strdup(res->filepath);
14069 if (filepath == NULL) {
14070 printf("Failed to allocate memory\n");
14073 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
14075 buff = open_file(file_fld[0], &size);
14077 free((void *)filepath);
14081 #ifdef RTE_NET_I40E
14082 if (ret == -ENOTSUP)
14083 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14085 RTE_PMD_I40E_PKG_OP_WR_ADD);
14088 if (ret == -EEXIST)
14089 printf("Profile has already existed.\n");
14091 printf("Failed to load profile.\n");
14092 else if (file_num == 2)
14093 save_file(file_fld[1], buff, size);
14096 free((void *)filepath);
14099 cmdline_parse_inst_t cmd_ddp_add = {
14100 .f = cmd_ddp_add_parsed,
14102 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
14104 (void *)&cmd_ddp_add_ddp,
14105 (void *)&cmd_ddp_add_add,
14106 (void *)&cmd_ddp_add_port_id,
14107 (void *)&cmd_ddp_add_filepath,
14112 /* Delete dynamic device personalization*/
14113 struct cmd_ddp_del_result {
14114 cmdline_fixed_string_t ddp;
14115 cmdline_fixed_string_t del;
14120 cmdline_parse_token_string_t cmd_ddp_del_ddp =
14121 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
14122 cmdline_parse_token_string_t cmd_ddp_del_del =
14123 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
14124 cmdline_parse_token_num_t cmd_ddp_del_port_id =
14125 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, RTE_UINT16);
14126 cmdline_parse_token_string_t cmd_ddp_del_filepath =
14127 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
14130 cmd_ddp_del_parsed(
14131 void *parsed_result,
14132 __rte_unused struct cmdline *cl,
14133 __rte_unused void *data)
14135 struct cmd_ddp_del_result *res = parsed_result;
14138 int ret = -ENOTSUP;
14140 if (!all_ports_stopped()) {
14141 printf("Please stop all ports first\n");
14145 buff = open_file(res->filepath, &size);
14149 #ifdef RTE_NET_I40E
14150 if (ret == -ENOTSUP)
14151 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14153 RTE_PMD_I40E_PKG_OP_WR_DEL);
14156 if (ret == -EACCES)
14157 printf("Profile does not exist.\n");
14159 printf("Failed to delete profile.\n");
14164 cmdline_parse_inst_t cmd_ddp_del = {
14165 .f = cmd_ddp_del_parsed,
14167 .help_str = "ddp del <port_id> <backup_profile_path>",
14169 (void *)&cmd_ddp_del_ddp,
14170 (void *)&cmd_ddp_del_del,
14171 (void *)&cmd_ddp_del_port_id,
14172 (void *)&cmd_ddp_del_filepath,
14177 /* Get dynamic device personalization profile info */
14178 struct cmd_ddp_info_result {
14179 cmdline_fixed_string_t ddp;
14180 cmdline_fixed_string_t get;
14181 cmdline_fixed_string_t info;
14185 cmdline_parse_token_string_t cmd_ddp_info_ddp =
14186 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
14187 cmdline_parse_token_string_t cmd_ddp_info_get =
14188 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
14189 cmdline_parse_token_string_t cmd_ddp_info_info =
14190 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
14191 cmdline_parse_token_string_t cmd_ddp_info_filepath =
14192 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
14195 cmd_ddp_info_parsed(
14196 void *parsed_result,
14197 __rte_unused struct cmdline *cl,
14198 __rte_unused void *data)
14200 struct cmd_ddp_info_result *res = parsed_result;
14203 int ret = -ENOTSUP;
14204 #ifdef RTE_NET_I40E
14207 uint32_t buff_size = 0;
14208 struct rte_pmd_i40e_profile_info info;
14209 uint32_t dev_num = 0;
14210 struct rte_pmd_i40e_ddp_device_id *devs;
14211 uint32_t proto_num = 0;
14212 struct rte_pmd_i40e_proto_info *proto = NULL;
14213 uint32_t pctype_num = 0;
14214 struct rte_pmd_i40e_ptype_info *pctype;
14215 uint32_t ptype_num = 0;
14216 struct rte_pmd_i40e_ptype_info *ptype;
14221 pkg = open_file(res->filepath, &pkg_size);
14225 #ifdef RTE_NET_I40E
14226 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14227 (uint8_t *)&info, sizeof(info),
14228 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
14230 printf("Global Track id: 0x%x\n", info.track_id);
14231 printf("Global Version: %d.%d.%d.%d\n",
14232 info.version.major,
14233 info.version.minor,
14234 info.version.update,
14235 info.version.draft);
14236 printf("Global Package name: %s\n\n", info.name);
14239 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14240 (uint8_t *)&info, sizeof(info),
14241 RTE_PMD_I40E_PKG_INFO_HEADER);
14243 printf("i40e Profile Track id: 0x%x\n", info.track_id);
14244 printf("i40e Profile Version: %d.%d.%d.%d\n",
14245 info.version.major,
14246 info.version.minor,
14247 info.version.update,
14248 info.version.draft);
14249 printf("i40e Profile name: %s\n\n", info.name);
14252 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14253 (uint8_t *)&buff_size, sizeof(buff_size),
14254 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
14255 if (!ret && buff_size) {
14256 buff = (uint8_t *)malloc(buff_size);
14258 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14260 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
14262 printf("Package Notes:\n%s\n\n", buff);
14267 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14268 (uint8_t *)&dev_num, sizeof(dev_num),
14269 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
14270 if (!ret && dev_num) {
14271 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
14272 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
14274 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14275 (uint8_t *)devs, buff_size,
14276 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
14278 printf("List of supported devices:\n");
14279 for (i = 0; i < dev_num; i++) {
14280 printf(" %04X:%04X %04X:%04X\n",
14281 devs[i].vendor_dev_id >> 16,
14282 devs[i].vendor_dev_id & 0xFFFF,
14283 devs[i].sub_vendor_dev_id >> 16,
14284 devs[i].sub_vendor_dev_id & 0xFFFF);
14292 /* get information about protocols and packet types */
14293 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14294 (uint8_t *)&proto_num, sizeof(proto_num),
14295 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
14296 if (ret || !proto_num)
14297 goto no_print_return;
14299 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
14300 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
14302 goto no_print_return;
14304 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
14306 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
14308 printf("List of used protocols:\n");
14309 for (i = 0; i < proto_num; i++)
14310 printf(" %2u: %s\n", proto[i].proto_id,
14314 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14315 (uint8_t *)&pctype_num, sizeof(pctype_num),
14316 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
14317 if (ret || !pctype_num)
14318 goto no_print_pctypes;
14320 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14321 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14323 goto no_print_pctypes;
14325 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
14327 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
14330 goto no_print_pctypes;
14333 printf("List of defined packet classification types:\n");
14334 for (i = 0; i < pctype_num; i++) {
14335 printf(" %2u:", pctype[i].ptype_id);
14336 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14337 proto_id = pctype[i].protocols[j];
14338 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14339 for (n = 0; n < proto_num; n++) {
14340 if (proto[n].proto_id == proto_id) {
14341 printf(" %s", proto[n].name);
14354 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
14356 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
14357 if (ret || !ptype_num)
14358 goto no_print_return;
14360 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14361 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14363 goto no_print_return;
14365 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
14367 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
14370 goto no_print_return;
14372 printf("List of defined packet types:\n");
14373 for (i = 0; i < ptype_num; i++) {
14374 printf(" %2u:", ptype[i].ptype_id);
14375 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14376 proto_id = ptype[i].protocols[j];
14377 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14378 for (n = 0; n < proto_num; n++) {
14379 if (proto[n].proto_id == proto_id) {
14380 printf(" %s", proto[n].name);
14396 if (ret == -ENOTSUP)
14397 printf("Function not supported in PMD driver\n");
14401 cmdline_parse_inst_t cmd_ddp_get_info = {
14402 .f = cmd_ddp_info_parsed,
14404 .help_str = "ddp get info <profile_path>",
14406 (void *)&cmd_ddp_info_ddp,
14407 (void *)&cmd_ddp_info_get,
14408 (void *)&cmd_ddp_info_info,
14409 (void *)&cmd_ddp_info_filepath,
14414 /* Get dynamic device personalization profile info list*/
14415 #define PROFILE_INFO_SIZE 48
14416 #define MAX_PROFILE_NUM 16
14418 struct cmd_ddp_get_list_result {
14419 cmdline_fixed_string_t ddp;
14420 cmdline_fixed_string_t get;
14421 cmdline_fixed_string_t list;
14425 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
14426 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
14427 cmdline_parse_token_string_t cmd_ddp_get_list_get =
14428 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
14429 cmdline_parse_token_string_t cmd_ddp_get_list_list =
14430 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
14431 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
14432 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id,
14436 cmd_ddp_get_list_parsed(
14437 __rte_unused void *parsed_result,
14438 __rte_unused struct cmdline *cl,
14439 __rte_unused void *data)
14441 #ifdef RTE_NET_I40E
14442 struct cmd_ddp_get_list_result *res = parsed_result;
14443 struct rte_pmd_i40e_profile_list *p_list;
14444 struct rte_pmd_i40e_profile_info *p_info;
14449 int ret = -ENOTSUP;
14451 #ifdef RTE_NET_I40E
14452 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
14453 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
14455 printf("%s: Failed to malloc buffer\n", __func__);
14459 if (ret == -ENOTSUP)
14460 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
14461 (uint8_t *)p_list, size);
14464 p_num = p_list->p_count;
14465 printf("Profile number is: %d\n\n", p_num);
14467 for (i = 0; i < p_num; i++) {
14468 p_info = &p_list->p_info[i];
14469 printf("Profile %d:\n", i);
14470 printf("Track id: 0x%x\n", p_info->track_id);
14471 printf("Version: %d.%d.%d.%d\n",
14472 p_info->version.major,
14473 p_info->version.minor,
14474 p_info->version.update,
14475 p_info->version.draft);
14476 printf("Profile name: %s\n\n", p_info->name);
14484 printf("Failed to get ddp list\n");
14487 cmdline_parse_inst_t cmd_ddp_get_list = {
14488 .f = cmd_ddp_get_list_parsed,
14490 .help_str = "ddp get list <port_id>",
14492 (void *)&cmd_ddp_get_list_ddp,
14493 (void *)&cmd_ddp_get_list_get,
14494 (void *)&cmd_ddp_get_list_list,
14495 (void *)&cmd_ddp_get_list_port_id,
14500 /* Configure input set */
14501 struct cmd_cfg_input_set_result {
14502 cmdline_fixed_string_t port;
14503 cmdline_fixed_string_t cfg;
14505 cmdline_fixed_string_t pctype;
14507 cmdline_fixed_string_t inset_type;
14508 cmdline_fixed_string_t opt;
14509 cmdline_fixed_string_t field;
14514 cmd_cfg_input_set_parsed(
14515 __rte_unused void *parsed_result,
14516 __rte_unused struct cmdline *cl,
14517 __rte_unused void *data)
14519 #ifdef RTE_NET_I40E
14520 struct cmd_cfg_input_set_result *res = parsed_result;
14521 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
14522 struct rte_pmd_i40e_inset inset;
14524 int ret = -ENOTSUP;
14526 if (!all_ports_stopped()) {
14527 printf("Please stop all ports first\n");
14531 #ifdef RTE_NET_I40E
14532 if (!strcmp(res->inset_type, "hash_inset"))
14533 inset_type = INSET_HASH;
14534 else if (!strcmp(res->inset_type, "fdir_inset"))
14535 inset_type = INSET_FDIR;
14536 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
14537 inset_type = INSET_FDIR_FLX;
14538 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
14539 &inset, inset_type);
14541 printf("Failed to get input set.\n");
14545 if (!strcmp(res->opt, "get")) {
14546 ret = rte_pmd_i40e_inset_field_get(inset.inset,
14549 printf("Field index %d is enabled.\n", res->field_idx);
14551 printf("Field index %d is disabled.\n", res->field_idx);
14553 } else if (!strcmp(res->opt, "set"))
14554 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
14556 else if (!strcmp(res->opt, "clear"))
14557 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
14560 printf("Failed to configure input set field.\n");
14564 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
14565 &inset, inset_type);
14567 printf("Failed to set input set.\n");
14572 if (ret == -ENOTSUP)
14573 printf("Function not supported\n");
14576 cmdline_parse_token_string_t cmd_cfg_input_set_port =
14577 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14579 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
14580 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14582 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
14583 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14584 port_id, RTE_UINT16);
14585 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
14586 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14588 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
14589 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14590 pctype_id, RTE_UINT8);
14591 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
14592 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14594 "hash_inset#fdir_inset#fdir_flx_inset");
14595 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
14596 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14597 opt, "get#set#clear");
14598 cmdline_parse_token_string_t cmd_cfg_input_set_field =
14599 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14601 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
14602 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14603 field_idx, RTE_UINT8);
14605 cmdline_parse_inst_t cmd_cfg_input_set = {
14606 .f = cmd_cfg_input_set_parsed,
14608 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
14609 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
14611 (void *)&cmd_cfg_input_set_port,
14612 (void *)&cmd_cfg_input_set_cfg,
14613 (void *)&cmd_cfg_input_set_port_id,
14614 (void *)&cmd_cfg_input_set_pctype,
14615 (void *)&cmd_cfg_input_set_pctype_id,
14616 (void *)&cmd_cfg_input_set_inset_type,
14617 (void *)&cmd_cfg_input_set_opt,
14618 (void *)&cmd_cfg_input_set_field,
14619 (void *)&cmd_cfg_input_set_field_idx,
14624 /* Clear input set */
14625 struct cmd_clear_input_set_result {
14626 cmdline_fixed_string_t port;
14627 cmdline_fixed_string_t cfg;
14629 cmdline_fixed_string_t pctype;
14631 cmdline_fixed_string_t inset_type;
14632 cmdline_fixed_string_t clear;
14633 cmdline_fixed_string_t all;
14637 cmd_clear_input_set_parsed(
14638 __rte_unused void *parsed_result,
14639 __rte_unused struct cmdline *cl,
14640 __rte_unused void *data)
14642 #ifdef RTE_NET_I40E
14643 struct cmd_clear_input_set_result *res = parsed_result;
14644 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
14645 struct rte_pmd_i40e_inset inset;
14647 int ret = -ENOTSUP;
14649 if (!all_ports_stopped()) {
14650 printf("Please stop all ports first\n");
14654 #ifdef RTE_NET_I40E
14655 if (!strcmp(res->inset_type, "hash_inset"))
14656 inset_type = INSET_HASH;
14657 else if (!strcmp(res->inset_type, "fdir_inset"))
14658 inset_type = INSET_FDIR;
14659 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
14660 inset_type = INSET_FDIR_FLX;
14662 memset(&inset, 0, sizeof(inset));
14664 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
14665 &inset, inset_type);
14667 printf("Failed to clear input set.\n");
14673 if (ret == -ENOTSUP)
14674 printf("Function not supported\n");
14677 cmdline_parse_token_string_t cmd_clear_input_set_port =
14678 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14680 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
14681 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14683 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
14684 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
14685 port_id, RTE_UINT16);
14686 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
14687 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14689 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
14690 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
14691 pctype_id, RTE_UINT8);
14692 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
14693 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14695 "hash_inset#fdir_inset#fdir_flx_inset");
14696 cmdline_parse_token_string_t cmd_clear_input_set_clear =
14697 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14699 cmdline_parse_token_string_t cmd_clear_input_set_all =
14700 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14703 cmdline_parse_inst_t cmd_clear_input_set = {
14704 .f = cmd_clear_input_set_parsed,
14706 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
14707 "fdir_inset|fdir_flx_inset clear all",
14709 (void *)&cmd_clear_input_set_port,
14710 (void *)&cmd_clear_input_set_cfg,
14711 (void *)&cmd_clear_input_set_port_id,
14712 (void *)&cmd_clear_input_set_pctype,
14713 (void *)&cmd_clear_input_set_pctype_id,
14714 (void *)&cmd_clear_input_set_inset_type,
14715 (void *)&cmd_clear_input_set_clear,
14716 (void *)&cmd_clear_input_set_all,
14721 /* show vf stats */
14723 /* Common result structure for show vf stats */
14724 struct cmd_show_vf_stats_result {
14725 cmdline_fixed_string_t show;
14726 cmdline_fixed_string_t vf;
14727 cmdline_fixed_string_t stats;
14732 /* Common CLI fields show vf stats*/
14733 cmdline_parse_token_string_t cmd_show_vf_stats_show =
14734 TOKEN_STRING_INITIALIZER
14735 (struct cmd_show_vf_stats_result,
14737 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
14738 TOKEN_STRING_INITIALIZER
14739 (struct cmd_show_vf_stats_result,
14741 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
14742 TOKEN_STRING_INITIALIZER
14743 (struct cmd_show_vf_stats_result,
14745 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
14746 TOKEN_NUM_INITIALIZER
14747 (struct cmd_show_vf_stats_result,
14748 port_id, RTE_UINT16);
14749 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
14750 TOKEN_NUM_INITIALIZER
14751 (struct cmd_show_vf_stats_result,
14752 vf_id, RTE_UINT16);
14755 cmd_show_vf_stats_parsed(
14756 void *parsed_result,
14757 __rte_unused struct cmdline *cl,
14758 __rte_unused void *data)
14760 struct cmd_show_vf_stats_result *res = parsed_result;
14761 struct rte_eth_stats stats;
14762 int ret = -ENOTSUP;
14763 static const char *nic_stats_border = "########################";
14765 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14768 memset(&stats, 0, sizeof(stats));
14770 #ifdef RTE_NET_I40E
14771 if (ret == -ENOTSUP)
14772 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
14776 #ifdef RTE_NET_BNXT
14777 if (ret == -ENOTSUP)
14778 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
14787 printf("invalid vf_id %d\n", res->vf_id);
14790 printf("invalid port_id %d\n", res->port_id);
14793 printf("function not implemented\n");
14796 printf("programming error: (%s)\n", strerror(-ret));
14799 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
14800 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
14802 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
14804 stats.ipackets, stats.imissed, stats.ibytes);
14805 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
14806 printf(" RX-nombuf: %-10"PRIu64"\n",
14808 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
14810 stats.opackets, stats.oerrors, stats.obytes);
14812 printf(" %s############################%s\n",
14813 nic_stats_border, nic_stats_border);
14816 cmdline_parse_inst_t cmd_show_vf_stats = {
14817 .f = cmd_show_vf_stats_parsed,
14819 .help_str = "show vf stats <port_id> <vf_id>",
14821 (void *)&cmd_show_vf_stats_show,
14822 (void *)&cmd_show_vf_stats_vf,
14823 (void *)&cmd_show_vf_stats_stats,
14824 (void *)&cmd_show_vf_stats_port_id,
14825 (void *)&cmd_show_vf_stats_vf_id,
14830 /* clear vf stats */
14832 /* Common result structure for clear vf stats */
14833 struct cmd_clear_vf_stats_result {
14834 cmdline_fixed_string_t clear;
14835 cmdline_fixed_string_t vf;
14836 cmdline_fixed_string_t stats;
14841 /* Common CLI fields clear vf stats*/
14842 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
14843 TOKEN_STRING_INITIALIZER
14844 (struct cmd_clear_vf_stats_result,
14846 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
14847 TOKEN_STRING_INITIALIZER
14848 (struct cmd_clear_vf_stats_result,
14850 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
14851 TOKEN_STRING_INITIALIZER
14852 (struct cmd_clear_vf_stats_result,
14854 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
14855 TOKEN_NUM_INITIALIZER
14856 (struct cmd_clear_vf_stats_result,
14857 port_id, RTE_UINT16);
14858 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
14859 TOKEN_NUM_INITIALIZER
14860 (struct cmd_clear_vf_stats_result,
14861 vf_id, RTE_UINT16);
14864 cmd_clear_vf_stats_parsed(
14865 void *parsed_result,
14866 __rte_unused struct cmdline *cl,
14867 __rte_unused void *data)
14869 struct cmd_clear_vf_stats_result *res = parsed_result;
14870 int ret = -ENOTSUP;
14872 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14875 #ifdef RTE_NET_I40E
14876 if (ret == -ENOTSUP)
14877 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
14880 #ifdef RTE_NET_BNXT
14881 if (ret == -ENOTSUP)
14882 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
14890 printf("invalid vf_id %d\n", res->vf_id);
14893 printf("invalid port_id %d\n", res->port_id);
14896 printf("function not implemented\n");
14899 printf("programming error: (%s)\n", strerror(-ret));
14903 cmdline_parse_inst_t cmd_clear_vf_stats = {
14904 .f = cmd_clear_vf_stats_parsed,
14906 .help_str = "clear vf stats <port_id> <vf_id>",
14908 (void *)&cmd_clear_vf_stats_clear,
14909 (void *)&cmd_clear_vf_stats_vf,
14910 (void *)&cmd_clear_vf_stats_stats,
14911 (void *)&cmd_clear_vf_stats_port_id,
14912 (void *)&cmd_clear_vf_stats_vf_id,
14917 /* port config pctype mapping reset */
14919 /* Common result structure for port config pctype mapping reset */
14920 struct cmd_pctype_mapping_reset_result {
14921 cmdline_fixed_string_t port;
14922 cmdline_fixed_string_t config;
14924 cmdline_fixed_string_t pctype;
14925 cmdline_fixed_string_t mapping;
14926 cmdline_fixed_string_t reset;
14929 /* Common CLI fields for port config pctype mapping reset*/
14930 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
14931 TOKEN_STRING_INITIALIZER
14932 (struct cmd_pctype_mapping_reset_result,
14934 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
14935 TOKEN_STRING_INITIALIZER
14936 (struct cmd_pctype_mapping_reset_result,
14938 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
14939 TOKEN_NUM_INITIALIZER
14940 (struct cmd_pctype_mapping_reset_result,
14941 port_id, RTE_UINT16);
14942 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
14943 TOKEN_STRING_INITIALIZER
14944 (struct cmd_pctype_mapping_reset_result,
14946 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
14947 TOKEN_STRING_INITIALIZER
14948 (struct cmd_pctype_mapping_reset_result,
14949 mapping, "mapping");
14950 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
14951 TOKEN_STRING_INITIALIZER
14952 (struct cmd_pctype_mapping_reset_result,
14956 cmd_pctype_mapping_reset_parsed(
14957 void *parsed_result,
14958 __rte_unused struct cmdline *cl,
14959 __rte_unused void *data)
14961 struct cmd_pctype_mapping_reset_result *res = parsed_result;
14962 int ret = -ENOTSUP;
14964 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14967 #ifdef RTE_NET_I40E
14968 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
14975 printf("invalid port_id %d\n", res->port_id);
14978 printf("function not implemented\n");
14981 printf("programming error: (%s)\n", strerror(-ret));
14985 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
14986 .f = cmd_pctype_mapping_reset_parsed,
14988 .help_str = "port config <port_id> pctype mapping reset",
14990 (void *)&cmd_pctype_mapping_reset_port,
14991 (void *)&cmd_pctype_mapping_reset_config,
14992 (void *)&cmd_pctype_mapping_reset_port_id,
14993 (void *)&cmd_pctype_mapping_reset_pctype,
14994 (void *)&cmd_pctype_mapping_reset_mapping,
14995 (void *)&cmd_pctype_mapping_reset_reset,
15000 /* show port pctype mapping */
15002 /* Common result structure for show port pctype mapping */
15003 struct cmd_pctype_mapping_get_result {
15004 cmdline_fixed_string_t show;
15005 cmdline_fixed_string_t port;
15007 cmdline_fixed_string_t pctype;
15008 cmdline_fixed_string_t mapping;
15011 /* Common CLI fields for pctype mapping get */
15012 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
15013 TOKEN_STRING_INITIALIZER
15014 (struct cmd_pctype_mapping_get_result,
15016 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
15017 TOKEN_STRING_INITIALIZER
15018 (struct cmd_pctype_mapping_get_result,
15020 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
15021 TOKEN_NUM_INITIALIZER
15022 (struct cmd_pctype_mapping_get_result,
15023 port_id, RTE_UINT16);
15024 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
15025 TOKEN_STRING_INITIALIZER
15026 (struct cmd_pctype_mapping_get_result,
15028 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
15029 TOKEN_STRING_INITIALIZER
15030 (struct cmd_pctype_mapping_get_result,
15031 mapping, "mapping");
15034 cmd_pctype_mapping_get_parsed(
15035 void *parsed_result,
15036 __rte_unused struct cmdline *cl,
15037 __rte_unused void *data)
15039 struct cmd_pctype_mapping_get_result *res = parsed_result;
15040 int ret = -ENOTSUP;
15041 #ifdef RTE_NET_I40E
15042 struct rte_pmd_i40e_flow_type_mapping
15043 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
15044 int i, j, first_pctype;
15047 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15050 #ifdef RTE_NET_I40E
15051 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
15058 printf("invalid port_id %d\n", res->port_id);
15061 printf("function not implemented\n");
15064 printf("programming error: (%s)\n", strerror(-ret));
15068 #ifdef RTE_NET_I40E
15069 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
15070 if (mapping[i].pctype != 0ULL) {
15073 printf("pctype: ");
15074 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
15075 if (mapping[i].pctype & (1ULL << j)) {
15076 printf(first_pctype ?
15077 "%02d" : ",%02d", j);
15081 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
15087 cmdline_parse_inst_t cmd_pctype_mapping_get = {
15088 .f = cmd_pctype_mapping_get_parsed,
15090 .help_str = "show port <port_id> pctype mapping",
15092 (void *)&cmd_pctype_mapping_get_show,
15093 (void *)&cmd_pctype_mapping_get_port,
15094 (void *)&cmd_pctype_mapping_get_port_id,
15095 (void *)&cmd_pctype_mapping_get_pctype,
15096 (void *)&cmd_pctype_mapping_get_mapping,
15101 /* port config pctype mapping update */
15103 /* Common result structure for port config pctype mapping update */
15104 struct cmd_pctype_mapping_update_result {
15105 cmdline_fixed_string_t port;
15106 cmdline_fixed_string_t config;
15108 cmdline_fixed_string_t pctype;
15109 cmdline_fixed_string_t mapping;
15110 cmdline_fixed_string_t update;
15111 cmdline_fixed_string_t pctype_list;
15112 uint16_t flow_type;
15115 /* Common CLI fields for pctype mapping update*/
15116 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
15117 TOKEN_STRING_INITIALIZER
15118 (struct cmd_pctype_mapping_update_result,
15120 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
15121 TOKEN_STRING_INITIALIZER
15122 (struct cmd_pctype_mapping_update_result,
15124 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
15125 TOKEN_NUM_INITIALIZER
15126 (struct cmd_pctype_mapping_update_result,
15127 port_id, RTE_UINT16);
15128 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
15129 TOKEN_STRING_INITIALIZER
15130 (struct cmd_pctype_mapping_update_result,
15132 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
15133 TOKEN_STRING_INITIALIZER
15134 (struct cmd_pctype_mapping_update_result,
15135 mapping, "mapping");
15136 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
15137 TOKEN_STRING_INITIALIZER
15138 (struct cmd_pctype_mapping_update_result,
15140 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
15141 TOKEN_STRING_INITIALIZER
15142 (struct cmd_pctype_mapping_update_result,
15143 pctype_list, NULL);
15144 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
15145 TOKEN_NUM_INITIALIZER
15146 (struct cmd_pctype_mapping_update_result,
15147 flow_type, RTE_UINT16);
15150 cmd_pctype_mapping_update_parsed(
15151 void *parsed_result,
15152 __rte_unused struct cmdline *cl,
15153 __rte_unused void *data)
15155 struct cmd_pctype_mapping_update_result *res = parsed_result;
15156 int ret = -ENOTSUP;
15157 #ifdef RTE_NET_I40E
15158 struct rte_pmd_i40e_flow_type_mapping mapping;
15160 unsigned int nb_item;
15161 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
15164 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15167 #ifdef RTE_NET_I40E
15168 nb_item = parse_item_list(res->pctype_list, "pctypes",
15169 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
15170 mapping.flow_type = res->flow_type;
15171 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
15172 mapping.pctype |= (1ULL << pctype_list[i]);
15173 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
15183 printf("invalid pctype or flow type\n");
15186 printf("invalid port_id %d\n", res->port_id);
15189 printf("function not implemented\n");
15192 printf("programming error: (%s)\n", strerror(-ret));
15196 cmdline_parse_inst_t cmd_pctype_mapping_update = {
15197 .f = cmd_pctype_mapping_update_parsed,
15199 .help_str = "port config <port_id> pctype mapping update"
15200 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
15202 (void *)&cmd_pctype_mapping_update_port,
15203 (void *)&cmd_pctype_mapping_update_config,
15204 (void *)&cmd_pctype_mapping_update_port_id,
15205 (void *)&cmd_pctype_mapping_update_pctype,
15206 (void *)&cmd_pctype_mapping_update_mapping,
15207 (void *)&cmd_pctype_mapping_update_update,
15208 (void *)&cmd_pctype_mapping_update_pc_type,
15209 (void *)&cmd_pctype_mapping_update_flow_type,
15214 /* ptype mapping get */
15216 /* Common result structure for ptype mapping get */
15217 struct cmd_ptype_mapping_get_result {
15218 cmdline_fixed_string_t ptype;
15219 cmdline_fixed_string_t mapping;
15220 cmdline_fixed_string_t get;
15222 uint8_t valid_only;
15225 /* Common CLI fields for ptype mapping get */
15226 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
15227 TOKEN_STRING_INITIALIZER
15228 (struct cmd_ptype_mapping_get_result,
15230 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
15231 TOKEN_STRING_INITIALIZER
15232 (struct cmd_ptype_mapping_get_result,
15233 mapping, "mapping");
15234 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
15235 TOKEN_STRING_INITIALIZER
15236 (struct cmd_ptype_mapping_get_result,
15238 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
15239 TOKEN_NUM_INITIALIZER
15240 (struct cmd_ptype_mapping_get_result,
15241 port_id, RTE_UINT16);
15242 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
15243 TOKEN_NUM_INITIALIZER
15244 (struct cmd_ptype_mapping_get_result,
15245 valid_only, RTE_UINT8);
15248 cmd_ptype_mapping_get_parsed(
15249 void *parsed_result,
15250 __rte_unused struct cmdline *cl,
15251 __rte_unused void *data)
15253 struct cmd_ptype_mapping_get_result *res = parsed_result;
15254 int ret = -ENOTSUP;
15255 #ifdef RTE_NET_I40E
15256 int max_ptype_num = 256;
15257 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
15262 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15265 #ifdef RTE_NET_I40E
15266 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
15277 printf("invalid port_id %d\n", res->port_id);
15280 printf("function not implemented\n");
15283 printf("programming error: (%s)\n", strerror(-ret));
15286 #ifdef RTE_NET_I40E
15288 for (i = 0; i < count; i++)
15289 printf("%3d\t0x%08x\n",
15290 mapping[i].hw_ptype, mapping[i].sw_ptype);
15295 cmdline_parse_inst_t cmd_ptype_mapping_get = {
15296 .f = cmd_ptype_mapping_get_parsed,
15298 .help_str = "ptype mapping get <port_id> <valid_only>",
15300 (void *)&cmd_ptype_mapping_get_ptype,
15301 (void *)&cmd_ptype_mapping_get_mapping,
15302 (void *)&cmd_ptype_mapping_get_get,
15303 (void *)&cmd_ptype_mapping_get_port_id,
15304 (void *)&cmd_ptype_mapping_get_valid_only,
15309 /* ptype mapping replace */
15311 /* Common result structure for ptype mapping replace */
15312 struct cmd_ptype_mapping_replace_result {
15313 cmdline_fixed_string_t ptype;
15314 cmdline_fixed_string_t mapping;
15315 cmdline_fixed_string_t replace;
15322 /* Common CLI fields for ptype mapping replace */
15323 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
15324 TOKEN_STRING_INITIALIZER
15325 (struct cmd_ptype_mapping_replace_result,
15327 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
15328 TOKEN_STRING_INITIALIZER
15329 (struct cmd_ptype_mapping_replace_result,
15330 mapping, "mapping");
15331 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
15332 TOKEN_STRING_INITIALIZER
15333 (struct cmd_ptype_mapping_replace_result,
15334 replace, "replace");
15335 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
15336 TOKEN_NUM_INITIALIZER
15337 (struct cmd_ptype_mapping_replace_result,
15338 port_id, RTE_UINT16);
15339 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
15340 TOKEN_NUM_INITIALIZER
15341 (struct cmd_ptype_mapping_replace_result,
15342 target, RTE_UINT32);
15343 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
15344 TOKEN_NUM_INITIALIZER
15345 (struct cmd_ptype_mapping_replace_result,
15347 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
15348 TOKEN_NUM_INITIALIZER
15349 (struct cmd_ptype_mapping_replace_result,
15350 pkt_type, RTE_UINT32);
15353 cmd_ptype_mapping_replace_parsed(
15354 void *parsed_result,
15355 __rte_unused struct cmdline *cl,
15356 __rte_unused void *data)
15358 struct cmd_ptype_mapping_replace_result *res = parsed_result;
15359 int ret = -ENOTSUP;
15361 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15364 #ifdef RTE_NET_I40E
15365 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
15375 printf("invalid ptype 0x%8x or 0x%8x\n",
15376 res->target, res->pkt_type);
15379 printf("invalid port_id %d\n", res->port_id);
15382 printf("function not implemented\n");
15385 printf("programming error: (%s)\n", strerror(-ret));
15389 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
15390 .f = cmd_ptype_mapping_replace_parsed,
15393 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
15395 (void *)&cmd_ptype_mapping_replace_ptype,
15396 (void *)&cmd_ptype_mapping_replace_mapping,
15397 (void *)&cmd_ptype_mapping_replace_replace,
15398 (void *)&cmd_ptype_mapping_replace_port_id,
15399 (void *)&cmd_ptype_mapping_replace_target,
15400 (void *)&cmd_ptype_mapping_replace_mask,
15401 (void *)&cmd_ptype_mapping_replace_pkt_type,
15406 /* ptype mapping reset */
15408 /* Common result structure for ptype mapping reset */
15409 struct cmd_ptype_mapping_reset_result {
15410 cmdline_fixed_string_t ptype;
15411 cmdline_fixed_string_t mapping;
15412 cmdline_fixed_string_t reset;
15416 /* Common CLI fields for ptype mapping reset*/
15417 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
15418 TOKEN_STRING_INITIALIZER
15419 (struct cmd_ptype_mapping_reset_result,
15421 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
15422 TOKEN_STRING_INITIALIZER
15423 (struct cmd_ptype_mapping_reset_result,
15424 mapping, "mapping");
15425 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
15426 TOKEN_STRING_INITIALIZER
15427 (struct cmd_ptype_mapping_reset_result,
15429 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
15430 TOKEN_NUM_INITIALIZER
15431 (struct cmd_ptype_mapping_reset_result,
15432 port_id, RTE_UINT16);
15435 cmd_ptype_mapping_reset_parsed(
15436 void *parsed_result,
15437 __rte_unused struct cmdline *cl,
15438 __rte_unused void *data)
15440 struct cmd_ptype_mapping_reset_result *res = parsed_result;
15441 int ret = -ENOTSUP;
15443 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15446 #ifdef RTE_NET_I40E
15447 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
15454 printf("invalid port_id %d\n", res->port_id);
15457 printf("function not implemented\n");
15460 printf("programming error: (%s)\n", strerror(-ret));
15464 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
15465 .f = cmd_ptype_mapping_reset_parsed,
15467 .help_str = "ptype mapping reset <port_id>",
15469 (void *)&cmd_ptype_mapping_reset_ptype,
15470 (void *)&cmd_ptype_mapping_reset_mapping,
15471 (void *)&cmd_ptype_mapping_reset_reset,
15472 (void *)&cmd_ptype_mapping_reset_port_id,
15477 /* ptype mapping update */
15479 /* Common result structure for ptype mapping update */
15480 struct cmd_ptype_mapping_update_result {
15481 cmdline_fixed_string_t ptype;
15482 cmdline_fixed_string_t mapping;
15483 cmdline_fixed_string_t reset;
15489 /* Common CLI fields for ptype mapping update*/
15490 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
15491 TOKEN_STRING_INITIALIZER
15492 (struct cmd_ptype_mapping_update_result,
15494 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
15495 TOKEN_STRING_INITIALIZER
15496 (struct cmd_ptype_mapping_update_result,
15497 mapping, "mapping");
15498 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
15499 TOKEN_STRING_INITIALIZER
15500 (struct cmd_ptype_mapping_update_result,
15502 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
15503 TOKEN_NUM_INITIALIZER
15504 (struct cmd_ptype_mapping_update_result,
15505 port_id, RTE_UINT16);
15506 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
15507 TOKEN_NUM_INITIALIZER
15508 (struct cmd_ptype_mapping_update_result,
15509 hw_ptype, RTE_UINT8);
15510 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
15511 TOKEN_NUM_INITIALIZER
15512 (struct cmd_ptype_mapping_update_result,
15513 sw_ptype, RTE_UINT32);
15516 cmd_ptype_mapping_update_parsed(
15517 void *parsed_result,
15518 __rte_unused struct cmdline *cl,
15519 __rte_unused void *data)
15521 struct cmd_ptype_mapping_update_result *res = parsed_result;
15522 int ret = -ENOTSUP;
15523 #ifdef RTE_NET_I40E
15524 struct rte_pmd_i40e_ptype_mapping mapping;
15526 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15529 #ifdef RTE_NET_I40E
15530 mapping.hw_ptype = res->hw_ptype;
15531 mapping.sw_ptype = res->sw_ptype;
15532 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
15542 printf("invalid ptype 0x%8x\n", res->sw_ptype);
15545 printf("invalid port_id %d\n", res->port_id);
15548 printf("function not implemented\n");
15551 printf("programming error: (%s)\n", strerror(-ret));
15555 cmdline_parse_inst_t cmd_ptype_mapping_update = {
15556 .f = cmd_ptype_mapping_update_parsed,
15558 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
15560 (void *)&cmd_ptype_mapping_update_ptype,
15561 (void *)&cmd_ptype_mapping_update_mapping,
15562 (void *)&cmd_ptype_mapping_update_update,
15563 (void *)&cmd_ptype_mapping_update_port_id,
15564 (void *)&cmd_ptype_mapping_update_hw_ptype,
15565 (void *)&cmd_ptype_mapping_update_sw_ptype,
15570 /* Common result structure for file commands */
15571 struct cmd_cmdfile_result {
15572 cmdline_fixed_string_t load;
15573 cmdline_fixed_string_t filename;
15576 /* Common CLI fields for file commands */
15577 cmdline_parse_token_string_t cmd_load_cmdfile =
15578 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
15579 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
15580 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
15583 cmd_load_from_file_parsed(
15584 void *parsed_result,
15585 __rte_unused struct cmdline *cl,
15586 __rte_unused void *data)
15588 struct cmd_cmdfile_result *res = parsed_result;
15590 cmdline_read_from_file(res->filename);
15593 cmdline_parse_inst_t cmd_load_from_file = {
15594 .f = cmd_load_from_file_parsed,
15596 .help_str = "load <filename>",
15598 (void *)&cmd_load_cmdfile,
15599 (void *)&cmd_load_cmdfile_filename,
15604 /* Get Rx offloads capabilities */
15605 struct cmd_rx_offload_get_capa_result {
15606 cmdline_fixed_string_t show;
15607 cmdline_fixed_string_t port;
15609 cmdline_fixed_string_t rx_offload;
15610 cmdline_fixed_string_t capabilities;
15613 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
15614 TOKEN_STRING_INITIALIZER
15615 (struct cmd_rx_offload_get_capa_result,
15617 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
15618 TOKEN_STRING_INITIALIZER
15619 (struct cmd_rx_offload_get_capa_result,
15621 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
15622 TOKEN_NUM_INITIALIZER
15623 (struct cmd_rx_offload_get_capa_result,
15624 port_id, RTE_UINT16);
15625 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
15626 TOKEN_STRING_INITIALIZER
15627 (struct cmd_rx_offload_get_capa_result,
15628 rx_offload, "rx_offload");
15629 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
15630 TOKEN_STRING_INITIALIZER
15631 (struct cmd_rx_offload_get_capa_result,
15632 capabilities, "capabilities");
15635 print_rx_offloads(uint64_t offloads)
15637 uint64_t single_offload;
15645 begin = __builtin_ctzll(offloads);
15646 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
15648 single_offload = 1ULL << begin;
15649 for (bit = begin; bit < end; bit++) {
15650 if (offloads & single_offload)
15652 rte_eth_dev_rx_offload_name(single_offload));
15653 single_offload <<= 1;
15658 cmd_rx_offload_get_capa_parsed(
15659 void *parsed_result,
15660 __rte_unused struct cmdline *cl,
15661 __rte_unused void *data)
15663 struct cmd_rx_offload_get_capa_result *res = parsed_result;
15664 struct rte_eth_dev_info dev_info;
15665 portid_t port_id = res->port_id;
15666 uint64_t queue_offloads;
15667 uint64_t port_offloads;
15670 ret = eth_dev_info_get_print_err(port_id, &dev_info);
15674 queue_offloads = dev_info.rx_queue_offload_capa;
15675 port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
15677 printf("Rx Offloading Capabilities of port %d :\n", port_id);
15678 printf(" Per Queue :");
15679 print_rx_offloads(queue_offloads);
15682 printf(" Per Port :");
15683 print_rx_offloads(port_offloads);
15687 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
15688 .f = cmd_rx_offload_get_capa_parsed,
15690 .help_str = "show port <port_id> rx_offload capabilities",
15692 (void *)&cmd_rx_offload_get_capa_show,
15693 (void *)&cmd_rx_offload_get_capa_port,
15694 (void *)&cmd_rx_offload_get_capa_port_id,
15695 (void *)&cmd_rx_offload_get_capa_rx_offload,
15696 (void *)&cmd_rx_offload_get_capa_capabilities,
15701 /* Get Rx offloads configuration */
15702 struct cmd_rx_offload_get_configuration_result {
15703 cmdline_fixed_string_t show;
15704 cmdline_fixed_string_t port;
15706 cmdline_fixed_string_t rx_offload;
15707 cmdline_fixed_string_t configuration;
15710 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
15711 TOKEN_STRING_INITIALIZER
15712 (struct cmd_rx_offload_get_configuration_result,
15714 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
15715 TOKEN_STRING_INITIALIZER
15716 (struct cmd_rx_offload_get_configuration_result,
15718 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
15719 TOKEN_NUM_INITIALIZER
15720 (struct cmd_rx_offload_get_configuration_result,
15721 port_id, RTE_UINT16);
15722 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
15723 TOKEN_STRING_INITIALIZER
15724 (struct cmd_rx_offload_get_configuration_result,
15725 rx_offload, "rx_offload");
15726 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
15727 TOKEN_STRING_INITIALIZER
15728 (struct cmd_rx_offload_get_configuration_result,
15729 configuration, "configuration");
15732 cmd_rx_offload_get_configuration_parsed(
15733 void *parsed_result,
15734 __rte_unused struct cmdline *cl,
15735 __rte_unused void *data)
15737 struct cmd_rx_offload_get_configuration_result *res = parsed_result;
15738 struct rte_eth_dev_info dev_info;
15739 portid_t port_id = res->port_id;
15740 struct rte_port *port = &ports[port_id];
15741 uint64_t port_offloads;
15742 uint64_t queue_offloads;
15743 uint16_t nb_rx_queues;
15747 printf("Rx Offloading Configuration of port %d :\n", port_id);
15749 port_offloads = port->dev_conf.rxmode.offloads;
15751 print_rx_offloads(port_offloads);
15754 ret = eth_dev_info_get_print_err(port_id, &dev_info);
15758 nb_rx_queues = dev_info.nb_rx_queues;
15759 for (q = 0; q < nb_rx_queues; q++) {
15760 queue_offloads = port->rx_conf[q].offloads;
15761 printf(" Queue[%2d] :", q);
15762 print_rx_offloads(queue_offloads);
15768 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
15769 .f = cmd_rx_offload_get_configuration_parsed,
15771 .help_str = "show port <port_id> rx_offload configuration",
15773 (void *)&cmd_rx_offload_get_configuration_show,
15774 (void *)&cmd_rx_offload_get_configuration_port,
15775 (void *)&cmd_rx_offload_get_configuration_port_id,
15776 (void *)&cmd_rx_offload_get_configuration_rx_offload,
15777 (void *)&cmd_rx_offload_get_configuration_configuration,
15782 /* Enable/Disable a per port offloading */
15783 struct cmd_config_per_port_rx_offload_result {
15784 cmdline_fixed_string_t port;
15785 cmdline_fixed_string_t config;
15787 cmdline_fixed_string_t rx_offload;
15788 cmdline_fixed_string_t offload;
15789 cmdline_fixed_string_t on_off;
15792 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
15793 TOKEN_STRING_INITIALIZER
15794 (struct cmd_config_per_port_rx_offload_result,
15796 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
15797 TOKEN_STRING_INITIALIZER
15798 (struct cmd_config_per_port_rx_offload_result,
15800 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
15801 TOKEN_NUM_INITIALIZER
15802 (struct cmd_config_per_port_rx_offload_result,
15803 port_id, RTE_UINT16);
15804 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
15805 TOKEN_STRING_INITIALIZER
15806 (struct cmd_config_per_port_rx_offload_result,
15807 rx_offload, "rx_offload");
15808 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
15809 TOKEN_STRING_INITIALIZER
15810 (struct cmd_config_per_port_rx_offload_result,
15811 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
15812 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
15813 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
15814 "scatter#buffer_split#timestamp#security#"
15815 "keep_crc#rss_hash");
15816 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
15817 TOKEN_STRING_INITIALIZER
15818 (struct cmd_config_per_port_rx_offload_result,
15822 search_rx_offload(const char *name)
15824 uint64_t single_offload;
15825 const char *single_name;
15829 single_offload = 1;
15830 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
15831 single_name = rte_eth_dev_rx_offload_name(single_offload);
15832 if (!strcasecmp(single_name, name)) {
15836 single_offload <<= 1;
15840 return single_offload;
15846 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
15847 __rte_unused struct cmdline *cl,
15848 __rte_unused void *data)
15850 struct cmd_config_per_port_rx_offload_result *res = parsed_result;
15851 portid_t port_id = res->port_id;
15852 struct rte_eth_dev_info dev_info;
15853 struct rte_port *port = &ports[port_id];
15854 uint64_t single_offload;
15855 uint16_t nb_rx_queues;
15859 if (port->port_status != RTE_PORT_STOPPED) {
15860 printf("Error: Can't config offload when Port %d "
15861 "is not stopped\n", port_id);
15865 single_offload = search_rx_offload(res->offload);
15866 if (single_offload == 0) {
15867 printf("Unknown offload name: %s\n", res->offload);
15871 ret = eth_dev_info_get_print_err(port_id, &dev_info);
15875 nb_rx_queues = dev_info.nb_rx_queues;
15876 if (!strcmp(res->on_off, "on")) {
15877 port->dev_conf.rxmode.offloads |= single_offload;
15878 for (q = 0; q < nb_rx_queues; q++)
15879 port->rx_conf[q].offloads |= single_offload;
15881 port->dev_conf.rxmode.offloads &= ~single_offload;
15882 for (q = 0; q < nb_rx_queues; q++)
15883 port->rx_conf[q].offloads &= ~single_offload;
15886 cmd_reconfig_device_queue(port_id, 1, 1);
15889 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
15890 .f = cmd_config_per_port_rx_offload_parsed,
15892 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
15893 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
15894 "macsec_strip|header_split|vlan_filter|vlan_extend|"
15895 "jumbo_frame|scatter|buffer_split|timestamp|security|"
15896 "keep_crc|rss_hash on|off",
15898 (void *)&cmd_config_per_port_rx_offload_result_port,
15899 (void *)&cmd_config_per_port_rx_offload_result_config,
15900 (void *)&cmd_config_per_port_rx_offload_result_port_id,
15901 (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
15902 (void *)&cmd_config_per_port_rx_offload_result_offload,
15903 (void *)&cmd_config_per_port_rx_offload_result_on_off,
15908 /* Enable/Disable a per queue offloading */
15909 struct cmd_config_per_queue_rx_offload_result {
15910 cmdline_fixed_string_t port;
15912 cmdline_fixed_string_t rxq;
15914 cmdline_fixed_string_t rx_offload;
15915 cmdline_fixed_string_t offload;
15916 cmdline_fixed_string_t on_off;
15919 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
15920 TOKEN_STRING_INITIALIZER
15921 (struct cmd_config_per_queue_rx_offload_result,
15923 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
15924 TOKEN_NUM_INITIALIZER
15925 (struct cmd_config_per_queue_rx_offload_result,
15926 port_id, RTE_UINT16);
15927 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
15928 TOKEN_STRING_INITIALIZER
15929 (struct cmd_config_per_queue_rx_offload_result,
15931 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
15932 TOKEN_NUM_INITIALIZER
15933 (struct cmd_config_per_queue_rx_offload_result,
15934 queue_id, RTE_UINT16);
15935 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
15936 TOKEN_STRING_INITIALIZER
15937 (struct cmd_config_per_queue_rx_offload_result,
15938 rx_offload, "rx_offload");
15939 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
15940 TOKEN_STRING_INITIALIZER
15941 (struct cmd_config_per_queue_rx_offload_result,
15942 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
15943 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
15944 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
15945 "scatter#buffer_split#timestamp#security#keep_crc");
15946 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
15947 TOKEN_STRING_INITIALIZER
15948 (struct cmd_config_per_queue_rx_offload_result,
15952 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
15953 __rte_unused struct cmdline *cl,
15954 __rte_unused void *data)
15956 struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
15957 struct rte_eth_dev_info dev_info;
15958 portid_t port_id = res->port_id;
15959 uint16_t queue_id = res->queue_id;
15960 struct rte_port *port = &ports[port_id];
15961 uint64_t single_offload;
15964 if (port->port_status != RTE_PORT_STOPPED) {
15965 printf("Error: Can't config offload when Port %d "
15966 "is not stopped\n", port_id);
15970 ret = eth_dev_info_get_print_err(port_id, &dev_info);
15974 if (queue_id >= dev_info.nb_rx_queues) {
15975 printf("Error: input queue_id should be 0 ... "
15976 "%d\n", dev_info.nb_rx_queues - 1);
15980 single_offload = search_rx_offload(res->offload);
15981 if (single_offload == 0) {
15982 printf("Unknown offload name: %s\n", res->offload);
15986 if (!strcmp(res->on_off, "on"))
15987 port->rx_conf[queue_id].offloads |= single_offload;
15989 port->rx_conf[queue_id].offloads &= ~single_offload;
15991 cmd_reconfig_device_queue(port_id, 1, 1);
15994 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
15995 .f = cmd_config_per_queue_rx_offload_parsed,
15997 .help_str = "port <port_id> rxq <queue_id> rx_offload "
15998 "vlan_strip|ipv4_cksum|"
15999 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
16000 "macsec_strip|header_split|vlan_filter|vlan_extend|"
16001 "jumbo_frame|scatter|buffer_split|timestamp|security|"
16004 (void *)&cmd_config_per_queue_rx_offload_result_port,
16005 (void *)&cmd_config_per_queue_rx_offload_result_port_id,
16006 (void *)&cmd_config_per_queue_rx_offload_result_rxq,
16007 (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
16008 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
16009 (void *)&cmd_config_per_queue_rx_offload_result_offload,
16010 (void *)&cmd_config_per_queue_rx_offload_result_on_off,
16015 /* Get Tx offloads capabilities */
16016 struct cmd_tx_offload_get_capa_result {
16017 cmdline_fixed_string_t show;
16018 cmdline_fixed_string_t port;
16020 cmdline_fixed_string_t tx_offload;
16021 cmdline_fixed_string_t capabilities;
16024 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
16025 TOKEN_STRING_INITIALIZER
16026 (struct cmd_tx_offload_get_capa_result,
16028 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
16029 TOKEN_STRING_INITIALIZER
16030 (struct cmd_tx_offload_get_capa_result,
16032 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
16033 TOKEN_NUM_INITIALIZER
16034 (struct cmd_tx_offload_get_capa_result,
16035 port_id, RTE_UINT16);
16036 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
16037 TOKEN_STRING_INITIALIZER
16038 (struct cmd_tx_offload_get_capa_result,
16039 tx_offload, "tx_offload");
16040 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
16041 TOKEN_STRING_INITIALIZER
16042 (struct cmd_tx_offload_get_capa_result,
16043 capabilities, "capabilities");
16046 print_tx_offloads(uint64_t offloads)
16048 uint64_t single_offload;
16056 begin = __builtin_ctzll(offloads);
16057 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
16059 single_offload = 1ULL << begin;
16060 for (bit = begin; bit < end; bit++) {
16061 if (offloads & single_offload)
16063 rte_eth_dev_tx_offload_name(single_offload));
16064 single_offload <<= 1;
16069 cmd_tx_offload_get_capa_parsed(
16070 void *parsed_result,
16071 __rte_unused struct cmdline *cl,
16072 __rte_unused void *data)
16074 struct cmd_tx_offload_get_capa_result *res = parsed_result;
16075 struct rte_eth_dev_info dev_info;
16076 portid_t port_id = res->port_id;
16077 uint64_t queue_offloads;
16078 uint64_t port_offloads;
16081 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16085 queue_offloads = dev_info.tx_queue_offload_capa;
16086 port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
16088 printf("Tx Offloading Capabilities of port %d :\n", port_id);
16089 printf(" Per Queue :");
16090 print_tx_offloads(queue_offloads);
16093 printf(" Per Port :");
16094 print_tx_offloads(port_offloads);
16098 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
16099 .f = cmd_tx_offload_get_capa_parsed,
16101 .help_str = "show port <port_id> tx_offload capabilities",
16103 (void *)&cmd_tx_offload_get_capa_show,
16104 (void *)&cmd_tx_offload_get_capa_port,
16105 (void *)&cmd_tx_offload_get_capa_port_id,
16106 (void *)&cmd_tx_offload_get_capa_tx_offload,
16107 (void *)&cmd_tx_offload_get_capa_capabilities,
16112 /* Get Tx offloads configuration */
16113 struct cmd_tx_offload_get_configuration_result {
16114 cmdline_fixed_string_t show;
16115 cmdline_fixed_string_t port;
16117 cmdline_fixed_string_t tx_offload;
16118 cmdline_fixed_string_t configuration;
16121 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
16122 TOKEN_STRING_INITIALIZER
16123 (struct cmd_tx_offload_get_configuration_result,
16125 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
16126 TOKEN_STRING_INITIALIZER
16127 (struct cmd_tx_offload_get_configuration_result,
16129 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
16130 TOKEN_NUM_INITIALIZER
16131 (struct cmd_tx_offload_get_configuration_result,
16132 port_id, RTE_UINT16);
16133 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
16134 TOKEN_STRING_INITIALIZER
16135 (struct cmd_tx_offload_get_configuration_result,
16136 tx_offload, "tx_offload");
16137 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
16138 TOKEN_STRING_INITIALIZER
16139 (struct cmd_tx_offload_get_configuration_result,
16140 configuration, "configuration");
16143 cmd_tx_offload_get_configuration_parsed(
16144 void *parsed_result,
16145 __rte_unused struct cmdline *cl,
16146 __rte_unused void *data)
16148 struct cmd_tx_offload_get_configuration_result *res = parsed_result;
16149 struct rte_eth_dev_info dev_info;
16150 portid_t port_id = res->port_id;
16151 struct rte_port *port = &ports[port_id];
16152 uint64_t port_offloads;
16153 uint64_t queue_offloads;
16154 uint16_t nb_tx_queues;
16158 printf("Tx Offloading Configuration of port %d :\n", port_id);
16160 port_offloads = port->dev_conf.txmode.offloads;
16162 print_tx_offloads(port_offloads);
16165 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16169 nb_tx_queues = dev_info.nb_tx_queues;
16170 for (q = 0; q < nb_tx_queues; q++) {
16171 queue_offloads = port->tx_conf[q].offloads;
16172 printf(" Queue[%2d] :", q);
16173 print_tx_offloads(queue_offloads);
16179 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
16180 .f = cmd_tx_offload_get_configuration_parsed,
16182 .help_str = "show port <port_id> tx_offload configuration",
16184 (void *)&cmd_tx_offload_get_configuration_show,
16185 (void *)&cmd_tx_offload_get_configuration_port,
16186 (void *)&cmd_tx_offload_get_configuration_port_id,
16187 (void *)&cmd_tx_offload_get_configuration_tx_offload,
16188 (void *)&cmd_tx_offload_get_configuration_configuration,
16193 /* Enable/Disable a per port offloading */
16194 struct cmd_config_per_port_tx_offload_result {
16195 cmdline_fixed_string_t port;
16196 cmdline_fixed_string_t config;
16198 cmdline_fixed_string_t tx_offload;
16199 cmdline_fixed_string_t offload;
16200 cmdline_fixed_string_t on_off;
16203 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
16204 TOKEN_STRING_INITIALIZER
16205 (struct cmd_config_per_port_tx_offload_result,
16207 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
16208 TOKEN_STRING_INITIALIZER
16209 (struct cmd_config_per_port_tx_offload_result,
16211 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
16212 TOKEN_NUM_INITIALIZER
16213 (struct cmd_config_per_port_tx_offload_result,
16214 port_id, RTE_UINT16);
16215 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
16216 TOKEN_STRING_INITIALIZER
16217 (struct cmd_config_per_port_tx_offload_result,
16218 tx_offload, "tx_offload");
16219 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
16220 TOKEN_STRING_INITIALIZER
16221 (struct cmd_config_per_port_tx_offload_result,
16222 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
16223 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
16224 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
16225 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
16226 "mt_lockfree#multi_segs#mbuf_fast_free#security#"
16227 "send_on_timestamp");
16228 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
16229 TOKEN_STRING_INITIALIZER
16230 (struct cmd_config_per_port_tx_offload_result,
16234 search_tx_offload(const char *name)
16236 uint64_t single_offload;
16237 const char *single_name;
16241 single_offload = 1;
16242 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
16243 single_name = rte_eth_dev_tx_offload_name(single_offload);
16244 if (single_name == NULL)
16246 if (!strcasecmp(single_name, name)) {
16249 } else if (!strcasecmp(single_name, "UNKNOWN"))
16251 single_offload <<= 1;
16255 return single_offload;
16261 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
16262 __rte_unused struct cmdline *cl,
16263 __rte_unused void *data)
16265 struct cmd_config_per_port_tx_offload_result *res = parsed_result;
16266 portid_t port_id = res->port_id;
16267 struct rte_eth_dev_info dev_info;
16268 struct rte_port *port = &ports[port_id];
16269 uint64_t single_offload;
16270 uint16_t nb_tx_queues;
16274 if (port->port_status != RTE_PORT_STOPPED) {
16275 printf("Error: Can't config offload when Port %d "
16276 "is not stopped\n", port_id);
16280 single_offload = search_tx_offload(res->offload);
16281 if (single_offload == 0) {
16282 printf("Unknown offload name: %s\n", res->offload);
16286 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16290 nb_tx_queues = dev_info.nb_tx_queues;
16291 if (!strcmp(res->on_off, "on")) {
16292 port->dev_conf.txmode.offloads |= single_offload;
16293 for (q = 0; q < nb_tx_queues; q++)
16294 port->tx_conf[q].offloads |= single_offload;
16296 port->dev_conf.txmode.offloads &= ~single_offload;
16297 for (q = 0; q < nb_tx_queues; q++)
16298 port->tx_conf[q].offloads &= ~single_offload;
16301 cmd_reconfig_device_queue(port_id, 1, 1);
16304 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
16305 .f = cmd_config_per_port_tx_offload_parsed,
16307 .help_str = "port config <port_id> tx_offload "
16308 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
16309 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
16310 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
16311 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
16312 "mt_lockfree|multi_segs|mbuf_fast_free|security|"
16313 "send_on_timestamp on|off",
16315 (void *)&cmd_config_per_port_tx_offload_result_port,
16316 (void *)&cmd_config_per_port_tx_offload_result_config,
16317 (void *)&cmd_config_per_port_tx_offload_result_port_id,
16318 (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
16319 (void *)&cmd_config_per_port_tx_offload_result_offload,
16320 (void *)&cmd_config_per_port_tx_offload_result_on_off,
16325 /* Enable/Disable a per queue offloading */
16326 struct cmd_config_per_queue_tx_offload_result {
16327 cmdline_fixed_string_t port;
16329 cmdline_fixed_string_t txq;
16331 cmdline_fixed_string_t tx_offload;
16332 cmdline_fixed_string_t offload;
16333 cmdline_fixed_string_t on_off;
16336 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
16337 TOKEN_STRING_INITIALIZER
16338 (struct cmd_config_per_queue_tx_offload_result,
16340 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
16341 TOKEN_NUM_INITIALIZER
16342 (struct cmd_config_per_queue_tx_offload_result,
16343 port_id, RTE_UINT16);
16344 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
16345 TOKEN_STRING_INITIALIZER
16346 (struct cmd_config_per_queue_tx_offload_result,
16348 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
16349 TOKEN_NUM_INITIALIZER
16350 (struct cmd_config_per_queue_tx_offload_result,
16351 queue_id, RTE_UINT16);
16352 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
16353 TOKEN_STRING_INITIALIZER
16354 (struct cmd_config_per_queue_tx_offload_result,
16355 tx_offload, "tx_offload");
16356 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
16357 TOKEN_STRING_INITIALIZER
16358 (struct cmd_config_per_queue_tx_offload_result,
16359 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
16360 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
16361 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
16362 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
16363 "mt_lockfree#multi_segs#mbuf_fast_free#security");
16364 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
16365 TOKEN_STRING_INITIALIZER
16366 (struct cmd_config_per_queue_tx_offload_result,
16370 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
16371 __rte_unused struct cmdline *cl,
16372 __rte_unused void *data)
16374 struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
16375 struct rte_eth_dev_info dev_info;
16376 portid_t port_id = res->port_id;
16377 uint16_t queue_id = res->queue_id;
16378 struct rte_port *port = &ports[port_id];
16379 uint64_t single_offload;
16382 if (port->port_status != RTE_PORT_STOPPED) {
16383 printf("Error: Can't config offload when Port %d "
16384 "is not stopped\n", port_id);
16388 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16392 if (queue_id >= dev_info.nb_tx_queues) {
16393 printf("Error: input queue_id should be 0 ... "
16394 "%d\n", dev_info.nb_tx_queues - 1);
16398 single_offload = search_tx_offload(res->offload);
16399 if (single_offload == 0) {
16400 printf("Unknown offload name: %s\n", res->offload);
16404 if (!strcmp(res->on_off, "on"))
16405 port->tx_conf[queue_id].offloads |= single_offload;
16407 port->tx_conf[queue_id].offloads &= ~single_offload;
16409 cmd_reconfig_device_queue(port_id, 1, 1);
16412 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
16413 .f = cmd_config_per_queue_tx_offload_parsed,
16415 .help_str = "port <port_id> txq <queue_id> tx_offload "
16416 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
16417 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
16418 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
16419 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
16420 "mt_lockfree|multi_segs|mbuf_fast_free|security "
16423 (void *)&cmd_config_per_queue_tx_offload_result_port,
16424 (void *)&cmd_config_per_queue_tx_offload_result_port_id,
16425 (void *)&cmd_config_per_queue_tx_offload_result_txq,
16426 (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
16427 (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
16428 (void *)&cmd_config_per_queue_tx_offload_result_offload,
16429 (void *)&cmd_config_per_queue_tx_offload_result_on_off,
16434 /* *** configure tx_metadata for specific port *** */
16435 struct cmd_config_tx_metadata_specific_result {
16436 cmdline_fixed_string_t port;
16437 cmdline_fixed_string_t keyword;
16439 cmdline_fixed_string_t item;
16444 cmd_config_tx_metadata_specific_parsed(void *parsed_result,
16445 __rte_unused struct cmdline *cl,
16446 __rte_unused void *data)
16448 struct cmd_config_tx_metadata_specific_result *res = parsed_result;
16450 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16452 ports[res->port_id].tx_metadata = res->value;
16453 /* Add/remove callback to insert valid metadata in every Tx packet. */
16454 if (ports[res->port_id].tx_metadata)
16455 add_tx_md_callback(res->port_id);
16457 remove_tx_md_callback(res->port_id);
16458 rte_flow_dynf_metadata_register();
16461 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
16462 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16464 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
16465 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16466 keyword, "config");
16467 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
16468 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16469 port_id, RTE_UINT16);
16470 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
16471 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16472 item, "tx_metadata");
16473 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
16474 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16475 value, RTE_UINT32);
16477 cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
16478 .f = cmd_config_tx_metadata_specific_parsed,
16480 .help_str = "port config <port_id> tx_metadata <value>",
16482 (void *)&cmd_config_tx_metadata_specific_port,
16483 (void *)&cmd_config_tx_metadata_specific_keyword,
16484 (void *)&cmd_config_tx_metadata_specific_id,
16485 (void *)&cmd_config_tx_metadata_specific_item,
16486 (void *)&cmd_config_tx_metadata_specific_value,
16491 /* *** set dynf *** */
16492 struct cmd_config_tx_dynf_specific_result {
16493 cmdline_fixed_string_t port;
16494 cmdline_fixed_string_t keyword;
16496 cmdline_fixed_string_t item;
16497 cmdline_fixed_string_t name;
16498 cmdline_fixed_string_t value;
16502 cmd_config_dynf_specific_parsed(void *parsed_result,
16503 __rte_unused struct cmdline *cl,
16504 __rte_unused void *data)
16506 struct cmd_config_tx_dynf_specific_result *res = parsed_result;
16507 struct rte_mbuf_dynflag desc_flag;
16509 uint64_t old_port_flags;
16511 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16513 flag = rte_mbuf_dynflag_lookup(res->name, NULL);
16515 if (strlcpy(desc_flag.name, res->name,
16516 RTE_MBUF_DYN_NAMESIZE) >= RTE_MBUF_DYN_NAMESIZE) {
16517 printf("Flag name too long\n");
16520 desc_flag.flags = 0;
16521 flag = rte_mbuf_dynflag_register(&desc_flag);
16523 printf("Can't register flag\n");
16526 strcpy(dynf_names[flag], desc_flag.name);
16528 old_port_flags = ports[res->port_id].mbuf_dynf;
16529 if (!strcmp(res->value, "set")) {
16530 ports[res->port_id].mbuf_dynf |= 1UL << flag;
16531 if (old_port_flags == 0)
16532 add_tx_dynf_callback(res->port_id);
16534 ports[res->port_id].mbuf_dynf &= ~(1UL << flag);
16535 if (ports[res->port_id].mbuf_dynf == 0)
16536 remove_tx_dynf_callback(res->port_id);
16540 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_port =
16541 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16543 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_keyword =
16544 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16545 keyword, "config");
16546 cmdline_parse_token_num_t cmd_config_tx_dynf_specific_port_id =
16547 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16548 port_id, RTE_UINT16);
16549 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_item =
16550 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16552 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_name =
16553 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16555 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_value =
16556 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16557 value, "set#clear");
16559 cmdline_parse_inst_t cmd_config_tx_dynf_specific = {
16560 .f = cmd_config_dynf_specific_parsed,
16562 .help_str = "port config <port id> dynf <name> set|clear",
16564 (void *)&cmd_config_tx_dynf_specific_port,
16565 (void *)&cmd_config_tx_dynf_specific_keyword,
16566 (void *)&cmd_config_tx_dynf_specific_port_id,
16567 (void *)&cmd_config_tx_dynf_specific_item,
16568 (void *)&cmd_config_tx_dynf_specific_name,
16569 (void *)&cmd_config_tx_dynf_specific_value,
16574 /* *** display tx_metadata per port configuration *** */
16575 struct cmd_show_tx_metadata_result {
16576 cmdline_fixed_string_t cmd_show;
16577 cmdline_fixed_string_t cmd_port;
16578 cmdline_fixed_string_t cmd_keyword;
16583 cmd_show_tx_metadata_parsed(void *parsed_result,
16584 __rte_unused struct cmdline *cl,
16585 __rte_unused void *data)
16587 struct cmd_show_tx_metadata_result *res = parsed_result;
16589 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16590 printf("invalid port id %u\n", res->cmd_pid);
16593 if (!strcmp(res->cmd_keyword, "tx_metadata")) {
16594 printf("Port %u tx_metadata: %u\n", res->cmd_pid,
16595 ports[res->cmd_pid].tx_metadata);
16599 cmdline_parse_token_string_t cmd_show_tx_metadata_show =
16600 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
16602 cmdline_parse_token_string_t cmd_show_tx_metadata_port =
16603 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
16605 cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
16606 TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
16607 cmd_pid, RTE_UINT16);
16608 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
16609 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
16610 cmd_keyword, "tx_metadata");
16612 cmdline_parse_inst_t cmd_show_tx_metadata = {
16613 .f = cmd_show_tx_metadata_parsed,
16615 .help_str = "show port <port_id> tx_metadata",
16617 (void *)&cmd_show_tx_metadata_show,
16618 (void *)&cmd_show_tx_metadata_port,
16619 (void *)&cmd_show_tx_metadata_pid,
16620 (void *)&cmd_show_tx_metadata_keyword,
16625 /* *** show fec capability per port configuration *** */
16626 struct cmd_show_fec_capability_result {
16627 cmdline_fixed_string_t cmd_show;
16628 cmdline_fixed_string_t cmd_port;
16629 cmdline_fixed_string_t cmd_fec;
16630 cmdline_fixed_string_t cmd_keyword;
16635 cmd_show_fec_capability_parsed(void *parsed_result,
16636 __rte_unused struct cmdline *cl,
16637 __rte_unused void *data)
16639 struct cmd_show_fec_capability_result *res = parsed_result;
16640 struct rte_eth_fec_capa *speed_fec_capa;
16644 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16645 printf("Invalid port id %u\n", res->cmd_pid);
16649 ret = rte_eth_fec_get_capability(res->cmd_pid, NULL, 0);
16650 if (ret == -ENOTSUP) {
16651 printf("Function not implemented\n");
16653 } else if (ret < 0) {
16654 printf("Get FEC capability failed: %d\n", ret);
16658 num = (unsigned int)ret;
16659 speed_fec_capa = calloc(num, sizeof(*speed_fec_capa));
16660 if (speed_fec_capa == NULL) {
16661 printf("Failed to alloc FEC capability buffer\n");
16665 ret = rte_eth_fec_get_capability(res->cmd_pid, speed_fec_capa, num);
16667 printf("Error getting FEC capability: %d\n", ret);
16671 show_fec_capability(num, speed_fec_capa);
16673 free(speed_fec_capa);
16676 cmdline_parse_token_string_t cmd_show_fec_capability_show =
16677 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16679 cmdline_parse_token_string_t cmd_show_fec_capability_port =
16680 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16682 cmdline_parse_token_num_t cmd_show_fec_capability_pid =
16683 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_capability_result,
16684 cmd_pid, RTE_UINT16);
16685 cmdline_parse_token_string_t cmd_show_fec_capability_fec =
16686 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16688 cmdline_parse_token_string_t cmd_show_fec_capability_keyword =
16689 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16690 cmd_keyword, "capabilities");
16692 cmdline_parse_inst_t cmd_show_capability = {
16693 .f = cmd_show_fec_capability_parsed,
16695 .help_str = "show port <port_id> fec capabilities",
16697 (void *)&cmd_show_fec_capability_show,
16698 (void *)&cmd_show_fec_capability_port,
16699 (void *)&cmd_show_fec_capability_pid,
16700 (void *)&cmd_show_fec_capability_fec,
16701 (void *)&cmd_show_fec_capability_keyword,
16706 /* *** show fec mode per port configuration *** */
16707 struct cmd_show_fec_metadata_result {
16708 cmdline_fixed_string_t cmd_show;
16709 cmdline_fixed_string_t cmd_port;
16710 cmdline_fixed_string_t cmd_keyword;
16715 cmd_show_fec_mode_parsed(void *parsed_result,
16716 __rte_unused struct cmdline *cl,
16717 __rte_unused void *data)
16719 #define FEC_NAME_SIZE 16
16720 struct cmd_show_fec_metadata_result *res = parsed_result;
16722 char buf[FEC_NAME_SIZE];
16725 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16726 printf("Invalid port id %u\n", res->cmd_pid);
16729 ret = rte_eth_fec_get(res->cmd_pid, &mode);
16730 if (ret == -ENOTSUP) {
16731 printf("Function not implemented\n");
16733 } else if (ret < 0) {
16734 printf("Get FEC mode failed\n");
16739 case RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC):
16740 strlcpy(buf, "off", sizeof(buf));
16742 case RTE_ETH_FEC_MODE_CAPA_MASK(AUTO):
16743 strlcpy(buf, "auto", sizeof(buf));
16745 case RTE_ETH_FEC_MODE_CAPA_MASK(BASER):
16746 strlcpy(buf, "baser", sizeof(buf));
16748 case RTE_ETH_FEC_MODE_CAPA_MASK(RS):
16749 strlcpy(buf, "rs", sizeof(buf));
16755 printf("%s\n", buf);
16758 cmdline_parse_token_string_t cmd_show_fec_mode_show =
16759 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
16761 cmdline_parse_token_string_t cmd_show_fec_mode_port =
16762 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
16764 cmdline_parse_token_num_t cmd_show_fec_mode_pid =
16765 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_metadata_result,
16766 cmd_pid, RTE_UINT16);
16767 cmdline_parse_token_string_t cmd_show_fec_mode_keyword =
16768 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
16769 cmd_keyword, "fec_mode");
16771 cmdline_parse_inst_t cmd_show_fec_mode = {
16772 .f = cmd_show_fec_mode_parsed,
16774 .help_str = "show port <port_id> fec_mode",
16776 (void *)&cmd_show_fec_mode_show,
16777 (void *)&cmd_show_fec_mode_port,
16778 (void *)&cmd_show_fec_mode_pid,
16779 (void *)&cmd_show_fec_mode_keyword,
16784 /* *** set fec mode per port configuration *** */
16785 struct cmd_set_port_fec_mode {
16786 cmdline_fixed_string_t set;
16787 cmdline_fixed_string_t port;
16789 cmdline_fixed_string_t fec_mode;
16790 cmdline_fixed_string_t fec_value;
16793 /* Common CLI fields for set fec mode */
16794 cmdline_parse_token_string_t cmd_set_port_fec_mode_set =
16795 TOKEN_STRING_INITIALIZER
16796 (struct cmd_set_port_fec_mode,
16798 cmdline_parse_token_string_t cmd_set_port_fec_mode_port =
16799 TOKEN_STRING_INITIALIZER
16800 (struct cmd_set_port_fec_mode,
16802 cmdline_parse_token_num_t cmd_set_port_fec_mode_port_id =
16803 TOKEN_NUM_INITIALIZER
16804 (struct cmd_set_port_fec_mode,
16805 port_id, RTE_UINT16);
16806 cmdline_parse_token_string_t cmd_set_port_fec_mode_str =
16807 TOKEN_STRING_INITIALIZER
16808 (struct cmd_set_port_fec_mode,
16809 fec_mode, "fec_mode");
16810 cmdline_parse_token_string_t cmd_set_port_fec_mode_value =
16811 TOKEN_STRING_INITIALIZER
16812 (struct cmd_set_port_fec_mode,
16816 cmd_set_port_fec_mode_parsed(
16817 void *parsed_result,
16818 __rte_unused struct cmdline *cl,
16819 __rte_unused void *data)
16821 struct cmd_set_port_fec_mode *res = parsed_result;
16822 uint16_t port_id = res->port_id;
16826 ret = parse_fec_mode(res->fec_value, &mode);
16828 printf("Unknown fec mode: %s for Port %d\n", res->fec_value,
16833 ret = rte_eth_fec_set(port_id, mode);
16834 if (ret == -ENOTSUP) {
16835 printf("Function not implemented\n");
16837 } else if (ret < 0) {
16838 printf("Set FEC mode failed\n");
16843 cmdline_parse_inst_t cmd_set_fec_mode = {
16844 .f = cmd_set_port_fec_mode_parsed,
16846 .help_str = "set port <port_id> fec_mode auto|off|rs|baser",
16848 (void *)&cmd_set_port_fec_mode_set,
16849 (void *)&cmd_set_port_fec_mode_port,
16850 (void *)&cmd_set_port_fec_mode_port_id,
16851 (void *)&cmd_set_port_fec_mode_str,
16852 (void *)&cmd_set_port_fec_mode_value,
16857 /* show port supported ptypes */
16859 /* Common result structure for show port ptypes */
16860 struct cmd_show_port_supported_ptypes_result {
16861 cmdline_fixed_string_t show;
16862 cmdline_fixed_string_t port;
16864 cmdline_fixed_string_t ptypes;
16867 /* Common CLI fields for show port ptypes */
16868 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =
16869 TOKEN_STRING_INITIALIZER
16870 (struct cmd_show_port_supported_ptypes_result,
16872 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
16873 TOKEN_STRING_INITIALIZER
16874 (struct cmd_show_port_supported_ptypes_result,
16876 cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =
16877 TOKEN_NUM_INITIALIZER
16878 (struct cmd_show_port_supported_ptypes_result,
16879 port_id, RTE_UINT16);
16880 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =
16881 TOKEN_STRING_INITIALIZER
16882 (struct cmd_show_port_supported_ptypes_result,
16886 cmd_show_port_supported_ptypes_parsed(
16887 void *parsed_result,
16888 __rte_unused struct cmdline *cl,
16889 __rte_unused void *data)
16891 #define RSVD_PTYPE_MASK 0xf0000000
16892 #define MAX_PTYPES_PER_LAYER 16
16893 #define LTYPE_NAMESIZE 32
16894 #define PTYPE_NAMESIZE 256
16895 struct cmd_show_port_supported_ptypes_result *res = parsed_result;
16896 char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE];
16897 uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
16898 uint32_t ptypes[MAX_PTYPES_PER_LAYER];
16899 uint16_t port_id = res->port_id;
16902 ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0);
16906 while (ptype_mask != RSVD_PTYPE_MASK) {
16908 switch (ptype_mask) {
16909 case RTE_PTYPE_L2_MASK:
16910 strlcpy(ltype, "L2", sizeof(ltype));
16912 case RTE_PTYPE_L3_MASK:
16913 strlcpy(ltype, "L3", sizeof(ltype));
16915 case RTE_PTYPE_L4_MASK:
16916 strlcpy(ltype, "L4", sizeof(ltype));
16918 case RTE_PTYPE_TUNNEL_MASK:
16919 strlcpy(ltype, "Tunnel", sizeof(ltype));
16921 case RTE_PTYPE_INNER_L2_MASK:
16922 strlcpy(ltype, "Inner L2", sizeof(ltype));
16924 case RTE_PTYPE_INNER_L3_MASK:
16925 strlcpy(ltype, "Inner L3", sizeof(ltype));
16927 case RTE_PTYPE_INNER_L4_MASK:
16928 strlcpy(ltype, "Inner L4", sizeof(ltype));
16934 ret = rte_eth_dev_get_supported_ptypes(res->port_id,
16935 ptype_mask, ptypes,
16936 MAX_PTYPES_PER_LAYER);
16939 printf("Supported %s ptypes:\n", ltype);
16941 printf("%s ptypes unsupported\n", ltype);
16943 for (i = 0; i < ret; ++i) {
16944 rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
16945 printf("%s\n", buf);
16952 cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
16953 .f = cmd_show_port_supported_ptypes_parsed,
16955 .help_str = "show port <port_id> ptypes",
16957 (void *)&cmd_show_port_supported_ptypes_show,
16958 (void *)&cmd_show_port_supported_ptypes_port,
16959 (void *)&cmd_show_port_supported_ptypes_port_id,
16960 (void *)&cmd_show_port_supported_ptypes_ptypes,
16965 /* *** display rx/tx descriptor status *** */
16966 struct cmd_show_rx_tx_desc_status_result {
16967 cmdline_fixed_string_t cmd_show;
16968 cmdline_fixed_string_t cmd_port;
16969 cmdline_fixed_string_t cmd_keyword;
16970 cmdline_fixed_string_t cmd_desc;
16971 cmdline_fixed_string_t cmd_status;
16978 cmd_show_rx_tx_desc_status_parsed(void *parsed_result,
16979 __rte_unused struct cmdline *cl,
16980 __rte_unused void *data)
16982 struct cmd_show_rx_tx_desc_status_result *res = parsed_result;
16985 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16986 printf("invalid port id %u\n", res->cmd_pid);
16990 if (!strcmp(res->cmd_keyword, "rxq")) {
16991 rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid,
16994 printf("Invalid input: queue id = %d, desc id = %d\n",
16995 res->cmd_qid, res->cmd_did);
16998 if (rc == RTE_ETH_RX_DESC_AVAIL)
16999 printf("Desc status = AVAILABLE\n");
17000 else if (rc == RTE_ETH_RX_DESC_DONE)
17001 printf("Desc status = DONE\n");
17003 printf("Desc status = UNAVAILABLE\n");
17004 } else if (!strcmp(res->cmd_keyword, "txq")) {
17005 rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid,
17008 printf("Invalid input: queue id = %d, desc id = %d\n",
17009 res->cmd_qid, res->cmd_did);
17012 if (rc == RTE_ETH_TX_DESC_FULL)
17013 printf("Desc status = FULL\n");
17014 else if (rc == RTE_ETH_TX_DESC_DONE)
17015 printf("Desc status = DONE\n");
17017 printf("Desc status = UNAVAILABLE\n");
17021 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show =
17022 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17024 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port =
17025 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17027 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid =
17028 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17029 cmd_pid, RTE_UINT16);
17030 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword =
17031 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17032 cmd_keyword, "rxq#txq");
17033 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid =
17034 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17035 cmd_qid, RTE_UINT16);
17036 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc =
17037 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17039 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did =
17040 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17041 cmd_did, RTE_UINT16);
17042 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status =
17043 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17044 cmd_status, "status");
17045 cmdline_parse_inst_t cmd_show_rx_tx_desc_status = {
17046 .f = cmd_show_rx_tx_desc_status_parsed,
17048 .help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> "
17051 (void *)&cmd_show_rx_tx_desc_status_show,
17052 (void *)&cmd_show_rx_tx_desc_status_port,
17053 (void *)&cmd_show_rx_tx_desc_status_pid,
17054 (void *)&cmd_show_rx_tx_desc_status_keyword,
17055 (void *)&cmd_show_rx_tx_desc_status_qid,
17056 (void *)&cmd_show_rx_tx_desc_status_desc,
17057 (void *)&cmd_show_rx_tx_desc_status_did,
17058 (void *)&cmd_show_rx_tx_desc_status_status,
17063 /* *** display rx queue desc used count *** */
17064 struct cmd_show_rx_queue_desc_used_count_result {
17065 cmdline_fixed_string_t cmd_show;
17066 cmdline_fixed_string_t cmd_port;
17067 cmdline_fixed_string_t cmd_rxq;
17068 cmdline_fixed_string_t cmd_desc;
17069 cmdline_fixed_string_t cmd_used;
17070 cmdline_fixed_string_t cmd_count;
17076 cmd_show_rx_queue_desc_used_count_parsed(void *parsed_result,
17077 __rte_unused struct cmdline *cl,
17078 __rte_unused void *data)
17080 struct cmd_show_rx_queue_desc_used_count_result *res = parsed_result;
17083 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17084 printf("invalid port id %u\n", res->cmd_pid);
17088 rc = rte_eth_rx_queue_count(res->cmd_pid, res->cmd_qid);
17090 printf("Invalid queueid = %d\n", res->cmd_qid);
17093 printf("Used desc count = %d\n", rc);
17096 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_show =
17097 TOKEN_STRING_INITIALIZER
17098 (struct cmd_show_rx_queue_desc_used_count_result,
17100 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_port =
17101 TOKEN_STRING_INITIALIZER
17102 (struct cmd_show_rx_queue_desc_used_count_result,
17104 cmdline_parse_token_num_t cmd_show_rx_queue_desc_used_count_pid =
17105 TOKEN_NUM_INITIALIZER
17106 (struct cmd_show_rx_queue_desc_used_count_result,
17107 cmd_pid, RTE_UINT16);
17108 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_rxq =
17109 TOKEN_STRING_INITIALIZER
17110 (struct cmd_show_rx_queue_desc_used_count_result,
17112 cmdline_parse_token_num_t cmd_show_rx_queue_desc_used_count_qid =
17113 TOKEN_NUM_INITIALIZER
17114 (struct cmd_show_rx_queue_desc_used_count_result,
17115 cmd_qid, RTE_UINT16);
17116 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_desc =
17117 TOKEN_STRING_INITIALIZER
17118 (struct cmd_show_rx_queue_desc_used_count_result,
17119 cmd_count, "desc");
17120 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_used =
17121 TOKEN_STRING_INITIALIZER
17122 (struct cmd_show_rx_queue_desc_used_count_result,
17123 cmd_count, "used");
17124 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_count =
17125 TOKEN_STRING_INITIALIZER
17126 (struct cmd_show_rx_queue_desc_used_count_result,
17127 cmd_count, "count");
17128 cmdline_parse_inst_t cmd_show_rx_queue_desc_used_count = {
17129 .f = cmd_show_rx_queue_desc_used_count_parsed,
17131 .help_str = "show port <port_id> rxq <queue_id> desc used count",
17133 (void *)&cmd_show_rx_queue_desc_used_count_show,
17134 (void *)&cmd_show_rx_queue_desc_used_count_port,
17135 (void *)&cmd_show_rx_queue_desc_used_count_pid,
17136 (void *)&cmd_show_rx_queue_desc_used_count_rxq,
17137 (void *)&cmd_show_rx_queue_desc_used_count_qid,
17138 (void *)&cmd_show_rx_queue_desc_used_count_desc,
17139 (void *)&cmd_show_rx_queue_desc_used_count_used,
17140 (void *)&cmd_show_rx_queue_desc_used_count_count,
17145 /* Common result structure for set port ptypes */
17146 struct cmd_set_port_ptypes_result {
17147 cmdline_fixed_string_t set;
17148 cmdline_fixed_string_t port;
17150 cmdline_fixed_string_t ptype_mask;
17154 /* Common CLI fields for set port ptypes */
17155 cmdline_parse_token_string_t cmd_set_port_ptypes_set =
17156 TOKEN_STRING_INITIALIZER
17157 (struct cmd_set_port_ptypes_result,
17159 cmdline_parse_token_string_t cmd_set_port_ptypes_port =
17160 TOKEN_STRING_INITIALIZER
17161 (struct cmd_set_port_ptypes_result,
17163 cmdline_parse_token_num_t cmd_set_port_ptypes_port_id =
17164 TOKEN_NUM_INITIALIZER
17165 (struct cmd_set_port_ptypes_result,
17166 port_id, RTE_UINT16);
17167 cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str =
17168 TOKEN_STRING_INITIALIZER
17169 (struct cmd_set_port_ptypes_result,
17170 ptype_mask, "ptype_mask");
17171 cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 =
17172 TOKEN_NUM_INITIALIZER
17173 (struct cmd_set_port_ptypes_result,
17177 cmd_set_port_ptypes_parsed(
17178 void *parsed_result,
17179 __rte_unused struct cmdline *cl,
17180 __rte_unused void *data)
17182 struct cmd_set_port_ptypes_result *res = parsed_result;
17183 #define PTYPE_NAMESIZE 256
17184 char ptype_name[PTYPE_NAMESIZE];
17185 uint16_t port_id = res->port_id;
17186 uint32_t ptype_mask = res->mask;
17189 ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK,
17192 printf("Port %d doesn't support any ptypes.\n", port_id);
17196 uint32_t ptypes[ret];
17198 ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret);
17200 printf("Unable to set requested ptypes for Port %d\n", port_id);
17204 printf("Successfully set following ptypes for Port %d\n", port_id);
17205 for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) {
17206 rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name));
17207 printf("%s\n", ptype_name);
17210 clear_ptypes = false;
17213 cmdline_parse_inst_t cmd_set_port_ptypes = {
17214 .f = cmd_set_port_ptypes_parsed,
17216 .help_str = "set port <port_id> ptype_mask <mask>",
17218 (void *)&cmd_set_port_ptypes_set,
17219 (void *)&cmd_set_port_ptypes_port,
17220 (void *)&cmd_set_port_ptypes_port_id,
17221 (void *)&cmd_set_port_ptypes_mask_str,
17222 (void *)&cmd_set_port_ptypes_mask_u32,
17227 /* *** display mac addresses added to a port *** */
17228 struct cmd_showport_macs_result {
17229 cmdline_fixed_string_t cmd_show;
17230 cmdline_fixed_string_t cmd_port;
17231 cmdline_fixed_string_t cmd_keyword;
17236 cmd_showport_macs_parsed(void *parsed_result,
17237 __rte_unused struct cmdline *cl,
17238 __rte_unused void *data)
17240 struct cmd_showport_macs_result *res = parsed_result;
17242 if (port_id_is_invalid(res->cmd_pid, ENABLED_WARN))
17245 if (!strcmp(res->cmd_keyword, "macs"))
17246 show_macs(res->cmd_pid);
17247 else if (!strcmp(res->cmd_keyword, "mcast_macs"))
17248 show_mcast_macs(res->cmd_pid);
17251 cmdline_parse_token_string_t cmd_showport_macs_show =
17252 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17254 cmdline_parse_token_string_t cmd_showport_macs_port =
17255 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17257 cmdline_parse_token_num_t cmd_showport_macs_pid =
17258 TOKEN_NUM_INITIALIZER(struct cmd_showport_macs_result,
17259 cmd_pid, RTE_UINT16);
17260 cmdline_parse_token_string_t cmd_showport_macs_keyword =
17261 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17262 cmd_keyword, "macs#mcast_macs");
17264 cmdline_parse_inst_t cmd_showport_macs = {
17265 .f = cmd_showport_macs_parsed,
17267 .help_str = "show port <port_id> macs|mcast_macs",
17269 (void *)&cmd_showport_macs_show,
17270 (void *)&cmd_showport_macs_port,
17271 (void *)&cmd_showport_macs_pid,
17272 (void *)&cmd_showport_macs_keyword,
17277 /* ******************************************************************************** */
17279 /* list of instructions */
17280 cmdline_parse_ctx_t main_ctx[] = {
17281 (cmdline_parse_inst_t *)&cmd_help_brief,
17282 (cmdline_parse_inst_t *)&cmd_help_long,
17283 (cmdline_parse_inst_t *)&cmd_quit,
17284 (cmdline_parse_inst_t *)&cmd_load_from_file,
17285 (cmdline_parse_inst_t *)&cmd_showport,
17286 (cmdline_parse_inst_t *)&cmd_showqueue,
17287 (cmdline_parse_inst_t *)&cmd_showeeprom,
17288 (cmdline_parse_inst_t *)&cmd_showportall,
17289 (cmdline_parse_inst_t *)&cmd_showdevice,
17290 (cmdline_parse_inst_t *)&cmd_showcfg,
17291 (cmdline_parse_inst_t *)&cmd_showfwdall,
17292 (cmdline_parse_inst_t *)&cmd_start,
17293 (cmdline_parse_inst_t *)&cmd_start_tx_first,
17294 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
17295 (cmdline_parse_inst_t *)&cmd_set_link_up,
17296 (cmdline_parse_inst_t *)&cmd_set_link_down,
17297 (cmdline_parse_inst_t *)&cmd_reset,
17298 (cmdline_parse_inst_t *)&cmd_set_numbers,
17299 (cmdline_parse_inst_t *)&cmd_set_log,
17300 (cmdline_parse_inst_t *)&cmd_set_rxoffs,
17301 (cmdline_parse_inst_t *)&cmd_set_rxpkts,
17302 (cmdline_parse_inst_t *)&cmd_set_txpkts,
17303 (cmdline_parse_inst_t *)&cmd_set_txsplit,
17304 (cmdline_parse_inst_t *)&cmd_set_txtimes,
17305 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
17306 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
17307 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
17308 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
17309 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
17310 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
17311 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
17312 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
17313 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
17314 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
17315 (cmdline_parse_inst_t *)&cmd_set_link_check,
17316 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
17317 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
17318 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
17319 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
17320 #ifdef RTE_NET_BOND
17321 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
17322 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
17323 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
17324 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
17325 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
17326 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
17327 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
17328 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
17329 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
17330 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
17331 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
17333 (cmdline_parse_inst_t *)&cmd_vlan_offload,
17334 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
17335 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
17336 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
17337 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
17338 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
17339 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
17340 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
17341 (cmdline_parse_inst_t *)&cmd_csum_set,
17342 (cmdline_parse_inst_t *)&cmd_csum_show,
17343 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
17344 (cmdline_parse_inst_t *)&cmd_tso_set,
17345 (cmdline_parse_inst_t *)&cmd_tso_show,
17346 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
17347 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
17348 (cmdline_parse_inst_t *)&cmd_gro_enable,
17349 (cmdline_parse_inst_t *)&cmd_gro_flush,
17350 (cmdline_parse_inst_t *)&cmd_gro_show,
17351 (cmdline_parse_inst_t *)&cmd_gso_enable,
17352 (cmdline_parse_inst_t *)&cmd_gso_size,
17353 (cmdline_parse_inst_t *)&cmd_gso_show,
17354 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
17355 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
17356 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
17357 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
17358 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
17359 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
17360 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
17361 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
17362 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
17363 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
17364 (cmdline_parse_inst_t *)&cmd_config_dcb,
17365 (cmdline_parse_inst_t *)&cmd_read_reg,
17366 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
17367 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
17368 (cmdline_parse_inst_t *)&cmd_write_reg,
17369 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
17370 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
17371 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
17372 (cmdline_parse_inst_t *)&cmd_stop,
17373 (cmdline_parse_inst_t *)&cmd_mac_addr,
17374 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
17375 (cmdline_parse_inst_t *)&cmd_set_qmap,
17376 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
17377 (cmdline_parse_inst_t *)&cmd_set_record_core_cycles,
17378 (cmdline_parse_inst_t *)&cmd_set_record_burst_stats,
17379 (cmdline_parse_inst_t *)&cmd_operate_port,
17380 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
17381 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
17382 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
17383 (cmdline_parse_inst_t *)&cmd_operate_detach_device,
17384 (cmdline_parse_inst_t *)&cmd_set_port_setup_on,
17385 (cmdline_parse_inst_t *)&cmd_config_speed_all,
17386 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
17387 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
17388 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
17389 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
17390 (cmdline_parse_inst_t *)&cmd_config_mtu,
17391 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
17392 (cmdline_parse_inst_t *)&cmd_config_max_lro_pkt_size,
17393 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
17394 (cmdline_parse_inst_t *)&cmd_config_rss,
17395 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
17396 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
17397 (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
17398 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
17399 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
17400 (cmdline_parse_inst_t *)&cmd_showport_reta,
17401 (cmdline_parse_inst_t *)&cmd_showport_macs,
17402 (cmdline_parse_inst_t *)&cmd_config_burst,
17403 (cmdline_parse_inst_t *)&cmd_config_thresh,
17404 (cmdline_parse_inst_t *)&cmd_config_threshold,
17405 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
17406 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
17407 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
17408 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
17409 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
17410 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
17411 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
17412 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
17413 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
17414 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
17415 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
17416 (cmdline_parse_inst_t *)&cmd_dump,
17417 (cmdline_parse_inst_t *)&cmd_dump_one,
17418 #ifdef RTE_NET_I40E
17419 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
17421 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
17422 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
17423 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
17424 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
17425 (cmdline_parse_inst_t *)&cmd_flow,
17426 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
17427 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
17428 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
17429 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
17430 (cmdline_parse_inst_t *)&cmd_create_port_meter,
17431 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
17432 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
17433 (cmdline_parse_inst_t *)&cmd_del_port_meter,
17434 (cmdline_parse_inst_t *)&cmd_del_port_meter_policy,
17435 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
17436 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
17437 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
17438 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
17439 (cmdline_parse_inst_t *)&cmd_mcast_addr,
17440 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
17441 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
17442 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
17443 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
17444 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
17445 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
17446 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
17447 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
17448 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
17449 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
17450 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
17451 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
17452 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
17453 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
17454 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
17455 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
17456 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
17457 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
17458 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
17459 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
17460 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
17461 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
17462 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
17463 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
17464 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
17465 (cmdline_parse_inst_t *)&cmd_set_vxlan,
17466 (cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl,
17467 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
17468 (cmdline_parse_inst_t *)&cmd_set_nvgre,
17469 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
17470 (cmdline_parse_inst_t *)&cmd_set_l2_encap,
17471 (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
17472 (cmdline_parse_inst_t *)&cmd_set_l2_decap,
17473 (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
17474 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
17475 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
17476 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
17477 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
17478 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
17479 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
17480 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
17481 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
17482 (cmdline_parse_inst_t *)&cmd_set_conntrack_common,
17483 (cmdline_parse_inst_t *)&cmd_set_conntrack_dir,
17484 (cmdline_parse_inst_t *)&cmd_ddp_add,
17485 (cmdline_parse_inst_t *)&cmd_ddp_del,
17486 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
17487 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
17488 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
17489 (cmdline_parse_inst_t *)&cmd_clear_input_set,
17490 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
17491 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
17492 (cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes,
17493 (cmdline_parse_inst_t *)&cmd_set_port_ptypes,
17494 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
17495 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
17496 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
17497 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
17499 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
17500 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
17501 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
17502 (cmdline_parse_inst_t *)&cmd_queue_region,
17503 (cmdline_parse_inst_t *)&cmd_region_flowtype,
17504 (cmdline_parse_inst_t *)&cmd_user_priority_region,
17505 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
17506 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
17507 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
17508 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
17509 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
17510 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
17511 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
17512 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
17513 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
17514 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
17515 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
17516 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
17517 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
17518 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
17519 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
17520 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node_pmode,
17521 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
17522 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
17523 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
17524 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
17525 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
17526 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
17527 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
17528 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
17529 (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
17530 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
17531 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
17532 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
17533 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
17534 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
17535 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
17536 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
17537 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
17538 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
17540 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
17541 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
17543 (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
17544 (cmdline_parse_inst_t *)&cmd_show_tx_metadata,
17545 (cmdline_parse_inst_t *)&cmd_show_rx_tx_desc_status,
17546 (cmdline_parse_inst_t *)&cmd_show_rx_queue_desc_used_count,
17547 (cmdline_parse_inst_t *)&cmd_set_raw,
17548 (cmdline_parse_inst_t *)&cmd_show_set_raw,
17549 (cmdline_parse_inst_t *)&cmd_show_set_raw_all,
17550 (cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific,
17551 (cmdline_parse_inst_t *)&cmd_show_fec_mode,
17552 (cmdline_parse_inst_t *)&cmd_set_fec_mode,
17553 (cmdline_parse_inst_t *)&cmd_show_capability,
17557 /* read cmdline commands from file */
17559 cmdline_read_from_file(const char *filename)
17561 struct cmdline *cl;
17563 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
17565 printf("Failed to create file based cmdline context: %s\n",
17570 cmdline_interact(cl);
17575 printf("Read CLI commands from %s\n", filename);
17578 /* prompt function, called from main on MAIN lcore */
17583 /* initialize non-constant commands */
17584 cmd_set_fwd_mode_init();
17585 cmd_set_fwd_retry_mode_init();
17587 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
17588 if (testpmd_cl == NULL)
17591 ret = atexit(prompt_exit);
17593 printf("Cannot set exit function for cmdline\n");
17595 cmdline_interact(testpmd_cl);
17597 cmdline_stdin_exit(testpmd_cl);
17603 if (testpmd_cl != NULL) {
17604 cmdline_quit(testpmd_cl);
17605 cmdline_stdin_exit(testpmd_cl);
17610 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
17612 if (id == (portid_t)RTE_PORT_ALL) {
17615 RTE_ETH_FOREACH_DEV(pid) {
17616 /* check if need_reconfig has been set to 1 */
17617 if (ports[pid].need_reconfig == 0)
17618 ports[pid].need_reconfig = dev;
17619 /* check if need_reconfig_queues has been set to 1 */
17620 if (ports[pid].need_reconfig_queues == 0)
17621 ports[pid].need_reconfig_queues = queue;
17623 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
17624 /* check if need_reconfig has been set to 1 */
17625 if (ports[id].need_reconfig == 0)
17626 ports[id].need_reconfig = dev;
17627 /* check if need_reconfig_queues has been set to 1 */
17628 if (ports[id].need_reconfig_queues == 0)
17629 ports[id].need_reconfig_queues = queue;