1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2016 Intel Corporation.
3 * Copyright(c) 2014 6WIND S.A.
14 #include <sys/socket.h>
15 #include <netinet/in.h>
17 #include <sys/queue.h>
19 #include <rte_common.h>
20 #include <rte_byteorder.h>
22 #include <rte_debug.h>
23 #include <rte_cycles.h>
24 #include <rte_memory.h>
25 #include <rte_memzone.h>
26 #include <rte_malloc.h>
27 #include <rte_launch.h>
29 #include <rte_per_lcore.h>
30 #include <rte_lcore.h>
31 #include <rte_atomic.h>
32 #include <rte_branch_prediction.h>
34 #include <rte_mempool.h>
35 #include <rte_interrupts.h>
37 #include <rte_ether.h>
38 #include <rte_ethdev.h>
39 #include <rte_string_fns.h>
40 #include <rte_devargs.h>
43 #include <rte_mbuf_dyn.h>
45 #include <cmdline_rdline.h>
46 #include <cmdline_parse.h>
47 #include <cmdline_parse_num.h>
48 #include <cmdline_parse_string.h>
49 #include <cmdline_parse_ipaddr.h>
50 #include <cmdline_parse_etheraddr.h>
51 #include <cmdline_socket.h>
54 #include <rte_eth_bond.h>
55 #include <rte_eth_bond_8023ad.h>
57 #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA
58 #include <rte_pmd_dpaa.h>
61 #include <rte_pmd_ixgbe.h>
64 #include <rte_pmd_i40e.h>
67 #include <rte_pmd_bnxt.h>
70 #include "cmdline_mtr.h"
71 #include "cmdline_tm.h"
74 static struct cmdline *testpmd_cl;
76 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
78 /* *** Help command with introduction. *** */
79 struct cmd_help_brief_result {
80 cmdline_fixed_string_t help;
83 static void cmd_help_brief_parsed(__rte_unused void *parsed_result,
85 __rte_unused void *data)
90 "Help is available for the following sections:\n\n"
91 " help control : Start and stop forwarding.\n"
92 " help display : Displaying port, stats and config "
94 " help config : Configuration information.\n"
95 " help ports : Configuring ports.\n"
96 " help registers : Reading and setting port registers.\n"
97 " help filters : Filters configuration help.\n"
98 " help traffic_management : Traffic Management commands.\n"
99 " help devices : Device related cmds.\n"
100 " help all : All of the above sections.\n\n"
105 cmdline_parse_token_string_t cmd_help_brief_help =
106 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
108 cmdline_parse_inst_t cmd_help_brief = {
109 .f = cmd_help_brief_parsed,
111 .help_str = "help: Show help",
113 (void *)&cmd_help_brief_help,
118 /* *** Help command with help sections. *** */
119 struct cmd_help_long_result {
120 cmdline_fixed_string_t help;
121 cmdline_fixed_string_t section;
124 static void cmd_help_long_parsed(void *parsed_result,
126 __rte_unused void *data)
129 struct cmd_help_long_result *res = parsed_result;
131 if (!strcmp(res->section, "all"))
134 if (show_all || !strcmp(res->section, "control")) {
139 "Control forwarding:\n"
140 "-------------------\n\n"
143 " Start packet forwarding with current configuration.\n\n"
146 " Start packet forwarding with current config"
147 " after sending one burst of packets.\n\n"
150 " Stop packet forwarding, and display accumulated"
154 " Quit to prompt.\n\n"
158 if (show_all || !strcmp(res->section, "display")) {
166 "show port (info|stats|summary|xstats|fdir|dcb_tc) (port_id|all)\n"
167 " Display information for port_id, or all.\n\n"
169 "show port port_id (module_eeprom|eeprom)\n"
170 " Display the module EEPROM or EEPROM information for port_id.\n\n"
172 "show port X rss reta (size) (mask0,mask1,...)\n"
173 " Display the rss redirection table entry indicated"
174 " by masks on port X. size is used to indicate the"
175 " hardware supported reta size\n\n"
177 "show port (port_id) rss-hash [key]\n"
178 " Display the RSS hash functions and RSS hash key of port\n\n"
180 "clear port (info|stats|xstats|fdir) (port_id|all)\n"
181 " Clear information for port_id, or all.\n\n"
183 "show (rxq|txq) info (port_id) (queue_id)\n"
184 " Display information for configured RX/TX queue.\n\n"
186 "show config (rxtx|cores|fwd|rxoffs|rxpkts|txpkts)\n"
187 " Display the given configuration.\n\n"
189 "read rxd (port_id) (queue_id) (rxd_id)\n"
190 " Display an RX descriptor of a port RX queue.\n\n"
192 "read txd (port_id) (queue_id) (txd_id)\n"
193 " Display a TX descriptor of a port TX queue.\n\n"
195 "ddp get list (port_id)\n"
196 " Get ddp profile info list\n\n"
198 "ddp get info (profile_path)\n"
199 " Get ddp profile information.\n\n"
201 "show vf stats (port_id) (vf_id)\n"
202 " Display a VF's statistics.\n\n"
204 "clear vf stats (port_id) (vf_id)\n"
205 " Reset a VF's statistics.\n\n"
207 "show port (port_id) pctype mapping\n"
208 " Get flow ptype to pctype mapping on a port\n\n"
210 "show port meter stats (port_id) (meter_id) (clear)\n"
211 " Get meter stats on a port\n\n"
213 "show fwd stats all\n"
214 " Display statistics for all fwd engines.\n\n"
216 "clear fwd stats all\n"
217 " Clear statistics for all fwd engines.\n\n"
219 "show port (port_id) rx_offload capabilities\n"
220 " List all per queue and per port Rx offloading"
221 " capabilities of a port\n\n"
223 "show port (port_id) rx_offload configuration\n"
224 " List port level and all queue level"
225 " Rx offloading configuration\n\n"
227 "show port (port_id) tx_offload capabilities\n"
228 " List all per queue and per port"
229 " Tx offloading capabilities of a port\n\n"
231 "show port (port_id) tx_offload configuration\n"
232 " List port level and all queue level"
233 " Tx offloading configuration\n\n"
235 "show port (port_id) tx_metadata\n"
236 " Show Tx metadata value set"
237 " for a specific port\n\n"
239 "show port (port_id) ptypes\n"
240 " Show port supported ptypes"
241 " for a specific port\n\n"
243 "show device info (<identifier>|all)"
244 " Show general information about devices probed.\n\n"
246 "show port (port_id) rxq|txq (queue_id) desc (desc_id) status"
247 " Show status of rx|tx descriptor.\n\n"
249 "show port (port_id) rxq (queue_id) desc used count\n"
250 " Show current number of filled receive"
251 " packet descriptors.\n\n"
253 "show port (port_id) macs|mcast_macs"
254 " Display list of mac addresses added to port.\n\n"
256 "show port (port_id) fec capabilities"
257 " Show fec capabilities of a port.\n\n"
259 "show port (port_id) fec_mode"
260 " Show fec mode of a port.\n\n"
264 if (show_all || !strcmp(res->section, "config")) {
270 "Configuration changes only become active when"
271 " forwarding is started/restarted.\n\n"
274 " Reset forwarding to the default configuration.\n\n"
276 "set verbose (level)\n"
277 " Set the debug verbosity level X.\n\n"
279 "set log global|(type) (level)\n"
280 " Set the log level.\n\n"
283 " Set number of ports.\n\n"
286 " Set number of cores.\n\n"
288 "set coremask (mask)\n"
289 " Set the forwarding cores hexadecimal mask.\n\n"
291 "set portmask (mask)\n"
292 " Set the forwarding ports hexadecimal mask.\n\n"
295 " Set number of packets per burst.\n\n"
297 "set burst tx delay (microseconds) retry (num)\n"
298 " Set the transmit delay time and number of retries,"
299 " effective when retry is enabled.\n\n"
301 "set rxoffs (x[,y]*)\n"
302 " Set the offset of each packet segment on"
303 " receiving if split feature is engaged."
304 " Affects only the queues configured with split"
307 "set rxpkts (x[,y]*)\n"
308 " Set the length of each segment to scatter"
309 " packets on receiving if split feature is engaged."
310 " Affects only the queues configured with split"
313 "set txpkts (x[,y]*)\n"
314 " Set the length of each segment of TXONLY"
315 " and optionally CSUM packets.\n\n"
317 "set txsplit (off|on|rand)\n"
318 " Set the split policy for the TX packets."
319 " Right now only applicable for CSUM and TXONLY"
322 "set txtimes (x, y)\n"
323 " Set the scheduling on timestamps"
324 " timings for the TXONLY mode\n\n"
326 "set corelist (x[,y]*)\n"
327 " Set the list of forwarding cores.\n\n"
329 "set portlist (x[,y]*)\n"
330 " Set the list of forwarding ports.\n\n"
332 "set port setup on (iterator|event)\n"
333 " Select how attached port is retrieved for setup.\n\n"
335 "set tx loopback (port_id) (on|off)\n"
336 " Enable or disable tx loopback.\n\n"
338 "set all queues drop (port_id) (on|off)\n"
339 " Set drop enable bit for all queues.\n\n"
341 "set vf split drop (port_id) (vf_id) (on|off)\n"
342 " Set split drop enable bit for a VF from the PF.\n\n"
344 "set vf mac antispoof (port_id) (vf_id) (on|off).\n"
345 " Set MAC antispoof for a VF from the PF.\n\n"
347 "set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n"
348 " Enable MACsec offload.\n\n"
350 "set macsec offload (port_id) off\n"
351 " Disable MACsec offload.\n\n"
353 "set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
354 " Configure MACsec secure connection (SC).\n\n"
356 "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n"
357 " Configure MACsec secure association (SA).\n\n"
359 "set vf broadcast (port_id) (vf_id) (on|off)\n"
360 " Set VF broadcast for a VF from the PF.\n\n"
362 "vlan set stripq (on|off) (port_id,queue_id)\n"
363 " Set the VLAN strip for a queue on a port.\n\n"
365 "set vf vlan stripq (port_id) (vf_id) (on|off)\n"
366 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
368 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
369 " Set VLAN insert for a VF from the PF.\n\n"
371 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
372 " Set VLAN antispoof for a VF from the PF.\n\n"
374 "set vf vlan tag (port_id) (vf_id) (on|off)\n"
375 " Set VLAN tag for a VF from the PF.\n\n"
377 "set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n"
378 " Set a VF's max bandwidth(Mbps).\n\n"
380 "set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n"
381 " Set all TCs' min bandwidth(%%) on a VF.\n\n"
383 "set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n"
384 " Set a TC's max bandwidth(Mbps) on a VF.\n\n"
386 "set tx strict-link-priority (port_id) (tc_bitmap)\n"
387 " Set some TCs' strict link priority mode on a physical port.\n\n"
389 "set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n"
390 " Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n"
392 "vlan set (strip|filter|qinq_strip|extend) (on|off) (port_id)\n"
393 " Set the VLAN strip or filter or qinq strip or extend\n\n"
395 "vlan set (inner|outer) tpid (value) (port_id)\n"
396 " Set the VLAN TPID for Packet Filtering on"
399 "rx_vlan add (vlan_id|all) (port_id)\n"
400 " Add a vlan_id, or all identifiers, to the set"
401 " of VLAN identifiers filtered by port_id.\n\n"
403 "rx_vlan rm (vlan_id|all) (port_id)\n"
404 " Remove a vlan_id, or all identifiers, from the set"
405 " of VLAN identifiers filtered by port_id.\n\n"
407 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
408 " Add a vlan_id, to the set of VLAN identifiers"
409 "filtered for VF(s) from port_id.\n\n"
411 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
412 " Remove a vlan_id, to the set of VLAN identifiers"
413 "filtered for VF(s) from port_id.\n\n"
415 "rx_vxlan_port add (udp_port) (port_id)\n"
416 " Add an UDP port for VXLAN packet filter on a port\n\n"
418 "rx_vxlan_port rm (udp_port) (port_id)\n"
419 " Remove an UDP port for VXLAN packet filter on a port\n\n"
421 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
422 " Set hardware insertion of VLAN IDs (single or double VLAN "
423 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
425 "tx_vlan set pvid port_id vlan_id (on|off)\n"
426 " Set port based TX VLAN insertion.\n\n"
428 "tx_vlan reset (port_id)\n"
429 " Disable hardware insertion of a VLAN header in"
430 " packets sent on a port.\n\n"
432 "csum set (ip|udp|tcp|sctp|outer-ip|outer-udp) (hw|sw) (port_id)\n"
433 " Select hardware or software calculation of the"
434 " checksum when transmitting a packet using the"
435 " csum forward engine.\n"
436 " ip|udp|tcp|sctp always concern the inner layer.\n"
437 " outer-ip concerns the outer IP layer in"
438 " outer-udp concerns the outer UDP layer in"
439 " case the packet is recognized as a tunnel packet by"
440 " the forward engine (vxlan, gre and ipip are supported)\n"
441 " Please check the NIC datasheet for HW limits.\n\n"
443 "csum parse-tunnel (on|off) (tx_port_id)\n"
444 " If disabled, treat tunnel packets as non-tunneled"
445 " packets (treat inner headers as payload). The port\n"
446 " argument is the port used for TX in csum forward"
449 "csum show (port_id)\n"
450 " Display tx checksum offload configuration\n\n"
452 "tso set (segsize) (portid)\n"
453 " Enable TCP Segmentation Offload in csum forward"
455 " Please check the NIC datasheet for HW limits.\n\n"
458 " Display the status of TCP Segmentation Offload.\n\n"
460 "set port (port_id) gro on|off\n"
461 " Enable or disable Generic Receive Offload in"
462 " csum forwarding engine.\n\n"
464 "show port (port_id) gro\n"
465 " Display GRO configuration.\n\n"
467 "set gro flush (cycles)\n"
468 " Set the cycle to flush GROed packets from"
469 " reassembly tables.\n\n"
471 "set port (port_id) gso (on|off)"
472 " Enable or disable Generic Segmentation Offload in"
473 " csum forwarding engine.\n\n"
475 "set gso segsz (length)\n"
476 " Set max packet length for output GSO segments,"
477 " including packet header and payload.\n\n"
479 "show port (port_id) gso\n"
480 " Show GSO configuration.\n\n"
483 " Set packet forwarding mode.\n\n"
485 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
486 " Add a MAC address on port_id.\n\n"
488 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
489 " Remove a MAC address from port_id.\n\n"
491 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
492 " Set the default MAC address for port_id.\n\n"
494 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
495 " Add a MAC address for a VF on the port.\n\n"
497 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
498 " Set the MAC address for a VF from the PF.\n\n"
500 "set eth-peer (port_id) (peer_addr)\n"
501 " set the peer address for certain port.\n\n"
503 "set port (port_id) uta (mac_address|all) (on|off)\n"
504 " Add/Remove a or all unicast hash filter(s)"
507 "set promisc (port_id|all) (on|off)\n"
508 " Set the promiscuous mode on port_id, or all.\n\n"
510 "set allmulti (port_id|all) (on|off)\n"
511 " Set the allmulti mode on port_id, or all.\n\n"
513 "set vf promisc (port_id) (vf_id) (on|off)\n"
514 " Set unicast promiscuous mode for a VF from the PF.\n\n"
516 "set vf allmulti (port_id) (vf_id) (on|off)\n"
517 " Set multicast promiscuous mode for a VF from the PF.\n\n"
519 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
520 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
521 " (on|off) autoneg (on|off) (port_id)\n"
522 "set flow_ctrl rx (on|off) (portid)\n"
523 "set flow_ctrl tx (on|off) (portid)\n"
524 "set flow_ctrl high_water (high_water) (portid)\n"
525 "set flow_ctrl low_water (low_water) (portid)\n"
526 "set flow_ctrl pause_time (pause_time) (portid)\n"
527 "set flow_ctrl send_xon (send_xon) (portid)\n"
528 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
529 "set flow_ctrl autoneg (on|off) (port_id)\n"
530 " Set the link flow control parameter on a port.\n\n"
532 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
533 " (low_water) (pause_time) (priority) (port_id)\n"
534 " Set the priority flow control parameter on a"
537 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
538 " Set statistics mapping (qmapping 0..15) for RX/TX"
540 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
541 " on port 0 to mapping 5.\n\n"
543 "set xstats-hide-zero on|off\n"
544 " Set the option to hide the zero values"
545 " for xstats display.\n"
547 "set record-core-cycles on|off\n"
548 " Set the option to enable measurement of CPU cycles.\n"
550 "set record-burst-stats on|off\n"
551 " Set the option to enable display of RX and TX bursts.\n"
553 "set port (port_id) vf (vf_id) rx|tx on|off\n"
554 " Enable/Disable a VF receive/tranmit from a port\n\n"
556 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
558 " AUPE:accepts untagged VLAN;"
559 "ROPE:accept unicast hash\n\n"
560 " BAM:accepts broadcast packets;"
561 "MPE:accepts all multicast packets\n\n"
562 " Enable/Disable a VF receive mode of a port\n\n"
564 "set port (port_id) queue (queue_id) rate (rate_num)\n"
565 " Set rate limit for a queue of a port\n\n"
567 "set port (port_id) vf (vf_id) rate (rate_num) "
568 "queue_mask (queue_mask_value)\n"
569 " Set rate limit for queues in VF of a port\n\n"
571 "set port (port_id) mirror-rule (rule_id)"
572 " (pool-mirror-up|pool-mirror-down|vlan-mirror)"
573 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
574 " Set pool or vlan type mirror rule on a port.\n"
575 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
576 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
579 "set port (port_id) mirror-rule (rule_id)"
580 " (uplink-mirror|downlink-mirror) dst-pool"
581 " (pool_id) (on|off)\n"
582 " Set uplink or downlink type mirror rule on a port.\n"
583 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
584 " 0 on' enable mirror income traffic to pool 0.\n\n"
586 "reset port (port_id) mirror-rule (rule_id)\n"
587 " Reset a mirror rule.\n\n"
589 "set flush_rx (on|off)\n"
590 " Flush (default) or don't flush RX streams before"
591 " forwarding. Mainly used with PCAP drivers.\n\n"
593 "set bypass mode (normal|bypass|isolate) (port_id)\n"
594 " Set the bypass mode for the lowest port on bypass enabled"
597 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
598 "mode (normal|bypass|isolate) (port_id)\n"
599 " Set the event required to initiate specified bypass mode for"
600 " the lowest port on a bypass enabled NIC where:\n"
601 " timeout = enable bypass after watchdog timeout.\n"
602 " os_on = enable bypass when OS/board is powered on.\n"
603 " os_off = enable bypass when OS/board is powered off.\n"
604 " power_on = enable bypass when power supply is turned on.\n"
605 " power_off = enable bypass when power supply is turned off."
608 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
609 " Set the bypass watchdog timeout to 'n' seconds"
610 " where 0 = instant.\n\n"
612 "show bypass config (port_id)\n"
613 " Show the bypass configuration for a bypass enabled NIC"
614 " using the lowest port on the NIC.\n\n"
617 "create bonded device (mode) (socket)\n"
618 " Create a new bonded device with specific bonding mode and socket.\n\n"
620 "add bonding slave (slave_id) (port_id)\n"
621 " Add a slave device to a bonded device.\n\n"
623 "remove bonding slave (slave_id) (port_id)\n"
624 " Remove a slave device from a bonded device.\n\n"
626 "set bonding mode (value) (port_id)\n"
627 " Set the bonding mode on a bonded device.\n\n"
629 "set bonding primary (slave_id) (port_id)\n"
630 " Set the primary slave for a bonded device.\n\n"
632 "show bonding config (port_id)\n"
633 " Show the bonding config for port_id.\n\n"
635 "set bonding mac_addr (port_id) (address)\n"
636 " Set the MAC address of a bonded device.\n\n"
638 "set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)"
639 " Set Aggregation mode for IEEE802.3AD (mode 4)"
641 "set bonding balance_xmit_policy (port_id) (l2|l23|l34)\n"
642 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
644 "set bonding mon_period (port_id) (value)\n"
645 " Set the bonding link status monitoring polling period in ms.\n\n"
647 "set bonding lacp dedicated_queues <port_id> (enable|disable)\n"
648 " Enable/disable dedicated queues for LACP control traffic.\n\n"
651 "set link-up port (port_id)\n"
652 " Set link up for a port.\n\n"
654 "set link-down port (port_id)\n"
655 " Set link down for a port.\n\n"
657 "ddp add (port_id) (profile_path[,backup_profile_path])\n"
658 " Load a profile package on a port\n\n"
660 "ddp del (port_id) (backup_profile_path)\n"
661 " Delete a profile package from a port\n\n"
663 "ptype mapping get (port_id) (valid_only)\n"
664 " Get ptype mapping on a port\n\n"
666 "ptype mapping replace (port_id) (target) (mask) (pky_type)\n"
667 " Replace target with the pkt_type in ptype mapping\n\n"
669 "ptype mapping reset (port_id)\n"
670 " Reset ptype mapping on a port\n\n"
672 "ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n"
673 " Update a ptype mapping item on a port\n\n"
675 "set port (port_id) ptype_mask (ptype_mask)\n"
676 " set packet types classification for a specific port\n\n"
678 "set port (port_id) queue-region region_id (value) "
679 "queue_start_index (value) queue_num (value)\n"
680 " Set a queue region on a port\n\n"
682 "set port (port_id) queue-region region_id (value) "
684 " Set a flowtype region index on a port\n\n"
686 "set port (port_id) queue-region UP (value) region_id (value)\n"
687 " Set the mapping of User Priority to "
688 "queue region on a port\n\n"
690 "set port (port_id) queue-region flush (on|off)\n"
691 " flush all queue region related configuration\n\n"
693 "show port meter cap (port_id)\n"
694 " Show port meter capability information\n\n"
696 "add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs) (packet_mode)\n"
697 " meter profile add - srtcm rfc 2697\n\n"
699 "add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs) (packet_mode)\n"
700 " meter profile add - trtcm rfc 2698\n\n"
702 "add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs) (packet_mode)\n"
703 " meter profile add - trtcm rfc 4115\n\n"
705 "del port meter profile (port_id) (profile_id)\n"
706 " meter profile delete\n\n"
708 "create port meter (port_id) (mtr_id) (profile_id) (policy_id) (meter_enable)\n"
709 "(stats_mask) (shared) (use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n"
710 "(dscp_tbl_entry63)]\n"
713 "enable port meter (port_id) (mtr_id)\n"
716 "disable port meter (port_id) (mtr_id)\n"
719 "del port meter (port_id) (mtr_id)\n"
722 "add port meter policy (port_id) (policy_id) g_actions (actions)\n"
723 "y_actions (actions) r_actions (actions)\n"
724 " meter policy add\n\n"
726 "del port meter policy (port_id) (policy_id)\n"
727 " meter policy delete\n\n"
729 "set port meter profile (port_id) (mtr_id) (profile_id)\n"
730 " meter update meter profile\n\n"
732 "set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n"
733 "(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n"
734 " update meter dscp table entries\n\n"
736 "set port meter policer action (port_id) (mtr_id) (action_mask)\n"
737 "(action0) [(action1) (action2)]\n"
738 " meter update policer action\n\n"
740 "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
741 " meter update stats\n\n"
743 "show port (port_id) queue-region\n"
744 " show all queue region related configuration info\n\n"
746 "set port (port_id) fec_mode auto|off|rs|baser\n"
747 " set fec mode for a specific port\n\n"
749 , list_pkt_forwarding_modes()
753 if (show_all || !strcmp(res->section, "ports")) {
759 "----------------\n\n"
761 "port start (port_id|all)\n"
762 " Start all ports or port_id.\n\n"
764 "port stop (port_id|all)\n"
765 " Stop all ports or port_id.\n\n"
767 "port close (port_id|all)\n"
768 " Close all ports or port_id.\n\n"
770 "port reset (port_id|all)\n"
771 " Reset all ports or port_id.\n\n"
773 "port attach (ident)\n"
774 " Attach physical or virtual dev by pci address or virtual device name\n\n"
776 "port detach (port_id)\n"
777 " Detach physical or virtual dev by port_id\n\n"
779 "port config (port_id|all)"
780 " speed (10|100|1000|10000|25000|40000|50000|100000|200000|auto)"
781 " duplex (half|full|auto)\n"
782 " Set speed and duplex for all ports or port_id\n\n"
784 "port config (port_id|all) loopback (mode)\n"
785 " Set loopback mode for all ports or port_id\n\n"
787 "port config all (rxq|txq|rxd|txd) (value)\n"
788 " Set number for rxq/txq/rxd/txd.\n\n"
790 "port config all max-pkt-len (value)\n"
791 " Set the max packet length.\n\n"
793 "port config all max-lro-pkt-size (value)\n"
794 " Set the max LRO aggregated packet size.\n\n"
796 "port config all drop-en (on|off)\n"
797 " Enable or disable packet drop on all RX queues of all ports when no "
798 "receive buffers available.\n\n"
800 "port config all rss (all|default|ip|tcp|udp|sctp|"
801 "ether|port|vxlan|geneve|nvgre|vxlan-gpe|ecpri|mpls|none|level-default|"
802 "level-outer|level-inner|<flowtype_id>)\n"
803 " Set the RSS mode.\n\n"
805 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
806 " Set the RSS redirection table.\n\n"
808 "port config (port_id) dcb vt (on|off) (traffic_class)"
810 " Set the DCB mode.\n\n"
812 "port config all burst (value)\n"
813 " Set the number of packets per burst.\n\n"
815 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
817 " Set the ring prefetch/host/writeback threshold"
818 " for tx/rx queue.\n\n"
820 "port config all (txfreet|txrst|rxfreet) (value)\n"
821 " Set free threshold for rx/tx, or set"
822 " tx rs bit threshold.\n\n"
823 "port config mtu X value\n"
824 " Set the MTU of port X to a given value\n\n"
826 "port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n"
827 " Set a rx/tx queue's ring size configuration, the new"
828 " value will take effect after command that (re-)start the port"
829 " or command that setup the specific queue\n\n"
831 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
832 " Start/stop a rx/tx queue of port X. Only take effect"
833 " when port X is started\n\n"
835 "port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n"
836 " Switch on/off a deferred start of port X rx/tx queue. Only"
837 " take effect when port X is stopped.\n\n"
839 "port (port_id) (rxq|txq) (queue_id) setup\n"
840 " Setup a rx/tx queue of port X.\n\n"
842 "port config (port_id) pctype mapping reset\n"
843 " Reset flow type to pctype mapping on a port\n\n"
845 "port config (port_id) pctype mapping update"
846 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
847 " Update a flow type to pctype mapping item on a port\n\n"
849 "port config (port_id) pctype (pctype_id) hash_inset|"
850 "fdir_inset|fdir_flx_inset get|set|clear field\n"
852 " Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n"
854 "port config (port_id) pctype (pctype_id) hash_inset|"
855 "fdir_inset|fdir_flx_inset clear all"
856 " Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n"
858 "port config (port_id) udp_tunnel_port add|rm vxlan|geneve|ecpri (udp_port)\n\n"
859 " Add/remove UDP tunnel port for tunneling offload\n\n"
861 "port config <port_id> rx_offload vlan_strip|"
862 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
863 "outer_ipv4_cksum|macsec_strip|header_split|"
864 "vlan_filter|vlan_extend|jumbo_frame|scatter|"
865 "buffer_split|timestamp|security|keep_crc on|off\n"
866 " Enable or disable a per port Rx offloading"
867 " on all Rx queues of a port\n\n"
869 "port (port_id) rxq (queue_id) rx_offload vlan_strip|"
870 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
871 "outer_ipv4_cksum|macsec_strip|header_split|"
872 "vlan_filter|vlan_extend|jumbo_frame|scatter|"
873 "buffer_split|timestamp|security|keep_crc on|off\n"
874 " Enable or disable a per queue Rx offloading"
875 " only on a specific Rx queue\n\n"
877 "port config (port_id) tx_offload vlan_insert|"
878 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
879 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
880 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|"
881 "macsec_insert|mt_lockfree|multi_segs|mbuf_fast_free|"
883 " Enable or disable a per port Tx offloading"
884 " on all Tx queues of a port\n\n"
886 "port (port_id) txq (queue_id) tx_offload vlan_insert|"
887 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
888 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
889 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|macsec_insert"
890 "|mt_lockfree|multi_segs|mbuf_fast_free|security"
892 " Enable or disable a per queue Tx offloading"
893 " only on a specific Tx queue\n\n"
895 "bpf-load rx|tx (port) (queue) (J|M|B) (file_name)\n"
896 " Load an eBPF program as a callback"
897 " for particular RX/TX queue\n\n"
899 "bpf-unload rx|tx (port) (queue)\n"
900 " Unload previously loaded eBPF program"
901 " for particular RX/TX queue\n\n"
903 "port config (port_id) tx_metadata (value)\n"
904 " Set Tx metadata value per port. Testpmd will add this value"
905 " to any Tx packet sent from this port\n\n"
907 "port config (port_id) dynf (name) set|clear\n"
908 " Register a dynf and Set/clear this flag on Tx. "
909 "Testpmd will set this value to any Tx packet "
910 "sent from this port\n\n"
912 "port cleanup (port_id) txq (queue_id) (free_cnt)\n"
913 " Cleanup txq mbufs for a specific Tx queue\n\n"
917 if (show_all || !strcmp(res->section, "registers")) {
925 "read reg (port_id) (address)\n"
926 " Display value of a port register.\n\n"
928 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
929 " Display a port register bit field.\n\n"
931 "read regbit (port_id) (address) (bit_x)\n"
932 " Display a single port register bit.\n\n"
934 "write reg (port_id) (address) (value)\n"
935 " Set value of a port register.\n\n"
937 "write regfield (port_id) (address) (bit_x) (bit_y)"
939 " Set bit field of a port register.\n\n"
941 "write regbit (port_id) (address) (bit_x) (value)\n"
942 " Set single bit value of a port register.\n\n"
945 if (show_all || !strcmp(res->section, "filters")) {
954 "flow_director_filter (port_id) mode raw (add|del|update)"
955 " flow (flow_id) (drop|fwd) queue (queue_id)"
956 " fd_id (fd_id_value) packet (packet file name)\n"
957 " Add/Del a raw type flow director filter.\n\n"
960 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
961 " src_mask (ipv4_src) (ipv6_src) (src_port)"
962 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
963 " Set flow director IP mask.\n\n"
965 "flow_director_mask (port_id) mode MAC-VLAN"
966 " vlan (vlan_value)\n"
967 " Set flow director MAC-VLAN mask.\n\n"
969 "flow_director_mask (port_id) mode Tunnel"
970 " vlan (vlan_value) mac (mac_value)"
971 " tunnel-type (tunnel_type_value)"
972 " tunnel-id (tunnel_id_value)\n"
973 " Set flow director Tunnel mask.\n\n"
975 "flow_director_flex_payload (port_id)"
976 " (raw|l2|l3|l4) (config)\n"
977 " Configure flex payload selection.\n\n"
979 "flow validate {port_id}"
980 " [group {group_id}] [priority {level}]"
981 " [ingress] [egress]"
982 " pattern {item} [/ {item} [...]] / end"
983 " actions {action} [/ {action} [...]] / end\n"
984 " Check whether a flow rule can be created.\n\n"
986 "flow create {port_id}"
987 " [group {group_id}] [priority {level}]"
988 " [ingress] [egress]"
989 " pattern {item} [/ {item} [...]] / end"
990 " actions {action} [/ {action} [...]] / end\n"
991 " Create a flow rule.\n\n"
993 "flow destroy {port_id} rule {rule_id} [...]\n"
994 " Destroy specific flow rules.\n\n"
996 "flow flush {port_id}\n"
997 " Destroy all flow rules.\n\n"
999 "flow query {port_id} {rule_id} {action}\n"
1000 " Query an existing flow rule.\n\n"
1002 "flow list {port_id} [group {group_id}] [...]\n"
1003 " List existing flow rules sorted by priority,"
1004 " filtered by group identifiers.\n\n"
1006 "flow isolate {port_id} {boolean}\n"
1007 " Restrict ingress traffic to the defined"
1010 "flow aged {port_id} [destroy]\n"
1011 " List and destroy aged flows"
1014 "flow indirect_action {port_id} create"
1015 " [action_id {indirect_action_id}]"
1016 " [ingress] [egress]"
1017 " action {action} / end\n"
1018 " Create indirect action.\n\n"
1020 "flow indirect_action {port_id} update"
1021 " {indirect_action_id} action {action} / end\n"
1022 " Update indirect action.\n\n"
1024 "flow indirect_action {port_id} destroy"
1025 " action_id {indirect_action_id} [...]\n"
1026 " Destroy specific indirect actions.\n\n"
1028 "flow indirect_action {port_id} query"
1029 " {indirect_action_id}\n"
1030 " Query an existing indirect action.\n\n"
1032 "set vxlan ip-version (ipv4|ipv6) vni (vni) udp-src"
1033 " (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst"
1034 " (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n"
1035 " Configure the VXLAN encapsulation for flows.\n\n"
1037 "set vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)"
1038 " udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)"
1039 " ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)"
1040 " eth-dst (eth-dst)\n"
1041 " Configure the VXLAN encapsulation for flows.\n\n"
1043 "set vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src"
1044 " (udp-src) udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl)"
1045 " ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src)"
1046 " eth-dst (eth-dst)\n"
1047 " Configure the VXLAN encapsulation for flows.\n\n"
1049 "set nvgre ip-version (ipv4|ipv6) tni (tni) ip-src"
1050 " (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst"
1052 " Configure the NVGRE encapsulation for flows.\n\n"
1054 "set nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)"
1055 " ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)"
1056 " eth-src (eth-src) eth-dst (eth-dst)\n"
1057 " Configure the NVGRE encapsulation for flows.\n\n"
1059 "set raw_encap {flow items}\n"
1060 " Configure the encapsulation with raw data.\n\n"
1062 "set raw_decap {flow items}\n"
1063 " Configure the decapsulation with raw data.\n\n"
1068 if (show_all || !strcmp(res->section, "traffic_management")) {
1072 "Traffic Management:\n"
1074 "show port tm cap (port_id)\n"
1075 " Display the port TM capability.\n\n"
1077 "show port tm level cap (port_id) (level_id)\n"
1078 " Display the port TM hierarchical level capability.\n\n"
1080 "show port tm node cap (port_id) (node_id)\n"
1081 " Display the port TM node capability.\n\n"
1083 "show port tm node type (port_id) (node_id)\n"
1084 " Display the port TM node type.\n\n"
1086 "show port tm node stats (port_id) (node_id) (clear)\n"
1087 " Display the port TM node stats.\n\n"
1089 "add port tm node shaper profile (port_id) (shaper_profile_id)"
1090 " (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)"
1091 " (packet_length_adjust) (packet_mode)\n"
1092 " Add port tm node private shaper profile.\n\n"
1094 "del port tm node shaper profile (port_id) (shaper_profile_id)\n"
1095 " Delete port tm node private shaper profile.\n\n"
1097 "add port tm node shared shaper (port_id) (shared_shaper_id)"
1098 " (shaper_profile_id)\n"
1099 " Add/update port tm node shared shaper.\n\n"
1101 "del port tm node shared shaper (port_id) (shared_shaper_id)\n"
1102 " Delete port tm node shared shaper.\n\n"
1104 "set port tm node shaper profile (port_id) (node_id)"
1105 " (shaper_profile_id)\n"
1106 " Set port tm node shaper profile.\n\n"
1108 "add port tm node wred profile (port_id) (wred_profile_id)"
1109 " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
1110 " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
1111 " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
1112 " Add port tm node wred profile.\n\n"
1114 "del port tm node wred profile (port_id) (wred_profile_id)\n"
1115 " Delete port tm node wred profile.\n\n"
1117 "add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
1118 " (priority) (weight) (level_id) (shaper_profile_id)"
1119 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1120 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1121 " Add port tm nonleaf node.\n\n"
1123 "add port tm nonleaf node pktmode (port_id) (node_id) (parent_node_id)"
1124 " (priority) (weight) (level_id) (shaper_profile_id)"
1125 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1126 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1127 " Add port tm nonleaf node with pkt mode enabled.\n\n"
1129 "add port tm leaf node (port_id) (node_id) (parent_node_id)"
1130 " (priority) (weight) (level_id) (shaper_profile_id)"
1131 " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
1132 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1133 " Add port tm leaf node.\n\n"
1135 "del port tm node (port_id) (node_id)\n"
1136 " Delete port tm node.\n\n"
1138 "set port tm node parent (port_id) (node_id) (parent_node_id)"
1139 " (priority) (weight)\n"
1140 " Set port tm node parent.\n\n"
1142 "suspend port tm node (port_id) (node_id)"
1143 " Suspend tm node.\n\n"
1145 "resume port tm node (port_id) (node_id)"
1146 " Resume tm node.\n\n"
1148 "port tm hierarchy commit (port_id) (clean_on_fail)\n"
1149 " Commit tm hierarchy.\n\n"
1151 "set port tm mark ip_ecn (port) (green) (yellow)"
1153 " Enables/Disables the traffic management marking"
1154 " for IP ECN (Explicit Congestion Notification)"
1155 " packets on a given port\n\n"
1157 "set port tm mark ip_dscp (port) (green) (yellow)"
1159 " Enables/Disables the traffic management marking"
1160 " on the port for IP dscp packets\n\n"
1162 "set port tm mark vlan_dei (port) (green) (yellow)"
1164 " Enables/Disables the traffic management marking"
1165 " on the port for VLAN packets with DEI enabled\n\n"
1169 if (show_all || !strcmp(res->section, "devices")) {
1173 "Device Operations:\n"
1175 "device detach (identifier)\n"
1176 " Detach device by identifier.\n\n"
1182 cmdline_parse_token_string_t cmd_help_long_help =
1183 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1185 cmdline_parse_token_string_t cmd_help_long_section =
1186 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1187 "all#control#display#config#"
1188 "ports#registers#filters#traffic_management#devices");
1190 cmdline_parse_inst_t cmd_help_long = {
1191 .f = cmd_help_long_parsed,
1193 .help_str = "help all|control|display|config|ports|register|"
1194 "filters|traffic_management|devices: "
1197 (void *)&cmd_help_long_help,
1198 (void *)&cmd_help_long_section,
1204 /* *** start/stop/close all ports *** */
1205 struct cmd_operate_port_result {
1206 cmdline_fixed_string_t keyword;
1207 cmdline_fixed_string_t name;
1208 cmdline_fixed_string_t value;
1211 static void cmd_operate_port_parsed(void *parsed_result,
1212 __rte_unused struct cmdline *cl,
1213 __rte_unused void *data)
1215 struct cmd_operate_port_result *res = parsed_result;
1217 if (!strcmp(res->name, "start"))
1218 start_port(RTE_PORT_ALL);
1219 else if (!strcmp(res->name, "stop"))
1220 stop_port(RTE_PORT_ALL);
1221 else if (!strcmp(res->name, "close"))
1222 close_port(RTE_PORT_ALL);
1223 else if (!strcmp(res->name, "reset"))
1224 reset_port(RTE_PORT_ALL);
1226 printf("Unknown parameter\n");
1229 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1230 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1232 cmdline_parse_token_string_t cmd_operate_port_all_port =
1233 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1234 "start#stop#close#reset");
1235 cmdline_parse_token_string_t cmd_operate_port_all_all =
1236 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1238 cmdline_parse_inst_t cmd_operate_port = {
1239 .f = cmd_operate_port_parsed,
1241 .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports",
1243 (void *)&cmd_operate_port_all_cmd,
1244 (void *)&cmd_operate_port_all_port,
1245 (void *)&cmd_operate_port_all_all,
1250 /* *** start/stop/close specific port *** */
1251 struct cmd_operate_specific_port_result {
1252 cmdline_fixed_string_t keyword;
1253 cmdline_fixed_string_t name;
1257 static void cmd_operate_specific_port_parsed(void *parsed_result,
1258 __rte_unused struct cmdline *cl,
1259 __rte_unused void *data)
1261 struct cmd_operate_specific_port_result *res = parsed_result;
1263 if (!strcmp(res->name, "start"))
1264 start_port(res->value);
1265 else if (!strcmp(res->name, "stop"))
1266 stop_port(res->value);
1267 else if (!strcmp(res->name, "close"))
1268 close_port(res->value);
1269 else if (!strcmp(res->name, "reset"))
1270 reset_port(res->value);
1272 printf("Unknown parameter\n");
1275 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1276 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1278 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1279 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1280 name, "start#stop#close#reset");
1281 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1282 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1285 cmdline_parse_inst_t cmd_operate_specific_port = {
1286 .f = cmd_operate_specific_port_parsed,
1288 .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id",
1290 (void *)&cmd_operate_specific_port_cmd,
1291 (void *)&cmd_operate_specific_port_port,
1292 (void *)&cmd_operate_specific_port_id,
1297 /* *** enable port setup (after attach) via iterator or event *** */
1298 struct cmd_set_port_setup_on_result {
1299 cmdline_fixed_string_t set;
1300 cmdline_fixed_string_t port;
1301 cmdline_fixed_string_t setup;
1302 cmdline_fixed_string_t on;
1303 cmdline_fixed_string_t mode;
1306 static void cmd_set_port_setup_on_parsed(void *parsed_result,
1307 __rte_unused struct cmdline *cl,
1308 __rte_unused void *data)
1310 struct cmd_set_port_setup_on_result *res = parsed_result;
1312 if (strcmp(res->mode, "event") == 0)
1313 setup_on_probe_event = true;
1314 else if (strcmp(res->mode, "iterator") == 0)
1315 setup_on_probe_event = false;
1317 printf("Unknown mode\n");
1320 cmdline_parse_token_string_t cmd_set_port_setup_on_set =
1321 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1323 cmdline_parse_token_string_t cmd_set_port_setup_on_port =
1324 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1326 cmdline_parse_token_string_t cmd_set_port_setup_on_setup =
1327 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1329 cmdline_parse_token_string_t cmd_set_port_setup_on_on =
1330 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1332 cmdline_parse_token_string_t cmd_set_port_setup_on_mode =
1333 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1334 mode, "iterator#event");
1336 cmdline_parse_inst_t cmd_set_port_setup_on = {
1337 .f = cmd_set_port_setup_on_parsed,
1339 .help_str = "set port setup on iterator|event",
1341 (void *)&cmd_set_port_setup_on_set,
1342 (void *)&cmd_set_port_setup_on_port,
1343 (void *)&cmd_set_port_setup_on_setup,
1344 (void *)&cmd_set_port_setup_on_on,
1345 (void *)&cmd_set_port_setup_on_mode,
1350 /* *** attach a specified port *** */
1351 struct cmd_operate_attach_port_result {
1352 cmdline_fixed_string_t port;
1353 cmdline_fixed_string_t keyword;
1354 cmdline_multi_string_t identifier;
1357 static void cmd_operate_attach_port_parsed(void *parsed_result,
1358 __rte_unused struct cmdline *cl,
1359 __rte_unused void *data)
1361 struct cmd_operate_attach_port_result *res = parsed_result;
1363 if (!strcmp(res->keyword, "attach"))
1364 attach_port(res->identifier);
1366 printf("Unknown parameter\n");
1369 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1370 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1372 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1373 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1375 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1376 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1377 identifier, TOKEN_STRING_MULTI);
1379 cmdline_parse_inst_t cmd_operate_attach_port = {
1380 .f = cmd_operate_attach_port_parsed,
1382 .help_str = "port attach <identifier>: "
1383 "(identifier: pci address or virtual dev name)",
1385 (void *)&cmd_operate_attach_port_port,
1386 (void *)&cmd_operate_attach_port_keyword,
1387 (void *)&cmd_operate_attach_port_identifier,
1392 /* *** detach a specified port *** */
1393 struct cmd_operate_detach_port_result {
1394 cmdline_fixed_string_t port;
1395 cmdline_fixed_string_t keyword;
1399 static void cmd_operate_detach_port_parsed(void *parsed_result,
1400 __rte_unused struct cmdline *cl,
1401 __rte_unused void *data)
1403 struct cmd_operate_detach_port_result *res = parsed_result;
1405 if (!strcmp(res->keyword, "detach")) {
1406 RTE_ETH_VALID_PORTID_OR_RET(res->port_id);
1407 detach_port_device(res->port_id);
1409 printf("Unknown parameter\n");
1413 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1414 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1416 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1417 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1419 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1420 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1421 port_id, RTE_UINT16);
1423 cmdline_parse_inst_t cmd_operate_detach_port = {
1424 .f = cmd_operate_detach_port_parsed,
1426 .help_str = "port detach <port_id>",
1428 (void *)&cmd_operate_detach_port_port,
1429 (void *)&cmd_operate_detach_port_keyword,
1430 (void *)&cmd_operate_detach_port_port_id,
1435 /* *** detach device by identifier *** */
1436 struct cmd_operate_detach_device_result {
1437 cmdline_fixed_string_t device;
1438 cmdline_fixed_string_t keyword;
1439 cmdline_fixed_string_t identifier;
1442 static void cmd_operate_detach_device_parsed(void *parsed_result,
1443 __rte_unused struct cmdline *cl,
1444 __rte_unused void *data)
1446 struct cmd_operate_detach_device_result *res = parsed_result;
1448 if (!strcmp(res->keyword, "detach"))
1449 detach_devargs(res->identifier);
1451 printf("Unknown parameter\n");
1454 cmdline_parse_token_string_t cmd_operate_detach_device_device =
1455 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1457 cmdline_parse_token_string_t cmd_operate_detach_device_keyword =
1458 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1460 cmdline_parse_token_string_t cmd_operate_detach_device_identifier =
1461 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1464 cmdline_parse_inst_t cmd_operate_detach_device = {
1465 .f = cmd_operate_detach_device_parsed,
1467 .help_str = "device detach <identifier>:"
1468 "(identifier: pci address or virtual dev name)",
1470 (void *)&cmd_operate_detach_device_device,
1471 (void *)&cmd_operate_detach_device_keyword,
1472 (void *)&cmd_operate_detach_device_identifier,
1476 /* *** configure speed for all ports *** */
1477 struct cmd_config_speed_all {
1478 cmdline_fixed_string_t port;
1479 cmdline_fixed_string_t keyword;
1480 cmdline_fixed_string_t all;
1481 cmdline_fixed_string_t item1;
1482 cmdline_fixed_string_t item2;
1483 cmdline_fixed_string_t value1;
1484 cmdline_fixed_string_t value2;
1488 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1493 if (!strcmp(duplexstr, "half")) {
1494 duplex = ETH_LINK_HALF_DUPLEX;
1495 } else if (!strcmp(duplexstr, "full")) {
1496 duplex = ETH_LINK_FULL_DUPLEX;
1497 } else if (!strcmp(duplexstr, "auto")) {
1498 duplex = ETH_LINK_FULL_DUPLEX;
1500 printf("Unknown duplex parameter\n");
1504 if (!strcmp(speedstr, "10")) {
1505 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1506 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1507 } else if (!strcmp(speedstr, "100")) {
1508 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1509 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1511 if (duplex != ETH_LINK_FULL_DUPLEX) {
1512 printf("Invalid speed/duplex parameters\n");
1515 if (!strcmp(speedstr, "1000")) {
1516 *speed = ETH_LINK_SPEED_1G;
1517 } else if (!strcmp(speedstr, "10000")) {
1518 *speed = ETH_LINK_SPEED_10G;
1519 } else if (!strcmp(speedstr, "25000")) {
1520 *speed = ETH_LINK_SPEED_25G;
1521 } else if (!strcmp(speedstr, "40000")) {
1522 *speed = ETH_LINK_SPEED_40G;
1523 } else if (!strcmp(speedstr, "50000")) {
1524 *speed = ETH_LINK_SPEED_50G;
1525 } else if (!strcmp(speedstr, "100000")) {
1526 *speed = ETH_LINK_SPEED_100G;
1527 } else if (!strcmp(speedstr, "200000")) {
1528 *speed = ETH_LINK_SPEED_200G;
1529 } else if (!strcmp(speedstr, "auto")) {
1530 *speed = ETH_LINK_SPEED_AUTONEG;
1532 printf("Unknown speed parameter\n");
1537 if (*speed != ETH_LINK_SPEED_AUTONEG)
1538 *speed |= ETH_LINK_SPEED_FIXED;
1544 cmd_config_speed_all_parsed(void *parsed_result,
1545 __rte_unused struct cmdline *cl,
1546 __rte_unused void *data)
1548 struct cmd_config_speed_all *res = parsed_result;
1549 uint32_t link_speed;
1552 if (!all_ports_stopped()) {
1553 printf("Please stop all ports first\n");
1557 if (parse_and_check_speed_duplex(res->value1, res->value2,
1561 RTE_ETH_FOREACH_DEV(pid) {
1562 ports[pid].dev_conf.link_speeds = link_speed;
1565 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1568 cmdline_parse_token_string_t cmd_config_speed_all_port =
1569 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1570 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1571 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1573 cmdline_parse_token_string_t cmd_config_speed_all_all =
1574 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1575 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1576 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1577 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1578 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1579 "10#100#1000#10000#25000#40000#50000#100000#200000#auto");
1580 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1581 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1582 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1583 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1586 cmdline_parse_inst_t cmd_config_speed_all = {
1587 .f = cmd_config_speed_all_parsed,
1589 .help_str = "port config all speed "
1590 "10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex "
1593 (void *)&cmd_config_speed_all_port,
1594 (void *)&cmd_config_speed_all_keyword,
1595 (void *)&cmd_config_speed_all_all,
1596 (void *)&cmd_config_speed_all_item1,
1597 (void *)&cmd_config_speed_all_value1,
1598 (void *)&cmd_config_speed_all_item2,
1599 (void *)&cmd_config_speed_all_value2,
1604 /* *** configure speed for specific port *** */
1605 struct cmd_config_speed_specific {
1606 cmdline_fixed_string_t port;
1607 cmdline_fixed_string_t keyword;
1609 cmdline_fixed_string_t item1;
1610 cmdline_fixed_string_t item2;
1611 cmdline_fixed_string_t value1;
1612 cmdline_fixed_string_t value2;
1616 cmd_config_speed_specific_parsed(void *parsed_result,
1617 __rte_unused struct cmdline *cl,
1618 __rte_unused void *data)
1620 struct cmd_config_speed_specific *res = parsed_result;
1621 uint32_t link_speed;
1623 if (!all_ports_stopped()) {
1624 printf("Please stop all ports first\n");
1628 if (port_id_is_invalid(res->id, ENABLED_WARN))
1631 if (parse_and_check_speed_duplex(res->value1, res->value2,
1635 ports[res->id].dev_conf.link_speeds = link_speed;
1637 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1641 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1642 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1644 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1645 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1647 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1648 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, RTE_UINT16);
1649 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1650 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1652 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1653 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1654 "10#100#1000#10000#25000#40000#50000#100000#200000#auto");
1655 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1656 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1658 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1659 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1662 cmdline_parse_inst_t cmd_config_speed_specific = {
1663 .f = cmd_config_speed_specific_parsed,
1665 .help_str = "port config <port_id> speed "
1666 "10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex "
1669 (void *)&cmd_config_speed_specific_port,
1670 (void *)&cmd_config_speed_specific_keyword,
1671 (void *)&cmd_config_speed_specific_id,
1672 (void *)&cmd_config_speed_specific_item1,
1673 (void *)&cmd_config_speed_specific_value1,
1674 (void *)&cmd_config_speed_specific_item2,
1675 (void *)&cmd_config_speed_specific_value2,
1680 /* *** configure loopback for all ports *** */
1681 struct cmd_config_loopback_all {
1682 cmdline_fixed_string_t port;
1683 cmdline_fixed_string_t keyword;
1684 cmdline_fixed_string_t all;
1685 cmdline_fixed_string_t item;
1690 cmd_config_loopback_all_parsed(void *parsed_result,
1691 __rte_unused struct cmdline *cl,
1692 __rte_unused void *data)
1694 struct cmd_config_loopback_all *res = parsed_result;
1697 if (!all_ports_stopped()) {
1698 printf("Please stop all ports first\n");
1702 RTE_ETH_FOREACH_DEV(pid) {
1703 ports[pid].dev_conf.lpbk_mode = res->mode;
1706 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1709 cmdline_parse_token_string_t cmd_config_loopback_all_port =
1710 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1711 cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1712 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1714 cmdline_parse_token_string_t cmd_config_loopback_all_all =
1715 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1716 cmdline_parse_token_string_t cmd_config_loopback_all_item =
1717 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1719 cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1720 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, RTE_UINT32);
1722 cmdline_parse_inst_t cmd_config_loopback_all = {
1723 .f = cmd_config_loopback_all_parsed,
1725 .help_str = "port config all loopback <mode>",
1727 (void *)&cmd_config_loopback_all_port,
1728 (void *)&cmd_config_loopback_all_keyword,
1729 (void *)&cmd_config_loopback_all_all,
1730 (void *)&cmd_config_loopback_all_item,
1731 (void *)&cmd_config_loopback_all_mode,
1736 /* *** configure loopback for specific port *** */
1737 struct cmd_config_loopback_specific {
1738 cmdline_fixed_string_t port;
1739 cmdline_fixed_string_t keyword;
1741 cmdline_fixed_string_t item;
1746 cmd_config_loopback_specific_parsed(void *parsed_result,
1747 __rte_unused struct cmdline *cl,
1748 __rte_unused void *data)
1750 struct cmd_config_loopback_specific *res = parsed_result;
1752 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1755 if (!port_is_stopped(res->port_id)) {
1756 printf("Please stop port %u first\n", res->port_id);
1760 ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1762 cmd_reconfig_device_queue(res->port_id, 1, 1);
1766 cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1767 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1769 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1770 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1772 cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1773 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1775 cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1776 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1778 cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1779 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1782 cmdline_parse_inst_t cmd_config_loopback_specific = {
1783 .f = cmd_config_loopback_specific_parsed,
1785 .help_str = "port config <port_id> loopback <mode>",
1787 (void *)&cmd_config_loopback_specific_port,
1788 (void *)&cmd_config_loopback_specific_keyword,
1789 (void *)&cmd_config_loopback_specific_id,
1790 (void *)&cmd_config_loopback_specific_item,
1791 (void *)&cmd_config_loopback_specific_mode,
1796 /* *** configure txq/rxq, txd/rxd *** */
1797 struct cmd_config_rx_tx {
1798 cmdline_fixed_string_t port;
1799 cmdline_fixed_string_t keyword;
1800 cmdline_fixed_string_t all;
1801 cmdline_fixed_string_t name;
1806 cmd_config_rx_tx_parsed(void *parsed_result,
1807 __rte_unused struct cmdline *cl,
1808 __rte_unused void *data)
1810 struct cmd_config_rx_tx *res = parsed_result;
1812 if (!all_ports_stopped()) {
1813 printf("Please stop all ports first\n");
1816 if (!strcmp(res->name, "rxq")) {
1817 if (!res->value && !nb_txq) {
1818 printf("Warning: Either rx or tx queues should be non zero\n");
1821 if (check_nb_rxq(res->value) != 0)
1823 nb_rxq = res->value;
1825 else if (!strcmp(res->name, "txq")) {
1826 if (!res->value && !nb_rxq) {
1827 printf("Warning: Either rx or tx queues should be non zero\n");
1830 if (check_nb_txq(res->value) != 0)
1832 nb_txq = res->value;
1834 else if (!strcmp(res->name, "rxd")) {
1835 if (check_nb_rxd(res->value) != 0)
1837 nb_rxd = res->value;
1838 } else if (!strcmp(res->name, "txd")) {
1839 if (check_nb_txd(res->value) != 0)
1842 nb_txd = res->value;
1844 printf("Unknown parameter\n");
1852 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1855 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1856 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1857 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1858 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1859 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1860 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1861 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1862 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1864 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1865 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, RTE_UINT16);
1867 cmdline_parse_inst_t cmd_config_rx_tx = {
1868 .f = cmd_config_rx_tx_parsed,
1870 .help_str = "port config all rxq|txq|rxd|txd <value>",
1872 (void *)&cmd_config_rx_tx_port,
1873 (void *)&cmd_config_rx_tx_keyword,
1874 (void *)&cmd_config_rx_tx_all,
1875 (void *)&cmd_config_rx_tx_name,
1876 (void *)&cmd_config_rx_tx_value,
1881 /* *** config max packet length *** */
1882 struct cmd_config_max_pkt_len_result {
1883 cmdline_fixed_string_t port;
1884 cmdline_fixed_string_t keyword;
1885 cmdline_fixed_string_t all;
1886 cmdline_fixed_string_t name;
1891 cmd_config_max_pkt_len_parsed(void *parsed_result,
1892 __rte_unused struct cmdline *cl,
1893 __rte_unused void *data)
1895 struct cmd_config_max_pkt_len_result *res = parsed_result;
1896 uint32_t max_rx_pkt_len_backup = 0;
1900 if (!all_ports_stopped()) {
1901 printf("Please stop all ports first\n");
1905 RTE_ETH_FOREACH_DEV(pid) {
1906 struct rte_port *port = &ports[pid];
1908 if (!strcmp(res->name, "max-pkt-len")) {
1909 if (res->value < RTE_ETHER_MIN_LEN) {
1910 printf("max-pkt-len can not be less than %d\n",
1914 if (res->value == port->dev_conf.rxmode.max_rx_pkt_len)
1917 ret = eth_dev_info_get_print_err(pid, &port->dev_info);
1919 printf("rte_eth_dev_info_get() failed for port %u\n",
1924 max_rx_pkt_len_backup = port->dev_conf.rxmode.max_rx_pkt_len;
1926 port->dev_conf.rxmode.max_rx_pkt_len = res->value;
1927 if (update_jumbo_frame_offload(pid) != 0)
1928 port->dev_conf.rxmode.max_rx_pkt_len = max_rx_pkt_len_backup;
1930 printf("Unknown parameter\n");
1937 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1940 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1941 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1943 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1944 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1946 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1947 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1949 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1950 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1952 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1953 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1956 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1957 .f = cmd_config_max_pkt_len_parsed,
1959 .help_str = "port config all max-pkt-len <value>",
1961 (void *)&cmd_config_max_pkt_len_port,
1962 (void *)&cmd_config_max_pkt_len_keyword,
1963 (void *)&cmd_config_max_pkt_len_all,
1964 (void *)&cmd_config_max_pkt_len_name,
1965 (void *)&cmd_config_max_pkt_len_value,
1970 /* *** config max LRO aggregated packet size *** */
1971 struct cmd_config_max_lro_pkt_size_result {
1972 cmdline_fixed_string_t port;
1973 cmdline_fixed_string_t keyword;
1974 cmdline_fixed_string_t all;
1975 cmdline_fixed_string_t name;
1980 cmd_config_max_lro_pkt_size_parsed(void *parsed_result,
1981 __rte_unused struct cmdline *cl,
1982 __rte_unused void *data)
1984 struct cmd_config_max_lro_pkt_size_result *res = parsed_result;
1987 if (!all_ports_stopped()) {
1988 printf("Please stop all ports first\n");
1992 RTE_ETH_FOREACH_DEV(pid) {
1993 struct rte_port *port = &ports[pid];
1995 if (!strcmp(res->name, "max-lro-pkt-size")) {
1997 port->dev_conf.rxmode.max_lro_pkt_size)
2000 port->dev_conf.rxmode.max_lro_pkt_size = res->value;
2002 printf("Unknown parameter\n");
2009 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2012 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_port =
2013 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2015 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_keyword =
2016 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2018 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_all =
2019 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2021 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_name =
2022 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2023 name, "max-lro-pkt-size");
2024 cmdline_parse_token_num_t cmd_config_max_lro_pkt_size_value =
2025 TOKEN_NUM_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2028 cmdline_parse_inst_t cmd_config_max_lro_pkt_size = {
2029 .f = cmd_config_max_lro_pkt_size_parsed,
2031 .help_str = "port config all max-lro-pkt-size <value>",
2033 (void *)&cmd_config_max_lro_pkt_size_port,
2034 (void *)&cmd_config_max_lro_pkt_size_keyword,
2035 (void *)&cmd_config_max_lro_pkt_size_all,
2036 (void *)&cmd_config_max_lro_pkt_size_name,
2037 (void *)&cmd_config_max_lro_pkt_size_value,
2042 /* *** configure port MTU *** */
2043 struct cmd_config_mtu_result {
2044 cmdline_fixed_string_t port;
2045 cmdline_fixed_string_t keyword;
2046 cmdline_fixed_string_t mtu;
2052 cmd_config_mtu_parsed(void *parsed_result,
2053 __rte_unused struct cmdline *cl,
2054 __rte_unused void *data)
2056 struct cmd_config_mtu_result *res = parsed_result;
2058 if (res->value < RTE_ETHER_MIN_LEN) {
2059 printf("mtu cannot be less than %d\n", RTE_ETHER_MIN_LEN);
2062 port_mtu_set(res->port_id, res->value);
2065 cmdline_parse_token_string_t cmd_config_mtu_port =
2066 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
2068 cmdline_parse_token_string_t cmd_config_mtu_keyword =
2069 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2071 cmdline_parse_token_string_t cmd_config_mtu_mtu =
2072 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2074 cmdline_parse_token_num_t cmd_config_mtu_port_id =
2075 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id,
2077 cmdline_parse_token_num_t cmd_config_mtu_value =
2078 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value,
2081 cmdline_parse_inst_t cmd_config_mtu = {
2082 .f = cmd_config_mtu_parsed,
2084 .help_str = "port config mtu <port_id> <value>",
2086 (void *)&cmd_config_mtu_port,
2087 (void *)&cmd_config_mtu_keyword,
2088 (void *)&cmd_config_mtu_mtu,
2089 (void *)&cmd_config_mtu_port_id,
2090 (void *)&cmd_config_mtu_value,
2095 /* *** configure rx mode *** */
2096 struct cmd_config_rx_mode_flag {
2097 cmdline_fixed_string_t port;
2098 cmdline_fixed_string_t keyword;
2099 cmdline_fixed_string_t all;
2100 cmdline_fixed_string_t name;
2101 cmdline_fixed_string_t value;
2105 cmd_config_rx_mode_flag_parsed(void *parsed_result,
2106 __rte_unused struct cmdline *cl,
2107 __rte_unused void *data)
2109 struct cmd_config_rx_mode_flag *res = parsed_result;
2111 if (!all_ports_stopped()) {
2112 printf("Please stop all ports first\n");
2116 if (!strcmp(res->name, "drop-en")) {
2117 if (!strcmp(res->value, "on"))
2119 else if (!strcmp(res->value, "off"))
2122 printf("Unknown parameter\n");
2126 printf("Unknown parameter\n");
2132 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2135 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
2136 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
2137 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
2138 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
2140 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2141 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2142 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2143 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2145 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2146 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2149 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2150 .f = cmd_config_rx_mode_flag_parsed,
2152 .help_str = "port config all drop-en on|off",
2154 (void *)&cmd_config_rx_mode_flag_port,
2155 (void *)&cmd_config_rx_mode_flag_keyword,
2156 (void *)&cmd_config_rx_mode_flag_all,
2157 (void *)&cmd_config_rx_mode_flag_name,
2158 (void *)&cmd_config_rx_mode_flag_value,
2163 /* *** configure rss *** */
2164 struct cmd_config_rss {
2165 cmdline_fixed_string_t port;
2166 cmdline_fixed_string_t keyword;
2167 cmdline_fixed_string_t all;
2168 cmdline_fixed_string_t name;
2169 cmdline_fixed_string_t value;
2173 cmd_config_rss_parsed(void *parsed_result,
2174 __rte_unused struct cmdline *cl,
2175 __rte_unused void *data)
2177 struct cmd_config_rss *res = parsed_result;
2178 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2179 struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2180 int use_default = 0;
2181 int all_updated = 1;
2186 if (!strcmp(res->value, "all"))
2187 rss_conf.rss_hf = ETH_RSS_ETH | ETH_RSS_VLAN | ETH_RSS_IP |
2188 ETH_RSS_TCP | ETH_RSS_UDP | ETH_RSS_SCTP |
2189 ETH_RSS_L2_PAYLOAD | ETH_RSS_L2TPV3 | ETH_RSS_ESP |
2190 ETH_RSS_AH | ETH_RSS_PFCP | ETH_RSS_GTPU |
2192 else if (!strcmp(res->value, "eth"))
2193 rss_conf.rss_hf = ETH_RSS_ETH;
2194 else if (!strcmp(res->value, "vlan"))
2195 rss_conf.rss_hf = ETH_RSS_VLAN;
2196 else if (!strcmp(res->value, "ip"))
2197 rss_conf.rss_hf = ETH_RSS_IP;
2198 else if (!strcmp(res->value, "udp"))
2199 rss_conf.rss_hf = ETH_RSS_UDP;
2200 else if (!strcmp(res->value, "tcp"))
2201 rss_conf.rss_hf = ETH_RSS_TCP;
2202 else if (!strcmp(res->value, "sctp"))
2203 rss_conf.rss_hf = ETH_RSS_SCTP;
2204 else if (!strcmp(res->value, "ether"))
2205 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
2206 else if (!strcmp(res->value, "port"))
2207 rss_conf.rss_hf = ETH_RSS_PORT;
2208 else if (!strcmp(res->value, "vxlan"))
2209 rss_conf.rss_hf = ETH_RSS_VXLAN;
2210 else if (!strcmp(res->value, "geneve"))
2211 rss_conf.rss_hf = ETH_RSS_GENEVE;
2212 else if (!strcmp(res->value, "nvgre"))
2213 rss_conf.rss_hf = ETH_RSS_NVGRE;
2214 else if (!strcmp(res->value, "l3-pre32"))
2215 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE32;
2216 else if (!strcmp(res->value, "l3-pre40"))
2217 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE40;
2218 else if (!strcmp(res->value, "l3-pre48"))
2219 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE48;
2220 else if (!strcmp(res->value, "l3-pre56"))
2221 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE56;
2222 else if (!strcmp(res->value, "l3-pre64"))
2223 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE64;
2224 else if (!strcmp(res->value, "l3-pre96"))
2225 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE96;
2226 else if (!strcmp(res->value, "l3-src-only"))
2227 rss_conf.rss_hf = ETH_RSS_L3_SRC_ONLY;
2228 else if (!strcmp(res->value, "l3-dst-only"))
2229 rss_conf.rss_hf = ETH_RSS_L3_DST_ONLY;
2230 else if (!strcmp(res->value, "l4-src-only"))
2231 rss_conf.rss_hf = ETH_RSS_L4_SRC_ONLY;
2232 else if (!strcmp(res->value, "l4-dst-only"))
2233 rss_conf.rss_hf = ETH_RSS_L4_DST_ONLY;
2234 else if (!strcmp(res->value, "l2-src-only"))
2235 rss_conf.rss_hf = ETH_RSS_L2_SRC_ONLY;
2236 else if (!strcmp(res->value, "l2-dst-only"))
2237 rss_conf.rss_hf = ETH_RSS_L2_DST_ONLY;
2238 else if (!strcmp(res->value, "l2tpv3"))
2239 rss_conf.rss_hf = ETH_RSS_L2TPV3;
2240 else if (!strcmp(res->value, "esp"))
2241 rss_conf.rss_hf = ETH_RSS_ESP;
2242 else if (!strcmp(res->value, "ah"))
2243 rss_conf.rss_hf = ETH_RSS_AH;
2244 else if (!strcmp(res->value, "pfcp"))
2245 rss_conf.rss_hf = ETH_RSS_PFCP;
2246 else if (!strcmp(res->value, "pppoe"))
2247 rss_conf.rss_hf = ETH_RSS_PPPOE;
2248 else if (!strcmp(res->value, "gtpu"))
2249 rss_conf.rss_hf = ETH_RSS_GTPU;
2250 else if (!strcmp(res->value, "ecpri"))
2251 rss_conf.rss_hf = ETH_RSS_ECPRI;
2252 else if (!strcmp(res->value, "mpls"))
2253 rss_conf.rss_hf = ETH_RSS_MPLS;
2254 else if (!strcmp(res->value, "none"))
2255 rss_conf.rss_hf = 0;
2256 else if (!strcmp(res->value, "level-default")) {
2257 rss_hf &= (~ETH_RSS_LEVEL_MASK);
2258 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_PMD_DEFAULT);
2259 } else if (!strcmp(res->value, "level-outer")) {
2260 rss_hf &= (~ETH_RSS_LEVEL_MASK);
2261 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_OUTERMOST);
2262 } else if (!strcmp(res->value, "level-inner")) {
2263 rss_hf &= (~ETH_RSS_LEVEL_MASK);
2264 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_INNERMOST);
2265 } else if (!strcmp(res->value, "default"))
2267 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2268 atoi(res->value) < 64)
2269 rss_conf.rss_hf = 1ULL << atoi(res->value);
2271 printf("Unknown parameter\n");
2274 rss_conf.rss_key = NULL;
2275 /* Update global configuration for RSS types. */
2276 RTE_ETH_FOREACH_DEV(i) {
2277 struct rte_eth_rss_conf local_rss_conf;
2279 ret = eth_dev_info_get_print_err(i, &dev_info);
2284 rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2286 local_rss_conf = rss_conf;
2287 local_rss_conf.rss_hf = rss_conf.rss_hf &
2288 dev_info.flow_type_rss_offloads;
2289 if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2290 printf("Port %u modified RSS hash function based on hardware support,"
2291 "requested:%#"PRIx64" configured:%#"PRIx64"\n",
2292 i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2294 diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2297 printf("Configuration of RSS hash at ethernet port %d "
2298 "failed with error (%d): %s.\n",
2299 i, -diag, strerror(-diag));
2302 if (all_updated && !use_default) {
2303 rss_hf = rss_conf.rss_hf;
2304 printf("rss_hf %#"PRIx64"\n", rss_hf);
2308 cmdline_parse_token_string_t cmd_config_rss_port =
2309 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2310 cmdline_parse_token_string_t cmd_config_rss_keyword =
2311 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2312 cmdline_parse_token_string_t cmd_config_rss_all =
2313 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2314 cmdline_parse_token_string_t cmd_config_rss_name =
2315 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2316 cmdline_parse_token_string_t cmd_config_rss_value =
2317 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2319 cmdline_parse_inst_t cmd_config_rss = {
2320 .f = cmd_config_rss_parsed,
2322 .help_str = "port config all rss "
2323 "all|default|eth|vlan|ip|tcp|udp|sctp|ether|port|vxlan|geneve|"
2324 "nvgre|vxlan-gpe|l2tpv3|esp|ah|pfcp|ecpri|mpls|none|level-default|"
2325 "level-outer|level-inner|<flowtype_id>",
2327 (void *)&cmd_config_rss_port,
2328 (void *)&cmd_config_rss_keyword,
2329 (void *)&cmd_config_rss_all,
2330 (void *)&cmd_config_rss_name,
2331 (void *)&cmd_config_rss_value,
2336 /* *** configure rss hash key *** */
2337 struct cmd_config_rss_hash_key {
2338 cmdline_fixed_string_t port;
2339 cmdline_fixed_string_t config;
2341 cmdline_fixed_string_t rss_hash_key;
2342 cmdline_fixed_string_t rss_type;
2343 cmdline_fixed_string_t key;
2347 hexa_digit_to_value(char hexa_digit)
2349 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2350 return (uint8_t) (hexa_digit - '0');
2351 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2352 return (uint8_t) ((hexa_digit - 'a') + 10);
2353 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2354 return (uint8_t) ((hexa_digit - 'A') + 10);
2355 /* Invalid hexa digit */
2360 parse_and_check_key_hexa_digit(char *key, int idx)
2364 hexa_v = hexa_digit_to_value(key[idx]);
2366 printf("invalid key: character %c at position %d is not a "
2367 "valid hexa digit\n", key[idx], idx);
2372 cmd_config_rss_hash_key_parsed(void *parsed_result,
2373 __rte_unused struct cmdline *cl,
2374 __rte_unused void *data)
2376 struct cmd_config_rss_hash_key *res = parsed_result;
2377 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2381 struct rte_eth_dev_info dev_info;
2382 uint8_t hash_key_size;
2386 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2390 if (dev_info.hash_key_size > 0 &&
2391 dev_info.hash_key_size <= sizeof(hash_key))
2392 hash_key_size = dev_info.hash_key_size;
2394 printf("dev_info did not provide a valid hash key size\n");
2397 /* Check the length of the RSS hash key */
2398 key_len = strlen(res->key);
2399 if (key_len != (hash_key_size * 2)) {
2400 printf("key length: %d invalid - key must be a string of %d"
2401 " hexa-decimal numbers\n",
2402 (int) key_len, hash_key_size * 2);
2405 /* Translate RSS hash key into binary representation */
2406 for (i = 0; i < hash_key_size; i++) {
2407 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2410 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2413 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2415 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2419 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2420 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2421 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2422 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2424 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2425 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id,
2427 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2428 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2429 rss_hash_key, "rss-hash-key");
2430 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2431 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2432 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2433 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2434 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2435 "ipv6-tcp-ex#ipv6-udp-ex#"
2436 "l3-src-only#l3-dst-only#l4-src-only#l4-dst-only#"
2437 "l2-src-only#l2-dst-only#s-vlan#c-vlan#"
2438 "l2tpv3#esp#ah#pfcp#pppoe#gtpu#ecpri#mpls");
2439 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2440 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2442 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2443 .f = cmd_config_rss_hash_key_parsed,
2445 .help_str = "port config <port_id> rss-hash-key "
2446 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2447 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2448 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|"
2449 "l3-src-only|l3-dst-only|l4-src-only|l4-dst-only|"
2450 "l2-src-only|l2-dst-only|s-vlan|c-vlan|"
2451 "l2tpv3|esp|ah|pfcp|pppoe|gtpu|ecpri|mpls "
2452 "<string of hex digits (variable length, NIC dependent)>",
2454 (void *)&cmd_config_rss_hash_key_port,
2455 (void *)&cmd_config_rss_hash_key_config,
2456 (void *)&cmd_config_rss_hash_key_port_id,
2457 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2458 (void *)&cmd_config_rss_hash_key_rss_type,
2459 (void *)&cmd_config_rss_hash_key_value,
2464 /* *** cleanup txq mbufs *** */
2465 struct cmd_cleanup_txq_mbufs_result {
2466 cmdline_fixed_string_t port;
2467 cmdline_fixed_string_t keyword;
2468 cmdline_fixed_string_t name;
2475 cmd_cleanup_txq_mbufs_parsed(void *parsed_result,
2476 __rte_unused struct cmdline *cl,
2477 __rte_unused void *data)
2479 struct cmd_cleanup_txq_mbufs_result *res = parsed_result;
2480 uint16_t port_id = res->port_id;
2481 uint16_t queue_id = res->queue_id;
2482 uint32_t free_cnt = res->free_cnt;
2483 struct rte_eth_txq_info qinfo;
2486 if (test_done == 0) {
2487 printf("Please stop forwarding first\n");
2491 if (rte_eth_tx_queue_info_get(port_id, queue_id, &qinfo)) {
2492 printf("Failed to get port %u Tx queue %u info\n",
2497 if (qinfo.queue_state != RTE_ETH_QUEUE_STATE_STARTED) {
2498 printf("Tx queue %u not started\n", queue_id);
2502 ret = rte_eth_tx_done_cleanup(port_id, queue_id, free_cnt);
2504 printf("Failed to cleanup mbuf for port %u Tx queue %u "
2505 "error desc: %s(%d)\n",
2506 port_id, queue_id, strerror(-ret), ret);
2510 printf("Cleanup port %u Tx queue %u mbuf nums: %u\n",
2511 port_id, queue_id, ret);
2514 cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_port =
2515 TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, port,
2517 cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_cleanup =
2518 TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, keyword,
2520 cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_port_id =
2521 TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, port_id,
2523 cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_txq =
2524 TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, name,
2526 cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_queue_id =
2527 TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, queue_id,
2529 cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_free_cnt =
2530 TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, free_cnt,
2533 cmdline_parse_inst_t cmd_cleanup_txq_mbufs = {
2534 .f = cmd_cleanup_txq_mbufs_parsed,
2536 .help_str = "port cleanup <port_id> txq <queue_id> <free_cnt>",
2538 (void *)&cmd_cleanup_txq_mbufs_port,
2539 (void *)&cmd_cleanup_txq_mbufs_cleanup,
2540 (void *)&cmd_cleanup_txq_mbufs_port_id,
2541 (void *)&cmd_cleanup_txq_mbufs_txq,
2542 (void *)&cmd_cleanup_txq_mbufs_queue_id,
2543 (void *)&cmd_cleanup_txq_mbufs_free_cnt,
2548 /* *** configure port rxq/txq ring size *** */
2549 struct cmd_config_rxtx_ring_size {
2550 cmdline_fixed_string_t port;
2551 cmdline_fixed_string_t config;
2553 cmdline_fixed_string_t rxtxq;
2555 cmdline_fixed_string_t rsize;
2560 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2561 __rte_unused struct cmdline *cl,
2562 __rte_unused void *data)
2564 struct cmd_config_rxtx_ring_size *res = parsed_result;
2565 struct rte_port *port;
2568 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2571 if (res->portid == (portid_t)RTE_PORT_ALL) {
2572 printf("Invalid port id\n");
2576 port = &ports[res->portid];
2578 if (!strcmp(res->rxtxq, "rxq"))
2580 else if (!strcmp(res->rxtxq, "txq"))
2583 printf("Unknown parameter\n");
2587 if (isrx && rx_queue_id_is_invalid(res->qid))
2589 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2592 if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2593 printf("Invalid rx ring_size, must > rx_free_thresh: %d\n",
2599 port->nb_rx_desc[res->qid] = res->size;
2601 port->nb_tx_desc[res->qid] = res->size;
2603 cmd_reconfig_device_queue(res->portid, 0, 1);
2606 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2607 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2609 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2610 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2612 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2613 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2614 portid, RTE_UINT16);
2615 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2616 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2618 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2619 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2621 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2622 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2623 rsize, "ring_size");
2624 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2625 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2628 cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2629 .f = cmd_config_rxtx_ring_size_parsed,
2631 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2633 (void *)&cmd_config_rxtx_ring_size_port,
2634 (void *)&cmd_config_rxtx_ring_size_config,
2635 (void *)&cmd_config_rxtx_ring_size_portid,
2636 (void *)&cmd_config_rxtx_ring_size_rxtxq,
2637 (void *)&cmd_config_rxtx_ring_size_qid,
2638 (void *)&cmd_config_rxtx_ring_size_rsize,
2639 (void *)&cmd_config_rxtx_ring_size_size,
2644 /* *** configure port rxq/txq start/stop *** */
2645 struct cmd_config_rxtx_queue {
2646 cmdline_fixed_string_t port;
2648 cmdline_fixed_string_t rxtxq;
2650 cmdline_fixed_string_t opname;
2654 cmd_config_rxtx_queue_parsed(void *parsed_result,
2655 __rte_unused struct cmdline *cl,
2656 __rte_unused void *data)
2658 struct cmd_config_rxtx_queue *res = parsed_result;
2663 if (test_done == 0) {
2664 printf("Please stop forwarding first\n");
2668 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2671 if (port_is_started(res->portid) != 1) {
2672 printf("Please start port %u first\n", res->portid);
2676 if (!strcmp(res->rxtxq, "rxq"))
2678 else if (!strcmp(res->rxtxq, "txq"))
2681 printf("Unknown parameter\n");
2685 if (isrx && rx_queue_id_is_invalid(res->qid))
2687 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2690 if (!strcmp(res->opname, "start"))
2692 else if (!strcmp(res->opname, "stop"))
2695 printf("Unknown parameter\n");
2699 if (isstart && isrx)
2700 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2701 else if (!isstart && isrx)
2702 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2703 else if (isstart && !isrx)
2704 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2706 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2708 if (ret == -ENOTSUP)
2709 printf("Function not supported in PMD driver\n");
2712 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2713 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2714 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2715 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, RTE_UINT16);
2716 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2717 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2718 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2719 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, RTE_UINT16);
2720 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2721 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2724 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2725 .f = cmd_config_rxtx_queue_parsed,
2727 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2729 (void *)&cmd_config_rxtx_queue_port,
2730 (void *)&cmd_config_rxtx_queue_portid,
2731 (void *)&cmd_config_rxtx_queue_rxtxq,
2732 (void *)&cmd_config_rxtx_queue_qid,
2733 (void *)&cmd_config_rxtx_queue_opname,
2738 /* *** configure port rxq/txq deferred start on/off *** */
2739 struct cmd_config_deferred_start_rxtx_queue {
2740 cmdline_fixed_string_t port;
2742 cmdline_fixed_string_t rxtxq;
2744 cmdline_fixed_string_t opname;
2745 cmdline_fixed_string_t state;
2749 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2750 __rte_unused struct cmdline *cl,
2751 __rte_unused void *data)
2753 struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2754 struct rte_port *port;
2757 uint8_t needreconfig = 0;
2759 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2762 if (port_is_started(res->port_id) != 0) {
2763 printf("Please stop port %u first\n", res->port_id);
2767 port = &ports[res->port_id];
2769 isrx = !strcmp(res->rxtxq, "rxq");
2771 if (isrx && rx_queue_id_is_invalid(res->qid))
2773 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2776 ison = !strcmp(res->state, "on");
2778 if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) {
2779 port->rx_conf[res->qid].rx_deferred_start = ison;
2781 } else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) {
2782 port->tx_conf[res->qid].tx_deferred_start = ison;
2787 cmd_reconfig_device_queue(res->port_id, 0, 1);
2790 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2791 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2793 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2794 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2795 port_id, RTE_UINT16);
2796 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2797 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2799 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2800 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2802 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2803 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2804 opname, "deferred_start");
2805 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2806 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2809 cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
2810 .f = cmd_config_deferred_start_rxtx_queue_parsed,
2812 .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
2814 (void *)&cmd_config_deferred_start_rxtx_queue_port,
2815 (void *)&cmd_config_deferred_start_rxtx_queue_port_id,
2816 (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
2817 (void *)&cmd_config_deferred_start_rxtx_queue_qid,
2818 (void *)&cmd_config_deferred_start_rxtx_queue_opname,
2819 (void *)&cmd_config_deferred_start_rxtx_queue_state,
2824 /* *** configure port rxq/txq setup *** */
2825 struct cmd_setup_rxtx_queue {
2826 cmdline_fixed_string_t port;
2828 cmdline_fixed_string_t rxtxq;
2830 cmdline_fixed_string_t setup;
2833 /* Common CLI fields for queue setup */
2834 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2835 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2836 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2837 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, RTE_UINT16);
2838 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2839 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2840 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2841 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, RTE_UINT16);
2842 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2843 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2846 cmd_setup_rxtx_queue_parsed(
2847 void *parsed_result,
2848 __rte_unused struct cmdline *cl,
2849 __rte_unused void *data)
2851 struct cmd_setup_rxtx_queue *res = parsed_result;
2852 struct rte_port *port;
2853 struct rte_mempool *mp;
2854 unsigned int socket_id;
2858 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2861 if (res->portid == (portid_t)RTE_PORT_ALL) {
2862 printf("Invalid port id\n");
2866 if (!strcmp(res->rxtxq, "rxq"))
2868 else if (!strcmp(res->rxtxq, "txq"))
2871 printf("Unknown parameter\n");
2875 if (isrx && rx_queue_id_is_invalid(res->qid)) {
2876 printf("Invalid rx queue\n");
2878 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2879 printf("Invalid tx queue\n");
2883 port = &ports[res->portid];
2885 socket_id = rxring_numa[res->portid];
2886 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2887 socket_id = port->socket_id;
2889 mp = mbuf_pool_find(socket_id, 0);
2891 printf("Failed to setup RX queue: "
2892 "No mempool allocation"
2893 " on the socket %d\n",
2894 rxring_numa[res->portid]);
2897 ret = rx_queue_setup(res->portid,
2899 port->nb_rx_desc[res->qid],
2901 &port->rx_conf[res->qid],
2904 printf("Failed to setup RX queue\n");
2906 socket_id = txring_numa[res->portid];
2907 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2908 socket_id = port->socket_id;
2910 ret = rte_eth_tx_queue_setup(res->portid,
2912 port->nb_tx_desc[res->qid],
2914 &port->tx_conf[res->qid]);
2916 printf("Failed to setup TX queue\n");
2920 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2921 .f = cmd_setup_rxtx_queue_parsed,
2923 .help_str = "port <port_id> rxq|txq <queue_idx> setup",
2925 (void *)&cmd_setup_rxtx_queue_port,
2926 (void *)&cmd_setup_rxtx_queue_portid,
2927 (void *)&cmd_setup_rxtx_queue_rxtxq,
2928 (void *)&cmd_setup_rxtx_queue_qid,
2929 (void *)&cmd_setup_rxtx_queue_setup,
2935 /* *** Configure RSS RETA *** */
2936 struct cmd_config_rss_reta {
2937 cmdline_fixed_string_t port;
2938 cmdline_fixed_string_t keyword;
2940 cmdline_fixed_string_t name;
2941 cmdline_fixed_string_t list_name;
2942 cmdline_fixed_string_t list_of_items;
2946 parse_reta_config(const char *str,
2947 struct rte_eth_rss_reta_entry64 *reta_conf,
2948 uint16_t nb_entries)
2952 uint16_t hash_index, idx, shift;
2955 const char *p, *p0 = str;
2962 unsigned long int_fld[_NUM_FLD];
2963 char *str_fld[_NUM_FLD];
2965 while ((p = strchr(p0,'(')) != NULL) {
2967 if((p0 = strchr(p,')')) == NULL)
2971 if(size >= sizeof(s))
2974 snprintf(s, sizeof(s), "%.*s", size, p);
2975 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2977 for (i = 0; i < _NUM_FLD; i++) {
2979 int_fld[i] = strtoul(str_fld[i], &end, 0);
2980 if (errno != 0 || end == str_fld[i] ||
2985 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2986 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2988 if (hash_index >= nb_entries) {
2989 printf("Invalid RETA hash index=%d\n", hash_index);
2993 idx = hash_index / RTE_RETA_GROUP_SIZE;
2994 shift = hash_index % RTE_RETA_GROUP_SIZE;
2995 reta_conf[idx].mask |= (1ULL << shift);
2996 reta_conf[idx].reta[shift] = nb_queue;
3003 cmd_set_rss_reta_parsed(void *parsed_result,
3004 __rte_unused struct cmdline *cl,
3005 __rte_unused void *data)
3008 struct rte_eth_dev_info dev_info;
3009 struct rte_eth_rss_reta_entry64 reta_conf[8];
3010 struct cmd_config_rss_reta *res = parsed_result;
3012 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3016 if (dev_info.reta_size == 0) {
3017 printf("Redirection table size is 0 which is "
3018 "invalid for RSS\n");
3021 printf("The reta size of port %d is %u\n",
3022 res->port_id, dev_info.reta_size);
3023 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
3024 printf("Currently do not support more than %u entries of "
3025 "redirection table\n", ETH_RSS_RETA_SIZE_512);
3029 memset(reta_conf, 0, sizeof(reta_conf));
3030 if (!strcmp(res->list_name, "reta")) {
3031 if (parse_reta_config(res->list_of_items, reta_conf,
3032 dev_info.reta_size)) {
3033 printf("Invalid RSS Redirection Table "
3034 "config entered\n");
3037 ret = rte_eth_dev_rss_reta_update(res->port_id,
3038 reta_conf, dev_info.reta_size);
3040 printf("Bad redirection table parameter, "
3041 "return code = %d \n", ret);
3045 cmdline_parse_token_string_t cmd_config_rss_reta_port =
3046 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
3047 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
3048 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
3049 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
3050 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, RTE_UINT16);
3051 cmdline_parse_token_string_t cmd_config_rss_reta_name =
3052 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
3053 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
3054 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
3055 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
3056 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
3058 cmdline_parse_inst_t cmd_config_rss_reta = {
3059 .f = cmd_set_rss_reta_parsed,
3061 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
3063 (void *)&cmd_config_rss_reta_port,
3064 (void *)&cmd_config_rss_reta_keyword,
3065 (void *)&cmd_config_rss_reta_port_id,
3066 (void *)&cmd_config_rss_reta_name,
3067 (void *)&cmd_config_rss_reta_list_name,
3068 (void *)&cmd_config_rss_reta_list_of_items,
3073 /* *** SHOW PORT RETA INFO *** */
3074 struct cmd_showport_reta {
3075 cmdline_fixed_string_t show;
3076 cmdline_fixed_string_t port;
3078 cmdline_fixed_string_t rss;
3079 cmdline_fixed_string_t reta;
3081 cmdline_fixed_string_t list_of_items;
3085 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
3086 uint16_t nb_entries,
3090 const char *p, *p0 = str;
3095 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
3096 RTE_RETA_GROUP_SIZE;
3099 p = strchr(p0, '(');
3103 p0 = strchr(p, ')');
3107 if (size >= sizeof(s)) {
3108 printf("The string size exceeds the internal buffer size\n");
3111 snprintf(s, sizeof(s), "%.*s", size, p);
3112 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
3113 if (ret <= 0 || ret != num) {
3114 printf("The bits of masks do not match the number of "
3115 "reta entries: %u\n", num);
3118 for (i = 0; i < ret; i++)
3119 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
3125 cmd_showport_reta_parsed(void *parsed_result,
3126 __rte_unused struct cmdline *cl,
3127 __rte_unused void *data)
3129 struct cmd_showport_reta *res = parsed_result;
3130 struct rte_eth_rss_reta_entry64 reta_conf[8];
3131 struct rte_eth_dev_info dev_info;
3132 uint16_t max_reta_size;
3135 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3139 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
3140 if (res->size == 0 || res->size > max_reta_size) {
3141 printf("Invalid redirection table size: %u (1-%u)\n",
3142 res->size, max_reta_size);
3146 memset(reta_conf, 0, sizeof(reta_conf));
3147 if (showport_parse_reta_config(reta_conf, res->size,
3148 res->list_of_items) < 0) {
3149 printf("Invalid string: %s for reta masks\n",
3150 res->list_of_items);
3153 port_rss_reta_info(res->port_id, reta_conf, res->size);
3156 cmdline_parse_token_string_t cmd_showport_reta_show =
3157 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
3158 cmdline_parse_token_string_t cmd_showport_reta_port =
3159 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
3160 cmdline_parse_token_num_t cmd_showport_reta_port_id =
3161 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, RTE_UINT16);
3162 cmdline_parse_token_string_t cmd_showport_reta_rss =
3163 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
3164 cmdline_parse_token_string_t cmd_showport_reta_reta =
3165 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
3166 cmdline_parse_token_num_t cmd_showport_reta_size =
3167 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, RTE_UINT16);
3168 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
3169 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
3170 list_of_items, NULL);
3172 cmdline_parse_inst_t cmd_showport_reta = {
3173 .f = cmd_showport_reta_parsed,
3175 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
3177 (void *)&cmd_showport_reta_show,
3178 (void *)&cmd_showport_reta_port,
3179 (void *)&cmd_showport_reta_port_id,
3180 (void *)&cmd_showport_reta_rss,
3181 (void *)&cmd_showport_reta_reta,
3182 (void *)&cmd_showport_reta_size,
3183 (void *)&cmd_showport_reta_list_of_items,
3188 /* *** Show RSS hash configuration *** */
3189 struct cmd_showport_rss_hash {
3190 cmdline_fixed_string_t show;
3191 cmdline_fixed_string_t port;
3193 cmdline_fixed_string_t rss_hash;
3194 cmdline_fixed_string_t rss_type;
3195 cmdline_fixed_string_t key; /* optional argument */
3198 static void cmd_showport_rss_hash_parsed(void *parsed_result,
3199 __rte_unused struct cmdline *cl,
3202 struct cmd_showport_rss_hash *res = parsed_result;
3204 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
3207 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
3208 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
3209 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
3210 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
3211 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
3212 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id,
3214 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
3215 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
3217 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
3218 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
3220 cmdline_parse_inst_t cmd_showport_rss_hash = {
3221 .f = cmd_showport_rss_hash_parsed,
3223 .help_str = "show port <port_id> rss-hash",
3225 (void *)&cmd_showport_rss_hash_show,
3226 (void *)&cmd_showport_rss_hash_port,
3227 (void *)&cmd_showport_rss_hash_port_id,
3228 (void *)&cmd_showport_rss_hash_rss_hash,
3233 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
3234 .f = cmd_showport_rss_hash_parsed,
3236 .help_str = "show port <port_id> rss-hash key",
3238 (void *)&cmd_showport_rss_hash_show,
3239 (void *)&cmd_showport_rss_hash_port,
3240 (void *)&cmd_showport_rss_hash_port_id,
3241 (void *)&cmd_showport_rss_hash_rss_hash,
3242 (void *)&cmd_showport_rss_hash_rss_key,
3247 /* *** Configure DCB *** */
3248 struct cmd_config_dcb {
3249 cmdline_fixed_string_t port;
3250 cmdline_fixed_string_t config;
3252 cmdline_fixed_string_t dcb;
3253 cmdline_fixed_string_t vt;
3254 cmdline_fixed_string_t vt_en;
3256 cmdline_fixed_string_t pfc;
3257 cmdline_fixed_string_t pfc_en;
3261 cmd_config_dcb_parsed(void *parsed_result,
3262 __rte_unused struct cmdline *cl,
3263 __rte_unused void *data)
3265 struct cmd_config_dcb *res = parsed_result;
3266 portid_t port_id = res->port_id;
3267 struct rte_port *port;
3271 port = &ports[port_id];
3272 /** Check if the port is not started **/
3273 if (port->port_status != RTE_PORT_STOPPED) {
3274 printf("Please stop port %d first\n", port_id);
3278 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
3279 printf("The invalid number of traffic class,"
3280 " only 4 or 8 allowed.\n");
3284 if (nb_fwd_lcores < res->num_tcs) {
3285 printf("nb_cores shouldn't be less than number of TCs.\n");
3288 if (!strncmp(res->pfc_en, "on", 2))
3293 /* DCB in VT mode */
3294 if (!strncmp(res->vt_en, "on", 2))
3295 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3296 (enum rte_eth_nb_tcs)res->num_tcs,
3299 ret = init_port_dcb_config(port_id, DCB_ENABLED,
3300 (enum rte_eth_nb_tcs)res->num_tcs,
3305 printf("Cannot initialize network ports.\n");
3309 cmd_reconfig_device_queue(port_id, 1, 1);
3312 cmdline_parse_token_string_t cmd_config_dcb_port =
3313 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3314 cmdline_parse_token_string_t cmd_config_dcb_config =
3315 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3316 cmdline_parse_token_num_t cmd_config_dcb_port_id =
3317 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, RTE_UINT16);
3318 cmdline_parse_token_string_t cmd_config_dcb_dcb =
3319 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3320 cmdline_parse_token_string_t cmd_config_dcb_vt =
3321 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3322 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3323 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3324 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3325 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, RTE_UINT8);
3326 cmdline_parse_token_string_t cmd_config_dcb_pfc=
3327 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3328 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
3329 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
3331 cmdline_parse_inst_t cmd_config_dcb = {
3332 .f = cmd_config_dcb_parsed,
3334 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
3336 (void *)&cmd_config_dcb_port,
3337 (void *)&cmd_config_dcb_config,
3338 (void *)&cmd_config_dcb_port_id,
3339 (void *)&cmd_config_dcb_dcb,
3340 (void *)&cmd_config_dcb_vt,
3341 (void *)&cmd_config_dcb_vt_en,
3342 (void *)&cmd_config_dcb_num_tcs,
3343 (void *)&cmd_config_dcb_pfc,
3344 (void *)&cmd_config_dcb_pfc_en,
3349 /* *** configure number of packets per burst *** */
3350 struct cmd_config_burst {
3351 cmdline_fixed_string_t port;
3352 cmdline_fixed_string_t keyword;
3353 cmdline_fixed_string_t all;
3354 cmdline_fixed_string_t name;
3359 cmd_config_burst_parsed(void *parsed_result,
3360 __rte_unused struct cmdline *cl,
3361 __rte_unused void *data)
3363 struct cmd_config_burst *res = parsed_result;
3364 struct rte_eth_dev_info dev_info;
3365 uint16_t rec_nb_pkts;
3368 if (!all_ports_stopped()) {
3369 printf("Please stop all ports first\n");
3373 if (!strcmp(res->name, "burst")) {
3374 if (res->value == 0) {
3375 /* If user gives a value of zero, query the PMD for
3376 * its recommended Rx burst size. Testpmd uses a single
3377 * size for all ports, so assume all ports are the same
3378 * NIC model and use the values from Port 0.
3380 ret = eth_dev_info_get_print_err(0, &dev_info);
3384 rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3386 if (rec_nb_pkts == 0) {
3387 printf("PMD does not recommend a burst size.\n"
3388 "User provided value must be between"
3389 " 1 and %d\n", MAX_PKT_BURST);
3391 } else if (rec_nb_pkts > MAX_PKT_BURST) {
3392 printf("PMD recommended burst size of %d"
3393 " exceeds maximum value of %d\n",
3394 rec_nb_pkts, MAX_PKT_BURST);
3397 printf("Using PMD-provided burst value of %d\n",
3399 nb_pkt_per_burst = rec_nb_pkts;
3400 } else if (res->value > MAX_PKT_BURST) {
3401 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
3404 nb_pkt_per_burst = res->value;
3406 printf("Unknown parameter\n");
3412 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3415 cmdline_parse_token_string_t cmd_config_burst_port =
3416 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3417 cmdline_parse_token_string_t cmd_config_burst_keyword =
3418 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3419 cmdline_parse_token_string_t cmd_config_burst_all =
3420 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3421 cmdline_parse_token_string_t cmd_config_burst_name =
3422 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3423 cmdline_parse_token_num_t cmd_config_burst_value =
3424 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, RTE_UINT16);
3426 cmdline_parse_inst_t cmd_config_burst = {
3427 .f = cmd_config_burst_parsed,
3429 .help_str = "port config all burst <value>",
3431 (void *)&cmd_config_burst_port,
3432 (void *)&cmd_config_burst_keyword,
3433 (void *)&cmd_config_burst_all,
3434 (void *)&cmd_config_burst_name,
3435 (void *)&cmd_config_burst_value,
3440 /* *** configure rx/tx queues *** */
3441 struct cmd_config_thresh {
3442 cmdline_fixed_string_t port;
3443 cmdline_fixed_string_t keyword;
3444 cmdline_fixed_string_t all;
3445 cmdline_fixed_string_t name;
3450 cmd_config_thresh_parsed(void *parsed_result,
3451 __rte_unused struct cmdline *cl,
3452 __rte_unused void *data)
3454 struct cmd_config_thresh *res = parsed_result;
3456 if (!all_ports_stopped()) {
3457 printf("Please stop all ports first\n");
3461 if (!strcmp(res->name, "txpt"))
3462 tx_pthresh = res->value;
3463 else if(!strcmp(res->name, "txht"))
3464 tx_hthresh = res->value;
3465 else if(!strcmp(res->name, "txwt"))
3466 tx_wthresh = res->value;
3467 else if(!strcmp(res->name, "rxpt"))
3468 rx_pthresh = res->value;
3469 else if(!strcmp(res->name, "rxht"))
3470 rx_hthresh = res->value;
3471 else if(!strcmp(res->name, "rxwt"))
3472 rx_wthresh = res->value;
3474 printf("Unknown parameter\n");
3480 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3483 cmdline_parse_token_string_t cmd_config_thresh_port =
3484 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3485 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3486 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3487 cmdline_parse_token_string_t cmd_config_thresh_all =
3488 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3489 cmdline_parse_token_string_t cmd_config_thresh_name =
3490 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3491 "txpt#txht#txwt#rxpt#rxht#rxwt");
3492 cmdline_parse_token_num_t cmd_config_thresh_value =
3493 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, RTE_UINT8);
3495 cmdline_parse_inst_t cmd_config_thresh = {
3496 .f = cmd_config_thresh_parsed,
3498 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3500 (void *)&cmd_config_thresh_port,
3501 (void *)&cmd_config_thresh_keyword,
3502 (void *)&cmd_config_thresh_all,
3503 (void *)&cmd_config_thresh_name,
3504 (void *)&cmd_config_thresh_value,
3509 /* *** configure free/rs threshold *** */
3510 struct cmd_config_threshold {
3511 cmdline_fixed_string_t port;
3512 cmdline_fixed_string_t keyword;
3513 cmdline_fixed_string_t all;
3514 cmdline_fixed_string_t name;
3519 cmd_config_threshold_parsed(void *parsed_result,
3520 __rte_unused struct cmdline *cl,
3521 __rte_unused void *data)
3523 struct cmd_config_threshold *res = parsed_result;
3525 if (!all_ports_stopped()) {
3526 printf("Please stop all ports first\n");
3530 if (!strcmp(res->name, "txfreet"))
3531 tx_free_thresh = res->value;
3532 else if (!strcmp(res->name, "txrst"))
3533 tx_rs_thresh = res->value;
3534 else if (!strcmp(res->name, "rxfreet"))
3535 rx_free_thresh = res->value;
3537 printf("Unknown parameter\n");
3543 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3546 cmdline_parse_token_string_t cmd_config_threshold_port =
3547 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3548 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3549 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3551 cmdline_parse_token_string_t cmd_config_threshold_all =
3552 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3553 cmdline_parse_token_string_t cmd_config_threshold_name =
3554 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3555 "txfreet#txrst#rxfreet");
3556 cmdline_parse_token_num_t cmd_config_threshold_value =
3557 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, RTE_UINT16);
3559 cmdline_parse_inst_t cmd_config_threshold = {
3560 .f = cmd_config_threshold_parsed,
3562 .help_str = "port config all txfreet|txrst|rxfreet <value>",
3564 (void *)&cmd_config_threshold_port,
3565 (void *)&cmd_config_threshold_keyword,
3566 (void *)&cmd_config_threshold_all,
3567 (void *)&cmd_config_threshold_name,
3568 (void *)&cmd_config_threshold_value,
3574 struct cmd_stop_result {
3575 cmdline_fixed_string_t stop;
3578 static void cmd_stop_parsed(__rte_unused void *parsed_result,
3579 __rte_unused struct cmdline *cl,
3580 __rte_unused void *data)
3582 stop_packet_forwarding();
3585 cmdline_parse_token_string_t cmd_stop_stop =
3586 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3588 cmdline_parse_inst_t cmd_stop = {
3589 .f = cmd_stop_parsed,
3591 .help_str = "stop: Stop packet forwarding",
3593 (void *)&cmd_stop_stop,
3598 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3601 parse_item_list(char* str, const char* item_name, unsigned int max_items,
3602 unsigned int *parsed_items, int check_unique_values)
3604 unsigned int nb_item;
3612 * First parse all items in the list and store their value.
3617 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3619 if ((c >= '0') && (c <= '9')) {
3620 value = (unsigned int) (value * 10 + (c - '0'));
3625 printf("character %c is not a decimal digit\n", c);
3629 printf("No valid value before comma\n");
3632 if (nb_item < max_items) {
3633 parsed_items[nb_item] = value;
3639 if (nb_item >= max_items) {
3640 printf("Number of %s = %u > %u (maximum items)\n",
3641 item_name, nb_item + 1, max_items);
3644 parsed_items[nb_item++] = value;
3645 if (! check_unique_values)
3649 * Then, check that all values in the list are differents.
3650 * No optimization here...
3652 for (i = 0; i < nb_item; i++) {
3653 for (j = i + 1; j < nb_item; j++) {
3654 if (parsed_items[j] == parsed_items[i]) {
3655 printf("duplicated %s %u at index %u and %u\n",
3656 item_name, parsed_items[i], i, j);
3664 struct cmd_set_list_result {
3665 cmdline_fixed_string_t cmd_keyword;
3666 cmdline_fixed_string_t list_name;
3667 cmdline_fixed_string_t list_of_items;
3670 static void cmd_set_list_parsed(void *parsed_result,
3671 __rte_unused struct cmdline *cl,
3672 __rte_unused void *data)
3674 struct cmd_set_list_result *res;
3676 unsigned int lcorelist[RTE_MAX_LCORE];
3677 unsigned int portlist[RTE_MAX_ETHPORTS];
3679 unsigned int nb_item;
3681 if (test_done == 0) {
3682 printf("Please stop forwarding first\n");
3686 res = parsed_result;
3687 if (!strcmp(res->list_name, "corelist")) {
3688 nb_item = parse_item_list(res->list_of_items, "core",
3690 parsed_items.lcorelist, 1);
3692 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3697 if (!strcmp(res->list_name, "portlist")) {
3698 nb_item = parse_item_list(res->list_of_items, "port",
3700 parsed_items.portlist, 1);
3702 set_fwd_ports_list(parsed_items.portlist, nb_item);
3708 cmdline_parse_token_string_t cmd_set_list_keyword =
3709 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3711 cmdline_parse_token_string_t cmd_set_list_name =
3712 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3713 "corelist#portlist");
3714 cmdline_parse_token_string_t cmd_set_list_of_items =
3715 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3718 cmdline_parse_inst_t cmd_set_fwd_list = {
3719 .f = cmd_set_list_parsed,
3721 .help_str = "set corelist|portlist <list0[,list1]*>",
3723 (void *)&cmd_set_list_keyword,
3724 (void *)&cmd_set_list_name,
3725 (void *)&cmd_set_list_of_items,
3730 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3732 struct cmd_setmask_result {
3733 cmdline_fixed_string_t set;
3734 cmdline_fixed_string_t mask;
3738 static void cmd_set_mask_parsed(void *parsed_result,
3739 __rte_unused struct cmdline *cl,
3740 __rte_unused void *data)
3742 struct cmd_setmask_result *res = parsed_result;
3744 if (test_done == 0) {
3745 printf("Please stop forwarding first\n");
3748 if (!strcmp(res->mask, "coremask")) {
3749 set_fwd_lcores_mask(res->hexavalue);
3751 } else if (!strcmp(res->mask, "portmask")) {
3752 set_fwd_ports_mask(res->hexavalue);
3757 cmdline_parse_token_string_t cmd_setmask_set =
3758 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3759 cmdline_parse_token_string_t cmd_setmask_mask =
3760 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3761 "coremask#portmask");
3762 cmdline_parse_token_num_t cmd_setmask_value =
3763 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, RTE_UINT64);
3765 cmdline_parse_inst_t cmd_set_fwd_mask = {
3766 .f = cmd_set_mask_parsed,
3768 .help_str = "set coremask|portmask <hexadecimal value>",
3770 (void *)&cmd_setmask_set,
3771 (void *)&cmd_setmask_mask,
3772 (void *)&cmd_setmask_value,
3778 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3780 struct cmd_set_result {
3781 cmdline_fixed_string_t set;
3782 cmdline_fixed_string_t what;
3786 static void cmd_set_parsed(void *parsed_result,
3787 __rte_unused struct cmdline *cl,
3788 __rte_unused void *data)
3790 struct cmd_set_result *res = parsed_result;
3791 if (!strcmp(res->what, "nbport")) {
3792 set_fwd_ports_number(res->value);
3794 } else if (!strcmp(res->what, "nbcore")) {
3795 set_fwd_lcores_number(res->value);
3797 } else if (!strcmp(res->what, "burst"))
3798 set_nb_pkt_per_burst(res->value);
3799 else if (!strcmp(res->what, "verbose"))
3800 set_verbose_level(res->value);
3803 cmdline_parse_token_string_t cmd_set_set =
3804 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3805 cmdline_parse_token_string_t cmd_set_what =
3806 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3807 "nbport#nbcore#burst#verbose");
3808 cmdline_parse_token_num_t cmd_set_value =
3809 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, RTE_UINT16);
3811 cmdline_parse_inst_t cmd_set_numbers = {
3812 .f = cmd_set_parsed,
3814 .help_str = "set nbport|nbcore|burst|verbose <value>",
3816 (void *)&cmd_set_set,
3817 (void *)&cmd_set_what,
3818 (void *)&cmd_set_value,
3823 /* *** SET LOG LEVEL CONFIGURATION *** */
3825 struct cmd_set_log_result {
3826 cmdline_fixed_string_t set;
3827 cmdline_fixed_string_t log;
3828 cmdline_fixed_string_t type;
3833 cmd_set_log_parsed(void *parsed_result,
3834 __rte_unused struct cmdline *cl,
3835 __rte_unused void *data)
3837 struct cmd_set_log_result *res;
3840 res = parsed_result;
3841 if (!strcmp(res->type, "global"))
3842 rte_log_set_global_level(res->level);
3844 ret = rte_log_set_level_regexp(res->type, res->level);
3846 printf("Unable to set log level\n");
3850 cmdline_parse_token_string_t cmd_set_log_set =
3851 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3852 cmdline_parse_token_string_t cmd_set_log_log =
3853 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3854 cmdline_parse_token_string_t cmd_set_log_type =
3855 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3856 cmdline_parse_token_num_t cmd_set_log_level =
3857 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, RTE_UINT32);
3859 cmdline_parse_inst_t cmd_set_log = {
3860 .f = cmd_set_log_parsed,
3862 .help_str = "set log global|<type> <level>",
3864 (void *)&cmd_set_log_set,
3865 (void *)&cmd_set_log_log,
3866 (void *)&cmd_set_log_type,
3867 (void *)&cmd_set_log_level,
3872 /* *** SET SEGMENT OFFSETS OF RX PACKETS SPLIT *** */
3874 struct cmd_set_rxoffs_result {
3875 cmdline_fixed_string_t cmd_keyword;
3876 cmdline_fixed_string_t rxoffs;
3877 cmdline_fixed_string_t seg_offsets;
3881 cmd_set_rxoffs_parsed(void *parsed_result,
3882 __rte_unused struct cmdline *cl,
3883 __rte_unused void *data)
3885 struct cmd_set_rxoffs_result *res;
3886 unsigned int seg_offsets[MAX_SEGS_BUFFER_SPLIT];
3887 unsigned int nb_segs;
3889 res = parsed_result;
3890 nb_segs = parse_item_list(res->seg_offsets, "segment offsets",
3891 MAX_SEGS_BUFFER_SPLIT, seg_offsets, 0);
3893 set_rx_pkt_offsets(seg_offsets, nb_segs);
3894 cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
3897 cmdline_parse_token_string_t cmd_set_rxoffs_keyword =
3898 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3899 cmd_keyword, "set");
3900 cmdline_parse_token_string_t cmd_set_rxoffs_name =
3901 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3903 cmdline_parse_token_string_t cmd_set_rxoffs_offsets =
3904 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3907 cmdline_parse_inst_t cmd_set_rxoffs = {
3908 .f = cmd_set_rxoffs_parsed,
3910 .help_str = "set rxoffs <len0[,len1]*>",
3912 (void *)&cmd_set_rxoffs_keyword,
3913 (void *)&cmd_set_rxoffs_name,
3914 (void *)&cmd_set_rxoffs_offsets,
3919 /* *** SET SEGMENT LENGTHS OF RX PACKETS SPLIT *** */
3921 struct cmd_set_rxpkts_result {
3922 cmdline_fixed_string_t cmd_keyword;
3923 cmdline_fixed_string_t rxpkts;
3924 cmdline_fixed_string_t seg_lengths;
3928 cmd_set_rxpkts_parsed(void *parsed_result,
3929 __rte_unused struct cmdline *cl,
3930 __rte_unused void *data)
3932 struct cmd_set_rxpkts_result *res;
3933 unsigned int seg_lengths[MAX_SEGS_BUFFER_SPLIT];
3934 unsigned int nb_segs;
3936 res = parsed_result;
3937 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3938 MAX_SEGS_BUFFER_SPLIT, seg_lengths, 0);
3940 set_rx_pkt_segments(seg_lengths, nb_segs);
3941 cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
3944 cmdline_parse_token_string_t cmd_set_rxpkts_keyword =
3945 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3946 cmd_keyword, "set");
3947 cmdline_parse_token_string_t cmd_set_rxpkts_name =
3948 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3950 cmdline_parse_token_string_t cmd_set_rxpkts_lengths =
3951 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3954 cmdline_parse_inst_t cmd_set_rxpkts = {
3955 .f = cmd_set_rxpkts_parsed,
3957 .help_str = "set rxpkts <len0[,len1]*>",
3959 (void *)&cmd_set_rxpkts_keyword,
3960 (void *)&cmd_set_rxpkts_name,
3961 (void *)&cmd_set_rxpkts_lengths,
3966 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3968 struct cmd_set_txpkts_result {
3969 cmdline_fixed_string_t cmd_keyword;
3970 cmdline_fixed_string_t txpkts;
3971 cmdline_fixed_string_t seg_lengths;
3975 cmd_set_txpkts_parsed(void *parsed_result,
3976 __rte_unused struct cmdline *cl,
3977 __rte_unused void *data)
3979 struct cmd_set_txpkts_result *res;
3980 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3981 unsigned int nb_segs;
3983 res = parsed_result;
3984 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3985 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3987 set_tx_pkt_segments(seg_lengths, nb_segs);
3990 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3991 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3992 cmd_keyword, "set");
3993 cmdline_parse_token_string_t cmd_set_txpkts_name =
3994 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3996 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3997 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4000 cmdline_parse_inst_t cmd_set_txpkts = {
4001 .f = cmd_set_txpkts_parsed,
4003 .help_str = "set txpkts <len0[,len1]*>",
4005 (void *)&cmd_set_txpkts_keyword,
4006 (void *)&cmd_set_txpkts_name,
4007 (void *)&cmd_set_txpkts_lengths,
4012 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
4014 struct cmd_set_txsplit_result {
4015 cmdline_fixed_string_t cmd_keyword;
4016 cmdline_fixed_string_t txsplit;
4017 cmdline_fixed_string_t mode;
4021 cmd_set_txsplit_parsed(void *parsed_result,
4022 __rte_unused struct cmdline *cl,
4023 __rte_unused void *data)
4025 struct cmd_set_txsplit_result *res;
4027 res = parsed_result;
4028 set_tx_pkt_split(res->mode);
4031 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
4032 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4033 cmd_keyword, "set");
4034 cmdline_parse_token_string_t cmd_set_txsplit_name =
4035 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4036 txsplit, "txsplit");
4037 cmdline_parse_token_string_t cmd_set_txsplit_mode =
4038 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4041 cmdline_parse_inst_t cmd_set_txsplit = {
4042 .f = cmd_set_txsplit_parsed,
4044 .help_str = "set txsplit on|off|rand",
4046 (void *)&cmd_set_txsplit_keyword,
4047 (void *)&cmd_set_txsplit_name,
4048 (void *)&cmd_set_txsplit_mode,
4053 /* *** SET TIMES FOR TXONLY PACKETS SCHEDULING ON TIMESTAMPS *** */
4055 struct cmd_set_txtimes_result {
4056 cmdline_fixed_string_t cmd_keyword;
4057 cmdline_fixed_string_t txtimes;
4058 cmdline_fixed_string_t tx_times;
4062 cmd_set_txtimes_parsed(void *parsed_result,
4063 __rte_unused struct cmdline *cl,
4064 __rte_unused void *data)
4066 struct cmd_set_txtimes_result *res;
4067 unsigned int tx_times[2] = {0, 0};
4068 unsigned int n_times;
4070 res = parsed_result;
4071 n_times = parse_item_list(res->tx_times, "tx times",
4074 set_tx_pkt_times(tx_times);
4077 cmdline_parse_token_string_t cmd_set_txtimes_keyword =
4078 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4079 cmd_keyword, "set");
4080 cmdline_parse_token_string_t cmd_set_txtimes_name =
4081 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4082 txtimes, "txtimes");
4083 cmdline_parse_token_string_t cmd_set_txtimes_value =
4084 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4087 cmdline_parse_inst_t cmd_set_txtimes = {
4088 .f = cmd_set_txtimes_parsed,
4090 .help_str = "set txtimes <inter_burst>,<intra_burst>",
4092 (void *)&cmd_set_txtimes_keyword,
4093 (void *)&cmd_set_txtimes_name,
4094 (void *)&cmd_set_txtimes_value,
4099 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
4100 struct cmd_rx_vlan_filter_all_result {
4101 cmdline_fixed_string_t rx_vlan;
4102 cmdline_fixed_string_t what;
4103 cmdline_fixed_string_t all;
4108 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
4109 __rte_unused struct cmdline *cl,
4110 __rte_unused void *data)
4112 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
4114 if (!strcmp(res->what, "add"))
4115 rx_vlan_all_filter_set(res->port_id, 1);
4117 rx_vlan_all_filter_set(res->port_id, 0);
4120 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
4121 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4122 rx_vlan, "rx_vlan");
4123 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
4124 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4126 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
4127 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4129 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
4130 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4131 port_id, RTE_UINT16);
4133 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
4134 .f = cmd_rx_vlan_filter_all_parsed,
4136 .help_str = "rx_vlan add|rm all <port_id>: "
4137 "Add/Remove all identifiers to/from the set of VLAN "
4138 "identifiers filtered by a port",
4140 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
4141 (void *)&cmd_rx_vlan_filter_all_what,
4142 (void *)&cmd_rx_vlan_filter_all_all,
4143 (void *)&cmd_rx_vlan_filter_all_portid,
4148 /* *** VLAN OFFLOAD SET ON A PORT *** */
4149 struct cmd_vlan_offload_result {
4150 cmdline_fixed_string_t vlan;
4151 cmdline_fixed_string_t set;
4152 cmdline_fixed_string_t vlan_type;
4153 cmdline_fixed_string_t what;
4154 cmdline_fixed_string_t on;
4155 cmdline_fixed_string_t port_id;
4159 cmd_vlan_offload_parsed(void *parsed_result,
4160 __rte_unused struct cmdline *cl,
4161 __rte_unused void *data)
4164 struct cmd_vlan_offload_result *res = parsed_result;
4167 portid_t port_id = 0;
4171 len = strnlen(str, STR_TOKEN_SIZE);
4173 /* Get port_id first */
4181 tmp = strtoul(str, NULL, 0);
4182 /* If port_id greater that what portid_t can represent, return */
4183 if(tmp >= RTE_MAX_ETHPORTS)
4185 port_id = (portid_t)tmp;
4187 if (!strcmp(res->on, "on"))
4192 if (!strcmp(res->what, "strip"))
4193 rx_vlan_strip_set(port_id, on);
4194 else if(!strcmp(res->what, "stripq")){
4195 uint16_t queue_id = 0;
4197 /* No queue_id, return */
4199 printf("must specify (port,queue_id)\n");
4202 tmp = strtoul(str + i + 1, NULL, 0);
4203 /* If queue_id greater that what 16-bits can represent, return */
4207 queue_id = (uint16_t)tmp;
4208 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
4210 else if (!strcmp(res->what, "filter"))
4211 rx_vlan_filter_set(port_id, on);
4212 else if (!strcmp(res->what, "qinq_strip"))
4213 rx_vlan_qinq_strip_set(port_id, on);
4215 vlan_extend_set(port_id, on);
4220 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
4221 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4223 cmdline_parse_token_string_t cmd_vlan_offload_set =
4224 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4226 cmdline_parse_token_string_t cmd_vlan_offload_what =
4227 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4228 what, "strip#filter#qinq_strip#extend#stripq");
4229 cmdline_parse_token_string_t cmd_vlan_offload_on =
4230 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4232 cmdline_parse_token_string_t cmd_vlan_offload_portid =
4233 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4236 cmdline_parse_inst_t cmd_vlan_offload = {
4237 .f = cmd_vlan_offload_parsed,
4239 .help_str = "vlan set strip|filter|qinq_strip|extend|stripq on|off "
4240 "<port_id[,queue_id]>: "
4241 "Strip/Filter/QinQ for rx side Extend for both rx/tx sides",
4243 (void *)&cmd_vlan_offload_vlan,
4244 (void *)&cmd_vlan_offload_set,
4245 (void *)&cmd_vlan_offload_what,
4246 (void *)&cmd_vlan_offload_on,
4247 (void *)&cmd_vlan_offload_portid,
4252 /* *** VLAN TPID SET ON A PORT *** */
4253 struct cmd_vlan_tpid_result {
4254 cmdline_fixed_string_t vlan;
4255 cmdline_fixed_string_t set;
4256 cmdline_fixed_string_t vlan_type;
4257 cmdline_fixed_string_t what;
4263 cmd_vlan_tpid_parsed(void *parsed_result,
4264 __rte_unused struct cmdline *cl,
4265 __rte_unused void *data)
4267 struct cmd_vlan_tpid_result *res = parsed_result;
4268 enum rte_vlan_type vlan_type;
4270 if (!strcmp(res->vlan_type, "inner"))
4271 vlan_type = ETH_VLAN_TYPE_INNER;
4272 else if (!strcmp(res->vlan_type, "outer"))
4273 vlan_type = ETH_VLAN_TYPE_OUTER;
4275 printf("Unknown vlan type\n");
4278 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
4281 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
4282 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4284 cmdline_parse_token_string_t cmd_vlan_tpid_set =
4285 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4287 cmdline_parse_token_string_t cmd_vlan_type =
4288 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4289 vlan_type, "inner#outer");
4290 cmdline_parse_token_string_t cmd_vlan_tpid_what =
4291 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4293 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
4294 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4296 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
4297 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4298 port_id, RTE_UINT16);
4300 cmdline_parse_inst_t cmd_vlan_tpid = {
4301 .f = cmd_vlan_tpid_parsed,
4303 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
4304 "Set the VLAN Ether type",
4306 (void *)&cmd_vlan_tpid_vlan,
4307 (void *)&cmd_vlan_tpid_set,
4308 (void *)&cmd_vlan_type,
4309 (void *)&cmd_vlan_tpid_what,
4310 (void *)&cmd_vlan_tpid_tpid,
4311 (void *)&cmd_vlan_tpid_portid,
4316 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4317 struct cmd_rx_vlan_filter_result {
4318 cmdline_fixed_string_t rx_vlan;
4319 cmdline_fixed_string_t what;
4325 cmd_rx_vlan_filter_parsed(void *parsed_result,
4326 __rte_unused struct cmdline *cl,
4327 __rte_unused void *data)
4329 struct cmd_rx_vlan_filter_result *res = parsed_result;
4331 if (!strcmp(res->what, "add"))
4332 rx_vft_set(res->port_id, res->vlan_id, 1);
4334 rx_vft_set(res->port_id, res->vlan_id, 0);
4337 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
4338 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4339 rx_vlan, "rx_vlan");
4340 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
4341 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4343 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
4344 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4345 vlan_id, RTE_UINT16);
4346 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
4347 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4348 port_id, RTE_UINT16);
4350 cmdline_parse_inst_t cmd_rx_vlan_filter = {
4351 .f = cmd_rx_vlan_filter_parsed,
4353 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
4354 "Add/Remove a VLAN identifier to/from the set of VLAN "
4355 "identifiers filtered by a port",
4357 (void *)&cmd_rx_vlan_filter_rx_vlan,
4358 (void *)&cmd_rx_vlan_filter_what,
4359 (void *)&cmd_rx_vlan_filter_vlanid,
4360 (void *)&cmd_rx_vlan_filter_portid,
4365 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4366 struct cmd_tx_vlan_set_result {
4367 cmdline_fixed_string_t tx_vlan;
4368 cmdline_fixed_string_t set;
4374 cmd_tx_vlan_set_parsed(void *parsed_result,
4375 __rte_unused struct cmdline *cl,
4376 __rte_unused void *data)
4378 struct cmd_tx_vlan_set_result *res = parsed_result;
4380 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4383 if (!port_is_stopped(res->port_id)) {
4384 printf("Please stop port %d first\n", res->port_id);
4388 tx_vlan_set(res->port_id, res->vlan_id);
4390 cmd_reconfig_device_queue(res->port_id, 1, 1);
4393 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4394 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4395 tx_vlan, "tx_vlan");
4396 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4397 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4399 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4400 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4401 port_id, RTE_UINT16);
4402 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
4403 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4404 vlan_id, RTE_UINT16);
4406 cmdline_parse_inst_t cmd_tx_vlan_set = {
4407 .f = cmd_tx_vlan_set_parsed,
4409 .help_str = "tx_vlan set <port_id> <vlan_id>: "
4410 "Enable hardware insertion of a single VLAN header "
4411 "with a given TAG Identifier in packets sent on a port",
4413 (void *)&cmd_tx_vlan_set_tx_vlan,
4414 (void *)&cmd_tx_vlan_set_set,
4415 (void *)&cmd_tx_vlan_set_portid,
4416 (void *)&cmd_tx_vlan_set_vlanid,
4421 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4422 struct cmd_tx_vlan_set_qinq_result {
4423 cmdline_fixed_string_t tx_vlan;
4424 cmdline_fixed_string_t set;
4427 uint16_t vlan_id_outer;
4431 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4432 __rte_unused struct cmdline *cl,
4433 __rte_unused void *data)
4435 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
4437 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4440 if (!port_is_stopped(res->port_id)) {
4441 printf("Please stop port %d first\n", res->port_id);
4445 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
4447 cmd_reconfig_device_queue(res->port_id, 1, 1);
4450 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
4451 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4452 tx_vlan, "tx_vlan");
4453 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
4454 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4456 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
4457 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4458 port_id, RTE_UINT16);
4459 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
4460 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4461 vlan_id, RTE_UINT16);
4462 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
4463 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4464 vlan_id_outer, RTE_UINT16);
4466 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
4467 .f = cmd_tx_vlan_set_qinq_parsed,
4469 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
4470 "Enable hardware insertion of double VLAN header "
4471 "with given TAG Identifiers in packets sent on a port",
4473 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
4474 (void *)&cmd_tx_vlan_set_qinq_set,
4475 (void *)&cmd_tx_vlan_set_qinq_portid,
4476 (void *)&cmd_tx_vlan_set_qinq_vlanid,
4477 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
4482 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
4483 struct cmd_tx_vlan_set_pvid_result {
4484 cmdline_fixed_string_t tx_vlan;
4485 cmdline_fixed_string_t set;
4486 cmdline_fixed_string_t pvid;
4489 cmdline_fixed_string_t mode;
4493 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
4494 __rte_unused struct cmdline *cl,
4495 __rte_unused void *data)
4497 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
4499 if (strcmp(res->mode, "on") == 0)
4500 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
4502 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
4505 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
4506 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4507 tx_vlan, "tx_vlan");
4508 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
4509 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4511 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
4512 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4514 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
4515 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4516 port_id, RTE_UINT16);
4517 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
4518 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4519 vlan_id, RTE_UINT16);
4520 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
4521 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4524 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
4525 .f = cmd_tx_vlan_set_pvid_parsed,
4527 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
4529 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
4530 (void *)&cmd_tx_vlan_set_pvid_set,
4531 (void *)&cmd_tx_vlan_set_pvid_pvid,
4532 (void *)&cmd_tx_vlan_set_pvid_port_id,
4533 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
4534 (void *)&cmd_tx_vlan_set_pvid_mode,
4539 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4540 struct cmd_tx_vlan_reset_result {
4541 cmdline_fixed_string_t tx_vlan;
4542 cmdline_fixed_string_t reset;
4547 cmd_tx_vlan_reset_parsed(void *parsed_result,
4548 __rte_unused struct cmdline *cl,
4549 __rte_unused void *data)
4551 struct cmd_tx_vlan_reset_result *res = parsed_result;
4553 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4556 if (!port_is_stopped(res->port_id)) {
4557 printf("Please stop port %d first\n", res->port_id);
4561 tx_vlan_reset(res->port_id);
4563 cmd_reconfig_device_queue(res->port_id, 1, 1);
4566 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4567 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4568 tx_vlan, "tx_vlan");
4569 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4570 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4572 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4573 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4574 port_id, RTE_UINT16);
4576 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4577 .f = cmd_tx_vlan_reset_parsed,
4579 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4580 "VLAN header in packets sent on a port",
4582 (void *)&cmd_tx_vlan_reset_tx_vlan,
4583 (void *)&cmd_tx_vlan_reset_reset,
4584 (void *)&cmd_tx_vlan_reset_portid,
4590 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4591 struct cmd_csum_result {
4592 cmdline_fixed_string_t csum;
4593 cmdline_fixed_string_t mode;
4594 cmdline_fixed_string_t proto;
4595 cmdline_fixed_string_t hwsw;
4600 csum_show(int port_id)
4602 struct rte_eth_dev_info dev_info;
4603 uint64_t tx_offloads;
4606 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4607 printf("Parse tunnel is %s\n",
4608 (ports[port_id].parse_tunnel) ? "on" : "off");
4609 printf("IP checksum offload is %s\n",
4610 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4611 printf("UDP checksum offload is %s\n",
4612 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4613 printf("TCP checksum offload is %s\n",
4614 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4615 printf("SCTP checksum offload is %s\n",
4616 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4617 printf("Outer-Ip checksum offload is %s\n",
4618 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4619 printf("Outer-Udp checksum offload is %s\n",
4620 (tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
4622 /* display warnings if configuration is not supported by the NIC */
4623 ret = eth_dev_info_get_print_err(port_id, &dev_info);
4627 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
4628 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4629 printf("Warning: hardware IP checksum enabled but not "
4630 "supported by port %d\n", port_id);
4632 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
4633 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
4634 printf("Warning: hardware UDP checksum enabled but not "
4635 "supported by port %d\n", port_id);
4637 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
4638 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
4639 printf("Warning: hardware TCP checksum enabled but not "
4640 "supported by port %d\n", port_id);
4642 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
4643 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4644 printf("Warning: hardware SCTP checksum enabled but not "
4645 "supported by port %d\n", port_id);
4647 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4648 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4649 printf("Warning: hardware outer IP checksum enabled but not "
4650 "supported by port %d\n", port_id);
4652 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
4653 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)
4655 printf("Warning: hardware outer UDP checksum enabled but not "
4656 "supported by port %d\n", port_id);
4661 cmd_config_queue_tx_offloads(struct rte_port *port)
4665 /* Apply queue tx offloads configuration */
4666 for (k = 0; k < port->dev_info.max_rx_queues; k++)
4667 port->tx_conf[k].offloads =
4668 port->dev_conf.txmode.offloads;
4672 cmd_csum_parsed(void *parsed_result,
4673 __rte_unused struct cmdline *cl,
4674 __rte_unused void *data)
4676 struct cmd_csum_result *res = parsed_result;
4678 uint64_t csum_offloads = 0;
4679 struct rte_eth_dev_info dev_info;
4682 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4683 printf("invalid port %d\n", res->port_id);
4686 if (!port_is_stopped(res->port_id)) {
4687 printf("Please stop port %d first\n", res->port_id);
4691 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4695 if (!strcmp(res->mode, "set")) {
4697 if (!strcmp(res->hwsw, "hw"))
4700 if (!strcmp(res->proto, "ip")) {
4701 if (hw == 0 || (dev_info.tx_offload_capa &
4702 DEV_TX_OFFLOAD_IPV4_CKSUM)) {
4703 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
4705 printf("IP checksum offload is not supported "
4706 "by port %u\n", res->port_id);
4708 } else if (!strcmp(res->proto, "udp")) {
4709 if (hw == 0 || (dev_info.tx_offload_capa &
4710 DEV_TX_OFFLOAD_UDP_CKSUM)) {
4711 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
4713 printf("UDP checksum offload is not supported "
4714 "by port %u\n", res->port_id);
4716 } else if (!strcmp(res->proto, "tcp")) {
4717 if (hw == 0 || (dev_info.tx_offload_capa &
4718 DEV_TX_OFFLOAD_TCP_CKSUM)) {
4719 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
4721 printf("TCP checksum offload is not supported "
4722 "by port %u\n", res->port_id);
4724 } else if (!strcmp(res->proto, "sctp")) {
4725 if (hw == 0 || (dev_info.tx_offload_capa &
4726 DEV_TX_OFFLOAD_SCTP_CKSUM)) {
4727 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
4729 printf("SCTP checksum offload is not supported "
4730 "by port %u\n", res->port_id);
4732 } else if (!strcmp(res->proto, "outer-ip")) {
4733 if (hw == 0 || (dev_info.tx_offload_capa &
4734 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4736 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4738 printf("Outer IP checksum offload is not "
4739 "supported by port %u\n", res->port_id);
4741 } else if (!strcmp(res->proto, "outer-udp")) {
4742 if (hw == 0 || (dev_info.tx_offload_capa &
4743 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
4745 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM;
4747 printf("Outer UDP checksum offload is not "
4748 "supported by port %u\n", res->port_id);
4753 ports[res->port_id].dev_conf.txmode.offloads |=
4756 ports[res->port_id].dev_conf.txmode.offloads &=
4759 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4761 csum_show(res->port_id);
4763 cmd_reconfig_device_queue(res->port_id, 1, 1);
4766 cmdline_parse_token_string_t cmd_csum_csum =
4767 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4769 cmdline_parse_token_string_t cmd_csum_mode =
4770 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4772 cmdline_parse_token_string_t cmd_csum_proto =
4773 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4774 proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
4775 cmdline_parse_token_string_t cmd_csum_hwsw =
4776 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4778 cmdline_parse_token_num_t cmd_csum_portid =
4779 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4780 port_id, RTE_UINT16);
4782 cmdline_parse_inst_t cmd_csum_set = {
4783 .f = cmd_csum_parsed,
4785 .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
4786 "Enable/Disable hardware calculation of L3/L4 checksum when "
4787 "using csum forward engine",
4789 (void *)&cmd_csum_csum,
4790 (void *)&cmd_csum_mode,
4791 (void *)&cmd_csum_proto,
4792 (void *)&cmd_csum_hwsw,
4793 (void *)&cmd_csum_portid,
4798 cmdline_parse_token_string_t cmd_csum_mode_show =
4799 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4802 cmdline_parse_inst_t cmd_csum_show = {
4803 .f = cmd_csum_parsed,
4805 .help_str = "csum show <port_id>: Show checksum offload configuration",
4807 (void *)&cmd_csum_csum,
4808 (void *)&cmd_csum_mode_show,
4809 (void *)&cmd_csum_portid,
4814 /* Enable/disable tunnel parsing */
4815 struct cmd_csum_tunnel_result {
4816 cmdline_fixed_string_t csum;
4817 cmdline_fixed_string_t parse;
4818 cmdline_fixed_string_t onoff;
4823 cmd_csum_tunnel_parsed(void *parsed_result,
4824 __rte_unused struct cmdline *cl,
4825 __rte_unused void *data)
4827 struct cmd_csum_tunnel_result *res = parsed_result;
4829 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4832 if (!strcmp(res->onoff, "on"))
4833 ports[res->port_id].parse_tunnel = 1;
4835 ports[res->port_id].parse_tunnel = 0;
4837 csum_show(res->port_id);
4840 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4841 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4843 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4844 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4845 parse, "parse-tunnel");
4846 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4847 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4849 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4850 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4851 port_id, RTE_UINT16);
4853 cmdline_parse_inst_t cmd_csum_tunnel = {
4854 .f = cmd_csum_tunnel_parsed,
4856 .help_str = "csum parse-tunnel on|off <port_id>: "
4857 "Enable/Disable parsing of tunnels for csum engine",
4859 (void *)&cmd_csum_tunnel_csum,
4860 (void *)&cmd_csum_tunnel_parse,
4861 (void *)&cmd_csum_tunnel_onoff,
4862 (void *)&cmd_csum_tunnel_portid,
4867 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4868 struct cmd_tso_set_result {
4869 cmdline_fixed_string_t tso;
4870 cmdline_fixed_string_t mode;
4876 cmd_tso_set_parsed(void *parsed_result,
4877 __rte_unused struct cmdline *cl,
4878 __rte_unused void *data)
4880 struct cmd_tso_set_result *res = parsed_result;
4881 struct rte_eth_dev_info dev_info;
4884 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4886 if (!port_is_stopped(res->port_id)) {
4887 printf("Please stop port %d first\n", res->port_id);
4891 if (!strcmp(res->mode, "set"))
4892 ports[res->port_id].tso_segsz = res->tso_segsz;
4894 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4898 if ((ports[res->port_id].tso_segsz != 0) &&
4899 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4900 printf("Error: TSO is not supported by port %d\n",
4905 if (ports[res->port_id].tso_segsz == 0) {
4906 ports[res->port_id].dev_conf.txmode.offloads &=
4907 ~DEV_TX_OFFLOAD_TCP_TSO;
4908 printf("TSO for non-tunneled packets is disabled\n");
4910 ports[res->port_id].dev_conf.txmode.offloads |=
4911 DEV_TX_OFFLOAD_TCP_TSO;
4912 printf("TSO segment size for non-tunneled packets is %d\n",
4913 ports[res->port_id].tso_segsz);
4915 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4917 /* display warnings if configuration is not supported by the NIC */
4918 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4922 if ((ports[res->port_id].tso_segsz != 0) &&
4923 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4924 printf("Warning: TSO enabled but not "
4925 "supported by port %d\n", res->port_id);
4928 cmd_reconfig_device_queue(res->port_id, 1, 1);
4931 cmdline_parse_token_string_t cmd_tso_set_tso =
4932 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4934 cmdline_parse_token_string_t cmd_tso_set_mode =
4935 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4937 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4938 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4939 tso_segsz, RTE_UINT16);
4940 cmdline_parse_token_num_t cmd_tso_set_portid =
4941 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4942 port_id, RTE_UINT16);
4944 cmdline_parse_inst_t cmd_tso_set = {
4945 .f = cmd_tso_set_parsed,
4947 .help_str = "tso set <tso_segsz> <port_id>: "
4948 "Set TSO segment size of non-tunneled packets for csum engine "
4951 (void *)&cmd_tso_set_tso,
4952 (void *)&cmd_tso_set_mode,
4953 (void *)&cmd_tso_set_tso_segsz,
4954 (void *)&cmd_tso_set_portid,
4959 cmdline_parse_token_string_t cmd_tso_show_mode =
4960 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4964 cmdline_parse_inst_t cmd_tso_show = {
4965 .f = cmd_tso_set_parsed,
4967 .help_str = "tso show <port_id>: "
4968 "Show TSO segment size of non-tunneled packets for csum engine",
4970 (void *)&cmd_tso_set_tso,
4971 (void *)&cmd_tso_show_mode,
4972 (void *)&cmd_tso_set_portid,
4977 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
4978 struct cmd_tunnel_tso_set_result {
4979 cmdline_fixed_string_t tso;
4980 cmdline_fixed_string_t mode;
4985 static struct rte_eth_dev_info
4986 check_tunnel_tso_nic_support(portid_t port_id)
4988 struct rte_eth_dev_info dev_info;
4990 if (eth_dev_info_get_print_err(port_id, &dev_info) != 0)
4993 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
4994 printf("Warning: VXLAN TUNNEL TSO not supported therefore "
4995 "not enabled for port %d\n", port_id);
4996 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
4997 printf("Warning: GRE TUNNEL TSO not supported therefore "
4998 "not enabled for port %d\n", port_id);
4999 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
5000 printf("Warning: IPIP TUNNEL TSO not supported therefore "
5001 "not enabled for port %d\n", port_id);
5002 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
5003 printf("Warning: GENEVE TUNNEL TSO not supported therefore "
5004 "not enabled for port %d\n", port_id);
5005 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
5006 printf("Warning: IP TUNNEL TSO not supported therefore "
5007 "not enabled for port %d\n", port_id);
5008 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
5009 printf("Warning: UDP TUNNEL TSO not supported therefore "
5010 "not enabled for port %d\n", port_id);
5015 cmd_tunnel_tso_set_parsed(void *parsed_result,
5016 __rte_unused struct cmdline *cl,
5017 __rte_unused void *data)
5019 struct cmd_tunnel_tso_set_result *res = parsed_result;
5020 struct rte_eth_dev_info dev_info;
5022 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
5024 if (!port_is_stopped(res->port_id)) {
5025 printf("Please stop port %d first\n", res->port_id);
5029 if (!strcmp(res->mode, "set"))
5030 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
5032 dev_info = check_tunnel_tso_nic_support(res->port_id);
5033 if (ports[res->port_id].tunnel_tso_segsz == 0) {
5034 ports[res->port_id].dev_conf.txmode.offloads &=
5035 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
5036 DEV_TX_OFFLOAD_GRE_TNL_TSO |
5037 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
5038 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
5039 DEV_TX_OFFLOAD_IP_TNL_TSO |
5040 DEV_TX_OFFLOAD_UDP_TNL_TSO);
5041 printf("TSO for tunneled packets is disabled\n");
5043 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
5044 DEV_TX_OFFLOAD_GRE_TNL_TSO |
5045 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
5046 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
5047 DEV_TX_OFFLOAD_IP_TNL_TSO |
5048 DEV_TX_OFFLOAD_UDP_TNL_TSO);
5050 ports[res->port_id].dev_conf.txmode.offloads |=
5051 (tso_offloads & dev_info.tx_offload_capa);
5052 printf("TSO segment size for tunneled packets is %d\n",
5053 ports[res->port_id].tunnel_tso_segsz);
5055 /* Below conditions are needed to make it work:
5056 * (1) tunnel TSO is supported by the NIC;
5057 * (2) "csum parse_tunnel" must be set so that tunneled pkts
5059 * (3) for tunneled pkts with outer L3 of IPv4,
5060 * "csum set outer-ip" must be set to hw, because after tso,
5061 * total_len of outer IP header is changed, and the checksum
5062 * of outer IP header calculated by sw should be wrong; that
5063 * is not necessary for IPv6 tunneled pkts because there's no
5064 * checksum in IP header anymore.
5067 if (!ports[res->port_id].parse_tunnel)
5068 printf("Warning: csum parse_tunnel must be set "
5069 "so that tunneled packets are recognized\n");
5070 if (!(ports[res->port_id].dev_conf.txmode.offloads &
5071 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
5072 printf("Warning: csum set outer-ip must be set to hw "
5073 "if outer L3 is IPv4; not necessary for IPv6\n");
5076 cmd_config_queue_tx_offloads(&ports[res->port_id]);
5077 cmd_reconfig_device_queue(res->port_id, 1, 1);
5080 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
5081 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5083 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
5084 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5086 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
5087 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5088 tso_segsz, RTE_UINT16);
5089 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
5090 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5091 port_id, RTE_UINT16);
5093 cmdline_parse_inst_t cmd_tunnel_tso_set = {
5094 .f = cmd_tunnel_tso_set_parsed,
5096 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
5097 "Set TSO segment size of tunneled packets for csum engine "
5100 (void *)&cmd_tunnel_tso_set_tso,
5101 (void *)&cmd_tunnel_tso_set_mode,
5102 (void *)&cmd_tunnel_tso_set_tso_segsz,
5103 (void *)&cmd_tunnel_tso_set_portid,
5108 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
5109 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5113 cmdline_parse_inst_t cmd_tunnel_tso_show = {
5114 .f = cmd_tunnel_tso_set_parsed,
5116 .help_str = "tunnel_tso show <port_id> "
5117 "Show TSO segment size of tunneled packets for csum engine",
5119 (void *)&cmd_tunnel_tso_set_tso,
5120 (void *)&cmd_tunnel_tso_show_mode,
5121 (void *)&cmd_tunnel_tso_set_portid,
5126 /* *** SET GRO FOR A PORT *** */
5127 struct cmd_gro_enable_result {
5128 cmdline_fixed_string_t cmd_set;
5129 cmdline_fixed_string_t cmd_port;
5130 cmdline_fixed_string_t cmd_keyword;
5131 cmdline_fixed_string_t cmd_onoff;
5136 cmd_gro_enable_parsed(void *parsed_result,
5137 __rte_unused struct cmdline *cl,
5138 __rte_unused void *data)
5140 struct cmd_gro_enable_result *res;
5142 res = parsed_result;
5143 if (!strcmp(res->cmd_keyword, "gro"))
5144 setup_gro(res->cmd_onoff, res->cmd_pid);
5147 cmdline_parse_token_string_t cmd_gro_enable_set =
5148 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5150 cmdline_parse_token_string_t cmd_gro_enable_port =
5151 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5152 cmd_keyword, "port");
5153 cmdline_parse_token_num_t cmd_gro_enable_pid =
5154 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
5155 cmd_pid, RTE_UINT16);
5156 cmdline_parse_token_string_t cmd_gro_enable_keyword =
5157 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5158 cmd_keyword, "gro");
5159 cmdline_parse_token_string_t cmd_gro_enable_onoff =
5160 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5161 cmd_onoff, "on#off");
5163 cmdline_parse_inst_t cmd_gro_enable = {
5164 .f = cmd_gro_enable_parsed,
5166 .help_str = "set port <port_id> gro on|off",
5168 (void *)&cmd_gro_enable_set,
5169 (void *)&cmd_gro_enable_port,
5170 (void *)&cmd_gro_enable_pid,
5171 (void *)&cmd_gro_enable_keyword,
5172 (void *)&cmd_gro_enable_onoff,
5177 /* *** DISPLAY GRO CONFIGURATION *** */
5178 struct cmd_gro_show_result {
5179 cmdline_fixed_string_t cmd_show;
5180 cmdline_fixed_string_t cmd_port;
5181 cmdline_fixed_string_t cmd_keyword;
5186 cmd_gro_show_parsed(void *parsed_result,
5187 __rte_unused struct cmdline *cl,
5188 __rte_unused void *data)
5190 struct cmd_gro_show_result *res;
5192 res = parsed_result;
5193 if (!strcmp(res->cmd_keyword, "gro"))
5194 show_gro(res->cmd_pid);
5197 cmdline_parse_token_string_t cmd_gro_show_show =
5198 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5200 cmdline_parse_token_string_t cmd_gro_show_port =
5201 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5203 cmdline_parse_token_num_t cmd_gro_show_pid =
5204 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
5205 cmd_pid, RTE_UINT16);
5206 cmdline_parse_token_string_t cmd_gro_show_keyword =
5207 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5208 cmd_keyword, "gro");
5210 cmdline_parse_inst_t cmd_gro_show = {
5211 .f = cmd_gro_show_parsed,
5213 .help_str = "show port <port_id> gro",
5215 (void *)&cmd_gro_show_show,
5216 (void *)&cmd_gro_show_port,
5217 (void *)&cmd_gro_show_pid,
5218 (void *)&cmd_gro_show_keyword,
5223 /* *** SET FLUSH CYCLES FOR GRO *** */
5224 struct cmd_gro_flush_result {
5225 cmdline_fixed_string_t cmd_set;
5226 cmdline_fixed_string_t cmd_keyword;
5227 cmdline_fixed_string_t cmd_flush;
5232 cmd_gro_flush_parsed(void *parsed_result,
5233 __rte_unused struct cmdline *cl,
5234 __rte_unused void *data)
5236 struct cmd_gro_flush_result *res;
5238 res = parsed_result;
5239 if ((!strcmp(res->cmd_keyword, "gro")) &&
5240 (!strcmp(res->cmd_flush, "flush")))
5241 setup_gro_flush_cycles(res->cmd_cycles);
5244 cmdline_parse_token_string_t cmd_gro_flush_set =
5245 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5247 cmdline_parse_token_string_t cmd_gro_flush_keyword =
5248 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5249 cmd_keyword, "gro");
5250 cmdline_parse_token_string_t cmd_gro_flush_flush =
5251 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5252 cmd_flush, "flush");
5253 cmdline_parse_token_num_t cmd_gro_flush_cycles =
5254 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
5255 cmd_cycles, RTE_UINT8);
5257 cmdline_parse_inst_t cmd_gro_flush = {
5258 .f = cmd_gro_flush_parsed,
5260 .help_str = "set gro flush <cycles>",
5262 (void *)&cmd_gro_flush_set,
5263 (void *)&cmd_gro_flush_keyword,
5264 (void *)&cmd_gro_flush_flush,
5265 (void *)&cmd_gro_flush_cycles,
5270 /* *** ENABLE/DISABLE GSO *** */
5271 struct cmd_gso_enable_result {
5272 cmdline_fixed_string_t cmd_set;
5273 cmdline_fixed_string_t cmd_port;
5274 cmdline_fixed_string_t cmd_keyword;
5275 cmdline_fixed_string_t cmd_mode;
5280 cmd_gso_enable_parsed(void *parsed_result,
5281 __rte_unused struct cmdline *cl,
5282 __rte_unused void *data)
5284 struct cmd_gso_enable_result *res;
5286 res = parsed_result;
5287 if (!strcmp(res->cmd_keyword, "gso"))
5288 setup_gso(res->cmd_mode, res->cmd_pid);
5291 cmdline_parse_token_string_t cmd_gso_enable_set =
5292 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5294 cmdline_parse_token_string_t cmd_gso_enable_port =
5295 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5297 cmdline_parse_token_string_t cmd_gso_enable_keyword =
5298 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5299 cmd_keyword, "gso");
5300 cmdline_parse_token_string_t cmd_gso_enable_mode =
5301 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5302 cmd_mode, "on#off");
5303 cmdline_parse_token_num_t cmd_gso_enable_pid =
5304 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
5305 cmd_pid, RTE_UINT16);
5307 cmdline_parse_inst_t cmd_gso_enable = {
5308 .f = cmd_gso_enable_parsed,
5310 .help_str = "set port <port_id> gso on|off",
5312 (void *)&cmd_gso_enable_set,
5313 (void *)&cmd_gso_enable_port,
5314 (void *)&cmd_gso_enable_pid,
5315 (void *)&cmd_gso_enable_keyword,
5316 (void *)&cmd_gso_enable_mode,
5321 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
5322 struct cmd_gso_size_result {
5323 cmdline_fixed_string_t cmd_set;
5324 cmdline_fixed_string_t cmd_keyword;
5325 cmdline_fixed_string_t cmd_segsz;
5330 cmd_gso_size_parsed(void *parsed_result,
5331 __rte_unused struct cmdline *cl,
5332 __rte_unused void *data)
5334 struct cmd_gso_size_result *res = parsed_result;
5336 if (test_done == 0) {
5337 printf("Before setting GSO segsz, please first"
5338 " stop forwarding\n");
5342 if (!strcmp(res->cmd_keyword, "gso") &&
5343 !strcmp(res->cmd_segsz, "segsz")) {
5344 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
5345 printf("gso_size should be larger than %zu."
5346 " Please input a legal value\n",
5347 RTE_GSO_SEG_SIZE_MIN);
5349 gso_max_segment_size = res->cmd_size;
5353 cmdline_parse_token_string_t cmd_gso_size_set =
5354 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5356 cmdline_parse_token_string_t cmd_gso_size_keyword =
5357 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5358 cmd_keyword, "gso");
5359 cmdline_parse_token_string_t cmd_gso_size_segsz =
5360 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5361 cmd_segsz, "segsz");
5362 cmdline_parse_token_num_t cmd_gso_size_size =
5363 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
5364 cmd_size, RTE_UINT16);
5366 cmdline_parse_inst_t cmd_gso_size = {
5367 .f = cmd_gso_size_parsed,
5369 .help_str = "set gso segsz <length>",
5371 (void *)&cmd_gso_size_set,
5372 (void *)&cmd_gso_size_keyword,
5373 (void *)&cmd_gso_size_segsz,
5374 (void *)&cmd_gso_size_size,
5379 /* *** SHOW GSO CONFIGURATION *** */
5380 struct cmd_gso_show_result {
5381 cmdline_fixed_string_t cmd_show;
5382 cmdline_fixed_string_t cmd_port;
5383 cmdline_fixed_string_t cmd_keyword;
5388 cmd_gso_show_parsed(void *parsed_result,
5389 __rte_unused struct cmdline *cl,
5390 __rte_unused void *data)
5392 struct cmd_gso_show_result *res = parsed_result;
5394 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
5395 printf("invalid port id %u\n", res->cmd_pid);
5398 if (!strcmp(res->cmd_keyword, "gso")) {
5399 if (gso_ports[res->cmd_pid].enable) {
5400 printf("Max GSO'd packet size: %uB\n"
5401 "Supported GSO types: TCP/IPv4, "
5402 "UDP/IPv4, VxLAN with inner "
5403 "TCP/IPv4 packet, GRE with inner "
5404 "TCP/IPv4 packet\n",
5405 gso_max_segment_size);
5407 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
5411 cmdline_parse_token_string_t cmd_gso_show_show =
5412 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5414 cmdline_parse_token_string_t cmd_gso_show_port =
5415 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5417 cmdline_parse_token_string_t cmd_gso_show_keyword =
5418 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5419 cmd_keyword, "gso");
5420 cmdline_parse_token_num_t cmd_gso_show_pid =
5421 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
5422 cmd_pid, RTE_UINT16);
5424 cmdline_parse_inst_t cmd_gso_show = {
5425 .f = cmd_gso_show_parsed,
5427 .help_str = "show port <port_id> gso",
5429 (void *)&cmd_gso_show_show,
5430 (void *)&cmd_gso_show_port,
5431 (void *)&cmd_gso_show_pid,
5432 (void *)&cmd_gso_show_keyword,
5437 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
5438 struct cmd_set_flush_rx {
5439 cmdline_fixed_string_t set;
5440 cmdline_fixed_string_t flush_rx;
5441 cmdline_fixed_string_t mode;
5445 cmd_set_flush_rx_parsed(void *parsed_result,
5446 __rte_unused struct cmdline *cl,
5447 __rte_unused void *data)
5449 struct cmd_set_flush_rx *res = parsed_result;
5450 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5453 cmdline_parse_token_string_t cmd_setflushrx_set =
5454 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5456 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
5457 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5458 flush_rx, "flush_rx");
5459 cmdline_parse_token_string_t cmd_setflushrx_mode =
5460 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5464 cmdline_parse_inst_t cmd_set_flush_rx = {
5465 .f = cmd_set_flush_rx_parsed,
5466 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
5469 (void *)&cmd_setflushrx_set,
5470 (void *)&cmd_setflushrx_flush_rx,
5471 (void *)&cmd_setflushrx_mode,
5476 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
5477 struct cmd_set_link_check {
5478 cmdline_fixed_string_t set;
5479 cmdline_fixed_string_t link_check;
5480 cmdline_fixed_string_t mode;
5484 cmd_set_link_check_parsed(void *parsed_result,
5485 __rte_unused struct cmdline *cl,
5486 __rte_unused void *data)
5488 struct cmd_set_link_check *res = parsed_result;
5489 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5492 cmdline_parse_token_string_t cmd_setlinkcheck_set =
5493 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5495 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
5496 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5497 link_check, "link_check");
5498 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
5499 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5503 cmdline_parse_inst_t cmd_set_link_check = {
5504 .f = cmd_set_link_check_parsed,
5505 .help_str = "set link_check on|off: Enable/Disable link status check "
5506 "when starting/stopping a port",
5509 (void *)&cmd_setlinkcheck_set,
5510 (void *)&cmd_setlinkcheck_link_check,
5511 (void *)&cmd_setlinkcheck_mode,
5516 /* *** SET NIC BYPASS MODE *** */
5517 struct cmd_set_bypass_mode_result {
5518 cmdline_fixed_string_t set;
5519 cmdline_fixed_string_t bypass;
5520 cmdline_fixed_string_t mode;
5521 cmdline_fixed_string_t value;
5526 cmd_set_bypass_mode_parsed(void *parsed_result,
5527 __rte_unused struct cmdline *cl,
5528 __rte_unused void *data)
5530 struct cmd_set_bypass_mode_result *res = parsed_result;
5531 portid_t port_id = res->port_id;
5532 int32_t rc = -EINVAL;
5534 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5535 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5537 if (!strcmp(res->value, "bypass"))
5538 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5539 else if (!strcmp(res->value, "isolate"))
5540 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5542 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5544 /* Set the bypass mode for the relevant port. */
5545 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
5548 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
5551 cmdline_parse_token_string_t cmd_setbypass_mode_set =
5552 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5554 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
5555 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5557 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
5558 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5560 cmdline_parse_token_string_t cmd_setbypass_mode_value =
5561 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5562 value, "normal#bypass#isolate");
5563 cmdline_parse_token_num_t cmd_setbypass_mode_port =
5564 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
5565 port_id, RTE_UINT16);
5567 cmdline_parse_inst_t cmd_set_bypass_mode = {
5568 .f = cmd_set_bypass_mode_parsed,
5569 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
5570 "Set the NIC bypass mode for port_id",
5573 (void *)&cmd_setbypass_mode_set,
5574 (void *)&cmd_setbypass_mode_bypass,
5575 (void *)&cmd_setbypass_mode_mode,
5576 (void *)&cmd_setbypass_mode_value,
5577 (void *)&cmd_setbypass_mode_port,
5582 /* *** SET NIC BYPASS EVENT *** */
5583 struct cmd_set_bypass_event_result {
5584 cmdline_fixed_string_t set;
5585 cmdline_fixed_string_t bypass;
5586 cmdline_fixed_string_t event;
5587 cmdline_fixed_string_t event_value;
5588 cmdline_fixed_string_t mode;
5589 cmdline_fixed_string_t mode_value;
5594 cmd_set_bypass_event_parsed(void *parsed_result,
5595 __rte_unused struct cmdline *cl,
5596 __rte_unused void *data)
5598 int32_t rc = -EINVAL;
5599 struct cmd_set_bypass_event_result *res = parsed_result;
5600 portid_t port_id = res->port_id;
5602 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5603 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5604 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5606 if (!strcmp(res->event_value, "timeout"))
5607 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
5608 else if (!strcmp(res->event_value, "os_on"))
5609 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
5610 else if (!strcmp(res->event_value, "os_off"))
5611 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5612 else if (!strcmp(res->event_value, "power_on"))
5613 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5614 else if (!strcmp(res->event_value, "power_off"))
5615 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5617 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5619 if (!strcmp(res->mode_value, "bypass"))
5620 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5621 else if (!strcmp(res->mode_value, "isolate"))
5622 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5624 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5626 /* Set the watchdog timeout. */
5627 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5630 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5631 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5635 printf("Failed to set timeout value %u "
5636 "for port %d, errto code: %d.\n",
5637 bypass_timeout, port_id, rc);
5641 /* Set the bypass event to transition to bypass mode. */
5642 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5647 printf("\t Failed to set bypass event for port = %d.\n",
5651 cmdline_parse_token_string_t cmd_setbypass_event_set =
5652 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5654 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5655 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5657 cmdline_parse_token_string_t cmd_setbypass_event_event =
5658 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5660 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5661 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5662 event_value, "none#timeout#os_off#os_on#power_on#power_off");
5663 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5664 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5666 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5667 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5668 mode_value, "normal#bypass#isolate");
5669 cmdline_parse_token_num_t cmd_setbypass_event_port =
5670 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5671 port_id, RTE_UINT16);
5673 cmdline_parse_inst_t cmd_set_bypass_event = {
5674 .f = cmd_set_bypass_event_parsed,
5675 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5676 "power_off mode normal|bypass|isolate <port_id>: "
5677 "Set the NIC bypass event mode for port_id",
5680 (void *)&cmd_setbypass_event_set,
5681 (void *)&cmd_setbypass_event_bypass,
5682 (void *)&cmd_setbypass_event_event,
5683 (void *)&cmd_setbypass_event_event_value,
5684 (void *)&cmd_setbypass_event_mode,
5685 (void *)&cmd_setbypass_event_mode_value,
5686 (void *)&cmd_setbypass_event_port,
5692 /* *** SET NIC BYPASS TIMEOUT *** */
5693 struct cmd_set_bypass_timeout_result {
5694 cmdline_fixed_string_t set;
5695 cmdline_fixed_string_t bypass;
5696 cmdline_fixed_string_t timeout;
5697 cmdline_fixed_string_t value;
5701 cmd_set_bypass_timeout_parsed(void *parsed_result,
5702 __rte_unused struct cmdline *cl,
5703 __rte_unused void *data)
5705 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5707 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5708 if (!strcmp(res->value, "1.5"))
5709 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5710 else if (!strcmp(res->value, "2"))
5711 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5712 else if (!strcmp(res->value, "3"))
5713 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5714 else if (!strcmp(res->value, "4"))
5715 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5716 else if (!strcmp(res->value, "8"))
5717 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5718 else if (!strcmp(res->value, "16"))
5719 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5720 else if (!strcmp(res->value, "32"))
5721 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5723 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5727 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5728 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5730 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5731 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5733 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5734 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5735 timeout, "timeout");
5736 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5737 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5738 value, "0#1.5#2#3#4#8#16#32");
5740 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5741 .f = cmd_set_bypass_timeout_parsed,
5742 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5743 "Set the NIC bypass watchdog timeout in seconds",
5746 (void *)&cmd_setbypass_timeout_set,
5747 (void *)&cmd_setbypass_timeout_bypass,
5748 (void *)&cmd_setbypass_timeout_timeout,
5749 (void *)&cmd_setbypass_timeout_value,
5754 /* *** SHOW NIC BYPASS MODE *** */
5755 struct cmd_show_bypass_config_result {
5756 cmdline_fixed_string_t show;
5757 cmdline_fixed_string_t bypass;
5758 cmdline_fixed_string_t config;
5763 cmd_show_bypass_config_parsed(void *parsed_result,
5764 __rte_unused struct cmdline *cl,
5765 __rte_unused void *data)
5767 struct cmd_show_bypass_config_result *res = parsed_result;
5768 portid_t port_id = res->port_id;
5770 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5771 uint32_t event_mode;
5772 uint32_t bypass_mode;
5773 uint32_t timeout = bypass_timeout;
5776 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5777 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
5778 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5779 {"UNKNOWN", "normal", "bypass", "isolate"};
5780 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5788 /* Display the bypass mode.*/
5789 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5790 printf("\tFailed to get bypass mode for port = %d\n", port_id);
5794 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5795 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5797 printf("\tbypass mode = %s\n", modes[bypass_mode]);
5800 /* Display the bypass timeout.*/
5801 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5802 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5804 printf("\tbypass timeout = %s\n", timeouts[timeout]);
5806 /* Display the bypass events and associated modes. */
5807 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < RTE_DIM(events); i++) {
5809 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5810 printf("\tFailed to get bypass mode for event = %s\n",
5813 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5814 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5816 printf("\tbypass event: %-16s = %s\n", events[i],
5822 printf("\tFailed to get bypass configuration for port = %d\n",
5826 cmdline_parse_token_string_t cmd_showbypass_config_show =
5827 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5829 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5830 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5832 cmdline_parse_token_string_t cmd_showbypass_config_config =
5833 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5835 cmdline_parse_token_num_t cmd_showbypass_config_port =
5836 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5837 port_id, RTE_UINT16);
5839 cmdline_parse_inst_t cmd_show_bypass_config = {
5840 .f = cmd_show_bypass_config_parsed,
5841 .help_str = "show bypass config <port_id>: "
5842 "Show the NIC bypass config for port_id",
5845 (void *)&cmd_showbypass_config_show,
5846 (void *)&cmd_showbypass_config_bypass,
5847 (void *)&cmd_showbypass_config_config,
5848 (void *)&cmd_showbypass_config_port,
5854 /* *** SET BONDING MODE *** */
5855 struct cmd_set_bonding_mode_result {
5856 cmdline_fixed_string_t set;
5857 cmdline_fixed_string_t bonding;
5858 cmdline_fixed_string_t mode;
5863 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5864 __rte_unused struct cmdline *cl,
5865 __rte_unused void *data)
5867 struct cmd_set_bonding_mode_result *res = parsed_result;
5868 portid_t port_id = res->port_id;
5870 /* Set the bonding mode for the relevant port. */
5871 if (0 != rte_eth_bond_mode_set(port_id, res->value))
5872 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
5875 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5876 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5878 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5879 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5880 bonding, "bonding");
5881 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5882 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5884 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5885 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5887 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5888 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5889 port_id, RTE_UINT16);
5891 cmdline_parse_inst_t cmd_set_bonding_mode = {
5892 .f = cmd_set_bonding_mode_parsed,
5893 .help_str = "set bonding mode <mode_value> <port_id>: "
5894 "Set the bonding mode for port_id",
5897 (void *) &cmd_setbonding_mode_set,
5898 (void *) &cmd_setbonding_mode_bonding,
5899 (void *) &cmd_setbonding_mode_mode,
5900 (void *) &cmd_setbonding_mode_value,
5901 (void *) &cmd_setbonding_mode_port,
5906 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5907 struct cmd_set_bonding_lacp_dedicated_queues_result {
5908 cmdline_fixed_string_t set;
5909 cmdline_fixed_string_t bonding;
5910 cmdline_fixed_string_t lacp;
5911 cmdline_fixed_string_t dedicated_queues;
5913 cmdline_fixed_string_t mode;
5916 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5917 __rte_unused struct cmdline *cl,
5918 __rte_unused void *data)
5920 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5921 portid_t port_id = res->port_id;
5922 struct rte_port *port;
5924 port = &ports[port_id];
5926 /** Check if the port is not started **/
5927 if (port->port_status != RTE_PORT_STOPPED) {
5928 printf("Please stop port %d first\n", port_id);
5932 if (!strcmp(res->mode, "enable")) {
5933 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5934 printf("Dedicate queues for LACP control packets"
5937 printf("Enabling dedicate queues for LACP control "
5938 "packets on port %d failed\n", port_id);
5939 } else if (!strcmp(res->mode, "disable")) {
5940 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5941 printf("Dedicated queues for LACP control packets "
5944 printf("Disabling dedicated queues for LACP control "
5945 "traffic on port %d failed\n", port_id);
5949 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5950 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5952 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
5953 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5954 bonding, "bonding");
5955 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
5956 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5958 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
5959 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5960 dedicated_queues, "dedicated_queues");
5961 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
5962 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5963 port_id, RTE_UINT16);
5964 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
5965 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5966 mode, "enable#disable");
5968 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
5969 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
5970 .help_str = "set bonding lacp dedicated_queues <port_id> "
5972 "Enable/disable dedicated queues for LACP control traffic for port_id",
5975 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
5976 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
5977 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
5978 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
5979 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
5980 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
5985 /* *** SET BALANCE XMIT POLICY *** */
5986 struct cmd_set_bonding_balance_xmit_policy_result {
5987 cmdline_fixed_string_t set;
5988 cmdline_fixed_string_t bonding;
5989 cmdline_fixed_string_t balance_xmit_policy;
5991 cmdline_fixed_string_t policy;
5994 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
5995 __rte_unused struct cmdline *cl,
5996 __rte_unused void *data)
5998 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
5999 portid_t port_id = res->port_id;
6002 if (!strcmp(res->policy, "l2")) {
6003 policy = BALANCE_XMIT_POLICY_LAYER2;
6004 } else if (!strcmp(res->policy, "l23")) {
6005 policy = BALANCE_XMIT_POLICY_LAYER23;
6006 } else if (!strcmp(res->policy, "l34")) {
6007 policy = BALANCE_XMIT_POLICY_LAYER34;
6009 printf("\t Invalid xmit policy selection");
6013 /* Set the bonding mode for the relevant port. */
6014 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
6015 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
6020 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
6021 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6023 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
6024 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6025 bonding, "bonding");
6026 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
6027 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6028 balance_xmit_policy, "balance_xmit_policy");
6029 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
6030 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6031 port_id, RTE_UINT16);
6032 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
6033 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6034 policy, "l2#l23#l34");
6036 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
6037 .f = cmd_set_bonding_balance_xmit_policy_parsed,
6038 .help_str = "set bonding balance_xmit_policy <port_id> "
6040 "Set the bonding balance_xmit_policy for port_id",
6043 (void *)&cmd_setbonding_balance_xmit_policy_set,
6044 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
6045 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
6046 (void *)&cmd_setbonding_balance_xmit_policy_port,
6047 (void *)&cmd_setbonding_balance_xmit_policy_policy,
6052 /* *** SHOW NIC BONDING CONFIGURATION *** */
6053 struct cmd_show_bonding_config_result {
6054 cmdline_fixed_string_t show;
6055 cmdline_fixed_string_t bonding;
6056 cmdline_fixed_string_t config;
6060 static void cmd_show_bonding_config_parsed(void *parsed_result,
6061 __rte_unused struct cmdline *cl,
6062 __rte_unused void *data)
6064 struct cmd_show_bonding_config_result *res = parsed_result;
6065 int bonding_mode, agg_mode;
6066 portid_t slaves[RTE_MAX_ETHPORTS];
6067 int num_slaves, num_active_slaves;
6070 portid_t port_id = res->port_id;
6072 /* Display the bonding mode.*/
6073 bonding_mode = rte_eth_bond_mode_get(port_id);
6074 if (bonding_mode < 0) {
6075 printf("\tFailed to get bonding mode for port = %d\n", port_id);
6078 printf("\tBonding mode: %d\n", bonding_mode);
6080 if (bonding_mode == BONDING_MODE_BALANCE) {
6081 int balance_xmit_policy;
6083 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
6084 if (balance_xmit_policy < 0) {
6085 printf("\tFailed to get balance xmit policy for port = %d\n",
6089 printf("\tBalance Xmit Policy: ");
6091 switch (balance_xmit_policy) {
6092 case BALANCE_XMIT_POLICY_LAYER2:
6093 printf("BALANCE_XMIT_POLICY_LAYER2");
6095 case BALANCE_XMIT_POLICY_LAYER23:
6096 printf("BALANCE_XMIT_POLICY_LAYER23");
6098 case BALANCE_XMIT_POLICY_LAYER34:
6099 printf("BALANCE_XMIT_POLICY_LAYER34");
6106 if (bonding_mode == BONDING_MODE_8023AD) {
6107 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
6108 printf("\tIEEE802.3AD Aggregator Mode: ");
6111 printf("bandwidth");
6123 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
6125 if (num_slaves < 0) {
6126 printf("\tFailed to get slave list for port = %d\n", port_id);
6129 if (num_slaves > 0) {
6130 printf("\tSlaves (%d): [", num_slaves);
6131 for (i = 0; i < num_slaves - 1; i++)
6132 printf("%d ", slaves[i]);
6134 printf("%d]\n", slaves[num_slaves - 1]);
6136 printf("\tSlaves: []\n");
6140 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
6143 if (num_active_slaves < 0) {
6144 printf("\tFailed to get active slave list for port = %d\n", port_id);
6147 if (num_active_slaves > 0) {
6148 printf("\tActive Slaves (%d): [", num_active_slaves);
6149 for (i = 0; i < num_active_slaves - 1; i++)
6150 printf("%d ", slaves[i]);
6152 printf("%d]\n", slaves[num_active_slaves - 1]);
6155 printf("\tActive Slaves: []\n");
6159 primary_id = rte_eth_bond_primary_get(port_id);
6160 if (primary_id < 0) {
6161 printf("\tFailed to get primary slave for port = %d\n", port_id);
6164 printf("\tPrimary: [%d]\n", primary_id);
6168 cmdline_parse_token_string_t cmd_showbonding_config_show =
6169 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6171 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
6172 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6173 bonding, "bonding");
6174 cmdline_parse_token_string_t cmd_showbonding_config_config =
6175 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6177 cmdline_parse_token_num_t cmd_showbonding_config_port =
6178 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
6179 port_id, RTE_UINT16);
6181 cmdline_parse_inst_t cmd_show_bonding_config = {
6182 .f = cmd_show_bonding_config_parsed,
6183 .help_str = "show bonding config <port_id>: "
6184 "Show the bonding config for port_id",
6187 (void *)&cmd_showbonding_config_show,
6188 (void *)&cmd_showbonding_config_bonding,
6189 (void *)&cmd_showbonding_config_config,
6190 (void *)&cmd_showbonding_config_port,
6195 /* *** SET BONDING PRIMARY *** */
6196 struct cmd_set_bonding_primary_result {
6197 cmdline_fixed_string_t set;
6198 cmdline_fixed_string_t bonding;
6199 cmdline_fixed_string_t primary;
6204 static void cmd_set_bonding_primary_parsed(void *parsed_result,
6205 __rte_unused struct cmdline *cl,
6206 __rte_unused void *data)
6208 struct cmd_set_bonding_primary_result *res = parsed_result;
6209 portid_t master_port_id = res->port_id;
6210 portid_t slave_port_id = res->slave_id;
6212 /* Set the primary slave for a bonded device. */
6213 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
6214 printf("\t Failed to set primary slave for port = %d.\n",
6221 cmdline_parse_token_string_t cmd_setbonding_primary_set =
6222 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6224 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
6225 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6226 bonding, "bonding");
6227 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
6228 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6229 primary, "primary");
6230 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
6231 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6232 slave_id, RTE_UINT16);
6233 cmdline_parse_token_num_t cmd_setbonding_primary_port =
6234 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6235 port_id, RTE_UINT16);
6237 cmdline_parse_inst_t cmd_set_bonding_primary = {
6238 .f = cmd_set_bonding_primary_parsed,
6239 .help_str = "set bonding primary <slave_id> <port_id>: "
6240 "Set the primary slave for port_id",
6243 (void *)&cmd_setbonding_primary_set,
6244 (void *)&cmd_setbonding_primary_bonding,
6245 (void *)&cmd_setbonding_primary_primary,
6246 (void *)&cmd_setbonding_primary_slave,
6247 (void *)&cmd_setbonding_primary_port,
6252 /* *** ADD SLAVE *** */
6253 struct cmd_add_bonding_slave_result {
6254 cmdline_fixed_string_t add;
6255 cmdline_fixed_string_t bonding;
6256 cmdline_fixed_string_t slave;
6261 static void cmd_add_bonding_slave_parsed(void *parsed_result,
6262 __rte_unused struct cmdline *cl,
6263 __rte_unused void *data)
6265 struct cmd_add_bonding_slave_result *res = parsed_result;
6266 portid_t master_port_id = res->port_id;
6267 portid_t slave_port_id = res->slave_id;
6269 /* add the slave for a bonded device. */
6270 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
6271 printf("\t Failed to add slave %d to master port = %d.\n",
6272 slave_port_id, master_port_id);
6276 set_port_slave_flag(slave_port_id);
6279 cmdline_parse_token_string_t cmd_addbonding_slave_add =
6280 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6282 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
6283 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6284 bonding, "bonding");
6285 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
6286 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6288 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
6289 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6290 slave_id, RTE_UINT16);
6291 cmdline_parse_token_num_t cmd_addbonding_slave_port =
6292 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6293 port_id, RTE_UINT16);
6295 cmdline_parse_inst_t cmd_add_bonding_slave = {
6296 .f = cmd_add_bonding_slave_parsed,
6297 .help_str = "add bonding slave <slave_id> <port_id>: "
6298 "Add a slave device to a bonded device",
6301 (void *)&cmd_addbonding_slave_add,
6302 (void *)&cmd_addbonding_slave_bonding,
6303 (void *)&cmd_addbonding_slave_slave,
6304 (void *)&cmd_addbonding_slave_slaveid,
6305 (void *)&cmd_addbonding_slave_port,
6310 /* *** REMOVE SLAVE *** */
6311 struct cmd_remove_bonding_slave_result {
6312 cmdline_fixed_string_t remove;
6313 cmdline_fixed_string_t bonding;
6314 cmdline_fixed_string_t slave;
6319 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
6320 __rte_unused struct cmdline *cl,
6321 __rte_unused void *data)
6323 struct cmd_remove_bonding_slave_result *res = parsed_result;
6324 portid_t master_port_id = res->port_id;
6325 portid_t slave_port_id = res->slave_id;
6327 /* remove the slave from a bonded device. */
6328 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
6329 printf("\t Failed to remove slave %d from master port = %d.\n",
6330 slave_port_id, master_port_id);
6334 clear_port_slave_flag(slave_port_id);
6337 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
6338 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6340 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
6341 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6342 bonding, "bonding");
6343 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
6344 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6346 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
6347 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6348 slave_id, RTE_UINT16);
6349 cmdline_parse_token_num_t cmd_removebonding_slave_port =
6350 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6351 port_id, RTE_UINT16);
6353 cmdline_parse_inst_t cmd_remove_bonding_slave = {
6354 .f = cmd_remove_bonding_slave_parsed,
6355 .help_str = "remove bonding slave <slave_id> <port_id>: "
6356 "Remove a slave device from a bonded device",
6359 (void *)&cmd_removebonding_slave_remove,
6360 (void *)&cmd_removebonding_slave_bonding,
6361 (void *)&cmd_removebonding_slave_slave,
6362 (void *)&cmd_removebonding_slave_slaveid,
6363 (void *)&cmd_removebonding_slave_port,
6368 /* *** CREATE BONDED DEVICE *** */
6369 struct cmd_create_bonded_device_result {
6370 cmdline_fixed_string_t create;
6371 cmdline_fixed_string_t bonded;
6372 cmdline_fixed_string_t device;
6377 static int bond_dev_num = 0;
6379 static void cmd_create_bonded_device_parsed(void *parsed_result,
6380 __rte_unused struct cmdline *cl,
6381 __rte_unused void *data)
6383 struct cmd_create_bonded_device_result *res = parsed_result;
6384 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
6388 if (test_done == 0) {
6389 printf("Please stop forwarding first\n");
6393 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
6396 /* Create a new bonded device. */
6397 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
6399 printf("\t Failed to create bonded device.\n");
6402 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
6405 /* Update number of ports */
6406 nb_ports = rte_eth_dev_count_avail();
6407 reconfig(port_id, res->socket);
6408 ret = rte_eth_promiscuous_enable(port_id);
6410 printf("Failed to enable promiscuous mode for port %u: %s - ignore\n",
6411 port_id, rte_strerror(-ret));
6413 ports[port_id].need_setup = 0;
6414 ports[port_id].port_status = RTE_PORT_STOPPED;
6419 cmdline_parse_token_string_t cmd_createbonded_device_create =
6420 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6422 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
6423 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6425 cmdline_parse_token_string_t cmd_createbonded_device_device =
6426 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6428 cmdline_parse_token_num_t cmd_createbonded_device_mode =
6429 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6431 cmdline_parse_token_num_t cmd_createbonded_device_socket =
6432 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6435 cmdline_parse_inst_t cmd_create_bonded_device = {
6436 .f = cmd_create_bonded_device_parsed,
6437 .help_str = "create bonded device <mode> <socket>: "
6438 "Create a new bonded device with specific bonding mode and socket",
6441 (void *)&cmd_createbonded_device_create,
6442 (void *)&cmd_createbonded_device_bonded,
6443 (void *)&cmd_createbonded_device_device,
6444 (void *)&cmd_createbonded_device_mode,
6445 (void *)&cmd_createbonded_device_socket,
6450 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
6451 struct cmd_set_bond_mac_addr_result {
6452 cmdline_fixed_string_t set;
6453 cmdline_fixed_string_t bonding;
6454 cmdline_fixed_string_t mac_addr;
6456 struct rte_ether_addr address;
6459 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
6460 __rte_unused struct cmdline *cl,
6461 __rte_unused void *data)
6463 struct cmd_set_bond_mac_addr_result *res = parsed_result;
6466 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
6469 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
6471 /* check the return value and print it if is < 0 */
6473 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6476 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
6477 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
6478 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
6479 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
6481 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
6482 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
6484 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
6485 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
6486 port_num, RTE_UINT16);
6487 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
6488 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
6490 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
6491 .f = cmd_set_bond_mac_addr_parsed,
6493 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
6495 (void *)&cmd_set_bond_mac_addr_set,
6496 (void *)&cmd_set_bond_mac_addr_bonding,
6497 (void *)&cmd_set_bond_mac_addr_mac,
6498 (void *)&cmd_set_bond_mac_addr_portnum,
6499 (void *)&cmd_set_bond_mac_addr_addr,
6505 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
6506 struct cmd_set_bond_mon_period_result {
6507 cmdline_fixed_string_t set;
6508 cmdline_fixed_string_t bonding;
6509 cmdline_fixed_string_t mon_period;
6514 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
6515 __rte_unused struct cmdline *cl,
6516 __rte_unused void *data)
6518 struct cmd_set_bond_mon_period_result *res = parsed_result;
6521 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
6523 /* check the return value and print it if is < 0 */
6525 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6528 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
6529 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6531 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
6532 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6533 bonding, "bonding");
6534 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
6535 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6536 mon_period, "mon_period");
6537 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
6538 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6539 port_num, RTE_UINT16);
6540 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
6541 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6542 period_ms, RTE_UINT32);
6544 cmdline_parse_inst_t cmd_set_bond_mon_period = {
6545 .f = cmd_set_bond_mon_period_parsed,
6547 .help_str = "set bonding mon_period <port_id> <period_ms>",
6549 (void *)&cmd_set_bond_mon_period_set,
6550 (void *)&cmd_set_bond_mon_period_bonding,
6551 (void *)&cmd_set_bond_mon_period_mon_period,
6552 (void *)&cmd_set_bond_mon_period_portnum,
6553 (void *)&cmd_set_bond_mon_period_period_ms,
6560 struct cmd_set_bonding_agg_mode_policy_result {
6561 cmdline_fixed_string_t set;
6562 cmdline_fixed_string_t bonding;
6563 cmdline_fixed_string_t agg_mode;
6565 cmdline_fixed_string_t policy;
6570 cmd_set_bonding_agg_mode(void *parsed_result,
6571 __rte_unused struct cmdline *cl,
6572 __rte_unused void *data)
6574 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
6575 uint8_t policy = AGG_BANDWIDTH;
6577 if (!strcmp(res->policy, "bandwidth"))
6578 policy = AGG_BANDWIDTH;
6579 else if (!strcmp(res->policy, "stable"))
6580 policy = AGG_STABLE;
6581 else if (!strcmp(res->policy, "count"))
6584 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
6588 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
6589 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6591 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
6592 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6593 bonding, "bonding");
6595 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
6596 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6597 agg_mode, "agg_mode");
6599 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
6600 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6601 port_num, RTE_UINT16);
6603 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6604 TOKEN_STRING_INITIALIZER(
6605 struct cmd_set_bonding_balance_xmit_policy_result,
6606 policy, "stable#bandwidth#count");
6608 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6609 .f = cmd_set_bonding_agg_mode,
6611 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6613 (void *)&cmd_set_bonding_agg_mode_set,
6614 (void *)&cmd_set_bonding_agg_mode_bonding,
6615 (void *)&cmd_set_bonding_agg_mode_agg_mode,
6616 (void *)&cmd_set_bonding_agg_mode_portnum,
6617 (void *)&cmd_set_bonding_agg_mode_policy_string,
6623 #endif /* RTE_NET_BOND */
6625 /* *** SET FORWARDING MODE *** */
6626 struct cmd_set_fwd_mode_result {
6627 cmdline_fixed_string_t set;
6628 cmdline_fixed_string_t fwd;
6629 cmdline_fixed_string_t mode;
6632 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6633 __rte_unused struct cmdline *cl,
6634 __rte_unused void *data)
6636 struct cmd_set_fwd_mode_result *res = parsed_result;
6639 set_pkt_forwarding_mode(res->mode);
6642 cmdline_parse_token_string_t cmd_setfwd_set =
6643 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6644 cmdline_parse_token_string_t cmd_setfwd_fwd =
6645 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6646 cmdline_parse_token_string_t cmd_setfwd_mode =
6647 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6648 "" /* defined at init */);
6650 cmdline_parse_inst_t cmd_set_fwd_mode = {
6651 .f = cmd_set_fwd_mode_parsed,
6653 .help_str = NULL, /* defined at init */
6655 (void *)&cmd_setfwd_set,
6656 (void *)&cmd_setfwd_fwd,
6657 (void *)&cmd_setfwd_mode,
6662 static void cmd_set_fwd_mode_init(void)
6665 static char token[128];
6666 static char help[256];
6667 cmdline_parse_token_string_t *token_struct;
6669 modes = list_pkt_forwarding_modes();
6670 snprintf(help, sizeof(help), "set fwd %s: "
6671 "Set packet forwarding mode", modes);
6672 cmd_set_fwd_mode.help_str = help;
6674 /* string token separator is # */
6675 for (c = token; *modes != '\0'; modes++)
6680 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6681 token_struct->string_data.str = token;
6684 /* *** SET RETRY FORWARDING MODE *** */
6685 struct cmd_set_fwd_retry_mode_result {
6686 cmdline_fixed_string_t set;
6687 cmdline_fixed_string_t fwd;
6688 cmdline_fixed_string_t mode;
6689 cmdline_fixed_string_t retry;
6692 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6693 __rte_unused struct cmdline *cl,
6694 __rte_unused void *data)
6696 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6699 set_pkt_forwarding_mode(res->mode);
6702 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6703 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6705 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6706 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6708 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6709 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6711 "" /* defined at init */);
6712 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6713 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6716 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6717 .f = cmd_set_fwd_retry_mode_parsed,
6719 .help_str = NULL, /* defined at init */
6721 (void *)&cmd_setfwd_retry_set,
6722 (void *)&cmd_setfwd_retry_fwd,
6723 (void *)&cmd_setfwd_retry_mode,
6724 (void *)&cmd_setfwd_retry_retry,
6729 static void cmd_set_fwd_retry_mode_init(void)
6732 static char token[128];
6733 static char help[256];
6734 cmdline_parse_token_string_t *token_struct;
6736 modes = list_pkt_forwarding_retry_modes();
6737 snprintf(help, sizeof(help), "set fwd %s retry: "
6738 "Set packet forwarding mode with retry", modes);
6739 cmd_set_fwd_retry_mode.help_str = help;
6741 /* string token separator is # */
6742 for (c = token; *modes != '\0'; modes++)
6747 token_struct = (cmdline_parse_token_string_t *)
6748 cmd_set_fwd_retry_mode.tokens[2];
6749 token_struct->string_data.str = token;
6752 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6753 struct cmd_set_burst_tx_retry_result {
6754 cmdline_fixed_string_t set;
6755 cmdline_fixed_string_t burst;
6756 cmdline_fixed_string_t tx;
6757 cmdline_fixed_string_t delay;
6759 cmdline_fixed_string_t retry;
6763 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6764 __rte_unused struct cmdline *cl,
6765 __rte_unused void *data)
6767 struct cmd_set_burst_tx_retry_result *res = parsed_result;
6769 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6770 && !strcmp(res->tx, "tx")) {
6771 if (!strcmp(res->delay, "delay"))
6772 burst_tx_delay_time = res->time;
6773 if (!strcmp(res->retry, "retry"))
6774 burst_tx_retry_num = res->retry_num;
6779 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6780 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6781 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6782 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6784 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6785 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6786 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6787 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6788 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6789 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time,
6791 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6792 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6793 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6794 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num,
6797 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6798 .f = cmd_set_burst_tx_retry_parsed,
6799 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6801 (void *)&cmd_set_burst_tx_retry_set,
6802 (void *)&cmd_set_burst_tx_retry_burst,
6803 (void *)&cmd_set_burst_tx_retry_tx,
6804 (void *)&cmd_set_burst_tx_retry_delay,
6805 (void *)&cmd_set_burst_tx_retry_time,
6806 (void *)&cmd_set_burst_tx_retry_retry,
6807 (void *)&cmd_set_burst_tx_retry_retry_num,
6812 /* *** SET PROMISC MODE *** */
6813 struct cmd_set_promisc_mode_result {
6814 cmdline_fixed_string_t set;
6815 cmdline_fixed_string_t promisc;
6816 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6817 uint16_t port_num; /* valid if "allports" argument == 0 */
6818 cmdline_fixed_string_t mode;
6821 static void cmd_set_promisc_mode_parsed(void *parsed_result,
6822 __rte_unused struct cmdline *cl,
6825 struct cmd_set_promisc_mode_result *res = parsed_result;
6829 if (!strcmp(res->mode, "on"))
6836 RTE_ETH_FOREACH_DEV(i)
6837 eth_set_promisc_mode(i, enable);
6839 eth_set_promisc_mode(res->port_num, enable);
6843 cmdline_parse_token_string_t cmd_setpromisc_set =
6844 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6845 cmdline_parse_token_string_t cmd_setpromisc_promisc =
6846 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6848 cmdline_parse_token_string_t cmd_setpromisc_portall =
6849 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6851 cmdline_parse_token_num_t cmd_setpromisc_portnum =
6852 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6854 cmdline_parse_token_string_t cmd_setpromisc_mode =
6855 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6858 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6859 .f = cmd_set_promisc_mode_parsed,
6861 .help_str = "set promisc all on|off: Set promisc mode for all ports",
6863 (void *)&cmd_setpromisc_set,
6864 (void *)&cmd_setpromisc_promisc,
6865 (void *)&cmd_setpromisc_portall,
6866 (void *)&cmd_setpromisc_mode,
6871 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6872 .f = cmd_set_promisc_mode_parsed,
6874 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6876 (void *)&cmd_setpromisc_set,
6877 (void *)&cmd_setpromisc_promisc,
6878 (void *)&cmd_setpromisc_portnum,
6879 (void *)&cmd_setpromisc_mode,
6884 /* *** SET ALLMULTI MODE *** */
6885 struct cmd_set_allmulti_mode_result {
6886 cmdline_fixed_string_t set;
6887 cmdline_fixed_string_t allmulti;
6888 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6889 uint16_t port_num; /* valid if "allports" argument == 0 */
6890 cmdline_fixed_string_t mode;
6893 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6894 __rte_unused struct cmdline *cl,
6897 struct cmd_set_allmulti_mode_result *res = parsed_result;
6901 if (!strcmp(res->mode, "on"))
6908 RTE_ETH_FOREACH_DEV(i) {
6909 eth_set_allmulticast_mode(i, enable);
6913 eth_set_allmulticast_mode(res->port_num, enable);
6917 cmdline_parse_token_string_t cmd_setallmulti_set =
6918 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6919 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6920 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6922 cmdline_parse_token_string_t cmd_setallmulti_portall =
6923 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6925 cmdline_parse_token_num_t cmd_setallmulti_portnum =
6926 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6928 cmdline_parse_token_string_t cmd_setallmulti_mode =
6929 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6932 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6933 .f = cmd_set_allmulti_mode_parsed,
6935 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6937 (void *)&cmd_setallmulti_set,
6938 (void *)&cmd_setallmulti_allmulti,
6939 (void *)&cmd_setallmulti_portall,
6940 (void *)&cmd_setallmulti_mode,
6945 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6946 .f = cmd_set_allmulti_mode_parsed,
6948 .help_str = "set allmulti <port_id> on|off: "
6949 "Set allmulti mode on port_id",
6951 (void *)&cmd_setallmulti_set,
6952 (void *)&cmd_setallmulti_allmulti,
6953 (void *)&cmd_setallmulti_portnum,
6954 (void *)&cmd_setallmulti_mode,
6959 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
6960 struct cmd_link_flow_ctrl_set_result {
6961 cmdline_fixed_string_t set;
6962 cmdline_fixed_string_t flow_ctrl;
6963 cmdline_fixed_string_t rx;
6964 cmdline_fixed_string_t rx_lfc_mode;
6965 cmdline_fixed_string_t tx;
6966 cmdline_fixed_string_t tx_lfc_mode;
6967 cmdline_fixed_string_t mac_ctrl_frame_fwd;
6968 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
6969 cmdline_fixed_string_t autoneg_str;
6970 cmdline_fixed_string_t autoneg;
6971 cmdline_fixed_string_t hw_str;
6972 uint32_t high_water;
6973 cmdline_fixed_string_t lw_str;
6975 cmdline_fixed_string_t pt_str;
6976 uint16_t pause_time;
6977 cmdline_fixed_string_t xon_str;
6982 cmdline_parse_token_string_t cmd_lfc_set_set =
6983 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6985 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
6986 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6987 flow_ctrl, "flow_ctrl");
6988 cmdline_parse_token_string_t cmd_lfc_set_rx =
6989 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6991 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
6992 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6993 rx_lfc_mode, "on#off");
6994 cmdline_parse_token_string_t cmd_lfc_set_tx =
6995 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6997 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
6998 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6999 tx_lfc_mode, "on#off");
7000 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
7001 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7002 hw_str, "high_water");
7003 cmdline_parse_token_num_t cmd_lfc_set_high_water =
7004 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7005 high_water, RTE_UINT32);
7006 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
7007 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7008 lw_str, "low_water");
7009 cmdline_parse_token_num_t cmd_lfc_set_low_water =
7010 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7011 low_water, RTE_UINT32);
7012 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
7013 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7014 pt_str, "pause_time");
7015 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
7016 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7017 pause_time, RTE_UINT16);
7018 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
7019 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7020 xon_str, "send_xon");
7021 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
7022 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7023 send_xon, RTE_UINT16);
7024 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
7025 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7026 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
7027 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
7028 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7029 mac_ctrl_frame_fwd_mode, "on#off");
7030 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
7031 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7032 autoneg_str, "autoneg");
7033 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
7034 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7036 cmdline_parse_token_num_t cmd_lfc_set_portid =
7037 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7038 port_id, RTE_UINT16);
7040 /* forward declaration */
7042 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
7045 cmdline_parse_inst_t cmd_link_flow_control_set = {
7046 .f = cmd_link_flow_ctrl_set_parsed,
7048 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
7049 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
7050 "autoneg on|off <port_id>: Configure the Ethernet flow control",
7052 (void *)&cmd_lfc_set_set,
7053 (void *)&cmd_lfc_set_flow_ctrl,
7054 (void *)&cmd_lfc_set_rx,
7055 (void *)&cmd_lfc_set_rx_mode,
7056 (void *)&cmd_lfc_set_tx,
7057 (void *)&cmd_lfc_set_tx_mode,
7058 (void *)&cmd_lfc_set_high_water,
7059 (void *)&cmd_lfc_set_low_water,
7060 (void *)&cmd_lfc_set_pause_time,
7061 (void *)&cmd_lfc_set_send_xon,
7062 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
7063 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
7064 (void *)&cmd_lfc_set_autoneg_str,
7065 (void *)&cmd_lfc_set_autoneg,
7066 (void *)&cmd_lfc_set_portid,
7071 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
7072 .f = cmd_link_flow_ctrl_set_parsed,
7073 .data = (void *)&cmd_link_flow_control_set_rx,
7074 .help_str = "set flow_ctrl rx on|off <port_id>: "
7075 "Change rx flow control parameter",
7077 (void *)&cmd_lfc_set_set,
7078 (void *)&cmd_lfc_set_flow_ctrl,
7079 (void *)&cmd_lfc_set_rx,
7080 (void *)&cmd_lfc_set_rx_mode,
7081 (void *)&cmd_lfc_set_portid,
7086 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
7087 .f = cmd_link_flow_ctrl_set_parsed,
7088 .data = (void *)&cmd_link_flow_control_set_tx,
7089 .help_str = "set flow_ctrl tx on|off <port_id>: "
7090 "Change tx flow control parameter",
7092 (void *)&cmd_lfc_set_set,
7093 (void *)&cmd_lfc_set_flow_ctrl,
7094 (void *)&cmd_lfc_set_tx,
7095 (void *)&cmd_lfc_set_tx_mode,
7096 (void *)&cmd_lfc_set_portid,
7101 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
7102 .f = cmd_link_flow_ctrl_set_parsed,
7103 .data = (void *)&cmd_link_flow_control_set_hw,
7104 .help_str = "set flow_ctrl high_water <value> <port_id>: "
7105 "Change high water flow control parameter",
7107 (void *)&cmd_lfc_set_set,
7108 (void *)&cmd_lfc_set_flow_ctrl,
7109 (void *)&cmd_lfc_set_high_water_str,
7110 (void *)&cmd_lfc_set_high_water,
7111 (void *)&cmd_lfc_set_portid,
7116 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
7117 .f = cmd_link_flow_ctrl_set_parsed,
7118 .data = (void *)&cmd_link_flow_control_set_lw,
7119 .help_str = "set flow_ctrl low_water <value> <port_id>: "
7120 "Change low water flow control parameter",
7122 (void *)&cmd_lfc_set_set,
7123 (void *)&cmd_lfc_set_flow_ctrl,
7124 (void *)&cmd_lfc_set_low_water_str,
7125 (void *)&cmd_lfc_set_low_water,
7126 (void *)&cmd_lfc_set_portid,
7131 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
7132 .f = cmd_link_flow_ctrl_set_parsed,
7133 .data = (void *)&cmd_link_flow_control_set_pt,
7134 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
7135 "Change pause time flow control parameter",
7137 (void *)&cmd_lfc_set_set,
7138 (void *)&cmd_lfc_set_flow_ctrl,
7139 (void *)&cmd_lfc_set_pause_time_str,
7140 (void *)&cmd_lfc_set_pause_time,
7141 (void *)&cmd_lfc_set_portid,
7146 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
7147 .f = cmd_link_flow_ctrl_set_parsed,
7148 .data = (void *)&cmd_link_flow_control_set_xon,
7149 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
7150 "Change send_xon flow control parameter",
7152 (void *)&cmd_lfc_set_set,
7153 (void *)&cmd_lfc_set_flow_ctrl,
7154 (void *)&cmd_lfc_set_send_xon_str,
7155 (void *)&cmd_lfc_set_send_xon,
7156 (void *)&cmd_lfc_set_portid,
7161 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
7162 .f = cmd_link_flow_ctrl_set_parsed,
7163 .data = (void *)&cmd_link_flow_control_set_macfwd,
7164 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
7165 "Change mac ctrl fwd flow control parameter",
7167 (void *)&cmd_lfc_set_set,
7168 (void *)&cmd_lfc_set_flow_ctrl,
7169 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
7170 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
7171 (void *)&cmd_lfc_set_portid,
7176 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
7177 .f = cmd_link_flow_ctrl_set_parsed,
7178 .data = (void *)&cmd_link_flow_control_set_autoneg,
7179 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
7180 "Change autoneg flow control parameter",
7182 (void *)&cmd_lfc_set_set,
7183 (void *)&cmd_lfc_set_flow_ctrl,
7184 (void *)&cmd_lfc_set_autoneg_str,
7185 (void *)&cmd_lfc_set_autoneg,
7186 (void *)&cmd_lfc_set_portid,
7192 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
7193 __rte_unused struct cmdline *cl,
7196 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
7197 cmdline_parse_inst_t *cmd = data;
7198 struct rte_eth_fc_conf fc_conf;
7204 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7205 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7206 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7207 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7209 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
7210 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7213 /* Partial command line, retrieve current configuration */
7215 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
7217 printf("cannot get current flow ctrl parameters, return"
7218 "code = %d\n", ret);
7222 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
7223 (fc_conf.mode == RTE_FC_FULL))
7225 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
7226 (fc_conf.mode == RTE_FC_FULL))
7230 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
7231 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
7233 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
7234 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
7236 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
7238 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
7239 fc_conf.high_water = res->high_water;
7241 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
7242 fc_conf.low_water = res->low_water;
7244 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
7245 fc_conf.pause_time = res->pause_time;
7247 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
7248 fc_conf.send_xon = res->send_xon;
7250 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
7251 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
7252 fc_conf.mac_ctrl_frame_fwd = 1;
7254 fc_conf.mac_ctrl_frame_fwd = 0;
7257 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
7258 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
7260 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
7262 printf("bad flow contrl parameter, return code = %d \n", ret);
7265 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
7266 struct cmd_priority_flow_ctrl_set_result {
7267 cmdline_fixed_string_t set;
7268 cmdline_fixed_string_t pfc_ctrl;
7269 cmdline_fixed_string_t rx;
7270 cmdline_fixed_string_t rx_pfc_mode;
7271 cmdline_fixed_string_t tx;
7272 cmdline_fixed_string_t tx_pfc_mode;
7273 uint32_t high_water;
7275 uint16_t pause_time;
7281 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
7282 __rte_unused struct cmdline *cl,
7283 __rte_unused void *data)
7285 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
7286 struct rte_eth_pfc_conf pfc_conf;
7287 int rx_fc_enable, tx_fc_enable;
7291 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7292 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7293 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7294 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7296 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
7297 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7300 memset(&pfc_conf, 0, sizeof(struct rte_eth_pfc_conf));
7301 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
7302 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
7303 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
7304 pfc_conf.fc.high_water = res->high_water;
7305 pfc_conf.fc.low_water = res->low_water;
7306 pfc_conf.fc.pause_time = res->pause_time;
7307 pfc_conf.priority = res->priority;
7309 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
7311 printf("bad priority flow contrl parameter, return code = %d \n", ret);
7314 cmdline_parse_token_string_t cmd_pfc_set_set =
7315 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7317 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
7318 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7319 pfc_ctrl, "pfc_ctrl");
7320 cmdline_parse_token_string_t cmd_pfc_set_rx =
7321 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7323 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
7324 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7325 rx_pfc_mode, "on#off");
7326 cmdline_parse_token_string_t cmd_pfc_set_tx =
7327 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7329 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
7330 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7331 tx_pfc_mode, "on#off");
7332 cmdline_parse_token_num_t cmd_pfc_set_high_water =
7333 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7334 high_water, RTE_UINT32);
7335 cmdline_parse_token_num_t cmd_pfc_set_low_water =
7336 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7337 low_water, RTE_UINT32);
7338 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
7339 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7340 pause_time, RTE_UINT16);
7341 cmdline_parse_token_num_t cmd_pfc_set_priority =
7342 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7343 priority, RTE_UINT8);
7344 cmdline_parse_token_num_t cmd_pfc_set_portid =
7345 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7346 port_id, RTE_UINT16);
7348 cmdline_parse_inst_t cmd_priority_flow_control_set = {
7349 .f = cmd_priority_flow_ctrl_set_parsed,
7351 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
7352 "<pause_time> <priority> <port_id>: "
7353 "Configure the Ethernet priority flow control",
7355 (void *)&cmd_pfc_set_set,
7356 (void *)&cmd_pfc_set_flow_ctrl,
7357 (void *)&cmd_pfc_set_rx,
7358 (void *)&cmd_pfc_set_rx_mode,
7359 (void *)&cmd_pfc_set_tx,
7360 (void *)&cmd_pfc_set_tx_mode,
7361 (void *)&cmd_pfc_set_high_water,
7362 (void *)&cmd_pfc_set_low_water,
7363 (void *)&cmd_pfc_set_pause_time,
7364 (void *)&cmd_pfc_set_priority,
7365 (void *)&cmd_pfc_set_portid,
7370 /* *** RESET CONFIGURATION *** */
7371 struct cmd_reset_result {
7372 cmdline_fixed_string_t reset;
7373 cmdline_fixed_string_t def;
7376 static void cmd_reset_parsed(__rte_unused void *parsed_result,
7378 __rte_unused void *data)
7380 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
7381 set_def_fwd_config();
7384 cmdline_parse_token_string_t cmd_reset_set =
7385 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
7386 cmdline_parse_token_string_t cmd_reset_def =
7387 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
7390 cmdline_parse_inst_t cmd_reset = {
7391 .f = cmd_reset_parsed,
7393 .help_str = "set default: Reset default forwarding configuration",
7395 (void *)&cmd_reset_set,
7396 (void *)&cmd_reset_def,
7401 /* *** START FORWARDING *** */
7402 struct cmd_start_result {
7403 cmdline_fixed_string_t start;
7406 cmdline_parse_token_string_t cmd_start_start =
7407 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
7409 static void cmd_start_parsed(__rte_unused void *parsed_result,
7410 __rte_unused struct cmdline *cl,
7411 __rte_unused void *data)
7413 start_packet_forwarding(0);
7416 cmdline_parse_inst_t cmd_start = {
7417 .f = cmd_start_parsed,
7419 .help_str = "start: Start packet forwarding",
7421 (void *)&cmd_start_start,
7426 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7427 struct cmd_start_tx_first_result {
7428 cmdline_fixed_string_t start;
7429 cmdline_fixed_string_t tx_first;
7433 cmd_start_tx_first_parsed(__rte_unused void *parsed_result,
7434 __rte_unused struct cmdline *cl,
7435 __rte_unused void *data)
7437 start_packet_forwarding(1);
7440 cmdline_parse_token_string_t cmd_start_tx_first_start =
7441 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7443 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7444 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7445 tx_first, "tx_first");
7447 cmdline_parse_inst_t cmd_start_tx_first = {
7448 .f = cmd_start_tx_first_parsed,
7450 .help_str = "start tx_first: Start packet forwarding, "
7451 "after sending 1 burst of packets",
7453 (void *)&cmd_start_tx_first_start,
7454 (void *)&cmd_start_tx_first_tx_first,
7459 /* *** START FORWARDING WITH N TX BURST FIRST *** */
7460 struct cmd_start_tx_first_n_result {
7461 cmdline_fixed_string_t start;
7462 cmdline_fixed_string_t tx_first;
7467 cmd_start_tx_first_n_parsed(void *parsed_result,
7468 __rte_unused struct cmdline *cl,
7469 __rte_unused void *data)
7471 struct cmd_start_tx_first_n_result *res = parsed_result;
7473 start_packet_forwarding(res->tx_num);
7476 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7477 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7479 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7480 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7481 tx_first, "tx_first");
7482 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7483 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7484 tx_num, RTE_UINT32);
7486 cmdline_parse_inst_t cmd_start_tx_first_n = {
7487 .f = cmd_start_tx_first_n_parsed,
7489 .help_str = "start tx_first <num>: "
7490 "packet forwarding, after sending <num> bursts of packets",
7492 (void *)&cmd_start_tx_first_n_start,
7493 (void *)&cmd_start_tx_first_n_tx_first,
7494 (void *)&cmd_start_tx_first_n_tx_num,
7499 /* *** SET LINK UP *** */
7500 struct cmd_set_link_up_result {
7501 cmdline_fixed_string_t set;
7502 cmdline_fixed_string_t link_up;
7503 cmdline_fixed_string_t port;
7507 cmdline_parse_token_string_t cmd_set_link_up_set =
7508 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7509 cmdline_parse_token_string_t cmd_set_link_up_link_up =
7510 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7512 cmdline_parse_token_string_t cmd_set_link_up_port =
7513 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7514 cmdline_parse_token_num_t cmd_set_link_up_port_id =
7515 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id,
7518 static void cmd_set_link_up_parsed(__rte_unused void *parsed_result,
7519 __rte_unused struct cmdline *cl,
7520 __rte_unused void *data)
7522 struct cmd_set_link_up_result *res = parsed_result;
7523 dev_set_link_up(res->port_id);
7526 cmdline_parse_inst_t cmd_set_link_up = {
7527 .f = cmd_set_link_up_parsed,
7529 .help_str = "set link-up port <port id>",
7531 (void *)&cmd_set_link_up_set,
7532 (void *)&cmd_set_link_up_link_up,
7533 (void *)&cmd_set_link_up_port,
7534 (void *)&cmd_set_link_up_port_id,
7539 /* *** SET LINK DOWN *** */
7540 struct cmd_set_link_down_result {
7541 cmdline_fixed_string_t set;
7542 cmdline_fixed_string_t link_down;
7543 cmdline_fixed_string_t port;
7547 cmdline_parse_token_string_t cmd_set_link_down_set =
7548 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
7549 cmdline_parse_token_string_t cmd_set_link_down_link_down =
7550 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
7552 cmdline_parse_token_string_t cmd_set_link_down_port =
7553 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
7554 cmdline_parse_token_num_t cmd_set_link_down_port_id =
7555 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id,
7558 static void cmd_set_link_down_parsed(
7559 __rte_unused void *parsed_result,
7560 __rte_unused struct cmdline *cl,
7561 __rte_unused void *data)
7563 struct cmd_set_link_down_result *res = parsed_result;
7564 dev_set_link_down(res->port_id);
7567 cmdline_parse_inst_t cmd_set_link_down = {
7568 .f = cmd_set_link_down_parsed,
7570 .help_str = "set link-down port <port id>",
7572 (void *)&cmd_set_link_down_set,
7573 (void *)&cmd_set_link_down_link_down,
7574 (void *)&cmd_set_link_down_port,
7575 (void *)&cmd_set_link_down_port_id,
7580 /* *** SHOW CFG *** */
7581 struct cmd_showcfg_result {
7582 cmdline_fixed_string_t show;
7583 cmdline_fixed_string_t cfg;
7584 cmdline_fixed_string_t what;
7587 static void cmd_showcfg_parsed(void *parsed_result,
7588 __rte_unused struct cmdline *cl,
7589 __rte_unused void *data)
7591 struct cmd_showcfg_result *res = parsed_result;
7592 if (!strcmp(res->what, "rxtx"))
7593 rxtx_config_display();
7594 else if (!strcmp(res->what, "cores"))
7595 fwd_lcores_config_display();
7596 else if (!strcmp(res->what, "fwd"))
7597 pkt_fwd_config_display(&cur_fwd_config);
7598 else if (!strcmp(res->what, "rxoffs"))
7599 show_rx_pkt_offsets();
7600 else if (!strcmp(res->what, "rxpkts"))
7601 show_rx_pkt_segments();
7602 else if (!strcmp(res->what, "txpkts"))
7603 show_tx_pkt_segments();
7604 else if (!strcmp(res->what, "txtimes"))
7605 show_tx_pkt_times();
7608 cmdline_parse_token_string_t cmd_showcfg_show =
7609 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7610 cmdline_parse_token_string_t cmd_showcfg_port =
7611 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7612 cmdline_parse_token_string_t cmd_showcfg_what =
7613 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7614 "rxtx#cores#fwd#rxoffs#rxpkts#txpkts#txtimes");
7616 cmdline_parse_inst_t cmd_showcfg = {
7617 .f = cmd_showcfg_parsed,
7619 .help_str = "show config rxtx|cores|fwd|rxoffs|rxpkts|txpkts|txtimes",
7621 (void *)&cmd_showcfg_show,
7622 (void *)&cmd_showcfg_port,
7623 (void *)&cmd_showcfg_what,
7628 /* *** SHOW ALL PORT INFO *** */
7629 struct cmd_showportall_result {
7630 cmdline_fixed_string_t show;
7631 cmdline_fixed_string_t port;
7632 cmdline_fixed_string_t what;
7633 cmdline_fixed_string_t all;
7636 static void cmd_showportall_parsed(void *parsed_result,
7637 __rte_unused struct cmdline *cl,
7638 __rte_unused void *data)
7642 struct cmd_showportall_result *res = parsed_result;
7643 if (!strcmp(res->show, "clear")) {
7644 if (!strcmp(res->what, "stats"))
7645 RTE_ETH_FOREACH_DEV(i)
7647 else if (!strcmp(res->what, "xstats"))
7648 RTE_ETH_FOREACH_DEV(i)
7649 nic_xstats_clear(i);
7650 } else if (!strcmp(res->what, "info"))
7651 RTE_ETH_FOREACH_DEV(i)
7652 port_infos_display(i);
7653 else if (!strcmp(res->what, "summary")) {
7654 port_summary_header_display();
7655 RTE_ETH_FOREACH_DEV(i)
7656 port_summary_display(i);
7658 else if (!strcmp(res->what, "stats"))
7659 RTE_ETH_FOREACH_DEV(i)
7660 nic_stats_display(i);
7661 else if (!strcmp(res->what, "xstats"))
7662 RTE_ETH_FOREACH_DEV(i)
7663 nic_xstats_display(i);
7664 #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
7665 else if (!strcmp(res->what, "fdir"))
7666 RTE_ETH_FOREACH_DEV(i)
7669 else if (!strcmp(res->what, "dcb_tc"))
7670 RTE_ETH_FOREACH_DEV(i)
7671 port_dcb_info_display(i);
7674 cmdline_parse_token_string_t cmd_showportall_show =
7675 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7677 cmdline_parse_token_string_t cmd_showportall_port =
7678 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7679 cmdline_parse_token_string_t cmd_showportall_what =
7680 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7681 "info#summary#stats#xstats#fdir#dcb_tc");
7682 cmdline_parse_token_string_t cmd_showportall_all =
7683 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7684 cmdline_parse_inst_t cmd_showportall = {
7685 .f = cmd_showportall_parsed,
7687 .help_str = "show|clear port "
7688 "info|summary|stats|xstats|fdir|dcb_tc all",
7690 (void *)&cmd_showportall_show,
7691 (void *)&cmd_showportall_port,
7692 (void *)&cmd_showportall_what,
7693 (void *)&cmd_showportall_all,
7698 /* *** SHOW PORT INFO *** */
7699 struct cmd_showport_result {
7700 cmdline_fixed_string_t show;
7701 cmdline_fixed_string_t port;
7702 cmdline_fixed_string_t what;
7706 static void cmd_showport_parsed(void *parsed_result,
7707 __rte_unused struct cmdline *cl,
7708 __rte_unused void *data)
7710 struct cmd_showport_result *res = parsed_result;
7711 if (!strcmp(res->show, "clear")) {
7712 if (!strcmp(res->what, "stats"))
7713 nic_stats_clear(res->portnum);
7714 else if (!strcmp(res->what, "xstats"))
7715 nic_xstats_clear(res->portnum);
7716 } else if (!strcmp(res->what, "info"))
7717 port_infos_display(res->portnum);
7718 else if (!strcmp(res->what, "summary")) {
7719 port_summary_header_display();
7720 port_summary_display(res->portnum);
7722 else if (!strcmp(res->what, "stats"))
7723 nic_stats_display(res->portnum);
7724 else if (!strcmp(res->what, "xstats"))
7725 nic_xstats_display(res->portnum);
7726 #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
7727 else if (!strcmp(res->what, "fdir"))
7728 fdir_get_infos(res->portnum);
7730 else if (!strcmp(res->what, "dcb_tc"))
7731 port_dcb_info_display(res->portnum);
7734 cmdline_parse_token_string_t cmd_showport_show =
7735 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7737 cmdline_parse_token_string_t cmd_showport_port =
7738 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7739 cmdline_parse_token_string_t cmd_showport_what =
7740 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7741 "info#summary#stats#xstats#fdir#dcb_tc");
7742 cmdline_parse_token_num_t cmd_showport_portnum =
7743 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, RTE_UINT16);
7745 cmdline_parse_inst_t cmd_showport = {
7746 .f = cmd_showport_parsed,
7748 .help_str = "show|clear port "
7749 "info|summary|stats|xstats|fdir|dcb_tc "
7752 (void *)&cmd_showport_show,
7753 (void *)&cmd_showport_port,
7754 (void *)&cmd_showport_what,
7755 (void *)&cmd_showport_portnum,
7760 /* *** SHOW DEVICE INFO *** */
7761 struct cmd_showdevice_result {
7762 cmdline_fixed_string_t show;
7763 cmdline_fixed_string_t device;
7764 cmdline_fixed_string_t what;
7765 cmdline_fixed_string_t identifier;
7768 static void cmd_showdevice_parsed(void *parsed_result,
7769 __rte_unused struct cmdline *cl,
7770 __rte_unused void *data)
7772 struct cmd_showdevice_result *res = parsed_result;
7773 if (!strcmp(res->what, "info")) {
7774 if (!strcmp(res->identifier, "all"))
7775 device_infos_display(NULL);
7777 device_infos_display(res->identifier);
7781 cmdline_parse_token_string_t cmd_showdevice_show =
7782 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show,
7784 cmdline_parse_token_string_t cmd_showdevice_device =
7785 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device");
7786 cmdline_parse_token_string_t cmd_showdevice_what =
7787 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what,
7789 cmdline_parse_token_string_t cmd_showdevice_identifier =
7790 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result,
7793 cmdline_parse_inst_t cmd_showdevice = {
7794 .f = cmd_showdevice_parsed,
7796 .help_str = "show device info <identifier>|all",
7798 (void *)&cmd_showdevice_show,
7799 (void *)&cmd_showdevice_device,
7800 (void *)&cmd_showdevice_what,
7801 (void *)&cmd_showdevice_identifier,
7806 /* *** SHOW MODULE EEPROM/EEPROM port INFO *** */
7807 struct cmd_showeeprom_result {
7808 cmdline_fixed_string_t show;
7809 cmdline_fixed_string_t port;
7811 cmdline_fixed_string_t type;
7814 static void cmd_showeeprom_parsed(void *parsed_result,
7815 __rte_unused struct cmdline *cl,
7816 __rte_unused void *data)
7818 struct cmd_showeeprom_result *res = parsed_result;
7820 if (!strcmp(res->type, "eeprom"))
7821 port_eeprom_display(res->portnum);
7822 else if (!strcmp(res->type, "module_eeprom"))
7823 port_module_eeprom_display(res->portnum);
7825 printf("Unknown argument\n");
7828 cmdline_parse_token_string_t cmd_showeeprom_show =
7829 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, show, "show");
7830 cmdline_parse_token_string_t cmd_showeeprom_port =
7831 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, port, "port");
7832 cmdline_parse_token_num_t cmd_showeeprom_portnum =
7833 TOKEN_NUM_INITIALIZER(struct cmd_showeeprom_result, portnum,
7835 cmdline_parse_token_string_t cmd_showeeprom_type =
7836 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, type, "module_eeprom#eeprom");
7838 cmdline_parse_inst_t cmd_showeeprom = {
7839 .f = cmd_showeeprom_parsed,
7841 .help_str = "show port <port_id> module_eeprom|eeprom",
7843 (void *)&cmd_showeeprom_show,
7844 (void *)&cmd_showeeprom_port,
7845 (void *)&cmd_showeeprom_portnum,
7846 (void *)&cmd_showeeprom_type,
7851 /* *** SHOW QUEUE INFO *** */
7852 struct cmd_showqueue_result {
7853 cmdline_fixed_string_t show;
7854 cmdline_fixed_string_t type;
7855 cmdline_fixed_string_t what;
7861 cmd_showqueue_parsed(void *parsed_result,
7862 __rte_unused struct cmdline *cl,
7863 __rte_unused void *data)
7865 struct cmd_showqueue_result *res = parsed_result;
7867 if (!strcmp(res->type, "rxq"))
7868 rx_queue_infos_display(res->portnum, res->queuenum);
7869 else if (!strcmp(res->type, "txq"))
7870 tx_queue_infos_display(res->portnum, res->queuenum);
7873 cmdline_parse_token_string_t cmd_showqueue_show =
7874 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
7875 cmdline_parse_token_string_t cmd_showqueue_type =
7876 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
7877 cmdline_parse_token_string_t cmd_showqueue_what =
7878 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
7879 cmdline_parse_token_num_t cmd_showqueue_portnum =
7880 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum,
7882 cmdline_parse_token_num_t cmd_showqueue_queuenum =
7883 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum,
7886 cmdline_parse_inst_t cmd_showqueue = {
7887 .f = cmd_showqueue_parsed,
7889 .help_str = "show rxq|txq info <port_id> <queue_id>",
7891 (void *)&cmd_showqueue_show,
7892 (void *)&cmd_showqueue_type,
7893 (void *)&cmd_showqueue_what,
7894 (void *)&cmd_showqueue_portnum,
7895 (void *)&cmd_showqueue_queuenum,
7900 /* show/clear fwd engine statistics */
7902 cmdline_fixed_string_t action;
7903 cmdline_fixed_string_t fwd;
7904 cmdline_fixed_string_t stats;
7905 cmdline_fixed_string_t all;
7908 cmdline_parse_token_string_t cmd_fwd_action =
7909 TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
7910 cmdline_parse_token_string_t cmd_fwd_fwd =
7911 TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
7912 cmdline_parse_token_string_t cmd_fwd_stats =
7913 TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
7914 cmdline_parse_token_string_t cmd_fwd_all =
7915 TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
7918 cmd_showfwdall_parsed(void *parsed_result,
7919 __rte_unused struct cmdline *cl,
7920 __rte_unused void *data)
7922 struct fwd_result *res = parsed_result;
7924 if (!strcmp(res->action, "show"))
7925 fwd_stats_display();
7930 static cmdline_parse_inst_t cmd_showfwdall = {
7931 .f = cmd_showfwdall_parsed,
7933 .help_str = "show|clear fwd stats all",
7935 (void *)&cmd_fwd_action,
7936 (void *)&cmd_fwd_fwd,
7937 (void *)&cmd_fwd_stats,
7938 (void *)&cmd_fwd_all,
7943 /* *** READ PORT REGISTER *** */
7944 struct cmd_read_reg_result {
7945 cmdline_fixed_string_t read;
7946 cmdline_fixed_string_t reg;
7952 cmd_read_reg_parsed(void *parsed_result,
7953 __rte_unused struct cmdline *cl,
7954 __rte_unused void *data)
7956 struct cmd_read_reg_result *res = parsed_result;
7957 port_reg_display(res->port_id, res->reg_off);
7960 cmdline_parse_token_string_t cmd_read_reg_read =
7961 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
7962 cmdline_parse_token_string_t cmd_read_reg_reg =
7963 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
7964 cmdline_parse_token_num_t cmd_read_reg_port_id =
7965 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, RTE_UINT16);
7966 cmdline_parse_token_num_t cmd_read_reg_reg_off =
7967 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, RTE_UINT32);
7969 cmdline_parse_inst_t cmd_read_reg = {
7970 .f = cmd_read_reg_parsed,
7972 .help_str = "read reg <port_id> <reg_off>",
7974 (void *)&cmd_read_reg_read,
7975 (void *)&cmd_read_reg_reg,
7976 (void *)&cmd_read_reg_port_id,
7977 (void *)&cmd_read_reg_reg_off,
7982 /* *** READ PORT REGISTER BIT FIELD *** */
7983 struct cmd_read_reg_bit_field_result {
7984 cmdline_fixed_string_t read;
7985 cmdline_fixed_string_t regfield;
7993 cmd_read_reg_bit_field_parsed(void *parsed_result,
7994 __rte_unused struct cmdline *cl,
7995 __rte_unused void *data)
7997 struct cmd_read_reg_bit_field_result *res = parsed_result;
7998 port_reg_bit_field_display(res->port_id, res->reg_off,
7999 res->bit1_pos, res->bit2_pos);
8002 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
8003 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
8005 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
8006 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
8007 regfield, "regfield");
8008 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
8009 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
8011 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
8012 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
8014 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
8015 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
8017 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
8018 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
8021 cmdline_parse_inst_t cmd_read_reg_bit_field = {
8022 .f = cmd_read_reg_bit_field_parsed,
8024 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
8025 "Read register bit field between bit_x and bit_y included",
8027 (void *)&cmd_read_reg_bit_field_read,
8028 (void *)&cmd_read_reg_bit_field_regfield,
8029 (void *)&cmd_read_reg_bit_field_port_id,
8030 (void *)&cmd_read_reg_bit_field_reg_off,
8031 (void *)&cmd_read_reg_bit_field_bit1_pos,
8032 (void *)&cmd_read_reg_bit_field_bit2_pos,
8037 /* *** READ PORT REGISTER BIT *** */
8038 struct cmd_read_reg_bit_result {
8039 cmdline_fixed_string_t read;
8040 cmdline_fixed_string_t regbit;
8047 cmd_read_reg_bit_parsed(void *parsed_result,
8048 __rte_unused struct cmdline *cl,
8049 __rte_unused void *data)
8051 struct cmd_read_reg_bit_result *res = parsed_result;
8052 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
8055 cmdline_parse_token_string_t cmd_read_reg_bit_read =
8056 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
8057 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
8058 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
8060 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
8061 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id,
8063 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
8064 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off,
8066 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
8067 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos,
8070 cmdline_parse_inst_t cmd_read_reg_bit = {
8071 .f = cmd_read_reg_bit_parsed,
8073 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
8075 (void *)&cmd_read_reg_bit_read,
8076 (void *)&cmd_read_reg_bit_regbit,
8077 (void *)&cmd_read_reg_bit_port_id,
8078 (void *)&cmd_read_reg_bit_reg_off,
8079 (void *)&cmd_read_reg_bit_bit_pos,
8084 /* *** WRITE PORT REGISTER *** */
8085 struct cmd_write_reg_result {
8086 cmdline_fixed_string_t write;
8087 cmdline_fixed_string_t reg;
8094 cmd_write_reg_parsed(void *parsed_result,
8095 __rte_unused struct cmdline *cl,
8096 __rte_unused void *data)
8098 struct cmd_write_reg_result *res = parsed_result;
8099 port_reg_set(res->port_id, res->reg_off, res->value);
8102 cmdline_parse_token_string_t cmd_write_reg_write =
8103 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
8104 cmdline_parse_token_string_t cmd_write_reg_reg =
8105 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
8106 cmdline_parse_token_num_t cmd_write_reg_port_id =
8107 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, RTE_UINT16);
8108 cmdline_parse_token_num_t cmd_write_reg_reg_off =
8109 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, RTE_UINT32);
8110 cmdline_parse_token_num_t cmd_write_reg_value =
8111 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, RTE_UINT32);
8113 cmdline_parse_inst_t cmd_write_reg = {
8114 .f = cmd_write_reg_parsed,
8116 .help_str = "write reg <port_id> <reg_off> <reg_value>",
8118 (void *)&cmd_write_reg_write,
8119 (void *)&cmd_write_reg_reg,
8120 (void *)&cmd_write_reg_port_id,
8121 (void *)&cmd_write_reg_reg_off,
8122 (void *)&cmd_write_reg_value,
8127 /* *** WRITE PORT REGISTER BIT FIELD *** */
8128 struct cmd_write_reg_bit_field_result {
8129 cmdline_fixed_string_t write;
8130 cmdline_fixed_string_t regfield;
8139 cmd_write_reg_bit_field_parsed(void *parsed_result,
8140 __rte_unused struct cmdline *cl,
8141 __rte_unused void *data)
8143 struct cmd_write_reg_bit_field_result *res = parsed_result;
8144 port_reg_bit_field_set(res->port_id, res->reg_off,
8145 res->bit1_pos, res->bit2_pos, res->value);
8148 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
8149 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
8151 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
8152 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
8153 regfield, "regfield");
8154 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
8155 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
8157 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
8158 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
8160 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
8161 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
8163 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
8164 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
8166 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
8167 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
8170 cmdline_parse_inst_t cmd_write_reg_bit_field = {
8171 .f = cmd_write_reg_bit_field_parsed,
8173 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
8175 "Set register bit field between bit_x and bit_y included",
8177 (void *)&cmd_write_reg_bit_field_write,
8178 (void *)&cmd_write_reg_bit_field_regfield,
8179 (void *)&cmd_write_reg_bit_field_port_id,
8180 (void *)&cmd_write_reg_bit_field_reg_off,
8181 (void *)&cmd_write_reg_bit_field_bit1_pos,
8182 (void *)&cmd_write_reg_bit_field_bit2_pos,
8183 (void *)&cmd_write_reg_bit_field_value,
8188 /* *** WRITE PORT REGISTER BIT *** */
8189 struct cmd_write_reg_bit_result {
8190 cmdline_fixed_string_t write;
8191 cmdline_fixed_string_t regbit;
8199 cmd_write_reg_bit_parsed(void *parsed_result,
8200 __rte_unused struct cmdline *cl,
8201 __rte_unused void *data)
8203 struct cmd_write_reg_bit_result *res = parsed_result;
8204 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
8207 cmdline_parse_token_string_t cmd_write_reg_bit_write =
8208 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
8210 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
8211 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
8213 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
8214 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id,
8216 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
8217 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off,
8219 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
8220 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos,
8222 cmdline_parse_token_num_t cmd_write_reg_bit_value =
8223 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value,
8226 cmdline_parse_inst_t cmd_write_reg_bit = {
8227 .f = cmd_write_reg_bit_parsed,
8229 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
8232 (void *)&cmd_write_reg_bit_write,
8233 (void *)&cmd_write_reg_bit_regbit,
8234 (void *)&cmd_write_reg_bit_port_id,
8235 (void *)&cmd_write_reg_bit_reg_off,
8236 (void *)&cmd_write_reg_bit_bit_pos,
8237 (void *)&cmd_write_reg_bit_value,
8242 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
8243 struct cmd_read_rxd_txd_result {
8244 cmdline_fixed_string_t read;
8245 cmdline_fixed_string_t rxd_txd;
8252 cmd_read_rxd_txd_parsed(void *parsed_result,
8253 __rte_unused struct cmdline *cl,
8254 __rte_unused void *data)
8256 struct cmd_read_rxd_txd_result *res = parsed_result;
8258 if (!strcmp(res->rxd_txd, "rxd"))
8259 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8260 else if (!strcmp(res->rxd_txd, "txd"))
8261 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8264 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
8265 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
8266 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
8267 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
8269 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
8270 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id,
8272 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
8273 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id,
8275 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
8276 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id,
8279 cmdline_parse_inst_t cmd_read_rxd_txd = {
8280 .f = cmd_read_rxd_txd_parsed,
8282 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
8284 (void *)&cmd_read_rxd_txd_read,
8285 (void *)&cmd_read_rxd_txd_rxd_txd,
8286 (void *)&cmd_read_rxd_txd_port_id,
8287 (void *)&cmd_read_rxd_txd_queue_id,
8288 (void *)&cmd_read_rxd_txd_desc_id,
8294 struct cmd_quit_result {
8295 cmdline_fixed_string_t quit;
8298 static void cmd_quit_parsed(__rte_unused void *parsed_result,
8300 __rte_unused void *data)
8305 cmdline_parse_token_string_t cmd_quit_quit =
8306 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
8308 cmdline_parse_inst_t cmd_quit = {
8309 .f = cmd_quit_parsed,
8311 .help_str = "quit: Exit application",
8313 (void *)&cmd_quit_quit,
8318 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
8319 struct cmd_mac_addr_result {
8320 cmdline_fixed_string_t mac_addr_cmd;
8321 cmdline_fixed_string_t what;
8323 struct rte_ether_addr address;
8326 static void cmd_mac_addr_parsed(void *parsed_result,
8327 __rte_unused struct cmdline *cl,
8328 __rte_unused void *data)
8330 struct cmd_mac_addr_result *res = parsed_result;
8333 if (strcmp(res->what, "add") == 0)
8334 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
8335 else if (strcmp(res->what, "set") == 0)
8336 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
8339 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
8341 /* check the return value and print it if is < 0 */
8343 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
8347 cmdline_parse_token_string_t cmd_mac_addr_cmd =
8348 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
8350 cmdline_parse_token_string_t cmd_mac_addr_what =
8351 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
8353 cmdline_parse_token_num_t cmd_mac_addr_portnum =
8354 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
8356 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
8357 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
8359 cmdline_parse_inst_t cmd_mac_addr = {
8360 .f = cmd_mac_addr_parsed,
8362 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
8363 "Add/Remove/Set MAC address on port_id",
8365 (void *)&cmd_mac_addr_cmd,
8366 (void *)&cmd_mac_addr_what,
8367 (void *)&cmd_mac_addr_portnum,
8368 (void *)&cmd_mac_addr_addr,
8373 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
8374 struct cmd_eth_peer_result {
8375 cmdline_fixed_string_t set;
8376 cmdline_fixed_string_t eth_peer;
8378 cmdline_fixed_string_t peer_addr;
8381 static void cmd_set_eth_peer_parsed(void *parsed_result,
8382 __rte_unused struct cmdline *cl,
8383 __rte_unused void *data)
8385 struct cmd_eth_peer_result *res = parsed_result;
8387 if (test_done == 0) {
8388 printf("Please stop forwarding first\n");
8391 if (!strcmp(res->eth_peer, "eth-peer")) {
8392 set_fwd_eth_peer(res->port_id, res->peer_addr);
8396 cmdline_parse_token_string_t cmd_eth_peer_set =
8397 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
8398 cmdline_parse_token_string_t cmd_eth_peer =
8399 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
8400 cmdline_parse_token_num_t cmd_eth_peer_port_id =
8401 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id,
8403 cmdline_parse_token_string_t cmd_eth_peer_addr =
8404 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
8406 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
8407 .f = cmd_set_eth_peer_parsed,
8409 .help_str = "set eth-peer <port_id> <peer_mac>",
8411 (void *)&cmd_eth_peer_set,
8412 (void *)&cmd_eth_peer,
8413 (void *)&cmd_eth_peer_port_id,
8414 (void *)&cmd_eth_peer_addr,
8419 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
8420 struct cmd_set_qmap_result {
8421 cmdline_fixed_string_t set;
8422 cmdline_fixed_string_t qmap;
8423 cmdline_fixed_string_t what;
8430 cmd_set_qmap_parsed(void *parsed_result,
8431 __rte_unused struct cmdline *cl,
8432 __rte_unused void *data)
8434 struct cmd_set_qmap_result *res = parsed_result;
8435 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
8437 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
8440 cmdline_parse_token_string_t cmd_setqmap_set =
8441 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8443 cmdline_parse_token_string_t cmd_setqmap_qmap =
8444 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8446 cmdline_parse_token_string_t cmd_setqmap_what =
8447 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8449 cmdline_parse_token_num_t cmd_setqmap_portid =
8450 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8451 port_id, RTE_UINT16);
8452 cmdline_parse_token_num_t cmd_setqmap_queueid =
8453 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8454 queue_id, RTE_UINT16);
8455 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
8456 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8457 map_value, RTE_UINT8);
8459 cmdline_parse_inst_t cmd_set_qmap = {
8460 .f = cmd_set_qmap_parsed,
8462 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
8463 "Set statistics mapping value on tx|rx queue_id of port_id",
8465 (void *)&cmd_setqmap_set,
8466 (void *)&cmd_setqmap_qmap,
8467 (void *)&cmd_setqmap_what,
8468 (void *)&cmd_setqmap_portid,
8469 (void *)&cmd_setqmap_queueid,
8470 (void *)&cmd_setqmap_mapvalue,
8475 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
8476 struct cmd_set_xstats_hide_zero_result {
8477 cmdline_fixed_string_t keyword;
8478 cmdline_fixed_string_t name;
8479 cmdline_fixed_string_t on_off;
8483 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
8484 __rte_unused struct cmdline *cl,
8485 __rte_unused void *data)
8487 struct cmd_set_xstats_hide_zero_result *res;
8488 uint16_t on_off = 0;
8490 res = parsed_result;
8491 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8492 set_xstats_hide_zero(on_off);
8495 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
8496 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8498 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
8499 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8500 name, "xstats-hide-zero");
8501 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
8502 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8505 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
8506 .f = cmd_set_xstats_hide_zero_parsed,
8508 .help_str = "set xstats-hide-zero on|off",
8510 (void *)&cmd_set_xstats_hide_zero_keyword,
8511 (void *)&cmd_set_xstats_hide_zero_name,
8512 (void *)&cmd_set_xstats_hide_zero_on_off,
8517 /* *** SET OPTION TO ENABLE MEASUREMENT OF CPU CYCLES *** */
8518 struct cmd_set_record_core_cycles_result {
8519 cmdline_fixed_string_t keyword;
8520 cmdline_fixed_string_t name;
8521 cmdline_fixed_string_t on_off;
8525 cmd_set_record_core_cycles_parsed(void *parsed_result,
8526 __rte_unused struct cmdline *cl,
8527 __rte_unused void *data)
8529 struct cmd_set_record_core_cycles_result *res;
8530 uint16_t on_off = 0;
8532 res = parsed_result;
8533 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8534 set_record_core_cycles(on_off);
8537 cmdline_parse_token_string_t cmd_set_record_core_cycles_keyword =
8538 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8540 cmdline_parse_token_string_t cmd_set_record_core_cycles_name =
8541 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8542 name, "record-core-cycles");
8543 cmdline_parse_token_string_t cmd_set_record_core_cycles_on_off =
8544 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8547 cmdline_parse_inst_t cmd_set_record_core_cycles = {
8548 .f = cmd_set_record_core_cycles_parsed,
8550 .help_str = "set record-core-cycles on|off",
8552 (void *)&cmd_set_record_core_cycles_keyword,
8553 (void *)&cmd_set_record_core_cycles_name,
8554 (void *)&cmd_set_record_core_cycles_on_off,
8559 /* *** SET OPTION TO ENABLE DISPLAY OF RX AND TX BURSTS *** */
8560 struct cmd_set_record_burst_stats_result {
8561 cmdline_fixed_string_t keyword;
8562 cmdline_fixed_string_t name;
8563 cmdline_fixed_string_t on_off;
8567 cmd_set_record_burst_stats_parsed(void *parsed_result,
8568 __rte_unused struct cmdline *cl,
8569 __rte_unused void *data)
8571 struct cmd_set_record_burst_stats_result *res;
8572 uint16_t on_off = 0;
8574 res = parsed_result;
8575 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8576 set_record_burst_stats(on_off);
8579 cmdline_parse_token_string_t cmd_set_record_burst_stats_keyword =
8580 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8582 cmdline_parse_token_string_t cmd_set_record_burst_stats_name =
8583 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8584 name, "record-burst-stats");
8585 cmdline_parse_token_string_t cmd_set_record_burst_stats_on_off =
8586 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8589 cmdline_parse_inst_t cmd_set_record_burst_stats = {
8590 .f = cmd_set_record_burst_stats_parsed,
8592 .help_str = "set record-burst-stats on|off",
8594 (void *)&cmd_set_record_burst_stats_keyword,
8595 (void *)&cmd_set_record_burst_stats_name,
8596 (void *)&cmd_set_record_burst_stats_on_off,
8601 /* *** CONFIGURE UNICAST HASH TABLE *** */
8602 struct cmd_set_uc_hash_table {
8603 cmdline_fixed_string_t set;
8604 cmdline_fixed_string_t port;
8606 cmdline_fixed_string_t what;
8607 struct rte_ether_addr address;
8608 cmdline_fixed_string_t mode;
8612 cmd_set_uc_hash_parsed(void *parsed_result,
8613 __rte_unused struct cmdline *cl,
8614 __rte_unused void *data)
8617 struct cmd_set_uc_hash_table *res = parsed_result;
8619 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8621 if (strcmp(res->what, "uta") == 0)
8622 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
8623 &res->address,(uint8_t)is_on);
8625 printf("bad unicast hash table parameter, return code = %d \n", ret);
8629 cmdline_parse_token_string_t cmd_set_uc_hash_set =
8630 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8632 cmdline_parse_token_string_t cmd_set_uc_hash_port =
8633 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8635 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
8636 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
8637 port_id, RTE_UINT16);
8638 cmdline_parse_token_string_t cmd_set_uc_hash_what =
8639 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8641 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
8642 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
8644 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
8645 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8648 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
8649 .f = cmd_set_uc_hash_parsed,
8651 .help_str = "set port <port_id> uta <mac_addr> on|off)",
8653 (void *)&cmd_set_uc_hash_set,
8654 (void *)&cmd_set_uc_hash_port,
8655 (void *)&cmd_set_uc_hash_portid,
8656 (void *)&cmd_set_uc_hash_what,
8657 (void *)&cmd_set_uc_hash_mac,
8658 (void *)&cmd_set_uc_hash_mode,
8663 struct cmd_set_uc_all_hash_table {
8664 cmdline_fixed_string_t set;
8665 cmdline_fixed_string_t port;
8667 cmdline_fixed_string_t what;
8668 cmdline_fixed_string_t value;
8669 cmdline_fixed_string_t mode;
8673 cmd_set_uc_all_hash_parsed(void *parsed_result,
8674 __rte_unused struct cmdline *cl,
8675 __rte_unused void *data)
8678 struct cmd_set_uc_all_hash_table *res = parsed_result;
8680 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8682 if ((strcmp(res->what, "uta") == 0) &&
8683 (strcmp(res->value, "all") == 0))
8684 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
8686 printf("bad unicast hash table parameter,"
8687 "return code = %d \n", ret);
8690 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
8691 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8693 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
8694 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8696 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
8697 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
8698 port_id, RTE_UINT16);
8699 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
8700 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8702 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
8703 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8705 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
8706 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8709 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
8710 .f = cmd_set_uc_all_hash_parsed,
8712 .help_str = "set port <port_id> uta all on|off",
8714 (void *)&cmd_set_uc_all_hash_set,
8715 (void *)&cmd_set_uc_all_hash_port,
8716 (void *)&cmd_set_uc_all_hash_portid,
8717 (void *)&cmd_set_uc_all_hash_what,
8718 (void *)&cmd_set_uc_all_hash_value,
8719 (void *)&cmd_set_uc_all_hash_mode,
8724 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
8725 struct cmd_set_vf_traffic {
8726 cmdline_fixed_string_t set;
8727 cmdline_fixed_string_t port;
8729 cmdline_fixed_string_t vf;
8731 cmdline_fixed_string_t what;
8732 cmdline_fixed_string_t mode;
8736 cmd_set_vf_traffic_parsed(void *parsed_result,
8737 __rte_unused struct cmdline *cl,
8738 __rte_unused void *data)
8740 struct cmd_set_vf_traffic *res = parsed_result;
8741 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
8742 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8744 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
8747 cmdline_parse_token_string_t cmd_setvf_traffic_set =
8748 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8750 cmdline_parse_token_string_t cmd_setvf_traffic_port =
8751 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8753 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8754 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8755 port_id, RTE_UINT16);
8756 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8757 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8759 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8760 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8762 cmdline_parse_token_string_t cmd_setvf_traffic_what =
8763 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8765 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8766 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8769 cmdline_parse_inst_t cmd_set_vf_traffic = {
8770 .f = cmd_set_vf_traffic_parsed,
8772 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8774 (void *)&cmd_setvf_traffic_set,
8775 (void *)&cmd_setvf_traffic_port,
8776 (void *)&cmd_setvf_traffic_portid,
8777 (void *)&cmd_setvf_traffic_vf,
8778 (void *)&cmd_setvf_traffic_vfid,
8779 (void *)&cmd_setvf_traffic_what,
8780 (void *)&cmd_setvf_traffic_mode,
8785 /* *** CONFIGURE VF RECEIVE MODE *** */
8786 struct cmd_set_vf_rxmode {
8787 cmdline_fixed_string_t set;
8788 cmdline_fixed_string_t port;
8790 cmdline_fixed_string_t vf;
8792 cmdline_fixed_string_t what;
8793 cmdline_fixed_string_t mode;
8794 cmdline_fixed_string_t on;
8798 cmd_set_vf_rxmode_parsed(void *parsed_result,
8799 __rte_unused struct cmdline *cl,
8800 __rte_unused void *data)
8803 uint16_t vf_rxmode = 0;
8804 struct cmd_set_vf_rxmode *res = parsed_result;
8806 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8807 if (!strcmp(res->what,"rxmode")) {
8808 if (!strcmp(res->mode, "AUPE"))
8809 vf_rxmode |= ETH_VMDQ_ACCEPT_UNTAG;
8810 else if (!strcmp(res->mode, "ROPE"))
8811 vf_rxmode |= ETH_VMDQ_ACCEPT_HASH_UC;
8812 else if (!strcmp(res->mode, "BAM"))
8813 vf_rxmode |= ETH_VMDQ_ACCEPT_BROADCAST;
8814 else if (!strncmp(res->mode, "MPE",3))
8815 vf_rxmode |= ETH_VMDQ_ACCEPT_MULTICAST;
8818 RTE_SET_USED(is_on);
8820 #ifdef RTE_NET_IXGBE
8821 if (ret == -ENOTSUP)
8822 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8823 vf_rxmode, (uint8_t)is_on);
8826 if (ret == -ENOTSUP)
8827 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8828 vf_rxmode, (uint8_t)is_on);
8831 printf("bad VF receive mode parameter, return code = %d \n",
8835 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8836 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8838 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8839 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8841 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8842 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8843 port_id, RTE_UINT16);
8844 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8845 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8847 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8848 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8850 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
8851 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8853 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
8854 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8855 mode, "AUPE#ROPE#BAM#MPE");
8856 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
8857 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8860 cmdline_parse_inst_t cmd_set_vf_rxmode = {
8861 .f = cmd_set_vf_rxmode_parsed,
8863 .help_str = "set port <port_id> vf <vf_id> rxmode "
8864 "AUPE|ROPE|BAM|MPE on|off",
8866 (void *)&cmd_set_vf_rxmode_set,
8867 (void *)&cmd_set_vf_rxmode_port,
8868 (void *)&cmd_set_vf_rxmode_portid,
8869 (void *)&cmd_set_vf_rxmode_vf,
8870 (void *)&cmd_set_vf_rxmode_vfid,
8871 (void *)&cmd_set_vf_rxmode_what,
8872 (void *)&cmd_set_vf_rxmode_mode,
8873 (void *)&cmd_set_vf_rxmode_on,
8878 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
8879 struct cmd_vf_mac_addr_result {
8880 cmdline_fixed_string_t mac_addr_cmd;
8881 cmdline_fixed_string_t what;
8882 cmdline_fixed_string_t port;
8884 cmdline_fixed_string_t vf;
8886 struct rte_ether_addr address;
8889 static void cmd_vf_mac_addr_parsed(void *parsed_result,
8890 __rte_unused struct cmdline *cl,
8891 __rte_unused void *data)
8893 struct cmd_vf_mac_addr_result *res = parsed_result;
8896 if (strcmp(res->what, "add") != 0)
8900 if (ret == -ENOTSUP)
8901 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
8905 if (ret == -ENOTSUP)
8906 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
8911 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
8915 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
8916 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8917 mac_addr_cmd,"mac_addr");
8918 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
8919 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8921 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
8922 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8924 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
8925 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8926 port_num, RTE_UINT16);
8927 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
8928 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8930 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
8931 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8933 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
8934 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
8937 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
8938 .f = cmd_vf_mac_addr_parsed,
8940 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
8941 "Add MAC address filtering for a VF on port_id",
8943 (void *)&cmd_vf_mac_addr_cmd,
8944 (void *)&cmd_vf_mac_addr_what,
8945 (void *)&cmd_vf_mac_addr_port,
8946 (void *)&cmd_vf_mac_addr_portnum,
8947 (void *)&cmd_vf_mac_addr_vf,
8948 (void *)&cmd_vf_mac_addr_vfnum,
8949 (void *)&cmd_vf_mac_addr_addr,
8954 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
8955 struct cmd_vf_rx_vlan_filter {
8956 cmdline_fixed_string_t rx_vlan;
8957 cmdline_fixed_string_t what;
8959 cmdline_fixed_string_t port;
8961 cmdline_fixed_string_t vf;
8966 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
8967 __rte_unused struct cmdline *cl,
8968 __rte_unused void *data)
8970 struct cmd_vf_rx_vlan_filter *res = parsed_result;
8973 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
8975 #ifdef RTE_NET_IXGBE
8976 if (ret == -ENOTSUP)
8977 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
8978 res->vlan_id, res->vf_mask, is_add);
8981 if (ret == -ENOTSUP)
8982 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
8983 res->vlan_id, res->vf_mask, is_add);
8986 if (ret == -ENOTSUP)
8987 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
8988 res->vlan_id, res->vf_mask, is_add);
8995 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
8996 res->vlan_id, res->vf_mask);
8999 printf("invalid port_id %d\n", res->port_id);
9002 printf("function not implemented or supported\n");
9005 printf("programming error: (%s)\n", strerror(-ret));
9009 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
9010 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9011 rx_vlan, "rx_vlan");
9012 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
9013 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9015 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
9016 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9017 vlan_id, RTE_UINT16);
9018 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
9019 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9021 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
9022 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9023 port_id, RTE_UINT16);
9024 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
9025 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9027 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
9028 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9029 vf_mask, RTE_UINT64);
9031 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
9032 .f = cmd_vf_rx_vlan_filter_parsed,
9034 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
9035 "(vf_mask = hexadecimal VF mask)",
9037 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
9038 (void *)&cmd_vf_rx_vlan_filter_what,
9039 (void *)&cmd_vf_rx_vlan_filter_vlanid,
9040 (void *)&cmd_vf_rx_vlan_filter_port,
9041 (void *)&cmd_vf_rx_vlan_filter_portid,
9042 (void *)&cmd_vf_rx_vlan_filter_vf,
9043 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
9048 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
9049 struct cmd_queue_rate_limit_result {
9050 cmdline_fixed_string_t set;
9051 cmdline_fixed_string_t port;
9053 cmdline_fixed_string_t queue;
9055 cmdline_fixed_string_t rate;
9059 static void cmd_queue_rate_limit_parsed(void *parsed_result,
9060 __rte_unused struct cmdline *cl,
9061 __rte_unused void *data)
9063 struct cmd_queue_rate_limit_result *res = parsed_result;
9066 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9067 && (strcmp(res->queue, "queue") == 0)
9068 && (strcmp(res->rate, "rate") == 0))
9069 ret = set_queue_rate_limit(res->port_num, res->queue_num,
9072 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
9076 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
9077 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9079 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
9080 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9082 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
9083 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9084 port_num, RTE_UINT16);
9085 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
9086 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9088 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
9089 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9090 queue_num, RTE_UINT8);
9091 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
9092 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9094 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
9095 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9096 rate_num, RTE_UINT16);
9098 cmdline_parse_inst_t cmd_queue_rate_limit = {
9099 .f = cmd_queue_rate_limit_parsed,
9101 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
9102 "Set rate limit for a queue on port_id",
9104 (void *)&cmd_queue_rate_limit_set,
9105 (void *)&cmd_queue_rate_limit_port,
9106 (void *)&cmd_queue_rate_limit_portnum,
9107 (void *)&cmd_queue_rate_limit_queue,
9108 (void *)&cmd_queue_rate_limit_queuenum,
9109 (void *)&cmd_queue_rate_limit_rate,
9110 (void *)&cmd_queue_rate_limit_ratenum,
9115 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
9116 struct cmd_vf_rate_limit_result {
9117 cmdline_fixed_string_t set;
9118 cmdline_fixed_string_t port;
9120 cmdline_fixed_string_t vf;
9122 cmdline_fixed_string_t rate;
9124 cmdline_fixed_string_t q_msk;
9128 static void cmd_vf_rate_limit_parsed(void *parsed_result,
9129 __rte_unused struct cmdline *cl,
9130 __rte_unused void *data)
9132 struct cmd_vf_rate_limit_result *res = parsed_result;
9135 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9136 && (strcmp(res->vf, "vf") == 0)
9137 && (strcmp(res->rate, "rate") == 0)
9138 && (strcmp(res->q_msk, "queue_mask") == 0))
9139 ret = set_vf_rate_limit(res->port_num, res->vf_num,
9140 res->rate_num, res->q_msk_val);
9142 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
9146 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
9147 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9149 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
9150 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9152 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
9153 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9154 port_num, RTE_UINT16);
9155 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
9156 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9158 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
9159 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9161 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
9162 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9164 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
9165 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9166 rate_num, RTE_UINT16);
9167 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
9168 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9169 q_msk, "queue_mask");
9170 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
9171 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9172 q_msk_val, RTE_UINT64);
9174 cmdline_parse_inst_t cmd_vf_rate_limit = {
9175 .f = cmd_vf_rate_limit_parsed,
9177 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
9178 "queue_mask <queue_mask_value>: "
9179 "Set rate limit for queues of VF on port_id",
9181 (void *)&cmd_vf_rate_limit_set,
9182 (void *)&cmd_vf_rate_limit_port,
9183 (void *)&cmd_vf_rate_limit_portnum,
9184 (void *)&cmd_vf_rate_limit_vf,
9185 (void *)&cmd_vf_rate_limit_vfnum,
9186 (void *)&cmd_vf_rate_limit_rate,
9187 (void *)&cmd_vf_rate_limit_ratenum,
9188 (void *)&cmd_vf_rate_limit_q_msk,
9189 (void *)&cmd_vf_rate_limit_q_msk_val,
9194 /* *** CONFIGURE TUNNEL UDP PORT *** */
9195 struct cmd_tunnel_udp_config {
9196 cmdline_fixed_string_t rx_vxlan_port;
9197 cmdline_fixed_string_t what;
9203 cmd_tunnel_udp_config_parsed(void *parsed_result,
9204 __rte_unused struct cmdline *cl,
9205 __rte_unused void *data)
9207 struct cmd_tunnel_udp_config *res = parsed_result;
9208 struct rte_eth_udp_tunnel tunnel_udp;
9211 tunnel_udp.udp_port = res->udp_port;
9212 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9214 if (!strcmp(res->what, "add"))
9215 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9218 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9222 printf("udp tunneling add error: (%s)\n", strerror(-ret));
9225 cmdline_parse_token_string_t cmd_tunnel_udp_config_rx_vxlan_port =
9226 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9227 rx_vxlan_port, "rx_vxlan_port");
9228 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
9229 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9231 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
9232 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9233 udp_port, RTE_UINT16);
9234 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
9235 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9236 port_id, RTE_UINT16);
9238 cmdline_parse_inst_t cmd_tunnel_udp_config = {
9239 .f = cmd_tunnel_udp_config_parsed,
9241 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
9242 "Add/Remove a tunneling UDP port filter",
9244 (void *)&cmd_tunnel_udp_config_rx_vxlan_port,
9245 (void *)&cmd_tunnel_udp_config_what,
9246 (void *)&cmd_tunnel_udp_config_udp_port,
9247 (void *)&cmd_tunnel_udp_config_port_id,
9252 struct cmd_config_tunnel_udp_port {
9253 cmdline_fixed_string_t port;
9254 cmdline_fixed_string_t config;
9256 cmdline_fixed_string_t udp_tunnel_port;
9257 cmdline_fixed_string_t action;
9258 cmdline_fixed_string_t tunnel_type;
9263 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
9264 __rte_unused struct cmdline *cl,
9265 __rte_unused void *data)
9267 struct cmd_config_tunnel_udp_port *res = parsed_result;
9268 struct rte_eth_udp_tunnel tunnel_udp;
9271 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9274 tunnel_udp.udp_port = res->udp_port;
9276 if (!strcmp(res->tunnel_type, "vxlan")) {
9277 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9278 } else if (!strcmp(res->tunnel_type, "geneve")) {
9279 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE;
9280 } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
9281 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9282 } else if (!strcmp(res->tunnel_type, "ecpri")) {
9283 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_ECPRI;
9285 printf("Invalid tunnel type\n");
9289 if (!strcmp(res->action, "add"))
9290 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9293 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9297 printf("udp tunneling port add error: (%s)\n", strerror(-ret));
9300 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
9301 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
9303 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
9304 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
9306 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
9307 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
9309 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
9310 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
9313 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
9314 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
9316 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
9317 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
9318 "vxlan#geneve#vxlan-gpe#ecpri");
9319 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
9320 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
9323 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
9324 .f = cmd_cfg_tunnel_udp_port_parsed,
9326 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|"
9327 "geneve|vxlan-gpe|ecpri <udp_port>",
9329 (void *)&cmd_config_tunnel_udp_port_port,
9330 (void *)&cmd_config_tunnel_udp_port_config,
9331 (void *)&cmd_config_tunnel_udp_port_port_id,
9332 (void *)&cmd_config_tunnel_udp_port_tunnel_port,
9333 (void *)&cmd_config_tunnel_udp_port_action,
9334 (void *)&cmd_config_tunnel_udp_port_tunnel_type,
9335 (void *)&cmd_config_tunnel_udp_port_value,
9340 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
9341 struct cmd_set_mirror_mask_result {
9342 cmdline_fixed_string_t set;
9343 cmdline_fixed_string_t port;
9345 cmdline_fixed_string_t mirror;
9347 cmdline_fixed_string_t what;
9348 cmdline_fixed_string_t value;
9349 cmdline_fixed_string_t dstpool;
9351 cmdline_fixed_string_t on;
9354 cmdline_parse_token_string_t cmd_mirror_mask_set =
9355 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9357 cmdline_parse_token_string_t cmd_mirror_mask_port =
9358 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9360 cmdline_parse_token_num_t cmd_mirror_mask_portid =
9361 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9362 port_id, RTE_UINT16);
9363 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
9364 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9365 mirror, "mirror-rule");
9366 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
9367 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9368 rule_id, RTE_UINT8);
9369 cmdline_parse_token_string_t cmd_mirror_mask_what =
9370 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9371 what, "pool-mirror-up#pool-mirror-down"
9373 cmdline_parse_token_string_t cmd_mirror_mask_value =
9374 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9376 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
9377 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9378 dstpool, "dst-pool");
9379 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
9380 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9381 dstpool_id, RTE_UINT8);
9382 cmdline_parse_token_string_t cmd_mirror_mask_on =
9383 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9387 cmd_set_mirror_mask_parsed(void *parsed_result,
9388 __rte_unused struct cmdline *cl,
9389 __rte_unused void *data)
9392 struct cmd_set_mirror_mask_result *res = parsed_result;
9393 struct rte_eth_mirror_conf mr_conf;
9395 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9397 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
9399 mr_conf.dst_pool = res->dstpool_id;
9401 if (!strcmp(res->what, "pool-mirror-up")) {
9402 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9403 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
9404 } else if (!strcmp(res->what, "pool-mirror-down")) {
9405 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9406 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
9407 } else if (!strcmp(res->what, "vlan-mirror")) {
9408 mr_conf.rule_type = ETH_MIRROR_VLAN;
9409 nb_item = parse_item_list(res->value, "vlan",
9410 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
9414 for (i = 0; i < nb_item; i++) {
9415 if (vlan_list[i] > RTE_ETHER_MAX_VLAN_ID) {
9416 printf("Invalid vlan_id: must be < 4096\n");
9420 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
9421 mr_conf.vlan.vlan_mask |= 1ULL << i;
9425 if (!strcmp(res->on, "on"))
9426 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9429 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9432 printf("mirror rule add error: (%s)\n", strerror(-ret));
9435 cmdline_parse_inst_t cmd_set_mirror_mask = {
9436 .f = cmd_set_mirror_mask_parsed,
9438 .help_str = "set port <port_id> mirror-rule <rule_id> "
9439 "pool-mirror-up|pool-mirror-down|vlan-mirror "
9440 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
9442 (void *)&cmd_mirror_mask_set,
9443 (void *)&cmd_mirror_mask_port,
9444 (void *)&cmd_mirror_mask_portid,
9445 (void *)&cmd_mirror_mask_mirror,
9446 (void *)&cmd_mirror_mask_ruleid,
9447 (void *)&cmd_mirror_mask_what,
9448 (void *)&cmd_mirror_mask_value,
9449 (void *)&cmd_mirror_mask_dstpool,
9450 (void *)&cmd_mirror_mask_poolid,
9451 (void *)&cmd_mirror_mask_on,
9456 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
9457 struct cmd_set_mirror_link_result {
9458 cmdline_fixed_string_t set;
9459 cmdline_fixed_string_t port;
9461 cmdline_fixed_string_t mirror;
9463 cmdline_fixed_string_t what;
9464 cmdline_fixed_string_t dstpool;
9466 cmdline_fixed_string_t on;
9469 cmdline_parse_token_string_t cmd_mirror_link_set =
9470 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9472 cmdline_parse_token_string_t cmd_mirror_link_port =
9473 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9475 cmdline_parse_token_num_t cmd_mirror_link_portid =
9476 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9477 port_id, RTE_UINT16);
9478 cmdline_parse_token_string_t cmd_mirror_link_mirror =
9479 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9480 mirror, "mirror-rule");
9481 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
9482 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9483 rule_id, RTE_UINT8);
9484 cmdline_parse_token_string_t cmd_mirror_link_what =
9485 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9486 what, "uplink-mirror#downlink-mirror");
9487 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
9488 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9489 dstpool, "dst-pool");
9490 cmdline_parse_token_num_t cmd_mirror_link_poolid =
9491 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9492 dstpool_id, RTE_UINT8);
9493 cmdline_parse_token_string_t cmd_mirror_link_on =
9494 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9498 cmd_set_mirror_link_parsed(void *parsed_result,
9499 __rte_unused struct cmdline *cl,
9500 __rte_unused void *data)
9503 struct cmd_set_mirror_link_result *res = parsed_result;
9504 struct rte_eth_mirror_conf mr_conf;
9506 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9507 if (!strcmp(res->what, "uplink-mirror"))
9508 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
9510 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
9512 mr_conf.dst_pool = res->dstpool_id;
9514 if (!strcmp(res->on, "on"))
9515 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9518 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9521 /* check the return value and print it if is < 0 */
9523 printf("mirror rule add error: (%s)\n", strerror(-ret));
9527 cmdline_parse_inst_t cmd_set_mirror_link = {
9528 .f = cmd_set_mirror_link_parsed,
9530 .help_str = "set port <port_id> mirror-rule <rule_id> "
9531 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
9533 (void *)&cmd_mirror_link_set,
9534 (void *)&cmd_mirror_link_port,
9535 (void *)&cmd_mirror_link_portid,
9536 (void *)&cmd_mirror_link_mirror,
9537 (void *)&cmd_mirror_link_ruleid,
9538 (void *)&cmd_mirror_link_what,
9539 (void *)&cmd_mirror_link_dstpool,
9540 (void *)&cmd_mirror_link_poolid,
9541 (void *)&cmd_mirror_link_on,
9546 /* *** RESET VM MIRROR RULE *** */
9547 struct cmd_rm_mirror_rule_result {
9548 cmdline_fixed_string_t reset;
9549 cmdline_fixed_string_t port;
9551 cmdline_fixed_string_t mirror;
9555 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
9556 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9558 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
9559 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9561 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
9562 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9563 port_id, RTE_UINT16);
9564 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
9565 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9566 mirror, "mirror-rule");
9567 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
9568 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9569 rule_id, RTE_UINT8);
9572 cmd_reset_mirror_rule_parsed(void *parsed_result,
9573 __rte_unused struct cmdline *cl,
9574 __rte_unused void *data)
9577 struct cmd_set_mirror_link_result *res = parsed_result;
9579 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
9581 printf("mirror rule remove error: (%s)\n", strerror(-ret));
9584 cmdline_parse_inst_t cmd_reset_mirror_rule = {
9585 .f = cmd_reset_mirror_rule_parsed,
9587 .help_str = "reset port <port_id> mirror-rule <rule_id>",
9589 (void *)&cmd_rm_mirror_rule_reset,
9590 (void *)&cmd_rm_mirror_rule_port,
9591 (void *)&cmd_rm_mirror_rule_portid,
9592 (void *)&cmd_rm_mirror_rule_mirror,
9593 (void *)&cmd_rm_mirror_rule_ruleid,
9598 /* ******************************************************************************** */
9600 struct cmd_dump_result {
9601 cmdline_fixed_string_t dump;
9605 dump_struct_sizes(void)
9607 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9608 DUMP_SIZE(struct rte_mbuf);
9609 DUMP_SIZE(struct rte_mempool);
9610 DUMP_SIZE(struct rte_ring);
9615 /* Dump the socket memory statistics on console */
9617 dump_socket_mem(FILE *f)
9619 struct rte_malloc_socket_stats socket_stats;
9624 unsigned int n_alloc = 0;
9625 unsigned int n_free = 0;
9626 static size_t last_allocs;
9627 static size_t last_total;
9630 for (i = 0; i < RTE_MAX_NUMA_NODES; i++) {
9631 if (rte_malloc_get_socket_stats(i, &socket_stats) ||
9632 !socket_stats.heap_totalsz_bytes)
9634 total += socket_stats.heap_totalsz_bytes;
9635 alloc += socket_stats.heap_allocsz_bytes;
9636 free += socket_stats.heap_freesz_bytes;
9637 n_alloc += socket_stats.alloc_count;
9638 n_free += socket_stats.free_count;
9640 "Socket %u: size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9642 (double)socket_stats.heap_totalsz_bytes / (1024 * 1024),
9643 (double)socket_stats.heap_allocsz_bytes / (1024 * 1024),
9644 (double)socket_stats.heap_allocsz_bytes * 100 /
9645 (double)socket_stats.heap_totalsz_bytes,
9646 (double)socket_stats.heap_freesz_bytes / (1024 * 1024),
9647 socket_stats.alloc_count,
9648 socket_stats.free_count);
9651 "Total : size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9652 (double)total / (1024 * 1024), (double)alloc / (1024 * 1024),
9653 (double)alloc * 100 / (double)total,
9654 (double)free / (1024 * 1024),
9657 fprintf(stdout, "Memory total change: %.6lf(M), allocation change: %.6lf(M)\n",
9658 ((double)total - (double)last_total) / (1024 * 1024),
9659 (double)(alloc - (double)last_allocs) / 1024 / 1024);
9660 last_allocs = alloc;
9664 static void cmd_dump_parsed(void *parsed_result,
9665 __rte_unused struct cmdline *cl,
9666 __rte_unused void *data)
9668 struct cmd_dump_result *res = parsed_result;
9670 if (!strcmp(res->dump, "dump_physmem"))
9671 rte_dump_physmem_layout(stdout);
9672 else if (!strcmp(res->dump, "dump_socket_mem"))
9673 dump_socket_mem(stdout);
9674 else if (!strcmp(res->dump, "dump_memzone"))
9675 rte_memzone_dump(stdout);
9676 else if (!strcmp(res->dump, "dump_struct_sizes"))
9677 dump_struct_sizes();
9678 else if (!strcmp(res->dump, "dump_ring"))
9679 rte_ring_list_dump(stdout);
9680 else if (!strcmp(res->dump, "dump_mempool"))
9681 rte_mempool_list_dump(stdout);
9682 else if (!strcmp(res->dump, "dump_devargs"))
9683 rte_devargs_dump(stdout);
9684 else if (!strcmp(res->dump, "dump_log_types"))
9685 rte_log_dump(stdout);
9688 cmdline_parse_token_string_t cmd_dump_dump =
9689 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9693 "dump_struct_sizes#"
9699 cmdline_parse_inst_t cmd_dump = {
9700 .f = cmd_dump_parsed, /* function to call */
9701 .data = NULL, /* 2nd arg of func */
9702 .help_str = "Dump status",
9703 .tokens = { /* token list, NULL terminated */
9704 (void *)&cmd_dump_dump,
9709 /* ******************************************************************************** */
9711 struct cmd_dump_one_result {
9712 cmdline_fixed_string_t dump;
9713 cmdline_fixed_string_t name;
9716 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9717 __rte_unused void *data)
9719 struct cmd_dump_one_result *res = parsed_result;
9721 if (!strcmp(res->dump, "dump_ring")) {
9723 r = rte_ring_lookup(res->name);
9725 cmdline_printf(cl, "Cannot find ring\n");
9728 rte_ring_dump(stdout, r);
9729 } else if (!strcmp(res->dump, "dump_mempool")) {
9730 struct rte_mempool *mp;
9731 mp = rte_mempool_lookup(res->name);
9733 cmdline_printf(cl, "Cannot find mempool\n");
9736 rte_mempool_dump(stdout, mp);
9740 cmdline_parse_token_string_t cmd_dump_one_dump =
9741 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9742 "dump_ring#dump_mempool");
9744 cmdline_parse_token_string_t cmd_dump_one_name =
9745 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9747 cmdline_parse_inst_t cmd_dump_one = {
9748 .f = cmd_dump_one_parsed, /* function to call */
9749 .data = NULL, /* 2nd arg of func */
9750 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9751 .tokens = { /* token list, NULL terminated */
9752 (void *)&cmd_dump_one_dump,
9753 (void *)&cmd_dump_one_name,
9758 /* *** queue region set *** */
9759 struct cmd_queue_region_result {
9760 cmdline_fixed_string_t set;
9761 cmdline_fixed_string_t port;
9763 cmdline_fixed_string_t cmd;
9764 cmdline_fixed_string_t region;
9766 cmdline_fixed_string_t queue_start_index;
9768 cmdline_fixed_string_t queue_num;
9769 uint8_t queue_num_value;
9773 cmd_queue_region_parsed(void *parsed_result,
9774 __rte_unused struct cmdline *cl,
9775 __rte_unused void *data)
9777 struct cmd_queue_region_result *res = parsed_result;
9780 struct rte_pmd_i40e_queue_region_conf region_conf;
9781 enum rte_pmd_i40e_queue_region_op op_type;
9784 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9788 memset(®ion_conf, 0, sizeof(region_conf));
9789 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
9790 region_conf.region_id = res->region_id;
9791 region_conf.queue_num = res->queue_num_value;
9792 region_conf.queue_start_index = res->queue_id;
9794 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9795 op_type, ®ion_conf);
9802 printf("function not implemented or supported\n");
9805 printf("queue region config error: (%s)\n", strerror(-ret));
9809 cmdline_parse_token_string_t cmd_queue_region_set =
9810 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9812 cmdline_parse_token_string_t cmd_queue_region_port =
9813 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
9814 cmdline_parse_token_num_t cmd_queue_region_port_id =
9815 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9816 port_id, RTE_UINT16);
9817 cmdline_parse_token_string_t cmd_queue_region_cmd =
9818 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9819 cmd, "queue-region");
9820 cmdline_parse_token_string_t cmd_queue_region_id =
9821 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9822 region, "region_id");
9823 cmdline_parse_token_num_t cmd_queue_region_index =
9824 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9825 region_id, RTE_UINT8);
9826 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
9827 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9828 queue_start_index, "queue_start_index");
9829 cmdline_parse_token_num_t cmd_queue_region_queue_id =
9830 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9831 queue_id, RTE_UINT8);
9832 cmdline_parse_token_string_t cmd_queue_region_queue_num =
9833 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9834 queue_num, "queue_num");
9835 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
9836 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9837 queue_num_value, RTE_UINT8);
9839 cmdline_parse_inst_t cmd_queue_region = {
9840 .f = cmd_queue_region_parsed,
9842 .help_str = "set port <port_id> queue-region region_id <value> "
9843 "queue_start_index <value> queue_num <value>: Set a queue region",
9845 (void *)&cmd_queue_region_set,
9846 (void *)&cmd_queue_region_port,
9847 (void *)&cmd_queue_region_port_id,
9848 (void *)&cmd_queue_region_cmd,
9849 (void *)&cmd_queue_region_id,
9850 (void *)&cmd_queue_region_index,
9851 (void *)&cmd_queue_region_queue_start_index,
9852 (void *)&cmd_queue_region_queue_id,
9853 (void *)&cmd_queue_region_queue_num,
9854 (void *)&cmd_queue_region_queue_num_value,
9859 /* *** queue region and flowtype set *** */
9860 struct cmd_region_flowtype_result {
9861 cmdline_fixed_string_t set;
9862 cmdline_fixed_string_t port;
9864 cmdline_fixed_string_t cmd;
9865 cmdline_fixed_string_t region;
9867 cmdline_fixed_string_t flowtype;
9868 uint8_t flowtype_id;
9872 cmd_region_flowtype_parsed(void *parsed_result,
9873 __rte_unused struct cmdline *cl,
9874 __rte_unused void *data)
9876 struct cmd_region_flowtype_result *res = parsed_result;
9879 struct rte_pmd_i40e_queue_region_conf region_conf;
9880 enum rte_pmd_i40e_queue_region_op op_type;
9883 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9887 memset(®ion_conf, 0, sizeof(region_conf));
9889 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
9890 region_conf.region_id = res->region_id;
9891 region_conf.hw_flowtype = res->flowtype_id;
9893 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9894 op_type, ®ion_conf);
9901 printf("function not implemented or supported\n");
9904 printf("region flowtype config error: (%s)\n", strerror(-ret));
9908 cmdline_parse_token_string_t cmd_region_flowtype_set =
9909 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9911 cmdline_parse_token_string_t cmd_region_flowtype_port =
9912 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9914 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
9915 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9916 port_id, RTE_UINT16);
9917 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
9918 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9919 cmd, "queue-region");
9920 cmdline_parse_token_string_t cmd_region_flowtype_index =
9921 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9922 region, "region_id");
9923 cmdline_parse_token_num_t cmd_region_flowtype_id =
9924 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9925 region_id, RTE_UINT8);
9926 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
9927 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9928 flowtype, "flowtype");
9929 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
9930 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9931 flowtype_id, RTE_UINT8);
9932 cmdline_parse_inst_t cmd_region_flowtype = {
9933 .f = cmd_region_flowtype_parsed,
9935 .help_str = "set port <port_id> queue-region region_id <value> "
9936 "flowtype <value>: Set a flowtype region index",
9938 (void *)&cmd_region_flowtype_set,
9939 (void *)&cmd_region_flowtype_port,
9940 (void *)&cmd_region_flowtype_port_index,
9941 (void *)&cmd_region_flowtype_cmd,
9942 (void *)&cmd_region_flowtype_index,
9943 (void *)&cmd_region_flowtype_id,
9944 (void *)&cmd_region_flowtype_flow_index,
9945 (void *)&cmd_region_flowtype_flow_id,
9950 /* *** User Priority (UP) to queue region (region_id) set *** */
9951 struct cmd_user_priority_region_result {
9952 cmdline_fixed_string_t set;
9953 cmdline_fixed_string_t port;
9955 cmdline_fixed_string_t cmd;
9956 cmdline_fixed_string_t user_priority;
9957 uint8_t user_priority_id;
9958 cmdline_fixed_string_t region;
9963 cmd_user_priority_region_parsed(void *parsed_result,
9964 __rte_unused struct cmdline *cl,
9965 __rte_unused void *data)
9967 struct cmd_user_priority_region_result *res = parsed_result;
9970 struct rte_pmd_i40e_queue_region_conf region_conf;
9971 enum rte_pmd_i40e_queue_region_op op_type;
9974 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9978 memset(®ion_conf, 0, sizeof(region_conf));
9979 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
9980 region_conf.user_priority = res->user_priority_id;
9981 region_conf.region_id = res->region_id;
9983 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9984 op_type, ®ion_conf);
9991 printf("function not implemented or supported\n");
9994 printf("user_priority region config error: (%s)\n",
9999 cmdline_parse_token_string_t cmd_user_priority_region_set =
10000 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10002 cmdline_parse_token_string_t cmd_user_priority_region_port =
10003 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10005 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
10006 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10007 port_id, RTE_UINT16);
10008 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
10009 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10010 cmd, "queue-region");
10011 cmdline_parse_token_string_t cmd_user_priority_region_UP =
10012 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10013 user_priority, "UP");
10014 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
10015 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10016 user_priority_id, RTE_UINT8);
10017 cmdline_parse_token_string_t cmd_user_priority_region_region =
10018 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10019 region, "region_id");
10020 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
10021 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10022 region_id, RTE_UINT8);
10024 cmdline_parse_inst_t cmd_user_priority_region = {
10025 .f = cmd_user_priority_region_parsed,
10027 .help_str = "set port <port_id> queue-region UP <value> "
10028 "region_id <value>: Set the mapping of User Priority (UP) "
10029 "to queue region (region_id) ",
10031 (void *)&cmd_user_priority_region_set,
10032 (void *)&cmd_user_priority_region_port,
10033 (void *)&cmd_user_priority_region_port_index,
10034 (void *)&cmd_user_priority_region_cmd,
10035 (void *)&cmd_user_priority_region_UP,
10036 (void *)&cmd_user_priority_region_UP_id,
10037 (void *)&cmd_user_priority_region_region,
10038 (void *)&cmd_user_priority_region_region_id,
10043 /* *** flush all queue region related configuration *** */
10044 struct cmd_flush_queue_region_result {
10045 cmdline_fixed_string_t set;
10046 cmdline_fixed_string_t port;
10048 cmdline_fixed_string_t cmd;
10049 cmdline_fixed_string_t flush;
10050 cmdline_fixed_string_t what;
10054 cmd_flush_queue_region_parsed(void *parsed_result,
10055 __rte_unused struct cmdline *cl,
10056 __rte_unused void *data)
10058 struct cmd_flush_queue_region_result *res = parsed_result;
10059 int ret = -ENOTSUP;
10060 #ifdef RTE_NET_I40E
10061 struct rte_pmd_i40e_queue_region_conf region_conf;
10062 enum rte_pmd_i40e_queue_region_op op_type;
10065 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10068 #ifdef RTE_NET_I40E
10069 memset(®ion_conf, 0, sizeof(region_conf));
10071 if (strcmp(res->what, "on") == 0)
10072 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
10074 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
10076 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10077 op_type, ®ion_conf);
10084 printf("function not implemented or supported\n");
10087 printf("queue region config flush error: (%s)\n",
10092 cmdline_parse_token_string_t cmd_flush_queue_region_set =
10093 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10095 cmdline_parse_token_string_t cmd_flush_queue_region_port =
10096 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10098 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
10099 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
10100 port_id, RTE_UINT16);
10101 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
10102 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10103 cmd, "queue-region");
10104 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
10105 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10107 cmdline_parse_token_string_t cmd_flush_queue_region_what =
10108 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10111 cmdline_parse_inst_t cmd_flush_queue_region = {
10112 .f = cmd_flush_queue_region_parsed,
10114 .help_str = "set port <port_id> queue-region flush on|off"
10115 ": flush all queue region related configuration",
10117 (void *)&cmd_flush_queue_region_set,
10118 (void *)&cmd_flush_queue_region_port,
10119 (void *)&cmd_flush_queue_region_port_index,
10120 (void *)&cmd_flush_queue_region_cmd,
10121 (void *)&cmd_flush_queue_region_flush,
10122 (void *)&cmd_flush_queue_region_what,
10127 /* *** get all queue region related configuration info *** */
10128 struct cmd_show_queue_region_info {
10129 cmdline_fixed_string_t show;
10130 cmdline_fixed_string_t port;
10132 cmdline_fixed_string_t cmd;
10136 cmd_show_queue_region_info_parsed(void *parsed_result,
10137 __rte_unused struct cmdline *cl,
10138 __rte_unused void *data)
10140 struct cmd_show_queue_region_info *res = parsed_result;
10141 int ret = -ENOTSUP;
10142 #ifdef RTE_NET_I40E
10143 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
10144 enum rte_pmd_i40e_queue_region_op op_type;
10147 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10150 #ifdef RTE_NET_I40E
10151 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
10153 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
10155 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10156 op_type, &rte_pmd_regions);
10158 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
10165 printf("function not implemented or supported\n");
10168 printf("queue region config info show error: (%s)\n",
10173 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
10174 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10176 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
10177 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10179 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
10180 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
10181 port_id, RTE_UINT16);
10182 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
10183 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10184 cmd, "queue-region");
10186 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
10187 .f = cmd_show_queue_region_info_parsed,
10189 .help_str = "show port <port_id> queue-region"
10190 ": show all queue region related configuration info",
10192 (void *)&cmd_show_queue_region_info_get,
10193 (void *)&cmd_show_queue_region_info_port,
10194 (void *)&cmd_show_queue_region_info_port_index,
10195 (void *)&cmd_show_queue_region_info_cmd,
10200 /* *** Filters Control *** */
10202 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10204 if ((ip_addr).family == AF_INET) \
10205 (ip) = (ip_addr).addr.ipv4.s_addr; \
10207 printf("invalid parameter.\n"); \
10212 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10214 if ((ip_addr).family == AF_INET6) \
10215 rte_memcpy(&(ip), \
10216 &((ip_addr).addr.ipv6), \
10217 sizeof(struct in6_addr)); \
10219 printf("invalid parameter.\n"); \
10224 #ifdef RTE_NET_I40E
10227 str2flowtype(char *string)
10230 static const struct {
10233 } flowtype_str[] = {
10234 {"raw", RTE_ETH_FLOW_RAW},
10235 {"ipv4", RTE_ETH_FLOW_IPV4},
10236 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10237 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10238 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10239 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10240 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10241 {"ipv6", RTE_ETH_FLOW_IPV6},
10242 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10243 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10244 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10245 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10246 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10247 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10250 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
10251 if (!strcmp(flowtype_str[i].str, string))
10252 return flowtype_str[i].type;
10255 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
10256 return (uint16_t)atoi(string);
10258 return RTE_ETH_FLOW_UNKNOWN;
10261 /* *** deal with flow director filter *** */
10262 struct cmd_flow_director_result {
10263 cmdline_fixed_string_t flow_director_filter;
10265 cmdline_fixed_string_t mode;
10266 cmdline_fixed_string_t mode_value;
10267 cmdline_fixed_string_t ops;
10268 cmdline_fixed_string_t flow;
10269 cmdline_fixed_string_t flow_type;
10270 cmdline_fixed_string_t drop;
10271 cmdline_fixed_string_t queue;
10273 cmdline_fixed_string_t fd_id;
10274 uint32_t fd_id_value;
10275 cmdline_fixed_string_t packet;
10280 cmd_flow_director_filter_parsed(void *parsed_result,
10281 __rte_unused struct cmdline *cl,
10282 __rte_unused void *data)
10284 struct cmd_flow_director_result *res = parsed_result;
10286 struct rte_pmd_i40e_flow_type_mapping
10287 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
10288 struct rte_pmd_i40e_pkt_template_conf conf;
10289 uint16_t flow_type = str2flowtype(res->flow_type);
10290 uint16_t i, port = res->port_id;
10293 memset(&conf, 0, sizeof(conf));
10295 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
10296 printf("Invalid flow type specified.\n");
10299 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
10303 if (mapping[flow_type].pctype == 0ULL) {
10304 printf("Invalid flow type specified.\n");
10307 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
10308 if (mapping[flow_type].pctype & (1ULL << i)) {
10309 conf.input.pctype = i;
10314 conf.input.packet = open_file(res->filepath,
10315 &conf.input.length);
10316 if (!conf.input.packet)
10318 if (!strcmp(res->drop, "drop"))
10319 conf.action.behavior =
10320 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
10322 conf.action.behavior =
10323 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
10324 conf.action.report_status =
10325 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
10326 conf.action.rx_queue = res->queue_id;
10327 conf.soft_id = res->fd_id_value;
10328 add = strcmp(res->ops, "del") ? 1 : 0;
10329 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
10333 printf("flow director config error: (%s)\n",
10335 close_file(conf.input.packet);
10338 cmdline_parse_token_string_t cmd_flow_director_filter =
10339 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10340 flow_director_filter, "flow_director_filter");
10341 cmdline_parse_token_num_t cmd_flow_director_port_id =
10342 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10343 port_id, RTE_UINT16);
10344 cmdline_parse_token_string_t cmd_flow_director_ops =
10345 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10346 ops, "add#del#update");
10347 cmdline_parse_token_string_t cmd_flow_director_flow =
10348 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10350 cmdline_parse_token_string_t cmd_flow_director_flow_type =
10351 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10353 cmdline_parse_token_string_t cmd_flow_director_drop =
10354 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10356 cmdline_parse_token_string_t cmd_flow_director_queue =
10357 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10359 cmdline_parse_token_num_t cmd_flow_director_queue_id =
10360 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10361 queue_id, RTE_UINT16);
10362 cmdline_parse_token_string_t cmd_flow_director_fd_id =
10363 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10365 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
10366 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10367 fd_id_value, RTE_UINT32);
10369 cmdline_parse_token_string_t cmd_flow_director_mode =
10370 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10372 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
10373 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10374 mode_value, "raw");
10375 cmdline_parse_token_string_t cmd_flow_director_packet =
10376 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10378 cmdline_parse_token_string_t cmd_flow_director_filepath =
10379 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10382 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
10383 .f = cmd_flow_director_filter_parsed,
10385 .help_str = "flow_director_filter ... : Add or delete a raw flow "
10386 "director entry on NIC",
10388 (void *)&cmd_flow_director_filter,
10389 (void *)&cmd_flow_director_port_id,
10390 (void *)&cmd_flow_director_mode,
10391 (void *)&cmd_flow_director_mode_raw,
10392 (void *)&cmd_flow_director_ops,
10393 (void *)&cmd_flow_director_flow,
10394 (void *)&cmd_flow_director_flow_type,
10395 (void *)&cmd_flow_director_drop,
10396 (void *)&cmd_flow_director_queue,
10397 (void *)&cmd_flow_director_queue_id,
10398 (void *)&cmd_flow_director_fd_id,
10399 (void *)&cmd_flow_director_fd_id_value,
10400 (void *)&cmd_flow_director_packet,
10401 (void *)&cmd_flow_director_filepath,
10406 #endif /* RTE_NET_I40E */
10408 /* *** deal with flow director mask *** */
10409 struct cmd_flow_director_mask_result {
10410 cmdline_fixed_string_t flow_director_mask;
10412 cmdline_fixed_string_t mode;
10413 cmdline_fixed_string_t mode_value;
10414 cmdline_fixed_string_t vlan;
10415 uint16_t vlan_mask;
10416 cmdline_fixed_string_t src_mask;
10417 cmdline_ipaddr_t ipv4_src;
10418 cmdline_ipaddr_t ipv6_src;
10420 cmdline_fixed_string_t dst_mask;
10421 cmdline_ipaddr_t ipv4_dst;
10422 cmdline_ipaddr_t ipv6_dst;
10424 cmdline_fixed_string_t mac;
10425 uint8_t mac_addr_byte_mask;
10426 cmdline_fixed_string_t tunnel_id;
10427 uint32_t tunnel_id_mask;
10428 cmdline_fixed_string_t tunnel_type;
10429 uint8_t tunnel_type_mask;
10433 cmd_flow_director_mask_parsed(void *parsed_result,
10434 __rte_unused struct cmdline *cl,
10435 __rte_unused void *data)
10437 struct cmd_flow_director_mask_result *res = parsed_result;
10438 struct rte_eth_fdir_masks *mask;
10439 struct rte_port *port;
10441 port = &ports[res->port_id];
10442 /** Check if the port is not started **/
10443 if (port->port_status != RTE_PORT_STOPPED) {
10444 printf("Please stop port %d first\n", res->port_id);
10448 mask = &port->dev_conf.fdir_conf.mask;
10450 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10451 if (strcmp(res->mode_value, "MAC-VLAN")) {
10452 printf("Please set mode to MAC-VLAN.\n");
10456 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10457 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10458 if (strcmp(res->mode_value, "Tunnel")) {
10459 printf("Please set mode to Tunnel.\n");
10463 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10464 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
10465 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
10466 mask->tunnel_type_mask = res->tunnel_type_mask;
10468 if (strcmp(res->mode_value, "IP")) {
10469 printf("Please set mode to IP.\n");
10473 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10474 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
10475 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
10476 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
10477 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
10478 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
10479 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
10482 cmd_reconfig_device_queue(res->port_id, 1, 1);
10485 cmdline_parse_token_string_t cmd_flow_director_mask =
10486 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10487 flow_director_mask, "flow_director_mask");
10488 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
10489 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10490 port_id, RTE_UINT16);
10491 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
10492 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10494 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
10495 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10496 vlan_mask, RTE_UINT16);
10497 cmdline_parse_token_string_t cmd_flow_director_mask_src =
10498 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10499 src_mask, "src_mask");
10500 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
10501 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10503 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
10504 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10506 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
10507 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10508 port_src, RTE_UINT16);
10509 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
10510 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10511 dst_mask, "dst_mask");
10512 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
10513 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10515 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
10516 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10518 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
10519 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10520 port_dst, RTE_UINT16);
10522 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
10523 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10525 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
10526 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10528 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
10529 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10530 mode_value, "MAC-VLAN");
10531 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
10532 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10533 mode_value, "Tunnel");
10534 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
10535 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10537 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
10538 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10539 mac_addr_byte_mask, RTE_UINT8);
10540 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
10541 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10542 tunnel_type, "tunnel-type");
10543 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
10544 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10545 tunnel_type_mask, RTE_UINT8);
10546 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
10547 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10548 tunnel_id, "tunnel-id");
10549 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
10550 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10551 tunnel_id_mask, RTE_UINT32);
10553 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
10554 .f = cmd_flow_director_mask_parsed,
10556 .help_str = "flow_director_mask ... : "
10557 "Set IP mode flow director's mask on NIC",
10559 (void *)&cmd_flow_director_mask,
10560 (void *)&cmd_flow_director_mask_port_id,
10561 (void *)&cmd_flow_director_mask_mode,
10562 (void *)&cmd_flow_director_mask_mode_ip,
10563 (void *)&cmd_flow_director_mask_vlan,
10564 (void *)&cmd_flow_director_mask_vlan_value,
10565 (void *)&cmd_flow_director_mask_src,
10566 (void *)&cmd_flow_director_mask_ipv4_src,
10567 (void *)&cmd_flow_director_mask_ipv6_src,
10568 (void *)&cmd_flow_director_mask_port_src,
10569 (void *)&cmd_flow_director_mask_dst,
10570 (void *)&cmd_flow_director_mask_ipv4_dst,
10571 (void *)&cmd_flow_director_mask_ipv6_dst,
10572 (void *)&cmd_flow_director_mask_port_dst,
10577 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
10578 .f = cmd_flow_director_mask_parsed,
10580 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
10581 "flow director's mask on NIC",
10583 (void *)&cmd_flow_director_mask,
10584 (void *)&cmd_flow_director_mask_port_id,
10585 (void *)&cmd_flow_director_mask_mode,
10586 (void *)&cmd_flow_director_mask_mode_mac_vlan,
10587 (void *)&cmd_flow_director_mask_vlan,
10588 (void *)&cmd_flow_director_mask_vlan_value,
10593 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
10594 .f = cmd_flow_director_mask_parsed,
10596 .help_str = "flow_director_mask ... : Set tunnel mode "
10597 "flow director's mask on NIC",
10599 (void *)&cmd_flow_director_mask,
10600 (void *)&cmd_flow_director_mask_port_id,
10601 (void *)&cmd_flow_director_mask_mode,
10602 (void *)&cmd_flow_director_mask_mode_tunnel,
10603 (void *)&cmd_flow_director_mask_vlan,
10604 (void *)&cmd_flow_director_mask_vlan_value,
10605 (void *)&cmd_flow_director_mask_mac,
10606 (void *)&cmd_flow_director_mask_mac_value,
10607 (void *)&cmd_flow_director_mask_tunnel_type,
10608 (void *)&cmd_flow_director_mask_tunnel_type_value,
10609 (void *)&cmd_flow_director_mask_tunnel_id,
10610 (void *)&cmd_flow_director_mask_tunnel_id_value,
10615 /* *** deal with flow director flexible payload configuration *** */
10616 struct cmd_flow_director_flexpayload_result {
10617 cmdline_fixed_string_t flow_director_flexpayload;
10619 cmdline_fixed_string_t payload_layer;
10620 cmdline_fixed_string_t payload_cfg;
10624 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
10627 const char *p, *p0 = q_arg;
10629 unsigned long int_fld;
10630 char *str_fld[max_num];
10635 p = strchr(p0, '(');
10639 p0 = strchr(p, ')');
10644 if (size >= sizeof(s))
10647 snprintf(s, sizeof(s), "%.*s", size, p);
10648 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10649 if (ret < 0 || ret > max_num)
10651 for (i = 0; i < ret; i++) {
10653 int_fld = strtoul(str_fld[i], &end, 0);
10654 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
10656 offsets[i] = (uint16_t)int_fld;
10662 cmd_flow_director_flxpld_parsed(void *parsed_result,
10663 __rte_unused struct cmdline *cl,
10664 __rte_unused void *data)
10666 struct cmd_flow_director_flexpayload_result *res = parsed_result;
10667 struct rte_eth_flex_payload_cfg flex_cfg;
10668 struct rte_port *port;
10671 port = &ports[res->port_id];
10672 /** Check if the port is not started **/
10673 if (port->port_status != RTE_PORT_STOPPED) {
10674 printf("Please stop port %d first\n", res->port_id);
10678 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
10680 if (!strcmp(res->payload_layer, "raw"))
10681 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
10682 else if (!strcmp(res->payload_layer, "l2"))
10683 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
10684 else if (!strcmp(res->payload_layer, "l3"))
10685 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
10686 else if (!strcmp(res->payload_layer, "l4"))
10687 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
10689 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
10690 RTE_ETH_FDIR_MAX_FLEXLEN);
10692 printf("error: Cannot parse flex payload input.\n");
10696 fdir_set_flex_payload(res->port_id, &flex_cfg);
10697 cmd_reconfig_device_queue(res->port_id, 1, 1);
10700 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
10701 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10702 flow_director_flexpayload,
10703 "flow_director_flex_payload");
10704 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
10705 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10706 port_id, RTE_UINT16);
10707 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
10708 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10709 payload_layer, "raw#l2#l3#l4");
10710 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
10711 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10712 payload_cfg, NULL);
10714 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
10715 .f = cmd_flow_director_flxpld_parsed,
10717 .help_str = "flow_director_flexpayload ... : "
10718 "Set flow director's flex payload on NIC",
10720 (void *)&cmd_flow_director_flexpayload,
10721 (void *)&cmd_flow_director_flexpayload_port_id,
10722 (void *)&cmd_flow_director_flexpayload_payload_layer,
10723 (void *)&cmd_flow_director_flexpayload_payload_cfg,
10728 /* Generic flow interface command. */
10729 extern cmdline_parse_inst_t cmd_flow;
10731 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
10732 struct cmd_mcast_addr_result {
10733 cmdline_fixed_string_t mcast_addr_cmd;
10734 cmdline_fixed_string_t what;
10736 struct rte_ether_addr mc_addr;
10739 static void cmd_mcast_addr_parsed(void *parsed_result,
10740 __rte_unused struct cmdline *cl,
10741 __rte_unused void *data)
10743 struct cmd_mcast_addr_result *res = parsed_result;
10745 if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
10746 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
10747 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
10748 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
10749 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
10752 if (strcmp(res->what, "add") == 0)
10753 mcast_addr_add(res->port_num, &res->mc_addr);
10755 mcast_addr_remove(res->port_num, &res->mc_addr);
10758 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
10759 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
10760 mcast_addr_cmd, "mcast_addr");
10761 cmdline_parse_token_string_t cmd_mcast_addr_what =
10762 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
10764 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
10765 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num,
10767 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
10768 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
10770 cmdline_parse_inst_t cmd_mcast_addr = {
10771 .f = cmd_mcast_addr_parsed,
10773 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
10774 "Add/Remove multicast MAC address on port_id",
10776 (void *)&cmd_mcast_addr_cmd,
10777 (void *)&cmd_mcast_addr_what,
10778 (void *)&cmd_mcast_addr_portnum,
10779 (void *)&cmd_mcast_addr_addr,
10784 /* vf vlan anti spoof configuration */
10786 /* Common result structure for vf vlan anti spoof */
10787 struct cmd_vf_vlan_anti_spoof_result {
10788 cmdline_fixed_string_t set;
10789 cmdline_fixed_string_t vf;
10790 cmdline_fixed_string_t vlan;
10791 cmdline_fixed_string_t antispoof;
10794 cmdline_fixed_string_t on_off;
10797 /* Common CLI fields for vf vlan anti spoof enable disable */
10798 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
10799 TOKEN_STRING_INITIALIZER
10800 (struct cmd_vf_vlan_anti_spoof_result,
10802 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
10803 TOKEN_STRING_INITIALIZER
10804 (struct cmd_vf_vlan_anti_spoof_result,
10806 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
10807 TOKEN_STRING_INITIALIZER
10808 (struct cmd_vf_vlan_anti_spoof_result,
10810 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
10811 TOKEN_STRING_INITIALIZER
10812 (struct cmd_vf_vlan_anti_spoof_result,
10813 antispoof, "antispoof");
10814 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
10815 TOKEN_NUM_INITIALIZER
10816 (struct cmd_vf_vlan_anti_spoof_result,
10817 port_id, RTE_UINT16);
10818 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
10819 TOKEN_NUM_INITIALIZER
10820 (struct cmd_vf_vlan_anti_spoof_result,
10821 vf_id, RTE_UINT32);
10822 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
10823 TOKEN_STRING_INITIALIZER
10824 (struct cmd_vf_vlan_anti_spoof_result,
10828 cmd_set_vf_vlan_anti_spoof_parsed(
10829 void *parsed_result,
10830 __rte_unused struct cmdline *cl,
10831 __rte_unused void *data)
10833 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
10834 int ret = -ENOTSUP;
10836 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
10838 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10841 #ifdef RTE_NET_IXGBE
10842 if (ret == -ENOTSUP)
10843 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
10844 res->vf_id, is_on);
10846 #ifdef RTE_NET_I40E
10847 if (ret == -ENOTSUP)
10848 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
10849 res->vf_id, is_on);
10851 #ifdef RTE_NET_BNXT
10852 if (ret == -ENOTSUP)
10853 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
10854 res->vf_id, is_on);
10861 printf("invalid vf_id %d\n", res->vf_id);
10864 printf("invalid port_id %d\n", res->port_id);
10867 printf("function not implemented\n");
10870 printf("programming error: (%s)\n", strerror(-ret));
10874 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
10875 .f = cmd_set_vf_vlan_anti_spoof_parsed,
10877 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
10879 (void *)&cmd_vf_vlan_anti_spoof_set,
10880 (void *)&cmd_vf_vlan_anti_spoof_vf,
10881 (void *)&cmd_vf_vlan_anti_spoof_vlan,
10882 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
10883 (void *)&cmd_vf_vlan_anti_spoof_port_id,
10884 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
10885 (void *)&cmd_vf_vlan_anti_spoof_on_off,
10890 /* vf mac anti spoof configuration */
10892 /* Common result structure for vf mac anti spoof */
10893 struct cmd_vf_mac_anti_spoof_result {
10894 cmdline_fixed_string_t set;
10895 cmdline_fixed_string_t vf;
10896 cmdline_fixed_string_t mac;
10897 cmdline_fixed_string_t antispoof;
10900 cmdline_fixed_string_t on_off;
10903 /* Common CLI fields for vf mac anti spoof enable disable */
10904 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
10905 TOKEN_STRING_INITIALIZER
10906 (struct cmd_vf_mac_anti_spoof_result,
10908 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
10909 TOKEN_STRING_INITIALIZER
10910 (struct cmd_vf_mac_anti_spoof_result,
10912 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
10913 TOKEN_STRING_INITIALIZER
10914 (struct cmd_vf_mac_anti_spoof_result,
10916 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
10917 TOKEN_STRING_INITIALIZER
10918 (struct cmd_vf_mac_anti_spoof_result,
10919 antispoof, "antispoof");
10920 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
10921 TOKEN_NUM_INITIALIZER
10922 (struct cmd_vf_mac_anti_spoof_result,
10923 port_id, RTE_UINT16);
10924 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
10925 TOKEN_NUM_INITIALIZER
10926 (struct cmd_vf_mac_anti_spoof_result,
10927 vf_id, RTE_UINT32);
10928 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
10929 TOKEN_STRING_INITIALIZER
10930 (struct cmd_vf_mac_anti_spoof_result,
10934 cmd_set_vf_mac_anti_spoof_parsed(
10935 void *parsed_result,
10936 __rte_unused struct cmdline *cl,
10937 __rte_unused void *data)
10939 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
10940 int ret = -ENOTSUP;
10942 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
10944 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10947 #ifdef RTE_NET_IXGBE
10948 if (ret == -ENOTSUP)
10949 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
10950 res->vf_id, is_on);
10952 #ifdef RTE_NET_I40E
10953 if (ret == -ENOTSUP)
10954 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
10955 res->vf_id, is_on);
10957 #ifdef RTE_NET_BNXT
10958 if (ret == -ENOTSUP)
10959 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
10960 res->vf_id, is_on);
10967 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
10970 printf("invalid port_id %d\n", res->port_id);
10973 printf("function not implemented\n");
10976 printf("programming error: (%s)\n", strerror(-ret));
10980 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
10981 .f = cmd_set_vf_mac_anti_spoof_parsed,
10983 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
10985 (void *)&cmd_vf_mac_anti_spoof_set,
10986 (void *)&cmd_vf_mac_anti_spoof_vf,
10987 (void *)&cmd_vf_mac_anti_spoof_mac,
10988 (void *)&cmd_vf_mac_anti_spoof_antispoof,
10989 (void *)&cmd_vf_mac_anti_spoof_port_id,
10990 (void *)&cmd_vf_mac_anti_spoof_vf_id,
10991 (void *)&cmd_vf_mac_anti_spoof_on_off,
10996 /* vf vlan strip queue configuration */
10998 /* Common result structure for vf mac anti spoof */
10999 struct cmd_vf_vlan_stripq_result {
11000 cmdline_fixed_string_t set;
11001 cmdline_fixed_string_t vf;
11002 cmdline_fixed_string_t vlan;
11003 cmdline_fixed_string_t stripq;
11006 cmdline_fixed_string_t on_off;
11009 /* Common CLI fields for vf vlan strip enable disable */
11010 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
11011 TOKEN_STRING_INITIALIZER
11012 (struct cmd_vf_vlan_stripq_result,
11014 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
11015 TOKEN_STRING_INITIALIZER
11016 (struct cmd_vf_vlan_stripq_result,
11018 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
11019 TOKEN_STRING_INITIALIZER
11020 (struct cmd_vf_vlan_stripq_result,
11022 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
11023 TOKEN_STRING_INITIALIZER
11024 (struct cmd_vf_vlan_stripq_result,
11026 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
11027 TOKEN_NUM_INITIALIZER
11028 (struct cmd_vf_vlan_stripq_result,
11029 port_id, RTE_UINT16);
11030 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
11031 TOKEN_NUM_INITIALIZER
11032 (struct cmd_vf_vlan_stripq_result,
11033 vf_id, RTE_UINT16);
11034 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
11035 TOKEN_STRING_INITIALIZER
11036 (struct cmd_vf_vlan_stripq_result,
11040 cmd_set_vf_vlan_stripq_parsed(
11041 void *parsed_result,
11042 __rte_unused struct cmdline *cl,
11043 __rte_unused void *data)
11045 struct cmd_vf_vlan_stripq_result *res = parsed_result;
11046 int ret = -ENOTSUP;
11048 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11050 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11053 #ifdef RTE_NET_IXGBE
11054 if (ret == -ENOTSUP)
11055 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
11056 res->vf_id, is_on);
11058 #ifdef RTE_NET_I40E
11059 if (ret == -ENOTSUP)
11060 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
11061 res->vf_id, is_on);
11063 #ifdef RTE_NET_BNXT
11064 if (ret == -ENOTSUP)
11065 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
11066 res->vf_id, is_on);
11073 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11076 printf("invalid port_id %d\n", res->port_id);
11079 printf("function not implemented\n");
11082 printf("programming error: (%s)\n", strerror(-ret));
11086 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
11087 .f = cmd_set_vf_vlan_stripq_parsed,
11089 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
11091 (void *)&cmd_vf_vlan_stripq_set,
11092 (void *)&cmd_vf_vlan_stripq_vf,
11093 (void *)&cmd_vf_vlan_stripq_vlan,
11094 (void *)&cmd_vf_vlan_stripq_stripq,
11095 (void *)&cmd_vf_vlan_stripq_port_id,
11096 (void *)&cmd_vf_vlan_stripq_vf_id,
11097 (void *)&cmd_vf_vlan_stripq_on_off,
11102 /* vf vlan insert configuration */
11104 /* Common result structure for vf vlan insert */
11105 struct cmd_vf_vlan_insert_result {
11106 cmdline_fixed_string_t set;
11107 cmdline_fixed_string_t vf;
11108 cmdline_fixed_string_t vlan;
11109 cmdline_fixed_string_t insert;
11115 /* Common CLI fields for vf vlan insert enable disable */
11116 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
11117 TOKEN_STRING_INITIALIZER
11118 (struct cmd_vf_vlan_insert_result,
11120 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
11121 TOKEN_STRING_INITIALIZER
11122 (struct cmd_vf_vlan_insert_result,
11124 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
11125 TOKEN_STRING_INITIALIZER
11126 (struct cmd_vf_vlan_insert_result,
11128 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
11129 TOKEN_STRING_INITIALIZER
11130 (struct cmd_vf_vlan_insert_result,
11132 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
11133 TOKEN_NUM_INITIALIZER
11134 (struct cmd_vf_vlan_insert_result,
11135 port_id, RTE_UINT16);
11136 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
11137 TOKEN_NUM_INITIALIZER
11138 (struct cmd_vf_vlan_insert_result,
11139 vf_id, RTE_UINT16);
11140 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
11141 TOKEN_NUM_INITIALIZER
11142 (struct cmd_vf_vlan_insert_result,
11143 vlan_id, RTE_UINT16);
11146 cmd_set_vf_vlan_insert_parsed(
11147 void *parsed_result,
11148 __rte_unused struct cmdline *cl,
11149 __rte_unused void *data)
11151 struct cmd_vf_vlan_insert_result *res = parsed_result;
11152 int ret = -ENOTSUP;
11154 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11157 #ifdef RTE_NET_IXGBE
11158 if (ret == -ENOTSUP)
11159 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
11162 #ifdef RTE_NET_I40E
11163 if (ret == -ENOTSUP)
11164 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
11167 #ifdef RTE_NET_BNXT
11168 if (ret == -ENOTSUP)
11169 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
11177 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
11180 printf("invalid port_id %d\n", res->port_id);
11183 printf("function not implemented\n");
11186 printf("programming error: (%s)\n", strerror(-ret));
11190 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
11191 .f = cmd_set_vf_vlan_insert_parsed,
11193 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
11195 (void *)&cmd_vf_vlan_insert_set,
11196 (void *)&cmd_vf_vlan_insert_vf,
11197 (void *)&cmd_vf_vlan_insert_vlan,
11198 (void *)&cmd_vf_vlan_insert_insert,
11199 (void *)&cmd_vf_vlan_insert_port_id,
11200 (void *)&cmd_vf_vlan_insert_vf_id,
11201 (void *)&cmd_vf_vlan_insert_vlan_id,
11206 /* tx loopback configuration */
11208 /* Common result structure for tx loopback */
11209 struct cmd_tx_loopback_result {
11210 cmdline_fixed_string_t set;
11211 cmdline_fixed_string_t tx;
11212 cmdline_fixed_string_t loopback;
11214 cmdline_fixed_string_t on_off;
11217 /* Common CLI fields for tx loopback enable disable */
11218 cmdline_parse_token_string_t cmd_tx_loopback_set =
11219 TOKEN_STRING_INITIALIZER
11220 (struct cmd_tx_loopback_result,
11222 cmdline_parse_token_string_t cmd_tx_loopback_tx =
11223 TOKEN_STRING_INITIALIZER
11224 (struct cmd_tx_loopback_result,
11226 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
11227 TOKEN_STRING_INITIALIZER
11228 (struct cmd_tx_loopback_result,
11229 loopback, "loopback");
11230 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
11231 TOKEN_NUM_INITIALIZER
11232 (struct cmd_tx_loopback_result,
11233 port_id, RTE_UINT16);
11234 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
11235 TOKEN_STRING_INITIALIZER
11236 (struct cmd_tx_loopback_result,
11240 cmd_set_tx_loopback_parsed(
11241 void *parsed_result,
11242 __rte_unused struct cmdline *cl,
11243 __rte_unused void *data)
11245 struct cmd_tx_loopback_result *res = parsed_result;
11246 int ret = -ENOTSUP;
11248 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11250 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11253 #ifdef RTE_NET_IXGBE
11254 if (ret == -ENOTSUP)
11255 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
11257 #ifdef RTE_NET_I40E
11258 if (ret == -ENOTSUP)
11259 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
11261 #ifdef RTE_NET_BNXT
11262 if (ret == -ENOTSUP)
11263 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
11265 #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA
11266 if (ret == -ENOTSUP)
11267 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
11274 printf("invalid is_on %d\n", is_on);
11277 printf("invalid port_id %d\n", res->port_id);
11280 printf("function not implemented\n");
11283 printf("programming error: (%s)\n", strerror(-ret));
11287 cmdline_parse_inst_t cmd_set_tx_loopback = {
11288 .f = cmd_set_tx_loopback_parsed,
11290 .help_str = "set tx loopback <port_id> on|off",
11292 (void *)&cmd_tx_loopback_set,
11293 (void *)&cmd_tx_loopback_tx,
11294 (void *)&cmd_tx_loopback_loopback,
11295 (void *)&cmd_tx_loopback_port_id,
11296 (void *)&cmd_tx_loopback_on_off,
11301 /* all queues drop enable configuration */
11303 /* Common result structure for all queues drop enable */
11304 struct cmd_all_queues_drop_en_result {
11305 cmdline_fixed_string_t set;
11306 cmdline_fixed_string_t all;
11307 cmdline_fixed_string_t queues;
11308 cmdline_fixed_string_t drop;
11310 cmdline_fixed_string_t on_off;
11313 /* Common CLI fields for tx loopback enable disable */
11314 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
11315 TOKEN_STRING_INITIALIZER
11316 (struct cmd_all_queues_drop_en_result,
11318 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
11319 TOKEN_STRING_INITIALIZER
11320 (struct cmd_all_queues_drop_en_result,
11322 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
11323 TOKEN_STRING_INITIALIZER
11324 (struct cmd_all_queues_drop_en_result,
11326 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
11327 TOKEN_STRING_INITIALIZER
11328 (struct cmd_all_queues_drop_en_result,
11330 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
11331 TOKEN_NUM_INITIALIZER
11332 (struct cmd_all_queues_drop_en_result,
11333 port_id, RTE_UINT16);
11334 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
11335 TOKEN_STRING_INITIALIZER
11336 (struct cmd_all_queues_drop_en_result,
11340 cmd_set_all_queues_drop_en_parsed(
11341 void *parsed_result,
11342 __rte_unused struct cmdline *cl,
11343 __rte_unused void *data)
11345 struct cmd_all_queues_drop_en_result *res = parsed_result;
11346 int ret = -ENOTSUP;
11347 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11349 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11352 #ifdef RTE_NET_IXGBE
11353 if (ret == -ENOTSUP)
11354 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
11356 #ifdef RTE_NET_BNXT
11357 if (ret == -ENOTSUP)
11358 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
11364 printf("invalid is_on %d\n", is_on);
11367 printf("invalid port_id %d\n", res->port_id);
11370 printf("function not implemented\n");
11373 printf("programming error: (%s)\n", strerror(-ret));
11377 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
11378 .f = cmd_set_all_queues_drop_en_parsed,
11380 .help_str = "set all queues drop <port_id> on|off",
11382 (void *)&cmd_all_queues_drop_en_set,
11383 (void *)&cmd_all_queues_drop_en_all,
11384 (void *)&cmd_all_queues_drop_en_queues,
11385 (void *)&cmd_all_queues_drop_en_drop,
11386 (void *)&cmd_all_queues_drop_en_port_id,
11387 (void *)&cmd_all_queues_drop_en_on_off,
11392 /* vf split drop enable configuration */
11394 /* Common result structure for vf split drop enable */
11395 struct cmd_vf_split_drop_en_result {
11396 cmdline_fixed_string_t set;
11397 cmdline_fixed_string_t vf;
11398 cmdline_fixed_string_t split;
11399 cmdline_fixed_string_t drop;
11402 cmdline_fixed_string_t on_off;
11405 /* Common CLI fields for vf split drop enable disable */
11406 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
11407 TOKEN_STRING_INITIALIZER
11408 (struct cmd_vf_split_drop_en_result,
11410 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
11411 TOKEN_STRING_INITIALIZER
11412 (struct cmd_vf_split_drop_en_result,
11414 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
11415 TOKEN_STRING_INITIALIZER
11416 (struct cmd_vf_split_drop_en_result,
11418 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
11419 TOKEN_STRING_INITIALIZER
11420 (struct cmd_vf_split_drop_en_result,
11422 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
11423 TOKEN_NUM_INITIALIZER
11424 (struct cmd_vf_split_drop_en_result,
11425 port_id, RTE_UINT16);
11426 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
11427 TOKEN_NUM_INITIALIZER
11428 (struct cmd_vf_split_drop_en_result,
11429 vf_id, RTE_UINT16);
11430 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
11431 TOKEN_STRING_INITIALIZER
11432 (struct cmd_vf_split_drop_en_result,
11436 cmd_set_vf_split_drop_en_parsed(
11437 void *parsed_result,
11438 __rte_unused struct cmdline *cl,
11439 __rte_unused void *data)
11441 struct cmd_vf_split_drop_en_result *res = parsed_result;
11442 int ret = -ENOTSUP;
11443 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11445 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11448 #ifdef RTE_NET_IXGBE
11449 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
11456 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11459 printf("invalid port_id %d\n", res->port_id);
11462 printf("not supported on port %d\n", res->port_id);
11465 printf("programming error: (%s)\n", strerror(-ret));
11469 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
11470 .f = cmd_set_vf_split_drop_en_parsed,
11472 .help_str = "set vf split drop <port_id> <vf_id> on|off",
11474 (void *)&cmd_vf_split_drop_en_set,
11475 (void *)&cmd_vf_split_drop_en_vf,
11476 (void *)&cmd_vf_split_drop_en_split,
11477 (void *)&cmd_vf_split_drop_en_drop,
11478 (void *)&cmd_vf_split_drop_en_port_id,
11479 (void *)&cmd_vf_split_drop_en_vf_id,
11480 (void *)&cmd_vf_split_drop_en_on_off,
11485 /* vf mac address configuration */
11487 /* Common result structure for vf mac address */
11488 struct cmd_set_vf_mac_addr_result {
11489 cmdline_fixed_string_t set;
11490 cmdline_fixed_string_t vf;
11491 cmdline_fixed_string_t mac;
11492 cmdline_fixed_string_t addr;
11495 struct rte_ether_addr mac_addr;
11499 /* Common CLI fields for vf split drop enable disable */
11500 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
11501 TOKEN_STRING_INITIALIZER
11502 (struct cmd_set_vf_mac_addr_result,
11504 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
11505 TOKEN_STRING_INITIALIZER
11506 (struct cmd_set_vf_mac_addr_result,
11508 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
11509 TOKEN_STRING_INITIALIZER
11510 (struct cmd_set_vf_mac_addr_result,
11512 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
11513 TOKEN_STRING_INITIALIZER
11514 (struct cmd_set_vf_mac_addr_result,
11516 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
11517 TOKEN_NUM_INITIALIZER
11518 (struct cmd_set_vf_mac_addr_result,
11519 port_id, RTE_UINT16);
11520 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
11521 TOKEN_NUM_INITIALIZER
11522 (struct cmd_set_vf_mac_addr_result,
11523 vf_id, RTE_UINT16);
11524 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
11525 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
11529 cmd_set_vf_mac_addr_parsed(
11530 void *parsed_result,
11531 __rte_unused struct cmdline *cl,
11532 __rte_unused void *data)
11534 struct cmd_set_vf_mac_addr_result *res = parsed_result;
11535 int ret = -ENOTSUP;
11537 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11540 #ifdef RTE_NET_IXGBE
11541 if (ret == -ENOTSUP)
11542 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
11545 #ifdef RTE_NET_I40E
11546 if (ret == -ENOTSUP)
11547 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
11550 #ifdef RTE_NET_BNXT
11551 if (ret == -ENOTSUP)
11552 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
11560 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
11563 printf("invalid port_id %d\n", res->port_id);
11566 printf("function not implemented\n");
11569 printf("programming error: (%s)\n", strerror(-ret));
11573 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
11574 .f = cmd_set_vf_mac_addr_parsed,
11576 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
11578 (void *)&cmd_set_vf_mac_addr_set,
11579 (void *)&cmd_set_vf_mac_addr_vf,
11580 (void *)&cmd_set_vf_mac_addr_mac,
11581 (void *)&cmd_set_vf_mac_addr_addr,
11582 (void *)&cmd_set_vf_mac_addr_port_id,
11583 (void *)&cmd_set_vf_mac_addr_vf_id,
11584 (void *)&cmd_set_vf_mac_addr_mac_addr,
11589 /* MACsec configuration */
11591 /* Common result structure for MACsec offload enable */
11592 struct cmd_macsec_offload_on_result {
11593 cmdline_fixed_string_t set;
11594 cmdline_fixed_string_t macsec;
11595 cmdline_fixed_string_t offload;
11597 cmdline_fixed_string_t on;
11598 cmdline_fixed_string_t encrypt;
11599 cmdline_fixed_string_t en_on_off;
11600 cmdline_fixed_string_t replay_protect;
11601 cmdline_fixed_string_t rp_on_off;
11604 /* Common CLI fields for MACsec offload disable */
11605 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
11606 TOKEN_STRING_INITIALIZER
11607 (struct cmd_macsec_offload_on_result,
11609 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
11610 TOKEN_STRING_INITIALIZER
11611 (struct cmd_macsec_offload_on_result,
11613 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
11614 TOKEN_STRING_INITIALIZER
11615 (struct cmd_macsec_offload_on_result,
11616 offload, "offload");
11617 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
11618 TOKEN_NUM_INITIALIZER
11619 (struct cmd_macsec_offload_on_result,
11620 port_id, RTE_UINT16);
11621 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
11622 TOKEN_STRING_INITIALIZER
11623 (struct cmd_macsec_offload_on_result,
11625 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
11626 TOKEN_STRING_INITIALIZER
11627 (struct cmd_macsec_offload_on_result,
11628 encrypt, "encrypt");
11629 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
11630 TOKEN_STRING_INITIALIZER
11631 (struct cmd_macsec_offload_on_result,
11632 en_on_off, "on#off");
11633 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
11634 TOKEN_STRING_INITIALIZER
11635 (struct cmd_macsec_offload_on_result,
11636 replay_protect, "replay-protect");
11637 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
11638 TOKEN_STRING_INITIALIZER
11639 (struct cmd_macsec_offload_on_result,
11640 rp_on_off, "on#off");
11643 cmd_set_macsec_offload_on_parsed(
11644 void *parsed_result,
11645 __rte_unused struct cmdline *cl,
11646 __rte_unused void *data)
11648 struct cmd_macsec_offload_on_result *res = parsed_result;
11649 int ret = -ENOTSUP;
11650 portid_t port_id = res->port_id;
11651 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
11652 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
11653 struct rte_eth_dev_info dev_info;
11655 if (port_id_is_invalid(port_id, ENABLED_WARN))
11657 if (!port_is_stopped(port_id)) {
11658 printf("Please stop port %d first\n", port_id);
11662 ret = eth_dev_info_get_print_err(port_id, &dev_info);
11666 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
11667 #ifdef RTE_NET_IXGBE
11668 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
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_on = {
11692 .f = cmd_set_macsec_offload_on_parsed,
11694 .help_str = "set macsec offload <port_id> on "
11695 "encrypt on|off replay-protect on|off",
11697 (void *)&cmd_macsec_offload_on_set,
11698 (void *)&cmd_macsec_offload_on_macsec,
11699 (void *)&cmd_macsec_offload_on_offload,
11700 (void *)&cmd_macsec_offload_on_port_id,
11701 (void *)&cmd_macsec_offload_on_on,
11702 (void *)&cmd_macsec_offload_on_encrypt,
11703 (void *)&cmd_macsec_offload_on_en_on_off,
11704 (void *)&cmd_macsec_offload_on_replay_protect,
11705 (void *)&cmd_macsec_offload_on_rp_on_off,
11710 /* Common result structure for MACsec offload disable */
11711 struct cmd_macsec_offload_off_result {
11712 cmdline_fixed_string_t set;
11713 cmdline_fixed_string_t macsec;
11714 cmdline_fixed_string_t offload;
11716 cmdline_fixed_string_t off;
11719 /* Common CLI fields for MACsec offload disable */
11720 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
11721 TOKEN_STRING_INITIALIZER
11722 (struct cmd_macsec_offload_off_result,
11724 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
11725 TOKEN_STRING_INITIALIZER
11726 (struct cmd_macsec_offload_off_result,
11728 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
11729 TOKEN_STRING_INITIALIZER
11730 (struct cmd_macsec_offload_off_result,
11731 offload, "offload");
11732 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
11733 TOKEN_NUM_INITIALIZER
11734 (struct cmd_macsec_offload_off_result,
11735 port_id, RTE_UINT16);
11736 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
11737 TOKEN_STRING_INITIALIZER
11738 (struct cmd_macsec_offload_off_result,
11742 cmd_set_macsec_offload_off_parsed(
11743 void *parsed_result,
11744 __rte_unused struct cmdline *cl,
11745 __rte_unused void *data)
11747 struct cmd_macsec_offload_off_result *res = parsed_result;
11748 int ret = -ENOTSUP;
11749 struct rte_eth_dev_info dev_info;
11750 portid_t port_id = res->port_id;
11752 if (port_id_is_invalid(port_id, ENABLED_WARN))
11754 if (!port_is_stopped(port_id)) {
11755 printf("Please stop port %d first\n", port_id);
11759 ret = eth_dev_info_get_print_err(port_id, &dev_info);
11763 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
11764 #ifdef RTE_NET_IXGBE
11765 ret = rte_pmd_ixgbe_macsec_disable(port_id);
11770 ports[port_id].dev_conf.txmode.offloads &=
11771 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
11772 cmd_reconfig_device_queue(port_id, 1, 1);
11775 printf("invalid port_id %d\n", port_id);
11778 printf("not supported on port %d\n", port_id);
11781 printf("programming error: (%s)\n", strerror(-ret));
11785 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
11786 .f = cmd_set_macsec_offload_off_parsed,
11788 .help_str = "set macsec offload <port_id> off",
11790 (void *)&cmd_macsec_offload_off_set,
11791 (void *)&cmd_macsec_offload_off_macsec,
11792 (void *)&cmd_macsec_offload_off_offload,
11793 (void *)&cmd_macsec_offload_off_port_id,
11794 (void *)&cmd_macsec_offload_off_off,
11799 /* Common result structure for MACsec secure connection configure */
11800 struct cmd_macsec_sc_result {
11801 cmdline_fixed_string_t set;
11802 cmdline_fixed_string_t macsec;
11803 cmdline_fixed_string_t sc;
11804 cmdline_fixed_string_t tx_rx;
11806 struct rte_ether_addr mac;
11810 /* Common CLI fields for MACsec secure connection configure */
11811 cmdline_parse_token_string_t cmd_macsec_sc_set =
11812 TOKEN_STRING_INITIALIZER
11813 (struct cmd_macsec_sc_result,
11815 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
11816 TOKEN_STRING_INITIALIZER
11817 (struct cmd_macsec_sc_result,
11819 cmdline_parse_token_string_t cmd_macsec_sc_sc =
11820 TOKEN_STRING_INITIALIZER
11821 (struct cmd_macsec_sc_result,
11823 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
11824 TOKEN_STRING_INITIALIZER
11825 (struct cmd_macsec_sc_result,
11827 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
11828 TOKEN_NUM_INITIALIZER
11829 (struct cmd_macsec_sc_result,
11830 port_id, RTE_UINT16);
11831 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
11832 TOKEN_ETHERADDR_INITIALIZER
11833 (struct cmd_macsec_sc_result,
11835 cmdline_parse_token_num_t cmd_macsec_sc_pi =
11836 TOKEN_NUM_INITIALIZER
11837 (struct cmd_macsec_sc_result,
11841 cmd_set_macsec_sc_parsed(
11842 void *parsed_result,
11843 __rte_unused struct cmdline *cl,
11844 __rte_unused void *data)
11846 struct cmd_macsec_sc_result *res = parsed_result;
11847 int ret = -ENOTSUP;
11848 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
11850 #ifdef RTE_NET_IXGBE
11852 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
11853 res->mac.addr_bytes) :
11854 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
11855 res->mac.addr_bytes, res->pi);
11857 RTE_SET_USED(is_tx);
11863 printf("invalid port_id %d\n", res->port_id);
11866 printf("not supported on port %d\n", res->port_id);
11869 printf("programming error: (%s)\n", strerror(-ret));
11873 cmdline_parse_inst_t cmd_set_macsec_sc = {
11874 .f = cmd_set_macsec_sc_parsed,
11876 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
11878 (void *)&cmd_macsec_sc_set,
11879 (void *)&cmd_macsec_sc_macsec,
11880 (void *)&cmd_macsec_sc_sc,
11881 (void *)&cmd_macsec_sc_tx_rx,
11882 (void *)&cmd_macsec_sc_port_id,
11883 (void *)&cmd_macsec_sc_mac,
11884 (void *)&cmd_macsec_sc_pi,
11889 /* Common result structure for MACsec secure connection configure */
11890 struct cmd_macsec_sa_result {
11891 cmdline_fixed_string_t set;
11892 cmdline_fixed_string_t macsec;
11893 cmdline_fixed_string_t sa;
11894 cmdline_fixed_string_t tx_rx;
11899 cmdline_fixed_string_t key;
11902 /* Common CLI fields for MACsec secure connection configure */
11903 cmdline_parse_token_string_t cmd_macsec_sa_set =
11904 TOKEN_STRING_INITIALIZER
11905 (struct cmd_macsec_sa_result,
11907 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
11908 TOKEN_STRING_INITIALIZER
11909 (struct cmd_macsec_sa_result,
11911 cmdline_parse_token_string_t cmd_macsec_sa_sa =
11912 TOKEN_STRING_INITIALIZER
11913 (struct cmd_macsec_sa_result,
11915 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
11916 TOKEN_STRING_INITIALIZER
11917 (struct cmd_macsec_sa_result,
11919 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
11920 TOKEN_NUM_INITIALIZER
11921 (struct cmd_macsec_sa_result,
11922 port_id, RTE_UINT16);
11923 cmdline_parse_token_num_t cmd_macsec_sa_idx =
11924 TOKEN_NUM_INITIALIZER
11925 (struct cmd_macsec_sa_result,
11927 cmdline_parse_token_num_t cmd_macsec_sa_an =
11928 TOKEN_NUM_INITIALIZER
11929 (struct cmd_macsec_sa_result,
11931 cmdline_parse_token_num_t cmd_macsec_sa_pn =
11932 TOKEN_NUM_INITIALIZER
11933 (struct cmd_macsec_sa_result,
11935 cmdline_parse_token_string_t cmd_macsec_sa_key =
11936 TOKEN_STRING_INITIALIZER
11937 (struct cmd_macsec_sa_result,
11941 cmd_set_macsec_sa_parsed(
11942 void *parsed_result,
11943 __rte_unused struct cmdline *cl,
11944 __rte_unused void *data)
11946 struct cmd_macsec_sa_result *res = parsed_result;
11947 int ret = -ENOTSUP;
11948 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
11949 uint8_t key[16] = { 0 };
11955 key_len = strlen(res->key) / 2;
11959 for (i = 0; i < key_len; i++) {
11960 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
11963 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
11966 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
11969 #ifdef RTE_NET_IXGBE
11971 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
11972 res->idx, res->an, res->pn, key) :
11973 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
11974 res->idx, res->an, res->pn, key);
11976 RTE_SET_USED(is_tx);
11983 printf("invalid idx %d or an %d\n", res->idx, res->an);
11986 printf("invalid port_id %d\n", res->port_id);
11989 printf("not supported on port %d\n", res->port_id);
11992 printf("programming error: (%s)\n", strerror(-ret));
11996 cmdline_parse_inst_t cmd_set_macsec_sa = {
11997 .f = cmd_set_macsec_sa_parsed,
11999 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
12001 (void *)&cmd_macsec_sa_set,
12002 (void *)&cmd_macsec_sa_macsec,
12003 (void *)&cmd_macsec_sa_sa,
12004 (void *)&cmd_macsec_sa_tx_rx,
12005 (void *)&cmd_macsec_sa_port_id,
12006 (void *)&cmd_macsec_sa_idx,
12007 (void *)&cmd_macsec_sa_an,
12008 (void *)&cmd_macsec_sa_pn,
12009 (void *)&cmd_macsec_sa_key,
12014 /* VF unicast promiscuous mode configuration */
12016 /* Common result structure for VF unicast promiscuous mode */
12017 struct cmd_vf_promisc_result {
12018 cmdline_fixed_string_t set;
12019 cmdline_fixed_string_t vf;
12020 cmdline_fixed_string_t promisc;
12023 cmdline_fixed_string_t on_off;
12026 /* Common CLI fields for VF unicast promiscuous mode enable disable */
12027 cmdline_parse_token_string_t cmd_vf_promisc_set =
12028 TOKEN_STRING_INITIALIZER
12029 (struct cmd_vf_promisc_result,
12031 cmdline_parse_token_string_t cmd_vf_promisc_vf =
12032 TOKEN_STRING_INITIALIZER
12033 (struct cmd_vf_promisc_result,
12035 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
12036 TOKEN_STRING_INITIALIZER
12037 (struct cmd_vf_promisc_result,
12038 promisc, "promisc");
12039 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
12040 TOKEN_NUM_INITIALIZER
12041 (struct cmd_vf_promisc_result,
12042 port_id, RTE_UINT16);
12043 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
12044 TOKEN_NUM_INITIALIZER
12045 (struct cmd_vf_promisc_result,
12046 vf_id, RTE_UINT32);
12047 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
12048 TOKEN_STRING_INITIALIZER
12049 (struct cmd_vf_promisc_result,
12053 cmd_set_vf_promisc_parsed(
12054 void *parsed_result,
12055 __rte_unused struct cmdline *cl,
12056 __rte_unused void *data)
12058 struct cmd_vf_promisc_result *res = parsed_result;
12059 int ret = -ENOTSUP;
12061 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12063 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12066 #ifdef RTE_NET_I40E
12067 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
12068 res->vf_id, is_on);
12075 printf("invalid vf_id %d\n", res->vf_id);
12078 printf("invalid port_id %d\n", res->port_id);
12081 printf("function not implemented\n");
12084 printf("programming error: (%s)\n", strerror(-ret));
12088 cmdline_parse_inst_t cmd_set_vf_promisc = {
12089 .f = cmd_set_vf_promisc_parsed,
12091 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
12092 "Set unicast promiscuous mode for a VF from the PF",
12094 (void *)&cmd_vf_promisc_set,
12095 (void *)&cmd_vf_promisc_vf,
12096 (void *)&cmd_vf_promisc_promisc,
12097 (void *)&cmd_vf_promisc_port_id,
12098 (void *)&cmd_vf_promisc_vf_id,
12099 (void *)&cmd_vf_promisc_on_off,
12104 /* VF multicast promiscuous mode configuration */
12106 /* Common result structure for VF multicast promiscuous mode */
12107 struct cmd_vf_allmulti_result {
12108 cmdline_fixed_string_t set;
12109 cmdline_fixed_string_t vf;
12110 cmdline_fixed_string_t allmulti;
12113 cmdline_fixed_string_t on_off;
12116 /* Common CLI fields for VF multicast promiscuous mode enable disable */
12117 cmdline_parse_token_string_t cmd_vf_allmulti_set =
12118 TOKEN_STRING_INITIALIZER
12119 (struct cmd_vf_allmulti_result,
12121 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
12122 TOKEN_STRING_INITIALIZER
12123 (struct cmd_vf_allmulti_result,
12125 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
12126 TOKEN_STRING_INITIALIZER
12127 (struct cmd_vf_allmulti_result,
12128 allmulti, "allmulti");
12129 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
12130 TOKEN_NUM_INITIALIZER
12131 (struct cmd_vf_allmulti_result,
12132 port_id, RTE_UINT16);
12133 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
12134 TOKEN_NUM_INITIALIZER
12135 (struct cmd_vf_allmulti_result,
12136 vf_id, RTE_UINT32);
12137 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
12138 TOKEN_STRING_INITIALIZER
12139 (struct cmd_vf_allmulti_result,
12143 cmd_set_vf_allmulti_parsed(
12144 void *parsed_result,
12145 __rte_unused struct cmdline *cl,
12146 __rte_unused void *data)
12148 struct cmd_vf_allmulti_result *res = parsed_result;
12149 int ret = -ENOTSUP;
12151 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12153 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12156 #ifdef RTE_NET_I40E
12157 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
12158 res->vf_id, is_on);
12165 printf("invalid vf_id %d\n", res->vf_id);
12168 printf("invalid port_id %d\n", res->port_id);
12171 printf("function not implemented\n");
12174 printf("programming error: (%s)\n", strerror(-ret));
12178 cmdline_parse_inst_t cmd_set_vf_allmulti = {
12179 .f = cmd_set_vf_allmulti_parsed,
12181 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
12182 "Set multicast promiscuous mode for a VF from the PF",
12184 (void *)&cmd_vf_allmulti_set,
12185 (void *)&cmd_vf_allmulti_vf,
12186 (void *)&cmd_vf_allmulti_allmulti,
12187 (void *)&cmd_vf_allmulti_port_id,
12188 (void *)&cmd_vf_allmulti_vf_id,
12189 (void *)&cmd_vf_allmulti_on_off,
12194 /* vf broadcast mode configuration */
12196 /* Common result structure for vf broadcast */
12197 struct cmd_set_vf_broadcast_result {
12198 cmdline_fixed_string_t set;
12199 cmdline_fixed_string_t vf;
12200 cmdline_fixed_string_t broadcast;
12203 cmdline_fixed_string_t on_off;
12206 /* Common CLI fields for vf broadcast enable disable */
12207 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
12208 TOKEN_STRING_INITIALIZER
12209 (struct cmd_set_vf_broadcast_result,
12211 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
12212 TOKEN_STRING_INITIALIZER
12213 (struct cmd_set_vf_broadcast_result,
12215 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
12216 TOKEN_STRING_INITIALIZER
12217 (struct cmd_set_vf_broadcast_result,
12218 broadcast, "broadcast");
12219 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
12220 TOKEN_NUM_INITIALIZER
12221 (struct cmd_set_vf_broadcast_result,
12222 port_id, RTE_UINT16);
12223 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
12224 TOKEN_NUM_INITIALIZER
12225 (struct cmd_set_vf_broadcast_result,
12226 vf_id, RTE_UINT16);
12227 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
12228 TOKEN_STRING_INITIALIZER
12229 (struct cmd_set_vf_broadcast_result,
12233 cmd_set_vf_broadcast_parsed(
12234 void *parsed_result,
12235 __rte_unused struct cmdline *cl,
12236 __rte_unused void *data)
12238 struct cmd_set_vf_broadcast_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_broadcast(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_broadcast = {
12269 .f = cmd_set_vf_broadcast_parsed,
12271 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
12273 (void *)&cmd_set_vf_broadcast_set,
12274 (void *)&cmd_set_vf_broadcast_vf,
12275 (void *)&cmd_set_vf_broadcast_broadcast,
12276 (void *)&cmd_set_vf_broadcast_port_id,
12277 (void *)&cmd_set_vf_broadcast_vf_id,
12278 (void *)&cmd_set_vf_broadcast_on_off,
12283 /* vf vlan tag configuration */
12285 /* Common result structure for vf vlan tag */
12286 struct cmd_set_vf_vlan_tag_result {
12287 cmdline_fixed_string_t set;
12288 cmdline_fixed_string_t vf;
12289 cmdline_fixed_string_t vlan;
12290 cmdline_fixed_string_t tag;
12293 cmdline_fixed_string_t on_off;
12296 /* Common CLI fields for vf vlan tag enable disable */
12297 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
12298 TOKEN_STRING_INITIALIZER
12299 (struct cmd_set_vf_vlan_tag_result,
12301 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
12302 TOKEN_STRING_INITIALIZER
12303 (struct cmd_set_vf_vlan_tag_result,
12305 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
12306 TOKEN_STRING_INITIALIZER
12307 (struct cmd_set_vf_vlan_tag_result,
12309 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
12310 TOKEN_STRING_INITIALIZER
12311 (struct cmd_set_vf_vlan_tag_result,
12313 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
12314 TOKEN_NUM_INITIALIZER
12315 (struct cmd_set_vf_vlan_tag_result,
12316 port_id, RTE_UINT16);
12317 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
12318 TOKEN_NUM_INITIALIZER
12319 (struct cmd_set_vf_vlan_tag_result,
12320 vf_id, RTE_UINT16);
12321 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
12322 TOKEN_STRING_INITIALIZER
12323 (struct cmd_set_vf_vlan_tag_result,
12327 cmd_set_vf_vlan_tag_parsed(
12328 void *parsed_result,
12329 __rte_unused struct cmdline *cl,
12330 __rte_unused void *data)
12332 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
12333 int ret = -ENOTSUP;
12335 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12337 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12340 #ifdef RTE_NET_I40E
12341 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
12342 res->vf_id, is_on);
12349 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12352 printf("invalid port_id %d\n", res->port_id);
12355 printf("function not implemented\n");
12358 printf("programming error: (%s)\n", strerror(-ret));
12362 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
12363 .f = cmd_set_vf_vlan_tag_parsed,
12365 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
12367 (void *)&cmd_set_vf_vlan_tag_set,
12368 (void *)&cmd_set_vf_vlan_tag_vf,
12369 (void *)&cmd_set_vf_vlan_tag_vlan,
12370 (void *)&cmd_set_vf_vlan_tag_tag,
12371 (void *)&cmd_set_vf_vlan_tag_port_id,
12372 (void *)&cmd_set_vf_vlan_tag_vf_id,
12373 (void *)&cmd_set_vf_vlan_tag_on_off,
12378 /* Common definition of VF and TC TX bandwidth configuration */
12379 struct cmd_vf_tc_bw_result {
12380 cmdline_fixed_string_t set;
12381 cmdline_fixed_string_t vf;
12382 cmdline_fixed_string_t tc;
12383 cmdline_fixed_string_t tx;
12384 cmdline_fixed_string_t min_bw;
12385 cmdline_fixed_string_t max_bw;
12386 cmdline_fixed_string_t strict_link_prio;
12391 cmdline_fixed_string_t bw_list;
12395 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
12396 TOKEN_STRING_INITIALIZER
12397 (struct cmd_vf_tc_bw_result,
12399 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
12400 TOKEN_STRING_INITIALIZER
12401 (struct cmd_vf_tc_bw_result,
12403 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
12404 TOKEN_STRING_INITIALIZER
12405 (struct cmd_vf_tc_bw_result,
12407 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
12408 TOKEN_STRING_INITIALIZER
12409 (struct cmd_vf_tc_bw_result,
12411 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
12412 TOKEN_STRING_INITIALIZER
12413 (struct cmd_vf_tc_bw_result,
12414 strict_link_prio, "strict-link-priority");
12415 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
12416 TOKEN_STRING_INITIALIZER
12417 (struct cmd_vf_tc_bw_result,
12418 min_bw, "min-bandwidth");
12419 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
12420 TOKEN_STRING_INITIALIZER
12421 (struct cmd_vf_tc_bw_result,
12422 max_bw, "max-bandwidth");
12423 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
12424 TOKEN_NUM_INITIALIZER
12425 (struct cmd_vf_tc_bw_result,
12426 port_id, RTE_UINT16);
12427 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
12428 TOKEN_NUM_INITIALIZER
12429 (struct cmd_vf_tc_bw_result,
12430 vf_id, RTE_UINT16);
12431 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
12432 TOKEN_NUM_INITIALIZER
12433 (struct cmd_vf_tc_bw_result,
12435 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
12436 TOKEN_NUM_INITIALIZER
12437 (struct cmd_vf_tc_bw_result,
12439 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
12440 TOKEN_STRING_INITIALIZER
12441 (struct cmd_vf_tc_bw_result,
12443 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
12444 TOKEN_NUM_INITIALIZER
12445 (struct cmd_vf_tc_bw_result,
12446 tc_map, RTE_UINT8);
12448 /* VF max bandwidth setting */
12450 cmd_vf_max_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;
12456 int ret = -ENOTSUP;
12458 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12461 #ifdef RTE_NET_I40E
12462 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
12463 res->vf_id, res->bw);
12470 printf("invalid vf_id %d or bandwidth %d\n",
12471 res->vf_id, res->bw);
12474 printf("invalid port_id %d\n", res->port_id);
12477 printf("function not implemented\n");
12480 printf("programming error: (%s)\n", strerror(-ret));
12484 cmdline_parse_inst_t cmd_vf_max_bw = {
12485 .f = cmd_vf_max_bw_parsed,
12487 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
12489 (void *)&cmd_vf_tc_bw_set,
12490 (void *)&cmd_vf_tc_bw_vf,
12491 (void *)&cmd_vf_tc_bw_tx,
12492 (void *)&cmd_vf_tc_bw_max_bw,
12493 (void *)&cmd_vf_tc_bw_port_id,
12494 (void *)&cmd_vf_tc_bw_vf_id,
12495 (void *)&cmd_vf_tc_bw_bw,
12501 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
12506 const char *p, *p0 = str;
12513 p = strchr(p0, '(');
12515 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
12519 p0 = strchr(p, ')');
12521 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
12525 if (size >= sizeof(s)) {
12526 printf("The string size exceeds the internal buffer size\n");
12529 snprintf(s, sizeof(s), "%.*s", size, p);
12530 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
12532 printf("Failed to get the bandwidth list. ");
12536 for (i = 0; i < ret; i++)
12537 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
12542 /* TC min bandwidth setting */
12544 cmd_vf_tc_min_bw_parsed(
12545 void *parsed_result,
12546 __rte_unused struct cmdline *cl,
12547 __rte_unused void *data)
12549 struct cmd_vf_tc_bw_result *res = parsed_result;
12552 int ret = -ENOTSUP;
12554 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12557 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12561 #ifdef RTE_NET_I40E
12562 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
12570 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
12573 printf("invalid port_id %d\n", res->port_id);
12576 printf("function not implemented\n");
12579 printf("programming error: (%s)\n", strerror(-ret));
12583 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
12584 .f = cmd_vf_tc_min_bw_parsed,
12586 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
12587 " <bw1, bw2, ...>",
12589 (void *)&cmd_vf_tc_bw_set,
12590 (void *)&cmd_vf_tc_bw_vf,
12591 (void *)&cmd_vf_tc_bw_tc,
12592 (void *)&cmd_vf_tc_bw_tx,
12593 (void *)&cmd_vf_tc_bw_min_bw,
12594 (void *)&cmd_vf_tc_bw_port_id,
12595 (void *)&cmd_vf_tc_bw_vf_id,
12596 (void *)&cmd_vf_tc_bw_bw_list,
12602 cmd_tc_min_bw_parsed(
12603 void *parsed_result,
12604 __rte_unused struct cmdline *cl,
12605 __rte_unused void *data)
12607 struct cmd_vf_tc_bw_result *res = parsed_result;
12608 struct rte_port *port;
12611 int ret = -ENOTSUP;
12613 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12616 port = &ports[res->port_id];
12617 /** Check if the port is not started **/
12618 if (port->port_status != RTE_PORT_STOPPED) {
12619 printf("Please stop port %d first\n", res->port_id);
12623 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12627 #ifdef RTE_NET_IXGBE
12628 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
12635 printf("invalid bandwidth\n");
12638 printf("invalid port_id %d\n", res->port_id);
12641 printf("function not implemented\n");
12644 printf("programming error: (%s)\n", strerror(-ret));
12648 cmdline_parse_inst_t cmd_tc_min_bw = {
12649 .f = cmd_tc_min_bw_parsed,
12651 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
12653 (void *)&cmd_vf_tc_bw_set,
12654 (void *)&cmd_vf_tc_bw_tc,
12655 (void *)&cmd_vf_tc_bw_tx,
12656 (void *)&cmd_vf_tc_bw_min_bw,
12657 (void *)&cmd_vf_tc_bw_port_id,
12658 (void *)&cmd_vf_tc_bw_bw_list,
12663 /* TC max bandwidth setting */
12665 cmd_vf_tc_max_bw_parsed(
12666 void *parsed_result,
12667 __rte_unused struct cmdline *cl,
12668 __rte_unused void *data)
12670 struct cmd_vf_tc_bw_result *res = parsed_result;
12671 int ret = -ENOTSUP;
12673 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12676 #ifdef RTE_NET_I40E
12677 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
12678 res->tc_no, res->bw);
12685 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
12686 res->vf_id, res->tc_no, res->bw);
12689 printf("invalid port_id %d\n", res->port_id);
12692 printf("function not implemented\n");
12695 printf("programming error: (%s)\n", strerror(-ret));
12699 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
12700 .f = cmd_vf_tc_max_bw_parsed,
12702 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
12705 (void *)&cmd_vf_tc_bw_set,
12706 (void *)&cmd_vf_tc_bw_vf,
12707 (void *)&cmd_vf_tc_bw_tc,
12708 (void *)&cmd_vf_tc_bw_tx,
12709 (void *)&cmd_vf_tc_bw_max_bw,
12710 (void *)&cmd_vf_tc_bw_port_id,
12711 (void *)&cmd_vf_tc_bw_vf_id,
12712 (void *)&cmd_vf_tc_bw_tc_no,
12713 (void *)&cmd_vf_tc_bw_bw,
12718 /** Set VXLAN encapsulation details */
12719 struct cmd_set_vxlan_result {
12720 cmdline_fixed_string_t set;
12721 cmdline_fixed_string_t vxlan;
12722 cmdline_fixed_string_t pos_token;
12723 cmdline_fixed_string_t ip_version;
12724 uint32_t vlan_present:1;
12728 cmdline_ipaddr_t ip_src;
12729 cmdline_ipaddr_t ip_dst;
12733 struct rte_ether_addr eth_src;
12734 struct rte_ether_addr eth_dst;
12737 cmdline_parse_token_string_t cmd_set_vxlan_set =
12738 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
12739 cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
12740 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
12741 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
12742 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
12744 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
12745 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
12746 "vxlan-with-vlan");
12747 cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
12748 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12750 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
12751 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
12753 cmdline_parse_token_string_t cmd_set_vxlan_vni =
12754 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12756 cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
12757 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, RTE_UINT32);
12758 cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
12759 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12761 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
12762 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, RTE_UINT16);
12763 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
12764 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12766 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
12767 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, RTE_UINT16);
12768 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
12769 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12771 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
12772 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, RTE_UINT8);
12773 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
12774 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12776 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
12777 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, RTE_UINT8);
12778 cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
12779 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12781 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
12782 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
12783 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
12784 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12786 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
12787 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
12788 cmdline_parse_token_string_t cmd_set_vxlan_vlan =
12789 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12791 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
12792 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, RTE_UINT16);
12793 cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
12794 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12796 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
12797 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
12798 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
12799 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12801 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
12802 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
12804 static void cmd_set_vxlan_parsed(void *parsed_result,
12805 __rte_unused struct cmdline *cl,
12806 __rte_unused void *data)
12808 struct cmd_set_vxlan_result *res = parsed_result;
12813 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
12816 vxlan_encap_conf.select_tos_ttl = 0;
12817 if (strcmp(res->vxlan, "vxlan") == 0)
12818 vxlan_encap_conf.select_vlan = 0;
12819 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
12820 vxlan_encap_conf.select_vlan = 1;
12821 else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
12822 vxlan_encap_conf.select_vlan = 0;
12823 vxlan_encap_conf.select_tos_ttl = 1;
12825 if (strcmp(res->ip_version, "ipv4") == 0)
12826 vxlan_encap_conf.select_ipv4 = 1;
12827 else if (strcmp(res->ip_version, "ipv6") == 0)
12828 vxlan_encap_conf.select_ipv4 = 0;
12831 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
12832 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
12833 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
12834 vxlan_encap_conf.ip_tos = res->tos;
12835 vxlan_encap_conf.ip_ttl = res->ttl;
12836 if (vxlan_encap_conf.select_ipv4) {
12837 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
12838 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
12840 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
12841 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
12843 if (vxlan_encap_conf.select_vlan)
12844 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
12845 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
12846 RTE_ETHER_ADDR_LEN);
12847 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
12848 RTE_ETHER_ADDR_LEN);
12851 cmdline_parse_inst_t cmd_set_vxlan = {
12852 .f = cmd_set_vxlan_parsed,
12854 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
12855 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
12856 " eth-src <eth-src> eth-dst <eth-dst>",
12858 (void *)&cmd_set_vxlan_set,
12859 (void *)&cmd_set_vxlan_vxlan,
12860 (void *)&cmd_set_vxlan_ip_version,
12861 (void *)&cmd_set_vxlan_ip_version_value,
12862 (void *)&cmd_set_vxlan_vni,
12863 (void *)&cmd_set_vxlan_vni_value,
12864 (void *)&cmd_set_vxlan_udp_src,
12865 (void *)&cmd_set_vxlan_udp_src_value,
12866 (void *)&cmd_set_vxlan_udp_dst,
12867 (void *)&cmd_set_vxlan_udp_dst_value,
12868 (void *)&cmd_set_vxlan_ip_src,
12869 (void *)&cmd_set_vxlan_ip_src_value,
12870 (void *)&cmd_set_vxlan_ip_dst,
12871 (void *)&cmd_set_vxlan_ip_dst_value,
12872 (void *)&cmd_set_vxlan_eth_src,
12873 (void *)&cmd_set_vxlan_eth_src_value,
12874 (void *)&cmd_set_vxlan_eth_dst,
12875 (void *)&cmd_set_vxlan_eth_dst_value,
12880 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
12881 .f = cmd_set_vxlan_parsed,
12883 .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
12884 " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
12885 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
12886 " eth-dst <eth-dst>",
12888 (void *)&cmd_set_vxlan_set,
12889 (void *)&cmd_set_vxlan_vxlan_tos_ttl,
12890 (void *)&cmd_set_vxlan_ip_version,
12891 (void *)&cmd_set_vxlan_ip_version_value,
12892 (void *)&cmd_set_vxlan_vni,
12893 (void *)&cmd_set_vxlan_vni_value,
12894 (void *)&cmd_set_vxlan_udp_src,
12895 (void *)&cmd_set_vxlan_udp_src_value,
12896 (void *)&cmd_set_vxlan_udp_dst,
12897 (void *)&cmd_set_vxlan_udp_dst_value,
12898 (void *)&cmd_set_vxlan_ip_tos,
12899 (void *)&cmd_set_vxlan_ip_tos_value,
12900 (void *)&cmd_set_vxlan_ip_ttl,
12901 (void *)&cmd_set_vxlan_ip_ttl_value,
12902 (void *)&cmd_set_vxlan_ip_src,
12903 (void *)&cmd_set_vxlan_ip_src_value,
12904 (void *)&cmd_set_vxlan_ip_dst,
12905 (void *)&cmd_set_vxlan_ip_dst_value,
12906 (void *)&cmd_set_vxlan_eth_src,
12907 (void *)&cmd_set_vxlan_eth_src_value,
12908 (void *)&cmd_set_vxlan_eth_dst,
12909 (void *)&cmd_set_vxlan_eth_dst_value,
12914 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
12915 .f = cmd_set_vxlan_parsed,
12917 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
12918 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
12919 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
12922 (void *)&cmd_set_vxlan_set,
12923 (void *)&cmd_set_vxlan_vxlan_with_vlan,
12924 (void *)&cmd_set_vxlan_ip_version,
12925 (void *)&cmd_set_vxlan_ip_version_value,
12926 (void *)&cmd_set_vxlan_vni,
12927 (void *)&cmd_set_vxlan_vni_value,
12928 (void *)&cmd_set_vxlan_udp_src,
12929 (void *)&cmd_set_vxlan_udp_src_value,
12930 (void *)&cmd_set_vxlan_udp_dst,
12931 (void *)&cmd_set_vxlan_udp_dst_value,
12932 (void *)&cmd_set_vxlan_ip_src,
12933 (void *)&cmd_set_vxlan_ip_src_value,
12934 (void *)&cmd_set_vxlan_ip_dst,
12935 (void *)&cmd_set_vxlan_ip_dst_value,
12936 (void *)&cmd_set_vxlan_vlan,
12937 (void *)&cmd_set_vxlan_vlan_value,
12938 (void *)&cmd_set_vxlan_eth_src,
12939 (void *)&cmd_set_vxlan_eth_src_value,
12940 (void *)&cmd_set_vxlan_eth_dst,
12941 (void *)&cmd_set_vxlan_eth_dst_value,
12946 /** Set NVGRE encapsulation details */
12947 struct cmd_set_nvgre_result {
12948 cmdline_fixed_string_t set;
12949 cmdline_fixed_string_t nvgre;
12950 cmdline_fixed_string_t pos_token;
12951 cmdline_fixed_string_t ip_version;
12953 cmdline_ipaddr_t ip_src;
12954 cmdline_ipaddr_t ip_dst;
12956 struct rte_ether_addr eth_src;
12957 struct rte_ether_addr eth_dst;
12960 cmdline_parse_token_string_t cmd_set_nvgre_set =
12961 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
12962 cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
12963 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
12964 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
12965 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
12966 "nvgre-with-vlan");
12967 cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
12968 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
12970 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
12971 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
12973 cmdline_parse_token_string_t cmd_set_nvgre_tni =
12974 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
12976 cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
12977 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, RTE_UINT32);
12978 cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
12979 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
12981 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
12982 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
12983 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
12984 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
12986 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
12987 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
12988 cmdline_parse_token_string_t cmd_set_nvgre_vlan =
12989 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
12991 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
12992 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, RTE_UINT16);
12993 cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
12994 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
12996 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
12997 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
12998 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
12999 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13001 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
13002 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
13004 static void cmd_set_nvgre_parsed(void *parsed_result,
13005 __rte_unused struct cmdline *cl,
13006 __rte_unused void *data)
13008 struct cmd_set_nvgre_result *res = parsed_result;
13010 uint32_t nvgre_tni;
13013 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
13016 if (strcmp(res->nvgre, "nvgre") == 0)
13017 nvgre_encap_conf.select_vlan = 0;
13018 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
13019 nvgre_encap_conf.select_vlan = 1;
13020 if (strcmp(res->ip_version, "ipv4") == 0)
13021 nvgre_encap_conf.select_ipv4 = 1;
13022 else if (strcmp(res->ip_version, "ipv6") == 0)
13023 nvgre_encap_conf.select_ipv4 = 0;
13026 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
13027 if (nvgre_encap_conf.select_ipv4) {
13028 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
13029 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
13031 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
13032 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
13034 if (nvgre_encap_conf.select_vlan)
13035 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13036 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
13037 RTE_ETHER_ADDR_LEN);
13038 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13039 RTE_ETHER_ADDR_LEN);
13042 cmdline_parse_inst_t cmd_set_nvgre = {
13043 .f = cmd_set_nvgre_parsed,
13045 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
13046 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
13047 " eth-dst <eth-dst>",
13049 (void *)&cmd_set_nvgre_set,
13050 (void *)&cmd_set_nvgre_nvgre,
13051 (void *)&cmd_set_nvgre_ip_version,
13052 (void *)&cmd_set_nvgre_ip_version_value,
13053 (void *)&cmd_set_nvgre_tni,
13054 (void *)&cmd_set_nvgre_tni_value,
13055 (void *)&cmd_set_nvgre_ip_src,
13056 (void *)&cmd_set_nvgre_ip_src_value,
13057 (void *)&cmd_set_nvgre_ip_dst,
13058 (void *)&cmd_set_nvgre_ip_dst_value,
13059 (void *)&cmd_set_nvgre_eth_src,
13060 (void *)&cmd_set_nvgre_eth_src_value,
13061 (void *)&cmd_set_nvgre_eth_dst,
13062 (void *)&cmd_set_nvgre_eth_dst_value,
13067 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
13068 .f = cmd_set_nvgre_parsed,
13070 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
13071 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
13072 " eth-src <eth-src> eth-dst <eth-dst>",
13074 (void *)&cmd_set_nvgre_set,
13075 (void *)&cmd_set_nvgre_nvgre_with_vlan,
13076 (void *)&cmd_set_nvgre_ip_version,
13077 (void *)&cmd_set_nvgre_ip_version_value,
13078 (void *)&cmd_set_nvgre_tni,
13079 (void *)&cmd_set_nvgre_tni_value,
13080 (void *)&cmd_set_nvgre_ip_src,
13081 (void *)&cmd_set_nvgre_ip_src_value,
13082 (void *)&cmd_set_nvgre_ip_dst,
13083 (void *)&cmd_set_nvgre_ip_dst_value,
13084 (void *)&cmd_set_nvgre_vlan,
13085 (void *)&cmd_set_nvgre_vlan_value,
13086 (void *)&cmd_set_nvgre_eth_src,
13087 (void *)&cmd_set_nvgre_eth_src_value,
13088 (void *)&cmd_set_nvgre_eth_dst,
13089 (void *)&cmd_set_nvgre_eth_dst_value,
13094 /** Set L2 encapsulation details */
13095 struct cmd_set_l2_encap_result {
13096 cmdline_fixed_string_t set;
13097 cmdline_fixed_string_t l2_encap;
13098 cmdline_fixed_string_t pos_token;
13099 cmdline_fixed_string_t ip_version;
13100 uint32_t vlan_present:1;
13102 struct rte_ether_addr eth_src;
13103 struct rte_ether_addr eth_dst;
13106 cmdline_parse_token_string_t cmd_set_l2_encap_set =
13107 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
13108 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
13109 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
13110 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
13111 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
13112 "l2_encap-with-vlan");
13113 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
13114 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13116 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
13117 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
13119 cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
13120 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13122 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
13123 TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, RTE_UINT16);
13124 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
13125 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13127 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
13128 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
13129 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
13130 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13132 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
13133 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
13135 static void cmd_set_l2_encap_parsed(void *parsed_result,
13136 __rte_unused struct cmdline *cl,
13137 __rte_unused void *data)
13139 struct cmd_set_l2_encap_result *res = parsed_result;
13141 if (strcmp(res->l2_encap, "l2_encap") == 0)
13142 l2_encap_conf.select_vlan = 0;
13143 else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
13144 l2_encap_conf.select_vlan = 1;
13145 if (strcmp(res->ip_version, "ipv4") == 0)
13146 l2_encap_conf.select_ipv4 = 1;
13147 else if (strcmp(res->ip_version, "ipv6") == 0)
13148 l2_encap_conf.select_ipv4 = 0;
13151 if (l2_encap_conf.select_vlan)
13152 l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13153 rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
13154 RTE_ETHER_ADDR_LEN);
13155 rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13156 RTE_ETHER_ADDR_LEN);
13159 cmdline_parse_inst_t cmd_set_l2_encap = {
13160 .f = cmd_set_l2_encap_parsed,
13162 .help_str = "set l2_encap ip-version ipv4|ipv6"
13163 " eth-src <eth-src> eth-dst <eth-dst>",
13165 (void *)&cmd_set_l2_encap_set,
13166 (void *)&cmd_set_l2_encap_l2_encap,
13167 (void *)&cmd_set_l2_encap_ip_version,
13168 (void *)&cmd_set_l2_encap_ip_version_value,
13169 (void *)&cmd_set_l2_encap_eth_src,
13170 (void *)&cmd_set_l2_encap_eth_src_value,
13171 (void *)&cmd_set_l2_encap_eth_dst,
13172 (void *)&cmd_set_l2_encap_eth_dst_value,
13177 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
13178 .f = cmd_set_l2_encap_parsed,
13180 .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
13181 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
13183 (void *)&cmd_set_l2_encap_set,
13184 (void *)&cmd_set_l2_encap_l2_encap_with_vlan,
13185 (void *)&cmd_set_l2_encap_ip_version,
13186 (void *)&cmd_set_l2_encap_ip_version_value,
13187 (void *)&cmd_set_l2_encap_vlan,
13188 (void *)&cmd_set_l2_encap_vlan_value,
13189 (void *)&cmd_set_l2_encap_eth_src,
13190 (void *)&cmd_set_l2_encap_eth_src_value,
13191 (void *)&cmd_set_l2_encap_eth_dst,
13192 (void *)&cmd_set_l2_encap_eth_dst_value,
13197 /** Set L2 decapsulation details */
13198 struct cmd_set_l2_decap_result {
13199 cmdline_fixed_string_t set;
13200 cmdline_fixed_string_t l2_decap;
13201 cmdline_fixed_string_t pos_token;
13202 uint32_t vlan_present:1;
13205 cmdline_parse_token_string_t cmd_set_l2_decap_set =
13206 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
13207 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
13208 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
13210 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
13211 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
13212 "l2_decap-with-vlan");
13214 static void cmd_set_l2_decap_parsed(void *parsed_result,
13215 __rte_unused struct cmdline *cl,
13216 __rte_unused void *data)
13218 struct cmd_set_l2_decap_result *res = parsed_result;
13220 if (strcmp(res->l2_decap, "l2_decap") == 0)
13221 l2_decap_conf.select_vlan = 0;
13222 else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
13223 l2_decap_conf.select_vlan = 1;
13226 cmdline_parse_inst_t cmd_set_l2_decap = {
13227 .f = cmd_set_l2_decap_parsed,
13229 .help_str = "set l2_decap",
13231 (void *)&cmd_set_l2_decap_set,
13232 (void *)&cmd_set_l2_decap_l2_decap,
13237 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
13238 .f = cmd_set_l2_decap_parsed,
13240 .help_str = "set l2_decap-with-vlan",
13242 (void *)&cmd_set_l2_decap_set,
13243 (void *)&cmd_set_l2_decap_l2_decap_with_vlan,
13248 /** Set MPLSoGRE encapsulation details */
13249 struct cmd_set_mplsogre_encap_result {
13250 cmdline_fixed_string_t set;
13251 cmdline_fixed_string_t mplsogre;
13252 cmdline_fixed_string_t pos_token;
13253 cmdline_fixed_string_t ip_version;
13254 uint32_t vlan_present:1;
13256 cmdline_ipaddr_t ip_src;
13257 cmdline_ipaddr_t ip_dst;
13259 struct rte_ether_addr eth_src;
13260 struct rte_ether_addr eth_dst;
13263 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
13264 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
13266 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
13267 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
13269 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
13270 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13271 mplsogre, "mplsogre_encap-with-vlan");
13272 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
13273 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13274 pos_token, "ip-version");
13275 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
13276 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13277 ip_version, "ipv4#ipv6");
13278 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
13279 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13280 pos_token, "label");
13281 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
13282 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
13284 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
13285 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13286 pos_token, "ip-src");
13287 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
13288 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
13289 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
13290 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13291 pos_token, "ip-dst");
13292 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
13293 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
13294 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
13295 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13296 pos_token, "vlan-tci");
13297 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
13298 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
13300 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
13301 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13302 pos_token, "eth-src");
13303 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
13304 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13306 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
13307 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13308 pos_token, "eth-dst");
13309 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
13310 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13313 static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
13314 __rte_unused struct cmdline *cl,
13315 __rte_unused void *data)
13317 struct cmd_set_mplsogre_encap_result *res = parsed_result;
13319 uint32_t mplsogre_label;
13322 .mplsogre_label = rte_cpu_to_be_32(res->label<<12),
13325 if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
13326 mplsogre_encap_conf.select_vlan = 0;
13327 else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
13328 mplsogre_encap_conf.select_vlan = 1;
13329 if (strcmp(res->ip_version, "ipv4") == 0)
13330 mplsogre_encap_conf.select_ipv4 = 1;
13331 else if (strcmp(res->ip_version, "ipv6") == 0)
13332 mplsogre_encap_conf.select_ipv4 = 0;
13335 rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
13336 if (mplsogre_encap_conf.select_ipv4) {
13337 IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
13338 IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
13340 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
13341 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
13343 if (mplsogre_encap_conf.select_vlan)
13344 mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13345 rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
13346 RTE_ETHER_ADDR_LEN);
13347 rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13348 RTE_ETHER_ADDR_LEN);
13351 cmdline_parse_inst_t cmd_set_mplsogre_encap = {
13352 .f = cmd_set_mplsogre_encap_parsed,
13354 .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
13355 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
13356 " eth-dst <eth-dst>",
13358 (void *)&cmd_set_mplsogre_encap_set,
13359 (void *)&cmd_set_mplsogre_encap_mplsogre_encap,
13360 (void *)&cmd_set_mplsogre_encap_ip_version,
13361 (void *)&cmd_set_mplsogre_encap_ip_version_value,
13362 (void *)&cmd_set_mplsogre_encap_label,
13363 (void *)&cmd_set_mplsogre_encap_label_value,
13364 (void *)&cmd_set_mplsogre_encap_ip_src,
13365 (void *)&cmd_set_mplsogre_encap_ip_src_value,
13366 (void *)&cmd_set_mplsogre_encap_ip_dst,
13367 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
13368 (void *)&cmd_set_mplsogre_encap_eth_src,
13369 (void *)&cmd_set_mplsogre_encap_eth_src_value,
13370 (void *)&cmd_set_mplsogre_encap_eth_dst,
13371 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
13376 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
13377 .f = cmd_set_mplsogre_encap_parsed,
13379 .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
13380 " label <label> ip-src <ip-src> ip-dst <ip-dst>"
13381 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
13383 (void *)&cmd_set_mplsogre_encap_set,
13384 (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
13385 (void *)&cmd_set_mplsogre_encap_ip_version,
13386 (void *)&cmd_set_mplsogre_encap_ip_version_value,
13387 (void *)&cmd_set_mplsogre_encap_label,
13388 (void *)&cmd_set_mplsogre_encap_label_value,
13389 (void *)&cmd_set_mplsogre_encap_ip_src,
13390 (void *)&cmd_set_mplsogre_encap_ip_src_value,
13391 (void *)&cmd_set_mplsogre_encap_ip_dst,
13392 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
13393 (void *)&cmd_set_mplsogre_encap_vlan,
13394 (void *)&cmd_set_mplsogre_encap_vlan_value,
13395 (void *)&cmd_set_mplsogre_encap_eth_src,
13396 (void *)&cmd_set_mplsogre_encap_eth_src_value,
13397 (void *)&cmd_set_mplsogre_encap_eth_dst,
13398 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
13403 /** Set MPLSoGRE decapsulation details */
13404 struct cmd_set_mplsogre_decap_result {
13405 cmdline_fixed_string_t set;
13406 cmdline_fixed_string_t mplsogre;
13407 cmdline_fixed_string_t pos_token;
13408 cmdline_fixed_string_t ip_version;
13409 uint32_t vlan_present:1;
13412 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
13413 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
13415 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
13416 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
13418 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
13419 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13420 mplsogre, "mplsogre_decap-with-vlan");
13421 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
13422 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13423 pos_token, "ip-version");
13424 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
13425 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13426 ip_version, "ipv4#ipv6");
13428 static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
13429 __rte_unused struct cmdline *cl,
13430 __rte_unused void *data)
13432 struct cmd_set_mplsogre_decap_result *res = parsed_result;
13434 if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
13435 mplsogre_decap_conf.select_vlan = 0;
13436 else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
13437 mplsogre_decap_conf.select_vlan = 1;
13438 if (strcmp(res->ip_version, "ipv4") == 0)
13439 mplsogre_decap_conf.select_ipv4 = 1;
13440 else if (strcmp(res->ip_version, "ipv6") == 0)
13441 mplsogre_decap_conf.select_ipv4 = 0;
13444 cmdline_parse_inst_t cmd_set_mplsogre_decap = {
13445 .f = cmd_set_mplsogre_decap_parsed,
13447 .help_str = "set mplsogre_decap ip-version ipv4|ipv6",
13449 (void *)&cmd_set_mplsogre_decap_set,
13450 (void *)&cmd_set_mplsogre_decap_mplsogre_decap,
13451 (void *)&cmd_set_mplsogre_decap_ip_version,
13452 (void *)&cmd_set_mplsogre_decap_ip_version_value,
13457 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
13458 .f = cmd_set_mplsogre_decap_parsed,
13460 .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
13462 (void *)&cmd_set_mplsogre_decap_set,
13463 (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
13464 (void *)&cmd_set_mplsogre_decap_ip_version,
13465 (void *)&cmd_set_mplsogre_decap_ip_version_value,
13470 /** Set MPLSoUDP encapsulation details */
13471 struct cmd_set_mplsoudp_encap_result {
13472 cmdline_fixed_string_t set;
13473 cmdline_fixed_string_t mplsoudp;
13474 cmdline_fixed_string_t pos_token;
13475 cmdline_fixed_string_t ip_version;
13476 uint32_t vlan_present:1;
13480 cmdline_ipaddr_t ip_src;
13481 cmdline_ipaddr_t ip_dst;
13483 struct rte_ether_addr eth_src;
13484 struct rte_ether_addr eth_dst;
13487 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
13488 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
13490 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
13491 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
13493 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
13494 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13495 mplsoudp, "mplsoudp_encap-with-vlan");
13496 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
13497 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13498 pos_token, "ip-version");
13499 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
13500 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13501 ip_version, "ipv4#ipv6");
13502 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
13503 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13504 pos_token, "label");
13505 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
13506 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
13508 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
13509 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13510 pos_token, "udp-src");
13511 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
13512 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
13514 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
13515 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13516 pos_token, "udp-dst");
13517 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
13518 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
13520 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
13521 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13522 pos_token, "ip-src");
13523 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
13524 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
13525 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
13526 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13527 pos_token, "ip-dst");
13528 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
13529 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
13530 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
13531 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13532 pos_token, "vlan-tci");
13533 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
13534 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
13536 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
13537 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13538 pos_token, "eth-src");
13539 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
13540 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13542 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
13543 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13544 pos_token, "eth-dst");
13545 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
13546 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13549 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
13550 __rte_unused struct cmdline *cl,
13551 __rte_unused void *data)
13553 struct cmd_set_mplsoudp_encap_result *res = parsed_result;
13555 uint32_t mplsoudp_label;
13558 .mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
13561 if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
13562 mplsoudp_encap_conf.select_vlan = 0;
13563 else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
13564 mplsoudp_encap_conf.select_vlan = 1;
13565 if (strcmp(res->ip_version, "ipv4") == 0)
13566 mplsoudp_encap_conf.select_ipv4 = 1;
13567 else if (strcmp(res->ip_version, "ipv6") == 0)
13568 mplsoudp_encap_conf.select_ipv4 = 0;
13571 rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
13572 mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
13573 mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
13574 if (mplsoudp_encap_conf.select_ipv4) {
13575 IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
13576 IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
13578 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
13579 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
13581 if (mplsoudp_encap_conf.select_vlan)
13582 mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13583 rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
13584 RTE_ETHER_ADDR_LEN);
13585 rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13586 RTE_ETHER_ADDR_LEN);
13589 cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
13590 .f = cmd_set_mplsoudp_encap_parsed,
13592 .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
13593 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
13594 " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
13596 (void *)&cmd_set_mplsoudp_encap_set,
13597 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
13598 (void *)&cmd_set_mplsoudp_encap_ip_version,
13599 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
13600 (void *)&cmd_set_mplsoudp_encap_label,
13601 (void *)&cmd_set_mplsoudp_encap_label_value,
13602 (void *)&cmd_set_mplsoudp_encap_udp_src,
13603 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
13604 (void *)&cmd_set_mplsoudp_encap_udp_dst,
13605 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
13606 (void *)&cmd_set_mplsoudp_encap_ip_src,
13607 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
13608 (void *)&cmd_set_mplsoudp_encap_ip_dst,
13609 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
13610 (void *)&cmd_set_mplsoudp_encap_eth_src,
13611 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
13612 (void *)&cmd_set_mplsoudp_encap_eth_dst,
13613 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
13618 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
13619 .f = cmd_set_mplsoudp_encap_parsed,
13621 .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
13622 " label <label> udp-src <udp-src> udp-dst <udp-dst>"
13623 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
13624 " eth-src <eth-src> eth-dst <eth-dst>",
13626 (void *)&cmd_set_mplsoudp_encap_set,
13627 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
13628 (void *)&cmd_set_mplsoudp_encap_ip_version,
13629 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
13630 (void *)&cmd_set_mplsoudp_encap_label,
13631 (void *)&cmd_set_mplsoudp_encap_label_value,
13632 (void *)&cmd_set_mplsoudp_encap_udp_src,
13633 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
13634 (void *)&cmd_set_mplsoudp_encap_udp_dst,
13635 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
13636 (void *)&cmd_set_mplsoudp_encap_ip_src,
13637 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
13638 (void *)&cmd_set_mplsoudp_encap_ip_dst,
13639 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
13640 (void *)&cmd_set_mplsoudp_encap_vlan,
13641 (void *)&cmd_set_mplsoudp_encap_vlan_value,
13642 (void *)&cmd_set_mplsoudp_encap_eth_src,
13643 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
13644 (void *)&cmd_set_mplsoudp_encap_eth_dst,
13645 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
13650 /** Set MPLSoUDP decapsulation details */
13651 struct cmd_set_mplsoudp_decap_result {
13652 cmdline_fixed_string_t set;
13653 cmdline_fixed_string_t mplsoudp;
13654 cmdline_fixed_string_t pos_token;
13655 cmdline_fixed_string_t ip_version;
13656 uint32_t vlan_present:1;
13659 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
13660 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
13662 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
13663 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
13665 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
13666 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
13667 mplsoudp, "mplsoudp_decap-with-vlan");
13668 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
13669 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
13670 pos_token, "ip-version");
13671 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
13672 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
13673 ip_version, "ipv4#ipv6");
13675 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
13676 __rte_unused struct cmdline *cl,
13677 __rte_unused void *data)
13679 struct cmd_set_mplsoudp_decap_result *res = parsed_result;
13681 if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
13682 mplsoudp_decap_conf.select_vlan = 0;
13683 else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
13684 mplsoudp_decap_conf.select_vlan = 1;
13685 if (strcmp(res->ip_version, "ipv4") == 0)
13686 mplsoudp_decap_conf.select_ipv4 = 1;
13687 else if (strcmp(res->ip_version, "ipv6") == 0)
13688 mplsoudp_decap_conf.select_ipv4 = 0;
13691 cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
13692 .f = cmd_set_mplsoudp_decap_parsed,
13694 .help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
13696 (void *)&cmd_set_mplsoudp_decap_set,
13697 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
13698 (void *)&cmd_set_mplsoudp_decap_ip_version,
13699 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
13704 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
13705 .f = cmd_set_mplsoudp_decap_parsed,
13707 .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
13709 (void *)&cmd_set_mplsoudp_decap_set,
13710 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
13711 (void *)&cmd_set_mplsoudp_decap_ip_version,
13712 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
13717 /** Set connection tracking object common details */
13718 struct cmd_set_conntrack_common_result {
13719 cmdline_fixed_string_t set;
13720 cmdline_fixed_string_t conntrack;
13721 cmdline_fixed_string_t common;
13722 cmdline_fixed_string_t peer;
13723 cmdline_fixed_string_t is_orig;
13724 cmdline_fixed_string_t enable;
13725 cmdline_fixed_string_t live;
13726 cmdline_fixed_string_t sack;
13727 cmdline_fixed_string_t cack;
13728 cmdline_fixed_string_t last_dir;
13729 cmdline_fixed_string_t liberal;
13730 cmdline_fixed_string_t state;
13731 cmdline_fixed_string_t max_ack_win;
13732 cmdline_fixed_string_t retrans;
13733 cmdline_fixed_string_t last_win;
13734 cmdline_fixed_string_t last_seq;
13735 cmdline_fixed_string_t last_ack;
13736 cmdline_fixed_string_t last_end;
13737 cmdline_fixed_string_t last_index;
13740 uint16_t peer_port;
13741 uint32_t is_original;
13756 cmdline_parse_token_string_t cmd_set_conntrack_set =
13757 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13759 cmdline_parse_token_string_t cmd_set_conntrack_conntrack =
13760 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13761 conntrack, "conntrack");
13762 cmdline_parse_token_string_t cmd_set_conntrack_common_com =
13763 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13765 cmdline_parse_token_string_t cmd_set_conntrack_common_peer =
13766 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13768 cmdline_parse_token_num_t cmd_set_conntrack_common_peer_value =
13769 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13770 peer_port, RTE_UINT16);
13771 cmdline_parse_token_string_t cmd_set_conntrack_common_is_orig =
13772 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13773 is_orig, "is_orig");
13774 cmdline_parse_token_num_t cmd_set_conntrack_common_is_orig_value =
13775 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13776 is_original, RTE_UINT32);
13777 cmdline_parse_token_string_t cmd_set_conntrack_common_enable =
13778 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13780 cmdline_parse_token_num_t cmd_set_conntrack_common_enable_value =
13781 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13783 cmdline_parse_token_string_t cmd_set_conntrack_common_live =
13784 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13786 cmdline_parse_token_num_t cmd_set_conntrack_common_live_value =
13787 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13788 is_live, RTE_UINT32);
13789 cmdline_parse_token_string_t cmd_set_conntrack_common_sack =
13790 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13792 cmdline_parse_token_num_t cmd_set_conntrack_common_sack_value =
13793 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13794 s_ack, RTE_UINT32);
13795 cmdline_parse_token_string_t cmd_set_conntrack_common_cack =
13796 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13798 cmdline_parse_token_num_t cmd_set_conntrack_common_cack_value =
13799 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13800 c_ack, RTE_UINT32);
13801 cmdline_parse_token_string_t cmd_set_conntrack_common_last_dir =
13802 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13803 last_dir, "last_dir");
13804 cmdline_parse_token_num_t cmd_set_conntrack_common_last_dir_value =
13805 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13807 cmdline_parse_token_string_t cmd_set_conntrack_common_liberal =
13808 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13809 liberal, "liberal");
13810 cmdline_parse_token_num_t cmd_set_conntrack_common_liberal_value =
13811 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13813 cmdline_parse_token_string_t cmd_set_conntrack_common_state =
13814 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13816 cmdline_parse_token_num_t cmd_set_conntrack_common_state_value =
13817 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13819 cmdline_parse_token_string_t cmd_set_conntrack_common_max_ackwin =
13820 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13821 max_ack_win, "max_ack_win");
13822 cmdline_parse_token_num_t cmd_set_conntrack_common_max_ackwin_value =
13823 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13824 factor, RTE_UINT8);
13825 cmdline_parse_token_string_t cmd_set_conntrack_common_retrans =
13826 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13828 cmdline_parse_token_num_t cmd_set_conntrack_common_retrans_value =
13829 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13830 re_num, RTE_UINT8);
13831 cmdline_parse_token_string_t cmd_set_conntrack_common_last_win =
13832 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13833 last_win, "last_win");
13834 cmdline_parse_token_num_t cmd_set_conntrack_common_last_win_value =
13835 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13837 cmdline_parse_token_string_t cmd_set_conntrack_common_last_seq =
13838 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13839 last_seq, "last_seq");
13840 cmdline_parse_token_num_t cmd_set_conntrack_common_last_seq_value =
13841 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13843 cmdline_parse_token_string_t cmd_set_conntrack_common_last_ack =
13844 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13845 last_ack, "last_ack");
13846 cmdline_parse_token_num_t cmd_set_conntrack_common_last_ack_value =
13847 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13849 cmdline_parse_token_string_t cmd_set_conntrack_common_last_end =
13850 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13851 last_end, "last_end");
13852 cmdline_parse_token_num_t cmd_set_conntrack_common_last_end_value =
13853 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13855 cmdline_parse_token_string_t cmd_set_conntrack_common_last_index =
13856 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13857 last_index, "last_index");
13858 cmdline_parse_token_num_t cmd_set_conntrack_common_last_index_value =
13859 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13862 static void cmd_set_conntrack_common_parsed(void *parsed_result,
13863 __rte_unused struct cmdline *cl,
13864 __rte_unused void *data)
13866 struct cmd_set_conntrack_common_result *res = parsed_result;
13868 /* No need to swap to big endian. */
13869 conntrack_context.peer_port = res->peer_port;
13870 conntrack_context.is_original_dir = res->is_original;
13871 conntrack_context.enable = res->en;
13872 conntrack_context.live_connection = res->is_live;
13873 conntrack_context.selective_ack = res->s_ack;
13874 conntrack_context.challenge_ack_passed = res->c_ack;
13875 conntrack_context.last_direction = res->ld;
13876 conntrack_context.liberal_mode = res->lb;
13877 conntrack_context.state = (enum rte_flow_conntrack_state)res->stat;
13878 conntrack_context.max_ack_window = res->factor;
13879 conntrack_context.retransmission_limit = res->re_num;
13880 conntrack_context.last_window = res->lw;
13881 conntrack_context.last_index =
13882 (enum rte_flow_conntrack_tcp_last_index)res->li;
13883 conntrack_context.last_seq = res->ls;
13884 conntrack_context.last_ack = res->la;
13885 conntrack_context.last_end = res->le;
13888 cmdline_parse_inst_t cmd_set_conntrack_common = {
13889 .f = cmd_set_conntrack_common_parsed,
13891 .help_str = "set conntrack com peer <port_id> is_orig <dir> enable <en>"
13892 " live <ack_seen> sack <en> cack <passed> last_dir <dir>"
13893 " liberal <en> state <s> max_ack_win <factor> r_lim <num>"
13894 " last_win <win> last_seq <seq> last_ack <ack> last_end <end>"
13895 " last_index <flag>",
13897 (void *)&cmd_set_conntrack_set,
13898 (void *)&cmd_set_conntrack_conntrack,
13899 (void *)&cmd_set_conntrack_common_com,
13900 (void *)&cmd_set_conntrack_common_peer,
13901 (void *)&cmd_set_conntrack_common_peer_value,
13902 (void *)&cmd_set_conntrack_common_is_orig,
13903 (void *)&cmd_set_conntrack_common_is_orig_value,
13904 (void *)&cmd_set_conntrack_common_enable,
13905 (void *)&cmd_set_conntrack_common_enable_value,
13906 (void *)&cmd_set_conntrack_common_live,
13907 (void *)&cmd_set_conntrack_common_live_value,
13908 (void *)&cmd_set_conntrack_common_sack,
13909 (void *)&cmd_set_conntrack_common_sack_value,
13910 (void *)&cmd_set_conntrack_common_cack,
13911 (void *)&cmd_set_conntrack_common_cack_value,
13912 (void *)&cmd_set_conntrack_common_last_dir,
13913 (void *)&cmd_set_conntrack_common_last_dir_value,
13914 (void *)&cmd_set_conntrack_common_liberal,
13915 (void *)&cmd_set_conntrack_common_liberal_value,
13916 (void *)&cmd_set_conntrack_common_state,
13917 (void *)&cmd_set_conntrack_common_state_value,
13918 (void *)&cmd_set_conntrack_common_max_ackwin,
13919 (void *)&cmd_set_conntrack_common_max_ackwin_value,
13920 (void *)&cmd_set_conntrack_common_retrans,
13921 (void *)&cmd_set_conntrack_common_retrans_value,
13922 (void *)&cmd_set_conntrack_common_last_win,
13923 (void *)&cmd_set_conntrack_common_last_win_value,
13924 (void *)&cmd_set_conntrack_common_last_seq,
13925 (void *)&cmd_set_conntrack_common_last_seq_value,
13926 (void *)&cmd_set_conntrack_common_last_ack,
13927 (void *)&cmd_set_conntrack_common_last_ack_value,
13928 (void *)&cmd_set_conntrack_common_last_end,
13929 (void *)&cmd_set_conntrack_common_last_end_value,
13930 (void *)&cmd_set_conntrack_common_last_index,
13931 (void *)&cmd_set_conntrack_common_last_index_value,
13936 /** Set connection tracking object both directions' details */
13937 struct cmd_set_conntrack_dir_result {
13938 cmdline_fixed_string_t set;
13939 cmdline_fixed_string_t conntrack;
13940 cmdline_fixed_string_t dir;
13941 cmdline_fixed_string_t scale;
13942 cmdline_fixed_string_t fin;
13943 cmdline_fixed_string_t ack_seen;
13944 cmdline_fixed_string_t unack;
13945 cmdline_fixed_string_t sent_end;
13946 cmdline_fixed_string_t reply_end;
13947 cmdline_fixed_string_t max_win;
13948 cmdline_fixed_string_t max_ack;
13959 cmdline_parse_token_string_t cmd_set_conntrack_dir_set =
13960 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
13962 cmdline_parse_token_string_t cmd_set_conntrack_dir_conntrack =
13963 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
13964 conntrack, "conntrack");
13965 cmdline_parse_token_string_t cmd_set_conntrack_dir_dir =
13966 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
13968 cmdline_parse_token_string_t cmd_set_conntrack_dir_scale =
13969 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
13971 cmdline_parse_token_num_t cmd_set_conntrack_dir_scale_value =
13972 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
13973 factor, RTE_UINT32);
13974 cmdline_parse_token_string_t cmd_set_conntrack_dir_fin =
13975 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
13977 cmdline_parse_token_num_t cmd_set_conntrack_dir_fin_value =
13978 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
13980 cmdline_parse_token_string_t cmd_set_conntrack_dir_ack =
13981 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
13982 ack_seen, "acked");
13983 cmdline_parse_token_num_t cmd_set_conntrack_dir_ack_value =
13984 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
13986 cmdline_parse_token_string_t cmd_set_conntrack_dir_unack_data =
13987 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
13988 unack, "unack_data");
13989 cmdline_parse_token_num_t cmd_set_conntrack_dir_unack_data_value =
13990 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
13992 cmdline_parse_token_string_t cmd_set_conntrack_dir_sent_end =
13993 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
13994 sent_end, "sent_end");
13995 cmdline_parse_token_num_t cmd_set_conntrack_dir_sent_end_value =
13996 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
13998 cmdline_parse_token_string_t cmd_set_conntrack_dir_reply_end =
13999 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14000 reply_end, "reply_end");
14001 cmdline_parse_token_num_t cmd_set_conntrack_dir_reply_end_value =
14002 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14004 cmdline_parse_token_string_t cmd_set_conntrack_dir_max_win =
14005 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14006 max_win, "max_win");
14007 cmdline_parse_token_num_t cmd_set_conntrack_dir_max_win_value =
14008 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14010 cmdline_parse_token_string_t cmd_set_conntrack_dir_max_ack =
14011 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14012 max_ack, "max_ack");
14013 cmdline_parse_token_num_t cmd_set_conntrack_dir_max_ack_value =
14014 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14017 static void cmd_set_conntrack_dir_parsed(void *parsed_result,
14018 __rte_unused struct cmdline *cl,
14019 __rte_unused void *data)
14021 struct cmd_set_conntrack_dir_result *res = parsed_result;
14022 struct rte_flow_tcp_dir_param *dir = NULL;
14024 if (strcmp(res->dir, "orig") == 0)
14025 dir = &conntrack_context.original_dir;
14026 else if (strcmp(res->dir, "rply") == 0)
14027 dir = &conntrack_context.reply_dir;
14030 dir->scale = res->factor;
14031 dir->close_initiated = res->f;
14032 dir->last_ack_seen = res->as;
14033 dir->data_unacked = res->un;
14034 dir->sent_end = res->se;
14035 dir->reply_end = res->re;
14036 dir->max_ack = res->ma;
14037 dir->max_win = res->mw;
14040 cmdline_parse_inst_t cmd_set_conntrack_dir = {
14041 .f = cmd_set_conntrack_dir_parsed,
14043 .help_str = "set conntrack orig|rply scale <factor> fin <sent>"
14044 " acked <seen> unack_data <unack> sent_end <sent>"
14045 " reply_end <reply> max_win <win> max_ack <ack>",
14047 (void *)&cmd_set_conntrack_set,
14048 (void *)&cmd_set_conntrack_conntrack,
14049 (void *)&cmd_set_conntrack_dir_dir,
14050 (void *)&cmd_set_conntrack_dir_scale,
14051 (void *)&cmd_set_conntrack_dir_scale_value,
14052 (void *)&cmd_set_conntrack_dir_fin,
14053 (void *)&cmd_set_conntrack_dir_fin_value,
14054 (void *)&cmd_set_conntrack_dir_ack,
14055 (void *)&cmd_set_conntrack_dir_ack_value,
14056 (void *)&cmd_set_conntrack_dir_unack_data,
14057 (void *)&cmd_set_conntrack_dir_unack_data_value,
14058 (void *)&cmd_set_conntrack_dir_sent_end,
14059 (void *)&cmd_set_conntrack_dir_sent_end_value,
14060 (void *)&cmd_set_conntrack_dir_reply_end,
14061 (void *)&cmd_set_conntrack_dir_reply_end_value,
14062 (void *)&cmd_set_conntrack_dir_max_win,
14063 (void *)&cmd_set_conntrack_dir_max_win_value,
14064 (void *)&cmd_set_conntrack_dir_max_ack,
14065 (void *)&cmd_set_conntrack_dir_max_ack_value,
14070 /* Strict link priority scheduling mode setting */
14072 cmd_strict_link_prio_parsed(
14073 void *parsed_result,
14074 __rte_unused struct cmdline *cl,
14075 __rte_unused void *data)
14077 struct cmd_vf_tc_bw_result *res = parsed_result;
14078 int ret = -ENOTSUP;
14080 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14083 #ifdef RTE_NET_I40E
14084 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
14091 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
14094 printf("invalid port_id %d\n", res->port_id);
14097 printf("function not implemented\n");
14100 printf("programming error: (%s)\n", strerror(-ret));
14104 cmdline_parse_inst_t cmd_strict_link_prio = {
14105 .f = cmd_strict_link_prio_parsed,
14107 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
14109 (void *)&cmd_vf_tc_bw_set,
14110 (void *)&cmd_vf_tc_bw_tx,
14111 (void *)&cmd_vf_tc_bw_strict_link_prio,
14112 (void *)&cmd_vf_tc_bw_port_id,
14113 (void *)&cmd_vf_tc_bw_tc_map,
14118 /* Load dynamic device personalization*/
14119 struct cmd_ddp_add_result {
14120 cmdline_fixed_string_t ddp;
14121 cmdline_fixed_string_t add;
14126 cmdline_parse_token_string_t cmd_ddp_add_ddp =
14127 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
14128 cmdline_parse_token_string_t cmd_ddp_add_add =
14129 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
14130 cmdline_parse_token_num_t cmd_ddp_add_port_id =
14131 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id,
14133 cmdline_parse_token_string_t cmd_ddp_add_filepath =
14134 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
14137 cmd_ddp_add_parsed(
14138 void *parsed_result,
14139 __rte_unused struct cmdline *cl,
14140 __rte_unused void *data)
14142 struct cmd_ddp_add_result *res = parsed_result;
14148 int ret = -ENOTSUP;
14150 if (!all_ports_stopped()) {
14151 printf("Please stop all ports first\n");
14155 filepath = strdup(res->filepath);
14156 if (filepath == NULL) {
14157 printf("Failed to allocate memory\n");
14160 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
14162 buff = open_file(file_fld[0], &size);
14164 free((void *)filepath);
14168 #ifdef RTE_NET_I40E
14169 if (ret == -ENOTSUP)
14170 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14172 RTE_PMD_I40E_PKG_OP_WR_ADD);
14175 if (ret == -EEXIST)
14176 printf("Profile has already existed.\n");
14178 printf("Failed to load profile.\n");
14179 else if (file_num == 2)
14180 save_file(file_fld[1], buff, size);
14183 free((void *)filepath);
14186 cmdline_parse_inst_t cmd_ddp_add = {
14187 .f = cmd_ddp_add_parsed,
14189 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
14191 (void *)&cmd_ddp_add_ddp,
14192 (void *)&cmd_ddp_add_add,
14193 (void *)&cmd_ddp_add_port_id,
14194 (void *)&cmd_ddp_add_filepath,
14199 /* Delete dynamic device personalization*/
14200 struct cmd_ddp_del_result {
14201 cmdline_fixed_string_t ddp;
14202 cmdline_fixed_string_t del;
14207 cmdline_parse_token_string_t cmd_ddp_del_ddp =
14208 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
14209 cmdline_parse_token_string_t cmd_ddp_del_del =
14210 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
14211 cmdline_parse_token_num_t cmd_ddp_del_port_id =
14212 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, RTE_UINT16);
14213 cmdline_parse_token_string_t cmd_ddp_del_filepath =
14214 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
14217 cmd_ddp_del_parsed(
14218 void *parsed_result,
14219 __rte_unused struct cmdline *cl,
14220 __rte_unused void *data)
14222 struct cmd_ddp_del_result *res = parsed_result;
14225 int ret = -ENOTSUP;
14227 if (!all_ports_stopped()) {
14228 printf("Please stop all ports first\n");
14232 buff = open_file(res->filepath, &size);
14236 #ifdef RTE_NET_I40E
14237 if (ret == -ENOTSUP)
14238 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14240 RTE_PMD_I40E_PKG_OP_WR_DEL);
14243 if (ret == -EACCES)
14244 printf("Profile does not exist.\n");
14246 printf("Failed to delete profile.\n");
14251 cmdline_parse_inst_t cmd_ddp_del = {
14252 .f = cmd_ddp_del_parsed,
14254 .help_str = "ddp del <port_id> <backup_profile_path>",
14256 (void *)&cmd_ddp_del_ddp,
14257 (void *)&cmd_ddp_del_del,
14258 (void *)&cmd_ddp_del_port_id,
14259 (void *)&cmd_ddp_del_filepath,
14264 /* Get dynamic device personalization profile info */
14265 struct cmd_ddp_info_result {
14266 cmdline_fixed_string_t ddp;
14267 cmdline_fixed_string_t get;
14268 cmdline_fixed_string_t info;
14272 cmdline_parse_token_string_t cmd_ddp_info_ddp =
14273 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
14274 cmdline_parse_token_string_t cmd_ddp_info_get =
14275 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
14276 cmdline_parse_token_string_t cmd_ddp_info_info =
14277 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
14278 cmdline_parse_token_string_t cmd_ddp_info_filepath =
14279 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
14282 cmd_ddp_info_parsed(
14283 void *parsed_result,
14284 __rte_unused struct cmdline *cl,
14285 __rte_unused void *data)
14287 struct cmd_ddp_info_result *res = parsed_result;
14290 int ret = -ENOTSUP;
14291 #ifdef RTE_NET_I40E
14294 uint32_t buff_size = 0;
14295 struct rte_pmd_i40e_profile_info info;
14296 uint32_t dev_num = 0;
14297 struct rte_pmd_i40e_ddp_device_id *devs;
14298 uint32_t proto_num = 0;
14299 struct rte_pmd_i40e_proto_info *proto = NULL;
14300 uint32_t pctype_num = 0;
14301 struct rte_pmd_i40e_ptype_info *pctype;
14302 uint32_t ptype_num = 0;
14303 struct rte_pmd_i40e_ptype_info *ptype;
14308 pkg = open_file(res->filepath, &pkg_size);
14312 #ifdef RTE_NET_I40E
14313 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14314 (uint8_t *)&info, sizeof(info),
14315 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
14317 printf("Global Track id: 0x%x\n", info.track_id);
14318 printf("Global Version: %d.%d.%d.%d\n",
14319 info.version.major,
14320 info.version.minor,
14321 info.version.update,
14322 info.version.draft);
14323 printf("Global Package name: %s\n\n", info.name);
14326 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14327 (uint8_t *)&info, sizeof(info),
14328 RTE_PMD_I40E_PKG_INFO_HEADER);
14330 printf("i40e Profile Track id: 0x%x\n", info.track_id);
14331 printf("i40e Profile Version: %d.%d.%d.%d\n",
14332 info.version.major,
14333 info.version.minor,
14334 info.version.update,
14335 info.version.draft);
14336 printf("i40e Profile name: %s\n\n", info.name);
14339 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14340 (uint8_t *)&buff_size, sizeof(buff_size),
14341 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
14342 if (!ret && buff_size) {
14343 buff = (uint8_t *)malloc(buff_size);
14345 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14347 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
14349 printf("Package Notes:\n%s\n\n", buff);
14354 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14355 (uint8_t *)&dev_num, sizeof(dev_num),
14356 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
14357 if (!ret && dev_num) {
14358 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
14359 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
14361 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14362 (uint8_t *)devs, buff_size,
14363 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
14365 printf("List of supported devices:\n");
14366 for (i = 0; i < dev_num; i++) {
14367 printf(" %04X:%04X %04X:%04X\n",
14368 devs[i].vendor_dev_id >> 16,
14369 devs[i].vendor_dev_id & 0xFFFF,
14370 devs[i].sub_vendor_dev_id >> 16,
14371 devs[i].sub_vendor_dev_id & 0xFFFF);
14379 /* get information about protocols and packet types */
14380 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14381 (uint8_t *)&proto_num, sizeof(proto_num),
14382 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
14383 if (ret || !proto_num)
14384 goto no_print_return;
14386 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
14387 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
14389 goto no_print_return;
14391 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
14393 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
14395 printf("List of used protocols:\n");
14396 for (i = 0; i < proto_num; i++)
14397 printf(" %2u: %s\n", proto[i].proto_id,
14401 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14402 (uint8_t *)&pctype_num, sizeof(pctype_num),
14403 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
14404 if (ret || !pctype_num)
14405 goto no_print_pctypes;
14407 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14408 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14410 goto no_print_pctypes;
14412 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
14414 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
14417 goto no_print_pctypes;
14420 printf("List of defined packet classification types:\n");
14421 for (i = 0; i < pctype_num; i++) {
14422 printf(" %2u:", pctype[i].ptype_id);
14423 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14424 proto_id = pctype[i].protocols[j];
14425 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14426 for (n = 0; n < proto_num; n++) {
14427 if (proto[n].proto_id == proto_id) {
14428 printf(" %s", proto[n].name);
14441 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
14443 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
14444 if (ret || !ptype_num)
14445 goto no_print_return;
14447 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14448 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14450 goto no_print_return;
14452 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
14454 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
14457 goto no_print_return;
14459 printf("List of defined packet types:\n");
14460 for (i = 0; i < ptype_num; i++) {
14461 printf(" %2u:", ptype[i].ptype_id);
14462 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14463 proto_id = ptype[i].protocols[j];
14464 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14465 for (n = 0; n < proto_num; n++) {
14466 if (proto[n].proto_id == proto_id) {
14467 printf(" %s", proto[n].name);
14483 if (ret == -ENOTSUP)
14484 printf("Function not supported in PMD driver\n");
14488 cmdline_parse_inst_t cmd_ddp_get_info = {
14489 .f = cmd_ddp_info_parsed,
14491 .help_str = "ddp get info <profile_path>",
14493 (void *)&cmd_ddp_info_ddp,
14494 (void *)&cmd_ddp_info_get,
14495 (void *)&cmd_ddp_info_info,
14496 (void *)&cmd_ddp_info_filepath,
14501 /* Get dynamic device personalization profile info list*/
14502 #define PROFILE_INFO_SIZE 48
14503 #define MAX_PROFILE_NUM 16
14505 struct cmd_ddp_get_list_result {
14506 cmdline_fixed_string_t ddp;
14507 cmdline_fixed_string_t get;
14508 cmdline_fixed_string_t list;
14512 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
14513 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
14514 cmdline_parse_token_string_t cmd_ddp_get_list_get =
14515 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
14516 cmdline_parse_token_string_t cmd_ddp_get_list_list =
14517 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
14518 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
14519 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id,
14523 cmd_ddp_get_list_parsed(
14524 __rte_unused void *parsed_result,
14525 __rte_unused struct cmdline *cl,
14526 __rte_unused void *data)
14528 #ifdef RTE_NET_I40E
14529 struct cmd_ddp_get_list_result *res = parsed_result;
14530 struct rte_pmd_i40e_profile_list *p_list;
14531 struct rte_pmd_i40e_profile_info *p_info;
14536 int ret = -ENOTSUP;
14538 #ifdef RTE_NET_I40E
14539 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
14540 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
14542 printf("%s: Failed to malloc buffer\n", __func__);
14546 if (ret == -ENOTSUP)
14547 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
14548 (uint8_t *)p_list, size);
14551 p_num = p_list->p_count;
14552 printf("Profile number is: %d\n\n", p_num);
14554 for (i = 0; i < p_num; i++) {
14555 p_info = &p_list->p_info[i];
14556 printf("Profile %d:\n", i);
14557 printf("Track id: 0x%x\n", p_info->track_id);
14558 printf("Version: %d.%d.%d.%d\n",
14559 p_info->version.major,
14560 p_info->version.minor,
14561 p_info->version.update,
14562 p_info->version.draft);
14563 printf("Profile name: %s\n\n", p_info->name);
14571 printf("Failed to get ddp list\n");
14574 cmdline_parse_inst_t cmd_ddp_get_list = {
14575 .f = cmd_ddp_get_list_parsed,
14577 .help_str = "ddp get list <port_id>",
14579 (void *)&cmd_ddp_get_list_ddp,
14580 (void *)&cmd_ddp_get_list_get,
14581 (void *)&cmd_ddp_get_list_list,
14582 (void *)&cmd_ddp_get_list_port_id,
14587 /* Configure input set */
14588 struct cmd_cfg_input_set_result {
14589 cmdline_fixed_string_t port;
14590 cmdline_fixed_string_t cfg;
14592 cmdline_fixed_string_t pctype;
14594 cmdline_fixed_string_t inset_type;
14595 cmdline_fixed_string_t opt;
14596 cmdline_fixed_string_t field;
14601 cmd_cfg_input_set_parsed(
14602 __rte_unused void *parsed_result,
14603 __rte_unused struct cmdline *cl,
14604 __rte_unused void *data)
14606 #ifdef RTE_NET_I40E
14607 struct cmd_cfg_input_set_result *res = parsed_result;
14608 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
14609 struct rte_pmd_i40e_inset inset;
14611 int ret = -ENOTSUP;
14613 if (!all_ports_stopped()) {
14614 printf("Please stop all ports first\n");
14618 #ifdef RTE_NET_I40E
14619 if (!strcmp(res->inset_type, "hash_inset"))
14620 inset_type = INSET_HASH;
14621 else if (!strcmp(res->inset_type, "fdir_inset"))
14622 inset_type = INSET_FDIR;
14623 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
14624 inset_type = INSET_FDIR_FLX;
14625 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
14626 &inset, inset_type);
14628 printf("Failed to get input set.\n");
14632 if (!strcmp(res->opt, "get")) {
14633 ret = rte_pmd_i40e_inset_field_get(inset.inset,
14636 printf("Field index %d is enabled.\n", res->field_idx);
14638 printf("Field index %d is disabled.\n", res->field_idx);
14640 } else if (!strcmp(res->opt, "set"))
14641 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
14643 else if (!strcmp(res->opt, "clear"))
14644 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
14647 printf("Failed to configure input set field.\n");
14651 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
14652 &inset, inset_type);
14654 printf("Failed to set input set.\n");
14659 if (ret == -ENOTSUP)
14660 printf("Function not supported\n");
14663 cmdline_parse_token_string_t cmd_cfg_input_set_port =
14664 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14666 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
14667 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14669 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
14670 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14671 port_id, RTE_UINT16);
14672 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
14673 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14675 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
14676 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14677 pctype_id, RTE_UINT8);
14678 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
14679 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14681 "hash_inset#fdir_inset#fdir_flx_inset");
14682 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
14683 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14684 opt, "get#set#clear");
14685 cmdline_parse_token_string_t cmd_cfg_input_set_field =
14686 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14688 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
14689 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14690 field_idx, RTE_UINT8);
14692 cmdline_parse_inst_t cmd_cfg_input_set = {
14693 .f = cmd_cfg_input_set_parsed,
14695 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
14696 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
14698 (void *)&cmd_cfg_input_set_port,
14699 (void *)&cmd_cfg_input_set_cfg,
14700 (void *)&cmd_cfg_input_set_port_id,
14701 (void *)&cmd_cfg_input_set_pctype,
14702 (void *)&cmd_cfg_input_set_pctype_id,
14703 (void *)&cmd_cfg_input_set_inset_type,
14704 (void *)&cmd_cfg_input_set_opt,
14705 (void *)&cmd_cfg_input_set_field,
14706 (void *)&cmd_cfg_input_set_field_idx,
14711 /* Clear input set */
14712 struct cmd_clear_input_set_result {
14713 cmdline_fixed_string_t port;
14714 cmdline_fixed_string_t cfg;
14716 cmdline_fixed_string_t pctype;
14718 cmdline_fixed_string_t inset_type;
14719 cmdline_fixed_string_t clear;
14720 cmdline_fixed_string_t all;
14724 cmd_clear_input_set_parsed(
14725 __rte_unused void *parsed_result,
14726 __rte_unused struct cmdline *cl,
14727 __rte_unused void *data)
14729 #ifdef RTE_NET_I40E
14730 struct cmd_clear_input_set_result *res = parsed_result;
14731 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
14732 struct rte_pmd_i40e_inset inset;
14734 int ret = -ENOTSUP;
14736 if (!all_ports_stopped()) {
14737 printf("Please stop all ports first\n");
14741 #ifdef RTE_NET_I40E
14742 if (!strcmp(res->inset_type, "hash_inset"))
14743 inset_type = INSET_HASH;
14744 else if (!strcmp(res->inset_type, "fdir_inset"))
14745 inset_type = INSET_FDIR;
14746 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
14747 inset_type = INSET_FDIR_FLX;
14749 memset(&inset, 0, sizeof(inset));
14751 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
14752 &inset, inset_type);
14754 printf("Failed to clear input set.\n");
14760 if (ret == -ENOTSUP)
14761 printf("Function not supported\n");
14764 cmdline_parse_token_string_t cmd_clear_input_set_port =
14765 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14767 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
14768 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14770 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
14771 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
14772 port_id, RTE_UINT16);
14773 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
14774 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14776 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
14777 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
14778 pctype_id, RTE_UINT8);
14779 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
14780 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14782 "hash_inset#fdir_inset#fdir_flx_inset");
14783 cmdline_parse_token_string_t cmd_clear_input_set_clear =
14784 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14786 cmdline_parse_token_string_t cmd_clear_input_set_all =
14787 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14790 cmdline_parse_inst_t cmd_clear_input_set = {
14791 .f = cmd_clear_input_set_parsed,
14793 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
14794 "fdir_inset|fdir_flx_inset clear all",
14796 (void *)&cmd_clear_input_set_port,
14797 (void *)&cmd_clear_input_set_cfg,
14798 (void *)&cmd_clear_input_set_port_id,
14799 (void *)&cmd_clear_input_set_pctype,
14800 (void *)&cmd_clear_input_set_pctype_id,
14801 (void *)&cmd_clear_input_set_inset_type,
14802 (void *)&cmd_clear_input_set_clear,
14803 (void *)&cmd_clear_input_set_all,
14808 /* show vf stats */
14810 /* Common result structure for show vf stats */
14811 struct cmd_show_vf_stats_result {
14812 cmdline_fixed_string_t show;
14813 cmdline_fixed_string_t vf;
14814 cmdline_fixed_string_t stats;
14819 /* Common CLI fields show vf stats*/
14820 cmdline_parse_token_string_t cmd_show_vf_stats_show =
14821 TOKEN_STRING_INITIALIZER
14822 (struct cmd_show_vf_stats_result,
14824 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
14825 TOKEN_STRING_INITIALIZER
14826 (struct cmd_show_vf_stats_result,
14828 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
14829 TOKEN_STRING_INITIALIZER
14830 (struct cmd_show_vf_stats_result,
14832 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
14833 TOKEN_NUM_INITIALIZER
14834 (struct cmd_show_vf_stats_result,
14835 port_id, RTE_UINT16);
14836 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
14837 TOKEN_NUM_INITIALIZER
14838 (struct cmd_show_vf_stats_result,
14839 vf_id, RTE_UINT16);
14842 cmd_show_vf_stats_parsed(
14843 void *parsed_result,
14844 __rte_unused struct cmdline *cl,
14845 __rte_unused void *data)
14847 struct cmd_show_vf_stats_result *res = parsed_result;
14848 struct rte_eth_stats stats;
14849 int ret = -ENOTSUP;
14850 static const char *nic_stats_border = "########################";
14852 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14855 memset(&stats, 0, sizeof(stats));
14857 #ifdef RTE_NET_I40E
14858 if (ret == -ENOTSUP)
14859 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
14863 #ifdef RTE_NET_BNXT
14864 if (ret == -ENOTSUP)
14865 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
14874 printf("invalid vf_id %d\n", res->vf_id);
14877 printf("invalid port_id %d\n", res->port_id);
14880 printf("function not implemented\n");
14883 printf("programming error: (%s)\n", strerror(-ret));
14886 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
14887 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
14889 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
14891 stats.ipackets, stats.imissed, stats.ibytes);
14892 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
14893 printf(" RX-nombuf: %-10"PRIu64"\n",
14895 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
14897 stats.opackets, stats.oerrors, stats.obytes);
14899 printf(" %s############################%s\n",
14900 nic_stats_border, nic_stats_border);
14903 cmdline_parse_inst_t cmd_show_vf_stats = {
14904 .f = cmd_show_vf_stats_parsed,
14906 .help_str = "show vf stats <port_id> <vf_id>",
14908 (void *)&cmd_show_vf_stats_show,
14909 (void *)&cmd_show_vf_stats_vf,
14910 (void *)&cmd_show_vf_stats_stats,
14911 (void *)&cmd_show_vf_stats_port_id,
14912 (void *)&cmd_show_vf_stats_vf_id,
14917 /* clear vf stats */
14919 /* Common result structure for clear vf stats */
14920 struct cmd_clear_vf_stats_result {
14921 cmdline_fixed_string_t clear;
14922 cmdline_fixed_string_t vf;
14923 cmdline_fixed_string_t stats;
14928 /* Common CLI fields clear vf stats*/
14929 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
14930 TOKEN_STRING_INITIALIZER
14931 (struct cmd_clear_vf_stats_result,
14933 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
14934 TOKEN_STRING_INITIALIZER
14935 (struct cmd_clear_vf_stats_result,
14937 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
14938 TOKEN_STRING_INITIALIZER
14939 (struct cmd_clear_vf_stats_result,
14941 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
14942 TOKEN_NUM_INITIALIZER
14943 (struct cmd_clear_vf_stats_result,
14944 port_id, RTE_UINT16);
14945 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
14946 TOKEN_NUM_INITIALIZER
14947 (struct cmd_clear_vf_stats_result,
14948 vf_id, RTE_UINT16);
14951 cmd_clear_vf_stats_parsed(
14952 void *parsed_result,
14953 __rte_unused struct cmdline *cl,
14954 __rte_unused void *data)
14956 struct cmd_clear_vf_stats_result *res = parsed_result;
14957 int ret = -ENOTSUP;
14959 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14962 #ifdef RTE_NET_I40E
14963 if (ret == -ENOTSUP)
14964 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
14967 #ifdef RTE_NET_BNXT
14968 if (ret == -ENOTSUP)
14969 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
14977 printf("invalid vf_id %d\n", res->vf_id);
14980 printf("invalid port_id %d\n", res->port_id);
14983 printf("function not implemented\n");
14986 printf("programming error: (%s)\n", strerror(-ret));
14990 cmdline_parse_inst_t cmd_clear_vf_stats = {
14991 .f = cmd_clear_vf_stats_parsed,
14993 .help_str = "clear vf stats <port_id> <vf_id>",
14995 (void *)&cmd_clear_vf_stats_clear,
14996 (void *)&cmd_clear_vf_stats_vf,
14997 (void *)&cmd_clear_vf_stats_stats,
14998 (void *)&cmd_clear_vf_stats_port_id,
14999 (void *)&cmd_clear_vf_stats_vf_id,
15004 /* port config pctype mapping reset */
15006 /* Common result structure for port config pctype mapping reset */
15007 struct cmd_pctype_mapping_reset_result {
15008 cmdline_fixed_string_t port;
15009 cmdline_fixed_string_t config;
15011 cmdline_fixed_string_t pctype;
15012 cmdline_fixed_string_t mapping;
15013 cmdline_fixed_string_t reset;
15016 /* Common CLI fields for port config pctype mapping reset*/
15017 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
15018 TOKEN_STRING_INITIALIZER
15019 (struct cmd_pctype_mapping_reset_result,
15021 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
15022 TOKEN_STRING_INITIALIZER
15023 (struct cmd_pctype_mapping_reset_result,
15025 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
15026 TOKEN_NUM_INITIALIZER
15027 (struct cmd_pctype_mapping_reset_result,
15028 port_id, RTE_UINT16);
15029 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
15030 TOKEN_STRING_INITIALIZER
15031 (struct cmd_pctype_mapping_reset_result,
15033 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
15034 TOKEN_STRING_INITIALIZER
15035 (struct cmd_pctype_mapping_reset_result,
15036 mapping, "mapping");
15037 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
15038 TOKEN_STRING_INITIALIZER
15039 (struct cmd_pctype_mapping_reset_result,
15043 cmd_pctype_mapping_reset_parsed(
15044 void *parsed_result,
15045 __rte_unused struct cmdline *cl,
15046 __rte_unused void *data)
15048 struct cmd_pctype_mapping_reset_result *res = parsed_result;
15049 int ret = -ENOTSUP;
15051 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15054 #ifdef RTE_NET_I40E
15055 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
15062 printf("invalid port_id %d\n", res->port_id);
15065 printf("function not implemented\n");
15068 printf("programming error: (%s)\n", strerror(-ret));
15072 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
15073 .f = cmd_pctype_mapping_reset_parsed,
15075 .help_str = "port config <port_id> pctype mapping reset",
15077 (void *)&cmd_pctype_mapping_reset_port,
15078 (void *)&cmd_pctype_mapping_reset_config,
15079 (void *)&cmd_pctype_mapping_reset_port_id,
15080 (void *)&cmd_pctype_mapping_reset_pctype,
15081 (void *)&cmd_pctype_mapping_reset_mapping,
15082 (void *)&cmd_pctype_mapping_reset_reset,
15087 /* show port pctype mapping */
15089 /* Common result structure for show port pctype mapping */
15090 struct cmd_pctype_mapping_get_result {
15091 cmdline_fixed_string_t show;
15092 cmdline_fixed_string_t port;
15094 cmdline_fixed_string_t pctype;
15095 cmdline_fixed_string_t mapping;
15098 /* Common CLI fields for pctype mapping get */
15099 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
15100 TOKEN_STRING_INITIALIZER
15101 (struct cmd_pctype_mapping_get_result,
15103 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
15104 TOKEN_STRING_INITIALIZER
15105 (struct cmd_pctype_mapping_get_result,
15107 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
15108 TOKEN_NUM_INITIALIZER
15109 (struct cmd_pctype_mapping_get_result,
15110 port_id, RTE_UINT16);
15111 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
15112 TOKEN_STRING_INITIALIZER
15113 (struct cmd_pctype_mapping_get_result,
15115 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
15116 TOKEN_STRING_INITIALIZER
15117 (struct cmd_pctype_mapping_get_result,
15118 mapping, "mapping");
15121 cmd_pctype_mapping_get_parsed(
15122 void *parsed_result,
15123 __rte_unused struct cmdline *cl,
15124 __rte_unused void *data)
15126 struct cmd_pctype_mapping_get_result *res = parsed_result;
15127 int ret = -ENOTSUP;
15128 #ifdef RTE_NET_I40E
15129 struct rte_pmd_i40e_flow_type_mapping
15130 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
15131 int i, j, first_pctype;
15134 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15137 #ifdef RTE_NET_I40E
15138 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
15145 printf("invalid port_id %d\n", res->port_id);
15148 printf("function not implemented\n");
15151 printf("programming error: (%s)\n", strerror(-ret));
15155 #ifdef RTE_NET_I40E
15156 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
15157 if (mapping[i].pctype != 0ULL) {
15160 printf("pctype: ");
15161 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
15162 if (mapping[i].pctype & (1ULL << j)) {
15163 printf(first_pctype ?
15164 "%02d" : ",%02d", j);
15168 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
15174 cmdline_parse_inst_t cmd_pctype_mapping_get = {
15175 .f = cmd_pctype_mapping_get_parsed,
15177 .help_str = "show port <port_id> pctype mapping",
15179 (void *)&cmd_pctype_mapping_get_show,
15180 (void *)&cmd_pctype_mapping_get_port,
15181 (void *)&cmd_pctype_mapping_get_port_id,
15182 (void *)&cmd_pctype_mapping_get_pctype,
15183 (void *)&cmd_pctype_mapping_get_mapping,
15188 /* port config pctype mapping update */
15190 /* Common result structure for port config pctype mapping update */
15191 struct cmd_pctype_mapping_update_result {
15192 cmdline_fixed_string_t port;
15193 cmdline_fixed_string_t config;
15195 cmdline_fixed_string_t pctype;
15196 cmdline_fixed_string_t mapping;
15197 cmdline_fixed_string_t update;
15198 cmdline_fixed_string_t pctype_list;
15199 uint16_t flow_type;
15202 /* Common CLI fields for pctype mapping update*/
15203 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
15204 TOKEN_STRING_INITIALIZER
15205 (struct cmd_pctype_mapping_update_result,
15207 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
15208 TOKEN_STRING_INITIALIZER
15209 (struct cmd_pctype_mapping_update_result,
15211 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
15212 TOKEN_NUM_INITIALIZER
15213 (struct cmd_pctype_mapping_update_result,
15214 port_id, RTE_UINT16);
15215 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
15216 TOKEN_STRING_INITIALIZER
15217 (struct cmd_pctype_mapping_update_result,
15219 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
15220 TOKEN_STRING_INITIALIZER
15221 (struct cmd_pctype_mapping_update_result,
15222 mapping, "mapping");
15223 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
15224 TOKEN_STRING_INITIALIZER
15225 (struct cmd_pctype_mapping_update_result,
15227 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
15228 TOKEN_STRING_INITIALIZER
15229 (struct cmd_pctype_mapping_update_result,
15230 pctype_list, NULL);
15231 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
15232 TOKEN_NUM_INITIALIZER
15233 (struct cmd_pctype_mapping_update_result,
15234 flow_type, RTE_UINT16);
15237 cmd_pctype_mapping_update_parsed(
15238 void *parsed_result,
15239 __rte_unused struct cmdline *cl,
15240 __rte_unused void *data)
15242 struct cmd_pctype_mapping_update_result *res = parsed_result;
15243 int ret = -ENOTSUP;
15244 #ifdef RTE_NET_I40E
15245 struct rte_pmd_i40e_flow_type_mapping mapping;
15247 unsigned int nb_item;
15248 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
15251 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15254 #ifdef RTE_NET_I40E
15255 nb_item = parse_item_list(res->pctype_list, "pctypes",
15256 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
15257 mapping.flow_type = res->flow_type;
15258 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
15259 mapping.pctype |= (1ULL << pctype_list[i]);
15260 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
15270 printf("invalid pctype or flow type\n");
15273 printf("invalid port_id %d\n", res->port_id);
15276 printf("function not implemented\n");
15279 printf("programming error: (%s)\n", strerror(-ret));
15283 cmdline_parse_inst_t cmd_pctype_mapping_update = {
15284 .f = cmd_pctype_mapping_update_parsed,
15286 .help_str = "port config <port_id> pctype mapping update"
15287 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
15289 (void *)&cmd_pctype_mapping_update_port,
15290 (void *)&cmd_pctype_mapping_update_config,
15291 (void *)&cmd_pctype_mapping_update_port_id,
15292 (void *)&cmd_pctype_mapping_update_pctype,
15293 (void *)&cmd_pctype_mapping_update_mapping,
15294 (void *)&cmd_pctype_mapping_update_update,
15295 (void *)&cmd_pctype_mapping_update_pc_type,
15296 (void *)&cmd_pctype_mapping_update_flow_type,
15301 /* ptype mapping get */
15303 /* Common result structure for ptype mapping get */
15304 struct cmd_ptype_mapping_get_result {
15305 cmdline_fixed_string_t ptype;
15306 cmdline_fixed_string_t mapping;
15307 cmdline_fixed_string_t get;
15309 uint8_t valid_only;
15312 /* Common CLI fields for ptype mapping get */
15313 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
15314 TOKEN_STRING_INITIALIZER
15315 (struct cmd_ptype_mapping_get_result,
15317 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
15318 TOKEN_STRING_INITIALIZER
15319 (struct cmd_ptype_mapping_get_result,
15320 mapping, "mapping");
15321 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
15322 TOKEN_STRING_INITIALIZER
15323 (struct cmd_ptype_mapping_get_result,
15325 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
15326 TOKEN_NUM_INITIALIZER
15327 (struct cmd_ptype_mapping_get_result,
15328 port_id, RTE_UINT16);
15329 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
15330 TOKEN_NUM_INITIALIZER
15331 (struct cmd_ptype_mapping_get_result,
15332 valid_only, RTE_UINT8);
15335 cmd_ptype_mapping_get_parsed(
15336 void *parsed_result,
15337 __rte_unused struct cmdline *cl,
15338 __rte_unused void *data)
15340 struct cmd_ptype_mapping_get_result *res = parsed_result;
15341 int ret = -ENOTSUP;
15342 #ifdef RTE_NET_I40E
15343 int max_ptype_num = 256;
15344 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
15349 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15352 #ifdef RTE_NET_I40E
15353 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
15364 printf("invalid port_id %d\n", res->port_id);
15367 printf("function not implemented\n");
15370 printf("programming error: (%s)\n", strerror(-ret));
15373 #ifdef RTE_NET_I40E
15375 for (i = 0; i < count; i++)
15376 printf("%3d\t0x%08x\n",
15377 mapping[i].hw_ptype, mapping[i].sw_ptype);
15382 cmdline_parse_inst_t cmd_ptype_mapping_get = {
15383 .f = cmd_ptype_mapping_get_parsed,
15385 .help_str = "ptype mapping get <port_id> <valid_only>",
15387 (void *)&cmd_ptype_mapping_get_ptype,
15388 (void *)&cmd_ptype_mapping_get_mapping,
15389 (void *)&cmd_ptype_mapping_get_get,
15390 (void *)&cmd_ptype_mapping_get_port_id,
15391 (void *)&cmd_ptype_mapping_get_valid_only,
15396 /* ptype mapping replace */
15398 /* Common result structure for ptype mapping replace */
15399 struct cmd_ptype_mapping_replace_result {
15400 cmdline_fixed_string_t ptype;
15401 cmdline_fixed_string_t mapping;
15402 cmdline_fixed_string_t replace;
15409 /* Common CLI fields for ptype mapping replace */
15410 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
15411 TOKEN_STRING_INITIALIZER
15412 (struct cmd_ptype_mapping_replace_result,
15414 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
15415 TOKEN_STRING_INITIALIZER
15416 (struct cmd_ptype_mapping_replace_result,
15417 mapping, "mapping");
15418 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
15419 TOKEN_STRING_INITIALIZER
15420 (struct cmd_ptype_mapping_replace_result,
15421 replace, "replace");
15422 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
15423 TOKEN_NUM_INITIALIZER
15424 (struct cmd_ptype_mapping_replace_result,
15425 port_id, RTE_UINT16);
15426 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
15427 TOKEN_NUM_INITIALIZER
15428 (struct cmd_ptype_mapping_replace_result,
15429 target, RTE_UINT32);
15430 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
15431 TOKEN_NUM_INITIALIZER
15432 (struct cmd_ptype_mapping_replace_result,
15434 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
15435 TOKEN_NUM_INITIALIZER
15436 (struct cmd_ptype_mapping_replace_result,
15437 pkt_type, RTE_UINT32);
15440 cmd_ptype_mapping_replace_parsed(
15441 void *parsed_result,
15442 __rte_unused struct cmdline *cl,
15443 __rte_unused void *data)
15445 struct cmd_ptype_mapping_replace_result *res = parsed_result;
15446 int ret = -ENOTSUP;
15448 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15451 #ifdef RTE_NET_I40E
15452 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
15462 printf("invalid ptype 0x%8x or 0x%8x\n",
15463 res->target, res->pkt_type);
15466 printf("invalid port_id %d\n", res->port_id);
15469 printf("function not implemented\n");
15472 printf("programming error: (%s)\n", strerror(-ret));
15476 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
15477 .f = cmd_ptype_mapping_replace_parsed,
15480 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
15482 (void *)&cmd_ptype_mapping_replace_ptype,
15483 (void *)&cmd_ptype_mapping_replace_mapping,
15484 (void *)&cmd_ptype_mapping_replace_replace,
15485 (void *)&cmd_ptype_mapping_replace_port_id,
15486 (void *)&cmd_ptype_mapping_replace_target,
15487 (void *)&cmd_ptype_mapping_replace_mask,
15488 (void *)&cmd_ptype_mapping_replace_pkt_type,
15493 /* ptype mapping reset */
15495 /* Common result structure for ptype mapping reset */
15496 struct cmd_ptype_mapping_reset_result {
15497 cmdline_fixed_string_t ptype;
15498 cmdline_fixed_string_t mapping;
15499 cmdline_fixed_string_t reset;
15503 /* Common CLI fields for ptype mapping reset*/
15504 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
15505 TOKEN_STRING_INITIALIZER
15506 (struct cmd_ptype_mapping_reset_result,
15508 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
15509 TOKEN_STRING_INITIALIZER
15510 (struct cmd_ptype_mapping_reset_result,
15511 mapping, "mapping");
15512 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
15513 TOKEN_STRING_INITIALIZER
15514 (struct cmd_ptype_mapping_reset_result,
15516 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
15517 TOKEN_NUM_INITIALIZER
15518 (struct cmd_ptype_mapping_reset_result,
15519 port_id, RTE_UINT16);
15522 cmd_ptype_mapping_reset_parsed(
15523 void *parsed_result,
15524 __rte_unused struct cmdline *cl,
15525 __rte_unused void *data)
15527 struct cmd_ptype_mapping_reset_result *res = parsed_result;
15528 int ret = -ENOTSUP;
15530 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15533 #ifdef RTE_NET_I40E
15534 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
15541 printf("invalid port_id %d\n", res->port_id);
15544 printf("function not implemented\n");
15547 printf("programming error: (%s)\n", strerror(-ret));
15551 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
15552 .f = cmd_ptype_mapping_reset_parsed,
15554 .help_str = "ptype mapping reset <port_id>",
15556 (void *)&cmd_ptype_mapping_reset_ptype,
15557 (void *)&cmd_ptype_mapping_reset_mapping,
15558 (void *)&cmd_ptype_mapping_reset_reset,
15559 (void *)&cmd_ptype_mapping_reset_port_id,
15564 /* ptype mapping update */
15566 /* Common result structure for ptype mapping update */
15567 struct cmd_ptype_mapping_update_result {
15568 cmdline_fixed_string_t ptype;
15569 cmdline_fixed_string_t mapping;
15570 cmdline_fixed_string_t reset;
15576 /* Common CLI fields for ptype mapping update*/
15577 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
15578 TOKEN_STRING_INITIALIZER
15579 (struct cmd_ptype_mapping_update_result,
15581 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
15582 TOKEN_STRING_INITIALIZER
15583 (struct cmd_ptype_mapping_update_result,
15584 mapping, "mapping");
15585 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
15586 TOKEN_STRING_INITIALIZER
15587 (struct cmd_ptype_mapping_update_result,
15589 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
15590 TOKEN_NUM_INITIALIZER
15591 (struct cmd_ptype_mapping_update_result,
15592 port_id, RTE_UINT16);
15593 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
15594 TOKEN_NUM_INITIALIZER
15595 (struct cmd_ptype_mapping_update_result,
15596 hw_ptype, RTE_UINT8);
15597 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
15598 TOKEN_NUM_INITIALIZER
15599 (struct cmd_ptype_mapping_update_result,
15600 sw_ptype, RTE_UINT32);
15603 cmd_ptype_mapping_update_parsed(
15604 void *parsed_result,
15605 __rte_unused struct cmdline *cl,
15606 __rte_unused void *data)
15608 struct cmd_ptype_mapping_update_result *res = parsed_result;
15609 int ret = -ENOTSUP;
15610 #ifdef RTE_NET_I40E
15611 struct rte_pmd_i40e_ptype_mapping mapping;
15613 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15616 #ifdef RTE_NET_I40E
15617 mapping.hw_ptype = res->hw_ptype;
15618 mapping.sw_ptype = res->sw_ptype;
15619 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
15629 printf("invalid ptype 0x%8x\n", res->sw_ptype);
15632 printf("invalid port_id %d\n", res->port_id);
15635 printf("function not implemented\n");
15638 printf("programming error: (%s)\n", strerror(-ret));
15642 cmdline_parse_inst_t cmd_ptype_mapping_update = {
15643 .f = cmd_ptype_mapping_update_parsed,
15645 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
15647 (void *)&cmd_ptype_mapping_update_ptype,
15648 (void *)&cmd_ptype_mapping_update_mapping,
15649 (void *)&cmd_ptype_mapping_update_update,
15650 (void *)&cmd_ptype_mapping_update_port_id,
15651 (void *)&cmd_ptype_mapping_update_hw_ptype,
15652 (void *)&cmd_ptype_mapping_update_sw_ptype,
15657 /* Common result structure for file commands */
15658 struct cmd_cmdfile_result {
15659 cmdline_fixed_string_t load;
15660 cmdline_fixed_string_t filename;
15663 /* Common CLI fields for file commands */
15664 cmdline_parse_token_string_t cmd_load_cmdfile =
15665 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
15666 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
15667 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
15670 cmd_load_from_file_parsed(
15671 void *parsed_result,
15672 __rte_unused struct cmdline *cl,
15673 __rte_unused void *data)
15675 struct cmd_cmdfile_result *res = parsed_result;
15677 cmdline_read_from_file(res->filename);
15680 cmdline_parse_inst_t cmd_load_from_file = {
15681 .f = cmd_load_from_file_parsed,
15683 .help_str = "load <filename>",
15685 (void *)&cmd_load_cmdfile,
15686 (void *)&cmd_load_cmdfile_filename,
15691 /* Get Rx offloads capabilities */
15692 struct cmd_rx_offload_get_capa_result {
15693 cmdline_fixed_string_t show;
15694 cmdline_fixed_string_t port;
15696 cmdline_fixed_string_t rx_offload;
15697 cmdline_fixed_string_t capabilities;
15700 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
15701 TOKEN_STRING_INITIALIZER
15702 (struct cmd_rx_offload_get_capa_result,
15704 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
15705 TOKEN_STRING_INITIALIZER
15706 (struct cmd_rx_offload_get_capa_result,
15708 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
15709 TOKEN_NUM_INITIALIZER
15710 (struct cmd_rx_offload_get_capa_result,
15711 port_id, RTE_UINT16);
15712 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
15713 TOKEN_STRING_INITIALIZER
15714 (struct cmd_rx_offload_get_capa_result,
15715 rx_offload, "rx_offload");
15716 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
15717 TOKEN_STRING_INITIALIZER
15718 (struct cmd_rx_offload_get_capa_result,
15719 capabilities, "capabilities");
15722 print_rx_offloads(uint64_t offloads)
15724 uint64_t single_offload;
15732 begin = __builtin_ctzll(offloads);
15733 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
15735 single_offload = 1ULL << begin;
15736 for (bit = begin; bit < end; bit++) {
15737 if (offloads & single_offload)
15739 rte_eth_dev_rx_offload_name(single_offload));
15740 single_offload <<= 1;
15745 cmd_rx_offload_get_capa_parsed(
15746 void *parsed_result,
15747 __rte_unused struct cmdline *cl,
15748 __rte_unused void *data)
15750 struct cmd_rx_offload_get_capa_result *res = parsed_result;
15751 struct rte_eth_dev_info dev_info;
15752 portid_t port_id = res->port_id;
15753 uint64_t queue_offloads;
15754 uint64_t port_offloads;
15757 ret = eth_dev_info_get_print_err(port_id, &dev_info);
15761 queue_offloads = dev_info.rx_queue_offload_capa;
15762 port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
15764 printf("Rx Offloading Capabilities of port %d :\n", port_id);
15765 printf(" Per Queue :");
15766 print_rx_offloads(queue_offloads);
15769 printf(" Per Port :");
15770 print_rx_offloads(port_offloads);
15774 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
15775 .f = cmd_rx_offload_get_capa_parsed,
15777 .help_str = "show port <port_id> rx_offload capabilities",
15779 (void *)&cmd_rx_offload_get_capa_show,
15780 (void *)&cmd_rx_offload_get_capa_port,
15781 (void *)&cmd_rx_offload_get_capa_port_id,
15782 (void *)&cmd_rx_offload_get_capa_rx_offload,
15783 (void *)&cmd_rx_offload_get_capa_capabilities,
15788 /* Get Rx offloads configuration */
15789 struct cmd_rx_offload_get_configuration_result {
15790 cmdline_fixed_string_t show;
15791 cmdline_fixed_string_t port;
15793 cmdline_fixed_string_t rx_offload;
15794 cmdline_fixed_string_t configuration;
15797 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
15798 TOKEN_STRING_INITIALIZER
15799 (struct cmd_rx_offload_get_configuration_result,
15801 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
15802 TOKEN_STRING_INITIALIZER
15803 (struct cmd_rx_offload_get_configuration_result,
15805 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
15806 TOKEN_NUM_INITIALIZER
15807 (struct cmd_rx_offload_get_configuration_result,
15808 port_id, RTE_UINT16);
15809 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
15810 TOKEN_STRING_INITIALIZER
15811 (struct cmd_rx_offload_get_configuration_result,
15812 rx_offload, "rx_offload");
15813 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
15814 TOKEN_STRING_INITIALIZER
15815 (struct cmd_rx_offload_get_configuration_result,
15816 configuration, "configuration");
15819 cmd_rx_offload_get_configuration_parsed(
15820 void *parsed_result,
15821 __rte_unused struct cmdline *cl,
15822 __rte_unused void *data)
15824 struct cmd_rx_offload_get_configuration_result *res = parsed_result;
15825 struct rte_eth_dev_info dev_info;
15826 portid_t port_id = res->port_id;
15827 struct rte_port *port = &ports[port_id];
15828 uint64_t port_offloads;
15829 uint64_t queue_offloads;
15830 uint16_t nb_rx_queues;
15834 printf("Rx Offloading Configuration of port %d :\n", port_id);
15836 port_offloads = port->dev_conf.rxmode.offloads;
15838 print_rx_offloads(port_offloads);
15841 ret = eth_dev_info_get_print_err(port_id, &dev_info);
15845 nb_rx_queues = dev_info.nb_rx_queues;
15846 for (q = 0; q < nb_rx_queues; q++) {
15847 queue_offloads = port->rx_conf[q].offloads;
15848 printf(" Queue[%2d] :", q);
15849 print_rx_offloads(queue_offloads);
15855 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
15856 .f = cmd_rx_offload_get_configuration_parsed,
15858 .help_str = "show port <port_id> rx_offload configuration",
15860 (void *)&cmd_rx_offload_get_configuration_show,
15861 (void *)&cmd_rx_offload_get_configuration_port,
15862 (void *)&cmd_rx_offload_get_configuration_port_id,
15863 (void *)&cmd_rx_offload_get_configuration_rx_offload,
15864 (void *)&cmd_rx_offload_get_configuration_configuration,
15869 /* Enable/Disable a per port offloading */
15870 struct cmd_config_per_port_rx_offload_result {
15871 cmdline_fixed_string_t port;
15872 cmdline_fixed_string_t config;
15874 cmdline_fixed_string_t rx_offload;
15875 cmdline_fixed_string_t offload;
15876 cmdline_fixed_string_t on_off;
15879 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
15880 TOKEN_STRING_INITIALIZER
15881 (struct cmd_config_per_port_rx_offload_result,
15883 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
15884 TOKEN_STRING_INITIALIZER
15885 (struct cmd_config_per_port_rx_offload_result,
15887 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
15888 TOKEN_NUM_INITIALIZER
15889 (struct cmd_config_per_port_rx_offload_result,
15890 port_id, RTE_UINT16);
15891 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
15892 TOKEN_STRING_INITIALIZER
15893 (struct cmd_config_per_port_rx_offload_result,
15894 rx_offload, "rx_offload");
15895 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
15896 TOKEN_STRING_INITIALIZER
15897 (struct cmd_config_per_port_rx_offload_result,
15898 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
15899 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
15900 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
15901 "scatter#buffer_split#timestamp#security#"
15902 "keep_crc#rss_hash");
15903 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
15904 TOKEN_STRING_INITIALIZER
15905 (struct cmd_config_per_port_rx_offload_result,
15909 search_rx_offload(const char *name)
15911 uint64_t single_offload;
15912 const char *single_name;
15916 single_offload = 1;
15917 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
15918 single_name = rte_eth_dev_rx_offload_name(single_offload);
15919 if (!strcasecmp(single_name, name)) {
15923 single_offload <<= 1;
15927 return single_offload;
15933 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
15934 __rte_unused struct cmdline *cl,
15935 __rte_unused void *data)
15937 struct cmd_config_per_port_rx_offload_result *res = parsed_result;
15938 portid_t port_id = res->port_id;
15939 struct rte_eth_dev_info dev_info;
15940 struct rte_port *port = &ports[port_id];
15941 uint64_t single_offload;
15942 uint16_t nb_rx_queues;
15946 if (port->port_status != RTE_PORT_STOPPED) {
15947 printf("Error: Can't config offload when Port %d "
15948 "is not stopped\n", port_id);
15952 single_offload = search_rx_offload(res->offload);
15953 if (single_offload == 0) {
15954 printf("Unknown offload name: %s\n", res->offload);
15958 ret = eth_dev_info_get_print_err(port_id, &dev_info);
15962 nb_rx_queues = dev_info.nb_rx_queues;
15963 if (!strcmp(res->on_off, "on")) {
15964 port->dev_conf.rxmode.offloads |= single_offload;
15965 for (q = 0; q < nb_rx_queues; q++)
15966 port->rx_conf[q].offloads |= single_offload;
15968 port->dev_conf.rxmode.offloads &= ~single_offload;
15969 for (q = 0; q < nb_rx_queues; q++)
15970 port->rx_conf[q].offloads &= ~single_offload;
15973 cmd_reconfig_device_queue(port_id, 1, 1);
15976 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
15977 .f = cmd_config_per_port_rx_offload_parsed,
15979 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
15980 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
15981 "macsec_strip|header_split|vlan_filter|vlan_extend|"
15982 "jumbo_frame|scatter|buffer_split|timestamp|security|"
15983 "keep_crc|rss_hash on|off",
15985 (void *)&cmd_config_per_port_rx_offload_result_port,
15986 (void *)&cmd_config_per_port_rx_offload_result_config,
15987 (void *)&cmd_config_per_port_rx_offload_result_port_id,
15988 (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
15989 (void *)&cmd_config_per_port_rx_offload_result_offload,
15990 (void *)&cmd_config_per_port_rx_offload_result_on_off,
15995 /* Enable/Disable a per queue offloading */
15996 struct cmd_config_per_queue_rx_offload_result {
15997 cmdline_fixed_string_t port;
15999 cmdline_fixed_string_t rxq;
16001 cmdline_fixed_string_t rx_offload;
16002 cmdline_fixed_string_t offload;
16003 cmdline_fixed_string_t on_off;
16006 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
16007 TOKEN_STRING_INITIALIZER
16008 (struct cmd_config_per_queue_rx_offload_result,
16010 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
16011 TOKEN_NUM_INITIALIZER
16012 (struct cmd_config_per_queue_rx_offload_result,
16013 port_id, RTE_UINT16);
16014 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
16015 TOKEN_STRING_INITIALIZER
16016 (struct cmd_config_per_queue_rx_offload_result,
16018 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
16019 TOKEN_NUM_INITIALIZER
16020 (struct cmd_config_per_queue_rx_offload_result,
16021 queue_id, RTE_UINT16);
16022 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
16023 TOKEN_STRING_INITIALIZER
16024 (struct cmd_config_per_queue_rx_offload_result,
16025 rx_offload, "rx_offload");
16026 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
16027 TOKEN_STRING_INITIALIZER
16028 (struct cmd_config_per_queue_rx_offload_result,
16029 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
16030 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
16031 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
16032 "scatter#buffer_split#timestamp#security#keep_crc");
16033 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
16034 TOKEN_STRING_INITIALIZER
16035 (struct cmd_config_per_queue_rx_offload_result,
16039 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
16040 __rte_unused struct cmdline *cl,
16041 __rte_unused void *data)
16043 struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
16044 struct rte_eth_dev_info dev_info;
16045 portid_t port_id = res->port_id;
16046 uint16_t queue_id = res->queue_id;
16047 struct rte_port *port = &ports[port_id];
16048 uint64_t single_offload;
16051 if (port->port_status != RTE_PORT_STOPPED) {
16052 printf("Error: Can't config offload when Port %d "
16053 "is not stopped\n", port_id);
16057 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16061 if (queue_id >= dev_info.nb_rx_queues) {
16062 printf("Error: input queue_id should be 0 ... "
16063 "%d\n", dev_info.nb_rx_queues - 1);
16067 single_offload = search_rx_offload(res->offload);
16068 if (single_offload == 0) {
16069 printf("Unknown offload name: %s\n", res->offload);
16073 if (!strcmp(res->on_off, "on"))
16074 port->rx_conf[queue_id].offloads |= single_offload;
16076 port->rx_conf[queue_id].offloads &= ~single_offload;
16078 cmd_reconfig_device_queue(port_id, 1, 1);
16081 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
16082 .f = cmd_config_per_queue_rx_offload_parsed,
16084 .help_str = "port <port_id> rxq <queue_id> rx_offload "
16085 "vlan_strip|ipv4_cksum|"
16086 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
16087 "macsec_strip|header_split|vlan_filter|vlan_extend|"
16088 "jumbo_frame|scatter|buffer_split|timestamp|security|"
16091 (void *)&cmd_config_per_queue_rx_offload_result_port,
16092 (void *)&cmd_config_per_queue_rx_offload_result_port_id,
16093 (void *)&cmd_config_per_queue_rx_offload_result_rxq,
16094 (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
16095 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
16096 (void *)&cmd_config_per_queue_rx_offload_result_offload,
16097 (void *)&cmd_config_per_queue_rx_offload_result_on_off,
16102 /* Get Tx offloads capabilities */
16103 struct cmd_tx_offload_get_capa_result {
16104 cmdline_fixed_string_t show;
16105 cmdline_fixed_string_t port;
16107 cmdline_fixed_string_t tx_offload;
16108 cmdline_fixed_string_t capabilities;
16111 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
16112 TOKEN_STRING_INITIALIZER
16113 (struct cmd_tx_offload_get_capa_result,
16115 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
16116 TOKEN_STRING_INITIALIZER
16117 (struct cmd_tx_offload_get_capa_result,
16119 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
16120 TOKEN_NUM_INITIALIZER
16121 (struct cmd_tx_offload_get_capa_result,
16122 port_id, RTE_UINT16);
16123 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
16124 TOKEN_STRING_INITIALIZER
16125 (struct cmd_tx_offload_get_capa_result,
16126 tx_offload, "tx_offload");
16127 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
16128 TOKEN_STRING_INITIALIZER
16129 (struct cmd_tx_offload_get_capa_result,
16130 capabilities, "capabilities");
16133 print_tx_offloads(uint64_t offloads)
16135 uint64_t single_offload;
16143 begin = __builtin_ctzll(offloads);
16144 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
16146 single_offload = 1ULL << begin;
16147 for (bit = begin; bit < end; bit++) {
16148 if (offloads & single_offload)
16150 rte_eth_dev_tx_offload_name(single_offload));
16151 single_offload <<= 1;
16156 cmd_tx_offload_get_capa_parsed(
16157 void *parsed_result,
16158 __rte_unused struct cmdline *cl,
16159 __rte_unused void *data)
16161 struct cmd_tx_offload_get_capa_result *res = parsed_result;
16162 struct rte_eth_dev_info dev_info;
16163 portid_t port_id = res->port_id;
16164 uint64_t queue_offloads;
16165 uint64_t port_offloads;
16168 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16172 queue_offloads = dev_info.tx_queue_offload_capa;
16173 port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
16175 printf("Tx Offloading Capabilities of port %d :\n", port_id);
16176 printf(" Per Queue :");
16177 print_tx_offloads(queue_offloads);
16180 printf(" Per Port :");
16181 print_tx_offloads(port_offloads);
16185 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
16186 .f = cmd_tx_offload_get_capa_parsed,
16188 .help_str = "show port <port_id> tx_offload capabilities",
16190 (void *)&cmd_tx_offload_get_capa_show,
16191 (void *)&cmd_tx_offload_get_capa_port,
16192 (void *)&cmd_tx_offload_get_capa_port_id,
16193 (void *)&cmd_tx_offload_get_capa_tx_offload,
16194 (void *)&cmd_tx_offload_get_capa_capabilities,
16199 /* Get Tx offloads configuration */
16200 struct cmd_tx_offload_get_configuration_result {
16201 cmdline_fixed_string_t show;
16202 cmdline_fixed_string_t port;
16204 cmdline_fixed_string_t tx_offload;
16205 cmdline_fixed_string_t configuration;
16208 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
16209 TOKEN_STRING_INITIALIZER
16210 (struct cmd_tx_offload_get_configuration_result,
16212 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
16213 TOKEN_STRING_INITIALIZER
16214 (struct cmd_tx_offload_get_configuration_result,
16216 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
16217 TOKEN_NUM_INITIALIZER
16218 (struct cmd_tx_offload_get_configuration_result,
16219 port_id, RTE_UINT16);
16220 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
16221 TOKEN_STRING_INITIALIZER
16222 (struct cmd_tx_offload_get_configuration_result,
16223 tx_offload, "tx_offload");
16224 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
16225 TOKEN_STRING_INITIALIZER
16226 (struct cmd_tx_offload_get_configuration_result,
16227 configuration, "configuration");
16230 cmd_tx_offload_get_configuration_parsed(
16231 void *parsed_result,
16232 __rte_unused struct cmdline *cl,
16233 __rte_unused void *data)
16235 struct cmd_tx_offload_get_configuration_result *res = parsed_result;
16236 struct rte_eth_dev_info dev_info;
16237 portid_t port_id = res->port_id;
16238 struct rte_port *port = &ports[port_id];
16239 uint64_t port_offloads;
16240 uint64_t queue_offloads;
16241 uint16_t nb_tx_queues;
16245 printf("Tx Offloading Configuration of port %d :\n", port_id);
16247 port_offloads = port->dev_conf.txmode.offloads;
16249 print_tx_offloads(port_offloads);
16252 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16256 nb_tx_queues = dev_info.nb_tx_queues;
16257 for (q = 0; q < nb_tx_queues; q++) {
16258 queue_offloads = port->tx_conf[q].offloads;
16259 printf(" Queue[%2d] :", q);
16260 print_tx_offloads(queue_offloads);
16266 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
16267 .f = cmd_tx_offload_get_configuration_parsed,
16269 .help_str = "show port <port_id> tx_offload configuration",
16271 (void *)&cmd_tx_offload_get_configuration_show,
16272 (void *)&cmd_tx_offload_get_configuration_port,
16273 (void *)&cmd_tx_offload_get_configuration_port_id,
16274 (void *)&cmd_tx_offload_get_configuration_tx_offload,
16275 (void *)&cmd_tx_offload_get_configuration_configuration,
16280 /* Enable/Disable a per port offloading */
16281 struct cmd_config_per_port_tx_offload_result {
16282 cmdline_fixed_string_t port;
16283 cmdline_fixed_string_t config;
16285 cmdline_fixed_string_t tx_offload;
16286 cmdline_fixed_string_t offload;
16287 cmdline_fixed_string_t on_off;
16290 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
16291 TOKEN_STRING_INITIALIZER
16292 (struct cmd_config_per_port_tx_offload_result,
16294 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
16295 TOKEN_STRING_INITIALIZER
16296 (struct cmd_config_per_port_tx_offload_result,
16298 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
16299 TOKEN_NUM_INITIALIZER
16300 (struct cmd_config_per_port_tx_offload_result,
16301 port_id, RTE_UINT16);
16302 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
16303 TOKEN_STRING_INITIALIZER
16304 (struct cmd_config_per_port_tx_offload_result,
16305 tx_offload, "tx_offload");
16306 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
16307 TOKEN_STRING_INITIALIZER
16308 (struct cmd_config_per_port_tx_offload_result,
16309 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
16310 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
16311 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
16312 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
16313 "mt_lockfree#multi_segs#mbuf_fast_free#security#"
16314 "send_on_timestamp");
16315 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
16316 TOKEN_STRING_INITIALIZER
16317 (struct cmd_config_per_port_tx_offload_result,
16321 search_tx_offload(const char *name)
16323 uint64_t single_offload;
16324 const char *single_name;
16328 single_offload = 1;
16329 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
16330 single_name = rte_eth_dev_tx_offload_name(single_offload);
16331 if (single_name == NULL)
16333 if (!strcasecmp(single_name, name)) {
16336 } else if (!strcasecmp(single_name, "UNKNOWN"))
16338 single_offload <<= 1;
16342 return single_offload;
16348 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
16349 __rte_unused struct cmdline *cl,
16350 __rte_unused void *data)
16352 struct cmd_config_per_port_tx_offload_result *res = parsed_result;
16353 portid_t port_id = res->port_id;
16354 struct rte_eth_dev_info dev_info;
16355 struct rte_port *port = &ports[port_id];
16356 uint64_t single_offload;
16357 uint16_t nb_tx_queues;
16361 if (port->port_status != RTE_PORT_STOPPED) {
16362 printf("Error: Can't config offload when Port %d "
16363 "is not stopped\n", port_id);
16367 single_offload = search_tx_offload(res->offload);
16368 if (single_offload == 0) {
16369 printf("Unknown offload name: %s\n", res->offload);
16373 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16377 nb_tx_queues = dev_info.nb_tx_queues;
16378 if (!strcmp(res->on_off, "on")) {
16379 port->dev_conf.txmode.offloads |= single_offload;
16380 for (q = 0; q < nb_tx_queues; q++)
16381 port->tx_conf[q].offloads |= single_offload;
16383 port->dev_conf.txmode.offloads &= ~single_offload;
16384 for (q = 0; q < nb_tx_queues; q++)
16385 port->tx_conf[q].offloads &= ~single_offload;
16388 cmd_reconfig_device_queue(port_id, 1, 1);
16391 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
16392 .f = cmd_config_per_port_tx_offload_parsed,
16394 .help_str = "port config <port_id> tx_offload "
16395 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
16396 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
16397 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
16398 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
16399 "mt_lockfree|multi_segs|mbuf_fast_free|security|"
16400 "send_on_timestamp on|off",
16402 (void *)&cmd_config_per_port_tx_offload_result_port,
16403 (void *)&cmd_config_per_port_tx_offload_result_config,
16404 (void *)&cmd_config_per_port_tx_offload_result_port_id,
16405 (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
16406 (void *)&cmd_config_per_port_tx_offload_result_offload,
16407 (void *)&cmd_config_per_port_tx_offload_result_on_off,
16412 /* Enable/Disable a per queue offloading */
16413 struct cmd_config_per_queue_tx_offload_result {
16414 cmdline_fixed_string_t port;
16416 cmdline_fixed_string_t txq;
16418 cmdline_fixed_string_t tx_offload;
16419 cmdline_fixed_string_t offload;
16420 cmdline_fixed_string_t on_off;
16423 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
16424 TOKEN_STRING_INITIALIZER
16425 (struct cmd_config_per_queue_tx_offload_result,
16427 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
16428 TOKEN_NUM_INITIALIZER
16429 (struct cmd_config_per_queue_tx_offload_result,
16430 port_id, RTE_UINT16);
16431 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
16432 TOKEN_STRING_INITIALIZER
16433 (struct cmd_config_per_queue_tx_offload_result,
16435 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
16436 TOKEN_NUM_INITIALIZER
16437 (struct cmd_config_per_queue_tx_offload_result,
16438 queue_id, RTE_UINT16);
16439 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
16440 TOKEN_STRING_INITIALIZER
16441 (struct cmd_config_per_queue_tx_offload_result,
16442 tx_offload, "tx_offload");
16443 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
16444 TOKEN_STRING_INITIALIZER
16445 (struct cmd_config_per_queue_tx_offload_result,
16446 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
16447 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
16448 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
16449 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
16450 "mt_lockfree#multi_segs#mbuf_fast_free#security");
16451 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
16452 TOKEN_STRING_INITIALIZER
16453 (struct cmd_config_per_queue_tx_offload_result,
16457 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
16458 __rte_unused struct cmdline *cl,
16459 __rte_unused void *data)
16461 struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
16462 struct rte_eth_dev_info dev_info;
16463 portid_t port_id = res->port_id;
16464 uint16_t queue_id = res->queue_id;
16465 struct rte_port *port = &ports[port_id];
16466 uint64_t single_offload;
16469 if (port->port_status != RTE_PORT_STOPPED) {
16470 printf("Error: Can't config offload when Port %d "
16471 "is not stopped\n", port_id);
16475 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16479 if (queue_id >= dev_info.nb_tx_queues) {
16480 printf("Error: input queue_id should be 0 ... "
16481 "%d\n", dev_info.nb_tx_queues - 1);
16485 single_offload = search_tx_offload(res->offload);
16486 if (single_offload == 0) {
16487 printf("Unknown offload name: %s\n", res->offload);
16491 if (!strcmp(res->on_off, "on"))
16492 port->tx_conf[queue_id].offloads |= single_offload;
16494 port->tx_conf[queue_id].offloads &= ~single_offload;
16496 cmd_reconfig_device_queue(port_id, 1, 1);
16499 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
16500 .f = cmd_config_per_queue_tx_offload_parsed,
16502 .help_str = "port <port_id> txq <queue_id> tx_offload "
16503 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
16504 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
16505 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
16506 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
16507 "mt_lockfree|multi_segs|mbuf_fast_free|security "
16510 (void *)&cmd_config_per_queue_tx_offload_result_port,
16511 (void *)&cmd_config_per_queue_tx_offload_result_port_id,
16512 (void *)&cmd_config_per_queue_tx_offload_result_txq,
16513 (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
16514 (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
16515 (void *)&cmd_config_per_queue_tx_offload_result_offload,
16516 (void *)&cmd_config_per_queue_tx_offload_result_on_off,
16521 /* *** configure tx_metadata for specific port *** */
16522 struct cmd_config_tx_metadata_specific_result {
16523 cmdline_fixed_string_t port;
16524 cmdline_fixed_string_t keyword;
16526 cmdline_fixed_string_t item;
16531 cmd_config_tx_metadata_specific_parsed(void *parsed_result,
16532 __rte_unused struct cmdline *cl,
16533 __rte_unused void *data)
16535 struct cmd_config_tx_metadata_specific_result *res = parsed_result;
16537 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16539 ports[res->port_id].tx_metadata = res->value;
16540 /* Add/remove callback to insert valid metadata in every Tx packet. */
16541 if (ports[res->port_id].tx_metadata)
16542 add_tx_md_callback(res->port_id);
16544 remove_tx_md_callback(res->port_id);
16545 rte_flow_dynf_metadata_register();
16548 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
16549 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16551 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
16552 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16553 keyword, "config");
16554 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
16555 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16556 port_id, RTE_UINT16);
16557 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
16558 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16559 item, "tx_metadata");
16560 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
16561 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16562 value, RTE_UINT32);
16564 cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
16565 .f = cmd_config_tx_metadata_specific_parsed,
16567 .help_str = "port config <port_id> tx_metadata <value>",
16569 (void *)&cmd_config_tx_metadata_specific_port,
16570 (void *)&cmd_config_tx_metadata_specific_keyword,
16571 (void *)&cmd_config_tx_metadata_specific_id,
16572 (void *)&cmd_config_tx_metadata_specific_item,
16573 (void *)&cmd_config_tx_metadata_specific_value,
16578 /* *** set dynf *** */
16579 struct cmd_config_tx_dynf_specific_result {
16580 cmdline_fixed_string_t port;
16581 cmdline_fixed_string_t keyword;
16583 cmdline_fixed_string_t item;
16584 cmdline_fixed_string_t name;
16585 cmdline_fixed_string_t value;
16589 cmd_config_dynf_specific_parsed(void *parsed_result,
16590 __rte_unused struct cmdline *cl,
16591 __rte_unused void *data)
16593 struct cmd_config_tx_dynf_specific_result *res = parsed_result;
16594 struct rte_mbuf_dynflag desc_flag;
16596 uint64_t old_port_flags;
16598 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16600 flag = rte_mbuf_dynflag_lookup(res->name, NULL);
16602 if (strlcpy(desc_flag.name, res->name,
16603 RTE_MBUF_DYN_NAMESIZE) >= RTE_MBUF_DYN_NAMESIZE) {
16604 printf("Flag name too long\n");
16607 desc_flag.flags = 0;
16608 flag = rte_mbuf_dynflag_register(&desc_flag);
16610 printf("Can't register flag\n");
16613 strcpy(dynf_names[flag], desc_flag.name);
16615 old_port_flags = ports[res->port_id].mbuf_dynf;
16616 if (!strcmp(res->value, "set")) {
16617 ports[res->port_id].mbuf_dynf |= 1UL << flag;
16618 if (old_port_flags == 0)
16619 add_tx_dynf_callback(res->port_id);
16621 ports[res->port_id].mbuf_dynf &= ~(1UL << flag);
16622 if (ports[res->port_id].mbuf_dynf == 0)
16623 remove_tx_dynf_callback(res->port_id);
16627 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_port =
16628 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16630 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_keyword =
16631 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16632 keyword, "config");
16633 cmdline_parse_token_num_t cmd_config_tx_dynf_specific_port_id =
16634 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16635 port_id, RTE_UINT16);
16636 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_item =
16637 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16639 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_name =
16640 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16642 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_value =
16643 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16644 value, "set#clear");
16646 cmdline_parse_inst_t cmd_config_tx_dynf_specific = {
16647 .f = cmd_config_dynf_specific_parsed,
16649 .help_str = "port config <port id> dynf <name> set|clear",
16651 (void *)&cmd_config_tx_dynf_specific_port,
16652 (void *)&cmd_config_tx_dynf_specific_keyword,
16653 (void *)&cmd_config_tx_dynf_specific_port_id,
16654 (void *)&cmd_config_tx_dynf_specific_item,
16655 (void *)&cmd_config_tx_dynf_specific_name,
16656 (void *)&cmd_config_tx_dynf_specific_value,
16661 /* *** display tx_metadata per port configuration *** */
16662 struct cmd_show_tx_metadata_result {
16663 cmdline_fixed_string_t cmd_show;
16664 cmdline_fixed_string_t cmd_port;
16665 cmdline_fixed_string_t cmd_keyword;
16670 cmd_show_tx_metadata_parsed(void *parsed_result,
16671 __rte_unused struct cmdline *cl,
16672 __rte_unused void *data)
16674 struct cmd_show_tx_metadata_result *res = parsed_result;
16676 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16677 printf("invalid port id %u\n", res->cmd_pid);
16680 if (!strcmp(res->cmd_keyword, "tx_metadata")) {
16681 printf("Port %u tx_metadata: %u\n", res->cmd_pid,
16682 ports[res->cmd_pid].tx_metadata);
16686 cmdline_parse_token_string_t cmd_show_tx_metadata_show =
16687 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
16689 cmdline_parse_token_string_t cmd_show_tx_metadata_port =
16690 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
16692 cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
16693 TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
16694 cmd_pid, RTE_UINT16);
16695 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
16696 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
16697 cmd_keyword, "tx_metadata");
16699 cmdline_parse_inst_t cmd_show_tx_metadata = {
16700 .f = cmd_show_tx_metadata_parsed,
16702 .help_str = "show port <port_id> tx_metadata",
16704 (void *)&cmd_show_tx_metadata_show,
16705 (void *)&cmd_show_tx_metadata_port,
16706 (void *)&cmd_show_tx_metadata_pid,
16707 (void *)&cmd_show_tx_metadata_keyword,
16712 /* *** show fec capability per port configuration *** */
16713 struct cmd_show_fec_capability_result {
16714 cmdline_fixed_string_t cmd_show;
16715 cmdline_fixed_string_t cmd_port;
16716 cmdline_fixed_string_t cmd_fec;
16717 cmdline_fixed_string_t cmd_keyword;
16722 cmd_show_fec_capability_parsed(void *parsed_result,
16723 __rte_unused struct cmdline *cl,
16724 __rte_unused void *data)
16726 struct cmd_show_fec_capability_result *res = parsed_result;
16727 struct rte_eth_fec_capa *speed_fec_capa;
16731 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16732 printf("Invalid port id %u\n", res->cmd_pid);
16736 ret = rte_eth_fec_get_capability(res->cmd_pid, NULL, 0);
16737 if (ret == -ENOTSUP) {
16738 printf("Function not implemented\n");
16740 } else if (ret < 0) {
16741 printf("Get FEC capability failed: %d\n", ret);
16745 num = (unsigned int)ret;
16746 speed_fec_capa = calloc(num, sizeof(*speed_fec_capa));
16747 if (speed_fec_capa == NULL) {
16748 printf("Failed to alloc FEC capability buffer\n");
16752 ret = rte_eth_fec_get_capability(res->cmd_pid, speed_fec_capa, num);
16754 printf("Error getting FEC capability: %d\n", ret);
16758 show_fec_capability(num, speed_fec_capa);
16760 free(speed_fec_capa);
16763 cmdline_parse_token_string_t cmd_show_fec_capability_show =
16764 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16766 cmdline_parse_token_string_t cmd_show_fec_capability_port =
16767 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16769 cmdline_parse_token_num_t cmd_show_fec_capability_pid =
16770 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_capability_result,
16771 cmd_pid, RTE_UINT16);
16772 cmdline_parse_token_string_t cmd_show_fec_capability_fec =
16773 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16775 cmdline_parse_token_string_t cmd_show_fec_capability_keyword =
16776 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16777 cmd_keyword, "capabilities");
16779 cmdline_parse_inst_t cmd_show_capability = {
16780 .f = cmd_show_fec_capability_parsed,
16782 .help_str = "show port <port_id> fec capabilities",
16784 (void *)&cmd_show_fec_capability_show,
16785 (void *)&cmd_show_fec_capability_port,
16786 (void *)&cmd_show_fec_capability_pid,
16787 (void *)&cmd_show_fec_capability_fec,
16788 (void *)&cmd_show_fec_capability_keyword,
16793 /* *** show fec mode per port configuration *** */
16794 struct cmd_show_fec_metadata_result {
16795 cmdline_fixed_string_t cmd_show;
16796 cmdline_fixed_string_t cmd_port;
16797 cmdline_fixed_string_t cmd_keyword;
16802 cmd_show_fec_mode_parsed(void *parsed_result,
16803 __rte_unused struct cmdline *cl,
16804 __rte_unused void *data)
16806 #define FEC_NAME_SIZE 16
16807 struct cmd_show_fec_metadata_result *res = parsed_result;
16809 char buf[FEC_NAME_SIZE];
16812 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16813 printf("Invalid port id %u\n", res->cmd_pid);
16816 ret = rte_eth_fec_get(res->cmd_pid, &mode);
16817 if (ret == -ENOTSUP) {
16818 printf("Function not implemented\n");
16820 } else if (ret < 0) {
16821 printf("Get FEC mode failed\n");
16826 case RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC):
16827 strlcpy(buf, "off", sizeof(buf));
16829 case RTE_ETH_FEC_MODE_CAPA_MASK(AUTO):
16830 strlcpy(buf, "auto", sizeof(buf));
16832 case RTE_ETH_FEC_MODE_CAPA_MASK(BASER):
16833 strlcpy(buf, "baser", sizeof(buf));
16835 case RTE_ETH_FEC_MODE_CAPA_MASK(RS):
16836 strlcpy(buf, "rs", sizeof(buf));
16842 printf("%s\n", buf);
16845 cmdline_parse_token_string_t cmd_show_fec_mode_show =
16846 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
16848 cmdline_parse_token_string_t cmd_show_fec_mode_port =
16849 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
16851 cmdline_parse_token_num_t cmd_show_fec_mode_pid =
16852 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_metadata_result,
16853 cmd_pid, RTE_UINT16);
16854 cmdline_parse_token_string_t cmd_show_fec_mode_keyword =
16855 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
16856 cmd_keyword, "fec_mode");
16858 cmdline_parse_inst_t cmd_show_fec_mode = {
16859 .f = cmd_show_fec_mode_parsed,
16861 .help_str = "show port <port_id> fec_mode",
16863 (void *)&cmd_show_fec_mode_show,
16864 (void *)&cmd_show_fec_mode_port,
16865 (void *)&cmd_show_fec_mode_pid,
16866 (void *)&cmd_show_fec_mode_keyword,
16871 /* *** set fec mode per port configuration *** */
16872 struct cmd_set_port_fec_mode {
16873 cmdline_fixed_string_t set;
16874 cmdline_fixed_string_t port;
16876 cmdline_fixed_string_t fec_mode;
16877 cmdline_fixed_string_t fec_value;
16880 /* Common CLI fields for set fec mode */
16881 cmdline_parse_token_string_t cmd_set_port_fec_mode_set =
16882 TOKEN_STRING_INITIALIZER
16883 (struct cmd_set_port_fec_mode,
16885 cmdline_parse_token_string_t cmd_set_port_fec_mode_port =
16886 TOKEN_STRING_INITIALIZER
16887 (struct cmd_set_port_fec_mode,
16889 cmdline_parse_token_num_t cmd_set_port_fec_mode_port_id =
16890 TOKEN_NUM_INITIALIZER
16891 (struct cmd_set_port_fec_mode,
16892 port_id, RTE_UINT16);
16893 cmdline_parse_token_string_t cmd_set_port_fec_mode_str =
16894 TOKEN_STRING_INITIALIZER
16895 (struct cmd_set_port_fec_mode,
16896 fec_mode, "fec_mode");
16897 cmdline_parse_token_string_t cmd_set_port_fec_mode_value =
16898 TOKEN_STRING_INITIALIZER
16899 (struct cmd_set_port_fec_mode,
16903 cmd_set_port_fec_mode_parsed(
16904 void *parsed_result,
16905 __rte_unused struct cmdline *cl,
16906 __rte_unused void *data)
16908 struct cmd_set_port_fec_mode *res = parsed_result;
16909 uint16_t port_id = res->port_id;
16913 ret = parse_fec_mode(res->fec_value, &mode);
16915 printf("Unknown fec mode: %s for Port %d\n", res->fec_value,
16920 ret = rte_eth_fec_set(port_id, mode);
16921 if (ret == -ENOTSUP) {
16922 printf("Function not implemented\n");
16924 } else if (ret < 0) {
16925 printf("Set FEC mode failed\n");
16930 cmdline_parse_inst_t cmd_set_fec_mode = {
16931 .f = cmd_set_port_fec_mode_parsed,
16933 .help_str = "set port <port_id> fec_mode auto|off|rs|baser",
16935 (void *)&cmd_set_port_fec_mode_set,
16936 (void *)&cmd_set_port_fec_mode_port,
16937 (void *)&cmd_set_port_fec_mode_port_id,
16938 (void *)&cmd_set_port_fec_mode_str,
16939 (void *)&cmd_set_port_fec_mode_value,
16944 /* show port supported ptypes */
16946 /* Common result structure for show port ptypes */
16947 struct cmd_show_port_supported_ptypes_result {
16948 cmdline_fixed_string_t show;
16949 cmdline_fixed_string_t port;
16951 cmdline_fixed_string_t ptypes;
16954 /* Common CLI fields for show port ptypes */
16955 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =
16956 TOKEN_STRING_INITIALIZER
16957 (struct cmd_show_port_supported_ptypes_result,
16959 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
16960 TOKEN_STRING_INITIALIZER
16961 (struct cmd_show_port_supported_ptypes_result,
16963 cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =
16964 TOKEN_NUM_INITIALIZER
16965 (struct cmd_show_port_supported_ptypes_result,
16966 port_id, RTE_UINT16);
16967 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =
16968 TOKEN_STRING_INITIALIZER
16969 (struct cmd_show_port_supported_ptypes_result,
16973 cmd_show_port_supported_ptypes_parsed(
16974 void *parsed_result,
16975 __rte_unused struct cmdline *cl,
16976 __rte_unused void *data)
16978 #define RSVD_PTYPE_MASK 0xf0000000
16979 #define MAX_PTYPES_PER_LAYER 16
16980 #define LTYPE_NAMESIZE 32
16981 #define PTYPE_NAMESIZE 256
16982 struct cmd_show_port_supported_ptypes_result *res = parsed_result;
16983 char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE];
16984 uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
16985 uint32_t ptypes[MAX_PTYPES_PER_LAYER];
16986 uint16_t port_id = res->port_id;
16989 ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0);
16993 while (ptype_mask != RSVD_PTYPE_MASK) {
16995 switch (ptype_mask) {
16996 case RTE_PTYPE_L2_MASK:
16997 strlcpy(ltype, "L2", sizeof(ltype));
16999 case RTE_PTYPE_L3_MASK:
17000 strlcpy(ltype, "L3", sizeof(ltype));
17002 case RTE_PTYPE_L4_MASK:
17003 strlcpy(ltype, "L4", sizeof(ltype));
17005 case RTE_PTYPE_TUNNEL_MASK:
17006 strlcpy(ltype, "Tunnel", sizeof(ltype));
17008 case RTE_PTYPE_INNER_L2_MASK:
17009 strlcpy(ltype, "Inner L2", sizeof(ltype));
17011 case RTE_PTYPE_INNER_L3_MASK:
17012 strlcpy(ltype, "Inner L3", sizeof(ltype));
17014 case RTE_PTYPE_INNER_L4_MASK:
17015 strlcpy(ltype, "Inner L4", sizeof(ltype));
17021 ret = rte_eth_dev_get_supported_ptypes(res->port_id,
17022 ptype_mask, ptypes,
17023 MAX_PTYPES_PER_LAYER);
17026 printf("Supported %s ptypes:\n", ltype);
17028 printf("%s ptypes unsupported\n", ltype);
17030 for (i = 0; i < ret; ++i) {
17031 rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
17032 printf("%s\n", buf);
17039 cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
17040 .f = cmd_show_port_supported_ptypes_parsed,
17042 .help_str = "show port <port_id> ptypes",
17044 (void *)&cmd_show_port_supported_ptypes_show,
17045 (void *)&cmd_show_port_supported_ptypes_port,
17046 (void *)&cmd_show_port_supported_ptypes_port_id,
17047 (void *)&cmd_show_port_supported_ptypes_ptypes,
17052 /* *** display rx/tx descriptor status *** */
17053 struct cmd_show_rx_tx_desc_status_result {
17054 cmdline_fixed_string_t cmd_show;
17055 cmdline_fixed_string_t cmd_port;
17056 cmdline_fixed_string_t cmd_keyword;
17057 cmdline_fixed_string_t cmd_desc;
17058 cmdline_fixed_string_t cmd_status;
17065 cmd_show_rx_tx_desc_status_parsed(void *parsed_result,
17066 __rte_unused struct cmdline *cl,
17067 __rte_unused void *data)
17069 struct cmd_show_rx_tx_desc_status_result *res = parsed_result;
17072 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17073 printf("invalid port id %u\n", res->cmd_pid);
17077 if (!strcmp(res->cmd_keyword, "rxq")) {
17078 rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid,
17081 printf("Invalid input: queue id = %d, desc id = %d\n",
17082 res->cmd_qid, res->cmd_did);
17085 if (rc == RTE_ETH_RX_DESC_AVAIL)
17086 printf("Desc status = AVAILABLE\n");
17087 else if (rc == RTE_ETH_RX_DESC_DONE)
17088 printf("Desc status = DONE\n");
17090 printf("Desc status = UNAVAILABLE\n");
17091 } else if (!strcmp(res->cmd_keyword, "txq")) {
17092 rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid,
17095 printf("Invalid input: queue id = %d, desc id = %d\n",
17096 res->cmd_qid, res->cmd_did);
17099 if (rc == RTE_ETH_TX_DESC_FULL)
17100 printf("Desc status = FULL\n");
17101 else if (rc == RTE_ETH_TX_DESC_DONE)
17102 printf("Desc status = DONE\n");
17104 printf("Desc status = UNAVAILABLE\n");
17108 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show =
17109 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17111 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port =
17112 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17114 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid =
17115 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17116 cmd_pid, RTE_UINT16);
17117 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword =
17118 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17119 cmd_keyword, "rxq#txq");
17120 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid =
17121 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17122 cmd_qid, RTE_UINT16);
17123 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc =
17124 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17126 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did =
17127 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17128 cmd_did, RTE_UINT16);
17129 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status =
17130 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17131 cmd_status, "status");
17132 cmdline_parse_inst_t cmd_show_rx_tx_desc_status = {
17133 .f = cmd_show_rx_tx_desc_status_parsed,
17135 .help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> "
17138 (void *)&cmd_show_rx_tx_desc_status_show,
17139 (void *)&cmd_show_rx_tx_desc_status_port,
17140 (void *)&cmd_show_rx_tx_desc_status_pid,
17141 (void *)&cmd_show_rx_tx_desc_status_keyword,
17142 (void *)&cmd_show_rx_tx_desc_status_qid,
17143 (void *)&cmd_show_rx_tx_desc_status_desc,
17144 (void *)&cmd_show_rx_tx_desc_status_did,
17145 (void *)&cmd_show_rx_tx_desc_status_status,
17150 /* *** display rx queue desc used count *** */
17151 struct cmd_show_rx_queue_desc_used_count_result {
17152 cmdline_fixed_string_t cmd_show;
17153 cmdline_fixed_string_t cmd_port;
17154 cmdline_fixed_string_t cmd_rxq;
17155 cmdline_fixed_string_t cmd_desc;
17156 cmdline_fixed_string_t cmd_used;
17157 cmdline_fixed_string_t cmd_count;
17163 cmd_show_rx_queue_desc_used_count_parsed(void *parsed_result,
17164 __rte_unused struct cmdline *cl,
17165 __rte_unused void *data)
17167 struct cmd_show_rx_queue_desc_used_count_result *res = parsed_result;
17170 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17171 printf("invalid port id %u\n", res->cmd_pid);
17175 rc = rte_eth_rx_queue_count(res->cmd_pid, res->cmd_qid);
17177 printf("Invalid queueid = %d\n", res->cmd_qid);
17180 printf("Used desc count = %d\n", rc);
17183 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_show =
17184 TOKEN_STRING_INITIALIZER
17185 (struct cmd_show_rx_queue_desc_used_count_result,
17187 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_port =
17188 TOKEN_STRING_INITIALIZER
17189 (struct cmd_show_rx_queue_desc_used_count_result,
17191 cmdline_parse_token_num_t cmd_show_rx_queue_desc_used_count_pid =
17192 TOKEN_NUM_INITIALIZER
17193 (struct cmd_show_rx_queue_desc_used_count_result,
17194 cmd_pid, RTE_UINT16);
17195 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_rxq =
17196 TOKEN_STRING_INITIALIZER
17197 (struct cmd_show_rx_queue_desc_used_count_result,
17199 cmdline_parse_token_num_t cmd_show_rx_queue_desc_used_count_qid =
17200 TOKEN_NUM_INITIALIZER
17201 (struct cmd_show_rx_queue_desc_used_count_result,
17202 cmd_qid, RTE_UINT16);
17203 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_desc =
17204 TOKEN_STRING_INITIALIZER
17205 (struct cmd_show_rx_queue_desc_used_count_result,
17206 cmd_count, "desc");
17207 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_used =
17208 TOKEN_STRING_INITIALIZER
17209 (struct cmd_show_rx_queue_desc_used_count_result,
17210 cmd_count, "used");
17211 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_count =
17212 TOKEN_STRING_INITIALIZER
17213 (struct cmd_show_rx_queue_desc_used_count_result,
17214 cmd_count, "count");
17215 cmdline_parse_inst_t cmd_show_rx_queue_desc_used_count = {
17216 .f = cmd_show_rx_queue_desc_used_count_parsed,
17218 .help_str = "show port <port_id> rxq <queue_id> desc used count",
17220 (void *)&cmd_show_rx_queue_desc_used_count_show,
17221 (void *)&cmd_show_rx_queue_desc_used_count_port,
17222 (void *)&cmd_show_rx_queue_desc_used_count_pid,
17223 (void *)&cmd_show_rx_queue_desc_used_count_rxq,
17224 (void *)&cmd_show_rx_queue_desc_used_count_qid,
17225 (void *)&cmd_show_rx_queue_desc_used_count_desc,
17226 (void *)&cmd_show_rx_queue_desc_used_count_used,
17227 (void *)&cmd_show_rx_queue_desc_used_count_count,
17232 /* Common result structure for set port ptypes */
17233 struct cmd_set_port_ptypes_result {
17234 cmdline_fixed_string_t set;
17235 cmdline_fixed_string_t port;
17237 cmdline_fixed_string_t ptype_mask;
17241 /* Common CLI fields for set port ptypes */
17242 cmdline_parse_token_string_t cmd_set_port_ptypes_set =
17243 TOKEN_STRING_INITIALIZER
17244 (struct cmd_set_port_ptypes_result,
17246 cmdline_parse_token_string_t cmd_set_port_ptypes_port =
17247 TOKEN_STRING_INITIALIZER
17248 (struct cmd_set_port_ptypes_result,
17250 cmdline_parse_token_num_t cmd_set_port_ptypes_port_id =
17251 TOKEN_NUM_INITIALIZER
17252 (struct cmd_set_port_ptypes_result,
17253 port_id, RTE_UINT16);
17254 cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str =
17255 TOKEN_STRING_INITIALIZER
17256 (struct cmd_set_port_ptypes_result,
17257 ptype_mask, "ptype_mask");
17258 cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 =
17259 TOKEN_NUM_INITIALIZER
17260 (struct cmd_set_port_ptypes_result,
17264 cmd_set_port_ptypes_parsed(
17265 void *parsed_result,
17266 __rte_unused struct cmdline *cl,
17267 __rte_unused void *data)
17269 struct cmd_set_port_ptypes_result *res = parsed_result;
17270 #define PTYPE_NAMESIZE 256
17271 char ptype_name[PTYPE_NAMESIZE];
17272 uint16_t port_id = res->port_id;
17273 uint32_t ptype_mask = res->mask;
17276 ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK,
17279 printf("Port %d doesn't support any ptypes.\n", port_id);
17283 uint32_t ptypes[ret];
17285 ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret);
17287 printf("Unable to set requested ptypes for Port %d\n", port_id);
17291 printf("Successfully set following ptypes for Port %d\n", port_id);
17292 for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) {
17293 rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name));
17294 printf("%s\n", ptype_name);
17297 clear_ptypes = false;
17300 cmdline_parse_inst_t cmd_set_port_ptypes = {
17301 .f = cmd_set_port_ptypes_parsed,
17303 .help_str = "set port <port_id> ptype_mask <mask>",
17305 (void *)&cmd_set_port_ptypes_set,
17306 (void *)&cmd_set_port_ptypes_port,
17307 (void *)&cmd_set_port_ptypes_port_id,
17308 (void *)&cmd_set_port_ptypes_mask_str,
17309 (void *)&cmd_set_port_ptypes_mask_u32,
17314 /* *** display mac addresses added to a port *** */
17315 struct cmd_showport_macs_result {
17316 cmdline_fixed_string_t cmd_show;
17317 cmdline_fixed_string_t cmd_port;
17318 cmdline_fixed_string_t cmd_keyword;
17323 cmd_showport_macs_parsed(void *parsed_result,
17324 __rte_unused struct cmdline *cl,
17325 __rte_unused void *data)
17327 struct cmd_showport_macs_result *res = parsed_result;
17329 if (port_id_is_invalid(res->cmd_pid, ENABLED_WARN))
17332 if (!strcmp(res->cmd_keyword, "macs"))
17333 show_macs(res->cmd_pid);
17334 else if (!strcmp(res->cmd_keyword, "mcast_macs"))
17335 show_mcast_macs(res->cmd_pid);
17338 cmdline_parse_token_string_t cmd_showport_macs_show =
17339 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17341 cmdline_parse_token_string_t cmd_showport_macs_port =
17342 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17344 cmdline_parse_token_num_t cmd_showport_macs_pid =
17345 TOKEN_NUM_INITIALIZER(struct cmd_showport_macs_result,
17346 cmd_pid, RTE_UINT16);
17347 cmdline_parse_token_string_t cmd_showport_macs_keyword =
17348 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17349 cmd_keyword, "macs#mcast_macs");
17351 cmdline_parse_inst_t cmd_showport_macs = {
17352 .f = cmd_showport_macs_parsed,
17354 .help_str = "show port <port_id> macs|mcast_macs",
17356 (void *)&cmd_showport_macs_show,
17357 (void *)&cmd_showport_macs_port,
17358 (void *)&cmd_showport_macs_pid,
17359 (void *)&cmd_showport_macs_keyword,
17364 /* ******************************************************************************** */
17366 /* list of instructions */
17367 cmdline_parse_ctx_t main_ctx[] = {
17368 (cmdline_parse_inst_t *)&cmd_help_brief,
17369 (cmdline_parse_inst_t *)&cmd_help_long,
17370 (cmdline_parse_inst_t *)&cmd_quit,
17371 (cmdline_parse_inst_t *)&cmd_load_from_file,
17372 (cmdline_parse_inst_t *)&cmd_showport,
17373 (cmdline_parse_inst_t *)&cmd_showqueue,
17374 (cmdline_parse_inst_t *)&cmd_showeeprom,
17375 (cmdline_parse_inst_t *)&cmd_showportall,
17376 (cmdline_parse_inst_t *)&cmd_showdevice,
17377 (cmdline_parse_inst_t *)&cmd_showcfg,
17378 (cmdline_parse_inst_t *)&cmd_showfwdall,
17379 (cmdline_parse_inst_t *)&cmd_start,
17380 (cmdline_parse_inst_t *)&cmd_start_tx_first,
17381 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
17382 (cmdline_parse_inst_t *)&cmd_set_link_up,
17383 (cmdline_parse_inst_t *)&cmd_set_link_down,
17384 (cmdline_parse_inst_t *)&cmd_reset,
17385 (cmdline_parse_inst_t *)&cmd_set_numbers,
17386 (cmdline_parse_inst_t *)&cmd_set_log,
17387 (cmdline_parse_inst_t *)&cmd_set_rxoffs,
17388 (cmdline_parse_inst_t *)&cmd_set_rxpkts,
17389 (cmdline_parse_inst_t *)&cmd_set_txpkts,
17390 (cmdline_parse_inst_t *)&cmd_set_txsplit,
17391 (cmdline_parse_inst_t *)&cmd_set_txtimes,
17392 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
17393 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
17394 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
17395 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
17396 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
17397 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
17398 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
17399 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
17400 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
17401 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
17402 (cmdline_parse_inst_t *)&cmd_set_link_check,
17403 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
17404 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
17405 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
17406 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
17407 #ifdef RTE_NET_BOND
17408 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
17409 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
17410 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
17411 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
17412 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
17413 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
17414 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
17415 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
17416 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
17417 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
17418 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
17420 (cmdline_parse_inst_t *)&cmd_vlan_offload,
17421 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
17422 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
17423 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
17424 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
17425 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
17426 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
17427 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
17428 (cmdline_parse_inst_t *)&cmd_csum_set,
17429 (cmdline_parse_inst_t *)&cmd_csum_show,
17430 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
17431 (cmdline_parse_inst_t *)&cmd_tso_set,
17432 (cmdline_parse_inst_t *)&cmd_tso_show,
17433 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
17434 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
17435 (cmdline_parse_inst_t *)&cmd_gro_enable,
17436 (cmdline_parse_inst_t *)&cmd_gro_flush,
17437 (cmdline_parse_inst_t *)&cmd_gro_show,
17438 (cmdline_parse_inst_t *)&cmd_gso_enable,
17439 (cmdline_parse_inst_t *)&cmd_gso_size,
17440 (cmdline_parse_inst_t *)&cmd_gso_show,
17441 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
17442 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
17443 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
17444 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
17445 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
17446 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
17447 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
17448 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
17449 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
17450 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
17451 (cmdline_parse_inst_t *)&cmd_config_dcb,
17452 (cmdline_parse_inst_t *)&cmd_read_reg,
17453 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
17454 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
17455 (cmdline_parse_inst_t *)&cmd_write_reg,
17456 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
17457 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
17458 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
17459 (cmdline_parse_inst_t *)&cmd_stop,
17460 (cmdline_parse_inst_t *)&cmd_mac_addr,
17461 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
17462 (cmdline_parse_inst_t *)&cmd_set_qmap,
17463 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
17464 (cmdline_parse_inst_t *)&cmd_set_record_core_cycles,
17465 (cmdline_parse_inst_t *)&cmd_set_record_burst_stats,
17466 (cmdline_parse_inst_t *)&cmd_operate_port,
17467 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
17468 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
17469 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
17470 (cmdline_parse_inst_t *)&cmd_operate_detach_device,
17471 (cmdline_parse_inst_t *)&cmd_set_port_setup_on,
17472 (cmdline_parse_inst_t *)&cmd_config_speed_all,
17473 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
17474 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
17475 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
17476 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
17477 (cmdline_parse_inst_t *)&cmd_config_mtu,
17478 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
17479 (cmdline_parse_inst_t *)&cmd_config_max_lro_pkt_size,
17480 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
17481 (cmdline_parse_inst_t *)&cmd_config_rss,
17482 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
17483 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
17484 (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
17485 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
17486 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
17487 (cmdline_parse_inst_t *)&cmd_showport_reta,
17488 (cmdline_parse_inst_t *)&cmd_showport_macs,
17489 (cmdline_parse_inst_t *)&cmd_config_burst,
17490 (cmdline_parse_inst_t *)&cmd_config_thresh,
17491 (cmdline_parse_inst_t *)&cmd_config_threshold,
17492 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
17493 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
17494 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
17495 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
17496 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
17497 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
17498 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
17499 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
17500 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
17501 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
17502 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
17503 (cmdline_parse_inst_t *)&cmd_cleanup_txq_mbufs,
17504 (cmdline_parse_inst_t *)&cmd_dump,
17505 (cmdline_parse_inst_t *)&cmd_dump_one,
17506 #ifdef RTE_NET_I40E
17507 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
17509 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
17510 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
17511 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
17512 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
17513 (cmdline_parse_inst_t *)&cmd_flow,
17514 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
17515 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
17516 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
17517 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
17518 (cmdline_parse_inst_t *)&cmd_create_port_meter,
17519 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
17520 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
17521 (cmdline_parse_inst_t *)&cmd_del_port_meter,
17522 (cmdline_parse_inst_t *)&cmd_del_port_meter_policy,
17523 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
17524 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
17525 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
17526 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
17527 (cmdline_parse_inst_t *)&cmd_mcast_addr,
17528 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
17529 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
17530 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
17531 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
17532 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
17533 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
17534 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
17535 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
17536 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
17537 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
17538 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
17539 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
17540 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
17541 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
17542 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
17543 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
17544 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
17545 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
17546 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
17547 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
17548 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
17549 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
17550 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
17551 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
17552 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
17553 (cmdline_parse_inst_t *)&cmd_set_vxlan,
17554 (cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl,
17555 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
17556 (cmdline_parse_inst_t *)&cmd_set_nvgre,
17557 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
17558 (cmdline_parse_inst_t *)&cmd_set_l2_encap,
17559 (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
17560 (cmdline_parse_inst_t *)&cmd_set_l2_decap,
17561 (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
17562 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
17563 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
17564 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
17565 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
17566 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
17567 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
17568 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
17569 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
17570 (cmdline_parse_inst_t *)&cmd_set_conntrack_common,
17571 (cmdline_parse_inst_t *)&cmd_set_conntrack_dir,
17572 (cmdline_parse_inst_t *)&cmd_ddp_add,
17573 (cmdline_parse_inst_t *)&cmd_ddp_del,
17574 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
17575 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
17576 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
17577 (cmdline_parse_inst_t *)&cmd_clear_input_set,
17578 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
17579 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
17580 (cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes,
17581 (cmdline_parse_inst_t *)&cmd_set_port_ptypes,
17582 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
17583 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
17584 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
17585 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
17587 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
17588 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
17589 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
17590 (cmdline_parse_inst_t *)&cmd_queue_region,
17591 (cmdline_parse_inst_t *)&cmd_region_flowtype,
17592 (cmdline_parse_inst_t *)&cmd_user_priority_region,
17593 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
17594 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
17595 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
17596 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
17597 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
17598 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
17599 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
17600 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
17601 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
17602 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
17603 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
17604 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
17605 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
17606 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
17607 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
17608 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node_pmode,
17609 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
17610 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
17611 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
17612 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
17613 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
17614 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
17615 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
17616 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
17617 (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
17618 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
17619 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
17620 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
17621 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
17622 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
17623 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
17624 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
17625 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
17626 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
17628 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
17629 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
17631 (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
17632 (cmdline_parse_inst_t *)&cmd_show_tx_metadata,
17633 (cmdline_parse_inst_t *)&cmd_show_rx_tx_desc_status,
17634 (cmdline_parse_inst_t *)&cmd_show_rx_queue_desc_used_count,
17635 (cmdline_parse_inst_t *)&cmd_set_raw,
17636 (cmdline_parse_inst_t *)&cmd_show_set_raw,
17637 (cmdline_parse_inst_t *)&cmd_show_set_raw_all,
17638 (cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific,
17639 (cmdline_parse_inst_t *)&cmd_show_fec_mode,
17640 (cmdline_parse_inst_t *)&cmd_set_fec_mode,
17641 (cmdline_parse_inst_t *)&cmd_show_capability,
17645 /* read cmdline commands from file */
17647 cmdline_read_from_file(const char *filename)
17649 struct cmdline *cl;
17651 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
17653 printf("Failed to create file based cmdline context: %s\n",
17658 cmdline_interact(cl);
17663 printf("Read CLI commands from %s\n", filename);
17666 /* prompt function, called from main on MAIN lcore */
17671 /* initialize non-constant commands */
17672 cmd_set_fwd_mode_init();
17673 cmd_set_fwd_retry_mode_init();
17675 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
17676 if (testpmd_cl == NULL)
17679 ret = atexit(prompt_exit);
17681 printf("Cannot set exit function for cmdline\n");
17683 cmdline_interact(testpmd_cl);
17685 cmdline_stdin_exit(testpmd_cl);
17691 if (testpmd_cl != NULL) {
17692 cmdline_quit(testpmd_cl);
17693 cmdline_stdin_exit(testpmd_cl);
17698 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
17700 if (id == (portid_t)RTE_PORT_ALL) {
17703 RTE_ETH_FOREACH_DEV(pid) {
17704 /* check if need_reconfig has been set to 1 */
17705 if (ports[pid].need_reconfig == 0)
17706 ports[pid].need_reconfig = dev;
17707 /* check if need_reconfig_queues has been set to 1 */
17708 if (ports[pid].need_reconfig_queues == 0)
17709 ports[pid].need_reconfig_queues = queue;
17711 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
17712 /* check if need_reconfig has been set to 1 */
17713 if (ports[id].need_reconfig == 0)
17714 ports[id].need_reconfig = dev;
17715 /* check if need_reconfig_queues has been set to 1 */
17716 if (ports[id].need_reconfig_queues == 0)
17717 ports[id].need_reconfig_queues = queue;