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 "vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src"
798 " (udp-src) udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl)"
799 " ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src)"
800 " eth-dst (eth-dst)\n"
801 " Configure the VXLAN encapsulation for flows.\n\n"
803 "nvgre ip-version (ipv4|ipv6) tni (tni) ip-src"
804 " (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst"
806 " Configure the NVGRE encapsulation for flows.\n\n"
808 "nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)"
809 " ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)"
810 " eth-src (eth-src) eth-dst (eth-dst)\n"
811 " Configure the NVGRE encapsulation for flows.\n\n"
813 , list_pkt_forwarding_modes()
817 if (show_all || !strcmp(res->section, "ports")) {
823 "----------------\n\n"
825 "port start (port_id|all)\n"
826 " Start all ports or port_id.\n\n"
828 "port stop (port_id|all)\n"
829 " Stop all ports or port_id.\n\n"
831 "port close (port_id|all)\n"
832 " Close all ports or port_id.\n\n"
834 "port attach (ident)\n"
835 " Attach physical or virtual dev by pci address or virtual device name\n\n"
837 "port detach (port_id)\n"
838 " Detach physical or virtual dev by port_id\n\n"
840 "port config (port_id|all)"
841 " speed (10|100|1000|10000|25000|40000|50000|100000|auto)"
842 " duplex (half|full|auto)\n"
843 " Set speed and duplex for all ports or port_id\n\n"
845 "port config (port_id|all) loopback (mode)\n"
846 " Set loopback mode for all ports or port_id\n\n"
848 "port config all (rxq|txq|rxd|txd) (value)\n"
849 " Set number for rxq/txq/rxd/txd.\n\n"
851 "port config all max-pkt-len (value)\n"
852 " Set the max packet length.\n\n"
854 "port config all (crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|hw-vlan-filter|"
855 "hw-vlan-strip|hw-vlan-extend|drop-en)"
857 " Set crc-strip/scatter/rx-checksum/hardware-vlan/drop_en"
860 "port config all rss (all|default|ip|tcp|udp|sctp|"
861 "ether|port|vxlan|geneve|nvgre|none|<flowtype_id>)\n"
862 " Set the RSS mode.\n\n"
864 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
865 " Set the RSS redirection table.\n\n"
867 "port config (port_id) dcb vt (on|off) (traffic_class)"
869 " Set the DCB mode.\n\n"
871 "port config all burst (value)\n"
872 " Set the number of packets per burst.\n\n"
874 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
876 " Set the ring prefetch/host/writeback threshold"
877 " for tx/rx queue.\n\n"
879 "port config all (txfreet|txrst|rxfreet) (value)\n"
880 " Set free threshold for rx/tx, or set"
881 " tx rs bit threshold.\n\n"
882 "port config mtu X value\n"
883 " Set the MTU of port X to a given value\n\n"
885 "port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n"
886 " Set a rx/tx queue's ring size configuration, the new"
887 " value will take effect after command that (re-)start the port"
888 " or command that setup the specific queue\n\n"
890 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
891 " Start/stop a rx/tx queue of port X. Only take effect"
892 " when port X is started\n\n"
894 "port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n"
895 " Switch on/off a deferred start of port X rx/tx queue. Only"
896 " take effect when port X is stopped.\n\n"
898 "port (port_id) (rxq|txq) (queue_id) setup\n"
899 " Setup a rx/tx queue of port X.\n\n"
901 "port config (port_id|all) l2-tunnel E-tag ether-type"
903 " Set the value of E-tag ether-type.\n\n"
905 "port config (port_id|all) l2-tunnel E-tag"
906 " (enable|disable)\n"
907 " Enable/disable the E-tag support.\n\n"
909 "port config (port_id) pctype mapping reset\n"
910 " Reset flow type to pctype mapping on a port\n\n"
912 "port config (port_id) pctype mapping update"
913 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
914 " Update a flow type to pctype mapping item on a port\n\n"
916 "port config (port_id) pctype (pctype_id) hash_inset|"
917 "fdir_inset|fdir_flx_inset get|set|clear field\n"
919 " Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n"
921 "port config (port_id) pctype (pctype_id) hash_inset|"
922 "fdir_inset|fdir_flx_inset clear all"
923 " Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n"
925 "port config (port_id) udp_tunnel_port add|rm vxlan|geneve (udp_port)\n\n"
926 " Add/remove UDP tunnel port for tunneling offload\n\n"
930 if (show_all || !strcmp(res->section, "registers")) {
938 "read reg (port_id) (address)\n"
939 " Display value of a port register.\n\n"
941 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
942 " Display a port register bit field.\n\n"
944 "read regbit (port_id) (address) (bit_x)\n"
945 " Display a single port register bit.\n\n"
947 "write reg (port_id) (address) (value)\n"
948 " Set value of a port register.\n\n"
950 "write regfield (port_id) (address) (bit_x) (bit_y)"
952 " Set bit field of a port register.\n\n"
954 "write regbit (port_id) (address) (bit_x) (value)\n"
955 " Set single bit value of a port register.\n\n"
958 if (show_all || !strcmp(res->section, "filters")) {
966 "ethertype_filter (port_id) (add|del)"
967 " (mac_addr|mac_ignr) (mac_address) ethertype"
968 " (ether_type) (drop|fwd) queue (queue_id)\n"
969 " Add/Del an ethertype filter.\n\n"
971 "2tuple_filter (port_id) (add|del)"
972 " dst_port (dst_port_value) protocol (protocol_value)"
973 " mask (mask_value) tcp_flags (tcp_flags_value)"
974 " priority (prio_value) queue (queue_id)\n"
975 " Add/Del a 2tuple filter.\n\n"
977 "5tuple_filter (port_id) (add|del)"
978 " dst_ip (dst_address) src_ip (src_address)"
979 " dst_port (dst_port_value) src_port (src_port_value)"
980 " protocol (protocol_value)"
981 " mask (mask_value) tcp_flags (tcp_flags_value)"
982 " priority (prio_value) queue (queue_id)\n"
983 " Add/Del a 5tuple filter.\n\n"
985 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
986 " Add/Del syn filter.\n\n"
988 "flex_filter (port_id) (add|del) len (len_value)"
989 " bytes (bytes_value) mask (mask_value)"
990 " priority (prio_value) queue (queue_id)\n"
991 " Add/Del a flex filter.\n\n"
993 "flow_director_filter (port_id) mode IP (add|del|update)"
994 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
995 " src (src_ip_address) dst (dst_ip_address)"
996 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
997 " vlan (vlan_value) flexbytes (flexbytes_value)"
998 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
999 " fd_id (fd_id_value)\n"
1000 " Add/Del an IP type flow director filter.\n\n"
1002 "flow_director_filter (port_id) mode IP (add|del|update)"
1003 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
1004 " src (src_ip_address) (src_port)"
1005 " dst (dst_ip_address) (dst_port)"
1006 " tos (tos_value) ttl (ttl_value)"
1007 " vlan (vlan_value) flexbytes (flexbytes_value)"
1008 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
1009 " fd_id (fd_id_value)\n"
1010 " Add/Del an UDP/TCP type flow director filter.\n\n"
1012 "flow_director_filter (port_id) mode IP (add|del|update)"
1013 " flow (ipv4-sctp|ipv6-sctp)"
1014 " src (src_ip_address) (src_port)"
1015 " dst (dst_ip_address) (dst_port)"
1016 " tag (verification_tag) "
1017 " tos (tos_value) ttl (ttl_value)"
1018 " vlan (vlan_value)"
1019 " flexbytes (flexbytes_value) (drop|fwd)"
1020 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
1021 " Add/Del a SCTP type flow director filter.\n\n"
1023 "flow_director_filter (port_id) mode IP (add|del|update)"
1024 " flow l2_payload ether (ethertype)"
1025 " flexbytes (flexbytes_value) (drop|fwd)"
1026 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
1027 " Add/Del a l2 payload type flow director filter.\n\n"
1029 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
1030 " mac (mac_address) vlan (vlan_value)"
1031 " flexbytes (flexbytes_value) (drop|fwd)"
1032 " queue (queue_id) fd_id (fd_id_value)\n"
1033 " Add/Del a MAC-VLAN flow director filter.\n\n"
1035 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
1036 " mac (mac_address) vlan (vlan_value)"
1037 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
1038 " flexbytes (flexbytes_value) (drop|fwd)"
1039 " queue (queue_id) fd_id (fd_id_value)\n"
1040 " Add/Del a Tunnel flow director filter.\n\n"
1042 "flow_director_filter (port_id) mode raw (add|del|update)"
1043 " flow (flow_id) (drop|fwd) queue (queue_id)"
1044 " fd_id (fd_id_value) packet (packet file name)\n"
1045 " Add/Del a raw type flow director filter.\n\n"
1047 "flush_flow_director (port_id)\n"
1048 " Flush all flow director entries of a device.\n\n"
1050 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
1051 " src_mask (ipv4_src) (ipv6_src) (src_port)"
1052 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
1053 " Set flow director IP mask.\n\n"
1055 "flow_director_mask (port_id) mode MAC-VLAN"
1056 " vlan (vlan_value)\n"
1057 " Set flow director MAC-VLAN mask.\n\n"
1059 "flow_director_mask (port_id) mode Tunnel"
1060 " vlan (vlan_value) mac (mac_value)"
1061 " tunnel-type (tunnel_type_value)"
1062 " tunnel-id (tunnel_id_value)\n"
1063 " Set flow director Tunnel mask.\n\n"
1065 "flow_director_flex_mask (port_id)"
1066 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
1067 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
1069 " Configure mask of flex payload.\n\n"
1071 "flow_director_flex_payload (port_id)"
1072 " (raw|l2|l3|l4) (config)\n"
1073 " Configure flex payload selection.\n\n"
1075 "get_sym_hash_ena_per_port (port_id)\n"
1076 " get symmetric hash enable configuration per port.\n\n"
1078 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
1079 " set symmetric hash enable configuration per port"
1080 " to enable or disable.\n\n"
1082 "get_hash_global_config (port_id)\n"
1083 " Get the global configurations of hash filters.\n\n"
1085 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)"
1086 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1087 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
1088 " (enable|disable)\n"
1089 " Set the global configurations of hash filters.\n\n"
1091 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
1092 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1093 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1094 "l2_payload|<flowtype_id>) (ovlan|ivlan|src-ipv4|dst-ipv4|"
1095 "src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
1096 "ipv6-next-header|udp-src-port|udp-dst-port|"
1097 "tcp-src-port|tcp-dst-port|sctp-src-port|"
1098 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
1099 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
1100 "fld-8th|none) (select|add)\n"
1101 " Set the input set for hash.\n\n"
1103 "set_fdir_input_set (port_id) "
1104 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1105 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1106 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
1107 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
1108 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
1109 "udp-dst-port|tcp-src-port|tcp-dst-port|"
1110 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
1112 " Set the input set for FDir.\n\n"
1114 "flow validate {port_id}"
1115 " [group {group_id}] [priority {level}]"
1116 " [ingress] [egress]"
1117 " pattern {item} [/ {item} [...]] / end"
1118 " actions {action} [/ {action} [...]] / end\n"
1119 " Check whether a flow rule can be created.\n\n"
1121 "flow create {port_id}"
1122 " [group {group_id}] [priority {level}]"
1123 " [ingress] [egress]"
1124 " pattern {item} [/ {item} [...]] / end"
1125 " actions {action} [/ {action} [...]] / end\n"
1126 " Create a flow rule.\n\n"
1128 "flow destroy {port_id} rule {rule_id} [...]\n"
1129 " Destroy specific flow rules.\n\n"
1131 "flow flush {port_id}\n"
1132 " Destroy all flow rules.\n\n"
1134 "flow query {port_id} {rule_id} {action}\n"
1135 " Query an existing flow rule.\n\n"
1137 "flow list {port_id} [group {group_id}] [...]\n"
1138 " List existing flow rules sorted by priority,"
1139 " filtered by group identifiers.\n\n"
1141 "flow isolate {port_id} {boolean}\n"
1142 " Restrict ingress traffic to the defined"
1148 cmdline_parse_token_string_t cmd_help_long_help =
1149 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1151 cmdline_parse_token_string_t cmd_help_long_section =
1152 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1153 "all#control#display#config#"
1154 "ports#registers#filters");
1156 cmdline_parse_inst_t cmd_help_long = {
1157 .f = cmd_help_long_parsed,
1159 .help_str = "help all|control|display|config|ports|register|filters: "
1162 (void *)&cmd_help_long_help,
1163 (void *)&cmd_help_long_section,
1169 /* *** start/stop/close all ports *** */
1170 struct cmd_operate_port_result {
1171 cmdline_fixed_string_t keyword;
1172 cmdline_fixed_string_t name;
1173 cmdline_fixed_string_t value;
1176 static void cmd_operate_port_parsed(void *parsed_result,
1177 __attribute__((unused)) struct cmdline *cl,
1178 __attribute__((unused)) void *data)
1180 struct cmd_operate_port_result *res = parsed_result;
1182 if (!strcmp(res->name, "start"))
1183 start_port(RTE_PORT_ALL);
1184 else if (!strcmp(res->name, "stop"))
1185 stop_port(RTE_PORT_ALL);
1186 else if (!strcmp(res->name, "close"))
1187 close_port(RTE_PORT_ALL);
1188 else if (!strcmp(res->name, "reset"))
1189 reset_port(RTE_PORT_ALL);
1191 printf("Unknown parameter\n");
1194 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1195 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1197 cmdline_parse_token_string_t cmd_operate_port_all_port =
1198 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1199 "start#stop#close#reset");
1200 cmdline_parse_token_string_t cmd_operate_port_all_all =
1201 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1203 cmdline_parse_inst_t cmd_operate_port = {
1204 .f = cmd_operate_port_parsed,
1206 .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports",
1208 (void *)&cmd_operate_port_all_cmd,
1209 (void *)&cmd_operate_port_all_port,
1210 (void *)&cmd_operate_port_all_all,
1215 /* *** start/stop/close specific port *** */
1216 struct cmd_operate_specific_port_result {
1217 cmdline_fixed_string_t keyword;
1218 cmdline_fixed_string_t name;
1222 static void cmd_operate_specific_port_parsed(void *parsed_result,
1223 __attribute__((unused)) struct cmdline *cl,
1224 __attribute__((unused)) void *data)
1226 struct cmd_operate_specific_port_result *res = parsed_result;
1228 if (!strcmp(res->name, "start"))
1229 start_port(res->value);
1230 else if (!strcmp(res->name, "stop"))
1231 stop_port(res->value);
1232 else if (!strcmp(res->name, "close"))
1233 close_port(res->value);
1234 else if (!strcmp(res->name, "reset"))
1235 reset_port(res->value);
1237 printf("Unknown parameter\n");
1240 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1241 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1243 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1244 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1245 name, "start#stop#close#reset");
1246 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1247 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1250 cmdline_parse_inst_t cmd_operate_specific_port = {
1251 .f = cmd_operate_specific_port_parsed,
1253 .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id",
1255 (void *)&cmd_operate_specific_port_cmd,
1256 (void *)&cmd_operate_specific_port_port,
1257 (void *)&cmd_operate_specific_port_id,
1262 /* *** enable port setup (after attach) via iterator or event *** */
1263 struct cmd_set_port_setup_on_result {
1264 cmdline_fixed_string_t set;
1265 cmdline_fixed_string_t port;
1266 cmdline_fixed_string_t setup;
1267 cmdline_fixed_string_t on;
1268 cmdline_fixed_string_t mode;
1271 static void cmd_set_port_setup_on_parsed(void *parsed_result,
1272 __attribute__((unused)) struct cmdline *cl,
1273 __attribute__((unused)) void *data)
1275 struct cmd_set_port_setup_on_result *res = parsed_result;
1277 if (strcmp(res->mode, "event") == 0)
1278 setup_on_probe_event = true;
1279 else if (strcmp(res->mode, "iterator") == 0)
1280 setup_on_probe_event = false;
1282 printf("Unknown mode\n");
1285 cmdline_parse_token_string_t cmd_set_port_setup_on_set =
1286 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1288 cmdline_parse_token_string_t cmd_set_port_setup_on_port =
1289 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1291 cmdline_parse_token_string_t cmd_set_port_setup_on_setup =
1292 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1294 cmdline_parse_token_string_t cmd_set_port_setup_on_on =
1295 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1297 cmdline_parse_token_string_t cmd_set_port_setup_on_mode =
1298 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1299 mode, "iterator#event");
1301 cmdline_parse_inst_t cmd_set_port_setup_on = {
1302 .f = cmd_set_port_setup_on_parsed,
1304 .help_str = "set port setup on iterator|event",
1306 (void *)&cmd_set_port_setup_on_set,
1307 (void *)&cmd_set_port_setup_on_port,
1308 (void *)&cmd_set_port_setup_on_setup,
1309 (void *)&cmd_set_port_setup_on_on,
1310 (void *)&cmd_set_port_setup_on_mode,
1315 /* *** attach a specified port *** */
1316 struct cmd_operate_attach_port_result {
1317 cmdline_fixed_string_t port;
1318 cmdline_fixed_string_t keyword;
1319 cmdline_fixed_string_t identifier;
1322 static void cmd_operate_attach_port_parsed(void *parsed_result,
1323 __attribute__((unused)) struct cmdline *cl,
1324 __attribute__((unused)) void *data)
1326 struct cmd_operate_attach_port_result *res = parsed_result;
1328 if (!strcmp(res->keyword, "attach"))
1329 attach_port(res->identifier);
1331 printf("Unknown parameter\n");
1334 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1335 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1337 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1338 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1340 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1341 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1344 cmdline_parse_inst_t cmd_operate_attach_port = {
1345 .f = cmd_operate_attach_port_parsed,
1347 .help_str = "port attach <identifier>: "
1348 "(identifier: pci address or virtual dev name)",
1350 (void *)&cmd_operate_attach_port_port,
1351 (void *)&cmd_operate_attach_port_keyword,
1352 (void *)&cmd_operate_attach_port_identifier,
1357 /* *** detach a specified port *** */
1358 struct cmd_operate_detach_port_result {
1359 cmdline_fixed_string_t port;
1360 cmdline_fixed_string_t keyword;
1364 static void cmd_operate_detach_port_parsed(void *parsed_result,
1365 __attribute__((unused)) struct cmdline *cl,
1366 __attribute__((unused)) void *data)
1368 struct cmd_operate_detach_port_result *res = parsed_result;
1370 if (!strcmp(res->keyword, "detach"))
1371 detach_port_device(res->port_id);
1373 printf("Unknown parameter\n");
1376 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1377 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1379 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1380 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1382 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1383 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1386 cmdline_parse_inst_t cmd_operate_detach_port = {
1387 .f = cmd_operate_detach_port_parsed,
1389 .help_str = "port detach <port_id>",
1391 (void *)&cmd_operate_detach_port_port,
1392 (void *)&cmd_operate_detach_port_keyword,
1393 (void *)&cmd_operate_detach_port_port_id,
1398 /* *** configure speed for all ports *** */
1399 struct cmd_config_speed_all {
1400 cmdline_fixed_string_t port;
1401 cmdline_fixed_string_t keyword;
1402 cmdline_fixed_string_t all;
1403 cmdline_fixed_string_t item1;
1404 cmdline_fixed_string_t item2;
1405 cmdline_fixed_string_t value1;
1406 cmdline_fixed_string_t value2;
1410 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1415 if (!strcmp(duplexstr, "half")) {
1416 duplex = ETH_LINK_HALF_DUPLEX;
1417 } else if (!strcmp(duplexstr, "full")) {
1418 duplex = ETH_LINK_FULL_DUPLEX;
1419 } else if (!strcmp(duplexstr, "auto")) {
1420 duplex = ETH_LINK_FULL_DUPLEX;
1422 printf("Unknown duplex parameter\n");
1426 if (!strcmp(speedstr, "10")) {
1427 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1428 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1429 } else if (!strcmp(speedstr, "100")) {
1430 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1431 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1433 if (duplex != ETH_LINK_FULL_DUPLEX) {
1434 printf("Invalid speed/duplex parameters\n");
1437 if (!strcmp(speedstr, "1000")) {
1438 *speed = ETH_LINK_SPEED_1G;
1439 } else if (!strcmp(speedstr, "10000")) {
1440 *speed = ETH_LINK_SPEED_10G;
1441 } else if (!strcmp(speedstr, "25000")) {
1442 *speed = ETH_LINK_SPEED_25G;
1443 } else if (!strcmp(speedstr, "40000")) {
1444 *speed = ETH_LINK_SPEED_40G;
1445 } else if (!strcmp(speedstr, "50000")) {
1446 *speed = ETH_LINK_SPEED_50G;
1447 } else if (!strcmp(speedstr, "100000")) {
1448 *speed = ETH_LINK_SPEED_100G;
1449 } else if (!strcmp(speedstr, "auto")) {
1450 *speed = ETH_LINK_SPEED_AUTONEG;
1452 printf("Unknown speed parameter\n");
1461 cmd_config_speed_all_parsed(void *parsed_result,
1462 __attribute__((unused)) struct cmdline *cl,
1463 __attribute__((unused)) void *data)
1465 struct cmd_config_speed_all *res = parsed_result;
1466 uint32_t link_speed;
1469 if (!all_ports_stopped()) {
1470 printf("Please stop all ports first\n");
1474 if (parse_and_check_speed_duplex(res->value1, res->value2,
1478 RTE_ETH_FOREACH_DEV(pid) {
1479 ports[pid].dev_conf.link_speeds = link_speed;
1482 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1485 cmdline_parse_token_string_t cmd_config_speed_all_port =
1486 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1487 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1488 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1490 cmdline_parse_token_string_t cmd_config_speed_all_all =
1491 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1492 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1493 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1494 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1495 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1496 "10#100#1000#10000#25000#40000#50000#100000#auto");
1497 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1498 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1499 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1500 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1503 cmdline_parse_inst_t cmd_config_speed_all = {
1504 .f = cmd_config_speed_all_parsed,
1506 .help_str = "port config all speed "
1507 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1510 (void *)&cmd_config_speed_all_port,
1511 (void *)&cmd_config_speed_all_keyword,
1512 (void *)&cmd_config_speed_all_all,
1513 (void *)&cmd_config_speed_all_item1,
1514 (void *)&cmd_config_speed_all_value1,
1515 (void *)&cmd_config_speed_all_item2,
1516 (void *)&cmd_config_speed_all_value2,
1521 /* *** configure speed for specific port *** */
1522 struct cmd_config_speed_specific {
1523 cmdline_fixed_string_t port;
1524 cmdline_fixed_string_t keyword;
1526 cmdline_fixed_string_t item1;
1527 cmdline_fixed_string_t item2;
1528 cmdline_fixed_string_t value1;
1529 cmdline_fixed_string_t value2;
1533 cmd_config_speed_specific_parsed(void *parsed_result,
1534 __attribute__((unused)) struct cmdline *cl,
1535 __attribute__((unused)) void *data)
1537 struct cmd_config_speed_specific *res = parsed_result;
1538 uint32_t link_speed;
1540 if (!all_ports_stopped()) {
1541 printf("Please stop all ports first\n");
1545 if (port_id_is_invalid(res->id, ENABLED_WARN))
1548 if (parse_and_check_speed_duplex(res->value1, res->value2,
1552 ports[res->id].dev_conf.link_speeds = link_speed;
1554 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1558 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1559 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1561 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1562 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1564 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1565 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT16);
1566 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1567 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1569 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1570 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1571 "10#100#1000#10000#25000#40000#50000#100000#auto");
1572 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1573 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1575 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1576 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1579 cmdline_parse_inst_t cmd_config_speed_specific = {
1580 .f = cmd_config_speed_specific_parsed,
1582 .help_str = "port config <port_id> speed "
1583 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1586 (void *)&cmd_config_speed_specific_port,
1587 (void *)&cmd_config_speed_specific_keyword,
1588 (void *)&cmd_config_speed_specific_id,
1589 (void *)&cmd_config_speed_specific_item1,
1590 (void *)&cmd_config_speed_specific_value1,
1591 (void *)&cmd_config_speed_specific_item2,
1592 (void *)&cmd_config_speed_specific_value2,
1597 /* *** configure loopback for all ports *** */
1598 struct cmd_config_loopback_all {
1599 cmdline_fixed_string_t port;
1600 cmdline_fixed_string_t keyword;
1601 cmdline_fixed_string_t all;
1602 cmdline_fixed_string_t item;
1607 cmd_config_loopback_all_parsed(void *parsed_result,
1608 __attribute__((unused)) struct cmdline *cl,
1609 __attribute__((unused)) void *data)
1611 struct cmd_config_loopback_all *res = parsed_result;
1614 if (!all_ports_stopped()) {
1615 printf("Please stop all ports first\n");
1619 RTE_ETH_FOREACH_DEV(pid) {
1620 ports[pid].dev_conf.lpbk_mode = res->mode;
1623 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1626 cmdline_parse_token_string_t cmd_config_loopback_all_port =
1627 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1628 cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1629 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1631 cmdline_parse_token_string_t cmd_config_loopback_all_all =
1632 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1633 cmdline_parse_token_string_t cmd_config_loopback_all_item =
1634 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1636 cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1637 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, UINT32);
1639 cmdline_parse_inst_t cmd_config_loopback_all = {
1640 .f = cmd_config_loopback_all_parsed,
1642 .help_str = "port config all loopback <mode>",
1644 (void *)&cmd_config_loopback_all_port,
1645 (void *)&cmd_config_loopback_all_keyword,
1646 (void *)&cmd_config_loopback_all_all,
1647 (void *)&cmd_config_loopback_all_item,
1648 (void *)&cmd_config_loopback_all_mode,
1653 /* *** configure loopback for specific port *** */
1654 struct cmd_config_loopback_specific {
1655 cmdline_fixed_string_t port;
1656 cmdline_fixed_string_t keyword;
1658 cmdline_fixed_string_t item;
1663 cmd_config_loopback_specific_parsed(void *parsed_result,
1664 __attribute__((unused)) struct cmdline *cl,
1665 __attribute__((unused)) void *data)
1667 struct cmd_config_loopback_specific *res = parsed_result;
1669 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1672 if (!port_is_stopped(res->port_id)) {
1673 printf("Please stop port %u first\n", res->port_id);
1677 ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1679 cmd_reconfig_device_queue(res->port_id, 1, 1);
1683 cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1684 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1686 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1687 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1689 cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1690 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1692 cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1693 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1695 cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1696 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1699 cmdline_parse_inst_t cmd_config_loopback_specific = {
1700 .f = cmd_config_loopback_specific_parsed,
1702 .help_str = "port config <port_id> loopback <mode>",
1704 (void *)&cmd_config_loopback_specific_port,
1705 (void *)&cmd_config_loopback_specific_keyword,
1706 (void *)&cmd_config_loopback_specific_id,
1707 (void *)&cmd_config_loopback_specific_item,
1708 (void *)&cmd_config_loopback_specific_mode,
1713 /* *** configure txq/rxq, txd/rxd *** */
1714 struct cmd_config_rx_tx {
1715 cmdline_fixed_string_t port;
1716 cmdline_fixed_string_t keyword;
1717 cmdline_fixed_string_t all;
1718 cmdline_fixed_string_t name;
1723 cmd_config_rx_tx_parsed(void *parsed_result,
1724 __attribute__((unused)) struct cmdline *cl,
1725 __attribute__((unused)) void *data)
1727 struct cmd_config_rx_tx *res = parsed_result;
1729 if (!all_ports_stopped()) {
1730 printf("Please stop all ports first\n");
1733 if (!strcmp(res->name, "rxq")) {
1734 if (!res->value && !nb_txq) {
1735 printf("Warning: Either rx or tx queues should be non zero\n");
1738 if (check_nb_rxq(res->value) != 0)
1740 nb_rxq = res->value;
1742 else if (!strcmp(res->name, "txq")) {
1743 if (!res->value && !nb_rxq) {
1744 printf("Warning: Either rx or tx queues should be non zero\n");
1747 if (check_nb_txq(res->value) != 0)
1749 nb_txq = res->value;
1751 else if (!strcmp(res->name, "rxd")) {
1752 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1753 printf("rxd %d invalid - must be > 0 && <= %d\n",
1754 res->value, RTE_TEST_RX_DESC_MAX);
1757 nb_rxd = res->value;
1758 } else if (!strcmp(res->name, "txd")) {
1759 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1760 printf("txd %d invalid - must be > 0 && <= %d\n",
1761 res->value, RTE_TEST_TX_DESC_MAX);
1764 nb_txd = res->value;
1766 printf("Unknown parameter\n");
1774 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1777 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1778 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1779 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1780 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1781 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1782 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1783 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1784 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1786 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1787 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1789 cmdline_parse_inst_t cmd_config_rx_tx = {
1790 .f = cmd_config_rx_tx_parsed,
1792 .help_str = "port config all rxq|txq|rxd|txd <value>",
1794 (void *)&cmd_config_rx_tx_port,
1795 (void *)&cmd_config_rx_tx_keyword,
1796 (void *)&cmd_config_rx_tx_all,
1797 (void *)&cmd_config_rx_tx_name,
1798 (void *)&cmd_config_rx_tx_value,
1803 /* *** config max packet length *** */
1804 struct cmd_config_max_pkt_len_result {
1805 cmdline_fixed_string_t port;
1806 cmdline_fixed_string_t keyword;
1807 cmdline_fixed_string_t all;
1808 cmdline_fixed_string_t name;
1813 cmd_config_max_pkt_len_parsed(void *parsed_result,
1814 __attribute__((unused)) struct cmdline *cl,
1815 __attribute__((unused)) void *data)
1817 struct cmd_config_max_pkt_len_result *res = parsed_result;
1820 if (!all_ports_stopped()) {
1821 printf("Please stop all ports first\n");
1825 RTE_ETH_FOREACH_DEV(pid) {
1826 struct rte_port *port = &ports[pid];
1827 uint64_t rx_offloads = port->dev_conf.rxmode.offloads;
1829 if (!strcmp(res->name, "max-pkt-len")) {
1830 if (res->value < ETHER_MIN_LEN) {
1831 printf("max-pkt-len can not be less than %d\n",
1835 if (res->value == port->dev_conf.rxmode.max_rx_pkt_len)
1838 port->dev_conf.rxmode.max_rx_pkt_len = res->value;
1839 if (res->value > ETHER_MAX_LEN)
1840 rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
1842 rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
1843 port->dev_conf.rxmode.offloads = rx_offloads;
1845 printf("Unknown parameter\n");
1852 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1855 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1856 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1858 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1859 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1861 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1862 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1864 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1865 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1867 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1868 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1871 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1872 .f = cmd_config_max_pkt_len_parsed,
1874 .help_str = "port config all max-pkt-len <value>",
1876 (void *)&cmd_config_max_pkt_len_port,
1877 (void *)&cmd_config_max_pkt_len_keyword,
1878 (void *)&cmd_config_max_pkt_len_all,
1879 (void *)&cmd_config_max_pkt_len_name,
1880 (void *)&cmd_config_max_pkt_len_value,
1885 /* *** configure port MTU *** */
1886 struct cmd_config_mtu_result {
1887 cmdline_fixed_string_t port;
1888 cmdline_fixed_string_t keyword;
1889 cmdline_fixed_string_t mtu;
1895 cmd_config_mtu_parsed(void *parsed_result,
1896 __attribute__((unused)) struct cmdline *cl,
1897 __attribute__((unused)) void *data)
1899 struct cmd_config_mtu_result *res = parsed_result;
1901 if (res->value < ETHER_MIN_LEN) {
1902 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1905 port_mtu_set(res->port_id, res->value);
1908 cmdline_parse_token_string_t cmd_config_mtu_port =
1909 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1911 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1912 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1914 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1915 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1917 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1918 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT16);
1919 cmdline_parse_token_num_t cmd_config_mtu_value =
1920 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1922 cmdline_parse_inst_t cmd_config_mtu = {
1923 .f = cmd_config_mtu_parsed,
1925 .help_str = "port config mtu <port_id> <value>",
1927 (void *)&cmd_config_mtu_port,
1928 (void *)&cmd_config_mtu_keyword,
1929 (void *)&cmd_config_mtu_mtu,
1930 (void *)&cmd_config_mtu_port_id,
1931 (void *)&cmd_config_mtu_value,
1936 /* *** configure rx mode *** */
1937 struct cmd_config_rx_mode_flag {
1938 cmdline_fixed_string_t port;
1939 cmdline_fixed_string_t keyword;
1940 cmdline_fixed_string_t all;
1941 cmdline_fixed_string_t name;
1942 cmdline_fixed_string_t value;
1946 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1947 __attribute__((unused)) struct cmdline *cl,
1948 __attribute__((unused)) void *data)
1950 struct cmd_config_rx_mode_flag *res = parsed_result;
1953 if (!all_ports_stopped()) {
1954 printf("Please stop all ports first\n");
1958 RTE_ETH_FOREACH_DEV(pid) {
1959 struct rte_port *port;
1960 uint64_t rx_offloads;
1963 rx_offloads = port->dev_conf.rxmode.offloads;
1964 if (!strcmp(res->name, "crc-strip")) {
1965 if (!strcmp(res->value, "on")) {
1966 rx_offloads &= ~DEV_RX_OFFLOAD_KEEP_CRC;
1967 } else if (!strcmp(res->value, "off")) {
1968 rx_offloads |= DEV_RX_OFFLOAD_KEEP_CRC;
1970 printf("Unknown parameter\n");
1973 } else if (!strcmp(res->name, "scatter")) {
1974 if (!strcmp(res->value, "on")) {
1975 rx_offloads |= DEV_RX_OFFLOAD_SCATTER;
1976 } else if (!strcmp(res->value, "off")) {
1977 rx_offloads &= ~DEV_RX_OFFLOAD_SCATTER;
1979 printf("Unknown parameter\n");
1982 } else if (!strcmp(res->name, "rx-cksum")) {
1983 if (!strcmp(res->value, "on"))
1984 rx_offloads |= DEV_RX_OFFLOAD_CHECKSUM;
1985 else if (!strcmp(res->value, "off"))
1986 rx_offloads &= ~DEV_RX_OFFLOAD_CHECKSUM;
1988 printf("Unknown parameter\n");
1991 } else if (!strcmp(res->name, "rx-timestamp")) {
1992 if (!strcmp(res->value, "on"))
1993 rx_offloads |= DEV_RX_OFFLOAD_TIMESTAMP;
1994 else if (!strcmp(res->value, "off"))
1995 rx_offloads &= ~DEV_RX_OFFLOAD_TIMESTAMP;
1997 printf("Unknown parameter\n");
2000 } else if (!strcmp(res->name, "hw-vlan")) {
2001 if (!strcmp(res->value, "on")) {
2002 rx_offloads |= (DEV_RX_OFFLOAD_VLAN_FILTER |
2003 DEV_RX_OFFLOAD_VLAN_STRIP);
2004 } else if (!strcmp(res->value, "off")) {
2005 rx_offloads &= ~(DEV_RX_OFFLOAD_VLAN_FILTER |
2006 DEV_RX_OFFLOAD_VLAN_STRIP);
2008 printf("Unknown parameter\n");
2011 } else if (!strcmp(res->name, "hw-vlan-filter")) {
2012 if (!strcmp(res->value, "on"))
2013 rx_offloads |= DEV_RX_OFFLOAD_VLAN_FILTER;
2014 else if (!strcmp(res->value, "off"))
2015 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_FILTER;
2017 printf("Unknown parameter\n");
2020 } else if (!strcmp(res->name, "hw-vlan-strip")) {
2021 if (!strcmp(res->value, "on"))
2022 rx_offloads |= DEV_RX_OFFLOAD_VLAN_STRIP;
2023 else if (!strcmp(res->value, "off"))
2024 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_STRIP;
2026 printf("Unknown parameter\n");
2029 } else if (!strcmp(res->name, "hw-vlan-extend")) {
2030 if (!strcmp(res->value, "on"))
2031 rx_offloads |= DEV_RX_OFFLOAD_VLAN_EXTEND;
2032 else if (!strcmp(res->value, "off"))
2033 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_EXTEND;
2035 printf("Unknown parameter\n");
2038 } else if (!strcmp(res->name, "drop-en")) {
2039 if (!strcmp(res->value, "on"))
2041 else if (!strcmp(res->value, "off"))
2044 printf("Unknown parameter\n");
2048 printf("Unknown parameter\n");
2051 port->dev_conf.rxmode.offloads = rx_offloads;
2056 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2059 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
2060 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
2061 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
2062 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
2064 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2065 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2066 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2067 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2068 "crc-strip#scatter#rx-cksum#rx-timestamp#hw-vlan#"
2069 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
2070 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2071 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2074 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2075 .f = cmd_config_rx_mode_flag_parsed,
2077 .help_str = "port config all crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|"
2078 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
2080 (void *)&cmd_config_rx_mode_flag_port,
2081 (void *)&cmd_config_rx_mode_flag_keyword,
2082 (void *)&cmd_config_rx_mode_flag_all,
2083 (void *)&cmd_config_rx_mode_flag_name,
2084 (void *)&cmd_config_rx_mode_flag_value,
2089 /* *** configure rss *** */
2090 struct cmd_config_rss {
2091 cmdline_fixed_string_t port;
2092 cmdline_fixed_string_t keyword;
2093 cmdline_fixed_string_t all;
2094 cmdline_fixed_string_t name;
2095 cmdline_fixed_string_t value;
2099 cmd_config_rss_parsed(void *parsed_result,
2100 __attribute__((unused)) struct cmdline *cl,
2101 __attribute__((unused)) void *data)
2103 struct cmd_config_rss *res = parsed_result;
2104 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2105 struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2106 int use_default = 0;
2107 int all_updated = 1;
2111 if (!strcmp(res->value, "all"))
2112 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
2113 ETH_RSS_UDP | ETH_RSS_SCTP |
2115 else if (!strcmp(res->value, "ip"))
2116 rss_conf.rss_hf = ETH_RSS_IP;
2117 else if (!strcmp(res->value, "udp"))
2118 rss_conf.rss_hf = ETH_RSS_UDP;
2119 else if (!strcmp(res->value, "tcp"))
2120 rss_conf.rss_hf = ETH_RSS_TCP;
2121 else if (!strcmp(res->value, "sctp"))
2122 rss_conf.rss_hf = ETH_RSS_SCTP;
2123 else if (!strcmp(res->value, "ether"))
2124 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
2125 else if (!strcmp(res->value, "port"))
2126 rss_conf.rss_hf = ETH_RSS_PORT;
2127 else if (!strcmp(res->value, "vxlan"))
2128 rss_conf.rss_hf = ETH_RSS_VXLAN;
2129 else if (!strcmp(res->value, "geneve"))
2130 rss_conf.rss_hf = ETH_RSS_GENEVE;
2131 else if (!strcmp(res->value, "nvgre"))
2132 rss_conf.rss_hf = ETH_RSS_NVGRE;
2133 else if (!strcmp(res->value, "none"))
2134 rss_conf.rss_hf = 0;
2135 else if (!strcmp(res->value, "default"))
2137 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2138 atoi(res->value) < 64)
2139 rss_conf.rss_hf = 1ULL << atoi(res->value);
2141 printf("Unknown parameter\n");
2144 rss_conf.rss_key = NULL;
2145 /* Update global configuration for RSS types. */
2146 RTE_ETH_FOREACH_DEV(i) {
2147 struct rte_eth_rss_conf local_rss_conf;
2149 rte_eth_dev_info_get(i, &dev_info);
2151 rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2153 local_rss_conf = rss_conf;
2154 local_rss_conf.rss_hf = rss_conf.rss_hf &
2155 dev_info.flow_type_rss_offloads;
2156 if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2157 printf("Port %u modified RSS hash function based on hardware support,"
2158 "requested:%#"PRIx64" configured:%#"PRIx64"\n",
2159 i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2161 diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2164 printf("Configuration of RSS hash at ethernet port %d "
2165 "failed with error (%d): %s.\n",
2166 i, -diag, strerror(-diag));
2169 if (all_updated && !use_default)
2170 rss_hf = rss_conf.rss_hf;
2173 cmdline_parse_token_string_t cmd_config_rss_port =
2174 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2175 cmdline_parse_token_string_t cmd_config_rss_keyword =
2176 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2177 cmdline_parse_token_string_t cmd_config_rss_all =
2178 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2179 cmdline_parse_token_string_t cmd_config_rss_name =
2180 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2181 cmdline_parse_token_string_t cmd_config_rss_value =
2182 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2184 cmdline_parse_inst_t cmd_config_rss = {
2185 .f = cmd_config_rss_parsed,
2187 .help_str = "port config all rss "
2188 "all|default|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none|<flowtype_id>",
2190 (void *)&cmd_config_rss_port,
2191 (void *)&cmd_config_rss_keyword,
2192 (void *)&cmd_config_rss_all,
2193 (void *)&cmd_config_rss_name,
2194 (void *)&cmd_config_rss_value,
2199 /* *** configure rss hash key *** */
2200 struct cmd_config_rss_hash_key {
2201 cmdline_fixed_string_t port;
2202 cmdline_fixed_string_t config;
2204 cmdline_fixed_string_t rss_hash_key;
2205 cmdline_fixed_string_t rss_type;
2206 cmdline_fixed_string_t key;
2210 hexa_digit_to_value(char hexa_digit)
2212 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2213 return (uint8_t) (hexa_digit - '0');
2214 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2215 return (uint8_t) ((hexa_digit - 'a') + 10);
2216 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2217 return (uint8_t) ((hexa_digit - 'A') + 10);
2218 /* Invalid hexa digit */
2223 parse_and_check_key_hexa_digit(char *key, int idx)
2227 hexa_v = hexa_digit_to_value(key[idx]);
2229 printf("invalid key: character %c at position %d is not a "
2230 "valid hexa digit\n", key[idx], idx);
2235 cmd_config_rss_hash_key_parsed(void *parsed_result,
2236 __attribute__((unused)) struct cmdline *cl,
2237 __attribute__((unused)) void *data)
2239 struct cmd_config_rss_hash_key *res = parsed_result;
2240 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2244 struct rte_eth_dev_info dev_info;
2245 uint8_t hash_key_size;
2248 memset(&dev_info, 0, sizeof(dev_info));
2249 rte_eth_dev_info_get(res->port_id, &dev_info);
2250 if (dev_info.hash_key_size > 0 &&
2251 dev_info.hash_key_size <= sizeof(hash_key))
2252 hash_key_size = dev_info.hash_key_size;
2254 printf("dev_info did not provide a valid hash key size\n");
2257 /* Check the length of the RSS hash key */
2258 key_len = strlen(res->key);
2259 if (key_len != (hash_key_size * 2)) {
2260 printf("key length: %d invalid - key must be a string of %d"
2261 " hexa-decimal numbers\n",
2262 (int) key_len, hash_key_size * 2);
2265 /* Translate RSS hash key into binary representation */
2266 for (i = 0; i < hash_key_size; i++) {
2267 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2270 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2273 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2275 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2279 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2280 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2281 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2282 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2284 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2285 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16);
2286 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2287 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2288 rss_hash_key, "rss-hash-key");
2289 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2290 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2291 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2292 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2293 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2294 "ipv6-tcp-ex#ipv6-udp-ex");
2295 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2296 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2298 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2299 .f = cmd_config_rss_hash_key_parsed,
2301 .help_str = "port config <port_id> rss-hash-key "
2302 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2303 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2304 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex "
2305 "<string of hex digits (variable length, NIC dependent)>",
2307 (void *)&cmd_config_rss_hash_key_port,
2308 (void *)&cmd_config_rss_hash_key_config,
2309 (void *)&cmd_config_rss_hash_key_port_id,
2310 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2311 (void *)&cmd_config_rss_hash_key_rss_type,
2312 (void *)&cmd_config_rss_hash_key_value,
2317 /* *** configure port rxq/txq ring size *** */
2318 struct cmd_config_rxtx_ring_size {
2319 cmdline_fixed_string_t port;
2320 cmdline_fixed_string_t config;
2322 cmdline_fixed_string_t rxtxq;
2324 cmdline_fixed_string_t rsize;
2329 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2330 __attribute__((unused)) struct cmdline *cl,
2331 __attribute__((unused)) void *data)
2333 struct cmd_config_rxtx_ring_size *res = parsed_result;
2334 struct rte_port *port;
2337 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2340 if (res->portid == (portid_t)RTE_PORT_ALL) {
2341 printf("Invalid port id\n");
2345 port = &ports[res->portid];
2347 if (!strcmp(res->rxtxq, "rxq"))
2349 else if (!strcmp(res->rxtxq, "txq"))
2352 printf("Unknown parameter\n");
2356 if (isrx && rx_queue_id_is_invalid(res->qid))
2358 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2361 if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2362 printf("Invalid rx ring_size, must > rx_free_thresh: %d\n",
2368 port->nb_rx_desc[res->qid] = res->size;
2370 port->nb_tx_desc[res->qid] = res->size;
2372 cmd_reconfig_device_queue(res->portid, 0, 1);
2375 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2376 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2378 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2379 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2381 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2382 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2384 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2385 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2387 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2388 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2390 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2391 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2392 rsize, "ring_size");
2393 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2394 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2397 cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2398 .f = cmd_config_rxtx_ring_size_parsed,
2400 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2402 (void *)&cmd_config_rxtx_ring_size_port,
2403 (void *)&cmd_config_rxtx_ring_size_config,
2404 (void *)&cmd_config_rxtx_ring_size_portid,
2405 (void *)&cmd_config_rxtx_ring_size_rxtxq,
2406 (void *)&cmd_config_rxtx_ring_size_qid,
2407 (void *)&cmd_config_rxtx_ring_size_rsize,
2408 (void *)&cmd_config_rxtx_ring_size_size,
2413 /* *** configure port rxq/txq start/stop *** */
2414 struct cmd_config_rxtx_queue {
2415 cmdline_fixed_string_t port;
2417 cmdline_fixed_string_t rxtxq;
2419 cmdline_fixed_string_t opname;
2423 cmd_config_rxtx_queue_parsed(void *parsed_result,
2424 __attribute__((unused)) struct cmdline *cl,
2425 __attribute__((unused)) void *data)
2427 struct cmd_config_rxtx_queue *res = parsed_result;
2432 if (test_done == 0) {
2433 printf("Please stop forwarding first\n");
2437 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2440 if (port_is_started(res->portid) != 1) {
2441 printf("Please start port %u first\n", res->portid);
2445 if (!strcmp(res->rxtxq, "rxq"))
2447 else if (!strcmp(res->rxtxq, "txq"))
2450 printf("Unknown parameter\n");
2454 if (isrx && rx_queue_id_is_invalid(res->qid))
2456 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2459 if (!strcmp(res->opname, "start"))
2461 else if (!strcmp(res->opname, "stop"))
2464 printf("Unknown parameter\n");
2468 if (isstart && isrx)
2469 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2470 else if (!isstart && isrx)
2471 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2472 else if (isstart && !isrx)
2473 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2475 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2477 if (ret == -ENOTSUP)
2478 printf("Function not supported in PMD driver\n");
2481 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2482 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2483 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2484 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16);
2485 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2486 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2487 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2488 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
2489 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2490 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2493 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2494 .f = cmd_config_rxtx_queue_parsed,
2496 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2498 (void *)&cmd_config_rxtx_queue_port,
2499 (void *)&cmd_config_rxtx_queue_portid,
2500 (void *)&cmd_config_rxtx_queue_rxtxq,
2501 (void *)&cmd_config_rxtx_queue_qid,
2502 (void *)&cmd_config_rxtx_queue_opname,
2507 /* *** configure port rxq/txq deferred start on/off *** */
2508 struct cmd_config_deferred_start_rxtx_queue {
2509 cmdline_fixed_string_t port;
2511 cmdline_fixed_string_t rxtxq;
2513 cmdline_fixed_string_t opname;
2514 cmdline_fixed_string_t state;
2518 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2519 __attribute__((unused)) struct cmdline *cl,
2520 __attribute__((unused)) void *data)
2522 struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2523 struct rte_port *port;
2526 uint8_t needreconfig = 0;
2528 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2531 if (port_is_started(res->port_id) != 0) {
2532 printf("Please stop port %u first\n", res->port_id);
2536 port = &ports[res->port_id];
2538 isrx = !strcmp(res->rxtxq, "rxq");
2540 if (isrx && rx_queue_id_is_invalid(res->qid))
2542 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2545 ison = !strcmp(res->state, "on");
2547 if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) {
2548 port->rx_conf[res->qid].rx_deferred_start = ison;
2550 } else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) {
2551 port->tx_conf[res->qid].tx_deferred_start = ison;
2556 cmd_reconfig_device_queue(res->port_id, 0, 1);
2559 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2560 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2562 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2563 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2565 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2566 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2568 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2569 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2571 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2572 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2573 opname, "deferred_start");
2574 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2575 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2578 cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
2579 .f = cmd_config_deferred_start_rxtx_queue_parsed,
2581 .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
2583 (void *)&cmd_config_deferred_start_rxtx_queue_port,
2584 (void *)&cmd_config_deferred_start_rxtx_queue_port_id,
2585 (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
2586 (void *)&cmd_config_deferred_start_rxtx_queue_qid,
2587 (void *)&cmd_config_deferred_start_rxtx_queue_opname,
2588 (void *)&cmd_config_deferred_start_rxtx_queue_state,
2593 /* *** configure port rxq/txq setup *** */
2594 struct cmd_setup_rxtx_queue {
2595 cmdline_fixed_string_t port;
2597 cmdline_fixed_string_t rxtxq;
2599 cmdline_fixed_string_t setup;
2602 /* Common CLI fields for queue setup */
2603 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2604 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2605 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2606 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, UINT16);
2607 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2608 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2609 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2610 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, UINT16);
2611 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2612 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2615 cmd_setup_rxtx_queue_parsed(
2616 void *parsed_result,
2617 __attribute__((unused)) struct cmdline *cl,
2618 __attribute__((unused)) void *data)
2620 struct cmd_setup_rxtx_queue *res = parsed_result;
2621 struct rte_port *port;
2622 struct rte_mempool *mp;
2623 unsigned int socket_id;
2627 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2630 if (res->portid == (portid_t)RTE_PORT_ALL) {
2631 printf("Invalid port id\n");
2635 if (!strcmp(res->rxtxq, "rxq"))
2637 else if (!strcmp(res->rxtxq, "txq"))
2640 printf("Unknown parameter\n");
2644 if (isrx && rx_queue_id_is_invalid(res->qid)) {
2645 printf("Invalid rx queue\n");
2647 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2648 printf("Invalid tx queue\n");
2652 port = &ports[res->portid];
2654 socket_id = rxring_numa[res->portid];
2655 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2656 socket_id = port->socket_id;
2658 mp = mbuf_pool_find(socket_id);
2660 printf("Failed to setup RX queue: "
2661 "No mempool allocation"
2662 " on the socket %d\n",
2663 rxring_numa[res->portid]);
2666 ret = rte_eth_rx_queue_setup(res->portid,
2668 port->nb_rx_desc[res->qid],
2670 &port->rx_conf[res->qid],
2673 printf("Failed to setup RX queue\n");
2675 socket_id = txring_numa[res->portid];
2676 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2677 socket_id = port->socket_id;
2679 ret = rte_eth_tx_queue_setup(res->portid,
2681 port->nb_tx_desc[res->qid],
2683 &port->tx_conf[res->qid]);
2685 printf("Failed to setup TX queue\n");
2689 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2690 .f = cmd_setup_rxtx_queue_parsed,
2692 .help_str = "port <port_id> rxq|txq <queue_idx> setup",
2694 (void *)&cmd_setup_rxtx_queue_port,
2695 (void *)&cmd_setup_rxtx_queue_portid,
2696 (void *)&cmd_setup_rxtx_queue_rxtxq,
2697 (void *)&cmd_setup_rxtx_queue_qid,
2698 (void *)&cmd_setup_rxtx_queue_setup,
2704 /* *** Configure RSS RETA *** */
2705 struct cmd_config_rss_reta {
2706 cmdline_fixed_string_t port;
2707 cmdline_fixed_string_t keyword;
2709 cmdline_fixed_string_t name;
2710 cmdline_fixed_string_t list_name;
2711 cmdline_fixed_string_t list_of_items;
2715 parse_reta_config(const char *str,
2716 struct rte_eth_rss_reta_entry64 *reta_conf,
2717 uint16_t nb_entries)
2721 uint16_t hash_index, idx, shift;
2724 const char *p, *p0 = str;
2731 unsigned long int_fld[_NUM_FLD];
2732 char *str_fld[_NUM_FLD];
2734 while ((p = strchr(p0,'(')) != NULL) {
2736 if((p0 = strchr(p,')')) == NULL)
2740 if(size >= sizeof(s))
2743 snprintf(s, sizeof(s), "%.*s", size, p);
2744 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2746 for (i = 0; i < _NUM_FLD; i++) {
2748 int_fld[i] = strtoul(str_fld[i], &end, 0);
2749 if (errno != 0 || end == str_fld[i] ||
2754 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2755 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2757 if (hash_index >= nb_entries) {
2758 printf("Invalid RETA hash index=%d\n", hash_index);
2762 idx = hash_index / RTE_RETA_GROUP_SIZE;
2763 shift = hash_index % RTE_RETA_GROUP_SIZE;
2764 reta_conf[idx].mask |= (1ULL << shift);
2765 reta_conf[idx].reta[shift] = nb_queue;
2772 cmd_set_rss_reta_parsed(void *parsed_result,
2773 __attribute__((unused)) struct cmdline *cl,
2774 __attribute__((unused)) void *data)
2777 struct rte_eth_dev_info dev_info;
2778 struct rte_eth_rss_reta_entry64 reta_conf[8];
2779 struct cmd_config_rss_reta *res = parsed_result;
2781 memset(&dev_info, 0, sizeof(dev_info));
2782 rte_eth_dev_info_get(res->port_id, &dev_info);
2783 if (dev_info.reta_size == 0) {
2784 printf("Redirection table size is 0 which is "
2785 "invalid for RSS\n");
2788 printf("The reta size of port %d is %u\n",
2789 res->port_id, dev_info.reta_size);
2790 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2791 printf("Currently do not support more than %u entries of "
2792 "redirection table\n", ETH_RSS_RETA_SIZE_512);
2796 memset(reta_conf, 0, sizeof(reta_conf));
2797 if (!strcmp(res->list_name, "reta")) {
2798 if (parse_reta_config(res->list_of_items, reta_conf,
2799 dev_info.reta_size)) {
2800 printf("Invalid RSS Redirection Table "
2801 "config entered\n");
2804 ret = rte_eth_dev_rss_reta_update(res->port_id,
2805 reta_conf, dev_info.reta_size);
2807 printf("Bad redirection table parameter, "
2808 "return code = %d \n", ret);
2812 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2813 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2814 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2815 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2816 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2817 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16);
2818 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2819 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2820 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2821 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2822 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2823 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2825 cmdline_parse_inst_t cmd_config_rss_reta = {
2826 .f = cmd_set_rss_reta_parsed,
2828 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2830 (void *)&cmd_config_rss_reta_port,
2831 (void *)&cmd_config_rss_reta_keyword,
2832 (void *)&cmd_config_rss_reta_port_id,
2833 (void *)&cmd_config_rss_reta_name,
2834 (void *)&cmd_config_rss_reta_list_name,
2835 (void *)&cmd_config_rss_reta_list_of_items,
2840 /* *** SHOW PORT RETA INFO *** */
2841 struct cmd_showport_reta {
2842 cmdline_fixed_string_t show;
2843 cmdline_fixed_string_t port;
2845 cmdline_fixed_string_t rss;
2846 cmdline_fixed_string_t reta;
2848 cmdline_fixed_string_t list_of_items;
2852 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2853 uint16_t nb_entries,
2857 const char *p, *p0 = str;
2862 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
2863 RTE_RETA_GROUP_SIZE;
2866 p = strchr(p0, '(');
2870 p0 = strchr(p, ')');
2874 if (size >= sizeof(s)) {
2875 printf("The string size exceeds the internal buffer size\n");
2878 snprintf(s, sizeof(s), "%.*s", size, p);
2879 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
2880 if (ret <= 0 || ret != num) {
2881 printf("The bits of masks do not match the number of "
2882 "reta entries: %u\n", num);
2885 for (i = 0; i < ret; i++)
2886 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
2892 cmd_showport_reta_parsed(void *parsed_result,
2893 __attribute__((unused)) struct cmdline *cl,
2894 __attribute__((unused)) void *data)
2896 struct cmd_showport_reta *res = parsed_result;
2897 struct rte_eth_rss_reta_entry64 reta_conf[8];
2898 struct rte_eth_dev_info dev_info;
2899 uint16_t max_reta_size;
2901 memset(&dev_info, 0, sizeof(dev_info));
2902 rte_eth_dev_info_get(res->port_id, &dev_info);
2903 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
2904 if (res->size == 0 || res->size > max_reta_size) {
2905 printf("Invalid redirection table size: %u (1-%u)\n",
2906 res->size, max_reta_size);
2910 memset(reta_conf, 0, sizeof(reta_conf));
2911 if (showport_parse_reta_config(reta_conf, res->size,
2912 res->list_of_items) < 0) {
2913 printf("Invalid string: %s for reta masks\n",
2914 res->list_of_items);
2917 port_rss_reta_info(res->port_id, reta_conf, res->size);
2920 cmdline_parse_token_string_t cmd_showport_reta_show =
2921 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
2922 cmdline_parse_token_string_t cmd_showport_reta_port =
2923 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
2924 cmdline_parse_token_num_t cmd_showport_reta_port_id =
2925 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16);
2926 cmdline_parse_token_string_t cmd_showport_reta_rss =
2927 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
2928 cmdline_parse_token_string_t cmd_showport_reta_reta =
2929 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
2930 cmdline_parse_token_num_t cmd_showport_reta_size =
2931 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
2932 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
2933 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
2934 list_of_items, NULL);
2936 cmdline_parse_inst_t cmd_showport_reta = {
2937 .f = cmd_showport_reta_parsed,
2939 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
2941 (void *)&cmd_showport_reta_show,
2942 (void *)&cmd_showport_reta_port,
2943 (void *)&cmd_showport_reta_port_id,
2944 (void *)&cmd_showport_reta_rss,
2945 (void *)&cmd_showport_reta_reta,
2946 (void *)&cmd_showport_reta_size,
2947 (void *)&cmd_showport_reta_list_of_items,
2952 /* *** Show RSS hash configuration *** */
2953 struct cmd_showport_rss_hash {
2954 cmdline_fixed_string_t show;
2955 cmdline_fixed_string_t port;
2957 cmdline_fixed_string_t rss_hash;
2958 cmdline_fixed_string_t rss_type;
2959 cmdline_fixed_string_t key; /* optional argument */
2962 static void cmd_showport_rss_hash_parsed(void *parsed_result,
2963 __attribute__((unused)) struct cmdline *cl,
2966 struct cmd_showport_rss_hash *res = parsed_result;
2968 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
2971 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
2972 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
2973 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
2974 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
2975 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
2976 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16);
2977 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
2978 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
2980 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
2981 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
2983 cmdline_parse_inst_t cmd_showport_rss_hash = {
2984 .f = cmd_showport_rss_hash_parsed,
2986 .help_str = "show port <port_id> rss-hash",
2988 (void *)&cmd_showport_rss_hash_show,
2989 (void *)&cmd_showport_rss_hash_port,
2990 (void *)&cmd_showport_rss_hash_port_id,
2991 (void *)&cmd_showport_rss_hash_rss_hash,
2996 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
2997 .f = cmd_showport_rss_hash_parsed,
2999 .help_str = "show port <port_id> rss-hash key",
3001 (void *)&cmd_showport_rss_hash_show,
3002 (void *)&cmd_showport_rss_hash_port,
3003 (void *)&cmd_showport_rss_hash_port_id,
3004 (void *)&cmd_showport_rss_hash_rss_hash,
3005 (void *)&cmd_showport_rss_hash_rss_key,
3010 /* *** Configure DCB *** */
3011 struct cmd_config_dcb {
3012 cmdline_fixed_string_t port;
3013 cmdline_fixed_string_t config;
3015 cmdline_fixed_string_t dcb;
3016 cmdline_fixed_string_t vt;
3017 cmdline_fixed_string_t vt_en;
3019 cmdline_fixed_string_t pfc;
3020 cmdline_fixed_string_t pfc_en;
3024 cmd_config_dcb_parsed(void *parsed_result,
3025 __attribute__((unused)) struct cmdline *cl,
3026 __attribute__((unused)) void *data)
3028 struct cmd_config_dcb *res = parsed_result;
3029 portid_t port_id = res->port_id;
3030 struct rte_port *port;
3034 port = &ports[port_id];
3035 /** Check if the port is not started **/
3036 if (port->port_status != RTE_PORT_STOPPED) {
3037 printf("Please stop port %d first\n", port_id);
3041 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
3042 printf("The invalid number of traffic class,"
3043 " only 4 or 8 allowed.\n");
3047 if (nb_fwd_lcores < res->num_tcs) {
3048 printf("nb_cores shouldn't be less than number of TCs.\n");
3051 if (!strncmp(res->pfc_en, "on", 2))
3056 /* DCB in VT mode */
3057 if (!strncmp(res->vt_en, "on", 2))
3058 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3059 (enum rte_eth_nb_tcs)res->num_tcs,
3062 ret = init_port_dcb_config(port_id, DCB_ENABLED,
3063 (enum rte_eth_nb_tcs)res->num_tcs,
3068 printf("Cannot initialize network ports.\n");
3072 cmd_reconfig_device_queue(port_id, 1, 1);
3075 cmdline_parse_token_string_t cmd_config_dcb_port =
3076 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3077 cmdline_parse_token_string_t cmd_config_dcb_config =
3078 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3079 cmdline_parse_token_num_t cmd_config_dcb_port_id =
3080 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16);
3081 cmdline_parse_token_string_t cmd_config_dcb_dcb =
3082 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3083 cmdline_parse_token_string_t cmd_config_dcb_vt =
3084 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3085 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3086 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3087 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3088 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
3089 cmdline_parse_token_string_t cmd_config_dcb_pfc=
3090 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3091 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
3092 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
3094 cmdline_parse_inst_t cmd_config_dcb = {
3095 .f = cmd_config_dcb_parsed,
3097 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
3099 (void *)&cmd_config_dcb_port,
3100 (void *)&cmd_config_dcb_config,
3101 (void *)&cmd_config_dcb_port_id,
3102 (void *)&cmd_config_dcb_dcb,
3103 (void *)&cmd_config_dcb_vt,
3104 (void *)&cmd_config_dcb_vt_en,
3105 (void *)&cmd_config_dcb_num_tcs,
3106 (void *)&cmd_config_dcb_pfc,
3107 (void *)&cmd_config_dcb_pfc_en,
3112 /* *** configure number of packets per burst *** */
3113 struct cmd_config_burst {
3114 cmdline_fixed_string_t port;
3115 cmdline_fixed_string_t keyword;
3116 cmdline_fixed_string_t all;
3117 cmdline_fixed_string_t name;
3122 cmd_config_burst_parsed(void *parsed_result,
3123 __attribute__((unused)) struct cmdline *cl,
3124 __attribute__((unused)) void *data)
3126 struct cmd_config_burst *res = parsed_result;
3127 struct rte_eth_dev_info dev_info;
3128 uint16_t rec_nb_pkts;
3130 if (!all_ports_stopped()) {
3131 printf("Please stop all ports first\n");
3135 if (!strcmp(res->name, "burst")) {
3136 if (res->value == 0) {
3137 /* If user gives a value of zero, query the PMD for
3138 * its recommended Rx burst size. Testpmd uses a single
3139 * size for all ports, so assume all ports are the same
3140 * NIC model and use the values from Port 0.
3142 rte_eth_dev_info_get(0, &dev_info);
3143 rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3145 if (rec_nb_pkts == 0) {
3146 printf("PMD does not recommend a burst size.\n"
3147 "User provided value must be between"
3148 " 1 and %d\n", MAX_PKT_BURST);
3150 } else if (rec_nb_pkts > MAX_PKT_BURST) {
3151 printf("PMD recommended burst size of %d"
3152 " exceeds maximum value of %d\n",
3153 rec_nb_pkts, MAX_PKT_BURST);
3156 printf("Using PMD-provided burst value of %d\n",
3158 nb_pkt_per_burst = rec_nb_pkts;
3159 } else if (res->value > MAX_PKT_BURST) {
3160 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
3163 nb_pkt_per_burst = res->value;
3165 printf("Unknown parameter\n");
3171 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3174 cmdline_parse_token_string_t cmd_config_burst_port =
3175 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3176 cmdline_parse_token_string_t cmd_config_burst_keyword =
3177 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3178 cmdline_parse_token_string_t cmd_config_burst_all =
3179 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3180 cmdline_parse_token_string_t cmd_config_burst_name =
3181 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3182 cmdline_parse_token_num_t cmd_config_burst_value =
3183 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
3185 cmdline_parse_inst_t cmd_config_burst = {
3186 .f = cmd_config_burst_parsed,
3188 .help_str = "port config all burst <value>",
3190 (void *)&cmd_config_burst_port,
3191 (void *)&cmd_config_burst_keyword,
3192 (void *)&cmd_config_burst_all,
3193 (void *)&cmd_config_burst_name,
3194 (void *)&cmd_config_burst_value,
3199 /* *** configure rx/tx queues *** */
3200 struct cmd_config_thresh {
3201 cmdline_fixed_string_t port;
3202 cmdline_fixed_string_t keyword;
3203 cmdline_fixed_string_t all;
3204 cmdline_fixed_string_t name;
3209 cmd_config_thresh_parsed(void *parsed_result,
3210 __attribute__((unused)) struct cmdline *cl,
3211 __attribute__((unused)) void *data)
3213 struct cmd_config_thresh *res = parsed_result;
3215 if (!all_ports_stopped()) {
3216 printf("Please stop all ports first\n");
3220 if (!strcmp(res->name, "txpt"))
3221 tx_pthresh = res->value;
3222 else if(!strcmp(res->name, "txht"))
3223 tx_hthresh = res->value;
3224 else if(!strcmp(res->name, "txwt"))
3225 tx_wthresh = res->value;
3226 else if(!strcmp(res->name, "rxpt"))
3227 rx_pthresh = res->value;
3228 else if(!strcmp(res->name, "rxht"))
3229 rx_hthresh = res->value;
3230 else if(!strcmp(res->name, "rxwt"))
3231 rx_wthresh = res->value;
3233 printf("Unknown parameter\n");
3239 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3242 cmdline_parse_token_string_t cmd_config_thresh_port =
3243 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3244 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3245 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3246 cmdline_parse_token_string_t cmd_config_thresh_all =
3247 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3248 cmdline_parse_token_string_t cmd_config_thresh_name =
3249 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3250 "txpt#txht#txwt#rxpt#rxht#rxwt");
3251 cmdline_parse_token_num_t cmd_config_thresh_value =
3252 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
3254 cmdline_parse_inst_t cmd_config_thresh = {
3255 .f = cmd_config_thresh_parsed,
3257 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3259 (void *)&cmd_config_thresh_port,
3260 (void *)&cmd_config_thresh_keyword,
3261 (void *)&cmd_config_thresh_all,
3262 (void *)&cmd_config_thresh_name,
3263 (void *)&cmd_config_thresh_value,
3268 /* *** configure free/rs threshold *** */
3269 struct cmd_config_threshold {
3270 cmdline_fixed_string_t port;
3271 cmdline_fixed_string_t keyword;
3272 cmdline_fixed_string_t all;
3273 cmdline_fixed_string_t name;
3278 cmd_config_threshold_parsed(void *parsed_result,
3279 __attribute__((unused)) struct cmdline *cl,
3280 __attribute__((unused)) void *data)
3282 struct cmd_config_threshold *res = parsed_result;
3284 if (!all_ports_stopped()) {
3285 printf("Please stop all ports first\n");
3289 if (!strcmp(res->name, "txfreet"))
3290 tx_free_thresh = res->value;
3291 else if (!strcmp(res->name, "txrst"))
3292 tx_rs_thresh = res->value;
3293 else if (!strcmp(res->name, "rxfreet"))
3294 rx_free_thresh = res->value;
3296 printf("Unknown parameter\n");
3302 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3305 cmdline_parse_token_string_t cmd_config_threshold_port =
3306 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3307 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3308 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3310 cmdline_parse_token_string_t cmd_config_threshold_all =
3311 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3312 cmdline_parse_token_string_t cmd_config_threshold_name =
3313 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3314 "txfreet#txrst#rxfreet");
3315 cmdline_parse_token_num_t cmd_config_threshold_value =
3316 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
3318 cmdline_parse_inst_t cmd_config_threshold = {
3319 .f = cmd_config_threshold_parsed,
3321 .help_str = "port config all txfreet|txrst|rxfreet <value>",
3323 (void *)&cmd_config_threshold_port,
3324 (void *)&cmd_config_threshold_keyword,
3325 (void *)&cmd_config_threshold_all,
3326 (void *)&cmd_config_threshold_name,
3327 (void *)&cmd_config_threshold_value,
3333 struct cmd_stop_result {
3334 cmdline_fixed_string_t stop;
3337 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
3338 __attribute__((unused)) struct cmdline *cl,
3339 __attribute__((unused)) void *data)
3341 stop_packet_forwarding();
3344 cmdline_parse_token_string_t cmd_stop_stop =
3345 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3347 cmdline_parse_inst_t cmd_stop = {
3348 .f = cmd_stop_parsed,
3350 .help_str = "stop: Stop packet forwarding",
3352 (void *)&cmd_stop_stop,
3357 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3360 parse_item_list(char* str, const char* item_name, unsigned int max_items,
3361 unsigned int *parsed_items, int check_unique_values)
3363 unsigned int nb_item;
3371 * First parse all items in the list and store their value.
3376 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3378 if ((c >= '0') && (c <= '9')) {
3379 value = (unsigned int) (value * 10 + (c - '0'));
3384 printf("character %c is not a decimal digit\n", c);
3388 printf("No valid value before comma\n");
3391 if (nb_item < max_items) {
3392 parsed_items[nb_item] = value;
3398 if (nb_item >= max_items) {
3399 printf("Number of %s = %u > %u (maximum items)\n",
3400 item_name, nb_item + 1, max_items);
3403 parsed_items[nb_item++] = value;
3404 if (! check_unique_values)
3408 * Then, check that all values in the list are differents.
3409 * No optimization here...
3411 for (i = 0; i < nb_item; i++) {
3412 for (j = i + 1; j < nb_item; j++) {
3413 if (parsed_items[j] == parsed_items[i]) {
3414 printf("duplicated %s %u at index %u and %u\n",
3415 item_name, parsed_items[i], i, j);
3423 struct cmd_set_list_result {
3424 cmdline_fixed_string_t cmd_keyword;
3425 cmdline_fixed_string_t list_name;
3426 cmdline_fixed_string_t list_of_items;
3429 static void cmd_set_list_parsed(void *parsed_result,
3430 __attribute__((unused)) struct cmdline *cl,
3431 __attribute__((unused)) void *data)
3433 struct cmd_set_list_result *res;
3435 unsigned int lcorelist[RTE_MAX_LCORE];
3436 unsigned int portlist[RTE_MAX_ETHPORTS];
3438 unsigned int nb_item;
3440 if (test_done == 0) {
3441 printf("Please stop forwarding first\n");
3445 res = parsed_result;
3446 if (!strcmp(res->list_name, "corelist")) {
3447 nb_item = parse_item_list(res->list_of_items, "core",
3449 parsed_items.lcorelist, 1);
3451 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3456 if (!strcmp(res->list_name, "portlist")) {
3457 nb_item = parse_item_list(res->list_of_items, "port",
3459 parsed_items.portlist, 1);
3461 set_fwd_ports_list(parsed_items.portlist, nb_item);
3467 cmdline_parse_token_string_t cmd_set_list_keyword =
3468 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3470 cmdline_parse_token_string_t cmd_set_list_name =
3471 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3472 "corelist#portlist");
3473 cmdline_parse_token_string_t cmd_set_list_of_items =
3474 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3477 cmdline_parse_inst_t cmd_set_fwd_list = {
3478 .f = cmd_set_list_parsed,
3480 .help_str = "set corelist|portlist <list0[,list1]*>",
3482 (void *)&cmd_set_list_keyword,
3483 (void *)&cmd_set_list_name,
3484 (void *)&cmd_set_list_of_items,
3489 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3491 struct cmd_setmask_result {
3492 cmdline_fixed_string_t set;
3493 cmdline_fixed_string_t mask;
3497 static void cmd_set_mask_parsed(void *parsed_result,
3498 __attribute__((unused)) struct cmdline *cl,
3499 __attribute__((unused)) void *data)
3501 struct cmd_setmask_result *res = parsed_result;
3503 if (test_done == 0) {
3504 printf("Please stop forwarding first\n");
3507 if (!strcmp(res->mask, "coremask")) {
3508 set_fwd_lcores_mask(res->hexavalue);
3510 } else if (!strcmp(res->mask, "portmask")) {
3511 set_fwd_ports_mask(res->hexavalue);
3516 cmdline_parse_token_string_t cmd_setmask_set =
3517 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3518 cmdline_parse_token_string_t cmd_setmask_mask =
3519 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3520 "coremask#portmask");
3521 cmdline_parse_token_num_t cmd_setmask_value =
3522 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
3524 cmdline_parse_inst_t cmd_set_fwd_mask = {
3525 .f = cmd_set_mask_parsed,
3527 .help_str = "set coremask|portmask <hexadecimal value>",
3529 (void *)&cmd_setmask_set,
3530 (void *)&cmd_setmask_mask,
3531 (void *)&cmd_setmask_value,
3537 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3539 struct cmd_set_result {
3540 cmdline_fixed_string_t set;
3541 cmdline_fixed_string_t what;
3545 static void cmd_set_parsed(void *parsed_result,
3546 __attribute__((unused)) struct cmdline *cl,
3547 __attribute__((unused)) void *data)
3549 struct cmd_set_result *res = parsed_result;
3550 if (!strcmp(res->what, "nbport")) {
3551 set_fwd_ports_number(res->value);
3553 } else if (!strcmp(res->what, "nbcore")) {
3554 set_fwd_lcores_number(res->value);
3556 } else if (!strcmp(res->what, "burst"))
3557 set_nb_pkt_per_burst(res->value);
3558 else if (!strcmp(res->what, "verbose"))
3559 set_verbose_level(res->value);
3562 cmdline_parse_token_string_t cmd_set_set =
3563 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3564 cmdline_parse_token_string_t cmd_set_what =
3565 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3566 "nbport#nbcore#burst#verbose");
3567 cmdline_parse_token_num_t cmd_set_value =
3568 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
3570 cmdline_parse_inst_t cmd_set_numbers = {
3571 .f = cmd_set_parsed,
3573 .help_str = "set nbport|nbcore|burst|verbose <value>",
3575 (void *)&cmd_set_set,
3576 (void *)&cmd_set_what,
3577 (void *)&cmd_set_value,
3582 /* *** SET LOG LEVEL CONFIGURATION *** */
3584 struct cmd_set_log_result {
3585 cmdline_fixed_string_t set;
3586 cmdline_fixed_string_t log;
3587 cmdline_fixed_string_t type;
3592 cmd_set_log_parsed(void *parsed_result,
3593 __attribute__((unused)) struct cmdline *cl,
3594 __attribute__((unused)) void *data)
3596 struct cmd_set_log_result *res;
3599 res = parsed_result;
3600 if (!strcmp(res->type, "global"))
3601 rte_log_set_global_level(res->level);
3603 ret = rte_log_set_level_regexp(res->type, res->level);
3605 printf("Unable to set log level\n");
3609 cmdline_parse_token_string_t cmd_set_log_set =
3610 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3611 cmdline_parse_token_string_t cmd_set_log_log =
3612 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3613 cmdline_parse_token_string_t cmd_set_log_type =
3614 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3615 cmdline_parse_token_num_t cmd_set_log_level =
3616 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, UINT32);
3618 cmdline_parse_inst_t cmd_set_log = {
3619 .f = cmd_set_log_parsed,
3621 .help_str = "set log global|<type> <level>",
3623 (void *)&cmd_set_log_set,
3624 (void *)&cmd_set_log_log,
3625 (void *)&cmd_set_log_type,
3626 (void *)&cmd_set_log_level,
3631 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3633 struct cmd_set_txpkts_result {
3634 cmdline_fixed_string_t cmd_keyword;
3635 cmdline_fixed_string_t txpkts;
3636 cmdline_fixed_string_t seg_lengths;
3640 cmd_set_txpkts_parsed(void *parsed_result,
3641 __attribute__((unused)) struct cmdline *cl,
3642 __attribute__((unused)) void *data)
3644 struct cmd_set_txpkts_result *res;
3645 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3646 unsigned int nb_segs;
3648 res = parsed_result;
3649 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3650 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3652 set_tx_pkt_segments(seg_lengths, nb_segs);
3655 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3656 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3657 cmd_keyword, "set");
3658 cmdline_parse_token_string_t cmd_set_txpkts_name =
3659 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3661 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3662 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3665 cmdline_parse_inst_t cmd_set_txpkts = {
3666 .f = cmd_set_txpkts_parsed,
3668 .help_str = "set txpkts <len0[,len1]*>",
3670 (void *)&cmd_set_txpkts_keyword,
3671 (void *)&cmd_set_txpkts_name,
3672 (void *)&cmd_set_txpkts_lengths,
3677 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
3679 struct cmd_set_txsplit_result {
3680 cmdline_fixed_string_t cmd_keyword;
3681 cmdline_fixed_string_t txsplit;
3682 cmdline_fixed_string_t mode;
3686 cmd_set_txsplit_parsed(void *parsed_result,
3687 __attribute__((unused)) struct cmdline *cl,
3688 __attribute__((unused)) void *data)
3690 struct cmd_set_txsplit_result *res;
3692 res = parsed_result;
3693 set_tx_pkt_split(res->mode);
3696 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
3697 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3698 cmd_keyword, "set");
3699 cmdline_parse_token_string_t cmd_set_txsplit_name =
3700 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3701 txsplit, "txsplit");
3702 cmdline_parse_token_string_t cmd_set_txsplit_mode =
3703 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3706 cmdline_parse_inst_t cmd_set_txsplit = {
3707 .f = cmd_set_txsplit_parsed,
3709 .help_str = "set txsplit on|off|rand",
3711 (void *)&cmd_set_txsplit_keyword,
3712 (void *)&cmd_set_txsplit_name,
3713 (void *)&cmd_set_txsplit_mode,
3718 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
3719 struct cmd_rx_vlan_filter_all_result {
3720 cmdline_fixed_string_t rx_vlan;
3721 cmdline_fixed_string_t what;
3722 cmdline_fixed_string_t all;
3727 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
3728 __attribute__((unused)) struct cmdline *cl,
3729 __attribute__((unused)) void *data)
3731 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
3733 if (!strcmp(res->what, "add"))
3734 rx_vlan_all_filter_set(res->port_id, 1);
3736 rx_vlan_all_filter_set(res->port_id, 0);
3739 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
3740 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3741 rx_vlan, "rx_vlan");
3742 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
3743 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3745 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
3746 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3748 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
3749 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3752 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
3753 .f = cmd_rx_vlan_filter_all_parsed,
3755 .help_str = "rx_vlan add|rm all <port_id>: "
3756 "Add/Remove all identifiers to/from the set of VLAN "
3757 "identifiers filtered by a port",
3759 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
3760 (void *)&cmd_rx_vlan_filter_all_what,
3761 (void *)&cmd_rx_vlan_filter_all_all,
3762 (void *)&cmd_rx_vlan_filter_all_portid,
3767 /* *** VLAN OFFLOAD SET ON A PORT *** */
3768 struct cmd_vlan_offload_result {
3769 cmdline_fixed_string_t vlan;
3770 cmdline_fixed_string_t set;
3771 cmdline_fixed_string_t vlan_type;
3772 cmdline_fixed_string_t what;
3773 cmdline_fixed_string_t on;
3774 cmdline_fixed_string_t port_id;
3778 cmd_vlan_offload_parsed(void *parsed_result,
3779 __attribute__((unused)) struct cmdline *cl,
3780 __attribute__((unused)) void *data)
3783 struct cmd_vlan_offload_result *res = parsed_result;
3786 portid_t port_id = 0;
3790 len = strnlen(str, STR_TOKEN_SIZE);
3792 /* Get port_id first */
3800 tmp = strtoul(str, NULL, 0);
3801 /* If port_id greater that what portid_t can represent, return */
3802 if(tmp >= RTE_MAX_ETHPORTS)
3804 port_id = (portid_t)tmp;
3806 if (!strcmp(res->on, "on"))
3811 if (!strcmp(res->what, "strip"))
3812 rx_vlan_strip_set(port_id, on);
3813 else if(!strcmp(res->what, "stripq")){
3814 uint16_t queue_id = 0;
3816 /* No queue_id, return */
3818 printf("must specify (port,queue_id)\n");
3821 tmp = strtoul(str + i + 1, NULL, 0);
3822 /* If queue_id greater that what 16-bits can represent, return */
3826 queue_id = (uint16_t)tmp;
3827 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
3829 else if (!strcmp(res->what, "filter"))
3830 rx_vlan_filter_set(port_id, on);
3832 vlan_extend_set(port_id, on);
3837 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
3838 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3840 cmdline_parse_token_string_t cmd_vlan_offload_set =
3841 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3843 cmdline_parse_token_string_t cmd_vlan_offload_what =
3844 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3845 what, "strip#filter#qinq#stripq");
3846 cmdline_parse_token_string_t cmd_vlan_offload_on =
3847 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3849 cmdline_parse_token_string_t cmd_vlan_offload_portid =
3850 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3853 cmdline_parse_inst_t cmd_vlan_offload = {
3854 .f = cmd_vlan_offload_parsed,
3856 .help_str = "vlan set strip|filter|qinq|stripq on|off "
3857 "<port_id[,queue_id]>: "
3858 "Filter/Strip for rx side qinq(extended) for both rx/tx sides",
3860 (void *)&cmd_vlan_offload_vlan,
3861 (void *)&cmd_vlan_offload_set,
3862 (void *)&cmd_vlan_offload_what,
3863 (void *)&cmd_vlan_offload_on,
3864 (void *)&cmd_vlan_offload_portid,
3869 /* *** VLAN TPID SET ON A PORT *** */
3870 struct cmd_vlan_tpid_result {
3871 cmdline_fixed_string_t vlan;
3872 cmdline_fixed_string_t set;
3873 cmdline_fixed_string_t vlan_type;
3874 cmdline_fixed_string_t what;
3880 cmd_vlan_tpid_parsed(void *parsed_result,
3881 __attribute__((unused)) struct cmdline *cl,
3882 __attribute__((unused)) void *data)
3884 struct cmd_vlan_tpid_result *res = parsed_result;
3885 enum rte_vlan_type vlan_type;
3887 if (!strcmp(res->vlan_type, "inner"))
3888 vlan_type = ETH_VLAN_TYPE_INNER;
3889 else if (!strcmp(res->vlan_type, "outer"))
3890 vlan_type = ETH_VLAN_TYPE_OUTER;
3892 printf("Unknown vlan type\n");
3895 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
3898 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
3899 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3901 cmdline_parse_token_string_t cmd_vlan_tpid_set =
3902 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3904 cmdline_parse_token_string_t cmd_vlan_type =
3905 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3906 vlan_type, "inner#outer");
3907 cmdline_parse_token_string_t cmd_vlan_tpid_what =
3908 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3910 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
3911 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3913 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
3914 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3917 cmdline_parse_inst_t cmd_vlan_tpid = {
3918 .f = cmd_vlan_tpid_parsed,
3920 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
3921 "Set the VLAN Ether type",
3923 (void *)&cmd_vlan_tpid_vlan,
3924 (void *)&cmd_vlan_tpid_set,
3925 (void *)&cmd_vlan_type,
3926 (void *)&cmd_vlan_tpid_what,
3927 (void *)&cmd_vlan_tpid_tpid,
3928 (void *)&cmd_vlan_tpid_portid,
3933 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
3934 struct cmd_rx_vlan_filter_result {
3935 cmdline_fixed_string_t rx_vlan;
3936 cmdline_fixed_string_t what;
3942 cmd_rx_vlan_filter_parsed(void *parsed_result,
3943 __attribute__((unused)) struct cmdline *cl,
3944 __attribute__((unused)) void *data)
3946 struct cmd_rx_vlan_filter_result *res = parsed_result;
3948 if (!strcmp(res->what, "add"))
3949 rx_vft_set(res->port_id, res->vlan_id, 1);
3951 rx_vft_set(res->port_id, res->vlan_id, 0);
3954 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
3955 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3956 rx_vlan, "rx_vlan");
3957 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
3958 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3960 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
3961 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3963 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
3964 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3967 cmdline_parse_inst_t cmd_rx_vlan_filter = {
3968 .f = cmd_rx_vlan_filter_parsed,
3970 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
3971 "Add/Remove a VLAN identifier to/from the set of VLAN "
3972 "identifiers filtered by a port",
3974 (void *)&cmd_rx_vlan_filter_rx_vlan,
3975 (void *)&cmd_rx_vlan_filter_what,
3976 (void *)&cmd_rx_vlan_filter_vlanid,
3977 (void *)&cmd_rx_vlan_filter_portid,
3982 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3983 struct cmd_tx_vlan_set_result {
3984 cmdline_fixed_string_t tx_vlan;
3985 cmdline_fixed_string_t set;
3991 cmd_tx_vlan_set_parsed(void *parsed_result,
3992 __attribute__((unused)) struct cmdline *cl,
3993 __attribute__((unused)) void *data)
3995 struct cmd_tx_vlan_set_result *res = parsed_result;
3997 if (!port_is_stopped(res->port_id)) {
3998 printf("Please stop port %d first\n", res->port_id);
4002 tx_vlan_set(res->port_id, res->vlan_id);
4004 cmd_reconfig_device_queue(res->port_id, 1, 1);
4007 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4008 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4009 tx_vlan, "tx_vlan");
4010 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4011 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4013 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4014 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4016 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
4017 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4020 cmdline_parse_inst_t cmd_tx_vlan_set = {
4021 .f = cmd_tx_vlan_set_parsed,
4023 .help_str = "tx_vlan set <port_id> <vlan_id>: "
4024 "Enable hardware insertion of a single VLAN header "
4025 "with a given TAG Identifier in packets sent on a port",
4027 (void *)&cmd_tx_vlan_set_tx_vlan,
4028 (void *)&cmd_tx_vlan_set_set,
4029 (void *)&cmd_tx_vlan_set_portid,
4030 (void *)&cmd_tx_vlan_set_vlanid,
4035 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4036 struct cmd_tx_vlan_set_qinq_result {
4037 cmdline_fixed_string_t tx_vlan;
4038 cmdline_fixed_string_t set;
4041 uint16_t vlan_id_outer;
4045 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4046 __attribute__((unused)) struct cmdline *cl,
4047 __attribute__((unused)) void *data)
4049 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
4051 if (!port_is_stopped(res->port_id)) {
4052 printf("Please stop port %d first\n", res->port_id);
4056 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
4058 cmd_reconfig_device_queue(res->port_id, 1, 1);
4061 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
4062 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4063 tx_vlan, "tx_vlan");
4064 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
4065 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4067 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
4068 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4070 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
4071 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4073 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
4074 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4075 vlan_id_outer, UINT16);
4077 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
4078 .f = cmd_tx_vlan_set_qinq_parsed,
4080 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
4081 "Enable hardware insertion of double VLAN header "
4082 "with given TAG Identifiers in packets sent on a port",
4084 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
4085 (void *)&cmd_tx_vlan_set_qinq_set,
4086 (void *)&cmd_tx_vlan_set_qinq_portid,
4087 (void *)&cmd_tx_vlan_set_qinq_vlanid,
4088 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
4093 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
4094 struct cmd_tx_vlan_set_pvid_result {
4095 cmdline_fixed_string_t tx_vlan;
4096 cmdline_fixed_string_t set;
4097 cmdline_fixed_string_t pvid;
4100 cmdline_fixed_string_t mode;
4104 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
4105 __attribute__((unused)) struct cmdline *cl,
4106 __attribute__((unused)) void *data)
4108 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
4110 if (strcmp(res->mode, "on") == 0)
4111 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
4113 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
4116 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
4117 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4118 tx_vlan, "tx_vlan");
4119 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
4120 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4122 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
4123 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4125 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
4126 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4128 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
4129 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4131 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
4132 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4135 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
4136 .f = cmd_tx_vlan_set_pvid_parsed,
4138 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
4140 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
4141 (void *)&cmd_tx_vlan_set_pvid_set,
4142 (void *)&cmd_tx_vlan_set_pvid_pvid,
4143 (void *)&cmd_tx_vlan_set_pvid_port_id,
4144 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
4145 (void *)&cmd_tx_vlan_set_pvid_mode,
4150 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4151 struct cmd_tx_vlan_reset_result {
4152 cmdline_fixed_string_t tx_vlan;
4153 cmdline_fixed_string_t reset;
4158 cmd_tx_vlan_reset_parsed(void *parsed_result,
4159 __attribute__((unused)) struct cmdline *cl,
4160 __attribute__((unused)) void *data)
4162 struct cmd_tx_vlan_reset_result *res = parsed_result;
4164 if (!port_is_stopped(res->port_id)) {
4165 printf("Please stop port %d first\n", res->port_id);
4169 tx_vlan_reset(res->port_id);
4171 cmd_reconfig_device_queue(res->port_id, 1, 1);
4174 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4175 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4176 tx_vlan, "tx_vlan");
4177 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4178 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4180 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4181 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4184 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4185 .f = cmd_tx_vlan_reset_parsed,
4187 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4188 "VLAN header in packets sent on a port",
4190 (void *)&cmd_tx_vlan_reset_tx_vlan,
4191 (void *)&cmd_tx_vlan_reset_reset,
4192 (void *)&cmd_tx_vlan_reset_portid,
4198 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4199 struct cmd_csum_result {
4200 cmdline_fixed_string_t csum;
4201 cmdline_fixed_string_t mode;
4202 cmdline_fixed_string_t proto;
4203 cmdline_fixed_string_t hwsw;
4208 csum_show(int port_id)
4210 struct rte_eth_dev_info dev_info;
4211 uint64_t tx_offloads;
4213 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4214 printf("Parse tunnel is %s\n",
4215 (ports[port_id].parse_tunnel) ? "on" : "off");
4216 printf("IP checksum offload is %s\n",
4217 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4218 printf("UDP checksum offload is %s\n",
4219 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4220 printf("TCP checksum offload is %s\n",
4221 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4222 printf("SCTP checksum offload is %s\n",
4223 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4224 printf("Outer-Ip checksum offload is %s\n",
4225 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4226 printf("Outer-Udp checksum offload is %s\n",
4227 (tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
4229 /* display warnings if configuration is not supported by the NIC */
4230 rte_eth_dev_info_get(port_id, &dev_info);
4231 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
4232 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4233 printf("Warning: hardware IP checksum enabled but not "
4234 "supported by port %d\n", port_id);
4236 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
4237 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
4238 printf("Warning: hardware UDP checksum enabled but not "
4239 "supported by port %d\n", port_id);
4241 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
4242 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
4243 printf("Warning: hardware TCP checksum enabled but not "
4244 "supported by port %d\n", port_id);
4246 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
4247 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4248 printf("Warning: hardware SCTP checksum enabled but not "
4249 "supported by port %d\n", port_id);
4251 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4252 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4253 printf("Warning: hardware outer IP checksum enabled but not "
4254 "supported by port %d\n", port_id);
4256 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
4257 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)
4259 printf("Warning: hardware outer UDP checksum enabled but not "
4260 "supported by port %d\n", port_id);
4265 cmd_csum_parsed(void *parsed_result,
4266 __attribute__((unused)) struct cmdline *cl,
4267 __attribute__((unused)) void *data)
4269 struct cmd_csum_result *res = parsed_result;
4271 uint64_t csum_offloads = 0;
4272 struct rte_eth_dev_info dev_info;
4274 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4275 printf("invalid port %d\n", res->port_id);
4278 if (!port_is_stopped(res->port_id)) {
4279 printf("Please stop port %d first\n", res->port_id);
4283 rte_eth_dev_info_get(res->port_id, &dev_info);
4284 if (!strcmp(res->mode, "set")) {
4286 if (!strcmp(res->hwsw, "hw"))
4289 if (!strcmp(res->proto, "ip")) {
4290 if (hw == 0 || (dev_info.tx_offload_capa &
4291 DEV_TX_OFFLOAD_IPV4_CKSUM)) {
4292 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
4294 printf("IP checksum offload is not supported "
4295 "by port %u\n", res->port_id);
4297 } else if (!strcmp(res->proto, "udp")) {
4298 if (hw == 0 || (dev_info.tx_offload_capa &
4299 DEV_TX_OFFLOAD_UDP_CKSUM)) {
4300 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
4302 printf("UDP checksum offload is not supported "
4303 "by port %u\n", res->port_id);
4305 } else if (!strcmp(res->proto, "tcp")) {
4306 if (hw == 0 || (dev_info.tx_offload_capa &
4307 DEV_TX_OFFLOAD_TCP_CKSUM)) {
4308 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
4310 printf("TCP checksum offload is not supported "
4311 "by port %u\n", res->port_id);
4313 } else if (!strcmp(res->proto, "sctp")) {
4314 if (hw == 0 || (dev_info.tx_offload_capa &
4315 DEV_TX_OFFLOAD_SCTP_CKSUM)) {
4316 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
4318 printf("SCTP checksum offload is not supported "
4319 "by port %u\n", res->port_id);
4321 } else if (!strcmp(res->proto, "outer-ip")) {
4322 if (hw == 0 || (dev_info.tx_offload_capa &
4323 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4325 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4327 printf("Outer IP checksum offload is not "
4328 "supported by port %u\n", res->port_id);
4330 } else if (!strcmp(res->proto, "outer-udp")) {
4331 if (hw == 0 || (dev_info.tx_offload_capa &
4332 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
4334 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM;
4336 printf("Outer UDP checksum offload is not "
4337 "supported by port %u\n", res->port_id);
4342 ports[res->port_id].dev_conf.txmode.offloads |=
4345 ports[res->port_id].dev_conf.txmode.offloads &=
4349 csum_show(res->port_id);
4351 cmd_reconfig_device_queue(res->port_id, 1, 1);
4354 cmdline_parse_token_string_t cmd_csum_csum =
4355 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4357 cmdline_parse_token_string_t cmd_csum_mode =
4358 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4360 cmdline_parse_token_string_t cmd_csum_proto =
4361 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4362 proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
4363 cmdline_parse_token_string_t cmd_csum_hwsw =
4364 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4366 cmdline_parse_token_num_t cmd_csum_portid =
4367 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4370 cmdline_parse_inst_t cmd_csum_set = {
4371 .f = cmd_csum_parsed,
4373 .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
4374 "Enable/Disable hardware calculation of L3/L4 checksum when "
4375 "using csum forward engine",
4377 (void *)&cmd_csum_csum,
4378 (void *)&cmd_csum_mode,
4379 (void *)&cmd_csum_proto,
4380 (void *)&cmd_csum_hwsw,
4381 (void *)&cmd_csum_portid,
4386 cmdline_parse_token_string_t cmd_csum_mode_show =
4387 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4390 cmdline_parse_inst_t cmd_csum_show = {
4391 .f = cmd_csum_parsed,
4393 .help_str = "csum show <port_id>: Show checksum offload configuration",
4395 (void *)&cmd_csum_csum,
4396 (void *)&cmd_csum_mode_show,
4397 (void *)&cmd_csum_portid,
4402 /* Enable/disable tunnel parsing */
4403 struct cmd_csum_tunnel_result {
4404 cmdline_fixed_string_t csum;
4405 cmdline_fixed_string_t parse;
4406 cmdline_fixed_string_t onoff;
4411 cmd_csum_tunnel_parsed(void *parsed_result,
4412 __attribute__((unused)) struct cmdline *cl,
4413 __attribute__((unused)) void *data)
4415 struct cmd_csum_tunnel_result *res = parsed_result;
4417 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4420 if (!strcmp(res->onoff, "on"))
4421 ports[res->port_id].parse_tunnel = 1;
4423 ports[res->port_id].parse_tunnel = 0;
4425 csum_show(res->port_id);
4428 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4429 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4431 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4432 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4433 parse, "parse-tunnel");
4434 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4435 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4437 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4438 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4441 cmdline_parse_inst_t cmd_csum_tunnel = {
4442 .f = cmd_csum_tunnel_parsed,
4444 .help_str = "csum parse-tunnel on|off <port_id>: "
4445 "Enable/Disable parsing of tunnels for csum engine",
4447 (void *)&cmd_csum_tunnel_csum,
4448 (void *)&cmd_csum_tunnel_parse,
4449 (void *)&cmd_csum_tunnel_onoff,
4450 (void *)&cmd_csum_tunnel_portid,
4455 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4456 struct cmd_tso_set_result {
4457 cmdline_fixed_string_t tso;
4458 cmdline_fixed_string_t mode;
4464 cmd_tso_set_parsed(void *parsed_result,
4465 __attribute__((unused)) struct cmdline *cl,
4466 __attribute__((unused)) void *data)
4468 struct cmd_tso_set_result *res = parsed_result;
4469 struct rte_eth_dev_info dev_info;
4471 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4473 if (!port_is_stopped(res->port_id)) {
4474 printf("Please stop port %d first\n", res->port_id);
4478 if (!strcmp(res->mode, "set"))
4479 ports[res->port_id].tso_segsz = res->tso_segsz;
4481 rte_eth_dev_info_get(res->port_id, &dev_info);
4482 if ((ports[res->port_id].tso_segsz != 0) &&
4483 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4484 printf("Error: TSO is not supported by port %d\n",
4489 if (ports[res->port_id].tso_segsz == 0) {
4490 ports[res->port_id].dev_conf.txmode.offloads &=
4491 ~DEV_TX_OFFLOAD_TCP_TSO;
4492 printf("TSO for non-tunneled packets is disabled\n");
4494 ports[res->port_id].dev_conf.txmode.offloads |=
4495 DEV_TX_OFFLOAD_TCP_TSO;
4496 printf("TSO segment size for non-tunneled packets is %d\n",
4497 ports[res->port_id].tso_segsz);
4500 /* display warnings if configuration is not supported by the NIC */
4501 rte_eth_dev_info_get(res->port_id, &dev_info);
4502 if ((ports[res->port_id].tso_segsz != 0) &&
4503 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4504 printf("Warning: TSO enabled but not "
4505 "supported by port %d\n", res->port_id);
4508 cmd_reconfig_device_queue(res->port_id, 1, 1);
4511 cmdline_parse_token_string_t cmd_tso_set_tso =
4512 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4514 cmdline_parse_token_string_t cmd_tso_set_mode =
4515 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4517 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4518 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4520 cmdline_parse_token_num_t cmd_tso_set_portid =
4521 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4524 cmdline_parse_inst_t cmd_tso_set = {
4525 .f = cmd_tso_set_parsed,
4527 .help_str = "tso set <tso_segsz> <port_id>: "
4528 "Set TSO segment size of non-tunneled packets for csum engine "
4531 (void *)&cmd_tso_set_tso,
4532 (void *)&cmd_tso_set_mode,
4533 (void *)&cmd_tso_set_tso_segsz,
4534 (void *)&cmd_tso_set_portid,
4539 cmdline_parse_token_string_t cmd_tso_show_mode =
4540 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4544 cmdline_parse_inst_t cmd_tso_show = {
4545 .f = cmd_tso_set_parsed,
4547 .help_str = "tso show <port_id>: "
4548 "Show TSO segment size of non-tunneled packets for csum engine",
4550 (void *)&cmd_tso_set_tso,
4551 (void *)&cmd_tso_show_mode,
4552 (void *)&cmd_tso_set_portid,
4557 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
4558 struct cmd_tunnel_tso_set_result {
4559 cmdline_fixed_string_t tso;
4560 cmdline_fixed_string_t mode;
4565 static struct rte_eth_dev_info
4566 check_tunnel_tso_nic_support(portid_t port_id)
4568 struct rte_eth_dev_info dev_info;
4570 rte_eth_dev_info_get(port_id, &dev_info);
4571 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
4572 printf("Warning: VXLAN TUNNEL TSO not supported therefore "
4573 "not enabled for port %d\n", port_id);
4574 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
4575 printf("Warning: GRE TUNNEL TSO not supported therefore "
4576 "not enabled for port %d\n", port_id);
4577 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
4578 printf("Warning: IPIP TUNNEL TSO not supported therefore "
4579 "not enabled for port %d\n", port_id);
4580 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
4581 printf("Warning: GENEVE TUNNEL TSO not supported therefore "
4582 "not enabled for port %d\n", port_id);
4583 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
4584 printf("Warning: IP TUNNEL TSO not supported therefore "
4585 "not enabled for port %d\n", port_id);
4586 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
4587 printf("Warning: UDP TUNNEL TSO not supported therefore "
4588 "not enabled for port %d\n", port_id);
4593 cmd_tunnel_tso_set_parsed(void *parsed_result,
4594 __attribute__((unused)) struct cmdline *cl,
4595 __attribute__((unused)) void *data)
4597 struct cmd_tunnel_tso_set_result *res = parsed_result;
4598 struct rte_eth_dev_info dev_info;
4600 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4602 if (!port_is_stopped(res->port_id)) {
4603 printf("Please stop port %d first\n", res->port_id);
4607 if (!strcmp(res->mode, "set"))
4608 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
4610 dev_info = check_tunnel_tso_nic_support(res->port_id);
4611 if (ports[res->port_id].tunnel_tso_segsz == 0) {
4612 ports[res->port_id].dev_conf.txmode.offloads &=
4613 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4614 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4615 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4616 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4617 DEV_TX_OFFLOAD_IP_TNL_TSO |
4618 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4619 printf("TSO for tunneled packets is disabled\n");
4621 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4622 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4623 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4624 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4625 DEV_TX_OFFLOAD_IP_TNL_TSO |
4626 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4628 ports[res->port_id].dev_conf.txmode.offloads |=
4629 (tso_offloads & dev_info.tx_offload_capa);
4630 printf("TSO segment size for tunneled packets is %d\n",
4631 ports[res->port_id].tunnel_tso_segsz);
4633 /* Below conditions are needed to make it work:
4634 * (1) tunnel TSO is supported by the NIC;
4635 * (2) "csum parse_tunnel" must be set so that tunneled pkts
4637 * (3) for tunneled pkts with outer L3 of IPv4,
4638 * "csum set outer-ip" must be set to hw, because after tso,
4639 * total_len of outer IP header is changed, and the checksum
4640 * of outer IP header calculated by sw should be wrong; that
4641 * is not necessary for IPv6 tunneled pkts because there's no
4642 * checksum in IP header anymore.
4645 if (!ports[res->port_id].parse_tunnel)
4646 printf("Warning: csum parse_tunnel must be set "
4647 "so that tunneled packets are recognized\n");
4648 if (!(ports[res->port_id].dev_conf.txmode.offloads &
4649 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
4650 printf("Warning: csum set outer-ip must be set to hw "
4651 "if outer L3 is IPv4; not necessary for IPv6\n");
4654 cmd_reconfig_device_queue(res->port_id, 1, 1);
4657 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
4658 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4660 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
4661 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4663 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
4664 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4666 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
4667 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4670 cmdline_parse_inst_t cmd_tunnel_tso_set = {
4671 .f = cmd_tunnel_tso_set_parsed,
4673 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
4674 "Set TSO segment size of tunneled packets for csum engine "
4677 (void *)&cmd_tunnel_tso_set_tso,
4678 (void *)&cmd_tunnel_tso_set_mode,
4679 (void *)&cmd_tunnel_tso_set_tso_segsz,
4680 (void *)&cmd_tunnel_tso_set_portid,
4685 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
4686 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4690 cmdline_parse_inst_t cmd_tunnel_tso_show = {
4691 .f = cmd_tunnel_tso_set_parsed,
4693 .help_str = "tunnel_tso show <port_id> "
4694 "Show TSO segment size of tunneled packets for csum engine",
4696 (void *)&cmd_tunnel_tso_set_tso,
4697 (void *)&cmd_tunnel_tso_show_mode,
4698 (void *)&cmd_tunnel_tso_set_portid,
4703 /* *** SET GRO FOR A PORT *** */
4704 struct cmd_gro_enable_result {
4705 cmdline_fixed_string_t cmd_set;
4706 cmdline_fixed_string_t cmd_port;
4707 cmdline_fixed_string_t cmd_keyword;
4708 cmdline_fixed_string_t cmd_onoff;
4713 cmd_gro_enable_parsed(void *parsed_result,
4714 __attribute__((unused)) struct cmdline *cl,
4715 __attribute__((unused)) void *data)
4717 struct cmd_gro_enable_result *res;
4719 res = parsed_result;
4720 if (!strcmp(res->cmd_keyword, "gro"))
4721 setup_gro(res->cmd_onoff, res->cmd_pid);
4724 cmdline_parse_token_string_t cmd_gro_enable_set =
4725 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4727 cmdline_parse_token_string_t cmd_gro_enable_port =
4728 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4729 cmd_keyword, "port");
4730 cmdline_parse_token_num_t cmd_gro_enable_pid =
4731 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
4733 cmdline_parse_token_string_t cmd_gro_enable_keyword =
4734 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4735 cmd_keyword, "gro");
4736 cmdline_parse_token_string_t cmd_gro_enable_onoff =
4737 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4738 cmd_onoff, "on#off");
4740 cmdline_parse_inst_t cmd_gro_enable = {
4741 .f = cmd_gro_enable_parsed,
4743 .help_str = "set port <port_id> gro on|off",
4745 (void *)&cmd_gro_enable_set,
4746 (void *)&cmd_gro_enable_port,
4747 (void *)&cmd_gro_enable_pid,
4748 (void *)&cmd_gro_enable_keyword,
4749 (void *)&cmd_gro_enable_onoff,
4754 /* *** DISPLAY GRO CONFIGURATION *** */
4755 struct cmd_gro_show_result {
4756 cmdline_fixed_string_t cmd_show;
4757 cmdline_fixed_string_t cmd_port;
4758 cmdline_fixed_string_t cmd_keyword;
4763 cmd_gro_show_parsed(void *parsed_result,
4764 __attribute__((unused)) struct cmdline *cl,
4765 __attribute__((unused)) void *data)
4767 struct cmd_gro_show_result *res;
4769 res = parsed_result;
4770 if (!strcmp(res->cmd_keyword, "gro"))
4771 show_gro(res->cmd_pid);
4774 cmdline_parse_token_string_t cmd_gro_show_show =
4775 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4777 cmdline_parse_token_string_t cmd_gro_show_port =
4778 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4780 cmdline_parse_token_num_t cmd_gro_show_pid =
4781 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
4783 cmdline_parse_token_string_t cmd_gro_show_keyword =
4784 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4785 cmd_keyword, "gro");
4787 cmdline_parse_inst_t cmd_gro_show = {
4788 .f = cmd_gro_show_parsed,
4790 .help_str = "show port <port_id> gro",
4792 (void *)&cmd_gro_show_show,
4793 (void *)&cmd_gro_show_port,
4794 (void *)&cmd_gro_show_pid,
4795 (void *)&cmd_gro_show_keyword,
4800 /* *** SET FLUSH CYCLES FOR GRO *** */
4801 struct cmd_gro_flush_result {
4802 cmdline_fixed_string_t cmd_set;
4803 cmdline_fixed_string_t cmd_keyword;
4804 cmdline_fixed_string_t cmd_flush;
4809 cmd_gro_flush_parsed(void *parsed_result,
4810 __attribute__((unused)) struct cmdline *cl,
4811 __attribute__((unused)) void *data)
4813 struct cmd_gro_flush_result *res;
4815 res = parsed_result;
4816 if ((!strcmp(res->cmd_keyword, "gro")) &&
4817 (!strcmp(res->cmd_flush, "flush")))
4818 setup_gro_flush_cycles(res->cmd_cycles);
4821 cmdline_parse_token_string_t cmd_gro_flush_set =
4822 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4824 cmdline_parse_token_string_t cmd_gro_flush_keyword =
4825 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4826 cmd_keyword, "gro");
4827 cmdline_parse_token_string_t cmd_gro_flush_flush =
4828 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4829 cmd_flush, "flush");
4830 cmdline_parse_token_num_t cmd_gro_flush_cycles =
4831 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
4834 cmdline_parse_inst_t cmd_gro_flush = {
4835 .f = cmd_gro_flush_parsed,
4837 .help_str = "set gro flush <cycles>",
4839 (void *)&cmd_gro_flush_set,
4840 (void *)&cmd_gro_flush_keyword,
4841 (void *)&cmd_gro_flush_flush,
4842 (void *)&cmd_gro_flush_cycles,
4847 /* *** ENABLE/DISABLE GSO *** */
4848 struct cmd_gso_enable_result {
4849 cmdline_fixed_string_t cmd_set;
4850 cmdline_fixed_string_t cmd_port;
4851 cmdline_fixed_string_t cmd_keyword;
4852 cmdline_fixed_string_t cmd_mode;
4857 cmd_gso_enable_parsed(void *parsed_result,
4858 __attribute__((unused)) struct cmdline *cl,
4859 __attribute__((unused)) void *data)
4861 struct cmd_gso_enable_result *res;
4863 res = parsed_result;
4864 if (!strcmp(res->cmd_keyword, "gso"))
4865 setup_gso(res->cmd_mode, res->cmd_pid);
4868 cmdline_parse_token_string_t cmd_gso_enable_set =
4869 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4871 cmdline_parse_token_string_t cmd_gso_enable_port =
4872 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4874 cmdline_parse_token_string_t cmd_gso_enable_keyword =
4875 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4876 cmd_keyword, "gso");
4877 cmdline_parse_token_string_t cmd_gso_enable_mode =
4878 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4879 cmd_mode, "on#off");
4880 cmdline_parse_token_num_t cmd_gso_enable_pid =
4881 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
4884 cmdline_parse_inst_t cmd_gso_enable = {
4885 .f = cmd_gso_enable_parsed,
4887 .help_str = "set port <port_id> gso on|off",
4889 (void *)&cmd_gso_enable_set,
4890 (void *)&cmd_gso_enable_port,
4891 (void *)&cmd_gso_enable_pid,
4892 (void *)&cmd_gso_enable_keyword,
4893 (void *)&cmd_gso_enable_mode,
4898 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
4899 struct cmd_gso_size_result {
4900 cmdline_fixed_string_t cmd_set;
4901 cmdline_fixed_string_t cmd_keyword;
4902 cmdline_fixed_string_t cmd_segsz;
4907 cmd_gso_size_parsed(void *parsed_result,
4908 __attribute__((unused)) struct cmdline *cl,
4909 __attribute__((unused)) void *data)
4911 struct cmd_gso_size_result *res = parsed_result;
4913 if (test_done == 0) {
4914 printf("Before setting GSO segsz, please first"
4915 " stop fowarding\n");
4919 if (!strcmp(res->cmd_keyword, "gso") &&
4920 !strcmp(res->cmd_segsz, "segsz")) {
4921 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
4922 printf("gso_size should be larger than %zu."
4923 " Please input a legal value\n",
4924 RTE_GSO_SEG_SIZE_MIN);
4926 gso_max_segment_size = res->cmd_size;
4930 cmdline_parse_token_string_t cmd_gso_size_set =
4931 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4933 cmdline_parse_token_string_t cmd_gso_size_keyword =
4934 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4935 cmd_keyword, "gso");
4936 cmdline_parse_token_string_t cmd_gso_size_segsz =
4937 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4938 cmd_segsz, "segsz");
4939 cmdline_parse_token_num_t cmd_gso_size_size =
4940 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
4943 cmdline_parse_inst_t cmd_gso_size = {
4944 .f = cmd_gso_size_parsed,
4946 .help_str = "set gso segsz <length>",
4948 (void *)&cmd_gso_size_set,
4949 (void *)&cmd_gso_size_keyword,
4950 (void *)&cmd_gso_size_segsz,
4951 (void *)&cmd_gso_size_size,
4956 /* *** SHOW GSO CONFIGURATION *** */
4957 struct cmd_gso_show_result {
4958 cmdline_fixed_string_t cmd_show;
4959 cmdline_fixed_string_t cmd_port;
4960 cmdline_fixed_string_t cmd_keyword;
4965 cmd_gso_show_parsed(void *parsed_result,
4966 __attribute__((unused)) struct cmdline *cl,
4967 __attribute__((unused)) void *data)
4969 struct cmd_gso_show_result *res = parsed_result;
4971 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
4972 printf("invalid port id %u\n", res->cmd_pid);
4975 if (!strcmp(res->cmd_keyword, "gso")) {
4976 if (gso_ports[res->cmd_pid].enable) {
4977 printf("Max GSO'd packet size: %uB\n"
4978 "Supported GSO types: TCP/IPv4, "
4979 "UDP/IPv4, VxLAN with inner "
4980 "TCP/IPv4 packet, GRE with inner "
4981 "TCP/IPv4 packet\n",
4982 gso_max_segment_size);
4984 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
4988 cmdline_parse_token_string_t cmd_gso_show_show =
4989 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4991 cmdline_parse_token_string_t cmd_gso_show_port =
4992 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4994 cmdline_parse_token_string_t cmd_gso_show_keyword =
4995 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4996 cmd_keyword, "gso");
4997 cmdline_parse_token_num_t cmd_gso_show_pid =
4998 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
5001 cmdline_parse_inst_t cmd_gso_show = {
5002 .f = cmd_gso_show_parsed,
5004 .help_str = "show port <port_id> gso",
5006 (void *)&cmd_gso_show_show,
5007 (void *)&cmd_gso_show_port,
5008 (void *)&cmd_gso_show_pid,
5009 (void *)&cmd_gso_show_keyword,
5014 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
5015 struct cmd_set_flush_rx {
5016 cmdline_fixed_string_t set;
5017 cmdline_fixed_string_t flush_rx;
5018 cmdline_fixed_string_t mode;
5022 cmd_set_flush_rx_parsed(void *parsed_result,
5023 __attribute__((unused)) struct cmdline *cl,
5024 __attribute__((unused)) void *data)
5026 struct cmd_set_flush_rx *res = parsed_result;
5027 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5030 cmdline_parse_token_string_t cmd_setflushrx_set =
5031 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5033 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
5034 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5035 flush_rx, "flush_rx");
5036 cmdline_parse_token_string_t cmd_setflushrx_mode =
5037 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5041 cmdline_parse_inst_t cmd_set_flush_rx = {
5042 .f = cmd_set_flush_rx_parsed,
5043 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
5046 (void *)&cmd_setflushrx_set,
5047 (void *)&cmd_setflushrx_flush_rx,
5048 (void *)&cmd_setflushrx_mode,
5053 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
5054 struct cmd_set_link_check {
5055 cmdline_fixed_string_t set;
5056 cmdline_fixed_string_t link_check;
5057 cmdline_fixed_string_t mode;
5061 cmd_set_link_check_parsed(void *parsed_result,
5062 __attribute__((unused)) struct cmdline *cl,
5063 __attribute__((unused)) void *data)
5065 struct cmd_set_link_check *res = parsed_result;
5066 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5069 cmdline_parse_token_string_t cmd_setlinkcheck_set =
5070 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5072 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
5073 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5074 link_check, "link_check");
5075 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
5076 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5080 cmdline_parse_inst_t cmd_set_link_check = {
5081 .f = cmd_set_link_check_parsed,
5082 .help_str = "set link_check on|off: Enable/Disable link status check "
5083 "when starting/stopping a port",
5086 (void *)&cmd_setlinkcheck_set,
5087 (void *)&cmd_setlinkcheck_link_check,
5088 (void *)&cmd_setlinkcheck_mode,
5093 /* *** SET NIC BYPASS MODE *** */
5094 struct cmd_set_bypass_mode_result {
5095 cmdline_fixed_string_t set;
5096 cmdline_fixed_string_t bypass;
5097 cmdline_fixed_string_t mode;
5098 cmdline_fixed_string_t value;
5103 cmd_set_bypass_mode_parsed(void *parsed_result,
5104 __attribute__((unused)) struct cmdline *cl,
5105 __attribute__((unused)) void *data)
5107 struct cmd_set_bypass_mode_result *res = parsed_result;
5108 portid_t port_id = res->port_id;
5109 int32_t rc = -EINVAL;
5111 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5112 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5114 if (!strcmp(res->value, "bypass"))
5115 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5116 else if (!strcmp(res->value, "isolate"))
5117 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5119 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5121 /* Set the bypass mode for the relevant port. */
5122 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
5125 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
5128 cmdline_parse_token_string_t cmd_setbypass_mode_set =
5129 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5131 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
5132 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5134 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
5135 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5137 cmdline_parse_token_string_t cmd_setbypass_mode_value =
5138 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5139 value, "normal#bypass#isolate");
5140 cmdline_parse_token_num_t cmd_setbypass_mode_port =
5141 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
5144 cmdline_parse_inst_t cmd_set_bypass_mode = {
5145 .f = cmd_set_bypass_mode_parsed,
5146 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
5147 "Set the NIC bypass mode for port_id",
5150 (void *)&cmd_setbypass_mode_set,
5151 (void *)&cmd_setbypass_mode_bypass,
5152 (void *)&cmd_setbypass_mode_mode,
5153 (void *)&cmd_setbypass_mode_value,
5154 (void *)&cmd_setbypass_mode_port,
5159 /* *** SET NIC BYPASS EVENT *** */
5160 struct cmd_set_bypass_event_result {
5161 cmdline_fixed_string_t set;
5162 cmdline_fixed_string_t bypass;
5163 cmdline_fixed_string_t event;
5164 cmdline_fixed_string_t event_value;
5165 cmdline_fixed_string_t mode;
5166 cmdline_fixed_string_t mode_value;
5171 cmd_set_bypass_event_parsed(void *parsed_result,
5172 __attribute__((unused)) struct cmdline *cl,
5173 __attribute__((unused)) void *data)
5175 int32_t rc = -EINVAL;
5176 struct cmd_set_bypass_event_result *res = parsed_result;
5177 portid_t port_id = res->port_id;
5179 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5180 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5181 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5183 if (!strcmp(res->event_value, "timeout"))
5184 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
5185 else if (!strcmp(res->event_value, "os_on"))
5186 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
5187 else if (!strcmp(res->event_value, "os_off"))
5188 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5189 else if (!strcmp(res->event_value, "power_on"))
5190 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5191 else if (!strcmp(res->event_value, "power_off"))
5192 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5194 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5196 if (!strcmp(res->mode_value, "bypass"))
5197 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5198 else if (!strcmp(res->mode_value, "isolate"))
5199 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5201 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5203 /* Set the watchdog timeout. */
5204 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5207 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5208 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5212 printf("Failed to set timeout value %u "
5213 "for port %d, errto code: %d.\n",
5214 bypass_timeout, port_id, rc);
5218 /* Set the bypass event to transition to bypass mode. */
5219 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5224 printf("\t Failed to set bypass event for port = %d.\n",
5228 cmdline_parse_token_string_t cmd_setbypass_event_set =
5229 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5231 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5232 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5234 cmdline_parse_token_string_t cmd_setbypass_event_event =
5235 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5237 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5238 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5239 event_value, "none#timeout#os_off#os_on#power_on#power_off");
5240 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5241 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5243 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5244 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5245 mode_value, "normal#bypass#isolate");
5246 cmdline_parse_token_num_t cmd_setbypass_event_port =
5247 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5250 cmdline_parse_inst_t cmd_set_bypass_event = {
5251 .f = cmd_set_bypass_event_parsed,
5252 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5253 "power_off mode normal|bypass|isolate <port_id>: "
5254 "Set the NIC bypass event mode for port_id",
5257 (void *)&cmd_setbypass_event_set,
5258 (void *)&cmd_setbypass_event_bypass,
5259 (void *)&cmd_setbypass_event_event,
5260 (void *)&cmd_setbypass_event_event_value,
5261 (void *)&cmd_setbypass_event_mode,
5262 (void *)&cmd_setbypass_event_mode_value,
5263 (void *)&cmd_setbypass_event_port,
5269 /* *** SET NIC BYPASS TIMEOUT *** */
5270 struct cmd_set_bypass_timeout_result {
5271 cmdline_fixed_string_t set;
5272 cmdline_fixed_string_t bypass;
5273 cmdline_fixed_string_t timeout;
5274 cmdline_fixed_string_t value;
5278 cmd_set_bypass_timeout_parsed(void *parsed_result,
5279 __attribute__((unused)) struct cmdline *cl,
5280 __attribute__((unused)) void *data)
5282 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5284 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5285 if (!strcmp(res->value, "1.5"))
5286 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5287 else if (!strcmp(res->value, "2"))
5288 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5289 else if (!strcmp(res->value, "3"))
5290 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5291 else if (!strcmp(res->value, "4"))
5292 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5293 else if (!strcmp(res->value, "8"))
5294 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5295 else if (!strcmp(res->value, "16"))
5296 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5297 else if (!strcmp(res->value, "32"))
5298 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5300 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5304 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5305 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5307 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5308 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5310 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5311 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5312 timeout, "timeout");
5313 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5314 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5315 value, "0#1.5#2#3#4#8#16#32");
5317 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5318 .f = cmd_set_bypass_timeout_parsed,
5319 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5320 "Set the NIC bypass watchdog timeout in seconds",
5323 (void *)&cmd_setbypass_timeout_set,
5324 (void *)&cmd_setbypass_timeout_bypass,
5325 (void *)&cmd_setbypass_timeout_timeout,
5326 (void *)&cmd_setbypass_timeout_value,
5331 /* *** SHOW NIC BYPASS MODE *** */
5332 struct cmd_show_bypass_config_result {
5333 cmdline_fixed_string_t show;
5334 cmdline_fixed_string_t bypass;
5335 cmdline_fixed_string_t config;
5340 cmd_show_bypass_config_parsed(void *parsed_result,
5341 __attribute__((unused)) struct cmdline *cl,
5342 __attribute__((unused)) void *data)
5344 struct cmd_show_bypass_config_result *res = parsed_result;
5345 portid_t port_id = res->port_id;
5347 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5348 uint32_t event_mode;
5349 uint32_t bypass_mode;
5350 uint32_t timeout = bypass_timeout;
5353 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5354 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
5355 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5356 {"UNKNOWN", "normal", "bypass", "isolate"};
5357 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5364 int num_events = (sizeof events) / (sizeof events[0]);
5366 /* Display the bypass mode.*/
5367 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5368 printf("\tFailed to get bypass mode for port = %d\n", port_id);
5372 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5373 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5375 printf("\tbypass mode = %s\n", modes[bypass_mode]);
5378 /* Display the bypass timeout.*/
5379 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5380 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5382 printf("\tbypass timeout = %s\n", timeouts[timeout]);
5384 /* Display the bypass events and associated modes. */
5385 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < num_events; i++) {
5387 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5388 printf("\tFailed to get bypass mode for event = %s\n",
5391 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5392 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5394 printf("\tbypass event: %-16s = %s\n", events[i],
5400 printf("\tFailed to get bypass configuration for port = %d\n",
5404 cmdline_parse_token_string_t cmd_showbypass_config_show =
5405 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5407 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5408 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5410 cmdline_parse_token_string_t cmd_showbypass_config_config =
5411 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5413 cmdline_parse_token_num_t cmd_showbypass_config_port =
5414 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5417 cmdline_parse_inst_t cmd_show_bypass_config = {
5418 .f = cmd_show_bypass_config_parsed,
5419 .help_str = "show bypass config <port_id>: "
5420 "Show the NIC bypass config for port_id",
5423 (void *)&cmd_showbypass_config_show,
5424 (void *)&cmd_showbypass_config_bypass,
5425 (void *)&cmd_showbypass_config_config,
5426 (void *)&cmd_showbypass_config_port,
5431 #ifdef RTE_LIBRTE_PMD_BOND
5432 /* *** SET BONDING MODE *** */
5433 struct cmd_set_bonding_mode_result {
5434 cmdline_fixed_string_t set;
5435 cmdline_fixed_string_t bonding;
5436 cmdline_fixed_string_t mode;
5441 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5442 __attribute__((unused)) struct cmdline *cl,
5443 __attribute__((unused)) void *data)
5445 struct cmd_set_bonding_mode_result *res = parsed_result;
5446 portid_t port_id = res->port_id;
5448 /* Set the bonding mode for the relevant port. */
5449 if (0 != rte_eth_bond_mode_set(port_id, res->value))
5450 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
5453 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5454 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5456 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5457 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5458 bonding, "bonding");
5459 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5460 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5462 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5463 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5465 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5466 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5469 cmdline_parse_inst_t cmd_set_bonding_mode = {
5470 .f = cmd_set_bonding_mode_parsed,
5471 .help_str = "set bonding mode <mode_value> <port_id>: "
5472 "Set the bonding mode for port_id",
5475 (void *) &cmd_setbonding_mode_set,
5476 (void *) &cmd_setbonding_mode_bonding,
5477 (void *) &cmd_setbonding_mode_mode,
5478 (void *) &cmd_setbonding_mode_value,
5479 (void *) &cmd_setbonding_mode_port,
5484 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5485 struct cmd_set_bonding_lacp_dedicated_queues_result {
5486 cmdline_fixed_string_t set;
5487 cmdline_fixed_string_t bonding;
5488 cmdline_fixed_string_t lacp;
5489 cmdline_fixed_string_t dedicated_queues;
5491 cmdline_fixed_string_t mode;
5494 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5495 __attribute__((unused)) struct cmdline *cl,
5496 __attribute__((unused)) void *data)
5498 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5499 portid_t port_id = res->port_id;
5500 struct rte_port *port;
5502 port = &ports[port_id];
5504 /** Check if the port is not started **/
5505 if (port->port_status != RTE_PORT_STOPPED) {
5506 printf("Please stop port %d first\n", port_id);
5510 if (!strcmp(res->mode, "enable")) {
5511 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5512 printf("Dedicate queues for LACP control packets"
5515 printf("Enabling dedicate queues for LACP control "
5516 "packets on port %d failed\n", port_id);
5517 } else if (!strcmp(res->mode, "disable")) {
5518 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5519 printf("Dedicated queues for LACP control packets "
5522 printf("Disabling dedicated queues for LACP control "
5523 "traffic on port %d failed\n", port_id);
5527 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5528 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5530 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
5531 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5532 bonding, "bonding");
5533 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
5534 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5536 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
5537 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5538 dedicated_queues, "dedicated_queues");
5539 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
5540 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5542 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
5543 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5544 mode, "enable#disable");
5546 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
5547 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
5548 .help_str = "set bonding lacp dedicated_queues <port_id> "
5550 "Enable/disable dedicated queues for LACP control traffic for port_id",
5553 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
5554 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
5555 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
5556 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
5557 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
5558 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
5563 /* *** SET BALANCE XMIT POLICY *** */
5564 struct cmd_set_bonding_balance_xmit_policy_result {
5565 cmdline_fixed_string_t set;
5566 cmdline_fixed_string_t bonding;
5567 cmdline_fixed_string_t balance_xmit_policy;
5569 cmdline_fixed_string_t policy;
5572 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
5573 __attribute__((unused)) struct cmdline *cl,
5574 __attribute__((unused)) void *data)
5576 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
5577 portid_t port_id = res->port_id;
5580 if (!strcmp(res->policy, "l2")) {
5581 policy = BALANCE_XMIT_POLICY_LAYER2;
5582 } else if (!strcmp(res->policy, "l23")) {
5583 policy = BALANCE_XMIT_POLICY_LAYER23;
5584 } else if (!strcmp(res->policy, "l34")) {
5585 policy = BALANCE_XMIT_POLICY_LAYER34;
5587 printf("\t Invalid xmit policy selection");
5591 /* Set the bonding mode for the relevant port. */
5592 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
5593 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
5598 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
5599 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5601 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
5602 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5603 bonding, "bonding");
5604 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
5605 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5606 balance_xmit_policy, "balance_xmit_policy");
5607 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
5608 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5610 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
5611 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5612 policy, "l2#l23#l34");
5614 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
5615 .f = cmd_set_bonding_balance_xmit_policy_parsed,
5616 .help_str = "set bonding balance_xmit_policy <port_id> "
5618 "Set the bonding balance_xmit_policy for port_id",
5621 (void *)&cmd_setbonding_balance_xmit_policy_set,
5622 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
5623 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
5624 (void *)&cmd_setbonding_balance_xmit_policy_port,
5625 (void *)&cmd_setbonding_balance_xmit_policy_policy,
5630 /* *** SHOW NIC BONDING CONFIGURATION *** */
5631 struct cmd_show_bonding_config_result {
5632 cmdline_fixed_string_t show;
5633 cmdline_fixed_string_t bonding;
5634 cmdline_fixed_string_t config;
5638 static void cmd_show_bonding_config_parsed(void *parsed_result,
5639 __attribute__((unused)) struct cmdline *cl,
5640 __attribute__((unused)) void *data)
5642 struct cmd_show_bonding_config_result *res = parsed_result;
5643 int bonding_mode, agg_mode;
5644 portid_t slaves[RTE_MAX_ETHPORTS];
5645 int num_slaves, num_active_slaves;
5648 portid_t port_id = res->port_id;
5650 /* Display the bonding mode.*/
5651 bonding_mode = rte_eth_bond_mode_get(port_id);
5652 if (bonding_mode < 0) {
5653 printf("\tFailed to get bonding mode for port = %d\n", port_id);
5656 printf("\tBonding mode: %d\n", bonding_mode);
5658 if (bonding_mode == BONDING_MODE_BALANCE) {
5659 int balance_xmit_policy;
5661 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
5662 if (balance_xmit_policy < 0) {
5663 printf("\tFailed to get balance xmit policy for port = %d\n",
5667 printf("\tBalance Xmit Policy: ");
5669 switch (balance_xmit_policy) {
5670 case BALANCE_XMIT_POLICY_LAYER2:
5671 printf("BALANCE_XMIT_POLICY_LAYER2");
5673 case BALANCE_XMIT_POLICY_LAYER23:
5674 printf("BALANCE_XMIT_POLICY_LAYER23");
5676 case BALANCE_XMIT_POLICY_LAYER34:
5677 printf("BALANCE_XMIT_POLICY_LAYER34");
5684 if (bonding_mode == BONDING_MODE_8023AD) {
5685 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
5686 printf("\tIEEE802.3AD Aggregator Mode: ");
5689 printf("bandwidth");
5701 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
5703 if (num_slaves < 0) {
5704 printf("\tFailed to get slave list for port = %d\n", port_id);
5707 if (num_slaves > 0) {
5708 printf("\tSlaves (%d): [", num_slaves);
5709 for (i = 0; i < num_slaves - 1; i++)
5710 printf("%d ", slaves[i]);
5712 printf("%d]\n", slaves[num_slaves - 1]);
5714 printf("\tSlaves: []\n");
5718 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
5721 if (num_active_slaves < 0) {
5722 printf("\tFailed to get active slave list for port = %d\n", port_id);
5725 if (num_active_slaves > 0) {
5726 printf("\tActive Slaves (%d): [", num_active_slaves);
5727 for (i = 0; i < num_active_slaves - 1; i++)
5728 printf("%d ", slaves[i]);
5730 printf("%d]\n", slaves[num_active_slaves - 1]);
5733 printf("\tActive Slaves: []\n");
5737 primary_id = rte_eth_bond_primary_get(port_id);
5738 if (primary_id < 0) {
5739 printf("\tFailed to get primary slave for port = %d\n", port_id);
5742 printf("\tPrimary: [%d]\n", primary_id);
5746 cmdline_parse_token_string_t cmd_showbonding_config_show =
5747 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5749 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
5750 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5751 bonding, "bonding");
5752 cmdline_parse_token_string_t cmd_showbonding_config_config =
5753 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5755 cmdline_parse_token_num_t cmd_showbonding_config_port =
5756 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
5759 cmdline_parse_inst_t cmd_show_bonding_config = {
5760 .f = cmd_show_bonding_config_parsed,
5761 .help_str = "show bonding config <port_id>: "
5762 "Show the bonding config for port_id",
5765 (void *)&cmd_showbonding_config_show,
5766 (void *)&cmd_showbonding_config_bonding,
5767 (void *)&cmd_showbonding_config_config,
5768 (void *)&cmd_showbonding_config_port,
5773 /* *** SET BONDING PRIMARY *** */
5774 struct cmd_set_bonding_primary_result {
5775 cmdline_fixed_string_t set;
5776 cmdline_fixed_string_t bonding;
5777 cmdline_fixed_string_t primary;
5782 static void cmd_set_bonding_primary_parsed(void *parsed_result,
5783 __attribute__((unused)) struct cmdline *cl,
5784 __attribute__((unused)) void *data)
5786 struct cmd_set_bonding_primary_result *res = parsed_result;
5787 portid_t master_port_id = res->port_id;
5788 portid_t slave_port_id = res->slave_id;
5790 /* Set the primary slave for a bonded device. */
5791 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
5792 printf("\t Failed to set primary slave for port = %d.\n",
5799 cmdline_parse_token_string_t cmd_setbonding_primary_set =
5800 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5802 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
5803 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5804 bonding, "bonding");
5805 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
5806 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5807 primary, "primary");
5808 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
5809 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5811 cmdline_parse_token_num_t cmd_setbonding_primary_port =
5812 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5815 cmdline_parse_inst_t cmd_set_bonding_primary = {
5816 .f = cmd_set_bonding_primary_parsed,
5817 .help_str = "set bonding primary <slave_id> <port_id>: "
5818 "Set the primary slave for port_id",
5821 (void *)&cmd_setbonding_primary_set,
5822 (void *)&cmd_setbonding_primary_bonding,
5823 (void *)&cmd_setbonding_primary_primary,
5824 (void *)&cmd_setbonding_primary_slave,
5825 (void *)&cmd_setbonding_primary_port,
5830 /* *** ADD SLAVE *** */
5831 struct cmd_add_bonding_slave_result {
5832 cmdline_fixed_string_t add;
5833 cmdline_fixed_string_t bonding;
5834 cmdline_fixed_string_t slave;
5839 static void cmd_add_bonding_slave_parsed(void *parsed_result,
5840 __attribute__((unused)) struct cmdline *cl,
5841 __attribute__((unused)) void *data)
5843 struct cmd_add_bonding_slave_result *res = parsed_result;
5844 portid_t master_port_id = res->port_id;
5845 portid_t slave_port_id = res->slave_id;
5847 /* add the slave for a bonded device. */
5848 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
5849 printf("\t Failed to add slave %d to master port = %d.\n",
5850 slave_port_id, master_port_id);
5854 set_port_slave_flag(slave_port_id);
5857 cmdline_parse_token_string_t cmd_addbonding_slave_add =
5858 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5860 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
5861 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5862 bonding, "bonding");
5863 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
5864 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5866 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
5867 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5869 cmdline_parse_token_num_t cmd_addbonding_slave_port =
5870 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5873 cmdline_parse_inst_t cmd_add_bonding_slave = {
5874 .f = cmd_add_bonding_slave_parsed,
5875 .help_str = "add bonding slave <slave_id> <port_id>: "
5876 "Add a slave device to a bonded device",
5879 (void *)&cmd_addbonding_slave_add,
5880 (void *)&cmd_addbonding_slave_bonding,
5881 (void *)&cmd_addbonding_slave_slave,
5882 (void *)&cmd_addbonding_slave_slaveid,
5883 (void *)&cmd_addbonding_slave_port,
5888 /* *** REMOVE SLAVE *** */
5889 struct cmd_remove_bonding_slave_result {
5890 cmdline_fixed_string_t remove;
5891 cmdline_fixed_string_t bonding;
5892 cmdline_fixed_string_t slave;
5897 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
5898 __attribute__((unused)) struct cmdline *cl,
5899 __attribute__((unused)) void *data)
5901 struct cmd_remove_bonding_slave_result *res = parsed_result;
5902 portid_t master_port_id = res->port_id;
5903 portid_t slave_port_id = res->slave_id;
5905 /* remove the slave from a bonded device. */
5906 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
5907 printf("\t Failed to remove slave %d from master port = %d.\n",
5908 slave_port_id, master_port_id);
5912 clear_port_slave_flag(slave_port_id);
5915 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
5916 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5918 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
5919 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5920 bonding, "bonding");
5921 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
5922 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5924 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
5925 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5927 cmdline_parse_token_num_t cmd_removebonding_slave_port =
5928 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5931 cmdline_parse_inst_t cmd_remove_bonding_slave = {
5932 .f = cmd_remove_bonding_slave_parsed,
5933 .help_str = "remove bonding slave <slave_id> <port_id>: "
5934 "Remove a slave device from a bonded device",
5937 (void *)&cmd_removebonding_slave_remove,
5938 (void *)&cmd_removebonding_slave_bonding,
5939 (void *)&cmd_removebonding_slave_slave,
5940 (void *)&cmd_removebonding_slave_slaveid,
5941 (void *)&cmd_removebonding_slave_port,
5946 /* *** CREATE BONDED DEVICE *** */
5947 struct cmd_create_bonded_device_result {
5948 cmdline_fixed_string_t create;
5949 cmdline_fixed_string_t bonded;
5950 cmdline_fixed_string_t device;
5955 static int bond_dev_num = 0;
5957 static void cmd_create_bonded_device_parsed(void *parsed_result,
5958 __attribute__((unused)) struct cmdline *cl,
5959 __attribute__((unused)) void *data)
5961 struct cmd_create_bonded_device_result *res = parsed_result;
5962 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
5965 if (test_done == 0) {
5966 printf("Please stop forwarding first\n");
5970 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
5973 /* Create a new bonded device. */
5974 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
5976 printf("\t Failed to create bonded device.\n");
5979 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
5982 /* Update number of ports */
5983 nb_ports = rte_eth_dev_count_avail();
5984 reconfig(port_id, res->socket);
5985 rte_eth_promiscuous_enable(port_id);
5986 ports[port_id].need_setup = 0;
5987 ports[port_id].port_status = RTE_PORT_STOPPED;
5992 cmdline_parse_token_string_t cmd_createbonded_device_create =
5993 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5995 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
5996 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5998 cmdline_parse_token_string_t cmd_createbonded_device_device =
5999 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6001 cmdline_parse_token_num_t cmd_createbonded_device_mode =
6002 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6004 cmdline_parse_token_num_t cmd_createbonded_device_socket =
6005 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6008 cmdline_parse_inst_t cmd_create_bonded_device = {
6009 .f = cmd_create_bonded_device_parsed,
6010 .help_str = "create bonded device <mode> <socket>: "
6011 "Create a new bonded device with specific bonding mode and socket",
6014 (void *)&cmd_createbonded_device_create,
6015 (void *)&cmd_createbonded_device_bonded,
6016 (void *)&cmd_createbonded_device_device,
6017 (void *)&cmd_createbonded_device_mode,
6018 (void *)&cmd_createbonded_device_socket,
6023 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
6024 struct cmd_set_bond_mac_addr_result {
6025 cmdline_fixed_string_t set;
6026 cmdline_fixed_string_t bonding;
6027 cmdline_fixed_string_t mac_addr;
6029 struct ether_addr address;
6032 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
6033 __attribute__((unused)) struct cmdline *cl,
6034 __attribute__((unused)) void *data)
6036 struct cmd_set_bond_mac_addr_result *res = parsed_result;
6039 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
6042 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
6044 /* check the return value and print it if is < 0 */
6046 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6049 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
6050 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
6051 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
6052 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
6054 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
6055 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
6057 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
6058 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
6060 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
6061 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
6063 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
6064 .f = cmd_set_bond_mac_addr_parsed,
6066 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
6068 (void *)&cmd_set_bond_mac_addr_set,
6069 (void *)&cmd_set_bond_mac_addr_bonding,
6070 (void *)&cmd_set_bond_mac_addr_mac,
6071 (void *)&cmd_set_bond_mac_addr_portnum,
6072 (void *)&cmd_set_bond_mac_addr_addr,
6078 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
6079 struct cmd_set_bond_mon_period_result {
6080 cmdline_fixed_string_t set;
6081 cmdline_fixed_string_t bonding;
6082 cmdline_fixed_string_t mon_period;
6087 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
6088 __attribute__((unused)) struct cmdline *cl,
6089 __attribute__((unused)) void *data)
6091 struct cmd_set_bond_mon_period_result *res = parsed_result;
6094 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
6096 /* check the return value and print it if is < 0 */
6098 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6101 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
6102 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6104 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
6105 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6106 bonding, "bonding");
6107 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
6108 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6109 mon_period, "mon_period");
6110 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
6111 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6113 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
6114 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6117 cmdline_parse_inst_t cmd_set_bond_mon_period = {
6118 .f = cmd_set_bond_mon_period_parsed,
6120 .help_str = "set bonding mon_period <port_id> <period_ms>",
6122 (void *)&cmd_set_bond_mon_period_set,
6123 (void *)&cmd_set_bond_mon_period_bonding,
6124 (void *)&cmd_set_bond_mon_period_mon_period,
6125 (void *)&cmd_set_bond_mon_period_portnum,
6126 (void *)&cmd_set_bond_mon_period_period_ms,
6133 struct cmd_set_bonding_agg_mode_policy_result {
6134 cmdline_fixed_string_t set;
6135 cmdline_fixed_string_t bonding;
6136 cmdline_fixed_string_t agg_mode;
6138 cmdline_fixed_string_t policy;
6143 cmd_set_bonding_agg_mode(void *parsed_result,
6144 __attribute__((unused)) struct cmdline *cl,
6145 __attribute__((unused)) void *data)
6147 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
6148 uint8_t policy = AGG_BANDWIDTH;
6150 if (!strcmp(res->policy, "bandwidth"))
6151 policy = AGG_BANDWIDTH;
6152 else if (!strcmp(res->policy, "stable"))
6153 policy = AGG_STABLE;
6154 else if (!strcmp(res->policy, "count"))
6157 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
6161 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
6162 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6164 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
6165 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6166 bonding, "bonding");
6168 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
6169 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6170 agg_mode, "agg_mode");
6172 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
6173 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6176 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6177 TOKEN_STRING_INITIALIZER(
6178 struct cmd_set_bonding_balance_xmit_policy_result,
6179 policy, "stable#bandwidth#count");
6181 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6182 .f = cmd_set_bonding_agg_mode,
6184 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6186 (void *)&cmd_set_bonding_agg_mode_set,
6187 (void *)&cmd_set_bonding_agg_mode_bonding,
6188 (void *)&cmd_set_bonding_agg_mode_agg_mode,
6189 (void *)&cmd_set_bonding_agg_mode_portnum,
6190 (void *)&cmd_set_bonding_agg_mode_policy_string,
6196 #endif /* RTE_LIBRTE_PMD_BOND */
6198 /* *** SET FORWARDING MODE *** */
6199 struct cmd_set_fwd_mode_result {
6200 cmdline_fixed_string_t set;
6201 cmdline_fixed_string_t fwd;
6202 cmdline_fixed_string_t mode;
6205 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6206 __attribute__((unused)) struct cmdline *cl,
6207 __attribute__((unused)) void *data)
6209 struct cmd_set_fwd_mode_result *res = parsed_result;
6212 set_pkt_forwarding_mode(res->mode);
6215 cmdline_parse_token_string_t cmd_setfwd_set =
6216 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6217 cmdline_parse_token_string_t cmd_setfwd_fwd =
6218 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6219 cmdline_parse_token_string_t cmd_setfwd_mode =
6220 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6221 "" /* defined at init */);
6223 cmdline_parse_inst_t cmd_set_fwd_mode = {
6224 .f = cmd_set_fwd_mode_parsed,
6226 .help_str = NULL, /* defined at init */
6228 (void *)&cmd_setfwd_set,
6229 (void *)&cmd_setfwd_fwd,
6230 (void *)&cmd_setfwd_mode,
6235 static void cmd_set_fwd_mode_init(void)
6238 static char token[128];
6239 static char help[256];
6240 cmdline_parse_token_string_t *token_struct;
6242 modes = list_pkt_forwarding_modes();
6243 snprintf(help, sizeof(help), "set fwd %s: "
6244 "Set packet forwarding mode", modes);
6245 cmd_set_fwd_mode.help_str = help;
6247 /* string token separator is # */
6248 for (c = token; *modes != '\0'; modes++)
6253 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6254 token_struct->string_data.str = token;
6257 /* *** SET RETRY FORWARDING MODE *** */
6258 struct cmd_set_fwd_retry_mode_result {
6259 cmdline_fixed_string_t set;
6260 cmdline_fixed_string_t fwd;
6261 cmdline_fixed_string_t mode;
6262 cmdline_fixed_string_t retry;
6265 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6266 __attribute__((unused)) struct cmdline *cl,
6267 __attribute__((unused)) void *data)
6269 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6272 set_pkt_forwarding_mode(res->mode);
6275 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6276 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6278 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6279 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6281 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6282 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6284 "" /* defined at init */);
6285 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6286 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6289 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6290 .f = cmd_set_fwd_retry_mode_parsed,
6292 .help_str = NULL, /* defined at init */
6294 (void *)&cmd_setfwd_retry_set,
6295 (void *)&cmd_setfwd_retry_fwd,
6296 (void *)&cmd_setfwd_retry_mode,
6297 (void *)&cmd_setfwd_retry_retry,
6302 static void cmd_set_fwd_retry_mode_init(void)
6305 static char token[128];
6306 static char help[256];
6307 cmdline_parse_token_string_t *token_struct;
6309 modes = list_pkt_forwarding_retry_modes();
6310 snprintf(help, sizeof(help), "set fwd %s retry: "
6311 "Set packet forwarding mode with retry", modes);
6312 cmd_set_fwd_retry_mode.help_str = help;
6314 /* string token separator is # */
6315 for (c = token; *modes != '\0'; modes++)
6320 token_struct = (cmdline_parse_token_string_t *)
6321 cmd_set_fwd_retry_mode.tokens[2];
6322 token_struct->string_data.str = token;
6325 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6326 struct cmd_set_burst_tx_retry_result {
6327 cmdline_fixed_string_t set;
6328 cmdline_fixed_string_t burst;
6329 cmdline_fixed_string_t tx;
6330 cmdline_fixed_string_t delay;
6332 cmdline_fixed_string_t retry;
6336 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6337 __attribute__((unused)) struct cmdline *cl,
6338 __attribute__((unused)) void *data)
6340 struct cmd_set_burst_tx_retry_result *res = parsed_result;
6342 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6343 && !strcmp(res->tx, "tx")) {
6344 if (!strcmp(res->delay, "delay"))
6345 burst_tx_delay_time = res->time;
6346 if (!strcmp(res->retry, "retry"))
6347 burst_tx_retry_num = res->retry_num;
6352 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6353 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6354 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6355 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6357 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6358 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6359 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6360 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6361 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6362 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
6363 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6364 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6365 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6366 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
6368 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6369 .f = cmd_set_burst_tx_retry_parsed,
6370 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6372 (void *)&cmd_set_burst_tx_retry_set,
6373 (void *)&cmd_set_burst_tx_retry_burst,
6374 (void *)&cmd_set_burst_tx_retry_tx,
6375 (void *)&cmd_set_burst_tx_retry_delay,
6376 (void *)&cmd_set_burst_tx_retry_time,
6377 (void *)&cmd_set_burst_tx_retry_retry,
6378 (void *)&cmd_set_burst_tx_retry_retry_num,
6383 /* *** SET PROMISC MODE *** */
6384 struct cmd_set_promisc_mode_result {
6385 cmdline_fixed_string_t set;
6386 cmdline_fixed_string_t promisc;
6387 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6388 uint16_t port_num; /* valid if "allports" argument == 0 */
6389 cmdline_fixed_string_t mode;
6392 static void cmd_set_promisc_mode_parsed(void *parsed_result,
6393 __attribute__((unused)) struct cmdline *cl,
6396 struct cmd_set_promisc_mode_result *res = parsed_result;
6400 if (!strcmp(res->mode, "on"))
6407 RTE_ETH_FOREACH_DEV(i) {
6409 rte_eth_promiscuous_enable(i);
6411 rte_eth_promiscuous_disable(i);
6416 rte_eth_promiscuous_enable(res->port_num);
6418 rte_eth_promiscuous_disable(res->port_num);
6422 cmdline_parse_token_string_t cmd_setpromisc_set =
6423 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6424 cmdline_parse_token_string_t cmd_setpromisc_promisc =
6425 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6427 cmdline_parse_token_string_t cmd_setpromisc_portall =
6428 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6430 cmdline_parse_token_num_t cmd_setpromisc_portnum =
6431 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6433 cmdline_parse_token_string_t cmd_setpromisc_mode =
6434 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6437 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6438 .f = cmd_set_promisc_mode_parsed,
6440 .help_str = "set promisc all on|off: Set promisc mode for all ports",
6442 (void *)&cmd_setpromisc_set,
6443 (void *)&cmd_setpromisc_promisc,
6444 (void *)&cmd_setpromisc_portall,
6445 (void *)&cmd_setpromisc_mode,
6450 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6451 .f = cmd_set_promisc_mode_parsed,
6453 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6455 (void *)&cmd_setpromisc_set,
6456 (void *)&cmd_setpromisc_promisc,
6457 (void *)&cmd_setpromisc_portnum,
6458 (void *)&cmd_setpromisc_mode,
6463 /* *** SET ALLMULTI MODE *** */
6464 struct cmd_set_allmulti_mode_result {
6465 cmdline_fixed_string_t set;
6466 cmdline_fixed_string_t allmulti;
6467 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6468 uint16_t port_num; /* valid if "allports" argument == 0 */
6469 cmdline_fixed_string_t mode;
6472 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6473 __attribute__((unused)) struct cmdline *cl,
6476 struct cmd_set_allmulti_mode_result *res = parsed_result;
6480 if (!strcmp(res->mode, "on"))
6487 RTE_ETH_FOREACH_DEV(i) {
6489 rte_eth_allmulticast_enable(i);
6491 rte_eth_allmulticast_disable(i);
6496 rte_eth_allmulticast_enable(res->port_num);
6498 rte_eth_allmulticast_disable(res->port_num);
6502 cmdline_parse_token_string_t cmd_setallmulti_set =
6503 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6504 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6505 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6507 cmdline_parse_token_string_t cmd_setallmulti_portall =
6508 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6510 cmdline_parse_token_num_t cmd_setallmulti_portnum =
6511 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6513 cmdline_parse_token_string_t cmd_setallmulti_mode =
6514 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6517 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6518 .f = cmd_set_allmulti_mode_parsed,
6520 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6522 (void *)&cmd_setallmulti_set,
6523 (void *)&cmd_setallmulti_allmulti,
6524 (void *)&cmd_setallmulti_portall,
6525 (void *)&cmd_setallmulti_mode,
6530 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6531 .f = cmd_set_allmulti_mode_parsed,
6533 .help_str = "set allmulti <port_id> on|off: "
6534 "Set allmulti mode on port_id",
6536 (void *)&cmd_setallmulti_set,
6537 (void *)&cmd_setallmulti_allmulti,
6538 (void *)&cmd_setallmulti_portnum,
6539 (void *)&cmd_setallmulti_mode,
6544 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
6545 struct cmd_link_flow_ctrl_set_result {
6546 cmdline_fixed_string_t set;
6547 cmdline_fixed_string_t flow_ctrl;
6548 cmdline_fixed_string_t rx;
6549 cmdline_fixed_string_t rx_lfc_mode;
6550 cmdline_fixed_string_t tx;
6551 cmdline_fixed_string_t tx_lfc_mode;
6552 cmdline_fixed_string_t mac_ctrl_frame_fwd;
6553 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
6554 cmdline_fixed_string_t autoneg_str;
6555 cmdline_fixed_string_t autoneg;
6556 cmdline_fixed_string_t hw_str;
6557 uint32_t high_water;
6558 cmdline_fixed_string_t lw_str;
6560 cmdline_fixed_string_t pt_str;
6561 uint16_t pause_time;
6562 cmdline_fixed_string_t xon_str;
6567 cmdline_parse_token_string_t cmd_lfc_set_set =
6568 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6570 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
6571 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6572 flow_ctrl, "flow_ctrl");
6573 cmdline_parse_token_string_t cmd_lfc_set_rx =
6574 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6576 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
6577 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6578 rx_lfc_mode, "on#off");
6579 cmdline_parse_token_string_t cmd_lfc_set_tx =
6580 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6582 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
6583 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6584 tx_lfc_mode, "on#off");
6585 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
6586 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6587 hw_str, "high_water");
6588 cmdline_parse_token_num_t cmd_lfc_set_high_water =
6589 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6590 high_water, UINT32);
6591 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
6592 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6593 lw_str, "low_water");
6594 cmdline_parse_token_num_t cmd_lfc_set_low_water =
6595 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6597 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
6598 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6599 pt_str, "pause_time");
6600 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
6601 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6602 pause_time, UINT16);
6603 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
6604 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6605 xon_str, "send_xon");
6606 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
6607 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6609 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
6610 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6611 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
6612 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6613 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6614 mac_ctrl_frame_fwd_mode, "on#off");
6615 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6616 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6617 autoneg_str, "autoneg");
6618 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6619 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6621 cmdline_parse_token_num_t cmd_lfc_set_portid =
6622 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6625 /* forward declaration */
6627 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6630 cmdline_parse_inst_t cmd_link_flow_control_set = {
6631 .f = cmd_link_flow_ctrl_set_parsed,
6633 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6634 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6635 "autoneg on|off <port_id>: Configure the Ethernet flow control",
6637 (void *)&cmd_lfc_set_set,
6638 (void *)&cmd_lfc_set_flow_ctrl,
6639 (void *)&cmd_lfc_set_rx,
6640 (void *)&cmd_lfc_set_rx_mode,
6641 (void *)&cmd_lfc_set_tx,
6642 (void *)&cmd_lfc_set_tx_mode,
6643 (void *)&cmd_lfc_set_high_water,
6644 (void *)&cmd_lfc_set_low_water,
6645 (void *)&cmd_lfc_set_pause_time,
6646 (void *)&cmd_lfc_set_send_xon,
6647 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6648 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6649 (void *)&cmd_lfc_set_autoneg_str,
6650 (void *)&cmd_lfc_set_autoneg,
6651 (void *)&cmd_lfc_set_portid,
6656 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6657 .f = cmd_link_flow_ctrl_set_parsed,
6658 .data = (void *)&cmd_link_flow_control_set_rx,
6659 .help_str = "set flow_ctrl rx on|off <port_id>: "
6660 "Change rx flow control parameter",
6662 (void *)&cmd_lfc_set_set,
6663 (void *)&cmd_lfc_set_flow_ctrl,
6664 (void *)&cmd_lfc_set_rx,
6665 (void *)&cmd_lfc_set_rx_mode,
6666 (void *)&cmd_lfc_set_portid,
6671 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6672 .f = cmd_link_flow_ctrl_set_parsed,
6673 .data = (void *)&cmd_link_flow_control_set_tx,
6674 .help_str = "set flow_ctrl tx on|off <port_id>: "
6675 "Change tx flow control parameter",
6677 (void *)&cmd_lfc_set_set,
6678 (void *)&cmd_lfc_set_flow_ctrl,
6679 (void *)&cmd_lfc_set_tx,
6680 (void *)&cmd_lfc_set_tx_mode,
6681 (void *)&cmd_lfc_set_portid,
6686 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
6687 .f = cmd_link_flow_ctrl_set_parsed,
6688 .data = (void *)&cmd_link_flow_control_set_hw,
6689 .help_str = "set flow_ctrl high_water <value> <port_id>: "
6690 "Change high water flow control parameter",
6692 (void *)&cmd_lfc_set_set,
6693 (void *)&cmd_lfc_set_flow_ctrl,
6694 (void *)&cmd_lfc_set_high_water_str,
6695 (void *)&cmd_lfc_set_high_water,
6696 (void *)&cmd_lfc_set_portid,
6701 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
6702 .f = cmd_link_flow_ctrl_set_parsed,
6703 .data = (void *)&cmd_link_flow_control_set_lw,
6704 .help_str = "set flow_ctrl low_water <value> <port_id>: "
6705 "Change low water flow control parameter",
6707 (void *)&cmd_lfc_set_set,
6708 (void *)&cmd_lfc_set_flow_ctrl,
6709 (void *)&cmd_lfc_set_low_water_str,
6710 (void *)&cmd_lfc_set_low_water,
6711 (void *)&cmd_lfc_set_portid,
6716 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
6717 .f = cmd_link_flow_ctrl_set_parsed,
6718 .data = (void *)&cmd_link_flow_control_set_pt,
6719 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
6720 "Change pause time flow control parameter",
6722 (void *)&cmd_lfc_set_set,
6723 (void *)&cmd_lfc_set_flow_ctrl,
6724 (void *)&cmd_lfc_set_pause_time_str,
6725 (void *)&cmd_lfc_set_pause_time,
6726 (void *)&cmd_lfc_set_portid,
6731 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
6732 .f = cmd_link_flow_ctrl_set_parsed,
6733 .data = (void *)&cmd_link_flow_control_set_xon,
6734 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
6735 "Change send_xon flow control parameter",
6737 (void *)&cmd_lfc_set_set,
6738 (void *)&cmd_lfc_set_flow_ctrl,
6739 (void *)&cmd_lfc_set_send_xon_str,
6740 (void *)&cmd_lfc_set_send_xon,
6741 (void *)&cmd_lfc_set_portid,
6746 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
6747 .f = cmd_link_flow_ctrl_set_parsed,
6748 .data = (void *)&cmd_link_flow_control_set_macfwd,
6749 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
6750 "Change mac ctrl fwd flow control parameter",
6752 (void *)&cmd_lfc_set_set,
6753 (void *)&cmd_lfc_set_flow_ctrl,
6754 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6755 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6756 (void *)&cmd_lfc_set_portid,
6761 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
6762 .f = cmd_link_flow_ctrl_set_parsed,
6763 .data = (void *)&cmd_link_flow_control_set_autoneg,
6764 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
6765 "Change autoneg flow control parameter",
6767 (void *)&cmd_lfc_set_set,
6768 (void *)&cmd_lfc_set_flow_ctrl,
6769 (void *)&cmd_lfc_set_autoneg_str,
6770 (void *)&cmd_lfc_set_autoneg,
6771 (void *)&cmd_lfc_set_portid,
6777 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
6778 __attribute__((unused)) struct cmdline *cl,
6781 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
6782 cmdline_parse_inst_t *cmd = data;
6783 struct rte_eth_fc_conf fc_conf;
6789 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6790 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6791 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6792 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6794 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
6795 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
6798 /* Partial command line, retrieve current configuration */
6800 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
6802 printf("cannot get current flow ctrl parameters, return"
6803 "code = %d\n", ret);
6807 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
6808 (fc_conf.mode == RTE_FC_FULL))
6810 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
6811 (fc_conf.mode == RTE_FC_FULL))
6815 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
6816 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
6818 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
6819 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
6821 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
6823 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
6824 fc_conf.high_water = res->high_water;
6826 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
6827 fc_conf.low_water = res->low_water;
6829 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
6830 fc_conf.pause_time = res->pause_time;
6832 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
6833 fc_conf.send_xon = res->send_xon;
6835 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
6836 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
6837 fc_conf.mac_ctrl_frame_fwd = 1;
6839 fc_conf.mac_ctrl_frame_fwd = 0;
6842 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
6843 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
6845 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
6847 printf("bad flow contrl parameter, return code = %d \n", ret);
6850 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
6851 struct cmd_priority_flow_ctrl_set_result {
6852 cmdline_fixed_string_t set;
6853 cmdline_fixed_string_t pfc_ctrl;
6854 cmdline_fixed_string_t rx;
6855 cmdline_fixed_string_t rx_pfc_mode;
6856 cmdline_fixed_string_t tx;
6857 cmdline_fixed_string_t tx_pfc_mode;
6858 uint32_t high_water;
6860 uint16_t pause_time;
6866 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
6867 __attribute__((unused)) struct cmdline *cl,
6868 __attribute__((unused)) void *data)
6870 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
6871 struct rte_eth_pfc_conf pfc_conf;
6872 int rx_fc_enable, tx_fc_enable;
6876 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6877 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6878 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6879 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6881 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
6882 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
6885 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
6886 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
6887 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
6888 pfc_conf.fc.high_water = res->high_water;
6889 pfc_conf.fc.low_water = res->low_water;
6890 pfc_conf.fc.pause_time = res->pause_time;
6891 pfc_conf.priority = res->priority;
6893 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
6895 printf("bad priority flow contrl parameter, return code = %d \n", ret);
6898 cmdline_parse_token_string_t cmd_pfc_set_set =
6899 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6901 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
6902 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6903 pfc_ctrl, "pfc_ctrl");
6904 cmdline_parse_token_string_t cmd_pfc_set_rx =
6905 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6907 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
6908 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6909 rx_pfc_mode, "on#off");
6910 cmdline_parse_token_string_t cmd_pfc_set_tx =
6911 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6913 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
6914 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6915 tx_pfc_mode, "on#off");
6916 cmdline_parse_token_num_t cmd_pfc_set_high_water =
6917 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6918 high_water, UINT32);
6919 cmdline_parse_token_num_t cmd_pfc_set_low_water =
6920 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6922 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
6923 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6924 pause_time, UINT16);
6925 cmdline_parse_token_num_t cmd_pfc_set_priority =
6926 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6928 cmdline_parse_token_num_t cmd_pfc_set_portid =
6929 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6932 cmdline_parse_inst_t cmd_priority_flow_control_set = {
6933 .f = cmd_priority_flow_ctrl_set_parsed,
6935 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
6936 "<pause_time> <priority> <port_id>: "
6937 "Configure the Ethernet priority flow control",
6939 (void *)&cmd_pfc_set_set,
6940 (void *)&cmd_pfc_set_flow_ctrl,
6941 (void *)&cmd_pfc_set_rx,
6942 (void *)&cmd_pfc_set_rx_mode,
6943 (void *)&cmd_pfc_set_tx,
6944 (void *)&cmd_pfc_set_tx_mode,
6945 (void *)&cmd_pfc_set_high_water,
6946 (void *)&cmd_pfc_set_low_water,
6947 (void *)&cmd_pfc_set_pause_time,
6948 (void *)&cmd_pfc_set_priority,
6949 (void *)&cmd_pfc_set_portid,
6954 /* *** RESET CONFIGURATION *** */
6955 struct cmd_reset_result {
6956 cmdline_fixed_string_t reset;
6957 cmdline_fixed_string_t def;
6960 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
6962 __attribute__((unused)) void *data)
6964 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
6965 set_def_fwd_config();
6968 cmdline_parse_token_string_t cmd_reset_set =
6969 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
6970 cmdline_parse_token_string_t cmd_reset_def =
6971 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
6974 cmdline_parse_inst_t cmd_reset = {
6975 .f = cmd_reset_parsed,
6977 .help_str = "set default: Reset default forwarding configuration",
6979 (void *)&cmd_reset_set,
6980 (void *)&cmd_reset_def,
6985 /* *** START FORWARDING *** */
6986 struct cmd_start_result {
6987 cmdline_fixed_string_t start;
6990 cmdline_parse_token_string_t cmd_start_start =
6991 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
6993 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
6994 __attribute__((unused)) struct cmdline *cl,
6995 __attribute__((unused)) void *data)
6997 start_packet_forwarding(0);
7000 cmdline_parse_inst_t cmd_start = {
7001 .f = cmd_start_parsed,
7003 .help_str = "start: Start packet forwarding",
7005 (void *)&cmd_start_start,
7010 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7011 struct cmd_start_tx_first_result {
7012 cmdline_fixed_string_t start;
7013 cmdline_fixed_string_t tx_first;
7017 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
7018 __attribute__((unused)) struct cmdline *cl,
7019 __attribute__((unused)) void *data)
7021 start_packet_forwarding(1);
7024 cmdline_parse_token_string_t cmd_start_tx_first_start =
7025 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7027 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7028 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7029 tx_first, "tx_first");
7031 cmdline_parse_inst_t cmd_start_tx_first = {
7032 .f = cmd_start_tx_first_parsed,
7034 .help_str = "start tx_first: Start packet forwarding, "
7035 "after sending 1 burst of packets",
7037 (void *)&cmd_start_tx_first_start,
7038 (void *)&cmd_start_tx_first_tx_first,
7043 /* *** START FORWARDING WITH N TX BURST FIRST *** */
7044 struct cmd_start_tx_first_n_result {
7045 cmdline_fixed_string_t start;
7046 cmdline_fixed_string_t tx_first;
7051 cmd_start_tx_first_n_parsed(void *parsed_result,
7052 __attribute__((unused)) struct cmdline *cl,
7053 __attribute__((unused)) void *data)
7055 struct cmd_start_tx_first_n_result *res = parsed_result;
7057 start_packet_forwarding(res->tx_num);
7060 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7061 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7063 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7064 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7065 tx_first, "tx_first");
7066 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7067 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7070 cmdline_parse_inst_t cmd_start_tx_first_n = {
7071 .f = cmd_start_tx_first_n_parsed,
7073 .help_str = "start tx_first <num>: "
7074 "packet forwarding, after sending <num> bursts of packets",
7076 (void *)&cmd_start_tx_first_n_start,
7077 (void *)&cmd_start_tx_first_n_tx_first,
7078 (void *)&cmd_start_tx_first_n_tx_num,
7083 /* *** SET LINK UP *** */
7084 struct cmd_set_link_up_result {
7085 cmdline_fixed_string_t set;
7086 cmdline_fixed_string_t link_up;
7087 cmdline_fixed_string_t port;
7091 cmdline_parse_token_string_t cmd_set_link_up_set =
7092 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7093 cmdline_parse_token_string_t cmd_set_link_up_link_up =
7094 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7096 cmdline_parse_token_string_t cmd_set_link_up_port =
7097 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7098 cmdline_parse_token_num_t cmd_set_link_up_port_id =
7099 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16);
7101 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
7102 __attribute__((unused)) struct cmdline *cl,
7103 __attribute__((unused)) void *data)
7105 struct cmd_set_link_up_result *res = parsed_result;
7106 dev_set_link_up(res->port_id);
7109 cmdline_parse_inst_t cmd_set_link_up = {
7110 .f = cmd_set_link_up_parsed,
7112 .help_str = "set link-up port <port id>",
7114 (void *)&cmd_set_link_up_set,
7115 (void *)&cmd_set_link_up_link_up,
7116 (void *)&cmd_set_link_up_port,
7117 (void *)&cmd_set_link_up_port_id,
7122 /* *** SET LINK DOWN *** */
7123 struct cmd_set_link_down_result {
7124 cmdline_fixed_string_t set;
7125 cmdline_fixed_string_t link_down;
7126 cmdline_fixed_string_t port;
7130 cmdline_parse_token_string_t cmd_set_link_down_set =
7131 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
7132 cmdline_parse_token_string_t cmd_set_link_down_link_down =
7133 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
7135 cmdline_parse_token_string_t cmd_set_link_down_port =
7136 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
7137 cmdline_parse_token_num_t cmd_set_link_down_port_id =
7138 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16);
7140 static void cmd_set_link_down_parsed(
7141 __attribute__((unused)) void *parsed_result,
7142 __attribute__((unused)) struct cmdline *cl,
7143 __attribute__((unused)) void *data)
7145 struct cmd_set_link_down_result *res = parsed_result;
7146 dev_set_link_down(res->port_id);
7149 cmdline_parse_inst_t cmd_set_link_down = {
7150 .f = cmd_set_link_down_parsed,
7152 .help_str = "set link-down port <port id>",
7154 (void *)&cmd_set_link_down_set,
7155 (void *)&cmd_set_link_down_link_down,
7156 (void *)&cmd_set_link_down_port,
7157 (void *)&cmd_set_link_down_port_id,
7162 /* *** SHOW CFG *** */
7163 struct cmd_showcfg_result {
7164 cmdline_fixed_string_t show;
7165 cmdline_fixed_string_t cfg;
7166 cmdline_fixed_string_t what;
7169 static void cmd_showcfg_parsed(void *parsed_result,
7170 __attribute__((unused)) struct cmdline *cl,
7171 __attribute__((unused)) void *data)
7173 struct cmd_showcfg_result *res = parsed_result;
7174 if (!strcmp(res->what, "rxtx"))
7175 rxtx_config_display();
7176 else if (!strcmp(res->what, "cores"))
7177 fwd_lcores_config_display();
7178 else if (!strcmp(res->what, "fwd"))
7179 pkt_fwd_config_display(&cur_fwd_config);
7180 else if (!strcmp(res->what, "txpkts"))
7181 show_tx_pkt_segments();
7184 cmdline_parse_token_string_t cmd_showcfg_show =
7185 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7186 cmdline_parse_token_string_t cmd_showcfg_port =
7187 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7188 cmdline_parse_token_string_t cmd_showcfg_what =
7189 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7190 "rxtx#cores#fwd#txpkts");
7192 cmdline_parse_inst_t cmd_showcfg = {
7193 .f = cmd_showcfg_parsed,
7195 .help_str = "show config rxtx|cores|fwd|txpkts",
7197 (void *)&cmd_showcfg_show,
7198 (void *)&cmd_showcfg_port,
7199 (void *)&cmd_showcfg_what,
7204 /* *** SHOW ALL PORT INFO *** */
7205 struct cmd_showportall_result {
7206 cmdline_fixed_string_t show;
7207 cmdline_fixed_string_t port;
7208 cmdline_fixed_string_t what;
7209 cmdline_fixed_string_t all;
7212 static void cmd_showportall_parsed(void *parsed_result,
7213 __attribute__((unused)) struct cmdline *cl,
7214 __attribute__((unused)) void *data)
7218 struct cmd_showportall_result *res = parsed_result;
7219 if (!strcmp(res->show, "clear")) {
7220 if (!strcmp(res->what, "stats"))
7221 RTE_ETH_FOREACH_DEV(i)
7223 else if (!strcmp(res->what, "xstats"))
7224 RTE_ETH_FOREACH_DEV(i)
7225 nic_xstats_clear(i);
7226 } else if (!strcmp(res->what, "info"))
7227 RTE_ETH_FOREACH_DEV(i)
7228 port_infos_display(i);
7229 else if (!strcmp(res->what, "summary")) {
7230 port_summary_header_display();
7231 RTE_ETH_FOREACH_DEV(i)
7232 port_summary_display(i);
7234 else if (!strcmp(res->what, "stats"))
7235 RTE_ETH_FOREACH_DEV(i)
7236 nic_stats_display(i);
7237 else if (!strcmp(res->what, "xstats"))
7238 RTE_ETH_FOREACH_DEV(i)
7239 nic_xstats_display(i);
7240 else if (!strcmp(res->what, "fdir"))
7241 RTE_ETH_FOREACH_DEV(i)
7243 else if (!strcmp(res->what, "stat_qmap"))
7244 RTE_ETH_FOREACH_DEV(i)
7245 nic_stats_mapping_display(i);
7246 else if (!strcmp(res->what, "dcb_tc"))
7247 RTE_ETH_FOREACH_DEV(i)
7248 port_dcb_info_display(i);
7249 else if (!strcmp(res->what, "cap"))
7250 RTE_ETH_FOREACH_DEV(i)
7251 port_offload_cap_display(i);
7254 cmdline_parse_token_string_t cmd_showportall_show =
7255 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7257 cmdline_parse_token_string_t cmd_showportall_port =
7258 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7259 cmdline_parse_token_string_t cmd_showportall_what =
7260 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7261 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7262 cmdline_parse_token_string_t cmd_showportall_all =
7263 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7264 cmdline_parse_inst_t cmd_showportall = {
7265 .f = cmd_showportall_parsed,
7267 .help_str = "show|clear port "
7268 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
7270 (void *)&cmd_showportall_show,
7271 (void *)&cmd_showportall_port,
7272 (void *)&cmd_showportall_what,
7273 (void *)&cmd_showportall_all,
7278 /* *** SHOW PORT INFO *** */
7279 struct cmd_showport_result {
7280 cmdline_fixed_string_t show;
7281 cmdline_fixed_string_t port;
7282 cmdline_fixed_string_t what;
7286 static void cmd_showport_parsed(void *parsed_result,
7287 __attribute__((unused)) struct cmdline *cl,
7288 __attribute__((unused)) void *data)
7290 struct cmd_showport_result *res = parsed_result;
7291 if (!strcmp(res->show, "clear")) {
7292 if (!strcmp(res->what, "stats"))
7293 nic_stats_clear(res->portnum);
7294 else if (!strcmp(res->what, "xstats"))
7295 nic_xstats_clear(res->portnum);
7296 } else if (!strcmp(res->what, "info"))
7297 port_infos_display(res->portnum);
7298 else if (!strcmp(res->what, "summary")) {
7299 port_summary_header_display();
7300 port_summary_display(res->portnum);
7302 else if (!strcmp(res->what, "stats"))
7303 nic_stats_display(res->portnum);
7304 else if (!strcmp(res->what, "xstats"))
7305 nic_xstats_display(res->portnum);
7306 else if (!strcmp(res->what, "fdir"))
7307 fdir_get_infos(res->portnum);
7308 else if (!strcmp(res->what, "stat_qmap"))
7309 nic_stats_mapping_display(res->portnum);
7310 else if (!strcmp(res->what, "dcb_tc"))
7311 port_dcb_info_display(res->portnum);
7312 else if (!strcmp(res->what, "cap"))
7313 port_offload_cap_display(res->portnum);
7316 cmdline_parse_token_string_t cmd_showport_show =
7317 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7319 cmdline_parse_token_string_t cmd_showport_port =
7320 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7321 cmdline_parse_token_string_t cmd_showport_what =
7322 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7323 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7324 cmdline_parse_token_num_t cmd_showport_portnum =
7325 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
7327 cmdline_parse_inst_t cmd_showport = {
7328 .f = cmd_showport_parsed,
7330 .help_str = "show|clear port "
7331 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
7334 (void *)&cmd_showport_show,
7335 (void *)&cmd_showport_port,
7336 (void *)&cmd_showport_what,
7337 (void *)&cmd_showport_portnum,
7342 /* *** SHOW QUEUE INFO *** */
7343 struct cmd_showqueue_result {
7344 cmdline_fixed_string_t show;
7345 cmdline_fixed_string_t type;
7346 cmdline_fixed_string_t what;
7352 cmd_showqueue_parsed(void *parsed_result,
7353 __attribute__((unused)) struct cmdline *cl,
7354 __attribute__((unused)) void *data)
7356 struct cmd_showqueue_result *res = parsed_result;
7358 if (!strcmp(res->type, "rxq"))
7359 rx_queue_infos_display(res->portnum, res->queuenum);
7360 else if (!strcmp(res->type, "txq"))
7361 tx_queue_infos_display(res->portnum, res->queuenum);
7364 cmdline_parse_token_string_t cmd_showqueue_show =
7365 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
7366 cmdline_parse_token_string_t cmd_showqueue_type =
7367 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
7368 cmdline_parse_token_string_t cmd_showqueue_what =
7369 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
7370 cmdline_parse_token_num_t cmd_showqueue_portnum =
7371 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16);
7372 cmdline_parse_token_num_t cmd_showqueue_queuenum =
7373 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
7375 cmdline_parse_inst_t cmd_showqueue = {
7376 .f = cmd_showqueue_parsed,
7378 .help_str = "show rxq|txq info <port_id> <queue_id>",
7380 (void *)&cmd_showqueue_show,
7381 (void *)&cmd_showqueue_type,
7382 (void *)&cmd_showqueue_what,
7383 (void *)&cmd_showqueue_portnum,
7384 (void *)&cmd_showqueue_queuenum,
7389 /* *** READ PORT REGISTER *** */
7390 struct cmd_read_reg_result {
7391 cmdline_fixed_string_t read;
7392 cmdline_fixed_string_t reg;
7398 cmd_read_reg_parsed(void *parsed_result,
7399 __attribute__((unused)) struct cmdline *cl,
7400 __attribute__((unused)) void *data)
7402 struct cmd_read_reg_result *res = parsed_result;
7403 port_reg_display(res->port_id, res->reg_off);
7406 cmdline_parse_token_string_t cmd_read_reg_read =
7407 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
7408 cmdline_parse_token_string_t cmd_read_reg_reg =
7409 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
7410 cmdline_parse_token_num_t cmd_read_reg_port_id =
7411 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16);
7412 cmdline_parse_token_num_t cmd_read_reg_reg_off =
7413 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
7415 cmdline_parse_inst_t cmd_read_reg = {
7416 .f = cmd_read_reg_parsed,
7418 .help_str = "read reg <port_id> <reg_off>",
7420 (void *)&cmd_read_reg_read,
7421 (void *)&cmd_read_reg_reg,
7422 (void *)&cmd_read_reg_port_id,
7423 (void *)&cmd_read_reg_reg_off,
7428 /* *** READ PORT REGISTER BIT FIELD *** */
7429 struct cmd_read_reg_bit_field_result {
7430 cmdline_fixed_string_t read;
7431 cmdline_fixed_string_t regfield;
7439 cmd_read_reg_bit_field_parsed(void *parsed_result,
7440 __attribute__((unused)) struct cmdline *cl,
7441 __attribute__((unused)) void *data)
7443 struct cmd_read_reg_bit_field_result *res = parsed_result;
7444 port_reg_bit_field_display(res->port_id, res->reg_off,
7445 res->bit1_pos, res->bit2_pos);
7448 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
7449 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
7451 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
7452 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
7453 regfield, "regfield");
7454 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
7455 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
7457 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
7458 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
7460 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
7461 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
7463 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
7464 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
7467 cmdline_parse_inst_t cmd_read_reg_bit_field = {
7468 .f = cmd_read_reg_bit_field_parsed,
7470 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
7471 "Read register bit field between bit_x and bit_y included",
7473 (void *)&cmd_read_reg_bit_field_read,
7474 (void *)&cmd_read_reg_bit_field_regfield,
7475 (void *)&cmd_read_reg_bit_field_port_id,
7476 (void *)&cmd_read_reg_bit_field_reg_off,
7477 (void *)&cmd_read_reg_bit_field_bit1_pos,
7478 (void *)&cmd_read_reg_bit_field_bit2_pos,
7483 /* *** READ PORT REGISTER BIT *** */
7484 struct cmd_read_reg_bit_result {
7485 cmdline_fixed_string_t read;
7486 cmdline_fixed_string_t regbit;
7493 cmd_read_reg_bit_parsed(void *parsed_result,
7494 __attribute__((unused)) struct cmdline *cl,
7495 __attribute__((unused)) void *data)
7497 struct cmd_read_reg_bit_result *res = parsed_result;
7498 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
7501 cmdline_parse_token_string_t cmd_read_reg_bit_read =
7502 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
7503 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
7504 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
7506 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
7507 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16);
7508 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
7509 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
7510 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
7511 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
7513 cmdline_parse_inst_t cmd_read_reg_bit = {
7514 .f = cmd_read_reg_bit_parsed,
7516 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
7518 (void *)&cmd_read_reg_bit_read,
7519 (void *)&cmd_read_reg_bit_regbit,
7520 (void *)&cmd_read_reg_bit_port_id,
7521 (void *)&cmd_read_reg_bit_reg_off,
7522 (void *)&cmd_read_reg_bit_bit_pos,
7527 /* *** WRITE PORT REGISTER *** */
7528 struct cmd_write_reg_result {
7529 cmdline_fixed_string_t write;
7530 cmdline_fixed_string_t reg;
7537 cmd_write_reg_parsed(void *parsed_result,
7538 __attribute__((unused)) struct cmdline *cl,
7539 __attribute__((unused)) void *data)
7541 struct cmd_write_reg_result *res = parsed_result;
7542 port_reg_set(res->port_id, res->reg_off, res->value);
7545 cmdline_parse_token_string_t cmd_write_reg_write =
7546 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
7547 cmdline_parse_token_string_t cmd_write_reg_reg =
7548 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
7549 cmdline_parse_token_num_t cmd_write_reg_port_id =
7550 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16);
7551 cmdline_parse_token_num_t cmd_write_reg_reg_off =
7552 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
7553 cmdline_parse_token_num_t cmd_write_reg_value =
7554 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
7556 cmdline_parse_inst_t cmd_write_reg = {
7557 .f = cmd_write_reg_parsed,
7559 .help_str = "write reg <port_id> <reg_off> <reg_value>",
7561 (void *)&cmd_write_reg_write,
7562 (void *)&cmd_write_reg_reg,
7563 (void *)&cmd_write_reg_port_id,
7564 (void *)&cmd_write_reg_reg_off,
7565 (void *)&cmd_write_reg_value,
7570 /* *** WRITE PORT REGISTER BIT FIELD *** */
7571 struct cmd_write_reg_bit_field_result {
7572 cmdline_fixed_string_t write;
7573 cmdline_fixed_string_t regfield;
7582 cmd_write_reg_bit_field_parsed(void *parsed_result,
7583 __attribute__((unused)) struct cmdline *cl,
7584 __attribute__((unused)) void *data)
7586 struct cmd_write_reg_bit_field_result *res = parsed_result;
7587 port_reg_bit_field_set(res->port_id, res->reg_off,
7588 res->bit1_pos, res->bit2_pos, res->value);
7591 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
7592 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
7594 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
7595 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
7596 regfield, "regfield");
7597 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
7598 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
7600 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
7601 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
7603 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
7604 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
7606 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
7607 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
7609 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
7610 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
7613 cmdline_parse_inst_t cmd_write_reg_bit_field = {
7614 .f = cmd_write_reg_bit_field_parsed,
7616 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
7618 "Set register bit field between bit_x and bit_y included",
7620 (void *)&cmd_write_reg_bit_field_write,
7621 (void *)&cmd_write_reg_bit_field_regfield,
7622 (void *)&cmd_write_reg_bit_field_port_id,
7623 (void *)&cmd_write_reg_bit_field_reg_off,
7624 (void *)&cmd_write_reg_bit_field_bit1_pos,
7625 (void *)&cmd_write_reg_bit_field_bit2_pos,
7626 (void *)&cmd_write_reg_bit_field_value,
7631 /* *** WRITE PORT REGISTER BIT *** */
7632 struct cmd_write_reg_bit_result {
7633 cmdline_fixed_string_t write;
7634 cmdline_fixed_string_t regbit;
7642 cmd_write_reg_bit_parsed(void *parsed_result,
7643 __attribute__((unused)) struct cmdline *cl,
7644 __attribute__((unused)) void *data)
7646 struct cmd_write_reg_bit_result *res = parsed_result;
7647 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
7650 cmdline_parse_token_string_t cmd_write_reg_bit_write =
7651 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
7653 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
7654 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
7656 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
7657 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16);
7658 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
7659 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
7660 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
7661 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
7662 cmdline_parse_token_num_t cmd_write_reg_bit_value =
7663 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
7665 cmdline_parse_inst_t cmd_write_reg_bit = {
7666 .f = cmd_write_reg_bit_parsed,
7668 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
7671 (void *)&cmd_write_reg_bit_write,
7672 (void *)&cmd_write_reg_bit_regbit,
7673 (void *)&cmd_write_reg_bit_port_id,
7674 (void *)&cmd_write_reg_bit_reg_off,
7675 (void *)&cmd_write_reg_bit_bit_pos,
7676 (void *)&cmd_write_reg_bit_value,
7681 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
7682 struct cmd_read_rxd_txd_result {
7683 cmdline_fixed_string_t read;
7684 cmdline_fixed_string_t rxd_txd;
7691 cmd_read_rxd_txd_parsed(void *parsed_result,
7692 __attribute__((unused)) struct cmdline *cl,
7693 __attribute__((unused)) void *data)
7695 struct cmd_read_rxd_txd_result *res = parsed_result;
7697 if (!strcmp(res->rxd_txd, "rxd"))
7698 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7699 else if (!strcmp(res->rxd_txd, "txd"))
7700 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7703 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
7704 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
7705 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
7706 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
7708 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
7709 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16);
7710 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
7711 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
7712 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
7713 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
7715 cmdline_parse_inst_t cmd_read_rxd_txd = {
7716 .f = cmd_read_rxd_txd_parsed,
7718 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
7720 (void *)&cmd_read_rxd_txd_read,
7721 (void *)&cmd_read_rxd_txd_rxd_txd,
7722 (void *)&cmd_read_rxd_txd_port_id,
7723 (void *)&cmd_read_rxd_txd_queue_id,
7724 (void *)&cmd_read_rxd_txd_desc_id,
7730 struct cmd_quit_result {
7731 cmdline_fixed_string_t quit;
7734 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
7736 __attribute__((unused)) void *data)
7741 cmdline_parse_token_string_t cmd_quit_quit =
7742 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
7744 cmdline_parse_inst_t cmd_quit = {
7745 .f = cmd_quit_parsed,
7747 .help_str = "quit: Exit application",
7749 (void *)&cmd_quit_quit,
7754 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
7755 struct cmd_mac_addr_result {
7756 cmdline_fixed_string_t mac_addr_cmd;
7757 cmdline_fixed_string_t what;
7759 struct ether_addr address;
7762 static void cmd_mac_addr_parsed(void *parsed_result,
7763 __attribute__((unused)) struct cmdline *cl,
7764 __attribute__((unused)) void *data)
7766 struct cmd_mac_addr_result *res = parsed_result;
7769 if (strcmp(res->what, "add") == 0)
7770 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
7771 else if (strcmp(res->what, "set") == 0)
7772 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
7775 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
7777 /* check the return value and print it if is < 0 */
7779 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
7783 cmdline_parse_token_string_t cmd_mac_addr_cmd =
7784 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
7786 cmdline_parse_token_string_t cmd_mac_addr_what =
7787 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
7789 cmdline_parse_token_num_t cmd_mac_addr_portnum =
7790 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
7792 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
7793 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
7795 cmdline_parse_inst_t cmd_mac_addr = {
7796 .f = cmd_mac_addr_parsed,
7798 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
7799 "Add/Remove/Set MAC address on port_id",
7801 (void *)&cmd_mac_addr_cmd,
7802 (void *)&cmd_mac_addr_what,
7803 (void *)&cmd_mac_addr_portnum,
7804 (void *)&cmd_mac_addr_addr,
7809 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
7810 struct cmd_eth_peer_result {
7811 cmdline_fixed_string_t set;
7812 cmdline_fixed_string_t eth_peer;
7814 cmdline_fixed_string_t peer_addr;
7817 static void cmd_set_eth_peer_parsed(void *parsed_result,
7818 __attribute__((unused)) struct cmdline *cl,
7819 __attribute__((unused)) void *data)
7821 struct cmd_eth_peer_result *res = parsed_result;
7823 if (test_done == 0) {
7824 printf("Please stop forwarding first\n");
7827 if (!strcmp(res->eth_peer, "eth-peer")) {
7828 set_fwd_eth_peer(res->port_id, res->peer_addr);
7832 cmdline_parse_token_string_t cmd_eth_peer_set =
7833 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
7834 cmdline_parse_token_string_t cmd_eth_peer =
7835 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
7836 cmdline_parse_token_num_t cmd_eth_peer_port_id =
7837 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, UINT16);
7838 cmdline_parse_token_string_t cmd_eth_peer_addr =
7839 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
7841 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
7842 .f = cmd_set_eth_peer_parsed,
7844 .help_str = "set eth-peer <port_id> <peer_mac>",
7846 (void *)&cmd_eth_peer_set,
7847 (void *)&cmd_eth_peer,
7848 (void *)&cmd_eth_peer_port_id,
7849 (void *)&cmd_eth_peer_addr,
7854 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
7855 struct cmd_set_qmap_result {
7856 cmdline_fixed_string_t set;
7857 cmdline_fixed_string_t qmap;
7858 cmdline_fixed_string_t what;
7865 cmd_set_qmap_parsed(void *parsed_result,
7866 __attribute__((unused)) struct cmdline *cl,
7867 __attribute__((unused)) void *data)
7869 struct cmd_set_qmap_result *res = parsed_result;
7870 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
7872 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
7875 cmdline_parse_token_string_t cmd_setqmap_set =
7876 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7878 cmdline_parse_token_string_t cmd_setqmap_qmap =
7879 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7881 cmdline_parse_token_string_t cmd_setqmap_what =
7882 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7884 cmdline_parse_token_num_t cmd_setqmap_portid =
7885 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7887 cmdline_parse_token_num_t cmd_setqmap_queueid =
7888 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7890 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
7891 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7894 cmdline_parse_inst_t cmd_set_qmap = {
7895 .f = cmd_set_qmap_parsed,
7897 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
7898 "Set statistics mapping value on tx|rx queue_id of port_id",
7900 (void *)&cmd_setqmap_set,
7901 (void *)&cmd_setqmap_qmap,
7902 (void *)&cmd_setqmap_what,
7903 (void *)&cmd_setqmap_portid,
7904 (void *)&cmd_setqmap_queueid,
7905 (void *)&cmd_setqmap_mapvalue,
7910 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
7911 struct cmd_set_xstats_hide_zero_result {
7912 cmdline_fixed_string_t keyword;
7913 cmdline_fixed_string_t name;
7914 cmdline_fixed_string_t on_off;
7918 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
7919 __attribute__((unused)) struct cmdline *cl,
7920 __attribute__((unused)) void *data)
7922 struct cmd_set_xstats_hide_zero_result *res;
7923 uint16_t on_off = 0;
7925 res = parsed_result;
7926 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
7927 set_xstats_hide_zero(on_off);
7930 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
7931 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7933 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
7934 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7935 name, "xstats-hide-zero");
7936 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
7937 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7940 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
7941 .f = cmd_set_xstats_hide_zero_parsed,
7943 .help_str = "set xstats-hide-zero on|off",
7945 (void *)&cmd_set_xstats_hide_zero_keyword,
7946 (void *)&cmd_set_xstats_hide_zero_name,
7947 (void *)&cmd_set_xstats_hide_zero_on_off,
7952 /* *** CONFIGURE UNICAST HASH TABLE *** */
7953 struct cmd_set_uc_hash_table {
7954 cmdline_fixed_string_t set;
7955 cmdline_fixed_string_t port;
7957 cmdline_fixed_string_t what;
7958 struct ether_addr address;
7959 cmdline_fixed_string_t mode;
7963 cmd_set_uc_hash_parsed(void *parsed_result,
7964 __attribute__((unused)) struct cmdline *cl,
7965 __attribute__((unused)) void *data)
7968 struct cmd_set_uc_hash_table *res = parsed_result;
7970 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7972 if (strcmp(res->what, "uta") == 0)
7973 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
7974 &res->address,(uint8_t)is_on);
7976 printf("bad unicast hash table parameter, return code = %d \n", ret);
7980 cmdline_parse_token_string_t cmd_set_uc_hash_set =
7981 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7983 cmdline_parse_token_string_t cmd_set_uc_hash_port =
7984 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7986 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
7987 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
7989 cmdline_parse_token_string_t cmd_set_uc_hash_what =
7990 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7992 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
7993 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
7995 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
7996 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7999 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
8000 .f = cmd_set_uc_hash_parsed,
8002 .help_str = "set port <port_id> uta <mac_addr> on|off)",
8004 (void *)&cmd_set_uc_hash_set,
8005 (void *)&cmd_set_uc_hash_port,
8006 (void *)&cmd_set_uc_hash_portid,
8007 (void *)&cmd_set_uc_hash_what,
8008 (void *)&cmd_set_uc_hash_mac,
8009 (void *)&cmd_set_uc_hash_mode,
8014 struct cmd_set_uc_all_hash_table {
8015 cmdline_fixed_string_t set;
8016 cmdline_fixed_string_t port;
8018 cmdline_fixed_string_t what;
8019 cmdline_fixed_string_t value;
8020 cmdline_fixed_string_t mode;
8024 cmd_set_uc_all_hash_parsed(void *parsed_result,
8025 __attribute__((unused)) struct cmdline *cl,
8026 __attribute__((unused)) void *data)
8029 struct cmd_set_uc_all_hash_table *res = parsed_result;
8031 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8033 if ((strcmp(res->what, "uta") == 0) &&
8034 (strcmp(res->value, "all") == 0))
8035 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
8037 printf("bad unicast hash table parameter,"
8038 "return code = %d \n", ret);
8041 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
8042 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8044 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
8045 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8047 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
8048 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
8050 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
8051 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8053 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
8054 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8056 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
8057 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8060 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
8061 .f = cmd_set_uc_all_hash_parsed,
8063 .help_str = "set port <port_id> uta all on|off",
8065 (void *)&cmd_set_uc_all_hash_set,
8066 (void *)&cmd_set_uc_all_hash_port,
8067 (void *)&cmd_set_uc_all_hash_portid,
8068 (void *)&cmd_set_uc_all_hash_what,
8069 (void *)&cmd_set_uc_all_hash_value,
8070 (void *)&cmd_set_uc_all_hash_mode,
8075 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
8076 struct cmd_set_vf_macvlan_filter {
8077 cmdline_fixed_string_t set;
8078 cmdline_fixed_string_t port;
8080 cmdline_fixed_string_t vf;
8082 struct ether_addr address;
8083 cmdline_fixed_string_t filter_type;
8084 cmdline_fixed_string_t mode;
8088 cmd_set_vf_macvlan_parsed(void *parsed_result,
8089 __attribute__((unused)) struct cmdline *cl,
8090 __attribute__((unused)) void *data)
8093 struct cmd_set_vf_macvlan_filter *res = parsed_result;
8094 struct rte_eth_mac_filter filter;
8096 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
8098 rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
8100 /* set VF MAC filter */
8104 filter.dst_id = res->vf_id;
8106 if (!strcmp(res->filter_type, "exact-mac"))
8107 filter.filter_type = RTE_MAC_PERFECT_MATCH;
8108 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
8109 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
8110 else if (!strcmp(res->filter_type, "hashmac"))
8111 filter.filter_type = RTE_MAC_HASH_MATCH;
8112 else if (!strcmp(res->filter_type, "hashmac-vlan"))
8113 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
8115 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8118 ret = rte_eth_dev_filter_ctrl(res->port_id,
8119 RTE_ETH_FILTER_MACVLAN,
8123 ret = rte_eth_dev_filter_ctrl(res->port_id,
8124 RTE_ETH_FILTER_MACVLAN,
8125 RTE_ETH_FILTER_DELETE,
8129 printf("bad set MAC hash parameter, return code = %d\n", ret);
8133 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
8134 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8136 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
8137 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8139 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
8140 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8142 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
8143 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8145 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
8146 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8148 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
8149 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8151 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
8152 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8153 filter_type, "exact-mac#exact-mac-vlan"
8154 "#hashmac#hashmac-vlan");
8155 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
8156 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8159 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
8160 .f = cmd_set_vf_macvlan_parsed,
8162 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
8163 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
8164 "Exact match rule: exact match of MAC or MAC and VLAN; "
8165 "hash match rule: hash match of MAC and exact match of VLAN",
8167 (void *)&cmd_set_vf_macvlan_set,
8168 (void *)&cmd_set_vf_macvlan_port,
8169 (void *)&cmd_set_vf_macvlan_portid,
8170 (void *)&cmd_set_vf_macvlan_vf,
8171 (void *)&cmd_set_vf_macvlan_vf_id,
8172 (void *)&cmd_set_vf_macvlan_mac,
8173 (void *)&cmd_set_vf_macvlan_filter_type,
8174 (void *)&cmd_set_vf_macvlan_mode,
8179 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
8180 struct cmd_set_vf_traffic {
8181 cmdline_fixed_string_t set;
8182 cmdline_fixed_string_t port;
8184 cmdline_fixed_string_t vf;
8186 cmdline_fixed_string_t what;
8187 cmdline_fixed_string_t mode;
8191 cmd_set_vf_traffic_parsed(void *parsed_result,
8192 __attribute__((unused)) struct cmdline *cl,
8193 __attribute__((unused)) void *data)
8195 struct cmd_set_vf_traffic *res = parsed_result;
8196 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
8197 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8199 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
8202 cmdline_parse_token_string_t cmd_setvf_traffic_set =
8203 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8205 cmdline_parse_token_string_t cmd_setvf_traffic_port =
8206 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8208 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8209 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8211 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8212 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8214 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8215 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8217 cmdline_parse_token_string_t cmd_setvf_traffic_what =
8218 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8220 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8221 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8224 cmdline_parse_inst_t cmd_set_vf_traffic = {
8225 .f = cmd_set_vf_traffic_parsed,
8227 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8229 (void *)&cmd_setvf_traffic_set,
8230 (void *)&cmd_setvf_traffic_port,
8231 (void *)&cmd_setvf_traffic_portid,
8232 (void *)&cmd_setvf_traffic_vf,
8233 (void *)&cmd_setvf_traffic_vfid,
8234 (void *)&cmd_setvf_traffic_what,
8235 (void *)&cmd_setvf_traffic_mode,
8240 /* *** CONFIGURE VF RECEIVE MODE *** */
8241 struct cmd_set_vf_rxmode {
8242 cmdline_fixed_string_t set;
8243 cmdline_fixed_string_t port;
8245 cmdline_fixed_string_t vf;
8247 cmdline_fixed_string_t what;
8248 cmdline_fixed_string_t mode;
8249 cmdline_fixed_string_t on;
8253 cmd_set_vf_rxmode_parsed(void *parsed_result,
8254 __attribute__((unused)) struct cmdline *cl,
8255 __attribute__((unused)) void *data)
8258 uint16_t rx_mode = 0;
8259 struct cmd_set_vf_rxmode *res = parsed_result;
8261 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8262 if (!strcmp(res->what,"rxmode")) {
8263 if (!strcmp(res->mode, "AUPE"))
8264 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
8265 else if (!strcmp(res->mode, "ROPE"))
8266 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
8267 else if (!strcmp(res->mode, "BAM"))
8268 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
8269 else if (!strncmp(res->mode, "MPE",3))
8270 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
8273 RTE_SET_USED(is_on);
8275 #ifdef RTE_LIBRTE_IXGBE_PMD
8276 if (ret == -ENOTSUP)
8277 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8278 rx_mode, (uint8_t)is_on);
8280 #ifdef RTE_LIBRTE_BNXT_PMD
8281 if (ret == -ENOTSUP)
8282 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8283 rx_mode, (uint8_t)is_on);
8286 printf("bad VF receive mode parameter, return code = %d \n",
8290 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8291 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8293 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8294 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8296 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8297 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8299 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8300 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8302 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8303 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8305 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
8306 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8308 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
8309 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8310 mode, "AUPE#ROPE#BAM#MPE");
8311 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
8312 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8315 cmdline_parse_inst_t cmd_set_vf_rxmode = {
8316 .f = cmd_set_vf_rxmode_parsed,
8318 .help_str = "set port <port_id> vf <vf_id> rxmode "
8319 "AUPE|ROPE|BAM|MPE on|off",
8321 (void *)&cmd_set_vf_rxmode_set,
8322 (void *)&cmd_set_vf_rxmode_port,
8323 (void *)&cmd_set_vf_rxmode_portid,
8324 (void *)&cmd_set_vf_rxmode_vf,
8325 (void *)&cmd_set_vf_rxmode_vfid,
8326 (void *)&cmd_set_vf_rxmode_what,
8327 (void *)&cmd_set_vf_rxmode_mode,
8328 (void *)&cmd_set_vf_rxmode_on,
8333 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
8334 struct cmd_vf_mac_addr_result {
8335 cmdline_fixed_string_t mac_addr_cmd;
8336 cmdline_fixed_string_t what;
8337 cmdline_fixed_string_t port;
8339 cmdline_fixed_string_t vf;
8341 struct ether_addr address;
8344 static void cmd_vf_mac_addr_parsed(void *parsed_result,
8345 __attribute__((unused)) struct cmdline *cl,
8346 __attribute__((unused)) void *data)
8348 struct cmd_vf_mac_addr_result *res = parsed_result;
8351 if (strcmp(res->what, "add") != 0)
8354 #ifdef RTE_LIBRTE_I40E_PMD
8355 if (ret == -ENOTSUP)
8356 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
8359 #ifdef RTE_LIBRTE_BNXT_PMD
8360 if (ret == -ENOTSUP)
8361 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
8366 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
8370 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
8371 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8372 mac_addr_cmd,"mac_addr");
8373 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
8374 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8376 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
8377 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8379 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
8380 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8382 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
8383 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8385 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
8386 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8388 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
8389 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
8392 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
8393 .f = cmd_vf_mac_addr_parsed,
8395 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
8396 "Add MAC address filtering for a VF on port_id",
8398 (void *)&cmd_vf_mac_addr_cmd,
8399 (void *)&cmd_vf_mac_addr_what,
8400 (void *)&cmd_vf_mac_addr_port,
8401 (void *)&cmd_vf_mac_addr_portnum,
8402 (void *)&cmd_vf_mac_addr_vf,
8403 (void *)&cmd_vf_mac_addr_vfnum,
8404 (void *)&cmd_vf_mac_addr_addr,
8409 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
8410 struct cmd_vf_rx_vlan_filter {
8411 cmdline_fixed_string_t rx_vlan;
8412 cmdline_fixed_string_t what;
8414 cmdline_fixed_string_t port;
8416 cmdline_fixed_string_t vf;
8421 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
8422 __attribute__((unused)) struct cmdline *cl,
8423 __attribute__((unused)) void *data)
8425 struct cmd_vf_rx_vlan_filter *res = parsed_result;
8428 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
8430 #ifdef RTE_LIBRTE_IXGBE_PMD
8431 if (ret == -ENOTSUP)
8432 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
8433 res->vlan_id, res->vf_mask, is_add);
8435 #ifdef RTE_LIBRTE_I40E_PMD
8436 if (ret == -ENOTSUP)
8437 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
8438 res->vlan_id, res->vf_mask, is_add);
8440 #ifdef RTE_LIBRTE_BNXT_PMD
8441 if (ret == -ENOTSUP)
8442 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
8443 res->vlan_id, res->vf_mask, is_add);
8450 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
8451 res->vlan_id, res->vf_mask);
8454 printf("invalid port_id %d\n", res->port_id);
8457 printf("function not implemented or supported\n");
8460 printf("programming error: (%s)\n", strerror(-ret));
8464 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
8465 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8466 rx_vlan, "rx_vlan");
8467 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
8468 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8470 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
8471 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8473 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
8474 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8476 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
8477 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8479 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
8480 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8482 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
8483 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8486 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
8487 .f = cmd_vf_rx_vlan_filter_parsed,
8489 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
8490 "(vf_mask = hexadecimal VF mask)",
8492 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
8493 (void *)&cmd_vf_rx_vlan_filter_what,
8494 (void *)&cmd_vf_rx_vlan_filter_vlanid,
8495 (void *)&cmd_vf_rx_vlan_filter_port,
8496 (void *)&cmd_vf_rx_vlan_filter_portid,
8497 (void *)&cmd_vf_rx_vlan_filter_vf,
8498 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
8503 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
8504 struct cmd_queue_rate_limit_result {
8505 cmdline_fixed_string_t set;
8506 cmdline_fixed_string_t port;
8508 cmdline_fixed_string_t queue;
8510 cmdline_fixed_string_t rate;
8514 static void cmd_queue_rate_limit_parsed(void *parsed_result,
8515 __attribute__((unused)) struct cmdline *cl,
8516 __attribute__((unused)) void *data)
8518 struct cmd_queue_rate_limit_result *res = parsed_result;
8521 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8522 && (strcmp(res->queue, "queue") == 0)
8523 && (strcmp(res->rate, "rate") == 0))
8524 ret = set_queue_rate_limit(res->port_num, res->queue_num,
8527 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
8531 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
8532 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8534 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
8535 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8537 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
8538 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8540 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
8541 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8543 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
8544 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8546 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
8547 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8549 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
8550 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8553 cmdline_parse_inst_t cmd_queue_rate_limit = {
8554 .f = cmd_queue_rate_limit_parsed,
8556 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
8557 "Set rate limit for a queue on port_id",
8559 (void *)&cmd_queue_rate_limit_set,
8560 (void *)&cmd_queue_rate_limit_port,
8561 (void *)&cmd_queue_rate_limit_portnum,
8562 (void *)&cmd_queue_rate_limit_queue,
8563 (void *)&cmd_queue_rate_limit_queuenum,
8564 (void *)&cmd_queue_rate_limit_rate,
8565 (void *)&cmd_queue_rate_limit_ratenum,
8570 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
8571 struct cmd_vf_rate_limit_result {
8572 cmdline_fixed_string_t set;
8573 cmdline_fixed_string_t port;
8575 cmdline_fixed_string_t vf;
8577 cmdline_fixed_string_t rate;
8579 cmdline_fixed_string_t q_msk;
8583 static void cmd_vf_rate_limit_parsed(void *parsed_result,
8584 __attribute__((unused)) struct cmdline *cl,
8585 __attribute__((unused)) void *data)
8587 struct cmd_vf_rate_limit_result *res = parsed_result;
8590 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8591 && (strcmp(res->vf, "vf") == 0)
8592 && (strcmp(res->rate, "rate") == 0)
8593 && (strcmp(res->q_msk, "queue_mask") == 0))
8594 ret = set_vf_rate_limit(res->port_num, res->vf_num,
8595 res->rate_num, res->q_msk_val);
8597 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
8601 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
8602 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8604 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
8605 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8607 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
8608 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8610 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
8611 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8613 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
8614 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8616 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
8617 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8619 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
8620 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8622 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
8623 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8624 q_msk, "queue_mask");
8625 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
8626 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8629 cmdline_parse_inst_t cmd_vf_rate_limit = {
8630 .f = cmd_vf_rate_limit_parsed,
8632 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
8633 "queue_mask <queue_mask_value>: "
8634 "Set rate limit for queues of VF on port_id",
8636 (void *)&cmd_vf_rate_limit_set,
8637 (void *)&cmd_vf_rate_limit_port,
8638 (void *)&cmd_vf_rate_limit_portnum,
8639 (void *)&cmd_vf_rate_limit_vf,
8640 (void *)&cmd_vf_rate_limit_vfnum,
8641 (void *)&cmd_vf_rate_limit_rate,
8642 (void *)&cmd_vf_rate_limit_ratenum,
8643 (void *)&cmd_vf_rate_limit_q_msk,
8644 (void *)&cmd_vf_rate_limit_q_msk_val,
8649 /* *** ADD TUNNEL FILTER OF A PORT *** */
8650 struct cmd_tunnel_filter_result {
8651 cmdline_fixed_string_t cmd;
8652 cmdline_fixed_string_t what;
8654 struct ether_addr outer_mac;
8655 struct ether_addr inner_mac;
8656 cmdline_ipaddr_t ip_value;
8657 uint16_t inner_vlan;
8658 cmdline_fixed_string_t tunnel_type;
8659 cmdline_fixed_string_t filter_type;
8665 cmd_tunnel_filter_parsed(void *parsed_result,
8666 __attribute__((unused)) struct cmdline *cl,
8667 __attribute__((unused)) void *data)
8669 struct cmd_tunnel_filter_result *res = parsed_result;
8670 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
8673 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
8675 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
8676 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
8677 tunnel_filter_conf.inner_vlan = res->inner_vlan;
8679 if (res->ip_value.family == AF_INET) {
8680 tunnel_filter_conf.ip_addr.ipv4_addr =
8681 res->ip_value.addr.ipv4.s_addr;
8682 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
8684 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
8685 &(res->ip_value.addr.ipv6),
8686 sizeof(struct in6_addr));
8687 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
8690 if (!strcmp(res->filter_type, "imac-ivlan"))
8691 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
8692 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
8693 tunnel_filter_conf.filter_type =
8694 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
8695 else if (!strcmp(res->filter_type, "imac-tenid"))
8696 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
8697 else if (!strcmp(res->filter_type, "imac"))
8698 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
8699 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
8700 tunnel_filter_conf.filter_type =
8701 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
8702 else if (!strcmp(res->filter_type, "oip"))
8703 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
8704 else if (!strcmp(res->filter_type, "iip"))
8705 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
8707 printf("The filter type is not supported");
8711 if (!strcmp(res->tunnel_type, "vxlan"))
8712 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
8713 else if (!strcmp(res->tunnel_type, "nvgre"))
8714 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
8715 else if (!strcmp(res->tunnel_type, "ipingre"))
8716 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
8718 printf("The tunnel type %s not supported.\n", res->tunnel_type);
8722 tunnel_filter_conf.tenant_id = res->tenant_id;
8723 tunnel_filter_conf.queue_id = res->queue_num;
8724 if (!strcmp(res->what, "add"))
8725 ret = rte_eth_dev_filter_ctrl(res->port_id,
8726 RTE_ETH_FILTER_TUNNEL,
8728 &tunnel_filter_conf);
8730 ret = rte_eth_dev_filter_ctrl(res->port_id,
8731 RTE_ETH_FILTER_TUNNEL,
8732 RTE_ETH_FILTER_DELETE,
8733 &tunnel_filter_conf);
8735 printf("cmd_tunnel_filter_parsed error: (%s)\n",
8739 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
8740 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8741 cmd, "tunnel_filter");
8742 cmdline_parse_token_string_t cmd_tunnel_filter_what =
8743 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8745 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
8746 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8748 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
8749 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8751 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
8752 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8754 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
8755 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8756 inner_vlan, UINT16);
8757 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
8758 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8760 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
8761 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8762 tunnel_type, "vxlan#nvgre#ipingre");
8764 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
8765 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8766 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
8767 "imac#omac-imac-tenid");
8768 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
8769 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8771 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
8772 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8775 cmdline_parse_inst_t cmd_tunnel_filter = {
8776 .f = cmd_tunnel_filter_parsed,
8778 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
8779 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
8780 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
8781 "<queue_id>: Add/Rm tunnel filter of a port",
8783 (void *)&cmd_tunnel_filter_cmd,
8784 (void *)&cmd_tunnel_filter_what,
8785 (void *)&cmd_tunnel_filter_port_id,
8786 (void *)&cmd_tunnel_filter_outer_mac,
8787 (void *)&cmd_tunnel_filter_inner_mac,
8788 (void *)&cmd_tunnel_filter_ip_value,
8789 (void *)&cmd_tunnel_filter_innner_vlan,
8790 (void *)&cmd_tunnel_filter_tunnel_type,
8791 (void *)&cmd_tunnel_filter_filter_type,
8792 (void *)&cmd_tunnel_filter_tenant_id,
8793 (void *)&cmd_tunnel_filter_queue_num,
8798 /* *** CONFIGURE TUNNEL UDP PORT *** */
8799 struct cmd_tunnel_udp_config {
8800 cmdline_fixed_string_t cmd;
8801 cmdline_fixed_string_t what;
8807 cmd_tunnel_udp_config_parsed(void *parsed_result,
8808 __attribute__((unused)) struct cmdline *cl,
8809 __attribute__((unused)) void *data)
8811 struct cmd_tunnel_udp_config *res = parsed_result;
8812 struct rte_eth_udp_tunnel tunnel_udp;
8815 tunnel_udp.udp_port = res->udp_port;
8817 if (!strcmp(res->cmd, "rx_vxlan_port"))
8818 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
8820 if (!strcmp(res->what, "add"))
8821 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
8824 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
8828 printf("udp tunneling add error: (%s)\n", strerror(-ret));
8831 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
8832 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8833 cmd, "rx_vxlan_port");
8834 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
8835 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8837 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
8838 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8840 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
8841 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8844 cmdline_parse_inst_t cmd_tunnel_udp_config = {
8845 .f = cmd_tunnel_udp_config_parsed,
8847 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
8848 "Add/Remove a tunneling UDP port filter",
8850 (void *)&cmd_tunnel_udp_config_cmd,
8851 (void *)&cmd_tunnel_udp_config_what,
8852 (void *)&cmd_tunnel_udp_config_udp_port,
8853 (void *)&cmd_tunnel_udp_config_port_id,
8858 struct cmd_config_tunnel_udp_port {
8859 cmdline_fixed_string_t port;
8860 cmdline_fixed_string_t config;
8862 cmdline_fixed_string_t udp_tunnel_port;
8863 cmdline_fixed_string_t action;
8864 cmdline_fixed_string_t tunnel_type;
8869 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
8870 __attribute__((unused)) struct cmdline *cl,
8871 __attribute__((unused)) void *data)
8873 struct cmd_config_tunnel_udp_port *res = parsed_result;
8874 struct rte_eth_udp_tunnel tunnel_udp;
8877 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8880 tunnel_udp.udp_port = res->udp_port;
8882 if (!strcmp(res->tunnel_type, "vxlan")) {
8883 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
8884 } else if (!strcmp(res->tunnel_type, "geneve")) {
8885 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE;
8887 printf("Invalid tunnel type\n");
8891 if (!strcmp(res->action, "add"))
8892 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
8895 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
8899 printf("udp tunneling port add error: (%s)\n", strerror(-ret));
8902 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
8903 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
8905 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
8906 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
8908 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
8909 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
8911 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
8912 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
8915 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
8916 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
8918 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
8919 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
8921 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
8922 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
8925 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
8926 .f = cmd_cfg_tunnel_udp_port_parsed,
8928 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|geneve <udp_port>",
8930 (void *)&cmd_config_tunnel_udp_port_port,
8931 (void *)&cmd_config_tunnel_udp_port_config,
8932 (void *)&cmd_config_tunnel_udp_port_port_id,
8933 (void *)&cmd_config_tunnel_udp_port_tunnel_port,
8934 (void *)&cmd_config_tunnel_udp_port_action,
8935 (void *)&cmd_config_tunnel_udp_port_tunnel_type,
8936 (void *)&cmd_config_tunnel_udp_port_value,
8941 /* *** GLOBAL CONFIG *** */
8942 struct cmd_global_config_result {
8943 cmdline_fixed_string_t cmd;
8945 cmdline_fixed_string_t cfg_type;
8950 cmd_global_config_parsed(void *parsed_result,
8951 __attribute__((unused)) struct cmdline *cl,
8952 __attribute__((unused)) void *data)
8954 struct cmd_global_config_result *res = parsed_result;
8955 struct rte_eth_global_cfg conf;
8958 memset(&conf, 0, sizeof(conf));
8959 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
8960 conf.cfg.gre_key_len = res->len;
8961 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
8962 RTE_ETH_FILTER_SET, &conf);
8964 printf("Global config error\n");
8967 cmdline_parse_token_string_t cmd_global_config_cmd =
8968 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
8970 cmdline_parse_token_num_t cmd_global_config_port_id =
8971 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id,
8973 cmdline_parse_token_string_t cmd_global_config_type =
8974 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
8975 cfg_type, "gre-key-len");
8976 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
8977 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
8980 cmdline_parse_inst_t cmd_global_config = {
8981 .f = cmd_global_config_parsed,
8982 .data = (void *)NULL,
8983 .help_str = "global_config <port_id> gre-key-len <key_len>",
8985 (void *)&cmd_global_config_cmd,
8986 (void *)&cmd_global_config_port_id,
8987 (void *)&cmd_global_config_type,
8988 (void *)&cmd_global_config_gre_key_len,
8993 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
8994 struct cmd_set_mirror_mask_result {
8995 cmdline_fixed_string_t set;
8996 cmdline_fixed_string_t port;
8998 cmdline_fixed_string_t mirror;
9000 cmdline_fixed_string_t what;
9001 cmdline_fixed_string_t value;
9002 cmdline_fixed_string_t dstpool;
9004 cmdline_fixed_string_t on;
9007 cmdline_parse_token_string_t cmd_mirror_mask_set =
9008 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9010 cmdline_parse_token_string_t cmd_mirror_mask_port =
9011 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9013 cmdline_parse_token_num_t cmd_mirror_mask_portid =
9014 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9016 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
9017 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9018 mirror, "mirror-rule");
9019 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
9020 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9022 cmdline_parse_token_string_t cmd_mirror_mask_what =
9023 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9024 what, "pool-mirror-up#pool-mirror-down"
9026 cmdline_parse_token_string_t cmd_mirror_mask_value =
9027 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9029 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
9030 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9031 dstpool, "dst-pool");
9032 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
9033 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9035 cmdline_parse_token_string_t cmd_mirror_mask_on =
9036 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9040 cmd_set_mirror_mask_parsed(void *parsed_result,
9041 __attribute__((unused)) struct cmdline *cl,
9042 __attribute__((unused)) void *data)
9045 struct cmd_set_mirror_mask_result *res = parsed_result;
9046 struct rte_eth_mirror_conf mr_conf;
9048 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9050 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
9052 mr_conf.dst_pool = res->dstpool_id;
9054 if (!strcmp(res->what, "pool-mirror-up")) {
9055 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9056 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
9057 } else if (!strcmp(res->what, "pool-mirror-down")) {
9058 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9059 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
9060 } else if (!strcmp(res->what, "vlan-mirror")) {
9061 mr_conf.rule_type = ETH_MIRROR_VLAN;
9062 nb_item = parse_item_list(res->value, "vlan",
9063 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
9067 for (i = 0; i < nb_item; i++) {
9068 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
9069 printf("Invalid vlan_id: must be < 4096\n");
9073 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
9074 mr_conf.vlan.vlan_mask |= 1ULL << i;
9078 if (!strcmp(res->on, "on"))
9079 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9082 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9085 printf("mirror rule add error: (%s)\n", strerror(-ret));
9088 cmdline_parse_inst_t cmd_set_mirror_mask = {
9089 .f = cmd_set_mirror_mask_parsed,
9091 .help_str = "set port <port_id> mirror-rule <rule_id> "
9092 "pool-mirror-up|pool-mirror-down|vlan-mirror "
9093 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
9095 (void *)&cmd_mirror_mask_set,
9096 (void *)&cmd_mirror_mask_port,
9097 (void *)&cmd_mirror_mask_portid,
9098 (void *)&cmd_mirror_mask_mirror,
9099 (void *)&cmd_mirror_mask_ruleid,
9100 (void *)&cmd_mirror_mask_what,
9101 (void *)&cmd_mirror_mask_value,
9102 (void *)&cmd_mirror_mask_dstpool,
9103 (void *)&cmd_mirror_mask_poolid,
9104 (void *)&cmd_mirror_mask_on,
9109 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
9110 struct cmd_set_mirror_link_result {
9111 cmdline_fixed_string_t set;
9112 cmdline_fixed_string_t port;
9114 cmdline_fixed_string_t mirror;
9116 cmdline_fixed_string_t what;
9117 cmdline_fixed_string_t dstpool;
9119 cmdline_fixed_string_t on;
9122 cmdline_parse_token_string_t cmd_mirror_link_set =
9123 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9125 cmdline_parse_token_string_t cmd_mirror_link_port =
9126 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9128 cmdline_parse_token_num_t cmd_mirror_link_portid =
9129 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9131 cmdline_parse_token_string_t cmd_mirror_link_mirror =
9132 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9133 mirror, "mirror-rule");
9134 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
9135 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9137 cmdline_parse_token_string_t cmd_mirror_link_what =
9138 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9139 what, "uplink-mirror#downlink-mirror");
9140 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
9141 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9142 dstpool, "dst-pool");
9143 cmdline_parse_token_num_t cmd_mirror_link_poolid =
9144 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9146 cmdline_parse_token_string_t cmd_mirror_link_on =
9147 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9151 cmd_set_mirror_link_parsed(void *parsed_result,
9152 __attribute__((unused)) struct cmdline *cl,
9153 __attribute__((unused)) void *data)
9156 struct cmd_set_mirror_link_result *res = parsed_result;
9157 struct rte_eth_mirror_conf mr_conf;
9159 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9160 if (!strcmp(res->what, "uplink-mirror"))
9161 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
9163 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
9165 mr_conf.dst_pool = res->dstpool_id;
9167 if (!strcmp(res->on, "on"))
9168 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9171 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9174 /* check the return value and print it if is < 0 */
9176 printf("mirror rule add error: (%s)\n", strerror(-ret));
9180 cmdline_parse_inst_t cmd_set_mirror_link = {
9181 .f = cmd_set_mirror_link_parsed,
9183 .help_str = "set port <port_id> mirror-rule <rule_id> "
9184 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
9186 (void *)&cmd_mirror_link_set,
9187 (void *)&cmd_mirror_link_port,
9188 (void *)&cmd_mirror_link_portid,
9189 (void *)&cmd_mirror_link_mirror,
9190 (void *)&cmd_mirror_link_ruleid,
9191 (void *)&cmd_mirror_link_what,
9192 (void *)&cmd_mirror_link_dstpool,
9193 (void *)&cmd_mirror_link_poolid,
9194 (void *)&cmd_mirror_link_on,
9199 /* *** RESET VM MIRROR RULE *** */
9200 struct cmd_rm_mirror_rule_result {
9201 cmdline_fixed_string_t reset;
9202 cmdline_fixed_string_t port;
9204 cmdline_fixed_string_t mirror;
9208 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
9209 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9211 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
9212 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9214 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
9215 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9217 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
9218 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9219 mirror, "mirror-rule");
9220 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
9221 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9225 cmd_reset_mirror_rule_parsed(void *parsed_result,
9226 __attribute__((unused)) struct cmdline *cl,
9227 __attribute__((unused)) void *data)
9230 struct cmd_set_mirror_link_result *res = parsed_result;
9232 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
9234 printf("mirror rule remove error: (%s)\n", strerror(-ret));
9237 cmdline_parse_inst_t cmd_reset_mirror_rule = {
9238 .f = cmd_reset_mirror_rule_parsed,
9240 .help_str = "reset port <port_id> mirror-rule <rule_id>",
9242 (void *)&cmd_rm_mirror_rule_reset,
9243 (void *)&cmd_rm_mirror_rule_port,
9244 (void *)&cmd_rm_mirror_rule_portid,
9245 (void *)&cmd_rm_mirror_rule_mirror,
9246 (void *)&cmd_rm_mirror_rule_ruleid,
9251 /* ******************************************************************************** */
9253 struct cmd_dump_result {
9254 cmdline_fixed_string_t dump;
9258 dump_struct_sizes(void)
9260 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9261 DUMP_SIZE(struct rte_mbuf);
9262 DUMP_SIZE(struct rte_mempool);
9263 DUMP_SIZE(struct rte_ring);
9267 static void cmd_dump_parsed(void *parsed_result,
9268 __attribute__((unused)) struct cmdline *cl,
9269 __attribute__((unused)) void *data)
9271 struct cmd_dump_result *res = parsed_result;
9273 if (!strcmp(res->dump, "dump_physmem"))
9274 rte_dump_physmem_layout(stdout);
9275 else if (!strcmp(res->dump, "dump_memzone"))
9276 rte_memzone_dump(stdout);
9277 else if (!strcmp(res->dump, "dump_struct_sizes"))
9278 dump_struct_sizes();
9279 else if (!strcmp(res->dump, "dump_ring"))
9280 rte_ring_list_dump(stdout);
9281 else if (!strcmp(res->dump, "dump_mempool"))
9282 rte_mempool_list_dump(stdout);
9283 else if (!strcmp(res->dump, "dump_devargs"))
9284 rte_devargs_dump(stdout);
9285 else if (!strcmp(res->dump, "dump_log_types"))
9286 rte_log_dump(stdout);
9289 cmdline_parse_token_string_t cmd_dump_dump =
9290 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9293 "dump_struct_sizes#"
9299 cmdline_parse_inst_t cmd_dump = {
9300 .f = cmd_dump_parsed, /* function to call */
9301 .data = NULL, /* 2nd arg of func */
9302 .help_str = "Dump status",
9303 .tokens = { /* token list, NULL terminated */
9304 (void *)&cmd_dump_dump,
9309 /* ******************************************************************************** */
9311 struct cmd_dump_one_result {
9312 cmdline_fixed_string_t dump;
9313 cmdline_fixed_string_t name;
9316 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9317 __attribute__((unused)) void *data)
9319 struct cmd_dump_one_result *res = parsed_result;
9321 if (!strcmp(res->dump, "dump_ring")) {
9323 r = rte_ring_lookup(res->name);
9325 cmdline_printf(cl, "Cannot find ring\n");
9328 rte_ring_dump(stdout, r);
9329 } else if (!strcmp(res->dump, "dump_mempool")) {
9330 struct rte_mempool *mp;
9331 mp = rte_mempool_lookup(res->name);
9333 cmdline_printf(cl, "Cannot find mempool\n");
9336 rte_mempool_dump(stdout, mp);
9340 cmdline_parse_token_string_t cmd_dump_one_dump =
9341 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9342 "dump_ring#dump_mempool");
9344 cmdline_parse_token_string_t cmd_dump_one_name =
9345 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9347 cmdline_parse_inst_t cmd_dump_one = {
9348 .f = cmd_dump_one_parsed, /* function to call */
9349 .data = NULL, /* 2nd arg of func */
9350 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9351 .tokens = { /* token list, NULL terminated */
9352 (void *)&cmd_dump_one_dump,
9353 (void *)&cmd_dump_one_name,
9358 /* *** Add/Del syn filter *** */
9359 struct cmd_syn_filter_result {
9360 cmdline_fixed_string_t filter;
9362 cmdline_fixed_string_t ops;
9363 cmdline_fixed_string_t priority;
9364 cmdline_fixed_string_t high;
9365 cmdline_fixed_string_t queue;
9370 cmd_syn_filter_parsed(void *parsed_result,
9371 __attribute__((unused)) struct cmdline *cl,
9372 __attribute__((unused)) void *data)
9374 struct cmd_syn_filter_result *res = parsed_result;
9375 struct rte_eth_syn_filter syn_filter;
9378 ret = rte_eth_dev_filter_supported(res->port_id,
9379 RTE_ETH_FILTER_SYN);
9381 printf("syn filter is not supported on port %u.\n",
9386 memset(&syn_filter, 0, sizeof(syn_filter));
9388 if (!strcmp(res->ops, "add")) {
9389 if (!strcmp(res->high, "high"))
9390 syn_filter.hig_pri = 1;
9392 syn_filter.hig_pri = 0;
9394 syn_filter.queue = res->queue_id;
9395 ret = rte_eth_dev_filter_ctrl(res->port_id,
9400 ret = rte_eth_dev_filter_ctrl(res->port_id,
9402 RTE_ETH_FILTER_DELETE,
9406 printf("syn filter programming error: (%s)\n",
9410 cmdline_parse_token_string_t cmd_syn_filter_filter =
9411 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9412 filter, "syn_filter");
9413 cmdline_parse_token_num_t cmd_syn_filter_port_id =
9414 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9416 cmdline_parse_token_string_t cmd_syn_filter_ops =
9417 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9419 cmdline_parse_token_string_t cmd_syn_filter_priority =
9420 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9421 priority, "priority");
9422 cmdline_parse_token_string_t cmd_syn_filter_high =
9423 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9425 cmdline_parse_token_string_t cmd_syn_filter_queue =
9426 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9428 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
9429 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9432 cmdline_parse_inst_t cmd_syn_filter = {
9433 .f = cmd_syn_filter_parsed,
9435 .help_str = "syn_filter <port_id> add|del priority high|low queue "
9436 "<queue_id>: Add/Delete syn filter",
9438 (void *)&cmd_syn_filter_filter,
9439 (void *)&cmd_syn_filter_port_id,
9440 (void *)&cmd_syn_filter_ops,
9441 (void *)&cmd_syn_filter_priority,
9442 (void *)&cmd_syn_filter_high,
9443 (void *)&cmd_syn_filter_queue,
9444 (void *)&cmd_syn_filter_queue_id,
9449 /* *** queue region set *** */
9450 struct cmd_queue_region_result {
9451 cmdline_fixed_string_t set;
9452 cmdline_fixed_string_t port;
9454 cmdline_fixed_string_t cmd;
9455 cmdline_fixed_string_t region;
9457 cmdline_fixed_string_t queue_start_index;
9459 cmdline_fixed_string_t queue_num;
9460 uint8_t queue_num_value;
9464 cmd_queue_region_parsed(void *parsed_result,
9465 __attribute__((unused)) struct cmdline *cl,
9466 __attribute__((unused)) void *data)
9468 struct cmd_queue_region_result *res = parsed_result;
9470 #ifdef RTE_LIBRTE_I40E_PMD
9471 struct rte_pmd_i40e_queue_region_conf region_conf;
9472 enum rte_pmd_i40e_queue_region_op op_type;
9475 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9478 #ifdef RTE_LIBRTE_I40E_PMD
9479 memset(®ion_conf, 0, sizeof(region_conf));
9480 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
9481 region_conf.region_id = res->region_id;
9482 region_conf.queue_num = res->queue_num_value;
9483 region_conf.queue_start_index = res->queue_id;
9485 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9486 op_type, ®ion_conf);
9493 printf("function not implemented or supported\n");
9496 printf("queue region config error: (%s)\n", strerror(-ret));
9500 cmdline_parse_token_string_t cmd_queue_region_set =
9501 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9503 cmdline_parse_token_string_t cmd_queue_region_port =
9504 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
9505 cmdline_parse_token_num_t cmd_queue_region_port_id =
9506 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9508 cmdline_parse_token_string_t cmd_queue_region_cmd =
9509 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9510 cmd, "queue-region");
9511 cmdline_parse_token_string_t cmd_queue_region_id =
9512 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9513 region, "region_id");
9514 cmdline_parse_token_num_t cmd_queue_region_index =
9515 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9517 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
9518 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9519 queue_start_index, "queue_start_index");
9520 cmdline_parse_token_num_t cmd_queue_region_queue_id =
9521 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9523 cmdline_parse_token_string_t cmd_queue_region_queue_num =
9524 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9525 queue_num, "queue_num");
9526 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
9527 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9528 queue_num_value, UINT8);
9530 cmdline_parse_inst_t cmd_queue_region = {
9531 .f = cmd_queue_region_parsed,
9533 .help_str = "set port <port_id> queue-region region_id <value> "
9534 "queue_start_index <value> queue_num <value>: Set a queue region",
9536 (void *)&cmd_queue_region_set,
9537 (void *)&cmd_queue_region_port,
9538 (void *)&cmd_queue_region_port_id,
9539 (void *)&cmd_queue_region_cmd,
9540 (void *)&cmd_queue_region_id,
9541 (void *)&cmd_queue_region_index,
9542 (void *)&cmd_queue_region_queue_start_index,
9543 (void *)&cmd_queue_region_queue_id,
9544 (void *)&cmd_queue_region_queue_num,
9545 (void *)&cmd_queue_region_queue_num_value,
9550 /* *** queue region and flowtype set *** */
9551 struct cmd_region_flowtype_result {
9552 cmdline_fixed_string_t set;
9553 cmdline_fixed_string_t port;
9555 cmdline_fixed_string_t cmd;
9556 cmdline_fixed_string_t region;
9558 cmdline_fixed_string_t flowtype;
9559 uint8_t flowtype_id;
9563 cmd_region_flowtype_parsed(void *parsed_result,
9564 __attribute__((unused)) struct cmdline *cl,
9565 __attribute__((unused)) void *data)
9567 struct cmd_region_flowtype_result *res = parsed_result;
9569 #ifdef RTE_LIBRTE_I40E_PMD
9570 struct rte_pmd_i40e_queue_region_conf region_conf;
9571 enum rte_pmd_i40e_queue_region_op op_type;
9574 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9577 #ifdef RTE_LIBRTE_I40E_PMD
9578 memset(®ion_conf, 0, sizeof(region_conf));
9580 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
9581 region_conf.region_id = res->region_id;
9582 region_conf.hw_flowtype = res->flowtype_id;
9584 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9585 op_type, ®ion_conf);
9592 printf("function not implemented or supported\n");
9595 printf("region flowtype config error: (%s)\n", strerror(-ret));
9599 cmdline_parse_token_string_t cmd_region_flowtype_set =
9600 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9602 cmdline_parse_token_string_t cmd_region_flowtype_port =
9603 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9605 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
9606 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9608 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
9609 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9610 cmd, "queue-region");
9611 cmdline_parse_token_string_t cmd_region_flowtype_index =
9612 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9613 region, "region_id");
9614 cmdline_parse_token_num_t cmd_region_flowtype_id =
9615 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9617 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
9618 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9619 flowtype, "flowtype");
9620 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
9621 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9622 flowtype_id, UINT8);
9623 cmdline_parse_inst_t cmd_region_flowtype = {
9624 .f = cmd_region_flowtype_parsed,
9626 .help_str = "set port <port_id> queue-region region_id <value> "
9627 "flowtype <value>: Set a flowtype region index",
9629 (void *)&cmd_region_flowtype_set,
9630 (void *)&cmd_region_flowtype_port,
9631 (void *)&cmd_region_flowtype_port_index,
9632 (void *)&cmd_region_flowtype_cmd,
9633 (void *)&cmd_region_flowtype_index,
9634 (void *)&cmd_region_flowtype_id,
9635 (void *)&cmd_region_flowtype_flow_index,
9636 (void *)&cmd_region_flowtype_flow_id,
9641 /* *** User Priority (UP) to queue region (region_id) set *** */
9642 struct cmd_user_priority_region_result {
9643 cmdline_fixed_string_t set;
9644 cmdline_fixed_string_t port;
9646 cmdline_fixed_string_t cmd;
9647 cmdline_fixed_string_t user_priority;
9648 uint8_t user_priority_id;
9649 cmdline_fixed_string_t region;
9654 cmd_user_priority_region_parsed(void *parsed_result,
9655 __attribute__((unused)) struct cmdline *cl,
9656 __attribute__((unused)) void *data)
9658 struct cmd_user_priority_region_result *res = parsed_result;
9660 #ifdef RTE_LIBRTE_I40E_PMD
9661 struct rte_pmd_i40e_queue_region_conf region_conf;
9662 enum rte_pmd_i40e_queue_region_op op_type;
9665 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9668 #ifdef RTE_LIBRTE_I40E_PMD
9669 memset(®ion_conf, 0, sizeof(region_conf));
9670 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
9671 region_conf.user_priority = res->user_priority_id;
9672 region_conf.region_id = res->region_id;
9674 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9675 op_type, ®ion_conf);
9682 printf("function not implemented or supported\n");
9685 printf("user_priority region config error: (%s)\n",
9690 cmdline_parse_token_string_t cmd_user_priority_region_set =
9691 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9693 cmdline_parse_token_string_t cmd_user_priority_region_port =
9694 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9696 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
9697 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9699 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
9700 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9701 cmd, "queue-region");
9702 cmdline_parse_token_string_t cmd_user_priority_region_UP =
9703 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9704 user_priority, "UP");
9705 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
9706 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9707 user_priority_id, UINT8);
9708 cmdline_parse_token_string_t cmd_user_priority_region_region =
9709 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9710 region, "region_id");
9711 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
9712 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9715 cmdline_parse_inst_t cmd_user_priority_region = {
9716 .f = cmd_user_priority_region_parsed,
9718 .help_str = "set port <port_id> queue-region UP <value> "
9719 "region_id <value>: Set the mapping of User Priority (UP) "
9720 "to queue region (region_id) ",
9722 (void *)&cmd_user_priority_region_set,
9723 (void *)&cmd_user_priority_region_port,
9724 (void *)&cmd_user_priority_region_port_index,
9725 (void *)&cmd_user_priority_region_cmd,
9726 (void *)&cmd_user_priority_region_UP,
9727 (void *)&cmd_user_priority_region_UP_id,
9728 (void *)&cmd_user_priority_region_region,
9729 (void *)&cmd_user_priority_region_region_id,
9734 /* *** flush all queue region related configuration *** */
9735 struct cmd_flush_queue_region_result {
9736 cmdline_fixed_string_t set;
9737 cmdline_fixed_string_t port;
9739 cmdline_fixed_string_t cmd;
9740 cmdline_fixed_string_t flush;
9741 cmdline_fixed_string_t what;
9745 cmd_flush_queue_region_parsed(void *parsed_result,
9746 __attribute__((unused)) struct cmdline *cl,
9747 __attribute__((unused)) void *data)
9749 struct cmd_flush_queue_region_result *res = parsed_result;
9751 #ifdef RTE_LIBRTE_I40E_PMD
9752 struct rte_pmd_i40e_queue_region_conf region_conf;
9753 enum rte_pmd_i40e_queue_region_op op_type;
9756 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9759 #ifdef RTE_LIBRTE_I40E_PMD
9760 memset(®ion_conf, 0, sizeof(region_conf));
9762 if (strcmp(res->what, "on") == 0)
9763 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
9765 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
9767 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9768 op_type, ®ion_conf);
9775 printf("function not implemented or supported\n");
9778 printf("queue region config flush error: (%s)\n",
9783 cmdline_parse_token_string_t cmd_flush_queue_region_set =
9784 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9786 cmdline_parse_token_string_t cmd_flush_queue_region_port =
9787 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9789 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
9790 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
9792 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
9793 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9794 cmd, "queue-region");
9795 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
9796 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9798 cmdline_parse_token_string_t cmd_flush_queue_region_what =
9799 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9802 cmdline_parse_inst_t cmd_flush_queue_region = {
9803 .f = cmd_flush_queue_region_parsed,
9805 .help_str = "set port <port_id> queue-region flush on|off"
9806 ": flush all queue region related configuration",
9808 (void *)&cmd_flush_queue_region_set,
9809 (void *)&cmd_flush_queue_region_port,
9810 (void *)&cmd_flush_queue_region_port_index,
9811 (void *)&cmd_flush_queue_region_cmd,
9812 (void *)&cmd_flush_queue_region_flush,
9813 (void *)&cmd_flush_queue_region_what,
9818 /* *** get all queue region related configuration info *** */
9819 struct cmd_show_queue_region_info {
9820 cmdline_fixed_string_t show;
9821 cmdline_fixed_string_t port;
9823 cmdline_fixed_string_t cmd;
9827 cmd_show_queue_region_info_parsed(void *parsed_result,
9828 __attribute__((unused)) struct cmdline *cl,
9829 __attribute__((unused)) void *data)
9831 struct cmd_show_queue_region_info *res = parsed_result;
9833 #ifdef RTE_LIBRTE_I40E_PMD
9834 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
9835 enum rte_pmd_i40e_queue_region_op op_type;
9838 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9841 #ifdef RTE_LIBRTE_I40E_PMD
9842 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
9844 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
9846 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9847 op_type, &rte_pmd_regions);
9849 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
9856 printf("function not implemented or supported\n");
9859 printf("queue region config info show error: (%s)\n",
9864 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
9865 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9867 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
9868 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9870 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
9871 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
9873 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
9874 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9875 cmd, "queue-region");
9877 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
9878 .f = cmd_show_queue_region_info_parsed,
9880 .help_str = "show port <port_id> queue-region"
9881 ": show all queue region related configuration info",
9883 (void *)&cmd_show_queue_region_info_get,
9884 (void *)&cmd_show_queue_region_info_port,
9885 (void *)&cmd_show_queue_region_info_port_index,
9886 (void *)&cmd_show_queue_region_info_cmd,
9891 /* *** ADD/REMOVE A 2tuple FILTER *** */
9892 struct cmd_2tuple_filter_result {
9893 cmdline_fixed_string_t filter;
9895 cmdline_fixed_string_t ops;
9896 cmdline_fixed_string_t dst_port;
9897 uint16_t dst_port_value;
9898 cmdline_fixed_string_t protocol;
9899 uint8_t protocol_value;
9900 cmdline_fixed_string_t mask;
9902 cmdline_fixed_string_t tcp_flags;
9903 uint8_t tcp_flags_value;
9904 cmdline_fixed_string_t priority;
9905 uint8_t priority_value;
9906 cmdline_fixed_string_t queue;
9911 cmd_2tuple_filter_parsed(void *parsed_result,
9912 __attribute__((unused)) struct cmdline *cl,
9913 __attribute__((unused)) void *data)
9915 struct rte_eth_ntuple_filter filter;
9916 struct cmd_2tuple_filter_result *res = parsed_result;
9919 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
9921 printf("ntuple filter is not supported on port %u.\n",
9926 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
9928 filter.flags = RTE_2TUPLE_FLAGS;
9929 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
9930 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
9931 filter.proto = res->protocol_value;
9932 filter.priority = res->priority_value;
9933 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
9934 printf("nonzero tcp_flags is only meaningful"
9935 " when protocol is TCP.\n");
9938 if (res->tcp_flags_value > TCP_FLAG_ALL) {
9939 printf("invalid TCP flags.\n");
9943 if (res->tcp_flags_value != 0) {
9944 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
9945 filter.tcp_flags = res->tcp_flags_value;
9948 /* need convert to big endian. */
9949 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
9950 filter.queue = res->queue_id;
9952 if (!strcmp(res->ops, "add"))
9953 ret = rte_eth_dev_filter_ctrl(res->port_id,
9954 RTE_ETH_FILTER_NTUPLE,
9958 ret = rte_eth_dev_filter_ctrl(res->port_id,
9959 RTE_ETH_FILTER_NTUPLE,
9960 RTE_ETH_FILTER_DELETE,
9963 printf("2tuple filter programming error: (%s)\n",
9968 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
9969 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9970 filter, "2tuple_filter");
9971 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
9972 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9974 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
9975 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9977 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
9978 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9979 dst_port, "dst_port");
9980 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
9981 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9982 dst_port_value, UINT16);
9983 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
9984 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9985 protocol, "protocol");
9986 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
9987 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9988 protocol_value, UINT8);
9989 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
9990 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9992 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
9993 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9995 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
9996 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9997 tcp_flags, "tcp_flags");
9998 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
9999 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10000 tcp_flags_value, UINT8);
10001 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
10002 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10003 priority, "priority");
10004 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
10005 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10006 priority_value, UINT8);
10007 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
10008 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10010 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
10011 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10014 cmdline_parse_inst_t cmd_2tuple_filter = {
10015 .f = cmd_2tuple_filter_parsed,
10017 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
10018 "<value> mask <value> tcp_flags <value> priority <value> queue "
10019 "<queue_id>: Add a 2tuple filter",
10021 (void *)&cmd_2tuple_filter_filter,
10022 (void *)&cmd_2tuple_filter_port_id,
10023 (void *)&cmd_2tuple_filter_ops,
10024 (void *)&cmd_2tuple_filter_dst_port,
10025 (void *)&cmd_2tuple_filter_dst_port_value,
10026 (void *)&cmd_2tuple_filter_protocol,
10027 (void *)&cmd_2tuple_filter_protocol_value,
10028 (void *)&cmd_2tuple_filter_mask,
10029 (void *)&cmd_2tuple_filter_mask_value,
10030 (void *)&cmd_2tuple_filter_tcp_flags,
10031 (void *)&cmd_2tuple_filter_tcp_flags_value,
10032 (void *)&cmd_2tuple_filter_priority,
10033 (void *)&cmd_2tuple_filter_priority_value,
10034 (void *)&cmd_2tuple_filter_queue,
10035 (void *)&cmd_2tuple_filter_queue_id,
10040 /* *** ADD/REMOVE A 5tuple FILTER *** */
10041 struct cmd_5tuple_filter_result {
10042 cmdline_fixed_string_t filter;
10044 cmdline_fixed_string_t ops;
10045 cmdline_fixed_string_t dst_ip;
10046 cmdline_ipaddr_t dst_ip_value;
10047 cmdline_fixed_string_t src_ip;
10048 cmdline_ipaddr_t src_ip_value;
10049 cmdline_fixed_string_t dst_port;
10050 uint16_t dst_port_value;
10051 cmdline_fixed_string_t src_port;
10052 uint16_t src_port_value;
10053 cmdline_fixed_string_t protocol;
10054 uint8_t protocol_value;
10055 cmdline_fixed_string_t mask;
10056 uint8_t mask_value;
10057 cmdline_fixed_string_t tcp_flags;
10058 uint8_t tcp_flags_value;
10059 cmdline_fixed_string_t priority;
10060 uint8_t priority_value;
10061 cmdline_fixed_string_t queue;
10066 cmd_5tuple_filter_parsed(void *parsed_result,
10067 __attribute__((unused)) struct cmdline *cl,
10068 __attribute__((unused)) void *data)
10070 struct rte_eth_ntuple_filter filter;
10071 struct cmd_5tuple_filter_result *res = parsed_result;
10074 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
10076 printf("ntuple filter is not supported on port %u.\n",
10081 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
10083 filter.flags = RTE_5TUPLE_FLAGS;
10084 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
10085 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
10086 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
10087 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
10088 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
10089 filter.proto = res->protocol_value;
10090 filter.priority = res->priority_value;
10091 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
10092 printf("nonzero tcp_flags is only meaningful"
10093 " when protocol is TCP.\n");
10096 if (res->tcp_flags_value > TCP_FLAG_ALL) {
10097 printf("invalid TCP flags.\n");
10101 if (res->tcp_flags_value != 0) {
10102 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
10103 filter.tcp_flags = res->tcp_flags_value;
10106 if (res->dst_ip_value.family == AF_INET)
10107 /* no need to convert, already big endian. */
10108 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
10110 if (filter.dst_ip_mask == 0) {
10111 printf("can not support ipv6 involved compare.\n");
10117 if (res->src_ip_value.family == AF_INET)
10118 /* no need to convert, already big endian. */
10119 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
10121 if (filter.src_ip_mask == 0) {
10122 printf("can not support ipv6 involved compare.\n");
10127 /* need convert to big endian. */
10128 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
10129 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
10130 filter.queue = res->queue_id;
10132 if (!strcmp(res->ops, "add"))
10133 ret = rte_eth_dev_filter_ctrl(res->port_id,
10134 RTE_ETH_FILTER_NTUPLE,
10135 RTE_ETH_FILTER_ADD,
10138 ret = rte_eth_dev_filter_ctrl(res->port_id,
10139 RTE_ETH_FILTER_NTUPLE,
10140 RTE_ETH_FILTER_DELETE,
10143 printf("5tuple filter programming error: (%s)\n",
10147 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
10148 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10149 filter, "5tuple_filter");
10150 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
10151 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10153 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
10154 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10156 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
10157 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10159 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
10160 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10162 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
10163 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10165 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
10166 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10168 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
10169 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10170 dst_port, "dst_port");
10171 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
10172 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10173 dst_port_value, UINT16);
10174 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
10175 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10176 src_port, "src_port");
10177 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
10178 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10179 src_port_value, UINT16);
10180 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
10181 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10182 protocol, "protocol");
10183 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
10184 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10185 protocol_value, UINT8);
10186 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
10187 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10189 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
10190 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10192 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
10193 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10194 tcp_flags, "tcp_flags");
10195 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
10196 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10197 tcp_flags_value, UINT8);
10198 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
10199 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10200 priority, "priority");
10201 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
10202 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10203 priority_value, UINT8);
10204 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
10205 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10207 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
10208 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10211 cmdline_parse_inst_t cmd_5tuple_filter = {
10212 .f = cmd_5tuple_filter_parsed,
10214 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
10215 "src_ip <value> dst_port <value> src_port <value> "
10216 "protocol <value> mask <value> tcp_flags <value> "
10217 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
10219 (void *)&cmd_5tuple_filter_filter,
10220 (void *)&cmd_5tuple_filter_port_id,
10221 (void *)&cmd_5tuple_filter_ops,
10222 (void *)&cmd_5tuple_filter_dst_ip,
10223 (void *)&cmd_5tuple_filter_dst_ip_value,
10224 (void *)&cmd_5tuple_filter_src_ip,
10225 (void *)&cmd_5tuple_filter_src_ip_value,
10226 (void *)&cmd_5tuple_filter_dst_port,
10227 (void *)&cmd_5tuple_filter_dst_port_value,
10228 (void *)&cmd_5tuple_filter_src_port,
10229 (void *)&cmd_5tuple_filter_src_port_value,
10230 (void *)&cmd_5tuple_filter_protocol,
10231 (void *)&cmd_5tuple_filter_protocol_value,
10232 (void *)&cmd_5tuple_filter_mask,
10233 (void *)&cmd_5tuple_filter_mask_value,
10234 (void *)&cmd_5tuple_filter_tcp_flags,
10235 (void *)&cmd_5tuple_filter_tcp_flags_value,
10236 (void *)&cmd_5tuple_filter_priority,
10237 (void *)&cmd_5tuple_filter_priority_value,
10238 (void *)&cmd_5tuple_filter_queue,
10239 (void *)&cmd_5tuple_filter_queue_id,
10244 /* *** ADD/REMOVE A flex FILTER *** */
10245 struct cmd_flex_filter_result {
10246 cmdline_fixed_string_t filter;
10247 cmdline_fixed_string_t ops;
10249 cmdline_fixed_string_t len;
10251 cmdline_fixed_string_t bytes;
10252 cmdline_fixed_string_t bytes_value;
10253 cmdline_fixed_string_t mask;
10254 cmdline_fixed_string_t mask_value;
10255 cmdline_fixed_string_t priority;
10256 uint8_t priority_value;
10257 cmdline_fixed_string_t queue;
10261 static int xdigit2val(unsigned char c)
10266 else if (isupper(c))
10267 val = c - 'A' + 10;
10269 val = c - 'a' + 10;
10274 cmd_flex_filter_parsed(void *parsed_result,
10275 __attribute__((unused)) struct cmdline *cl,
10276 __attribute__((unused)) void *data)
10279 struct rte_eth_flex_filter filter;
10280 struct cmd_flex_filter_result *res = parsed_result;
10281 char *bytes_ptr, *mask_ptr;
10282 uint16_t len, i, j = 0;
10287 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
10288 printf("the len exceed the max length 128\n");
10291 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
10292 filter.len = res->len_value;
10293 filter.priority = res->priority_value;
10294 filter.queue = res->queue_id;
10295 bytes_ptr = res->bytes_value;
10296 mask_ptr = res->mask_value;
10298 /* translate bytes string to array. */
10299 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
10300 (bytes_ptr[1] == 'X')))
10302 len = strnlen(bytes_ptr, res->len_value * 2);
10303 if (len == 0 || (len % 8 != 0)) {
10304 printf("please check len and bytes input\n");
10307 for (i = 0; i < len; i++) {
10309 if (isxdigit(c) == 0) {
10310 /* invalid characters. */
10311 printf("invalid input\n");
10314 val = xdigit2val(c);
10317 filter.bytes[j] = byte;
10318 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
10325 /* translate mask string to uint8_t array. */
10326 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
10327 (mask_ptr[1] == 'X')))
10329 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
10331 printf("invalid input\n");
10336 for (i = 0; i < len; i++) {
10338 if (isxdigit(c) == 0) {
10339 /* invalid characters. */
10340 printf("invalid input\n");
10343 val = xdigit2val(c);
10346 filter.mask[j] = byte;
10347 printf("mask[%d]:%02x ", j, filter.mask[j]);
10355 if (!strcmp(res->ops, "add"))
10356 ret = rte_eth_dev_filter_ctrl(res->port_id,
10357 RTE_ETH_FILTER_FLEXIBLE,
10358 RTE_ETH_FILTER_ADD,
10361 ret = rte_eth_dev_filter_ctrl(res->port_id,
10362 RTE_ETH_FILTER_FLEXIBLE,
10363 RTE_ETH_FILTER_DELETE,
10367 printf("flex filter setting error: (%s)\n", strerror(-ret));
10370 cmdline_parse_token_string_t cmd_flex_filter_filter =
10371 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10372 filter, "flex_filter");
10373 cmdline_parse_token_num_t cmd_flex_filter_port_id =
10374 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10376 cmdline_parse_token_string_t cmd_flex_filter_ops =
10377 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10379 cmdline_parse_token_string_t cmd_flex_filter_len =
10380 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10382 cmdline_parse_token_num_t cmd_flex_filter_len_value =
10383 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10385 cmdline_parse_token_string_t cmd_flex_filter_bytes =
10386 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10388 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
10389 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10390 bytes_value, NULL);
10391 cmdline_parse_token_string_t cmd_flex_filter_mask =
10392 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10394 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
10395 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10397 cmdline_parse_token_string_t cmd_flex_filter_priority =
10398 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10399 priority, "priority");
10400 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
10401 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10402 priority_value, UINT8);
10403 cmdline_parse_token_string_t cmd_flex_filter_queue =
10404 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10406 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
10407 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10409 cmdline_parse_inst_t cmd_flex_filter = {
10410 .f = cmd_flex_filter_parsed,
10412 .help_str = "flex_filter <port_id> add|del len <value> bytes "
10413 "<value> mask <value> priority <value> queue <queue_id>: "
10414 "Add/Del a flex filter",
10416 (void *)&cmd_flex_filter_filter,
10417 (void *)&cmd_flex_filter_port_id,
10418 (void *)&cmd_flex_filter_ops,
10419 (void *)&cmd_flex_filter_len,
10420 (void *)&cmd_flex_filter_len_value,
10421 (void *)&cmd_flex_filter_bytes,
10422 (void *)&cmd_flex_filter_bytes_value,
10423 (void *)&cmd_flex_filter_mask,
10424 (void *)&cmd_flex_filter_mask_value,
10425 (void *)&cmd_flex_filter_priority,
10426 (void *)&cmd_flex_filter_priority_value,
10427 (void *)&cmd_flex_filter_queue,
10428 (void *)&cmd_flex_filter_queue_id,
10433 /* *** Filters Control *** */
10435 /* *** deal with ethertype filter *** */
10436 struct cmd_ethertype_filter_result {
10437 cmdline_fixed_string_t filter;
10439 cmdline_fixed_string_t ops;
10440 cmdline_fixed_string_t mac;
10441 struct ether_addr mac_addr;
10442 cmdline_fixed_string_t ethertype;
10443 uint16_t ethertype_value;
10444 cmdline_fixed_string_t drop;
10445 cmdline_fixed_string_t queue;
10449 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
10450 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10451 filter, "ethertype_filter");
10452 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
10453 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10455 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
10456 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10458 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
10459 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10460 mac, "mac_addr#mac_ignr");
10461 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
10462 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
10464 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
10465 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10466 ethertype, "ethertype");
10467 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
10468 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10469 ethertype_value, UINT16);
10470 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
10471 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10473 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
10474 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10476 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
10477 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10481 cmd_ethertype_filter_parsed(void *parsed_result,
10482 __attribute__((unused)) struct cmdline *cl,
10483 __attribute__((unused)) void *data)
10485 struct cmd_ethertype_filter_result *res = parsed_result;
10486 struct rte_eth_ethertype_filter filter;
10489 ret = rte_eth_dev_filter_supported(res->port_id,
10490 RTE_ETH_FILTER_ETHERTYPE);
10492 printf("ethertype filter is not supported on port %u.\n",
10497 memset(&filter, 0, sizeof(filter));
10498 if (!strcmp(res->mac, "mac_addr")) {
10499 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
10500 rte_memcpy(&filter.mac_addr, &res->mac_addr,
10501 sizeof(struct ether_addr));
10503 if (!strcmp(res->drop, "drop"))
10504 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
10505 filter.ether_type = res->ethertype_value;
10506 filter.queue = res->queue_id;
10508 if (!strcmp(res->ops, "add"))
10509 ret = rte_eth_dev_filter_ctrl(res->port_id,
10510 RTE_ETH_FILTER_ETHERTYPE,
10511 RTE_ETH_FILTER_ADD,
10514 ret = rte_eth_dev_filter_ctrl(res->port_id,
10515 RTE_ETH_FILTER_ETHERTYPE,
10516 RTE_ETH_FILTER_DELETE,
10519 printf("ethertype filter programming error: (%s)\n",
10523 cmdline_parse_inst_t cmd_ethertype_filter = {
10524 .f = cmd_ethertype_filter_parsed,
10526 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
10527 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
10528 "Add or delete an ethertype filter entry",
10530 (void *)&cmd_ethertype_filter_filter,
10531 (void *)&cmd_ethertype_filter_port_id,
10532 (void *)&cmd_ethertype_filter_ops,
10533 (void *)&cmd_ethertype_filter_mac,
10534 (void *)&cmd_ethertype_filter_mac_addr,
10535 (void *)&cmd_ethertype_filter_ethertype,
10536 (void *)&cmd_ethertype_filter_ethertype_value,
10537 (void *)&cmd_ethertype_filter_drop,
10538 (void *)&cmd_ethertype_filter_queue,
10539 (void *)&cmd_ethertype_filter_queue_id,
10544 /* *** deal with flow director filter *** */
10545 struct cmd_flow_director_result {
10546 cmdline_fixed_string_t flow_director_filter;
10548 cmdline_fixed_string_t mode;
10549 cmdline_fixed_string_t mode_value;
10550 cmdline_fixed_string_t ops;
10551 cmdline_fixed_string_t flow;
10552 cmdline_fixed_string_t flow_type;
10553 cmdline_fixed_string_t ether;
10554 uint16_t ether_type;
10555 cmdline_fixed_string_t src;
10556 cmdline_ipaddr_t ip_src;
10558 cmdline_fixed_string_t dst;
10559 cmdline_ipaddr_t ip_dst;
10561 cmdline_fixed_string_t verify_tag;
10562 uint32_t verify_tag_value;
10563 cmdline_fixed_string_t tos;
10565 cmdline_fixed_string_t proto;
10566 uint8_t proto_value;
10567 cmdline_fixed_string_t ttl;
10569 cmdline_fixed_string_t vlan;
10570 uint16_t vlan_value;
10571 cmdline_fixed_string_t flexbytes;
10572 cmdline_fixed_string_t flexbytes_value;
10573 cmdline_fixed_string_t pf_vf;
10574 cmdline_fixed_string_t drop;
10575 cmdline_fixed_string_t queue;
10577 cmdline_fixed_string_t fd_id;
10578 uint32_t fd_id_value;
10579 cmdline_fixed_string_t mac;
10580 struct ether_addr mac_addr;
10581 cmdline_fixed_string_t tunnel;
10582 cmdline_fixed_string_t tunnel_type;
10583 cmdline_fixed_string_t tunnel_id;
10584 uint32_t tunnel_id_value;
10585 cmdline_fixed_string_t packet;
10590 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
10593 const char *p, *p0 = q_arg;
10595 unsigned long int_fld;
10596 char *str_fld[max_num];
10601 p = strchr(p0, '(');
10605 p0 = strchr(p, ')');
10610 if (size >= sizeof(s))
10613 snprintf(s, sizeof(s), "%.*s", size, p);
10614 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10615 if (ret < 0 || ret > max_num)
10617 for (i = 0; i < ret; i++) {
10619 int_fld = strtoul(str_fld[i], &end, 0);
10620 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
10622 flexbytes[i] = (uint8_t)int_fld;
10628 str2flowtype(char *string)
10631 static const struct {
10634 } flowtype_str[] = {
10635 {"raw", RTE_ETH_FLOW_RAW},
10636 {"ipv4", RTE_ETH_FLOW_IPV4},
10637 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10638 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10639 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10640 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10641 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10642 {"ipv6", RTE_ETH_FLOW_IPV6},
10643 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10644 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10645 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10646 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10647 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10648 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10651 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
10652 if (!strcmp(flowtype_str[i].str, string))
10653 return flowtype_str[i].type;
10656 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
10657 return (uint16_t)atoi(string);
10659 return RTE_ETH_FLOW_UNKNOWN;
10662 static enum rte_eth_fdir_tunnel_type
10663 str2fdir_tunneltype(char *string)
10667 static const struct {
10669 enum rte_eth_fdir_tunnel_type type;
10670 } tunneltype_str[] = {
10671 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
10672 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
10675 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
10676 if (!strcmp(tunneltype_str[i].str, string))
10677 return tunneltype_str[i].type;
10679 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
10682 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10684 if ((ip_addr).family == AF_INET) \
10685 (ip) = (ip_addr).addr.ipv4.s_addr; \
10687 printf("invalid parameter.\n"); \
10692 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10694 if ((ip_addr).family == AF_INET6) \
10695 rte_memcpy(&(ip), \
10696 &((ip_addr).addr.ipv6), \
10697 sizeof(struct in6_addr)); \
10699 printf("invalid parameter.\n"); \
10705 cmd_flow_director_filter_parsed(void *parsed_result,
10706 __attribute__((unused)) struct cmdline *cl,
10707 __attribute__((unused)) void *data)
10709 struct cmd_flow_director_result *res = parsed_result;
10710 struct rte_eth_fdir_filter entry;
10711 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
10713 unsigned long vf_id;
10716 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
10718 printf("flow director is not supported on port %u.\n",
10722 memset(flexbytes, 0, sizeof(flexbytes));
10723 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
10725 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10726 if (strcmp(res->mode_value, "MAC-VLAN")) {
10727 printf("Please set mode to MAC-VLAN.\n");
10730 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10731 if (strcmp(res->mode_value, "Tunnel")) {
10732 printf("Please set mode to Tunnel.\n");
10736 if (!strcmp(res->mode_value, "raw")) {
10737 #ifdef RTE_LIBRTE_I40E_PMD
10738 struct rte_pmd_i40e_flow_type_mapping
10739 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
10740 struct rte_pmd_i40e_pkt_template_conf conf;
10741 uint16_t flow_type = str2flowtype(res->flow_type);
10742 uint16_t i, port = res->port_id;
10745 memset(&conf, 0, sizeof(conf));
10747 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
10748 printf("Invalid flow type specified.\n");
10751 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
10755 if (mapping[flow_type].pctype == 0ULL) {
10756 printf("Invalid flow type specified.\n");
10759 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
10760 if (mapping[flow_type].pctype & (1ULL << i)) {
10761 conf.input.pctype = i;
10766 conf.input.packet = open_file(res->filepath,
10767 &conf.input.length);
10768 if (!conf.input.packet)
10770 if (!strcmp(res->drop, "drop"))
10771 conf.action.behavior =
10772 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
10774 conf.action.behavior =
10775 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
10776 conf.action.report_status =
10777 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
10778 conf.action.rx_queue = res->queue_id;
10779 conf.soft_id = res->fd_id_value;
10780 add = strcmp(res->ops, "del") ? 1 : 0;
10781 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
10785 printf("flow director config error: (%s)\n",
10787 close_file(conf.input.packet);
10790 } else if (strcmp(res->mode_value, "IP")) {
10791 printf("Please set mode to IP or raw.\n");
10794 entry.input.flow_type = str2flowtype(res->flow_type);
10797 ret = parse_flexbytes(res->flexbytes_value,
10799 RTE_ETH_FDIR_MAX_FLEXLEN);
10801 printf("error: Cannot parse flexbytes input.\n");
10805 switch (entry.input.flow_type) {
10806 case RTE_ETH_FLOW_FRAG_IPV4:
10807 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
10808 entry.input.flow.ip4_flow.proto = res->proto_value;
10810 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
10811 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
10812 IPV4_ADDR_TO_UINT(res->ip_dst,
10813 entry.input.flow.ip4_flow.dst_ip);
10814 IPV4_ADDR_TO_UINT(res->ip_src,
10815 entry.input.flow.ip4_flow.src_ip);
10816 entry.input.flow.ip4_flow.tos = res->tos_value;
10817 entry.input.flow.ip4_flow.ttl = res->ttl_value;
10818 /* need convert to big endian. */
10819 entry.input.flow.udp4_flow.dst_port =
10820 rte_cpu_to_be_16(res->port_dst);
10821 entry.input.flow.udp4_flow.src_port =
10822 rte_cpu_to_be_16(res->port_src);
10824 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
10825 IPV4_ADDR_TO_UINT(res->ip_dst,
10826 entry.input.flow.sctp4_flow.ip.dst_ip);
10827 IPV4_ADDR_TO_UINT(res->ip_src,
10828 entry.input.flow.sctp4_flow.ip.src_ip);
10829 entry.input.flow.ip4_flow.tos = res->tos_value;
10830 entry.input.flow.ip4_flow.ttl = res->ttl_value;
10831 /* need convert to big endian. */
10832 entry.input.flow.sctp4_flow.dst_port =
10833 rte_cpu_to_be_16(res->port_dst);
10834 entry.input.flow.sctp4_flow.src_port =
10835 rte_cpu_to_be_16(res->port_src);
10836 entry.input.flow.sctp4_flow.verify_tag =
10837 rte_cpu_to_be_32(res->verify_tag_value);
10839 case RTE_ETH_FLOW_FRAG_IPV6:
10840 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
10841 entry.input.flow.ipv6_flow.proto = res->proto_value;
10843 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
10844 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
10845 IPV6_ADDR_TO_ARRAY(res->ip_dst,
10846 entry.input.flow.ipv6_flow.dst_ip);
10847 IPV6_ADDR_TO_ARRAY(res->ip_src,
10848 entry.input.flow.ipv6_flow.src_ip);
10849 entry.input.flow.ipv6_flow.tc = res->tos_value;
10850 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
10851 /* need convert to big endian. */
10852 entry.input.flow.udp6_flow.dst_port =
10853 rte_cpu_to_be_16(res->port_dst);
10854 entry.input.flow.udp6_flow.src_port =
10855 rte_cpu_to_be_16(res->port_src);
10857 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
10858 IPV6_ADDR_TO_ARRAY(res->ip_dst,
10859 entry.input.flow.sctp6_flow.ip.dst_ip);
10860 IPV6_ADDR_TO_ARRAY(res->ip_src,
10861 entry.input.flow.sctp6_flow.ip.src_ip);
10862 entry.input.flow.ipv6_flow.tc = res->tos_value;
10863 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
10864 /* need convert to big endian. */
10865 entry.input.flow.sctp6_flow.dst_port =
10866 rte_cpu_to_be_16(res->port_dst);
10867 entry.input.flow.sctp6_flow.src_port =
10868 rte_cpu_to_be_16(res->port_src);
10869 entry.input.flow.sctp6_flow.verify_tag =
10870 rte_cpu_to_be_32(res->verify_tag_value);
10872 case RTE_ETH_FLOW_L2_PAYLOAD:
10873 entry.input.flow.l2_flow.ether_type =
10874 rte_cpu_to_be_16(res->ether_type);
10880 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
10881 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
10883 sizeof(struct ether_addr));
10885 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10886 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
10888 sizeof(struct ether_addr));
10889 entry.input.flow.tunnel_flow.tunnel_type =
10890 str2fdir_tunneltype(res->tunnel_type);
10891 entry.input.flow.tunnel_flow.tunnel_id =
10892 rte_cpu_to_be_32(res->tunnel_id_value);
10895 rte_memcpy(entry.input.flow_ext.flexbytes,
10897 RTE_ETH_FDIR_MAX_FLEXLEN);
10899 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
10901 entry.action.flex_off = 0; /*use 0 by default */
10902 if (!strcmp(res->drop, "drop"))
10903 entry.action.behavior = RTE_ETH_FDIR_REJECT;
10905 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
10907 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
10908 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
10909 if (!strcmp(res->pf_vf, "pf"))
10910 entry.input.flow_ext.is_vf = 0;
10911 else if (!strncmp(res->pf_vf, "vf", 2)) {
10912 struct rte_eth_dev_info dev_info;
10914 memset(&dev_info, 0, sizeof(dev_info));
10915 rte_eth_dev_info_get(res->port_id, &dev_info);
10917 vf_id = strtoul(res->pf_vf + 2, &end, 10);
10918 if (errno != 0 || *end != '\0' ||
10919 vf_id >= dev_info.max_vfs) {
10920 printf("invalid parameter %s.\n", res->pf_vf);
10923 entry.input.flow_ext.is_vf = 1;
10924 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
10926 printf("invalid parameter %s.\n", res->pf_vf);
10931 /* set to report FD ID by default */
10932 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
10933 entry.action.rx_queue = res->queue_id;
10934 entry.soft_id = res->fd_id_value;
10935 if (!strcmp(res->ops, "add"))
10936 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10937 RTE_ETH_FILTER_ADD, &entry);
10938 else if (!strcmp(res->ops, "del"))
10939 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10940 RTE_ETH_FILTER_DELETE, &entry);
10942 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10943 RTE_ETH_FILTER_UPDATE, &entry);
10945 printf("flow director programming error: (%s)\n",
10949 cmdline_parse_token_string_t cmd_flow_director_filter =
10950 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10951 flow_director_filter, "flow_director_filter");
10952 cmdline_parse_token_num_t cmd_flow_director_port_id =
10953 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10955 cmdline_parse_token_string_t cmd_flow_director_ops =
10956 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10957 ops, "add#del#update");
10958 cmdline_parse_token_string_t cmd_flow_director_flow =
10959 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10961 cmdline_parse_token_string_t cmd_flow_director_flow_type =
10962 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10964 cmdline_parse_token_string_t cmd_flow_director_ether =
10965 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10967 cmdline_parse_token_num_t cmd_flow_director_ether_type =
10968 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10969 ether_type, UINT16);
10970 cmdline_parse_token_string_t cmd_flow_director_src =
10971 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10973 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
10974 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10976 cmdline_parse_token_num_t cmd_flow_director_port_src =
10977 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10979 cmdline_parse_token_string_t cmd_flow_director_dst =
10980 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10982 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
10983 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10985 cmdline_parse_token_num_t cmd_flow_director_port_dst =
10986 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10988 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
10989 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10990 verify_tag, "verify_tag");
10991 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
10992 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10993 verify_tag_value, UINT32);
10994 cmdline_parse_token_string_t cmd_flow_director_tos =
10995 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10997 cmdline_parse_token_num_t cmd_flow_director_tos_value =
10998 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11000 cmdline_parse_token_string_t cmd_flow_director_proto =
11001 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11003 cmdline_parse_token_num_t cmd_flow_director_proto_value =
11004 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11005 proto_value, UINT8);
11006 cmdline_parse_token_string_t cmd_flow_director_ttl =
11007 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11009 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
11010 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11012 cmdline_parse_token_string_t cmd_flow_director_vlan =
11013 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11015 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
11016 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11017 vlan_value, UINT16);
11018 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
11019 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11020 flexbytes, "flexbytes");
11021 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
11022 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11023 flexbytes_value, NULL);
11024 cmdline_parse_token_string_t cmd_flow_director_drop =
11025 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11027 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
11028 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11030 cmdline_parse_token_string_t cmd_flow_director_queue =
11031 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11033 cmdline_parse_token_num_t cmd_flow_director_queue_id =
11034 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11036 cmdline_parse_token_string_t cmd_flow_director_fd_id =
11037 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11039 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
11040 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11041 fd_id_value, UINT32);
11043 cmdline_parse_token_string_t cmd_flow_director_mode =
11044 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11046 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
11047 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11049 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
11050 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11051 mode_value, "MAC-VLAN");
11052 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
11053 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11054 mode_value, "Tunnel");
11055 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
11056 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11057 mode_value, "raw");
11058 cmdline_parse_token_string_t cmd_flow_director_mac =
11059 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11061 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
11062 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
11064 cmdline_parse_token_string_t cmd_flow_director_tunnel =
11065 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11067 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
11068 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11069 tunnel_type, "NVGRE#VxLAN");
11070 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
11071 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11072 tunnel_id, "tunnel-id");
11073 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
11074 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11075 tunnel_id_value, UINT32);
11076 cmdline_parse_token_string_t cmd_flow_director_packet =
11077 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11079 cmdline_parse_token_string_t cmd_flow_director_filepath =
11080 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11083 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
11084 .f = cmd_flow_director_filter_parsed,
11086 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
11087 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
11088 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
11089 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
11090 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
11091 "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> "
11092 "fd_id <fd_id_value>: "
11093 "Add or delete an ip flow director entry on NIC",
11095 (void *)&cmd_flow_director_filter,
11096 (void *)&cmd_flow_director_port_id,
11097 (void *)&cmd_flow_director_mode,
11098 (void *)&cmd_flow_director_mode_ip,
11099 (void *)&cmd_flow_director_ops,
11100 (void *)&cmd_flow_director_flow,
11101 (void *)&cmd_flow_director_flow_type,
11102 (void *)&cmd_flow_director_src,
11103 (void *)&cmd_flow_director_ip_src,
11104 (void *)&cmd_flow_director_dst,
11105 (void *)&cmd_flow_director_ip_dst,
11106 (void *)&cmd_flow_director_tos,
11107 (void *)&cmd_flow_director_tos_value,
11108 (void *)&cmd_flow_director_proto,
11109 (void *)&cmd_flow_director_proto_value,
11110 (void *)&cmd_flow_director_ttl,
11111 (void *)&cmd_flow_director_ttl_value,
11112 (void *)&cmd_flow_director_vlan,
11113 (void *)&cmd_flow_director_vlan_value,
11114 (void *)&cmd_flow_director_flexbytes,
11115 (void *)&cmd_flow_director_flexbytes_value,
11116 (void *)&cmd_flow_director_drop,
11117 (void *)&cmd_flow_director_pf_vf,
11118 (void *)&cmd_flow_director_queue,
11119 (void *)&cmd_flow_director_queue_id,
11120 (void *)&cmd_flow_director_fd_id,
11121 (void *)&cmd_flow_director_fd_id_value,
11126 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
11127 .f = cmd_flow_director_filter_parsed,
11129 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
11130 "director entry on NIC",
11132 (void *)&cmd_flow_director_filter,
11133 (void *)&cmd_flow_director_port_id,
11134 (void *)&cmd_flow_director_mode,
11135 (void *)&cmd_flow_director_mode_ip,
11136 (void *)&cmd_flow_director_ops,
11137 (void *)&cmd_flow_director_flow,
11138 (void *)&cmd_flow_director_flow_type,
11139 (void *)&cmd_flow_director_src,
11140 (void *)&cmd_flow_director_ip_src,
11141 (void *)&cmd_flow_director_port_src,
11142 (void *)&cmd_flow_director_dst,
11143 (void *)&cmd_flow_director_ip_dst,
11144 (void *)&cmd_flow_director_port_dst,
11145 (void *)&cmd_flow_director_tos,
11146 (void *)&cmd_flow_director_tos_value,
11147 (void *)&cmd_flow_director_ttl,
11148 (void *)&cmd_flow_director_ttl_value,
11149 (void *)&cmd_flow_director_vlan,
11150 (void *)&cmd_flow_director_vlan_value,
11151 (void *)&cmd_flow_director_flexbytes,
11152 (void *)&cmd_flow_director_flexbytes_value,
11153 (void *)&cmd_flow_director_drop,
11154 (void *)&cmd_flow_director_pf_vf,
11155 (void *)&cmd_flow_director_queue,
11156 (void *)&cmd_flow_director_queue_id,
11157 (void *)&cmd_flow_director_fd_id,
11158 (void *)&cmd_flow_director_fd_id_value,
11163 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
11164 .f = cmd_flow_director_filter_parsed,
11166 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
11167 "director entry on NIC",
11169 (void *)&cmd_flow_director_filter,
11170 (void *)&cmd_flow_director_port_id,
11171 (void *)&cmd_flow_director_mode,
11172 (void *)&cmd_flow_director_mode_ip,
11173 (void *)&cmd_flow_director_ops,
11174 (void *)&cmd_flow_director_flow,
11175 (void *)&cmd_flow_director_flow_type,
11176 (void *)&cmd_flow_director_src,
11177 (void *)&cmd_flow_director_ip_src,
11178 (void *)&cmd_flow_director_port_src,
11179 (void *)&cmd_flow_director_dst,
11180 (void *)&cmd_flow_director_ip_dst,
11181 (void *)&cmd_flow_director_port_dst,
11182 (void *)&cmd_flow_director_verify_tag,
11183 (void *)&cmd_flow_director_verify_tag_value,
11184 (void *)&cmd_flow_director_tos,
11185 (void *)&cmd_flow_director_tos_value,
11186 (void *)&cmd_flow_director_ttl,
11187 (void *)&cmd_flow_director_ttl_value,
11188 (void *)&cmd_flow_director_vlan,
11189 (void *)&cmd_flow_director_vlan_value,
11190 (void *)&cmd_flow_director_flexbytes,
11191 (void *)&cmd_flow_director_flexbytes_value,
11192 (void *)&cmd_flow_director_drop,
11193 (void *)&cmd_flow_director_pf_vf,
11194 (void *)&cmd_flow_director_queue,
11195 (void *)&cmd_flow_director_queue_id,
11196 (void *)&cmd_flow_director_fd_id,
11197 (void *)&cmd_flow_director_fd_id_value,
11202 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
11203 .f = cmd_flow_director_filter_parsed,
11205 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
11206 "director entry on NIC",
11208 (void *)&cmd_flow_director_filter,
11209 (void *)&cmd_flow_director_port_id,
11210 (void *)&cmd_flow_director_mode,
11211 (void *)&cmd_flow_director_mode_ip,
11212 (void *)&cmd_flow_director_ops,
11213 (void *)&cmd_flow_director_flow,
11214 (void *)&cmd_flow_director_flow_type,
11215 (void *)&cmd_flow_director_ether,
11216 (void *)&cmd_flow_director_ether_type,
11217 (void *)&cmd_flow_director_flexbytes,
11218 (void *)&cmd_flow_director_flexbytes_value,
11219 (void *)&cmd_flow_director_drop,
11220 (void *)&cmd_flow_director_pf_vf,
11221 (void *)&cmd_flow_director_queue,
11222 (void *)&cmd_flow_director_queue_id,
11223 (void *)&cmd_flow_director_fd_id,
11224 (void *)&cmd_flow_director_fd_id_value,
11229 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
11230 .f = cmd_flow_director_filter_parsed,
11232 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
11233 "director entry on NIC",
11235 (void *)&cmd_flow_director_filter,
11236 (void *)&cmd_flow_director_port_id,
11237 (void *)&cmd_flow_director_mode,
11238 (void *)&cmd_flow_director_mode_mac_vlan,
11239 (void *)&cmd_flow_director_ops,
11240 (void *)&cmd_flow_director_mac,
11241 (void *)&cmd_flow_director_mac_addr,
11242 (void *)&cmd_flow_director_vlan,
11243 (void *)&cmd_flow_director_vlan_value,
11244 (void *)&cmd_flow_director_flexbytes,
11245 (void *)&cmd_flow_director_flexbytes_value,
11246 (void *)&cmd_flow_director_drop,
11247 (void *)&cmd_flow_director_queue,
11248 (void *)&cmd_flow_director_queue_id,
11249 (void *)&cmd_flow_director_fd_id,
11250 (void *)&cmd_flow_director_fd_id_value,
11255 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
11256 .f = cmd_flow_director_filter_parsed,
11258 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
11259 "director entry on NIC",
11261 (void *)&cmd_flow_director_filter,
11262 (void *)&cmd_flow_director_port_id,
11263 (void *)&cmd_flow_director_mode,
11264 (void *)&cmd_flow_director_mode_tunnel,
11265 (void *)&cmd_flow_director_ops,
11266 (void *)&cmd_flow_director_mac,
11267 (void *)&cmd_flow_director_mac_addr,
11268 (void *)&cmd_flow_director_vlan,
11269 (void *)&cmd_flow_director_vlan_value,
11270 (void *)&cmd_flow_director_tunnel,
11271 (void *)&cmd_flow_director_tunnel_type,
11272 (void *)&cmd_flow_director_tunnel_id,
11273 (void *)&cmd_flow_director_tunnel_id_value,
11274 (void *)&cmd_flow_director_flexbytes,
11275 (void *)&cmd_flow_director_flexbytes_value,
11276 (void *)&cmd_flow_director_drop,
11277 (void *)&cmd_flow_director_queue,
11278 (void *)&cmd_flow_director_queue_id,
11279 (void *)&cmd_flow_director_fd_id,
11280 (void *)&cmd_flow_director_fd_id_value,
11285 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
11286 .f = cmd_flow_director_filter_parsed,
11288 .help_str = "flow_director_filter ... : Add or delete a raw flow "
11289 "director entry on NIC",
11291 (void *)&cmd_flow_director_filter,
11292 (void *)&cmd_flow_director_port_id,
11293 (void *)&cmd_flow_director_mode,
11294 (void *)&cmd_flow_director_mode_raw,
11295 (void *)&cmd_flow_director_ops,
11296 (void *)&cmd_flow_director_flow,
11297 (void *)&cmd_flow_director_flow_type,
11298 (void *)&cmd_flow_director_drop,
11299 (void *)&cmd_flow_director_queue,
11300 (void *)&cmd_flow_director_queue_id,
11301 (void *)&cmd_flow_director_fd_id,
11302 (void *)&cmd_flow_director_fd_id_value,
11303 (void *)&cmd_flow_director_packet,
11304 (void *)&cmd_flow_director_filepath,
11309 struct cmd_flush_flow_director_result {
11310 cmdline_fixed_string_t flush_flow_director;
11314 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
11315 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
11316 flush_flow_director, "flush_flow_director");
11317 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
11318 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
11322 cmd_flush_flow_director_parsed(void *parsed_result,
11323 __attribute__((unused)) struct cmdline *cl,
11324 __attribute__((unused)) void *data)
11326 struct cmd_flow_director_result *res = parsed_result;
11329 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
11331 printf("flow director is not supported on port %u.\n",
11336 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11337 RTE_ETH_FILTER_FLUSH, NULL);
11339 printf("flow director table flushing error: (%s)\n",
11343 cmdline_parse_inst_t cmd_flush_flow_director = {
11344 .f = cmd_flush_flow_director_parsed,
11346 .help_str = "flush_flow_director <port_id>: "
11347 "Flush all flow director entries of a device on NIC",
11349 (void *)&cmd_flush_flow_director_flush,
11350 (void *)&cmd_flush_flow_director_port_id,
11355 /* *** deal with flow director mask *** */
11356 struct cmd_flow_director_mask_result {
11357 cmdline_fixed_string_t flow_director_mask;
11359 cmdline_fixed_string_t mode;
11360 cmdline_fixed_string_t mode_value;
11361 cmdline_fixed_string_t vlan;
11362 uint16_t vlan_mask;
11363 cmdline_fixed_string_t src_mask;
11364 cmdline_ipaddr_t ipv4_src;
11365 cmdline_ipaddr_t ipv6_src;
11367 cmdline_fixed_string_t dst_mask;
11368 cmdline_ipaddr_t ipv4_dst;
11369 cmdline_ipaddr_t ipv6_dst;
11371 cmdline_fixed_string_t mac;
11372 uint8_t mac_addr_byte_mask;
11373 cmdline_fixed_string_t tunnel_id;
11374 uint32_t tunnel_id_mask;
11375 cmdline_fixed_string_t tunnel_type;
11376 uint8_t tunnel_type_mask;
11380 cmd_flow_director_mask_parsed(void *parsed_result,
11381 __attribute__((unused)) struct cmdline *cl,
11382 __attribute__((unused)) void *data)
11384 struct cmd_flow_director_mask_result *res = parsed_result;
11385 struct rte_eth_fdir_masks *mask;
11386 struct rte_port *port;
11388 port = &ports[res->port_id];
11389 /** Check if the port is not started **/
11390 if (port->port_status != RTE_PORT_STOPPED) {
11391 printf("Please stop port %d first\n", res->port_id);
11395 mask = &port->dev_conf.fdir_conf.mask;
11397 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
11398 if (strcmp(res->mode_value, "MAC-VLAN")) {
11399 printf("Please set mode to MAC-VLAN.\n");
11403 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11404 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11405 if (strcmp(res->mode_value, "Tunnel")) {
11406 printf("Please set mode to Tunnel.\n");
11410 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11411 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
11412 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
11413 mask->tunnel_type_mask = res->tunnel_type_mask;
11415 if (strcmp(res->mode_value, "IP")) {
11416 printf("Please set mode to IP.\n");
11420 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11421 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
11422 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
11423 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
11424 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
11425 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
11426 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
11429 cmd_reconfig_device_queue(res->port_id, 1, 1);
11432 cmdline_parse_token_string_t cmd_flow_director_mask =
11433 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11434 flow_director_mask, "flow_director_mask");
11435 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
11436 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11438 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
11439 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11441 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
11442 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11443 vlan_mask, UINT16);
11444 cmdline_parse_token_string_t cmd_flow_director_mask_src =
11445 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11446 src_mask, "src_mask");
11447 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
11448 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11450 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
11451 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11453 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
11454 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11456 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
11457 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11458 dst_mask, "dst_mask");
11459 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
11460 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11462 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
11463 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11465 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
11466 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11469 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
11470 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11472 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
11473 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11475 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
11476 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11477 mode_value, "MAC-VLAN");
11478 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
11479 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11480 mode_value, "Tunnel");
11481 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
11482 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11484 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
11485 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11486 mac_addr_byte_mask, UINT8);
11487 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
11488 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11489 tunnel_type, "tunnel-type");
11490 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
11491 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11492 tunnel_type_mask, UINT8);
11493 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
11494 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11495 tunnel_id, "tunnel-id");
11496 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
11497 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11498 tunnel_id_mask, UINT32);
11500 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
11501 .f = cmd_flow_director_mask_parsed,
11503 .help_str = "flow_director_mask ... : "
11504 "Set IP mode flow director's mask on NIC",
11506 (void *)&cmd_flow_director_mask,
11507 (void *)&cmd_flow_director_mask_port_id,
11508 (void *)&cmd_flow_director_mask_mode,
11509 (void *)&cmd_flow_director_mask_mode_ip,
11510 (void *)&cmd_flow_director_mask_vlan,
11511 (void *)&cmd_flow_director_mask_vlan_value,
11512 (void *)&cmd_flow_director_mask_src,
11513 (void *)&cmd_flow_director_mask_ipv4_src,
11514 (void *)&cmd_flow_director_mask_ipv6_src,
11515 (void *)&cmd_flow_director_mask_port_src,
11516 (void *)&cmd_flow_director_mask_dst,
11517 (void *)&cmd_flow_director_mask_ipv4_dst,
11518 (void *)&cmd_flow_director_mask_ipv6_dst,
11519 (void *)&cmd_flow_director_mask_port_dst,
11524 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
11525 .f = cmd_flow_director_mask_parsed,
11527 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
11528 "flow director's mask on NIC",
11530 (void *)&cmd_flow_director_mask,
11531 (void *)&cmd_flow_director_mask_port_id,
11532 (void *)&cmd_flow_director_mask_mode,
11533 (void *)&cmd_flow_director_mask_mode_mac_vlan,
11534 (void *)&cmd_flow_director_mask_vlan,
11535 (void *)&cmd_flow_director_mask_vlan_value,
11540 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
11541 .f = cmd_flow_director_mask_parsed,
11543 .help_str = "flow_director_mask ... : Set tunnel mode "
11544 "flow director's mask on NIC",
11546 (void *)&cmd_flow_director_mask,
11547 (void *)&cmd_flow_director_mask_port_id,
11548 (void *)&cmd_flow_director_mask_mode,
11549 (void *)&cmd_flow_director_mask_mode_tunnel,
11550 (void *)&cmd_flow_director_mask_vlan,
11551 (void *)&cmd_flow_director_mask_vlan_value,
11552 (void *)&cmd_flow_director_mask_mac,
11553 (void *)&cmd_flow_director_mask_mac_value,
11554 (void *)&cmd_flow_director_mask_tunnel_type,
11555 (void *)&cmd_flow_director_mask_tunnel_type_value,
11556 (void *)&cmd_flow_director_mask_tunnel_id,
11557 (void *)&cmd_flow_director_mask_tunnel_id_value,
11562 /* *** deal with flow director mask on flexible payload *** */
11563 struct cmd_flow_director_flex_mask_result {
11564 cmdline_fixed_string_t flow_director_flexmask;
11566 cmdline_fixed_string_t flow;
11567 cmdline_fixed_string_t flow_type;
11568 cmdline_fixed_string_t mask;
11572 cmd_flow_director_flex_mask_parsed(void *parsed_result,
11573 __attribute__((unused)) struct cmdline *cl,
11574 __attribute__((unused)) void *data)
11576 struct cmd_flow_director_flex_mask_result *res = parsed_result;
11577 struct rte_eth_fdir_info fdir_info;
11578 struct rte_eth_fdir_flex_mask flex_mask;
11579 struct rte_port *port;
11580 uint64_t flow_type_mask;
11584 port = &ports[res->port_id];
11585 /** Check if the port is not started **/
11586 if (port->port_status != RTE_PORT_STOPPED) {
11587 printf("Please stop port %d first\n", res->port_id);
11591 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
11592 ret = parse_flexbytes(res->mask,
11594 RTE_ETH_FDIR_MAX_FLEXLEN);
11596 printf("error: Cannot parse mask input.\n");
11600 memset(&fdir_info, 0, sizeof(fdir_info));
11601 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11602 RTE_ETH_FILTER_INFO, &fdir_info);
11604 printf("Cannot get FDir filter info\n");
11608 if (!strcmp(res->flow_type, "none")) {
11609 /* means don't specify the flow type */
11610 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
11611 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
11612 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
11613 0, sizeof(struct rte_eth_fdir_flex_mask));
11614 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
11615 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
11617 sizeof(struct rte_eth_fdir_flex_mask));
11618 cmd_reconfig_device_queue(res->port_id, 1, 1);
11621 flow_type_mask = fdir_info.flow_types_mask[0];
11622 if (!strcmp(res->flow_type, "all")) {
11623 if (!flow_type_mask) {
11624 printf("No flow type supported\n");
11627 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
11628 if (flow_type_mask & (1ULL << i)) {
11629 flex_mask.flow_type = i;
11630 fdir_set_flex_mask(res->port_id, &flex_mask);
11633 cmd_reconfig_device_queue(res->port_id, 1, 1);
11636 flex_mask.flow_type = str2flowtype(res->flow_type);
11637 if (!(flow_type_mask & (1ULL << flex_mask.flow_type))) {
11638 printf("Flow type %s not supported on port %d\n",
11639 res->flow_type, res->port_id);
11642 fdir_set_flex_mask(res->port_id, &flex_mask);
11643 cmd_reconfig_device_queue(res->port_id, 1, 1);
11646 cmdline_parse_token_string_t cmd_flow_director_flexmask =
11647 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11648 flow_director_flexmask,
11649 "flow_director_flex_mask");
11650 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
11651 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11653 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
11654 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11656 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
11657 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11658 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
11659 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
11660 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
11661 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11664 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
11665 .f = cmd_flow_director_flex_mask_parsed,
11667 .help_str = "flow_director_flex_mask ... : "
11668 "Set flow director's flex mask on NIC",
11670 (void *)&cmd_flow_director_flexmask,
11671 (void *)&cmd_flow_director_flexmask_port_id,
11672 (void *)&cmd_flow_director_flexmask_flow,
11673 (void *)&cmd_flow_director_flexmask_flow_type,
11674 (void *)&cmd_flow_director_flexmask_mask,
11679 /* *** deal with flow director flexible payload configuration *** */
11680 struct cmd_flow_director_flexpayload_result {
11681 cmdline_fixed_string_t flow_director_flexpayload;
11683 cmdline_fixed_string_t payload_layer;
11684 cmdline_fixed_string_t payload_cfg;
11688 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
11691 const char *p, *p0 = q_arg;
11693 unsigned long int_fld;
11694 char *str_fld[max_num];
11699 p = strchr(p0, '(');
11703 p0 = strchr(p, ')');
11708 if (size >= sizeof(s))
11711 snprintf(s, sizeof(s), "%.*s", size, p);
11712 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
11713 if (ret < 0 || ret > max_num)
11715 for (i = 0; i < ret; i++) {
11717 int_fld = strtoul(str_fld[i], &end, 0);
11718 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
11720 offsets[i] = (uint16_t)int_fld;
11726 cmd_flow_director_flxpld_parsed(void *parsed_result,
11727 __attribute__((unused)) struct cmdline *cl,
11728 __attribute__((unused)) void *data)
11730 struct cmd_flow_director_flexpayload_result *res = parsed_result;
11731 struct rte_eth_flex_payload_cfg flex_cfg;
11732 struct rte_port *port;
11735 port = &ports[res->port_id];
11736 /** Check if the port is not started **/
11737 if (port->port_status != RTE_PORT_STOPPED) {
11738 printf("Please stop port %d first\n", res->port_id);
11742 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
11744 if (!strcmp(res->payload_layer, "raw"))
11745 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
11746 else if (!strcmp(res->payload_layer, "l2"))
11747 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
11748 else if (!strcmp(res->payload_layer, "l3"))
11749 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
11750 else if (!strcmp(res->payload_layer, "l4"))
11751 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
11753 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
11754 RTE_ETH_FDIR_MAX_FLEXLEN);
11756 printf("error: Cannot parse flex payload input.\n");
11760 fdir_set_flex_payload(res->port_id, &flex_cfg);
11761 cmd_reconfig_device_queue(res->port_id, 1, 1);
11764 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
11765 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11766 flow_director_flexpayload,
11767 "flow_director_flex_payload");
11768 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
11769 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11771 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
11772 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11773 payload_layer, "raw#l2#l3#l4");
11774 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
11775 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11776 payload_cfg, NULL);
11778 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
11779 .f = cmd_flow_director_flxpld_parsed,
11781 .help_str = "flow_director_flexpayload ... : "
11782 "Set flow director's flex payload on NIC",
11784 (void *)&cmd_flow_director_flexpayload,
11785 (void *)&cmd_flow_director_flexpayload_port_id,
11786 (void *)&cmd_flow_director_flexpayload_payload_layer,
11787 (void *)&cmd_flow_director_flexpayload_payload_cfg,
11792 /* Generic flow interface command. */
11793 extern cmdline_parse_inst_t cmd_flow;
11795 /* *** Classification Filters Control *** */
11796 /* *** Get symmetric hash enable per port *** */
11797 struct cmd_get_sym_hash_ena_per_port_result {
11798 cmdline_fixed_string_t get_sym_hash_ena_per_port;
11803 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
11804 __rte_unused struct cmdline *cl,
11805 __rte_unused void *data)
11807 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
11808 struct rte_eth_hash_filter_info info;
11811 if (rte_eth_dev_filter_supported(res->port_id,
11812 RTE_ETH_FILTER_HASH) < 0) {
11813 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
11818 memset(&info, 0, sizeof(info));
11819 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
11820 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11821 RTE_ETH_FILTER_GET, &info);
11824 printf("Cannot get symmetric hash enable per port "
11825 "on port %u\n", res->port_id);
11829 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
11830 "enabled" : "disabled", res->port_id);
11833 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
11834 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
11835 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
11836 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
11837 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
11840 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
11841 .f = cmd_get_sym_hash_per_port_parsed,
11843 .help_str = "get_sym_hash_ena_per_port <port_id>",
11845 (void *)&cmd_get_sym_hash_ena_per_port_all,
11846 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
11851 /* *** Set symmetric hash enable per port *** */
11852 struct cmd_set_sym_hash_ena_per_port_result {
11853 cmdline_fixed_string_t set_sym_hash_ena_per_port;
11854 cmdline_fixed_string_t enable;
11859 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
11860 __rte_unused struct cmdline *cl,
11861 __rte_unused void *data)
11863 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
11864 struct rte_eth_hash_filter_info info;
11867 if (rte_eth_dev_filter_supported(res->port_id,
11868 RTE_ETH_FILTER_HASH) < 0) {
11869 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
11874 memset(&info, 0, sizeof(info));
11875 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
11876 if (!strcmp(res->enable, "enable"))
11877 info.info.enable = 1;
11878 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11879 RTE_ETH_FILTER_SET, &info);
11881 printf("Cannot set symmetric hash enable per port on "
11882 "port %u\n", res->port_id);
11885 printf("Symmetric hash has been set to %s on port %u\n",
11886 res->enable, res->port_id);
11889 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
11890 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11891 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
11892 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
11893 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11895 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
11896 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11897 enable, "enable#disable");
11899 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
11900 .f = cmd_set_sym_hash_per_port_parsed,
11902 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
11904 (void *)&cmd_set_sym_hash_ena_per_port_all,
11905 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
11906 (void *)&cmd_set_sym_hash_ena_per_port_enable,
11911 /* Get global config of hash function */
11912 struct cmd_get_hash_global_config_result {
11913 cmdline_fixed_string_t get_hash_global_config;
11918 flowtype_to_str(uint16_t ftype)
11924 } ftype_table[] = {
11925 {"ipv4", RTE_ETH_FLOW_IPV4},
11926 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
11927 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
11928 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
11929 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
11930 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
11931 {"ipv6", RTE_ETH_FLOW_IPV6},
11932 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
11933 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
11934 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
11935 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
11936 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
11937 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
11938 {"port", RTE_ETH_FLOW_PORT},
11939 {"vxlan", RTE_ETH_FLOW_VXLAN},
11940 {"geneve", RTE_ETH_FLOW_GENEVE},
11941 {"nvgre", RTE_ETH_FLOW_NVGRE},
11944 for (i = 0; i < RTE_DIM(ftype_table); i++) {
11945 if (ftype_table[i].ftype == ftype)
11946 return ftype_table[i].str;
11953 cmd_get_hash_global_config_parsed(void *parsed_result,
11954 __rte_unused struct cmdline *cl,
11955 __rte_unused void *data)
11957 struct cmd_get_hash_global_config_result *res = parsed_result;
11958 struct rte_eth_hash_filter_info info;
11959 uint32_t idx, offset;
11964 if (rte_eth_dev_filter_supported(res->port_id,
11965 RTE_ETH_FILTER_HASH) < 0) {
11966 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
11971 memset(&info, 0, sizeof(info));
11972 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
11973 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11974 RTE_ETH_FILTER_GET, &info);
11976 printf("Cannot get hash global configurations by port %d\n",
11981 switch (info.info.global_conf.hash_func) {
11982 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
11983 printf("Hash function is Toeplitz\n");
11985 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
11986 printf("Hash function is Simple XOR\n");
11989 printf("Unknown hash function\n");
11993 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
11994 idx = i / UINT64_BIT;
11995 offset = i % UINT64_BIT;
11996 if (!(info.info.global_conf.valid_bit_mask[idx] &
11999 str = flowtype_to_str(i);
12002 printf("Symmetric hash is %s globally for flow type %s "
12004 ((info.info.global_conf.sym_hash_enable_mask[idx] &
12005 (1ULL << offset)) ? "enabled" : "disabled"), str,
12010 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
12011 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
12012 get_hash_global_config, "get_hash_global_config");
12013 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
12014 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
12017 cmdline_parse_inst_t cmd_get_hash_global_config = {
12018 .f = cmd_get_hash_global_config_parsed,
12020 .help_str = "get_hash_global_config <port_id>",
12022 (void *)&cmd_get_hash_global_config_all,
12023 (void *)&cmd_get_hash_global_config_port_id,
12028 /* Set global config of hash function */
12029 struct cmd_set_hash_global_config_result {
12030 cmdline_fixed_string_t set_hash_global_config;
12032 cmdline_fixed_string_t hash_func;
12033 cmdline_fixed_string_t flow_type;
12034 cmdline_fixed_string_t enable;
12038 cmd_set_hash_global_config_parsed(void *parsed_result,
12039 __rte_unused struct cmdline *cl,
12040 __rte_unused void *data)
12042 struct cmd_set_hash_global_config_result *res = parsed_result;
12043 struct rte_eth_hash_filter_info info;
12044 uint32_t ftype, idx, offset;
12047 if (rte_eth_dev_filter_supported(res->port_id,
12048 RTE_ETH_FILTER_HASH) < 0) {
12049 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
12053 memset(&info, 0, sizeof(info));
12054 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
12055 if (!strcmp(res->hash_func, "toeplitz"))
12056 info.info.global_conf.hash_func =
12057 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
12058 else if (!strcmp(res->hash_func, "simple_xor"))
12059 info.info.global_conf.hash_func =
12060 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
12061 else if (!strcmp(res->hash_func, "default"))
12062 info.info.global_conf.hash_func =
12063 RTE_ETH_HASH_FUNCTION_DEFAULT;
12065 ftype = str2flowtype(res->flow_type);
12066 idx = ftype / UINT64_BIT;
12067 offset = ftype % UINT64_BIT;
12068 info.info.global_conf.valid_bit_mask[idx] |= (1ULL << offset);
12069 if (!strcmp(res->enable, "enable"))
12070 info.info.global_conf.sym_hash_enable_mask[idx] |=
12072 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12073 RTE_ETH_FILTER_SET, &info);
12075 printf("Cannot set global hash configurations by port %d\n",
12078 printf("Global hash configurations have been set "
12079 "successfully by port %d\n", res->port_id);
12082 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
12083 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12084 set_hash_global_config, "set_hash_global_config");
12085 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
12086 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
12088 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
12089 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12090 hash_func, "toeplitz#simple_xor#default");
12091 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
12092 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12094 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
12095 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12096 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
12097 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12098 enable, "enable#disable");
12100 cmdline_parse_inst_t cmd_set_hash_global_config = {
12101 .f = cmd_set_hash_global_config_parsed,
12103 .help_str = "set_hash_global_config <port_id> "
12104 "toeplitz|simple_xor|default "
12105 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12106 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
12107 "l2_payload enable|disable",
12109 (void *)&cmd_set_hash_global_config_all,
12110 (void *)&cmd_set_hash_global_config_port_id,
12111 (void *)&cmd_set_hash_global_config_hash_func,
12112 (void *)&cmd_set_hash_global_config_flow_type,
12113 (void *)&cmd_set_hash_global_config_enable,
12118 /* Set hash input set */
12119 struct cmd_set_hash_input_set_result {
12120 cmdline_fixed_string_t set_hash_input_set;
12122 cmdline_fixed_string_t flow_type;
12123 cmdline_fixed_string_t inset_field;
12124 cmdline_fixed_string_t select;
12127 static enum rte_eth_input_set_field
12128 str2inset(char *string)
12132 static const struct {
12134 enum rte_eth_input_set_field inset;
12135 } inset_table[] = {
12136 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
12137 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
12138 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
12139 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
12140 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
12141 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
12142 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
12143 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
12144 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
12145 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
12146 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
12147 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
12148 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
12149 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
12150 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
12151 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
12152 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
12153 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
12154 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
12155 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
12156 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
12157 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
12158 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
12159 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
12160 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
12161 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
12162 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
12163 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
12164 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
12165 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
12166 {"none", RTE_ETH_INPUT_SET_NONE},
12169 for (i = 0; i < RTE_DIM(inset_table); i++) {
12170 if (!strcmp(string, inset_table[i].str))
12171 return inset_table[i].inset;
12174 return RTE_ETH_INPUT_SET_UNKNOWN;
12178 cmd_set_hash_input_set_parsed(void *parsed_result,
12179 __rte_unused struct cmdline *cl,
12180 __rte_unused void *data)
12182 struct cmd_set_hash_input_set_result *res = parsed_result;
12183 struct rte_eth_hash_filter_info info;
12185 memset(&info, 0, sizeof(info));
12186 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
12187 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12188 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12189 info.info.input_set_conf.inset_size = 1;
12190 if (!strcmp(res->select, "select"))
12191 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12192 else if (!strcmp(res->select, "add"))
12193 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12194 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12195 RTE_ETH_FILTER_SET, &info);
12198 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
12199 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12200 set_hash_input_set, "set_hash_input_set");
12201 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
12202 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
12204 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
12205 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12207 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
12208 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12210 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12211 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
12212 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
12213 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
12214 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
12216 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
12217 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12218 select, "select#add");
12220 cmdline_parse_inst_t cmd_set_hash_input_set = {
12221 .f = cmd_set_hash_input_set_parsed,
12223 .help_str = "set_hash_input_set <port_id> "
12224 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12225 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
12226 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
12227 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
12228 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
12229 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
12230 "fld-7th|fld-8th|none select|add",
12232 (void *)&cmd_set_hash_input_set_cmd,
12233 (void *)&cmd_set_hash_input_set_port_id,
12234 (void *)&cmd_set_hash_input_set_flow_type,
12235 (void *)&cmd_set_hash_input_set_field,
12236 (void *)&cmd_set_hash_input_set_select,
12241 /* Set flow director input set */
12242 struct cmd_set_fdir_input_set_result {
12243 cmdline_fixed_string_t set_fdir_input_set;
12245 cmdline_fixed_string_t flow_type;
12246 cmdline_fixed_string_t inset_field;
12247 cmdline_fixed_string_t select;
12251 cmd_set_fdir_input_set_parsed(void *parsed_result,
12252 __rte_unused struct cmdline *cl,
12253 __rte_unused void *data)
12255 struct cmd_set_fdir_input_set_result *res = parsed_result;
12256 struct rte_eth_fdir_filter_info info;
12258 memset(&info, 0, sizeof(info));
12259 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
12260 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12261 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12262 info.info.input_set_conf.inset_size = 1;
12263 if (!strcmp(res->select, "select"))
12264 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12265 else if (!strcmp(res->select, "add"))
12266 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12267 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
12268 RTE_ETH_FILTER_SET, &info);
12271 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
12272 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12273 set_fdir_input_set, "set_fdir_input_set");
12274 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
12275 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
12277 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
12278 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12280 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
12281 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12282 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
12283 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12285 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12286 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
12287 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
12288 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
12289 "sctp-veri-tag#none");
12290 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
12291 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12292 select, "select#add");
12294 cmdline_parse_inst_t cmd_set_fdir_input_set = {
12295 .f = cmd_set_fdir_input_set_parsed,
12297 .help_str = "set_fdir_input_set <port_id> "
12298 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12299 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
12300 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
12301 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
12302 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
12303 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
12304 "sctp-veri-tag|none select|add",
12306 (void *)&cmd_set_fdir_input_set_cmd,
12307 (void *)&cmd_set_fdir_input_set_port_id,
12308 (void *)&cmd_set_fdir_input_set_flow_type,
12309 (void *)&cmd_set_fdir_input_set_field,
12310 (void *)&cmd_set_fdir_input_set_select,
12315 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
12316 struct cmd_mcast_addr_result {
12317 cmdline_fixed_string_t mcast_addr_cmd;
12318 cmdline_fixed_string_t what;
12320 struct ether_addr mc_addr;
12323 static void cmd_mcast_addr_parsed(void *parsed_result,
12324 __attribute__((unused)) struct cmdline *cl,
12325 __attribute__((unused)) void *data)
12327 struct cmd_mcast_addr_result *res = parsed_result;
12329 if (!is_multicast_ether_addr(&res->mc_addr)) {
12330 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
12331 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
12332 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
12333 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
12336 if (strcmp(res->what, "add") == 0)
12337 mcast_addr_add(res->port_num, &res->mc_addr);
12339 mcast_addr_remove(res->port_num, &res->mc_addr);
12342 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
12343 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
12344 mcast_addr_cmd, "mcast_addr");
12345 cmdline_parse_token_string_t cmd_mcast_addr_what =
12346 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
12348 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
12349 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
12350 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
12351 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
12353 cmdline_parse_inst_t cmd_mcast_addr = {
12354 .f = cmd_mcast_addr_parsed,
12356 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
12357 "Add/Remove multicast MAC address on port_id",
12359 (void *)&cmd_mcast_addr_cmd,
12360 (void *)&cmd_mcast_addr_what,
12361 (void *)&cmd_mcast_addr_portnum,
12362 (void *)&cmd_mcast_addr_addr,
12367 /* l2 tunnel config
12368 * only support E-tag now.
12371 /* Ether type config */
12372 struct cmd_config_l2_tunnel_eth_type_result {
12373 cmdline_fixed_string_t port;
12374 cmdline_fixed_string_t config;
12375 cmdline_fixed_string_t all;
12377 cmdline_fixed_string_t l2_tunnel;
12378 cmdline_fixed_string_t l2_tunnel_type;
12379 cmdline_fixed_string_t eth_type;
12380 uint16_t eth_type_val;
12383 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
12384 TOKEN_STRING_INITIALIZER
12385 (struct cmd_config_l2_tunnel_eth_type_result,
12387 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
12388 TOKEN_STRING_INITIALIZER
12389 (struct cmd_config_l2_tunnel_eth_type_result,
12391 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
12392 TOKEN_STRING_INITIALIZER
12393 (struct cmd_config_l2_tunnel_eth_type_result,
12395 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
12396 TOKEN_NUM_INITIALIZER
12397 (struct cmd_config_l2_tunnel_eth_type_result,
12399 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
12400 TOKEN_STRING_INITIALIZER
12401 (struct cmd_config_l2_tunnel_eth_type_result,
12402 l2_tunnel, "l2-tunnel");
12403 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
12404 TOKEN_STRING_INITIALIZER
12405 (struct cmd_config_l2_tunnel_eth_type_result,
12406 l2_tunnel_type, "E-tag");
12407 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
12408 TOKEN_STRING_INITIALIZER
12409 (struct cmd_config_l2_tunnel_eth_type_result,
12410 eth_type, "ether-type");
12411 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
12412 TOKEN_NUM_INITIALIZER
12413 (struct cmd_config_l2_tunnel_eth_type_result,
12414 eth_type_val, UINT16);
12416 static enum rte_eth_tunnel_type
12417 str2fdir_l2_tunnel_type(char *string)
12421 static const struct {
12423 enum rte_eth_tunnel_type type;
12424 } l2_tunnel_type_str[] = {
12425 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
12428 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
12429 if (!strcmp(l2_tunnel_type_str[i].str, string))
12430 return l2_tunnel_type_str[i].type;
12432 return RTE_TUNNEL_TYPE_NONE;
12435 /* ether type config for all ports */
12437 cmd_config_l2_tunnel_eth_type_all_parsed
12438 (void *parsed_result,
12439 __attribute__((unused)) struct cmdline *cl,
12440 __attribute__((unused)) void *data)
12442 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
12443 struct rte_eth_l2_tunnel_conf entry;
12446 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12447 entry.ether_type = res->eth_type_val;
12449 RTE_ETH_FOREACH_DEV(pid) {
12450 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
12454 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
12455 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
12457 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
12459 (void *)&cmd_config_l2_tunnel_eth_type_port,
12460 (void *)&cmd_config_l2_tunnel_eth_type_config,
12461 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
12462 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12463 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12464 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12465 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12470 /* ether type config for a specific port */
12472 cmd_config_l2_tunnel_eth_type_specific_parsed(
12473 void *parsed_result,
12474 __attribute__((unused)) struct cmdline *cl,
12475 __attribute__((unused)) void *data)
12477 struct cmd_config_l2_tunnel_eth_type_result *res =
12479 struct rte_eth_l2_tunnel_conf entry;
12481 if (port_id_is_invalid(res->id, ENABLED_WARN))
12484 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12485 entry.ether_type = res->eth_type_val;
12487 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
12490 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
12491 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
12493 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
12495 (void *)&cmd_config_l2_tunnel_eth_type_port,
12496 (void *)&cmd_config_l2_tunnel_eth_type_config,
12497 (void *)&cmd_config_l2_tunnel_eth_type_id,
12498 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12499 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12500 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12501 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12506 /* Enable/disable l2 tunnel */
12507 struct cmd_config_l2_tunnel_en_dis_result {
12508 cmdline_fixed_string_t port;
12509 cmdline_fixed_string_t config;
12510 cmdline_fixed_string_t all;
12512 cmdline_fixed_string_t l2_tunnel;
12513 cmdline_fixed_string_t l2_tunnel_type;
12514 cmdline_fixed_string_t en_dis;
12517 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
12518 TOKEN_STRING_INITIALIZER
12519 (struct cmd_config_l2_tunnel_en_dis_result,
12521 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
12522 TOKEN_STRING_INITIALIZER
12523 (struct cmd_config_l2_tunnel_en_dis_result,
12525 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
12526 TOKEN_STRING_INITIALIZER
12527 (struct cmd_config_l2_tunnel_en_dis_result,
12529 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
12530 TOKEN_NUM_INITIALIZER
12531 (struct cmd_config_l2_tunnel_en_dis_result,
12533 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
12534 TOKEN_STRING_INITIALIZER
12535 (struct cmd_config_l2_tunnel_en_dis_result,
12536 l2_tunnel, "l2-tunnel");
12537 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
12538 TOKEN_STRING_INITIALIZER
12539 (struct cmd_config_l2_tunnel_en_dis_result,
12540 l2_tunnel_type, "E-tag");
12541 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
12542 TOKEN_STRING_INITIALIZER
12543 (struct cmd_config_l2_tunnel_en_dis_result,
12544 en_dis, "enable#disable");
12546 /* enable/disable l2 tunnel for all ports */
12548 cmd_config_l2_tunnel_en_dis_all_parsed(
12549 void *parsed_result,
12550 __attribute__((unused)) struct cmdline *cl,
12551 __attribute__((unused)) void *data)
12553 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
12554 struct rte_eth_l2_tunnel_conf entry;
12558 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12560 if (!strcmp("enable", res->en_dis))
12565 RTE_ETH_FOREACH_DEV(pid) {
12566 rte_eth_dev_l2_tunnel_offload_set(pid,
12568 ETH_L2_TUNNEL_ENABLE_MASK,
12573 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
12574 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
12576 .help_str = "port config all l2-tunnel E-tag enable|disable",
12578 (void *)&cmd_config_l2_tunnel_en_dis_port,
12579 (void *)&cmd_config_l2_tunnel_en_dis_config,
12580 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
12581 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12582 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12583 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12588 /* enable/disable l2 tunnel for a port */
12590 cmd_config_l2_tunnel_en_dis_specific_parsed(
12591 void *parsed_result,
12592 __attribute__((unused)) struct cmdline *cl,
12593 __attribute__((unused)) void *data)
12595 struct cmd_config_l2_tunnel_en_dis_result *res =
12597 struct rte_eth_l2_tunnel_conf entry;
12599 if (port_id_is_invalid(res->id, ENABLED_WARN))
12602 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12604 if (!strcmp("enable", res->en_dis))
12605 rte_eth_dev_l2_tunnel_offload_set(res->id,
12607 ETH_L2_TUNNEL_ENABLE_MASK,
12610 rte_eth_dev_l2_tunnel_offload_set(res->id,
12612 ETH_L2_TUNNEL_ENABLE_MASK,
12616 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
12617 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
12619 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
12621 (void *)&cmd_config_l2_tunnel_en_dis_port,
12622 (void *)&cmd_config_l2_tunnel_en_dis_config,
12623 (void *)&cmd_config_l2_tunnel_en_dis_id,
12624 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12625 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12626 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12631 /* E-tag configuration */
12633 /* Common result structure for all E-tag configuration */
12634 struct cmd_config_e_tag_result {
12635 cmdline_fixed_string_t e_tag;
12636 cmdline_fixed_string_t set;
12637 cmdline_fixed_string_t insertion;
12638 cmdline_fixed_string_t stripping;
12639 cmdline_fixed_string_t forwarding;
12640 cmdline_fixed_string_t filter;
12641 cmdline_fixed_string_t add;
12642 cmdline_fixed_string_t del;
12643 cmdline_fixed_string_t on;
12644 cmdline_fixed_string_t off;
12645 cmdline_fixed_string_t on_off;
12646 cmdline_fixed_string_t port_tag_id;
12647 uint32_t port_tag_id_val;
12648 cmdline_fixed_string_t e_tag_id;
12649 uint16_t e_tag_id_val;
12650 cmdline_fixed_string_t dst_pool;
12651 uint8_t dst_pool_val;
12652 cmdline_fixed_string_t port;
12654 cmdline_fixed_string_t vf;
12658 /* Common CLI fields for all E-tag configuration */
12659 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
12660 TOKEN_STRING_INITIALIZER
12661 (struct cmd_config_e_tag_result,
12663 cmdline_parse_token_string_t cmd_config_e_tag_set =
12664 TOKEN_STRING_INITIALIZER
12665 (struct cmd_config_e_tag_result,
12667 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
12668 TOKEN_STRING_INITIALIZER
12669 (struct cmd_config_e_tag_result,
12670 insertion, "insertion");
12671 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
12672 TOKEN_STRING_INITIALIZER
12673 (struct cmd_config_e_tag_result,
12674 stripping, "stripping");
12675 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
12676 TOKEN_STRING_INITIALIZER
12677 (struct cmd_config_e_tag_result,
12678 forwarding, "forwarding");
12679 cmdline_parse_token_string_t cmd_config_e_tag_filter =
12680 TOKEN_STRING_INITIALIZER
12681 (struct cmd_config_e_tag_result,
12683 cmdline_parse_token_string_t cmd_config_e_tag_add =
12684 TOKEN_STRING_INITIALIZER
12685 (struct cmd_config_e_tag_result,
12687 cmdline_parse_token_string_t cmd_config_e_tag_del =
12688 TOKEN_STRING_INITIALIZER
12689 (struct cmd_config_e_tag_result,
12691 cmdline_parse_token_string_t cmd_config_e_tag_on =
12692 TOKEN_STRING_INITIALIZER
12693 (struct cmd_config_e_tag_result,
12695 cmdline_parse_token_string_t cmd_config_e_tag_off =
12696 TOKEN_STRING_INITIALIZER
12697 (struct cmd_config_e_tag_result,
12699 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
12700 TOKEN_STRING_INITIALIZER
12701 (struct cmd_config_e_tag_result,
12703 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
12704 TOKEN_STRING_INITIALIZER
12705 (struct cmd_config_e_tag_result,
12706 port_tag_id, "port-tag-id");
12707 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
12708 TOKEN_NUM_INITIALIZER
12709 (struct cmd_config_e_tag_result,
12710 port_tag_id_val, UINT32);
12711 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
12712 TOKEN_STRING_INITIALIZER
12713 (struct cmd_config_e_tag_result,
12714 e_tag_id, "e-tag-id");
12715 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
12716 TOKEN_NUM_INITIALIZER
12717 (struct cmd_config_e_tag_result,
12718 e_tag_id_val, UINT16);
12719 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
12720 TOKEN_STRING_INITIALIZER
12721 (struct cmd_config_e_tag_result,
12722 dst_pool, "dst-pool");
12723 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
12724 TOKEN_NUM_INITIALIZER
12725 (struct cmd_config_e_tag_result,
12726 dst_pool_val, UINT8);
12727 cmdline_parse_token_string_t cmd_config_e_tag_port =
12728 TOKEN_STRING_INITIALIZER
12729 (struct cmd_config_e_tag_result,
12731 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
12732 TOKEN_NUM_INITIALIZER
12733 (struct cmd_config_e_tag_result,
12735 cmdline_parse_token_string_t cmd_config_e_tag_vf =
12736 TOKEN_STRING_INITIALIZER
12737 (struct cmd_config_e_tag_result,
12739 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
12740 TOKEN_NUM_INITIALIZER
12741 (struct cmd_config_e_tag_result,
12744 /* E-tag insertion configuration */
12746 cmd_config_e_tag_insertion_en_parsed(
12747 void *parsed_result,
12748 __attribute__((unused)) struct cmdline *cl,
12749 __attribute__((unused)) void *data)
12751 struct cmd_config_e_tag_result *res =
12753 struct rte_eth_l2_tunnel_conf entry;
12755 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12758 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12759 entry.tunnel_id = res->port_tag_id_val;
12760 entry.vf_id = res->vf_id;
12761 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12763 ETH_L2_TUNNEL_INSERTION_MASK,
12768 cmd_config_e_tag_insertion_dis_parsed(
12769 void *parsed_result,
12770 __attribute__((unused)) struct cmdline *cl,
12771 __attribute__((unused)) void *data)
12773 struct cmd_config_e_tag_result *res =
12775 struct rte_eth_l2_tunnel_conf entry;
12777 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12780 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12781 entry.vf_id = res->vf_id;
12783 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12785 ETH_L2_TUNNEL_INSERTION_MASK,
12789 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
12790 .f = cmd_config_e_tag_insertion_en_parsed,
12792 .help_str = "E-tag ... : E-tag insertion enable",
12794 (void *)&cmd_config_e_tag_e_tag,
12795 (void *)&cmd_config_e_tag_set,
12796 (void *)&cmd_config_e_tag_insertion,
12797 (void *)&cmd_config_e_tag_on,
12798 (void *)&cmd_config_e_tag_port_tag_id,
12799 (void *)&cmd_config_e_tag_port_tag_id_val,
12800 (void *)&cmd_config_e_tag_port,
12801 (void *)&cmd_config_e_tag_port_id,
12802 (void *)&cmd_config_e_tag_vf,
12803 (void *)&cmd_config_e_tag_vf_id,
12808 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
12809 .f = cmd_config_e_tag_insertion_dis_parsed,
12811 .help_str = "E-tag ... : E-tag insertion disable",
12813 (void *)&cmd_config_e_tag_e_tag,
12814 (void *)&cmd_config_e_tag_set,
12815 (void *)&cmd_config_e_tag_insertion,
12816 (void *)&cmd_config_e_tag_off,
12817 (void *)&cmd_config_e_tag_port,
12818 (void *)&cmd_config_e_tag_port_id,
12819 (void *)&cmd_config_e_tag_vf,
12820 (void *)&cmd_config_e_tag_vf_id,
12825 /* E-tag stripping configuration */
12827 cmd_config_e_tag_stripping_parsed(
12828 void *parsed_result,
12829 __attribute__((unused)) struct cmdline *cl,
12830 __attribute__((unused)) void *data)
12832 struct cmd_config_e_tag_result *res =
12834 struct rte_eth_l2_tunnel_conf entry;
12836 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12839 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12841 if (!strcmp(res->on_off, "on"))
12842 rte_eth_dev_l2_tunnel_offload_set
12845 ETH_L2_TUNNEL_STRIPPING_MASK,
12848 rte_eth_dev_l2_tunnel_offload_set
12851 ETH_L2_TUNNEL_STRIPPING_MASK,
12855 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
12856 .f = cmd_config_e_tag_stripping_parsed,
12858 .help_str = "E-tag ... : E-tag stripping enable/disable",
12860 (void *)&cmd_config_e_tag_e_tag,
12861 (void *)&cmd_config_e_tag_set,
12862 (void *)&cmd_config_e_tag_stripping,
12863 (void *)&cmd_config_e_tag_on_off,
12864 (void *)&cmd_config_e_tag_port,
12865 (void *)&cmd_config_e_tag_port_id,
12870 /* E-tag forwarding configuration */
12872 cmd_config_e_tag_forwarding_parsed(
12873 void *parsed_result,
12874 __attribute__((unused)) struct cmdline *cl,
12875 __attribute__((unused)) void *data)
12877 struct cmd_config_e_tag_result *res = parsed_result;
12878 struct rte_eth_l2_tunnel_conf entry;
12880 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12883 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12885 if (!strcmp(res->on_off, "on"))
12886 rte_eth_dev_l2_tunnel_offload_set
12889 ETH_L2_TUNNEL_FORWARDING_MASK,
12892 rte_eth_dev_l2_tunnel_offload_set
12895 ETH_L2_TUNNEL_FORWARDING_MASK,
12899 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
12900 .f = cmd_config_e_tag_forwarding_parsed,
12902 .help_str = "E-tag ... : E-tag forwarding enable/disable",
12904 (void *)&cmd_config_e_tag_e_tag,
12905 (void *)&cmd_config_e_tag_set,
12906 (void *)&cmd_config_e_tag_forwarding,
12907 (void *)&cmd_config_e_tag_on_off,
12908 (void *)&cmd_config_e_tag_port,
12909 (void *)&cmd_config_e_tag_port_id,
12914 /* E-tag filter configuration */
12916 cmd_config_e_tag_filter_add_parsed(
12917 void *parsed_result,
12918 __attribute__((unused)) struct cmdline *cl,
12919 __attribute__((unused)) void *data)
12921 struct cmd_config_e_tag_result *res = parsed_result;
12922 struct rte_eth_l2_tunnel_conf entry;
12925 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12928 if (res->e_tag_id_val > 0x3fff) {
12929 printf("e-tag-id must be equal or less than 0x3fff.\n");
12933 ret = rte_eth_dev_filter_supported(res->port_id,
12934 RTE_ETH_FILTER_L2_TUNNEL);
12936 printf("E-tag filter is not supported on port %u.\n",
12941 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12942 entry.tunnel_id = res->e_tag_id_val;
12943 entry.pool = res->dst_pool_val;
12945 ret = rte_eth_dev_filter_ctrl(res->port_id,
12946 RTE_ETH_FILTER_L2_TUNNEL,
12947 RTE_ETH_FILTER_ADD,
12950 printf("E-tag filter programming error: (%s)\n",
12954 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
12955 .f = cmd_config_e_tag_filter_add_parsed,
12957 .help_str = "E-tag ... : E-tag filter add",
12959 (void *)&cmd_config_e_tag_e_tag,
12960 (void *)&cmd_config_e_tag_set,
12961 (void *)&cmd_config_e_tag_filter,
12962 (void *)&cmd_config_e_tag_add,
12963 (void *)&cmd_config_e_tag_e_tag_id,
12964 (void *)&cmd_config_e_tag_e_tag_id_val,
12965 (void *)&cmd_config_e_tag_dst_pool,
12966 (void *)&cmd_config_e_tag_dst_pool_val,
12967 (void *)&cmd_config_e_tag_port,
12968 (void *)&cmd_config_e_tag_port_id,
12974 cmd_config_e_tag_filter_del_parsed(
12975 void *parsed_result,
12976 __attribute__((unused)) struct cmdline *cl,
12977 __attribute__((unused)) void *data)
12979 struct cmd_config_e_tag_result *res = parsed_result;
12980 struct rte_eth_l2_tunnel_conf entry;
12983 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12986 if (res->e_tag_id_val > 0x3fff) {
12987 printf("e-tag-id must be less than 0x3fff.\n");
12991 ret = rte_eth_dev_filter_supported(res->port_id,
12992 RTE_ETH_FILTER_L2_TUNNEL);
12994 printf("E-tag filter is not supported on port %u.\n",
12999 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13000 entry.tunnel_id = res->e_tag_id_val;
13002 ret = rte_eth_dev_filter_ctrl(res->port_id,
13003 RTE_ETH_FILTER_L2_TUNNEL,
13004 RTE_ETH_FILTER_DELETE,
13007 printf("E-tag filter programming error: (%s)\n",
13011 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
13012 .f = cmd_config_e_tag_filter_del_parsed,
13014 .help_str = "E-tag ... : E-tag filter delete",
13016 (void *)&cmd_config_e_tag_e_tag,
13017 (void *)&cmd_config_e_tag_set,
13018 (void *)&cmd_config_e_tag_filter,
13019 (void *)&cmd_config_e_tag_del,
13020 (void *)&cmd_config_e_tag_e_tag_id,
13021 (void *)&cmd_config_e_tag_e_tag_id_val,
13022 (void *)&cmd_config_e_tag_port,
13023 (void *)&cmd_config_e_tag_port_id,
13028 /* vf vlan anti spoof configuration */
13030 /* Common result structure for vf vlan anti spoof */
13031 struct cmd_vf_vlan_anti_spoof_result {
13032 cmdline_fixed_string_t set;
13033 cmdline_fixed_string_t vf;
13034 cmdline_fixed_string_t vlan;
13035 cmdline_fixed_string_t antispoof;
13038 cmdline_fixed_string_t on_off;
13041 /* Common CLI fields for vf vlan anti spoof enable disable */
13042 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
13043 TOKEN_STRING_INITIALIZER
13044 (struct cmd_vf_vlan_anti_spoof_result,
13046 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
13047 TOKEN_STRING_INITIALIZER
13048 (struct cmd_vf_vlan_anti_spoof_result,
13050 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
13051 TOKEN_STRING_INITIALIZER
13052 (struct cmd_vf_vlan_anti_spoof_result,
13054 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
13055 TOKEN_STRING_INITIALIZER
13056 (struct cmd_vf_vlan_anti_spoof_result,
13057 antispoof, "antispoof");
13058 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
13059 TOKEN_NUM_INITIALIZER
13060 (struct cmd_vf_vlan_anti_spoof_result,
13062 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
13063 TOKEN_NUM_INITIALIZER
13064 (struct cmd_vf_vlan_anti_spoof_result,
13066 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
13067 TOKEN_STRING_INITIALIZER
13068 (struct cmd_vf_vlan_anti_spoof_result,
13072 cmd_set_vf_vlan_anti_spoof_parsed(
13073 void *parsed_result,
13074 __attribute__((unused)) struct cmdline *cl,
13075 __attribute__((unused)) void *data)
13077 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
13078 int ret = -ENOTSUP;
13080 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13082 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13085 #ifdef RTE_LIBRTE_IXGBE_PMD
13086 if (ret == -ENOTSUP)
13087 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
13088 res->vf_id, is_on);
13090 #ifdef RTE_LIBRTE_I40E_PMD
13091 if (ret == -ENOTSUP)
13092 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
13093 res->vf_id, is_on);
13095 #ifdef RTE_LIBRTE_BNXT_PMD
13096 if (ret == -ENOTSUP)
13097 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
13098 res->vf_id, is_on);
13105 printf("invalid vf_id %d\n", res->vf_id);
13108 printf("invalid port_id %d\n", res->port_id);
13111 printf("function not implemented\n");
13114 printf("programming error: (%s)\n", strerror(-ret));
13118 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
13119 .f = cmd_set_vf_vlan_anti_spoof_parsed,
13121 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
13123 (void *)&cmd_vf_vlan_anti_spoof_set,
13124 (void *)&cmd_vf_vlan_anti_spoof_vf,
13125 (void *)&cmd_vf_vlan_anti_spoof_vlan,
13126 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
13127 (void *)&cmd_vf_vlan_anti_spoof_port_id,
13128 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
13129 (void *)&cmd_vf_vlan_anti_spoof_on_off,
13134 /* vf mac anti spoof configuration */
13136 /* Common result structure for vf mac anti spoof */
13137 struct cmd_vf_mac_anti_spoof_result {
13138 cmdline_fixed_string_t set;
13139 cmdline_fixed_string_t vf;
13140 cmdline_fixed_string_t mac;
13141 cmdline_fixed_string_t antispoof;
13144 cmdline_fixed_string_t on_off;
13147 /* Common CLI fields for vf mac anti spoof enable disable */
13148 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
13149 TOKEN_STRING_INITIALIZER
13150 (struct cmd_vf_mac_anti_spoof_result,
13152 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
13153 TOKEN_STRING_INITIALIZER
13154 (struct cmd_vf_mac_anti_spoof_result,
13156 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
13157 TOKEN_STRING_INITIALIZER
13158 (struct cmd_vf_mac_anti_spoof_result,
13160 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
13161 TOKEN_STRING_INITIALIZER
13162 (struct cmd_vf_mac_anti_spoof_result,
13163 antispoof, "antispoof");
13164 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
13165 TOKEN_NUM_INITIALIZER
13166 (struct cmd_vf_mac_anti_spoof_result,
13168 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
13169 TOKEN_NUM_INITIALIZER
13170 (struct cmd_vf_mac_anti_spoof_result,
13172 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
13173 TOKEN_STRING_INITIALIZER
13174 (struct cmd_vf_mac_anti_spoof_result,
13178 cmd_set_vf_mac_anti_spoof_parsed(
13179 void *parsed_result,
13180 __attribute__((unused)) struct cmdline *cl,
13181 __attribute__((unused)) void *data)
13183 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
13184 int ret = -ENOTSUP;
13186 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13188 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13191 #ifdef RTE_LIBRTE_IXGBE_PMD
13192 if (ret == -ENOTSUP)
13193 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
13194 res->vf_id, is_on);
13196 #ifdef RTE_LIBRTE_I40E_PMD
13197 if (ret == -ENOTSUP)
13198 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
13199 res->vf_id, is_on);
13201 #ifdef RTE_LIBRTE_BNXT_PMD
13202 if (ret == -ENOTSUP)
13203 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
13204 res->vf_id, is_on);
13211 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13214 printf("invalid port_id %d\n", res->port_id);
13217 printf("function not implemented\n");
13220 printf("programming error: (%s)\n", strerror(-ret));
13224 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
13225 .f = cmd_set_vf_mac_anti_spoof_parsed,
13227 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
13229 (void *)&cmd_vf_mac_anti_spoof_set,
13230 (void *)&cmd_vf_mac_anti_spoof_vf,
13231 (void *)&cmd_vf_mac_anti_spoof_mac,
13232 (void *)&cmd_vf_mac_anti_spoof_antispoof,
13233 (void *)&cmd_vf_mac_anti_spoof_port_id,
13234 (void *)&cmd_vf_mac_anti_spoof_vf_id,
13235 (void *)&cmd_vf_mac_anti_spoof_on_off,
13240 /* vf vlan strip queue configuration */
13242 /* Common result structure for vf mac anti spoof */
13243 struct cmd_vf_vlan_stripq_result {
13244 cmdline_fixed_string_t set;
13245 cmdline_fixed_string_t vf;
13246 cmdline_fixed_string_t vlan;
13247 cmdline_fixed_string_t stripq;
13250 cmdline_fixed_string_t on_off;
13253 /* Common CLI fields for vf vlan strip enable disable */
13254 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
13255 TOKEN_STRING_INITIALIZER
13256 (struct cmd_vf_vlan_stripq_result,
13258 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
13259 TOKEN_STRING_INITIALIZER
13260 (struct cmd_vf_vlan_stripq_result,
13262 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
13263 TOKEN_STRING_INITIALIZER
13264 (struct cmd_vf_vlan_stripq_result,
13266 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
13267 TOKEN_STRING_INITIALIZER
13268 (struct cmd_vf_vlan_stripq_result,
13270 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
13271 TOKEN_NUM_INITIALIZER
13272 (struct cmd_vf_vlan_stripq_result,
13274 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
13275 TOKEN_NUM_INITIALIZER
13276 (struct cmd_vf_vlan_stripq_result,
13278 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
13279 TOKEN_STRING_INITIALIZER
13280 (struct cmd_vf_vlan_stripq_result,
13284 cmd_set_vf_vlan_stripq_parsed(
13285 void *parsed_result,
13286 __attribute__((unused)) struct cmdline *cl,
13287 __attribute__((unused)) void *data)
13289 struct cmd_vf_vlan_stripq_result *res = parsed_result;
13290 int ret = -ENOTSUP;
13292 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13294 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13297 #ifdef RTE_LIBRTE_IXGBE_PMD
13298 if (ret == -ENOTSUP)
13299 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
13300 res->vf_id, is_on);
13302 #ifdef RTE_LIBRTE_I40E_PMD
13303 if (ret == -ENOTSUP)
13304 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
13305 res->vf_id, is_on);
13307 #ifdef RTE_LIBRTE_BNXT_PMD
13308 if (ret == -ENOTSUP)
13309 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
13310 res->vf_id, is_on);
13317 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13320 printf("invalid port_id %d\n", res->port_id);
13323 printf("function not implemented\n");
13326 printf("programming error: (%s)\n", strerror(-ret));
13330 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
13331 .f = cmd_set_vf_vlan_stripq_parsed,
13333 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
13335 (void *)&cmd_vf_vlan_stripq_set,
13336 (void *)&cmd_vf_vlan_stripq_vf,
13337 (void *)&cmd_vf_vlan_stripq_vlan,
13338 (void *)&cmd_vf_vlan_stripq_stripq,
13339 (void *)&cmd_vf_vlan_stripq_port_id,
13340 (void *)&cmd_vf_vlan_stripq_vf_id,
13341 (void *)&cmd_vf_vlan_stripq_on_off,
13346 /* vf vlan insert configuration */
13348 /* Common result structure for vf vlan insert */
13349 struct cmd_vf_vlan_insert_result {
13350 cmdline_fixed_string_t set;
13351 cmdline_fixed_string_t vf;
13352 cmdline_fixed_string_t vlan;
13353 cmdline_fixed_string_t insert;
13359 /* Common CLI fields for vf vlan insert enable disable */
13360 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
13361 TOKEN_STRING_INITIALIZER
13362 (struct cmd_vf_vlan_insert_result,
13364 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
13365 TOKEN_STRING_INITIALIZER
13366 (struct cmd_vf_vlan_insert_result,
13368 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
13369 TOKEN_STRING_INITIALIZER
13370 (struct cmd_vf_vlan_insert_result,
13372 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
13373 TOKEN_STRING_INITIALIZER
13374 (struct cmd_vf_vlan_insert_result,
13376 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
13377 TOKEN_NUM_INITIALIZER
13378 (struct cmd_vf_vlan_insert_result,
13380 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
13381 TOKEN_NUM_INITIALIZER
13382 (struct cmd_vf_vlan_insert_result,
13384 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
13385 TOKEN_NUM_INITIALIZER
13386 (struct cmd_vf_vlan_insert_result,
13390 cmd_set_vf_vlan_insert_parsed(
13391 void *parsed_result,
13392 __attribute__((unused)) struct cmdline *cl,
13393 __attribute__((unused)) void *data)
13395 struct cmd_vf_vlan_insert_result *res = parsed_result;
13396 int ret = -ENOTSUP;
13398 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13401 #ifdef RTE_LIBRTE_IXGBE_PMD
13402 if (ret == -ENOTSUP)
13403 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
13406 #ifdef RTE_LIBRTE_I40E_PMD
13407 if (ret == -ENOTSUP)
13408 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
13411 #ifdef RTE_LIBRTE_BNXT_PMD
13412 if (ret == -ENOTSUP)
13413 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
13421 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
13424 printf("invalid port_id %d\n", res->port_id);
13427 printf("function not implemented\n");
13430 printf("programming error: (%s)\n", strerror(-ret));
13434 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
13435 .f = cmd_set_vf_vlan_insert_parsed,
13437 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
13439 (void *)&cmd_vf_vlan_insert_set,
13440 (void *)&cmd_vf_vlan_insert_vf,
13441 (void *)&cmd_vf_vlan_insert_vlan,
13442 (void *)&cmd_vf_vlan_insert_insert,
13443 (void *)&cmd_vf_vlan_insert_port_id,
13444 (void *)&cmd_vf_vlan_insert_vf_id,
13445 (void *)&cmd_vf_vlan_insert_vlan_id,
13450 /* tx loopback configuration */
13452 /* Common result structure for tx loopback */
13453 struct cmd_tx_loopback_result {
13454 cmdline_fixed_string_t set;
13455 cmdline_fixed_string_t tx;
13456 cmdline_fixed_string_t loopback;
13458 cmdline_fixed_string_t on_off;
13461 /* Common CLI fields for tx loopback enable disable */
13462 cmdline_parse_token_string_t cmd_tx_loopback_set =
13463 TOKEN_STRING_INITIALIZER
13464 (struct cmd_tx_loopback_result,
13466 cmdline_parse_token_string_t cmd_tx_loopback_tx =
13467 TOKEN_STRING_INITIALIZER
13468 (struct cmd_tx_loopback_result,
13470 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
13471 TOKEN_STRING_INITIALIZER
13472 (struct cmd_tx_loopback_result,
13473 loopback, "loopback");
13474 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
13475 TOKEN_NUM_INITIALIZER
13476 (struct cmd_tx_loopback_result,
13478 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
13479 TOKEN_STRING_INITIALIZER
13480 (struct cmd_tx_loopback_result,
13484 cmd_set_tx_loopback_parsed(
13485 void *parsed_result,
13486 __attribute__((unused)) struct cmdline *cl,
13487 __attribute__((unused)) void *data)
13489 struct cmd_tx_loopback_result *res = parsed_result;
13490 int ret = -ENOTSUP;
13492 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13494 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13497 #ifdef RTE_LIBRTE_IXGBE_PMD
13498 if (ret == -ENOTSUP)
13499 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
13501 #ifdef RTE_LIBRTE_I40E_PMD
13502 if (ret == -ENOTSUP)
13503 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
13505 #ifdef RTE_LIBRTE_BNXT_PMD
13506 if (ret == -ENOTSUP)
13507 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
13509 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD
13510 if (ret == -ENOTSUP)
13511 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
13518 printf("invalid is_on %d\n", is_on);
13521 printf("invalid port_id %d\n", res->port_id);
13524 printf("function not implemented\n");
13527 printf("programming error: (%s)\n", strerror(-ret));
13531 cmdline_parse_inst_t cmd_set_tx_loopback = {
13532 .f = cmd_set_tx_loopback_parsed,
13534 .help_str = "set tx loopback <port_id> on|off",
13536 (void *)&cmd_tx_loopback_set,
13537 (void *)&cmd_tx_loopback_tx,
13538 (void *)&cmd_tx_loopback_loopback,
13539 (void *)&cmd_tx_loopback_port_id,
13540 (void *)&cmd_tx_loopback_on_off,
13545 /* all queues drop enable configuration */
13547 /* Common result structure for all queues drop enable */
13548 struct cmd_all_queues_drop_en_result {
13549 cmdline_fixed_string_t set;
13550 cmdline_fixed_string_t all;
13551 cmdline_fixed_string_t queues;
13552 cmdline_fixed_string_t drop;
13554 cmdline_fixed_string_t on_off;
13557 /* Common CLI fields for tx loopback enable disable */
13558 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
13559 TOKEN_STRING_INITIALIZER
13560 (struct cmd_all_queues_drop_en_result,
13562 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
13563 TOKEN_STRING_INITIALIZER
13564 (struct cmd_all_queues_drop_en_result,
13566 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
13567 TOKEN_STRING_INITIALIZER
13568 (struct cmd_all_queues_drop_en_result,
13570 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
13571 TOKEN_STRING_INITIALIZER
13572 (struct cmd_all_queues_drop_en_result,
13574 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
13575 TOKEN_NUM_INITIALIZER
13576 (struct cmd_all_queues_drop_en_result,
13578 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
13579 TOKEN_STRING_INITIALIZER
13580 (struct cmd_all_queues_drop_en_result,
13584 cmd_set_all_queues_drop_en_parsed(
13585 void *parsed_result,
13586 __attribute__((unused)) struct cmdline *cl,
13587 __attribute__((unused)) void *data)
13589 struct cmd_all_queues_drop_en_result *res = parsed_result;
13590 int ret = -ENOTSUP;
13591 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13593 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13596 #ifdef RTE_LIBRTE_IXGBE_PMD
13597 if (ret == -ENOTSUP)
13598 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
13600 #ifdef RTE_LIBRTE_BNXT_PMD
13601 if (ret == -ENOTSUP)
13602 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
13608 printf("invalid is_on %d\n", is_on);
13611 printf("invalid port_id %d\n", res->port_id);
13614 printf("function not implemented\n");
13617 printf("programming error: (%s)\n", strerror(-ret));
13621 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
13622 .f = cmd_set_all_queues_drop_en_parsed,
13624 .help_str = "set all queues drop <port_id> on|off",
13626 (void *)&cmd_all_queues_drop_en_set,
13627 (void *)&cmd_all_queues_drop_en_all,
13628 (void *)&cmd_all_queues_drop_en_queues,
13629 (void *)&cmd_all_queues_drop_en_drop,
13630 (void *)&cmd_all_queues_drop_en_port_id,
13631 (void *)&cmd_all_queues_drop_en_on_off,
13636 /* vf split drop enable configuration */
13638 /* Common result structure for vf split drop enable */
13639 struct cmd_vf_split_drop_en_result {
13640 cmdline_fixed_string_t set;
13641 cmdline_fixed_string_t vf;
13642 cmdline_fixed_string_t split;
13643 cmdline_fixed_string_t drop;
13646 cmdline_fixed_string_t on_off;
13649 /* Common CLI fields for vf split drop enable disable */
13650 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
13651 TOKEN_STRING_INITIALIZER
13652 (struct cmd_vf_split_drop_en_result,
13654 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
13655 TOKEN_STRING_INITIALIZER
13656 (struct cmd_vf_split_drop_en_result,
13658 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
13659 TOKEN_STRING_INITIALIZER
13660 (struct cmd_vf_split_drop_en_result,
13662 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
13663 TOKEN_STRING_INITIALIZER
13664 (struct cmd_vf_split_drop_en_result,
13666 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
13667 TOKEN_NUM_INITIALIZER
13668 (struct cmd_vf_split_drop_en_result,
13670 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
13671 TOKEN_NUM_INITIALIZER
13672 (struct cmd_vf_split_drop_en_result,
13674 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
13675 TOKEN_STRING_INITIALIZER
13676 (struct cmd_vf_split_drop_en_result,
13680 cmd_set_vf_split_drop_en_parsed(
13681 void *parsed_result,
13682 __attribute__((unused)) struct cmdline *cl,
13683 __attribute__((unused)) void *data)
13685 struct cmd_vf_split_drop_en_result *res = parsed_result;
13686 int ret = -ENOTSUP;
13687 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13689 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13692 #ifdef RTE_LIBRTE_IXGBE_PMD
13693 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
13700 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13703 printf("invalid port_id %d\n", res->port_id);
13706 printf("not supported on port %d\n", res->port_id);
13709 printf("programming error: (%s)\n", strerror(-ret));
13713 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
13714 .f = cmd_set_vf_split_drop_en_parsed,
13716 .help_str = "set vf split drop <port_id> <vf_id> on|off",
13718 (void *)&cmd_vf_split_drop_en_set,
13719 (void *)&cmd_vf_split_drop_en_vf,
13720 (void *)&cmd_vf_split_drop_en_split,
13721 (void *)&cmd_vf_split_drop_en_drop,
13722 (void *)&cmd_vf_split_drop_en_port_id,
13723 (void *)&cmd_vf_split_drop_en_vf_id,
13724 (void *)&cmd_vf_split_drop_en_on_off,
13729 /* vf mac address configuration */
13731 /* Common result structure for vf mac address */
13732 struct cmd_set_vf_mac_addr_result {
13733 cmdline_fixed_string_t set;
13734 cmdline_fixed_string_t vf;
13735 cmdline_fixed_string_t mac;
13736 cmdline_fixed_string_t addr;
13739 struct ether_addr mac_addr;
13743 /* Common CLI fields for vf split drop enable disable */
13744 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
13745 TOKEN_STRING_INITIALIZER
13746 (struct cmd_set_vf_mac_addr_result,
13748 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
13749 TOKEN_STRING_INITIALIZER
13750 (struct cmd_set_vf_mac_addr_result,
13752 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
13753 TOKEN_STRING_INITIALIZER
13754 (struct cmd_set_vf_mac_addr_result,
13756 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
13757 TOKEN_STRING_INITIALIZER
13758 (struct cmd_set_vf_mac_addr_result,
13760 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
13761 TOKEN_NUM_INITIALIZER
13762 (struct cmd_set_vf_mac_addr_result,
13764 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
13765 TOKEN_NUM_INITIALIZER
13766 (struct cmd_set_vf_mac_addr_result,
13768 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
13769 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
13773 cmd_set_vf_mac_addr_parsed(
13774 void *parsed_result,
13775 __attribute__((unused)) struct cmdline *cl,
13776 __attribute__((unused)) void *data)
13778 struct cmd_set_vf_mac_addr_result *res = parsed_result;
13779 int ret = -ENOTSUP;
13781 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13784 #ifdef RTE_LIBRTE_IXGBE_PMD
13785 if (ret == -ENOTSUP)
13786 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
13789 #ifdef RTE_LIBRTE_I40E_PMD
13790 if (ret == -ENOTSUP)
13791 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
13794 #ifdef RTE_LIBRTE_BNXT_PMD
13795 if (ret == -ENOTSUP)
13796 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
13804 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
13807 printf("invalid port_id %d\n", res->port_id);
13810 printf("function not implemented\n");
13813 printf("programming error: (%s)\n", strerror(-ret));
13817 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
13818 .f = cmd_set_vf_mac_addr_parsed,
13820 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
13822 (void *)&cmd_set_vf_mac_addr_set,
13823 (void *)&cmd_set_vf_mac_addr_vf,
13824 (void *)&cmd_set_vf_mac_addr_mac,
13825 (void *)&cmd_set_vf_mac_addr_addr,
13826 (void *)&cmd_set_vf_mac_addr_port_id,
13827 (void *)&cmd_set_vf_mac_addr_vf_id,
13828 (void *)&cmd_set_vf_mac_addr_mac_addr,
13833 /* MACsec configuration */
13835 /* Common result structure for MACsec offload enable */
13836 struct cmd_macsec_offload_on_result {
13837 cmdline_fixed_string_t set;
13838 cmdline_fixed_string_t macsec;
13839 cmdline_fixed_string_t offload;
13841 cmdline_fixed_string_t on;
13842 cmdline_fixed_string_t encrypt;
13843 cmdline_fixed_string_t en_on_off;
13844 cmdline_fixed_string_t replay_protect;
13845 cmdline_fixed_string_t rp_on_off;
13848 /* Common CLI fields for MACsec offload disable */
13849 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
13850 TOKEN_STRING_INITIALIZER
13851 (struct cmd_macsec_offload_on_result,
13853 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
13854 TOKEN_STRING_INITIALIZER
13855 (struct cmd_macsec_offload_on_result,
13857 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
13858 TOKEN_STRING_INITIALIZER
13859 (struct cmd_macsec_offload_on_result,
13860 offload, "offload");
13861 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
13862 TOKEN_NUM_INITIALIZER
13863 (struct cmd_macsec_offload_on_result,
13865 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
13866 TOKEN_STRING_INITIALIZER
13867 (struct cmd_macsec_offload_on_result,
13869 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
13870 TOKEN_STRING_INITIALIZER
13871 (struct cmd_macsec_offload_on_result,
13872 encrypt, "encrypt");
13873 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
13874 TOKEN_STRING_INITIALIZER
13875 (struct cmd_macsec_offload_on_result,
13876 en_on_off, "on#off");
13877 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
13878 TOKEN_STRING_INITIALIZER
13879 (struct cmd_macsec_offload_on_result,
13880 replay_protect, "replay-protect");
13881 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
13882 TOKEN_STRING_INITIALIZER
13883 (struct cmd_macsec_offload_on_result,
13884 rp_on_off, "on#off");
13887 cmd_set_macsec_offload_on_parsed(
13888 void *parsed_result,
13889 __attribute__((unused)) struct cmdline *cl,
13890 __attribute__((unused)) void *data)
13892 struct cmd_macsec_offload_on_result *res = parsed_result;
13893 int ret = -ENOTSUP;
13894 portid_t port_id = res->port_id;
13895 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
13896 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
13897 struct rte_eth_dev_info dev_info;
13899 if (port_id_is_invalid(port_id, ENABLED_WARN))
13901 if (!port_is_stopped(port_id)) {
13902 printf("Please stop port %d first\n", port_id);
13906 rte_eth_dev_info_get(port_id, &dev_info);
13907 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
13908 #ifdef RTE_LIBRTE_IXGBE_PMD
13909 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
13917 ports[port_id].dev_conf.txmode.offloads |=
13918 DEV_TX_OFFLOAD_MACSEC_INSERT;
13919 cmd_reconfig_device_queue(port_id, 1, 1);
13922 printf("invalid port_id %d\n", port_id);
13925 printf("not supported on port %d\n", port_id);
13928 printf("programming error: (%s)\n", strerror(-ret));
13932 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
13933 .f = cmd_set_macsec_offload_on_parsed,
13935 .help_str = "set macsec offload <port_id> on "
13936 "encrypt on|off replay-protect on|off",
13938 (void *)&cmd_macsec_offload_on_set,
13939 (void *)&cmd_macsec_offload_on_macsec,
13940 (void *)&cmd_macsec_offload_on_offload,
13941 (void *)&cmd_macsec_offload_on_port_id,
13942 (void *)&cmd_macsec_offload_on_on,
13943 (void *)&cmd_macsec_offload_on_encrypt,
13944 (void *)&cmd_macsec_offload_on_en_on_off,
13945 (void *)&cmd_macsec_offload_on_replay_protect,
13946 (void *)&cmd_macsec_offload_on_rp_on_off,
13951 /* Common result structure for MACsec offload disable */
13952 struct cmd_macsec_offload_off_result {
13953 cmdline_fixed_string_t set;
13954 cmdline_fixed_string_t macsec;
13955 cmdline_fixed_string_t offload;
13957 cmdline_fixed_string_t off;
13960 /* Common CLI fields for MACsec offload disable */
13961 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
13962 TOKEN_STRING_INITIALIZER
13963 (struct cmd_macsec_offload_off_result,
13965 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
13966 TOKEN_STRING_INITIALIZER
13967 (struct cmd_macsec_offload_off_result,
13969 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
13970 TOKEN_STRING_INITIALIZER
13971 (struct cmd_macsec_offload_off_result,
13972 offload, "offload");
13973 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
13974 TOKEN_NUM_INITIALIZER
13975 (struct cmd_macsec_offload_off_result,
13977 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
13978 TOKEN_STRING_INITIALIZER
13979 (struct cmd_macsec_offload_off_result,
13983 cmd_set_macsec_offload_off_parsed(
13984 void *parsed_result,
13985 __attribute__((unused)) struct cmdline *cl,
13986 __attribute__((unused)) void *data)
13988 struct cmd_macsec_offload_off_result *res = parsed_result;
13989 int ret = -ENOTSUP;
13990 struct rte_eth_dev_info dev_info;
13991 portid_t port_id = res->port_id;
13993 if (port_id_is_invalid(port_id, ENABLED_WARN))
13995 if (!port_is_stopped(port_id)) {
13996 printf("Please stop port %d first\n", port_id);
14000 rte_eth_dev_info_get(port_id, &dev_info);
14001 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
14002 #ifdef RTE_LIBRTE_IXGBE_PMD
14003 ret = rte_pmd_ixgbe_macsec_disable(port_id);
14008 ports[port_id].dev_conf.txmode.offloads &=
14009 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
14010 cmd_reconfig_device_queue(port_id, 1, 1);
14013 printf("invalid port_id %d\n", port_id);
14016 printf("not supported on port %d\n", port_id);
14019 printf("programming error: (%s)\n", strerror(-ret));
14023 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
14024 .f = cmd_set_macsec_offload_off_parsed,
14026 .help_str = "set macsec offload <port_id> off",
14028 (void *)&cmd_macsec_offload_off_set,
14029 (void *)&cmd_macsec_offload_off_macsec,
14030 (void *)&cmd_macsec_offload_off_offload,
14031 (void *)&cmd_macsec_offload_off_port_id,
14032 (void *)&cmd_macsec_offload_off_off,
14037 /* Common result structure for MACsec secure connection configure */
14038 struct cmd_macsec_sc_result {
14039 cmdline_fixed_string_t set;
14040 cmdline_fixed_string_t macsec;
14041 cmdline_fixed_string_t sc;
14042 cmdline_fixed_string_t tx_rx;
14044 struct ether_addr mac;
14048 /* Common CLI fields for MACsec secure connection configure */
14049 cmdline_parse_token_string_t cmd_macsec_sc_set =
14050 TOKEN_STRING_INITIALIZER
14051 (struct cmd_macsec_sc_result,
14053 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
14054 TOKEN_STRING_INITIALIZER
14055 (struct cmd_macsec_sc_result,
14057 cmdline_parse_token_string_t cmd_macsec_sc_sc =
14058 TOKEN_STRING_INITIALIZER
14059 (struct cmd_macsec_sc_result,
14061 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
14062 TOKEN_STRING_INITIALIZER
14063 (struct cmd_macsec_sc_result,
14065 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
14066 TOKEN_NUM_INITIALIZER
14067 (struct cmd_macsec_sc_result,
14069 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
14070 TOKEN_ETHERADDR_INITIALIZER
14071 (struct cmd_macsec_sc_result,
14073 cmdline_parse_token_num_t cmd_macsec_sc_pi =
14074 TOKEN_NUM_INITIALIZER
14075 (struct cmd_macsec_sc_result,
14079 cmd_set_macsec_sc_parsed(
14080 void *parsed_result,
14081 __attribute__((unused)) struct cmdline *cl,
14082 __attribute__((unused)) void *data)
14084 struct cmd_macsec_sc_result *res = parsed_result;
14085 int ret = -ENOTSUP;
14086 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14088 #ifdef RTE_LIBRTE_IXGBE_PMD
14090 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
14091 res->mac.addr_bytes) :
14092 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
14093 res->mac.addr_bytes, res->pi);
14095 RTE_SET_USED(is_tx);
14101 printf("invalid port_id %d\n", res->port_id);
14104 printf("not supported on port %d\n", res->port_id);
14107 printf("programming error: (%s)\n", strerror(-ret));
14111 cmdline_parse_inst_t cmd_set_macsec_sc = {
14112 .f = cmd_set_macsec_sc_parsed,
14114 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
14116 (void *)&cmd_macsec_sc_set,
14117 (void *)&cmd_macsec_sc_macsec,
14118 (void *)&cmd_macsec_sc_sc,
14119 (void *)&cmd_macsec_sc_tx_rx,
14120 (void *)&cmd_macsec_sc_port_id,
14121 (void *)&cmd_macsec_sc_mac,
14122 (void *)&cmd_macsec_sc_pi,
14127 /* Common result structure for MACsec secure connection configure */
14128 struct cmd_macsec_sa_result {
14129 cmdline_fixed_string_t set;
14130 cmdline_fixed_string_t macsec;
14131 cmdline_fixed_string_t sa;
14132 cmdline_fixed_string_t tx_rx;
14137 cmdline_fixed_string_t key;
14140 /* Common CLI fields for MACsec secure connection configure */
14141 cmdline_parse_token_string_t cmd_macsec_sa_set =
14142 TOKEN_STRING_INITIALIZER
14143 (struct cmd_macsec_sa_result,
14145 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
14146 TOKEN_STRING_INITIALIZER
14147 (struct cmd_macsec_sa_result,
14149 cmdline_parse_token_string_t cmd_macsec_sa_sa =
14150 TOKEN_STRING_INITIALIZER
14151 (struct cmd_macsec_sa_result,
14153 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
14154 TOKEN_STRING_INITIALIZER
14155 (struct cmd_macsec_sa_result,
14157 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
14158 TOKEN_NUM_INITIALIZER
14159 (struct cmd_macsec_sa_result,
14161 cmdline_parse_token_num_t cmd_macsec_sa_idx =
14162 TOKEN_NUM_INITIALIZER
14163 (struct cmd_macsec_sa_result,
14165 cmdline_parse_token_num_t cmd_macsec_sa_an =
14166 TOKEN_NUM_INITIALIZER
14167 (struct cmd_macsec_sa_result,
14169 cmdline_parse_token_num_t cmd_macsec_sa_pn =
14170 TOKEN_NUM_INITIALIZER
14171 (struct cmd_macsec_sa_result,
14173 cmdline_parse_token_string_t cmd_macsec_sa_key =
14174 TOKEN_STRING_INITIALIZER
14175 (struct cmd_macsec_sa_result,
14179 cmd_set_macsec_sa_parsed(
14180 void *parsed_result,
14181 __attribute__((unused)) struct cmdline *cl,
14182 __attribute__((unused)) void *data)
14184 struct cmd_macsec_sa_result *res = parsed_result;
14185 int ret = -ENOTSUP;
14186 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14187 uint8_t key[16] = { 0 };
14193 key_len = strlen(res->key) / 2;
14197 for (i = 0; i < key_len; i++) {
14198 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
14201 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
14204 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
14207 #ifdef RTE_LIBRTE_IXGBE_PMD
14209 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
14210 res->idx, res->an, res->pn, key) :
14211 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
14212 res->idx, res->an, res->pn, key);
14214 RTE_SET_USED(is_tx);
14221 printf("invalid idx %d or an %d\n", res->idx, res->an);
14224 printf("invalid port_id %d\n", res->port_id);
14227 printf("not supported on port %d\n", res->port_id);
14230 printf("programming error: (%s)\n", strerror(-ret));
14234 cmdline_parse_inst_t cmd_set_macsec_sa = {
14235 .f = cmd_set_macsec_sa_parsed,
14237 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
14239 (void *)&cmd_macsec_sa_set,
14240 (void *)&cmd_macsec_sa_macsec,
14241 (void *)&cmd_macsec_sa_sa,
14242 (void *)&cmd_macsec_sa_tx_rx,
14243 (void *)&cmd_macsec_sa_port_id,
14244 (void *)&cmd_macsec_sa_idx,
14245 (void *)&cmd_macsec_sa_an,
14246 (void *)&cmd_macsec_sa_pn,
14247 (void *)&cmd_macsec_sa_key,
14252 /* VF unicast promiscuous mode configuration */
14254 /* Common result structure for VF unicast promiscuous mode */
14255 struct cmd_vf_promisc_result {
14256 cmdline_fixed_string_t set;
14257 cmdline_fixed_string_t vf;
14258 cmdline_fixed_string_t promisc;
14261 cmdline_fixed_string_t on_off;
14264 /* Common CLI fields for VF unicast promiscuous mode enable disable */
14265 cmdline_parse_token_string_t cmd_vf_promisc_set =
14266 TOKEN_STRING_INITIALIZER
14267 (struct cmd_vf_promisc_result,
14269 cmdline_parse_token_string_t cmd_vf_promisc_vf =
14270 TOKEN_STRING_INITIALIZER
14271 (struct cmd_vf_promisc_result,
14273 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
14274 TOKEN_STRING_INITIALIZER
14275 (struct cmd_vf_promisc_result,
14276 promisc, "promisc");
14277 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
14278 TOKEN_NUM_INITIALIZER
14279 (struct cmd_vf_promisc_result,
14281 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
14282 TOKEN_NUM_INITIALIZER
14283 (struct cmd_vf_promisc_result,
14285 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
14286 TOKEN_STRING_INITIALIZER
14287 (struct cmd_vf_promisc_result,
14291 cmd_set_vf_promisc_parsed(
14292 void *parsed_result,
14293 __attribute__((unused)) struct cmdline *cl,
14294 __attribute__((unused)) void *data)
14296 struct cmd_vf_promisc_result *res = parsed_result;
14297 int ret = -ENOTSUP;
14299 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14301 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14304 #ifdef RTE_LIBRTE_I40E_PMD
14305 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
14306 res->vf_id, is_on);
14313 printf("invalid vf_id %d\n", res->vf_id);
14316 printf("invalid port_id %d\n", res->port_id);
14319 printf("function not implemented\n");
14322 printf("programming error: (%s)\n", strerror(-ret));
14326 cmdline_parse_inst_t cmd_set_vf_promisc = {
14327 .f = cmd_set_vf_promisc_parsed,
14329 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
14330 "Set unicast promiscuous mode for a VF from the PF",
14332 (void *)&cmd_vf_promisc_set,
14333 (void *)&cmd_vf_promisc_vf,
14334 (void *)&cmd_vf_promisc_promisc,
14335 (void *)&cmd_vf_promisc_port_id,
14336 (void *)&cmd_vf_promisc_vf_id,
14337 (void *)&cmd_vf_promisc_on_off,
14342 /* VF multicast promiscuous mode configuration */
14344 /* Common result structure for VF multicast promiscuous mode */
14345 struct cmd_vf_allmulti_result {
14346 cmdline_fixed_string_t set;
14347 cmdline_fixed_string_t vf;
14348 cmdline_fixed_string_t allmulti;
14351 cmdline_fixed_string_t on_off;
14354 /* Common CLI fields for VF multicast promiscuous mode enable disable */
14355 cmdline_parse_token_string_t cmd_vf_allmulti_set =
14356 TOKEN_STRING_INITIALIZER
14357 (struct cmd_vf_allmulti_result,
14359 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
14360 TOKEN_STRING_INITIALIZER
14361 (struct cmd_vf_allmulti_result,
14363 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
14364 TOKEN_STRING_INITIALIZER
14365 (struct cmd_vf_allmulti_result,
14366 allmulti, "allmulti");
14367 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
14368 TOKEN_NUM_INITIALIZER
14369 (struct cmd_vf_allmulti_result,
14371 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
14372 TOKEN_NUM_INITIALIZER
14373 (struct cmd_vf_allmulti_result,
14375 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
14376 TOKEN_STRING_INITIALIZER
14377 (struct cmd_vf_allmulti_result,
14381 cmd_set_vf_allmulti_parsed(
14382 void *parsed_result,
14383 __attribute__((unused)) struct cmdline *cl,
14384 __attribute__((unused)) void *data)
14386 struct cmd_vf_allmulti_result *res = parsed_result;
14387 int ret = -ENOTSUP;
14389 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14391 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14394 #ifdef RTE_LIBRTE_I40E_PMD
14395 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
14396 res->vf_id, is_on);
14403 printf("invalid vf_id %d\n", res->vf_id);
14406 printf("invalid port_id %d\n", res->port_id);
14409 printf("function not implemented\n");
14412 printf("programming error: (%s)\n", strerror(-ret));
14416 cmdline_parse_inst_t cmd_set_vf_allmulti = {
14417 .f = cmd_set_vf_allmulti_parsed,
14419 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
14420 "Set multicast promiscuous mode for a VF from the PF",
14422 (void *)&cmd_vf_allmulti_set,
14423 (void *)&cmd_vf_allmulti_vf,
14424 (void *)&cmd_vf_allmulti_allmulti,
14425 (void *)&cmd_vf_allmulti_port_id,
14426 (void *)&cmd_vf_allmulti_vf_id,
14427 (void *)&cmd_vf_allmulti_on_off,
14432 /* vf broadcast mode configuration */
14434 /* Common result structure for vf broadcast */
14435 struct cmd_set_vf_broadcast_result {
14436 cmdline_fixed_string_t set;
14437 cmdline_fixed_string_t vf;
14438 cmdline_fixed_string_t broadcast;
14441 cmdline_fixed_string_t on_off;
14444 /* Common CLI fields for vf broadcast enable disable */
14445 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
14446 TOKEN_STRING_INITIALIZER
14447 (struct cmd_set_vf_broadcast_result,
14449 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
14450 TOKEN_STRING_INITIALIZER
14451 (struct cmd_set_vf_broadcast_result,
14453 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
14454 TOKEN_STRING_INITIALIZER
14455 (struct cmd_set_vf_broadcast_result,
14456 broadcast, "broadcast");
14457 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
14458 TOKEN_NUM_INITIALIZER
14459 (struct cmd_set_vf_broadcast_result,
14461 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
14462 TOKEN_NUM_INITIALIZER
14463 (struct cmd_set_vf_broadcast_result,
14465 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
14466 TOKEN_STRING_INITIALIZER
14467 (struct cmd_set_vf_broadcast_result,
14471 cmd_set_vf_broadcast_parsed(
14472 void *parsed_result,
14473 __attribute__((unused)) struct cmdline *cl,
14474 __attribute__((unused)) void *data)
14476 struct cmd_set_vf_broadcast_result *res = parsed_result;
14477 int ret = -ENOTSUP;
14479 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14481 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14484 #ifdef RTE_LIBRTE_I40E_PMD
14485 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
14486 res->vf_id, is_on);
14493 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14496 printf("invalid port_id %d\n", res->port_id);
14499 printf("function not implemented\n");
14502 printf("programming error: (%s)\n", strerror(-ret));
14506 cmdline_parse_inst_t cmd_set_vf_broadcast = {
14507 .f = cmd_set_vf_broadcast_parsed,
14509 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
14511 (void *)&cmd_set_vf_broadcast_set,
14512 (void *)&cmd_set_vf_broadcast_vf,
14513 (void *)&cmd_set_vf_broadcast_broadcast,
14514 (void *)&cmd_set_vf_broadcast_port_id,
14515 (void *)&cmd_set_vf_broadcast_vf_id,
14516 (void *)&cmd_set_vf_broadcast_on_off,
14521 /* vf vlan tag configuration */
14523 /* Common result structure for vf vlan tag */
14524 struct cmd_set_vf_vlan_tag_result {
14525 cmdline_fixed_string_t set;
14526 cmdline_fixed_string_t vf;
14527 cmdline_fixed_string_t vlan;
14528 cmdline_fixed_string_t tag;
14531 cmdline_fixed_string_t on_off;
14534 /* Common CLI fields for vf vlan tag enable disable */
14535 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
14536 TOKEN_STRING_INITIALIZER
14537 (struct cmd_set_vf_vlan_tag_result,
14539 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
14540 TOKEN_STRING_INITIALIZER
14541 (struct cmd_set_vf_vlan_tag_result,
14543 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
14544 TOKEN_STRING_INITIALIZER
14545 (struct cmd_set_vf_vlan_tag_result,
14547 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
14548 TOKEN_STRING_INITIALIZER
14549 (struct cmd_set_vf_vlan_tag_result,
14551 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
14552 TOKEN_NUM_INITIALIZER
14553 (struct cmd_set_vf_vlan_tag_result,
14555 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
14556 TOKEN_NUM_INITIALIZER
14557 (struct cmd_set_vf_vlan_tag_result,
14559 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
14560 TOKEN_STRING_INITIALIZER
14561 (struct cmd_set_vf_vlan_tag_result,
14565 cmd_set_vf_vlan_tag_parsed(
14566 void *parsed_result,
14567 __attribute__((unused)) struct cmdline *cl,
14568 __attribute__((unused)) void *data)
14570 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
14571 int ret = -ENOTSUP;
14573 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14575 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14578 #ifdef RTE_LIBRTE_I40E_PMD
14579 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
14580 res->vf_id, is_on);
14587 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14590 printf("invalid port_id %d\n", res->port_id);
14593 printf("function not implemented\n");
14596 printf("programming error: (%s)\n", strerror(-ret));
14600 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
14601 .f = cmd_set_vf_vlan_tag_parsed,
14603 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
14605 (void *)&cmd_set_vf_vlan_tag_set,
14606 (void *)&cmd_set_vf_vlan_tag_vf,
14607 (void *)&cmd_set_vf_vlan_tag_vlan,
14608 (void *)&cmd_set_vf_vlan_tag_tag,
14609 (void *)&cmd_set_vf_vlan_tag_port_id,
14610 (void *)&cmd_set_vf_vlan_tag_vf_id,
14611 (void *)&cmd_set_vf_vlan_tag_on_off,
14616 /* Common definition of VF and TC TX bandwidth configuration */
14617 struct cmd_vf_tc_bw_result {
14618 cmdline_fixed_string_t set;
14619 cmdline_fixed_string_t vf;
14620 cmdline_fixed_string_t tc;
14621 cmdline_fixed_string_t tx;
14622 cmdline_fixed_string_t min_bw;
14623 cmdline_fixed_string_t max_bw;
14624 cmdline_fixed_string_t strict_link_prio;
14629 cmdline_fixed_string_t bw_list;
14633 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
14634 TOKEN_STRING_INITIALIZER
14635 (struct cmd_vf_tc_bw_result,
14637 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
14638 TOKEN_STRING_INITIALIZER
14639 (struct cmd_vf_tc_bw_result,
14641 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
14642 TOKEN_STRING_INITIALIZER
14643 (struct cmd_vf_tc_bw_result,
14645 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
14646 TOKEN_STRING_INITIALIZER
14647 (struct cmd_vf_tc_bw_result,
14649 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
14650 TOKEN_STRING_INITIALIZER
14651 (struct cmd_vf_tc_bw_result,
14652 strict_link_prio, "strict-link-priority");
14653 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
14654 TOKEN_STRING_INITIALIZER
14655 (struct cmd_vf_tc_bw_result,
14656 min_bw, "min-bandwidth");
14657 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
14658 TOKEN_STRING_INITIALIZER
14659 (struct cmd_vf_tc_bw_result,
14660 max_bw, "max-bandwidth");
14661 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
14662 TOKEN_NUM_INITIALIZER
14663 (struct cmd_vf_tc_bw_result,
14665 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
14666 TOKEN_NUM_INITIALIZER
14667 (struct cmd_vf_tc_bw_result,
14669 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
14670 TOKEN_NUM_INITIALIZER
14671 (struct cmd_vf_tc_bw_result,
14673 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
14674 TOKEN_NUM_INITIALIZER
14675 (struct cmd_vf_tc_bw_result,
14677 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
14678 TOKEN_STRING_INITIALIZER
14679 (struct cmd_vf_tc_bw_result,
14681 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
14682 TOKEN_NUM_INITIALIZER
14683 (struct cmd_vf_tc_bw_result,
14686 /* VF max bandwidth setting */
14688 cmd_vf_max_bw_parsed(
14689 void *parsed_result,
14690 __attribute__((unused)) struct cmdline *cl,
14691 __attribute__((unused)) void *data)
14693 struct cmd_vf_tc_bw_result *res = parsed_result;
14694 int ret = -ENOTSUP;
14696 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14699 #ifdef RTE_LIBRTE_I40E_PMD
14700 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
14701 res->vf_id, res->bw);
14708 printf("invalid vf_id %d or bandwidth %d\n",
14709 res->vf_id, res->bw);
14712 printf("invalid port_id %d\n", res->port_id);
14715 printf("function not implemented\n");
14718 printf("programming error: (%s)\n", strerror(-ret));
14722 cmdline_parse_inst_t cmd_vf_max_bw = {
14723 .f = cmd_vf_max_bw_parsed,
14725 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
14727 (void *)&cmd_vf_tc_bw_set,
14728 (void *)&cmd_vf_tc_bw_vf,
14729 (void *)&cmd_vf_tc_bw_tx,
14730 (void *)&cmd_vf_tc_bw_max_bw,
14731 (void *)&cmd_vf_tc_bw_port_id,
14732 (void *)&cmd_vf_tc_bw_vf_id,
14733 (void *)&cmd_vf_tc_bw_bw,
14739 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
14744 const char *p, *p0 = str;
14751 p = strchr(p0, '(');
14753 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14757 p0 = strchr(p, ')');
14759 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14763 if (size >= sizeof(s)) {
14764 printf("The string size exceeds the internal buffer size\n");
14767 snprintf(s, sizeof(s), "%.*s", size, p);
14768 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
14770 printf("Failed to get the bandwidth list. ");
14774 for (i = 0; i < ret; i++)
14775 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
14780 /* TC min bandwidth setting */
14782 cmd_vf_tc_min_bw_parsed(
14783 void *parsed_result,
14784 __attribute__((unused)) struct cmdline *cl,
14785 __attribute__((unused)) void *data)
14787 struct cmd_vf_tc_bw_result *res = parsed_result;
14790 int ret = -ENOTSUP;
14792 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14795 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
14799 #ifdef RTE_LIBRTE_I40E_PMD
14800 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
14808 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
14811 printf("invalid port_id %d\n", res->port_id);
14814 printf("function not implemented\n");
14817 printf("programming error: (%s)\n", strerror(-ret));
14821 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
14822 .f = cmd_vf_tc_min_bw_parsed,
14824 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
14825 " <bw1, bw2, ...>",
14827 (void *)&cmd_vf_tc_bw_set,
14828 (void *)&cmd_vf_tc_bw_vf,
14829 (void *)&cmd_vf_tc_bw_tc,
14830 (void *)&cmd_vf_tc_bw_tx,
14831 (void *)&cmd_vf_tc_bw_min_bw,
14832 (void *)&cmd_vf_tc_bw_port_id,
14833 (void *)&cmd_vf_tc_bw_vf_id,
14834 (void *)&cmd_vf_tc_bw_bw_list,
14840 cmd_tc_min_bw_parsed(
14841 void *parsed_result,
14842 __attribute__((unused)) struct cmdline *cl,
14843 __attribute__((unused)) void *data)
14845 struct cmd_vf_tc_bw_result *res = parsed_result;
14846 struct rte_port *port;
14849 int ret = -ENOTSUP;
14851 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14854 port = &ports[res->port_id];
14855 /** Check if the port is not started **/
14856 if (port->port_status != RTE_PORT_STOPPED) {
14857 printf("Please stop port %d first\n", res->port_id);
14861 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
14865 #ifdef RTE_LIBRTE_IXGBE_PMD
14866 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
14873 printf("invalid bandwidth\n");
14876 printf("invalid port_id %d\n", res->port_id);
14879 printf("function not implemented\n");
14882 printf("programming error: (%s)\n", strerror(-ret));
14886 cmdline_parse_inst_t cmd_tc_min_bw = {
14887 .f = cmd_tc_min_bw_parsed,
14889 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
14891 (void *)&cmd_vf_tc_bw_set,
14892 (void *)&cmd_vf_tc_bw_tc,
14893 (void *)&cmd_vf_tc_bw_tx,
14894 (void *)&cmd_vf_tc_bw_min_bw,
14895 (void *)&cmd_vf_tc_bw_port_id,
14896 (void *)&cmd_vf_tc_bw_bw_list,
14901 /* TC max bandwidth setting */
14903 cmd_vf_tc_max_bw_parsed(
14904 void *parsed_result,
14905 __attribute__((unused)) struct cmdline *cl,
14906 __attribute__((unused)) void *data)
14908 struct cmd_vf_tc_bw_result *res = parsed_result;
14909 int ret = -ENOTSUP;
14911 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14914 #ifdef RTE_LIBRTE_I40E_PMD
14915 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
14916 res->tc_no, res->bw);
14923 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
14924 res->vf_id, res->tc_no, res->bw);
14927 printf("invalid port_id %d\n", res->port_id);
14930 printf("function not implemented\n");
14933 printf("programming error: (%s)\n", strerror(-ret));
14937 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
14938 .f = cmd_vf_tc_max_bw_parsed,
14940 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
14943 (void *)&cmd_vf_tc_bw_set,
14944 (void *)&cmd_vf_tc_bw_vf,
14945 (void *)&cmd_vf_tc_bw_tc,
14946 (void *)&cmd_vf_tc_bw_tx,
14947 (void *)&cmd_vf_tc_bw_max_bw,
14948 (void *)&cmd_vf_tc_bw_port_id,
14949 (void *)&cmd_vf_tc_bw_vf_id,
14950 (void *)&cmd_vf_tc_bw_tc_no,
14951 (void *)&cmd_vf_tc_bw_bw,
14957 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
14959 /* *** Set Port default Traffic Management Hierarchy *** */
14960 struct cmd_set_port_tm_hierarchy_default_result {
14961 cmdline_fixed_string_t set;
14962 cmdline_fixed_string_t port;
14963 cmdline_fixed_string_t tm;
14964 cmdline_fixed_string_t hierarchy;
14965 cmdline_fixed_string_t def;
14969 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_set =
14970 TOKEN_STRING_INITIALIZER(
14971 struct cmd_set_port_tm_hierarchy_default_result, set, "set");
14972 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_port =
14973 TOKEN_STRING_INITIALIZER(
14974 struct cmd_set_port_tm_hierarchy_default_result, port, "port");
14975 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_tm =
14976 TOKEN_STRING_INITIALIZER(
14977 struct cmd_set_port_tm_hierarchy_default_result, tm, "tm");
14978 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_hierarchy =
14979 TOKEN_STRING_INITIALIZER(
14980 struct cmd_set_port_tm_hierarchy_default_result,
14981 hierarchy, "hierarchy");
14982 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_default =
14983 TOKEN_STRING_INITIALIZER(
14984 struct cmd_set_port_tm_hierarchy_default_result,
14986 cmdline_parse_token_num_t cmd_set_port_tm_hierarchy_default_port_id =
14987 TOKEN_NUM_INITIALIZER(
14988 struct cmd_set_port_tm_hierarchy_default_result,
14991 static void cmd_set_port_tm_hierarchy_default_parsed(void *parsed_result,
14992 __attribute__((unused)) struct cmdline *cl,
14993 __attribute__((unused)) void *data)
14995 struct cmd_set_port_tm_hierarchy_default_result *res = parsed_result;
14996 struct rte_port *p;
14997 portid_t port_id = res->port_id;
14999 if (port_id_is_invalid(port_id, ENABLED_WARN))
15002 p = &ports[port_id];
15004 /* Forward mode: tm */
15005 if (strcmp(cur_fwd_config.fwd_eng->fwd_mode_name, "softnic")) {
15006 printf(" softnicfwd mode not enabled(error)\n");
15010 /* Set the default tm hierarchy */
15011 p->softport.default_tm_hierarchy_enable = 1;
15014 cmdline_parse_inst_t cmd_set_port_tm_hierarchy_default = {
15015 .f = cmd_set_port_tm_hierarchy_default_parsed,
15017 .help_str = "set port tm hierarchy default <port_id>",
15019 (void *)&cmd_set_port_tm_hierarchy_default_set,
15020 (void *)&cmd_set_port_tm_hierarchy_default_port,
15021 (void *)&cmd_set_port_tm_hierarchy_default_tm,
15022 (void *)&cmd_set_port_tm_hierarchy_default_hierarchy,
15023 (void *)&cmd_set_port_tm_hierarchy_default_default,
15024 (void *)&cmd_set_port_tm_hierarchy_default_port_id,
15030 /** Set VXLAN encapsulation details */
15031 struct cmd_set_vxlan_result {
15032 cmdline_fixed_string_t set;
15033 cmdline_fixed_string_t vxlan;
15034 cmdline_fixed_string_t pos_token;
15035 cmdline_fixed_string_t ip_version;
15036 uint32_t vlan_present:1;
15040 cmdline_ipaddr_t ip_src;
15041 cmdline_ipaddr_t ip_dst;
15045 struct ether_addr eth_src;
15046 struct ether_addr eth_dst;
15049 cmdline_parse_token_string_t cmd_set_vxlan_set =
15050 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
15051 cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
15052 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
15053 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
15054 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15056 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
15057 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15058 "vxlan-with-vlan");
15059 cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
15060 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15062 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
15063 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
15065 cmdline_parse_token_string_t cmd_set_vxlan_vni =
15066 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15068 cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
15069 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, UINT32);
15070 cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
15071 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15073 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
15074 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, UINT16);
15075 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
15076 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15078 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
15079 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, UINT16);
15080 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
15081 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15083 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
15084 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, UINT8);
15085 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
15086 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15088 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
15089 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, UINT8);
15090 cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
15091 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15093 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
15094 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
15095 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
15096 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15098 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
15099 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
15100 cmdline_parse_token_string_t cmd_set_vxlan_vlan =
15101 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15103 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
15104 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, UINT16);
15105 cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
15106 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15108 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
15109 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
15110 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
15111 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15113 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
15114 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
15116 static void cmd_set_vxlan_parsed(void *parsed_result,
15117 __attribute__((unused)) struct cmdline *cl,
15118 __attribute__((unused)) void *data)
15120 struct cmd_set_vxlan_result *res = parsed_result;
15125 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
15128 vxlan_encap_conf.select_tos_ttl = 0;
15129 if (strcmp(res->vxlan, "vxlan") == 0)
15130 vxlan_encap_conf.select_vlan = 0;
15131 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
15132 vxlan_encap_conf.select_vlan = 1;
15133 else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
15134 vxlan_encap_conf.select_vlan = 0;
15135 vxlan_encap_conf.select_tos_ttl = 1;
15137 if (strcmp(res->ip_version, "ipv4") == 0)
15138 vxlan_encap_conf.select_ipv4 = 1;
15139 else if (strcmp(res->ip_version, "ipv6") == 0)
15140 vxlan_encap_conf.select_ipv4 = 0;
15143 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
15144 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
15145 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
15146 vxlan_encap_conf.ip_tos = res->tos;
15147 vxlan_encap_conf.ip_ttl = res->ttl;
15148 if (vxlan_encap_conf.select_ipv4) {
15149 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
15150 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
15152 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
15153 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
15155 if (vxlan_encap_conf.select_vlan)
15156 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15157 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
15159 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15163 cmdline_parse_inst_t cmd_set_vxlan = {
15164 .f = cmd_set_vxlan_parsed,
15166 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
15167 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
15168 " eth-src <eth-src> eth-dst <eth-dst>",
15170 (void *)&cmd_set_vxlan_set,
15171 (void *)&cmd_set_vxlan_vxlan,
15172 (void *)&cmd_set_vxlan_ip_version,
15173 (void *)&cmd_set_vxlan_ip_version_value,
15174 (void *)&cmd_set_vxlan_vni,
15175 (void *)&cmd_set_vxlan_vni_value,
15176 (void *)&cmd_set_vxlan_udp_src,
15177 (void *)&cmd_set_vxlan_udp_src_value,
15178 (void *)&cmd_set_vxlan_udp_dst,
15179 (void *)&cmd_set_vxlan_udp_dst_value,
15180 (void *)&cmd_set_vxlan_ip_src,
15181 (void *)&cmd_set_vxlan_ip_src_value,
15182 (void *)&cmd_set_vxlan_ip_dst,
15183 (void *)&cmd_set_vxlan_ip_dst_value,
15184 (void *)&cmd_set_vxlan_eth_src,
15185 (void *)&cmd_set_vxlan_eth_src_value,
15186 (void *)&cmd_set_vxlan_eth_dst,
15187 (void *)&cmd_set_vxlan_eth_dst_value,
15192 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
15193 .f = cmd_set_vxlan_parsed,
15195 .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
15196 " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
15197 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15198 " eth-dst <eth-dst>",
15200 (void *)&cmd_set_vxlan_set,
15201 (void *)&cmd_set_vxlan_vxlan_tos_ttl,
15202 (void *)&cmd_set_vxlan_ip_version,
15203 (void *)&cmd_set_vxlan_ip_version_value,
15204 (void *)&cmd_set_vxlan_vni,
15205 (void *)&cmd_set_vxlan_vni_value,
15206 (void *)&cmd_set_vxlan_udp_src,
15207 (void *)&cmd_set_vxlan_udp_src_value,
15208 (void *)&cmd_set_vxlan_udp_dst,
15209 (void *)&cmd_set_vxlan_udp_dst_value,
15210 (void *)&cmd_set_vxlan_ip_tos,
15211 (void *)&cmd_set_vxlan_ip_tos_value,
15212 (void *)&cmd_set_vxlan_ip_ttl,
15213 (void *)&cmd_set_vxlan_ip_ttl_value,
15214 (void *)&cmd_set_vxlan_ip_src,
15215 (void *)&cmd_set_vxlan_ip_src_value,
15216 (void *)&cmd_set_vxlan_ip_dst,
15217 (void *)&cmd_set_vxlan_ip_dst_value,
15218 (void *)&cmd_set_vxlan_eth_src,
15219 (void *)&cmd_set_vxlan_eth_src_value,
15220 (void *)&cmd_set_vxlan_eth_dst,
15221 (void *)&cmd_set_vxlan_eth_dst_value,
15226 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
15227 .f = cmd_set_vxlan_parsed,
15229 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
15230 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
15231 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
15234 (void *)&cmd_set_vxlan_set,
15235 (void *)&cmd_set_vxlan_vxlan_with_vlan,
15236 (void *)&cmd_set_vxlan_ip_version,
15237 (void *)&cmd_set_vxlan_ip_version_value,
15238 (void *)&cmd_set_vxlan_vni,
15239 (void *)&cmd_set_vxlan_vni_value,
15240 (void *)&cmd_set_vxlan_udp_src,
15241 (void *)&cmd_set_vxlan_udp_src_value,
15242 (void *)&cmd_set_vxlan_udp_dst,
15243 (void *)&cmd_set_vxlan_udp_dst_value,
15244 (void *)&cmd_set_vxlan_ip_src,
15245 (void *)&cmd_set_vxlan_ip_src_value,
15246 (void *)&cmd_set_vxlan_ip_dst,
15247 (void *)&cmd_set_vxlan_ip_dst_value,
15248 (void *)&cmd_set_vxlan_vlan,
15249 (void *)&cmd_set_vxlan_vlan_value,
15250 (void *)&cmd_set_vxlan_eth_src,
15251 (void *)&cmd_set_vxlan_eth_src_value,
15252 (void *)&cmd_set_vxlan_eth_dst,
15253 (void *)&cmd_set_vxlan_eth_dst_value,
15258 /** Set NVGRE encapsulation details */
15259 struct cmd_set_nvgre_result {
15260 cmdline_fixed_string_t set;
15261 cmdline_fixed_string_t nvgre;
15262 cmdline_fixed_string_t pos_token;
15263 cmdline_fixed_string_t ip_version;
15265 cmdline_ipaddr_t ip_src;
15266 cmdline_ipaddr_t ip_dst;
15268 struct ether_addr eth_src;
15269 struct ether_addr eth_dst;
15272 cmdline_parse_token_string_t cmd_set_nvgre_set =
15273 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
15274 cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
15275 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
15276 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
15277 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
15278 "nvgre-with-vlan");
15279 cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
15280 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15282 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
15283 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
15285 cmdline_parse_token_string_t cmd_set_nvgre_tni =
15286 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15288 cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
15289 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, UINT32);
15290 cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
15291 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15293 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
15294 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
15295 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
15296 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15298 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
15299 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
15300 cmdline_parse_token_string_t cmd_set_nvgre_vlan =
15301 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15303 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
15304 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, UINT16);
15305 cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
15306 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15308 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
15309 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
15310 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
15311 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15313 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
15314 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
15316 static void cmd_set_nvgre_parsed(void *parsed_result,
15317 __attribute__((unused)) struct cmdline *cl,
15318 __attribute__((unused)) void *data)
15320 struct cmd_set_nvgre_result *res = parsed_result;
15322 uint32_t nvgre_tni;
15325 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
15328 if (strcmp(res->nvgre, "nvgre") == 0)
15329 nvgre_encap_conf.select_vlan = 0;
15330 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
15331 nvgre_encap_conf.select_vlan = 1;
15332 if (strcmp(res->ip_version, "ipv4") == 0)
15333 nvgre_encap_conf.select_ipv4 = 1;
15334 else if (strcmp(res->ip_version, "ipv6") == 0)
15335 nvgre_encap_conf.select_ipv4 = 0;
15338 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
15339 if (nvgre_encap_conf.select_ipv4) {
15340 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
15341 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
15343 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
15344 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
15346 if (nvgre_encap_conf.select_vlan)
15347 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15348 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
15350 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15354 cmdline_parse_inst_t cmd_set_nvgre = {
15355 .f = cmd_set_nvgre_parsed,
15357 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
15358 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15359 " eth-dst <eth-dst>",
15361 (void *)&cmd_set_nvgre_set,
15362 (void *)&cmd_set_nvgre_nvgre,
15363 (void *)&cmd_set_nvgre_ip_version,
15364 (void *)&cmd_set_nvgre_ip_version_value,
15365 (void *)&cmd_set_nvgre_tni,
15366 (void *)&cmd_set_nvgre_tni_value,
15367 (void *)&cmd_set_nvgre_ip_src,
15368 (void *)&cmd_set_nvgre_ip_src_value,
15369 (void *)&cmd_set_nvgre_ip_dst,
15370 (void *)&cmd_set_nvgre_ip_dst_value,
15371 (void *)&cmd_set_nvgre_eth_src,
15372 (void *)&cmd_set_nvgre_eth_src_value,
15373 (void *)&cmd_set_nvgre_eth_dst,
15374 (void *)&cmd_set_nvgre_eth_dst_value,
15379 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
15380 .f = cmd_set_nvgre_parsed,
15382 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
15383 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
15384 " eth-src <eth-src> eth-dst <eth-dst>",
15386 (void *)&cmd_set_nvgre_set,
15387 (void *)&cmd_set_nvgre_nvgre_with_vlan,
15388 (void *)&cmd_set_nvgre_ip_version,
15389 (void *)&cmd_set_nvgre_ip_version_value,
15390 (void *)&cmd_set_nvgre_tni,
15391 (void *)&cmd_set_nvgre_tni_value,
15392 (void *)&cmd_set_nvgre_ip_src,
15393 (void *)&cmd_set_nvgre_ip_src_value,
15394 (void *)&cmd_set_nvgre_ip_dst,
15395 (void *)&cmd_set_nvgre_ip_dst_value,
15396 (void *)&cmd_set_nvgre_vlan,
15397 (void *)&cmd_set_nvgre_vlan_value,
15398 (void *)&cmd_set_nvgre_eth_src,
15399 (void *)&cmd_set_nvgre_eth_src_value,
15400 (void *)&cmd_set_nvgre_eth_dst,
15401 (void *)&cmd_set_nvgre_eth_dst_value,
15406 /** Set L2 encapsulation details */
15407 struct cmd_set_l2_encap_result {
15408 cmdline_fixed_string_t set;
15409 cmdline_fixed_string_t l2_encap;
15410 cmdline_fixed_string_t pos_token;
15411 cmdline_fixed_string_t ip_version;
15412 uint32_t vlan_present:1;
15414 struct ether_addr eth_src;
15415 struct ether_addr eth_dst;
15418 cmdline_parse_token_string_t cmd_set_l2_encap_set =
15419 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
15420 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
15421 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
15422 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
15423 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
15424 "l2_encap-with-vlan");
15425 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
15426 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15428 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
15429 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
15431 cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
15432 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15434 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
15435 TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, UINT16);
15436 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
15437 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15439 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
15440 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
15441 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
15442 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15444 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
15445 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
15447 static void cmd_set_l2_encap_parsed(void *parsed_result,
15448 __attribute__((unused)) struct cmdline *cl,
15449 __attribute__((unused)) void *data)
15451 struct cmd_set_l2_encap_result *res = parsed_result;
15453 if (strcmp(res->l2_encap, "l2_encap") == 0)
15454 l2_encap_conf.select_vlan = 0;
15455 else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
15456 l2_encap_conf.select_vlan = 1;
15457 if (strcmp(res->ip_version, "ipv4") == 0)
15458 l2_encap_conf.select_ipv4 = 1;
15459 else if (strcmp(res->ip_version, "ipv6") == 0)
15460 l2_encap_conf.select_ipv4 = 0;
15463 if (l2_encap_conf.select_vlan)
15464 l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15465 rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
15467 rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15471 cmdline_parse_inst_t cmd_set_l2_encap = {
15472 .f = cmd_set_l2_encap_parsed,
15474 .help_str = "set l2_encap ip-version ipv4|ipv6"
15475 " eth-src <eth-src> eth-dst <eth-dst>",
15477 (void *)&cmd_set_l2_encap_set,
15478 (void *)&cmd_set_l2_encap_l2_encap,
15479 (void *)&cmd_set_l2_encap_ip_version,
15480 (void *)&cmd_set_l2_encap_ip_version_value,
15481 (void *)&cmd_set_l2_encap_eth_src,
15482 (void *)&cmd_set_l2_encap_eth_src_value,
15483 (void *)&cmd_set_l2_encap_eth_dst,
15484 (void *)&cmd_set_l2_encap_eth_dst_value,
15489 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
15490 .f = cmd_set_l2_encap_parsed,
15492 .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
15493 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
15495 (void *)&cmd_set_l2_encap_set,
15496 (void *)&cmd_set_l2_encap_l2_encap_with_vlan,
15497 (void *)&cmd_set_l2_encap_ip_version,
15498 (void *)&cmd_set_l2_encap_ip_version_value,
15499 (void *)&cmd_set_l2_encap_vlan,
15500 (void *)&cmd_set_l2_encap_vlan_value,
15501 (void *)&cmd_set_l2_encap_eth_src,
15502 (void *)&cmd_set_l2_encap_eth_src_value,
15503 (void *)&cmd_set_l2_encap_eth_dst,
15504 (void *)&cmd_set_l2_encap_eth_dst_value,
15509 /** Set L2 decapsulation details */
15510 struct cmd_set_l2_decap_result {
15511 cmdline_fixed_string_t set;
15512 cmdline_fixed_string_t l2_decap;
15513 cmdline_fixed_string_t pos_token;
15514 uint32_t vlan_present:1;
15517 cmdline_parse_token_string_t cmd_set_l2_decap_set =
15518 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
15519 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
15520 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
15522 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
15523 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
15524 "l2_decap-with-vlan");
15526 static void cmd_set_l2_decap_parsed(void *parsed_result,
15527 __attribute__((unused)) struct cmdline *cl,
15528 __attribute__((unused)) void *data)
15530 struct cmd_set_l2_decap_result *res = parsed_result;
15532 if (strcmp(res->l2_decap, "l2_decap") == 0)
15533 l2_decap_conf.select_vlan = 0;
15534 else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
15535 l2_decap_conf.select_vlan = 1;
15538 cmdline_parse_inst_t cmd_set_l2_decap = {
15539 .f = cmd_set_l2_decap_parsed,
15541 .help_str = "set l2_decap",
15543 (void *)&cmd_set_l2_decap_set,
15544 (void *)&cmd_set_l2_decap_l2_decap,
15549 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
15550 .f = cmd_set_l2_decap_parsed,
15552 .help_str = "set l2_decap-with-vlan",
15554 (void *)&cmd_set_l2_decap_set,
15555 (void *)&cmd_set_l2_decap_l2_decap_with_vlan,
15560 /** Set MPLSoGRE encapsulation details */
15561 struct cmd_set_mplsogre_encap_result {
15562 cmdline_fixed_string_t set;
15563 cmdline_fixed_string_t mplsogre;
15564 cmdline_fixed_string_t pos_token;
15565 cmdline_fixed_string_t ip_version;
15566 uint32_t vlan_present:1;
15568 cmdline_ipaddr_t ip_src;
15569 cmdline_ipaddr_t ip_dst;
15571 struct ether_addr eth_src;
15572 struct ether_addr eth_dst;
15575 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
15576 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
15578 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
15579 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
15581 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
15582 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15583 mplsogre, "mplsogre_encap-with-vlan");
15584 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
15585 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15586 pos_token, "ip-version");
15587 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
15588 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15589 ip_version, "ipv4#ipv6");
15590 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
15591 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15592 pos_token, "label");
15593 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
15594 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
15596 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
15597 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15598 pos_token, "ip-src");
15599 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
15600 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
15601 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
15602 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15603 pos_token, "ip-dst");
15604 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
15605 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
15606 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
15607 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15608 pos_token, "vlan-tci");
15609 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
15610 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
15612 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
15613 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15614 pos_token, "eth-src");
15615 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
15616 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15618 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
15619 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15620 pos_token, "eth-dst");
15621 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
15622 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15625 static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
15626 __attribute__((unused)) struct cmdline *cl,
15627 __attribute__((unused)) void *data)
15629 struct cmd_set_mplsogre_encap_result *res = parsed_result;
15631 uint32_t mplsogre_label;
15634 .mplsogre_label = rte_cpu_to_be_32(res->label<<12),
15637 if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
15638 mplsogre_encap_conf.select_vlan = 0;
15639 else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
15640 mplsogre_encap_conf.select_vlan = 1;
15641 if (strcmp(res->ip_version, "ipv4") == 0)
15642 mplsogre_encap_conf.select_ipv4 = 1;
15643 else if (strcmp(res->ip_version, "ipv6") == 0)
15644 mplsogre_encap_conf.select_ipv4 = 0;
15647 rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
15648 if (mplsogre_encap_conf.select_ipv4) {
15649 IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
15650 IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
15652 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
15653 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
15655 if (mplsogre_encap_conf.select_vlan)
15656 mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15657 rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
15659 rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15663 cmdline_parse_inst_t cmd_set_mplsogre_encap = {
15664 .f = cmd_set_mplsogre_encap_parsed,
15666 .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
15667 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15668 " eth-dst <eth-dst>",
15670 (void *)&cmd_set_mplsogre_encap_set,
15671 (void *)&cmd_set_mplsogre_encap_mplsogre_encap,
15672 (void *)&cmd_set_mplsogre_encap_ip_version,
15673 (void *)&cmd_set_mplsogre_encap_ip_version_value,
15674 (void *)&cmd_set_mplsogre_encap_label,
15675 (void *)&cmd_set_mplsogre_encap_label_value,
15676 (void *)&cmd_set_mplsogre_encap_ip_src,
15677 (void *)&cmd_set_mplsogre_encap_ip_src_value,
15678 (void *)&cmd_set_mplsogre_encap_ip_dst,
15679 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
15680 (void *)&cmd_set_mplsogre_encap_eth_src,
15681 (void *)&cmd_set_mplsogre_encap_eth_src_value,
15682 (void *)&cmd_set_mplsogre_encap_eth_dst,
15683 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
15688 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
15689 .f = cmd_set_mplsogre_encap_parsed,
15691 .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
15692 " label <label> ip-src <ip-src> ip-dst <ip-dst>"
15693 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
15695 (void *)&cmd_set_mplsogre_encap_set,
15696 (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
15697 (void *)&cmd_set_mplsogre_encap_ip_version,
15698 (void *)&cmd_set_mplsogre_encap_ip_version_value,
15699 (void *)&cmd_set_mplsogre_encap_label,
15700 (void *)&cmd_set_mplsogre_encap_label_value,
15701 (void *)&cmd_set_mplsogre_encap_ip_src,
15702 (void *)&cmd_set_mplsogre_encap_ip_src_value,
15703 (void *)&cmd_set_mplsogre_encap_ip_dst,
15704 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
15705 (void *)&cmd_set_mplsogre_encap_vlan,
15706 (void *)&cmd_set_mplsogre_encap_vlan_value,
15707 (void *)&cmd_set_mplsogre_encap_eth_src,
15708 (void *)&cmd_set_mplsogre_encap_eth_src_value,
15709 (void *)&cmd_set_mplsogre_encap_eth_dst,
15710 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
15715 /** Set MPLSoGRE decapsulation details */
15716 struct cmd_set_mplsogre_decap_result {
15717 cmdline_fixed_string_t set;
15718 cmdline_fixed_string_t mplsogre;
15719 cmdline_fixed_string_t pos_token;
15720 cmdline_fixed_string_t ip_version;
15721 uint32_t vlan_present:1;
15724 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
15725 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
15727 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
15728 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
15730 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
15731 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
15732 mplsogre, "mplsogre_decap-with-vlan");
15733 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
15734 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
15735 pos_token, "ip-version");
15736 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
15737 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
15738 ip_version, "ipv4#ipv6");
15740 static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
15741 __attribute__((unused)) struct cmdline *cl,
15742 __attribute__((unused)) void *data)
15744 struct cmd_set_mplsogre_decap_result *res = parsed_result;
15746 if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
15747 mplsogre_decap_conf.select_vlan = 0;
15748 else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
15749 mplsogre_decap_conf.select_vlan = 1;
15750 if (strcmp(res->ip_version, "ipv4") == 0)
15751 mplsogre_decap_conf.select_ipv4 = 1;
15752 else if (strcmp(res->ip_version, "ipv6") == 0)
15753 mplsogre_decap_conf.select_ipv4 = 0;
15756 cmdline_parse_inst_t cmd_set_mplsogre_decap = {
15757 .f = cmd_set_mplsogre_decap_parsed,
15759 .help_str = "set mplsogre_decap ip-version ipv4|ipv6",
15761 (void *)&cmd_set_mplsogre_decap_set,
15762 (void *)&cmd_set_mplsogre_decap_mplsogre_decap,
15763 (void *)&cmd_set_mplsogre_decap_ip_version,
15764 (void *)&cmd_set_mplsogre_decap_ip_version_value,
15769 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
15770 .f = cmd_set_mplsogre_decap_parsed,
15772 .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
15774 (void *)&cmd_set_mplsogre_decap_set,
15775 (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
15776 (void *)&cmd_set_mplsogre_decap_ip_version,
15777 (void *)&cmd_set_mplsogre_decap_ip_version_value,
15782 /** Set MPLSoUDP encapsulation details */
15783 struct cmd_set_mplsoudp_encap_result {
15784 cmdline_fixed_string_t set;
15785 cmdline_fixed_string_t mplsoudp;
15786 cmdline_fixed_string_t pos_token;
15787 cmdline_fixed_string_t ip_version;
15788 uint32_t vlan_present:1;
15792 cmdline_ipaddr_t ip_src;
15793 cmdline_ipaddr_t ip_dst;
15795 struct ether_addr eth_src;
15796 struct ether_addr eth_dst;
15799 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
15800 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
15802 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
15803 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
15805 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
15806 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15807 mplsoudp, "mplsoudp_encap-with-vlan");
15808 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
15809 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15810 pos_token, "ip-version");
15811 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
15812 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15813 ip_version, "ipv4#ipv6");
15814 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
15815 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15816 pos_token, "label");
15817 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
15818 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
15820 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
15821 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15822 pos_token, "udp-src");
15823 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
15824 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
15826 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
15827 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15828 pos_token, "udp-dst");
15829 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
15830 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
15832 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
15833 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15834 pos_token, "ip-src");
15835 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
15836 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
15837 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
15838 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15839 pos_token, "ip-dst");
15840 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
15841 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
15842 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
15843 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15844 pos_token, "vlan-tci");
15845 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
15846 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
15848 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
15849 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15850 pos_token, "eth-src");
15851 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
15852 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15854 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
15855 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15856 pos_token, "eth-dst");
15857 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
15858 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15861 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
15862 __attribute__((unused)) struct cmdline *cl,
15863 __attribute__((unused)) void *data)
15865 struct cmd_set_mplsoudp_encap_result *res = parsed_result;
15867 uint32_t mplsoudp_label;
15870 .mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
15873 if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
15874 mplsoudp_encap_conf.select_vlan = 0;
15875 else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
15876 mplsoudp_encap_conf.select_vlan = 1;
15877 if (strcmp(res->ip_version, "ipv4") == 0)
15878 mplsoudp_encap_conf.select_ipv4 = 1;
15879 else if (strcmp(res->ip_version, "ipv6") == 0)
15880 mplsoudp_encap_conf.select_ipv4 = 0;
15883 rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
15884 mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
15885 mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
15886 if (mplsoudp_encap_conf.select_ipv4) {
15887 IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
15888 IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
15890 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
15891 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
15893 if (mplsoudp_encap_conf.select_vlan)
15894 mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15895 rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
15897 rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15901 cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
15902 .f = cmd_set_mplsoudp_encap_parsed,
15904 .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
15905 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
15906 " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
15908 (void *)&cmd_set_mplsoudp_encap_set,
15909 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
15910 (void *)&cmd_set_mplsoudp_encap_ip_version,
15911 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
15912 (void *)&cmd_set_mplsoudp_encap_label,
15913 (void *)&cmd_set_mplsoudp_encap_label_value,
15914 (void *)&cmd_set_mplsoudp_encap_udp_src,
15915 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
15916 (void *)&cmd_set_mplsoudp_encap_udp_dst,
15917 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
15918 (void *)&cmd_set_mplsoudp_encap_ip_src,
15919 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
15920 (void *)&cmd_set_mplsoudp_encap_ip_dst,
15921 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
15922 (void *)&cmd_set_mplsoudp_encap_eth_src,
15923 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
15924 (void *)&cmd_set_mplsoudp_encap_eth_dst,
15925 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
15930 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
15931 .f = cmd_set_mplsoudp_encap_parsed,
15933 .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
15934 " label <label> udp-src <udp-src> udp-dst <udp-dst>"
15935 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
15936 " eth-src <eth-src> eth-dst <eth-dst>",
15938 (void *)&cmd_set_mplsoudp_encap_set,
15939 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
15940 (void *)&cmd_set_mplsoudp_encap_ip_version,
15941 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
15942 (void *)&cmd_set_mplsoudp_encap_label,
15943 (void *)&cmd_set_mplsoudp_encap_label_value,
15944 (void *)&cmd_set_mplsoudp_encap_udp_src,
15945 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
15946 (void *)&cmd_set_mplsoudp_encap_udp_dst,
15947 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
15948 (void *)&cmd_set_mplsoudp_encap_ip_src,
15949 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
15950 (void *)&cmd_set_mplsoudp_encap_ip_dst,
15951 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
15952 (void *)&cmd_set_mplsoudp_encap_vlan,
15953 (void *)&cmd_set_mplsoudp_encap_vlan_value,
15954 (void *)&cmd_set_mplsoudp_encap_eth_src,
15955 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
15956 (void *)&cmd_set_mplsoudp_encap_eth_dst,
15957 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
15962 /** Set MPLSoUDP decapsulation details */
15963 struct cmd_set_mplsoudp_decap_result {
15964 cmdline_fixed_string_t set;
15965 cmdline_fixed_string_t mplsoudp;
15966 cmdline_fixed_string_t pos_token;
15967 cmdline_fixed_string_t ip_version;
15968 uint32_t vlan_present:1;
15971 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
15972 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
15974 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
15975 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
15977 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
15978 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
15979 mplsoudp, "mplsoudp_decap-with-vlan");
15980 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
15981 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
15982 pos_token, "ip-version");
15983 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
15984 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
15985 ip_version, "ipv4#ipv6");
15987 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
15988 __attribute__((unused)) struct cmdline *cl,
15989 __attribute__((unused)) void *data)
15991 struct cmd_set_mplsoudp_decap_result *res = parsed_result;
15993 if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
15994 mplsoudp_decap_conf.select_vlan = 0;
15995 else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
15996 mplsoudp_decap_conf.select_vlan = 1;
15997 if (strcmp(res->ip_version, "ipv4") == 0)
15998 mplsoudp_decap_conf.select_ipv4 = 1;
15999 else if (strcmp(res->ip_version, "ipv6") == 0)
16000 mplsoudp_decap_conf.select_ipv4 = 0;
16003 cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
16004 .f = cmd_set_mplsoudp_decap_parsed,
16006 .help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
16008 (void *)&cmd_set_mplsoudp_decap_set,
16009 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
16010 (void *)&cmd_set_mplsoudp_decap_ip_version,
16011 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
16016 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
16017 .f = cmd_set_mplsoudp_decap_parsed,
16019 .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
16021 (void *)&cmd_set_mplsoudp_decap_set,
16022 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
16023 (void *)&cmd_set_mplsoudp_decap_ip_version,
16024 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
16029 /* Strict link priority scheduling mode setting */
16031 cmd_strict_link_prio_parsed(
16032 void *parsed_result,
16033 __attribute__((unused)) struct cmdline *cl,
16034 __attribute__((unused)) void *data)
16036 struct cmd_vf_tc_bw_result *res = parsed_result;
16037 int ret = -ENOTSUP;
16039 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16042 #ifdef RTE_LIBRTE_I40E_PMD
16043 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
16050 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
16053 printf("invalid port_id %d\n", res->port_id);
16056 printf("function not implemented\n");
16059 printf("programming error: (%s)\n", strerror(-ret));
16063 cmdline_parse_inst_t cmd_strict_link_prio = {
16064 .f = cmd_strict_link_prio_parsed,
16066 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
16068 (void *)&cmd_vf_tc_bw_set,
16069 (void *)&cmd_vf_tc_bw_tx,
16070 (void *)&cmd_vf_tc_bw_strict_link_prio,
16071 (void *)&cmd_vf_tc_bw_port_id,
16072 (void *)&cmd_vf_tc_bw_tc_map,
16077 /* Load dynamic device personalization*/
16078 struct cmd_ddp_add_result {
16079 cmdline_fixed_string_t ddp;
16080 cmdline_fixed_string_t add;
16085 cmdline_parse_token_string_t cmd_ddp_add_ddp =
16086 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
16087 cmdline_parse_token_string_t cmd_ddp_add_add =
16088 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
16089 cmdline_parse_token_num_t cmd_ddp_add_port_id =
16090 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
16091 cmdline_parse_token_string_t cmd_ddp_add_filepath =
16092 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
16095 cmd_ddp_add_parsed(
16096 void *parsed_result,
16097 __attribute__((unused)) struct cmdline *cl,
16098 __attribute__((unused)) void *data)
16100 struct cmd_ddp_add_result *res = parsed_result;
16106 int ret = -ENOTSUP;
16108 if (!all_ports_stopped()) {
16109 printf("Please stop all ports first\n");
16113 filepath = strdup(res->filepath);
16114 if (filepath == NULL) {
16115 printf("Failed to allocate memory\n");
16118 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
16120 buff = open_file(file_fld[0], &size);
16122 free((void *)filepath);
16126 #ifdef RTE_LIBRTE_I40E_PMD
16127 if (ret == -ENOTSUP)
16128 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16130 RTE_PMD_I40E_PKG_OP_WR_ADD);
16133 if (ret == -EEXIST)
16134 printf("Profile has already existed.\n");
16136 printf("Failed to load profile.\n");
16137 else if (file_num == 2)
16138 save_file(file_fld[1], buff, size);
16141 free((void *)filepath);
16144 cmdline_parse_inst_t cmd_ddp_add = {
16145 .f = cmd_ddp_add_parsed,
16147 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
16149 (void *)&cmd_ddp_add_ddp,
16150 (void *)&cmd_ddp_add_add,
16151 (void *)&cmd_ddp_add_port_id,
16152 (void *)&cmd_ddp_add_filepath,
16157 /* Delete dynamic device personalization*/
16158 struct cmd_ddp_del_result {
16159 cmdline_fixed_string_t ddp;
16160 cmdline_fixed_string_t del;
16165 cmdline_parse_token_string_t cmd_ddp_del_ddp =
16166 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
16167 cmdline_parse_token_string_t cmd_ddp_del_del =
16168 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
16169 cmdline_parse_token_num_t cmd_ddp_del_port_id =
16170 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
16171 cmdline_parse_token_string_t cmd_ddp_del_filepath =
16172 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
16175 cmd_ddp_del_parsed(
16176 void *parsed_result,
16177 __attribute__((unused)) struct cmdline *cl,
16178 __attribute__((unused)) void *data)
16180 struct cmd_ddp_del_result *res = parsed_result;
16183 int ret = -ENOTSUP;
16185 if (!all_ports_stopped()) {
16186 printf("Please stop all ports first\n");
16190 buff = open_file(res->filepath, &size);
16194 #ifdef RTE_LIBRTE_I40E_PMD
16195 if (ret == -ENOTSUP)
16196 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16198 RTE_PMD_I40E_PKG_OP_WR_DEL);
16201 if (ret == -EACCES)
16202 printf("Profile does not exist.\n");
16204 printf("Failed to delete profile.\n");
16209 cmdline_parse_inst_t cmd_ddp_del = {
16210 .f = cmd_ddp_del_parsed,
16212 .help_str = "ddp del <port_id> <backup_profile_path>",
16214 (void *)&cmd_ddp_del_ddp,
16215 (void *)&cmd_ddp_del_del,
16216 (void *)&cmd_ddp_del_port_id,
16217 (void *)&cmd_ddp_del_filepath,
16222 /* Get dynamic device personalization profile info */
16223 struct cmd_ddp_info_result {
16224 cmdline_fixed_string_t ddp;
16225 cmdline_fixed_string_t get;
16226 cmdline_fixed_string_t info;
16230 cmdline_parse_token_string_t cmd_ddp_info_ddp =
16231 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
16232 cmdline_parse_token_string_t cmd_ddp_info_get =
16233 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
16234 cmdline_parse_token_string_t cmd_ddp_info_info =
16235 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
16236 cmdline_parse_token_string_t cmd_ddp_info_filepath =
16237 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
16240 cmd_ddp_info_parsed(
16241 void *parsed_result,
16242 __attribute__((unused)) struct cmdline *cl,
16243 __attribute__((unused)) void *data)
16245 struct cmd_ddp_info_result *res = parsed_result;
16248 int ret = -ENOTSUP;
16249 #ifdef RTE_LIBRTE_I40E_PMD
16252 uint32_t buff_size = 0;
16253 struct rte_pmd_i40e_profile_info info;
16254 uint32_t dev_num = 0;
16255 struct rte_pmd_i40e_ddp_device_id *devs;
16256 uint32_t proto_num = 0;
16257 struct rte_pmd_i40e_proto_info *proto = NULL;
16258 uint32_t pctype_num = 0;
16259 struct rte_pmd_i40e_ptype_info *pctype;
16260 uint32_t ptype_num = 0;
16261 struct rte_pmd_i40e_ptype_info *ptype;
16266 pkg = open_file(res->filepath, &pkg_size);
16270 #ifdef RTE_LIBRTE_I40E_PMD
16271 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16272 (uint8_t *)&info, sizeof(info),
16273 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
16275 printf("Global Track id: 0x%x\n", info.track_id);
16276 printf("Global Version: %d.%d.%d.%d\n",
16277 info.version.major,
16278 info.version.minor,
16279 info.version.update,
16280 info.version.draft);
16281 printf("Global Package name: %s\n\n", info.name);
16284 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16285 (uint8_t *)&info, sizeof(info),
16286 RTE_PMD_I40E_PKG_INFO_HEADER);
16288 printf("i40e Profile Track id: 0x%x\n", info.track_id);
16289 printf("i40e Profile Version: %d.%d.%d.%d\n",
16290 info.version.major,
16291 info.version.minor,
16292 info.version.update,
16293 info.version.draft);
16294 printf("i40e Profile name: %s\n\n", info.name);
16297 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16298 (uint8_t *)&buff_size, sizeof(buff_size),
16299 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
16300 if (!ret && buff_size) {
16301 buff = (uint8_t *)malloc(buff_size);
16303 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16305 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
16307 printf("Package Notes:\n%s\n\n", buff);
16312 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16313 (uint8_t *)&dev_num, sizeof(dev_num),
16314 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
16315 if (!ret && dev_num) {
16316 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
16317 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
16319 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16320 (uint8_t *)devs, buff_size,
16321 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
16323 printf("List of supported devices:\n");
16324 for (i = 0; i < dev_num; i++) {
16325 printf(" %04X:%04X %04X:%04X\n",
16326 devs[i].vendor_dev_id >> 16,
16327 devs[i].vendor_dev_id & 0xFFFF,
16328 devs[i].sub_vendor_dev_id >> 16,
16329 devs[i].sub_vendor_dev_id & 0xFFFF);
16337 /* get information about protocols and packet types */
16338 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16339 (uint8_t *)&proto_num, sizeof(proto_num),
16340 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
16341 if (ret || !proto_num)
16342 goto no_print_return;
16344 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
16345 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
16347 goto no_print_return;
16349 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
16351 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
16353 printf("List of used protocols:\n");
16354 for (i = 0; i < proto_num; i++)
16355 printf(" %2u: %s\n", proto[i].proto_id,
16359 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16360 (uint8_t *)&pctype_num, sizeof(pctype_num),
16361 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
16362 if (ret || !pctype_num)
16363 goto no_print_pctypes;
16365 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16366 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16368 goto no_print_pctypes;
16370 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
16372 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
16375 goto no_print_pctypes;
16378 printf("List of defined packet classification types:\n");
16379 for (i = 0; i < pctype_num; i++) {
16380 printf(" %2u:", pctype[i].ptype_id);
16381 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
16382 proto_id = pctype[i].protocols[j];
16383 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
16384 for (n = 0; n < proto_num; n++) {
16385 if (proto[n].proto_id == proto_id) {
16386 printf(" %s", proto[n].name);
16399 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
16401 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
16402 if (ret || !ptype_num)
16403 goto no_print_return;
16405 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16406 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16408 goto no_print_return;
16410 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
16412 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
16415 goto no_print_return;
16417 printf("List of defined packet types:\n");
16418 for (i = 0; i < ptype_num; i++) {
16419 printf(" %2u:", ptype[i].ptype_id);
16420 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
16421 proto_id = ptype[i].protocols[j];
16422 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
16423 for (n = 0; n < proto_num; n++) {
16424 if (proto[n].proto_id == proto_id) {
16425 printf(" %s", proto[n].name);
16441 if (ret == -ENOTSUP)
16442 printf("Function not supported in PMD driver\n");
16446 cmdline_parse_inst_t cmd_ddp_get_info = {
16447 .f = cmd_ddp_info_parsed,
16449 .help_str = "ddp get info <profile_path>",
16451 (void *)&cmd_ddp_info_ddp,
16452 (void *)&cmd_ddp_info_get,
16453 (void *)&cmd_ddp_info_info,
16454 (void *)&cmd_ddp_info_filepath,
16459 /* Get dynamic device personalization profile info list*/
16460 #define PROFILE_INFO_SIZE 48
16461 #define MAX_PROFILE_NUM 16
16463 struct cmd_ddp_get_list_result {
16464 cmdline_fixed_string_t ddp;
16465 cmdline_fixed_string_t get;
16466 cmdline_fixed_string_t list;
16470 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
16471 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
16472 cmdline_parse_token_string_t cmd_ddp_get_list_get =
16473 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
16474 cmdline_parse_token_string_t cmd_ddp_get_list_list =
16475 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
16476 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
16477 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
16480 cmd_ddp_get_list_parsed(
16481 __attribute__((unused)) void *parsed_result,
16482 __attribute__((unused)) struct cmdline *cl,
16483 __attribute__((unused)) void *data)
16485 #ifdef RTE_LIBRTE_I40E_PMD
16486 struct cmd_ddp_get_list_result *res = parsed_result;
16487 struct rte_pmd_i40e_profile_list *p_list;
16488 struct rte_pmd_i40e_profile_info *p_info;
16493 int ret = -ENOTSUP;
16495 #ifdef RTE_LIBRTE_I40E_PMD
16496 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
16497 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
16499 printf("%s: Failed to malloc buffer\n", __func__);
16501 if (ret == -ENOTSUP)
16502 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
16503 (uint8_t *)p_list, size);
16506 p_num = p_list->p_count;
16507 printf("Profile number is: %d\n\n", p_num);
16509 for (i = 0; i < p_num; i++) {
16510 p_info = &p_list->p_info[i];
16511 printf("Profile %d:\n", i);
16512 printf("Track id: 0x%x\n", p_info->track_id);
16513 printf("Version: %d.%d.%d.%d\n",
16514 p_info->version.major,
16515 p_info->version.minor,
16516 p_info->version.update,
16517 p_info->version.draft);
16518 printf("Profile name: %s\n\n", p_info->name);
16526 printf("Failed to get ddp list\n");
16529 cmdline_parse_inst_t cmd_ddp_get_list = {
16530 .f = cmd_ddp_get_list_parsed,
16532 .help_str = "ddp get list <port_id>",
16534 (void *)&cmd_ddp_get_list_ddp,
16535 (void *)&cmd_ddp_get_list_get,
16536 (void *)&cmd_ddp_get_list_list,
16537 (void *)&cmd_ddp_get_list_port_id,
16542 /* Configure input set */
16543 struct cmd_cfg_input_set_result {
16544 cmdline_fixed_string_t port;
16545 cmdline_fixed_string_t cfg;
16547 cmdline_fixed_string_t pctype;
16549 cmdline_fixed_string_t inset_type;
16550 cmdline_fixed_string_t opt;
16551 cmdline_fixed_string_t field;
16556 cmd_cfg_input_set_parsed(
16557 __attribute__((unused)) void *parsed_result,
16558 __attribute__((unused)) struct cmdline *cl,
16559 __attribute__((unused)) void *data)
16561 #ifdef RTE_LIBRTE_I40E_PMD
16562 struct cmd_cfg_input_set_result *res = parsed_result;
16563 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
16564 struct rte_pmd_i40e_inset inset;
16566 int ret = -ENOTSUP;
16568 if (!all_ports_stopped()) {
16569 printf("Please stop all ports first\n");
16573 #ifdef RTE_LIBRTE_I40E_PMD
16574 if (!strcmp(res->inset_type, "hash_inset"))
16575 inset_type = INSET_HASH;
16576 else if (!strcmp(res->inset_type, "fdir_inset"))
16577 inset_type = INSET_FDIR;
16578 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
16579 inset_type = INSET_FDIR_FLX;
16580 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
16581 &inset, inset_type);
16583 printf("Failed to get input set.\n");
16587 if (!strcmp(res->opt, "get")) {
16588 ret = rte_pmd_i40e_inset_field_get(inset.inset,
16591 printf("Field index %d is enabled.\n", res->field_idx);
16593 printf("Field index %d is disabled.\n", res->field_idx);
16595 } else if (!strcmp(res->opt, "set"))
16596 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
16598 else if (!strcmp(res->opt, "clear"))
16599 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
16602 printf("Failed to configure input set field.\n");
16606 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
16607 &inset, inset_type);
16609 printf("Failed to set input set.\n");
16614 if (ret == -ENOTSUP)
16615 printf("Function not supported\n");
16618 cmdline_parse_token_string_t cmd_cfg_input_set_port =
16619 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16621 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
16622 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16624 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
16625 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16627 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
16628 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16630 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
16631 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16633 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
16634 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16636 "hash_inset#fdir_inset#fdir_flx_inset");
16637 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
16638 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16639 opt, "get#set#clear");
16640 cmdline_parse_token_string_t cmd_cfg_input_set_field =
16641 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16643 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
16644 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16647 cmdline_parse_inst_t cmd_cfg_input_set = {
16648 .f = cmd_cfg_input_set_parsed,
16650 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
16651 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
16653 (void *)&cmd_cfg_input_set_port,
16654 (void *)&cmd_cfg_input_set_cfg,
16655 (void *)&cmd_cfg_input_set_port_id,
16656 (void *)&cmd_cfg_input_set_pctype,
16657 (void *)&cmd_cfg_input_set_pctype_id,
16658 (void *)&cmd_cfg_input_set_inset_type,
16659 (void *)&cmd_cfg_input_set_opt,
16660 (void *)&cmd_cfg_input_set_field,
16661 (void *)&cmd_cfg_input_set_field_idx,
16666 /* Clear input set */
16667 struct cmd_clear_input_set_result {
16668 cmdline_fixed_string_t port;
16669 cmdline_fixed_string_t cfg;
16671 cmdline_fixed_string_t pctype;
16673 cmdline_fixed_string_t inset_type;
16674 cmdline_fixed_string_t clear;
16675 cmdline_fixed_string_t all;
16679 cmd_clear_input_set_parsed(
16680 __attribute__((unused)) void *parsed_result,
16681 __attribute__((unused)) struct cmdline *cl,
16682 __attribute__((unused)) void *data)
16684 #ifdef RTE_LIBRTE_I40E_PMD
16685 struct cmd_clear_input_set_result *res = parsed_result;
16686 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
16687 struct rte_pmd_i40e_inset inset;
16689 int ret = -ENOTSUP;
16691 if (!all_ports_stopped()) {
16692 printf("Please stop all ports first\n");
16696 #ifdef RTE_LIBRTE_I40E_PMD
16697 if (!strcmp(res->inset_type, "hash_inset"))
16698 inset_type = INSET_HASH;
16699 else if (!strcmp(res->inset_type, "fdir_inset"))
16700 inset_type = INSET_FDIR;
16701 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
16702 inset_type = INSET_FDIR_FLX;
16704 memset(&inset, 0, sizeof(inset));
16706 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
16707 &inset, inset_type);
16709 printf("Failed to clear input set.\n");
16715 if (ret == -ENOTSUP)
16716 printf("Function not supported\n");
16719 cmdline_parse_token_string_t cmd_clear_input_set_port =
16720 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16722 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
16723 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16725 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
16726 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
16728 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
16729 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16731 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
16732 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
16734 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
16735 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16737 "hash_inset#fdir_inset#fdir_flx_inset");
16738 cmdline_parse_token_string_t cmd_clear_input_set_clear =
16739 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16741 cmdline_parse_token_string_t cmd_clear_input_set_all =
16742 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16745 cmdline_parse_inst_t cmd_clear_input_set = {
16746 .f = cmd_clear_input_set_parsed,
16748 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
16749 "fdir_inset|fdir_flx_inset clear all",
16751 (void *)&cmd_clear_input_set_port,
16752 (void *)&cmd_clear_input_set_cfg,
16753 (void *)&cmd_clear_input_set_port_id,
16754 (void *)&cmd_clear_input_set_pctype,
16755 (void *)&cmd_clear_input_set_pctype_id,
16756 (void *)&cmd_clear_input_set_inset_type,
16757 (void *)&cmd_clear_input_set_clear,
16758 (void *)&cmd_clear_input_set_all,
16763 /* show vf stats */
16765 /* Common result structure for show vf stats */
16766 struct cmd_show_vf_stats_result {
16767 cmdline_fixed_string_t show;
16768 cmdline_fixed_string_t vf;
16769 cmdline_fixed_string_t stats;
16774 /* Common CLI fields show vf stats*/
16775 cmdline_parse_token_string_t cmd_show_vf_stats_show =
16776 TOKEN_STRING_INITIALIZER
16777 (struct cmd_show_vf_stats_result,
16779 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
16780 TOKEN_STRING_INITIALIZER
16781 (struct cmd_show_vf_stats_result,
16783 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
16784 TOKEN_STRING_INITIALIZER
16785 (struct cmd_show_vf_stats_result,
16787 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
16788 TOKEN_NUM_INITIALIZER
16789 (struct cmd_show_vf_stats_result,
16791 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
16792 TOKEN_NUM_INITIALIZER
16793 (struct cmd_show_vf_stats_result,
16797 cmd_show_vf_stats_parsed(
16798 void *parsed_result,
16799 __attribute__((unused)) struct cmdline *cl,
16800 __attribute__((unused)) void *data)
16802 struct cmd_show_vf_stats_result *res = parsed_result;
16803 struct rte_eth_stats stats;
16804 int ret = -ENOTSUP;
16805 static const char *nic_stats_border = "########################";
16807 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16810 memset(&stats, 0, sizeof(stats));
16812 #ifdef RTE_LIBRTE_I40E_PMD
16813 if (ret == -ENOTSUP)
16814 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
16818 #ifdef RTE_LIBRTE_BNXT_PMD
16819 if (ret == -ENOTSUP)
16820 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
16829 printf("invalid vf_id %d\n", res->vf_id);
16832 printf("invalid port_id %d\n", res->port_id);
16835 printf("function not implemented\n");
16838 printf("programming error: (%s)\n", strerror(-ret));
16841 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
16842 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
16844 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
16846 stats.ipackets, stats.imissed, stats.ibytes);
16847 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
16848 printf(" RX-nombuf: %-10"PRIu64"\n",
16850 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
16852 stats.opackets, stats.oerrors, stats.obytes);
16854 printf(" %s############################%s\n",
16855 nic_stats_border, nic_stats_border);
16858 cmdline_parse_inst_t cmd_show_vf_stats = {
16859 .f = cmd_show_vf_stats_parsed,
16861 .help_str = "show vf stats <port_id> <vf_id>",
16863 (void *)&cmd_show_vf_stats_show,
16864 (void *)&cmd_show_vf_stats_vf,
16865 (void *)&cmd_show_vf_stats_stats,
16866 (void *)&cmd_show_vf_stats_port_id,
16867 (void *)&cmd_show_vf_stats_vf_id,
16872 /* clear vf stats */
16874 /* Common result structure for clear vf stats */
16875 struct cmd_clear_vf_stats_result {
16876 cmdline_fixed_string_t clear;
16877 cmdline_fixed_string_t vf;
16878 cmdline_fixed_string_t stats;
16883 /* Common CLI fields clear vf stats*/
16884 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
16885 TOKEN_STRING_INITIALIZER
16886 (struct cmd_clear_vf_stats_result,
16888 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
16889 TOKEN_STRING_INITIALIZER
16890 (struct cmd_clear_vf_stats_result,
16892 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
16893 TOKEN_STRING_INITIALIZER
16894 (struct cmd_clear_vf_stats_result,
16896 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
16897 TOKEN_NUM_INITIALIZER
16898 (struct cmd_clear_vf_stats_result,
16900 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
16901 TOKEN_NUM_INITIALIZER
16902 (struct cmd_clear_vf_stats_result,
16906 cmd_clear_vf_stats_parsed(
16907 void *parsed_result,
16908 __attribute__((unused)) struct cmdline *cl,
16909 __attribute__((unused)) void *data)
16911 struct cmd_clear_vf_stats_result *res = parsed_result;
16912 int ret = -ENOTSUP;
16914 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16917 #ifdef RTE_LIBRTE_I40E_PMD
16918 if (ret == -ENOTSUP)
16919 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
16922 #ifdef RTE_LIBRTE_BNXT_PMD
16923 if (ret == -ENOTSUP)
16924 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
16932 printf("invalid vf_id %d\n", res->vf_id);
16935 printf("invalid port_id %d\n", res->port_id);
16938 printf("function not implemented\n");
16941 printf("programming error: (%s)\n", strerror(-ret));
16945 cmdline_parse_inst_t cmd_clear_vf_stats = {
16946 .f = cmd_clear_vf_stats_parsed,
16948 .help_str = "clear vf stats <port_id> <vf_id>",
16950 (void *)&cmd_clear_vf_stats_clear,
16951 (void *)&cmd_clear_vf_stats_vf,
16952 (void *)&cmd_clear_vf_stats_stats,
16953 (void *)&cmd_clear_vf_stats_port_id,
16954 (void *)&cmd_clear_vf_stats_vf_id,
16959 /* port config pctype mapping reset */
16961 /* Common result structure for port config pctype mapping reset */
16962 struct cmd_pctype_mapping_reset_result {
16963 cmdline_fixed_string_t port;
16964 cmdline_fixed_string_t config;
16966 cmdline_fixed_string_t pctype;
16967 cmdline_fixed_string_t mapping;
16968 cmdline_fixed_string_t reset;
16971 /* Common CLI fields for port config pctype mapping reset*/
16972 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
16973 TOKEN_STRING_INITIALIZER
16974 (struct cmd_pctype_mapping_reset_result,
16976 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
16977 TOKEN_STRING_INITIALIZER
16978 (struct cmd_pctype_mapping_reset_result,
16980 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
16981 TOKEN_NUM_INITIALIZER
16982 (struct cmd_pctype_mapping_reset_result,
16984 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
16985 TOKEN_STRING_INITIALIZER
16986 (struct cmd_pctype_mapping_reset_result,
16988 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
16989 TOKEN_STRING_INITIALIZER
16990 (struct cmd_pctype_mapping_reset_result,
16991 mapping, "mapping");
16992 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
16993 TOKEN_STRING_INITIALIZER
16994 (struct cmd_pctype_mapping_reset_result,
16998 cmd_pctype_mapping_reset_parsed(
16999 void *parsed_result,
17000 __attribute__((unused)) struct cmdline *cl,
17001 __attribute__((unused)) void *data)
17003 struct cmd_pctype_mapping_reset_result *res = parsed_result;
17004 int ret = -ENOTSUP;
17006 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17009 #ifdef RTE_LIBRTE_I40E_PMD
17010 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
17017 printf("invalid port_id %d\n", res->port_id);
17020 printf("function not implemented\n");
17023 printf("programming error: (%s)\n", strerror(-ret));
17027 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
17028 .f = cmd_pctype_mapping_reset_parsed,
17030 .help_str = "port config <port_id> pctype mapping reset",
17032 (void *)&cmd_pctype_mapping_reset_port,
17033 (void *)&cmd_pctype_mapping_reset_config,
17034 (void *)&cmd_pctype_mapping_reset_port_id,
17035 (void *)&cmd_pctype_mapping_reset_pctype,
17036 (void *)&cmd_pctype_mapping_reset_mapping,
17037 (void *)&cmd_pctype_mapping_reset_reset,
17042 /* show port pctype mapping */
17044 /* Common result structure for show port pctype mapping */
17045 struct cmd_pctype_mapping_get_result {
17046 cmdline_fixed_string_t show;
17047 cmdline_fixed_string_t port;
17049 cmdline_fixed_string_t pctype;
17050 cmdline_fixed_string_t mapping;
17053 /* Common CLI fields for pctype mapping get */
17054 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
17055 TOKEN_STRING_INITIALIZER
17056 (struct cmd_pctype_mapping_get_result,
17058 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
17059 TOKEN_STRING_INITIALIZER
17060 (struct cmd_pctype_mapping_get_result,
17062 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
17063 TOKEN_NUM_INITIALIZER
17064 (struct cmd_pctype_mapping_get_result,
17066 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
17067 TOKEN_STRING_INITIALIZER
17068 (struct cmd_pctype_mapping_get_result,
17070 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
17071 TOKEN_STRING_INITIALIZER
17072 (struct cmd_pctype_mapping_get_result,
17073 mapping, "mapping");
17076 cmd_pctype_mapping_get_parsed(
17077 void *parsed_result,
17078 __attribute__((unused)) struct cmdline *cl,
17079 __attribute__((unused)) void *data)
17081 struct cmd_pctype_mapping_get_result *res = parsed_result;
17082 int ret = -ENOTSUP;
17083 #ifdef RTE_LIBRTE_I40E_PMD
17084 struct rte_pmd_i40e_flow_type_mapping
17085 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
17086 int i, j, first_pctype;
17089 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17092 #ifdef RTE_LIBRTE_I40E_PMD
17093 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
17100 printf("invalid port_id %d\n", res->port_id);
17103 printf("function not implemented\n");
17106 printf("programming error: (%s)\n", strerror(-ret));
17110 #ifdef RTE_LIBRTE_I40E_PMD
17111 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
17112 if (mapping[i].pctype != 0ULL) {
17115 printf("pctype: ");
17116 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
17117 if (mapping[i].pctype & (1ULL << j)) {
17118 printf(first_pctype ?
17119 "%02d" : ",%02d", j);
17123 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
17129 cmdline_parse_inst_t cmd_pctype_mapping_get = {
17130 .f = cmd_pctype_mapping_get_parsed,
17132 .help_str = "show port <port_id> pctype mapping",
17134 (void *)&cmd_pctype_mapping_get_show,
17135 (void *)&cmd_pctype_mapping_get_port,
17136 (void *)&cmd_pctype_mapping_get_port_id,
17137 (void *)&cmd_pctype_mapping_get_pctype,
17138 (void *)&cmd_pctype_mapping_get_mapping,
17143 /* port config pctype mapping update */
17145 /* Common result structure for port config pctype mapping update */
17146 struct cmd_pctype_mapping_update_result {
17147 cmdline_fixed_string_t port;
17148 cmdline_fixed_string_t config;
17150 cmdline_fixed_string_t pctype;
17151 cmdline_fixed_string_t mapping;
17152 cmdline_fixed_string_t update;
17153 cmdline_fixed_string_t pctype_list;
17154 uint16_t flow_type;
17157 /* Common CLI fields for pctype mapping update*/
17158 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
17159 TOKEN_STRING_INITIALIZER
17160 (struct cmd_pctype_mapping_update_result,
17162 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
17163 TOKEN_STRING_INITIALIZER
17164 (struct cmd_pctype_mapping_update_result,
17166 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
17167 TOKEN_NUM_INITIALIZER
17168 (struct cmd_pctype_mapping_update_result,
17170 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
17171 TOKEN_STRING_INITIALIZER
17172 (struct cmd_pctype_mapping_update_result,
17174 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
17175 TOKEN_STRING_INITIALIZER
17176 (struct cmd_pctype_mapping_update_result,
17177 mapping, "mapping");
17178 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
17179 TOKEN_STRING_INITIALIZER
17180 (struct cmd_pctype_mapping_update_result,
17182 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
17183 TOKEN_STRING_INITIALIZER
17184 (struct cmd_pctype_mapping_update_result,
17185 pctype_list, NULL);
17186 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
17187 TOKEN_NUM_INITIALIZER
17188 (struct cmd_pctype_mapping_update_result,
17189 flow_type, UINT16);
17192 cmd_pctype_mapping_update_parsed(
17193 void *parsed_result,
17194 __attribute__((unused)) struct cmdline *cl,
17195 __attribute__((unused)) void *data)
17197 struct cmd_pctype_mapping_update_result *res = parsed_result;
17198 int ret = -ENOTSUP;
17199 #ifdef RTE_LIBRTE_I40E_PMD
17200 struct rte_pmd_i40e_flow_type_mapping mapping;
17202 unsigned int nb_item;
17203 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
17206 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17209 #ifdef RTE_LIBRTE_I40E_PMD
17210 nb_item = parse_item_list(res->pctype_list, "pctypes",
17211 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
17212 mapping.flow_type = res->flow_type;
17213 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
17214 mapping.pctype |= (1ULL << pctype_list[i]);
17215 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
17225 printf("invalid pctype or flow type\n");
17228 printf("invalid port_id %d\n", res->port_id);
17231 printf("function not implemented\n");
17234 printf("programming error: (%s)\n", strerror(-ret));
17238 cmdline_parse_inst_t cmd_pctype_mapping_update = {
17239 .f = cmd_pctype_mapping_update_parsed,
17241 .help_str = "port config <port_id> pctype mapping update"
17242 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
17244 (void *)&cmd_pctype_mapping_update_port,
17245 (void *)&cmd_pctype_mapping_update_config,
17246 (void *)&cmd_pctype_mapping_update_port_id,
17247 (void *)&cmd_pctype_mapping_update_pctype,
17248 (void *)&cmd_pctype_mapping_update_mapping,
17249 (void *)&cmd_pctype_mapping_update_update,
17250 (void *)&cmd_pctype_mapping_update_pc_type,
17251 (void *)&cmd_pctype_mapping_update_flow_type,
17256 /* ptype mapping get */
17258 /* Common result structure for ptype mapping get */
17259 struct cmd_ptype_mapping_get_result {
17260 cmdline_fixed_string_t ptype;
17261 cmdline_fixed_string_t mapping;
17262 cmdline_fixed_string_t get;
17264 uint8_t valid_only;
17267 /* Common CLI fields for ptype mapping get */
17268 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
17269 TOKEN_STRING_INITIALIZER
17270 (struct cmd_ptype_mapping_get_result,
17272 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
17273 TOKEN_STRING_INITIALIZER
17274 (struct cmd_ptype_mapping_get_result,
17275 mapping, "mapping");
17276 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
17277 TOKEN_STRING_INITIALIZER
17278 (struct cmd_ptype_mapping_get_result,
17280 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
17281 TOKEN_NUM_INITIALIZER
17282 (struct cmd_ptype_mapping_get_result,
17284 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
17285 TOKEN_NUM_INITIALIZER
17286 (struct cmd_ptype_mapping_get_result,
17287 valid_only, UINT8);
17290 cmd_ptype_mapping_get_parsed(
17291 void *parsed_result,
17292 __attribute__((unused)) struct cmdline *cl,
17293 __attribute__((unused)) void *data)
17295 struct cmd_ptype_mapping_get_result *res = parsed_result;
17296 int ret = -ENOTSUP;
17297 #ifdef RTE_LIBRTE_I40E_PMD
17298 int max_ptype_num = 256;
17299 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
17304 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17307 #ifdef RTE_LIBRTE_I40E_PMD
17308 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
17319 printf("invalid port_id %d\n", res->port_id);
17322 printf("function not implemented\n");
17325 printf("programming error: (%s)\n", strerror(-ret));
17328 #ifdef RTE_LIBRTE_I40E_PMD
17330 for (i = 0; i < count; i++)
17331 printf("%3d\t0x%08x\n",
17332 mapping[i].hw_ptype, mapping[i].sw_ptype);
17337 cmdline_parse_inst_t cmd_ptype_mapping_get = {
17338 .f = cmd_ptype_mapping_get_parsed,
17340 .help_str = "ptype mapping get <port_id> <valid_only>",
17342 (void *)&cmd_ptype_mapping_get_ptype,
17343 (void *)&cmd_ptype_mapping_get_mapping,
17344 (void *)&cmd_ptype_mapping_get_get,
17345 (void *)&cmd_ptype_mapping_get_port_id,
17346 (void *)&cmd_ptype_mapping_get_valid_only,
17351 /* ptype mapping replace */
17353 /* Common result structure for ptype mapping replace */
17354 struct cmd_ptype_mapping_replace_result {
17355 cmdline_fixed_string_t ptype;
17356 cmdline_fixed_string_t mapping;
17357 cmdline_fixed_string_t replace;
17364 /* Common CLI fields for ptype mapping replace */
17365 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
17366 TOKEN_STRING_INITIALIZER
17367 (struct cmd_ptype_mapping_replace_result,
17369 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
17370 TOKEN_STRING_INITIALIZER
17371 (struct cmd_ptype_mapping_replace_result,
17372 mapping, "mapping");
17373 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
17374 TOKEN_STRING_INITIALIZER
17375 (struct cmd_ptype_mapping_replace_result,
17376 replace, "replace");
17377 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
17378 TOKEN_NUM_INITIALIZER
17379 (struct cmd_ptype_mapping_replace_result,
17381 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
17382 TOKEN_NUM_INITIALIZER
17383 (struct cmd_ptype_mapping_replace_result,
17385 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
17386 TOKEN_NUM_INITIALIZER
17387 (struct cmd_ptype_mapping_replace_result,
17389 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
17390 TOKEN_NUM_INITIALIZER
17391 (struct cmd_ptype_mapping_replace_result,
17395 cmd_ptype_mapping_replace_parsed(
17396 void *parsed_result,
17397 __attribute__((unused)) struct cmdline *cl,
17398 __attribute__((unused)) void *data)
17400 struct cmd_ptype_mapping_replace_result *res = parsed_result;
17401 int ret = -ENOTSUP;
17403 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17406 #ifdef RTE_LIBRTE_I40E_PMD
17407 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
17417 printf("invalid ptype 0x%8x or 0x%8x\n",
17418 res->target, res->pkt_type);
17421 printf("invalid port_id %d\n", res->port_id);
17424 printf("function not implemented\n");
17427 printf("programming error: (%s)\n", strerror(-ret));
17431 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
17432 .f = cmd_ptype_mapping_replace_parsed,
17435 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
17437 (void *)&cmd_ptype_mapping_replace_ptype,
17438 (void *)&cmd_ptype_mapping_replace_mapping,
17439 (void *)&cmd_ptype_mapping_replace_replace,
17440 (void *)&cmd_ptype_mapping_replace_port_id,
17441 (void *)&cmd_ptype_mapping_replace_target,
17442 (void *)&cmd_ptype_mapping_replace_mask,
17443 (void *)&cmd_ptype_mapping_replace_pkt_type,
17448 /* ptype mapping reset */
17450 /* Common result structure for ptype mapping reset */
17451 struct cmd_ptype_mapping_reset_result {
17452 cmdline_fixed_string_t ptype;
17453 cmdline_fixed_string_t mapping;
17454 cmdline_fixed_string_t reset;
17458 /* Common CLI fields for ptype mapping reset*/
17459 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
17460 TOKEN_STRING_INITIALIZER
17461 (struct cmd_ptype_mapping_reset_result,
17463 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
17464 TOKEN_STRING_INITIALIZER
17465 (struct cmd_ptype_mapping_reset_result,
17466 mapping, "mapping");
17467 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
17468 TOKEN_STRING_INITIALIZER
17469 (struct cmd_ptype_mapping_reset_result,
17471 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
17472 TOKEN_NUM_INITIALIZER
17473 (struct cmd_ptype_mapping_reset_result,
17477 cmd_ptype_mapping_reset_parsed(
17478 void *parsed_result,
17479 __attribute__((unused)) struct cmdline *cl,
17480 __attribute__((unused)) void *data)
17482 struct cmd_ptype_mapping_reset_result *res = parsed_result;
17483 int ret = -ENOTSUP;
17485 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17488 #ifdef RTE_LIBRTE_I40E_PMD
17489 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
17496 printf("invalid port_id %d\n", res->port_id);
17499 printf("function not implemented\n");
17502 printf("programming error: (%s)\n", strerror(-ret));
17506 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
17507 .f = cmd_ptype_mapping_reset_parsed,
17509 .help_str = "ptype mapping reset <port_id>",
17511 (void *)&cmd_ptype_mapping_reset_ptype,
17512 (void *)&cmd_ptype_mapping_reset_mapping,
17513 (void *)&cmd_ptype_mapping_reset_reset,
17514 (void *)&cmd_ptype_mapping_reset_port_id,
17519 /* ptype mapping update */
17521 /* Common result structure for ptype mapping update */
17522 struct cmd_ptype_mapping_update_result {
17523 cmdline_fixed_string_t ptype;
17524 cmdline_fixed_string_t mapping;
17525 cmdline_fixed_string_t reset;
17531 /* Common CLI fields for ptype mapping update*/
17532 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
17533 TOKEN_STRING_INITIALIZER
17534 (struct cmd_ptype_mapping_update_result,
17536 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
17537 TOKEN_STRING_INITIALIZER
17538 (struct cmd_ptype_mapping_update_result,
17539 mapping, "mapping");
17540 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
17541 TOKEN_STRING_INITIALIZER
17542 (struct cmd_ptype_mapping_update_result,
17544 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
17545 TOKEN_NUM_INITIALIZER
17546 (struct cmd_ptype_mapping_update_result,
17548 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
17549 TOKEN_NUM_INITIALIZER
17550 (struct cmd_ptype_mapping_update_result,
17552 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
17553 TOKEN_NUM_INITIALIZER
17554 (struct cmd_ptype_mapping_update_result,
17558 cmd_ptype_mapping_update_parsed(
17559 void *parsed_result,
17560 __attribute__((unused)) struct cmdline *cl,
17561 __attribute__((unused)) void *data)
17563 struct cmd_ptype_mapping_update_result *res = parsed_result;
17564 int ret = -ENOTSUP;
17565 #ifdef RTE_LIBRTE_I40E_PMD
17566 struct rte_pmd_i40e_ptype_mapping mapping;
17568 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17571 #ifdef RTE_LIBRTE_I40E_PMD
17572 mapping.hw_ptype = res->hw_ptype;
17573 mapping.sw_ptype = res->sw_ptype;
17574 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
17584 printf("invalid ptype 0x%8x\n", res->sw_ptype);
17587 printf("invalid port_id %d\n", res->port_id);
17590 printf("function not implemented\n");
17593 printf("programming error: (%s)\n", strerror(-ret));
17597 cmdline_parse_inst_t cmd_ptype_mapping_update = {
17598 .f = cmd_ptype_mapping_update_parsed,
17600 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
17602 (void *)&cmd_ptype_mapping_update_ptype,
17603 (void *)&cmd_ptype_mapping_update_mapping,
17604 (void *)&cmd_ptype_mapping_update_update,
17605 (void *)&cmd_ptype_mapping_update_port_id,
17606 (void *)&cmd_ptype_mapping_update_hw_ptype,
17607 (void *)&cmd_ptype_mapping_update_sw_ptype,
17612 /* Common result structure for file commands */
17613 struct cmd_cmdfile_result {
17614 cmdline_fixed_string_t load;
17615 cmdline_fixed_string_t filename;
17618 /* Common CLI fields for file commands */
17619 cmdline_parse_token_string_t cmd_load_cmdfile =
17620 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
17621 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
17622 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
17625 cmd_load_from_file_parsed(
17626 void *parsed_result,
17627 __attribute__((unused)) struct cmdline *cl,
17628 __attribute__((unused)) void *data)
17630 struct cmd_cmdfile_result *res = parsed_result;
17632 cmdline_read_from_file(res->filename);
17635 cmdline_parse_inst_t cmd_load_from_file = {
17636 .f = cmd_load_from_file_parsed,
17638 .help_str = "load <filename>",
17640 (void *)&cmd_load_cmdfile,
17641 (void *)&cmd_load_cmdfile_filename,
17646 /* Get Rx offloads capabilities */
17647 struct cmd_rx_offload_get_capa_result {
17648 cmdline_fixed_string_t show;
17649 cmdline_fixed_string_t port;
17651 cmdline_fixed_string_t rx_offload;
17652 cmdline_fixed_string_t capabilities;
17655 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
17656 TOKEN_STRING_INITIALIZER
17657 (struct cmd_rx_offload_get_capa_result,
17659 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
17660 TOKEN_STRING_INITIALIZER
17661 (struct cmd_rx_offload_get_capa_result,
17663 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
17664 TOKEN_NUM_INITIALIZER
17665 (struct cmd_rx_offload_get_capa_result,
17667 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
17668 TOKEN_STRING_INITIALIZER
17669 (struct cmd_rx_offload_get_capa_result,
17670 rx_offload, "rx_offload");
17671 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
17672 TOKEN_STRING_INITIALIZER
17673 (struct cmd_rx_offload_get_capa_result,
17674 capabilities, "capabilities");
17677 print_rx_offloads(uint64_t offloads)
17679 uint64_t single_offload;
17687 begin = __builtin_ctzll(offloads);
17688 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
17690 single_offload = 1 << begin;
17691 for (bit = begin; bit < end; bit++) {
17692 if (offloads & single_offload)
17694 rte_eth_dev_rx_offload_name(single_offload));
17695 single_offload <<= 1;
17700 cmd_rx_offload_get_capa_parsed(
17701 void *parsed_result,
17702 __attribute__((unused)) struct cmdline *cl,
17703 __attribute__((unused)) void *data)
17705 struct cmd_rx_offload_get_capa_result *res = parsed_result;
17706 struct rte_eth_dev_info dev_info;
17707 portid_t port_id = res->port_id;
17708 uint64_t queue_offloads;
17709 uint64_t port_offloads;
17711 rte_eth_dev_info_get(port_id, &dev_info);
17712 queue_offloads = dev_info.rx_queue_offload_capa;
17713 port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
17715 printf("Rx Offloading Capabilities of port %d :\n", port_id);
17716 printf(" Per Queue :");
17717 print_rx_offloads(queue_offloads);
17720 printf(" Per Port :");
17721 print_rx_offloads(port_offloads);
17725 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
17726 .f = cmd_rx_offload_get_capa_parsed,
17728 .help_str = "show port <port_id> rx_offload capabilities",
17730 (void *)&cmd_rx_offload_get_capa_show,
17731 (void *)&cmd_rx_offload_get_capa_port,
17732 (void *)&cmd_rx_offload_get_capa_port_id,
17733 (void *)&cmd_rx_offload_get_capa_rx_offload,
17734 (void *)&cmd_rx_offload_get_capa_capabilities,
17739 /* Get Rx offloads configuration */
17740 struct cmd_rx_offload_get_configuration_result {
17741 cmdline_fixed_string_t show;
17742 cmdline_fixed_string_t port;
17744 cmdline_fixed_string_t rx_offload;
17745 cmdline_fixed_string_t configuration;
17748 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
17749 TOKEN_STRING_INITIALIZER
17750 (struct cmd_rx_offload_get_configuration_result,
17752 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
17753 TOKEN_STRING_INITIALIZER
17754 (struct cmd_rx_offload_get_configuration_result,
17756 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
17757 TOKEN_NUM_INITIALIZER
17758 (struct cmd_rx_offload_get_configuration_result,
17760 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
17761 TOKEN_STRING_INITIALIZER
17762 (struct cmd_rx_offload_get_configuration_result,
17763 rx_offload, "rx_offload");
17764 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
17765 TOKEN_STRING_INITIALIZER
17766 (struct cmd_rx_offload_get_configuration_result,
17767 configuration, "configuration");
17770 cmd_rx_offload_get_configuration_parsed(
17771 void *parsed_result,
17772 __attribute__((unused)) struct cmdline *cl,
17773 __attribute__((unused)) void *data)
17775 struct cmd_rx_offload_get_configuration_result *res = parsed_result;
17776 struct rte_eth_dev_info dev_info;
17777 portid_t port_id = res->port_id;
17778 struct rte_port *port = &ports[port_id];
17779 uint64_t port_offloads;
17780 uint64_t queue_offloads;
17781 uint16_t nb_rx_queues;
17784 printf("Rx Offloading Configuration of port %d :\n", port_id);
17786 port_offloads = port->dev_conf.rxmode.offloads;
17788 print_rx_offloads(port_offloads);
17791 rte_eth_dev_info_get(port_id, &dev_info);
17792 nb_rx_queues = dev_info.nb_rx_queues;
17793 for (q = 0; q < nb_rx_queues; q++) {
17794 queue_offloads = port->rx_conf[q].offloads;
17795 printf(" Queue[%2d] :", q);
17796 print_rx_offloads(queue_offloads);
17802 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
17803 .f = cmd_rx_offload_get_configuration_parsed,
17805 .help_str = "show port <port_id> rx_offload configuration",
17807 (void *)&cmd_rx_offload_get_configuration_show,
17808 (void *)&cmd_rx_offload_get_configuration_port,
17809 (void *)&cmd_rx_offload_get_configuration_port_id,
17810 (void *)&cmd_rx_offload_get_configuration_rx_offload,
17811 (void *)&cmd_rx_offload_get_configuration_configuration,
17816 /* Enable/Disable a per port offloading */
17817 struct cmd_config_per_port_rx_offload_result {
17818 cmdline_fixed_string_t port;
17819 cmdline_fixed_string_t config;
17821 cmdline_fixed_string_t rx_offload;
17822 cmdline_fixed_string_t offload;
17823 cmdline_fixed_string_t on_off;
17826 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
17827 TOKEN_STRING_INITIALIZER
17828 (struct cmd_config_per_port_rx_offload_result,
17830 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
17831 TOKEN_STRING_INITIALIZER
17832 (struct cmd_config_per_port_rx_offload_result,
17834 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
17835 TOKEN_NUM_INITIALIZER
17836 (struct cmd_config_per_port_rx_offload_result,
17838 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
17839 TOKEN_STRING_INITIALIZER
17840 (struct cmd_config_per_port_rx_offload_result,
17841 rx_offload, "rx_offload");
17842 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
17843 TOKEN_STRING_INITIALIZER
17844 (struct cmd_config_per_port_rx_offload_result,
17845 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
17846 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
17847 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
17848 "crc_strip#scatter#timestamp#security#keep_crc");
17849 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
17850 TOKEN_STRING_INITIALIZER
17851 (struct cmd_config_per_port_rx_offload_result,
17855 search_rx_offload(const char *name)
17857 uint64_t single_offload;
17858 const char *single_name;
17862 single_offload = 1;
17863 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
17864 single_name = rte_eth_dev_rx_offload_name(single_offload);
17865 if (!strcasecmp(single_name, name)) {
17869 single_offload <<= 1;
17873 return single_offload;
17879 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
17880 __attribute__((unused)) struct cmdline *cl,
17881 __attribute__((unused)) void *data)
17883 struct cmd_config_per_port_rx_offload_result *res = parsed_result;
17884 portid_t port_id = res->port_id;
17885 struct rte_eth_dev_info dev_info;
17886 struct rte_port *port = &ports[port_id];
17887 uint64_t single_offload;
17888 uint16_t nb_rx_queues;
17891 if (port->port_status != RTE_PORT_STOPPED) {
17892 printf("Error: Can't config offload when Port %d "
17893 "is not stopped\n", port_id);
17897 single_offload = search_rx_offload(res->offload);
17898 if (single_offload == 0) {
17899 printf("Unknown offload name: %s\n", res->offload);
17903 rte_eth_dev_info_get(port_id, &dev_info);
17904 nb_rx_queues = dev_info.nb_rx_queues;
17905 if (!strcmp(res->on_off, "on")) {
17906 port->dev_conf.rxmode.offloads |= single_offload;
17907 for (q = 0; q < nb_rx_queues; q++)
17908 port->rx_conf[q].offloads |= single_offload;
17910 port->dev_conf.rxmode.offloads &= ~single_offload;
17911 for (q = 0; q < nb_rx_queues; q++)
17912 port->rx_conf[q].offloads &= ~single_offload;
17915 cmd_reconfig_device_queue(port_id, 1, 1);
17918 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
17919 .f = cmd_config_per_port_rx_offload_parsed,
17921 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
17922 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
17923 "macsec_strip|header_split|vlan_filter|vlan_extend|"
17924 "jumbo_frame|crc_strip|scatter|timestamp|security|keep_crc "
17927 (void *)&cmd_config_per_port_rx_offload_result_port,
17928 (void *)&cmd_config_per_port_rx_offload_result_config,
17929 (void *)&cmd_config_per_port_rx_offload_result_port_id,
17930 (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
17931 (void *)&cmd_config_per_port_rx_offload_result_offload,
17932 (void *)&cmd_config_per_port_rx_offload_result_on_off,
17937 /* Enable/Disable a per queue offloading */
17938 struct cmd_config_per_queue_rx_offload_result {
17939 cmdline_fixed_string_t port;
17941 cmdline_fixed_string_t rxq;
17943 cmdline_fixed_string_t rx_offload;
17944 cmdline_fixed_string_t offload;
17945 cmdline_fixed_string_t on_off;
17948 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
17949 TOKEN_STRING_INITIALIZER
17950 (struct cmd_config_per_queue_rx_offload_result,
17952 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
17953 TOKEN_NUM_INITIALIZER
17954 (struct cmd_config_per_queue_rx_offload_result,
17956 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
17957 TOKEN_STRING_INITIALIZER
17958 (struct cmd_config_per_queue_rx_offload_result,
17960 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
17961 TOKEN_NUM_INITIALIZER
17962 (struct cmd_config_per_queue_rx_offload_result,
17964 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
17965 TOKEN_STRING_INITIALIZER
17966 (struct cmd_config_per_queue_rx_offload_result,
17967 rx_offload, "rx_offload");
17968 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
17969 TOKEN_STRING_INITIALIZER
17970 (struct cmd_config_per_queue_rx_offload_result,
17971 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
17972 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
17973 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
17974 "crc_strip#scatter#timestamp#security#keep_crc");
17975 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
17976 TOKEN_STRING_INITIALIZER
17977 (struct cmd_config_per_queue_rx_offload_result,
17981 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
17982 __attribute__((unused)) struct cmdline *cl,
17983 __attribute__((unused)) void *data)
17985 struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
17986 struct rte_eth_dev_info dev_info;
17987 portid_t port_id = res->port_id;
17988 uint16_t queue_id = res->queue_id;
17989 struct rte_port *port = &ports[port_id];
17990 uint64_t single_offload;
17992 if (port->port_status != RTE_PORT_STOPPED) {
17993 printf("Error: Can't config offload when Port %d "
17994 "is not stopped\n", port_id);
17998 rte_eth_dev_info_get(port_id, &dev_info);
17999 if (queue_id >= dev_info.nb_rx_queues) {
18000 printf("Error: input queue_id should be 0 ... "
18001 "%d\n", dev_info.nb_rx_queues - 1);
18005 single_offload = search_rx_offload(res->offload);
18006 if (single_offload == 0) {
18007 printf("Unknown offload name: %s\n", res->offload);
18011 if (!strcmp(res->on_off, "on"))
18012 port->rx_conf[queue_id].offloads |= single_offload;
18014 port->rx_conf[queue_id].offloads &= ~single_offload;
18016 cmd_reconfig_device_queue(port_id, 1, 1);
18019 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
18020 .f = cmd_config_per_queue_rx_offload_parsed,
18022 .help_str = "port <port_id> rxq <queue_id> rx_offload "
18023 "vlan_strip|ipv4_cksum|"
18024 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
18025 "macsec_strip|header_split|vlan_filter|vlan_extend|"
18026 "jumbo_frame|crc_strip|scatter|timestamp|security|keep_crc "
18029 (void *)&cmd_config_per_queue_rx_offload_result_port,
18030 (void *)&cmd_config_per_queue_rx_offload_result_port_id,
18031 (void *)&cmd_config_per_queue_rx_offload_result_rxq,
18032 (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
18033 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
18034 (void *)&cmd_config_per_queue_rx_offload_result_offload,
18035 (void *)&cmd_config_per_queue_rx_offload_result_on_off,
18040 /* Get Tx offloads capabilities */
18041 struct cmd_tx_offload_get_capa_result {
18042 cmdline_fixed_string_t show;
18043 cmdline_fixed_string_t port;
18045 cmdline_fixed_string_t tx_offload;
18046 cmdline_fixed_string_t capabilities;
18049 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
18050 TOKEN_STRING_INITIALIZER
18051 (struct cmd_tx_offload_get_capa_result,
18053 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
18054 TOKEN_STRING_INITIALIZER
18055 (struct cmd_tx_offload_get_capa_result,
18057 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
18058 TOKEN_NUM_INITIALIZER
18059 (struct cmd_tx_offload_get_capa_result,
18061 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
18062 TOKEN_STRING_INITIALIZER
18063 (struct cmd_tx_offload_get_capa_result,
18064 tx_offload, "tx_offload");
18065 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
18066 TOKEN_STRING_INITIALIZER
18067 (struct cmd_tx_offload_get_capa_result,
18068 capabilities, "capabilities");
18071 print_tx_offloads(uint64_t offloads)
18073 uint64_t single_offload;
18081 begin = __builtin_ctzll(offloads);
18082 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
18084 single_offload = 1 << begin;
18085 for (bit = begin; bit < end; bit++) {
18086 if (offloads & single_offload)
18088 rte_eth_dev_tx_offload_name(single_offload));
18089 single_offload <<= 1;
18094 cmd_tx_offload_get_capa_parsed(
18095 void *parsed_result,
18096 __attribute__((unused)) struct cmdline *cl,
18097 __attribute__((unused)) void *data)
18099 struct cmd_tx_offload_get_capa_result *res = parsed_result;
18100 struct rte_eth_dev_info dev_info;
18101 portid_t port_id = res->port_id;
18102 uint64_t queue_offloads;
18103 uint64_t port_offloads;
18105 rte_eth_dev_info_get(port_id, &dev_info);
18106 queue_offloads = dev_info.tx_queue_offload_capa;
18107 port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
18109 printf("Tx Offloading Capabilities of port %d :\n", port_id);
18110 printf(" Per Queue :");
18111 print_tx_offloads(queue_offloads);
18114 printf(" Per Port :");
18115 print_tx_offloads(port_offloads);
18119 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
18120 .f = cmd_tx_offload_get_capa_parsed,
18122 .help_str = "show port <port_id> tx_offload capabilities",
18124 (void *)&cmd_tx_offload_get_capa_show,
18125 (void *)&cmd_tx_offload_get_capa_port,
18126 (void *)&cmd_tx_offload_get_capa_port_id,
18127 (void *)&cmd_tx_offload_get_capa_tx_offload,
18128 (void *)&cmd_tx_offload_get_capa_capabilities,
18133 /* Get Tx offloads configuration */
18134 struct cmd_tx_offload_get_configuration_result {
18135 cmdline_fixed_string_t show;
18136 cmdline_fixed_string_t port;
18138 cmdline_fixed_string_t tx_offload;
18139 cmdline_fixed_string_t configuration;
18142 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
18143 TOKEN_STRING_INITIALIZER
18144 (struct cmd_tx_offload_get_configuration_result,
18146 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
18147 TOKEN_STRING_INITIALIZER
18148 (struct cmd_tx_offload_get_configuration_result,
18150 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
18151 TOKEN_NUM_INITIALIZER
18152 (struct cmd_tx_offload_get_configuration_result,
18154 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
18155 TOKEN_STRING_INITIALIZER
18156 (struct cmd_tx_offload_get_configuration_result,
18157 tx_offload, "tx_offload");
18158 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
18159 TOKEN_STRING_INITIALIZER
18160 (struct cmd_tx_offload_get_configuration_result,
18161 configuration, "configuration");
18164 cmd_tx_offload_get_configuration_parsed(
18165 void *parsed_result,
18166 __attribute__((unused)) struct cmdline *cl,
18167 __attribute__((unused)) void *data)
18169 struct cmd_tx_offload_get_configuration_result *res = parsed_result;
18170 struct rte_eth_dev_info dev_info;
18171 portid_t port_id = res->port_id;
18172 struct rte_port *port = &ports[port_id];
18173 uint64_t port_offloads;
18174 uint64_t queue_offloads;
18175 uint16_t nb_tx_queues;
18178 printf("Tx Offloading Configuration of port %d :\n", port_id);
18180 port_offloads = port->dev_conf.txmode.offloads;
18182 print_tx_offloads(port_offloads);
18185 rte_eth_dev_info_get(port_id, &dev_info);
18186 nb_tx_queues = dev_info.nb_tx_queues;
18187 for (q = 0; q < nb_tx_queues; q++) {
18188 queue_offloads = port->tx_conf[q].offloads;
18189 printf(" Queue[%2d] :", q);
18190 print_tx_offloads(queue_offloads);
18196 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
18197 .f = cmd_tx_offload_get_configuration_parsed,
18199 .help_str = "show port <port_id> tx_offload configuration",
18201 (void *)&cmd_tx_offload_get_configuration_show,
18202 (void *)&cmd_tx_offload_get_configuration_port,
18203 (void *)&cmd_tx_offload_get_configuration_port_id,
18204 (void *)&cmd_tx_offload_get_configuration_tx_offload,
18205 (void *)&cmd_tx_offload_get_configuration_configuration,
18210 /* Enable/Disable a per port offloading */
18211 struct cmd_config_per_port_tx_offload_result {
18212 cmdline_fixed_string_t port;
18213 cmdline_fixed_string_t config;
18215 cmdline_fixed_string_t tx_offload;
18216 cmdline_fixed_string_t offload;
18217 cmdline_fixed_string_t on_off;
18220 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
18221 TOKEN_STRING_INITIALIZER
18222 (struct cmd_config_per_port_tx_offload_result,
18224 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
18225 TOKEN_STRING_INITIALIZER
18226 (struct cmd_config_per_port_tx_offload_result,
18228 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
18229 TOKEN_NUM_INITIALIZER
18230 (struct cmd_config_per_port_tx_offload_result,
18232 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
18233 TOKEN_STRING_INITIALIZER
18234 (struct cmd_config_per_port_tx_offload_result,
18235 tx_offload, "tx_offload");
18236 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
18237 TOKEN_STRING_INITIALIZER
18238 (struct cmd_config_per_port_tx_offload_result,
18239 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18240 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18241 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18242 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18243 "mt_lockfree#multi_segs#mbuf_fast_free#security#"
18245 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
18246 TOKEN_STRING_INITIALIZER
18247 (struct cmd_config_per_port_tx_offload_result,
18251 search_tx_offload(const char *name)
18253 uint64_t single_offload;
18254 const char *single_name;
18258 single_offload = 1;
18259 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
18260 single_name = rte_eth_dev_tx_offload_name(single_offload);
18261 if (!strcasecmp(single_name, name)) {
18264 } else if (!strcasecmp(single_name, "UNKNOWN"))
18266 else if (single_name == NULL)
18268 single_offload <<= 1;
18272 return single_offload;
18278 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
18279 __attribute__((unused)) struct cmdline *cl,
18280 __attribute__((unused)) void *data)
18282 struct cmd_config_per_port_tx_offload_result *res = parsed_result;
18283 portid_t port_id = res->port_id;
18284 struct rte_eth_dev_info dev_info;
18285 struct rte_port *port = &ports[port_id];
18286 uint64_t single_offload;
18287 uint16_t nb_tx_queues;
18290 if (port->port_status != RTE_PORT_STOPPED) {
18291 printf("Error: Can't config offload when Port %d "
18292 "is not stopped\n", port_id);
18296 single_offload = search_tx_offload(res->offload);
18297 if (single_offload == 0) {
18298 printf("Unknown offload name: %s\n", res->offload);
18302 rte_eth_dev_info_get(port_id, &dev_info);
18303 nb_tx_queues = dev_info.nb_tx_queues;
18304 if (!strcmp(res->on_off, "on")) {
18305 port->dev_conf.txmode.offloads |= single_offload;
18306 for (q = 0; q < nb_tx_queues; q++)
18307 port->tx_conf[q].offloads |= single_offload;
18309 port->dev_conf.txmode.offloads &= ~single_offload;
18310 for (q = 0; q < nb_tx_queues; q++)
18311 port->tx_conf[q].offloads &= ~single_offload;
18314 cmd_reconfig_device_queue(port_id, 1, 1);
18317 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
18318 .f = cmd_config_per_port_tx_offload_parsed,
18320 .help_str = "port config <port_id> tx_offload "
18321 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
18322 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
18323 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
18324 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
18325 "mt_lockfree|multi_segs|mbuf_fast_free|security|"
18326 "match_metadata on|off",
18328 (void *)&cmd_config_per_port_tx_offload_result_port,
18329 (void *)&cmd_config_per_port_tx_offload_result_config,
18330 (void *)&cmd_config_per_port_tx_offload_result_port_id,
18331 (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
18332 (void *)&cmd_config_per_port_tx_offload_result_offload,
18333 (void *)&cmd_config_per_port_tx_offload_result_on_off,
18338 /* Enable/Disable a per queue offloading */
18339 struct cmd_config_per_queue_tx_offload_result {
18340 cmdline_fixed_string_t port;
18342 cmdline_fixed_string_t txq;
18344 cmdline_fixed_string_t tx_offload;
18345 cmdline_fixed_string_t offload;
18346 cmdline_fixed_string_t on_off;
18349 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
18350 TOKEN_STRING_INITIALIZER
18351 (struct cmd_config_per_queue_tx_offload_result,
18353 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
18354 TOKEN_NUM_INITIALIZER
18355 (struct cmd_config_per_queue_tx_offload_result,
18357 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
18358 TOKEN_STRING_INITIALIZER
18359 (struct cmd_config_per_queue_tx_offload_result,
18361 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
18362 TOKEN_NUM_INITIALIZER
18363 (struct cmd_config_per_queue_tx_offload_result,
18365 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
18366 TOKEN_STRING_INITIALIZER
18367 (struct cmd_config_per_queue_tx_offload_result,
18368 tx_offload, "tx_offload");
18369 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
18370 TOKEN_STRING_INITIALIZER
18371 (struct cmd_config_per_queue_tx_offload_result,
18372 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18373 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18374 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18375 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18376 "mt_lockfree#multi_segs#mbuf_fast_free#security");
18377 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
18378 TOKEN_STRING_INITIALIZER
18379 (struct cmd_config_per_queue_tx_offload_result,
18383 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
18384 __attribute__((unused)) struct cmdline *cl,
18385 __attribute__((unused)) void *data)
18387 struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
18388 struct rte_eth_dev_info dev_info;
18389 portid_t port_id = res->port_id;
18390 uint16_t queue_id = res->queue_id;
18391 struct rte_port *port = &ports[port_id];
18392 uint64_t single_offload;
18394 if (port->port_status != RTE_PORT_STOPPED) {
18395 printf("Error: Can't config offload when Port %d "
18396 "is not stopped\n", port_id);
18400 rte_eth_dev_info_get(port_id, &dev_info);
18401 if (queue_id >= dev_info.nb_tx_queues) {
18402 printf("Error: input queue_id should be 0 ... "
18403 "%d\n", dev_info.nb_tx_queues - 1);
18407 single_offload = search_tx_offload(res->offload);
18408 if (single_offload == 0) {
18409 printf("Unknown offload name: %s\n", res->offload);
18413 if (!strcmp(res->on_off, "on"))
18414 port->tx_conf[queue_id].offloads |= single_offload;
18416 port->tx_conf[queue_id].offloads &= ~single_offload;
18418 cmd_reconfig_device_queue(port_id, 1, 1);
18421 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
18422 .f = cmd_config_per_queue_tx_offload_parsed,
18424 .help_str = "port <port_id> txq <queue_id> tx_offload "
18425 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
18426 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
18427 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
18428 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
18429 "mt_lockfree|multi_segs|mbuf_fast_free|security "
18432 (void *)&cmd_config_per_queue_tx_offload_result_port,
18433 (void *)&cmd_config_per_queue_tx_offload_result_port_id,
18434 (void *)&cmd_config_per_queue_tx_offload_result_txq,
18435 (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
18436 (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
18437 (void *)&cmd_config_per_queue_tx_offload_result_offload,
18438 (void *)&cmd_config_per_queue_tx_offload_result_on_off,
18443 /* *** configure tx_metadata for specific port *** */
18444 struct cmd_config_tx_metadata_specific_result {
18445 cmdline_fixed_string_t port;
18446 cmdline_fixed_string_t keyword;
18448 cmdline_fixed_string_t item;
18453 cmd_config_tx_metadata_specific_parsed(void *parsed_result,
18454 __attribute__((unused)) struct cmdline *cl,
18455 __attribute__((unused)) void *data)
18457 struct cmd_config_tx_metadata_specific_result *res = parsed_result;
18459 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
18461 ports[res->port_id].tx_metadata = rte_cpu_to_be_32(res->value);
18462 /* Add/remove callback to insert valid metadata in every Tx packet. */
18463 if (ports[res->port_id].tx_metadata)
18464 add_tx_md_callback(res->port_id);
18466 remove_tx_md_callback(res->port_id);
18469 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
18470 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18472 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
18473 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18474 keyword, "config");
18475 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
18476 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18478 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
18479 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18480 item, "tx_metadata");
18481 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
18482 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18485 cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
18486 .f = cmd_config_tx_metadata_specific_parsed,
18488 .help_str = "port config <port_id> tx_metadata <value>",
18490 (void *)&cmd_config_tx_metadata_specific_port,
18491 (void *)&cmd_config_tx_metadata_specific_keyword,
18492 (void *)&cmd_config_tx_metadata_specific_id,
18493 (void *)&cmd_config_tx_metadata_specific_item,
18494 (void *)&cmd_config_tx_metadata_specific_value,
18499 /* *** display tx_metadata per port configuration *** */
18500 struct cmd_show_tx_metadata_result {
18501 cmdline_fixed_string_t cmd_show;
18502 cmdline_fixed_string_t cmd_port;
18503 cmdline_fixed_string_t cmd_keyword;
18508 cmd_show_tx_metadata_parsed(void *parsed_result,
18509 __attribute__((unused)) struct cmdline *cl,
18510 __attribute__((unused)) void *data)
18512 struct cmd_show_tx_metadata_result *res = parsed_result;
18514 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
18515 printf("invalid port id %u\n", res->cmd_pid);
18518 if (!strcmp(res->cmd_keyword, "tx_metadata")) {
18519 printf("Port %u tx_metadata: %u\n", res->cmd_pid,
18520 rte_be_to_cpu_32(ports[res->cmd_pid].tx_metadata));
18524 cmdline_parse_token_string_t cmd_show_tx_metadata_show =
18525 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
18527 cmdline_parse_token_string_t cmd_show_tx_metadata_port =
18528 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
18530 cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
18531 TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
18533 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
18534 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
18535 cmd_keyword, "tx_metadata");
18537 cmdline_parse_inst_t cmd_show_tx_metadata = {
18538 .f = cmd_show_tx_metadata_parsed,
18540 .help_str = "show port <port_id> tx_metadata",
18542 (void *)&cmd_show_tx_metadata_show,
18543 (void *)&cmd_show_tx_metadata_port,
18544 (void *)&cmd_show_tx_metadata_pid,
18545 (void *)&cmd_show_tx_metadata_keyword,
18550 /* ******************************************************************************** */
18552 /* list of instructions */
18553 cmdline_parse_ctx_t main_ctx[] = {
18554 (cmdline_parse_inst_t *)&cmd_help_brief,
18555 (cmdline_parse_inst_t *)&cmd_help_long,
18556 (cmdline_parse_inst_t *)&cmd_quit,
18557 (cmdline_parse_inst_t *)&cmd_load_from_file,
18558 (cmdline_parse_inst_t *)&cmd_showport,
18559 (cmdline_parse_inst_t *)&cmd_showqueue,
18560 (cmdline_parse_inst_t *)&cmd_showportall,
18561 (cmdline_parse_inst_t *)&cmd_showcfg,
18562 (cmdline_parse_inst_t *)&cmd_start,
18563 (cmdline_parse_inst_t *)&cmd_start_tx_first,
18564 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
18565 (cmdline_parse_inst_t *)&cmd_set_link_up,
18566 (cmdline_parse_inst_t *)&cmd_set_link_down,
18567 (cmdline_parse_inst_t *)&cmd_reset,
18568 (cmdline_parse_inst_t *)&cmd_set_numbers,
18569 (cmdline_parse_inst_t *)&cmd_set_log,
18570 (cmdline_parse_inst_t *)&cmd_set_txpkts,
18571 (cmdline_parse_inst_t *)&cmd_set_txsplit,
18572 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
18573 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
18574 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
18575 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
18576 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
18577 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
18578 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
18579 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
18580 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
18581 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
18582 (cmdline_parse_inst_t *)&cmd_set_link_check,
18583 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
18584 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
18585 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
18586 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
18587 #ifdef RTE_LIBRTE_PMD_BOND
18588 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
18589 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
18590 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
18591 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
18592 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
18593 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
18594 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
18595 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
18596 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
18597 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
18598 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
18600 (cmdline_parse_inst_t *)&cmd_vlan_offload,
18601 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
18602 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
18603 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
18604 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
18605 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
18606 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
18607 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
18608 (cmdline_parse_inst_t *)&cmd_csum_set,
18609 (cmdline_parse_inst_t *)&cmd_csum_show,
18610 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
18611 (cmdline_parse_inst_t *)&cmd_tso_set,
18612 (cmdline_parse_inst_t *)&cmd_tso_show,
18613 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
18614 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
18615 (cmdline_parse_inst_t *)&cmd_gro_enable,
18616 (cmdline_parse_inst_t *)&cmd_gro_flush,
18617 (cmdline_parse_inst_t *)&cmd_gro_show,
18618 (cmdline_parse_inst_t *)&cmd_gso_enable,
18619 (cmdline_parse_inst_t *)&cmd_gso_size,
18620 (cmdline_parse_inst_t *)&cmd_gso_show,
18621 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
18622 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
18623 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
18624 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
18625 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
18626 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
18627 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
18628 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
18629 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
18630 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
18631 (cmdline_parse_inst_t *)&cmd_config_dcb,
18632 (cmdline_parse_inst_t *)&cmd_read_reg,
18633 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
18634 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
18635 (cmdline_parse_inst_t *)&cmd_write_reg,
18636 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
18637 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
18638 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
18639 (cmdline_parse_inst_t *)&cmd_stop,
18640 (cmdline_parse_inst_t *)&cmd_mac_addr,
18641 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
18642 (cmdline_parse_inst_t *)&cmd_set_qmap,
18643 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
18644 (cmdline_parse_inst_t *)&cmd_operate_port,
18645 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
18646 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
18647 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
18648 (cmdline_parse_inst_t *)&cmd_set_port_setup_on,
18649 (cmdline_parse_inst_t *)&cmd_config_speed_all,
18650 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
18651 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
18652 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
18653 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
18654 (cmdline_parse_inst_t *)&cmd_config_mtu,
18655 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
18656 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
18657 (cmdline_parse_inst_t *)&cmd_config_rss,
18658 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
18659 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
18660 (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
18661 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
18662 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
18663 (cmdline_parse_inst_t *)&cmd_showport_reta,
18664 (cmdline_parse_inst_t *)&cmd_config_burst,
18665 (cmdline_parse_inst_t *)&cmd_config_thresh,
18666 (cmdline_parse_inst_t *)&cmd_config_threshold,
18667 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
18668 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
18669 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
18670 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
18671 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
18672 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
18673 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
18674 (cmdline_parse_inst_t *)&cmd_global_config,
18675 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
18676 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
18677 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
18678 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
18679 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
18680 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
18681 (cmdline_parse_inst_t *)&cmd_dump,
18682 (cmdline_parse_inst_t *)&cmd_dump_one,
18683 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
18684 (cmdline_parse_inst_t *)&cmd_syn_filter,
18685 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
18686 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
18687 (cmdline_parse_inst_t *)&cmd_flex_filter,
18688 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
18689 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
18690 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
18691 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
18692 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
18693 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
18694 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
18695 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
18696 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
18697 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
18698 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
18699 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
18700 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
18701 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
18702 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
18703 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
18704 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
18705 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
18706 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
18707 (cmdline_parse_inst_t *)&cmd_flow,
18708 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
18709 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
18710 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
18711 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
18712 (cmdline_parse_inst_t *)&cmd_create_port_meter,
18713 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
18714 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
18715 (cmdline_parse_inst_t *)&cmd_del_port_meter,
18716 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
18717 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
18718 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
18719 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
18720 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
18721 (cmdline_parse_inst_t *)&cmd_mcast_addr,
18722 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
18723 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
18724 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
18725 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
18726 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
18727 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
18728 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
18729 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
18730 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
18731 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
18732 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
18733 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
18734 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
18735 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
18736 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
18737 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
18738 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
18739 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
18740 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
18741 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
18742 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
18743 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
18744 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
18745 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
18746 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
18747 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
18748 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
18749 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
18750 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
18751 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
18752 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
18753 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
18754 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
18755 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
18756 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
18757 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
18758 (cmdline_parse_inst_t *)&cmd_set_port_tm_hierarchy_default,
18760 (cmdline_parse_inst_t *)&cmd_set_vxlan,
18761 (cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl,
18762 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
18763 (cmdline_parse_inst_t *)&cmd_set_nvgre,
18764 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
18765 (cmdline_parse_inst_t *)&cmd_set_l2_encap,
18766 (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
18767 (cmdline_parse_inst_t *)&cmd_set_l2_decap,
18768 (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
18769 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
18770 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
18771 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
18772 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
18773 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
18774 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
18775 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
18776 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
18777 (cmdline_parse_inst_t *)&cmd_ddp_add,
18778 (cmdline_parse_inst_t *)&cmd_ddp_del,
18779 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
18780 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
18781 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
18782 (cmdline_parse_inst_t *)&cmd_clear_input_set,
18783 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
18784 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
18785 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
18786 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
18787 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
18788 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
18790 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
18791 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
18792 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
18793 (cmdline_parse_inst_t *)&cmd_queue_region,
18794 (cmdline_parse_inst_t *)&cmd_region_flowtype,
18795 (cmdline_parse_inst_t *)&cmd_user_priority_region,
18796 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
18797 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
18798 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
18799 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
18800 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
18801 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
18802 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
18803 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
18804 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
18805 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
18806 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
18807 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
18808 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
18809 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
18810 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
18811 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
18812 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
18813 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
18814 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
18815 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
18816 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
18817 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
18818 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
18819 (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
18820 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
18821 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
18822 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
18823 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
18824 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
18825 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
18826 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
18827 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
18828 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
18829 #ifdef RTE_LIBRTE_BPF
18830 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
18831 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
18833 (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
18834 (cmdline_parse_inst_t *)&cmd_show_tx_metadata,
18838 /* read cmdline commands from file */
18840 cmdline_read_from_file(const char *filename)
18842 struct cmdline *cl;
18844 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
18846 printf("Failed to create file based cmdline context: %s\n",
18851 cmdline_interact(cl);
18856 printf("Read CLI commands from %s\n", filename);
18859 /* prompt function, called from main on MASTER lcore */
18863 /* initialize non-constant commands */
18864 cmd_set_fwd_mode_init();
18865 cmd_set_fwd_retry_mode_init();
18867 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
18868 if (testpmd_cl == NULL)
18870 cmdline_interact(testpmd_cl);
18871 cmdline_stdin_exit(testpmd_cl);
18877 if (testpmd_cl != NULL)
18878 cmdline_quit(testpmd_cl);
18882 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
18884 if (id == (portid_t)RTE_PORT_ALL) {
18887 RTE_ETH_FOREACH_DEV(pid) {
18888 /* check if need_reconfig has been set to 1 */
18889 if (ports[pid].need_reconfig == 0)
18890 ports[pid].need_reconfig = dev;
18891 /* check if need_reconfig_queues has been set to 1 */
18892 if (ports[pid].need_reconfig_queues == 0)
18893 ports[pid].need_reconfig_queues = queue;
18895 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
18896 /* check if need_reconfig has been set to 1 */
18897 if (ports[id].need_reconfig == 0)
18898 ports[id].need_reconfig = dev;
18899 /* check if need_reconfig_queues has been set to 1 */
18900 if (ports[id].need_reconfig_queues == 0)
18901 ports[id].need_reconfig_queues = queue;