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) (meter_enable)\n"
709 "(g_action) (y_action) (r_action) (stats_mask) (shared)\n"
710 "(use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n"
711 "(dscp_tbl_entry63)]\n"
714 "enable port meter (port_id) (mtr_id)\n"
717 "disable port meter (port_id) (mtr_id)\n"
720 "del port meter (port_id) (mtr_id)\n"
723 "set port meter profile (port_id) (mtr_id) (profile_id)\n"
724 " meter update meter profile\n\n"
726 "set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n"
727 "(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n"
728 " update meter dscp table entries\n\n"
730 "set port meter policer action (port_id) (mtr_id) (action_mask)\n"
731 "(action0) [(action1) (action2)]\n"
732 " meter update policer action\n\n"
734 "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
735 " meter update stats\n\n"
737 "show port (port_id) queue-region\n"
738 " show all queue region related configuration info\n\n"
740 "set port (port_id) fec_mode auto|off|rs|baser\n"
741 " set fec mode for a specific port\n\n"
743 , list_pkt_forwarding_modes()
747 if (show_all || !strcmp(res->section, "ports")) {
753 "----------------\n\n"
755 "port start (port_id|all)\n"
756 " Start all ports or port_id.\n\n"
758 "port stop (port_id|all)\n"
759 " Stop all ports or port_id.\n\n"
761 "port close (port_id|all)\n"
762 " Close all ports or port_id.\n\n"
764 "port reset (port_id|all)\n"
765 " Reset all ports or port_id.\n\n"
767 "port attach (ident)\n"
768 " Attach physical or virtual dev by pci address or virtual device name\n\n"
770 "port detach (port_id)\n"
771 " Detach physical or virtual dev by port_id\n\n"
773 "port config (port_id|all)"
774 " speed (10|100|1000|10000|25000|40000|50000|100000|200000|auto)"
775 " duplex (half|full|auto)\n"
776 " Set speed and duplex for all ports or port_id\n\n"
778 "port config (port_id|all) loopback (mode)\n"
779 " Set loopback mode for all ports or port_id\n\n"
781 "port config all (rxq|txq|rxd|txd) (value)\n"
782 " Set number for rxq/txq/rxd/txd.\n\n"
784 "port config all max-pkt-len (value)\n"
785 " Set the max packet length.\n\n"
787 "port config all max-lro-pkt-size (value)\n"
788 " Set the max LRO aggregated packet size.\n\n"
790 "port config all drop-en (on|off)\n"
791 " Enable or disable packet drop on all RX queues of all ports when no "
792 "receive buffers available.\n\n"
794 "port config all rss (all|default|ip|tcp|udp|sctp|"
795 "ether|port|vxlan|geneve|nvgre|vxlan-gpe|ecpri|mpls|none|level-default|"
796 "level-outer|level-inner|<flowtype_id>)\n"
797 " Set the RSS mode.\n\n"
799 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
800 " Set the RSS redirection table.\n\n"
802 "port config (port_id) dcb vt (on|off) (traffic_class)"
804 " Set the DCB mode.\n\n"
806 "port config all burst (value)\n"
807 " Set the number of packets per burst.\n\n"
809 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
811 " Set the ring prefetch/host/writeback threshold"
812 " for tx/rx queue.\n\n"
814 "port config all (txfreet|txrst|rxfreet) (value)\n"
815 " Set free threshold for rx/tx, or set"
816 " tx rs bit threshold.\n\n"
817 "port config mtu X value\n"
818 " Set the MTU of port X to a given value\n\n"
820 "port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n"
821 " Set a rx/tx queue's ring size configuration, the new"
822 " value will take effect after command that (re-)start the port"
823 " or command that setup the specific queue\n\n"
825 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
826 " Start/stop a rx/tx queue of port X. Only take effect"
827 " when port X is started\n\n"
829 "port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n"
830 " Switch on/off a deferred start of port X rx/tx queue. Only"
831 " take effect when port X is stopped.\n\n"
833 "port (port_id) (rxq|txq) (queue_id) setup\n"
834 " Setup a rx/tx queue of port X.\n\n"
836 "port config (port_id) pctype mapping reset\n"
837 " Reset flow type to pctype mapping on a port\n\n"
839 "port config (port_id) pctype mapping update"
840 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
841 " Update a flow type to pctype mapping item on a port\n\n"
843 "port config (port_id) pctype (pctype_id) hash_inset|"
844 "fdir_inset|fdir_flx_inset get|set|clear field\n"
846 " Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n"
848 "port config (port_id) pctype (pctype_id) hash_inset|"
849 "fdir_inset|fdir_flx_inset clear all"
850 " Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n"
852 "port config (port_id) udp_tunnel_port add|rm vxlan|geneve|ecpri (udp_port)\n\n"
853 " Add/remove UDP tunnel port for tunneling offload\n\n"
855 "port config <port_id> rx_offload vlan_strip|"
856 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
857 "outer_ipv4_cksum|macsec_strip|header_split|"
858 "vlan_filter|vlan_extend|jumbo_frame|scatter|"
859 "buffer_split|timestamp|security|keep_crc on|off\n"
860 " Enable or disable a per port Rx offloading"
861 " on all Rx queues of a port\n\n"
863 "port (port_id) rxq (queue_id) rx_offload vlan_strip|"
864 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
865 "outer_ipv4_cksum|macsec_strip|header_split|"
866 "vlan_filter|vlan_extend|jumbo_frame|scatter|"
867 "buffer_split|timestamp|security|keep_crc on|off\n"
868 " Enable or disable a per queue Rx offloading"
869 " only on a specific Rx queue\n\n"
871 "port config (port_id) tx_offload vlan_insert|"
872 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
873 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
874 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|"
875 "macsec_insert|mt_lockfree|multi_segs|mbuf_fast_free|"
877 " Enable or disable a per port Tx offloading"
878 " on all Tx queues of a port\n\n"
880 "port (port_id) txq (queue_id) tx_offload vlan_insert|"
881 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
882 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
883 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|macsec_insert"
884 "|mt_lockfree|multi_segs|mbuf_fast_free|security"
886 " Enable or disable a per queue Tx offloading"
887 " only on a specific Tx queue\n\n"
889 "bpf-load rx|tx (port) (queue) (J|M|B) (file_name)\n"
890 " Load an eBPF program as a callback"
891 " for particular RX/TX queue\n\n"
893 "bpf-unload rx|tx (port) (queue)\n"
894 " Unload previously loaded eBPF program"
895 " for particular RX/TX queue\n\n"
897 "port config (port_id) tx_metadata (value)\n"
898 " Set Tx metadata value per port. Testpmd will add this value"
899 " to any Tx packet sent from this port\n\n"
901 "port config (port_id) dynf (name) set|clear\n"
902 " Register a dynf and Set/clear this flag on Tx. "
903 "Testpmd will set this value to any Tx packet "
904 "sent from this port\n\n"
908 if (show_all || !strcmp(res->section, "registers")) {
916 "read reg (port_id) (address)\n"
917 " Display value of a port register.\n\n"
919 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
920 " Display a port register bit field.\n\n"
922 "read regbit (port_id) (address) (bit_x)\n"
923 " Display a single port register bit.\n\n"
925 "write reg (port_id) (address) (value)\n"
926 " Set value of a port register.\n\n"
928 "write regfield (port_id) (address) (bit_x) (bit_y)"
930 " Set bit field of a port register.\n\n"
932 "write regbit (port_id) (address) (bit_x) (value)\n"
933 " Set single bit value of a port register.\n\n"
936 if (show_all || !strcmp(res->section, "filters")) {
945 "flow_director_filter (port_id) mode raw (add|del|update)"
946 " flow (flow_id) (drop|fwd) queue (queue_id)"
947 " fd_id (fd_id_value) packet (packet file name)\n"
948 " Add/Del a raw type flow director filter.\n\n"
951 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
952 " src_mask (ipv4_src) (ipv6_src) (src_port)"
953 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
954 " Set flow director IP mask.\n\n"
956 "flow_director_mask (port_id) mode MAC-VLAN"
957 " vlan (vlan_value)\n"
958 " Set flow director MAC-VLAN mask.\n\n"
960 "flow_director_mask (port_id) mode Tunnel"
961 " vlan (vlan_value) mac (mac_value)"
962 " tunnel-type (tunnel_type_value)"
963 " tunnel-id (tunnel_id_value)\n"
964 " Set flow director Tunnel mask.\n\n"
966 "flow_director_flex_payload (port_id)"
967 " (raw|l2|l3|l4) (config)\n"
968 " Configure flex payload selection.\n\n"
970 "flow validate {port_id}"
971 " [group {group_id}] [priority {level}]"
972 " [ingress] [egress]"
973 " pattern {item} [/ {item} [...]] / end"
974 " actions {action} [/ {action} [...]] / end\n"
975 " Check whether a flow rule can be created.\n\n"
977 "flow create {port_id}"
978 " [group {group_id}] [priority {level}]"
979 " [ingress] [egress]"
980 " pattern {item} [/ {item} [...]] / end"
981 " actions {action} [/ {action} [...]] / end\n"
982 " Create a flow rule.\n\n"
984 "flow destroy {port_id} rule {rule_id} [...]\n"
985 " Destroy specific flow rules.\n\n"
987 "flow flush {port_id}\n"
988 " Destroy all flow rules.\n\n"
990 "flow query {port_id} {rule_id} {action}\n"
991 " Query an existing flow rule.\n\n"
993 "flow list {port_id} [group {group_id}] [...]\n"
994 " List existing flow rules sorted by priority,"
995 " filtered by group identifiers.\n\n"
997 "flow isolate {port_id} {boolean}\n"
998 " Restrict ingress traffic to the defined"
1001 "flow aged {port_id} [destroy]\n"
1002 " List and destroy aged flows"
1005 "flow indirect_action {port_id} create"
1006 " [action_id {indirect_action_id}]"
1007 " [ingress] [egress]"
1008 " action {action} / end\n"
1009 " Create indirect action.\n\n"
1011 "flow indirect_action {port_id} update"
1012 " {indirect_action_id} action {action} / end\n"
1013 " Update indirect action.\n\n"
1015 "flow indirect_action {port_id} destroy"
1016 " action_id {indirect_action_id} [...]\n"
1017 " Destroy specific indirect actions.\n\n"
1019 "flow indirect_action {port_id} query"
1020 " {indirect_action_id}\n"
1021 " Query an existing indirect action.\n\n"
1023 "set vxlan ip-version (ipv4|ipv6) vni (vni) udp-src"
1024 " (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst"
1025 " (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n"
1026 " Configure the VXLAN encapsulation for flows.\n\n"
1028 "set vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)"
1029 " udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)"
1030 " ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)"
1031 " eth-dst (eth-dst)\n"
1032 " Configure the VXLAN encapsulation for flows.\n\n"
1034 "set vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src"
1035 " (udp-src) udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl)"
1036 " ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src)"
1037 " eth-dst (eth-dst)\n"
1038 " Configure the VXLAN encapsulation for flows.\n\n"
1040 "set nvgre ip-version (ipv4|ipv6) tni (tni) ip-src"
1041 " (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst"
1043 " Configure the NVGRE encapsulation for flows.\n\n"
1045 "set nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)"
1046 " ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)"
1047 " eth-src (eth-src) eth-dst (eth-dst)\n"
1048 " Configure the NVGRE encapsulation for flows.\n\n"
1050 "set raw_encap {flow items}\n"
1051 " Configure the encapsulation with raw data.\n\n"
1053 "set raw_decap {flow items}\n"
1054 " Configure the decapsulation with raw data.\n\n"
1059 if (show_all || !strcmp(res->section, "traffic_management")) {
1063 "Traffic Management:\n"
1065 "show port tm cap (port_id)\n"
1066 " Display the port TM capability.\n\n"
1068 "show port tm level cap (port_id) (level_id)\n"
1069 " Display the port TM hierarchical level capability.\n\n"
1071 "show port tm node cap (port_id) (node_id)\n"
1072 " Display the port TM node capability.\n\n"
1074 "show port tm node type (port_id) (node_id)\n"
1075 " Display the port TM node type.\n\n"
1077 "show port tm node stats (port_id) (node_id) (clear)\n"
1078 " Display the port TM node stats.\n\n"
1080 "add port tm node shaper profile (port_id) (shaper_profile_id)"
1081 " (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)"
1082 " (packet_length_adjust) (packet_mode)\n"
1083 " Add port tm node private shaper profile.\n\n"
1085 "del port tm node shaper profile (port_id) (shaper_profile_id)\n"
1086 " Delete port tm node private shaper profile.\n\n"
1088 "add port tm node shared shaper (port_id) (shared_shaper_id)"
1089 " (shaper_profile_id)\n"
1090 " Add/update port tm node shared shaper.\n\n"
1092 "del port tm node shared shaper (port_id) (shared_shaper_id)\n"
1093 " Delete port tm node shared shaper.\n\n"
1095 "set port tm node shaper profile (port_id) (node_id)"
1096 " (shaper_profile_id)\n"
1097 " Set port tm node shaper profile.\n\n"
1099 "add port tm node wred profile (port_id) (wred_profile_id)"
1100 " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
1101 " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
1102 " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
1103 " Add port tm node wred profile.\n\n"
1105 "del port tm node wred profile (port_id) (wred_profile_id)\n"
1106 " Delete port tm node wred profile.\n\n"
1108 "add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
1109 " (priority) (weight) (level_id) (shaper_profile_id)"
1110 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1111 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1112 " Add port tm nonleaf node.\n\n"
1114 "add port tm nonleaf node pktmode (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 with pkt mode enabled.\n\n"
1120 "add port tm leaf node (port_id) (node_id) (parent_node_id)"
1121 " (priority) (weight) (level_id) (shaper_profile_id)"
1122 " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
1123 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1124 " Add port tm leaf node.\n\n"
1126 "del port tm node (port_id) (node_id)\n"
1127 " Delete port tm node.\n\n"
1129 "set port tm node parent (port_id) (node_id) (parent_node_id)"
1130 " (priority) (weight)\n"
1131 " Set port tm node parent.\n\n"
1133 "suspend port tm node (port_id) (node_id)"
1134 " Suspend tm node.\n\n"
1136 "resume port tm node (port_id) (node_id)"
1137 " Resume tm node.\n\n"
1139 "port tm hierarchy commit (port_id) (clean_on_fail)\n"
1140 " Commit tm hierarchy.\n\n"
1142 "set port tm mark ip_ecn (port) (green) (yellow)"
1144 " Enables/Disables the traffic management marking"
1145 " for IP ECN (Explicit Congestion Notification)"
1146 " packets on a given port\n\n"
1148 "set port tm mark ip_dscp (port) (green) (yellow)"
1150 " Enables/Disables the traffic management marking"
1151 " on the port for IP dscp packets\n\n"
1153 "set port tm mark vlan_dei (port) (green) (yellow)"
1155 " Enables/Disables the traffic management marking"
1156 " on the port for VLAN packets with DEI enabled\n\n"
1160 if (show_all || !strcmp(res->section, "devices")) {
1164 "Device Operations:\n"
1166 "device detach (identifier)\n"
1167 " Detach device by identifier.\n\n"
1173 cmdline_parse_token_string_t cmd_help_long_help =
1174 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1176 cmdline_parse_token_string_t cmd_help_long_section =
1177 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1178 "all#control#display#config#"
1179 "ports#registers#filters#traffic_management#devices");
1181 cmdline_parse_inst_t cmd_help_long = {
1182 .f = cmd_help_long_parsed,
1184 .help_str = "help all|control|display|config|ports|register|"
1185 "filters|traffic_management|devices: "
1188 (void *)&cmd_help_long_help,
1189 (void *)&cmd_help_long_section,
1195 /* *** start/stop/close all ports *** */
1196 struct cmd_operate_port_result {
1197 cmdline_fixed_string_t keyword;
1198 cmdline_fixed_string_t name;
1199 cmdline_fixed_string_t value;
1202 static void cmd_operate_port_parsed(void *parsed_result,
1203 __rte_unused struct cmdline *cl,
1204 __rte_unused void *data)
1206 struct cmd_operate_port_result *res = parsed_result;
1208 if (!strcmp(res->name, "start"))
1209 start_port(RTE_PORT_ALL);
1210 else if (!strcmp(res->name, "stop"))
1211 stop_port(RTE_PORT_ALL);
1212 else if (!strcmp(res->name, "close"))
1213 close_port(RTE_PORT_ALL);
1214 else if (!strcmp(res->name, "reset"))
1215 reset_port(RTE_PORT_ALL);
1217 printf("Unknown parameter\n");
1220 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1221 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1223 cmdline_parse_token_string_t cmd_operate_port_all_port =
1224 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1225 "start#stop#close#reset");
1226 cmdline_parse_token_string_t cmd_operate_port_all_all =
1227 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1229 cmdline_parse_inst_t cmd_operate_port = {
1230 .f = cmd_operate_port_parsed,
1232 .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports",
1234 (void *)&cmd_operate_port_all_cmd,
1235 (void *)&cmd_operate_port_all_port,
1236 (void *)&cmd_operate_port_all_all,
1241 /* *** start/stop/close specific port *** */
1242 struct cmd_operate_specific_port_result {
1243 cmdline_fixed_string_t keyword;
1244 cmdline_fixed_string_t name;
1248 static void cmd_operate_specific_port_parsed(void *parsed_result,
1249 __rte_unused struct cmdline *cl,
1250 __rte_unused void *data)
1252 struct cmd_operate_specific_port_result *res = parsed_result;
1254 if (!strcmp(res->name, "start"))
1255 start_port(res->value);
1256 else if (!strcmp(res->name, "stop"))
1257 stop_port(res->value);
1258 else if (!strcmp(res->name, "close"))
1259 close_port(res->value);
1260 else if (!strcmp(res->name, "reset"))
1261 reset_port(res->value);
1263 printf("Unknown parameter\n");
1266 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1267 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1269 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1270 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1271 name, "start#stop#close#reset");
1272 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1273 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1276 cmdline_parse_inst_t cmd_operate_specific_port = {
1277 .f = cmd_operate_specific_port_parsed,
1279 .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id",
1281 (void *)&cmd_operate_specific_port_cmd,
1282 (void *)&cmd_operate_specific_port_port,
1283 (void *)&cmd_operate_specific_port_id,
1288 /* *** enable port setup (after attach) via iterator or event *** */
1289 struct cmd_set_port_setup_on_result {
1290 cmdline_fixed_string_t set;
1291 cmdline_fixed_string_t port;
1292 cmdline_fixed_string_t setup;
1293 cmdline_fixed_string_t on;
1294 cmdline_fixed_string_t mode;
1297 static void cmd_set_port_setup_on_parsed(void *parsed_result,
1298 __rte_unused struct cmdline *cl,
1299 __rte_unused void *data)
1301 struct cmd_set_port_setup_on_result *res = parsed_result;
1303 if (strcmp(res->mode, "event") == 0)
1304 setup_on_probe_event = true;
1305 else if (strcmp(res->mode, "iterator") == 0)
1306 setup_on_probe_event = false;
1308 printf("Unknown mode\n");
1311 cmdline_parse_token_string_t cmd_set_port_setup_on_set =
1312 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1314 cmdline_parse_token_string_t cmd_set_port_setup_on_port =
1315 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1317 cmdline_parse_token_string_t cmd_set_port_setup_on_setup =
1318 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1320 cmdline_parse_token_string_t cmd_set_port_setup_on_on =
1321 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1323 cmdline_parse_token_string_t cmd_set_port_setup_on_mode =
1324 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1325 mode, "iterator#event");
1327 cmdline_parse_inst_t cmd_set_port_setup_on = {
1328 .f = cmd_set_port_setup_on_parsed,
1330 .help_str = "set port setup on iterator|event",
1332 (void *)&cmd_set_port_setup_on_set,
1333 (void *)&cmd_set_port_setup_on_port,
1334 (void *)&cmd_set_port_setup_on_setup,
1335 (void *)&cmd_set_port_setup_on_on,
1336 (void *)&cmd_set_port_setup_on_mode,
1341 /* *** attach a specified port *** */
1342 struct cmd_operate_attach_port_result {
1343 cmdline_fixed_string_t port;
1344 cmdline_fixed_string_t keyword;
1345 cmdline_multi_string_t identifier;
1348 static void cmd_operate_attach_port_parsed(void *parsed_result,
1349 __rte_unused struct cmdline *cl,
1350 __rte_unused void *data)
1352 struct cmd_operate_attach_port_result *res = parsed_result;
1354 if (!strcmp(res->keyword, "attach"))
1355 attach_port(res->identifier);
1357 printf("Unknown parameter\n");
1360 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1361 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1363 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1364 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1366 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1367 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1368 identifier, TOKEN_STRING_MULTI);
1370 cmdline_parse_inst_t cmd_operate_attach_port = {
1371 .f = cmd_operate_attach_port_parsed,
1373 .help_str = "port attach <identifier>: "
1374 "(identifier: pci address or virtual dev name)",
1376 (void *)&cmd_operate_attach_port_port,
1377 (void *)&cmd_operate_attach_port_keyword,
1378 (void *)&cmd_operate_attach_port_identifier,
1383 /* *** detach a specified port *** */
1384 struct cmd_operate_detach_port_result {
1385 cmdline_fixed_string_t port;
1386 cmdline_fixed_string_t keyword;
1390 static void cmd_operate_detach_port_parsed(void *parsed_result,
1391 __rte_unused struct cmdline *cl,
1392 __rte_unused void *data)
1394 struct cmd_operate_detach_port_result *res = parsed_result;
1396 if (!strcmp(res->keyword, "detach")) {
1397 RTE_ETH_VALID_PORTID_OR_RET(res->port_id);
1398 detach_port_device(res->port_id);
1400 printf("Unknown parameter\n");
1404 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1405 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1407 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1408 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1410 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1411 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1412 port_id, RTE_UINT16);
1414 cmdline_parse_inst_t cmd_operate_detach_port = {
1415 .f = cmd_operate_detach_port_parsed,
1417 .help_str = "port detach <port_id>",
1419 (void *)&cmd_operate_detach_port_port,
1420 (void *)&cmd_operate_detach_port_keyword,
1421 (void *)&cmd_operate_detach_port_port_id,
1426 /* *** detach device by identifier *** */
1427 struct cmd_operate_detach_device_result {
1428 cmdline_fixed_string_t device;
1429 cmdline_fixed_string_t keyword;
1430 cmdline_fixed_string_t identifier;
1433 static void cmd_operate_detach_device_parsed(void *parsed_result,
1434 __rte_unused struct cmdline *cl,
1435 __rte_unused void *data)
1437 struct cmd_operate_detach_device_result *res = parsed_result;
1439 if (!strcmp(res->keyword, "detach"))
1440 detach_devargs(res->identifier);
1442 printf("Unknown parameter\n");
1445 cmdline_parse_token_string_t cmd_operate_detach_device_device =
1446 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1448 cmdline_parse_token_string_t cmd_operate_detach_device_keyword =
1449 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1451 cmdline_parse_token_string_t cmd_operate_detach_device_identifier =
1452 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1455 cmdline_parse_inst_t cmd_operate_detach_device = {
1456 .f = cmd_operate_detach_device_parsed,
1458 .help_str = "device detach <identifier>:"
1459 "(identifier: pci address or virtual dev name)",
1461 (void *)&cmd_operate_detach_device_device,
1462 (void *)&cmd_operate_detach_device_keyword,
1463 (void *)&cmd_operate_detach_device_identifier,
1467 /* *** configure speed for all ports *** */
1468 struct cmd_config_speed_all {
1469 cmdline_fixed_string_t port;
1470 cmdline_fixed_string_t keyword;
1471 cmdline_fixed_string_t all;
1472 cmdline_fixed_string_t item1;
1473 cmdline_fixed_string_t item2;
1474 cmdline_fixed_string_t value1;
1475 cmdline_fixed_string_t value2;
1479 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1484 if (!strcmp(duplexstr, "half")) {
1485 duplex = ETH_LINK_HALF_DUPLEX;
1486 } else if (!strcmp(duplexstr, "full")) {
1487 duplex = ETH_LINK_FULL_DUPLEX;
1488 } else if (!strcmp(duplexstr, "auto")) {
1489 duplex = ETH_LINK_FULL_DUPLEX;
1491 printf("Unknown duplex parameter\n");
1495 if (!strcmp(speedstr, "10")) {
1496 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1497 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1498 } else if (!strcmp(speedstr, "100")) {
1499 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1500 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1502 if (duplex != ETH_LINK_FULL_DUPLEX) {
1503 printf("Invalid speed/duplex parameters\n");
1506 if (!strcmp(speedstr, "1000")) {
1507 *speed = ETH_LINK_SPEED_1G;
1508 } else if (!strcmp(speedstr, "10000")) {
1509 *speed = ETH_LINK_SPEED_10G;
1510 } else if (!strcmp(speedstr, "25000")) {
1511 *speed = ETH_LINK_SPEED_25G;
1512 } else if (!strcmp(speedstr, "40000")) {
1513 *speed = ETH_LINK_SPEED_40G;
1514 } else if (!strcmp(speedstr, "50000")) {
1515 *speed = ETH_LINK_SPEED_50G;
1516 } else if (!strcmp(speedstr, "100000")) {
1517 *speed = ETH_LINK_SPEED_100G;
1518 } else if (!strcmp(speedstr, "200000")) {
1519 *speed = ETH_LINK_SPEED_200G;
1520 } else if (!strcmp(speedstr, "auto")) {
1521 *speed = ETH_LINK_SPEED_AUTONEG;
1523 printf("Unknown speed parameter\n");
1528 if (*speed != ETH_LINK_SPEED_AUTONEG)
1529 *speed |= ETH_LINK_SPEED_FIXED;
1535 cmd_config_speed_all_parsed(void *parsed_result,
1536 __rte_unused struct cmdline *cl,
1537 __rte_unused void *data)
1539 struct cmd_config_speed_all *res = parsed_result;
1540 uint32_t link_speed;
1543 if (!all_ports_stopped()) {
1544 printf("Please stop all ports first\n");
1548 if (parse_and_check_speed_duplex(res->value1, res->value2,
1552 RTE_ETH_FOREACH_DEV(pid) {
1553 ports[pid].dev_conf.link_speeds = link_speed;
1556 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1559 cmdline_parse_token_string_t cmd_config_speed_all_port =
1560 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1561 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1562 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1564 cmdline_parse_token_string_t cmd_config_speed_all_all =
1565 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1566 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1567 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1568 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1569 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1570 "10#100#1000#10000#25000#40000#50000#100000#200000#auto");
1571 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1572 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1573 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1574 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1577 cmdline_parse_inst_t cmd_config_speed_all = {
1578 .f = cmd_config_speed_all_parsed,
1580 .help_str = "port config all speed "
1581 "10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex "
1584 (void *)&cmd_config_speed_all_port,
1585 (void *)&cmd_config_speed_all_keyword,
1586 (void *)&cmd_config_speed_all_all,
1587 (void *)&cmd_config_speed_all_item1,
1588 (void *)&cmd_config_speed_all_value1,
1589 (void *)&cmd_config_speed_all_item2,
1590 (void *)&cmd_config_speed_all_value2,
1595 /* *** configure speed for specific port *** */
1596 struct cmd_config_speed_specific {
1597 cmdline_fixed_string_t port;
1598 cmdline_fixed_string_t keyword;
1600 cmdline_fixed_string_t item1;
1601 cmdline_fixed_string_t item2;
1602 cmdline_fixed_string_t value1;
1603 cmdline_fixed_string_t value2;
1607 cmd_config_speed_specific_parsed(void *parsed_result,
1608 __rte_unused struct cmdline *cl,
1609 __rte_unused void *data)
1611 struct cmd_config_speed_specific *res = parsed_result;
1612 uint32_t link_speed;
1614 if (!all_ports_stopped()) {
1615 printf("Please stop all ports first\n");
1619 if (port_id_is_invalid(res->id, ENABLED_WARN))
1622 if (parse_and_check_speed_duplex(res->value1, res->value2,
1626 ports[res->id].dev_conf.link_speeds = link_speed;
1628 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1632 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1633 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1635 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1636 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1638 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1639 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, RTE_UINT16);
1640 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1641 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1643 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1644 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1645 "10#100#1000#10000#25000#40000#50000#100000#200000#auto");
1646 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1647 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1649 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1650 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1653 cmdline_parse_inst_t cmd_config_speed_specific = {
1654 .f = cmd_config_speed_specific_parsed,
1656 .help_str = "port config <port_id> speed "
1657 "10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex "
1660 (void *)&cmd_config_speed_specific_port,
1661 (void *)&cmd_config_speed_specific_keyword,
1662 (void *)&cmd_config_speed_specific_id,
1663 (void *)&cmd_config_speed_specific_item1,
1664 (void *)&cmd_config_speed_specific_value1,
1665 (void *)&cmd_config_speed_specific_item2,
1666 (void *)&cmd_config_speed_specific_value2,
1671 /* *** configure loopback for all ports *** */
1672 struct cmd_config_loopback_all {
1673 cmdline_fixed_string_t port;
1674 cmdline_fixed_string_t keyword;
1675 cmdline_fixed_string_t all;
1676 cmdline_fixed_string_t item;
1681 cmd_config_loopback_all_parsed(void *parsed_result,
1682 __rte_unused struct cmdline *cl,
1683 __rte_unused void *data)
1685 struct cmd_config_loopback_all *res = parsed_result;
1688 if (!all_ports_stopped()) {
1689 printf("Please stop all ports first\n");
1693 RTE_ETH_FOREACH_DEV(pid) {
1694 ports[pid].dev_conf.lpbk_mode = res->mode;
1697 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1700 cmdline_parse_token_string_t cmd_config_loopback_all_port =
1701 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1702 cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1703 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1705 cmdline_parse_token_string_t cmd_config_loopback_all_all =
1706 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1707 cmdline_parse_token_string_t cmd_config_loopback_all_item =
1708 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1710 cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1711 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, RTE_UINT32);
1713 cmdline_parse_inst_t cmd_config_loopback_all = {
1714 .f = cmd_config_loopback_all_parsed,
1716 .help_str = "port config all loopback <mode>",
1718 (void *)&cmd_config_loopback_all_port,
1719 (void *)&cmd_config_loopback_all_keyword,
1720 (void *)&cmd_config_loopback_all_all,
1721 (void *)&cmd_config_loopback_all_item,
1722 (void *)&cmd_config_loopback_all_mode,
1727 /* *** configure loopback for specific port *** */
1728 struct cmd_config_loopback_specific {
1729 cmdline_fixed_string_t port;
1730 cmdline_fixed_string_t keyword;
1732 cmdline_fixed_string_t item;
1737 cmd_config_loopback_specific_parsed(void *parsed_result,
1738 __rte_unused struct cmdline *cl,
1739 __rte_unused void *data)
1741 struct cmd_config_loopback_specific *res = parsed_result;
1743 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1746 if (!port_is_stopped(res->port_id)) {
1747 printf("Please stop port %u first\n", res->port_id);
1751 ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1753 cmd_reconfig_device_queue(res->port_id, 1, 1);
1757 cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1758 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1760 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1761 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1763 cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1764 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1766 cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1767 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1769 cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1770 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1773 cmdline_parse_inst_t cmd_config_loopback_specific = {
1774 .f = cmd_config_loopback_specific_parsed,
1776 .help_str = "port config <port_id> loopback <mode>",
1778 (void *)&cmd_config_loopback_specific_port,
1779 (void *)&cmd_config_loopback_specific_keyword,
1780 (void *)&cmd_config_loopback_specific_id,
1781 (void *)&cmd_config_loopback_specific_item,
1782 (void *)&cmd_config_loopback_specific_mode,
1787 /* *** configure txq/rxq, txd/rxd *** */
1788 struct cmd_config_rx_tx {
1789 cmdline_fixed_string_t port;
1790 cmdline_fixed_string_t keyword;
1791 cmdline_fixed_string_t all;
1792 cmdline_fixed_string_t name;
1797 cmd_config_rx_tx_parsed(void *parsed_result,
1798 __rte_unused struct cmdline *cl,
1799 __rte_unused void *data)
1801 struct cmd_config_rx_tx *res = parsed_result;
1803 if (!all_ports_stopped()) {
1804 printf("Please stop all ports first\n");
1807 if (!strcmp(res->name, "rxq")) {
1808 if (!res->value && !nb_txq) {
1809 printf("Warning: Either rx or tx queues should be non zero\n");
1812 if (check_nb_rxq(res->value) != 0)
1814 nb_rxq = res->value;
1816 else if (!strcmp(res->name, "txq")) {
1817 if (!res->value && !nb_rxq) {
1818 printf("Warning: Either rx or tx queues should be non zero\n");
1821 if (check_nb_txq(res->value) != 0)
1823 nb_txq = res->value;
1825 else if (!strcmp(res->name, "rxd")) {
1826 if (check_nb_rxd(res->value) != 0)
1828 nb_rxd = res->value;
1829 } else if (!strcmp(res->name, "txd")) {
1830 if (check_nb_txd(res->value) != 0)
1833 nb_txd = res->value;
1835 printf("Unknown parameter\n");
1843 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1846 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1847 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1848 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1849 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1850 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1851 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1852 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1853 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1855 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1856 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, RTE_UINT16);
1858 cmdline_parse_inst_t cmd_config_rx_tx = {
1859 .f = cmd_config_rx_tx_parsed,
1861 .help_str = "port config all rxq|txq|rxd|txd <value>",
1863 (void *)&cmd_config_rx_tx_port,
1864 (void *)&cmd_config_rx_tx_keyword,
1865 (void *)&cmd_config_rx_tx_all,
1866 (void *)&cmd_config_rx_tx_name,
1867 (void *)&cmd_config_rx_tx_value,
1872 /* *** config max packet length *** */
1873 struct cmd_config_max_pkt_len_result {
1874 cmdline_fixed_string_t port;
1875 cmdline_fixed_string_t keyword;
1876 cmdline_fixed_string_t all;
1877 cmdline_fixed_string_t name;
1882 cmd_config_max_pkt_len_parsed(void *parsed_result,
1883 __rte_unused struct cmdline *cl,
1884 __rte_unused void *data)
1886 struct cmd_config_max_pkt_len_result *res = parsed_result;
1887 uint32_t max_rx_pkt_len_backup = 0;
1891 if (!all_ports_stopped()) {
1892 printf("Please stop all ports first\n");
1896 RTE_ETH_FOREACH_DEV(pid) {
1897 struct rte_port *port = &ports[pid];
1899 if (!strcmp(res->name, "max-pkt-len")) {
1900 if (res->value < RTE_ETHER_MIN_LEN) {
1901 printf("max-pkt-len can not be less than %d\n",
1905 if (res->value == port->dev_conf.rxmode.max_rx_pkt_len)
1908 ret = eth_dev_info_get_print_err(pid, &port->dev_info);
1910 printf("rte_eth_dev_info_get() failed for port %u\n",
1915 max_rx_pkt_len_backup = port->dev_conf.rxmode.max_rx_pkt_len;
1917 port->dev_conf.rxmode.max_rx_pkt_len = res->value;
1918 if (update_jumbo_frame_offload(pid) != 0)
1919 port->dev_conf.rxmode.max_rx_pkt_len = max_rx_pkt_len_backup;
1921 printf("Unknown parameter\n");
1928 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1931 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1932 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1934 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1935 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1937 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1938 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1940 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1941 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1943 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1944 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1947 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1948 .f = cmd_config_max_pkt_len_parsed,
1950 .help_str = "port config all max-pkt-len <value>",
1952 (void *)&cmd_config_max_pkt_len_port,
1953 (void *)&cmd_config_max_pkt_len_keyword,
1954 (void *)&cmd_config_max_pkt_len_all,
1955 (void *)&cmd_config_max_pkt_len_name,
1956 (void *)&cmd_config_max_pkt_len_value,
1961 /* *** config max LRO aggregated packet size *** */
1962 struct cmd_config_max_lro_pkt_size_result {
1963 cmdline_fixed_string_t port;
1964 cmdline_fixed_string_t keyword;
1965 cmdline_fixed_string_t all;
1966 cmdline_fixed_string_t name;
1971 cmd_config_max_lro_pkt_size_parsed(void *parsed_result,
1972 __rte_unused struct cmdline *cl,
1973 __rte_unused void *data)
1975 struct cmd_config_max_lro_pkt_size_result *res = parsed_result;
1978 if (!all_ports_stopped()) {
1979 printf("Please stop all ports first\n");
1983 RTE_ETH_FOREACH_DEV(pid) {
1984 struct rte_port *port = &ports[pid];
1986 if (!strcmp(res->name, "max-lro-pkt-size")) {
1988 port->dev_conf.rxmode.max_lro_pkt_size)
1991 port->dev_conf.rxmode.max_lro_pkt_size = res->value;
1993 printf("Unknown parameter\n");
2000 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2003 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_port =
2004 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2006 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_keyword =
2007 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2009 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_all =
2010 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2012 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_name =
2013 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2014 name, "max-lro-pkt-size");
2015 cmdline_parse_token_num_t cmd_config_max_lro_pkt_size_value =
2016 TOKEN_NUM_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2019 cmdline_parse_inst_t cmd_config_max_lro_pkt_size = {
2020 .f = cmd_config_max_lro_pkt_size_parsed,
2022 .help_str = "port config all max-lro-pkt-size <value>",
2024 (void *)&cmd_config_max_lro_pkt_size_port,
2025 (void *)&cmd_config_max_lro_pkt_size_keyword,
2026 (void *)&cmd_config_max_lro_pkt_size_all,
2027 (void *)&cmd_config_max_lro_pkt_size_name,
2028 (void *)&cmd_config_max_lro_pkt_size_value,
2033 /* *** configure port MTU *** */
2034 struct cmd_config_mtu_result {
2035 cmdline_fixed_string_t port;
2036 cmdline_fixed_string_t keyword;
2037 cmdline_fixed_string_t mtu;
2043 cmd_config_mtu_parsed(void *parsed_result,
2044 __rte_unused struct cmdline *cl,
2045 __rte_unused void *data)
2047 struct cmd_config_mtu_result *res = parsed_result;
2049 if (res->value < RTE_ETHER_MIN_LEN) {
2050 printf("mtu cannot be less than %d\n", RTE_ETHER_MIN_LEN);
2053 port_mtu_set(res->port_id, res->value);
2056 cmdline_parse_token_string_t cmd_config_mtu_port =
2057 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
2059 cmdline_parse_token_string_t cmd_config_mtu_keyword =
2060 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2062 cmdline_parse_token_string_t cmd_config_mtu_mtu =
2063 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2065 cmdline_parse_token_num_t cmd_config_mtu_port_id =
2066 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id,
2068 cmdline_parse_token_num_t cmd_config_mtu_value =
2069 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value,
2072 cmdline_parse_inst_t cmd_config_mtu = {
2073 .f = cmd_config_mtu_parsed,
2075 .help_str = "port config mtu <port_id> <value>",
2077 (void *)&cmd_config_mtu_port,
2078 (void *)&cmd_config_mtu_keyword,
2079 (void *)&cmd_config_mtu_mtu,
2080 (void *)&cmd_config_mtu_port_id,
2081 (void *)&cmd_config_mtu_value,
2086 /* *** configure rx mode *** */
2087 struct cmd_config_rx_mode_flag {
2088 cmdline_fixed_string_t port;
2089 cmdline_fixed_string_t keyword;
2090 cmdline_fixed_string_t all;
2091 cmdline_fixed_string_t name;
2092 cmdline_fixed_string_t value;
2096 cmd_config_rx_mode_flag_parsed(void *parsed_result,
2097 __rte_unused struct cmdline *cl,
2098 __rte_unused void *data)
2100 struct cmd_config_rx_mode_flag *res = parsed_result;
2102 if (!all_ports_stopped()) {
2103 printf("Please stop all ports first\n");
2107 if (!strcmp(res->name, "drop-en")) {
2108 if (!strcmp(res->value, "on"))
2110 else if (!strcmp(res->value, "off"))
2113 printf("Unknown parameter\n");
2117 printf("Unknown parameter\n");
2123 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2126 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
2127 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
2128 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
2129 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
2131 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2132 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2133 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2134 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2136 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2137 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2140 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2141 .f = cmd_config_rx_mode_flag_parsed,
2143 .help_str = "port config all drop-en on|off",
2145 (void *)&cmd_config_rx_mode_flag_port,
2146 (void *)&cmd_config_rx_mode_flag_keyword,
2147 (void *)&cmd_config_rx_mode_flag_all,
2148 (void *)&cmd_config_rx_mode_flag_name,
2149 (void *)&cmd_config_rx_mode_flag_value,
2154 /* *** configure rss *** */
2155 struct cmd_config_rss {
2156 cmdline_fixed_string_t port;
2157 cmdline_fixed_string_t keyword;
2158 cmdline_fixed_string_t all;
2159 cmdline_fixed_string_t name;
2160 cmdline_fixed_string_t value;
2164 cmd_config_rss_parsed(void *parsed_result,
2165 __rte_unused struct cmdline *cl,
2166 __rte_unused void *data)
2168 struct cmd_config_rss *res = parsed_result;
2169 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2170 struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2171 int use_default = 0;
2172 int all_updated = 1;
2177 if (!strcmp(res->value, "all"))
2178 rss_conf.rss_hf = ETH_RSS_ETH | ETH_RSS_VLAN | ETH_RSS_IP |
2179 ETH_RSS_TCP | ETH_RSS_UDP | ETH_RSS_SCTP |
2180 ETH_RSS_L2_PAYLOAD | ETH_RSS_L2TPV3 | ETH_RSS_ESP |
2181 ETH_RSS_AH | ETH_RSS_PFCP | ETH_RSS_GTPU |
2183 else if (!strcmp(res->value, "eth"))
2184 rss_conf.rss_hf = ETH_RSS_ETH;
2185 else if (!strcmp(res->value, "vlan"))
2186 rss_conf.rss_hf = ETH_RSS_VLAN;
2187 else if (!strcmp(res->value, "ip"))
2188 rss_conf.rss_hf = ETH_RSS_IP;
2189 else if (!strcmp(res->value, "udp"))
2190 rss_conf.rss_hf = ETH_RSS_UDP;
2191 else if (!strcmp(res->value, "tcp"))
2192 rss_conf.rss_hf = ETH_RSS_TCP;
2193 else if (!strcmp(res->value, "sctp"))
2194 rss_conf.rss_hf = ETH_RSS_SCTP;
2195 else if (!strcmp(res->value, "ether"))
2196 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
2197 else if (!strcmp(res->value, "port"))
2198 rss_conf.rss_hf = ETH_RSS_PORT;
2199 else if (!strcmp(res->value, "vxlan"))
2200 rss_conf.rss_hf = ETH_RSS_VXLAN;
2201 else if (!strcmp(res->value, "geneve"))
2202 rss_conf.rss_hf = ETH_RSS_GENEVE;
2203 else if (!strcmp(res->value, "nvgre"))
2204 rss_conf.rss_hf = ETH_RSS_NVGRE;
2205 else if (!strcmp(res->value, "l3-pre32"))
2206 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE32;
2207 else if (!strcmp(res->value, "l3-pre40"))
2208 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE40;
2209 else if (!strcmp(res->value, "l3-pre48"))
2210 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE48;
2211 else if (!strcmp(res->value, "l3-pre56"))
2212 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE56;
2213 else if (!strcmp(res->value, "l3-pre64"))
2214 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE64;
2215 else if (!strcmp(res->value, "l3-pre96"))
2216 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE96;
2217 else if (!strcmp(res->value, "l3-src-only"))
2218 rss_conf.rss_hf = ETH_RSS_L3_SRC_ONLY;
2219 else if (!strcmp(res->value, "l3-dst-only"))
2220 rss_conf.rss_hf = ETH_RSS_L3_DST_ONLY;
2221 else if (!strcmp(res->value, "l4-src-only"))
2222 rss_conf.rss_hf = ETH_RSS_L4_SRC_ONLY;
2223 else if (!strcmp(res->value, "l4-dst-only"))
2224 rss_conf.rss_hf = ETH_RSS_L4_DST_ONLY;
2225 else if (!strcmp(res->value, "l2-src-only"))
2226 rss_conf.rss_hf = ETH_RSS_L2_SRC_ONLY;
2227 else if (!strcmp(res->value, "l2-dst-only"))
2228 rss_conf.rss_hf = ETH_RSS_L2_DST_ONLY;
2229 else if (!strcmp(res->value, "l2tpv3"))
2230 rss_conf.rss_hf = ETH_RSS_L2TPV3;
2231 else if (!strcmp(res->value, "esp"))
2232 rss_conf.rss_hf = ETH_RSS_ESP;
2233 else if (!strcmp(res->value, "ah"))
2234 rss_conf.rss_hf = ETH_RSS_AH;
2235 else if (!strcmp(res->value, "pfcp"))
2236 rss_conf.rss_hf = ETH_RSS_PFCP;
2237 else if (!strcmp(res->value, "pppoe"))
2238 rss_conf.rss_hf = ETH_RSS_PPPOE;
2239 else if (!strcmp(res->value, "gtpu"))
2240 rss_conf.rss_hf = ETH_RSS_GTPU;
2241 else if (!strcmp(res->value, "ecpri"))
2242 rss_conf.rss_hf = ETH_RSS_ECPRI;
2243 else if (!strcmp(res->value, "mpls"))
2244 rss_conf.rss_hf = ETH_RSS_MPLS;
2245 else if (!strcmp(res->value, "none"))
2246 rss_conf.rss_hf = 0;
2247 else if (!strcmp(res->value, "level-default")) {
2248 rss_hf &= (~ETH_RSS_LEVEL_MASK);
2249 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_PMD_DEFAULT);
2250 } else if (!strcmp(res->value, "level-outer")) {
2251 rss_hf &= (~ETH_RSS_LEVEL_MASK);
2252 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_OUTERMOST);
2253 } else if (!strcmp(res->value, "level-inner")) {
2254 rss_hf &= (~ETH_RSS_LEVEL_MASK);
2255 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_INNERMOST);
2256 } else if (!strcmp(res->value, "default"))
2258 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2259 atoi(res->value) < 64)
2260 rss_conf.rss_hf = 1ULL << atoi(res->value);
2262 printf("Unknown parameter\n");
2265 rss_conf.rss_key = NULL;
2266 /* Update global configuration for RSS types. */
2267 RTE_ETH_FOREACH_DEV(i) {
2268 struct rte_eth_rss_conf local_rss_conf;
2270 ret = eth_dev_info_get_print_err(i, &dev_info);
2275 rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2277 local_rss_conf = rss_conf;
2278 local_rss_conf.rss_hf = rss_conf.rss_hf &
2279 dev_info.flow_type_rss_offloads;
2280 if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2281 printf("Port %u modified RSS hash function based on hardware support,"
2282 "requested:%#"PRIx64" configured:%#"PRIx64"\n",
2283 i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2285 diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2288 printf("Configuration of RSS hash at ethernet port %d "
2289 "failed with error (%d): %s.\n",
2290 i, -diag, strerror(-diag));
2293 if (all_updated && !use_default) {
2294 rss_hf = rss_conf.rss_hf;
2295 printf("rss_hf %#"PRIx64"\n", rss_hf);
2299 cmdline_parse_token_string_t cmd_config_rss_port =
2300 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2301 cmdline_parse_token_string_t cmd_config_rss_keyword =
2302 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2303 cmdline_parse_token_string_t cmd_config_rss_all =
2304 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2305 cmdline_parse_token_string_t cmd_config_rss_name =
2306 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2307 cmdline_parse_token_string_t cmd_config_rss_value =
2308 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2310 cmdline_parse_inst_t cmd_config_rss = {
2311 .f = cmd_config_rss_parsed,
2313 .help_str = "port config all rss "
2314 "all|default|eth|vlan|ip|tcp|udp|sctp|ether|port|vxlan|geneve|"
2315 "nvgre|vxlan-gpe|l2tpv3|esp|ah|pfcp|ecpri|mpls|none|level-default|"
2316 "level-outer|level-inner|<flowtype_id>",
2318 (void *)&cmd_config_rss_port,
2319 (void *)&cmd_config_rss_keyword,
2320 (void *)&cmd_config_rss_all,
2321 (void *)&cmd_config_rss_name,
2322 (void *)&cmd_config_rss_value,
2327 /* *** configure rss hash key *** */
2328 struct cmd_config_rss_hash_key {
2329 cmdline_fixed_string_t port;
2330 cmdline_fixed_string_t config;
2332 cmdline_fixed_string_t rss_hash_key;
2333 cmdline_fixed_string_t rss_type;
2334 cmdline_fixed_string_t key;
2338 hexa_digit_to_value(char hexa_digit)
2340 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2341 return (uint8_t) (hexa_digit - '0');
2342 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2343 return (uint8_t) ((hexa_digit - 'a') + 10);
2344 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2345 return (uint8_t) ((hexa_digit - 'A') + 10);
2346 /* Invalid hexa digit */
2351 parse_and_check_key_hexa_digit(char *key, int idx)
2355 hexa_v = hexa_digit_to_value(key[idx]);
2357 printf("invalid key: character %c at position %d is not a "
2358 "valid hexa digit\n", key[idx], idx);
2363 cmd_config_rss_hash_key_parsed(void *parsed_result,
2364 __rte_unused struct cmdline *cl,
2365 __rte_unused void *data)
2367 struct cmd_config_rss_hash_key *res = parsed_result;
2368 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2372 struct rte_eth_dev_info dev_info;
2373 uint8_t hash_key_size;
2377 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2381 if (dev_info.hash_key_size > 0 &&
2382 dev_info.hash_key_size <= sizeof(hash_key))
2383 hash_key_size = dev_info.hash_key_size;
2385 printf("dev_info did not provide a valid hash key size\n");
2388 /* Check the length of the RSS hash key */
2389 key_len = strlen(res->key);
2390 if (key_len != (hash_key_size * 2)) {
2391 printf("key length: %d invalid - key must be a string of %d"
2392 " hexa-decimal numbers\n",
2393 (int) key_len, hash_key_size * 2);
2396 /* Translate RSS hash key into binary representation */
2397 for (i = 0; i < hash_key_size; i++) {
2398 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2401 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2404 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2406 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2410 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2411 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2412 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2413 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2415 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2416 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id,
2418 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2419 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2420 rss_hash_key, "rss-hash-key");
2421 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2422 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2423 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2424 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2425 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2426 "ipv6-tcp-ex#ipv6-udp-ex#"
2427 "l3-src-only#l3-dst-only#l4-src-only#l4-dst-only#"
2428 "l2-src-only#l2-dst-only#s-vlan#c-vlan#"
2429 "l2tpv3#esp#ah#pfcp#pppoe#gtpu#ecpri#mpls");
2430 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2431 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2433 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2434 .f = cmd_config_rss_hash_key_parsed,
2436 .help_str = "port config <port_id> rss-hash-key "
2437 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2438 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2439 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|"
2440 "l3-src-only|l3-dst-only|l4-src-only|l4-dst-only|"
2441 "l2-src-only|l2-dst-only|s-vlan|c-vlan|"
2442 "l2tpv3|esp|ah|pfcp|pppoe|gtpu|ecpri|mpls "
2443 "<string of hex digits (variable length, NIC dependent)>",
2445 (void *)&cmd_config_rss_hash_key_port,
2446 (void *)&cmd_config_rss_hash_key_config,
2447 (void *)&cmd_config_rss_hash_key_port_id,
2448 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2449 (void *)&cmd_config_rss_hash_key_rss_type,
2450 (void *)&cmd_config_rss_hash_key_value,
2455 /* *** configure port rxq/txq ring size *** */
2456 struct cmd_config_rxtx_ring_size {
2457 cmdline_fixed_string_t port;
2458 cmdline_fixed_string_t config;
2460 cmdline_fixed_string_t rxtxq;
2462 cmdline_fixed_string_t rsize;
2467 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2468 __rte_unused struct cmdline *cl,
2469 __rte_unused void *data)
2471 struct cmd_config_rxtx_ring_size *res = parsed_result;
2472 struct rte_port *port;
2475 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2478 if (res->portid == (portid_t)RTE_PORT_ALL) {
2479 printf("Invalid port id\n");
2483 port = &ports[res->portid];
2485 if (!strcmp(res->rxtxq, "rxq"))
2487 else if (!strcmp(res->rxtxq, "txq"))
2490 printf("Unknown parameter\n");
2494 if (isrx && rx_queue_id_is_invalid(res->qid))
2496 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2499 if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2500 printf("Invalid rx ring_size, must > rx_free_thresh: %d\n",
2506 port->nb_rx_desc[res->qid] = res->size;
2508 port->nb_tx_desc[res->qid] = res->size;
2510 cmd_reconfig_device_queue(res->portid, 0, 1);
2513 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2514 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2516 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2517 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2519 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2520 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2521 portid, RTE_UINT16);
2522 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2523 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2525 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2526 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2528 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2529 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2530 rsize, "ring_size");
2531 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2532 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2535 cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2536 .f = cmd_config_rxtx_ring_size_parsed,
2538 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2540 (void *)&cmd_config_rxtx_ring_size_port,
2541 (void *)&cmd_config_rxtx_ring_size_config,
2542 (void *)&cmd_config_rxtx_ring_size_portid,
2543 (void *)&cmd_config_rxtx_ring_size_rxtxq,
2544 (void *)&cmd_config_rxtx_ring_size_qid,
2545 (void *)&cmd_config_rxtx_ring_size_rsize,
2546 (void *)&cmd_config_rxtx_ring_size_size,
2551 /* *** configure port rxq/txq start/stop *** */
2552 struct cmd_config_rxtx_queue {
2553 cmdline_fixed_string_t port;
2555 cmdline_fixed_string_t rxtxq;
2557 cmdline_fixed_string_t opname;
2561 cmd_config_rxtx_queue_parsed(void *parsed_result,
2562 __rte_unused struct cmdline *cl,
2563 __rte_unused void *data)
2565 struct cmd_config_rxtx_queue *res = parsed_result;
2570 if (test_done == 0) {
2571 printf("Please stop forwarding first\n");
2575 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2578 if (port_is_started(res->portid) != 1) {
2579 printf("Please start port %u first\n", res->portid);
2583 if (!strcmp(res->rxtxq, "rxq"))
2585 else if (!strcmp(res->rxtxq, "txq"))
2588 printf("Unknown parameter\n");
2592 if (isrx && rx_queue_id_is_invalid(res->qid))
2594 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2597 if (!strcmp(res->opname, "start"))
2599 else if (!strcmp(res->opname, "stop"))
2602 printf("Unknown parameter\n");
2606 if (isstart && isrx)
2607 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2608 else if (!isstart && isrx)
2609 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2610 else if (isstart && !isrx)
2611 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2613 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2615 if (ret == -ENOTSUP)
2616 printf("Function not supported in PMD driver\n");
2619 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2620 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2621 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2622 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, RTE_UINT16);
2623 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2624 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2625 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2626 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, RTE_UINT16);
2627 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2628 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2631 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2632 .f = cmd_config_rxtx_queue_parsed,
2634 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2636 (void *)&cmd_config_rxtx_queue_port,
2637 (void *)&cmd_config_rxtx_queue_portid,
2638 (void *)&cmd_config_rxtx_queue_rxtxq,
2639 (void *)&cmd_config_rxtx_queue_qid,
2640 (void *)&cmd_config_rxtx_queue_opname,
2645 /* *** configure port rxq/txq deferred start on/off *** */
2646 struct cmd_config_deferred_start_rxtx_queue {
2647 cmdline_fixed_string_t port;
2649 cmdline_fixed_string_t rxtxq;
2651 cmdline_fixed_string_t opname;
2652 cmdline_fixed_string_t state;
2656 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2657 __rte_unused struct cmdline *cl,
2658 __rte_unused void *data)
2660 struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2661 struct rte_port *port;
2664 uint8_t needreconfig = 0;
2666 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2669 if (port_is_started(res->port_id) != 0) {
2670 printf("Please stop port %u first\n", res->port_id);
2674 port = &ports[res->port_id];
2676 isrx = !strcmp(res->rxtxq, "rxq");
2678 if (isrx && rx_queue_id_is_invalid(res->qid))
2680 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2683 ison = !strcmp(res->state, "on");
2685 if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) {
2686 port->rx_conf[res->qid].rx_deferred_start = ison;
2688 } else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) {
2689 port->tx_conf[res->qid].tx_deferred_start = ison;
2694 cmd_reconfig_device_queue(res->port_id, 0, 1);
2697 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2698 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2700 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2701 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2702 port_id, RTE_UINT16);
2703 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2704 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2706 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2707 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2709 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2710 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2711 opname, "deferred_start");
2712 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2713 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2716 cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
2717 .f = cmd_config_deferred_start_rxtx_queue_parsed,
2719 .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
2721 (void *)&cmd_config_deferred_start_rxtx_queue_port,
2722 (void *)&cmd_config_deferred_start_rxtx_queue_port_id,
2723 (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
2724 (void *)&cmd_config_deferred_start_rxtx_queue_qid,
2725 (void *)&cmd_config_deferred_start_rxtx_queue_opname,
2726 (void *)&cmd_config_deferred_start_rxtx_queue_state,
2731 /* *** configure port rxq/txq setup *** */
2732 struct cmd_setup_rxtx_queue {
2733 cmdline_fixed_string_t port;
2735 cmdline_fixed_string_t rxtxq;
2737 cmdline_fixed_string_t setup;
2740 /* Common CLI fields for queue setup */
2741 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2742 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2743 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2744 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, RTE_UINT16);
2745 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2746 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2747 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2748 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, RTE_UINT16);
2749 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2750 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2753 cmd_setup_rxtx_queue_parsed(
2754 void *parsed_result,
2755 __rte_unused struct cmdline *cl,
2756 __rte_unused void *data)
2758 struct cmd_setup_rxtx_queue *res = parsed_result;
2759 struct rte_port *port;
2760 struct rte_mempool *mp;
2761 unsigned int socket_id;
2765 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2768 if (res->portid == (portid_t)RTE_PORT_ALL) {
2769 printf("Invalid port id\n");
2773 if (!strcmp(res->rxtxq, "rxq"))
2775 else if (!strcmp(res->rxtxq, "txq"))
2778 printf("Unknown parameter\n");
2782 if (isrx && rx_queue_id_is_invalid(res->qid)) {
2783 printf("Invalid rx queue\n");
2785 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2786 printf("Invalid tx queue\n");
2790 port = &ports[res->portid];
2792 socket_id = rxring_numa[res->portid];
2793 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2794 socket_id = port->socket_id;
2796 mp = mbuf_pool_find(socket_id, 0);
2798 printf("Failed to setup RX queue: "
2799 "No mempool allocation"
2800 " on the socket %d\n",
2801 rxring_numa[res->portid]);
2804 ret = rx_queue_setup(res->portid,
2806 port->nb_rx_desc[res->qid],
2808 &port->rx_conf[res->qid],
2811 printf("Failed to setup RX queue\n");
2813 socket_id = txring_numa[res->portid];
2814 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2815 socket_id = port->socket_id;
2817 ret = rte_eth_tx_queue_setup(res->portid,
2819 port->nb_tx_desc[res->qid],
2821 &port->tx_conf[res->qid]);
2823 printf("Failed to setup TX queue\n");
2827 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2828 .f = cmd_setup_rxtx_queue_parsed,
2830 .help_str = "port <port_id> rxq|txq <queue_idx> setup",
2832 (void *)&cmd_setup_rxtx_queue_port,
2833 (void *)&cmd_setup_rxtx_queue_portid,
2834 (void *)&cmd_setup_rxtx_queue_rxtxq,
2835 (void *)&cmd_setup_rxtx_queue_qid,
2836 (void *)&cmd_setup_rxtx_queue_setup,
2842 /* *** Configure RSS RETA *** */
2843 struct cmd_config_rss_reta {
2844 cmdline_fixed_string_t port;
2845 cmdline_fixed_string_t keyword;
2847 cmdline_fixed_string_t name;
2848 cmdline_fixed_string_t list_name;
2849 cmdline_fixed_string_t list_of_items;
2853 parse_reta_config(const char *str,
2854 struct rte_eth_rss_reta_entry64 *reta_conf,
2855 uint16_t nb_entries)
2859 uint16_t hash_index, idx, shift;
2862 const char *p, *p0 = str;
2869 unsigned long int_fld[_NUM_FLD];
2870 char *str_fld[_NUM_FLD];
2872 while ((p = strchr(p0,'(')) != NULL) {
2874 if((p0 = strchr(p,')')) == NULL)
2878 if(size >= sizeof(s))
2881 snprintf(s, sizeof(s), "%.*s", size, p);
2882 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2884 for (i = 0; i < _NUM_FLD; i++) {
2886 int_fld[i] = strtoul(str_fld[i], &end, 0);
2887 if (errno != 0 || end == str_fld[i] ||
2892 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2893 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2895 if (hash_index >= nb_entries) {
2896 printf("Invalid RETA hash index=%d\n", hash_index);
2900 idx = hash_index / RTE_RETA_GROUP_SIZE;
2901 shift = hash_index % RTE_RETA_GROUP_SIZE;
2902 reta_conf[idx].mask |= (1ULL << shift);
2903 reta_conf[idx].reta[shift] = nb_queue;
2910 cmd_set_rss_reta_parsed(void *parsed_result,
2911 __rte_unused struct cmdline *cl,
2912 __rte_unused void *data)
2915 struct rte_eth_dev_info dev_info;
2916 struct rte_eth_rss_reta_entry64 reta_conf[8];
2917 struct cmd_config_rss_reta *res = parsed_result;
2919 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2923 if (dev_info.reta_size == 0) {
2924 printf("Redirection table size is 0 which is "
2925 "invalid for RSS\n");
2928 printf("The reta size of port %d is %u\n",
2929 res->port_id, dev_info.reta_size);
2930 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2931 printf("Currently do not support more than %u entries of "
2932 "redirection table\n", ETH_RSS_RETA_SIZE_512);
2936 memset(reta_conf, 0, sizeof(reta_conf));
2937 if (!strcmp(res->list_name, "reta")) {
2938 if (parse_reta_config(res->list_of_items, reta_conf,
2939 dev_info.reta_size)) {
2940 printf("Invalid RSS Redirection Table "
2941 "config entered\n");
2944 ret = rte_eth_dev_rss_reta_update(res->port_id,
2945 reta_conf, dev_info.reta_size);
2947 printf("Bad redirection table parameter, "
2948 "return code = %d \n", ret);
2952 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2953 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2954 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2955 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2956 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2957 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, RTE_UINT16);
2958 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2959 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2960 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2961 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2962 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2963 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2965 cmdline_parse_inst_t cmd_config_rss_reta = {
2966 .f = cmd_set_rss_reta_parsed,
2968 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2970 (void *)&cmd_config_rss_reta_port,
2971 (void *)&cmd_config_rss_reta_keyword,
2972 (void *)&cmd_config_rss_reta_port_id,
2973 (void *)&cmd_config_rss_reta_name,
2974 (void *)&cmd_config_rss_reta_list_name,
2975 (void *)&cmd_config_rss_reta_list_of_items,
2980 /* *** SHOW PORT RETA INFO *** */
2981 struct cmd_showport_reta {
2982 cmdline_fixed_string_t show;
2983 cmdline_fixed_string_t port;
2985 cmdline_fixed_string_t rss;
2986 cmdline_fixed_string_t reta;
2988 cmdline_fixed_string_t list_of_items;
2992 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2993 uint16_t nb_entries,
2997 const char *p, *p0 = str;
3002 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
3003 RTE_RETA_GROUP_SIZE;
3006 p = strchr(p0, '(');
3010 p0 = strchr(p, ')');
3014 if (size >= sizeof(s)) {
3015 printf("The string size exceeds the internal buffer size\n");
3018 snprintf(s, sizeof(s), "%.*s", size, p);
3019 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
3020 if (ret <= 0 || ret != num) {
3021 printf("The bits of masks do not match the number of "
3022 "reta entries: %u\n", num);
3025 for (i = 0; i < ret; i++)
3026 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
3032 cmd_showport_reta_parsed(void *parsed_result,
3033 __rte_unused struct cmdline *cl,
3034 __rte_unused void *data)
3036 struct cmd_showport_reta *res = parsed_result;
3037 struct rte_eth_rss_reta_entry64 reta_conf[8];
3038 struct rte_eth_dev_info dev_info;
3039 uint16_t max_reta_size;
3042 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3046 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
3047 if (res->size == 0 || res->size > max_reta_size) {
3048 printf("Invalid redirection table size: %u (1-%u)\n",
3049 res->size, max_reta_size);
3053 memset(reta_conf, 0, sizeof(reta_conf));
3054 if (showport_parse_reta_config(reta_conf, res->size,
3055 res->list_of_items) < 0) {
3056 printf("Invalid string: %s for reta masks\n",
3057 res->list_of_items);
3060 port_rss_reta_info(res->port_id, reta_conf, res->size);
3063 cmdline_parse_token_string_t cmd_showport_reta_show =
3064 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
3065 cmdline_parse_token_string_t cmd_showport_reta_port =
3066 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
3067 cmdline_parse_token_num_t cmd_showport_reta_port_id =
3068 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, RTE_UINT16);
3069 cmdline_parse_token_string_t cmd_showport_reta_rss =
3070 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
3071 cmdline_parse_token_string_t cmd_showport_reta_reta =
3072 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
3073 cmdline_parse_token_num_t cmd_showport_reta_size =
3074 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, RTE_UINT16);
3075 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
3076 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
3077 list_of_items, NULL);
3079 cmdline_parse_inst_t cmd_showport_reta = {
3080 .f = cmd_showport_reta_parsed,
3082 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
3084 (void *)&cmd_showport_reta_show,
3085 (void *)&cmd_showport_reta_port,
3086 (void *)&cmd_showport_reta_port_id,
3087 (void *)&cmd_showport_reta_rss,
3088 (void *)&cmd_showport_reta_reta,
3089 (void *)&cmd_showport_reta_size,
3090 (void *)&cmd_showport_reta_list_of_items,
3095 /* *** Show RSS hash configuration *** */
3096 struct cmd_showport_rss_hash {
3097 cmdline_fixed_string_t show;
3098 cmdline_fixed_string_t port;
3100 cmdline_fixed_string_t rss_hash;
3101 cmdline_fixed_string_t rss_type;
3102 cmdline_fixed_string_t key; /* optional argument */
3105 static void cmd_showport_rss_hash_parsed(void *parsed_result,
3106 __rte_unused struct cmdline *cl,
3109 struct cmd_showport_rss_hash *res = parsed_result;
3111 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
3114 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
3115 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
3116 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
3117 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
3118 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
3119 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id,
3121 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
3122 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
3124 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
3125 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
3127 cmdline_parse_inst_t cmd_showport_rss_hash = {
3128 .f = cmd_showport_rss_hash_parsed,
3130 .help_str = "show port <port_id> rss-hash",
3132 (void *)&cmd_showport_rss_hash_show,
3133 (void *)&cmd_showport_rss_hash_port,
3134 (void *)&cmd_showport_rss_hash_port_id,
3135 (void *)&cmd_showport_rss_hash_rss_hash,
3140 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
3141 .f = cmd_showport_rss_hash_parsed,
3143 .help_str = "show port <port_id> rss-hash key",
3145 (void *)&cmd_showport_rss_hash_show,
3146 (void *)&cmd_showport_rss_hash_port,
3147 (void *)&cmd_showport_rss_hash_port_id,
3148 (void *)&cmd_showport_rss_hash_rss_hash,
3149 (void *)&cmd_showport_rss_hash_rss_key,
3154 /* *** Configure DCB *** */
3155 struct cmd_config_dcb {
3156 cmdline_fixed_string_t port;
3157 cmdline_fixed_string_t config;
3159 cmdline_fixed_string_t dcb;
3160 cmdline_fixed_string_t vt;
3161 cmdline_fixed_string_t vt_en;
3163 cmdline_fixed_string_t pfc;
3164 cmdline_fixed_string_t pfc_en;
3168 cmd_config_dcb_parsed(void *parsed_result,
3169 __rte_unused struct cmdline *cl,
3170 __rte_unused void *data)
3172 struct cmd_config_dcb *res = parsed_result;
3173 portid_t port_id = res->port_id;
3174 struct rte_port *port;
3178 port = &ports[port_id];
3179 /** Check if the port is not started **/
3180 if (port->port_status != RTE_PORT_STOPPED) {
3181 printf("Please stop port %d first\n", port_id);
3185 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
3186 printf("The invalid number of traffic class,"
3187 " only 4 or 8 allowed.\n");
3191 if (nb_fwd_lcores < res->num_tcs) {
3192 printf("nb_cores shouldn't be less than number of TCs.\n");
3195 if (!strncmp(res->pfc_en, "on", 2))
3200 /* DCB in VT mode */
3201 if (!strncmp(res->vt_en, "on", 2))
3202 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3203 (enum rte_eth_nb_tcs)res->num_tcs,
3206 ret = init_port_dcb_config(port_id, DCB_ENABLED,
3207 (enum rte_eth_nb_tcs)res->num_tcs,
3212 printf("Cannot initialize network ports.\n");
3216 cmd_reconfig_device_queue(port_id, 1, 1);
3219 cmdline_parse_token_string_t cmd_config_dcb_port =
3220 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3221 cmdline_parse_token_string_t cmd_config_dcb_config =
3222 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3223 cmdline_parse_token_num_t cmd_config_dcb_port_id =
3224 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, RTE_UINT16);
3225 cmdline_parse_token_string_t cmd_config_dcb_dcb =
3226 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3227 cmdline_parse_token_string_t cmd_config_dcb_vt =
3228 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3229 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3230 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3231 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3232 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, RTE_UINT8);
3233 cmdline_parse_token_string_t cmd_config_dcb_pfc=
3234 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3235 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
3236 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
3238 cmdline_parse_inst_t cmd_config_dcb = {
3239 .f = cmd_config_dcb_parsed,
3241 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
3243 (void *)&cmd_config_dcb_port,
3244 (void *)&cmd_config_dcb_config,
3245 (void *)&cmd_config_dcb_port_id,
3246 (void *)&cmd_config_dcb_dcb,
3247 (void *)&cmd_config_dcb_vt,
3248 (void *)&cmd_config_dcb_vt_en,
3249 (void *)&cmd_config_dcb_num_tcs,
3250 (void *)&cmd_config_dcb_pfc,
3251 (void *)&cmd_config_dcb_pfc_en,
3256 /* *** configure number of packets per burst *** */
3257 struct cmd_config_burst {
3258 cmdline_fixed_string_t port;
3259 cmdline_fixed_string_t keyword;
3260 cmdline_fixed_string_t all;
3261 cmdline_fixed_string_t name;
3266 cmd_config_burst_parsed(void *parsed_result,
3267 __rte_unused struct cmdline *cl,
3268 __rte_unused void *data)
3270 struct cmd_config_burst *res = parsed_result;
3271 struct rte_eth_dev_info dev_info;
3272 uint16_t rec_nb_pkts;
3275 if (!all_ports_stopped()) {
3276 printf("Please stop all ports first\n");
3280 if (!strcmp(res->name, "burst")) {
3281 if (res->value == 0) {
3282 /* If user gives a value of zero, query the PMD for
3283 * its recommended Rx burst size. Testpmd uses a single
3284 * size for all ports, so assume all ports are the same
3285 * NIC model and use the values from Port 0.
3287 ret = eth_dev_info_get_print_err(0, &dev_info);
3291 rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3293 if (rec_nb_pkts == 0) {
3294 printf("PMD does not recommend a burst size.\n"
3295 "User provided value must be between"
3296 " 1 and %d\n", MAX_PKT_BURST);
3298 } else if (rec_nb_pkts > MAX_PKT_BURST) {
3299 printf("PMD recommended burst size of %d"
3300 " exceeds maximum value of %d\n",
3301 rec_nb_pkts, MAX_PKT_BURST);
3304 printf("Using PMD-provided burst value of %d\n",
3306 nb_pkt_per_burst = rec_nb_pkts;
3307 } else if (res->value > MAX_PKT_BURST) {
3308 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
3311 nb_pkt_per_burst = res->value;
3313 printf("Unknown parameter\n");
3319 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3322 cmdline_parse_token_string_t cmd_config_burst_port =
3323 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3324 cmdline_parse_token_string_t cmd_config_burst_keyword =
3325 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3326 cmdline_parse_token_string_t cmd_config_burst_all =
3327 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3328 cmdline_parse_token_string_t cmd_config_burst_name =
3329 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3330 cmdline_parse_token_num_t cmd_config_burst_value =
3331 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, RTE_UINT16);
3333 cmdline_parse_inst_t cmd_config_burst = {
3334 .f = cmd_config_burst_parsed,
3336 .help_str = "port config all burst <value>",
3338 (void *)&cmd_config_burst_port,
3339 (void *)&cmd_config_burst_keyword,
3340 (void *)&cmd_config_burst_all,
3341 (void *)&cmd_config_burst_name,
3342 (void *)&cmd_config_burst_value,
3347 /* *** configure rx/tx queues *** */
3348 struct cmd_config_thresh {
3349 cmdline_fixed_string_t port;
3350 cmdline_fixed_string_t keyword;
3351 cmdline_fixed_string_t all;
3352 cmdline_fixed_string_t name;
3357 cmd_config_thresh_parsed(void *parsed_result,
3358 __rte_unused struct cmdline *cl,
3359 __rte_unused void *data)
3361 struct cmd_config_thresh *res = parsed_result;
3363 if (!all_ports_stopped()) {
3364 printf("Please stop all ports first\n");
3368 if (!strcmp(res->name, "txpt"))
3369 tx_pthresh = res->value;
3370 else if(!strcmp(res->name, "txht"))
3371 tx_hthresh = res->value;
3372 else if(!strcmp(res->name, "txwt"))
3373 tx_wthresh = res->value;
3374 else if(!strcmp(res->name, "rxpt"))
3375 rx_pthresh = res->value;
3376 else if(!strcmp(res->name, "rxht"))
3377 rx_hthresh = res->value;
3378 else if(!strcmp(res->name, "rxwt"))
3379 rx_wthresh = res->value;
3381 printf("Unknown parameter\n");
3387 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3390 cmdline_parse_token_string_t cmd_config_thresh_port =
3391 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3392 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3393 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3394 cmdline_parse_token_string_t cmd_config_thresh_all =
3395 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3396 cmdline_parse_token_string_t cmd_config_thresh_name =
3397 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3398 "txpt#txht#txwt#rxpt#rxht#rxwt");
3399 cmdline_parse_token_num_t cmd_config_thresh_value =
3400 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, RTE_UINT8);
3402 cmdline_parse_inst_t cmd_config_thresh = {
3403 .f = cmd_config_thresh_parsed,
3405 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3407 (void *)&cmd_config_thresh_port,
3408 (void *)&cmd_config_thresh_keyword,
3409 (void *)&cmd_config_thresh_all,
3410 (void *)&cmd_config_thresh_name,
3411 (void *)&cmd_config_thresh_value,
3416 /* *** configure free/rs threshold *** */
3417 struct cmd_config_threshold {
3418 cmdline_fixed_string_t port;
3419 cmdline_fixed_string_t keyword;
3420 cmdline_fixed_string_t all;
3421 cmdline_fixed_string_t name;
3426 cmd_config_threshold_parsed(void *parsed_result,
3427 __rte_unused struct cmdline *cl,
3428 __rte_unused void *data)
3430 struct cmd_config_threshold *res = parsed_result;
3432 if (!all_ports_stopped()) {
3433 printf("Please stop all ports first\n");
3437 if (!strcmp(res->name, "txfreet"))
3438 tx_free_thresh = res->value;
3439 else if (!strcmp(res->name, "txrst"))
3440 tx_rs_thresh = res->value;
3441 else if (!strcmp(res->name, "rxfreet"))
3442 rx_free_thresh = res->value;
3444 printf("Unknown parameter\n");
3450 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3453 cmdline_parse_token_string_t cmd_config_threshold_port =
3454 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3455 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3456 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3458 cmdline_parse_token_string_t cmd_config_threshold_all =
3459 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3460 cmdline_parse_token_string_t cmd_config_threshold_name =
3461 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3462 "txfreet#txrst#rxfreet");
3463 cmdline_parse_token_num_t cmd_config_threshold_value =
3464 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, RTE_UINT16);
3466 cmdline_parse_inst_t cmd_config_threshold = {
3467 .f = cmd_config_threshold_parsed,
3469 .help_str = "port config all txfreet|txrst|rxfreet <value>",
3471 (void *)&cmd_config_threshold_port,
3472 (void *)&cmd_config_threshold_keyword,
3473 (void *)&cmd_config_threshold_all,
3474 (void *)&cmd_config_threshold_name,
3475 (void *)&cmd_config_threshold_value,
3481 struct cmd_stop_result {
3482 cmdline_fixed_string_t stop;
3485 static void cmd_stop_parsed(__rte_unused void *parsed_result,
3486 __rte_unused struct cmdline *cl,
3487 __rte_unused void *data)
3489 stop_packet_forwarding();
3492 cmdline_parse_token_string_t cmd_stop_stop =
3493 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3495 cmdline_parse_inst_t cmd_stop = {
3496 .f = cmd_stop_parsed,
3498 .help_str = "stop: Stop packet forwarding",
3500 (void *)&cmd_stop_stop,
3505 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3508 parse_item_list(char* str, const char* item_name, unsigned int max_items,
3509 unsigned int *parsed_items, int check_unique_values)
3511 unsigned int nb_item;
3519 * First parse all items in the list and store their value.
3524 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3526 if ((c >= '0') && (c <= '9')) {
3527 value = (unsigned int) (value * 10 + (c - '0'));
3532 printf("character %c is not a decimal digit\n", c);
3536 printf("No valid value before comma\n");
3539 if (nb_item < max_items) {
3540 parsed_items[nb_item] = value;
3546 if (nb_item >= max_items) {
3547 printf("Number of %s = %u > %u (maximum items)\n",
3548 item_name, nb_item + 1, max_items);
3551 parsed_items[nb_item++] = value;
3552 if (! check_unique_values)
3556 * Then, check that all values in the list are differents.
3557 * No optimization here...
3559 for (i = 0; i < nb_item; i++) {
3560 for (j = i + 1; j < nb_item; j++) {
3561 if (parsed_items[j] == parsed_items[i]) {
3562 printf("duplicated %s %u at index %u and %u\n",
3563 item_name, parsed_items[i], i, j);
3571 struct cmd_set_list_result {
3572 cmdline_fixed_string_t cmd_keyword;
3573 cmdline_fixed_string_t list_name;
3574 cmdline_fixed_string_t list_of_items;
3577 static void cmd_set_list_parsed(void *parsed_result,
3578 __rte_unused struct cmdline *cl,
3579 __rte_unused void *data)
3581 struct cmd_set_list_result *res;
3583 unsigned int lcorelist[RTE_MAX_LCORE];
3584 unsigned int portlist[RTE_MAX_ETHPORTS];
3586 unsigned int nb_item;
3588 if (test_done == 0) {
3589 printf("Please stop forwarding first\n");
3593 res = parsed_result;
3594 if (!strcmp(res->list_name, "corelist")) {
3595 nb_item = parse_item_list(res->list_of_items, "core",
3597 parsed_items.lcorelist, 1);
3599 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3604 if (!strcmp(res->list_name, "portlist")) {
3605 nb_item = parse_item_list(res->list_of_items, "port",
3607 parsed_items.portlist, 1);
3609 set_fwd_ports_list(parsed_items.portlist, nb_item);
3615 cmdline_parse_token_string_t cmd_set_list_keyword =
3616 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3618 cmdline_parse_token_string_t cmd_set_list_name =
3619 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3620 "corelist#portlist");
3621 cmdline_parse_token_string_t cmd_set_list_of_items =
3622 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3625 cmdline_parse_inst_t cmd_set_fwd_list = {
3626 .f = cmd_set_list_parsed,
3628 .help_str = "set corelist|portlist <list0[,list1]*>",
3630 (void *)&cmd_set_list_keyword,
3631 (void *)&cmd_set_list_name,
3632 (void *)&cmd_set_list_of_items,
3637 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3639 struct cmd_setmask_result {
3640 cmdline_fixed_string_t set;
3641 cmdline_fixed_string_t mask;
3645 static void cmd_set_mask_parsed(void *parsed_result,
3646 __rte_unused struct cmdline *cl,
3647 __rte_unused void *data)
3649 struct cmd_setmask_result *res = parsed_result;
3651 if (test_done == 0) {
3652 printf("Please stop forwarding first\n");
3655 if (!strcmp(res->mask, "coremask")) {
3656 set_fwd_lcores_mask(res->hexavalue);
3658 } else if (!strcmp(res->mask, "portmask")) {
3659 set_fwd_ports_mask(res->hexavalue);
3664 cmdline_parse_token_string_t cmd_setmask_set =
3665 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3666 cmdline_parse_token_string_t cmd_setmask_mask =
3667 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3668 "coremask#portmask");
3669 cmdline_parse_token_num_t cmd_setmask_value =
3670 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, RTE_UINT64);
3672 cmdline_parse_inst_t cmd_set_fwd_mask = {
3673 .f = cmd_set_mask_parsed,
3675 .help_str = "set coremask|portmask <hexadecimal value>",
3677 (void *)&cmd_setmask_set,
3678 (void *)&cmd_setmask_mask,
3679 (void *)&cmd_setmask_value,
3685 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3687 struct cmd_set_result {
3688 cmdline_fixed_string_t set;
3689 cmdline_fixed_string_t what;
3693 static void cmd_set_parsed(void *parsed_result,
3694 __rte_unused struct cmdline *cl,
3695 __rte_unused void *data)
3697 struct cmd_set_result *res = parsed_result;
3698 if (!strcmp(res->what, "nbport")) {
3699 set_fwd_ports_number(res->value);
3701 } else if (!strcmp(res->what, "nbcore")) {
3702 set_fwd_lcores_number(res->value);
3704 } else if (!strcmp(res->what, "burst"))
3705 set_nb_pkt_per_burst(res->value);
3706 else if (!strcmp(res->what, "verbose"))
3707 set_verbose_level(res->value);
3710 cmdline_parse_token_string_t cmd_set_set =
3711 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3712 cmdline_parse_token_string_t cmd_set_what =
3713 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3714 "nbport#nbcore#burst#verbose");
3715 cmdline_parse_token_num_t cmd_set_value =
3716 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, RTE_UINT16);
3718 cmdline_parse_inst_t cmd_set_numbers = {
3719 .f = cmd_set_parsed,
3721 .help_str = "set nbport|nbcore|burst|verbose <value>",
3723 (void *)&cmd_set_set,
3724 (void *)&cmd_set_what,
3725 (void *)&cmd_set_value,
3730 /* *** SET LOG LEVEL CONFIGURATION *** */
3732 struct cmd_set_log_result {
3733 cmdline_fixed_string_t set;
3734 cmdline_fixed_string_t log;
3735 cmdline_fixed_string_t type;
3740 cmd_set_log_parsed(void *parsed_result,
3741 __rte_unused struct cmdline *cl,
3742 __rte_unused void *data)
3744 struct cmd_set_log_result *res;
3747 res = parsed_result;
3748 if (!strcmp(res->type, "global"))
3749 rte_log_set_global_level(res->level);
3751 ret = rte_log_set_level_regexp(res->type, res->level);
3753 printf("Unable to set log level\n");
3757 cmdline_parse_token_string_t cmd_set_log_set =
3758 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3759 cmdline_parse_token_string_t cmd_set_log_log =
3760 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3761 cmdline_parse_token_string_t cmd_set_log_type =
3762 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3763 cmdline_parse_token_num_t cmd_set_log_level =
3764 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, RTE_UINT32);
3766 cmdline_parse_inst_t cmd_set_log = {
3767 .f = cmd_set_log_parsed,
3769 .help_str = "set log global|<type> <level>",
3771 (void *)&cmd_set_log_set,
3772 (void *)&cmd_set_log_log,
3773 (void *)&cmd_set_log_type,
3774 (void *)&cmd_set_log_level,
3779 /* *** SET SEGMENT OFFSETS OF RX PACKETS SPLIT *** */
3781 struct cmd_set_rxoffs_result {
3782 cmdline_fixed_string_t cmd_keyword;
3783 cmdline_fixed_string_t rxoffs;
3784 cmdline_fixed_string_t seg_offsets;
3788 cmd_set_rxoffs_parsed(void *parsed_result,
3789 __rte_unused struct cmdline *cl,
3790 __rte_unused void *data)
3792 struct cmd_set_rxoffs_result *res;
3793 unsigned int seg_offsets[MAX_SEGS_BUFFER_SPLIT];
3794 unsigned int nb_segs;
3796 res = parsed_result;
3797 nb_segs = parse_item_list(res->seg_offsets, "segment offsets",
3798 MAX_SEGS_BUFFER_SPLIT, seg_offsets, 0);
3800 set_rx_pkt_offsets(seg_offsets, nb_segs);
3801 cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
3804 cmdline_parse_token_string_t cmd_set_rxoffs_keyword =
3805 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3806 cmd_keyword, "set");
3807 cmdline_parse_token_string_t cmd_set_rxoffs_name =
3808 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3810 cmdline_parse_token_string_t cmd_set_rxoffs_offsets =
3811 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3814 cmdline_parse_inst_t cmd_set_rxoffs = {
3815 .f = cmd_set_rxoffs_parsed,
3817 .help_str = "set rxoffs <len0[,len1]*>",
3819 (void *)&cmd_set_rxoffs_keyword,
3820 (void *)&cmd_set_rxoffs_name,
3821 (void *)&cmd_set_rxoffs_offsets,
3826 /* *** SET SEGMENT LENGTHS OF RX PACKETS SPLIT *** */
3828 struct cmd_set_rxpkts_result {
3829 cmdline_fixed_string_t cmd_keyword;
3830 cmdline_fixed_string_t rxpkts;
3831 cmdline_fixed_string_t seg_lengths;
3835 cmd_set_rxpkts_parsed(void *parsed_result,
3836 __rte_unused struct cmdline *cl,
3837 __rte_unused void *data)
3839 struct cmd_set_rxpkts_result *res;
3840 unsigned int seg_lengths[MAX_SEGS_BUFFER_SPLIT];
3841 unsigned int nb_segs;
3843 res = parsed_result;
3844 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3845 MAX_SEGS_BUFFER_SPLIT, seg_lengths, 0);
3847 set_rx_pkt_segments(seg_lengths, nb_segs);
3848 cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
3851 cmdline_parse_token_string_t cmd_set_rxpkts_keyword =
3852 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3853 cmd_keyword, "set");
3854 cmdline_parse_token_string_t cmd_set_rxpkts_name =
3855 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3857 cmdline_parse_token_string_t cmd_set_rxpkts_lengths =
3858 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3861 cmdline_parse_inst_t cmd_set_rxpkts = {
3862 .f = cmd_set_rxpkts_parsed,
3864 .help_str = "set rxpkts <len0[,len1]*>",
3866 (void *)&cmd_set_rxpkts_keyword,
3867 (void *)&cmd_set_rxpkts_name,
3868 (void *)&cmd_set_rxpkts_lengths,
3873 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3875 struct cmd_set_txpkts_result {
3876 cmdline_fixed_string_t cmd_keyword;
3877 cmdline_fixed_string_t txpkts;
3878 cmdline_fixed_string_t seg_lengths;
3882 cmd_set_txpkts_parsed(void *parsed_result,
3883 __rte_unused struct cmdline *cl,
3884 __rte_unused void *data)
3886 struct cmd_set_txpkts_result *res;
3887 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3888 unsigned int nb_segs;
3890 res = parsed_result;
3891 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3892 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3894 set_tx_pkt_segments(seg_lengths, nb_segs);
3897 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3898 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3899 cmd_keyword, "set");
3900 cmdline_parse_token_string_t cmd_set_txpkts_name =
3901 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3903 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3904 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3907 cmdline_parse_inst_t cmd_set_txpkts = {
3908 .f = cmd_set_txpkts_parsed,
3910 .help_str = "set txpkts <len0[,len1]*>",
3912 (void *)&cmd_set_txpkts_keyword,
3913 (void *)&cmd_set_txpkts_name,
3914 (void *)&cmd_set_txpkts_lengths,
3919 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
3921 struct cmd_set_txsplit_result {
3922 cmdline_fixed_string_t cmd_keyword;
3923 cmdline_fixed_string_t txsplit;
3924 cmdline_fixed_string_t mode;
3928 cmd_set_txsplit_parsed(void *parsed_result,
3929 __rte_unused struct cmdline *cl,
3930 __rte_unused void *data)
3932 struct cmd_set_txsplit_result *res;
3934 res = parsed_result;
3935 set_tx_pkt_split(res->mode);
3938 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
3939 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3940 cmd_keyword, "set");
3941 cmdline_parse_token_string_t cmd_set_txsplit_name =
3942 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3943 txsplit, "txsplit");
3944 cmdline_parse_token_string_t cmd_set_txsplit_mode =
3945 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3948 cmdline_parse_inst_t cmd_set_txsplit = {
3949 .f = cmd_set_txsplit_parsed,
3951 .help_str = "set txsplit on|off|rand",
3953 (void *)&cmd_set_txsplit_keyword,
3954 (void *)&cmd_set_txsplit_name,
3955 (void *)&cmd_set_txsplit_mode,
3960 /* *** SET TIMES FOR TXONLY PACKETS SCHEDULING ON TIMESTAMPS *** */
3962 struct cmd_set_txtimes_result {
3963 cmdline_fixed_string_t cmd_keyword;
3964 cmdline_fixed_string_t txtimes;
3965 cmdline_fixed_string_t tx_times;
3969 cmd_set_txtimes_parsed(void *parsed_result,
3970 __rte_unused struct cmdline *cl,
3971 __rte_unused void *data)
3973 struct cmd_set_txtimes_result *res;
3974 unsigned int tx_times[2] = {0, 0};
3975 unsigned int n_times;
3977 res = parsed_result;
3978 n_times = parse_item_list(res->tx_times, "tx times",
3981 set_tx_pkt_times(tx_times);
3984 cmdline_parse_token_string_t cmd_set_txtimes_keyword =
3985 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
3986 cmd_keyword, "set");
3987 cmdline_parse_token_string_t cmd_set_txtimes_name =
3988 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
3989 txtimes, "txtimes");
3990 cmdline_parse_token_string_t cmd_set_txtimes_value =
3991 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
3994 cmdline_parse_inst_t cmd_set_txtimes = {
3995 .f = cmd_set_txtimes_parsed,
3997 .help_str = "set txtimes <inter_burst>,<intra_burst>",
3999 (void *)&cmd_set_txtimes_keyword,
4000 (void *)&cmd_set_txtimes_name,
4001 (void *)&cmd_set_txtimes_value,
4006 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
4007 struct cmd_rx_vlan_filter_all_result {
4008 cmdline_fixed_string_t rx_vlan;
4009 cmdline_fixed_string_t what;
4010 cmdline_fixed_string_t all;
4015 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
4016 __rte_unused struct cmdline *cl,
4017 __rte_unused void *data)
4019 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
4021 if (!strcmp(res->what, "add"))
4022 rx_vlan_all_filter_set(res->port_id, 1);
4024 rx_vlan_all_filter_set(res->port_id, 0);
4027 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
4028 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4029 rx_vlan, "rx_vlan");
4030 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
4031 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4033 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
4034 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4036 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
4037 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4038 port_id, RTE_UINT16);
4040 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
4041 .f = cmd_rx_vlan_filter_all_parsed,
4043 .help_str = "rx_vlan add|rm all <port_id>: "
4044 "Add/Remove all identifiers to/from the set of VLAN "
4045 "identifiers filtered by a port",
4047 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
4048 (void *)&cmd_rx_vlan_filter_all_what,
4049 (void *)&cmd_rx_vlan_filter_all_all,
4050 (void *)&cmd_rx_vlan_filter_all_portid,
4055 /* *** VLAN OFFLOAD SET ON A PORT *** */
4056 struct cmd_vlan_offload_result {
4057 cmdline_fixed_string_t vlan;
4058 cmdline_fixed_string_t set;
4059 cmdline_fixed_string_t vlan_type;
4060 cmdline_fixed_string_t what;
4061 cmdline_fixed_string_t on;
4062 cmdline_fixed_string_t port_id;
4066 cmd_vlan_offload_parsed(void *parsed_result,
4067 __rte_unused struct cmdline *cl,
4068 __rte_unused void *data)
4071 struct cmd_vlan_offload_result *res = parsed_result;
4074 portid_t port_id = 0;
4078 len = strnlen(str, STR_TOKEN_SIZE);
4080 /* Get port_id first */
4088 tmp = strtoul(str, NULL, 0);
4089 /* If port_id greater that what portid_t can represent, return */
4090 if(tmp >= RTE_MAX_ETHPORTS)
4092 port_id = (portid_t)tmp;
4094 if (!strcmp(res->on, "on"))
4099 if (!strcmp(res->what, "strip"))
4100 rx_vlan_strip_set(port_id, on);
4101 else if(!strcmp(res->what, "stripq")){
4102 uint16_t queue_id = 0;
4104 /* No queue_id, return */
4106 printf("must specify (port,queue_id)\n");
4109 tmp = strtoul(str + i + 1, NULL, 0);
4110 /* If queue_id greater that what 16-bits can represent, return */
4114 queue_id = (uint16_t)tmp;
4115 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
4117 else if (!strcmp(res->what, "filter"))
4118 rx_vlan_filter_set(port_id, on);
4119 else if (!strcmp(res->what, "qinq_strip"))
4120 rx_vlan_qinq_strip_set(port_id, on);
4122 vlan_extend_set(port_id, on);
4127 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
4128 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4130 cmdline_parse_token_string_t cmd_vlan_offload_set =
4131 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4133 cmdline_parse_token_string_t cmd_vlan_offload_what =
4134 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4135 what, "strip#filter#qinq_strip#extend#stripq");
4136 cmdline_parse_token_string_t cmd_vlan_offload_on =
4137 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4139 cmdline_parse_token_string_t cmd_vlan_offload_portid =
4140 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4143 cmdline_parse_inst_t cmd_vlan_offload = {
4144 .f = cmd_vlan_offload_parsed,
4146 .help_str = "vlan set strip|filter|qinq_strip|extend|stripq on|off "
4147 "<port_id[,queue_id]>: "
4148 "Strip/Filter/QinQ for rx side Extend for both rx/tx sides",
4150 (void *)&cmd_vlan_offload_vlan,
4151 (void *)&cmd_vlan_offload_set,
4152 (void *)&cmd_vlan_offload_what,
4153 (void *)&cmd_vlan_offload_on,
4154 (void *)&cmd_vlan_offload_portid,
4159 /* *** VLAN TPID SET ON A PORT *** */
4160 struct cmd_vlan_tpid_result {
4161 cmdline_fixed_string_t vlan;
4162 cmdline_fixed_string_t set;
4163 cmdline_fixed_string_t vlan_type;
4164 cmdline_fixed_string_t what;
4170 cmd_vlan_tpid_parsed(void *parsed_result,
4171 __rte_unused struct cmdline *cl,
4172 __rte_unused void *data)
4174 struct cmd_vlan_tpid_result *res = parsed_result;
4175 enum rte_vlan_type vlan_type;
4177 if (!strcmp(res->vlan_type, "inner"))
4178 vlan_type = ETH_VLAN_TYPE_INNER;
4179 else if (!strcmp(res->vlan_type, "outer"))
4180 vlan_type = ETH_VLAN_TYPE_OUTER;
4182 printf("Unknown vlan type\n");
4185 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
4188 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
4189 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4191 cmdline_parse_token_string_t cmd_vlan_tpid_set =
4192 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4194 cmdline_parse_token_string_t cmd_vlan_type =
4195 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4196 vlan_type, "inner#outer");
4197 cmdline_parse_token_string_t cmd_vlan_tpid_what =
4198 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4200 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
4201 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4203 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
4204 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4205 port_id, RTE_UINT16);
4207 cmdline_parse_inst_t cmd_vlan_tpid = {
4208 .f = cmd_vlan_tpid_parsed,
4210 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
4211 "Set the VLAN Ether type",
4213 (void *)&cmd_vlan_tpid_vlan,
4214 (void *)&cmd_vlan_tpid_set,
4215 (void *)&cmd_vlan_type,
4216 (void *)&cmd_vlan_tpid_what,
4217 (void *)&cmd_vlan_tpid_tpid,
4218 (void *)&cmd_vlan_tpid_portid,
4223 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4224 struct cmd_rx_vlan_filter_result {
4225 cmdline_fixed_string_t rx_vlan;
4226 cmdline_fixed_string_t what;
4232 cmd_rx_vlan_filter_parsed(void *parsed_result,
4233 __rte_unused struct cmdline *cl,
4234 __rte_unused void *data)
4236 struct cmd_rx_vlan_filter_result *res = parsed_result;
4238 if (!strcmp(res->what, "add"))
4239 rx_vft_set(res->port_id, res->vlan_id, 1);
4241 rx_vft_set(res->port_id, res->vlan_id, 0);
4244 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
4245 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4246 rx_vlan, "rx_vlan");
4247 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
4248 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4250 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
4251 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4252 vlan_id, RTE_UINT16);
4253 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
4254 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4255 port_id, RTE_UINT16);
4257 cmdline_parse_inst_t cmd_rx_vlan_filter = {
4258 .f = cmd_rx_vlan_filter_parsed,
4260 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
4261 "Add/Remove a VLAN identifier to/from the set of VLAN "
4262 "identifiers filtered by a port",
4264 (void *)&cmd_rx_vlan_filter_rx_vlan,
4265 (void *)&cmd_rx_vlan_filter_what,
4266 (void *)&cmd_rx_vlan_filter_vlanid,
4267 (void *)&cmd_rx_vlan_filter_portid,
4272 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4273 struct cmd_tx_vlan_set_result {
4274 cmdline_fixed_string_t tx_vlan;
4275 cmdline_fixed_string_t set;
4281 cmd_tx_vlan_set_parsed(void *parsed_result,
4282 __rte_unused struct cmdline *cl,
4283 __rte_unused void *data)
4285 struct cmd_tx_vlan_set_result *res = parsed_result;
4287 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4290 if (!port_is_stopped(res->port_id)) {
4291 printf("Please stop port %d first\n", res->port_id);
4295 tx_vlan_set(res->port_id, res->vlan_id);
4297 cmd_reconfig_device_queue(res->port_id, 1, 1);
4300 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4301 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4302 tx_vlan, "tx_vlan");
4303 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4304 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4306 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4307 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4308 port_id, RTE_UINT16);
4309 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
4310 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4311 vlan_id, RTE_UINT16);
4313 cmdline_parse_inst_t cmd_tx_vlan_set = {
4314 .f = cmd_tx_vlan_set_parsed,
4316 .help_str = "tx_vlan set <port_id> <vlan_id>: "
4317 "Enable hardware insertion of a single VLAN header "
4318 "with a given TAG Identifier in packets sent on a port",
4320 (void *)&cmd_tx_vlan_set_tx_vlan,
4321 (void *)&cmd_tx_vlan_set_set,
4322 (void *)&cmd_tx_vlan_set_portid,
4323 (void *)&cmd_tx_vlan_set_vlanid,
4328 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4329 struct cmd_tx_vlan_set_qinq_result {
4330 cmdline_fixed_string_t tx_vlan;
4331 cmdline_fixed_string_t set;
4334 uint16_t vlan_id_outer;
4338 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4339 __rte_unused struct cmdline *cl,
4340 __rte_unused void *data)
4342 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
4344 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4347 if (!port_is_stopped(res->port_id)) {
4348 printf("Please stop port %d first\n", res->port_id);
4352 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
4354 cmd_reconfig_device_queue(res->port_id, 1, 1);
4357 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
4358 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4359 tx_vlan, "tx_vlan");
4360 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
4361 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4363 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
4364 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4365 port_id, RTE_UINT16);
4366 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
4367 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4368 vlan_id, RTE_UINT16);
4369 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
4370 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4371 vlan_id_outer, RTE_UINT16);
4373 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
4374 .f = cmd_tx_vlan_set_qinq_parsed,
4376 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
4377 "Enable hardware insertion of double VLAN header "
4378 "with given TAG Identifiers in packets sent on a port",
4380 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
4381 (void *)&cmd_tx_vlan_set_qinq_set,
4382 (void *)&cmd_tx_vlan_set_qinq_portid,
4383 (void *)&cmd_tx_vlan_set_qinq_vlanid,
4384 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
4389 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
4390 struct cmd_tx_vlan_set_pvid_result {
4391 cmdline_fixed_string_t tx_vlan;
4392 cmdline_fixed_string_t set;
4393 cmdline_fixed_string_t pvid;
4396 cmdline_fixed_string_t mode;
4400 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
4401 __rte_unused struct cmdline *cl,
4402 __rte_unused void *data)
4404 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
4406 if (strcmp(res->mode, "on") == 0)
4407 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
4409 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
4412 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
4413 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4414 tx_vlan, "tx_vlan");
4415 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
4416 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4418 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
4419 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4421 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
4422 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4423 port_id, RTE_UINT16);
4424 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
4425 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4426 vlan_id, RTE_UINT16);
4427 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
4428 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4431 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
4432 .f = cmd_tx_vlan_set_pvid_parsed,
4434 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
4436 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
4437 (void *)&cmd_tx_vlan_set_pvid_set,
4438 (void *)&cmd_tx_vlan_set_pvid_pvid,
4439 (void *)&cmd_tx_vlan_set_pvid_port_id,
4440 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
4441 (void *)&cmd_tx_vlan_set_pvid_mode,
4446 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4447 struct cmd_tx_vlan_reset_result {
4448 cmdline_fixed_string_t tx_vlan;
4449 cmdline_fixed_string_t reset;
4454 cmd_tx_vlan_reset_parsed(void *parsed_result,
4455 __rte_unused struct cmdline *cl,
4456 __rte_unused void *data)
4458 struct cmd_tx_vlan_reset_result *res = parsed_result;
4460 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4463 if (!port_is_stopped(res->port_id)) {
4464 printf("Please stop port %d first\n", res->port_id);
4468 tx_vlan_reset(res->port_id);
4470 cmd_reconfig_device_queue(res->port_id, 1, 1);
4473 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4474 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4475 tx_vlan, "tx_vlan");
4476 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4477 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4479 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4480 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4481 port_id, RTE_UINT16);
4483 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4484 .f = cmd_tx_vlan_reset_parsed,
4486 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4487 "VLAN header in packets sent on a port",
4489 (void *)&cmd_tx_vlan_reset_tx_vlan,
4490 (void *)&cmd_tx_vlan_reset_reset,
4491 (void *)&cmd_tx_vlan_reset_portid,
4497 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4498 struct cmd_csum_result {
4499 cmdline_fixed_string_t csum;
4500 cmdline_fixed_string_t mode;
4501 cmdline_fixed_string_t proto;
4502 cmdline_fixed_string_t hwsw;
4507 csum_show(int port_id)
4509 struct rte_eth_dev_info dev_info;
4510 uint64_t tx_offloads;
4513 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4514 printf("Parse tunnel is %s\n",
4515 (ports[port_id].parse_tunnel) ? "on" : "off");
4516 printf("IP checksum offload is %s\n",
4517 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4518 printf("UDP checksum offload is %s\n",
4519 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4520 printf("TCP checksum offload is %s\n",
4521 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4522 printf("SCTP checksum offload is %s\n",
4523 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4524 printf("Outer-Ip checksum offload is %s\n",
4525 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4526 printf("Outer-Udp checksum offload is %s\n",
4527 (tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
4529 /* display warnings if configuration is not supported by the NIC */
4530 ret = eth_dev_info_get_print_err(port_id, &dev_info);
4534 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
4535 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4536 printf("Warning: hardware IP checksum enabled but not "
4537 "supported by port %d\n", port_id);
4539 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
4540 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
4541 printf("Warning: hardware UDP checksum enabled but not "
4542 "supported by port %d\n", port_id);
4544 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
4545 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
4546 printf("Warning: hardware TCP checksum enabled but not "
4547 "supported by port %d\n", port_id);
4549 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
4550 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4551 printf("Warning: hardware SCTP checksum enabled but not "
4552 "supported by port %d\n", port_id);
4554 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4555 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4556 printf("Warning: hardware outer IP checksum enabled but not "
4557 "supported by port %d\n", port_id);
4559 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
4560 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)
4562 printf("Warning: hardware outer UDP checksum enabled but not "
4563 "supported by port %d\n", port_id);
4568 cmd_config_queue_tx_offloads(struct rte_port *port)
4572 /* Apply queue tx offloads configuration */
4573 for (k = 0; k < port->dev_info.max_rx_queues; k++)
4574 port->tx_conf[k].offloads =
4575 port->dev_conf.txmode.offloads;
4579 cmd_csum_parsed(void *parsed_result,
4580 __rte_unused struct cmdline *cl,
4581 __rte_unused void *data)
4583 struct cmd_csum_result *res = parsed_result;
4585 uint64_t csum_offloads = 0;
4586 struct rte_eth_dev_info dev_info;
4589 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4590 printf("invalid port %d\n", res->port_id);
4593 if (!port_is_stopped(res->port_id)) {
4594 printf("Please stop port %d first\n", res->port_id);
4598 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4602 if (!strcmp(res->mode, "set")) {
4604 if (!strcmp(res->hwsw, "hw"))
4607 if (!strcmp(res->proto, "ip")) {
4608 if (hw == 0 || (dev_info.tx_offload_capa &
4609 DEV_TX_OFFLOAD_IPV4_CKSUM)) {
4610 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
4612 printf("IP checksum offload is not supported "
4613 "by port %u\n", res->port_id);
4615 } else if (!strcmp(res->proto, "udp")) {
4616 if (hw == 0 || (dev_info.tx_offload_capa &
4617 DEV_TX_OFFLOAD_UDP_CKSUM)) {
4618 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
4620 printf("UDP checksum offload is not supported "
4621 "by port %u\n", res->port_id);
4623 } else if (!strcmp(res->proto, "tcp")) {
4624 if (hw == 0 || (dev_info.tx_offload_capa &
4625 DEV_TX_OFFLOAD_TCP_CKSUM)) {
4626 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
4628 printf("TCP checksum offload is not supported "
4629 "by port %u\n", res->port_id);
4631 } else if (!strcmp(res->proto, "sctp")) {
4632 if (hw == 0 || (dev_info.tx_offload_capa &
4633 DEV_TX_OFFLOAD_SCTP_CKSUM)) {
4634 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
4636 printf("SCTP checksum offload is not supported "
4637 "by port %u\n", res->port_id);
4639 } else if (!strcmp(res->proto, "outer-ip")) {
4640 if (hw == 0 || (dev_info.tx_offload_capa &
4641 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4643 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4645 printf("Outer IP checksum offload is not "
4646 "supported by port %u\n", res->port_id);
4648 } else if (!strcmp(res->proto, "outer-udp")) {
4649 if (hw == 0 || (dev_info.tx_offload_capa &
4650 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
4652 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM;
4654 printf("Outer UDP checksum offload is not "
4655 "supported by port %u\n", res->port_id);
4660 ports[res->port_id].dev_conf.txmode.offloads |=
4663 ports[res->port_id].dev_conf.txmode.offloads &=
4666 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4668 csum_show(res->port_id);
4670 cmd_reconfig_device_queue(res->port_id, 1, 1);
4673 cmdline_parse_token_string_t cmd_csum_csum =
4674 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4676 cmdline_parse_token_string_t cmd_csum_mode =
4677 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4679 cmdline_parse_token_string_t cmd_csum_proto =
4680 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4681 proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
4682 cmdline_parse_token_string_t cmd_csum_hwsw =
4683 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4685 cmdline_parse_token_num_t cmd_csum_portid =
4686 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4687 port_id, RTE_UINT16);
4689 cmdline_parse_inst_t cmd_csum_set = {
4690 .f = cmd_csum_parsed,
4692 .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
4693 "Enable/Disable hardware calculation of L3/L4 checksum when "
4694 "using csum forward engine",
4696 (void *)&cmd_csum_csum,
4697 (void *)&cmd_csum_mode,
4698 (void *)&cmd_csum_proto,
4699 (void *)&cmd_csum_hwsw,
4700 (void *)&cmd_csum_portid,
4705 cmdline_parse_token_string_t cmd_csum_mode_show =
4706 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4709 cmdline_parse_inst_t cmd_csum_show = {
4710 .f = cmd_csum_parsed,
4712 .help_str = "csum show <port_id>: Show checksum offload configuration",
4714 (void *)&cmd_csum_csum,
4715 (void *)&cmd_csum_mode_show,
4716 (void *)&cmd_csum_portid,
4721 /* Enable/disable tunnel parsing */
4722 struct cmd_csum_tunnel_result {
4723 cmdline_fixed_string_t csum;
4724 cmdline_fixed_string_t parse;
4725 cmdline_fixed_string_t onoff;
4730 cmd_csum_tunnel_parsed(void *parsed_result,
4731 __rte_unused struct cmdline *cl,
4732 __rte_unused void *data)
4734 struct cmd_csum_tunnel_result *res = parsed_result;
4736 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4739 if (!strcmp(res->onoff, "on"))
4740 ports[res->port_id].parse_tunnel = 1;
4742 ports[res->port_id].parse_tunnel = 0;
4744 csum_show(res->port_id);
4747 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4748 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4750 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4751 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4752 parse, "parse-tunnel");
4753 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4754 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4756 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4757 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4758 port_id, RTE_UINT16);
4760 cmdline_parse_inst_t cmd_csum_tunnel = {
4761 .f = cmd_csum_tunnel_parsed,
4763 .help_str = "csum parse-tunnel on|off <port_id>: "
4764 "Enable/Disable parsing of tunnels for csum engine",
4766 (void *)&cmd_csum_tunnel_csum,
4767 (void *)&cmd_csum_tunnel_parse,
4768 (void *)&cmd_csum_tunnel_onoff,
4769 (void *)&cmd_csum_tunnel_portid,
4774 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4775 struct cmd_tso_set_result {
4776 cmdline_fixed_string_t tso;
4777 cmdline_fixed_string_t mode;
4783 cmd_tso_set_parsed(void *parsed_result,
4784 __rte_unused struct cmdline *cl,
4785 __rte_unused void *data)
4787 struct cmd_tso_set_result *res = parsed_result;
4788 struct rte_eth_dev_info dev_info;
4791 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4793 if (!port_is_stopped(res->port_id)) {
4794 printf("Please stop port %d first\n", res->port_id);
4798 if (!strcmp(res->mode, "set"))
4799 ports[res->port_id].tso_segsz = res->tso_segsz;
4801 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4805 if ((ports[res->port_id].tso_segsz != 0) &&
4806 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4807 printf("Error: TSO is not supported by port %d\n",
4812 if (ports[res->port_id].tso_segsz == 0) {
4813 ports[res->port_id].dev_conf.txmode.offloads &=
4814 ~DEV_TX_OFFLOAD_TCP_TSO;
4815 printf("TSO for non-tunneled packets is disabled\n");
4817 ports[res->port_id].dev_conf.txmode.offloads |=
4818 DEV_TX_OFFLOAD_TCP_TSO;
4819 printf("TSO segment size for non-tunneled packets is %d\n",
4820 ports[res->port_id].tso_segsz);
4822 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4824 /* display warnings if configuration is not supported by the NIC */
4825 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4829 if ((ports[res->port_id].tso_segsz != 0) &&
4830 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4831 printf("Warning: TSO enabled but not "
4832 "supported by port %d\n", res->port_id);
4835 cmd_reconfig_device_queue(res->port_id, 1, 1);
4838 cmdline_parse_token_string_t cmd_tso_set_tso =
4839 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4841 cmdline_parse_token_string_t cmd_tso_set_mode =
4842 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4844 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4845 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4846 tso_segsz, RTE_UINT16);
4847 cmdline_parse_token_num_t cmd_tso_set_portid =
4848 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4849 port_id, RTE_UINT16);
4851 cmdline_parse_inst_t cmd_tso_set = {
4852 .f = cmd_tso_set_parsed,
4854 .help_str = "tso set <tso_segsz> <port_id>: "
4855 "Set TSO segment size of non-tunneled packets for csum engine "
4858 (void *)&cmd_tso_set_tso,
4859 (void *)&cmd_tso_set_mode,
4860 (void *)&cmd_tso_set_tso_segsz,
4861 (void *)&cmd_tso_set_portid,
4866 cmdline_parse_token_string_t cmd_tso_show_mode =
4867 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4871 cmdline_parse_inst_t cmd_tso_show = {
4872 .f = cmd_tso_set_parsed,
4874 .help_str = "tso show <port_id>: "
4875 "Show TSO segment size of non-tunneled packets for csum engine",
4877 (void *)&cmd_tso_set_tso,
4878 (void *)&cmd_tso_show_mode,
4879 (void *)&cmd_tso_set_portid,
4884 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
4885 struct cmd_tunnel_tso_set_result {
4886 cmdline_fixed_string_t tso;
4887 cmdline_fixed_string_t mode;
4892 static struct rte_eth_dev_info
4893 check_tunnel_tso_nic_support(portid_t port_id)
4895 struct rte_eth_dev_info dev_info;
4897 if (eth_dev_info_get_print_err(port_id, &dev_info) != 0)
4900 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
4901 printf("Warning: VXLAN TUNNEL TSO not supported therefore "
4902 "not enabled for port %d\n", port_id);
4903 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
4904 printf("Warning: GRE TUNNEL TSO not supported therefore "
4905 "not enabled for port %d\n", port_id);
4906 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
4907 printf("Warning: IPIP TUNNEL TSO not supported therefore "
4908 "not enabled for port %d\n", port_id);
4909 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
4910 printf("Warning: GENEVE TUNNEL TSO not supported therefore "
4911 "not enabled for port %d\n", port_id);
4912 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
4913 printf("Warning: IP TUNNEL TSO not supported therefore "
4914 "not enabled for port %d\n", port_id);
4915 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
4916 printf("Warning: UDP TUNNEL TSO not supported therefore "
4917 "not enabled for port %d\n", port_id);
4922 cmd_tunnel_tso_set_parsed(void *parsed_result,
4923 __rte_unused struct cmdline *cl,
4924 __rte_unused void *data)
4926 struct cmd_tunnel_tso_set_result *res = parsed_result;
4927 struct rte_eth_dev_info dev_info;
4929 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4931 if (!port_is_stopped(res->port_id)) {
4932 printf("Please stop port %d first\n", res->port_id);
4936 if (!strcmp(res->mode, "set"))
4937 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
4939 dev_info = check_tunnel_tso_nic_support(res->port_id);
4940 if (ports[res->port_id].tunnel_tso_segsz == 0) {
4941 ports[res->port_id].dev_conf.txmode.offloads &=
4942 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4943 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4944 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4945 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4946 DEV_TX_OFFLOAD_IP_TNL_TSO |
4947 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4948 printf("TSO for tunneled packets is disabled\n");
4950 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4951 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4952 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4953 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4954 DEV_TX_OFFLOAD_IP_TNL_TSO |
4955 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4957 ports[res->port_id].dev_conf.txmode.offloads |=
4958 (tso_offloads & dev_info.tx_offload_capa);
4959 printf("TSO segment size for tunneled packets is %d\n",
4960 ports[res->port_id].tunnel_tso_segsz);
4962 /* Below conditions are needed to make it work:
4963 * (1) tunnel TSO is supported by the NIC;
4964 * (2) "csum parse_tunnel" must be set so that tunneled pkts
4966 * (3) for tunneled pkts with outer L3 of IPv4,
4967 * "csum set outer-ip" must be set to hw, because after tso,
4968 * total_len of outer IP header is changed, and the checksum
4969 * of outer IP header calculated by sw should be wrong; that
4970 * is not necessary for IPv6 tunneled pkts because there's no
4971 * checksum in IP header anymore.
4974 if (!ports[res->port_id].parse_tunnel)
4975 printf("Warning: csum parse_tunnel must be set "
4976 "so that tunneled packets are recognized\n");
4977 if (!(ports[res->port_id].dev_conf.txmode.offloads &
4978 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
4979 printf("Warning: csum set outer-ip must be set to hw "
4980 "if outer L3 is IPv4; not necessary for IPv6\n");
4983 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4984 cmd_reconfig_device_queue(res->port_id, 1, 1);
4987 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
4988 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4990 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
4991 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4993 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
4994 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4995 tso_segsz, RTE_UINT16);
4996 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
4997 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4998 port_id, RTE_UINT16);
5000 cmdline_parse_inst_t cmd_tunnel_tso_set = {
5001 .f = cmd_tunnel_tso_set_parsed,
5003 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
5004 "Set TSO segment size of tunneled packets for csum engine "
5007 (void *)&cmd_tunnel_tso_set_tso,
5008 (void *)&cmd_tunnel_tso_set_mode,
5009 (void *)&cmd_tunnel_tso_set_tso_segsz,
5010 (void *)&cmd_tunnel_tso_set_portid,
5015 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
5016 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5020 cmdline_parse_inst_t cmd_tunnel_tso_show = {
5021 .f = cmd_tunnel_tso_set_parsed,
5023 .help_str = "tunnel_tso show <port_id> "
5024 "Show TSO segment size of tunneled packets for csum engine",
5026 (void *)&cmd_tunnel_tso_set_tso,
5027 (void *)&cmd_tunnel_tso_show_mode,
5028 (void *)&cmd_tunnel_tso_set_portid,
5033 /* *** SET GRO FOR A PORT *** */
5034 struct cmd_gro_enable_result {
5035 cmdline_fixed_string_t cmd_set;
5036 cmdline_fixed_string_t cmd_port;
5037 cmdline_fixed_string_t cmd_keyword;
5038 cmdline_fixed_string_t cmd_onoff;
5043 cmd_gro_enable_parsed(void *parsed_result,
5044 __rte_unused struct cmdline *cl,
5045 __rte_unused void *data)
5047 struct cmd_gro_enable_result *res;
5049 res = parsed_result;
5050 if (!strcmp(res->cmd_keyword, "gro"))
5051 setup_gro(res->cmd_onoff, res->cmd_pid);
5054 cmdline_parse_token_string_t cmd_gro_enable_set =
5055 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5057 cmdline_parse_token_string_t cmd_gro_enable_port =
5058 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5059 cmd_keyword, "port");
5060 cmdline_parse_token_num_t cmd_gro_enable_pid =
5061 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
5062 cmd_pid, RTE_UINT16);
5063 cmdline_parse_token_string_t cmd_gro_enable_keyword =
5064 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5065 cmd_keyword, "gro");
5066 cmdline_parse_token_string_t cmd_gro_enable_onoff =
5067 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5068 cmd_onoff, "on#off");
5070 cmdline_parse_inst_t cmd_gro_enable = {
5071 .f = cmd_gro_enable_parsed,
5073 .help_str = "set port <port_id> gro on|off",
5075 (void *)&cmd_gro_enable_set,
5076 (void *)&cmd_gro_enable_port,
5077 (void *)&cmd_gro_enable_pid,
5078 (void *)&cmd_gro_enable_keyword,
5079 (void *)&cmd_gro_enable_onoff,
5084 /* *** DISPLAY GRO CONFIGURATION *** */
5085 struct cmd_gro_show_result {
5086 cmdline_fixed_string_t cmd_show;
5087 cmdline_fixed_string_t cmd_port;
5088 cmdline_fixed_string_t cmd_keyword;
5093 cmd_gro_show_parsed(void *parsed_result,
5094 __rte_unused struct cmdline *cl,
5095 __rte_unused void *data)
5097 struct cmd_gro_show_result *res;
5099 res = parsed_result;
5100 if (!strcmp(res->cmd_keyword, "gro"))
5101 show_gro(res->cmd_pid);
5104 cmdline_parse_token_string_t cmd_gro_show_show =
5105 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5107 cmdline_parse_token_string_t cmd_gro_show_port =
5108 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5110 cmdline_parse_token_num_t cmd_gro_show_pid =
5111 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
5112 cmd_pid, RTE_UINT16);
5113 cmdline_parse_token_string_t cmd_gro_show_keyword =
5114 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5115 cmd_keyword, "gro");
5117 cmdline_parse_inst_t cmd_gro_show = {
5118 .f = cmd_gro_show_parsed,
5120 .help_str = "show port <port_id> gro",
5122 (void *)&cmd_gro_show_show,
5123 (void *)&cmd_gro_show_port,
5124 (void *)&cmd_gro_show_pid,
5125 (void *)&cmd_gro_show_keyword,
5130 /* *** SET FLUSH CYCLES FOR GRO *** */
5131 struct cmd_gro_flush_result {
5132 cmdline_fixed_string_t cmd_set;
5133 cmdline_fixed_string_t cmd_keyword;
5134 cmdline_fixed_string_t cmd_flush;
5139 cmd_gro_flush_parsed(void *parsed_result,
5140 __rte_unused struct cmdline *cl,
5141 __rte_unused void *data)
5143 struct cmd_gro_flush_result *res;
5145 res = parsed_result;
5146 if ((!strcmp(res->cmd_keyword, "gro")) &&
5147 (!strcmp(res->cmd_flush, "flush")))
5148 setup_gro_flush_cycles(res->cmd_cycles);
5151 cmdline_parse_token_string_t cmd_gro_flush_set =
5152 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5154 cmdline_parse_token_string_t cmd_gro_flush_keyword =
5155 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5156 cmd_keyword, "gro");
5157 cmdline_parse_token_string_t cmd_gro_flush_flush =
5158 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5159 cmd_flush, "flush");
5160 cmdline_parse_token_num_t cmd_gro_flush_cycles =
5161 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
5162 cmd_cycles, RTE_UINT8);
5164 cmdline_parse_inst_t cmd_gro_flush = {
5165 .f = cmd_gro_flush_parsed,
5167 .help_str = "set gro flush <cycles>",
5169 (void *)&cmd_gro_flush_set,
5170 (void *)&cmd_gro_flush_keyword,
5171 (void *)&cmd_gro_flush_flush,
5172 (void *)&cmd_gro_flush_cycles,
5177 /* *** ENABLE/DISABLE GSO *** */
5178 struct cmd_gso_enable_result {
5179 cmdline_fixed_string_t cmd_set;
5180 cmdline_fixed_string_t cmd_port;
5181 cmdline_fixed_string_t cmd_keyword;
5182 cmdline_fixed_string_t cmd_mode;
5187 cmd_gso_enable_parsed(void *parsed_result,
5188 __rte_unused struct cmdline *cl,
5189 __rte_unused void *data)
5191 struct cmd_gso_enable_result *res;
5193 res = parsed_result;
5194 if (!strcmp(res->cmd_keyword, "gso"))
5195 setup_gso(res->cmd_mode, res->cmd_pid);
5198 cmdline_parse_token_string_t cmd_gso_enable_set =
5199 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5201 cmdline_parse_token_string_t cmd_gso_enable_port =
5202 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5204 cmdline_parse_token_string_t cmd_gso_enable_keyword =
5205 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5206 cmd_keyword, "gso");
5207 cmdline_parse_token_string_t cmd_gso_enable_mode =
5208 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5209 cmd_mode, "on#off");
5210 cmdline_parse_token_num_t cmd_gso_enable_pid =
5211 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
5212 cmd_pid, RTE_UINT16);
5214 cmdline_parse_inst_t cmd_gso_enable = {
5215 .f = cmd_gso_enable_parsed,
5217 .help_str = "set port <port_id> gso on|off",
5219 (void *)&cmd_gso_enable_set,
5220 (void *)&cmd_gso_enable_port,
5221 (void *)&cmd_gso_enable_pid,
5222 (void *)&cmd_gso_enable_keyword,
5223 (void *)&cmd_gso_enable_mode,
5228 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
5229 struct cmd_gso_size_result {
5230 cmdline_fixed_string_t cmd_set;
5231 cmdline_fixed_string_t cmd_keyword;
5232 cmdline_fixed_string_t cmd_segsz;
5237 cmd_gso_size_parsed(void *parsed_result,
5238 __rte_unused struct cmdline *cl,
5239 __rte_unused void *data)
5241 struct cmd_gso_size_result *res = parsed_result;
5243 if (test_done == 0) {
5244 printf("Before setting GSO segsz, please first"
5245 " stop forwarding\n");
5249 if (!strcmp(res->cmd_keyword, "gso") &&
5250 !strcmp(res->cmd_segsz, "segsz")) {
5251 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
5252 printf("gso_size should be larger than %zu."
5253 " Please input a legal value\n",
5254 RTE_GSO_SEG_SIZE_MIN);
5256 gso_max_segment_size = res->cmd_size;
5260 cmdline_parse_token_string_t cmd_gso_size_set =
5261 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5263 cmdline_parse_token_string_t cmd_gso_size_keyword =
5264 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5265 cmd_keyword, "gso");
5266 cmdline_parse_token_string_t cmd_gso_size_segsz =
5267 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5268 cmd_segsz, "segsz");
5269 cmdline_parse_token_num_t cmd_gso_size_size =
5270 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
5271 cmd_size, RTE_UINT16);
5273 cmdline_parse_inst_t cmd_gso_size = {
5274 .f = cmd_gso_size_parsed,
5276 .help_str = "set gso segsz <length>",
5278 (void *)&cmd_gso_size_set,
5279 (void *)&cmd_gso_size_keyword,
5280 (void *)&cmd_gso_size_segsz,
5281 (void *)&cmd_gso_size_size,
5286 /* *** SHOW GSO CONFIGURATION *** */
5287 struct cmd_gso_show_result {
5288 cmdline_fixed_string_t cmd_show;
5289 cmdline_fixed_string_t cmd_port;
5290 cmdline_fixed_string_t cmd_keyword;
5295 cmd_gso_show_parsed(void *parsed_result,
5296 __rte_unused struct cmdline *cl,
5297 __rte_unused void *data)
5299 struct cmd_gso_show_result *res = parsed_result;
5301 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
5302 printf("invalid port id %u\n", res->cmd_pid);
5305 if (!strcmp(res->cmd_keyword, "gso")) {
5306 if (gso_ports[res->cmd_pid].enable) {
5307 printf("Max GSO'd packet size: %uB\n"
5308 "Supported GSO types: TCP/IPv4, "
5309 "UDP/IPv4, VxLAN with inner "
5310 "TCP/IPv4 packet, GRE with inner "
5311 "TCP/IPv4 packet\n",
5312 gso_max_segment_size);
5314 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
5318 cmdline_parse_token_string_t cmd_gso_show_show =
5319 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5321 cmdline_parse_token_string_t cmd_gso_show_port =
5322 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5324 cmdline_parse_token_string_t cmd_gso_show_keyword =
5325 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5326 cmd_keyword, "gso");
5327 cmdline_parse_token_num_t cmd_gso_show_pid =
5328 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
5329 cmd_pid, RTE_UINT16);
5331 cmdline_parse_inst_t cmd_gso_show = {
5332 .f = cmd_gso_show_parsed,
5334 .help_str = "show port <port_id> gso",
5336 (void *)&cmd_gso_show_show,
5337 (void *)&cmd_gso_show_port,
5338 (void *)&cmd_gso_show_pid,
5339 (void *)&cmd_gso_show_keyword,
5344 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
5345 struct cmd_set_flush_rx {
5346 cmdline_fixed_string_t set;
5347 cmdline_fixed_string_t flush_rx;
5348 cmdline_fixed_string_t mode;
5352 cmd_set_flush_rx_parsed(void *parsed_result,
5353 __rte_unused struct cmdline *cl,
5354 __rte_unused void *data)
5356 struct cmd_set_flush_rx *res = parsed_result;
5357 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5360 cmdline_parse_token_string_t cmd_setflushrx_set =
5361 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5363 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
5364 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5365 flush_rx, "flush_rx");
5366 cmdline_parse_token_string_t cmd_setflushrx_mode =
5367 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5371 cmdline_parse_inst_t cmd_set_flush_rx = {
5372 .f = cmd_set_flush_rx_parsed,
5373 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
5376 (void *)&cmd_setflushrx_set,
5377 (void *)&cmd_setflushrx_flush_rx,
5378 (void *)&cmd_setflushrx_mode,
5383 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
5384 struct cmd_set_link_check {
5385 cmdline_fixed_string_t set;
5386 cmdline_fixed_string_t link_check;
5387 cmdline_fixed_string_t mode;
5391 cmd_set_link_check_parsed(void *parsed_result,
5392 __rte_unused struct cmdline *cl,
5393 __rte_unused void *data)
5395 struct cmd_set_link_check *res = parsed_result;
5396 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5399 cmdline_parse_token_string_t cmd_setlinkcheck_set =
5400 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5402 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
5403 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5404 link_check, "link_check");
5405 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
5406 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5410 cmdline_parse_inst_t cmd_set_link_check = {
5411 .f = cmd_set_link_check_parsed,
5412 .help_str = "set link_check on|off: Enable/Disable link status check "
5413 "when starting/stopping a port",
5416 (void *)&cmd_setlinkcheck_set,
5417 (void *)&cmd_setlinkcheck_link_check,
5418 (void *)&cmd_setlinkcheck_mode,
5423 /* *** SET NIC BYPASS MODE *** */
5424 struct cmd_set_bypass_mode_result {
5425 cmdline_fixed_string_t set;
5426 cmdline_fixed_string_t bypass;
5427 cmdline_fixed_string_t mode;
5428 cmdline_fixed_string_t value;
5433 cmd_set_bypass_mode_parsed(void *parsed_result,
5434 __rte_unused struct cmdline *cl,
5435 __rte_unused void *data)
5437 struct cmd_set_bypass_mode_result *res = parsed_result;
5438 portid_t port_id = res->port_id;
5439 int32_t rc = -EINVAL;
5441 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5442 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5444 if (!strcmp(res->value, "bypass"))
5445 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5446 else if (!strcmp(res->value, "isolate"))
5447 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5449 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5451 /* Set the bypass mode for the relevant port. */
5452 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
5455 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
5458 cmdline_parse_token_string_t cmd_setbypass_mode_set =
5459 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5461 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
5462 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5464 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
5465 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5467 cmdline_parse_token_string_t cmd_setbypass_mode_value =
5468 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5469 value, "normal#bypass#isolate");
5470 cmdline_parse_token_num_t cmd_setbypass_mode_port =
5471 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
5472 port_id, RTE_UINT16);
5474 cmdline_parse_inst_t cmd_set_bypass_mode = {
5475 .f = cmd_set_bypass_mode_parsed,
5476 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
5477 "Set the NIC bypass mode for port_id",
5480 (void *)&cmd_setbypass_mode_set,
5481 (void *)&cmd_setbypass_mode_bypass,
5482 (void *)&cmd_setbypass_mode_mode,
5483 (void *)&cmd_setbypass_mode_value,
5484 (void *)&cmd_setbypass_mode_port,
5489 /* *** SET NIC BYPASS EVENT *** */
5490 struct cmd_set_bypass_event_result {
5491 cmdline_fixed_string_t set;
5492 cmdline_fixed_string_t bypass;
5493 cmdline_fixed_string_t event;
5494 cmdline_fixed_string_t event_value;
5495 cmdline_fixed_string_t mode;
5496 cmdline_fixed_string_t mode_value;
5501 cmd_set_bypass_event_parsed(void *parsed_result,
5502 __rte_unused struct cmdline *cl,
5503 __rte_unused void *data)
5505 int32_t rc = -EINVAL;
5506 struct cmd_set_bypass_event_result *res = parsed_result;
5507 portid_t port_id = res->port_id;
5509 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5510 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5511 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5513 if (!strcmp(res->event_value, "timeout"))
5514 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
5515 else if (!strcmp(res->event_value, "os_on"))
5516 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
5517 else if (!strcmp(res->event_value, "os_off"))
5518 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5519 else if (!strcmp(res->event_value, "power_on"))
5520 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5521 else if (!strcmp(res->event_value, "power_off"))
5522 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5524 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5526 if (!strcmp(res->mode_value, "bypass"))
5527 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5528 else if (!strcmp(res->mode_value, "isolate"))
5529 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5531 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5533 /* Set the watchdog timeout. */
5534 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5537 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5538 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5542 printf("Failed to set timeout value %u "
5543 "for port %d, errto code: %d.\n",
5544 bypass_timeout, port_id, rc);
5548 /* Set the bypass event to transition to bypass mode. */
5549 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5554 printf("\t Failed to set bypass event for port = %d.\n",
5558 cmdline_parse_token_string_t cmd_setbypass_event_set =
5559 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5561 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5562 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5564 cmdline_parse_token_string_t cmd_setbypass_event_event =
5565 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5567 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5568 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5569 event_value, "none#timeout#os_off#os_on#power_on#power_off");
5570 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5571 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5573 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5574 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5575 mode_value, "normal#bypass#isolate");
5576 cmdline_parse_token_num_t cmd_setbypass_event_port =
5577 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5578 port_id, RTE_UINT16);
5580 cmdline_parse_inst_t cmd_set_bypass_event = {
5581 .f = cmd_set_bypass_event_parsed,
5582 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5583 "power_off mode normal|bypass|isolate <port_id>: "
5584 "Set the NIC bypass event mode for port_id",
5587 (void *)&cmd_setbypass_event_set,
5588 (void *)&cmd_setbypass_event_bypass,
5589 (void *)&cmd_setbypass_event_event,
5590 (void *)&cmd_setbypass_event_event_value,
5591 (void *)&cmd_setbypass_event_mode,
5592 (void *)&cmd_setbypass_event_mode_value,
5593 (void *)&cmd_setbypass_event_port,
5599 /* *** SET NIC BYPASS TIMEOUT *** */
5600 struct cmd_set_bypass_timeout_result {
5601 cmdline_fixed_string_t set;
5602 cmdline_fixed_string_t bypass;
5603 cmdline_fixed_string_t timeout;
5604 cmdline_fixed_string_t value;
5608 cmd_set_bypass_timeout_parsed(void *parsed_result,
5609 __rte_unused struct cmdline *cl,
5610 __rte_unused void *data)
5612 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5614 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5615 if (!strcmp(res->value, "1.5"))
5616 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5617 else if (!strcmp(res->value, "2"))
5618 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5619 else if (!strcmp(res->value, "3"))
5620 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5621 else if (!strcmp(res->value, "4"))
5622 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5623 else if (!strcmp(res->value, "8"))
5624 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5625 else if (!strcmp(res->value, "16"))
5626 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5627 else if (!strcmp(res->value, "32"))
5628 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5630 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5634 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5635 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5637 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5638 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5640 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5641 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5642 timeout, "timeout");
5643 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5644 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5645 value, "0#1.5#2#3#4#8#16#32");
5647 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5648 .f = cmd_set_bypass_timeout_parsed,
5649 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5650 "Set the NIC bypass watchdog timeout in seconds",
5653 (void *)&cmd_setbypass_timeout_set,
5654 (void *)&cmd_setbypass_timeout_bypass,
5655 (void *)&cmd_setbypass_timeout_timeout,
5656 (void *)&cmd_setbypass_timeout_value,
5661 /* *** SHOW NIC BYPASS MODE *** */
5662 struct cmd_show_bypass_config_result {
5663 cmdline_fixed_string_t show;
5664 cmdline_fixed_string_t bypass;
5665 cmdline_fixed_string_t config;
5670 cmd_show_bypass_config_parsed(void *parsed_result,
5671 __rte_unused struct cmdline *cl,
5672 __rte_unused void *data)
5674 struct cmd_show_bypass_config_result *res = parsed_result;
5675 portid_t port_id = res->port_id;
5677 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5678 uint32_t event_mode;
5679 uint32_t bypass_mode;
5680 uint32_t timeout = bypass_timeout;
5683 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5684 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
5685 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5686 {"UNKNOWN", "normal", "bypass", "isolate"};
5687 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5695 /* Display the bypass mode.*/
5696 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5697 printf("\tFailed to get bypass mode for port = %d\n", port_id);
5701 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5702 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5704 printf("\tbypass mode = %s\n", modes[bypass_mode]);
5707 /* Display the bypass timeout.*/
5708 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5709 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5711 printf("\tbypass timeout = %s\n", timeouts[timeout]);
5713 /* Display the bypass events and associated modes. */
5714 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < RTE_DIM(events); i++) {
5716 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5717 printf("\tFailed to get bypass mode for event = %s\n",
5720 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5721 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5723 printf("\tbypass event: %-16s = %s\n", events[i],
5729 printf("\tFailed to get bypass configuration for port = %d\n",
5733 cmdline_parse_token_string_t cmd_showbypass_config_show =
5734 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5736 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5737 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5739 cmdline_parse_token_string_t cmd_showbypass_config_config =
5740 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5742 cmdline_parse_token_num_t cmd_showbypass_config_port =
5743 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5744 port_id, RTE_UINT16);
5746 cmdline_parse_inst_t cmd_show_bypass_config = {
5747 .f = cmd_show_bypass_config_parsed,
5748 .help_str = "show bypass config <port_id>: "
5749 "Show the NIC bypass config for port_id",
5752 (void *)&cmd_showbypass_config_show,
5753 (void *)&cmd_showbypass_config_bypass,
5754 (void *)&cmd_showbypass_config_config,
5755 (void *)&cmd_showbypass_config_port,
5761 /* *** SET BONDING MODE *** */
5762 struct cmd_set_bonding_mode_result {
5763 cmdline_fixed_string_t set;
5764 cmdline_fixed_string_t bonding;
5765 cmdline_fixed_string_t mode;
5770 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5771 __rte_unused struct cmdline *cl,
5772 __rte_unused void *data)
5774 struct cmd_set_bonding_mode_result *res = parsed_result;
5775 portid_t port_id = res->port_id;
5777 /* Set the bonding mode for the relevant port. */
5778 if (0 != rte_eth_bond_mode_set(port_id, res->value))
5779 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
5782 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5783 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5785 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5786 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5787 bonding, "bonding");
5788 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5789 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5791 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5792 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5794 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5795 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5796 port_id, RTE_UINT16);
5798 cmdline_parse_inst_t cmd_set_bonding_mode = {
5799 .f = cmd_set_bonding_mode_parsed,
5800 .help_str = "set bonding mode <mode_value> <port_id>: "
5801 "Set the bonding mode for port_id",
5804 (void *) &cmd_setbonding_mode_set,
5805 (void *) &cmd_setbonding_mode_bonding,
5806 (void *) &cmd_setbonding_mode_mode,
5807 (void *) &cmd_setbonding_mode_value,
5808 (void *) &cmd_setbonding_mode_port,
5813 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5814 struct cmd_set_bonding_lacp_dedicated_queues_result {
5815 cmdline_fixed_string_t set;
5816 cmdline_fixed_string_t bonding;
5817 cmdline_fixed_string_t lacp;
5818 cmdline_fixed_string_t dedicated_queues;
5820 cmdline_fixed_string_t mode;
5823 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5824 __rte_unused struct cmdline *cl,
5825 __rte_unused void *data)
5827 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5828 portid_t port_id = res->port_id;
5829 struct rte_port *port;
5831 port = &ports[port_id];
5833 /** Check if the port is not started **/
5834 if (port->port_status != RTE_PORT_STOPPED) {
5835 printf("Please stop port %d first\n", port_id);
5839 if (!strcmp(res->mode, "enable")) {
5840 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5841 printf("Dedicate queues for LACP control packets"
5844 printf("Enabling dedicate queues for LACP control "
5845 "packets on port %d failed\n", port_id);
5846 } else if (!strcmp(res->mode, "disable")) {
5847 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5848 printf("Dedicated queues for LACP control packets "
5851 printf("Disabling dedicated queues for LACP control "
5852 "traffic on port %d failed\n", port_id);
5856 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5857 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5859 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
5860 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5861 bonding, "bonding");
5862 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
5863 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5865 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
5866 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5867 dedicated_queues, "dedicated_queues");
5868 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
5869 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5870 port_id, RTE_UINT16);
5871 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
5872 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5873 mode, "enable#disable");
5875 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
5876 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
5877 .help_str = "set bonding lacp dedicated_queues <port_id> "
5879 "Enable/disable dedicated queues for LACP control traffic for port_id",
5882 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
5883 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
5884 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
5885 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
5886 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
5887 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
5892 /* *** SET BALANCE XMIT POLICY *** */
5893 struct cmd_set_bonding_balance_xmit_policy_result {
5894 cmdline_fixed_string_t set;
5895 cmdline_fixed_string_t bonding;
5896 cmdline_fixed_string_t balance_xmit_policy;
5898 cmdline_fixed_string_t policy;
5901 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
5902 __rte_unused struct cmdline *cl,
5903 __rte_unused void *data)
5905 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
5906 portid_t port_id = res->port_id;
5909 if (!strcmp(res->policy, "l2")) {
5910 policy = BALANCE_XMIT_POLICY_LAYER2;
5911 } else if (!strcmp(res->policy, "l23")) {
5912 policy = BALANCE_XMIT_POLICY_LAYER23;
5913 } else if (!strcmp(res->policy, "l34")) {
5914 policy = BALANCE_XMIT_POLICY_LAYER34;
5916 printf("\t Invalid xmit policy selection");
5920 /* Set the bonding mode for the relevant port. */
5921 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
5922 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
5927 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
5928 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5930 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
5931 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5932 bonding, "bonding");
5933 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
5934 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5935 balance_xmit_policy, "balance_xmit_policy");
5936 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
5937 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5938 port_id, RTE_UINT16);
5939 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
5940 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5941 policy, "l2#l23#l34");
5943 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
5944 .f = cmd_set_bonding_balance_xmit_policy_parsed,
5945 .help_str = "set bonding balance_xmit_policy <port_id> "
5947 "Set the bonding balance_xmit_policy for port_id",
5950 (void *)&cmd_setbonding_balance_xmit_policy_set,
5951 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
5952 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
5953 (void *)&cmd_setbonding_balance_xmit_policy_port,
5954 (void *)&cmd_setbonding_balance_xmit_policy_policy,
5959 /* *** SHOW NIC BONDING CONFIGURATION *** */
5960 struct cmd_show_bonding_config_result {
5961 cmdline_fixed_string_t show;
5962 cmdline_fixed_string_t bonding;
5963 cmdline_fixed_string_t config;
5967 static void cmd_show_bonding_config_parsed(void *parsed_result,
5968 __rte_unused struct cmdline *cl,
5969 __rte_unused void *data)
5971 struct cmd_show_bonding_config_result *res = parsed_result;
5972 int bonding_mode, agg_mode;
5973 portid_t slaves[RTE_MAX_ETHPORTS];
5974 int num_slaves, num_active_slaves;
5977 portid_t port_id = res->port_id;
5979 /* Display the bonding mode.*/
5980 bonding_mode = rte_eth_bond_mode_get(port_id);
5981 if (bonding_mode < 0) {
5982 printf("\tFailed to get bonding mode for port = %d\n", port_id);
5985 printf("\tBonding mode: %d\n", bonding_mode);
5987 if (bonding_mode == BONDING_MODE_BALANCE) {
5988 int balance_xmit_policy;
5990 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
5991 if (balance_xmit_policy < 0) {
5992 printf("\tFailed to get balance xmit policy for port = %d\n",
5996 printf("\tBalance Xmit Policy: ");
5998 switch (balance_xmit_policy) {
5999 case BALANCE_XMIT_POLICY_LAYER2:
6000 printf("BALANCE_XMIT_POLICY_LAYER2");
6002 case BALANCE_XMIT_POLICY_LAYER23:
6003 printf("BALANCE_XMIT_POLICY_LAYER23");
6005 case BALANCE_XMIT_POLICY_LAYER34:
6006 printf("BALANCE_XMIT_POLICY_LAYER34");
6013 if (bonding_mode == BONDING_MODE_8023AD) {
6014 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
6015 printf("\tIEEE802.3AD Aggregator Mode: ");
6018 printf("bandwidth");
6030 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
6032 if (num_slaves < 0) {
6033 printf("\tFailed to get slave list for port = %d\n", port_id);
6036 if (num_slaves > 0) {
6037 printf("\tSlaves (%d): [", num_slaves);
6038 for (i = 0; i < num_slaves - 1; i++)
6039 printf("%d ", slaves[i]);
6041 printf("%d]\n", slaves[num_slaves - 1]);
6043 printf("\tSlaves: []\n");
6047 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
6050 if (num_active_slaves < 0) {
6051 printf("\tFailed to get active slave list for port = %d\n", port_id);
6054 if (num_active_slaves > 0) {
6055 printf("\tActive Slaves (%d): [", num_active_slaves);
6056 for (i = 0; i < num_active_slaves - 1; i++)
6057 printf("%d ", slaves[i]);
6059 printf("%d]\n", slaves[num_active_slaves - 1]);
6062 printf("\tActive Slaves: []\n");
6066 primary_id = rte_eth_bond_primary_get(port_id);
6067 if (primary_id < 0) {
6068 printf("\tFailed to get primary slave for port = %d\n", port_id);
6071 printf("\tPrimary: [%d]\n", primary_id);
6075 cmdline_parse_token_string_t cmd_showbonding_config_show =
6076 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6078 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
6079 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6080 bonding, "bonding");
6081 cmdline_parse_token_string_t cmd_showbonding_config_config =
6082 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6084 cmdline_parse_token_num_t cmd_showbonding_config_port =
6085 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
6086 port_id, RTE_UINT16);
6088 cmdline_parse_inst_t cmd_show_bonding_config = {
6089 .f = cmd_show_bonding_config_parsed,
6090 .help_str = "show bonding config <port_id>: "
6091 "Show the bonding config for port_id",
6094 (void *)&cmd_showbonding_config_show,
6095 (void *)&cmd_showbonding_config_bonding,
6096 (void *)&cmd_showbonding_config_config,
6097 (void *)&cmd_showbonding_config_port,
6102 /* *** SET BONDING PRIMARY *** */
6103 struct cmd_set_bonding_primary_result {
6104 cmdline_fixed_string_t set;
6105 cmdline_fixed_string_t bonding;
6106 cmdline_fixed_string_t primary;
6111 static void cmd_set_bonding_primary_parsed(void *parsed_result,
6112 __rte_unused struct cmdline *cl,
6113 __rte_unused void *data)
6115 struct cmd_set_bonding_primary_result *res = parsed_result;
6116 portid_t master_port_id = res->port_id;
6117 portid_t slave_port_id = res->slave_id;
6119 /* Set the primary slave for a bonded device. */
6120 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
6121 printf("\t Failed to set primary slave for port = %d.\n",
6128 cmdline_parse_token_string_t cmd_setbonding_primary_set =
6129 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6131 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
6132 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6133 bonding, "bonding");
6134 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
6135 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6136 primary, "primary");
6137 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
6138 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6139 slave_id, RTE_UINT16);
6140 cmdline_parse_token_num_t cmd_setbonding_primary_port =
6141 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6142 port_id, RTE_UINT16);
6144 cmdline_parse_inst_t cmd_set_bonding_primary = {
6145 .f = cmd_set_bonding_primary_parsed,
6146 .help_str = "set bonding primary <slave_id> <port_id>: "
6147 "Set the primary slave for port_id",
6150 (void *)&cmd_setbonding_primary_set,
6151 (void *)&cmd_setbonding_primary_bonding,
6152 (void *)&cmd_setbonding_primary_primary,
6153 (void *)&cmd_setbonding_primary_slave,
6154 (void *)&cmd_setbonding_primary_port,
6159 /* *** ADD SLAVE *** */
6160 struct cmd_add_bonding_slave_result {
6161 cmdline_fixed_string_t add;
6162 cmdline_fixed_string_t bonding;
6163 cmdline_fixed_string_t slave;
6168 static void cmd_add_bonding_slave_parsed(void *parsed_result,
6169 __rte_unused struct cmdline *cl,
6170 __rte_unused void *data)
6172 struct cmd_add_bonding_slave_result *res = parsed_result;
6173 portid_t master_port_id = res->port_id;
6174 portid_t slave_port_id = res->slave_id;
6176 /* add the slave for a bonded device. */
6177 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
6178 printf("\t Failed to add slave %d to master port = %d.\n",
6179 slave_port_id, master_port_id);
6183 set_port_slave_flag(slave_port_id);
6186 cmdline_parse_token_string_t cmd_addbonding_slave_add =
6187 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6189 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
6190 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6191 bonding, "bonding");
6192 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
6193 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6195 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
6196 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6197 slave_id, RTE_UINT16);
6198 cmdline_parse_token_num_t cmd_addbonding_slave_port =
6199 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6200 port_id, RTE_UINT16);
6202 cmdline_parse_inst_t cmd_add_bonding_slave = {
6203 .f = cmd_add_bonding_slave_parsed,
6204 .help_str = "add bonding slave <slave_id> <port_id>: "
6205 "Add a slave device to a bonded device",
6208 (void *)&cmd_addbonding_slave_add,
6209 (void *)&cmd_addbonding_slave_bonding,
6210 (void *)&cmd_addbonding_slave_slave,
6211 (void *)&cmd_addbonding_slave_slaveid,
6212 (void *)&cmd_addbonding_slave_port,
6217 /* *** REMOVE SLAVE *** */
6218 struct cmd_remove_bonding_slave_result {
6219 cmdline_fixed_string_t remove;
6220 cmdline_fixed_string_t bonding;
6221 cmdline_fixed_string_t slave;
6226 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
6227 __rte_unused struct cmdline *cl,
6228 __rte_unused void *data)
6230 struct cmd_remove_bonding_slave_result *res = parsed_result;
6231 portid_t master_port_id = res->port_id;
6232 portid_t slave_port_id = res->slave_id;
6234 /* remove the slave from a bonded device. */
6235 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
6236 printf("\t Failed to remove slave %d from master port = %d.\n",
6237 slave_port_id, master_port_id);
6241 clear_port_slave_flag(slave_port_id);
6244 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
6245 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6247 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
6248 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6249 bonding, "bonding");
6250 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
6251 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6253 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
6254 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6255 slave_id, RTE_UINT16);
6256 cmdline_parse_token_num_t cmd_removebonding_slave_port =
6257 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6258 port_id, RTE_UINT16);
6260 cmdline_parse_inst_t cmd_remove_bonding_slave = {
6261 .f = cmd_remove_bonding_slave_parsed,
6262 .help_str = "remove bonding slave <slave_id> <port_id>: "
6263 "Remove a slave device from a bonded device",
6266 (void *)&cmd_removebonding_slave_remove,
6267 (void *)&cmd_removebonding_slave_bonding,
6268 (void *)&cmd_removebonding_slave_slave,
6269 (void *)&cmd_removebonding_slave_slaveid,
6270 (void *)&cmd_removebonding_slave_port,
6275 /* *** CREATE BONDED DEVICE *** */
6276 struct cmd_create_bonded_device_result {
6277 cmdline_fixed_string_t create;
6278 cmdline_fixed_string_t bonded;
6279 cmdline_fixed_string_t device;
6284 static int bond_dev_num = 0;
6286 static void cmd_create_bonded_device_parsed(void *parsed_result,
6287 __rte_unused struct cmdline *cl,
6288 __rte_unused void *data)
6290 struct cmd_create_bonded_device_result *res = parsed_result;
6291 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
6295 if (test_done == 0) {
6296 printf("Please stop forwarding first\n");
6300 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
6303 /* Create a new bonded device. */
6304 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
6306 printf("\t Failed to create bonded device.\n");
6309 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
6312 /* Update number of ports */
6313 nb_ports = rte_eth_dev_count_avail();
6314 reconfig(port_id, res->socket);
6315 ret = rte_eth_promiscuous_enable(port_id);
6317 printf("Failed to enable promiscuous mode for port %u: %s - ignore\n",
6318 port_id, rte_strerror(-ret));
6320 ports[port_id].need_setup = 0;
6321 ports[port_id].port_status = RTE_PORT_STOPPED;
6326 cmdline_parse_token_string_t cmd_createbonded_device_create =
6327 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6329 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
6330 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6332 cmdline_parse_token_string_t cmd_createbonded_device_device =
6333 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6335 cmdline_parse_token_num_t cmd_createbonded_device_mode =
6336 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6338 cmdline_parse_token_num_t cmd_createbonded_device_socket =
6339 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6342 cmdline_parse_inst_t cmd_create_bonded_device = {
6343 .f = cmd_create_bonded_device_parsed,
6344 .help_str = "create bonded device <mode> <socket>: "
6345 "Create a new bonded device with specific bonding mode and socket",
6348 (void *)&cmd_createbonded_device_create,
6349 (void *)&cmd_createbonded_device_bonded,
6350 (void *)&cmd_createbonded_device_device,
6351 (void *)&cmd_createbonded_device_mode,
6352 (void *)&cmd_createbonded_device_socket,
6357 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
6358 struct cmd_set_bond_mac_addr_result {
6359 cmdline_fixed_string_t set;
6360 cmdline_fixed_string_t bonding;
6361 cmdline_fixed_string_t mac_addr;
6363 struct rte_ether_addr address;
6366 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
6367 __rte_unused struct cmdline *cl,
6368 __rte_unused void *data)
6370 struct cmd_set_bond_mac_addr_result *res = parsed_result;
6373 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
6376 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
6378 /* check the return value and print it if is < 0 */
6380 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6383 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
6384 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
6385 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
6386 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
6388 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
6389 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
6391 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
6392 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
6393 port_num, RTE_UINT16);
6394 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
6395 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
6397 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
6398 .f = cmd_set_bond_mac_addr_parsed,
6400 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
6402 (void *)&cmd_set_bond_mac_addr_set,
6403 (void *)&cmd_set_bond_mac_addr_bonding,
6404 (void *)&cmd_set_bond_mac_addr_mac,
6405 (void *)&cmd_set_bond_mac_addr_portnum,
6406 (void *)&cmd_set_bond_mac_addr_addr,
6412 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
6413 struct cmd_set_bond_mon_period_result {
6414 cmdline_fixed_string_t set;
6415 cmdline_fixed_string_t bonding;
6416 cmdline_fixed_string_t mon_period;
6421 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
6422 __rte_unused struct cmdline *cl,
6423 __rte_unused void *data)
6425 struct cmd_set_bond_mon_period_result *res = parsed_result;
6428 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
6430 /* check the return value and print it if is < 0 */
6432 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6435 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
6436 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6438 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
6439 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6440 bonding, "bonding");
6441 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
6442 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6443 mon_period, "mon_period");
6444 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
6445 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6446 port_num, RTE_UINT16);
6447 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
6448 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6449 period_ms, RTE_UINT32);
6451 cmdline_parse_inst_t cmd_set_bond_mon_period = {
6452 .f = cmd_set_bond_mon_period_parsed,
6454 .help_str = "set bonding mon_period <port_id> <period_ms>",
6456 (void *)&cmd_set_bond_mon_period_set,
6457 (void *)&cmd_set_bond_mon_period_bonding,
6458 (void *)&cmd_set_bond_mon_period_mon_period,
6459 (void *)&cmd_set_bond_mon_period_portnum,
6460 (void *)&cmd_set_bond_mon_period_period_ms,
6467 struct cmd_set_bonding_agg_mode_policy_result {
6468 cmdline_fixed_string_t set;
6469 cmdline_fixed_string_t bonding;
6470 cmdline_fixed_string_t agg_mode;
6472 cmdline_fixed_string_t policy;
6477 cmd_set_bonding_agg_mode(void *parsed_result,
6478 __rte_unused struct cmdline *cl,
6479 __rte_unused void *data)
6481 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
6482 uint8_t policy = AGG_BANDWIDTH;
6484 if (!strcmp(res->policy, "bandwidth"))
6485 policy = AGG_BANDWIDTH;
6486 else if (!strcmp(res->policy, "stable"))
6487 policy = AGG_STABLE;
6488 else if (!strcmp(res->policy, "count"))
6491 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
6495 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
6496 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6498 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
6499 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6500 bonding, "bonding");
6502 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
6503 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6504 agg_mode, "agg_mode");
6506 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
6507 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6508 port_num, RTE_UINT16);
6510 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6511 TOKEN_STRING_INITIALIZER(
6512 struct cmd_set_bonding_balance_xmit_policy_result,
6513 policy, "stable#bandwidth#count");
6515 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6516 .f = cmd_set_bonding_agg_mode,
6518 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6520 (void *)&cmd_set_bonding_agg_mode_set,
6521 (void *)&cmd_set_bonding_agg_mode_bonding,
6522 (void *)&cmd_set_bonding_agg_mode_agg_mode,
6523 (void *)&cmd_set_bonding_agg_mode_portnum,
6524 (void *)&cmd_set_bonding_agg_mode_policy_string,
6530 #endif /* RTE_NET_BOND */
6532 /* *** SET FORWARDING MODE *** */
6533 struct cmd_set_fwd_mode_result {
6534 cmdline_fixed_string_t set;
6535 cmdline_fixed_string_t fwd;
6536 cmdline_fixed_string_t mode;
6539 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6540 __rte_unused struct cmdline *cl,
6541 __rte_unused void *data)
6543 struct cmd_set_fwd_mode_result *res = parsed_result;
6546 set_pkt_forwarding_mode(res->mode);
6549 cmdline_parse_token_string_t cmd_setfwd_set =
6550 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6551 cmdline_parse_token_string_t cmd_setfwd_fwd =
6552 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6553 cmdline_parse_token_string_t cmd_setfwd_mode =
6554 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6555 "" /* defined at init */);
6557 cmdline_parse_inst_t cmd_set_fwd_mode = {
6558 .f = cmd_set_fwd_mode_parsed,
6560 .help_str = NULL, /* defined at init */
6562 (void *)&cmd_setfwd_set,
6563 (void *)&cmd_setfwd_fwd,
6564 (void *)&cmd_setfwd_mode,
6569 static void cmd_set_fwd_mode_init(void)
6572 static char token[128];
6573 static char help[256];
6574 cmdline_parse_token_string_t *token_struct;
6576 modes = list_pkt_forwarding_modes();
6577 snprintf(help, sizeof(help), "set fwd %s: "
6578 "Set packet forwarding mode", modes);
6579 cmd_set_fwd_mode.help_str = help;
6581 /* string token separator is # */
6582 for (c = token; *modes != '\0'; modes++)
6587 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6588 token_struct->string_data.str = token;
6591 /* *** SET RETRY FORWARDING MODE *** */
6592 struct cmd_set_fwd_retry_mode_result {
6593 cmdline_fixed_string_t set;
6594 cmdline_fixed_string_t fwd;
6595 cmdline_fixed_string_t mode;
6596 cmdline_fixed_string_t retry;
6599 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6600 __rte_unused struct cmdline *cl,
6601 __rte_unused void *data)
6603 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6606 set_pkt_forwarding_mode(res->mode);
6609 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6610 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6612 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6613 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6615 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6616 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6618 "" /* defined at init */);
6619 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6620 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6623 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6624 .f = cmd_set_fwd_retry_mode_parsed,
6626 .help_str = NULL, /* defined at init */
6628 (void *)&cmd_setfwd_retry_set,
6629 (void *)&cmd_setfwd_retry_fwd,
6630 (void *)&cmd_setfwd_retry_mode,
6631 (void *)&cmd_setfwd_retry_retry,
6636 static void cmd_set_fwd_retry_mode_init(void)
6639 static char token[128];
6640 static char help[256];
6641 cmdline_parse_token_string_t *token_struct;
6643 modes = list_pkt_forwarding_retry_modes();
6644 snprintf(help, sizeof(help), "set fwd %s retry: "
6645 "Set packet forwarding mode with retry", modes);
6646 cmd_set_fwd_retry_mode.help_str = help;
6648 /* string token separator is # */
6649 for (c = token; *modes != '\0'; modes++)
6654 token_struct = (cmdline_parse_token_string_t *)
6655 cmd_set_fwd_retry_mode.tokens[2];
6656 token_struct->string_data.str = token;
6659 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6660 struct cmd_set_burst_tx_retry_result {
6661 cmdline_fixed_string_t set;
6662 cmdline_fixed_string_t burst;
6663 cmdline_fixed_string_t tx;
6664 cmdline_fixed_string_t delay;
6666 cmdline_fixed_string_t retry;
6670 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6671 __rte_unused struct cmdline *cl,
6672 __rte_unused void *data)
6674 struct cmd_set_burst_tx_retry_result *res = parsed_result;
6676 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6677 && !strcmp(res->tx, "tx")) {
6678 if (!strcmp(res->delay, "delay"))
6679 burst_tx_delay_time = res->time;
6680 if (!strcmp(res->retry, "retry"))
6681 burst_tx_retry_num = res->retry_num;
6686 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6687 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6688 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6689 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6691 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6692 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6693 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6694 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6695 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6696 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time,
6698 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6699 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6700 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6701 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num,
6704 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6705 .f = cmd_set_burst_tx_retry_parsed,
6706 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6708 (void *)&cmd_set_burst_tx_retry_set,
6709 (void *)&cmd_set_burst_tx_retry_burst,
6710 (void *)&cmd_set_burst_tx_retry_tx,
6711 (void *)&cmd_set_burst_tx_retry_delay,
6712 (void *)&cmd_set_burst_tx_retry_time,
6713 (void *)&cmd_set_burst_tx_retry_retry,
6714 (void *)&cmd_set_burst_tx_retry_retry_num,
6719 /* *** SET PROMISC MODE *** */
6720 struct cmd_set_promisc_mode_result {
6721 cmdline_fixed_string_t set;
6722 cmdline_fixed_string_t promisc;
6723 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6724 uint16_t port_num; /* valid if "allports" argument == 0 */
6725 cmdline_fixed_string_t mode;
6728 static void cmd_set_promisc_mode_parsed(void *parsed_result,
6729 __rte_unused struct cmdline *cl,
6732 struct cmd_set_promisc_mode_result *res = parsed_result;
6736 if (!strcmp(res->mode, "on"))
6743 RTE_ETH_FOREACH_DEV(i)
6744 eth_set_promisc_mode(i, enable);
6746 eth_set_promisc_mode(res->port_num, enable);
6750 cmdline_parse_token_string_t cmd_setpromisc_set =
6751 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6752 cmdline_parse_token_string_t cmd_setpromisc_promisc =
6753 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6755 cmdline_parse_token_string_t cmd_setpromisc_portall =
6756 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6758 cmdline_parse_token_num_t cmd_setpromisc_portnum =
6759 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6761 cmdline_parse_token_string_t cmd_setpromisc_mode =
6762 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6765 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6766 .f = cmd_set_promisc_mode_parsed,
6768 .help_str = "set promisc all on|off: Set promisc mode for all ports",
6770 (void *)&cmd_setpromisc_set,
6771 (void *)&cmd_setpromisc_promisc,
6772 (void *)&cmd_setpromisc_portall,
6773 (void *)&cmd_setpromisc_mode,
6778 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6779 .f = cmd_set_promisc_mode_parsed,
6781 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6783 (void *)&cmd_setpromisc_set,
6784 (void *)&cmd_setpromisc_promisc,
6785 (void *)&cmd_setpromisc_portnum,
6786 (void *)&cmd_setpromisc_mode,
6791 /* *** SET ALLMULTI MODE *** */
6792 struct cmd_set_allmulti_mode_result {
6793 cmdline_fixed_string_t set;
6794 cmdline_fixed_string_t allmulti;
6795 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6796 uint16_t port_num; /* valid if "allports" argument == 0 */
6797 cmdline_fixed_string_t mode;
6800 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6801 __rte_unused struct cmdline *cl,
6804 struct cmd_set_allmulti_mode_result *res = parsed_result;
6808 if (!strcmp(res->mode, "on"))
6815 RTE_ETH_FOREACH_DEV(i) {
6816 eth_set_allmulticast_mode(i, enable);
6820 eth_set_allmulticast_mode(res->port_num, enable);
6824 cmdline_parse_token_string_t cmd_setallmulti_set =
6825 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6826 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6827 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6829 cmdline_parse_token_string_t cmd_setallmulti_portall =
6830 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6832 cmdline_parse_token_num_t cmd_setallmulti_portnum =
6833 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6835 cmdline_parse_token_string_t cmd_setallmulti_mode =
6836 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6839 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6840 .f = cmd_set_allmulti_mode_parsed,
6842 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6844 (void *)&cmd_setallmulti_set,
6845 (void *)&cmd_setallmulti_allmulti,
6846 (void *)&cmd_setallmulti_portall,
6847 (void *)&cmd_setallmulti_mode,
6852 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6853 .f = cmd_set_allmulti_mode_parsed,
6855 .help_str = "set allmulti <port_id> on|off: "
6856 "Set allmulti mode on port_id",
6858 (void *)&cmd_setallmulti_set,
6859 (void *)&cmd_setallmulti_allmulti,
6860 (void *)&cmd_setallmulti_portnum,
6861 (void *)&cmd_setallmulti_mode,
6866 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
6867 struct cmd_link_flow_ctrl_set_result {
6868 cmdline_fixed_string_t set;
6869 cmdline_fixed_string_t flow_ctrl;
6870 cmdline_fixed_string_t rx;
6871 cmdline_fixed_string_t rx_lfc_mode;
6872 cmdline_fixed_string_t tx;
6873 cmdline_fixed_string_t tx_lfc_mode;
6874 cmdline_fixed_string_t mac_ctrl_frame_fwd;
6875 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
6876 cmdline_fixed_string_t autoneg_str;
6877 cmdline_fixed_string_t autoneg;
6878 cmdline_fixed_string_t hw_str;
6879 uint32_t high_water;
6880 cmdline_fixed_string_t lw_str;
6882 cmdline_fixed_string_t pt_str;
6883 uint16_t pause_time;
6884 cmdline_fixed_string_t xon_str;
6889 cmdline_parse_token_string_t cmd_lfc_set_set =
6890 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6892 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
6893 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6894 flow_ctrl, "flow_ctrl");
6895 cmdline_parse_token_string_t cmd_lfc_set_rx =
6896 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6898 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
6899 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6900 rx_lfc_mode, "on#off");
6901 cmdline_parse_token_string_t cmd_lfc_set_tx =
6902 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6904 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
6905 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6906 tx_lfc_mode, "on#off");
6907 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
6908 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6909 hw_str, "high_water");
6910 cmdline_parse_token_num_t cmd_lfc_set_high_water =
6911 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6912 high_water, RTE_UINT32);
6913 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
6914 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6915 lw_str, "low_water");
6916 cmdline_parse_token_num_t cmd_lfc_set_low_water =
6917 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6918 low_water, RTE_UINT32);
6919 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
6920 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6921 pt_str, "pause_time");
6922 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
6923 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6924 pause_time, RTE_UINT16);
6925 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
6926 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6927 xon_str, "send_xon");
6928 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
6929 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6930 send_xon, RTE_UINT16);
6931 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
6932 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6933 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
6934 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6935 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6936 mac_ctrl_frame_fwd_mode, "on#off");
6937 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6938 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6939 autoneg_str, "autoneg");
6940 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6941 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6943 cmdline_parse_token_num_t cmd_lfc_set_portid =
6944 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6945 port_id, RTE_UINT16);
6947 /* forward declaration */
6949 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6952 cmdline_parse_inst_t cmd_link_flow_control_set = {
6953 .f = cmd_link_flow_ctrl_set_parsed,
6955 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6956 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6957 "autoneg on|off <port_id>: Configure the Ethernet flow control",
6959 (void *)&cmd_lfc_set_set,
6960 (void *)&cmd_lfc_set_flow_ctrl,
6961 (void *)&cmd_lfc_set_rx,
6962 (void *)&cmd_lfc_set_rx_mode,
6963 (void *)&cmd_lfc_set_tx,
6964 (void *)&cmd_lfc_set_tx_mode,
6965 (void *)&cmd_lfc_set_high_water,
6966 (void *)&cmd_lfc_set_low_water,
6967 (void *)&cmd_lfc_set_pause_time,
6968 (void *)&cmd_lfc_set_send_xon,
6969 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6970 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6971 (void *)&cmd_lfc_set_autoneg_str,
6972 (void *)&cmd_lfc_set_autoneg,
6973 (void *)&cmd_lfc_set_portid,
6978 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6979 .f = cmd_link_flow_ctrl_set_parsed,
6980 .data = (void *)&cmd_link_flow_control_set_rx,
6981 .help_str = "set flow_ctrl rx on|off <port_id>: "
6982 "Change rx flow control parameter",
6984 (void *)&cmd_lfc_set_set,
6985 (void *)&cmd_lfc_set_flow_ctrl,
6986 (void *)&cmd_lfc_set_rx,
6987 (void *)&cmd_lfc_set_rx_mode,
6988 (void *)&cmd_lfc_set_portid,
6993 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6994 .f = cmd_link_flow_ctrl_set_parsed,
6995 .data = (void *)&cmd_link_flow_control_set_tx,
6996 .help_str = "set flow_ctrl tx on|off <port_id>: "
6997 "Change tx flow control parameter",
6999 (void *)&cmd_lfc_set_set,
7000 (void *)&cmd_lfc_set_flow_ctrl,
7001 (void *)&cmd_lfc_set_tx,
7002 (void *)&cmd_lfc_set_tx_mode,
7003 (void *)&cmd_lfc_set_portid,
7008 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
7009 .f = cmd_link_flow_ctrl_set_parsed,
7010 .data = (void *)&cmd_link_flow_control_set_hw,
7011 .help_str = "set flow_ctrl high_water <value> <port_id>: "
7012 "Change high water flow control parameter",
7014 (void *)&cmd_lfc_set_set,
7015 (void *)&cmd_lfc_set_flow_ctrl,
7016 (void *)&cmd_lfc_set_high_water_str,
7017 (void *)&cmd_lfc_set_high_water,
7018 (void *)&cmd_lfc_set_portid,
7023 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
7024 .f = cmd_link_flow_ctrl_set_parsed,
7025 .data = (void *)&cmd_link_flow_control_set_lw,
7026 .help_str = "set flow_ctrl low_water <value> <port_id>: "
7027 "Change low water flow control parameter",
7029 (void *)&cmd_lfc_set_set,
7030 (void *)&cmd_lfc_set_flow_ctrl,
7031 (void *)&cmd_lfc_set_low_water_str,
7032 (void *)&cmd_lfc_set_low_water,
7033 (void *)&cmd_lfc_set_portid,
7038 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
7039 .f = cmd_link_flow_ctrl_set_parsed,
7040 .data = (void *)&cmd_link_flow_control_set_pt,
7041 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
7042 "Change pause time flow control parameter",
7044 (void *)&cmd_lfc_set_set,
7045 (void *)&cmd_lfc_set_flow_ctrl,
7046 (void *)&cmd_lfc_set_pause_time_str,
7047 (void *)&cmd_lfc_set_pause_time,
7048 (void *)&cmd_lfc_set_portid,
7053 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
7054 .f = cmd_link_flow_ctrl_set_parsed,
7055 .data = (void *)&cmd_link_flow_control_set_xon,
7056 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
7057 "Change send_xon flow control parameter",
7059 (void *)&cmd_lfc_set_set,
7060 (void *)&cmd_lfc_set_flow_ctrl,
7061 (void *)&cmd_lfc_set_send_xon_str,
7062 (void *)&cmd_lfc_set_send_xon,
7063 (void *)&cmd_lfc_set_portid,
7068 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
7069 .f = cmd_link_flow_ctrl_set_parsed,
7070 .data = (void *)&cmd_link_flow_control_set_macfwd,
7071 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
7072 "Change mac ctrl fwd flow control parameter",
7074 (void *)&cmd_lfc_set_set,
7075 (void *)&cmd_lfc_set_flow_ctrl,
7076 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
7077 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
7078 (void *)&cmd_lfc_set_portid,
7083 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
7084 .f = cmd_link_flow_ctrl_set_parsed,
7085 .data = (void *)&cmd_link_flow_control_set_autoneg,
7086 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
7087 "Change autoneg flow control parameter",
7089 (void *)&cmd_lfc_set_set,
7090 (void *)&cmd_lfc_set_flow_ctrl,
7091 (void *)&cmd_lfc_set_autoneg_str,
7092 (void *)&cmd_lfc_set_autoneg,
7093 (void *)&cmd_lfc_set_portid,
7099 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
7100 __rte_unused struct cmdline *cl,
7103 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
7104 cmdline_parse_inst_t *cmd = data;
7105 struct rte_eth_fc_conf fc_conf;
7111 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7112 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7113 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7114 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7116 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
7117 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7120 /* Partial command line, retrieve current configuration */
7122 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
7124 printf("cannot get current flow ctrl parameters, return"
7125 "code = %d\n", ret);
7129 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
7130 (fc_conf.mode == RTE_FC_FULL))
7132 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
7133 (fc_conf.mode == RTE_FC_FULL))
7137 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
7138 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
7140 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
7141 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
7143 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
7145 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
7146 fc_conf.high_water = res->high_water;
7148 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
7149 fc_conf.low_water = res->low_water;
7151 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
7152 fc_conf.pause_time = res->pause_time;
7154 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
7155 fc_conf.send_xon = res->send_xon;
7157 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
7158 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
7159 fc_conf.mac_ctrl_frame_fwd = 1;
7161 fc_conf.mac_ctrl_frame_fwd = 0;
7164 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
7165 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
7167 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
7169 printf("bad flow contrl parameter, return code = %d \n", ret);
7172 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
7173 struct cmd_priority_flow_ctrl_set_result {
7174 cmdline_fixed_string_t set;
7175 cmdline_fixed_string_t pfc_ctrl;
7176 cmdline_fixed_string_t rx;
7177 cmdline_fixed_string_t rx_pfc_mode;
7178 cmdline_fixed_string_t tx;
7179 cmdline_fixed_string_t tx_pfc_mode;
7180 uint32_t high_water;
7182 uint16_t pause_time;
7188 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
7189 __rte_unused struct cmdline *cl,
7190 __rte_unused void *data)
7192 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
7193 struct rte_eth_pfc_conf pfc_conf;
7194 int rx_fc_enable, tx_fc_enable;
7198 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7199 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7200 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7201 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7203 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
7204 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7207 memset(&pfc_conf, 0, sizeof(struct rte_eth_pfc_conf));
7208 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
7209 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
7210 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
7211 pfc_conf.fc.high_water = res->high_water;
7212 pfc_conf.fc.low_water = res->low_water;
7213 pfc_conf.fc.pause_time = res->pause_time;
7214 pfc_conf.priority = res->priority;
7216 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
7218 printf("bad priority flow contrl parameter, return code = %d \n", ret);
7221 cmdline_parse_token_string_t cmd_pfc_set_set =
7222 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7224 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
7225 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7226 pfc_ctrl, "pfc_ctrl");
7227 cmdline_parse_token_string_t cmd_pfc_set_rx =
7228 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7230 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
7231 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7232 rx_pfc_mode, "on#off");
7233 cmdline_parse_token_string_t cmd_pfc_set_tx =
7234 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7236 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
7237 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7238 tx_pfc_mode, "on#off");
7239 cmdline_parse_token_num_t cmd_pfc_set_high_water =
7240 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7241 high_water, RTE_UINT32);
7242 cmdline_parse_token_num_t cmd_pfc_set_low_water =
7243 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7244 low_water, RTE_UINT32);
7245 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
7246 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7247 pause_time, RTE_UINT16);
7248 cmdline_parse_token_num_t cmd_pfc_set_priority =
7249 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7250 priority, RTE_UINT8);
7251 cmdline_parse_token_num_t cmd_pfc_set_portid =
7252 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7253 port_id, RTE_UINT16);
7255 cmdline_parse_inst_t cmd_priority_flow_control_set = {
7256 .f = cmd_priority_flow_ctrl_set_parsed,
7258 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
7259 "<pause_time> <priority> <port_id>: "
7260 "Configure the Ethernet priority flow control",
7262 (void *)&cmd_pfc_set_set,
7263 (void *)&cmd_pfc_set_flow_ctrl,
7264 (void *)&cmd_pfc_set_rx,
7265 (void *)&cmd_pfc_set_rx_mode,
7266 (void *)&cmd_pfc_set_tx,
7267 (void *)&cmd_pfc_set_tx_mode,
7268 (void *)&cmd_pfc_set_high_water,
7269 (void *)&cmd_pfc_set_low_water,
7270 (void *)&cmd_pfc_set_pause_time,
7271 (void *)&cmd_pfc_set_priority,
7272 (void *)&cmd_pfc_set_portid,
7277 /* *** RESET CONFIGURATION *** */
7278 struct cmd_reset_result {
7279 cmdline_fixed_string_t reset;
7280 cmdline_fixed_string_t def;
7283 static void cmd_reset_parsed(__rte_unused void *parsed_result,
7285 __rte_unused void *data)
7287 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
7288 set_def_fwd_config();
7291 cmdline_parse_token_string_t cmd_reset_set =
7292 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
7293 cmdline_parse_token_string_t cmd_reset_def =
7294 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
7297 cmdline_parse_inst_t cmd_reset = {
7298 .f = cmd_reset_parsed,
7300 .help_str = "set default: Reset default forwarding configuration",
7302 (void *)&cmd_reset_set,
7303 (void *)&cmd_reset_def,
7308 /* *** START FORWARDING *** */
7309 struct cmd_start_result {
7310 cmdline_fixed_string_t start;
7313 cmdline_parse_token_string_t cmd_start_start =
7314 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
7316 static void cmd_start_parsed(__rte_unused void *parsed_result,
7317 __rte_unused struct cmdline *cl,
7318 __rte_unused void *data)
7320 start_packet_forwarding(0);
7323 cmdline_parse_inst_t cmd_start = {
7324 .f = cmd_start_parsed,
7326 .help_str = "start: Start packet forwarding",
7328 (void *)&cmd_start_start,
7333 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7334 struct cmd_start_tx_first_result {
7335 cmdline_fixed_string_t start;
7336 cmdline_fixed_string_t tx_first;
7340 cmd_start_tx_first_parsed(__rte_unused void *parsed_result,
7341 __rte_unused struct cmdline *cl,
7342 __rte_unused void *data)
7344 start_packet_forwarding(1);
7347 cmdline_parse_token_string_t cmd_start_tx_first_start =
7348 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7350 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7351 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7352 tx_first, "tx_first");
7354 cmdline_parse_inst_t cmd_start_tx_first = {
7355 .f = cmd_start_tx_first_parsed,
7357 .help_str = "start tx_first: Start packet forwarding, "
7358 "after sending 1 burst of packets",
7360 (void *)&cmd_start_tx_first_start,
7361 (void *)&cmd_start_tx_first_tx_first,
7366 /* *** START FORWARDING WITH N TX BURST FIRST *** */
7367 struct cmd_start_tx_first_n_result {
7368 cmdline_fixed_string_t start;
7369 cmdline_fixed_string_t tx_first;
7374 cmd_start_tx_first_n_parsed(void *parsed_result,
7375 __rte_unused struct cmdline *cl,
7376 __rte_unused void *data)
7378 struct cmd_start_tx_first_n_result *res = parsed_result;
7380 start_packet_forwarding(res->tx_num);
7383 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7384 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7386 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7387 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7388 tx_first, "tx_first");
7389 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7390 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7391 tx_num, RTE_UINT32);
7393 cmdline_parse_inst_t cmd_start_tx_first_n = {
7394 .f = cmd_start_tx_first_n_parsed,
7396 .help_str = "start tx_first <num>: "
7397 "packet forwarding, after sending <num> bursts of packets",
7399 (void *)&cmd_start_tx_first_n_start,
7400 (void *)&cmd_start_tx_first_n_tx_first,
7401 (void *)&cmd_start_tx_first_n_tx_num,
7406 /* *** SET LINK UP *** */
7407 struct cmd_set_link_up_result {
7408 cmdline_fixed_string_t set;
7409 cmdline_fixed_string_t link_up;
7410 cmdline_fixed_string_t port;
7414 cmdline_parse_token_string_t cmd_set_link_up_set =
7415 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7416 cmdline_parse_token_string_t cmd_set_link_up_link_up =
7417 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7419 cmdline_parse_token_string_t cmd_set_link_up_port =
7420 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7421 cmdline_parse_token_num_t cmd_set_link_up_port_id =
7422 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id,
7425 static void cmd_set_link_up_parsed(__rte_unused void *parsed_result,
7426 __rte_unused struct cmdline *cl,
7427 __rte_unused void *data)
7429 struct cmd_set_link_up_result *res = parsed_result;
7430 dev_set_link_up(res->port_id);
7433 cmdline_parse_inst_t cmd_set_link_up = {
7434 .f = cmd_set_link_up_parsed,
7436 .help_str = "set link-up port <port id>",
7438 (void *)&cmd_set_link_up_set,
7439 (void *)&cmd_set_link_up_link_up,
7440 (void *)&cmd_set_link_up_port,
7441 (void *)&cmd_set_link_up_port_id,
7446 /* *** SET LINK DOWN *** */
7447 struct cmd_set_link_down_result {
7448 cmdline_fixed_string_t set;
7449 cmdline_fixed_string_t link_down;
7450 cmdline_fixed_string_t port;
7454 cmdline_parse_token_string_t cmd_set_link_down_set =
7455 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
7456 cmdline_parse_token_string_t cmd_set_link_down_link_down =
7457 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
7459 cmdline_parse_token_string_t cmd_set_link_down_port =
7460 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
7461 cmdline_parse_token_num_t cmd_set_link_down_port_id =
7462 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id,
7465 static void cmd_set_link_down_parsed(
7466 __rte_unused void *parsed_result,
7467 __rte_unused struct cmdline *cl,
7468 __rte_unused void *data)
7470 struct cmd_set_link_down_result *res = parsed_result;
7471 dev_set_link_down(res->port_id);
7474 cmdline_parse_inst_t cmd_set_link_down = {
7475 .f = cmd_set_link_down_parsed,
7477 .help_str = "set link-down port <port id>",
7479 (void *)&cmd_set_link_down_set,
7480 (void *)&cmd_set_link_down_link_down,
7481 (void *)&cmd_set_link_down_port,
7482 (void *)&cmd_set_link_down_port_id,
7487 /* *** SHOW CFG *** */
7488 struct cmd_showcfg_result {
7489 cmdline_fixed_string_t show;
7490 cmdline_fixed_string_t cfg;
7491 cmdline_fixed_string_t what;
7494 static void cmd_showcfg_parsed(void *parsed_result,
7495 __rte_unused struct cmdline *cl,
7496 __rte_unused void *data)
7498 struct cmd_showcfg_result *res = parsed_result;
7499 if (!strcmp(res->what, "rxtx"))
7500 rxtx_config_display();
7501 else if (!strcmp(res->what, "cores"))
7502 fwd_lcores_config_display();
7503 else if (!strcmp(res->what, "fwd"))
7504 pkt_fwd_config_display(&cur_fwd_config);
7505 else if (!strcmp(res->what, "rxoffs"))
7506 show_rx_pkt_offsets();
7507 else if (!strcmp(res->what, "rxpkts"))
7508 show_rx_pkt_segments();
7509 else if (!strcmp(res->what, "txpkts"))
7510 show_tx_pkt_segments();
7511 else if (!strcmp(res->what, "txtimes"))
7512 show_tx_pkt_times();
7515 cmdline_parse_token_string_t cmd_showcfg_show =
7516 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7517 cmdline_parse_token_string_t cmd_showcfg_port =
7518 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7519 cmdline_parse_token_string_t cmd_showcfg_what =
7520 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7521 "rxtx#cores#fwd#rxoffs#rxpkts#txpkts#txtimes");
7523 cmdline_parse_inst_t cmd_showcfg = {
7524 .f = cmd_showcfg_parsed,
7526 .help_str = "show config rxtx|cores|fwd|rxoffs|rxpkts|txpkts|txtimes",
7528 (void *)&cmd_showcfg_show,
7529 (void *)&cmd_showcfg_port,
7530 (void *)&cmd_showcfg_what,
7535 /* *** SHOW ALL PORT INFO *** */
7536 struct cmd_showportall_result {
7537 cmdline_fixed_string_t show;
7538 cmdline_fixed_string_t port;
7539 cmdline_fixed_string_t what;
7540 cmdline_fixed_string_t all;
7543 static void cmd_showportall_parsed(void *parsed_result,
7544 __rte_unused struct cmdline *cl,
7545 __rte_unused void *data)
7549 struct cmd_showportall_result *res = parsed_result;
7550 if (!strcmp(res->show, "clear")) {
7551 if (!strcmp(res->what, "stats"))
7552 RTE_ETH_FOREACH_DEV(i)
7554 else if (!strcmp(res->what, "xstats"))
7555 RTE_ETH_FOREACH_DEV(i)
7556 nic_xstats_clear(i);
7557 } else if (!strcmp(res->what, "info"))
7558 RTE_ETH_FOREACH_DEV(i)
7559 port_infos_display(i);
7560 else if (!strcmp(res->what, "summary")) {
7561 port_summary_header_display();
7562 RTE_ETH_FOREACH_DEV(i)
7563 port_summary_display(i);
7565 else if (!strcmp(res->what, "stats"))
7566 RTE_ETH_FOREACH_DEV(i)
7567 nic_stats_display(i);
7568 else if (!strcmp(res->what, "xstats"))
7569 RTE_ETH_FOREACH_DEV(i)
7570 nic_xstats_display(i);
7571 #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
7572 else if (!strcmp(res->what, "fdir"))
7573 RTE_ETH_FOREACH_DEV(i)
7576 else if (!strcmp(res->what, "dcb_tc"))
7577 RTE_ETH_FOREACH_DEV(i)
7578 port_dcb_info_display(i);
7581 cmdline_parse_token_string_t cmd_showportall_show =
7582 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7584 cmdline_parse_token_string_t cmd_showportall_port =
7585 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7586 cmdline_parse_token_string_t cmd_showportall_what =
7587 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7588 "info#summary#stats#xstats#fdir#dcb_tc");
7589 cmdline_parse_token_string_t cmd_showportall_all =
7590 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7591 cmdline_parse_inst_t cmd_showportall = {
7592 .f = cmd_showportall_parsed,
7594 .help_str = "show|clear port "
7595 "info|summary|stats|xstats|fdir|dcb_tc all",
7597 (void *)&cmd_showportall_show,
7598 (void *)&cmd_showportall_port,
7599 (void *)&cmd_showportall_what,
7600 (void *)&cmd_showportall_all,
7605 /* *** SHOW PORT INFO *** */
7606 struct cmd_showport_result {
7607 cmdline_fixed_string_t show;
7608 cmdline_fixed_string_t port;
7609 cmdline_fixed_string_t what;
7613 static void cmd_showport_parsed(void *parsed_result,
7614 __rte_unused struct cmdline *cl,
7615 __rte_unused void *data)
7617 struct cmd_showport_result *res = parsed_result;
7618 if (!strcmp(res->show, "clear")) {
7619 if (!strcmp(res->what, "stats"))
7620 nic_stats_clear(res->portnum);
7621 else if (!strcmp(res->what, "xstats"))
7622 nic_xstats_clear(res->portnum);
7623 } else if (!strcmp(res->what, "info"))
7624 port_infos_display(res->portnum);
7625 else if (!strcmp(res->what, "summary")) {
7626 port_summary_header_display();
7627 port_summary_display(res->portnum);
7629 else if (!strcmp(res->what, "stats"))
7630 nic_stats_display(res->portnum);
7631 else if (!strcmp(res->what, "xstats"))
7632 nic_xstats_display(res->portnum);
7633 #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
7634 else if (!strcmp(res->what, "fdir"))
7635 fdir_get_infos(res->portnum);
7637 else if (!strcmp(res->what, "dcb_tc"))
7638 port_dcb_info_display(res->portnum);
7641 cmdline_parse_token_string_t cmd_showport_show =
7642 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7644 cmdline_parse_token_string_t cmd_showport_port =
7645 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7646 cmdline_parse_token_string_t cmd_showport_what =
7647 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7648 "info#summary#stats#xstats#fdir#dcb_tc");
7649 cmdline_parse_token_num_t cmd_showport_portnum =
7650 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, RTE_UINT16);
7652 cmdline_parse_inst_t cmd_showport = {
7653 .f = cmd_showport_parsed,
7655 .help_str = "show|clear port "
7656 "info|summary|stats|xstats|fdir|dcb_tc "
7659 (void *)&cmd_showport_show,
7660 (void *)&cmd_showport_port,
7661 (void *)&cmd_showport_what,
7662 (void *)&cmd_showport_portnum,
7667 /* *** SHOW DEVICE INFO *** */
7668 struct cmd_showdevice_result {
7669 cmdline_fixed_string_t show;
7670 cmdline_fixed_string_t device;
7671 cmdline_fixed_string_t what;
7672 cmdline_fixed_string_t identifier;
7675 static void cmd_showdevice_parsed(void *parsed_result,
7676 __rte_unused struct cmdline *cl,
7677 __rte_unused void *data)
7679 struct cmd_showdevice_result *res = parsed_result;
7680 if (!strcmp(res->what, "info")) {
7681 if (!strcmp(res->identifier, "all"))
7682 device_infos_display(NULL);
7684 device_infos_display(res->identifier);
7688 cmdline_parse_token_string_t cmd_showdevice_show =
7689 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show,
7691 cmdline_parse_token_string_t cmd_showdevice_device =
7692 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device");
7693 cmdline_parse_token_string_t cmd_showdevice_what =
7694 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what,
7696 cmdline_parse_token_string_t cmd_showdevice_identifier =
7697 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result,
7700 cmdline_parse_inst_t cmd_showdevice = {
7701 .f = cmd_showdevice_parsed,
7703 .help_str = "show device info <identifier>|all",
7705 (void *)&cmd_showdevice_show,
7706 (void *)&cmd_showdevice_device,
7707 (void *)&cmd_showdevice_what,
7708 (void *)&cmd_showdevice_identifier,
7713 /* *** SHOW MODULE EEPROM/EEPROM port INFO *** */
7714 struct cmd_showeeprom_result {
7715 cmdline_fixed_string_t show;
7716 cmdline_fixed_string_t port;
7718 cmdline_fixed_string_t type;
7721 static void cmd_showeeprom_parsed(void *parsed_result,
7722 __rte_unused struct cmdline *cl,
7723 __rte_unused void *data)
7725 struct cmd_showeeprom_result *res = parsed_result;
7727 if (!strcmp(res->type, "eeprom"))
7728 port_eeprom_display(res->portnum);
7729 else if (!strcmp(res->type, "module_eeprom"))
7730 port_module_eeprom_display(res->portnum);
7732 printf("Unknown argument\n");
7735 cmdline_parse_token_string_t cmd_showeeprom_show =
7736 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, show, "show");
7737 cmdline_parse_token_string_t cmd_showeeprom_port =
7738 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, port, "port");
7739 cmdline_parse_token_num_t cmd_showeeprom_portnum =
7740 TOKEN_NUM_INITIALIZER(struct cmd_showeeprom_result, portnum,
7742 cmdline_parse_token_string_t cmd_showeeprom_type =
7743 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, type, "module_eeprom#eeprom");
7745 cmdline_parse_inst_t cmd_showeeprom = {
7746 .f = cmd_showeeprom_parsed,
7748 .help_str = "show port <port_id> module_eeprom|eeprom",
7750 (void *)&cmd_showeeprom_show,
7751 (void *)&cmd_showeeprom_port,
7752 (void *)&cmd_showeeprom_portnum,
7753 (void *)&cmd_showeeprom_type,
7758 /* *** SHOW QUEUE INFO *** */
7759 struct cmd_showqueue_result {
7760 cmdline_fixed_string_t show;
7761 cmdline_fixed_string_t type;
7762 cmdline_fixed_string_t what;
7768 cmd_showqueue_parsed(void *parsed_result,
7769 __rte_unused struct cmdline *cl,
7770 __rte_unused void *data)
7772 struct cmd_showqueue_result *res = parsed_result;
7774 if (!strcmp(res->type, "rxq"))
7775 rx_queue_infos_display(res->portnum, res->queuenum);
7776 else if (!strcmp(res->type, "txq"))
7777 tx_queue_infos_display(res->portnum, res->queuenum);
7780 cmdline_parse_token_string_t cmd_showqueue_show =
7781 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
7782 cmdline_parse_token_string_t cmd_showqueue_type =
7783 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
7784 cmdline_parse_token_string_t cmd_showqueue_what =
7785 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
7786 cmdline_parse_token_num_t cmd_showqueue_portnum =
7787 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum,
7789 cmdline_parse_token_num_t cmd_showqueue_queuenum =
7790 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum,
7793 cmdline_parse_inst_t cmd_showqueue = {
7794 .f = cmd_showqueue_parsed,
7796 .help_str = "show rxq|txq info <port_id> <queue_id>",
7798 (void *)&cmd_showqueue_show,
7799 (void *)&cmd_showqueue_type,
7800 (void *)&cmd_showqueue_what,
7801 (void *)&cmd_showqueue_portnum,
7802 (void *)&cmd_showqueue_queuenum,
7807 /* show/clear fwd engine statistics */
7809 cmdline_fixed_string_t action;
7810 cmdline_fixed_string_t fwd;
7811 cmdline_fixed_string_t stats;
7812 cmdline_fixed_string_t all;
7815 cmdline_parse_token_string_t cmd_fwd_action =
7816 TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
7817 cmdline_parse_token_string_t cmd_fwd_fwd =
7818 TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
7819 cmdline_parse_token_string_t cmd_fwd_stats =
7820 TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
7821 cmdline_parse_token_string_t cmd_fwd_all =
7822 TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
7825 cmd_showfwdall_parsed(void *parsed_result,
7826 __rte_unused struct cmdline *cl,
7827 __rte_unused void *data)
7829 struct fwd_result *res = parsed_result;
7831 if (!strcmp(res->action, "show"))
7832 fwd_stats_display();
7837 static cmdline_parse_inst_t cmd_showfwdall = {
7838 .f = cmd_showfwdall_parsed,
7840 .help_str = "show|clear fwd stats all",
7842 (void *)&cmd_fwd_action,
7843 (void *)&cmd_fwd_fwd,
7844 (void *)&cmd_fwd_stats,
7845 (void *)&cmd_fwd_all,
7850 /* *** READ PORT REGISTER *** */
7851 struct cmd_read_reg_result {
7852 cmdline_fixed_string_t read;
7853 cmdline_fixed_string_t reg;
7859 cmd_read_reg_parsed(void *parsed_result,
7860 __rte_unused struct cmdline *cl,
7861 __rte_unused void *data)
7863 struct cmd_read_reg_result *res = parsed_result;
7864 port_reg_display(res->port_id, res->reg_off);
7867 cmdline_parse_token_string_t cmd_read_reg_read =
7868 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
7869 cmdline_parse_token_string_t cmd_read_reg_reg =
7870 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
7871 cmdline_parse_token_num_t cmd_read_reg_port_id =
7872 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, RTE_UINT16);
7873 cmdline_parse_token_num_t cmd_read_reg_reg_off =
7874 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, RTE_UINT32);
7876 cmdline_parse_inst_t cmd_read_reg = {
7877 .f = cmd_read_reg_parsed,
7879 .help_str = "read reg <port_id> <reg_off>",
7881 (void *)&cmd_read_reg_read,
7882 (void *)&cmd_read_reg_reg,
7883 (void *)&cmd_read_reg_port_id,
7884 (void *)&cmd_read_reg_reg_off,
7889 /* *** READ PORT REGISTER BIT FIELD *** */
7890 struct cmd_read_reg_bit_field_result {
7891 cmdline_fixed_string_t read;
7892 cmdline_fixed_string_t regfield;
7900 cmd_read_reg_bit_field_parsed(void *parsed_result,
7901 __rte_unused struct cmdline *cl,
7902 __rte_unused void *data)
7904 struct cmd_read_reg_bit_field_result *res = parsed_result;
7905 port_reg_bit_field_display(res->port_id, res->reg_off,
7906 res->bit1_pos, res->bit2_pos);
7909 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
7910 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
7912 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
7913 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
7914 regfield, "regfield");
7915 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
7916 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
7918 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
7919 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
7921 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
7922 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
7924 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
7925 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
7928 cmdline_parse_inst_t cmd_read_reg_bit_field = {
7929 .f = cmd_read_reg_bit_field_parsed,
7931 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
7932 "Read register bit field between bit_x and bit_y included",
7934 (void *)&cmd_read_reg_bit_field_read,
7935 (void *)&cmd_read_reg_bit_field_regfield,
7936 (void *)&cmd_read_reg_bit_field_port_id,
7937 (void *)&cmd_read_reg_bit_field_reg_off,
7938 (void *)&cmd_read_reg_bit_field_bit1_pos,
7939 (void *)&cmd_read_reg_bit_field_bit2_pos,
7944 /* *** READ PORT REGISTER BIT *** */
7945 struct cmd_read_reg_bit_result {
7946 cmdline_fixed_string_t read;
7947 cmdline_fixed_string_t regbit;
7954 cmd_read_reg_bit_parsed(void *parsed_result,
7955 __rte_unused struct cmdline *cl,
7956 __rte_unused void *data)
7958 struct cmd_read_reg_bit_result *res = parsed_result;
7959 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
7962 cmdline_parse_token_string_t cmd_read_reg_bit_read =
7963 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
7964 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
7965 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
7967 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
7968 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id,
7970 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
7971 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off,
7973 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
7974 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos,
7977 cmdline_parse_inst_t cmd_read_reg_bit = {
7978 .f = cmd_read_reg_bit_parsed,
7980 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
7982 (void *)&cmd_read_reg_bit_read,
7983 (void *)&cmd_read_reg_bit_regbit,
7984 (void *)&cmd_read_reg_bit_port_id,
7985 (void *)&cmd_read_reg_bit_reg_off,
7986 (void *)&cmd_read_reg_bit_bit_pos,
7991 /* *** WRITE PORT REGISTER *** */
7992 struct cmd_write_reg_result {
7993 cmdline_fixed_string_t write;
7994 cmdline_fixed_string_t reg;
8001 cmd_write_reg_parsed(void *parsed_result,
8002 __rte_unused struct cmdline *cl,
8003 __rte_unused void *data)
8005 struct cmd_write_reg_result *res = parsed_result;
8006 port_reg_set(res->port_id, res->reg_off, res->value);
8009 cmdline_parse_token_string_t cmd_write_reg_write =
8010 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
8011 cmdline_parse_token_string_t cmd_write_reg_reg =
8012 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
8013 cmdline_parse_token_num_t cmd_write_reg_port_id =
8014 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, RTE_UINT16);
8015 cmdline_parse_token_num_t cmd_write_reg_reg_off =
8016 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, RTE_UINT32);
8017 cmdline_parse_token_num_t cmd_write_reg_value =
8018 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, RTE_UINT32);
8020 cmdline_parse_inst_t cmd_write_reg = {
8021 .f = cmd_write_reg_parsed,
8023 .help_str = "write reg <port_id> <reg_off> <reg_value>",
8025 (void *)&cmd_write_reg_write,
8026 (void *)&cmd_write_reg_reg,
8027 (void *)&cmd_write_reg_port_id,
8028 (void *)&cmd_write_reg_reg_off,
8029 (void *)&cmd_write_reg_value,
8034 /* *** WRITE PORT REGISTER BIT FIELD *** */
8035 struct cmd_write_reg_bit_field_result {
8036 cmdline_fixed_string_t write;
8037 cmdline_fixed_string_t regfield;
8046 cmd_write_reg_bit_field_parsed(void *parsed_result,
8047 __rte_unused struct cmdline *cl,
8048 __rte_unused void *data)
8050 struct cmd_write_reg_bit_field_result *res = parsed_result;
8051 port_reg_bit_field_set(res->port_id, res->reg_off,
8052 res->bit1_pos, res->bit2_pos, res->value);
8055 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
8056 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
8058 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
8059 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
8060 regfield, "regfield");
8061 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
8062 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
8064 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
8065 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
8067 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
8068 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
8070 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
8071 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
8073 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
8074 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
8077 cmdline_parse_inst_t cmd_write_reg_bit_field = {
8078 .f = cmd_write_reg_bit_field_parsed,
8080 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
8082 "Set register bit field between bit_x and bit_y included",
8084 (void *)&cmd_write_reg_bit_field_write,
8085 (void *)&cmd_write_reg_bit_field_regfield,
8086 (void *)&cmd_write_reg_bit_field_port_id,
8087 (void *)&cmd_write_reg_bit_field_reg_off,
8088 (void *)&cmd_write_reg_bit_field_bit1_pos,
8089 (void *)&cmd_write_reg_bit_field_bit2_pos,
8090 (void *)&cmd_write_reg_bit_field_value,
8095 /* *** WRITE PORT REGISTER BIT *** */
8096 struct cmd_write_reg_bit_result {
8097 cmdline_fixed_string_t write;
8098 cmdline_fixed_string_t regbit;
8106 cmd_write_reg_bit_parsed(void *parsed_result,
8107 __rte_unused struct cmdline *cl,
8108 __rte_unused void *data)
8110 struct cmd_write_reg_bit_result *res = parsed_result;
8111 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
8114 cmdline_parse_token_string_t cmd_write_reg_bit_write =
8115 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
8117 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
8118 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
8120 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
8121 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id,
8123 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
8124 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off,
8126 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
8127 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos,
8129 cmdline_parse_token_num_t cmd_write_reg_bit_value =
8130 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value,
8133 cmdline_parse_inst_t cmd_write_reg_bit = {
8134 .f = cmd_write_reg_bit_parsed,
8136 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
8139 (void *)&cmd_write_reg_bit_write,
8140 (void *)&cmd_write_reg_bit_regbit,
8141 (void *)&cmd_write_reg_bit_port_id,
8142 (void *)&cmd_write_reg_bit_reg_off,
8143 (void *)&cmd_write_reg_bit_bit_pos,
8144 (void *)&cmd_write_reg_bit_value,
8149 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
8150 struct cmd_read_rxd_txd_result {
8151 cmdline_fixed_string_t read;
8152 cmdline_fixed_string_t rxd_txd;
8159 cmd_read_rxd_txd_parsed(void *parsed_result,
8160 __rte_unused struct cmdline *cl,
8161 __rte_unused void *data)
8163 struct cmd_read_rxd_txd_result *res = parsed_result;
8165 if (!strcmp(res->rxd_txd, "rxd"))
8166 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8167 else if (!strcmp(res->rxd_txd, "txd"))
8168 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8171 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
8172 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
8173 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
8174 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
8176 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
8177 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id,
8179 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
8180 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id,
8182 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
8183 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id,
8186 cmdline_parse_inst_t cmd_read_rxd_txd = {
8187 .f = cmd_read_rxd_txd_parsed,
8189 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
8191 (void *)&cmd_read_rxd_txd_read,
8192 (void *)&cmd_read_rxd_txd_rxd_txd,
8193 (void *)&cmd_read_rxd_txd_port_id,
8194 (void *)&cmd_read_rxd_txd_queue_id,
8195 (void *)&cmd_read_rxd_txd_desc_id,
8201 struct cmd_quit_result {
8202 cmdline_fixed_string_t quit;
8205 static void cmd_quit_parsed(__rte_unused void *parsed_result,
8207 __rte_unused void *data)
8212 cmdline_parse_token_string_t cmd_quit_quit =
8213 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
8215 cmdline_parse_inst_t cmd_quit = {
8216 .f = cmd_quit_parsed,
8218 .help_str = "quit: Exit application",
8220 (void *)&cmd_quit_quit,
8225 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
8226 struct cmd_mac_addr_result {
8227 cmdline_fixed_string_t mac_addr_cmd;
8228 cmdline_fixed_string_t what;
8230 struct rte_ether_addr address;
8233 static void cmd_mac_addr_parsed(void *parsed_result,
8234 __rte_unused struct cmdline *cl,
8235 __rte_unused void *data)
8237 struct cmd_mac_addr_result *res = parsed_result;
8240 if (strcmp(res->what, "add") == 0)
8241 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
8242 else if (strcmp(res->what, "set") == 0)
8243 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
8246 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
8248 /* check the return value and print it if is < 0 */
8250 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
8254 cmdline_parse_token_string_t cmd_mac_addr_cmd =
8255 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
8257 cmdline_parse_token_string_t cmd_mac_addr_what =
8258 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
8260 cmdline_parse_token_num_t cmd_mac_addr_portnum =
8261 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
8263 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
8264 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
8266 cmdline_parse_inst_t cmd_mac_addr = {
8267 .f = cmd_mac_addr_parsed,
8269 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
8270 "Add/Remove/Set MAC address on port_id",
8272 (void *)&cmd_mac_addr_cmd,
8273 (void *)&cmd_mac_addr_what,
8274 (void *)&cmd_mac_addr_portnum,
8275 (void *)&cmd_mac_addr_addr,
8280 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
8281 struct cmd_eth_peer_result {
8282 cmdline_fixed_string_t set;
8283 cmdline_fixed_string_t eth_peer;
8285 cmdline_fixed_string_t peer_addr;
8288 static void cmd_set_eth_peer_parsed(void *parsed_result,
8289 __rte_unused struct cmdline *cl,
8290 __rte_unused void *data)
8292 struct cmd_eth_peer_result *res = parsed_result;
8294 if (test_done == 0) {
8295 printf("Please stop forwarding first\n");
8298 if (!strcmp(res->eth_peer, "eth-peer")) {
8299 set_fwd_eth_peer(res->port_id, res->peer_addr);
8303 cmdline_parse_token_string_t cmd_eth_peer_set =
8304 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
8305 cmdline_parse_token_string_t cmd_eth_peer =
8306 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
8307 cmdline_parse_token_num_t cmd_eth_peer_port_id =
8308 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id,
8310 cmdline_parse_token_string_t cmd_eth_peer_addr =
8311 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
8313 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
8314 .f = cmd_set_eth_peer_parsed,
8316 .help_str = "set eth-peer <port_id> <peer_mac>",
8318 (void *)&cmd_eth_peer_set,
8319 (void *)&cmd_eth_peer,
8320 (void *)&cmd_eth_peer_port_id,
8321 (void *)&cmd_eth_peer_addr,
8326 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
8327 struct cmd_set_qmap_result {
8328 cmdline_fixed_string_t set;
8329 cmdline_fixed_string_t qmap;
8330 cmdline_fixed_string_t what;
8337 cmd_set_qmap_parsed(void *parsed_result,
8338 __rte_unused struct cmdline *cl,
8339 __rte_unused void *data)
8341 struct cmd_set_qmap_result *res = parsed_result;
8342 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
8344 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
8347 cmdline_parse_token_string_t cmd_setqmap_set =
8348 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8350 cmdline_parse_token_string_t cmd_setqmap_qmap =
8351 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8353 cmdline_parse_token_string_t cmd_setqmap_what =
8354 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8356 cmdline_parse_token_num_t cmd_setqmap_portid =
8357 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8358 port_id, RTE_UINT16);
8359 cmdline_parse_token_num_t cmd_setqmap_queueid =
8360 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8361 queue_id, RTE_UINT16);
8362 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
8363 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8364 map_value, RTE_UINT8);
8366 cmdline_parse_inst_t cmd_set_qmap = {
8367 .f = cmd_set_qmap_parsed,
8369 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
8370 "Set statistics mapping value on tx|rx queue_id of port_id",
8372 (void *)&cmd_setqmap_set,
8373 (void *)&cmd_setqmap_qmap,
8374 (void *)&cmd_setqmap_what,
8375 (void *)&cmd_setqmap_portid,
8376 (void *)&cmd_setqmap_queueid,
8377 (void *)&cmd_setqmap_mapvalue,
8382 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
8383 struct cmd_set_xstats_hide_zero_result {
8384 cmdline_fixed_string_t keyword;
8385 cmdline_fixed_string_t name;
8386 cmdline_fixed_string_t on_off;
8390 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
8391 __rte_unused struct cmdline *cl,
8392 __rte_unused void *data)
8394 struct cmd_set_xstats_hide_zero_result *res;
8395 uint16_t on_off = 0;
8397 res = parsed_result;
8398 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8399 set_xstats_hide_zero(on_off);
8402 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
8403 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8405 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
8406 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8407 name, "xstats-hide-zero");
8408 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
8409 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8412 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
8413 .f = cmd_set_xstats_hide_zero_parsed,
8415 .help_str = "set xstats-hide-zero on|off",
8417 (void *)&cmd_set_xstats_hide_zero_keyword,
8418 (void *)&cmd_set_xstats_hide_zero_name,
8419 (void *)&cmd_set_xstats_hide_zero_on_off,
8424 /* *** SET OPTION TO ENABLE MEASUREMENT OF CPU CYCLES *** */
8425 struct cmd_set_record_core_cycles_result {
8426 cmdline_fixed_string_t keyword;
8427 cmdline_fixed_string_t name;
8428 cmdline_fixed_string_t on_off;
8432 cmd_set_record_core_cycles_parsed(void *parsed_result,
8433 __rte_unused struct cmdline *cl,
8434 __rte_unused void *data)
8436 struct cmd_set_record_core_cycles_result *res;
8437 uint16_t on_off = 0;
8439 res = parsed_result;
8440 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8441 set_record_core_cycles(on_off);
8444 cmdline_parse_token_string_t cmd_set_record_core_cycles_keyword =
8445 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8447 cmdline_parse_token_string_t cmd_set_record_core_cycles_name =
8448 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8449 name, "record-core-cycles");
8450 cmdline_parse_token_string_t cmd_set_record_core_cycles_on_off =
8451 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8454 cmdline_parse_inst_t cmd_set_record_core_cycles = {
8455 .f = cmd_set_record_core_cycles_parsed,
8457 .help_str = "set record-core-cycles on|off",
8459 (void *)&cmd_set_record_core_cycles_keyword,
8460 (void *)&cmd_set_record_core_cycles_name,
8461 (void *)&cmd_set_record_core_cycles_on_off,
8466 /* *** SET OPTION TO ENABLE DISPLAY OF RX AND TX BURSTS *** */
8467 struct cmd_set_record_burst_stats_result {
8468 cmdline_fixed_string_t keyword;
8469 cmdline_fixed_string_t name;
8470 cmdline_fixed_string_t on_off;
8474 cmd_set_record_burst_stats_parsed(void *parsed_result,
8475 __rte_unused struct cmdline *cl,
8476 __rte_unused void *data)
8478 struct cmd_set_record_burst_stats_result *res;
8479 uint16_t on_off = 0;
8481 res = parsed_result;
8482 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8483 set_record_burst_stats(on_off);
8486 cmdline_parse_token_string_t cmd_set_record_burst_stats_keyword =
8487 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8489 cmdline_parse_token_string_t cmd_set_record_burst_stats_name =
8490 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8491 name, "record-burst-stats");
8492 cmdline_parse_token_string_t cmd_set_record_burst_stats_on_off =
8493 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8496 cmdline_parse_inst_t cmd_set_record_burst_stats = {
8497 .f = cmd_set_record_burst_stats_parsed,
8499 .help_str = "set record-burst-stats on|off",
8501 (void *)&cmd_set_record_burst_stats_keyword,
8502 (void *)&cmd_set_record_burst_stats_name,
8503 (void *)&cmd_set_record_burst_stats_on_off,
8508 /* *** CONFIGURE UNICAST HASH TABLE *** */
8509 struct cmd_set_uc_hash_table {
8510 cmdline_fixed_string_t set;
8511 cmdline_fixed_string_t port;
8513 cmdline_fixed_string_t what;
8514 struct rte_ether_addr address;
8515 cmdline_fixed_string_t mode;
8519 cmd_set_uc_hash_parsed(void *parsed_result,
8520 __rte_unused struct cmdline *cl,
8521 __rte_unused void *data)
8524 struct cmd_set_uc_hash_table *res = parsed_result;
8526 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8528 if (strcmp(res->what, "uta") == 0)
8529 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
8530 &res->address,(uint8_t)is_on);
8532 printf("bad unicast hash table parameter, return code = %d \n", ret);
8536 cmdline_parse_token_string_t cmd_set_uc_hash_set =
8537 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8539 cmdline_parse_token_string_t cmd_set_uc_hash_port =
8540 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8542 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
8543 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
8544 port_id, RTE_UINT16);
8545 cmdline_parse_token_string_t cmd_set_uc_hash_what =
8546 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8548 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
8549 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
8551 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
8552 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8555 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
8556 .f = cmd_set_uc_hash_parsed,
8558 .help_str = "set port <port_id> uta <mac_addr> on|off)",
8560 (void *)&cmd_set_uc_hash_set,
8561 (void *)&cmd_set_uc_hash_port,
8562 (void *)&cmd_set_uc_hash_portid,
8563 (void *)&cmd_set_uc_hash_what,
8564 (void *)&cmd_set_uc_hash_mac,
8565 (void *)&cmd_set_uc_hash_mode,
8570 struct cmd_set_uc_all_hash_table {
8571 cmdline_fixed_string_t set;
8572 cmdline_fixed_string_t port;
8574 cmdline_fixed_string_t what;
8575 cmdline_fixed_string_t value;
8576 cmdline_fixed_string_t mode;
8580 cmd_set_uc_all_hash_parsed(void *parsed_result,
8581 __rte_unused struct cmdline *cl,
8582 __rte_unused void *data)
8585 struct cmd_set_uc_all_hash_table *res = parsed_result;
8587 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8589 if ((strcmp(res->what, "uta") == 0) &&
8590 (strcmp(res->value, "all") == 0))
8591 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
8593 printf("bad unicast hash table parameter,"
8594 "return code = %d \n", ret);
8597 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
8598 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8600 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
8601 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8603 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
8604 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
8605 port_id, RTE_UINT16);
8606 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
8607 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8609 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
8610 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8612 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
8613 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8616 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
8617 .f = cmd_set_uc_all_hash_parsed,
8619 .help_str = "set port <port_id> uta all on|off",
8621 (void *)&cmd_set_uc_all_hash_set,
8622 (void *)&cmd_set_uc_all_hash_port,
8623 (void *)&cmd_set_uc_all_hash_portid,
8624 (void *)&cmd_set_uc_all_hash_what,
8625 (void *)&cmd_set_uc_all_hash_value,
8626 (void *)&cmd_set_uc_all_hash_mode,
8631 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
8632 struct cmd_set_vf_traffic {
8633 cmdline_fixed_string_t set;
8634 cmdline_fixed_string_t port;
8636 cmdline_fixed_string_t vf;
8638 cmdline_fixed_string_t what;
8639 cmdline_fixed_string_t mode;
8643 cmd_set_vf_traffic_parsed(void *parsed_result,
8644 __rte_unused struct cmdline *cl,
8645 __rte_unused void *data)
8647 struct cmd_set_vf_traffic *res = parsed_result;
8648 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
8649 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8651 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
8654 cmdline_parse_token_string_t cmd_setvf_traffic_set =
8655 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8657 cmdline_parse_token_string_t cmd_setvf_traffic_port =
8658 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8660 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8661 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8662 port_id, RTE_UINT16);
8663 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8664 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8666 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8667 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8669 cmdline_parse_token_string_t cmd_setvf_traffic_what =
8670 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8672 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8673 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8676 cmdline_parse_inst_t cmd_set_vf_traffic = {
8677 .f = cmd_set_vf_traffic_parsed,
8679 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8681 (void *)&cmd_setvf_traffic_set,
8682 (void *)&cmd_setvf_traffic_port,
8683 (void *)&cmd_setvf_traffic_portid,
8684 (void *)&cmd_setvf_traffic_vf,
8685 (void *)&cmd_setvf_traffic_vfid,
8686 (void *)&cmd_setvf_traffic_what,
8687 (void *)&cmd_setvf_traffic_mode,
8692 /* *** CONFIGURE VF RECEIVE MODE *** */
8693 struct cmd_set_vf_rxmode {
8694 cmdline_fixed_string_t set;
8695 cmdline_fixed_string_t port;
8697 cmdline_fixed_string_t vf;
8699 cmdline_fixed_string_t what;
8700 cmdline_fixed_string_t mode;
8701 cmdline_fixed_string_t on;
8705 cmd_set_vf_rxmode_parsed(void *parsed_result,
8706 __rte_unused struct cmdline *cl,
8707 __rte_unused void *data)
8710 uint16_t vf_rxmode = 0;
8711 struct cmd_set_vf_rxmode *res = parsed_result;
8713 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8714 if (!strcmp(res->what,"rxmode")) {
8715 if (!strcmp(res->mode, "AUPE"))
8716 vf_rxmode |= ETH_VMDQ_ACCEPT_UNTAG;
8717 else if (!strcmp(res->mode, "ROPE"))
8718 vf_rxmode |= ETH_VMDQ_ACCEPT_HASH_UC;
8719 else if (!strcmp(res->mode, "BAM"))
8720 vf_rxmode |= ETH_VMDQ_ACCEPT_BROADCAST;
8721 else if (!strncmp(res->mode, "MPE",3))
8722 vf_rxmode |= ETH_VMDQ_ACCEPT_MULTICAST;
8725 RTE_SET_USED(is_on);
8727 #ifdef RTE_NET_IXGBE
8728 if (ret == -ENOTSUP)
8729 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8730 vf_rxmode, (uint8_t)is_on);
8733 if (ret == -ENOTSUP)
8734 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8735 vf_rxmode, (uint8_t)is_on);
8738 printf("bad VF receive mode parameter, return code = %d \n",
8742 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8743 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8745 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8746 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8748 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8749 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8750 port_id, RTE_UINT16);
8751 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8752 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8754 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8755 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8757 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
8758 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8760 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
8761 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8762 mode, "AUPE#ROPE#BAM#MPE");
8763 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
8764 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8767 cmdline_parse_inst_t cmd_set_vf_rxmode = {
8768 .f = cmd_set_vf_rxmode_parsed,
8770 .help_str = "set port <port_id> vf <vf_id> rxmode "
8771 "AUPE|ROPE|BAM|MPE on|off",
8773 (void *)&cmd_set_vf_rxmode_set,
8774 (void *)&cmd_set_vf_rxmode_port,
8775 (void *)&cmd_set_vf_rxmode_portid,
8776 (void *)&cmd_set_vf_rxmode_vf,
8777 (void *)&cmd_set_vf_rxmode_vfid,
8778 (void *)&cmd_set_vf_rxmode_what,
8779 (void *)&cmd_set_vf_rxmode_mode,
8780 (void *)&cmd_set_vf_rxmode_on,
8785 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
8786 struct cmd_vf_mac_addr_result {
8787 cmdline_fixed_string_t mac_addr_cmd;
8788 cmdline_fixed_string_t what;
8789 cmdline_fixed_string_t port;
8791 cmdline_fixed_string_t vf;
8793 struct rte_ether_addr address;
8796 static void cmd_vf_mac_addr_parsed(void *parsed_result,
8797 __rte_unused struct cmdline *cl,
8798 __rte_unused void *data)
8800 struct cmd_vf_mac_addr_result *res = parsed_result;
8803 if (strcmp(res->what, "add") != 0)
8807 if (ret == -ENOTSUP)
8808 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
8812 if (ret == -ENOTSUP)
8813 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
8818 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
8822 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
8823 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8824 mac_addr_cmd,"mac_addr");
8825 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
8826 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8828 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
8829 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8831 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
8832 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8833 port_num, RTE_UINT16);
8834 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
8835 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8837 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
8838 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8840 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
8841 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
8844 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
8845 .f = cmd_vf_mac_addr_parsed,
8847 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
8848 "Add MAC address filtering for a VF on port_id",
8850 (void *)&cmd_vf_mac_addr_cmd,
8851 (void *)&cmd_vf_mac_addr_what,
8852 (void *)&cmd_vf_mac_addr_port,
8853 (void *)&cmd_vf_mac_addr_portnum,
8854 (void *)&cmd_vf_mac_addr_vf,
8855 (void *)&cmd_vf_mac_addr_vfnum,
8856 (void *)&cmd_vf_mac_addr_addr,
8861 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
8862 struct cmd_vf_rx_vlan_filter {
8863 cmdline_fixed_string_t rx_vlan;
8864 cmdline_fixed_string_t what;
8866 cmdline_fixed_string_t port;
8868 cmdline_fixed_string_t vf;
8873 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
8874 __rte_unused struct cmdline *cl,
8875 __rte_unused void *data)
8877 struct cmd_vf_rx_vlan_filter *res = parsed_result;
8880 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
8882 #ifdef RTE_NET_IXGBE
8883 if (ret == -ENOTSUP)
8884 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
8885 res->vlan_id, res->vf_mask, is_add);
8888 if (ret == -ENOTSUP)
8889 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
8890 res->vlan_id, res->vf_mask, is_add);
8893 if (ret == -ENOTSUP)
8894 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
8895 res->vlan_id, res->vf_mask, is_add);
8902 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
8903 res->vlan_id, res->vf_mask);
8906 printf("invalid port_id %d\n", res->port_id);
8909 printf("function not implemented or supported\n");
8912 printf("programming error: (%s)\n", strerror(-ret));
8916 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
8917 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8918 rx_vlan, "rx_vlan");
8919 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
8920 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8922 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
8923 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8924 vlan_id, RTE_UINT16);
8925 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
8926 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8928 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
8929 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8930 port_id, RTE_UINT16);
8931 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
8932 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8934 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
8935 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8936 vf_mask, RTE_UINT64);
8938 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
8939 .f = cmd_vf_rx_vlan_filter_parsed,
8941 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
8942 "(vf_mask = hexadecimal VF mask)",
8944 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
8945 (void *)&cmd_vf_rx_vlan_filter_what,
8946 (void *)&cmd_vf_rx_vlan_filter_vlanid,
8947 (void *)&cmd_vf_rx_vlan_filter_port,
8948 (void *)&cmd_vf_rx_vlan_filter_portid,
8949 (void *)&cmd_vf_rx_vlan_filter_vf,
8950 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
8955 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
8956 struct cmd_queue_rate_limit_result {
8957 cmdline_fixed_string_t set;
8958 cmdline_fixed_string_t port;
8960 cmdline_fixed_string_t queue;
8962 cmdline_fixed_string_t rate;
8966 static void cmd_queue_rate_limit_parsed(void *parsed_result,
8967 __rte_unused struct cmdline *cl,
8968 __rte_unused void *data)
8970 struct cmd_queue_rate_limit_result *res = parsed_result;
8973 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8974 && (strcmp(res->queue, "queue") == 0)
8975 && (strcmp(res->rate, "rate") == 0))
8976 ret = set_queue_rate_limit(res->port_num, res->queue_num,
8979 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
8983 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
8984 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8986 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
8987 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8989 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
8990 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8991 port_num, RTE_UINT16);
8992 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
8993 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8995 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
8996 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8997 queue_num, RTE_UINT8);
8998 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
8999 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9001 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
9002 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9003 rate_num, RTE_UINT16);
9005 cmdline_parse_inst_t cmd_queue_rate_limit = {
9006 .f = cmd_queue_rate_limit_parsed,
9008 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
9009 "Set rate limit for a queue on port_id",
9011 (void *)&cmd_queue_rate_limit_set,
9012 (void *)&cmd_queue_rate_limit_port,
9013 (void *)&cmd_queue_rate_limit_portnum,
9014 (void *)&cmd_queue_rate_limit_queue,
9015 (void *)&cmd_queue_rate_limit_queuenum,
9016 (void *)&cmd_queue_rate_limit_rate,
9017 (void *)&cmd_queue_rate_limit_ratenum,
9022 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
9023 struct cmd_vf_rate_limit_result {
9024 cmdline_fixed_string_t set;
9025 cmdline_fixed_string_t port;
9027 cmdline_fixed_string_t vf;
9029 cmdline_fixed_string_t rate;
9031 cmdline_fixed_string_t q_msk;
9035 static void cmd_vf_rate_limit_parsed(void *parsed_result,
9036 __rte_unused struct cmdline *cl,
9037 __rte_unused void *data)
9039 struct cmd_vf_rate_limit_result *res = parsed_result;
9042 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9043 && (strcmp(res->vf, "vf") == 0)
9044 && (strcmp(res->rate, "rate") == 0)
9045 && (strcmp(res->q_msk, "queue_mask") == 0))
9046 ret = set_vf_rate_limit(res->port_num, res->vf_num,
9047 res->rate_num, res->q_msk_val);
9049 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
9053 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
9054 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9056 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
9057 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9059 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
9060 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9061 port_num, RTE_UINT16);
9062 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
9063 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9065 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
9066 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9068 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
9069 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9071 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
9072 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9073 rate_num, RTE_UINT16);
9074 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
9075 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9076 q_msk, "queue_mask");
9077 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
9078 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9079 q_msk_val, RTE_UINT64);
9081 cmdline_parse_inst_t cmd_vf_rate_limit = {
9082 .f = cmd_vf_rate_limit_parsed,
9084 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
9085 "queue_mask <queue_mask_value>: "
9086 "Set rate limit for queues of VF on port_id",
9088 (void *)&cmd_vf_rate_limit_set,
9089 (void *)&cmd_vf_rate_limit_port,
9090 (void *)&cmd_vf_rate_limit_portnum,
9091 (void *)&cmd_vf_rate_limit_vf,
9092 (void *)&cmd_vf_rate_limit_vfnum,
9093 (void *)&cmd_vf_rate_limit_rate,
9094 (void *)&cmd_vf_rate_limit_ratenum,
9095 (void *)&cmd_vf_rate_limit_q_msk,
9096 (void *)&cmd_vf_rate_limit_q_msk_val,
9101 /* *** CONFIGURE TUNNEL UDP PORT *** */
9102 struct cmd_tunnel_udp_config {
9103 cmdline_fixed_string_t rx_vxlan_port;
9104 cmdline_fixed_string_t what;
9110 cmd_tunnel_udp_config_parsed(void *parsed_result,
9111 __rte_unused struct cmdline *cl,
9112 __rte_unused void *data)
9114 struct cmd_tunnel_udp_config *res = parsed_result;
9115 struct rte_eth_udp_tunnel tunnel_udp;
9118 tunnel_udp.udp_port = res->udp_port;
9119 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9121 if (!strcmp(res->what, "add"))
9122 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9125 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9129 printf("udp tunneling add error: (%s)\n", strerror(-ret));
9132 cmdline_parse_token_string_t cmd_tunnel_udp_config_rx_vxlan_port =
9133 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9134 rx_vxlan_port, "rx_vxlan_port");
9135 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
9136 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9138 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
9139 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9140 udp_port, RTE_UINT16);
9141 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
9142 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9143 port_id, RTE_UINT16);
9145 cmdline_parse_inst_t cmd_tunnel_udp_config = {
9146 .f = cmd_tunnel_udp_config_parsed,
9148 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
9149 "Add/Remove a tunneling UDP port filter",
9151 (void *)&cmd_tunnel_udp_config_rx_vxlan_port,
9152 (void *)&cmd_tunnel_udp_config_what,
9153 (void *)&cmd_tunnel_udp_config_udp_port,
9154 (void *)&cmd_tunnel_udp_config_port_id,
9159 struct cmd_config_tunnel_udp_port {
9160 cmdline_fixed_string_t port;
9161 cmdline_fixed_string_t config;
9163 cmdline_fixed_string_t udp_tunnel_port;
9164 cmdline_fixed_string_t action;
9165 cmdline_fixed_string_t tunnel_type;
9170 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
9171 __rte_unused struct cmdline *cl,
9172 __rte_unused void *data)
9174 struct cmd_config_tunnel_udp_port *res = parsed_result;
9175 struct rte_eth_udp_tunnel tunnel_udp;
9178 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9181 tunnel_udp.udp_port = res->udp_port;
9183 if (!strcmp(res->tunnel_type, "vxlan")) {
9184 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9185 } else if (!strcmp(res->tunnel_type, "geneve")) {
9186 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE;
9187 } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
9188 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9189 } else if (!strcmp(res->tunnel_type, "ecpri")) {
9190 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_ECPRI;
9192 printf("Invalid tunnel type\n");
9196 if (!strcmp(res->action, "add"))
9197 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9200 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9204 printf("udp tunneling port add error: (%s)\n", strerror(-ret));
9207 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
9208 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
9210 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
9211 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
9213 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
9214 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
9216 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
9217 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
9220 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
9221 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
9223 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
9224 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
9225 "vxlan#geneve#vxlan-gpe#ecpri");
9226 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
9227 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
9230 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
9231 .f = cmd_cfg_tunnel_udp_port_parsed,
9233 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|"
9234 "geneve|vxlan-gpe|ecpri <udp_port>",
9236 (void *)&cmd_config_tunnel_udp_port_port,
9237 (void *)&cmd_config_tunnel_udp_port_config,
9238 (void *)&cmd_config_tunnel_udp_port_port_id,
9239 (void *)&cmd_config_tunnel_udp_port_tunnel_port,
9240 (void *)&cmd_config_tunnel_udp_port_action,
9241 (void *)&cmd_config_tunnel_udp_port_tunnel_type,
9242 (void *)&cmd_config_tunnel_udp_port_value,
9247 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
9248 struct cmd_set_mirror_mask_result {
9249 cmdline_fixed_string_t set;
9250 cmdline_fixed_string_t port;
9252 cmdline_fixed_string_t mirror;
9254 cmdline_fixed_string_t what;
9255 cmdline_fixed_string_t value;
9256 cmdline_fixed_string_t dstpool;
9258 cmdline_fixed_string_t on;
9261 cmdline_parse_token_string_t cmd_mirror_mask_set =
9262 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9264 cmdline_parse_token_string_t cmd_mirror_mask_port =
9265 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9267 cmdline_parse_token_num_t cmd_mirror_mask_portid =
9268 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9269 port_id, RTE_UINT16);
9270 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
9271 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9272 mirror, "mirror-rule");
9273 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
9274 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9275 rule_id, RTE_UINT8);
9276 cmdline_parse_token_string_t cmd_mirror_mask_what =
9277 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9278 what, "pool-mirror-up#pool-mirror-down"
9280 cmdline_parse_token_string_t cmd_mirror_mask_value =
9281 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9283 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
9284 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9285 dstpool, "dst-pool");
9286 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
9287 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9288 dstpool_id, RTE_UINT8);
9289 cmdline_parse_token_string_t cmd_mirror_mask_on =
9290 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9294 cmd_set_mirror_mask_parsed(void *parsed_result,
9295 __rte_unused struct cmdline *cl,
9296 __rte_unused void *data)
9299 struct cmd_set_mirror_mask_result *res = parsed_result;
9300 struct rte_eth_mirror_conf mr_conf;
9302 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9304 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
9306 mr_conf.dst_pool = res->dstpool_id;
9308 if (!strcmp(res->what, "pool-mirror-up")) {
9309 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9310 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
9311 } else if (!strcmp(res->what, "pool-mirror-down")) {
9312 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9313 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
9314 } else if (!strcmp(res->what, "vlan-mirror")) {
9315 mr_conf.rule_type = ETH_MIRROR_VLAN;
9316 nb_item = parse_item_list(res->value, "vlan",
9317 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
9321 for (i = 0; i < nb_item; i++) {
9322 if (vlan_list[i] > RTE_ETHER_MAX_VLAN_ID) {
9323 printf("Invalid vlan_id: must be < 4096\n");
9327 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
9328 mr_conf.vlan.vlan_mask |= 1ULL << i;
9332 if (!strcmp(res->on, "on"))
9333 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9336 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9339 printf("mirror rule add error: (%s)\n", strerror(-ret));
9342 cmdline_parse_inst_t cmd_set_mirror_mask = {
9343 .f = cmd_set_mirror_mask_parsed,
9345 .help_str = "set port <port_id> mirror-rule <rule_id> "
9346 "pool-mirror-up|pool-mirror-down|vlan-mirror "
9347 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
9349 (void *)&cmd_mirror_mask_set,
9350 (void *)&cmd_mirror_mask_port,
9351 (void *)&cmd_mirror_mask_portid,
9352 (void *)&cmd_mirror_mask_mirror,
9353 (void *)&cmd_mirror_mask_ruleid,
9354 (void *)&cmd_mirror_mask_what,
9355 (void *)&cmd_mirror_mask_value,
9356 (void *)&cmd_mirror_mask_dstpool,
9357 (void *)&cmd_mirror_mask_poolid,
9358 (void *)&cmd_mirror_mask_on,
9363 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
9364 struct cmd_set_mirror_link_result {
9365 cmdline_fixed_string_t set;
9366 cmdline_fixed_string_t port;
9368 cmdline_fixed_string_t mirror;
9370 cmdline_fixed_string_t what;
9371 cmdline_fixed_string_t dstpool;
9373 cmdline_fixed_string_t on;
9376 cmdline_parse_token_string_t cmd_mirror_link_set =
9377 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9379 cmdline_parse_token_string_t cmd_mirror_link_port =
9380 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9382 cmdline_parse_token_num_t cmd_mirror_link_portid =
9383 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9384 port_id, RTE_UINT16);
9385 cmdline_parse_token_string_t cmd_mirror_link_mirror =
9386 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9387 mirror, "mirror-rule");
9388 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
9389 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9390 rule_id, RTE_UINT8);
9391 cmdline_parse_token_string_t cmd_mirror_link_what =
9392 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9393 what, "uplink-mirror#downlink-mirror");
9394 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
9395 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9396 dstpool, "dst-pool");
9397 cmdline_parse_token_num_t cmd_mirror_link_poolid =
9398 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9399 dstpool_id, RTE_UINT8);
9400 cmdline_parse_token_string_t cmd_mirror_link_on =
9401 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9405 cmd_set_mirror_link_parsed(void *parsed_result,
9406 __rte_unused struct cmdline *cl,
9407 __rte_unused void *data)
9410 struct cmd_set_mirror_link_result *res = parsed_result;
9411 struct rte_eth_mirror_conf mr_conf;
9413 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9414 if (!strcmp(res->what, "uplink-mirror"))
9415 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
9417 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
9419 mr_conf.dst_pool = res->dstpool_id;
9421 if (!strcmp(res->on, "on"))
9422 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9425 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9428 /* check the return value and print it if is < 0 */
9430 printf("mirror rule add error: (%s)\n", strerror(-ret));
9434 cmdline_parse_inst_t cmd_set_mirror_link = {
9435 .f = cmd_set_mirror_link_parsed,
9437 .help_str = "set port <port_id> mirror-rule <rule_id> "
9438 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
9440 (void *)&cmd_mirror_link_set,
9441 (void *)&cmd_mirror_link_port,
9442 (void *)&cmd_mirror_link_portid,
9443 (void *)&cmd_mirror_link_mirror,
9444 (void *)&cmd_mirror_link_ruleid,
9445 (void *)&cmd_mirror_link_what,
9446 (void *)&cmd_mirror_link_dstpool,
9447 (void *)&cmd_mirror_link_poolid,
9448 (void *)&cmd_mirror_link_on,
9453 /* *** RESET VM MIRROR RULE *** */
9454 struct cmd_rm_mirror_rule_result {
9455 cmdline_fixed_string_t reset;
9456 cmdline_fixed_string_t port;
9458 cmdline_fixed_string_t mirror;
9462 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
9463 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9465 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
9466 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9468 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
9469 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9470 port_id, RTE_UINT16);
9471 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
9472 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9473 mirror, "mirror-rule");
9474 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
9475 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9476 rule_id, RTE_UINT8);
9479 cmd_reset_mirror_rule_parsed(void *parsed_result,
9480 __rte_unused struct cmdline *cl,
9481 __rte_unused void *data)
9484 struct cmd_set_mirror_link_result *res = parsed_result;
9486 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
9488 printf("mirror rule remove error: (%s)\n", strerror(-ret));
9491 cmdline_parse_inst_t cmd_reset_mirror_rule = {
9492 .f = cmd_reset_mirror_rule_parsed,
9494 .help_str = "reset port <port_id> mirror-rule <rule_id>",
9496 (void *)&cmd_rm_mirror_rule_reset,
9497 (void *)&cmd_rm_mirror_rule_port,
9498 (void *)&cmd_rm_mirror_rule_portid,
9499 (void *)&cmd_rm_mirror_rule_mirror,
9500 (void *)&cmd_rm_mirror_rule_ruleid,
9505 /* ******************************************************************************** */
9507 struct cmd_dump_result {
9508 cmdline_fixed_string_t dump;
9512 dump_struct_sizes(void)
9514 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9515 DUMP_SIZE(struct rte_mbuf);
9516 DUMP_SIZE(struct rte_mempool);
9517 DUMP_SIZE(struct rte_ring);
9522 /* Dump the socket memory statistics on console */
9524 dump_socket_mem(FILE *f)
9526 struct rte_malloc_socket_stats socket_stats;
9531 unsigned int n_alloc = 0;
9532 unsigned int n_free = 0;
9533 static size_t last_allocs;
9534 static size_t last_total;
9537 for (i = 0; i < RTE_MAX_NUMA_NODES; i++) {
9538 if (rte_malloc_get_socket_stats(i, &socket_stats) ||
9539 !socket_stats.heap_totalsz_bytes)
9541 total += socket_stats.heap_totalsz_bytes;
9542 alloc += socket_stats.heap_allocsz_bytes;
9543 free += socket_stats.heap_freesz_bytes;
9544 n_alloc += socket_stats.alloc_count;
9545 n_free += socket_stats.free_count;
9547 "Socket %u: size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9549 (double)socket_stats.heap_totalsz_bytes / (1024 * 1024),
9550 (double)socket_stats.heap_allocsz_bytes / (1024 * 1024),
9551 (double)socket_stats.heap_allocsz_bytes * 100 /
9552 (double)socket_stats.heap_totalsz_bytes,
9553 (double)socket_stats.heap_freesz_bytes / (1024 * 1024),
9554 socket_stats.alloc_count,
9555 socket_stats.free_count);
9558 "Total : size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9559 (double)total / (1024 * 1024), (double)alloc / (1024 * 1024),
9560 (double)alloc * 100 / (double)total,
9561 (double)free / (1024 * 1024),
9564 fprintf(stdout, "Memory total change: %.6lf(M), allocation change: %.6lf(M)\n",
9565 ((double)total - (double)last_total) / (1024 * 1024),
9566 (double)(alloc - (double)last_allocs) / 1024 / 1024);
9567 last_allocs = alloc;
9571 static void cmd_dump_parsed(void *parsed_result,
9572 __rte_unused struct cmdline *cl,
9573 __rte_unused void *data)
9575 struct cmd_dump_result *res = parsed_result;
9577 if (!strcmp(res->dump, "dump_physmem"))
9578 rte_dump_physmem_layout(stdout);
9579 else if (!strcmp(res->dump, "dump_socket_mem"))
9580 dump_socket_mem(stdout);
9581 else if (!strcmp(res->dump, "dump_memzone"))
9582 rte_memzone_dump(stdout);
9583 else if (!strcmp(res->dump, "dump_struct_sizes"))
9584 dump_struct_sizes();
9585 else if (!strcmp(res->dump, "dump_ring"))
9586 rte_ring_list_dump(stdout);
9587 else if (!strcmp(res->dump, "dump_mempool"))
9588 rte_mempool_list_dump(stdout);
9589 else if (!strcmp(res->dump, "dump_devargs"))
9590 rte_devargs_dump(stdout);
9591 else if (!strcmp(res->dump, "dump_log_types"))
9592 rte_log_dump(stdout);
9595 cmdline_parse_token_string_t cmd_dump_dump =
9596 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9600 "dump_struct_sizes#"
9606 cmdline_parse_inst_t cmd_dump = {
9607 .f = cmd_dump_parsed, /* function to call */
9608 .data = NULL, /* 2nd arg of func */
9609 .help_str = "Dump status",
9610 .tokens = { /* token list, NULL terminated */
9611 (void *)&cmd_dump_dump,
9616 /* ******************************************************************************** */
9618 struct cmd_dump_one_result {
9619 cmdline_fixed_string_t dump;
9620 cmdline_fixed_string_t name;
9623 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9624 __rte_unused void *data)
9626 struct cmd_dump_one_result *res = parsed_result;
9628 if (!strcmp(res->dump, "dump_ring")) {
9630 r = rte_ring_lookup(res->name);
9632 cmdline_printf(cl, "Cannot find ring\n");
9635 rte_ring_dump(stdout, r);
9636 } else if (!strcmp(res->dump, "dump_mempool")) {
9637 struct rte_mempool *mp;
9638 mp = rte_mempool_lookup(res->name);
9640 cmdline_printf(cl, "Cannot find mempool\n");
9643 rte_mempool_dump(stdout, mp);
9647 cmdline_parse_token_string_t cmd_dump_one_dump =
9648 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9649 "dump_ring#dump_mempool");
9651 cmdline_parse_token_string_t cmd_dump_one_name =
9652 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9654 cmdline_parse_inst_t cmd_dump_one = {
9655 .f = cmd_dump_one_parsed, /* function to call */
9656 .data = NULL, /* 2nd arg of func */
9657 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9658 .tokens = { /* token list, NULL terminated */
9659 (void *)&cmd_dump_one_dump,
9660 (void *)&cmd_dump_one_name,
9665 /* *** queue region set *** */
9666 struct cmd_queue_region_result {
9667 cmdline_fixed_string_t set;
9668 cmdline_fixed_string_t port;
9670 cmdline_fixed_string_t cmd;
9671 cmdline_fixed_string_t region;
9673 cmdline_fixed_string_t queue_start_index;
9675 cmdline_fixed_string_t queue_num;
9676 uint8_t queue_num_value;
9680 cmd_queue_region_parsed(void *parsed_result,
9681 __rte_unused struct cmdline *cl,
9682 __rte_unused void *data)
9684 struct cmd_queue_region_result *res = parsed_result;
9687 struct rte_pmd_i40e_queue_region_conf region_conf;
9688 enum rte_pmd_i40e_queue_region_op op_type;
9691 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9695 memset(®ion_conf, 0, sizeof(region_conf));
9696 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
9697 region_conf.region_id = res->region_id;
9698 region_conf.queue_num = res->queue_num_value;
9699 region_conf.queue_start_index = res->queue_id;
9701 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9702 op_type, ®ion_conf);
9709 printf("function not implemented or supported\n");
9712 printf("queue region config error: (%s)\n", strerror(-ret));
9716 cmdline_parse_token_string_t cmd_queue_region_set =
9717 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9719 cmdline_parse_token_string_t cmd_queue_region_port =
9720 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
9721 cmdline_parse_token_num_t cmd_queue_region_port_id =
9722 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9723 port_id, RTE_UINT16);
9724 cmdline_parse_token_string_t cmd_queue_region_cmd =
9725 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9726 cmd, "queue-region");
9727 cmdline_parse_token_string_t cmd_queue_region_id =
9728 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9729 region, "region_id");
9730 cmdline_parse_token_num_t cmd_queue_region_index =
9731 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9732 region_id, RTE_UINT8);
9733 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
9734 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9735 queue_start_index, "queue_start_index");
9736 cmdline_parse_token_num_t cmd_queue_region_queue_id =
9737 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9738 queue_id, RTE_UINT8);
9739 cmdline_parse_token_string_t cmd_queue_region_queue_num =
9740 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9741 queue_num, "queue_num");
9742 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
9743 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9744 queue_num_value, RTE_UINT8);
9746 cmdline_parse_inst_t cmd_queue_region = {
9747 .f = cmd_queue_region_parsed,
9749 .help_str = "set port <port_id> queue-region region_id <value> "
9750 "queue_start_index <value> queue_num <value>: Set a queue region",
9752 (void *)&cmd_queue_region_set,
9753 (void *)&cmd_queue_region_port,
9754 (void *)&cmd_queue_region_port_id,
9755 (void *)&cmd_queue_region_cmd,
9756 (void *)&cmd_queue_region_id,
9757 (void *)&cmd_queue_region_index,
9758 (void *)&cmd_queue_region_queue_start_index,
9759 (void *)&cmd_queue_region_queue_id,
9760 (void *)&cmd_queue_region_queue_num,
9761 (void *)&cmd_queue_region_queue_num_value,
9766 /* *** queue region and flowtype set *** */
9767 struct cmd_region_flowtype_result {
9768 cmdline_fixed_string_t set;
9769 cmdline_fixed_string_t port;
9771 cmdline_fixed_string_t cmd;
9772 cmdline_fixed_string_t region;
9774 cmdline_fixed_string_t flowtype;
9775 uint8_t flowtype_id;
9779 cmd_region_flowtype_parsed(void *parsed_result,
9780 __rte_unused struct cmdline *cl,
9781 __rte_unused void *data)
9783 struct cmd_region_flowtype_result *res = parsed_result;
9786 struct rte_pmd_i40e_queue_region_conf region_conf;
9787 enum rte_pmd_i40e_queue_region_op op_type;
9790 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9794 memset(®ion_conf, 0, sizeof(region_conf));
9796 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
9797 region_conf.region_id = res->region_id;
9798 region_conf.hw_flowtype = res->flowtype_id;
9800 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9801 op_type, ®ion_conf);
9808 printf("function not implemented or supported\n");
9811 printf("region flowtype config error: (%s)\n", strerror(-ret));
9815 cmdline_parse_token_string_t cmd_region_flowtype_set =
9816 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9818 cmdline_parse_token_string_t cmd_region_flowtype_port =
9819 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9821 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
9822 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9823 port_id, RTE_UINT16);
9824 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
9825 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9826 cmd, "queue-region");
9827 cmdline_parse_token_string_t cmd_region_flowtype_index =
9828 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9829 region, "region_id");
9830 cmdline_parse_token_num_t cmd_region_flowtype_id =
9831 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9832 region_id, RTE_UINT8);
9833 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
9834 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9835 flowtype, "flowtype");
9836 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
9837 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9838 flowtype_id, RTE_UINT8);
9839 cmdline_parse_inst_t cmd_region_flowtype = {
9840 .f = cmd_region_flowtype_parsed,
9842 .help_str = "set port <port_id> queue-region region_id <value> "
9843 "flowtype <value>: Set a flowtype region index",
9845 (void *)&cmd_region_flowtype_set,
9846 (void *)&cmd_region_flowtype_port,
9847 (void *)&cmd_region_flowtype_port_index,
9848 (void *)&cmd_region_flowtype_cmd,
9849 (void *)&cmd_region_flowtype_index,
9850 (void *)&cmd_region_flowtype_id,
9851 (void *)&cmd_region_flowtype_flow_index,
9852 (void *)&cmd_region_flowtype_flow_id,
9857 /* *** User Priority (UP) to queue region (region_id) set *** */
9858 struct cmd_user_priority_region_result {
9859 cmdline_fixed_string_t set;
9860 cmdline_fixed_string_t port;
9862 cmdline_fixed_string_t cmd;
9863 cmdline_fixed_string_t user_priority;
9864 uint8_t user_priority_id;
9865 cmdline_fixed_string_t region;
9870 cmd_user_priority_region_parsed(void *parsed_result,
9871 __rte_unused struct cmdline *cl,
9872 __rte_unused void *data)
9874 struct cmd_user_priority_region_result *res = parsed_result;
9877 struct rte_pmd_i40e_queue_region_conf region_conf;
9878 enum rte_pmd_i40e_queue_region_op op_type;
9881 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9885 memset(®ion_conf, 0, sizeof(region_conf));
9886 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
9887 region_conf.user_priority = res->user_priority_id;
9888 region_conf.region_id = res->region_id;
9890 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9891 op_type, ®ion_conf);
9898 printf("function not implemented or supported\n");
9901 printf("user_priority region config error: (%s)\n",
9906 cmdline_parse_token_string_t cmd_user_priority_region_set =
9907 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9909 cmdline_parse_token_string_t cmd_user_priority_region_port =
9910 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9912 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
9913 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9914 port_id, RTE_UINT16);
9915 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
9916 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9917 cmd, "queue-region");
9918 cmdline_parse_token_string_t cmd_user_priority_region_UP =
9919 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9920 user_priority, "UP");
9921 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
9922 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9923 user_priority_id, RTE_UINT8);
9924 cmdline_parse_token_string_t cmd_user_priority_region_region =
9925 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9926 region, "region_id");
9927 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
9928 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9929 region_id, RTE_UINT8);
9931 cmdline_parse_inst_t cmd_user_priority_region = {
9932 .f = cmd_user_priority_region_parsed,
9934 .help_str = "set port <port_id> queue-region UP <value> "
9935 "region_id <value>: Set the mapping of User Priority (UP) "
9936 "to queue region (region_id) ",
9938 (void *)&cmd_user_priority_region_set,
9939 (void *)&cmd_user_priority_region_port,
9940 (void *)&cmd_user_priority_region_port_index,
9941 (void *)&cmd_user_priority_region_cmd,
9942 (void *)&cmd_user_priority_region_UP,
9943 (void *)&cmd_user_priority_region_UP_id,
9944 (void *)&cmd_user_priority_region_region,
9945 (void *)&cmd_user_priority_region_region_id,
9950 /* *** flush all queue region related configuration *** */
9951 struct cmd_flush_queue_region_result {
9952 cmdline_fixed_string_t set;
9953 cmdline_fixed_string_t port;
9955 cmdline_fixed_string_t cmd;
9956 cmdline_fixed_string_t flush;
9957 cmdline_fixed_string_t what;
9961 cmd_flush_queue_region_parsed(void *parsed_result,
9962 __rte_unused struct cmdline *cl,
9963 __rte_unused void *data)
9965 struct cmd_flush_queue_region_result *res = parsed_result;
9968 struct rte_pmd_i40e_queue_region_conf region_conf;
9969 enum rte_pmd_i40e_queue_region_op op_type;
9972 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9976 memset(®ion_conf, 0, sizeof(region_conf));
9978 if (strcmp(res->what, "on") == 0)
9979 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
9981 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
9983 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9984 op_type, ®ion_conf);
9991 printf("function not implemented or supported\n");
9994 printf("queue region config flush error: (%s)\n",
9999 cmdline_parse_token_string_t cmd_flush_queue_region_set =
10000 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10002 cmdline_parse_token_string_t cmd_flush_queue_region_port =
10003 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10005 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
10006 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
10007 port_id, RTE_UINT16);
10008 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
10009 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10010 cmd, "queue-region");
10011 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
10012 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10014 cmdline_parse_token_string_t cmd_flush_queue_region_what =
10015 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10018 cmdline_parse_inst_t cmd_flush_queue_region = {
10019 .f = cmd_flush_queue_region_parsed,
10021 .help_str = "set port <port_id> queue-region flush on|off"
10022 ": flush all queue region related configuration",
10024 (void *)&cmd_flush_queue_region_set,
10025 (void *)&cmd_flush_queue_region_port,
10026 (void *)&cmd_flush_queue_region_port_index,
10027 (void *)&cmd_flush_queue_region_cmd,
10028 (void *)&cmd_flush_queue_region_flush,
10029 (void *)&cmd_flush_queue_region_what,
10034 /* *** get all queue region related configuration info *** */
10035 struct cmd_show_queue_region_info {
10036 cmdline_fixed_string_t show;
10037 cmdline_fixed_string_t port;
10039 cmdline_fixed_string_t cmd;
10043 cmd_show_queue_region_info_parsed(void *parsed_result,
10044 __rte_unused struct cmdline *cl,
10045 __rte_unused void *data)
10047 struct cmd_show_queue_region_info *res = parsed_result;
10048 int ret = -ENOTSUP;
10049 #ifdef RTE_NET_I40E
10050 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
10051 enum rte_pmd_i40e_queue_region_op op_type;
10054 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10057 #ifdef RTE_NET_I40E
10058 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
10060 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
10062 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10063 op_type, &rte_pmd_regions);
10065 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
10072 printf("function not implemented or supported\n");
10075 printf("queue region config info show error: (%s)\n",
10080 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
10081 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10083 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
10084 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10086 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
10087 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
10088 port_id, RTE_UINT16);
10089 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
10090 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10091 cmd, "queue-region");
10093 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
10094 .f = cmd_show_queue_region_info_parsed,
10096 .help_str = "show port <port_id> queue-region"
10097 ": show all queue region related configuration info",
10099 (void *)&cmd_show_queue_region_info_get,
10100 (void *)&cmd_show_queue_region_info_port,
10101 (void *)&cmd_show_queue_region_info_port_index,
10102 (void *)&cmd_show_queue_region_info_cmd,
10107 /* *** Filters Control *** */
10109 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10111 if ((ip_addr).family == AF_INET) \
10112 (ip) = (ip_addr).addr.ipv4.s_addr; \
10114 printf("invalid parameter.\n"); \
10119 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10121 if ((ip_addr).family == AF_INET6) \
10122 rte_memcpy(&(ip), \
10123 &((ip_addr).addr.ipv6), \
10124 sizeof(struct in6_addr)); \
10126 printf("invalid parameter.\n"); \
10131 #ifdef RTE_NET_I40E
10134 str2flowtype(char *string)
10137 static const struct {
10140 } flowtype_str[] = {
10141 {"raw", RTE_ETH_FLOW_RAW},
10142 {"ipv4", RTE_ETH_FLOW_IPV4},
10143 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10144 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10145 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10146 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10147 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10148 {"ipv6", RTE_ETH_FLOW_IPV6},
10149 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10150 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10151 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10152 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10153 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10154 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10157 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
10158 if (!strcmp(flowtype_str[i].str, string))
10159 return flowtype_str[i].type;
10162 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
10163 return (uint16_t)atoi(string);
10165 return RTE_ETH_FLOW_UNKNOWN;
10168 /* *** deal with flow director filter *** */
10169 struct cmd_flow_director_result {
10170 cmdline_fixed_string_t flow_director_filter;
10172 cmdline_fixed_string_t mode;
10173 cmdline_fixed_string_t mode_value;
10174 cmdline_fixed_string_t ops;
10175 cmdline_fixed_string_t flow;
10176 cmdline_fixed_string_t flow_type;
10177 cmdline_fixed_string_t drop;
10178 cmdline_fixed_string_t queue;
10180 cmdline_fixed_string_t fd_id;
10181 uint32_t fd_id_value;
10182 cmdline_fixed_string_t packet;
10187 cmd_flow_director_filter_parsed(void *parsed_result,
10188 __rte_unused struct cmdline *cl,
10189 __rte_unused void *data)
10191 struct cmd_flow_director_result *res = parsed_result;
10193 struct rte_pmd_i40e_flow_type_mapping
10194 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
10195 struct rte_pmd_i40e_pkt_template_conf conf;
10196 uint16_t flow_type = str2flowtype(res->flow_type);
10197 uint16_t i, port = res->port_id;
10200 memset(&conf, 0, sizeof(conf));
10202 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
10203 printf("Invalid flow type specified.\n");
10206 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
10210 if (mapping[flow_type].pctype == 0ULL) {
10211 printf("Invalid flow type specified.\n");
10214 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
10215 if (mapping[flow_type].pctype & (1ULL << i)) {
10216 conf.input.pctype = i;
10221 conf.input.packet = open_file(res->filepath,
10222 &conf.input.length);
10223 if (!conf.input.packet)
10225 if (!strcmp(res->drop, "drop"))
10226 conf.action.behavior =
10227 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
10229 conf.action.behavior =
10230 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
10231 conf.action.report_status =
10232 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
10233 conf.action.rx_queue = res->queue_id;
10234 conf.soft_id = res->fd_id_value;
10235 add = strcmp(res->ops, "del") ? 1 : 0;
10236 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
10240 printf("flow director config error: (%s)\n",
10242 close_file(conf.input.packet);
10245 cmdline_parse_token_string_t cmd_flow_director_filter =
10246 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10247 flow_director_filter, "flow_director_filter");
10248 cmdline_parse_token_num_t cmd_flow_director_port_id =
10249 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10250 port_id, RTE_UINT16);
10251 cmdline_parse_token_string_t cmd_flow_director_ops =
10252 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10253 ops, "add#del#update");
10254 cmdline_parse_token_string_t cmd_flow_director_flow =
10255 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10257 cmdline_parse_token_string_t cmd_flow_director_flow_type =
10258 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10260 cmdline_parse_token_string_t cmd_flow_director_drop =
10261 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10263 cmdline_parse_token_string_t cmd_flow_director_queue =
10264 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10266 cmdline_parse_token_num_t cmd_flow_director_queue_id =
10267 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10268 queue_id, RTE_UINT16);
10269 cmdline_parse_token_string_t cmd_flow_director_fd_id =
10270 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10272 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
10273 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10274 fd_id_value, RTE_UINT32);
10276 cmdline_parse_token_string_t cmd_flow_director_mode =
10277 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10279 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
10280 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10281 mode_value, "raw");
10282 cmdline_parse_token_string_t cmd_flow_director_packet =
10283 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10285 cmdline_parse_token_string_t cmd_flow_director_filepath =
10286 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10289 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
10290 .f = cmd_flow_director_filter_parsed,
10292 .help_str = "flow_director_filter ... : Add or delete a raw flow "
10293 "director entry on NIC",
10295 (void *)&cmd_flow_director_filter,
10296 (void *)&cmd_flow_director_port_id,
10297 (void *)&cmd_flow_director_mode,
10298 (void *)&cmd_flow_director_mode_raw,
10299 (void *)&cmd_flow_director_ops,
10300 (void *)&cmd_flow_director_flow,
10301 (void *)&cmd_flow_director_flow_type,
10302 (void *)&cmd_flow_director_drop,
10303 (void *)&cmd_flow_director_queue,
10304 (void *)&cmd_flow_director_queue_id,
10305 (void *)&cmd_flow_director_fd_id,
10306 (void *)&cmd_flow_director_fd_id_value,
10307 (void *)&cmd_flow_director_packet,
10308 (void *)&cmd_flow_director_filepath,
10313 #endif /* RTE_NET_I40E */
10315 /* *** deal with flow director mask *** */
10316 struct cmd_flow_director_mask_result {
10317 cmdline_fixed_string_t flow_director_mask;
10319 cmdline_fixed_string_t mode;
10320 cmdline_fixed_string_t mode_value;
10321 cmdline_fixed_string_t vlan;
10322 uint16_t vlan_mask;
10323 cmdline_fixed_string_t src_mask;
10324 cmdline_ipaddr_t ipv4_src;
10325 cmdline_ipaddr_t ipv6_src;
10327 cmdline_fixed_string_t dst_mask;
10328 cmdline_ipaddr_t ipv4_dst;
10329 cmdline_ipaddr_t ipv6_dst;
10331 cmdline_fixed_string_t mac;
10332 uint8_t mac_addr_byte_mask;
10333 cmdline_fixed_string_t tunnel_id;
10334 uint32_t tunnel_id_mask;
10335 cmdline_fixed_string_t tunnel_type;
10336 uint8_t tunnel_type_mask;
10340 cmd_flow_director_mask_parsed(void *parsed_result,
10341 __rte_unused struct cmdline *cl,
10342 __rte_unused void *data)
10344 struct cmd_flow_director_mask_result *res = parsed_result;
10345 struct rte_eth_fdir_masks *mask;
10346 struct rte_port *port;
10348 port = &ports[res->port_id];
10349 /** Check if the port is not started **/
10350 if (port->port_status != RTE_PORT_STOPPED) {
10351 printf("Please stop port %d first\n", res->port_id);
10355 mask = &port->dev_conf.fdir_conf.mask;
10357 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10358 if (strcmp(res->mode_value, "MAC-VLAN")) {
10359 printf("Please set mode to MAC-VLAN.\n");
10363 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10364 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10365 if (strcmp(res->mode_value, "Tunnel")) {
10366 printf("Please set mode to Tunnel.\n");
10370 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10371 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
10372 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
10373 mask->tunnel_type_mask = res->tunnel_type_mask;
10375 if (strcmp(res->mode_value, "IP")) {
10376 printf("Please set mode to IP.\n");
10380 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10381 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
10382 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
10383 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
10384 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
10385 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
10386 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
10389 cmd_reconfig_device_queue(res->port_id, 1, 1);
10392 cmdline_parse_token_string_t cmd_flow_director_mask =
10393 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10394 flow_director_mask, "flow_director_mask");
10395 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
10396 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10397 port_id, RTE_UINT16);
10398 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
10399 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10401 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
10402 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10403 vlan_mask, RTE_UINT16);
10404 cmdline_parse_token_string_t cmd_flow_director_mask_src =
10405 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10406 src_mask, "src_mask");
10407 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
10408 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10410 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
10411 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10413 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
10414 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10415 port_src, RTE_UINT16);
10416 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
10417 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10418 dst_mask, "dst_mask");
10419 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
10420 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10422 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
10423 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10425 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
10426 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10427 port_dst, RTE_UINT16);
10429 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
10430 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10432 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
10433 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10435 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
10436 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10437 mode_value, "MAC-VLAN");
10438 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
10439 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10440 mode_value, "Tunnel");
10441 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
10442 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10444 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
10445 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10446 mac_addr_byte_mask, RTE_UINT8);
10447 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
10448 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10449 tunnel_type, "tunnel-type");
10450 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
10451 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10452 tunnel_type_mask, RTE_UINT8);
10453 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
10454 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10455 tunnel_id, "tunnel-id");
10456 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
10457 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10458 tunnel_id_mask, RTE_UINT32);
10460 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
10461 .f = cmd_flow_director_mask_parsed,
10463 .help_str = "flow_director_mask ... : "
10464 "Set IP mode flow director's mask on NIC",
10466 (void *)&cmd_flow_director_mask,
10467 (void *)&cmd_flow_director_mask_port_id,
10468 (void *)&cmd_flow_director_mask_mode,
10469 (void *)&cmd_flow_director_mask_mode_ip,
10470 (void *)&cmd_flow_director_mask_vlan,
10471 (void *)&cmd_flow_director_mask_vlan_value,
10472 (void *)&cmd_flow_director_mask_src,
10473 (void *)&cmd_flow_director_mask_ipv4_src,
10474 (void *)&cmd_flow_director_mask_ipv6_src,
10475 (void *)&cmd_flow_director_mask_port_src,
10476 (void *)&cmd_flow_director_mask_dst,
10477 (void *)&cmd_flow_director_mask_ipv4_dst,
10478 (void *)&cmd_flow_director_mask_ipv6_dst,
10479 (void *)&cmd_flow_director_mask_port_dst,
10484 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
10485 .f = cmd_flow_director_mask_parsed,
10487 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
10488 "flow director's mask on NIC",
10490 (void *)&cmd_flow_director_mask,
10491 (void *)&cmd_flow_director_mask_port_id,
10492 (void *)&cmd_flow_director_mask_mode,
10493 (void *)&cmd_flow_director_mask_mode_mac_vlan,
10494 (void *)&cmd_flow_director_mask_vlan,
10495 (void *)&cmd_flow_director_mask_vlan_value,
10500 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
10501 .f = cmd_flow_director_mask_parsed,
10503 .help_str = "flow_director_mask ... : Set tunnel mode "
10504 "flow director's mask on NIC",
10506 (void *)&cmd_flow_director_mask,
10507 (void *)&cmd_flow_director_mask_port_id,
10508 (void *)&cmd_flow_director_mask_mode,
10509 (void *)&cmd_flow_director_mask_mode_tunnel,
10510 (void *)&cmd_flow_director_mask_vlan,
10511 (void *)&cmd_flow_director_mask_vlan_value,
10512 (void *)&cmd_flow_director_mask_mac,
10513 (void *)&cmd_flow_director_mask_mac_value,
10514 (void *)&cmd_flow_director_mask_tunnel_type,
10515 (void *)&cmd_flow_director_mask_tunnel_type_value,
10516 (void *)&cmd_flow_director_mask_tunnel_id,
10517 (void *)&cmd_flow_director_mask_tunnel_id_value,
10522 /* *** deal with flow director flexible payload configuration *** */
10523 struct cmd_flow_director_flexpayload_result {
10524 cmdline_fixed_string_t flow_director_flexpayload;
10526 cmdline_fixed_string_t payload_layer;
10527 cmdline_fixed_string_t payload_cfg;
10531 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
10534 const char *p, *p0 = q_arg;
10536 unsigned long int_fld;
10537 char *str_fld[max_num];
10542 p = strchr(p0, '(');
10546 p0 = strchr(p, ')');
10551 if (size >= sizeof(s))
10554 snprintf(s, sizeof(s), "%.*s", size, p);
10555 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10556 if (ret < 0 || ret > max_num)
10558 for (i = 0; i < ret; i++) {
10560 int_fld = strtoul(str_fld[i], &end, 0);
10561 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
10563 offsets[i] = (uint16_t)int_fld;
10569 cmd_flow_director_flxpld_parsed(void *parsed_result,
10570 __rte_unused struct cmdline *cl,
10571 __rte_unused void *data)
10573 struct cmd_flow_director_flexpayload_result *res = parsed_result;
10574 struct rte_eth_flex_payload_cfg flex_cfg;
10575 struct rte_port *port;
10578 port = &ports[res->port_id];
10579 /** Check if the port is not started **/
10580 if (port->port_status != RTE_PORT_STOPPED) {
10581 printf("Please stop port %d first\n", res->port_id);
10585 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
10587 if (!strcmp(res->payload_layer, "raw"))
10588 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
10589 else if (!strcmp(res->payload_layer, "l2"))
10590 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
10591 else if (!strcmp(res->payload_layer, "l3"))
10592 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
10593 else if (!strcmp(res->payload_layer, "l4"))
10594 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
10596 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
10597 RTE_ETH_FDIR_MAX_FLEXLEN);
10599 printf("error: Cannot parse flex payload input.\n");
10603 fdir_set_flex_payload(res->port_id, &flex_cfg);
10604 cmd_reconfig_device_queue(res->port_id, 1, 1);
10607 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
10608 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10609 flow_director_flexpayload,
10610 "flow_director_flex_payload");
10611 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
10612 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10613 port_id, RTE_UINT16);
10614 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
10615 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10616 payload_layer, "raw#l2#l3#l4");
10617 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
10618 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10619 payload_cfg, NULL);
10621 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
10622 .f = cmd_flow_director_flxpld_parsed,
10624 .help_str = "flow_director_flexpayload ... : "
10625 "Set flow director's flex payload on NIC",
10627 (void *)&cmd_flow_director_flexpayload,
10628 (void *)&cmd_flow_director_flexpayload_port_id,
10629 (void *)&cmd_flow_director_flexpayload_payload_layer,
10630 (void *)&cmd_flow_director_flexpayload_payload_cfg,
10635 /* Generic flow interface command. */
10636 extern cmdline_parse_inst_t cmd_flow;
10638 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
10639 struct cmd_mcast_addr_result {
10640 cmdline_fixed_string_t mcast_addr_cmd;
10641 cmdline_fixed_string_t what;
10643 struct rte_ether_addr mc_addr;
10646 static void cmd_mcast_addr_parsed(void *parsed_result,
10647 __rte_unused struct cmdline *cl,
10648 __rte_unused void *data)
10650 struct cmd_mcast_addr_result *res = parsed_result;
10652 if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
10653 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
10654 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
10655 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
10656 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
10659 if (strcmp(res->what, "add") == 0)
10660 mcast_addr_add(res->port_num, &res->mc_addr);
10662 mcast_addr_remove(res->port_num, &res->mc_addr);
10665 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
10666 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
10667 mcast_addr_cmd, "mcast_addr");
10668 cmdline_parse_token_string_t cmd_mcast_addr_what =
10669 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
10671 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
10672 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num,
10674 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
10675 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
10677 cmdline_parse_inst_t cmd_mcast_addr = {
10678 .f = cmd_mcast_addr_parsed,
10680 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
10681 "Add/Remove multicast MAC address on port_id",
10683 (void *)&cmd_mcast_addr_cmd,
10684 (void *)&cmd_mcast_addr_what,
10685 (void *)&cmd_mcast_addr_portnum,
10686 (void *)&cmd_mcast_addr_addr,
10691 /* vf vlan anti spoof configuration */
10693 /* Common result structure for vf vlan anti spoof */
10694 struct cmd_vf_vlan_anti_spoof_result {
10695 cmdline_fixed_string_t set;
10696 cmdline_fixed_string_t vf;
10697 cmdline_fixed_string_t vlan;
10698 cmdline_fixed_string_t antispoof;
10701 cmdline_fixed_string_t on_off;
10704 /* Common CLI fields for vf vlan anti spoof enable disable */
10705 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
10706 TOKEN_STRING_INITIALIZER
10707 (struct cmd_vf_vlan_anti_spoof_result,
10709 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
10710 TOKEN_STRING_INITIALIZER
10711 (struct cmd_vf_vlan_anti_spoof_result,
10713 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
10714 TOKEN_STRING_INITIALIZER
10715 (struct cmd_vf_vlan_anti_spoof_result,
10717 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
10718 TOKEN_STRING_INITIALIZER
10719 (struct cmd_vf_vlan_anti_spoof_result,
10720 antispoof, "antispoof");
10721 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
10722 TOKEN_NUM_INITIALIZER
10723 (struct cmd_vf_vlan_anti_spoof_result,
10724 port_id, RTE_UINT16);
10725 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
10726 TOKEN_NUM_INITIALIZER
10727 (struct cmd_vf_vlan_anti_spoof_result,
10728 vf_id, RTE_UINT32);
10729 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
10730 TOKEN_STRING_INITIALIZER
10731 (struct cmd_vf_vlan_anti_spoof_result,
10735 cmd_set_vf_vlan_anti_spoof_parsed(
10736 void *parsed_result,
10737 __rte_unused struct cmdline *cl,
10738 __rte_unused void *data)
10740 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
10741 int ret = -ENOTSUP;
10743 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
10745 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10748 #ifdef RTE_NET_IXGBE
10749 if (ret == -ENOTSUP)
10750 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
10751 res->vf_id, is_on);
10753 #ifdef RTE_NET_I40E
10754 if (ret == -ENOTSUP)
10755 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
10756 res->vf_id, is_on);
10758 #ifdef RTE_NET_BNXT
10759 if (ret == -ENOTSUP)
10760 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
10761 res->vf_id, is_on);
10768 printf("invalid vf_id %d\n", res->vf_id);
10771 printf("invalid port_id %d\n", res->port_id);
10774 printf("function not implemented\n");
10777 printf("programming error: (%s)\n", strerror(-ret));
10781 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
10782 .f = cmd_set_vf_vlan_anti_spoof_parsed,
10784 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
10786 (void *)&cmd_vf_vlan_anti_spoof_set,
10787 (void *)&cmd_vf_vlan_anti_spoof_vf,
10788 (void *)&cmd_vf_vlan_anti_spoof_vlan,
10789 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
10790 (void *)&cmd_vf_vlan_anti_spoof_port_id,
10791 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
10792 (void *)&cmd_vf_vlan_anti_spoof_on_off,
10797 /* vf mac anti spoof configuration */
10799 /* Common result structure for vf mac anti spoof */
10800 struct cmd_vf_mac_anti_spoof_result {
10801 cmdline_fixed_string_t set;
10802 cmdline_fixed_string_t vf;
10803 cmdline_fixed_string_t mac;
10804 cmdline_fixed_string_t antispoof;
10807 cmdline_fixed_string_t on_off;
10810 /* Common CLI fields for vf mac anti spoof enable disable */
10811 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
10812 TOKEN_STRING_INITIALIZER
10813 (struct cmd_vf_mac_anti_spoof_result,
10815 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
10816 TOKEN_STRING_INITIALIZER
10817 (struct cmd_vf_mac_anti_spoof_result,
10819 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
10820 TOKEN_STRING_INITIALIZER
10821 (struct cmd_vf_mac_anti_spoof_result,
10823 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
10824 TOKEN_STRING_INITIALIZER
10825 (struct cmd_vf_mac_anti_spoof_result,
10826 antispoof, "antispoof");
10827 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
10828 TOKEN_NUM_INITIALIZER
10829 (struct cmd_vf_mac_anti_spoof_result,
10830 port_id, RTE_UINT16);
10831 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
10832 TOKEN_NUM_INITIALIZER
10833 (struct cmd_vf_mac_anti_spoof_result,
10834 vf_id, RTE_UINT32);
10835 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
10836 TOKEN_STRING_INITIALIZER
10837 (struct cmd_vf_mac_anti_spoof_result,
10841 cmd_set_vf_mac_anti_spoof_parsed(
10842 void *parsed_result,
10843 __rte_unused struct cmdline *cl,
10844 __rte_unused void *data)
10846 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
10847 int ret = -ENOTSUP;
10849 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
10851 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10854 #ifdef RTE_NET_IXGBE
10855 if (ret == -ENOTSUP)
10856 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
10857 res->vf_id, is_on);
10859 #ifdef RTE_NET_I40E
10860 if (ret == -ENOTSUP)
10861 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
10862 res->vf_id, is_on);
10864 #ifdef RTE_NET_BNXT
10865 if (ret == -ENOTSUP)
10866 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
10867 res->vf_id, is_on);
10874 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
10877 printf("invalid port_id %d\n", res->port_id);
10880 printf("function not implemented\n");
10883 printf("programming error: (%s)\n", strerror(-ret));
10887 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
10888 .f = cmd_set_vf_mac_anti_spoof_parsed,
10890 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
10892 (void *)&cmd_vf_mac_anti_spoof_set,
10893 (void *)&cmd_vf_mac_anti_spoof_vf,
10894 (void *)&cmd_vf_mac_anti_spoof_mac,
10895 (void *)&cmd_vf_mac_anti_spoof_antispoof,
10896 (void *)&cmd_vf_mac_anti_spoof_port_id,
10897 (void *)&cmd_vf_mac_anti_spoof_vf_id,
10898 (void *)&cmd_vf_mac_anti_spoof_on_off,
10903 /* vf vlan strip queue configuration */
10905 /* Common result structure for vf mac anti spoof */
10906 struct cmd_vf_vlan_stripq_result {
10907 cmdline_fixed_string_t set;
10908 cmdline_fixed_string_t vf;
10909 cmdline_fixed_string_t vlan;
10910 cmdline_fixed_string_t stripq;
10913 cmdline_fixed_string_t on_off;
10916 /* Common CLI fields for vf vlan strip enable disable */
10917 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
10918 TOKEN_STRING_INITIALIZER
10919 (struct cmd_vf_vlan_stripq_result,
10921 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
10922 TOKEN_STRING_INITIALIZER
10923 (struct cmd_vf_vlan_stripq_result,
10925 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
10926 TOKEN_STRING_INITIALIZER
10927 (struct cmd_vf_vlan_stripq_result,
10929 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
10930 TOKEN_STRING_INITIALIZER
10931 (struct cmd_vf_vlan_stripq_result,
10933 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
10934 TOKEN_NUM_INITIALIZER
10935 (struct cmd_vf_vlan_stripq_result,
10936 port_id, RTE_UINT16);
10937 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
10938 TOKEN_NUM_INITIALIZER
10939 (struct cmd_vf_vlan_stripq_result,
10940 vf_id, RTE_UINT16);
10941 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
10942 TOKEN_STRING_INITIALIZER
10943 (struct cmd_vf_vlan_stripq_result,
10947 cmd_set_vf_vlan_stripq_parsed(
10948 void *parsed_result,
10949 __rte_unused struct cmdline *cl,
10950 __rte_unused void *data)
10952 struct cmd_vf_vlan_stripq_result *res = parsed_result;
10953 int ret = -ENOTSUP;
10955 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
10957 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10960 #ifdef RTE_NET_IXGBE
10961 if (ret == -ENOTSUP)
10962 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
10963 res->vf_id, is_on);
10965 #ifdef RTE_NET_I40E
10966 if (ret == -ENOTSUP)
10967 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
10968 res->vf_id, is_on);
10970 #ifdef RTE_NET_BNXT
10971 if (ret == -ENOTSUP)
10972 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
10973 res->vf_id, is_on);
10980 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
10983 printf("invalid port_id %d\n", res->port_id);
10986 printf("function not implemented\n");
10989 printf("programming error: (%s)\n", strerror(-ret));
10993 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
10994 .f = cmd_set_vf_vlan_stripq_parsed,
10996 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
10998 (void *)&cmd_vf_vlan_stripq_set,
10999 (void *)&cmd_vf_vlan_stripq_vf,
11000 (void *)&cmd_vf_vlan_stripq_vlan,
11001 (void *)&cmd_vf_vlan_stripq_stripq,
11002 (void *)&cmd_vf_vlan_stripq_port_id,
11003 (void *)&cmd_vf_vlan_stripq_vf_id,
11004 (void *)&cmd_vf_vlan_stripq_on_off,
11009 /* vf vlan insert configuration */
11011 /* Common result structure for vf vlan insert */
11012 struct cmd_vf_vlan_insert_result {
11013 cmdline_fixed_string_t set;
11014 cmdline_fixed_string_t vf;
11015 cmdline_fixed_string_t vlan;
11016 cmdline_fixed_string_t insert;
11022 /* Common CLI fields for vf vlan insert enable disable */
11023 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
11024 TOKEN_STRING_INITIALIZER
11025 (struct cmd_vf_vlan_insert_result,
11027 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
11028 TOKEN_STRING_INITIALIZER
11029 (struct cmd_vf_vlan_insert_result,
11031 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
11032 TOKEN_STRING_INITIALIZER
11033 (struct cmd_vf_vlan_insert_result,
11035 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
11036 TOKEN_STRING_INITIALIZER
11037 (struct cmd_vf_vlan_insert_result,
11039 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
11040 TOKEN_NUM_INITIALIZER
11041 (struct cmd_vf_vlan_insert_result,
11042 port_id, RTE_UINT16);
11043 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
11044 TOKEN_NUM_INITIALIZER
11045 (struct cmd_vf_vlan_insert_result,
11046 vf_id, RTE_UINT16);
11047 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
11048 TOKEN_NUM_INITIALIZER
11049 (struct cmd_vf_vlan_insert_result,
11050 vlan_id, RTE_UINT16);
11053 cmd_set_vf_vlan_insert_parsed(
11054 void *parsed_result,
11055 __rte_unused struct cmdline *cl,
11056 __rte_unused void *data)
11058 struct cmd_vf_vlan_insert_result *res = parsed_result;
11059 int ret = -ENOTSUP;
11061 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11064 #ifdef RTE_NET_IXGBE
11065 if (ret == -ENOTSUP)
11066 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
11069 #ifdef RTE_NET_I40E
11070 if (ret == -ENOTSUP)
11071 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
11074 #ifdef RTE_NET_BNXT
11075 if (ret == -ENOTSUP)
11076 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
11084 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
11087 printf("invalid port_id %d\n", res->port_id);
11090 printf("function not implemented\n");
11093 printf("programming error: (%s)\n", strerror(-ret));
11097 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
11098 .f = cmd_set_vf_vlan_insert_parsed,
11100 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
11102 (void *)&cmd_vf_vlan_insert_set,
11103 (void *)&cmd_vf_vlan_insert_vf,
11104 (void *)&cmd_vf_vlan_insert_vlan,
11105 (void *)&cmd_vf_vlan_insert_insert,
11106 (void *)&cmd_vf_vlan_insert_port_id,
11107 (void *)&cmd_vf_vlan_insert_vf_id,
11108 (void *)&cmd_vf_vlan_insert_vlan_id,
11113 /* tx loopback configuration */
11115 /* Common result structure for tx loopback */
11116 struct cmd_tx_loopback_result {
11117 cmdline_fixed_string_t set;
11118 cmdline_fixed_string_t tx;
11119 cmdline_fixed_string_t loopback;
11121 cmdline_fixed_string_t on_off;
11124 /* Common CLI fields for tx loopback enable disable */
11125 cmdline_parse_token_string_t cmd_tx_loopback_set =
11126 TOKEN_STRING_INITIALIZER
11127 (struct cmd_tx_loopback_result,
11129 cmdline_parse_token_string_t cmd_tx_loopback_tx =
11130 TOKEN_STRING_INITIALIZER
11131 (struct cmd_tx_loopback_result,
11133 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
11134 TOKEN_STRING_INITIALIZER
11135 (struct cmd_tx_loopback_result,
11136 loopback, "loopback");
11137 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
11138 TOKEN_NUM_INITIALIZER
11139 (struct cmd_tx_loopback_result,
11140 port_id, RTE_UINT16);
11141 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
11142 TOKEN_STRING_INITIALIZER
11143 (struct cmd_tx_loopback_result,
11147 cmd_set_tx_loopback_parsed(
11148 void *parsed_result,
11149 __rte_unused struct cmdline *cl,
11150 __rte_unused void *data)
11152 struct cmd_tx_loopback_result *res = parsed_result;
11153 int ret = -ENOTSUP;
11155 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11157 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11160 #ifdef RTE_NET_IXGBE
11161 if (ret == -ENOTSUP)
11162 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
11164 #ifdef RTE_NET_I40E
11165 if (ret == -ENOTSUP)
11166 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
11168 #ifdef RTE_NET_BNXT
11169 if (ret == -ENOTSUP)
11170 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
11172 #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA
11173 if (ret == -ENOTSUP)
11174 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
11181 printf("invalid is_on %d\n", is_on);
11184 printf("invalid port_id %d\n", res->port_id);
11187 printf("function not implemented\n");
11190 printf("programming error: (%s)\n", strerror(-ret));
11194 cmdline_parse_inst_t cmd_set_tx_loopback = {
11195 .f = cmd_set_tx_loopback_parsed,
11197 .help_str = "set tx loopback <port_id> on|off",
11199 (void *)&cmd_tx_loopback_set,
11200 (void *)&cmd_tx_loopback_tx,
11201 (void *)&cmd_tx_loopback_loopback,
11202 (void *)&cmd_tx_loopback_port_id,
11203 (void *)&cmd_tx_loopback_on_off,
11208 /* all queues drop enable configuration */
11210 /* Common result structure for all queues drop enable */
11211 struct cmd_all_queues_drop_en_result {
11212 cmdline_fixed_string_t set;
11213 cmdline_fixed_string_t all;
11214 cmdline_fixed_string_t queues;
11215 cmdline_fixed_string_t drop;
11217 cmdline_fixed_string_t on_off;
11220 /* Common CLI fields for tx loopback enable disable */
11221 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
11222 TOKEN_STRING_INITIALIZER
11223 (struct cmd_all_queues_drop_en_result,
11225 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
11226 TOKEN_STRING_INITIALIZER
11227 (struct cmd_all_queues_drop_en_result,
11229 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
11230 TOKEN_STRING_INITIALIZER
11231 (struct cmd_all_queues_drop_en_result,
11233 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
11234 TOKEN_STRING_INITIALIZER
11235 (struct cmd_all_queues_drop_en_result,
11237 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
11238 TOKEN_NUM_INITIALIZER
11239 (struct cmd_all_queues_drop_en_result,
11240 port_id, RTE_UINT16);
11241 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
11242 TOKEN_STRING_INITIALIZER
11243 (struct cmd_all_queues_drop_en_result,
11247 cmd_set_all_queues_drop_en_parsed(
11248 void *parsed_result,
11249 __rte_unused struct cmdline *cl,
11250 __rte_unused void *data)
11252 struct cmd_all_queues_drop_en_result *res = parsed_result;
11253 int ret = -ENOTSUP;
11254 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11256 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11259 #ifdef RTE_NET_IXGBE
11260 if (ret == -ENOTSUP)
11261 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
11263 #ifdef RTE_NET_BNXT
11264 if (ret == -ENOTSUP)
11265 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
11271 printf("invalid is_on %d\n", is_on);
11274 printf("invalid port_id %d\n", res->port_id);
11277 printf("function not implemented\n");
11280 printf("programming error: (%s)\n", strerror(-ret));
11284 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
11285 .f = cmd_set_all_queues_drop_en_parsed,
11287 .help_str = "set all queues drop <port_id> on|off",
11289 (void *)&cmd_all_queues_drop_en_set,
11290 (void *)&cmd_all_queues_drop_en_all,
11291 (void *)&cmd_all_queues_drop_en_queues,
11292 (void *)&cmd_all_queues_drop_en_drop,
11293 (void *)&cmd_all_queues_drop_en_port_id,
11294 (void *)&cmd_all_queues_drop_en_on_off,
11299 /* vf split drop enable configuration */
11301 /* Common result structure for vf split drop enable */
11302 struct cmd_vf_split_drop_en_result {
11303 cmdline_fixed_string_t set;
11304 cmdline_fixed_string_t vf;
11305 cmdline_fixed_string_t split;
11306 cmdline_fixed_string_t drop;
11309 cmdline_fixed_string_t on_off;
11312 /* Common CLI fields for vf split drop enable disable */
11313 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
11314 TOKEN_STRING_INITIALIZER
11315 (struct cmd_vf_split_drop_en_result,
11317 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
11318 TOKEN_STRING_INITIALIZER
11319 (struct cmd_vf_split_drop_en_result,
11321 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
11322 TOKEN_STRING_INITIALIZER
11323 (struct cmd_vf_split_drop_en_result,
11325 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
11326 TOKEN_STRING_INITIALIZER
11327 (struct cmd_vf_split_drop_en_result,
11329 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
11330 TOKEN_NUM_INITIALIZER
11331 (struct cmd_vf_split_drop_en_result,
11332 port_id, RTE_UINT16);
11333 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
11334 TOKEN_NUM_INITIALIZER
11335 (struct cmd_vf_split_drop_en_result,
11336 vf_id, RTE_UINT16);
11337 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
11338 TOKEN_STRING_INITIALIZER
11339 (struct cmd_vf_split_drop_en_result,
11343 cmd_set_vf_split_drop_en_parsed(
11344 void *parsed_result,
11345 __rte_unused struct cmdline *cl,
11346 __rte_unused void *data)
11348 struct cmd_vf_split_drop_en_result *res = parsed_result;
11349 int ret = -ENOTSUP;
11350 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11352 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11355 #ifdef RTE_NET_IXGBE
11356 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
11363 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11366 printf("invalid port_id %d\n", res->port_id);
11369 printf("not supported on port %d\n", res->port_id);
11372 printf("programming error: (%s)\n", strerror(-ret));
11376 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
11377 .f = cmd_set_vf_split_drop_en_parsed,
11379 .help_str = "set vf split drop <port_id> <vf_id> on|off",
11381 (void *)&cmd_vf_split_drop_en_set,
11382 (void *)&cmd_vf_split_drop_en_vf,
11383 (void *)&cmd_vf_split_drop_en_split,
11384 (void *)&cmd_vf_split_drop_en_drop,
11385 (void *)&cmd_vf_split_drop_en_port_id,
11386 (void *)&cmd_vf_split_drop_en_vf_id,
11387 (void *)&cmd_vf_split_drop_en_on_off,
11392 /* vf mac address configuration */
11394 /* Common result structure for vf mac address */
11395 struct cmd_set_vf_mac_addr_result {
11396 cmdline_fixed_string_t set;
11397 cmdline_fixed_string_t vf;
11398 cmdline_fixed_string_t mac;
11399 cmdline_fixed_string_t addr;
11402 struct rte_ether_addr mac_addr;
11406 /* Common CLI fields for vf split drop enable disable */
11407 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
11408 TOKEN_STRING_INITIALIZER
11409 (struct cmd_set_vf_mac_addr_result,
11411 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
11412 TOKEN_STRING_INITIALIZER
11413 (struct cmd_set_vf_mac_addr_result,
11415 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
11416 TOKEN_STRING_INITIALIZER
11417 (struct cmd_set_vf_mac_addr_result,
11419 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
11420 TOKEN_STRING_INITIALIZER
11421 (struct cmd_set_vf_mac_addr_result,
11423 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
11424 TOKEN_NUM_INITIALIZER
11425 (struct cmd_set_vf_mac_addr_result,
11426 port_id, RTE_UINT16);
11427 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
11428 TOKEN_NUM_INITIALIZER
11429 (struct cmd_set_vf_mac_addr_result,
11430 vf_id, RTE_UINT16);
11431 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
11432 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
11436 cmd_set_vf_mac_addr_parsed(
11437 void *parsed_result,
11438 __rte_unused struct cmdline *cl,
11439 __rte_unused void *data)
11441 struct cmd_set_vf_mac_addr_result *res = parsed_result;
11442 int ret = -ENOTSUP;
11444 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11447 #ifdef RTE_NET_IXGBE
11448 if (ret == -ENOTSUP)
11449 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
11452 #ifdef RTE_NET_I40E
11453 if (ret == -ENOTSUP)
11454 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
11457 #ifdef RTE_NET_BNXT
11458 if (ret == -ENOTSUP)
11459 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
11467 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
11470 printf("invalid port_id %d\n", res->port_id);
11473 printf("function not implemented\n");
11476 printf("programming error: (%s)\n", strerror(-ret));
11480 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
11481 .f = cmd_set_vf_mac_addr_parsed,
11483 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
11485 (void *)&cmd_set_vf_mac_addr_set,
11486 (void *)&cmd_set_vf_mac_addr_vf,
11487 (void *)&cmd_set_vf_mac_addr_mac,
11488 (void *)&cmd_set_vf_mac_addr_addr,
11489 (void *)&cmd_set_vf_mac_addr_port_id,
11490 (void *)&cmd_set_vf_mac_addr_vf_id,
11491 (void *)&cmd_set_vf_mac_addr_mac_addr,
11496 /* MACsec configuration */
11498 /* Common result structure for MACsec offload enable */
11499 struct cmd_macsec_offload_on_result {
11500 cmdline_fixed_string_t set;
11501 cmdline_fixed_string_t macsec;
11502 cmdline_fixed_string_t offload;
11504 cmdline_fixed_string_t on;
11505 cmdline_fixed_string_t encrypt;
11506 cmdline_fixed_string_t en_on_off;
11507 cmdline_fixed_string_t replay_protect;
11508 cmdline_fixed_string_t rp_on_off;
11511 /* Common CLI fields for MACsec offload disable */
11512 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
11513 TOKEN_STRING_INITIALIZER
11514 (struct cmd_macsec_offload_on_result,
11516 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
11517 TOKEN_STRING_INITIALIZER
11518 (struct cmd_macsec_offload_on_result,
11520 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
11521 TOKEN_STRING_INITIALIZER
11522 (struct cmd_macsec_offload_on_result,
11523 offload, "offload");
11524 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
11525 TOKEN_NUM_INITIALIZER
11526 (struct cmd_macsec_offload_on_result,
11527 port_id, RTE_UINT16);
11528 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
11529 TOKEN_STRING_INITIALIZER
11530 (struct cmd_macsec_offload_on_result,
11532 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
11533 TOKEN_STRING_INITIALIZER
11534 (struct cmd_macsec_offload_on_result,
11535 encrypt, "encrypt");
11536 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
11537 TOKEN_STRING_INITIALIZER
11538 (struct cmd_macsec_offload_on_result,
11539 en_on_off, "on#off");
11540 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
11541 TOKEN_STRING_INITIALIZER
11542 (struct cmd_macsec_offload_on_result,
11543 replay_protect, "replay-protect");
11544 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
11545 TOKEN_STRING_INITIALIZER
11546 (struct cmd_macsec_offload_on_result,
11547 rp_on_off, "on#off");
11550 cmd_set_macsec_offload_on_parsed(
11551 void *parsed_result,
11552 __rte_unused struct cmdline *cl,
11553 __rte_unused void *data)
11555 struct cmd_macsec_offload_on_result *res = parsed_result;
11556 int ret = -ENOTSUP;
11557 portid_t port_id = res->port_id;
11558 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
11559 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
11560 struct rte_eth_dev_info dev_info;
11562 if (port_id_is_invalid(port_id, ENABLED_WARN))
11564 if (!port_is_stopped(port_id)) {
11565 printf("Please stop port %d first\n", port_id);
11569 ret = eth_dev_info_get_print_err(port_id, &dev_info);
11573 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
11574 #ifdef RTE_NET_IXGBE
11575 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
11583 ports[port_id].dev_conf.txmode.offloads |=
11584 DEV_TX_OFFLOAD_MACSEC_INSERT;
11585 cmd_reconfig_device_queue(port_id, 1, 1);
11588 printf("invalid port_id %d\n", port_id);
11591 printf("not supported on port %d\n", port_id);
11594 printf("programming error: (%s)\n", strerror(-ret));
11598 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
11599 .f = cmd_set_macsec_offload_on_parsed,
11601 .help_str = "set macsec offload <port_id> on "
11602 "encrypt on|off replay-protect on|off",
11604 (void *)&cmd_macsec_offload_on_set,
11605 (void *)&cmd_macsec_offload_on_macsec,
11606 (void *)&cmd_macsec_offload_on_offload,
11607 (void *)&cmd_macsec_offload_on_port_id,
11608 (void *)&cmd_macsec_offload_on_on,
11609 (void *)&cmd_macsec_offload_on_encrypt,
11610 (void *)&cmd_macsec_offload_on_en_on_off,
11611 (void *)&cmd_macsec_offload_on_replay_protect,
11612 (void *)&cmd_macsec_offload_on_rp_on_off,
11617 /* Common result structure for MACsec offload disable */
11618 struct cmd_macsec_offload_off_result {
11619 cmdline_fixed_string_t set;
11620 cmdline_fixed_string_t macsec;
11621 cmdline_fixed_string_t offload;
11623 cmdline_fixed_string_t off;
11626 /* Common CLI fields for MACsec offload disable */
11627 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
11628 TOKEN_STRING_INITIALIZER
11629 (struct cmd_macsec_offload_off_result,
11631 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
11632 TOKEN_STRING_INITIALIZER
11633 (struct cmd_macsec_offload_off_result,
11635 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
11636 TOKEN_STRING_INITIALIZER
11637 (struct cmd_macsec_offload_off_result,
11638 offload, "offload");
11639 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
11640 TOKEN_NUM_INITIALIZER
11641 (struct cmd_macsec_offload_off_result,
11642 port_id, RTE_UINT16);
11643 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
11644 TOKEN_STRING_INITIALIZER
11645 (struct cmd_macsec_offload_off_result,
11649 cmd_set_macsec_offload_off_parsed(
11650 void *parsed_result,
11651 __rte_unused struct cmdline *cl,
11652 __rte_unused void *data)
11654 struct cmd_macsec_offload_off_result *res = parsed_result;
11655 int ret = -ENOTSUP;
11656 struct rte_eth_dev_info dev_info;
11657 portid_t port_id = res->port_id;
11659 if (port_id_is_invalid(port_id, ENABLED_WARN))
11661 if (!port_is_stopped(port_id)) {
11662 printf("Please stop port %d first\n", port_id);
11666 ret = eth_dev_info_get_print_err(port_id, &dev_info);
11670 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
11671 #ifdef RTE_NET_IXGBE
11672 ret = rte_pmd_ixgbe_macsec_disable(port_id);
11677 ports[port_id].dev_conf.txmode.offloads &=
11678 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
11679 cmd_reconfig_device_queue(port_id, 1, 1);
11682 printf("invalid port_id %d\n", port_id);
11685 printf("not supported on port %d\n", port_id);
11688 printf("programming error: (%s)\n", strerror(-ret));
11692 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
11693 .f = cmd_set_macsec_offload_off_parsed,
11695 .help_str = "set macsec offload <port_id> off",
11697 (void *)&cmd_macsec_offload_off_set,
11698 (void *)&cmd_macsec_offload_off_macsec,
11699 (void *)&cmd_macsec_offload_off_offload,
11700 (void *)&cmd_macsec_offload_off_port_id,
11701 (void *)&cmd_macsec_offload_off_off,
11706 /* Common result structure for MACsec secure connection configure */
11707 struct cmd_macsec_sc_result {
11708 cmdline_fixed_string_t set;
11709 cmdline_fixed_string_t macsec;
11710 cmdline_fixed_string_t sc;
11711 cmdline_fixed_string_t tx_rx;
11713 struct rte_ether_addr mac;
11717 /* Common CLI fields for MACsec secure connection configure */
11718 cmdline_parse_token_string_t cmd_macsec_sc_set =
11719 TOKEN_STRING_INITIALIZER
11720 (struct cmd_macsec_sc_result,
11722 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
11723 TOKEN_STRING_INITIALIZER
11724 (struct cmd_macsec_sc_result,
11726 cmdline_parse_token_string_t cmd_macsec_sc_sc =
11727 TOKEN_STRING_INITIALIZER
11728 (struct cmd_macsec_sc_result,
11730 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
11731 TOKEN_STRING_INITIALIZER
11732 (struct cmd_macsec_sc_result,
11734 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
11735 TOKEN_NUM_INITIALIZER
11736 (struct cmd_macsec_sc_result,
11737 port_id, RTE_UINT16);
11738 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
11739 TOKEN_ETHERADDR_INITIALIZER
11740 (struct cmd_macsec_sc_result,
11742 cmdline_parse_token_num_t cmd_macsec_sc_pi =
11743 TOKEN_NUM_INITIALIZER
11744 (struct cmd_macsec_sc_result,
11748 cmd_set_macsec_sc_parsed(
11749 void *parsed_result,
11750 __rte_unused struct cmdline *cl,
11751 __rte_unused void *data)
11753 struct cmd_macsec_sc_result *res = parsed_result;
11754 int ret = -ENOTSUP;
11755 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
11757 #ifdef RTE_NET_IXGBE
11759 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
11760 res->mac.addr_bytes) :
11761 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
11762 res->mac.addr_bytes, res->pi);
11764 RTE_SET_USED(is_tx);
11770 printf("invalid port_id %d\n", res->port_id);
11773 printf("not supported on port %d\n", res->port_id);
11776 printf("programming error: (%s)\n", strerror(-ret));
11780 cmdline_parse_inst_t cmd_set_macsec_sc = {
11781 .f = cmd_set_macsec_sc_parsed,
11783 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
11785 (void *)&cmd_macsec_sc_set,
11786 (void *)&cmd_macsec_sc_macsec,
11787 (void *)&cmd_macsec_sc_sc,
11788 (void *)&cmd_macsec_sc_tx_rx,
11789 (void *)&cmd_macsec_sc_port_id,
11790 (void *)&cmd_macsec_sc_mac,
11791 (void *)&cmd_macsec_sc_pi,
11796 /* Common result structure for MACsec secure connection configure */
11797 struct cmd_macsec_sa_result {
11798 cmdline_fixed_string_t set;
11799 cmdline_fixed_string_t macsec;
11800 cmdline_fixed_string_t sa;
11801 cmdline_fixed_string_t tx_rx;
11806 cmdline_fixed_string_t key;
11809 /* Common CLI fields for MACsec secure connection configure */
11810 cmdline_parse_token_string_t cmd_macsec_sa_set =
11811 TOKEN_STRING_INITIALIZER
11812 (struct cmd_macsec_sa_result,
11814 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
11815 TOKEN_STRING_INITIALIZER
11816 (struct cmd_macsec_sa_result,
11818 cmdline_parse_token_string_t cmd_macsec_sa_sa =
11819 TOKEN_STRING_INITIALIZER
11820 (struct cmd_macsec_sa_result,
11822 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
11823 TOKEN_STRING_INITIALIZER
11824 (struct cmd_macsec_sa_result,
11826 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
11827 TOKEN_NUM_INITIALIZER
11828 (struct cmd_macsec_sa_result,
11829 port_id, RTE_UINT16);
11830 cmdline_parse_token_num_t cmd_macsec_sa_idx =
11831 TOKEN_NUM_INITIALIZER
11832 (struct cmd_macsec_sa_result,
11834 cmdline_parse_token_num_t cmd_macsec_sa_an =
11835 TOKEN_NUM_INITIALIZER
11836 (struct cmd_macsec_sa_result,
11838 cmdline_parse_token_num_t cmd_macsec_sa_pn =
11839 TOKEN_NUM_INITIALIZER
11840 (struct cmd_macsec_sa_result,
11842 cmdline_parse_token_string_t cmd_macsec_sa_key =
11843 TOKEN_STRING_INITIALIZER
11844 (struct cmd_macsec_sa_result,
11848 cmd_set_macsec_sa_parsed(
11849 void *parsed_result,
11850 __rte_unused struct cmdline *cl,
11851 __rte_unused void *data)
11853 struct cmd_macsec_sa_result *res = parsed_result;
11854 int ret = -ENOTSUP;
11855 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
11856 uint8_t key[16] = { 0 };
11862 key_len = strlen(res->key) / 2;
11866 for (i = 0; i < key_len; i++) {
11867 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
11870 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
11873 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
11876 #ifdef RTE_NET_IXGBE
11878 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
11879 res->idx, res->an, res->pn, key) :
11880 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
11881 res->idx, res->an, res->pn, key);
11883 RTE_SET_USED(is_tx);
11890 printf("invalid idx %d or an %d\n", res->idx, res->an);
11893 printf("invalid port_id %d\n", res->port_id);
11896 printf("not supported on port %d\n", res->port_id);
11899 printf("programming error: (%s)\n", strerror(-ret));
11903 cmdline_parse_inst_t cmd_set_macsec_sa = {
11904 .f = cmd_set_macsec_sa_parsed,
11906 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
11908 (void *)&cmd_macsec_sa_set,
11909 (void *)&cmd_macsec_sa_macsec,
11910 (void *)&cmd_macsec_sa_sa,
11911 (void *)&cmd_macsec_sa_tx_rx,
11912 (void *)&cmd_macsec_sa_port_id,
11913 (void *)&cmd_macsec_sa_idx,
11914 (void *)&cmd_macsec_sa_an,
11915 (void *)&cmd_macsec_sa_pn,
11916 (void *)&cmd_macsec_sa_key,
11921 /* VF unicast promiscuous mode configuration */
11923 /* Common result structure for VF unicast promiscuous mode */
11924 struct cmd_vf_promisc_result {
11925 cmdline_fixed_string_t set;
11926 cmdline_fixed_string_t vf;
11927 cmdline_fixed_string_t promisc;
11930 cmdline_fixed_string_t on_off;
11933 /* Common CLI fields for VF unicast promiscuous mode enable disable */
11934 cmdline_parse_token_string_t cmd_vf_promisc_set =
11935 TOKEN_STRING_INITIALIZER
11936 (struct cmd_vf_promisc_result,
11938 cmdline_parse_token_string_t cmd_vf_promisc_vf =
11939 TOKEN_STRING_INITIALIZER
11940 (struct cmd_vf_promisc_result,
11942 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
11943 TOKEN_STRING_INITIALIZER
11944 (struct cmd_vf_promisc_result,
11945 promisc, "promisc");
11946 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
11947 TOKEN_NUM_INITIALIZER
11948 (struct cmd_vf_promisc_result,
11949 port_id, RTE_UINT16);
11950 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
11951 TOKEN_NUM_INITIALIZER
11952 (struct cmd_vf_promisc_result,
11953 vf_id, RTE_UINT32);
11954 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
11955 TOKEN_STRING_INITIALIZER
11956 (struct cmd_vf_promisc_result,
11960 cmd_set_vf_promisc_parsed(
11961 void *parsed_result,
11962 __rte_unused struct cmdline *cl,
11963 __rte_unused void *data)
11965 struct cmd_vf_promisc_result *res = parsed_result;
11966 int ret = -ENOTSUP;
11968 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11970 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11973 #ifdef RTE_NET_I40E
11974 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
11975 res->vf_id, is_on);
11982 printf("invalid vf_id %d\n", res->vf_id);
11985 printf("invalid port_id %d\n", res->port_id);
11988 printf("function not implemented\n");
11991 printf("programming error: (%s)\n", strerror(-ret));
11995 cmdline_parse_inst_t cmd_set_vf_promisc = {
11996 .f = cmd_set_vf_promisc_parsed,
11998 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
11999 "Set unicast promiscuous mode for a VF from the PF",
12001 (void *)&cmd_vf_promisc_set,
12002 (void *)&cmd_vf_promisc_vf,
12003 (void *)&cmd_vf_promisc_promisc,
12004 (void *)&cmd_vf_promisc_port_id,
12005 (void *)&cmd_vf_promisc_vf_id,
12006 (void *)&cmd_vf_promisc_on_off,
12011 /* VF multicast promiscuous mode configuration */
12013 /* Common result structure for VF multicast promiscuous mode */
12014 struct cmd_vf_allmulti_result {
12015 cmdline_fixed_string_t set;
12016 cmdline_fixed_string_t vf;
12017 cmdline_fixed_string_t allmulti;
12020 cmdline_fixed_string_t on_off;
12023 /* Common CLI fields for VF multicast promiscuous mode enable disable */
12024 cmdline_parse_token_string_t cmd_vf_allmulti_set =
12025 TOKEN_STRING_INITIALIZER
12026 (struct cmd_vf_allmulti_result,
12028 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
12029 TOKEN_STRING_INITIALIZER
12030 (struct cmd_vf_allmulti_result,
12032 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
12033 TOKEN_STRING_INITIALIZER
12034 (struct cmd_vf_allmulti_result,
12035 allmulti, "allmulti");
12036 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
12037 TOKEN_NUM_INITIALIZER
12038 (struct cmd_vf_allmulti_result,
12039 port_id, RTE_UINT16);
12040 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
12041 TOKEN_NUM_INITIALIZER
12042 (struct cmd_vf_allmulti_result,
12043 vf_id, RTE_UINT32);
12044 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
12045 TOKEN_STRING_INITIALIZER
12046 (struct cmd_vf_allmulti_result,
12050 cmd_set_vf_allmulti_parsed(
12051 void *parsed_result,
12052 __rte_unused struct cmdline *cl,
12053 __rte_unused void *data)
12055 struct cmd_vf_allmulti_result *res = parsed_result;
12056 int ret = -ENOTSUP;
12058 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12060 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12063 #ifdef RTE_NET_I40E
12064 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
12065 res->vf_id, is_on);
12072 printf("invalid vf_id %d\n", res->vf_id);
12075 printf("invalid port_id %d\n", res->port_id);
12078 printf("function not implemented\n");
12081 printf("programming error: (%s)\n", strerror(-ret));
12085 cmdline_parse_inst_t cmd_set_vf_allmulti = {
12086 .f = cmd_set_vf_allmulti_parsed,
12088 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
12089 "Set multicast promiscuous mode for a VF from the PF",
12091 (void *)&cmd_vf_allmulti_set,
12092 (void *)&cmd_vf_allmulti_vf,
12093 (void *)&cmd_vf_allmulti_allmulti,
12094 (void *)&cmd_vf_allmulti_port_id,
12095 (void *)&cmd_vf_allmulti_vf_id,
12096 (void *)&cmd_vf_allmulti_on_off,
12101 /* vf broadcast mode configuration */
12103 /* Common result structure for vf broadcast */
12104 struct cmd_set_vf_broadcast_result {
12105 cmdline_fixed_string_t set;
12106 cmdline_fixed_string_t vf;
12107 cmdline_fixed_string_t broadcast;
12110 cmdline_fixed_string_t on_off;
12113 /* Common CLI fields for vf broadcast enable disable */
12114 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
12115 TOKEN_STRING_INITIALIZER
12116 (struct cmd_set_vf_broadcast_result,
12118 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
12119 TOKEN_STRING_INITIALIZER
12120 (struct cmd_set_vf_broadcast_result,
12122 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
12123 TOKEN_STRING_INITIALIZER
12124 (struct cmd_set_vf_broadcast_result,
12125 broadcast, "broadcast");
12126 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
12127 TOKEN_NUM_INITIALIZER
12128 (struct cmd_set_vf_broadcast_result,
12129 port_id, RTE_UINT16);
12130 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
12131 TOKEN_NUM_INITIALIZER
12132 (struct cmd_set_vf_broadcast_result,
12133 vf_id, RTE_UINT16);
12134 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
12135 TOKEN_STRING_INITIALIZER
12136 (struct cmd_set_vf_broadcast_result,
12140 cmd_set_vf_broadcast_parsed(
12141 void *parsed_result,
12142 __rte_unused struct cmdline *cl,
12143 __rte_unused void *data)
12145 struct cmd_set_vf_broadcast_result *res = parsed_result;
12146 int ret = -ENOTSUP;
12148 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12150 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12153 #ifdef RTE_NET_I40E
12154 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
12155 res->vf_id, is_on);
12162 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12165 printf("invalid port_id %d\n", res->port_id);
12168 printf("function not implemented\n");
12171 printf("programming error: (%s)\n", strerror(-ret));
12175 cmdline_parse_inst_t cmd_set_vf_broadcast = {
12176 .f = cmd_set_vf_broadcast_parsed,
12178 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
12180 (void *)&cmd_set_vf_broadcast_set,
12181 (void *)&cmd_set_vf_broadcast_vf,
12182 (void *)&cmd_set_vf_broadcast_broadcast,
12183 (void *)&cmd_set_vf_broadcast_port_id,
12184 (void *)&cmd_set_vf_broadcast_vf_id,
12185 (void *)&cmd_set_vf_broadcast_on_off,
12190 /* vf vlan tag configuration */
12192 /* Common result structure for vf vlan tag */
12193 struct cmd_set_vf_vlan_tag_result {
12194 cmdline_fixed_string_t set;
12195 cmdline_fixed_string_t vf;
12196 cmdline_fixed_string_t vlan;
12197 cmdline_fixed_string_t tag;
12200 cmdline_fixed_string_t on_off;
12203 /* Common CLI fields for vf vlan tag enable disable */
12204 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
12205 TOKEN_STRING_INITIALIZER
12206 (struct cmd_set_vf_vlan_tag_result,
12208 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
12209 TOKEN_STRING_INITIALIZER
12210 (struct cmd_set_vf_vlan_tag_result,
12212 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
12213 TOKEN_STRING_INITIALIZER
12214 (struct cmd_set_vf_vlan_tag_result,
12216 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
12217 TOKEN_STRING_INITIALIZER
12218 (struct cmd_set_vf_vlan_tag_result,
12220 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
12221 TOKEN_NUM_INITIALIZER
12222 (struct cmd_set_vf_vlan_tag_result,
12223 port_id, RTE_UINT16);
12224 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
12225 TOKEN_NUM_INITIALIZER
12226 (struct cmd_set_vf_vlan_tag_result,
12227 vf_id, RTE_UINT16);
12228 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
12229 TOKEN_STRING_INITIALIZER
12230 (struct cmd_set_vf_vlan_tag_result,
12234 cmd_set_vf_vlan_tag_parsed(
12235 void *parsed_result,
12236 __rte_unused struct cmdline *cl,
12237 __rte_unused void *data)
12239 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
12240 int ret = -ENOTSUP;
12242 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12244 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12247 #ifdef RTE_NET_I40E
12248 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
12249 res->vf_id, is_on);
12256 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12259 printf("invalid port_id %d\n", res->port_id);
12262 printf("function not implemented\n");
12265 printf("programming error: (%s)\n", strerror(-ret));
12269 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
12270 .f = cmd_set_vf_vlan_tag_parsed,
12272 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
12274 (void *)&cmd_set_vf_vlan_tag_set,
12275 (void *)&cmd_set_vf_vlan_tag_vf,
12276 (void *)&cmd_set_vf_vlan_tag_vlan,
12277 (void *)&cmd_set_vf_vlan_tag_tag,
12278 (void *)&cmd_set_vf_vlan_tag_port_id,
12279 (void *)&cmd_set_vf_vlan_tag_vf_id,
12280 (void *)&cmd_set_vf_vlan_tag_on_off,
12285 /* Common definition of VF and TC TX bandwidth configuration */
12286 struct cmd_vf_tc_bw_result {
12287 cmdline_fixed_string_t set;
12288 cmdline_fixed_string_t vf;
12289 cmdline_fixed_string_t tc;
12290 cmdline_fixed_string_t tx;
12291 cmdline_fixed_string_t min_bw;
12292 cmdline_fixed_string_t max_bw;
12293 cmdline_fixed_string_t strict_link_prio;
12298 cmdline_fixed_string_t bw_list;
12302 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
12303 TOKEN_STRING_INITIALIZER
12304 (struct cmd_vf_tc_bw_result,
12306 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
12307 TOKEN_STRING_INITIALIZER
12308 (struct cmd_vf_tc_bw_result,
12310 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
12311 TOKEN_STRING_INITIALIZER
12312 (struct cmd_vf_tc_bw_result,
12314 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
12315 TOKEN_STRING_INITIALIZER
12316 (struct cmd_vf_tc_bw_result,
12318 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
12319 TOKEN_STRING_INITIALIZER
12320 (struct cmd_vf_tc_bw_result,
12321 strict_link_prio, "strict-link-priority");
12322 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
12323 TOKEN_STRING_INITIALIZER
12324 (struct cmd_vf_tc_bw_result,
12325 min_bw, "min-bandwidth");
12326 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
12327 TOKEN_STRING_INITIALIZER
12328 (struct cmd_vf_tc_bw_result,
12329 max_bw, "max-bandwidth");
12330 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
12331 TOKEN_NUM_INITIALIZER
12332 (struct cmd_vf_tc_bw_result,
12333 port_id, RTE_UINT16);
12334 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
12335 TOKEN_NUM_INITIALIZER
12336 (struct cmd_vf_tc_bw_result,
12337 vf_id, RTE_UINT16);
12338 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
12339 TOKEN_NUM_INITIALIZER
12340 (struct cmd_vf_tc_bw_result,
12342 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
12343 TOKEN_NUM_INITIALIZER
12344 (struct cmd_vf_tc_bw_result,
12346 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
12347 TOKEN_STRING_INITIALIZER
12348 (struct cmd_vf_tc_bw_result,
12350 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
12351 TOKEN_NUM_INITIALIZER
12352 (struct cmd_vf_tc_bw_result,
12353 tc_map, RTE_UINT8);
12355 /* VF max bandwidth setting */
12357 cmd_vf_max_bw_parsed(
12358 void *parsed_result,
12359 __rte_unused struct cmdline *cl,
12360 __rte_unused void *data)
12362 struct cmd_vf_tc_bw_result *res = parsed_result;
12363 int ret = -ENOTSUP;
12365 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12368 #ifdef RTE_NET_I40E
12369 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
12370 res->vf_id, res->bw);
12377 printf("invalid vf_id %d or bandwidth %d\n",
12378 res->vf_id, res->bw);
12381 printf("invalid port_id %d\n", res->port_id);
12384 printf("function not implemented\n");
12387 printf("programming error: (%s)\n", strerror(-ret));
12391 cmdline_parse_inst_t cmd_vf_max_bw = {
12392 .f = cmd_vf_max_bw_parsed,
12394 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
12396 (void *)&cmd_vf_tc_bw_set,
12397 (void *)&cmd_vf_tc_bw_vf,
12398 (void *)&cmd_vf_tc_bw_tx,
12399 (void *)&cmd_vf_tc_bw_max_bw,
12400 (void *)&cmd_vf_tc_bw_port_id,
12401 (void *)&cmd_vf_tc_bw_vf_id,
12402 (void *)&cmd_vf_tc_bw_bw,
12408 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
12413 const char *p, *p0 = str;
12420 p = strchr(p0, '(');
12422 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
12426 p0 = strchr(p, ')');
12428 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
12432 if (size >= sizeof(s)) {
12433 printf("The string size exceeds the internal buffer size\n");
12436 snprintf(s, sizeof(s), "%.*s", size, p);
12437 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
12439 printf("Failed to get the bandwidth list. ");
12443 for (i = 0; i < ret; i++)
12444 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
12449 /* TC min bandwidth setting */
12451 cmd_vf_tc_min_bw_parsed(
12452 void *parsed_result,
12453 __rte_unused struct cmdline *cl,
12454 __rte_unused void *data)
12456 struct cmd_vf_tc_bw_result *res = parsed_result;
12459 int ret = -ENOTSUP;
12461 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12464 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12468 #ifdef RTE_NET_I40E
12469 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
12477 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
12480 printf("invalid port_id %d\n", res->port_id);
12483 printf("function not implemented\n");
12486 printf("programming error: (%s)\n", strerror(-ret));
12490 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
12491 .f = cmd_vf_tc_min_bw_parsed,
12493 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
12494 " <bw1, bw2, ...>",
12496 (void *)&cmd_vf_tc_bw_set,
12497 (void *)&cmd_vf_tc_bw_vf,
12498 (void *)&cmd_vf_tc_bw_tc,
12499 (void *)&cmd_vf_tc_bw_tx,
12500 (void *)&cmd_vf_tc_bw_min_bw,
12501 (void *)&cmd_vf_tc_bw_port_id,
12502 (void *)&cmd_vf_tc_bw_vf_id,
12503 (void *)&cmd_vf_tc_bw_bw_list,
12509 cmd_tc_min_bw_parsed(
12510 void *parsed_result,
12511 __rte_unused struct cmdline *cl,
12512 __rte_unused void *data)
12514 struct cmd_vf_tc_bw_result *res = parsed_result;
12515 struct rte_port *port;
12518 int ret = -ENOTSUP;
12520 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12523 port = &ports[res->port_id];
12524 /** Check if the port is not started **/
12525 if (port->port_status != RTE_PORT_STOPPED) {
12526 printf("Please stop port %d first\n", res->port_id);
12530 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12534 #ifdef RTE_NET_IXGBE
12535 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
12542 printf("invalid bandwidth\n");
12545 printf("invalid port_id %d\n", res->port_id);
12548 printf("function not implemented\n");
12551 printf("programming error: (%s)\n", strerror(-ret));
12555 cmdline_parse_inst_t cmd_tc_min_bw = {
12556 .f = cmd_tc_min_bw_parsed,
12558 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
12560 (void *)&cmd_vf_tc_bw_set,
12561 (void *)&cmd_vf_tc_bw_tc,
12562 (void *)&cmd_vf_tc_bw_tx,
12563 (void *)&cmd_vf_tc_bw_min_bw,
12564 (void *)&cmd_vf_tc_bw_port_id,
12565 (void *)&cmd_vf_tc_bw_bw_list,
12570 /* TC max bandwidth setting */
12572 cmd_vf_tc_max_bw_parsed(
12573 void *parsed_result,
12574 __rte_unused struct cmdline *cl,
12575 __rte_unused void *data)
12577 struct cmd_vf_tc_bw_result *res = parsed_result;
12578 int ret = -ENOTSUP;
12580 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12583 #ifdef RTE_NET_I40E
12584 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
12585 res->tc_no, res->bw);
12592 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
12593 res->vf_id, res->tc_no, res->bw);
12596 printf("invalid port_id %d\n", res->port_id);
12599 printf("function not implemented\n");
12602 printf("programming error: (%s)\n", strerror(-ret));
12606 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
12607 .f = cmd_vf_tc_max_bw_parsed,
12609 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
12612 (void *)&cmd_vf_tc_bw_set,
12613 (void *)&cmd_vf_tc_bw_vf,
12614 (void *)&cmd_vf_tc_bw_tc,
12615 (void *)&cmd_vf_tc_bw_tx,
12616 (void *)&cmd_vf_tc_bw_max_bw,
12617 (void *)&cmd_vf_tc_bw_port_id,
12618 (void *)&cmd_vf_tc_bw_vf_id,
12619 (void *)&cmd_vf_tc_bw_tc_no,
12620 (void *)&cmd_vf_tc_bw_bw,
12625 /** Set VXLAN encapsulation details */
12626 struct cmd_set_vxlan_result {
12627 cmdline_fixed_string_t set;
12628 cmdline_fixed_string_t vxlan;
12629 cmdline_fixed_string_t pos_token;
12630 cmdline_fixed_string_t ip_version;
12631 uint32_t vlan_present:1;
12635 cmdline_ipaddr_t ip_src;
12636 cmdline_ipaddr_t ip_dst;
12640 struct rte_ether_addr eth_src;
12641 struct rte_ether_addr eth_dst;
12644 cmdline_parse_token_string_t cmd_set_vxlan_set =
12645 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
12646 cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
12647 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
12648 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
12649 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
12651 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
12652 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
12653 "vxlan-with-vlan");
12654 cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
12655 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12657 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
12658 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
12660 cmdline_parse_token_string_t cmd_set_vxlan_vni =
12661 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12663 cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
12664 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, RTE_UINT32);
12665 cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
12666 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12668 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
12669 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, RTE_UINT16);
12670 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
12671 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12673 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
12674 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, RTE_UINT16);
12675 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
12676 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12678 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
12679 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, RTE_UINT8);
12680 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
12681 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12683 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
12684 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, RTE_UINT8);
12685 cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
12686 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12688 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
12689 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
12690 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
12691 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12693 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
12694 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
12695 cmdline_parse_token_string_t cmd_set_vxlan_vlan =
12696 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12698 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
12699 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, RTE_UINT16);
12700 cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
12701 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12703 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
12704 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
12705 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
12706 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12708 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
12709 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
12711 static void cmd_set_vxlan_parsed(void *parsed_result,
12712 __rte_unused struct cmdline *cl,
12713 __rte_unused void *data)
12715 struct cmd_set_vxlan_result *res = parsed_result;
12720 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
12723 vxlan_encap_conf.select_tos_ttl = 0;
12724 if (strcmp(res->vxlan, "vxlan") == 0)
12725 vxlan_encap_conf.select_vlan = 0;
12726 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
12727 vxlan_encap_conf.select_vlan = 1;
12728 else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
12729 vxlan_encap_conf.select_vlan = 0;
12730 vxlan_encap_conf.select_tos_ttl = 1;
12732 if (strcmp(res->ip_version, "ipv4") == 0)
12733 vxlan_encap_conf.select_ipv4 = 1;
12734 else if (strcmp(res->ip_version, "ipv6") == 0)
12735 vxlan_encap_conf.select_ipv4 = 0;
12738 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
12739 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
12740 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
12741 vxlan_encap_conf.ip_tos = res->tos;
12742 vxlan_encap_conf.ip_ttl = res->ttl;
12743 if (vxlan_encap_conf.select_ipv4) {
12744 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
12745 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
12747 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
12748 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
12750 if (vxlan_encap_conf.select_vlan)
12751 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
12752 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
12753 RTE_ETHER_ADDR_LEN);
12754 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
12755 RTE_ETHER_ADDR_LEN);
12758 cmdline_parse_inst_t cmd_set_vxlan = {
12759 .f = cmd_set_vxlan_parsed,
12761 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
12762 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
12763 " eth-src <eth-src> eth-dst <eth-dst>",
12765 (void *)&cmd_set_vxlan_set,
12766 (void *)&cmd_set_vxlan_vxlan,
12767 (void *)&cmd_set_vxlan_ip_version,
12768 (void *)&cmd_set_vxlan_ip_version_value,
12769 (void *)&cmd_set_vxlan_vni,
12770 (void *)&cmd_set_vxlan_vni_value,
12771 (void *)&cmd_set_vxlan_udp_src,
12772 (void *)&cmd_set_vxlan_udp_src_value,
12773 (void *)&cmd_set_vxlan_udp_dst,
12774 (void *)&cmd_set_vxlan_udp_dst_value,
12775 (void *)&cmd_set_vxlan_ip_src,
12776 (void *)&cmd_set_vxlan_ip_src_value,
12777 (void *)&cmd_set_vxlan_ip_dst,
12778 (void *)&cmd_set_vxlan_ip_dst_value,
12779 (void *)&cmd_set_vxlan_eth_src,
12780 (void *)&cmd_set_vxlan_eth_src_value,
12781 (void *)&cmd_set_vxlan_eth_dst,
12782 (void *)&cmd_set_vxlan_eth_dst_value,
12787 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
12788 .f = cmd_set_vxlan_parsed,
12790 .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
12791 " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
12792 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
12793 " eth-dst <eth-dst>",
12795 (void *)&cmd_set_vxlan_set,
12796 (void *)&cmd_set_vxlan_vxlan_tos_ttl,
12797 (void *)&cmd_set_vxlan_ip_version,
12798 (void *)&cmd_set_vxlan_ip_version_value,
12799 (void *)&cmd_set_vxlan_vni,
12800 (void *)&cmd_set_vxlan_vni_value,
12801 (void *)&cmd_set_vxlan_udp_src,
12802 (void *)&cmd_set_vxlan_udp_src_value,
12803 (void *)&cmd_set_vxlan_udp_dst,
12804 (void *)&cmd_set_vxlan_udp_dst_value,
12805 (void *)&cmd_set_vxlan_ip_tos,
12806 (void *)&cmd_set_vxlan_ip_tos_value,
12807 (void *)&cmd_set_vxlan_ip_ttl,
12808 (void *)&cmd_set_vxlan_ip_ttl_value,
12809 (void *)&cmd_set_vxlan_ip_src,
12810 (void *)&cmd_set_vxlan_ip_src_value,
12811 (void *)&cmd_set_vxlan_ip_dst,
12812 (void *)&cmd_set_vxlan_ip_dst_value,
12813 (void *)&cmd_set_vxlan_eth_src,
12814 (void *)&cmd_set_vxlan_eth_src_value,
12815 (void *)&cmd_set_vxlan_eth_dst,
12816 (void *)&cmd_set_vxlan_eth_dst_value,
12821 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
12822 .f = cmd_set_vxlan_parsed,
12824 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
12825 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
12826 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
12829 (void *)&cmd_set_vxlan_set,
12830 (void *)&cmd_set_vxlan_vxlan_with_vlan,
12831 (void *)&cmd_set_vxlan_ip_version,
12832 (void *)&cmd_set_vxlan_ip_version_value,
12833 (void *)&cmd_set_vxlan_vni,
12834 (void *)&cmd_set_vxlan_vni_value,
12835 (void *)&cmd_set_vxlan_udp_src,
12836 (void *)&cmd_set_vxlan_udp_src_value,
12837 (void *)&cmd_set_vxlan_udp_dst,
12838 (void *)&cmd_set_vxlan_udp_dst_value,
12839 (void *)&cmd_set_vxlan_ip_src,
12840 (void *)&cmd_set_vxlan_ip_src_value,
12841 (void *)&cmd_set_vxlan_ip_dst,
12842 (void *)&cmd_set_vxlan_ip_dst_value,
12843 (void *)&cmd_set_vxlan_vlan,
12844 (void *)&cmd_set_vxlan_vlan_value,
12845 (void *)&cmd_set_vxlan_eth_src,
12846 (void *)&cmd_set_vxlan_eth_src_value,
12847 (void *)&cmd_set_vxlan_eth_dst,
12848 (void *)&cmd_set_vxlan_eth_dst_value,
12853 /** Set NVGRE encapsulation details */
12854 struct cmd_set_nvgre_result {
12855 cmdline_fixed_string_t set;
12856 cmdline_fixed_string_t nvgre;
12857 cmdline_fixed_string_t pos_token;
12858 cmdline_fixed_string_t ip_version;
12860 cmdline_ipaddr_t ip_src;
12861 cmdline_ipaddr_t ip_dst;
12863 struct rte_ether_addr eth_src;
12864 struct rte_ether_addr eth_dst;
12867 cmdline_parse_token_string_t cmd_set_nvgre_set =
12868 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
12869 cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
12870 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
12871 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
12872 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
12873 "nvgre-with-vlan");
12874 cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
12875 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
12877 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
12878 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
12880 cmdline_parse_token_string_t cmd_set_nvgre_tni =
12881 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
12883 cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
12884 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, RTE_UINT32);
12885 cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
12886 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
12888 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
12889 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
12890 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
12891 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
12893 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
12894 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
12895 cmdline_parse_token_string_t cmd_set_nvgre_vlan =
12896 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
12898 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
12899 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, RTE_UINT16);
12900 cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
12901 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
12903 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
12904 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
12905 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
12906 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
12908 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
12909 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
12911 static void cmd_set_nvgre_parsed(void *parsed_result,
12912 __rte_unused struct cmdline *cl,
12913 __rte_unused void *data)
12915 struct cmd_set_nvgre_result *res = parsed_result;
12917 uint32_t nvgre_tni;
12920 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
12923 if (strcmp(res->nvgre, "nvgre") == 0)
12924 nvgre_encap_conf.select_vlan = 0;
12925 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
12926 nvgre_encap_conf.select_vlan = 1;
12927 if (strcmp(res->ip_version, "ipv4") == 0)
12928 nvgre_encap_conf.select_ipv4 = 1;
12929 else if (strcmp(res->ip_version, "ipv6") == 0)
12930 nvgre_encap_conf.select_ipv4 = 0;
12933 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
12934 if (nvgre_encap_conf.select_ipv4) {
12935 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
12936 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
12938 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
12939 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
12941 if (nvgre_encap_conf.select_vlan)
12942 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
12943 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
12944 RTE_ETHER_ADDR_LEN);
12945 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
12946 RTE_ETHER_ADDR_LEN);
12949 cmdline_parse_inst_t cmd_set_nvgre = {
12950 .f = cmd_set_nvgre_parsed,
12952 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
12953 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
12954 " eth-dst <eth-dst>",
12956 (void *)&cmd_set_nvgre_set,
12957 (void *)&cmd_set_nvgre_nvgre,
12958 (void *)&cmd_set_nvgre_ip_version,
12959 (void *)&cmd_set_nvgre_ip_version_value,
12960 (void *)&cmd_set_nvgre_tni,
12961 (void *)&cmd_set_nvgre_tni_value,
12962 (void *)&cmd_set_nvgre_ip_src,
12963 (void *)&cmd_set_nvgre_ip_src_value,
12964 (void *)&cmd_set_nvgre_ip_dst,
12965 (void *)&cmd_set_nvgre_ip_dst_value,
12966 (void *)&cmd_set_nvgre_eth_src,
12967 (void *)&cmd_set_nvgre_eth_src_value,
12968 (void *)&cmd_set_nvgre_eth_dst,
12969 (void *)&cmd_set_nvgre_eth_dst_value,
12974 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
12975 .f = cmd_set_nvgre_parsed,
12977 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
12978 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
12979 " eth-src <eth-src> eth-dst <eth-dst>",
12981 (void *)&cmd_set_nvgre_set,
12982 (void *)&cmd_set_nvgre_nvgre_with_vlan,
12983 (void *)&cmd_set_nvgre_ip_version,
12984 (void *)&cmd_set_nvgre_ip_version_value,
12985 (void *)&cmd_set_nvgre_tni,
12986 (void *)&cmd_set_nvgre_tni_value,
12987 (void *)&cmd_set_nvgre_ip_src,
12988 (void *)&cmd_set_nvgre_ip_src_value,
12989 (void *)&cmd_set_nvgre_ip_dst,
12990 (void *)&cmd_set_nvgre_ip_dst_value,
12991 (void *)&cmd_set_nvgre_vlan,
12992 (void *)&cmd_set_nvgre_vlan_value,
12993 (void *)&cmd_set_nvgre_eth_src,
12994 (void *)&cmd_set_nvgre_eth_src_value,
12995 (void *)&cmd_set_nvgre_eth_dst,
12996 (void *)&cmd_set_nvgre_eth_dst_value,
13001 /** Set L2 encapsulation details */
13002 struct cmd_set_l2_encap_result {
13003 cmdline_fixed_string_t set;
13004 cmdline_fixed_string_t l2_encap;
13005 cmdline_fixed_string_t pos_token;
13006 cmdline_fixed_string_t ip_version;
13007 uint32_t vlan_present:1;
13009 struct rte_ether_addr eth_src;
13010 struct rte_ether_addr eth_dst;
13013 cmdline_parse_token_string_t cmd_set_l2_encap_set =
13014 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
13015 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
13016 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
13017 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
13018 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
13019 "l2_encap-with-vlan");
13020 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
13021 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13023 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
13024 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
13026 cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
13027 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13029 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
13030 TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, RTE_UINT16);
13031 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
13032 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13034 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
13035 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
13036 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
13037 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13039 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
13040 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
13042 static void cmd_set_l2_encap_parsed(void *parsed_result,
13043 __rte_unused struct cmdline *cl,
13044 __rte_unused void *data)
13046 struct cmd_set_l2_encap_result *res = parsed_result;
13048 if (strcmp(res->l2_encap, "l2_encap") == 0)
13049 l2_encap_conf.select_vlan = 0;
13050 else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
13051 l2_encap_conf.select_vlan = 1;
13052 if (strcmp(res->ip_version, "ipv4") == 0)
13053 l2_encap_conf.select_ipv4 = 1;
13054 else if (strcmp(res->ip_version, "ipv6") == 0)
13055 l2_encap_conf.select_ipv4 = 0;
13058 if (l2_encap_conf.select_vlan)
13059 l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13060 rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
13061 RTE_ETHER_ADDR_LEN);
13062 rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13063 RTE_ETHER_ADDR_LEN);
13066 cmdline_parse_inst_t cmd_set_l2_encap = {
13067 .f = cmd_set_l2_encap_parsed,
13069 .help_str = "set l2_encap ip-version ipv4|ipv6"
13070 " eth-src <eth-src> eth-dst <eth-dst>",
13072 (void *)&cmd_set_l2_encap_set,
13073 (void *)&cmd_set_l2_encap_l2_encap,
13074 (void *)&cmd_set_l2_encap_ip_version,
13075 (void *)&cmd_set_l2_encap_ip_version_value,
13076 (void *)&cmd_set_l2_encap_eth_src,
13077 (void *)&cmd_set_l2_encap_eth_src_value,
13078 (void *)&cmd_set_l2_encap_eth_dst,
13079 (void *)&cmd_set_l2_encap_eth_dst_value,
13084 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
13085 .f = cmd_set_l2_encap_parsed,
13087 .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
13088 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
13090 (void *)&cmd_set_l2_encap_set,
13091 (void *)&cmd_set_l2_encap_l2_encap_with_vlan,
13092 (void *)&cmd_set_l2_encap_ip_version,
13093 (void *)&cmd_set_l2_encap_ip_version_value,
13094 (void *)&cmd_set_l2_encap_vlan,
13095 (void *)&cmd_set_l2_encap_vlan_value,
13096 (void *)&cmd_set_l2_encap_eth_src,
13097 (void *)&cmd_set_l2_encap_eth_src_value,
13098 (void *)&cmd_set_l2_encap_eth_dst,
13099 (void *)&cmd_set_l2_encap_eth_dst_value,
13104 /** Set L2 decapsulation details */
13105 struct cmd_set_l2_decap_result {
13106 cmdline_fixed_string_t set;
13107 cmdline_fixed_string_t l2_decap;
13108 cmdline_fixed_string_t pos_token;
13109 uint32_t vlan_present:1;
13112 cmdline_parse_token_string_t cmd_set_l2_decap_set =
13113 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
13114 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
13115 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
13117 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
13118 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
13119 "l2_decap-with-vlan");
13121 static void cmd_set_l2_decap_parsed(void *parsed_result,
13122 __rte_unused struct cmdline *cl,
13123 __rte_unused void *data)
13125 struct cmd_set_l2_decap_result *res = parsed_result;
13127 if (strcmp(res->l2_decap, "l2_decap") == 0)
13128 l2_decap_conf.select_vlan = 0;
13129 else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
13130 l2_decap_conf.select_vlan = 1;
13133 cmdline_parse_inst_t cmd_set_l2_decap = {
13134 .f = cmd_set_l2_decap_parsed,
13136 .help_str = "set l2_decap",
13138 (void *)&cmd_set_l2_decap_set,
13139 (void *)&cmd_set_l2_decap_l2_decap,
13144 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
13145 .f = cmd_set_l2_decap_parsed,
13147 .help_str = "set l2_decap-with-vlan",
13149 (void *)&cmd_set_l2_decap_set,
13150 (void *)&cmd_set_l2_decap_l2_decap_with_vlan,
13155 /** Set MPLSoGRE encapsulation details */
13156 struct cmd_set_mplsogre_encap_result {
13157 cmdline_fixed_string_t set;
13158 cmdline_fixed_string_t mplsogre;
13159 cmdline_fixed_string_t pos_token;
13160 cmdline_fixed_string_t ip_version;
13161 uint32_t vlan_present:1;
13163 cmdline_ipaddr_t ip_src;
13164 cmdline_ipaddr_t ip_dst;
13166 struct rte_ether_addr eth_src;
13167 struct rte_ether_addr eth_dst;
13170 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
13171 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
13173 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
13174 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
13176 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
13177 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13178 mplsogre, "mplsogre_encap-with-vlan");
13179 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
13180 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13181 pos_token, "ip-version");
13182 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
13183 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13184 ip_version, "ipv4#ipv6");
13185 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
13186 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13187 pos_token, "label");
13188 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
13189 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
13191 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
13192 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13193 pos_token, "ip-src");
13194 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
13195 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
13196 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
13197 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13198 pos_token, "ip-dst");
13199 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
13200 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
13201 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
13202 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13203 pos_token, "vlan-tci");
13204 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
13205 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
13207 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
13208 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13209 pos_token, "eth-src");
13210 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
13211 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13213 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
13214 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13215 pos_token, "eth-dst");
13216 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
13217 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13220 static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
13221 __rte_unused struct cmdline *cl,
13222 __rte_unused void *data)
13224 struct cmd_set_mplsogre_encap_result *res = parsed_result;
13226 uint32_t mplsogre_label;
13229 .mplsogre_label = rte_cpu_to_be_32(res->label<<12),
13232 if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
13233 mplsogre_encap_conf.select_vlan = 0;
13234 else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
13235 mplsogre_encap_conf.select_vlan = 1;
13236 if (strcmp(res->ip_version, "ipv4") == 0)
13237 mplsogre_encap_conf.select_ipv4 = 1;
13238 else if (strcmp(res->ip_version, "ipv6") == 0)
13239 mplsogre_encap_conf.select_ipv4 = 0;
13242 rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
13243 if (mplsogre_encap_conf.select_ipv4) {
13244 IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
13245 IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
13247 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
13248 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
13250 if (mplsogre_encap_conf.select_vlan)
13251 mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13252 rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
13253 RTE_ETHER_ADDR_LEN);
13254 rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13255 RTE_ETHER_ADDR_LEN);
13258 cmdline_parse_inst_t cmd_set_mplsogre_encap = {
13259 .f = cmd_set_mplsogre_encap_parsed,
13261 .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
13262 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
13263 " eth-dst <eth-dst>",
13265 (void *)&cmd_set_mplsogre_encap_set,
13266 (void *)&cmd_set_mplsogre_encap_mplsogre_encap,
13267 (void *)&cmd_set_mplsogre_encap_ip_version,
13268 (void *)&cmd_set_mplsogre_encap_ip_version_value,
13269 (void *)&cmd_set_mplsogre_encap_label,
13270 (void *)&cmd_set_mplsogre_encap_label_value,
13271 (void *)&cmd_set_mplsogre_encap_ip_src,
13272 (void *)&cmd_set_mplsogre_encap_ip_src_value,
13273 (void *)&cmd_set_mplsogre_encap_ip_dst,
13274 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
13275 (void *)&cmd_set_mplsogre_encap_eth_src,
13276 (void *)&cmd_set_mplsogre_encap_eth_src_value,
13277 (void *)&cmd_set_mplsogre_encap_eth_dst,
13278 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
13283 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
13284 .f = cmd_set_mplsogre_encap_parsed,
13286 .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
13287 " label <label> ip-src <ip-src> ip-dst <ip-dst>"
13288 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
13290 (void *)&cmd_set_mplsogre_encap_set,
13291 (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
13292 (void *)&cmd_set_mplsogre_encap_ip_version,
13293 (void *)&cmd_set_mplsogre_encap_ip_version_value,
13294 (void *)&cmd_set_mplsogre_encap_label,
13295 (void *)&cmd_set_mplsogre_encap_label_value,
13296 (void *)&cmd_set_mplsogre_encap_ip_src,
13297 (void *)&cmd_set_mplsogre_encap_ip_src_value,
13298 (void *)&cmd_set_mplsogre_encap_ip_dst,
13299 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
13300 (void *)&cmd_set_mplsogre_encap_vlan,
13301 (void *)&cmd_set_mplsogre_encap_vlan_value,
13302 (void *)&cmd_set_mplsogre_encap_eth_src,
13303 (void *)&cmd_set_mplsogre_encap_eth_src_value,
13304 (void *)&cmd_set_mplsogre_encap_eth_dst,
13305 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
13310 /** Set MPLSoGRE decapsulation details */
13311 struct cmd_set_mplsogre_decap_result {
13312 cmdline_fixed_string_t set;
13313 cmdline_fixed_string_t mplsogre;
13314 cmdline_fixed_string_t pos_token;
13315 cmdline_fixed_string_t ip_version;
13316 uint32_t vlan_present:1;
13319 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
13320 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
13322 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
13323 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
13325 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
13326 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13327 mplsogre, "mplsogre_decap-with-vlan");
13328 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
13329 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13330 pos_token, "ip-version");
13331 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
13332 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13333 ip_version, "ipv4#ipv6");
13335 static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
13336 __rte_unused struct cmdline *cl,
13337 __rte_unused void *data)
13339 struct cmd_set_mplsogre_decap_result *res = parsed_result;
13341 if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
13342 mplsogre_decap_conf.select_vlan = 0;
13343 else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
13344 mplsogre_decap_conf.select_vlan = 1;
13345 if (strcmp(res->ip_version, "ipv4") == 0)
13346 mplsogre_decap_conf.select_ipv4 = 1;
13347 else if (strcmp(res->ip_version, "ipv6") == 0)
13348 mplsogre_decap_conf.select_ipv4 = 0;
13351 cmdline_parse_inst_t cmd_set_mplsogre_decap = {
13352 .f = cmd_set_mplsogre_decap_parsed,
13354 .help_str = "set mplsogre_decap ip-version ipv4|ipv6",
13356 (void *)&cmd_set_mplsogre_decap_set,
13357 (void *)&cmd_set_mplsogre_decap_mplsogre_decap,
13358 (void *)&cmd_set_mplsogre_decap_ip_version,
13359 (void *)&cmd_set_mplsogre_decap_ip_version_value,
13364 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
13365 .f = cmd_set_mplsogre_decap_parsed,
13367 .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
13369 (void *)&cmd_set_mplsogre_decap_set,
13370 (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
13371 (void *)&cmd_set_mplsogre_decap_ip_version,
13372 (void *)&cmd_set_mplsogre_decap_ip_version_value,
13377 /** Set MPLSoUDP encapsulation details */
13378 struct cmd_set_mplsoudp_encap_result {
13379 cmdline_fixed_string_t set;
13380 cmdline_fixed_string_t mplsoudp;
13381 cmdline_fixed_string_t pos_token;
13382 cmdline_fixed_string_t ip_version;
13383 uint32_t vlan_present:1;
13387 cmdline_ipaddr_t ip_src;
13388 cmdline_ipaddr_t ip_dst;
13390 struct rte_ether_addr eth_src;
13391 struct rte_ether_addr eth_dst;
13394 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
13395 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
13397 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
13398 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
13400 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
13401 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13402 mplsoudp, "mplsoudp_encap-with-vlan");
13403 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
13404 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13405 pos_token, "ip-version");
13406 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
13407 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13408 ip_version, "ipv4#ipv6");
13409 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
13410 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13411 pos_token, "label");
13412 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
13413 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
13415 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
13416 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13417 pos_token, "udp-src");
13418 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
13419 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
13421 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
13422 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13423 pos_token, "udp-dst");
13424 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
13425 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
13427 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
13428 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13429 pos_token, "ip-src");
13430 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
13431 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
13432 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
13433 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13434 pos_token, "ip-dst");
13435 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
13436 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
13437 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
13438 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13439 pos_token, "vlan-tci");
13440 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
13441 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
13443 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
13444 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13445 pos_token, "eth-src");
13446 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
13447 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13449 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
13450 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13451 pos_token, "eth-dst");
13452 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
13453 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13456 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
13457 __rte_unused struct cmdline *cl,
13458 __rte_unused void *data)
13460 struct cmd_set_mplsoudp_encap_result *res = parsed_result;
13462 uint32_t mplsoudp_label;
13465 .mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
13468 if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
13469 mplsoudp_encap_conf.select_vlan = 0;
13470 else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
13471 mplsoudp_encap_conf.select_vlan = 1;
13472 if (strcmp(res->ip_version, "ipv4") == 0)
13473 mplsoudp_encap_conf.select_ipv4 = 1;
13474 else if (strcmp(res->ip_version, "ipv6") == 0)
13475 mplsoudp_encap_conf.select_ipv4 = 0;
13478 rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
13479 mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
13480 mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
13481 if (mplsoudp_encap_conf.select_ipv4) {
13482 IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
13483 IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
13485 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
13486 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
13488 if (mplsoudp_encap_conf.select_vlan)
13489 mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13490 rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
13491 RTE_ETHER_ADDR_LEN);
13492 rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13493 RTE_ETHER_ADDR_LEN);
13496 cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
13497 .f = cmd_set_mplsoudp_encap_parsed,
13499 .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
13500 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
13501 " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
13503 (void *)&cmd_set_mplsoudp_encap_set,
13504 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
13505 (void *)&cmd_set_mplsoudp_encap_ip_version,
13506 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
13507 (void *)&cmd_set_mplsoudp_encap_label,
13508 (void *)&cmd_set_mplsoudp_encap_label_value,
13509 (void *)&cmd_set_mplsoudp_encap_udp_src,
13510 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
13511 (void *)&cmd_set_mplsoudp_encap_udp_dst,
13512 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
13513 (void *)&cmd_set_mplsoudp_encap_ip_src,
13514 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
13515 (void *)&cmd_set_mplsoudp_encap_ip_dst,
13516 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
13517 (void *)&cmd_set_mplsoudp_encap_eth_src,
13518 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
13519 (void *)&cmd_set_mplsoudp_encap_eth_dst,
13520 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
13525 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
13526 .f = cmd_set_mplsoudp_encap_parsed,
13528 .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
13529 " label <label> udp-src <udp-src> udp-dst <udp-dst>"
13530 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
13531 " eth-src <eth-src> eth-dst <eth-dst>",
13533 (void *)&cmd_set_mplsoudp_encap_set,
13534 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
13535 (void *)&cmd_set_mplsoudp_encap_ip_version,
13536 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
13537 (void *)&cmd_set_mplsoudp_encap_label,
13538 (void *)&cmd_set_mplsoudp_encap_label_value,
13539 (void *)&cmd_set_mplsoudp_encap_udp_src,
13540 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
13541 (void *)&cmd_set_mplsoudp_encap_udp_dst,
13542 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
13543 (void *)&cmd_set_mplsoudp_encap_ip_src,
13544 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
13545 (void *)&cmd_set_mplsoudp_encap_ip_dst,
13546 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
13547 (void *)&cmd_set_mplsoudp_encap_vlan,
13548 (void *)&cmd_set_mplsoudp_encap_vlan_value,
13549 (void *)&cmd_set_mplsoudp_encap_eth_src,
13550 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
13551 (void *)&cmd_set_mplsoudp_encap_eth_dst,
13552 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
13557 /** Set MPLSoUDP decapsulation details */
13558 struct cmd_set_mplsoudp_decap_result {
13559 cmdline_fixed_string_t set;
13560 cmdline_fixed_string_t mplsoudp;
13561 cmdline_fixed_string_t pos_token;
13562 cmdline_fixed_string_t ip_version;
13563 uint32_t vlan_present:1;
13566 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
13567 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
13569 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
13570 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
13572 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
13573 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
13574 mplsoudp, "mplsoudp_decap-with-vlan");
13575 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
13576 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
13577 pos_token, "ip-version");
13578 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
13579 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
13580 ip_version, "ipv4#ipv6");
13582 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
13583 __rte_unused struct cmdline *cl,
13584 __rte_unused void *data)
13586 struct cmd_set_mplsoudp_decap_result *res = parsed_result;
13588 if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
13589 mplsoudp_decap_conf.select_vlan = 0;
13590 else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
13591 mplsoudp_decap_conf.select_vlan = 1;
13592 if (strcmp(res->ip_version, "ipv4") == 0)
13593 mplsoudp_decap_conf.select_ipv4 = 1;
13594 else if (strcmp(res->ip_version, "ipv6") == 0)
13595 mplsoudp_decap_conf.select_ipv4 = 0;
13598 cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
13599 .f = cmd_set_mplsoudp_decap_parsed,
13601 .help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
13603 (void *)&cmd_set_mplsoudp_decap_set,
13604 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
13605 (void *)&cmd_set_mplsoudp_decap_ip_version,
13606 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
13611 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
13612 .f = cmd_set_mplsoudp_decap_parsed,
13614 .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
13616 (void *)&cmd_set_mplsoudp_decap_set,
13617 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
13618 (void *)&cmd_set_mplsoudp_decap_ip_version,
13619 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
13624 /** Set connection tracking object common details */
13625 struct cmd_set_conntrack_common_result {
13626 cmdline_fixed_string_t set;
13627 cmdline_fixed_string_t conntrack;
13628 cmdline_fixed_string_t common;
13629 cmdline_fixed_string_t peer;
13630 cmdline_fixed_string_t is_orig;
13631 cmdline_fixed_string_t enable;
13632 cmdline_fixed_string_t live;
13633 cmdline_fixed_string_t sack;
13634 cmdline_fixed_string_t cack;
13635 cmdline_fixed_string_t last_dir;
13636 cmdline_fixed_string_t liberal;
13637 cmdline_fixed_string_t state;
13638 cmdline_fixed_string_t max_ack_win;
13639 cmdline_fixed_string_t retrans;
13640 cmdline_fixed_string_t last_win;
13641 cmdline_fixed_string_t last_seq;
13642 cmdline_fixed_string_t last_ack;
13643 cmdline_fixed_string_t last_end;
13644 cmdline_fixed_string_t last_index;
13647 uint16_t peer_port;
13648 uint32_t is_original;
13663 cmdline_parse_token_string_t cmd_set_conntrack_set =
13664 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13666 cmdline_parse_token_string_t cmd_set_conntrack_conntrack =
13667 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13668 conntrack, "conntrack");
13669 cmdline_parse_token_string_t cmd_set_conntrack_common_com =
13670 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13672 cmdline_parse_token_string_t cmd_set_conntrack_common_peer =
13673 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13675 cmdline_parse_token_num_t cmd_set_conntrack_common_peer_value =
13676 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13677 peer_port, RTE_UINT16);
13678 cmdline_parse_token_string_t cmd_set_conntrack_common_is_orig =
13679 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13680 is_orig, "is_orig");
13681 cmdline_parse_token_num_t cmd_set_conntrack_common_is_orig_value =
13682 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13683 is_original, RTE_UINT32);
13684 cmdline_parse_token_string_t cmd_set_conntrack_common_enable =
13685 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13687 cmdline_parse_token_num_t cmd_set_conntrack_common_enable_value =
13688 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13690 cmdline_parse_token_string_t cmd_set_conntrack_common_live =
13691 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13693 cmdline_parse_token_num_t cmd_set_conntrack_common_live_value =
13694 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13695 is_live, RTE_UINT32);
13696 cmdline_parse_token_string_t cmd_set_conntrack_common_sack =
13697 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13699 cmdline_parse_token_num_t cmd_set_conntrack_common_sack_value =
13700 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13701 s_ack, RTE_UINT32);
13702 cmdline_parse_token_string_t cmd_set_conntrack_common_cack =
13703 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13705 cmdline_parse_token_num_t cmd_set_conntrack_common_cack_value =
13706 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13707 c_ack, RTE_UINT32);
13708 cmdline_parse_token_string_t cmd_set_conntrack_common_last_dir =
13709 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13710 last_dir, "last_dir");
13711 cmdline_parse_token_num_t cmd_set_conntrack_common_last_dir_value =
13712 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13714 cmdline_parse_token_string_t cmd_set_conntrack_common_liberal =
13715 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13716 liberal, "liberal");
13717 cmdline_parse_token_num_t cmd_set_conntrack_common_liberal_value =
13718 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13720 cmdline_parse_token_string_t cmd_set_conntrack_common_state =
13721 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13723 cmdline_parse_token_num_t cmd_set_conntrack_common_state_value =
13724 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13726 cmdline_parse_token_string_t cmd_set_conntrack_common_max_ackwin =
13727 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13728 max_ack_win, "max_ack_win");
13729 cmdline_parse_token_num_t cmd_set_conntrack_common_max_ackwin_value =
13730 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13731 factor, RTE_UINT8);
13732 cmdline_parse_token_string_t cmd_set_conntrack_common_retrans =
13733 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13735 cmdline_parse_token_num_t cmd_set_conntrack_common_retrans_value =
13736 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13737 re_num, RTE_UINT8);
13738 cmdline_parse_token_string_t cmd_set_conntrack_common_last_win =
13739 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13740 last_win, "last_win");
13741 cmdline_parse_token_num_t cmd_set_conntrack_common_last_win_value =
13742 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13744 cmdline_parse_token_string_t cmd_set_conntrack_common_last_seq =
13745 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13746 last_seq, "last_seq");
13747 cmdline_parse_token_num_t cmd_set_conntrack_common_last_seq_value =
13748 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13750 cmdline_parse_token_string_t cmd_set_conntrack_common_last_ack =
13751 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13752 last_ack, "last_ack");
13753 cmdline_parse_token_num_t cmd_set_conntrack_common_last_ack_value =
13754 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13756 cmdline_parse_token_string_t cmd_set_conntrack_common_last_end =
13757 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13758 last_end, "last_end");
13759 cmdline_parse_token_num_t cmd_set_conntrack_common_last_end_value =
13760 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13762 cmdline_parse_token_string_t cmd_set_conntrack_common_last_index =
13763 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13764 last_index, "last_index");
13765 cmdline_parse_token_num_t cmd_set_conntrack_common_last_index_value =
13766 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13769 static void cmd_set_conntrack_common_parsed(void *parsed_result,
13770 __rte_unused struct cmdline *cl,
13771 __rte_unused void *data)
13773 struct cmd_set_conntrack_common_result *res = parsed_result;
13775 /* No need to swap to big endian. */
13776 conntrack_context.peer_port = res->peer_port;
13777 conntrack_context.is_original_dir = res->is_original;
13778 conntrack_context.enable = res->en;
13779 conntrack_context.live_connection = res->is_live;
13780 conntrack_context.selective_ack = res->s_ack;
13781 conntrack_context.challenge_ack_passed = res->c_ack;
13782 conntrack_context.last_direction = res->ld;
13783 conntrack_context.liberal_mode = res->lb;
13784 conntrack_context.state = (enum rte_flow_conntrack_state)res->stat;
13785 conntrack_context.max_ack_window = res->factor;
13786 conntrack_context.retransmission_limit = res->re_num;
13787 conntrack_context.last_window = res->lw;
13788 conntrack_context.last_index =
13789 (enum rte_flow_conntrack_tcp_last_index)res->li;
13790 conntrack_context.last_seq = res->ls;
13791 conntrack_context.last_ack = res->la;
13792 conntrack_context.last_end = res->le;
13795 cmdline_parse_inst_t cmd_set_conntrack_common = {
13796 .f = cmd_set_conntrack_common_parsed,
13798 .help_str = "set conntrack com peer <port_id> is_orig <dir> enable <en>"
13799 " live <ack_seen> sack <en> cack <passed> last_dir <dir>"
13800 " liberal <en> state <s> max_ack_win <factor> r_lim <num>"
13801 " last_win <win> last_seq <seq> last_ack <ack> last_end <end>"
13802 " last_index <flag>",
13804 (void *)&cmd_set_conntrack_set,
13805 (void *)&cmd_set_conntrack_conntrack,
13806 (void *)&cmd_set_conntrack_common_com,
13807 (void *)&cmd_set_conntrack_common_peer,
13808 (void *)&cmd_set_conntrack_common_peer_value,
13809 (void *)&cmd_set_conntrack_common_is_orig,
13810 (void *)&cmd_set_conntrack_common_is_orig_value,
13811 (void *)&cmd_set_conntrack_common_enable,
13812 (void *)&cmd_set_conntrack_common_enable_value,
13813 (void *)&cmd_set_conntrack_common_live,
13814 (void *)&cmd_set_conntrack_common_live_value,
13815 (void *)&cmd_set_conntrack_common_sack,
13816 (void *)&cmd_set_conntrack_common_sack_value,
13817 (void *)&cmd_set_conntrack_common_cack,
13818 (void *)&cmd_set_conntrack_common_cack_value,
13819 (void *)&cmd_set_conntrack_common_last_dir,
13820 (void *)&cmd_set_conntrack_common_last_dir_value,
13821 (void *)&cmd_set_conntrack_common_liberal,
13822 (void *)&cmd_set_conntrack_common_liberal_value,
13823 (void *)&cmd_set_conntrack_common_state,
13824 (void *)&cmd_set_conntrack_common_state_value,
13825 (void *)&cmd_set_conntrack_common_max_ackwin,
13826 (void *)&cmd_set_conntrack_common_max_ackwin_value,
13827 (void *)&cmd_set_conntrack_common_retrans,
13828 (void *)&cmd_set_conntrack_common_retrans_value,
13829 (void *)&cmd_set_conntrack_common_last_win,
13830 (void *)&cmd_set_conntrack_common_last_win_value,
13831 (void *)&cmd_set_conntrack_common_last_seq,
13832 (void *)&cmd_set_conntrack_common_last_seq_value,
13833 (void *)&cmd_set_conntrack_common_last_ack,
13834 (void *)&cmd_set_conntrack_common_last_ack_value,
13835 (void *)&cmd_set_conntrack_common_last_end,
13836 (void *)&cmd_set_conntrack_common_last_end_value,
13837 (void *)&cmd_set_conntrack_common_last_index,
13838 (void *)&cmd_set_conntrack_common_last_index_value,
13843 /** Set connection tracking object both directions' details */
13844 struct cmd_set_conntrack_dir_result {
13845 cmdline_fixed_string_t set;
13846 cmdline_fixed_string_t conntrack;
13847 cmdline_fixed_string_t dir;
13848 cmdline_fixed_string_t scale;
13849 cmdline_fixed_string_t fin;
13850 cmdline_fixed_string_t ack_seen;
13851 cmdline_fixed_string_t unack;
13852 cmdline_fixed_string_t sent_end;
13853 cmdline_fixed_string_t reply_end;
13854 cmdline_fixed_string_t max_win;
13855 cmdline_fixed_string_t max_ack;
13866 cmdline_parse_token_string_t cmd_set_conntrack_dir_set =
13867 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
13869 cmdline_parse_token_string_t cmd_set_conntrack_dir_conntrack =
13870 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
13871 conntrack, "conntrack");
13872 cmdline_parse_token_string_t cmd_set_conntrack_dir_dir =
13873 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
13875 cmdline_parse_token_string_t cmd_set_conntrack_dir_scale =
13876 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
13878 cmdline_parse_token_num_t cmd_set_conntrack_dir_scale_value =
13879 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
13880 factor, RTE_UINT32);
13881 cmdline_parse_token_string_t cmd_set_conntrack_dir_fin =
13882 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
13884 cmdline_parse_token_num_t cmd_set_conntrack_dir_fin_value =
13885 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
13887 cmdline_parse_token_string_t cmd_set_conntrack_dir_ack =
13888 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
13889 ack_seen, "acked");
13890 cmdline_parse_token_num_t cmd_set_conntrack_dir_ack_value =
13891 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
13893 cmdline_parse_token_string_t cmd_set_conntrack_dir_unack_data =
13894 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
13895 unack, "unack_data");
13896 cmdline_parse_token_num_t cmd_set_conntrack_dir_unack_data_value =
13897 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
13899 cmdline_parse_token_string_t cmd_set_conntrack_dir_sent_end =
13900 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
13901 sent_end, "sent_end");
13902 cmdline_parse_token_num_t cmd_set_conntrack_dir_sent_end_value =
13903 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
13905 cmdline_parse_token_string_t cmd_set_conntrack_dir_reply_end =
13906 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
13907 reply_end, "reply_end");
13908 cmdline_parse_token_num_t cmd_set_conntrack_dir_reply_end_value =
13909 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
13911 cmdline_parse_token_string_t cmd_set_conntrack_dir_max_win =
13912 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
13913 max_win, "max_win");
13914 cmdline_parse_token_num_t cmd_set_conntrack_dir_max_win_value =
13915 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
13917 cmdline_parse_token_string_t cmd_set_conntrack_dir_max_ack =
13918 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
13919 max_ack, "max_ack");
13920 cmdline_parse_token_num_t cmd_set_conntrack_dir_max_ack_value =
13921 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
13924 static void cmd_set_conntrack_dir_parsed(void *parsed_result,
13925 __rte_unused struct cmdline *cl,
13926 __rte_unused void *data)
13928 struct cmd_set_conntrack_dir_result *res = parsed_result;
13929 struct rte_flow_tcp_dir_param *dir = NULL;
13931 if (strcmp(res->dir, "orig") == 0)
13932 dir = &conntrack_context.original_dir;
13933 else if (strcmp(res->dir, "rply") == 0)
13934 dir = &conntrack_context.reply_dir;
13937 dir->scale = res->factor;
13938 dir->close_initiated = res->f;
13939 dir->last_ack_seen = res->as;
13940 dir->data_unacked = res->un;
13941 dir->sent_end = res->se;
13942 dir->reply_end = res->re;
13943 dir->max_ack = res->ma;
13944 dir->max_win = res->mw;
13947 cmdline_parse_inst_t cmd_set_conntrack_dir = {
13948 .f = cmd_set_conntrack_dir_parsed,
13950 .help_str = "set conntrack orig|rply scale <factor> fin <sent>"
13951 " acked <seen> unack_data <unack> sent_end <sent>"
13952 " reply_end <reply> max_win <win> max_ack <ack>",
13954 (void *)&cmd_set_conntrack_set,
13955 (void *)&cmd_set_conntrack_conntrack,
13956 (void *)&cmd_set_conntrack_dir_dir,
13957 (void *)&cmd_set_conntrack_dir_scale,
13958 (void *)&cmd_set_conntrack_dir_scale_value,
13959 (void *)&cmd_set_conntrack_dir_fin,
13960 (void *)&cmd_set_conntrack_dir_fin_value,
13961 (void *)&cmd_set_conntrack_dir_ack,
13962 (void *)&cmd_set_conntrack_dir_ack_value,
13963 (void *)&cmd_set_conntrack_dir_unack_data,
13964 (void *)&cmd_set_conntrack_dir_unack_data_value,
13965 (void *)&cmd_set_conntrack_dir_sent_end,
13966 (void *)&cmd_set_conntrack_dir_sent_end_value,
13967 (void *)&cmd_set_conntrack_dir_reply_end,
13968 (void *)&cmd_set_conntrack_dir_reply_end_value,
13969 (void *)&cmd_set_conntrack_dir_max_win,
13970 (void *)&cmd_set_conntrack_dir_max_win_value,
13971 (void *)&cmd_set_conntrack_dir_max_ack,
13972 (void *)&cmd_set_conntrack_dir_max_ack_value,
13977 /* Strict link priority scheduling mode setting */
13979 cmd_strict_link_prio_parsed(
13980 void *parsed_result,
13981 __rte_unused struct cmdline *cl,
13982 __rte_unused void *data)
13984 struct cmd_vf_tc_bw_result *res = parsed_result;
13985 int ret = -ENOTSUP;
13987 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13990 #ifdef RTE_NET_I40E
13991 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
13998 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
14001 printf("invalid port_id %d\n", res->port_id);
14004 printf("function not implemented\n");
14007 printf("programming error: (%s)\n", strerror(-ret));
14011 cmdline_parse_inst_t cmd_strict_link_prio = {
14012 .f = cmd_strict_link_prio_parsed,
14014 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
14016 (void *)&cmd_vf_tc_bw_set,
14017 (void *)&cmd_vf_tc_bw_tx,
14018 (void *)&cmd_vf_tc_bw_strict_link_prio,
14019 (void *)&cmd_vf_tc_bw_port_id,
14020 (void *)&cmd_vf_tc_bw_tc_map,
14025 /* Load dynamic device personalization*/
14026 struct cmd_ddp_add_result {
14027 cmdline_fixed_string_t ddp;
14028 cmdline_fixed_string_t add;
14033 cmdline_parse_token_string_t cmd_ddp_add_ddp =
14034 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
14035 cmdline_parse_token_string_t cmd_ddp_add_add =
14036 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
14037 cmdline_parse_token_num_t cmd_ddp_add_port_id =
14038 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id,
14040 cmdline_parse_token_string_t cmd_ddp_add_filepath =
14041 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
14044 cmd_ddp_add_parsed(
14045 void *parsed_result,
14046 __rte_unused struct cmdline *cl,
14047 __rte_unused void *data)
14049 struct cmd_ddp_add_result *res = parsed_result;
14055 int ret = -ENOTSUP;
14057 if (!all_ports_stopped()) {
14058 printf("Please stop all ports first\n");
14062 filepath = strdup(res->filepath);
14063 if (filepath == NULL) {
14064 printf("Failed to allocate memory\n");
14067 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
14069 buff = open_file(file_fld[0], &size);
14071 free((void *)filepath);
14075 #ifdef RTE_NET_I40E
14076 if (ret == -ENOTSUP)
14077 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14079 RTE_PMD_I40E_PKG_OP_WR_ADD);
14082 if (ret == -EEXIST)
14083 printf("Profile has already existed.\n");
14085 printf("Failed to load profile.\n");
14086 else if (file_num == 2)
14087 save_file(file_fld[1], buff, size);
14090 free((void *)filepath);
14093 cmdline_parse_inst_t cmd_ddp_add = {
14094 .f = cmd_ddp_add_parsed,
14096 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
14098 (void *)&cmd_ddp_add_ddp,
14099 (void *)&cmd_ddp_add_add,
14100 (void *)&cmd_ddp_add_port_id,
14101 (void *)&cmd_ddp_add_filepath,
14106 /* Delete dynamic device personalization*/
14107 struct cmd_ddp_del_result {
14108 cmdline_fixed_string_t ddp;
14109 cmdline_fixed_string_t del;
14114 cmdline_parse_token_string_t cmd_ddp_del_ddp =
14115 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
14116 cmdline_parse_token_string_t cmd_ddp_del_del =
14117 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
14118 cmdline_parse_token_num_t cmd_ddp_del_port_id =
14119 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, RTE_UINT16);
14120 cmdline_parse_token_string_t cmd_ddp_del_filepath =
14121 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
14124 cmd_ddp_del_parsed(
14125 void *parsed_result,
14126 __rte_unused struct cmdline *cl,
14127 __rte_unused void *data)
14129 struct cmd_ddp_del_result *res = parsed_result;
14132 int ret = -ENOTSUP;
14134 if (!all_ports_stopped()) {
14135 printf("Please stop all ports first\n");
14139 buff = open_file(res->filepath, &size);
14143 #ifdef RTE_NET_I40E
14144 if (ret == -ENOTSUP)
14145 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14147 RTE_PMD_I40E_PKG_OP_WR_DEL);
14150 if (ret == -EACCES)
14151 printf("Profile does not exist.\n");
14153 printf("Failed to delete profile.\n");
14158 cmdline_parse_inst_t cmd_ddp_del = {
14159 .f = cmd_ddp_del_parsed,
14161 .help_str = "ddp del <port_id> <backup_profile_path>",
14163 (void *)&cmd_ddp_del_ddp,
14164 (void *)&cmd_ddp_del_del,
14165 (void *)&cmd_ddp_del_port_id,
14166 (void *)&cmd_ddp_del_filepath,
14171 /* Get dynamic device personalization profile info */
14172 struct cmd_ddp_info_result {
14173 cmdline_fixed_string_t ddp;
14174 cmdline_fixed_string_t get;
14175 cmdline_fixed_string_t info;
14179 cmdline_parse_token_string_t cmd_ddp_info_ddp =
14180 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
14181 cmdline_parse_token_string_t cmd_ddp_info_get =
14182 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
14183 cmdline_parse_token_string_t cmd_ddp_info_info =
14184 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
14185 cmdline_parse_token_string_t cmd_ddp_info_filepath =
14186 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
14189 cmd_ddp_info_parsed(
14190 void *parsed_result,
14191 __rte_unused struct cmdline *cl,
14192 __rte_unused void *data)
14194 struct cmd_ddp_info_result *res = parsed_result;
14197 int ret = -ENOTSUP;
14198 #ifdef RTE_NET_I40E
14201 uint32_t buff_size = 0;
14202 struct rte_pmd_i40e_profile_info info;
14203 uint32_t dev_num = 0;
14204 struct rte_pmd_i40e_ddp_device_id *devs;
14205 uint32_t proto_num = 0;
14206 struct rte_pmd_i40e_proto_info *proto = NULL;
14207 uint32_t pctype_num = 0;
14208 struct rte_pmd_i40e_ptype_info *pctype;
14209 uint32_t ptype_num = 0;
14210 struct rte_pmd_i40e_ptype_info *ptype;
14215 pkg = open_file(res->filepath, &pkg_size);
14219 #ifdef RTE_NET_I40E
14220 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14221 (uint8_t *)&info, sizeof(info),
14222 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
14224 printf("Global Track id: 0x%x\n", info.track_id);
14225 printf("Global Version: %d.%d.%d.%d\n",
14226 info.version.major,
14227 info.version.minor,
14228 info.version.update,
14229 info.version.draft);
14230 printf("Global Package name: %s\n\n", info.name);
14233 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14234 (uint8_t *)&info, sizeof(info),
14235 RTE_PMD_I40E_PKG_INFO_HEADER);
14237 printf("i40e Profile Track id: 0x%x\n", info.track_id);
14238 printf("i40e Profile Version: %d.%d.%d.%d\n",
14239 info.version.major,
14240 info.version.minor,
14241 info.version.update,
14242 info.version.draft);
14243 printf("i40e Profile name: %s\n\n", info.name);
14246 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14247 (uint8_t *)&buff_size, sizeof(buff_size),
14248 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
14249 if (!ret && buff_size) {
14250 buff = (uint8_t *)malloc(buff_size);
14252 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14254 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
14256 printf("Package Notes:\n%s\n\n", buff);
14261 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14262 (uint8_t *)&dev_num, sizeof(dev_num),
14263 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
14264 if (!ret && dev_num) {
14265 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
14266 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
14268 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14269 (uint8_t *)devs, buff_size,
14270 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
14272 printf("List of supported devices:\n");
14273 for (i = 0; i < dev_num; i++) {
14274 printf(" %04X:%04X %04X:%04X\n",
14275 devs[i].vendor_dev_id >> 16,
14276 devs[i].vendor_dev_id & 0xFFFF,
14277 devs[i].sub_vendor_dev_id >> 16,
14278 devs[i].sub_vendor_dev_id & 0xFFFF);
14286 /* get information about protocols and packet types */
14287 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14288 (uint8_t *)&proto_num, sizeof(proto_num),
14289 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
14290 if (ret || !proto_num)
14291 goto no_print_return;
14293 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
14294 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
14296 goto no_print_return;
14298 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
14300 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
14302 printf("List of used protocols:\n");
14303 for (i = 0; i < proto_num; i++)
14304 printf(" %2u: %s\n", proto[i].proto_id,
14308 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14309 (uint8_t *)&pctype_num, sizeof(pctype_num),
14310 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
14311 if (ret || !pctype_num)
14312 goto no_print_pctypes;
14314 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14315 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14317 goto no_print_pctypes;
14319 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
14321 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
14324 goto no_print_pctypes;
14327 printf("List of defined packet classification types:\n");
14328 for (i = 0; i < pctype_num; i++) {
14329 printf(" %2u:", pctype[i].ptype_id);
14330 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14331 proto_id = pctype[i].protocols[j];
14332 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14333 for (n = 0; n < proto_num; n++) {
14334 if (proto[n].proto_id == proto_id) {
14335 printf(" %s", proto[n].name);
14348 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
14350 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
14351 if (ret || !ptype_num)
14352 goto no_print_return;
14354 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14355 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14357 goto no_print_return;
14359 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
14361 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
14364 goto no_print_return;
14366 printf("List of defined packet types:\n");
14367 for (i = 0; i < ptype_num; i++) {
14368 printf(" %2u:", ptype[i].ptype_id);
14369 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14370 proto_id = ptype[i].protocols[j];
14371 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14372 for (n = 0; n < proto_num; n++) {
14373 if (proto[n].proto_id == proto_id) {
14374 printf(" %s", proto[n].name);
14390 if (ret == -ENOTSUP)
14391 printf("Function not supported in PMD driver\n");
14395 cmdline_parse_inst_t cmd_ddp_get_info = {
14396 .f = cmd_ddp_info_parsed,
14398 .help_str = "ddp get info <profile_path>",
14400 (void *)&cmd_ddp_info_ddp,
14401 (void *)&cmd_ddp_info_get,
14402 (void *)&cmd_ddp_info_info,
14403 (void *)&cmd_ddp_info_filepath,
14408 /* Get dynamic device personalization profile info list*/
14409 #define PROFILE_INFO_SIZE 48
14410 #define MAX_PROFILE_NUM 16
14412 struct cmd_ddp_get_list_result {
14413 cmdline_fixed_string_t ddp;
14414 cmdline_fixed_string_t get;
14415 cmdline_fixed_string_t list;
14419 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
14420 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
14421 cmdline_parse_token_string_t cmd_ddp_get_list_get =
14422 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
14423 cmdline_parse_token_string_t cmd_ddp_get_list_list =
14424 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
14425 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
14426 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id,
14430 cmd_ddp_get_list_parsed(
14431 __rte_unused void *parsed_result,
14432 __rte_unused struct cmdline *cl,
14433 __rte_unused void *data)
14435 #ifdef RTE_NET_I40E
14436 struct cmd_ddp_get_list_result *res = parsed_result;
14437 struct rte_pmd_i40e_profile_list *p_list;
14438 struct rte_pmd_i40e_profile_info *p_info;
14443 int ret = -ENOTSUP;
14445 #ifdef RTE_NET_I40E
14446 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
14447 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
14449 printf("%s: Failed to malloc buffer\n", __func__);
14453 if (ret == -ENOTSUP)
14454 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
14455 (uint8_t *)p_list, size);
14458 p_num = p_list->p_count;
14459 printf("Profile number is: %d\n\n", p_num);
14461 for (i = 0; i < p_num; i++) {
14462 p_info = &p_list->p_info[i];
14463 printf("Profile %d:\n", i);
14464 printf("Track id: 0x%x\n", p_info->track_id);
14465 printf("Version: %d.%d.%d.%d\n",
14466 p_info->version.major,
14467 p_info->version.minor,
14468 p_info->version.update,
14469 p_info->version.draft);
14470 printf("Profile name: %s\n\n", p_info->name);
14478 printf("Failed to get ddp list\n");
14481 cmdline_parse_inst_t cmd_ddp_get_list = {
14482 .f = cmd_ddp_get_list_parsed,
14484 .help_str = "ddp get list <port_id>",
14486 (void *)&cmd_ddp_get_list_ddp,
14487 (void *)&cmd_ddp_get_list_get,
14488 (void *)&cmd_ddp_get_list_list,
14489 (void *)&cmd_ddp_get_list_port_id,
14494 /* Configure input set */
14495 struct cmd_cfg_input_set_result {
14496 cmdline_fixed_string_t port;
14497 cmdline_fixed_string_t cfg;
14499 cmdline_fixed_string_t pctype;
14501 cmdline_fixed_string_t inset_type;
14502 cmdline_fixed_string_t opt;
14503 cmdline_fixed_string_t field;
14508 cmd_cfg_input_set_parsed(
14509 __rte_unused void *parsed_result,
14510 __rte_unused struct cmdline *cl,
14511 __rte_unused void *data)
14513 #ifdef RTE_NET_I40E
14514 struct cmd_cfg_input_set_result *res = parsed_result;
14515 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
14516 struct rte_pmd_i40e_inset inset;
14518 int ret = -ENOTSUP;
14520 if (!all_ports_stopped()) {
14521 printf("Please stop all ports first\n");
14525 #ifdef RTE_NET_I40E
14526 if (!strcmp(res->inset_type, "hash_inset"))
14527 inset_type = INSET_HASH;
14528 else if (!strcmp(res->inset_type, "fdir_inset"))
14529 inset_type = INSET_FDIR;
14530 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
14531 inset_type = INSET_FDIR_FLX;
14532 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
14533 &inset, inset_type);
14535 printf("Failed to get input set.\n");
14539 if (!strcmp(res->opt, "get")) {
14540 ret = rte_pmd_i40e_inset_field_get(inset.inset,
14543 printf("Field index %d is enabled.\n", res->field_idx);
14545 printf("Field index %d is disabled.\n", res->field_idx);
14547 } else if (!strcmp(res->opt, "set"))
14548 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
14550 else if (!strcmp(res->opt, "clear"))
14551 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
14554 printf("Failed to configure input set field.\n");
14558 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
14559 &inset, inset_type);
14561 printf("Failed to set input set.\n");
14566 if (ret == -ENOTSUP)
14567 printf("Function not supported\n");
14570 cmdline_parse_token_string_t cmd_cfg_input_set_port =
14571 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14573 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
14574 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14576 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
14577 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14578 port_id, RTE_UINT16);
14579 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
14580 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14582 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
14583 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14584 pctype_id, RTE_UINT8);
14585 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
14586 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14588 "hash_inset#fdir_inset#fdir_flx_inset");
14589 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
14590 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14591 opt, "get#set#clear");
14592 cmdline_parse_token_string_t cmd_cfg_input_set_field =
14593 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14595 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
14596 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14597 field_idx, RTE_UINT8);
14599 cmdline_parse_inst_t cmd_cfg_input_set = {
14600 .f = cmd_cfg_input_set_parsed,
14602 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
14603 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
14605 (void *)&cmd_cfg_input_set_port,
14606 (void *)&cmd_cfg_input_set_cfg,
14607 (void *)&cmd_cfg_input_set_port_id,
14608 (void *)&cmd_cfg_input_set_pctype,
14609 (void *)&cmd_cfg_input_set_pctype_id,
14610 (void *)&cmd_cfg_input_set_inset_type,
14611 (void *)&cmd_cfg_input_set_opt,
14612 (void *)&cmd_cfg_input_set_field,
14613 (void *)&cmd_cfg_input_set_field_idx,
14618 /* Clear input set */
14619 struct cmd_clear_input_set_result {
14620 cmdline_fixed_string_t port;
14621 cmdline_fixed_string_t cfg;
14623 cmdline_fixed_string_t pctype;
14625 cmdline_fixed_string_t inset_type;
14626 cmdline_fixed_string_t clear;
14627 cmdline_fixed_string_t all;
14631 cmd_clear_input_set_parsed(
14632 __rte_unused void *parsed_result,
14633 __rte_unused struct cmdline *cl,
14634 __rte_unused void *data)
14636 #ifdef RTE_NET_I40E
14637 struct cmd_clear_input_set_result *res = parsed_result;
14638 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
14639 struct rte_pmd_i40e_inset inset;
14641 int ret = -ENOTSUP;
14643 if (!all_ports_stopped()) {
14644 printf("Please stop all ports first\n");
14648 #ifdef RTE_NET_I40E
14649 if (!strcmp(res->inset_type, "hash_inset"))
14650 inset_type = INSET_HASH;
14651 else if (!strcmp(res->inset_type, "fdir_inset"))
14652 inset_type = INSET_FDIR;
14653 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
14654 inset_type = INSET_FDIR_FLX;
14656 memset(&inset, 0, sizeof(inset));
14658 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
14659 &inset, inset_type);
14661 printf("Failed to clear input set.\n");
14667 if (ret == -ENOTSUP)
14668 printf("Function not supported\n");
14671 cmdline_parse_token_string_t cmd_clear_input_set_port =
14672 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14674 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
14675 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14677 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
14678 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
14679 port_id, RTE_UINT16);
14680 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
14681 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14683 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
14684 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
14685 pctype_id, RTE_UINT8);
14686 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
14687 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14689 "hash_inset#fdir_inset#fdir_flx_inset");
14690 cmdline_parse_token_string_t cmd_clear_input_set_clear =
14691 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14693 cmdline_parse_token_string_t cmd_clear_input_set_all =
14694 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14697 cmdline_parse_inst_t cmd_clear_input_set = {
14698 .f = cmd_clear_input_set_parsed,
14700 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
14701 "fdir_inset|fdir_flx_inset clear all",
14703 (void *)&cmd_clear_input_set_port,
14704 (void *)&cmd_clear_input_set_cfg,
14705 (void *)&cmd_clear_input_set_port_id,
14706 (void *)&cmd_clear_input_set_pctype,
14707 (void *)&cmd_clear_input_set_pctype_id,
14708 (void *)&cmd_clear_input_set_inset_type,
14709 (void *)&cmd_clear_input_set_clear,
14710 (void *)&cmd_clear_input_set_all,
14715 /* show vf stats */
14717 /* Common result structure for show vf stats */
14718 struct cmd_show_vf_stats_result {
14719 cmdline_fixed_string_t show;
14720 cmdline_fixed_string_t vf;
14721 cmdline_fixed_string_t stats;
14726 /* Common CLI fields show vf stats*/
14727 cmdline_parse_token_string_t cmd_show_vf_stats_show =
14728 TOKEN_STRING_INITIALIZER
14729 (struct cmd_show_vf_stats_result,
14731 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
14732 TOKEN_STRING_INITIALIZER
14733 (struct cmd_show_vf_stats_result,
14735 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
14736 TOKEN_STRING_INITIALIZER
14737 (struct cmd_show_vf_stats_result,
14739 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
14740 TOKEN_NUM_INITIALIZER
14741 (struct cmd_show_vf_stats_result,
14742 port_id, RTE_UINT16);
14743 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
14744 TOKEN_NUM_INITIALIZER
14745 (struct cmd_show_vf_stats_result,
14746 vf_id, RTE_UINT16);
14749 cmd_show_vf_stats_parsed(
14750 void *parsed_result,
14751 __rte_unused struct cmdline *cl,
14752 __rte_unused void *data)
14754 struct cmd_show_vf_stats_result *res = parsed_result;
14755 struct rte_eth_stats stats;
14756 int ret = -ENOTSUP;
14757 static const char *nic_stats_border = "########################";
14759 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14762 memset(&stats, 0, sizeof(stats));
14764 #ifdef RTE_NET_I40E
14765 if (ret == -ENOTSUP)
14766 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
14770 #ifdef RTE_NET_BNXT
14771 if (ret == -ENOTSUP)
14772 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
14781 printf("invalid vf_id %d\n", res->vf_id);
14784 printf("invalid port_id %d\n", res->port_id);
14787 printf("function not implemented\n");
14790 printf("programming error: (%s)\n", strerror(-ret));
14793 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
14794 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
14796 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
14798 stats.ipackets, stats.imissed, stats.ibytes);
14799 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
14800 printf(" RX-nombuf: %-10"PRIu64"\n",
14802 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
14804 stats.opackets, stats.oerrors, stats.obytes);
14806 printf(" %s############################%s\n",
14807 nic_stats_border, nic_stats_border);
14810 cmdline_parse_inst_t cmd_show_vf_stats = {
14811 .f = cmd_show_vf_stats_parsed,
14813 .help_str = "show vf stats <port_id> <vf_id>",
14815 (void *)&cmd_show_vf_stats_show,
14816 (void *)&cmd_show_vf_stats_vf,
14817 (void *)&cmd_show_vf_stats_stats,
14818 (void *)&cmd_show_vf_stats_port_id,
14819 (void *)&cmd_show_vf_stats_vf_id,
14824 /* clear vf stats */
14826 /* Common result structure for clear vf stats */
14827 struct cmd_clear_vf_stats_result {
14828 cmdline_fixed_string_t clear;
14829 cmdline_fixed_string_t vf;
14830 cmdline_fixed_string_t stats;
14835 /* Common CLI fields clear vf stats*/
14836 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
14837 TOKEN_STRING_INITIALIZER
14838 (struct cmd_clear_vf_stats_result,
14840 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
14841 TOKEN_STRING_INITIALIZER
14842 (struct cmd_clear_vf_stats_result,
14844 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
14845 TOKEN_STRING_INITIALIZER
14846 (struct cmd_clear_vf_stats_result,
14848 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
14849 TOKEN_NUM_INITIALIZER
14850 (struct cmd_clear_vf_stats_result,
14851 port_id, RTE_UINT16);
14852 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
14853 TOKEN_NUM_INITIALIZER
14854 (struct cmd_clear_vf_stats_result,
14855 vf_id, RTE_UINT16);
14858 cmd_clear_vf_stats_parsed(
14859 void *parsed_result,
14860 __rte_unused struct cmdline *cl,
14861 __rte_unused void *data)
14863 struct cmd_clear_vf_stats_result *res = parsed_result;
14864 int ret = -ENOTSUP;
14866 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14869 #ifdef RTE_NET_I40E
14870 if (ret == -ENOTSUP)
14871 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
14874 #ifdef RTE_NET_BNXT
14875 if (ret == -ENOTSUP)
14876 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
14884 printf("invalid vf_id %d\n", res->vf_id);
14887 printf("invalid port_id %d\n", res->port_id);
14890 printf("function not implemented\n");
14893 printf("programming error: (%s)\n", strerror(-ret));
14897 cmdline_parse_inst_t cmd_clear_vf_stats = {
14898 .f = cmd_clear_vf_stats_parsed,
14900 .help_str = "clear vf stats <port_id> <vf_id>",
14902 (void *)&cmd_clear_vf_stats_clear,
14903 (void *)&cmd_clear_vf_stats_vf,
14904 (void *)&cmd_clear_vf_stats_stats,
14905 (void *)&cmd_clear_vf_stats_port_id,
14906 (void *)&cmd_clear_vf_stats_vf_id,
14911 /* port config pctype mapping reset */
14913 /* Common result structure for port config pctype mapping reset */
14914 struct cmd_pctype_mapping_reset_result {
14915 cmdline_fixed_string_t port;
14916 cmdline_fixed_string_t config;
14918 cmdline_fixed_string_t pctype;
14919 cmdline_fixed_string_t mapping;
14920 cmdline_fixed_string_t reset;
14923 /* Common CLI fields for port config pctype mapping reset*/
14924 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
14925 TOKEN_STRING_INITIALIZER
14926 (struct cmd_pctype_mapping_reset_result,
14928 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
14929 TOKEN_STRING_INITIALIZER
14930 (struct cmd_pctype_mapping_reset_result,
14932 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
14933 TOKEN_NUM_INITIALIZER
14934 (struct cmd_pctype_mapping_reset_result,
14935 port_id, RTE_UINT16);
14936 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
14937 TOKEN_STRING_INITIALIZER
14938 (struct cmd_pctype_mapping_reset_result,
14940 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
14941 TOKEN_STRING_INITIALIZER
14942 (struct cmd_pctype_mapping_reset_result,
14943 mapping, "mapping");
14944 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
14945 TOKEN_STRING_INITIALIZER
14946 (struct cmd_pctype_mapping_reset_result,
14950 cmd_pctype_mapping_reset_parsed(
14951 void *parsed_result,
14952 __rte_unused struct cmdline *cl,
14953 __rte_unused void *data)
14955 struct cmd_pctype_mapping_reset_result *res = parsed_result;
14956 int ret = -ENOTSUP;
14958 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14961 #ifdef RTE_NET_I40E
14962 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
14969 printf("invalid port_id %d\n", res->port_id);
14972 printf("function not implemented\n");
14975 printf("programming error: (%s)\n", strerror(-ret));
14979 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
14980 .f = cmd_pctype_mapping_reset_parsed,
14982 .help_str = "port config <port_id> pctype mapping reset",
14984 (void *)&cmd_pctype_mapping_reset_port,
14985 (void *)&cmd_pctype_mapping_reset_config,
14986 (void *)&cmd_pctype_mapping_reset_port_id,
14987 (void *)&cmd_pctype_mapping_reset_pctype,
14988 (void *)&cmd_pctype_mapping_reset_mapping,
14989 (void *)&cmd_pctype_mapping_reset_reset,
14994 /* show port pctype mapping */
14996 /* Common result structure for show port pctype mapping */
14997 struct cmd_pctype_mapping_get_result {
14998 cmdline_fixed_string_t show;
14999 cmdline_fixed_string_t port;
15001 cmdline_fixed_string_t pctype;
15002 cmdline_fixed_string_t mapping;
15005 /* Common CLI fields for pctype mapping get */
15006 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
15007 TOKEN_STRING_INITIALIZER
15008 (struct cmd_pctype_mapping_get_result,
15010 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
15011 TOKEN_STRING_INITIALIZER
15012 (struct cmd_pctype_mapping_get_result,
15014 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
15015 TOKEN_NUM_INITIALIZER
15016 (struct cmd_pctype_mapping_get_result,
15017 port_id, RTE_UINT16);
15018 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
15019 TOKEN_STRING_INITIALIZER
15020 (struct cmd_pctype_mapping_get_result,
15022 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
15023 TOKEN_STRING_INITIALIZER
15024 (struct cmd_pctype_mapping_get_result,
15025 mapping, "mapping");
15028 cmd_pctype_mapping_get_parsed(
15029 void *parsed_result,
15030 __rte_unused struct cmdline *cl,
15031 __rte_unused void *data)
15033 struct cmd_pctype_mapping_get_result *res = parsed_result;
15034 int ret = -ENOTSUP;
15035 #ifdef RTE_NET_I40E
15036 struct rte_pmd_i40e_flow_type_mapping
15037 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
15038 int i, j, first_pctype;
15041 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15044 #ifdef RTE_NET_I40E
15045 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
15052 printf("invalid port_id %d\n", res->port_id);
15055 printf("function not implemented\n");
15058 printf("programming error: (%s)\n", strerror(-ret));
15062 #ifdef RTE_NET_I40E
15063 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
15064 if (mapping[i].pctype != 0ULL) {
15067 printf("pctype: ");
15068 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
15069 if (mapping[i].pctype & (1ULL << j)) {
15070 printf(first_pctype ?
15071 "%02d" : ",%02d", j);
15075 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
15081 cmdline_parse_inst_t cmd_pctype_mapping_get = {
15082 .f = cmd_pctype_mapping_get_parsed,
15084 .help_str = "show port <port_id> pctype mapping",
15086 (void *)&cmd_pctype_mapping_get_show,
15087 (void *)&cmd_pctype_mapping_get_port,
15088 (void *)&cmd_pctype_mapping_get_port_id,
15089 (void *)&cmd_pctype_mapping_get_pctype,
15090 (void *)&cmd_pctype_mapping_get_mapping,
15095 /* port config pctype mapping update */
15097 /* Common result structure for port config pctype mapping update */
15098 struct cmd_pctype_mapping_update_result {
15099 cmdline_fixed_string_t port;
15100 cmdline_fixed_string_t config;
15102 cmdline_fixed_string_t pctype;
15103 cmdline_fixed_string_t mapping;
15104 cmdline_fixed_string_t update;
15105 cmdline_fixed_string_t pctype_list;
15106 uint16_t flow_type;
15109 /* Common CLI fields for pctype mapping update*/
15110 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
15111 TOKEN_STRING_INITIALIZER
15112 (struct cmd_pctype_mapping_update_result,
15114 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
15115 TOKEN_STRING_INITIALIZER
15116 (struct cmd_pctype_mapping_update_result,
15118 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
15119 TOKEN_NUM_INITIALIZER
15120 (struct cmd_pctype_mapping_update_result,
15121 port_id, RTE_UINT16);
15122 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
15123 TOKEN_STRING_INITIALIZER
15124 (struct cmd_pctype_mapping_update_result,
15126 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
15127 TOKEN_STRING_INITIALIZER
15128 (struct cmd_pctype_mapping_update_result,
15129 mapping, "mapping");
15130 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
15131 TOKEN_STRING_INITIALIZER
15132 (struct cmd_pctype_mapping_update_result,
15134 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
15135 TOKEN_STRING_INITIALIZER
15136 (struct cmd_pctype_mapping_update_result,
15137 pctype_list, NULL);
15138 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
15139 TOKEN_NUM_INITIALIZER
15140 (struct cmd_pctype_mapping_update_result,
15141 flow_type, RTE_UINT16);
15144 cmd_pctype_mapping_update_parsed(
15145 void *parsed_result,
15146 __rte_unused struct cmdline *cl,
15147 __rte_unused void *data)
15149 struct cmd_pctype_mapping_update_result *res = parsed_result;
15150 int ret = -ENOTSUP;
15151 #ifdef RTE_NET_I40E
15152 struct rte_pmd_i40e_flow_type_mapping mapping;
15154 unsigned int nb_item;
15155 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
15158 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15161 #ifdef RTE_NET_I40E
15162 nb_item = parse_item_list(res->pctype_list, "pctypes",
15163 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
15164 mapping.flow_type = res->flow_type;
15165 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
15166 mapping.pctype |= (1ULL << pctype_list[i]);
15167 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
15177 printf("invalid pctype or flow type\n");
15180 printf("invalid port_id %d\n", res->port_id);
15183 printf("function not implemented\n");
15186 printf("programming error: (%s)\n", strerror(-ret));
15190 cmdline_parse_inst_t cmd_pctype_mapping_update = {
15191 .f = cmd_pctype_mapping_update_parsed,
15193 .help_str = "port config <port_id> pctype mapping update"
15194 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
15196 (void *)&cmd_pctype_mapping_update_port,
15197 (void *)&cmd_pctype_mapping_update_config,
15198 (void *)&cmd_pctype_mapping_update_port_id,
15199 (void *)&cmd_pctype_mapping_update_pctype,
15200 (void *)&cmd_pctype_mapping_update_mapping,
15201 (void *)&cmd_pctype_mapping_update_update,
15202 (void *)&cmd_pctype_mapping_update_pc_type,
15203 (void *)&cmd_pctype_mapping_update_flow_type,
15208 /* ptype mapping get */
15210 /* Common result structure for ptype mapping get */
15211 struct cmd_ptype_mapping_get_result {
15212 cmdline_fixed_string_t ptype;
15213 cmdline_fixed_string_t mapping;
15214 cmdline_fixed_string_t get;
15216 uint8_t valid_only;
15219 /* Common CLI fields for ptype mapping get */
15220 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
15221 TOKEN_STRING_INITIALIZER
15222 (struct cmd_ptype_mapping_get_result,
15224 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
15225 TOKEN_STRING_INITIALIZER
15226 (struct cmd_ptype_mapping_get_result,
15227 mapping, "mapping");
15228 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
15229 TOKEN_STRING_INITIALIZER
15230 (struct cmd_ptype_mapping_get_result,
15232 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
15233 TOKEN_NUM_INITIALIZER
15234 (struct cmd_ptype_mapping_get_result,
15235 port_id, RTE_UINT16);
15236 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
15237 TOKEN_NUM_INITIALIZER
15238 (struct cmd_ptype_mapping_get_result,
15239 valid_only, RTE_UINT8);
15242 cmd_ptype_mapping_get_parsed(
15243 void *parsed_result,
15244 __rte_unused struct cmdline *cl,
15245 __rte_unused void *data)
15247 struct cmd_ptype_mapping_get_result *res = parsed_result;
15248 int ret = -ENOTSUP;
15249 #ifdef RTE_NET_I40E
15250 int max_ptype_num = 256;
15251 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
15256 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15259 #ifdef RTE_NET_I40E
15260 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
15271 printf("invalid port_id %d\n", res->port_id);
15274 printf("function not implemented\n");
15277 printf("programming error: (%s)\n", strerror(-ret));
15280 #ifdef RTE_NET_I40E
15282 for (i = 0; i < count; i++)
15283 printf("%3d\t0x%08x\n",
15284 mapping[i].hw_ptype, mapping[i].sw_ptype);
15289 cmdline_parse_inst_t cmd_ptype_mapping_get = {
15290 .f = cmd_ptype_mapping_get_parsed,
15292 .help_str = "ptype mapping get <port_id> <valid_only>",
15294 (void *)&cmd_ptype_mapping_get_ptype,
15295 (void *)&cmd_ptype_mapping_get_mapping,
15296 (void *)&cmd_ptype_mapping_get_get,
15297 (void *)&cmd_ptype_mapping_get_port_id,
15298 (void *)&cmd_ptype_mapping_get_valid_only,
15303 /* ptype mapping replace */
15305 /* Common result structure for ptype mapping replace */
15306 struct cmd_ptype_mapping_replace_result {
15307 cmdline_fixed_string_t ptype;
15308 cmdline_fixed_string_t mapping;
15309 cmdline_fixed_string_t replace;
15316 /* Common CLI fields for ptype mapping replace */
15317 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
15318 TOKEN_STRING_INITIALIZER
15319 (struct cmd_ptype_mapping_replace_result,
15321 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
15322 TOKEN_STRING_INITIALIZER
15323 (struct cmd_ptype_mapping_replace_result,
15324 mapping, "mapping");
15325 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
15326 TOKEN_STRING_INITIALIZER
15327 (struct cmd_ptype_mapping_replace_result,
15328 replace, "replace");
15329 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
15330 TOKEN_NUM_INITIALIZER
15331 (struct cmd_ptype_mapping_replace_result,
15332 port_id, RTE_UINT16);
15333 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
15334 TOKEN_NUM_INITIALIZER
15335 (struct cmd_ptype_mapping_replace_result,
15336 target, RTE_UINT32);
15337 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
15338 TOKEN_NUM_INITIALIZER
15339 (struct cmd_ptype_mapping_replace_result,
15341 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
15342 TOKEN_NUM_INITIALIZER
15343 (struct cmd_ptype_mapping_replace_result,
15344 pkt_type, RTE_UINT32);
15347 cmd_ptype_mapping_replace_parsed(
15348 void *parsed_result,
15349 __rte_unused struct cmdline *cl,
15350 __rte_unused void *data)
15352 struct cmd_ptype_mapping_replace_result *res = parsed_result;
15353 int ret = -ENOTSUP;
15355 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15358 #ifdef RTE_NET_I40E
15359 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
15369 printf("invalid ptype 0x%8x or 0x%8x\n",
15370 res->target, res->pkt_type);
15373 printf("invalid port_id %d\n", res->port_id);
15376 printf("function not implemented\n");
15379 printf("programming error: (%s)\n", strerror(-ret));
15383 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
15384 .f = cmd_ptype_mapping_replace_parsed,
15387 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
15389 (void *)&cmd_ptype_mapping_replace_ptype,
15390 (void *)&cmd_ptype_mapping_replace_mapping,
15391 (void *)&cmd_ptype_mapping_replace_replace,
15392 (void *)&cmd_ptype_mapping_replace_port_id,
15393 (void *)&cmd_ptype_mapping_replace_target,
15394 (void *)&cmd_ptype_mapping_replace_mask,
15395 (void *)&cmd_ptype_mapping_replace_pkt_type,
15400 /* ptype mapping reset */
15402 /* Common result structure for ptype mapping reset */
15403 struct cmd_ptype_mapping_reset_result {
15404 cmdline_fixed_string_t ptype;
15405 cmdline_fixed_string_t mapping;
15406 cmdline_fixed_string_t reset;
15410 /* Common CLI fields for ptype mapping reset*/
15411 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
15412 TOKEN_STRING_INITIALIZER
15413 (struct cmd_ptype_mapping_reset_result,
15415 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
15416 TOKEN_STRING_INITIALIZER
15417 (struct cmd_ptype_mapping_reset_result,
15418 mapping, "mapping");
15419 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
15420 TOKEN_STRING_INITIALIZER
15421 (struct cmd_ptype_mapping_reset_result,
15423 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
15424 TOKEN_NUM_INITIALIZER
15425 (struct cmd_ptype_mapping_reset_result,
15426 port_id, RTE_UINT16);
15429 cmd_ptype_mapping_reset_parsed(
15430 void *parsed_result,
15431 __rte_unused struct cmdline *cl,
15432 __rte_unused void *data)
15434 struct cmd_ptype_mapping_reset_result *res = parsed_result;
15435 int ret = -ENOTSUP;
15437 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15440 #ifdef RTE_NET_I40E
15441 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
15448 printf("invalid port_id %d\n", res->port_id);
15451 printf("function not implemented\n");
15454 printf("programming error: (%s)\n", strerror(-ret));
15458 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
15459 .f = cmd_ptype_mapping_reset_parsed,
15461 .help_str = "ptype mapping reset <port_id>",
15463 (void *)&cmd_ptype_mapping_reset_ptype,
15464 (void *)&cmd_ptype_mapping_reset_mapping,
15465 (void *)&cmd_ptype_mapping_reset_reset,
15466 (void *)&cmd_ptype_mapping_reset_port_id,
15471 /* ptype mapping update */
15473 /* Common result structure for ptype mapping update */
15474 struct cmd_ptype_mapping_update_result {
15475 cmdline_fixed_string_t ptype;
15476 cmdline_fixed_string_t mapping;
15477 cmdline_fixed_string_t reset;
15483 /* Common CLI fields for ptype mapping update*/
15484 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
15485 TOKEN_STRING_INITIALIZER
15486 (struct cmd_ptype_mapping_update_result,
15488 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
15489 TOKEN_STRING_INITIALIZER
15490 (struct cmd_ptype_mapping_update_result,
15491 mapping, "mapping");
15492 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
15493 TOKEN_STRING_INITIALIZER
15494 (struct cmd_ptype_mapping_update_result,
15496 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
15497 TOKEN_NUM_INITIALIZER
15498 (struct cmd_ptype_mapping_update_result,
15499 port_id, RTE_UINT16);
15500 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
15501 TOKEN_NUM_INITIALIZER
15502 (struct cmd_ptype_mapping_update_result,
15503 hw_ptype, RTE_UINT8);
15504 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
15505 TOKEN_NUM_INITIALIZER
15506 (struct cmd_ptype_mapping_update_result,
15507 sw_ptype, RTE_UINT32);
15510 cmd_ptype_mapping_update_parsed(
15511 void *parsed_result,
15512 __rte_unused struct cmdline *cl,
15513 __rte_unused void *data)
15515 struct cmd_ptype_mapping_update_result *res = parsed_result;
15516 int ret = -ENOTSUP;
15517 #ifdef RTE_NET_I40E
15518 struct rte_pmd_i40e_ptype_mapping mapping;
15520 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15523 #ifdef RTE_NET_I40E
15524 mapping.hw_ptype = res->hw_ptype;
15525 mapping.sw_ptype = res->sw_ptype;
15526 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
15536 printf("invalid ptype 0x%8x\n", res->sw_ptype);
15539 printf("invalid port_id %d\n", res->port_id);
15542 printf("function not implemented\n");
15545 printf("programming error: (%s)\n", strerror(-ret));
15549 cmdline_parse_inst_t cmd_ptype_mapping_update = {
15550 .f = cmd_ptype_mapping_update_parsed,
15552 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
15554 (void *)&cmd_ptype_mapping_update_ptype,
15555 (void *)&cmd_ptype_mapping_update_mapping,
15556 (void *)&cmd_ptype_mapping_update_update,
15557 (void *)&cmd_ptype_mapping_update_port_id,
15558 (void *)&cmd_ptype_mapping_update_hw_ptype,
15559 (void *)&cmd_ptype_mapping_update_sw_ptype,
15564 /* Common result structure for file commands */
15565 struct cmd_cmdfile_result {
15566 cmdline_fixed_string_t load;
15567 cmdline_fixed_string_t filename;
15570 /* Common CLI fields for file commands */
15571 cmdline_parse_token_string_t cmd_load_cmdfile =
15572 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
15573 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
15574 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
15577 cmd_load_from_file_parsed(
15578 void *parsed_result,
15579 __rte_unused struct cmdline *cl,
15580 __rte_unused void *data)
15582 struct cmd_cmdfile_result *res = parsed_result;
15584 cmdline_read_from_file(res->filename);
15587 cmdline_parse_inst_t cmd_load_from_file = {
15588 .f = cmd_load_from_file_parsed,
15590 .help_str = "load <filename>",
15592 (void *)&cmd_load_cmdfile,
15593 (void *)&cmd_load_cmdfile_filename,
15598 /* Get Rx offloads capabilities */
15599 struct cmd_rx_offload_get_capa_result {
15600 cmdline_fixed_string_t show;
15601 cmdline_fixed_string_t port;
15603 cmdline_fixed_string_t rx_offload;
15604 cmdline_fixed_string_t capabilities;
15607 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
15608 TOKEN_STRING_INITIALIZER
15609 (struct cmd_rx_offload_get_capa_result,
15611 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
15612 TOKEN_STRING_INITIALIZER
15613 (struct cmd_rx_offload_get_capa_result,
15615 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
15616 TOKEN_NUM_INITIALIZER
15617 (struct cmd_rx_offload_get_capa_result,
15618 port_id, RTE_UINT16);
15619 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
15620 TOKEN_STRING_INITIALIZER
15621 (struct cmd_rx_offload_get_capa_result,
15622 rx_offload, "rx_offload");
15623 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
15624 TOKEN_STRING_INITIALIZER
15625 (struct cmd_rx_offload_get_capa_result,
15626 capabilities, "capabilities");
15629 print_rx_offloads(uint64_t offloads)
15631 uint64_t single_offload;
15639 begin = __builtin_ctzll(offloads);
15640 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
15642 single_offload = 1ULL << begin;
15643 for (bit = begin; bit < end; bit++) {
15644 if (offloads & single_offload)
15646 rte_eth_dev_rx_offload_name(single_offload));
15647 single_offload <<= 1;
15652 cmd_rx_offload_get_capa_parsed(
15653 void *parsed_result,
15654 __rte_unused struct cmdline *cl,
15655 __rte_unused void *data)
15657 struct cmd_rx_offload_get_capa_result *res = parsed_result;
15658 struct rte_eth_dev_info dev_info;
15659 portid_t port_id = res->port_id;
15660 uint64_t queue_offloads;
15661 uint64_t port_offloads;
15664 ret = eth_dev_info_get_print_err(port_id, &dev_info);
15668 queue_offloads = dev_info.rx_queue_offload_capa;
15669 port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
15671 printf("Rx Offloading Capabilities of port %d :\n", port_id);
15672 printf(" Per Queue :");
15673 print_rx_offloads(queue_offloads);
15676 printf(" Per Port :");
15677 print_rx_offloads(port_offloads);
15681 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
15682 .f = cmd_rx_offload_get_capa_parsed,
15684 .help_str = "show port <port_id> rx_offload capabilities",
15686 (void *)&cmd_rx_offload_get_capa_show,
15687 (void *)&cmd_rx_offload_get_capa_port,
15688 (void *)&cmd_rx_offload_get_capa_port_id,
15689 (void *)&cmd_rx_offload_get_capa_rx_offload,
15690 (void *)&cmd_rx_offload_get_capa_capabilities,
15695 /* Get Rx offloads configuration */
15696 struct cmd_rx_offload_get_configuration_result {
15697 cmdline_fixed_string_t show;
15698 cmdline_fixed_string_t port;
15700 cmdline_fixed_string_t rx_offload;
15701 cmdline_fixed_string_t configuration;
15704 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
15705 TOKEN_STRING_INITIALIZER
15706 (struct cmd_rx_offload_get_configuration_result,
15708 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
15709 TOKEN_STRING_INITIALIZER
15710 (struct cmd_rx_offload_get_configuration_result,
15712 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
15713 TOKEN_NUM_INITIALIZER
15714 (struct cmd_rx_offload_get_configuration_result,
15715 port_id, RTE_UINT16);
15716 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
15717 TOKEN_STRING_INITIALIZER
15718 (struct cmd_rx_offload_get_configuration_result,
15719 rx_offload, "rx_offload");
15720 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
15721 TOKEN_STRING_INITIALIZER
15722 (struct cmd_rx_offload_get_configuration_result,
15723 configuration, "configuration");
15726 cmd_rx_offload_get_configuration_parsed(
15727 void *parsed_result,
15728 __rte_unused struct cmdline *cl,
15729 __rte_unused void *data)
15731 struct cmd_rx_offload_get_configuration_result *res = parsed_result;
15732 struct rte_eth_dev_info dev_info;
15733 portid_t port_id = res->port_id;
15734 struct rte_port *port = &ports[port_id];
15735 uint64_t port_offloads;
15736 uint64_t queue_offloads;
15737 uint16_t nb_rx_queues;
15741 printf("Rx Offloading Configuration of port %d :\n", port_id);
15743 port_offloads = port->dev_conf.rxmode.offloads;
15745 print_rx_offloads(port_offloads);
15748 ret = eth_dev_info_get_print_err(port_id, &dev_info);
15752 nb_rx_queues = dev_info.nb_rx_queues;
15753 for (q = 0; q < nb_rx_queues; q++) {
15754 queue_offloads = port->rx_conf[q].offloads;
15755 printf(" Queue[%2d] :", q);
15756 print_rx_offloads(queue_offloads);
15762 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
15763 .f = cmd_rx_offload_get_configuration_parsed,
15765 .help_str = "show port <port_id> rx_offload configuration",
15767 (void *)&cmd_rx_offload_get_configuration_show,
15768 (void *)&cmd_rx_offload_get_configuration_port,
15769 (void *)&cmd_rx_offload_get_configuration_port_id,
15770 (void *)&cmd_rx_offload_get_configuration_rx_offload,
15771 (void *)&cmd_rx_offload_get_configuration_configuration,
15776 /* Enable/Disable a per port offloading */
15777 struct cmd_config_per_port_rx_offload_result {
15778 cmdline_fixed_string_t port;
15779 cmdline_fixed_string_t config;
15781 cmdline_fixed_string_t rx_offload;
15782 cmdline_fixed_string_t offload;
15783 cmdline_fixed_string_t on_off;
15786 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
15787 TOKEN_STRING_INITIALIZER
15788 (struct cmd_config_per_port_rx_offload_result,
15790 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
15791 TOKEN_STRING_INITIALIZER
15792 (struct cmd_config_per_port_rx_offload_result,
15794 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
15795 TOKEN_NUM_INITIALIZER
15796 (struct cmd_config_per_port_rx_offload_result,
15797 port_id, RTE_UINT16);
15798 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
15799 TOKEN_STRING_INITIALIZER
15800 (struct cmd_config_per_port_rx_offload_result,
15801 rx_offload, "rx_offload");
15802 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
15803 TOKEN_STRING_INITIALIZER
15804 (struct cmd_config_per_port_rx_offload_result,
15805 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
15806 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
15807 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
15808 "scatter#buffer_split#timestamp#security#"
15809 "keep_crc#rss_hash");
15810 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
15811 TOKEN_STRING_INITIALIZER
15812 (struct cmd_config_per_port_rx_offload_result,
15816 search_rx_offload(const char *name)
15818 uint64_t single_offload;
15819 const char *single_name;
15823 single_offload = 1;
15824 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
15825 single_name = rte_eth_dev_rx_offload_name(single_offload);
15826 if (!strcasecmp(single_name, name)) {
15830 single_offload <<= 1;
15834 return single_offload;
15840 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
15841 __rte_unused struct cmdline *cl,
15842 __rte_unused void *data)
15844 struct cmd_config_per_port_rx_offload_result *res = parsed_result;
15845 portid_t port_id = res->port_id;
15846 struct rte_eth_dev_info dev_info;
15847 struct rte_port *port = &ports[port_id];
15848 uint64_t single_offload;
15849 uint16_t nb_rx_queues;
15853 if (port->port_status != RTE_PORT_STOPPED) {
15854 printf("Error: Can't config offload when Port %d "
15855 "is not stopped\n", port_id);
15859 single_offload = search_rx_offload(res->offload);
15860 if (single_offload == 0) {
15861 printf("Unknown offload name: %s\n", res->offload);
15865 ret = eth_dev_info_get_print_err(port_id, &dev_info);
15869 nb_rx_queues = dev_info.nb_rx_queues;
15870 if (!strcmp(res->on_off, "on")) {
15871 port->dev_conf.rxmode.offloads |= single_offload;
15872 for (q = 0; q < nb_rx_queues; q++)
15873 port->rx_conf[q].offloads |= single_offload;
15875 port->dev_conf.rxmode.offloads &= ~single_offload;
15876 for (q = 0; q < nb_rx_queues; q++)
15877 port->rx_conf[q].offloads &= ~single_offload;
15880 cmd_reconfig_device_queue(port_id, 1, 1);
15883 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
15884 .f = cmd_config_per_port_rx_offload_parsed,
15886 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
15887 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
15888 "macsec_strip|header_split|vlan_filter|vlan_extend|"
15889 "jumbo_frame|scatter|buffer_split|timestamp|security|"
15890 "keep_crc|rss_hash on|off",
15892 (void *)&cmd_config_per_port_rx_offload_result_port,
15893 (void *)&cmd_config_per_port_rx_offload_result_config,
15894 (void *)&cmd_config_per_port_rx_offload_result_port_id,
15895 (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
15896 (void *)&cmd_config_per_port_rx_offload_result_offload,
15897 (void *)&cmd_config_per_port_rx_offload_result_on_off,
15902 /* Enable/Disable a per queue offloading */
15903 struct cmd_config_per_queue_rx_offload_result {
15904 cmdline_fixed_string_t port;
15906 cmdline_fixed_string_t rxq;
15908 cmdline_fixed_string_t rx_offload;
15909 cmdline_fixed_string_t offload;
15910 cmdline_fixed_string_t on_off;
15913 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
15914 TOKEN_STRING_INITIALIZER
15915 (struct cmd_config_per_queue_rx_offload_result,
15917 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
15918 TOKEN_NUM_INITIALIZER
15919 (struct cmd_config_per_queue_rx_offload_result,
15920 port_id, RTE_UINT16);
15921 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
15922 TOKEN_STRING_INITIALIZER
15923 (struct cmd_config_per_queue_rx_offload_result,
15925 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
15926 TOKEN_NUM_INITIALIZER
15927 (struct cmd_config_per_queue_rx_offload_result,
15928 queue_id, RTE_UINT16);
15929 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
15930 TOKEN_STRING_INITIALIZER
15931 (struct cmd_config_per_queue_rx_offload_result,
15932 rx_offload, "rx_offload");
15933 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
15934 TOKEN_STRING_INITIALIZER
15935 (struct cmd_config_per_queue_rx_offload_result,
15936 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
15937 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
15938 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
15939 "scatter#buffer_split#timestamp#security#keep_crc");
15940 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
15941 TOKEN_STRING_INITIALIZER
15942 (struct cmd_config_per_queue_rx_offload_result,
15946 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
15947 __rte_unused struct cmdline *cl,
15948 __rte_unused void *data)
15950 struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
15951 struct rte_eth_dev_info dev_info;
15952 portid_t port_id = res->port_id;
15953 uint16_t queue_id = res->queue_id;
15954 struct rte_port *port = &ports[port_id];
15955 uint64_t single_offload;
15958 if (port->port_status != RTE_PORT_STOPPED) {
15959 printf("Error: Can't config offload when Port %d "
15960 "is not stopped\n", port_id);
15964 ret = eth_dev_info_get_print_err(port_id, &dev_info);
15968 if (queue_id >= dev_info.nb_rx_queues) {
15969 printf("Error: input queue_id should be 0 ... "
15970 "%d\n", dev_info.nb_rx_queues - 1);
15974 single_offload = search_rx_offload(res->offload);
15975 if (single_offload == 0) {
15976 printf("Unknown offload name: %s\n", res->offload);
15980 if (!strcmp(res->on_off, "on"))
15981 port->rx_conf[queue_id].offloads |= single_offload;
15983 port->rx_conf[queue_id].offloads &= ~single_offload;
15985 cmd_reconfig_device_queue(port_id, 1, 1);
15988 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
15989 .f = cmd_config_per_queue_rx_offload_parsed,
15991 .help_str = "port <port_id> rxq <queue_id> rx_offload "
15992 "vlan_strip|ipv4_cksum|"
15993 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
15994 "macsec_strip|header_split|vlan_filter|vlan_extend|"
15995 "jumbo_frame|scatter|buffer_split|timestamp|security|"
15998 (void *)&cmd_config_per_queue_rx_offload_result_port,
15999 (void *)&cmd_config_per_queue_rx_offload_result_port_id,
16000 (void *)&cmd_config_per_queue_rx_offload_result_rxq,
16001 (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
16002 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
16003 (void *)&cmd_config_per_queue_rx_offload_result_offload,
16004 (void *)&cmd_config_per_queue_rx_offload_result_on_off,
16009 /* Get Tx offloads capabilities */
16010 struct cmd_tx_offload_get_capa_result {
16011 cmdline_fixed_string_t show;
16012 cmdline_fixed_string_t port;
16014 cmdline_fixed_string_t tx_offload;
16015 cmdline_fixed_string_t capabilities;
16018 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
16019 TOKEN_STRING_INITIALIZER
16020 (struct cmd_tx_offload_get_capa_result,
16022 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
16023 TOKEN_STRING_INITIALIZER
16024 (struct cmd_tx_offload_get_capa_result,
16026 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
16027 TOKEN_NUM_INITIALIZER
16028 (struct cmd_tx_offload_get_capa_result,
16029 port_id, RTE_UINT16);
16030 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
16031 TOKEN_STRING_INITIALIZER
16032 (struct cmd_tx_offload_get_capa_result,
16033 tx_offload, "tx_offload");
16034 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
16035 TOKEN_STRING_INITIALIZER
16036 (struct cmd_tx_offload_get_capa_result,
16037 capabilities, "capabilities");
16040 print_tx_offloads(uint64_t offloads)
16042 uint64_t single_offload;
16050 begin = __builtin_ctzll(offloads);
16051 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
16053 single_offload = 1ULL << begin;
16054 for (bit = begin; bit < end; bit++) {
16055 if (offloads & single_offload)
16057 rte_eth_dev_tx_offload_name(single_offload));
16058 single_offload <<= 1;
16063 cmd_tx_offload_get_capa_parsed(
16064 void *parsed_result,
16065 __rte_unused struct cmdline *cl,
16066 __rte_unused void *data)
16068 struct cmd_tx_offload_get_capa_result *res = parsed_result;
16069 struct rte_eth_dev_info dev_info;
16070 portid_t port_id = res->port_id;
16071 uint64_t queue_offloads;
16072 uint64_t port_offloads;
16075 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16079 queue_offloads = dev_info.tx_queue_offload_capa;
16080 port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
16082 printf("Tx Offloading Capabilities of port %d :\n", port_id);
16083 printf(" Per Queue :");
16084 print_tx_offloads(queue_offloads);
16087 printf(" Per Port :");
16088 print_tx_offloads(port_offloads);
16092 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
16093 .f = cmd_tx_offload_get_capa_parsed,
16095 .help_str = "show port <port_id> tx_offload capabilities",
16097 (void *)&cmd_tx_offload_get_capa_show,
16098 (void *)&cmd_tx_offload_get_capa_port,
16099 (void *)&cmd_tx_offload_get_capa_port_id,
16100 (void *)&cmd_tx_offload_get_capa_tx_offload,
16101 (void *)&cmd_tx_offload_get_capa_capabilities,
16106 /* Get Tx offloads configuration */
16107 struct cmd_tx_offload_get_configuration_result {
16108 cmdline_fixed_string_t show;
16109 cmdline_fixed_string_t port;
16111 cmdline_fixed_string_t tx_offload;
16112 cmdline_fixed_string_t configuration;
16115 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
16116 TOKEN_STRING_INITIALIZER
16117 (struct cmd_tx_offload_get_configuration_result,
16119 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
16120 TOKEN_STRING_INITIALIZER
16121 (struct cmd_tx_offload_get_configuration_result,
16123 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
16124 TOKEN_NUM_INITIALIZER
16125 (struct cmd_tx_offload_get_configuration_result,
16126 port_id, RTE_UINT16);
16127 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
16128 TOKEN_STRING_INITIALIZER
16129 (struct cmd_tx_offload_get_configuration_result,
16130 tx_offload, "tx_offload");
16131 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
16132 TOKEN_STRING_INITIALIZER
16133 (struct cmd_tx_offload_get_configuration_result,
16134 configuration, "configuration");
16137 cmd_tx_offload_get_configuration_parsed(
16138 void *parsed_result,
16139 __rte_unused struct cmdline *cl,
16140 __rte_unused void *data)
16142 struct cmd_tx_offload_get_configuration_result *res = parsed_result;
16143 struct rte_eth_dev_info dev_info;
16144 portid_t port_id = res->port_id;
16145 struct rte_port *port = &ports[port_id];
16146 uint64_t port_offloads;
16147 uint64_t queue_offloads;
16148 uint16_t nb_tx_queues;
16152 printf("Tx Offloading Configuration of port %d :\n", port_id);
16154 port_offloads = port->dev_conf.txmode.offloads;
16156 print_tx_offloads(port_offloads);
16159 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16163 nb_tx_queues = dev_info.nb_tx_queues;
16164 for (q = 0; q < nb_tx_queues; q++) {
16165 queue_offloads = port->tx_conf[q].offloads;
16166 printf(" Queue[%2d] :", q);
16167 print_tx_offloads(queue_offloads);
16173 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
16174 .f = cmd_tx_offload_get_configuration_parsed,
16176 .help_str = "show port <port_id> tx_offload configuration",
16178 (void *)&cmd_tx_offload_get_configuration_show,
16179 (void *)&cmd_tx_offload_get_configuration_port,
16180 (void *)&cmd_tx_offload_get_configuration_port_id,
16181 (void *)&cmd_tx_offload_get_configuration_tx_offload,
16182 (void *)&cmd_tx_offload_get_configuration_configuration,
16187 /* Enable/Disable a per port offloading */
16188 struct cmd_config_per_port_tx_offload_result {
16189 cmdline_fixed_string_t port;
16190 cmdline_fixed_string_t config;
16192 cmdline_fixed_string_t tx_offload;
16193 cmdline_fixed_string_t offload;
16194 cmdline_fixed_string_t on_off;
16197 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
16198 TOKEN_STRING_INITIALIZER
16199 (struct cmd_config_per_port_tx_offload_result,
16201 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
16202 TOKEN_STRING_INITIALIZER
16203 (struct cmd_config_per_port_tx_offload_result,
16205 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
16206 TOKEN_NUM_INITIALIZER
16207 (struct cmd_config_per_port_tx_offload_result,
16208 port_id, RTE_UINT16);
16209 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
16210 TOKEN_STRING_INITIALIZER
16211 (struct cmd_config_per_port_tx_offload_result,
16212 tx_offload, "tx_offload");
16213 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
16214 TOKEN_STRING_INITIALIZER
16215 (struct cmd_config_per_port_tx_offload_result,
16216 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
16217 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
16218 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
16219 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
16220 "mt_lockfree#multi_segs#mbuf_fast_free#security#"
16221 "send_on_timestamp");
16222 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
16223 TOKEN_STRING_INITIALIZER
16224 (struct cmd_config_per_port_tx_offload_result,
16228 search_tx_offload(const char *name)
16230 uint64_t single_offload;
16231 const char *single_name;
16235 single_offload = 1;
16236 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
16237 single_name = rte_eth_dev_tx_offload_name(single_offload);
16238 if (single_name == NULL)
16240 if (!strcasecmp(single_name, name)) {
16243 } else if (!strcasecmp(single_name, "UNKNOWN"))
16245 single_offload <<= 1;
16249 return single_offload;
16255 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
16256 __rte_unused struct cmdline *cl,
16257 __rte_unused void *data)
16259 struct cmd_config_per_port_tx_offload_result *res = parsed_result;
16260 portid_t port_id = res->port_id;
16261 struct rte_eth_dev_info dev_info;
16262 struct rte_port *port = &ports[port_id];
16263 uint64_t single_offload;
16264 uint16_t nb_tx_queues;
16268 if (port->port_status != RTE_PORT_STOPPED) {
16269 printf("Error: Can't config offload when Port %d "
16270 "is not stopped\n", port_id);
16274 single_offload = search_tx_offload(res->offload);
16275 if (single_offload == 0) {
16276 printf("Unknown offload name: %s\n", res->offload);
16280 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16284 nb_tx_queues = dev_info.nb_tx_queues;
16285 if (!strcmp(res->on_off, "on")) {
16286 port->dev_conf.txmode.offloads |= single_offload;
16287 for (q = 0; q < nb_tx_queues; q++)
16288 port->tx_conf[q].offloads |= single_offload;
16290 port->dev_conf.txmode.offloads &= ~single_offload;
16291 for (q = 0; q < nb_tx_queues; q++)
16292 port->tx_conf[q].offloads &= ~single_offload;
16295 cmd_reconfig_device_queue(port_id, 1, 1);
16298 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
16299 .f = cmd_config_per_port_tx_offload_parsed,
16301 .help_str = "port config <port_id> tx_offload "
16302 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
16303 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
16304 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
16305 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
16306 "mt_lockfree|multi_segs|mbuf_fast_free|security|"
16307 "send_on_timestamp on|off",
16309 (void *)&cmd_config_per_port_tx_offload_result_port,
16310 (void *)&cmd_config_per_port_tx_offload_result_config,
16311 (void *)&cmd_config_per_port_tx_offload_result_port_id,
16312 (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
16313 (void *)&cmd_config_per_port_tx_offload_result_offload,
16314 (void *)&cmd_config_per_port_tx_offload_result_on_off,
16319 /* Enable/Disable a per queue offloading */
16320 struct cmd_config_per_queue_tx_offload_result {
16321 cmdline_fixed_string_t port;
16323 cmdline_fixed_string_t txq;
16325 cmdline_fixed_string_t tx_offload;
16326 cmdline_fixed_string_t offload;
16327 cmdline_fixed_string_t on_off;
16330 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
16331 TOKEN_STRING_INITIALIZER
16332 (struct cmd_config_per_queue_tx_offload_result,
16334 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
16335 TOKEN_NUM_INITIALIZER
16336 (struct cmd_config_per_queue_tx_offload_result,
16337 port_id, RTE_UINT16);
16338 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
16339 TOKEN_STRING_INITIALIZER
16340 (struct cmd_config_per_queue_tx_offload_result,
16342 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
16343 TOKEN_NUM_INITIALIZER
16344 (struct cmd_config_per_queue_tx_offload_result,
16345 queue_id, RTE_UINT16);
16346 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
16347 TOKEN_STRING_INITIALIZER
16348 (struct cmd_config_per_queue_tx_offload_result,
16349 tx_offload, "tx_offload");
16350 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
16351 TOKEN_STRING_INITIALIZER
16352 (struct cmd_config_per_queue_tx_offload_result,
16353 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
16354 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
16355 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
16356 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
16357 "mt_lockfree#multi_segs#mbuf_fast_free#security");
16358 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
16359 TOKEN_STRING_INITIALIZER
16360 (struct cmd_config_per_queue_tx_offload_result,
16364 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
16365 __rte_unused struct cmdline *cl,
16366 __rte_unused void *data)
16368 struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
16369 struct rte_eth_dev_info dev_info;
16370 portid_t port_id = res->port_id;
16371 uint16_t queue_id = res->queue_id;
16372 struct rte_port *port = &ports[port_id];
16373 uint64_t single_offload;
16376 if (port->port_status != RTE_PORT_STOPPED) {
16377 printf("Error: Can't config offload when Port %d "
16378 "is not stopped\n", port_id);
16382 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16386 if (queue_id >= dev_info.nb_tx_queues) {
16387 printf("Error: input queue_id should be 0 ... "
16388 "%d\n", dev_info.nb_tx_queues - 1);
16392 single_offload = search_tx_offload(res->offload);
16393 if (single_offload == 0) {
16394 printf("Unknown offload name: %s\n", res->offload);
16398 if (!strcmp(res->on_off, "on"))
16399 port->tx_conf[queue_id].offloads |= single_offload;
16401 port->tx_conf[queue_id].offloads &= ~single_offload;
16403 cmd_reconfig_device_queue(port_id, 1, 1);
16406 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
16407 .f = cmd_config_per_queue_tx_offload_parsed,
16409 .help_str = "port <port_id> txq <queue_id> tx_offload "
16410 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
16411 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
16412 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
16413 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
16414 "mt_lockfree|multi_segs|mbuf_fast_free|security "
16417 (void *)&cmd_config_per_queue_tx_offload_result_port,
16418 (void *)&cmd_config_per_queue_tx_offload_result_port_id,
16419 (void *)&cmd_config_per_queue_tx_offload_result_txq,
16420 (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
16421 (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
16422 (void *)&cmd_config_per_queue_tx_offload_result_offload,
16423 (void *)&cmd_config_per_queue_tx_offload_result_on_off,
16428 /* *** configure tx_metadata for specific port *** */
16429 struct cmd_config_tx_metadata_specific_result {
16430 cmdline_fixed_string_t port;
16431 cmdline_fixed_string_t keyword;
16433 cmdline_fixed_string_t item;
16438 cmd_config_tx_metadata_specific_parsed(void *parsed_result,
16439 __rte_unused struct cmdline *cl,
16440 __rte_unused void *data)
16442 struct cmd_config_tx_metadata_specific_result *res = parsed_result;
16444 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16446 ports[res->port_id].tx_metadata = res->value;
16447 /* Add/remove callback to insert valid metadata in every Tx packet. */
16448 if (ports[res->port_id].tx_metadata)
16449 add_tx_md_callback(res->port_id);
16451 remove_tx_md_callback(res->port_id);
16452 rte_flow_dynf_metadata_register();
16455 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
16456 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16458 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
16459 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16460 keyword, "config");
16461 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
16462 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16463 port_id, RTE_UINT16);
16464 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
16465 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16466 item, "tx_metadata");
16467 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
16468 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16469 value, RTE_UINT32);
16471 cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
16472 .f = cmd_config_tx_metadata_specific_parsed,
16474 .help_str = "port config <port_id> tx_metadata <value>",
16476 (void *)&cmd_config_tx_metadata_specific_port,
16477 (void *)&cmd_config_tx_metadata_specific_keyword,
16478 (void *)&cmd_config_tx_metadata_specific_id,
16479 (void *)&cmd_config_tx_metadata_specific_item,
16480 (void *)&cmd_config_tx_metadata_specific_value,
16485 /* *** set dynf *** */
16486 struct cmd_config_tx_dynf_specific_result {
16487 cmdline_fixed_string_t port;
16488 cmdline_fixed_string_t keyword;
16490 cmdline_fixed_string_t item;
16491 cmdline_fixed_string_t name;
16492 cmdline_fixed_string_t value;
16496 cmd_config_dynf_specific_parsed(void *parsed_result,
16497 __rte_unused struct cmdline *cl,
16498 __rte_unused void *data)
16500 struct cmd_config_tx_dynf_specific_result *res = parsed_result;
16501 struct rte_mbuf_dynflag desc_flag;
16503 uint64_t old_port_flags;
16505 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16507 flag = rte_mbuf_dynflag_lookup(res->name, NULL);
16509 if (strlcpy(desc_flag.name, res->name,
16510 RTE_MBUF_DYN_NAMESIZE) >= RTE_MBUF_DYN_NAMESIZE) {
16511 printf("Flag name too long\n");
16514 desc_flag.flags = 0;
16515 flag = rte_mbuf_dynflag_register(&desc_flag);
16517 printf("Can't register flag\n");
16520 strcpy(dynf_names[flag], desc_flag.name);
16522 old_port_flags = ports[res->port_id].mbuf_dynf;
16523 if (!strcmp(res->value, "set")) {
16524 ports[res->port_id].mbuf_dynf |= 1UL << flag;
16525 if (old_port_flags == 0)
16526 add_tx_dynf_callback(res->port_id);
16528 ports[res->port_id].mbuf_dynf &= ~(1UL << flag);
16529 if (ports[res->port_id].mbuf_dynf == 0)
16530 remove_tx_dynf_callback(res->port_id);
16534 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_port =
16535 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16537 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_keyword =
16538 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16539 keyword, "config");
16540 cmdline_parse_token_num_t cmd_config_tx_dynf_specific_port_id =
16541 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16542 port_id, RTE_UINT16);
16543 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_item =
16544 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16546 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_name =
16547 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16549 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_value =
16550 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16551 value, "set#clear");
16553 cmdline_parse_inst_t cmd_config_tx_dynf_specific = {
16554 .f = cmd_config_dynf_specific_parsed,
16556 .help_str = "port config <port id> dynf <name> set|clear",
16558 (void *)&cmd_config_tx_dynf_specific_port,
16559 (void *)&cmd_config_tx_dynf_specific_keyword,
16560 (void *)&cmd_config_tx_dynf_specific_port_id,
16561 (void *)&cmd_config_tx_dynf_specific_item,
16562 (void *)&cmd_config_tx_dynf_specific_name,
16563 (void *)&cmd_config_tx_dynf_specific_value,
16568 /* *** display tx_metadata per port configuration *** */
16569 struct cmd_show_tx_metadata_result {
16570 cmdline_fixed_string_t cmd_show;
16571 cmdline_fixed_string_t cmd_port;
16572 cmdline_fixed_string_t cmd_keyword;
16577 cmd_show_tx_metadata_parsed(void *parsed_result,
16578 __rte_unused struct cmdline *cl,
16579 __rte_unused void *data)
16581 struct cmd_show_tx_metadata_result *res = parsed_result;
16583 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16584 printf("invalid port id %u\n", res->cmd_pid);
16587 if (!strcmp(res->cmd_keyword, "tx_metadata")) {
16588 printf("Port %u tx_metadata: %u\n", res->cmd_pid,
16589 ports[res->cmd_pid].tx_metadata);
16593 cmdline_parse_token_string_t cmd_show_tx_metadata_show =
16594 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
16596 cmdline_parse_token_string_t cmd_show_tx_metadata_port =
16597 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
16599 cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
16600 TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
16601 cmd_pid, RTE_UINT16);
16602 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
16603 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
16604 cmd_keyword, "tx_metadata");
16606 cmdline_parse_inst_t cmd_show_tx_metadata = {
16607 .f = cmd_show_tx_metadata_parsed,
16609 .help_str = "show port <port_id> tx_metadata",
16611 (void *)&cmd_show_tx_metadata_show,
16612 (void *)&cmd_show_tx_metadata_port,
16613 (void *)&cmd_show_tx_metadata_pid,
16614 (void *)&cmd_show_tx_metadata_keyword,
16619 /* *** show fec capability per port configuration *** */
16620 struct cmd_show_fec_capability_result {
16621 cmdline_fixed_string_t cmd_show;
16622 cmdline_fixed_string_t cmd_port;
16623 cmdline_fixed_string_t cmd_fec;
16624 cmdline_fixed_string_t cmd_keyword;
16629 cmd_show_fec_capability_parsed(void *parsed_result,
16630 __rte_unused struct cmdline *cl,
16631 __rte_unused void *data)
16633 struct cmd_show_fec_capability_result *res = parsed_result;
16634 struct rte_eth_fec_capa *speed_fec_capa;
16638 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16639 printf("Invalid port id %u\n", res->cmd_pid);
16643 ret = rte_eth_fec_get_capability(res->cmd_pid, NULL, 0);
16644 if (ret == -ENOTSUP) {
16645 printf("Function not implemented\n");
16647 } else if (ret < 0) {
16648 printf("Get FEC capability failed: %d\n", ret);
16652 num = (unsigned int)ret;
16653 speed_fec_capa = calloc(num, sizeof(*speed_fec_capa));
16654 if (speed_fec_capa == NULL) {
16655 printf("Failed to alloc FEC capability buffer\n");
16659 ret = rte_eth_fec_get_capability(res->cmd_pid, speed_fec_capa, num);
16661 printf("Error getting FEC capability: %d\n", ret);
16665 show_fec_capability(num, speed_fec_capa);
16667 free(speed_fec_capa);
16670 cmdline_parse_token_string_t cmd_show_fec_capability_show =
16671 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16673 cmdline_parse_token_string_t cmd_show_fec_capability_port =
16674 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16676 cmdline_parse_token_num_t cmd_show_fec_capability_pid =
16677 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_capability_result,
16678 cmd_pid, RTE_UINT16);
16679 cmdline_parse_token_string_t cmd_show_fec_capability_fec =
16680 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16682 cmdline_parse_token_string_t cmd_show_fec_capability_keyword =
16683 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16684 cmd_keyword, "capabilities");
16686 cmdline_parse_inst_t cmd_show_capability = {
16687 .f = cmd_show_fec_capability_parsed,
16689 .help_str = "show port <port_id> fec capabilities",
16691 (void *)&cmd_show_fec_capability_show,
16692 (void *)&cmd_show_fec_capability_port,
16693 (void *)&cmd_show_fec_capability_pid,
16694 (void *)&cmd_show_fec_capability_fec,
16695 (void *)&cmd_show_fec_capability_keyword,
16700 /* *** show fec mode per port configuration *** */
16701 struct cmd_show_fec_metadata_result {
16702 cmdline_fixed_string_t cmd_show;
16703 cmdline_fixed_string_t cmd_port;
16704 cmdline_fixed_string_t cmd_keyword;
16709 cmd_show_fec_mode_parsed(void *parsed_result,
16710 __rte_unused struct cmdline *cl,
16711 __rte_unused void *data)
16713 #define FEC_NAME_SIZE 16
16714 struct cmd_show_fec_metadata_result *res = parsed_result;
16716 char buf[FEC_NAME_SIZE];
16719 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16720 printf("Invalid port id %u\n", res->cmd_pid);
16723 ret = rte_eth_fec_get(res->cmd_pid, &mode);
16724 if (ret == -ENOTSUP) {
16725 printf("Function not implemented\n");
16727 } else if (ret < 0) {
16728 printf("Get FEC mode failed\n");
16733 case RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC):
16734 strlcpy(buf, "off", sizeof(buf));
16736 case RTE_ETH_FEC_MODE_CAPA_MASK(AUTO):
16737 strlcpy(buf, "auto", sizeof(buf));
16739 case RTE_ETH_FEC_MODE_CAPA_MASK(BASER):
16740 strlcpy(buf, "baser", sizeof(buf));
16742 case RTE_ETH_FEC_MODE_CAPA_MASK(RS):
16743 strlcpy(buf, "rs", sizeof(buf));
16749 printf("%s\n", buf);
16752 cmdline_parse_token_string_t cmd_show_fec_mode_show =
16753 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
16755 cmdline_parse_token_string_t cmd_show_fec_mode_port =
16756 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
16758 cmdline_parse_token_num_t cmd_show_fec_mode_pid =
16759 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_metadata_result,
16760 cmd_pid, RTE_UINT16);
16761 cmdline_parse_token_string_t cmd_show_fec_mode_keyword =
16762 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
16763 cmd_keyword, "fec_mode");
16765 cmdline_parse_inst_t cmd_show_fec_mode = {
16766 .f = cmd_show_fec_mode_parsed,
16768 .help_str = "show port <port_id> fec_mode",
16770 (void *)&cmd_show_fec_mode_show,
16771 (void *)&cmd_show_fec_mode_port,
16772 (void *)&cmd_show_fec_mode_pid,
16773 (void *)&cmd_show_fec_mode_keyword,
16778 /* *** set fec mode per port configuration *** */
16779 struct cmd_set_port_fec_mode {
16780 cmdline_fixed_string_t set;
16781 cmdline_fixed_string_t port;
16783 cmdline_fixed_string_t fec_mode;
16784 cmdline_fixed_string_t fec_value;
16787 /* Common CLI fields for set fec mode */
16788 cmdline_parse_token_string_t cmd_set_port_fec_mode_set =
16789 TOKEN_STRING_INITIALIZER
16790 (struct cmd_set_port_fec_mode,
16792 cmdline_parse_token_string_t cmd_set_port_fec_mode_port =
16793 TOKEN_STRING_INITIALIZER
16794 (struct cmd_set_port_fec_mode,
16796 cmdline_parse_token_num_t cmd_set_port_fec_mode_port_id =
16797 TOKEN_NUM_INITIALIZER
16798 (struct cmd_set_port_fec_mode,
16799 port_id, RTE_UINT16);
16800 cmdline_parse_token_string_t cmd_set_port_fec_mode_str =
16801 TOKEN_STRING_INITIALIZER
16802 (struct cmd_set_port_fec_mode,
16803 fec_mode, "fec_mode");
16804 cmdline_parse_token_string_t cmd_set_port_fec_mode_value =
16805 TOKEN_STRING_INITIALIZER
16806 (struct cmd_set_port_fec_mode,
16810 cmd_set_port_fec_mode_parsed(
16811 void *parsed_result,
16812 __rte_unused struct cmdline *cl,
16813 __rte_unused void *data)
16815 struct cmd_set_port_fec_mode *res = parsed_result;
16816 uint16_t port_id = res->port_id;
16820 ret = parse_fec_mode(res->fec_value, &mode);
16822 printf("Unknown fec mode: %s for Port %d\n", res->fec_value,
16827 ret = rte_eth_fec_set(port_id, mode);
16828 if (ret == -ENOTSUP) {
16829 printf("Function not implemented\n");
16831 } else if (ret < 0) {
16832 printf("Set FEC mode failed\n");
16837 cmdline_parse_inst_t cmd_set_fec_mode = {
16838 .f = cmd_set_port_fec_mode_parsed,
16840 .help_str = "set port <port_id> fec_mode auto|off|rs|baser",
16842 (void *)&cmd_set_port_fec_mode_set,
16843 (void *)&cmd_set_port_fec_mode_port,
16844 (void *)&cmd_set_port_fec_mode_port_id,
16845 (void *)&cmd_set_port_fec_mode_str,
16846 (void *)&cmd_set_port_fec_mode_value,
16851 /* show port supported ptypes */
16853 /* Common result structure for show port ptypes */
16854 struct cmd_show_port_supported_ptypes_result {
16855 cmdline_fixed_string_t show;
16856 cmdline_fixed_string_t port;
16858 cmdline_fixed_string_t ptypes;
16861 /* Common CLI fields for show port ptypes */
16862 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =
16863 TOKEN_STRING_INITIALIZER
16864 (struct cmd_show_port_supported_ptypes_result,
16866 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
16867 TOKEN_STRING_INITIALIZER
16868 (struct cmd_show_port_supported_ptypes_result,
16870 cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =
16871 TOKEN_NUM_INITIALIZER
16872 (struct cmd_show_port_supported_ptypes_result,
16873 port_id, RTE_UINT16);
16874 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =
16875 TOKEN_STRING_INITIALIZER
16876 (struct cmd_show_port_supported_ptypes_result,
16880 cmd_show_port_supported_ptypes_parsed(
16881 void *parsed_result,
16882 __rte_unused struct cmdline *cl,
16883 __rte_unused void *data)
16885 #define RSVD_PTYPE_MASK 0xf0000000
16886 #define MAX_PTYPES_PER_LAYER 16
16887 #define LTYPE_NAMESIZE 32
16888 #define PTYPE_NAMESIZE 256
16889 struct cmd_show_port_supported_ptypes_result *res = parsed_result;
16890 char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE];
16891 uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
16892 uint32_t ptypes[MAX_PTYPES_PER_LAYER];
16893 uint16_t port_id = res->port_id;
16896 ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0);
16900 while (ptype_mask != RSVD_PTYPE_MASK) {
16902 switch (ptype_mask) {
16903 case RTE_PTYPE_L2_MASK:
16904 strlcpy(ltype, "L2", sizeof(ltype));
16906 case RTE_PTYPE_L3_MASK:
16907 strlcpy(ltype, "L3", sizeof(ltype));
16909 case RTE_PTYPE_L4_MASK:
16910 strlcpy(ltype, "L4", sizeof(ltype));
16912 case RTE_PTYPE_TUNNEL_MASK:
16913 strlcpy(ltype, "Tunnel", sizeof(ltype));
16915 case RTE_PTYPE_INNER_L2_MASK:
16916 strlcpy(ltype, "Inner L2", sizeof(ltype));
16918 case RTE_PTYPE_INNER_L3_MASK:
16919 strlcpy(ltype, "Inner L3", sizeof(ltype));
16921 case RTE_PTYPE_INNER_L4_MASK:
16922 strlcpy(ltype, "Inner L4", sizeof(ltype));
16928 ret = rte_eth_dev_get_supported_ptypes(res->port_id,
16929 ptype_mask, ptypes,
16930 MAX_PTYPES_PER_LAYER);
16933 printf("Supported %s ptypes:\n", ltype);
16935 printf("%s ptypes unsupported\n", ltype);
16937 for (i = 0; i < ret; ++i) {
16938 rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
16939 printf("%s\n", buf);
16946 cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
16947 .f = cmd_show_port_supported_ptypes_parsed,
16949 .help_str = "show port <port_id> ptypes",
16951 (void *)&cmd_show_port_supported_ptypes_show,
16952 (void *)&cmd_show_port_supported_ptypes_port,
16953 (void *)&cmd_show_port_supported_ptypes_port_id,
16954 (void *)&cmd_show_port_supported_ptypes_ptypes,
16959 /* *** display rx/tx descriptor status *** */
16960 struct cmd_show_rx_tx_desc_status_result {
16961 cmdline_fixed_string_t cmd_show;
16962 cmdline_fixed_string_t cmd_port;
16963 cmdline_fixed_string_t cmd_keyword;
16964 cmdline_fixed_string_t cmd_desc;
16965 cmdline_fixed_string_t cmd_status;
16972 cmd_show_rx_tx_desc_status_parsed(void *parsed_result,
16973 __rte_unused struct cmdline *cl,
16974 __rte_unused void *data)
16976 struct cmd_show_rx_tx_desc_status_result *res = parsed_result;
16979 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16980 printf("invalid port id %u\n", res->cmd_pid);
16984 if (!strcmp(res->cmd_keyword, "rxq")) {
16985 rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid,
16988 printf("Invalid input: queue id = %d, desc id = %d\n",
16989 res->cmd_qid, res->cmd_did);
16992 if (rc == RTE_ETH_RX_DESC_AVAIL)
16993 printf("Desc status = AVAILABLE\n");
16994 else if (rc == RTE_ETH_RX_DESC_DONE)
16995 printf("Desc status = DONE\n");
16997 printf("Desc status = UNAVAILABLE\n");
16998 } else if (!strcmp(res->cmd_keyword, "txq")) {
16999 rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid,
17002 printf("Invalid input: queue id = %d, desc id = %d\n",
17003 res->cmd_qid, res->cmd_did);
17006 if (rc == RTE_ETH_TX_DESC_FULL)
17007 printf("Desc status = FULL\n");
17008 else if (rc == RTE_ETH_TX_DESC_DONE)
17009 printf("Desc status = DONE\n");
17011 printf("Desc status = UNAVAILABLE\n");
17015 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show =
17016 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17018 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port =
17019 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17021 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid =
17022 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17023 cmd_pid, RTE_UINT16);
17024 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword =
17025 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17026 cmd_keyword, "rxq#txq");
17027 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid =
17028 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17029 cmd_qid, RTE_UINT16);
17030 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc =
17031 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17033 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did =
17034 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17035 cmd_did, RTE_UINT16);
17036 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status =
17037 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17038 cmd_status, "status");
17039 cmdline_parse_inst_t cmd_show_rx_tx_desc_status = {
17040 .f = cmd_show_rx_tx_desc_status_parsed,
17042 .help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> "
17045 (void *)&cmd_show_rx_tx_desc_status_show,
17046 (void *)&cmd_show_rx_tx_desc_status_port,
17047 (void *)&cmd_show_rx_tx_desc_status_pid,
17048 (void *)&cmd_show_rx_tx_desc_status_keyword,
17049 (void *)&cmd_show_rx_tx_desc_status_qid,
17050 (void *)&cmd_show_rx_tx_desc_status_desc,
17051 (void *)&cmd_show_rx_tx_desc_status_did,
17052 (void *)&cmd_show_rx_tx_desc_status_status,
17057 /* *** display rx queue desc used count *** */
17058 struct cmd_show_rx_queue_desc_used_count_result {
17059 cmdline_fixed_string_t cmd_show;
17060 cmdline_fixed_string_t cmd_port;
17061 cmdline_fixed_string_t cmd_rxq;
17062 cmdline_fixed_string_t cmd_desc;
17063 cmdline_fixed_string_t cmd_used;
17064 cmdline_fixed_string_t cmd_count;
17070 cmd_show_rx_queue_desc_used_count_parsed(void *parsed_result,
17071 __rte_unused struct cmdline *cl,
17072 __rte_unused void *data)
17074 struct cmd_show_rx_queue_desc_used_count_result *res = parsed_result;
17077 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17078 printf("invalid port id %u\n", res->cmd_pid);
17082 rc = rte_eth_rx_queue_count(res->cmd_pid, res->cmd_qid);
17084 printf("Invalid queueid = %d\n", res->cmd_qid);
17087 printf("Used desc count = %d\n", rc);
17090 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_show =
17091 TOKEN_STRING_INITIALIZER
17092 (struct cmd_show_rx_queue_desc_used_count_result,
17094 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_port =
17095 TOKEN_STRING_INITIALIZER
17096 (struct cmd_show_rx_queue_desc_used_count_result,
17098 cmdline_parse_token_num_t cmd_show_rx_queue_desc_used_count_pid =
17099 TOKEN_NUM_INITIALIZER
17100 (struct cmd_show_rx_queue_desc_used_count_result,
17101 cmd_pid, RTE_UINT16);
17102 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_rxq =
17103 TOKEN_STRING_INITIALIZER
17104 (struct cmd_show_rx_queue_desc_used_count_result,
17106 cmdline_parse_token_num_t cmd_show_rx_queue_desc_used_count_qid =
17107 TOKEN_NUM_INITIALIZER
17108 (struct cmd_show_rx_queue_desc_used_count_result,
17109 cmd_qid, RTE_UINT16);
17110 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_desc =
17111 TOKEN_STRING_INITIALIZER
17112 (struct cmd_show_rx_queue_desc_used_count_result,
17113 cmd_count, "desc");
17114 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_used =
17115 TOKEN_STRING_INITIALIZER
17116 (struct cmd_show_rx_queue_desc_used_count_result,
17117 cmd_count, "used");
17118 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_count =
17119 TOKEN_STRING_INITIALIZER
17120 (struct cmd_show_rx_queue_desc_used_count_result,
17121 cmd_count, "count");
17122 cmdline_parse_inst_t cmd_show_rx_queue_desc_used_count = {
17123 .f = cmd_show_rx_queue_desc_used_count_parsed,
17125 .help_str = "show port <port_id> rxq <queue_id> desc used count",
17127 (void *)&cmd_show_rx_queue_desc_used_count_show,
17128 (void *)&cmd_show_rx_queue_desc_used_count_port,
17129 (void *)&cmd_show_rx_queue_desc_used_count_pid,
17130 (void *)&cmd_show_rx_queue_desc_used_count_rxq,
17131 (void *)&cmd_show_rx_queue_desc_used_count_qid,
17132 (void *)&cmd_show_rx_queue_desc_used_count_desc,
17133 (void *)&cmd_show_rx_queue_desc_used_count_used,
17134 (void *)&cmd_show_rx_queue_desc_used_count_count,
17139 /* Common result structure for set port ptypes */
17140 struct cmd_set_port_ptypes_result {
17141 cmdline_fixed_string_t set;
17142 cmdline_fixed_string_t port;
17144 cmdline_fixed_string_t ptype_mask;
17148 /* Common CLI fields for set port ptypes */
17149 cmdline_parse_token_string_t cmd_set_port_ptypes_set =
17150 TOKEN_STRING_INITIALIZER
17151 (struct cmd_set_port_ptypes_result,
17153 cmdline_parse_token_string_t cmd_set_port_ptypes_port =
17154 TOKEN_STRING_INITIALIZER
17155 (struct cmd_set_port_ptypes_result,
17157 cmdline_parse_token_num_t cmd_set_port_ptypes_port_id =
17158 TOKEN_NUM_INITIALIZER
17159 (struct cmd_set_port_ptypes_result,
17160 port_id, RTE_UINT16);
17161 cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str =
17162 TOKEN_STRING_INITIALIZER
17163 (struct cmd_set_port_ptypes_result,
17164 ptype_mask, "ptype_mask");
17165 cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 =
17166 TOKEN_NUM_INITIALIZER
17167 (struct cmd_set_port_ptypes_result,
17171 cmd_set_port_ptypes_parsed(
17172 void *parsed_result,
17173 __rte_unused struct cmdline *cl,
17174 __rte_unused void *data)
17176 struct cmd_set_port_ptypes_result *res = parsed_result;
17177 #define PTYPE_NAMESIZE 256
17178 char ptype_name[PTYPE_NAMESIZE];
17179 uint16_t port_id = res->port_id;
17180 uint32_t ptype_mask = res->mask;
17183 ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK,
17186 printf("Port %d doesn't support any ptypes.\n", port_id);
17190 uint32_t ptypes[ret];
17192 ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret);
17194 printf("Unable to set requested ptypes for Port %d\n", port_id);
17198 printf("Successfully set following ptypes for Port %d\n", port_id);
17199 for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) {
17200 rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name));
17201 printf("%s\n", ptype_name);
17204 clear_ptypes = false;
17207 cmdline_parse_inst_t cmd_set_port_ptypes = {
17208 .f = cmd_set_port_ptypes_parsed,
17210 .help_str = "set port <port_id> ptype_mask <mask>",
17212 (void *)&cmd_set_port_ptypes_set,
17213 (void *)&cmd_set_port_ptypes_port,
17214 (void *)&cmd_set_port_ptypes_port_id,
17215 (void *)&cmd_set_port_ptypes_mask_str,
17216 (void *)&cmd_set_port_ptypes_mask_u32,
17221 /* *** display mac addresses added to a port *** */
17222 struct cmd_showport_macs_result {
17223 cmdline_fixed_string_t cmd_show;
17224 cmdline_fixed_string_t cmd_port;
17225 cmdline_fixed_string_t cmd_keyword;
17230 cmd_showport_macs_parsed(void *parsed_result,
17231 __rte_unused struct cmdline *cl,
17232 __rte_unused void *data)
17234 struct cmd_showport_macs_result *res = parsed_result;
17236 if (port_id_is_invalid(res->cmd_pid, ENABLED_WARN))
17239 if (!strcmp(res->cmd_keyword, "macs"))
17240 show_macs(res->cmd_pid);
17241 else if (!strcmp(res->cmd_keyword, "mcast_macs"))
17242 show_mcast_macs(res->cmd_pid);
17245 cmdline_parse_token_string_t cmd_showport_macs_show =
17246 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17248 cmdline_parse_token_string_t cmd_showport_macs_port =
17249 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17251 cmdline_parse_token_num_t cmd_showport_macs_pid =
17252 TOKEN_NUM_INITIALIZER(struct cmd_showport_macs_result,
17253 cmd_pid, RTE_UINT16);
17254 cmdline_parse_token_string_t cmd_showport_macs_keyword =
17255 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17256 cmd_keyword, "macs#mcast_macs");
17258 cmdline_parse_inst_t cmd_showport_macs = {
17259 .f = cmd_showport_macs_parsed,
17261 .help_str = "show port <port_id> macs|mcast_macs",
17263 (void *)&cmd_showport_macs_show,
17264 (void *)&cmd_showport_macs_port,
17265 (void *)&cmd_showport_macs_pid,
17266 (void *)&cmd_showport_macs_keyword,
17271 /* ******************************************************************************** */
17273 /* list of instructions */
17274 cmdline_parse_ctx_t main_ctx[] = {
17275 (cmdline_parse_inst_t *)&cmd_help_brief,
17276 (cmdline_parse_inst_t *)&cmd_help_long,
17277 (cmdline_parse_inst_t *)&cmd_quit,
17278 (cmdline_parse_inst_t *)&cmd_load_from_file,
17279 (cmdline_parse_inst_t *)&cmd_showport,
17280 (cmdline_parse_inst_t *)&cmd_showqueue,
17281 (cmdline_parse_inst_t *)&cmd_showeeprom,
17282 (cmdline_parse_inst_t *)&cmd_showportall,
17283 (cmdline_parse_inst_t *)&cmd_showdevice,
17284 (cmdline_parse_inst_t *)&cmd_showcfg,
17285 (cmdline_parse_inst_t *)&cmd_showfwdall,
17286 (cmdline_parse_inst_t *)&cmd_start,
17287 (cmdline_parse_inst_t *)&cmd_start_tx_first,
17288 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
17289 (cmdline_parse_inst_t *)&cmd_set_link_up,
17290 (cmdline_parse_inst_t *)&cmd_set_link_down,
17291 (cmdline_parse_inst_t *)&cmd_reset,
17292 (cmdline_parse_inst_t *)&cmd_set_numbers,
17293 (cmdline_parse_inst_t *)&cmd_set_log,
17294 (cmdline_parse_inst_t *)&cmd_set_rxoffs,
17295 (cmdline_parse_inst_t *)&cmd_set_rxpkts,
17296 (cmdline_parse_inst_t *)&cmd_set_txpkts,
17297 (cmdline_parse_inst_t *)&cmd_set_txsplit,
17298 (cmdline_parse_inst_t *)&cmd_set_txtimes,
17299 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
17300 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
17301 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
17302 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
17303 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
17304 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
17305 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
17306 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
17307 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
17308 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
17309 (cmdline_parse_inst_t *)&cmd_set_link_check,
17310 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
17311 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
17312 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
17313 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
17314 #ifdef RTE_NET_BOND
17315 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
17316 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
17317 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
17318 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
17319 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
17320 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
17321 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
17322 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
17323 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
17324 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
17325 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
17327 (cmdline_parse_inst_t *)&cmd_vlan_offload,
17328 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
17329 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
17330 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
17331 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
17332 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
17333 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
17334 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
17335 (cmdline_parse_inst_t *)&cmd_csum_set,
17336 (cmdline_parse_inst_t *)&cmd_csum_show,
17337 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
17338 (cmdline_parse_inst_t *)&cmd_tso_set,
17339 (cmdline_parse_inst_t *)&cmd_tso_show,
17340 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
17341 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
17342 (cmdline_parse_inst_t *)&cmd_gro_enable,
17343 (cmdline_parse_inst_t *)&cmd_gro_flush,
17344 (cmdline_parse_inst_t *)&cmd_gro_show,
17345 (cmdline_parse_inst_t *)&cmd_gso_enable,
17346 (cmdline_parse_inst_t *)&cmd_gso_size,
17347 (cmdline_parse_inst_t *)&cmd_gso_show,
17348 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
17349 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
17350 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
17351 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
17352 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
17353 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
17354 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
17355 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
17356 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
17357 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
17358 (cmdline_parse_inst_t *)&cmd_config_dcb,
17359 (cmdline_parse_inst_t *)&cmd_read_reg,
17360 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
17361 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
17362 (cmdline_parse_inst_t *)&cmd_write_reg,
17363 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
17364 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
17365 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
17366 (cmdline_parse_inst_t *)&cmd_stop,
17367 (cmdline_parse_inst_t *)&cmd_mac_addr,
17368 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
17369 (cmdline_parse_inst_t *)&cmd_set_qmap,
17370 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
17371 (cmdline_parse_inst_t *)&cmd_set_record_core_cycles,
17372 (cmdline_parse_inst_t *)&cmd_set_record_burst_stats,
17373 (cmdline_parse_inst_t *)&cmd_operate_port,
17374 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
17375 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
17376 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
17377 (cmdline_parse_inst_t *)&cmd_operate_detach_device,
17378 (cmdline_parse_inst_t *)&cmd_set_port_setup_on,
17379 (cmdline_parse_inst_t *)&cmd_config_speed_all,
17380 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
17381 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
17382 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
17383 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
17384 (cmdline_parse_inst_t *)&cmd_config_mtu,
17385 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
17386 (cmdline_parse_inst_t *)&cmd_config_max_lro_pkt_size,
17387 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
17388 (cmdline_parse_inst_t *)&cmd_config_rss,
17389 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
17390 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
17391 (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
17392 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
17393 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
17394 (cmdline_parse_inst_t *)&cmd_showport_reta,
17395 (cmdline_parse_inst_t *)&cmd_showport_macs,
17396 (cmdline_parse_inst_t *)&cmd_config_burst,
17397 (cmdline_parse_inst_t *)&cmd_config_thresh,
17398 (cmdline_parse_inst_t *)&cmd_config_threshold,
17399 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
17400 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
17401 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
17402 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
17403 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
17404 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
17405 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
17406 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
17407 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
17408 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
17409 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
17410 (cmdline_parse_inst_t *)&cmd_dump,
17411 (cmdline_parse_inst_t *)&cmd_dump_one,
17412 #ifdef RTE_NET_I40E
17413 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
17415 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
17416 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
17417 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
17418 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
17419 (cmdline_parse_inst_t *)&cmd_flow,
17420 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
17421 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
17422 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
17423 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
17424 (cmdline_parse_inst_t *)&cmd_create_port_meter,
17425 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
17426 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
17427 (cmdline_parse_inst_t *)&cmd_del_port_meter,
17428 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
17429 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
17430 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
17431 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
17432 (cmdline_parse_inst_t *)&cmd_mcast_addr,
17433 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
17434 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
17435 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
17436 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
17437 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
17438 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
17439 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
17440 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
17441 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
17442 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
17443 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
17444 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
17445 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
17446 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
17447 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
17448 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
17449 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
17450 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
17451 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
17452 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
17453 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
17454 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
17455 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
17456 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
17457 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
17458 (cmdline_parse_inst_t *)&cmd_set_vxlan,
17459 (cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl,
17460 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
17461 (cmdline_parse_inst_t *)&cmd_set_nvgre,
17462 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
17463 (cmdline_parse_inst_t *)&cmd_set_l2_encap,
17464 (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
17465 (cmdline_parse_inst_t *)&cmd_set_l2_decap,
17466 (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
17467 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
17468 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
17469 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
17470 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
17471 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
17472 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
17473 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
17474 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
17475 (cmdline_parse_inst_t *)&cmd_set_conntrack_common,
17476 (cmdline_parse_inst_t *)&cmd_set_conntrack_dir,
17477 (cmdline_parse_inst_t *)&cmd_ddp_add,
17478 (cmdline_parse_inst_t *)&cmd_ddp_del,
17479 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
17480 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
17481 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
17482 (cmdline_parse_inst_t *)&cmd_clear_input_set,
17483 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
17484 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
17485 (cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes,
17486 (cmdline_parse_inst_t *)&cmd_set_port_ptypes,
17487 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
17488 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
17489 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
17490 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
17492 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
17493 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
17494 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
17495 (cmdline_parse_inst_t *)&cmd_queue_region,
17496 (cmdline_parse_inst_t *)&cmd_region_flowtype,
17497 (cmdline_parse_inst_t *)&cmd_user_priority_region,
17498 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
17499 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
17500 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
17501 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
17502 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
17503 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
17504 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
17505 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
17506 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
17507 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
17508 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
17509 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
17510 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
17511 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
17512 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
17513 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node_pmode,
17514 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
17515 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
17516 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
17517 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
17518 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
17519 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
17520 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
17521 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
17522 (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
17523 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
17524 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
17525 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
17526 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
17527 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
17528 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
17529 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
17530 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
17531 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
17533 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
17534 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
17536 (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
17537 (cmdline_parse_inst_t *)&cmd_show_tx_metadata,
17538 (cmdline_parse_inst_t *)&cmd_show_rx_tx_desc_status,
17539 (cmdline_parse_inst_t *)&cmd_show_rx_queue_desc_used_count,
17540 (cmdline_parse_inst_t *)&cmd_set_raw,
17541 (cmdline_parse_inst_t *)&cmd_show_set_raw,
17542 (cmdline_parse_inst_t *)&cmd_show_set_raw_all,
17543 (cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific,
17544 (cmdline_parse_inst_t *)&cmd_show_fec_mode,
17545 (cmdline_parse_inst_t *)&cmd_set_fec_mode,
17546 (cmdline_parse_inst_t *)&cmd_show_capability,
17550 /* read cmdline commands from file */
17552 cmdline_read_from_file(const char *filename)
17554 struct cmdline *cl;
17556 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
17558 printf("Failed to create file based cmdline context: %s\n",
17563 cmdline_interact(cl);
17568 printf("Read CLI commands from %s\n", filename);
17571 /* prompt function, called from main on MAIN lcore */
17576 /* initialize non-constant commands */
17577 cmd_set_fwd_mode_init();
17578 cmd_set_fwd_retry_mode_init();
17580 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
17581 if (testpmd_cl == NULL)
17584 ret = atexit(prompt_exit);
17586 printf("Cannot set exit function for cmdline\n");
17588 cmdline_interact(testpmd_cl);
17590 cmdline_stdin_exit(testpmd_cl);
17596 if (testpmd_cl != NULL) {
17597 cmdline_quit(testpmd_cl);
17598 cmdline_stdin_exit(testpmd_cl);
17603 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
17605 if (id == (portid_t)RTE_PORT_ALL) {
17608 RTE_ETH_FOREACH_DEV(pid) {
17609 /* check if need_reconfig has been set to 1 */
17610 if (ports[pid].need_reconfig == 0)
17611 ports[pid].need_reconfig = dev;
17612 /* check if need_reconfig_queues has been set to 1 */
17613 if (ports[pid].need_reconfig_queues == 0)
17614 ports[pid].need_reconfig_queues = queue;
17616 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
17617 /* check if need_reconfig has been set to 1 */
17618 if (ports[id].need_reconfig == 0)
17619 ports[id].need_reconfig = dev;
17620 /* check if need_reconfig_queues has been set to 1 */
17621 if (ports[id].need_reconfig_queues == 0)
17622 ports[id].need_reconfig_queues = queue;