1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2016 Intel Corporation.
3 * Copyright(c) 2014 6WIND S.A.
16 #include <net/socket.h>
18 #include <sys/socket.h>
21 #include <netinet/in.h>
23 #include <sys/queue.h>
25 #include <rte_common.h>
26 #include <rte_byteorder.h>
28 #include <rte_debug.h>
29 #include <rte_cycles.h>
30 #include <rte_memory.h>
31 #include <rte_memzone.h>
32 #include <rte_malloc.h>
33 #include <rte_launch.h>
35 #include <rte_per_lcore.h>
36 #include <rte_lcore.h>
37 #include <rte_atomic.h>
38 #include <rte_branch_prediction.h>
40 #include <rte_mempool.h>
41 #include <rte_interrupts.h>
43 #include <rte_ether.h>
44 #include <rte_ethdev.h>
45 #include <rte_string_fns.h>
46 #include <rte_devargs.h>
47 #include <rte_eth_ctrl.h>
51 #include <cmdline_rdline.h>
52 #include <cmdline_parse.h>
53 #include <cmdline_parse_num.h>
54 #include <cmdline_parse_string.h>
55 #include <cmdline_parse_ipaddr.h>
56 #include <cmdline_parse_etheraddr.h>
57 #include <cmdline_socket.h>
59 #ifdef RTE_LIBRTE_PMD_BOND
60 #include <rte_eth_bond.h>
61 #include <rte_eth_bond_8023ad.h>
63 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD
64 #include <rte_pmd_dpaa.h>
66 #ifdef RTE_LIBRTE_IXGBE_PMD
67 #include <rte_pmd_ixgbe.h>
69 #ifdef RTE_LIBRTE_I40E_PMD
70 #include <rte_pmd_i40e.h>
72 #ifdef RTE_LIBRTE_BNXT_PMD
73 #include <rte_pmd_bnxt.h>
76 #include "cmdline_mtr.h"
77 #include "cmdline_tm.h"
80 static struct cmdline *testpmd_cl;
82 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
84 /* *** Help command with introduction. *** */
85 struct cmd_help_brief_result {
86 cmdline_fixed_string_t help;
89 static void cmd_help_brief_parsed(__attribute__((unused)) void *parsed_result,
91 __attribute__((unused)) void *data)
96 "Help is available for the following sections:\n\n"
97 " help control : Start and stop forwarding.\n"
98 " help display : Displaying port, stats and config "
100 " help config : Configuration information.\n"
101 " help ports : Configuring ports.\n"
102 " help registers : Reading and setting port registers.\n"
103 " help filters : Filters configuration help.\n"
104 " help all : All of the above sections.\n\n"
109 cmdline_parse_token_string_t cmd_help_brief_help =
110 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
112 cmdline_parse_inst_t cmd_help_brief = {
113 .f = cmd_help_brief_parsed,
115 .help_str = "help: Show help",
117 (void *)&cmd_help_brief_help,
122 /* *** Help command with help sections. *** */
123 struct cmd_help_long_result {
124 cmdline_fixed_string_t help;
125 cmdline_fixed_string_t section;
128 static void cmd_help_long_parsed(void *parsed_result,
130 __attribute__((unused)) void *data)
133 struct cmd_help_long_result *res = parsed_result;
135 if (!strcmp(res->section, "all"))
138 if (show_all || !strcmp(res->section, "control")) {
143 "Control forwarding:\n"
144 "-------------------\n\n"
147 " Start packet forwarding with current configuration.\n\n"
150 " Start packet forwarding with current config"
151 " after sending one burst of packets.\n\n"
154 " Stop packet forwarding, and display accumulated"
158 " Quit to prompt.\n\n"
162 if (show_all || !strcmp(res->section, "display")) {
170 "show port (info|stats|summary|xstats|fdir|stat_qmap|dcb_tc|cap) (port_id|all)\n"
171 " Display information for port_id, or all.\n\n"
173 "show port X rss reta (size) (mask0,mask1,...)\n"
174 " Display the rss redirection table entry indicated"
175 " by masks on port X. size is used to indicate the"
176 " hardware supported reta size\n\n"
178 "show port (port_id) rss-hash [key]\n"
179 " Display the RSS hash functions and RSS hash key of port\n\n"
181 "clear port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n"
182 " Clear information for port_id, or all.\n\n"
184 "show (rxq|txq) info (port_id) (queue_id)\n"
185 " Display information for configured RX/TX queue.\n\n"
187 "show config (rxtx|cores|fwd|txpkts)\n"
188 " Display the given configuration.\n\n"
190 "read rxd (port_id) (queue_id) (rxd_id)\n"
191 " Display an RX descriptor of a port RX queue.\n\n"
193 "read txd (port_id) (queue_id) (txd_id)\n"
194 " Display a TX descriptor of a port TX queue.\n\n"
196 "ddp get list (port_id)\n"
197 " Get ddp profile info list\n\n"
199 "ddp get info (profile_path)\n"
200 " Get ddp profile information.\n\n"
202 "show vf stats (port_id) (vf_id)\n"
203 " Display a VF's statistics.\n\n"
205 "clear vf stats (port_id) (vf_id)\n"
206 " Reset a VF's statistics.\n\n"
208 "show port (port_id) pctype mapping\n"
209 " Get flow ptype to pctype mapping on a port\n\n"
211 "show port meter stats (port_id) (meter_id) (clear)\n"
212 " Get meter stats on a port\n\n"
213 "show port tm cap (port_id)\n"
214 " Display the port TM capability.\n\n"
216 "show port tm level cap (port_id) (level_id)\n"
217 " Display the port TM hierarchical level capability.\n\n"
219 "show port tm node cap (port_id) (node_id)\n"
220 " Display the port TM node capability.\n\n"
222 "show port tm node type (port_id) (node_id)\n"
223 " Display the port TM node type.\n\n"
225 "show port tm node stats (port_id) (node_id) (clear)\n"
226 " Display the port TM node stats.\n\n"
231 if (show_all || !strcmp(res->section, "config")) {
237 "Configuration changes only become active when"
238 " forwarding is started/restarted.\n\n"
241 " Reset forwarding to the default configuration.\n\n"
243 "set verbose (level)\n"
244 " Set the debug verbosity level X.\n\n"
246 "set log global|(type) (level)\n"
247 " Set the log level.\n\n"
250 " Set number of ports.\n\n"
253 " Set number of cores.\n\n"
255 "set coremask (mask)\n"
256 " Set the forwarding cores hexadecimal mask.\n\n"
258 "set portmask (mask)\n"
259 " Set the forwarding ports hexadecimal mask.\n\n"
262 " Set number of packets per burst.\n\n"
264 "set burst tx delay (microseconds) retry (num)\n"
265 " Set the transmit delay time and number of retries,"
266 " effective when retry is enabled.\n\n"
268 "set txpkts (x[,y]*)\n"
269 " Set the length of each segment of TXONLY"
270 " and optionally CSUM packets.\n\n"
272 "set txsplit (off|on|rand)\n"
273 " Set the split policy for the TX packets."
274 " Right now only applicable for CSUM and TXONLY"
277 "set corelist (x[,y]*)\n"
278 " Set the list of forwarding cores.\n\n"
280 "set portlist (x[,y]*)\n"
281 " Set the list of forwarding ports.\n\n"
283 "set port setup on (iterator|event)\n"
284 " Select how attached port is retrieved for setup.\n\n"
286 "set tx loopback (port_id) (on|off)\n"
287 " Enable or disable tx loopback.\n\n"
289 "set all queues drop (port_id) (on|off)\n"
290 " Set drop enable bit for all queues.\n\n"
292 "set vf split drop (port_id) (vf_id) (on|off)\n"
293 " Set split drop enable bit for a VF from the PF.\n\n"
295 "set vf mac antispoof (port_id) (vf_id) (on|off).\n"
296 " Set MAC antispoof for a VF from the PF.\n\n"
298 "set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n"
299 " Enable MACsec offload.\n\n"
301 "set macsec offload (port_id) off\n"
302 " Disable MACsec offload.\n\n"
304 "set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
305 " Configure MACsec secure connection (SC).\n\n"
307 "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n"
308 " Configure MACsec secure association (SA).\n\n"
310 "set vf broadcast (port_id) (vf_id) (on|off)\n"
311 " Set VF broadcast for a VF from the PF.\n\n"
313 "vlan set strip (on|off) (port_id)\n"
314 " Set the VLAN strip on a port.\n\n"
316 "vlan set stripq (on|off) (port_id,queue_id)\n"
317 " Set the VLAN strip for a queue on a port.\n\n"
319 "set vf vlan stripq (port_id) (vf_id) (on|off)\n"
320 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
322 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
323 " Set VLAN insert for a VF from the PF.\n\n"
325 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
326 " Set VLAN antispoof for a VF from the PF.\n\n"
328 "set vf vlan tag (port_id) (vf_id) (on|off)\n"
329 " Set VLAN tag for a VF from the PF.\n\n"
331 "set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n"
332 " Set a VF's max bandwidth(Mbps).\n\n"
334 "set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n"
335 " Set all TCs' min bandwidth(%%) on a VF.\n\n"
337 "set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n"
338 " Set a TC's max bandwidth(Mbps) on a VF.\n\n"
340 "set tx strict-link-priority (port_id) (tc_bitmap)\n"
341 " Set some TCs' strict link priority mode on a physical port.\n\n"
343 "set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n"
344 " Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n"
346 "vlan set filter (on|off) (port_id)\n"
347 " Set the VLAN filter on a port.\n\n"
349 "vlan set qinq (on|off) (port_id)\n"
350 " Set the VLAN QinQ (extended queue in queue)"
353 "vlan set (inner|outer) tpid (value) (port_id)\n"
354 " Set the VLAN TPID for Packet Filtering on"
357 "rx_vlan add (vlan_id|all) (port_id)\n"
358 " Add a vlan_id, or all identifiers, to the set"
359 " of VLAN identifiers filtered by port_id.\n\n"
361 "rx_vlan rm (vlan_id|all) (port_id)\n"
362 " Remove a vlan_id, or all identifiers, from the set"
363 " of VLAN identifiers filtered by port_id.\n\n"
365 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
366 " Add a vlan_id, to the set of VLAN identifiers"
367 "filtered for VF(s) from port_id.\n\n"
369 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
370 " Remove a vlan_id, to the set of VLAN identifiers"
371 "filtered for VF(s) from port_id.\n\n"
373 "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) "
374 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
375 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
376 " add a tunnel filter of a port.\n\n"
378 "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) "
379 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
380 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
381 " remove a tunnel filter of a port.\n\n"
383 "rx_vxlan_port add (udp_port) (port_id)\n"
384 " Add an UDP port for VXLAN packet filter on a port\n\n"
386 "rx_vxlan_port rm (udp_port) (port_id)\n"
387 " Remove an UDP port for VXLAN packet filter on a port\n\n"
389 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
390 " Set hardware insertion of VLAN IDs (single or double VLAN "
391 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
393 "tx_vlan set pvid port_id vlan_id (on|off)\n"
394 " Set port based TX VLAN insertion.\n\n"
396 "tx_vlan reset (port_id)\n"
397 " Disable hardware insertion of a VLAN header in"
398 " packets sent on a port.\n\n"
400 "csum set (ip|udp|tcp|sctp|outer-ip|outer-udp) (hw|sw) (port_id)\n"
401 " Select hardware or software calculation of the"
402 " checksum when transmitting a packet using the"
403 " csum forward engine.\n"
404 " ip|udp|tcp|sctp always concern the inner layer.\n"
405 " outer-ip concerns the outer IP layer in"
406 " outer-udp concerns the outer UDP layer in"
407 " case the packet is recognized as a tunnel packet by"
408 " the forward engine (vxlan, gre and ipip are supported)\n"
409 " Please check the NIC datasheet for HW limits.\n\n"
411 "csum parse-tunnel (on|off) (tx_port_id)\n"
412 " If disabled, treat tunnel packets as non-tunneled"
413 " packets (treat inner headers as payload). The port\n"
414 " argument is the port used for TX in csum forward"
417 "csum show (port_id)\n"
418 " Display tx checksum offload configuration\n\n"
420 "tso set (segsize) (portid)\n"
421 " Enable TCP Segmentation Offload in csum forward"
423 " Please check the NIC datasheet for HW limits.\n\n"
426 " Display the status of TCP Segmentation Offload.\n\n"
428 "set port (port_id) gro on|off\n"
429 " Enable or disable Generic Receive Offload in"
430 " csum forwarding engine.\n\n"
432 "show port (port_id) gro\n"
433 " Display GRO configuration.\n\n"
435 "set gro flush (cycles)\n"
436 " Set the cycle to flush GROed packets from"
437 " reassembly tables.\n\n"
439 "set port (port_id) gso (on|off)"
440 " Enable or disable Generic Segmentation Offload in"
441 " csum forwarding engine.\n\n"
443 "set gso segsz (length)\n"
444 " Set max packet length for output GSO segments,"
445 " including packet header and payload.\n\n"
447 "show port (port_id) gso\n"
448 " Show GSO configuration.\n\n"
451 " Set packet forwarding mode.\n\n"
453 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
454 " Add a MAC address on port_id.\n\n"
456 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
457 " Remove a MAC address from port_id.\n\n"
459 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
460 " Set the default MAC address for port_id.\n\n"
462 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
463 " Add a MAC address for a VF on the port.\n\n"
465 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
466 " Set the MAC address for a VF from the PF.\n\n"
468 "set eth-peer (port_id) (peer_addr)\n"
469 " set the peer address for certain port.\n\n"
471 "set port (port_id) uta (mac_address|all) (on|off)\n"
472 " Add/Remove a or all unicast hash filter(s)"
475 "set promisc (port_id|all) (on|off)\n"
476 " Set the promiscuous mode on port_id, or all.\n\n"
478 "set allmulti (port_id|all) (on|off)\n"
479 " Set the allmulti mode on port_id, or all.\n\n"
481 "set vf promisc (port_id) (vf_id) (on|off)\n"
482 " Set unicast promiscuous mode for a VF from the PF.\n\n"
484 "set vf allmulti (port_id) (vf_id) (on|off)\n"
485 " Set multicast promiscuous mode for a VF from the PF.\n\n"
487 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
488 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
489 " (on|off) autoneg (on|off) (port_id)\n"
490 "set flow_ctrl rx (on|off) (portid)\n"
491 "set flow_ctrl tx (on|off) (portid)\n"
492 "set flow_ctrl high_water (high_water) (portid)\n"
493 "set flow_ctrl low_water (low_water) (portid)\n"
494 "set flow_ctrl pause_time (pause_time) (portid)\n"
495 "set flow_ctrl send_xon (send_xon) (portid)\n"
496 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
497 "set flow_ctrl autoneg (on|off) (port_id)\n"
498 " Set the link flow control parameter on a port.\n\n"
500 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
501 " (low_water) (pause_time) (priority) (port_id)\n"
502 " Set the priority flow control parameter on a"
505 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
506 " Set statistics mapping (qmapping 0..15) for RX/TX"
508 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
509 " on port 0 to mapping 5.\n\n"
511 "set xstats-hide-zero on|off\n"
512 " Set the option to hide the zero values"
513 " for xstats display.\n"
515 "set port (port_id) vf (vf_id) rx|tx on|off\n"
516 " Enable/Disable a VF receive/tranmit from a port\n\n"
518 "set port (port_id) vf (vf_id) (mac_addr)"
519 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
520 " Add/Remove unicast or multicast MAC addr filter"
523 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
525 " AUPE:accepts untagged VLAN;"
526 "ROPE:accept unicast hash\n\n"
527 " BAM:accepts broadcast packets;"
528 "MPE:accepts all multicast packets\n\n"
529 " Enable/Disable a VF receive mode of a port\n\n"
531 "set port (port_id) queue (queue_id) rate (rate_num)\n"
532 " Set rate limit for a queue of a port\n\n"
534 "set port (port_id) vf (vf_id) rate (rate_num) "
535 "queue_mask (queue_mask_value)\n"
536 " Set rate limit for queues in VF of a port\n\n"
538 "set port (port_id) mirror-rule (rule_id)"
539 " (pool-mirror-up|pool-mirror-down|vlan-mirror)"
540 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
541 " Set pool or vlan type mirror rule on a port.\n"
542 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
543 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
546 "set port (port_id) mirror-rule (rule_id)"
547 " (uplink-mirror|downlink-mirror) dst-pool"
548 " (pool_id) (on|off)\n"
549 " Set uplink or downlink type mirror rule on a port.\n"
550 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
551 " 0 on' enable mirror income traffic to pool 0.\n\n"
553 "reset port (port_id) mirror-rule (rule_id)\n"
554 " Reset a mirror rule.\n\n"
556 "set flush_rx (on|off)\n"
557 " Flush (default) or don't flush RX streams before"
558 " forwarding. Mainly used with PCAP drivers.\n\n"
560 "set bypass mode (normal|bypass|isolate) (port_id)\n"
561 " Set the bypass mode for the lowest port on bypass enabled"
564 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
565 "mode (normal|bypass|isolate) (port_id)\n"
566 " Set the event required to initiate specified bypass mode for"
567 " the lowest port on a bypass enabled NIC where:\n"
568 " timeout = enable bypass after watchdog timeout.\n"
569 " os_on = enable bypass when OS/board is powered on.\n"
570 " os_off = enable bypass when OS/board is powered off.\n"
571 " power_on = enable bypass when power supply is turned on.\n"
572 " power_off = enable bypass when power supply is turned off."
575 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
576 " Set the bypass watchdog timeout to 'n' seconds"
577 " where 0 = instant.\n\n"
579 "show bypass config (port_id)\n"
580 " Show the bypass configuration for a bypass enabled NIC"
581 " using the lowest port on the NIC.\n\n"
583 #ifdef RTE_LIBRTE_PMD_BOND
584 "create bonded device (mode) (socket)\n"
585 " Create a new bonded device with specific bonding mode and socket.\n\n"
587 "add bonding slave (slave_id) (port_id)\n"
588 " Add a slave device to a bonded device.\n\n"
590 "remove bonding slave (slave_id) (port_id)\n"
591 " Remove a slave device from a bonded device.\n\n"
593 "set bonding mode (value) (port_id)\n"
594 " Set the bonding mode on a bonded device.\n\n"
596 "set bonding primary (slave_id) (port_id)\n"
597 " Set the primary slave for a bonded device.\n\n"
599 "show bonding config (port_id)\n"
600 " Show the bonding config for port_id.\n\n"
602 "set bonding mac_addr (port_id) (address)\n"
603 " Set the MAC address of a bonded device.\n\n"
605 "set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)"
606 " Set Aggregation mode for IEEE802.3AD (mode 4)"
608 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
609 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
611 "set bonding mon_period (port_id) (value)\n"
612 " Set the bonding link status monitoring polling period in ms.\n\n"
614 "set bonding lacp dedicated_queues <port_id> (enable|disable)\n"
615 " Enable/disable dedicated queues for LACP control traffic.\n\n"
618 "set link-up port (port_id)\n"
619 " Set link up for a port.\n\n"
621 "set link-down port (port_id)\n"
622 " Set link down for a port.\n\n"
624 "E-tag set insertion on port-tag-id (value)"
625 " port (port_id) vf (vf_id)\n"
626 " Enable E-tag insertion for a VF on a port\n\n"
628 "E-tag set insertion off port (port_id) vf (vf_id)\n"
629 " Disable E-tag insertion for a VF on a port\n\n"
631 "E-tag set stripping (on|off) port (port_id)\n"
632 " Enable/disable E-tag stripping on a port\n\n"
634 "E-tag set forwarding (on|off) port (port_id)\n"
635 " Enable/disable E-tag based forwarding"
638 "E-tag set filter add e-tag-id (value) dst-pool"
639 " (pool_id) port (port_id)\n"
640 " Add an E-tag forwarding filter on a port\n\n"
642 "E-tag set filter del e-tag-id (value) port (port_id)\n"
643 " Delete an E-tag forwarding filter on a port\n\n"
645 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
646 "set port tm hierarchy default (port_id)\n"
647 " Set default traffic Management hierarchy on a port\n\n"
650 "ddp add (port_id) (profile_path[,backup_profile_path])\n"
651 " Load a profile package on a port\n\n"
653 "ddp del (port_id) (backup_profile_path)\n"
654 " Delete a profile package from a port\n\n"
656 "ptype mapping get (port_id) (valid_only)\n"
657 " Get ptype mapping on a port\n\n"
659 "ptype mapping replace (port_id) (target) (mask) (pky_type)\n"
660 " Replace target with the pkt_type in ptype mapping\n\n"
662 "ptype mapping reset (port_id)\n"
663 " Reset ptype mapping on a port\n\n"
665 "ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n"
666 " Update a ptype mapping item on a port\n\n"
668 "set port (port_id) queue-region region_id (value) "
669 "queue_start_index (value) queue_num (value)\n"
670 " Set a queue region on a port\n\n"
672 "set port (port_id) queue-region region_id (value) "
674 " Set a flowtype region index on a port\n\n"
676 "set port (port_id) queue-region UP (value) region_id (value)\n"
677 " Set the mapping of User Priority to "
678 "queue region on a port\n\n"
680 "set port (port_id) queue-region flush (on|off)\n"
681 " flush all queue region related configuration\n\n"
683 "show port meter cap (port_id)\n"
684 " Show port meter capability information\n\n"
686 "add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs)\n"
687 " meter profile add - srtcm rfc 2697\n\n"
689 "add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs)\n"
690 " meter profile add - trtcm rfc 2698\n\n"
692 "add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs)\n"
693 " meter profile add - trtcm rfc 4115\n\n"
695 "del port meter profile (port_id) (profile_id)\n"
696 " meter profile delete\n\n"
698 "create port meter (port_id) (mtr_id) (profile_id) (meter_enable)\n"
699 "(g_action) (y_action) (r_action) (stats_mask) (shared)\n"
700 "(use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n"
701 "(dscp_tbl_entry63)]\n"
704 "enable port meter (port_id) (mtr_id)\n"
707 "disable port meter (port_id) (mtr_id)\n"
710 "del port meter (port_id) (mtr_id)\n"
713 "set port meter profile (port_id) (mtr_id) (profile_id)\n"
714 " meter update meter profile\n\n"
716 "set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n"
717 "(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n"
718 " update meter dscp table entries\n\n"
720 "set port meter policer action (port_id) (mtr_id) (action_mask)\n"
721 "(action0) [(action1) (action2)]\n"
722 " meter update policer action\n\n"
724 "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
725 " meter update stats\n\n"
727 "show port (port_id) queue-region\n"
728 " show all queue region related configuration info\n\n"
730 "add port tm node shaper profile (port_id) (shaper_profile_id)"
731 " (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)"
732 " (packet_length_adjust)\n"
733 " Add port tm node private shaper profile.\n\n"
735 "del port tm node shaper profile (port_id) (shaper_profile_id)\n"
736 " Delete port tm node private shaper profile.\n\n"
738 "add port tm node shared shaper (port_id) (shared_shaper_id)"
739 " (shaper_profile_id)\n"
740 " Add/update port tm node shared shaper.\n\n"
742 "del port tm node shared shaper (port_id) (shared_shaper_id)\n"
743 " Delete port tm node shared shaper.\n\n"
745 "set port tm node shaper profile (port_id) (node_id)"
746 " (shaper_profile_id)\n"
747 " Set port tm node shaper profile.\n\n"
749 "add port tm node wred profile (port_id) (wred_profile_id)"
750 " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
751 " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
752 " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
753 " Add port tm node wred profile.\n\n"
755 "del port tm node wred profile (port_id) (wred_profile_id)\n"
756 " Delete port tm node wred profile.\n\n"
758 "add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
759 " (priority) (weight) (level_id) (shaper_profile_id)"
760 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
761 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
762 " Add port tm nonleaf node.\n\n"
764 "add port tm leaf node (port_id) (node_id) (parent_node_id)"
765 " (priority) (weight) (level_id) (shaper_profile_id)"
766 " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
767 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
768 " Add port tm leaf node.\n\n"
770 "del port tm node (port_id) (node_id)\n"
771 " Delete port tm node.\n\n"
773 "set port tm node parent (port_id) (node_id) (parent_node_id)"
774 " (priority) (weight)\n"
775 " Set port tm node parent.\n\n"
777 "suspend port tm node (port_id) (node_id)"
778 " Suspend tm node.\n\n"
780 "resume port tm node (port_id) (node_id)"
781 " Resume tm node.\n\n"
783 "port tm hierarchy commit (port_id) (clean_on_fail)\n"
784 " Commit tm hierarchy.\n\n"
786 "vxlan ip-version (ipv4|ipv6) vni (vni) udp-src"
787 " (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst"
788 " (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n"
789 " Configure the VXLAN encapsulation for flows.\n\n"
791 "vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)"
792 " udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)"
793 " ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)"
794 " eth-dst (eth-dst)\n"
795 " Configure the VXLAN encapsulation for flows.\n\n"
797 "nvgre ip-version (ipv4|ipv6) tni (tni) ip-src"
798 " (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst"
800 " Configure the NVGRE encapsulation for flows.\n\n"
802 "nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)"
803 " ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)"
804 " eth-src (eth-src) eth-dst (eth-dst)\n"
805 " Configure the NVGRE encapsulation for flows.\n\n"
807 , list_pkt_forwarding_modes()
811 if (show_all || !strcmp(res->section, "ports")) {
817 "----------------\n\n"
819 "port start (port_id|all)\n"
820 " Start all ports or port_id.\n\n"
822 "port stop (port_id|all)\n"
823 " Stop all ports or port_id.\n\n"
825 "port close (port_id|all)\n"
826 " Close all ports or port_id.\n\n"
828 "port attach (ident)\n"
829 " Attach physical or virtual dev by pci address or virtual device name\n\n"
831 "port detach (port_id)\n"
832 " Detach physical or virtual dev by port_id\n\n"
834 "port config (port_id|all)"
835 " speed (10|100|1000|10000|25000|40000|50000|100000|auto)"
836 " duplex (half|full|auto)\n"
837 " Set speed and duplex for all ports or port_id\n\n"
839 "port config (port_id|all) loopback (mode)\n"
840 " Set loopback mode for all ports or port_id\n\n"
842 "port config all (rxq|txq|rxd|txd) (value)\n"
843 " Set number for rxq/txq/rxd/txd.\n\n"
845 "port config all max-pkt-len (value)\n"
846 " Set the max packet length.\n\n"
848 "port config all (crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|hw-vlan-filter|"
849 "hw-vlan-strip|hw-vlan-extend|drop-en)"
851 " Set crc-strip/scatter/rx-checksum/hardware-vlan/drop_en"
854 "port config all rss (all|default|ip|tcp|udp|sctp|"
855 "ether|port|vxlan|geneve|nvgre|none|<flowtype_id>)\n"
856 " Set the RSS mode.\n\n"
858 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
859 " Set the RSS redirection table.\n\n"
861 "port config (port_id) dcb vt (on|off) (traffic_class)"
863 " Set the DCB mode.\n\n"
865 "port config all burst (value)\n"
866 " Set the number of packets per burst.\n\n"
868 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
870 " Set the ring prefetch/host/writeback threshold"
871 " for tx/rx queue.\n\n"
873 "port config all (txfreet|txrst|rxfreet) (value)\n"
874 " Set free threshold for rx/tx, or set"
875 " tx rs bit threshold.\n\n"
876 "port config mtu X value\n"
877 " Set the MTU of port X to a given value\n\n"
879 "port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n"
880 " Set a rx/tx queue's ring size configuration, the new"
881 " value will take effect after command that (re-)start the port"
882 " or command that setup the specific queue\n\n"
884 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
885 " Start/stop a rx/tx queue of port X. Only take effect"
886 " when port X is started\n\n"
888 "port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n"
889 " Switch on/off a deferred start of port X rx/tx queue. Only"
890 " take effect when port X is stopped.\n\n"
892 "port (port_id) (rxq|txq) (queue_id) setup\n"
893 " Setup a rx/tx queue of port X.\n\n"
895 "port config (port_id|all) l2-tunnel E-tag ether-type"
897 " Set the value of E-tag ether-type.\n\n"
899 "port config (port_id|all) l2-tunnel E-tag"
900 " (enable|disable)\n"
901 " Enable/disable the E-tag support.\n\n"
903 "port config (port_id) pctype mapping reset\n"
904 " Reset flow type to pctype mapping on a port\n\n"
906 "port config (port_id) pctype mapping update"
907 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
908 " Update a flow type to pctype mapping item on a port\n\n"
910 "port config (port_id) pctype (pctype_id) hash_inset|"
911 "fdir_inset|fdir_flx_inset get|set|clear field\n"
913 " Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n"
915 "port config (port_id) pctype (pctype_id) hash_inset|"
916 "fdir_inset|fdir_flx_inset clear all"
917 " Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n"
919 "port config (port_id) udp_tunnel_port add|rm vxlan|geneve (udp_port)\n\n"
920 " Add/remove UDP tunnel port for tunneling offload\n\n"
924 if (show_all || !strcmp(res->section, "registers")) {
932 "read reg (port_id) (address)\n"
933 " Display value of a port register.\n\n"
935 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
936 " Display a port register bit field.\n\n"
938 "read regbit (port_id) (address) (bit_x)\n"
939 " Display a single port register bit.\n\n"
941 "write reg (port_id) (address) (value)\n"
942 " Set value of a port register.\n\n"
944 "write regfield (port_id) (address) (bit_x) (bit_y)"
946 " Set bit field of a port register.\n\n"
948 "write regbit (port_id) (address) (bit_x) (value)\n"
949 " Set single bit value of a port register.\n\n"
952 if (show_all || !strcmp(res->section, "filters")) {
960 "ethertype_filter (port_id) (add|del)"
961 " (mac_addr|mac_ignr) (mac_address) ethertype"
962 " (ether_type) (drop|fwd) queue (queue_id)\n"
963 " Add/Del an ethertype filter.\n\n"
965 "2tuple_filter (port_id) (add|del)"
966 " dst_port (dst_port_value) protocol (protocol_value)"
967 " mask (mask_value) tcp_flags (tcp_flags_value)"
968 " priority (prio_value) queue (queue_id)\n"
969 " Add/Del a 2tuple filter.\n\n"
971 "5tuple_filter (port_id) (add|del)"
972 " dst_ip (dst_address) src_ip (src_address)"
973 " dst_port (dst_port_value) src_port (src_port_value)"
974 " protocol (protocol_value)"
975 " mask (mask_value) tcp_flags (tcp_flags_value)"
976 " priority (prio_value) queue (queue_id)\n"
977 " Add/Del a 5tuple filter.\n\n"
979 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
980 " Add/Del syn filter.\n\n"
982 "flex_filter (port_id) (add|del) len (len_value)"
983 " bytes (bytes_value) mask (mask_value)"
984 " priority (prio_value) queue (queue_id)\n"
985 " Add/Del a flex filter.\n\n"
987 "flow_director_filter (port_id) mode IP (add|del|update)"
988 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
989 " src (src_ip_address) dst (dst_ip_address)"
990 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
991 " vlan (vlan_value) flexbytes (flexbytes_value)"
992 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
993 " fd_id (fd_id_value)\n"
994 " Add/Del an IP type flow director filter.\n\n"
996 "flow_director_filter (port_id) mode IP (add|del|update)"
997 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
998 " src (src_ip_address) (src_port)"
999 " dst (dst_ip_address) (dst_port)"
1000 " tos (tos_value) ttl (ttl_value)"
1001 " vlan (vlan_value) flexbytes (flexbytes_value)"
1002 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
1003 " fd_id (fd_id_value)\n"
1004 " Add/Del an UDP/TCP type flow director filter.\n\n"
1006 "flow_director_filter (port_id) mode IP (add|del|update)"
1007 " flow (ipv4-sctp|ipv6-sctp)"
1008 " src (src_ip_address) (src_port)"
1009 " dst (dst_ip_address) (dst_port)"
1010 " tag (verification_tag) "
1011 " tos (tos_value) ttl (ttl_value)"
1012 " vlan (vlan_value)"
1013 " flexbytes (flexbytes_value) (drop|fwd)"
1014 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
1015 " Add/Del a SCTP type flow director filter.\n\n"
1017 "flow_director_filter (port_id) mode IP (add|del|update)"
1018 " flow l2_payload ether (ethertype)"
1019 " flexbytes (flexbytes_value) (drop|fwd)"
1020 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
1021 " Add/Del a l2 payload type flow director filter.\n\n"
1023 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
1024 " mac (mac_address) vlan (vlan_value)"
1025 " flexbytes (flexbytes_value) (drop|fwd)"
1026 " queue (queue_id) fd_id (fd_id_value)\n"
1027 " Add/Del a MAC-VLAN flow director filter.\n\n"
1029 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
1030 " mac (mac_address) vlan (vlan_value)"
1031 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
1032 " flexbytes (flexbytes_value) (drop|fwd)"
1033 " queue (queue_id) fd_id (fd_id_value)\n"
1034 " Add/Del a Tunnel flow director filter.\n\n"
1036 "flow_director_filter (port_id) mode raw (add|del|update)"
1037 " flow (flow_id) (drop|fwd) queue (queue_id)"
1038 " fd_id (fd_id_value) packet (packet file name)\n"
1039 " Add/Del a raw type flow director filter.\n\n"
1041 "flush_flow_director (port_id)\n"
1042 " Flush all flow director entries of a device.\n\n"
1044 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
1045 " src_mask (ipv4_src) (ipv6_src) (src_port)"
1046 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
1047 " Set flow director IP mask.\n\n"
1049 "flow_director_mask (port_id) mode MAC-VLAN"
1050 " vlan (vlan_value)\n"
1051 " Set flow director MAC-VLAN mask.\n\n"
1053 "flow_director_mask (port_id) mode Tunnel"
1054 " vlan (vlan_value) mac (mac_value)"
1055 " tunnel-type (tunnel_type_value)"
1056 " tunnel-id (tunnel_id_value)\n"
1057 " Set flow director Tunnel mask.\n\n"
1059 "flow_director_flex_mask (port_id)"
1060 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
1061 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
1063 " Configure mask of flex payload.\n\n"
1065 "flow_director_flex_payload (port_id)"
1066 " (raw|l2|l3|l4) (config)\n"
1067 " Configure flex payload selection.\n\n"
1069 "get_sym_hash_ena_per_port (port_id)\n"
1070 " get symmetric hash enable configuration per port.\n\n"
1072 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
1073 " set symmetric hash enable configuration per port"
1074 " to enable or disable.\n\n"
1076 "get_hash_global_config (port_id)\n"
1077 " Get the global configurations of hash filters.\n\n"
1079 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)"
1080 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1081 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
1082 " (enable|disable)\n"
1083 " Set the global configurations of hash filters.\n\n"
1085 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
1086 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1087 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1088 "l2_payload|<flowtype_id>) (ovlan|ivlan|src-ipv4|dst-ipv4|"
1089 "src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
1090 "ipv6-next-header|udp-src-port|udp-dst-port|"
1091 "tcp-src-port|tcp-dst-port|sctp-src-port|"
1092 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
1093 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
1094 "fld-8th|none) (select|add)\n"
1095 " Set the input set for hash.\n\n"
1097 "set_fdir_input_set (port_id) "
1098 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1099 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1100 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
1101 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
1102 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
1103 "udp-dst-port|tcp-src-port|tcp-dst-port|"
1104 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
1106 " Set the input set for FDir.\n\n"
1108 "flow validate {port_id}"
1109 " [group {group_id}] [priority {level}]"
1110 " [ingress] [egress]"
1111 " pattern {item} [/ {item} [...]] / end"
1112 " actions {action} [/ {action} [...]] / end\n"
1113 " Check whether a flow rule can be created.\n\n"
1115 "flow create {port_id}"
1116 " [group {group_id}] [priority {level}]"
1117 " [ingress] [egress]"
1118 " pattern {item} [/ {item} [...]] / end"
1119 " actions {action} [/ {action} [...]] / end\n"
1120 " Create a flow rule.\n\n"
1122 "flow destroy {port_id} rule {rule_id} [...]\n"
1123 " Destroy specific flow rules.\n\n"
1125 "flow flush {port_id}\n"
1126 " Destroy all flow rules.\n\n"
1128 "flow query {port_id} {rule_id} {action}\n"
1129 " Query an existing flow rule.\n\n"
1131 "flow list {port_id} [group {group_id}] [...]\n"
1132 " List existing flow rules sorted by priority,"
1133 " filtered by group identifiers.\n\n"
1135 "flow isolate {port_id} {boolean}\n"
1136 " Restrict ingress traffic to the defined"
1142 cmdline_parse_token_string_t cmd_help_long_help =
1143 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1145 cmdline_parse_token_string_t cmd_help_long_section =
1146 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1147 "all#control#display#config#"
1148 "ports#registers#filters");
1150 cmdline_parse_inst_t cmd_help_long = {
1151 .f = cmd_help_long_parsed,
1153 .help_str = "help all|control|display|config|ports|register|filters: "
1156 (void *)&cmd_help_long_help,
1157 (void *)&cmd_help_long_section,
1163 /* *** start/stop/close all ports *** */
1164 struct cmd_operate_port_result {
1165 cmdline_fixed_string_t keyword;
1166 cmdline_fixed_string_t name;
1167 cmdline_fixed_string_t value;
1170 static void cmd_operate_port_parsed(void *parsed_result,
1171 __attribute__((unused)) struct cmdline *cl,
1172 __attribute__((unused)) void *data)
1174 struct cmd_operate_port_result *res = parsed_result;
1176 if (!strcmp(res->name, "start"))
1177 start_port(RTE_PORT_ALL);
1178 else if (!strcmp(res->name, "stop"))
1179 stop_port(RTE_PORT_ALL);
1180 else if (!strcmp(res->name, "close"))
1181 close_port(RTE_PORT_ALL);
1182 else if (!strcmp(res->name, "reset"))
1183 reset_port(RTE_PORT_ALL);
1185 printf("Unknown parameter\n");
1188 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1189 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1191 cmdline_parse_token_string_t cmd_operate_port_all_port =
1192 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1193 "start#stop#close#reset");
1194 cmdline_parse_token_string_t cmd_operate_port_all_all =
1195 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1197 cmdline_parse_inst_t cmd_operate_port = {
1198 .f = cmd_operate_port_parsed,
1200 .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports",
1202 (void *)&cmd_operate_port_all_cmd,
1203 (void *)&cmd_operate_port_all_port,
1204 (void *)&cmd_operate_port_all_all,
1209 /* *** start/stop/close specific port *** */
1210 struct cmd_operate_specific_port_result {
1211 cmdline_fixed_string_t keyword;
1212 cmdline_fixed_string_t name;
1216 static void cmd_operate_specific_port_parsed(void *parsed_result,
1217 __attribute__((unused)) struct cmdline *cl,
1218 __attribute__((unused)) void *data)
1220 struct cmd_operate_specific_port_result *res = parsed_result;
1222 if (!strcmp(res->name, "start"))
1223 start_port(res->value);
1224 else if (!strcmp(res->name, "stop"))
1225 stop_port(res->value);
1226 else if (!strcmp(res->name, "close"))
1227 close_port(res->value);
1228 else if (!strcmp(res->name, "reset"))
1229 reset_port(res->value);
1231 printf("Unknown parameter\n");
1234 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1235 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1237 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1238 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1239 name, "start#stop#close#reset");
1240 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1241 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1244 cmdline_parse_inst_t cmd_operate_specific_port = {
1245 .f = cmd_operate_specific_port_parsed,
1247 .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id",
1249 (void *)&cmd_operate_specific_port_cmd,
1250 (void *)&cmd_operate_specific_port_port,
1251 (void *)&cmd_operate_specific_port_id,
1256 /* *** enable port setup (after attach) via iterator or event *** */
1257 struct cmd_set_port_setup_on_result {
1258 cmdline_fixed_string_t set;
1259 cmdline_fixed_string_t port;
1260 cmdline_fixed_string_t setup;
1261 cmdline_fixed_string_t on;
1262 cmdline_fixed_string_t mode;
1265 static void cmd_set_port_setup_on_parsed(void *parsed_result,
1266 __attribute__((unused)) struct cmdline *cl,
1267 __attribute__((unused)) void *data)
1269 struct cmd_set_port_setup_on_result *res = parsed_result;
1271 if (strcmp(res->mode, "event") == 0)
1272 setup_on_probe_event = true;
1273 else if (strcmp(res->mode, "iterator") == 0)
1274 setup_on_probe_event = false;
1276 printf("Unknown mode\n");
1279 cmdline_parse_token_string_t cmd_set_port_setup_on_set =
1280 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1282 cmdline_parse_token_string_t cmd_set_port_setup_on_port =
1283 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1285 cmdline_parse_token_string_t cmd_set_port_setup_on_setup =
1286 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1288 cmdline_parse_token_string_t cmd_set_port_setup_on_on =
1289 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1291 cmdline_parse_token_string_t cmd_set_port_setup_on_mode =
1292 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1293 mode, "iterator#event");
1295 cmdline_parse_inst_t cmd_set_port_setup_on = {
1296 .f = cmd_set_port_setup_on_parsed,
1298 .help_str = "set port setup on iterator|event",
1300 (void *)&cmd_set_port_setup_on_set,
1301 (void *)&cmd_set_port_setup_on_port,
1302 (void *)&cmd_set_port_setup_on_setup,
1303 (void *)&cmd_set_port_setup_on_on,
1304 (void *)&cmd_set_port_setup_on_mode,
1309 /* *** attach a specified port *** */
1310 struct cmd_operate_attach_port_result {
1311 cmdline_fixed_string_t port;
1312 cmdline_fixed_string_t keyword;
1313 cmdline_fixed_string_t identifier;
1316 static void cmd_operate_attach_port_parsed(void *parsed_result,
1317 __attribute__((unused)) struct cmdline *cl,
1318 __attribute__((unused)) void *data)
1320 struct cmd_operate_attach_port_result *res = parsed_result;
1322 if (!strcmp(res->keyword, "attach"))
1323 attach_port(res->identifier);
1325 printf("Unknown parameter\n");
1328 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1329 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1331 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1332 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1334 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1335 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1338 cmdline_parse_inst_t cmd_operate_attach_port = {
1339 .f = cmd_operate_attach_port_parsed,
1341 .help_str = "port attach <identifier>: "
1342 "(identifier: pci address or virtual dev name)",
1344 (void *)&cmd_operate_attach_port_port,
1345 (void *)&cmd_operate_attach_port_keyword,
1346 (void *)&cmd_operate_attach_port_identifier,
1351 /* *** detach a specified port *** */
1352 struct cmd_operate_detach_port_result {
1353 cmdline_fixed_string_t port;
1354 cmdline_fixed_string_t keyword;
1358 static void cmd_operate_detach_port_parsed(void *parsed_result,
1359 __attribute__((unused)) struct cmdline *cl,
1360 __attribute__((unused)) void *data)
1362 struct cmd_operate_detach_port_result *res = parsed_result;
1364 if (!strcmp(res->keyword, "detach"))
1365 detach_port_device(res->port_id);
1367 printf("Unknown parameter\n");
1370 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1371 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1373 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1374 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1376 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1377 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1380 cmdline_parse_inst_t cmd_operate_detach_port = {
1381 .f = cmd_operate_detach_port_parsed,
1383 .help_str = "port detach <port_id>",
1385 (void *)&cmd_operate_detach_port_port,
1386 (void *)&cmd_operate_detach_port_keyword,
1387 (void *)&cmd_operate_detach_port_port_id,
1392 /* *** configure speed for all ports *** */
1393 struct cmd_config_speed_all {
1394 cmdline_fixed_string_t port;
1395 cmdline_fixed_string_t keyword;
1396 cmdline_fixed_string_t all;
1397 cmdline_fixed_string_t item1;
1398 cmdline_fixed_string_t item2;
1399 cmdline_fixed_string_t value1;
1400 cmdline_fixed_string_t value2;
1404 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1409 if (!strcmp(duplexstr, "half")) {
1410 duplex = ETH_LINK_HALF_DUPLEX;
1411 } else if (!strcmp(duplexstr, "full")) {
1412 duplex = ETH_LINK_FULL_DUPLEX;
1413 } else if (!strcmp(duplexstr, "auto")) {
1414 duplex = ETH_LINK_FULL_DUPLEX;
1416 printf("Unknown duplex parameter\n");
1420 if (!strcmp(speedstr, "10")) {
1421 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1422 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1423 } else if (!strcmp(speedstr, "100")) {
1424 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1425 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1427 if (duplex != ETH_LINK_FULL_DUPLEX) {
1428 printf("Invalid speed/duplex parameters\n");
1431 if (!strcmp(speedstr, "1000")) {
1432 *speed = ETH_LINK_SPEED_1G;
1433 } else if (!strcmp(speedstr, "10000")) {
1434 *speed = ETH_LINK_SPEED_10G;
1435 } else if (!strcmp(speedstr, "25000")) {
1436 *speed = ETH_LINK_SPEED_25G;
1437 } else if (!strcmp(speedstr, "40000")) {
1438 *speed = ETH_LINK_SPEED_40G;
1439 } else if (!strcmp(speedstr, "50000")) {
1440 *speed = ETH_LINK_SPEED_50G;
1441 } else if (!strcmp(speedstr, "100000")) {
1442 *speed = ETH_LINK_SPEED_100G;
1443 } else if (!strcmp(speedstr, "auto")) {
1444 *speed = ETH_LINK_SPEED_AUTONEG;
1446 printf("Unknown speed parameter\n");
1455 cmd_config_speed_all_parsed(void *parsed_result,
1456 __attribute__((unused)) struct cmdline *cl,
1457 __attribute__((unused)) void *data)
1459 struct cmd_config_speed_all *res = parsed_result;
1460 uint32_t link_speed;
1463 if (!all_ports_stopped()) {
1464 printf("Please stop all ports first\n");
1468 if (parse_and_check_speed_duplex(res->value1, res->value2,
1472 RTE_ETH_FOREACH_DEV(pid) {
1473 ports[pid].dev_conf.link_speeds = link_speed;
1476 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1479 cmdline_parse_token_string_t cmd_config_speed_all_port =
1480 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1481 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1482 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1484 cmdline_parse_token_string_t cmd_config_speed_all_all =
1485 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1486 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1487 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1488 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1489 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1490 "10#100#1000#10000#25000#40000#50000#100000#auto");
1491 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1492 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1493 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1494 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1497 cmdline_parse_inst_t cmd_config_speed_all = {
1498 .f = cmd_config_speed_all_parsed,
1500 .help_str = "port config all speed "
1501 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1504 (void *)&cmd_config_speed_all_port,
1505 (void *)&cmd_config_speed_all_keyword,
1506 (void *)&cmd_config_speed_all_all,
1507 (void *)&cmd_config_speed_all_item1,
1508 (void *)&cmd_config_speed_all_value1,
1509 (void *)&cmd_config_speed_all_item2,
1510 (void *)&cmd_config_speed_all_value2,
1515 /* *** configure speed for specific port *** */
1516 struct cmd_config_speed_specific {
1517 cmdline_fixed_string_t port;
1518 cmdline_fixed_string_t keyword;
1520 cmdline_fixed_string_t item1;
1521 cmdline_fixed_string_t item2;
1522 cmdline_fixed_string_t value1;
1523 cmdline_fixed_string_t value2;
1527 cmd_config_speed_specific_parsed(void *parsed_result,
1528 __attribute__((unused)) struct cmdline *cl,
1529 __attribute__((unused)) void *data)
1531 struct cmd_config_speed_specific *res = parsed_result;
1532 uint32_t link_speed;
1534 if (!all_ports_stopped()) {
1535 printf("Please stop all ports first\n");
1539 if (port_id_is_invalid(res->id, ENABLED_WARN))
1542 if (parse_and_check_speed_duplex(res->value1, res->value2,
1546 ports[res->id].dev_conf.link_speeds = link_speed;
1548 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1552 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1553 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1555 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1556 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1558 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1559 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT16);
1560 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1561 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1563 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1564 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1565 "10#100#1000#10000#25000#40000#50000#100000#auto");
1566 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1567 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1569 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1570 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1573 cmdline_parse_inst_t cmd_config_speed_specific = {
1574 .f = cmd_config_speed_specific_parsed,
1576 .help_str = "port config <port_id> speed "
1577 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1580 (void *)&cmd_config_speed_specific_port,
1581 (void *)&cmd_config_speed_specific_keyword,
1582 (void *)&cmd_config_speed_specific_id,
1583 (void *)&cmd_config_speed_specific_item1,
1584 (void *)&cmd_config_speed_specific_value1,
1585 (void *)&cmd_config_speed_specific_item2,
1586 (void *)&cmd_config_speed_specific_value2,
1591 /* *** configure loopback for all ports *** */
1592 struct cmd_config_loopback_all {
1593 cmdline_fixed_string_t port;
1594 cmdline_fixed_string_t keyword;
1595 cmdline_fixed_string_t all;
1596 cmdline_fixed_string_t item;
1601 cmd_config_loopback_all_parsed(void *parsed_result,
1602 __attribute__((unused)) struct cmdline *cl,
1603 __attribute__((unused)) void *data)
1605 struct cmd_config_loopback_all *res = parsed_result;
1608 if (!all_ports_stopped()) {
1609 printf("Please stop all ports first\n");
1613 RTE_ETH_FOREACH_DEV(pid) {
1614 ports[pid].dev_conf.lpbk_mode = res->mode;
1617 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1620 cmdline_parse_token_string_t cmd_config_loopback_all_port =
1621 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1622 cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1623 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1625 cmdline_parse_token_string_t cmd_config_loopback_all_all =
1626 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1627 cmdline_parse_token_string_t cmd_config_loopback_all_item =
1628 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1630 cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1631 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, UINT32);
1633 cmdline_parse_inst_t cmd_config_loopback_all = {
1634 .f = cmd_config_loopback_all_parsed,
1636 .help_str = "port config all loopback <mode>",
1638 (void *)&cmd_config_loopback_all_port,
1639 (void *)&cmd_config_loopback_all_keyword,
1640 (void *)&cmd_config_loopback_all_all,
1641 (void *)&cmd_config_loopback_all_item,
1642 (void *)&cmd_config_loopback_all_mode,
1647 /* *** configure loopback for specific port *** */
1648 struct cmd_config_loopback_specific {
1649 cmdline_fixed_string_t port;
1650 cmdline_fixed_string_t keyword;
1652 cmdline_fixed_string_t item;
1657 cmd_config_loopback_specific_parsed(void *parsed_result,
1658 __attribute__((unused)) struct cmdline *cl,
1659 __attribute__((unused)) void *data)
1661 struct cmd_config_loopback_specific *res = parsed_result;
1663 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1666 if (!port_is_stopped(res->port_id)) {
1667 printf("Please stop port %u first\n", res->port_id);
1671 ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1673 cmd_reconfig_device_queue(res->port_id, 1, 1);
1677 cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1678 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1680 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1681 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1683 cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1684 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1686 cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1687 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1689 cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1690 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1693 cmdline_parse_inst_t cmd_config_loopback_specific = {
1694 .f = cmd_config_loopback_specific_parsed,
1696 .help_str = "port config <port_id> loopback <mode>",
1698 (void *)&cmd_config_loopback_specific_port,
1699 (void *)&cmd_config_loopback_specific_keyword,
1700 (void *)&cmd_config_loopback_specific_id,
1701 (void *)&cmd_config_loopback_specific_item,
1702 (void *)&cmd_config_loopback_specific_mode,
1707 /* *** configure txq/rxq, txd/rxd *** */
1708 struct cmd_config_rx_tx {
1709 cmdline_fixed_string_t port;
1710 cmdline_fixed_string_t keyword;
1711 cmdline_fixed_string_t all;
1712 cmdline_fixed_string_t name;
1717 cmd_config_rx_tx_parsed(void *parsed_result,
1718 __attribute__((unused)) struct cmdline *cl,
1719 __attribute__((unused)) void *data)
1721 struct cmd_config_rx_tx *res = parsed_result;
1723 if (!all_ports_stopped()) {
1724 printf("Please stop all ports first\n");
1727 if (!strcmp(res->name, "rxq")) {
1728 if (!res->value && !nb_txq) {
1729 printf("Warning: Either rx or tx queues should be non zero\n");
1732 if (check_nb_rxq(res->value) != 0)
1734 nb_rxq = res->value;
1736 else if (!strcmp(res->name, "txq")) {
1737 if (!res->value && !nb_rxq) {
1738 printf("Warning: Either rx or tx queues should be non zero\n");
1741 if (check_nb_txq(res->value) != 0)
1743 nb_txq = res->value;
1745 else if (!strcmp(res->name, "rxd")) {
1746 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1747 printf("rxd %d invalid - must be > 0 && <= %d\n",
1748 res->value, RTE_TEST_RX_DESC_MAX);
1751 nb_rxd = res->value;
1752 } else if (!strcmp(res->name, "txd")) {
1753 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1754 printf("txd %d invalid - must be > 0 && <= %d\n",
1755 res->value, RTE_TEST_TX_DESC_MAX);
1758 nb_txd = res->value;
1760 printf("Unknown parameter\n");
1768 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1771 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1772 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1773 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1774 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1775 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1776 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1777 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1778 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1780 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1781 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1783 cmdline_parse_inst_t cmd_config_rx_tx = {
1784 .f = cmd_config_rx_tx_parsed,
1786 .help_str = "port config all rxq|txq|rxd|txd <value>",
1788 (void *)&cmd_config_rx_tx_port,
1789 (void *)&cmd_config_rx_tx_keyword,
1790 (void *)&cmd_config_rx_tx_all,
1791 (void *)&cmd_config_rx_tx_name,
1792 (void *)&cmd_config_rx_tx_value,
1797 /* *** config max packet length *** */
1798 struct cmd_config_max_pkt_len_result {
1799 cmdline_fixed_string_t port;
1800 cmdline_fixed_string_t keyword;
1801 cmdline_fixed_string_t all;
1802 cmdline_fixed_string_t name;
1807 cmd_config_max_pkt_len_parsed(void *parsed_result,
1808 __attribute__((unused)) struct cmdline *cl,
1809 __attribute__((unused)) void *data)
1811 struct cmd_config_max_pkt_len_result *res = parsed_result;
1814 if (!all_ports_stopped()) {
1815 printf("Please stop all ports first\n");
1819 RTE_ETH_FOREACH_DEV(pid) {
1820 struct rte_port *port = &ports[pid];
1821 uint64_t rx_offloads = port->dev_conf.rxmode.offloads;
1823 if (!strcmp(res->name, "max-pkt-len")) {
1824 if (res->value < ETHER_MIN_LEN) {
1825 printf("max-pkt-len can not be less than %d\n",
1829 if (res->value == port->dev_conf.rxmode.max_rx_pkt_len)
1832 port->dev_conf.rxmode.max_rx_pkt_len = res->value;
1833 if (res->value > ETHER_MAX_LEN)
1834 rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
1836 rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
1837 port->dev_conf.rxmode.offloads = rx_offloads;
1839 printf("Unknown parameter\n");
1846 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1849 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1850 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1852 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1853 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1855 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1856 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1858 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1859 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1861 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1862 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1865 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1866 .f = cmd_config_max_pkt_len_parsed,
1868 .help_str = "port config all max-pkt-len <value>",
1870 (void *)&cmd_config_max_pkt_len_port,
1871 (void *)&cmd_config_max_pkt_len_keyword,
1872 (void *)&cmd_config_max_pkt_len_all,
1873 (void *)&cmd_config_max_pkt_len_name,
1874 (void *)&cmd_config_max_pkt_len_value,
1879 /* *** configure port MTU *** */
1880 struct cmd_config_mtu_result {
1881 cmdline_fixed_string_t port;
1882 cmdline_fixed_string_t keyword;
1883 cmdline_fixed_string_t mtu;
1889 cmd_config_mtu_parsed(void *parsed_result,
1890 __attribute__((unused)) struct cmdline *cl,
1891 __attribute__((unused)) void *data)
1893 struct cmd_config_mtu_result *res = parsed_result;
1895 if (res->value < ETHER_MIN_LEN) {
1896 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1899 port_mtu_set(res->port_id, res->value);
1902 cmdline_parse_token_string_t cmd_config_mtu_port =
1903 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1905 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1906 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1908 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1909 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1911 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1912 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT16);
1913 cmdline_parse_token_num_t cmd_config_mtu_value =
1914 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1916 cmdline_parse_inst_t cmd_config_mtu = {
1917 .f = cmd_config_mtu_parsed,
1919 .help_str = "port config mtu <port_id> <value>",
1921 (void *)&cmd_config_mtu_port,
1922 (void *)&cmd_config_mtu_keyword,
1923 (void *)&cmd_config_mtu_mtu,
1924 (void *)&cmd_config_mtu_port_id,
1925 (void *)&cmd_config_mtu_value,
1930 /* *** configure rx mode *** */
1931 struct cmd_config_rx_mode_flag {
1932 cmdline_fixed_string_t port;
1933 cmdline_fixed_string_t keyword;
1934 cmdline_fixed_string_t all;
1935 cmdline_fixed_string_t name;
1936 cmdline_fixed_string_t value;
1940 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1941 __attribute__((unused)) struct cmdline *cl,
1942 __attribute__((unused)) void *data)
1944 struct cmd_config_rx_mode_flag *res = parsed_result;
1947 if (!all_ports_stopped()) {
1948 printf("Please stop all ports first\n");
1952 RTE_ETH_FOREACH_DEV(pid) {
1953 struct rte_port *port;
1954 uint64_t rx_offloads;
1957 rx_offloads = port->dev_conf.rxmode.offloads;
1958 if (!strcmp(res->name, "crc-strip")) {
1959 if (!strcmp(res->value, "on")) {
1960 rx_offloads &= ~DEV_RX_OFFLOAD_KEEP_CRC;
1961 } else if (!strcmp(res->value, "off")) {
1962 rx_offloads |= DEV_RX_OFFLOAD_KEEP_CRC;
1964 printf("Unknown parameter\n");
1967 } else if (!strcmp(res->name, "scatter")) {
1968 if (!strcmp(res->value, "on")) {
1969 rx_offloads |= DEV_RX_OFFLOAD_SCATTER;
1970 } else if (!strcmp(res->value, "off")) {
1971 rx_offloads &= ~DEV_RX_OFFLOAD_SCATTER;
1973 printf("Unknown parameter\n");
1976 } else if (!strcmp(res->name, "rx-cksum")) {
1977 if (!strcmp(res->value, "on"))
1978 rx_offloads |= DEV_RX_OFFLOAD_CHECKSUM;
1979 else if (!strcmp(res->value, "off"))
1980 rx_offloads &= ~DEV_RX_OFFLOAD_CHECKSUM;
1982 printf("Unknown parameter\n");
1985 } else if (!strcmp(res->name, "rx-timestamp")) {
1986 if (!strcmp(res->value, "on"))
1987 rx_offloads |= DEV_RX_OFFLOAD_TIMESTAMP;
1988 else if (!strcmp(res->value, "off"))
1989 rx_offloads &= ~DEV_RX_OFFLOAD_TIMESTAMP;
1991 printf("Unknown parameter\n");
1994 } else if (!strcmp(res->name, "hw-vlan")) {
1995 if (!strcmp(res->value, "on")) {
1996 rx_offloads |= (DEV_RX_OFFLOAD_VLAN_FILTER |
1997 DEV_RX_OFFLOAD_VLAN_STRIP);
1998 } else if (!strcmp(res->value, "off")) {
1999 rx_offloads &= ~(DEV_RX_OFFLOAD_VLAN_FILTER |
2000 DEV_RX_OFFLOAD_VLAN_STRIP);
2002 printf("Unknown parameter\n");
2005 } else if (!strcmp(res->name, "hw-vlan-filter")) {
2006 if (!strcmp(res->value, "on"))
2007 rx_offloads |= DEV_RX_OFFLOAD_VLAN_FILTER;
2008 else if (!strcmp(res->value, "off"))
2009 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_FILTER;
2011 printf("Unknown parameter\n");
2014 } else if (!strcmp(res->name, "hw-vlan-strip")) {
2015 if (!strcmp(res->value, "on"))
2016 rx_offloads |= DEV_RX_OFFLOAD_VLAN_STRIP;
2017 else if (!strcmp(res->value, "off"))
2018 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_STRIP;
2020 printf("Unknown parameter\n");
2023 } else if (!strcmp(res->name, "hw-vlan-extend")) {
2024 if (!strcmp(res->value, "on"))
2025 rx_offloads |= DEV_RX_OFFLOAD_VLAN_EXTEND;
2026 else if (!strcmp(res->value, "off"))
2027 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_EXTEND;
2029 printf("Unknown parameter\n");
2032 } else if (!strcmp(res->name, "drop-en")) {
2033 if (!strcmp(res->value, "on"))
2035 else if (!strcmp(res->value, "off"))
2038 printf("Unknown parameter\n");
2042 printf("Unknown parameter\n");
2045 port->dev_conf.rxmode.offloads = rx_offloads;
2050 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2053 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
2054 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
2055 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
2056 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
2058 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2059 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2060 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2061 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2062 "crc-strip#scatter#rx-cksum#rx-timestamp#hw-vlan#"
2063 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
2064 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2065 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2068 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2069 .f = cmd_config_rx_mode_flag_parsed,
2071 .help_str = "port config all crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|"
2072 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
2074 (void *)&cmd_config_rx_mode_flag_port,
2075 (void *)&cmd_config_rx_mode_flag_keyword,
2076 (void *)&cmd_config_rx_mode_flag_all,
2077 (void *)&cmd_config_rx_mode_flag_name,
2078 (void *)&cmd_config_rx_mode_flag_value,
2083 /* *** configure rss *** */
2084 struct cmd_config_rss {
2085 cmdline_fixed_string_t port;
2086 cmdline_fixed_string_t keyword;
2087 cmdline_fixed_string_t all;
2088 cmdline_fixed_string_t name;
2089 cmdline_fixed_string_t value;
2093 cmd_config_rss_parsed(void *parsed_result,
2094 __attribute__((unused)) struct cmdline *cl,
2095 __attribute__((unused)) void *data)
2097 struct cmd_config_rss *res = parsed_result;
2098 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2099 struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2100 int use_default = 0;
2101 int all_updated = 1;
2105 if (!strcmp(res->value, "all"))
2106 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
2107 ETH_RSS_UDP | ETH_RSS_SCTP |
2109 else if (!strcmp(res->value, "ip"))
2110 rss_conf.rss_hf = ETH_RSS_IP;
2111 else if (!strcmp(res->value, "udp"))
2112 rss_conf.rss_hf = ETH_RSS_UDP;
2113 else if (!strcmp(res->value, "tcp"))
2114 rss_conf.rss_hf = ETH_RSS_TCP;
2115 else if (!strcmp(res->value, "sctp"))
2116 rss_conf.rss_hf = ETH_RSS_SCTP;
2117 else if (!strcmp(res->value, "ether"))
2118 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
2119 else if (!strcmp(res->value, "port"))
2120 rss_conf.rss_hf = ETH_RSS_PORT;
2121 else if (!strcmp(res->value, "vxlan"))
2122 rss_conf.rss_hf = ETH_RSS_VXLAN;
2123 else if (!strcmp(res->value, "geneve"))
2124 rss_conf.rss_hf = ETH_RSS_GENEVE;
2125 else if (!strcmp(res->value, "nvgre"))
2126 rss_conf.rss_hf = ETH_RSS_NVGRE;
2127 else if (!strcmp(res->value, "none"))
2128 rss_conf.rss_hf = 0;
2129 else if (!strcmp(res->value, "default"))
2131 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2132 atoi(res->value) < 64)
2133 rss_conf.rss_hf = 1ULL << atoi(res->value);
2135 printf("Unknown parameter\n");
2138 rss_conf.rss_key = NULL;
2139 /* Update global configuration for RSS types. */
2140 RTE_ETH_FOREACH_DEV(i) {
2141 struct rte_eth_rss_conf local_rss_conf;
2143 rte_eth_dev_info_get(i, &dev_info);
2145 rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2147 local_rss_conf = rss_conf;
2148 local_rss_conf.rss_hf = rss_conf.rss_hf &
2149 dev_info.flow_type_rss_offloads;
2150 if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2151 printf("Port %u modified RSS hash function based on hardware support,"
2152 "requested:%#"PRIx64" configured:%#"PRIx64"\n",
2153 i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2155 diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2158 printf("Configuration of RSS hash at ethernet port %d "
2159 "failed with error (%d): %s.\n",
2160 i, -diag, strerror(-diag));
2163 if (all_updated && !use_default)
2164 rss_hf = rss_conf.rss_hf;
2167 cmdline_parse_token_string_t cmd_config_rss_port =
2168 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2169 cmdline_parse_token_string_t cmd_config_rss_keyword =
2170 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2171 cmdline_parse_token_string_t cmd_config_rss_all =
2172 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2173 cmdline_parse_token_string_t cmd_config_rss_name =
2174 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2175 cmdline_parse_token_string_t cmd_config_rss_value =
2176 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2178 cmdline_parse_inst_t cmd_config_rss = {
2179 .f = cmd_config_rss_parsed,
2181 .help_str = "port config all rss "
2182 "all|default|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none|<flowtype_id>",
2184 (void *)&cmd_config_rss_port,
2185 (void *)&cmd_config_rss_keyword,
2186 (void *)&cmd_config_rss_all,
2187 (void *)&cmd_config_rss_name,
2188 (void *)&cmd_config_rss_value,
2193 /* *** configure rss hash key *** */
2194 struct cmd_config_rss_hash_key {
2195 cmdline_fixed_string_t port;
2196 cmdline_fixed_string_t config;
2198 cmdline_fixed_string_t rss_hash_key;
2199 cmdline_fixed_string_t rss_type;
2200 cmdline_fixed_string_t key;
2204 hexa_digit_to_value(char hexa_digit)
2206 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2207 return (uint8_t) (hexa_digit - '0');
2208 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2209 return (uint8_t) ((hexa_digit - 'a') + 10);
2210 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2211 return (uint8_t) ((hexa_digit - 'A') + 10);
2212 /* Invalid hexa digit */
2217 parse_and_check_key_hexa_digit(char *key, int idx)
2221 hexa_v = hexa_digit_to_value(key[idx]);
2223 printf("invalid key: character %c at position %d is not a "
2224 "valid hexa digit\n", key[idx], idx);
2229 cmd_config_rss_hash_key_parsed(void *parsed_result,
2230 __attribute__((unused)) struct cmdline *cl,
2231 __attribute__((unused)) void *data)
2233 struct cmd_config_rss_hash_key *res = parsed_result;
2234 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2238 struct rte_eth_dev_info dev_info;
2239 uint8_t hash_key_size;
2242 memset(&dev_info, 0, sizeof(dev_info));
2243 rte_eth_dev_info_get(res->port_id, &dev_info);
2244 if (dev_info.hash_key_size > 0 &&
2245 dev_info.hash_key_size <= sizeof(hash_key))
2246 hash_key_size = dev_info.hash_key_size;
2248 printf("dev_info did not provide a valid hash key size\n");
2251 /* Check the length of the RSS hash key */
2252 key_len = strlen(res->key);
2253 if (key_len != (hash_key_size * 2)) {
2254 printf("key length: %d invalid - key must be a string of %d"
2255 " hexa-decimal numbers\n",
2256 (int) key_len, hash_key_size * 2);
2259 /* Translate RSS hash key into binary representation */
2260 for (i = 0; i < hash_key_size; i++) {
2261 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2264 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2267 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2269 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2273 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2274 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2275 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2276 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2278 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2279 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16);
2280 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2281 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2282 rss_hash_key, "rss-hash-key");
2283 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2284 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2285 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2286 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2287 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2288 "ipv6-tcp-ex#ipv6-udp-ex");
2289 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2290 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2292 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2293 .f = cmd_config_rss_hash_key_parsed,
2295 .help_str = "port config <port_id> rss-hash-key "
2296 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2297 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2298 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex "
2299 "<string of hex digits (variable length, NIC dependent)>",
2301 (void *)&cmd_config_rss_hash_key_port,
2302 (void *)&cmd_config_rss_hash_key_config,
2303 (void *)&cmd_config_rss_hash_key_port_id,
2304 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2305 (void *)&cmd_config_rss_hash_key_rss_type,
2306 (void *)&cmd_config_rss_hash_key_value,
2311 /* *** configure port rxq/txq ring size *** */
2312 struct cmd_config_rxtx_ring_size {
2313 cmdline_fixed_string_t port;
2314 cmdline_fixed_string_t config;
2316 cmdline_fixed_string_t rxtxq;
2318 cmdline_fixed_string_t rsize;
2323 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2324 __attribute__((unused)) struct cmdline *cl,
2325 __attribute__((unused)) void *data)
2327 struct cmd_config_rxtx_ring_size *res = parsed_result;
2328 struct rte_port *port;
2331 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2334 if (res->portid == (portid_t)RTE_PORT_ALL) {
2335 printf("Invalid port id\n");
2339 port = &ports[res->portid];
2341 if (!strcmp(res->rxtxq, "rxq"))
2343 else if (!strcmp(res->rxtxq, "txq"))
2346 printf("Unknown parameter\n");
2350 if (isrx && rx_queue_id_is_invalid(res->qid))
2352 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2355 if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2356 printf("Invalid rx ring_size, must > rx_free_thresh: %d\n",
2362 port->nb_rx_desc[res->qid] = res->size;
2364 port->nb_tx_desc[res->qid] = res->size;
2366 cmd_reconfig_device_queue(res->portid, 0, 1);
2369 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2370 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2372 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2373 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2375 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2376 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2378 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2379 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2381 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2382 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2384 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2385 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2386 rsize, "ring_size");
2387 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2388 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2391 cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2392 .f = cmd_config_rxtx_ring_size_parsed,
2394 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2396 (void *)&cmd_config_rxtx_ring_size_port,
2397 (void *)&cmd_config_rxtx_ring_size_config,
2398 (void *)&cmd_config_rxtx_ring_size_portid,
2399 (void *)&cmd_config_rxtx_ring_size_rxtxq,
2400 (void *)&cmd_config_rxtx_ring_size_qid,
2401 (void *)&cmd_config_rxtx_ring_size_rsize,
2402 (void *)&cmd_config_rxtx_ring_size_size,
2407 /* *** configure port rxq/txq start/stop *** */
2408 struct cmd_config_rxtx_queue {
2409 cmdline_fixed_string_t port;
2411 cmdline_fixed_string_t rxtxq;
2413 cmdline_fixed_string_t opname;
2417 cmd_config_rxtx_queue_parsed(void *parsed_result,
2418 __attribute__((unused)) struct cmdline *cl,
2419 __attribute__((unused)) void *data)
2421 struct cmd_config_rxtx_queue *res = parsed_result;
2426 if (test_done == 0) {
2427 printf("Please stop forwarding first\n");
2431 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2434 if (port_is_started(res->portid) != 1) {
2435 printf("Please start port %u first\n", res->portid);
2439 if (!strcmp(res->rxtxq, "rxq"))
2441 else if (!strcmp(res->rxtxq, "txq"))
2444 printf("Unknown parameter\n");
2448 if (isrx && rx_queue_id_is_invalid(res->qid))
2450 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2453 if (!strcmp(res->opname, "start"))
2455 else if (!strcmp(res->opname, "stop"))
2458 printf("Unknown parameter\n");
2462 if (isstart && isrx)
2463 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2464 else if (!isstart && isrx)
2465 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2466 else if (isstart && !isrx)
2467 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2469 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2471 if (ret == -ENOTSUP)
2472 printf("Function not supported in PMD driver\n");
2475 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2476 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2477 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2478 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16);
2479 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2480 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2481 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2482 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
2483 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2484 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2487 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2488 .f = cmd_config_rxtx_queue_parsed,
2490 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2492 (void *)&cmd_config_rxtx_queue_port,
2493 (void *)&cmd_config_rxtx_queue_portid,
2494 (void *)&cmd_config_rxtx_queue_rxtxq,
2495 (void *)&cmd_config_rxtx_queue_qid,
2496 (void *)&cmd_config_rxtx_queue_opname,
2501 /* *** configure port rxq/txq deferred start on/off *** */
2502 struct cmd_config_deferred_start_rxtx_queue {
2503 cmdline_fixed_string_t port;
2505 cmdline_fixed_string_t rxtxq;
2507 cmdline_fixed_string_t opname;
2508 cmdline_fixed_string_t state;
2512 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2513 __attribute__((unused)) struct cmdline *cl,
2514 __attribute__((unused)) void *data)
2516 struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2517 struct rte_port *port;
2520 uint8_t needreconfig = 0;
2522 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2525 if (port_is_started(res->port_id) != 0) {
2526 printf("Please stop port %u first\n", res->port_id);
2530 port = &ports[res->port_id];
2532 isrx = !strcmp(res->rxtxq, "rxq");
2534 if (isrx && rx_queue_id_is_invalid(res->qid))
2536 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2539 ison = !strcmp(res->state, "on");
2541 if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) {
2542 port->rx_conf[res->qid].rx_deferred_start = ison;
2544 } else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) {
2545 port->tx_conf[res->qid].tx_deferred_start = ison;
2550 cmd_reconfig_device_queue(res->port_id, 0, 1);
2553 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2554 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2556 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2557 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2559 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2560 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2562 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2563 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2565 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2566 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2567 opname, "deferred_start");
2568 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2569 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2572 cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
2573 .f = cmd_config_deferred_start_rxtx_queue_parsed,
2575 .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
2577 (void *)&cmd_config_deferred_start_rxtx_queue_port,
2578 (void *)&cmd_config_deferred_start_rxtx_queue_port_id,
2579 (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
2580 (void *)&cmd_config_deferred_start_rxtx_queue_qid,
2581 (void *)&cmd_config_deferred_start_rxtx_queue_opname,
2582 (void *)&cmd_config_deferred_start_rxtx_queue_state,
2587 /* *** configure port rxq/txq setup *** */
2588 struct cmd_setup_rxtx_queue {
2589 cmdline_fixed_string_t port;
2591 cmdline_fixed_string_t rxtxq;
2593 cmdline_fixed_string_t setup;
2596 /* Common CLI fields for queue setup */
2597 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2598 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2599 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2600 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, UINT16);
2601 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2602 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2603 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2604 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, UINT16);
2605 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2606 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2609 cmd_setup_rxtx_queue_parsed(
2610 void *parsed_result,
2611 __attribute__((unused)) struct cmdline *cl,
2612 __attribute__((unused)) void *data)
2614 struct cmd_setup_rxtx_queue *res = parsed_result;
2615 struct rte_port *port;
2616 struct rte_mempool *mp;
2617 unsigned int socket_id;
2621 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2624 if (res->portid == (portid_t)RTE_PORT_ALL) {
2625 printf("Invalid port id\n");
2629 if (!strcmp(res->rxtxq, "rxq"))
2631 else if (!strcmp(res->rxtxq, "txq"))
2634 printf("Unknown parameter\n");
2638 if (isrx && rx_queue_id_is_invalid(res->qid)) {
2639 printf("Invalid rx queue\n");
2641 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2642 printf("Invalid tx queue\n");
2646 port = &ports[res->portid];
2648 socket_id = rxring_numa[res->portid];
2649 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2650 socket_id = port->socket_id;
2652 mp = mbuf_pool_find(socket_id);
2654 printf("Failed to setup RX queue: "
2655 "No mempool allocation"
2656 " on the socket %d\n",
2657 rxring_numa[res->portid]);
2660 ret = rte_eth_rx_queue_setup(res->portid,
2662 port->nb_rx_desc[res->qid],
2664 &port->rx_conf[res->qid],
2667 printf("Failed to setup RX queue\n");
2669 socket_id = txring_numa[res->portid];
2670 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2671 socket_id = port->socket_id;
2673 ret = rte_eth_tx_queue_setup(res->portid,
2675 port->nb_tx_desc[res->qid],
2677 &port->tx_conf[res->qid]);
2679 printf("Failed to setup TX queue\n");
2683 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2684 .f = cmd_setup_rxtx_queue_parsed,
2686 .help_str = "port <port_id> rxq|txq <queue_idx> setup",
2688 (void *)&cmd_setup_rxtx_queue_port,
2689 (void *)&cmd_setup_rxtx_queue_portid,
2690 (void *)&cmd_setup_rxtx_queue_rxtxq,
2691 (void *)&cmd_setup_rxtx_queue_qid,
2692 (void *)&cmd_setup_rxtx_queue_setup,
2698 /* *** Configure RSS RETA *** */
2699 struct cmd_config_rss_reta {
2700 cmdline_fixed_string_t port;
2701 cmdline_fixed_string_t keyword;
2703 cmdline_fixed_string_t name;
2704 cmdline_fixed_string_t list_name;
2705 cmdline_fixed_string_t list_of_items;
2709 parse_reta_config(const char *str,
2710 struct rte_eth_rss_reta_entry64 *reta_conf,
2711 uint16_t nb_entries)
2715 uint16_t hash_index, idx, shift;
2718 const char *p, *p0 = str;
2725 unsigned long int_fld[_NUM_FLD];
2726 char *str_fld[_NUM_FLD];
2728 while ((p = strchr(p0,'(')) != NULL) {
2730 if((p0 = strchr(p,')')) == NULL)
2734 if(size >= sizeof(s))
2737 snprintf(s, sizeof(s), "%.*s", size, p);
2738 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2740 for (i = 0; i < _NUM_FLD; i++) {
2742 int_fld[i] = strtoul(str_fld[i], &end, 0);
2743 if (errno != 0 || end == str_fld[i] ||
2748 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2749 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2751 if (hash_index >= nb_entries) {
2752 printf("Invalid RETA hash index=%d\n", hash_index);
2756 idx = hash_index / RTE_RETA_GROUP_SIZE;
2757 shift = hash_index % RTE_RETA_GROUP_SIZE;
2758 reta_conf[idx].mask |= (1ULL << shift);
2759 reta_conf[idx].reta[shift] = nb_queue;
2766 cmd_set_rss_reta_parsed(void *parsed_result,
2767 __attribute__((unused)) struct cmdline *cl,
2768 __attribute__((unused)) void *data)
2771 struct rte_eth_dev_info dev_info;
2772 struct rte_eth_rss_reta_entry64 reta_conf[8];
2773 struct cmd_config_rss_reta *res = parsed_result;
2775 memset(&dev_info, 0, sizeof(dev_info));
2776 rte_eth_dev_info_get(res->port_id, &dev_info);
2777 if (dev_info.reta_size == 0) {
2778 printf("Redirection table size is 0 which is "
2779 "invalid for RSS\n");
2782 printf("The reta size of port %d is %u\n",
2783 res->port_id, dev_info.reta_size);
2784 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2785 printf("Currently do not support more than %u entries of "
2786 "redirection table\n", ETH_RSS_RETA_SIZE_512);
2790 memset(reta_conf, 0, sizeof(reta_conf));
2791 if (!strcmp(res->list_name, "reta")) {
2792 if (parse_reta_config(res->list_of_items, reta_conf,
2793 dev_info.reta_size)) {
2794 printf("Invalid RSS Redirection Table "
2795 "config entered\n");
2798 ret = rte_eth_dev_rss_reta_update(res->port_id,
2799 reta_conf, dev_info.reta_size);
2801 printf("Bad redirection table parameter, "
2802 "return code = %d \n", ret);
2806 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2807 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2808 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2809 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2810 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2811 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16);
2812 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2813 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2814 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2815 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2816 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2817 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2819 cmdline_parse_inst_t cmd_config_rss_reta = {
2820 .f = cmd_set_rss_reta_parsed,
2822 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2824 (void *)&cmd_config_rss_reta_port,
2825 (void *)&cmd_config_rss_reta_keyword,
2826 (void *)&cmd_config_rss_reta_port_id,
2827 (void *)&cmd_config_rss_reta_name,
2828 (void *)&cmd_config_rss_reta_list_name,
2829 (void *)&cmd_config_rss_reta_list_of_items,
2834 /* *** SHOW PORT RETA INFO *** */
2835 struct cmd_showport_reta {
2836 cmdline_fixed_string_t show;
2837 cmdline_fixed_string_t port;
2839 cmdline_fixed_string_t rss;
2840 cmdline_fixed_string_t reta;
2842 cmdline_fixed_string_t list_of_items;
2846 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2847 uint16_t nb_entries,
2851 const char *p, *p0 = str;
2856 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
2857 RTE_RETA_GROUP_SIZE;
2860 p = strchr(p0, '(');
2864 p0 = strchr(p, ')');
2868 if (size >= sizeof(s)) {
2869 printf("The string size exceeds the internal buffer size\n");
2872 snprintf(s, sizeof(s), "%.*s", size, p);
2873 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
2874 if (ret <= 0 || ret != num) {
2875 printf("The bits of masks do not match the number of "
2876 "reta entries: %u\n", num);
2879 for (i = 0; i < ret; i++)
2880 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
2886 cmd_showport_reta_parsed(void *parsed_result,
2887 __attribute__((unused)) struct cmdline *cl,
2888 __attribute__((unused)) void *data)
2890 struct cmd_showport_reta *res = parsed_result;
2891 struct rte_eth_rss_reta_entry64 reta_conf[8];
2892 struct rte_eth_dev_info dev_info;
2893 uint16_t max_reta_size;
2895 memset(&dev_info, 0, sizeof(dev_info));
2896 rte_eth_dev_info_get(res->port_id, &dev_info);
2897 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
2898 if (res->size == 0 || res->size > max_reta_size) {
2899 printf("Invalid redirection table size: %u (1-%u)\n",
2900 res->size, max_reta_size);
2904 memset(reta_conf, 0, sizeof(reta_conf));
2905 if (showport_parse_reta_config(reta_conf, res->size,
2906 res->list_of_items) < 0) {
2907 printf("Invalid string: %s for reta masks\n",
2908 res->list_of_items);
2911 port_rss_reta_info(res->port_id, reta_conf, res->size);
2914 cmdline_parse_token_string_t cmd_showport_reta_show =
2915 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
2916 cmdline_parse_token_string_t cmd_showport_reta_port =
2917 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
2918 cmdline_parse_token_num_t cmd_showport_reta_port_id =
2919 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16);
2920 cmdline_parse_token_string_t cmd_showport_reta_rss =
2921 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
2922 cmdline_parse_token_string_t cmd_showport_reta_reta =
2923 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
2924 cmdline_parse_token_num_t cmd_showport_reta_size =
2925 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
2926 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
2927 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
2928 list_of_items, NULL);
2930 cmdline_parse_inst_t cmd_showport_reta = {
2931 .f = cmd_showport_reta_parsed,
2933 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
2935 (void *)&cmd_showport_reta_show,
2936 (void *)&cmd_showport_reta_port,
2937 (void *)&cmd_showport_reta_port_id,
2938 (void *)&cmd_showport_reta_rss,
2939 (void *)&cmd_showport_reta_reta,
2940 (void *)&cmd_showport_reta_size,
2941 (void *)&cmd_showport_reta_list_of_items,
2946 /* *** Show RSS hash configuration *** */
2947 struct cmd_showport_rss_hash {
2948 cmdline_fixed_string_t show;
2949 cmdline_fixed_string_t port;
2951 cmdline_fixed_string_t rss_hash;
2952 cmdline_fixed_string_t rss_type;
2953 cmdline_fixed_string_t key; /* optional argument */
2956 static void cmd_showport_rss_hash_parsed(void *parsed_result,
2957 __attribute__((unused)) struct cmdline *cl,
2960 struct cmd_showport_rss_hash *res = parsed_result;
2962 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
2965 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
2966 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
2967 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
2968 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
2969 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
2970 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16);
2971 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
2972 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
2974 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
2975 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
2977 cmdline_parse_inst_t cmd_showport_rss_hash = {
2978 .f = cmd_showport_rss_hash_parsed,
2980 .help_str = "show port <port_id> rss-hash",
2982 (void *)&cmd_showport_rss_hash_show,
2983 (void *)&cmd_showport_rss_hash_port,
2984 (void *)&cmd_showport_rss_hash_port_id,
2985 (void *)&cmd_showport_rss_hash_rss_hash,
2990 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
2991 .f = cmd_showport_rss_hash_parsed,
2993 .help_str = "show port <port_id> rss-hash key",
2995 (void *)&cmd_showport_rss_hash_show,
2996 (void *)&cmd_showport_rss_hash_port,
2997 (void *)&cmd_showport_rss_hash_port_id,
2998 (void *)&cmd_showport_rss_hash_rss_hash,
2999 (void *)&cmd_showport_rss_hash_rss_key,
3004 /* *** Configure DCB *** */
3005 struct cmd_config_dcb {
3006 cmdline_fixed_string_t port;
3007 cmdline_fixed_string_t config;
3009 cmdline_fixed_string_t dcb;
3010 cmdline_fixed_string_t vt;
3011 cmdline_fixed_string_t vt_en;
3013 cmdline_fixed_string_t pfc;
3014 cmdline_fixed_string_t pfc_en;
3018 cmd_config_dcb_parsed(void *parsed_result,
3019 __attribute__((unused)) struct cmdline *cl,
3020 __attribute__((unused)) void *data)
3022 struct cmd_config_dcb *res = parsed_result;
3023 portid_t port_id = res->port_id;
3024 struct rte_port *port;
3028 port = &ports[port_id];
3029 /** Check if the port is not started **/
3030 if (port->port_status != RTE_PORT_STOPPED) {
3031 printf("Please stop port %d first\n", port_id);
3035 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
3036 printf("The invalid number of traffic class,"
3037 " only 4 or 8 allowed.\n");
3041 if (nb_fwd_lcores < res->num_tcs) {
3042 printf("nb_cores shouldn't be less than number of TCs.\n");
3045 if (!strncmp(res->pfc_en, "on", 2))
3050 /* DCB in VT mode */
3051 if (!strncmp(res->vt_en, "on", 2))
3052 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3053 (enum rte_eth_nb_tcs)res->num_tcs,
3056 ret = init_port_dcb_config(port_id, DCB_ENABLED,
3057 (enum rte_eth_nb_tcs)res->num_tcs,
3062 printf("Cannot initialize network ports.\n");
3066 cmd_reconfig_device_queue(port_id, 1, 1);
3069 cmdline_parse_token_string_t cmd_config_dcb_port =
3070 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3071 cmdline_parse_token_string_t cmd_config_dcb_config =
3072 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3073 cmdline_parse_token_num_t cmd_config_dcb_port_id =
3074 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16);
3075 cmdline_parse_token_string_t cmd_config_dcb_dcb =
3076 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3077 cmdline_parse_token_string_t cmd_config_dcb_vt =
3078 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3079 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3080 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3081 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3082 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
3083 cmdline_parse_token_string_t cmd_config_dcb_pfc=
3084 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3085 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
3086 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
3088 cmdline_parse_inst_t cmd_config_dcb = {
3089 .f = cmd_config_dcb_parsed,
3091 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
3093 (void *)&cmd_config_dcb_port,
3094 (void *)&cmd_config_dcb_config,
3095 (void *)&cmd_config_dcb_port_id,
3096 (void *)&cmd_config_dcb_dcb,
3097 (void *)&cmd_config_dcb_vt,
3098 (void *)&cmd_config_dcb_vt_en,
3099 (void *)&cmd_config_dcb_num_tcs,
3100 (void *)&cmd_config_dcb_pfc,
3101 (void *)&cmd_config_dcb_pfc_en,
3106 /* *** configure number of packets per burst *** */
3107 struct cmd_config_burst {
3108 cmdline_fixed_string_t port;
3109 cmdline_fixed_string_t keyword;
3110 cmdline_fixed_string_t all;
3111 cmdline_fixed_string_t name;
3116 cmd_config_burst_parsed(void *parsed_result,
3117 __attribute__((unused)) struct cmdline *cl,
3118 __attribute__((unused)) void *data)
3120 struct cmd_config_burst *res = parsed_result;
3121 struct rte_eth_dev_info dev_info;
3122 uint16_t rec_nb_pkts;
3124 if (!all_ports_stopped()) {
3125 printf("Please stop all ports first\n");
3129 if (!strcmp(res->name, "burst")) {
3130 if (res->value == 0) {
3131 /* If user gives a value of zero, query the PMD for
3132 * its recommended Rx burst size. Testpmd uses a single
3133 * size for all ports, so assume all ports are the same
3134 * NIC model and use the values from Port 0.
3136 rte_eth_dev_info_get(0, &dev_info);
3137 rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3139 if (rec_nb_pkts == 0) {
3140 printf("PMD does not recommend a burst size.\n"
3141 "User provided value must be between"
3142 " 1 and %d\n", MAX_PKT_BURST);
3144 } else if (rec_nb_pkts > MAX_PKT_BURST) {
3145 printf("PMD recommended burst size of %d"
3146 " exceeds maximum value of %d\n",
3147 rec_nb_pkts, MAX_PKT_BURST);
3150 printf("Using PMD-provided burst value of %d\n",
3152 nb_pkt_per_burst = rec_nb_pkts;
3153 } else if (res->value > MAX_PKT_BURST) {
3154 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
3157 nb_pkt_per_burst = res->value;
3159 printf("Unknown parameter\n");
3165 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3168 cmdline_parse_token_string_t cmd_config_burst_port =
3169 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3170 cmdline_parse_token_string_t cmd_config_burst_keyword =
3171 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3172 cmdline_parse_token_string_t cmd_config_burst_all =
3173 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3174 cmdline_parse_token_string_t cmd_config_burst_name =
3175 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3176 cmdline_parse_token_num_t cmd_config_burst_value =
3177 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
3179 cmdline_parse_inst_t cmd_config_burst = {
3180 .f = cmd_config_burst_parsed,
3182 .help_str = "port config all burst <value>",
3184 (void *)&cmd_config_burst_port,
3185 (void *)&cmd_config_burst_keyword,
3186 (void *)&cmd_config_burst_all,
3187 (void *)&cmd_config_burst_name,
3188 (void *)&cmd_config_burst_value,
3193 /* *** configure rx/tx queues *** */
3194 struct cmd_config_thresh {
3195 cmdline_fixed_string_t port;
3196 cmdline_fixed_string_t keyword;
3197 cmdline_fixed_string_t all;
3198 cmdline_fixed_string_t name;
3203 cmd_config_thresh_parsed(void *parsed_result,
3204 __attribute__((unused)) struct cmdline *cl,
3205 __attribute__((unused)) void *data)
3207 struct cmd_config_thresh *res = parsed_result;
3209 if (!all_ports_stopped()) {
3210 printf("Please stop all ports first\n");
3214 if (!strcmp(res->name, "txpt"))
3215 tx_pthresh = res->value;
3216 else if(!strcmp(res->name, "txht"))
3217 tx_hthresh = res->value;
3218 else if(!strcmp(res->name, "txwt"))
3219 tx_wthresh = res->value;
3220 else if(!strcmp(res->name, "rxpt"))
3221 rx_pthresh = res->value;
3222 else if(!strcmp(res->name, "rxht"))
3223 rx_hthresh = res->value;
3224 else if(!strcmp(res->name, "rxwt"))
3225 rx_wthresh = res->value;
3227 printf("Unknown parameter\n");
3233 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3236 cmdline_parse_token_string_t cmd_config_thresh_port =
3237 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3238 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3239 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3240 cmdline_parse_token_string_t cmd_config_thresh_all =
3241 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3242 cmdline_parse_token_string_t cmd_config_thresh_name =
3243 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3244 "txpt#txht#txwt#rxpt#rxht#rxwt");
3245 cmdline_parse_token_num_t cmd_config_thresh_value =
3246 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
3248 cmdline_parse_inst_t cmd_config_thresh = {
3249 .f = cmd_config_thresh_parsed,
3251 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3253 (void *)&cmd_config_thresh_port,
3254 (void *)&cmd_config_thresh_keyword,
3255 (void *)&cmd_config_thresh_all,
3256 (void *)&cmd_config_thresh_name,
3257 (void *)&cmd_config_thresh_value,
3262 /* *** configure free/rs threshold *** */
3263 struct cmd_config_threshold {
3264 cmdline_fixed_string_t port;
3265 cmdline_fixed_string_t keyword;
3266 cmdline_fixed_string_t all;
3267 cmdline_fixed_string_t name;
3272 cmd_config_threshold_parsed(void *parsed_result,
3273 __attribute__((unused)) struct cmdline *cl,
3274 __attribute__((unused)) void *data)
3276 struct cmd_config_threshold *res = parsed_result;
3278 if (!all_ports_stopped()) {
3279 printf("Please stop all ports first\n");
3283 if (!strcmp(res->name, "txfreet"))
3284 tx_free_thresh = res->value;
3285 else if (!strcmp(res->name, "txrst"))
3286 tx_rs_thresh = res->value;
3287 else if (!strcmp(res->name, "rxfreet"))
3288 rx_free_thresh = res->value;
3290 printf("Unknown parameter\n");
3296 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3299 cmdline_parse_token_string_t cmd_config_threshold_port =
3300 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3301 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3302 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3304 cmdline_parse_token_string_t cmd_config_threshold_all =
3305 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3306 cmdline_parse_token_string_t cmd_config_threshold_name =
3307 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3308 "txfreet#txrst#rxfreet");
3309 cmdline_parse_token_num_t cmd_config_threshold_value =
3310 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
3312 cmdline_parse_inst_t cmd_config_threshold = {
3313 .f = cmd_config_threshold_parsed,
3315 .help_str = "port config all txfreet|txrst|rxfreet <value>",
3317 (void *)&cmd_config_threshold_port,
3318 (void *)&cmd_config_threshold_keyword,
3319 (void *)&cmd_config_threshold_all,
3320 (void *)&cmd_config_threshold_name,
3321 (void *)&cmd_config_threshold_value,
3327 struct cmd_stop_result {
3328 cmdline_fixed_string_t stop;
3331 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
3332 __attribute__((unused)) struct cmdline *cl,
3333 __attribute__((unused)) void *data)
3335 stop_packet_forwarding();
3338 cmdline_parse_token_string_t cmd_stop_stop =
3339 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3341 cmdline_parse_inst_t cmd_stop = {
3342 .f = cmd_stop_parsed,
3344 .help_str = "stop: Stop packet forwarding",
3346 (void *)&cmd_stop_stop,
3351 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3354 parse_item_list(char* str, const char* item_name, unsigned int max_items,
3355 unsigned int *parsed_items, int check_unique_values)
3357 unsigned int nb_item;
3365 * First parse all items in the list and store their value.
3370 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3372 if ((c >= '0') && (c <= '9')) {
3373 value = (unsigned int) (value * 10 + (c - '0'));
3378 printf("character %c is not a decimal digit\n", c);
3382 printf("No valid value before comma\n");
3385 if (nb_item < max_items) {
3386 parsed_items[nb_item] = value;
3392 if (nb_item >= max_items) {
3393 printf("Number of %s = %u > %u (maximum items)\n",
3394 item_name, nb_item + 1, max_items);
3397 parsed_items[nb_item++] = value;
3398 if (! check_unique_values)
3402 * Then, check that all values in the list are differents.
3403 * No optimization here...
3405 for (i = 0; i < nb_item; i++) {
3406 for (j = i + 1; j < nb_item; j++) {
3407 if (parsed_items[j] == parsed_items[i]) {
3408 printf("duplicated %s %u at index %u and %u\n",
3409 item_name, parsed_items[i], i, j);
3417 struct cmd_set_list_result {
3418 cmdline_fixed_string_t cmd_keyword;
3419 cmdline_fixed_string_t list_name;
3420 cmdline_fixed_string_t list_of_items;
3423 static void cmd_set_list_parsed(void *parsed_result,
3424 __attribute__((unused)) struct cmdline *cl,
3425 __attribute__((unused)) void *data)
3427 struct cmd_set_list_result *res;
3429 unsigned int lcorelist[RTE_MAX_LCORE];
3430 unsigned int portlist[RTE_MAX_ETHPORTS];
3432 unsigned int nb_item;
3434 if (test_done == 0) {
3435 printf("Please stop forwarding first\n");
3439 res = parsed_result;
3440 if (!strcmp(res->list_name, "corelist")) {
3441 nb_item = parse_item_list(res->list_of_items, "core",
3443 parsed_items.lcorelist, 1);
3445 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3450 if (!strcmp(res->list_name, "portlist")) {
3451 nb_item = parse_item_list(res->list_of_items, "port",
3453 parsed_items.portlist, 1);
3455 set_fwd_ports_list(parsed_items.portlist, nb_item);
3461 cmdline_parse_token_string_t cmd_set_list_keyword =
3462 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3464 cmdline_parse_token_string_t cmd_set_list_name =
3465 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3466 "corelist#portlist");
3467 cmdline_parse_token_string_t cmd_set_list_of_items =
3468 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3471 cmdline_parse_inst_t cmd_set_fwd_list = {
3472 .f = cmd_set_list_parsed,
3474 .help_str = "set corelist|portlist <list0[,list1]*>",
3476 (void *)&cmd_set_list_keyword,
3477 (void *)&cmd_set_list_name,
3478 (void *)&cmd_set_list_of_items,
3483 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3485 struct cmd_setmask_result {
3486 cmdline_fixed_string_t set;
3487 cmdline_fixed_string_t mask;
3491 static void cmd_set_mask_parsed(void *parsed_result,
3492 __attribute__((unused)) struct cmdline *cl,
3493 __attribute__((unused)) void *data)
3495 struct cmd_setmask_result *res = parsed_result;
3497 if (test_done == 0) {
3498 printf("Please stop forwarding first\n");
3501 if (!strcmp(res->mask, "coremask")) {
3502 set_fwd_lcores_mask(res->hexavalue);
3504 } else if (!strcmp(res->mask, "portmask")) {
3505 set_fwd_ports_mask(res->hexavalue);
3510 cmdline_parse_token_string_t cmd_setmask_set =
3511 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3512 cmdline_parse_token_string_t cmd_setmask_mask =
3513 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3514 "coremask#portmask");
3515 cmdline_parse_token_num_t cmd_setmask_value =
3516 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
3518 cmdline_parse_inst_t cmd_set_fwd_mask = {
3519 .f = cmd_set_mask_parsed,
3521 .help_str = "set coremask|portmask <hexadecimal value>",
3523 (void *)&cmd_setmask_set,
3524 (void *)&cmd_setmask_mask,
3525 (void *)&cmd_setmask_value,
3531 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3533 struct cmd_set_result {
3534 cmdline_fixed_string_t set;
3535 cmdline_fixed_string_t what;
3539 static void cmd_set_parsed(void *parsed_result,
3540 __attribute__((unused)) struct cmdline *cl,
3541 __attribute__((unused)) void *data)
3543 struct cmd_set_result *res = parsed_result;
3544 if (!strcmp(res->what, "nbport")) {
3545 set_fwd_ports_number(res->value);
3547 } else if (!strcmp(res->what, "nbcore")) {
3548 set_fwd_lcores_number(res->value);
3550 } else if (!strcmp(res->what, "burst"))
3551 set_nb_pkt_per_burst(res->value);
3552 else if (!strcmp(res->what, "verbose"))
3553 set_verbose_level(res->value);
3556 cmdline_parse_token_string_t cmd_set_set =
3557 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3558 cmdline_parse_token_string_t cmd_set_what =
3559 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3560 "nbport#nbcore#burst#verbose");
3561 cmdline_parse_token_num_t cmd_set_value =
3562 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
3564 cmdline_parse_inst_t cmd_set_numbers = {
3565 .f = cmd_set_parsed,
3567 .help_str = "set nbport|nbcore|burst|verbose <value>",
3569 (void *)&cmd_set_set,
3570 (void *)&cmd_set_what,
3571 (void *)&cmd_set_value,
3576 /* *** SET LOG LEVEL CONFIGURATION *** */
3578 struct cmd_set_log_result {
3579 cmdline_fixed_string_t set;
3580 cmdline_fixed_string_t log;
3581 cmdline_fixed_string_t type;
3586 cmd_set_log_parsed(void *parsed_result,
3587 __attribute__((unused)) struct cmdline *cl,
3588 __attribute__((unused)) void *data)
3590 struct cmd_set_log_result *res;
3593 res = parsed_result;
3594 if (!strcmp(res->type, "global"))
3595 rte_log_set_global_level(res->level);
3597 ret = rte_log_set_level_regexp(res->type, res->level);
3599 printf("Unable to set log level\n");
3603 cmdline_parse_token_string_t cmd_set_log_set =
3604 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3605 cmdline_parse_token_string_t cmd_set_log_log =
3606 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3607 cmdline_parse_token_string_t cmd_set_log_type =
3608 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3609 cmdline_parse_token_num_t cmd_set_log_level =
3610 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, UINT32);
3612 cmdline_parse_inst_t cmd_set_log = {
3613 .f = cmd_set_log_parsed,
3615 .help_str = "set log global|<type> <level>",
3617 (void *)&cmd_set_log_set,
3618 (void *)&cmd_set_log_log,
3619 (void *)&cmd_set_log_type,
3620 (void *)&cmd_set_log_level,
3625 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3627 struct cmd_set_txpkts_result {
3628 cmdline_fixed_string_t cmd_keyword;
3629 cmdline_fixed_string_t txpkts;
3630 cmdline_fixed_string_t seg_lengths;
3634 cmd_set_txpkts_parsed(void *parsed_result,
3635 __attribute__((unused)) struct cmdline *cl,
3636 __attribute__((unused)) void *data)
3638 struct cmd_set_txpkts_result *res;
3639 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3640 unsigned int nb_segs;
3642 res = parsed_result;
3643 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3644 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3646 set_tx_pkt_segments(seg_lengths, nb_segs);
3649 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3650 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3651 cmd_keyword, "set");
3652 cmdline_parse_token_string_t cmd_set_txpkts_name =
3653 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3655 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3656 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3659 cmdline_parse_inst_t cmd_set_txpkts = {
3660 .f = cmd_set_txpkts_parsed,
3662 .help_str = "set txpkts <len0[,len1]*>",
3664 (void *)&cmd_set_txpkts_keyword,
3665 (void *)&cmd_set_txpkts_name,
3666 (void *)&cmd_set_txpkts_lengths,
3671 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
3673 struct cmd_set_txsplit_result {
3674 cmdline_fixed_string_t cmd_keyword;
3675 cmdline_fixed_string_t txsplit;
3676 cmdline_fixed_string_t mode;
3680 cmd_set_txsplit_parsed(void *parsed_result,
3681 __attribute__((unused)) struct cmdline *cl,
3682 __attribute__((unused)) void *data)
3684 struct cmd_set_txsplit_result *res;
3686 res = parsed_result;
3687 set_tx_pkt_split(res->mode);
3690 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
3691 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3692 cmd_keyword, "set");
3693 cmdline_parse_token_string_t cmd_set_txsplit_name =
3694 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3695 txsplit, "txsplit");
3696 cmdline_parse_token_string_t cmd_set_txsplit_mode =
3697 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3700 cmdline_parse_inst_t cmd_set_txsplit = {
3701 .f = cmd_set_txsplit_parsed,
3703 .help_str = "set txsplit on|off|rand",
3705 (void *)&cmd_set_txsplit_keyword,
3706 (void *)&cmd_set_txsplit_name,
3707 (void *)&cmd_set_txsplit_mode,
3712 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
3713 struct cmd_rx_vlan_filter_all_result {
3714 cmdline_fixed_string_t rx_vlan;
3715 cmdline_fixed_string_t what;
3716 cmdline_fixed_string_t all;
3721 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
3722 __attribute__((unused)) struct cmdline *cl,
3723 __attribute__((unused)) void *data)
3725 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
3727 if (!strcmp(res->what, "add"))
3728 rx_vlan_all_filter_set(res->port_id, 1);
3730 rx_vlan_all_filter_set(res->port_id, 0);
3733 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
3734 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3735 rx_vlan, "rx_vlan");
3736 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
3737 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3739 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
3740 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3742 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
3743 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3746 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
3747 .f = cmd_rx_vlan_filter_all_parsed,
3749 .help_str = "rx_vlan add|rm all <port_id>: "
3750 "Add/Remove all identifiers to/from the set of VLAN "
3751 "identifiers filtered by a port",
3753 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
3754 (void *)&cmd_rx_vlan_filter_all_what,
3755 (void *)&cmd_rx_vlan_filter_all_all,
3756 (void *)&cmd_rx_vlan_filter_all_portid,
3761 /* *** VLAN OFFLOAD SET ON A PORT *** */
3762 struct cmd_vlan_offload_result {
3763 cmdline_fixed_string_t vlan;
3764 cmdline_fixed_string_t set;
3765 cmdline_fixed_string_t vlan_type;
3766 cmdline_fixed_string_t what;
3767 cmdline_fixed_string_t on;
3768 cmdline_fixed_string_t port_id;
3772 cmd_vlan_offload_parsed(void *parsed_result,
3773 __attribute__((unused)) struct cmdline *cl,
3774 __attribute__((unused)) void *data)
3777 struct cmd_vlan_offload_result *res = parsed_result;
3780 portid_t port_id = 0;
3784 len = strnlen(str, STR_TOKEN_SIZE);
3786 /* Get port_id first */
3794 tmp = strtoul(str, NULL, 0);
3795 /* If port_id greater that what portid_t can represent, return */
3796 if(tmp >= RTE_MAX_ETHPORTS)
3798 port_id = (portid_t)tmp;
3800 if (!strcmp(res->on, "on"))
3805 if (!strcmp(res->what, "strip"))
3806 rx_vlan_strip_set(port_id, on);
3807 else if(!strcmp(res->what, "stripq")){
3808 uint16_t queue_id = 0;
3810 /* No queue_id, return */
3812 printf("must specify (port,queue_id)\n");
3815 tmp = strtoul(str + i + 1, NULL, 0);
3816 /* If queue_id greater that what 16-bits can represent, return */
3820 queue_id = (uint16_t)tmp;
3821 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
3823 else if (!strcmp(res->what, "filter"))
3824 rx_vlan_filter_set(port_id, on);
3826 vlan_extend_set(port_id, on);
3831 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
3832 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3834 cmdline_parse_token_string_t cmd_vlan_offload_set =
3835 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3837 cmdline_parse_token_string_t cmd_vlan_offload_what =
3838 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3839 what, "strip#filter#qinq#stripq");
3840 cmdline_parse_token_string_t cmd_vlan_offload_on =
3841 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3843 cmdline_parse_token_string_t cmd_vlan_offload_portid =
3844 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3847 cmdline_parse_inst_t cmd_vlan_offload = {
3848 .f = cmd_vlan_offload_parsed,
3850 .help_str = "vlan set strip|filter|qinq|stripq on|off "
3851 "<port_id[,queue_id]>: "
3852 "Filter/Strip for rx side qinq(extended) for both rx/tx sides",
3854 (void *)&cmd_vlan_offload_vlan,
3855 (void *)&cmd_vlan_offload_set,
3856 (void *)&cmd_vlan_offload_what,
3857 (void *)&cmd_vlan_offload_on,
3858 (void *)&cmd_vlan_offload_portid,
3863 /* *** VLAN TPID SET ON A PORT *** */
3864 struct cmd_vlan_tpid_result {
3865 cmdline_fixed_string_t vlan;
3866 cmdline_fixed_string_t set;
3867 cmdline_fixed_string_t vlan_type;
3868 cmdline_fixed_string_t what;
3874 cmd_vlan_tpid_parsed(void *parsed_result,
3875 __attribute__((unused)) struct cmdline *cl,
3876 __attribute__((unused)) void *data)
3878 struct cmd_vlan_tpid_result *res = parsed_result;
3879 enum rte_vlan_type vlan_type;
3881 if (!strcmp(res->vlan_type, "inner"))
3882 vlan_type = ETH_VLAN_TYPE_INNER;
3883 else if (!strcmp(res->vlan_type, "outer"))
3884 vlan_type = ETH_VLAN_TYPE_OUTER;
3886 printf("Unknown vlan type\n");
3889 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
3892 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
3893 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3895 cmdline_parse_token_string_t cmd_vlan_tpid_set =
3896 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3898 cmdline_parse_token_string_t cmd_vlan_type =
3899 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3900 vlan_type, "inner#outer");
3901 cmdline_parse_token_string_t cmd_vlan_tpid_what =
3902 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3904 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
3905 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3907 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
3908 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3911 cmdline_parse_inst_t cmd_vlan_tpid = {
3912 .f = cmd_vlan_tpid_parsed,
3914 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
3915 "Set the VLAN Ether type",
3917 (void *)&cmd_vlan_tpid_vlan,
3918 (void *)&cmd_vlan_tpid_set,
3919 (void *)&cmd_vlan_type,
3920 (void *)&cmd_vlan_tpid_what,
3921 (void *)&cmd_vlan_tpid_tpid,
3922 (void *)&cmd_vlan_tpid_portid,
3927 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
3928 struct cmd_rx_vlan_filter_result {
3929 cmdline_fixed_string_t rx_vlan;
3930 cmdline_fixed_string_t what;
3936 cmd_rx_vlan_filter_parsed(void *parsed_result,
3937 __attribute__((unused)) struct cmdline *cl,
3938 __attribute__((unused)) void *data)
3940 struct cmd_rx_vlan_filter_result *res = parsed_result;
3942 if (!strcmp(res->what, "add"))
3943 rx_vft_set(res->port_id, res->vlan_id, 1);
3945 rx_vft_set(res->port_id, res->vlan_id, 0);
3948 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
3949 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3950 rx_vlan, "rx_vlan");
3951 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
3952 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3954 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
3955 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3957 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
3958 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3961 cmdline_parse_inst_t cmd_rx_vlan_filter = {
3962 .f = cmd_rx_vlan_filter_parsed,
3964 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
3965 "Add/Remove a VLAN identifier to/from the set of VLAN "
3966 "identifiers filtered by a port",
3968 (void *)&cmd_rx_vlan_filter_rx_vlan,
3969 (void *)&cmd_rx_vlan_filter_what,
3970 (void *)&cmd_rx_vlan_filter_vlanid,
3971 (void *)&cmd_rx_vlan_filter_portid,
3976 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3977 struct cmd_tx_vlan_set_result {
3978 cmdline_fixed_string_t tx_vlan;
3979 cmdline_fixed_string_t set;
3985 cmd_tx_vlan_set_parsed(void *parsed_result,
3986 __attribute__((unused)) struct cmdline *cl,
3987 __attribute__((unused)) void *data)
3989 struct cmd_tx_vlan_set_result *res = parsed_result;
3991 if (!port_is_stopped(res->port_id)) {
3992 printf("Please stop port %d first\n", res->port_id);
3996 tx_vlan_set(res->port_id, res->vlan_id);
3998 cmd_reconfig_device_queue(res->port_id, 1, 1);
4001 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4002 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4003 tx_vlan, "tx_vlan");
4004 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4005 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4007 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4008 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4010 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
4011 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4014 cmdline_parse_inst_t cmd_tx_vlan_set = {
4015 .f = cmd_tx_vlan_set_parsed,
4017 .help_str = "tx_vlan set <port_id> <vlan_id>: "
4018 "Enable hardware insertion of a single VLAN header "
4019 "with a given TAG Identifier in packets sent on a port",
4021 (void *)&cmd_tx_vlan_set_tx_vlan,
4022 (void *)&cmd_tx_vlan_set_set,
4023 (void *)&cmd_tx_vlan_set_portid,
4024 (void *)&cmd_tx_vlan_set_vlanid,
4029 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4030 struct cmd_tx_vlan_set_qinq_result {
4031 cmdline_fixed_string_t tx_vlan;
4032 cmdline_fixed_string_t set;
4035 uint16_t vlan_id_outer;
4039 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4040 __attribute__((unused)) struct cmdline *cl,
4041 __attribute__((unused)) void *data)
4043 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
4045 if (!port_is_stopped(res->port_id)) {
4046 printf("Please stop port %d first\n", res->port_id);
4050 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
4052 cmd_reconfig_device_queue(res->port_id, 1, 1);
4055 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
4056 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4057 tx_vlan, "tx_vlan");
4058 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
4059 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4061 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
4062 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4064 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
4065 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4067 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
4068 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4069 vlan_id_outer, UINT16);
4071 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
4072 .f = cmd_tx_vlan_set_qinq_parsed,
4074 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
4075 "Enable hardware insertion of double VLAN header "
4076 "with given TAG Identifiers in packets sent on a port",
4078 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
4079 (void *)&cmd_tx_vlan_set_qinq_set,
4080 (void *)&cmd_tx_vlan_set_qinq_portid,
4081 (void *)&cmd_tx_vlan_set_qinq_vlanid,
4082 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
4087 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
4088 struct cmd_tx_vlan_set_pvid_result {
4089 cmdline_fixed_string_t tx_vlan;
4090 cmdline_fixed_string_t set;
4091 cmdline_fixed_string_t pvid;
4094 cmdline_fixed_string_t mode;
4098 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
4099 __attribute__((unused)) struct cmdline *cl,
4100 __attribute__((unused)) void *data)
4102 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
4104 if (strcmp(res->mode, "on") == 0)
4105 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
4107 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
4110 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
4111 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4112 tx_vlan, "tx_vlan");
4113 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
4114 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4116 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
4117 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4119 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
4120 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4122 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
4123 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4125 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
4126 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4129 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
4130 .f = cmd_tx_vlan_set_pvid_parsed,
4132 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
4134 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
4135 (void *)&cmd_tx_vlan_set_pvid_set,
4136 (void *)&cmd_tx_vlan_set_pvid_pvid,
4137 (void *)&cmd_tx_vlan_set_pvid_port_id,
4138 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
4139 (void *)&cmd_tx_vlan_set_pvid_mode,
4144 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4145 struct cmd_tx_vlan_reset_result {
4146 cmdline_fixed_string_t tx_vlan;
4147 cmdline_fixed_string_t reset;
4152 cmd_tx_vlan_reset_parsed(void *parsed_result,
4153 __attribute__((unused)) struct cmdline *cl,
4154 __attribute__((unused)) void *data)
4156 struct cmd_tx_vlan_reset_result *res = parsed_result;
4158 if (!port_is_stopped(res->port_id)) {
4159 printf("Please stop port %d first\n", res->port_id);
4163 tx_vlan_reset(res->port_id);
4165 cmd_reconfig_device_queue(res->port_id, 1, 1);
4168 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4169 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4170 tx_vlan, "tx_vlan");
4171 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4172 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4174 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4175 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4178 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4179 .f = cmd_tx_vlan_reset_parsed,
4181 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4182 "VLAN header in packets sent on a port",
4184 (void *)&cmd_tx_vlan_reset_tx_vlan,
4185 (void *)&cmd_tx_vlan_reset_reset,
4186 (void *)&cmd_tx_vlan_reset_portid,
4192 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4193 struct cmd_csum_result {
4194 cmdline_fixed_string_t csum;
4195 cmdline_fixed_string_t mode;
4196 cmdline_fixed_string_t proto;
4197 cmdline_fixed_string_t hwsw;
4202 csum_show(int port_id)
4204 struct rte_eth_dev_info dev_info;
4205 uint64_t tx_offloads;
4207 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4208 printf("Parse tunnel is %s\n",
4209 (ports[port_id].parse_tunnel) ? "on" : "off");
4210 printf("IP checksum offload is %s\n",
4211 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4212 printf("UDP checksum offload is %s\n",
4213 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4214 printf("TCP checksum offload is %s\n",
4215 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4216 printf("SCTP checksum offload is %s\n",
4217 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4218 printf("Outer-Ip checksum offload is %s\n",
4219 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4220 printf("Outer-Udp checksum offload is %s\n",
4221 (tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
4223 /* display warnings if configuration is not supported by the NIC */
4224 rte_eth_dev_info_get(port_id, &dev_info);
4225 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
4226 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4227 printf("Warning: hardware IP checksum enabled but not "
4228 "supported by port %d\n", port_id);
4230 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
4231 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
4232 printf("Warning: hardware UDP checksum enabled but not "
4233 "supported by port %d\n", port_id);
4235 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
4236 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
4237 printf("Warning: hardware TCP checksum enabled but not "
4238 "supported by port %d\n", port_id);
4240 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
4241 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4242 printf("Warning: hardware SCTP checksum enabled but not "
4243 "supported by port %d\n", port_id);
4245 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4246 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4247 printf("Warning: hardware outer IP checksum enabled but not "
4248 "supported by port %d\n", port_id);
4250 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
4251 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)
4253 printf("Warning: hardware outer UDP checksum enabled but not "
4254 "supported by port %d\n", port_id);
4259 cmd_csum_parsed(void *parsed_result,
4260 __attribute__((unused)) struct cmdline *cl,
4261 __attribute__((unused)) void *data)
4263 struct cmd_csum_result *res = parsed_result;
4265 uint64_t csum_offloads = 0;
4266 struct rte_eth_dev_info dev_info;
4268 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4269 printf("invalid port %d\n", res->port_id);
4272 if (!port_is_stopped(res->port_id)) {
4273 printf("Please stop port %d first\n", res->port_id);
4277 rte_eth_dev_info_get(res->port_id, &dev_info);
4278 if (!strcmp(res->mode, "set")) {
4280 if (!strcmp(res->hwsw, "hw"))
4283 if (!strcmp(res->proto, "ip")) {
4284 if (hw == 0 || (dev_info.tx_offload_capa &
4285 DEV_TX_OFFLOAD_IPV4_CKSUM)) {
4286 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
4288 printf("IP checksum offload is not supported "
4289 "by port %u\n", res->port_id);
4291 } else if (!strcmp(res->proto, "udp")) {
4292 if (hw == 0 || (dev_info.tx_offload_capa &
4293 DEV_TX_OFFLOAD_UDP_CKSUM)) {
4294 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
4296 printf("UDP checksum offload is not supported "
4297 "by port %u\n", res->port_id);
4299 } else if (!strcmp(res->proto, "tcp")) {
4300 if (hw == 0 || (dev_info.tx_offload_capa &
4301 DEV_TX_OFFLOAD_TCP_CKSUM)) {
4302 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
4304 printf("TCP checksum offload is not supported "
4305 "by port %u\n", res->port_id);
4307 } else if (!strcmp(res->proto, "sctp")) {
4308 if (hw == 0 || (dev_info.tx_offload_capa &
4309 DEV_TX_OFFLOAD_SCTP_CKSUM)) {
4310 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
4312 printf("SCTP checksum offload is not supported "
4313 "by port %u\n", res->port_id);
4315 } else if (!strcmp(res->proto, "outer-ip")) {
4316 if (hw == 0 || (dev_info.tx_offload_capa &
4317 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4319 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4321 printf("Outer IP checksum offload is not "
4322 "supported by port %u\n", res->port_id);
4324 } else if (!strcmp(res->proto, "outer-udp")) {
4325 if (hw == 0 || (dev_info.tx_offload_capa &
4326 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
4328 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM;
4330 printf("Outer UDP checksum offload is not "
4331 "supported by port %u\n", res->port_id);
4336 ports[res->port_id].dev_conf.txmode.offloads |=
4339 ports[res->port_id].dev_conf.txmode.offloads &=
4343 csum_show(res->port_id);
4345 cmd_reconfig_device_queue(res->port_id, 1, 1);
4348 cmdline_parse_token_string_t cmd_csum_csum =
4349 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4351 cmdline_parse_token_string_t cmd_csum_mode =
4352 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4354 cmdline_parse_token_string_t cmd_csum_proto =
4355 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4356 proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
4357 cmdline_parse_token_string_t cmd_csum_hwsw =
4358 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4360 cmdline_parse_token_num_t cmd_csum_portid =
4361 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4364 cmdline_parse_inst_t cmd_csum_set = {
4365 .f = cmd_csum_parsed,
4367 .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
4368 "Enable/Disable hardware calculation of L3/L4 checksum when "
4369 "using csum forward engine",
4371 (void *)&cmd_csum_csum,
4372 (void *)&cmd_csum_mode,
4373 (void *)&cmd_csum_proto,
4374 (void *)&cmd_csum_hwsw,
4375 (void *)&cmd_csum_portid,
4380 cmdline_parse_token_string_t cmd_csum_mode_show =
4381 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4384 cmdline_parse_inst_t cmd_csum_show = {
4385 .f = cmd_csum_parsed,
4387 .help_str = "csum show <port_id>: Show checksum offload configuration",
4389 (void *)&cmd_csum_csum,
4390 (void *)&cmd_csum_mode_show,
4391 (void *)&cmd_csum_portid,
4396 /* Enable/disable tunnel parsing */
4397 struct cmd_csum_tunnel_result {
4398 cmdline_fixed_string_t csum;
4399 cmdline_fixed_string_t parse;
4400 cmdline_fixed_string_t onoff;
4405 cmd_csum_tunnel_parsed(void *parsed_result,
4406 __attribute__((unused)) struct cmdline *cl,
4407 __attribute__((unused)) void *data)
4409 struct cmd_csum_tunnel_result *res = parsed_result;
4411 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4414 if (!strcmp(res->onoff, "on"))
4415 ports[res->port_id].parse_tunnel = 1;
4417 ports[res->port_id].parse_tunnel = 0;
4419 csum_show(res->port_id);
4422 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4423 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4425 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4426 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4427 parse, "parse-tunnel");
4428 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4429 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4431 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4432 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4435 cmdline_parse_inst_t cmd_csum_tunnel = {
4436 .f = cmd_csum_tunnel_parsed,
4438 .help_str = "csum parse-tunnel on|off <port_id>: "
4439 "Enable/Disable parsing of tunnels for csum engine",
4441 (void *)&cmd_csum_tunnel_csum,
4442 (void *)&cmd_csum_tunnel_parse,
4443 (void *)&cmd_csum_tunnel_onoff,
4444 (void *)&cmd_csum_tunnel_portid,
4449 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4450 struct cmd_tso_set_result {
4451 cmdline_fixed_string_t tso;
4452 cmdline_fixed_string_t mode;
4458 cmd_tso_set_parsed(void *parsed_result,
4459 __attribute__((unused)) struct cmdline *cl,
4460 __attribute__((unused)) void *data)
4462 struct cmd_tso_set_result *res = parsed_result;
4463 struct rte_eth_dev_info dev_info;
4465 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4467 if (!port_is_stopped(res->port_id)) {
4468 printf("Please stop port %d first\n", res->port_id);
4472 if (!strcmp(res->mode, "set"))
4473 ports[res->port_id].tso_segsz = res->tso_segsz;
4475 rte_eth_dev_info_get(res->port_id, &dev_info);
4476 if ((ports[res->port_id].tso_segsz != 0) &&
4477 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4478 printf("Error: TSO is not supported by port %d\n",
4483 if (ports[res->port_id].tso_segsz == 0) {
4484 ports[res->port_id].dev_conf.txmode.offloads &=
4485 ~DEV_TX_OFFLOAD_TCP_TSO;
4486 printf("TSO for non-tunneled packets is disabled\n");
4488 ports[res->port_id].dev_conf.txmode.offloads |=
4489 DEV_TX_OFFLOAD_TCP_TSO;
4490 printf("TSO segment size for non-tunneled packets is %d\n",
4491 ports[res->port_id].tso_segsz);
4494 /* display warnings if configuration is not supported by the NIC */
4495 rte_eth_dev_info_get(res->port_id, &dev_info);
4496 if ((ports[res->port_id].tso_segsz != 0) &&
4497 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4498 printf("Warning: TSO enabled but not "
4499 "supported by port %d\n", res->port_id);
4502 cmd_reconfig_device_queue(res->port_id, 1, 1);
4505 cmdline_parse_token_string_t cmd_tso_set_tso =
4506 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4508 cmdline_parse_token_string_t cmd_tso_set_mode =
4509 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4511 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4512 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4514 cmdline_parse_token_num_t cmd_tso_set_portid =
4515 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4518 cmdline_parse_inst_t cmd_tso_set = {
4519 .f = cmd_tso_set_parsed,
4521 .help_str = "tso set <tso_segsz> <port_id>: "
4522 "Set TSO segment size of non-tunneled packets for csum engine "
4525 (void *)&cmd_tso_set_tso,
4526 (void *)&cmd_tso_set_mode,
4527 (void *)&cmd_tso_set_tso_segsz,
4528 (void *)&cmd_tso_set_portid,
4533 cmdline_parse_token_string_t cmd_tso_show_mode =
4534 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4538 cmdline_parse_inst_t cmd_tso_show = {
4539 .f = cmd_tso_set_parsed,
4541 .help_str = "tso show <port_id>: "
4542 "Show TSO segment size of non-tunneled packets for csum engine",
4544 (void *)&cmd_tso_set_tso,
4545 (void *)&cmd_tso_show_mode,
4546 (void *)&cmd_tso_set_portid,
4551 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
4552 struct cmd_tunnel_tso_set_result {
4553 cmdline_fixed_string_t tso;
4554 cmdline_fixed_string_t mode;
4559 static struct rte_eth_dev_info
4560 check_tunnel_tso_nic_support(portid_t port_id)
4562 struct rte_eth_dev_info dev_info;
4564 rte_eth_dev_info_get(port_id, &dev_info);
4565 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
4566 printf("Warning: VXLAN TUNNEL TSO not supported therefore "
4567 "not enabled for port %d\n", port_id);
4568 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
4569 printf("Warning: GRE TUNNEL TSO not supported therefore "
4570 "not enabled for port %d\n", port_id);
4571 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
4572 printf("Warning: IPIP TUNNEL TSO not supported therefore "
4573 "not enabled for port %d\n", port_id);
4574 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
4575 printf("Warning: GENEVE TUNNEL TSO not supported therefore "
4576 "not enabled for port %d\n", port_id);
4577 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
4578 printf("Warning: IP TUNNEL TSO not supported therefore "
4579 "not enabled for port %d\n", port_id);
4580 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
4581 printf("Warning: UDP TUNNEL TSO not supported therefore "
4582 "not enabled for port %d\n", port_id);
4587 cmd_tunnel_tso_set_parsed(void *parsed_result,
4588 __attribute__((unused)) struct cmdline *cl,
4589 __attribute__((unused)) void *data)
4591 struct cmd_tunnel_tso_set_result *res = parsed_result;
4592 struct rte_eth_dev_info dev_info;
4594 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4596 if (!port_is_stopped(res->port_id)) {
4597 printf("Please stop port %d first\n", res->port_id);
4601 if (!strcmp(res->mode, "set"))
4602 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
4604 dev_info = check_tunnel_tso_nic_support(res->port_id);
4605 if (ports[res->port_id].tunnel_tso_segsz == 0) {
4606 ports[res->port_id].dev_conf.txmode.offloads &=
4607 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4608 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4609 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4610 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4611 DEV_TX_OFFLOAD_IP_TNL_TSO |
4612 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4613 printf("TSO for tunneled packets is disabled\n");
4615 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4616 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4617 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4618 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4619 DEV_TX_OFFLOAD_IP_TNL_TSO |
4620 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4622 ports[res->port_id].dev_conf.txmode.offloads |=
4623 (tso_offloads & dev_info.tx_offload_capa);
4624 printf("TSO segment size for tunneled packets is %d\n",
4625 ports[res->port_id].tunnel_tso_segsz);
4627 /* Below conditions are needed to make it work:
4628 * (1) tunnel TSO is supported by the NIC;
4629 * (2) "csum parse_tunnel" must be set so that tunneled pkts
4631 * (3) for tunneled pkts with outer L3 of IPv4,
4632 * "csum set outer-ip" must be set to hw, because after tso,
4633 * total_len of outer IP header is changed, and the checksum
4634 * of outer IP header calculated by sw should be wrong; that
4635 * is not necessary for IPv6 tunneled pkts because there's no
4636 * checksum in IP header anymore.
4639 if (!ports[res->port_id].parse_tunnel)
4640 printf("Warning: csum parse_tunnel must be set "
4641 "so that tunneled packets are recognized\n");
4642 if (!(ports[res->port_id].dev_conf.txmode.offloads &
4643 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
4644 printf("Warning: csum set outer-ip must be set to hw "
4645 "if outer L3 is IPv4; not necessary for IPv6\n");
4648 cmd_reconfig_device_queue(res->port_id, 1, 1);
4651 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
4652 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4654 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
4655 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4657 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
4658 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4660 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
4661 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4664 cmdline_parse_inst_t cmd_tunnel_tso_set = {
4665 .f = cmd_tunnel_tso_set_parsed,
4667 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
4668 "Set TSO segment size of tunneled packets for csum engine "
4671 (void *)&cmd_tunnel_tso_set_tso,
4672 (void *)&cmd_tunnel_tso_set_mode,
4673 (void *)&cmd_tunnel_tso_set_tso_segsz,
4674 (void *)&cmd_tunnel_tso_set_portid,
4679 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
4680 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4684 cmdline_parse_inst_t cmd_tunnel_tso_show = {
4685 .f = cmd_tunnel_tso_set_parsed,
4687 .help_str = "tunnel_tso show <port_id> "
4688 "Show TSO segment size of tunneled packets for csum engine",
4690 (void *)&cmd_tunnel_tso_set_tso,
4691 (void *)&cmd_tunnel_tso_show_mode,
4692 (void *)&cmd_tunnel_tso_set_portid,
4697 /* *** SET GRO FOR A PORT *** */
4698 struct cmd_gro_enable_result {
4699 cmdline_fixed_string_t cmd_set;
4700 cmdline_fixed_string_t cmd_port;
4701 cmdline_fixed_string_t cmd_keyword;
4702 cmdline_fixed_string_t cmd_onoff;
4707 cmd_gro_enable_parsed(void *parsed_result,
4708 __attribute__((unused)) struct cmdline *cl,
4709 __attribute__((unused)) void *data)
4711 struct cmd_gro_enable_result *res;
4713 res = parsed_result;
4714 if (!strcmp(res->cmd_keyword, "gro"))
4715 setup_gro(res->cmd_onoff, res->cmd_pid);
4718 cmdline_parse_token_string_t cmd_gro_enable_set =
4719 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4721 cmdline_parse_token_string_t cmd_gro_enable_port =
4722 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4723 cmd_keyword, "port");
4724 cmdline_parse_token_num_t cmd_gro_enable_pid =
4725 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
4727 cmdline_parse_token_string_t cmd_gro_enable_keyword =
4728 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4729 cmd_keyword, "gro");
4730 cmdline_parse_token_string_t cmd_gro_enable_onoff =
4731 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4732 cmd_onoff, "on#off");
4734 cmdline_parse_inst_t cmd_gro_enable = {
4735 .f = cmd_gro_enable_parsed,
4737 .help_str = "set port <port_id> gro on|off",
4739 (void *)&cmd_gro_enable_set,
4740 (void *)&cmd_gro_enable_port,
4741 (void *)&cmd_gro_enable_pid,
4742 (void *)&cmd_gro_enable_keyword,
4743 (void *)&cmd_gro_enable_onoff,
4748 /* *** DISPLAY GRO CONFIGURATION *** */
4749 struct cmd_gro_show_result {
4750 cmdline_fixed_string_t cmd_show;
4751 cmdline_fixed_string_t cmd_port;
4752 cmdline_fixed_string_t cmd_keyword;
4757 cmd_gro_show_parsed(void *parsed_result,
4758 __attribute__((unused)) struct cmdline *cl,
4759 __attribute__((unused)) void *data)
4761 struct cmd_gro_show_result *res;
4763 res = parsed_result;
4764 if (!strcmp(res->cmd_keyword, "gro"))
4765 show_gro(res->cmd_pid);
4768 cmdline_parse_token_string_t cmd_gro_show_show =
4769 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4771 cmdline_parse_token_string_t cmd_gro_show_port =
4772 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4774 cmdline_parse_token_num_t cmd_gro_show_pid =
4775 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
4777 cmdline_parse_token_string_t cmd_gro_show_keyword =
4778 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4779 cmd_keyword, "gro");
4781 cmdline_parse_inst_t cmd_gro_show = {
4782 .f = cmd_gro_show_parsed,
4784 .help_str = "show port <port_id> gro",
4786 (void *)&cmd_gro_show_show,
4787 (void *)&cmd_gro_show_port,
4788 (void *)&cmd_gro_show_pid,
4789 (void *)&cmd_gro_show_keyword,
4794 /* *** SET FLUSH CYCLES FOR GRO *** */
4795 struct cmd_gro_flush_result {
4796 cmdline_fixed_string_t cmd_set;
4797 cmdline_fixed_string_t cmd_keyword;
4798 cmdline_fixed_string_t cmd_flush;
4803 cmd_gro_flush_parsed(void *parsed_result,
4804 __attribute__((unused)) struct cmdline *cl,
4805 __attribute__((unused)) void *data)
4807 struct cmd_gro_flush_result *res;
4809 res = parsed_result;
4810 if ((!strcmp(res->cmd_keyword, "gro")) &&
4811 (!strcmp(res->cmd_flush, "flush")))
4812 setup_gro_flush_cycles(res->cmd_cycles);
4815 cmdline_parse_token_string_t cmd_gro_flush_set =
4816 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4818 cmdline_parse_token_string_t cmd_gro_flush_keyword =
4819 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4820 cmd_keyword, "gro");
4821 cmdline_parse_token_string_t cmd_gro_flush_flush =
4822 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4823 cmd_flush, "flush");
4824 cmdline_parse_token_num_t cmd_gro_flush_cycles =
4825 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
4828 cmdline_parse_inst_t cmd_gro_flush = {
4829 .f = cmd_gro_flush_parsed,
4831 .help_str = "set gro flush <cycles>",
4833 (void *)&cmd_gro_flush_set,
4834 (void *)&cmd_gro_flush_keyword,
4835 (void *)&cmd_gro_flush_flush,
4836 (void *)&cmd_gro_flush_cycles,
4841 /* *** ENABLE/DISABLE GSO *** */
4842 struct cmd_gso_enable_result {
4843 cmdline_fixed_string_t cmd_set;
4844 cmdline_fixed_string_t cmd_port;
4845 cmdline_fixed_string_t cmd_keyword;
4846 cmdline_fixed_string_t cmd_mode;
4851 cmd_gso_enable_parsed(void *parsed_result,
4852 __attribute__((unused)) struct cmdline *cl,
4853 __attribute__((unused)) void *data)
4855 struct cmd_gso_enable_result *res;
4857 res = parsed_result;
4858 if (!strcmp(res->cmd_keyword, "gso"))
4859 setup_gso(res->cmd_mode, res->cmd_pid);
4862 cmdline_parse_token_string_t cmd_gso_enable_set =
4863 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4865 cmdline_parse_token_string_t cmd_gso_enable_port =
4866 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4868 cmdline_parse_token_string_t cmd_gso_enable_keyword =
4869 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4870 cmd_keyword, "gso");
4871 cmdline_parse_token_string_t cmd_gso_enable_mode =
4872 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4873 cmd_mode, "on#off");
4874 cmdline_parse_token_num_t cmd_gso_enable_pid =
4875 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
4878 cmdline_parse_inst_t cmd_gso_enable = {
4879 .f = cmd_gso_enable_parsed,
4881 .help_str = "set port <port_id> gso on|off",
4883 (void *)&cmd_gso_enable_set,
4884 (void *)&cmd_gso_enable_port,
4885 (void *)&cmd_gso_enable_pid,
4886 (void *)&cmd_gso_enable_keyword,
4887 (void *)&cmd_gso_enable_mode,
4892 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
4893 struct cmd_gso_size_result {
4894 cmdline_fixed_string_t cmd_set;
4895 cmdline_fixed_string_t cmd_keyword;
4896 cmdline_fixed_string_t cmd_segsz;
4901 cmd_gso_size_parsed(void *parsed_result,
4902 __attribute__((unused)) struct cmdline *cl,
4903 __attribute__((unused)) void *data)
4905 struct cmd_gso_size_result *res = parsed_result;
4907 if (test_done == 0) {
4908 printf("Before setting GSO segsz, please first"
4909 " stop fowarding\n");
4913 if (!strcmp(res->cmd_keyword, "gso") &&
4914 !strcmp(res->cmd_segsz, "segsz")) {
4915 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
4916 printf("gso_size should be larger than %zu."
4917 " Please input a legal value\n",
4918 RTE_GSO_SEG_SIZE_MIN);
4920 gso_max_segment_size = res->cmd_size;
4924 cmdline_parse_token_string_t cmd_gso_size_set =
4925 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4927 cmdline_parse_token_string_t cmd_gso_size_keyword =
4928 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4929 cmd_keyword, "gso");
4930 cmdline_parse_token_string_t cmd_gso_size_segsz =
4931 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4932 cmd_segsz, "segsz");
4933 cmdline_parse_token_num_t cmd_gso_size_size =
4934 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
4937 cmdline_parse_inst_t cmd_gso_size = {
4938 .f = cmd_gso_size_parsed,
4940 .help_str = "set gso segsz <length>",
4942 (void *)&cmd_gso_size_set,
4943 (void *)&cmd_gso_size_keyword,
4944 (void *)&cmd_gso_size_segsz,
4945 (void *)&cmd_gso_size_size,
4950 /* *** SHOW GSO CONFIGURATION *** */
4951 struct cmd_gso_show_result {
4952 cmdline_fixed_string_t cmd_show;
4953 cmdline_fixed_string_t cmd_port;
4954 cmdline_fixed_string_t cmd_keyword;
4959 cmd_gso_show_parsed(void *parsed_result,
4960 __attribute__((unused)) struct cmdline *cl,
4961 __attribute__((unused)) void *data)
4963 struct cmd_gso_show_result *res = parsed_result;
4965 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
4966 printf("invalid port id %u\n", res->cmd_pid);
4969 if (!strcmp(res->cmd_keyword, "gso")) {
4970 if (gso_ports[res->cmd_pid].enable) {
4971 printf("Max GSO'd packet size: %uB\n"
4972 "Supported GSO types: TCP/IPv4, "
4973 "UDP/IPv4, VxLAN with inner "
4974 "TCP/IPv4 packet, GRE with inner "
4975 "TCP/IPv4 packet\n",
4976 gso_max_segment_size);
4978 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
4982 cmdline_parse_token_string_t cmd_gso_show_show =
4983 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4985 cmdline_parse_token_string_t cmd_gso_show_port =
4986 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4988 cmdline_parse_token_string_t cmd_gso_show_keyword =
4989 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4990 cmd_keyword, "gso");
4991 cmdline_parse_token_num_t cmd_gso_show_pid =
4992 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
4995 cmdline_parse_inst_t cmd_gso_show = {
4996 .f = cmd_gso_show_parsed,
4998 .help_str = "show port <port_id> gso",
5000 (void *)&cmd_gso_show_show,
5001 (void *)&cmd_gso_show_port,
5002 (void *)&cmd_gso_show_pid,
5003 (void *)&cmd_gso_show_keyword,
5008 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
5009 struct cmd_set_flush_rx {
5010 cmdline_fixed_string_t set;
5011 cmdline_fixed_string_t flush_rx;
5012 cmdline_fixed_string_t mode;
5016 cmd_set_flush_rx_parsed(void *parsed_result,
5017 __attribute__((unused)) struct cmdline *cl,
5018 __attribute__((unused)) void *data)
5020 struct cmd_set_flush_rx *res = parsed_result;
5021 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5024 cmdline_parse_token_string_t cmd_setflushrx_set =
5025 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5027 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
5028 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5029 flush_rx, "flush_rx");
5030 cmdline_parse_token_string_t cmd_setflushrx_mode =
5031 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5035 cmdline_parse_inst_t cmd_set_flush_rx = {
5036 .f = cmd_set_flush_rx_parsed,
5037 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
5040 (void *)&cmd_setflushrx_set,
5041 (void *)&cmd_setflushrx_flush_rx,
5042 (void *)&cmd_setflushrx_mode,
5047 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
5048 struct cmd_set_link_check {
5049 cmdline_fixed_string_t set;
5050 cmdline_fixed_string_t link_check;
5051 cmdline_fixed_string_t mode;
5055 cmd_set_link_check_parsed(void *parsed_result,
5056 __attribute__((unused)) struct cmdline *cl,
5057 __attribute__((unused)) void *data)
5059 struct cmd_set_link_check *res = parsed_result;
5060 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5063 cmdline_parse_token_string_t cmd_setlinkcheck_set =
5064 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5066 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
5067 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5068 link_check, "link_check");
5069 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
5070 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5074 cmdline_parse_inst_t cmd_set_link_check = {
5075 .f = cmd_set_link_check_parsed,
5076 .help_str = "set link_check on|off: Enable/Disable link status check "
5077 "when starting/stopping a port",
5080 (void *)&cmd_setlinkcheck_set,
5081 (void *)&cmd_setlinkcheck_link_check,
5082 (void *)&cmd_setlinkcheck_mode,
5087 /* *** SET NIC BYPASS MODE *** */
5088 struct cmd_set_bypass_mode_result {
5089 cmdline_fixed_string_t set;
5090 cmdline_fixed_string_t bypass;
5091 cmdline_fixed_string_t mode;
5092 cmdline_fixed_string_t value;
5097 cmd_set_bypass_mode_parsed(void *parsed_result,
5098 __attribute__((unused)) struct cmdline *cl,
5099 __attribute__((unused)) void *data)
5101 struct cmd_set_bypass_mode_result *res = parsed_result;
5102 portid_t port_id = res->port_id;
5103 int32_t rc = -EINVAL;
5105 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5106 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5108 if (!strcmp(res->value, "bypass"))
5109 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5110 else if (!strcmp(res->value, "isolate"))
5111 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5113 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5115 /* Set the bypass mode for the relevant port. */
5116 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
5119 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
5122 cmdline_parse_token_string_t cmd_setbypass_mode_set =
5123 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5125 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
5126 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5128 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
5129 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5131 cmdline_parse_token_string_t cmd_setbypass_mode_value =
5132 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5133 value, "normal#bypass#isolate");
5134 cmdline_parse_token_num_t cmd_setbypass_mode_port =
5135 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
5138 cmdline_parse_inst_t cmd_set_bypass_mode = {
5139 .f = cmd_set_bypass_mode_parsed,
5140 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
5141 "Set the NIC bypass mode for port_id",
5144 (void *)&cmd_setbypass_mode_set,
5145 (void *)&cmd_setbypass_mode_bypass,
5146 (void *)&cmd_setbypass_mode_mode,
5147 (void *)&cmd_setbypass_mode_value,
5148 (void *)&cmd_setbypass_mode_port,
5153 /* *** SET NIC BYPASS EVENT *** */
5154 struct cmd_set_bypass_event_result {
5155 cmdline_fixed_string_t set;
5156 cmdline_fixed_string_t bypass;
5157 cmdline_fixed_string_t event;
5158 cmdline_fixed_string_t event_value;
5159 cmdline_fixed_string_t mode;
5160 cmdline_fixed_string_t mode_value;
5165 cmd_set_bypass_event_parsed(void *parsed_result,
5166 __attribute__((unused)) struct cmdline *cl,
5167 __attribute__((unused)) void *data)
5169 int32_t rc = -EINVAL;
5170 struct cmd_set_bypass_event_result *res = parsed_result;
5171 portid_t port_id = res->port_id;
5173 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5174 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5175 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5177 if (!strcmp(res->event_value, "timeout"))
5178 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
5179 else if (!strcmp(res->event_value, "os_on"))
5180 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
5181 else if (!strcmp(res->event_value, "os_off"))
5182 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5183 else if (!strcmp(res->event_value, "power_on"))
5184 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5185 else if (!strcmp(res->event_value, "power_off"))
5186 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5188 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5190 if (!strcmp(res->mode_value, "bypass"))
5191 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5192 else if (!strcmp(res->mode_value, "isolate"))
5193 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5195 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5197 /* Set the watchdog timeout. */
5198 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5201 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5202 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5206 printf("Failed to set timeout value %u "
5207 "for port %d, errto code: %d.\n",
5208 bypass_timeout, port_id, rc);
5212 /* Set the bypass event to transition to bypass mode. */
5213 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5218 printf("\t Failed to set bypass event for port = %d.\n",
5222 cmdline_parse_token_string_t cmd_setbypass_event_set =
5223 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5225 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5226 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5228 cmdline_parse_token_string_t cmd_setbypass_event_event =
5229 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5231 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5232 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5233 event_value, "none#timeout#os_off#os_on#power_on#power_off");
5234 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5235 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5237 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5238 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5239 mode_value, "normal#bypass#isolate");
5240 cmdline_parse_token_num_t cmd_setbypass_event_port =
5241 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5244 cmdline_parse_inst_t cmd_set_bypass_event = {
5245 .f = cmd_set_bypass_event_parsed,
5246 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5247 "power_off mode normal|bypass|isolate <port_id>: "
5248 "Set the NIC bypass event mode for port_id",
5251 (void *)&cmd_setbypass_event_set,
5252 (void *)&cmd_setbypass_event_bypass,
5253 (void *)&cmd_setbypass_event_event,
5254 (void *)&cmd_setbypass_event_event_value,
5255 (void *)&cmd_setbypass_event_mode,
5256 (void *)&cmd_setbypass_event_mode_value,
5257 (void *)&cmd_setbypass_event_port,
5263 /* *** SET NIC BYPASS TIMEOUT *** */
5264 struct cmd_set_bypass_timeout_result {
5265 cmdline_fixed_string_t set;
5266 cmdline_fixed_string_t bypass;
5267 cmdline_fixed_string_t timeout;
5268 cmdline_fixed_string_t value;
5272 cmd_set_bypass_timeout_parsed(void *parsed_result,
5273 __attribute__((unused)) struct cmdline *cl,
5274 __attribute__((unused)) void *data)
5276 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5278 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5279 if (!strcmp(res->value, "1.5"))
5280 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5281 else if (!strcmp(res->value, "2"))
5282 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5283 else if (!strcmp(res->value, "3"))
5284 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5285 else if (!strcmp(res->value, "4"))
5286 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5287 else if (!strcmp(res->value, "8"))
5288 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5289 else if (!strcmp(res->value, "16"))
5290 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5291 else if (!strcmp(res->value, "32"))
5292 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5294 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5298 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5299 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5301 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5302 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5304 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5305 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5306 timeout, "timeout");
5307 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5308 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5309 value, "0#1.5#2#3#4#8#16#32");
5311 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5312 .f = cmd_set_bypass_timeout_parsed,
5313 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5314 "Set the NIC bypass watchdog timeout in seconds",
5317 (void *)&cmd_setbypass_timeout_set,
5318 (void *)&cmd_setbypass_timeout_bypass,
5319 (void *)&cmd_setbypass_timeout_timeout,
5320 (void *)&cmd_setbypass_timeout_value,
5325 /* *** SHOW NIC BYPASS MODE *** */
5326 struct cmd_show_bypass_config_result {
5327 cmdline_fixed_string_t show;
5328 cmdline_fixed_string_t bypass;
5329 cmdline_fixed_string_t config;
5334 cmd_show_bypass_config_parsed(void *parsed_result,
5335 __attribute__((unused)) struct cmdline *cl,
5336 __attribute__((unused)) void *data)
5338 struct cmd_show_bypass_config_result *res = parsed_result;
5339 portid_t port_id = res->port_id;
5341 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5342 uint32_t event_mode;
5343 uint32_t bypass_mode;
5344 uint32_t timeout = bypass_timeout;
5347 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5348 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
5349 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5350 {"UNKNOWN", "normal", "bypass", "isolate"};
5351 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5358 int num_events = (sizeof events) / (sizeof events[0]);
5360 /* Display the bypass mode.*/
5361 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5362 printf("\tFailed to get bypass mode for port = %d\n", port_id);
5366 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5367 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5369 printf("\tbypass mode = %s\n", modes[bypass_mode]);
5372 /* Display the bypass timeout.*/
5373 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5374 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5376 printf("\tbypass timeout = %s\n", timeouts[timeout]);
5378 /* Display the bypass events and associated modes. */
5379 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < num_events; i++) {
5381 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5382 printf("\tFailed to get bypass mode for event = %s\n",
5385 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5386 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5388 printf("\tbypass event: %-16s = %s\n", events[i],
5394 printf("\tFailed to get bypass configuration for port = %d\n",
5398 cmdline_parse_token_string_t cmd_showbypass_config_show =
5399 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5401 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5402 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5404 cmdline_parse_token_string_t cmd_showbypass_config_config =
5405 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5407 cmdline_parse_token_num_t cmd_showbypass_config_port =
5408 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5411 cmdline_parse_inst_t cmd_show_bypass_config = {
5412 .f = cmd_show_bypass_config_parsed,
5413 .help_str = "show bypass config <port_id>: "
5414 "Show the NIC bypass config for port_id",
5417 (void *)&cmd_showbypass_config_show,
5418 (void *)&cmd_showbypass_config_bypass,
5419 (void *)&cmd_showbypass_config_config,
5420 (void *)&cmd_showbypass_config_port,
5425 #ifdef RTE_LIBRTE_PMD_BOND
5426 /* *** SET BONDING MODE *** */
5427 struct cmd_set_bonding_mode_result {
5428 cmdline_fixed_string_t set;
5429 cmdline_fixed_string_t bonding;
5430 cmdline_fixed_string_t mode;
5435 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5436 __attribute__((unused)) struct cmdline *cl,
5437 __attribute__((unused)) void *data)
5439 struct cmd_set_bonding_mode_result *res = parsed_result;
5440 portid_t port_id = res->port_id;
5442 /* Set the bonding mode for the relevant port. */
5443 if (0 != rte_eth_bond_mode_set(port_id, res->value))
5444 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
5447 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5448 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5450 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5451 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5452 bonding, "bonding");
5453 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5454 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5456 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5457 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5459 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5460 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5463 cmdline_parse_inst_t cmd_set_bonding_mode = {
5464 .f = cmd_set_bonding_mode_parsed,
5465 .help_str = "set bonding mode <mode_value> <port_id>: "
5466 "Set the bonding mode for port_id",
5469 (void *) &cmd_setbonding_mode_set,
5470 (void *) &cmd_setbonding_mode_bonding,
5471 (void *) &cmd_setbonding_mode_mode,
5472 (void *) &cmd_setbonding_mode_value,
5473 (void *) &cmd_setbonding_mode_port,
5478 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5479 struct cmd_set_bonding_lacp_dedicated_queues_result {
5480 cmdline_fixed_string_t set;
5481 cmdline_fixed_string_t bonding;
5482 cmdline_fixed_string_t lacp;
5483 cmdline_fixed_string_t dedicated_queues;
5485 cmdline_fixed_string_t mode;
5488 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5489 __attribute__((unused)) struct cmdline *cl,
5490 __attribute__((unused)) void *data)
5492 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5493 portid_t port_id = res->port_id;
5494 struct rte_port *port;
5496 port = &ports[port_id];
5498 /** Check if the port is not started **/
5499 if (port->port_status != RTE_PORT_STOPPED) {
5500 printf("Please stop port %d first\n", port_id);
5504 if (!strcmp(res->mode, "enable")) {
5505 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5506 printf("Dedicate queues for LACP control packets"
5509 printf("Enabling dedicate queues for LACP control "
5510 "packets on port %d failed\n", port_id);
5511 } else if (!strcmp(res->mode, "disable")) {
5512 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5513 printf("Dedicated queues for LACP control packets "
5516 printf("Disabling dedicated queues for LACP control "
5517 "traffic on port %d failed\n", port_id);
5521 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5522 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5524 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
5525 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5526 bonding, "bonding");
5527 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
5528 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5530 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
5531 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5532 dedicated_queues, "dedicated_queues");
5533 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
5534 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5536 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
5537 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5538 mode, "enable#disable");
5540 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
5541 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
5542 .help_str = "set bonding lacp dedicated_queues <port_id> "
5544 "Enable/disable dedicated queues for LACP control traffic for port_id",
5547 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
5548 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
5549 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
5550 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
5551 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
5552 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
5557 /* *** SET BALANCE XMIT POLICY *** */
5558 struct cmd_set_bonding_balance_xmit_policy_result {
5559 cmdline_fixed_string_t set;
5560 cmdline_fixed_string_t bonding;
5561 cmdline_fixed_string_t balance_xmit_policy;
5563 cmdline_fixed_string_t policy;
5566 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
5567 __attribute__((unused)) struct cmdline *cl,
5568 __attribute__((unused)) void *data)
5570 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
5571 portid_t port_id = res->port_id;
5574 if (!strcmp(res->policy, "l2")) {
5575 policy = BALANCE_XMIT_POLICY_LAYER2;
5576 } else if (!strcmp(res->policy, "l23")) {
5577 policy = BALANCE_XMIT_POLICY_LAYER23;
5578 } else if (!strcmp(res->policy, "l34")) {
5579 policy = BALANCE_XMIT_POLICY_LAYER34;
5581 printf("\t Invalid xmit policy selection");
5585 /* Set the bonding mode for the relevant port. */
5586 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
5587 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
5592 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
5593 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5595 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
5596 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5597 bonding, "bonding");
5598 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
5599 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5600 balance_xmit_policy, "balance_xmit_policy");
5601 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
5602 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5604 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
5605 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5606 policy, "l2#l23#l34");
5608 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
5609 .f = cmd_set_bonding_balance_xmit_policy_parsed,
5610 .help_str = "set bonding balance_xmit_policy <port_id> "
5612 "Set the bonding balance_xmit_policy for port_id",
5615 (void *)&cmd_setbonding_balance_xmit_policy_set,
5616 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
5617 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
5618 (void *)&cmd_setbonding_balance_xmit_policy_port,
5619 (void *)&cmd_setbonding_balance_xmit_policy_policy,
5624 /* *** SHOW NIC BONDING CONFIGURATION *** */
5625 struct cmd_show_bonding_config_result {
5626 cmdline_fixed_string_t show;
5627 cmdline_fixed_string_t bonding;
5628 cmdline_fixed_string_t config;
5632 static void cmd_show_bonding_config_parsed(void *parsed_result,
5633 __attribute__((unused)) struct cmdline *cl,
5634 __attribute__((unused)) void *data)
5636 struct cmd_show_bonding_config_result *res = parsed_result;
5637 int bonding_mode, agg_mode;
5638 portid_t slaves[RTE_MAX_ETHPORTS];
5639 int num_slaves, num_active_slaves;
5642 portid_t port_id = res->port_id;
5644 /* Display the bonding mode.*/
5645 bonding_mode = rte_eth_bond_mode_get(port_id);
5646 if (bonding_mode < 0) {
5647 printf("\tFailed to get bonding mode for port = %d\n", port_id);
5650 printf("\tBonding mode: %d\n", bonding_mode);
5652 if (bonding_mode == BONDING_MODE_BALANCE) {
5653 int balance_xmit_policy;
5655 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
5656 if (balance_xmit_policy < 0) {
5657 printf("\tFailed to get balance xmit policy for port = %d\n",
5661 printf("\tBalance Xmit Policy: ");
5663 switch (balance_xmit_policy) {
5664 case BALANCE_XMIT_POLICY_LAYER2:
5665 printf("BALANCE_XMIT_POLICY_LAYER2");
5667 case BALANCE_XMIT_POLICY_LAYER23:
5668 printf("BALANCE_XMIT_POLICY_LAYER23");
5670 case BALANCE_XMIT_POLICY_LAYER34:
5671 printf("BALANCE_XMIT_POLICY_LAYER34");
5678 if (bonding_mode == BONDING_MODE_8023AD) {
5679 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
5680 printf("\tIEEE802.3AD Aggregator Mode: ");
5683 printf("bandwidth");
5695 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
5697 if (num_slaves < 0) {
5698 printf("\tFailed to get slave list for port = %d\n", port_id);
5701 if (num_slaves > 0) {
5702 printf("\tSlaves (%d): [", num_slaves);
5703 for (i = 0; i < num_slaves - 1; i++)
5704 printf("%d ", slaves[i]);
5706 printf("%d]\n", slaves[num_slaves - 1]);
5708 printf("\tSlaves: []\n");
5712 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
5715 if (num_active_slaves < 0) {
5716 printf("\tFailed to get active slave list for port = %d\n", port_id);
5719 if (num_active_slaves > 0) {
5720 printf("\tActive Slaves (%d): [", num_active_slaves);
5721 for (i = 0; i < num_active_slaves - 1; i++)
5722 printf("%d ", slaves[i]);
5724 printf("%d]\n", slaves[num_active_slaves - 1]);
5727 printf("\tActive Slaves: []\n");
5731 primary_id = rte_eth_bond_primary_get(port_id);
5732 if (primary_id < 0) {
5733 printf("\tFailed to get primary slave for port = %d\n", port_id);
5736 printf("\tPrimary: [%d]\n", primary_id);
5740 cmdline_parse_token_string_t cmd_showbonding_config_show =
5741 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5743 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
5744 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5745 bonding, "bonding");
5746 cmdline_parse_token_string_t cmd_showbonding_config_config =
5747 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5749 cmdline_parse_token_num_t cmd_showbonding_config_port =
5750 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
5753 cmdline_parse_inst_t cmd_show_bonding_config = {
5754 .f = cmd_show_bonding_config_parsed,
5755 .help_str = "show bonding config <port_id>: "
5756 "Show the bonding config for port_id",
5759 (void *)&cmd_showbonding_config_show,
5760 (void *)&cmd_showbonding_config_bonding,
5761 (void *)&cmd_showbonding_config_config,
5762 (void *)&cmd_showbonding_config_port,
5767 /* *** SET BONDING PRIMARY *** */
5768 struct cmd_set_bonding_primary_result {
5769 cmdline_fixed_string_t set;
5770 cmdline_fixed_string_t bonding;
5771 cmdline_fixed_string_t primary;
5776 static void cmd_set_bonding_primary_parsed(void *parsed_result,
5777 __attribute__((unused)) struct cmdline *cl,
5778 __attribute__((unused)) void *data)
5780 struct cmd_set_bonding_primary_result *res = parsed_result;
5781 portid_t master_port_id = res->port_id;
5782 portid_t slave_port_id = res->slave_id;
5784 /* Set the primary slave for a bonded device. */
5785 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
5786 printf("\t Failed to set primary slave for port = %d.\n",
5793 cmdline_parse_token_string_t cmd_setbonding_primary_set =
5794 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5796 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
5797 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5798 bonding, "bonding");
5799 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
5800 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5801 primary, "primary");
5802 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
5803 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5805 cmdline_parse_token_num_t cmd_setbonding_primary_port =
5806 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5809 cmdline_parse_inst_t cmd_set_bonding_primary = {
5810 .f = cmd_set_bonding_primary_parsed,
5811 .help_str = "set bonding primary <slave_id> <port_id>: "
5812 "Set the primary slave for port_id",
5815 (void *)&cmd_setbonding_primary_set,
5816 (void *)&cmd_setbonding_primary_bonding,
5817 (void *)&cmd_setbonding_primary_primary,
5818 (void *)&cmd_setbonding_primary_slave,
5819 (void *)&cmd_setbonding_primary_port,
5824 /* *** ADD SLAVE *** */
5825 struct cmd_add_bonding_slave_result {
5826 cmdline_fixed_string_t add;
5827 cmdline_fixed_string_t bonding;
5828 cmdline_fixed_string_t slave;
5833 static void cmd_add_bonding_slave_parsed(void *parsed_result,
5834 __attribute__((unused)) struct cmdline *cl,
5835 __attribute__((unused)) void *data)
5837 struct cmd_add_bonding_slave_result *res = parsed_result;
5838 portid_t master_port_id = res->port_id;
5839 portid_t slave_port_id = res->slave_id;
5841 /* add the slave for a bonded device. */
5842 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
5843 printf("\t Failed to add slave %d to master port = %d.\n",
5844 slave_port_id, master_port_id);
5848 set_port_slave_flag(slave_port_id);
5851 cmdline_parse_token_string_t cmd_addbonding_slave_add =
5852 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5854 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
5855 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5856 bonding, "bonding");
5857 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
5858 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5860 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
5861 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5863 cmdline_parse_token_num_t cmd_addbonding_slave_port =
5864 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5867 cmdline_parse_inst_t cmd_add_bonding_slave = {
5868 .f = cmd_add_bonding_slave_parsed,
5869 .help_str = "add bonding slave <slave_id> <port_id>: "
5870 "Add a slave device to a bonded device",
5873 (void *)&cmd_addbonding_slave_add,
5874 (void *)&cmd_addbonding_slave_bonding,
5875 (void *)&cmd_addbonding_slave_slave,
5876 (void *)&cmd_addbonding_slave_slaveid,
5877 (void *)&cmd_addbonding_slave_port,
5882 /* *** REMOVE SLAVE *** */
5883 struct cmd_remove_bonding_slave_result {
5884 cmdline_fixed_string_t remove;
5885 cmdline_fixed_string_t bonding;
5886 cmdline_fixed_string_t slave;
5891 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
5892 __attribute__((unused)) struct cmdline *cl,
5893 __attribute__((unused)) void *data)
5895 struct cmd_remove_bonding_slave_result *res = parsed_result;
5896 portid_t master_port_id = res->port_id;
5897 portid_t slave_port_id = res->slave_id;
5899 /* remove the slave from a bonded device. */
5900 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
5901 printf("\t Failed to remove slave %d from master port = %d.\n",
5902 slave_port_id, master_port_id);
5906 clear_port_slave_flag(slave_port_id);
5909 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
5910 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5912 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
5913 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5914 bonding, "bonding");
5915 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
5916 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5918 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
5919 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5921 cmdline_parse_token_num_t cmd_removebonding_slave_port =
5922 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5925 cmdline_parse_inst_t cmd_remove_bonding_slave = {
5926 .f = cmd_remove_bonding_slave_parsed,
5927 .help_str = "remove bonding slave <slave_id> <port_id>: "
5928 "Remove a slave device from a bonded device",
5931 (void *)&cmd_removebonding_slave_remove,
5932 (void *)&cmd_removebonding_slave_bonding,
5933 (void *)&cmd_removebonding_slave_slave,
5934 (void *)&cmd_removebonding_slave_slaveid,
5935 (void *)&cmd_removebonding_slave_port,
5940 /* *** CREATE BONDED DEVICE *** */
5941 struct cmd_create_bonded_device_result {
5942 cmdline_fixed_string_t create;
5943 cmdline_fixed_string_t bonded;
5944 cmdline_fixed_string_t device;
5949 static int bond_dev_num = 0;
5951 static void cmd_create_bonded_device_parsed(void *parsed_result,
5952 __attribute__((unused)) struct cmdline *cl,
5953 __attribute__((unused)) void *data)
5955 struct cmd_create_bonded_device_result *res = parsed_result;
5956 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
5959 if (test_done == 0) {
5960 printf("Please stop forwarding first\n");
5964 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
5967 /* Create a new bonded device. */
5968 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
5970 printf("\t Failed to create bonded device.\n");
5973 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
5976 /* Update number of ports */
5977 nb_ports = rte_eth_dev_count_avail();
5978 reconfig(port_id, res->socket);
5979 rte_eth_promiscuous_enable(port_id);
5980 ports[port_id].need_setup = 0;
5981 ports[port_id].port_status = RTE_PORT_STOPPED;
5986 cmdline_parse_token_string_t cmd_createbonded_device_create =
5987 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5989 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
5990 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5992 cmdline_parse_token_string_t cmd_createbonded_device_device =
5993 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5995 cmdline_parse_token_num_t cmd_createbonded_device_mode =
5996 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5998 cmdline_parse_token_num_t cmd_createbonded_device_socket =
5999 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6002 cmdline_parse_inst_t cmd_create_bonded_device = {
6003 .f = cmd_create_bonded_device_parsed,
6004 .help_str = "create bonded device <mode> <socket>: "
6005 "Create a new bonded device with specific bonding mode and socket",
6008 (void *)&cmd_createbonded_device_create,
6009 (void *)&cmd_createbonded_device_bonded,
6010 (void *)&cmd_createbonded_device_device,
6011 (void *)&cmd_createbonded_device_mode,
6012 (void *)&cmd_createbonded_device_socket,
6017 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
6018 struct cmd_set_bond_mac_addr_result {
6019 cmdline_fixed_string_t set;
6020 cmdline_fixed_string_t bonding;
6021 cmdline_fixed_string_t mac_addr;
6023 struct ether_addr address;
6026 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
6027 __attribute__((unused)) struct cmdline *cl,
6028 __attribute__((unused)) void *data)
6030 struct cmd_set_bond_mac_addr_result *res = parsed_result;
6033 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
6036 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
6038 /* check the return value and print it if is < 0 */
6040 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6043 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
6044 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
6045 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
6046 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
6048 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
6049 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
6051 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
6052 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
6054 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
6055 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
6057 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
6058 .f = cmd_set_bond_mac_addr_parsed,
6060 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
6062 (void *)&cmd_set_bond_mac_addr_set,
6063 (void *)&cmd_set_bond_mac_addr_bonding,
6064 (void *)&cmd_set_bond_mac_addr_mac,
6065 (void *)&cmd_set_bond_mac_addr_portnum,
6066 (void *)&cmd_set_bond_mac_addr_addr,
6072 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
6073 struct cmd_set_bond_mon_period_result {
6074 cmdline_fixed_string_t set;
6075 cmdline_fixed_string_t bonding;
6076 cmdline_fixed_string_t mon_period;
6081 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
6082 __attribute__((unused)) struct cmdline *cl,
6083 __attribute__((unused)) void *data)
6085 struct cmd_set_bond_mon_period_result *res = parsed_result;
6088 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
6090 /* check the return value and print it if is < 0 */
6092 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6095 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
6096 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6098 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
6099 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6100 bonding, "bonding");
6101 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
6102 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6103 mon_period, "mon_period");
6104 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
6105 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6107 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
6108 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6111 cmdline_parse_inst_t cmd_set_bond_mon_period = {
6112 .f = cmd_set_bond_mon_period_parsed,
6114 .help_str = "set bonding mon_period <port_id> <period_ms>",
6116 (void *)&cmd_set_bond_mon_period_set,
6117 (void *)&cmd_set_bond_mon_period_bonding,
6118 (void *)&cmd_set_bond_mon_period_mon_period,
6119 (void *)&cmd_set_bond_mon_period_portnum,
6120 (void *)&cmd_set_bond_mon_period_period_ms,
6127 struct cmd_set_bonding_agg_mode_policy_result {
6128 cmdline_fixed_string_t set;
6129 cmdline_fixed_string_t bonding;
6130 cmdline_fixed_string_t agg_mode;
6132 cmdline_fixed_string_t policy;
6137 cmd_set_bonding_agg_mode(void *parsed_result,
6138 __attribute__((unused)) struct cmdline *cl,
6139 __attribute__((unused)) void *data)
6141 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
6142 uint8_t policy = AGG_BANDWIDTH;
6144 if (!strcmp(res->policy, "bandwidth"))
6145 policy = AGG_BANDWIDTH;
6146 else if (!strcmp(res->policy, "stable"))
6147 policy = AGG_STABLE;
6148 else if (!strcmp(res->policy, "count"))
6151 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
6155 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
6156 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6158 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
6159 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6160 bonding, "bonding");
6162 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
6163 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6164 agg_mode, "agg_mode");
6166 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
6167 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6170 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6171 TOKEN_STRING_INITIALIZER(
6172 struct cmd_set_bonding_balance_xmit_policy_result,
6173 policy, "stable#bandwidth#count");
6175 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6176 .f = cmd_set_bonding_agg_mode,
6178 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6180 (void *)&cmd_set_bonding_agg_mode_set,
6181 (void *)&cmd_set_bonding_agg_mode_bonding,
6182 (void *)&cmd_set_bonding_agg_mode_agg_mode,
6183 (void *)&cmd_set_bonding_agg_mode_portnum,
6184 (void *)&cmd_set_bonding_agg_mode_policy_string,
6190 #endif /* RTE_LIBRTE_PMD_BOND */
6192 /* *** SET FORWARDING MODE *** */
6193 struct cmd_set_fwd_mode_result {
6194 cmdline_fixed_string_t set;
6195 cmdline_fixed_string_t fwd;
6196 cmdline_fixed_string_t mode;
6199 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6200 __attribute__((unused)) struct cmdline *cl,
6201 __attribute__((unused)) void *data)
6203 struct cmd_set_fwd_mode_result *res = parsed_result;
6206 set_pkt_forwarding_mode(res->mode);
6209 cmdline_parse_token_string_t cmd_setfwd_set =
6210 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6211 cmdline_parse_token_string_t cmd_setfwd_fwd =
6212 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6213 cmdline_parse_token_string_t cmd_setfwd_mode =
6214 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6215 "" /* defined at init */);
6217 cmdline_parse_inst_t cmd_set_fwd_mode = {
6218 .f = cmd_set_fwd_mode_parsed,
6220 .help_str = NULL, /* defined at init */
6222 (void *)&cmd_setfwd_set,
6223 (void *)&cmd_setfwd_fwd,
6224 (void *)&cmd_setfwd_mode,
6229 static void cmd_set_fwd_mode_init(void)
6232 static char token[128];
6233 static char help[256];
6234 cmdline_parse_token_string_t *token_struct;
6236 modes = list_pkt_forwarding_modes();
6237 snprintf(help, sizeof(help), "set fwd %s: "
6238 "Set packet forwarding mode", modes);
6239 cmd_set_fwd_mode.help_str = help;
6241 /* string token separator is # */
6242 for (c = token; *modes != '\0'; modes++)
6247 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6248 token_struct->string_data.str = token;
6251 /* *** SET RETRY FORWARDING MODE *** */
6252 struct cmd_set_fwd_retry_mode_result {
6253 cmdline_fixed_string_t set;
6254 cmdline_fixed_string_t fwd;
6255 cmdline_fixed_string_t mode;
6256 cmdline_fixed_string_t retry;
6259 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6260 __attribute__((unused)) struct cmdline *cl,
6261 __attribute__((unused)) void *data)
6263 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6266 set_pkt_forwarding_mode(res->mode);
6269 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6270 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6272 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6273 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6275 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6276 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6278 "" /* defined at init */);
6279 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6280 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6283 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6284 .f = cmd_set_fwd_retry_mode_parsed,
6286 .help_str = NULL, /* defined at init */
6288 (void *)&cmd_setfwd_retry_set,
6289 (void *)&cmd_setfwd_retry_fwd,
6290 (void *)&cmd_setfwd_retry_mode,
6291 (void *)&cmd_setfwd_retry_retry,
6296 static void cmd_set_fwd_retry_mode_init(void)
6299 static char token[128];
6300 static char help[256];
6301 cmdline_parse_token_string_t *token_struct;
6303 modes = list_pkt_forwarding_retry_modes();
6304 snprintf(help, sizeof(help), "set fwd %s retry: "
6305 "Set packet forwarding mode with retry", modes);
6306 cmd_set_fwd_retry_mode.help_str = help;
6308 /* string token separator is # */
6309 for (c = token; *modes != '\0'; modes++)
6314 token_struct = (cmdline_parse_token_string_t *)
6315 cmd_set_fwd_retry_mode.tokens[2];
6316 token_struct->string_data.str = token;
6319 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6320 struct cmd_set_burst_tx_retry_result {
6321 cmdline_fixed_string_t set;
6322 cmdline_fixed_string_t burst;
6323 cmdline_fixed_string_t tx;
6324 cmdline_fixed_string_t delay;
6326 cmdline_fixed_string_t retry;
6330 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6331 __attribute__((unused)) struct cmdline *cl,
6332 __attribute__((unused)) void *data)
6334 struct cmd_set_burst_tx_retry_result *res = parsed_result;
6336 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6337 && !strcmp(res->tx, "tx")) {
6338 if (!strcmp(res->delay, "delay"))
6339 burst_tx_delay_time = res->time;
6340 if (!strcmp(res->retry, "retry"))
6341 burst_tx_retry_num = res->retry_num;
6346 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6347 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6348 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6349 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6351 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6352 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6353 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6354 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6355 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6356 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
6357 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6358 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6359 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6360 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
6362 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6363 .f = cmd_set_burst_tx_retry_parsed,
6364 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6366 (void *)&cmd_set_burst_tx_retry_set,
6367 (void *)&cmd_set_burst_tx_retry_burst,
6368 (void *)&cmd_set_burst_tx_retry_tx,
6369 (void *)&cmd_set_burst_tx_retry_delay,
6370 (void *)&cmd_set_burst_tx_retry_time,
6371 (void *)&cmd_set_burst_tx_retry_retry,
6372 (void *)&cmd_set_burst_tx_retry_retry_num,
6377 /* *** SET PROMISC MODE *** */
6378 struct cmd_set_promisc_mode_result {
6379 cmdline_fixed_string_t set;
6380 cmdline_fixed_string_t promisc;
6381 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6382 uint16_t port_num; /* valid if "allports" argument == 0 */
6383 cmdline_fixed_string_t mode;
6386 static void cmd_set_promisc_mode_parsed(void *parsed_result,
6387 __attribute__((unused)) struct cmdline *cl,
6390 struct cmd_set_promisc_mode_result *res = parsed_result;
6394 if (!strcmp(res->mode, "on"))
6401 RTE_ETH_FOREACH_DEV(i) {
6403 rte_eth_promiscuous_enable(i);
6405 rte_eth_promiscuous_disable(i);
6410 rte_eth_promiscuous_enable(res->port_num);
6412 rte_eth_promiscuous_disable(res->port_num);
6416 cmdline_parse_token_string_t cmd_setpromisc_set =
6417 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6418 cmdline_parse_token_string_t cmd_setpromisc_promisc =
6419 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6421 cmdline_parse_token_string_t cmd_setpromisc_portall =
6422 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6424 cmdline_parse_token_num_t cmd_setpromisc_portnum =
6425 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6427 cmdline_parse_token_string_t cmd_setpromisc_mode =
6428 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6431 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6432 .f = cmd_set_promisc_mode_parsed,
6434 .help_str = "set promisc all on|off: Set promisc mode for all ports",
6436 (void *)&cmd_setpromisc_set,
6437 (void *)&cmd_setpromisc_promisc,
6438 (void *)&cmd_setpromisc_portall,
6439 (void *)&cmd_setpromisc_mode,
6444 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6445 .f = cmd_set_promisc_mode_parsed,
6447 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6449 (void *)&cmd_setpromisc_set,
6450 (void *)&cmd_setpromisc_promisc,
6451 (void *)&cmd_setpromisc_portnum,
6452 (void *)&cmd_setpromisc_mode,
6457 /* *** SET ALLMULTI MODE *** */
6458 struct cmd_set_allmulti_mode_result {
6459 cmdline_fixed_string_t set;
6460 cmdline_fixed_string_t allmulti;
6461 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6462 uint16_t port_num; /* valid if "allports" argument == 0 */
6463 cmdline_fixed_string_t mode;
6466 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6467 __attribute__((unused)) struct cmdline *cl,
6470 struct cmd_set_allmulti_mode_result *res = parsed_result;
6474 if (!strcmp(res->mode, "on"))
6481 RTE_ETH_FOREACH_DEV(i) {
6483 rte_eth_allmulticast_enable(i);
6485 rte_eth_allmulticast_disable(i);
6490 rte_eth_allmulticast_enable(res->port_num);
6492 rte_eth_allmulticast_disable(res->port_num);
6496 cmdline_parse_token_string_t cmd_setallmulti_set =
6497 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6498 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6499 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6501 cmdline_parse_token_string_t cmd_setallmulti_portall =
6502 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6504 cmdline_parse_token_num_t cmd_setallmulti_portnum =
6505 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6507 cmdline_parse_token_string_t cmd_setallmulti_mode =
6508 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6511 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6512 .f = cmd_set_allmulti_mode_parsed,
6514 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6516 (void *)&cmd_setallmulti_set,
6517 (void *)&cmd_setallmulti_allmulti,
6518 (void *)&cmd_setallmulti_portall,
6519 (void *)&cmd_setallmulti_mode,
6524 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6525 .f = cmd_set_allmulti_mode_parsed,
6527 .help_str = "set allmulti <port_id> on|off: "
6528 "Set allmulti mode on port_id",
6530 (void *)&cmd_setallmulti_set,
6531 (void *)&cmd_setallmulti_allmulti,
6532 (void *)&cmd_setallmulti_portnum,
6533 (void *)&cmd_setallmulti_mode,
6538 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
6539 struct cmd_link_flow_ctrl_set_result {
6540 cmdline_fixed_string_t set;
6541 cmdline_fixed_string_t flow_ctrl;
6542 cmdline_fixed_string_t rx;
6543 cmdline_fixed_string_t rx_lfc_mode;
6544 cmdline_fixed_string_t tx;
6545 cmdline_fixed_string_t tx_lfc_mode;
6546 cmdline_fixed_string_t mac_ctrl_frame_fwd;
6547 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
6548 cmdline_fixed_string_t autoneg_str;
6549 cmdline_fixed_string_t autoneg;
6550 cmdline_fixed_string_t hw_str;
6551 uint32_t high_water;
6552 cmdline_fixed_string_t lw_str;
6554 cmdline_fixed_string_t pt_str;
6555 uint16_t pause_time;
6556 cmdline_fixed_string_t xon_str;
6561 cmdline_parse_token_string_t cmd_lfc_set_set =
6562 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6564 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
6565 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6566 flow_ctrl, "flow_ctrl");
6567 cmdline_parse_token_string_t cmd_lfc_set_rx =
6568 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6570 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
6571 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6572 rx_lfc_mode, "on#off");
6573 cmdline_parse_token_string_t cmd_lfc_set_tx =
6574 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6576 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
6577 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6578 tx_lfc_mode, "on#off");
6579 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
6580 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6581 hw_str, "high_water");
6582 cmdline_parse_token_num_t cmd_lfc_set_high_water =
6583 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6584 high_water, UINT32);
6585 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
6586 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6587 lw_str, "low_water");
6588 cmdline_parse_token_num_t cmd_lfc_set_low_water =
6589 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6591 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
6592 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6593 pt_str, "pause_time");
6594 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
6595 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6596 pause_time, UINT16);
6597 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
6598 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6599 xon_str, "send_xon");
6600 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
6601 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6603 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
6604 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6605 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
6606 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6607 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6608 mac_ctrl_frame_fwd_mode, "on#off");
6609 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6610 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6611 autoneg_str, "autoneg");
6612 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6613 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6615 cmdline_parse_token_num_t cmd_lfc_set_portid =
6616 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6619 /* forward declaration */
6621 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6624 cmdline_parse_inst_t cmd_link_flow_control_set = {
6625 .f = cmd_link_flow_ctrl_set_parsed,
6627 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6628 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6629 "autoneg on|off <port_id>: Configure the Ethernet flow control",
6631 (void *)&cmd_lfc_set_set,
6632 (void *)&cmd_lfc_set_flow_ctrl,
6633 (void *)&cmd_lfc_set_rx,
6634 (void *)&cmd_lfc_set_rx_mode,
6635 (void *)&cmd_lfc_set_tx,
6636 (void *)&cmd_lfc_set_tx_mode,
6637 (void *)&cmd_lfc_set_high_water,
6638 (void *)&cmd_lfc_set_low_water,
6639 (void *)&cmd_lfc_set_pause_time,
6640 (void *)&cmd_lfc_set_send_xon,
6641 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6642 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6643 (void *)&cmd_lfc_set_autoneg_str,
6644 (void *)&cmd_lfc_set_autoneg,
6645 (void *)&cmd_lfc_set_portid,
6650 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6651 .f = cmd_link_flow_ctrl_set_parsed,
6652 .data = (void *)&cmd_link_flow_control_set_rx,
6653 .help_str = "set flow_ctrl rx on|off <port_id>: "
6654 "Change rx flow control parameter",
6656 (void *)&cmd_lfc_set_set,
6657 (void *)&cmd_lfc_set_flow_ctrl,
6658 (void *)&cmd_lfc_set_rx,
6659 (void *)&cmd_lfc_set_rx_mode,
6660 (void *)&cmd_lfc_set_portid,
6665 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6666 .f = cmd_link_flow_ctrl_set_parsed,
6667 .data = (void *)&cmd_link_flow_control_set_tx,
6668 .help_str = "set flow_ctrl tx on|off <port_id>: "
6669 "Change tx flow control parameter",
6671 (void *)&cmd_lfc_set_set,
6672 (void *)&cmd_lfc_set_flow_ctrl,
6673 (void *)&cmd_lfc_set_tx,
6674 (void *)&cmd_lfc_set_tx_mode,
6675 (void *)&cmd_lfc_set_portid,
6680 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
6681 .f = cmd_link_flow_ctrl_set_parsed,
6682 .data = (void *)&cmd_link_flow_control_set_hw,
6683 .help_str = "set flow_ctrl high_water <value> <port_id>: "
6684 "Change high water flow control parameter",
6686 (void *)&cmd_lfc_set_set,
6687 (void *)&cmd_lfc_set_flow_ctrl,
6688 (void *)&cmd_lfc_set_high_water_str,
6689 (void *)&cmd_lfc_set_high_water,
6690 (void *)&cmd_lfc_set_portid,
6695 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
6696 .f = cmd_link_flow_ctrl_set_parsed,
6697 .data = (void *)&cmd_link_flow_control_set_lw,
6698 .help_str = "set flow_ctrl low_water <value> <port_id>: "
6699 "Change low water flow control parameter",
6701 (void *)&cmd_lfc_set_set,
6702 (void *)&cmd_lfc_set_flow_ctrl,
6703 (void *)&cmd_lfc_set_low_water_str,
6704 (void *)&cmd_lfc_set_low_water,
6705 (void *)&cmd_lfc_set_portid,
6710 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
6711 .f = cmd_link_flow_ctrl_set_parsed,
6712 .data = (void *)&cmd_link_flow_control_set_pt,
6713 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
6714 "Change pause time flow control parameter",
6716 (void *)&cmd_lfc_set_set,
6717 (void *)&cmd_lfc_set_flow_ctrl,
6718 (void *)&cmd_lfc_set_pause_time_str,
6719 (void *)&cmd_lfc_set_pause_time,
6720 (void *)&cmd_lfc_set_portid,
6725 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
6726 .f = cmd_link_flow_ctrl_set_parsed,
6727 .data = (void *)&cmd_link_flow_control_set_xon,
6728 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
6729 "Change send_xon flow control parameter",
6731 (void *)&cmd_lfc_set_set,
6732 (void *)&cmd_lfc_set_flow_ctrl,
6733 (void *)&cmd_lfc_set_send_xon_str,
6734 (void *)&cmd_lfc_set_send_xon,
6735 (void *)&cmd_lfc_set_portid,
6740 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
6741 .f = cmd_link_flow_ctrl_set_parsed,
6742 .data = (void *)&cmd_link_flow_control_set_macfwd,
6743 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
6744 "Change mac ctrl fwd flow control parameter",
6746 (void *)&cmd_lfc_set_set,
6747 (void *)&cmd_lfc_set_flow_ctrl,
6748 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6749 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6750 (void *)&cmd_lfc_set_portid,
6755 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
6756 .f = cmd_link_flow_ctrl_set_parsed,
6757 .data = (void *)&cmd_link_flow_control_set_autoneg,
6758 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
6759 "Change autoneg flow control parameter",
6761 (void *)&cmd_lfc_set_set,
6762 (void *)&cmd_lfc_set_flow_ctrl,
6763 (void *)&cmd_lfc_set_autoneg_str,
6764 (void *)&cmd_lfc_set_autoneg,
6765 (void *)&cmd_lfc_set_portid,
6771 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
6772 __attribute__((unused)) struct cmdline *cl,
6775 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
6776 cmdline_parse_inst_t *cmd = data;
6777 struct rte_eth_fc_conf fc_conf;
6783 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6784 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6785 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6786 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6788 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
6789 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
6792 /* Partial command line, retrieve current configuration */
6794 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
6796 printf("cannot get current flow ctrl parameters, return"
6797 "code = %d\n", ret);
6801 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
6802 (fc_conf.mode == RTE_FC_FULL))
6804 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
6805 (fc_conf.mode == RTE_FC_FULL))
6809 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
6810 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
6812 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
6813 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
6815 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
6817 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
6818 fc_conf.high_water = res->high_water;
6820 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
6821 fc_conf.low_water = res->low_water;
6823 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
6824 fc_conf.pause_time = res->pause_time;
6826 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
6827 fc_conf.send_xon = res->send_xon;
6829 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
6830 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
6831 fc_conf.mac_ctrl_frame_fwd = 1;
6833 fc_conf.mac_ctrl_frame_fwd = 0;
6836 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
6837 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
6839 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
6841 printf("bad flow contrl parameter, return code = %d \n", ret);
6844 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
6845 struct cmd_priority_flow_ctrl_set_result {
6846 cmdline_fixed_string_t set;
6847 cmdline_fixed_string_t pfc_ctrl;
6848 cmdline_fixed_string_t rx;
6849 cmdline_fixed_string_t rx_pfc_mode;
6850 cmdline_fixed_string_t tx;
6851 cmdline_fixed_string_t tx_pfc_mode;
6852 uint32_t high_water;
6854 uint16_t pause_time;
6860 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
6861 __attribute__((unused)) struct cmdline *cl,
6862 __attribute__((unused)) void *data)
6864 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
6865 struct rte_eth_pfc_conf pfc_conf;
6866 int rx_fc_enable, tx_fc_enable;
6870 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6871 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6872 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6873 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6875 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
6876 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
6879 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
6880 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
6881 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
6882 pfc_conf.fc.high_water = res->high_water;
6883 pfc_conf.fc.low_water = res->low_water;
6884 pfc_conf.fc.pause_time = res->pause_time;
6885 pfc_conf.priority = res->priority;
6887 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
6889 printf("bad priority flow contrl parameter, return code = %d \n", ret);
6892 cmdline_parse_token_string_t cmd_pfc_set_set =
6893 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6895 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
6896 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6897 pfc_ctrl, "pfc_ctrl");
6898 cmdline_parse_token_string_t cmd_pfc_set_rx =
6899 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6901 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
6902 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6903 rx_pfc_mode, "on#off");
6904 cmdline_parse_token_string_t cmd_pfc_set_tx =
6905 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6907 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
6908 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6909 tx_pfc_mode, "on#off");
6910 cmdline_parse_token_num_t cmd_pfc_set_high_water =
6911 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6912 high_water, UINT32);
6913 cmdline_parse_token_num_t cmd_pfc_set_low_water =
6914 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6916 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
6917 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6918 pause_time, UINT16);
6919 cmdline_parse_token_num_t cmd_pfc_set_priority =
6920 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6922 cmdline_parse_token_num_t cmd_pfc_set_portid =
6923 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6926 cmdline_parse_inst_t cmd_priority_flow_control_set = {
6927 .f = cmd_priority_flow_ctrl_set_parsed,
6929 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
6930 "<pause_time> <priority> <port_id>: "
6931 "Configure the Ethernet priority flow control",
6933 (void *)&cmd_pfc_set_set,
6934 (void *)&cmd_pfc_set_flow_ctrl,
6935 (void *)&cmd_pfc_set_rx,
6936 (void *)&cmd_pfc_set_rx_mode,
6937 (void *)&cmd_pfc_set_tx,
6938 (void *)&cmd_pfc_set_tx_mode,
6939 (void *)&cmd_pfc_set_high_water,
6940 (void *)&cmd_pfc_set_low_water,
6941 (void *)&cmd_pfc_set_pause_time,
6942 (void *)&cmd_pfc_set_priority,
6943 (void *)&cmd_pfc_set_portid,
6948 /* *** RESET CONFIGURATION *** */
6949 struct cmd_reset_result {
6950 cmdline_fixed_string_t reset;
6951 cmdline_fixed_string_t def;
6954 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
6956 __attribute__((unused)) void *data)
6958 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
6959 set_def_fwd_config();
6962 cmdline_parse_token_string_t cmd_reset_set =
6963 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
6964 cmdline_parse_token_string_t cmd_reset_def =
6965 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
6968 cmdline_parse_inst_t cmd_reset = {
6969 .f = cmd_reset_parsed,
6971 .help_str = "set default: Reset default forwarding configuration",
6973 (void *)&cmd_reset_set,
6974 (void *)&cmd_reset_def,
6979 /* *** START FORWARDING *** */
6980 struct cmd_start_result {
6981 cmdline_fixed_string_t start;
6984 cmdline_parse_token_string_t cmd_start_start =
6985 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
6987 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
6988 __attribute__((unused)) struct cmdline *cl,
6989 __attribute__((unused)) void *data)
6991 start_packet_forwarding(0);
6994 cmdline_parse_inst_t cmd_start = {
6995 .f = cmd_start_parsed,
6997 .help_str = "start: Start packet forwarding",
6999 (void *)&cmd_start_start,
7004 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7005 struct cmd_start_tx_first_result {
7006 cmdline_fixed_string_t start;
7007 cmdline_fixed_string_t tx_first;
7011 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
7012 __attribute__((unused)) struct cmdline *cl,
7013 __attribute__((unused)) void *data)
7015 start_packet_forwarding(1);
7018 cmdline_parse_token_string_t cmd_start_tx_first_start =
7019 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7021 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7022 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7023 tx_first, "tx_first");
7025 cmdline_parse_inst_t cmd_start_tx_first = {
7026 .f = cmd_start_tx_first_parsed,
7028 .help_str = "start tx_first: Start packet forwarding, "
7029 "after sending 1 burst of packets",
7031 (void *)&cmd_start_tx_first_start,
7032 (void *)&cmd_start_tx_first_tx_first,
7037 /* *** START FORWARDING WITH N TX BURST FIRST *** */
7038 struct cmd_start_tx_first_n_result {
7039 cmdline_fixed_string_t start;
7040 cmdline_fixed_string_t tx_first;
7045 cmd_start_tx_first_n_parsed(void *parsed_result,
7046 __attribute__((unused)) struct cmdline *cl,
7047 __attribute__((unused)) void *data)
7049 struct cmd_start_tx_first_n_result *res = parsed_result;
7051 start_packet_forwarding(res->tx_num);
7054 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7055 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7057 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7058 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7059 tx_first, "tx_first");
7060 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7061 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7064 cmdline_parse_inst_t cmd_start_tx_first_n = {
7065 .f = cmd_start_tx_first_n_parsed,
7067 .help_str = "start tx_first <num>: "
7068 "packet forwarding, after sending <num> bursts of packets",
7070 (void *)&cmd_start_tx_first_n_start,
7071 (void *)&cmd_start_tx_first_n_tx_first,
7072 (void *)&cmd_start_tx_first_n_tx_num,
7077 /* *** SET LINK UP *** */
7078 struct cmd_set_link_up_result {
7079 cmdline_fixed_string_t set;
7080 cmdline_fixed_string_t link_up;
7081 cmdline_fixed_string_t port;
7085 cmdline_parse_token_string_t cmd_set_link_up_set =
7086 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7087 cmdline_parse_token_string_t cmd_set_link_up_link_up =
7088 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7090 cmdline_parse_token_string_t cmd_set_link_up_port =
7091 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7092 cmdline_parse_token_num_t cmd_set_link_up_port_id =
7093 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16);
7095 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
7096 __attribute__((unused)) struct cmdline *cl,
7097 __attribute__((unused)) void *data)
7099 struct cmd_set_link_up_result *res = parsed_result;
7100 dev_set_link_up(res->port_id);
7103 cmdline_parse_inst_t cmd_set_link_up = {
7104 .f = cmd_set_link_up_parsed,
7106 .help_str = "set link-up port <port id>",
7108 (void *)&cmd_set_link_up_set,
7109 (void *)&cmd_set_link_up_link_up,
7110 (void *)&cmd_set_link_up_port,
7111 (void *)&cmd_set_link_up_port_id,
7116 /* *** SET LINK DOWN *** */
7117 struct cmd_set_link_down_result {
7118 cmdline_fixed_string_t set;
7119 cmdline_fixed_string_t link_down;
7120 cmdline_fixed_string_t port;
7124 cmdline_parse_token_string_t cmd_set_link_down_set =
7125 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
7126 cmdline_parse_token_string_t cmd_set_link_down_link_down =
7127 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
7129 cmdline_parse_token_string_t cmd_set_link_down_port =
7130 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
7131 cmdline_parse_token_num_t cmd_set_link_down_port_id =
7132 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16);
7134 static void cmd_set_link_down_parsed(
7135 __attribute__((unused)) void *parsed_result,
7136 __attribute__((unused)) struct cmdline *cl,
7137 __attribute__((unused)) void *data)
7139 struct cmd_set_link_down_result *res = parsed_result;
7140 dev_set_link_down(res->port_id);
7143 cmdline_parse_inst_t cmd_set_link_down = {
7144 .f = cmd_set_link_down_parsed,
7146 .help_str = "set link-down port <port id>",
7148 (void *)&cmd_set_link_down_set,
7149 (void *)&cmd_set_link_down_link_down,
7150 (void *)&cmd_set_link_down_port,
7151 (void *)&cmd_set_link_down_port_id,
7156 /* *** SHOW CFG *** */
7157 struct cmd_showcfg_result {
7158 cmdline_fixed_string_t show;
7159 cmdline_fixed_string_t cfg;
7160 cmdline_fixed_string_t what;
7163 static void cmd_showcfg_parsed(void *parsed_result,
7164 __attribute__((unused)) struct cmdline *cl,
7165 __attribute__((unused)) void *data)
7167 struct cmd_showcfg_result *res = parsed_result;
7168 if (!strcmp(res->what, "rxtx"))
7169 rxtx_config_display();
7170 else if (!strcmp(res->what, "cores"))
7171 fwd_lcores_config_display();
7172 else if (!strcmp(res->what, "fwd"))
7173 pkt_fwd_config_display(&cur_fwd_config);
7174 else if (!strcmp(res->what, "txpkts"))
7175 show_tx_pkt_segments();
7178 cmdline_parse_token_string_t cmd_showcfg_show =
7179 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7180 cmdline_parse_token_string_t cmd_showcfg_port =
7181 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7182 cmdline_parse_token_string_t cmd_showcfg_what =
7183 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7184 "rxtx#cores#fwd#txpkts");
7186 cmdline_parse_inst_t cmd_showcfg = {
7187 .f = cmd_showcfg_parsed,
7189 .help_str = "show config rxtx|cores|fwd|txpkts",
7191 (void *)&cmd_showcfg_show,
7192 (void *)&cmd_showcfg_port,
7193 (void *)&cmd_showcfg_what,
7198 /* *** SHOW ALL PORT INFO *** */
7199 struct cmd_showportall_result {
7200 cmdline_fixed_string_t show;
7201 cmdline_fixed_string_t port;
7202 cmdline_fixed_string_t what;
7203 cmdline_fixed_string_t all;
7206 static void cmd_showportall_parsed(void *parsed_result,
7207 __attribute__((unused)) struct cmdline *cl,
7208 __attribute__((unused)) void *data)
7212 struct cmd_showportall_result *res = parsed_result;
7213 if (!strcmp(res->show, "clear")) {
7214 if (!strcmp(res->what, "stats"))
7215 RTE_ETH_FOREACH_DEV(i)
7217 else if (!strcmp(res->what, "xstats"))
7218 RTE_ETH_FOREACH_DEV(i)
7219 nic_xstats_clear(i);
7220 } else if (!strcmp(res->what, "info"))
7221 RTE_ETH_FOREACH_DEV(i)
7222 port_infos_display(i);
7223 else if (!strcmp(res->what, "summary")) {
7224 port_summary_header_display();
7225 RTE_ETH_FOREACH_DEV(i)
7226 port_summary_display(i);
7228 else if (!strcmp(res->what, "stats"))
7229 RTE_ETH_FOREACH_DEV(i)
7230 nic_stats_display(i);
7231 else if (!strcmp(res->what, "xstats"))
7232 RTE_ETH_FOREACH_DEV(i)
7233 nic_xstats_display(i);
7234 else if (!strcmp(res->what, "fdir"))
7235 RTE_ETH_FOREACH_DEV(i)
7237 else if (!strcmp(res->what, "stat_qmap"))
7238 RTE_ETH_FOREACH_DEV(i)
7239 nic_stats_mapping_display(i);
7240 else if (!strcmp(res->what, "dcb_tc"))
7241 RTE_ETH_FOREACH_DEV(i)
7242 port_dcb_info_display(i);
7243 else if (!strcmp(res->what, "cap"))
7244 RTE_ETH_FOREACH_DEV(i)
7245 port_offload_cap_display(i);
7248 cmdline_parse_token_string_t cmd_showportall_show =
7249 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7251 cmdline_parse_token_string_t cmd_showportall_port =
7252 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7253 cmdline_parse_token_string_t cmd_showportall_what =
7254 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7255 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7256 cmdline_parse_token_string_t cmd_showportall_all =
7257 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7258 cmdline_parse_inst_t cmd_showportall = {
7259 .f = cmd_showportall_parsed,
7261 .help_str = "show|clear port "
7262 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
7264 (void *)&cmd_showportall_show,
7265 (void *)&cmd_showportall_port,
7266 (void *)&cmd_showportall_what,
7267 (void *)&cmd_showportall_all,
7272 /* *** SHOW PORT INFO *** */
7273 struct cmd_showport_result {
7274 cmdline_fixed_string_t show;
7275 cmdline_fixed_string_t port;
7276 cmdline_fixed_string_t what;
7280 static void cmd_showport_parsed(void *parsed_result,
7281 __attribute__((unused)) struct cmdline *cl,
7282 __attribute__((unused)) void *data)
7284 struct cmd_showport_result *res = parsed_result;
7285 if (!strcmp(res->show, "clear")) {
7286 if (!strcmp(res->what, "stats"))
7287 nic_stats_clear(res->portnum);
7288 else if (!strcmp(res->what, "xstats"))
7289 nic_xstats_clear(res->portnum);
7290 } else if (!strcmp(res->what, "info"))
7291 port_infos_display(res->portnum);
7292 else if (!strcmp(res->what, "summary")) {
7293 port_summary_header_display();
7294 port_summary_display(res->portnum);
7296 else if (!strcmp(res->what, "stats"))
7297 nic_stats_display(res->portnum);
7298 else if (!strcmp(res->what, "xstats"))
7299 nic_xstats_display(res->portnum);
7300 else if (!strcmp(res->what, "fdir"))
7301 fdir_get_infos(res->portnum);
7302 else if (!strcmp(res->what, "stat_qmap"))
7303 nic_stats_mapping_display(res->portnum);
7304 else if (!strcmp(res->what, "dcb_tc"))
7305 port_dcb_info_display(res->portnum);
7306 else if (!strcmp(res->what, "cap"))
7307 port_offload_cap_display(res->portnum);
7310 cmdline_parse_token_string_t cmd_showport_show =
7311 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7313 cmdline_parse_token_string_t cmd_showport_port =
7314 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7315 cmdline_parse_token_string_t cmd_showport_what =
7316 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7317 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7318 cmdline_parse_token_num_t cmd_showport_portnum =
7319 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
7321 cmdline_parse_inst_t cmd_showport = {
7322 .f = cmd_showport_parsed,
7324 .help_str = "show|clear port "
7325 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
7328 (void *)&cmd_showport_show,
7329 (void *)&cmd_showport_port,
7330 (void *)&cmd_showport_what,
7331 (void *)&cmd_showport_portnum,
7336 /* *** SHOW QUEUE INFO *** */
7337 struct cmd_showqueue_result {
7338 cmdline_fixed_string_t show;
7339 cmdline_fixed_string_t type;
7340 cmdline_fixed_string_t what;
7346 cmd_showqueue_parsed(void *parsed_result,
7347 __attribute__((unused)) struct cmdline *cl,
7348 __attribute__((unused)) void *data)
7350 struct cmd_showqueue_result *res = parsed_result;
7352 if (!strcmp(res->type, "rxq"))
7353 rx_queue_infos_display(res->portnum, res->queuenum);
7354 else if (!strcmp(res->type, "txq"))
7355 tx_queue_infos_display(res->portnum, res->queuenum);
7358 cmdline_parse_token_string_t cmd_showqueue_show =
7359 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
7360 cmdline_parse_token_string_t cmd_showqueue_type =
7361 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
7362 cmdline_parse_token_string_t cmd_showqueue_what =
7363 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
7364 cmdline_parse_token_num_t cmd_showqueue_portnum =
7365 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16);
7366 cmdline_parse_token_num_t cmd_showqueue_queuenum =
7367 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
7369 cmdline_parse_inst_t cmd_showqueue = {
7370 .f = cmd_showqueue_parsed,
7372 .help_str = "show rxq|txq info <port_id> <queue_id>",
7374 (void *)&cmd_showqueue_show,
7375 (void *)&cmd_showqueue_type,
7376 (void *)&cmd_showqueue_what,
7377 (void *)&cmd_showqueue_portnum,
7378 (void *)&cmd_showqueue_queuenum,
7383 /* *** READ PORT REGISTER *** */
7384 struct cmd_read_reg_result {
7385 cmdline_fixed_string_t read;
7386 cmdline_fixed_string_t reg;
7392 cmd_read_reg_parsed(void *parsed_result,
7393 __attribute__((unused)) struct cmdline *cl,
7394 __attribute__((unused)) void *data)
7396 struct cmd_read_reg_result *res = parsed_result;
7397 port_reg_display(res->port_id, res->reg_off);
7400 cmdline_parse_token_string_t cmd_read_reg_read =
7401 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
7402 cmdline_parse_token_string_t cmd_read_reg_reg =
7403 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
7404 cmdline_parse_token_num_t cmd_read_reg_port_id =
7405 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16);
7406 cmdline_parse_token_num_t cmd_read_reg_reg_off =
7407 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
7409 cmdline_parse_inst_t cmd_read_reg = {
7410 .f = cmd_read_reg_parsed,
7412 .help_str = "read reg <port_id> <reg_off>",
7414 (void *)&cmd_read_reg_read,
7415 (void *)&cmd_read_reg_reg,
7416 (void *)&cmd_read_reg_port_id,
7417 (void *)&cmd_read_reg_reg_off,
7422 /* *** READ PORT REGISTER BIT FIELD *** */
7423 struct cmd_read_reg_bit_field_result {
7424 cmdline_fixed_string_t read;
7425 cmdline_fixed_string_t regfield;
7433 cmd_read_reg_bit_field_parsed(void *parsed_result,
7434 __attribute__((unused)) struct cmdline *cl,
7435 __attribute__((unused)) void *data)
7437 struct cmd_read_reg_bit_field_result *res = parsed_result;
7438 port_reg_bit_field_display(res->port_id, res->reg_off,
7439 res->bit1_pos, res->bit2_pos);
7442 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
7443 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
7445 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
7446 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
7447 regfield, "regfield");
7448 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
7449 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
7451 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
7452 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
7454 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
7455 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
7457 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
7458 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
7461 cmdline_parse_inst_t cmd_read_reg_bit_field = {
7462 .f = cmd_read_reg_bit_field_parsed,
7464 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
7465 "Read register bit field between bit_x and bit_y included",
7467 (void *)&cmd_read_reg_bit_field_read,
7468 (void *)&cmd_read_reg_bit_field_regfield,
7469 (void *)&cmd_read_reg_bit_field_port_id,
7470 (void *)&cmd_read_reg_bit_field_reg_off,
7471 (void *)&cmd_read_reg_bit_field_bit1_pos,
7472 (void *)&cmd_read_reg_bit_field_bit2_pos,
7477 /* *** READ PORT REGISTER BIT *** */
7478 struct cmd_read_reg_bit_result {
7479 cmdline_fixed_string_t read;
7480 cmdline_fixed_string_t regbit;
7487 cmd_read_reg_bit_parsed(void *parsed_result,
7488 __attribute__((unused)) struct cmdline *cl,
7489 __attribute__((unused)) void *data)
7491 struct cmd_read_reg_bit_result *res = parsed_result;
7492 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
7495 cmdline_parse_token_string_t cmd_read_reg_bit_read =
7496 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
7497 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
7498 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
7500 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
7501 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16);
7502 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
7503 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
7504 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
7505 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
7507 cmdline_parse_inst_t cmd_read_reg_bit = {
7508 .f = cmd_read_reg_bit_parsed,
7510 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
7512 (void *)&cmd_read_reg_bit_read,
7513 (void *)&cmd_read_reg_bit_regbit,
7514 (void *)&cmd_read_reg_bit_port_id,
7515 (void *)&cmd_read_reg_bit_reg_off,
7516 (void *)&cmd_read_reg_bit_bit_pos,
7521 /* *** WRITE PORT REGISTER *** */
7522 struct cmd_write_reg_result {
7523 cmdline_fixed_string_t write;
7524 cmdline_fixed_string_t reg;
7531 cmd_write_reg_parsed(void *parsed_result,
7532 __attribute__((unused)) struct cmdline *cl,
7533 __attribute__((unused)) void *data)
7535 struct cmd_write_reg_result *res = parsed_result;
7536 port_reg_set(res->port_id, res->reg_off, res->value);
7539 cmdline_parse_token_string_t cmd_write_reg_write =
7540 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
7541 cmdline_parse_token_string_t cmd_write_reg_reg =
7542 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
7543 cmdline_parse_token_num_t cmd_write_reg_port_id =
7544 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16);
7545 cmdline_parse_token_num_t cmd_write_reg_reg_off =
7546 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
7547 cmdline_parse_token_num_t cmd_write_reg_value =
7548 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
7550 cmdline_parse_inst_t cmd_write_reg = {
7551 .f = cmd_write_reg_parsed,
7553 .help_str = "write reg <port_id> <reg_off> <reg_value>",
7555 (void *)&cmd_write_reg_write,
7556 (void *)&cmd_write_reg_reg,
7557 (void *)&cmd_write_reg_port_id,
7558 (void *)&cmd_write_reg_reg_off,
7559 (void *)&cmd_write_reg_value,
7564 /* *** WRITE PORT REGISTER BIT FIELD *** */
7565 struct cmd_write_reg_bit_field_result {
7566 cmdline_fixed_string_t write;
7567 cmdline_fixed_string_t regfield;
7576 cmd_write_reg_bit_field_parsed(void *parsed_result,
7577 __attribute__((unused)) struct cmdline *cl,
7578 __attribute__((unused)) void *data)
7580 struct cmd_write_reg_bit_field_result *res = parsed_result;
7581 port_reg_bit_field_set(res->port_id, res->reg_off,
7582 res->bit1_pos, res->bit2_pos, res->value);
7585 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
7586 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
7588 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
7589 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
7590 regfield, "regfield");
7591 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
7592 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
7594 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
7595 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
7597 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
7598 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
7600 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
7601 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
7603 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
7604 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
7607 cmdline_parse_inst_t cmd_write_reg_bit_field = {
7608 .f = cmd_write_reg_bit_field_parsed,
7610 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
7612 "Set register bit field between bit_x and bit_y included",
7614 (void *)&cmd_write_reg_bit_field_write,
7615 (void *)&cmd_write_reg_bit_field_regfield,
7616 (void *)&cmd_write_reg_bit_field_port_id,
7617 (void *)&cmd_write_reg_bit_field_reg_off,
7618 (void *)&cmd_write_reg_bit_field_bit1_pos,
7619 (void *)&cmd_write_reg_bit_field_bit2_pos,
7620 (void *)&cmd_write_reg_bit_field_value,
7625 /* *** WRITE PORT REGISTER BIT *** */
7626 struct cmd_write_reg_bit_result {
7627 cmdline_fixed_string_t write;
7628 cmdline_fixed_string_t regbit;
7636 cmd_write_reg_bit_parsed(void *parsed_result,
7637 __attribute__((unused)) struct cmdline *cl,
7638 __attribute__((unused)) void *data)
7640 struct cmd_write_reg_bit_result *res = parsed_result;
7641 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
7644 cmdline_parse_token_string_t cmd_write_reg_bit_write =
7645 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
7647 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
7648 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
7650 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
7651 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16);
7652 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
7653 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
7654 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
7655 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
7656 cmdline_parse_token_num_t cmd_write_reg_bit_value =
7657 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
7659 cmdline_parse_inst_t cmd_write_reg_bit = {
7660 .f = cmd_write_reg_bit_parsed,
7662 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
7665 (void *)&cmd_write_reg_bit_write,
7666 (void *)&cmd_write_reg_bit_regbit,
7667 (void *)&cmd_write_reg_bit_port_id,
7668 (void *)&cmd_write_reg_bit_reg_off,
7669 (void *)&cmd_write_reg_bit_bit_pos,
7670 (void *)&cmd_write_reg_bit_value,
7675 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
7676 struct cmd_read_rxd_txd_result {
7677 cmdline_fixed_string_t read;
7678 cmdline_fixed_string_t rxd_txd;
7685 cmd_read_rxd_txd_parsed(void *parsed_result,
7686 __attribute__((unused)) struct cmdline *cl,
7687 __attribute__((unused)) void *data)
7689 struct cmd_read_rxd_txd_result *res = parsed_result;
7691 if (!strcmp(res->rxd_txd, "rxd"))
7692 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7693 else if (!strcmp(res->rxd_txd, "txd"))
7694 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7697 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
7698 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
7699 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
7700 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
7702 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
7703 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16);
7704 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
7705 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
7706 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
7707 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
7709 cmdline_parse_inst_t cmd_read_rxd_txd = {
7710 .f = cmd_read_rxd_txd_parsed,
7712 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
7714 (void *)&cmd_read_rxd_txd_read,
7715 (void *)&cmd_read_rxd_txd_rxd_txd,
7716 (void *)&cmd_read_rxd_txd_port_id,
7717 (void *)&cmd_read_rxd_txd_queue_id,
7718 (void *)&cmd_read_rxd_txd_desc_id,
7724 struct cmd_quit_result {
7725 cmdline_fixed_string_t quit;
7728 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
7730 __attribute__((unused)) void *data)
7735 cmdline_parse_token_string_t cmd_quit_quit =
7736 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
7738 cmdline_parse_inst_t cmd_quit = {
7739 .f = cmd_quit_parsed,
7741 .help_str = "quit: Exit application",
7743 (void *)&cmd_quit_quit,
7748 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
7749 struct cmd_mac_addr_result {
7750 cmdline_fixed_string_t mac_addr_cmd;
7751 cmdline_fixed_string_t what;
7753 struct ether_addr address;
7756 static void cmd_mac_addr_parsed(void *parsed_result,
7757 __attribute__((unused)) struct cmdline *cl,
7758 __attribute__((unused)) void *data)
7760 struct cmd_mac_addr_result *res = parsed_result;
7763 if (strcmp(res->what, "add") == 0)
7764 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
7765 else if (strcmp(res->what, "set") == 0)
7766 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
7769 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
7771 /* check the return value and print it if is < 0 */
7773 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
7777 cmdline_parse_token_string_t cmd_mac_addr_cmd =
7778 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
7780 cmdline_parse_token_string_t cmd_mac_addr_what =
7781 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
7783 cmdline_parse_token_num_t cmd_mac_addr_portnum =
7784 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
7786 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
7787 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
7789 cmdline_parse_inst_t cmd_mac_addr = {
7790 .f = cmd_mac_addr_parsed,
7792 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
7793 "Add/Remove/Set MAC address on port_id",
7795 (void *)&cmd_mac_addr_cmd,
7796 (void *)&cmd_mac_addr_what,
7797 (void *)&cmd_mac_addr_portnum,
7798 (void *)&cmd_mac_addr_addr,
7803 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
7804 struct cmd_eth_peer_result {
7805 cmdline_fixed_string_t set;
7806 cmdline_fixed_string_t eth_peer;
7808 cmdline_fixed_string_t peer_addr;
7811 static void cmd_set_eth_peer_parsed(void *parsed_result,
7812 __attribute__((unused)) struct cmdline *cl,
7813 __attribute__((unused)) void *data)
7815 struct cmd_eth_peer_result *res = parsed_result;
7817 if (test_done == 0) {
7818 printf("Please stop forwarding first\n");
7821 if (!strcmp(res->eth_peer, "eth-peer")) {
7822 set_fwd_eth_peer(res->port_id, res->peer_addr);
7826 cmdline_parse_token_string_t cmd_eth_peer_set =
7827 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
7828 cmdline_parse_token_string_t cmd_eth_peer =
7829 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
7830 cmdline_parse_token_num_t cmd_eth_peer_port_id =
7831 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, UINT16);
7832 cmdline_parse_token_string_t cmd_eth_peer_addr =
7833 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
7835 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
7836 .f = cmd_set_eth_peer_parsed,
7838 .help_str = "set eth-peer <port_id> <peer_mac>",
7840 (void *)&cmd_eth_peer_set,
7841 (void *)&cmd_eth_peer,
7842 (void *)&cmd_eth_peer_port_id,
7843 (void *)&cmd_eth_peer_addr,
7848 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
7849 struct cmd_set_qmap_result {
7850 cmdline_fixed_string_t set;
7851 cmdline_fixed_string_t qmap;
7852 cmdline_fixed_string_t what;
7859 cmd_set_qmap_parsed(void *parsed_result,
7860 __attribute__((unused)) struct cmdline *cl,
7861 __attribute__((unused)) void *data)
7863 struct cmd_set_qmap_result *res = parsed_result;
7864 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
7866 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
7869 cmdline_parse_token_string_t cmd_setqmap_set =
7870 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7872 cmdline_parse_token_string_t cmd_setqmap_qmap =
7873 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7875 cmdline_parse_token_string_t cmd_setqmap_what =
7876 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7878 cmdline_parse_token_num_t cmd_setqmap_portid =
7879 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7881 cmdline_parse_token_num_t cmd_setqmap_queueid =
7882 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7884 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
7885 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7888 cmdline_parse_inst_t cmd_set_qmap = {
7889 .f = cmd_set_qmap_parsed,
7891 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
7892 "Set statistics mapping value on tx|rx queue_id of port_id",
7894 (void *)&cmd_setqmap_set,
7895 (void *)&cmd_setqmap_qmap,
7896 (void *)&cmd_setqmap_what,
7897 (void *)&cmd_setqmap_portid,
7898 (void *)&cmd_setqmap_queueid,
7899 (void *)&cmd_setqmap_mapvalue,
7904 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
7905 struct cmd_set_xstats_hide_zero_result {
7906 cmdline_fixed_string_t keyword;
7907 cmdline_fixed_string_t name;
7908 cmdline_fixed_string_t on_off;
7912 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
7913 __attribute__((unused)) struct cmdline *cl,
7914 __attribute__((unused)) void *data)
7916 struct cmd_set_xstats_hide_zero_result *res;
7917 uint16_t on_off = 0;
7919 res = parsed_result;
7920 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
7921 set_xstats_hide_zero(on_off);
7924 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
7925 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7927 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
7928 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7929 name, "xstats-hide-zero");
7930 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
7931 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7934 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
7935 .f = cmd_set_xstats_hide_zero_parsed,
7937 .help_str = "set xstats-hide-zero on|off",
7939 (void *)&cmd_set_xstats_hide_zero_keyword,
7940 (void *)&cmd_set_xstats_hide_zero_name,
7941 (void *)&cmd_set_xstats_hide_zero_on_off,
7946 /* *** CONFIGURE UNICAST HASH TABLE *** */
7947 struct cmd_set_uc_hash_table {
7948 cmdline_fixed_string_t set;
7949 cmdline_fixed_string_t port;
7951 cmdline_fixed_string_t what;
7952 struct ether_addr address;
7953 cmdline_fixed_string_t mode;
7957 cmd_set_uc_hash_parsed(void *parsed_result,
7958 __attribute__((unused)) struct cmdline *cl,
7959 __attribute__((unused)) void *data)
7962 struct cmd_set_uc_hash_table *res = parsed_result;
7964 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7966 if (strcmp(res->what, "uta") == 0)
7967 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
7968 &res->address,(uint8_t)is_on);
7970 printf("bad unicast hash table parameter, return code = %d \n", ret);
7974 cmdline_parse_token_string_t cmd_set_uc_hash_set =
7975 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7977 cmdline_parse_token_string_t cmd_set_uc_hash_port =
7978 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7980 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
7981 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
7983 cmdline_parse_token_string_t cmd_set_uc_hash_what =
7984 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7986 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
7987 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
7989 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
7990 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7993 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
7994 .f = cmd_set_uc_hash_parsed,
7996 .help_str = "set port <port_id> uta <mac_addr> on|off)",
7998 (void *)&cmd_set_uc_hash_set,
7999 (void *)&cmd_set_uc_hash_port,
8000 (void *)&cmd_set_uc_hash_portid,
8001 (void *)&cmd_set_uc_hash_what,
8002 (void *)&cmd_set_uc_hash_mac,
8003 (void *)&cmd_set_uc_hash_mode,
8008 struct cmd_set_uc_all_hash_table {
8009 cmdline_fixed_string_t set;
8010 cmdline_fixed_string_t port;
8012 cmdline_fixed_string_t what;
8013 cmdline_fixed_string_t value;
8014 cmdline_fixed_string_t mode;
8018 cmd_set_uc_all_hash_parsed(void *parsed_result,
8019 __attribute__((unused)) struct cmdline *cl,
8020 __attribute__((unused)) void *data)
8023 struct cmd_set_uc_all_hash_table *res = parsed_result;
8025 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8027 if ((strcmp(res->what, "uta") == 0) &&
8028 (strcmp(res->value, "all") == 0))
8029 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
8031 printf("bad unicast hash table parameter,"
8032 "return code = %d \n", ret);
8035 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
8036 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8038 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
8039 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8041 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
8042 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
8044 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
8045 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8047 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
8048 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8050 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
8051 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8054 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
8055 .f = cmd_set_uc_all_hash_parsed,
8057 .help_str = "set port <port_id> uta all on|off",
8059 (void *)&cmd_set_uc_all_hash_set,
8060 (void *)&cmd_set_uc_all_hash_port,
8061 (void *)&cmd_set_uc_all_hash_portid,
8062 (void *)&cmd_set_uc_all_hash_what,
8063 (void *)&cmd_set_uc_all_hash_value,
8064 (void *)&cmd_set_uc_all_hash_mode,
8069 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
8070 struct cmd_set_vf_macvlan_filter {
8071 cmdline_fixed_string_t set;
8072 cmdline_fixed_string_t port;
8074 cmdline_fixed_string_t vf;
8076 struct ether_addr address;
8077 cmdline_fixed_string_t filter_type;
8078 cmdline_fixed_string_t mode;
8082 cmd_set_vf_macvlan_parsed(void *parsed_result,
8083 __attribute__((unused)) struct cmdline *cl,
8084 __attribute__((unused)) void *data)
8087 struct cmd_set_vf_macvlan_filter *res = parsed_result;
8088 struct rte_eth_mac_filter filter;
8090 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
8092 rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
8094 /* set VF MAC filter */
8098 filter.dst_id = res->vf_id;
8100 if (!strcmp(res->filter_type, "exact-mac"))
8101 filter.filter_type = RTE_MAC_PERFECT_MATCH;
8102 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
8103 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
8104 else if (!strcmp(res->filter_type, "hashmac"))
8105 filter.filter_type = RTE_MAC_HASH_MATCH;
8106 else if (!strcmp(res->filter_type, "hashmac-vlan"))
8107 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
8109 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8112 ret = rte_eth_dev_filter_ctrl(res->port_id,
8113 RTE_ETH_FILTER_MACVLAN,
8117 ret = rte_eth_dev_filter_ctrl(res->port_id,
8118 RTE_ETH_FILTER_MACVLAN,
8119 RTE_ETH_FILTER_DELETE,
8123 printf("bad set MAC hash parameter, return code = %d\n", ret);
8127 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
8128 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8130 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
8131 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8133 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
8134 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8136 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
8137 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8139 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
8140 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8142 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
8143 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8145 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
8146 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8147 filter_type, "exact-mac#exact-mac-vlan"
8148 "#hashmac#hashmac-vlan");
8149 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
8150 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8153 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
8154 .f = cmd_set_vf_macvlan_parsed,
8156 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
8157 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
8158 "Exact match rule: exact match of MAC or MAC and VLAN; "
8159 "hash match rule: hash match of MAC and exact match of VLAN",
8161 (void *)&cmd_set_vf_macvlan_set,
8162 (void *)&cmd_set_vf_macvlan_port,
8163 (void *)&cmd_set_vf_macvlan_portid,
8164 (void *)&cmd_set_vf_macvlan_vf,
8165 (void *)&cmd_set_vf_macvlan_vf_id,
8166 (void *)&cmd_set_vf_macvlan_mac,
8167 (void *)&cmd_set_vf_macvlan_filter_type,
8168 (void *)&cmd_set_vf_macvlan_mode,
8173 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
8174 struct cmd_set_vf_traffic {
8175 cmdline_fixed_string_t set;
8176 cmdline_fixed_string_t port;
8178 cmdline_fixed_string_t vf;
8180 cmdline_fixed_string_t what;
8181 cmdline_fixed_string_t mode;
8185 cmd_set_vf_traffic_parsed(void *parsed_result,
8186 __attribute__((unused)) struct cmdline *cl,
8187 __attribute__((unused)) void *data)
8189 struct cmd_set_vf_traffic *res = parsed_result;
8190 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
8191 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8193 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
8196 cmdline_parse_token_string_t cmd_setvf_traffic_set =
8197 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8199 cmdline_parse_token_string_t cmd_setvf_traffic_port =
8200 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8202 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8203 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8205 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8206 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8208 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8209 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8211 cmdline_parse_token_string_t cmd_setvf_traffic_what =
8212 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8214 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8215 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8218 cmdline_parse_inst_t cmd_set_vf_traffic = {
8219 .f = cmd_set_vf_traffic_parsed,
8221 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8223 (void *)&cmd_setvf_traffic_set,
8224 (void *)&cmd_setvf_traffic_port,
8225 (void *)&cmd_setvf_traffic_portid,
8226 (void *)&cmd_setvf_traffic_vf,
8227 (void *)&cmd_setvf_traffic_vfid,
8228 (void *)&cmd_setvf_traffic_what,
8229 (void *)&cmd_setvf_traffic_mode,
8234 /* *** CONFIGURE VF RECEIVE MODE *** */
8235 struct cmd_set_vf_rxmode {
8236 cmdline_fixed_string_t set;
8237 cmdline_fixed_string_t port;
8239 cmdline_fixed_string_t vf;
8241 cmdline_fixed_string_t what;
8242 cmdline_fixed_string_t mode;
8243 cmdline_fixed_string_t on;
8247 cmd_set_vf_rxmode_parsed(void *parsed_result,
8248 __attribute__((unused)) struct cmdline *cl,
8249 __attribute__((unused)) void *data)
8252 uint16_t rx_mode = 0;
8253 struct cmd_set_vf_rxmode *res = parsed_result;
8255 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8256 if (!strcmp(res->what,"rxmode")) {
8257 if (!strcmp(res->mode, "AUPE"))
8258 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
8259 else if (!strcmp(res->mode, "ROPE"))
8260 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
8261 else if (!strcmp(res->mode, "BAM"))
8262 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
8263 else if (!strncmp(res->mode, "MPE",3))
8264 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
8267 RTE_SET_USED(is_on);
8269 #ifdef RTE_LIBRTE_IXGBE_PMD
8270 if (ret == -ENOTSUP)
8271 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8272 rx_mode, (uint8_t)is_on);
8274 #ifdef RTE_LIBRTE_BNXT_PMD
8275 if (ret == -ENOTSUP)
8276 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8277 rx_mode, (uint8_t)is_on);
8280 printf("bad VF receive mode parameter, return code = %d \n",
8284 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8285 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8287 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8288 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8290 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8291 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8293 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8294 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8296 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8297 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8299 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
8300 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8302 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
8303 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8304 mode, "AUPE#ROPE#BAM#MPE");
8305 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
8306 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8309 cmdline_parse_inst_t cmd_set_vf_rxmode = {
8310 .f = cmd_set_vf_rxmode_parsed,
8312 .help_str = "set port <port_id> vf <vf_id> rxmode "
8313 "AUPE|ROPE|BAM|MPE on|off",
8315 (void *)&cmd_set_vf_rxmode_set,
8316 (void *)&cmd_set_vf_rxmode_port,
8317 (void *)&cmd_set_vf_rxmode_portid,
8318 (void *)&cmd_set_vf_rxmode_vf,
8319 (void *)&cmd_set_vf_rxmode_vfid,
8320 (void *)&cmd_set_vf_rxmode_what,
8321 (void *)&cmd_set_vf_rxmode_mode,
8322 (void *)&cmd_set_vf_rxmode_on,
8327 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
8328 struct cmd_vf_mac_addr_result {
8329 cmdline_fixed_string_t mac_addr_cmd;
8330 cmdline_fixed_string_t what;
8331 cmdline_fixed_string_t port;
8333 cmdline_fixed_string_t vf;
8335 struct ether_addr address;
8338 static void cmd_vf_mac_addr_parsed(void *parsed_result,
8339 __attribute__((unused)) struct cmdline *cl,
8340 __attribute__((unused)) void *data)
8342 struct cmd_vf_mac_addr_result *res = parsed_result;
8345 if (strcmp(res->what, "add") != 0)
8348 #ifdef RTE_LIBRTE_I40E_PMD
8349 if (ret == -ENOTSUP)
8350 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
8353 #ifdef RTE_LIBRTE_BNXT_PMD
8354 if (ret == -ENOTSUP)
8355 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
8360 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
8364 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
8365 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8366 mac_addr_cmd,"mac_addr");
8367 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
8368 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8370 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
8371 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8373 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
8374 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8376 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
8377 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8379 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
8380 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8382 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
8383 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
8386 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
8387 .f = cmd_vf_mac_addr_parsed,
8389 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
8390 "Add MAC address filtering for a VF on port_id",
8392 (void *)&cmd_vf_mac_addr_cmd,
8393 (void *)&cmd_vf_mac_addr_what,
8394 (void *)&cmd_vf_mac_addr_port,
8395 (void *)&cmd_vf_mac_addr_portnum,
8396 (void *)&cmd_vf_mac_addr_vf,
8397 (void *)&cmd_vf_mac_addr_vfnum,
8398 (void *)&cmd_vf_mac_addr_addr,
8403 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
8404 struct cmd_vf_rx_vlan_filter {
8405 cmdline_fixed_string_t rx_vlan;
8406 cmdline_fixed_string_t what;
8408 cmdline_fixed_string_t port;
8410 cmdline_fixed_string_t vf;
8415 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
8416 __attribute__((unused)) struct cmdline *cl,
8417 __attribute__((unused)) void *data)
8419 struct cmd_vf_rx_vlan_filter *res = parsed_result;
8422 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
8424 #ifdef RTE_LIBRTE_IXGBE_PMD
8425 if (ret == -ENOTSUP)
8426 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
8427 res->vlan_id, res->vf_mask, is_add);
8429 #ifdef RTE_LIBRTE_I40E_PMD
8430 if (ret == -ENOTSUP)
8431 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
8432 res->vlan_id, res->vf_mask, is_add);
8434 #ifdef RTE_LIBRTE_BNXT_PMD
8435 if (ret == -ENOTSUP)
8436 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
8437 res->vlan_id, res->vf_mask, is_add);
8444 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
8445 res->vlan_id, res->vf_mask);
8448 printf("invalid port_id %d\n", res->port_id);
8451 printf("function not implemented or supported\n");
8454 printf("programming error: (%s)\n", strerror(-ret));
8458 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
8459 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8460 rx_vlan, "rx_vlan");
8461 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
8462 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8464 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
8465 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8467 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
8468 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8470 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
8471 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8473 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
8474 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8476 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
8477 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8480 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
8481 .f = cmd_vf_rx_vlan_filter_parsed,
8483 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
8484 "(vf_mask = hexadecimal VF mask)",
8486 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
8487 (void *)&cmd_vf_rx_vlan_filter_what,
8488 (void *)&cmd_vf_rx_vlan_filter_vlanid,
8489 (void *)&cmd_vf_rx_vlan_filter_port,
8490 (void *)&cmd_vf_rx_vlan_filter_portid,
8491 (void *)&cmd_vf_rx_vlan_filter_vf,
8492 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
8497 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
8498 struct cmd_queue_rate_limit_result {
8499 cmdline_fixed_string_t set;
8500 cmdline_fixed_string_t port;
8502 cmdline_fixed_string_t queue;
8504 cmdline_fixed_string_t rate;
8508 static void cmd_queue_rate_limit_parsed(void *parsed_result,
8509 __attribute__((unused)) struct cmdline *cl,
8510 __attribute__((unused)) void *data)
8512 struct cmd_queue_rate_limit_result *res = parsed_result;
8515 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8516 && (strcmp(res->queue, "queue") == 0)
8517 && (strcmp(res->rate, "rate") == 0))
8518 ret = set_queue_rate_limit(res->port_num, res->queue_num,
8521 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
8525 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
8526 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8528 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
8529 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8531 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
8532 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8534 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
8535 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8537 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
8538 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8540 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
8541 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8543 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
8544 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8547 cmdline_parse_inst_t cmd_queue_rate_limit = {
8548 .f = cmd_queue_rate_limit_parsed,
8550 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
8551 "Set rate limit for a queue on port_id",
8553 (void *)&cmd_queue_rate_limit_set,
8554 (void *)&cmd_queue_rate_limit_port,
8555 (void *)&cmd_queue_rate_limit_portnum,
8556 (void *)&cmd_queue_rate_limit_queue,
8557 (void *)&cmd_queue_rate_limit_queuenum,
8558 (void *)&cmd_queue_rate_limit_rate,
8559 (void *)&cmd_queue_rate_limit_ratenum,
8564 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
8565 struct cmd_vf_rate_limit_result {
8566 cmdline_fixed_string_t set;
8567 cmdline_fixed_string_t port;
8569 cmdline_fixed_string_t vf;
8571 cmdline_fixed_string_t rate;
8573 cmdline_fixed_string_t q_msk;
8577 static void cmd_vf_rate_limit_parsed(void *parsed_result,
8578 __attribute__((unused)) struct cmdline *cl,
8579 __attribute__((unused)) void *data)
8581 struct cmd_vf_rate_limit_result *res = parsed_result;
8584 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8585 && (strcmp(res->vf, "vf") == 0)
8586 && (strcmp(res->rate, "rate") == 0)
8587 && (strcmp(res->q_msk, "queue_mask") == 0))
8588 ret = set_vf_rate_limit(res->port_num, res->vf_num,
8589 res->rate_num, res->q_msk_val);
8591 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
8595 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
8596 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8598 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
8599 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8601 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
8602 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8604 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
8605 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8607 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
8608 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8610 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
8611 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8613 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
8614 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8616 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
8617 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8618 q_msk, "queue_mask");
8619 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
8620 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8623 cmdline_parse_inst_t cmd_vf_rate_limit = {
8624 .f = cmd_vf_rate_limit_parsed,
8626 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
8627 "queue_mask <queue_mask_value>: "
8628 "Set rate limit for queues of VF on port_id",
8630 (void *)&cmd_vf_rate_limit_set,
8631 (void *)&cmd_vf_rate_limit_port,
8632 (void *)&cmd_vf_rate_limit_portnum,
8633 (void *)&cmd_vf_rate_limit_vf,
8634 (void *)&cmd_vf_rate_limit_vfnum,
8635 (void *)&cmd_vf_rate_limit_rate,
8636 (void *)&cmd_vf_rate_limit_ratenum,
8637 (void *)&cmd_vf_rate_limit_q_msk,
8638 (void *)&cmd_vf_rate_limit_q_msk_val,
8643 /* *** ADD TUNNEL FILTER OF A PORT *** */
8644 struct cmd_tunnel_filter_result {
8645 cmdline_fixed_string_t cmd;
8646 cmdline_fixed_string_t what;
8648 struct ether_addr outer_mac;
8649 struct ether_addr inner_mac;
8650 cmdline_ipaddr_t ip_value;
8651 uint16_t inner_vlan;
8652 cmdline_fixed_string_t tunnel_type;
8653 cmdline_fixed_string_t filter_type;
8659 cmd_tunnel_filter_parsed(void *parsed_result,
8660 __attribute__((unused)) struct cmdline *cl,
8661 __attribute__((unused)) void *data)
8663 struct cmd_tunnel_filter_result *res = parsed_result;
8664 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
8667 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
8669 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
8670 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
8671 tunnel_filter_conf.inner_vlan = res->inner_vlan;
8673 if (res->ip_value.family == AF_INET) {
8674 tunnel_filter_conf.ip_addr.ipv4_addr =
8675 res->ip_value.addr.ipv4.s_addr;
8676 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
8678 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
8679 &(res->ip_value.addr.ipv6),
8680 sizeof(struct in6_addr));
8681 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
8684 if (!strcmp(res->filter_type, "imac-ivlan"))
8685 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
8686 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
8687 tunnel_filter_conf.filter_type =
8688 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
8689 else if (!strcmp(res->filter_type, "imac-tenid"))
8690 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
8691 else if (!strcmp(res->filter_type, "imac"))
8692 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
8693 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
8694 tunnel_filter_conf.filter_type =
8695 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
8696 else if (!strcmp(res->filter_type, "oip"))
8697 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
8698 else if (!strcmp(res->filter_type, "iip"))
8699 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
8701 printf("The filter type is not supported");
8705 if (!strcmp(res->tunnel_type, "vxlan"))
8706 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
8707 else if (!strcmp(res->tunnel_type, "nvgre"))
8708 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
8709 else if (!strcmp(res->tunnel_type, "ipingre"))
8710 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
8712 printf("The tunnel type %s not supported.\n", res->tunnel_type);
8716 tunnel_filter_conf.tenant_id = res->tenant_id;
8717 tunnel_filter_conf.queue_id = res->queue_num;
8718 if (!strcmp(res->what, "add"))
8719 ret = rte_eth_dev_filter_ctrl(res->port_id,
8720 RTE_ETH_FILTER_TUNNEL,
8722 &tunnel_filter_conf);
8724 ret = rte_eth_dev_filter_ctrl(res->port_id,
8725 RTE_ETH_FILTER_TUNNEL,
8726 RTE_ETH_FILTER_DELETE,
8727 &tunnel_filter_conf);
8729 printf("cmd_tunnel_filter_parsed error: (%s)\n",
8733 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
8734 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8735 cmd, "tunnel_filter");
8736 cmdline_parse_token_string_t cmd_tunnel_filter_what =
8737 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8739 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
8740 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8742 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
8743 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8745 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
8746 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8748 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
8749 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8750 inner_vlan, UINT16);
8751 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
8752 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8754 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
8755 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8756 tunnel_type, "vxlan#nvgre#ipingre");
8758 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
8759 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8760 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
8761 "imac#omac-imac-tenid");
8762 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
8763 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8765 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
8766 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8769 cmdline_parse_inst_t cmd_tunnel_filter = {
8770 .f = cmd_tunnel_filter_parsed,
8772 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
8773 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
8774 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
8775 "<queue_id>: Add/Rm tunnel filter of a port",
8777 (void *)&cmd_tunnel_filter_cmd,
8778 (void *)&cmd_tunnel_filter_what,
8779 (void *)&cmd_tunnel_filter_port_id,
8780 (void *)&cmd_tunnel_filter_outer_mac,
8781 (void *)&cmd_tunnel_filter_inner_mac,
8782 (void *)&cmd_tunnel_filter_ip_value,
8783 (void *)&cmd_tunnel_filter_innner_vlan,
8784 (void *)&cmd_tunnel_filter_tunnel_type,
8785 (void *)&cmd_tunnel_filter_filter_type,
8786 (void *)&cmd_tunnel_filter_tenant_id,
8787 (void *)&cmd_tunnel_filter_queue_num,
8792 /* *** CONFIGURE TUNNEL UDP PORT *** */
8793 struct cmd_tunnel_udp_config {
8794 cmdline_fixed_string_t cmd;
8795 cmdline_fixed_string_t what;
8801 cmd_tunnel_udp_config_parsed(void *parsed_result,
8802 __attribute__((unused)) struct cmdline *cl,
8803 __attribute__((unused)) void *data)
8805 struct cmd_tunnel_udp_config *res = parsed_result;
8806 struct rte_eth_udp_tunnel tunnel_udp;
8809 tunnel_udp.udp_port = res->udp_port;
8811 if (!strcmp(res->cmd, "rx_vxlan_port"))
8812 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
8814 if (!strcmp(res->what, "add"))
8815 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
8818 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
8822 printf("udp tunneling add error: (%s)\n", strerror(-ret));
8825 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
8826 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8827 cmd, "rx_vxlan_port");
8828 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
8829 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8831 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
8832 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8834 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
8835 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8838 cmdline_parse_inst_t cmd_tunnel_udp_config = {
8839 .f = cmd_tunnel_udp_config_parsed,
8841 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
8842 "Add/Remove a tunneling UDP port filter",
8844 (void *)&cmd_tunnel_udp_config_cmd,
8845 (void *)&cmd_tunnel_udp_config_what,
8846 (void *)&cmd_tunnel_udp_config_udp_port,
8847 (void *)&cmd_tunnel_udp_config_port_id,
8852 struct cmd_config_tunnel_udp_port {
8853 cmdline_fixed_string_t port;
8854 cmdline_fixed_string_t config;
8856 cmdline_fixed_string_t udp_tunnel_port;
8857 cmdline_fixed_string_t action;
8858 cmdline_fixed_string_t tunnel_type;
8863 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
8864 __attribute__((unused)) struct cmdline *cl,
8865 __attribute__((unused)) void *data)
8867 struct cmd_config_tunnel_udp_port *res = parsed_result;
8868 struct rte_eth_udp_tunnel tunnel_udp;
8871 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8874 tunnel_udp.udp_port = res->udp_port;
8876 if (!strcmp(res->tunnel_type, "vxlan")) {
8877 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
8878 } else if (!strcmp(res->tunnel_type, "geneve")) {
8879 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE;
8881 printf("Invalid tunnel type\n");
8885 if (!strcmp(res->action, "add"))
8886 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
8889 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
8893 printf("udp tunneling port add error: (%s)\n", strerror(-ret));
8896 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
8897 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
8899 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
8900 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
8902 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
8903 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
8905 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
8906 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
8909 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
8910 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
8912 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
8913 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
8915 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
8916 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
8919 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
8920 .f = cmd_cfg_tunnel_udp_port_parsed,
8922 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|geneve <udp_port>",
8924 (void *)&cmd_config_tunnel_udp_port_port,
8925 (void *)&cmd_config_tunnel_udp_port_config,
8926 (void *)&cmd_config_tunnel_udp_port_port_id,
8927 (void *)&cmd_config_tunnel_udp_port_tunnel_port,
8928 (void *)&cmd_config_tunnel_udp_port_action,
8929 (void *)&cmd_config_tunnel_udp_port_tunnel_type,
8930 (void *)&cmd_config_tunnel_udp_port_value,
8935 /* *** GLOBAL CONFIG *** */
8936 struct cmd_global_config_result {
8937 cmdline_fixed_string_t cmd;
8939 cmdline_fixed_string_t cfg_type;
8944 cmd_global_config_parsed(void *parsed_result,
8945 __attribute__((unused)) struct cmdline *cl,
8946 __attribute__((unused)) void *data)
8948 struct cmd_global_config_result *res = parsed_result;
8949 struct rte_eth_global_cfg conf;
8952 memset(&conf, 0, sizeof(conf));
8953 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
8954 conf.cfg.gre_key_len = res->len;
8955 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
8956 RTE_ETH_FILTER_SET, &conf);
8958 printf("Global config error\n");
8961 cmdline_parse_token_string_t cmd_global_config_cmd =
8962 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
8964 cmdline_parse_token_num_t cmd_global_config_port_id =
8965 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id,
8967 cmdline_parse_token_string_t cmd_global_config_type =
8968 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
8969 cfg_type, "gre-key-len");
8970 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
8971 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
8974 cmdline_parse_inst_t cmd_global_config = {
8975 .f = cmd_global_config_parsed,
8976 .data = (void *)NULL,
8977 .help_str = "global_config <port_id> gre-key-len <key_len>",
8979 (void *)&cmd_global_config_cmd,
8980 (void *)&cmd_global_config_port_id,
8981 (void *)&cmd_global_config_type,
8982 (void *)&cmd_global_config_gre_key_len,
8987 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
8988 struct cmd_set_mirror_mask_result {
8989 cmdline_fixed_string_t set;
8990 cmdline_fixed_string_t port;
8992 cmdline_fixed_string_t mirror;
8994 cmdline_fixed_string_t what;
8995 cmdline_fixed_string_t value;
8996 cmdline_fixed_string_t dstpool;
8998 cmdline_fixed_string_t on;
9001 cmdline_parse_token_string_t cmd_mirror_mask_set =
9002 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9004 cmdline_parse_token_string_t cmd_mirror_mask_port =
9005 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9007 cmdline_parse_token_num_t cmd_mirror_mask_portid =
9008 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9010 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
9011 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9012 mirror, "mirror-rule");
9013 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
9014 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9016 cmdline_parse_token_string_t cmd_mirror_mask_what =
9017 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9018 what, "pool-mirror-up#pool-mirror-down"
9020 cmdline_parse_token_string_t cmd_mirror_mask_value =
9021 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9023 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
9024 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9025 dstpool, "dst-pool");
9026 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
9027 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9029 cmdline_parse_token_string_t cmd_mirror_mask_on =
9030 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9034 cmd_set_mirror_mask_parsed(void *parsed_result,
9035 __attribute__((unused)) struct cmdline *cl,
9036 __attribute__((unused)) void *data)
9039 struct cmd_set_mirror_mask_result *res = parsed_result;
9040 struct rte_eth_mirror_conf mr_conf;
9042 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9044 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
9046 mr_conf.dst_pool = res->dstpool_id;
9048 if (!strcmp(res->what, "pool-mirror-up")) {
9049 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9050 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
9051 } else if (!strcmp(res->what, "pool-mirror-down")) {
9052 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9053 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
9054 } else if (!strcmp(res->what, "vlan-mirror")) {
9055 mr_conf.rule_type = ETH_MIRROR_VLAN;
9056 nb_item = parse_item_list(res->value, "vlan",
9057 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
9061 for (i = 0; i < nb_item; i++) {
9062 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
9063 printf("Invalid vlan_id: must be < 4096\n");
9067 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
9068 mr_conf.vlan.vlan_mask |= 1ULL << i;
9072 if (!strcmp(res->on, "on"))
9073 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9076 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9079 printf("mirror rule add error: (%s)\n", strerror(-ret));
9082 cmdline_parse_inst_t cmd_set_mirror_mask = {
9083 .f = cmd_set_mirror_mask_parsed,
9085 .help_str = "set port <port_id> mirror-rule <rule_id> "
9086 "pool-mirror-up|pool-mirror-down|vlan-mirror "
9087 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
9089 (void *)&cmd_mirror_mask_set,
9090 (void *)&cmd_mirror_mask_port,
9091 (void *)&cmd_mirror_mask_portid,
9092 (void *)&cmd_mirror_mask_mirror,
9093 (void *)&cmd_mirror_mask_ruleid,
9094 (void *)&cmd_mirror_mask_what,
9095 (void *)&cmd_mirror_mask_value,
9096 (void *)&cmd_mirror_mask_dstpool,
9097 (void *)&cmd_mirror_mask_poolid,
9098 (void *)&cmd_mirror_mask_on,
9103 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
9104 struct cmd_set_mirror_link_result {
9105 cmdline_fixed_string_t set;
9106 cmdline_fixed_string_t port;
9108 cmdline_fixed_string_t mirror;
9110 cmdline_fixed_string_t what;
9111 cmdline_fixed_string_t dstpool;
9113 cmdline_fixed_string_t on;
9116 cmdline_parse_token_string_t cmd_mirror_link_set =
9117 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9119 cmdline_parse_token_string_t cmd_mirror_link_port =
9120 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9122 cmdline_parse_token_num_t cmd_mirror_link_portid =
9123 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9125 cmdline_parse_token_string_t cmd_mirror_link_mirror =
9126 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9127 mirror, "mirror-rule");
9128 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
9129 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9131 cmdline_parse_token_string_t cmd_mirror_link_what =
9132 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9133 what, "uplink-mirror#downlink-mirror");
9134 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
9135 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9136 dstpool, "dst-pool");
9137 cmdline_parse_token_num_t cmd_mirror_link_poolid =
9138 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9140 cmdline_parse_token_string_t cmd_mirror_link_on =
9141 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9145 cmd_set_mirror_link_parsed(void *parsed_result,
9146 __attribute__((unused)) struct cmdline *cl,
9147 __attribute__((unused)) void *data)
9150 struct cmd_set_mirror_link_result *res = parsed_result;
9151 struct rte_eth_mirror_conf mr_conf;
9153 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9154 if (!strcmp(res->what, "uplink-mirror"))
9155 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
9157 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
9159 mr_conf.dst_pool = res->dstpool_id;
9161 if (!strcmp(res->on, "on"))
9162 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9165 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9168 /* check the return value and print it if is < 0 */
9170 printf("mirror rule add error: (%s)\n", strerror(-ret));
9174 cmdline_parse_inst_t cmd_set_mirror_link = {
9175 .f = cmd_set_mirror_link_parsed,
9177 .help_str = "set port <port_id> mirror-rule <rule_id> "
9178 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
9180 (void *)&cmd_mirror_link_set,
9181 (void *)&cmd_mirror_link_port,
9182 (void *)&cmd_mirror_link_portid,
9183 (void *)&cmd_mirror_link_mirror,
9184 (void *)&cmd_mirror_link_ruleid,
9185 (void *)&cmd_mirror_link_what,
9186 (void *)&cmd_mirror_link_dstpool,
9187 (void *)&cmd_mirror_link_poolid,
9188 (void *)&cmd_mirror_link_on,
9193 /* *** RESET VM MIRROR RULE *** */
9194 struct cmd_rm_mirror_rule_result {
9195 cmdline_fixed_string_t reset;
9196 cmdline_fixed_string_t port;
9198 cmdline_fixed_string_t mirror;
9202 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
9203 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9205 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
9206 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9208 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
9209 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9211 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
9212 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9213 mirror, "mirror-rule");
9214 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
9215 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9219 cmd_reset_mirror_rule_parsed(void *parsed_result,
9220 __attribute__((unused)) struct cmdline *cl,
9221 __attribute__((unused)) void *data)
9224 struct cmd_set_mirror_link_result *res = parsed_result;
9226 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
9228 printf("mirror rule remove error: (%s)\n", strerror(-ret));
9231 cmdline_parse_inst_t cmd_reset_mirror_rule = {
9232 .f = cmd_reset_mirror_rule_parsed,
9234 .help_str = "reset port <port_id> mirror-rule <rule_id>",
9236 (void *)&cmd_rm_mirror_rule_reset,
9237 (void *)&cmd_rm_mirror_rule_port,
9238 (void *)&cmd_rm_mirror_rule_portid,
9239 (void *)&cmd_rm_mirror_rule_mirror,
9240 (void *)&cmd_rm_mirror_rule_ruleid,
9245 /* ******************************************************************************** */
9247 struct cmd_dump_result {
9248 cmdline_fixed_string_t dump;
9252 dump_struct_sizes(void)
9254 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9255 DUMP_SIZE(struct rte_mbuf);
9256 DUMP_SIZE(struct rte_mempool);
9257 DUMP_SIZE(struct rte_ring);
9261 static void cmd_dump_parsed(void *parsed_result,
9262 __attribute__((unused)) struct cmdline *cl,
9263 __attribute__((unused)) void *data)
9265 struct cmd_dump_result *res = parsed_result;
9267 if (!strcmp(res->dump, "dump_physmem"))
9268 rte_dump_physmem_layout(stdout);
9269 else if (!strcmp(res->dump, "dump_memzone"))
9270 rte_memzone_dump(stdout);
9271 else if (!strcmp(res->dump, "dump_struct_sizes"))
9272 dump_struct_sizes();
9273 else if (!strcmp(res->dump, "dump_ring"))
9274 rte_ring_list_dump(stdout);
9275 else if (!strcmp(res->dump, "dump_mempool"))
9276 rte_mempool_list_dump(stdout);
9277 else if (!strcmp(res->dump, "dump_devargs"))
9278 rte_devargs_dump(stdout);
9279 else if (!strcmp(res->dump, "dump_log_types"))
9280 rte_log_dump(stdout);
9283 cmdline_parse_token_string_t cmd_dump_dump =
9284 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9287 "dump_struct_sizes#"
9293 cmdline_parse_inst_t cmd_dump = {
9294 .f = cmd_dump_parsed, /* function to call */
9295 .data = NULL, /* 2nd arg of func */
9296 .help_str = "Dump status",
9297 .tokens = { /* token list, NULL terminated */
9298 (void *)&cmd_dump_dump,
9303 /* ******************************************************************************** */
9305 struct cmd_dump_one_result {
9306 cmdline_fixed_string_t dump;
9307 cmdline_fixed_string_t name;
9310 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9311 __attribute__((unused)) void *data)
9313 struct cmd_dump_one_result *res = parsed_result;
9315 if (!strcmp(res->dump, "dump_ring")) {
9317 r = rte_ring_lookup(res->name);
9319 cmdline_printf(cl, "Cannot find ring\n");
9322 rte_ring_dump(stdout, r);
9323 } else if (!strcmp(res->dump, "dump_mempool")) {
9324 struct rte_mempool *mp;
9325 mp = rte_mempool_lookup(res->name);
9327 cmdline_printf(cl, "Cannot find mempool\n");
9330 rte_mempool_dump(stdout, mp);
9334 cmdline_parse_token_string_t cmd_dump_one_dump =
9335 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9336 "dump_ring#dump_mempool");
9338 cmdline_parse_token_string_t cmd_dump_one_name =
9339 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9341 cmdline_parse_inst_t cmd_dump_one = {
9342 .f = cmd_dump_one_parsed, /* function to call */
9343 .data = NULL, /* 2nd arg of func */
9344 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9345 .tokens = { /* token list, NULL terminated */
9346 (void *)&cmd_dump_one_dump,
9347 (void *)&cmd_dump_one_name,
9352 /* *** Add/Del syn filter *** */
9353 struct cmd_syn_filter_result {
9354 cmdline_fixed_string_t filter;
9356 cmdline_fixed_string_t ops;
9357 cmdline_fixed_string_t priority;
9358 cmdline_fixed_string_t high;
9359 cmdline_fixed_string_t queue;
9364 cmd_syn_filter_parsed(void *parsed_result,
9365 __attribute__((unused)) struct cmdline *cl,
9366 __attribute__((unused)) void *data)
9368 struct cmd_syn_filter_result *res = parsed_result;
9369 struct rte_eth_syn_filter syn_filter;
9372 ret = rte_eth_dev_filter_supported(res->port_id,
9373 RTE_ETH_FILTER_SYN);
9375 printf("syn filter is not supported on port %u.\n",
9380 memset(&syn_filter, 0, sizeof(syn_filter));
9382 if (!strcmp(res->ops, "add")) {
9383 if (!strcmp(res->high, "high"))
9384 syn_filter.hig_pri = 1;
9386 syn_filter.hig_pri = 0;
9388 syn_filter.queue = res->queue_id;
9389 ret = rte_eth_dev_filter_ctrl(res->port_id,
9394 ret = rte_eth_dev_filter_ctrl(res->port_id,
9396 RTE_ETH_FILTER_DELETE,
9400 printf("syn filter programming error: (%s)\n",
9404 cmdline_parse_token_string_t cmd_syn_filter_filter =
9405 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9406 filter, "syn_filter");
9407 cmdline_parse_token_num_t cmd_syn_filter_port_id =
9408 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9410 cmdline_parse_token_string_t cmd_syn_filter_ops =
9411 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9413 cmdline_parse_token_string_t cmd_syn_filter_priority =
9414 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9415 priority, "priority");
9416 cmdline_parse_token_string_t cmd_syn_filter_high =
9417 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9419 cmdline_parse_token_string_t cmd_syn_filter_queue =
9420 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9422 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
9423 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9426 cmdline_parse_inst_t cmd_syn_filter = {
9427 .f = cmd_syn_filter_parsed,
9429 .help_str = "syn_filter <port_id> add|del priority high|low queue "
9430 "<queue_id>: Add/Delete syn filter",
9432 (void *)&cmd_syn_filter_filter,
9433 (void *)&cmd_syn_filter_port_id,
9434 (void *)&cmd_syn_filter_ops,
9435 (void *)&cmd_syn_filter_priority,
9436 (void *)&cmd_syn_filter_high,
9437 (void *)&cmd_syn_filter_queue,
9438 (void *)&cmd_syn_filter_queue_id,
9443 /* *** queue region set *** */
9444 struct cmd_queue_region_result {
9445 cmdline_fixed_string_t set;
9446 cmdline_fixed_string_t port;
9448 cmdline_fixed_string_t cmd;
9449 cmdline_fixed_string_t region;
9451 cmdline_fixed_string_t queue_start_index;
9453 cmdline_fixed_string_t queue_num;
9454 uint8_t queue_num_value;
9458 cmd_queue_region_parsed(void *parsed_result,
9459 __attribute__((unused)) struct cmdline *cl,
9460 __attribute__((unused)) void *data)
9462 struct cmd_queue_region_result *res = parsed_result;
9464 #ifdef RTE_LIBRTE_I40E_PMD
9465 struct rte_pmd_i40e_queue_region_conf region_conf;
9466 enum rte_pmd_i40e_queue_region_op op_type;
9469 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9472 #ifdef RTE_LIBRTE_I40E_PMD
9473 memset(®ion_conf, 0, sizeof(region_conf));
9474 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
9475 region_conf.region_id = res->region_id;
9476 region_conf.queue_num = res->queue_num_value;
9477 region_conf.queue_start_index = res->queue_id;
9479 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9480 op_type, ®ion_conf);
9487 printf("function not implemented or supported\n");
9490 printf("queue region config error: (%s)\n", strerror(-ret));
9494 cmdline_parse_token_string_t cmd_queue_region_set =
9495 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9497 cmdline_parse_token_string_t cmd_queue_region_port =
9498 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
9499 cmdline_parse_token_num_t cmd_queue_region_port_id =
9500 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9502 cmdline_parse_token_string_t cmd_queue_region_cmd =
9503 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9504 cmd, "queue-region");
9505 cmdline_parse_token_string_t cmd_queue_region_id =
9506 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9507 region, "region_id");
9508 cmdline_parse_token_num_t cmd_queue_region_index =
9509 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9511 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
9512 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9513 queue_start_index, "queue_start_index");
9514 cmdline_parse_token_num_t cmd_queue_region_queue_id =
9515 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9517 cmdline_parse_token_string_t cmd_queue_region_queue_num =
9518 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9519 queue_num, "queue_num");
9520 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
9521 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9522 queue_num_value, UINT8);
9524 cmdline_parse_inst_t cmd_queue_region = {
9525 .f = cmd_queue_region_parsed,
9527 .help_str = "set port <port_id> queue-region region_id <value> "
9528 "queue_start_index <value> queue_num <value>: Set a queue region",
9530 (void *)&cmd_queue_region_set,
9531 (void *)&cmd_queue_region_port,
9532 (void *)&cmd_queue_region_port_id,
9533 (void *)&cmd_queue_region_cmd,
9534 (void *)&cmd_queue_region_id,
9535 (void *)&cmd_queue_region_index,
9536 (void *)&cmd_queue_region_queue_start_index,
9537 (void *)&cmd_queue_region_queue_id,
9538 (void *)&cmd_queue_region_queue_num,
9539 (void *)&cmd_queue_region_queue_num_value,
9544 /* *** queue region and flowtype set *** */
9545 struct cmd_region_flowtype_result {
9546 cmdline_fixed_string_t set;
9547 cmdline_fixed_string_t port;
9549 cmdline_fixed_string_t cmd;
9550 cmdline_fixed_string_t region;
9552 cmdline_fixed_string_t flowtype;
9553 uint8_t flowtype_id;
9557 cmd_region_flowtype_parsed(void *parsed_result,
9558 __attribute__((unused)) struct cmdline *cl,
9559 __attribute__((unused)) void *data)
9561 struct cmd_region_flowtype_result *res = parsed_result;
9563 #ifdef RTE_LIBRTE_I40E_PMD
9564 struct rte_pmd_i40e_queue_region_conf region_conf;
9565 enum rte_pmd_i40e_queue_region_op op_type;
9568 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9571 #ifdef RTE_LIBRTE_I40E_PMD
9572 memset(®ion_conf, 0, sizeof(region_conf));
9574 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
9575 region_conf.region_id = res->region_id;
9576 region_conf.hw_flowtype = res->flowtype_id;
9578 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9579 op_type, ®ion_conf);
9586 printf("function not implemented or supported\n");
9589 printf("region flowtype config error: (%s)\n", strerror(-ret));
9593 cmdline_parse_token_string_t cmd_region_flowtype_set =
9594 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9596 cmdline_parse_token_string_t cmd_region_flowtype_port =
9597 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9599 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
9600 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9602 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
9603 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9604 cmd, "queue-region");
9605 cmdline_parse_token_string_t cmd_region_flowtype_index =
9606 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9607 region, "region_id");
9608 cmdline_parse_token_num_t cmd_region_flowtype_id =
9609 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9611 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
9612 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9613 flowtype, "flowtype");
9614 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
9615 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9616 flowtype_id, UINT8);
9617 cmdline_parse_inst_t cmd_region_flowtype = {
9618 .f = cmd_region_flowtype_parsed,
9620 .help_str = "set port <port_id> queue-region region_id <value> "
9621 "flowtype <value>: Set a flowtype region index",
9623 (void *)&cmd_region_flowtype_set,
9624 (void *)&cmd_region_flowtype_port,
9625 (void *)&cmd_region_flowtype_port_index,
9626 (void *)&cmd_region_flowtype_cmd,
9627 (void *)&cmd_region_flowtype_index,
9628 (void *)&cmd_region_flowtype_id,
9629 (void *)&cmd_region_flowtype_flow_index,
9630 (void *)&cmd_region_flowtype_flow_id,
9635 /* *** User Priority (UP) to queue region (region_id) set *** */
9636 struct cmd_user_priority_region_result {
9637 cmdline_fixed_string_t set;
9638 cmdline_fixed_string_t port;
9640 cmdline_fixed_string_t cmd;
9641 cmdline_fixed_string_t user_priority;
9642 uint8_t user_priority_id;
9643 cmdline_fixed_string_t region;
9648 cmd_user_priority_region_parsed(void *parsed_result,
9649 __attribute__((unused)) struct cmdline *cl,
9650 __attribute__((unused)) void *data)
9652 struct cmd_user_priority_region_result *res = parsed_result;
9654 #ifdef RTE_LIBRTE_I40E_PMD
9655 struct rte_pmd_i40e_queue_region_conf region_conf;
9656 enum rte_pmd_i40e_queue_region_op op_type;
9659 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9662 #ifdef RTE_LIBRTE_I40E_PMD
9663 memset(®ion_conf, 0, sizeof(region_conf));
9664 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
9665 region_conf.user_priority = res->user_priority_id;
9666 region_conf.region_id = res->region_id;
9668 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9669 op_type, ®ion_conf);
9676 printf("function not implemented or supported\n");
9679 printf("user_priority region config error: (%s)\n",
9684 cmdline_parse_token_string_t cmd_user_priority_region_set =
9685 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9687 cmdline_parse_token_string_t cmd_user_priority_region_port =
9688 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9690 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
9691 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9693 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
9694 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9695 cmd, "queue-region");
9696 cmdline_parse_token_string_t cmd_user_priority_region_UP =
9697 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9698 user_priority, "UP");
9699 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
9700 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9701 user_priority_id, UINT8);
9702 cmdline_parse_token_string_t cmd_user_priority_region_region =
9703 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9704 region, "region_id");
9705 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
9706 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9709 cmdline_parse_inst_t cmd_user_priority_region = {
9710 .f = cmd_user_priority_region_parsed,
9712 .help_str = "set port <port_id> queue-region UP <value> "
9713 "region_id <value>: Set the mapping of User Priority (UP) "
9714 "to queue region (region_id) ",
9716 (void *)&cmd_user_priority_region_set,
9717 (void *)&cmd_user_priority_region_port,
9718 (void *)&cmd_user_priority_region_port_index,
9719 (void *)&cmd_user_priority_region_cmd,
9720 (void *)&cmd_user_priority_region_UP,
9721 (void *)&cmd_user_priority_region_UP_id,
9722 (void *)&cmd_user_priority_region_region,
9723 (void *)&cmd_user_priority_region_region_id,
9728 /* *** flush all queue region related configuration *** */
9729 struct cmd_flush_queue_region_result {
9730 cmdline_fixed_string_t set;
9731 cmdline_fixed_string_t port;
9733 cmdline_fixed_string_t cmd;
9734 cmdline_fixed_string_t flush;
9735 cmdline_fixed_string_t what;
9739 cmd_flush_queue_region_parsed(void *parsed_result,
9740 __attribute__((unused)) struct cmdline *cl,
9741 __attribute__((unused)) void *data)
9743 struct cmd_flush_queue_region_result *res = parsed_result;
9745 #ifdef RTE_LIBRTE_I40E_PMD
9746 struct rte_pmd_i40e_queue_region_conf region_conf;
9747 enum rte_pmd_i40e_queue_region_op op_type;
9750 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9753 #ifdef RTE_LIBRTE_I40E_PMD
9754 memset(®ion_conf, 0, sizeof(region_conf));
9756 if (strcmp(res->what, "on") == 0)
9757 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
9759 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
9761 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9762 op_type, ®ion_conf);
9769 printf("function not implemented or supported\n");
9772 printf("queue region config flush error: (%s)\n",
9777 cmdline_parse_token_string_t cmd_flush_queue_region_set =
9778 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9780 cmdline_parse_token_string_t cmd_flush_queue_region_port =
9781 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9783 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
9784 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
9786 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
9787 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9788 cmd, "queue-region");
9789 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
9790 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9792 cmdline_parse_token_string_t cmd_flush_queue_region_what =
9793 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9796 cmdline_parse_inst_t cmd_flush_queue_region = {
9797 .f = cmd_flush_queue_region_parsed,
9799 .help_str = "set port <port_id> queue-region flush on|off"
9800 ": flush all queue region related configuration",
9802 (void *)&cmd_flush_queue_region_set,
9803 (void *)&cmd_flush_queue_region_port,
9804 (void *)&cmd_flush_queue_region_port_index,
9805 (void *)&cmd_flush_queue_region_cmd,
9806 (void *)&cmd_flush_queue_region_flush,
9807 (void *)&cmd_flush_queue_region_what,
9812 /* *** get all queue region related configuration info *** */
9813 struct cmd_show_queue_region_info {
9814 cmdline_fixed_string_t show;
9815 cmdline_fixed_string_t port;
9817 cmdline_fixed_string_t cmd;
9821 cmd_show_queue_region_info_parsed(void *parsed_result,
9822 __attribute__((unused)) struct cmdline *cl,
9823 __attribute__((unused)) void *data)
9825 struct cmd_show_queue_region_info *res = parsed_result;
9827 #ifdef RTE_LIBRTE_I40E_PMD
9828 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
9829 enum rte_pmd_i40e_queue_region_op op_type;
9832 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9835 #ifdef RTE_LIBRTE_I40E_PMD
9836 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
9838 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
9840 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9841 op_type, &rte_pmd_regions);
9843 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
9850 printf("function not implemented or supported\n");
9853 printf("queue region config info show error: (%s)\n",
9858 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
9859 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9861 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
9862 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9864 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
9865 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
9867 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
9868 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9869 cmd, "queue-region");
9871 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
9872 .f = cmd_show_queue_region_info_parsed,
9874 .help_str = "show port <port_id> queue-region"
9875 ": show all queue region related configuration info",
9877 (void *)&cmd_show_queue_region_info_get,
9878 (void *)&cmd_show_queue_region_info_port,
9879 (void *)&cmd_show_queue_region_info_port_index,
9880 (void *)&cmd_show_queue_region_info_cmd,
9885 /* *** ADD/REMOVE A 2tuple FILTER *** */
9886 struct cmd_2tuple_filter_result {
9887 cmdline_fixed_string_t filter;
9889 cmdline_fixed_string_t ops;
9890 cmdline_fixed_string_t dst_port;
9891 uint16_t dst_port_value;
9892 cmdline_fixed_string_t protocol;
9893 uint8_t protocol_value;
9894 cmdline_fixed_string_t mask;
9896 cmdline_fixed_string_t tcp_flags;
9897 uint8_t tcp_flags_value;
9898 cmdline_fixed_string_t priority;
9899 uint8_t priority_value;
9900 cmdline_fixed_string_t queue;
9905 cmd_2tuple_filter_parsed(void *parsed_result,
9906 __attribute__((unused)) struct cmdline *cl,
9907 __attribute__((unused)) void *data)
9909 struct rte_eth_ntuple_filter filter;
9910 struct cmd_2tuple_filter_result *res = parsed_result;
9913 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
9915 printf("ntuple filter is not supported on port %u.\n",
9920 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
9922 filter.flags = RTE_2TUPLE_FLAGS;
9923 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
9924 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
9925 filter.proto = res->protocol_value;
9926 filter.priority = res->priority_value;
9927 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
9928 printf("nonzero tcp_flags is only meaningful"
9929 " when protocol is TCP.\n");
9932 if (res->tcp_flags_value > TCP_FLAG_ALL) {
9933 printf("invalid TCP flags.\n");
9937 if (res->tcp_flags_value != 0) {
9938 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
9939 filter.tcp_flags = res->tcp_flags_value;
9942 /* need convert to big endian. */
9943 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
9944 filter.queue = res->queue_id;
9946 if (!strcmp(res->ops, "add"))
9947 ret = rte_eth_dev_filter_ctrl(res->port_id,
9948 RTE_ETH_FILTER_NTUPLE,
9952 ret = rte_eth_dev_filter_ctrl(res->port_id,
9953 RTE_ETH_FILTER_NTUPLE,
9954 RTE_ETH_FILTER_DELETE,
9957 printf("2tuple filter programming error: (%s)\n",
9962 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
9963 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9964 filter, "2tuple_filter");
9965 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
9966 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9968 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
9969 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9971 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
9972 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9973 dst_port, "dst_port");
9974 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
9975 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9976 dst_port_value, UINT16);
9977 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
9978 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9979 protocol, "protocol");
9980 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
9981 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9982 protocol_value, UINT8);
9983 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
9984 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9986 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
9987 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9989 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
9990 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9991 tcp_flags, "tcp_flags");
9992 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
9993 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9994 tcp_flags_value, UINT8);
9995 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
9996 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9997 priority, "priority");
9998 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
9999 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10000 priority_value, UINT8);
10001 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
10002 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10004 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
10005 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10008 cmdline_parse_inst_t cmd_2tuple_filter = {
10009 .f = cmd_2tuple_filter_parsed,
10011 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
10012 "<value> mask <value> tcp_flags <value> priority <value> queue "
10013 "<queue_id>: Add a 2tuple filter",
10015 (void *)&cmd_2tuple_filter_filter,
10016 (void *)&cmd_2tuple_filter_port_id,
10017 (void *)&cmd_2tuple_filter_ops,
10018 (void *)&cmd_2tuple_filter_dst_port,
10019 (void *)&cmd_2tuple_filter_dst_port_value,
10020 (void *)&cmd_2tuple_filter_protocol,
10021 (void *)&cmd_2tuple_filter_protocol_value,
10022 (void *)&cmd_2tuple_filter_mask,
10023 (void *)&cmd_2tuple_filter_mask_value,
10024 (void *)&cmd_2tuple_filter_tcp_flags,
10025 (void *)&cmd_2tuple_filter_tcp_flags_value,
10026 (void *)&cmd_2tuple_filter_priority,
10027 (void *)&cmd_2tuple_filter_priority_value,
10028 (void *)&cmd_2tuple_filter_queue,
10029 (void *)&cmd_2tuple_filter_queue_id,
10034 /* *** ADD/REMOVE A 5tuple FILTER *** */
10035 struct cmd_5tuple_filter_result {
10036 cmdline_fixed_string_t filter;
10038 cmdline_fixed_string_t ops;
10039 cmdline_fixed_string_t dst_ip;
10040 cmdline_ipaddr_t dst_ip_value;
10041 cmdline_fixed_string_t src_ip;
10042 cmdline_ipaddr_t src_ip_value;
10043 cmdline_fixed_string_t dst_port;
10044 uint16_t dst_port_value;
10045 cmdline_fixed_string_t src_port;
10046 uint16_t src_port_value;
10047 cmdline_fixed_string_t protocol;
10048 uint8_t protocol_value;
10049 cmdline_fixed_string_t mask;
10050 uint8_t mask_value;
10051 cmdline_fixed_string_t tcp_flags;
10052 uint8_t tcp_flags_value;
10053 cmdline_fixed_string_t priority;
10054 uint8_t priority_value;
10055 cmdline_fixed_string_t queue;
10060 cmd_5tuple_filter_parsed(void *parsed_result,
10061 __attribute__((unused)) struct cmdline *cl,
10062 __attribute__((unused)) void *data)
10064 struct rte_eth_ntuple_filter filter;
10065 struct cmd_5tuple_filter_result *res = parsed_result;
10068 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
10070 printf("ntuple filter is not supported on port %u.\n",
10075 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
10077 filter.flags = RTE_5TUPLE_FLAGS;
10078 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
10079 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
10080 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
10081 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
10082 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
10083 filter.proto = res->protocol_value;
10084 filter.priority = res->priority_value;
10085 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
10086 printf("nonzero tcp_flags is only meaningful"
10087 " when protocol is TCP.\n");
10090 if (res->tcp_flags_value > TCP_FLAG_ALL) {
10091 printf("invalid TCP flags.\n");
10095 if (res->tcp_flags_value != 0) {
10096 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
10097 filter.tcp_flags = res->tcp_flags_value;
10100 if (res->dst_ip_value.family == AF_INET)
10101 /* no need to convert, already big endian. */
10102 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
10104 if (filter.dst_ip_mask == 0) {
10105 printf("can not support ipv6 involved compare.\n");
10111 if (res->src_ip_value.family == AF_INET)
10112 /* no need to convert, already big endian. */
10113 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
10115 if (filter.src_ip_mask == 0) {
10116 printf("can not support ipv6 involved compare.\n");
10121 /* need convert to big endian. */
10122 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
10123 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
10124 filter.queue = res->queue_id;
10126 if (!strcmp(res->ops, "add"))
10127 ret = rte_eth_dev_filter_ctrl(res->port_id,
10128 RTE_ETH_FILTER_NTUPLE,
10129 RTE_ETH_FILTER_ADD,
10132 ret = rte_eth_dev_filter_ctrl(res->port_id,
10133 RTE_ETH_FILTER_NTUPLE,
10134 RTE_ETH_FILTER_DELETE,
10137 printf("5tuple filter programming error: (%s)\n",
10141 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
10142 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10143 filter, "5tuple_filter");
10144 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
10145 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10147 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
10148 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10150 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
10151 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10153 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
10154 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10156 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
10157 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10159 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
10160 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10162 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
10163 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10164 dst_port, "dst_port");
10165 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
10166 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10167 dst_port_value, UINT16);
10168 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
10169 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10170 src_port, "src_port");
10171 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
10172 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10173 src_port_value, UINT16);
10174 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
10175 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10176 protocol, "protocol");
10177 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
10178 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10179 protocol_value, UINT8);
10180 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
10181 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10183 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
10184 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10186 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
10187 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10188 tcp_flags, "tcp_flags");
10189 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
10190 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10191 tcp_flags_value, UINT8);
10192 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
10193 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10194 priority, "priority");
10195 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
10196 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10197 priority_value, UINT8);
10198 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
10199 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10201 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
10202 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10205 cmdline_parse_inst_t cmd_5tuple_filter = {
10206 .f = cmd_5tuple_filter_parsed,
10208 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
10209 "src_ip <value> dst_port <value> src_port <value> "
10210 "protocol <value> mask <value> tcp_flags <value> "
10211 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
10213 (void *)&cmd_5tuple_filter_filter,
10214 (void *)&cmd_5tuple_filter_port_id,
10215 (void *)&cmd_5tuple_filter_ops,
10216 (void *)&cmd_5tuple_filter_dst_ip,
10217 (void *)&cmd_5tuple_filter_dst_ip_value,
10218 (void *)&cmd_5tuple_filter_src_ip,
10219 (void *)&cmd_5tuple_filter_src_ip_value,
10220 (void *)&cmd_5tuple_filter_dst_port,
10221 (void *)&cmd_5tuple_filter_dst_port_value,
10222 (void *)&cmd_5tuple_filter_src_port,
10223 (void *)&cmd_5tuple_filter_src_port_value,
10224 (void *)&cmd_5tuple_filter_protocol,
10225 (void *)&cmd_5tuple_filter_protocol_value,
10226 (void *)&cmd_5tuple_filter_mask,
10227 (void *)&cmd_5tuple_filter_mask_value,
10228 (void *)&cmd_5tuple_filter_tcp_flags,
10229 (void *)&cmd_5tuple_filter_tcp_flags_value,
10230 (void *)&cmd_5tuple_filter_priority,
10231 (void *)&cmd_5tuple_filter_priority_value,
10232 (void *)&cmd_5tuple_filter_queue,
10233 (void *)&cmd_5tuple_filter_queue_id,
10238 /* *** ADD/REMOVE A flex FILTER *** */
10239 struct cmd_flex_filter_result {
10240 cmdline_fixed_string_t filter;
10241 cmdline_fixed_string_t ops;
10243 cmdline_fixed_string_t len;
10245 cmdline_fixed_string_t bytes;
10246 cmdline_fixed_string_t bytes_value;
10247 cmdline_fixed_string_t mask;
10248 cmdline_fixed_string_t mask_value;
10249 cmdline_fixed_string_t priority;
10250 uint8_t priority_value;
10251 cmdline_fixed_string_t queue;
10255 static int xdigit2val(unsigned char c)
10260 else if (isupper(c))
10261 val = c - 'A' + 10;
10263 val = c - 'a' + 10;
10268 cmd_flex_filter_parsed(void *parsed_result,
10269 __attribute__((unused)) struct cmdline *cl,
10270 __attribute__((unused)) void *data)
10273 struct rte_eth_flex_filter filter;
10274 struct cmd_flex_filter_result *res = parsed_result;
10275 char *bytes_ptr, *mask_ptr;
10276 uint16_t len, i, j = 0;
10281 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
10282 printf("the len exceed the max length 128\n");
10285 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
10286 filter.len = res->len_value;
10287 filter.priority = res->priority_value;
10288 filter.queue = res->queue_id;
10289 bytes_ptr = res->bytes_value;
10290 mask_ptr = res->mask_value;
10292 /* translate bytes string to array. */
10293 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
10294 (bytes_ptr[1] == 'X')))
10296 len = strnlen(bytes_ptr, res->len_value * 2);
10297 if (len == 0 || (len % 8 != 0)) {
10298 printf("please check len and bytes input\n");
10301 for (i = 0; i < len; i++) {
10303 if (isxdigit(c) == 0) {
10304 /* invalid characters. */
10305 printf("invalid input\n");
10308 val = xdigit2val(c);
10311 filter.bytes[j] = byte;
10312 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
10319 /* translate mask string to uint8_t array. */
10320 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
10321 (mask_ptr[1] == 'X')))
10323 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
10325 printf("invalid input\n");
10330 for (i = 0; i < len; i++) {
10332 if (isxdigit(c) == 0) {
10333 /* invalid characters. */
10334 printf("invalid input\n");
10337 val = xdigit2val(c);
10340 filter.mask[j] = byte;
10341 printf("mask[%d]:%02x ", j, filter.mask[j]);
10349 if (!strcmp(res->ops, "add"))
10350 ret = rte_eth_dev_filter_ctrl(res->port_id,
10351 RTE_ETH_FILTER_FLEXIBLE,
10352 RTE_ETH_FILTER_ADD,
10355 ret = rte_eth_dev_filter_ctrl(res->port_id,
10356 RTE_ETH_FILTER_FLEXIBLE,
10357 RTE_ETH_FILTER_DELETE,
10361 printf("flex filter setting error: (%s)\n", strerror(-ret));
10364 cmdline_parse_token_string_t cmd_flex_filter_filter =
10365 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10366 filter, "flex_filter");
10367 cmdline_parse_token_num_t cmd_flex_filter_port_id =
10368 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10370 cmdline_parse_token_string_t cmd_flex_filter_ops =
10371 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10373 cmdline_parse_token_string_t cmd_flex_filter_len =
10374 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10376 cmdline_parse_token_num_t cmd_flex_filter_len_value =
10377 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10379 cmdline_parse_token_string_t cmd_flex_filter_bytes =
10380 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10382 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
10383 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10384 bytes_value, NULL);
10385 cmdline_parse_token_string_t cmd_flex_filter_mask =
10386 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10388 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
10389 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10391 cmdline_parse_token_string_t cmd_flex_filter_priority =
10392 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10393 priority, "priority");
10394 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
10395 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10396 priority_value, UINT8);
10397 cmdline_parse_token_string_t cmd_flex_filter_queue =
10398 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10400 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
10401 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10403 cmdline_parse_inst_t cmd_flex_filter = {
10404 .f = cmd_flex_filter_parsed,
10406 .help_str = "flex_filter <port_id> add|del len <value> bytes "
10407 "<value> mask <value> priority <value> queue <queue_id>: "
10408 "Add/Del a flex filter",
10410 (void *)&cmd_flex_filter_filter,
10411 (void *)&cmd_flex_filter_port_id,
10412 (void *)&cmd_flex_filter_ops,
10413 (void *)&cmd_flex_filter_len,
10414 (void *)&cmd_flex_filter_len_value,
10415 (void *)&cmd_flex_filter_bytes,
10416 (void *)&cmd_flex_filter_bytes_value,
10417 (void *)&cmd_flex_filter_mask,
10418 (void *)&cmd_flex_filter_mask_value,
10419 (void *)&cmd_flex_filter_priority,
10420 (void *)&cmd_flex_filter_priority_value,
10421 (void *)&cmd_flex_filter_queue,
10422 (void *)&cmd_flex_filter_queue_id,
10427 /* *** Filters Control *** */
10429 /* *** deal with ethertype filter *** */
10430 struct cmd_ethertype_filter_result {
10431 cmdline_fixed_string_t filter;
10433 cmdline_fixed_string_t ops;
10434 cmdline_fixed_string_t mac;
10435 struct ether_addr mac_addr;
10436 cmdline_fixed_string_t ethertype;
10437 uint16_t ethertype_value;
10438 cmdline_fixed_string_t drop;
10439 cmdline_fixed_string_t queue;
10443 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
10444 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10445 filter, "ethertype_filter");
10446 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
10447 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10449 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
10450 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10452 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
10453 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10454 mac, "mac_addr#mac_ignr");
10455 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
10456 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
10458 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
10459 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10460 ethertype, "ethertype");
10461 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
10462 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10463 ethertype_value, UINT16);
10464 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
10465 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10467 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
10468 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10470 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
10471 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10475 cmd_ethertype_filter_parsed(void *parsed_result,
10476 __attribute__((unused)) struct cmdline *cl,
10477 __attribute__((unused)) void *data)
10479 struct cmd_ethertype_filter_result *res = parsed_result;
10480 struct rte_eth_ethertype_filter filter;
10483 ret = rte_eth_dev_filter_supported(res->port_id,
10484 RTE_ETH_FILTER_ETHERTYPE);
10486 printf("ethertype filter is not supported on port %u.\n",
10491 memset(&filter, 0, sizeof(filter));
10492 if (!strcmp(res->mac, "mac_addr")) {
10493 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
10494 rte_memcpy(&filter.mac_addr, &res->mac_addr,
10495 sizeof(struct ether_addr));
10497 if (!strcmp(res->drop, "drop"))
10498 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
10499 filter.ether_type = res->ethertype_value;
10500 filter.queue = res->queue_id;
10502 if (!strcmp(res->ops, "add"))
10503 ret = rte_eth_dev_filter_ctrl(res->port_id,
10504 RTE_ETH_FILTER_ETHERTYPE,
10505 RTE_ETH_FILTER_ADD,
10508 ret = rte_eth_dev_filter_ctrl(res->port_id,
10509 RTE_ETH_FILTER_ETHERTYPE,
10510 RTE_ETH_FILTER_DELETE,
10513 printf("ethertype filter programming error: (%s)\n",
10517 cmdline_parse_inst_t cmd_ethertype_filter = {
10518 .f = cmd_ethertype_filter_parsed,
10520 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
10521 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
10522 "Add or delete an ethertype filter entry",
10524 (void *)&cmd_ethertype_filter_filter,
10525 (void *)&cmd_ethertype_filter_port_id,
10526 (void *)&cmd_ethertype_filter_ops,
10527 (void *)&cmd_ethertype_filter_mac,
10528 (void *)&cmd_ethertype_filter_mac_addr,
10529 (void *)&cmd_ethertype_filter_ethertype,
10530 (void *)&cmd_ethertype_filter_ethertype_value,
10531 (void *)&cmd_ethertype_filter_drop,
10532 (void *)&cmd_ethertype_filter_queue,
10533 (void *)&cmd_ethertype_filter_queue_id,
10538 /* *** deal with flow director filter *** */
10539 struct cmd_flow_director_result {
10540 cmdline_fixed_string_t flow_director_filter;
10542 cmdline_fixed_string_t mode;
10543 cmdline_fixed_string_t mode_value;
10544 cmdline_fixed_string_t ops;
10545 cmdline_fixed_string_t flow;
10546 cmdline_fixed_string_t flow_type;
10547 cmdline_fixed_string_t ether;
10548 uint16_t ether_type;
10549 cmdline_fixed_string_t src;
10550 cmdline_ipaddr_t ip_src;
10552 cmdline_fixed_string_t dst;
10553 cmdline_ipaddr_t ip_dst;
10555 cmdline_fixed_string_t verify_tag;
10556 uint32_t verify_tag_value;
10557 cmdline_fixed_string_t tos;
10559 cmdline_fixed_string_t proto;
10560 uint8_t proto_value;
10561 cmdline_fixed_string_t ttl;
10563 cmdline_fixed_string_t vlan;
10564 uint16_t vlan_value;
10565 cmdline_fixed_string_t flexbytes;
10566 cmdline_fixed_string_t flexbytes_value;
10567 cmdline_fixed_string_t pf_vf;
10568 cmdline_fixed_string_t drop;
10569 cmdline_fixed_string_t queue;
10571 cmdline_fixed_string_t fd_id;
10572 uint32_t fd_id_value;
10573 cmdline_fixed_string_t mac;
10574 struct ether_addr mac_addr;
10575 cmdline_fixed_string_t tunnel;
10576 cmdline_fixed_string_t tunnel_type;
10577 cmdline_fixed_string_t tunnel_id;
10578 uint32_t tunnel_id_value;
10579 cmdline_fixed_string_t packet;
10584 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
10587 const char *p, *p0 = q_arg;
10589 unsigned long int_fld;
10590 char *str_fld[max_num];
10595 p = strchr(p0, '(');
10599 p0 = strchr(p, ')');
10604 if (size >= sizeof(s))
10607 snprintf(s, sizeof(s), "%.*s", size, p);
10608 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10609 if (ret < 0 || ret > max_num)
10611 for (i = 0; i < ret; i++) {
10613 int_fld = strtoul(str_fld[i], &end, 0);
10614 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
10616 flexbytes[i] = (uint8_t)int_fld;
10622 str2flowtype(char *string)
10625 static const struct {
10628 } flowtype_str[] = {
10629 {"raw", RTE_ETH_FLOW_RAW},
10630 {"ipv4", RTE_ETH_FLOW_IPV4},
10631 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10632 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10633 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10634 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10635 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10636 {"ipv6", RTE_ETH_FLOW_IPV6},
10637 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10638 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10639 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10640 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10641 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10642 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10645 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
10646 if (!strcmp(flowtype_str[i].str, string))
10647 return flowtype_str[i].type;
10650 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
10651 return (uint16_t)atoi(string);
10653 return RTE_ETH_FLOW_UNKNOWN;
10656 static enum rte_eth_fdir_tunnel_type
10657 str2fdir_tunneltype(char *string)
10661 static const struct {
10663 enum rte_eth_fdir_tunnel_type type;
10664 } tunneltype_str[] = {
10665 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
10666 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
10669 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
10670 if (!strcmp(tunneltype_str[i].str, string))
10671 return tunneltype_str[i].type;
10673 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
10676 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10678 if ((ip_addr).family == AF_INET) \
10679 (ip) = (ip_addr).addr.ipv4.s_addr; \
10681 printf("invalid parameter.\n"); \
10686 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10688 if ((ip_addr).family == AF_INET6) \
10689 rte_memcpy(&(ip), \
10690 &((ip_addr).addr.ipv6), \
10691 sizeof(struct in6_addr)); \
10693 printf("invalid parameter.\n"); \
10699 cmd_flow_director_filter_parsed(void *parsed_result,
10700 __attribute__((unused)) struct cmdline *cl,
10701 __attribute__((unused)) void *data)
10703 struct cmd_flow_director_result *res = parsed_result;
10704 struct rte_eth_fdir_filter entry;
10705 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
10707 unsigned long vf_id;
10710 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
10712 printf("flow director is not supported on port %u.\n",
10716 memset(flexbytes, 0, sizeof(flexbytes));
10717 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
10719 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10720 if (strcmp(res->mode_value, "MAC-VLAN")) {
10721 printf("Please set mode to MAC-VLAN.\n");
10724 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10725 if (strcmp(res->mode_value, "Tunnel")) {
10726 printf("Please set mode to Tunnel.\n");
10730 if (!strcmp(res->mode_value, "raw")) {
10731 #ifdef RTE_LIBRTE_I40E_PMD
10732 struct rte_pmd_i40e_flow_type_mapping
10733 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
10734 struct rte_pmd_i40e_pkt_template_conf conf;
10735 uint16_t flow_type = str2flowtype(res->flow_type);
10736 uint16_t i, port = res->port_id;
10739 memset(&conf, 0, sizeof(conf));
10741 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
10742 printf("Invalid flow type specified.\n");
10745 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
10749 if (mapping[flow_type].pctype == 0ULL) {
10750 printf("Invalid flow type specified.\n");
10753 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
10754 if (mapping[flow_type].pctype & (1ULL << i)) {
10755 conf.input.pctype = i;
10760 conf.input.packet = open_file(res->filepath,
10761 &conf.input.length);
10762 if (!conf.input.packet)
10764 if (!strcmp(res->drop, "drop"))
10765 conf.action.behavior =
10766 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
10768 conf.action.behavior =
10769 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
10770 conf.action.report_status =
10771 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
10772 conf.action.rx_queue = res->queue_id;
10773 conf.soft_id = res->fd_id_value;
10774 add = strcmp(res->ops, "del") ? 1 : 0;
10775 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
10779 printf("flow director config error: (%s)\n",
10781 close_file(conf.input.packet);
10784 } else if (strcmp(res->mode_value, "IP")) {
10785 printf("Please set mode to IP or raw.\n");
10788 entry.input.flow_type = str2flowtype(res->flow_type);
10791 ret = parse_flexbytes(res->flexbytes_value,
10793 RTE_ETH_FDIR_MAX_FLEXLEN);
10795 printf("error: Cannot parse flexbytes input.\n");
10799 switch (entry.input.flow_type) {
10800 case RTE_ETH_FLOW_FRAG_IPV4:
10801 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
10802 entry.input.flow.ip4_flow.proto = res->proto_value;
10804 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
10805 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
10806 IPV4_ADDR_TO_UINT(res->ip_dst,
10807 entry.input.flow.ip4_flow.dst_ip);
10808 IPV4_ADDR_TO_UINT(res->ip_src,
10809 entry.input.flow.ip4_flow.src_ip);
10810 entry.input.flow.ip4_flow.tos = res->tos_value;
10811 entry.input.flow.ip4_flow.ttl = res->ttl_value;
10812 /* need convert to big endian. */
10813 entry.input.flow.udp4_flow.dst_port =
10814 rte_cpu_to_be_16(res->port_dst);
10815 entry.input.flow.udp4_flow.src_port =
10816 rte_cpu_to_be_16(res->port_src);
10818 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
10819 IPV4_ADDR_TO_UINT(res->ip_dst,
10820 entry.input.flow.sctp4_flow.ip.dst_ip);
10821 IPV4_ADDR_TO_UINT(res->ip_src,
10822 entry.input.flow.sctp4_flow.ip.src_ip);
10823 entry.input.flow.ip4_flow.tos = res->tos_value;
10824 entry.input.flow.ip4_flow.ttl = res->ttl_value;
10825 /* need convert to big endian. */
10826 entry.input.flow.sctp4_flow.dst_port =
10827 rte_cpu_to_be_16(res->port_dst);
10828 entry.input.flow.sctp4_flow.src_port =
10829 rte_cpu_to_be_16(res->port_src);
10830 entry.input.flow.sctp4_flow.verify_tag =
10831 rte_cpu_to_be_32(res->verify_tag_value);
10833 case RTE_ETH_FLOW_FRAG_IPV6:
10834 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
10835 entry.input.flow.ipv6_flow.proto = res->proto_value;
10837 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
10838 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
10839 IPV6_ADDR_TO_ARRAY(res->ip_dst,
10840 entry.input.flow.ipv6_flow.dst_ip);
10841 IPV6_ADDR_TO_ARRAY(res->ip_src,
10842 entry.input.flow.ipv6_flow.src_ip);
10843 entry.input.flow.ipv6_flow.tc = res->tos_value;
10844 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
10845 /* need convert to big endian. */
10846 entry.input.flow.udp6_flow.dst_port =
10847 rte_cpu_to_be_16(res->port_dst);
10848 entry.input.flow.udp6_flow.src_port =
10849 rte_cpu_to_be_16(res->port_src);
10851 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
10852 IPV6_ADDR_TO_ARRAY(res->ip_dst,
10853 entry.input.flow.sctp6_flow.ip.dst_ip);
10854 IPV6_ADDR_TO_ARRAY(res->ip_src,
10855 entry.input.flow.sctp6_flow.ip.src_ip);
10856 entry.input.flow.ipv6_flow.tc = res->tos_value;
10857 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
10858 /* need convert to big endian. */
10859 entry.input.flow.sctp6_flow.dst_port =
10860 rte_cpu_to_be_16(res->port_dst);
10861 entry.input.flow.sctp6_flow.src_port =
10862 rte_cpu_to_be_16(res->port_src);
10863 entry.input.flow.sctp6_flow.verify_tag =
10864 rte_cpu_to_be_32(res->verify_tag_value);
10866 case RTE_ETH_FLOW_L2_PAYLOAD:
10867 entry.input.flow.l2_flow.ether_type =
10868 rte_cpu_to_be_16(res->ether_type);
10874 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
10875 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
10877 sizeof(struct ether_addr));
10879 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10880 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
10882 sizeof(struct ether_addr));
10883 entry.input.flow.tunnel_flow.tunnel_type =
10884 str2fdir_tunneltype(res->tunnel_type);
10885 entry.input.flow.tunnel_flow.tunnel_id =
10886 rte_cpu_to_be_32(res->tunnel_id_value);
10889 rte_memcpy(entry.input.flow_ext.flexbytes,
10891 RTE_ETH_FDIR_MAX_FLEXLEN);
10893 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
10895 entry.action.flex_off = 0; /*use 0 by default */
10896 if (!strcmp(res->drop, "drop"))
10897 entry.action.behavior = RTE_ETH_FDIR_REJECT;
10899 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
10901 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
10902 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
10903 if (!strcmp(res->pf_vf, "pf"))
10904 entry.input.flow_ext.is_vf = 0;
10905 else if (!strncmp(res->pf_vf, "vf", 2)) {
10906 struct rte_eth_dev_info dev_info;
10908 memset(&dev_info, 0, sizeof(dev_info));
10909 rte_eth_dev_info_get(res->port_id, &dev_info);
10911 vf_id = strtoul(res->pf_vf + 2, &end, 10);
10912 if (errno != 0 || *end != '\0' ||
10913 vf_id >= dev_info.max_vfs) {
10914 printf("invalid parameter %s.\n", res->pf_vf);
10917 entry.input.flow_ext.is_vf = 1;
10918 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
10920 printf("invalid parameter %s.\n", res->pf_vf);
10925 /* set to report FD ID by default */
10926 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
10927 entry.action.rx_queue = res->queue_id;
10928 entry.soft_id = res->fd_id_value;
10929 if (!strcmp(res->ops, "add"))
10930 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10931 RTE_ETH_FILTER_ADD, &entry);
10932 else if (!strcmp(res->ops, "del"))
10933 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10934 RTE_ETH_FILTER_DELETE, &entry);
10936 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10937 RTE_ETH_FILTER_UPDATE, &entry);
10939 printf("flow director programming error: (%s)\n",
10943 cmdline_parse_token_string_t cmd_flow_director_filter =
10944 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10945 flow_director_filter, "flow_director_filter");
10946 cmdline_parse_token_num_t cmd_flow_director_port_id =
10947 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10949 cmdline_parse_token_string_t cmd_flow_director_ops =
10950 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10951 ops, "add#del#update");
10952 cmdline_parse_token_string_t cmd_flow_director_flow =
10953 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10955 cmdline_parse_token_string_t cmd_flow_director_flow_type =
10956 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10958 cmdline_parse_token_string_t cmd_flow_director_ether =
10959 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10961 cmdline_parse_token_num_t cmd_flow_director_ether_type =
10962 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10963 ether_type, UINT16);
10964 cmdline_parse_token_string_t cmd_flow_director_src =
10965 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10967 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
10968 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10970 cmdline_parse_token_num_t cmd_flow_director_port_src =
10971 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10973 cmdline_parse_token_string_t cmd_flow_director_dst =
10974 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10976 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
10977 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10979 cmdline_parse_token_num_t cmd_flow_director_port_dst =
10980 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10982 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
10983 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10984 verify_tag, "verify_tag");
10985 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
10986 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10987 verify_tag_value, UINT32);
10988 cmdline_parse_token_string_t cmd_flow_director_tos =
10989 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10991 cmdline_parse_token_num_t cmd_flow_director_tos_value =
10992 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10994 cmdline_parse_token_string_t cmd_flow_director_proto =
10995 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10997 cmdline_parse_token_num_t cmd_flow_director_proto_value =
10998 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10999 proto_value, UINT8);
11000 cmdline_parse_token_string_t cmd_flow_director_ttl =
11001 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11003 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
11004 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11006 cmdline_parse_token_string_t cmd_flow_director_vlan =
11007 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11009 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
11010 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11011 vlan_value, UINT16);
11012 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
11013 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11014 flexbytes, "flexbytes");
11015 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
11016 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11017 flexbytes_value, NULL);
11018 cmdline_parse_token_string_t cmd_flow_director_drop =
11019 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11021 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
11022 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11024 cmdline_parse_token_string_t cmd_flow_director_queue =
11025 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11027 cmdline_parse_token_num_t cmd_flow_director_queue_id =
11028 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11030 cmdline_parse_token_string_t cmd_flow_director_fd_id =
11031 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11033 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
11034 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11035 fd_id_value, UINT32);
11037 cmdline_parse_token_string_t cmd_flow_director_mode =
11038 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11040 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
11041 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11043 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
11044 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11045 mode_value, "MAC-VLAN");
11046 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
11047 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11048 mode_value, "Tunnel");
11049 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
11050 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11051 mode_value, "raw");
11052 cmdline_parse_token_string_t cmd_flow_director_mac =
11053 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11055 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
11056 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
11058 cmdline_parse_token_string_t cmd_flow_director_tunnel =
11059 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11061 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
11062 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11063 tunnel_type, "NVGRE#VxLAN");
11064 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
11065 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11066 tunnel_id, "tunnel-id");
11067 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
11068 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11069 tunnel_id_value, UINT32);
11070 cmdline_parse_token_string_t cmd_flow_director_packet =
11071 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11073 cmdline_parse_token_string_t cmd_flow_director_filepath =
11074 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11077 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
11078 .f = cmd_flow_director_filter_parsed,
11080 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
11081 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
11082 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
11083 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
11084 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
11085 "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> "
11086 "fd_id <fd_id_value>: "
11087 "Add or delete an ip flow director entry on NIC",
11089 (void *)&cmd_flow_director_filter,
11090 (void *)&cmd_flow_director_port_id,
11091 (void *)&cmd_flow_director_mode,
11092 (void *)&cmd_flow_director_mode_ip,
11093 (void *)&cmd_flow_director_ops,
11094 (void *)&cmd_flow_director_flow,
11095 (void *)&cmd_flow_director_flow_type,
11096 (void *)&cmd_flow_director_src,
11097 (void *)&cmd_flow_director_ip_src,
11098 (void *)&cmd_flow_director_dst,
11099 (void *)&cmd_flow_director_ip_dst,
11100 (void *)&cmd_flow_director_tos,
11101 (void *)&cmd_flow_director_tos_value,
11102 (void *)&cmd_flow_director_proto,
11103 (void *)&cmd_flow_director_proto_value,
11104 (void *)&cmd_flow_director_ttl,
11105 (void *)&cmd_flow_director_ttl_value,
11106 (void *)&cmd_flow_director_vlan,
11107 (void *)&cmd_flow_director_vlan_value,
11108 (void *)&cmd_flow_director_flexbytes,
11109 (void *)&cmd_flow_director_flexbytes_value,
11110 (void *)&cmd_flow_director_drop,
11111 (void *)&cmd_flow_director_pf_vf,
11112 (void *)&cmd_flow_director_queue,
11113 (void *)&cmd_flow_director_queue_id,
11114 (void *)&cmd_flow_director_fd_id,
11115 (void *)&cmd_flow_director_fd_id_value,
11120 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
11121 .f = cmd_flow_director_filter_parsed,
11123 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
11124 "director entry on NIC",
11126 (void *)&cmd_flow_director_filter,
11127 (void *)&cmd_flow_director_port_id,
11128 (void *)&cmd_flow_director_mode,
11129 (void *)&cmd_flow_director_mode_ip,
11130 (void *)&cmd_flow_director_ops,
11131 (void *)&cmd_flow_director_flow,
11132 (void *)&cmd_flow_director_flow_type,
11133 (void *)&cmd_flow_director_src,
11134 (void *)&cmd_flow_director_ip_src,
11135 (void *)&cmd_flow_director_port_src,
11136 (void *)&cmd_flow_director_dst,
11137 (void *)&cmd_flow_director_ip_dst,
11138 (void *)&cmd_flow_director_port_dst,
11139 (void *)&cmd_flow_director_tos,
11140 (void *)&cmd_flow_director_tos_value,
11141 (void *)&cmd_flow_director_ttl,
11142 (void *)&cmd_flow_director_ttl_value,
11143 (void *)&cmd_flow_director_vlan,
11144 (void *)&cmd_flow_director_vlan_value,
11145 (void *)&cmd_flow_director_flexbytes,
11146 (void *)&cmd_flow_director_flexbytes_value,
11147 (void *)&cmd_flow_director_drop,
11148 (void *)&cmd_flow_director_pf_vf,
11149 (void *)&cmd_flow_director_queue,
11150 (void *)&cmd_flow_director_queue_id,
11151 (void *)&cmd_flow_director_fd_id,
11152 (void *)&cmd_flow_director_fd_id_value,
11157 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
11158 .f = cmd_flow_director_filter_parsed,
11160 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
11161 "director entry on NIC",
11163 (void *)&cmd_flow_director_filter,
11164 (void *)&cmd_flow_director_port_id,
11165 (void *)&cmd_flow_director_mode,
11166 (void *)&cmd_flow_director_mode_ip,
11167 (void *)&cmd_flow_director_ops,
11168 (void *)&cmd_flow_director_flow,
11169 (void *)&cmd_flow_director_flow_type,
11170 (void *)&cmd_flow_director_src,
11171 (void *)&cmd_flow_director_ip_src,
11172 (void *)&cmd_flow_director_port_src,
11173 (void *)&cmd_flow_director_dst,
11174 (void *)&cmd_flow_director_ip_dst,
11175 (void *)&cmd_flow_director_port_dst,
11176 (void *)&cmd_flow_director_verify_tag,
11177 (void *)&cmd_flow_director_verify_tag_value,
11178 (void *)&cmd_flow_director_tos,
11179 (void *)&cmd_flow_director_tos_value,
11180 (void *)&cmd_flow_director_ttl,
11181 (void *)&cmd_flow_director_ttl_value,
11182 (void *)&cmd_flow_director_vlan,
11183 (void *)&cmd_flow_director_vlan_value,
11184 (void *)&cmd_flow_director_flexbytes,
11185 (void *)&cmd_flow_director_flexbytes_value,
11186 (void *)&cmd_flow_director_drop,
11187 (void *)&cmd_flow_director_pf_vf,
11188 (void *)&cmd_flow_director_queue,
11189 (void *)&cmd_flow_director_queue_id,
11190 (void *)&cmd_flow_director_fd_id,
11191 (void *)&cmd_flow_director_fd_id_value,
11196 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
11197 .f = cmd_flow_director_filter_parsed,
11199 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
11200 "director entry on NIC",
11202 (void *)&cmd_flow_director_filter,
11203 (void *)&cmd_flow_director_port_id,
11204 (void *)&cmd_flow_director_mode,
11205 (void *)&cmd_flow_director_mode_ip,
11206 (void *)&cmd_flow_director_ops,
11207 (void *)&cmd_flow_director_flow,
11208 (void *)&cmd_flow_director_flow_type,
11209 (void *)&cmd_flow_director_ether,
11210 (void *)&cmd_flow_director_ether_type,
11211 (void *)&cmd_flow_director_flexbytes,
11212 (void *)&cmd_flow_director_flexbytes_value,
11213 (void *)&cmd_flow_director_drop,
11214 (void *)&cmd_flow_director_pf_vf,
11215 (void *)&cmd_flow_director_queue,
11216 (void *)&cmd_flow_director_queue_id,
11217 (void *)&cmd_flow_director_fd_id,
11218 (void *)&cmd_flow_director_fd_id_value,
11223 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
11224 .f = cmd_flow_director_filter_parsed,
11226 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
11227 "director entry on NIC",
11229 (void *)&cmd_flow_director_filter,
11230 (void *)&cmd_flow_director_port_id,
11231 (void *)&cmd_flow_director_mode,
11232 (void *)&cmd_flow_director_mode_mac_vlan,
11233 (void *)&cmd_flow_director_ops,
11234 (void *)&cmd_flow_director_mac,
11235 (void *)&cmd_flow_director_mac_addr,
11236 (void *)&cmd_flow_director_vlan,
11237 (void *)&cmd_flow_director_vlan_value,
11238 (void *)&cmd_flow_director_flexbytes,
11239 (void *)&cmd_flow_director_flexbytes_value,
11240 (void *)&cmd_flow_director_drop,
11241 (void *)&cmd_flow_director_queue,
11242 (void *)&cmd_flow_director_queue_id,
11243 (void *)&cmd_flow_director_fd_id,
11244 (void *)&cmd_flow_director_fd_id_value,
11249 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
11250 .f = cmd_flow_director_filter_parsed,
11252 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
11253 "director entry on NIC",
11255 (void *)&cmd_flow_director_filter,
11256 (void *)&cmd_flow_director_port_id,
11257 (void *)&cmd_flow_director_mode,
11258 (void *)&cmd_flow_director_mode_tunnel,
11259 (void *)&cmd_flow_director_ops,
11260 (void *)&cmd_flow_director_mac,
11261 (void *)&cmd_flow_director_mac_addr,
11262 (void *)&cmd_flow_director_vlan,
11263 (void *)&cmd_flow_director_vlan_value,
11264 (void *)&cmd_flow_director_tunnel,
11265 (void *)&cmd_flow_director_tunnel_type,
11266 (void *)&cmd_flow_director_tunnel_id,
11267 (void *)&cmd_flow_director_tunnel_id_value,
11268 (void *)&cmd_flow_director_flexbytes,
11269 (void *)&cmd_flow_director_flexbytes_value,
11270 (void *)&cmd_flow_director_drop,
11271 (void *)&cmd_flow_director_queue,
11272 (void *)&cmd_flow_director_queue_id,
11273 (void *)&cmd_flow_director_fd_id,
11274 (void *)&cmd_flow_director_fd_id_value,
11279 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
11280 .f = cmd_flow_director_filter_parsed,
11282 .help_str = "flow_director_filter ... : Add or delete a raw flow "
11283 "director entry on NIC",
11285 (void *)&cmd_flow_director_filter,
11286 (void *)&cmd_flow_director_port_id,
11287 (void *)&cmd_flow_director_mode,
11288 (void *)&cmd_flow_director_mode_raw,
11289 (void *)&cmd_flow_director_ops,
11290 (void *)&cmd_flow_director_flow,
11291 (void *)&cmd_flow_director_flow_type,
11292 (void *)&cmd_flow_director_drop,
11293 (void *)&cmd_flow_director_queue,
11294 (void *)&cmd_flow_director_queue_id,
11295 (void *)&cmd_flow_director_fd_id,
11296 (void *)&cmd_flow_director_fd_id_value,
11297 (void *)&cmd_flow_director_packet,
11298 (void *)&cmd_flow_director_filepath,
11303 struct cmd_flush_flow_director_result {
11304 cmdline_fixed_string_t flush_flow_director;
11308 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
11309 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
11310 flush_flow_director, "flush_flow_director");
11311 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
11312 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
11316 cmd_flush_flow_director_parsed(void *parsed_result,
11317 __attribute__((unused)) struct cmdline *cl,
11318 __attribute__((unused)) void *data)
11320 struct cmd_flow_director_result *res = parsed_result;
11323 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
11325 printf("flow director is not supported on port %u.\n",
11330 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11331 RTE_ETH_FILTER_FLUSH, NULL);
11333 printf("flow director table flushing error: (%s)\n",
11337 cmdline_parse_inst_t cmd_flush_flow_director = {
11338 .f = cmd_flush_flow_director_parsed,
11340 .help_str = "flush_flow_director <port_id>: "
11341 "Flush all flow director entries of a device on NIC",
11343 (void *)&cmd_flush_flow_director_flush,
11344 (void *)&cmd_flush_flow_director_port_id,
11349 /* *** deal with flow director mask *** */
11350 struct cmd_flow_director_mask_result {
11351 cmdline_fixed_string_t flow_director_mask;
11353 cmdline_fixed_string_t mode;
11354 cmdline_fixed_string_t mode_value;
11355 cmdline_fixed_string_t vlan;
11356 uint16_t vlan_mask;
11357 cmdline_fixed_string_t src_mask;
11358 cmdline_ipaddr_t ipv4_src;
11359 cmdline_ipaddr_t ipv6_src;
11361 cmdline_fixed_string_t dst_mask;
11362 cmdline_ipaddr_t ipv4_dst;
11363 cmdline_ipaddr_t ipv6_dst;
11365 cmdline_fixed_string_t mac;
11366 uint8_t mac_addr_byte_mask;
11367 cmdline_fixed_string_t tunnel_id;
11368 uint32_t tunnel_id_mask;
11369 cmdline_fixed_string_t tunnel_type;
11370 uint8_t tunnel_type_mask;
11374 cmd_flow_director_mask_parsed(void *parsed_result,
11375 __attribute__((unused)) struct cmdline *cl,
11376 __attribute__((unused)) void *data)
11378 struct cmd_flow_director_mask_result *res = parsed_result;
11379 struct rte_eth_fdir_masks *mask;
11380 struct rte_port *port;
11382 port = &ports[res->port_id];
11383 /** Check if the port is not started **/
11384 if (port->port_status != RTE_PORT_STOPPED) {
11385 printf("Please stop port %d first\n", res->port_id);
11389 mask = &port->dev_conf.fdir_conf.mask;
11391 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
11392 if (strcmp(res->mode_value, "MAC-VLAN")) {
11393 printf("Please set mode to MAC-VLAN.\n");
11397 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11398 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11399 if (strcmp(res->mode_value, "Tunnel")) {
11400 printf("Please set mode to Tunnel.\n");
11404 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11405 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
11406 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
11407 mask->tunnel_type_mask = res->tunnel_type_mask;
11409 if (strcmp(res->mode_value, "IP")) {
11410 printf("Please set mode to IP.\n");
11414 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11415 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
11416 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
11417 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
11418 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
11419 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
11420 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
11423 cmd_reconfig_device_queue(res->port_id, 1, 1);
11426 cmdline_parse_token_string_t cmd_flow_director_mask =
11427 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11428 flow_director_mask, "flow_director_mask");
11429 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
11430 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11432 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
11433 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11435 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
11436 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11437 vlan_mask, UINT16);
11438 cmdline_parse_token_string_t cmd_flow_director_mask_src =
11439 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11440 src_mask, "src_mask");
11441 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
11442 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11444 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
11445 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11447 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
11448 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11450 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
11451 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11452 dst_mask, "dst_mask");
11453 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
11454 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11456 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
11457 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11459 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
11460 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11463 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
11464 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11466 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
11467 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11469 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
11470 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11471 mode_value, "MAC-VLAN");
11472 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
11473 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11474 mode_value, "Tunnel");
11475 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
11476 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11478 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
11479 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11480 mac_addr_byte_mask, UINT8);
11481 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
11482 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11483 tunnel_type, "tunnel-type");
11484 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
11485 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11486 tunnel_type_mask, UINT8);
11487 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
11488 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11489 tunnel_id, "tunnel-id");
11490 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
11491 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11492 tunnel_id_mask, UINT32);
11494 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
11495 .f = cmd_flow_director_mask_parsed,
11497 .help_str = "flow_director_mask ... : "
11498 "Set IP mode flow director's mask on NIC",
11500 (void *)&cmd_flow_director_mask,
11501 (void *)&cmd_flow_director_mask_port_id,
11502 (void *)&cmd_flow_director_mask_mode,
11503 (void *)&cmd_flow_director_mask_mode_ip,
11504 (void *)&cmd_flow_director_mask_vlan,
11505 (void *)&cmd_flow_director_mask_vlan_value,
11506 (void *)&cmd_flow_director_mask_src,
11507 (void *)&cmd_flow_director_mask_ipv4_src,
11508 (void *)&cmd_flow_director_mask_ipv6_src,
11509 (void *)&cmd_flow_director_mask_port_src,
11510 (void *)&cmd_flow_director_mask_dst,
11511 (void *)&cmd_flow_director_mask_ipv4_dst,
11512 (void *)&cmd_flow_director_mask_ipv6_dst,
11513 (void *)&cmd_flow_director_mask_port_dst,
11518 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
11519 .f = cmd_flow_director_mask_parsed,
11521 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
11522 "flow director's mask on NIC",
11524 (void *)&cmd_flow_director_mask,
11525 (void *)&cmd_flow_director_mask_port_id,
11526 (void *)&cmd_flow_director_mask_mode,
11527 (void *)&cmd_flow_director_mask_mode_mac_vlan,
11528 (void *)&cmd_flow_director_mask_vlan,
11529 (void *)&cmd_flow_director_mask_vlan_value,
11534 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
11535 .f = cmd_flow_director_mask_parsed,
11537 .help_str = "flow_director_mask ... : Set tunnel mode "
11538 "flow director's mask on NIC",
11540 (void *)&cmd_flow_director_mask,
11541 (void *)&cmd_flow_director_mask_port_id,
11542 (void *)&cmd_flow_director_mask_mode,
11543 (void *)&cmd_flow_director_mask_mode_tunnel,
11544 (void *)&cmd_flow_director_mask_vlan,
11545 (void *)&cmd_flow_director_mask_vlan_value,
11546 (void *)&cmd_flow_director_mask_mac,
11547 (void *)&cmd_flow_director_mask_mac_value,
11548 (void *)&cmd_flow_director_mask_tunnel_type,
11549 (void *)&cmd_flow_director_mask_tunnel_type_value,
11550 (void *)&cmd_flow_director_mask_tunnel_id,
11551 (void *)&cmd_flow_director_mask_tunnel_id_value,
11556 /* *** deal with flow director mask on flexible payload *** */
11557 struct cmd_flow_director_flex_mask_result {
11558 cmdline_fixed_string_t flow_director_flexmask;
11560 cmdline_fixed_string_t flow;
11561 cmdline_fixed_string_t flow_type;
11562 cmdline_fixed_string_t mask;
11566 cmd_flow_director_flex_mask_parsed(void *parsed_result,
11567 __attribute__((unused)) struct cmdline *cl,
11568 __attribute__((unused)) void *data)
11570 struct cmd_flow_director_flex_mask_result *res = parsed_result;
11571 struct rte_eth_fdir_info fdir_info;
11572 struct rte_eth_fdir_flex_mask flex_mask;
11573 struct rte_port *port;
11574 uint64_t flow_type_mask;
11578 port = &ports[res->port_id];
11579 /** Check if the port is not started **/
11580 if (port->port_status != RTE_PORT_STOPPED) {
11581 printf("Please stop port %d first\n", res->port_id);
11585 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
11586 ret = parse_flexbytes(res->mask,
11588 RTE_ETH_FDIR_MAX_FLEXLEN);
11590 printf("error: Cannot parse mask input.\n");
11594 memset(&fdir_info, 0, sizeof(fdir_info));
11595 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11596 RTE_ETH_FILTER_INFO, &fdir_info);
11598 printf("Cannot get FDir filter info\n");
11602 if (!strcmp(res->flow_type, "none")) {
11603 /* means don't specify the flow type */
11604 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
11605 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
11606 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
11607 0, sizeof(struct rte_eth_fdir_flex_mask));
11608 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
11609 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
11611 sizeof(struct rte_eth_fdir_flex_mask));
11612 cmd_reconfig_device_queue(res->port_id, 1, 1);
11615 flow_type_mask = fdir_info.flow_types_mask[0];
11616 if (!strcmp(res->flow_type, "all")) {
11617 if (!flow_type_mask) {
11618 printf("No flow type supported\n");
11621 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
11622 if (flow_type_mask & (1ULL << i)) {
11623 flex_mask.flow_type = i;
11624 fdir_set_flex_mask(res->port_id, &flex_mask);
11627 cmd_reconfig_device_queue(res->port_id, 1, 1);
11630 flex_mask.flow_type = str2flowtype(res->flow_type);
11631 if (!(flow_type_mask & (1ULL << flex_mask.flow_type))) {
11632 printf("Flow type %s not supported on port %d\n",
11633 res->flow_type, res->port_id);
11636 fdir_set_flex_mask(res->port_id, &flex_mask);
11637 cmd_reconfig_device_queue(res->port_id, 1, 1);
11640 cmdline_parse_token_string_t cmd_flow_director_flexmask =
11641 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11642 flow_director_flexmask,
11643 "flow_director_flex_mask");
11644 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
11645 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11647 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
11648 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11650 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
11651 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11652 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
11653 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
11654 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
11655 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11658 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
11659 .f = cmd_flow_director_flex_mask_parsed,
11661 .help_str = "flow_director_flex_mask ... : "
11662 "Set flow director's flex mask on NIC",
11664 (void *)&cmd_flow_director_flexmask,
11665 (void *)&cmd_flow_director_flexmask_port_id,
11666 (void *)&cmd_flow_director_flexmask_flow,
11667 (void *)&cmd_flow_director_flexmask_flow_type,
11668 (void *)&cmd_flow_director_flexmask_mask,
11673 /* *** deal with flow director flexible payload configuration *** */
11674 struct cmd_flow_director_flexpayload_result {
11675 cmdline_fixed_string_t flow_director_flexpayload;
11677 cmdline_fixed_string_t payload_layer;
11678 cmdline_fixed_string_t payload_cfg;
11682 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
11685 const char *p, *p0 = q_arg;
11687 unsigned long int_fld;
11688 char *str_fld[max_num];
11693 p = strchr(p0, '(');
11697 p0 = strchr(p, ')');
11702 if (size >= sizeof(s))
11705 snprintf(s, sizeof(s), "%.*s", size, p);
11706 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
11707 if (ret < 0 || ret > max_num)
11709 for (i = 0; i < ret; i++) {
11711 int_fld = strtoul(str_fld[i], &end, 0);
11712 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
11714 offsets[i] = (uint16_t)int_fld;
11720 cmd_flow_director_flxpld_parsed(void *parsed_result,
11721 __attribute__((unused)) struct cmdline *cl,
11722 __attribute__((unused)) void *data)
11724 struct cmd_flow_director_flexpayload_result *res = parsed_result;
11725 struct rte_eth_flex_payload_cfg flex_cfg;
11726 struct rte_port *port;
11729 port = &ports[res->port_id];
11730 /** Check if the port is not started **/
11731 if (port->port_status != RTE_PORT_STOPPED) {
11732 printf("Please stop port %d first\n", res->port_id);
11736 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
11738 if (!strcmp(res->payload_layer, "raw"))
11739 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
11740 else if (!strcmp(res->payload_layer, "l2"))
11741 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
11742 else if (!strcmp(res->payload_layer, "l3"))
11743 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
11744 else if (!strcmp(res->payload_layer, "l4"))
11745 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
11747 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
11748 RTE_ETH_FDIR_MAX_FLEXLEN);
11750 printf("error: Cannot parse flex payload input.\n");
11754 fdir_set_flex_payload(res->port_id, &flex_cfg);
11755 cmd_reconfig_device_queue(res->port_id, 1, 1);
11758 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
11759 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11760 flow_director_flexpayload,
11761 "flow_director_flex_payload");
11762 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
11763 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11765 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
11766 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11767 payload_layer, "raw#l2#l3#l4");
11768 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
11769 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11770 payload_cfg, NULL);
11772 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
11773 .f = cmd_flow_director_flxpld_parsed,
11775 .help_str = "flow_director_flexpayload ... : "
11776 "Set flow director's flex payload on NIC",
11778 (void *)&cmd_flow_director_flexpayload,
11779 (void *)&cmd_flow_director_flexpayload_port_id,
11780 (void *)&cmd_flow_director_flexpayload_payload_layer,
11781 (void *)&cmd_flow_director_flexpayload_payload_cfg,
11786 /* Generic flow interface command. */
11787 extern cmdline_parse_inst_t cmd_flow;
11789 /* *** Classification Filters Control *** */
11790 /* *** Get symmetric hash enable per port *** */
11791 struct cmd_get_sym_hash_ena_per_port_result {
11792 cmdline_fixed_string_t get_sym_hash_ena_per_port;
11797 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
11798 __rte_unused struct cmdline *cl,
11799 __rte_unused void *data)
11801 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
11802 struct rte_eth_hash_filter_info info;
11805 if (rte_eth_dev_filter_supported(res->port_id,
11806 RTE_ETH_FILTER_HASH) < 0) {
11807 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
11812 memset(&info, 0, sizeof(info));
11813 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
11814 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11815 RTE_ETH_FILTER_GET, &info);
11818 printf("Cannot get symmetric hash enable per port "
11819 "on port %u\n", res->port_id);
11823 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
11824 "enabled" : "disabled", res->port_id);
11827 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
11828 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
11829 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
11830 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
11831 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
11834 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
11835 .f = cmd_get_sym_hash_per_port_parsed,
11837 .help_str = "get_sym_hash_ena_per_port <port_id>",
11839 (void *)&cmd_get_sym_hash_ena_per_port_all,
11840 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
11845 /* *** Set symmetric hash enable per port *** */
11846 struct cmd_set_sym_hash_ena_per_port_result {
11847 cmdline_fixed_string_t set_sym_hash_ena_per_port;
11848 cmdline_fixed_string_t enable;
11853 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
11854 __rte_unused struct cmdline *cl,
11855 __rte_unused void *data)
11857 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
11858 struct rte_eth_hash_filter_info info;
11861 if (rte_eth_dev_filter_supported(res->port_id,
11862 RTE_ETH_FILTER_HASH) < 0) {
11863 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
11868 memset(&info, 0, sizeof(info));
11869 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
11870 if (!strcmp(res->enable, "enable"))
11871 info.info.enable = 1;
11872 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11873 RTE_ETH_FILTER_SET, &info);
11875 printf("Cannot set symmetric hash enable per port on "
11876 "port %u\n", res->port_id);
11879 printf("Symmetric hash has been set to %s on port %u\n",
11880 res->enable, res->port_id);
11883 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
11884 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11885 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
11886 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
11887 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11889 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
11890 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11891 enable, "enable#disable");
11893 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
11894 .f = cmd_set_sym_hash_per_port_parsed,
11896 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
11898 (void *)&cmd_set_sym_hash_ena_per_port_all,
11899 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
11900 (void *)&cmd_set_sym_hash_ena_per_port_enable,
11905 /* Get global config of hash function */
11906 struct cmd_get_hash_global_config_result {
11907 cmdline_fixed_string_t get_hash_global_config;
11912 flowtype_to_str(uint16_t ftype)
11918 } ftype_table[] = {
11919 {"ipv4", RTE_ETH_FLOW_IPV4},
11920 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
11921 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
11922 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
11923 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
11924 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
11925 {"ipv6", RTE_ETH_FLOW_IPV6},
11926 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
11927 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
11928 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
11929 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
11930 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
11931 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
11932 {"port", RTE_ETH_FLOW_PORT},
11933 {"vxlan", RTE_ETH_FLOW_VXLAN},
11934 {"geneve", RTE_ETH_FLOW_GENEVE},
11935 {"nvgre", RTE_ETH_FLOW_NVGRE},
11938 for (i = 0; i < RTE_DIM(ftype_table); i++) {
11939 if (ftype_table[i].ftype == ftype)
11940 return ftype_table[i].str;
11947 cmd_get_hash_global_config_parsed(void *parsed_result,
11948 __rte_unused struct cmdline *cl,
11949 __rte_unused void *data)
11951 struct cmd_get_hash_global_config_result *res = parsed_result;
11952 struct rte_eth_hash_filter_info info;
11953 uint32_t idx, offset;
11958 if (rte_eth_dev_filter_supported(res->port_id,
11959 RTE_ETH_FILTER_HASH) < 0) {
11960 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
11965 memset(&info, 0, sizeof(info));
11966 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
11967 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11968 RTE_ETH_FILTER_GET, &info);
11970 printf("Cannot get hash global configurations by port %d\n",
11975 switch (info.info.global_conf.hash_func) {
11976 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
11977 printf("Hash function is Toeplitz\n");
11979 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
11980 printf("Hash function is Simple XOR\n");
11983 printf("Unknown hash function\n");
11987 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
11988 idx = i / UINT64_BIT;
11989 offset = i % UINT64_BIT;
11990 if (!(info.info.global_conf.valid_bit_mask[idx] &
11993 str = flowtype_to_str(i);
11996 printf("Symmetric hash is %s globally for flow type %s "
11998 ((info.info.global_conf.sym_hash_enable_mask[idx] &
11999 (1ULL << offset)) ? "enabled" : "disabled"), str,
12004 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
12005 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
12006 get_hash_global_config, "get_hash_global_config");
12007 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
12008 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
12011 cmdline_parse_inst_t cmd_get_hash_global_config = {
12012 .f = cmd_get_hash_global_config_parsed,
12014 .help_str = "get_hash_global_config <port_id>",
12016 (void *)&cmd_get_hash_global_config_all,
12017 (void *)&cmd_get_hash_global_config_port_id,
12022 /* Set global config of hash function */
12023 struct cmd_set_hash_global_config_result {
12024 cmdline_fixed_string_t set_hash_global_config;
12026 cmdline_fixed_string_t hash_func;
12027 cmdline_fixed_string_t flow_type;
12028 cmdline_fixed_string_t enable;
12032 cmd_set_hash_global_config_parsed(void *parsed_result,
12033 __rte_unused struct cmdline *cl,
12034 __rte_unused void *data)
12036 struct cmd_set_hash_global_config_result *res = parsed_result;
12037 struct rte_eth_hash_filter_info info;
12038 uint32_t ftype, idx, offset;
12041 if (rte_eth_dev_filter_supported(res->port_id,
12042 RTE_ETH_FILTER_HASH) < 0) {
12043 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
12047 memset(&info, 0, sizeof(info));
12048 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
12049 if (!strcmp(res->hash_func, "toeplitz"))
12050 info.info.global_conf.hash_func =
12051 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
12052 else if (!strcmp(res->hash_func, "simple_xor"))
12053 info.info.global_conf.hash_func =
12054 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
12055 else if (!strcmp(res->hash_func, "default"))
12056 info.info.global_conf.hash_func =
12057 RTE_ETH_HASH_FUNCTION_DEFAULT;
12059 ftype = str2flowtype(res->flow_type);
12060 idx = ftype / UINT64_BIT;
12061 offset = ftype % UINT64_BIT;
12062 info.info.global_conf.valid_bit_mask[idx] |= (1ULL << offset);
12063 if (!strcmp(res->enable, "enable"))
12064 info.info.global_conf.sym_hash_enable_mask[idx] |=
12066 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12067 RTE_ETH_FILTER_SET, &info);
12069 printf("Cannot set global hash configurations by port %d\n",
12072 printf("Global hash configurations have been set "
12073 "succcessfully by port %d\n", res->port_id);
12076 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
12077 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12078 set_hash_global_config, "set_hash_global_config");
12079 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
12080 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
12082 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
12083 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12084 hash_func, "toeplitz#simple_xor#default");
12085 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
12086 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12088 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
12089 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12090 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
12091 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12092 enable, "enable#disable");
12094 cmdline_parse_inst_t cmd_set_hash_global_config = {
12095 .f = cmd_set_hash_global_config_parsed,
12097 .help_str = "set_hash_global_config <port_id> "
12098 "toeplitz|simple_xor|default "
12099 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12100 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
12101 "l2_payload enable|disable",
12103 (void *)&cmd_set_hash_global_config_all,
12104 (void *)&cmd_set_hash_global_config_port_id,
12105 (void *)&cmd_set_hash_global_config_hash_func,
12106 (void *)&cmd_set_hash_global_config_flow_type,
12107 (void *)&cmd_set_hash_global_config_enable,
12112 /* Set hash input set */
12113 struct cmd_set_hash_input_set_result {
12114 cmdline_fixed_string_t set_hash_input_set;
12116 cmdline_fixed_string_t flow_type;
12117 cmdline_fixed_string_t inset_field;
12118 cmdline_fixed_string_t select;
12121 static enum rte_eth_input_set_field
12122 str2inset(char *string)
12126 static const struct {
12128 enum rte_eth_input_set_field inset;
12129 } inset_table[] = {
12130 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
12131 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
12132 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
12133 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
12134 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
12135 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
12136 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
12137 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
12138 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
12139 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
12140 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
12141 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
12142 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
12143 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
12144 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
12145 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
12146 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
12147 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
12148 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
12149 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
12150 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
12151 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
12152 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
12153 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
12154 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
12155 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
12156 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
12157 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
12158 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
12159 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
12160 {"none", RTE_ETH_INPUT_SET_NONE},
12163 for (i = 0; i < RTE_DIM(inset_table); i++) {
12164 if (!strcmp(string, inset_table[i].str))
12165 return inset_table[i].inset;
12168 return RTE_ETH_INPUT_SET_UNKNOWN;
12172 cmd_set_hash_input_set_parsed(void *parsed_result,
12173 __rte_unused struct cmdline *cl,
12174 __rte_unused void *data)
12176 struct cmd_set_hash_input_set_result *res = parsed_result;
12177 struct rte_eth_hash_filter_info info;
12179 memset(&info, 0, sizeof(info));
12180 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
12181 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12182 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12183 info.info.input_set_conf.inset_size = 1;
12184 if (!strcmp(res->select, "select"))
12185 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12186 else if (!strcmp(res->select, "add"))
12187 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12188 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12189 RTE_ETH_FILTER_SET, &info);
12192 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
12193 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12194 set_hash_input_set, "set_hash_input_set");
12195 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
12196 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
12198 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
12199 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12201 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
12202 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12204 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12205 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
12206 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
12207 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
12208 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
12210 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
12211 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12212 select, "select#add");
12214 cmdline_parse_inst_t cmd_set_hash_input_set = {
12215 .f = cmd_set_hash_input_set_parsed,
12217 .help_str = "set_hash_input_set <port_id> "
12218 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12219 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
12220 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
12221 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
12222 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
12223 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
12224 "fld-7th|fld-8th|none select|add",
12226 (void *)&cmd_set_hash_input_set_cmd,
12227 (void *)&cmd_set_hash_input_set_port_id,
12228 (void *)&cmd_set_hash_input_set_flow_type,
12229 (void *)&cmd_set_hash_input_set_field,
12230 (void *)&cmd_set_hash_input_set_select,
12235 /* Set flow director input set */
12236 struct cmd_set_fdir_input_set_result {
12237 cmdline_fixed_string_t set_fdir_input_set;
12239 cmdline_fixed_string_t flow_type;
12240 cmdline_fixed_string_t inset_field;
12241 cmdline_fixed_string_t select;
12245 cmd_set_fdir_input_set_parsed(void *parsed_result,
12246 __rte_unused struct cmdline *cl,
12247 __rte_unused void *data)
12249 struct cmd_set_fdir_input_set_result *res = parsed_result;
12250 struct rte_eth_fdir_filter_info info;
12252 memset(&info, 0, sizeof(info));
12253 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
12254 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12255 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12256 info.info.input_set_conf.inset_size = 1;
12257 if (!strcmp(res->select, "select"))
12258 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12259 else if (!strcmp(res->select, "add"))
12260 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12261 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
12262 RTE_ETH_FILTER_SET, &info);
12265 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
12266 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12267 set_fdir_input_set, "set_fdir_input_set");
12268 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
12269 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
12271 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
12272 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12274 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
12275 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12276 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
12277 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12279 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12280 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
12281 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
12282 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
12283 "sctp-veri-tag#none");
12284 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
12285 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12286 select, "select#add");
12288 cmdline_parse_inst_t cmd_set_fdir_input_set = {
12289 .f = cmd_set_fdir_input_set_parsed,
12291 .help_str = "set_fdir_input_set <port_id> "
12292 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12293 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
12294 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
12295 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
12296 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
12297 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
12298 "sctp-veri-tag|none select|add",
12300 (void *)&cmd_set_fdir_input_set_cmd,
12301 (void *)&cmd_set_fdir_input_set_port_id,
12302 (void *)&cmd_set_fdir_input_set_flow_type,
12303 (void *)&cmd_set_fdir_input_set_field,
12304 (void *)&cmd_set_fdir_input_set_select,
12309 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
12310 struct cmd_mcast_addr_result {
12311 cmdline_fixed_string_t mcast_addr_cmd;
12312 cmdline_fixed_string_t what;
12314 struct ether_addr mc_addr;
12317 static void cmd_mcast_addr_parsed(void *parsed_result,
12318 __attribute__((unused)) struct cmdline *cl,
12319 __attribute__((unused)) void *data)
12321 struct cmd_mcast_addr_result *res = parsed_result;
12323 if (!is_multicast_ether_addr(&res->mc_addr)) {
12324 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
12325 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
12326 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
12327 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
12330 if (strcmp(res->what, "add") == 0)
12331 mcast_addr_add(res->port_num, &res->mc_addr);
12333 mcast_addr_remove(res->port_num, &res->mc_addr);
12336 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
12337 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
12338 mcast_addr_cmd, "mcast_addr");
12339 cmdline_parse_token_string_t cmd_mcast_addr_what =
12340 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
12342 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
12343 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
12344 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
12345 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
12347 cmdline_parse_inst_t cmd_mcast_addr = {
12348 .f = cmd_mcast_addr_parsed,
12350 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
12351 "Add/Remove multicast MAC address on port_id",
12353 (void *)&cmd_mcast_addr_cmd,
12354 (void *)&cmd_mcast_addr_what,
12355 (void *)&cmd_mcast_addr_portnum,
12356 (void *)&cmd_mcast_addr_addr,
12361 /* l2 tunnel config
12362 * only support E-tag now.
12365 /* Ether type config */
12366 struct cmd_config_l2_tunnel_eth_type_result {
12367 cmdline_fixed_string_t port;
12368 cmdline_fixed_string_t config;
12369 cmdline_fixed_string_t all;
12371 cmdline_fixed_string_t l2_tunnel;
12372 cmdline_fixed_string_t l2_tunnel_type;
12373 cmdline_fixed_string_t eth_type;
12374 uint16_t eth_type_val;
12377 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
12378 TOKEN_STRING_INITIALIZER
12379 (struct cmd_config_l2_tunnel_eth_type_result,
12381 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
12382 TOKEN_STRING_INITIALIZER
12383 (struct cmd_config_l2_tunnel_eth_type_result,
12385 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
12386 TOKEN_STRING_INITIALIZER
12387 (struct cmd_config_l2_tunnel_eth_type_result,
12389 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
12390 TOKEN_NUM_INITIALIZER
12391 (struct cmd_config_l2_tunnel_eth_type_result,
12393 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
12394 TOKEN_STRING_INITIALIZER
12395 (struct cmd_config_l2_tunnel_eth_type_result,
12396 l2_tunnel, "l2-tunnel");
12397 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
12398 TOKEN_STRING_INITIALIZER
12399 (struct cmd_config_l2_tunnel_eth_type_result,
12400 l2_tunnel_type, "E-tag");
12401 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
12402 TOKEN_STRING_INITIALIZER
12403 (struct cmd_config_l2_tunnel_eth_type_result,
12404 eth_type, "ether-type");
12405 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
12406 TOKEN_NUM_INITIALIZER
12407 (struct cmd_config_l2_tunnel_eth_type_result,
12408 eth_type_val, UINT16);
12410 static enum rte_eth_tunnel_type
12411 str2fdir_l2_tunnel_type(char *string)
12415 static const struct {
12417 enum rte_eth_tunnel_type type;
12418 } l2_tunnel_type_str[] = {
12419 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
12422 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
12423 if (!strcmp(l2_tunnel_type_str[i].str, string))
12424 return l2_tunnel_type_str[i].type;
12426 return RTE_TUNNEL_TYPE_NONE;
12429 /* ether type config for all ports */
12431 cmd_config_l2_tunnel_eth_type_all_parsed
12432 (void *parsed_result,
12433 __attribute__((unused)) struct cmdline *cl,
12434 __attribute__((unused)) void *data)
12436 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
12437 struct rte_eth_l2_tunnel_conf entry;
12440 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12441 entry.ether_type = res->eth_type_val;
12443 RTE_ETH_FOREACH_DEV(pid) {
12444 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
12448 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
12449 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
12451 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
12453 (void *)&cmd_config_l2_tunnel_eth_type_port,
12454 (void *)&cmd_config_l2_tunnel_eth_type_config,
12455 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
12456 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12457 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12458 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12459 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12464 /* ether type config for a specific port */
12466 cmd_config_l2_tunnel_eth_type_specific_parsed(
12467 void *parsed_result,
12468 __attribute__((unused)) struct cmdline *cl,
12469 __attribute__((unused)) void *data)
12471 struct cmd_config_l2_tunnel_eth_type_result *res =
12473 struct rte_eth_l2_tunnel_conf entry;
12475 if (port_id_is_invalid(res->id, ENABLED_WARN))
12478 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12479 entry.ether_type = res->eth_type_val;
12481 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
12484 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
12485 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
12487 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
12489 (void *)&cmd_config_l2_tunnel_eth_type_port,
12490 (void *)&cmd_config_l2_tunnel_eth_type_config,
12491 (void *)&cmd_config_l2_tunnel_eth_type_id,
12492 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12493 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12494 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12495 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12500 /* Enable/disable l2 tunnel */
12501 struct cmd_config_l2_tunnel_en_dis_result {
12502 cmdline_fixed_string_t port;
12503 cmdline_fixed_string_t config;
12504 cmdline_fixed_string_t all;
12506 cmdline_fixed_string_t l2_tunnel;
12507 cmdline_fixed_string_t l2_tunnel_type;
12508 cmdline_fixed_string_t en_dis;
12511 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
12512 TOKEN_STRING_INITIALIZER
12513 (struct cmd_config_l2_tunnel_en_dis_result,
12515 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
12516 TOKEN_STRING_INITIALIZER
12517 (struct cmd_config_l2_tunnel_en_dis_result,
12519 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
12520 TOKEN_STRING_INITIALIZER
12521 (struct cmd_config_l2_tunnel_en_dis_result,
12523 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
12524 TOKEN_NUM_INITIALIZER
12525 (struct cmd_config_l2_tunnel_en_dis_result,
12527 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
12528 TOKEN_STRING_INITIALIZER
12529 (struct cmd_config_l2_tunnel_en_dis_result,
12530 l2_tunnel, "l2-tunnel");
12531 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
12532 TOKEN_STRING_INITIALIZER
12533 (struct cmd_config_l2_tunnel_en_dis_result,
12534 l2_tunnel_type, "E-tag");
12535 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
12536 TOKEN_STRING_INITIALIZER
12537 (struct cmd_config_l2_tunnel_en_dis_result,
12538 en_dis, "enable#disable");
12540 /* enable/disable l2 tunnel for all ports */
12542 cmd_config_l2_tunnel_en_dis_all_parsed(
12543 void *parsed_result,
12544 __attribute__((unused)) struct cmdline *cl,
12545 __attribute__((unused)) void *data)
12547 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
12548 struct rte_eth_l2_tunnel_conf entry;
12552 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12554 if (!strcmp("enable", res->en_dis))
12559 RTE_ETH_FOREACH_DEV(pid) {
12560 rte_eth_dev_l2_tunnel_offload_set(pid,
12562 ETH_L2_TUNNEL_ENABLE_MASK,
12567 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
12568 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
12570 .help_str = "port config all l2-tunnel E-tag enable|disable",
12572 (void *)&cmd_config_l2_tunnel_en_dis_port,
12573 (void *)&cmd_config_l2_tunnel_en_dis_config,
12574 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
12575 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12576 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12577 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12582 /* enable/disable l2 tunnel for a port */
12584 cmd_config_l2_tunnel_en_dis_specific_parsed(
12585 void *parsed_result,
12586 __attribute__((unused)) struct cmdline *cl,
12587 __attribute__((unused)) void *data)
12589 struct cmd_config_l2_tunnel_en_dis_result *res =
12591 struct rte_eth_l2_tunnel_conf entry;
12593 if (port_id_is_invalid(res->id, ENABLED_WARN))
12596 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12598 if (!strcmp("enable", res->en_dis))
12599 rte_eth_dev_l2_tunnel_offload_set(res->id,
12601 ETH_L2_TUNNEL_ENABLE_MASK,
12604 rte_eth_dev_l2_tunnel_offload_set(res->id,
12606 ETH_L2_TUNNEL_ENABLE_MASK,
12610 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
12611 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
12613 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
12615 (void *)&cmd_config_l2_tunnel_en_dis_port,
12616 (void *)&cmd_config_l2_tunnel_en_dis_config,
12617 (void *)&cmd_config_l2_tunnel_en_dis_id,
12618 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12619 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12620 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12625 /* E-tag configuration */
12627 /* Common result structure for all E-tag configuration */
12628 struct cmd_config_e_tag_result {
12629 cmdline_fixed_string_t e_tag;
12630 cmdline_fixed_string_t set;
12631 cmdline_fixed_string_t insertion;
12632 cmdline_fixed_string_t stripping;
12633 cmdline_fixed_string_t forwarding;
12634 cmdline_fixed_string_t filter;
12635 cmdline_fixed_string_t add;
12636 cmdline_fixed_string_t del;
12637 cmdline_fixed_string_t on;
12638 cmdline_fixed_string_t off;
12639 cmdline_fixed_string_t on_off;
12640 cmdline_fixed_string_t port_tag_id;
12641 uint32_t port_tag_id_val;
12642 cmdline_fixed_string_t e_tag_id;
12643 uint16_t e_tag_id_val;
12644 cmdline_fixed_string_t dst_pool;
12645 uint8_t dst_pool_val;
12646 cmdline_fixed_string_t port;
12648 cmdline_fixed_string_t vf;
12652 /* Common CLI fields for all E-tag configuration */
12653 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
12654 TOKEN_STRING_INITIALIZER
12655 (struct cmd_config_e_tag_result,
12657 cmdline_parse_token_string_t cmd_config_e_tag_set =
12658 TOKEN_STRING_INITIALIZER
12659 (struct cmd_config_e_tag_result,
12661 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
12662 TOKEN_STRING_INITIALIZER
12663 (struct cmd_config_e_tag_result,
12664 insertion, "insertion");
12665 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
12666 TOKEN_STRING_INITIALIZER
12667 (struct cmd_config_e_tag_result,
12668 stripping, "stripping");
12669 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
12670 TOKEN_STRING_INITIALIZER
12671 (struct cmd_config_e_tag_result,
12672 forwarding, "forwarding");
12673 cmdline_parse_token_string_t cmd_config_e_tag_filter =
12674 TOKEN_STRING_INITIALIZER
12675 (struct cmd_config_e_tag_result,
12677 cmdline_parse_token_string_t cmd_config_e_tag_add =
12678 TOKEN_STRING_INITIALIZER
12679 (struct cmd_config_e_tag_result,
12681 cmdline_parse_token_string_t cmd_config_e_tag_del =
12682 TOKEN_STRING_INITIALIZER
12683 (struct cmd_config_e_tag_result,
12685 cmdline_parse_token_string_t cmd_config_e_tag_on =
12686 TOKEN_STRING_INITIALIZER
12687 (struct cmd_config_e_tag_result,
12689 cmdline_parse_token_string_t cmd_config_e_tag_off =
12690 TOKEN_STRING_INITIALIZER
12691 (struct cmd_config_e_tag_result,
12693 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
12694 TOKEN_STRING_INITIALIZER
12695 (struct cmd_config_e_tag_result,
12697 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
12698 TOKEN_STRING_INITIALIZER
12699 (struct cmd_config_e_tag_result,
12700 port_tag_id, "port-tag-id");
12701 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
12702 TOKEN_NUM_INITIALIZER
12703 (struct cmd_config_e_tag_result,
12704 port_tag_id_val, UINT32);
12705 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
12706 TOKEN_STRING_INITIALIZER
12707 (struct cmd_config_e_tag_result,
12708 e_tag_id, "e-tag-id");
12709 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
12710 TOKEN_NUM_INITIALIZER
12711 (struct cmd_config_e_tag_result,
12712 e_tag_id_val, UINT16);
12713 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
12714 TOKEN_STRING_INITIALIZER
12715 (struct cmd_config_e_tag_result,
12716 dst_pool, "dst-pool");
12717 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
12718 TOKEN_NUM_INITIALIZER
12719 (struct cmd_config_e_tag_result,
12720 dst_pool_val, UINT8);
12721 cmdline_parse_token_string_t cmd_config_e_tag_port =
12722 TOKEN_STRING_INITIALIZER
12723 (struct cmd_config_e_tag_result,
12725 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
12726 TOKEN_NUM_INITIALIZER
12727 (struct cmd_config_e_tag_result,
12729 cmdline_parse_token_string_t cmd_config_e_tag_vf =
12730 TOKEN_STRING_INITIALIZER
12731 (struct cmd_config_e_tag_result,
12733 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
12734 TOKEN_NUM_INITIALIZER
12735 (struct cmd_config_e_tag_result,
12738 /* E-tag insertion configuration */
12740 cmd_config_e_tag_insertion_en_parsed(
12741 void *parsed_result,
12742 __attribute__((unused)) struct cmdline *cl,
12743 __attribute__((unused)) void *data)
12745 struct cmd_config_e_tag_result *res =
12747 struct rte_eth_l2_tunnel_conf entry;
12749 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12752 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12753 entry.tunnel_id = res->port_tag_id_val;
12754 entry.vf_id = res->vf_id;
12755 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12757 ETH_L2_TUNNEL_INSERTION_MASK,
12762 cmd_config_e_tag_insertion_dis_parsed(
12763 void *parsed_result,
12764 __attribute__((unused)) struct cmdline *cl,
12765 __attribute__((unused)) void *data)
12767 struct cmd_config_e_tag_result *res =
12769 struct rte_eth_l2_tunnel_conf entry;
12771 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12774 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12775 entry.vf_id = res->vf_id;
12777 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12779 ETH_L2_TUNNEL_INSERTION_MASK,
12783 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
12784 .f = cmd_config_e_tag_insertion_en_parsed,
12786 .help_str = "E-tag ... : E-tag insertion enable",
12788 (void *)&cmd_config_e_tag_e_tag,
12789 (void *)&cmd_config_e_tag_set,
12790 (void *)&cmd_config_e_tag_insertion,
12791 (void *)&cmd_config_e_tag_on,
12792 (void *)&cmd_config_e_tag_port_tag_id,
12793 (void *)&cmd_config_e_tag_port_tag_id_val,
12794 (void *)&cmd_config_e_tag_port,
12795 (void *)&cmd_config_e_tag_port_id,
12796 (void *)&cmd_config_e_tag_vf,
12797 (void *)&cmd_config_e_tag_vf_id,
12802 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
12803 .f = cmd_config_e_tag_insertion_dis_parsed,
12805 .help_str = "E-tag ... : E-tag insertion disable",
12807 (void *)&cmd_config_e_tag_e_tag,
12808 (void *)&cmd_config_e_tag_set,
12809 (void *)&cmd_config_e_tag_insertion,
12810 (void *)&cmd_config_e_tag_off,
12811 (void *)&cmd_config_e_tag_port,
12812 (void *)&cmd_config_e_tag_port_id,
12813 (void *)&cmd_config_e_tag_vf,
12814 (void *)&cmd_config_e_tag_vf_id,
12819 /* E-tag stripping configuration */
12821 cmd_config_e_tag_stripping_parsed(
12822 void *parsed_result,
12823 __attribute__((unused)) struct cmdline *cl,
12824 __attribute__((unused)) void *data)
12826 struct cmd_config_e_tag_result *res =
12828 struct rte_eth_l2_tunnel_conf entry;
12830 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12833 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12835 if (!strcmp(res->on_off, "on"))
12836 rte_eth_dev_l2_tunnel_offload_set
12839 ETH_L2_TUNNEL_STRIPPING_MASK,
12842 rte_eth_dev_l2_tunnel_offload_set
12845 ETH_L2_TUNNEL_STRIPPING_MASK,
12849 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
12850 .f = cmd_config_e_tag_stripping_parsed,
12852 .help_str = "E-tag ... : E-tag stripping enable/disable",
12854 (void *)&cmd_config_e_tag_e_tag,
12855 (void *)&cmd_config_e_tag_set,
12856 (void *)&cmd_config_e_tag_stripping,
12857 (void *)&cmd_config_e_tag_on_off,
12858 (void *)&cmd_config_e_tag_port,
12859 (void *)&cmd_config_e_tag_port_id,
12864 /* E-tag forwarding configuration */
12866 cmd_config_e_tag_forwarding_parsed(
12867 void *parsed_result,
12868 __attribute__((unused)) struct cmdline *cl,
12869 __attribute__((unused)) void *data)
12871 struct cmd_config_e_tag_result *res = parsed_result;
12872 struct rte_eth_l2_tunnel_conf entry;
12874 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12877 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12879 if (!strcmp(res->on_off, "on"))
12880 rte_eth_dev_l2_tunnel_offload_set
12883 ETH_L2_TUNNEL_FORWARDING_MASK,
12886 rte_eth_dev_l2_tunnel_offload_set
12889 ETH_L2_TUNNEL_FORWARDING_MASK,
12893 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
12894 .f = cmd_config_e_tag_forwarding_parsed,
12896 .help_str = "E-tag ... : E-tag forwarding enable/disable",
12898 (void *)&cmd_config_e_tag_e_tag,
12899 (void *)&cmd_config_e_tag_set,
12900 (void *)&cmd_config_e_tag_forwarding,
12901 (void *)&cmd_config_e_tag_on_off,
12902 (void *)&cmd_config_e_tag_port,
12903 (void *)&cmd_config_e_tag_port_id,
12908 /* E-tag filter configuration */
12910 cmd_config_e_tag_filter_add_parsed(
12911 void *parsed_result,
12912 __attribute__((unused)) struct cmdline *cl,
12913 __attribute__((unused)) void *data)
12915 struct cmd_config_e_tag_result *res = parsed_result;
12916 struct rte_eth_l2_tunnel_conf entry;
12919 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12922 if (res->e_tag_id_val > 0x3fff) {
12923 printf("e-tag-id must be equal or less than 0x3fff.\n");
12927 ret = rte_eth_dev_filter_supported(res->port_id,
12928 RTE_ETH_FILTER_L2_TUNNEL);
12930 printf("E-tag filter is not supported on port %u.\n",
12935 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12936 entry.tunnel_id = res->e_tag_id_val;
12937 entry.pool = res->dst_pool_val;
12939 ret = rte_eth_dev_filter_ctrl(res->port_id,
12940 RTE_ETH_FILTER_L2_TUNNEL,
12941 RTE_ETH_FILTER_ADD,
12944 printf("E-tag filter programming error: (%s)\n",
12948 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
12949 .f = cmd_config_e_tag_filter_add_parsed,
12951 .help_str = "E-tag ... : E-tag filter add",
12953 (void *)&cmd_config_e_tag_e_tag,
12954 (void *)&cmd_config_e_tag_set,
12955 (void *)&cmd_config_e_tag_filter,
12956 (void *)&cmd_config_e_tag_add,
12957 (void *)&cmd_config_e_tag_e_tag_id,
12958 (void *)&cmd_config_e_tag_e_tag_id_val,
12959 (void *)&cmd_config_e_tag_dst_pool,
12960 (void *)&cmd_config_e_tag_dst_pool_val,
12961 (void *)&cmd_config_e_tag_port,
12962 (void *)&cmd_config_e_tag_port_id,
12968 cmd_config_e_tag_filter_del_parsed(
12969 void *parsed_result,
12970 __attribute__((unused)) struct cmdline *cl,
12971 __attribute__((unused)) void *data)
12973 struct cmd_config_e_tag_result *res = parsed_result;
12974 struct rte_eth_l2_tunnel_conf entry;
12977 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12980 if (res->e_tag_id_val > 0x3fff) {
12981 printf("e-tag-id must be less than 0x3fff.\n");
12985 ret = rte_eth_dev_filter_supported(res->port_id,
12986 RTE_ETH_FILTER_L2_TUNNEL);
12988 printf("E-tag filter is not supported on port %u.\n",
12993 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12994 entry.tunnel_id = res->e_tag_id_val;
12996 ret = rte_eth_dev_filter_ctrl(res->port_id,
12997 RTE_ETH_FILTER_L2_TUNNEL,
12998 RTE_ETH_FILTER_DELETE,
13001 printf("E-tag filter programming error: (%s)\n",
13005 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
13006 .f = cmd_config_e_tag_filter_del_parsed,
13008 .help_str = "E-tag ... : E-tag filter delete",
13010 (void *)&cmd_config_e_tag_e_tag,
13011 (void *)&cmd_config_e_tag_set,
13012 (void *)&cmd_config_e_tag_filter,
13013 (void *)&cmd_config_e_tag_del,
13014 (void *)&cmd_config_e_tag_e_tag_id,
13015 (void *)&cmd_config_e_tag_e_tag_id_val,
13016 (void *)&cmd_config_e_tag_port,
13017 (void *)&cmd_config_e_tag_port_id,
13022 /* vf vlan anti spoof configuration */
13024 /* Common result structure for vf vlan anti spoof */
13025 struct cmd_vf_vlan_anti_spoof_result {
13026 cmdline_fixed_string_t set;
13027 cmdline_fixed_string_t vf;
13028 cmdline_fixed_string_t vlan;
13029 cmdline_fixed_string_t antispoof;
13032 cmdline_fixed_string_t on_off;
13035 /* Common CLI fields for vf vlan anti spoof enable disable */
13036 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
13037 TOKEN_STRING_INITIALIZER
13038 (struct cmd_vf_vlan_anti_spoof_result,
13040 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
13041 TOKEN_STRING_INITIALIZER
13042 (struct cmd_vf_vlan_anti_spoof_result,
13044 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
13045 TOKEN_STRING_INITIALIZER
13046 (struct cmd_vf_vlan_anti_spoof_result,
13048 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
13049 TOKEN_STRING_INITIALIZER
13050 (struct cmd_vf_vlan_anti_spoof_result,
13051 antispoof, "antispoof");
13052 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
13053 TOKEN_NUM_INITIALIZER
13054 (struct cmd_vf_vlan_anti_spoof_result,
13056 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
13057 TOKEN_NUM_INITIALIZER
13058 (struct cmd_vf_vlan_anti_spoof_result,
13060 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
13061 TOKEN_STRING_INITIALIZER
13062 (struct cmd_vf_vlan_anti_spoof_result,
13066 cmd_set_vf_vlan_anti_spoof_parsed(
13067 void *parsed_result,
13068 __attribute__((unused)) struct cmdline *cl,
13069 __attribute__((unused)) void *data)
13071 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
13072 int ret = -ENOTSUP;
13074 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13076 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13079 #ifdef RTE_LIBRTE_IXGBE_PMD
13080 if (ret == -ENOTSUP)
13081 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
13082 res->vf_id, is_on);
13084 #ifdef RTE_LIBRTE_I40E_PMD
13085 if (ret == -ENOTSUP)
13086 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
13087 res->vf_id, is_on);
13089 #ifdef RTE_LIBRTE_BNXT_PMD
13090 if (ret == -ENOTSUP)
13091 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
13092 res->vf_id, is_on);
13099 printf("invalid vf_id %d\n", res->vf_id);
13102 printf("invalid port_id %d\n", res->port_id);
13105 printf("function not implemented\n");
13108 printf("programming error: (%s)\n", strerror(-ret));
13112 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
13113 .f = cmd_set_vf_vlan_anti_spoof_parsed,
13115 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
13117 (void *)&cmd_vf_vlan_anti_spoof_set,
13118 (void *)&cmd_vf_vlan_anti_spoof_vf,
13119 (void *)&cmd_vf_vlan_anti_spoof_vlan,
13120 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
13121 (void *)&cmd_vf_vlan_anti_spoof_port_id,
13122 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
13123 (void *)&cmd_vf_vlan_anti_spoof_on_off,
13128 /* vf mac anti spoof configuration */
13130 /* Common result structure for vf mac anti spoof */
13131 struct cmd_vf_mac_anti_spoof_result {
13132 cmdline_fixed_string_t set;
13133 cmdline_fixed_string_t vf;
13134 cmdline_fixed_string_t mac;
13135 cmdline_fixed_string_t antispoof;
13138 cmdline_fixed_string_t on_off;
13141 /* Common CLI fields for vf mac anti spoof enable disable */
13142 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
13143 TOKEN_STRING_INITIALIZER
13144 (struct cmd_vf_mac_anti_spoof_result,
13146 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
13147 TOKEN_STRING_INITIALIZER
13148 (struct cmd_vf_mac_anti_spoof_result,
13150 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
13151 TOKEN_STRING_INITIALIZER
13152 (struct cmd_vf_mac_anti_spoof_result,
13154 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
13155 TOKEN_STRING_INITIALIZER
13156 (struct cmd_vf_mac_anti_spoof_result,
13157 antispoof, "antispoof");
13158 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
13159 TOKEN_NUM_INITIALIZER
13160 (struct cmd_vf_mac_anti_spoof_result,
13162 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
13163 TOKEN_NUM_INITIALIZER
13164 (struct cmd_vf_mac_anti_spoof_result,
13166 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
13167 TOKEN_STRING_INITIALIZER
13168 (struct cmd_vf_mac_anti_spoof_result,
13172 cmd_set_vf_mac_anti_spoof_parsed(
13173 void *parsed_result,
13174 __attribute__((unused)) struct cmdline *cl,
13175 __attribute__((unused)) void *data)
13177 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
13178 int ret = -ENOTSUP;
13180 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13182 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13185 #ifdef RTE_LIBRTE_IXGBE_PMD
13186 if (ret == -ENOTSUP)
13187 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
13188 res->vf_id, is_on);
13190 #ifdef RTE_LIBRTE_I40E_PMD
13191 if (ret == -ENOTSUP)
13192 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
13193 res->vf_id, is_on);
13195 #ifdef RTE_LIBRTE_BNXT_PMD
13196 if (ret == -ENOTSUP)
13197 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
13198 res->vf_id, is_on);
13205 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13208 printf("invalid port_id %d\n", res->port_id);
13211 printf("function not implemented\n");
13214 printf("programming error: (%s)\n", strerror(-ret));
13218 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
13219 .f = cmd_set_vf_mac_anti_spoof_parsed,
13221 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
13223 (void *)&cmd_vf_mac_anti_spoof_set,
13224 (void *)&cmd_vf_mac_anti_spoof_vf,
13225 (void *)&cmd_vf_mac_anti_spoof_mac,
13226 (void *)&cmd_vf_mac_anti_spoof_antispoof,
13227 (void *)&cmd_vf_mac_anti_spoof_port_id,
13228 (void *)&cmd_vf_mac_anti_spoof_vf_id,
13229 (void *)&cmd_vf_mac_anti_spoof_on_off,
13234 /* vf vlan strip queue configuration */
13236 /* Common result structure for vf mac anti spoof */
13237 struct cmd_vf_vlan_stripq_result {
13238 cmdline_fixed_string_t set;
13239 cmdline_fixed_string_t vf;
13240 cmdline_fixed_string_t vlan;
13241 cmdline_fixed_string_t stripq;
13244 cmdline_fixed_string_t on_off;
13247 /* Common CLI fields for vf vlan strip enable disable */
13248 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
13249 TOKEN_STRING_INITIALIZER
13250 (struct cmd_vf_vlan_stripq_result,
13252 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
13253 TOKEN_STRING_INITIALIZER
13254 (struct cmd_vf_vlan_stripq_result,
13256 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
13257 TOKEN_STRING_INITIALIZER
13258 (struct cmd_vf_vlan_stripq_result,
13260 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
13261 TOKEN_STRING_INITIALIZER
13262 (struct cmd_vf_vlan_stripq_result,
13264 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
13265 TOKEN_NUM_INITIALIZER
13266 (struct cmd_vf_vlan_stripq_result,
13268 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
13269 TOKEN_NUM_INITIALIZER
13270 (struct cmd_vf_vlan_stripq_result,
13272 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
13273 TOKEN_STRING_INITIALIZER
13274 (struct cmd_vf_vlan_stripq_result,
13278 cmd_set_vf_vlan_stripq_parsed(
13279 void *parsed_result,
13280 __attribute__((unused)) struct cmdline *cl,
13281 __attribute__((unused)) void *data)
13283 struct cmd_vf_vlan_stripq_result *res = parsed_result;
13284 int ret = -ENOTSUP;
13286 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13288 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13291 #ifdef RTE_LIBRTE_IXGBE_PMD
13292 if (ret == -ENOTSUP)
13293 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
13294 res->vf_id, is_on);
13296 #ifdef RTE_LIBRTE_I40E_PMD
13297 if (ret == -ENOTSUP)
13298 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
13299 res->vf_id, is_on);
13301 #ifdef RTE_LIBRTE_BNXT_PMD
13302 if (ret == -ENOTSUP)
13303 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
13304 res->vf_id, is_on);
13311 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13314 printf("invalid port_id %d\n", res->port_id);
13317 printf("function not implemented\n");
13320 printf("programming error: (%s)\n", strerror(-ret));
13324 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
13325 .f = cmd_set_vf_vlan_stripq_parsed,
13327 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
13329 (void *)&cmd_vf_vlan_stripq_set,
13330 (void *)&cmd_vf_vlan_stripq_vf,
13331 (void *)&cmd_vf_vlan_stripq_vlan,
13332 (void *)&cmd_vf_vlan_stripq_stripq,
13333 (void *)&cmd_vf_vlan_stripq_port_id,
13334 (void *)&cmd_vf_vlan_stripq_vf_id,
13335 (void *)&cmd_vf_vlan_stripq_on_off,
13340 /* vf vlan insert configuration */
13342 /* Common result structure for vf vlan insert */
13343 struct cmd_vf_vlan_insert_result {
13344 cmdline_fixed_string_t set;
13345 cmdline_fixed_string_t vf;
13346 cmdline_fixed_string_t vlan;
13347 cmdline_fixed_string_t insert;
13353 /* Common CLI fields for vf vlan insert enable disable */
13354 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
13355 TOKEN_STRING_INITIALIZER
13356 (struct cmd_vf_vlan_insert_result,
13358 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
13359 TOKEN_STRING_INITIALIZER
13360 (struct cmd_vf_vlan_insert_result,
13362 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
13363 TOKEN_STRING_INITIALIZER
13364 (struct cmd_vf_vlan_insert_result,
13366 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
13367 TOKEN_STRING_INITIALIZER
13368 (struct cmd_vf_vlan_insert_result,
13370 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
13371 TOKEN_NUM_INITIALIZER
13372 (struct cmd_vf_vlan_insert_result,
13374 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
13375 TOKEN_NUM_INITIALIZER
13376 (struct cmd_vf_vlan_insert_result,
13378 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
13379 TOKEN_NUM_INITIALIZER
13380 (struct cmd_vf_vlan_insert_result,
13384 cmd_set_vf_vlan_insert_parsed(
13385 void *parsed_result,
13386 __attribute__((unused)) struct cmdline *cl,
13387 __attribute__((unused)) void *data)
13389 struct cmd_vf_vlan_insert_result *res = parsed_result;
13390 int ret = -ENOTSUP;
13392 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13395 #ifdef RTE_LIBRTE_IXGBE_PMD
13396 if (ret == -ENOTSUP)
13397 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
13400 #ifdef RTE_LIBRTE_I40E_PMD
13401 if (ret == -ENOTSUP)
13402 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
13405 #ifdef RTE_LIBRTE_BNXT_PMD
13406 if (ret == -ENOTSUP)
13407 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
13415 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
13418 printf("invalid port_id %d\n", res->port_id);
13421 printf("function not implemented\n");
13424 printf("programming error: (%s)\n", strerror(-ret));
13428 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
13429 .f = cmd_set_vf_vlan_insert_parsed,
13431 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
13433 (void *)&cmd_vf_vlan_insert_set,
13434 (void *)&cmd_vf_vlan_insert_vf,
13435 (void *)&cmd_vf_vlan_insert_vlan,
13436 (void *)&cmd_vf_vlan_insert_insert,
13437 (void *)&cmd_vf_vlan_insert_port_id,
13438 (void *)&cmd_vf_vlan_insert_vf_id,
13439 (void *)&cmd_vf_vlan_insert_vlan_id,
13444 /* tx loopback configuration */
13446 /* Common result structure for tx loopback */
13447 struct cmd_tx_loopback_result {
13448 cmdline_fixed_string_t set;
13449 cmdline_fixed_string_t tx;
13450 cmdline_fixed_string_t loopback;
13452 cmdline_fixed_string_t on_off;
13455 /* Common CLI fields for tx loopback enable disable */
13456 cmdline_parse_token_string_t cmd_tx_loopback_set =
13457 TOKEN_STRING_INITIALIZER
13458 (struct cmd_tx_loopback_result,
13460 cmdline_parse_token_string_t cmd_tx_loopback_tx =
13461 TOKEN_STRING_INITIALIZER
13462 (struct cmd_tx_loopback_result,
13464 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
13465 TOKEN_STRING_INITIALIZER
13466 (struct cmd_tx_loopback_result,
13467 loopback, "loopback");
13468 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
13469 TOKEN_NUM_INITIALIZER
13470 (struct cmd_tx_loopback_result,
13472 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
13473 TOKEN_STRING_INITIALIZER
13474 (struct cmd_tx_loopback_result,
13478 cmd_set_tx_loopback_parsed(
13479 void *parsed_result,
13480 __attribute__((unused)) struct cmdline *cl,
13481 __attribute__((unused)) void *data)
13483 struct cmd_tx_loopback_result *res = parsed_result;
13484 int ret = -ENOTSUP;
13486 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13488 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13491 #ifdef RTE_LIBRTE_IXGBE_PMD
13492 if (ret == -ENOTSUP)
13493 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
13495 #ifdef RTE_LIBRTE_I40E_PMD
13496 if (ret == -ENOTSUP)
13497 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
13499 #ifdef RTE_LIBRTE_BNXT_PMD
13500 if (ret == -ENOTSUP)
13501 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
13503 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD
13504 if (ret == -ENOTSUP)
13505 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
13512 printf("invalid is_on %d\n", is_on);
13515 printf("invalid port_id %d\n", res->port_id);
13518 printf("function not implemented\n");
13521 printf("programming error: (%s)\n", strerror(-ret));
13525 cmdline_parse_inst_t cmd_set_tx_loopback = {
13526 .f = cmd_set_tx_loopback_parsed,
13528 .help_str = "set tx loopback <port_id> on|off",
13530 (void *)&cmd_tx_loopback_set,
13531 (void *)&cmd_tx_loopback_tx,
13532 (void *)&cmd_tx_loopback_loopback,
13533 (void *)&cmd_tx_loopback_port_id,
13534 (void *)&cmd_tx_loopback_on_off,
13539 /* all queues drop enable configuration */
13541 /* Common result structure for all queues drop enable */
13542 struct cmd_all_queues_drop_en_result {
13543 cmdline_fixed_string_t set;
13544 cmdline_fixed_string_t all;
13545 cmdline_fixed_string_t queues;
13546 cmdline_fixed_string_t drop;
13548 cmdline_fixed_string_t on_off;
13551 /* Common CLI fields for tx loopback enable disable */
13552 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
13553 TOKEN_STRING_INITIALIZER
13554 (struct cmd_all_queues_drop_en_result,
13556 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
13557 TOKEN_STRING_INITIALIZER
13558 (struct cmd_all_queues_drop_en_result,
13560 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
13561 TOKEN_STRING_INITIALIZER
13562 (struct cmd_all_queues_drop_en_result,
13564 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
13565 TOKEN_STRING_INITIALIZER
13566 (struct cmd_all_queues_drop_en_result,
13568 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
13569 TOKEN_NUM_INITIALIZER
13570 (struct cmd_all_queues_drop_en_result,
13572 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
13573 TOKEN_STRING_INITIALIZER
13574 (struct cmd_all_queues_drop_en_result,
13578 cmd_set_all_queues_drop_en_parsed(
13579 void *parsed_result,
13580 __attribute__((unused)) struct cmdline *cl,
13581 __attribute__((unused)) void *data)
13583 struct cmd_all_queues_drop_en_result *res = parsed_result;
13584 int ret = -ENOTSUP;
13585 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13587 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13590 #ifdef RTE_LIBRTE_IXGBE_PMD
13591 if (ret == -ENOTSUP)
13592 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
13594 #ifdef RTE_LIBRTE_BNXT_PMD
13595 if (ret == -ENOTSUP)
13596 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
13602 printf("invalid is_on %d\n", is_on);
13605 printf("invalid port_id %d\n", res->port_id);
13608 printf("function not implemented\n");
13611 printf("programming error: (%s)\n", strerror(-ret));
13615 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
13616 .f = cmd_set_all_queues_drop_en_parsed,
13618 .help_str = "set all queues drop <port_id> on|off",
13620 (void *)&cmd_all_queues_drop_en_set,
13621 (void *)&cmd_all_queues_drop_en_all,
13622 (void *)&cmd_all_queues_drop_en_queues,
13623 (void *)&cmd_all_queues_drop_en_drop,
13624 (void *)&cmd_all_queues_drop_en_port_id,
13625 (void *)&cmd_all_queues_drop_en_on_off,
13630 /* vf split drop enable configuration */
13632 /* Common result structure for vf split drop enable */
13633 struct cmd_vf_split_drop_en_result {
13634 cmdline_fixed_string_t set;
13635 cmdline_fixed_string_t vf;
13636 cmdline_fixed_string_t split;
13637 cmdline_fixed_string_t drop;
13640 cmdline_fixed_string_t on_off;
13643 /* Common CLI fields for vf split drop enable disable */
13644 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
13645 TOKEN_STRING_INITIALIZER
13646 (struct cmd_vf_split_drop_en_result,
13648 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
13649 TOKEN_STRING_INITIALIZER
13650 (struct cmd_vf_split_drop_en_result,
13652 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
13653 TOKEN_STRING_INITIALIZER
13654 (struct cmd_vf_split_drop_en_result,
13656 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
13657 TOKEN_STRING_INITIALIZER
13658 (struct cmd_vf_split_drop_en_result,
13660 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
13661 TOKEN_NUM_INITIALIZER
13662 (struct cmd_vf_split_drop_en_result,
13664 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
13665 TOKEN_NUM_INITIALIZER
13666 (struct cmd_vf_split_drop_en_result,
13668 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
13669 TOKEN_STRING_INITIALIZER
13670 (struct cmd_vf_split_drop_en_result,
13674 cmd_set_vf_split_drop_en_parsed(
13675 void *parsed_result,
13676 __attribute__((unused)) struct cmdline *cl,
13677 __attribute__((unused)) void *data)
13679 struct cmd_vf_split_drop_en_result *res = parsed_result;
13680 int ret = -ENOTSUP;
13681 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13683 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13686 #ifdef RTE_LIBRTE_IXGBE_PMD
13687 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
13694 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13697 printf("invalid port_id %d\n", res->port_id);
13700 printf("not supported on port %d\n", res->port_id);
13703 printf("programming error: (%s)\n", strerror(-ret));
13707 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
13708 .f = cmd_set_vf_split_drop_en_parsed,
13710 .help_str = "set vf split drop <port_id> <vf_id> on|off",
13712 (void *)&cmd_vf_split_drop_en_set,
13713 (void *)&cmd_vf_split_drop_en_vf,
13714 (void *)&cmd_vf_split_drop_en_split,
13715 (void *)&cmd_vf_split_drop_en_drop,
13716 (void *)&cmd_vf_split_drop_en_port_id,
13717 (void *)&cmd_vf_split_drop_en_vf_id,
13718 (void *)&cmd_vf_split_drop_en_on_off,
13723 /* vf mac address configuration */
13725 /* Common result structure for vf mac address */
13726 struct cmd_set_vf_mac_addr_result {
13727 cmdline_fixed_string_t set;
13728 cmdline_fixed_string_t vf;
13729 cmdline_fixed_string_t mac;
13730 cmdline_fixed_string_t addr;
13733 struct ether_addr mac_addr;
13737 /* Common CLI fields for vf split drop enable disable */
13738 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
13739 TOKEN_STRING_INITIALIZER
13740 (struct cmd_set_vf_mac_addr_result,
13742 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
13743 TOKEN_STRING_INITIALIZER
13744 (struct cmd_set_vf_mac_addr_result,
13746 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
13747 TOKEN_STRING_INITIALIZER
13748 (struct cmd_set_vf_mac_addr_result,
13750 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
13751 TOKEN_STRING_INITIALIZER
13752 (struct cmd_set_vf_mac_addr_result,
13754 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
13755 TOKEN_NUM_INITIALIZER
13756 (struct cmd_set_vf_mac_addr_result,
13758 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
13759 TOKEN_NUM_INITIALIZER
13760 (struct cmd_set_vf_mac_addr_result,
13762 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
13763 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
13767 cmd_set_vf_mac_addr_parsed(
13768 void *parsed_result,
13769 __attribute__((unused)) struct cmdline *cl,
13770 __attribute__((unused)) void *data)
13772 struct cmd_set_vf_mac_addr_result *res = parsed_result;
13773 int ret = -ENOTSUP;
13775 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13778 #ifdef RTE_LIBRTE_IXGBE_PMD
13779 if (ret == -ENOTSUP)
13780 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
13783 #ifdef RTE_LIBRTE_I40E_PMD
13784 if (ret == -ENOTSUP)
13785 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
13788 #ifdef RTE_LIBRTE_BNXT_PMD
13789 if (ret == -ENOTSUP)
13790 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
13798 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
13801 printf("invalid port_id %d\n", res->port_id);
13804 printf("function not implemented\n");
13807 printf("programming error: (%s)\n", strerror(-ret));
13811 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
13812 .f = cmd_set_vf_mac_addr_parsed,
13814 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
13816 (void *)&cmd_set_vf_mac_addr_set,
13817 (void *)&cmd_set_vf_mac_addr_vf,
13818 (void *)&cmd_set_vf_mac_addr_mac,
13819 (void *)&cmd_set_vf_mac_addr_addr,
13820 (void *)&cmd_set_vf_mac_addr_port_id,
13821 (void *)&cmd_set_vf_mac_addr_vf_id,
13822 (void *)&cmd_set_vf_mac_addr_mac_addr,
13827 /* MACsec configuration */
13829 /* Common result structure for MACsec offload enable */
13830 struct cmd_macsec_offload_on_result {
13831 cmdline_fixed_string_t set;
13832 cmdline_fixed_string_t macsec;
13833 cmdline_fixed_string_t offload;
13835 cmdline_fixed_string_t on;
13836 cmdline_fixed_string_t encrypt;
13837 cmdline_fixed_string_t en_on_off;
13838 cmdline_fixed_string_t replay_protect;
13839 cmdline_fixed_string_t rp_on_off;
13842 /* Common CLI fields for MACsec offload disable */
13843 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
13844 TOKEN_STRING_INITIALIZER
13845 (struct cmd_macsec_offload_on_result,
13847 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
13848 TOKEN_STRING_INITIALIZER
13849 (struct cmd_macsec_offload_on_result,
13851 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
13852 TOKEN_STRING_INITIALIZER
13853 (struct cmd_macsec_offload_on_result,
13854 offload, "offload");
13855 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
13856 TOKEN_NUM_INITIALIZER
13857 (struct cmd_macsec_offload_on_result,
13859 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
13860 TOKEN_STRING_INITIALIZER
13861 (struct cmd_macsec_offload_on_result,
13863 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
13864 TOKEN_STRING_INITIALIZER
13865 (struct cmd_macsec_offload_on_result,
13866 encrypt, "encrypt");
13867 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
13868 TOKEN_STRING_INITIALIZER
13869 (struct cmd_macsec_offload_on_result,
13870 en_on_off, "on#off");
13871 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
13872 TOKEN_STRING_INITIALIZER
13873 (struct cmd_macsec_offload_on_result,
13874 replay_protect, "replay-protect");
13875 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
13876 TOKEN_STRING_INITIALIZER
13877 (struct cmd_macsec_offload_on_result,
13878 rp_on_off, "on#off");
13881 cmd_set_macsec_offload_on_parsed(
13882 void *parsed_result,
13883 __attribute__((unused)) struct cmdline *cl,
13884 __attribute__((unused)) void *data)
13886 struct cmd_macsec_offload_on_result *res = parsed_result;
13887 int ret = -ENOTSUP;
13888 portid_t port_id = res->port_id;
13889 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
13890 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
13891 struct rte_eth_dev_info dev_info;
13893 if (port_id_is_invalid(port_id, ENABLED_WARN))
13895 if (!port_is_stopped(port_id)) {
13896 printf("Please stop port %d first\n", port_id);
13900 rte_eth_dev_info_get(port_id, &dev_info);
13901 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
13902 #ifdef RTE_LIBRTE_IXGBE_PMD
13903 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
13911 ports[port_id].dev_conf.txmode.offloads |=
13912 DEV_TX_OFFLOAD_MACSEC_INSERT;
13913 cmd_reconfig_device_queue(port_id, 1, 1);
13916 printf("invalid port_id %d\n", port_id);
13919 printf("not supported on port %d\n", port_id);
13922 printf("programming error: (%s)\n", strerror(-ret));
13926 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
13927 .f = cmd_set_macsec_offload_on_parsed,
13929 .help_str = "set macsec offload <port_id> on "
13930 "encrypt on|off replay-protect on|off",
13932 (void *)&cmd_macsec_offload_on_set,
13933 (void *)&cmd_macsec_offload_on_macsec,
13934 (void *)&cmd_macsec_offload_on_offload,
13935 (void *)&cmd_macsec_offload_on_port_id,
13936 (void *)&cmd_macsec_offload_on_on,
13937 (void *)&cmd_macsec_offload_on_encrypt,
13938 (void *)&cmd_macsec_offload_on_en_on_off,
13939 (void *)&cmd_macsec_offload_on_replay_protect,
13940 (void *)&cmd_macsec_offload_on_rp_on_off,
13945 /* Common result structure for MACsec offload disable */
13946 struct cmd_macsec_offload_off_result {
13947 cmdline_fixed_string_t set;
13948 cmdline_fixed_string_t macsec;
13949 cmdline_fixed_string_t offload;
13951 cmdline_fixed_string_t off;
13954 /* Common CLI fields for MACsec offload disable */
13955 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
13956 TOKEN_STRING_INITIALIZER
13957 (struct cmd_macsec_offload_off_result,
13959 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
13960 TOKEN_STRING_INITIALIZER
13961 (struct cmd_macsec_offload_off_result,
13963 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
13964 TOKEN_STRING_INITIALIZER
13965 (struct cmd_macsec_offload_off_result,
13966 offload, "offload");
13967 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
13968 TOKEN_NUM_INITIALIZER
13969 (struct cmd_macsec_offload_off_result,
13971 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
13972 TOKEN_STRING_INITIALIZER
13973 (struct cmd_macsec_offload_off_result,
13977 cmd_set_macsec_offload_off_parsed(
13978 void *parsed_result,
13979 __attribute__((unused)) struct cmdline *cl,
13980 __attribute__((unused)) void *data)
13982 struct cmd_macsec_offload_off_result *res = parsed_result;
13983 int ret = -ENOTSUP;
13984 struct rte_eth_dev_info dev_info;
13985 portid_t port_id = res->port_id;
13987 if (port_id_is_invalid(port_id, ENABLED_WARN))
13989 if (!port_is_stopped(port_id)) {
13990 printf("Please stop port %d first\n", port_id);
13994 rte_eth_dev_info_get(port_id, &dev_info);
13995 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
13996 #ifdef RTE_LIBRTE_IXGBE_PMD
13997 ret = rte_pmd_ixgbe_macsec_disable(port_id);
14002 ports[port_id].dev_conf.txmode.offloads &=
14003 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
14004 cmd_reconfig_device_queue(port_id, 1, 1);
14007 printf("invalid port_id %d\n", port_id);
14010 printf("not supported on port %d\n", port_id);
14013 printf("programming error: (%s)\n", strerror(-ret));
14017 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
14018 .f = cmd_set_macsec_offload_off_parsed,
14020 .help_str = "set macsec offload <port_id> off",
14022 (void *)&cmd_macsec_offload_off_set,
14023 (void *)&cmd_macsec_offload_off_macsec,
14024 (void *)&cmd_macsec_offload_off_offload,
14025 (void *)&cmd_macsec_offload_off_port_id,
14026 (void *)&cmd_macsec_offload_off_off,
14031 /* Common result structure for MACsec secure connection configure */
14032 struct cmd_macsec_sc_result {
14033 cmdline_fixed_string_t set;
14034 cmdline_fixed_string_t macsec;
14035 cmdline_fixed_string_t sc;
14036 cmdline_fixed_string_t tx_rx;
14038 struct ether_addr mac;
14042 /* Common CLI fields for MACsec secure connection configure */
14043 cmdline_parse_token_string_t cmd_macsec_sc_set =
14044 TOKEN_STRING_INITIALIZER
14045 (struct cmd_macsec_sc_result,
14047 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
14048 TOKEN_STRING_INITIALIZER
14049 (struct cmd_macsec_sc_result,
14051 cmdline_parse_token_string_t cmd_macsec_sc_sc =
14052 TOKEN_STRING_INITIALIZER
14053 (struct cmd_macsec_sc_result,
14055 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
14056 TOKEN_STRING_INITIALIZER
14057 (struct cmd_macsec_sc_result,
14059 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
14060 TOKEN_NUM_INITIALIZER
14061 (struct cmd_macsec_sc_result,
14063 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
14064 TOKEN_ETHERADDR_INITIALIZER
14065 (struct cmd_macsec_sc_result,
14067 cmdline_parse_token_num_t cmd_macsec_sc_pi =
14068 TOKEN_NUM_INITIALIZER
14069 (struct cmd_macsec_sc_result,
14073 cmd_set_macsec_sc_parsed(
14074 void *parsed_result,
14075 __attribute__((unused)) struct cmdline *cl,
14076 __attribute__((unused)) void *data)
14078 struct cmd_macsec_sc_result *res = parsed_result;
14079 int ret = -ENOTSUP;
14080 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14082 #ifdef RTE_LIBRTE_IXGBE_PMD
14084 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
14085 res->mac.addr_bytes) :
14086 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
14087 res->mac.addr_bytes, res->pi);
14089 RTE_SET_USED(is_tx);
14095 printf("invalid port_id %d\n", res->port_id);
14098 printf("not supported on port %d\n", res->port_id);
14101 printf("programming error: (%s)\n", strerror(-ret));
14105 cmdline_parse_inst_t cmd_set_macsec_sc = {
14106 .f = cmd_set_macsec_sc_parsed,
14108 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
14110 (void *)&cmd_macsec_sc_set,
14111 (void *)&cmd_macsec_sc_macsec,
14112 (void *)&cmd_macsec_sc_sc,
14113 (void *)&cmd_macsec_sc_tx_rx,
14114 (void *)&cmd_macsec_sc_port_id,
14115 (void *)&cmd_macsec_sc_mac,
14116 (void *)&cmd_macsec_sc_pi,
14121 /* Common result structure for MACsec secure connection configure */
14122 struct cmd_macsec_sa_result {
14123 cmdline_fixed_string_t set;
14124 cmdline_fixed_string_t macsec;
14125 cmdline_fixed_string_t sa;
14126 cmdline_fixed_string_t tx_rx;
14131 cmdline_fixed_string_t key;
14134 /* Common CLI fields for MACsec secure connection configure */
14135 cmdline_parse_token_string_t cmd_macsec_sa_set =
14136 TOKEN_STRING_INITIALIZER
14137 (struct cmd_macsec_sa_result,
14139 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
14140 TOKEN_STRING_INITIALIZER
14141 (struct cmd_macsec_sa_result,
14143 cmdline_parse_token_string_t cmd_macsec_sa_sa =
14144 TOKEN_STRING_INITIALIZER
14145 (struct cmd_macsec_sa_result,
14147 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
14148 TOKEN_STRING_INITIALIZER
14149 (struct cmd_macsec_sa_result,
14151 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
14152 TOKEN_NUM_INITIALIZER
14153 (struct cmd_macsec_sa_result,
14155 cmdline_parse_token_num_t cmd_macsec_sa_idx =
14156 TOKEN_NUM_INITIALIZER
14157 (struct cmd_macsec_sa_result,
14159 cmdline_parse_token_num_t cmd_macsec_sa_an =
14160 TOKEN_NUM_INITIALIZER
14161 (struct cmd_macsec_sa_result,
14163 cmdline_parse_token_num_t cmd_macsec_sa_pn =
14164 TOKEN_NUM_INITIALIZER
14165 (struct cmd_macsec_sa_result,
14167 cmdline_parse_token_string_t cmd_macsec_sa_key =
14168 TOKEN_STRING_INITIALIZER
14169 (struct cmd_macsec_sa_result,
14173 cmd_set_macsec_sa_parsed(
14174 void *parsed_result,
14175 __attribute__((unused)) struct cmdline *cl,
14176 __attribute__((unused)) void *data)
14178 struct cmd_macsec_sa_result *res = parsed_result;
14179 int ret = -ENOTSUP;
14180 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14181 uint8_t key[16] = { 0 };
14187 key_len = strlen(res->key) / 2;
14191 for (i = 0; i < key_len; i++) {
14192 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
14195 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
14198 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
14201 #ifdef RTE_LIBRTE_IXGBE_PMD
14203 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
14204 res->idx, res->an, res->pn, key) :
14205 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
14206 res->idx, res->an, res->pn, key);
14208 RTE_SET_USED(is_tx);
14215 printf("invalid idx %d or an %d\n", res->idx, res->an);
14218 printf("invalid port_id %d\n", res->port_id);
14221 printf("not supported on port %d\n", res->port_id);
14224 printf("programming error: (%s)\n", strerror(-ret));
14228 cmdline_parse_inst_t cmd_set_macsec_sa = {
14229 .f = cmd_set_macsec_sa_parsed,
14231 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
14233 (void *)&cmd_macsec_sa_set,
14234 (void *)&cmd_macsec_sa_macsec,
14235 (void *)&cmd_macsec_sa_sa,
14236 (void *)&cmd_macsec_sa_tx_rx,
14237 (void *)&cmd_macsec_sa_port_id,
14238 (void *)&cmd_macsec_sa_idx,
14239 (void *)&cmd_macsec_sa_an,
14240 (void *)&cmd_macsec_sa_pn,
14241 (void *)&cmd_macsec_sa_key,
14246 /* VF unicast promiscuous mode configuration */
14248 /* Common result structure for VF unicast promiscuous mode */
14249 struct cmd_vf_promisc_result {
14250 cmdline_fixed_string_t set;
14251 cmdline_fixed_string_t vf;
14252 cmdline_fixed_string_t promisc;
14255 cmdline_fixed_string_t on_off;
14258 /* Common CLI fields for VF unicast promiscuous mode enable disable */
14259 cmdline_parse_token_string_t cmd_vf_promisc_set =
14260 TOKEN_STRING_INITIALIZER
14261 (struct cmd_vf_promisc_result,
14263 cmdline_parse_token_string_t cmd_vf_promisc_vf =
14264 TOKEN_STRING_INITIALIZER
14265 (struct cmd_vf_promisc_result,
14267 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
14268 TOKEN_STRING_INITIALIZER
14269 (struct cmd_vf_promisc_result,
14270 promisc, "promisc");
14271 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
14272 TOKEN_NUM_INITIALIZER
14273 (struct cmd_vf_promisc_result,
14275 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
14276 TOKEN_NUM_INITIALIZER
14277 (struct cmd_vf_promisc_result,
14279 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
14280 TOKEN_STRING_INITIALIZER
14281 (struct cmd_vf_promisc_result,
14285 cmd_set_vf_promisc_parsed(
14286 void *parsed_result,
14287 __attribute__((unused)) struct cmdline *cl,
14288 __attribute__((unused)) void *data)
14290 struct cmd_vf_promisc_result *res = parsed_result;
14291 int ret = -ENOTSUP;
14293 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14295 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14298 #ifdef RTE_LIBRTE_I40E_PMD
14299 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
14300 res->vf_id, is_on);
14307 printf("invalid vf_id %d\n", res->vf_id);
14310 printf("invalid port_id %d\n", res->port_id);
14313 printf("function not implemented\n");
14316 printf("programming error: (%s)\n", strerror(-ret));
14320 cmdline_parse_inst_t cmd_set_vf_promisc = {
14321 .f = cmd_set_vf_promisc_parsed,
14323 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
14324 "Set unicast promiscuous mode for a VF from the PF",
14326 (void *)&cmd_vf_promisc_set,
14327 (void *)&cmd_vf_promisc_vf,
14328 (void *)&cmd_vf_promisc_promisc,
14329 (void *)&cmd_vf_promisc_port_id,
14330 (void *)&cmd_vf_promisc_vf_id,
14331 (void *)&cmd_vf_promisc_on_off,
14336 /* VF multicast promiscuous mode configuration */
14338 /* Common result structure for VF multicast promiscuous mode */
14339 struct cmd_vf_allmulti_result {
14340 cmdline_fixed_string_t set;
14341 cmdline_fixed_string_t vf;
14342 cmdline_fixed_string_t allmulti;
14345 cmdline_fixed_string_t on_off;
14348 /* Common CLI fields for VF multicast promiscuous mode enable disable */
14349 cmdline_parse_token_string_t cmd_vf_allmulti_set =
14350 TOKEN_STRING_INITIALIZER
14351 (struct cmd_vf_allmulti_result,
14353 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
14354 TOKEN_STRING_INITIALIZER
14355 (struct cmd_vf_allmulti_result,
14357 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
14358 TOKEN_STRING_INITIALIZER
14359 (struct cmd_vf_allmulti_result,
14360 allmulti, "allmulti");
14361 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
14362 TOKEN_NUM_INITIALIZER
14363 (struct cmd_vf_allmulti_result,
14365 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
14366 TOKEN_NUM_INITIALIZER
14367 (struct cmd_vf_allmulti_result,
14369 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
14370 TOKEN_STRING_INITIALIZER
14371 (struct cmd_vf_allmulti_result,
14375 cmd_set_vf_allmulti_parsed(
14376 void *parsed_result,
14377 __attribute__((unused)) struct cmdline *cl,
14378 __attribute__((unused)) void *data)
14380 struct cmd_vf_allmulti_result *res = parsed_result;
14381 int ret = -ENOTSUP;
14383 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14385 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14388 #ifdef RTE_LIBRTE_I40E_PMD
14389 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
14390 res->vf_id, is_on);
14397 printf("invalid vf_id %d\n", res->vf_id);
14400 printf("invalid port_id %d\n", res->port_id);
14403 printf("function not implemented\n");
14406 printf("programming error: (%s)\n", strerror(-ret));
14410 cmdline_parse_inst_t cmd_set_vf_allmulti = {
14411 .f = cmd_set_vf_allmulti_parsed,
14413 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
14414 "Set multicast promiscuous mode for a VF from the PF",
14416 (void *)&cmd_vf_allmulti_set,
14417 (void *)&cmd_vf_allmulti_vf,
14418 (void *)&cmd_vf_allmulti_allmulti,
14419 (void *)&cmd_vf_allmulti_port_id,
14420 (void *)&cmd_vf_allmulti_vf_id,
14421 (void *)&cmd_vf_allmulti_on_off,
14426 /* vf broadcast mode configuration */
14428 /* Common result structure for vf broadcast */
14429 struct cmd_set_vf_broadcast_result {
14430 cmdline_fixed_string_t set;
14431 cmdline_fixed_string_t vf;
14432 cmdline_fixed_string_t broadcast;
14435 cmdline_fixed_string_t on_off;
14438 /* Common CLI fields for vf broadcast enable disable */
14439 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
14440 TOKEN_STRING_INITIALIZER
14441 (struct cmd_set_vf_broadcast_result,
14443 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
14444 TOKEN_STRING_INITIALIZER
14445 (struct cmd_set_vf_broadcast_result,
14447 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
14448 TOKEN_STRING_INITIALIZER
14449 (struct cmd_set_vf_broadcast_result,
14450 broadcast, "broadcast");
14451 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
14452 TOKEN_NUM_INITIALIZER
14453 (struct cmd_set_vf_broadcast_result,
14455 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
14456 TOKEN_NUM_INITIALIZER
14457 (struct cmd_set_vf_broadcast_result,
14459 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
14460 TOKEN_STRING_INITIALIZER
14461 (struct cmd_set_vf_broadcast_result,
14465 cmd_set_vf_broadcast_parsed(
14466 void *parsed_result,
14467 __attribute__((unused)) struct cmdline *cl,
14468 __attribute__((unused)) void *data)
14470 struct cmd_set_vf_broadcast_result *res = parsed_result;
14471 int ret = -ENOTSUP;
14473 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14475 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14478 #ifdef RTE_LIBRTE_I40E_PMD
14479 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
14480 res->vf_id, is_on);
14487 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14490 printf("invalid port_id %d\n", res->port_id);
14493 printf("function not implemented\n");
14496 printf("programming error: (%s)\n", strerror(-ret));
14500 cmdline_parse_inst_t cmd_set_vf_broadcast = {
14501 .f = cmd_set_vf_broadcast_parsed,
14503 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
14505 (void *)&cmd_set_vf_broadcast_set,
14506 (void *)&cmd_set_vf_broadcast_vf,
14507 (void *)&cmd_set_vf_broadcast_broadcast,
14508 (void *)&cmd_set_vf_broadcast_port_id,
14509 (void *)&cmd_set_vf_broadcast_vf_id,
14510 (void *)&cmd_set_vf_broadcast_on_off,
14515 /* vf vlan tag configuration */
14517 /* Common result structure for vf vlan tag */
14518 struct cmd_set_vf_vlan_tag_result {
14519 cmdline_fixed_string_t set;
14520 cmdline_fixed_string_t vf;
14521 cmdline_fixed_string_t vlan;
14522 cmdline_fixed_string_t tag;
14525 cmdline_fixed_string_t on_off;
14528 /* Common CLI fields for vf vlan tag enable disable */
14529 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
14530 TOKEN_STRING_INITIALIZER
14531 (struct cmd_set_vf_vlan_tag_result,
14533 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
14534 TOKEN_STRING_INITIALIZER
14535 (struct cmd_set_vf_vlan_tag_result,
14537 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
14538 TOKEN_STRING_INITIALIZER
14539 (struct cmd_set_vf_vlan_tag_result,
14541 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
14542 TOKEN_STRING_INITIALIZER
14543 (struct cmd_set_vf_vlan_tag_result,
14545 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
14546 TOKEN_NUM_INITIALIZER
14547 (struct cmd_set_vf_vlan_tag_result,
14549 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
14550 TOKEN_NUM_INITIALIZER
14551 (struct cmd_set_vf_vlan_tag_result,
14553 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
14554 TOKEN_STRING_INITIALIZER
14555 (struct cmd_set_vf_vlan_tag_result,
14559 cmd_set_vf_vlan_tag_parsed(
14560 void *parsed_result,
14561 __attribute__((unused)) struct cmdline *cl,
14562 __attribute__((unused)) void *data)
14564 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
14565 int ret = -ENOTSUP;
14567 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14569 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14572 #ifdef RTE_LIBRTE_I40E_PMD
14573 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
14574 res->vf_id, is_on);
14581 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14584 printf("invalid port_id %d\n", res->port_id);
14587 printf("function not implemented\n");
14590 printf("programming error: (%s)\n", strerror(-ret));
14594 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
14595 .f = cmd_set_vf_vlan_tag_parsed,
14597 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
14599 (void *)&cmd_set_vf_vlan_tag_set,
14600 (void *)&cmd_set_vf_vlan_tag_vf,
14601 (void *)&cmd_set_vf_vlan_tag_vlan,
14602 (void *)&cmd_set_vf_vlan_tag_tag,
14603 (void *)&cmd_set_vf_vlan_tag_port_id,
14604 (void *)&cmd_set_vf_vlan_tag_vf_id,
14605 (void *)&cmd_set_vf_vlan_tag_on_off,
14610 /* Common definition of VF and TC TX bandwidth configuration */
14611 struct cmd_vf_tc_bw_result {
14612 cmdline_fixed_string_t set;
14613 cmdline_fixed_string_t vf;
14614 cmdline_fixed_string_t tc;
14615 cmdline_fixed_string_t tx;
14616 cmdline_fixed_string_t min_bw;
14617 cmdline_fixed_string_t max_bw;
14618 cmdline_fixed_string_t strict_link_prio;
14623 cmdline_fixed_string_t bw_list;
14627 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
14628 TOKEN_STRING_INITIALIZER
14629 (struct cmd_vf_tc_bw_result,
14631 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
14632 TOKEN_STRING_INITIALIZER
14633 (struct cmd_vf_tc_bw_result,
14635 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
14636 TOKEN_STRING_INITIALIZER
14637 (struct cmd_vf_tc_bw_result,
14639 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
14640 TOKEN_STRING_INITIALIZER
14641 (struct cmd_vf_tc_bw_result,
14643 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
14644 TOKEN_STRING_INITIALIZER
14645 (struct cmd_vf_tc_bw_result,
14646 strict_link_prio, "strict-link-priority");
14647 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
14648 TOKEN_STRING_INITIALIZER
14649 (struct cmd_vf_tc_bw_result,
14650 min_bw, "min-bandwidth");
14651 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
14652 TOKEN_STRING_INITIALIZER
14653 (struct cmd_vf_tc_bw_result,
14654 max_bw, "max-bandwidth");
14655 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
14656 TOKEN_NUM_INITIALIZER
14657 (struct cmd_vf_tc_bw_result,
14659 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
14660 TOKEN_NUM_INITIALIZER
14661 (struct cmd_vf_tc_bw_result,
14663 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
14664 TOKEN_NUM_INITIALIZER
14665 (struct cmd_vf_tc_bw_result,
14667 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
14668 TOKEN_NUM_INITIALIZER
14669 (struct cmd_vf_tc_bw_result,
14671 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
14672 TOKEN_STRING_INITIALIZER
14673 (struct cmd_vf_tc_bw_result,
14675 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
14676 TOKEN_NUM_INITIALIZER
14677 (struct cmd_vf_tc_bw_result,
14680 /* VF max bandwidth setting */
14682 cmd_vf_max_bw_parsed(
14683 void *parsed_result,
14684 __attribute__((unused)) struct cmdline *cl,
14685 __attribute__((unused)) void *data)
14687 struct cmd_vf_tc_bw_result *res = parsed_result;
14688 int ret = -ENOTSUP;
14690 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14693 #ifdef RTE_LIBRTE_I40E_PMD
14694 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
14695 res->vf_id, res->bw);
14702 printf("invalid vf_id %d or bandwidth %d\n",
14703 res->vf_id, res->bw);
14706 printf("invalid port_id %d\n", res->port_id);
14709 printf("function not implemented\n");
14712 printf("programming error: (%s)\n", strerror(-ret));
14716 cmdline_parse_inst_t cmd_vf_max_bw = {
14717 .f = cmd_vf_max_bw_parsed,
14719 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
14721 (void *)&cmd_vf_tc_bw_set,
14722 (void *)&cmd_vf_tc_bw_vf,
14723 (void *)&cmd_vf_tc_bw_tx,
14724 (void *)&cmd_vf_tc_bw_max_bw,
14725 (void *)&cmd_vf_tc_bw_port_id,
14726 (void *)&cmd_vf_tc_bw_vf_id,
14727 (void *)&cmd_vf_tc_bw_bw,
14733 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
14738 const char *p, *p0 = str;
14745 p = strchr(p0, '(');
14747 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14751 p0 = strchr(p, ')');
14753 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14757 if (size >= sizeof(s)) {
14758 printf("The string size exceeds the internal buffer size\n");
14761 snprintf(s, sizeof(s), "%.*s", size, p);
14762 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
14764 printf("Failed to get the bandwidth list. ");
14768 for (i = 0; i < ret; i++)
14769 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
14774 /* TC min bandwidth setting */
14776 cmd_vf_tc_min_bw_parsed(
14777 void *parsed_result,
14778 __attribute__((unused)) struct cmdline *cl,
14779 __attribute__((unused)) void *data)
14781 struct cmd_vf_tc_bw_result *res = parsed_result;
14784 int ret = -ENOTSUP;
14786 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14789 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
14793 #ifdef RTE_LIBRTE_I40E_PMD
14794 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
14802 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
14805 printf("invalid port_id %d\n", res->port_id);
14808 printf("function not implemented\n");
14811 printf("programming error: (%s)\n", strerror(-ret));
14815 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
14816 .f = cmd_vf_tc_min_bw_parsed,
14818 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
14819 " <bw1, bw2, ...>",
14821 (void *)&cmd_vf_tc_bw_set,
14822 (void *)&cmd_vf_tc_bw_vf,
14823 (void *)&cmd_vf_tc_bw_tc,
14824 (void *)&cmd_vf_tc_bw_tx,
14825 (void *)&cmd_vf_tc_bw_min_bw,
14826 (void *)&cmd_vf_tc_bw_port_id,
14827 (void *)&cmd_vf_tc_bw_vf_id,
14828 (void *)&cmd_vf_tc_bw_bw_list,
14834 cmd_tc_min_bw_parsed(
14835 void *parsed_result,
14836 __attribute__((unused)) struct cmdline *cl,
14837 __attribute__((unused)) void *data)
14839 struct cmd_vf_tc_bw_result *res = parsed_result;
14840 struct rte_port *port;
14843 int ret = -ENOTSUP;
14845 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14848 port = &ports[res->port_id];
14849 /** Check if the port is not started **/
14850 if (port->port_status != RTE_PORT_STOPPED) {
14851 printf("Please stop port %d first\n", res->port_id);
14855 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
14859 #ifdef RTE_LIBRTE_IXGBE_PMD
14860 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
14867 printf("invalid bandwidth\n");
14870 printf("invalid port_id %d\n", res->port_id);
14873 printf("function not implemented\n");
14876 printf("programming error: (%s)\n", strerror(-ret));
14880 cmdline_parse_inst_t cmd_tc_min_bw = {
14881 .f = cmd_tc_min_bw_parsed,
14883 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
14885 (void *)&cmd_vf_tc_bw_set,
14886 (void *)&cmd_vf_tc_bw_tc,
14887 (void *)&cmd_vf_tc_bw_tx,
14888 (void *)&cmd_vf_tc_bw_min_bw,
14889 (void *)&cmd_vf_tc_bw_port_id,
14890 (void *)&cmd_vf_tc_bw_bw_list,
14895 /* TC max bandwidth setting */
14897 cmd_vf_tc_max_bw_parsed(
14898 void *parsed_result,
14899 __attribute__((unused)) struct cmdline *cl,
14900 __attribute__((unused)) void *data)
14902 struct cmd_vf_tc_bw_result *res = parsed_result;
14903 int ret = -ENOTSUP;
14905 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14908 #ifdef RTE_LIBRTE_I40E_PMD
14909 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
14910 res->tc_no, res->bw);
14917 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
14918 res->vf_id, res->tc_no, res->bw);
14921 printf("invalid port_id %d\n", res->port_id);
14924 printf("function not implemented\n");
14927 printf("programming error: (%s)\n", strerror(-ret));
14931 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
14932 .f = cmd_vf_tc_max_bw_parsed,
14934 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
14937 (void *)&cmd_vf_tc_bw_set,
14938 (void *)&cmd_vf_tc_bw_vf,
14939 (void *)&cmd_vf_tc_bw_tc,
14940 (void *)&cmd_vf_tc_bw_tx,
14941 (void *)&cmd_vf_tc_bw_max_bw,
14942 (void *)&cmd_vf_tc_bw_port_id,
14943 (void *)&cmd_vf_tc_bw_vf_id,
14944 (void *)&cmd_vf_tc_bw_tc_no,
14945 (void *)&cmd_vf_tc_bw_bw,
14951 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
14953 /* *** Set Port default Traffic Management Hierarchy *** */
14954 struct cmd_set_port_tm_hierarchy_default_result {
14955 cmdline_fixed_string_t set;
14956 cmdline_fixed_string_t port;
14957 cmdline_fixed_string_t tm;
14958 cmdline_fixed_string_t hierarchy;
14959 cmdline_fixed_string_t def;
14963 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_set =
14964 TOKEN_STRING_INITIALIZER(
14965 struct cmd_set_port_tm_hierarchy_default_result, set, "set");
14966 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_port =
14967 TOKEN_STRING_INITIALIZER(
14968 struct cmd_set_port_tm_hierarchy_default_result, port, "port");
14969 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_tm =
14970 TOKEN_STRING_INITIALIZER(
14971 struct cmd_set_port_tm_hierarchy_default_result, tm, "tm");
14972 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_hierarchy =
14973 TOKEN_STRING_INITIALIZER(
14974 struct cmd_set_port_tm_hierarchy_default_result,
14975 hierarchy, "hierarchy");
14976 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_default =
14977 TOKEN_STRING_INITIALIZER(
14978 struct cmd_set_port_tm_hierarchy_default_result,
14980 cmdline_parse_token_num_t cmd_set_port_tm_hierarchy_default_port_id =
14981 TOKEN_NUM_INITIALIZER(
14982 struct cmd_set_port_tm_hierarchy_default_result,
14985 static void cmd_set_port_tm_hierarchy_default_parsed(void *parsed_result,
14986 __attribute__((unused)) struct cmdline *cl,
14987 __attribute__((unused)) void *data)
14989 struct cmd_set_port_tm_hierarchy_default_result *res = parsed_result;
14990 struct rte_port *p;
14991 portid_t port_id = res->port_id;
14993 if (port_id_is_invalid(port_id, ENABLED_WARN))
14996 p = &ports[port_id];
14998 /* Forward mode: tm */
14999 if (strcmp(cur_fwd_config.fwd_eng->fwd_mode_name, "softnic")) {
15000 printf(" softnicfwd mode not enabled(error)\n");
15004 /* Set the default tm hierarchy */
15005 p->softport.default_tm_hierarchy_enable = 1;
15008 cmdline_parse_inst_t cmd_set_port_tm_hierarchy_default = {
15009 .f = cmd_set_port_tm_hierarchy_default_parsed,
15011 .help_str = "set port tm hierarchy default <port_id>",
15013 (void *)&cmd_set_port_tm_hierarchy_default_set,
15014 (void *)&cmd_set_port_tm_hierarchy_default_port,
15015 (void *)&cmd_set_port_tm_hierarchy_default_tm,
15016 (void *)&cmd_set_port_tm_hierarchy_default_hierarchy,
15017 (void *)&cmd_set_port_tm_hierarchy_default_default,
15018 (void *)&cmd_set_port_tm_hierarchy_default_port_id,
15024 /** Set VXLAN encapsulation details */
15025 struct cmd_set_vxlan_result {
15026 cmdline_fixed_string_t set;
15027 cmdline_fixed_string_t vxlan;
15028 cmdline_fixed_string_t pos_token;
15029 cmdline_fixed_string_t ip_version;
15030 uint32_t vlan_present:1;
15034 cmdline_ipaddr_t ip_src;
15035 cmdline_ipaddr_t ip_dst;
15037 struct ether_addr eth_src;
15038 struct ether_addr eth_dst;
15041 cmdline_parse_token_string_t cmd_set_vxlan_set =
15042 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
15043 cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
15044 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
15045 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
15046 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15047 "vxlan-with-vlan");
15048 cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
15049 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15051 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
15052 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
15054 cmdline_parse_token_string_t cmd_set_vxlan_vni =
15055 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15057 cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
15058 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, UINT32);
15059 cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
15060 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15062 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
15063 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, UINT16);
15064 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
15065 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15067 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
15068 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, UINT16);
15069 cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
15070 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15072 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
15073 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
15074 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
15075 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15077 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
15078 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
15079 cmdline_parse_token_string_t cmd_set_vxlan_vlan =
15080 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15082 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
15083 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, UINT16);
15084 cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
15085 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15087 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
15088 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
15089 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
15090 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15092 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
15093 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
15095 static void cmd_set_vxlan_parsed(void *parsed_result,
15096 __attribute__((unused)) struct cmdline *cl,
15097 __attribute__((unused)) void *data)
15099 struct cmd_set_vxlan_result *res = parsed_result;
15104 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
15107 if (strcmp(res->vxlan, "vxlan") == 0)
15108 vxlan_encap_conf.select_vlan = 0;
15109 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
15110 vxlan_encap_conf.select_vlan = 1;
15111 if (strcmp(res->ip_version, "ipv4") == 0)
15112 vxlan_encap_conf.select_ipv4 = 1;
15113 else if (strcmp(res->ip_version, "ipv6") == 0)
15114 vxlan_encap_conf.select_ipv4 = 0;
15117 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
15118 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
15119 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
15120 if (vxlan_encap_conf.select_ipv4) {
15121 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
15122 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
15124 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
15125 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
15127 if (vxlan_encap_conf.select_vlan)
15128 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15129 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
15131 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15135 cmdline_parse_inst_t cmd_set_vxlan = {
15136 .f = cmd_set_vxlan_parsed,
15138 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
15139 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
15140 " eth-src <eth-src> eth-dst <eth-dst>",
15142 (void *)&cmd_set_vxlan_set,
15143 (void *)&cmd_set_vxlan_vxlan,
15144 (void *)&cmd_set_vxlan_ip_version,
15145 (void *)&cmd_set_vxlan_ip_version_value,
15146 (void *)&cmd_set_vxlan_vni,
15147 (void *)&cmd_set_vxlan_vni_value,
15148 (void *)&cmd_set_vxlan_udp_src,
15149 (void *)&cmd_set_vxlan_udp_src_value,
15150 (void *)&cmd_set_vxlan_udp_dst,
15151 (void *)&cmd_set_vxlan_udp_dst_value,
15152 (void *)&cmd_set_vxlan_ip_src,
15153 (void *)&cmd_set_vxlan_ip_src_value,
15154 (void *)&cmd_set_vxlan_ip_dst,
15155 (void *)&cmd_set_vxlan_ip_dst_value,
15156 (void *)&cmd_set_vxlan_eth_src,
15157 (void *)&cmd_set_vxlan_eth_src_value,
15158 (void *)&cmd_set_vxlan_eth_dst,
15159 (void *)&cmd_set_vxlan_eth_dst_value,
15164 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
15165 .f = cmd_set_vxlan_parsed,
15167 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
15168 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
15169 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
15172 (void *)&cmd_set_vxlan_set,
15173 (void *)&cmd_set_vxlan_vxlan_with_vlan,
15174 (void *)&cmd_set_vxlan_ip_version,
15175 (void *)&cmd_set_vxlan_ip_version_value,
15176 (void *)&cmd_set_vxlan_vni,
15177 (void *)&cmd_set_vxlan_vni_value,
15178 (void *)&cmd_set_vxlan_udp_src,
15179 (void *)&cmd_set_vxlan_udp_src_value,
15180 (void *)&cmd_set_vxlan_udp_dst,
15181 (void *)&cmd_set_vxlan_udp_dst_value,
15182 (void *)&cmd_set_vxlan_ip_src,
15183 (void *)&cmd_set_vxlan_ip_src_value,
15184 (void *)&cmd_set_vxlan_ip_dst,
15185 (void *)&cmd_set_vxlan_ip_dst_value,
15186 (void *)&cmd_set_vxlan_vlan,
15187 (void *)&cmd_set_vxlan_vlan_value,
15188 (void *)&cmd_set_vxlan_eth_src,
15189 (void *)&cmd_set_vxlan_eth_src_value,
15190 (void *)&cmd_set_vxlan_eth_dst,
15191 (void *)&cmd_set_vxlan_eth_dst_value,
15196 /** Set NVGRE encapsulation details */
15197 struct cmd_set_nvgre_result {
15198 cmdline_fixed_string_t set;
15199 cmdline_fixed_string_t nvgre;
15200 cmdline_fixed_string_t pos_token;
15201 cmdline_fixed_string_t ip_version;
15203 cmdline_ipaddr_t ip_src;
15204 cmdline_ipaddr_t ip_dst;
15206 struct ether_addr eth_src;
15207 struct ether_addr eth_dst;
15210 cmdline_parse_token_string_t cmd_set_nvgre_set =
15211 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
15212 cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
15213 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
15214 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
15215 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
15216 "nvgre-with-vlan");
15217 cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
15218 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15220 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
15221 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
15223 cmdline_parse_token_string_t cmd_set_nvgre_tni =
15224 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15226 cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
15227 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, UINT32);
15228 cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
15229 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15231 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
15232 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
15233 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
15234 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15236 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
15237 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
15238 cmdline_parse_token_string_t cmd_set_nvgre_vlan =
15239 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15241 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
15242 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, UINT16);
15243 cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
15244 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15246 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
15247 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
15248 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
15249 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15251 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
15252 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
15254 static void cmd_set_nvgre_parsed(void *parsed_result,
15255 __attribute__((unused)) struct cmdline *cl,
15256 __attribute__((unused)) void *data)
15258 struct cmd_set_nvgre_result *res = parsed_result;
15260 uint32_t nvgre_tni;
15263 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
15266 if (strcmp(res->nvgre, "nvgre") == 0)
15267 nvgre_encap_conf.select_vlan = 0;
15268 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
15269 nvgre_encap_conf.select_vlan = 1;
15270 if (strcmp(res->ip_version, "ipv4") == 0)
15271 nvgre_encap_conf.select_ipv4 = 1;
15272 else if (strcmp(res->ip_version, "ipv6") == 0)
15273 nvgre_encap_conf.select_ipv4 = 0;
15276 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
15277 if (nvgre_encap_conf.select_ipv4) {
15278 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
15279 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
15281 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
15282 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
15284 if (nvgre_encap_conf.select_vlan)
15285 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15286 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
15288 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15292 cmdline_parse_inst_t cmd_set_nvgre = {
15293 .f = cmd_set_nvgre_parsed,
15295 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
15296 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15297 " eth-dst <eth-dst>",
15299 (void *)&cmd_set_nvgre_set,
15300 (void *)&cmd_set_nvgre_nvgre,
15301 (void *)&cmd_set_nvgre_ip_version,
15302 (void *)&cmd_set_nvgre_ip_version_value,
15303 (void *)&cmd_set_nvgre_tni,
15304 (void *)&cmd_set_nvgre_tni_value,
15305 (void *)&cmd_set_nvgre_ip_src,
15306 (void *)&cmd_set_nvgre_ip_src_value,
15307 (void *)&cmd_set_nvgre_ip_dst,
15308 (void *)&cmd_set_nvgre_ip_dst_value,
15309 (void *)&cmd_set_nvgre_eth_src,
15310 (void *)&cmd_set_nvgre_eth_src_value,
15311 (void *)&cmd_set_nvgre_eth_dst,
15312 (void *)&cmd_set_nvgre_eth_dst_value,
15317 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
15318 .f = cmd_set_nvgre_parsed,
15320 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
15321 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
15322 " eth-src <eth-src> eth-dst <eth-dst>",
15324 (void *)&cmd_set_nvgre_set,
15325 (void *)&cmd_set_nvgre_nvgre_with_vlan,
15326 (void *)&cmd_set_nvgre_ip_version,
15327 (void *)&cmd_set_nvgre_ip_version_value,
15328 (void *)&cmd_set_nvgre_tni,
15329 (void *)&cmd_set_nvgre_tni_value,
15330 (void *)&cmd_set_nvgre_ip_src,
15331 (void *)&cmd_set_nvgre_ip_src_value,
15332 (void *)&cmd_set_nvgre_ip_dst,
15333 (void *)&cmd_set_nvgre_ip_dst_value,
15334 (void *)&cmd_set_nvgre_vlan,
15335 (void *)&cmd_set_nvgre_vlan_value,
15336 (void *)&cmd_set_nvgre_eth_src,
15337 (void *)&cmd_set_nvgre_eth_src_value,
15338 (void *)&cmd_set_nvgre_eth_dst,
15339 (void *)&cmd_set_nvgre_eth_dst_value,
15344 /** Set L2 encapsulation details */
15345 struct cmd_set_l2_encap_result {
15346 cmdline_fixed_string_t set;
15347 cmdline_fixed_string_t l2_encap;
15348 cmdline_fixed_string_t pos_token;
15349 cmdline_fixed_string_t ip_version;
15350 uint32_t vlan_present:1;
15352 struct ether_addr eth_src;
15353 struct ether_addr eth_dst;
15356 cmdline_parse_token_string_t cmd_set_l2_encap_set =
15357 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
15358 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
15359 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
15360 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
15361 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
15362 "l2_encap-with-vlan");
15363 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
15364 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15366 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
15367 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
15369 cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
15370 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15372 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
15373 TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, UINT16);
15374 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
15375 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15377 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
15378 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
15379 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
15380 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15382 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
15383 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
15385 static void cmd_set_l2_encap_parsed(void *parsed_result,
15386 __attribute__((unused)) struct cmdline *cl,
15387 __attribute__((unused)) void *data)
15389 struct cmd_set_l2_encap_result *res = parsed_result;
15391 if (strcmp(res->l2_encap, "l2_encap") == 0)
15392 l2_encap_conf.select_vlan = 0;
15393 else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
15394 l2_encap_conf.select_vlan = 1;
15395 if (strcmp(res->ip_version, "ipv4") == 0)
15396 l2_encap_conf.select_ipv4 = 1;
15397 else if (strcmp(res->ip_version, "ipv6") == 0)
15398 l2_encap_conf.select_ipv4 = 0;
15401 if (l2_encap_conf.select_vlan)
15402 l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15403 rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
15405 rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15409 cmdline_parse_inst_t cmd_set_l2_encap = {
15410 .f = cmd_set_l2_encap_parsed,
15412 .help_str = "set l2_encap ip-version ipv4|ipv6"
15413 " eth-src <eth-src> eth-dst <eth-dst>",
15415 (void *)&cmd_set_l2_encap_set,
15416 (void *)&cmd_set_l2_encap_l2_encap,
15417 (void *)&cmd_set_l2_encap_ip_version,
15418 (void *)&cmd_set_l2_encap_ip_version_value,
15419 (void *)&cmd_set_l2_encap_eth_src,
15420 (void *)&cmd_set_l2_encap_eth_src_value,
15421 (void *)&cmd_set_l2_encap_eth_dst,
15422 (void *)&cmd_set_l2_encap_eth_dst_value,
15427 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
15428 .f = cmd_set_l2_encap_parsed,
15430 .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
15431 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
15433 (void *)&cmd_set_l2_encap_set,
15434 (void *)&cmd_set_l2_encap_l2_encap_with_vlan,
15435 (void *)&cmd_set_l2_encap_ip_version,
15436 (void *)&cmd_set_l2_encap_ip_version_value,
15437 (void *)&cmd_set_l2_encap_vlan,
15438 (void *)&cmd_set_l2_encap_vlan_value,
15439 (void *)&cmd_set_l2_encap_eth_src,
15440 (void *)&cmd_set_l2_encap_eth_src_value,
15441 (void *)&cmd_set_l2_encap_eth_dst,
15442 (void *)&cmd_set_l2_encap_eth_dst_value,
15447 /** Set L2 decapsulation details */
15448 struct cmd_set_l2_decap_result {
15449 cmdline_fixed_string_t set;
15450 cmdline_fixed_string_t l2_decap;
15451 cmdline_fixed_string_t pos_token;
15452 uint32_t vlan_present:1;
15455 cmdline_parse_token_string_t cmd_set_l2_decap_set =
15456 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
15457 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
15458 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
15460 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
15461 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
15462 "l2_decap-with-vlan");
15464 static void cmd_set_l2_decap_parsed(void *parsed_result,
15465 __attribute__((unused)) struct cmdline *cl,
15466 __attribute__((unused)) void *data)
15468 struct cmd_set_l2_decap_result *res = parsed_result;
15470 if (strcmp(res->l2_decap, "l2_decap") == 0)
15471 l2_decap_conf.select_vlan = 0;
15472 else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
15473 l2_decap_conf.select_vlan = 1;
15476 cmdline_parse_inst_t cmd_set_l2_decap = {
15477 .f = cmd_set_l2_decap_parsed,
15479 .help_str = "set l2_decap",
15481 (void *)&cmd_set_l2_decap_set,
15482 (void *)&cmd_set_l2_decap_l2_decap,
15487 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
15488 .f = cmd_set_l2_decap_parsed,
15490 .help_str = "set l2_decap-with-vlan",
15492 (void *)&cmd_set_l2_decap_set,
15493 (void *)&cmd_set_l2_decap_l2_decap_with_vlan,
15498 /** Set MPLSoGRE encapsulation details */
15499 struct cmd_set_mplsogre_encap_result {
15500 cmdline_fixed_string_t set;
15501 cmdline_fixed_string_t mplsogre;
15502 cmdline_fixed_string_t pos_token;
15503 cmdline_fixed_string_t ip_version;
15504 uint32_t vlan_present:1;
15506 cmdline_ipaddr_t ip_src;
15507 cmdline_ipaddr_t ip_dst;
15509 struct ether_addr eth_src;
15510 struct ether_addr eth_dst;
15513 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
15514 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
15516 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
15517 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
15519 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
15520 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15521 mplsogre, "mplsogre_encap-with-vlan");
15522 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
15523 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15524 pos_token, "ip-version");
15525 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
15526 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15527 ip_version, "ipv4#ipv6");
15528 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
15529 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15530 pos_token, "label");
15531 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
15532 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
15534 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
15535 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15536 pos_token, "ip-src");
15537 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
15538 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
15539 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
15540 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15541 pos_token, "ip-dst");
15542 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
15543 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
15544 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
15545 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15546 pos_token, "vlan-tci");
15547 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
15548 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
15550 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
15551 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15552 pos_token, "eth-src");
15553 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
15554 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15556 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
15557 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15558 pos_token, "eth-dst");
15559 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
15560 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15563 static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
15564 __attribute__((unused)) struct cmdline *cl,
15565 __attribute__((unused)) void *data)
15567 struct cmd_set_mplsogre_encap_result *res = parsed_result;
15569 uint32_t mplsogre_label;
15573 rte_cpu_to_be_32(res->label) & RTE_BE32(0x00ffffff),
15576 if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
15577 mplsogre_encap_conf.select_vlan = 0;
15578 else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
15579 mplsogre_encap_conf.select_vlan = 1;
15580 if (strcmp(res->ip_version, "ipv4") == 0)
15581 mplsogre_encap_conf.select_ipv4 = 1;
15582 else if (strcmp(res->ip_version, "ipv6") == 0)
15583 mplsogre_encap_conf.select_ipv4 = 0;
15586 rte_memcpy(mplsogre_encap_conf.label, &id.label[1], 3);
15587 if (mplsogre_encap_conf.select_ipv4) {
15588 IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
15589 IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
15591 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
15592 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
15594 if (mplsogre_encap_conf.select_vlan)
15595 mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15596 rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
15598 rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15602 cmdline_parse_inst_t cmd_set_mplsogre_encap = {
15603 .f = cmd_set_mplsogre_encap_parsed,
15605 .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
15606 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15607 " eth-dst <eth-dst>",
15609 (void *)&cmd_set_mplsogre_encap_set,
15610 (void *)&cmd_set_mplsogre_encap_mplsogre_encap,
15611 (void *)&cmd_set_mplsogre_encap_ip_version,
15612 (void *)&cmd_set_mplsogre_encap_ip_version_value,
15613 (void *)&cmd_set_mplsogre_encap_label,
15614 (void *)&cmd_set_mplsogre_encap_label_value,
15615 (void *)&cmd_set_mplsogre_encap_ip_src,
15616 (void *)&cmd_set_mplsogre_encap_ip_src_value,
15617 (void *)&cmd_set_mplsogre_encap_ip_dst,
15618 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
15619 (void *)&cmd_set_mplsogre_encap_eth_src,
15620 (void *)&cmd_set_mplsogre_encap_eth_src_value,
15621 (void *)&cmd_set_mplsogre_encap_eth_dst,
15622 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
15627 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
15628 .f = cmd_set_mplsogre_encap_parsed,
15630 .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
15631 " label <label> ip-src <ip-src> ip-dst <ip-dst>"
15632 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
15634 (void *)&cmd_set_mplsogre_encap_set,
15635 (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
15636 (void *)&cmd_set_mplsogre_encap_ip_version,
15637 (void *)&cmd_set_mplsogre_encap_ip_version_value,
15638 (void *)&cmd_set_mplsogre_encap_label,
15639 (void *)&cmd_set_mplsogre_encap_label_value,
15640 (void *)&cmd_set_mplsogre_encap_ip_src,
15641 (void *)&cmd_set_mplsogre_encap_ip_src_value,
15642 (void *)&cmd_set_mplsogre_encap_ip_dst,
15643 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
15644 (void *)&cmd_set_mplsogre_encap_vlan,
15645 (void *)&cmd_set_mplsogre_encap_vlan_value,
15646 (void *)&cmd_set_mplsogre_encap_eth_src,
15647 (void *)&cmd_set_mplsogre_encap_eth_src_value,
15648 (void *)&cmd_set_mplsogre_encap_eth_dst,
15649 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
15654 /** Set MPLSoGRE decapsulation details */
15655 struct cmd_set_mplsogre_decap_result {
15656 cmdline_fixed_string_t set;
15657 cmdline_fixed_string_t mplsogre;
15658 cmdline_fixed_string_t pos_token;
15659 cmdline_fixed_string_t ip_version;
15660 uint32_t vlan_present:1;
15663 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
15664 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
15666 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
15667 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
15669 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
15670 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
15671 mplsogre, "mplsogre_decap-with-vlan");
15672 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
15673 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
15674 pos_token, "ip-version");
15675 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
15676 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
15677 ip_version, "ipv4#ipv6");
15679 static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
15680 __attribute__((unused)) struct cmdline *cl,
15681 __attribute__((unused)) void *data)
15683 struct cmd_set_mplsogre_decap_result *res = parsed_result;
15685 if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
15686 mplsogre_decap_conf.select_vlan = 0;
15687 else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
15688 mplsogre_decap_conf.select_vlan = 1;
15689 if (strcmp(res->ip_version, "ipv4") == 0)
15690 mplsogre_decap_conf.select_ipv4 = 1;
15691 else if (strcmp(res->ip_version, "ipv6") == 0)
15692 mplsogre_decap_conf.select_ipv4 = 0;
15695 cmdline_parse_inst_t cmd_set_mplsogre_decap = {
15696 .f = cmd_set_mplsogre_decap_parsed,
15698 .help_str = "set mplsogre_decap ip-version ipv4|ipv6",
15700 (void *)&cmd_set_mplsogre_decap_set,
15701 (void *)&cmd_set_mplsogre_decap_mplsogre_decap,
15702 (void *)&cmd_set_mplsogre_decap_ip_version,
15703 (void *)&cmd_set_mplsogre_decap_ip_version_value,
15708 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
15709 .f = cmd_set_mplsogre_decap_parsed,
15711 .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
15713 (void *)&cmd_set_mplsogre_decap_set,
15714 (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
15715 (void *)&cmd_set_mplsogre_decap_ip_version,
15716 (void *)&cmd_set_mplsogre_decap_ip_version_value,
15721 /** Set MPLSoUDP encapsulation details */
15722 struct cmd_set_mplsoudp_encap_result {
15723 cmdline_fixed_string_t set;
15724 cmdline_fixed_string_t mplsoudp;
15725 cmdline_fixed_string_t pos_token;
15726 cmdline_fixed_string_t ip_version;
15727 uint32_t vlan_present:1;
15731 cmdline_ipaddr_t ip_src;
15732 cmdline_ipaddr_t ip_dst;
15734 struct ether_addr eth_src;
15735 struct ether_addr eth_dst;
15738 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
15739 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
15741 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
15742 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
15744 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
15745 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15746 mplsoudp, "mplsoudp_encap-with-vlan");
15747 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
15748 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15749 pos_token, "ip-version");
15750 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
15751 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15752 ip_version, "ipv4#ipv6");
15753 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
15754 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15755 pos_token, "label");
15756 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
15757 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
15759 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
15760 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15761 pos_token, "udp-src");
15762 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
15763 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
15765 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
15766 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15767 pos_token, "udp-dst");
15768 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
15769 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
15771 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
15772 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15773 pos_token, "ip-src");
15774 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
15775 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
15776 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
15777 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15778 pos_token, "ip-dst");
15779 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
15780 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
15781 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
15782 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15783 pos_token, "vlan-tci");
15784 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
15785 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
15787 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
15788 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15789 pos_token, "eth-src");
15790 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
15791 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15793 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
15794 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15795 pos_token, "eth-dst");
15796 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
15797 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15800 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
15801 __attribute__((unused)) struct cmdline *cl,
15802 __attribute__((unused)) void *data)
15804 struct cmd_set_mplsoudp_encap_result *res = parsed_result;
15806 uint32_t mplsoudp_label;
15810 rte_cpu_to_be_32(res->label) & RTE_BE32(0x00ffffff),
15813 if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
15814 mplsoudp_encap_conf.select_vlan = 0;
15815 else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
15816 mplsoudp_encap_conf.select_vlan = 1;
15817 if (strcmp(res->ip_version, "ipv4") == 0)
15818 mplsoudp_encap_conf.select_ipv4 = 1;
15819 else if (strcmp(res->ip_version, "ipv6") == 0)
15820 mplsoudp_encap_conf.select_ipv4 = 0;
15823 rte_memcpy(mplsoudp_encap_conf.label, &id.label[1], 3);
15824 mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
15825 mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
15826 if (mplsoudp_encap_conf.select_ipv4) {
15827 IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
15828 IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
15830 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
15831 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
15833 if (mplsoudp_encap_conf.select_vlan)
15834 mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15835 rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
15837 rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15841 cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
15842 .f = cmd_set_mplsoudp_encap_parsed,
15844 .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
15845 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
15846 " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
15848 (void *)&cmd_set_mplsoudp_encap_set,
15849 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
15850 (void *)&cmd_set_mplsoudp_encap_ip_version,
15851 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
15852 (void *)&cmd_set_mplsoudp_encap_label,
15853 (void *)&cmd_set_mplsoudp_encap_label_value,
15854 (void *)&cmd_set_mplsoudp_encap_udp_src,
15855 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
15856 (void *)&cmd_set_mplsoudp_encap_udp_dst,
15857 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
15858 (void *)&cmd_set_mplsoudp_encap_ip_src,
15859 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
15860 (void *)&cmd_set_mplsoudp_encap_ip_dst,
15861 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
15862 (void *)&cmd_set_mplsoudp_encap_eth_src,
15863 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
15864 (void *)&cmd_set_mplsoudp_encap_eth_dst,
15865 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
15870 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
15871 .f = cmd_set_mplsoudp_encap_parsed,
15873 .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
15874 " label <label> udp-src <udp-src> udp-dst <udp-dst>"
15875 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
15876 " eth-src <eth-src> eth-dst <eth-dst>",
15878 (void *)&cmd_set_mplsoudp_encap_set,
15879 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
15880 (void *)&cmd_set_mplsoudp_encap_ip_version,
15881 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
15882 (void *)&cmd_set_mplsoudp_encap_label,
15883 (void *)&cmd_set_mplsoudp_encap_label_value,
15884 (void *)&cmd_set_mplsoudp_encap_udp_src,
15885 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
15886 (void *)&cmd_set_mplsoudp_encap_udp_dst,
15887 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
15888 (void *)&cmd_set_mplsoudp_encap_ip_src,
15889 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
15890 (void *)&cmd_set_mplsoudp_encap_ip_dst,
15891 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
15892 (void *)&cmd_set_mplsoudp_encap_vlan,
15893 (void *)&cmd_set_mplsoudp_encap_vlan_value,
15894 (void *)&cmd_set_mplsoudp_encap_eth_src,
15895 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
15896 (void *)&cmd_set_mplsoudp_encap_eth_dst,
15897 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
15902 /** Set MPLSoUDP decapsulation details */
15903 struct cmd_set_mplsoudp_decap_result {
15904 cmdline_fixed_string_t set;
15905 cmdline_fixed_string_t mplsoudp;
15906 cmdline_fixed_string_t pos_token;
15907 cmdline_fixed_string_t ip_version;
15908 uint32_t vlan_present:1;
15911 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
15912 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
15914 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
15915 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
15917 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
15918 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
15919 mplsoudp, "mplsoudp_decap-with-vlan");
15920 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
15921 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
15922 pos_token, "ip-version");
15923 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
15924 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
15925 ip_version, "ipv4#ipv6");
15927 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
15928 __attribute__((unused)) struct cmdline *cl,
15929 __attribute__((unused)) void *data)
15931 struct cmd_set_mplsoudp_decap_result *res = parsed_result;
15933 if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
15934 mplsoudp_decap_conf.select_vlan = 0;
15935 else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
15936 mplsoudp_decap_conf.select_vlan = 1;
15937 if (strcmp(res->ip_version, "ipv4") == 0)
15938 mplsoudp_decap_conf.select_ipv4 = 1;
15939 else if (strcmp(res->ip_version, "ipv6") == 0)
15940 mplsoudp_decap_conf.select_ipv4 = 0;
15943 cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
15944 .f = cmd_set_mplsoudp_decap_parsed,
15946 .help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
15948 (void *)&cmd_set_mplsoudp_decap_set,
15949 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
15950 (void *)&cmd_set_mplsoudp_decap_ip_version,
15951 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
15956 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
15957 .f = cmd_set_mplsoudp_decap_parsed,
15959 .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
15961 (void *)&cmd_set_mplsoudp_decap_set,
15962 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
15963 (void *)&cmd_set_mplsoudp_decap_ip_version,
15964 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
15969 /* Strict link priority scheduling mode setting */
15971 cmd_strict_link_prio_parsed(
15972 void *parsed_result,
15973 __attribute__((unused)) struct cmdline *cl,
15974 __attribute__((unused)) void *data)
15976 struct cmd_vf_tc_bw_result *res = parsed_result;
15977 int ret = -ENOTSUP;
15979 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15982 #ifdef RTE_LIBRTE_I40E_PMD
15983 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
15990 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
15993 printf("invalid port_id %d\n", res->port_id);
15996 printf("function not implemented\n");
15999 printf("programming error: (%s)\n", strerror(-ret));
16003 cmdline_parse_inst_t cmd_strict_link_prio = {
16004 .f = cmd_strict_link_prio_parsed,
16006 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
16008 (void *)&cmd_vf_tc_bw_set,
16009 (void *)&cmd_vf_tc_bw_tx,
16010 (void *)&cmd_vf_tc_bw_strict_link_prio,
16011 (void *)&cmd_vf_tc_bw_port_id,
16012 (void *)&cmd_vf_tc_bw_tc_map,
16017 /* Load dynamic device personalization*/
16018 struct cmd_ddp_add_result {
16019 cmdline_fixed_string_t ddp;
16020 cmdline_fixed_string_t add;
16025 cmdline_parse_token_string_t cmd_ddp_add_ddp =
16026 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
16027 cmdline_parse_token_string_t cmd_ddp_add_add =
16028 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
16029 cmdline_parse_token_num_t cmd_ddp_add_port_id =
16030 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
16031 cmdline_parse_token_string_t cmd_ddp_add_filepath =
16032 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
16035 cmd_ddp_add_parsed(
16036 void *parsed_result,
16037 __attribute__((unused)) struct cmdline *cl,
16038 __attribute__((unused)) void *data)
16040 struct cmd_ddp_add_result *res = parsed_result;
16046 int ret = -ENOTSUP;
16048 if (!all_ports_stopped()) {
16049 printf("Please stop all ports first\n");
16053 filepath = strdup(res->filepath);
16054 if (filepath == NULL) {
16055 printf("Failed to allocate memory\n");
16058 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
16060 buff = open_file(file_fld[0], &size);
16062 free((void *)filepath);
16066 #ifdef RTE_LIBRTE_I40E_PMD
16067 if (ret == -ENOTSUP)
16068 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16070 RTE_PMD_I40E_PKG_OP_WR_ADD);
16073 if (ret == -EEXIST)
16074 printf("Profile has already existed.\n");
16076 printf("Failed to load profile.\n");
16077 else if (file_num == 2)
16078 save_file(file_fld[1], buff, size);
16081 free((void *)filepath);
16084 cmdline_parse_inst_t cmd_ddp_add = {
16085 .f = cmd_ddp_add_parsed,
16087 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
16089 (void *)&cmd_ddp_add_ddp,
16090 (void *)&cmd_ddp_add_add,
16091 (void *)&cmd_ddp_add_port_id,
16092 (void *)&cmd_ddp_add_filepath,
16097 /* Delete dynamic device personalization*/
16098 struct cmd_ddp_del_result {
16099 cmdline_fixed_string_t ddp;
16100 cmdline_fixed_string_t del;
16105 cmdline_parse_token_string_t cmd_ddp_del_ddp =
16106 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
16107 cmdline_parse_token_string_t cmd_ddp_del_del =
16108 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
16109 cmdline_parse_token_num_t cmd_ddp_del_port_id =
16110 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
16111 cmdline_parse_token_string_t cmd_ddp_del_filepath =
16112 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
16115 cmd_ddp_del_parsed(
16116 void *parsed_result,
16117 __attribute__((unused)) struct cmdline *cl,
16118 __attribute__((unused)) void *data)
16120 struct cmd_ddp_del_result *res = parsed_result;
16123 int ret = -ENOTSUP;
16125 if (!all_ports_stopped()) {
16126 printf("Please stop all ports first\n");
16130 buff = open_file(res->filepath, &size);
16134 #ifdef RTE_LIBRTE_I40E_PMD
16135 if (ret == -ENOTSUP)
16136 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16138 RTE_PMD_I40E_PKG_OP_WR_DEL);
16141 if (ret == -EACCES)
16142 printf("Profile does not exist.\n");
16144 printf("Failed to delete profile.\n");
16149 cmdline_parse_inst_t cmd_ddp_del = {
16150 .f = cmd_ddp_del_parsed,
16152 .help_str = "ddp del <port_id> <backup_profile_path>",
16154 (void *)&cmd_ddp_del_ddp,
16155 (void *)&cmd_ddp_del_del,
16156 (void *)&cmd_ddp_del_port_id,
16157 (void *)&cmd_ddp_del_filepath,
16162 /* Get dynamic device personalization profile info */
16163 struct cmd_ddp_info_result {
16164 cmdline_fixed_string_t ddp;
16165 cmdline_fixed_string_t get;
16166 cmdline_fixed_string_t info;
16170 cmdline_parse_token_string_t cmd_ddp_info_ddp =
16171 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
16172 cmdline_parse_token_string_t cmd_ddp_info_get =
16173 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
16174 cmdline_parse_token_string_t cmd_ddp_info_info =
16175 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
16176 cmdline_parse_token_string_t cmd_ddp_info_filepath =
16177 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
16180 cmd_ddp_info_parsed(
16181 void *parsed_result,
16182 __attribute__((unused)) struct cmdline *cl,
16183 __attribute__((unused)) void *data)
16185 struct cmd_ddp_info_result *res = parsed_result;
16188 int ret = -ENOTSUP;
16189 #ifdef RTE_LIBRTE_I40E_PMD
16192 uint32_t buff_size = 0;
16193 struct rte_pmd_i40e_profile_info info;
16194 uint32_t dev_num = 0;
16195 struct rte_pmd_i40e_ddp_device_id *devs;
16196 uint32_t proto_num = 0;
16197 struct rte_pmd_i40e_proto_info *proto = NULL;
16198 uint32_t pctype_num = 0;
16199 struct rte_pmd_i40e_ptype_info *pctype;
16200 uint32_t ptype_num = 0;
16201 struct rte_pmd_i40e_ptype_info *ptype;
16206 pkg = open_file(res->filepath, &pkg_size);
16210 #ifdef RTE_LIBRTE_I40E_PMD
16211 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16212 (uint8_t *)&info, sizeof(info),
16213 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
16215 printf("Global Track id: 0x%x\n", info.track_id);
16216 printf("Global Version: %d.%d.%d.%d\n",
16217 info.version.major,
16218 info.version.minor,
16219 info.version.update,
16220 info.version.draft);
16221 printf("Global Package name: %s\n\n", info.name);
16224 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16225 (uint8_t *)&info, sizeof(info),
16226 RTE_PMD_I40E_PKG_INFO_HEADER);
16228 printf("i40e Profile Track id: 0x%x\n", info.track_id);
16229 printf("i40e Profile Version: %d.%d.%d.%d\n",
16230 info.version.major,
16231 info.version.minor,
16232 info.version.update,
16233 info.version.draft);
16234 printf("i40e Profile name: %s\n\n", info.name);
16237 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16238 (uint8_t *)&buff_size, sizeof(buff_size),
16239 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
16240 if (!ret && buff_size) {
16241 buff = (uint8_t *)malloc(buff_size);
16243 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16245 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
16247 printf("Package Notes:\n%s\n\n", buff);
16252 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16253 (uint8_t *)&dev_num, sizeof(dev_num),
16254 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
16255 if (!ret && dev_num) {
16256 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
16257 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
16259 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16260 (uint8_t *)devs, buff_size,
16261 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
16263 printf("List of supported devices:\n");
16264 for (i = 0; i < dev_num; i++) {
16265 printf(" %04X:%04X %04X:%04X\n",
16266 devs[i].vendor_dev_id >> 16,
16267 devs[i].vendor_dev_id & 0xFFFF,
16268 devs[i].sub_vendor_dev_id >> 16,
16269 devs[i].sub_vendor_dev_id & 0xFFFF);
16277 /* get information about protocols and packet types */
16278 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16279 (uint8_t *)&proto_num, sizeof(proto_num),
16280 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
16281 if (ret || !proto_num)
16282 goto no_print_return;
16284 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
16285 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
16287 goto no_print_return;
16289 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
16291 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
16293 printf("List of used protocols:\n");
16294 for (i = 0; i < proto_num; i++)
16295 printf(" %2u: %s\n", proto[i].proto_id,
16299 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16300 (uint8_t *)&pctype_num, sizeof(pctype_num),
16301 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
16302 if (ret || !pctype_num)
16303 goto no_print_pctypes;
16305 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16306 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16308 goto no_print_pctypes;
16310 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
16312 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
16315 goto no_print_pctypes;
16318 printf("List of defined packet classification types:\n");
16319 for (i = 0; i < pctype_num; i++) {
16320 printf(" %2u:", pctype[i].ptype_id);
16321 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
16322 proto_id = pctype[i].protocols[j];
16323 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
16324 for (n = 0; n < proto_num; n++) {
16325 if (proto[n].proto_id == proto_id) {
16326 printf(" %s", proto[n].name);
16339 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
16341 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
16342 if (ret || !ptype_num)
16343 goto no_print_return;
16345 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16346 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16348 goto no_print_return;
16350 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
16352 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
16355 goto no_print_return;
16357 printf("List of defined packet types:\n");
16358 for (i = 0; i < ptype_num; i++) {
16359 printf(" %2u:", ptype[i].ptype_id);
16360 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
16361 proto_id = ptype[i].protocols[j];
16362 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
16363 for (n = 0; n < proto_num; n++) {
16364 if (proto[n].proto_id == proto_id) {
16365 printf(" %s", proto[n].name);
16381 if (ret == -ENOTSUP)
16382 printf("Function not supported in PMD driver\n");
16386 cmdline_parse_inst_t cmd_ddp_get_info = {
16387 .f = cmd_ddp_info_parsed,
16389 .help_str = "ddp get info <profile_path>",
16391 (void *)&cmd_ddp_info_ddp,
16392 (void *)&cmd_ddp_info_get,
16393 (void *)&cmd_ddp_info_info,
16394 (void *)&cmd_ddp_info_filepath,
16399 /* Get dynamic device personalization profile info list*/
16400 #define PROFILE_INFO_SIZE 48
16401 #define MAX_PROFILE_NUM 16
16403 struct cmd_ddp_get_list_result {
16404 cmdline_fixed_string_t ddp;
16405 cmdline_fixed_string_t get;
16406 cmdline_fixed_string_t list;
16410 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
16411 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
16412 cmdline_parse_token_string_t cmd_ddp_get_list_get =
16413 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
16414 cmdline_parse_token_string_t cmd_ddp_get_list_list =
16415 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
16416 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
16417 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
16420 cmd_ddp_get_list_parsed(
16421 __attribute__((unused)) void *parsed_result,
16422 __attribute__((unused)) struct cmdline *cl,
16423 __attribute__((unused)) void *data)
16425 #ifdef RTE_LIBRTE_I40E_PMD
16426 struct cmd_ddp_get_list_result *res = parsed_result;
16427 struct rte_pmd_i40e_profile_list *p_list;
16428 struct rte_pmd_i40e_profile_info *p_info;
16433 int ret = -ENOTSUP;
16435 #ifdef RTE_LIBRTE_I40E_PMD
16436 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
16437 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
16439 printf("%s: Failed to malloc buffer\n", __func__);
16441 if (ret == -ENOTSUP)
16442 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
16443 (uint8_t *)p_list, size);
16446 p_num = p_list->p_count;
16447 printf("Profile number is: %d\n\n", p_num);
16449 for (i = 0; i < p_num; i++) {
16450 p_info = &p_list->p_info[i];
16451 printf("Profile %d:\n", i);
16452 printf("Track id: 0x%x\n", p_info->track_id);
16453 printf("Version: %d.%d.%d.%d\n",
16454 p_info->version.major,
16455 p_info->version.minor,
16456 p_info->version.update,
16457 p_info->version.draft);
16458 printf("Profile name: %s\n\n", p_info->name);
16466 printf("Failed to get ddp list\n");
16469 cmdline_parse_inst_t cmd_ddp_get_list = {
16470 .f = cmd_ddp_get_list_parsed,
16472 .help_str = "ddp get list <port_id>",
16474 (void *)&cmd_ddp_get_list_ddp,
16475 (void *)&cmd_ddp_get_list_get,
16476 (void *)&cmd_ddp_get_list_list,
16477 (void *)&cmd_ddp_get_list_port_id,
16482 /* Configure input set */
16483 struct cmd_cfg_input_set_result {
16484 cmdline_fixed_string_t port;
16485 cmdline_fixed_string_t cfg;
16487 cmdline_fixed_string_t pctype;
16489 cmdline_fixed_string_t inset_type;
16490 cmdline_fixed_string_t opt;
16491 cmdline_fixed_string_t field;
16496 cmd_cfg_input_set_parsed(
16497 __attribute__((unused)) void *parsed_result,
16498 __attribute__((unused)) struct cmdline *cl,
16499 __attribute__((unused)) void *data)
16501 #ifdef RTE_LIBRTE_I40E_PMD
16502 struct cmd_cfg_input_set_result *res = parsed_result;
16503 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
16504 struct rte_pmd_i40e_inset inset;
16506 int ret = -ENOTSUP;
16508 if (!all_ports_stopped()) {
16509 printf("Please stop all ports first\n");
16513 #ifdef RTE_LIBRTE_I40E_PMD
16514 if (!strcmp(res->inset_type, "hash_inset"))
16515 inset_type = INSET_HASH;
16516 else if (!strcmp(res->inset_type, "fdir_inset"))
16517 inset_type = INSET_FDIR;
16518 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
16519 inset_type = INSET_FDIR_FLX;
16520 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
16521 &inset, inset_type);
16523 printf("Failed to get input set.\n");
16527 if (!strcmp(res->opt, "get")) {
16528 ret = rte_pmd_i40e_inset_field_get(inset.inset,
16531 printf("Field index %d is enabled.\n", res->field_idx);
16533 printf("Field index %d is disabled.\n", res->field_idx);
16535 } else if (!strcmp(res->opt, "set"))
16536 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
16538 else if (!strcmp(res->opt, "clear"))
16539 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
16542 printf("Failed to configure input set field.\n");
16546 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
16547 &inset, inset_type);
16549 printf("Failed to set input set.\n");
16554 if (ret == -ENOTSUP)
16555 printf("Function not supported\n");
16558 cmdline_parse_token_string_t cmd_cfg_input_set_port =
16559 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16561 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
16562 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16564 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
16565 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16567 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
16568 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16570 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
16571 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16573 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
16574 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16576 "hash_inset#fdir_inset#fdir_flx_inset");
16577 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
16578 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16579 opt, "get#set#clear");
16580 cmdline_parse_token_string_t cmd_cfg_input_set_field =
16581 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16583 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
16584 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16587 cmdline_parse_inst_t cmd_cfg_input_set = {
16588 .f = cmd_cfg_input_set_parsed,
16590 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
16591 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
16593 (void *)&cmd_cfg_input_set_port,
16594 (void *)&cmd_cfg_input_set_cfg,
16595 (void *)&cmd_cfg_input_set_port_id,
16596 (void *)&cmd_cfg_input_set_pctype,
16597 (void *)&cmd_cfg_input_set_pctype_id,
16598 (void *)&cmd_cfg_input_set_inset_type,
16599 (void *)&cmd_cfg_input_set_opt,
16600 (void *)&cmd_cfg_input_set_field,
16601 (void *)&cmd_cfg_input_set_field_idx,
16606 /* Clear input set */
16607 struct cmd_clear_input_set_result {
16608 cmdline_fixed_string_t port;
16609 cmdline_fixed_string_t cfg;
16611 cmdline_fixed_string_t pctype;
16613 cmdline_fixed_string_t inset_type;
16614 cmdline_fixed_string_t clear;
16615 cmdline_fixed_string_t all;
16619 cmd_clear_input_set_parsed(
16620 __attribute__((unused)) void *parsed_result,
16621 __attribute__((unused)) struct cmdline *cl,
16622 __attribute__((unused)) void *data)
16624 #ifdef RTE_LIBRTE_I40E_PMD
16625 struct cmd_clear_input_set_result *res = parsed_result;
16626 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
16627 struct rte_pmd_i40e_inset inset;
16629 int ret = -ENOTSUP;
16631 if (!all_ports_stopped()) {
16632 printf("Please stop all ports first\n");
16636 #ifdef RTE_LIBRTE_I40E_PMD
16637 if (!strcmp(res->inset_type, "hash_inset"))
16638 inset_type = INSET_HASH;
16639 else if (!strcmp(res->inset_type, "fdir_inset"))
16640 inset_type = INSET_FDIR;
16641 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
16642 inset_type = INSET_FDIR_FLX;
16644 memset(&inset, 0, sizeof(inset));
16646 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
16647 &inset, inset_type);
16649 printf("Failed to clear input set.\n");
16655 if (ret == -ENOTSUP)
16656 printf("Function not supported\n");
16659 cmdline_parse_token_string_t cmd_clear_input_set_port =
16660 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16662 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
16663 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16665 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
16666 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
16668 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
16669 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16671 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
16672 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
16674 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
16675 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16677 "hash_inset#fdir_inset#fdir_flx_inset");
16678 cmdline_parse_token_string_t cmd_clear_input_set_clear =
16679 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16681 cmdline_parse_token_string_t cmd_clear_input_set_all =
16682 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16685 cmdline_parse_inst_t cmd_clear_input_set = {
16686 .f = cmd_clear_input_set_parsed,
16688 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
16689 "fdir_inset|fdir_flx_inset clear all",
16691 (void *)&cmd_clear_input_set_port,
16692 (void *)&cmd_clear_input_set_cfg,
16693 (void *)&cmd_clear_input_set_port_id,
16694 (void *)&cmd_clear_input_set_pctype,
16695 (void *)&cmd_clear_input_set_pctype_id,
16696 (void *)&cmd_clear_input_set_inset_type,
16697 (void *)&cmd_clear_input_set_clear,
16698 (void *)&cmd_clear_input_set_all,
16703 /* show vf stats */
16705 /* Common result structure for show vf stats */
16706 struct cmd_show_vf_stats_result {
16707 cmdline_fixed_string_t show;
16708 cmdline_fixed_string_t vf;
16709 cmdline_fixed_string_t stats;
16714 /* Common CLI fields show vf stats*/
16715 cmdline_parse_token_string_t cmd_show_vf_stats_show =
16716 TOKEN_STRING_INITIALIZER
16717 (struct cmd_show_vf_stats_result,
16719 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
16720 TOKEN_STRING_INITIALIZER
16721 (struct cmd_show_vf_stats_result,
16723 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
16724 TOKEN_STRING_INITIALIZER
16725 (struct cmd_show_vf_stats_result,
16727 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
16728 TOKEN_NUM_INITIALIZER
16729 (struct cmd_show_vf_stats_result,
16731 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
16732 TOKEN_NUM_INITIALIZER
16733 (struct cmd_show_vf_stats_result,
16737 cmd_show_vf_stats_parsed(
16738 void *parsed_result,
16739 __attribute__((unused)) struct cmdline *cl,
16740 __attribute__((unused)) void *data)
16742 struct cmd_show_vf_stats_result *res = parsed_result;
16743 struct rte_eth_stats stats;
16744 int ret = -ENOTSUP;
16745 static const char *nic_stats_border = "########################";
16747 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16750 memset(&stats, 0, sizeof(stats));
16752 #ifdef RTE_LIBRTE_I40E_PMD
16753 if (ret == -ENOTSUP)
16754 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
16758 #ifdef RTE_LIBRTE_BNXT_PMD
16759 if (ret == -ENOTSUP)
16760 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
16769 printf("invalid vf_id %d\n", res->vf_id);
16772 printf("invalid port_id %d\n", res->port_id);
16775 printf("function not implemented\n");
16778 printf("programming error: (%s)\n", strerror(-ret));
16781 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
16782 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
16784 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
16786 stats.ipackets, stats.imissed, stats.ibytes);
16787 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
16788 printf(" RX-nombuf: %-10"PRIu64"\n",
16790 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
16792 stats.opackets, stats.oerrors, stats.obytes);
16794 printf(" %s############################%s\n",
16795 nic_stats_border, nic_stats_border);
16798 cmdline_parse_inst_t cmd_show_vf_stats = {
16799 .f = cmd_show_vf_stats_parsed,
16801 .help_str = "show vf stats <port_id> <vf_id>",
16803 (void *)&cmd_show_vf_stats_show,
16804 (void *)&cmd_show_vf_stats_vf,
16805 (void *)&cmd_show_vf_stats_stats,
16806 (void *)&cmd_show_vf_stats_port_id,
16807 (void *)&cmd_show_vf_stats_vf_id,
16812 /* clear vf stats */
16814 /* Common result structure for clear vf stats */
16815 struct cmd_clear_vf_stats_result {
16816 cmdline_fixed_string_t clear;
16817 cmdline_fixed_string_t vf;
16818 cmdline_fixed_string_t stats;
16823 /* Common CLI fields clear vf stats*/
16824 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
16825 TOKEN_STRING_INITIALIZER
16826 (struct cmd_clear_vf_stats_result,
16828 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
16829 TOKEN_STRING_INITIALIZER
16830 (struct cmd_clear_vf_stats_result,
16832 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
16833 TOKEN_STRING_INITIALIZER
16834 (struct cmd_clear_vf_stats_result,
16836 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
16837 TOKEN_NUM_INITIALIZER
16838 (struct cmd_clear_vf_stats_result,
16840 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
16841 TOKEN_NUM_INITIALIZER
16842 (struct cmd_clear_vf_stats_result,
16846 cmd_clear_vf_stats_parsed(
16847 void *parsed_result,
16848 __attribute__((unused)) struct cmdline *cl,
16849 __attribute__((unused)) void *data)
16851 struct cmd_clear_vf_stats_result *res = parsed_result;
16852 int ret = -ENOTSUP;
16854 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16857 #ifdef RTE_LIBRTE_I40E_PMD
16858 if (ret == -ENOTSUP)
16859 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
16862 #ifdef RTE_LIBRTE_BNXT_PMD
16863 if (ret == -ENOTSUP)
16864 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
16872 printf("invalid vf_id %d\n", res->vf_id);
16875 printf("invalid port_id %d\n", res->port_id);
16878 printf("function not implemented\n");
16881 printf("programming error: (%s)\n", strerror(-ret));
16885 cmdline_parse_inst_t cmd_clear_vf_stats = {
16886 .f = cmd_clear_vf_stats_parsed,
16888 .help_str = "clear vf stats <port_id> <vf_id>",
16890 (void *)&cmd_clear_vf_stats_clear,
16891 (void *)&cmd_clear_vf_stats_vf,
16892 (void *)&cmd_clear_vf_stats_stats,
16893 (void *)&cmd_clear_vf_stats_port_id,
16894 (void *)&cmd_clear_vf_stats_vf_id,
16899 /* port config pctype mapping reset */
16901 /* Common result structure for port config pctype mapping reset */
16902 struct cmd_pctype_mapping_reset_result {
16903 cmdline_fixed_string_t port;
16904 cmdline_fixed_string_t config;
16906 cmdline_fixed_string_t pctype;
16907 cmdline_fixed_string_t mapping;
16908 cmdline_fixed_string_t reset;
16911 /* Common CLI fields for port config pctype mapping reset*/
16912 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
16913 TOKEN_STRING_INITIALIZER
16914 (struct cmd_pctype_mapping_reset_result,
16916 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
16917 TOKEN_STRING_INITIALIZER
16918 (struct cmd_pctype_mapping_reset_result,
16920 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
16921 TOKEN_NUM_INITIALIZER
16922 (struct cmd_pctype_mapping_reset_result,
16924 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
16925 TOKEN_STRING_INITIALIZER
16926 (struct cmd_pctype_mapping_reset_result,
16928 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
16929 TOKEN_STRING_INITIALIZER
16930 (struct cmd_pctype_mapping_reset_result,
16931 mapping, "mapping");
16932 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
16933 TOKEN_STRING_INITIALIZER
16934 (struct cmd_pctype_mapping_reset_result,
16938 cmd_pctype_mapping_reset_parsed(
16939 void *parsed_result,
16940 __attribute__((unused)) struct cmdline *cl,
16941 __attribute__((unused)) void *data)
16943 struct cmd_pctype_mapping_reset_result *res = parsed_result;
16944 int ret = -ENOTSUP;
16946 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16949 #ifdef RTE_LIBRTE_I40E_PMD
16950 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
16957 printf("invalid port_id %d\n", res->port_id);
16960 printf("function not implemented\n");
16963 printf("programming error: (%s)\n", strerror(-ret));
16967 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
16968 .f = cmd_pctype_mapping_reset_parsed,
16970 .help_str = "port config <port_id> pctype mapping reset",
16972 (void *)&cmd_pctype_mapping_reset_port,
16973 (void *)&cmd_pctype_mapping_reset_config,
16974 (void *)&cmd_pctype_mapping_reset_port_id,
16975 (void *)&cmd_pctype_mapping_reset_pctype,
16976 (void *)&cmd_pctype_mapping_reset_mapping,
16977 (void *)&cmd_pctype_mapping_reset_reset,
16982 /* show port pctype mapping */
16984 /* Common result structure for show port pctype mapping */
16985 struct cmd_pctype_mapping_get_result {
16986 cmdline_fixed_string_t show;
16987 cmdline_fixed_string_t port;
16989 cmdline_fixed_string_t pctype;
16990 cmdline_fixed_string_t mapping;
16993 /* Common CLI fields for pctype mapping get */
16994 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
16995 TOKEN_STRING_INITIALIZER
16996 (struct cmd_pctype_mapping_get_result,
16998 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
16999 TOKEN_STRING_INITIALIZER
17000 (struct cmd_pctype_mapping_get_result,
17002 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
17003 TOKEN_NUM_INITIALIZER
17004 (struct cmd_pctype_mapping_get_result,
17006 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
17007 TOKEN_STRING_INITIALIZER
17008 (struct cmd_pctype_mapping_get_result,
17010 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
17011 TOKEN_STRING_INITIALIZER
17012 (struct cmd_pctype_mapping_get_result,
17013 mapping, "mapping");
17016 cmd_pctype_mapping_get_parsed(
17017 void *parsed_result,
17018 __attribute__((unused)) struct cmdline *cl,
17019 __attribute__((unused)) void *data)
17021 struct cmd_pctype_mapping_get_result *res = parsed_result;
17022 int ret = -ENOTSUP;
17023 #ifdef RTE_LIBRTE_I40E_PMD
17024 struct rte_pmd_i40e_flow_type_mapping
17025 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
17026 int i, j, first_pctype;
17029 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17032 #ifdef RTE_LIBRTE_I40E_PMD
17033 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
17040 printf("invalid port_id %d\n", res->port_id);
17043 printf("function not implemented\n");
17046 printf("programming error: (%s)\n", strerror(-ret));
17050 #ifdef RTE_LIBRTE_I40E_PMD
17051 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
17052 if (mapping[i].pctype != 0ULL) {
17055 printf("pctype: ");
17056 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
17057 if (mapping[i].pctype & (1ULL << j)) {
17058 printf(first_pctype ?
17059 "%02d" : ",%02d", j);
17063 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
17069 cmdline_parse_inst_t cmd_pctype_mapping_get = {
17070 .f = cmd_pctype_mapping_get_parsed,
17072 .help_str = "show port <port_id> pctype mapping",
17074 (void *)&cmd_pctype_mapping_get_show,
17075 (void *)&cmd_pctype_mapping_get_port,
17076 (void *)&cmd_pctype_mapping_get_port_id,
17077 (void *)&cmd_pctype_mapping_get_pctype,
17078 (void *)&cmd_pctype_mapping_get_mapping,
17083 /* port config pctype mapping update */
17085 /* Common result structure for port config pctype mapping update */
17086 struct cmd_pctype_mapping_update_result {
17087 cmdline_fixed_string_t port;
17088 cmdline_fixed_string_t config;
17090 cmdline_fixed_string_t pctype;
17091 cmdline_fixed_string_t mapping;
17092 cmdline_fixed_string_t update;
17093 cmdline_fixed_string_t pctype_list;
17094 uint16_t flow_type;
17097 /* Common CLI fields for pctype mapping update*/
17098 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
17099 TOKEN_STRING_INITIALIZER
17100 (struct cmd_pctype_mapping_update_result,
17102 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
17103 TOKEN_STRING_INITIALIZER
17104 (struct cmd_pctype_mapping_update_result,
17106 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
17107 TOKEN_NUM_INITIALIZER
17108 (struct cmd_pctype_mapping_update_result,
17110 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
17111 TOKEN_STRING_INITIALIZER
17112 (struct cmd_pctype_mapping_update_result,
17114 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
17115 TOKEN_STRING_INITIALIZER
17116 (struct cmd_pctype_mapping_update_result,
17117 mapping, "mapping");
17118 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
17119 TOKEN_STRING_INITIALIZER
17120 (struct cmd_pctype_mapping_update_result,
17122 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
17123 TOKEN_STRING_INITIALIZER
17124 (struct cmd_pctype_mapping_update_result,
17125 pctype_list, NULL);
17126 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
17127 TOKEN_NUM_INITIALIZER
17128 (struct cmd_pctype_mapping_update_result,
17129 flow_type, UINT16);
17132 cmd_pctype_mapping_update_parsed(
17133 void *parsed_result,
17134 __attribute__((unused)) struct cmdline *cl,
17135 __attribute__((unused)) void *data)
17137 struct cmd_pctype_mapping_update_result *res = parsed_result;
17138 int ret = -ENOTSUP;
17139 #ifdef RTE_LIBRTE_I40E_PMD
17140 struct rte_pmd_i40e_flow_type_mapping mapping;
17142 unsigned int nb_item;
17143 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
17146 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17149 #ifdef RTE_LIBRTE_I40E_PMD
17150 nb_item = parse_item_list(res->pctype_list, "pctypes",
17151 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
17152 mapping.flow_type = res->flow_type;
17153 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
17154 mapping.pctype |= (1ULL << pctype_list[i]);
17155 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
17165 printf("invalid pctype or flow type\n");
17168 printf("invalid port_id %d\n", res->port_id);
17171 printf("function not implemented\n");
17174 printf("programming error: (%s)\n", strerror(-ret));
17178 cmdline_parse_inst_t cmd_pctype_mapping_update = {
17179 .f = cmd_pctype_mapping_update_parsed,
17181 .help_str = "port config <port_id> pctype mapping update"
17182 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
17184 (void *)&cmd_pctype_mapping_update_port,
17185 (void *)&cmd_pctype_mapping_update_config,
17186 (void *)&cmd_pctype_mapping_update_port_id,
17187 (void *)&cmd_pctype_mapping_update_pctype,
17188 (void *)&cmd_pctype_mapping_update_mapping,
17189 (void *)&cmd_pctype_mapping_update_update,
17190 (void *)&cmd_pctype_mapping_update_pc_type,
17191 (void *)&cmd_pctype_mapping_update_flow_type,
17196 /* ptype mapping get */
17198 /* Common result structure for ptype mapping get */
17199 struct cmd_ptype_mapping_get_result {
17200 cmdline_fixed_string_t ptype;
17201 cmdline_fixed_string_t mapping;
17202 cmdline_fixed_string_t get;
17204 uint8_t valid_only;
17207 /* Common CLI fields for ptype mapping get */
17208 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
17209 TOKEN_STRING_INITIALIZER
17210 (struct cmd_ptype_mapping_get_result,
17212 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
17213 TOKEN_STRING_INITIALIZER
17214 (struct cmd_ptype_mapping_get_result,
17215 mapping, "mapping");
17216 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
17217 TOKEN_STRING_INITIALIZER
17218 (struct cmd_ptype_mapping_get_result,
17220 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
17221 TOKEN_NUM_INITIALIZER
17222 (struct cmd_ptype_mapping_get_result,
17224 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
17225 TOKEN_NUM_INITIALIZER
17226 (struct cmd_ptype_mapping_get_result,
17227 valid_only, UINT8);
17230 cmd_ptype_mapping_get_parsed(
17231 void *parsed_result,
17232 __attribute__((unused)) struct cmdline *cl,
17233 __attribute__((unused)) void *data)
17235 struct cmd_ptype_mapping_get_result *res = parsed_result;
17236 int ret = -ENOTSUP;
17237 #ifdef RTE_LIBRTE_I40E_PMD
17238 int max_ptype_num = 256;
17239 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
17244 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17247 #ifdef RTE_LIBRTE_I40E_PMD
17248 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
17259 printf("invalid port_id %d\n", res->port_id);
17262 printf("function not implemented\n");
17265 printf("programming error: (%s)\n", strerror(-ret));
17268 #ifdef RTE_LIBRTE_I40E_PMD
17270 for (i = 0; i < count; i++)
17271 printf("%3d\t0x%08x\n",
17272 mapping[i].hw_ptype, mapping[i].sw_ptype);
17277 cmdline_parse_inst_t cmd_ptype_mapping_get = {
17278 .f = cmd_ptype_mapping_get_parsed,
17280 .help_str = "ptype mapping get <port_id> <valid_only>",
17282 (void *)&cmd_ptype_mapping_get_ptype,
17283 (void *)&cmd_ptype_mapping_get_mapping,
17284 (void *)&cmd_ptype_mapping_get_get,
17285 (void *)&cmd_ptype_mapping_get_port_id,
17286 (void *)&cmd_ptype_mapping_get_valid_only,
17291 /* ptype mapping replace */
17293 /* Common result structure for ptype mapping replace */
17294 struct cmd_ptype_mapping_replace_result {
17295 cmdline_fixed_string_t ptype;
17296 cmdline_fixed_string_t mapping;
17297 cmdline_fixed_string_t replace;
17304 /* Common CLI fields for ptype mapping replace */
17305 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
17306 TOKEN_STRING_INITIALIZER
17307 (struct cmd_ptype_mapping_replace_result,
17309 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
17310 TOKEN_STRING_INITIALIZER
17311 (struct cmd_ptype_mapping_replace_result,
17312 mapping, "mapping");
17313 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
17314 TOKEN_STRING_INITIALIZER
17315 (struct cmd_ptype_mapping_replace_result,
17316 replace, "replace");
17317 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
17318 TOKEN_NUM_INITIALIZER
17319 (struct cmd_ptype_mapping_replace_result,
17321 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
17322 TOKEN_NUM_INITIALIZER
17323 (struct cmd_ptype_mapping_replace_result,
17325 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
17326 TOKEN_NUM_INITIALIZER
17327 (struct cmd_ptype_mapping_replace_result,
17329 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
17330 TOKEN_NUM_INITIALIZER
17331 (struct cmd_ptype_mapping_replace_result,
17335 cmd_ptype_mapping_replace_parsed(
17336 void *parsed_result,
17337 __attribute__((unused)) struct cmdline *cl,
17338 __attribute__((unused)) void *data)
17340 struct cmd_ptype_mapping_replace_result *res = parsed_result;
17341 int ret = -ENOTSUP;
17343 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17346 #ifdef RTE_LIBRTE_I40E_PMD
17347 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
17357 printf("invalid ptype 0x%8x or 0x%8x\n",
17358 res->target, res->pkt_type);
17361 printf("invalid port_id %d\n", res->port_id);
17364 printf("function not implemented\n");
17367 printf("programming error: (%s)\n", strerror(-ret));
17371 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
17372 .f = cmd_ptype_mapping_replace_parsed,
17375 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
17377 (void *)&cmd_ptype_mapping_replace_ptype,
17378 (void *)&cmd_ptype_mapping_replace_mapping,
17379 (void *)&cmd_ptype_mapping_replace_replace,
17380 (void *)&cmd_ptype_mapping_replace_port_id,
17381 (void *)&cmd_ptype_mapping_replace_target,
17382 (void *)&cmd_ptype_mapping_replace_mask,
17383 (void *)&cmd_ptype_mapping_replace_pkt_type,
17388 /* ptype mapping reset */
17390 /* Common result structure for ptype mapping reset */
17391 struct cmd_ptype_mapping_reset_result {
17392 cmdline_fixed_string_t ptype;
17393 cmdline_fixed_string_t mapping;
17394 cmdline_fixed_string_t reset;
17398 /* Common CLI fields for ptype mapping reset*/
17399 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
17400 TOKEN_STRING_INITIALIZER
17401 (struct cmd_ptype_mapping_reset_result,
17403 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
17404 TOKEN_STRING_INITIALIZER
17405 (struct cmd_ptype_mapping_reset_result,
17406 mapping, "mapping");
17407 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
17408 TOKEN_STRING_INITIALIZER
17409 (struct cmd_ptype_mapping_reset_result,
17411 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
17412 TOKEN_NUM_INITIALIZER
17413 (struct cmd_ptype_mapping_reset_result,
17417 cmd_ptype_mapping_reset_parsed(
17418 void *parsed_result,
17419 __attribute__((unused)) struct cmdline *cl,
17420 __attribute__((unused)) void *data)
17422 struct cmd_ptype_mapping_reset_result *res = parsed_result;
17423 int ret = -ENOTSUP;
17425 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17428 #ifdef RTE_LIBRTE_I40E_PMD
17429 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
17436 printf("invalid port_id %d\n", res->port_id);
17439 printf("function not implemented\n");
17442 printf("programming error: (%s)\n", strerror(-ret));
17446 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
17447 .f = cmd_ptype_mapping_reset_parsed,
17449 .help_str = "ptype mapping reset <port_id>",
17451 (void *)&cmd_ptype_mapping_reset_ptype,
17452 (void *)&cmd_ptype_mapping_reset_mapping,
17453 (void *)&cmd_ptype_mapping_reset_reset,
17454 (void *)&cmd_ptype_mapping_reset_port_id,
17459 /* ptype mapping update */
17461 /* Common result structure for ptype mapping update */
17462 struct cmd_ptype_mapping_update_result {
17463 cmdline_fixed_string_t ptype;
17464 cmdline_fixed_string_t mapping;
17465 cmdline_fixed_string_t reset;
17471 /* Common CLI fields for ptype mapping update*/
17472 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
17473 TOKEN_STRING_INITIALIZER
17474 (struct cmd_ptype_mapping_update_result,
17476 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
17477 TOKEN_STRING_INITIALIZER
17478 (struct cmd_ptype_mapping_update_result,
17479 mapping, "mapping");
17480 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
17481 TOKEN_STRING_INITIALIZER
17482 (struct cmd_ptype_mapping_update_result,
17484 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
17485 TOKEN_NUM_INITIALIZER
17486 (struct cmd_ptype_mapping_update_result,
17488 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
17489 TOKEN_NUM_INITIALIZER
17490 (struct cmd_ptype_mapping_update_result,
17492 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
17493 TOKEN_NUM_INITIALIZER
17494 (struct cmd_ptype_mapping_update_result,
17498 cmd_ptype_mapping_update_parsed(
17499 void *parsed_result,
17500 __attribute__((unused)) struct cmdline *cl,
17501 __attribute__((unused)) void *data)
17503 struct cmd_ptype_mapping_update_result *res = parsed_result;
17504 int ret = -ENOTSUP;
17505 #ifdef RTE_LIBRTE_I40E_PMD
17506 struct rte_pmd_i40e_ptype_mapping mapping;
17508 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17511 #ifdef RTE_LIBRTE_I40E_PMD
17512 mapping.hw_ptype = res->hw_ptype;
17513 mapping.sw_ptype = res->sw_ptype;
17514 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
17524 printf("invalid ptype 0x%8x\n", res->sw_ptype);
17527 printf("invalid port_id %d\n", res->port_id);
17530 printf("function not implemented\n");
17533 printf("programming error: (%s)\n", strerror(-ret));
17537 cmdline_parse_inst_t cmd_ptype_mapping_update = {
17538 .f = cmd_ptype_mapping_update_parsed,
17540 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
17542 (void *)&cmd_ptype_mapping_update_ptype,
17543 (void *)&cmd_ptype_mapping_update_mapping,
17544 (void *)&cmd_ptype_mapping_update_update,
17545 (void *)&cmd_ptype_mapping_update_port_id,
17546 (void *)&cmd_ptype_mapping_update_hw_ptype,
17547 (void *)&cmd_ptype_mapping_update_sw_ptype,
17552 /* Common result structure for file commands */
17553 struct cmd_cmdfile_result {
17554 cmdline_fixed_string_t load;
17555 cmdline_fixed_string_t filename;
17558 /* Common CLI fields for file commands */
17559 cmdline_parse_token_string_t cmd_load_cmdfile =
17560 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
17561 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
17562 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
17565 cmd_load_from_file_parsed(
17566 void *parsed_result,
17567 __attribute__((unused)) struct cmdline *cl,
17568 __attribute__((unused)) void *data)
17570 struct cmd_cmdfile_result *res = parsed_result;
17572 cmdline_read_from_file(res->filename);
17575 cmdline_parse_inst_t cmd_load_from_file = {
17576 .f = cmd_load_from_file_parsed,
17578 .help_str = "load <filename>",
17580 (void *)&cmd_load_cmdfile,
17581 (void *)&cmd_load_cmdfile_filename,
17586 /* Get Rx offloads capabilities */
17587 struct cmd_rx_offload_get_capa_result {
17588 cmdline_fixed_string_t show;
17589 cmdline_fixed_string_t port;
17591 cmdline_fixed_string_t rx_offload;
17592 cmdline_fixed_string_t capabilities;
17595 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
17596 TOKEN_STRING_INITIALIZER
17597 (struct cmd_rx_offload_get_capa_result,
17599 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
17600 TOKEN_STRING_INITIALIZER
17601 (struct cmd_rx_offload_get_capa_result,
17603 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
17604 TOKEN_NUM_INITIALIZER
17605 (struct cmd_rx_offload_get_capa_result,
17607 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
17608 TOKEN_STRING_INITIALIZER
17609 (struct cmd_rx_offload_get_capa_result,
17610 rx_offload, "rx_offload");
17611 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
17612 TOKEN_STRING_INITIALIZER
17613 (struct cmd_rx_offload_get_capa_result,
17614 capabilities, "capabilities");
17617 print_rx_offloads(uint64_t offloads)
17619 uint64_t single_offload;
17627 begin = __builtin_ctzll(offloads);
17628 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
17630 single_offload = 1 << begin;
17631 for (bit = begin; bit < end; bit++) {
17632 if (offloads & single_offload)
17634 rte_eth_dev_rx_offload_name(single_offload));
17635 single_offload <<= 1;
17640 cmd_rx_offload_get_capa_parsed(
17641 void *parsed_result,
17642 __attribute__((unused)) struct cmdline *cl,
17643 __attribute__((unused)) void *data)
17645 struct cmd_rx_offload_get_capa_result *res = parsed_result;
17646 struct rte_eth_dev_info dev_info;
17647 portid_t port_id = res->port_id;
17648 uint64_t queue_offloads;
17649 uint64_t port_offloads;
17651 rte_eth_dev_info_get(port_id, &dev_info);
17652 queue_offloads = dev_info.rx_queue_offload_capa;
17653 port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
17655 printf("Rx Offloading Capabilities of port %d :\n", port_id);
17656 printf(" Per Queue :");
17657 print_rx_offloads(queue_offloads);
17660 printf(" Per Port :");
17661 print_rx_offloads(port_offloads);
17665 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
17666 .f = cmd_rx_offload_get_capa_parsed,
17668 .help_str = "show port <port_id> rx_offload capabilities",
17670 (void *)&cmd_rx_offload_get_capa_show,
17671 (void *)&cmd_rx_offload_get_capa_port,
17672 (void *)&cmd_rx_offload_get_capa_port_id,
17673 (void *)&cmd_rx_offload_get_capa_rx_offload,
17674 (void *)&cmd_rx_offload_get_capa_capabilities,
17679 /* Get Rx offloads configuration */
17680 struct cmd_rx_offload_get_configuration_result {
17681 cmdline_fixed_string_t show;
17682 cmdline_fixed_string_t port;
17684 cmdline_fixed_string_t rx_offload;
17685 cmdline_fixed_string_t configuration;
17688 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
17689 TOKEN_STRING_INITIALIZER
17690 (struct cmd_rx_offload_get_configuration_result,
17692 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
17693 TOKEN_STRING_INITIALIZER
17694 (struct cmd_rx_offload_get_configuration_result,
17696 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
17697 TOKEN_NUM_INITIALIZER
17698 (struct cmd_rx_offload_get_configuration_result,
17700 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
17701 TOKEN_STRING_INITIALIZER
17702 (struct cmd_rx_offload_get_configuration_result,
17703 rx_offload, "rx_offload");
17704 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
17705 TOKEN_STRING_INITIALIZER
17706 (struct cmd_rx_offload_get_configuration_result,
17707 configuration, "configuration");
17710 cmd_rx_offload_get_configuration_parsed(
17711 void *parsed_result,
17712 __attribute__((unused)) struct cmdline *cl,
17713 __attribute__((unused)) void *data)
17715 struct cmd_rx_offload_get_configuration_result *res = parsed_result;
17716 struct rte_eth_dev_info dev_info;
17717 portid_t port_id = res->port_id;
17718 struct rte_port *port = &ports[port_id];
17719 uint64_t port_offloads;
17720 uint64_t queue_offloads;
17721 uint16_t nb_rx_queues;
17724 printf("Rx Offloading Configuration of port %d :\n", port_id);
17726 port_offloads = port->dev_conf.rxmode.offloads;
17728 print_rx_offloads(port_offloads);
17731 rte_eth_dev_info_get(port_id, &dev_info);
17732 nb_rx_queues = dev_info.nb_rx_queues;
17733 for (q = 0; q < nb_rx_queues; q++) {
17734 queue_offloads = port->rx_conf[q].offloads;
17735 printf(" Queue[%2d] :", q);
17736 print_rx_offloads(queue_offloads);
17742 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
17743 .f = cmd_rx_offload_get_configuration_parsed,
17745 .help_str = "show port <port_id> rx_offload configuration",
17747 (void *)&cmd_rx_offload_get_configuration_show,
17748 (void *)&cmd_rx_offload_get_configuration_port,
17749 (void *)&cmd_rx_offload_get_configuration_port_id,
17750 (void *)&cmd_rx_offload_get_configuration_rx_offload,
17751 (void *)&cmd_rx_offload_get_configuration_configuration,
17756 /* Enable/Disable a per port offloading */
17757 struct cmd_config_per_port_rx_offload_result {
17758 cmdline_fixed_string_t port;
17759 cmdline_fixed_string_t config;
17761 cmdline_fixed_string_t rx_offload;
17762 cmdline_fixed_string_t offload;
17763 cmdline_fixed_string_t on_off;
17766 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
17767 TOKEN_STRING_INITIALIZER
17768 (struct cmd_config_per_port_rx_offload_result,
17770 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
17771 TOKEN_STRING_INITIALIZER
17772 (struct cmd_config_per_port_rx_offload_result,
17774 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
17775 TOKEN_NUM_INITIALIZER
17776 (struct cmd_config_per_port_rx_offload_result,
17778 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
17779 TOKEN_STRING_INITIALIZER
17780 (struct cmd_config_per_port_rx_offload_result,
17781 rx_offload, "rx_offload");
17782 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
17783 TOKEN_STRING_INITIALIZER
17784 (struct cmd_config_per_port_rx_offload_result,
17785 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
17786 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
17787 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
17788 "crc_strip#scatter#timestamp#security#keep_crc");
17789 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
17790 TOKEN_STRING_INITIALIZER
17791 (struct cmd_config_per_port_rx_offload_result,
17795 search_rx_offload(const char *name)
17797 uint64_t single_offload;
17798 const char *single_name;
17802 single_offload = 1;
17803 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
17804 single_name = rte_eth_dev_rx_offload_name(single_offload);
17805 if (!strcasecmp(single_name, name)) {
17809 single_offload <<= 1;
17813 return single_offload;
17819 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
17820 __attribute__((unused)) struct cmdline *cl,
17821 __attribute__((unused)) void *data)
17823 struct cmd_config_per_port_rx_offload_result *res = parsed_result;
17824 portid_t port_id = res->port_id;
17825 struct rte_eth_dev_info dev_info;
17826 struct rte_port *port = &ports[port_id];
17827 uint64_t single_offload;
17828 uint16_t nb_rx_queues;
17831 if (port->port_status != RTE_PORT_STOPPED) {
17832 printf("Error: Can't config offload when Port %d "
17833 "is not stopped\n", port_id);
17837 single_offload = search_rx_offload(res->offload);
17838 if (single_offload == 0) {
17839 printf("Unknown offload name: %s\n", res->offload);
17843 rte_eth_dev_info_get(port_id, &dev_info);
17844 nb_rx_queues = dev_info.nb_rx_queues;
17845 if (!strcmp(res->on_off, "on")) {
17846 port->dev_conf.rxmode.offloads |= single_offload;
17847 for (q = 0; q < nb_rx_queues; q++)
17848 port->rx_conf[q].offloads |= single_offload;
17850 port->dev_conf.rxmode.offloads &= ~single_offload;
17851 for (q = 0; q < nb_rx_queues; q++)
17852 port->rx_conf[q].offloads &= ~single_offload;
17855 cmd_reconfig_device_queue(port_id, 1, 1);
17858 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
17859 .f = cmd_config_per_port_rx_offload_parsed,
17861 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
17862 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
17863 "macsec_strip|header_split|vlan_filter|vlan_extend|"
17864 "jumbo_frame|crc_strip|scatter|timestamp|security|keep_crc "
17867 (void *)&cmd_config_per_port_rx_offload_result_port,
17868 (void *)&cmd_config_per_port_rx_offload_result_config,
17869 (void *)&cmd_config_per_port_rx_offload_result_port_id,
17870 (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
17871 (void *)&cmd_config_per_port_rx_offload_result_offload,
17872 (void *)&cmd_config_per_port_rx_offload_result_on_off,
17877 /* Enable/Disable a per queue offloading */
17878 struct cmd_config_per_queue_rx_offload_result {
17879 cmdline_fixed_string_t port;
17881 cmdline_fixed_string_t rxq;
17883 cmdline_fixed_string_t rx_offload;
17884 cmdline_fixed_string_t offload;
17885 cmdline_fixed_string_t on_off;
17888 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
17889 TOKEN_STRING_INITIALIZER
17890 (struct cmd_config_per_queue_rx_offload_result,
17892 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
17893 TOKEN_NUM_INITIALIZER
17894 (struct cmd_config_per_queue_rx_offload_result,
17896 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
17897 TOKEN_STRING_INITIALIZER
17898 (struct cmd_config_per_queue_rx_offload_result,
17900 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
17901 TOKEN_NUM_INITIALIZER
17902 (struct cmd_config_per_queue_rx_offload_result,
17904 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
17905 TOKEN_STRING_INITIALIZER
17906 (struct cmd_config_per_queue_rx_offload_result,
17907 rx_offload, "rx_offload");
17908 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
17909 TOKEN_STRING_INITIALIZER
17910 (struct cmd_config_per_queue_rx_offload_result,
17911 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
17912 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
17913 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
17914 "crc_strip#scatter#timestamp#security#keep_crc");
17915 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
17916 TOKEN_STRING_INITIALIZER
17917 (struct cmd_config_per_queue_rx_offload_result,
17921 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
17922 __attribute__((unused)) struct cmdline *cl,
17923 __attribute__((unused)) void *data)
17925 struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
17926 struct rte_eth_dev_info dev_info;
17927 portid_t port_id = res->port_id;
17928 uint16_t queue_id = res->queue_id;
17929 struct rte_port *port = &ports[port_id];
17930 uint64_t single_offload;
17932 if (port->port_status != RTE_PORT_STOPPED) {
17933 printf("Error: Can't config offload when Port %d "
17934 "is not stopped\n", port_id);
17938 rte_eth_dev_info_get(port_id, &dev_info);
17939 if (queue_id >= dev_info.nb_rx_queues) {
17940 printf("Error: input queue_id should be 0 ... "
17941 "%d\n", dev_info.nb_rx_queues - 1);
17945 single_offload = search_rx_offload(res->offload);
17946 if (single_offload == 0) {
17947 printf("Unknown offload name: %s\n", res->offload);
17951 if (!strcmp(res->on_off, "on"))
17952 port->rx_conf[queue_id].offloads |= single_offload;
17954 port->rx_conf[queue_id].offloads &= ~single_offload;
17956 cmd_reconfig_device_queue(port_id, 1, 1);
17959 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
17960 .f = cmd_config_per_queue_rx_offload_parsed,
17962 .help_str = "port <port_id> rxq <queue_id> rx_offload "
17963 "vlan_strip|ipv4_cksum|"
17964 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
17965 "macsec_strip|header_split|vlan_filter|vlan_extend|"
17966 "jumbo_frame|crc_strip|scatter|timestamp|security|keep_crc "
17969 (void *)&cmd_config_per_queue_rx_offload_result_port,
17970 (void *)&cmd_config_per_queue_rx_offload_result_port_id,
17971 (void *)&cmd_config_per_queue_rx_offload_result_rxq,
17972 (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
17973 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
17974 (void *)&cmd_config_per_queue_rx_offload_result_offload,
17975 (void *)&cmd_config_per_queue_rx_offload_result_on_off,
17980 /* Get Tx offloads capabilities */
17981 struct cmd_tx_offload_get_capa_result {
17982 cmdline_fixed_string_t show;
17983 cmdline_fixed_string_t port;
17985 cmdline_fixed_string_t tx_offload;
17986 cmdline_fixed_string_t capabilities;
17989 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
17990 TOKEN_STRING_INITIALIZER
17991 (struct cmd_tx_offload_get_capa_result,
17993 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
17994 TOKEN_STRING_INITIALIZER
17995 (struct cmd_tx_offload_get_capa_result,
17997 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
17998 TOKEN_NUM_INITIALIZER
17999 (struct cmd_tx_offload_get_capa_result,
18001 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
18002 TOKEN_STRING_INITIALIZER
18003 (struct cmd_tx_offload_get_capa_result,
18004 tx_offload, "tx_offload");
18005 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
18006 TOKEN_STRING_INITIALIZER
18007 (struct cmd_tx_offload_get_capa_result,
18008 capabilities, "capabilities");
18011 print_tx_offloads(uint64_t offloads)
18013 uint64_t single_offload;
18021 begin = __builtin_ctzll(offloads);
18022 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
18024 single_offload = 1 << begin;
18025 for (bit = begin; bit < end; bit++) {
18026 if (offloads & single_offload)
18028 rte_eth_dev_tx_offload_name(single_offload));
18029 single_offload <<= 1;
18034 cmd_tx_offload_get_capa_parsed(
18035 void *parsed_result,
18036 __attribute__((unused)) struct cmdline *cl,
18037 __attribute__((unused)) void *data)
18039 struct cmd_tx_offload_get_capa_result *res = parsed_result;
18040 struct rte_eth_dev_info dev_info;
18041 portid_t port_id = res->port_id;
18042 uint64_t queue_offloads;
18043 uint64_t port_offloads;
18045 rte_eth_dev_info_get(port_id, &dev_info);
18046 queue_offloads = dev_info.tx_queue_offload_capa;
18047 port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
18049 printf("Tx Offloading Capabilities of port %d :\n", port_id);
18050 printf(" Per Queue :");
18051 print_tx_offloads(queue_offloads);
18054 printf(" Per Port :");
18055 print_tx_offloads(port_offloads);
18059 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
18060 .f = cmd_tx_offload_get_capa_parsed,
18062 .help_str = "show port <port_id> tx_offload capabilities",
18064 (void *)&cmd_tx_offload_get_capa_show,
18065 (void *)&cmd_tx_offload_get_capa_port,
18066 (void *)&cmd_tx_offload_get_capa_port_id,
18067 (void *)&cmd_tx_offload_get_capa_tx_offload,
18068 (void *)&cmd_tx_offload_get_capa_capabilities,
18073 /* Get Tx offloads configuration */
18074 struct cmd_tx_offload_get_configuration_result {
18075 cmdline_fixed_string_t show;
18076 cmdline_fixed_string_t port;
18078 cmdline_fixed_string_t tx_offload;
18079 cmdline_fixed_string_t configuration;
18082 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
18083 TOKEN_STRING_INITIALIZER
18084 (struct cmd_tx_offload_get_configuration_result,
18086 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
18087 TOKEN_STRING_INITIALIZER
18088 (struct cmd_tx_offload_get_configuration_result,
18090 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
18091 TOKEN_NUM_INITIALIZER
18092 (struct cmd_tx_offload_get_configuration_result,
18094 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
18095 TOKEN_STRING_INITIALIZER
18096 (struct cmd_tx_offload_get_configuration_result,
18097 tx_offload, "tx_offload");
18098 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
18099 TOKEN_STRING_INITIALIZER
18100 (struct cmd_tx_offload_get_configuration_result,
18101 configuration, "configuration");
18104 cmd_tx_offload_get_configuration_parsed(
18105 void *parsed_result,
18106 __attribute__((unused)) struct cmdline *cl,
18107 __attribute__((unused)) void *data)
18109 struct cmd_tx_offload_get_configuration_result *res = parsed_result;
18110 struct rte_eth_dev_info dev_info;
18111 portid_t port_id = res->port_id;
18112 struct rte_port *port = &ports[port_id];
18113 uint64_t port_offloads;
18114 uint64_t queue_offloads;
18115 uint16_t nb_tx_queues;
18118 printf("Tx Offloading Configuration of port %d :\n", port_id);
18120 port_offloads = port->dev_conf.txmode.offloads;
18122 print_tx_offloads(port_offloads);
18125 rte_eth_dev_info_get(port_id, &dev_info);
18126 nb_tx_queues = dev_info.nb_tx_queues;
18127 for (q = 0; q < nb_tx_queues; q++) {
18128 queue_offloads = port->tx_conf[q].offloads;
18129 printf(" Queue[%2d] :", q);
18130 print_tx_offloads(queue_offloads);
18136 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
18137 .f = cmd_tx_offload_get_configuration_parsed,
18139 .help_str = "show port <port_id> tx_offload configuration",
18141 (void *)&cmd_tx_offload_get_configuration_show,
18142 (void *)&cmd_tx_offload_get_configuration_port,
18143 (void *)&cmd_tx_offload_get_configuration_port_id,
18144 (void *)&cmd_tx_offload_get_configuration_tx_offload,
18145 (void *)&cmd_tx_offload_get_configuration_configuration,
18150 /* Enable/Disable a per port offloading */
18151 struct cmd_config_per_port_tx_offload_result {
18152 cmdline_fixed_string_t port;
18153 cmdline_fixed_string_t config;
18155 cmdline_fixed_string_t tx_offload;
18156 cmdline_fixed_string_t offload;
18157 cmdline_fixed_string_t on_off;
18160 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
18161 TOKEN_STRING_INITIALIZER
18162 (struct cmd_config_per_port_tx_offload_result,
18164 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
18165 TOKEN_STRING_INITIALIZER
18166 (struct cmd_config_per_port_tx_offload_result,
18168 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
18169 TOKEN_NUM_INITIALIZER
18170 (struct cmd_config_per_port_tx_offload_result,
18172 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
18173 TOKEN_STRING_INITIALIZER
18174 (struct cmd_config_per_port_tx_offload_result,
18175 tx_offload, "tx_offload");
18176 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
18177 TOKEN_STRING_INITIALIZER
18178 (struct cmd_config_per_port_tx_offload_result,
18179 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18180 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18181 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18182 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18183 "mt_lockfree#multi_segs#mbuf_fast_free#security#"
18185 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
18186 TOKEN_STRING_INITIALIZER
18187 (struct cmd_config_per_port_tx_offload_result,
18191 search_tx_offload(const char *name)
18193 uint64_t single_offload;
18194 const char *single_name;
18198 single_offload = 1;
18199 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
18200 single_name = rte_eth_dev_tx_offload_name(single_offload);
18201 if (!strcasecmp(single_name, name)) {
18204 } else if (!strcasecmp(single_name, "UNKNOWN"))
18206 else if (single_name == NULL)
18208 single_offload <<= 1;
18212 return single_offload;
18218 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
18219 __attribute__((unused)) struct cmdline *cl,
18220 __attribute__((unused)) void *data)
18222 struct cmd_config_per_port_tx_offload_result *res = parsed_result;
18223 portid_t port_id = res->port_id;
18224 struct rte_eth_dev_info dev_info;
18225 struct rte_port *port = &ports[port_id];
18226 uint64_t single_offload;
18227 uint16_t nb_tx_queues;
18230 if (port->port_status != RTE_PORT_STOPPED) {
18231 printf("Error: Can't config offload when Port %d "
18232 "is not stopped\n", port_id);
18236 single_offload = search_tx_offload(res->offload);
18237 if (single_offload == 0) {
18238 printf("Unknown offload name: %s\n", res->offload);
18242 rte_eth_dev_info_get(port_id, &dev_info);
18243 nb_tx_queues = dev_info.nb_tx_queues;
18244 if (!strcmp(res->on_off, "on")) {
18245 port->dev_conf.txmode.offloads |= single_offload;
18246 for (q = 0; q < nb_tx_queues; q++)
18247 port->tx_conf[q].offloads |= single_offload;
18249 port->dev_conf.txmode.offloads &= ~single_offload;
18250 for (q = 0; q < nb_tx_queues; q++)
18251 port->tx_conf[q].offloads &= ~single_offload;
18254 cmd_reconfig_device_queue(port_id, 1, 1);
18257 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
18258 .f = cmd_config_per_port_tx_offload_parsed,
18260 .help_str = "port config <port_id> tx_offload "
18261 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
18262 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
18263 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
18264 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
18265 "mt_lockfree|multi_segs|mbuf_fast_free|security|"
18266 "match_metadata on|off",
18268 (void *)&cmd_config_per_port_tx_offload_result_port,
18269 (void *)&cmd_config_per_port_tx_offload_result_config,
18270 (void *)&cmd_config_per_port_tx_offload_result_port_id,
18271 (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
18272 (void *)&cmd_config_per_port_tx_offload_result_offload,
18273 (void *)&cmd_config_per_port_tx_offload_result_on_off,
18278 /* Enable/Disable a per queue offloading */
18279 struct cmd_config_per_queue_tx_offload_result {
18280 cmdline_fixed_string_t port;
18282 cmdline_fixed_string_t txq;
18284 cmdline_fixed_string_t tx_offload;
18285 cmdline_fixed_string_t offload;
18286 cmdline_fixed_string_t on_off;
18289 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
18290 TOKEN_STRING_INITIALIZER
18291 (struct cmd_config_per_queue_tx_offload_result,
18293 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
18294 TOKEN_NUM_INITIALIZER
18295 (struct cmd_config_per_queue_tx_offload_result,
18297 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
18298 TOKEN_STRING_INITIALIZER
18299 (struct cmd_config_per_queue_tx_offload_result,
18301 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
18302 TOKEN_NUM_INITIALIZER
18303 (struct cmd_config_per_queue_tx_offload_result,
18305 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
18306 TOKEN_STRING_INITIALIZER
18307 (struct cmd_config_per_queue_tx_offload_result,
18308 tx_offload, "tx_offload");
18309 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
18310 TOKEN_STRING_INITIALIZER
18311 (struct cmd_config_per_queue_tx_offload_result,
18312 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18313 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18314 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18315 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18316 "mt_lockfree#multi_segs#mbuf_fast_free#security");
18317 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
18318 TOKEN_STRING_INITIALIZER
18319 (struct cmd_config_per_queue_tx_offload_result,
18323 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
18324 __attribute__((unused)) struct cmdline *cl,
18325 __attribute__((unused)) void *data)
18327 struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
18328 struct rte_eth_dev_info dev_info;
18329 portid_t port_id = res->port_id;
18330 uint16_t queue_id = res->queue_id;
18331 struct rte_port *port = &ports[port_id];
18332 uint64_t single_offload;
18334 if (port->port_status != RTE_PORT_STOPPED) {
18335 printf("Error: Can't config offload when Port %d "
18336 "is not stopped\n", port_id);
18340 rte_eth_dev_info_get(port_id, &dev_info);
18341 if (queue_id >= dev_info.nb_tx_queues) {
18342 printf("Error: input queue_id should be 0 ... "
18343 "%d\n", dev_info.nb_tx_queues - 1);
18347 single_offload = search_tx_offload(res->offload);
18348 if (single_offload == 0) {
18349 printf("Unknown offload name: %s\n", res->offload);
18353 if (!strcmp(res->on_off, "on"))
18354 port->tx_conf[queue_id].offloads |= single_offload;
18356 port->tx_conf[queue_id].offloads &= ~single_offload;
18358 cmd_reconfig_device_queue(port_id, 1, 1);
18361 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
18362 .f = cmd_config_per_queue_tx_offload_parsed,
18364 .help_str = "port <port_id> txq <queue_id> tx_offload "
18365 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
18366 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
18367 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
18368 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
18369 "mt_lockfree|multi_segs|mbuf_fast_free|security "
18372 (void *)&cmd_config_per_queue_tx_offload_result_port,
18373 (void *)&cmd_config_per_queue_tx_offload_result_port_id,
18374 (void *)&cmd_config_per_queue_tx_offload_result_txq,
18375 (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
18376 (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
18377 (void *)&cmd_config_per_queue_tx_offload_result_offload,
18378 (void *)&cmd_config_per_queue_tx_offload_result_on_off,
18383 /* *** configure tx_metadata for specific port *** */
18384 struct cmd_config_tx_metadata_specific_result {
18385 cmdline_fixed_string_t port;
18386 cmdline_fixed_string_t keyword;
18388 cmdline_fixed_string_t item;
18393 cmd_config_tx_metadata_specific_parsed(void *parsed_result,
18394 __attribute__((unused)) struct cmdline *cl,
18395 __attribute__((unused)) void *data)
18397 struct cmd_config_tx_metadata_specific_result *res = parsed_result;
18399 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
18401 ports[res->port_id].tx_metadata = rte_cpu_to_be_32(res->value);
18402 /* Add/remove callback to insert valid metadata in every Tx packet. */
18403 if (ports[res->port_id].tx_metadata)
18404 add_tx_md_callback(res->port_id);
18406 remove_tx_md_callback(res->port_id);
18409 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
18410 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18412 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
18413 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18414 keyword, "config");
18415 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
18416 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18418 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
18419 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18420 item, "tx_metadata");
18421 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
18422 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18425 cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
18426 .f = cmd_config_tx_metadata_specific_parsed,
18428 .help_str = "port config <port_id> tx_metadata <value>",
18430 (void *)&cmd_config_tx_metadata_specific_port,
18431 (void *)&cmd_config_tx_metadata_specific_keyword,
18432 (void *)&cmd_config_tx_metadata_specific_id,
18433 (void *)&cmd_config_tx_metadata_specific_item,
18434 (void *)&cmd_config_tx_metadata_specific_value,
18439 /* *** display tx_metadata per port configuration *** */
18440 struct cmd_show_tx_metadata_result {
18441 cmdline_fixed_string_t cmd_show;
18442 cmdline_fixed_string_t cmd_port;
18443 cmdline_fixed_string_t cmd_keyword;
18448 cmd_show_tx_metadata_parsed(void *parsed_result,
18449 __attribute__((unused)) struct cmdline *cl,
18450 __attribute__((unused)) void *data)
18452 struct cmd_show_tx_metadata_result *res = parsed_result;
18454 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
18455 printf("invalid port id %u\n", res->cmd_pid);
18458 if (!strcmp(res->cmd_keyword, "tx_metadata")) {
18459 printf("Port %u tx_metadata: %u\n", res->cmd_pid,
18460 ports[res->cmd_pid].tx_metadata);
18464 cmdline_parse_token_string_t cmd_show_tx_metadata_show =
18465 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
18467 cmdline_parse_token_string_t cmd_show_tx_metadata_port =
18468 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
18470 cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
18471 TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
18473 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
18474 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
18475 cmd_keyword, "tx_metadata");
18477 cmdline_parse_inst_t cmd_show_tx_metadata = {
18478 .f = cmd_show_tx_metadata_parsed,
18480 .help_str = "show port <port_id> tx_metadata",
18482 (void *)&cmd_show_tx_metadata_show,
18483 (void *)&cmd_show_tx_metadata_port,
18484 (void *)&cmd_show_tx_metadata_pid,
18485 (void *)&cmd_show_tx_metadata_keyword,
18490 /* ******************************************************************************** */
18492 /* list of instructions */
18493 cmdline_parse_ctx_t main_ctx[] = {
18494 (cmdline_parse_inst_t *)&cmd_help_brief,
18495 (cmdline_parse_inst_t *)&cmd_help_long,
18496 (cmdline_parse_inst_t *)&cmd_quit,
18497 (cmdline_parse_inst_t *)&cmd_load_from_file,
18498 (cmdline_parse_inst_t *)&cmd_showport,
18499 (cmdline_parse_inst_t *)&cmd_showqueue,
18500 (cmdline_parse_inst_t *)&cmd_showportall,
18501 (cmdline_parse_inst_t *)&cmd_showcfg,
18502 (cmdline_parse_inst_t *)&cmd_start,
18503 (cmdline_parse_inst_t *)&cmd_start_tx_first,
18504 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
18505 (cmdline_parse_inst_t *)&cmd_set_link_up,
18506 (cmdline_parse_inst_t *)&cmd_set_link_down,
18507 (cmdline_parse_inst_t *)&cmd_reset,
18508 (cmdline_parse_inst_t *)&cmd_set_numbers,
18509 (cmdline_parse_inst_t *)&cmd_set_log,
18510 (cmdline_parse_inst_t *)&cmd_set_txpkts,
18511 (cmdline_parse_inst_t *)&cmd_set_txsplit,
18512 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
18513 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
18514 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
18515 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
18516 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
18517 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
18518 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
18519 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
18520 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
18521 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
18522 (cmdline_parse_inst_t *)&cmd_set_link_check,
18523 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
18524 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
18525 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
18526 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
18527 #ifdef RTE_LIBRTE_PMD_BOND
18528 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
18529 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
18530 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
18531 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
18532 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
18533 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
18534 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
18535 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
18536 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
18537 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
18538 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
18540 (cmdline_parse_inst_t *)&cmd_vlan_offload,
18541 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
18542 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
18543 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
18544 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
18545 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
18546 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
18547 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
18548 (cmdline_parse_inst_t *)&cmd_csum_set,
18549 (cmdline_parse_inst_t *)&cmd_csum_show,
18550 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
18551 (cmdline_parse_inst_t *)&cmd_tso_set,
18552 (cmdline_parse_inst_t *)&cmd_tso_show,
18553 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
18554 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
18555 (cmdline_parse_inst_t *)&cmd_gro_enable,
18556 (cmdline_parse_inst_t *)&cmd_gro_flush,
18557 (cmdline_parse_inst_t *)&cmd_gro_show,
18558 (cmdline_parse_inst_t *)&cmd_gso_enable,
18559 (cmdline_parse_inst_t *)&cmd_gso_size,
18560 (cmdline_parse_inst_t *)&cmd_gso_show,
18561 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
18562 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
18563 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
18564 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
18565 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
18566 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
18567 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
18568 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
18569 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
18570 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
18571 (cmdline_parse_inst_t *)&cmd_config_dcb,
18572 (cmdline_parse_inst_t *)&cmd_read_reg,
18573 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
18574 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
18575 (cmdline_parse_inst_t *)&cmd_write_reg,
18576 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
18577 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
18578 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
18579 (cmdline_parse_inst_t *)&cmd_stop,
18580 (cmdline_parse_inst_t *)&cmd_mac_addr,
18581 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
18582 (cmdline_parse_inst_t *)&cmd_set_qmap,
18583 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
18584 (cmdline_parse_inst_t *)&cmd_operate_port,
18585 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
18586 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
18587 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
18588 (cmdline_parse_inst_t *)&cmd_set_port_setup_on,
18589 (cmdline_parse_inst_t *)&cmd_config_speed_all,
18590 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
18591 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
18592 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
18593 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
18594 (cmdline_parse_inst_t *)&cmd_config_mtu,
18595 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
18596 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
18597 (cmdline_parse_inst_t *)&cmd_config_rss,
18598 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
18599 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
18600 (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
18601 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
18602 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
18603 (cmdline_parse_inst_t *)&cmd_showport_reta,
18604 (cmdline_parse_inst_t *)&cmd_config_burst,
18605 (cmdline_parse_inst_t *)&cmd_config_thresh,
18606 (cmdline_parse_inst_t *)&cmd_config_threshold,
18607 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
18608 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
18609 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
18610 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
18611 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
18612 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
18613 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
18614 (cmdline_parse_inst_t *)&cmd_global_config,
18615 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
18616 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
18617 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
18618 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
18619 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
18620 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
18621 (cmdline_parse_inst_t *)&cmd_dump,
18622 (cmdline_parse_inst_t *)&cmd_dump_one,
18623 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
18624 (cmdline_parse_inst_t *)&cmd_syn_filter,
18625 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
18626 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
18627 (cmdline_parse_inst_t *)&cmd_flex_filter,
18628 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
18629 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
18630 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
18631 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
18632 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
18633 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
18634 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
18635 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
18636 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
18637 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
18638 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
18639 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
18640 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
18641 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
18642 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
18643 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
18644 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
18645 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
18646 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
18647 (cmdline_parse_inst_t *)&cmd_flow,
18648 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
18649 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
18650 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
18651 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
18652 (cmdline_parse_inst_t *)&cmd_create_port_meter,
18653 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
18654 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
18655 (cmdline_parse_inst_t *)&cmd_del_port_meter,
18656 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
18657 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
18658 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
18659 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
18660 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
18661 (cmdline_parse_inst_t *)&cmd_mcast_addr,
18662 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
18663 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
18664 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
18665 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
18666 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
18667 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
18668 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
18669 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
18670 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
18671 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
18672 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
18673 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
18674 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
18675 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
18676 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
18677 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
18678 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
18679 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
18680 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
18681 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
18682 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
18683 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
18684 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
18685 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
18686 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
18687 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
18688 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
18689 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
18690 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
18691 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
18692 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
18693 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
18694 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
18695 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
18696 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
18697 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
18698 (cmdline_parse_inst_t *)&cmd_set_port_tm_hierarchy_default,
18700 (cmdline_parse_inst_t *)&cmd_set_vxlan,
18701 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
18702 (cmdline_parse_inst_t *)&cmd_set_nvgre,
18703 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
18704 (cmdline_parse_inst_t *)&cmd_set_l2_encap,
18705 (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
18706 (cmdline_parse_inst_t *)&cmd_set_l2_decap,
18707 (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
18708 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
18709 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
18710 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
18711 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
18712 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
18713 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
18714 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
18715 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
18716 (cmdline_parse_inst_t *)&cmd_ddp_add,
18717 (cmdline_parse_inst_t *)&cmd_ddp_del,
18718 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
18719 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
18720 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
18721 (cmdline_parse_inst_t *)&cmd_clear_input_set,
18722 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
18723 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
18724 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
18725 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
18726 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
18727 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
18729 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
18730 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
18731 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
18732 (cmdline_parse_inst_t *)&cmd_queue_region,
18733 (cmdline_parse_inst_t *)&cmd_region_flowtype,
18734 (cmdline_parse_inst_t *)&cmd_user_priority_region,
18735 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
18736 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
18737 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
18738 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
18739 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
18740 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
18741 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
18742 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
18743 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
18744 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
18745 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
18746 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
18747 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
18748 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
18749 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
18750 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
18751 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
18752 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
18753 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
18754 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
18755 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
18756 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
18757 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
18758 (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
18759 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
18760 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
18761 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
18762 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
18763 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
18764 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
18765 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
18766 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
18767 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
18768 #ifdef RTE_LIBRTE_BPF
18769 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
18770 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
18772 (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
18773 (cmdline_parse_inst_t *)&cmd_show_tx_metadata,
18777 /* read cmdline commands from file */
18779 cmdline_read_from_file(const char *filename)
18781 struct cmdline *cl;
18783 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
18785 printf("Failed to create file based cmdline context: %s\n",
18790 cmdline_interact(cl);
18795 printf("Read CLI commands from %s\n", filename);
18798 /* prompt function, called from main on MASTER lcore */
18802 /* initialize non-constant commands */
18803 cmd_set_fwd_mode_init();
18804 cmd_set_fwd_retry_mode_init();
18806 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
18807 if (testpmd_cl == NULL)
18809 cmdline_interact(testpmd_cl);
18810 cmdline_stdin_exit(testpmd_cl);
18816 if (testpmd_cl != NULL)
18817 cmdline_quit(testpmd_cl);
18821 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
18823 if (id == (portid_t)RTE_PORT_ALL) {
18826 RTE_ETH_FOREACH_DEV(pid) {
18827 /* check if need_reconfig has been set to 1 */
18828 if (ports[pid].need_reconfig == 0)
18829 ports[pid].need_reconfig = dev;
18830 /* check if need_reconfig_queues has been set to 1 */
18831 if (ports[pid].need_reconfig_queues == 0)
18832 ports[pid].need_reconfig_queues = queue;
18834 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
18835 /* check if need_reconfig has been set to 1 */
18836 if (ports[id].need_reconfig == 0)
18837 ports[id].need_reconfig = dev;
18838 /* check if need_reconfig_queues has been set to 1 */
18839 if (ports[id].need_reconfig_queues == 0)
18840 ports[id].need_reconfig_queues = queue;