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)\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)\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)\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 shared_action {port_id} create"
1006 " [action_id {shared_action_id}]"
1007 " [ingress] [egress]"
1008 " action {action} / end\n"
1009 " Create shared action.\n\n"
1011 "flow shared_action {port_id} update"
1012 " {shared_action_id} action {action} / end\n"
1013 " Update shared action.\n\n"
1015 "flow shared_action {port_id} destroy"
1016 " action_id {shared_action_id} [...]\n"
1017 " Destroy specific shared actions.\n\n"
1019 "flow shared_action {port_id} query"
1020 " {shared_action_id}\n"
1021 " Query an existing shared 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");
1532 cmd_config_speed_all_parsed(void *parsed_result,
1533 __rte_unused struct cmdline *cl,
1534 __rte_unused void *data)
1536 struct cmd_config_speed_all *res = parsed_result;
1537 uint32_t link_speed;
1540 if (!all_ports_stopped()) {
1541 printf("Please stop all ports first\n");
1545 if (parse_and_check_speed_duplex(res->value1, res->value2,
1549 RTE_ETH_FOREACH_DEV(pid) {
1550 ports[pid].dev_conf.link_speeds = link_speed;
1553 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1556 cmdline_parse_token_string_t cmd_config_speed_all_port =
1557 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1558 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1559 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1561 cmdline_parse_token_string_t cmd_config_speed_all_all =
1562 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1563 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1564 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1565 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1566 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1567 "10#100#1000#10000#25000#40000#50000#100000#200000#auto");
1568 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1569 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1570 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1571 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1574 cmdline_parse_inst_t cmd_config_speed_all = {
1575 .f = cmd_config_speed_all_parsed,
1577 .help_str = "port config all speed "
1578 "10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex "
1581 (void *)&cmd_config_speed_all_port,
1582 (void *)&cmd_config_speed_all_keyword,
1583 (void *)&cmd_config_speed_all_all,
1584 (void *)&cmd_config_speed_all_item1,
1585 (void *)&cmd_config_speed_all_value1,
1586 (void *)&cmd_config_speed_all_item2,
1587 (void *)&cmd_config_speed_all_value2,
1592 /* *** configure speed for specific port *** */
1593 struct cmd_config_speed_specific {
1594 cmdline_fixed_string_t port;
1595 cmdline_fixed_string_t keyword;
1597 cmdline_fixed_string_t item1;
1598 cmdline_fixed_string_t item2;
1599 cmdline_fixed_string_t value1;
1600 cmdline_fixed_string_t value2;
1604 cmd_config_speed_specific_parsed(void *parsed_result,
1605 __rte_unused struct cmdline *cl,
1606 __rte_unused void *data)
1608 struct cmd_config_speed_specific *res = parsed_result;
1609 uint32_t link_speed;
1611 if (!all_ports_stopped()) {
1612 printf("Please stop all ports first\n");
1616 if (port_id_is_invalid(res->id, ENABLED_WARN))
1619 if (parse_and_check_speed_duplex(res->value1, res->value2,
1623 ports[res->id].dev_conf.link_speeds = link_speed;
1625 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1629 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1630 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1632 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1633 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1635 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1636 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, RTE_UINT16);
1637 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1638 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1640 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1641 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1642 "10#100#1000#10000#25000#40000#50000#100000#200000#auto");
1643 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1644 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1646 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1647 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1650 cmdline_parse_inst_t cmd_config_speed_specific = {
1651 .f = cmd_config_speed_specific_parsed,
1653 .help_str = "port config <port_id> speed "
1654 "10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex "
1657 (void *)&cmd_config_speed_specific_port,
1658 (void *)&cmd_config_speed_specific_keyword,
1659 (void *)&cmd_config_speed_specific_id,
1660 (void *)&cmd_config_speed_specific_item1,
1661 (void *)&cmd_config_speed_specific_value1,
1662 (void *)&cmd_config_speed_specific_item2,
1663 (void *)&cmd_config_speed_specific_value2,
1668 /* *** configure loopback for all ports *** */
1669 struct cmd_config_loopback_all {
1670 cmdline_fixed_string_t port;
1671 cmdline_fixed_string_t keyword;
1672 cmdline_fixed_string_t all;
1673 cmdline_fixed_string_t item;
1678 cmd_config_loopback_all_parsed(void *parsed_result,
1679 __rte_unused struct cmdline *cl,
1680 __rte_unused void *data)
1682 struct cmd_config_loopback_all *res = parsed_result;
1685 if (!all_ports_stopped()) {
1686 printf("Please stop all ports first\n");
1690 RTE_ETH_FOREACH_DEV(pid) {
1691 ports[pid].dev_conf.lpbk_mode = res->mode;
1694 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1697 cmdline_parse_token_string_t cmd_config_loopback_all_port =
1698 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1699 cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1700 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1702 cmdline_parse_token_string_t cmd_config_loopback_all_all =
1703 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1704 cmdline_parse_token_string_t cmd_config_loopback_all_item =
1705 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1707 cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1708 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, RTE_UINT32);
1710 cmdline_parse_inst_t cmd_config_loopback_all = {
1711 .f = cmd_config_loopback_all_parsed,
1713 .help_str = "port config all loopback <mode>",
1715 (void *)&cmd_config_loopback_all_port,
1716 (void *)&cmd_config_loopback_all_keyword,
1717 (void *)&cmd_config_loopback_all_all,
1718 (void *)&cmd_config_loopback_all_item,
1719 (void *)&cmd_config_loopback_all_mode,
1724 /* *** configure loopback for specific port *** */
1725 struct cmd_config_loopback_specific {
1726 cmdline_fixed_string_t port;
1727 cmdline_fixed_string_t keyword;
1729 cmdline_fixed_string_t item;
1734 cmd_config_loopback_specific_parsed(void *parsed_result,
1735 __rte_unused struct cmdline *cl,
1736 __rte_unused void *data)
1738 struct cmd_config_loopback_specific *res = parsed_result;
1740 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1743 if (!port_is_stopped(res->port_id)) {
1744 printf("Please stop port %u first\n", res->port_id);
1748 ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1750 cmd_reconfig_device_queue(res->port_id, 1, 1);
1754 cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1755 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1757 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1758 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1760 cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1761 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1763 cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1764 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1766 cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1767 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1770 cmdline_parse_inst_t cmd_config_loopback_specific = {
1771 .f = cmd_config_loopback_specific_parsed,
1773 .help_str = "port config <port_id> loopback <mode>",
1775 (void *)&cmd_config_loopback_specific_port,
1776 (void *)&cmd_config_loopback_specific_keyword,
1777 (void *)&cmd_config_loopback_specific_id,
1778 (void *)&cmd_config_loopback_specific_item,
1779 (void *)&cmd_config_loopback_specific_mode,
1784 /* *** configure txq/rxq, txd/rxd *** */
1785 struct cmd_config_rx_tx {
1786 cmdline_fixed_string_t port;
1787 cmdline_fixed_string_t keyword;
1788 cmdline_fixed_string_t all;
1789 cmdline_fixed_string_t name;
1794 cmd_config_rx_tx_parsed(void *parsed_result,
1795 __rte_unused struct cmdline *cl,
1796 __rte_unused void *data)
1798 struct cmd_config_rx_tx *res = parsed_result;
1800 if (!all_ports_stopped()) {
1801 printf("Please stop all ports first\n");
1804 if (!strcmp(res->name, "rxq")) {
1805 if (!res->value && !nb_txq) {
1806 printf("Warning: Either rx or tx queues should be non zero\n");
1809 if (check_nb_rxq(res->value) != 0)
1811 nb_rxq = res->value;
1813 else if (!strcmp(res->name, "txq")) {
1814 if (!res->value && !nb_rxq) {
1815 printf("Warning: Either rx or tx queues should be non zero\n");
1818 if (check_nb_txq(res->value) != 0)
1820 nb_txq = res->value;
1822 else if (!strcmp(res->name, "rxd")) {
1823 if (check_nb_rxd(res->value) != 0)
1825 nb_rxd = res->value;
1826 } else if (!strcmp(res->name, "txd")) {
1827 if (check_nb_txd(res->value) != 0)
1830 nb_txd = res->value;
1832 printf("Unknown parameter\n");
1840 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1843 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1844 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1845 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1846 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1847 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1848 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1849 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1850 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1852 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1853 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, RTE_UINT16);
1855 cmdline_parse_inst_t cmd_config_rx_tx = {
1856 .f = cmd_config_rx_tx_parsed,
1858 .help_str = "port config all rxq|txq|rxd|txd <value>",
1860 (void *)&cmd_config_rx_tx_port,
1861 (void *)&cmd_config_rx_tx_keyword,
1862 (void *)&cmd_config_rx_tx_all,
1863 (void *)&cmd_config_rx_tx_name,
1864 (void *)&cmd_config_rx_tx_value,
1869 /* *** config max packet length *** */
1870 struct cmd_config_max_pkt_len_result {
1871 cmdline_fixed_string_t port;
1872 cmdline_fixed_string_t keyword;
1873 cmdline_fixed_string_t all;
1874 cmdline_fixed_string_t name;
1879 cmd_config_max_pkt_len_parsed(void *parsed_result,
1880 __rte_unused struct cmdline *cl,
1881 __rte_unused void *data)
1883 struct cmd_config_max_pkt_len_result *res = parsed_result;
1884 uint32_t max_rx_pkt_len_backup = 0;
1888 if (!all_ports_stopped()) {
1889 printf("Please stop all ports first\n");
1893 RTE_ETH_FOREACH_DEV(pid) {
1894 struct rte_port *port = &ports[pid];
1896 if (!strcmp(res->name, "max-pkt-len")) {
1897 if (res->value < RTE_ETHER_MIN_LEN) {
1898 printf("max-pkt-len can not be less than %d\n",
1902 if (res->value == port->dev_conf.rxmode.max_rx_pkt_len)
1905 ret = eth_dev_info_get_print_err(pid, &port->dev_info);
1907 printf("rte_eth_dev_info_get() failed for port %u\n",
1912 max_rx_pkt_len_backup = port->dev_conf.rxmode.max_rx_pkt_len;
1914 port->dev_conf.rxmode.max_rx_pkt_len = res->value;
1915 if (update_jumbo_frame_offload(pid) != 0)
1916 port->dev_conf.rxmode.max_rx_pkt_len = max_rx_pkt_len_backup;
1918 printf("Unknown parameter\n");
1925 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1928 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1929 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1931 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1932 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1934 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1935 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1937 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1938 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1940 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1941 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1944 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1945 .f = cmd_config_max_pkt_len_parsed,
1947 .help_str = "port config all max-pkt-len <value>",
1949 (void *)&cmd_config_max_pkt_len_port,
1950 (void *)&cmd_config_max_pkt_len_keyword,
1951 (void *)&cmd_config_max_pkt_len_all,
1952 (void *)&cmd_config_max_pkt_len_name,
1953 (void *)&cmd_config_max_pkt_len_value,
1958 /* *** config max LRO aggregated packet size *** */
1959 struct cmd_config_max_lro_pkt_size_result {
1960 cmdline_fixed_string_t port;
1961 cmdline_fixed_string_t keyword;
1962 cmdline_fixed_string_t all;
1963 cmdline_fixed_string_t name;
1968 cmd_config_max_lro_pkt_size_parsed(void *parsed_result,
1969 __rte_unused struct cmdline *cl,
1970 __rte_unused void *data)
1972 struct cmd_config_max_lro_pkt_size_result *res = parsed_result;
1975 if (!all_ports_stopped()) {
1976 printf("Please stop all ports first\n");
1980 RTE_ETH_FOREACH_DEV(pid) {
1981 struct rte_port *port = &ports[pid];
1983 if (!strcmp(res->name, "max-lro-pkt-size")) {
1985 port->dev_conf.rxmode.max_lro_pkt_size)
1988 port->dev_conf.rxmode.max_lro_pkt_size = res->value;
1990 printf("Unknown parameter\n");
1997 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2000 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_port =
2001 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2003 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_keyword =
2004 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2006 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_all =
2007 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2009 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_name =
2010 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2011 name, "max-lro-pkt-size");
2012 cmdline_parse_token_num_t cmd_config_max_lro_pkt_size_value =
2013 TOKEN_NUM_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2016 cmdline_parse_inst_t cmd_config_max_lro_pkt_size = {
2017 .f = cmd_config_max_lro_pkt_size_parsed,
2019 .help_str = "port config all max-lro-pkt-size <value>",
2021 (void *)&cmd_config_max_lro_pkt_size_port,
2022 (void *)&cmd_config_max_lro_pkt_size_keyword,
2023 (void *)&cmd_config_max_lro_pkt_size_all,
2024 (void *)&cmd_config_max_lro_pkt_size_name,
2025 (void *)&cmd_config_max_lro_pkt_size_value,
2030 /* *** configure port MTU *** */
2031 struct cmd_config_mtu_result {
2032 cmdline_fixed_string_t port;
2033 cmdline_fixed_string_t keyword;
2034 cmdline_fixed_string_t mtu;
2040 cmd_config_mtu_parsed(void *parsed_result,
2041 __rte_unused struct cmdline *cl,
2042 __rte_unused void *data)
2044 struct cmd_config_mtu_result *res = parsed_result;
2046 if (res->value < RTE_ETHER_MIN_LEN) {
2047 printf("mtu cannot be less than %d\n", RTE_ETHER_MIN_LEN);
2050 port_mtu_set(res->port_id, res->value);
2053 cmdline_parse_token_string_t cmd_config_mtu_port =
2054 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
2056 cmdline_parse_token_string_t cmd_config_mtu_keyword =
2057 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2059 cmdline_parse_token_string_t cmd_config_mtu_mtu =
2060 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2062 cmdline_parse_token_num_t cmd_config_mtu_port_id =
2063 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id,
2065 cmdline_parse_token_num_t cmd_config_mtu_value =
2066 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value,
2069 cmdline_parse_inst_t cmd_config_mtu = {
2070 .f = cmd_config_mtu_parsed,
2072 .help_str = "port config mtu <port_id> <value>",
2074 (void *)&cmd_config_mtu_port,
2075 (void *)&cmd_config_mtu_keyword,
2076 (void *)&cmd_config_mtu_mtu,
2077 (void *)&cmd_config_mtu_port_id,
2078 (void *)&cmd_config_mtu_value,
2083 /* *** configure rx mode *** */
2084 struct cmd_config_rx_mode_flag {
2085 cmdline_fixed_string_t port;
2086 cmdline_fixed_string_t keyword;
2087 cmdline_fixed_string_t all;
2088 cmdline_fixed_string_t name;
2089 cmdline_fixed_string_t value;
2093 cmd_config_rx_mode_flag_parsed(void *parsed_result,
2094 __rte_unused struct cmdline *cl,
2095 __rte_unused void *data)
2097 struct cmd_config_rx_mode_flag *res = parsed_result;
2099 if (!all_ports_stopped()) {
2100 printf("Please stop all ports first\n");
2104 if (!strcmp(res->name, "drop-en")) {
2105 if (!strcmp(res->value, "on"))
2107 else if (!strcmp(res->value, "off"))
2110 printf("Unknown parameter\n");
2114 printf("Unknown parameter\n");
2120 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2123 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
2124 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
2125 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
2126 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
2128 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2129 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2130 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2131 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2133 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2134 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2137 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2138 .f = cmd_config_rx_mode_flag_parsed,
2140 .help_str = "port config all drop-en on|off",
2142 (void *)&cmd_config_rx_mode_flag_port,
2143 (void *)&cmd_config_rx_mode_flag_keyword,
2144 (void *)&cmd_config_rx_mode_flag_all,
2145 (void *)&cmd_config_rx_mode_flag_name,
2146 (void *)&cmd_config_rx_mode_flag_value,
2151 /* *** configure rss *** */
2152 struct cmd_config_rss {
2153 cmdline_fixed_string_t port;
2154 cmdline_fixed_string_t keyword;
2155 cmdline_fixed_string_t all;
2156 cmdline_fixed_string_t name;
2157 cmdline_fixed_string_t value;
2161 cmd_config_rss_parsed(void *parsed_result,
2162 __rte_unused struct cmdline *cl,
2163 __rte_unused void *data)
2165 struct cmd_config_rss *res = parsed_result;
2166 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2167 struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2168 int use_default = 0;
2169 int all_updated = 1;
2174 if (!strcmp(res->value, "all"))
2175 rss_conf.rss_hf = ETH_RSS_ETH | ETH_RSS_VLAN | ETH_RSS_IP |
2176 ETH_RSS_TCP | ETH_RSS_UDP | ETH_RSS_SCTP |
2177 ETH_RSS_L2_PAYLOAD | ETH_RSS_L2TPV3 | ETH_RSS_ESP |
2178 ETH_RSS_AH | ETH_RSS_PFCP | ETH_RSS_GTPU |
2180 else if (!strcmp(res->value, "eth"))
2181 rss_conf.rss_hf = ETH_RSS_ETH;
2182 else if (!strcmp(res->value, "vlan"))
2183 rss_conf.rss_hf = ETH_RSS_VLAN;
2184 else if (!strcmp(res->value, "ip"))
2185 rss_conf.rss_hf = ETH_RSS_IP;
2186 else if (!strcmp(res->value, "udp"))
2187 rss_conf.rss_hf = ETH_RSS_UDP;
2188 else if (!strcmp(res->value, "tcp"))
2189 rss_conf.rss_hf = ETH_RSS_TCP;
2190 else if (!strcmp(res->value, "sctp"))
2191 rss_conf.rss_hf = ETH_RSS_SCTP;
2192 else if (!strcmp(res->value, "ether"))
2193 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
2194 else if (!strcmp(res->value, "port"))
2195 rss_conf.rss_hf = ETH_RSS_PORT;
2196 else if (!strcmp(res->value, "vxlan"))
2197 rss_conf.rss_hf = ETH_RSS_VXLAN;
2198 else if (!strcmp(res->value, "geneve"))
2199 rss_conf.rss_hf = ETH_RSS_GENEVE;
2200 else if (!strcmp(res->value, "nvgre"))
2201 rss_conf.rss_hf = ETH_RSS_NVGRE;
2202 else if (!strcmp(res->value, "l3-pre32"))
2203 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE32;
2204 else if (!strcmp(res->value, "l3-pre40"))
2205 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE40;
2206 else if (!strcmp(res->value, "l3-pre48"))
2207 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE48;
2208 else if (!strcmp(res->value, "l3-pre56"))
2209 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE56;
2210 else if (!strcmp(res->value, "l3-pre64"))
2211 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE64;
2212 else if (!strcmp(res->value, "l3-pre96"))
2213 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE96;
2214 else if (!strcmp(res->value, "l3-src-only"))
2215 rss_conf.rss_hf = ETH_RSS_L3_SRC_ONLY;
2216 else if (!strcmp(res->value, "l3-dst-only"))
2217 rss_conf.rss_hf = ETH_RSS_L3_DST_ONLY;
2218 else if (!strcmp(res->value, "l4-src-only"))
2219 rss_conf.rss_hf = ETH_RSS_L4_SRC_ONLY;
2220 else if (!strcmp(res->value, "l4-dst-only"))
2221 rss_conf.rss_hf = ETH_RSS_L4_DST_ONLY;
2222 else if (!strcmp(res->value, "l2-src-only"))
2223 rss_conf.rss_hf = ETH_RSS_L2_SRC_ONLY;
2224 else if (!strcmp(res->value, "l2-dst-only"))
2225 rss_conf.rss_hf = ETH_RSS_L2_DST_ONLY;
2226 else if (!strcmp(res->value, "l2tpv3"))
2227 rss_conf.rss_hf = ETH_RSS_L2TPV3;
2228 else if (!strcmp(res->value, "esp"))
2229 rss_conf.rss_hf = ETH_RSS_ESP;
2230 else if (!strcmp(res->value, "ah"))
2231 rss_conf.rss_hf = ETH_RSS_AH;
2232 else if (!strcmp(res->value, "pfcp"))
2233 rss_conf.rss_hf = ETH_RSS_PFCP;
2234 else if (!strcmp(res->value, "pppoe"))
2235 rss_conf.rss_hf = ETH_RSS_PPPOE;
2236 else if (!strcmp(res->value, "gtpu"))
2237 rss_conf.rss_hf = ETH_RSS_GTPU;
2238 else if (!strcmp(res->value, "ecpri"))
2239 rss_conf.rss_hf = ETH_RSS_ECPRI;
2240 else if (!strcmp(res->value, "mpls"))
2241 rss_conf.rss_hf = ETH_RSS_MPLS;
2242 else if (!strcmp(res->value, "none"))
2243 rss_conf.rss_hf = 0;
2244 else if (!strcmp(res->value, "level-default")) {
2245 rss_hf &= (~ETH_RSS_LEVEL_MASK);
2246 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_PMD_DEFAULT);
2247 } else if (!strcmp(res->value, "level-outer")) {
2248 rss_hf &= (~ETH_RSS_LEVEL_MASK);
2249 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_OUTERMOST);
2250 } else if (!strcmp(res->value, "level-inner")) {
2251 rss_hf &= (~ETH_RSS_LEVEL_MASK);
2252 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_INNERMOST);
2253 } else if (!strcmp(res->value, "default"))
2255 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2256 atoi(res->value) < 64)
2257 rss_conf.rss_hf = 1ULL << atoi(res->value);
2259 printf("Unknown parameter\n");
2262 rss_conf.rss_key = NULL;
2263 /* Update global configuration for RSS types. */
2264 RTE_ETH_FOREACH_DEV(i) {
2265 struct rte_eth_rss_conf local_rss_conf;
2267 ret = eth_dev_info_get_print_err(i, &dev_info);
2272 rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2274 local_rss_conf = rss_conf;
2275 local_rss_conf.rss_hf = rss_conf.rss_hf &
2276 dev_info.flow_type_rss_offloads;
2277 if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2278 printf("Port %u modified RSS hash function based on hardware support,"
2279 "requested:%#"PRIx64" configured:%#"PRIx64"\n",
2280 i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2282 diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2285 printf("Configuration of RSS hash at ethernet port %d "
2286 "failed with error (%d): %s.\n",
2287 i, -diag, strerror(-diag));
2290 if (all_updated && !use_default) {
2291 rss_hf = rss_conf.rss_hf;
2292 printf("rss_hf %#"PRIx64"\n", rss_hf);
2296 cmdline_parse_token_string_t cmd_config_rss_port =
2297 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2298 cmdline_parse_token_string_t cmd_config_rss_keyword =
2299 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2300 cmdline_parse_token_string_t cmd_config_rss_all =
2301 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2302 cmdline_parse_token_string_t cmd_config_rss_name =
2303 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2304 cmdline_parse_token_string_t cmd_config_rss_value =
2305 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2307 cmdline_parse_inst_t cmd_config_rss = {
2308 .f = cmd_config_rss_parsed,
2310 .help_str = "port config all rss "
2311 "all|default|eth|vlan|ip|tcp|udp|sctp|ether|port|vxlan|geneve|"
2312 "nvgre|vxlan-gpe|l2tpv3|esp|ah|pfcp|ecpri|mpls|none|level-default|"
2313 "level-outer|level-inner|<flowtype_id>",
2315 (void *)&cmd_config_rss_port,
2316 (void *)&cmd_config_rss_keyword,
2317 (void *)&cmd_config_rss_all,
2318 (void *)&cmd_config_rss_name,
2319 (void *)&cmd_config_rss_value,
2324 /* *** configure rss hash key *** */
2325 struct cmd_config_rss_hash_key {
2326 cmdline_fixed_string_t port;
2327 cmdline_fixed_string_t config;
2329 cmdline_fixed_string_t rss_hash_key;
2330 cmdline_fixed_string_t rss_type;
2331 cmdline_fixed_string_t key;
2335 hexa_digit_to_value(char hexa_digit)
2337 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2338 return (uint8_t) (hexa_digit - '0');
2339 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2340 return (uint8_t) ((hexa_digit - 'a') + 10);
2341 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2342 return (uint8_t) ((hexa_digit - 'A') + 10);
2343 /* Invalid hexa digit */
2348 parse_and_check_key_hexa_digit(char *key, int idx)
2352 hexa_v = hexa_digit_to_value(key[idx]);
2354 printf("invalid key: character %c at position %d is not a "
2355 "valid hexa digit\n", key[idx], idx);
2360 cmd_config_rss_hash_key_parsed(void *parsed_result,
2361 __rte_unused struct cmdline *cl,
2362 __rte_unused void *data)
2364 struct cmd_config_rss_hash_key *res = parsed_result;
2365 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2369 struct rte_eth_dev_info dev_info;
2370 uint8_t hash_key_size;
2374 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2378 if (dev_info.hash_key_size > 0 &&
2379 dev_info.hash_key_size <= sizeof(hash_key))
2380 hash_key_size = dev_info.hash_key_size;
2382 printf("dev_info did not provide a valid hash key size\n");
2385 /* Check the length of the RSS hash key */
2386 key_len = strlen(res->key);
2387 if (key_len != (hash_key_size * 2)) {
2388 printf("key length: %d invalid - key must be a string of %d"
2389 " hexa-decimal numbers\n",
2390 (int) key_len, hash_key_size * 2);
2393 /* Translate RSS hash key into binary representation */
2394 for (i = 0; i < hash_key_size; i++) {
2395 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2398 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2401 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2403 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2407 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2408 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2409 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2410 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2412 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2413 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id,
2415 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2416 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2417 rss_hash_key, "rss-hash-key");
2418 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2419 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2420 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2421 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2422 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2423 "ipv6-tcp-ex#ipv6-udp-ex#"
2424 "l3-src-only#l3-dst-only#l4-src-only#l4-dst-only#"
2425 "l2-src-only#l2-dst-only#s-vlan#c-vlan#"
2426 "l2tpv3#esp#ah#pfcp#pppoe#gtpu#ecpri");
2427 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2428 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2430 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2431 .f = cmd_config_rss_hash_key_parsed,
2433 .help_str = "port config <port_id> rss-hash-key "
2434 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2435 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2436 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|"
2437 "l3-src-only|l3-dst-only|l4-src-only|l4-dst-only|"
2438 "l2-src-only|l2-dst-only|s-vlan|c-vlan|"
2439 "l2tpv3|esp|ah|pfcp|pppoe|gtpu|ecpri "
2440 "<string of hex digits (variable length, NIC dependent)>",
2442 (void *)&cmd_config_rss_hash_key_port,
2443 (void *)&cmd_config_rss_hash_key_config,
2444 (void *)&cmd_config_rss_hash_key_port_id,
2445 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2446 (void *)&cmd_config_rss_hash_key_rss_type,
2447 (void *)&cmd_config_rss_hash_key_value,
2452 /* *** configure port rxq/txq ring size *** */
2453 struct cmd_config_rxtx_ring_size {
2454 cmdline_fixed_string_t port;
2455 cmdline_fixed_string_t config;
2457 cmdline_fixed_string_t rxtxq;
2459 cmdline_fixed_string_t rsize;
2464 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2465 __rte_unused struct cmdline *cl,
2466 __rte_unused void *data)
2468 struct cmd_config_rxtx_ring_size *res = parsed_result;
2469 struct rte_port *port;
2472 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2475 if (res->portid == (portid_t)RTE_PORT_ALL) {
2476 printf("Invalid port id\n");
2480 port = &ports[res->portid];
2482 if (!strcmp(res->rxtxq, "rxq"))
2484 else if (!strcmp(res->rxtxq, "txq"))
2487 printf("Unknown parameter\n");
2491 if (isrx && rx_queue_id_is_invalid(res->qid))
2493 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2496 if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2497 printf("Invalid rx ring_size, must > rx_free_thresh: %d\n",
2503 port->nb_rx_desc[res->qid] = res->size;
2505 port->nb_tx_desc[res->qid] = res->size;
2507 cmd_reconfig_device_queue(res->portid, 0, 1);
2510 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2511 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2513 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2514 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2516 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2517 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2518 portid, RTE_UINT16);
2519 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2520 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2522 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2523 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2525 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2526 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2527 rsize, "ring_size");
2528 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2529 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2532 cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2533 .f = cmd_config_rxtx_ring_size_parsed,
2535 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2537 (void *)&cmd_config_rxtx_ring_size_port,
2538 (void *)&cmd_config_rxtx_ring_size_config,
2539 (void *)&cmd_config_rxtx_ring_size_portid,
2540 (void *)&cmd_config_rxtx_ring_size_rxtxq,
2541 (void *)&cmd_config_rxtx_ring_size_qid,
2542 (void *)&cmd_config_rxtx_ring_size_rsize,
2543 (void *)&cmd_config_rxtx_ring_size_size,
2548 /* *** configure port rxq/txq start/stop *** */
2549 struct cmd_config_rxtx_queue {
2550 cmdline_fixed_string_t port;
2552 cmdline_fixed_string_t rxtxq;
2554 cmdline_fixed_string_t opname;
2558 cmd_config_rxtx_queue_parsed(void *parsed_result,
2559 __rte_unused struct cmdline *cl,
2560 __rte_unused void *data)
2562 struct cmd_config_rxtx_queue *res = parsed_result;
2567 if (test_done == 0) {
2568 printf("Please stop forwarding first\n");
2572 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2575 if (port_is_started(res->portid) != 1) {
2576 printf("Please start port %u first\n", res->portid);
2580 if (!strcmp(res->rxtxq, "rxq"))
2582 else if (!strcmp(res->rxtxq, "txq"))
2585 printf("Unknown parameter\n");
2589 if (isrx && rx_queue_id_is_invalid(res->qid))
2591 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2594 if (!strcmp(res->opname, "start"))
2596 else if (!strcmp(res->opname, "stop"))
2599 printf("Unknown parameter\n");
2603 if (isstart && isrx)
2604 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2605 else if (!isstart && isrx)
2606 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2607 else if (isstart && !isrx)
2608 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2610 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2612 if (ret == -ENOTSUP)
2613 printf("Function not supported in PMD driver\n");
2616 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2617 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2618 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2619 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, RTE_UINT16);
2620 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2621 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2622 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2623 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, RTE_UINT16);
2624 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2625 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2628 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2629 .f = cmd_config_rxtx_queue_parsed,
2631 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2633 (void *)&cmd_config_rxtx_queue_port,
2634 (void *)&cmd_config_rxtx_queue_portid,
2635 (void *)&cmd_config_rxtx_queue_rxtxq,
2636 (void *)&cmd_config_rxtx_queue_qid,
2637 (void *)&cmd_config_rxtx_queue_opname,
2642 /* *** configure port rxq/txq deferred start on/off *** */
2643 struct cmd_config_deferred_start_rxtx_queue {
2644 cmdline_fixed_string_t port;
2646 cmdline_fixed_string_t rxtxq;
2648 cmdline_fixed_string_t opname;
2649 cmdline_fixed_string_t state;
2653 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2654 __rte_unused struct cmdline *cl,
2655 __rte_unused void *data)
2657 struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2658 struct rte_port *port;
2661 uint8_t needreconfig = 0;
2663 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2666 if (port_is_started(res->port_id) != 0) {
2667 printf("Please stop port %u first\n", res->port_id);
2671 port = &ports[res->port_id];
2673 isrx = !strcmp(res->rxtxq, "rxq");
2675 if (isrx && rx_queue_id_is_invalid(res->qid))
2677 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2680 ison = !strcmp(res->state, "on");
2682 if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) {
2683 port->rx_conf[res->qid].rx_deferred_start = ison;
2685 } else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) {
2686 port->tx_conf[res->qid].tx_deferred_start = ison;
2691 cmd_reconfig_device_queue(res->port_id, 0, 1);
2694 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2695 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2697 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2698 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2699 port_id, RTE_UINT16);
2700 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2701 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2703 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2704 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2706 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2707 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2708 opname, "deferred_start");
2709 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2710 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2713 cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
2714 .f = cmd_config_deferred_start_rxtx_queue_parsed,
2716 .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
2718 (void *)&cmd_config_deferred_start_rxtx_queue_port,
2719 (void *)&cmd_config_deferred_start_rxtx_queue_port_id,
2720 (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
2721 (void *)&cmd_config_deferred_start_rxtx_queue_qid,
2722 (void *)&cmd_config_deferred_start_rxtx_queue_opname,
2723 (void *)&cmd_config_deferred_start_rxtx_queue_state,
2728 /* *** configure port rxq/txq setup *** */
2729 struct cmd_setup_rxtx_queue {
2730 cmdline_fixed_string_t port;
2732 cmdline_fixed_string_t rxtxq;
2734 cmdline_fixed_string_t setup;
2737 /* Common CLI fields for queue setup */
2738 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2739 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2740 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2741 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, RTE_UINT16);
2742 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2743 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2744 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2745 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, RTE_UINT16);
2746 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2747 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2750 cmd_setup_rxtx_queue_parsed(
2751 void *parsed_result,
2752 __rte_unused struct cmdline *cl,
2753 __rte_unused void *data)
2755 struct cmd_setup_rxtx_queue *res = parsed_result;
2756 struct rte_port *port;
2757 struct rte_mempool *mp;
2758 unsigned int socket_id;
2762 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2765 if (res->portid == (portid_t)RTE_PORT_ALL) {
2766 printf("Invalid port id\n");
2770 if (!strcmp(res->rxtxq, "rxq"))
2772 else if (!strcmp(res->rxtxq, "txq"))
2775 printf("Unknown parameter\n");
2779 if (isrx && rx_queue_id_is_invalid(res->qid)) {
2780 printf("Invalid rx queue\n");
2782 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2783 printf("Invalid tx queue\n");
2787 port = &ports[res->portid];
2789 socket_id = rxring_numa[res->portid];
2790 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2791 socket_id = port->socket_id;
2793 mp = mbuf_pool_find(socket_id, 0);
2795 printf("Failed to setup RX queue: "
2796 "No mempool allocation"
2797 " on the socket %d\n",
2798 rxring_numa[res->portid]);
2801 ret = rx_queue_setup(res->portid,
2803 port->nb_rx_desc[res->qid],
2805 &port->rx_conf[res->qid],
2808 printf("Failed to setup RX queue\n");
2810 socket_id = txring_numa[res->portid];
2811 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2812 socket_id = port->socket_id;
2814 ret = rte_eth_tx_queue_setup(res->portid,
2816 port->nb_tx_desc[res->qid],
2818 &port->tx_conf[res->qid]);
2820 printf("Failed to setup TX queue\n");
2824 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2825 .f = cmd_setup_rxtx_queue_parsed,
2827 .help_str = "port <port_id> rxq|txq <queue_idx> setup",
2829 (void *)&cmd_setup_rxtx_queue_port,
2830 (void *)&cmd_setup_rxtx_queue_portid,
2831 (void *)&cmd_setup_rxtx_queue_rxtxq,
2832 (void *)&cmd_setup_rxtx_queue_qid,
2833 (void *)&cmd_setup_rxtx_queue_setup,
2839 /* *** Configure RSS RETA *** */
2840 struct cmd_config_rss_reta {
2841 cmdline_fixed_string_t port;
2842 cmdline_fixed_string_t keyword;
2844 cmdline_fixed_string_t name;
2845 cmdline_fixed_string_t list_name;
2846 cmdline_fixed_string_t list_of_items;
2850 parse_reta_config(const char *str,
2851 struct rte_eth_rss_reta_entry64 *reta_conf,
2852 uint16_t nb_entries)
2856 uint16_t hash_index, idx, shift;
2859 const char *p, *p0 = str;
2866 unsigned long int_fld[_NUM_FLD];
2867 char *str_fld[_NUM_FLD];
2869 while ((p = strchr(p0,'(')) != NULL) {
2871 if((p0 = strchr(p,')')) == NULL)
2875 if(size >= sizeof(s))
2878 snprintf(s, sizeof(s), "%.*s", size, p);
2879 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2881 for (i = 0; i < _NUM_FLD; i++) {
2883 int_fld[i] = strtoul(str_fld[i], &end, 0);
2884 if (errno != 0 || end == str_fld[i] ||
2889 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2890 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2892 if (hash_index >= nb_entries) {
2893 printf("Invalid RETA hash index=%d\n", hash_index);
2897 idx = hash_index / RTE_RETA_GROUP_SIZE;
2898 shift = hash_index % RTE_RETA_GROUP_SIZE;
2899 reta_conf[idx].mask |= (1ULL << shift);
2900 reta_conf[idx].reta[shift] = nb_queue;
2907 cmd_set_rss_reta_parsed(void *parsed_result,
2908 __rte_unused struct cmdline *cl,
2909 __rte_unused void *data)
2912 struct rte_eth_dev_info dev_info;
2913 struct rte_eth_rss_reta_entry64 reta_conf[8];
2914 struct cmd_config_rss_reta *res = parsed_result;
2916 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2920 if (dev_info.reta_size == 0) {
2921 printf("Redirection table size is 0 which is "
2922 "invalid for RSS\n");
2925 printf("The reta size of port %d is %u\n",
2926 res->port_id, dev_info.reta_size);
2927 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2928 printf("Currently do not support more than %u entries of "
2929 "redirection table\n", ETH_RSS_RETA_SIZE_512);
2933 memset(reta_conf, 0, sizeof(reta_conf));
2934 if (!strcmp(res->list_name, "reta")) {
2935 if (parse_reta_config(res->list_of_items, reta_conf,
2936 dev_info.reta_size)) {
2937 printf("Invalid RSS Redirection Table "
2938 "config entered\n");
2941 ret = rte_eth_dev_rss_reta_update(res->port_id,
2942 reta_conf, dev_info.reta_size);
2944 printf("Bad redirection table parameter, "
2945 "return code = %d \n", ret);
2949 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2950 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2951 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2952 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2953 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2954 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, RTE_UINT16);
2955 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2956 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2957 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2958 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2959 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2960 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2962 cmdline_parse_inst_t cmd_config_rss_reta = {
2963 .f = cmd_set_rss_reta_parsed,
2965 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2967 (void *)&cmd_config_rss_reta_port,
2968 (void *)&cmd_config_rss_reta_keyword,
2969 (void *)&cmd_config_rss_reta_port_id,
2970 (void *)&cmd_config_rss_reta_name,
2971 (void *)&cmd_config_rss_reta_list_name,
2972 (void *)&cmd_config_rss_reta_list_of_items,
2977 /* *** SHOW PORT RETA INFO *** */
2978 struct cmd_showport_reta {
2979 cmdline_fixed_string_t show;
2980 cmdline_fixed_string_t port;
2982 cmdline_fixed_string_t rss;
2983 cmdline_fixed_string_t reta;
2985 cmdline_fixed_string_t list_of_items;
2989 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2990 uint16_t nb_entries,
2994 const char *p, *p0 = str;
2999 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
3000 RTE_RETA_GROUP_SIZE;
3003 p = strchr(p0, '(');
3007 p0 = strchr(p, ')');
3011 if (size >= sizeof(s)) {
3012 printf("The string size exceeds the internal buffer size\n");
3015 snprintf(s, sizeof(s), "%.*s", size, p);
3016 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
3017 if (ret <= 0 || ret != num) {
3018 printf("The bits of masks do not match the number of "
3019 "reta entries: %u\n", num);
3022 for (i = 0; i < ret; i++)
3023 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
3029 cmd_showport_reta_parsed(void *parsed_result,
3030 __rte_unused struct cmdline *cl,
3031 __rte_unused void *data)
3033 struct cmd_showport_reta *res = parsed_result;
3034 struct rte_eth_rss_reta_entry64 reta_conf[8];
3035 struct rte_eth_dev_info dev_info;
3036 uint16_t max_reta_size;
3039 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3043 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
3044 if (res->size == 0 || res->size > max_reta_size) {
3045 printf("Invalid redirection table size: %u (1-%u)\n",
3046 res->size, max_reta_size);
3050 memset(reta_conf, 0, sizeof(reta_conf));
3051 if (showport_parse_reta_config(reta_conf, res->size,
3052 res->list_of_items) < 0) {
3053 printf("Invalid string: %s for reta masks\n",
3054 res->list_of_items);
3057 port_rss_reta_info(res->port_id, reta_conf, res->size);
3060 cmdline_parse_token_string_t cmd_showport_reta_show =
3061 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
3062 cmdline_parse_token_string_t cmd_showport_reta_port =
3063 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
3064 cmdline_parse_token_num_t cmd_showport_reta_port_id =
3065 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, RTE_UINT16);
3066 cmdline_parse_token_string_t cmd_showport_reta_rss =
3067 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
3068 cmdline_parse_token_string_t cmd_showport_reta_reta =
3069 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
3070 cmdline_parse_token_num_t cmd_showport_reta_size =
3071 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, RTE_UINT16);
3072 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
3073 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
3074 list_of_items, NULL);
3076 cmdline_parse_inst_t cmd_showport_reta = {
3077 .f = cmd_showport_reta_parsed,
3079 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
3081 (void *)&cmd_showport_reta_show,
3082 (void *)&cmd_showport_reta_port,
3083 (void *)&cmd_showport_reta_port_id,
3084 (void *)&cmd_showport_reta_rss,
3085 (void *)&cmd_showport_reta_reta,
3086 (void *)&cmd_showport_reta_size,
3087 (void *)&cmd_showport_reta_list_of_items,
3092 /* *** Show RSS hash configuration *** */
3093 struct cmd_showport_rss_hash {
3094 cmdline_fixed_string_t show;
3095 cmdline_fixed_string_t port;
3097 cmdline_fixed_string_t rss_hash;
3098 cmdline_fixed_string_t rss_type;
3099 cmdline_fixed_string_t key; /* optional argument */
3102 static void cmd_showport_rss_hash_parsed(void *parsed_result,
3103 __rte_unused struct cmdline *cl,
3106 struct cmd_showport_rss_hash *res = parsed_result;
3108 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
3111 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
3112 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
3113 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
3114 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
3115 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
3116 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id,
3118 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
3119 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
3121 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
3122 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
3124 cmdline_parse_inst_t cmd_showport_rss_hash = {
3125 .f = cmd_showport_rss_hash_parsed,
3127 .help_str = "show port <port_id> rss-hash",
3129 (void *)&cmd_showport_rss_hash_show,
3130 (void *)&cmd_showport_rss_hash_port,
3131 (void *)&cmd_showport_rss_hash_port_id,
3132 (void *)&cmd_showport_rss_hash_rss_hash,
3137 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
3138 .f = cmd_showport_rss_hash_parsed,
3140 .help_str = "show port <port_id> rss-hash key",
3142 (void *)&cmd_showport_rss_hash_show,
3143 (void *)&cmd_showport_rss_hash_port,
3144 (void *)&cmd_showport_rss_hash_port_id,
3145 (void *)&cmd_showport_rss_hash_rss_hash,
3146 (void *)&cmd_showport_rss_hash_rss_key,
3151 /* *** Configure DCB *** */
3152 struct cmd_config_dcb {
3153 cmdline_fixed_string_t port;
3154 cmdline_fixed_string_t config;
3156 cmdline_fixed_string_t dcb;
3157 cmdline_fixed_string_t vt;
3158 cmdline_fixed_string_t vt_en;
3160 cmdline_fixed_string_t pfc;
3161 cmdline_fixed_string_t pfc_en;
3165 cmd_config_dcb_parsed(void *parsed_result,
3166 __rte_unused struct cmdline *cl,
3167 __rte_unused void *data)
3169 struct cmd_config_dcb *res = parsed_result;
3170 portid_t port_id = res->port_id;
3171 struct rte_port *port;
3175 port = &ports[port_id];
3176 /** Check if the port is not started **/
3177 if (port->port_status != RTE_PORT_STOPPED) {
3178 printf("Please stop port %d first\n", port_id);
3182 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
3183 printf("The invalid number of traffic class,"
3184 " only 4 or 8 allowed.\n");
3188 if (nb_fwd_lcores < res->num_tcs) {
3189 printf("nb_cores shouldn't be less than number of TCs.\n");
3192 if (!strncmp(res->pfc_en, "on", 2))
3197 /* DCB in VT mode */
3198 if (!strncmp(res->vt_en, "on", 2))
3199 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3200 (enum rte_eth_nb_tcs)res->num_tcs,
3203 ret = init_port_dcb_config(port_id, DCB_ENABLED,
3204 (enum rte_eth_nb_tcs)res->num_tcs,
3209 printf("Cannot initialize network ports.\n");
3213 cmd_reconfig_device_queue(port_id, 1, 1);
3216 cmdline_parse_token_string_t cmd_config_dcb_port =
3217 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3218 cmdline_parse_token_string_t cmd_config_dcb_config =
3219 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3220 cmdline_parse_token_num_t cmd_config_dcb_port_id =
3221 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, RTE_UINT16);
3222 cmdline_parse_token_string_t cmd_config_dcb_dcb =
3223 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3224 cmdline_parse_token_string_t cmd_config_dcb_vt =
3225 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3226 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3227 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3228 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3229 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, RTE_UINT8);
3230 cmdline_parse_token_string_t cmd_config_dcb_pfc=
3231 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3232 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
3233 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
3235 cmdline_parse_inst_t cmd_config_dcb = {
3236 .f = cmd_config_dcb_parsed,
3238 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
3240 (void *)&cmd_config_dcb_port,
3241 (void *)&cmd_config_dcb_config,
3242 (void *)&cmd_config_dcb_port_id,
3243 (void *)&cmd_config_dcb_dcb,
3244 (void *)&cmd_config_dcb_vt,
3245 (void *)&cmd_config_dcb_vt_en,
3246 (void *)&cmd_config_dcb_num_tcs,
3247 (void *)&cmd_config_dcb_pfc,
3248 (void *)&cmd_config_dcb_pfc_en,
3253 /* *** configure number of packets per burst *** */
3254 struct cmd_config_burst {
3255 cmdline_fixed_string_t port;
3256 cmdline_fixed_string_t keyword;
3257 cmdline_fixed_string_t all;
3258 cmdline_fixed_string_t name;
3263 cmd_config_burst_parsed(void *parsed_result,
3264 __rte_unused struct cmdline *cl,
3265 __rte_unused void *data)
3267 struct cmd_config_burst *res = parsed_result;
3268 struct rte_eth_dev_info dev_info;
3269 uint16_t rec_nb_pkts;
3272 if (!all_ports_stopped()) {
3273 printf("Please stop all ports first\n");
3277 if (!strcmp(res->name, "burst")) {
3278 if (res->value == 0) {
3279 /* If user gives a value of zero, query the PMD for
3280 * its recommended Rx burst size. Testpmd uses a single
3281 * size for all ports, so assume all ports are the same
3282 * NIC model and use the values from Port 0.
3284 ret = eth_dev_info_get_print_err(0, &dev_info);
3288 rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3290 if (rec_nb_pkts == 0) {
3291 printf("PMD does not recommend a burst size.\n"
3292 "User provided value must be between"
3293 " 1 and %d\n", MAX_PKT_BURST);
3295 } else if (rec_nb_pkts > MAX_PKT_BURST) {
3296 printf("PMD recommended burst size of %d"
3297 " exceeds maximum value of %d\n",
3298 rec_nb_pkts, MAX_PKT_BURST);
3301 printf("Using PMD-provided burst value of %d\n",
3303 nb_pkt_per_burst = rec_nb_pkts;
3304 } else if (res->value > MAX_PKT_BURST) {
3305 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
3308 nb_pkt_per_burst = res->value;
3310 printf("Unknown parameter\n");
3316 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3319 cmdline_parse_token_string_t cmd_config_burst_port =
3320 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3321 cmdline_parse_token_string_t cmd_config_burst_keyword =
3322 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3323 cmdline_parse_token_string_t cmd_config_burst_all =
3324 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3325 cmdline_parse_token_string_t cmd_config_burst_name =
3326 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3327 cmdline_parse_token_num_t cmd_config_burst_value =
3328 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, RTE_UINT16);
3330 cmdline_parse_inst_t cmd_config_burst = {
3331 .f = cmd_config_burst_parsed,
3333 .help_str = "port config all burst <value>",
3335 (void *)&cmd_config_burst_port,
3336 (void *)&cmd_config_burst_keyword,
3337 (void *)&cmd_config_burst_all,
3338 (void *)&cmd_config_burst_name,
3339 (void *)&cmd_config_burst_value,
3344 /* *** configure rx/tx queues *** */
3345 struct cmd_config_thresh {
3346 cmdline_fixed_string_t port;
3347 cmdline_fixed_string_t keyword;
3348 cmdline_fixed_string_t all;
3349 cmdline_fixed_string_t name;
3354 cmd_config_thresh_parsed(void *parsed_result,
3355 __rte_unused struct cmdline *cl,
3356 __rte_unused void *data)
3358 struct cmd_config_thresh *res = parsed_result;
3360 if (!all_ports_stopped()) {
3361 printf("Please stop all ports first\n");
3365 if (!strcmp(res->name, "txpt"))
3366 tx_pthresh = res->value;
3367 else if(!strcmp(res->name, "txht"))
3368 tx_hthresh = res->value;
3369 else if(!strcmp(res->name, "txwt"))
3370 tx_wthresh = res->value;
3371 else if(!strcmp(res->name, "rxpt"))
3372 rx_pthresh = res->value;
3373 else if(!strcmp(res->name, "rxht"))
3374 rx_hthresh = res->value;
3375 else if(!strcmp(res->name, "rxwt"))
3376 rx_wthresh = res->value;
3378 printf("Unknown parameter\n");
3384 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3387 cmdline_parse_token_string_t cmd_config_thresh_port =
3388 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3389 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3390 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3391 cmdline_parse_token_string_t cmd_config_thresh_all =
3392 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3393 cmdline_parse_token_string_t cmd_config_thresh_name =
3394 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3395 "txpt#txht#txwt#rxpt#rxht#rxwt");
3396 cmdline_parse_token_num_t cmd_config_thresh_value =
3397 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, RTE_UINT8);
3399 cmdline_parse_inst_t cmd_config_thresh = {
3400 .f = cmd_config_thresh_parsed,
3402 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3404 (void *)&cmd_config_thresh_port,
3405 (void *)&cmd_config_thresh_keyword,
3406 (void *)&cmd_config_thresh_all,
3407 (void *)&cmd_config_thresh_name,
3408 (void *)&cmd_config_thresh_value,
3413 /* *** configure free/rs threshold *** */
3414 struct cmd_config_threshold {
3415 cmdline_fixed_string_t port;
3416 cmdline_fixed_string_t keyword;
3417 cmdline_fixed_string_t all;
3418 cmdline_fixed_string_t name;
3423 cmd_config_threshold_parsed(void *parsed_result,
3424 __rte_unused struct cmdline *cl,
3425 __rte_unused void *data)
3427 struct cmd_config_threshold *res = parsed_result;
3429 if (!all_ports_stopped()) {
3430 printf("Please stop all ports first\n");
3434 if (!strcmp(res->name, "txfreet"))
3435 tx_free_thresh = res->value;
3436 else if (!strcmp(res->name, "txrst"))
3437 tx_rs_thresh = res->value;
3438 else if (!strcmp(res->name, "rxfreet"))
3439 rx_free_thresh = res->value;
3441 printf("Unknown parameter\n");
3447 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3450 cmdline_parse_token_string_t cmd_config_threshold_port =
3451 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3452 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3453 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3455 cmdline_parse_token_string_t cmd_config_threshold_all =
3456 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3457 cmdline_parse_token_string_t cmd_config_threshold_name =
3458 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3459 "txfreet#txrst#rxfreet");
3460 cmdline_parse_token_num_t cmd_config_threshold_value =
3461 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, RTE_UINT16);
3463 cmdline_parse_inst_t cmd_config_threshold = {
3464 .f = cmd_config_threshold_parsed,
3466 .help_str = "port config all txfreet|txrst|rxfreet <value>",
3468 (void *)&cmd_config_threshold_port,
3469 (void *)&cmd_config_threshold_keyword,
3470 (void *)&cmd_config_threshold_all,
3471 (void *)&cmd_config_threshold_name,
3472 (void *)&cmd_config_threshold_value,
3478 struct cmd_stop_result {
3479 cmdline_fixed_string_t stop;
3482 static void cmd_stop_parsed(__rte_unused void *parsed_result,
3483 __rte_unused struct cmdline *cl,
3484 __rte_unused void *data)
3486 stop_packet_forwarding();
3489 cmdline_parse_token_string_t cmd_stop_stop =
3490 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3492 cmdline_parse_inst_t cmd_stop = {
3493 .f = cmd_stop_parsed,
3495 .help_str = "stop: Stop packet forwarding",
3497 (void *)&cmd_stop_stop,
3502 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3505 parse_item_list(char* str, const char* item_name, unsigned int max_items,
3506 unsigned int *parsed_items, int check_unique_values)
3508 unsigned int nb_item;
3516 * First parse all items in the list and store their value.
3521 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3523 if ((c >= '0') && (c <= '9')) {
3524 value = (unsigned int) (value * 10 + (c - '0'));
3529 printf("character %c is not a decimal digit\n", c);
3533 printf("No valid value before comma\n");
3536 if (nb_item < max_items) {
3537 parsed_items[nb_item] = value;
3543 if (nb_item >= max_items) {
3544 printf("Number of %s = %u > %u (maximum items)\n",
3545 item_name, nb_item + 1, max_items);
3548 parsed_items[nb_item++] = value;
3549 if (! check_unique_values)
3553 * Then, check that all values in the list are differents.
3554 * No optimization here...
3556 for (i = 0; i < nb_item; i++) {
3557 for (j = i + 1; j < nb_item; j++) {
3558 if (parsed_items[j] == parsed_items[i]) {
3559 printf("duplicated %s %u at index %u and %u\n",
3560 item_name, parsed_items[i], i, j);
3568 struct cmd_set_list_result {
3569 cmdline_fixed_string_t cmd_keyword;
3570 cmdline_fixed_string_t list_name;
3571 cmdline_fixed_string_t list_of_items;
3574 static void cmd_set_list_parsed(void *parsed_result,
3575 __rte_unused struct cmdline *cl,
3576 __rte_unused void *data)
3578 struct cmd_set_list_result *res;
3580 unsigned int lcorelist[RTE_MAX_LCORE];
3581 unsigned int portlist[RTE_MAX_ETHPORTS];
3583 unsigned int nb_item;
3585 if (test_done == 0) {
3586 printf("Please stop forwarding first\n");
3590 res = parsed_result;
3591 if (!strcmp(res->list_name, "corelist")) {
3592 nb_item = parse_item_list(res->list_of_items, "core",
3594 parsed_items.lcorelist, 1);
3596 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3601 if (!strcmp(res->list_name, "portlist")) {
3602 nb_item = parse_item_list(res->list_of_items, "port",
3604 parsed_items.portlist, 1);
3606 set_fwd_ports_list(parsed_items.portlist, nb_item);
3612 cmdline_parse_token_string_t cmd_set_list_keyword =
3613 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3615 cmdline_parse_token_string_t cmd_set_list_name =
3616 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3617 "corelist#portlist");
3618 cmdline_parse_token_string_t cmd_set_list_of_items =
3619 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3622 cmdline_parse_inst_t cmd_set_fwd_list = {
3623 .f = cmd_set_list_parsed,
3625 .help_str = "set corelist|portlist <list0[,list1]*>",
3627 (void *)&cmd_set_list_keyword,
3628 (void *)&cmd_set_list_name,
3629 (void *)&cmd_set_list_of_items,
3634 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3636 struct cmd_setmask_result {
3637 cmdline_fixed_string_t set;
3638 cmdline_fixed_string_t mask;
3642 static void cmd_set_mask_parsed(void *parsed_result,
3643 __rte_unused struct cmdline *cl,
3644 __rte_unused void *data)
3646 struct cmd_setmask_result *res = parsed_result;
3648 if (test_done == 0) {
3649 printf("Please stop forwarding first\n");
3652 if (!strcmp(res->mask, "coremask")) {
3653 set_fwd_lcores_mask(res->hexavalue);
3655 } else if (!strcmp(res->mask, "portmask")) {
3656 set_fwd_ports_mask(res->hexavalue);
3661 cmdline_parse_token_string_t cmd_setmask_set =
3662 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3663 cmdline_parse_token_string_t cmd_setmask_mask =
3664 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3665 "coremask#portmask");
3666 cmdline_parse_token_num_t cmd_setmask_value =
3667 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, RTE_UINT64);
3669 cmdline_parse_inst_t cmd_set_fwd_mask = {
3670 .f = cmd_set_mask_parsed,
3672 .help_str = "set coremask|portmask <hexadecimal value>",
3674 (void *)&cmd_setmask_set,
3675 (void *)&cmd_setmask_mask,
3676 (void *)&cmd_setmask_value,
3682 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3684 struct cmd_set_result {
3685 cmdline_fixed_string_t set;
3686 cmdline_fixed_string_t what;
3690 static void cmd_set_parsed(void *parsed_result,
3691 __rte_unused struct cmdline *cl,
3692 __rte_unused void *data)
3694 struct cmd_set_result *res = parsed_result;
3695 if (!strcmp(res->what, "nbport")) {
3696 set_fwd_ports_number(res->value);
3698 } else if (!strcmp(res->what, "nbcore")) {
3699 set_fwd_lcores_number(res->value);
3701 } else if (!strcmp(res->what, "burst"))
3702 set_nb_pkt_per_burst(res->value);
3703 else if (!strcmp(res->what, "verbose"))
3704 set_verbose_level(res->value);
3707 cmdline_parse_token_string_t cmd_set_set =
3708 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3709 cmdline_parse_token_string_t cmd_set_what =
3710 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3711 "nbport#nbcore#burst#verbose");
3712 cmdline_parse_token_num_t cmd_set_value =
3713 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, RTE_UINT16);
3715 cmdline_parse_inst_t cmd_set_numbers = {
3716 .f = cmd_set_parsed,
3718 .help_str = "set nbport|nbcore|burst|verbose <value>",
3720 (void *)&cmd_set_set,
3721 (void *)&cmd_set_what,
3722 (void *)&cmd_set_value,
3727 /* *** SET LOG LEVEL CONFIGURATION *** */
3729 struct cmd_set_log_result {
3730 cmdline_fixed_string_t set;
3731 cmdline_fixed_string_t log;
3732 cmdline_fixed_string_t type;
3737 cmd_set_log_parsed(void *parsed_result,
3738 __rte_unused struct cmdline *cl,
3739 __rte_unused void *data)
3741 struct cmd_set_log_result *res;
3744 res = parsed_result;
3745 if (!strcmp(res->type, "global"))
3746 rte_log_set_global_level(res->level);
3748 ret = rte_log_set_level_regexp(res->type, res->level);
3750 printf("Unable to set log level\n");
3754 cmdline_parse_token_string_t cmd_set_log_set =
3755 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3756 cmdline_parse_token_string_t cmd_set_log_log =
3757 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3758 cmdline_parse_token_string_t cmd_set_log_type =
3759 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3760 cmdline_parse_token_num_t cmd_set_log_level =
3761 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, RTE_UINT32);
3763 cmdline_parse_inst_t cmd_set_log = {
3764 .f = cmd_set_log_parsed,
3766 .help_str = "set log global|<type> <level>",
3768 (void *)&cmd_set_log_set,
3769 (void *)&cmd_set_log_log,
3770 (void *)&cmd_set_log_type,
3771 (void *)&cmd_set_log_level,
3776 /* *** SET SEGMENT OFFSETS OF RX PACKETS SPLIT *** */
3778 struct cmd_set_rxoffs_result {
3779 cmdline_fixed_string_t cmd_keyword;
3780 cmdline_fixed_string_t rxoffs;
3781 cmdline_fixed_string_t seg_offsets;
3785 cmd_set_rxoffs_parsed(void *parsed_result,
3786 __rte_unused struct cmdline *cl,
3787 __rte_unused void *data)
3789 struct cmd_set_rxoffs_result *res;
3790 unsigned int seg_offsets[MAX_SEGS_BUFFER_SPLIT];
3791 unsigned int nb_segs;
3793 res = parsed_result;
3794 nb_segs = parse_item_list(res->seg_offsets, "segment offsets",
3795 MAX_SEGS_BUFFER_SPLIT, seg_offsets, 0);
3797 set_rx_pkt_offsets(seg_offsets, nb_segs);
3798 cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
3801 cmdline_parse_token_string_t cmd_set_rxoffs_keyword =
3802 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3803 cmd_keyword, "set");
3804 cmdline_parse_token_string_t cmd_set_rxoffs_name =
3805 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3807 cmdline_parse_token_string_t cmd_set_rxoffs_offsets =
3808 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3811 cmdline_parse_inst_t cmd_set_rxoffs = {
3812 .f = cmd_set_rxoffs_parsed,
3814 .help_str = "set rxoffs <len0[,len1]*>",
3816 (void *)&cmd_set_rxoffs_keyword,
3817 (void *)&cmd_set_rxoffs_name,
3818 (void *)&cmd_set_rxoffs_offsets,
3823 /* *** SET SEGMENT LENGTHS OF RX PACKETS SPLIT *** */
3825 struct cmd_set_rxpkts_result {
3826 cmdline_fixed_string_t cmd_keyword;
3827 cmdline_fixed_string_t rxpkts;
3828 cmdline_fixed_string_t seg_lengths;
3832 cmd_set_rxpkts_parsed(void *parsed_result,
3833 __rte_unused struct cmdline *cl,
3834 __rte_unused void *data)
3836 struct cmd_set_rxpkts_result *res;
3837 unsigned int seg_lengths[MAX_SEGS_BUFFER_SPLIT];
3838 unsigned int nb_segs;
3840 res = parsed_result;
3841 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3842 MAX_SEGS_BUFFER_SPLIT, seg_lengths, 0);
3844 set_rx_pkt_segments(seg_lengths, nb_segs);
3845 cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
3848 cmdline_parse_token_string_t cmd_set_rxpkts_keyword =
3849 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3850 cmd_keyword, "set");
3851 cmdline_parse_token_string_t cmd_set_rxpkts_name =
3852 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3854 cmdline_parse_token_string_t cmd_set_rxpkts_lengths =
3855 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3858 cmdline_parse_inst_t cmd_set_rxpkts = {
3859 .f = cmd_set_rxpkts_parsed,
3861 .help_str = "set rxpkts <len0[,len1]*>",
3863 (void *)&cmd_set_rxpkts_keyword,
3864 (void *)&cmd_set_rxpkts_name,
3865 (void *)&cmd_set_rxpkts_lengths,
3870 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3872 struct cmd_set_txpkts_result {
3873 cmdline_fixed_string_t cmd_keyword;
3874 cmdline_fixed_string_t txpkts;
3875 cmdline_fixed_string_t seg_lengths;
3879 cmd_set_txpkts_parsed(void *parsed_result,
3880 __rte_unused struct cmdline *cl,
3881 __rte_unused void *data)
3883 struct cmd_set_txpkts_result *res;
3884 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3885 unsigned int nb_segs;
3887 res = parsed_result;
3888 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3889 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3891 set_tx_pkt_segments(seg_lengths, nb_segs);
3894 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3895 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3896 cmd_keyword, "set");
3897 cmdline_parse_token_string_t cmd_set_txpkts_name =
3898 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3900 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3901 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3904 cmdline_parse_inst_t cmd_set_txpkts = {
3905 .f = cmd_set_txpkts_parsed,
3907 .help_str = "set txpkts <len0[,len1]*>",
3909 (void *)&cmd_set_txpkts_keyword,
3910 (void *)&cmd_set_txpkts_name,
3911 (void *)&cmd_set_txpkts_lengths,
3916 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
3918 struct cmd_set_txsplit_result {
3919 cmdline_fixed_string_t cmd_keyword;
3920 cmdline_fixed_string_t txsplit;
3921 cmdline_fixed_string_t mode;
3925 cmd_set_txsplit_parsed(void *parsed_result,
3926 __rte_unused struct cmdline *cl,
3927 __rte_unused void *data)
3929 struct cmd_set_txsplit_result *res;
3931 res = parsed_result;
3932 set_tx_pkt_split(res->mode);
3935 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
3936 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3937 cmd_keyword, "set");
3938 cmdline_parse_token_string_t cmd_set_txsplit_name =
3939 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3940 txsplit, "txsplit");
3941 cmdline_parse_token_string_t cmd_set_txsplit_mode =
3942 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3945 cmdline_parse_inst_t cmd_set_txsplit = {
3946 .f = cmd_set_txsplit_parsed,
3948 .help_str = "set txsplit on|off|rand",
3950 (void *)&cmd_set_txsplit_keyword,
3951 (void *)&cmd_set_txsplit_name,
3952 (void *)&cmd_set_txsplit_mode,
3957 /* *** SET TIMES FOR TXONLY PACKETS SCHEDULING ON TIMESTAMPS *** */
3959 struct cmd_set_txtimes_result {
3960 cmdline_fixed_string_t cmd_keyword;
3961 cmdline_fixed_string_t txtimes;
3962 cmdline_fixed_string_t tx_times;
3966 cmd_set_txtimes_parsed(void *parsed_result,
3967 __rte_unused struct cmdline *cl,
3968 __rte_unused void *data)
3970 struct cmd_set_txtimes_result *res;
3971 unsigned int tx_times[2] = {0, 0};
3972 unsigned int n_times;
3974 res = parsed_result;
3975 n_times = parse_item_list(res->tx_times, "tx times",
3978 set_tx_pkt_times(tx_times);
3981 cmdline_parse_token_string_t cmd_set_txtimes_keyword =
3982 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
3983 cmd_keyword, "set");
3984 cmdline_parse_token_string_t cmd_set_txtimes_name =
3985 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
3986 txtimes, "txtimes");
3987 cmdline_parse_token_string_t cmd_set_txtimes_value =
3988 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
3991 cmdline_parse_inst_t cmd_set_txtimes = {
3992 .f = cmd_set_txtimes_parsed,
3994 .help_str = "set txtimes <inter_burst>,<intra_burst>",
3996 (void *)&cmd_set_txtimes_keyword,
3997 (void *)&cmd_set_txtimes_name,
3998 (void *)&cmd_set_txtimes_value,
4003 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
4004 struct cmd_rx_vlan_filter_all_result {
4005 cmdline_fixed_string_t rx_vlan;
4006 cmdline_fixed_string_t what;
4007 cmdline_fixed_string_t all;
4012 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
4013 __rte_unused struct cmdline *cl,
4014 __rte_unused void *data)
4016 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
4018 if (!strcmp(res->what, "add"))
4019 rx_vlan_all_filter_set(res->port_id, 1);
4021 rx_vlan_all_filter_set(res->port_id, 0);
4024 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
4025 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4026 rx_vlan, "rx_vlan");
4027 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
4028 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4030 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
4031 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4033 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
4034 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4035 port_id, RTE_UINT16);
4037 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
4038 .f = cmd_rx_vlan_filter_all_parsed,
4040 .help_str = "rx_vlan add|rm all <port_id>: "
4041 "Add/Remove all identifiers to/from the set of VLAN "
4042 "identifiers filtered by a port",
4044 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
4045 (void *)&cmd_rx_vlan_filter_all_what,
4046 (void *)&cmd_rx_vlan_filter_all_all,
4047 (void *)&cmd_rx_vlan_filter_all_portid,
4052 /* *** VLAN OFFLOAD SET ON A PORT *** */
4053 struct cmd_vlan_offload_result {
4054 cmdline_fixed_string_t vlan;
4055 cmdline_fixed_string_t set;
4056 cmdline_fixed_string_t vlan_type;
4057 cmdline_fixed_string_t what;
4058 cmdline_fixed_string_t on;
4059 cmdline_fixed_string_t port_id;
4063 cmd_vlan_offload_parsed(void *parsed_result,
4064 __rte_unused struct cmdline *cl,
4065 __rte_unused void *data)
4068 struct cmd_vlan_offload_result *res = parsed_result;
4071 portid_t port_id = 0;
4075 len = strnlen(str, STR_TOKEN_SIZE);
4077 /* Get port_id first */
4085 tmp = strtoul(str, NULL, 0);
4086 /* If port_id greater that what portid_t can represent, return */
4087 if(tmp >= RTE_MAX_ETHPORTS)
4089 port_id = (portid_t)tmp;
4091 if (!strcmp(res->on, "on"))
4096 if (!strcmp(res->what, "strip"))
4097 rx_vlan_strip_set(port_id, on);
4098 else if(!strcmp(res->what, "stripq")){
4099 uint16_t queue_id = 0;
4101 /* No queue_id, return */
4103 printf("must specify (port,queue_id)\n");
4106 tmp = strtoul(str + i + 1, NULL, 0);
4107 /* If queue_id greater that what 16-bits can represent, return */
4111 queue_id = (uint16_t)tmp;
4112 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
4114 else if (!strcmp(res->what, "filter"))
4115 rx_vlan_filter_set(port_id, on);
4116 else if (!strcmp(res->what, "qinq_strip"))
4117 rx_vlan_qinq_strip_set(port_id, on);
4119 vlan_extend_set(port_id, on);
4124 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
4125 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4127 cmdline_parse_token_string_t cmd_vlan_offload_set =
4128 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4130 cmdline_parse_token_string_t cmd_vlan_offload_what =
4131 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4132 what, "strip#filter#qinq_strip#extend#stripq");
4133 cmdline_parse_token_string_t cmd_vlan_offload_on =
4134 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4136 cmdline_parse_token_string_t cmd_vlan_offload_portid =
4137 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4140 cmdline_parse_inst_t cmd_vlan_offload = {
4141 .f = cmd_vlan_offload_parsed,
4143 .help_str = "vlan set strip|filter|qinq_strip|extend|stripq on|off "
4144 "<port_id[,queue_id]>: "
4145 "Strip/Filter/QinQ for rx side Extend for both rx/tx sides",
4147 (void *)&cmd_vlan_offload_vlan,
4148 (void *)&cmd_vlan_offload_set,
4149 (void *)&cmd_vlan_offload_what,
4150 (void *)&cmd_vlan_offload_on,
4151 (void *)&cmd_vlan_offload_portid,
4156 /* *** VLAN TPID SET ON A PORT *** */
4157 struct cmd_vlan_tpid_result {
4158 cmdline_fixed_string_t vlan;
4159 cmdline_fixed_string_t set;
4160 cmdline_fixed_string_t vlan_type;
4161 cmdline_fixed_string_t what;
4167 cmd_vlan_tpid_parsed(void *parsed_result,
4168 __rte_unused struct cmdline *cl,
4169 __rte_unused void *data)
4171 struct cmd_vlan_tpid_result *res = parsed_result;
4172 enum rte_vlan_type vlan_type;
4174 if (!strcmp(res->vlan_type, "inner"))
4175 vlan_type = ETH_VLAN_TYPE_INNER;
4176 else if (!strcmp(res->vlan_type, "outer"))
4177 vlan_type = ETH_VLAN_TYPE_OUTER;
4179 printf("Unknown vlan type\n");
4182 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
4185 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
4186 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4188 cmdline_parse_token_string_t cmd_vlan_tpid_set =
4189 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4191 cmdline_parse_token_string_t cmd_vlan_type =
4192 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4193 vlan_type, "inner#outer");
4194 cmdline_parse_token_string_t cmd_vlan_tpid_what =
4195 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4197 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
4198 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4200 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
4201 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4202 port_id, RTE_UINT16);
4204 cmdline_parse_inst_t cmd_vlan_tpid = {
4205 .f = cmd_vlan_tpid_parsed,
4207 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
4208 "Set the VLAN Ether type",
4210 (void *)&cmd_vlan_tpid_vlan,
4211 (void *)&cmd_vlan_tpid_set,
4212 (void *)&cmd_vlan_type,
4213 (void *)&cmd_vlan_tpid_what,
4214 (void *)&cmd_vlan_tpid_tpid,
4215 (void *)&cmd_vlan_tpid_portid,
4220 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4221 struct cmd_rx_vlan_filter_result {
4222 cmdline_fixed_string_t rx_vlan;
4223 cmdline_fixed_string_t what;
4229 cmd_rx_vlan_filter_parsed(void *parsed_result,
4230 __rte_unused struct cmdline *cl,
4231 __rte_unused void *data)
4233 struct cmd_rx_vlan_filter_result *res = parsed_result;
4235 if (!strcmp(res->what, "add"))
4236 rx_vft_set(res->port_id, res->vlan_id, 1);
4238 rx_vft_set(res->port_id, res->vlan_id, 0);
4241 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
4242 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4243 rx_vlan, "rx_vlan");
4244 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
4245 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4247 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
4248 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4249 vlan_id, RTE_UINT16);
4250 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
4251 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4252 port_id, RTE_UINT16);
4254 cmdline_parse_inst_t cmd_rx_vlan_filter = {
4255 .f = cmd_rx_vlan_filter_parsed,
4257 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
4258 "Add/Remove a VLAN identifier to/from the set of VLAN "
4259 "identifiers filtered by a port",
4261 (void *)&cmd_rx_vlan_filter_rx_vlan,
4262 (void *)&cmd_rx_vlan_filter_what,
4263 (void *)&cmd_rx_vlan_filter_vlanid,
4264 (void *)&cmd_rx_vlan_filter_portid,
4269 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4270 struct cmd_tx_vlan_set_result {
4271 cmdline_fixed_string_t tx_vlan;
4272 cmdline_fixed_string_t set;
4278 cmd_tx_vlan_set_parsed(void *parsed_result,
4279 __rte_unused struct cmdline *cl,
4280 __rte_unused void *data)
4282 struct cmd_tx_vlan_set_result *res = parsed_result;
4284 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4287 if (!port_is_stopped(res->port_id)) {
4288 printf("Please stop port %d first\n", res->port_id);
4292 tx_vlan_set(res->port_id, res->vlan_id);
4294 cmd_reconfig_device_queue(res->port_id, 1, 1);
4297 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4298 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4299 tx_vlan, "tx_vlan");
4300 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4301 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4303 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4304 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4305 port_id, RTE_UINT16);
4306 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
4307 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4308 vlan_id, RTE_UINT16);
4310 cmdline_parse_inst_t cmd_tx_vlan_set = {
4311 .f = cmd_tx_vlan_set_parsed,
4313 .help_str = "tx_vlan set <port_id> <vlan_id>: "
4314 "Enable hardware insertion of a single VLAN header "
4315 "with a given TAG Identifier in packets sent on a port",
4317 (void *)&cmd_tx_vlan_set_tx_vlan,
4318 (void *)&cmd_tx_vlan_set_set,
4319 (void *)&cmd_tx_vlan_set_portid,
4320 (void *)&cmd_tx_vlan_set_vlanid,
4325 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4326 struct cmd_tx_vlan_set_qinq_result {
4327 cmdline_fixed_string_t tx_vlan;
4328 cmdline_fixed_string_t set;
4331 uint16_t vlan_id_outer;
4335 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4336 __rte_unused struct cmdline *cl,
4337 __rte_unused void *data)
4339 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
4341 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4344 if (!port_is_stopped(res->port_id)) {
4345 printf("Please stop port %d first\n", res->port_id);
4349 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
4351 cmd_reconfig_device_queue(res->port_id, 1, 1);
4354 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
4355 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4356 tx_vlan, "tx_vlan");
4357 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
4358 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4360 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
4361 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4362 port_id, RTE_UINT16);
4363 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
4364 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4365 vlan_id, RTE_UINT16);
4366 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
4367 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4368 vlan_id_outer, RTE_UINT16);
4370 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
4371 .f = cmd_tx_vlan_set_qinq_parsed,
4373 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
4374 "Enable hardware insertion of double VLAN header "
4375 "with given TAG Identifiers in packets sent on a port",
4377 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
4378 (void *)&cmd_tx_vlan_set_qinq_set,
4379 (void *)&cmd_tx_vlan_set_qinq_portid,
4380 (void *)&cmd_tx_vlan_set_qinq_vlanid,
4381 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
4386 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
4387 struct cmd_tx_vlan_set_pvid_result {
4388 cmdline_fixed_string_t tx_vlan;
4389 cmdline_fixed_string_t set;
4390 cmdline_fixed_string_t pvid;
4393 cmdline_fixed_string_t mode;
4397 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
4398 __rte_unused struct cmdline *cl,
4399 __rte_unused void *data)
4401 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
4403 if (strcmp(res->mode, "on") == 0)
4404 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
4406 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
4409 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
4410 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4411 tx_vlan, "tx_vlan");
4412 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
4413 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4415 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
4416 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4418 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
4419 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4420 port_id, RTE_UINT16);
4421 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
4422 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4423 vlan_id, RTE_UINT16);
4424 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
4425 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4428 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
4429 .f = cmd_tx_vlan_set_pvid_parsed,
4431 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
4433 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
4434 (void *)&cmd_tx_vlan_set_pvid_set,
4435 (void *)&cmd_tx_vlan_set_pvid_pvid,
4436 (void *)&cmd_tx_vlan_set_pvid_port_id,
4437 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
4438 (void *)&cmd_tx_vlan_set_pvid_mode,
4443 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4444 struct cmd_tx_vlan_reset_result {
4445 cmdline_fixed_string_t tx_vlan;
4446 cmdline_fixed_string_t reset;
4451 cmd_tx_vlan_reset_parsed(void *parsed_result,
4452 __rte_unused struct cmdline *cl,
4453 __rte_unused void *data)
4455 struct cmd_tx_vlan_reset_result *res = parsed_result;
4457 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4460 if (!port_is_stopped(res->port_id)) {
4461 printf("Please stop port %d first\n", res->port_id);
4465 tx_vlan_reset(res->port_id);
4467 cmd_reconfig_device_queue(res->port_id, 1, 1);
4470 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4471 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4472 tx_vlan, "tx_vlan");
4473 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4474 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4476 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4477 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4478 port_id, RTE_UINT16);
4480 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4481 .f = cmd_tx_vlan_reset_parsed,
4483 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4484 "VLAN header in packets sent on a port",
4486 (void *)&cmd_tx_vlan_reset_tx_vlan,
4487 (void *)&cmd_tx_vlan_reset_reset,
4488 (void *)&cmd_tx_vlan_reset_portid,
4494 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4495 struct cmd_csum_result {
4496 cmdline_fixed_string_t csum;
4497 cmdline_fixed_string_t mode;
4498 cmdline_fixed_string_t proto;
4499 cmdline_fixed_string_t hwsw;
4504 csum_show(int port_id)
4506 struct rte_eth_dev_info dev_info;
4507 uint64_t tx_offloads;
4510 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4511 printf("Parse tunnel is %s\n",
4512 (ports[port_id].parse_tunnel) ? "on" : "off");
4513 printf("IP checksum offload is %s\n",
4514 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4515 printf("UDP checksum offload is %s\n",
4516 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4517 printf("TCP checksum offload is %s\n",
4518 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4519 printf("SCTP checksum offload is %s\n",
4520 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4521 printf("Outer-Ip checksum offload is %s\n",
4522 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4523 printf("Outer-Udp checksum offload is %s\n",
4524 (tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
4526 /* display warnings if configuration is not supported by the NIC */
4527 ret = eth_dev_info_get_print_err(port_id, &dev_info);
4531 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
4532 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4533 printf("Warning: hardware IP checksum enabled but not "
4534 "supported by port %d\n", port_id);
4536 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
4537 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
4538 printf("Warning: hardware UDP checksum enabled but not "
4539 "supported by port %d\n", port_id);
4541 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
4542 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
4543 printf("Warning: hardware TCP checksum enabled but not "
4544 "supported by port %d\n", port_id);
4546 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
4547 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4548 printf("Warning: hardware SCTP checksum enabled but not "
4549 "supported by port %d\n", port_id);
4551 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4552 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4553 printf("Warning: hardware outer IP checksum enabled but not "
4554 "supported by port %d\n", port_id);
4556 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
4557 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)
4559 printf("Warning: hardware outer UDP checksum enabled but not "
4560 "supported by port %d\n", port_id);
4565 cmd_config_queue_tx_offloads(struct rte_port *port)
4569 /* Apply queue tx offloads configuration */
4570 for (k = 0; k < port->dev_info.max_rx_queues; k++)
4571 port->tx_conf[k].offloads =
4572 port->dev_conf.txmode.offloads;
4576 cmd_csum_parsed(void *parsed_result,
4577 __rte_unused struct cmdline *cl,
4578 __rte_unused void *data)
4580 struct cmd_csum_result *res = parsed_result;
4582 uint64_t csum_offloads = 0;
4583 struct rte_eth_dev_info dev_info;
4586 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4587 printf("invalid port %d\n", res->port_id);
4590 if (!port_is_stopped(res->port_id)) {
4591 printf("Please stop port %d first\n", res->port_id);
4595 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4599 if (!strcmp(res->mode, "set")) {
4601 if (!strcmp(res->hwsw, "hw"))
4604 if (!strcmp(res->proto, "ip")) {
4605 if (hw == 0 || (dev_info.tx_offload_capa &
4606 DEV_TX_OFFLOAD_IPV4_CKSUM)) {
4607 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
4609 printf("IP checksum offload is not supported "
4610 "by port %u\n", res->port_id);
4612 } else if (!strcmp(res->proto, "udp")) {
4613 if (hw == 0 || (dev_info.tx_offload_capa &
4614 DEV_TX_OFFLOAD_UDP_CKSUM)) {
4615 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
4617 printf("UDP checksum offload is not supported "
4618 "by port %u\n", res->port_id);
4620 } else if (!strcmp(res->proto, "tcp")) {
4621 if (hw == 0 || (dev_info.tx_offload_capa &
4622 DEV_TX_OFFLOAD_TCP_CKSUM)) {
4623 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
4625 printf("TCP checksum offload is not supported "
4626 "by port %u\n", res->port_id);
4628 } else if (!strcmp(res->proto, "sctp")) {
4629 if (hw == 0 || (dev_info.tx_offload_capa &
4630 DEV_TX_OFFLOAD_SCTP_CKSUM)) {
4631 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
4633 printf("SCTP checksum offload is not supported "
4634 "by port %u\n", res->port_id);
4636 } else if (!strcmp(res->proto, "outer-ip")) {
4637 if (hw == 0 || (dev_info.tx_offload_capa &
4638 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4640 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4642 printf("Outer IP checksum offload is not "
4643 "supported by port %u\n", res->port_id);
4645 } else if (!strcmp(res->proto, "outer-udp")) {
4646 if (hw == 0 || (dev_info.tx_offload_capa &
4647 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
4649 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM;
4651 printf("Outer UDP checksum offload is not "
4652 "supported by port %u\n", res->port_id);
4657 ports[res->port_id].dev_conf.txmode.offloads |=
4660 ports[res->port_id].dev_conf.txmode.offloads &=
4663 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4665 csum_show(res->port_id);
4667 cmd_reconfig_device_queue(res->port_id, 1, 1);
4670 cmdline_parse_token_string_t cmd_csum_csum =
4671 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4673 cmdline_parse_token_string_t cmd_csum_mode =
4674 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4676 cmdline_parse_token_string_t cmd_csum_proto =
4677 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4678 proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
4679 cmdline_parse_token_string_t cmd_csum_hwsw =
4680 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4682 cmdline_parse_token_num_t cmd_csum_portid =
4683 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4684 port_id, RTE_UINT16);
4686 cmdline_parse_inst_t cmd_csum_set = {
4687 .f = cmd_csum_parsed,
4689 .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
4690 "Enable/Disable hardware calculation of L3/L4 checksum when "
4691 "using csum forward engine",
4693 (void *)&cmd_csum_csum,
4694 (void *)&cmd_csum_mode,
4695 (void *)&cmd_csum_proto,
4696 (void *)&cmd_csum_hwsw,
4697 (void *)&cmd_csum_portid,
4702 cmdline_parse_token_string_t cmd_csum_mode_show =
4703 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4706 cmdline_parse_inst_t cmd_csum_show = {
4707 .f = cmd_csum_parsed,
4709 .help_str = "csum show <port_id>: Show checksum offload configuration",
4711 (void *)&cmd_csum_csum,
4712 (void *)&cmd_csum_mode_show,
4713 (void *)&cmd_csum_portid,
4718 /* Enable/disable tunnel parsing */
4719 struct cmd_csum_tunnel_result {
4720 cmdline_fixed_string_t csum;
4721 cmdline_fixed_string_t parse;
4722 cmdline_fixed_string_t onoff;
4727 cmd_csum_tunnel_parsed(void *parsed_result,
4728 __rte_unused struct cmdline *cl,
4729 __rte_unused void *data)
4731 struct cmd_csum_tunnel_result *res = parsed_result;
4733 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4736 if (!strcmp(res->onoff, "on"))
4737 ports[res->port_id].parse_tunnel = 1;
4739 ports[res->port_id].parse_tunnel = 0;
4741 csum_show(res->port_id);
4744 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4745 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4747 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4748 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4749 parse, "parse-tunnel");
4750 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4751 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4753 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4754 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4755 port_id, RTE_UINT16);
4757 cmdline_parse_inst_t cmd_csum_tunnel = {
4758 .f = cmd_csum_tunnel_parsed,
4760 .help_str = "csum parse-tunnel on|off <port_id>: "
4761 "Enable/Disable parsing of tunnels for csum engine",
4763 (void *)&cmd_csum_tunnel_csum,
4764 (void *)&cmd_csum_tunnel_parse,
4765 (void *)&cmd_csum_tunnel_onoff,
4766 (void *)&cmd_csum_tunnel_portid,
4771 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4772 struct cmd_tso_set_result {
4773 cmdline_fixed_string_t tso;
4774 cmdline_fixed_string_t mode;
4780 cmd_tso_set_parsed(void *parsed_result,
4781 __rte_unused struct cmdline *cl,
4782 __rte_unused void *data)
4784 struct cmd_tso_set_result *res = parsed_result;
4785 struct rte_eth_dev_info dev_info;
4788 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4790 if (!port_is_stopped(res->port_id)) {
4791 printf("Please stop port %d first\n", res->port_id);
4795 if (!strcmp(res->mode, "set"))
4796 ports[res->port_id].tso_segsz = res->tso_segsz;
4798 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4802 if ((ports[res->port_id].tso_segsz != 0) &&
4803 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4804 printf("Error: TSO is not supported by port %d\n",
4809 if (ports[res->port_id].tso_segsz == 0) {
4810 ports[res->port_id].dev_conf.txmode.offloads &=
4811 ~DEV_TX_OFFLOAD_TCP_TSO;
4812 printf("TSO for non-tunneled packets is disabled\n");
4814 ports[res->port_id].dev_conf.txmode.offloads |=
4815 DEV_TX_OFFLOAD_TCP_TSO;
4816 printf("TSO segment size for non-tunneled packets is %d\n",
4817 ports[res->port_id].tso_segsz);
4819 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4821 /* display warnings if configuration is not supported by the NIC */
4822 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4826 if ((ports[res->port_id].tso_segsz != 0) &&
4827 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4828 printf("Warning: TSO enabled but not "
4829 "supported by port %d\n", res->port_id);
4832 cmd_reconfig_device_queue(res->port_id, 1, 1);
4835 cmdline_parse_token_string_t cmd_tso_set_tso =
4836 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4838 cmdline_parse_token_string_t cmd_tso_set_mode =
4839 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4841 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4842 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4843 tso_segsz, RTE_UINT16);
4844 cmdline_parse_token_num_t cmd_tso_set_portid =
4845 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4846 port_id, RTE_UINT16);
4848 cmdline_parse_inst_t cmd_tso_set = {
4849 .f = cmd_tso_set_parsed,
4851 .help_str = "tso set <tso_segsz> <port_id>: "
4852 "Set TSO segment size of non-tunneled packets for csum engine "
4855 (void *)&cmd_tso_set_tso,
4856 (void *)&cmd_tso_set_mode,
4857 (void *)&cmd_tso_set_tso_segsz,
4858 (void *)&cmd_tso_set_portid,
4863 cmdline_parse_token_string_t cmd_tso_show_mode =
4864 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4868 cmdline_parse_inst_t cmd_tso_show = {
4869 .f = cmd_tso_set_parsed,
4871 .help_str = "tso show <port_id>: "
4872 "Show TSO segment size of non-tunneled packets for csum engine",
4874 (void *)&cmd_tso_set_tso,
4875 (void *)&cmd_tso_show_mode,
4876 (void *)&cmd_tso_set_portid,
4881 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
4882 struct cmd_tunnel_tso_set_result {
4883 cmdline_fixed_string_t tso;
4884 cmdline_fixed_string_t mode;
4889 static struct rte_eth_dev_info
4890 check_tunnel_tso_nic_support(portid_t port_id)
4892 struct rte_eth_dev_info dev_info;
4894 if (eth_dev_info_get_print_err(port_id, &dev_info) != 0)
4897 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
4898 printf("Warning: VXLAN TUNNEL TSO not supported therefore "
4899 "not enabled for port %d\n", port_id);
4900 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
4901 printf("Warning: GRE TUNNEL TSO not supported therefore "
4902 "not enabled for port %d\n", port_id);
4903 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
4904 printf("Warning: IPIP TUNNEL TSO not supported therefore "
4905 "not enabled for port %d\n", port_id);
4906 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
4907 printf("Warning: GENEVE TUNNEL TSO not supported therefore "
4908 "not enabled for port %d\n", port_id);
4909 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
4910 printf("Warning: IP TUNNEL TSO not supported therefore "
4911 "not enabled for port %d\n", port_id);
4912 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
4913 printf("Warning: UDP TUNNEL TSO not supported therefore "
4914 "not enabled for port %d\n", port_id);
4919 cmd_tunnel_tso_set_parsed(void *parsed_result,
4920 __rte_unused struct cmdline *cl,
4921 __rte_unused void *data)
4923 struct cmd_tunnel_tso_set_result *res = parsed_result;
4924 struct rte_eth_dev_info dev_info;
4926 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4928 if (!port_is_stopped(res->port_id)) {
4929 printf("Please stop port %d first\n", res->port_id);
4933 if (!strcmp(res->mode, "set"))
4934 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
4936 dev_info = check_tunnel_tso_nic_support(res->port_id);
4937 if (ports[res->port_id].tunnel_tso_segsz == 0) {
4938 ports[res->port_id].dev_conf.txmode.offloads &=
4939 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4940 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4941 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4942 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4943 DEV_TX_OFFLOAD_IP_TNL_TSO |
4944 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4945 printf("TSO for tunneled packets is disabled\n");
4947 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4948 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4949 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4950 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4951 DEV_TX_OFFLOAD_IP_TNL_TSO |
4952 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4954 ports[res->port_id].dev_conf.txmode.offloads |=
4955 (tso_offloads & dev_info.tx_offload_capa);
4956 printf("TSO segment size for tunneled packets is %d\n",
4957 ports[res->port_id].tunnel_tso_segsz);
4959 /* Below conditions are needed to make it work:
4960 * (1) tunnel TSO is supported by the NIC;
4961 * (2) "csum parse_tunnel" must be set so that tunneled pkts
4963 * (3) for tunneled pkts with outer L3 of IPv4,
4964 * "csum set outer-ip" must be set to hw, because after tso,
4965 * total_len of outer IP header is changed, and the checksum
4966 * of outer IP header calculated by sw should be wrong; that
4967 * is not necessary for IPv6 tunneled pkts because there's no
4968 * checksum in IP header anymore.
4971 if (!ports[res->port_id].parse_tunnel)
4972 printf("Warning: csum parse_tunnel must be set "
4973 "so that tunneled packets are recognized\n");
4974 if (!(ports[res->port_id].dev_conf.txmode.offloads &
4975 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
4976 printf("Warning: csum set outer-ip must be set to hw "
4977 "if outer L3 is IPv4; not necessary for IPv6\n");
4980 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4981 cmd_reconfig_device_queue(res->port_id, 1, 1);
4984 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
4985 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4987 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
4988 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4990 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
4991 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4992 tso_segsz, RTE_UINT16);
4993 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
4994 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4995 port_id, RTE_UINT16);
4997 cmdline_parse_inst_t cmd_tunnel_tso_set = {
4998 .f = cmd_tunnel_tso_set_parsed,
5000 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
5001 "Set TSO segment size of tunneled packets for csum engine "
5004 (void *)&cmd_tunnel_tso_set_tso,
5005 (void *)&cmd_tunnel_tso_set_mode,
5006 (void *)&cmd_tunnel_tso_set_tso_segsz,
5007 (void *)&cmd_tunnel_tso_set_portid,
5012 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
5013 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5017 cmdline_parse_inst_t cmd_tunnel_tso_show = {
5018 .f = cmd_tunnel_tso_set_parsed,
5020 .help_str = "tunnel_tso show <port_id> "
5021 "Show TSO segment size of tunneled packets for csum engine",
5023 (void *)&cmd_tunnel_tso_set_tso,
5024 (void *)&cmd_tunnel_tso_show_mode,
5025 (void *)&cmd_tunnel_tso_set_portid,
5030 /* *** SET GRO FOR A PORT *** */
5031 struct cmd_gro_enable_result {
5032 cmdline_fixed_string_t cmd_set;
5033 cmdline_fixed_string_t cmd_port;
5034 cmdline_fixed_string_t cmd_keyword;
5035 cmdline_fixed_string_t cmd_onoff;
5040 cmd_gro_enable_parsed(void *parsed_result,
5041 __rte_unused struct cmdline *cl,
5042 __rte_unused void *data)
5044 struct cmd_gro_enable_result *res;
5046 res = parsed_result;
5047 if (!strcmp(res->cmd_keyword, "gro"))
5048 setup_gro(res->cmd_onoff, res->cmd_pid);
5051 cmdline_parse_token_string_t cmd_gro_enable_set =
5052 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5054 cmdline_parse_token_string_t cmd_gro_enable_port =
5055 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5056 cmd_keyword, "port");
5057 cmdline_parse_token_num_t cmd_gro_enable_pid =
5058 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
5059 cmd_pid, RTE_UINT16);
5060 cmdline_parse_token_string_t cmd_gro_enable_keyword =
5061 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5062 cmd_keyword, "gro");
5063 cmdline_parse_token_string_t cmd_gro_enable_onoff =
5064 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5065 cmd_onoff, "on#off");
5067 cmdline_parse_inst_t cmd_gro_enable = {
5068 .f = cmd_gro_enable_parsed,
5070 .help_str = "set port <port_id> gro on|off",
5072 (void *)&cmd_gro_enable_set,
5073 (void *)&cmd_gro_enable_port,
5074 (void *)&cmd_gro_enable_pid,
5075 (void *)&cmd_gro_enable_keyword,
5076 (void *)&cmd_gro_enable_onoff,
5081 /* *** DISPLAY GRO CONFIGURATION *** */
5082 struct cmd_gro_show_result {
5083 cmdline_fixed_string_t cmd_show;
5084 cmdline_fixed_string_t cmd_port;
5085 cmdline_fixed_string_t cmd_keyword;
5090 cmd_gro_show_parsed(void *parsed_result,
5091 __rte_unused struct cmdline *cl,
5092 __rte_unused void *data)
5094 struct cmd_gro_show_result *res;
5096 res = parsed_result;
5097 if (!strcmp(res->cmd_keyword, "gro"))
5098 show_gro(res->cmd_pid);
5101 cmdline_parse_token_string_t cmd_gro_show_show =
5102 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5104 cmdline_parse_token_string_t cmd_gro_show_port =
5105 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5107 cmdline_parse_token_num_t cmd_gro_show_pid =
5108 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
5109 cmd_pid, RTE_UINT16);
5110 cmdline_parse_token_string_t cmd_gro_show_keyword =
5111 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5112 cmd_keyword, "gro");
5114 cmdline_parse_inst_t cmd_gro_show = {
5115 .f = cmd_gro_show_parsed,
5117 .help_str = "show port <port_id> gro",
5119 (void *)&cmd_gro_show_show,
5120 (void *)&cmd_gro_show_port,
5121 (void *)&cmd_gro_show_pid,
5122 (void *)&cmd_gro_show_keyword,
5127 /* *** SET FLUSH CYCLES FOR GRO *** */
5128 struct cmd_gro_flush_result {
5129 cmdline_fixed_string_t cmd_set;
5130 cmdline_fixed_string_t cmd_keyword;
5131 cmdline_fixed_string_t cmd_flush;
5136 cmd_gro_flush_parsed(void *parsed_result,
5137 __rte_unused struct cmdline *cl,
5138 __rte_unused void *data)
5140 struct cmd_gro_flush_result *res;
5142 res = parsed_result;
5143 if ((!strcmp(res->cmd_keyword, "gro")) &&
5144 (!strcmp(res->cmd_flush, "flush")))
5145 setup_gro_flush_cycles(res->cmd_cycles);
5148 cmdline_parse_token_string_t cmd_gro_flush_set =
5149 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5151 cmdline_parse_token_string_t cmd_gro_flush_keyword =
5152 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5153 cmd_keyword, "gro");
5154 cmdline_parse_token_string_t cmd_gro_flush_flush =
5155 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5156 cmd_flush, "flush");
5157 cmdline_parse_token_num_t cmd_gro_flush_cycles =
5158 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
5159 cmd_cycles, RTE_UINT8);
5161 cmdline_parse_inst_t cmd_gro_flush = {
5162 .f = cmd_gro_flush_parsed,
5164 .help_str = "set gro flush <cycles>",
5166 (void *)&cmd_gro_flush_set,
5167 (void *)&cmd_gro_flush_keyword,
5168 (void *)&cmd_gro_flush_flush,
5169 (void *)&cmd_gro_flush_cycles,
5174 /* *** ENABLE/DISABLE GSO *** */
5175 struct cmd_gso_enable_result {
5176 cmdline_fixed_string_t cmd_set;
5177 cmdline_fixed_string_t cmd_port;
5178 cmdline_fixed_string_t cmd_keyword;
5179 cmdline_fixed_string_t cmd_mode;
5184 cmd_gso_enable_parsed(void *parsed_result,
5185 __rte_unused struct cmdline *cl,
5186 __rte_unused void *data)
5188 struct cmd_gso_enable_result *res;
5190 res = parsed_result;
5191 if (!strcmp(res->cmd_keyword, "gso"))
5192 setup_gso(res->cmd_mode, res->cmd_pid);
5195 cmdline_parse_token_string_t cmd_gso_enable_set =
5196 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5198 cmdline_parse_token_string_t cmd_gso_enable_port =
5199 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5201 cmdline_parse_token_string_t cmd_gso_enable_keyword =
5202 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5203 cmd_keyword, "gso");
5204 cmdline_parse_token_string_t cmd_gso_enable_mode =
5205 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5206 cmd_mode, "on#off");
5207 cmdline_parse_token_num_t cmd_gso_enable_pid =
5208 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
5209 cmd_pid, RTE_UINT16);
5211 cmdline_parse_inst_t cmd_gso_enable = {
5212 .f = cmd_gso_enable_parsed,
5214 .help_str = "set port <port_id> gso on|off",
5216 (void *)&cmd_gso_enable_set,
5217 (void *)&cmd_gso_enable_port,
5218 (void *)&cmd_gso_enable_pid,
5219 (void *)&cmd_gso_enable_keyword,
5220 (void *)&cmd_gso_enable_mode,
5225 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
5226 struct cmd_gso_size_result {
5227 cmdline_fixed_string_t cmd_set;
5228 cmdline_fixed_string_t cmd_keyword;
5229 cmdline_fixed_string_t cmd_segsz;
5234 cmd_gso_size_parsed(void *parsed_result,
5235 __rte_unused struct cmdline *cl,
5236 __rte_unused void *data)
5238 struct cmd_gso_size_result *res = parsed_result;
5240 if (test_done == 0) {
5241 printf("Before setting GSO segsz, please first"
5242 " stop forwarding\n");
5246 if (!strcmp(res->cmd_keyword, "gso") &&
5247 !strcmp(res->cmd_segsz, "segsz")) {
5248 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
5249 printf("gso_size should be larger than %zu."
5250 " Please input a legal value\n",
5251 RTE_GSO_SEG_SIZE_MIN);
5253 gso_max_segment_size = res->cmd_size;
5257 cmdline_parse_token_string_t cmd_gso_size_set =
5258 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5260 cmdline_parse_token_string_t cmd_gso_size_keyword =
5261 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5262 cmd_keyword, "gso");
5263 cmdline_parse_token_string_t cmd_gso_size_segsz =
5264 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5265 cmd_segsz, "segsz");
5266 cmdline_parse_token_num_t cmd_gso_size_size =
5267 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
5268 cmd_size, RTE_UINT16);
5270 cmdline_parse_inst_t cmd_gso_size = {
5271 .f = cmd_gso_size_parsed,
5273 .help_str = "set gso segsz <length>",
5275 (void *)&cmd_gso_size_set,
5276 (void *)&cmd_gso_size_keyword,
5277 (void *)&cmd_gso_size_segsz,
5278 (void *)&cmd_gso_size_size,
5283 /* *** SHOW GSO CONFIGURATION *** */
5284 struct cmd_gso_show_result {
5285 cmdline_fixed_string_t cmd_show;
5286 cmdline_fixed_string_t cmd_port;
5287 cmdline_fixed_string_t cmd_keyword;
5292 cmd_gso_show_parsed(void *parsed_result,
5293 __rte_unused struct cmdline *cl,
5294 __rte_unused void *data)
5296 struct cmd_gso_show_result *res = parsed_result;
5298 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
5299 printf("invalid port id %u\n", res->cmd_pid);
5302 if (!strcmp(res->cmd_keyword, "gso")) {
5303 if (gso_ports[res->cmd_pid].enable) {
5304 printf("Max GSO'd packet size: %uB\n"
5305 "Supported GSO types: TCP/IPv4, "
5306 "UDP/IPv4, VxLAN with inner "
5307 "TCP/IPv4 packet, GRE with inner "
5308 "TCP/IPv4 packet\n",
5309 gso_max_segment_size);
5311 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
5315 cmdline_parse_token_string_t cmd_gso_show_show =
5316 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5318 cmdline_parse_token_string_t cmd_gso_show_port =
5319 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5321 cmdline_parse_token_string_t cmd_gso_show_keyword =
5322 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5323 cmd_keyword, "gso");
5324 cmdline_parse_token_num_t cmd_gso_show_pid =
5325 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
5326 cmd_pid, RTE_UINT16);
5328 cmdline_parse_inst_t cmd_gso_show = {
5329 .f = cmd_gso_show_parsed,
5331 .help_str = "show port <port_id> gso",
5333 (void *)&cmd_gso_show_show,
5334 (void *)&cmd_gso_show_port,
5335 (void *)&cmd_gso_show_pid,
5336 (void *)&cmd_gso_show_keyword,
5341 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
5342 struct cmd_set_flush_rx {
5343 cmdline_fixed_string_t set;
5344 cmdline_fixed_string_t flush_rx;
5345 cmdline_fixed_string_t mode;
5349 cmd_set_flush_rx_parsed(void *parsed_result,
5350 __rte_unused struct cmdline *cl,
5351 __rte_unused void *data)
5353 struct cmd_set_flush_rx *res = parsed_result;
5354 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5357 cmdline_parse_token_string_t cmd_setflushrx_set =
5358 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5360 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
5361 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5362 flush_rx, "flush_rx");
5363 cmdline_parse_token_string_t cmd_setflushrx_mode =
5364 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5368 cmdline_parse_inst_t cmd_set_flush_rx = {
5369 .f = cmd_set_flush_rx_parsed,
5370 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
5373 (void *)&cmd_setflushrx_set,
5374 (void *)&cmd_setflushrx_flush_rx,
5375 (void *)&cmd_setflushrx_mode,
5380 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
5381 struct cmd_set_link_check {
5382 cmdline_fixed_string_t set;
5383 cmdline_fixed_string_t link_check;
5384 cmdline_fixed_string_t mode;
5388 cmd_set_link_check_parsed(void *parsed_result,
5389 __rte_unused struct cmdline *cl,
5390 __rte_unused void *data)
5392 struct cmd_set_link_check *res = parsed_result;
5393 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5396 cmdline_parse_token_string_t cmd_setlinkcheck_set =
5397 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5399 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
5400 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5401 link_check, "link_check");
5402 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
5403 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5407 cmdline_parse_inst_t cmd_set_link_check = {
5408 .f = cmd_set_link_check_parsed,
5409 .help_str = "set link_check on|off: Enable/Disable link status check "
5410 "when starting/stopping a port",
5413 (void *)&cmd_setlinkcheck_set,
5414 (void *)&cmd_setlinkcheck_link_check,
5415 (void *)&cmd_setlinkcheck_mode,
5420 /* *** SET NIC BYPASS MODE *** */
5421 struct cmd_set_bypass_mode_result {
5422 cmdline_fixed_string_t set;
5423 cmdline_fixed_string_t bypass;
5424 cmdline_fixed_string_t mode;
5425 cmdline_fixed_string_t value;
5430 cmd_set_bypass_mode_parsed(void *parsed_result,
5431 __rte_unused struct cmdline *cl,
5432 __rte_unused void *data)
5434 struct cmd_set_bypass_mode_result *res = parsed_result;
5435 portid_t port_id = res->port_id;
5436 int32_t rc = -EINVAL;
5438 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5439 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5441 if (!strcmp(res->value, "bypass"))
5442 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5443 else if (!strcmp(res->value, "isolate"))
5444 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5446 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5448 /* Set the bypass mode for the relevant port. */
5449 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
5452 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
5455 cmdline_parse_token_string_t cmd_setbypass_mode_set =
5456 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5458 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
5459 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5461 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
5462 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5464 cmdline_parse_token_string_t cmd_setbypass_mode_value =
5465 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5466 value, "normal#bypass#isolate");
5467 cmdline_parse_token_num_t cmd_setbypass_mode_port =
5468 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
5469 port_id, RTE_UINT16);
5471 cmdline_parse_inst_t cmd_set_bypass_mode = {
5472 .f = cmd_set_bypass_mode_parsed,
5473 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
5474 "Set the NIC bypass mode for port_id",
5477 (void *)&cmd_setbypass_mode_set,
5478 (void *)&cmd_setbypass_mode_bypass,
5479 (void *)&cmd_setbypass_mode_mode,
5480 (void *)&cmd_setbypass_mode_value,
5481 (void *)&cmd_setbypass_mode_port,
5486 /* *** SET NIC BYPASS EVENT *** */
5487 struct cmd_set_bypass_event_result {
5488 cmdline_fixed_string_t set;
5489 cmdline_fixed_string_t bypass;
5490 cmdline_fixed_string_t event;
5491 cmdline_fixed_string_t event_value;
5492 cmdline_fixed_string_t mode;
5493 cmdline_fixed_string_t mode_value;
5498 cmd_set_bypass_event_parsed(void *parsed_result,
5499 __rte_unused struct cmdline *cl,
5500 __rte_unused void *data)
5502 int32_t rc = -EINVAL;
5503 struct cmd_set_bypass_event_result *res = parsed_result;
5504 portid_t port_id = res->port_id;
5506 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5507 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5508 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5510 if (!strcmp(res->event_value, "timeout"))
5511 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
5512 else if (!strcmp(res->event_value, "os_on"))
5513 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
5514 else if (!strcmp(res->event_value, "os_off"))
5515 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5516 else if (!strcmp(res->event_value, "power_on"))
5517 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5518 else if (!strcmp(res->event_value, "power_off"))
5519 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5521 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5523 if (!strcmp(res->mode_value, "bypass"))
5524 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5525 else if (!strcmp(res->mode_value, "isolate"))
5526 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5528 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5530 /* Set the watchdog timeout. */
5531 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5534 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5535 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5539 printf("Failed to set timeout value %u "
5540 "for port %d, errto code: %d.\n",
5541 bypass_timeout, port_id, rc);
5545 /* Set the bypass event to transition to bypass mode. */
5546 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5551 printf("\t Failed to set bypass event for port = %d.\n",
5555 cmdline_parse_token_string_t cmd_setbypass_event_set =
5556 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5558 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5559 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5561 cmdline_parse_token_string_t cmd_setbypass_event_event =
5562 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5564 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5565 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5566 event_value, "none#timeout#os_off#os_on#power_on#power_off");
5567 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5568 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5570 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5571 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5572 mode_value, "normal#bypass#isolate");
5573 cmdline_parse_token_num_t cmd_setbypass_event_port =
5574 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5575 port_id, RTE_UINT16);
5577 cmdline_parse_inst_t cmd_set_bypass_event = {
5578 .f = cmd_set_bypass_event_parsed,
5579 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5580 "power_off mode normal|bypass|isolate <port_id>: "
5581 "Set the NIC bypass event mode for port_id",
5584 (void *)&cmd_setbypass_event_set,
5585 (void *)&cmd_setbypass_event_bypass,
5586 (void *)&cmd_setbypass_event_event,
5587 (void *)&cmd_setbypass_event_event_value,
5588 (void *)&cmd_setbypass_event_mode,
5589 (void *)&cmd_setbypass_event_mode_value,
5590 (void *)&cmd_setbypass_event_port,
5596 /* *** SET NIC BYPASS TIMEOUT *** */
5597 struct cmd_set_bypass_timeout_result {
5598 cmdline_fixed_string_t set;
5599 cmdline_fixed_string_t bypass;
5600 cmdline_fixed_string_t timeout;
5601 cmdline_fixed_string_t value;
5605 cmd_set_bypass_timeout_parsed(void *parsed_result,
5606 __rte_unused struct cmdline *cl,
5607 __rte_unused void *data)
5609 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5611 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5612 if (!strcmp(res->value, "1.5"))
5613 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5614 else if (!strcmp(res->value, "2"))
5615 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5616 else if (!strcmp(res->value, "3"))
5617 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5618 else if (!strcmp(res->value, "4"))
5619 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5620 else if (!strcmp(res->value, "8"))
5621 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5622 else if (!strcmp(res->value, "16"))
5623 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5624 else if (!strcmp(res->value, "32"))
5625 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5627 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5631 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5632 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5634 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5635 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5637 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5638 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5639 timeout, "timeout");
5640 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5641 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5642 value, "0#1.5#2#3#4#8#16#32");
5644 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5645 .f = cmd_set_bypass_timeout_parsed,
5646 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5647 "Set the NIC bypass watchdog timeout in seconds",
5650 (void *)&cmd_setbypass_timeout_set,
5651 (void *)&cmd_setbypass_timeout_bypass,
5652 (void *)&cmd_setbypass_timeout_timeout,
5653 (void *)&cmd_setbypass_timeout_value,
5658 /* *** SHOW NIC BYPASS MODE *** */
5659 struct cmd_show_bypass_config_result {
5660 cmdline_fixed_string_t show;
5661 cmdline_fixed_string_t bypass;
5662 cmdline_fixed_string_t config;
5667 cmd_show_bypass_config_parsed(void *parsed_result,
5668 __rte_unused struct cmdline *cl,
5669 __rte_unused void *data)
5671 struct cmd_show_bypass_config_result *res = parsed_result;
5672 portid_t port_id = res->port_id;
5674 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5675 uint32_t event_mode;
5676 uint32_t bypass_mode;
5677 uint32_t timeout = bypass_timeout;
5680 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5681 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
5682 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5683 {"UNKNOWN", "normal", "bypass", "isolate"};
5684 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5692 /* Display the bypass mode.*/
5693 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5694 printf("\tFailed to get bypass mode for port = %d\n", port_id);
5698 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5699 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5701 printf("\tbypass mode = %s\n", modes[bypass_mode]);
5704 /* Display the bypass timeout.*/
5705 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5706 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5708 printf("\tbypass timeout = %s\n", timeouts[timeout]);
5710 /* Display the bypass events and associated modes. */
5711 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < RTE_DIM(events); i++) {
5713 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5714 printf("\tFailed to get bypass mode for event = %s\n",
5717 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5718 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5720 printf("\tbypass event: %-16s = %s\n", events[i],
5726 printf("\tFailed to get bypass configuration for port = %d\n",
5730 cmdline_parse_token_string_t cmd_showbypass_config_show =
5731 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5733 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5734 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5736 cmdline_parse_token_string_t cmd_showbypass_config_config =
5737 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5739 cmdline_parse_token_num_t cmd_showbypass_config_port =
5740 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5741 port_id, RTE_UINT16);
5743 cmdline_parse_inst_t cmd_show_bypass_config = {
5744 .f = cmd_show_bypass_config_parsed,
5745 .help_str = "show bypass config <port_id>: "
5746 "Show the NIC bypass config for port_id",
5749 (void *)&cmd_showbypass_config_show,
5750 (void *)&cmd_showbypass_config_bypass,
5751 (void *)&cmd_showbypass_config_config,
5752 (void *)&cmd_showbypass_config_port,
5758 /* *** SET BONDING MODE *** */
5759 struct cmd_set_bonding_mode_result {
5760 cmdline_fixed_string_t set;
5761 cmdline_fixed_string_t bonding;
5762 cmdline_fixed_string_t mode;
5767 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5768 __rte_unused struct cmdline *cl,
5769 __rte_unused void *data)
5771 struct cmd_set_bonding_mode_result *res = parsed_result;
5772 portid_t port_id = res->port_id;
5774 /* Set the bonding mode for the relevant port. */
5775 if (0 != rte_eth_bond_mode_set(port_id, res->value))
5776 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
5779 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5780 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5782 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5783 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5784 bonding, "bonding");
5785 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5786 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5788 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5789 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5791 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5792 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5793 port_id, RTE_UINT16);
5795 cmdline_parse_inst_t cmd_set_bonding_mode = {
5796 .f = cmd_set_bonding_mode_parsed,
5797 .help_str = "set bonding mode <mode_value> <port_id>: "
5798 "Set the bonding mode for port_id",
5801 (void *) &cmd_setbonding_mode_set,
5802 (void *) &cmd_setbonding_mode_bonding,
5803 (void *) &cmd_setbonding_mode_mode,
5804 (void *) &cmd_setbonding_mode_value,
5805 (void *) &cmd_setbonding_mode_port,
5810 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5811 struct cmd_set_bonding_lacp_dedicated_queues_result {
5812 cmdline_fixed_string_t set;
5813 cmdline_fixed_string_t bonding;
5814 cmdline_fixed_string_t lacp;
5815 cmdline_fixed_string_t dedicated_queues;
5817 cmdline_fixed_string_t mode;
5820 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5821 __rte_unused struct cmdline *cl,
5822 __rte_unused void *data)
5824 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5825 portid_t port_id = res->port_id;
5826 struct rte_port *port;
5828 port = &ports[port_id];
5830 /** Check if the port is not started **/
5831 if (port->port_status != RTE_PORT_STOPPED) {
5832 printf("Please stop port %d first\n", port_id);
5836 if (!strcmp(res->mode, "enable")) {
5837 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5838 printf("Dedicate queues for LACP control packets"
5841 printf("Enabling dedicate queues for LACP control "
5842 "packets on port %d failed\n", port_id);
5843 } else if (!strcmp(res->mode, "disable")) {
5844 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5845 printf("Dedicated queues for LACP control packets "
5848 printf("Disabling dedicated queues for LACP control "
5849 "traffic on port %d failed\n", port_id);
5853 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5854 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5856 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
5857 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5858 bonding, "bonding");
5859 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
5860 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5862 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
5863 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5864 dedicated_queues, "dedicated_queues");
5865 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
5866 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5867 port_id, RTE_UINT16);
5868 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
5869 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5870 mode, "enable#disable");
5872 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
5873 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
5874 .help_str = "set bonding lacp dedicated_queues <port_id> "
5876 "Enable/disable dedicated queues for LACP control traffic for port_id",
5879 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
5880 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
5881 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
5882 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
5883 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
5884 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
5889 /* *** SET BALANCE XMIT POLICY *** */
5890 struct cmd_set_bonding_balance_xmit_policy_result {
5891 cmdline_fixed_string_t set;
5892 cmdline_fixed_string_t bonding;
5893 cmdline_fixed_string_t balance_xmit_policy;
5895 cmdline_fixed_string_t policy;
5898 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
5899 __rte_unused struct cmdline *cl,
5900 __rte_unused void *data)
5902 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
5903 portid_t port_id = res->port_id;
5906 if (!strcmp(res->policy, "l2")) {
5907 policy = BALANCE_XMIT_POLICY_LAYER2;
5908 } else if (!strcmp(res->policy, "l23")) {
5909 policy = BALANCE_XMIT_POLICY_LAYER23;
5910 } else if (!strcmp(res->policy, "l34")) {
5911 policy = BALANCE_XMIT_POLICY_LAYER34;
5913 printf("\t Invalid xmit policy selection");
5917 /* Set the bonding mode for the relevant port. */
5918 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
5919 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
5924 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
5925 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5927 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
5928 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5929 bonding, "bonding");
5930 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
5931 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5932 balance_xmit_policy, "balance_xmit_policy");
5933 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
5934 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5935 port_id, RTE_UINT16);
5936 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
5937 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5938 policy, "l2#l23#l34");
5940 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
5941 .f = cmd_set_bonding_balance_xmit_policy_parsed,
5942 .help_str = "set bonding balance_xmit_policy <port_id> "
5944 "Set the bonding balance_xmit_policy for port_id",
5947 (void *)&cmd_setbonding_balance_xmit_policy_set,
5948 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
5949 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
5950 (void *)&cmd_setbonding_balance_xmit_policy_port,
5951 (void *)&cmd_setbonding_balance_xmit_policy_policy,
5956 /* *** SHOW NIC BONDING CONFIGURATION *** */
5957 struct cmd_show_bonding_config_result {
5958 cmdline_fixed_string_t show;
5959 cmdline_fixed_string_t bonding;
5960 cmdline_fixed_string_t config;
5964 static void cmd_show_bonding_config_parsed(void *parsed_result,
5965 __rte_unused struct cmdline *cl,
5966 __rte_unused void *data)
5968 struct cmd_show_bonding_config_result *res = parsed_result;
5969 int bonding_mode, agg_mode;
5970 portid_t slaves[RTE_MAX_ETHPORTS];
5971 int num_slaves, num_active_slaves;
5974 portid_t port_id = res->port_id;
5976 /* Display the bonding mode.*/
5977 bonding_mode = rte_eth_bond_mode_get(port_id);
5978 if (bonding_mode < 0) {
5979 printf("\tFailed to get bonding mode for port = %d\n", port_id);
5982 printf("\tBonding mode: %d\n", bonding_mode);
5984 if (bonding_mode == BONDING_MODE_BALANCE) {
5985 int balance_xmit_policy;
5987 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
5988 if (balance_xmit_policy < 0) {
5989 printf("\tFailed to get balance xmit policy for port = %d\n",
5993 printf("\tBalance Xmit Policy: ");
5995 switch (balance_xmit_policy) {
5996 case BALANCE_XMIT_POLICY_LAYER2:
5997 printf("BALANCE_XMIT_POLICY_LAYER2");
5999 case BALANCE_XMIT_POLICY_LAYER23:
6000 printf("BALANCE_XMIT_POLICY_LAYER23");
6002 case BALANCE_XMIT_POLICY_LAYER34:
6003 printf("BALANCE_XMIT_POLICY_LAYER34");
6010 if (bonding_mode == BONDING_MODE_8023AD) {
6011 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
6012 printf("\tIEEE802.3AD Aggregator Mode: ");
6015 printf("bandwidth");
6027 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
6029 if (num_slaves < 0) {
6030 printf("\tFailed to get slave list for port = %d\n", port_id);
6033 if (num_slaves > 0) {
6034 printf("\tSlaves (%d): [", num_slaves);
6035 for (i = 0; i < num_slaves - 1; i++)
6036 printf("%d ", slaves[i]);
6038 printf("%d]\n", slaves[num_slaves - 1]);
6040 printf("\tSlaves: []\n");
6044 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
6047 if (num_active_slaves < 0) {
6048 printf("\tFailed to get active slave list for port = %d\n", port_id);
6051 if (num_active_slaves > 0) {
6052 printf("\tActive Slaves (%d): [", num_active_slaves);
6053 for (i = 0; i < num_active_slaves - 1; i++)
6054 printf("%d ", slaves[i]);
6056 printf("%d]\n", slaves[num_active_slaves - 1]);
6059 printf("\tActive Slaves: []\n");
6063 primary_id = rte_eth_bond_primary_get(port_id);
6064 if (primary_id < 0) {
6065 printf("\tFailed to get primary slave for port = %d\n", port_id);
6068 printf("\tPrimary: [%d]\n", primary_id);
6072 cmdline_parse_token_string_t cmd_showbonding_config_show =
6073 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6075 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
6076 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6077 bonding, "bonding");
6078 cmdline_parse_token_string_t cmd_showbonding_config_config =
6079 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6081 cmdline_parse_token_num_t cmd_showbonding_config_port =
6082 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
6083 port_id, RTE_UINT16);
6085 cmdline_parse_inst_t cmd_show_bonding_config = {
6086 .f = cmd_show_bonding_config_parsed,
6087 .help_str = "show bonding config <port_id>: "
6088 "Show the bonding config for port_id",
6091 (void *)&cmd_showbonding_config_show,
6092 (void *)&cmd_showbonding_config_bonding,
6093 (void *)&cmd_showbonding_config_config,
6094 (void *)&cmd_showbonding_config_port,
6099 /* *** SET BONDING PRIMARY *** */
6100 struct cmd_set_bonding_primary_result {
6101 cmdline_fixed_string_t set;
6102 cmdline_fixed_string_t bonding;
6103 cmdline_fixed_string_t primary;
6108 static void cmd_set_bonding_primary_parsed(void *parsed_result,
6109 __rte_unused struct cmdline *cl,
6110 __rte_unused void *data)
6112 struct cmd_set_bonding_primary_result *res = parsed_result;
6113 portid_t master_port_id = res->port_id;
6114 portid_t slave_port_id = res->slave_id;
6116 /* Set the primary slave for a bonded device. */
6117 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
6118 printf("\t Failed to set primary slave for port = %d.\n",
6125 cmdline_parse_token_string_t cmd_setbonding_primary_set =
6126 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6128 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
6129 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6130 bonding, "bonding");
6131 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
6132 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6133 primary, "primary");
6134 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
6135 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6136 slave_id, RTE_UINT16);
6137 cmdline_parse_token_num_t cmd_setbonding_primary_port =
6138 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6139 port_id, RTE_UINT16);
6141 cmdline_parse_inst_t cmd_set_bonding_primary = {
6142 .f = cmd_set_bonding_primary_parsed,
6143 .help_str = "set bonding primary <slave_id> <port_id>: "
6144 "Set the primary slave for port_id",
6147 (void *)&cmd_setbonding_primary_set,
6148 (void *)&cmd_setbonding_primary_bonding,
6149 (void *)&cmd_setbonding_primary_primary,
6150 (void *)&cmd_setbonding_primary_slave,
6151 (void *)&cmd_setbonding_primary_port,
6156 /* *** ADD SLAVE *** */
6157 struct cmd_add_bonding_slave_result {
6158 cmdline_fixed_string_t add;
6159 cmdline_fixed_string_t bonding;
6160 cmdline_fixed_string_t slave;
6165 static void cmd_add_bonding_slave_parsed(void *parsed_result,
6166 __rte_unused struct cmdline *cl,
6167 __rte_unused void *data)
6169 struct cmd_add_bonding_slave_result *res = parsed_result;
6170 portid_t master_port_id = res->port_id;
6171 portid_t slave_port_id = res->slave_id;
6173 /* add the slave for a bonded device. */
6174 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
6175 printf("\t Failed to add slave %d to master port = %d.\n",
6176 slave_port_id, master_port_id);
6180 set_port_slave_flag(slave_port_id);
6183 cmdline_parse_token_string_t cmd_addbonding_slave_add =
6184 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6186 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
6187 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6188 bonding, "bonding");
6189 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
6190 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6192 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
6193 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6194 slave_id, RTE_UINT16);
6195 cmdline_parse_token_num_t cmd_addbonding_slave_port =
6196 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6197 port_id, RTE_UINT16);
6199 cmdline_parse_inst_t cmd_add_bonding_slave = {
6200 .f = cmd_add_bonding_slave_parsed,
6201 .help_str = "add bonding slave <slave_id> <port_id>: "
6202 "Add a slave device to a bonded device",
6205 (void *)&cmd_addbonding_slave_add,
6206 (void *)&cmd_addbonding_slave_bonding,
6207 (void *)&cmd_addbonding_slave_slave,
6208 (void *)&cmd_addbonding_slave_slaveid,
6209 (void *)&cmd_addbonding_slave_port,
6214 /* *** REMOVE SLAVE *** */
6215 struct cmd_remove_bonding_slave_result {
6216 cmdline_fixed_string_t remove;
6217 cmdline_fixed_string_t bonding;
6218 cmdline_fixed_string_t slave;
6223 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
6224 __rte_unused struct cmdline *cl,
6225 __rte_unused void *data)
6227 struct cmd_remove_bonding_slave_result *res = parsed_result;
6228 portid_t master_port_id = res->port_id;
6229 portid_t slave_port_id = res->slave_id;
6231 /* remove the slave from a bonded device. */
6232 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
6233 printf("\t Failed to remove slave %d from master port = %d.\n",
6234 slave_port_id, master_port_id);
6238 clear_port_slave_flag(slave_port_id);
6241 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
6242 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6244 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
6245 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6246 bonding, "bonding");
6247 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
6248 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6250 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
6251 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6252 slave_id, RTE_UINT16);
6253 cmdline_parse_token_num_t cmd_removebonding_slave_port =
6254 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6255 port_id, RTE_UINT16);
6257 cmdline_parse_inst_t cmd_remove_bonding_slave = {
6258 .f = cmd_remove_bonding_slave_parsed,
6259 .help_str = "remove bonding slave <slave_id> <port_id>: "
6260 "Remove a slave device from a bonded device",
6263 (void *)&cmd_removebonding_slave_remove,
6264 (void *)&cmd_removebonding_slave_bonding,
6265 (void *)&cmd_removebonding_slave_slave,
6266 (void *)&cmd_removebonding_slave_slaveid,
6267 (void *)&cmd_removebonding_slave_port,
6272 /* *** CREATE BONDED DEVICE *** */
6273 struct cmd_create_bonded_device_result {
6274 cmdline_fixed_string_t create;
6275 cmdline_fixed_string_t bonded;
6276 cmdline_fixed_string_t device;
6281 static int bond_dev_num = 0;
6283 static void cmd_create_bonded_device_parsed(void *parsed_result,
6284 __rte_unused struct cmdline *cl,
6285 __rte_unused void *data)
6287 struct cmd_create_bonded_device_result *res = parsed_result;
6288 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
6292 if (test_done == 0) {
6293 printf("Please stop forwarding first\n");
6297 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
6300 /* Create a new bonded device. */
6301 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
6303 printf("\t Failed to create bonded device.\n");
6306 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
6309 /* Update number of ports */
6310 nb_ports = rte_eth_dev_count_avail();
6311 reconfig(port_id, res->socket);
6312 ret = rte_eth_promiscuous_enable(port_id);
6314 printf("Failed to enable promiscuous mode for port %u: %s - ignore\n",
6315 port_id, rte_strerror(-ret));
6317 ports[port_id].need_setup = 0;
6318 ports[port_id].port_status = RTE_PORT_STOPPED;
6323 cmdline_parse_token_string_t cmd_createbonded_device_create =
6324 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6326 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
6327 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6329 cmdline_parse_token_string_t cmd_createbonded_device_device =
6330 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6332 cmdline_parse_token_num_t cmd_createbonded_device_mode =
6333 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6335 cmdline_parse_token_num_t cmd_createbonded_device_socket =
6336 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6339 cmdline_parse_inst_t cmd_create_bonded_device = {
6340 .f = cmd_create_bonded_device_parsed,
6341 .help_str = "create bonded device <mode> <socket>: "
6342 "Create a new bonded device with specific bonding mode and socket",
6345 (void *)&cmd_createbonded_device_create,
6346 (void *)&cmd_createbonded_device_bonded,
6347 (void *)&cmd_createbonded_device_device,
6348 (void *)&cmd_createbonded_device_mode,
6349 (void *)&cmd_createbonded_device_socket,
6354 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
6355 struct cmd_set_bond_mac_addr_result {
6356 cmdline_fixed_string_t set;
6357 cmdline_fixed_string_t bonding;
6358 cmdline_fixed_string_t mac_addr;
6360 struct rte_ether_addr address;
6363 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
6364 __rte_unused struct cmdline *cl,
6365 __rte_unused void *data)
6367 struct cmd_set_bond_mac_addr_result *res = parsed_result;
6370 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
6373 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
6375 /* check the return value and print it if is < 0 */
6377 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6380 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
6381 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
6382 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
6383 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
6385 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
6386 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
6388 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
6389 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
6390 port_num, RTE_UINT16);
6391 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
6392 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
6394 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
6395 .f = cmd_set_bond_mac_addr_parsed,
6397 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
6399 (void *)&cmd_set_bond_mac_addr_set,
6400 (void *)&cmd_set_bond_mac_addr_bonding,
6401 (void *)&cmd_set_bond_mac_addr_mac,
6402 (void *)&cmd_set_bond_mac_addr_portnum,
6403 (void *)&cmd_set_bond_mac_addr_addr,
6409 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
6410 struct cmd_set_bond_mon_period_result {
6411 cmdline_fixed_string_t set;
6412 cmdline_fixed_string_t bonding;
6413 cmdline_fixed_string_t mon_period;
6418 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
6419 __rte_unused struct cmdline *cl,
6420 __rte_unused void *data)
6422 struct cmd_set_bond_mon_period_result *res = parsed_result;
6425 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
6427 /* check the return value and print it if is < 0 */
6429 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6432 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
6433 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6435 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
6436 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6437 bonding, "bonding");
6438 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
6439 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6440 mon_period, "mon_period");
6441 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
6442 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6443 port_num, RTE_UINT16);
6444 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
6445 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6446 period_ms, RTE_UINT32);
6448 cmdline_parse_inst_t cmd_set_bond_mon_period = {
6449 .f = cmd_set_bond_mon_period_parsed,
6451 .help_str = "set bonding mon_period <port_id> <period_ms>",
6453 (void *)&cmd_set_bond_mon_period_set,
6454 (void *)&cmd_set_bond_mon_period_bonding,
6455 (void *)&cmd_set_bond_mon_period_mon_period,
6456 (void *)&cmd_set_bond_mon_period_portnum,
6457 (void *)&cmd_set_bond_mon_period_period_ms,
6464 struct cmd_set_bonding_agg_mode_policy_result {
6465 cmdline_fixed_string_t set;
6466 cmdline_fixed_string_t bonding;
6467 cmdline_fixed_string_t agg_mode;
6469 cmdline_fixed_string_t policy;
6474 cmd_set_bonding_agg_mode(void *parsed_result,
6475 __rte_unused struct cmdline *cl,
6476 __rte_unused void *data)
6478 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
6479 uint8_t policy = AGG_BANDWIDTH;
6481 if (!strcmp(res->policy, "bandwidth"))
6482 policy = AGG_BANDWIDTH;
6483 else if (!strcmp(res->policy, "stable"))
6484 policy = AGG_STABLE;
6485 else if (!strcmp(res->policy, "count"))
6488 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
6492 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
6493 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6495 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
6496 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6497 bonding, "bonding");
6499 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
6500 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6501 agg_mode, "agg_mode");
6503 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
6504 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6505 port_num, RTE_UINT16);
6507 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6508 TOKEN_STRING_INITIALIZER(
6509 struct cmd_set_bonding_balance_xmit_policy_result,
6510 policy, "stable#bandwidth#count");
6512 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6513 .f = cmd_set_bonding_agg_mode,
6515 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6517 (void *)&cmd_set_bonding_agg_mode_set,
6518 (void *)&cmd_set_bonding_agg_mode_bonding,
6519 (void *)&cmd_set_bonding_agg_mode_agg_mode,
6520 (void *)&cmd_set_bonding_agg_mode_portnum,
6521 (void *)&cmd_set_bonding_agg_mode_policy_string,
6527 #endif /* RTE_NET_BOND */
6529 /* *** SET FORWARDING MODE *** */
6530 struct cmd_set_fwd_mode_result {
6531 cmdline_fixed_string_t set;
6532 cmdline_fixed_string_t fwd;
6533 cmdline_fixed_string_t mode;
6536 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6537 __rte_unused struct cmdline *cl,
6538 __rte_unused void *data)
6540 struct cmd_set_fwd_mode_result *res = parsed_result;
6543 set_pkt_forwarding_mode(res->mode);
6546 cmdline_parse_token_string_t cmd_setfwd_set =
6547 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6548 cmdline_parse_token_string_t cmd_setfwd_fwd =
6549 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6550 cmdline_parse_token_string_t cmd_setfwd_mode =
6551 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6552 "" /* defined at init */);
6554 cmdline_parse_inst_t cmd_set_fwd_mode = {
6555 .f = cmd_set_fwd_mode_parsed,
6557 .help_str = NULL, /* defined at init */
6559 (void *)&cmd_setfwd_set,
6560 (void *)&cmd_setfwd_fwd,
6561 (void *)&cmd_setfwd_mode,
6566 static void cmd_set_fwd_mode_init(void)
6569 static char token[128];
6570 static char help[256];
6571 cmdline_parse_token_string_t *token_struct;
6573 modes = list_pkt_forwarding_modes();
6574 snprintf(help, sizeof(help), "set fwd %s: "
6575 "Set packet forwarding mode", modes);
6576 cmd_set_fwd_mode.help_str = help;
6578 /* string token separator is # */
6579 for (c = token; *modes != '\0'; modes++)
6584 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6585 token_struct->string_data.str = token;
6588 /* *** SET RETRY FORWARDING MODE *** */
6589 struct cmd_set_fwd_retry_mode_result {
6590 cmdline_fixed_string_t set;
6591 cmdline_fixed_string_t fwd;
6592 cmdline_fixed_string_t mode;
6593 cmdline_fixed_string_t retry;
6596 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6597 __rte_unused struct cmdline *cl,
6598 __rte_unused void *data)
6600 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6603 set_pkt_forwarding_mode(res->mode);
6606 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6607 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6609 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6610 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6612 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6613 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6615 "" /* defined at init */);
6616 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6617 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6620 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6621 .f = cmd_set_fwd_retry_mode_parsed,
6623 .help_str = NULL, /* defined at init */
6625 (void *)&cmd_setfwd_retry_set,
6626 (void *)&cmd_setfwd_retry_fwd,
6627 (void *)&cmd_setfwd_retry_mode,
6628 (void *)&cmd_setfwd_retry_retry,
6633 static void cmd_set_fwd_retry_mode_init(void)
6636 static char token[128];
6637 static char help[256];
6638 cmdline_parse_token_string_t *token_struct;
6640 modes = list_pkt_forwarding_retry_modes();
6641 snprintf(help, sizeof(help), "set fwd %s retry: "
6642 "Set packet forwarding mode with retry", modes);
6643 cmd_set_fwd_retry_mode.help_str = help;
6645 /* string token separator is # */
6646 for (c = token; *modes != '\0'; modes++)
6651 token_struct = (cmdline_parse_token_string_t *)
6652 cmd_set_fwd_retry_mode.tokens[2];
6653 token_struct->string_data.str = token;
6656 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6657 struct cmd_set_burst_tx_retry_result {
6658 cmdline_fixed_string_t set;
6659 cmdline_fixed_string_t burst;
6660 cmdline_fixed_string_t tx;
6661 cmdline_fixed_string_t delay;
6663 cmdline_fixed_string_t retry;
6667 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6668 __rte_unused struct cmdline *cl,
6669 __rte_unused void *data)
6671 struct cmd_set_burst_tx_retry_result *res = parsed_result;
6673 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6674 && !strcmp(res->tx, "tx")) {
6675 if (!strcmp(res->delay, "delay"))
6676 burst_tx_delay_time = res->time;
6677 if (!strcmp(res->retry, "retry"))
6678 burst_tx_retry_num = res->retry_num;
6683 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6684 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6685 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6686 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6688 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6689 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6690 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6691 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6692 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6693 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time,
6695 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6696 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6697 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6698 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num,
6701 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6702 .f = cmd_set_burst_tx_retry_parsed,
6703 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6705 (void *)&cmd_set_burst_tx_retry_set,
6706 (void *)&cmd_set_burst_tx_retry_burst,
6707 (void *)&cmd_set_burst_tx_retry_tx,
6708 (void *)&cmd_set_burst_tx_retry_delay,
6709 (void *)&cmd_set_burst_tx_retry_time,
6710 (void *)&cmd_set_burst_tx_retry_retry,
6711 (void *)&cmd_set_burst_tx_retry_retry_num,
6716 /* *** SET PROMISC MODE *** */
6717 struct cmd_set_promisc_mode_result {
6718 cmdline_fixed_string_t set;
6719 cmdline_fixed_string_t promisc;
6720 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6721 uint16_t port_num; /* valid if "allports" argument == 0 */
6722 cmdline_fixed_string_t mode;
6725 static void cmd_set_promisc_mode_parsed(void *parsed_result,
6726 __rte_unused struct cmdline *cl,
6729 struct cmd_set_promisc_mode_result *res = parsed_result;
6733 if (!strcmp(res->mode, "on"))
6740 RTE_ETH_FOREACH_DEV(i)
6741 eth_set_promisc_mode(i, enable);
6743 eth_set_promisc_mode(res->port_num, enable);
6747 cmdline_parse_token_string_t cmd_setpromisc_set =
6748 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6749 cmdline_parse_token_string_t cmd_setpromisc_promisc =
6750 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6752 cmdline_parse_token_string_t cmd_setpromisc_portall =
6753 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6755 cmdline_parse_token_num_t cmd_setpromisc_portnum =
6756 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6758 cmdline_parse_token_string_t cmd_setpromisc_mode =
6759 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6762 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6763 .f = cmd_set_promisc_mode_parsed,
6765 .help_str = "set promisc all on|off: Set promisc mode for all ports",
6767 (void *)&cmd_setpromisc_set,
6768 (void *)&cmd_setpromisc_promisc,
6769 (void *)&cmd_setpromisc_portall,
6770 (void *)&cmd_setpromisc_mode,
6775 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6776 .f = cmd_set_promisc_mode_parsed,
6778 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6780 (void *)&cmd_setpromisc_set,
6781 (void *)&cmd_setpromisc_promisc,
6782 (void *)&cmd_setpromisc_portnum,
6783 (void *)&cmd_setpromisc_mode,
6788 /* *** SET ALLMULTI MODE *** */
6789 struct cmd_set_allmulti_mode_result {
6790 cmdline_fixed_string_t set;
6791 cmdline_fixed_string_t allmulti;
6792 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6793 uint16_t port_num; /* valid if "allports" argument == 0 */
6794 cmdline_fixed_string_t mode;
6797 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6798 __rte_unused struct cmdline *cl,
6801 struct cmd_set_allmulti_mode_result *res = parsed_result;
6805 if (!strcmp(res->mode, "on"))
6812 RTE_ETH_FOREACH_DEV(i) {
6813 eth_set_allmulticast_mode(i, enable);
6817 eth_set_allmulticast_mode(res->port_num, enable);
6821 cmdline_parse_token_string_t cmd_setallmulti_set =
6822 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6823 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6824 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6826 cmdline_parse_token_string_t cmd_setallmulti_portall =
6827 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6829 cmdline_parse_token_num_t cmd_setallmulti_portnum =
6830 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6832 cmdline_parse_token_string_t cmd_setallmulti_mode =
6833 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6836 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6837 .f = cmd_set_allmulti_mode_parsed,
6839 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6841 (void *)&cmd_setallmulti_set,
6842 (void *)&cmd_setallmulti_allmulti,
6843 (void *)&cmd_setallmulti_portall,
6844 (void *)&cmd_setallmulti_mode,
6849 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6850 .f = cmd_set_allmulti_mode_parsed,
6852 .help_str = "set allmulti <port_id> on|off: "
6853 "Set allmulti mode on port_id",
6855 (void *)&cmd_setallmulti_set,
6856 (void *)&cmd_setallmulti_allmulti,
6857 (void *)&cmd_setallmulti_portnum,
6858 (void *)&cmd_setallmulti_mode,
6863 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
6864 struct cmd_link_flow_ctrl_set_result {
6865 cmdline_fixed_string_t set;
6866 cmdline_fixed_string_t flow_ctrl;
6867 cmdline_fixed_string_t rx;
6868 cmdline_fixed_string_t rx_lfc_mode;
6869 cmdline_fixed_string_t tx;
6870 cmdline_fixed_string_t tx_lfc_mode;
6871 cmdline_fixed_string_t mac_ctrl_frame_fwd;
6872 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
6873 cmdline_fixed_string_t autoneg_str;
6874 cmdline_fixed_string_t autoneg;
6875 cmdline_fixed_string_t hw_str;
6876 uint32_t high_water;
6877 cmdline_fixed_string_t lw_str;
6879 cmdline_fixed_string_t pt_str;
6880 uint16_t pause_time;
6881 cmdline_fixed_string_t xon_str;
6886 cmdline_parse_token_string_t cmd_lfc_set_set =
6887 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6889 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
6890 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6891 flow_ctrl, "flow_ctrl");
6892 cmdline_parse_token_string_t cmd_lfc_set_rx =
6893 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6895 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
6896 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6897 rx_lfc_mode, "on#off");
6898 cmdline_parse_token_string_t cmd_lfc_set_tx =
6899 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6901 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
6902 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6903 tx_lfc_mode, "on#off");
6904 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
6905 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6906 hw_str, "high_water");
6907 cmdline_parse_token_num_t cmd_lfc_set_high_water =
6908 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6909 high_water, RTE_UINT32);
6910 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
6911 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6912 lw_str, "low_water");
6913 cmdline_parse_token_num_t cmd_lfc_set_low_water =
6914 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6915 low_water, RTE_UINT32);
6916 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
6917 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6918 pt_str, "pause_time");
6919 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
6920 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6921 pause_time, RTE_UINT16);
6922 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
6923 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6924 xon_str, "send_xon");
6925 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
6926 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6927 send_xon, RTE_UINT16);
6928 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
6929 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6930 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
6931 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6932 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6933 mac_ctrl_frame_fwd_mode, "on#off");
6934 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6935 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6936 autoneg_str, "autoneg");
6937 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6938 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6940 cmdline_parse_token_num_t cmd_lfc_set_portid =
6941 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6942 port_id, RTE_UINT16);
6944 /* forward declaration */
6946 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6949 cmdline_parse_inst_t cmd_link_flow_control_set = {
6950 .f = cmd_link_flow_ctrl_set_parsed,
6952 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6953 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6954 "autoneg on|off <port_id>: Configure the Ethernet flow control",
6956 (void *)&cmd_lfc_set_set,
6957 (void *)&cmd_lfc_set_flow_ctrl,
6958 (void *)&cmd_lfc_set_rx,
6959 (void *)&cmd_lfc_set_rx_mode,
6960 (void *)&cmd_lfc_set_tx,
6961 (void *)&cmd_lfc_set_tx_mode,
6962 (void *)&cmd_lfc_set_high_water,
6963 (void *)&cmd_lfc_set_low_water,
6964 (void *)&cmd_lfc_set_pause_time,
6965 (void *)&cmd_lfc_set_send_xon,
6966 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6967 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6968 (void *)&cmd_lfc_set_autoneg_str,
6969 (void *)&cmd_lfc_set_autoneg,
6970 (void *)&cmd_lfc_set_portid,
6975 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6976 .f = cmd_link_flow_ctrl_set_parsed,
6977 .data = (void *)&cmd_link_flow_control_set_rx,
6978 .help_str = "set flow_ctrl rx on|off <port_id>: "
6979 "Change rx flow control parameter",
6981 (void *)&cmd_lfc_set_set,
6982 (void *)&cmd_lfc_set_flow_ctrl,
6983 (void *)&cmd_lfc_set_rx,
6984 (void *)&cmd_lfc_set_rx_mode,
6985 (void *)&cmd_lfc_set_portid,
6990 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6991 .f = cmd_link_flow_ctrl_set_parsed,
6992 .data = (void *)&cmd_link_flow_control_set_tx,
6993 .help_str = "set flow_ctrl tx on|off <port_id>: "
6994 "Change tx flow control parameter",
6996 (void *)&cmd_lfc_set_set,
6997 (void *)&cmd_lfc_set_flow_ctrl,
6998 (void *)&cmd_lfc_set_tx,
6999 (void *)&cmd_lfc_set_tx_mode,
7000 (void *)&cmd_lfc_set_portid,
7005 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
7006 .f = cmd_link_flow_ctrl_set_parsed,
7007 .data = (void *)&cmd_link_flow_control_set_hw,
7008 .help_str = "set flow_ctrl high_water <value> <port_id>: "
7009 "Change high water flow control parameter",
7011 (void *)&cmd_lfc_set_set,
7012 (void *)&cmd_lfc_set_flow_ctrl,
7013 (void *)&cmd_lfc_set_high_water_str,
7014 (void *)&cmd_lfc_set_high_water,
7015 (void *)&cmd_lfc_set_portid,
7020 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
7021 .f = cmd_link_flow_ctrl_set_parsed,
7022 .data = (void *)&cmd_link_flow_control_set_lw,
7023 .help_str = "set flow_ctrl low_water <value> <port_id>: "
7024 "Change low water flow control parameter",
7026 (void *)&cmd_lfc_set_set,
7027 (void *)&cmd_lfc_set_flow_ctrl,
7028 (void *)&cmd_lfc_set_low_water_str,
7029 (void *)&cmd_lfc_set_low_water,
7030 (void *)&cmd_lfc_set_portid,
7035 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
7036 .f = cmd_link_flow_ctrl_set_parsed,
7037 .data = (void *)&cmd_link_flow_control_set_pt,
7038 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
7039 "Change pause time flow control parameter",
7041 (void *)&cmd_lfc_set_set,
7042 (void *)&cmd_lfc_set_flow_ctrl,
7043 (void *)&cmd_lfc_set_pause_time_str,
7044 (void *)&cmd_lfc_set_pause_time,
7045 (void *)&cmd_lfc_set_portid,
7050 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
7051 .f = cmd_link_flow_ctrl_set_parsed,
7052 .data = (void *)&cmd_link_flow_control_set_xon,
7053 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
7054 "Change send_xon flow control parameter",
7056 (void *)&cmd_lfc_set_set,
7057 (void *)&cmd_lfc_set_flow_ctrl,
7058 (void *)&cmd_lfc_set_send_xon_str,
7059 (void *)&cmd_lfc_set_send_xon,
7060 (void *)&cmd_lfc_set_portid,
7065 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
7066 .f = cmd_link_flow_ctrl_set_parsed,
7067 .data = (void *)&cmd_link_flow_control_set_macfwd,
7068 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
7069 "Change mac ctrl fwd flow control parameter",
7071 (void *)&cmd_lfc_set_set,
7072 (void *)&cmd_lfc_set_flow_ctrl,
7073 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
7074 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
7075 (void *)&cmd_lfc_set_portid,
7080 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
7081 .f = cmd_link_flow_ctrl_set_parsed,
7082 .data = (void *)&cmd_link_flow_control_set_autoneg,
7083 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
7084 "Change autoneg flow control parameter",
7086 (void *)&cmd_lfc_set_set,
7087 (void *)&cmd_lfc_set_flow_ctrl,
7088 (void *)&cmd_lfc_set_autoneg_str,
7089 (void *)&cmd_lfc_set_autoneg,
7090 (void *)&cmd_lfc_set_portid,
7096 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
7097 __rte_unused struct cmdline *cl,
7100 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
7101 cmdline_parse_inst_t *cmd = data;
7102 struct rte_eth_fc_conf fc_conf;
7108 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7109 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7110 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7111 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7113 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
7114 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7117 /* Partial command line, retrieve current configuration */
7119 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
7121 printf("cannot get current flow ctrl parameters, return"
7122 "code = %d\n", ret);
7126 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
7127 (fc_conf.mode == RTE_FC_FULL))
7129 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
7130 (fc_conf.mode == RTE_FC_FULL))
7134 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
7135 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
7137 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
7138 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
7140 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
7142 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
7143 fc_conf.high_water = res->high_water;
7145 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
7146 fc_conf.low_water = res->low_water;
7148 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
7149 fc_conf.pause_time = res->pause_time;
7151 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
7152 fc_conf.send_xon = res->send_xon;
7154 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
7155 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
7156 fc_conf.mac_ctrl_frame_fwd = 1;
7158 fc_conf.mac_ctrl_frame_fwd = 0;
7161 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
7162 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
7164 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
7166 printf("bad flow contrl parameter, return code = %d \n", ret);
7169 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
7170 struct cmd_priority_flow_ctrl_set_result {
7171 cmdline_fixed_string_t set;
7172 cmdline_fixed_string_t pfc_ctrl;
7173 cmdline_fixed_string_t rx;
7174 cmdline_fixed_string_t rx_pfc_mode;
7175 cmdline_fixed_string_t tx;
7176 cmdline_fixed_string_t tx_pfc_mode;
7177 uint32_t high_water;
7179 uint16_t pause_time;
7185 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
7186 __rte_unused struct cmdline *cl,
7187 __rte_unused void *data)
7189 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
7190 struct rte_eth_pfc_conf pfc_conf;
7191 int rx_fc_enable, tx_fc_enable;
7195 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7196 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7197 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7198 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7200 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
7201 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7204 memset(&pfc_conf, 0, sizeof(struct rte_eth_pfc_conf));
7205 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
7206 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
7207 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
7208 pfc_conf.fc.high_water = res->high_water;
7209 pfc_conf.fc.low_water = res->low_water;
7210 pfc_conf.fc.pause_time = res->pause_time;
7211 pfc_conf.priority = res->priority;
7213 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
7215 printf("bad priority flow contrl parameter, return code = %d \n", ret);
7218 cmdline_parse_token_string_t cmd_pfc_set_set =
7219 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7221 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
7222 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7223 pfc_ctrl, "pfc_ctrl");
7224 cmdline_parse_token_string_t cmd_pfc_set_rx =
7225 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7227 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
7228 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7229 rx_pfc_mode, "on#off");
7230 cmdline_parse_token_string_t cmd_pfc_set_tx =
7231 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7233 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
7234 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7235 tx_pfc_mode, "on#off");
7236 cmdline_parse_token_num_t cmd_pfc_set_high_water =
7237 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7238 high_water, RTE_UINT32);
7239 cmdline_parse_token_num_t cmd_pfc_set_low_water =
7240 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7241 low_water, RTE_UINT32);
7242 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
7243 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7244 pause_time, RTE_UINT16);
7245 cmdline_parse_token_num_t cmd_pfc_set_priority =
7246 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7247 priority, RTE_UINT8);
7248 cmdline_parse_token_num_t cmd_pfc_set_portid =
7249 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7250 port_id, RTE_UINT16);
7252 cmdline_parse_inst_t cmd_priority_flow_control_set = {
7253 .f = cmd_priority_flow_ctrl_set_parsed,
7255 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
7256 "<pause_time> <priority> <port_id>: "
7257 "Configure the Ethernet priority flow control",
7259 (void *)&cmd_pfc_set_set,
7260 (void *)&cmd_pfc_set_flow_ctrl,
7261 (void *)&cmd_pfc_set_rx,
7262 (void *)&cmd_pfc_set_rx_mode,
7263 (void *)&cmd_pfc_set_tx,
7264 (void *)&cmd_pfc_set_tx_mode,
7265 (void *)&cmd_pfc_set_high_water,
7266 (void *)&cmd_pfc_set_low_water,
7267 (void *)&cmd_pfc_set_pause_time,
7268 (void *)&cmd_pfc_set_priority,
7269 (void *)&cmd_pfc_set_portid,
7274 /* *** RESET CONFIGURATION *** */
7275 struct cmd_reset_result {
7276 cmdline_fixed_string_t reset;
7277 cmdline_fixed_string_t def;
7280 static void cmd_reset_parsed(__rte_unused void *parsed_result,
7282 __rte_unused void *data)
7284 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
7285 set_def_fwd_config();
7288 cmdline_parse_token_string_t cmd_reset_set =
7289 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
7290 cmdline_parse_token_string_t cmd_reset_def =
7291 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
7294 cmdline_parse_inst_t cmd_reset = {
7295 .f = cmd_reset_parsed,
7297 .help_str = "set default: Reset default forwarding configuration",
7299 (void *)&cmd_reset_set,
7300 (void *)&cmd_reset_def,
7305 /* *** START FORWARDING *** */
7306 struct cmd_start_result {
7307 cmdline_fixed_string_t start;
7310 cmdline_parse_token_string_t cmd_start_start =
7311 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
7313 static void cmd_start_parsed(__rte_unused void *parsed_result,
7314 __rte_unused struct cmdline *cl,
7315 __rte_unused void *data)
7317 start_packet_forwarding(0);
7320 cmdline_parse_inst_t cmd_start = {
7321 .f = cmd_start_parsed,
7323 .help_str = "start: Start packet forwarding",
7325 (void *)&cmd_start_start,
7330 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7331 struct cmd_start_tx_first_result {
7332 cmdline_fixed_string_t start;
7333 cmdline_fixed_string_t tx_first;
7337 cmd_start_tx_first_parsed(__rte_unused void *parsed_result,
7338 __rte_unused struct cmdline *cl,
7339 __rte_unused void *data)
7341 start_packet_forwarding(1);
7344 cmdline_parse_token_string_t cmd_start_tx_first_start =
7345 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7347 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7348 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7349 tx_first, "tx_first");
7351 cmdline_parse_inst_t cmd_start_tx_first = {
7352 .f = cmd_start_tx_first_parsed,
7354 .help_str = "start tx_first: Start packet forwarding, "
7355 "after sending 1 burst of packets",
7357 (void *)&cmd_start_tx_first_start,
7358 (void *)&cmd_start_tx_first_tx_first,
7363 /* *** START FORWARDING WITH N TX BURST FIRST *** */
7364 struct cmd_start_tx_first_n_result {
7365 cmdline_fixed_string_t start;
7366 cmdline_fixed_string_t tx_first;
7371 cmd_start_tx_first_n_parsed(void *parsed_result,
7372 __rte_unused struct cmdline *cl,
7373 __rte_unused void *data)
7375 struct cmd_start_tx_first_n_result *res = parsed_result;
7377 start_packet_forwarding(res->tx_num);
7380 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7381 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7383 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7384 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7385 tx_first, "tx_first");
7386 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7387 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7388 tx_num, RTE_UINT32);
7390 cmdline_parse_inst_t cmd_start_tx_first_n = {
7391 .f = cmd_start_tx_first_n_parsed,
7393 .help_str = "start tx_first <num>: "
7394 "packet forwarding, after sending <num> bursts of packets",
7396 (void *)&cmd_start_tx_first_n_start,
7397 (void *)&cmd_start_tx_first_n_tx_first,
7398 (void *)&cmd_start_tx_first_n_tx_num,
7403 /* *** SET LINK UP *** */
7404 struct cmd_set_link_up_result {
7405 cmdline_fixed_string_t set;
7406 cmdline_fixed_string_t link_up;
7407 cmdline_fixed_string_t port;
7411 cmdline_parse_token_string_t cmd_set_link_up_set =
7412 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7413 cmdline_parse_token_string_t cmd_set_link_up_link_up =
7414 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7416 cmdline_parse_token_string_t cmd_set_link_up_port =
7417 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7418 cmdline_parse_token_num_t cmd_set_link_up_port_id =
7419 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id,
7422 static void cmd_set_link_up_parsed(__rte_unused void *parsed_result,
7423 __rte_unused struct cmdline *cl,
7424 __rte_unused void *data)
7426 struct cmd_set_link_up_result *res = parsed_result;
7427 dev_set_link_up(res->port_id);
7430 cmdline_parse_inst_t cmd_set_link_up = {
7431 .f = cmd_set_link_up_parsed,
7433 .help_str = "set link-up port <port id>",
7435 (void *)&cmd_set_link_up_set,
7436 (void *)&cmd_set_link_up_link_up,
7437 (void *)&cmd_set_link_up_port,
7438 (void *)&cmd_set_link_up_port_id,
7443 /* *** SET LINK DOWN *** */
7444 struct cmd_set_link_down_result {
7445 cmdline_fixed_string_t set;
7446 cmdline_fixed_string_t link_down;
7447 cmdline_fixed_string_t port;
7451 cmdline_parse_token_string_t cmd_set_link_down_set =
7452 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
7453 cmdline_parse_token_string_t cmd_set_link_down_link_down =
7454 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
7456 cmdline_parse_token_string_t cmd_set_link_down_port =
7457 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
7458 cmdline_parse_token_num_t cmd_set_link_down_port_id =
7459 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id,
7462 static void cmd_set_link_down_parsed(
7463 __rte_unused void *parsed_result,
7464 __rte_unused struct cmdline *cl,
7465 __rte_unused void *data)
7467 struct cmd_set_link_down_result *res = parsed_result;
7468 dev_set_link_down(res->port_id);
7471 cmdline_parse_inst_t cmd_set_link_down = {
7472 .f = cmd_set_link_down_parsed,
7474 .help_str = "set link-down port <port id>",
7476 (void *)&cmd_set_link_down_set,
7477 (void *)&cmd_set_link_down_link_down,
7478 (void *)&cmd_set_link_down_port,
7479 (void *)&cmd_set_link_down_port_id,
7484 /* *** SHOW CFG *** */
7485 struct cmd_showcfg_result {
7486 cmdline_fixed_string_t show;
7487 cmdline_fixed_string_t cfg;
7488 cmdline_fixed_string_t what;
7491 static void cmd_showcfg_parsed(void *parsed_result,
7492 __rte_unused struct cmdline *cl,
7493 __rte_unused void *data)
7495 struct cmd_showcfg_result *res = parsed_result;
7496 if (!strcmp(res->what, "rxtx"))
7497 rxtx_config_display();
7498 else if (!strcmp(res->what, "cores"))
7499 fwd_lcores_config_display();
7500 else if (!strcmp(res->what, "fwd"))
7501 pkt_fwd_config_display(&cur_fwd_config);
7502 else if (!strcmp(res->what, "rxoffs"))
7503 show_rx_pkt_offsets();
7504 else if (!strcmp(res->what, "rxpkts"))
7505 show_rx_pkt_segments();
7506 else if (!strcmp(res->what, "txpkts"))
7507 show_tx_pkt_segments();
7508 else if (!strcmp(res->what, "txtimes"))
7509 show_tx_pkt_times();
7512 cmdline_parse_token_string_t cmd_showcfg_show =
7513 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7514 cmdline_parse_token_string_t cmd_showcfg_port =
7515 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7516 cmdline_parse_token_string_t cmd_showcfg_what =
7517 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7518 "rxtx#cores#fwd#rxoffs#rxpkts#txpkts#txtimes");
7520 cmdline_parse_inst_t cmd_showcfg = {
7521 .f = cmd_showcfg_parsed,
7523 .help_str = "show config rxtx|cores|fwd|rxoffs|rxpkts|txpkts|txtimes",
7525 (void *)&cmd_showcfg_show,
7526 (void *)&cmd_showcfg_port,
7527 (void *)&cmd_showcfg_what,
7532 /* *** SHOW ALL PORT INFO *** */
7533 struct cmd_showportall_result {
7534 cmdline_fixed_string_t show;
7535 cmdline_fixed_string_t port;
7536 cmdline_fixed_string_t what;
7537 cmdline_fixed_string_t all;
7540 static void cmd_showportall_parsed(void *parsed_result,
7541 __rte_unused struct cmdline *cl,
7542 __rte_unused void *data)
7546 struct cmd_showportall_result *res = parsed_result;
7547 if (!strcmp(res->show, "clear")) {
7548 if (!strcmp(res->what, "stats"))
7549 RTE_ETH_FOREACH_DEV(i)
7551 else if (!strcmp(res->what, "xstats"))
7552 RTE_ETH_FOREACH_DEV(i)
7553 nic_xstats_clear(i);
7554 } else if (!strcmp(res->what, "info"))
7555 RTE_ETH_FOREACH_DEV(i)
7556 port_infos_display(i);
7557 else if (!strcmp(res->what, "summary")) {
7558 port_summary_header_display();
7559 RTE_ETH_FOREACH_DEV(i)
7560 port_summary_display(i);
7562 else if (!strcmp(res->what, "stats"))
7563 RTE_ETH_FOREACH_DEV(i)
7564 nic_stats_display(i);
7565 else if (!strcmp(res->what, "xstats"))
7566 RTE_ETH_FOREACH_DEV(i)
7567 nic_xstats_display(i);
7568 #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
7569 else if (!strcmp(res->what, "fdir"))
7570 RTE_ETH_FOREACH_DEV(i)
7573 else if (!strcmp(res->what, "dcb_tc"))
7574 RTE_ETH_FOREACH_DEV(i)
7575 port_dcb_info_display(i);
7578 cmdline_parse_token_string_t cmd_showportall_show =
7579 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7581 cmdline_parse_token_string_t cmd_showportall_port =
7582 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7583 cmdline_parse_token_string_t cmd_showportall_what =
7584 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7585 "info#summary#stats#xstats#fdir#dcb_tc");
7586 cmdline_parse_token_string_t cmd_showportall_all =
7587 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7588 cmdline_parse_inst_t cmd_showportall = {
7589 .f = cmd_showportall_parsed,
7591 .help_str = "show|clear port "
7592 "info|summary|stats|xstats|fdir|dcb_tc all",
7594 (void *)&cmd_showportall_show,
7595 (void *)&cmd_showportall_port,
7596 (void *)&cmd_showportall_what,
7597 (void *)&cmd_showportall_all,
7602 /* *** SHOW PORT INFO *** */
7603 struct cmd_showport_result {
7604 cmdline_fixed_string_t show;
7605 cmdline_fixed_string_t port;
7606 cmdline_fixed_string_t what;
7610 static void cmd_showport_parsed(void *parsed_result,
7611 __rte_unused struct cmdline *cl,
7612 __rte_unused void *data)
7614 struct cmd_showport_result *res = parsed_result;
7615 if (!strcmp(res->show, "clear")) {
7616 if (!strcmp(res->what, "stats"))
7617 nic_stats_clear(res->portnum);
7618 else if (!strcmp(res->what, "xstats"))
7619 nic_xstats_clear(res->portnum);
7620 } else if (!strcmp(res->what, "info"))
7621 port_infos_display(res->portnum);
7622 else if (!strcmp(res->what, "summary")) {
7623 port_summary_header_display();
7624 port_summary_display(res->portnum);
7626 else if (!strcmp(res->what, "stats"))
7627 nic_stats_display(res->portnum);
7628 else if (!strcmp(res->what, "xstats"))
7629 nic_xstats_display(res->portnum);
7630 #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
7631 else if (!strcmp(res->what, "fdir"))
7632 fdir_get_infos(res->portnum);
7634 else if (!strcmp(res->what, "dcb_tc"))
7635 port_dcb_info_display(res->portnum);
7638 cmdline_parse_token_string_t cmd_showport_show =
7639 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7641 cmdline_parse_token_string_t cmd_showport_port =
7642 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7643 cmdline_parse_token_string_t cmd_showport_what =
7644 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7645 "info#summary#stats#xstats#fdir#dcb_tc");
7646 cmdline_parse_token_num_t cmd_showport_portnum =
7647 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, RTE_UINT16);
7649 cmdline_parse_inst_t cmd_showport = {
7650 .f = cmd_showport_parsed,
7652 .help_str = "show|clear port "
7653 "info|summary|stats|xstats|fdir|dcb_tc "
7656 (void *)&cmd_showport_show,
7657 (void *)&cmd_showport_port,
7658 (void *)&cmd_showport_what,
7659 (void *)&cmd_showport_portnum,
7664 /* *** SHOW DEVICE INFO *** */
7665 struct cmd_showdevice_result {
7666 cmdline_fixed_string_t show;
7667 cmdline_fixed_string_t device;
7668 cmdline_fixed_string_t what;
7669 cmdline_fixed_string_t identifier;
7672 static void cmd_showdevice_parsed(void *parsed_result,
7673 __rte_unused struct cmdline *cl,
7674 __rte_unused void *data)
7676 struct cmd_showdevice_result *res = parsed_result;
7677 if (!strcmp(res->what, "info")) {
7678 if (!strcmp(res->identifier, "all"))
7679 device_infos_display(NULL);
7681 device_infos_display(res->identifier);
7685 cmdline_parse_token_string_t cmd_showdevice_show =
7686 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show,
7688 cmdline_parse_token_string_t cmd_showdevice_device =
7689 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device");
7690 cmdline_parse_token_string_t cmd_showdevice_what =
7691 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what,
7693 cmdline_parse_token_string_t cmd_showdevice_identifier =
7694 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result,
7697 cmdline_parse_inst_t cmd_showdevice = {
7698 .f = cmd_showdevice_parsed,
7700 .help_str = "show device info <identifier>|all",
7702 (void *)&cmd_showdevice_show,
7703 (void *)&cmd_showdevice_device,
7704 (void *)&cmd_showdevice_what,
7705 (void *)&cmd_showdevice_identifier,
7710 /* *** SHOW MODULE EEPROM/EEPROM port INFO *** */
7711 struct cmd_showeeprom_result {
7712 cmdline_fixed_string_t show;
7713 cmdline_fixed_string_t port;
7715 cmdline_fixed_string_t type;
7718 static void cmd_showeeprom_parsed(void *parsed_result,
7719 __rte_unused struct cmdline *cl,
7720 __rte_unused void *data)
7722 struct cmd_showeeprom_result *res = parsed_result;
7724 if (!strcmp(res->type, "eeprom"))
7725 port_eeprom_display(res->portnum);
7726 else if (!strcmp(res->type, "module_eeprom"))
7727 port_module_eeprom_display(res->portnum);
7729 printf("Unknown argument\n");
7732 cmdline_parse_token_string_t cmd_showeeprom_show =
7733 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, show, "show");
7734 cmdline_parse_token_string_t cmd_showeeprom_port =
7735 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, port, "port");
7736 cmdline_parse_token_num_t cmd_showeeprom_portnum =
7737 TOKEN_NUM_INITIALIZER(struct cmd_showeeprom_result, portnum,
7739 cmdline_parse_token_string_t cmd_showeeprom_type =
7740 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, type, "module_eeprom#eeprom");
7742 cmdline_parse_inst_t cmd_showeeprom = {
7743 .f = cmd_showeeprom_parsed,
7745 .help_str = "show port <port_id> module_eeprom|eeprom",
7747 (void *)&cmd_showeeprom_show,
7748 (void *)&cmd_showeeprom_port,
7749 (void *)&cmd_showeeprom_portnum,
7750 (void *)&cmd_showeeprom_type,
7755 /* *** SHOW QUEUE INFO *** */
7756 struct cmd_showqueue_result {
7757 cmdline_fixed_string_t show;
7758 cmdline_fixed_string_t type;
7759 cmdline_fixed_string_t what;
7765 cmd_showqueue_parsed(void *parsed_result,
7766 __rte_unused struct cmdline *cl,
7767 __rte_unused void *data)
7769 struct cmd_showqueue_result *res = parsed_result;
7771 if (!strcmp(res->type, "rxq"))
7772 rx_queue_infos_display(res->portnum, res->queuenum);
7773 else if (!strcmp(res->type, "txq"))
7774 tx_queue_infos_display(res->portnum, res->queuenum);
7777 cmdline_parse_token_string_t cmd_showqueue_show =
7778 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
7779 cmdline_parse_token_string_t cmd_showqueue_type =
7780 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
7781 cmdline_parse_token_string_t cmd_showqueue_what =
7782 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
7783 cmdline_parse_token_num_t cmd_showqueue_portnum =
7784 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum,
7786 cmdline_parse_token_num_t cmd_showqueue_queuenum =
7787 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum,
7790 cmdline_parse_inst_t cmd_showqueue = {
7791 .f = cmd_showqueue_parsed,
7793 .help_str = "show rxq|txq info <port_id> <queue_id>",
7795 (void *)&cmd_showqueue_show,
7796 (void *)&cmd_showqueue_type,
7797 (void *)&cmd_showqueue_what,
7798 (void *)&cmd_showqueue_portnum,
7799 (void *)&cmd_showqueue_queuenum,
7804 /* show/clear fwd engine statistics */
7806 cmdline_fixed_string_t action;
7807 cmdline_fixed_string_t fwd;
7808 cmdline_fixed_string_t stats;
7809 cmdline_fixed_string_t all;
7812 cmdline_parse_token_string_t cmd_fwd_action =
7813 TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
7814 cmdline_parse_token_string_t cmd_fwd_fwd =
7815 TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
7816 cmdline_parse_token_string_t cmd_fwd_stats =
7817 TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
7818 cmdline_parse_token_string_t cmd_fwd_all =
7819 TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
7822 cmd_showfwdall_parsed(void *parsed_result,
7823 __rte_unused struct cmdline *cl,
7824 __rte_unused void *data)
7826 struct fwd_result *res = parsed_result;
7828 if (!strcmp(res->action, "show"))
7829 fwd_stats_display();
7834 static cmdline_parse_inst_t cmd_showfwdall = {
7835 .f = cmd_showfwdall_parsed,
7837 .help_str = "show|clear fwd stats all",
7839 (void *)&cmd_fwd_action,
7840 (void *)&cmd_fwd_fwd,
7841 (void *)&cmd_fwd_stats,
7842 (void *)&cmd_fwd_all,
7847 /* *** READ PORT REGISTER *** */
7848 struct cmd_read_reg_result {
7849 cmdline_fixed_string_t read;
7850 cmdline_fixed_string_t reg;
7856 cmd_read_reg_parsed(void *parsed_result,
7857 __rte_unused struct cmdline *cl,
7858 __rte_unused void *data)
7860 struct cmd_read_reg_result *res = parsed_result;
7861 port_reg_display(res->port_id, res->reg_off);
7864 cmdline_parse_token_string_t cmd_read_reg_read =
7865 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
7866 cmdline_parse_token_string_t cmd_read_reg_reg =
7867 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
7868 cmdline_parse_token_num_t cmd_read_reg_port_id =
7869 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, RTE_UINT16);
7870 cmdline_parse_token_num_t cmd_read_reg_reg_off =
7871 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, RTE_UINT32);
7873 cmdline_parse_inst_t cmd_read_reg = {
7874 .f = cmd_read_reg_parsed,
7876 .help_str = "read reg <port_id> <reg_off>",
7878 (void *)&cmd_read_reg_read,
7879 (void *)&cmd_read_reg_reg,
7880 (void *)&cmd_read_reg_port_id,
7881 (void *)&cmd_read_reg_reg_off,
7886 /* *** READ PORT REGISTER BIT FIELD *** */
7887 struct cmd_read_reg_bit_field_result {
7888 cmdline_fixed_string_t read;
7889 cmdline_fixed_string_t regfield;
7897 cmd_read_reg_bit_field_parsed(void *parsed_result,
7898 __rte_unused struct cmdline *cl,
7899 __rte_unused void *data)
7901 struct cmd_read_reg_bit_field_result *res = parsed_result;
7902 port_reg_bit_field_display(res->port_id, res->reg_off,
7903 res->bit1_pos, res->bit2_pos);
7906 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
7907 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
7909 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
7910 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
7911 regfield, "regfield");
7912 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
7913 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
7915 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
7916 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
7918 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
7919 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
7921 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
7922 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
7925 cmdline_parse_inst_t cmd_read_reg_bit_field = {
7926 .f = cmd_read_reg_bit_field_parsed,
7928 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
7929 "Read register bit field between bit_x and bit_y included",
7931 (void *)&cmd_read_reg_bit_field_read,
7932 (void *)&cmd_read_reg_bit_field_regfield,
7933 (void *)&cmd_read_reg_bit_field_port_id,
7934 (void *)&cmd_read_reg_bit_field_reg_off,
7935 (void *)&cmd_read_reg_bit_field_bit1_pos,
7936 (void *)&cmd_read_reg_bit_field_bit2_pos,
7941 /* *** READ PORT REGISTER BIT *** */
7942 struct cmd_read_reg_bit_result {
7943 cmdline_fixed_string_t read;
7944 cmdline_fixed_string_t regbit;
7951 cmd_read_reg_bit_parsed(void *parsed_result,
7952 __rte_unused struct cmdline *cl,
7953 __rte_unused void *data)
7955 struct cmd_read_reg_bit_result *res = parsed_result;
7956 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
7959 cmdline_parse_token_string_t cmd_read_reg_bit_read =
7960 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
7961 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
7962 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
7964 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
7965 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id,
7967 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
7968 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off,
7970 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
7971 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos,
7974 cmdline_parse_inst_t cmd_read_reg_bit = {
7975 .f = cmd_read_reg_bit_parsed,
7977 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
7979 (void *)&cmd_read_reg_bit_read,
7980 (void *)&cmd_read_reg_bit_regbit,
7981 (void *)&cmd_read_reg_bit_port_id,
7982 (void *)&cmd_read_reg_bit_reg_off,
7983 (void *)&cmd_read_reg_bit_bit_pos,
7988 /* *** WRITE PORT REGISTER *** */
7989 struct cmd_write_reg_result {
7990 cmdline_fixed_string_t write;
7991 cmdline_fixed_string_t reg;
7998 cmd_write_reg_parsed(void *parsed_result,
7999 __rte_unused struct cmdline *cl,
8000 __rte_unused void *data)
8002 struct cmd_write_reg_result *res = parsed_result;
8003 port_reg_set(res->port_id, res->reg_off, res->value);
8006 cmdline_parse_token_string_t cmd_write_reg_write =
8007 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
8008 cmdline_parse_token_string_t cmd_write_reg_reg =
8009 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
8010 cmdline_parse_token_num_t cmd_write_reg_port_id =
8011 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, RTE_UINT16);
8012 cmdline_parse_token_num_t cmd_write_reg_reg_off =
8013 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, RTE_UINT32);
8014 cmdline_parse_token_num_t cmd_write_reg_value =
8015 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, RTE_UINT32);
8017 cmdline_parse_inst_t cmd_write_reg = {
8018 .f = cmd_write_reg_parsed,
8020 .help_str = "write reg <port_id> <reg_off> <reg_value>",
8022 (void *)&cmd_write_reg_write,
8023 (void *)&cmd_write_reg_reg,
8024 (void *)&cmd_write_reg_port_id,
8025 (void *)&cmd_write_reg_reg_off,
8026 (void *)&cmd_write_reg_value,
8031 /* *** WRITE PORT REGISTER BIT FIELD *** */
8032 struct cmd_write_reg_bit_field_result {
8033 cmdline_fixed_string_t write;
8034 cmdline_fixed_string_t regfield;
8043 cmd_write_reg_bit_field_parsed(void *parsed_result,
8044 __rte_unused struct cmdline *cl,
8045 __rte_unused void *data)
8047 struct cmd_write_reg_bit_field_result *res = parsed_result;
8048 port_reg_bit_field_set(res->port_id, res->reg_off,
8049 res->bit1_pos, res->bit2_pos, res->value);
8052 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
8053 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
8055 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
8056 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
8057 regfield, "regfield");
8058 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
8059 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
8061 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
8062 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
8064 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
8065 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
8067 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
8068 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
8070 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
8071 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
8074 cmdline_parse_inst_t cmd_write_reg_bit_field = {
8075 .f = cmd_write_reg_bit_field_parsed,
8077 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
8079 "Set register bit field between bit_x and bit_y included",
8081 (void *)&cmd_write_reg_bit_field_write,
8082 (void *)&cmd_write_reg_bit_field_regfield,
8083 (void *)&cmd_write_reg_bit_field_port_id,
8084 (void *)&cmd_write_reg_bit_field_reg_off,
8085 (void *)&cmd_write_reg_bit_field_bit1_pos,
8086 (void *)&cmd_write_reg_bit_field_bit2_pos,
8087 (void *)&cmd_write_reg_bit_field_value,
8092 /* *** WRITE PORT REGISTER BIT *** */
8093 struct cmd_write_reg_bit_result {
8094 cmdline_fixed_string_t write;
8095 cmdline_fixed_string_t regbit;
8103 cmd_write_reg_bit_parsed(void *parsed_result,
8104 __rte_unused struct cmdline *cl,
8105 __rte_unused void *data)
8107 struct cmd_write_reg_bit_result *res = parsed_result;
8108 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
8111 cmdline_parse_token_string_t cmd_write_reg_bit_write =
8112 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
8114 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
8115 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
8117 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
8118 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id,
8120 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
8121 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off,
8123 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
8124 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos,
8126 cmdline_parse_token_num_t cmd_write_reg_bit_value =
8127 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value,
8130 cmdline_parse_inst_t cmd_write_reg_bit = {
8131 .f = cmd_write_reg_bit_parsed,
8133 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
8136 (void *)&cmd_write_reg_bit_write,
8137 (void *)&cmd_write_reg_bit_regbit,
8138 (void *)&cmd_write_reg_bit_port_id,
8139 (void *)&cmd_write_reg_bit_reg_off,
8140 (void *)&cmd_write_reg_bit_bit_pos,
8141 (void *)&cmd_write_reg_bit_value,
8146 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
8147 struct cmd_read_rxd_txd_result {
8148 cmdline_fixed_string_t read;
8149 cmdline_fixed_string_t rxd_txd;
8156 cmd_read_rxd_txd_parsed(void *parsed_result,
8157 __rte_unused struct cmdline *cl,
8158 __rte_unused void *data)
8160 struct cmd_read_rxd_txd_result *res = parsed_result;
8162 if (!strcmp(res->rxd_txd, "rxd"))
8163 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8164 else if (!strcmp(res->rxd_txd, "txd"))
8165 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8168 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
8169 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
8170 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
8171 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
8173 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
8174 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id,
8176 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
8177 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id,
8179 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
8180 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id,
8183 cmdline_parse_inst_t cmd_read_rxd_txd = {
8184 .f = cmd_read_rxd_txd_parsed,
8186 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
8188 (void *)&cmd_read_rxd_txd_read,
8189 (void *)&cmd_read_rxd_txd_rxd_txd,
8190 (void *)&cmd_read_rxd_txd_port_id,
8191 (void *)&cmd_read_rxd_txd_queue_id,
8192 (void *)&cmd_read_rxd_txd_desc_id,
8198 struct cmd_quit_result {
8199 cmdline_fixed_string_t quit;
8202 static void cmd_quit_parsed(__rte_unused void *parsed_result,
8204 __rte_unused void *data)
8209 cmdline_parse_token_string_t cmd_quit_quit =
8210 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
8212 cmdline_parse_inst_t cmd_quit = {
8213 .f = cmd_quit_parsed,
8215 .help_str = "quit: Exit application",
8217 (void *)&cmd_quit_quit,
8222 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
8223 struct cmd_mac_addr_result {
8224 cmdline_fixed_string_t mac_addr_cmd;
8225 cmdline_fixed_string_t what;
8227 struct rte_ether_addr address;
8230 static void cmd_mac_addr_parsed(void *parsed_result,
8231 __rte_unused struct cmdline *cl,
8232 __rte_unused void *data)
8234 struct cmd_mac_addr_result *res = parsed_result;
8237 if (strcmp(res->what, "add") == 0)
8238 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
8239 else if (strcmp(res->what, "set") == 0)
8240 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
8243 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
8245 /* check the return value and print it if is < 0 */
8247 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
8251 cmdline_parse_token_string_t cmd_mac_addr_cmd =
8252 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
8254 cmdline_parse_token_string_t cmd_mac_addr_what =
8255 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
8257 cmdline_parse_token_num_t cmd_mac_addr_portnum =
8258 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
8260 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
8261 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
8263 cmdline_parse_inst_t cmd_mac_addr = {
8264 .f = cmd_mac_addr_parsed,
8266 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
8267 "Add/Remove/Set MAC address on port_id",
8269 (void *)&cmd_mac_addr_cmd,
8270 (void *)&cmd_mac_addr_what,
8271 (void *)&cmd_mac_addr_portnum,
8272 (void *)&cmd_mac_addr_addr,
8277 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
8278 struct cmd_eth_peer_result {
8279 cmdline_fixed_string_t set;
8280 cmdline_fixed_string_t eth_peer;
8282 cmdline_fixed_string_t peer_addr;
8285 static void cmd_set_eth_peer_parsed(void *parsed_result,
8286 __rte_unused struct cmdline *cl,
8287 __rte_unused void *data)
8289 struct cmd_eth_peer_result *res = parsed_result;
8291 if (test_done == 0) {
8292 printf("Please stop forwarding first\n");
8295 if (!strcmp(res->eth_peer, "eth-peer")) {
8296 set_fwd_eth_peer(res->port_id, res->peer_addr);
8300 cmdline_parse_token_string_t cmd_eth_peer_set =
8301 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
8302 cmdline_parse_token_string_t cmd_eth_peer =
8303 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
8304 cmdline_parse_token_num_t cmd_eth_peer_port_id =
8305 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id,
8307 cmdline_parse_token_string_t cmd_eth_peer_addr =
8308 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
8310 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
8311 .f = cmd_set_eth_peer_parsed,
8313 .help_str = "set eth-peer <port_id> <peer_mac>",
8315 (void *)&cmd_eth_peer_set,
8316 (void *)&cmd_eth_peer,
8317 (void *)&cmd_eth_peer_port_id,
8318 (void *)&cmd_eth_peer_addr,
8323 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
8324 struct cmd_set_qmap_result {
8325 cmdline_fixed_string_t set;
8326 cmdline_fixed_string_t qmap;
8327 cmdline_fixed_string_t what;
8334 cmd_set_qmap_parsed(void *parsed_result,
8335 __rte_unused struct cmdline *cl,
8336 __rte_unused void *data)
8338 struct cmd_set_qmap_result *res = parsed_result;
8339 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
8341 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
8344 cmdline_parse_token_string_t cmd_setqmap_set =
8345 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8347 cmdline_parse_token_string_t cmd_setqmap_qmap =
8348 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8350 cmdline_parse_token_string_t cmd_setqmap_what =
8351 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8353 cmdline_parse_token_num_t cmd_setqmap_portid =
8354 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8355 port_id, RTE_UINT16);
8356 cmdline_parse_token_num_t cmd_setqmap_queueid =
8357 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8358 queue_id, RTE_UINT16);
8359 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
8360 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8361 map_value, RTE_UINT8);
8363 cmdline_parse_inst_t cmd_set_qmap = {
8364 .f = cmd_set_qmap_parsed,
8366 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
8367 "Set statistics mapping value on tx|rx queue_id of port_id",
8369 (void *)&cmd_setqmap_set,
8370 (void *)&cmd_setqmap_qmap,
8371 (void *)&cmd_setqmap_what,
8372 (void *)&cmd_setqmap_portid,
8373 (void *)&cmd_setqmap_queueid,
8374 (void *)&cmd_setqmap_mapvalue,
8379 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
8380 struct cmd_set_xstats_hide_zero_result {
8381 cmdline_fixed_string_t keyword;
8382 cmdline_fixed_string_t name;
8383 cmdline_fixed_string_t on_off;
8387 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
8388 __rte_unused struct cmdline *cl,
8389 __rte_unused void *data)
8391 struct cmd_set_xstats_hide_zero_result *res;
8392 uint16_t on_off = 0;
8394 res = parsed_result;
8395 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8396 set_xstats_hide_zero(on_off);
8399 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
8400 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8402 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
8403 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8404 name, "xstats-hide-zero");
8405 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
8406 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8409 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
8410 .f = cmd_set_xstats_hide_zero_parsed,
8412 .help_str = "set xstats-hide-zero on|off",
8414 (void *)&cmd_set_xstats_hide_zero_keyword,
8415 (void *)&cmd_set_xstats_hide_zero_name,
8416 (void *)&cmd_set_xstats_hide_zero_on_off,
8421 /* *** SET OPTION TO ENABLE MEASUREMENT OF CPU CYCLES *** */
8422 struct cmd_set_record_core_cycles_result {
8423 cmdline_fixed_string_t keyword;
8424 cmdline_fixed_string_t name;
8425 cmdline_fixed_string_t on_off;
8429 cmd_set_record_core_cycles_parsed(void *parsed_result,
8430 __rte_unused struct cmdline *cl,
8431 __rte_unused void *data)
8433 struct cmd_set_record_core_cycles_result *res;
8434 uint16_t on_off = 0;
8436 res = parsed_result;
8437 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8438 set_record_core_cycles(on_off);
8441 cmdline_parse_token_string_t cmd_set_record_core_cycles_keyword =
8442 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8444 cmdline_parse_token_string_t cmd_set_record_core_cycles_name =
8445 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8446 name, "record-core-cycles");
8447 cmdline_parse_token_string_t cmd_set_record_core_cycles_on_off =
8448 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8451 cmdline_parse_inst_t cmd_set_record_core_cycles = {
8452 .f = cmd_set_record_core_cycles_parsed,
8454 .help_str = "set record-core-cycles on|off",
8456 (void *)&cmd_set_record_core_cycles_keyword,
8457 (void *)&cmd_set_record_core_cycles_name,
8458 (void *)&cmd_set_record_core_cycles_on_off,
8463 /* *** SET OPTION TO ENABLE DISPLAY OF RX AND TX BURSTS *** */
8464 struct cmd_set_record_burst_stats_result {
8465 cmdline_fixed_string_t keyword;
8466 cmdline_fixed_string_t name;
8467 cmdline_fixed_string_t on_off;
8471 cmd_set_record_burst_stats_parsed(void *parsed_result,
8472 __rte_unused struct cmdline *cl,
8473 __rte_unused void *data)
8475 struct cmd_set_record_burst_stats_result *res;
8476 uint16_t on_off = 0;
8478 res = parsed_result;
8479 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8480 set_record_burst_stats(on_off);
8483 cmdline_parse_token_string_t cmd_set_record_burst_stats_keyword =
8484 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8486 cmdline_parse_token_string_t cmd_set_record_burst_stats_name =
8487 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8488 name, "record-burst-stats");
8489 cmdline_parse_token_string_t cmd_set_record_burst_stats_on_off =
8490 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8493 cmdline_parse_inst_t cmd_set_record_burst_stats = {
8494 .f = cmd_set_record_burst_stats_parsed,
8496 .help_str = "set record-burst-stats on|off",
8498 (void *)&cmd_set_record_burst_stats_keyword,
8499 (void *)&cmd_set_record_burst_stats_name,
8500 (void *)&cmd_set_record_burst_stats_on_off,
8505 /* *** CONFIGURE UNICAST HASH TABLE *** */
8506 struct cmd_set_uc_hash_table {
8507 cmdline_fixed_string_t set;
8508 cmdline_fixed_string_t port;
8510 cmdline_fixed_string_t what;
8511 struct rte_ether_addr address;
8512 cmdline_fixed_string_t mode;
8516 cmd_set_uc_hash_parsed(void *parsed_result,
8517 __rte_unused struct cmdline *cl,
8518 __rte_unused void *data)
8521 struct cmd_set_uc_hash_table *res = parsed_result;
8523 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8525 if (strcmp(res->what, "uta") == 0)
8526 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
8527 &res->address,(uint8_t)is_on);
8529 printf("bad unicast hash table parameter, return code = %d \n", ret);
8533 cmdline_parse_token_string_t cmd_set_uc_hash_set =
8534 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8536 cmdline_parse_token_string_t cmd_set_uc_hash_port =
8537 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8539 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
8540 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
8541 port_id, RTE_UINT16);
8542 cmdline_parse_token_string_t cmd_set_uc_hash_what =
8543 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8545 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
8546 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
8548 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
8549 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8552 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
8553 .f = cmd_set_uc_hash_parsed,
8555 .help_str = "set port <port_id> uta <mac_addr> on|off)",
8557 (void *)&cmd_set_uc_hash_set,
8558 (void *)&cmd_set_uc_hash_port,
8559 (void *)&cmd_set_uc_hash_portid,
8560 (void *)&cmd_set_uc_hash_what,
8561 (void *)&cmd_set_uc_hash_mac,
8562 (void *)&cmd_set_uc_hash_mode,
8567 struct cmd_set_uc_all_hash_table {
8568 cmdline_fixed_string_t set;
8569 cmdline_fixed_string_t port;
8571 cmdline_fixed_string_t what;
8572 cmdline_fixed_string_t value;
8573 cmdline_fixed_string_t mode;
8577 cmd_set_uc_all_hash_parsed(void *parsed_result,
8578 __rte_unused struct cmdline *cl,
8579 __rte_unused void *data)
8582 struct cmd_set_uc_all_hash_table *res = parsed_result;
8584 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8586 if ((strcmp(res->what, "uta") == 0) &&
8587 (strcmp(res->value, "all") == 0))
8588 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
8590 printf("bad unicast hash table parameter,"
8591 "return code = %d \n", ret);
8594 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
8595 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8597 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
8598 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8600 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
8601 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
8602 port_id, RTE_UINT16);
8603 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
8604 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8606 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
8607 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8609 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
8610 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8613 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
8614 .f = cmd_set_uc_all_hash_parsed,
8616 .help_str = "set port <port_id> uta all on|off",
8618 (void *)&cmd_set_uc_all_hash_set,
8619 (void *)&cmd_set_uc_all_hash_port,
8620 (void *)&cmd_set_uc_all_hash_portid,
8621 (void *)&cmd_set_uc_all_hash_what,
8622 (void *)&cmd_set_uc_all_hash_value,
8623 (void *)&cmd_set_uc_all_hash_mode,
8628 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
8629 struct cmd_set_vf_traffic {
8630 cmdline_fixed_string_t set;
8631 cmdline_fixed_string_t port;
8633 cmdline_fixed_string_t vf;
8635 cmdline_fixed_string_t what;
8636 cmdline_fixed_string_t mode;
8640 cmd_set_vf_traffic_parsed(void *parsed_result,
8641 __rte_unused struct cmdline *cl,
8642 __rte_unused void *data)
8644 struct cmd_set_vf_traffic *res = parsed_result;
8645 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
8646 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8648 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
8651 cmdline_parse_token_string_t cmd_setvf_traffic_set =
8652 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8654 cmdline_parse_token_string_t cmd_setvf_traffic_port =
8655 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8657 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8658 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8659 port_id, RTE_UINT16);
8660 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8661 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8663 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8664 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8666 cmdline_parse_token_string_t cmd_setvf_traffic_what =
8667 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8669 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8670 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8673 cmdline_parse_inst_t cmd_set_vf_traffic = {
8674 .f = cmd_set_vf_traffic_parsed,
8676 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8678 (void *)&cmd_setvf_traffic_set,
8679 (void *)&cmd_setvf_traffic_port,
8680 (void *)&cmd_setvf_traffic_portid,
8681 (void *)&cmd_setvf_traffic_vf,
8682 (void *)&cmd_setvf_traffic_vfid,
8683 (void *)&cmd_setvf_traffic_what,
8684 (void *)&cmd_setvf_traffic_mode,
8689 /* *** CONFIGURE VF RECEIVE MODE *** */
8690 struct cmd_set_vf_rxmode {
8691 cmdline_fixed_string_t set;
8692 cmdline_fixed_string_t port;
8694 cmdline_fixed_string_t vf;
8696 cmdline_fixed_string_t what;
8697 cmdline_fixed_string_t mode;
8698 cmdline_fixed_string_t on;
8702 cmd_set_vf_rxmode_parsed(void *parsed_result,
8703 __rte_unused struct cmdline *cl,
8704 __rte_unused void *data)
8707 uint16_t vf_rxmode = 0;
8708 struct cmd_set_vf_rxmode *res = parsed_result;
8710 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8711 if (!strcmp(res->what,"rxmode")) {
8712 if (!strcmp(res->mode, "AUPE"))
8713 vf_rxmode |= ETH_VMDQ_ACCEPT_UNTAG;
8714 else if (!strcmp(res->mode, "ROPE"))
8715 vf_rxmode |= ETH_VMDQ_ACCEPT_HASH_UC;
8716 else if (!strcmp(res->mode, "BAM"))
8717 vf_rxmode |= ETH_VMDQ_ACCEPT_BROADCAST;
8718 else if (!strncmp(res->mode, "MPE",3))
8719 vf_rxmode |= ETH_VMDQ_ACCEPT_MULTICAST;
8722 RTE_SET_USED(is_on);
8724 #ifdef RTE_NET_IXGBE
8725 if (ret == -ENOTSUP)
8726 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8727 vf_rxmode, (uint8_t)is_on);
8730 if (ret == -ENOTSUP)
8731 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8732 vf_rxmode, (uint8_t)is_on);
8735 printf("bad VF receive mode parameter, return code = %d \n",
8739 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8740 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8742 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8743 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8745 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8746 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8747 port_id, RTE_UINT16);
8748 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8749 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8751 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8752 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8754 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
8755 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8757 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
8758 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8759 mode, "AUPE#ROPE#BAM#MPE");
8760 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
8761 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8764 cmdline_parse_inst_t cmd_set_vf_rxmode = {
8765 .f = cmd_set_vf_rxmode_parsed,
8767 .help_str = "set port <port_id> vf <vf_id> rxmode "
8768 "AUPE|ROPE|BAM|MPE on|off",
8770 (void *)&cmd_set_vf_rxmode_set,
8771 (void *)&cmd_set_vf_rxmode_port,
8772 (void *)&cmd_set_vf_rxmode_portid,
8773 (void *)&cmd_set_vf_rxmode_vf,
8774 (void *)&cmd_set_vf_rxmode_vfid,
8775 (void *)&cmd_set_vf_rxmode_what,
8776 (void *)&cmd_set_vf_rxmode_mode,
8777 (void *)&cmd_set_vf_rxmode_on,
8782 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
8783 struct cmd_vf_mac_addr_result {
8784 cmdline_fixed_string_t mac_addr_cmd;
8785 cmdline_fixed_string_t what;
8786 cmdline_fixed_string_t port;
8788 cmdline_fixed_string_t vf;
8790 struct rte_ether_addr address;
8793 static void cmd_vf_mac_addr_parsed(void *parsed_result,
8794 __rte_unused struct cmdline *cl,
8795 __rte_unused void *data)
8797 struct cmd_vf_mac_addr_result *res = parsed_result;
8800 if (strcmp(res->what, "add") != 0)
8804 if (ret == -ENOTSUP)
8805 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
8809 if (ret == -ENOTSUP)
8810 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
8815 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
8819 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
8820 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8821 mac_addr_cmd,"mac_addr");
8822 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
8823 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8825 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
8826 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8828 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
8829 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8830 port_num, RTE_UINT16);
8831 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
8832 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8834 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
8835 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8837 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
8838 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
8841 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
8842 .f = cmd_vf_mac_addr_parsed,
8844 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
8845 "Add MAC address filtering for a VF on port_id",
8847 (void *)&cmd_vf_mac_addr_cmd,
8848 (void *)&cmd_vf_mac_addr_what,
8849 (void *)&cmd_vf_mac_addr_port,
8850 (void *)&cmd_vf_mac_addr_portnum,
8851 (void *)&cmd_vf_mac_addr_vf,
8852 (void *)&cmd_vf_mac_addr_vfnum,
8853 (void *)&cmd_vf_mac_addr_addr,
8858 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
8859 struct cmd_vf_rx_vlan_filter {
8860 cmdline_fixed_string_t rx_vlan;
8861 cmdline_fixed_string_t what;
8863 cmdline_fixed_string_t port;
8865 cmdline_fixed_string_t vf;
8870 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
8871 __rte_unused struct cmdline *cl,
8872 __rte_unused void *data)
8874 struct cmd_vf_rx_vlan_filter *res = parsed_result;
8877 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
8879 #ifdef RTE_NET_IXGBE
8880 if (ret == -ENOTSUP)
8881 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
8882 res->vlan_id, res->vf_mask, is_add);
8885 if (ret == -ENOTSUP)
8886 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
8887 res->vlan_id, res->vf_mask, is_add);
8890 if (ret == -ENOTSUP)
8891 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
8892 res->vlan_id, res->vf_mask, is_add);
8899 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
8900 res->vlan_id, res->vf_mask);
8903 printf("invalid port_id %d\n", res->port_id);
8906 printf("function not implemented or supported\n");
8909 printf("programming error: (%s)\n", strerror(-ret));
8913 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
8914 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8915 rx_vlan, "rx_vlan");
8916 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
8917 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8919 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
8920 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8921 vlan_id, RTE_UINT16);
8922 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
8923 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8925 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
8926 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8927 port_id, RTE_UINT16);
8928 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
8929 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8931 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
8932 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8933 vf_mask, RTE_UINT64);
8935 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
8936 .f = cmd_vf_rx_vlan_filter_parsed,
8938 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
8939 "(vf_mask = hexadecimal VF mask)",
8941 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
8942 (void *)&cmd_vf_rx_vlan_filter_what,
8943 (void *)&cmd_vf_rx_vlan_filter_vlanid,
8944 (void *)&cmd_vf_rx_vlan_filter_port,
8945 (void *)&cmd_vf_rx_vlan_filter_portid,
8946 (void *)&cmd_vf_rx_vlan_filter_vf,
8947 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
8952 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
8953 struct cmd_queue_rate_limit_result {
8954 cmdline_fixed_string_t set;
8955 cmdline_fixed_string_t port;
8957 cmdline_fixed_string_t queue;
8959 cmdline_fixed_string_t rate;
8963 static void cmd_queue_rate_limit_parsed(void *parsed_result,
8964 __rte_unused struct cmdline *cl,
8965 __rte_unused void *data)
8967 struct cmd_queue_rate_limit_result *res = parsed_result;
8970 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8971 && (strcmp(res->queue, "queue") == 0)
8972 && (strcmp(res->rate, "rate") == 0))
8973 ret = set_queue_rate_limit(res->port_num, res->queue_num,
8976 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
8980 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
8981 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8983 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
8984 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8986 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
8987 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8988 port_num, RTE_UINT16);
8989 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
8990 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8992 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
8993 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8994 queue_num, RTE_UINT8);
8995 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
8996 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8998 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
8999 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9000 rate_num, RTE_UINT16);
9002 cmdline_parse_inst_t cmd_queue_rate_limit = {
9003 .f = cmd_queue_rate_limit_parsed,
9005 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
9006 "Set rate limit for a queue on port_id",
9008 (void *)&cmd_queue_rate_limit_set,
9009 (void *)&cmd_queue_rate_limit_port,
9010 (void *)&cmd_queue_rate_limit_portnum,
9011 (void *)&cmd_queue_rate_limit_queue,
9012 (void *)&cmd_queue_rate_limit_queuenum,
9013 (void *)&cmd_queue_rate_limit_rate,
9014 (void *)&cmd_queue_rate_limit_ratenum,
9019 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
9020 struct cmd_vf_rate_limit_result {
9021 cmdline_fixed_string_t set;
9022 cmdline_fixed_string_t port;
9024 cmdline_fixed_string_t vf;
9026 cmdline_fixed_string_t rate;
9028 cmdline_fixed_string_t q_msk;
9032 static void cmd_vf_rate_limit_parsed(void *parsed_result,
9033 __rte_unused struct cmdline *cl,
9034 __rte_unused void *data)
9036 struct cmd_vf_rate_limit_result *res = parsed_result;
9039 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9040 && (strcmp(res->vf, "vf") == 0)
9041 && (strcmp(res->rate, "rate") == 0)
9042 && (strcmp(res->q_msk, "queue_mask") == 0))
9043 ret = set_vf_rate_limit(res->port_num, res->vf_num,
9044 res->rate_num, res->q_msk_val);
9046 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
9050 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
9051 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9053 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
9054 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9056 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
9057 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9058 port_num, RTE_UINT16);
9059 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
9060 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9062 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
9063 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9065 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
9066 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9068 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
9069 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9070 rate_num, RTE_UINT16);
9071 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
9072 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9073 q_msk, "queue_mask");
9074 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
9075 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9076 q_msk_val, RTE_UINT64);
9078 cmdline_parse_inst_t cmd_vf_rate_limit = {
9079 .f = cmd_vf_rate_limit_parsed,
9081 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
9082 "queue_mask <queue_mask_value>: "
9083 "Set rate limit for queues of VF on port_id",
9085 (void *)&cmd_vf_rate_limit_set,
9086 (void *)&cmd_vf_rate_limit_port,
9087 (void *)&cmd_vf_rate_limit_portnum,
9088 (void *)&cmd_vf_rate_limit_vf,
9089 (void *)&cmd_vf_rate_limit_vfnum,
9090 (void *)&cmd_vf_rate_limit_rate,
9091 (void *)&cmd_vf_rate_limit_ratenum,
9092 (void *)&cmd_vf_rate_limit_q_msk,
9093 (void *)&cmd_vf_rate_limit_q_msk_val,
9098 /* *** CONFIGURE TUNNEL UDP PORT *** */
9099 struct cmd_tunnel_udp_config {
9100 cmdline_fixed_string_t cmd;
9101 cmdline_fixed_string_t what;
9107 cmd_tunnel_udp_config_parsed(void *parsed_result,
9108 __rte_unused struct cmdline *cl,
9109 __rte_unused void *data)
9111 struct cmd_tunnel_udp_config *res = parsed_result;
9112 struct rte_eth_udp_tunnel tunnel_udp;
9115 tunnel_udp.udp_port = res->udp_port;
9117 if (!strcmp(res->cmd, "rx_vxlan_port"))
9118 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9120 if (!strcmp(res->what, "add"))
9121 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9124 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9128 printf("udp tunneling add error: (%s)\n", strerror(-ret));
9131 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
9132 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9133 cmd, "rx_vxlan_port");
9134 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
9135 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9137 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
9138 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9139 udp_port, RTE_UINT16);
9140 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
9141 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9142 port_id, RTE_UINT16);
9144 cmdline_parse_inst_t cmd_tunnel_udp_config = {
9145 .f = cmd_tunnel_udp_config_parsed,
9147 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
9148 "Add/Remove a tunneling UDP port filter",
9150 (void *)&cmd_tunnel_udp_config_cmd,
9151 (void *)&cmd_tunnel_udp_config_what,
9152 (void *)&cmd_tunnel_udp_config_udp_port,
9153 (void *)&cmd_tunnel_udp_config_port_id,
9158 struct cmd_config_tunnel_udp_port {
9159 cmdline_fixed_string_t port;
9160 cmdline_fixed_string_t config;
9162 cmdline_fixed_string_t udp_tunnel_port;
9163 cmdline_fixed_string_t action;
9164 cmdline_fixed_string_t tunnel_type;
9169 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
9170 __rte_unused struct cmdline *cl,
9171 __rte_unused void *data)
9173 struct cmd_config_tunnel_udp_port *res = parsed_result;
9174 struct rte_eth_udp_tunnel tunnel_udp;
9177 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9180 tunnel_udp.udp_port = res->udp_port;
9182 if (!strcmp(res->tunnel_type, "vxlan")) {
9183 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9184 } else if (!strcmp(res->tunnel_type, "geneve")) {
9185 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE;
9186 } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
9187 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9188 } else if (!strcmp(res->tunnel_type, "ecpri")) {
9189 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_ECPRI;
9191 printf("Invalid tunnel type\n");
9195 if (!strcmp(res->action, "add"))
9196 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9199 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9203 printf("udp tunneling port add error: (%s)\n", strerror(-ret));
9206 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
9207 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
9209 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
9210 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
9212 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
9213 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
9215 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
9216 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
9219 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
9220 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
9222 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
9223 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
9224 "vxlan#geneve#vxlan-gpe#ecpri");
9225 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
9226 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
9229 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
9230 .f = cmd_cfg_tunnel_udp_port_parsed,
9232 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|"
9233 "geneve|vxlan-gpe|ecpri <udp_port>",
9235 (void *)&cmd_config_tunnel_udp_port_port,
9236 (void *)&cmd_config_tunnel_udp_port_config,
9237 (void *)&cmd_config_tunnel_udp_port_port_id,
9238 (void *)&cmd_config_tunnel_udp_port_tunnel_port,
9239 (void *)&cmd_config_tunnel_udp_port_action,
9240 (void *)&cmd_config_tunnel_udp_port_tunnel_type,
9241 (void *)&cmd_config_tunnel_udp_port_value,
9246 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
9247 struct cmd_set_mirror_mask_result {
9248 cmdline_fixed_string_t set;
9249 cmdline_fixed_string_t port;
9251 cmdline_fixed_string_t mirror;
9253 cmdline_fixed_string_t what;
9254 cmdline_fixed_string_t value;
9255 cmdline_fixed_string_t dstpool;
9257 cmdline_fixed_string_t on;
9260 cmdline_parse_token_string_t cmd_mirror_mask_set =
9261 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9263 cmdline_parse_token_string_t cmd_mirror_mask_port =
9264 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9266 cmdline_parse_token_num_t cmd_mirror_mask_portid =
9267 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9268 port_id, RTE_UINT16);
9269 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
9270 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9271 mirror, "mirror-rule");
9272 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
9273 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9274 rule_id, RTE_UINT8);
9275 cmdline_parse_token_string_t cmd_mirror_mask_what =
9276 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9277 what, "pool-mirror-up#pool-mirror-down"
9279 cmdline_parse_token_string_t cmd_mirror_mask_value =
9280 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9282 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
9283 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9284 dstpool, "dst-pool");
9285 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
9286 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9287 dstpool_id, RTE_UINT8);
9288 cmdline_parse_token_string_t cmd_mirror_mask_on =
9289 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9293 cmd_set_mirror_mask_parsed(void *parsed_result,
9294 __rte_unused struct cmdline *cl,
9295 __rte_unused void *data)
9298 struct cmd_set_mirror_mask_result *res = parsed_result;
9299 struct rte_eth_mirror_conf mr_conf;
9301 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9303 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
9305 mr_conf.dst_pool = res->dstpool_id;
9307 if (!strcmp(res->what, "pool-mirror-up")) {
9308 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9309 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
9310 } else if (!strcmp(res->what, "pool-mirror-down")) {
9311 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9312 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
9313 } else if (!strcmp(res->what, "vlan-mirror")) {
9314 mr_conf.rule_type = ETH_MIRROR_VLAN;
9315 nb_item = parse_item_list(res->value, "vlan",
9316 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
9320 for (i = 0; i < nb_item; i++) {
9321 if (vlan_list[i] > RTE_ETHER_MAX_VLAN_ID) {
9322 printf("Invalid vlan_id: must be < 4096\n");
9326 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
9327 mr_conf.vlan.vlan_mask |= 1ULL << i;
9331 if (!strcmp(res->on, "on"))
9332 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9335 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9338 printf("mirror rule add error: (%s)\n", strerror(-ret));
9341 cmdline_parse_inst_t cmd_set_mirror_mask = {
9342 .f = cmd_set_mirror_mask_parsed,
9344 .help_str = "set port <port_id> mirror-rule <rule_id> "
9345 "pool-mirror-up|pool-mirror-down|vlan-mirror "
9346 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
9348 (void *)&cmd_mirror_mask_set,
9349 (void *)&cmd_mirror_mask_port,
9350 (void *)&cmd_mirror_mask_portid,
9351 (void *)&cmd_mirror_mask_mirror,
9352 (void *)&cmd_mirror_mask_ruleid,
9353 (void *)&cmd_mirror_mask_what,
9354 (void *)&cmd_mirror_mask_value,
9355 (void *)&cmd_mirror_mask_dstpool,
9356 (void *)&cmd_mirror_mask_poolid,
9357 (void *)&cmd_mirror_mask_on,
9362 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
9363 struct cmd_set_mirror_link_result {
9364 cmdline_fixed_string_t set;
9365 cmdline_fixed_string_t port;
9367 cmdline_fixed_string_t mirror;
9369 cmdline_fixed_string_t what;
9370 cmdline_fixed_string_t dstpool;
9372 cmdline_fixed_string_t on;
9375 cmdline_parse_token_string_t cmd_mirror_link_set =
9376 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9378 cmdline_parse_token_string_t cmd_mirror_link_port =
9379 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9381 cmdline_parse_token_num_t cmd_mirror_link_portid =
9382 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9383 port_id, RTE_UINT16);
9384 cmdline_parse_token_string_t cmd_mirror_link_mirror =
9385 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9386 mirror, "mirror-rule");
9387 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
9388 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9389 rule_id, RTE_UINT8);
9390 cmdline_parse_token_string_t cmd_mirror_link_what =
9391 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9392 what, "uplink-mirror#downlink-mirror");
9393 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
9394 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9395 dstpool, "dst-pool");
9396 cmdline_parse_token_num_t cmd_mirror_link_poolid =
9397 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9398 dstpool_id, RTE_UINT8);
9399 cmdline_parse_token_string_t cmd_mirror_link_on =
9400 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9404 cmd_set_mirror_link_parsed(void *parsed_result,
9405 __rte_unused struct cmdline *cl,
9406 __rte_unused void *data)
9409 struct cmd_set_mirror_link_result *res = parsed_result;
9410 struct rte_eth_mirror_conf mr_conf;
9412 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9413 if (!strcmp(res->what, "uplink-mirror"))
9414 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
9416 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
9418 mr_conf.dst_pool = res->dstpool_id;
9420 if (!strcmp(res->on, "on"))
9421 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9424 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9427 /* check the return value and print it if is < 0 */
9429 printf("mirror rule add error: (%s)\n", strerror(-ret));
9433 cmdline_parse_inst_t cmd_set_mirror_link = {
9434 .f = cmd_set_mirror_link_parsed,
9436 .help_str = "set port <port_id> mirror-rule <rule_id> "
9437 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
9439 (void *)&cmd_mirror_link_set,
9440 (void *)&cmd_mirror_link_port,
9441 (void *)&cmd_mirror_link_portid,
9442 (void *)&cmd_mirror_link_mirror,
9443 (void *)&cmd_mirror_link_ruleid,
9444 (void *)&cmd_mirror_link_what,
9445 (void *)&cmd_mirror_link_dstpool,
9446 (void *)&cmd_mirror_link_poolid,
9447 (void *)&cmd_mirror_link_on,
9452 /* *** RESET VM MIRROR RULE *** */
9453 struct cmd_rm_mirror_rule_result {
9454 cmdline_fixed_string_t reset;
9455 cmdline_fixed_string_t port;
9457 cmdline_fixed_string_t mirror;
9461 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
9462 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9464 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
9465 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9467 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
9468 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9469 port_id, RTE_UINT16);
9470 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
9471 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9472 mirror, "mirror-rule");
9473 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
9474 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9475 rule_id, RTE_UINT8);
9478 cmd_reset_mirror_rule_parsed(void *parsed_result,
9479 __rte_unused struct cmdline *cl,
9480 __rte_unused void *data)
9483 struct cmd_set_mirror_link_result *res = parsed_result;
9485 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
9487 printf("mirror rule remove error: (%s)\n", strerror(-ret));
9490 cmdline_parse_inst_t cmd_reset_mirror_rule = {
9491 .f = cmd_reset_mirror_rule_parsed,
9493 .help_str = "reset port <port_id> mirror-rule <rule_id>",
9495 (void *)&cmd_rm_mirror_rule_reset,
9496 (void *)&cmd_rm_mirror_rule_port,
9497 (void *)&cmd_rm_mirror_rule_portid,
9498 (void *)&cmd_rm_mirror_rule_mirror,
9499 (void *)&cmd_rm_mirror_rule_ruleid,
9504 /* ******************************************************************************** */
9506 struct cmd_dump_result {
9507 cmdline_fixed_string_t dump;
9511 dump_struct_sizes(void)
9513 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9514 DUMP_SIZE(struct rte_mbuf);
9515 DUMP_SIZE(struct rte_mempool);
9516 DUMP_SIZE(struct rte_ring);
9521 /* Dump the socket memory statistics on console */
9523 dump_socket_mem(FILE *f)
9525 struct rte_malloc_socket_stats socket_stats;
9530 unsigned int n_alloc = 0;
9531 unsigned int n_free = 0;
9532 static size_t last_allocs;
9533 static size_t last_total;
9536 for (i = 0; i < RTE_MAX_NUMA_NODES; i++) {
9537 if (rte_malloc_get_socket_stats(i, &socket_stats) ||
9538 !socket_stats.heap_totalsz_bytes)
9540 total += socket_stats.heap_totalsz_bytes;
9541 alloc += socket_stats.heap_allocsz_bytes;
9542 free += socket_stats.heap_freesz_bytes;
9543 n_alloc += socket_stats.alloc_count;
9544 n_free += socket_stats.free_count;
9546 "Socket %u: size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9548 (double)socket_stats.heap_totalsz_bytes / (1024 * 1024),
9549 (double)socket_stats.heap_allocsz_bytes / (1024 * 1024),
9550 (double)socket_stats.heap_allocsz_bytes * 100 /
9551 (double)socket_stats.heap_totalsz_bytes,
9552 (double)socket_stats.heap_freesz_bytes / (1024 * 1024),
9553 socket_stats.alloc_count,
9554 socket_stats.free_count);
9557 "Total : size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9558 (double)total / (1024 * 1024), (double)alloc / (1024 * 1024),
9559 (double)alloc * 100 / (double)total,
9560 (double)free / (1024 * 1024),
9563 fprintf(stdout, "Memory total change: %.6lf(M), allocation change: %.6lf(M)\n",
9564 ((double)total - (double)last_total) / (1024 * 1024),
9565 (double)(alloc - (double)last_allocs) / 1024 / 1024);
9566 last_allocs = alloc;
9570 static void cmd_dump_parsed(void *parsed_result,
9571 __rte_unused struct cmdline *cl,
9572 __rte_unused void *data)
9574 struct cmd_dump_result *res = parsed_result;
9576 if (!strcmp(res->dump, "dump_physmem"))
9577 rte_dump_physmem_layout(stdout);
9578 else if (!strcmp(res->dump, "dump_socket_mem"))
9579 dump_socket_mem(stdout);
9580 else if (!strcmp(res->dump, "dump_memzone"))
9581 rte_memzone_dump(stdout);
9582 else if (!strcmp(res->dump, "dump_struct_sizes"))
9583 dump_struct_sizes();
9584 else if (!strcmp(res->dump, "dump_ring"))
9585 rte_ring_list_dump(stdout);
9586 else if (!strcmp(res->dump, "dump_mempool"))
9587 rte_mempool_list_dump(stdout);
9588 else if (!strcmp(res->dump, "dump_devargs"))
9589 rte_devargs_dump(stdout);
9590 else if (!strcmp(res->dump, "dump_log_types"))
9591 rte_log_dump(stdout);
9594 cmdline_parse_token_string_t cmd_dump_dump =
9595 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9599 "dump_struct_sizes#"
9605 cmdline_parse_inst_t cmd_dump = {
9606 .f = cmd_dump_parsed, /* function to call */
9607 .data = NULL, /* 2nd arg of func */
9608 .help_str = "Dump status",
9609 .tokens = { /* token list, NULL terminated */
9610 (void *)&cmd_dump_dump,
9615 /* ******************************************************************************** */
9617 struct cmd_dump_one_result {
9618 cmdline_fixed_string_t dump;
9619 cmdline_fixed_string_t name;
9622 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9623 __rte_unused void *data)
9625 struct cmd_dump_one_result *res = parsed_result;
9627 if (!strcmp(res->dump, "dump_ring")) {
9629 r = rte_ring_lookup(res->name);
9631 cmdline_printf(cl, "Cannot find ring\n");
9634 rte_ring_dump(stdout, r);
9635 } else if (!strcmp(res->dump, "dump_mempool")) {
9636 struct rte_mempool *mp;
9637 mp = rte_mempool_lookup(res->name);
9639 cmdline_printf(cl, "Cannot find mempool\n");
9642 rte_mempool_dump(stdout, mp);
9646 cmdline_parse_token_string_t cmd_dump_one_dump =
9647 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9648 "dump_ring#dump_mempool");
9650 cmdline_parse_token_string_t cmd_dump_one_name =
9651 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9653 cmdline_parse_inst_t cmd_dump_one = {
9654 .f = cmd_dump_one_parsed, /* function to call */
9655 .data = NULL, /* 2nd arg of func */
9656 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9657 .tokens = { /* token list, NULL terminated */
9658 (void *)&cmd_dump_one_dump,
9659 (void *)&cmd_dump_one_name,
9664 /* *** queue region set *** */
9665 struct cmd_queue_region_result {
9666 cmdline_fixed_string_t set;
9667 cmdline_fixed_string_t port;
9669 cmdline_fixed_string_t cmd;
9670 cmdline_fixed_string_t region;
9672 cmdline_fixed_string_t queue_start_index;
9674 cmdline_fixed_string_t queue_num;
9675 uint8_t queue_num_value;
9679 cmd_queue_region_parsed(void *parsed_result,
9680 __rte_unused struct cmdline *cl,
9681 __rte_unused void *data)
9683 struct cmd_queue_region_result *res = parsed_result;
9686 struct rte_pmd_i40e_queue_region_conf region_conf;
9687 enum rte_pmd_i40e_queue_region_op op_type;
9690 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9694 memset(®ion_conf, 0, sizeof(region_conf));
9695 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
9696 region_conf.region_id = res->region_id;
9697 region_conf.queue_num = res->queue_num_value;
9698 region_conf.queue_start_index = res->queue_id;
9700 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9701 op_type, ®ion_conf);
9708 printf("function not implemented or supported\n");
9711 printf("queue region config error: (%s)\n", strerror(-ret));
9715 cmdline_parse_token_string_t cmd_queue_region_set =
9716 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9718 cmdline_parse_token_string_t cmd_queue_region_port =
9719 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
9720 cmdline_parse_token_num_t cmd_queue_region_port_id =
9721 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9722 port_id, RTE_UINT16);
9723 cmdline_parse_token_string_t cmd_queue_region_cmd =
9724 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9725 cmd, "queue-region");
9726 cmdline_parse_token_string_t cmd_queue_region_id =
9727 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9728 region, "region_id");
9729 cmdline_parse_token_num_t cmd_queue_region_index =
9730 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9731 region_id, RTE_UINT8);
9732 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
9733 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9734 queue_start_index, "queue_start_index");
9735 cmdline_parse_token_num_t cmd_queue_region_queue_id =
9736 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9737 queue_id, RTE_UINT8);
9738 cmdline_parse_token_string_t cmd_queue_region_queue_num =
9739 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9740 queue_num, "queue_num");
9741 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
9742 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9743 queue_num_value, RTE_UINT8);
9745 cmdline_parse_inst_t cmd_queue_region = {
9746 .f = cmd_queue_region_parsed,
9748 .help_str = "set port <port_id> queue-region region_id <value> "
9749 "queue_start_index <value> queue_num <value>: Set a queue region",
9751 (void *)&cmd_queue_region_set,
9752 (void *)&cmd_queue_region_port,
9753 (void *)&cmd_queue_region_port_id,
9754 (void *)&cmd_queue_region_cmd,
9755 (void *)&cmd_queue_region_id,
9756 (void *)&cmd_queue_region_index,
9757 (void *)&cmd_queue_region_queue_start_index,
9758 (void *)&cmd_queue_region_queue_id,
9759 (void *)&cmd_queue_region_queue_num,
9760 (void *)&cmd_queue_region_queue_num_value,
9765 /* *** queue region and flowtype set *** */
9766 struct cmd_region_flowtype_result {
9767 cmdline_fixed_string_t set;
9768 cmdline_fixed_string_t port;
9770 cmdline_fixed_string_t cmd;
9771 cmdline_fixed_string_t region;
9773 cmdline_fixed_string_t flowtype;
9774 uint8_t flowtype_id;
9778 cmd_region_flowtype_parsed(void *parsed_result,
9779 __rte_unused struct cmdline *cl,
9780 __rte_unused void *data)
9782 struct cmd_region_flowtype_result *res = parsed_result;
9785 struct rte_pmd_i40e_queue_region_conf region_conf;
9786 enum rte_pmd_i40e_queue_region_op op_type;
9789 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9793 memset(®ion_conf, 0, sizeof(region_conf));
9795 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
9796 region_conf.region_id = res->region_id;
9797 region_conf.hw_flowtype = res->flowtype_id;
9799 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9800 op_type, ®ion_conf);
9807 printf("function not implemented or supported\n");
9810 printf("region flowtype config error: (%s)\n", strerror(-ret));
9814 cmdline_parse_token_string_t cmd_region_flowtype_set =
9815 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9817 cmdline_parse_token_string_t cmd_region_flowtype_port =
9818 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9820 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
9821 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9822 port_id, RTE_UINT16);
9823 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
9824 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9825 cmd, "queue-region");
9826 cmdline_parse_token_string_t cmd_region_flowtype_index =
9827 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9828 region, "region_id");
9829 cmdline_parse_token_num_t cmd_region_flowtype_id =
9830 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9831 region_id, RTE_UINT8);
9832 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
9833 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9834 flowtype, "flowtype");
9835 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
9836 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9837 flowtype_id, RTE_UINT8);
9838 cmdline_parse_inst_t cmd_region_flowtype = {
9839 .f = cmd_region_flowtype_parsed,
9841 .help_str = "set port <port_id> queue-region region_id <value> "
9842 "flowtype <value>: Set a flowtype region index",
9844 (void *)&cmd_region_flowtype_set,
9845 (void *)&cmd_region_flowtype_port,
9846 (void *)&cmd_region_flowtype_port_index,
9847 (void *)&cmd_region_flowtype_cmd,
9848 (void *)&cmd_region_flowtype_index,
9849 (void *)&cmd_region_flowtype_id,
9850 (void *)&cmd_region_flowtype_flow_index,
9851 (void *)&cmd_region_flowtype_flow_id,
9856 /* *** User Priority (UP) to queue region (region_id) set *** */
9857 struct cmd_user_priority_region_result {
9858 cmdline_fixed_string_t set;
9859 cmdline_fixed_string_t port;
9861 cmdline_fixed_string_t cmd;
9862 cmdline_fixed_string_t user_priority;
9863 uint8_t user_priority_id;
9864 cmdline_fixed_string_t region;
9869 cmd_user_priority_region_parsed(void *parsed_result,
9870 __rte_unused struct cmdline *cl,
9871 __rte_unused void *data)
9873 struct cmd_user_priority_region_result *res = parsed_result;
9876 struct rte_pmd_i40e_queue_region_conf region_conf;
9877 enum rte_pmd_i40e_queue_region_op op_type;
9880 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9884 memset(®ion_conf, 0, sizeof(region_conf));
9885 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
9886 region_conf.user_priority = res->user_priority_id;
9887 region_conf.region_id = res->region_id;
9889 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9890 op_type, ®ion_conf);
9897 printf("function not implemented or supported\n");
9900 printf("user_priority region config error: (%s)\n",
9905 cmdline_parse_token_string_t cmd_user_priority_region_set =
9906 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9908 cmdline_parse_token_string_t cmd_user_priority_region_port =
9909 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9911 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
9912 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9913 port_id, RTE_UINT16);
9914 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
9915 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9916 cmd, "queue-region");
9917 cmdline_parse_token_string_t cmd_user_priority_region_UP =
9918 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9919 user_priority, "UP");
9920 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
9921 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9922 user_priority_id, RTE_UINT8);
9923 cmdline_parse_token_string_t cmd_user_priority_region_region =
9924 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9925 region, "region_id");
9926 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
9927 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9928 region_id, RTE_UINT8);
9930 cmdline_parse_inst_t cmd_user_priority_region = {
9931 .f = cmd_user_priority_region_parsed,
9933 .help_str = "set port <port_id> queue-region UP <value> "
9934 "region_id <value>: Set the mapping of User Priority (UP) "
9935 "to queue region (region_id) ",
9937 (void *)&cmd_user_priority_region_set,
9938 (void *)&cmd_user_priority_region_port,
9939 (void *)&cmd_user_priority_region_port_index,
9940 (void *)&cmd_user_priority_region_cmd,
9941 (void *)&cmd_user_priority_region_UP,
9942 (void *)&cmd_user_priority_region_UP_id,
9943 (void *)&cmd_user_priority_region_region,
9944 (void *)&cmd_user_priority_region_region_id,
9949 /* *** flush all queue region related configuration *** */
9950 struct cmd_flush_queue_region_result {
9951 cmdline_fixed_string_t set;
9952 cmdline_fixed_string_t port;
9954 cmdline_fixed_string_t cmd;
9955 cmdline_fixed_string_t flush;
9956 cmdline_fixed_string_t what;
9960 cmd_flush_queue_region_parsed(void *parsed_result,
9961 __rte_unused struct cmdline *cl,
9962 __rte_unused void *data)
9964 struct cmd_flush_queue_region_result *res = parsed_result;
9967 struct rte_pmd_i40e_queue_region_conf region_conf;
9968 enum rte_pmd_i40e_queue_region_op op_type;
9971 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9975 memset(®ion_conf, 0, sizeof(region_conf));
9977 if (strcmp(res->what, "on") == 0)
9978 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
9980 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
9982 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9983 op_type, ®ion_conf);
9990 printf("function not implemented or supported\n");
9993 printf("queue region config flush error: (%s)\n",
9998 cmdline_parse_token_string_t cmd_flush_queue_region_set =
9999 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10001 cmdline_parse_token_string_t cmd_flush_queue_region_port =
10002 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10004 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
10005 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
10006 port_id, RTE_UINT16);
10007 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
10008 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10009 cmd, "queue-region");
10010 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
10011 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10013 cmdline_parse_token_string_t cmd_flush_queue_region_what =
10014 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10017 cmdline_parse_inst_t cmd_flush_queue_region = {
10018 .f = cmd_flush_queue_region_parsed,
10020 .help_str = "set port <port_id> queue-region flush on|off"
10021 ": flush all queue region related configuration",
10023 (void *)&cmd_flush_queue_region_set,
10024 (void *)&cmd_flush_queue_region_port,
10025 (void *)&cmd_flush_queue_region_port_index,
10026 (void *)&cmd_flush_queue_region_cmd,
10027 (void *)&cmd_flush_queue_region_flush,
10028 (void *)&cmd_flush_queue_region_what,
10033 /* *** get all queue region related configuration info *** */
10034 struct cmd_show_queue_region_info {
10035 cmdline_fixed_string_t show;
10036 cmdline_fixed_string_t port;
10038 cmdline_fixed_string_t cmd;
10042 cmd_show_queue_region_info_parsed(void *parsed_result,
10043 __rte_unused struct cmdline *cl,
10044 __rte_unused void *data)
10046 struct cmd_show_queue_region_info *res = parsed_result;
10047 int ret = -ENOTSUP;
10048 #ifdef RTE_NET_I40E
10049 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
10050 enum rte_pmd_i40e_queue_region_op op_type;
10053 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10056 #ifdef RTE_NET_I40E
10057 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
10059 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
10061 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10062 op_type, &rte_pmd_regions);
10064 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
10071 printf("function not implemented or supported\n");
10074 printf("queue region config info show error: (%s)\n",
10079 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
10080 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10082 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
10083 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10085 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
10086 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
10087 port_id, RTE_UINT16);
10088 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
10089 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10090 cmd, "queue-region");
10092 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
10093 .f = cmd_show_queue_region_info_parsed,
10095 .help_str = "show port <port_id> queue-region"
10096 ": show all queue region related configuration info",
10098 (void *)&cmd_show_queue_region_info_get,
10099 (void *)&cmd_show_queue_region_info_port,
10100 (void *)&cmd_show_queue_region_info_port_index,
10101 (void *)&cmd_show_queue_region_info_cmd,
10106 /* *** Filters Control *** */
10108 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10110 if ((ip_addr).family == AF_INET) \
10111 (ip) = (ip_addr).addr.ipv4.s_addr; \
10113 printf("invalid parameter.\n"); \
10118 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10120 if ((ip_addr).family == AF_INET6) \
10121 rte_memcpy(&(ip), \
10122 &((ip_addr).addr.ipv6), \
10123 sizeof(struct in6_addr)); \
10125 printf("invalid parameter.\n"); \
10130 #ifdef RTE_NET_I40E
10133 str2flowtype(char *string)
10136 static const struct {
10139 } flowtype_str[] = {
10140 {"raw", RTE_ETH_FLOW_RAW},
10141 {"ipv4", RTE_ETH_FLOW_IPV4},
10142 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10143 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10144 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10145 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10146 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10147 {"ipv6", RTE_ETH_FLOW_IPV6},
10148 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10149 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10150 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10151 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10152 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10153 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10156 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
10157 if (!strcmp(flowtype_str[i].str, string))
10158 return flowtype_str[i].type;
10161 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
10162 return (uint16_t)atoi(string);
10164 return RTE_ETH_FLOW_UNKNOWN;
10167 /* *** deal with flow director filter *** */
10168 struct cmd_flow_director_result {
10169 cmdline_fixed_string_t flow_director_filter;
10171 cmdline_fixed_string_t mode;
10172 cmdline_fixed_string_t mode_value;
10173 cmdline_fixed_string_t ops;
10174 cmdline_fixed_string_t flow;
10175 cmdline_fixed_string_t flow_type;
10176 cmdline_fixed_string_t drop;
10177 cmdline_fixed_string_t queue;
10179 cmdline_fixed_string_t fd_id;
10180 uint32_t fd_id_value;
10181 cmdline_fixed_string_t packet;
10186 cmd_flow_director_filter_parsed(void *parsed_result,
10187 __rte_unused struct cmdline *cl,
10188 __rte_unused void *data)
10190 struct cmd_flow_director_result *res = parsed_result;
10192 struct rte_pmd_i40e_flow_type_mapping
10193 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
10194 struct rte_pmd_i40e_pkt_template_conf conf;
10195 uint16_t flow_type = str2flowtype(res->flow_type);
10196 uint16_t i, port = res->port_id;
10199 memset(&conf, 0, sizeof(conf));
10201 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
10202 printf("Invalid flow type specified.\n");
10205 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
10209 if (mapping[flow_type].pctype == 0ULL) {
10210 printf("Invalid flow type specified.\n");
10213 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
10214 if (mapping[flow_type].pctype & (1ULL << i)) {
10215 conf.input.pctype = i;
10220 conf.input.packet = open_file(res->filepath,
10221 &conf.input.length);
10222 if (!conf.input.packet)
10224 if (!strcmp(res->drop, "drop"))
10225 conf.action.behavior =
10226 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
10228 conf.action.behavior =
10229 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
10230 conf.action.report_status =
10231 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
10232 conf.action.rx_queue = res->queue_id;
10233 conf.soft_id = res->fd_id_value;
10234 add = strcmp(res->ops, "del") ? 1 : 0;
10235 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
10239 printf("flow director config error: (%s)\n",
10241 close_file(conf.input.packet);
10244 cmdline_parse_token_string_t cmd_flow_director_filter =
10245 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10246 flow_director_filter, "flow_director_filter");
10247 cmdline_parse_token_num_t cmd_flow_director_port_id =
10248 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10249 port_id, RTE_UINT16);
10250 cmdline_parse_token_string_t cmd_flow_director_ops =
10251 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10252 ops, "add#del#update");
10253 cmdline_parse_token_string_t cmd_flow_director_flow =
10254 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10256 cmdline_parse_token_string_t cmd_flow_director_flow_type =
10257 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10259 cmdline_parse_token_string_t cmd_flow_director_drop =
10260 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10262 cmdline_parse_token_string_t cmd_flow_director_queue =
10263 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10265 cmdline_parse_token_num_t cmd_flow_director_queue_id =
10266 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10267 queue_id, RTE_UINT16);
10268 cmdline_parse_token_string_t cmd_flow_director_fd_id =
10269 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10271 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
10272 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10273 fd_id_value, RTE_UINT32);
10275 cmdline_parse_token_string_t cmd_flow_director_mode =
10276 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10278 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
10279 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10280 mode_value, "raw");
10281 cmdline_parse_token_string_t cmd_flow_director_packet =
10282 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10284 cmdline_parse_token_string_t cmd_flow_director_filepath =
10285 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10288 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
10289 .f = cmd_flow_director_filter_parsed,
10291 .help_str = "flow_director_filter ... : Add or delete a raw flow "
10292 "director entry on NIC",
10294 (void *)&cmd_flow_director_filter,
10295 (void *)&cmd_flow_director_port_id,
10296 (void *)&cmd_flow_director_mode,
10297 (void *)&cmd_flow_director_mode_raw,
10298 (void *)&cmd_flow_director_ops,
10299 (void *)&cmd_flow_director_flow,
10300 (void *)&cmd_flow_director_flow_type,
10301 (void *)&cmd_flow_director_drop,
10302 (void *)&cmd_flow_director_queue,
10303 (void *)&cmd_flow_director_queue_id,
10304 (void *)&cmd_flow_director_fd_id,
10305 (void *)&cmd_flow_director_fd_id_value,
10306 (void *)&cmd_flow_director_packet,
10307 (void *)&cmd_flow_director_filepath,
10312 #endif /* RTE_NET_I40E */
10314 /* *** deal with flow director mask *** */
10315 struct cmd_flow_director_mask_result {
10316 cmdline_fixed_string_t flow_director_mask;
10318 cmdline_fixed_string_t mode;
10319 cmdline_fixed_string_t mode_value;
10320 cmdline_fixed_string_t vlan;
10321 uint16_t vlan_mask;
10322 cmdline_fixed_string_t src_mask;
10323 cmdline_ipaddr_t ipv4_src;
10324 cmdline_ipaddr_t ipv6_src;
10326 cmdline_fixed_string_t dst_mask;
10327 cmdline_ipaddr_t ipv4_dst;
10328 cmdline_ipaddr_t ipv6_dst;
10330 cmdline_fixed_string_t mac;
10331 uint8_t mac_addr_byte_mask;
10332 cmdline_fixed_string_t tunnel_id;
10333 uint32_t tunnel_id_mask;
10334 cmdline_fixed_string_t tunnel_type;
10335 uint8_t tunnel_type_mask;
10339 cmd_flow_director_mask_parsed(void *parsed_result,
10340 __rte_unused struct cmdline *cl,
10341 __rte_unused void *data)
10343 struct cmd_flow_director_mask_result *res = parsed_result;
10344 struct rte_eth_fdir_masks *mask;
10345 struct rte_port *port;
10347 port = &ports[res->port_id];
10348 /** Check if the port is not started **/
10349 if (port->port_status != RTE_PORT_STOPPED) {
10350 printf("Please stop port %d first\n", res->port_id);
10354 mask = &port->dev_conf.fdir_conf.mask;
10356 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10357 if (strcmp(res->mode_value, "MAC-VLAN")) {
10358 printf("Please set mode to MAC-VLAN.\n");
10362 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10363 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10364 if (strcmp(res->mode_value, "Tunnel")) {
10365 printf("Please set mode to Tunnel.\n");
10369 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10370 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
10371 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
10372 mask->tunnel_type_mask = res->tunnel_type_mask;
10374 if (strcmp(res->mode_value, "IP")) {
10375 printf("Please set mode to IP.\n");
10379 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10380 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
10381 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
10382 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
10383 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
10384 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
10385 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
10388 cmd_reconfig_device_queue(res->port_id, 1, 1);
10391 cmdline_parse_token_string_t cmd_flow_director_mask =
10392 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10393 flow_director_mask, "flow_director_mask");
10394 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
10395 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10396 port_id, RTE_UINT16);
10397 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
10398 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10400 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
10401 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10402 vlan_mask, RTE_UINT16);
10403 cmdline_parse_token_string_t cmd_flow_director_mask_src =
10404 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10405 src_mask, "src_mask");
10406 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
10407 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10409 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
10410 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10412 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
10413 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10414 port_src, RTE_UINT16);
10415 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
10416 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10417 dst_mask, "dst_mask");
10418 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
10419 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10421 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
10422 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10424 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
10425 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10426 port_dst, RTE_UINT16);
10428 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
10429 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10431 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
10432 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10434 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
10435 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10436 mode_value, "MAC-VLAN");
10437 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
10438 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10439 mode_value, "Tunnel");
10440 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
10441 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10443 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
10444 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10445 mac_addr_byte_mask, RTE_UINT8);
10446 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
10447 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10448 tunnel_type, "tunnel-type");
10449 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
10450 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10451 tunnel_type_mask, RTE_UINT8);
10452 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
10453 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10454 tunnel_id, "tunnel-id");
10455 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
10456 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10457 tunnel_id_mask, RTE_UINT32);
10459 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
10460 .f = cmd_flow_director_mask_parsed,
10462 .help_str = "flow_director_mask ... : "
10463 "Set IP mode flow director's mask on NIC",
10465 (void *)&cmd_flow_director_mask,
10466 (void *)&cmd_flow_director_mask_port_id,
10467 (void *)&cmd_flow_director_mask_mode,
10468 (void *)&cmd_flow_director_mask_mode_ip,
10469 (void *)&cmd_flow_director_mask_vlan,
10470 (void *)&cmd_flow_director_mask_vlan_value,
10471 (void *)&cmd_flow_director_mask_src,
10472 (void *)&cmd_flow_director_mask_ipv4_src,
10473 (void *)&cmd_flow_director_mask_ipv6_src,
10474 (void *)&cmd_flow_director_mask_port_src,
10475 (void *)&cmd_flow_director_mask_dst,
10476 (void *)&cmd_flow_director_mask_ipv4_dst,
10477 (void *)&cmd_flow_director_mask_ipv6_dst,
10478 (void *)&cmd_flow_director_mask_port_dst,
10483 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
10484 .f = cmd_flow_director_mask_parsed,
10486 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
10487 "flow director's mask on NIC",
10489 (void *)&cmd_flow_director_mask,
10490 (void *)&cmd_flow_director_mask_port_id,
10491 (void *)&cmd_flow_director_mask_mode,
10492 (void *)&cmd_flow_director_mask_mode_mac_vlan,
10493 (void *)&cmd_flow_director_mask_vlan,
10494 (void *)&cmd_flow_director_mask_vlan_value,
10499 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
10500 .f = cmd_flow_director_mask_parsed,
10502 .help_str = "flow_director_mask ... : Set tunnel mode "
10503 "flow director's mask on NIC",
10505 (void *)&cmd_flow_director_mask,
10506 (void *)&cmd_flow_director_mask_port_id,
10507 (void *)&cmd_flow_director_mask_mode,
10508 (void *)&cmd_flow_director_mask_mode_tunnel,
10509 (void *)&cmd_flow_director_mask_vlan,
10510 (void *)&cmd_flow_director_mask_vlan_value,
10511 (void *)&cmd_flow_director_mask_mac,
10512 (void *)&cmd_flow_director_mask_mac_value,
10513 (void *)&cmd_flow_director_mask_tunnel_type,
10514 (void *)&cmd_flow_director_mask_tunnel_type_value,
10515 (void *)&cmd_flow_director_mask_tunnel_id,
10516 (void *)&cmd_flow_director_mask_tunnel_id_value,
10521 /* *** deal with flow director flexible payload configuration *** */
10522 struct cmd_flow_director_flexpayload_result {
10523 cmdline_fixed_string_t flow_director_flexpayload;
10525 cmdline_fixed_string_t payload_layer;
10526 cmdline_fixed_string_t payload_cfg;
10530 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
10533 const char *p, *p0 = q_arg;
10535 unsigned long int_fld;
10536 char *str_fld[max_num];
10541 p = strchr(p0, '(');
10545 p0 = strchr(p, ')');
10550 if (size >= sizeof(s))
10553 snprintf(s, sizeof(s), "%.*s", size, p);
10554 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10555 if (ret < 0 || ret > max_num)
10557 for (i = 0; i < ret; i++) {
10559 int_fld = strtoul(str_fld[i], &end, 0);
10560 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
10562 offsets[i] = (uint16_t)int_fld;
10568 cmd_flow_director_flxpld_parsed(void *parsed_result,
10569 __rte_unused struct cmdline *cl,
10570 __rte_unused void *data)
10572 struct cmd_flow_director_flexpayload_result *res = parsed_result;
10573 struct rte_eth_flex_payload_cfg flex_cfg;
10574 struct rte_port *port;
10577 port = &ports[res->port_id];
10578 /** Check if the port is not started **/
10579 if (port->port_status != RTE_PORT_STOPPED) {
10580 printf("Please stop port %d first\n", res->port_id);
10584 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
10586 if (!strcmp(res->payload_layer, "raw"))
10587 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
10588 else if (!strcmp(res->payload_layer, "l2"))
10589 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
10590 else if (!strcmp(res->payload_layer, "l3"))
10591 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
10592 else if (!strcmp(res->payload_layer, "l4"))
10593 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
10595 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
10596 RTE_ETH_FDIR_MAX_FLEXLEN);
10598 printf("error: Cannot parse flex payload input.\n");
10602 fdir_set_flex_payload(res->port_id, &flex_cfg);
10603 cmd_reconfig_device_queue(res->port_id, 1, 1);
10606 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
10607 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10608 flow_director_flexpayload,
10609 "flow_director_flex_payload");
10610 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
10611 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10612 port_id, RTE_UINT16);
10613 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
10614 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10615 payload_layer, "raw#l2#l3#l4");
10616 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
10617 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10618 payload_cfg, NULL);
10620 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
10621 .f = cmd_flow_director_flxpld_parsed,
10623 .help_str = "flow_director_flexpayload ... : "
10624 "Set flow director's flex payload on NIC",
10626 (void *)&cmd_flow_director_flexpayload,
10627 (void *)&cmd_flow_director_flexpayload_port_id,
10628 (void *)&cmd_flow_director_flexpayload_payload_layer,
10629 (void *)&cmd_flow_director_flexpayload_payload_cfg,
10634 /* Generic flow interface command. */
10635 extern cmdline_parse_inst_t cmd_flow;
10637 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
10638 struct cmd_mcast_addr_result {
10639 cmdline_fixed_string_t mcast_addr_cmd;
10640 cmdline_fixed_string_t what;
10642 struct rte_ether_addr mc_addr;
10645 static void cmd_mcast_addr_parsed(void *parsed_result,
10646 __rte_unused struct cmdline *cl,
10647 __rte_unused void *data)
10649 struct cmd_mcast_addr_result *res = parsed_result;
10651 if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
10652 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
10653 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
10654 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
10655 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
10658 if (strcmp(res->what, "add") == 0)
10659 mcast_addr_add(res->port_num, &res->mc_addr);
10661 mcast_addr_remove(res->port_num, &res->mc_addr);
10664 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
10665 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
10666 mcast_addr_cmd, "mcast_addr");
10667 cmdline_parse_token_string_t cmd_mcast_addr_what =
10668 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
10670 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
10671 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num,
10673 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
10674 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
10676 cmdline_parse_inst_t cmd_mcast_addr = {
10677 .f = cmd_mcast_addr_parsed,
10679 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
10680 "Add/Remove multicast MAC address on port_id",
10682 (void *)&cmd_mcast_addr_cmd,
10683 (void *)&cmd_mcast_addr_what,
10684 (void *)&cmd_mcast_addr_portnum,
10685 (void *)&cmd_mcast_addr_addr,
10690 /* vf vlan anti spoof configuration */
10692 /* Common result structure for vf vlan anti spoof */
10693 struct cmd_vf_vlan_anti_spoof_result {
10694 cmdline_fixed_string_t set;
10695 cmdline_fixed_string_t vf;
10696 cmdline_fixed_string_t vlan;
10697 cmdline_fixed_string_t antispoof;
10700 cmdline_fixed_string_t on_off;
10703 /* Common CLI fields for vf vlan anti spoof enable disable */
10704 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
10705 TOKEN_STRING_INITIALIZER
10706 (struct cmd_vf_vlan_anti_spoof_result,
10708 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
10709 TOKEN_STRING_INITIALIZER
10710 (struct cmd_vf_vlan_anti_spoof_result,
10712 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
10713 TOKEN_STRING_INITIALIZER
10714 (struct cmd_vf_vlan_anti_spoof_result,
10716 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
10717 TOKEN_STRING_INITIALIZER
10718 (struct cmd_vf_vlan_anti_spoof_result,
10719 antispoof, "antispoof");
10720 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
10721 TOKEN_NUM_INITIALIZER
10722 (struct cmd_vf_vlan_anti_spoof_result,
10723 port_id, RTE_UINT16);
10724 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
10725 TOKEN_NUM_INITIALIZER
10726 (struct cmd_vf_vlan_anti_spoof_result,
10727 vf_id, RTE_UINT32);
10728 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
10729 TOKEN_STRING_INITIALIZER
10730 (struct cmd_vf_vlan_anti_spoof_result,
10734 cmd_set_vf_vlan_anti_spoof_parsed(
10735 void *parsed_result,
10736 __rte_unused struct cmdline *cl,
10737 __rte_unused void *data)
10739 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
10740 int ret = -ENOTSUP;
10742 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
10744 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10747 #ifdef RTE_NET_IXGBE
10748 if (ret == -ENOTSUP)
10749 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
10750 res->vf_id, is_on);
10752 #ifdef RTE_NET_I40E
10753 if (ret == -ENOTSUP)
10754 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
10755 res->vf_id, is_on);
10757 #ifdef RTE_NET_BNXT
10758 if (ret == -ENOTSUP)
10759 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
10760 res->vf_id, is_on);
10767 printf("invalid vf_id %d\n", res->vf_id);
10770 printf("invalid port_id %d\n", res->port_id);
10773 printf("function not implemented\n");
10776 printf("programming error: (%s)\n", strerror(-ret));
10780 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
10781 .f = cmd_set_vf_vlan_anti_spoof_parsed,
10783 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
10785 (void *)&cmd_vf_vlan_anti_spoof_set,
10786 (void *)&cmd_vf_vlan_anti_spoof_vf,
10787 (void *)&cmd_vf_vlan_anti_spoof_vlan,
10788 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
10789 (void *)&cmd_vf_vlan_anti_spoof_port_id,
10790 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
10791 (void *)&cmd_vf_vlan_anti_spoof_on_off,
10796 /* vf mac anti spoof configuration */
10798 /* Common result structure for vf mac anti spoof */
10799 struct cmd_vf_mac_anti_spoof_result {
10800 cmdline_fixed_string_t set;
10801 cmdline_fixed_string_t vf;
10802 cmdline_fixed_string_t mac;
10803 cmdline_fixed_string_t antispoof;
10806 cmdline_fixed_string_t on_off;
10809 /* Common CLI fields for vf mac anti spoof enable disable */
10810 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
10811 TOKEN_STRING_INITIALIZER
10812 (struct cmd_vf_mac_anti_spoof_result,
10814 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
10815 TOKEN_STRING_INITIALIZER
10816 (struct cmd_vf_mac_anti_spoof_result,
10818 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
10819 TOKEN_STRING_INITIALIZER
10820 (struct cmd_vf_mac_anti_spoof_result,
10822 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
10823 TOKEN_STRING_INITIALIZER
10824 (struct cmd_vf_mac_anti_spoof_result,
10825 antispoof, "antispoof");
10826 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
10827 TOKEN_NUM_INITIALIZER
10828 (struct cmd_vf_mac_anti_spoof_result,
10829 port_id, RTE_UINT16);
10830 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
10831 TOKEN_NUM_INITIALIZER
10832 (struct cmd_vf_mac_anti_spoof_result,
10833 vf_id, RTE_UINT32);
10834 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
10835 TOKEN_STRING_INITIALIZER
10836 (struct cmd_vf_mac_anti_spoof_result,
10840 cmd_set_vf_mac_anti_spoof_parsed(
10841 void *parsed_result,
10842 __rte_unused struct cmdline *cl,
10843 __rte_unused void *data)
10845 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
10846 int ret = -ENOTSUP;
10848 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
10850 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10853 #ifdef RTE_NET_IXGBE
10854 if (ret == -ENOTSUP)
10855 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
10856 res->vf_id, is_on);
10858 #ifdef RTE_NET_I40E
10859 if (ret == -ENOTSUP)
10860 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
10861 res->vf_id, is_on);
10863 #ifdef RTE_NET_BNXT
10864 if (ret == -ENOTSUP)
10865 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
10866 res->vf_id, is_on);
10873 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
10876 printf("invalid port_id %d\n", res->port_id);
10879 printf("function not implemented\n");
10882 printf("programming error: (%s)\n", strerror(-ret));
10886 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
10887 .f = cmd_set_vf_mac_anti_spoof_parsed,
10889 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
10891 (void *)&cmd_vf_mac_anti_spoof_set,
10892 (void *)&cmd_vf_mac_anti_spoof_vf,
10893 (void *)&cmd_vf_mac_anti_spoof_mac,
10894 (void *)&cmd_vf_mac_anti_spoof_antispoof,
10895 (void *)&cmd_vf_mac_anti_spoof_port_id,
10896 (void *)&cmd_vf_mac_anti_spoof_vf_id,
10897 (void *)&cmd_vf_mac_anti_spoof_on_off,
10902 /* vf vlan strip queue configuration */
10904 /* Common result structure for vf mac anti spoof */
10905 struct cmd_vf_vlan_stripq_result {
10906 cmdline_fixed_string_t set;
10907 cmdline_fixed_string_t vf;
10908 cmdline_fixed_string_t vlan;
10909 cmdline_fixed_string_t stripq;
10912 cmdline_fixed_string_t on_off;
10915 /* Common CLI fields for vf vlan strip enable disable */
10916 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
10917 TOKEN_STRING_INITIALIZER
10918 (struct cmd_vf_vlan_stripq_result,
10920 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
10921 TOKEN_STRING_INITIALIZER
10922 (struct cmd_vf_vlan_stripq_result,
10924 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
10925 TOKEN_STRING_INITIALIZER
10926 (struct cmd_vf_vlan_stripq_result,
10928 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
10929 TOKEN_STRING_INITIALIZER
10930 (struct cmd_vf_vlan_stripq_result,
10932 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
10933 TOKEN_NUM_INITIALIZER
10934 (struct cmd_vf_vlan_stripq_result,
10935 port_id, RTE_UINT16);
10936 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
10937 TOKEN_NUM_INITIALIZER
10938 (struct cmd_vf_vlan_stripq_result,
10939 vf_id, RTE_UINT16);
10940 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
10941 TOKEN_STRING_INITIALIZER
10942 (struct cmd_vf_vlan_stripq_result,
10946 cmd_set_vf_vlan_stripq_parsed(
10947 void *parsed_result,
10948 __rte_unused struct cmdline *cl,
10949 __rte_unused void *data)
10951 struct cmd_vf_vlan_stripq_result *res = parsed_result;
10952 int ret = -ENOTSUP;
10954 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
10956 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10959 #ifdef RTE_NET_IXGBE
10960 if (ret == -ENOTSUP)
10961 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
10962 res->vf_id, is_on);
10964 #ifdef RTE_NET_I40E
10965 if (ret == -ENOTSUP)
10966 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
10967 res->vf_id, is_on);
10969 #ifdef RTE_NET_BNXT
10970 if (ret == -ENOTSUP)
10971 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
10972 res->vf_id, is_on);
10979 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
10982 printf("invalid port_id %d\n", res->port_id);
10985 printf("function not implemented\n");
10988 printf("programming error: (%s)\n", strerror(-ret));
10992 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
10993 .f = cmd_set_vf_vlan_stripq_parsed,
10995 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
10997 (void *)&cmd_vf_vlan_stripq_set,
10998 (void *)&cmd_vf_vlan_stripq_vf,
10999 (void *)&cmd_vf_vlan_stripq_vlan,
11000 (void *)&cmd_vf_vlan_stripq_stripq,
11001 (void *)&cmd_vf_vlan_stripq_port_id,
11002 (void *)&cmd_vf_vlan_stripq_vf_id,
11003 (void *)&cmd_vf_vlan_stripq_on_off,
11008 /* vf vlan insert configuration */
11010 /* Common result structure for vf vlan insert */
11011 struct cmd_vf_vlan_insert_result {
11012 cmdline_fixed_string_t set;
11013 cmdline_fixed_string_t vf;
11014 cmdline_fixed_string_t vlan;
11015 cmdline_fixed_string_t insert;
11021 /* Common CLI fields for vf vlan insert enable disable */
11022 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
11023 TOKEN_STRING_INITIALIZER
11024 (struct cmd_vf_vlan_insert_result,
11026 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
11027 TOKEN_STRING_INITIALIZER
11028 (struct cmd_vf_vlan_insert_result,
11030 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
11031 TOKEN_STRING_INITIALIZER
11032 (struct cmd_vf_vlan_insert_result,
11034 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
11035 TOKEN_STRING_INITIALIZER
11036 (struct cmd_vf_vlan_insert_result,
11038 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
11039 TOKEN_NUM_INITIALIZER
11040 (struct cmd_vf_vlan_insert_result,
11041 port_id, RTE_UINT16);
11042 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
11043 TOKEN_NUM_INITIALIZER
11044 (struct cmd_vf_vlan_insert_result,
11045 vf_id, RTE_UINT16);
11046 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
11047 TOKEN_NUM_INITIALIZER
11048 (struct cmd_vf_vlan_insert_result,
11049 vlan_id, RTE_UINT16);
11052 cmd_set_vf_vlan_insert_parsed(
11053 void *parsed_result,
11054 __rte_unused struct cmdline *cl,
11055 __rte_unused void *data)
11057 struct cmd_vf_vlan_insert_result *res = parsed_result;
11058 int ret = -ENOTSUP;
11060 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11063 #ifdef RTE_NET_IXGBE
11064 if (ret == -ENOTSUP)
11065 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
11068 #ifdef RTE_NET_I40E
11069 if (ret == -ENOTSUP)
11070 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
11073 #ifdef RTE_NET_BNXT
11074 if (ret == -ENOTSUP)
11075 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
11083 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
11086 printf("invalid port_id %d\n", res->port_id);
11089 printf("function not implemented\n");
11092 printf("programming error: (%s)\n", strerror(-ret));
11096 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
11097 .f = cmd_set_vf_vlan_insert_parsed,
11099 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
11101 (void *)&cmd_vf_vlan_insert_set,
11102 (void *)&cmd_vf_vlan_insert_vf,
11103 (void *)&cmd_vf_vlan_insert_vlan,
11104 (void *)&cmd_vf_vlan_insert_insert,
11105 (void *)&cmd_vf_vlan_insert_port_id,
11106 (void *)&cmd_vf_vlan_insert_vf_id,
11107 (void *)&cmd_vf_vlan_insert_vlan_id,
11112 /* tx loopback configuration */
11114 /* Common result structure for tx loopback */
11115 struct cmd_tx_loopback_result {
11116 cmdline_fixed_string_t set;
11117 cmdline_fixed_string_t tx;
11118 cmdline_fixed_string_t loopback;
11120 cmdline_fixed_string_t on_off;
11123 /* Common CLI fields for tx loopback enable disable */
11124 cmdline_parse_token_string_t cmd_tx_loopback_set =
11125 TOKEN_STRING_INITIALIZER
11126 (struct cmd_tx_loopback_result,
11128 cmdline_parse_token_string_t cmd_tx_loopback_tx =
11129 TOKEN_STRING_INITIALIZER
11130 (struct cmd_tx_loopback_result,
11132 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
11133 TOKEN_STRING_INITIALIZER
11134 (struct cmd_tx_loopback_result,
11135 loopback, "loopback");
11136 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
11137 TOKEN_NUM_INITIALIZER
11138 (struct cmd_tx_loopback_result,
11139 port_id, RTE_UINT16);
11140 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
11141 TOKEN_STRING_INITIALIZER
11142 (struct cmd_tx_loopback_result,
11146 cmd_set_tx_loopback_parsed(
11147 void *parsed_result,
11148 __rte_unused struct cmdline *cl,
11149 __rte_unused void *data)
11151 struct cmd_tx_loopback_result *res = parsed_result;
11152 int ret = -ENOTSUP;
11154 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11156 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11159 #ifdef RTE_NET_IXGBE
11160 if (ret == -ENOTSUP)
11161 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
11163 #ifdef RTE_NET_I40E
11164 if (ret == -ENOTSUP)
11165 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
11167 #ifdef RTE_NET_BNXT
11168 if (ret == -ENOTSUP)
11169 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
11171 #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA
11172 if (ret == -ENOTSUP)
11173 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
11180 printf("invalid is_on %d\n", is_on);
11183 printf("invalid port_id %d\n", res->port_id);
11186 printf("function not implemented\n");
11189 printf("programming error: (%s)\n", strerror(-ret));
11193 cmdline_parse_inst_t cmd_set_tx_loopback = {
11194 .f = cmd_set_tx_loopback_parsed,
11196 .help_str = "set tx loopback <port_id> on|off",
11198 (void *)&cmd_tx_loopback_set,
11199 (void *)&cmd_tx_loopback_tx,
11200 (void *)&cmd_tx_loopback_loopback,
11201 (void *)&cmd_tx_loopback_port_id,
11202 (void *)&cmd_tx_loopback_on_off,
11207 /* all queues drop enable configuration */
11209 /* Common result structure for all queues drop enable */
11210 struct cmd_all_queues_drop_en_result {
11211 cmdline_fixed_string_t set;
11212 cmdline_fixed_string_t all;
11213 cmdline_fixed_string_t queues;
11214 cmdline_fixed_string_t drop;
11216 cmdline_fixed_string_t on_off;
11219 /* Common CLI fields for tx loopback enable disable */
11220 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
11221 TOKEN_STRING_INITIALIZER
11222 (struct cmd_all_queues_drop_en_result,
11224 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
11225 TOKEN_STRING_INITIALIZER
11226 (struct cmd_all_queues_drop_en_result,
11228 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
11229 TOKEN_STRING_INITIALIZER
11230 (struct cmd_all_queues_drop_en_result,
11232 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
11233 TOKEN_STRING_INITIALIZER
11234 (struct cmd_all_queues_drop_en_result,
11236 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
11237 TOKEN_NUM_INITIALIZER
11238 (struct cmd_all_queues_drop_en_result,
11239 port_id, RTE_UINT16);
11240 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
11241 TOKEN_STRING_INITIALIZER
11242 (struct cmd_all_queues_drop_en_result,
11246 cmd_set_all_queues_drop_en_parsed(
11247 void *parsed_result,
11248 __rte_unused struct cmdline *cl,
11249 __rte_unused void *data)
11251 struct cmd_all_queues_drop_en_result *res = parsed_result;
11252 int ret = -ENOTSUP;
11253 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11255 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11258 #ifdef RTE_NET_IXGBE
11259 if (ret == -ENOTSUP)
11260 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
11262 #ifdef RTE_NET_BNXT
11263 if (ret == -ENOTSUP)
11264 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
11270 printf("invalid is_on %d\n", is_on);
11273 printf("invalid port_id %d\n", res->port_id);
11276 printf("function not implemented\n");
11279 printf("programming error: (%s)\n", strerror(-ret));
11283 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
11284 .f = cmd_set_all_queues_drop_en_parsed,
11286 .help_str = "set all queues drop <port_id> on|off",
11288 (void *)&cmd_all_queues_drop_en_set,
11289 (void *)&cmd_all_queues_drop_en_all,
11290 (void *)&cmd_all_queues_drop_en_queues,
11291 (void *)&cmd_all_queues_drop_en_drop,
11292 (void *)&cmd_all_queues_drop_en_port_id,
11293 (void *)&cmd_all_queues_drop_en_on_off,
11298 /* vf split drop enable configuration */
11300 /* Common result structure for vf split drop enable */
11301 struct cmd_vf_split_drop_en_result {
11302 cmdline_fixed_string_t set;
11303 cmdline_fixed_string_t vf;
11304 cmdline_fixed_string_t split;
11305 cmdline_fixed_string_t drop;
11308 cmdline_fixed_string_t on_off;
11311 /* Common CLI fields for vf split drop enable disable */
11312 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
11313 TOKEN_STRING_INITIALIZER
11314 (struct cmd_vf_split_drop_en_result,
11316 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
11317 TOKEN_STRING_INITIALIZER
11318 (struct cmd_vf_split_drop_en_result,
11320 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
11321 TOKEN_STRING_INITIALIZER
11322 (struct cmd_vf_split_drop_en_result,
11324 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
11325 TOKEN_STRING_INITIALIZER
11326 (struct cmd_vf_split_drop_en_result,
11328 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
11329 TOKEN_NUM_INITIALIZER
11330 (struct cmd_vf_split_drop_en_result,
11331 port_id, RTE_UINT16);
11332 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
11333 TOKEN_NUM_INITIALIZER
11334 (struct cmd_vf_split_drop_en_result,
11335 vf_id, RTE_UINT16);
11336 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
11337 TOKEN_STRING_INITIALIZER
11338 (struct cmd_vf_split_drop_en_result,
11342 cmd_set_vf_split_drop_en_parsed(
11343 void *parsed_result,
11344 __rte_unused struct cmdline *cl,
11345 __rte_unused void *data)
11347 struct cmd_vf_split_drop_en_result *res = parsed_result;
11348 int ret = -ENOTSUP;
11349 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11351 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11354 #ifdef RTE_NET_IXGBE
11355 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
11362 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11365 printf("invalid port_id %d\n", res->port_id);
11368 printf("not supported on port %d\n", res->port_id);
11371 printf("programming error: (%s)\n", strerror(-ret));
11375 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
11376 .f = cmd_set_vf_split_drop_en_parsed,
11378 .help_str = "set vf split drop <port_id> <vf_id> on|off",
11380 (void *)&cmd_vf_split_drop_en_set,
11381 (void *)&cmd_vf_split_drop_en_vf,
11382 (void *)&cmd_vf_split_drop_en_split,
11383 (void *)&cmd_vf_split_drop_en_drop,
11384 (void *)&cmd_vf_split_drop_en_port_id,
11385 (void *)&cmd_vf_split_drop_en_vf_id,
11386 (void *)&cmd_vf_split_drop_en_on_off,
11391 /* vf mac address configuration */
11393 /* Common result structure for vf mac address */
11394 struct cmd_set_vf_mac_addr_result {
11395 cmdline_fixed_string_t set;
11396 cmdline_fixed_string_t vf;
11397 cmdline_fixed_string_t mac;
11398 cmdline_fixed_string_t addr;
11401 struct rte_ether_addr mac_addr;
11405 /* Common CLI fields for vf split drop enable disable */
11406 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
11407 TOKEN_STRING_INITIALIZER
11408 (struct cmd_set_vf_mac_addr_result,
11410 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
11411 TOKEN_STRING_INITIALIZER
11412 (struct cmd_set_vf_mac_addr_result,
11414 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
11415 TOKEN_STRING_INITIALIZER
11416 (struct cmd_set_vf_mac_addr_result,
11418 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
11419 TOKEN_STRING_INITIALIZER
11420 (struct cmd_set_vf_mac_addr_result,
11422 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
11423 TOKEN_NUM_INITIALIZER
11424 (struct cmd_set_vf_mac_addr_result,
11425 port_id, RTE_UINT16);
11426 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
11427 TOKEN_NUM_INITIALIZER
11428 (struct cmd_set_vf_mac_addr_result,
11429 vf_id, RTE_UINT16);
11430 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
11431 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
11435 cmd_set_vf_mac_addr_parsed(
11436 void *parsed_result,
11437 __rte_unused struct cmdline *cl,
11438 __rte_unused void *data)
11440 struct cmd_set_vf_mac_addr_result *res = parsed_result;
11441 int ret = -ENOTSUP;
11443 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11446 #ifdef RTE_NET_IXGBE
11447 if (ret == -ENOTSUP)
11448 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
11451 #ifdef RTE_NET_I40E
11452 if (ret == -ENOTSUP)
11453 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
11456 #ifdef RTE_NET_BNXT
11457 if (ret == -ENOTSUP)
11458 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
11466 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
11469 printf("invalid port_id %d\n", res->port_id);
11472 printf("function not implemented\n");
11475 printf("programming error: (%s)\n", strerror(-ret));
11479 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
11480 .f = cmd_set_vf_mac_addr_parsed,
11482 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
11484 (void *)&cmd_set_vf_mac_addr_set,
11485 (void *)&cmd_set_vf_mac_addr_vf,
11486 (void *)&cmd_set_vf_mac_addr_mac,
11487 (void *)&cmd_set_vf_mac_addr_addr,
11488 (void *)&cmd_set_vf_mac_addr_port_id,
11489 (void *)&cmd_set_vf_mac_addr_vf_id,
11490 (void *)&cmd_set_vf_mac_addr_mac_addr,
11495 /* MACsec configuration */
11497 /* Common result structure for MACsec offload enable */
11498 struct cmd_macsec_offload_on_result {
11499 cmdline_fixed_string_t set;
11500 cmdline_fixed_string_t macsec;
11501 cmdline_fixed_string_t offload;
11503 cmdline_fixed_string_t on;
11504 cmdline_fixed_string_t encrypt;
11505 cmdline_fixed_string_t en_on_off;
11506 cmdline_fixed_string_t replay_protect;
11507 cmdline_fixed_string_t rp_on_off;
11510 /* Common CLI fields for MACsec offload disable */
11511 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
11512 TOKEN_STRING_INITIALIZER
11513 (struct cmd_macsec_offload_on_result,
11515 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
11516 TOKEN_STRING_INITIALIZER
11517 (struct cmd_macsec_offload_on_result,
11519 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
11520 TOKEN_STRING_INITIALIZER
11521 (struct cmd_macsec_offload_on_result,
11522 offload, "offload");
11523 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
11524 TOKEN_NUM_INITIALIZER
11525 (struct cmd_macsec_offload_on_result,
11526 port_id, RTE_UINT16);
11527 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
11528 TOKEN_STRING_INITIALIZER
11529 (struct cmd_macsec_offload_on_result,
11531 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
11532 TOKEN_STRING_INITIALIZER
11533 (struct cmd_macsec_offload_on_result,
11534 encrypt, "encrypt");
11535 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
11536 TOKEN_STRING_INITIALIZER
11537 (struct cmd_macsec_offload_on_result,
11538 en_on_off, "on#off");
11539 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
11540 TOKEN_STRING_INITIALIZER
11541 (struct cmd_macsec_offload_on_result,
11542 replay_protect, "replay-protect");
11543 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
11544 TOKEN_STRING_INITIALIZER
11545 (struct cmd_macsec_offload_on_result,
11546 rp_on_off, "on#off");
11549 cmd_set_macsec_offload_on_parsed(
11550 void *parsed_result,
11551 __rte_unused struct cmdline *cl,
11552 __rte_unused void *data)
11554 struct cmd_macsec_offload_on_result *res = parsed_result;
11555 int ret = -ENOTSUP;
11556 portid_t port_id = res->port_id;
11557 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
11558 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
11559 struct rte_eth_dev_info dev_info;
11561 if (port_id_is_invalid(port_id, ENABLED_WARN))
11563 if (!port_is_stopped(port_id)) {
11564 printf("Please stop port %d first\n", port_id);
11568 ret = eth_dev_info_get_print_err(port_id, &dev_info);
11572 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
11573 #ifdef RTE_NET_IXGBE
11574 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
11582 ports[port_id].dev_conf.txmode.offloads |=
11583 DEV_TX_OFFLOAD_MACSEC_INSERT;
11584 cmd_reconfig_device_queue(port_id, 1, 1);
11587 printf("invalid port_id %d\n", port_id);
11590 printf("not supported on port %d\n", port_id);
11593 printf("programming error: (%s)\n", strerror(-ret));
11597 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
11598 .f = cmd_set_macsec_offload_on_parsed,
11600 .help_str = "set macsec offload <port_id> on "
11601 "encrypt on|off replay-protect on|off",
11603 (void *)&cmd_macsec_offload_on_set,
11604 (void *)&cmd_macsec_offload_on_macsec,
11605 (void *)&cmd_macsec_offload_on_offload,
11606 (void *)&cmd_macsec_offload_on_port_id,
11607 (void *)&cmd_macsec_offload_on_on,
11608 (void *)&cmd_macsec_offload_on_encrypt,
11609 (void *)&cmd_macsec_offload_on_en_on_off,
11610 (void *)&cmd_macsec_offload_on_replay_protect,
11611 (void *)&cmd_macsec_offload_on_rp_on_off,
11616 /* Common result structure for MACsec offload disable */
11617 struct cmd_macsec_offload_off_result {
11618 cmdline_fixed_string_t set;
11619 cmdline_fixed_string_t macsec;
11620 cmdline_fixed_string_t offload;
11622 cmdline_fixed_string_t off;
11625 /* Common CLI fields for MACsec offload disable */
11626 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
11627 TOKEN_STRING_INITIALIZER
11628 (struct cmd_macsec_offload_off_result,
11630 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
11631 TOKEN_STRING_INITIALIZER
11632 (struct cmd_macsec_offload_off_result,
11634 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
11635 TOKEN_STRING_INITIALIZER
11636 (struct cmd_macsec_offload_off_result,
11637 offload, "offload");
11638 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
11639 TOKEN_NUM_INITIALIZER
11640 (struct cmd_macsec_offload_off_result,
11641 port_id, RTE_UINT16);
11642 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
11643 TOKEN_STRING_INITIALIZER
11644 (struct cmd_macsec_offload_off_result,
11648 cmd_set_macsec_offload_off_parsed(
11649 void *parsed_result,
11650 __rte_unused struct cmdline *cl,
11651 __rte_unused void *data)
11653 struct cmd_macsec_offload_off_result *res = parsed_result;
11654 int ret = -ENOTSUP;
11655 struct rte_eth_dev_info dev_info;
11656 portid_t port_id = res->port_id;
11658 if (port_id_is_invalid(port_id, ENABLED_WARN))
11660 if (!port_is_stopped(port_id)) {
11661 printf("Please stop port %d first\n", port_id);
11665 ret = eth_dev_info_get_print_err(port_id, &dev_info);
11669 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
11670 #ifdef RTE_NET_IXGBE
11671 ret = rte_pmd_ixgbe_macsec_disable(port_id);
11676 ports[port_id].dev_conf.txmode.offloads &=
11677 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
11678 cmd_reconfig_device_queue(port_id, 1, 1);
11681 printf("invalid port_id %d\n", port_id);
11684 printf("not supported on port %d\n", port_id);
11687 printf("programming error: (%s)\n", strerror(-ret));
11691 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
11692 .f = cmd_set_macsec_offload_off_parsed,
11694 .help_str = "set macsec offload <port_id> off",
11696 (void *)&cmd_macsec_offload_off_set,
11697 (void *)&cmd_macsec_offload_off_macsec,
11698 (void *)&cmd_macsec_offload_off_offload,
11699 (void *)&cmd_macsec_offload_off_port_id,
11700 (void *)&cmd_macsec_offload_off_off,
11705 /* Common result structure for MACsec secure connection configure */
11706 struct cmd_macsec_sc_result {
11707 cmdline_fixed_string_t set;
11708 cmdline_fixed_string_t macsec;
11709 cmdline_fixed_string_t sc;
11710 cmdline_fixed_string_t tx_rx;
11712 struct rte_ether_addr mac;
11716 /* Common CLI fields for MACsec secure connection configure */
11717 cmdline_parse_token_string_t cmd_macsec_sc_set =
11718 TOKEN_STRING_INITIALIZER
11719 (struct cmd_macsec_sc_result,
11721 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
11722 TOKEN_STRING_INITIALIZER
11723 (struct cmd_macsec_sc_result,
11725 cmdline_parse_token_string_t cmd_macsec_sc_sc =
11726 TOKEN_STRING_INITIALIZER
11727 (struct cmd_macsec_sc_result,
11729 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
11730 TOKEN_STRING_INITIALIZER
11731 (struct cmd_macsec_sc_result,
11733 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
11734 TOKEN_NUM_INITIALIZER
11735 (struct cmd_macsec_sc_result,
11736 port_id, RTE_UINT16);
11737 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
11738 TOKEN_ETHERADDR_INITIALIZER
11739 (struct cmd_macsec_sc_result,
11741 cmdline_parse_token_num_t cmd_macsec_sc_pi =
11742 TOKEN_NUM_INITIALIZER
11743 (struct cmd_macsec_sc_result,
11747 cmd_set_macsec_sc_parsed(
11748 void *parsed_result,
11749 __rte_unused struct cmdline *cl,
11750 __rte_unused void *data)
11752 struct cmd_macsec_sc_result *res = parsed_result;
11753 int ret = -ENOTSUP;
11754 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
11756 #ifdef RTE_NET_IXGBE
11758 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
11759 res->mac.addr_bytes) :
11760 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
11761 res->mac.addr_bytes, res->pi);
11763 RTE_SET_USED(is_tx);
11769 printf("invalid port_id %d\n", res->port_id);
11772 printf("not supported on port %d\n", res->port_id);
11775 printf("programming error: (%s)\n", strerror(-ret));
11779 cmdline_parse_inst_t cmd_set_macsec_sc = {
11780 .f = cmd_set_macsec_sc_parsed,
11782 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
11784 (void *)&cmd_macsec_sc_set,
11785 (void *)&cmd_macsec_sc_macsec,
11786 (void *)&cmd_macsec_sc_sc,
11787 (void *)&cmd_macsec_sc_tx_rx,
11788 (void *)&cmd_macsec_sc_port_id,
11789 (void *)&cmd_macsec_sc_mac,
11790 (void *)&cmd_macsec_sc_pi,
11795 /* Common result structure for MACsec secure connection configure */
11796 struct cmd_macsec_sa_result {
11797 cmdline_fixed_string_t set;
11798 cmdline_fixed_string_t macsec;
11799 cmdline_fixed_string_t sa;
11800 cmdline_fixed_string_t tx_rx;
11805 cmdline_fixed_string_t key;
11808 /* Common CLI fields for MACsec secure connection configure */
11809 cmdline_parse_token_string_t cmd_macsec_sa_set =
11810 TOKEN_STRING_INITIALIZER
11811 (struct cmd_macsec_sa_result,
11813 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
11814 TOKEN_STRING_INITIALIZER
11815 (struct cmd_macsec_sa_result,
11817 cmdline_parse_token_string_t cmd_macsec_sa_sa =
11818 TOKEN_STRING_INITIALIZER
11819 (struct cmd_macsec_sa_result,
11821 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
11822 TOKEN_STRING_INITIALIZER
11823 (struct cmd_macsec_sa_result,
11825 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
11826 TOKEN_NUM_INITIALIZER
11827 (struct cmd_macsec_sa_result,
11828 port_id, RTE_UINT16);
11829 cmdline_parse_token_num_t cmd_macsec_sa_idx =
11830 TOKEN_NUM_INITIALIZER
11831 (struct cmd_macsec_sa_result,
11833 cmdline_parse_token_num_t cmd_macsec_sa_an =
11834 TOKEN_NUM_INITIALIZER
11835 (struct cmd_macsec_sa_result,
11837 cmdline_parse_token_num_t cmd_macsec_sa_pn =
11838 TOKEN_NUM_INITIALIZER
11839 (struct cmd_macsec_sa_result,
11841 cmdline_parse_token_string_t cmd_macsec_sa_key =
11842 TOKEN_STRING_INITIALIZER
11843 (struct cmd_macsec_sa_result,
11847 cmd_set_macsec_sa_parsed(
11848 void *parsed_result,
11849 __rte_unused struct cmdline *cl,
11850 __rte_unused void *data)
11852 struct cmd_macsec_sa_result *res = parsed_result;
11853 int ret = -ENOTSUP;
11854 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
11855 uint8_t key[16] = { 0 };
11861 key_len = strlen(res->key) / 2;
11865 for (i = 0; i < key_len; i++) {
11866 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
11869 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
11872 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
11875 #ifdef RTE_NET_IXGBE
11877 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
11878 res->idx, res->an, res->pn, key) :
11879 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
11880 res->idx, res->an, res->pn, key);
11882 RTE_SET_USED(is_tx);
11889 printf("invalid idx %d or an %d\n", res->idx, res->an);
11892 printf("invalid port_id %d\n", res->port_id);
11895 printf("not supported on port %d\n", res->port_id);
11898 printf("programming error: (%s)\n", strerror(-ret));
11902 cmdline_parse_inst_t cmd_set_macsec_sa = {
11903 .f = cmd_set_macsec_sa_parsed,
11905 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
11907 (void *)&cmd_macsec_sa_set,
11908 (void *)&cmd_macsec_sa_macsec,
11909 (void *)&cmd_macsec_sa_sa,
11910 (void *)&cmd_macsec_sa_tx_rx,
11911 (void *)&cmd_macsec_sa_port_id,
11912 (void *)&cmd_macsec_sa_idx,
11913 (void *)&cmd_macsec_sa_an,
11914 (void *)&cmd_macsec_sa_pn,
11915 (void *)&cmd_macsec_sa_key,
11920 /* VF unicast promiscuous mode configuration */
11922 /* Common result structure for VF unicast promiscuous mode */
11923 struct cmd_vf_promisc_result {
11924 cmdline_fixed_string_t set;
11925 cmdline_fixed_string_t vf;
11926 cmdline_fixed_string_t promisc;
11929 cmdline_fixed_string_t on_off;
11932 /* Common CLI fields for VF unicast promiscuous mode enable disable */
11933 cmdline_parse_token_string_t cmd_vf_promisc_set =
11934 TOKEN_STRING_INITIALIZER
11935 (struct cmd_vf_promisc_result,
11937 cmdline_parse_token_string_t cmd_vf_promisc_vf =
11938 TOKEN_STRING_INITIALIZER
11939 (struct cmd_vf_promisc_result,
11941 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
11942 TOKEN_STRING_INITIALIZER
11943 (struct cmd_vf_promisc_result,
11944 promisc, "promisc");
11945 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
11946 TOKEN_NUM_INITIALIZER
11947 (struct cmd_vf_promisc_result,
11948 port_id, RTE_UINT16);
11949 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
11950 TOKEN_NUM_INITIALIZER
11951 (struct cmd_vf_promisc_result,
11952 vf_id, RTE_UINT32);
11953 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
11954 TOKEN_STRING_INITIALIZER
11955 (struct cmd_vf_promisc_result,
11959 cmd_set_vf_promisc_parsed(
11960 void *parsed_result,
11961 __rte_unused struct cmdline *cl,
11962 __rte_unused void *data)
11964 struct cmd_vf_promisc_result *res = parsed_result;
11965 int ret = -ENOTSUP;
11967 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11969 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11972 #ifdef RTE_NET_I40E
11973 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
11974 res->vf_id, is_on);
11981 printf("invalid vf_id %d\n", res->vf_id);
11984 printf("invalid port_id %d\n", res->port_id);
11987 printf("function not implemented\n");
11990 printf("programming error: (%s)\n", strerror(-ret));
11994 cmdline_parse_inst_t cmd_set_vf_promisc = {
11995 .f = cmd_set_vf_promisc_parsed,
11997 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
11998 "Set unicast promiscuous mode for a VF from the PF",
12000 (void *)&cmd_vf_promisc_set,
12001 (void *)&cmd_vf_promisc_vf,
12002 (void *)&cmd_vf_promisc_promisc,
12003 (void *)&cmd_vf_promisc_port_id,
12004 (void *)&cmd_vf_promisc_vf_id,
12005 (void *)&cmd_vf_promisc_on_off,
12010 /* VF multicast promiscuous mode configuration */
12012 /* Common result structure for VF multicast promiscuous mode */
12013 struct cmd_vf_allmulti_result {
12014 cmdline_fixed_string_t set;
12015 cmdline_fixed_string_t vf;
12016 cmdline_fixed_string_t allmulti;
12019 cmdline_fixed_string_t on_off;
12022 /* Common CLI fields for VF multicast promiscuous mode enable disable */
12023 cmdline_parse_token_string_t cmd_vf_allmulti_set =
12024 TOKEN_STRING_INITIALIZER
12025 (struct cmd_vf_allmulti_result,
12027 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
12028 TOKEN_STRING_INITIALIZER
12029 (struct cmd_vf_allmulti_result,
12031 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
12032 TOKEN_STRING_INITIALIZER
12033 (struct cmd_vf_allmulti_result,
12034 allmulti, "allmulti");
12035 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
12036 TOKEN_NUM_INITIALIZER
12037 (struct cmd_vf_allmulti_result,
12038 port_id, RTE_UINT16);
12039 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
12040 TOKEN_NUM_INITIALIZER
12041 (struct cmd_vf_allmulti_result,
12042 vf_id, RTE_UINT32);
12043 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
12044 TOKEN_STRING_INITIALIZER
12045 (struct cmd_vf_allmulti_result,
12049 cmd_set_vf_allmulti_parsed(
12050 void *parsed_result,
12051 __rte_unused struct cmdline *cl,
12052 __rte_unused void *data)
12054 struct cmd_vf_allmulti_result *res = parsed_result;
12055 int ret = -ENOTSUP;
12057 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12059 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12062 #ifdef RTE_NET_I40E
12063 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
12064 res->vf_id, is_on);
12071 printf("invalid vf_id %d\n", res->vf_id);
12074 printf("invalid port_id %d\n", res->port_id);
12077 printf("function not implemented\n");
12080 printf("programming error: (%s)\n", strerror(-ret));
12084 cmdline_parse_inst_t cmd_set_vf_allmulti = {
12085 .f = cmd_set_vf_allmulti_parsed,
12087 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
12088 "Set multicast promiscuous mode for a VF from the PF",
12090 (void *)&cmd_vf_allmulti_set,
12091 (void *)&cmd_vf_allmulti_vf,
12092 (void *)&cmd_vf_allmulti_allmulti,
12093 (void *)&cmd_vf_allmulti_port_id,
12094 (void *)&cmd_vf_allmulti_vf_id,
12095 (void *)&cmd_vf_allmulti_on_off,
12100 /* vf broadcast mode configuration */
12102 /* Common result structure for vf broadcast */
12103 struct cmd_set_vf_broadcast_result {
12104 cmdline_fixed_string_t set;
12105 cmdline_fixed_string_t vf;
12106 cmdline_fixed_string_t broadcast;
12109 cmdline_fixed_string_t on_off;
12112 /* Common CLI fields for vf broadcast enable disable */
12113 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
12114 TOKEN_STRING_INITIALIZER
12115 (struct cmd_set_vf_broadcast_result,
12117 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
12118 TOKEN_STRING_INITIALIZER
12119 (struct cmd_set_vf_broadcast_result,
12121 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
12122 TOKEN_STRING_INITIALIZER
12123 (struct cmd_set_vf_broadcast_result,
12124 broadcast, "broadcast");
12125 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
12126 TOKEN_NUM_INITIALIZER
12127 (struct cmd_set_vf_broadcast_result,
12128 port_id, RTE_UINT16);
12129 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
12130 TOKEN_NUM_INITIALIZER
12131 (struct cmd_set_vf_broadcast_result,
12132 vf_id, RTE_UINT16);
12133 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
12134 TOKEN_STRING_INITIALIZER
12135 (struct cmd_set_vf_broadcast_result,
12139 cmd_set_vf_broadcast_parsed(
12140 void *parsed_result,
12141 __rte_unused struct cmdline *cl,
12142 __rte_unused void *data)
12144 struct cmd_set_vf_broadcast_result *res = parsed_result;
12145 int ret = -ENOTSUP;
12147 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12149 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12152 #ifdef RTE_NET_I40E
12153 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
12154 res->vf_id, is_on);
12161 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12164 printf("invalid port_id %d\n", res->port_id);
12167 printf("function not implemented\n");
12170 printf("programming error: (%s)\n", strerror(-ret));
12174 cmdline_parse_inst_t cmd_set_vf_broadcast = {
12175 .f = cmd_set_vf_broadcast_parsed,
12177 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
12179 (void *)&cmd_set_vf_broadcast_set,
12180 (void *)&cmd_set_vf_broadcast_vf,
12181 (void *)&cmd_set_vf_broadcast_broadcast,
12182 (void *)&cmd_set_vf_broadcast_port_id,
12183 (void *)&cmd_set_vf_broadcast_vf_id,
12184 (void *)&cmd_set_vf_broadcast_on_off,
12189 /* vf vlan tag configuration */
12191 /* Common result structure for vf vlan tag */
12192 struct cmd_set_vf_vlan_tag_result {
12193 cmdline_fixed_string_t set;
12194 cmdline_fixed_string_t vf;
12195 cmdline_fixed_string_t vlan;
12196 cmdline_fixed_string_t tag;
12199 cmdline_fixed_string_t on_off;
12202 /* Common CLI fields for vf vlan tag enable disable */
12203 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
12204 TOKEN_STRING_INITIALIZER
12205 (struct cmd_set_vf_vlan_tag_result,
12207 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
12208 TOKEN_STRING_INITIALIZER
12209 (struct cmd_set_vf_vlan_tag_result,
12211 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
12212 TOKEN_STRING_INITIALIZER
12213 (struct cmd_set_vf_vlan_tag_result,
12215 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
12216 TOKEN_STRING_INITIALIZER
12217 (struct cmd_set_vf_vlan_tag_result,
12219 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
12220 TOKEN_NUM_INITIALIZER
12221 (struct cmd_set_vf_vlan_tag_result,
12222 port_id, RTE_UINT16);
12223 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
12224 TOKEN_NUM_INITIALIZER
12225 (struct cmd_set_vf_vlan_tag_result,
12226 vf_id, RTE_UINT16);
12227 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
12228 TOKEN_STRING_INITIALIZER
12229 (struct cmd_set_vf_vlan_tag_result,
12233 cmd_set_vf_vlan_tag_parsed(
12234 void *parsed_result,
12235 __rte_unused struct cmdline *cl,
12236 __rte_unused void *data)
12238 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
12239 int ret = -ENOTSUP;
12241 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12243 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12246 #ifdef RTE_NET_I40E
12247 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
12248 res->vf_id, is_on);
12255 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12258 printf("invalid port_id %d\n", res->port_id);
12261 printf("function not implemented\n");
12264 printf("programming error: (%s)\n", strerror(-ret));
12268 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
12269 .f = cmd_set_vf_vlan_tag_parsed,
12271 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
12273 (void *)&cmd_set_vf_vlan_tag_set,
12274 (void *)&cmd_set_vf_vlan_tag_vf,
12275 (void *)&cmd_set_vf_vlan_tag_vlan,
12276 (void *)&cmd_set_vf_vlan_tag_tag,
12277 (void *)&cmd_set_vf_vlan_tag_port_id,
12278 (void *)&cmd_set_vf_vlan_tag_vf_id,
12279 (void *)&cmd_set_vf_vlan_tag_on_off,
12284 /* Common definition of VF and TC TX bandwidth configuration */
12285 struct cmd_vf_tc_bw_result {
12286 cmdline_fixed_string_t set;
12287 cmdline_fixed_string_t vf;
12288 cmdline_fixed_string_t tc;
12289 cmdline_fixed_string_t tx;
12290 cmdline_fixed_string_t min_bw;
12291 cmdline_fixed_string_t max_bw;
12292 cmdline_fixed_string_t strict_link_prio;
12297 cmdline_fixed_string_t bw_list;
12301 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
12302 TOKEN_STRING_INITIALIZER
12303 (struct cmd_vf_tc_bw_result,
12305 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
12306 TOKEN_STRING_INITIALIZER
12307 (struct cmd_vf_tc_bw_result,
12309 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
12310 TOKEN_STRING_INITIALIZER
12311 (struct cmd_vf_tc_bw_result,
12313 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
12314 TOKEN_STRING_INITIALIZER
12315 (struct cmd_vf_tc_bw_result,
12317 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
12318 TOKEN_STRING_INITIALIZER
12319 (struct cmd_vf_tc_bw_result,
12320 strict_link_prio, "strict-link-priority");
12321 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
12322 TOKEN_STRING_INITIALIZER
12323 (struct cmd_vf_tc_bw_result,
12324 min_bw, "min-bandwidth");
12325 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
12326 TOKEN_STRING_INITIALIZER
12327 (struct cmd_vf_tc_bw_result,
12328 max_bw, "max-bandwidth");
12329 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
12330 TOKEN_NUM_INITIALIZER
12331 (struct cmd_vf_tc_bw_result,
12332 port_id, RTE_UINT16);
12333 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
12334 TOKEN_NUM_INITIALIZER
12335 (struct cmd_vf_tc_bw_result,
12336 vf_id, RTE_UINT16);
12337 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
12338 TOKEN_NUM_INITIALIZER
12339 (struct cmd_vf_tc_bw_result,
12341 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
12342 TOKEN_NUM_INITIALIZER
12343 (struct cmd_vf_tc_bw_result,
12345 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
12346 TOKEN_STRING_INITIALIZER
12347 (struct cmd_vf_tc_bw_result,
12349 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
12350 TOKEN_NUM_INITIALIZER
12351 (struct cmd_vf_tc_bw_result,
12352 tc_map, RTE_UINT8);
12354 /* VF max bandwidth setting */
12356 cmd_vf_max_bw_parsed(
12357 void *parsed_result,
12358 __rte_unused struct cmdline *cl,
12359 __rte_unused void *data)
12361 struct cmd_vf_tc_bw_result *res = parsed_result;
12362 int ret = -ENOTSUP;
12364 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12367 #ifdef RTE_NET_I40E
12368 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
12369 res->vf_id, res->bw);
12376 printf("invalid vf_id %d or bandwidth %d\n",
12377 res->vf_id, res->bw);
12380 printf("invalid port_id %d\n", res->port_id);
12383 printf("function not implemented\n");
12386 printf("programming error: (%s)\n", strerror(-ret));
12390 cmdline_parse_inst_t cmd_vf_max_bw = {
12391 .f = cmd_vf_max_bw_parsed,
12393 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
12395 (void *)&cmd_vf_tc_bw_set,
12396 (void *)&cmd_vf_tc_bw_vf,
12397 (void *)&cmd_vf_tc_bw_tx,
12398 (void *)&cmd_vf_tc_bw_max_bw,
12399 (void *)&cmd_vf_tc_bw_port_id,
12400 (void *)&cmd_vf_tc_bw_vf_id,
12401 (void *)&cmd_vf_tc_bw_bw,
12407 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
12412 const char *p, *p0 = str;
12419 p = strchr(p0, '(');
12421 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
12425 p0 = strchr(p, ')');
12427 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
12431 if (size >= sizeof(s)) {
12432 printf("The string size exceeds the internal buffer size\n");
12435 snprintf(s, sizeof(s), "%.*s", size, p);
12436 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
12438 printf("Failed to get the bandwidth list. ");
12442 for (i = 0; i < ret; i++)
12443 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
12448 /* TC min bandwidth setting */
12450 cmd_vf_tc_min_bw_parsed(
12451 void *parsed_result,
12452 __rte_unused struct cmdline *cl,
12453 __rte_unused void *data)
12455 struct cmd_vf_tc_bw_result *res = parsed_result;
12458 int ret = -ENOTSUP;
12460 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12463 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12467 #ifdef RTE_NET_I40E
12468 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
12476 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
12479 printf("invalid port_id %d\n", res->port_id);
12482 printf("function not implemented\n");
12485 printf("programming error: (%s)\n", strerror(-ret));
12489 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
12490 .f = cmd_vf_tc_min_bw_parsed,
12492 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
12493 " <bw1, bw2, ...>",
12495 (void *)&cmd_vf_tc_bw_set,
12496 (void *)&cmd_vf_tc_bw_vf,
12497 (void *)&cmd_vf_tc_bw_tc,
12498 (void *)&cmd_vf_tc_bw_tx,
12499 (void *)&cmd_vf_tc_bw_min_bw,
12500 (void *)&cmd_vf_tc_bw_port_id,
12501 (void *)&cmd_vf_tc_bw_vf_id,
12502 (void *)&cmd_vf_tc_bw_bw_list,
12508 cmd_tc_min_bw_parsed(
12509 void *parsed_result,
12510 __rte_unused struct cmdline *cl,
12511 __rte_unused void *data)
12513 struct cmd_vf_tc_bw_result *res = parsed_result;
12514 struct rte_port *port;
12517 int ret = -ENOTSUP;
12519 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12522 port = &ports[res->port_id];
12523 /** Check if the port is not started **/
12524 if (port->port_status != RTE_PORT_STOPPED) {
12525 printf("Please stop port %d first\n", res->port_id);
12529 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12533 #ifdef RTE_NET_IXGBE
12534 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
12541 printf("invalid bandwidth\n");
12544 printf("invalid port_id %d\n", res->port_id);
12547 printf("function not implemented\n");
12550 printf("programming error: (%s)\n", strerror(-ret));
12554 cmdline_parse_inst_t cmd_tc_min_bw = {
12555 .f = cmd_tc_min_bw_parsed,
12557 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
12559 (void *)&cmd_vf_tc_bw_set,
12560 (void *)&cmd_vf_tc_bw_tc,
12561 (void *)&cmd_vf_tc_bw_tx,
12562 (void *)&cmd_vf_tc_bw_min_bw,
12563 (void *)&cmd_vf_tc_bw_port_id,
12564 (void *)&cmd_vf_tc_bw_bw_list,
12569 /* TC max bandwidth setting */
12571 cmd_vf_tc_max_bw_parsed(
12572 void *parsed_result,
12573 __rte_unused struct cmdline *cl,
12574 __rte_unused void *data)
12576 struct cmd_vf_tc_bw_result *res = parsed_result;
12577 int ret = -ENOTSUP;
12579 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12582 #ifdef RTE_NET_I40E
12583 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
12584 res->tc_no, res->bw);
12591 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
12592 res->vf_id, res->tc_no, res->bw);
12595 printf("invalid port_id %d\n", res->port_id);
12598 printf("function not implemented\n");
12601 printf("programming error: (%s)\n", strerror(-ret));
12605 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
12606 .f = cmd_vf_tc_max_bw_parsed,
12608 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
12611 (void *)&cmd_vf_tc_bw_set,
12612 (void *)&cmd_vf_tc_bw_vf,
12613 (void *)&cmd_vf_tc_bw_tc,
12614 (void *)&cmd_vf_tc_bw_tx,
12615 (void *)&cmd_vf_tc_bw_max_bw,
12616 (void *)&cmd_vf_tc_bw_port_id,
12617 (void *)&cmd_vf_tc_bw_vf_id,
12618 (void *)&cmd_vf_tc_bw_tc_no,
12619 (void *)&cmd_vf_tc_bw_bw,
12624 /** Set VXLAN encapsulation details */
12625 struct cmd_set_vxlan_result {
12626 cmdline_fixed_string_t set;
12627 cmdline_fixed_string_t vxlan;
12628 cmdline_fixed_string_t pos_token;
12629 cmdline_fixed_string_t ip_version;
12630 uint32_t vlan_present:1;
12634 cmdline_ipaddr_t ip_src;
12635 cmdline_ipaddr_t ip_dst;
12639 struct rte_ether_addr eth_src;
12640 struct rte_ether_addr eth_dst;
12643 cmdline_parse_token_string_t cmd_set_vxlan_set =
12644 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
12645 cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
12646 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
12647 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
12648 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
12650 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
12651 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
12652 "vxlan-with-vlan");
12653 cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
12654 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12656 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
12657 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
12659 cmdline_parse_token_string_t cmd_set_vxlan_vni =
12660 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12662 cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
12663 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, RTE_UINT32);
12664 cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
12665 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12667 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
12668 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, RTE_UINT16);
12669 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
12670 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12672 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
12673 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, RTE_UINT16);
12674 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
12675 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12677 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
12678 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, RTE_UINT8);
12679 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
12680 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12682 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
12683 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, RTE_UINT8);
12684 cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
12685 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12687 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
12688 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
12689 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
12690 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12692 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
12693 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
12694 cmdline_parse_token_string_t cmd_set_vxlan_vlan =
12695 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12697 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
12698 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, RTE_UINT16);
12699 cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
12700 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12702 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
12703 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
12704 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
12705 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12707 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
12708 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
12710 static void cmd_set_vxlan_parsed(void *parsed_result,
12711 __rte_unused struct cmdline *cl,
12712 __rte_unused void *data)
12714 struct cmd_set_vxlan_result *res = parsed_result;
12719 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
12722 vxlan_encap_conf.select_tos_ttl = 0;
12723 if (strcmp(res->vxlan, "vxlan") == 0)
12724 vxlan_encap_conf.select_vlan = 0;
12725 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
12726 vxlan_encap_conf.select_vlan = 1;
12727 else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
12728 vxlan_encap_conf.select_vlan = 0;
12729 vxlan_encap_conf.select_tos_ttl = 1;
12731 if (strcmp(res->ip_version, "ipv4") == 0)
12732 vxlan_encap_conf.select_ipv4 = 1;
12733 else if (strcmp(res->ip_version, "ipv6") == 0)
12734 vxlan_encap_conf.select_ipv4 = 0;
12737 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
12738 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
12739 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
12740 vxlan_encap_conf.ip_tos = res->tos;
12741 vxlan_encap_conf.ip_ttl = res->ttl;
12742 if (vxlan_encap_conf.select_ipv4) {
12743 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
12744 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
12746 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
12747 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
12749 if (vxlan_encap_conf.select_vlan)
12750 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
12751 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
12752 RTE_ETHER_ADDR_LEN);
12753 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
12754 RTE_ETHER_ADDR_LEN);
12757 cmdline_parse_inst_t cmd_set_vxlan = {
12758 .f = cmd_set_vxlan_parsed,
12760 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
12761 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
12762 " eth-src <eth-src> eth-dst <eth-dst>",
12764 (void *)&cmd_set_vxlan_set,
12765 (void *)&cmd_set_vxlan_vxlan,
12766 (void *)&cmd_set_vxlan_ip_version,
12767 (void *)&cmd_set_vxlan_ip_version_value,
12768 (void *)&cmd_set_vxlan_vni,
12769 (void *)&cmd_set_vxlan_vni_value,
12770 (void *)&cmd_set_vxlan_udp_src,
12771 (void *)&cmd_set_vxlan_udp_src_value,
12772 (void *)&cmd_set_vxlan_udp_dst,
12773 (void *)&cmd_set_vxlan_udp_dst_value,
12774 (void *)&cmd_set_vxlan_ip_src,
12775 (void *)&cmd_set_vxlan_ip_src_value,
12776 (void *)&cmd_set_vxlan_ip_dst,
12777 (void *)&cmd_set_vxlan_ip_dst_value,
12778 (void *)&cmd_set_vxlan_eth_src,
12779 (void *)&cmd_set_vxlan_eth_src_value,
12780 (void *)&cmd_set_vxlan_eth_dst,
12781 (void *)&cmd_set_vxlan_eth_dst_value,
12786 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
12787 .f = cmd_set_vxlan_parsed,
12789 .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
12790 " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
12791 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
12792 " eth-dst <eth-dst>",
12794 (void *)&cmd_set_vxlan_set,
12795 (void *)&cmd_set_vxlan_vxlan_tos_ttl,
12796 (void *)&cmd_set_vxlan_ip_version,
12797 (void *)&cmd_set_vxlan_ip_version_value,
12798 (void *)&cmd_set_vxlan_vni,
12799 (void *)&cmd_set_vxlan_vni_value,
12800 (void *)&cmd_set_vxlan_udp_src,
12801 (void *)&cmd_set_vxlan_udp_src_value,
12802 (void *)&cmd_set_vxlan_udp_dst,
12803 (void *)&cmd_set_vxlan_udp_dst_value,
12804 (void *)&cmd_set_vxlan_ip_tos,
12805 (void *)&cmd_set_vxlan_ip_tos_value,
12806 (void *)&cmd_set_vxlan_ip_ttl,
12807 (void *)&cmd_set_vxlan_ip_ttl_value,
12808 (void *)&cmd_set_vxlan_ip_src,
12809 (void *)&cmd_set_vxlan_ip_src_value,
12810 (void *)&cmd_set_vxlan_ip_dst,
12811 (void *)&cmd_set_vxlan_ip_dst_value,
12812 (void *)&cmd_set_vxlan_eth_src,
12813 (void *)&cmd_set_vxlan_eth_src_value,
12814 (void *)&cmd_set_vxlan_eth_dst,
12815 (void *)&cmd_set_vxlan_eth_dst_value,
12820 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
12821 .f = cmd_set_vxlan_parsed,
12823 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
12824 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
12825 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
12828 (void *)&cmd_set_vxlan_set,
12829 (void *)&cmd_set_vxlan_vxlan_with_vlan,
12830 (void *)&cmd_set_vxlan_ip_version,
12831 (void *)&cmd_set_vxlan_ip_version_value,
12832 (void *)&cmd_set_vxlan_vni,
12833 (void *)&cmd_set_vxlan_vni_value,
12834 (void *)&cmd_set_vxlan_udp_src,
12835 (void *)&cmd_set_vxlan_udp_src_value,
12836 (void *)&cmd_set_vxlan_udp_dst,
12837 (void *)&cmd_set_vxlan_udp_dst_value,
12838 (void *)&cmd_set_vxlan_ip_src,
12839 (void *)&cmd_set_vxlan_ip_src_value,
12840 (void *)&cmd_set_vxlan_ip_dst,
12841 (void *)&cmd_set_vxlan_ip_dst_value,
12842 (void *)&cmd_set_vxlan_vlan,
12843 (void *)&cmd_set_vxlan_vlan_value,
12844 (void *)&cmd_set_vxlan_eth_src,
12845 (void *)&cmd_set_vxlan_eth_src_value,
12846 (void *)&cmd_set_vxlan_eth_dst,
12847 (void *)&cmd_set_vxlan_eth_dst_value,
12852 /** Set NVGRE encapsulation details */
12853 struct cmd_set_nvgre_result {
12854 cmdline_fixed_string_t set;
12855 cmdline_fixed_string_t nvgre;
12856 cmdline_fixed_string_t pos_token;
12857 cmdline_fixed_string_t ip_version;
12859 cmdline_ipaddr_t ip_src;
12860 cmdline_ipaddr_t ip_dst;
12862 struct rte_ether_addr eth_src;
12863 struct rte_ether_addr eth_dst;
12866 cmdline_parse_token_string_t cmd_set_nvgre_set =
12867 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
12868 cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
12869 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
12870 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
12871 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
12872 "nvgre-with-vlan");
12873 cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
12874 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
12876 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
12877 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
12879 cmdline_parse_token_string_t cmd_set_nvgre_tni =
12880 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
12882 cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
12883 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, RTE_UINT32);
12884 cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
12885 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
12887 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
12888 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
12889 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
12890 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
12892 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
12893 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
12894 cmdline_parse_token_string_t cmd_set_nvgre_vlan =
12895 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
12897 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
12898 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, RTE_UINT16);
12899 cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
12900 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
12902 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
12903 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
12904 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
12905 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
12907 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
12908 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
12910 static void cmd_set_nvgre_parsed(void *parsed_result,
12911 __rte_unused struct cmdline *cl,
12912 __rte_unused void *data)
12914 struct cmd_set_nvgre_result *res = parsed_result;
12916 uint32_t nvgre_tni;
12919 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
12922 if (strcmp(res->nvgre, "nvgre") == 0)
12923 nvgre_encap_conf.select_vlan = 0;
12924 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
12925 nvgre_encap_conf.select_vlan = 1;
12926 if (strcmp(res->ip_version, "ipv4") == 0)
12927 nvgre_encap_conf.select_ipv4 = 1;
12928 else if (strcmp(res->ip_version, "ipv6") == 0)
12929 nvgre_encap_conf.select_ipv4 = 0;
12932 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
12933 if (nvgre_encap_conf.select_ipv4) {
12934 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
12935 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
12937 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
12938 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
12940 if (nvgre_encap_conf.select_vlan)
12941 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
12942 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
12943 RTE_ETHER_ADDR_LEN);
12944 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
12945 RTE_ETHER_ADDR_LEN);
12948 cmdline_parse_inst_t cmd_set_nvgre = {
12949 .f = cmd_set_nvgre_parsed,
12951 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
12952 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
12953 " eth-dst <eth-dst>",
12955 (void *)&cmd_set_nvgre_set,
12956 (void *)&cmd_set_nvgre_nvgre,
12957 (void *)&cmd_set_nvgre_ip_version,
12958 (void *)&cmd_set_nvgre_ip_version_value,
12959 (void *)&cmd_set_nvgre_tni,
12960 (void *)&cmd_set_nvgre_tni_value,
12961 (void *)&cmd_set_nvgre_ip_src,
12962 (void *)&cmd_set_nvgre_ip_src_value,
12963 (void *)&cmd_set_nvgre_ip_dst,
12964 (void *)&cmd_set_nvgre_ip_dst_value,
12965 (void *)&cmd_set_nvgre_eth_src,
12966 (void *)&cmd_set_nvgre_eth_src_value,
12967 (void *)&cmd_set_nvgre_eth_dst,
12968 (void *)&cmd_set_nvgre_eth_dst_value,
12973 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
12974 .f = cmd_set_nvgre_parsed,
12976 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
12977 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
12978 " eth-src <eth-src> eth-dst <eth-dst>",
12980 (void *)&cmd_set_nvgre_set,
12981 (void *)&cmd_set_nvgre_nvgre_with_vlan,
12982 (void *)&cmd_set_nvgre_ip_version,
12983 (void *)&cmd_set_nvgre_ip_version_value,
12984 (void *)&cmd_set_nvgre_tni,
12985 (void *)&cmd_set_nvgre_tni_value,
12986 (void *)&cmd_set_nvgre_ip_src,
12987 (void *)&cmd_set_nvgre_ip_src_value,
12988 (void *)&cmd_set_nvgre_ip_dst,
12989 (void *)&cmd_set_nvgre_ip_dst_value,
12990 (void *)&cmd_set_nvgre_vlan,
12991 (void *)&cmd_set_nvgre_vlan_value,
12992 (void *)&cmd_set_nvgre_eth_src,
12993 (void *)&cmd_set_nvgre_eth_src_value,
12994 (void *)&cmd_set_nvgre_eth_dst,
12995 (void *)&cmd_set_nvgre_eth_dst_value,
13000 /** Set L2 encapsulation details */
13001 struct cmd_set_l2_encap_result {
13002 cmdline_fixed_string_t set;
13003 cmdline_fixed_string_t l2_encap;
13004 cmdline_fixed_string_t pos_token;
13005 cmdline_fixed_string_t ip_version;
13006 uint32_t vlan_present:1;
13008 struct rte_ether_addr eth_src;
13009 struct rte_ether_addr eth_dst;
13012 cmdline_parse_token_string_t cmd_set_l2_encap_set =
13013 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
13014 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
13015 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
13016 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
13017 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
13018 "l2_encap-with-vlan");
13019 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
13020 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13022 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
13023 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
13025 cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
13026 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13028 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
13029 TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, RTE_UINT16);
13030 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
13031 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13033 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
13034 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
13035 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
13036 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13038 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
13039 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
13041 static void cmd_set_l2_encap_parsed(void *parsed_result,
13042 __rte_unused struct cmdline *cl,
13043 __rte_unused void *data)
13045 struct cmd_set_l2_encap_result *res = parsed_result;
13047 if (strcmp(res->l2_encap, "l2_encap") == 0)
13048 l2_encap_conf.select_vlan = 0;
13049 else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
13050 l2_encap_conf.select_vlan = 1;
13051 if (strcmp(res->ip_version, "ipv4") == 0)
13052 l2_encap_conf.select_ipv4 = 1;
13053 else if (strcmp(res->ip_version, "ipv6") == 0)
13054 l2_encap_conf.select_ipv4 = 0;
13057 if (l2_encap_conf.select_vlan)
13058 l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13059 rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
13060 RTE_ETHER_ADDR_LEN);
13061 rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13062 RTE_ETHER_ADDR_LEN);
13065 cmdline_parse_inst_t cmd_set_l2_encap = {
13066 .f = cmd_set_l2_encap_parsed,
13068 .help_str = "set l2_encap ip-version ipv4|ipv6"
13069 " eth-src <eth-src> eth-dst <eth-dst>",
13071 (void *)&cmd_set_l2_encap_set,
13072 (void *)&cmd_set_l2_encap_l2_encap,
13073 (void *)&cmd_set_l2_encap_ip_version,
13074 (void *)&cmd_set_l2_encap_ip_version_value,
13075 (void *)&cmd_set_l2_encap_eth_src,
13076 (void *)&cmd_set_l2_encap_eth_src_value,
13077 (void *)&cmd_set_l2_encap_eth_dst,
13078 (void *)&cmd_set_l2_encap_eth_dst_value,
13083 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
13084 .f = cmd_set_l2_encap_parsed,
13086 .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
13087 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
13089 (void *)&cmd_set_l2_encap_set,
13090 (void *)&cmd_set_l2_encap_l2_encap_with_vlan,
13091 (void *)&cmd_set_l2_encap_ip_version,
13092 (void *)&cmd_set_l2_encap_ip_version_value,
13093 (void *)&cmd_set_l2_encap_vlan,
13094 (void *)&cmd_set_l2_encap_vlan_value,
13095 (void *)&cmd_set_l2_encap_eth_src,
13096 (void *)&cmd_set_l2_encap_eth_src_value,
13097 (void *)&cmd_set_l2_encap_eth_dst,
13098 (void *)&cmd_set_l2_encap_eth_dst_value,
13103 /** Set L2 decapsulation details */
13104 struct cmd_set_l2_decap_result {
13105 cmdline_fixed_string_t set;
13106 cmdline_fixed_string_t l2_decap;
13107 cmdline_fixed_string_t pos_token;
13108 uint32_t vlan_present:1;
13111 cmdline_parse_token_string_t cmd_set_l2_decap_set =
13112 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
13113 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
13114 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
13116 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
13117 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
13118 "l2_decap-with-vlan");
13120 static void cmd_set_l2_decap_parsed(void *parsed_result,
13121 __rte_unused struct cmdline *cl,
13122 __rte_unused void *data)
13124 struct cmd_set_l2_decap_result *res = parsed_result;
13126 if (strcmp(res->l2_decap, "l2_decap") == 0)
13127 l2_decap_conf.select_vlan = 0;
13128 else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
13129 l2_decap_conf.select_vlan = 1;
13132 cmdline_parse_inst_t cmd_set_l2_decap = {
13133 .f = cmd_set_l2_decap_parsed,
13135 .help_str = "set l2_decap",
13137 (void *)&cmd_set_l2_decap_set,
13138 (void *)&cmd_set_l2_decap_l2_decap,
13143 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
13144 .f = cmd_set_l2_decap_parsed,
13146 .help_str = "set l2_decap-with-vlan",
13148 (void *)&cmd_set_l2_decap_set,
13149 (void *)&cmd_set_l2_decap_l2_decap_with_vlan,
13154 /** Set MPLSoGRE encapsulation details */
13155 struct cmd_set_mplsogre_encap_result {
13156 cmdline_fixed_string_t set;
13157 cmdline_fixed_string_t mplsogre;
13158 cmdline_fixed_string_t pos_token;
13159 cmdline_fixed_string_t ip_version;
13160 uint32_t vlan_present:1;
13162 cmdline_ipaddr_t ip_src;
13163 cmdline_ipaddr_t ip_dst;
13165 struct rte_ether_addr eth_src;
13166 struct rte_ether_addr eth_dst;
13169 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
13170 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
13172 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
13173 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
13175 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
13176 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13177 mplsogre, "mplsogre_encap-with-vlan");
13178 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
13179 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13180 pos_token, "ip-version");
13181 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
13182 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13183 ip_version, "ipv4#ipv6");
13184 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
13185 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13186 pos_token, "label");
13187 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
13188 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
13190 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
13191 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13192 pos_token, "ip-src");
13193 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
13194 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
13195 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
13196 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13197 pos_token, "ip-dst");
13198 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
13199 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
13200 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
13201 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13202 pos_token, "vlan-tci");
13203 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
13204 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
13206 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
13207 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13208 pos_token, "eth-src");
13209 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
13210 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13212 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
13213 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13214 pos_token, "eth-dst");
13215 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
13216 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13219 static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
13220 __rte_unused struct cmdline *cl,
13221 __rte_unused void *data)
13223 struct cmd_set_mplsogre_encap_result *res = parsed_result;
13225 uint32_t mplsogre_label;
13228 .mplsogre_label = rte_cpu_to_be_32(res->label<<12),
13231 if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
13232 mplsogre_encap_conf.select_vlan = 0;
13233 else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
13234 mplsogre_encap_conf.select_vlan = 1;
13235 if (strcmp(res->ip_version, "ipv4") == 0)
13236 mplsogre_encap_conf.select_ipv4 = 1;
13237 else if (strcmp(res->ip_version, "ipv6") == 0)
13238 mplsogre_encap_conf.select_ipv4 = 0;
13241 rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
13242 if (mplsogre_encap_conf.select_ipv4) {
13243 IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
13244 IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
13246 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
13247 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
13249 if (mplsogre_encap_conf.select_vlan)
13250 mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13251 rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
13252 RTE_ETHER_ADDR_LEN);
13253 rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13254 RTE_ETHER_ADDR_LEN);
13257 cmdline_parse_inst_t cmd_set_mplsogre_encap = {
13258 .f = cmd_set_mplsogre_encap_parsed,
13260 .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
13261 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
13262 " eth-dst <eth-dst>",
13264 (void *)&cmd_set_mplsogre_encap_set,
13265 (void *)&cmd_set_mplsogre_encap_mplsogre_encap,
13266 (void *)&cmd_set_mplsogre_encap_ip_version,
13267 (void *)&cmd_set_mplsogre_encap_ip_version_value,
13268 (void *)&cmd_set_mplsogre_encap_label,
13269 (void *)&cmd_set_mplsogre_encap_label_value,
13270 (void *)&cmd_set_mplsogre_encap_ip_src,
13271 (void *)&cmd_set_mplsogre_encap_ip_src_value,
13272 (void *)&cmd_set_mplsogre_encap_ip_dst,
13273 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
13274 (void *)&cmd_set_mplsogre_encap_eth_src,
13275 (void *)&cmd_set_mplsogre_encap_eth_src_value,
13276 (void *)&cmd_set_mplsogre_encap_eth_dst,
13277 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
13282 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
13283 .f = cmd_set_mplsogre_encap_parsed,
13285 .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
13286 " label <label> ip-src <ip-src> ip-dst <ip-dst>"
13287 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
13289 (void *)&cmd_set_mplsogre_encap_set,
13290 (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
13291 (void *)&cmd_set_mplsogre_encap_ip_version,
13292 (void *)&cmd_set_mplsogre_encap_ip_version_value,
13293 (void *)&cmd_set_mplsogre_encap_label,
13294 (void *)&cmd_set_mplsogre_encap_label_value,
13295 (void *)&cmd_set_mplsogre_encap_ip_src,
13296 (void *)&cmd_set_mplsogre_encap_ip_src_value,
13297 (void *)&cmd_set_mplsogre_encap_ip_dst,
13298 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
13299 (void *)&cmd_set_mplsogre_encap_vlan,
13300 (void *)&cmd_set_mplsogre_encap_vlan_value,
13301 (void *)&cmd_set_mplsogre_encap_eth_src,
13302 (void *)&cmd_set_mplsogre_encap_eth_src_value,
13303 (void *)&cmd_set_mplsogre_encap_eth_dst,
13304 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
13309 /** Set MPLSoGRE decapsulation details */
13310 struct cmd_set_mplsogre_decap_result {
13311 cmdline_fixed_string_t set;
13312 cmdline_fixed_string_t mplsogre;
13313 cmdline_fixed_string_t pos_token;
13314 cmdline_fixed_string_t ip_version;
13315 uint32_t vlan_present:1;
13318 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
13319 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
13321 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
13322 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
13324 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
13325 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13326 mplsogre, "mplsogre_decap-with-vlan");
13327 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
13328 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13329 pos_token, "ip-version");
13330 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
13331 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13332 ip_version, "ipv4#ipv6");
13334 static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
13335 __rte_unused struct cmdline *cl,
13336 __rte_unused void *data)
13338 struct cmd_set_mplsogre_decap_result *res = parsed_result;
13340 if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
13341 mplsogre_decap_conf.select_vlan = 0;
13342 else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
13343 mplsogre_decap_conf.select_vlan = 1;
13344 if (strcmp(res->ip_version, "ipv4") == 0)
13345 mplsogre_decap_conf.select_ipv4 = 1;
13346 else if (strcmp(res->ip_version, "ipv6") == 0)
13347 mplsogre_decap_conf.select_ipv4 = 0;
13350 cmdline_parse_inst_t cmd_set_mplsogre_decap = {
13351 .f = cmd_set_mplsogre_decap_parsed,
13353 .help_str = "set mplsogre_decap ip-version ipv4|ipv6",
13355 (void *)&cmd_set_mplsogre_decap_set,
13356 (void *)&cmd_set_mplsogre_decap_mplsogre_decap,
13357 (void *)&cmd_set_mplsogre_decap_ip_version,
13358 (void *)&cmd_set_mplsogre_decap_ip_version_value,
13363 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
13364 .f = cmd_set_mplsogre_decap_parsed,
13366 .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
13368 (void *)&cmd_set_mplsogre_decap_set,
13369 (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
13370 (void *)&cmd_set_mplsogre_decap_ip_version,
13371 (void *)&cmd_set_mplsogre_decap_ip_version_value,
13376 /** Set MPLSoUDP encapsulation details */
13377 struct cmd_set_mplsoudp_encap_result {
13378 cmdline_fixed_string_t set;
13379 cmdline_fixed_string_t mplsoudp;
13380 cmdline_fixed_string_t pos_token;
13381 cmdline_fixed_string_t ip_version;
13382 uint32_t vlan_present:1;
13386 cmdline_ipaddr_t ip_src;
13387 cmdline_ipaddr_t ip_dst;
13389 struct rte_ether_addr eth_src;
13390 struct rte_ether_addr eth_dst;
13393 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
13394 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
13396 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
13397 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
13399 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
13400 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13401 mplsoudp, "mplsoudp_encap-with-vlan");
13402 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
13403 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13404 pos_token, "ip-version");
13405 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
13406 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13407 ip_version, "ipv4#ipv6");
13408 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
13409 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13410 pos_token, "label");
13411 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
13412 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
13414 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
13415 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13416 pos_token, "udp-src");
13417 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
13418 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
13420 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
13421 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13422 pos_token, "udp-dst");
13423 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
13424 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
13426 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
13427 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13428 pos_token, "ip-src");
13429 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
13430 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
13431 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
13432 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13433 pos_token, "ip-dst");
13434 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
13435 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
13436 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
13437 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13438 pos_token, "vlan-tci");
13439 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
13440 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
13442 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
13443 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13444 pos_token, "eth-src");
13445 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
13446 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13448 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
13449 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13450 pos_token, "eth-dst");
13451 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
13452 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13455 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
13456 __rte_unused struct cmdline *cl,
13457 __rte_unused void *data)
13459 struct cmd_set_mplsoudp_encap_result *res = parsed_result;
13461 uint32_t mplsoudp_label;
13464 .mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
13467 if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
13468 mplsoudp_encap_conf.select_vlan = 0;
13469 else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
13470 mplsoudp_encap_conf.select_vlan = 1;
13471 if (strcmp(res->ip_version, "ipv4") == 0)
13472 mplsoudp_encap_conf.select_ipv4 = 1;
13473 else if (strcmp(res->ip_version, "ipv6") == 0)
13474 mplsoudp_encap_conf.select_ipv4 = 0;
13477 rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
13478 mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
13479 mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
13480 if (mplsoudp_encap_conf.select_ipv4) {
13481 IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
13482 IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
13484 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
13485 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
13487 if (mplsoudp_encap_conf.select_vlan)
13488 mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13489 rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
13490 RTE_ETHER_ADDR_LEN);
13491 rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13492 RTE_ETHER_ADDR_LEN);
13495 cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
13496 .f = cmd_set_mplsoudp_encap_parsed,
13498 .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
13499 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
13500 " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
13502 (void *)&cmd_set_mplsoudp_encap_set,
13503 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
13504 (void *)&cmd_set_mplsoudp_encap_ip_version,
13505 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
13506 (void *)&cmd_set_mplsoudp_encap_label,
13507 (void *)&cmd_set_mplsoudp_encap_label_value,
13508 (void *)&cmd_set_mplsoudp_encap_udp_src,
13509 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
13510 (void *)&cmd_set_mplsoudp_encap_udp_dst,
13511 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
13512 (void *)&cmd_set_mplsoudp_encap_ip_src,
13513 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
13514 (void *)&cmd_set_mplsoudp_encap_ip_dst,
13515 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
13516 (void *)&cmd_set_mplsoudp_encap_eth_src,
13517 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
13518 (void *)&cmd_set_mplsoudp_encap_eth_dst,
13519 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
13524 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
13525 .f = cmd_set_mplsoudp_encap_parsed,
13527 .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
13528 " label <label> udp-src <udp-src> udp-dst <udp-dst>"
13529 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
13530 " eth-src <eth-src> eth-dst <eth-dst>",
13532 (void *)&cmd_set_mplsoudp_encap_set,
13533 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
13534 (void *)&cmd_set_mplsoudp_encap_ip_version,
13535 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
13536 (void *)&cmd_set_mplsoudp_encap_label,
13537 (void *)&cmd_set_mplsoudp_encap_label_value,
13538 (void *)&cmd_set_mplsoudp_encap_udp_src,
13539 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
13540 (void *)&cmd_set_mplsoudp_encap_udp_dst,
13541 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
13542 (void *)&cmd_set_mplsoudp_encap_ip_src,
13543 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
13544 (void *)&cmd_set_mplsoudp_encap_ip_dst,
13545 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
13546 (void *)&cmd_set_mplsoudp_encap_vlan,
13547 (void *)&cmd_set_mplsoudp_encap_vlan_value,
13548 (void *)&cmd_set_mplsoudp_encap_eth_src,
13549 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
13550 (void *)&cmd_set_mplsoudp_encap_eth_dst,
13551 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
13556 /** Set MPLSoUDP decapsulation details */
13557 struct cmd_set_mplsoudp_decap_result {
13558 cmdline_fixed_string_t set;
13559 cmdline_fixed_string_t mplsoudp;
13560 cmdline_fixed_string_t pos_token;
13561 cmdline_fixed_string_t ip_version;
13562 uint32_t vlan_present:1;
13565 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
13566 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
13568 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
13569 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
13571 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
13572 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
13573 mplsoudp, "mplsoudp_decap-with-vlan");
13574 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
13575 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
13576 pos_token, "ip-version");
13577 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
13578 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
13579 ip_version, "ipv4#ipv6");
13581 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
13582 __rte_unused struct cmdline *cl,
13583 __rte_unused void *data)
13585 struct cmd_set_mplsoudp_decap_result *res = parsed_result;
13587 if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
13588 mplsoudp_decap_conf.select_vlan = 0;
13589 else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
13590 mplsoudp_decap_conf.select_vlan = 1;
13591 if (strcmp(res->ip_version, "ipv4") == 0)
13592 mplsoudp_decap_conf.select_ipv4 = 1;
13593 else if (strcmp(res->ip_version, "ipv6") == 0)
13594 mplsoudp_decap_conf.select_ipv4 = 0;
13597 cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
13598 .f = cmd_set_mplsoudp_decap_parsed,
13600 .help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
13602 (void *)&cmd_set_mplsoudp_decap_set,
13603 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
13604 (void *)&cmd_set_mplsoudp_decap_ip_version,
13605 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
13610 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
13611 .f = cmd_set_mplsoudp_decap_parsed,
13613 .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
13615 (void *)&cmd_set_mplsoudp_decap_set,
13616 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
13617 (void *)&cmd_set_mplsoudp_decap_ip_version,
13618 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
13623 /* Strict link priority scheduling mode setting */
13625 cmd_strict_link_prio_parsed(
13626 void *parsed_result,
13627 __rte_unused struct cmdline *cl,
13628 __rte_unused void *data)
13630 struct cmd_vf_tc_bw_result *res = parsed_result;
13631 int ret = -ENOTSUP;
13633 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13636 #ifdef RTE_NET_I40E
13637 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
13644 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
13647 printf("invalid port_id %d\n", res->port_id);
13650 printf("function not implemented\n");
13653 printf("programming error: (%s)\n", strerror(-ret));
13657 cmdline_parse_inst_t cmd_strict_link_prio = {
13658 .f = cmd_strict_link_prio_parsed,
13660 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
13662 (void *)&cmd_vf_tc_bw_set,
13663 (void *)&cmd_vf_tc_bw_tx,
13664 (void *)&cmd_vf_tc_bw_strict_link_prio,
13665 (void *)&cmd_vf_tc_bw_port_id,
13666 (void *)&cmd_vf_tc_bw_tc_map,
13671 /* Load dynamic device personalization*/
13672 struct cmd_ddp_add_result {
13673 cmdline_fixed_string_t ddp;
13674 cmdline_fixed_string_t add;
13679 cmdline_parse_token_string_t cmd_ddp_add_ddp =
13680 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
13681 cmdline_parse_token_string_t cmd_ddp_add_add =
13682 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
13683 cmdline_parse_token_num_t cmd_ddp_add_port_id =
13684 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id,
13686 cmdline_parse_token_string_t cmd_ddp_add_filepath =
13687 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
13690 cmd_ddp_add_parsed(
13691 void *parsed_result,
13692 __rte_unused struct cmdline *cl,
13693 __rte_unused void *data)
13695 struct cmd_ddp_add_result *res = parsed_result;
13701 int ret = -ENOTSUP;
13703 if (!all_ports_stopped()) {
13704 printf("Please stop all ports first\n");
13708 filepath = strdup(res->filepath);
13709 if (filepath == NULL) {
13710 printf("Failed to allocate memory\n");
13713 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
13715 buff = open_file(file_fld[0], &size);
13717 free((void *)filepath);
13721 #ifdef RTE_NET_I40E
13722 if (ret == -ENOTSUP)
13723 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
13725 RTE_PMD_I40E_PKG_OP_WR_ADD);
13728 if (ret == -EEXIST)
13729 printf("Profile has already existed.\n");
13731 printf("Failed to load profile.\n");
13732 else if (file_num == 2)
13733 save_file(file_fld[1], buff, size);
13736 free((void *)filepath);
13739 cmdline_parse_inst_t cmd_ddp_add = {
13740 .f = cmd_ddp_add_parsed,
13742 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
13744 (void *)&cmd_ddp_add_ddp,
13745 (void *)&cmd_ddp_add_add,
13746 (void *)&cmd_ddp_add_port_id,
13747 (void *)&cmd_ddp_add_filepath,
13752 /* Delete dynamic device personalization*/
13753 struct cmd_ddp_del_result {
13754 cmdline_fixed_string_t ddp;
13755 cmdline_fixed_string_t del;
13760 cmdline_parse_token_string_t cmd_ddp_del_ddp =
13761 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
13762 cmdline_parse_token_string_t cmd_ddp_del_del =
13763 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
13764 cmdline_parse_token_num_t cmd_ddp_del_port_id =
13765 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, RTE_UINT16);
13766 cmdline_parse_token_string_t cmd_ddp_del_filepath =
13767 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
13770 cmd_ddp_del_parsed(
13771 void *parsed_result,
13772 __rte_unused struct cmdline *cl,
13773 __rte_unused void *data)
13775 struct cmd_ddp_del_result *res = parsed_result;
13778 int ret = -ENOTSUP;
13780 if (!all_ports_stopped()) {
13781 printf("Please stop all ports first\n");
13785 buff = open_file(res->filepath, &size);
13789 #ifdef RTE_NET_I40E
13790 if (ret == -ENOTSUP)
13791 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
13793 RTE_PMD_I40E_PKG_OP_WR_DEL);
13796 if (ret == -EACCES)
13797 printf("Profile does not exist.\n");
13799 printf("Failed to delete profile.\n");
13804 cmdline_parse_inst_t cmd_ddp_del = {
13805 .f = cmd_ddp_del_parsed,
13807 .help_str = "ddp del <port_id> <backup_profile_path>",
13809 (void *)&cmd_ddp_del_ddp,
13810 (void *)&cmd_ddp_del_del,
13811 (void *)&cmd_ddp_del_port_id,
13812 (void *)&cmd_ddp_del_filepath,
13817 /* Get dynamic device personalization profile info */
13818 struct cmd_ddp_info_result {
13819 cmdline_fixed_string_t ddp;
13820 cmdline_fixed_string_t get;
13821 cmdline_fixed_string_t info;
13825 cmdline_parse_token_string_t cmd_ddp_info_ddp =
13826 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
13827 cmdline_parse_token_string_t cmd_ddp_info_get =
13828 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
13829 cmdline_parse_token_string_t cmd_ddp_info_info =
13830 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
13831 cmdline_parse_token_string_t cmd_ddp_info_filepath =
13832 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
13835 cmd_ddp_info_parsed(
13836 void *parsed_result,
13837 __rte_unused struct cmdline *cl,
13838 __rte_unused void *data)
13840 struct cmd_ddp_info_result *res = parsed_result;
13843 int ret = -ENOTSUP;
13844 #ifdef RTE_NET_I40E
13847 uint32_t buff_size = 0;
13848 struct rte_pmd_i40e_profile_info info;
13849 uint32_t dev_num = 0;
13850 struct rte_pmd_i40e_ddp_device_id *devs;
13851 uint32_t proto_num = 0;
13852 struct rte_pmd_i40e_proto_info *proto = NULL;
13853 uint32_t pctype_num = 0;
13854 struct rte_pmd_i40e_ptype_info *pctype;
13855 uint32_t ptype_num = 0;
13856 struct rte_pmd_i40e_ptype_info *ptype;
13861 pkg = open_file(res->filepath, &pkg_size);
13865 #ifdef RTE_NET_I40E
13866 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13867 (uint8_t *)&info, sizeof(info),
13868 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
13870 printf("Global Track id: 0x%x\n", info.track_id);
13871 printf("Global Version: %d.%d.%d.%d\n",
13872 info.version.major,
13873 info.version.minor,
13874 info.version.update,
13875 info.version.draft);
13876 printf("Global Package name: %s\n\n", info.name);
13879 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13880 (uint8_t *)&info, sizeof(info),
13881 RTE_PMD_I40E_PKG_INFO_HEADER);
13883 printf("i40e Profile Track id: 0x%x\n", info.track_id);
13884 printf("i40e Profile Version: %d.%d.%d.%d\n",
13885 info.version.major,
13886 info.version.minor,
13887 info.version.update,
13888 info.version.draft);
13889 printf("i40e Profile name: %s\n\n", info.name);
13892 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13893 (uint8_t *)&buff_size, sizeof(buff_size),
13894 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
13895 if (!ret && buff_size) {
13896 buff = (uint8_t *)malloc(buff_size);
13898 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13900 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
13902 printf("Package Notes:\n%s\n\n", buff);
13907 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13908 (uint8_t *)&dev_num, sizeof(dev_num),
13909 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
13910 if (!ret && dev_num) {
13911 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
13912 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
13914 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13915 (uint8_t *)devs, buff_size,
13916 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
13918 printf("List of supported devices:\n");
13919 for (i = 0; i < dev_num; i++) {
13920 printf(" %04X:%04X %04X:%04X\n",
13921 devs[i].vendor_dev_id >> 16,
13922 devs[i].vendor_dev_id & 0xFFFF,
13923 devs[i].sub_vendor_dev_id >> 16,
13924 devs[i].sub_vendor_dev_id & 0xFFFF);
13932 /* get information about protocols and packet types */
13933 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13934 (uint8_t *)&proto_num, sizeof(proto_num),
13935 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
13936 if (ret || !proto_num)
13937 goto no_print_return;
13939 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
13940 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
13942 goto no_print_return;
13944 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
13946 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
13948 printf("List of used protocols:\n");
13949 for (i = 0; i < proto_num; i++)
13950 printf(" %2u: %s\n", proto[i].proto_id,
13954 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13955 (uint8_t *)&pctype_num, sizeof(pctype_num),
13956 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
13957 if (ret || !pctype_num)
13958 goto no_print_pctypes;
13960 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
13961 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
13963 goto no_print_pctypes;
13965 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
13967 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
13970 goto no_print_pctypes;
13973 printf("List of defined packet classification types:\n");
13974 for (i = 0; i < pctype_num; i++) {
13975 printf(" %2u:", pctype[i].ptype_id);
13976 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
13977 proto_id = pctype[i].protocols[j];
13978 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
13979 for (n = 0; n < proto_num; n++) {
13980 if (proto[n].proto_id == proto_id) {
13981 printf(" %s", proto[n].name);
13994 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
13996 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
13997 if (ret || !ptype_num)
13998 goto no_print_return;
14000 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14001 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14003 goto no_print_return;
14005 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
14007 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
14010 goto no_print_return;
14012 printf("List of defined packet types:\n");
14013 for (i = 0; i < ptype_num; i++) {
14014 printf(" %2u:", ptype[i].ptype_id);
14015 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14016 proto_id = ptype[i].protocols[j];
14017 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14018 for (n = 0; n < proto_num; n++) {
14019 if (proto[n].proto_id == proto_id) {
14020 printf(" %s", proto[n].name);
14036 if (ret == -ENOTSUP)
14037 printf("Function not supported in PMD driver\n");
14041 cmdline_parse_inst_t cmd_ddp_get_info = {
14042 .f = cmd_ddp_info_parsed,
14044 .help_str = "ddp get info <profile_path>",
14046 (void *)&cmd_ddp_info_ddp,
14047 (void *)&cmd_ddp_info_get,
14048 (void *)&cmd_ddp_info_info,
14049 (void *)&cmd_ddp_info_filepath,
14054 /* Get dynamic device personalization profile info list*/
14055 #define PROFILE_INFO_SIZE 48
14056 #define MAX_PROFILE_NUM 16
14058 struct cmd_ddp_get_list_result {
14059 cmdline_fixed_string_t ddp;
14060 cmdline_fixed_string_t get;
14061 cmdline_fixed_string_t list;
14065 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
14066 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
14067 cmdline_parse_token_string_t cmd_ddp_get_list_get =
14068 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
14069 cmdline_parse_token_string_t cmd_ddp_get_list_list =
14070 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
14071 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
14072 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id,
14076 cmd_ddp_get_list_parsed(
14077 __rte_unused void *parsed_result,
14078 __rte_unused struct cmdline *cl,
14079 __rte_unused void *data)
14081 #ifdef RTE_NET_I40E
14082 struct cmd_ddp_get_list_result *res = parsed_result;
14083 struct rte_pmd_i40e_profile_list *p_list;
14084 struct rte_pmd_i40e_profile_info *p_info;
14089 int ret = -ENOTSUP;
14091 #ifdef RTE_NET_I40E
14092 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
14093 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
14095 printf("%s: Failed to malloc buffer\n", __func__);
14099 if (ret == -ENOTSUP)
14100 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
14101 (uint8_t *)p_list, size);
14104 p_num = p_list->p_count;
14105 printf("Profile number is: %d\n\n", p_num);
14107 for (i = 0; i < p_num; i++) {
14108 p_info = &p_list->p_info[i];
14109 printf("Profile %d:\n", i);
14110 printf("Track id: 0x%x\n", p_info->track_id);
14111 printf("Version: %d.%d.%d.%d\n",
14112 p_info->version.major,
14113 p_info->version.minor,
14114 p_info->version.update,
14115 p_info->version.draft);
14116 printf("Profile name: %s\n\n", p_info->name);
14124 printf("Failed to get ddp list\n");
14127 cmdline_parse_inst_t cmd_ddp_get_list = {
14128 .f = cmd_ddp_get_list_parsed,
14130 .help_str = "ddp get list <port_id>",
14132 (void *)&cmd_ddp_get_list_ddp,
14133 (void *)&cmd_ddp_get_list_get,
14134 (void *)&cmd_ddp_get_list_list,
14135 (void *)&cmd_ddp_get_list_port_id,
14140 /* Configure input set */
14141 struct cmd_cfg_input_set_result {
14142 cmdline_fixed_string_t port;
14143 cmdline_fixed_string_t cfg;
14145 cmdline_fixed_string_t pctype;
14147 cmdline_fixed_string_t inset_type;
14148 cmdline_fixed_string_t opt;
14149 cmdline_fixed_string_t field;
14154 cmd_cfg_input_set_parsed(
14155 __rte_unused void *parsed_result,
14156 __rte_unused struct cmdline *cl,
14157 __rte_unused void *data)
14159 #ifdef RTE_NET_I40E
14160 struct cmd_cfg_input_set_result *res = parsed_result;
14161 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
14162 struct rte_pmd_i40e_inset inset;
14164 int ret = -ENOTSUP;
14166 if (!all_ports_stopped()) {
14167 printf("Please stop all ports first\n");
14171 #ifdef RTE_NET_I40E
14172 if (!strcmp(res->inset_type, "hash_inset"))
14173 inset_type = INSET_HASH;
14174 else if (!strcmp(res->inset_type, "fdir_inset"))
14175 inset_type = INSET_FDIR;
14176 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
14177 inset_type = INSET_FDIR_FLX;
14178 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
14179 &inset, inset_type);
14181 printf("Failed to get input set.\n");
14185 if (!strcmp(res->opt, "get")) {
14186 ret = rte_pmd_i40e_inset_field_get(inset.inset,
14189 printf("Field index %d is enabled.\n", res->field_idx);
14191 printf("Field index %d is disabled.\n", res->field_idx);
14193 } else if (!strcmp(res->opt, "set"))
14194 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
14196 else if (!strcmp(res->opt, "clear"))
14197 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
14200 printf("Failed to configure input set field.\n");
14204 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
14205 &inset, inset_type);
14207 printf("Failed to set input set.\n");
14212 if (ret == -ENOTSUP)
14213 printf("Function not supported\n");
14216 cmdline_parse_token_string_t cmd_cfg_input_set_port =
14217 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14219 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
14220 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14222 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
14223 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14224 port_id, RTE_UINT16);
14225 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
14226 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14228 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
14229 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14230 pctype_id, RTE_UINT8);
14231 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
14232 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14234 "hash_inset#fdir_inset#fdir_flx_inset");
14235 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
14236 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14237 opt, "get#set#clear");
14238 cmdline_parse_token_string_t cmd_cfg_input_set_field =
14239 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14241 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
14242 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14243 field_idx, RTE_UINT8);
14245 cmdline_parse_inst_t cmd_cfg_input_set = {
14246 .f = cmd_cfg_input_set_parsed,
14248 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
14249 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
14251 (void *)&cmd_cfg_input_set_port,
14252 (void *)&cmd_cfg_input_set_cfg,
14253 (void *)&cmd_cfg_input_set_port_id,
14254 (void *)&cmd_cfg_input_set_pctype,
14255 (void *)&cmd_cfg_input_set_pctype_id,
14256 (void *)&cmd_cfg_input_set_inset_type,
14257 (void *)&cmd_cfg_input_set_opt,
14258 (void *)&cmd_cfg_input_set_field,
14259 (void *)&cmd_cfg_input_set_field_idx,
14264 /* Clear input set */
14265 struct cmd_clear_input_set_result {
14266 cmdline_fixed_string_t port;
14267 cmdline_fixed_string_t cfg;
14269 cmdline_fixed_string_t pctype;
14271 cmdline_fixed_string_t inset_type;
14272 cmdline_fixed_string_t clear;
14273 cmdline_fixed_string_t all;
14277 cmd_clear_input_set_parsed(
14278 __rte_unused void *parsed_result,
14279 __rte_unused struct cmdline *cl,
14280 __rte_unused void *data)
14282 #ifdef RTE_NET_I40E
14283 struct cmd_clear_input_set_result *res = parsed_result;
14284 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
14285 struct rte_pmd_i40e_inset inset;
14287 int ret = -ENOTSUP;
14289 if (!all_ports_stopped()) {
14290 printf("Please stop all ports first\n");
14294 #ifdef RTE_NET_I40E
14295 if (!strcmp(res->inset_type, "hash_inset"))
14296 inset_type = INSET_HASH;
14297 else if (!strcmp(res->inset_type, "fdir_inset"))
14298 inset_type = INSET_FDIR;
14299 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
14300 inset_type = INSET_FDIR_FLX;
14302 memset(&inset, 0, sizeof(inset));
14304 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
14305 &inset, inset_type);
14307 printf("Failed to clear input set.\n");
14313 if (ret == -ENOTSUP)
14314 printf("Function not supported\n");
14317 cmdline_parse_token_string_t cmd_clear_input_set_port =
14318 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14320 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
14321 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14323 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
14324 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
14325 port_id, RTE_UINT16);
14326 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
14327 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14329 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
14330 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
14331 pctype_id, RTE_UINT8);
14332 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
14333 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14335 "hash_inset#fdir_inset#fdir_flx_inset");
14336 cmdline_parse_token_string_t cmd_clear_input_set_clear =
14337 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14339 cmdline_parse_token_string_t cmd_clear_input_set_all =
14340 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14343 cmdline_parse_inst_t cmd_clear_input_set = {
14344 .f = cmd_clear_input_set_parsed,
14346 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
14347 "fdir_inset|fdir_flx_inset clear all",
14349 (void *)&cmd_clear_input_set_port,
14350 (void *)&cmd_clear_input_set_cfg,
14351 (void *)&cmd_clear_input_set_port_id,
14352 (void *)&cmd_clear_input_set_pctype,
14353 (void *)&cmd_clear_input_set_pctype_id,
14354 (void *)&cmd_clear_input_set_inset_type,
14355 (void *)&cmd_clear_input_set_clear,
14356 (void *)&cmd_clear_input_set_all,
14361 /* show vf stats */
14363 /* Common result structure for show vf stats */
14364 struct cmd_show_vf_stats_result {
14365 cmdline_fixed_string_t show;
14366 cmdline_fixed_string_t vf;
14367 cmdline_fixed_string_t stats;
14372 /* Common CLI fields show vf stats*/
14373 cmdline_parse_token_string_t cmd_show_vf_stats_show =
14374 TOKEN_STRING_INITIALIZER
14375 (struct cmd_show_vf_stats_result,
14377 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
14378 TOKEN_STRING_INITIALIZER
14379 (struct cmd_show_vf_stats_result,
14381 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
14382 TOKEN_STRING_INITIALIZER
14383 (struct cmd_show_vf_stats_result,
14385 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
14386 TOKEN_NUM_INITIALIZER
14387 (struct cmd_show_vf_stats_result,
14388 port_id, RTE_UINT16);
14389 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
14390 TOKEN_NUM_INITIALIZER
14391 (struct cmd_show_vf_stats_result,
14392 vf_id, RTE_UINT16);
14395 cmd_show_vf_stats_parsed(
14396 void *parsed_result,
14397 __rte_unused struct cmdline *cl,
14398 __rte_unused void *data)
14400 struct cmd_show_vf_stats_result *res = parsed_result;
14401 struct rte_eth_stats stats;
14402 int ret = -ENOTSUP;
14403 static const char *nic_stats_border = "########################";
14405 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14408 memset(&stats, 0, sizeof(stats));
14410 #ifdef RTE_NET_I40E
14411 if (ret == -ENOTSUP)
14412 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
14416 #ifdef RTE_NET_BNXT
14417 if (ret == -ENOTSUP)
14418 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
14427 printf("invalid vf_id %d\n", res->vf_id);
14430 printf("invalid port_id %d\n", res->port_id);
14433 printf("function not implemented\n");
14436 printf("programming error: (%s)\n", strerror(-ret));
14439 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
14440 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
14442 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
14444 stats.ipackets, stats.imissed, stats.ibytes);
14445 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
14446 printf(" RX-nombuf: %-10"PRIu64"\n",
14448 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
14450 stats.opackets, stats.oerrors, stats.obytes);
14452 printf(" %s############################%s\n",
14453 nic_stats_border, nic_stats_border);
14456 cmdline_parse_inst_t cmd_show_vf_stats = {
14457 .f = cmd_show_vf_stats_parsed,
14459 .help_str = "show vf stats <port_id> <vf_id>",
14461 (void *)&cmd_show_vf_stats_show,
14462 (void *)&cmd_show_vf_stats_vf,
14463 (void *)&cmd_show_vf_stats_stats,
14464 (void *)&cmd_show_vf_stats_port_id,
14465 (void *)&cmd_show_vf_stats_vf_id,
14470 /* clear vf stats */
14472 /* Common result structure for clear vf stats */
14473 struct cmd_clear_vf_stats_result {
14474 cmdline_fixed_string_t clear;
14475 cmdline_fixed_string_t vf;
14476 cmdline_fixed_string_t stats;
14481 /* Common CLI fields clear vf stats*/
14482 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
14483 TOKEN_STRING_INITIALIZER
14484 (struct cmd_clear_vf_stats_result,
14486 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
14487 TOKEN_STRING_INITIALIZER
14488 (struct cmd_clear_vf_stats_result,
14490 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
14491 TOKEN_STRING_INITIALIZER
14492 (struct cmd_clear_vf_stats_result,
14494 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
14495 TOKEN_NUM_INITIALIZER
14496 (struct cmd_clear_vf_stats_result,
14497 port_id, RTE_UINT16);
14498 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
14499 TOKEN_NUM_INITIALIZER
14500 (struct cmd_clear_vf_stats_result,
14501 vf_id, RTE_UINT16);
14504 cmd_clear_vf_stats_parsed(
14505 void *parsed_result,
14506 __rte_unused struct cmdline *cl,
14507 __rte_unused void *data)
14509 struct cmd_clear_vf_stats_result *res = parsed_result;
14510 int ret = -ENOTSUP;
14512 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14515 #ifdef RTE_NET_I40E
14516 if (ret == -ENOTSUP)
14517 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
14520 #ifdef RTE_NET_BNXT
14521 if (ret == -ENOTSUP)
14522 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
14530 printf("invalid vf_id %d\n", res->vf_id);
14533 printf("invalid port_id %d\n", res->port_id);
14536 printf("function not implemented\n");
14539 printf("programming error: (%s)\n", strerror(-ret));
14543 cmdline_parse_inst_t cmd_clear_vf_stats = {
14544 .f = cmd_clear_vf_stats_parsed,
14546 .help_str = "clear vf stats <port_id> <vf_id>",
14548 (void *)&cmd_clear_vf_stats_clear,
14549 (void *)&cmd_clear_vf_stats_vf,
14550 (void *)&cmd_clear_vf_stats_stats,
14551 (void *)&cmd_clear_vf_stats_port_id,
14552 (void *)&cmd_clear_vf_stats_vf_id,
14557 /* port config pctype mapping reset */
14559 /* Common result structure for port config pctype mapping reset */
14560 struct cmd_pctype_mapping_reset_result {
14561 cmdline_fixed_string_t port;
14562 cmdline_fixed_string_t config;
14564 cmdline_fixed_string_t pctype;
14565 cmdline_fixed_string_t mapping;
14566 cmdline_fixed_string_t reset;
14569 /* Common CLI fields for port config pctype mapping reset*/
14570 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
14571 TOKEN_STRING_INITIALIZER
14572 (struct cmd_pctype_mapping_reset_result,
14574 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
14575 TOKEN_STRING_INITIALIZER
14576 (struct cmd_pctype_mapping_reset_result,
14578 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
14579 TOKEN_NUM_INITIALIZER
14580 (struct cmd_pctype_mapping_reset_result,
14581 port_id, RTE_UINT16);
14582 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
14583 TOKEN_STRING_INITIALIZER
14584 (struct cmd_pctype_mapping_reset_result,
14586 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
14587 TOKEN_STRING_INITIALIZER
14588 (struct cmd_pctype_mapping_reset_result,
14589 mapping, "mapping");
14590 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
14591 TOKEN_STRING_INITIALIZER
14592 (struct cmd_pctype_mapping_reset_result,
14596 cmd_pctype_mapping_reset_parsed(
14597 void *parsed_result,
14598 __rte_unused struct cmdline *cl,
14599 __rte_unused void *data)
14601 struct cmd_pctype_mapping_reset_result *res = parsed_result;
14602 int ret = -ENOTSUP;
14604 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14607 #ifdef RTE_NET_I40E
14608 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
14615 printf("invalid port_id %d\n", res->port_id);
14618 printf("function not implemented\n");
14621 printf("programming error: (%s)\n", strerror(-ret));
14625 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
14626 .f = cmd_pctype_mapping_reset_parsed,
14628 .help_str = "port config <port_id> pctype mapping reset",
14630 (void *)&cmd_pctype_mapping_reset_port,
14631 (void *)&cmd_pctype_mapping_reset_config,
14632 (void *)&cmd_pctype_mapping_reset_port_id,
14633 (void *)&cmd_pctype_mapping_reset_pctype,
14634 (void *)&cmd_pctype_mapping_reset_mapping,
14635 (void *)&cmd_pctype_mapping_reset_reset,
14640 /* show port pctype mapping */
14642 /* Common result structure for show port pctype mapping */
14643 struct cmd_pctype_mapping_get_result {
14644 cmdline_fixed_string_t show;
14645 cmdline_fixed_string_t port;
14647 cmdline_fixed_string_t pctype;
14648 cmdline_fixed_string_t mapping;
14651 /* Common CLI fields for pctype mapping get */
14652 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
14653 TOKEN_STRING_INITIALIZER
14654 (struct cmd_pctype_mapping_get_result,
14656 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
14657 TOKEN_STRING_INITIALIZER
14658 (struct cmd_pctype_mapping_get_result,
14660 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
14661 TOKEN_NUM_INITIALIZER
14662 (struct cmd_pctype_mapping_get_result,
14663 port_id, RTE_UINT16);
14664 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
14665 TOKEN_STRING_INITIALIZER
14666 (struct cmd_pctype_mapping_get_result,
14668 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
14669 TOKEN_STRING_INITIALIZER
14670 (struct cmd_pctype_mapping_get_result,
14671 mapping, "mapping");
14674 cmd_pctype_mapping_get_parsed(
14675 void *parsed_result,
14676 __rte_unused struct cmdline *cl,
14677 __rte_unused void *data)
14679 struct cmd_pctype_mapping_get_result *res = parsed_result;
14680 int ret = -ENOTSUP;
14681 #ifdef RTE_NET_I40E
14682 struct rte_pmd_i40e_flow_type_mapping
14683 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
14684 int i, j, first_pctype;
14687 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14690 #ifdef RTE_NET_I40E
14691 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
14698 printf("invalid port_id %d\n", res->port_id);
14701 printf("function not implemented\n");
14704 printf("programming error: (%s)\n", strerror(-ret));
14708 #ifdef RTE_NET_I40E
14709 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
14710 if (mapping[i].pctype != 0ULL) {
14713 printf("pctype: ");
14714 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
14715 if (mapping[i].pctype & (1ULL << j)) {
14716 printf(first_pctype ?
14717 "%02d" : ",%02d", j);
14721 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
14727 cmdline_parse_inst_t cmd_pctype_mapping_get = {
14728 .f = cmd_pctype_mapping_get_parsed,
14730 .help_str = "show port <port_id> pctype mapping",
14732 (void *)&cmd_pctype_mapping_get_show,
14733 (void *)&cmd_pctype_mapping_get_port,
14734 (void *)&cmd_pctype_mapping_get_port_id,
14735 (void *)&cmd_pctype_mapping_get_pctype,
14736 (void *)&cmd_pctype_mapping_get_mapping,
14741 /* port config pctype mapping update */
14743 /* Common result structure for port config pctype mapping update */
14744 struct cmd_pctype_mapping_update_result {
14745 cmdline_fixed_string_t port;
14746 cmdline_fixed_string_t config;
14748 cmdline_fixed_string_t pctype;
14749 cmdline_fixed_string_t mapping;
14750 cmdline_fixed_string_t update;
14751 cmdline_fixed_string_t pctype_list;
14752 uint16_t flow_type;
14755 /* Common CLI fields for pctype mapping update*/
14756 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
14757 TOKEN_STRING_INITIALIZER
14758 (struct cmd_pctype_mapping_update_result,
14760 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
14761 TOKEN_STRING_INITIALIZER
14762 (struct cmd_pctype_mapping_update_result,
14764 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
14765 TOKEN_NUM_INITIALIZER
14766 (struct cmd_pctype_mapping_update_result,
14767 port_id, RTE_UINT16);
14768 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
14769 TOKEN_STRING_INITIALIZER
14770 (struct cmd_pctype_mapping_update_result,
14772 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
14773 TOKEN_STRING_INITIALIZER
14774 (struct cmd_pctype_mapping_update_result,
14775 mapping, "mapping");
14776 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
14777 TOKEN_STRING_INITIALIZER
14778 (struct cmd_pctype_mapping_update_result,
14780 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
14781 TOKEN_STRING_INITIALIZER
14782 (struct cmd_pctype_mapping_update_result,
14783 pctype_list, NULL);
14784 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
14785 TOKEN_NUM_INITIALIZER
14786 (struct cmd_pctype_mapping_update_result,
14787 flow_type, RTE_UINT16);
14790 cmd_pctype_mapping_update_parsed(
14791 void *parsed_result,
14792 __rte_unused struct cmdline *cl,
14793 __rte_unused void *data)
14795 struct cmd_pctype_mapping_update_result *res = parsed_result;
14796 int ret = -ENOTSUP;
14797 #ifdef RTE_NET_I40E
14798 struct rte_pmd_i40e_flow_type_mapping mapping;
14800 unsigned int nb_item;
14801 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
14804 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14807 #ifdef RTE_NET_I40E
14808 nb_item = parse_item_list(res->pctype_list, "pctypes",
14809 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
14810 mapping.flow_type = res->flow_type;
14811 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
14812 mapping.pctype |= (1ULL << pctype_list[i]);
14813 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
14823 printf("invalid pctype or flow type\n");
14826 printf("invalid port_id %d\n", res->port_id);
14829 printf("function not implemented\n");
14832 printf("programming error: (%s)\n", strerror(-ret));
14836 cmdline_parse_inst_t cmd_pctype_mapping_update = {
14837 .f = cmd_pctype_mapping_update_parsed,
14839 .help_str = "port config <port_id> pctype mapping update"
14840 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
14842 (void *)&cmd_pctype_mapping_update_port,
14843 (void *)&cmd_pctype_mapping_update_config,
14844 (void *)&cmd_pctype_mapping_update_port_id,
14845 (void *)&cmd_pctype_mapping_update_pctype,
14846 (void *)&cmd_pctype_mapping_update_mapping,
14847 (void *)&cmd_pctype_mapping_update_update,
14848 (void *)&cmd_pctype_mapping_update_pc_type,
14849 (void *)&cmd_pctype_mapping_update_flow_type,
14854 /* ptype mapping get */
14856 /* Common result structure for ptype mapping get */
14857 struct cmd_ptype_mapping_get_result {
14858 cmdline_fixed_string_t ptype;
14859 cmdline_fixed_string_t mapping;
14860 cmdline_fixed_string_t get;
14862 uint8_t valid_only;
14865 /* Common CLI fields for ptype mapping get */
14866 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
14867 TOKEN_STRING_INITIALIZER
14868 (struct cmd_ptype_mapping_get_result,
14870 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
14871 TOKEN_STRING_INITIALIZER
14872 (struct cmd_ptype_mapping_get_result,
14873 mapping, "mapping");
14874 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
14875 TOKEN_STRING_INITIALIZER
14876 (struct cmd_ptype_mapping_get_result,
14878 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
14879 TOKEN_NUM_INITIALIZER
14880 (struct cmd_ptype_mapping_get_result,
14881 port_id, RTE_UINT16);
14882 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
14883 TOKEN_NUM_INITIALIZER
14884 (struct cmd_ptype_mapping_get_result,
14885 valid_only, RTE_UINT8);
14888 cmd_ptype_mapping_get_parsed(
14889 void *parsed_result,
14890 __rte_unused struct cmdline *cl,
14891 __rte_unused void *data)
14893 struct cmd_ptype_mapping_get_result *res = parsed_result;
14894 int ret = -ENOTSUP;
14895 #ifdef RTE_NET_I40E
14896 int max_ptype_num = 256;
14897 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
14902 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14905 #ifdef RTE_NET_I40E
14906 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
14917 printf("invalid port_id %d\n", res->port_id);
14920 printf("function not implemented\n");
14923 printf("programming error: (%s)\n", strerror(-ret));
14926 #ifdef RTE_NET_I40E
14928 for (i = 0; i < count; i++)
14929 printf("%3d\t0x%08x\n",
14930 mapping[i].hw_ptype, mapping[i].sw_ptype);
14935 cmdline_parse_inst_t cmd_ptype_mapping_get = {
14936 .f = cmd_ptype_mapping_get_parsed,
14938 .help_str = "ptype mapping get <port_id> <valid_only>",
14940 (void *)&cmd_ptype_mapping_get_ptype,
14941 (void *)&cmd_ptype_mapping_get_mapping,
14942 (void *)&cmd_ptype_mapping_get_get,
14943 (void *)&cmd_ptype_mapping_get_port_id,
14944 (void *)&cmd_ptype_mapping_get_valid_only,
14949 /* ptype mapping replace */
14951 /* Common result structure for ptype mapping replace */
14952 struct cmd_ptype_mapping_replace_result {
14953 cmdline_fixed_string_t ptype;
14954 cmdline_fixed_string_t mapping;
14955 cmdline_fixed_string_t replace;
14962 /* Common CLI fields for ptype mapping replace */
14963 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
14964 TOKEN_STRING_INITIALIZER
14965 (struct cmd_ptype_mapping_replace_result,
14967 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
14968 TOKEN_STRING_INITIALIZER
14969 (struct cmd_ptype_mapping_replace_result,
14970 mapping, "mapping");
14971 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
14972 TOKEN_STRING_INITIALIZER
14973 (struct cmd_ptype_mapping_replace_result,
14974 replace, "replace");
14975 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
14976 TOKEN_NUM_INITIALIZER
14977 (struct cmd_ptype_mapping_replace_result,
14978 port_id, RTE_UINT16);
14979 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
14980 TOKEN_NUM_INITIALIZER
14981 (struct cmd_ptype_mapping_replace_result,
14982 target, RTE_UINT32);
14983 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
14984 TOKEN_NUM_INITIALIZER
14985 (struct cmd_ptype_mapping_replace_result,
14987 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
14988 TOKEN_NUM_INITIALIZER
14989 (struct cmd_ptype_mapping_replace_result,
14990 pkt_type, RTE_UINT32);
14993 cmd_ptype_mapping_replace_parsed(
14994 void *parsed_result,
14995 __rte_unused struct cmdline *cl,
14996 __rte_unused void *data)
14998 struct cmd_ptype_mapping_replace_result *res = parsed_result;
14999 int ret = -ENOTSUP;
15001 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15004 #ifdef RTE_NET_I40E
15005 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
15015 printf("invalid ptype 0x%8x or 0x%8x\n",
15016 res->target, res->pkt_type);
15019 printf("invalid port_id %d\n", res->port_id);
15022 printf("function not implemented\n");
15025 printf("programming error: (%s)\n", strerror(-ret));
15029 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
15030 .f = cmd_ptype_mapping_replace_parsed,
15033 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
15035 (void *)&cmd_ptype_mapping_replace_ptype,
15036 (void *)&cmd_ptype_mapping_replace_mapping,
15037 (void *)&cmd_ptype_mapping_replace_replace,
15038 (void *)&cmd_ptype_mapping_replace_port_id,
15039 (void *)&cmd_ptype_mapping_replace_target,
15040 (void *)&cmd_ptype_mapping_replace_mask,
15041 (void *)&cmd_ptype_mapping_replace_pkt_type,
15046 /* ptype mapping reset */
15048 /* Common result structure for ptype mapping reset */
15049 struct cmd_ptype_mapping_reset_result {
15050 cmdline_fixed_string_t ptype;
15051 cmdline_fixed_string_t mapping;
15052 cmdline_fixed_string_t reset;
15056 /* Common CLI fields for ptype mapping reset*/
15057 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
15058 TOKEN_STRING_INITIALIZER
15059 (struct cmd_ptype_mapping_reset_result,
15061 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
15062 TOKEN_STRING_INITIALIZER
15063 (struct cmd_ptype_mapping_reset_result,
15064 mapping, "mapping");
15065 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
15066 TOKEN_STRING_INITIALIZER
15067 (struct cmd_ptype_mapping_reset_result,
15069 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
15070 TOKEN_NUM_INITIALIZER
15071 (struct cmd_ptype_mapping_reset_result,
15072 port_id, RTE_UINT16);
15075 cmd_ptype_mapping_reset_parsed(
15076 void *parsed_result,
15077 __rte_unused struct cmdline *cl,
15078 __rte_unused void *data)
15080 struct cmd_ptype_mapping_reset_result *res = parsed_result;
15081 int ret = -ENOTSUP;
15083 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15086 #ifdef RTE_NET_I40E
15087 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
15094 printf("invalid port_id %d\n", res->port_id);
15097 printf("function not implemented\n");
15100 printf("programming error: (%s)\n", strerror(-ret));
15104 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
15105 .f = cmd_ptype_mapping_reset_parsed,
15107 .help_str = "ptype mapping reset <port_id>",
15109 (void *)&cmd_ptype_mapping_reset_ptype,
15110 (void *)&cmd_ptype_mapping_reset_mapping,
15111 (void *)&cmd_ptype_mapping_reset_reset,
15112 (void *)&cmd_ptype_mapping_reset_port_id,
15117 /* ptype mapping update */
15119 /* Common result structure for ptype mapping update */
15120 struct cmd_ptype_mapping_update_result {
15121 cmdline_fixed_string_t ptype;
15122 cmdline_fixed_string_t mapping;
15123 cmdline_fixed_string_t reset;
15129 /* Common CLI fields for ptype mapping update*/
15130 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
15131 TOKEN_STRING_INITIALIZER
15132 (struct cmd_ptype_mapping_update_result,
15134 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
15135 TOKEN_STRING_INITIALIZER
15136 (struct cmd_ptype_mapping_update_result,
15137 mapping, "mapping");
15138 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
15139 TOKEN_STRING_INITIALIZER
15140 (struct cmd_ptype_mapping_update_result,
15142 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
15143 TOKEN_NUM_INITIALIZER
15144 (struct cmd_ptype_mapping_update_result,
15145 port_id, RTE_UINT16);
15146 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
15147 TOKEN_NUM_INITIALIZER
15148 (struct cmd_ptype_mapping_update_result,
15149 hw_ptype, RTE_UINT8);
15150 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
15151 TOKEN_NUM_INITIALIZER
15152 (struct cmd_ptype_mapping_update_result,
15153 sw_ptype, RTE_UINT32);
15156 cmd_ptype_mapping_update_parsed(
15157 void *parsed_result,
15158 __rte_unused struct cmdline *cl,
15159 __rte_unused void *data)
15161 struct cmd_ptype_mapping_update_result *res = parsed_result;
15162 int ret = -ENOTSUP;
15163 #ifdef RTE_NET_I40E
15164 struct rte_pmd_i40e_ptype_mapping mapping;
15166 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15169 #ifdef RTE_NET_I40E
15170 mapping.hw_ptype = res->hw_ptype;
15171 mapping.sw_ptype = res->sw_ptype;
15172 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
15182 printf("invalid ptype 0x%8x\n", res->sw_ptype);
15185 printf("invalid port_id %d\n", res->port_id);
15188 printf("function not implemented\n");
15191 printf("programming error: (%s)\n", strerror(-ret));
15195 cmdline_parse_inst_t cmd_ptype_mapping_update = {
15196 .f = cmd_ptype_mapping_update_parsed,
15198 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
15200 (void *)&cmd_ptype_mapping_update_ptype,
15201 (void *)&cmd_ptype_mapping_update_mapping,
15202 (void *)&cmd_ptype_mapping_update_update,
15203 (void *)&cmd_ptype_mapping_update_port_id,
15204 (void *)&cmd_ptype_mapping_update_hw_ptype,
15205 (void *)&cmd_ptype_mapping_update_sw_ptype,
15210 /* Common result structure for file commands */
15211 struct cmd_cmdfile_result {
15212 cmdline_fixed_string_t load;
15213 cmdline_fixed_string_t filename;
15216 /* Common CLI fields for file commands */
15217 cmdline_parse_token_string_t cmd_load_cmdfile =
15218 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
15219 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
15220 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
15223 cmd_load_from_file_parsed(
15224 void *parsed_result,
15225 __rte_unused struct cmdline *cl,
15226 __rte_unused void *data)
15228 struct cmd_cmdfile_result *res = parsed_result;
15230 cmdline_read_from_file(res->filename);
15233 cmdline_parse_inst_t cmd_load_from_file = {
15234 .f = cmd_load_from_file_parsed,
15236 .help_str = "load <filename>",
15238 (void *)&cmd_load_cmdfile,
15239 (void *)&cmd_load_cmdfile_filename,
15244 /* Get Rx offloads capabilities */
15245 struct cmd_rx_offload_get_capa_result {
15246 cmdline_fixed_string_t show;
15247 cmdline_fixed_string_t port;
15249 cmdline_fixed_string_t rx_offload;
15250 cmdline_fixed_string_t capabilities;
15253 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
15254 TOKEN_STRING_INITIALIZER
15255 (struct cmd_rx_offload_get_capa_result,
15257 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
15258 TOKEN_STRING_INITIALIZER
15259 (struct cmd_rx_offload_get_capa_result,
15261 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
15262 TOKEN_NUM_INITIALIZER
15263 (struct cmd_rx_offload_get_capa_result,
15264 port_id, RTE_UINT16);
15265 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
15266 TOKEN_STRING_INITIALIZER
15267 (struct cmd_rx_offload_get_capa_result,
15268 rx_offload, "rx_offload");
15269 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
15270 TOKEN_STRING_INITIALIZER
15271 (struct cmd_rx_offload_get_capa_result,
15272 capabilities, "capabilities");
15275 print_rx_offloads(uint64_t offloads)
15277 uint64_t single_offload;
15285 begin = __builtin_ctzll(offloads);
15286 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
15288 single_offload = 1ULL << begin;
15289 for (bit = begin; bit < end; bit++) {
15290 if (offloads & single_offload)
15292 rte_eth_dev_rx_offload_name(single_offload));
15293 single_offload <<= 1;
15298 cmd_rx_offload_get_capa_parsed(
15299 void *parsed_result,
15300 __rte_unused struct cmdline *cl,
15301 __rte_unused void *data)
15303 struct cmd_rx_offload_get_capa_result *res = parsed_result;
15304 struct rte_eth_dev_info dev_info;
15305 portid_t port_id = res->port_id;
15306 uint64_t queue_offloads;
15307 uint64_t port_offloads;
15310 ret = eth_dev_info_get_print_err(port_id, &dev_info);
15314 queue_offloads = dev_info.rx_queue_offload_capa;
15315 port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
15317 printf("Rx Offloading Capabilities of port %d :\n", port_id);
15318 printf(" Per Queue :");
15319 print_rx_offloads(queue_offloads);
15322 printf(" Per Port :");
15323 print_rx_offloads(port_offloads);
15327 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
15328 .f = cmd_rx_offload_get_capa_parsed,
15330 .help_str = "show port <port_id> rx_offload capabilities",
15332 (void *)&cmd_rx_offload_get_capa_show,
15333 (void *)&cmd_rx_offload_get_capa_port,
15334 (void *)&cmd_rx_offload_get_capa_port_id,
15335 (void *)&cmd_rx_offload_get_capa_rx_offload,
15336 (void *)&cmd_rx_offload_get_capa_capabilities,
15341 /* Get Rx offloads configuration */
15342 struct cmd_rx_offload_get_configuration_result {
15343 cmdline_fixed_string_t show;
15344 cmdline_fixed_string_t port;
15346 cmdline_fixed_string_t rx_offload;
15347 cmdline_fixed_string_t configuration;
15350 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
15351 TOKEN_STRING_INITIALIZER
15352 (struct cmd_rx_offload_get_configuration_result,
15354 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
15355 TOKEN_STRING_INITIALIZER
15356 (struct cmd_rx_offload_get_configuration_result,
15358 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
15359 TOKEN_NUM_INITIALIZER
15360 (struct cmd_rx_offload_get_configuration_result,
15361 port_id, RTE_UINT16);
15362 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
15363 TOKEN_STRING_INITIALIZER
15364 (struct cmd_rx_offload_get_configuration_result,
15365 rx_offload, "rx_offload");
15366 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
15367 TOKEN_STRING_INITIALIZER
15368 (struct cmd_rx_offload_get_configuration_result,
15369 configuration, "configuration");
15372 cmd_rx_offload_get_configuration_parsed(
15373 void *parsed_result,
15374 __rte_unused struct cmdline *cl,
15375 __rte_unused void *data)
15377 struct cmd_rx_offload_get_configuration_result *res = parsed_result;
15378 struct rte_eth_dev_info dev_info;
15379 portid_t port_id = res->port_id;
15380 struct rte_port *port = &ports[port_id];
15381 uint64_t port_offloads;
15382 uint64_t queue_offloads;
15383 uint16_t nb_rx_queues;
15387 printf("Rx Offloading Configuration of port %d :\n", port_id);
15389 port_offloads = port->dev_conf.rxmode.offloads;
15391 print_rx_offloads(port_offloads);
15394 ret = eth_dev_info_get_print_err(port_id, &dev_info);
15398 nb_rx_queues = dev_info.nb_rx_queues;
15399 for (q = 0; q < nb_rx_queues; q++) {
15400 queue_offloads = port->rx_conf[q].offloads;
15401 printf(" Queue[%2d] :", q);
15402 print_rx_offloads(queue_offloads);
15408 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
15409 .f = cmd_rx_offload_get_configuration_parsed,
15411 .help_str = "show port <port_id> rx_offload configuration",
15413 (void *)&cmd_rx_offload_get_configuration_show,
15414 (void *)&cmd_rx_offload_get_configuration_port,
15415 (void *)&cmd_rx_offload_get_configuration_port_id,
15416 (void *)&cmd_rx_offload_get_configuration_rx_offload,
15417 (void *)&cmd_rx_offload_get_configuration_configuration,
15422 /* Enable/Disable a per port offloading */
15423 struct cmd_config_per_port_rx_offload_result {
15424 cmdline_fixed_string_t port;
15425 cmdline_fixed_string_t config;
15427 cmdline_fixed_string_t rx_offload;
15428 cmdline_fixed_string_t offload;
15429 cmdline_fixed_string_t on_off;
15432 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
15433 TOKEN_STRING_INITIALIZER
15434 (struct cmd_config_per_port_rx_offload_result,
15436 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
15437 TOKEN_STRING_INITIALIZER
15438 (struct cmd_config_per_port_rx_offload_result,
15440 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
15441 TOKEN_NUM_INITIALIZER
15442 (struct cmd_config_per_port_rx_offload_result,
15443 port_id, RTE_UINT16);
15444 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
15445 TOKEN_STRING_INITIALIZER
15446 (struct cmd_config_per_port_rx_offload_result,
15447 rx_offload, "rx_offload");
15448 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
15449 TOKEN_STRING_INITIALIZER
15450 (struct cmd_config_per_port_rx_offload_result,
15451 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
15452 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
15453 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
15454 "scatter#buffer_split#timestamp#security#"
15455 "keep_crc#rss_hash");
15456 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
15457 TOKEN_STRING_INITIALIZER
15458 (struct cmd_config_per_port_rx_offload_result,
15462 search_rx_offload(const char *name)
15464 uint64_t single_offload;
15465 const char *single_name;
15469 single_offload = 1;
15470 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
15471 single_name = rte_eth_dev_rx_offload_name(single_offload);
15472 if (!strcasecmp(single_name, name)) {
15476 single_offload <<= 1;
15480 return single_offload;
15486 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
15487 __rte_unused struct cmdline *cl,
15488 __rte_unused void *data)
15490 struct cmd_config_per_port_rx_offload_result *res = parsed_result;
15491 portid_t port_id = res->port_id;
15492 struct rte_eth_dev_info dev_info;
15493 struct rte_port *port = &ports[port_id];
15494 uint64_t single_offload;
15495 uint16_t nb_rx_queues;
15499 if (port->port_status != RTE_PORT_STOPPED) {
15500 printf("Error: Can't config offload when Port %d "
15501 "is not stopped\n", port_id);
15505 single_offload = search_rx_offload(res->offload);
15506 if (single_offload == 0) {
15507 printf("Unknown offload name: %s\n", res->offload);
15511 ret = eth_dev_info_get_print_err(port_id, &dev_info);
15515 nb_rx_queues = dev_info.nb_rx_queues;
15516 if (!strcmp(res->on_off, "on")) {
15517 port->dev_conf.rxmode.offloads |= single_offload;
15518 for (q = 0; q < nb_rx_queues; q++)
15519 port->rx_conf[q].offloads |= single_offload;
15521 port->dev_conf.rxmode.offloads &= ~single_offload;
15522 for (q = 0; q < nb_rx_queues; q++)
15523 port->rx_conf[q].offloads &= ~single_offload;
15526 cmd_reconfig_device_queue(port_id, 1, 1);
15529 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
15530 .f = cmd_config_per_port_rx_offload_parsed,
15532 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
15533 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
15534 "macsec_strip|header_split|vlan_filter|vlan_extend|"
15535 "jumbo_frame|scatter|buffer_split|timestamp|security|"
15536 "keep_crc|rss_hash on|off",
15538 (void *)&cmd_config_per_port_rx_offload_result_port,
15539 (void *)&cmd_config_per_port_rx_offload_result_config,
15540 (void *)&cmd_config_per_port_rx_offload_result_port_id,
15541 (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
15542 (void *)&cmd_config_per_port_rx_offload_result_offload,
15543 (void *)&cmd_config_per_port_rx_offload_result_on_off,
15548 /* Enable/Disable a per queue offloading */
15549 struct cmd_config_per_queue_rx_offload_result {
15550 cmdline_fixed_string_t port;
15552 cmdline_fixed_string_t rxq;
15554 cmdline_fixed_string_t rx_offload;
15555 cmdline_fixed_string_t offload;
15556 cmdline_fixed_string_t on_off;
15559 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
15560 TOKEN_STRING_INITIALIZER
15561 (struct cmd_config_per_queue_rx_offload_result,
15563 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
15564 TOKEN_NUM_INITIALIZER
15565 (struct cmd_config_per_queue_rx_offload_result,
15566 port_id, RTE_UINT16);
15567 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
15568 TOKEN_STRING_INITIALIZER
15569 (struct cmd_config_per_queue_rx_offload_result,
15571 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
15572 TOKEN_NUM_INITIALIZER
15573 (struct cmd_config_per_queue_rx_offload_result,
15574 queue_id, RTE_UINT16);
15575 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
15576 TOKEN_STRING_INITIALIZER
15577 (struct cmd_config_per_queue_rx_offload_result,
15578 rx_offload, "rx_offload");
15579 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
15580 TOKEN_STRING_INITIALIZER
15581 (struct cmd_config_per_queue_rx_offload_result,
15582 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
15583 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
15584 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
15585 "scatter#buffer_split#timestamp#security#keep_crc");
15586 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
15587 TOKEN_STRING_INITIALIZER
15588 (struct cmd_config_per_queue_rx_offload_result,
15592 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
15593 __rte_unused struct cmdline *cl,
15594 __rte_unused void *data)
15596 struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
15597 struct rte_eth_dev_info dev_info;
15598 portid_t port_id = res->port_id;
15599 uint16_t queue_id = res->queue_id;
15600 struct rte_port *port = &ports[port_id];
15601 uint64_t single_offload;
15604 if (port->port_status != RTE_PORT_STOPPED) {
15605 printf("Error: Can't config offload when Port %d "
15606 "is not stopped\n", port_id);
15610 ret = eth_dev_info_get_print_err(port_id, &dev_info);
15614 if (queue_id >= dev_info.nb_rx_queues) {
15615 printf("Error: input queue_id should be 0 ... "
15616 "%d\n", dev_info.nb_rx_queues - 1);
15620 single_offload = search_rx_offload(res->offload);
15621 if (single_offload == 0) {
15622 printf("Unknown offload name: %s\n", res->offload);
15626 if (!strcmp(res->on_off, "on"))
15627 port->rx_conf[queue_id].offloads |= single_offload;
15629 port->rx_conf[queue_id].offloads &= ~single_offload;
15631 cmd_reconfig_device_queue(port_id, 1, 1);
15634 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
15635 .f = cmd_config_per_queue_rx_offload_parsed,
15637 .help_str = "port <port_id> rxq <queue_id> rx_offload "
15638 "vlan_strip|ipv4_cksum|"
15639 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
15640 "macsec_strip|header_split|vlan_filter|vlan_extend|"
15641 "jumbo_frame|scatter|buffer_split|timestamp|security|"
15644 (void *)&cmd_config_per_queue_rx_offload_result_port,
15645 (void *)&cmd_config_per_queue_rx_offload_result_port_id,
15646 (void *)&cmd_config_per_queue_rx_offload_result_rxq,
15647 (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
15648 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
15649 (void *)&cmd_config_per_queue_rx_offload_result_offload,
15650 (void *)&cmd_config_per_queue_rx_offload_result_on_off,
15655 /* Get Tx offloads capabilities */
15656 struct cmd_tx_offload_get_capa_result {
15657 cmdline_fixed_string_t show;
15658 cmdline_fixed_string_t port;
15660 cmdline_fixed_string_t tx_offload;
15661 cmdline_fixed_string_t capabilities;
15664 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
15665 TOKEN_STRING_INITIALIZER
15666 (struct cmd_tx_offload_get_capa_result,
15668 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
15669 TOKEN_STRING_INITIALIZER
15670 (struct cmd_tx_offload_get_capa_result,
15672 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
15673 TOKEN_NUM_INITIALIZER
15674 (struct cmd_tx_offload_get_capa_result,
15675 port_id, RTE_UINT16);
15676 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
15677 TOKEN_STRING_INITIALIZER
15678 (struct cmd_tx_offload_get_capa_result,
15679 tx_offload, "tx_offload");
15680 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
15681 TOKEN_STRING_INITIALIZER
15682 (struct cmd_tx_offload_get_capa_result,
15683 capabilities, "capabilities");
15686 print_tx_offloads(uint64_t offloads)
15688 uint64_t single_offload;
15696 begin = __builtin_ctzll(offloads);
15697 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
15699 single_offload = 1ULL << begin;
15700 for (bit = begin; bit < end; bit++) {
15701 if (offloads & single_offload)
15703 rte_eth_dev_tx_offload_name(single_offload));
15704 single_offload <<= 1;
15709 cmd_tx_offload_get_capa_parsed(
15710 void *parsed_result,
15711 __rte_unused struct cmdline *cl,
15712 __rte_unused void *data)
15714 struct cmd_tx_offload_get_capa_result *res = parsed_result;
15715 struct rte_eth_dev_info dev_info;
15716 portid_t port_id = res->port_id;
15717 uint64_t queue_offloads;
15718 uint64_t port_offloads;
15721 ret = eth_dev_info_get_print_err(port_id, &dev_info);
15725 queue_offloads = dev_info.tx_queue_offload_capa;
15726 port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
15728 printf("Tx Offloading Capabilities of port %d :\n", port_id);
15729 printf(" Per Queue :");
15730 print_tx_offloads(queue_offloads);
15733 printf(" Per Port :");
15734 print_tx_offloads(port_offloads);
15738 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
15739 .f = cmd_tx_offload_get_capa_parsed,
15741 .help_str = "show port <port_id> tx_offload capabilities",
15743 (void *)&cmd_tx_offload_get_capa_show,
15744 (void *)&cmd_tx_offload_get_capa_port,
15745 (void *)&cmd_tx_offload_get_capa_port_id,
15746 (void *)&cmd_tx_offload_get_capa_tx_offload,
15747 (void *)&cmd_tx_offload_get_capa_capabilities,
15752 /* Get Tx offloads configuration */
15753 struct cmd_tx_offload_get_configuration_result {
15754 cmdline_fixed_string_t show;
15755 cmdline_fixed_string_t port;
15757 cmdline_fixed_string_t tx_offload;
15758 cmdline_fixed_string_t configuration;
15761 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
15762 TOKEN_STRING_INITIALIZER
15763 (struct cmd_tx_offload_get_configuration_result,
15765 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
15766 TOKEN_STRING_INITIALIZER
15767 (struct cmd_tx_offload_get_configuration_result,
15769 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
15770 TOKEN_NUM_INITIALIZER
15771 (struct cmd_tx_offload_get_configuration_result,
15772 port_id, RTE_UINT16);
15773 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
15774 TOKEN_STRING_INITIALIZER
15775 (struct cmd_tx_offload_get_configuration_result,
15776 tx_offload, "tx_offload");
15777 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
15778 TOKEN_STRING_INITIALIZER
15779 (struct cmd_tx_offload_get_configuration_result,
15780 configuration, "configuration");
15783 cmd_tx_offload_get_configuration_parsed(
15784 void *parsed_result,
15785 __rte_unused struct cmdline *cl,
15786 __rte_unused void *data)
15788 struct cmd_tx_offload_get_configuration_result *res = parsed_result;
15789 struct rte_eth_dev_info dev_info;
15790 portid_t port_id = res->port_id;
15791 struct rte_port *port = &ports[port_id];
15792 uint64_t port_offloads;
15793 uint64_t queue_offloads;
15794 uint16_t nb_tx_queues;
15798 printf("Tx Offloading Configuration of port %d :\n", port_id);
15800 port_offloads = port->dev_conf.txmode.offloads;
15802 print_tx_offloads(port_offloads);
15805 ret = eth_dev_info_get_print_err(port_id, &dev_info);
15809 nb_tx_queues = dev_info.nb_tx_queues;
15810 for (q = 0; q < nb_tx_queues; q++) {
15811 queue_offloads = port->tx_conf[q].offloads;
15812 printf(" Queue[%2d] :", q);
15813 print_tx_offloads(queue_offloads);
15819 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
15820 .f = cmd_tx_offload_get_configuration_parsed,
15822 .help_str = "show port <port_id> tx_offload configuration",
15824 (void *)&cmd_tx_offload_get_configuration_show,
15825 (void *)&cmd_tx_offload_get_configuration_port,
15826 (void *)&cmd_tx_offload_get_configuration_port_id,
15827 (void *)&cmd_tx_offload_get_configuration_tx_offload,
15828 (void *)&cmd_tx_offload_get_configuration_configuration,
15833 /* Enable/Disable a per port offloading */
15834 struct cmd_config_per_port_tx_offload_result {
15835 cmdline_fixed_string_t port;
15836 cmdline_fixed_string_t config;
15838 cmdline_fixed_string_t tx_offload;
15839 cmdline_fixed_string_t offload;
15840 cmdline_fixed_string_t on_off;
15843 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
15844 TOKEN_STRING_INITIALIZER
15845 (struct cmd_config_per_port_tx_offload_result,
15847 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
15848 TOKEN_STRING_INITIALIZER
15849 (struct cmd_config_per_port_tx_offload_result,
15851 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
15852 TOKEN_NUM_INITIALIZER
15853 (struct cmd_config_per_port_tx_offload_result,
15854 port_id, RTE_UINT16);
15855 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
15856 TOKEN_STRING_INITIALIZER
15857 (struct cmd_config_per_port_tx_offload_result,
15858 tx_offload, "tx_offload");
15859 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
15860 TOKEN_STRING_INITIALIZER
15861 (struct cmd_config_per_port_tx_offload_result,
15862 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
15863 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
15864 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
15865 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
15866 "mt_lockfree#multi_segs#mbuf_fast_free#security#"
15867 "send_on_timestamp");
15868 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
15869 TOKEN_STRING_INITIALIZER
15870 (struct cmd_config_per_port_tx_offload_result,
15874 search_tx_offload(const char *name)
15876 uint64_t single_offload;
15877 const char *single_name;
15881 single_offload = 1;
15882 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
15883 single_name = rte_eth_dev_tx_offload_name(single_offload);
15884 if (single_name == NULL)
15886 if (!strcasecmp(single_name, name)) {
15889 } else if (!strcasecmp(single_name, "UNKNOWN"))
15891 single_offload <<= 1;
15895 return single_offload;
15901 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
15902 __rte_unused struct cmdline *cl,
15903 __rte_unused void *data)
15905 struct cmd_config_per_port_tx_offload_result *res = parsed_result;
15906 portid_t port_id = res->port_id;
15907 struct rte_eth_dev_info dev_info;
15908 struct rte_port *port = &ports[port_id];
15909 uint64_t single_offload;
15910 uint16_t nb_tx_queues;
15914 if (port->port_status != RTE_PORT_STOPPED) {
15915 printf("Error: Can't config offload when Port %d "
15916 "is not stopped\n", port_id);
15920 single_offload = search_tx_offload(res->offload);
15921 if (single_offload == 0) {
15922 printf("Unknown offload name: %s\n", res->offload);
15926 ret = eth_dev_info_get_print_err(port_id, &dev_info);
15930 nb_tx_queues = dev_info.nb_tx_queues;
15931 if (!strcmp(res->on_off, "on")) {
15932 port->dev_conf.txmode.offloads |= single_offload;
15933 for (q = 0; q < nb_tx_queues; q++)
15934 port->tx_conf[q].offloads |= single_offload;
15936 port->dev_conf.txmode.offloads &= ~single_offload;
15937 for (q = 0; q < nb_tx_queues; q++)
15938 port->tx_conf[q].offloads &= ~single_offload;
15941 cmd_reconfig_device_queue(port_id, 1, 1);
15944 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
15945 .f = cmd_config_per_port_tx_offload_parsed,
15947 .help_str = "port config <port_id> tx_offload "
15948 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
15949 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
15950 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
15951 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
15952 "mt_lockfree|multi_segs|mbuf_fast_free|security|"
15953 "send_on_timestamp on|off",
15955 (void *)&cmd_config_per_port_tx_offload_result_port,
15956 (void *)&cmd_config_per_port_tx_offload_result_config,
15957 (void *)&cmd_config_per_port_tx_offload_result_port_id,
15958 (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
15959 (void *)&cmd_config_per_port_tx_offload_result_offload,
15960 (void *)&cmd_config_per_port_tx_offload_result_on_off,
15965 /* Enable/Disable a per queue offloading */
15966 struct cmd_config_per_queue_tx_offload_result {
15967 cmdline_fixed_string_t port;
15969 cmdline_fixed_string_t txq;
15971 cmdline_fixed_string_t tx_offload;
15972 cmdline_fixed_string_t offload;
15973 cmdline_fixed_string_t on_off;
15976 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
15977 TOKEN_STRING_INITIALIZER
15978 (struct cmd_config_per_queue_tx_offload_result,
15980 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
15981 TOKEN_NUM_INITIALIZER
15982 (struct cmd_config_per_queue_tx_offload_result,
15983 port_id, RTE_UINT16);
15984 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
15985 TOKEN_STRING_INITIALIZER
15986 (struct cmd_config_per_queue_tx_offload_result,
15988 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
15989 TOKEN_NUM_INITIALIZER
15990 (struct cmd_config_per_queue_tx_offload_result,
15991 queue_id, RTE_UINT16);
15992 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
15993 TOKEN_STRING_INITIALIZER
15994 (struct cmd_config_per_queue_tx_offload_result,
15995 tx_offload, "tx_offload");
15996 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
15997 TOKEN_STRING_INITIALIZER
15998 (struct cmd_config_per_queue_tx_offload_result,
15999 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
16000 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
16001 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
16002 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
16003 "mt_lockfree#multi_segs#mbuf_fast_free#security");
16004 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
16005 TOKEN_STRING_INITIALIZER
16006 (struct cmd_config_per_queue_tx_offload_result,
16010 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
16011 __rte_unused struct cmdline *cl,
16012 __rte_unused void *data)
16014 struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
16015 struct rte_eth_dev_info dev_info;
16016 portid_t port_id = res->port_id;
16017 uint16_t queue_id = res->queue_id;
16018 struct rte_port *port = &ports[port_id];
16019 uint64_t single_offload;
16022 if (port->port_status != RTE_PORT_STOPPED) {
16023 printf("Error: Can't config offload when Port %d "
16024 "is not stopped\n", port_id);
16028 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16032 if (queue_id >= dev_info.nb_tx_queues) {
16033 printf("Error: input queue_id should be 0 ... "
16034 "%d\n", dev_info.nb_tx_queues - 1);
16038 single_offload = search_tx_offload(res->offload);
16039 if (single_offload == 0) {
16040 printf("Unknown offload name: %s\n", res->offload);
16044 if (!strcmp(res->on_off, "on"))
16045 port->tx_conf[queue_id].offloads |= single_offload;
16047 port->tx_conf[queue_id].offloads &= ~single_offload;
16049 cmd_reconfig_device_queue(port_id, 1, 1);
16052 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
16053 .f = cmd_config_per_queue_tx_offload_parsed,
16055 .help_str = "port <port_id> txq <queue_id> tx_offload "
16056 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
16057 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
16058 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
16059 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
16060 "mt_lockfree|multi_segs|mbuf_fast_free|security "
16063 (void *)&cmd_config_per_queue_tx_offload_result_port,
16064 (void *)&cmd_config_per_queue_tx_offload_result_port_id,
16065 (void *)&cmd_config_per_queue_tx_offload_result_txq,
16066 (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
16067 (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
16068 (void *)&cmd_config_per_queue_tx_offload_result_offload,
16069 (void *)&cmd_config_per_queue_tx_offload_result_on_off,
16074 /* *** configure tx_metadata for specific port *** */
16075 struct cmd_config_tx_metadata_specific_result {
16076 cmdline_fixed_string_t port;
16077 cmdline_fixed_string_t keyword;
16079 cmdline_fixed_string_t item;
16084 cmd_config_tx_metadata_specific_parsed(void *parsed_result,
16085 __rte_unused struct cmdline *cl,
16086 __rte_unused void *data)
16088 struct cmd_config_tx_metadata_specific_result *res = parsed_result;
16090 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16092 ports[res->port_id].tx_metadata = res->value;
16093 /* Add/remove callback to insert valid metadata in every Tx packet. */
16094 if (ports[res->port_id].tx_metadata)
16095 add_tx_md_callback(res->port_id);
16097 remove_tx_md_callback(res->port_id);
16098 rte_flow_dynf_metadata_register();
16101 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
16102 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16104 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
16105 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16106 keyword, "config");
16107 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
16108 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16109 port_id, RTE_UINT16);
16110 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
16111 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16112 item, "tx_metadata");
16113 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
16114 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16115 value, RTE_UINT32);
16117 cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
16118 .f = cmd_config_tx_metadata_specific_parsed,
16120 .help_str = "port config <port_id> tx_metadata <value>",
16122 (void *)&cmd_config_tx_metadata_specific_port,
16123 (void *)&cmd_config_tx_metadata_specific_keyword,
16124 (void *)&cmd_config_tx_metadata_specific_id,
16125 (void *)&cmd_config_tx_metadata_specific_item,
16126 (void *)&cmd_config_tx_metadata_specific_value,
16131 /* *** set dynf *** */
16132 struct cmd_config_tx_dynf_specific_result {
16133 cmdline_fixed_string_t port;
16134 cmdline_fixed_string_t keyword;
16136 cmdline_fixed_string_t item;
16137 cmdline_fixed_string_t name;
16138 cmdline_fixed_string_t value;
16142 cmd_config_dynf_specific_parsed(void *parsed_result,
16143 __rte_unused struct cmdline *cl,
16144 __rte_unused void *data)
16146 struct cmd_config_tx_dynf_specific_result *res = parsed_result;
16147 struct rte_mbuf_dynflag desc_flag;
16149 uint64_t old_port_flags;
16151 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16153 flag = rte_mbuf_dynflag_lookup(res->name, NULL);
16155 if (strlcpy(desc_flag.name, res->name,
16156 RTE_MBUF_DYN_NAMESIZE) >= RTE_MBUF_DYN_NAMESIZE) {
16157 printf("Flag name too long\n");
16160 desc_flag.flags = 0;
16161 flag = rte_mbuf_dynflag_register(&desc_flag);
16163 printf("Can't register flag\n");
16166 strcpy(dynf_names[flag], desc_flag.name);
16168 old_port_flags = ports[res->port_id].mbuf_dynf;
16169 if (!strcmp(res->value, "set")) {
16170 ports[res->port_id].mbuf_dynf |= 1UL << flag;
16171 if (old_port_flags == 0)
16172 add_tx_dynf_callback(res->port_id);
16174 ports[res->port_id].mbuf_dynf &= ~(1UL << flag);
16175 if (ports[res->port_id].mbuf_dynf == 0)
16176 remove_tx_dynf_callback(res->port_id);
16180 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_port =
16181 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16183 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_keyword =
16184 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16185 keyword, "config");
16186 cmdline_parse_token_num_t cmd_config_tx_dynf_specific_port_id =
16187 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16188 port_id, RTE_UINT16);
16189 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_item =
16190 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16192 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_name =
16193 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16195 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_value =
16196 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16197 value, "set#clear");
16199 cmdline_parse_inst_t cmd_config_tx_dynf_specific = {
16200 .f = cmd_config_dynf_specific_parsed,
16202 .help_str = "port config <port id> dynf <name> set|clear",
16204 (void *)&cmd_config_tx_dynf_specific_port,
16205 (void *)&cmd_config_tx_dynf_specific_keyword,
16206 (void *)&cmd_config_tx_dynf_specific_port_id,
16207 (void *)&cmd_config_tx_dynf_specific_item,
16208 (void *)&cmd_config_tx_dynf_specific_name,
16209 (void *)&cmd_config_tx_dynf_specific_value,
16214 /* *** display tx_metadata per port configuration *** */
16215 struct cmd_show_tx_metadata_result {
16216 cmdline_fixed_string_t cmd_show;
16217 cmdline_fixed_string_t cmd_port;
16218 cmdline_fixed_string_t cmd_keyword;
16223 cmd_show_tx_metadata_parsed(void *parsed_result,
16224 __rte_unused struct cmdline *cl,
16225 __rte_unused void *data)
16227 struct cmd_show_tx_metadata_result *res = parsed_result;
16229 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16230 printf("invalid port id %u\n", res->cmd_pid);
16233 if (!strcmp(res->cmd_keyword, "tx_metadata")) {
16234 printf("Port %u tx_metadata: %u\n", res->cmd_pid,
16235 ports[res->cmd_pid].tx_metadata);
16239 cmdline_parse_token_string_t cmd_show_tx_metadata_show =
16240 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
16242 cmdline_parse_token_string_t cmd_show_tx_metadata_port =
16243 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
16245 cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
16246 TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
16247 cmd_pid, RTE_UINT16);
16248 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
16249 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
16250 cmd_keyword, "tx_metadata");
16252 cmdline_parse_inst_t cmd_show_tx_metadata = {
16253 .f = cmd_show_tx_metadata_parsed,
16255 .help_str = "show port <port_id> tx_metadata",
16257 (void *)&cmd_show_tx_metadata_show,
16258 (void *)&cmd_show_tx_metadata_port,
16259 (void *)&cmd_show_tx_metadata_pid,
16260 (void *)&cmd_show_tx_metadata_keyword,
16265 /* *** show fec capability per port configuration *** */
16266 struct cmd_show_fec_capability_result {
16267 cmdline_fixed_string_t cmd_show;
16268 cmdline_fixed_string_t cmd_port;
16269 cmdline_fixed_string_t cmd_fec;
16270 cmdline_fixed_string_t cmd_keyword;
16275 cmd_show_fec_capability_parsed(void *parsed_result,
16276 __rte_unused struct cmdline *cl,
16277 __rte_unused void *data)
16279 struct cmd_show_fec_capability_result *res = parsed_result;
16280 struct rte_eth_fec_capa *speed_fec_capa;
16284 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16285 printf("Invalid port id %u\n", res->cmd_pid);
16289 ret = rte_eth_fec_get_capability(res->cmd_pid, NULL, 0);
16290 if (ret == -ENOTSUP) {
16291 printf("Function not implemented\n");
16293 } else if (ret < 0) {
16294 printf("Get FEC capability failed: %d\n", ret);
16298 num = (unsigned int)ret;
16299 speed_fec_capa = calloc(num, sizeof(*speed_fec_capa));
16300 if (speed_fec_capa == NULL) {
16301 printf("Failed to alloc FEC capability buffer\n");
16305 ret = rte_eth_fec_get_capability(res->cmd_pid, speed_fec_capa, num);
16307 printf("Error getting FEC capability: %d\n", ret);
16311 show_fec_capability(num, speed_fec_capa);
16313 free(speed_fec_capa);
16316 cmdline_parse_token_string_t cmd_show_fec_capability_show =
16317 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16319 cmdline_parse_token_string_t cmd_show_fec_capability_port =
16320 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16322 cmdline_parse_token_num_t cmd_show_fec_capability_pid =
16323 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_capability_result,
16324 cmd_pid, RTE_UINT16);
16325 cmdline_parse_token_string_t cmd_show_fec_capability_fec =
16326 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16328 cmdline_parse_token_string_t cmd_show_fec_capability_keyword =
16329 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16330 cmd_keyword, "capabilities");
16332 cmdline_parse_inst_t cmd_show_capability = {
16333 .f = cmd_show_fec_capability_parsed,
16335 .help_str = "show port <port_id> fec capabilities",
16337 (void *)&cmd_show_fec_capability_show,
16338 (void *)&cmd_show_fec_capability_port,
16339 (void *)&cmd_show_fec_capability_pid,
16340 (void *)&cmd_show_fec_capability_fec,
16341 (void *)&cmd_show_fec_capability_keyword,
16346 /* *** show fec mode per port configuration *** */
16347 struct cmd_show_fec_metadata_result {
16348 cmdline_fixed_string_t cmd_show;
16349 cmdline_fixed_string_t cmd_port;
16350 cmdline_fixed_string_t cmd_keyword;
16355 cmd_show_fec_mode_parsed(void *parsed_result,
16356 __rte_unused struct cmdline *cl,
16357 __rte_unused void *data)
16359 #define FEC_NAME_SIZE 16
16360 struct cmd_show_fec_metadata_result *res = parsed_result;
16362 char buf[FEC_NAME_SIZE];
16365 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16366 printf("Invalid port id %u\n", res->cmd_pid);
16369 ret = rte_eth_fec_get(res->cmd_pid, &mode);
16370 if (ret == -ENOTSUP) {
16371 printf("Function not implemented\n");
16373 } else if (ret < 0) {
16374 printf("Get FEC mode failed\n");
16379 case RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC):
16380 strlcpy(buf, "off", sizeof(buf));
16382 case RTE_ETH_FEC_MODE_CAPA_MASK(AUTO):
16383 strlcpy(buf, "auto", sizeof(buf));
16385 case RTE_ETH_FEC_MODE_CAPA_MASK(BASER):
16386 strlcpy(buf, "baser", sizeof(buf));
16388 case RTE_ETH_FEC_MODE_CAPA_MASK(RS):
16389 strlcpy(buf, "rs", sizeof(buf));
16395 printf("%s\n", buf);
16398 cmdline_parse_token_string_t cmd_show_fec_mode_show =
16399 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
16401 cmdline_parse_token_string_t cmd_show_fec_mode_port =
16402 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
16404 cmdline_parse_token_num_t cmd_show_fec_mode_pid =
16405 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_metadata_result,
16406 cmd_pid, RTE_UINT16);
16407 cmdline_parse_token_string_t cmd_show_fec_mode_keyword =
16408 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
16409 cmd_keyword, "fec_mode");
16411 cmdline_parse_inst_t cmd_show_fec_mode = {
16412 .f = cmd_show_fec_mode_parsed,
16414 .help_str = "show port <port_id> fec_mode",
16416 (void *)&cmd_show_fec_mode_show,
16417 (void *)&cmd_show_fec_mode_port,
16418 (void *)&cmd_show_fec_mode_pid,
16419 (void *)&cmd_show_fec_mode_keyword,
16424 /* *** set fec mode per port configuration *** */
16425 struct cmd_set_port_fec_mode {
16426 cmdline_fixed_string_t set;
16427 cmdline_fixed_string_t port;
16429 cmdline_fixed_string_t fec_mode;
16430 cmdline_fixed_string_t fec_value;
16433 /* Common CLI fields for set fec mode */
16434 cmdline_parse_token_string_t cmd_set_port_fec_mode_set =
16435 TOKEN_STRING_INITIALIZER
16436 (struct cmd_set_port_fec_mode,
16438 cmdline_parse_token_string_t cmd_set_port_fec_mode_port =
16439 TOKEN_STRING_INITIALIZER
16440 (struct cmd_set_port_fec_mode,
16442 cmdline_parse_token_num_t cmd_set_port_fec_mode_port_id =
16443 TOKEN_NUM_INITIALIZER
16444 (struct cmd_set_port_fec_mode,
16445 port_id, RTE_UINT16);
16446 cmdline_parse_token_string_t cmd_set_port_fec_mode_str =
16447 TOKEN_STRING_INITIALIZER
16448 (struct cmd_set_port_fec_mode,
16449 fec_mode, "fec_mode");
16450 cmdline_parse_token_string_t cmd_set_port_fec_mode_value =
16451 TOKEN_STRING_INITIALIZER
16452 (struct cmd_set_port_fec_mode,
16456 cmd_set_port_fec_mode_parsed(
16457 void *parsed_result,
16458 __rte_unused struct cmdline *cl,
16459 __rte_unused void *data)
16461 struct cmd_set_port_fec_mode *res = parsed_result;
16462 uint16_t port_id = res->port_id;
16466 ret = parse_fec_mode(res->fec_value, &mode);
16468 printf("Unknown fec mode: %s for Port %d\n", res->fec_value,
16473 ret = rte_eth_fec_set(port_id, mode);
16474 if (ret == -ENOTSUP) {
16475 printf("Function not implemented\n");
16477 } else if (ret < 0) {
16478 printf("Set FEC mode failed\n");
16483 cmdline_parse_inst_t cmd_set_fec_mode = {
16484 .f = cmd_set_port_fec_mode_parsed,
16486 .help_str = "set port <port_id> fec_mode auto|off|rs|baser",
16488 (void *)&cmd_set_port_fec_mode_set,
16489 (void *)&cmd_set_port_fec_mode_port,
16490 (void *)&cmd_set_port_fec_mode_port_id,
16491 (void *)&cmd_set_port_fec_mode_str,
16492 (void *)&cmd_set_port_fec_mode_value,
16497 /* show port supported ptypes */
16499 /* Common result structure for show port ptypes */
16500 struct cmd_show_port_supported_ptypes_result {
16501 cmdline_fixed_string_t show;
16502 cmdline_fixed_string_t port;
16504 cmdline_fixed_string_t ptypes;
16507 /* Common CLI fields for show port ptypes */
16508 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =
16509 TOKEN_STRING_INITIALIZER
16510 (struct cmd_show_port_supported_ptypes_result,
16512 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
16513 TOKEN_STRING_INITIALIZER
16514 (struct cmd_show_port_supported_ptypes_result,
16516 cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =
16517 TOKEN_NUM_INITIALIZER
16518 (struct cmd_show_port_supported_ptypes_result,
16519 port_id, RTE_UINT16);
16520 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =
16521 TOKEN_STRING_INITIALIZER
16522 (struct cmd_show_port_supported_ptypes_result,
16526 cmd_show_port_supported_ptypes_parsed(
16527 void *parsed_result,
16528 __rte_unused struct cmdline *cl,
16529 __rte_unused void *data)
16531 #define RSVD_PTYPE_MASK 0xf0000000
16532 #define MAX_PTYPES_PER_LAYER 16
16533 #define LTYPE_NAMESIZE 32
16534 #define PTYPE_NAMESIZE 256
16535 struct cmd_show_port_supported_ptypes_result *res = parsed_result;
16536 char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE];
16537 uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
16538 uint32_t ptypes[MAX_PTYPES_PER_LAYER];
16539 uint16_t port_id = res->port_id;
16542 ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0);
16546 while (ptype_mask != RSVD_PTYPE_MASK) {
16548 switch (ptype_mask) {
16549 case RTE_PTYPE_L2_MASK:
16550 strlcpy(ltype, "L2", sizeof(ltype));
16552 case RTE_PTYPE_L3_MASK:
16553 strlcpy(ltype, "L3", sizeof(ltype));
16555 case RTE_PTYPE_L4_MASK:
16556 strlcpy(ltype, "L4", sizeof(ltype));
16558 case RTE_PTYPE_TUNNEL_MASK:
16559 strlcpy(ltype, "Tunnel", sizeof(ltype));
16561 case RTE_PTYPE_INNER_L2_MASK:
16562 strlcpy(ltype, "Inner L2", sizeof(ltype));
16564 case RTE_PTYPE_INNER_L3_MASK:
16565 strlcpy(ltype, "Inner L3", sizeof(ltype));
16567 case RTE_PTYPE_INNER_L4_MASK:
16568 strlcpy(ltype, "Inner L4", sizeof(ltype));
16574 ret = rte_eth_dev_get_supported_ptypes(res->port_id,
16575 ptype_mask, ptypes,
16576 MAX_PTYPES_PER_LAYER);
16579 printf("Supported %s ptypes:\n", ltype);
16581 printf("%s ptypes unsupported\n", ltype);
16583 for (i = 0; i < ret; ++i) {
16584 rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
16585 printf("%s\n", buf);
16592 cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
16593 .f = cmd_show_port_supported_ptypes_parsed,
16595 .help_str = "show port <port_id> ptypes",
16597 (void *)&cmd_show_port_supported_ptypes_show,
16598 (void *)&cmd_show_port_supported_ptypes_port,
16599 (void *)&cmd_show_port_supported_ptypes_port_id,
16600 (void *)&cmd_show_port_supported_ptypes_ptypes,
16605 /* *** display rx/tx descriptor status *** */
16606 struct cmd_show_rx_tx_desc_status_result {
16607 cmdline_fixed_string_t cmd_show;
16608 cmdline_fixed_string_t cmd_port;
16609 cmdline_fixed_string_t cmd_keyword;
16610 cmdline_fixed_string_t cmd_desc;
16611 cmdline_fixed_string_t cmd_status;
16618 cmd_show_rx_tx_desc_status_parsed(void *parsed_result,
16619 __rte_unused struct cmdline *cl,
16620 __rte_unused void *data)
16622 struct cmd_show_rx_tx_desc_status_result *res = parsed_result;
16625 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16626 printf("invalid port id %u\n", res->cmd_pid);
16630 if (!strcmp(res->cmd_keyword, "rxq")) {
16631 rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid,
16634 printf("Invalid queueid = %d\n", res->cmd_qid);
16637 if (rc == RTE_ETH_RX_DESC_AVAIL)
16638 printf("Desc status = AVAILABLE\n");
16639 else if (rc == RTE_ETH_RX_DESC_DONE)
16640 printf("Desc status = DONE\n");
16642 printf("Desc status = UNAVAILABLE\n");
16643 } else if (!strcmp(res->cmd_keyword, "txq")) {
16644 rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid,
16647 printf("Invalid queueid = %d\n", res->cmd_qid);
16650 if (rc == RTE_ETH_TX_DESC_FULL)
16651 printf("Desc status = FULL\n");
16652 else if (rc == RTE_ETH_TX_DESC_DONE)
16653 printf("Desc status = DONE\n");
16655 printf("Desc status = UNAVAILABLE\n");
16659 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show =
16660 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
16662 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port =
16663 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
16665 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid =
16666 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
16667 cmd_pid, RTE_UINT16);
16668 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword =
16669 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
16670 cmd_keyword, "rxq#txq");
16671 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid =
16672 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
16673 cmd_qid, RTE_UINT16);
16674 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc =
16675 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
16677 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did =
16678 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
16679 cmd_did, RTE_UINT16);
16680 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status =
16681 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
16682 cmd_status, "status");
16683 cmdline_parse_inst_t cmd_show_rx_tx_desc_status = {
16684 .f = cmd_show_rx_tx_desc_status_parsed,
16686 .help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> "
16689 (void *)&cmd_show_rx_tx_desc_status_show,
16690 (void *)&cmd_show_rx_tx_desc_status_port,
16691 (void *)&cmd_show_rx_tx_desc_status_pid,
16692 (void *)&cmd_show_rx_tx_desc_status_keyword,
16693 (void *)&cmd_show_rx_tx_desc_status_qid,
16694 (void *)&cmd_show_rx_tx_desc_status_desc,
16695 (void *)&cmd_show_rx_tx_desc_status_did,
16696 (void *)&cmd_show_rx_tx_desc_status_status,
16701 /* *** display rx queue desc used count *** */
16702 struct cmd_show_rx_queue_desc_used_count_result {
16703 cmdline_fixed_string_t cmd_show;
16704 cmdline_fixed_string_t cmd_port;
16705 cmdline_fixed_string_t cmd_rxq;
16706 cmdline_fixed_string_t cmd_desc;
16707 cmdline_fixed_string_t cmd_used;
16708 cmdline_fixed_string_t cmd_count;
16714 cmd_show_rx_queue_desc_used_count_parsed(void *parsed_result,
16715 __rte_unused struct cmdline *cl,
16716 __rte_unused void *data)
16718 struct cmd_show_rx_queue_desc_used_count_result *res = parsed_result;
16721 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16722 printf("invalid port id %u\n", res->cmd_pid);
16726 rc = rte_eth_rx_queue_count(res->cmd_pid, res->cmd_qid);
16728 printf("Invalid queueid = %d\n", res->cmd_qid);
16731 printf("Used desc count = %d\n", rc);
16734 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_show =
16735 TOKEN_STRING_INITIALIZER
16736 (struct cmd_show_rx_queue_desc_used_count_result,
16738 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_port =
16739 TOKEN_STRING_INITIALIZER
16740 (struct cmd_show_rx_queue_desc_used_count_result,
16742 cmdline_parse_token_num_t cmd_show_rx_queue_desc_used_count_pid =
16743 TOKEN_NUM_INITIALIZER
16744 (struct cmd_show_rx_queue_desc_used_count_result,
16745 cmd_pid, RTE_UINT16);
16746 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_rxq =
16747 TOKEN_STRING_INITIALIZER
16748 (struct cmd_show_rx_queue_desc_used_count_result,
16750 cmdline_parse_token_num_t cmd_show_rx_queue_desc_used_count_qid =
16751 TOKEN_NUM_INITIALIZER
16752 (struct cmd_show_rx_queue_desc_used_count_result,
16753 cmd_qid, RTE_UINT16);
16754 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_desc =
16755 TOKEN_STRING_INITIALIZER
16756 (struct cmd_show_rx_queue_desc_used_count_result,
16757 cmd_count, "desc");
16758 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_used =
16759 TOKEN_STRING_INITIALIZER
16760 (struct cmd_show_rx_queue_desc_used_count_result,
16761 cmd_count, "used");
16762 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_count =
16763 TOKEN_STRING_INITIALIZER
16764 (struct cmd_show_rx_queue_desc_used_count_result,
16765 cmd_count, "count");
16766 cmdline_parse_inst_t cmd_show_rx_queue_desc_used_count = {
16767 .f = cmd_show_rx_queue_desc_used_count_parsed,
16769 .help_str = "show port <port_id> rxq <queue_id> desc used count",
16771 (void *)&cmd_show_rx_queue_desc_used_count_show,
16772 (void *)&cmd_show_rx_queue_desc_used_count_port,
16773 (void *)&cmd_show_rx_queue_desc_used_count_pid,
16774 (void *)&cmd_show_rx_queue_desc_used_count_rxq,
16775 (void *)&cmd_show_rx_queue_desc_used_count_qid,
16776 (void *)&cmd_show_rx_queue_desc_used_count_desc,
16777 (void *)&cmd_show_rx_queue_desc_used_count_used,
16778 (void *)&cmd_show_rx_queue_desc_used_count_count,
16783 /* Common result structure for set port ptypes */
16784 struct cmd_set_port_ptypes_result {
16785 cmdline_fixed_string_t set;
16786 cmdline_fixed_string_t port;
16788 cmdline_fixed_string_t ptype_mask;
16792 /* Common CLI fields for set port ptypes */
16793 cmdline_parse_token_string_t cmd_set_port_ptypes_set =
16794 TOKEN_STRING_INITIALIZER
16795 (struct cmd_set_port_ptypes_result,
16797 cmdline_parse_token_string_t cmd_set_port_ptypes_port =
16798 TOKEN_STRING_INITIALIZER
16799 (struct cmd_set_port_ptypes_result,
16801 cmdline_parse_token_num_t cmd_set_port_ptypes_port_id =
16802 TOKEN_NUM_INITIALIZER
16803 (struct cmd_set_port_ptypes_result,
16804 port_id, RTE_UINT16);
16805 cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str =
16806 TOKEN_STRING_INITIALIZER
16807 (struct cmd_set_port_ptypes_result,
16808 ptype_mask, "ptype_mask");
16809 cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 =
16810 TOKEN_NUM_INITIALIZER
16811 (struct cmd_set_port_ptypes_result,
16815 cmd_set_port_ptypes_parsed(
16816 void *parsed_result,
16817 __rte_unused struct cmdline *cl,
16818 __rte_unused void *data)
16820 struct cmd_set_port_ptypes_result *res = parsed_result;
16821 #define PTYPE_NAMESIZE 256
16822 char ptype_name[PTYPE_NAMESIZE];
16823 uint16_t port_id = res->port_id;
16824 uint32_t ptype_mask = res->mask;
16827 ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK,
16830 printf("Port %d doesn't support any ptypes.\n", port_id);
16834 uint32_t ptypes[ret];
16836 ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret);
16838 printf("Unable to set requested ptypes for Port %d\n", port_id);
16842 printf("Successfully set following ptypes for Port %d\n", port_id);
16843 for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) {
16844 rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name));
16845 printf("%s\n", ptype_name);
16848 clear_ptypes = false;
16851 cmdline_parse_inst_t cmd_set_port_ptypes = {
16852 .f = cmd_set_port_ptypes_parsed,
16854 .help_str = "set port <port_id> ptype_mask <mask>",
16856 (void *)&cmd_set_port_ptypes_set,
16857 (void *)&cmd_set_port_ptypes_port,
16858 (void *)&cmd_set_port_ptypes_port_id,
16859 (void *)&cmd_set_port_ptypes_mask_str,
16860 (void *)&cmd_set_port_ptypes_mask_u32,
16865 /* *** display mac addresses added to a port *** */
16866 struct cmd_showport_macs_result {
16867 cmdline_fixed_string_t cmd_show;
16868 cmdline_fixed_string_t cmd_port;
16869 cmdline_fixed_string_t cmd_keyword;
16874 cmd_showport_macs_parsed(void *parsed_result,
16875 __rte_unused struct cmdline *cl,
16876 __rte_unused void *data)
16878 struct cmd_showport_macs_result *res = parsed_result;
16880 if (port_id_is_invalid(res->cmd_pid, ENABLED_WARN))
16883 if (!strcmp(res->cmd_keyword, "macs"))
16884 show_macs(res->cmd_pid);
16885 else if (!strcmp(res->cmd_keyword, "mcast_macs"))
16886 show_mcast_macs(res->cmd_pid);
16889 cmdline_parse_token_string_t cmd_showport_macs_show =
16890 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
16892 cmdline_parse_token_string_t cmd_showport_macs_port =
16893 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
16895 cmdline_parse_token_num_t cmd_showport_macs_pid =
16896 TOKEN_NUM_INITIALIZER(struct cmd_showport_macs_result,
16897 cmd_pid, RTE_UINT16);
16898 cmdline_parse_token_string_t cmd_showport_macs_keyword =
16899 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
16900 cmd_keyword, "macs#mcast_macs");
16902 cmdline_parse_inst_t cmd_showport_macs = {
16903 .f = cmd_showport_macs_parsed,
16905 .help_str = "show port <port_id> macs|mcast_macs",
16907 (void *)&cmd_showport_macs_show,
16908 (void *)&cmd_showport_macs_port,
16909 (void *)&cmd_showport_macs_pid,
16910 (void *)&cmd_showport_macs_keyword,
16915 /* ******************************************************************************** */
16917 /* list of instructions */
16918 cmdline_parse_ctx_t main_ctx[] = {
16919 (cmdline_parse_inst_t *)&cmd_help_brief,
16920 (cmdline_parse_inst_t *)&cmd_help_long,
16921 (cmdline_parse_inst_t *)&cmd_quit,
16922 (cmdline_parse_inst_t *)&cmd_load_from_file,
16923 (cmdline_parse_inst_t *)&cmd_showport,
16924 (cmdline_parse_inst_t *)&cmd_showqueue,
16925 (cmdline_parse_inst_t *)&cmd_showeeprom,
16926 (cmdline_parse_inst_t *)&cmd_showportall,
16927 (cmdline_parse_inst_t *)&cmd_showdevice,
16928 (cmdline_parse_inst_t *)&cmd_showcfg,
16929 (cmdline_parse_inst_t *)&cmd_showfwdall,
16930 (cmdline_parse_inst_t *)&cmd_start,
16931 (cmdline_parse_inst_t *)&cmd_start_tx_first,
16932 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
16933 (cmdline_parse_inst_t *)&cmd_set_link_up,
16934 (cmdline_parse_inst_t *)&cmd_set_link_down,
16935 (cmdline_parse_inst_t *)&cmd_reset,
16936 (cmdline_parse_inst_t *)&cmd_set_numbers,
16937 (cmdline_parse_inst_t *)&cmd_set_log,
16938 (cmdline_parse_inst_t *)&cmd_set_rxoffs,
16939 (cmdline_parse_inst_t *)&cmd_set_rxpkts,
16940 (cmdline_parse_inst_t *)&cmd_set_txpkts,
16941 (cmdline_parse_inst_t *)&cmd_set_txsplit,
16942 (cmdline_parse_inst_t *)&cmd_set_txtimes,
16943 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
16944 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
16945 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
16946 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
16947 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
16948 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
16949 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
16950 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
16951 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
16952 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
16953 (cmdline_parse_inst_t *)&cmd_set_link_check,
16954 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
16955 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
16956 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
16957 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
16958 #ifdef RTE_NET_BOND
16959 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
16960 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
16961 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
16962 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
16963 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
16964 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
16965 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
16966 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
16967 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
16968 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
16969 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
16971 (cmdline_parse_inst_t *)&cmd_vlan_offload,
16972 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
16973 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
16974 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
16975 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
16976 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
16977 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
16978 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
16979 (cmdline_parse_inst_t *)&cmd_csum_set,
16980 (cmdline_parse_inst_t *)&cmd_csum_show,
16981 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
16982 (cmdline_parse_inst_t *)&cmd_tso_set,
16983 (cmdline_parse_inst_t *)&cmd_tso_show,
16984 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
16985 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
16986 (cmdline_parse_inst_t *)&cmd_gro_enable,
16987 (cmdline_parse_inst_t *)&cmd_gro_flush,
16988 (cmdline_parse_inst_t *)&cmd_gro_show,
16989 (cmdline_parse_inst_t *)&cmd_gso_enable,
16990 (cmdline_parse_inst_t *)&cmd_gso_size,
16991 (cmdline_parse_inst_t *)&cmd_gso_show,
16992 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
16993 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
16994 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
16995 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
16996 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
16997 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
16998 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
16999 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
17000 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
17001 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
17002 (cmdline_parse_inst_t *)&cmd_config_dcb,
17003 (cmdline_parse_inst_t *)&cmd_read_reg,
17004 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
17005 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
17006 (cmdline_parse_inst_t *)&cmd_write_reg,
17007 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
17008 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
17009 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
17010 (cmdline_parse_inst_t *)&cmd_stop,
17011 (cmdline_parse_inst_t *)&cmd_mac_addr,
17012 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
17013 (cmdline_parse_inst_t *)&cmd_set_qmap,
17014 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
17015 (cmdline_parse_inst_t *)&cmd_set_record_core_cycles,
17016 (cmdline_parse_inst_t *)&cmd_set_record_burst_stats,
17017 (cmdline_parse_inst_t *)&cmd_operate_port,
17018 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
17019 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
17020 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
17021 (cmdline_parse_inst_t *)&cmd_operate_detach_device,
17022 (cmdline_parse_inst_t *)&cmd_set_port_setup_on,
17023 (cmdline_parse_inst_t *)&cmd_config_speed_all,
17024 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
17025 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
17026 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
17027 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
17028 (cmdline_parse_inst_t *)&cmd_config_mtu,
17029 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
17030 (cmdline_parse_inst_t *)&cmd_config_max_lro_pkt_size,
17031 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
17032 (cmdline_parse_inst_t *)&cmd_config_rss,
17033 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
17034 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
17035 (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
17036 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
17037 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
17038 (cmdline_parse_inst_t *)&cmd_showport_reta,
17039 (cmdline_parse_inst_t *)&cmd_showport_macs,
17040 (cmdline_parse_inst_t *)&cmd_config_burst,
17041 (cmdline_parse_inst_t *)&cmd_config_thresh,
17042 (cmdline_parse_inst_t *)&cmd_config_threshold,
17043 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
17044 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
17045 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
17046 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
17047 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
17048 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
17049 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
17050 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
17051 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
17052 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
17053 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
17054 (cmdline_parse_inst_t *)&cmd_dump,
17055 (cmdline_parse_inst_t *)&cmd_dump_one,
17056 #ifdef RTE_NET_I40E
17057 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
17059 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
17060 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
17061 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
17062 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
17063 (cmdline_parse_inst_t *)&cmd_flow,
17064 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
17065 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
17066 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
17067 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
17068 (cmdline_parse_inst_t *)&cmd_create_port_meter,
17069 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
17070 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
17071 (cmdline_parse_inst_t *)&cmd_del_port_meter,
17072 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
17073 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
17074 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
17075 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
17076 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
17077 (cmdline_parse_inst_t *)&cmd_mcast_addr,
17078 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
17079 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
17080 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
17081 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
17082 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
17083 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
17084 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
17085 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
17086 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
17087 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
17088 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
17089 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
17090 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
17091 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
17092 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
17093 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
17094 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
17095 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
17096 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
17097 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
17098 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
17099 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
17100 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
17101 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
17102 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
17103 (cmdline_parse_inst_t *)&cmd_set_vxlan,
17104 (cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl,
17105 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
17106 (cmdline_parse_inst_t *)&cmd_set_nvgre,
17107 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
17108 (cmdline_parse_inst_t *)&cmd_set_l2_encap,
17109 (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
17110 (cmdline_parse_inst_t *)&cmd_set_l2_decap,
17111 (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
17112 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
17113 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
17114 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
17115 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
17116 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
17117 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
17118 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
17119 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
17120 (cmdline_parse_inst_t *)&cmd_ddp_add,
17121 (cmdline_parse_inst_t *)&cmd_ddp_del,
17122 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
17123 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
17124 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
17125 (cmdline_parse_inst_t *)&cmd_clear_input_set,
17126 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
17127 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
17128 (cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes,
17129 (cmdline_parse_inst_t *)&cmd_set_port_ptypes,
17130 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
17131 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
17132 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
17133 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
17135 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
17136 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
17137 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
17138 (cmdline_parse_inst_t *)&cmd_queue_region,
17139 (cmdline_parse_inst_t *)&cmd_region_flowtype,
17140 (cmdline_parse_inst_t *)&cmd_user_priority_region,
17141 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
17142 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
17143 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
17144 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
17145 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
17146 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
17147 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
17148 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
17149 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
17150 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
17151 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
17152 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
17153 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
17154 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
17155 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
17156 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node_pmode,
17157 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
17158 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
17159 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
17160 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
17161 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
17162 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
17163 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
17164 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
17165 (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
17166 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
17167 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
17168 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
17169 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
17170 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
17171 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
17172 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
17173 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
17174 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
17176 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
17177 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
17179 (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
17180 (cmdline_parse_inst_t *)&cmd_show_tx_metadata,
17181 (cmdline_parse_inst_t *)&cmd_show_rx_tx_desc_status,
17182 (cmdline_parse_inst_t *)&cmd_show_rx_queue_desc_used_count,
17183 (cmdline_parse_inst_t *)&cmd_set_raw,
17184 (cmdline_parse_inst_t *)&cmd_show_set_raw,
17185 (cmdline_parse_inst_t *)&cmd_show_set_raw_all,
17186 (cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific,
17187 (cmdline_parse_inst_t *)&cmd_show_fec_mode,
17188 (cmdline_parse_inst_t *)&cmd_set_fec_mode,
17189 (cmdline_parse_inst_t *)&cmd_show_capability,
17193 /* read cmdline commands from file */
17195 cmdline_read_from_file(const char *filename)
17197 struct cmdline *cl;
17199 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
17201 printf("Failed to create file based cmdline context: %s\n",
17206 cmdline_interact(cl);
17211 printf("Read CLI commands from %s\n", filename);
17214 /* prompt function, called from main on MAIN lcore */
17219 /* initialize non-constant commands */
17220 cmd_set_fwd_mode_init();
17221 cmd_set_fwd_retry_mode_init();
17223 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
17224 if (testpmd_cl == NULL)
17227 ret = atexit(prompt_exit);
17229 printf("Cannot set exit function for cmdline\n");
17231 cmdline_interact(testpmd_cl);
17233 cmdline_stdin_exit(testpmd_cl);
17239 if (testpmd_cl != NULL) {
17240 cmdline_quit(testpmd_cl);
17241 cmdline_stdin_exit(testpmd_cl);
17246 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
17248 if (id == (portid_t)RTE_PORT_ALL) {
17251 RTE_ETH_FOREACH_DEV(pid) {
17252 /* check if need_reconfig has been set to 1 */
17253 if (ports[pid].need_reconfig == 0)
17254 ports[pid].need_reconfig = dev;
17255 /* check if need_reconfig_queues has been set to 1 */
17256 if (ports[pid].need_reconfig_queues == 0)
17257 ports[pid].need_reconfig_queues = queue;
17259 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
17260 /* check if need_reconfig has been set to 1 */
17261 if (ports[id].need_reconfig == 0)
17262 ports[id].need_reconfig = dev;
17263 /* check if need_reconfig_queues has been set to 1 */
17264 if (ports[id].need_reconfig_queues == 0)
17265 ports[id].need_reconfig_queues = queue;